@palantir/pack.document-schema.type-gen 0.20.0 → 0.25.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 (113) hide show
  1. package/README.md +14 -0
  2. package/build/esm/commands/ir/__tests__/irDeployFirstParty.test.js +237 -0
  3. package/build/esm/commands/ir/__tests__/irDeployFirstParty.test.js.map +1 -0
  4. package/build/esm/commands/ir/irDeployHandler.js +81 -41
  5. package/build/esm/commands/ir/irDeployHandler.js.map +1 -1
  6. package/build/esm/commands/ir/irGenAssetHandler.js +13 -0
  7. package/build/esm/commands/ir/irGenAssetHandler.js.map +1 -1
  8. package/build/esm/commands/ir/registerIrCommands.js +2 -2
  9. package/build/esm/commands/ir/registerIrCommands.js.map +1 -1
  10. package/build/esm/lib/pack-docschema-api/pack-docschema-api/index.js +1 -0
  11. package/build/esm/lib/pack-docschema-api/pack-docschema-api/index.js.map +1 -1
  12. package/build/esm/lib/pack-docschema-api/pack-docschema-api/resourceRid.js +2 -0
  13. package/build/esm/lib/pack-docschema-api/pack-docschema-api/resourceRid.js.map +1 -0
  14. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueResourceRef.js +2 -0
  15. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueResourceRef.js.map +1 -0
  16. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueUnion.js +14 -0
  17. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueUnion.js.map +1 -1
  18. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/index.js +1 -0
  19. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/index.js.map +1 -1
  20. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js +1 -1
  21. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js.map +1 -1
  22. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js +3 -2
  23. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js.map +1 -1
  24. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js +1 -1
  25. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js.map +1 -1
  26. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/union-types.js +1 -1
  27. package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/union-types.js.map +1 -1
  28. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/array-and-map-types.js +1 -1
  29. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/array-and-map-types.js.map +1 -1
  30. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js +1 -1
  31. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js.map +1 -1
  32. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/custom-discriminant.js +1 -1
  33. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/custom-discriminant.js.map +1 -1
  34. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js +1 -1
  35. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js.map +1 -1
  36. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js +1 -1
  37. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js.map +1 -1
  38. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-before-records.js +1 -1
  39. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-before-records.js.map +1 -1
  40. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js +1 -1
  41. package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js.map +1 -1
  42. package/build/esm/utils/ir/__tests__/convertIrToConjureSchema.test.js +185 -0
  43. package/build/esm/utils/ir/__tests__/convertIrToConjureSchema.test.js.map +1 -0
  44. package/build/esm/utils/ir/__tests__/convertIrToWireSchema.test.js +6 -0
  45. package/build/esm/utils/ir/__tests__/convertIrToWireSchema.test.js.map +1 -1
  46. package/build/esm/utils/ir/__tests__/generateModelsFromIr.test.js +17 -0
  47. package/build/esm/utils/ir/__tests__/generateModelsFromIr.test.js.map +1 -1
  48. package/build/esm/utils/ir/convertIrToConjureSchema.js +148 -0
  49. package/build/esm/utils/ir/convertIrToConjureSchema.js.map +1 -0
  50. package/build/esm/utils/ir/convertIrToWireSchema.js +7 -0
  51. package/build/esm/utils/ir/convertIrToWireSchema.js.map +1 -1
  52. package/build/esm/utils/ir/generateModelsFromIr.js +3 -1
  53. package/build/esm/utils/ir/generateModelsFromIr.js.map +1 -1
  54. package/build/esm/utils/ir/generateZodSchemasFromIr.js +1 -0
  55. package/build/esm/utils/ir/generateZodSchemasFromIr.js.map +1 -1
  56. package/build/esm/utils/ir/irFieldHelpers.js +24 -11
  57. package/build/esm/utils/ir/irFieldHelpers.js.map +1 -1
  58. package/build/esm/utils/schema/__tests__/__snapshots__/generateDocumentTypeFromSchema/with-name-and-description.js +1 -1
  59. package/build/esm/utils/schema/__tests__/__snapshots__/generateDocumentTypeFromSchema/with-name-and-description.js.map +1 -1
  60. package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/single-version.js.map +1 -1
  61. package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/three-version-chain.js.map +1 -1
  62. package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/two-version.js.map +1 -1
  63. package/build/esm/utils/schema/__tests__/fixtures.js +6 -2
  64. package/build/esm/utils/schema/__tests__/fixtures.js.map +1 -1
  65. package/build/esm/utils/schema/convertSchemaToSteps.js +2 -0
  66. package/build/esm/utils/schema/convertSchemaToSteps.js.map +1 -1
  67. package/build/esm/utils/schema/generateTypesFromSchema.js +13 -8
  68. package/build/esm/utils/schema/generateTypesFromSchema.js.map +1 -1
  69. package/build/esm/utils/steps/__tests__/__snapshots__/types/arrayFields.js.map +1 -1
  70. package/build/esm/utils/steps/__tests__/__snapshots__/types/customDiscriminant.js +1 -1
  71. package/build/esm/utils/steps/__tests__/__snapshots__/types/customDiscriminant.js.map +1 -1
  72. package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js +1 -1
  73. package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js.map +1 -1
  74. package/build/esm/utils/steps/__tests__/__snapshots__/types/refTypes.js.map +1 -1
  75. package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleRecord.js.map +1 -1
  76. package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleSteps.js +1 -1
  77. package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleSteps.js.map +1 -1
  78. package/build/esm/utils/steps/__tests__/fixtures/stepSchemas/refTypes.js +15 -0
  79. package/build/esm/utils/steps/__tests__/fixtures/stepSchemas/refTypes.js.map +1 -1
  80. package/build/esm/utils/steps/convertStepsToIr.js +5 -0
  81. package/build/esm/utils/steps/convertStepsToIr.js.map +1 -1
  82. package/build/esm/utils/steps/convertStepsToSchema.js +5 -0
  83. package/build/esm/utils/steps/convertStepsToSchema.js.map +1 -1
  84. package/build/types/commands/ir/__tests__/irDeployFirstParty.test.d.ts +2 -0
  85. package/build/types/commands/ir/__tests__/irDeployFirstParty.test.d.ts.map +1 -0
  86. package/build/types/commands/ir/irDeployHandler.d.ts +20 -2
  87. package/build/types/commands/ir/irDeployHandler.d.ts.map +1 -1
  88. package/build/types/commands/ir/irGenAssetHandler.d.ts +5 -0
  89. package/build/types/commands/ir/irGenAssetHandler.d.ts.map +1 -1
  90. package/build/types/commands/ir/registerIrCommands.d.ts.map +1 -1
  91. package/build/types/lib/pack-docschema-api/pack-docschema-api/index.d.ts +1 -0
  92. package/build/types/lib/pack-docschema-api/pack-docschema-api/index.d.ts.map +1 -1
  93. package/build/types/lib/pack-docschema-api/pack-docschema-api/resourceRid.d.ts +5 -0
  94. package/build/types/lib/pack-docschema-api/pack-docschema-api/resourceRid.d.ts.map +1 -0
  95. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueResourceRef.d.ts +5 -0
  96. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueResourceRef.d.ts.map +1 -0
  97. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueUnion.d.ts +11 -1
  98. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueUnion.d.ts.map +1 -1
  99. package/build/types/lib/pack-docschema-api/pack-docschema-ir/index.d.ts +1 -0
  100. package/build/types/lib/pack-docschema-api/pack-docschema-ir/index.d.ts.map +1 -1
  101. package/build/types/utils/ir/__tests__/convertIrToConjureSchema.test.d.ts +2 -0
  102. package/build/types/utils/ir/__tests__/convertIrToConjureSchema.test.d.ts.map +1 -0
  103. package/build/types/utils/ir/convertIrToConjureSchema.d.ts +26 -0
  104. package/build/types/utils/ir/convertIrToConjureSchema.d.ts.map +1 -0
  105. package/build/types/utils/ir/generateModelsFromIr.d.ts.map +1 -1
  106. package/build/types/utils/ir/generateZodSchemasFromIr.d.ts.map +1 -1
  107. package/build/types/utils/ir/irFieldHelpers.d.ts +4 -3
  108. package/build/types/utils/ir/irFieldHelpers.d.ts.map +1 -1
  109. package/build/types/utils/schema/__tests__/fixtures.d.ts.map +1 -1
  110. package/build/types/utils/schema/convertSchemaToSteps.d.ts.map +1 -1
  111. package/build/types/utils/schema/generateTypesFromSchema.d.ts.map +1 -1
  112. package/build/types/utils/steps/convertStepsToIr.d.ts.map +1 -1
  113. package/package.json +4 -4
