@palantir/pack.document-schema.type-gen 0.11.0 → 0.13.0

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 (109) hide show
  1. package/build/esm/commands/asset/assetDeployHandler.js +1 -1
  2. package/build/esm/commands/asset/assetDeployHandler.js.map +1 -1
  3. package/build/esm/commands/asset/assetUpdateSchemaHandler.js +1 -1
  4. package/build/esm/commands/asset/assetUpdateSchemaHandler.js.map +1 -1
  5. package/build/esm/commands/ir/irGenAssetHandler.js +81 -12
  6. package/build/esm/commands/ir/irGenAssetHandler.js.map +1 -1
  7. package/build/esm/commands/ir/irGenTypesHandler.js +10 -8
  8. package/build/esm/commands/ir/irGenTypesHandler.js.map +1 -1
  9. package/build/esm/commands/ir/registerIrCommands.js +2 -2
  10. package/build/esm/commands/ir/registerIrCommands.js.map +1 -1
  11. package/build/esm/commands/schema/__tests__/readPackConfig.test.js +112 -0
  12. package/build/esm/commands/schema/__tests__/readPackConfig.test.js.map +1 -0
  13. package/build/esm/commands/schema/registerSchemaCommands.js +1 -1
  14. package/build/esm/commands/schema/registerSchemaCommands.js.map +1 -1
  15. package/build/esm/commands/schema/schemaIrHandler.js +77 -11
  16. package/build/esm/commands/schema/schemaIrHandler.js.map +1 -1
  17. package/build/esm/commands/types.js.map +1 -1
  18. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js +1 -1
  19. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js.map +1 -1
  20. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js +1 -1
  21. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js.map +1 -1
  22. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js +1 -1
  23. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js.map +1 -1
  24. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/union-types.js +1 -1
  25. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/union-types.js.map +1 -1
  26. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/array-and-map-types.js +1 -1
  27. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/array-and-map-types.js.map +1 -1
  28. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js +1 -1
  29. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js.map +1 -1
  30. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/custom-discriminant.js +1 -1
  31. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/custom-discriminant.js.map +1 -1
  32. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js +1 -1
  33. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js.map +1 -1
  34. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js +1 -1
  35. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js.map +1 -1
  36. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-before-records.js +1 -1
  37. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-before-records.js.map +1 -1
  38. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js +1 -1
  39. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js.map +1 -1
  40. package/build/esm/utils/schema/__tests__/__snapshots__/generateDocumentTypeFromSchema/with-name-and-description.js +9 -0
  41. package/build/esm/utils/schema/__tests__/__snapshots__/generateDocumentTypeFromSchema/with-name-and-description.js.map +1 -0
  42. package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/single-version.js.map +1 -1
  43. package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/three-version-chain.js.map +1 -1
  44. package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/two-version.js.map +1 -1
  45. package/build/esm/utils/schema/__tests__/generateDocumentTypeFromSchema.test.js +34 -0
  46. package/build/esm/utils/schema/__tests__/generateDocumentTypeFromSchema.test.js.map +1 -0
  47. package/build/esm/utils/schema/__tests__/provenanceScenarios.test.js +184 -0
  48. package/build/esm/utils/schema/__tests__/provenanceScenarios.test.js.map +1 -0
  49. package/build/esm/utils/schema/__tests__/resolveSchemaChain.test.js +122 -0
  50. package/build/esm/utils/schema/__tests__/resolveSchemaChain.test.js.map +1 -0
  51. package/build/esm/utils/schema/generateDocumentTypeFromSchema.js +39 -0
  52. package/build/esm/utils/schema/generateDocumentTypeFromSchema.js.map +1 -0
  53. package/build/esm/utils/schema/generateIndexFromSchema.js +3 -1
  54. package/build/esm/utils/schema/generateIndexFromSchema.js.map +1 -1
  55. package/build/esm/utils/schema/generateInternalFromSchema.js +1 -1
  56. package/build/esm/utils/schema/generateInternalFromSchema.js.map +1 -1
  57. package/build/esm/utils/schema/generateScopeFromSchema.js +2 -2
  58. package/build/esm/utils/schema/generateScopeFromSchema.js.map +1 -1
  59. package/build/esm/utils/schema/loadSchemaModule.js +2 -5
  60. package/build/esm/utils/schema/loadSchemaModule.js.map +1 -1
  61. package/build/esm/utils/schema/resolveSchemaChain.js +104 -17
  62. package/build/esm/utils/schema/resolveSchemaChain.js.map +1 -1
  63. package/build/esm/utils/schema/runtimeSchema.js +3 -0
  64. package/build/esm/utils/schema/runtimeSchema.js.map +1 -1
  65. package/build/esm/utils/schema/writeAllSdkFiles.js +8 -8
  66. package/build/esm/utils/schema/writeAllSdkFiles.js.map +1 -1
  67. package/build/esm/utils/steps/__tests__/__snapshots__/types/arrayFields.js.map +1 -1
  68. package/build/esm/utils/steps/__tests__/__snapshots__/types/customDiscriminant.js +1 -1
  69. package/build/esm/utils/steps/__tests__/__snapshots__/types/customDiscriminant.js.map +1 -1
  70. package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js +1 -1
  71. package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js.map +1 -1
  72. package/build/esm/utils/steps/__tests__/__snapshots__/types/refTypes.js.map +1 -1
  73. package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleRecord.js.map +1 -1
  74. package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleSteps.js +1 -1
  75. package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleSteps.js.map +1 -1
  76. package/build/esm/utils/steps/convertStepsToIr.js +49 -24
  77. package/build/esm/utils/steps/convertStepsToIr.js.map +1 -1
  78. package/build/types/commands/ir/irGenAssetHandler.d.ts +16 -5
  79. package/build/types/commands/ir/irGenAssetHandler.d.ts.map +1 -1
  80. package/build/types/commands/ir/irGenTypesHandler.d.ts +0 -1
  81. package/build/types/commands/ir/irGenTypesHandler.d.ts.map +1 -1
  82. package/build/types/commands/ir/registerIrCommands.d.ts.map +1 -1
  83. package/build/types/commands/schema/__tests__/readPackConfig.test.d.ts +2 -0
  84. package/build/types/commands/schema/__tests__/readPackConfig.test.d.ts.map +1 -0
  85. package/build/types/commands/schema/registerSchemaCommands.d.ts.map +1 -1
  86. package/build/types/commands/schema/schemaIrHandler.d.ts +28 -6
  87. package/build/types/commands/schema/schemaIrHandler.d.ts.map +1 -1
  88. package/build/types/commands/types.d.ts +3 -1
  89. package/build/types/commands/types.d.ts.map +1 -1
  90. package/build/types/utils/schema/__tests__/generateDocumentTypeFromSchema.test.d.ts +2 -0
  91. package/build/types/utils/schema/__tests__/generateDocumentTypeFromSchema.test.d.ts.map +1 -0
  92. package/build/types/utils/schema/__tests__/provenanceScenarios.test.d.ts +2 -0
  93. package/build/types/utils/schema/__tests__/provenanceScenarios.test.d.ts.map +1 -0
  94. package/build/types/utils/schema/__tests__/resolveSchemaChain.test.d.ts +2 -0
  95. package/build/types/utils/schema/__tests__/resolveSchemaChain.test.d.ts.map +1 -0
  96. package/build/types/utils/schema/generateDocumentTypeFromSchema.d.ts +17 -0
  97. package/build/types/utils/schema/generateDocumentTypeFromSchema.d.ts.map +1 -0
  98. package/build/types/utils/schema/generateIndexFromSchema.d.ts +1 -0
  99. package/build/types/utils/schema/generateIndexFromSchema.d.ts.map +1 -1
  100. package/build/types/utils/schema/loadSchemaModule.d.ts.map +1 -1
  101. package/build/types/utils/schema/resolveSchemaChain.d.ts +26 -1
  102. package/build/types/utils/schema/resolveSchemaChain.d.ts.map +1 -1
  103. package/build/types/utils/schema/runtimeSchema.d.ts +2 -0
  104. package/build/types/utils/schema/runtimeSchema.d.ts.map +1 -1
  105. package/build/types/utils/schema/writeAllSdkFiles.d.ts +0 -1
  106. package/build/types/utils/schema/writeAllSdkFiles.d.ts.map +1 -1
  107. package/build/types/utils/steps/convertStepsToIr.d.ts +19 -4
  108. package/build/types/utils/steps/convertStepsToIr.d.ts.map +1 -1
  109. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- /* Generated by @palantir/pack.document-schema.type-gen@0.11.0 */
