@palantir/pack.document-schema.type-gen 0.16.0 → 0.17.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/build/esm/commands/ir/irDeployHandler.js.map +1 -1
- package/build/esm/commands/ir/irGenAssetHandler.js +9 -12
- package/build/esm/commands/ir/irGenAssetHandler.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/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/schema/__tests__/generateIndexFromSchema.test.js +38 -0
- package/build/esm/utils/schema/__tests__/generateIndexFromSchema.test.js.map +1 -0
- package/build/esm/utils/schema/generateIndexFromSchema.js +12 -2
- package/build/esm/utils/schema/generateIndexFromSchema.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/irDeployHandler.d.ts +1 -1
- package/build/types/commands/ir/irDeployHandler.d.ts.map +1 -1
- package/build/types/commands/ir/irGenAssetHandler.d.ts +1 -1
- package/build/types/commands/ir/irGenAssetHandler.d.ts.map +1 -1
- package/build/types/utils/schema/__tests__/generateIndexFromSchema.test.d.ts +2 -0
- package/build/types/utils/schema/__tests__/generateIndexFromSchema.test.d.ts.map +1 -0
- package/build/types/utils/schema/generateIndexFromSchema.d.ts +3 -0
- package/build/types/utils/schema/generateIndexFromSchema.d.ts.map +1 -1
- package/package.json +3 -3
- package/build/esm/commands/types.js +0 -2
- package/build/esm/commands/types.js.map +0 -1
- package/build/types/commands/types.d.ts +0 -12
- package/build/types/commands/types.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"irDeployHandler.js","names":["createPlatformClient","PalantirApiError","DocumentTypes","CommanderError","consola","readFileSync","resolve","convertIrToWireSchema","buildPrefixRewriteFetch","DEFAULT_API_PREFIX","resolveIrInput","irDeployHandler","options","irPath","ir","info","latestVersion","JSON","parse","schema","fileSystemType","firstParty","deployFirstParty","name","deployThirdParty","error","parentFolder","osdkClient","baseUrl","Promise","auth","request","parentFolderRid","result","create","preview","success","version","ontologyRid","fetchFn","firstPartyPrefix","undefined","requestBody","createFirstParty","message","errorName","errorCode","details","filter","Boolean","join"],"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, PalantirApiError } from \"@osdk/client\";\nimport type {\n CreateDocumentTypeRequest,\n CreateFirstPartyDocumentTypeRequest,\n} 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 { convertIrToWireSchema } from \"../../utils/ir/convertIrToWireSchema.js\";\nimport
|
|
1
|
+
{"version":3,"file":"irDeployHandler.js","names":["createPlatformClient","PalantirApiError","DocumentTypes","CommanderError","consola","readFileSync","resolve","convertIrToWireSchema","buildPrefixRewriteFetch","DEFAULT_API_PREFIX","resolveIrInput","irDeployHandler","options","irPath","ir","info","latestVersion","JSON","parse","schema","fileSystemType","firstParty","deployFirstParty","name","deployThirdParty","error","parentFolder","osdkClient","baseUrl","Promise","auth","request","parentFolderRid","result","create","preview","success","version","ontologyRid","fetchFn","firstPartyPrefix","undefined","requestBody","createFirstParty","message","errorName","errorCode","details","filter","Boolean","join"],"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, PalantirApiError } from \"@osdk/client\";\nimport type {\n CreateDocumentTypeRequest,\n CreateFirstPartyDocumentTypeRequest,\n FileSystemType,\n} 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 { convertIrToWireSchema } from \"../../utils/ir/convertIrToWireSchema.js\";\nimport { buildPrefixRewriteFetch, DEFAULT_API_PREFIX } from \"../utils/firstPartyPrefix.js\";\nimport { resolveIrInput } from \"./resolveIrInput.js\";\n\ninterface DeployOptions {\n readonly ir: string;\n readonly baseUrl: string;\n readonly auth: string;\n readonly fileSystemType?: FileSystemType;\n readonly firstParty?: boolean;\n /** Required for third-party deploys. */\n readonly parentFolder?: string;\n /** Required for first-party deploys. */\n readonly ontologyRid?: string;\n /** Overrides the API prefix for first-party deploys (e.g. /api/gotham). */\n readonly firstPartyPrefix?: string;\n}\n\nexport async function irDeployHandler(options: DeployOptions): Promise<void> {\n try {\n const irPath = resolve(options.ir);\n consola.info(`Reading schema from: ${irPath}`);\n\n const { ir, latestVersion } = resolveIrInput(\n JSON.parse(readFileSync(irPath, \"utf8\")) as unknown,\n irPath,\n );\n const schema = convertIrToWireSchema(ir);\n const fileSystemType = options.fileSystemType ?? \"ARTIFACTS\";\n\n if (options.firstParty) {\n await deployFirstParty(options, ir.name, schema, latestVersion, fileSystemType);\n } else {\n await deployThirdParty(options, ir.name, schema, fileSystemType);\n }\n } catch (error) {\n if (error instanceof CommanderError) {\n throw error;\n }\n consola.error(\"❌ Error during Deploy:\", error);\n throw new CommanderError(1, \"ERRIRMDEPLOY\", \"Error deploying IR document schema\");\n }\n}\n\ntype DocumentTypeSchema = CreateDocumentTypeRequest[\"schema\"];\n\nasync function deployThirdParty(\n options: DeployOptions,\n name: string,\n schema: DocumentTypeSchema,\n fileSystemType: FileSystemType,\n): Promise<void> {\n if (options.parentFolder == null) {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n \"--parent-folder is required when deploying a third-party document type\",\n );\n }\n\n const osdkClient = createPlatformClient(options.baseUrl, () => Promise.resolve(options.auth));\n\n const request: CreateDocumentTypeRequest = {\n name,\n parentFolderRid: options.parentFolder,\n schema,\n fileSystemType,\n };\n\n consola.info(\"Creating document type with schema\", request);\n const result = await DocumentTypes.create(osdkClient, request, { preview: true });\n consola.success(\"Successfully created document type\", result);\n}\n\nasync function deployFirstParty(\n options: DeployOptions,\n name: string,\n schema: DocumentTypeSchema,\n version: number,\n fileSystemType: FileSystemType,\n): Promise<void> {\n if (options.ontologyRid == null) {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n \"--ontology-rid is required when deploying a first-party document type\",\n );\n }\n\n const fetchFn = options.firstPartyPrefix != null\n ? buildPrefixRewriteFetch(options.firstPartyPrefix)\n : undefined;\n if (fetchFn != null) {\n consola.info(`Rewriting OSDK '${DEFAULT_API_PREFIX}' -> '${options.firstPartyPrefix}'`);\n }\n\n const osdkClient = createPlatformClient(\n options.baseUrl,\n () => Promise.resolve(options.auth),\n undefined,\n fetchFn,\n );\n\n const request: CreateFirstPartyDocumentTypeRequest = {\n requestBody: {\n name,\n ontologyRid: options.ontologyRid,\n schema,\n version,\n fileSystemType,\n },\n };\n\n consola.info(\"Creating first-party document type\", request);\n try {\n const result = await DocumentTypes.createFirstParty(osdkClient, request, { preview: true });\n consola.success(\"Successfully created first-party document type\", result);\n } catch (error) {\n if (error instanceof PalantirApiError) {\n const { message, errorName, errorCode } = error;\n const details = [errorName, errorCode].filter(Boolean).join(\" \");\n consola.error(\n `❌ Error during first-party deploy: ${message}${details ? ` [${details}]` : \"\"}`,\n );\n }\n throw error;\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -75,19 +75,16 @@ export function irGenAssetHandler(options) {
|
|
|
75
75
|
recursive: true
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
writeFileSync(outputPath, JSON.stringify({
|
|
79
79
|
comment: GENERATED_JSON_COMMENT,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
writeFileSync(outputPath, JSON.stringify(output, null, 2), "utf8");
|
|
80
|
+
documentTypeName,
|
|
81
|
+
documentStorageType: {
|
|
82
|
+
type: "yjs",
|
|
83
|
+
schema: wireSchema
|
|
84
|
+
},
|
|
85
|
+
fileSystemType,
|
|
86
|
+
schemaVersion: latestVersion
|
|
87
|
+
}, null, 2), "utf8");
|
|
91
88
|
const compatibilityRangePath = resolve(options.compatibilityRangeOutput ?? deriveCompatibilityRangePath(outputPath));
|
|
92
89
|
const compatibilityRangeDir = dirname(compatibilityRangePath);
|
|
93
90
|
if (!existsSync(compatibilityRangeDir)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"irGenAssetHandler.js","names":["CommanderError","consola","existsSync","mkdirSync","readFileSync","writeFileSync","basename","dirname","extname","join","resolve","GENERATED_JSON_COMMENT","convertIrToWireSchema","resolveIrInput","deriveCompatibilityRangePath","assetOutputPath","stem","irGenAssetHandler","options","irPath","ir","outputPath","output","info","parsed","JSON","parse","resolved","irSchema","latestVersion","minSupportedVersion","name","documentTypeName","wireSchema","fileSystemType","outputDir","recursive","comment","documentStorageType","type","schema","schemaVersion","
|
|
1
|
+
{"version":3,"file":"irGenAssetHandler.js","names":["CommanderError","consola","existsSync","mkdirSync","readFileSync","writeFileSync","basename","dirname","extname","join","resolve","GENERATED_JSON_COMMENT","convertIrToWireSchema","resolveIrInput","deriveCompatibilityRangePath","assetOutputPath","stem","irGenAssetHandler","options","irPath","ir","outputPath","output","info","parsed","JSON","parse","resolved","irSchema","latestVersion","minSupportedVersion","name","documentTypeName","wireSchema","fileSystemType","outputDir","recursive","stringify","comment","documentStorageType","type","schema","schemaVersion","compatibilityRangePath","compatibilityRangeOutput","compatibilityRangeDir","min","max","success","error"],"sources":["irGenAssetHandler.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 { DocumentTypeAsset, FileSystemType } from \"@osdk/foundry.pack\";\nimport { CommanderError } from \"commander\";\nimport { consola } from \"consola\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { basename, dirname, extname, join, resolve } from \"path\";\nimport { GENERATED_JSON_COMMENT } from \"../../utils/generatedFileHeader.js\";\nimport { convertIrToWireSchema } from \"../../utils/ir/convertIrToWireSchema.js\";\nimport { resolveIrInput } from \"./resolveIrInput.js\";\n\ninterface IrGenAssetOptions {\n readonly ir: string;\n readonly output: string;\n readonly fileSystemType?: FileSystemType;\n readonly compatibilityRangeOutput?: string;\n}\n\ninterface SchemaCompatibilityRangeFile {\n readonly min: number;\n readonly max: number;\n}\n\nfunction deriveCompatibilityRangePath(assetOutputPath: string): string {\n const stem = basename(assetOutputPath, extname(assetOutputPath));\n return join(dirname(assetOutputPath), `${stem}-schema-compatibility-range.json`);\n}\n\n/**\n * Generates a document type asset JSON file (and a sibling schema\n * compatibility range JSON file) from an IR schema.\n *\n * The input IR may be either:\n * - a chain payload `{ latestVersion, minSupportedVersion?, chain }` produced\n * by `schema ir`. The latest entry's `ir` is used as the wire schema; the\n * asset's `schemaVersion` is `latestVersion`; the compatibility range is\n * `{ min: minSupportedVersion ?? latestVersion, max: latestVersion }`.\n * - a bare single-version `IRealTimeDocumentSchema` (legacy). The compat\n * range defaults to `{ min: version, max: version }` since no chain\n * information is available.\n *\n * This command is intended for internal platform applications where the\n * document type asset must exist on disk so the platform can discover it and\n * register the document type automatically at deploy time. Most users should\n * use `ir deploy` to register document types via the Foundry API instead.\n *\n * If you are unsure whether you need this command, you almost certainly do not.\n */\nexport function irGenAssetHandler(options: IrGenAssetOptions): void {\n try {\n const irPath = resolve(options.ir);\n const outputPath = resolve(options.output);\n\n if (!existsSync(irPath)) {\n throw new CommanderError(1, \"ENOENT\", `IR file does not exist: ${irPath}`);\n }\n\n consola.info(`Reading IR schema from: ${irPath}`);\n const parsed = JSON.parse(readFileSync(irPath, \"utf8\")) as unknown;\n\n const resolved = resolveIrInput(parsed, irPath);\n\n const { ir: irSchema, latestVersion, minSupportedVersion } = resolved;\n const { name: documentTypeName } = irSchema;\n const wireSchema = convertIrToWireSchema(irSchema);\n\n const fileSystemType = options.fileSystemType ?? \"ARTIFACTS\";\n if (fileSystemType !== \"ARTIFACTS\" && fileSystemType !== \"COMPASS\") {\n throw new CommanderError(\n 1,\n \"EINVAL\",\n `Invalid fileSystemType \"${fileSystemType}\". Must be \"ARTIFACTS\" or \"COMPASS\".`,\n );\n }\n\n const asset: DocumentTypeAsset = {\n comment: GENERATED_JSON_COMMENT,\n documentTypeName,\n documentStorageType: {\n type: \"yjs\",\n schema: wireSchema,\n },\n fileSystemType,\n schemaVersion: latestVersion,\n };\n\n const outputDir = dirname(outputPath);\n if (!existsSync(outputDir)) {\n mkdirSync(outputDir, { recursive: true });\n }\n writeFileSync(outputPath, JSON.stringify(asset, null, 2), \"utf8\");\n\n const compatibilityRange: SchemaCompatibilityRangeFile = {\n min: minSupportedVersion,\n max: latestVersion,\n };\n const compatibilityRangePath = resolve(\n options.compatibilityRangeOutput ?? deriveCompatibilityRangePath(outputPath),\n );\n const compatibilityRangeDir = dirname(compatibilityRangePath);\n if (!existsSync(compatibilityRangeDir)) {\n mkdirSync(compatibilityRangeDir, { recursive: true });\n }\n const compatibilityRangeOutput = {\n comment: GENERATED_JSON_COMMENT,\n ...compatibilityRange,\n };\n writeFileSync(\n compatibilityRangePath,\n JSON.stringify(compatibilityRangeOutput, null, 2),\n \"utf8\",\n );\n\n consola.success(\"Successfully generated document type asset\");\n consola.info(` Output: ${outputPath}`);\n consola.info(` Compatibility range output: ${compatibilityRangePath}`);\n consola.info(` Document type: ${documentTypeName}`);\n consola.info(` Schema version: ${latestVersion}`);\n consola.info(` Compatibility range: [${minSupportedVersion}, ${latestVersion}]`);\n consola.info(` File system type: ${fileSystemType}`);\n } catch (error) {\n if (error instanceof CommanderError) {\n throw error;\n }\n consola.error(\"Error generating document type asset:\", error);\n throw new CommanderError(1, \"IR_ASSET_ERROR\", \"Failed to generate document type asset\");\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
package/build/esm/utils/ir/__tests__/__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.17.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.17.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","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","name","DocumentModel","Event","version"],"sources":["external-refs.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.17.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 },\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;IACX,CAAC;IACDC,IAAI,EAAE;EACR;AACF,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG;EAC3BC,KAAK,EAAER,UAAU;EACjB,CAACF,QAAQ,GAAG;IACVW,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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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.17.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":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// documentType.ts
|
|
3
3
|
// ============================================================
|
|
4
4
|
|
|
5
|
-
/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
5
|
+
/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */
|
|
6
6
|
|
|
7
7
|
export const DOCUMENT_TYPE_NAME = 'Canvas Document Type';
|
|
8
8
|
export const DOCUMENT_TYPE_DESCRIPTION = 'Document type description for demo canvas';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-name-and-description.js","names":["DOCUMENT_TYPE_NAME","DOCUMENT_TYPE_DESCRIPTION"],"sources":["with-name-and-description.ts"],"sourcesContent":["// ============================================================\n// documentType.ts\n// ============================================================\n\n/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"with-name-and-description.js","names":["DOCUMENT_TYPE_NAME","DOCUMENT_TYPE_DESCRIPTION"],"sources":["with-name-and-description.ts"],"sourcesContent":["// ============================================================\n// documentType.ts\n// ============================================================\n\n/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */\n\nexport const DOCUMENT_TYPE_NAME = 'Canvas Document Type';\nexport const DOCUMENT_TYPE_DESCRIPTION =\n 'Document type description for demo canvas';\n"],"mappings":"AAAA;AACA;AACA;;AAEA;;AAEA,OAAO,MAAMA,kBAAkB,GAAG,sBAAsB;AACxD,OAAO,MAAMC,yBAAyB,GACpC,2CAA2C","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"single-version.js","names":[],"sources":["single-version.ts"],"sourcesContent":["// ============================================================\n// versions.ts\n// ============================================================\n\n/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"single-version.js","names":[],"sources":["single-version.ts"],"sourcesContent":["// ============================================================\n// versions.ts\n// ============================================================\n\n/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */\n\nexport type SupportedVersions = 1;\nexport type LatestVersion = 1;\nexport type MinSupportedVersion = 1;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"three-version-chain.js","names":[],"sources":["three-version-chain.ts"],"sourcesContent":["// ============================================================\n// versions.ts\n// ============================================================\n\n/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"three-version-chain.js","names":[],"sources":["three-version-chain.ts"],"sourcesContent":["// ============================================================\n// versions.ts\n// ============================================================\n\n/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */\n\nexport type SupportedVersions = 1 | 2 | 3;\nexport type LatestVersion = 3;\nexport type MinSupportedVersion = 1;\n"],"mappings":"","ignoreList":[]}
|
package/build/esm/utils/schema/__tests__/__snapshots__/generateVersionsFromSchema/two-version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"two-version.js","names":[],"sources":["two-version.ts"],"sourcesContent":["// ============================================================\n// versions.ts\n// ============================================================\n\n/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"two-version.js","names":[],"sources":["two-version.ts"],"sourcesContent":["// ============================================================\n// versions.ts\n// ============================================================\n\n/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */\n\nexport type SupportedVersions = 1 | 2;\nexport type LatestVersion = 2;\nexport type MinSupportedVersion = 1;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { generateIndexFromChain } from "../generateIndexFromSchema.js";
|
|
19
|
+
import { resolveSchemaChain } from "../resolveSchemaChain.js";
|
|
20
|
+
import { singleVersionSchema, unionTypesSchema } from "./fixtures.js";
|
|
21
|
+
describe("generateIndexFromChain", () => {
|
|
22
|
+
it("re-exports union variant type guards as values", () => {
|
|
23
|
+
const result = generateIndexFromChain(resolveSchemaChain(unionTypesSchema));
|
|
24
|
+
|
|
25
|
+
// Guards are exported as values (not `export type`) so consumers can narrow
|
|
26
|
+
// a union at runtime without re-deriving the discriminant check.
|
|
27
|
+
expect(result).toContain(`export { isShape_v1Circle, isShape_v1Rectangle } from "./types_v1.js";`);
|
|
28
|
+
// The variant *types* remain a separate type-only export.
|
|
29
|
+
expect(result).toMatch(/export type \{[^}]*Shape_v1Circle[^}]*\} from "\.\/types_v1\.js";/);
|
|
30
|
+
});
|
|
31
|
+
it("emits no value guard export when the schema has no unions", () => {
|
|
32
|
+
const result = generateIndexFromChain(resolveSchemaChain(singleVersionSchema));
|
|
33
|
+
|
|
34
|
+
// No unions → no `is<Variant>` guards → no value export from types_v1.
|
|
35
|
+
expect(result).not.toMatch(/export \{ is\w+ \} from "\.\/types_v1\.js";/);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=generateIndexFromSchema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateIndexFromSchema.test.js","names":["describe","expect","it","generateIndexFromChain","resolveSchemaChain","singleVersionSchema","unionTypesSchema","result","toContain","toMatch","not"],"sources":["generateIndexFromSchema.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 { generateIndexFromChain } from \"../generateIndexFromSchema.js\";\nimport { resolveSchemaChain } from \"../resolveSchemaChain.js\";\nimport { singleVersionSchema, unionTypesSchema } from \"./fixtures.js\";\n\ndescribe(\"generateIndexFromChain\", () => {\n it(\"re-exports union variant type guards as values\", () => {\n const result = generateIndexFromChain(resolveSchemaChain(unionTypesSchema));\n\n // Guards are exported as values (not `export type`) so consumers can narrow\n // a union at runtime without re-deriving the discriminant check.\n expect(result).toContain(\n `export { isShape_v1Circle, isShape_v1Rectangle } from \"./types_v1.js\";`,\n );\n // The variant *types* remain a separate type-only export.\n expect(result).toMatch(/export type \\{[^}]*Shape_v1Circle[^}]*\\} from \"\\.\\/types_v1\\.js\";/);\n });\n\n it(\"emits no value guard export when the schema has no unions\", () => {\n const result = generateIndexFromChain(resolveSchemaChain(singleVersionSchema));\n\n // No unions → no `is<Variant>` guards → no value export from types_v1.\n expect(result).not.toMatch(/export \\{ is\\w+ \\} from \"\\.\\/types_v1\\.js\";/);\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;AAC7C,SAASC,sBAAsB,QAAQ,+BAA+B;AACtE,SAASC,kBAAkB,QAAQ,0BAA0B;AAC7D,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,eAAe;AAErEN,QAAQ,CAAC,wBAAwB,EAAE,MAAM;EACvCE,EAAE,CAAC,gDAAgD,EAAE,MAAM;IACzD,MAAMK,MAAM,GAAGJ,sBAAsB,CAACC,kBAAkB,CAACE,gBAAgB,CAAC,CAAC;;IAE3E;IACA;IACAL,MAAM,CAACM,MAAM,CAAC,CAACC,SAAS,CACtB,wEACF,CAAC;IACD;IACAP,MAAM,CAACM,MAAM,CAAC,CAACE,OAAO,CAAC,mEAAmE,CAAC;EAC7F,CAAC,CAAC;EAEFP,EAAE,CAAC,2DAA2D,EAAE,MAAM;IACpE,MAAMK,MAAM,GAAGJ,sBAAsB,CAACC,kBAAkB,CAACC,mBAAmB,CAAC,CAAC;;IAE9E;IACAJ,MAAM,CAACM,MAAM,CAAC,CAACG,GAAG,CAACD,OAAO,CAAC,6CAA6C,CAAC;EAC3E,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -32,6 +32,9 @@ import { DOCUMENT_TYPE_PATH, INTERNAL_UPGRADE_FNS_PATH, MODELS_PATH, TYPES_REEXP
|
|
|
32
32
|
* - `DocumentUpgradeFns` type (the typed shape the factory accepts)
|
|
33
33
|
* - Per supported version: explicit named type exports from `types_vN.js`
|
|
34
34
|
* (not star exports, to avoid polluting autocomplete for read-only consumers)
|
|
35
|
+
* - Per supported version: the union variant type guard *functions* from
|
|
36
|
+
* `types_vN.js` as values (e.g. `isFooBar_v1`), so consumers can narrow a
|
|
37
|
+
* union without re-deriving the discriminant check
|
|
35
38
|
*/
|
|
36
39
|
export function generateIndexFromChain(resolved, minSupportedVersion) {
|
|
37
40
|
const {
|
|
@@ -59,22 +62,29 @@ export function generateIndexFromChain(resolved, minSupportedVersion) {
|
|
|
59
62
|
} of chain) {
|
|
60
63
|
if (version < minVersion) continue;
|
|
61
64
|
const typeNames = [];
|
|
65
|
+
// Union variant type guard functions (values, not types).
|
|
66
|
+
const guardNames = [];
|
|
62
67
|
for (const [modelKey, modelDef] of Object.entries(ir.models)) {
|
|
63
68
|
if (modelDef.type === "record") {
|
|
64
69
|
typeNames.push(versionedTypeName(modelKey, version));
|
|
65
70
|
} else if (modelDef.type === "union") {
|
|
66
71
|
typeNames.push(versionedTypeName(modelKey, version));
|
|
67
72
|
|
|
68
|
-
// Union variant types
|
|
73
|
+
// Union variant types and their generated `is<Variant>` guards.
|
|
69
74
|
for (const variantName of Object.keys(modelDef.union.variants)) {
|
|
70
75
|
const formattedVariant = formatVariantName(variantName);
|
|
71
|
-
|
|
76
|
+
const variantTypeName = `${versionedTypeName(modelKey, version)}${formattedVariant}`;
|
|
77
|
+
typeNames.push(variantTypeName);
|
|
78
|
+
guardNames.push(`is${variantTypeName}`);
|
|
72
79
|
}
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
if (typeNames.length > 0) {
|
|
76
83
|
output += `export type { ${typeNames.sort().join(", ")} } from "${typesFilePath(version)}";\n`;
|
|
77
84
|
}
|
|
85
|
+
if (guardNames.length > 0) {
|
|
86
|
+
output += `export { ${guardNames.sort().join(", ")} } from "${typesFilePath(version)}";\n`;
|
|
87
|
+
}
|
|
78
88
|
}
|
|
79
89
|
return output;
|
|
80
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateIndexFromSchema.js","names":["formatVariantName","GENERATED_FILE_HEADER","resolveMinVersion","DOCUMENT_TYPE_PATH","INTERNAL_UPGRADE_FNS_PATH","MODELS_PATH","TYPES_REEXPORT_PATH","typesFilePath","VERSIONED_DOC_REF_PATH","versionedTypeName","VERSIONS_PATH","generateIndexFromChain","resolved","minSupportedVersion","chain","minVersion","output","version","ir","typeNames","modelKey","modelDef","Object","entries","models","type","push","variantName","keys","union","variants","formattedVariant","length","sort","join"],"sources":["generateIndexFromSchema.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 { formatVariantName } from \"../formatVariantName.js\";\nimport { GENERATED_FILE_HEADER } from \"../generatedFileHeader.js\";\nimport type { ResolvedIrChain } from \"./resolveSchemaChain.js\";\nimport { resolveMinVersion } from \"./resolveSchemaChain.js\";\nimport {\n DOCUMENT_TYPE_PATH,\n INTERNAL_UPGRADE_FNS_PATH,\n MODELS_PATH,\n TYPES_REEXPORT_PATH,\n typesFilePath,\n VERSIONED_DOC_REF_PATH,\n versionedTypeName,\n VERSIONS_PATH,\n} from \"./runtimeSchema.js\";\n\n/**\n * Generate the index.ts barrel export from a versioned schema.\n *\n * Exports:\n * - `models.js` (star export — model constants and `DocumentModel`; emitted\n * as a factory function when the schema has derived fields, otherwise a const)\n * - `types.js` (star export — latest-version type aliases)\n * - `versions.js` (star export — SupportedVersions, LatestVersion, MinSupportedVersion)\n * - `versionedDocRef.js` (star export — VersionedDocRef types and factory)\n * - `documentType.js` (star export — DOCUMENT_TYPE_NAME and DOCUMENT_TYPE_DESCRIPTION)\n * - `DocumentUpgradeFns` type (the typed shape the factory accepts)\n * - Per supported version: explicit named type exports from `types_vN.js`\n * (not star exports, to avoid polluting autocomplete for read-only consumers)\n */\nexport function generateIndexFromChain(\n resolved: ResolvedIrChain,\n minSupportedVersion?: number,\n): string {\n const { chain } = resolved;\n const { minVersion } = resolveMinVersion(chain, minSupportedVersion);\n\n let output = GENERATED_FILE_HEADER;\n\n // Star exports for core modules\n output += `export * from \"${MODELS_PATH}\";\\n`;\n output += `export * from \"${TYPES_REEXPORT_PATH}\";\\n`;\n output += `export * from \"${VERSIONS_PATH}\";\\n`;\n output += `export * from \"${VERSIONED_DOC_REF_PATH}\";\\n`;\n output += `export * from \"${DOCUMENT_TYPE_PATH}\";\\n`;\n // The typed upgrade-function table shape. Apps reference this type when\n // constructing the value passed to `DocumentModel(...)`.\n output += `export { type DocumentUpgradeFns } from \"${INTERNAL_UPGRADE_FNS_PATH}\";\\n`;\n\n // Per-version explicit named type exports\n for (const { version, ir } of chain) {\n if (version < minVersion) continue;\n\n const typeNames: string[] = [];\n\n for (const [modelKey, modelDef] of Object.entries(ir.models)) {\n if (modelDef.type === \"record\") {\n typeNames.push(versionedTypeName(modelKey, version));\n } else if (modelDef.type === \"union\") {\n typeNames.push(versionedTypeName(modelKey, version));\n\n // Union variant types
|
|
1
|
+
{"version":3,"file":"generateIndexFromSchema.js","names":["formatVariantName","GENERATED_FILE_HEADER","resolveMinVersion","DOCUMENT_TYPE_PATH","INTERNAL_UPGRADE_FNS_PATH","MODELS_PATH","TYPES_REEXPORT_PATH","typesFilePath","VERSIONED_DOC_REF_PATH","versionedTypeName","VERSIONS_PATH","generateIndexFromChain","resolved","minSupportedVersion","chain","minVersion","output","version","ir","typeNames","guardNames","modelKey","modelDef","Object","entries","models","type","push","variantName","keys","union","variants","formattedVariant","variantTypeName","length","sort","join"],"sources":["generateIndexFromSchema.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 { formatVariantName } from \"../formatVariantName.js\";\nimport { GENERATED_FILE_HEADER } from \"../generatedFileHeader.js\";\nimport type { ResolvedIrChain } from \"./resolveSchemaChain.js\";\nimport { resolveMinVersion } from \"./resolveSchemaChain.js\";\nimport {\n DOCUMENT_TYPE_PATH,\n INTERNAL_UPGRADE_FNS_PATH,\n MODELS_PATH,\n TYPES_REEXPORT_PATH,\n typesFilePath,\n VERSIONED_DOC_REF_PATH,\n versionedTypeName,\n VERSIONS_PATH,\n} from \"./runtimeSchema.js\";\n\n/**\n * Generate the index.ts barrel export from a versioned schema.\n *\n * Exports:\n * - `models.js` (star export — model constants and `DocumentModel`; emitted\n * as a factory function when the schema has derived fields, otherwise a const)\n * - `types.js` (star export — latest-version type aliases)\n * - `versions.js` (star export — SupportedVersions, LatestVersion, MinSupportedVersion)\n * - `versionedDocRef.js` (star export — VersionedDocRef types and factory)\n * - `documentType.js` (star export — DOCUMENT_TYPE_NAME and DOCUMENT_TYPE_DESCRIPTION)\n * - `DocumentUpgradeFns` type (the typed shape the factory accepts)\n * - Per supported version: explicit named type exports from `types_vN.js`\n * (not star exports, to avoid polluting autocomplete for read-only consumers)\n * - Per supported version: the union variant type guard *functions* from\n * `types_vN.js` as values (e.g. `isFooBar_v1`), so consumers can narrow a\n * union without re-deriving the discriminant check\n */\nexport function generateIndexFromChain(\n resolved: ResolvedIrChain,\n minSupportedVersion?: number,\n): string {\n const { chain } = resolved;\n const { minVersion } = resolveMinVersion(chain, minSupportedVersion);\n\n let output = GENERATED_FILE_HEADER;\n\n // Star exports for core modules\n output += `export * from \"${MODELS_PATH}\";\\n`;\n output += `export * from \"${TYPES_REEXPORT_PATH}\";\\n`;\n output += `export * from \"${VERSIONS_PATH}\";\\n`;\n output += `export * from \"${VERSIONED_DOC_REF_PATH}\";\\n`;\n output += `export * from \"${DOCUMENT_TYPE_PATH}\";\\n`;\n // The typed upgrade-function table shape. Apps reference this type when\n // constructing the value passed to `DocumentModel(...)`.\n output += `export { type DocumentUpgradeFns } from \"${INTERNAL_UPGRADE_FNS_PATH}\";\\n`;\n\n // Per-version explicit named type exports\n for (const { version, ir } of chain) {\n if (version < minVersion) continue;\n\n const typeNames: string[] = [];\n // Union variant type guard functions (values, not types).\n const guardNames: string[] = [];\n\n for (const [modelKey, modelDef] of Object.entries(ir.models)) {\n if (modelDef.type === \"record\") {\n typeNames.push(versionedTypeName(modelKey, version));\n } else if (modelDef.type === \"union\") {\n typeNames.push(versionedTypeName(modelKey, version));\n\n // Union variant types and their generated `is<Variant>` guards.\n for (const variantName of Object.keys(modelDef.union.variants)) {\n const formattedVariant = formatVariantName(variantName);\n const variantTypeName = `${versionedTypeName(modelKey, version)}${formattedVariant}`;\n typeNames.push(variantTypeName);\n guardNames.push(`is${variantTypeName}`);\n }\n }\n }\n\n if (typeNames.length > 0) {\n output += `export type { ${typeNames.sort().join(\", \")} } from \"${\n typesFilePath(version)\n }\";\\n`;\n }\n\n if (guardNames.length > 0) {\n output += `export { ${guardNames.sort().join(\", \")} } from \"${typesFilePath(version)}\";\\n`;\n }\n }\n\n return output;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,iBAAiB,QAAQ,yBAAyB;AAC3D,SAASC,qBAAqB,QAAQ,2BAA2B;AAEjE,SAASC,iBAAiB,QAAQ,yBAAyB;AAC3D,SACEC,kBAAkB,EAClBC,yBAAyB,EACzBC,WAAW,EACXC,mBAAmB,EACnBC,aAAa,EACbC,sBAAsB,EACtBC,iBAAiB,EACjBC,aAAa,QACR,oBAAoB;;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCC,QAAyB,EACzBC,mBAA4B,EACpB;EACR,MAAM;IAAEC;EAAM,CAAC,GAAGF,QAAQ;EAC1B,MAAM;IAAEG;EAAW,CAAC,GAAGb,iBAAiB,CAACY,KAAK,EAAED,mBAAmB,CAAC;EAEpE,IAAIG,MAAM,GAAGf,qBAAqB;;EAElC;EACAe,MAAM,IAAI,kBAAkBX,WAAW,MAAM;EAC7CW,MAAM,IAAI,kBAAkBV,mBAAmB,MAAM;EACrDU,MAAM,IAAI,kBAAkBN,aAAa,MAAM;EAC/CM,MAAM,IAAI,kBAAkBR,sBAAsB,MAAM;EACxDQ,MAAM,IAAI,kBAAkBb,kBAAkB,MAAM;EACpD;EACA;EACAa,MAAM,IAAI,4CAA4CZ,yBAAyB,MAAM;;EAErF;EACA,KAAK,MAAM;IAAEa,OAAO;IAAEC;EAAG,CAAC,IAAIJ,KAAK,EAAE;IACnC,IAAIG,OAAO,GAAGF,UAAU,EAAE;IAE1B,MAAMI,SAAmB,GAAG,EAAE;IAC9B;IACA,MAAMC,UAAoB,GAAG,EAAE;IAE/B,KAAK,MAAM,CAACC,QAAQ,EAAEC,QAAQ,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACN,EAAE,CAACO,MAAM,CAAC,EAAE;MAC5D,IAAIH,QAAQ,CAACI,IAAI,KAAK,QAAQ,EAAE;QAC9BP,SAAS,CAACQ,IAAI,CAAClB,iBAAiB,CAACY,QAAQ,EAAEJ,OAAO,CAAC,CAAC;MACtD,CAAC,MAAM,IAAIK,QAAQ,CAACI,IAAI,KAAK,OAAO,EAAE;QACpCP,SAAS,CAACQ,IAAI,CAAClB,iBAAiB,CAACY,QAAQ,EAAEJ,OAAO,CAAC,CAAC;;QAEpD;QACA,KAAK,MAAMW,WAAW,IAAIL,MAAM,CAACM,IAAI,CAACP,QAAQ,CAACQ,KAAK,CAACC,QAAQ,CAAC,EAAE;UAC9D,MAAMC,gBAAgB,GAAGhC,iBAAiB,CAAC4B,WAAW,CAAC;UACvD,MAAMK,eAAe,GAAG,GAAGxB,iBAAiB,CAACY,QAAQ,EAAEJ,OAAO,CAAC,GAAGe,gBAAgB,EAAE;UACpFb,SAAS,CAACQ,IAAI,CAACM,eAAe,CAAC;UAC/Bb,UAAU,CAACO,IAAI,CAAC,KAAKM,eAAe,EAAE,CAAC;QACzC;MACF;IACF;IAEA,IAAId,SAAS,CAACe,MAAM,GAAG,CAAC,EAAE;MACxBlB,MAAM,IAAI,iBAAiBG,SAAS,CAACgB,IAAI,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,YACpD7B,aAAa,CAACU,OAAO,CAAC,MAClB;IACR;IAEA,IAAIG,UAAU,CAACc,MAAM,GAAG,CAAC,EAAE;MACzBlB,MAAM,IAAI,YAAYI,UAAU,CAACe,IAAI,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,YAAY7B,aAAa,CAACU,OAAO,CAAC,MAAM;IAC5F;EACF;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrayFields.js","names":[],"sources":["arrayFields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"arrayFields.js","names":[],"sources":["arrayFields.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */\n\n\nexport interface Container {\n readonly items: readonly string[];\n readonly numbers: readonly number[];\n}\n\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customDiscriminant.js","names":["isAnimalCat","value","kind","isAnimalDog"],"sources":["customDiscriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"customDiscriminant.js","names":["isAnimalCat","value","kind","isAnimalDog"],"sources":["customDiscriminant.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */\n\n\n/**\n * A cat\n */\nexport interface Cat {\n readonly meow: string;\n readonly whiskers: number;\n}\n\n/**\n * A dog\n */\nexport interface Dog {\n readonly bark: string;\n readonly tailWags: number;\n}\n\nexport interface AnimalCat extends Cat {\n readonly kind: \"cat\";\n}\n\nexport interface AnimalDog extends Dog {\n readonly kind: \"dog\";\n}\n\nexport type Animal = AnimalCat | AnimalDog;\n\nexport function isAnimalCat(value: Animal): value is AnimalCat {\n return value.kind === \"cat\";\n}\n\nexport function isAnimalDog(value: Animal): value is AnimalDog {\n return value.kind === \"dog\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAgBA,OAAO,SAASA,WAAWA,CAACC,KAAa,EAAsB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,KAAK;AAC7B;AAEA,OAAO,SAASC,WAAWA,CAACF,KAAa,EAAsB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,KAAK;AAC7B","ignoreList":[]}
|
package/build/esm/utils/steps/__tests__/__snapshots__/types/generateTypeScriptInterfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateTypeScriptInterfaces.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["generateTypeScriptInterfaces.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"generateTypeScriptInterfaces.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["generateTypeScriptInterfaces.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */\n\n\n/**\n * Represents an edge in a graph\n */\nexport interface Edge {\n readonly source: ObjectNode;\n readonly target: ObjectNode;\n}\n\nexport interface ObjectNode {\n readonly x: number;\n readonly y: number;\n readonly label?: string;\n readonly color?: string;\n}\n\n/**\n * Represents a text box in a graph\n */\nexport interface TextBox {\n readonly x: number;\n readonly y: number;\n readonly text: string;\n}\n\nexport interface NodeObject extends ObjectNode {\n readonly type: \"object\";\n}\n\nexport interface NodeTextBox extends TextBox {\n readonly type: \"text-box\";\n}\n\nexport type Node = NodeObject | NodeTextBox;\n\nexport function isNodeObject(value: Node): value is NodeObject {\n return value.type === \"object\";\n}\n\nexport function isNodeTextBox(value: Node): value is NodeTextBox {\n return value.type === \"text-box\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAiBA,OAAO,SAASA,YAAYA,CAACC,KAAW,EAAuB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ;AAChC;AAEA,OAAO,SAASC,aAAaA,CAACF,KAAW,EAAwB;EAC/D,OAAOA,KAAK,CAACC,IAAI,KAAK,UAAU;AAClC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refTypes.js","names":[],"sources":["refTypes.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"refTypes.js","names":[],"sources":["refTypes.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */\n\nimport type { DocumentRef, MediaRef, ObjectRef, UserRef } from \"@palantir/pack.document-schema.model-types\";\n\n/**\n * A record containing all reference types\n */\nexport interface Document {\n readonly id: string;\n readonly docRef: DocumentRef;\n readonly userRef: UserRef;\n readonly objectRef: ObjectRef;\n readonly mediaRef: MediaRef;\n readonly optionalDocRef?: DocumentRef;\n readonly docRefArray: readonly DocumentRef[];\n readonly userRefArray: readonly UserRef[];\n}\n\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleRecord.js","names":[],"sources":["simpleRecord.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"simpleRecord.js","names":[],"sources":["simpleRecord.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */\n\n\n/**\n * A person record\n */\nexport interface Person {\n readonly name: string;\n readonly age: number;\n readonly email?: string;\n}\n\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simpleSteps.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["simpleSteps.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.
|
|
1
|
+
{"version":3,"file":"simpleSteps.js","names":["isNodeObject","value","type","isNodeTextBox"],"sources":["simpleSteps.ts"],"sourcesContent":["/* Generated by @palantir/pack.document-schema.type-gen@0.17.0 */\n\n\n/**\n * A node in the graph\n */\nexport interface ObjectNode {\n readonly x: number;\n readonly y: number;\n readonly object: string;\n readonly label?: string;\n readonly edges: readonly Edge[];\n}\n\n/**\n * A text box in the graph\n */\nexport interface TextBox {\n readonly x: number;\n readonly y: number;\n readonly text: string;\n}\n\n/**\n * An edge in the graph\n */\nexport interface Edge {\n readonly source: ObjectNode;\n readonly target: ObjectNode;\n}\n\nexport interface NodeObject extends ObjectNode {\n readonly type: \"object\";\n}\n\nexport interface NodeTextBox extends TextBox {\n readonly type: \"textBox\";\n}\n\nexport type Node = NodeObject | NodeTextBox;\n\nexport function isNodeObject(value: Node): value is NodeObject {\n return value.type === \"object\";\n}\n\nexport function isNodeTextBox(value: Node): value is NodeTextBox {\n return value.type === \"textBox\";\n}\n\n"],"mappings":"AAAA;;AAGA;AACA;AACA;;AASA;AACA;AACA;;AAOA;AACA;AACA;;AAgBA,OAAO,SAASA,YAAYA,CAACC,KAAW,EAAuB;EAC7D,OAAOA,KAAK,CAACC,IAAI,KAAK,QAAQ;AAChC;AAEA,OAAO,SAASC,aAAaA,CAACF,KAAW,EAAwB;EAC/D,OAAOA,KAAK,CAACC,IAAI,KAAK,SAAS;AACjC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"irDeployHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irDeployHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"irDeployHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irDeployHandler.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,oBAAoB,CAAC;AAU5B,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,wCAAwC;IACxC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,wCAAwC;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"irGenAssetHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irGenAssetHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"irGenAssetHandler.d.ts","sourceRoot":"","sources":["../../../../src/commands/ir/irGenAssetHandler.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAqB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAS5E,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CAC5C;AAYD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CA+ElE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateIndexFromSchema.test.d.ts","sourceRoot":"","sources":["../../../../../src/utils/schema/__tests__/generateIndexFromSchema.test.ts"],"names":[],"mappings":""}
|
|
@@ -12,6 +12,9 @@ import type { ResolvedIrChain } from "./resolveSchemaChain.js";
|
|
|
12
12
|
* - `DocumentUpgradeFns` type (the typed shape the factory accepts)
|
|
13
13
|
* - Per supported version: explicit named type exports from `types_vN.js`
|
|
14
14
|
* (not star exports, to avoid polluting autocomplete for read-only consumers)
|
|
15
|
+
* - Per supported version: the union variant type guard *functions* from
|
|
16
|
+
* `types_vN.js` as values (e.g. `isFooBar_v1`), so consumers can narrow a
|
|
17
|
+
* union without re-deriving the discriminant check
|
|
15
18
|
*/
|
|
16
19
|
export declare function generateIndexFromChain(resolved: ResolvedIrChain, minSupportedVersion?: number): string;
|
|
17
20
|
//# sourceMappingURL=generateIndexFromSchema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateIndexFromSchema.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/generateIndexFromSchema.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAa/D
|
|
1
|
+
{"version":3,"file":"generateIndexFromSchema.d.ts","sourceRoot":"","sources":["../../../../src/utils/schema/generateIndexFromSchema.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAa/D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,mBAAmB,CAAC,EAAE,MAAM,GAC3B,MAAM,CAoDR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@palantir/pack.document-schema.type-gen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "TypeScript type generation from document schema",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@osdk/client": "^2.5.2",
|
|
21
|
-
"@osdk/foundry.pack": "^2.
|
|
21
|
+
"@osdk/foundry.pack": "^2.66.0",
|
|
22
22
|
"commander": "^14.0.0",
|
|
23
23
|
"conjure-client": "^2.15.0",
|
|
24
24
|
"consola": "^3.4.2",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"tiny-invariant": "^1.3.3",
|
|
28
28
|
"yaml": "^2.8.2",
|
|
29
29
|
"zod": "^4.1.13",
|
|
30
|
-
"@palantir/pack.document-schema.model-types": "~0.
|
|
30
|
+
"@palantir/pack.document-schema.model-types": "~0.15.0",
|
|
31
31
|
"@palantir/pack.schema": "0.10.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["types.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 { DocumentTypeSchema } from \"@osdk/foundry.pack\";\n\nexport type FileSystemType = \"ARTIFACTS\" | \"COMPASS\";\n\nexport interface DocumentTypeAsset {\n readonly documentTypeName: string;\n readonly documentStorageType: {\n readonly type: \"yjs\";\n readonly schema: DocumentTypeSchema;\n };\n readonly fileSystemType: FileSystemType;\n readonly schemaVersion: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { DocumentTypeSchema } from "@osdk/foundry.pack";
|
|
2
|
-
export type FileSystemType = "ARTIFACTS" | "COMPASS";
|
|
3
|
-
export interface DocumentTypeAsset {
|
|
4
|
-
readonly documentTypeName: string;
|
|
5
|
-
readonly documentStorageType: {
|
|
6
|
-
readonly type: "yjs";
|
|
7
|
-
readonly schema: DocumentTypeSchema;
|
|
8
|
-
};
|
|
9
|
-
readonly fileSystemType: FileSystemType;
|
|
10
|
-
readonly schemaVersion: number;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/types.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,SAAS,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,mBAAmB,EAAE;QAC5B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;QACrB,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;KACrC,CAAC;IACF,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC"}
|