@@ -0,0 +1,185 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { describe, expect, it } from "vitest";
18
+ import { IFieldValueUnion } from "../../../lib/pack-docschema-api/pack-docschema-ir/index.js";
19
+ import { convertIrToConjureSchema } from "../convertIrToConjureSchema.js";
20
+ function schemaWith(models, primaryModelKeys = []) {
21
+ return {
22
+ name: "Test",
23
+ description: "Test",
24
+ version: 1,
25
+ primaryModelKeys,
26
+ models
27
+ };
28
+ }
29
+ describe("convertIrToConjureSchema", () => {
30
+ it("keeps record models nested under `record` (not flattened like the OSDK shape)", () => {
31
+ const record = {
32
+ key: "Person",
33
+ name: "Person",
34
+ fields: [{
35
+ key: "name",
36
+ name: "Name",
37
+ fieldType: {
38
+ type: "value",
39
+ value: IFieldValueUnion.string({})
40
+ },
41
+ metadata: {
42
+ addedInVersion: 1
43
+ }
44
+ }]
45
+ };
46
+ const model = convertIrToConjureSchema(schemaWith({
47
+ Person: {
48
+ type: "record",
49
+ record
50
+ }
51
+ }, ["Person"])).models["Person"];
52
+ expect(model.type).toBe("record");
53
+ expect(model.record.key).toBe("Person"); // nested, not { type: "record", key, name }
54
+ expect(model.record.fields).toHaveLength(1);
55
+ });
56
+ it("keeps union models nested under `union`", () => {
57
+ const model = convertIrToConjureSchema(schemaWith({
58
+ Shape: {
59
+ type: "union",
60
+ union: {
61
+ key: "Shape",
62
+ discriminant: "shapeType",
63
+ name: "Shape",
64
+ variants: {
65
+ circle: "Circle"
66
+ },
67
+ metadata: {
68
+ addedInVersion: 1
69
+ }
70
+ }
71
+ }
72
+ }, ["Shape"])).models["Shape"];
73
+ expect(model.type).toBe("union");
74
+ expect(model.union.discriminant).toBe("shapeType");
75
+ expect(model.union.variants).toEqual({
76
+ circle: "Circle"
77
+ });
78
+ });
79
+ it("keeps a value field's union nested under its discriminant (no flattening)", () => {
80
+ const record = {
81
+ key: "R",
82
+ name: "R",
83
+ fields: [{
84
+ key: "f",
85
+ name: "f",
86
+ fieldType: {
87
+ type: "value",
88
+ value: IFieldValueUnion.string({
89
+ defaultValue: "abc"
90
+ })
91
+ },
92
+ metadata: {
93
+ addedInVersion: 1
94
+ }
95
+ }]
96
+ };
97
+ const model = convertIrToConjureSchema(schemaWith({
98
+ R: {
99
+ type: "record",
100
+ record
101
+ }
102
+ })).models["R"];
103
+
104
+ // Conjure: { type: "value", value: { type: "string", string: { defaultValue: "abc" } } }
105
+ expect(model.record.fields[0].fieldType).toEqual({
106
+ type: "value",
107
+ value: {
108
+ type: "string",
109
+ string: {
110
+ defaultValue: "abc"
111
+ }
112
+ }
113
+ });
114
+ });
115
+ it("wraps collection element types in Conjure's FieldValueType", () => {
116
+ const record = {
117
+ key: "R",
118
+ name: "R",
119
+ fields: [{
120
+ key: "tags",
121
+ name: "Tags",
122
+ fieldType: {
123
+ type: "array",
124
+ array: {
125
+ allowNullValue: false,
126
+ value: IFieldValueUnion.string({})
127
+ }
128
+ },
129
+ metadata: {
130
+ addedInVersion: 1
131
+ }
132
+ }]
133
+ };
134
+ const model = convertIrToConjureSchema(schemaWith({
135
+ R: {
136
+ type: "record",
137
+ record
138
+ }
139
+ })).models["R"];
140
+ expect(model.record.fields[0].fieldType).toEqual({
141
+ type: "array",
142
+ array: {
143
+ allowNullValue: false,
144
+ value: {
145
+ valueType: {
146
+ type: "string",
147
+ string: {}
148
+ }
149
+ }
150
+ }
151
+ });
152
+ });
153
+ it("rejects the NaN sentinel in a double value", () => {
154
+ const record = {
155
+ key: "R",
156
+ name: "R",
157
+ fields: [{
158
+ key: "n",
159
+ name: "N",
160
+ fieldType: {
161
+ type: "value",
162
+ value: IFieldValueUnion.double({
163
+ defaultValue: "NaN"
164
+ })
165
+ },
166
+ metadata: {
167
+ addedInVersion: 1
168
+ }
169
+ }]
170
+ };
171
+ expect(() => convertIrToConjureSchema(schemaWith({
172
+ R: {
173
+ type: "record",
174
+ record
175
+ }
176
+ }))).toThrow(/NaN/);
177
+ });
178
+ it("returns empty models for an empty schema", () => {
179
+ expect(convertIrToConjureSchema(schemaWith({}))).toEqual({
180
+ primaryModelKeys: [],
181
+ models: {}
182
+ });
183
+ });
184
+ });
185
+ //# sourceMappingURL=convertIrToConjureSchema.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertIrToConjureSchema.test.js","names":["describe","expect","it","IFieldValueUnion","convertIrToConjureSchema","schemaWith","models","primaryModelKeys","name","description","version","record","key","fields","fieldType","type","value","string","metadata","addedInVersion","model","Person","toBe","toHaveLength","Shape","union","discriminant","variants","circle","toEqual","defaultValue","R","array","allowNullValue","valueType","double","toThrow"],"sources":["convertIrToConjureSchema.test.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { describe, expect, it } from \"vitest\";\nimport type {\n IModelDef,\n IRealTimeDocumentSchema,\n IRecordDef,\n IUnionDef,\n} from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { IFieldValueUnion } from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { convertIrToConjureSchema } from \"../convertIrToConjureSchema.js\";\n\nfunction schemaWith(\n models: Record<string, IModelDef>,\n primaryModelKeys: string[] = [],\n): IRealTimeDocumentSchema {\n return { name: \"Test\", description: \"Test\", version: 1, primaryModelKeys, models };\n}\n\ndescribe(\"convertIrToConjureSchema\", () => {\n it(\"keeps record models nested under `record` (not flattened like the OSDK shape)\", () => {\n const record: IRecordDef = {\n key: \"Person\",\n name: \"Person\",\n fields: [{\n key: \"name\",\n name: \"Name\",\n fieldType: { type: \"value\", value: IFieldValueUnion.string({}) },\n metadata: { addedInVersion: 1 },\n }],\n };\n\n const model = convertIrToConjureSchema(\n schemaWith({ Person: { type: \"record\", record } as IModelDef }, [\"Person\"]),\n ).models[\"Person\"] as { type: string; record: IRecordDef };\n\n expect(model.type).toBe(\"record\");\n expect(model.record.key).toBe(\"Person\"); // nested, not { type: \"record\", key, name }\n expect(model.record.fields).toHaveLength(1);\n });\n\n it(\"keeps union models nested under `union`\", () => {\n const union: IUnionDef = {\n key: \"Shape\",\n discriminant: \"shapeType\",\n name: \"Shape\",\n variants: { circle: \"Circle\" },\n metadata: { addedInVersion: 1 },\n };\n\n const model = convertIrToConjureSchema(\n schemaWith({ Shape: { type: \"union\", union } as IModelDef }, [\"Shape\"]),\n ).models[\"Shape\"] as { type: string; union: IUnionDef };\n\n expect(model.type).toBe(\"union\");\n expect(model.union.discriminant).toBe(\"shapeType\");\n expect(model.union.variants).toEqual({ circle: \"Circle\" });\n });\n\n it(\"keeps a value field's union nested under its discriminant (no flattening)\", () => {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [{\n key: \"f\",\n name: \"f\",\n fieldType: { type: \"value\", value: IFieldValueUnion.string({ defaultValue: \"abc\" }) },\n metadata: { addedInVersion: 1 },\n }],\n };\n\n const model = convertIrToConjureSchema(\n schemaWith({ R: { type: \"record\", record } as IModelDef }),\n )\n .models[\"R\"] as { record: { fields: Array<{ fieldType: unknown }> } };\n\n // Conjure: { type: \"value\", value: { type: \"string\", string: { defaultValue: \"abc\" } } }\n expect(model.record.fields[0]!.fieldType).toEqual({\n type: \"value\",\n value: { type: \"string\", string: { defaultValue: \"abc\" } },\n });\n });\n\n it(\"wraps collection element types in Conjure's FieldValueType\", () => {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [{\n key: \"tags\",\n name: \"Tags\",\n fieldType: {\n type: \"array\",\n array: { allowNullValue: false, value: IFieldValueUnion.string({}) },\n },\n metadata: { addedInVersion: 1 },\n }],\n };\n\n const model = convertIrToConjureSchema(\n schemaWith({ R: { type: \"record\", record } as IModelDef }),\n )\n .models[\"R\"] as { record: { fields: Array<{ fieldType: unknown }> } };\n\n expect(model.record.fields[0]!.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: { valueType: { type: \"string\", string: {} } },\n },\n });\n });\n\n it(\"rejects the NaN sentinel in a double value\", () => {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [{\n key: \"n\",\n name: \"N\",\n fieldType: { type: \"value\", value: IFieldValueUnion.double({ defaultValue: \"NaN\" }) },\n metadata: { addedInVersion: 1 },\n }],\n };\n\n expect(() =>\n convertIrToConjureSchema(schemaWith({ R: { type: \"record\", record } as IModelDef }))\n )\n .toThrow(/NaN/);\n });\n\n it(\"returns empty models for an empty schema\", () => {\n expect(convertIrToConjureSchema(schemaWith({}))).toEqual({ primaryModelKeys: [], models: {} });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAO7C,SAASC,gBAAgB,QAAQ,4DAA4D;AAC7F,SAASC,wBAAwB,QAAQ,gCAAgC;AAEzE,SAASC,UAAUA,CACjBC,MAAiC,EACjCC,gBAA0B,GAAG,EAAE,EACN;EACzB,OAAO;IAAEC,IAAI,EAAE,MAAM;IAAEC,WAAW,EAAE,MAAM;IAAEC,OAAO,EAAE,CAAC;IAAEH,gBAAgB;IAAED;EAAO,CAAC;AACpF;AAEAN,QAAQ,CAAC,0BAA0B,EAAE,MAAM;EACzCE,EAAE,CAAC,+EAA+E,EAAE,MAAM;IACxF,MAAMS,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,CAAC,MACLG,wBAAwB,CAACC,UAAU,CAAC;MAAE0B,CAAC,EAAE;QAAEhB,IAAI,EAAE,QAAQ;QAAEJ;MAAO;IAAe,CAAC,CAAC,CACrF,CAAC,CACEyB,OAAO,CAAC,KAAK,CAAC;EACnB,CAAC,CAAC;EAEFlC,EAAE,CAAC,0CAA0C,EAAE,MAAM;IACnDD,MAAM,CAACG,wBAAwB,CAACC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACwB,OAAO,CAAC;MAAEtB,gBAAgB,EAAE,EAAE;MAAED,MAAM,EAAE,CAAC;IAAE,CAAC,CAAC;EAChG,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -196,6 +196,12 @@ describe("convertIrToWireSchema", () => {
196
196
  });
