@palantir/pack.document-schema.type-gen 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/bin/cli-node.js +6 -0
  2. package/build/esm/commands/ir/irDeployHandler.js.map +1 -1
  3. package/build/esm/commands/ir/irGenModelsHandler.js.map +1 -1
  4. package/build/esm/commands/ir/irGenZodHandler.js.map +1 -1
  5. package/build/esm/lib/pack-docschema-api/pack-docschema-api/index.js +7 -7
  6. package/build/esm/lib/pack-docschema-api/pack-docschema-api/index.js.map +1 -1
  7. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldDef.js.map +1 -1
  8. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldTypeCollection.js.map +1 -1
  9. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldTypeMap.js.map +1 -1
  10. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldTypeUnion.js.map +1 -1
  11. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueDocumentRef.js.map +1 -1
  12. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueModelRef.js.map +1 -1
  13. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueObjectRef.js.map +1 -1
  14. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/fieldValueUnion.js.map +1 -1
  15. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/index.js +21 -21
  16. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/index.js.map +1 -1
  17. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/modelDef.js.map +1 -1
  18. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/realTimeDocumentSchema.js.map +1 -1
  19. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/recordDef.js.map +1 -1
  20. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.js.map +1 -1
  21. package/build/esm/lib/pack-docschema-api/pack-docschema-ir/unionDef.js.map +1 -1
  22. package/build/esm/utils/ir/__tests__/generateZodSchemasFromIr.test.js.map +1 -1
  23. package/build/esm/utils/ir/generateModelsFromIr.js.map +1 -1
  24. package/build/esm/utils/ir/generateZodSchemasFromIr.js.map +1 -1
  25. package/build/esm/utils/steps/__tests__/convertStepsToIr.test.js.map +1 -1
  26. package/build/esm/utils/steps/convertStepsToIr.js +1 -1
  27. package/build/esm/utils/steps/convertStepsToIr.js.map +1 -1
  28. package/build/types/lib/pack-docschema-api/pack-docschema-api/index.d.ts +7 -7
  29. package/build/types/lib/pack-docschema-api/pack-docschema-api/index.d.ts.map +1 -1
  30. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldDef.d.ts +3 -3
  31. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldDef.d.ts.map +1 -1
  32. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldTypeCollection.d.ts +1 -1
  33. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldTypeCollection.d.ts.map +1 -1
  34. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldTypeMap.d.ts +1 -1
  35. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldTypeMap.d.ts.map +1 -1
  36. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldTypeUnion.d.ts +3 -3
  37. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldTypeUnion.d.ts.map +1 -1
  38. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueDocumentRef.d.ts +1 -1
  39. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueDocumentRef.d.ts.map +1 -1
  40. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueModelRef.d.ts +1 -1
  41. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueModelRef.d.ts.map +1 -1
  42. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueObjectRef.d.ts +2 -2
  43. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueObjectRef.d.ts.map +1 -1
  44. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueUnion.d.ts +11 -11
  45. package/build/types/lib/pack-docschema-api/pack-docschema-ir/fieldValueUnion.d.ts.map +1 -1
  46. package/build/types/lib/pack-docschema-api/pack-docschema-ir/index.d.ts +21 -21
  47. package/build/types/lib/pack-docschema-api/pack-docschema-ir/index.d.ts.map +1 -1
  48. package/build/types/lib/pack-docschema-api/pack-docschema-ir/modelDef.d.ts +2 -2
  49. package/build/types/lib/pack-docschema-api/pack-docschema-ir/modelDef.d.ts.map +1 -1
  50. package/build/types/lib/pack-docschema-api/pack-docschema-ir/realTimeDocumentSchema.d.ts +3 -3
  51. package/build/types/lib/pack-docschema-api/pack-docschema-ir/realTimeDocumentSchema.d.ts.map +1 -1
  52. package/build/types/lib/pack-docschema-api/pack-docschema-ir/recordDef.d.ts +3 -3
  53. package/build/types/lib/pack-docschema-api/pack-docschema-ir/recordDef.d.ts.map +1 -1
  54. package/build/types/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.d.ts +1 -1
  55. package/build/types/lib/pack-docschema-api/pack-docschema-ir/schemaMeta.d.ts.map +1 -1
  56. package/build/types/lib/pack-docschema-api/pack-docschema-ir/unionDef.d.ts +4 -4
  57. package/build/types/lib/pack-docschema-api/pack-docschema-ir/unionDef.d.ts.map +1 -1
  58. package/build/types/utils/ir/generateModelsFromIr.d.ts +1 -1
  59. package/build/types/utils/ir/generateModelsFromIr.d.ts.map +1 -1
  60. package/build/types/utils/ir/generateZodSchemasFromIr.d.ts +1 -1
  61. package/build/types/utils/ir/generateZodSchemasFromIr.d.ts.map +1 -1
  62. package/build/types/utils/steps/convertStepsToIr.d.ts +2 -2
  63. package/build/types/utils/steps/convertStepsToIr.d.ts.map +1 -1
  64. package/package.json +4 -3
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env -S node
2
+
3
+ /* eslint-disable header/header */
4
+
5
+ import { cli } from "../build/esm/index.js";
6
+ cli(process.argv);
@@ -1 +1 @@
1
- {"version":3,"file":"irDeployHandler.js","names":["createPlatformClient","DocumentTypes","CommanderError","consola","readFileSync","resolve","irDeployHandler","options","irPath","ir","info","irContent","JSON","parse","osdkClient","baseUrl","Promise","auth","request","name","parentFolderRid","parentFolder","warn","create","error"],"sources":["irDeployHandler.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 { createPlatformClient } from \"@osdk/client\";\nimport type { CreateDocumentTypeRequest } from \"@osdk/foundry.pack\";\nimport { DocumentTypes } from \"@osdk/foundry.pack\";\nimport { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { readFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport type { IRealTimeDocumentSchema } from \"../../lib/pack-docschema-api/pack-docschema-ir\";\n\ninterface DeployOptions {\n readonly ir: string;\n readonly baseUrl: string;\n readonly auth: string;\n readonly parentFolder: string;\n}\n\nexport async function irDeployHandler(options: DeployOptions): Promise<void> {\n try {\n const irPath = resolve(options.ir);\n\n consola.info(`Reading schema from: ${irPath}`);\n\n const irContent = readFileSync(irPath, \"utf8\");\n\n // TODO: conjureToZod based validation that IR content matches the conjure IR shape\n const ir = JSON.parse(irContent) as IRealTimeDocumentSchema;\n\n const osdkClient = createPlatformClient(\n options.baseUrl,\n () => Promise.resolve(options.auth),\n );\n\n const request: CreateDocumentTypeRequest = {\n name: ir.name,\n parentFolderRid: options.parentFolder,\n };\n\n // PACK BE does not yet support storing schemas...\n consola.warn(\"Creating document type without schema information\", request);\n\n await DocumentTypes.create(osdkClient, request);\n } catch (error) {\n consola.error(\"❌ Error during Deploy:\", error);\n throw new CommanderError(1, \"ERRIRMDEPLOY\", \"Error deploying IR document schema\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,QAAQ,cAAc;AAEnD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,YAAY,QAAQ,IAAI;AACjC,SAASC,OAAO,QAAQ,MAAM;AAU9B,OAAO,eAAeC,eAAeA,CAACC,OAAsB,EAAiB;EAC3E,IAAI;IACF,MAAMC,MAAM,GAAGH,OAAO,CAACE,OAAO,CAACE,EAAE,CAAC;IAElCN,OAAO,CAACO,IAAI,CAAC,wBAAwBF,MAAM,EAAE,CAAC;IAE9C,MAAMG,SAAS,GAAGP,YAAY,CAACI,MAAM,EAAE,MAAM,CAAC;;IAE9C;IACA,MAAMC,EAAE,GAAGG,IAAI,CAACC,KAAK,CAACF,SAAS,CAA4B;IAE3D,MAAMG,UAAU,GAAGd,oBAAoB,CACrCO,OAAO,CAACQ,OAAO,EACf,MAAMC,OAAO,CAACX,OAAO,CAACE,OAAO,CAACU,IAAI,CACpC,CAAC;IAED,MAAMC,OAAkC,GAAG;MACzCC,IAAI,EAAEV,EAAE,CAACU,IAAI;MACbC,eAAe,EAAEb,OAAO,CAACc;IAC3B,CAAC;;IAED;IACAlB,OAAO,CAACmB,IAAI,CAAC,mDAAmD,EAAEJ,OAAO,CAAC;IAE1E,MAAMjB,aAAa,CAACsB,MAAM,CAACT,UAAU,EAAEI,OAAO,CAAC;EACjD,CAAC,CAAC,OAAOM,KAAK,EAAE;IACdrB,OAAO,CAACqB,KAAK,CAAC,wBAAwB,EAAEA,KAAK,CAAC;IAC9C,MAAM,IAAItB,cAAc,CAAC,CAAC,EAAE,cAAc,EAAE,oCAAoC,CAAC;EACnF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"irDeployHandler.js","names":["createPlatformClient","DocumentTypes","CommanderError","consola","readFileSync","resolve","irDeployHandler","options","irPath","ir","info","irContent","JSON","parse","osdkClient","baseUrl","Promise","auth","request","name","parentFolderRid","parentFolder","warn","create","error"],"sources":["irDeployHandler.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 { createPlatformClient } from \"@osdk/client\";\nimport type { CreateDocumentTypeRequest } from \"@osdk/foundry.pack\";\nimport { DocumentTypes } from \"@osdk/foundry.pack\";\nimport { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { readFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport type { IRealTimeDocumentSchema } from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\n\ninterface DeployOptions {\n readonly ir: string;\n readonly baseUrl: string;\n readonly auth: string;\n readonly parentFolder: string;\n}\n\nexport async function irDeployHandler(options: DeployOptions): Promise<void> {\n try {\n const irPath = resolve(options.ir);\n\n consola.info(`Reading schema from: ${irPath}`);\n\n const irContent = readFileSync(irPath, \"utf8\");\n\n // TODO: conjureToZod based validation that IR content matches the conjure IR shape\n const ir = JSON.parse(irContent) as IRealTimeDocumentSchema;\n\n const osdkClient = createPlatformClient(\n options.baseUrl,\n () => Promise.resolve(options.auth),\n );\n\n const request: CreateDocumentTypeRequest = {\n name: ir.name,\n parentFolderRid: options.parentFolder,\n };\n\n // PACK BE does not yet support storing schemas...\n consola.warn(\"Creating document type without schema information\", request);\n\n await DocumentTypes.create(osdkClient, request);\n } catch (error) {\n consola.error(\"❌ Error during Deploy:\", error);\n throw new CommanderError(1, \"ERRIRMDEPLOY\", \"Error deploying IR document schema\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,QAAQ,cAAc;AAEnD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,YAAY,QAAQ,IAAI;AACjC,SAASC,OAAO,QAAQ,MAAM;AAU9B,OAAO,eAAeC,eAAeA,CAACC,OAAsB,EAAiB;EAC3E,IAAI;IACF,MAAMC,MAAM,GAAGH,OAAO,CAACE,OAAO,CAACE,EAAE,CAAC;IAElCN,OAAO,CAACO,IAAI,CAAC,wBAAwBF,MAAM,EAAE,CAAC;IAE9C,MAAMG,SAAS,GAAGP,YAAY,CAACI,MAAM,EAAE,MAAM,CAAC;;IAE9C;IACA,MAAMC,EAAE,GAAGG,IAAI,CAACC,KAAK,CAACF,SAAS,CAA4B;IAE3D,MAAMG,UAAU,GAAGd,oBAAoB,CACrCO,OAAO,CAACQ,OAAO,EACf,MAAMC,OAAO,CAACX,OAAO,CAACE,OAAO,CAACU,IAAI,CACpC,CAAC;IAED,MAAMC,OAAkC,GAAG;MACzCC,IAAI,EAAEV,EAAE,CAACU,IAAI;MACbC,eAAe,EAAEb,OAAO,CAACc;IAC3B,CAAC;;IAED;IACAlB,OAAO,CAACmB,IAAI,CAAC,mDAAmD,EAAEJ,OAAO,CAAC;IAE1E,MAAMjB,aAAa,CAACsB,MAAM,CAACT,UAAU,EAAEI,OAAO,CAAC;EACjD,CAAC,CAAC,OAAOM,KAAK,EAAE;IACdrB,OAAO,CAACqB,KAAK,CAAC,wBAAwB,EAAEA,KAAK,CAAC;IAC9C,MAAM,IAAItB,cAAc,CAAC,CAAC,EAAE,cAAc,EAAE,oCAAoC,CAAC;EACnF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"irGenModelsHandler.js","names":["CommanderError","consola","readFileSync","writeFileSync","resolve","generateModelsFromIr","irGenModelsHandler","options","schemaPath","schema","outputPath","output","info","schemaContent","JSON","parse","primaryModelKeys","length","generatedCode","typeImportPath","schemaImportPath","success","error"],"sources":["irGenModelsHandler.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 { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { readFileSync, writeFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport type { IRealTimeDocumentSchema } from \"../../lib/pack-docschema-api/pack-docschema-ir\";\nimport { generateModelsFromIr } from \"../../utils/ir/generateModelsFromIr.js\";\n\ninterface ModelsGenOptions {\n readonly schema: string;\n readonly output: string;\n readonly typeImportPath?: string;\n readonly schemaImportPath?: string;\n}\n\nexport async function irGenModelsHandler(options: ModelsGenOptions): Promise<void> {\n try {\n const schemaPath = resolve(options.schema);\n const outputPath = resolve(options.output);\n\n consola.info(`Reading schema from: ${schemaPath}`);\n\n const schemaContent = readFileSync(schemaPath, \"utf8\");\n\n // TODO: conjureToZod based validation matches conjure ir\n const schema = JSON.parse(schemaContent) as IRealTimeDocumentSchema;\n\n consola.info(`Generating Model constants for ${schema.primaryModelKeys.length} model(s)...`);\n\n const generatedCode = await generateModelsFromIr(schema, {\n typeImportPath: options.typeImportPath,\n schemaImportPath: options.schemaImportPath,\n });\n\n consola.info(`Writing generated Model constants to: ${outputPath}`);\n writeFileSync(outputPath, generatedCode, \"utf8\");\n\n consola.success(\"✅ Model constants generation completed successfully\");\n } catch (error) {\n consola.error(\"❌ Error during Model constants generation:\", error);\n throw new CommanderError(1, \"ERRIRMODELS\", \"Error generating Model constants\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,YAAY,EAAEC,aAAa,QAAQ,IAAI;AAChD,SAASC,OAAO,QAAQ,MAAM;AAE9B,SAASC,oBAAoB,QAAQ,wCAAwC;AAS7E,OAAO,eAAeC,kBAAkBA,CAACC,OAAyB,EAAiB;EACjF,IAAI;IACF,MAAMC,UAAU,GAAGJ,OAAO,CAACG,OAAO,CAACE,MAAM,CAAC;IAC1C,MAAMC,UAAU,GAAGN,OAAO,CAACG,OAAO,CAACI,MAAM,CAAC;IAE1CV,OAAO,CAACW,IAAI,CAAC,wBAAwBJ,UAAU,EAAE,CAAC;IAElD,MAAMK,aAAa,GAAGX,YAAY,CAACM,UAAU,EAAE,MAAM,CAAC;;IAEtD;IACA,MAAMC,MAAM,GAAGK,IAAI,CAACC,KAAK,CAACF,aAAa,CAA4B;IAEnEZ,OAAO,CAACW,IAAI,CAAC,kCAAkCH,MAAM,CAACO,gBAAgB,CAACC,MAAM,cAAc,CAAC;IAE5F,MAAMC,aAAa,GAAG,MAAMb,oBAAoB,CAACI,MAAM,EAAE;MACvDU,cAAc,EAAEZ,OAAO,CAACY,cAAc;MACtCC,gBAAgB,EAAEb,OAAO,CAACa;IAC5B,CAAC,CAAC;IAEFnB,OAAO,CAACW,IAAI,CAAC,yCAAyCF,UAAU,EAAE,CAAC;IACnEP,aAAa,CAACO,UAAU,EAAEQ,aAAa,EAAE,MAAM,CAAC;IAEhDjB,OAAO,CAACoB,OAAO,CAAC,qDAAqD,CAAC;EACxE,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdrB,OAAO,CAACqB,KAAK,CAAC,4CAA4C,EAAEA,KAAK,CAAC;IAClE,MAAM,IAAItB,cAAc,CAAC,CAAC,EAAE,aAAa,EAAE,kCAAkC,CAAC;EAChF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"irGenModelsHandler.js","names":["CommanderError","consola","readFileSync","writeFileSync","resolve","generateModelsFromIr","irGenModelsHandler","options","schemaPath","schema","outputPath","output","info","schemaContent","JSON","parse","primaryModelKeys","length","generatedCode","typeImportPath","schemaImportPath","success","error"],"sources":["irGenModelsHandler.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 { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { readFileSync, writeFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport type { IRealTimeDocumentSchema } from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { generateModelsFromIr } from \"../../utils/ir/generateModelsFromIr.js\";\n\ninterface ModelsGenOptions {\n readonly schema: string;\n readonly output: string;\n readonly typeImportPath?: string;\n readonly schemaImportPath?: string;\n}\n\nexport async function irGenModelsHandler(options: ModelsGenOptions): Promise<void> {\n try {\n const schemaPath = resolve(options.schema);\n const outputPath = resolve(options.output);\n\n consola.info(`Reading schema from: ${schemaPath}`);\n\n const schemaContent = readFileSync(schemaPath, \"utf8\");\n\n // TODO: conjureToZod based validation matches conjure ir\n const schema = JSON.parse(schemaContent) as IRealTimeDocumentSchema;\n\n consola.info(`Generating Model constants for ${schema.primaryModelKeys.length} model(s)...`);\n\n const generatedCode = await generateModelsFromIr(schema, {\n typeImportPath: options.typeImportPath,\n schemaImportPath: options.schemaImportPath,\n });\n\n consola.info(`Writing generated Model constants to: ${outputPath}`);\n writeFileSync(outputPath, generatedCode, \"utf8\");\n\n consola.success(\"✅ Model constants generation completed successfully\");\n } catch (error) {\n consola.error(\"❌ Error during Model constants generation:\", error);\n throw new CommanderError(1, \"ERRIRMODELS\", \"Error generating Model constants\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,YAAY,EAAEC,aAAa,QAAQ,IAAI;AAChD,SAASC,OAAO,QAAQ,MAAM;AAE9B,SAASC,oBAAoB,QAAQ,wCAAwC;AAS7E,OAAO,eAAeC,kBAAkBA,CAACC,OAAyB,EAAiB;EACjF,IAAI;IACF,MAAMC,UAAU,GAAGJ,OAAO,CAACG,OAAO,CAACE,MAAM,CAAC;IAC1C,MAAMC,UAAU,GAAGN,OAAO,CAACG,OAAO,CAACI,MAAM,CAAC;IAE1CV,OAAO,CAACW,IAAI,CAAC,wBAAwBJ,UAAU,EAAE,CAAC;IAElD,MAAMK,aAAa,GAAGX,YAAY,CAACM,UAAU,EAAE,MAAM,CAAC;;IAEtD;IACA,MAAMC,MAAM,GAAGK,IAAI,CAACC,KAAK,CAACF,aAAa,CAA4B;IAEnEZ,OAAO,CAACW,IAAI,CAAC,kCAAkCH,MAAM,CAACO,gBAAgB,CAACC,MAAM,cAAc,CAAC;IAE5F,MAAMC,aAAa,GAAG,MAAMb,oBAAoB,CAACI,MAAM,EAAE;MACvDU,cAAc,EAAEZ,OAAO,CAACY,cAAc;MACtCC,gBAAgB,EAAEb,OAAO,CAACa;IAC5B,CAAC,CAAC;IAEFnB,OAAO,CAACW,IAAI,CAAC,yCAAyCF,UAAU,EAAE,CAAC;IACnEP,aAAa,CAACO,UAAU,EAAEQ,aAAa,EAAE,MAAM,CAAC;IAEhDjB,OAAO,CAACoB,OAAO,CAAC,qDAAqD,CAAC;EACxE,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdrB,OAAO,CAACqB,KAAK,CAAC,4CAA4C,EAAEA,KAAK,CAAC;IAClE,MAAM,IAAItB,cAAc,CAAC,CAAC,EAAE,aAAa,EAAE,kCAAkC,CAAC;EAChF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"irGenZodHandler.js","names":["CommanderError","consola","readFileSync","writeFileSync","resolve","generateZodSchemasFromIr","irGenZodHandler","options","schemaPath","schema","outputPath","output","info","schemaContent","JSON","parse","primaryModelKeys","length","generatedCode","typeImportPath","success","error"],"sources":["irGenZodHandler.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 { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { readFileSync, writeFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport type { IRealTimeDocumentSchema } from \"../../lib/pack-docschema-api/pack-docschema-ir\";\nimport { generateZodSchemasFromIr } from \"../../utils/ir/generateZodSchemasFromIr.js\";\n\ninterface ZodGenOptions {\n readonly schema: string;\n readonly output: string;\n readonly typeImportPath?: string;\n}\n\nexport async function irGenZodHandler(options: ZodGenOptions): Promise<void> {\n try {\n const schemaPath = resolve(options.schema);\n const outputPath = resolve(options.output);\n\n consola.info(`Reading schema from: ${schemaPath}`);\n\n const schemaContent = readFileSync(schemaPath, \"utf8\");\n\n // TODO: conjureToZod based validation matches conjure ir\n const schema = JSON.parse(schemaContent) as IRealTimeDocumentSchema;\n\n consola.info(`Generating Zod schemas for ${schema.primaryModelKeys.length} model(s)...`);\n\n const generatedCode = await generateZodSchemasFromIr(schema, {\n typeImportPath: options.typeImportPath,\n });\n\n consola.info(`Writing generated Zod schemas to: ${outputPath}`);\n writeFileSync(outputPath, generatedCode, \"utf8\");\n\n consola.success(\"✅ Zod schema generation completed successfully\");\n } catch (error) {\n consola.error(\"❌ Error during Zod schema generation:\", error);\n throw new CommanderError(1, \"ERRIRZOD\", \"Error generating Zod schemas\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,YAAY,EAAEC,aAAa,QAAQ,IAAI;AAChD,SAASC,OAAO,QAAQ,MAAM;AAE9B,SAASC,wBAAwB,QAAQ,4CAA4C;AAQrF,OAAO,eAAeC,eAAeA,CAACC,OAAsB,EAAiB;EAC3E,IAAI;IACF,MAAMC,UAAU,GAAGJ,OAAO,CAACG,OAAO,CAACE,MAAM,CAAC;IAC1C,MAAMC,UAAU,GAAGN,OAAO,CAACG,OAAO,CAACI,MAAM,CAAC;IAE1CV,OAAO,CAACW,IAAI,CAAC,wBAAwBJ,UAAU,EAAE,CAAC;IAElD,MAAMK,aAAa,GAAGX,YAAY,CAACM,UAAU,EAAE,MAAM,CAAC;;IAEtD;IACA,MAAMC,MAAM,GAAGK,IAAI,CAACC,KAAK,CAACF,aAAa,CAA4B;IAEnEZ,OAAO,CAACW,IAAI,CAAC,8BAA8BH,MAAM,CAACO,gBAAgB,CAACC,MAAM,cAAc,CAAC;IAExF,MAAMC,aAAa,GAAG,MAAMb,wBAAwB,CAACI,MAAM,EAAE;MAC3DU,cAAc,EAAEZ,OAAO,CAACY;IAC1B,CAAC,CAAC;IAEFlB,OAAO,CAACW,IAAI,CAAC,qCAAqCF,UAAU,EAAE,CAAC;IAC/DP,aAAa,CAACO,UAAU,EAAEQ,aAAa,EAAE,MAAM,CAAC;IAEhDjB,OAAO,CAACmB,OAAO,CAAC,gDAAgD,CAAC;EACnE,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdpB,OAAO,CAACoB,KAAK,CAAC,uCAAuC,EAAEA,KAAK,CAAC;IAC7D,MAAM,IAAIrB,cAAc,CAAC,CAAC,EAAE,UAAU,EAAE,8BAA8B,CAAC;EACzE;AACF","ignoreList":[]}
1
+ {"version":3,"file":"irGenZodHandler.js","names":["CommanderError","consola","readFileSync","writeFileSync","resolve","generateZodSchemasFromIr","irGenZodHandler","options","schemaPath","schema","outputPath","output","info","schemaContent","JSON","parse","primaryModelKeys","length","generatedCode","typeImportPath","success","error"],"sources":["irGenZodHandler.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 { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { readFileSync, writeFileSync } from \"fs\";\nimport { resolve } from \"path\";\nimport type { IRealTimeDocumentSchema } from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { generateZodSchemasFromIr } from \"../../utils/ir/generateZodSchemasFromIr.js\";\n\ninterface ZodGenOptions {\n readonly schema: string;\n readonly output: string;\n readonly typeImportPath?: string;\n}\n\nexport async function irGenZodHandler(options: ZodGenOptions): Promise<void> {\n try {\n const schemaPath = resolve(options.schema);\n const outputPath = resolve(options.output);\n\n consola.info(`Reading schema from: ${schemaPath}`);\n\n const schemaContent = readFileSync(schemaPath, \"utf8\");\n\n // TODO: conjureToZod based validation matches conjure ir\n const schema = JSON.parse(schemaContent) as IRealTimeDocumentSchema;\n\n consola.info(`Generating Zod schemas for ${schema.primaryModelKeys.length} model(s)...`);\n\n const generatedCode = await generateZodSchemasFromIr(schema, {\n typeImportPath: options.typeImportPath,\n });\n\n consola.info(`Writing generated Zod schemas to: ${outputPath}`);\n writeFileSync(outputPath, generatedCode, \"utf8\");\n\n consola.success(\"✅ Zod schema generation completed successfully\");\n } catch (error) {\n consola.error(\"❌ Error during Zod schema generation:\", error);\n throw new CommanderError(1, \"ERRIRZOD\", \"Error generating Zod schemas\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,cAAc,QAAQ,WAAW;AAC1C,SAASC,OAAO,QAAQ,SAAS;AACjC,SAASC,YAAY,EAAEC,aAAa,QAAQ,IAAI;AAChD,SAASC,OAAO,QAAQ,MAAM;AAE9B,SAASC,wBAAwB,QAAQ,4CAA4C;AAQrF,OAAO,eAAeC,eAAeA,CAACC,OAAsB,EAAiB;EAC3E,IAAI;IACF,MAAMC,UAAU,GAAGJ,OAAO,CAACG,OAAO,CAACE,MAAM,CAAC;IAC1C,MAAMC,UAAU,GAAGN,OAAO,CAACG,OAAO,CAACI,MAAM,CAAC;IAE1CV,OAAO,CAACW,IAAI,CAAC,wBAAwBJ,UAAU,EAAE,CAAC;IAElD,MAAMK,aAAa,GAAGX,YAAY,CAACM,UAAU,EAAE,MAAM,CAAC;;IAEtD;IACA,MAAMC,MAAM,GAAGK,IAAI,CAACC,KAAK,CAACF,aAAa,CAA4B;IAEnEZ,OAAO,CAACW,IAAI,CAAC,8BAA8BH,MAAM,CAACO,gBAAgB,CAACC,MAAM,cAAc,CAAC;IAExF,MAAMC,aAAa,GAAG,MAAMb,wBAAwB,CAACI,MAAM,EAAE;MAC3DU,cAAc,EAAEZ,OAAO,CAACY;IAC1B,CAAC,CAAC;IAEFlB,OAAO,CAACW,IAAI,CAAC,qCAAqCF,UAAU,EAAE,CAAC;IAC/DP,aAAa,CAACO,UAAU,EAAEQ,aAAa,EAAE,MAAM,CAAC;IAEhDjB,OAAO,CAACmB,OAAO,CAAC,gDAAgD,CAAC;EACnE,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdpB,OAAO,CAACoB,KAAK,CAAC,uCAAuC,EAAEA,KAAK,CAAC;IAC7D,MAAM,IAAIrB,cAAc,CAAC,CAAC,EAAE,UAAU,EAAE,8BAA8B,CAAC;EACzE;AACF","ignoreList":[]}
@@ -14,11 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export * from "./documentTypeRid";
18
- export * from "./fieldKey";
19
- export * from "./interfaceTypeRid";
20
- export * from "./modelTypeKey";
21
- export * from "./objectTypeRid";
22
- export * from "./schemaVersion";
23
- export * from "./unionVariantKey";
17
+ export * from "./documentTypeRid.js";
18
+ export * from "./fieldKey.js";
19
+ export * from "./interfaceTypeRid.js";
20
+ export * from "./modelTypeKey.js";
21
+ export * from "./objectTypeRid.js";
22
+ export * from "./schemaVersion.js";
23
+ export * from "./unionVariantKey.js";
24
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["index.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\nexport * from \"./documentTypeRid\";\nexport * from \"./fieldKey\";\nexport * from \"./interfaceTypeRid\";\nexport * from \"./modelTypeKey\";\nexport * from \"./objectTypeRid\";\nexport * from \"./schemaVersion\";\nexport * from \"./unionVariantKey\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,mBAAmB;AACjC,cAAc,YAAY;AAC1B,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAC9B,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;AAC/B,cAAc,mBAAmB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["index.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\nexport * from \"./documentTypeRid.js\";\nexport * from \"./fieldKey.js\";\nexport * from \"./interfaceTypeRid.js\";\nexport * from \"./modelTypeKey.js\";\nexport * from \"./objectTypeRid.js\";\nexport * from \"./schemaVersion.js\";\nexport * from \"./unionVariantKey.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,sBAAsB;AACpC,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,mBAAmB;AACjC,cAAc,oBAAoB;AAClC,cAAc,oBAAoB;AAClC,cAAc,sBAAsB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldDef.js","names":[],"sources":["fieldDef.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 { IFieldKey } from \"../pack-docschema-api/fieldKey\";\nimport type * as IFieldTypeUnion from \"./fieldTypeUnion\";\nimport type { ISchemaMeta } from \"./schemaMeta\";\nexport interface IFieldDef {\n readonly \"key\": IFieldKey;\n readonly \"name\": string;\n readonly \"description\"?: string | null;\n readonly \"isOptional\"?: boolean | null;\n readonly \"value\": IFieldTypeUnion.IFieldTypeUnion;\n readonly \"meta\": ISchemaMeta;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"fieldDef.js","names":[],"sources":["fieldDef.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 { IFieldKey } from \"../pack-docschema-api/fieldKey.js\";\nimport type * as IFieldTypeUnion from \"./fieldTypeUnion.js\";\nimport type { ISchemaMeta } from \"./schemaMeta.js\";\nexport interface IFieldDef {\n readonly \"key\": IFieldKey;\n readonly \"name\": string;\n readonly \"description\"?: string | null;\n readonly \"isOptional\"?: boolean | null;\n readonly \"value\": IFieldTypeUnion.IFieldTypeUnion;\n readonly \"meta\": ISchemaMeta;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldTypeCollection.js","names":[],"sources":["fieldTypeCollection.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 IFieldValueUnion from \"./fieldValueUnion\";\nexport interface IFieldTypeCollection {\n readonly \"allowNullValue\": boolean;\n readonly \"value\": IFieldValueUnion.IFieldValueUnion;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"fieldTypeCollection.js","names":[],"sources":["fieldTypeCollection.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 IFieldValueUnion from \"./fieldValueUnion.js\";\nexport interface IFieldTypeCollection {\n readonly \"allowNullValue\": boolean;\n readonly \"value\": IFieldValueUnion.IFieldValueUnion;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldTypeMap.js","names":[],"sources":["fieldTypeMap.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 IFieldValueUnion from \"./fieldValueUnion\";\n\nexport interface IFieldTypeMap {\n readonly \"allowNullValue\": boolean;\n readonly \"key\": IFieldValueUnion.IFieldValueUnion;\n readonly \"value\": IFieldValueUnion.IFieldValueUnion;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"fieldTypeMap.js","names":[],"sources":["fieldTypeMap.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 IFieldValueUnion from \"./fieldValueUnion.js\";\n\nexport interface IFieldTypeMap {\n readonly \"allowNullValue\": boolean;\n readonly \"key\": IFieldValueUnion.IFieldValueUnion;\n readonly \"value\": IFieldValueUnion.IFieldValueUnion;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldTypeUnion.js","names":["isArray","obj","type","array","isMap","map","isSet","set","isValue","value","visit","visitor","unknown","IFieldTypeUnion"],"sources":["fieldTypeUnion.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 { IFieldTypeCollection } from \"./fieldTypeCollection\";\nimport type { IFieldTypeMap } from \"./fieldTypeMap\";\nimport type * as IFieldValueUnion from \"./fieldValueUnion\";\n\nexport interface IFieldTypeUnion_Array {\n readonly \"array\": IFieldTypeCollection;\n readonly \"type\": \"array\";\n}\n\nexport interface IFieldTypeUnion_Map {\n readonly \"map\": IFieldTypeMap;\n readonly \"type\": \"map\";\n}\n\nexport interface IFieldTypeUnion_Set {\n readonly \"set\": IFieldTypeCollection;\n readonly \"type\": \"set\";\n}\n\nexport interface IFieldTypeUnion_Value {\n readonly \"value\": IFieldValueUnion.IFieldValueUnion;\n readonly \"type\": \"value\";\n}\n\nexport type IFieldTypeUnion =\n | IFieldTypeUnion_Array\n | IFieldTypeUnion_Map\n | IFieldTypeUnion_Set\n | IFieldTypeUnion_Value;\n\nexport interface IFieldTypeUnionVisitor<T> {\n readonly \"array\": (obj: IFieldTypeCollection) => T;\n readonly \"map\": (obj: IFieldTypeMap) => T;\n readonly \"set\": (obj: IFieldTypeCollection) => T;\n readonly \"value\": (obj: IFieldValueUnion.IFieldValueUnion) => T;\n readonly \"unknown\": (obj: IFieldTypeUnion) => T;\n}\n\nfunction isArray(obj: IFieldTypeUnion): obj is IFieldTypeUnion_Array {\n return (obj.type === \"array\");\n}\n\nfunction array(obj: IFieldTypeCollection): IFieldTypeUnion_Array {\n return {\n array: obj,\n type: \"array\",\n };\n}\n\nfunction isMap(obj: IFieldTypeUnion): obj is IFieldTypeUnion_Map {\n return (obj.type === \"map\");\n}\n\nfunction map(obj: IFieldTypeMap): IFieldTypeUnion_Map {\n return {\n map: obj,\n type: \"map\",\n };\n}\n\nfunction isSet(obj: IFieldTypeUnion): obj is IFieldTypeUnion_Set {\n return (obj.type === \"set\");\n}\n\nfunction set(obj: IFieldTypeCollection): IFieldTypeUnion_Set {\n return {\n set: obj,\n type: \"set\",\n };\n}\n\nfunction isValue(obj: IFieldTypeUnion): obj is IFieldTypeUnion_Value {\n return (obj.type === \"value\");\n}\n\nfunction value(obj: IFieldValueUnion.IFieldValueUnion): IFieldTypeUnion_Value {\n return {\n value: obj,\n type: \"value\",\n };\n}\n\nfunction visit<T>(obj: IFieldTypeUnion, visitor: IFieldTypeUnionVisitor<T>): T {\n if (isArray(obj)) {\n return visitor.array(obj.array);\n }\n if (isMap(obj)) {\n return visitor.map(obj.map);\n }\n if (isSet(obj)) {\n return visitor.set(obj.set);\n }\n if (isValue(obj)) {\n return visitor.value(obj.value);\n }\n return visitor.unknown(obj);\n}\n\nexport const IFieldTypeUnion: {\n isArray: typeof isArray;\n array: typeof array;\n isMap: typeof isMap;\n map: typeof map;\n isSet: typeof isSet;\n set: typeof set;\n isValue: typeof isValue;\n value: typeof value;\n visit: typeof visit;\n} = {\n isArray: isArray,\n array: array,\n isMap: isMap,\n map: map,\n isSet: isSet,\n set: set,\n isValue: isValue,\n value: value,\n visit: visit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwCA,SAASA,OAAOA,CAACC,GAAoB,EAAgC;EACnE,OAAQA,GAAG,CAACC,IAAI,KAAK,OAAO;AAC9B;AAEA,SAASC,KAAKA,CAACF,GAAyB,EAAyB;EAC/D,OAAO;IACLE,KAAK,EAAEF,GAAG;IACVC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASE,KAAKA,CAACH,GAAoB,EAA8B;EAC/D,OAAQA,GAAG,CAACC,IAAI,KAAK,KAAK;AAC5B;AAEA,SAASG,GAAGA,CAACJ,GAAkB,EAAuB;EACpD,OAAO;IACLI,GAAG,EAAEJ,GAAG;IACRC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASI,KAAKA,CAACL,GAAoB,EAA8B;EAC/D,O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j","type","array","isMap","map","isSet","set","isValue","value","visit","visitor","unknown","IFieldTypeUnion"],"sources":["fieldTypeUnion.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 { IFieldTypeCollection } from \"./fieldTypeCollection.js\";\nimport type { IFieldTypeMap } from \"./fieldTypeMap.js\";\nimport type * as IFieldValueUnion from \"./fieldValueUnion.js\";\n\nexport interface IFieldTypeUnion_Array {\n readonly \"array\": IFieldTypeCollection;\n readonly \"type\": \"array\";\n}\n\nexport interface IFieldTypeUnion_Map {\n readonly \"map\": IFieldTypeMap;\n readonly \"type\": \"map\";\n}\n\nexport interface IFieldTypeUnion_Set {\n readonly \"set\": IFieldTypeCollection;\n readonly \"type\": \"set\";\n}\n\nexport interface IFieldTypeUnion_Value {\n readonly \"value\": IFieldValueUnion.IFieldValueUnion;\n readonly \"type\": \"value\";\n}\n\nexport type IFieldTypeUnion =\n | IFieldTypeUnion_Array\n | IFieldTypeUnion_Map\n | IFieldTypeUnion_Set\n | IFieldTypeUnion_Value;\n\nexport interface IFieldTypeUnionVisitor<T> {\n readonly \"array\": (obj: IFieldTypeCollection) => T;\n readonly \"map\": (obj: IFieldTypeMap) => T;\n readonly \"set\": (obj: IFieldTypeCollection) => T;\n readonly \"value\": (obj: IFieldValueUnion.IFieldValueUnion) => T;\n readonly \"unknown\": (obj: IFieldTypeUnion) => T;\n}\n\nfunction isArray(obj: IFieldTypeUnion): obj is IFieldTypeUnion_Array {\n return (obj.type === \"array\");\n}\n\nfunction array(obj: IFieldTypeCollection): IFieldTypeUnion_Array {\n return {\n array: obj,\n type: \"array\",\n };\n}\n\nfunction isMap(obj: IFieldTypeUnion): obj is IFieldTypeUnion_Map {\n return (obj.type === \"map\");\n}\n\nfunction map(obj: IFieldTypeMap): IFieldTypeUnion_Map {\n return {\n map: obj,\n type: \"map\",\n };\n}\n\nfunction isSet(obj: IFieldTypeUnion): obj is IFieldTypeUnion_Set {\n return (obj.type === \"set\");\n}\n\nfunction set(obj: IFieldTypeCollection): IFieldTypeUnion_Set {\n return {\n set: obj,\n type: \"set\",\n };\n}\n\nfunction isValue(obj: IFieldTypeUnion): obj is IFieldTypeUnion_Value {\n return (obj.type === \"value\");\n}\n\nfunction value(obj: IFieldValueUnion.IFieldValueUnion): IFieldTypeUnion_Value {\n return {\n value: obj,\n type: \"value\",\n };\n}\n\nfunction visit<T>(obj: IFieldTypeUnion, visitor: IFieldTypeUnionVisitor<T>): T {\n if (isArray(obj)) {\n return visitor.array(obj.array);\n }\n if (isMap(obj)) {\n return visitor.map(obj.map);\n }\n if (isSet(obj)) {\n return visitor.set(obj.set);\n }\n if (isValue(obj)) {\n return visitor.value(obj.value);\n }\n return visitor.unknown(obj);\n}\n\nexport const IFieldTypeUnion: {\n isArray: typeof isArray;\n array: typeof array;\n isMap: typeof isMap;\n map: typeof map;\n isSet: typeof isSet;\n set: typeof set;\n isValue: typeof isValue;\n value: typeof value;\n visit: typeof visit;\n} = {\n isArray: isArray,\n array: array,\n isMap: isMap,\n map: map,\n isSet: isSet,\n set: set,\n isValue: isValue,\n value: value,\n visit: visit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwCA,SAASA,OAAOA,CAACC,GAAoB,EAAgC;EACnE,OAAQA,GAAG,CAACC,IAAI,KAAK,OAAO;AAC9B;AAEA,SAASC,KAAKA,CAACF,GAAyB,EAAyB;EAC/D,OAAO;IACLE,KAAK,EAAEF,GAAG;IACVC,IAAI,EAAE;E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AAO;EAChBG,KAAK,EAAEA,KAAK;EACZC,KAAK,EAAEA,KAAK;EACZC,GAAG,EAAEA,GAAG;EACRC,KAAK,EAAEA,KAAK;EACZC,GAAG,EAAEA,GAAG;EACRC,OAAO,EAAEA,OAAO;EAChBC,KAAK,EAAEA,KAAK;EACZC,KAAK,EAAEA;AACT,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldValueDocumentRef.js","names":[],"sources":["fieldValueDocumentRef.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 { IDocumentTypeRid } from \"../pack-docschema-api/documentTypeRid\";\nexport interface IFieldValueDocumentRef {\n readonly \"documentTypeRids\": ReadonlyArray<IDocumentTypeRid>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"fieldValueDocumentRef.js","names":[],"sources":["fieldValueDocumentRef.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 { IDocumentTypeRid } from \"../pack-docschema-api/documentTypeRid.js\";\nexport interface IFieldValueDocumentRef {\n readonly \"documentTypeRids\": ReadonlyArray<IDocumentTypeRid>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldValueModelRef.js","names":[],"sources":["fieldValueModelRef.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 { IModelTypeKey } from \"../pack-docschema-api/modelTypeKey\";\nexport interface IFieldValueModelRef {\n readonly \"modelTypes\": ReadonlyArray<IModelTypeKey>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"fieldValueModelRef.js","names":[],"sources":["fieldValueModelRef.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 { IModelTypeKey } from \"../pack-docschema-api/modelTypeKey.js\";\nexport interface IFieldValueModelRef {\n readonly \"modelTypes\": ReadonlyArray<IModelTypeKey>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldValueObjectRef.js","names":[],"sources":["fieldValueObjectRef.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 { IInterfaceTypeRid } from \"../pack-docschema-api/interfaceTypeRid\";\nimport type { IObjectTypeRid } from \"../pack-docschema-api/objectTypeRid\";\nexport interface IFieldValueObjectRef {\n readonly \"interfaceTypeRids\": ReadonlyArray<IInterfaceTypeRid>;\n readonly \"objectTypeRids\": ReadonlyArray<IObjectTypeRid>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"fieldValueObjectRef.js","names":[],"sources":["fieldValueObjectRef.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 { IInterfaceTypeRid } from \"../pack-docschema-api/interfaceTypeRid.js\";\nimport type { IObjectTypeRid } from \"../pack-docschema-api/objectTypeRid.js\";\nexport interface IFieldValueObjectRef {\n readonly \"interfaceTypeRids\": ReadonlyArray<IInterfaceTypeRid>;\n readonly \"objectTypeRids\": ReadonlyArray<IObjectTypeRid>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"fieldValueUnion.js","names":["isDatetime","obj","type","datetime","isDocRef","docRef","isDouble","double","isInteger","integer","isMediaRef","mediaRef","isModelRef","modelRef","isObject","object","isString","string","isText","text","isUnmanagedJson","unmanagedJson","isUserRef","userRef","visit","visitor","unknown","IFieldValueUnion"],"sources":["fieldValueUnion.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 { IFieldValueDatetime } from \"./fieldValueDatetime\";\nimport type { IFieldValueDocumentRef } from \"./fieldValueDocumentRef\";\nimport type { IFieldValueDouble } from \"./fieldValueDouble\";\nimport type { IFieldValueInteger } from \"./fieldValueInteger\";\nimport type { IFieldValueMediaRef } from \"./fieldValueMediaRef\";\nimport type { IFieldValueModelRef } from \"./fieldValueModelRef\";\nimport type { IFieldValueObjectRef } from \"./fieldValueObjectRef\";\nimport type { IFieldValueString } from \"./fieldValueString\";\nimport type { IFieldValueText } from \"./fieldValueText\";\nimport type { IFieldValueUnmanagedJson } from \"./fieldValueUnmanagedJson\";\nimport type { IFieldValueUserRef } from \"./fieldValueUserRef\";\n\nexport interface IFieldValueUnion_Datetime {\n readonly \"datetime\": IFieldValueDatetime;\n readonly \"type\": \"datetime\";\n}\n\nexport interface IFieldValueUnion_DocRef {\n readonly \"docRef\": IFieldValueDocumentRef;\n readonly \"type\": \"docRef\";\n}\n\nexport interface IFieldValueUnion_Double {\n readonly \"double\": IFieldValueDouble;\n readonly \"type\": \"double\";\n}\n\nexport interface IFieldValueUnion_Integer {\n readonly \"integer\": IFieldValueInteger;\n readonly \"type\": \"integer\";\n}\n\nexport interface IFieldValueUnion_MediaRef {\n readonly \"mediaRef\": IFieldValueMediaRef;\n readonly \"type\": \"mediaRef\";\n}\n\nexport interface IFieldValueUnion_ModelRef {\n readonly \"modelRef\": IFieldValueModelRef;\n readonly \"type\": \"modelRef\";\n}\n\nexport interface IFieldValueUnion_Object {\n readonly \"object\": IFieldValueObjectRef;\n readonly \"type\": \"object\";\n}\n\nexport interface IFieldValueUnion_String {\n readonly \"string\": IFieldValueString;\n readonly \"type\": \"string\";\n}\n\nexport interface IFieldValueUnion_Text {\n readonly \"text\": IFieldValueText;\n readonly \"type\": \"text\";\n}\n\nexport interface IFieldValueUnion_UnmanagedJson {\n readonly \"unmanagedJson\": IFieldValueUnmanagedJson;\n readonly \"type\": \"unmanagedJson\";\n}\n\nexport interface IFieldValueUnion_UserRef {\n readonly \"userRef\": IFieldValueUserRef;\n readonly \"type\": \"userRef\";\n}\n\nexport type IFieldValueUnion =\n | IFieldValueUnion_Datetime\n | IFieldValueUnion_DocRef\n | IFieldValueUnion_Double\n | IFieldValueUnion_Integer\n | IFieldValueUnion_MediaRef\n | IFieldValueUnion_ModelRef\n | IFieldValueUnion_Object\n | IFieldValueUnion_String\n | IFieldValueUnion_Text\n | IFieldValueUnion_UnmanagedJson\n | IFieldValueUnion_UserRef;\n\nexport interface IFieldValueUnionVisitor<T> {\n readonly \"datetime\": (obj: IFieldValueDatetime) => T;\n readonly \"docRef\": (obj: IFieldValueDocumentRef) => T;\n readonly \"double\": (obj: IFieldValueDouble) => T;\n readonly \"integer\": (obj: IFieldValueInteger) => T;\n readonly \"mediaRef\": (obj: IFieldValueMediaRef) => T;\n readonly \"modelRef\": (obj: IFieldValueModelRef) => T;\n readonly \"object\": (obj: IFieldValueObjectRef) => T;\n readonly \"string\": (obj: IFieldValueString) => T;\n readonly \"text\": (obj: IFieldValueText) => T;\n readonly \"unmanagedJson\": (obj: IFieldValueUnmanagedJson) => T;\n readonly \"userRef\": (obj: IFieldValueUserRef) => T;\n readonly \"unknown\": (obj: IFieldValueUnion) => T;\n}\n\nfunction isDatetime(obj: IFieldValueUnion): obj is IFieldValueUnion_Datetime {\n return (obj.type === \"datetime\");\n}\n\nfunction datetime(obj: IFieldValueDatetime): IFieldValueUnion_Datetime {\n return {\n datetime: obj,\n type: \"datetime\",\n };\n}\n\nfunction isDocRef(obj: IFieldValueUnion): obj is IFieldValueUnion_DocRef {\n return (obj.type === \"docRef\");\n}\n\nfunction docRef(obj: IFieldValueDocumentRef): IFieldValueUnion_DocRef {\n return {\n docRef: obj,\n type: \"docRef\",\n };\n}\n\nfunction isDouble(obj: IFieldValueUnion): obj is IFieldValueUnion_Double {\n return (obj.type === \"double\");\n}\n\nfunction double(obj: IFieldValueDouble): IFieldValueUnion_Double {\n return {\n double: obj,\n type: \"double\",\n };\n}\n\nfunction isInteger(obj: IFieldValueUnion): obj is IFieldValueUnion_Integer {\n return (obj.type === \"integer\");\n}\n\nfunction integer(obj: IFieldValueInteger): IFieldValueUnion_Integer {\n return {\n integer: obj,\n type: \"integer\",\n };\n}\n\nfunction isMediaRef(obj: IFieldValueUnion): obj is IFieldValueUnion_MediaRef {\n return (obj.type === \"mediaRef\");\n}\n\nfunction mediaRef(obj: IFieldValueMediaRef): IFieldValueUnion_MediaRef {\n return {\n mediaRef: obj,\n type: \"mediaRef\",\n };\n}\n\nfunction isModelRef(obj: IFieldValueUnion): obj is IFieldValueUnion_ModelRef {\n return (obj.type === \"modelRef\");\n}\n\nfunction modelRef(obj: IFieldValueModelRef): IFieldValueUnion_ModelRef {\n return {\n modelRef: obj,\n type: \"modelRef\",\n };\n}\n\nfunction isObject(obj: IFieldValueUnion): obj is IFieldValueUnion_Object {\n return (obj.type === \"object\");\n}\n\nfunction object(obj: IFieldValueObjectRef): IFieldValueUnion_Object {\n return {\n object: obj,\n type: \"object\",\n };\n}\n\nfunction isString(obj: IFieldValueUnion): obj is IFieldValueUnion_String {\n return (obj.type === \"string\");\n}\n\nfunction string(obj: IFieldValueString): IFieldValueUnion_String {\n return {\n string: obj,\n type: \"string\",\n };\n}\n\nfunction isText(obj: IFieldValueUnion): obj is IFieldValueUnion_Text {\n return (obj.type === \"text\");\n}\n\nfunction text(obj: IFieldValueText): IFieldValueUnion_Text {\n return {\n text: obj,\n type: \"text\",\n };\n}\n\nfunction isUnmanagedJson(obj: IFieldValueUnion): obj is IFieldValueUnion_UnmanagedJson {\n return (obj.type === \"unmanagedJson\");\n}\n\nfunction unmanagedJson(obj: IFieldValueUnmanagedJson): IFieldValueUnion_UnmanagedJson {\n return {\n unmanagedJson: obj,\n type: \"unmanagedJson\",\n };\n}\n\nfunction isUserRef(obj: IFieldValueUnion): obj is IFieldValueUnion_UserRef {\n return (obj.type === \"userRef\");\n}\n\nfunction userRef(obj: IFieldValueUserRef): IFieldValueUnion_UserRef {\n return {\n userRef: obj,\n type: \"userRef\",\n };\n}\n\nfunction visit<T>(obj: IFieldValueUnion, visitor: IFieldValueUnionVisitor<T>): T {\n if (isDatetime(obj)) {\n return visitor.datetime(obj.datetime);\n }\n if (isDocRef(obj)) {\n return visitor.docRef(obj.docRef);\n }\n if (isDouble(obj)) {\n return visitor.double(obj.double);\n }\n if (isInteger(obj)) {\n return visitor.integer(obj.integer);\n }\n if (isMediaRef(obj)) {\n return visitor.mediaRef(obj.mediaRef);\n }\n if (isModelRef(obj)) {\n return visitor.modelRef(obj.modelRef);\n }\n if (isObject(obj)) {\n return visitor.object(obj.object);\n }\n if (isString(obj)) {\n return visitor.string(obj.string);\n }\n if (isText(obj)) {\n return visitor.text(obj.text);\n }\n if (isUnmanagedJson(obj)) {\n return visitor.unmanagedJson(obj.unmanagedJson);\n }\n if (isUserRef(obj)) {\n return visitor.userRef(obj.userRef);\n }\n return visitor.unknown(obj);\n}\n\nexport const IFieldValueUnion: {\n isDatetime: typeof isDatetime;\n datetime: typeof datetime;\n isDocRef: typeof isDocRef;\n docRef: typeof docRef;\n isDouble: typeof isDouble;\n double: typeof double;\n isInteger: typeof isInteger;\n integer: typeof integer;\n isMediaRef: typeof isMediaRef;\n mediaRef: typeof mediaRef;\n isModelRef: typeof isModelRef;\n modelRef: typeof modelRef;\n isObject: typeof isObject;\n object: typeof object;\n isString: typeof isString;\n string: typeof string;\n isText: typeof isText;\n text: typeof text;\n isUnmanagedJson: typeof isUnmanagedJson;\n unmanagedJson: typeof unmanagedJson;\n isUserRef: typeof isUserRef;\n userRef: typeof userRef;\n visit: typeof visit;\n} = {\n isDatetime: isDatetime,\n datetime: datetime,\n isDocRef: isDocRef,\n docRef: docRef,\n isDouble: isDouble,\n double: double,\n isInteger: isInteger,\n integer: integer,\n isMediaRef: isMediaRef,\n mediaRef: mediaRef,\n isModelRef: isModelRef,\n modelRef: modelRef,\n isObject: isObject,\n object: object,\n isString: isString,\n string: string,\n isText: isText,\n text: text,\n isUnmanagedJson: isUnmanagedJson,\n unmanagedJson: unmanagedJson,\n isUserRef: isUserRef,\n userRef: userRef,\n visit: visit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiGA,SAASA,UAAUA,CAACC,GAAqB,EAAoC;EAC3E,OAAQA,GAAG,CAACC,IAAI,KAAK,UAAU;AACjC;AAEA,SAASC,QAAQA,CAACF,GAAwB,EAA6B;EACrE,OAAO;IACLE,QAAQ,EAAEF,GAAG;IACbC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASE,QAAQA,CAACH,GAAqB,EAAkC;EACvE,OAAQA,GAAG,CAACC,IAAI,KAAK,QAAQ;AAC/B;AAEA,SAASG,MAAMA,CAACJ,GAA2B,EAA2B;EACpE,OAAO;IACLI,MAAM,EAAEJ,GAAG;IACXC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASI,QAAQA,CAACL,GAAqB,EAAkC;EACvE,OAAQA,GAAG,CAACC,IAAI,KAAK,QAAQ;AAC/B;AAEA,SAASK,MAAMA,CAACN,GAAsB,EAA2B;EAC/D,OAAO;IACLM,MAAM,EAAEN,GAAG;IACXC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASM,SAASA,CAACP,GAAqB,EAAmC;EACzE,OAAQA,GAAG,CAACC,IAAI,K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;IACjB,OAAOwB,OAAO,CAACR,MAAM,CAAChB,GAAG,CAACgB,MAAM,CAAC;EACnC;EACA,IAAIC,MAAM,CAACjB,GAAG,CAAC,EAAE;IACf,OAAOwB,OAAO,CAACN,IAAI,CAAClB,GAAG,CAACkB,IAAI,CAAC;EAC/B;EACA,IAAIC,eAAe,CAACnB,GAAG,CAAC,EAAE;IACxB,OAAOwB,OAAO,CAACJ,aAAa,CAACpB,GAAG,CAACoB,aAAa,CAAC;EACjD;EACA,IAAIC,SAAS,CAACrB,GAAG,CAAC,EAAE;IAClB,OAAOwB,OAAO,CAACF,OAAO,CAACtB,GAAG,CAACsB,OAAO,CAAC;EACrC;EACA,OAAOE,OAAO,CAACC,OAAO,CAACzB,GAAG,CAAC;AAC7B;AAEA,OAAO,MAAM0B,gBAwBZ,GAAG;EACF3B,UAAU,EAAEA,UAAU;EACtBG,QAAQ,EAAEA,QAAQ;EAClBC,QAAQ,EAAEA,QAAQ;EAClBC,MAAM,EAAEA,MAAM;EACdC,QAAQ,EAAEA,QAAQ;EAClBC,MAAM,EAAEA,MAAM;EACdC,SAAS,EAAEA,SAAS;EACpBC,OAAO,EAAEA,OAAO;EAChBC,UAAU,EAAEA,UAAU;EACtBC,QAAQ,EAAEA,QAAQ;EAClBC,UAAU,EAAEA,UAAU;EACtBC,QAAQ,EAAEA,QAAQ;EAClBC,QAAQ,EAAEA,QAAQ;EAClBC,MAAM,EAAEA,MAAM;EACdC,QAAQ,EAAEA,QAAQ;EAClBC,MAAM,EAAEA,MAAM;EACdC,MAAM,EAAEA,MAAM;EACdC,IAAI,EAAEA,IAAI;EACVC,eAAe,EAAEA,eAAe;EAChCC,aAAa,EAAEA,aAAa;EAC5BC,SAAS,EAAEA,SAAS;EACpBC,OAAO,EAAEA,OAAO;EAChBC,KAAK,EAAEA;AACT,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"fieldValueUnion.js","names":["isDatetime","obj","type","datetime","isDocRef","docRef","isDouble","double","isInteger","integer","isMediaRef","mediaRef","isModelRef","modelRef","isObject","object","isString","string","isText","text","isUnmanagedJson","unmanagedJson","isUserRef","userRef","visit","visitor","unknown","IFieldValueUnion"],"sources":["fieldValueUnion.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 { IFieldValueDatetime } from \"./fieldValueDatetime.js\";\nimport type { IFieldValueDocumentRef } from \"./fieldValueDocumentRef.js\";\nimport type { IFieldValueDouble } from \"./fieldValueDouble.js\";\nimport type { IFieldValueInteger } from \"./fieldValueInteger.js\";\nimport type { IFieldValueMediaRef } from \"./fieldValueMediaRef.js\";\nimport type { IFieldValueModelRef } from \"./fieldValueModelRef.js\";\nimport type { IFieldValueObjectRef } from \"./fieldValueObjectRef.js\";\nimport type { IFieldValueString } from \"./fieldValueString.js\";\nimport type { IFieldValueText } from \"./fieldValueText.js\";\nimport type { IFieldValueUnmanagedJson } from \"./fieldValueUnmanagedJson.js\";\nimport type { IFieldValueUserRef } from \"./fieldValueUserRef.js\";\n\nexport interface IFieldValueUnion_Datetime {\n readonly \"datetime\": IFieldValueDatetime;\n readonly \"type\": \"datetime\";\n}\n\nexport interface IFieldValueUnion_DocRef {\n readonly \"docRef\": IFieldValueDocumentRef;\n readonly \"type\": \"docRef\";\n}\n\nexport interface IFieldValueUnion_Double {\n readonly \"double\": IFieldValueDouble;\n readonly \"type\": \"double\";\n}\n\nexport interface IFieldValueUnion_Integer {\n readonly \"integer\": IFieldValueInteger;\n readonly \"type\": \"integer\";\n}\n\nexport interface IFieldValueUnion_MediaRef {\n readonly \"mediaRef\": IFieldValueMediaRef;\n readonly \"type\": \"mediaRef\";\n}\n\nexport interface IFieldValueUnion_ModelRef {\n readonly \"modelRef\": IFieldValueModelRef;\n readonly \"type\": \"modelRef\";\n}\n\nexport interface IFieldValueUnion_Object {\n readonly \"object\": IFieldValueObjectRef;\n readonly \"type\": \"object\";\n}\n\nexport interface IFieldValueUnion_String {\n readonly \"string\": IFieldValueString;\n readonly \"type\": \"string\";\n}\n\nexport interface IFieldValueUnion_Text {\n readonly \"text\": IFieldValueText;\n readonly \"type\": \"text\";\n}\n\nexport interface IFieldValueUnion_UnmanagedJson {\n readonly \"unmanagedJson\": IFieldValueUnmanagedJson;\n readonly \"type\": \"unmanagedJson\";\n}\n\nexport interface IFieldValueUnion_UserRef {\n readonly \"userRef\": IFieldValueUserRef;\n readonly \"type\": \"userRef\";\n}\n\nexport type IFieldValueUnion =\n | IFieldValueUnion_Datetime\n | IFieldValueUnion_DocRef\n | IFieldValueUnion_Double\n | IFieldValueUnion_Integer\n | IFieldValueUnion_MediaRef\n | IFieldValueUnion_ModelRef\n | IFieldValueUnion_Object\n | IFieldValueUnion_String\n | IFieldValueUnion_Text\n | IFieldValueUnion_UnmanagedJson\n | IFieldValueUnion_UserRef;\n\nexport interface IFieldValueUnionVisitor<T> {\n readonly \"datetime\": (obj: IFieldValueDatetime) => T;\n readonly \"docRef\": (obj: IFieldValueDocumentRef) => T;\n readonly \"double\": (obj: IFieldValueDouble) => T;\n readonly \"integer\": (obj: IFieldValueInteger) => T;\n readonly \"mediaRef\": (obj: IFieldValueMediaRef) => T;\n readonly \"modelRef\": (obj: IFieldValueModelRef) => T;\n readonly \"object\": (obj: IFieldValueObjectRef) => T;\n readonly \"string\": (obj: IFieldValueString) => T;\n readonly \"text\": (obj: IFieldValueText) => T;\n readonly \"unmanagedJson\": (obj: IFieldValueUnmanagedJson) => T;\n readonly \"userRef\": (obj: IFieldValueUserRef) => T;\n readonly \"unknown\": (obj: IFieldValueUnion) => T;\n}\n\nfunction isDatetime(obj: IFieldValueUnion): obj is IFieldValueUnion_Datetime {\n return (obj.type === \"datetime\");\n}\n\nfunction datetime(obj: IFieldValueDatetime): IFieldValueUnion_Datetime {\n return {\n datetime: obj,\n type: \"datetime\",\n };\n}\n\nfunction isDocRef(obj: IFieldValueUnion): obj is IFieldValueUnion_DocRef {\n return (obj.type === \"docRef\");\n}\n\nfunction docRef(obj: IFieldValueDocumentRef): IFieldValueUnion_DocRef {\n return {\n docRef: obj,\n type: \"docRef\",\n };\n}\n\nfunction isDouble(obj: IFieldValueUnion): obj is IFieldValueUnion_Double {\n return (obj.type === \"double\");\n}\n\nfunction double(obj: IFieldValueDouble): IFieldValueUnion_Double {\n return {\n double: obj,\n type: \"double\",\n };\n}\n\nfunction isInteger(obj: IFieldValueUnion): obj is IFieldValueUnion_Integer {\n return (obj.type === \"integer\");\n}\n\nfunction integer(obj: IFieldValueInteger): IFieldValueUnion_Integer {\n return {\n integer: obj,\n type: \"integer\",\n };\n}\n\nfunction isMediaRef(obj: IFieldValueUnion): obj is IFieldValueUnion_MediaRef {\n return (obj.type === \"mediaRef\");\n}\n\nfunction mediaRef(obj: IFieldValueMediaRef): IFieldValueUnion_MediaRef {\n return {\n mediaRef: obj,\n type: \"mediaRef\",\n };\n}\n\nfunction isModelRef(obj: IFieldValueUnion): obj is IFieldValueUnion_ModelRef {\n return (obj.type === \"modelRef\");\n}\n\nfunction modelRef(obj: IFieldValueModelRef): IFieldValueUnion_ModelRef {\n return {\n modelRef: obj,\n type: \"modelRef\",\n };\n}\n\nfunction isObject(obj: IFieldValueUnion): obj is IFieldValueUnion_Object {\n return (obj.type === \"object\");\n}\n\nfunction object(obj: IFieldValueObjectRef): IFieldValueUnion_Object {\n return {\n object: obj,\n type: \"object\",\n };\n}\n\nfunction isString(obj: IFieldValueUnion): obj is IFieldValueUnion_String {\n return (obj.type === \"string\");\n}\n\nfunction string(obj: IFieldValueString): IFieldValueUnion_String {\n return {\n string: obj,\n type: \"string\",\n };\n}\n\nfunction isText(obj: IFieldValueUnion): obj is IFieldValueUnion_Text {\n return (obj.type === \"text\");\n}\n\nfunction text(obj: IFieldValueText): IFieldValueUnion_Text {\n return {\n text: obj,\n type: \"text\",\n };\n}\n\nfunction isUnmanagedJson(obj: IFieldValueUnion): obj is IFieldValueUnion_UnmanagedJson {\n return (obj.type === \"unmanagedJson\");\n}\n\nfunction unmanagedJson(obj: IFieldValueUnmanagedJson): IFieldValueUnion_UnmanagedJson {\n return {\n unmanagedJson: obj,\n type: \"unmanagedJson\",\n };\n}\n\nfunction isUserRef(obj: IFieldValueUnion): obj is IFieldValueUnion_UserRef {\n return (obj.type === \"userRef\");\n}\n\nfunction userRef(obj: IFieldValueUserRef): IFieldValueUnion_UserRef {\n return {\n userRef: obj,\n type: \"userRef\",\n };\n}\n\nfunction visit<T>(obj: IFieldValueUnion, visitor: IFieldValueUnionVisitor<T>): T {\n if (isDatetime(obj)) {\n return visitor.datetime(obj.datetime);\n }\n if (isDocRef(obj)) {\n return visitor.docRef(obj.docRef);\n }\n if (isDouble(obj)) {\n return visitor.double(obj.double);\n }\n if (isInteger(obj)) {\n return visitor.integer(obj.integer);\n }\n if (isMediaRef(obj)) {\n return visitor.mediaRef(obj.mediaRef);\n }\n if (isModelRef(obj)) {\n return visitor.modelRef(obj.modelRef);\n }\n if (isObject(obj)) {\n return visitor.object(obj.object);\n }\n if (isString(obj)) {\n return visitor.string(obj.string);\n }\n if (isText(obj)) {\n return visitor.text(obj.text);\n }\n if (isUnmanagedJson(obj)) {\n return visitor.unmanagedJson(obj.unmanagedJson);\n }\n if (isUserRef(obj)) {\n return visitor.userRef(obj.userRef);\n }\n return visitor.unknown(obj);\n}\n\nexport const IFieldValueUnion: {\n isDatetime: typeof isDatetime;\n datetime: typeof datetime;\n isDocRef: typeof isDocRef;\n docRef: typeof docRef;\n isDouble: typeof isDouble;\n double: typeof double;\n isInteger: typeof isInteger;\n integer: typeof integer;\n isMediaRef: typeof isMediaRef;\n mediaRef: typeof mediaRef;\n isModelRef: typeof isModelRef;\n modelRef: typeof modelRef;\n isObject: typeof isObject;\n object: typeof object;\n isString: typeof isString;\n string: typeof string;\n isText: typeof isText;\n text: typeof text;\n isUnmanagedJson: typeof isUnmanagedJson;\n unmanagedJson: typeof unmanagedJson;\n isUserRef: typeof isUserRef;\n userRef: typeof userRef;\n visit: typeof visit;\n} = {\n isDatetime: isDatetime,\n datetime: datetime,\n isDocRef: isDocRef,\n docRef: docRef,\n isDouble: isDouble,\n double: double,\n isInteger: isInteger,\n integer: integer,\n isMediaRef: isMediaRef,\n mediaRef: mediaRef,\n isModelRef: isModelRef,\n modelRef: modelRef,\n isObject: isObject,\n object: object,\n isString: isString,\n string: string,\n isText: isText,\n text: text,\n isUnmanagedJson: isUnmanagedJson,\n unmanagedJson: unmanagedJson,\n isUserRef: isUserRef,\n userRef: userRef,\n visit: visit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiGA,SAASA,UAAUA,CAACC,GAAqB,EAAoC;EAC3E,OAAQA,GAAG,CAACC,IAAI,KAAK,UAAU;AACjC;AAEA,SAASC,QAAQA,CAACF,GAAwB,EAA6B;EACrE,OAAO;IACLE,QAAQ,EAAEF,GAAG;IACbC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASE,QAAQA,CAACH,GAAqB,EAAkC;EACvE,OAAQA,GAAG,CAACC,IAAI,KAAK,QAAQ;AAC/B;AAEA,SAASG,MAAMA,CAACJ,GAA2B,EAA2B;EACpE,OAAO;IACLI,MAAM,EAAEJ,GAAG;IACXC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASI,QAAQA,CAACL,GAAqB,EAAkC;EACvE,OAAQA,GAAG,CAACC,IAAI,KAAK,QAAQ;AAC/B;AAEA,SAASK,MAAMA,CAACN,GAAsB,EAA2B;EAC/D,OAAO;IACLM,MAAM,EAAEN,GAAG;IACXC,IAAI,EAAE;EACR,CA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25 +14,25 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export * from "./fieldDef";
18
- export * from "./fieldTypeCollection";
19
- export * from "./fieldTypeMap";
20
- export * from "./fieldTypeUnion";
21
- export * from "./fieldValueDatetime";
22
- export * from "./fieldValueDocumentRef";
23
- export * from "./fieldValueDouble";
24
- export * from "./fieldValueInteger";
25
- export * from "./fieldValueMediaRef";
26
- export * from "./fieldValueModelRef";
27
- export * from "./fieldValueObjectRef";
28
- export * from "./fieldValueString";
29
- export * from "./fieldValueText";
30
- export * from "./fieldValueUnion";
31
- export * from "./fieldValueUnmanagedJson";
32
- export * from "./fieldValueUserRef";
33
- export * from "./modelDef";
34
- export * from "./realTimeDocumentSchema";
35
- export * from "./recordDef";
36
- export * from "./schemaMeta";
37
- export * from "./unionDef";
17
+ export * from "./fieldDef.js";
18
+ export * from "./fieldTypeCollection.js";
19
+ export * from "./fieldTypeMap.js";
20
+ export * from "./fieldTypeUnion.js";
21
+ export * from "./fieldValueDatetime.js";
22
+ export * from "./fieldValueDocumentRef.js";
23
+ export * from "./fieldValueDouble.js";
24
+ export * from "./fieldValueInteger.js";
25
+ export * from "./fieldValueMediaRef.js";
26
+ export * from "./fieldValueModelRef.js";
27
+ export * from "./fieldValueObjectRef.js";
28
+ export * from "./fieldValueString.js";
29
+ export * from "./fieldValueText.js";
30
+ export * from "./fieldValueUnion.js";
31
+ export * from "./fieldValueUnmanagedJson.js";
32
+ export * from "./fieldValueUserRef.js";
33
+ export * from "./modelDef.js";
34
+ export * from "./realTimeDocumentSchema.js";
35
+ export * from "./recordDef.js";
36
+ export * from "./schemaMeta.js";
37
+ export * from "./unionDef.js";
38
38
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["index.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\nexport * from \"./fieldDef\";\nexport * from \"./fieldTypeCollection\";\nexport * from \"./fieldTypeMap\";\nexport * from \"./fieldTypeUnion\";\nexport * from \"./fieldValueDatetime\";\nexport * from \"./fieldValueDocumentRef\";\nexport * from \"./fieldValueDouble\";\nexport * from \"./fieldValueInteger\";\nexport * from \"./fieldValueMediaRef\";\nexport * from \"./fieldValueModelRef\";\nexport * from \"./fieldValueObjectRef\";\nexport * from \"./fieldValueString\";\nexport * from \"./fieldValueText\";\nexport * from \"./fieldValueUnion\";\nexport * from \"./fieldValueUnmanagedJson\";\nexport * from \"./fieldValueUserRef\";\nexport * from \"./modelDef\";\nexport * from \"./realTimeDocumentSchema\";\nexport * from \"./recordDef\";\nexport * from \"./schemaMeta\";\nexport * from \"./unionDef\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,YAAY;AAC1B,cAAc,uBAAuB;AACrC,cAAc,gBAAgB;AAC9B,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,oBAAoB;AAClC,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,mBAAmB;AACjC,cAAc,2BAA2B;AACzC,cAAc,qBAAqB;AACnC,cAAc,YAAY;AAC1B,cAAc,0BAA0B;AACxC,cAAc,aAAa;AAC3B,cAAc,cAAc;AAC5B,cAAc,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["index.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\nexport * from \"./fieldDef.js\";\nexport * from \"./fieldTypeCollection.js\";\nexport * from \"./fieldTypeMap.js\";\nexport * from \"./fieldTypeUnion.js\";\nexport * from \"./fieldValueDatetime.js\";\nexport * from \"./fieldValueDocumentRef.js\";\nexport * from \"./fieldValueDouble.js\";\nexport * from \"./fieldValueInteger.js\";\nexport * from \"./fieldValueMediaRef.js\";\nexport * from \"./fieldValueModelRef.js\";\nexport * from \"./fieldValueObjectRef.js\";\nexport * from \"./fieldValueString.js\";\nexport * from \"./fieldValueText.js\";\nexport * from \"./fieldValueUnion.js\";\nexport * from \"./fieldValueUnmanagedJson.js\";\nexport * from \"./fieldValueUserRef.js\";\nexport * from \"./modelDef.js\";\nexport * from \"./realTimeDocumentSchema.js\";\nexport * from \"./recordDef.js\";\nexport * from \"./schemaMeta.js\";\nexport * from \"./unionDef.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,eAAe;AAC7B,cAAc,0BAA0B;AACxC,cAAc,mBAAmB;AACjC,cAAc,qBAAqB;AACnC,cAAc,yBAAyB;AACvC,cAAc,4BAA4B;AAC1C,cAAc,uBAAuB;AACrC,cAAc,wBAAwB;AACtC,cAAc,yBAAyB;AACvC,cAAc,yBAAyB;AACvC,cAAc,0BAA0B;AACxC,cAAc,uBAAuB;AACrC,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,8BAA8B;AAC5C,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,6BAA6B;AAC3C,cAAc,gBAAgB;AAC9B,cAAc,iBAAiB;AAC/B,cAAc,eAAe","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"modelDef.js","names":["isRecord","obj","type","record","isUnion","union","visit","visitor","unknown","IModelDef"],"sources":["modelDef.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 { IRecordDef } from \"./recordDef\";\nimport type { IUnionDef } from \"./unionDef\";\n\nexport interface IModelDef_Record {\n readonly \"record\": IRecordDef;\n readonly \"type\": \"record\";\n}\n\nexport interface IModelDef_Union {\n readonly \"union\": IUnionDef;\n readonly \"type\": \"union\";\n}\n\nexport type IModelDef = IModelDef_Record | IModelDef_Union;\n\nexport interface IModelDefVisitor<T> {\n readonly \"record\": (obj: IRecordDef) => T;\n readonly \"union\": (obj: IUnionDef) => T;\n readonly \"unknown\": (obj: IModelDef) => T;\n}\n\nfunction isRecord(obj: IModelDef): obj is IModelDef_Record {\n return (obj.type === \"record\");\n}\n\nfunction record(obj: IRecordDef): IModelDef_Record {\n return {\n record: obj,\n type: \"record\",\n };\n}\n\nfunction isUnion(obj: IModelDef): obj is IModelDef_Union {\n return (obj.type === \"union\");\n}\n\nfunction union(obj: IUnionDef): IModelDef_Union {\n return {\n union: obj,\n type: \"union\",\n };\n}\n\nfunction visit<T>(obj: IModelDef, visitor: IModelDefVisitor<T>): T {\n if (isRecord(obj)) {\n return visitor.record(obj.record);\n }\n if (isUnion(obj)) {\n return visitor.union(obj.union);\n }\n return visitor.unknown(obj);\n}\n\nexport const IModelDef: {\n isRecord: typeof isRecord;\n record: typeof record;\n isUnion: typeof isUnion;\n union: typeof union;\n visit: typeof visit;\n} = {\n isRecord: isRecord,\n record: record,\n isUnion: isUnion,\n union: union,\n visit: visit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA,SAASA,QAAQA,CAACC,GAAc,EAA2B;EACzD,OAAQA,GAAG,CAACC,IAAI,KAAK,QAAQ;AAC/B;AAEA,SAASC,MAAMA,CAACF,GAAe,EAAoB;EACjD,OAAO;IACLE,MAAM,EAAEF,GAAG;IACXC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASE,OAAOA,CAACH,GAAc,EAA0B;EACvD,OAAQA,GAAG,CAACC,IAAI,KAAK,OAAO;AAC9B;AAEA,SAASG,KAAKA,CAACJ,GAAc,EAAmB;EAC9C,OAAO;IACLI,KAAK,EAAEJ,GAAG;IACVC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASI,KAAKA,CAAIL,GAAc,EAAEM,OAA4B,EAAK;EACjE,IAAIP,QAAQ,CAACC,GAAG,CAAC,EAAE;IACjB,OAAOM,OAAO,CAACJ,MAAM,CAACF,GAAG,CAACE,MAAM,CAAC;EACnC;EACA,IAAIC,OAAO,CAACH,GAAG,CAAC,EAAE;IAChB,OAAOM,OAAO,CAACF,KAAK,CAACJ,GAAG,CAACI,KAAK,CAAC;EACjC;EACA,OAAOE,OAAO,CAACC,OAAO,CAACP,GAAG,CAAC;AAC7B;AAEA,OAAO,MAAMQ,SAMZ,GAAG;EACFT,QAAQ,EAAEA,QAAQ;EAClBG,MAAM,EAAEA,MAAM;EACdC,OAAO,EAAEA,OAAO;EAChBC,KAAK,EAAEA,KAAK;EACZC,KAAK,EAAEA;AACT,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"modelDef.js","names":["isRecord","obj","type","record","isUnion","union","visit","visitor","unknown","IModelDef"],"sources":["modelDef.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 { IRecordDef } from \"./recordDef.js\";\nimport type { IUnionDef } from \"./unionDef.js\";\n\nexport interface IModelDef_Record {\n readonly \"record\": IRecordDef;\n readonly \"type\": \"record\";\n}\n\nexport interface IModelDef_Union {\n readonly \"union\": IUnionDef;\n readonly \"type\": \"union\";\n}\n\nexport type IModelDef = IModelDef_Record | IModelDef_Union;\n\nexport interface IModelDefVisitor<T> {\n readonly \"record\": (obj: IRecordDef) => T;\n readonly \"union\": (obj: IUnionDef) => T;\n readonly \"unknown\": (obj: IModelDef) => T;\n}\n\nfunction isRecord(obj: IModelDef): obj is IModelDef_Record {\n return (obj.type === \"record\");\n}\n\nfunction record(obj: IRecordDef): IModelDef_Record {\n return {\n record: obj,\n type: \"record\",\n };\n}\n\nfunction isUnion(obj: IModelDef): obj is IModelDef_Union {\n return (obj.type === \"union\");\n}\n\nfunction union(obj: IUnionDef): IModelDef_Union {\n return {\n union: obj,\n type: \"union\",\n };\n}\n\nfunction visit<T>(obj: IModelDef, visitor: IModelDefVisitor<T>): T {\n if (isRecord(obj)) {\n return visitor.record(obj.record);\n }\n if (isUnion(obj)) {\n return visitor.union(obj.union);\n }\n return visitor.unknown(obj);\n}\n\nexport const IModelDef: {\n isRecord: typeof isRecord;\n record: typeof record;\n isUnion: typeof isUnion;\n union: typeof union;\n visit: typeof visit;\n} = {\n isRecord: isRecord,\n record: record,\n isUnion: isUnion,\n union: union,\n visit: visit,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA,SAASA,QAAQA,CAACC,GAAc,EAA2B;EACzD,OAAQA,GAAG,CAACC,IAAI,KAAK,QAAQ;AAC/B;AAEA,SAASC,MAAMA,CAACF,GAAe,EAAoB;EACjD,OAAO;IACLE,MAAM,EAAEF,GAAG;IACXC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASE,OAAOA,CAACH,GAAc,EAA0B;EACvD,OAAQA,GAAG,CAACC,IAAI,KAAK,OAAO;AAC9B;AAEA,SAASG,KAAKA,CAACJ,GAAc,EAAmB;EAC9C,OAAO;IACLI,KAAK,EAAEJ,GAAG;IACVC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,SAASI,KAAKA,CAAIL,GAAc,EAAEM,OAA4B,EAAK;EACjE,IAAIP,QAAQ,CAACC,GAAG,CAAC,EAAE;IACjB,OAAOM,OAAO,CAACJ,MAAM,CAACF,GAAG,CAACE,MAAM,CAAC;EACnC;EACA,IAAIC,OAAO,CAACH,GAAG,CAAC,EAAE;IAChB,OAAOM,OAAO,CAACF,KAAK,CAACJ,GAAG,CAACI,KAAK,CAAC;EACjC;EACA,OAAOE,OAAO,CAACC,OAAO,CAACP,GAAG,CAAC;AAC7B;AAEA,OAAO,MAAMQ,SAMZ,GAAG;EACFT,QAAQ,EAAEA,QAAQ;EAClBG,MAAM,EAAEA,MAAM;EACdC,OAAO,EAAEA,OAAO;EAChBC,KAAK,EAAEA,KAAK;EACZC,KAAK,EAAEA;AACT,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"realTimeDocumentSchema.js","names":[],"sources":["realTimeDocumentSchema.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 { IModelTypeKey } from \"../pack-docschema-api/modelTypeKey\";\nimport type { ISchemaVersion } from \"../pack-docschema-api/schemaVersion\";\nimport type * as IModelDef from \"./modelDef\";\nexport interface IRealTimeDocumentSchema {\n readonly \"name\": string;\n readonly \"description\": string;\n readonly \"version\": ISchemaVersion;\n /** The primary models. There may be others described internally as nested/sub-models. */\n readonly \"primaryModelKeys\": ReadonlyArray<IModelTypeKey>;\n readonly \"models\": {\n readonly [key: IModelTypeKey]: IModelDef.IModelDef;\n };\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"realTimeDocumentSchema.js","names":[],"sources":["realTimeDocumentSchema.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 { IModelTypeKey } from \"../pack-docschema-api/modelTypeKey.js\";\nimport type { ISchemaVersion } from \"../pack-docschema-api/schemaVersion.js\";\nimport type * as IModelDef from \"./modelDef.js\";\nexport interface IRealTimeDocumentSchema {\n readonly \"name\": string;\n readonly \"description\": string;\n readonly \"version\": ISchemaVersion;\n /** The primary models. There may be others described internally as nested/sub-models. */\n readonly \"primaryModelKeys\": ReadonlyArray<IModelTypeKey>;\n readonly \"models\": {\n readonly [key: IModelTypeKey]: IModelDef.IModelDef;\n };\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"recordDef.js","names":[],"sources":["recordDef.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 { IModelTypeKey } from \"../pack-docschema-api/modelTypeKey\";\nimport type { IFieldDef } from \"./fieldDef\";\nimport type { ISchemaMeta } from \"./schemaMeta\";\nexport interface IRecordDef {\n readonly \"key\": IModelTypeKey;\n readonly \"name\": string;\n readonly \"description\"?: string | null;\n readonly \"fields\": ReadonlyArray<IFieldDef>;\n readonly \"meta\": ISchemaMeta;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"recordDef.js","names":[],"sources":["recordDef.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 { IModelTypeKey } from \"../pack-docschema-api/modelTypeKey.js\";\nimport type { IFieldDef } from \"./fieldDef.js\";\nimport type { ISchemaMeta } from \"./schemaMeta.js\";\nexport interface IRecordDef {\n readonly \"key\": IModelTypeKey;\n readonly \"name\": string;\n readonly \"description\"?: string | null;\n readonly \"fields\": ReadonlyArray<IFieldDef>;\n readonly \"meta\": ISchemaMeta;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"schemaMeta.js","names":[],"sources":["schemaMeta.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 { ISchemaVersion } from \"../pack-docschema-api/schemaVersion\";\nexport interface ISchemaMeta {\n readonly \"addedIn\": ISchemaVersion;\n readonly \"deprecated\"?: ISchemaVersion | null;\n readonly \"deprecatedMessage\"?: string | null;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"schemaMeta.js","names":[],"sources":["schemaMeta.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 { ISchemaVersion } from \"../pack-docschema-api/schemaVersion.js\";\nexport interface ISchemaMeta {\n readonly \"addedIn\": ISchemaVersion;\n readonly \"deprecated\"?: ISchemaVersion | null;\n readonly \"deprecatedMessage\"?: string | null;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"unionDef.js","names":[],"sources":["unionDef.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 { IFieldKey } from \"../pack-docschema-api/fieldKey\";\nimport type { IModelTypeKey } from \"../pack-docschema-api/modelTypeKey\";\nimport type { IUnionVariantKey } from \"../pack-docschema-api/unionVariantKey\";\nimport type { ISchemaMeta } from \"./schemaMeta\";\nexport interface IUnionDef {\n readonly \"key\": IModelTypeKey;\n readonly \"discriminant\": IFieldKey;\n readonly \"name\": string;\n readonly \"description\"?: string | null;\n readonly \"variants\": {\n readonly [key: IUnionVariantKey]: IModelTypeKey;\n };\n readonly \"meta\": ISchemaMeta;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"unionDef.js","names":[],"sources":["unionDef.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 { IFieldKey } from \"../pack-docschema-api/fieldKey.js\";\nimport type { IModelTypeKey } from \"../pack-docschema-api/modelTypeKey.js\";\nimport type { IUnionVariantKey } from \"../pack-docschema-api/unionVariantKey.js\";\nimport type { ISchemaMeta } from \"./schemaMeta.js\";\nexport interface IUnionDef {\n readonly \"key\": IModelTypeKey;\n readonly \"discriminant\": IFieldKey;\n readonly \"name\": string;\n readonly \"description\"?: string | null;\n readonly \"variants\": {\n readonly [key: IUnionVariantKey]: IModelTypeKey;\n };\n readonly \"meta\": ISchemaMeta;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"generateZodSchemasFromIr.test.js","names":["path","describe","expect","it","generateZodSchemasFromIr","formatWithPrettier","snapshotDir","join","__dirname","result","name","description","version","primaryModelKeys","models","Person","type","record","key","fields","value","string","minLength","maxLength","meta","addedIn","integer","minValue","maxValue","isOptional","formatted","toMatchFileSnapshot","Container","array","allowNullValue","map","unmanagedJson","Event","datetime","ObjectNode","double","TextBox","Node","union","discriminant","variants","object","Foo","Bar","FooBar","foo","bar","lines","split","fooSchemaIndex","findIndex","line","includes","barSchemaIndex","fooBarSchemaIndex","toBeGreaterThan","toBeLessThan"],"sources":["generateZodSchemasFromIr.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\";\nimport { generateZodSchemasFromIr } from \"../generateZodSchemasFromIr.js\";\nimport { formatWithPrettier } from \"./formatWithPrettier.js\";\n\ndescribe(\"generateZodSchemasFromIr\", () => {\n const snapshotDir = path.join(__dirname, \"__snapshots__\", \"generateZodSchemasFromIr\");\n it(\"should generate Zod schemas for simple record types\", async () => {\n const personField1: IFieldDef = {\n key: \"name\",\n name: \"Name\",\n description: \"Person name\",\n value: {\n type: \"value\",\n value: {\n type: \"string\",\n string: { minLength: 2, maxLength: 50 },\n },\n },\n meta: { addedIn: 1 },\n };\n\n const personField2: IFieldDef = {\n key: \"age\",\n name: \"Age\",\n description: \"Person age\",\n value: {\n type: \"value\",\n value: {\n type: \"integer\",\n integer: { minValue: 0, maxValue: 150 },\n },\n },\n meta: { addedIn: 1 },\n };\n\n const personField3: IFieldDef = {\n key: \"email\",\n name: \"Email\",\n description: \"Person email\",\n isOptional: true,\n value: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n meta: { addedIn: 1 },\n };\n\n const personRecord: IRecordDef = {\n key: \"Person\",\n name: \"Person\",\n description: \"A person record\",\n fields: [personField1, personField2, personField3],\n meta: { addedIn: 1 },\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 generateZodSchemasFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"simple-records.ts\"));\n });\n\n it(\"should generate Zod schemas for array and map types\", async () => {\n const arrayField: IFieldDef = {\n key: \"tags\",\n name: \"Tags\",\n description: \"List of tags\",\n value: {\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"string\",\n string: {},\n },\n },\n },\n meta: { addedIn: 1 },\n };\n\n const mapField: IFieldDef = {\n key: \"metadata\",\n name: \"Metadata\",\n description: \"Key-value metadata\",\n value: {\n type: \"map\",\n map: {\n allowNullValue: false,\n key: {\n type: \"string\",\n string: {},\n },\n value: {\n type: \"unmanagedJson\",\n unmanagedJson: {},\n },\n },\n },\n meta: { addedIn: 1 },\n };\n\n const containerRecord: IRecordDef = {\n key: \"Container\",\n name: \"Container\",\n description: \"A container record\",\n fields: [arrayField, mapField],\n meta: { addedIn: 1 },\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema\",\n version: 1,\n primaryModelKeys: [\"Container\"],\n models: {\n Container: {\n type: \"record\",\n record: containerRecord,\n } as IModelDef,\n },\n };\n\n const result = await generateZodSchemasFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"array-and-map-types.ts\"));\n });\n\n it(\"should generate Zod schemas with datetime fields\", async () => {\n const datetimeField: IFieldDef = {\n key: \"timestamp\",\n name: \"Timestamp\",\n description: \"Event timestamp\",\n value: {\n type: \"value\",\n value: {\n type: \"datetime\",\n datetime: {},\n },\n },\n meta: { addedIn: 1 },\n };\n\n const eventRecord: IRecordDef = {\n key: \"Event\",\n name: \"Event\",\n description: \"An event record\",\n fields: [datetimeField],\n meta: { addedIn: 1 },\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema\",\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 generateZodSchemasFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"datetime-fields.ts\"));\n });\n\n it(\"should generate Zod schemas 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 value: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n meta: { addedIn: 1 },\n },\n {\n key: \"y\",\n name: \"Y\",\n description: \"Y coordinate\",\n value: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n meta: { addedIn: 1 },\n },\n {\n key: \"label\",\n name: \"Label\",\n description: \"Node label\",\n isOptional: true,\n value: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n meta: { addedIn: 1 },\n },\n ],\n meta: { addedIn: 1 },\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 value: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n meta: { addedIn: 1 },\n },\n {\n key: \"y\",\n name: \"Y\",\n description: \"Y coordinate\",\n value: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n meta: { addedIn: 1 },\n },\n {\n key: \"text\",\n name: \"Text\",\n description: \"Text content\",\n value: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n meta: { addedIn: 1 },\n },\n ],\n meta: { addedIn: 1 },\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 meta: { addedIn: 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 generateZodSchemasFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"union-types.ts\"));\n });\n\n it(\"should handle unions defined before their variant records\", async () => {\n // Define records\n const fooRecord: IRecordDef = {\n key: \"Foo\",\n name: \"Foo\",\n description: \"Foo record\",\n fields: [\n {\n key: \"value\",\n name: \"Value\",\n description: \"A value\",\n value: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n meta: { addedIn: 1 },\n },\n ],\n meta: { addedIn: 1 },\n };\n\n const barRecord: IRecordDef = {\n key: \"Bar\",\n name: \"Bar\",\n description: \"Bar record\",\n fields: [\n {\n key: \"count\",\n name: \"Count\",\n description: \"A count\",\n value: {\n type: \"value\",\n value: {\n type: \"integer\",\n integer: {},\n },\n },\n meta: { addedIn: 1 },\n },\n ],\n meta: { addedIn: 1 },\n };\n\n // Define union that references the records\n const fooBarUnion: IUnionDef = {\n key: \"FooBar\",\n discriminant: \"type\",\n name: \"FooBar\",\n description: \"FooBar union\",\n variants: {\n foo: \"Foo\",\n bar: \"Bar\",\n },\n meta: { addedIn: 1 },\n };\n\n // Intentionally put union BEFORE its variant records in primaryModelKeys\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"Test schema with union before records\",\n version: 1,\n primaryModelKeys: [\"FooBar\", \"Foo\", \"Bar\"], // Union comes first!\n models: {\n Foo: {\n type: \"record\",\n record: fooRecord,\n } as IModelDef,\n Bar: {\n type: \"record\",\n record: barRecord,\n } as IModelDef,\n FooBar: {\n type: \"union\",\n union: fooBarUnion,\n } as IModelDef,\n },\n };\n\n const result = await generateZodSchemasFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n // Verify that records come before union in the output\n const lines = formatted.split(\"\\n\");\n const fooSchemaIndex = lines.findIndex(line => line.includes(\"export const FooSchema\"));\n const barSchemaIndex = lines.findIndex(line => line.includes(\"export const BarSchema\"));\n const fooBarSchemaIndex = lines.findIndex(line => line.includes(\"export const FooBarSchema\"));\n\n expect(fooSchemaIndex).toBeGreaterThan(-1);\n expect(barSchemaIndex).toBeGreaterThan(-1);\n expect(fooBarSchemaIndex).toBeGreaterThan(-1);\n\n // Records should come before the union\n expect(fooSchemaIndex).toBeLessThan(fooBarSchemaIndex);\n expect(barSchemaIndex).toBeLessThan(fooBarSchemaIndex);\n\n await expect(formatted).toMatchFileSnapshot(path.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AC,CAAC;EAChG,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"generateZodSchemasFromIr.test.js","names":["path","describe","expect","it","generateZodSchemasFromIr","formatWithPrettier","snapshotDir","join","__dirname","result","name","description","version","primaryModelKeys","models","Person","type","record","key","fields","value","string","minLength","maxLength","meta","addedIn","integer","minValue","maxValue","isOptional","formatted","toMatchFileSnapshot","Container","array","allowNullValue","map","unmanagedJson","Event","datetime","ObjectNode","double","TextBox","Node","union","discriminant","variants","object","Foo","Bar","FooBar","foo","bar","lines","split","fooSchemaIndex","findIndex","line","includes","barSchemaIndex","fooBarSchemaIndex","toBeGreaterThan","toBeLessThan"],"sources":["generateZodSchemasFromIr.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 { generateZodSchemasFromIr } from \"../generateZodSchemasFromIr.js\";\nimport { formatWithPrettier } from \"./formatWithPrettier.js\";\n\ndescribe(\"generateZodSchemasFromIr\", () => {\n const snapshotDir = path.join(__dirname, \"__snapshots__\", \"generateZodSchemasFromIr\");\n it(\"should generate Zod schemas for simple record types\", async () => {\n const personField1: IFieldDef = {\n key: \"name\",\n name: \"Name\",\n description: \"Person name\",\n value: {\n type: \"value\",\n value: {\n type: \"string\",\n string: { minLength: 2, maxLength: 50 },\n },\n },\n meta: { addedIn: 1 },\n };\n\n const personField2: IFieldDef = {\n key: \"age\",\n name: \"Age\",\n description: \"Person age\",\n value: {\n type: \"value\",\n value: {\n type: \"integer\",\n integer: { minValue: 0, maxValue: 150 },\n },\n },\n meta: { addedIn: 1 },\n };\n\n const personField3: IFieldDef = {\n key: \"email\",\n name: \"Email\",\n description: \"Person email\",\n isOptional: true,\n value: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n meta: { addedIn: 1 },\n };\n\n const personRecord: IRecordDef = {\n key: \"Person\",\n name: \"Person\",\n description: \"A person record\",\n fields: [personField1, personField2, personField3],\n meta: { addedIn: 1 },\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 generateZodSchemasFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"simple-records.ts\"));\n });\n\n it(\"should generate Zod schemas for array and map types\", async () => {\n const arrayField: IFieldDef = {\n key: \"tags\",\n name: \"Tags\",\n description: \"List of tags\",\n value: {\n type: \"array\",\n array: {\n allowNullValue: false,\n value: {\n type: \"string\",\n string: {},\n },\n },\n },\n meta: { addedIn: 1 },\n };\n\n const mapField: IFieldDef = {\n key: \"metadata\",\n name: \"Metadata\",\n description: \"Key-value metadata\",\n value: {\n type: \"map\",\n map: {\n allowNullValue: false,\n key: {\n type: \"string\",\n string: {},\n },\n value: {\n type: \"unmanagedJson\",\n unmanagedJson: {},\n },\n },\n },\n meta: { addedIn: 1 },\n };\n\n const containerRecord: IRecordDef = {\n key: \"Container\",\n name: \"Container\",\n description: \"A container record\",\n fields: [arrayField, mapField],\n meta: { addedIn: 1 },\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema\",\n version: 1,\n primaryModelKeys: [\"Container\"],\n models: {\n Container: {\n type: \"record\",\n record: containerRecord,\n } as IModelDef,\n },\n };\n\n const result = await generateZodSchemasFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"array-and-map-types.ts\"));\n });\n\n it(\"should generate Zod schemas with datetime fields\", async () => {\n const datetimeField: IFieldDef = {\n key: \"timestamp\",\n name: \"Timestamp\",\n description: \"Event timestamp\",\n value: {\n type: \"value\",\n value: {\n type: \"datetime\",\n datetime: {},\n },\n },\n meta: { addedIn: 1 },\n };\n\n const eventRecord: IRecordDef = {\n key: \"Event\",\n name: \"Event\",\n description: \"An event record\",\n fields: [datetimeField],\n meta: { addedIn: 1 },\n };\n\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"A test schema\",\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 generateZodSchemasFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"datetime-fields.ts\"));\n });\n\n it(\"should generate Zod schemas 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 value: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n meta: { addedIn: 1 },\n },\n {\n key: \"y\",\n name: \"Y\",\n description: \"Y coordinate\",\n value: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n meta: { addedIn: 1 },\n },\n {\n key: \"label\",\n name: \"Label\",\n description: \"Node label\",\n isOptional: true,\n value: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n meta: { addedIn: 1 },\n },\n ],\n meta: { addedIn: 1 },\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 value: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n meta: { addedIn: 1 },\n },\n {\n key: \"y\",\n name: \"Y\",\n description: \"Y coordinate\",\n value: {\n type: \"value\",\n value: {\n type: \"double\",\n double: {},\n },\n },\n meta: { addedIn: 1 },\n },\n {\n key: \"text\",\n name: \"Text\",\n description: \"Text content\",\n value: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n meta: { addedIn: 1 },\n },\n ],\n meta: { addedIn: 1 },\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 meta: { addedIn: 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 generateZodSchemasFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"union-types.ts\"));\n });\n\n it(\"should handle unions defined before their variant records\", async () => {\n // Define records\n const fooRecord: IRecordDef = {\n key: \"Foo\",\n name: \"Foo\",\n description: \"Foo record\",\n fields: [\n {\n key: \"value\",\n name: \"Value\",\n description: \"A value\",\n value: {\n type: \"value\",\n value: {\n type: \"string\",\n string: {},\n },\n },\n meta: { addedIn: 1 },\n },\n ],\n meta: { addedIn: 1 },\n };\n\n const barRecord: IRecordDef = {\n key: \"Bar\",\n name: \"Bar\",\n description: \"Bar record\",\n fields: [\n {\n key: \"count\",\n name: \"Count\",\n description: \"A count\",\n value: {\n type: \"value\",\n value: {\n type: \"integer\",\n integer: {},\n },\n },\n meta: { addedIn: 1 },\n },\n ],\n meta: { addedIn: 1 },\n };\n\n // Define union that references the records\n const fooBarUnion: IUnionDef = {\n key: \"FooBar\",\n discriminant: \"type\",\n name: \"FooBar\",\n description: \"FooBar union\",\n variants: {\n foo: \"Foo\",\n bar: \"Bar\",\n },\n meta: { addedIn: 1 },\n };\n\n // Intentionally put union BEFORE its variant records in primaryModelKeys\n const schema: IRealTimeDocumentSchema = {\n name: \"Test Schema\",\n description: \"Test schema with union before records\",\n version: 1,\n primaryModelKeys: [\"FooBar\", \"Foo\", \"Bar\"], // Union comes first!\n models: {\n Foo: {\n type: \"record\",\n record: fooRecord,\n } as IModelDef,\n Bar: {\n type: \"record\",\n record: barRecord,\n } as IModelDef,\n FooBar: {\n type: \"union\",\n union: fooBarUnion,\n } as IModelDef,\n },\n };\n\n const result = await generateZodSchemasFromIr(schema);\n const formatted = await formatWithPrettier(result);\n\n // Verify that records come before union in the output\n const lines = formatted.split(\"\\n\");\n const fooSchemaIndex = lines.findIndex(line => line.includes(\"export const FooSchema\"));\n const barSchemaIndex = lines.findIndex(line => line.includes(\"export const BarSchema\"));\n const fooBarSchemaIndex = lines.findIndex(line => line.includes(\"export const FooBarSchema\"));\n\n expect(fooSchemaIndex).toBeGreaterThan(-1);\n expect(barSchemaIndex).toBeGreaterThan(-1);\n expect(fooBarSchemaIndex).toBeGreaterThan(-1);\n\n // Records should come before the union\n expect(fooSchemaIndex).toBeLessThan(fooBarSchemaIndex);\n expect(barSchemaIndex).toBeLessThan(fooBarSchemaIndex);\n\n await expect(formatted).toMatchFileSnapshot(path.join(snapshotDir, \"union-before-records.ts\"));\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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ariant","formatVariantName","ModelGenerator","constructor","schema","options","undefined","generateModels","typeImportPath","schemaImportPath","modelTypesPackage","imports","typeNames","Set","primaryModelKeys","modelKey","model","models","type","variantName","Object","keys","union","variants","formattedVariantName","variantTypeName","key","add","typeImports","Array","from","sort","join","schemaNames","variantSchemaName","schemaImports","modelConstants","generateModelConstants","documentSchema","generateDocumentSchema","Promise","resolve","constants","processedModels","process","env","NODE_ENV","has","modelConstant","generateModelConstant","push","typeName","modelName","schemaName","externalRefFields","extractExternalRefFieldTypes","externalRefFieldTypesCode","length","entries","map","field","record","fields","value","valueType","modelEntries","generateModelsFromIr","generator"],"sources":["generateModelsFromIr.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 invariant from \"tiny-invariant\";\nimport type { IRealTimeDocumentSchema } from \"../../lib/pack-docschema-api/pack-docschema-ir\";\nimport { formatVariantName } from \"../formatVariantName.js\";\n\nexport interface ModelGeneratorOptions {\n typeImportPath?: string;\n schemaImportPath?: string;\n}\n\nexport class ModelGenerator {\n constructor(\n private readonly schema: IRealTimeDocumentSchema,\n private readonly options: ModelGeneratorOptions | undefined = undefined,\n ) {}\n\n public generateModels(): Promise<string> {\n const typeImportPath = this.options?.typeImportPath ?? \"./types.js\";\n const schemaImportPath = this.options?.schemaImportPath ?? \"./schema.js\";\n const modelTypesPackage = \"@pack/document-schema-model-types\";\n\n // Generate imports\n let imports = `import type { DocumentSchema, Model } from \"${modelTypesPackage}\";\\n\n import { Metadata } from \"${modelTypesPackage}\";\\n`;\n\n // Collect all type names (primary models + union variants)\n const typeNames = new Set(this.schema.primaryModelKeys);\n\n // Add union variant type names\n for (const modelKey of this.schema.primaryModelKeys) {\n const model = this.schema.models[modelKey];\n if (model?.type === \"union\") {\n for (const variantName of Object.keys(model.union.variants)) {\n const formattedVariantName = formatVariantName(variantName);\n const variantTypeName = `${model.union.key}${formattedVariantName}`;\n typeNames.add(variantTypeName);\n }\n }\n }\n\n const typeImports = Array.from(typeNames).sort().join(\", \");\n imports += `import type { ${typeImports} } from \"${typeImportPath}\";\\n`;\n\n // Collect all schema names (primary models + union variants)\n const schemaNames = new Set<string>();\n for (const modelKey of this.schema.primaryModelKeys) {\n schemaNames.add(`${modelKey}Schema`);\n\n const model = this.schema.models[modelKey];\n if (model?.type === \"union\") {\n for (const variantName of Object.keys(model.union.variants)) {\n const formattedVariantName = formatVariantName(variantName);\n const variantSchemaName = `${model.union.key}${formattedVariantName}Schema`;\n schemaNames.add(variantSchemaName);\n }\n }\n }\n\n const schemaImports = Array.from(schemaNames).sort().join(\", \");\n imports += `import { ${schemaImports} } from \"${schemaImportPath}\";\\n\\n`;\n\n // Generate model constants\n const modelConstants = this.generateModelConstants();\n\n // Generate DocumentSchema\n const documentSchema = this.generateDocumentSchema();\n\n return Promise.resolve(imports + modelConstants + \"\\n\\n\" + documentSchema + \"\\n\");\n }\n\n private generateModelConstants(): string {\n const constants: string[] = [];\n const processedModels = new Set<string>();\n\n // Generate models for primary keys and their union variants\n for (const modelKey of this.schema.primaryModelKeys) {\n const model = this.schema.models[modelKey];\n invariant(model != null, `Model not found: ${modelKey}`);\n\n // Generate primary model constant\n if (!processedModels.has(modelKey)) {\n const modelConstant = this.generateModelConstant(modelKey, modelKey);\n constants.push(modelConstant);\n processedModels.add(modelKey);\n }\n\n // Generate union variant constants\n if (model.type === \"union\") {\n for (const variantName of Object.keys(model.union.variants)) {\n const formattedVariantName = formatVariantName(variantName);\n const variantTypeName = `${model.union.key}${formattedVariantName}`;\n\n if (!processedModels.has(variantTypeName)) {\n const modelConstant = this.generateModelConstant(variantTypeName, variantTypeName);\n constants.push(modelConstant);\n processedModels.add(variantTypeName);\n }\n }\n }\n }\n\n return constants.join(\"\\n\\n\");\n }\n\n private generateModelConstant(typeName: string, modelName: string): string {\n const schemaName = `${typeName}Schema`;\n const externalRefFields = this.extractExternalRefFieldTypes(modelName);\n\n let externalRefFieldTypesCode = \"\";\n if (externalRefFields.length > 0) {\n const entries = externalRefFields.map(([field, type]) => ` ${field}: \"${type}\",`).join(\n \"\\n\",\n );\n externalRefFieldTypesCode = `\\n externalRefFieldTypes: {\\n${entries}\\n },`;\n }\n\n return `export interface ${modelName}Model extends Model<${typeName}, typeof ${schemaName}> {}\nexport const ${modelName}Model: ${modelName}Model = {\n __type: {} as ${typeName},\n zodSchema: ${schemaName},\n [Metadata]: {${externalRefFieldTypesCode}\n name: \"${modelName}\",\n },\n};`;\n }\n\n private extractExternalRefFieldTypes(modelName: string): Array<[string, string]> {\n const model = this.schema.models[modelName];\n if (model?.type !== \"record\") {\n return [];\n }\n\n const externalRefFields: Array<[string, string]> = [];\n for (const field of model.record.fields) {\n if (field.value.type === \"value\") {\n const valueType = field.value.value.type;\n if (valueType === \"docRef\") {\n externalRefFields.push([field.key, \"docRef\"]);\n } else if (valueType === \"mediaRef\") {\n externalRefFields.push([field.key, \"mediaRef\"]);\n } else if (valueType === \"object\") {\n externalRefFields.push([field.key, \"objectRef\"]);\n } else if (valueType === \"userRef\") {\n externalRefFields.push([field.key, \"userRef\"]);\n }\n }\n }\n\n return externalRefFields;\n }\n\n private generateDocumentSchema(): string {\n const modelEntries: string[] = [];\n const processedModels = new Set<string>();\n\n // Collect all model names that will be generated\n for (const modelKey of this.schema.primaryModelKeys) {\n const model = this.schema.models[modelKey];\n invariant(model != null, `Model not found: ${modelKey}`);\n\n // Add primary model\n if (!processedModels.has(modelKey)) {\n modelEntries.push(` ${modelKey}: ${modelKey}Model`);\n processedModels.add(modelKey);\n }\n\n // Add union variant models\n if (model.type === \"union\") {\n for (const variantName of Object.keys(model.union.variants)) {\n const formattedVariantName = formatVariantName(variantName);\n const variantTypeName = `${model.union.key}${formattedVariantName}`;\n\n if (!processedModels.has(variantTypeName)) {\n modelEntries.push(` ${variantTypeName}: ${variantTypeName}Model`);\n processedModels.add(variantTypeName);\n }\n }\n }\n }\n\n return `export const DocumentModel = {\n${modelEntries.join(\",\\n\")},\n [Metadata]: {\n version: 1,\n },\n} as const satisfies DocumentSchema;\\n\n export type DocumentModel = typeof DocumentModel;`;\n }\n}\n\nexport async function generateModelsFromIr(\n schema: IRealTimeDocumentSchema,\n options?: ModelGeneratorOptions,\n): Promise<string> {\n const generator = new ModelGenerator(schema, options);\n return generator.generateModels();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AAEtC,SAASC,iBAAiB,QAAQ,yBAAyB;AAO3D,OAAO,MAAMC,cAAc,CAAC;EAC1BC,WAAWA,CACQC,MAA+B,EAC/BC,OAA0C,GAAGC,SAAS,EACvE;IAAA,KAFiBF,MAA+B,GAA/BA,MAA+B;IAAA,KAC/BC,OAA0C,GAA1CA,OAA0C;EAC1D;EAEIE,cAAcA,CAAA,EAAoB;IACvC,MAAMC,cAAc,GAAG,IAAI,CAACH,OAAO,EAAEG,cAAc,IAAI,YAAY;IACnE,MAAMC,gBAAgB,GAAG,IAAI,CAACJ,OAAO,EAAEI,gBAAgB,IAAI,aAAa;IACxE,MAAMC,iBAAiB,GAAG,mCAAmC;;IAE7D;IACA,IAAIC,OAAO,GAAG,+CAA+CD,iBAAiB;AAClF,gCAAgCA,iBAAiB,MAAM;;IAEnD;IACA,MAAME,SAAS,GAAG,IAAIC,GAAG,CAAC,IAAI,CAACT,MAAM,CAACU,gBAAgB,CAAC;;IAEvD;IACA,KAAK,MAAMC,QAAQ,IAAI,IAAI,CAACX,MAAM,CAACU,gBAAgB,EAAE;MACnD,MAAME,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A,CAAAC,QAAA,oBAAvB9C,SAAS,QAAgB,oBAAoBe,QAAQ,EAAE,IAAvDf,SAAS;;MAET;MACA,IAAI,CAAC2C,eAAe,CAACI,GAAG,CAAChC,QAAQ,CAAC,EAAE;QAClCkD,YAAY,CAACf,IAAI,CAAC,KAAKnC,QAAQ,KAAKA,QAAQ,OAAO,CAAC;QACpD4B,eAAe,CAAChB,GAAG,CAACZ,QAAQ,CAAC;MAC/B;;MAEA;MACA,IAAIC,KAAK,CAACE,IAAI,KAAK,OAAO,EAAE;QAC1B,KAAK,MAAMC,WAAW,IAAIC,MAAM,CAACC,IAAI,CAACL,KAAK,CAACM,KAAK,CAACC,QAAQ,CAAC,EAAE;UAC3D,MAAMC,oBAAoB,GAAGvB,iBAAiB,CAACkB,WAAW,CAAC;UAC3D,MAAMM,eAAe,GAAG,GAAGT,KAAK,CAACM,KAAK,CAACI,GAAG,GAAGF,oBAAoB,EAAE;UAEnE,IAAI,CAACmB,eAAe,CAACI,GAAG,CAACtB,eAAe,CAAC,EAAE;YACzCwC,YAAY,CAACf,IAAI,CAAC,KAAKzB,eAAe,KAAKA,eAAe,OAAO,CAAC;YAClEkB,eAAe,CAAChB,GAAG,CAACF,eAAe,CAAC;UACtC;QACF;MACF;IACF;IAEA,OAAO;AACX,EAAEwC,YAAY,CAACjC,IAAI,CAAC,KAAK,CAAC;AAC1B;AACA;AACA;AACA;AACA,mDAAmD;EACjD;AACF;AAEA,OAAO,eAAekC,oBAAoBA,CACxC9D,MAA+B,EAC/BC,OAA+B,EACd;EACjB,MAAM8D,SAAS,GAAG,IAAIjE,cAAc,CAACE,MAAM,EAAEC,OAAO,CAAC;EACrD,OAAO8D,SAAS,CAAC5D,cAAc,CAAC,CAAC;AACnC","ignoreList":[]}
1
+ {"version":3,"file":"generateModelsFromIr.js","names":["invariant","formatVariantName","ModelGenerator","constructor","schema","options","undefined","generateModels","typeImportPath","schemaImportPath","modelTypesPackage","imports","typeNames","Set","primaryModelKeys","modelKey","model","models","type","variantName","Object","keys","union","variants","formattedVariantName","variantTypeName","key","add","typeImports","Array","from","sort","join","schemaNames","variantSchemaName","schemaImports","modelConstants","generateModelConstants","documentSchema","generateDocumentSchema","Promise","resolve","constants","processedModels","process","env","NODE_ENV","has","modelConstant","generateModelConstant","push","typeName","modelName","schemaName","externalRefFields","extractExternalRefFieldTypes","externalRefFieldTypesCode","length","entries","map","field","record","fields","value","valueType","modelEntries","generateModelsFromIr","generator"],"sources":["generateModelsFromIr.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 invariant from \"tiny-invariant\";\nimport type { IRealTimeDocumentSchema } from \"../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { formatVariantName } from \"../formatVariantName.js\";\n\nexport interface ModelGeneratorOptions {\n typeImportPath?: string;\n schemaImportPath?: string;\n}\n\nexport class ModelGenerator {\n constructor(\n private readonly schema: IRealTimeDocumentSchema,\n private readonly options: ModelGeneratorOptions | undefined = undefined,\n ) {}\n\n public generateModels(): Promise<string> {\n const typeImportPath = this.options?.typeImportPath ?? \"./types.js\";\n const schemaImportPath = this.options?.schemaImportPath ?? \"./schema.js\";\n const modelTypesPackage = \"@pack/document-schema-model-types\";\n\n // Generate imports\n let imports = `import type { DocumentSchema, Model } from \"${modelTypesPackage}\";\\n\n import { Metadata } from \"${modelTypesPackage}\";\\n`;\n\n // Collect all type names (primary models + union variants)\n const typeNames = new Set(this.schema.primaryModelKeys);\n\n // Add union variant type names\n for (const modelKey of this.schema.primaryModelKeys) {\n const model = this.schema.models[modelKey];\n if (model?.type === \"union\") {\n for (const variantName of Object.keys(model.union.variants)) {\n const formattedVariantName = formatVariantName(variantName);\n const variantTypeName = `${model.union.key}${formattedVariantName}`;\n typeNames.add(variantTypeName);\n }\n }\n }\n\n const typeImports = Array.from(typeNames).sort().join(\", \");\n imports += `import type { ${typeImports} } from \"${typeImportPath}\";\\n`;\n\n // Collect all schema names (primary models + union variants)\n const schemaNames = new Set<string>();\n for (const modelKey of this.schema.primaryModelKeys) {\n schemaNames.add(`${modelKey}Schema`);\n\n const model = this.schema.models[modelKey];\n if (model?.type === \"union\") {\n for (const variantName of Object.keys(model.union.variants)) {\n const formattedVariantName = formatVariantName(variantName);\n const variantSchemaName = `${model.union.key}${formattedVariantName}Schema`;\n schemaNames.add(variantSchemaName);\n }\n }\n }\n\n const schemaImports = Array.from(schemaNames).sort().join(\", \");\n imports += `import { ${schemaImports} } from \"${schemaImportPath}\";\\n\\n`;\n\n // Generate model constants\n const modelConstants = this.generateModelConstants();\n\n // Generate DocumentSchema\n const documentSchema = this.generateDocumentSchema();\n\n return Promise.resolve(imports + modelConstants + \"\\n\\n\" + documentSchema + \"\\n\");\n }\n\n private generateModelConstants(): string {\n const constants: string[] = [];\n const processedModels = new Set<string>();\n\n // Generate models for primary keys and their union variants\n for (const modelKey of this.schema.primaryModelKeys) {\n const model = this.schema.models[modelKey];\n invariant(model != null, `Model not found: ${modelKey}`);\n\n // Generate primary model constant\n if (!processedModels.has(modelKey)) {\n const modelConstant = this.generateModelConstant(modelKey, modelKey);\n constants.push(modelConstant);\n processedModels.add(modelKey);\n }\n\n // Generate union variant constants\n if (model.type === \"union\") {\n for (const variantName of Object.keys(model.union.variants)) {\n const formattedVariantName = formatVariantName(variantName);\n const variantTypeName = `${model.union.key}${formattedVariantName}`;\n\n if (!processedModels.has(variantTypeName)) {\n const modelConstant = this.generateModelConstant(variantTypeName, variantTypeName);\n constants.push(modelConstant);\n processedModels.add(variantTypeName);\n }\n }\n }\n }\n\n return constants.join(\"\\n\\n\");\n }\n\n private generateModelConstant(typeName: string, modelName: string): string {\n const schemaName = `${typeName}Schema`;\n const externalRefFields = this.extractExternalRefFieldTypes(modelName);\n\n let externalRefFieldTypesCode = \"\";\n if (externalRefFields.length > 0) {\n const entries = externalRefFields.map(([field, type]) => ` ${field}: \"${type}\",`).join(\n \"\\n\",\n );\n externalRefFieldTypesCode = `\\n externalRefFieldTypes: {\\n${entries}\\n },`;\n }\n\n return `export interface ${modelName}Model extends Model<${typeName}, typeof ${schemaName}> {}\nexport const ${modelName}Model: ${modelName}Model = {\n __type: {} as ${typeName},\n zodSchema: ${schemaName},\n [Metadata]: {${externalRefFieldTypesCode}\n name: \"${modelName}\",\n },\n};`;\n }\n\n private extractExternalRefFieldTypes(modelName: string): Array<[string, string]> {\n const model = this.schema.models[modelName];\n if (model?.type !== \"record\") {\n return [];\n }\n\n const externalRefFields: Array<[string, string]> = [];\n for (const field of model.record.fields) {\n if (field.value.type === \"value\") {\n const valueType = field.value.value.type;\n if (valueType === \"docRef\") {\n externalRefFields.push([field.key, \"docRef\"]);\n } else if (valueType === \"mediaRef\") {\n externalRefFields.push([field.key, \"mediaRef\"]);\n } else if (valueType === \"object\") {\n externalRefFields.push([field.key, \"objectRef\"]);\n } else if (valueType === \"userRef\") {\n externalRefFields.push([field.key, \"userRef\"]);\n }\n }\n }\n\n return externalRefFields;\n }\n\n private generateDocumentSchema(): string {\n const modelEntries: string[] = [];\n const processedModels = new Set<string>();\n\n // Collect all model names that will be generated\n for (const modelKey of this.schema.primaryModelKeys) {\n const model = this.schema.models[modelKey];\n invariant(model != null, `Model not found: ${modelKey}`);\n\n // Add primary model\n if (!processedModels.has(modelKey)) {\n modelEntries.push(` ${modelKey}: ${modelKey}Model`);\n processedModels.add(modelKey);\n }\n\n // Add union variant models\n if (model.type === \"union\") {\n for (const variantName of Object.keys(model.union.variants)) {\n const formattedVariantName = formatVariantName(variantName);\n const variantTypeName = `${model.union.key}${formattedVariantName}`;\n\n if (!processedModels.has(variantTypeName)) {\n modelEntries.push(` ${variantTypeName}: ${variantTypeName}Model`);\n processedModels.add(variantTypeName);\n }\n }\n }\n }\n\n return `export const DocumentModel = {\n${modelEntries.join(\",\\n\")},\n [Metadata]: {\n version: 1,\n },\n} as const satisfies DocumentSchema;\\n\n export type DocumentModel = typeof DocumentModel;`;\n }\n}\n\nexport async function generateModelsFromIr(\n schema: IRealTimeDocumentSchema,\n options?: ModelGeneratorOptions,\n): Promise<string> {\n const generator = new ModelGenerator(schema, options);\n return generator.generateModels();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,SAAS,MAAM,gBAAgB;AAEtC,SAASC,iBAAiB,QAAQ,yBAAyB;AAO3D,OAAO,MAAMC,cAAc,CAAC;EAC1BC,WAAWA,CACQC,MAA+B,EAC/BC,OAA0C,GAAGC,SAAS,EACvE;IAAA,KAFiBF,MAA+B,GAA/BA,MAA+B;IAAA,KAC/BC,OAA0C,GAA1CA,OAA0C;EAC1D;EAEIE,cAAcA,CAAA,EAAoB;IACvC,MAAMC,cAAc,GAAG,IAAI,CAACH,OAAO,EAAEG,cAAc,IAAI,YAAY;IACnE,MAAMC,gBAAgB,GAAG,IAAI,CAACJ,OAAO,EAAEI,gBAAgB,IAAI,aAAa;IACxE,MAAMC,iBAAiB,GAAG,mCAAmC;;IAE7D;IACA,IAAIC,OAAO,GAAG,+CAA+CD,iBAAiB;AAClF,gCAAgCA,iBAAiB,MAAM;;IAEnD;IACA,MAAME,SAAS,GAAG,IAAIC,GAAG,CAAC,IAAI,CAACT,MAAM,CAACU,gBAAgB,CAAC;;IAEvD;IACA,KAAK,MAAMC,QAAQ,IAAI,IAAI,CAACX,MAAM,CAACU,gBAAgB,EAAE;MACnD,MAAME,KAAK,GAAG,IAAI,CAACZ,MAAM,CAACa,MAAM,CAACF,QAAQ,CAAC;MAC1C,IAAIC,KAAK,EAAEE,IAAI,KAAK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