@conform-ed/contracts 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/.turbo/turbo-format.log +6 -0
  3. package/.turbo/turbo-lint.log +4 -0
  4. package/.turbo/turbo-test.log +196 -0
  5. package/.turbo/turbo-typecheck.log +2 -0
  6. package/README.md +52 -0
  7. package/caliper-v1_2-zod-templates.md +123 -0
  8. package/case-v1_1-zod-templates.md +290 -0
  9. package/cat-v1_0-zod-templates.md +73 -0
  10. package/cc-v1_3-zod-templates.md +531 -0
  11. package/cc-v1_4-zod-templates.md +247 -0
  12. package/clr-v2_0-zod-templates.md +117 -0
  13. package/cmi5-v1_0-zod-templates.md +9 -0
  14. package/lti-zod-templates.md +11 -0
  15. package/oneroster-v1_2-zod-templates.md +76 -0
  16. package/open-badges-v3_0-zod-templates.md +66 -0
  17. package/package.json +42 -0
  18. package/qti-v2_1-zod-templates.md +45 -0
  19. package/qti-v2_2-zod-templates.md +32 -0
  20. package/qti-v3_0_1-zod-templates.md +421 -0
  21. package/src/adapter.ts +83 -0
  22. package/src/caliper/v1_2/caliper_v1p2_bootcamp_schema.ts +781 -0
  23. package/src/caliper/v1_2/index.ts +37 -0
  24. package/src/caliper/v1_2/shared.ts +122 -0
  25. package/src/caliper/v1_2/textual_requirements.ts +219 -0
  26. package/src/case/v1_1/case_v1p1_cfassociation_jsonschema1.ts +1 -0
  27. package/src/case/v1_1/case_v1p1_cfassociationgrouping_jsonschema1.ts +1 -0
  28. package/src/case/v1_1/case_v1p1_cfassociationset_jsonschema1.ts +1 -0
  29. package/src/case/v1_1/case_v1p1_cfconceptset_jsonschema1.ts +1 -0
  30. package/src/case/v1_1/case_v1p1_cfdocument_jsonschema1.ts +1 -0
  31. package/src/case/v1_1/case_v1p1_cfdocumentset_jsonschema1.ts +1 -0
  32. package/src/case/v1_1/case_v1p1_cfitem_jsonschema1.ts +1 -0
  33. package/src/case/v1_1/case_v1p1_cfitemtypeset_jsonschema1.ts +1 -0
  34. package/src/case/v1_1/case_v1p1_cflicense_jsonschema1.ts +1 -0
  35. package/src/case/v1_1/case_v1p1_cfpackage_jsonschema1.ts +1 -0
  36. package/src/case/v1_1/case_v1p1_cfrubric_jsonschema1.ts +1 -0
  37. package/src/case/v1_1/case_v1p1_cfsubjectset_jsonschema1.ts +1 -0
  38. package/src/case/v1_1/case_v1p1_imsx_statusinfo_jsonschema1.ts +1 -0
  39. package/src/case/v1_1/case_v1p1_openapi3_restbinding_schema.ts +113 -0
  40. package/src/case/v1_1/index.ts +95 -0
  41. package/src/case/v1_1/shared.ts +384 -0
  42. package/src/cat/v1_0/cat_v1p0_restbinding_operations_schema.ts +75 -0
  43. package/src/cat/v1_0/index.ts +124 -0
  44. package/src/cat/v1_0/shared.ts +345 -0
  45. package/src/clr/v2_0/clr_v2p0_achievementcredential_schema.ts +16 -0
  46. package/src/clr/v2_0/clr_v2p0_clrcredential_schema.ts +9 -0
  47. package/src/clr/v2_0/clr_v2p0_endorsementcredential_schema.ts +11 -0
  48. package/src/clr/v2_0/clr_v2p0_getclrcredentialsresponse_schema.ts +1 -0
  49. package/src/clr/v2_0/clr_v2p0_imsx_statusinfo_schema.ts +8 -0
  50. package/src/clr/v2_0/clr_v2p0_profile_schema.ts +9 -0
  51. package/src/clr/v2_0/index.ts +22 -0
  52. package/src/clr/v2_0/shared.ts +206 -0
  53. package/src/cmi5/index.ts +3 -0
  54. package/src/cmi5/v1_0/index.ts +134 -0
  55. package/src/common-cartridge/v1_3/ccv1p3_imsccauth_v1p3.ts +26 -0
  56. package/src/common-cartridge/v1_3/ccv1p3_imscp_v1p2_v1p0.ts +352 -0
  57. package/src/common-cartridge/v1_3/ccv1p3_imscsmd_v1p0.ts +35 -0
  58. package/src/common-cartridge/v1_3/ccv1p3_imsdt_v1p3.ts +33 -0
  59. package/src/common-cartridge/v1_3/ccv1p3_imswl_v1p3.ts +23 -0
  60. package/src/common-cartridge/v1_3/ccv1p3_lomccltilink_v1p0.ts +14 -0
  61. package/src/common-cartridge/v1_3/ccv1p3_lommanifest_v1p0.ts +14 -0
  62. package/src/common-cartridge/v1_3/ccv1p3_lomresource_v1p0.ts +14 -0
  63. package/src/common-cartridge/v1_3/ccv1p3_qtiasiv1p2p1_v1p0.ts +964 -0
  64. package/src/common-cartridge/v1_3/index.ts +41 -0
  65. package/src/common-cartridge/v1_3/lom-internal.ts +396 -0
  66. package/src/common-cartridge/v1_3/shared.ts +68 -0
  67. package/src/common-cartridge/v1_4/core/ccv1p4_imscp_v1p2_v1p0.ts +360 -0
  68. package/src/common-cartridge/v1_4/core/ccv1p4_lommanifest_v1p0.ts +14 -0
  69. package/src/common-cartridge/v1_4/core/ccv1p4_lomresource_v1p0.ts +14 -0
  70. package/src/common-cartridge/v1_4/extension/cc_extresource_assignmentv1p0_v1p0.ts +61 -0
  71. package/src/common-cartridge/v1_4/extension/ccv1p4_cpextensionv1p2_v1p0.ts +20 -0
  72. package/src/common-cartridge/v1_4/extension/ims_openvideov1p0_v1p0.ts +325 -0
  73. package/src/common-cartridge/v1_4/index.ts +104 -0
  74. package/src/common-cartridge/v1_4/k12/ccv1p4_imscp_v1p2_v1p0.ts +19 -0
  75. package/src/common-cartridge/v1_4/k12/ccv1p4_imscp_v1p2_v1p0_thin.ts +17 -0
  76. package/src/common-cartridge/v1_4/k12/ccv1p4_lommanifest_v1p0.ts +14 -0
  77. package/src/common-cartridge/v1_4/k12/ccv1p4_lomresource_v1p0.ts +14 -0
  78. package/src/common-cartridge/v1_4/lom-internal.ts +476 -0
  79. package/src/common-cartridge/v1_4/shared/ccv1p4_imsccauth_v1p4.ts +26 -0
  80. package/src/common-cartridge/v1_4/shared/ccv1p4_imscsmd_v1p1.ts +36 -0
  81. package/src/common-cartridge/v1_4/shared/ccv1p4_imsdt_v1p4.ts +33 -0
  82. package/src/common-cartridge/v1_4/shared/ccv1p4_imslticc_v1p4.ts +45 -0
  83. package/src/common-cartridge/v1_4/shared/ccv1p4_imswl_v1p4.ts +23 -0
  84. package/src/common-cartridge/v1_4/shared/ccv1p4_lomccltilink_v1p0.ts +14 -0
  85. package/src/common-cartridge/v1_4/shared/ccv1p4_qtiasiv1p2p1_v1p0.ts +964 -0
  86. package/src/common-cartridge/v1_4/shared/imsbasiclti_v1p0p1.ts +24 -0
  87. package/src/common-cartridge/v1_4/shared/imslticm_v1p0.ts +23 -0
  88. package/src/common-cartridge/v1_4/shared/imslticp_v1p0.ts +57 -0
  89. package/src/common-cartridge/v1_4/shared/lineitem_v1p0.ts +35 -0
  90. package/src/common-cartridge/v1_4/shared/resourcea11ymetadata-20210915.ts +110 -0
  91. package/src/common-cartridge/v1_4/shared.ts +68 -0
  92. package/src/common-cartridge/v1_4/thin/ccv1p4_imscp_v1p2_v1p0.ts +243 -0
  93. package/src/common-cartridge/v1_4/thin/ccv1p4_lommanifest_v1p0.ts +14 -0
  94. package/src/common-cartridge/v1_4/thin/ccv1p4_lomresource_v1p0.ts +14 -0
  95. package/src/common-cartridge/v1_4/vdex/imsmd_loose_v1p3p2.ts +13 -0
  96. package/src/common-cartridge/v1_4/vdex/imsvdex_v1p0.ts +124 -0
  97. package/src/config.ts +121 -0
  98. package/src/index.ts +32 -0
  99. package/src/lti/ags/v2_0/index.ts +97 -0
  100. package/src/lti/deep-linking/v2_0/index.ts +100 -0
  101. package/src/lti/index.ts +26 -0
  102. package/src/lti/nrps/v2_0/index.ts +69 -0
  103. package/src/lti/proctoring/v1_0/index.ts +131 -0
  104. package/src/lti/shared.ts +66 -0
  105. package/src/lti/v1_3/index.ts +84 -0
  106. package/src/oneroster/v1_2/index.ts +156 -0
  107. package/src/oneroster/v1_2/or_v1p2_csv_binding_schema.ts +427 -0
  108. package/src/oneroster/v1_2/or_v1p2_gradebook_restbinding_schema.ts +120 -0
  109. package/src/oneroster/v1_2/or_v1p2_gradebook_service_schema.ts +243 -0
  110. package/src/oneroster/v1_2/or_v1p2_resource_restbinding_schema.ts +24 -0
  111. package/src/oneroster/v1_2/or_v1p2_resource_service_schema.ts +47 -0
  112. package/src/oneroster/v1_2/or_v1p2_rostering_restbinding_schema.ts +84 -0
  113. package/src/oneroster/v1_2/or_v1p2_rostering_service_schema.ts +288 -0
  114. package/src/oneroster/v1_2/shared.ts +90 -0
  115. package/src/open-badges/v3_0/index.ts +20 -0
  116. package/src/open-badges/v3_0/ob_v3p0_achievementcredential_schema.ts +17 -0
  117. package/src/open-badges/v3_0/ob_v3p0_endorsementcredential_schema.ts +11 -0
  118. package/src/open-badges/v3_0/ob_v3p0_getopenbadgecredentialsresponse_schema.ts +1 -0
  119. package/src/open-badges/v3_0/ob_v3p0_imsx_statusinfo_schema.ts +8 -0
  120. package/src/open-badges/v3_0/ob_v3p0_profile_schema.ts +9 -0
  121. package/src/open-badges/v3_0/shared.ts +458 -0
  122. package/src/qti/v2-internal.ts +1683 -0
  123. package/src/qti/v2_1/apipv1p0_qtiextv2p1_v1p0.ts +3 -0
  124. package/src/qti/v2_1/imsqti_metadata_v2p1.ts +3 -0
  125. package/src/qti/v2_1/imsqti_result_v2p1.ts +3 -0
  126. package/src/qti/v2_1/imsqti_usagedata_v2p1.ts +3 -0
  127. package/src/qti/v2_1/imsqti_v2p1p2.ts +71 -0
  128. package/src/qti/v2_1/index.ts +53 -0
  129. package/src/qti/v2_1/qtiv2p1_imscpv1p2_v1p0.ts +3 -0
  130. package/src/qti/v2_1/schemas.ts +15 -0
  131. package/src/qti/v2_1/shared.ts +3 -0
  132. package/src/qti/v2_2/apipv1p0_qtiextv2p2_v1p0p1.ts +3 -0
  133. package/src/qti/v2_2/imsqti_metadata_v2p2.ts +3 -0
  134. package/src/qti/v2_2/imsqti_result_v2p2.ts +3 -0
  135. package/src/qti/v2_2/imsqti_usagedata_v2p2.ts +3 -0
  136. package/src/qti/v2_2/imsqti_v2p2p4.ts +76 -0
  137. package/src/qti/v2_2/imsqtiv2p2p4_html5_v1p0.ts +8 -0
  138. package/src/qti/v2_2/index.ts +59 -0
  139. package/src/qti/v2_2/qtiv2p2_csm_v2p2.ts +4 -0
  140. package/src/qti/v2_2/qtiv2p2_imscpv1p2_v1p0.ts +3 -0
  141. package/src/qti/v2_2/schemas.ts +19 -0
  142. package/src/qti/v2_2/shared.ts +3 -0
  143. package/src/qti/v3_0_1/assessment-internal.ts +1509 -0
  144. package/src/qti/v3_0_1/imsqti_asiv3p0p1_v1p0.ts +57 -0
  145. package/src/qti/v3_0_1/imsqti_itemv3p0p1_v1p0.ts +60 -0
  146. package/src/qti/v3_0_1/imsqti_metadatav3p0_v1p0.ts +73 -0
  147. package/src/qti/v3_0_1/imsqti_outcomev3p0p1_v1p0.ts +11 -0
  148. package/src/qti/v3_0_1/imsqti_responseprocessingv3p0p1_v1p0.ts +17 -0
  149. package/src/qti/v3_0_1/imsqti_resultv3p0_v1p0.ts +222 -0
  150. package/src/qti/v3_0_1/imsqti_sectionv3p0p1_v1p0.ts +15 -0
  151. package/src/qti/v3_0_1/imsqti_stimulusv3p0p1_v1p0.ts +15 -0
  152. package/src/qti/v3_0_1/imsqti_testv3p0p1_v1p0.ts +49 -0
  153. package/src/qti/v3_0_1/imsqti_usagedatav3p0_v1p0.ts +77 -0
  154. package/src/qti/v3_0_1/imsqtiv3p0_afa3p0pnp_v1p0.ts +269 -0
  155. package/src/qti/v3_0_1/index.ts +50 -0
  156. package/src/qti/v3_0_1/processing-internal.ts +667 -0
  157. package/src/qti/v3_0_1/shared.ts +146 -0
  158. package/src/qti/v3_0_1/variables-internal.ts +274 -0
  159. package/src/shared/imsx-status.ts +49 -0
  160. package/src/summary.ts +70 -0
  161. package/src/vc-data-model/v2_0/index.ts +27 -0
  162. package/src/vc-data-model/v2_0/shared.ts +206 -0
  163. package/src/xapi/index.ts +12 -0
  164. package/src/xapi/shared.ts +444 -0
  165. package/src/xapi/v1_0_3/index.ts +169 -0
  166. package/src/xapi/v2_0/index.ts +256 -0
  167. package/test/caliper-v1_2.test.ts +270 -0
  168. package/test/case-v1_1.test.ts +147 -0
  169. package/test/cat-v1_0.test.ts +338 -0
  170. package/test/cc-v1_4.test.ts +239 -0
  171. package/test/clr-v2_0.test.ts +225 -0
  172. package/test/cmi5-v1_0.test.ts +196 -0
  173. package/test/contracts.test.ts +125 -0
  174. package/test/fixtures/cmi5/extended-cmi5.xml +72 -0
  175. package/test/fixtures/cmi5/simple-cmi5.xml +26 -0
  176. package/test/lti.test.ts +146 -0
  177. package/test/oneroster-v1_2.test.ts +234 -0
  178. package/test/open-badges-v3_0.test.ts +144 -0
  179. package/test/qti-v2_1.test.ts +146 -0
  180. package/test/qti-v2_2.test.ts +154 -0
  181. package/test/qti-v3_0_1.test.ts +576 -0
  182. package/test/schema-examples.test.ts +101 -0
  183. package/test/vc-data-model-v2_0.test.ts +63 -0
  184. package/test/xapi.test.ts +384 -0
  185. package/tsconfig.json +7 -0
  186. package/vc-data-model-v2_0-zod-templates.md +43 -0
  187. package/xapi-zod-templates.md +95 -0