197
197
  it("should flatten all field value union variants", () => {
198
198
  const variants = [{
199
+ fn: IFieldValueUnion.resourceRef,
200
+ type: "resourceRef",
201
+ payload: {
202
+ resourceRids: ["rid3"]
203
+ }
204
+ }, {
199
205
  fn: IFieldValueUnion.boolean,
200
206
  type: "boolean",
201
207
  payload: {}
@@ -1 +1 @@
1
- {"version":3,"file":"convertIrToWireSchema.test.js","names":["describe","expect","it","IFieldValueUnion","convertIrToWireSchema","record","key","name","description","fields","fieldType","type","value","string","metadata","addedInVersion","wire","version","primaryModelKeys","models","Person","toEqual","toBeDefined","personModel","toBe","person","nameField","Shape","union","discriminant","variants","circle","square","shapeModel","shape","defaultValue","R","recordModel","field","valueType","array","allowNullValue","fn","boolean","payload","datetime","docRef","documentTypeRids","double","minValue","maxValue","integer","mediaRef","modelRef","modelTypes","object","interfaceTypeRids","objectTypeRids","maxLength","text","unmanagedJson","userRef","wireValue","toBeUndefined","val","Object","entries","FooAlias","model"],"sources":["convertIrToWireSchema.test.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 { FieldValueType, RecordDef, UnionDef } from \"@osdk/foundry.pack\";\nimport { describe, expect, it } from \"vitest\";\nimport type {\n IModelDef,\n IRealTimeDocumentSchema,\n IRecordDef,\n IUnionDef,\n} from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { IFieldValueUnion } from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { convertIrToWireSchema } from \"../convertIrToWireSchema.js\";\n\ndescribe(\"convertIrToWireSchema\", () => {\n it(\"should flatten record model and rename fields correctly\", () => {\n const record: IRecordDef = {\n key: \"Person\",\n name: \"Person\",\n description: \"A person\",\n fields: [\n {\n key: \"name\",\n name: \"Name\",\n fieldType: {\n type: \"value\",\n value: IFieldValueUnion.string({}),\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test schema\",\n version: 1,\n primaryModelKeys: [\"Person\"],\n models: {\n Person: { type: \"record\", record } as IModelDef,\n },\n };\n\n const wire = convertIrToWireSchema(ir);\n\n // Top-level structure\n expect(wire.primaryModelKeys).toEqual([\"Person\"]);\n expect(wire.models).toBeDefined();\n\n // Model is flattened (no .record wrapper)\n const personModel = wire.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel!.type).toBe(\"record\");\n const person = personModel as { type: \"record\" } & RecordDef;\n expect(person.key).toBe(\"Person\");\n expect(person.name).toBe(\"Person\");\n expect(\"record\" in person).toBe(false); // no conjure nesting\n\n // Field uses wire field names\n const nameField = person.fields[0]!;\n expect(nameField.key).toBe(\"name\");\n expect(nameField.fieldType).toBeDefined();\n expect(nameField.metadata).toEqual({ addedInVersion: 1 });\n });\n\n it(\"should flatten union model\", () => {\n const union: IUnionDef = {\n key: \"Shape\",\n discriminant: \"shapeType\",\n name: \"Shape\",\n variants: { circle: \"Circle\", square: \"Square\" },\n metadata: { addedInVersion: 1 },\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test\",\n version: 1,\n primaryModelKeys: [\"Shape\"],\n models: {\n Shape: { type: \"union\", union } as IModelDef,\n },\n };\n\n const wire = convertIrToWireSchema(ir);\n const shapeModel = wire.models[\"Shape\"];\n expect(shapeModel).toBeDefined();\n expect(shapeModel!.type).toBe(\"union\");\n const shape = shapeModel as { type: \"union\" } & UnionDef;\n\n expect(shape.key).toBe(\"Shape\");\n expect(shape.discriminant).toBe(\"shapeType\");\n expect(shape.variants).toEqual({ circle: \"Circle\", square: \"Square\" });\n expect(\"union\" in shape).toBe(false); // no conjure nesting\n });\n\n it(\"should convert value field type with FieldValueType wrapper\", () => {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [\n {\n key: \"f\",\n name: \"f\",\n fieldType: {\n type: \"value\",\n value: IFieldValueUnion.string({ defaultValue: \"abc\" }),\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test\",\n version: 1,\n primaryModelKeys: [\"R\"],\n models: { R: { type: \"record\", record } as IModelDef },\n };\n\n const wire = convertIrToWireSchema(ir);\n expect(wire.models[\"R\"]).toBeDefined();\n expect(wire.models[\"R\"]!.type).toBe(\"record\");\n const recordModel = wire.models[\"R\"] as { type: \"record\" } & RecordDef;\n const field = recordModel.fields[0]!;\n\n // Wire format wraps in { valueType: { type: \"string\", defaultValue: \"abc\" } }\n expect(field.fieldType).toEqual({\n type: \"value\",\n valueType: {\n type: \"string\",\n defaultValue: \"abc\",\n },\n });\n });\n\n it(\"should convert array field type with FieldValueType wrapper on elements\", () => {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [\n {\n key: \"tags\",\n name: \"Tags\",\n fieldType: {\n type: \"array\",\n array: {\n allowNullValue: false,\n value: IFieldValueUnion.string({}),\n },\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test\",\n version: 1,\n primaryModelKeys: [\"R\"],\n models: { R: { type: \"record\", record } as IModelDef },\n };\n\n const wire = convertIrToWireSchema(ir);\n expect(wire.models[\"R\"]).toBeDefined();\n expect(wire.models[\"R\"]!.type).toBe(\"record\");\n const recordModel = wire.models[\"R\"] as { type: \"record\" } & RecordDef;\n const field = recordModel.fields[0]!;\n\n expect(field.fieldType).toEqual({\n type: \"array\",\n allowNullValue: false,\n value: {\n valueType: {\n type: \"string\",\n },\n },\n });\n });\n\n it(\"should flatten all field value union variants\", () => {\n const variants: Array<{\n fn: (payload: never) => IFieldValueUnion;\n type: string;\n payload: Record<string, unknown>;\n }> = [\n { fn: IFieldValueUnion.boolean, type: \"boolean\", payload: {} },\n { fn: IFieldValueUnion.datetime, type: \"datetime\", payload: {} },\n { fn: IFieldValueUnion.docRef, type: \"docRef\", payload: { documentTypeRids: [\"rid1\"] } },\n { fn: IFieldValueUnion.double, type: \"double\", payload: { minValue: 0, maxValue: 100 } },\n { fn: IFieldValueUnion.integer, type: \"integer\", payload: { defaultValue: 42 } },\n { fn: IFieldValueUnion.mediaRef, type: \"mediaRef\", payload: {} },\n { fn: IFieldValueUnion.modelRef, type: \"modelRef\", payload: { modelTypes: [\"Foo\"] } },\n {\n fn: IFieldValueUnion.object,\n type: \"object\",\n payload: { interfaceTypeRids: [], objectTypeRids: [\"rid2\"] },\n },\n { fn: IFieldValueUnion.string, type: \"string\", payload: { maxLength: 255 } },\n { fn: IFieldValueUnion.text, type: \"text\", payload: {} },\n { fn: IFieldValueUnion.unmanagedJson, type: \"unmanagedJson\", payload: {} },\n { fn: IFieldValueUnion.userRef, type: \"userRef\", payload: {} },\n ];\n\n for (const { fn, type, payload } of variants) {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [\n {\n key: \"f\",\n name: \"f\",\n fieldType: {\n type: \"value\",\n value: fn(payload as never),\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test\",\n version: 1,\n primaryModelKeys: [\"R\"],\n models: { R: { type: \"record\", record } as IModelDef },\n };\n\n const wire = convertIrToWireSchema(ir);\n expect(wire.models[\"R\"]).toBeDefined();\n expect(wire.models[\"R\"]!.type).toBe(\"record\");\n const recordModel = wire.models[\"R\"] as { type: \"record\" } & RecordDef;\n const fieldType = recordModel.fields[0]!.fieldType;\n expect(fieldType.type).toBe(\"value\");\n const wireValue = (fieldType as { type: \"value\" } & FieldValueType).valueType;\n expect(wireValue.type).toBe(type);\n // no conjure nesting key\n expect((wireValue as unknown as Record<string, unknown>)[type]).toBeUndefined();\n // Payload fields should be at top level\n for (const [key, val] of Object.entries(payload)) {\n expect((wireValue as unknown as Record<string, unknown>)[key]).toEqual(val);\n }\n }\n });\n\n it(\"should preserve declared name (not export key) for aliased models on the wire\", () => {\n const record: IRecordDef = {\n key: \"FooAlias\",\n name: \"Foo\",\n description: \"A foo\",\n fields: [],\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test\",\n version: 1,\n primaryModelKeys: [\"FooAlias\"],\n models: {\n FooAlias: { type: \"record\", record } as IModelDef,\n },\n };\n\n const wire = convertIrToWireSchema(ir);\n const model = wire.models[\"FooAlias\"] as { type: \"record\"; name: string; key: string };\n // Wire format uses name for on-the-wire identity — must be declared name, not alias\n expect(model.name).toBe(\"Foo\");\n expect(model.key).toBe(\"FooAlias\");\n });\n\n it(\"should strip name, description, version from output\", () => {\n const ir: IRealTimeDocumentSchema = {\n name: \"My Schema\",\n description: \"My description\",\n version: 5,\n primaryModelKeys: [],\n models: {},\n };\n\n const wire = convertIrToWireSchema(ir);\n\n expect(\"name\" in wire).toBe(false);\n expect(\"description\" in wire).toBe(false);\n expect(\"version\" in wire).toBe(false);\n expect(wire.primaryModelKeys).toEqual([]);\n expect(wire.models).toEqual({});\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAO7C,SAASC,gBAAgB,QAAQ,4DAA4D;AAC7F,SAASC,qBAAqB,QAAQ,6BAA6B;AAEnEJ,QAAQ,CAAC,uBAAuB,EAAE,MAAM;EACtCE,EAAE,CAAC,yDAAyD,EAAE,MAAM;IAClE,MAAMG,MAAkB,GAAG;MACzBC,GAAG,EAAE,QAAQ;MACbC,IAAI,EAAE,QAAQ;MACdC,WAAW,EAAE,UAAU;MACvBC,MAAM,EAAE,CACN;QACEH,GAAG,EAAE,MAAM;QACXC,IAAI,EAAE,MAAM;QACZG,SAAS,EAAE;UACTC,IAAI,EAAE,OAAO;UACbC,KAAK,EAAET,gBAAgB,CAACU,MAAM,CAAC,CAAC,CAAC;QACnC,CAAC;QACDC,QAAQ,EAAE;UAAEC,cAAc,EAAE;QAAE;MAChC,CAAC;IAEL,CAAC;IAYD,MAAMC,IAAI,GAAGZ,qBAAqB,CAVE;MAClCG,IAAI,EAAE,MAAM;MACZC,WAAW,EAAE,aAAa;MAC1BS,OAAO,EAAE,CAAC;MACVC,gBAAgB,EAAE,CAAC,QAAQ,CAAC;MAC5BC,MAAM,EAAE;QACNC,MAAM,EAAE;UAAET,IAAI,EAAE,QAAQ;UAAEN;QAAO;MACnC;IACF,CAEqC,CAAC;;IAEtC;IACAJ,MAAM,CAACe,IAAI,CAACE,gBAAgB,CAAC,CAACG,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;IACjDpB,MAAM,CAACe,IAAI,CAACG,MAAM,CAAC,CAACG,WAAW,CAAC,CAAC;;IAEjC;IACA,MAAMC,WAAW,GAAGP,IAAI,CAACG,MAAM,CAAC,QA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;IACrCvB,MAAM,CAACe,IAAI,CAACE,gBAAgB,CAAC,CAACG,OAAO,CAAC,EAAE,CAAC;IACzCpB,MAAM,CAACe,IAAI,CAACG,MAAM,CAAC,CAACE,OAAO,CAAC,CAAC,CAAC,CAAC;EACjC,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"convertIrToWireSchema.test.js","names":["describe","expect","it","IFieldValueUnion","convertIrToWireSchema","record","key","name","description","fields","fieldType","type","value","string","metadata","addedInVersion","wire","version","primaryModelKeys","models","Person","toEqual","toBeDefined","personModel","toBe","person","nameField","Shape","union","discriminant","variants","circle","square","shapeModel","shape","defaultValue","R","recordModel","field","valueType","array","allowNullValue","fn","resourceRef","payload","resourceRids","boolean","datetime","docRef","documentTypeRids","double","minValue","maxValue","integer","mediaRef","modelRef","modelTypes","object","interfaceTypeRids","objectTypeRids","maxLength","text","unmanagedJson","userRef","wireValue","toBeUndefined","val","Object","entries","FooAlias","model"],"sources":["convertIrToWireSchema.test.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 { FieldValueType, RecordDef, UnionDef } from \"@osdk/foundry.pack\";\nimport { describe, expect, it } from \"vitest\";\nimport type {\n IModelDef,\n IRealTimeDocumentSchema,\n IRecordDef,\n IUnionDef,\n} from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { IFieldValueUnion } from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { convertIrToWireSchema } from \"../convertIrToWireSchema.js\";\n\ndescribe(\"convertIrToWireSchema\", () => {\n it(\"should flatten record model and rename fields correctly\", () => {\n const record: IRecordDef = {\n key: \"Person\",\n name: \"Person\",\n description: \"A person\",\n fields: [\n {\n key: \"name\",\n name: \"Name\",\n fieldType: {\n type: \"value\",\n value: IFieldValueUnion.string({}),\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test schema\",\n version: 1,\n primaryModelKeys: [\"Person\"],\n models: {\n Person: { type: \"record\", record } as IModelDef,\n },\n };\n\n const wire = convertIrToWireSchema(ir);\n\n // Top-level structure\n expect(wire.primaryModelKeys).toEqual([\"Person\"]);\n expect(wire.models).toBeDefined();\n\n // Model is flattened (no .record wrapper)\n const personModel = wire.models[\"Person\"];\n expect(personModel).toBeDefined();\n expect(personModel!.type).toBe(\"record\");\n const person = personModel as { type: \"record\" } & RecordDef;\n expect(person.key).toBe(\"Person\");\n expect(person.name).toBe(\"Person\");\n expect(\"record\" in person).toBe(false); // no conjure nesting\n\n // Field uses wire field names\n const nameField = person.fields[0]!;\n expect(nameField.key).toBe(\"name\");\n expect(nameField.fieldType).toBeDefined();\n expect(nameField.metadata).toEqual({ addedInVersion: 1 });\n });\n\n it(\"should flatten union model\", () => {\n const union: IUnionDef = {\n key: \"Shape\",\n discriminant: \"shapeType\",\n name: \"Shape\",\n variants: { circle: \"Circle\", square: \"Square\" },\n metadata: { addedInVersion: 1 },\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test\",\n version: 1,\n primaryModelKeys: [\"Shape\"],\n models: {\n Shape: { type: \"union\", union } as IModelDef,\n },\n };\n\n const wire = convertIrToWireSchema(ir);\n const shapeModel = wire.models[\"Shape\"];\n expect(shapeModel).toBeDefined();\n expect(shapeModel!.type).toBe(\"union\");\n const shape = shapeModel as { type: \"union\" } & UnionDef;\n\n expect(shape.key).toBe(\"Shape\");\n expect(shape.discriminant).toBe(\"shapeType\");\n expect(shape.variants).toEqual({ circle: \"Circle\", square: \"Square\" });\n expect(\"union\" in shape).toBe(false); // no conjure nesting\n });\n\n it(\"should convert value field type with FieldValueType wrapper\", () => {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [\n {\n key: \"f\",\n name: \"f\",\n fieldType: {\n type: \"value\",\n value: IFieldValueUnion.string({ defaultValue: \"abc\" }),\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test\",\n version: 1,\n primaryModelKeys: [\"R\"],\n models: { R: { type: \"record\", record } as IModelDef },\n };\n\n const wire = convertIrToWireSchema(ir);\n expect(wire.models[\"R\"]).toBeDefined();\n expect(wire.models[\"R\"]!.type).toBe(\"record\");\n const recordModel = wire.models[\"R\"] as { type: \"record\" } & RecordDef;\n const field = recordModel.fields[0]!;\n\n // Wire format wraps in { valueType: { type: \"string\", defaultValue: \"abc\" } }\n expect(field.fieldType).toEqual({\n type: \"value\",\n valueType: {\n type: \"string\",\n defaultValue: \"abc\",\n },\n });\n });\n\n it(\"should convert array field type with FieldValueType wrapper on elements\", () => {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [\n {\n key: \"tags\",\n name: \"Tags\",\n fieldType: {\n type: \"array\",\n array: {\n allowNullValue: false,\n value: IFieldValueUnion.string({}),\n },\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test\",\n version: 1,\n primaryModelKeys: [\"R\"],\n models: { R: { type: \"record\", record } as IModelDef },\n };\n\n const wire = convertIrToWireSchema(ir);\n expect(wire.models[\"R\"]).toBeDefined();\n expect(wire.models[\"R\"]!.type).toBe(\"record\");\n const recordModel = wire.models[\"R\"] as { type: \"record\" } & RecordDef;\n const field = recordModel.fields[0]!;\n\n expect(field.fieldType).toEqual({\n type: \"array\",\n allowNullValue: false,\n value: {\n valueType: {\n type: \"string\",\n },\n },\n });\n });\n\n it(\"should flatten all field value union variants\", () => {\n const variants: Array<{\n fn: (payload: never) => IFieldValueUnion;\n type: string;\n payload: Record<string, unknown>;\n }> = [\n {\n fn: IFieldValueUnion.resourceRef,\n type: \"resourceRef\",\n payload: { resourceRids: [\"rid3\"] },\n },\n { fn: IFieldValueUnion.boolean, type: \"boolean\", payload: {} },\n { fn: IFieldValueUnion.datetime, type: \"datetime\", payload: {} },\n { fn: IFieldValueUnion.docRef, type: \"docRef\", payload: { documentTypeRids: [\"rid1\"] } },\n { fn: IFieldValueUnion.double, type: \"double\", payload: { minValue: 0, maxValue: 100 } },\n { fn: IFieldValueUnion.integer, type: \"integer\", payload: { defaultValue: 42 } },\n { fn: IFieldValueUnion.mediaRef, type: \"mediaRef\", payload: {} },\n { fn: IFieldValueUnion.modelRef, type: \"modelRef\", payload: { modelTypes: [\"Foo\"] } },\n {\n fn: IFieldValueUnion.object,\n type: \"object\",\n payload: { interfaceTypeRids: [], objectTypeRids: [\"rid2\"] },\n },\n { fn: IFieldValueUnion.string, type: \"string\", payload: { maxLength: 255 } },\n { fn: IFieldValueUnion.text, type: \"text\", payload: {} },\n { fn: IFieldValueUnion.unmanagedJson, type: \"unmanagedJson\", payload: {} },\n { fn: IFieldValueUnion.userRef, type: \"userRef\", payload: {} },\n ];\n\n for (const { fn, type, payload } of variants) {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [\n {\n key: \"f\",\n name: \"f\",\n fieldType: {\n type: \"value\",\n value: fn(payload as never),\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test\",\n version: 1,\n primaryModelKeys: [\"R\"],\n models: { R: { type: \"record\", record } as IModelDef },\n };\n\n const wire = convertIrToWireSchema(ir);\n expect(wire.models[\"R\"]).toBeDefined();\n expect(wire.models[\"R\"]!.type).toBe(\"record\");\n const recordModel = wire.models[\"R\"] as { type: \"record\" } & RecordDef;\n const fieldType = recordModel.fields[0]!.fieldType;\n expect(fieldType.type).toBe(\"value\");\n const wireValue = (fieldType as { type: \"value\" } & FieldValueType).valueType;\n expect(wireValue.type).toBe(type);\n // no conjure nesting key\n expect((wireValue as unknown as Record<string, unknown>)[type]).toBeUndefined();\n // Payload fields should be at top level\n for (const [key, val] of Object.entries(payload)) {\n expect((wireValue as unknown as Record<string, unknown>)[key]).toEqual(val);\n }\n }\n });\n\n it(\"should preserve declared name (not export key) for aliased models on the wire\", () => {\n const record: IRecordDef = {\n key: \"FooAlias\",\n name: \"Foo\",\n description: \"A foo\",\n fields: [],\n };\n\n const ir: IRealTimeDocumentSchema = {\n name: \"Test\",\n description: \"Test\",\n version: 1,\n primaryModelKeys: [\"FooAlias\"],\n models: {\n FooAlias: { type: \"record\", record } as IModelDef,\n },\n };\n\n const wire = convertIrToWireSchema(ir);\n const model = wire.models[\"FooAlias\"] as { type: \"record\"; name: string; key: string };\n // Wire format uses name for on-the-wire identity — must be declared name, not alias\n expect(model.name).toBe(\"Foo\");\n expect(model.key).toBe(\"FooAlias\");\n });\n\n it(\"should strip name, description, version from output\", () => {\n const ir: IRealTimeDocumentSchema = {\n name: \"My Schema\",\n description: \"My description\",\n version: 5,\n primaryModelKeys: [],\n models: {},\n };\n\n const wire = convertIrToWireSchema(ir);\n\n expect(\"name\" in wire).toBe(false);\n expect(\"description\" in wire).toBe(false);\n expect(\"version\" in wire).toBe(false);\n expect(wire.primaryModelKeys).toEqual([]);\n expect(wire.models).toEqual({});\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAO7C,SAASC,gBAAgB,QAAQ,4DAA4D;AAC7F,SAASC,qBAAqB,QAAQ,6BAA6B;AAEnEJ,QAAQ,CAAC,uBAAuB,EAAE,MAAM;EACtCE,EAAE,CAAC,yDAAyD,EAAE,MAAM;IA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141
141
  metadata: {
142
142
  addedInVersion: 1
143
143
  }
144
+ }, {
145
+ key: "resourceRef",
146
+ name: "Resource Reference",
147
+ description: "A reference to a resource",
148
+ fieldType: {
149
+ type: "value",
150
+ value: {
151
+ type: "resourceRef",
152
+ resourceRef: {
153
+ resourceRids: []
154
+ }
155
+ }
156
+ },
157
+ metadata: {
158
+ addedInVersion: 1
159
+ }
144
160
  }]
145
161
  }
146
162
  }
@@ -152,6 +168,7 @@ describe("generateModelsFromIr", () => {
152
168
  expect(formatted).toContain("externalRefFieldTypes");
153
169
  expect(formatted).toContain("documentRef: 'docRef'");
154
170
  expect(formatted).toContain("userRef: 'userRef'");
171
+ expect(formatted).toContain("resourceRef: 'resourceRef'");
155
172
  await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, "external-refs.ts"));
156
173
  });
