import * as z from 'zod'; /** * Schema for LTI Assignment and Grade Services (AGS) Line Item. * Represents a gradebook column/assignment according to LTI AGS v2.0 specification. * * @see https://www.imsglobal.org/spec/lti-ags/v2p0/#line-item-service */ export const LineItemSchema = z.looseObject({ /** Unique identifier for the line item */ id: z.url(), /** Maximum score possible for this line item */ scoreMaximum: z.number().min(0), /** Human-readable label for the line item */ label: z.string(), /** Optional resource identifier that this line item is associated with */ resourceId: z.string().optional(), /** Optional resource link identifier */ resourceLinkId: z.string().optional(), /** Optional tag to identify the line item */ tag: z.string().optional(), /** Optional start date/time for the assignment */ startDateTime: z.iso.datetime().optional(), /** Optional end date/time for the assignment */ endDateTime: z.iso.datetime().optional(), /** Whether grades should be released to learners. */ gradesReleased: z.boolean().optional(), }); /** * Schema for creating a new LTI Assignment and Grade Services (AGS) Line Item. * Omits the 'id' field since it's generated by the platform upon creation. * * @see https://www.imsglobal.org/spec/lti-ags/v2p0/#line-item-service */ export const CreateLineItemSchema = LineItemSchema.omit({ id: true, }); /** * Schema for updating an existing LTI Assignment and Grade Services (AGS) Line Item. * Omits 'id' and 'resourceLinkId' fields as they are immutable per LTI AGS specification. * Tools MUST NOT change these values during updates. * * @see https://www.imsglobal.org/spec/lti-ags/v2p0/#line-item-service */ export const UpdateLineItemSchema = LineItemSchema.omit({ id: true, resourceLinkId: true, }); /** * Schema for an array of line items returned from the line items service. */ export const LineItemsSchema = z.array(LineItemSchema); // types /** * Type representing a validated line item for LTI AGS. * Represents a gradebook column or assignment. */ export type LineItem = z.infer; /** * Type representing an array of line items. */ export type LineItems = z.infer; /** * Type representing data required to create a new line item for LTI AGS. * Contains all LineItem fields except the platform-generated 'id'. */ export type CreateLineItem = z.infer; /** * Type representing data for updating an existing line item for LTI AGS. * Contains all LineItem fields except immutable 'id' and 'resourceLinkId'. */ export type UpdateLineItem = z.infer;