@@ -0,0 +1,24 @@
1
+ import { z } from "zod";
2
+
3
+ import { NonEmptyStringSchema, UriReferenceSchema, strictObject } from "../shared";
4
+ import { PlatformPropertySetSchema, PropertySetSchema } from "./imslticm_v1p0";
5
+ import { IconSchema, VendorSchema } from "./imslticp_v1p0";
6
+
7
+ export const BasicLTILinkSchema = strictObject({
8
+ title: NonEmptyStringSchema,
9
+ description: z.string().optional(),
10
+ custom: PropertySetSchema.optional(),
11
+ extensions: z.array(PlatformPropertySetSchema).optional(),
12
+ launch_url: UriReferenceSchema.optional(),
13
+ secure_launch_url: UriReferenceSchema.optional(),
14
+ icon: IconSchema.optional(),
15
+ secure_icon: IconSchema.optional(),
16
+ vendor: VendorSchema,
17
+ });
18
+
19
+ export const BasicLTILinkDocumentSchema = strictObject({
20
+ basic_lti_link: BasicLTILinkSchema,
21
+ });
22
+ // Inferred types from exported Zod validators.
23
+ export type BasicLTILink = z.infer<typeof BasicLTILinkSchema>;
24
+ export type BasicLTILinkDocument = z.infer<typeof BasicLTILinkDocumentSchema>;
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+
3
+ import { NonEmptyStringSchema, XmlForeignAttributesSchema, strictObject } from "../shared";
4
+
5
+ export const PropertySchema = strictObject({
6
+ value: z.string(),
7
+ name: NonEmptyStringSchema,
8
+ foreignAttributes: XmlForeignAttributesSchema.optional(),
9
+ });
10
+
11
+ export const PropertySetSchema = strictObject({
12
+ property: z.array(PropertySchema).optional(),
13
+ });
14
+
15
+ export const PlatformPropertySetSchema = strictObject({
16
+ property: z.array(PropertySchema).optional(),
17
+ platform: NonEmptyStringSchema,
18
+ foreignAttributes: XmlForeignAttributesSchema.optional(),
19
+ });
20
+ // Inferred types from exported Zod validators.
21
+ export type Property = z.infer<typeof PropertySchema>;
22
+ export type PropertySet = z.infer<typeof PropertySetSchema>;
23
+ export type PlatformPropertySet = z.infer<typeof PlatformPropertySetSchema>;
@@ -0,0 +1,57 @@
1
+ import { z } from "zod";
2
+
3
+ import {
4
+ NonEmptyStringSchema,
5
+ UriReferenceSchema,
6
+ XmlExtensionNodeListSchema,
7
+ XmlForeignAttributesSchema,
8
+ strictObject,
9
+ } from "../shared";
10
+
11
+ export const LocalizedStringSchema = strictObject({
12
+ value: z.string(),
13
+ key: NonEmptyStringSchema.optional(),
14
+ foreignAttributes: XmlForeignAttributesSchema.optional(),
15
+ });
16
+
17
+ export const ContactSchema = strictObject({
18
+ email: NonEmptyStringSchema,
19
+ extensions: XmlExtensionNodeListSchema.optional(),
20
+ });
21
+
22
+ export const VendorSchema = strictObject({
23
+ code: NonEmptyStringSchema,
24
+ name: LocalizedStringSchema,
25
+ description: LocalizedStringSchema.optional(),
26
+ url: UriReferenceSchema.optional(),
27
+ contact: ContactSchema.optional(),
28
+ });
29
+
30
+ export const ProductInfoSchema = strictObject({
31
+ code: NonEmptyStringSchema,
32
+ name: LocalizedStringSchema,
33
+ version: NonEmptyStringSchema,
34
+ description: LocalizedStringSchema.optional(),
35
+ technical_description: LocalizedStringSchema.optional(),
36
+ });
37
+
38
+ export const ToolLocatorSchema = strictObject({
39
+ vendor: VendorSchema,
40
+ tool_info: ProductInfoSchema,
41
+ deployment_url: UriReferenceSchema,
42
+ });
43
+
44
+ export const IconSchema = strictObject({
45
+ value: UriReferenceSchema,
46
+ key: NonEmptyStringSchema.optional(),
47
+ platform: NonEmptyStringSchema.optional(),
48
+ style: NonEmptyStringSchema.optional(),
49
+ foreignAttributes: XmlForeignAttributesSchema.optional(),
50
+ });
51
+ // Inferred types from exported Zod validators.
52
+ export type LocalizedString = z.infer<typeof LocalizedStringSchema>;
53
+ export type Contact = z.infer<typeof ContactSchema>;
54
+ export type Vendor = z.infer<typeof VendorSchema>;
55
+ export type ProductInfo = z.infer<typeof ProductInfoSchema>;
56
+ export type ToolLocator = z.infer<typeof ToolLocatorSchema>;
57
+ export type Icon = z.infer<typeof IconSchema>;
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+
3
+ import { NonEmptyStringSchema, UriReferenceSchema, XmlForeignAttributesSchema, strictObject } from "../shared";
4
+
5
+ export const AgsExtensionPropertyJsonTypeSchema = z.enum(["string", "number", "boolean", "object", "array", "other"]);
6
+
7
+ export const AgsExtensionPropertySchema = strictObject({
8
+ value: z.string(),
9
+ name: NonEmptyStringSchema,
10
+ jsonType: AgsExtensionPropertyJsonTypeSchema.optional(),
11
+ foreignAttributes: XmlForeignAttributesSchema.optional(),
12
+ });
13
+
14
+ export const AgsExtensionsSchema = strictObject({
15
+ property: z.array(AgsExtensionPropertySchema).optional(),
16
+ claim: UriReferenceSchema,
17
+ });
18
+
19
+ export const LineItemSchema = strictObject({
20
+ scoreMaximum: z.number(),
21
+ label: z.string(),
22
+ resourceId: z.string().optional(),
23
+ tag: z.string().optional(),
24
+ extensions: z.array(AgsExtensionsSchema).optional(),
25
+ });
26
+
27
+ export const LineItemDocumentSchema = strictObject({
28
+ lineItem: LineItemSchema,
29
+ });
30
+ // Inferred types from exported Zod validators.
31
+ export type AgsExtensionPropertyJsonType = z.infer<typeof AgsExtensionPropertyJsonTypeSchema>;
32
+ export type AgsExtensionProperty = z.infer<typeof AgsExtensionPropertySchema>;
33
+ export type AgsExtensions = z.infer<typeof AgsExtensionsSchema>;
34
+ export type LineItem = z.infer<typeof LineItemSchema>;
35
+ export type LineItemDocument = z.infer<typeof LineItemDocumentSchema>;
@@ -0,0 +1,110 @@
1
+ import { z } from "zod";
2
+
3
+ import { strictObject } from "../shared";
4
+
5
+ export const AccessibilityFeatureSchema = z.enum([
6
+ "alternativeText",
7
+ "annotations",
8
+ "audioDescription",
9
+ "bookmarks",
10
+ "braille",
11
+ "captions",
12
+ "ChemML",
13
+ "describedMath",
14
+ "displayTransformability",
15
+ "highContrastAudio",
16
+ "highContrastDisplay",
17
+ "index",
18
+ "largePrint",
19
+ "latex",
20
+ "longDescription",
21
+ "MathML",
22
+ "none",
23
+ "printPageNumbers",
24
+ "readingOrder",
25
+ "rubyAnnotations",
26
+ "signLanguage",
27
+ "structuralNavigation",
28
+ "synchronizedAudioText",
29
+ "tableOfContents",
30
+ "taggedPDF",
31
+ "tactileGraphic",
32
+ "tactileObject",
33
+ "timingControl",
34
+ "transcript",
35
+ "ttsMarkup",
36
+ "unlocked",
37
+ ]);
38
+
39
+ export const AccessibilityHazardSchema = z.enum([
40
+ "flashing",
41
+ "noFlashingHazard",
42
+ "motionSimulation",
43
+ "noMotionSimulationHazard",
44
+ "sound",
45
+ "noSoundHazard",
46
+ "unknown",
47
+ "none",
48
+ ]);
49
+
50
+ export const AccessibilityApiSchema = z.enum([
51
+ "AndroidAccessibility",
52
+ "ARIA",
53
+ "ATK",
54
+ "AT-SPI",
55
+ "BlackberryAccessibility",
56
+ "iAccessible2",
57
+ "iOSAccessibility",
58
+ "JavaAccessibility",
59
+ "MacOSXAccessibility",
60
+ "MSAA",
61
+ "UIAutomation",
62
+ ]);
63
+
64
+ export const AccessibilityControlSchema = z.enum([
65
+ "fullKeyboardControl",
66
+ "fullMouseControl",
67
+ "fullSwitchControl",
68
+ "fullTouchControl",
69
+ "fullVideoControl",
70
+ "fullVoiceControl",
71
+ ]);
72
+
73
+ export const AccessModeSchema = z.enum([
74
+ "auditory",
75
+ "chartOnVisual",
76
+ "chemOnVisual",
77
+ "colorDependent",
78
+ "diagramOnVisual",
79
+ "mathOnVisual",
80
+ "musicOnVisual",
81
+ "tactile",
82
+ "textOnVisual",
83
+ "textual",
84
+ "visual",
85
+ ]);
86
+
87
+ export const AccessModeSufficientSchema = z.enum(["auditory", "tactile", "textual", "visual"]);
88
+
89
+ export const ResourceAccessibilityMetadataSchema = strictObject({
90
+ accessibilityFeature: z.array(AccessibilityFeatureSchema).optional(),
91
+ accessibilityHazard: z.array(AccessibilityHazardSchema).optional(),
92
+ accessibilityAPI: z.array(AccessibilityApiSchema).optional(),
93
+ accessibilityControl: z.array(AccessibilityControlSchema).optional(),
94
+ accessMode: z.array(AccessModeSchema).optional(),
95
+ accessModeSufficient: z.array(AccessModeSufficientSchema).optional(),
96
+ accessibilitySummary: z.array(z.string()).optional(),
97
+ });
98
+
99
+ export const ResourceAccessibilityMetadataDocumentSchema = strictObject({
100
+ ResourceAccessibilityMetadata: ResourceAccessibilityMetadataSchema,
101
+ });
102
+ // Inferred types from exported Zod validators.
103
+ export type AccessibilityFeature = z.infer<typeof AccessibilityFeatureSchema>;
104
+ export type AccessibilityHazard = z.infer<typeof AccessibilityHazardSchema>;
105
+ export type AccessibilityApi = z.infer<typeof AccessibilityApiSchema>;
106
+ export type AccessibilityControl = z.infer<typeof AccessibilityControlSchema>;
107
+ export type AccessMode = z.infer<typeof AccessModeSchema>;
108
+ export type AccessModeSufficient = z.infer<typeof AccessModeSufficientSchema>;
109
+ export type ResourceAccessibilityMetadata = z.infer<typeof ResourceAccessibilityMetadataSchema>;
110
+ export type ResourceAccessibilityMetadataDocument = z.infer<typeof ResourceAccessibilityMetadataDocumentSchema>;
@@ -0,0 +1,68 @@
1
+ import { z } from "zod";
2
+
3
+ export const NonEmptyStringSchema = z.string().min(1);
4
+ export const UriReferenceSchema = z.string().min(1);
5
+ export const YesNoSchema = z.enum(["Yes", "No"]);
6
+ export const LowerYesNoSchema = z.enum(["yes", "no"]);
7
+ export const XmlSpaceSchema = z.enum(["default", "preserve"]);
8
+ export const XmlForeignAttributesSchema = z.record(z.string(), z.unknown());
9
+
10
+ export const XmlExtensionNodeSchema = z
11
+ .object({
12
+ namespace: NonEmptyStringSchema,
13
+ name: NonEmptyStringSchema,
14
+ value: z.unknown().optional(),
15
+ attributes: XmlForeignAttributesSchema.optional(),
16
+ children: z.array(z.unknown()).optional(),
17
+ })
18
+ .strict();
19
+
20
+ export const XmlExtensionNodeListSchema = z.array(XmlExtensionNodeSchema);
21
+
22
+ export function strictObject<T extends z.ZodRawShape>(shape: T) {
23
+ return z.object(shape).strict();
24
+ }
25
+
26
+ export function looseObject<T extends z.ZodRawShape>(shape: T) {
27
+ return strictObject({
28
+ ...shape,
29
+ extensions: XmlExtensionNodeListSchema.optional(),
30
+ foreignAttributes: XmlForeignAttributesSchema.optional(),
31
+ });
32
+ }
33
+
34
+ export function addIssue(context: z.RefinementCtx, path: Array<string | number>, message: string) {
35
+ context.addIssue({
36
+ code: z.ZodIssueCode.custom,
37
+ path,
38
+ message,
39
+ });
40
+ }
41
+
42
+ export function collectDuplicates(values: string[]): string[] {
43
+ const seen = new Set<string>();
44
+ const duplicates = new Set<string>();
45
+
46
+ for (const value of values) {
47
+ if (seen.has(value)) {
48
+ duplicates.add(value);
49
+ continue;
50
+ }
51
+ seen.add(value);
52
+ }
53
+
54
+ return [...duplicates];
55
+ }
56
+
57
+ export function asArray<T>(value: readonly T[] | T[] | undefined | null): T[] {
58
+ return Array.isArray(value) ? [...value] : [];
59
+ }
60
+ // Inferred types from exported Zod validators.
61
+ export type NonEmptyString = z.infer<typeof NonEmptyStringSchema>;
62
+ export type UriReference = z.infer<typeof UriReferenceSchema>;
63
+ export type YesNo = z.infer<typeof YesNoSchema>;
64
+ export type LowerYesNo = z.infer<typeof LowerYesNoSchema>;
65
+ export type XmlSpace = z.infer<typeof XmlSpaceSchema>;
66
+ export type XmlForeignAttributes = z.infer<typeof XmlForeignAttributesSchema>;
67
+ export type XmlExtensionNode = z.infer<typeof XmlExtensionNodeSchema>;
68
+ export type XmlExtensionNodeList = z.infer<typeof XmlExtensionNodeListSchema>;
@@ -0,0 +1,243 @@
1
+ import { z } from "zod";
2
+
3
+ import { CartridgeBasicLTILinkSchema } from "../shared/ccv1p4_imslticc_v1p4";
4
+ import { CurriculumStandardsMetadataSetSchema } from "../shared/ccv1p4_imscsmd_v1p1";
5
+ import { WebLinkSchema } from "../shared/ccv1p4_imswl_v1p4";
6
+ import {
7
+ NonEmptyStringSchema,
8
+ UriReferenceSchema,
9
+ addIssue,
10
+ asArray,
11
+ collectDuplicates,
12
+ strictObject,
13
+ } from "../shared";
14
+ import { ThinLomManifestSchema } from "./ccv1p4_lommanifest_v1p0";
15
+ import { ThinLomResourceSchema } from "./ccv1p4_lomresource_v1p0";
16
+
17
+ export const ThinCommonCartridgeResourceTypeSchema = z.enum(["imsbasiclti_xmlv1p4", "imswl_xmlv1p4"]);
18
+
19
+ export const ThinCommonCartridgeIntendedUseSchema = z.enum(["assignment", "lessonplan", "syllabus", "unspecified"]);
20
+
21
+ export const ThinCommonCartridgeFileSchema = strictObject({
22
+ href: UriReferenceSchema,
23
+ });
24
+
25
+ export const ThinCommonCartridgeItemSchema: z.ZodTypeAny = z.lazy(() =>
26
+ strictObject({
27
+ identifier: NonEmptyStringSchema,
28
+ identifierref: NonEmptyStringSchema.optional(),
29
+ title: z.string(),
30
+ item: z.array(ThinCommonCartridgeItemSchema).optional(),
31
+ }),
32
+ );
33
+
34
+ export const ThinCommonCartridgeItemOrgSchema: z.ZodTypeAny = z.lazy(() =>
35
+ strictObject({
36
+ identifier: NonEmptyStringSchema,
37
+ item: z.array(ThinCommonCartridgeItemSchema).optional(),
38
+ }),
39
+ );
40
+
41
+ export const ThinCommonCartridgeOrganizationSchema = strictObject({
42
+ identifier: NonEmptyStringSchema,
43
+ structure: z.literal("rooted-hierarchy"),
44
+ title: z.string().optional(),
45
+ item: ThinCommonCartridgeItemOrgSchema,
46
+ });
47
+
48
+ export const ThinCommonCartridgeOrganizationsSchema = strictObject({
49
+ organization: ThinCommonCartridgeOrganizationSchema.optional(),
50
+ });
51
+
52
+ export const ThinCommonCartridgeManifestMetadataSchema = strictObject({
53
+ schema: z.enum(["IMS Thin Common Cartridge", "IMS K-12 Thin Common Cartridge"]),
54
+ schemaversion: z.literal("1.4.0"),
55
+ lom: ThinLomManifestSchema,
56
+ curriculumStandardsMetadataSet: CurriculumStandardsMetadataSetSchema.optional(),
57
+ });
58
+
59
+ export const ThinCommonCartridgeResourceMetadataSchema = strictObject({
60
+ schema: z.string().optional(),
61
+ schemaversion: z.string().optional(),
62
+ lom: ThinLomResourceSchema.optional(),
63
+ curriculumStandardsMetadataSet: z.array(CurriculumStandardsMetadataSetSchema).optional(),
64
+ });
65
+
66
+ export const ThinCommonCartridgeResourceSchema = strictObject({
67
+ identifier: NonEmptyStringSchema,
68
+ type: ThinCommonCartridgeResourceTypeSchema,
69
+ href: UriReferenceSchema.optional(),
70
+ xmlBase: z.string().optional(),
71
+ intendeduse: ThinCommonCartridgeIntendedUseSchema.optional(),
72
+ metadata: ThinCommonCartridgeResourceMetadataSchema.optional(),
73
+ file: z.array(ThinCommonCartridgeFileSchema).optional(),
74
+ cartridge_basiclti_link: CartridgeBasicLTILinkSchema.optional(),
75
+ webLink: WebLinkSchema.optional(),
76
+ });
77
+
78
+ export const ThinCommonCartridgeResourcesSchema = strictObject({
79
+ xmlBase: z.string().optional(),
80
+ resource: z.array(ThinCommonCartridgeResourceSchema).optional(),
81
+ });
82
+
83
+ export const ThinCommonCartridgeManifestRawSchema = strictObject({
84
+ identifier: NonEmptyStringSchema,
85
+ xmlBase: z.string().optional(),
86
+ metadata: ThinCommonCartridgeManifestMetadataSchema,
87
+ organizations: ThinCommonCartridgeOrganizationsSchema,
88
+ resources: ThinCommonCartridgeResourcesSchema,
89
+ });
90
+
91
+ type ThinCommonCartridgeTraversalItem = {
92
+ identifier: string;
93
+ identifierref?: string;
94
+ item?: ThinCommonCartridgeTraversalItem[];
95
+ };
96
+
97
+ type ThinCommonCartridgeTraversalManifest = {
98
+ organizations: {
99
+ organization?: {
100
+ item: {
101
+ item?: ThinCommonCartridgeTraversalItem[];
102
+ };
103
+ };
104
+ };
105
+ };
106
+
107
+ function walkThinCommonCartridgeItems(
108
+ item: ThinCommonCartridgeTraversalItem,
109
+ visit: (candidate: ThinCommonCartridgeTraversalItem) => void,
110
+ ) {
111
+ visit(item);
112
+ for (const child of asArray(item.item)) {
113
+ walkThinCommonCartridgeItems(child, visit);
114
+ }
115
+ }
116
+
117
+ function collectThinCommonCartridgeItems(
118
+ manifest: ThinCommonCartridgeTraversalManifest,
119
+ ): ThinCommonCartridgeTraversalItem[] {
120
+ const items: ThinCommonCartridgeTraversalItem[] = [];
121
+ const rootItem = manifest.organizations.organization?.item;
122
+
123
+ if (!rootItem) {
124
+ return items;
125
+ }
126
+
127
+ for (const child of asArray(rootItem.item)) {
128
+ walkThinCommonCartridgeItems(child, (candidate) => {
129
+ items.push(candidate);
130
+ });
131
+ }
132
+
133
+ return items;
134
+ }
135
+
136
+ export const ThinCommonCartridgeManifestProfileSchema = ThinCommonCartridgeManifestRawSchema.superRefine(
137
+ (manifest, context) => {
138
+ const resources = asArray(manifest.resources.resource);
139
+
140
+ for (const duplicate of collectDuplicates(resources.map((resource) => resource.identifier))) {
141
+ addIssue(context, ["resources", "resource"], `Duplicate resource identifier: ${duplicate}`);
142
+ }
143
+
144
+ resources.forEach((resource, resourceIndex) => {
145
+ const files = asArray(resource.file);
146
+
147
+ for (const duplicate of collectDuplicates(files.map((file) => file.href))) {
148
+ addIssue(
149
+ context,
150
+ ["resources", "resource", resourceIndex, "file"],
151
+ `Resource ${resource.identifier} contains duplicate file href values: ${duplicate}`,
152
+ );
153
+ }
154
+
155
+ const hasBasicLti = Boolean(resource.cartridge_basiclti_link);
156
+ const hasWebLink = Boolean(resource.webLink);
157
+
158
+ if (resource.type === "imsbasiclti_xmlv1p4" && !hasBasicLti) {
159
+ addIssue(
160
+ context,
161
+ ["resources", "resource", resourceIndex, "cartridge_basiclti_link"],
162
+ `Thin resource ${resource.identifier} must contain cartridge_basiclti_link when type is imsbasiclti_xmlv1p4.`,
163
+ );
164
+ }
165
+
166
+ if (resource.type === "imswl_xmlv1p4" && !hasWebLink) {
167
+ addIssue(
168
+ context,
169
+ ["resources", "resource", resourceIndex, "webLink"],
170
+ `Thin resource ${resource.identifier} must contain webLink when type is imswl_xmlv1p4.`,
171
+ );
172
+ }
173
+
174
+ if (resource.type === "imsbasiclti_xmlv1p4" && hasWebLink) {
175
+ addIssue(
176
+ context,
177
+ ["resources", "resource", resourceIndex, "webLink"],
178
+ `Thin resource ${resource.identifier} must not contain webLink when type is imsbasiclti_xmlv1p4.`,
179
+ );
180
+ }
181
+
182
+ if (resource.type === "imswl_xmlv1p4" && hasBasicLti) {
183
+ addIssue(
184
+ context,
185
+ ["resources", "resource", resourceIndex, "cartridge_basiclti_link"],
186
+ `Thin resource ${resource.identifier} must not contain cartridge_basiclti_link when type is imswl_xmlv1p4.`,
187
+ );
188
+ }
189
+
190
+ if (resource.href && files.length === 0) {
191
+ addIssue(
192
+ context,
193
+ ["resources", "resource", resourceIndex, "file"],
194
+ `Resource ${resource.identifier} has href but no file entries.`,
195
+ );
196
+ }
197
+
198
+ if (resource.href && !files.some((file) => file.href === resource.href)) {
199
+ addIssue(
200
+ context,
201
+ ["resources", "resource", resourceIndex, "href"],
202
+ `Resource ${resource.identifier} has href ${resource.href} but no matching file/@href.`,
203
+ );
204
+ }
205
+ });
206
+
207
+ const items = collectThinCommonCartridgeItems(manifest as ThinCommonCartridgeTraversalManifest);
208
+
209
+ items.forEach((item, itemIndex) => {
210
+ if (item.identifierref && asArray(item.item).length > 0) {
211
+ addIssue(
212
+ context,
213
+ ["organizations", "organization", "item", itemIndex, "item"],
214
+ `Learning-object item ${item.identifier} must not contain child items when identifierref is present.`,
215
+ );
216
+ }
217
+ });
218
+ },
219
+ );
220
+
221
+ export const ThinCommonCartridgeManifestRawDocumentSchema = strictObject({
222
+ manifest: ThinCommonCartridgeManifestRawSchema,
223
+ });
224
+
225
+ export const ThinCommonCartridgeManifestProfileDocumentSchema = strictObject({
226
+ manifest: ThinCommonCartridgeManifestProfileSchema,
227
+ });
228
+ // Inferred types from exported Zod validators.
229
+ export type ThinCommonCartridgeResourceType = z.infer<typeof ThinCommonCartridgeResourceTypeSchema>;
230
+ export type ThinCommonCartridgeIntendedUse = z.infer<typeof ThinCommonCartridgeIntendedUseSchema>;
231
+ export type ThinCommonCartridgeFile = z.infer<typeof ThinCommonCartridgeFileSchema>;
232
+ export type ThinCommonCartridgeOrganization = z.infer<typeof ThinCommonCartridgeOrganizationSchema>;
233
+ export type ThinCommonCartridgeOrganizations = z.infer<typeof ThinCommonCartridgeOrganizationsSchema>;
234
+ export type ThinCommonCartridgeManifestMetadata = z.infer<typeof ThinCommonCartridgeManifestMetadataSchema>;
235
+ export type ThinCommonCartridgeResourceMetadata = z.infer<typeof ThinCommonCartridgeResourceMetadataSchema>;
236
+ export type ThinCommonCartridgeResource = z.infer<typeof ThinCommonCartridgeResourceSchema>;
237
+ export type ThinCommonCartridgeResources = z.infer<typeof ThinCommonCartridgeResourcesSchema>;
238
+ export type ThinCommonCartridgeManifestRaw = z.infer<typeof ThinCommonCartridgeManifestRawSchema>;
239
+ export type ThinCommonCartridgeManifestProfile = z.infer<typeof ThinCommonCartridgeManifestProfileSchema>;
240
+ export type ThinCommonCartridgeManifestRawDocument = z.infer<typeof ThinCommonCartridgeManifestRawDocumentSchema>;
241
+ export type ThinCommonCartridgeManifestProfileDocument = z.infer<
242
+ typeof ThinCommonCartridgeManifestProfileDocumentSchema
243
+ >;
@@ -0,0 +1,14 @@
1
+ import type { z } from "zod";
2
+ import { strictObject } from "../shared";
3
+ import { LomThinManifestProfileSchemas } from "../lom-internal";
4
+
5
+ export { LomThinManifestProfileSchemas } from "../lom-internal";
6
+
7
+ export const ThinLomManifestSchema = LomThinManifestProfileSchemas.LomSchema;
8
+
9
+ export const ThinLomManifestDocumentSchema = strictObject({
10
+ lom: ThinLomManifestSchema,
11
+ });
12
+ // Inferred types from exported Zod validators.
13
+ export type ThinLomManifest = z.infer<typeof ThinLomManifestSchema>;
14
+ export type ThinLomManifestDocument = z.infer<typeof ThinLomManifestDocumentSchema>;
@@ -0,0 +1,14 @@
1
+ import type { z } from "zod";
2
+ import { strictObject } from "../shared";
3
+ import { LomThinResourceProfileSchemas } from "../lom-internal";
4
+
5
+ export { LomThinResourceProfileSchemas } from "../lom-internal";
6
+
7
+ export const ThinLomResourceSchema = LomThinResourceProfileSchemas.LomSchema;
8
+
9
+ export const ThinLomResourceDocumentSchema = strictObject({
10
+ lom: ThinLomResourceSchema,
11
+ });
12
+ // Inferred types from exported Zod validators.
13
+ export type ThinLomResource = z.infer<typeof ThinLomResourceSchema>;
14
+ export type ThinLomResourceDocument = z.infer<typeof ThinLomResourceDocumentSchema>;
@@ -0,0 +1,13 @@
1
+ import type { z } from "zod";
2
+ import { strictObject } from "../shared";
3
+ import { LomManifestProfileSchemas } from "../lom-internal";
4
+
5
+ export { LomManifestProfileSchemas } from "../lom-internal";
6
+
7
+ export const ImsMdLooseLomSchema = LomManifestProfileSchemas.LomSchema;
8
+ export const ImsMdLooseLomDocumentSchema = strictObject({
9
+ lom: ImsMdLooseLomSchema,
10
+ });
11
+ // Inferred types from exported Zod validators.
12
+ export type ImsMdLooseLom = z.infer<typeof ImsMdLooseLomSchema>;
13
+ export type ImsMdLooseLomDocument = z.infer<typeof ImsMdLooseLomDocumentSchema>;