157
174
  it("should generate Model constants for union types", async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"generateModelsFromIr.test.js","names":["path","describe","expect","it","generateModelsFromIr","formatWithPrettier","snapshotDir","join","__dirname","result","name","description","version","primaryModelKeys","models","Person","type","record","key","fields","fieldType","value","string","minLength","maxLength","metadata","addedInVersion","integer","minValue","maxValue","formatted","lines","split","importLines","filter","line","startsWith","length","toBeGreaterThan","forEach","toMatch","toMatchFileSnapshot","Event","docRef","documentTypeRids","userRef","datetime","toContain","ObjectNode","double","TextBox","Node","union","discriminant","variants","object","Cat","Dog","Animal","cat","dog"],"sources":["generateModelsFromIr.test.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 path from \"path\";\nimport { describe, expect, it } from \"vitest\";\nimport type {\n IFieldDef,\n IModelDef,\n IRealTimeDocumentSchema,\n IRecordDef,\n IUnionDef,\n} from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { generateModelsFromIr } from \"../generateModelsFromIr.js\";\nimport { formatWithPrettier } from \"./formatWithPrettier.js\";\n\ndescribe(\"generateModelsFromIr\", () => {\n const snapshotDir = path.join(__dirname, \"__snapshots__\", \"generateModelsFromIr\");\n\n it(\"should generate Model constants for simple record types\", async () => {\n const personField1: IFieldDef = {\n key: \"name\",\n name: \"Name\",\n description: \"Person name\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"string\",\n string: { minLength: 2, maxLength: 50 },\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const personField2: IFieldDef = {\n key: \"age\",\n name: \"Age\",\n description: \"Person age\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"integer\",\n integer: { minValue: 0, maxValue: 150 },\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const personRecord: IRecordDef = {\n key: \"Person\",\n name: \"Person\",\n description: \"A person record\",\n fields: [personField1, personField2],\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema\",\n version: 1,\n primaryModelKeys: [\"Person\"],\n models: {\n Person: {\n type: \"record\",\n record: personRecord,\n } as IModelDef,\n },\n };\n\n const result = await generateModelsFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n // Verify imports are properly formatted (no weird indentation)\n const lines = formatted.split(\"\\n\");\n const importLines = lines.filter(line => line.startsWith(\"import\"));\n expect(importLines.length).toBeGreaterThan(0);\n // All imports should start at column 0 (no leading whitespace)\n importLines.forEach(line => {\n expect(line).toMatch(/^import/);\n });\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"simple-record.ts\"));\n });\n\n it(\"should generate Model constants with external ref fields\", async () => {\n const eventField1: IFieldDef = {\n key: \"documentRef\",\n name: \"Document Reference\",\n description: \"Reference to a document\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"docRef\",\n docRef: {\n documentTypeRids: [],\n },\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const eventField2: IFieldDef = {\n key: \"userRef\",\n name: \"User Reference\",\n description: \"Reference to a user\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"userRef\",\n userRef: {},\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const eventField3: IFieldDef = {\n key: \"timestamp\",\n name: \"Timestamp\",\n description: \"Event timestamp\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"datetime\",\n datetime: {},\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const eventRecord: IRecordDef = {\n key: \"Event\",\n name: \"Event\",\n description: \"An event record with external refs\",\n fields: [eventField1, eventField2, eventField3],\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema with external refs\",\n version: 1,\n primaryModelKeys: [\"Event\"],\n models: {\n Event: {\n type: \"record\",\n record: eventRecord,\n } as IModelDef,\n },\n };\n\n const result = await generateModelsFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n // Verify external ref fields are included in metadata\n expect(formatted).toContain(\"externalRefFieldTypes\");\n expect(formatted).toContain(\"documentRef: 'docRef'\");\n expect(formatted).toContain(\"userRef: 'userRef'\");\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"external-refs.ts\"));\n });\n\n it(\"should generate Model constants for union types\", async () => {\n // Define the ObjectNode record\n const objectNodeRecord: IRecordDef = {\n key: \"ObjectNode\",\n name: \"ObjectNode\",\n description: \"A node in the graph\",\n fields: [\n {\n key: \"x\",\n name: \"X\",\n description: \"X coordinate\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n {\n key: \"y\",\n name: \"Y\",\n description: \"Y coordinate\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n // Define the TextBox record\n const textBoxRecord: IRecordDef = {\n key: \"TextBox\",\n name: \"TextBox\",\n description: \"A text box in the graph\",\n fields: [\n {\n key: \"x\",\n name: \"X\",\n description: \"X coordinate\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n {\n key: \"text\",\n name: \"Text\",\n description: \"Text content\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n // Define the Node union\n const nodeUnion: IUnionDef = {\n key: \"Node\",\n discriminant: \"type\",\n name: \"Node\",\n description: \"A node in the graph\",\n variants: {\n object: \"ObjectNode\",\n \"text-box\": \"TextBox\",\n },\n metadata: { addedInVersion: 1 },\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema with unions\",\n version: 1,\n primaryModelKeys: [\"ObjectNode\", \"TextBox\", \"Node\"],\n models: {\n ObjectNode: {\n type: \"record\",\n record: objectNodeRecord,\n } as IModelDef,\n TextBox: {\n type: \"record\",\n record: textBoxRecord,\n } as IModelDef,\n Node: {\n type: \"union\",\n union: nodeUnion,\n } as IModelDef,\n },\n };\n\n const result = await generateModelsFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n // Verify all models are generated (primary models + union variants)\n expect(formatted).toContain(\"export const ObjectNodeModel\");\n expect(formatted).toContain(\"export const TextBoxModel\");\n expect(formatted).toContain(\"export const NodeModel\");\n expect(formatted).toContain(\"export const NodeObjectModel\");\n expect(formatted).toContain(\"export const NodeTextBoxModel\");\n\n // Verify DocumentSchema contains all models\n expect(formatted).toContain(\"export const DocumentModel\");\n expect(formatted).toContain(\"ObjectNode: ObjectNodeModel\");\n expect(formatted).toContain(\"TextBox: TextBoxModel\");\n expect(formatted).toContain(\"Node: NodeModel\");\n expect(formatted).toContain(\"NodeObject: NodeObjectModel\");\n expect(formatted).toContain(\"NodeTextBox: NodeTextBoxModel\");\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"union-types.ts\"));\n });\n\n it(\"should generate Model constants with custom discriminant\", async () => {\n const catRecord: IRecordDef = {\n key: \"Cat\",\n name: \"Cat\",\n description: \"A cat\",\n fields: [\n {\n key: \"meow\",\n name: \"Meow\",\n description: \"Cat sound\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const dogRecord: IRecordDef = {\n key: \"Dog\",\n name: \"Dog\",\n description: \"A dog\",\n fields: [\n {\n key: \"bark\",\n name: \"Bark\",\n description: \"Dog sound\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const animalUnion: IUnionDef = {\n key: \"Animal\",\n discriminant: \"kind\",\n name: \"Animal\",\n description: \"An animal union with custom discriminant\",\n variants: {\n cat: \"Cat\",\n dog: \"Dog\",\n },\n metadata: { addedInVersion: 1 },\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema with custom discriminant\",\n version: 1,\n primaryModelKeys: [\"Cat\", \"Dog\", \"Animal\"],\n models: {\n Cat: {\n type: \"record\",\n record: catRecord,\n } as IModelDef,\n Dog: {\n type: \"record\",\n record: dogRecord,\n } as IModelDef,\n Animal: {\n type: \"union\",\n union: animalUnion,\n } as IModelDef,\n },\n };\n\n const result = await generateModelsFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n expect(formatted).toContain(\"discriminant: 'kind'\");\n expect(formatted).toContain(\"export const AnimalModel\");\n expect(formatted).toContain(\"export const AnimalCatModel\");\n expect(formatted).toContain(\"export const AnimalDogModel\");\n\n await expect(formatted).toMatchFileSnapshot(\n path.join(snapshotDir, \"custom-discriminant.ts\"),\n );\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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wB,CACjD,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"generateModelsFromIr.test.js","names":["path","describe","expect","it","generateModelsFromIr","formatWithPrettier","snapshotDir","join","__dirname","result","name","description","version","primaryModelKeys","models","Person","type","record","key","fields","fieldType","value","string","minLength","maxLength","metadata","addedInVersion","integer","minValue","maxValue","formatted","lines","split","importLines","filter","line","startsWith","length","toBeGreaterThan","forEach","toMatch","toMatchFileSnapshot","Event","docRef","documentTypeRids","userRef","datetime","resourceRef","resourceRids","toContain","ObjectNode","double","TextBox","Node","union","discriminant","variants","object","Cat","Dog","Animal","cat","dog"],"sources":["generateModelsFromIr.test.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 path from \"path\";\nimport { describe, expect, it } from \"vitest\";\nimport type {\n IFieldDef,\n IModelDef,\n IRealTimeDocumentSchema,\n IRecordDef,\n IUnionDef,\n} from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { generateModelsFromIr } from \"../generateModelsFromIr.js\";\nimport { formatWithPrettier } from \"./formatWithPrettier.js\";\n\ndescribe(\"generateModelsFromIr\", () => {\n const snapshotDir = path.join(__dirname, \"__snapshots__\", \"generateModelsFromIr\");\n\n it(\"should generate Model constants for simple record types\", async () => {\n const personField1: IFieldDef = {\n key: \"name\",\n name: \"Name\",\n description: \"Person name\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"string\",\n string: { minLength: 2, maxLength: 50 },\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const personField2: IFieldDef = {\n key: \"age\",\n name: \"Age\",\n description: \"Person age\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"integer\",\n integer: { minValue: 0, maxValue: 150 },\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const personRecord: IRecordDef = {\n key: \"Person\",\n name: \"Person\",\n description: \"A person record\",\n fields: [personField1, personField2],\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema\",\n version: 1,\n primaryModelKeys: [\"Person\"],\n models: {\n Person: {\n type: \"record\",\n record: personRecord,\n } as IModelDef,\n },\n };\n\n const result = await generateModelsFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n // Verify imports are properly formatted (no weird indentation)\n const lines = formatted.split(\"\\n\");\n const importLines = lines.filter(line => line.startsWith(\"import\"));\n expect(importLines.length).toBeGreaterThan(0);\n // All imports should start at column 0 (no leading whitespace)\n importLines.forEach(line => {\n expect(line).toMatch(/^import/);\n });\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"simple-record.ts\"));\n });\n\n it(\"should generate Model constants with external ref fields\", async () => {\n const eventField1: IFieldDef = {\n key: \"documentRef\",\n name: \"Document Reference\",\n description: \"Reference to a document\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"docRef\",\n docRef: {\n documentTypeRids: [],\n },\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const eventField2: IFieldDef = {\n key: \"userRef\",\n name: \"User Reference\",\n description: \"Reference to a user\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"userRef\",\n userRef: {},\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const eventField3: IFieldDef = {\n key: \"timestamp\",\n name: \"Timestamp\",\n description: \"Event timestamp\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"datetime\",\n datetime: {},\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const eventField4: IFieldDef = {\n key: \"resourceRef\",\n name: \"Resource Reference\",\n description: \"A reference to a resource\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"resourceRef\",\n resourceRef: { resourceRids: [] },\n },\n },\n metadata: { addedInVersion: 1 },\n };\n\n const eventRecord: IRecordDef = {\n key: \"Event\",\n name: \"Event\",\n description: \"An event record with external refs\",\n fields: [eventField1, eventField2, eventField3, eventField4],\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema with external refs\",\n version: 1,\n primaryModelKeys: [\"Event\"],\n models: {\n Event: {\n type: \"record\",\n record: eventRecord,\n } as IModelDef,\n },\n };\n\n const result = await generateModelsFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n // Verify external ref fields are included in metadata\n expect(formatted).toContain(\"externalRefFieldTypes\");\n expect(formatted).toContain(\"documentRef: 'docRef'\");\n expect(formatted).toContain(\"userRef: 'userRef'\");\n expect(formatted).toContain(\"resourceRef: 'resourceRef'\");\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"external-refs.ts\"));\n });\n\n it(\"should generate Model constants for union types\", async () => {\n // Define the ObjectNode record\n const objectNodeRecord: IRecordDef = {\n key: \"ObjectNode\",\n name: \"ObjectNode\",\n description: \"A node in the graph\",\n fields: [\n {\n key: \"x\",\n name: \"X\",\n description: \"X coordinate\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n {\n key: \"y\",\n name: \"Y\",\n description: \"Y coordinate\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n // Define the TextBox record\n const textBoxRecord: IRecordDef = {\n key: \"TextBox\",\n name: \"TextBox\",\n description: \"A text box in the graph\",\n fields: [\n {\n key: \"x\",\n name: \"X\",\n description: \"X coordinate\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n {\n key: \"text\",\n name: \"Text\",\n description: \"Text content\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n // Define the Node union\n const nodeUnion: IUnionDef = {\n key: \"Node\",\n discriminant: \"type\",\n name: \"Node\",\n description: \"A node in the graph\",\n variants: {\n object: \"ObjectNode\",\n \"text-box\": \"TextBox\",\n },\n metadata: { addedInVersion: 1 },\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema with unions\",\n version: 1,\n primaryModelKeys: [\"ObjectNode\", \"TextBox\", \"Node\"],\n models: {\n ObjectNode: {\n type: \"record\",\n record: objectNodeRecord,\n } as IModelDef,\n TextBox: {\n type: \"record\",\n record: textBoxRecord,\n } as IModelDef,\n Node: {\n type: \"union\",\n union: nodeUnion,\n } as IModelDef,\n },\n };\n\n const result = await generateModelsFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n // Verify all models are generated (primary models + union variants)\n expect(formatted).toContain(\"export const ObjectNodeModel\");\n expect(formatted).toContain(\"export const TextBoxModel\");\n expect(formatted).toContain(\"export const NodeModel\");\n expect(formatted).toContain(\"export const NodeObjectModel\");\n expect(formatted).toContain(\"export const NodeTextBoxModel\");\n\n // Verify DocumentSchema contains all models\n expect(formatted).toContain(\"export const DocumentModel\");\n expect(formatted).toContain(\"ObjectNode: ObjectNodeModel\");\n expect(formatted).toContain(\"TextBox: TextBoxModel\");\n expect(formatted).toContain(\"Node: NodeModel\");\n expect(formatted).toContain(\"NodeObject: NodeObjectModel\");\n expect(formatted).toContain(\"NodeTextBox: NodeTextBoxModel\");\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"union-types.ts\"));\n });\n\n it(\"should generate Model constants with custom discriminant\", async () => {\n const catRecord: IRecordDef = {\n key: \"Cat\",\n name: \"Cat\",\n description: \"A cat\",\n fields: [\n {\n key: \"meow\",\n name: \"Meow\",\n description: \"Cat sound\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const dogRecord: IRecordDef = {\n key: \"Dog\",\n name: \"Dog\",\n description: \"A dog\",\n fields: [\n {\n key: \"bark\",\n name: \"Bark\",\n description: \"Dog sound\",\n fieldType: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n metadata: { addedInVersion: 1 },\n },\n ],\n };\n\n const animalUnion: IUnionDef = {\n key: \"Animal\",\n discriminant: \"kind\",\n name: \"Animal\",\n description: \"An animal union with custom discriminant\",\n variants: {\n cat: \"Cat\",\n dog: \"Dog\",\n },\n metadata: { addedInVersion: 1 },\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema with custom discriminant\",\n version: 1,\n primaryModelKeys: [\"Cat\", \"Dog\", \"Animal\"],\n models: {\n Cat: {\n type: \"record\",\n record: catRecord,\n } as IModelDef,\n Dog: {\n type: \"record\",\n record: dogRecord,\n } as IModelDef,\n Animal: {\n type: \"union\",\n union: animalUnion,\n } as IModelDef,\n },\n };\n\n const result = await generateModelsFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n expect(formatted).toContain(\"discriminant: 'kind'\");\n expect(formatted).toContain(\"export const AnimalModel\");\n expect(formatted).toContain(\"export const AnimalCatModel\");\n expect(formatted).toContain(\"export const AnimalDogModel\");\n\n await expect(formatted).toMatchFileSnapshot(\n path.join(snapshotDir, \"custom-discriminant.ts\"),\n );\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,IAAI,MAAM,MAAM;AACvB,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAQ7C,SAASC,oBAAoB,QAAQ,4BAA4B;AACjE,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5DJ,QAAQ,CAAC,sBAAsB,EAAE,MAAM;EACrC,MAAMK,WAAW,GAA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,CAAC;IAE1D,MAAM/C,MAAM,CAAC4B,SAAS,CAAC,CAACW,mBAAmB,CACzCzC,IAAI,CAACO,IAAI,CAACD,WAAW,EAAE,wBAAwB,CACjD,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,148 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /**
18
+ * The first-party API's Conjure `DocumentTypeSchema` wire shape. We don't depend on the generated
19
+ * Conjure client (it lives in an internal registry this public package can't use), so this is the
20
+ * structural shape the publish endpoint expects; nested payloads are left as `unknown`.
21
+ */
22
+
23
+ /**
24
+ * Converts the IR schema to the first-party API's Conjure wire format.
25
+ *
26
+ * Conjure nests a union's payload under a key matching the discriminant
27
+ * (`{ type: "record", record: { ... } }`) — which is how the IR is already shaped, so this is
28
+ * mostly a pass-through. The one real difference: Conjure models a collection's element type as
29
+ * `FieldValueType { valueType }`, while the IR carries the value union directly, so those get wrapped.
30
+ *
31
+ * Do NOT use {@link convertIrToWireSchema} for the first-party publish path: that flattens unions
32
+ * into the OSDK shape (`{ type: "record", key, name, ... }`), which the Conjure endpoint rejects.
33
+ *
34
+ * TODO(follow-up): this parallels {@link convertIrToWireSchema}'s tree walk. Longer term the IR
35
+ * generator could emit the Conjure shape directly, letting this converter be removed.
36
+ */
37
+ export function convertIrToConjureSchema(ir) {
38
+ const models = {};
39
+ for (const [key, model] of Object.entries(ir.models)) {
40
+ models[key] = convertModelDef(model);
41
+ }
42
+ return {
43
+ primaryModelKeys: [...ir.primaryModelKeys],
44
+ models
45
+ };
46
+ }
47
+ function convertModelDef(model) {
48
+ switch (model.type) {
49
+ case "record":
50
+ return {
51
+ type: "record",
52
+ record: {
53
+ ...model.record,
54
+ fields: model.record.fields.map(convertFieldDef)
55
+ }
56
+ };
57
+ case "union":
58
+ return {
59
+ type: "union",
60
+ union: {
61
+ ...model.union
62
+ }
63
+ };
64
+ default:
65
+ {
66
+ throw new Error(`Unknown model type: ${model.type}`);
67
+ }
68
+ }
69
+ }
70
+ function convertFieldDef(field) {
71
+ return {
72
+ ...field,
73
+ fieldType: convertFieldTypeUnion(field.fieldType)
74
+ };
75
+ }
76
+ function convertFieldTypeUnion(fieldType) {
77
+ switch (fieldType.type) {
78
+ case "array":
79
+ return {
80
+ type: "array",
81
+ array: {
82
+ allowNullValue: fieldType.array.allowNullValue,
83
+ value: toFieldValueType(fieldType.array.value)
84
+ }
85
+ };
86
+ case "map":
87
+ return {
88
+ type: "map",
89
+ map: {
90
+ allowNullValue: fieldType.map.allowNullValue,
91
+ key: toFieldValueType(fieldType.map.key),
92
+ value: toFieldValueType(fieldType.map.value)
93
+ }
94
+ };
95
+ case "set":
96
+ return {
97
+ type: "set",
98
+ set: {
99
+ allowNullValue: fieldType.set.allowNullValue,
100
+ value: toFieldValueType(fieldType.set.value)
101
+ }
102
+ };
103
+ // Conjure's `value` variant carries the value union directly (double values are NaN-guarded).
104
+ case "value":
105
+ return {
106
+ type: "value",
107
+ value: convertFieldValueUnion(fieldType.value)
108
+ };
109
+ default:
110
+ {
111
+ throw new Error(`Unknown field type: ${fieldType.type}`);
112
+ }
113
+ }
114
+ }
115
+
116
+ /** Wraps a value union in Conjure's `FieldValueType`. */
117
+ function toFieldValueType(value) {
118
+ return {
119
+ valueType: convertFieldValueUnion(value)
120
+ };
121
+ }
122
+
123
+ /**
124
+ * Value unions are already in the Conjure nested shape, so this is a pass-through — except doubles,
125
+ * whose numeric fields may carry the "NaN" sentinel. Reject it early (matching
126
+ * {@link convertIrToWireSchema}) rather than forward an invalid double to the first-party API.
127
+ */
128
+ function convertFieldValueUnion(value) {
129
+ if (value.type === "double") {
130
+ return {
131
+ type: "double",
132
+ double: {
133
+ ...value.double,
134
+ defaultValue: rejectNaN(value.double.defaultValue),
135
+ minValue: rejectNaN(value.double.minValue),
136
+ maxValue: rejectNaN(value.double.maxValue)
137
+ }
138
+ };
139
+ }
140
+ return value;
141
+ }
142
+ function rejectNaN(value) {
143
+ if (value === "NaN") {
144
+ throw new Error("NaN is not a valid double value for wire serialization");
145
+ }
146
+ return value ?? undefined;
147
+ }
148
+ //# sourceMappingURL=convertIrToConjureSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertIrToConjureSchema.js","names":["convertIrToConjureSchema","ir","models","key","model","Object","entries","convertModelDef","primaryModelKeys","type","record","fields","map","convertFieldDef","union","Error","field","fieldType","convertFieldTypeUnion","array","allowNullValue","value","toFieldValueType","set","convertFieldValueUnion","valueType","double","defaultValue","rejectNaN","minValue","maxValue","undefined"],"sources":["convertIrToConjureSchema.ts"],"sourcesContent":["/*\n * Copyright 2026 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 {\n IFieldDef,\n IFieldTypeUnion,\n IFieldValueUnion,\n IModelDef,\n IRealTimeDocumentSchema,\n} from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\n\n/**\n * The first-party API's Conjure `DocumentTypeSchema` wire shape. We don't depend on the generated\n * Conjure client (it lives in an internal registry this public package can't use), so this is the\n * structural shape the publish endpoint expects; nested payloads are left as `unknown`.\n */\nexport interface ConjureDocumentTypeSchema {\n readonly primaryModelKeys: readonly string[];\n readonly models: Record<string, unknown>;\n}\n\n/**\n * Converts the IR schema to the first-party API's Conjure wire format.\n *\n * Conjure nests a union's payload under a key matching the discriminant\n * (`{ type: \"record\", record: { ... } }`) — which is how the IR is already shaped, so this is\n * mostly a pass-through. The one real difference: Conjure models a collection's element type as\n * `FieldValueType { valueType }`, while the IR carries the value union directly, so those get wrapped.\n *\n * Do NOT use {@link convertIrToWireSchema} for the first-party publish path: that flattens unions\n * into the OSDK shape (`{ type: \"record\", key, name, ... }`), which the Conjure endpoint rejects.\n *\n * TODO(follow-up): this parallels {@link convertIrToWireSchema}'s tree walk. Longer term the IR\n * generator could emit the Conjure shape directly, letting this converter be removed.\n */\nexport function convertIrToConjureSchema(ir: IRealTimeDocumentSchema): ConjureDocumentTypeSchema {\n const models: Record<string, unknown> = {};\n for (const [key, model] of Object.entries(ir.models)) {\n models[key] = convertModelDef(model);\n }\n return { primaryModelKeys: [...ir.primaryModelKeys], models };\n}\n\nfunction convertModelDef(model: IModelDef): unknown {\n switch (model.type) {\n case \"record\":\n return {\n type: \"record\",\n record: { ...model.record, fields: model.record.fields.map(convertFieldDef) },\n };\n case \"union\":\n return { type: \"union\", union: { ...model.union } };\n default: {\n const _exhaustive: never = model;\n throw new Error(`Unknown model type: ${(_exhaustive as IModelDef).type}`);\n }\n }\n}\n\nfunction convertFieldDef(field: IFieldDef): unknown {\n return { ...field, fieldType: convertFieldTypeUnion(field.fieldType) };\n}\n\nfunction convertFieldTypeUnion(fieldType: IFieldTypeUnion): unknown {\n switch (fieldType.type) {\n case \"array\":\n return {\n type: \"array\",\n array: {\n allowNullValue: fieldType.array.allowNullValue,\n value: toFieldValueType(fieldType.array.value),\n },\n };\n case \"map\":\n return {\n type: \"map\",\n map: {\n allowNullValue: fieldType.map.allowNullValue,\n key: toFieldValueType(fieldType.map.key),\n value: toFieldValueType(fieldType.map.value),\n },\n };\n case \"set\":\n return {\n type: \"set\",\n set: {\n allowNullValue: fieldType.set.allowNullValue,\n value: toFieldValueType(fieldType.set.value),\n },\n };\n // Conjure's `value` variant carries the value union directly (double values are NaN-guarded).\n case \"value\":\n return { type: \"value\", value: convertFieldValueUnion(fieldType.value) };\n default: {\n const _exhaustive: never = fieldType;\n throw new Error(`Unknown field type: ${(_exhaustive as IFieldTypeUnion).type}`);\n }\n }\n}\n\n/** Wraps a value union in Conjure's `FieldValueType`. */\nfunction toFieldValueType(value: IFieldValueUnion): unknown {\n return { valueType: convertFieldValueUnion(value) };\n}\n\n/**\n * Value unions are already in the Conjure nested shape, so this is a pass-through — except doubles,\n * whose numeric fields may carry the \"NaN\" sentinel. Reject it early (matching\n * {@link convertIrToWireSchema}) rather than forward an invalid double to the first-party API.\n */\nfunction convertFieldValueUnion(value: IFieldValueUnion): unknown {\n if (value.type === \"double\") {\n return {\n type: \"double\",\n double: {\n ...value.double,\n defaultValue: rejectNaN(value.double.defaultValue),\n minValue: rejectNaN(value.double.minValue),\n maxValue: rejectNaN(value.double.maxValue),\n },\n };\n }\n return value;\n}\n\nfunction rejectNaN(value: number | \"NaN\" | null | undefined): number | undefined {\n if (value === \"NaN\") {\n throw new Error(\"NaN is not a valid double value for wire serialization\");\n }\n return value ?? undefined;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,wBAAwBA,CAACC,EAA2B,EAA6B;EAC/F,MAAMC,MAA+B,GAAG,CAAC,CAAC;EAC1C,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,EAAE,CAACC,MAAM,CAAC,EAAE;IACpDA,MAAM,CAACC,GAAG,CAAC,GAAGI,eAAe,CAACH,KAA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