1
+ /* Generated by @palantir/pack.document-schema.type-gen@0.13.0 */
2
2
 
3
3
  /**
4
4
  * A cat
@@ -1 +1 @@
1
- {"version":3,"file":"customDiscriminant.js","names":["isAnimalCat","value","kind","isAnimalDog"],"sources":["customDiscriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.11.0 */\n\n\n/**\n * A cat\n */\nexport interface Cat {\n readonly meow: string;\n readonly whiskers: number;\n}\n\n/**\n * A dog\n */\nexport interface Dog {\n readonly bark: string;\n readonly tailWags: number;\n}\n\nexport interface AnimalCat extends Cat {\n readonly kind: \"cat\";\n}\n\nexport interface AnimalDog extends Dog {\n readonly kind: \"dog\";\n}\n\nexport type Animal = AnimalCat | AnimalDog;\n\nexport function isAnimalCat(value: Animal): value is AnimalCat {\n return value.kind === \"cat\";\n}\n\nexport function isAnimalDog(value: Animal): value is AnimalDog {\n return value.kind === \"dog\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAgBA,OAAO,SAASA,WAAWA,CAACC,KAAa,EAAsB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,KAAK;AAC7B;AAEA,OAAO,SAASC,WAAWA,CAACF,KAAa,EAAsB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,KAAK;AAC7B","ignoreList":[]}
1
+ {"version":3,"file":"customDiscriminant.js","names":["isAnimalCat","value","kind","isAnimalDog"],"sources":["customDiscriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.13.0 */\n\n\n/**\n * A cat\n */\nexport interface Cat {\n readonly meow: string;\n readonly whiskers: number;\n}\n\n/**\n * A dog\n */\nexport interface Dog {\n readonly bark: string;\n readonly tailWags: number;\n}\n\nexport interface AnimalCat extends Cat {\n readonly kind: \"cat\";\n}\n\nexport interface AnimalDog extends Dog {\n readonly kind: \"dog\";\n}\n\nexport type Animal = AnimalCat | AnimalDog;\n\nexport function isAnimalCat(value: Animal): value is AnimalCat {\n return value.kind === \"cat\";\n}\n\nexport function isAnimalDog(value: Animal): value is AnimalDog {\n return value.kind === \"dog\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAgBA,OAAO,SAASA,WAAWA,CAACC,KAAa,EAAsB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,KAAK;AAC7B;AAEA,OAAO,SAASC,WAAWA,CAACF,KAAa,EAAsB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,KAAK;AAC7B","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- /* Generated by @palantir/pack.document-schema.type-gen@0.11.0 */
1
+ /* Generated by @palantir/pack.document-schema.type-gen@0.13.0 */
2
2
 
3
3
  /**
4
4
  * Represents an edge in a graph
@@ -1 +1 @@
1
- {"version":3,"file":"generateTypeScriptInterfaces.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["generateTypeScriptInterfaces.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.11.0 */\n\n\n/**\n * Represents an edge in a graph\n */\nexport interface Edge {\n readonly source: ObjectNode;\n readonly target: ObjectNode;\n}\n\nexport interface ObjectNode {\n readonly x: number;\n readonly y: number;\n readonly label?: string;\n readonly color?: string;\n}\n\n/**\n * Represents a text box in a graph\n */\nexport interface TextBox {\n readonly x: number;\n readonly y: number;\n readonly text: string;\n}\n\nexport interface NodeObject extends ObjectNode {\n readonly type: \"object\";\n}\n\nexport interface NodeTextBox extends TextBox {\n readonly type: \"text-box\";\n}\n\nexport type Node = NodeObject | NodeTextBox;\n\nexport function isNodeObject(value: Node): value is NodeObject {\n return value.type === \"object\";\n}\n\nexport function isNodeTextBox(value: Node): value is NodeTextBox {\n return value.type === \"text-box\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAiBA,OAAO,SAASA,YAAYA,CAACC,KAAW,EAAuB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ;AAChC;AAEA,OAAO,SAASC,aAAaA,CAACF,KAAW,EAAwB;EAC/D,OAAOA,KAAK,CAACC,IAAI,KAAK,UAAU;AAClC","ignoreList":[]}
1
+ {"version":3,"file":"generateTypeScriptInterfaces.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["generateTypeScriptInterfaces.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.13.0 */\n\n\n/**\n * Represents an edge in a graph\n */\nexport interface Edge {\n readonly source: ObjectNode;\n readonly target: ObjectNode;\n}\n\nexport interface ObjectNode {\n readonly x: number;\n readonly y: number;\n readonly label?: string;\n readonly color?: string;\n}\n\n/**\n * Represents a text box in a graph\n */\nexport interface TextBox {\n readonly x: number;\n readonly y: number;\n readonly text: string;\n}\n\nexport interface NodeObject extends ObjectNode {\n readonly type: \"object\";\n}\n\nexport interface NodeTextBox extends TextBox {\n readonly type: \"text-box\";\n}\n\nexport type Node = NodeObject | NodeTextBox;\n\nexport function isNodeObject(value: Node): value is NodeObject {\n return value.type === \"object\";\n}\n\nexport function isNodeTextBox(value: Node): value is NodeTextBox {\n return value.type === \"text-box\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAiBA,OAAO,SAASA,YAAYA,CAACC,KAAW,EAAuB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ;AAChC;AAEA,OAAO,SAASC,aAAaA,CAACF,KAAW,EAAwB;EAC/D,OAAOA,KAAK,CAACC,IAAI,KAAK,UAAU;AAClC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"refTypes.js","names":[],"sources":["refTypes.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.11.0 */\n\nimport type { DocumentRef, MediaRef, ObjectRef, UserRef } from \"@palantir/pack.document-schema.model-types\";\n\n/**\n * A record containing all reference types\n */\nexport interface Document {\n readonly id: string;\n readonly docRef: DocumentRef;\n readonly userRef: UserRef;\n readonly objectRef: ObjectRef;\n readonly mediaRef: MediaRef;\n readonly optionalDocRef?: DocumentRef;\n readonly docRefArray: readonly DocumentRef[];\n readonly userRefArray: readonly UserRef[];\n}\n\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"refTypes.js","names":[],"sources":["refTypes.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.13.0 */\n\nimport type { DocumentRef, MediaRef, ObjectRef, UserRef } from \"@palantir/pack.document-schema.model-types\";\n\n/**\n * A record containing all reference types\n */\nexport interface Document {\n readonly id: string;\n readonly docRef: DocumentRef;\n readonly userRef: UserRef;\n readonly objectRef: ObjectRef;\n readonly mediaRef: MediaRef;\n readonly optionalDocRef?: DocumentRef;\n readonly docRefArray: readonly DocumentRef[];\n readonly userRefArray: readonly UserRef[];\n}\n\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"simpleRecord.js","names":[],"sources":["simpleRecord.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.11.0 */\n\n\n/**\n * A person record\n */\nexport interface Person {\n readonly name: string;\n readonly age: number;\n readonly email?: string;\n}\n\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"simpleRecord.js","names":[],"sources":["simpleRecord.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.13.0 */\n\n\n/**\n * A person record\n */\nexport interface Person {\n readonly name: string;\n readonly age: number;\n readonly email?: string;\n}\n\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- /* Generated by @palantir/pack.document-schema.type-gen@0.11.0 */
1
+ /* Generated by @palantir/pack.document-schema.type-gen@0.13.0 */
2
2
 
3
3
  /**
4
4
  * A node in the graph
@@ -1 +1 @@
1
- {"version":3,"file":"simpleSteps.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["simpleSteps.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.11.0 */\n\n\n/**\n * A node in the graph\n */\nexport interface ObjectNode {\n readonly x: number;\n readonly y: number;\n readonly object: string;\n readonly label?: string;\n readonly edges: readonly Edge[];\n}\n\n/**\n * A text box in the graph\n */\nexport interface TextBox {\n readonly x: number;\n readonly y: number;\n readonly text: string;\n}\n\n/**\n * An edge in the graph\n */\nexport interface Edge {\n readonly source: ObjectNode;\n readonly target: ObjectNode;\n}\n\nexport interface NodeObject extends ObjectNode {\n readonly type: \"object\";\n}\n\nexport interface NodeTextBox extends TextBox {\n readonly type: \"textBox\";\n}\n\nexport type Node = NodeObject | NodeTextBox;\n\nexport function isNodeObject(value: Node): value is NodeObject {\n return value.type === \"object\";\n}\n\nexport function isNodeTextBox(value: Node): value is NodeTextBox {\n return value.type === \"textBox\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AASA;AACA;AACA;;AAOA;AACA;AACA;;AAgBA,OAAO,SAASA,YAAYA,CAACC,KAAW,EAAuB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ;AAChC;AAEA,OAAO,SAASC,aAAaA,CAACF,KAAW,EAAwB;EAC/D,OAAOA,KAAK,CAACC,IAAI,KAAK,SAAS;AACjC","ignoreList":[]}
1
+ {"version":3,"file":"simpleSteps.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["simpleSteps.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.13.0 */\n\n\n/**\n * A node in the graph\n */\nexport interface ObjectNode {\n readonly x: number;\n readonly y: number;\n readonly object: string;\n readonly label?: string;\n readonly edges: readonly Edge[];\n}\n\n/**\n * A text box in the graph\n */\nexport interface TextBox {\n readonly x: number;\n readonly y: number;\n readonly text: string;\n}\n\n/**\n * An edge in the graph\n */\nexport interface Edge {\n readonly source: ObjectNode;\n readonly target: ObjectNode;\n}\n\nexport interface NodeObject extends ObjectNode {\n readonly type: \"object\";\n}\n\nexport interface NodeTextBox extends TextBox {\n readonly type: \"textBox\";\n}\n\nexport type Node = NodeObject | NodeTextBox;\n\nexport function isNodeObject(value: Node): value is NodeObject {\n return value.type === \"object\";\n}\n\nexport function isNodeTextBox(value: Node): value is NodeTextBox {\n return value.type === \"textBox\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AASA;AACA;AACA;;AAOA;AACA;AACA;;AAgBA,OAAO,SAASA,YAAYA,CAACC,KAAW,EAAuB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ;AAChC;AAEA,OAAO,SAASC,aAAaA,CAACF,KAAW,EAAwB;EAC/D,OAAOA,KAAK,CAACC,IAAI,KAAK,SAAS;AACjC","ignoreList":[]}
@@ -18,6 +18,15 @@ import invariant from "tiny-invariant";
18
18
  import { IFieldTypeUnion, IFieldValueUnion, IModelDef } from "../../lib/pack-docschema-api/pack-docschema-ir/index.js";
19
19
  import { assertNever } from "../assertNever.js";
20
20
  import { convertStepsToSchema } from "./convertStepsToSchema.js";
21
+
22
+ /**
23
+ * Per-field version provenance for a schema, keyed by model export key then
24
+ * field name. Supplied by the version-aware caller (`resolveSchemaChain`) so the
25
+ * IR records the version each field first appeared in (and any deprecation)
26
+ * instead of a placeholder. When omitted, fields fall back to the schema's
27
+ * top-level version (correct for single-version / steps-based callers).
28
+ */
29
+
21
30
  /**
22
31
  * Converts migration steps to Palantir IR format
23
32
  */
@@ -35,9 +44,12 @@ export function convertStepsToIr(steps, metadata) {
35
44
  }
36
45
 
37
46
  /**
38
- * Converts record and union definitions to Palantir IR format
47
+ * Converts record and union definitions to Palantir IR format. When
48
+ * `provenance` is supplied (by the version-aware caller), each field/model is
49
+ * stamped with the version it first appeared in and any deprecation; otherwise
50
+ * everything falls back to `metadata.version` (default 1).
39
51
  */
40
- export function convertSchemaToIr(inputSchema, metadata) {
52
+ export function convertSchemaToIr(inputSchema, metadata, provenance) {
41
53
  // Build a mapping from declared model name → export key so that union variant
42
54
  // refs (which use declared model names) can be remapped to export keys.
43
55
  const nameToExportKey = new Map();
@@ -46,68 +58,81 @@ export function convertSchemaToIr(inputSchema, metadata) {
46
58
  !(existing == null) ? process.env.NODE_ENV !== "production" ? invariant(false, `Duplicate declared model name "${modelDef.name}": exported as both "${existing}" and "${exportKey}"`) : invariant(false) : void 0;
47
59
  nameToExportKey.set(modelDef.name, exportKey);
48
60
  }
61
+ const fallbackVersion = metadata?.version ?? 1;
49
62
  const primaryModelKeys = [];
50
63
  const models = new Map();
51
64
  for (const [exportKey, modelDef] of Object.entries(inputSchema)) {
52
- if (collectModels(exportKey, modelDef, nameToExportKey, models)) {
65
+ if (collectModels(exportKey, modelDef, nameToExportKey, models, fallbackVersion, provenance)) {
53
66
  primaryModelKeys.push(exportKey);
54
67
  }
55
68
  }
56
69
  return {
57
70
  name: metadata?.name ?? "Generated Schema",
58
71
  description: metadata?.description ?? "Schema generated from migration steps",
59
- version: metadata?.version ?? 1,
72
+ version: fallbackVersion,
60
73
  primaryModelKeys,
61
74
  models: Object.fromEntries(models)
62
75
  };
63
76
  }
64
- function collectModels(exportKey, modelDef, nameToExportKey, outModels) {
77
+ function collectModels(exportKey, modelDef, nameToExportKey, outModels, fallbackVersion, provenance) {
65
78
  !!outModels.has(exportKey) ? process.env.NODE_ENV !== "production" ? invariant(false, `Duplicate model definition: ${exportKey}`) : invariant(false) : void 0;
66
79
  switch (modelDef.type) {
67
80
  case "record":
68
81
  {
69
- outModels.set(exportKey, IModelDef.record(convertRecordDefToIr(modelDef, exportKey, nameToExportKey)));
82
+ outModels.set(exportKey, IModelDef.record(convertRecordDefToIr(modelDef, exportKey, nameToExportKey, fallbackVersion, provenance)));
70
83
  return true;
71
84
  }
72
85
  case "union":
73
86
  {
74
- outModels.set(exportKey, IModelDef.union(convertUnionDefToIr(modelDef, exportKey, nameToExportKey)));
87
+ outModels.set(exportKey, IModelDef.union(convertUnionDefToIr(modelDef, exportKey, nameToExportKey, fallbackVersion, provenance)));
75
88
  return true;
76
89
  }
77
90
  default:
78
91
  assertNever(modelDef);
79
92
  }
80
93
  }
81
- export function convertRecordDefToIr(recordDef, exportKey, nameToExportKey) {
82
- const key = exportKey ?? recordDef.name;
83
- const fields = Object.entries(recordDef.fields).map(([fieldKey, fieldType]) => ({
84
- key: fieldKey,
85
- name: fieldKey,
86
- description: undefined,
87
- fieldType: convertTypeToFieldTypeUnion(fieldType, nameToExportKey),
88
- metadata: {
89
- addedInVersion: 1
90
- },
91
- isOptional: fieldType.type === "optional" ? true : undefined
92
- }));
94
+ export function convertRecordDefToIr(recordDef, exportKey, nameToExportKey, fallbackVersion = 1, provenance) {
95
+ const modelKey = exportKey ?? recordDef.name;
96
+ const fieldVersions = provenance?.fieldVersions?.[modelKey];
97
+ const deprecations = provenance?.deprecations?.[modelKey];
98
+ const fields = Object.entries(recordDef.fields).map(([fieldKey, fieldType]) => {
99
+ const dep = deprecations?.[fieldKey];
100
+ return {
101
+ key: fieldKey,
102
+ name: fieldKey,
103
+ description: undefined,
104
+ fieldType: convertTypeToFieldTypeUnion(fieldType, nameToExportKey),
105
+ metadata: {
106
+ addedInVersion: fieldVersions?.[fieldKey] ?? fallbackVersion,
107
+ ...(dep != null ? {
108
+ deprecatedFromVersion: dep.fromVersion,
109
+ ...(dep.message != null ? {
110
+ deprecatedMessage: dep.message
111
+ } : {})
112
+ } : {})
113
+ },
114
+ isOptional: fieldType.type === "optional" ? true : undefined
115
+ };
116
+ });
93
117
  return {
94
- key,
118
+ key: modelKey,
95
119
  name: recordDef.name,
96
120
  description: recordDef.docs ?? undefined,
97
121
  fields
98
122
  };
99
123
  }
100
- export function convertUnionDefToIr(unionDef, exportKey, nameToExportKey) {
101
- const key = exportKey ?? unionDef.name;
124
+ export function convertUnionDefToIr(unionDef, exportKey, nameToExportKey, fallbackVersion = 1, provenance) {
125
+ const modelKey = exportKey ?? unionDef.name;
102
126
  const variantEntries = Object.entries(unionDef.variants).map(([variantName, modelRef]) => [variantName, nameToExportKey?.get(modelRef.name) ?? modelRef.name]);
127
+ const unionAddedIn = provenance?.modelVersions?.[modelKey] ?? fallbackVersion;
103
128
  return {
104
- key,
129
+ key: modelKey,
105
130
  name: unionDef.name,
106
131
  description: unionDef.docs,
107
132
  discriminant: unionDef.discriminant,
108
133
  variants: Object.fromEntries(variantEntries),
109
134
  metadata: {
110
- addedInVersion: 1
135
+ addedInVersion: unionAddedIn
111
136
  }
112
137
  };
113
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"convertStepsToIr.js","names":["invariant","IFieldTypeUnion","IFieldValueUnion","IModelDef","assertNever","convertStepsToSchema","convertStepsToIr","steps","metadata","recordDefinitions","unionDefinitions","schema","Object","fromEntries","map","def","name","convertSchemaToIr","inputSchema","nameToExportKey","Map","exportKey","modelDef","entries","existing","get","process","env","NODE_ENV","set","primaryModelKeys","models","collectModels","push","description","version","outModels","has","type","record","convertRecordDefToIr","union","convertUnionDefToIr","recordDef","key","fields","fieldKey","fieldType","undefined","convertTypeToFieldTypeUnion","addedInVersion","isOptional","docs","unionDef","variantEntries","variants","variantName","modelRef","discriminant","schemaType","items","allowNullValue","elementType","item","array","value","convertTypeToFieldValueUnion","Error","boolean","docRef","documentTypeRids","double","mediaRef","object","interfaceTypeRids","objectTypeRids","modelKey","modelTypes","string","unmanagedJson","userRef"],"sources":["convertStepsToIr.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as P from \"@palantir/pack.schema\";\nimport invariant from \"tiny-invariant\";\nimport type {\n IModelTypeKey,\n IUnionVariantKey,\n} from \"../../lib/pack-docschema-api/pack-docschema-api\";\nimport type {\n IFieldDef,\n IRealTimeDocumentSchema,\n IRecordDef,\n IUnionDef,\n} from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport {\n IFieldTypeUnion,\n IFieldValueUnion,\n IModelDef,\n} from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { assertNever } from \"../assertNever.js\";\nimport { convertStepsToSchema } from \"./convertStepsToSchema.js\";\nimport type { MigrationStep } from \"./parseMigrationSteps.js\";\n\nexport interface SchemaMetadata {\n readonly name?: string;\n readonly description?: string;\n readonly version?: number;\n}\n\n/**\n * Converts migration steps to Palantir IR format\n */\nexport function convertStepsToIr(\n steps: readonly MigrationStep[],\n metadata?: SchemaMetadata,\n): IRealTimeDocumentSchema {\n // First convert steps to document-schema-api format\n const { recordDefinitions, unionDefinitions } = convertStepsToSchema(steps as MigrationStep[]);\n\n const schema = {\n ...Object.fromEntries(recordDefinitions.map(def => [def.name, def])),\n ...Object.fromEntries(unionDefinitions.map(def => [def.name, def])),\n };\n\n return convertSchemaToIr(schema, metadata);\n}\n\n/**\n * Converts record and union definitions to Palantir IR format\n */\nexport function convertSchemaToIr(\n inputSchema: P.Schema<P.ReturnedSchema>,\n metadata?: SchemaMetadata,\n): IRealTimeDocumentSchema {\n // Build a mapping from declared model name → export key so that union variant\n // refs (which use declared model names) can be remapped to export keys.\n const nameToExportKey = new Map<string, string>();\n for (const [exportKey, modelDef] of Object.entries(inputSchema)) {\n const existing = nameToExportKey.get(modelDef.name);\n invariant(\n existing == null,\n `Duplicate declared model name \"${modelDef.name}\": exported as both \"${existing}\" and \"${exportKey}\"`,\n );\n nameToExportKey.set(modelDef.name, exportKey);\n }\n\n const primaryModelKeys: IModelTypeKey[] = [];\n const models = new Map<IModelTypeKey, IModelDef>();\n\n for (const [exportKey, modelDef] of Object.entries(inputSchema)) {\n if (collectModels(exportKey, modelDef, nameToExportKey, models)) {\n primaryModelKeys.push(exportKey);\n }\n }\n\n return {\n name: metadata?.name ?? \"Generated Schema\",\n description: metadata?.description ?? \"Schema generated from migration steps\",\n version: metadata?.version ?? 1,\n primaryModelKeys,\n models: Object.fromEntries(models),\n };\n}\n\nfunction collectModels(\n exportKey: string,\n modelDef: P.ModelDef,\n nameToExportKey: Map<string, string>,\n outModels: Map<IModelTypeKey, IModelDef>,\n): boolean {\n invariant(\n !outModels.has(exportKey),\n `Duplicate model definition: ${exportKey}`,\n );\n\n switch (modelDef.type) {\n case \"record\": {\n outModels.set(\n exportKey,\n IModelDef.record(convertRecordDefToIr(modelDef, exportKey, nameToExportKey)),\n );\n return true;\n }\n case \"union\": {\n outModels.set(\n exportKey,\n IModelDef.union(convertUnionDefToIr(modelDef, exportKey, nameToExportKey)),\n );\n return true;\n }\n default:\n assertNever(modelDef);\n }\n}\n\nexport function convertRecordDefToIr(\n recordDef: P.RecordDef,\n exportKey?: string,\n nameToExportKey?: Map<string, string>,\n): IRecordDef {\n const key = exportKey ?? recordDef.name;\n const fields = Object.entries(recordDef.fields).map(([fieldKey, fieldType]): IFieldDef => ({\n key: fieldKey,\n name: fieldKey,\n description: undefined,\n fieldType: convertTypeToFieldTypeUnion(fieldType, nameToExportKey),\n metadata: { addedInVersion: 1 },\n isOptional: fieldType.type === \"optional\" ? true : undefined,\n }));\n\n return {\n key,\n name: recordDef.name,\n description: recordDef.docs ?? undefined,\n fields,\n };\n}\n\nexport function convertUnionDefToIr(\n unionDef: P.UnionDef,\n exportKey?: string,\n nameToExportKey?: Map<string, string>,\n): IUnionDef {\n const key = exportKey ?? unionDef.name;\n const variantEntries = Object.entries(unionDef.variants).map((\n [variantName, modelRef],\n ) =>\n [\n variantName as IUnionVariantKey,\n (nameToExportKey?.get(modelRef.name) ?? modelRef.name) as IModelTypeKey,\n ] as const\n );\n\n return {\n key,\n name: unionDef.name,\n description: unionDef.docs,\n discriminant: unionDef.discriminant,\n variants: Object.fromEntries(variantEntries),\n metadata: { addedInVersion: 1 },\n };\n}\n\n// TODO: rename to convertSchemaTypeToFieldTypeUnion\nexport function convertTypeToFieldTypeUnion(\n schemaType: P.Type,\n nameToExportKey?: Map<string, string>,\n): IFieldTypeUnion {\n switch (schemaType.type) {\n case \"array\": {\n // P.Array.items is typed as TypeBase due to the generic; narrow via type field\n const items = schemaType.items as P.Type;\n const allowNullValue = items.type === \"optional\";\n const elementType: P.Type = allowNullValue ? (items as P.Optional).item as P.Type : items;\n return IFieldTypeUnion.array({\n allowNullValue,\n value: convertTypeToFieldValueUnion(elementType, nameToExportKey),\n });\n }\n\n case \"optional\":\n // Optional flag is handled at field level; unwrap and recurse on inner type\n return convertTypeToFieldTypeUnion(schemaType.item as P.Type, nameToExportKey);\n\n case \"boolean\":\n case \"docRef\":\n case \"double\":\n case \"mediaRef\":\n case \"objectRef\":\n case \"ref\":\n case \"string\":\n case \"unknown\":\n case \"userRef\":\n return IFieldTypeUnion.value(convertTypeToFieldValueUnion(schemaType, nameToExportKey));\n\n default:\n assertNever(schemaType);\n }\n}\n\nfunction convertTypeToFieldValueUnion(\n schemaType: P.Type,\n nameToExportKey?: Map<string, string>,\n): IFieldValueUnion {\n switch (schemaType.type) {\n case \"array\":\n throw new Error(\n \"Nested arrays are not supported in the IR. \"\n + \"Wrap the inner array in a record instead.\",\n );\n\n case \"boolean\":\n return IFieldValueUnion.boolean({});\n\n case \"docRef\":\n return IFieldValueUnion.docRef({\n documentTypeRids: [], // FIXME: confirm whether we will use rids in the deployed schema.\n });\n\n case \"double\":\n return IFieldValueUnion.double({});\n\n case \"mediaRef\":\n return IFieldValueUnion.mediaRef({});\n\n case \"objectRef\":\n return IFieldValueUnion.object({\n // FIXME: confirm whether we will use rids in the deployed schema.\n interfaceTypeRids: [],\n objectTypeRids: [],\n });\n\n case \"optional\":\n // Nested optional — unwrap and continue\n // TODO: probably warn? maybe throw\n return convertTypeToFieldValueUnion(schemaType.item as P.Type, nameToExportKey);\n\n case \"ref\": {\n const modelKey = nameToExportKey?.get(schemaType.name) ?? schemaType.name;\n return IFieldValueUnion.modelRef({ modelTypes: [modelKey as IModelTypeKey] });\n }\n\n case \"string\":\n return IFieldValueUnion.string({});\n\n case \"unknown\":\n return IFieldValueUnion.unmanagedJson({});\n\n case \"userRef\":\n return IFieldValueUnion.userRef({});\n\n default:\n assertNever(schemaType);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AAWtC,SACEC,eAAe,EACfC,gBAAgB,EAChBC,SAAS,QACJ,yDAAyD;AAChE,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,oBAAoB,QAAQ,2BAA2B;AAShE;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,KAA+B,EAC/BC,QAAyB,EACA;EACzB;EACA,MAAM;IAAEC,iBAAiB;IAAEC;EAAiB,CAAC,GAAGL,oBAAoB,CAACE,KAAwB,CAAC;EAE9F,MAAMI,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C,CAAC,CAAC,CAAC;IAEtC,KAAK,WAAW;MACd,OAAOtE,gBAAgB,CAACuE,MAAM,CAAC;QAC7B;QACAC,iBAAiB,EAAE,EAAE;QACrBC,cAAc,EAAE;MAClB,CAAC,CAAC;IAEJ,KAAK,UAAU;MACb;MACA;MACA,OAAOT,4BAA4B,CAACP,UAAU,CAACI,IAAI,EAAY5C,eAAe,CAAC;IAEjF,KAAK,KAAK;MAAE;QACV,MAAMyD,QAAQ,GAAGzD,eAAe,EAAEM,GAAG,CAACkC,UAAU,CAAC3C,IAAI,CAAC,IAAI2C,UAAU,CAAC3C,IAAI;QACzE,OAAOd,gBAAgB,CAACuD,QAAQ,CAAC;UAAEoB,UAAU,EAAE,CAACD,QAAQ;QAAmB,CAAC,CAAC;MAC/E;IAEA,KAAK,QAAQ;MACX,OAAO1E,gBAAgB,CAAC4E,MAAM,CAAC,CAAC,CAAC,CAAC;IAEpC,KAAK,SAAS;MACZ,OAAO5E,gBAAgB,CAAC6E,aAAa,CAAC,CAAC,CAAC,CAAC;IAE3C,KAAK,SAAS;MACZ,OAAO7E,gBAAgB,CAAC8E,OAAO,CAAC,CAAC,CAAC,CAAC;IAErC;MACE5E,WAAW,CAACuD,UAAU,CAAC;EAC3B;AACF","ignoreList":[]}
1
+ {"version":3,"file":"convertStepsToIr.js","names":["invariant","IFieldTypeUnion","IFieldValueUnion","IModelDef","assertNever","convertStepsToSchema","convertStepsToIr","steps","metadata","recordDefinitions","unionDefinitions","schema","Object","fromEntries","map","def","name","convertSchemaToIr","inputSchema","provenance","nameToExportKey","Map","exportKey","modelDef","entries","existing","get","process","env","NODE_ENV","set","fallbackVersion","version","primaryModelKeys","models","collectModels","push","description","outModels","has","type","record","convertRecordDefToIr","union","convertUnionDefToIr","recordDef","modelKey","fieldVersions","deprecations","fields","fieldKey","fieldType","dep","key","undefined","convertTypeToFieldTypeUnion","addedInVersion","deprecatedFromVersion","fromVersion","message","deprecatedMessage","isOptional","docs","unionDef","variantEntries","variants","variantName","modelRef","unionAddedIn","modelVersions","discriminant","schemaType","items","allowNullValue","elementType","item","array","value","convertTypeToFieldValueUnion","Error","boolean","docRef","documentTypeRids","double","mediaRef","object","interfaceTypeRids","objectTypeRids","modelTypes","string","unmanagedJson","userRef"],"sources":["convertStepsToIr.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as P from \"@palantir/pack.schema\";\nimport invariant from \"tiny-invariant\";\nimport type {\n IModelTypeKey,\n IUnionVariantKey,\n} from \"../../lib/pack-docschema-api/pack-docschema-api\";\nimport type {\n IFieldDef,\n IRealTimeDocumentSchema,\n IRecordDef,\n IUnionDef,\n} from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport {\n IFieldTypeUnion,\n IFieldValueUnion,\n IModelDef,\n} from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { assertNever } from \"../assertNever.js\";\nimport { convertStepsToSchema } from \"./convertStepsToSchema.js\";\nimport type { MigrationStep } from \"./parseMigrationSteps.js\";\n\nexport interface SchemaMetadata {\n readonly name?: string;\n readonly description?: string;\n readonly version?: number;\n}\n\n/**\n * Per-field version provenance for a schema, keyed by model export key then\n * field name. Supplied by the version-aware caller (`resolveSchemaChain`) so the\n * IR records the version each field first appeared in (and any deprecation)\n * instead of a placeholder. When omitted, fields fall back to the schema's\n * top-level version (correct for single-version / steps-based callers).\n */\nexport interface SchemaProvenance {\n readonly fieldVersions?: Record<string, Record<string, number>>;\n readonly modelVersions?: Record<string, number>;\n readonly deprecations?: P.VersionDeprecations;\n}\n\n/**\n * Converts migration steps to Palantir IR format\n */\nexport function convertStepsToIr(\n steps: readonly MigrationStep[],\n metadata?: SchemaMetadata,\n): IRealTimeDocumentSchema {\n // First convert steps to document-schema-api format\n const { recordDefinitions, unionDefinitions } = convertStepsToSchema(steps as MigrationStep[]);\n\n const schema = {\n ...Object.fromEntries(recordDefinitions.map(def => [def.name, def])),\n ...Object.fromEntries(unionDefinitions.map(def => [def.name, def])),\n };\n\n return convertSchemaToIr(schema, metadata);\n}\n\n/**\n * Converts record and union definitions to Palantir IR format. When\n * `provenance` is supplied (by the version-aware caller), each field/model is\n * stamped with the version it first appeared in and any deprecation; otherwise\n * everything falls back to `metadata.version` (default 1).\n */\nexport function convertSchemaToIr(\n inputSchema: P.Schema<P.ReturnedSchema>,\n metadata?: SchemaMetadata,\n provenance?: SchemaProvenance,\n): IRealTimeDocumentSchema {\n // Build a mapping from declared model name → export key so that union variant\n // refs (which use declared model names) can be remapped to export keys.\n const nameToExportKey = new Map<string, string>();\n for (const [exportKey, modelDef] of Object.entries(inputSchema)) {\n const existing = nameToExportKey.get(modelDef.name);\n invariant(\n existing == null,\n `Duplicate declared model name \"${modelDef.name}\": exported as both \"${existing}\" and \"${exportKey}\"`,\n );\n nameToExportKey.set(modelDef.name, exportKey);\n }\n const fallbackVersion = metadata?.version ?? 1;\n\n const primaryModelKeys: IModelTypeKey[] = [];\n const models = new Map<IModelTypeKey, IModelDef>();\n\n for (const [exportKey, modelDef] of Object.entries(inputSchema)) {\n if (collectModels(exportKey, modelDef, nameToExportKey, models, fallbackVersion, provenance)) {\n primaryModelKeys.push(exportKey);\n }\n }\n\n return {\n name: metadata?.name ?? \"Generated Schema\",\n description: metadata?.description ?? \"Schema generated from migration steps\",\n version: fallbackVersion,\n primaryModelKeys,\n models: Object.fromEntries(models),\n };\n}\n\nfunction collectModels(\n exportKey: string,\n modelDef: P.ModelDef,\n nameToExportKey: Map<string, string>,\n outModels: Map<IModelTypeKey, IModelDef>,\n fallbackVersion: number,\n provenance?: SchemaProvenance,\n): boolean {\n invariant(\n !outModels.has(exportKey),\n `Duplicate model definition: ${exportKey}`,\n );\n\n switch (modelDef.type) {\n case \"record\": {\n outModels.set(\n exportKey,\n IModelDef.record(\n convertRecordDefToIr(modelDef, exportKey, nameToExportKey, fallbackVersion, provenance),\n ),\n );\n return true;\n }\n case \"union\": {\n outModels.set(\n exportKey,\n IModelDef.union(\n convertUnionDefToIr(modelDef, exportKey, nameToExportKey, fallbackVersion, provenance),\n ),\n );\n return true;\n }\n default:\n assertNever(modelDef);\n }\n}\n\nexport function convertRecordDefToIr(\n recordDef: P.RecordDef,\n exportKey?: string,\n nameToExportKey?: Map<string, string>,\n fallbackVersion: number = 1,\n provenance?: SchemaProvenance,\n): IRecordDef {\n const modelKey = exportKey ?? recordDef.name;\n const fieldVersions = provenance?.fieldVersions?.[modelKey];\n const deprecations = provenance?.deprecations?.[modelKey];\n const fields = Object.entries(recordDef.fields).map(([fieldKey, fieldType]): IFieldDef => {\n const dep = deprecations?.[fieldKey];\n return {\n key: fieldKey,\n name: fieldKey,\n description: undefined,\n fieldType: convertTypeToFieldTypeUnion(fieldType, nameToExportKey),\n metadata: {\n addedInVersion: fieldVersions?.[fieldKey] ?? fallbackVersion,\n ...(dep != null\n ? {\n deprecatedFromVersion: dep.fromVersion,\n ...(dep.message != null ? { deprecatedMessage: dep.message } : {}),\n }\n : {}),\n },\n isOptional: fieldType.type === \"optional\" ? true : undefined,\n };\n });\n\n return {\n key: modelKey,\n name: recordDef.name,\n description: recordDef.docs ?? undefined,\n fields,\n };\n}\n\nexport function convertUnionDefToIr(\n unionDef: P.UnionDef,\n exportKey?: string,\n nameToExportKey?: Map<string, string>,\n fallbackVersion: number = 1,\n provenance?: SchemaProvenance,\n): IUnionDef {\n const modelKey = exportKey ?? unionDef.name;\n const variantEntries = Object.entries(unionDef.variants).map((\n [variantName, modelRef],\n ) =>\n [\n variantName as IUnionVariantKey,\n (nameToExportKey?.get(modelRef.name) ?? modelRef.name) as IModelTypeKey,\n ] as const\n );\n\n const unionAddedIn = provenance?.modelVersions?.[modelKey] ?? fallbackVersion;\n\n return {\n key: modelKey,\n name: unionDef.name,\n description: unionDef.docs,\n discriminant: unionDef.discriminant,\n variants: Object.fromEntries(variantEntries),\n metadata: { addedInVersion: unionAddedIn },\n };\n}\n\n// TODO: rename to convertSchemaTypeToFieldTypeUnion\nexport function convertTypeToFieldTypeUnion(\n schemaType: P.Type,\n nameToExportKey?: Map<string, string>,\n): IFieldTypeUnion {\n switch (schemaType.type) {\n case \"array\": {\n // P.Array.items is typed as TypeBase due to the generic; narrow via type field\n const items = schemaType.items as P.Type;\n const allowNullValue = items.type === \"optional\";\n const elementType: P.Type = allowNullValue ? (items as P.Optional).item as P.Type : items;\n return IFieldTypeUnion.array({\n allowNullValue,\n value: convertTypeToFieldValueUnion(elementType, nameToExportKey),\n });\n }\n\n case \"optional\":\n // Optional flag is handled at field level; unwrap and recurse on inner type\n return convertTypeToFieldTypeUnion(schemaType.item as P.Type, nameToExportKey);\n\n case \"boolean\":\n case \"docRef\":\n case \"double\":\n case \"mediaRef\":\n case \"objectRef\":\n case \"ref\":\n case \"string\":\n case \"unknown\":\n case \"userRef\":\n return IFieldTypeUnion.value(convertTypeToFieldValueUnion(schemaType, nameToExportKey));\n\n default:\n assertNever(schemaType);\n }\n}\n\nfunction convertTypeToFieldValueUnion(\n schemaType: P.Type,\n nameToExportKey?: Map<string, string>,\n): IFieldValueUnion {\n switch (schemaType.type) {\n case \"array\":\n throw new Error(\n \"Nested arrays are not supported in the IR. \"\n + \"Wrap the inner array in a record instead.\",\n );\n\n case \"boolean\":\n return IFieldValueUnion.boolean({});\n\n case \"docRef\":\n return IFieldValueUnion.docRef({\n documentTypeRids: [], // FIXME: confirm whether we will use rids in the deployed schema.\n });\n\n case \"double\":\n return IFieldValueUnion.double({});\n\n case \"mediaRef\":\n return IFieldValueUnion.mediaRef({});\n\n case \"objectRef\":\n return IFieldValueUnion.object({\n // FIXME: confirm whether we will use rids in the deployed schema.\n interfaceTypeRids: [],\n objectTypeRids: [],\n });\n\n case \"optional\":\n // Nested optional — unwrap and continue\n // TODO: probably warn? maybe throw\n return convertTypeToFieldValueUnion(schemaType.item as P.Type, nameToExportKey);\n\n case \"ref\": {\n const modelKey = nameToExportKey?.get(schemaType.name) ?? schemaType.name;\n return IFieldValueUnion.modelRef({ modelTypes: [modelKey as IModelTypeKey] });\n }\n\n case \"string\":\n return IFieldValueUnion.string({});\n\n case \"unknown\":\n return IFieldValueUnion.unmanagedJson({});\n\n case \"userRef\":\n return IFieldValueUnion.userRef({});\n\n default:\n assertNever(schemaType);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AAWtC,SACEC,eAAe,EACfC,gBAAgB,EAChBC,SAAS,QACJ,yDAAyD;AAChE,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,oBAAoB,QAAQ,2BAA2B;;AAShE;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,KAA+B,EAC/BC,QAAyB,EACA;EACzB;EACA,MAAM;IAAEC,iBAAiB;IAAEC;EAAiB,CAAC,GAAGL,oBAAoB,CAACE,KAAwB,CAAC;EAE9F,MAAMI,MAAM,GAAG;IACb,GAAGC,MAAM,CAACC,WAAW,CAACJ,iBAAiB,CAACK,GAAG,CAACC,GAAG,IAAI,CAACA,GAAG,CAACC,IAAI,EAAED,GAAG,CAAC,CAAC,CAAC;IACpE,GAAGH,MAAM,CAACC,WAAW,CAACH,gBAAgB,CAACI,GAAG,CAACC,GAAG,IAAI,CAACA,GAAG,CAACC,IAAI,EAAED,GAAG,CAAC,CAAC;EACpE,CAAC;EAED,OAAOE,iBAAiB,CAACN,MAAM,EAAEH,QAAQ,CAAC;AAC5C;;AAEA;AACA;AACA;AAC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AACmE,UAAU,CAAC;EAC3B;AACF","ignoreList":[]}
@@ -3,14 +3,25 @@ interface IrGenAssetOptions {
3
3
  readonly ir: string;
4
4
  readonly output: string;
5
5
  readonly fileSystemType?: FileSystemType;
6
+ readonly compatibilityRangeOutput?: string;
6
7
  }
7
8
  /**
8
- * Generates a document type asset JSON file from an IR schema.
9
+ * Generates a document type asset JSON file (and a sibling schema
10
+ * compatibility range JSON file) from an IR schema.
9
11
  *
10
- * This command is intended for internal platform applications where the document
11
- * type asset must exist on disk so the platform can discover it and register the
12
- * document type automatically at deploy time. Most users should use `ir deploy`
13
- * to register document types via the Foundry API instead.
12
+ * The input IR may be either:
13
+ * - a chain payload `{ latestVersion, minSupportedVersion?, chain }` produced
14
+ * by `schema ir`. The latest entry's `ir` is used as the wire schema; the
15
+ * asset's `schemaVersion` is `latestVersion`; the compatibility range is
16
+ * `{ min: minSupportedVersion ?? latestVersion, max: latestVersion }`.
17
+ * - a bare single-version `IRealTimeDocumentSchema` (legacy). The compat
18
+ * range defaults to `{ min: version, max: version }` since no chain
19
+ * information is available.
20
+ *
21
+ * This command is intended for internal platform applications where the
22
+ * document type asset must exist on disk so the platform can discover it and
23
+ * register the document type automatically at deploy time. Most users should
24
+ * use `ir deploy` to register document types via the Foundry API instead.
14
25
  *
15
26
  * If you are unsure whether you need this command, you almost certainly do not.
16
27
  */
@@ -1 +1 @@
1
- {"version":3,"file":"irGenAssetHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irGenAssetHandler.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,aAAa,CAAC;AAErE,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;CAC1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAuDlE"}
1
+ {"version":3,"file":"irGenAssetHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irGenAssetHandler.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,aAAa,CAAC;AAErE,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CAC5C;AAwDD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAmFlE"}
@@ -1,7 +1,6 @@
1
1
  interface IrGenTypesOptions {
2
2
  schema: string;
3
3
  output: string;
4
- minVersion?: string;
5
4
  }
6
5
  export declare function irGenTypesHandler(options: IrGenTypesOptions): Promise<void>;
7
6
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"irGenTypesHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irGenTypesHandler.ts"],"names":[],"mappings":"AAsBA,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAQD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBjF"}
1
+ {"version":3,"file":"irGenTypesHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irGenTypesHandler.ts"],"names":[],"mappings":"AA0BA,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBjF"}
@@ -1 +1 @@
1
- {"version":3,"file":"registerIrCommands.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/registerIrCommands.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqEzD"}
1
+ {"version":3,"file":"registerIrCommands.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/registerIrCommands.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2EzD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=readPackConfig.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readPackConfig.test.d.ts","sourceRoot":"","sources":["../../../../../src/commands/schema/__tests__/readPackConfig.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"registerSchemaCommands.d.ts","sourceRoot":"","sources":["../../../../src/commands/schema/registerSchemaCommands.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkB7D"}
1
+ {"version":3,"file":"registerSchemaCommands.d.ts","sourceRoot":"","sources":["../../../../src/commands/schema/registerSchemaCommands.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsB7D"}
@@ -1,18 +1,40 @@
1
1
  interface SchemaIrOptions {
2
2
  input: string;
3
3
  output: string;
4
+ config: string;
4
5
  }
6
+ interface PackConfigValues {
7
+ readonly documentTypeName: string;
8
+ readonly documentTypeDescription: string;
9
+ readonly minSupportedVersion?: number;
10
+ }
11
+ export declare function readPackConfig(configPath: string): Promise<PackConfigValues>;
5
12
  /**
6
13
  * Resolve a TypeScript schema module to a versioned IR chain JSON file.
7
14
  *
8
- * The output is a `{ latestVersion, chain }` payload where each entry is
9
- * `{ version, ir, migrations? }` and `ir` is a single-version
10
- * `IRealTimeDocumentSchema`. This is the input format for `ir gen-types`.
15
+ * The output is a `{ latestVersion, minSupportedVersion?, chain }` payload
16
+ * where each entry is `{ version, ir, migrations? }` and `ir` is a
17
+ * single-version `IRealTimeDocumentSchema`. This is the input format for
18
+ * `ir gen-types` and `ir asset`.
19
+ *
20
+ * `--config <pack-config.json>` is required: the pack-config is the single
21
+ * source of truth for document-type identity. Required fields:
22
+ * - `documentTypeName`: the document type name embedded into each chain
23
+ * entry's IR (and surfaced as `documentTypeName` by `ir asset`).
24
+ * - `documentTypeDescription`: document type description embedded into each
25
+ * chain entry's IR.
26
+ * Optional fields:
27
+ * - `minSupportedVersion`: declares the oldest version this SDK supports;
28
+ * when set, it must match one of the chain entries' `version` values and is
29
+ * embedded as `minSupportedVersion` in the payload so downstream consumers
30
+ * (`ir gen-types`, `ir asset`) read the same value. Omitting the field is
31
+ * an explicit opt-out: the IR will not include `minSupportedVersion` and
32
+ * downstream tools default to supporting only the latest schema version.
11
33
  *
12
34
  * Note: this is distinct from the legacy single-version IR JSON consumed by
13
- * `ir deploy` / `ir asset` / `ir zod`, which is a bare `IRealTimeDocumentSchema`
14
- * (no chain, no migrations). Tools that previously read that format should
15
- * pick the entry matching `latestVersion` from `chain` and use its `ir` field.
35
+ * `ir deploy` / `ir zod`, which is a bare `IRealTimeDocumentSchema` (no chain,
36
+ * no migrations). Tools that previously read that format should pick the
37
+ * entry matching `latestVersion` from `chain` and use its `ir` field.
16
38
  */
17
39
  export declare function schemaIrHandler(options: SchemaIrOptions): Promise<void>;
18
40
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"schemaIrHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/schema/schemaIrHandler.ts"],"names":[],"mappings":"AAuBA,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB7E"}
1
+ {"version":3,"file":"schemaIrHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/schema/schemaIrHandler.ts"],"names":[],"mappings":"AAuBA,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAQD,UAAU,gBAAgB;IACxB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACvC;AAwBD,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAiClF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAuC7E"}
@@ -4,7 +4,9 @@ export interface DocumentTypeAsset {
4
4
  readonly documentTypeName: string;
5
5
  readonly documentStorageType: {
6
6
  readonly type: "yjs";
7
- readonly yjs: DocumentTypeSchema;
7
+ readonly yjs: {
8
+ readonly schema: DocumentTypeSchema;
9
+ };
8
10
  };
9
11
  readonly fileSystemType: FileSystemType;
10
12
  readonly schemaVersion: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/types.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,SAAS,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE;QAC5B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;QACrB,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;KAClC,CAAC;IACF,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/types.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,SAAS,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE;QAC5B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;QACrB,QAAQ,CAAC,GAAG,EAAE;YACZ,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;SACrC,CAAC;KACH,CAAC;IACF,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generateDocumentTypeFromSchema.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateDocumentTypeFromSchema.test.d.ts","sourceRoot":"","sources":["../../../../../src/utils/schema/__tests__/generateDocumentTypeFromSchema.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=provenanceScenarios.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenanceScenarios.test.d.ts","sourceRoot":"","sources":["../../../../../src/utils/schema/__tests__/provenanceScenarios.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resolveSchemaChain.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveSchemaChain.test.d.ts","sourceRoot":"","sources":["../../../../../src/utils/schema/__tests__/resolveSchemaChain.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import type { ResolvedIrChain } from "./resolveSchemaChain.js";
2
+ /**
3
+ * Generate documentType.ts: runtime constants for the document type's user-facing
4
+ * identity, sourced from the IR's top-level `name` and `description`.
5
+ *
6
+ * Output:
7
+ * ```
8
+ * export const DOCUMENT_TYPE_NAME = "Canvas Document";
9
+ * export const DOCUMENT_TYPE_DESCRIPTION = "Schema for the Demo Canvas Application";
10
+ * ```
11
+ *
12
+ * Identity is read off the latest chain entry's IR — it is the same string on
13
+ * every entry (populated by `resolveSchemaChain` from pack-config), so the
14
+ * choice of entry is incidental.
15
+ */
16
+ export declare function generateDocumentTypeFromChain(resolved: ResolvedIrChain): string;
17
+ //# sourceMappingURL=generateDocumentTypeFromSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateDocumentTypeFromSchema.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/generateDocumentTypeFromSchema.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAO/E"}
@@ -8,6 +8,7 @@ import type { ResolvedIrChain } from "./resolveSchemaChain.js";
8
8
  * - `types.js` (star export — latest-version type aliases)
9
9
  * - `versions.js` (star export — SupportedVersions, LatestVersion, MinSupportedVersion)
10
10
  * - `versionedDocRef.js` (star export — VersionedDocRef types and factory)
11
+ * - `documentType.js` (star export — DOCUMENT_TYPE_NAME and DOCUMENT_TYPE_DESCRIPTION)
11
12
  * - `DocumentUpgradeFns` type (the typed shape the factory accepts)
12
13
  * - Per supported version: explicit named type exports from `types_vN.js`
13
14
  * (not star exports, to avoid polluting autocomplete for read-only consumers)
@@ -1 +1 @@
1
- {"version":3,"file":"generateIndexFromSchema.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/generateIndexFromSchema.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAY/D;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,mBAAmB,CAAC,EAAE,MAAM,GAC3B,MAAM,CA2CR"}
1
+ {"version":3,"file":"generateIndexFromSchema.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/generateIndexFromSchema.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAa/D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,mBAAmB,CAAC,EAAE,MAAM,GAC3B,MAAM,CA4CR"}
@@ -1 +1 @@
1
- {"version":3,"file":"loadSchemaModule.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/loadSchemaModule.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAM7E;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,OAAO,GAAG,gBAAgB,CAc/E;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAOlF"}
1
+ {"version":3,"file":"loadSchemaModule.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/loadSchemaModule.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAO9D;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,OAAO,GAAG,gBAAgB,CAc/E;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAOlF"}
@@ -16,6 +16,16 @@ export interface ResolvedIrChain {
16
16
  latestVersion: number;
17
17
  minVersion: number;
18
18
  }
19
+ export interface IrChainPayload {
20
+ __comment?: string;
21
+ latestVersion: number;
22
+ minSupportedVersion?: number;
23
+ chain: VersionedIrEntry[];
24
+ }
25
+ export interface SchemaIdentity {
26
+ readonly name?: string;
27
+ readonly description?: string;
28
+ }
19
29
  /**
20
30
  * Validate `minSupportedVersion` against an already-resolved chain and return
21
31
  * the effective `minVersion`. Throws on invalid input.
@@ -27,9 +37,24 @@ export declare function resolveMinVersion(chain: VersionedIrEntry[], minSupporte
27
37
  /**
28
38
  * Collect the version chain and resolve min/latest versions.
29
39
  * Each version's models are converted to IR (IRealTimeDocumentSchema).
40
+ * `identity.name` / `identity.description` are embedded into each chain entry's
41
+ * IR; when omitted (e.g. test callers), `convertSchemaToIr` falls back to its
42
+ * defaults.
30
43
  * Throws on empty chain or invalid minSupportedVersion.
31
44
  */
32
- export declare function resolveSchemaChain(schema: SchemaDefinition, minSupportedVersion?: number): ResolvedIrChain;
45
+ export declare function resolveSchemaChain(schema: SchemaDefinition, minSupportedVersion?: number, identity?: SchemaIdentity): ResolvedIrChain;
46
+ /**
47
+ * Return a copy of the chain with deprecated fields removed from every version
48
+ * at or after the version in which they were deprecated.
49
+ *
50
+ * The SDK type generators (`writeAllSdkFiles` and friends) must treat a
51
+ * deprecated field exactly as a removed field: it disappears from that version's
52
+ * public read/write types and per-version internal types, and the prev/curr diff
53
+ * records it as a `removedField` (driving the upgrade lens). The field is still
54
+ * collected into the all-versions `__Internal` type from earlier versions, which
55
+ * are left untouched.
56
+ */
57
+ export declare function stripDeprecatedFieldsForSdk(chain: VersionedIrEntry[]): VersionedIrEntry[];
33
58
  /**
34
59
  * True if any migration in the chain declares a non-empty `derivedFrom`. Drives
35
60
  * whether the generated SDK emits `DocumentModel` as a factory (requires the
@@ -1 +1 @@
1
- {"version":3,"file":"resolveSchemaChain.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/resolveSchemaChain.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAqB,MAAM,uBAAuB,CAAC;AACjF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yDAAyD,CAAC;AAGvG,0DAA0D;AAC1D,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED,qEAAqE;AACrE,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAC9C,MAAM,EACN,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CACzC,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,uBAAuB,CAAC;IAC5B,UAAU,CAAC,EAAE,2BAA2B,CAAC;CAC1C;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAwCD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,EAAE,EACzB,mBAAmB,EAAE,MAAM,GAAG,SAAS,GACtC;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAkB/C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,gBAAgB,EACxB,mBAAmB,CAAC,EAAE,MAAM,GAC3B,eAAe,CAIjB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAUxE"}
1
+ {"version":3,"file":"resolveSchema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AE,gBAAgB,EACxB,mBAAmB,CAAC,EAAE,MAAM,EAC5B,QAAQ,GAAE,cAAmB,GAC5B,eAAe,CAIjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,gBAAgB,EAAE,CAgBzF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAUxE"}
@@ -26,4 +26,6 @@ export declare const INTERNAL_UPGRADE_FNS_PATH = "./_internal/upgradeFns.js";
26
26
  export declare const VERSIONS_PATH = "./versions.js";
27
27
  /** Versioned doc ref file path: `./versionedDocRef.js` */
28
28
  export declare const VERSIONED_DOC_REF_PATH = "./versionedDocRef.js";
29
+ /** Document type identity constants file path: `./documentType.js` */
30
+ export declare const DOCUMENT_TYPE_PATH = "./documentType.js";
29
31
  //# sourceMappingURL=runtimeSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeSchema.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/runtimeSchema.ts"],"names":[],"mappings":"AAgBA,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED,uDAAuD;AACvD,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAElF;AAED,uDAAuD;AACvD,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED,6CAA6C;AAC7C,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,sDAAsD;AACtD,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,mDAAmD;AACnD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;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AAC;AAEhD,gDAAgD;AAChD,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD,sCAAsC;AACtC,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAEzC,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAEhE,wEAAwE;AACxE,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE,0CAA0C;AAC1C,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C,0DAA0D;AAC1D,eAAO,MAAM,sBAAsB,yBAAyB,CAAC;AAE7D,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,sBAAsB,CAAC"}
@@ -4,5 +4,4 @@ import type { ResolvedIrChain } from "./resolveSchemaChain.js";
4
4
  * them to `outputDir`.
5
5
  */
6
6
  export declare function writeAllSdkFiles(resolved: ResolvedIrChain, outputDir: string, minSupportedVersion: number | undefined): Promise<void>;
7
- export declare function parseMinVersion(minVersion: string | undefined): number | undefined;
8
7
  //# sourceMappingURL=writeAllSdkFiles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeAllSdkFiles.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/writeAllSdkFiles.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,MAAM,EACjB,mBAAmB,EAAE,MAAM,GAAG,SAAS,GACtC,OAAO,CAAC,IAAI,CAAC,CAyEf;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAOlF"}
1
+ {"version":3,"file":"writeAllSdkFiles.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/writeAllSdkFiles.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,MAAM,EACjB,mBAAmB,EAAE,MAAM,GAAG,SAAS,GACtC,OAAO,CAAC,IAAI,CAAC,CAgFf"}