@palantir/pack.document-schema.type-gen 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/build/esm/commands/ir/__tests__/irDeployFirstParty.test.js +237 -0
- package/build/esm/commands/ir/__tests__/irDeployFirstParty.test.js.map +1 -0
- package/build/esm/commands/ir/irDeployHandler.js +81 -41
- package/build/esm/commands/ir/irDeployHandler.js.map +1 -1
- package/build/esm/commands/ir/irGenAssetHandler.js +13 -0
- package/build/esm/commands/ir/irGenAssetHandler.js.map +1 -1
- package/build/esm/commands/ir/registerIrCommands.js +2 -2
- package/build/esm/commands/ir/registerIrCommands.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/union-types.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/union-types.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/array-and-map-types.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/array-and-map-types.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/custom-discriminant.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/custom-discriminant.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-before-records.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-before-records.js.map +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js +1 -1
- package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js.map +1 -1
- package/build/esm/utils/ir/__tests__/convertIrToConjureSchema.test.js +185 -0
- package/build/esm/utils/ir/__tests__/convertIrToConjureSchema.test.js.map +1 -0
- package/build/esm/utils/ir/convertIrToConjureSchema.js +148 -0
- package/build/esm/utils/ir/convertIrToConjureSchema.js.map +1 -0
- package/build/esm/utils/schema/__tests__/__snapshots__/generateDocumentTypeFromSchema/with-name-and-description.js +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateDocumentTypeFromSchema/with-name-and-description.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/single-version.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/three-version-chain.js.map +1 -1
- package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/two-version.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/arrayFields.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/customDiscriminant.js +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/customDiscriminant.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/refTypes.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleRecord.js.map +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleSteps.js +1 -1
- package/build/esm/utils/steps/__tests__/__snapshots__/types/simpleSteps.js.map +1 -1
- package/build/types/commands/ir/__tests__/irDeployFirstParty.test.d.ts +2 -0
- package/build/types/commands/ir/__tests__/irDeployFirstParty.test.d.ts.map +1 -0
- package/build/types/commands/ir/irDeployHandler.d.ts +20 -2
- package/build/types/commands/ir/irDeployHandler.d.ts.map +1 -1
- package/build/types/commands/ir/irGenAssetHandler.d.ts +5 -0
- package/build/types/commands/ir/irGenAssetHandler.d.ts.map +1 -1
- package/build/types/commands/ir/registerIrCommands.d.ts.map +1 -1
- package/build/types/utils/ir/__tests__/convertIrToConjureSchema.test.d.ts +2 -0
- package/build/types/utils/ir/__tests__/convertIrToConjureSchema.test.d.ts.map +1 -0
- package/build/types/utils/ir/convertIrToConjureSchema.d.ts +26 -0
- package/build/types/utils/ir/convertIrToConjureSchema.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerIrCommands.js","names":["irDeployHandler","irGenAssetHandler","irGenModelsHandler","irGenTypesHandler","irGenZodHandler","irUpdateSchemaHandler","registerIrCommands","program","irCmd","command","description","requiredOption","action","option"],"sources":["registerIrCommands.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 { Command } from \"commander\";\nimport { irDeployHandler } from \"./irDeployHandler.js\";\nimport { irGenAssetHandler } from \"./irGenAssetHandler.js\";\nimport { irGenModelsHandler } from \"./irGenModelsHandler.js\";\nimport { irGenTypesHandler } from \"./irGenTypesHandler.js\";\nimport { irGenZodHandler } from \"./irGenZodHandler.js\";\nimport { irUpdateSchemaHandler } from \"./irUpdateSchemaHandler.js\";\n\nexport function registerIrCommands(program: Command): void {\n const irCmd = program\n .command(\"ir\")\n .description(\"IR (Intermediate Representation) based generation commands\");\n\n irCmd\n .command(\"gen-types\")\n .description(\n \"Generate versioned SDK files (types, schemas, internal/, models.ts, versions.ts, versionedDocRef.ts, index.ts) from a versioned IR chain JSON.\",\n )\n .requiredOption(\"-s, --schema <file>\", \"Path to versioned IR chain JSON file\")\n .requiredOption(\"-o, --output <dir>\", \"Output directory for generated SDK files\")\n .action(irGenTypesHandler);\n\n irCmd\n .command(\"zod\")\n .description(\"Generate Zod schemas from IR document schema definitions\")\n .requiredOption(\"-s, --schema <file>\", \"Path to schema JSON file\")\n .requiredOption(\"-o, --output <file>\", \"Output file path for generated Zod schemas\")\n .option(\n \"-t, --type-import-path <path>\",\n \"Path to import types from (enables satisfies operators)\",\n )\n .action(irGenZodHandler);\n\n irCmd\n .command(\"models\")\n .description(\"Generate Model constants from IR document schema definitions\")\n .requiredOption(\"-s, --schema <file>\", \"Path to schema JSON file\")\n .requiredOption(\"-o, --output <file>\", \"Output file path for generated Model constants\")\n .option(\n \"-t, --type-import-path <path>\",\n \"Path to import types from\",\n \"./types.js\",\n )\n .option(\n \"--schema-import-path <path>\",\n \"Path to import schemas from\",\n \"./schema.js\",\n )\n .action(irGenModelsHandler);\n\n irCmd\n .command(\"deploy\")\n .description(\n \"Create a document type on a Foundry stack using an IR document schema. Deploys via the general \"\n + \"(third-party) path by default, or the first-party path with --first-party.\",\n )\n .requiredOption(\n \"-i, --ir <file>\",\n \"Path to IR JSON file (chain payload from 'schema ir', or legacy single-version IR)\",\n )\n .requiredOption(\"-b, --base-url <url>\", \"Base URL for Foundry API\")\n .requiredOption(\"-a, --auth <token>\", \"Authentication token for Foundry API\")\n .option(\n \"-p, --parent-folder <rid>\",\n \"Parent folder RID for the document type (required for third-party deploys)\",\n )\n .option(\n \"--first-party\",\n \"
|
|
1
|
+
{"version":3,"file":"registerIrCommands.js","names":["irDeployHandler","irGenAssetHandler","irGenModelsHandler","irGenTypesHandler","irGenZodHandler","irUpdateSchemaHandler","registerIrCommands","program","irCmd","command","description","requiredOption","action","option"],"sources":["registerIrCommands.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 { Command } from \"commander\";\nimport { irDeployHandler } from \"./irDeployHandler.js\";\nimport { irGenAssetHandler } from \"./irGenAssetHandler.js\";\nimport { irGenModelsHandler } from \"./irGenModelsHandler.js\";\nimport { irGenTypesHandler } from \"./irGenTypesHandler.js\";\nimport { irGenZodHandler } from \"./irGenZodHandler.js\";\nimport { irUpdateSchemaHandler } from \"./irUpdateSchemaHandler.js\";\n\nexport function registerIrCommands(program: Command): void {\n const irCmd = program\n .command(\"ir\")\n .description(\"IR (Intermediate Representation) based generation commands\");\n\n irCmd\n .command(\"gen-types\")\n .description(\n \"Generate versioned SDK files (types, schemas, internal/, models.ts, versions.ts, versionedDocRef.ts, index.ts) from a versioned IR chain JSON.\",\n )\n .requiredOption(\"-s, --schema <file>\", \"Path to versioned IR chain JSON file\")\n .requiredOption(\"-o, --output <dir>\", \"Output directory for generated SDK files\")\n .action(irGenTypesHandler);\n\n irCmd\n .command(\"zod\")\n .description(\"Generate Zod schemas from IR document schema definitions\")\n .requiredOption(\"-s, --schema <file>\", \"Path to schema JSON file\")\n .requiredOption(\"-o, --output <file>\", \"Output file path for generated Zod schemas\")\n .option(\n \"-t, --type-import-path <path>\",\n \"Path to import types from (enables satisfies operators)\",\n )\n .action(irGenZodHandler);\n\n irCmd\n .command(\"models\")\n .description(\"Generate Model constants from IR document schema definitions\")\n .requiredOption(\"-s, --schema <file>\", \"Path to schema JSON file\")\n .requiredOption(\"-o, --output <file>\", \"Output file path for generated Model constants\")\n .option(\n \"-t, --type-import-path <path>\",\n \"Path to import types from\",\n \"./types.js\",\n )\n .option(\n \"--schema-import-path <path>\",\n \"Path to import schemas from\",\n \"./schema.js\",\n )\n .action(irGenModelsHandler);\n\n irCmd\n .command(\"deploy\")\n .description(\n \"Create a document type on a Foundry stack using an IR document schema. Deploys via the general \"\n + \"(third-party) path by default, or the first-party path with --first-party.\",\n )\n .requiredOption(\n \"-i, --ir <file>\",\n \"Path to IR JSON file (chain payload from 'schema ir', or legacy single-version IR)\",\n )\n .requiredOption(\"-b, --base-url <url>\", \"Base URL for Foundry API\")\n .requiredOption(\"-a, --auth <token>\", \"Authentication token for Foundry API\")\n .option(\n \"-p, --parent-folder <rid>\",\n \"Parent folder RID for the document type (required for third-party deploys)\",\n )\n .option(\n \"--first-party\",\n \"Publish a first-party document type in dev mode: schema is unversioned (version -1) and you \"\n + \"can re-run with the same name to iterate on it. Requires --first-party-api-url.\",\n false,\n )\n .option(\n \"-o, --ontology-rid <rid>\",\n \"[deprecated] Ignored for first-party deploys (publish has no ontology binding)\",\n )\n .option(\n \"-f, --file-system-type <type>\",\n \"File system type for the document type (ARTIFACTS or COMPASS)\",\n )\n .option(\n \"--first-party-api-url <url>\",\n \"First-party document type REST API base URL, required for first-party deploys (installation-dependent)\",\n )\n .option(\n \"--first-party-prefix <path>\",\n \"[deprecated] Ignored; use --first-party-api-url for first-party deploys\",\n )\n .action(irDeployHandler);\n\n irCmd\n .command(\"update-schema\")\n .description(\"Update the schema of an existing document type using an IR document schema\")\n .requiredOption(\n \"-i, --ir <file>\",\n \"Path to IR JSON file (chain payload from 'schema ir', or legacy single-version IR)\",\n )\n .requiredOption(\"-b, --base-url <url>\", \"Base URL for Foundry API\")\n .requiredOption(\"-a, --auth <token>\", \"Authentication token for Foundry API\")\n .requiredOption(\"-o, --ontology-rid <rid>\", \"Target ontology RID\")\n .option(\n \"--force-overwrite\",\n \"Skip backwards-compatibility validation when updating the schema\",\n false,\n )\n .option(\n \"--first-party-prefix <path>\",\n \"Override the API prefix used for first-party requests (e.g. /api/gotham). Defaults to /api.\",\n )\n .action(irUpdateSchemaHandler);\n\n irCmd\n .command(\"asset\")\n .description(\n \"Generate document type asset JSON and a sibling schema compatibility range JSON from an IR file (advanced — most users should use 'ir deploy' instead). The minimum supported schema version is sourced from the IR payload's 'minSupportedVersion' field (set by 'schema ir --config <pack-config.json>'); legacy single-IR inputs default to min == max.\",\n )\n .requiredOption(\n \"-i, --ir <file>\",\n \"Path to IR JSON file (chain payload from 'schema ir', or legacy single-version IR)\",\n )\n .requiredOption(\"-o, --output <file>\", \"Output file path for asset JSON\")\n .option(\n \"-f, --file-system-type <type>\",\n \"File system type (ARTIFACTS or COMPASS)\",\n \"ARTIFACTS\",\n )\n .option(\n \"--compatibility-range-output <file>\",\n \"Output path for the schema compatibility range JSON (defaults to a sibling of --output with '-schema-compatibility-range' suffix)\",\n )\n .option(\n \"--force-overwrite\",\n \"Mark the asset so backwards-compatibility validation is skipped when the platform processes it\",\n false,\n )\n .action(irGenAssetHandler);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,eAAe,QAAQ,sBAAsB;A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__snapshots__/generateModelsFromIr/custom-discriminant.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */
|
|
2
2
|
|
|
3
3
|
import { Metadata } from '@palantir/pack.document-schema.model-types';
|
|
4
4
|
import { AnimalCatSchema, AnimalDogSchema, AnimalSchema, CatSchema, DogSchema } from './schema.js';
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/custom-discriminant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-discriminant.js","names":["Metadata","AnimalCatSchema","AnimalDogSchema","AnimalSchema","CatSchema","DogSchema","CatModel","__type","zodSchema","name","DogModel","AnimalModel","discriminant","AnimalCatModel","AnimalDogModel","DocumentModel","Cat","Dog","Animal","AnimalCat","AnimalDog","version"],"sources":["custom-discriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"custom-discriminant.js","names":["Metadata","AnimalCatSchema","AnimalDogSchema","AnimalSchema","CatSchema","DogSchema","CatModel","__type","zodSchema","name","DogModel","AnimalModel","discriminant","AnimalCatModel","AnimalDogModel","DocumentModel","Cat","Dog","Animal","AnimalCat","AnimalDog","version"],"sources":["custom-discriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport type {\n DocumentSchema,\n RecordModel,\n UnionModel,\n} from '@palantir/pack.document-schema.model-types';\nimport { Metadata } from '@palantir/pack.document-schema.model-types';\nimport type { Animal, AnimalCat, AnimalDog, Cat, Dog } from './types.js';\nimport {\n AnimalCatSchema,\n AnimalDogSchema,\n AnimalSchema,\n CatSchema,\n DogSchema,\n} from './schema.js';\n\nexport interface CatModel extends RecordModel<Cat, typeof CatSchema> {}\nexport const CatModel: CatModel = {\n __type: {} as Cat,\n zodSchema: CatSchema,\n [Metadata]: {\n name: 'Cat',\n },\n};\n\nexport interface DogModel extends RecordModel<Dog, typeof DogSchema> {}\nexport const DogModel: DogModel = {\n __type: {} as Dog,\n zodSchema: DogSchema,\n [Metadata]: {\n name: 'Dog',\n },\n};\n\nexport interface AnimalModel extends UnionModel<Animal, typeof AnimalSchema> {}\nexport const AnimalModel: AnimalModel = {\n __type: {} as Animal,\n zodSchema: AnimalSchema,\n [Metadata]: {\n discriminant: 'kind',\n name: 'Animal',\n },\n};\n\nexport interface AnimalCatModel extends UnionModel<\n AnimalCat,\n typeof AnimalCatSchema\n> {}\nexport const AnimalCatModel: AnimalCatModel = {\n __type: {} as AnimalCat,\n zodSchema: AnimalCatSchema,\n [Metadata]: {\n discriminant: 'kind',\n name: 'AnimalCat',\n },\n};\n\nexport interface AnimalDogModel extends UnionModel<\n AnimalDog,\n typeof AnimalDogSchema\n> {}\nexport const AnimalDogModel: AnimalDogModel = {\n __type: {} as AnimalDog,\n zodSchema: AnimalDogSchema,\n [Metadata]: {\n discriminant: 'kind',\n name: 'AnimalDog',\n },\n};\n\nexport const DocumentModel = {\n Cat: CatModel,\n Dog: DogModel,\n Animal: AnimalModel,\n AnimalCat: AnimalCatModel,\n AnimalDog: AnimalDogModel,\n [Metadata]: {\n version: 1,\n },\n} as const satisfies DocumentSchema;\n\nexport type DocumentModel = typeof DocumentModel;\n"],"mappings":"AAAA;;AAOA,SAASA,QAAQ,QAAQ,4CAA4C;AAErE,SACEC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,SAAS,EACTC,SAAS,QACJ,aAAa;AAGpB,OAAO,MAAMC,QAAkB,GAAG;EAChCC,MAAM,EAAE,CAAC,CAAQ;EACjBC,SAAS,EAAEJ,SAAS;EACpB,CAACJ,QAAQ,GAAG;IACVS,IAAI,EAAE;EACR;AACF,CAAC;AAGD,OAAO,MAAMC,QAAkB,GAAG;EAChCH,MAAM,EAAE,CAAC,CAAQ;EACjBC,SAAS,EAAEH,SAAS;EACpB,CAACL,QAAQ,GAAG;IACVS,IAAI,EAAE;EACR;AACF,CAAC;AAGD,OAAO,MAAME,WAAwB,GAAG;EACtCJ,MAAM,EAAE,CAAC,CAAW;EACpBC,SAAS,EAAEL,YAAY;EACvB,CAACH,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAMD,OAAO,MAAMI,cAA8B,GAAG;EAC5CN,MAAM,EAAE,CAAC,CAAc;EACvBC,SAAS,EAAEP,eAAe;EAC1B,CAACD,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAMD,OAAO,MAAMK,cAA8B,GAAG;EAC5CP,MAAM,EAAE,CAAC,CAAc;EACvBC,SAAS,EAAEN,eAAe;EAC1B,CAACF,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAED,OAAO,MAAMM,aAAa,GAAG;EAC3BC,GAAG,EAAEV,QAAQ;EACbW,GAAG,EAAEP,QAAQ;EACbQ,MAAM,EAAEP,WAAW;EACnBQ,SAAS,EAAEN,cAAc;EACzBO,SAAS,EAAEN,cAAc;EACzB,CAACd,QAAQ,GAAG;IACVqB,OAAO,EAAE;EACX;AACF,CAAmC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/external-refs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external-refs.js","names":["Metadata","EventSchema","EventModel","__type","zodSchema","externalRefFieldTypes","documentRef","userRef","resourceRef","name","DocumentModel","Event","version"],"sources":["external-refs.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"external-refs.js","names":["Metadata","EventSchema","EventModel","__type","zodSchema","externalRefFieldTypes","documentRef","userRef","resourceRef","name","DocumentModel","Event","version"],"sources":["external-refs.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport type {\n DocumentSchema,\n RecordModel,\n UnionModel,\n} from '@palantir/pack.document-schema.model-types';\nimport { Metadata } from '@palantir/pack.document-schema.model-types';\nimport type { Event } from './types.js';\nimport { EventSchema } from './schema.js';\n\nexport interface EventModel extends RecordModel<Event, typeof EventSchema> {}\nexport const EventModel: EventModel = {\n __type: {} as Event,\n zodSchema: EventSchema,\n [Metadata]: {\n externalRefFieldTypes: {\n documentRef: 'docRef',\n userRef: 'userRef',\n resourceRef: 'resourceRef',\n },\n name: 'Event',\n },\n};\n\nexport const DocumentModel = {\n Event: EventModel,\n [Metadata]: {\n version: 1,\n },\n} as const satisfies DocumentSchema;\n\nexport type DocumentModel = typeof DocumentModel;\n"],"mappings":"AAAA;;AAOA,SAASA,QAAQ,QAAQ,4CAA4C;AAErE,SAASC,WAAW,QAAQ,aAAa;AAGzC,OAAO,MAAMC,UAAsB,GAAG;EACpCC,MAAM,EAAE,CAAC,CAAU;EACnBC,SAAS,EAAEH,WAAW;EACtB,CAACD,QAAQ,GAAG;IACVK,qBAAqB,EAAE;MACrBC,WAAW,EAAE,QAAQ;MACrBC,OAAO,EAAE,SAAS;MAClBC,WAAW,EAAE;IACf,CAAC;IACDC,IAAI,EAAE;EACR;AACF,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG;EAC3BC,KAAK,EAAET,UAAU;EACjB,CAACF,QAAQ,GAAG;IACVY,OAAO,EAAE;EACX;AACF,CAAmC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateModelsFromIr/simple-record.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-record.js","names":["Metadata","PersonSchema","PersonModel","__type","zodSchema","name","DocumentModel","Person","version"],"sources":["simple-record.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"simple-record.js","names":["Metadata","PersonSchema","PersonModel","__type","zodSchema","name","DocumentModel","Person","version"],"sources":["simple-record.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport type {\n DocumentSchema,\n RecordModel,\n UnionModel,\n} from '@palantir/pack.document-schema.model-types';\nimport { Metadata } from '@palantir/pack.document-schema.model-types';\nimport type { Person } from './types.js';\nimport { PersonSchema } from './schema.js';\n\nexport interface PersonModel extends RecordModel<Person, typeof PersonSchema> {}\nexport const PersonModel: PersonModel = {\n __type: {} as Person,\n zodSchema: PersonSchema,\n [Metadata]: {\n name: 'Person',\n },\n};\n\nexport const DocumentModel = {\n Person: PersonModel,\n [Metadata]: {\n version: 1,\n },\n} as const satisfies DocumentSchema;\n\nexport type DocumentModel = typeof DocumentModel;\n"],"mappings":"AAAA;;AAOA,SAASA,QAAQ,QAAQ,4CAA4C;AAErE,SAASC,YAAY,QAAQ,aAAa;AAG1C,OAAO,MAAMC,WAAwB,GAAG;EACtCC,MAAM,EAAE,CAAC,CAAW;EACpBC,SAAS,EAAEH,YAAY;EACvB,CAACD,QAAQ,GAAG;IACVK,IAAI,EAAE;EACR;AACF,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG;EAC3BC,MAAM,EAAEL,WAAW;EACnB,CAACF,QAAQ,GAAG;IACVQ,OAAO,EAAE;EACX;AACF,CAAmC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */
|
|
2
2
|
|
|
3
3
|
import { Metadata } from '@palantir/pack.document-schema.model-types';
|
|
4
4
|
import { NodeObjectSchema, NodeSchema, NodeTextBoxSchema, ObjectNodeSchema, TextBoxSchema } from './schema.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union-types.js","names":["Metadata","NodeObjectSchema","NodeSchema","NodeTextBoxSchema","ObjectNodeSchema","TextBoxSchema","ObjectNodeModel","__type","zodSchema","name","TextBoxModel","NodeModel","discriminant","NodeObjectModel","NodeTextBoxModel","DocumentModel","ObjectNode","TextBox","Node","NodeObject","NodeTextBox","version"],"sources":["union-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"union-types.js","names":["Metadata","NodeObjectSchema","NodeSchema","NodeTextBoxSchema","ObjectNodeSchema","TextBoxSchema","ObjectNodeModel","__type","zodSchema","name","TextBoxModel","NodeModel","discriminant","NodeObjectModel","NodeTextBoxModel","DocumentModel","ObjectNode","TextBox","Node","NodeObject","NodeTextBox","version"],"sources":["union-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport type {\n DocumentSchema,\n RecordModel,\n UnionModel,\n} from '@palantir/pack.document-schema.model-types';\nimport { Metadata } from '@palantir/pack.document-schema.model-types';\nimport type {\n Node,\n NodeObject,\n NodeTextBox,\n ObjectNode,\n TextBox,\n} from './types.js';\nimport {\n NodeObjectSchema,\n NodeSchema,\n NodeTextBoxSchema,\n ObjectNodeSchema,\n TextBoxSchema,\n} from './schema.js';\n\nexport interface ObjectNodeModel extends RecordModel<\n ObjectNode,\n typeof ObjectNodeSchema\n> {}\nexport const ObjectNodeModel: ObjectNodeModel = {\n __type: {} as ObjectNode,\n zodSchema: ObjectNodeSchema,\n [Metadata]: {\n name: 'ObjectNode',\n },\n};\n\nexport interface TextBoxModel extends RecordModel<\n TextBox,\n typeof TextBoxSchema\n> {}\nexport const TextBoxModel: TextBoxModel = {\n __type: {} as TextBox,\n zodSchema: TextBoxSchema,\n [Metadata]: {\n name: 'TextBox',\n },\n};\n\nexport interface NodeModel extends UnionModel<Node, typeof NodeSchema> {}\nexport const NodeModel: NodeModel = {\n __type: {} as Node,\n zodSchema: NodeSchema,\n [Metadata]: {\n discriminant: 'type',\n name: 'Node',\n },\n};\n\nexport interface NodeObjectModel extends UnionModel<\n NodeObject,\n typeof NodeObjectSchema\n> {}\nexport const NodeObjectModel: NodeObjectModel = {\n __type: {} as NodeObject,\n zodSchema: NodeObjectSchema,\n [Metadata]: {\n discriminant: 'type',\n name: 'NodeObject',\n },\n};\n\nexport interface NodeTextBoxModel extends UnionModel<\n NodeTextBox,\n typeof NodeTextBoxSchema\n> {}\nexport const NodeTextBoxModel: NodeTextBoxModel = {\n __type: {} as NodeTextBox,\n zodSchema: NodeTextBoxSchema,\n [Metadata]: {\n discriminant: 'type',\n name: 'NodeTextBox',\n },\n};\n\nexport const DocumentModel = {\n ObjectNode: ObjectNodeModel,\n TextBox: TextBoxModel,\n Node: NodeModel,\n NodeObject: NodeObjectModel,\n NodeTextBox: NodeTextBoxModel,\n [Metadata]: {\n version: 1,\n },\n} as const satisfies DocumentSchema;\n\nexport type DocumentModel = typeof DocumentModel;\n"],"mappings":"AAAA;;AAOA,SAASA,QAAQ,QAAQ,4CAA4C;AAQrE,SACEC,gBAAgB,EAChBC,UAAU,EACVC,iBAAiB,EACjBC,gBAAgB,EAChBC,aAAa,QACR,aAAa;AAMpB,OAAO,MAAMC,eAAgC,GAAG;EAC9CC,MAAM,EAAE,CAAC,CAAe;EACxBC,SAAS,EAAEJ,gBAAgB;EAC3B,CAACJ,QAAQ,GAAG;IACVS,IAAI,EAAE;EACR;AACF,CAAC;AAMD,OAAO,MAAMC,YAA0B,GAAG;EACxCH,MAAM,EAAE,CAAC,CAAY;EACrBC,SAAS,EAAEH,aAAa;EACxB,CAACL,QAAQ,GAAG;IACVS,IAAI,EAAE;EACR;AACF,CAAC;AAGD,OAAO,MAAME,SAAoB,GAAG;EAClCJ,MAAM,EAAE,CAAC,CAAS;EAClBC,SAAS,EAAEN,UAAU;EACrB,CAACF,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAMD,OAAO,MAAMI,eAAgC,GAAG;EAC9CN,MAAM,EAAE,CAAC,CAAe;EACxBC,SAAS,EAAEP,gBAAgB;EAC3B,CAACD,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAMD,OAAO,MAAMK,gBAAkC,GAAG;EAChDP,MAAM,EAAE,CAAC,CAAgB;EACzBC,SAAS,EAAEL,iBAAiB;EAC5B,CAACH,QAAQ,GAAG;IACVY,YAAY,EAAE,MAAM;IACpBH,IAAI,EAAE;EACR;AACF,CAAC;AAED,OAAO,MAAMM,aAAa,GAAG;EAC3BC,UAAU,EAAEV,eAAe;EAC3BW,OAAO,EAAEP,YAAY;EACrBQ,IAAI,EAAEP,SAAS;EACfQ,UAAU,EAAEN,eAAe;EAC3BO,WAAW,EAAEN,gBAAgB;EAC7B,CAACd,QAAQ,GAAG;IACVqB,OAAO,EAAE;EACX;AACF,CAAmC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-and-map-types.js","names":["z","ContainerSchema","object","tags","array","string","metadata","record","unknown"],"sources":["array-and-map-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"array-and-map-types.js","names":["z","ContainerSchema","object","tags","array","string","metadata","record","unknown"],"sources":["array-and-map-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport { z } from 'zod';\n\nexport const ContainerSchema = z.object({\n tags: z.array(z.string()),\n metadata: z.record(z.string(), z.unknown()),\n});\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,eAAe,GAAGD,CAAC,CAACE,MAAM,CAAC;EACtCC,IAAI,EAAEH,CAAC,CAACI,KAAK,CAACJ,CAAC,CAACK,MAAM,CAAC,CAAC,CAAC;EACzBC,QAAQ,EAAEN,CAAC,CAACO,MAAM,CAACP,CAAC,CAACK,MAAM,CAAC,CAAC,EAAEL,CAAC,CAACQ,OAAO,CAAC,CAAC;AAC5C,CAAC,CAAC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/boolean-fields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean-fields.js","names":["z","FeatureSchema","object","enabled","boolean","isPublic","optional","flags","array"],"sources":["boolean-fields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"boolean-fields.js","names":["z","FeatureSchema","object","enabled","boolean","isPublic","optional","flags","array"],"sources":["boolean-fields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport { z } from 'zod';\n\nexport const FeatureSchema = z.object({\n enabled: z.boolean(),\n isPublic: z.boolean().optional(),\n flags: z.array(z.boolean()),\n});\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,aAAa,GAAGD,CAAC,CAACE,MAAM,CAAC;EACpCC,OAAO,EAAEH,CAAC,CAACI,OAAO,CAAC,CAAC;EACpBC,QAAQ,EAAEL,CAAC,CAACI,OAAO,CAAC,CAAC,CAACE,QAAQ,CAAC,CAAC;EAChCC,KAAK,EAAEP,CAAC,CAACQ,KAAK,CAACR,CAAC,CAACI,OAAO,CAAC,CAAC;AAC5B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-discriminant.js","names":["z","CatSchema","object","meow","string","DogSchema","bark","AnimalCatSchema","extend","kind","literal","AnimalDogSchema","AnimalSchema","discriminatedUnion"],"sources":["custom-discriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"custom-discriminant.js","names":["z","CatSchema","object","meow","string","DogSchema","bark","AnimalCatSchema","extend","kind","literal","AnimalDogSchema","AnimalSchema","discriminatedUnion"],"sources":["custom-discriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport { z } from 'zod';\n\nexport const CatSchema = z.object({\n meow: z.string(),\n});\n\nexport const DogSchema = z.object({\n bark: z.string(),\n});\n\nexport const AnimalCatSchema = CatSchema.extend({\n kind: z.literal('cat'),\n});\n\nexport const AnimalDogSchema = DogSchema.extend({\n kind: z.literal('dog'),\n});\n\nexport const AnimalSchema = z.discriminatedUnion('kind', [\n AnimalCatSchema,\n AnimalDogSchema,\n]);\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,SAAS,GAAGD,CAAC,CAACE,MAAM,CAAC;EAChCC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,MAAMC,SAAS,GAAGL,CAAC,CAACE,MAAM,CAAC;EAChCI,IAAI,EAAEN,CAAC,CAACI,MAAM,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,MAAMG,eAAe,GAAGN,SAAS,CAACO,MAAM,CAAC;EAC9CC,IAAI,EAAET,CAAC,CAACU,OAAO,CAAC,KAAK;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,eAAe,GAAGN,SAAS,CAACG,MAAM,CAAC;EAC9CC,IAAI,EAAET,CAAC,CAACU,OAAO,CAAC,KAAK;AACvB,CAAC,CAAC;AAEF,OAAO,MAAME,YAAY,GAAGZ,CAAC,CAACa,kBAAkB,CAAC,MAAM,EAAE,CACvDN,eAAe,EACfI,eAAe,CAChB,CAAC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/datetime-fields.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime-fields.js","names":["z","EventSchema","object","timestamp","string","datetime"],"sources":["datetime-fields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"datetime-fields.js","names":["z","EventSchema","object","timestamp","string","datetime"],"sources":["datetime-fields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport { z } from 'zod';\n\nexport const EventSchema = z.object({\n timestamp: z.string().datetime(),\n});\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,WAAW,GAAGD,CAAC,CAACE,MAAM,CAAC;EAClCC,SAAS,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC;AACjC,CAAC,CAAC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/simple-records.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-records.js","names":["z","PersonSchema","object","name","string","min","max","age","number","int","email","optional"],"sources":["simple-records.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"simple-records.js","names":["z","PersonSchema","object","name","string","min","max","age","number","int","email","optional"],"sources":["simple-records.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport { z } from 'zod';\n\nexport const PersonSchema = z.object({\n name: z.string().min(2).max(50),\n age: z.number().int().min(0).max(150),\n email: z.string().optional(),\n});\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,YAAY,GAAGD,CAAC,CAACE,MAAM,CAAC;EACnCC,IAAI,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAAC,CAACC,GAAG,CAAC,EAAE,CAAC;EAC/BC,GAAG,EAAEP,CAAC,CAACQ,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC,CAACJ,GAAG,CAAC,CAAC,CAAC,CAACC,GAAG,CAAC,GAAG,CAAC;EACrCI,KAAK,EAAEV,CAAC,CAACI,MAAM,CAAC,CAAC,CAACO,QAAQ,CAAC;AAC7B,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union-before-records.js","names":["z","FooSchema","object","value","string","BarSchema","count","number","int","FooBarFooSchema","extend","type","literal","FooBarBarSchema","FooBarSchema","discriminatedUnion"],"sources":["union-before-records.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"union-before-records.js","names":["z","FooSchema","object","value","string","BarSchema","count","number","int","FooBarFooSchema","extend","type","literal","FooBarBarSchema","FooBarSchema","discriminatedUnion"],"sources":["union-before-records.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport { z } from 'zod';\n\nexport const FooSchema = z.object({\n value: z.string(),\n});\n\nexport const BarSchema = z.object({\n count: z.number().int(),\n});\n\nexport const FooBarFooSchema = FooSchema.extend({\n type: z.literal('foo'),\n});\n\nexport const FooBarBarSchema = BarSchema.extend({\n type: z.literal('bar'),\n});\n\nexport const FooBarSchema = z.discriminatedUnion('type', [\n FooBarFooSchema,\n FooBarBarSchema,\n]);\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,SAAS,GAAGD,CAAC,CAACE,MAAM,CAAC;EAChCC,KAAK,EAAEH,CAAC,CAACI,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,OAAO,MAAMC,SAAS,GAAGL,CAAC,CAACE,MAAM,CAAC;EAChCI,KAAK,EAAEN,CAAC,CAACO,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC;AACxB,CAAC,CAAC;AAEF,OAAO,MAAMC,eAAe,GAAGR,SAAS,CAACS,MAAM,CAAC;EAC9CC,IAAI,EAAEX,CAAC,CAACY,OAAO,CAAC,KAAK;AACvB,CAAC,CAAC;AAEF,OAAO,MAAMC,eAAe,GAAGR,SAAS,CAACK,MAAM,CAAC;EAC9CC,IAAI,EAAEX,CAAC,CAACY,OAAO,CAAC,KAAK;AACvB,CAAC,CAAC;AAEF,OAAO,MAAME,YAAY,GAAGd,CAAC,CAACe,kBAAkB,CAAC,MAAM,EAAE,CACvDN,eAAe,EACfI,eAAe,CAChB,CAAC","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__snapshots__/generateZodSchemasFromIr/union-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union-types.js","names":["z","ObjectNodeSchema","object","x","number","y","label","string","optional","TextBoxSchema","text","NodeObjectSchema","extend","type","literal","NodeTextBoxSchema","NodeSchema","discriminatedUnion"],"sources":["union-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"union-types.js","names":["z","ObjectNodeSchema","object","x","number","y","label","string","optional","TextBoxSchema","text","NodeObjectSchema","extend","type","literal","NodeTextBoxSchema","NodeSchema","discriminatedUnion"],"sources":["union-types.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.25.0 */\n\nimport { z } from 'zod';\n\nexport const ObjectNodeSchema = z.object({\n x: z.number(),\n y: z.number(),\n label: z.string().optional(),\n});\n\nexport const TextBoxSchema = z.object({\n x: z.number(),\n y: z.number(),\n text: z.string(),\n});\n\nexport const NodeObjectSchema = ObjectNodeSchema.extend({\n type: z.literal('object'),\n});\n\nexport const NodeTextBoxSchema = TextBoxSchema.extend({\n type: z.literal('text-box'),\n});\n\nexport const NodeSchema = z.discriminatedUnion('type', [\n NodeObjectSchema,\n NodeTextBoxSchema,\n]);\n"],"mappings":"AAAA;;AAEA,SAASA,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,gBAAgB,GAAGD,CAAC,CAACE,MAAM,CAAC;EACvCC,CAAC,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC;EACbC,CAAC,EAAEL,CAAC,CAACI,MAAM,CAAC,CAAC;EACbE,KAAK,EAAEN,CAAC,CAACO,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC;AAC7B,CAAC,CAAC;AAEF,OAAO,MAAMC,aAAa,GAAGT,CAAC,CAACE,MAAM,CAAC;EACpCC,CAAC,EAAEH,CAAC,CAACI,MAAM,CAAC,CAAC;EACbC,CAAC,EAAEL,CAAC,CAACI,MAAM,CAAC,CAAC;EACbM,IAAI,EAAEV,CAAC,CAACO,MAAM,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,MAAMI,gBAAgB,GAAGV,gBAAgB,CAACW,MAAM,CAAC;EACtDC,IAAI,EAAEb,CAAC,CAACc,OAAO,CAAC,QAAQ;AAC1B,CAAC,CAAC;AAEF,OAAO,MAAMC,iBAAiB,GAAGN,aAAa,CAACG,MAAM,CAAC;EACpDC,IAAI,EAAEb,CAAC,CAACc,OAAO,CAAC,UAAU;AAC5B,CAAC,CAAC;AAEF,OAAO,MAAME,UAAU,GAAGhB,CAAC,CAACiB,kBAAkB,CAAC,MAAM,EAAE,CACrDN,gBAAgB,EAChBI,iBAAiB,CAClB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { describe, expect, it } from "vitest";
|
|
18
|
+
import { IFieldValueUnion } from "../../../lib/pack-docschema-api/pack-docschema-ir/index.js";
|
|
19
|
+
import { convertIrToConjureSchema } from "../convertIrToConjureSchema.js";
|
|
20
|
+
function schemaWith(models, primaryModelKeys = []) {
|
|
21
|
+
return {
|
|
22
|
+
name: "Test",
|
|
23
|
+
description: "Test",
|
|
24
|
+
version: 1,
|
|
25
|
+
primaryModelKeys,
|
|
26
|
+
models
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
describe("convertIrToConjureSchema", () => {
|
|
30
|
+
it("keeps record models nested under `record` (not flattened like the OSDK shape)", () => {
|
|
31
|
+
const record = {
|
|
32
|
+
key: "Person",
|
|
33
|
+
name: "Person",
|
|
34
|
+
fields: [{
|
|
35
|
+
key: "name",
|
|
36
|
+
name: "Name",
|
|
37
|
+
fieldType: {
|
|
38
|
+
type: "value",
|
|
39
|
+
value: IFieldValueUnion.string({})
|
|
40
|
+
},
|
|
41
|
+
metadata: {
|
|
42
|
+
addedInVersion: 1
|
|
43
|
+
}
|
|
44
|
+
}]
|
|
45
|
+
};
|
|
46
|
+
const model = convertIrToConjureSchema(schemaWith({
|
|
47
|
+
Person: {
|
|
48
|
+
type: "record",
|
|
49
|
+
record
|
|
50
|
+
}
|
|
51
|
+
}, ["Person"])).models["Person"];
|
|
52
|
+
expect(model.type).toBe("record");
|
|
53
|
+
expect(model.record.key).toBe("Person"); // nested, not { type: "record", key, name }
|
|
54
|
+
expect(model.record.fields).toHaveLength(1);
|
|
55
|
+
});
|
|
56
|
+
it("keeps union models nested under `union`", () => {
|
|
57
|
+
const model = convertIrToConjureSchema(schemaWith({
|
|
58
|
+
Shape: {
|
|
59
|
+
type: "union",
|
|
60
|
+
union: {
|
|
61
|
+
key: "Shape",
|
|
62
|
+
discriminant: "shapeType",
|
|
63
|
+
name: "Shape",
|
|
64
|
+
variants: {
|
|
65
|
+
circle: "Circle"
|
|
66
|
+
},
|
|
67
|
+
metadata: {
|
|
68
|
+
addedInVersion: 1
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}, ["Shape"])).models["Shape"];
|
|
73
|
+
expect(model.type).toBe("union");
|
|
74
|
+
expect(model.union.discriminant).toBe("shapeType");
|
|
75
|
+
expect(model.union.variants).toEqual({
|
|
76
|
+
circle: "Circle"
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
it("keeps a value field's union nested under its discriminant (no flattening)", () => {
|
|
80
|
+
const record = {
|
|
81
|
+
key: "R",
|
|
82
|
+
name: "R",
|
|
83
|
+
fields: [{
|
|
84
|
+
key: "f",
|
|
85
|
+
name: "f",
|
|
86
|
+
fieldType: {
|
|
87
|
+
type: "value",
|
|
88
|
+
value: IFieldValueUnion.string({
|
|
89
|
+
defaultValue: "abc"
|
|
90
|
+
})
|
|
91
|
+
},
|
|
92
|
+
metadata: {
|
|
93
|
+
addedInVersion: 1
|
|
94
|
+
}
|
|
95
|
+
}]
|
|
96
|
+
};
|
|
97
|
+
const model = convertIrToConjureSchema(schemaWith({
|
|
98
|
+
R: {
|
|
99
|
+
type: "record",
|
|
100
|
+
record
|
|
101
|
+
}
|
|
102
|
+
})).models["R"];
|
|
103
|
+
|
|
104
|
+
// Conjure: { type: "value", value: { type: "string", string: { defaultValue: "abc" } } }
|
|
105
|
+
expect(model.record.fields[0].fieldType).toEqual({
|
|
106
|
+
type: "value",
|
|
107
|
+
value: {
|
|
108
|
+
type: "string",
|
|
109
|
+
string: {
|
|
110
|
+
defaultValue: "abc"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
it("wraps collection element types in Conjure's FieldValueType", () => {
|
|
116
|
+
const record = {
|
|
117
|
+
key: "R",
|
|
118
|
+
name: "R",
|
|
119
|
+
fields: [{
|
|
120
|
+
key: "tags",
|
|
121
|
+
name: "Tags",
|
|
122
|
+
fieldType: {
|
|
123
|
+
type: "array",
|
|
124
|
+
array: {
|
|
125
|
+
allowNullValue: false,
|
|
126
|
+
value: IFieldValueUnion.string({})
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
metadata: {
|
|
130
|
+
addedInVersion: 1
|
|
131
|
+
}
|
|
132
|
+
}]
|
|
133
|
+
};
|
|
134
|
+
const model = convertIrToConjureSchema(schemaWith({
|
|
135
|
+
R: {
|
|
136
|
+
type: "record",
|
|
137
|
+
record
|
|
138
|
+
}
|
|
139
|
+
})).models["R"];
|
|
140
|
+
expect(model.record.fields[0].fieldType).toEqual({
|
|
141
|
+
type: "array",
|
|
142
|
+
array: {
|
|
143
|
+
allowNullValue: false,
|
|
144
|
+
value: {
|
|
145
|
+
valueType: {
|
|
146
|
+
type: "string",
|
|
147
|
+
string: {}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
it("rejects the NaN sentinel in a double value", () => {
|
|
154
|
+
const record = {
|
|
155
|
+
key: "R",
|
|
156
|
+
name: "R",
|
|
157
|
+
fields: [{
|
|
158
|
+
key: "n",
|
|
159
|
+
name: "N",
|
|
160
|
+
fieldType: {
|
|
161
|
+
type: "value",
|
|
162
|
+
value: IFieldValueUnion.double({
|
|
163
|
+
defaultValue: "NaN"
|
|
164
|
+
})
|
|
165
|
+
},
|
|
166
|
+
metadata: {
|
|
167
|
+
addedInVersion: 1
|
|
168
|
+
}
|
|
169
|
+
}]
|
|
170
|
+
};
|
|
171
|
+
expect(() => convertIrToConjureSchema(schemaWith({
|
|
172
|
+
R: {
|
|
173
|
+
type: "record",
|
|
174
|
+
record
|
|
175
|
+
}
|
|
176
|
+
}))).toThrow(/NaN/);
|
|
177
|
+
});
|
|
178
|
+
it("returns empty models for an empty schema", () => {
|
|
179
|
+
expect(convertIrToConjureSchema(schemaWith({}))).toEqual({
|
|
180
|
+
primaryModelKeys: [],
|
|
181
|
+
models: {}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
//# sourceMappingURL=convertIrToConjureSchema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertIrToConjureSchema.test.js","names":["describe","expect","it","IFieldValueUnion","convertIrToConjureSchema","schemaWith","models","primaryModelKeys","name","description","version","record","key","fields","fieldType","type","value","string","metadata","addedInVersion","model","Person","toBe","toHaveLength","Shape","union","discriminant","variants","circle","toEqual","defaultValue","R","array","allowNullValue","valueType","double","toThrow"],"sources":["convertIrToConjureSchema.test.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { describe, expect, it } from \"vitest\";\nimport type {\n IModelDef,\n IRealTimeDocumentSchema,\n IRecordDef,\n IUnionDef,\n} from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { IFieldValueUnion } from \"../../../lib/pack-docschema-api/pack-docschema-ir/index.js\";\nimport { convertIrToConjureSchema } from \"../convertIrToConjureSchema.js\";\n\nfunction schemaWith(\n models: Record<string, IModelDef>,\n primaryModelKeys: string[] = [],\n): IRealTimeDocumentSchema {\n return { name: \"Test\", description: \"Test\", version: 1, primaryModelKeys, models };\n}\n\ndescribe(\"convertIrToConjureSchema\", () => {\n it(\"keeps record models nested under `record` (not flattened like the OSDK shape)\", () => {\n const record: IRecordDef = {\n key: \"Person\",\n name: \"Person\",\n fields: [{\n key: \"name\",\n name: \"Name\",\n fieldType: { type: \"value\", value: IFieldValueUnion.string({}) },\n metadata: { addedInVersion: 1 },\n }],\n };\n\n const model = convertIrToConjureSchema(\n schemaWith({ Person: { type: \"record\", record } as IModelDef }, [\"Person\"]),\n ).models[\"Person\"] as { type: string; record: IRecordDef };\n\n expect(model.type).toBe(\"record\");\n expect(model.record.key).toBe(\"Person\"); // nested, not { type: \"record\", key, name }\n expect(model.record.fields).toHaveLength(1);\n });\n\n it(\"keeps union models nested under `union`\", () => {\n const union: IUnionDef = {\n key: \"Shape\",\n discriminant: \"shapeType\",\n name: \"Shape\",\n variants: { circle: \"Circle\" },\n metadata: { addedInVersion: 1 },\n };\n\n const model = convertIrToConjureSchema(\n schemaWith({ Shape: { type: \"union\", union } as IModelDef }, [\"Shape\"]),\n ).models[\"Shape\"] as { type: string; union: IUnionDef };\n\n expect(model.type).toBe(\"union\");\n expect(model.union.discriminant).toBe(\"shapeType\");\n expect(model.union.variants).toEqual({ circle: \"Circle\" });\n });\n\n it(\"keeps a value field's union nested under its discriminant (no flattening)\", () => {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [{\n key: \"f\",\n name: \"f\",\n fieldType: { type: \"value\", value: IFieldValueUnion.string({ defaultValue: \"abc\" }) },\n metadata: { addedInVersion: 1 },\n }],\n };\n\n const model = convertIrToConjureSchema(\n schemaWith({ R: { type: \"record\", record } as IModelDef }),\n )\n .models[\"R\"] as { record: { fields: Array<{ fieldType: unknown }> } };\n\n // Conjure: { type: \"value\", value: { type: \"string\", string: { defaultValue: \"abc\" } } }\n expect(model.record.fields[0]!.fieldType).toEqual({\n type: \"value\",\n value: { type: \"string\", string: { defaultValue: \"abc\" } },\n });\n });\n\n it(\"wraps collection element types in Conjure's FieldValueType\", () => {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [{\n key: \"tags\",\n name: \"Tags\",\n fieldType: {\n type: \"array\",\n array: { allowNullValue: false, value: IFieldValueUnion.string({}) },\n },\n metadata: { addedInVersion: 1 },\n }],\n };\n\n const model = convertIrToConjureSchema(\n schemaWith({ R: { type: \"record\", record } as IModelDef }),\n )\n .models[\"R\"] as { record: { fields: Array<{ fieldType: unknown }> } };\n\n expect(model.record.fields[0]!.fieldType).toEqual({\n type: \"array\",\n array: {\n allowNullValue: false,\n value: { valueType: { type: \"string\", string: {} } },\n },\n });\n });\n\n it(\"rejects the NaN sentinel in a double value\", () => {\n const record: IRecordDef = {\n key: \"R\",\n name: \"R\",\n fields: [{\n key: \"n\",\n name: \"N\",\n fieldType: { type: \"value\", value: IFieldValueUnion.double({ defaultValue: \"NaN\" }) },\n metadata: { addedInVersion: 1 },\n }],\n };\n\n expect(() =>\n convertIrToConjureSchema(schemaWith({ R: { type: \"record\", record } as IModelDef }))\n )\n .toThrow(/NaN/);\n });\n\n it(\"returns empty models for an empty schema\", () => {\n expect(convertIrToConjureSchema(schemaWith({}))).toEqual({ primaryModelKeys: [], models: {} });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAO7C,SAASC,gBAAgB,QAAQ,4DAA4D;AAC7F,SAASC,wBAAwB,QAAQ,gCAAgC;AAEzE,SAASC,UAAUA,CACjBC,MAAiC,EACjCC,gBAA0B,GAAG,EAAE,EACN;EACzB,OAAO;IAAEC,IAAI,EAAE,MAAM;IAAEC,WAAW,EAAE,MAAM;IAAEC,OAAO,EAAE,CAAC;IAAEH,gBAAgB;IAAED;EAAO,CAAC;AACpF;AAEAN,QAAQ,CAAC,0BAA0B,EAAE,MAAM;EACzCE,EAAE,CAAC,+EAA+E,EAAE,MAAM;IACxF,MAAMS,MAAkB,GAAG;MACzBC,GAAG,EAAE,QAAQ;MACbJ,IAAI,EAAE,QAAQ;MACdK,MAAM,EAAE,CAAC;QACPD,GAAG,EAAE,MAAM;QACXJ,IAAI,EAAE,MAAM;QACZM,SAAS,EAAE;UAAEC,IAAI,EAAE,OAAO;UAAEC,KAAK,EAAEb,gBAAgB,CAACc,MAAM,CAAC,CAAC,CAAC;QAAE,CAAC;QAChEC,QAAQ,EAAE;UAAEC,cAAc,EAAE;QAAE;MAChC,CAAC;IACH,CAAC;IAED,MAAMC,KAAK,GAAGhB,wBAAwB,CACpCC,UAAU,CAAC;MAAEgB,MAAM,EAAE;QAAEN,IAAI,EAAE,QAAQ;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","ignoreList":[]}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The first-party API's Conjure `DocumentTypeSchema` wire shape. We don't depend on the generated
|
|
19
|
+
* Conjure client (it lives in an internal registry this public package can't use), so this is the
|
|
20
|
+
* structural shape the publish endpoint expects; nested payloads are left as `unknown`.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Converts the IR schema to the first-party API's Conjure wire format.
|
|
25
|
+
*
|
|
26
|
+
* Conjure nests a union's payload under a key matching the discriminant
|
|
27
|
+
* (`{ type: "record", record: { ... } }`) — which is how the IR is already shaped, so this is
|
|
28
|
+
* mostly a pass-through. The one real difference: Conjure models a collection's element type as
|
|
29
|
+
* `FieldValueType { valueType }`, while the IR carries the value union directly, so those get wrapped.
|
|
30
|
+
*
|
|
31
|
+
* Do NOT use {@link convertIrToWireSchema} for the first-party publish path: that flattens unions
|
|
32
|
+
* into the OSDK shape (`{ type: "record", key, name, ... }`), which the Conjure endpoint rejects.
|
|
33
|
+
*
|
|
34
|
+
* TODO(follow-up): this parallels {@link convertIrToWireSchema}'s tree walk. Longer term the IR
|
|
35
|
+
* generator could emit the Conjure shape directly, letting this converter be removed.
|
|
36
|
+
*/
|
|
37
|
+
export function convertIrToConjureSchema(ir) {
|
|
38
|
+
const models = {};
|
|
39
|
+
for (const [key, model] of Object.entries(ir.models)) {
|
|
40
|
+
models[key] = convertModelDef(model);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
primaryModelKeys: [...ir.primaryModelKeys],
|
|
44
|
+
models
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function convertModelDef(model) {
|
|
48
|
+
switch (model.type) {
|
|
49
|
+
case "record":
|
|
50
|
+
return {
|
|
51
|
+
type: "record",
|
|
52
|
+
record: {
|
|
53
|
+
...model.record,
|
|
54
|
+
fields: model.record.fields.map(convertFieldDef)
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
case "union":
|
|
58
|
+
return {
|
|
59
|
+
type: "union",
|
|
60
|
+
union: {
|
|
61
|
+
...model.union
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
default:
|
|
65
|
+
{
|
|
66
|
+
throw new Error(`Unknown model type: ${model.type}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function convertFieldDef(field) {
|
|
71
|
+
return {
|
|
72
|
+
...field,
|
|
73
|
+
fieldType: convertFieldTypeUnion(field.fieldType)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function convertFieldTypeUnion(fieldType) {
|
|
77
|
+
switch (fieldType.type) {
|
|
78
|
+
case "array":
|
|
79
|
+
return {
|
|
80
|
+
type: "array",
|
|
81
|
+
array: {
|
|
82
|
+
allowNullValue: fieldType.array.allowNullValue,
|
|
83
|
+
value: toFieldValueType(fieldType.array.value)
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
case "map":
|
|
87
|
+
return {
|
|
88
|
+
type: "map",
|
|
89
|
+
map: {
|
|
90
|
+
allowNullValue: fieldType.map.allowNullValue,
|
|
91
|
+
key: toFieldValueType(fieldType.map.key),
|
|
92
|
+
value: toFieldValueType(fieldType.map.value)
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
case "set":
|
|
96
|
+
return {
|
|
97
|
+
type: "set",
|
|
98
|
+
set: {
|
|
99
|
+
allowNullValue: fieldType.set.allowNullValue,
|
|
100
|
+
value: toFieldValueType(fieldType.set.value)
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
// Conjure's `value` variant carries the value union directly (double values are NaN-guarded).
|
|
104
|
+
case "value":
|
|
105
|
+
return {
|
|
106
|
+
type: "value",
|
|
107
|
+
value: convertFieldValueUnion(fieldType.value)
|
|
108
|
+
};
|
|
109
|
+
default:
|
|
110
|
+
{
|
|
111
|
+
throw new Error(`Unknown field type: ${fieldType.type}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Wraps a value union in Conjure's `FieldValueType`. */
|
|
117
|
+
function toFieldValueType(value) {
|
|
118
|
+
return {
|
|
119
|
+
valueType: convertFieldValueUnion(value)
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Value unions are already in the Conjure nested shape, so this is a pass-through — except doubles,
|
|
125
|
+
* whose numeric fields may carry the "NaN" sentinel. Reject it early (matching
|
|
126
|
+
* {@link convertIrToWireSchema}) rather than forward an invalid double to the first-party API.
|
|
127
|
+
*/
|
|
128
|
+
function convertFieldValueUnion(value) {
|
|
129
|
+
if (value.type === "double") {
|
|
130
|
+
return {
|
|
131
|
+
type: "double",
|
|
132
|
+
double: {
|
|
133
|
+
...value.double,
|
|
134
|
+
defaultValue: rejectNaN(value.double.defaultValue),
|
|
135
|
+
minValue: rejectNaN(value.double.minValue),
|
|
136
|
+
maxValue: rejectNaN(value.double.maxValue)
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return value;
|
|
141
|
+
}
|
|
142
|
+
function rejectNaN(value) {
|
|
143
|
+
if (value === "NaN") {
|
|
144
|
+
throw new Error("NaN is not a valid double value for wire serialization");
|
|
145
|
+
}
|
|
146
|
+
return value ?? undefined;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=convertIrToConjureSchema.js.map
|