@osdk/seed-helpers 0.26.0 → 0.27.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/CHANGELOG.md +6 -0
- package/build/browser/SeedBuilder.js +1 -1
- package/build/browser/SeedBuilder.js.map +1 -1
- package/build/cjs/index.cjs +1 -1
- package/build/cjs/index.cjs.map +1 -1
- package/build/esm/SeedBuilder.js +1 -1
- package/build/esm/SeedBuilder.js.map +1 -1
- package/build/types/SeedBuilder.d.ts.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @osdk/seed-helpers
|
|
2
2
|
|
|
3
|
+
## 0.27.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fb5b752: Reduce `@osdk/seed-compiler` to merging. Seed files are fed through a single `SeedBuilder` from `@osdk/seed-helpers`, which already validates objects, rejects duplicate primary keys, and deduplicates links — so the compiler's own wire-type tables and validator are gone, along with the `mergeSeedOutputs`, `validateSeedOutput`, and `schemaFromMetadata` exports. `compileSeedData` is the only remaining export and now takes `OntologyFullMetadata` in place of a `SchemaMap`. Sharing one builder lets a link reference objects from another seed file, and primary-key conflicts name the file that introduced them. Seed files may default-export either the `createSeed(...)` result (`{ output, context }`) or its `.output`; anything else is rejected with a message naming what was found instead. `SeedBuilder` now names the object type in its not-in-metadata error.
|
|
8
|
+
|
|
3
9
|
## 0.26.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -51,7 +51,7 @@ export class SeedBuilder {
|
|
|
51
51
|
*/
|
|
52
52
|
#objectType(apiName) {
|
|
53
53
|
const full = this.#metadata.objectTypes[apiName];
|
|
54
|
-
!full ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
54
|
+
!full ? process.env.NODE_ENV !== "production" ? invariant(false, () => `Object type '${apiName}' is not defined in the ontology`) : invariant(false) : void 0;
|
|
55
55
|
return full.objectType;
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SeedBuilder.js","names":["createObjectSpecifierFromPrimaryKey","consola","invariant","validateSeedObject","linkIdentity","source","apiName","target","$apiName","String","$primaryKey","join","SeedBuilder","metadata","objectMap","links","constructor","Map","objectType","Object","values","objectTypes","hasOwn","properties","primaryKey","process","env","NODE_ENV","reset","#reset","#objectType","full","addAll","seed","objectEntries","entries","objects","flatMap","map","o","object","create","type","linkEntries","link","sourceRef","ref","sourceObjectType","sourceKey","targetRef","targetObjectType","targetKey","recordLink","linkType","set","#ref","props","getObjectTypeMap","get","base","$objectSpecifier","$objectType","$title","titleProperty","freeze","has","primaryKeyValue","stringPrimaryKeyValue","update","currentValue","warn","merged","delete","targets","Array","isArray","t","#recordLink","unlink","removed","build","nextEntry","next","done","objectTypeApiName","value","nextObjectEntry","push","nextLink","key","name","#getObjectTypeMap","createSeedWithMetadata","ontologyMetadata","fn","sb","context","output"],"sources":["SeedBuilder.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectTypeDefinition,\n OsdkBase,\n PrimaryKeyType,\n LinkTypeApiNamesFor,\n} from \"@osdk/api\";\nimport { createObjectSpecifierFromPrimaryKey } from \"@osdk/client\";\nimport type * as Ontology from \"@osdk/foundry.ontologies\";\nimport { consola } from \"consola\";\nimport invariant from \"tiny-invariant\";\n\nimport type { LinkTargets } from \"./linkTypes.js\";\nimport type { SeedOutput, SeedProps, SeedRef } from \"./types.js\";\nimport { validateSeedObject } from \"./validation.js\";\n\nexport type SeedFunction<T> = (seed: SeedBuilder) => T;\n\ninterface SeedLinkRecord {\n source: SeedRef<ObjectTypeDefinition>;\n apiName: string;\n target: SeedRef<ObjectTypeDefinition>;\n}\n\nfunction linkIdentity(\n source: SeedRef<ObjectTypeDefinition>,\n apiName: string,\n target: SeedRef<ObjectTypeDefinition>,\n): string {\n return [\n source.$apiName,\n String(source.$primaryKey),\n apiName,\n target.$apiName,\n String(target.$primaryKey),\n ].join(\":\");\n}\n\nexport class SeedBuilder {\n #metadata: Ontology.OntologyFullMetadata;\n #objectMap: Map<string, Map<string, SeedProps<ObjectTypeDefinition>>>;\n #links: Map<string, SeedLinkRecord>;\n\n /**\n * Creates a seed builder backed by the given ontology metadata.\n * @param metadata Ontology full metadata describing the object types\n */\n constructor(metadata: Ontology.OntologyFullMetadata) {\n this.#metadata = metadata;\n this.#objectMap = new Map();\n this.#links = new Map();\n for (const { objectType } of Object.values(metadata.objectTypes)) {\n invariant(\n Object.hasOwn(objectType.properties, objectType.primaryKey),\n `[${objectType.apiName}] Primary key '${objectType.primaryKey}' is not among the object's properties`,\n );\n }\n }\n\n #reset() {\n this.#objectMap = new Map();\n this.#links = new Map();\n }\n\n /**\n * Resolves the object type metadata for `apiName`.\n * @throws if the object type is not present in the metadata\n */\n #objectType(apiName: string): Ontology.ObjectTypeV2 {\n const full = this.#metadata.objectTypes[apiName];\n invariant(full, \"Object not found in metadata\");\n return full.objectType;\n }\n\n /**\n * Merges an existing seed output. Must match the metadata supplied at construction.\n * @param seed Seed output to derive from\n */\n addAll(seed: SeedOutput): void {\n const objectEntries = Object.entries(seed.objects).flatMap(\n ([apiName, objects]) => objects.map((o) => [apiName, o] as const),\n );\n for (const [apiName, object] of objectEntries) {\n this.create(\n {\n type: \"object\",\n apiName,\n },\n object,\n );\n }\n const linkEntries = seed.links;\n for (const link of linkEntries) {\n const sourceRef = this.#ref(\n {\n type: \"object\",\n apiName: link.sourceObjectType,\n },\n link.sourceKey,\n );\n const targetRef = this.#ref(\n {\n type: \"object\",\n apiName: link.targetObjectType,\n },\n link.targetKey,\n );\n this.#recordLink(sourceRef, link.linkType, targetRef);\n }\n }\n\n /**\n * Set the current state to the provided seed.\n * @param seed Seed output to reset to. Resets the seed builder if undefined.\n */\n set(seed?: SeedOutput): void {\n this.#reset();\n if (typeof seed !== \"undefined\") {\n this.addAll(seed);\n }\n }\n\n /**\n * Returns a SeedRef<Q> regardless of the existence of the object.\n * @param o Object Type\n * @param primaryKey\n * @returns SeedRef<Q>\n */\n #ref<Q extends ObjectTypeDefinition>(\n o: Q,\n primaryKey: PrimaryKeyType<Q>,\n ): SeedRef<Q> {\n const objectType = this.#objectType(o.apiName);\n const props = this.#getObjectTypeMap(o.apiName).get(String(primaryKey)) as\n | SeedProps<Q>\n | undefined;\n const base: OsdkBase<Q> = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKey),\n $objectType: o.apiName,\n $primaryKey: primaryKey,\n $title: props?.[objectType.titleProperty as keyof typeof props],\n };\n return Object.freeze({\n ...base,\n ...props,\n }) as SeedRef<Q>;\n }\n\n /**\n * Returns a reference to a previously created object, or `undefined` if none exists.\n * @param o Object type definition\n * @param primaryKey Primary key value of the object\n * @returns Reference to the object, or `undefined` if not found\n */\n ref<Q extends ObjectTypeDefinition>(\n o: Q,\n primaryKey: PrimaryKeyType<Q>,\n ): SeedRef<Q> | undefined {\n if (!this.#getObjectTypeMap(o.apiName).has(String(primaryKey))) {\n return;\n }\n return this.#ref(o, primaryKey);\n }\n\n /**\n * Creates an object of the given type, returning a reference to it.\n * @param o Object type definition\n * @param props Object properties, including its primary key\n * @returns Reference to the created object\n */\n create<Q extends ObjectTypeDefinition>(\n o: Q,\n props: SeedProps<Q>,\n ): SeedRef<Q> {\n const objectType = this.#objectType(o.apiName);\n const primaryKeyValue = props[\n objectType.primaryKey as keyof typeof props\n ] as PrimaryKeyType<Q>;\n const stringPrimaryKeyValue = String(primaryKeyValue);\n invariant(\n !this.#getObjectTypeMap(o.apiName).has(stringPrimaryKeyValue),\n `${o.apiName} with primary key ${stringPrimaryKeyValue} already exists.`,\n );\n validateSeedObject(props as Record<string, unknown>, objectType);\n this.#getObjectTypeMap(o.apiName).set(stringPrimaryKeyValue, props);\n const base: OsdkBase<Q> = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKeyValue),\n $objectType: o.apiName,\n $primaryKey: primaryKeyValue,\n $title: props[objectType.titleProperty as keyof typeof props],\n };\n return Object.freeze({\n ...base,\n ...props,\n }) as SeedRef<Q>;\n }\n\n /**\n * Merges the given props into the referenced object, keeping its primary key.\n * Properties not included in `props` are left unchanged; if the object does\n * not yet exist it is created from `props`.\n * @param ref Reference to the object to update\n * @param props Partial object properties to merge in, excluding the primary key\n * @returns The same reference passed in\n */\n update<Q extends ObjectTypeDefinition>(\n ref: SeedRef<Q>,\n props: Partial<\n Omit<SeedProps<Q>, Exclude<Q[\"primaryKeyApiName\"], undefined>>\n >,\n ): SeedRef<Q> {\n const { $apiName, $primaryKey } = ref;\n const objectType = this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n const currentValue = this.#getObjectTypeMap($apiName).get(\n stringPrimaryKeyValue,\n );\n if (!currentValue) {\n consola.warn(\n `Updating ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will create the object regardless.`,\n );\n }\n invariant(\n typeof props[objectType.primaryKey as keyof typeof props] === \"undefined\",\n `Cannot modify primary key ${objectType.primaryKey}`,\n );\n const merged = {\n ...currentValue,\n ...props,\n [objectType.primaryKey]: $primaryKey,\n };\n validateSeedObject(merged as Record<string, unknown>, objectType);\n this.#getObjectTypeMap($apiName).set(stringPrimaryKeyValue, merged);\n return ref;\n }\n\n /**\n * Removes the referenced object from the seed.\n * @param ref Reference to the object to delete\n */\n delete<Q extends ObjectTypeDefinition>(ref: SeedRef<Q>): void {\n const { $apiName, $primaryKey } = ref;\n this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n if (!this.#getObjectTypeMap($apiName).delete(stringPrimaryKeyValue)) {\n consola.warn(\n `Deleting ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will be a no-op.`,\n );\n return;\n }\n }\n\n /**\n * Links the source object to one or more targets via the given link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n link<Q extends ObjectTypeDefinition, A extends LinkTypeApiNamesFor<Q>>(\n source: SeedRef<Q>,\n apiName: A,\n target: LinkTargets<Q, A>,\n ): void {\n const targets = (Array.isArray(target) ? target : [target]) as Array<\n SeedRef<ObjectTypeDefinition>\n >;\n for (const t of targets) {\n this.#recordLink(source, apiName, t);\n }\n }\n\n #recordLink(\n source: SeedRef<ObjectTypeDefinition>,\n apiName: string,\n target: SeedRef<ObjectTypeDefinition>,\n ): void {\n this.#links.set(linkIdentity(source, apiName, target), {\n source,\n apiName,\n target,\n });\n }\n\n /**\n * Removes links from the source object to the given targets via the link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n unlink<Q extends ObjectTypeDefinition, A extends LinkTypeApiNamesFor<Q>>(\n source: SeedRef<Q>,\n apiName: A,\n target: LinkTargets<Q, A>,\n ): void {\n const targets = (Array.isArray(target) ? target : [target]) as Array<\n SeedRef<ObjectTypeDefinition>\n >;\n let removed = 0;\n for (const t of targets) {\n if (this.#links.delete(linkIdentity(source, apiName, t))) {\n removed++;\n }\n }\n if (removed === 0) {\n consola.warn(\n `Unlinking ${source.$apiName} with primary key ${String(\n source.$primaryKey,\n )} via '${apiName}' which matches no existing links. This will be a no-op.`,\n );\n }\n }\n\n /**\n * Validates the accumulated objects and links and returns the seed output.\n * @returns The built seed output\n */\n build(): SeedOutput {\n const objects: SeedOutput[\"objects\"] = {};\n const entries = this.#objectMap.entries();\n let nextEntry = entries.next();\n while (!nextEntry.done) {\n const objectTypeApiName = nextEntry.value[0];\n objects[objectTypeApiName] = [];\n const objectMap = nextEntry.value[1];\n const objectEntries = objectMap.entries();\n let nextObjectEntry = objectEntries.next();\n while (!nextObjectEntry.done) {\n objects[objectTypeApiName].push(nextObjectEntry.value[1]);\n nextObjectEntry = objectEntries.next();\n }\n nextEntry = entries.next();\n }\n const links: SeedOutput[\"links\"] = [];\n const linkEntries = this.#links.entries();\n let nextLink = linkEntries.next();\n while (!nextLink.done) {\n const [key, value] = nextLink.value;\n links.push({\n name: key,\n sourceObjectType: value.source.$apiName,\n sourceKey: String(value.source.$primaryKey),\n linkType: value.apiName,\n targetObjectType: value.target.$apiName,\n targetKey: String(value.target.$primaryKey),\n });\n nextLink = linkEntries.next();\n }\n return { objects, links } as SeedOutput;\n }\n\n #getObjectTypeMap(\n objectTypeApiName: string,\n ): Map<string, SeedProps<ObjectTypeDefinition>> {\n if (!this.#objectMap.has(objectTypeApiName)) {\n this.#objectMap.set(objectTypeApiName, new Map());\n }\n return this.#objectMap.get(objectTypeApiName)!;\n }\n}\n\n/**\n * Utility handle for building seeds from a metadata\n * @param ontologyMetadata Ontology metadata to instantiate seed builder from\n * @param fn handle to create seeds, may return an arbitrary value\n * @returns Tuple of [SeedOutput, T]: Seed output and arbitrary value returned from fn\n */\nexport function createSeedWithMetadata<T>(\n ontologyMetadata: Ontology.OntologyFullMetadata,\n fn: SeedFunction<T>,\n): {\n output: SeedOutput;\n context: T;\n} {\n const sb = new SeedBuilder(ontologyMetadata);\n const context = fn(sb);\n return {\n output: sb.build(),\n context,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,mCAAmC,QAAQ,cAAc;AAElE,SAASC,OAAO,QAAQ,SAAS;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AAItC,SAASC,kBAAkB,QAAQ,iBAAiB;AAUpD,SAASC,YAAYA,CACnBC,MAAqC,EACrCC,OAAe,EACfC,MAAqC,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CAAC;EAC3B;EAEA,CAAC0C,gBAAgBkC,CACfP,iBAAyB,EACqB;IAC9C,IAAI,CAAC,IAAI,CAAC,CAACtE,SAAS,CAACmD,GAAG,CAACmB,iBAAiB,CAAC,EAAE;MAC3C,IAAI,CAAC,CAACtE,SAAS,CAACwC,GAAG,CAAC8B,iBAAiB,EAAE,IAAInE,GAAG,CAAC,CAAC,CAAC;IACnD;IACA,OAAO,IAAI,CAAC,CAACH,SAAS,CAAC4C,GAAG,CAAC0B,iBAAiB,CAAC;EAC/C;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,sBAAsBA,CACpCC,gBAA+C,EAC/CC,EAAmB,EAInB;EACA,MAAMC,EAAE,GAAG,IAAInF,WAAW,CAACiF,gBAAgB,CAAC;EAC5C,MAAMG,OAAO,GAAGF,EAAE,CAACC,EAAE,CAAC;EACtB,OAAO;IACLE,MAAM,EAAEF,EAAE,CAACf,KAAK,CAAC,CAAC;IAClBgB;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SeedBuilder.js","names":["createObjectSpecifierFromPrimaryKey","consola","invariant","validateSeedObject","linkIdentity","source","apiName","target","$apiName","String","$primaryKey","join","SeedBuilder","metadata","objectMap","links","constructor","Map","objectType","Object","values","objectTypes","hasOwn","properties","primaryKey","process","env","NODE_ENV","reset","#reset","#objectType","full","addAll","seed","objectEntries","entries","objects","flatMap","map","o","object","create","type","linkEntries","link","sourceRef","ref","sourceObjectType","sourceKey","targetRef","targetObjectType","targetKey","recordLink","linkType","set","#ref","props","getObjectTypeMap","get","base","$objectSpecifier","$objectType","$title","titleProperty","freeze","has","primaryKeyValue","stringPrimaryKeyValue","update","currentValue","warn","merged","delete","targets","Array","isArray","t","#recordLink","unlink","removed","build","nextEntry","next","done","objectTypeApiName","value","nextObjectEntry","push","nextLink","key","name","#getObjectTypeMap","createSeedWithMetadata","ontologyMetadata","fn","sb","context","output"],"sources":["SeedBuilder.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectTypeDefinition,\n OsdkBase,\n PrimaryKeyType,\n LinkTypeApiNamesFor,\n} from \"@osdk/api\";\nimport { createObjectSpecifierFromPrimaryKey } from \"@osdk/client\";\nimport type * as Ontology from \"@osdk/foundry.ontologies\";\nimport { consola } from \"consola\";\nimport invariant from \"tiny-invariant\";\n\nimport type { LinkTargets } from \"./linkTypes.js\";\nimport type { SeedOutput, SeedProps, SeedRef } from \"./types.js\";\nimport { validateSeedObject } from \"./validation.js\";\n\nexport type SeedFunction<T> = (seed: SeedBuilder) => T;\n\ninterface SeedLinkRecord {\n source: SeedRef<ObjectTypeDefinition>;\n apiName: string;\n target: SeedRef<ObjectTypeDefinition>;\n}\n\nfunction linkIdentity(\n source: SeedRef<ObjectTypeDefinition>,\n apiName: string,\n target: SeedRef<ObjectTypeDefinition>,\n): string {\n return [\n source.$apiName,\n String(source.$primaryKey),\n apiName,\n target.$apiName,\n String(target.$primaryKey),\n ].join(\":\");\n}\n\nexport class SeedBuilder {\n #metadata: Ontology.OntologyFullMetadata;\n #objectMap: Map<string, Map<string, SeedProps<ObjectTypeDefinition>>>;\n #links: Map<string, SeedLinkRecord>;\n\n /**\n * Creates a seed builder backed by the given ontology metadata.\n * @param metadata Ontology full metadata describing the object types\n */\n constructor(metadata: Ontology.OntologyFullMetadata) {\n this.#metadata = metadata;\n this.#objectMap = new Map();\n this.#links = new Map();\n for (const { objectType } of Object.values(metadata.objectTypes)) {\n invariant(\n Object.hasOwn(objectType.properties, objectType.primaryKey),\n `[${objectType.apiName}] Primary key '${objectType.primaryKey}' is not among the object's properties`,\n );\n }\n }\n\n #reset() {\n this.#objectMap = new Map();\n this.#links = new Map();\n }\n\n /**\n * Resolves the object type metadata for `apiName`.\n * @throws if the object type is not present in the metadata\n */\n #objectType(apiName: string): Ontology.ObjectTypeV2 {\n const full = this.#metadata.objectTypes[apiName];\n invariant(\n full,\n () => `Object type '${apiName}' is not defined in the ontology`,\n );\n return full.objectType;\n }\n\n /**\n * Merges an existing seed output. Must match the metadata supplied at construction.\n * @param seed Seed output to derive from\n */\n addAll(seed: SeedOutput): void {\n const objectEntries = Object.entries(seed.objects).flatMap(\n ([apiName, objects]) => objects.map((o) => [apiName, o] as const),\n );\n for (const [apiName, object] of objectEntries) {\n this.create(\n {\n type: \"object\",\n apiName,\n },\n object,\n );\n }\n const linkEntries = seed.links;\n for (const link of linkEntries) {\n const sourceRef = this.#ref(\n {\n type: \"object\",\n apiName: link.sourceObjectType,\n },\n link.sourceKey,\n );\n const targetRef = this.#ref(\n {\n type: \"object\",\n apiName: link.targetObjectType,\n },\n link.targetKey,\n );\n this.#recordLink(sourceRef, link.linkType, targetRef);\n }\n }\n\n /**\n * Set the current state to the provided seed.\n * @param seed Seed output to reset to. Resets the seed builder if undefined.\n */\n set(seed?: SeedOutput): void {\n this.#reset();\n if (typeof seed !== \"undefined\") {\n this.addAll(seed);\n }\n }\n\n /**\n * Returns a SeedRef<Q> regardless of the existence of the object.\n * @param o Object Type\n * @param primaryKey\n * @returns SeedRef<Q>\n */\n #ref<Q extends ObjectTypeDefinition>(\n o: Q,\n primaryKey: PrimaryKeyType<Q>,\n ): SeedRef<Q> {\n const objectType = this.#objectType(o.apiName);\n const props = this.#getObjectTypeMap(o.apiName).get(String(primaryKey)) as\n | SeedProps<Q>\n | undefined;\n const base: OsdkBase<Q> = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKey),\n $objectType: o.apiName,\n $primaryKey: primaryKey,\n $title: props?.[objectType.titleProperty as keyof typeof props],\n };\n return Object.freeze({\n ...base,\n ...props,\n }) as SeedRef<Q>;\n }\n\n /**\n * Returns a reference to a previously created object, or `undefined` if none exists.\n * @param o Object type definition\n * @param primaryKey Primary key value of the object\n * @returns Reference to the object, or `undefined` if not found\n */\n ref<Q extends ObjectTypeDefinition>(\n o: Q,\n primaryKey: PrimaryKeyType<Q>,\n ): SeedRef<Q> | undefined {\n if (!this.#getObjectTypeMap(o.apiName).has(String(primaryKey))) {\n return;\n }\n return this.#ref(o, primaryKey);\n }\n\n /**\n * Creates an object of the given type, returning a reference to it.\n * @param o Object type definition\n * @param props Object properties, including its primary key\n * @returns Reference to the created object\n */\n create<Q extends ObjectTypeDefinition>(\n o: Q,\n props: SeedProps<Q>,\n ): SeedRef<Q> {\n const objectType = this.#objectType(o.apiName);\n const primaryKeyValue = props[\n objectType.primaryKey as keyof typeof props\n ] as PrimaryKeyType<Q>;\n const stringPrimaryKeyValue = String(primaryKeyValue);\n invariant(\n !this.#getObjectTypeMap(o.apiName).has(stringPrimaryKeyValue),\n `${o.apiName} with primary key ${stringPrimaryKeyValue} already exists.`,\n );\n validateSeedObject(props as Record<string, unknown>, objectType);\n this.#getObjectTypeMap(o.apiName).set(stringPrimaryKeyValue, props);\n const base: OsdkBase<Q> = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKeyValue),\n $objectType: o.apiName,\n $primaryKey: primaryKeyValue,\n $title: props[objectType.titleProperty as keyof typeof props],\n };\n return Object.freeze({\n ...base,\n ...props,\n }) as SeedRef<Q>;\n }\n\n /**\n * Merges the given props into the referenced object, keeping its primary key.\n * Properties not included in `props` are left unchanged; if the object does\n * not yet exist it is created from `props`.\n * @param ref Reference to the object to update\n * @param props Partial object properties to merge in, excluding the primary key\n * @returns The same reference passed in\n */\n update<Q extends ObjectTypeDefinition>(\n ref: SeedRef<Q>,\n props: Partial<\n Omit<SeedProps<Q>, Exclude<Q[\"primaryKeyApiName\"], undefined>>\n >,\n ): SeedRef<Q> {\n const { $apiName, $primaryKey } = ref;\n const objectType = this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n const currentValue = this.#getObjectTypeMap($apiName).get(\n stringPrimaryKeyValue,\n );\n if (!currentValue) {\n consola.warn(\n `Updating ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will create the object regardless.`,\n );\n }\n invariant(\n typeof props[objectType.primaryKey as keyof typeof props] === \"undefined\",\n `Cannot modify primary key ${objectType.primaryKey}`,\n );\n const merged = {\n ...currentValue,\n ...props,\n [objectType.primaryKey]: $primaryKey,\n };\n validateSeedObject(merged as Record<string, unknown>, objectType);\n this.#getObjectTypeMap($apiName).set(stringPrimaryKeyValue, merged);\n return ref;\n }\n\n /**\n * Removes the referenced object from the seed.\n * @param ref Reference to the object to delete\n */\n delete<Q extends ObjectTypeDefinition>(ref: SeedRef<Q>): void {\n const { $apiName, $primaryKey } = ref;\n this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n if (!this.#getObjectTypeMap($apiName).delete(stringPrimaryKeyValue)) {\n consola.warn(\n `Deleting ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will be a no-op.`,\n );\n return;\n }\n }\n\n /**\n * Links the source object to one or more targets via the given link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n link<Q extends ObjectTypeDefinition, A extends LinkTypeApiNamesFor<Q>>(\n source: SeedRef<Q>,\n apiName: A,\n target: LinkTargets<Q, A>,\n ): void {\n const targets = (Array.isArray(target) ? target : [target]) as Array<\n SeedRef<ObjectTypeDefinition>\n >;\n for (const t of targets) {\n this.#recordLink(source, apiName, t);\n }\n }\n\n #recordLink(\n source: SeedRef<ObjectTypeDefinition>,\n apiName: string,\n target: SeedRef<ObjectTypeDefinition>,\n ): void {\n this.#links.set(linkIdentity(source, apiName, target), {\n source,\n apiName,\n target,\n });\n }\n\n /**\n * Removes links from the source object to the given targets via the link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n unlink<Q extends ObjectTypeDefinition, A extends LinkTypeApiNamesFor<Q>>(\n source: SeedRef<Q>,\n apiName: A,\n target: LinkTargets<Q, A>,\n ): void {\n const targets = (Array.isArray(target) ? target : [target]) as Array<\n SeedRef<ObjectTypeDefinition>\n >;\n let removed = 0;\n for (const t of targets) {\n if (this.#links.delete(linkIdentity(source, apiName, t))) {\n removed++;\n }\n }\n if (removed === 0) {\n consola.warn(\n `Unlinking ${source.$apiName} with primary key ${String(\n source.$primaryKey,\n )} via '${apiName}' which matches no existing links. This will be a no-op.`,\n );\n }\n }\n\n /**\n * Validates the accumulated objects and links and returns the seed output.\n * @returns The built seed output\n */\n build(): SeedOutput {\n const objects: SeedOutput[\"objects\"] = {};\n const entries = this.#objectMap.entries();\n let nextEntry = entries.next();\n while (!nextEntry.done) {\n const objectTypeApiName = nextEntry.value[0];\n objects[objectTypeApiName] = [];\n const objectMap = nextEntry.value[1];\n const objectEntries = objectMap.entries();\n let nextObjectEntry = objectEntries.next();\n while (!nextObjectEntry.done) {\n objects[objectTypeApiName].push(nextObjectEntry.value[1]);\n nextObjectEntry = objectEntries.next();\n }\n nextEntry = entries.next();\n }\n const links: SeedOutput[\"links\"] = [];\n const linkEntries = this.#links.entries();\n let nextLink = linkEntries.next();\n while (!nextLink.done) {\n const [key, value] = nextLink.value;\n links.push({\n name: key,\n sourceObjectType: value.source.$apiName,\n sourceKey: String(value.source.$primaryKey),\n linkType: value.apiName,\n targetObjectType: value.target.$apiName,\n targetKey: String(value.target.$primaryKey),\n });\n nextLink = linkEntries.next();\n }\n return { objects, links } as SeedOutput;\n }\n\n #getObjectTypeMap(\n objectTypeApiName: string,\n ): Map<string, SeedProps<ObjectTypeDefinition>> {\n if (!this.#objectMap.has(objectTypeApiName)) {\n this.#objectMap.set(objectTypeApiName, new Map());\n }\n return this.#objectMap.get(objectTypeApiName)!;\n }\n}\n\n/**\n * Utility handle for building seeds from a metadata\n * @param ontologyMetadata Ontology metadata to instantiate seed builder from\n * @param fn handle to create seeds, may return an arbitrary value\n * @returns Tuple of [SeedOutput, T]: Seed output and arbitrary value returned from fn\n */\nexport function createSeedWithMetadata<T>(\n ontologyMetadata: Ontology.OntologyFullMetadata,\n fn: SeedFunction<T>,\n): {\n output: SeedOutput;\n context: T;\n} {\n const sb = new SeedBuilder(ontologyMetadata);\n const context = fn(sb);\n return {\n output: sb.build(),\n context,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,mCAAmC,QAAQ,cAAc;AAElE,SAASC,OAAO,QAAQ,SAAS;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AAItC,SAASC,kBAAkB,QAAQ,iBAAiB;AAUpD,SAASC,YAAYA,CACnBC,MAAqC,EACrCC,OAAe,EACfC,MAAqC,EAC7B;EACR,OAAO,CACLF,MAAM,CAACG,QAAQ,EACfC,MAAM,CAACJ,MAAM,CAACK,WAAW,CAAC,EAC1BJ,OAAO,EACPC,MAAM,CAACC,QAAQ,EACfC,MAAM,CAACF,MAAM,CAACG,WAAW,CAAC,CAC3B,CAACC,IAAI,CAAC,GAAG,CAAC;AACb;AAEA,OAAO,MAAMC,WAAW,CAAC;EACvB,CAACC,QAAQ;EACT,CAACC,SAAS;EACV,CAACC,KAAK;;EAEN;AACF;AACA;AACA;EACEC,WAAWA,CAACH,QAAuC,EAAE;IACnD,IAAI,CAAC,CAACA,QAAQ,GAAGA,QAAQ;IACzB,IAAI,CAAC,CAACC,SAAS,GAAG,IAAIG,GAAG,CAAC,CAAC;IAC3B,IAAI,CAAC,CAACF,KAAK,GAAG,IAAIE,GAAG,CAAC,CAAC;IACvB,KAAK,MAAM;MAAEC;IAAW,CAAC,IAAIC,MAAM,CAACC,MAAM,CAACP,QAAQ,CAACQ,WAAW,CAAC,EAAE;MA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;IAClBgB;EACF,CAAC;AACH","ignoreList":[]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -116,7 +116,7 @@ var SeedBuilder = class {
|
|
|
116
116
|
*/
|
|
117
117
|
#objectType(apiName) {
|
|
118
118
|
const full = this.#metadata.objectTypes[apiName];
|
|
119
|
-
!full ? process.env.NODE_ENV !== "production" ? invariant__default.default(false,
|
|
119
|
+
!full ? process.env.NODE_ENV !== "production" ? invariant__default.default(false, () => `Object type '${apiName}' is not defined in the ontology`) : invariant__default.default(false) : void 0;
|
|
120
120
|
return full.objectType;
|
|
121
121
|
}
|
|
122
122
|
/**
|
package/build/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/validation.ts","../../src/SeedBuilder.ts"],"names":["invariant","createObjectSpecifierFromPrimaryKey","consola"],"mappings":";;;;;;;;;;;AA2BA,IAAM,gBAAA,GAAmB;AAAA;AAAA,EAEvB,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,QAAA;AAAA,EACX,IAAA,EAAM,QAAA;AAAA,EACN,QAAA,EAAU,QAAA;AAAA,EACV,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,QAAA;AAAA,EACX,UAAA,EAAY,QAAA;AAAA;AAAA,EAEZ,OAAA,EAAS,QAAA;AAAA,EACT,IAAA,EAAM,QAAA;AAAA,EACN,KAAA,EAAO,QAAA;AAAA,EACP,MAAA,EAAQ,QAAA;AAAA,EACR,KAAA,EAAO,QAAA;AAAA;AAAA,EAEP,OAAA,EAAS;AACX,CAAA;AAaA,IAAM,gBAAA,GAAmB;AAAA,EACvB,SAAA,EAAW;AAAA,IACT,OAAA,EAAS,mEAAA;AAAA,IACT,OAAA,EAAS;AAAA,GACX;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,OAAA,EAAS,sBAAA;AAAA,IACT,OAAA,EAAS;AAA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,IAAA,OAAO,CAAC,SAAS,IAAA,EAAM;AACrB,MAAA,MAAM,CAAC,GAAA,EAAK,KAAK,CAAA,GAAI,QAAA,CAAS,KAAA;AAC9B,MAAA,KAAA,CAAM,IAAA,CAAK;AAAA,QACT,IAAA,EAAM,GAAA;AAAA,QACN,gBAAA,EAAkB,MAAM,MAAA,CAAO,QAAA;AAAA,QAC/B,SAAA,EAAW,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,WAAW,CAAA;AAAA,QAC1C,UAAU,KAAA,CAAM,OAAA;AAAA,QAChB,gBAAA,EAAkB,MAAM,MAAA,CAAO,QAAA;AAAA,QAC/B,SAAA,EAAW,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,WAAW;AAAA,OAC3C,CAAA;AACD,MAAA,QAAA,GAAW,YAAY,IAAA,EAAK;AAAA,IAC9B;AACA,IAAA,OAAO;AAAA,MACL,OAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AAAA,EACA,kBAAkB,iBAAA,EAAmB;AACnC,IAAA,IAAI,CAAC,IAAA,CAAK,UAAA,CAAW,GAAA,CAAI,iBAAiB,CAAA,EAAG;AAC3C,MAAA,IAAA,CAAK,UAAA,CAAW,GAAA,CAAI,iBAAA,kBAAmB,IAAI,KAAK,CAAA;AAAA,IAClD;AACA,IAAA,OAAO,IAAA,CAAK,UAAA,CAAW,GAAA,CAAI,iBAAiB,CAAA;AAAA,EAC9C;AACF;AAQO,SAAS,sBAAA,CAAuB,kBAAkB,EAAA,EAAI;AAC3D,EAAA,MAAM,EAAA,GAAK,IAAI,WAAA,CAAY,gBAAgB,CAAA;AAC3C,EAAA,MAAM,OAAA,GAAU,GAAG,EAAE,CAAA;AACrB,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,GAAG,KAAA,EAAM;AAAA,IACjB;AAAA,GACF;AACF","file":"index.cjs","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 invariant from \"tiny-invariant\";\n\n/**\n * Expected runtime JS type for each cataloged wire type.\n *\n * Used to fail fast on `as any` callers that pass a value of the wrong shape\n * (e.g., `age: \"30\"` when `age` is an integer). Wire types not listed here\n * are not strictly typed by this validator — currently `attachment`,\n * `mediaReference`, `geopoint`, `geoshape`, `vector`, `array`, `struct`,\n * which have non-primitive runtime shapes that need bespoke validation.\n */\nconst EXPECTED_JS_TYPE = {\n // string-encoded primitives\n string: \"string\",\n marking: \"string\",\n timestamp: \"string\",\n date: \"string\",\n datetime: \"string\",\n long: \"string\",\n decimal: \"string\",\n ipAddress: \"string\",\n cipherText: \"string\",\n // numeric primitives\n integer: \"number\",\n byte: \"number\",\n short: \"number\",\n double: \"number\",\n float: \"number\",\n // boolean\n boolean: \"boolean\"\n};\n\n/**\n * Regex patterns for string-encoded wire types that TypeScript cannot validate.\n *\n * These patterns are aligned with the Rust backend's actual parsing behavior:\n * - timestamp: RFC 3339 parse on the Rust side — requires timezone, rejects trailing garbage\n * - date: stored as raw string, but only YYYY-MM-DD works in SQLite queries\n * - datetime: stored as raw string, same YYYY-MM-DD requirement for query correctness\n * - long: strict decimal integer parse on the Rust side — no scientific notation\n * - decimal: Rust stores any string (no validation), but we enforce numeric format\n * to prevent obviously invalid values from silently passing through\n */\nconst WIRE_TYPE_FORMAT = {\n timestamp: {\n pattern: /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$/u,\n example: \"2025-01-01T00:00:00Z\"\n },\n date: {\n pattern: /^\\d{4}-\\d{2}-\\d{2}$/u,\n example: \"2025-01-01\"\n },\n datetime: {\n pattern: /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/u,\n example: \"2025-01-01T12:00:00Z\"\n },\n long: {\n // Strict decimal integer — matches Rust's str::parse::<i64>().\n // No scientific notation, no decimal point, no whitespace.\n pattern: /^-?\\d+$/u,\n example: \"9007199254740993\"\n },\n decimal: {\n // Numeric string with optional decimal point. Anchored.\n // Rust stores any string (no validation), but we reject obviously invalid values.\n pattern: /^-?\\d+(\\.\\d+)?$/u,\n example: \"123.45\"\n }\n};\n\n/**\n * Validates a single seed object's properties against its schema.\n *\n * Structural violations (unknown property name, null/undefined value, wrong JS\n * type) throw immediately. String-format violations (e.g. a timestamp that\n * doesn't match the wire format regex) are collected across the object's\n * properties and reported together in one error so a user can fix every\n * content mistake on the object in a single pass.\n *\n * The object type's existence in the ontology is assumed — callers resolve the\n * {@link Ontology.ObjectTypeV2} before invoking this validator.\n *\n * @throws on any structural violation, or listing all format failures for the\n * object.\n */\nexport function validateSeedObject(props, objectType) {\n const apiName = objectType.apiName;\n const identity = pkIdentity(props, objectType);\n const formatErrors = [];\n for (const [key, value] of Object.entries(props)) {\n const wireType = objectType.properties[key]?.dataType.type;\n !(wireType !== undefined) ? process.env.NODE_ENV !== \"production\" ? invariant(false, () => `Property '${key}' on '${apiName}' object` + ` (primary key ${identity}) is not defined in the ontology`) : invariant(false) : void 0;\n !(value != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, () => `Property '${key}' on '${apiName}' object` + ` (primary key ${identity}) is null or undefined`) : invariant(false) : void 0;\n const expectedJsType = EXPECTED_JS_TYPE[wireType];\n !(expectedJsType === undefined || typeof value === expectedJsType) ? process.env.NODE_ENV !== \"production\" ? invariant(false, () => `Property '${key}' on '${apiName}' object` + ` (primary key ${identity}) expects ${wireType} (a ${expectedJsType})` + ` but got ${typeof value}`) : invariant(false) : void 0;\n const format = WIRE_TYPE_FORMAT[wireType];\n if (!format) continue;\n if (format.pattern.test(value)) continue;\n formatErrors.push(`property '${key}' has invalid ${wireType}` + ` format: '${String(value)}'.` + ` Expected format like '${format.example}'`);\n }\n !(formatErrors.length === 0) ? process.env.NODE_ENV !== \"production\" ? invariant(false, () => formatValidationErrors(apiName, identity, formatErrors)) : invariant(false) : void 0;\n}\n\n/**\n * Derives the human-readable identity for an object from its primary key,\n * falling back to `<unknown>` when the key is absent (e.g. a `create` call that\n * omits it) or null.\n */\nfunction pkIdentity(props, objectType) {\n const pk = props[objectType.primaryKey];\n return pk == null ? \"<unknown>\" : String(pk);\n}\nfunction formatValidationErrors(apiName, identity, messages) {\n const errorWord = messages.length === 1 ? \"error\" : \"errors\";\n const body = messages.map(msg => ` ${msg}`).join(\"\\n\");\n return `Seed data validation failed for '${apiName}' object` + ` (primary key ${identity}) (${messages.length} ${errorWord}):\\n\\n${body}`;\n}","/*\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 { createObjectSpecifierFromPrimaryKey } from \"@osdk/client\";\nimport { consola } from \"consola\";\nimport invariant from \"tiny-invariant\";\nimport { validateSeedObject } from \"./validation.js\";\nfunction linkIdentity(source, apiName, target) {\n return [source.$apiName, String(source.$primaryKey), apiName, target.$apiName, String(target.$primaryKey)].join(\":\");\n}\nexport class SeedBuilder {\n #metadata;\n #objectMap;\n #links;\n\n /**\n * Creates a seed builder backed by the given ontology metadata.\n * @param metadata Ontology full metadata describing the object types\n */\n constructor(metadata) {\n this.#metadata = metadata;\n this.#objectMap = new Map();\n this.#links = new Map();\n for (const {\n objectType\n } of Object.values(metadata.objectTypes)) {\n !Object.hasOwn(objectType.properties, objectType.primaryKey) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `[${objectType.apiName}] Primary key '${objectType.primaryKey}' is not among the object's properties`) : invariant(false) : void 0;\n }\n }\n #reset() {\n this.#objectMap = new Map();\n this.#links = new Map();\n }\n\n /**\n * Resolves the object type metadata for `apiName`.\n * @throws if the object type is not present in the metadata\n */\n #objectType(apiName) {\n const full = this.#metadata.objectTypes[apiName];\n !full ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Object not found in metadata\") : invariant(false) : void 0;\n return full.objectType;\n }\n\n /**\n * Merges an existing seed output. Must match the metadata supplied at construction.\n * @param seed Seed output to derive from\n */\n addAll(seed) {\n const objectEntries = Object.entries(seed.objects).flatMap(([apiName, objects]) => objects.map(o => [apiName, o]));\n for (const [apiName, object] of objectEntries) {\n this.create({\n type: \"object\",\n apiName\n }, object);\n }\n const linkEntries = seed.links;\n for (const link of linkEntries) {\n const sourceRef = this.#ref({\n type: \"object\",\n apiName: link.sourceObjectType\n }, link.sourceKey);\n const targetRef = this.#ref({\n type: \"object\",\n apiName: link.targetObjectType\n }, link.targetKey);\n this.#recordLink(sourceRef, link.linkType, targetRef);\n }\n }\n\n /**\n * Set the current state to the provided seed.\n * @param seed Seed output to reset to. Resets the seed builder if undefined.\n */\n set(seed) {\n this.#reset();\n if (typeof seed !== \"undefined\") {\n this.addAll(seed);\n }\n }\n\n /**\n * Returns a SeedRef<Q> regardless of the existence of the object.\n * @param o Object Type\n * @param primaryKey\n * @returns SeedRef<Q>\n */\n #ref(o, primaryKey) {\n const objectType = this.#objectType(o.apiName);\n const props = this.#getObjectTypeMap(o.apiName).get(String(primaryKey));\n const base = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKey),\n $objectType: o.apiName,\n $primaryKey: primaryKey,\n $title: props?.[objectType.titleProperty]\n };\n return Object.freeze({\n ...base,\n ...props\n });\n }\n\n /**\n * Returns a reference to a previously created object, or `undefined` if none exists.\n * @param o Object type definition\n * @param primaryKey Primary key value of the object\n * @returns Reference to the object, or `undefined` if not found\n */\n ref(o, primaryKey) {\n if (!this.#getObjectTypeMap(o.apiName).has(String(primaryKey))) {\n return;\n }\n return this.#ref(o, primaryKey);\n }\n\n /**\n * Creates an object of the given type, returning a reference to it.\n * @param o Object type definition\n * @param props Object properties, including its primary key\n * @returns Reference to the created object\n */\n create(o, props) {\n const objectType = this.#objectType(o.apiName);\n const primaryKeyValue = props[objectType.primaryKey];\n const stringPrimaryKeyValue = String(primaryKeyValue);\n !!this.#getObjectTypeMap(o.apiName).has(stringPrimaryKeyValue) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `${o.apiName} with primary key ${stringPrimaryKeyValue} already exists.`) : invariant(false) : void 0;\n validateSeedObject(props, objectType);\n this.#getObjectTypeMap(o.apiName).set(stringPrimaryKeyValue, props);\n const base = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKeyValue),\n $objectType: o.apiName,\n $primaryKey: primaryKeyValue,\n $title: props[objectType.titleProperty]\n };\n return Object.freeze({\n ...base,\n ...props\n });\n }\n\n /**\n * Merges the given props into the referenced object, keeping its primary key.\n * Properties not included in `props` are left unchanged; if the object does\n * not yet exist it is created from `props`.\n * @param ref Reference to the object to update\n * @param props Partial object properties to merge in, excluding the primary key\n * @returns The same reference passed in\n */\n update(ref, props) {\n const {\n $apiName,\n $primaryKey\n } = ref;\n const objectType = this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n const currentValue = this.#getObjectTypeMap($apiName).get(stringPrimaryKeyValue);\n if (!currentValue) {\n consola.warn(`Updating ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will create the object regardless.`);\n }\n !(typeof props[objectType.primaryKey] === \"undefined\") ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Cannot modify primary key ${objectType.primaryKey}`) : invariant(false) : void 0;\n const merged = {\n ...currentValue,\n ...props,\n [objectType.primaryKey]: $primaryKey\n };\n validateSeedObject(merged, objectType);\n this.#getObjectTypeMap($apiName).set(stringPrimaryKeyValue, merged);\n return ref;\n }\n\n /**\n * Removes the referenced object from the seed.\n * @param ref Reference to the object to delete\n */\n delete(ref) {\n const {\n $apiName,\n $primaryKey\n } = ref;\n this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n if (!this.#getObjectTypeMap($apiName).delete(stringPrimaryKeyValue)) {\n consola.warn(`Deleting ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will be a no-op.`);\n return;\n }\n }\n\n /**\n * Links the source object to one or more targets via the given link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n link(source, apiName, target) {\n const targets = Array.isArray(target) ? target : [target];\n for (const t of targets) {\n this.#recordLink(source, apiName, t);\n }\n }\n #recordLink(source, apiName, target) {\n this.#links.set(linkIdentity(source, apiName, target), {\n source,\n apiName,\n target\n });\n }\n\n /**\n * Removes links from the source object to the given targets via the link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n unlink(source, apiName, target) {\n const targets = Array.isArray(target) ? target : [target];\n let removed = 0;\n for (const t of targets) {\n if (this.#links.delete(linkIdentity(source, apiName, t))) {\n removed++;\n }\n }\n if (removed === 0) {\n consola.warn(`Unlinking ${source.$apiName} with primary key ${String(source.$primaryKey)} via '${apiName}' which matches no existing links. This will be a no-op.`);\n }\n }\n\n /**\n * Validates the accumulated objects and links and returns the seed output.\n * @returns The built seed output\n */\n build() {\n const objects = {};\n const entries = this.#objectMap.entries();\n let nextEntry = entries.next();\n while (!nextEntry.done) {\n const objectTypeApiName = nextEntry.value[0];\n objects[objectTypeApiName] = [];\n const objectMap = nextEntry.value[1];\n const objectEntries = objectMap.entries();\n let nextObjectEntry = objectEntries.next();\n while (!nextObjectEntry.done) {\n objects[objectTypeApiName].push(nextObjectEntry.value[1]);\n nextObjectEntry = objectEntries.next();\n }\n nextEntry = entries.next();\n }\n const links = [];\n const linkEntries = this.#links.entries();\n let nextLink = linkEntries.next();\n while (!nextLink.done) {\n const [key, value] = nextLink.value;\n links.push({\n name: key,\n sourceObjectType: value.source.$apiName,\n sourceKey: String(value.source.$primaryKey),\n linkType: value.apiName,\n targetObjectType: value.target.$apiName,\n targetKey: String(value.target.$primaryKey)\n });\n nextLink = linkEntries.next();\n }\n return {\n objects,\n links\n };\n }\n #getObjectTypeMap(objectTypeApiName) {\n if (!this.#objectMap.has(objectTypeApiName)) {\n this.#objectMap.set(objectTypeApiName, new Map());\n }\n return this.#objectMap.get(objectTypeApiName);\n }\n}\n\n/**\n * Utility handle for building seeds from a metadata\n * @param ontologyMetadata Ontology metadata to instantiate seed builder from\n * @param fn handle to create seeds, may return an arbitrary value\n * @returns Tuple of [SeedOutput, T]: Seed output and arbitrary value returned from fn\n */\nexport function createSeedWithMetadata(ontologyMetadata, fn) {\n const sb = new SeedBuilder(ontologyMetadata);\n const context = fn(sb);\n return {\n output: sb.build(),\n context\n };\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/validation.ts","../../src/SeedBuilder.ts"],"names":["invariant","createObjectSpecifierFromPrimaryKey","consola"],"mappings":";;;;;;;;;;;AA2BA,IAAM,gBAAA,GAAmB;AAAA;AAAA,EAEvB,MAAA,EAAQ,QAAA;AAAA,EACR,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,QAAA;AAAA,EACX,IAAA,EAAM,QAAA;AAAA,EACN,QAAA,EAAU,QAAA;AAAA,EACV,IAAA,EAAM,QAAA;AAAA,EACN,OAAA,EAAS,QAAA;AAAA,EACT,SAAA,EAAW,QAAA;AAAA,EACX,UAAA,EAAY,QAAA;AAAA;AAAA,EAEZ,OAAA,EAAS,QAAA;AAAA,EACT,IAAA,EAAM,QAAA;AAAA,EACN,KAAA,EAAO,QAAA;AAAA,EACP,MAAA,EAAQ,QAAA;AA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AI;AAC3D,EAAA,MAAM,EAAA,GAAK,IAAI,WAAA,CAAY,gBAAgB,CAAA;AAC3C,EAAA,MAAM,OAAA,GAAU,GAAG,EAAE,CAAA;AACrB,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,GAAG,KAAA,EAAM;AAAA,IACjB;AAAA,GACF;AACF","file":"index.cjs","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 invariant from \"tiny-invariant\";\n\n/**\n * Expected runtime JS type for each cataloged wire type.\n *\n * Used to fail fast on `as any` callers that pass a value of the wrong shape\n * (e.g., `age: \"30\"` when `age` is an integer). Wire types not listed here\n * are not strictly typed by this validator — currently `attachment`,\n * `mediaReference`, `geopoint`, `geoshape`, `vector`, `array`, `struct`,\n * which have non-primitive runtime shapes that need bespoke validation.\n */\nconst EXPECTED_JS_TYPE = {\n // string-encoded primitives\n string: \"string\",\n marking: \"string\",\n timestamp: \"string\",\n date: \"string\",\n datetime: \"string\",\n long: \"string\",\n decimal: \"string\",\n ipAddress: \"string\",\n cipherText: \"string\",\n // numeric primitives\n integer: \"number\",\n byte: \"number\",\n short: \"number\",\n double: \"number\",\n float: \"number\",\n // boolean\n boolean: \"boolean\"\n};\n\n/**\n * Regex patterns for string-encoded wire types that TypeScript cannot validate.\n *\n * These patterns are aligned with the Rust backend's actual parsing behavior:\n * - timestamp: RFC 3339 parse on the Rust side — requires timezone, rejects trailing garbage\n * - date: stored as raw string, but only YYYY-MM-DD works in SQLite queries\n * - datetime: stored as raw string, same YYYY-MM-DD requirement for query correctness\n * - long: strict decimal integer parse on the Rust side — no scientific notation\n * - decimal: Rust stores any string (no validation), but we enforce numeric format\n * to prevent obviously invalid values from silently passing through\n */\nconst WIRE_TYPE_FORMAT = {\n timestamp: {\n pattern: /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$/u,\n example: \"2025-01-01T00:00:00Z\"\n },\n date: {\n pattern: /^\\d{4}-\\d{2}-\\d{2}$/u,\n example: \"2025-01-01\"\n },\n datetime: {\n pattern: /^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})?)?$/u,\n example: \"2025-01-01T12:00:00Z\"\n },\n long: {\n // Strict decimal integer — matches Rust's str::parse::<i64>().\n // No scientific notation, no decimal point, no whitespace.\n pattern: /^-?\\d+$/u,\n example: \"9007199254740993\"\n },\n decimal: {\n // Numeric string with optional decimal point. Anchored.\n // Rust stores any string (no validation), but we reject obviously invalid values.\n pattern: /^-?\\d+(\\.\\d+)?$/u,\n example: \"123.45\"\n }\n};\n\n/**\n * Validates a single seed object's properties against its schema.\n *\n * Structural violations (unknown property name, null/undefined value, wrong JS\n * type) throw immediately. String-format violations (e.g. a timestamp that\n * doesn't match the wire format regex) are collected across the object's\n * properties and reported together in one error so a user can fix every\n * content mistake on the object in a single pass.\n *\n * The object type's existence in the ontology is assumed — callers resolve the\n * {@link Ontology.ObjectTypeV2} before invoking this validator.\n *\n * @throws on any structural violation, or listing all format failures for the\n * object.\n */\nexport function validateSeedObject(props, objectType) {\n const apiName = objectType.apiName;\n const identity = pkIdentity(props, objectType);\n const formatErrors = [];\n for (const [key, value] of Object.entries(props)) {\n const wireType = objectType.properties[key]?.dataType.type;\n !(wireType !== undefined) ? process.env.NODE_ENV !== \"production\" ? invariant(false, () => `Property '${key}' on '${apiName}' object` + ` (primary key ${identity}) is not defined in the ontology`) : invariant(false) : void 0;\n !(value != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, () => `Property '${key}' on '${apiName}' object` + ` (primary key ${identity}) is null or undefined`) : invariant(false) : void 0;\n const expectedJsType = EXPECTED_JS_TYPE[wireType];\n !(expectedJsType === undefined || typeof value === expectedJsType) ? process.env.NODE_ENV !== \"production\" ? invariant(false, () => `Property '${key}' on '${apiName}' object` + ` (primary key ${identity}) expects ${wireType} (a ${expectedJsType})` + ` but got ${typeof value}`) : invariant(false) : void 0;\n const format = WIRE_TYPE_FORMAT[wireType];\n if (!format) continue;\n if (format.pattern.test(value)) continue;\n formatErrors.push(`property '${key}' has invalid ${wireType}` + ` format: '${String(value)}'.` + ` Expected format like '${format.example}'`);\n }\n !(formatErrors.length === 0) ? process.env.NODE_ENV !== \"production\" ? invariant(false, () => formatValidationErrors(apiName, identity, formatErrors)) : invariant(false) : void 0;\n}\n\n/**\n * Derives the human-readable identity for an object from its primary key,\n * falling back to `<unknown>` when the key is absent (e.g. a `create` call that\n * omits it) or null.\n */\nfunction pkIdentity(props, objectType) {\n const pk = props[objectType.primaryKey];\n return pk == null ? \"<unknown>\" : String(pk);\n}\nfunction formatValidationErrors(apiName, identity, messages) {\n const errorWord = messages.length === 1 ? \"error\" : \"errors\";\n const body = messages.map(msg => ` ${msg}`).join(\"\\n\");\n return `Seed data validation failed for '${apiName}' object` + ` (primary key ${identity}) (${messages.length} ${errorWord}):\\n\\n${body}`;\n}","/*\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 { createObjectSpecifierFromPrimaryKey } from \"@osdk/client\";\nimport { consola } from \"consola\";\nimport invariant from \"tiny-invariant\";\nimport { validateSeedObject } from \"./validation.js\";\nfunction linkIdentity(source, apiName, target) {\n return [source.$apiName, String(source.$primaryKey), apiName, target.$apiName, String(target.$primaryKey)].join(\":\");\n}\nexport class SeedBuilder {\n #metadata;\n #objectMap;\n #links;\n\n /**\n * Creates a seed builder backed by the given ontology metadata.\n * @param metadata Ontology full metadata describing the object types\n */\n constructor(metadata) {\n this.#metadata = metadata;\n this.#objectMap = new Map();\n this.#links = new Map();\n for (const {\n objectType\n } of Object.values(metadata.objectTypes)) {\n !Object.hasOwn(objectType.properties, objectType.primaryKey) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `[${objectType.apiName}] Primary key '${objectType.primaryKey}' is not among the object's properties`) : invariant(false) : void 0;\n }\n }\n #reset() {\n this.#objectMap = new Map();\n this.#links = new Map();\n }\n\n /**\n * Resolves the object type metadata for `apiName`.\n * @throws if the object type is not present in the metadata\n */\n #objectType(apiName) {\n const full = this.#metadata.objectTypes[apiName];\n !full ? process.env.NODE_ENV !== \"production\" ? invariant(false, () => `Object type '${apiName}' is not defined in the ontology`) : invariant(false) : void 0;\n return full.objectType;\n }\n\n /**\n * Merges an existing seed output. Must match the metadata supplied at construction.\n * @param seed Seed output to derive from\n */\n addAll(seed) {\n const objectEntries = Object.entries(seed.objects).flatMap(([apiName, objects]) => objects.map(o => [apiName, o]));\n for (const [apiName, object] of objectEntries) {\n this.create({\n type: \"object\",\n apiName\n }, object);\n }\n const linkEntries = seed.links;\n for (const link of linkEntries) {\n const sourceRef = this.#ref({\n type: \"object\",\n apiName: link.sourceObjectType\n }, link.sourceKey);\n const targetRef = this.#ref({\n type: \"object\",\n apiName: link.targetObjectType\n }, link.targetKey);\n this.#recordLink(sourceRef, link.linkType, targetRef);\n }\n }\n\n /**\n * Set the current state to the provided seed.\n * @param seed Seed output to reset to. Resets the seed builder if undefined.\n */\n set(seed) {\n this.#reset();\n if (typeof seed !== \"undefined\") {\n this.addAll(seed);\n }\n }\n\n /**\n * Returns a SeedRef<Q> regardless of the existence of the object.\n * @param o Object Type\n * @param primaryKey\n * @returns SeedRef<Q>\n */\n #ref(o, primaryKey) {\n const objectType = this.#objectType(o.apiName);\n const props = this.#getObjectTypeMap(o.apiName).get(String(primaryKey));\n const base = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKey),\n $objectType: o.apiName,\n $primaryKey: primaryKey,\n $title: props?.[objectType.titleProperty]\n };\n return Object.freeze({\n ...base,\n ...props\n });\n }\n\n /**\n * Returns a reference to a previously created object, or `undefined` if none exists.\n * @param o Object type definition\n * @param primaryKey Primary key value of the object\n * @returns Reference to the object, or `undefined` if not found\n */\n ref(o, primaryKey) {\n if (!this.#getObjectTypeMap(o.apiName).has(String(primaryKey))) {\n return;\n }\n return this.#ref(o, primaryKey);\n }\n\n /**\n * Creates an object of the given type, returning a reference to it.\n * @param o Object type definition\n * @param props Object properties, including its primary key\n * @returns Reference to the created object\n */\n create(o, props) {\n const objectType = this.#objectType(o.apiName);\n const primaryKeyValue = props[objectType.primaryKey];\n const stringPrimaryKeyValue = String(primaryKeyValue);\n !!this.#getObjectTypeMap(o.apiName).has(stringPrimaryKeyValue) ? process.env.NODE_ENV !== \"production\" ? invariant(false, `${o.apiName} with primary key ${stringPrimaryKeyValue} already exists.`) : invariant(false) : void 0;\n validateSeedObject(props, objectType);\n this.#getObjectTypeMap(o.apiName).set(stringPrimaryKeyValue, props);\n const base = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKeyValue),\n $objectType: o.apiName,\n $primaryKey: primaryKeyValue,\n $title: props[objectType.titleProperty]\n };\n return Object.freeze({\n ...base,\n ...props\n });\n }\n\n /**\n * Merges the given props into the referenced object, keeping its primary key.\n * Properties not included in `props` are left unchanged; if the object does\n * not yet exist it is created from `props`.\n * @param ref Reference to the object to update\n * @param props Partial object properties to merge in, excluding the primary key\n * @returns The same reference passed in\n */\n update(ref, props) {\n const {\n $apiName,\n $primaryKey\n } = ref;\n const objectType = this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n const currentValue = this.#getObjectTypeMap($apiName).get(stringPrimaryKeyValue);\n if (!currentValue) {\n consola.warn(`Updating ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will create the object regardless.`);\n }\n !(typeof props[objectType.primaryKey] === \"undefined\") ? process.env.NODE_ENV !== \"production\" ? invariant(false, `Cannot modify primary key ${objectType.primaryKey}`) : invariant(false) : void 0;\n const merged = {\n ...currentValue,\n ...props,\n [objectType.primaryKey]: $primaryKey\n };\n validateSeedObject(merged, objectType);\n this.#getObjectTypeMap($apiName).set(stringPrimaryKeyValue, merged);\n return ref;\n }\n\n /**\n * Removes the referenced object from the seed.\n * @param ref Reference to the object to delete\n */\n delete(ref) {\n const {\n $apiName,\n $primaryKey\n } = ref;\n this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n if (!this.#getObjectTypeMap($apiName).delete(stringPrimaryKeyValue)) {\n consola.warn(`Deleting ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will be a no-op.`);\n return;\n }\n }\n\n /**\n * Links the source object to one or more targets via the given link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n link(source, apiName, target) {\n const targets = Array.isArray(target) ? target : [target];\n for (const t of targets) {\n this.#recordLink(source, apiName, t);\n }\n }\n #recordLink(source, apiName, target) {\n this.#links.set(linkIdentity(source, apiName, target), {\n source,\n apiName,\n target\n });\n }\n\n /**\n * Removes links from the source object to the given targets via the link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n unlink(source, apiName, target) {\n const targets = Array.isArray(target) ? target : [target];\n let removed = 0;\n for (const t of targets) {\n if (this.#links.delete(linkIdentity(source, apiName, t))) {\n removed++;\n }\n }\n if (removed === 0) {\n consola.warn(`Unlinking ${source.$apiName} with primary key ${String(source.$primaryKey)} via '${apiName}' which matches no existing links. This will be a no-op.`);\n }\n }\n\n /**\n * Validates the accumulated objects and links and returns the seed output.\n * @returns The built seed output\n */\n build() {\n const objects = {};\n const entries = this.#objectMap.entries();\n let nextEntry = entries.next();\n while (!nextEntry.done) {\n const objectTypeApiName = nextEntry.value[0];\n objects[objectTypeApiName] = [];\n const objectMap = nextEntry.value[1];\n const objectEntries = objectMap.entries();\n let nextObjectEntry = objectEntries.next();\n while (!nextObjectEntry.done) {\n objects[objectTypeApiName].push(nextObjectEntry.value[1]);\n nextObjectEntry = objectEntries.next();\n }\n nextEntry = entries.next();\n }\n const links = [];\n const linkEntries = this.#links.entries();\n let nextLink = linkEntries.next();\n while (!nextLink.done) {\n const [key, value] = nextLink.value;\n links.push({\n name: key,\n sourceObjectType: value.source.$apiName,\n sourceKey: String(value.source.$primaryKey),\n linkType: value.apiName,\n targetObjectType: value.target.$apiName,\n targetKey: String(value.target.$primaryKey)\n });\n nextLink = linkEntries.next();\n }\n return {\n objects,\n links\n };\n }\n #getObjectTypeMap(objectTypeApiName) {\n if (!this.#objectMap.has(objectTypeApiName)) {\n this.#objectMap.set(objectTypeApiName, new Map());\n }\n return this.#objectMap.get(objectTypeApiName);\n }\n}\n\n/**\n * Utility handle for building seeds from a metadata\n * @param ontologyMetadata Ontology metadata to instantiate seed builder from\n * @param fn handle to create seeds, may return an arbitrary value\n * @returns Tuple of [SeedOutput, T]: Seed output and arbitrary value returned from fn\n */\nexport function createSeedWithMetadata(ontologyMetadata, fn) {\n const sb = new SeedBuilder(ontologyMetadata);\n const context = fn(sb);\n return {\n output: sb.build(),\n context\n };\n}"]}
|
package/build/esm/SeedBuilder.js
CHANGED
|
@@ -51,7 +51,7 @@ export class SeedBuilder {
|
|
|
51
51
|
*/
|
|
52
52
|
#objectType(apiName) {
|
|
53
53
|
const full = this.#metadata.objectTypes[apiName];
|
|
54
|
-
!full ? process.env.NODE_ENV !== "production" ? invariant(false,
|
|
54
|
+
!full ? process.env.NODE_ENV !== "production" ? invariant(false, () => `Object type '${apiName}' is not defined in the ontology`) : invariant(false) : void 0;
|
|
55
55
|
return full.objectType;
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SeedBuilder.js","names":["createObjectSpecifierFromPrimaryKey","consola","invariant","validateSeedObject","linkIdentity","source","apiName","target","$apiName","String","$primaryKey","join","SeedBuilder","metadata","objectMap","links","constructor","Map","objectType","Object","values","objectTypes","hasOwn","properties","primaryKey","process","env","NODE_ENV","reset","#reset","#objectType","full","addAll","seed","objectEntries","entries","objects","flatMap","map","o","object","create","type","linkEntries","link","sourceRef","ref","sourceObjectType","sourceKey","targetRef","targetObjectType","targetKey","recordLink","linkType","set","#ref","props","getObjectTypeMap","get","base","$objectSpecifier","$objectType","$title","titleProperty","freeze","has","primaryKeyValue","stringPrimaryKeyValue","update","currentValue","warn","merged","delete","targets","Array","isArray","t","#recordLink","unlink","removed","build","nextEntry","next","done","objectTypeApiName","value","nextObjectEntry","push","nextLink","key","name","#getObjectTypeMap","createSeedWithMetadata","ontologyMetadata","fn","sb","context","output"],"sources":["SeedBuilder.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectTypeDefinition,\n OsdkBase,\n PrimaryKeyType,\n LinkTypeApiNamesFor,\n} from \"@osdk/api\";\nimport { createObjectSpecifierFromPrimaryKey } from \"@osdk/client\";\nimport type * as Ontology from \"@osdk/foundry.ontologies\";\nimport { consola } from \"consola\";\nimport invariant from \"tiny-invariant\";\n\nimport type { LinkTargets } from \"./linkTypes.js\";\nimport type { SeedOutput, SeedProps, SeedRef } from \"./types.js\";\nimport { validateSeedObject } from \"./validation.js\";\n\nexport type SeedFunction<T> = (seed: SeedBuilder) => T;\n\ninterface SeedLinkRecord {\n source: SeedRef<ObjectTypeDefinition>;\n apiName: string;\n target: SeedRef<ObjectTypeDefinition>;\n}\n\nfunction linkIdentity(\n source: SeedRef<ObjectTypeDefinition>,\n apiName: string,\n target: SeedRef<ObjectTypeDefinition>,\n): string {\n return [\n source.$apiName,\n String(source.$primaryKey),\n apiName,\n target.$apiName,\n String(target.$primaryKey),\n ].join(\":\");\n}\n\nexport class SeedBuilder {\n #metadata: Ontology.OntologyFullMetadata;\n #objectMap: Map<string, Map<string, SeedProps<ObjectTypeDefinition>>>;\n #links: Map<string, SeedLinkRecord>;\n\n /**\n * Creates a seed builder backed by the given ontology metadata.\n * @param metadata Ontology full metadata describing the object types\n */\n constructor(metadata: Ontology.OntologyFullMetadata) {\n this.#metadata = metadata;\n this.#objectMap = new Map();\n this.#links = new Map();\n for (const { objectType } of Object.values(metadata.objectTypes)) {\n invariant(\n Object.hasOwn(objectType.properties, objectType.primaryKey),\n `[${objectType.apiName}] Primary key '${objectType.primaryKey}' is not among the object's properties`,\n );\n }\n }\n\n #reset() {\n this.#objectMap = new Map();\n this.#links = new Map();\n }\n\n /**\n * Resolves the object type metadata for `apiName`.\n * @throws if the object type is not present in the metadata\n */\n #objectType(apiName: string): Ontology.ObjectTypeV2 {\n const full = this.#metadata.objectTypes[apiName];\n invariant(full, \"Object not found in metadata\");\n return full.objectType;\n }\n\n /**\n * Merges an existing seed output. Must match the metadata supplied at construction.\n * @param seed Seed output to derive from\n */\n addAll(seed: SeedOutput): void {\n const objectEntries = Object.entries(seed.objects).flatMap(\n ([apiName, objects]) => objects.map((o) => [apiName, o] as const),\n );\n for (const [apiName, object] of objectEntries) {\n this.create(\n {\n type: \"object\",\n apiName,\n },\n object,\n );\n }\n const linkEntries = seed.links;\n for (const link of linkEntries) {\n const sourceRef = this.#ref(\n {\n type: \"object\",\n apiName: link.sourceObjectType,\n },\n link.sourceKey,\n );\n const targetRef = this.#ref(\n {\n type: \"object\",\n apiName: link.targetObjectType,\n },\n link.targetKey,\n );\n this.#recordLink(sourceRef, link.linkType, targetRef);\n }\n }\n\n /**\n * Set the current state to the provided seed.\n * @param seed Seed output to reset to. Resets the seed builder if undefined.\n */\n set(seed?: SeedOutput): void {\n this.#reset();\n if (typeof seed !== \"undefined\") {\n this.addAll(seed);\n }\n }\n\n /**\n * Returns a SeedRef<Q> regardless of the existence of the object.\n * @param o Object Type\n * @param primaryKey\n * @returns SeedRef<Q>\n */\n #ref<Q extends ObjectTypeDefinition>(\n o: Q,\n primaryKey: PrimaryKeyType<Q>,\n ): SeedRef<Q> {\n const objectType = this.#objectType(o.apiName);\n const props = this.#getObjectTypeMap(o.apiName).get(String(primaryKey)) as\n | SeedProps<Q>\n | undefined;\n const base: OsdkBase<Q> = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKey),\n $objectType: o.apiName,\n $primaryKey: primaryKey,\n $title: props?.[objectType.titleProperty as keyof typeof props],\n };\n return Object.freeze({\n ...base,\n ...props,\n }) as SeedRef<Q>;\n }\n\n /**\n * Returns a reference to a previously created object, or `undefined` if none exists.\n * @param o Object type definition\n * @param primaryKey Primary key value of the object\n * @returns Reference to the object, or `undefined` if not found\n */\n ref<Q extends ObjectTypeDefinition>(\n o: Q,\n primaryKey: PrimaryKeyType<Q>,\n ): SeedRef<Q> | undefined {\n if (!this.#getObjectTypeMap(o.apiName).has(String(primaryKey))) {\n return;\n }\n return this.#ref(o, primaryKey);\n }\n\n /**\n * Creates an object of the given type, returning a reference to it.\n * @param o Object type definition\n * @param props Object properties, including its primary key\n * @returns Reference to the created object\n */\n create<Q extends ObjectTypeDefinition>(\n o: Q,\n props: SeedProps<Q>,\n ): SeedRef<Q> {\n const objectType = this.#objectType(o.apiName);\n const primaryKeyValue = props[\n objectType.primaryKey as keyof typeof props\n ] as PrimaryKeyType<Q>;\n const stringPrimaryKeyValue = String(primaryKeyValue);\n invariant(\n !this.#getObjectTypeMap(o.apiName).has(stringPrimaryKeyValue),\n `${o.apiName} with primary key ${stringPrimaryKeyValue} already exists.`,\n );\n validateSeedObject(props as Record<string, unknown>, objectType);\n this.#getObjectTypeMap(o.apiName).set(stringPrimaryKeyValue, props);\n const base: OsdkBase<Q> = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKeyValue),\n $objectType: o.apiName,\n $primaryKey: primaryKeyValue,\n $title: props[objectType.titleProperty as keyof typeof props],\n };\n return Object.freeze({\n ...base,\n ...props,\n }) as SeedRef<Q>;\n }\n\n /**\n * Merges the given props into the referenced object, keeping its primary key.\n * Properties not included in `props` are left unchanged; if the object does\n * not yet exist it is created from `props`.\n * @param ref Reference to the object to update\n * @param props Partial object properties to merge in, excluding the primary key\n * @returns The same reference passed in\n */\n update<Q extends ObjectTypeDefinition>(\n ref: SeedRef<Q>,\n props: Partial<\n Omit<SeedProps<Q>, Exclude<Q[\"primaryKeyApiName\"], undefined>>\n >,\n ): SeedRef<Q> {\n const { $apiName, $primaryKey } = ref;\n const objectType = this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n const currentValue = this.#getObjectTypeMap($apiName).get(\n stringPrimaryKeyValue,\n );\n if (!currentValue) {\n consola.warn(\n `Updating ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will create the object regardless.`,\n );\n }\n invariant(\n typeof props[objectType.primaryKey as keyof typeof props] === \"undefined\",\n `Cannot modify primary key ${objectType.primaryKey}`,\n );\n const merged = {\n ...currentValue,\n ...props,\n [objectType.primaryKey]: $primaryKey,\n };\n validateSeedObject(merged as Record<string, unknown>, objectType);\n this.#getObjectTypeMap($apiName).set(stringPrimaryKeyValue, merged);\n return ref;\n }\n\n /**\n * Removes the referenced object from the seed.\n * @param ref Reference to the object to delete\n */\n delete<Q extends ObjectTypeDefinition>(ref: SeedRef<Q>): void {\n const { $apiName, $primaryKey } = ref;\n this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n if (!this.#getObjectTypeMap($apiName).delete(stringPrimaryKeyValue)) {\n consola.warn(\n `Deleting ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will be a no-op.`,\n );\n return;\n }\n }\n\n /**\n * Links the source object to one or more targets via the given link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n link<Q extends ObjectTypeDefinition, A extends LinkTypeApiNamesFor<Q>>(\n source: SeedRef<Q>,\n apiName: A,\n target: LinkTargets<Q, A>,\n ): void {\n const targets = (Array.isArray(target) ? target : [target]) as Array<\n SeedRef<ObjectTypeDefinition>\n >;\n for (const t of targets) {\n this.#recordLink(source, apiName, t);\n }\n }\n\n #recordLink(\n source: SeedRef<ObjectTypeDefinition>,\n apiName: string,\n target: SeedRef<ObjectTypeDefinition>,\n ): void {\n this.#links.set(linkIdentity(source, apiName, target), {\n source,\n apiName,\n target,\n });\n }\n\n /**\n * Removes links from the source object to the given targets via the link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n unlink<Q extends ObjectTypeDefinition, A extends LinkTypeApiNamesFor<Q>>(\n source: SeedRef<Q>,\n apiName: A,\n target: LinkTargets<Q, A>,\n ): void {\n const targets = (Array.isArray(target) ? target : [target]) as Array<\n SeedRef<ObjectTypeDefinition>\n >;\n let removed = 0;\n for (const t of targets) {\n if (this.#links.delete(linkIdentity(source, apiName, t))) {\n removed++;\n }\n }\n if (removed === 0) {\n consola.warn(\n `Unlinking ${source.$apiName} with primary key ${String(\n source.$primaryKey,\n )} via '${apiName}' which matches no existing links. This will be a no-op.`,\n );\n }\n }\n\n /**\n * Validates the accumulated objects and links and returns the seed output.\n * @returns The built seed output\n */\n build(): SeedOutput {\n const objects: SeedOutput[\"objects\"] = {};\n const entries = this.#objectMap.entries();\n let nextEntry = entries.next();\n while (!nextEntry.done) {\n const objectTypeApiName = nextEntry.value[0];\n objects[objectTypeApiName] = [];\n const objectMap = nextEntry.value[1];\n const objectEntries = objectMap.entries();\n let nextObjectEntry = objectEntries.next();\n while (!nextObjectEntry.done) {\n objects[objectTypeApiName].push(nextObjectEntry.value[1]);\n nextObjectEntry = objectEntries.next();\n }\n nextEntry = entries.next();\n }\n const links: SeedOutput[\"links\"] = [];\n const linkEntries = this.#links.entries();\n let nextLink = linkEntries.next();\n while (!nextLink.done) {\n const [key, value] = nextLink.value;\n links.push({\n name: key,\n sourceObjectType: value.source.$apiName,\n sourceKey: String(value.source.$primaryKey),\n linkType: value.apiName,\n targetObjectType: value.target.$apiName,\n targetKey: String(value.target.$primaryKey),\n });\n nextLink = linkEntries.next();\n }\n return { objects, links } as SeedOutput;\n }\n\n #getObjectTypeMap(\n objectTypeApiName: string,\n ): Map<string, SeedProps<ObjectTypeDefinition>> {\n if (!this.#objectMap.has(objectTypeApiName)) {\n this.#objectMap.set(objectTypeApiName, new Map());\n }\n return this.#objectMap.get(objectTypeApiName)!;\n }\n}\n\n/**\n * Utility handle for building seeds from a metadata\n * @param ontologyMetadata Ontology metadata to instantiate seed builder from\n * @param fn handle to create seeds, may return an arbitrary value\n * @returns Tuple of [SeedOutput, T]: Seed output and arbitrary value returned from fn\n */\nexport function createSeedWithMetadata<T>(\n ontologyMetadata: Ontology.OntologyFullMetadata,\n fn: SeedFunction<T>,\n): {\n output: SeedOutput;\n context: T;\n} {\n const sb = new SeedBuilder(ontologyMetadata);\n const context = fn(sb);\n return {\n output: sb.build(),\n context,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,mCAAmC,QAAQ,cAAc;AAElE,SAASC,OAAO,QAAQ,SAAS;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AAItC,SAASC,kBAAkB,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WAAW,CAACuC,IAAI,CAAC,CAAC;IAC/B;IACA,OAAO;MAAE9C,OAAO;MAAErB;IAAM,CAAC;EAC3B;EAEA,CAAC0C,gBAAgBkC,CACfP,iBAAyB,EACqB;IAC9C,IAAI,CAAC,IAAI,CAAC,CAACtE,SAAS,CAACmD,GAAG,CAACmB,iBAAiB,CAAC,EAAE;MAC3C,IAAI,CAAC,CAACtE,SAAS,CAACwC,GAAG,CAAC8B,iBAAiB,EAAE,IAAInE,GAAG,CAAC,CAAC,CAAC;IACnD;IACA,OAAO,IAAI,CAAC,CAACH,SAAS,CAAC4C,GAAG,CAAC0B,iBAAiB,CAAC;EAC/C;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,sBAAsBA,CACpCC,gBAA+C,EAC/CC,EAAmB,EAInB;EACA,MAAMC,EAAE,GAAG,IAAInF,WAAW,CAACiF,gBAAgB,CAAC;EAC5C,MAAMG,OAAO,GAAGF,EAAE,CAACC,EAAE,CAAC;EACtB,OAAO;IACLE,MAAM,EAAEF,EAAE,CAACf,KAAK,CAAC,CAAC;IAClBgB;EACF,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SeedBuilder.js","names":["createObjectSpecifierFromPrimaryKey","consola","invariant","validateSeedObject","linkIdentity","source","apiName","target","$apiName","String","$primaryKey","join","SeedBuilder","metadata","objectMap","links","constructor","Map","objectType","Object","values","objectTypes","hasOwn","properties","primaryKey","process","env","NODE_ENV","reset","#reset","#objectType","full","addAll","seed","objectEntries","entries","objects","flatMap","map","o","object","create","type","linkEntries","link","sourceRef","ref","sourceObjectType","sourceKey","targetRef","targetObjectType","targetKey","recordLink","linkType","set","#ref","props","getObjectTypeMap","get","base","$objectSpecifier","$objectType","$title","titleProperty","freeze","has","primaryKeyValue","stringPrimaryKeyValue","update","currentValue","warn","merged","delete","targets","Array","isArray","t","#recordLink","unlink","removed","build","nextEntry","next","done","objectTypeApiName","value","nextObjectEntry","push","nextLink","key","name","#getObjectTypeMap","createSeedWithMetadata","ontologyMetadata","fn","sb","context","output"],"sources":["SeedBuilder.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectTypeDefinition,\n OsdkBase,\n PrimaryKeyType,\n LinkTypeApiNamesFor,\n} from \"@osdk/api\";\nimport { createObjectSpecifierFromPrimaryKey } from \"@osdk/client\";\nimport type * as Ontology from \"@osdk/foundry.ontologies\";\nimport { consola } from \"consola\";\nimport invariant from \"tiny-invariant\";\n\nimport type { LinkTargets } from \"./linkTypes.js\";\nimport type { SeedOutput, SeedProps, SeedRef } from \"./types.js\";\nimport { validateSeedObject } from \"./validation.js\";\n\nexport type SeedFunction<T> = (seed: SeedBuilder) => T;\n\ninterface SeedLinkRecord {\n source: SeedRef<ObjectTypeDefinition>;\n apiName: string;\n target: SeedRef<ObjectTypeDefinition>;\n}\n\nfunction linkIdentity(\n source: SeedRef<ObjectTypeDefinition>,\n apiName: string,\n target: SeedRef<ObjectTypeDefinition>,\n): string {\n return [\n source.$apiName,\n String(source.$primaryKey),\n apiName,\n target.$apiName,\n String(target.$primaryKey),\n ].join(\":\");\n}\n\nexport class SeedBuilder {\n #metadata: Ontology.OntologyFullMetadata;\n #objectMap: Map<string, Map<string, SeedProps<ObjectTypeDefinition>>>;\n #links: Map<string, SeedLinkRecord>;\n\n /**\n * Creates a seed builder backed by the given ontology metadata.\n * @param metadata Ontology full metadata describing the object types\n */\n constructor(metadata: Ontology.OntologyFullMetadata) {\n this.#metadata = metadata;\n this.#objectMap = new Map();\n this.#links = new Map();\n for (const { objectType } of Object.values(metadata.objectTypes)) {\n invariant(\n Object.hasOwn(objectType.properties, objectType.primaryKey),\n `[${objectType.apiName}] Primary key '${objectType.primaryKey}' is not among the object's properties`,\n );\n }\n }\n\n #reset() {\n this.#objectMap = new Map();\n this.#links = new Map();\n }\n\n /**\n * Resolves the object type metadata for `apiName`.\n * @throws if the object type is not present in the metadata\n */\n #objectType(apiName: string): Ontology.ObjectTypeV2 {\n const full = this.#metadata.objectTypes[apiName];\n invariant(\n full,\n () => `Object type '${apiName}' is not defined in the ontology`,\n );\n return full.objectType;\n }\n\n /**\n * Merges an existing seed output. Must match the metadata supplied at construction.\n * @param seed Seed output to derive from\n */\n addAll(seed: SeedOutput): void {\n const objectEntries = Object.entries(seed.objects).flatMap(\n ([apiName, objects]) => objects.map((o) => [apiName, o] as const),\n );\n for (const [apiName, object] of objectEntries) {\n this.create(\n {\n type: \"object\",\n apiName,\n },\n object,\n );\n }\n const linkEntries = seed.links;\n for (const link of linkEntries) {\n const sourceRef = this.#ref(\n {\n type: \"object\",\n apiName: link.sourceObjectType,\n },\n link.sourceKey,\n );\n const targetRef = this.#ref(\n {\n type: \"object\",\n apiName: link.targetObjectType,\n },\n link.targetKey,\n );\n this.#recordLink(sourceRef, link.linkType, targetRef);\n }\n }\n\n /**\n * Set the current state to the provided seed.\n * @param seed Seed output to reset to. Resets the seed builder if undefined.\n */\n set(seed?: SeedOutput): void {\n this.#reset();\n if (typeof seed !== \"undefined\") {\n this.addAll(seed);\n }\n }\n\n /**\n * Returns a SeedRef<Q> regardless of the existence of the object.\n * @param o Object Type\n * @param primaryKey\n * @returns SeedRef<Q>\n */\n #ref<Q extends ObjectTypeDefinition>(\n o: Q,\n primaryKey: PrimaryKeyType<Q>,\n ): SeedRef<Q> {\n const objectType = this.#objectType(o.apiName);\n const props = this.#getObjectTypeMap(o.apiName).get(String(primaryKey)) as\n | SeedProps<Q>\n | undefined;\n const base: OsdkBase<Q> = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKey),\n $objectType: o.apiName,\n $primaryKey: primaryKey,\n $title: props?.[objectType.titleProperty as keyof typeof props],\n };\n return Object.freeze({\n ...base,\n ...props,\n }) as SeedRef<Q>;\n }\n\n /**\n * Returns a reference to a previously created object, or `undefined` if none exists.\n * @param o Object type definition\n * @param primaryKey Primary key value of the object\n * @returns Reference to the object, or `undefined` if not found\n */\n ref<Q extends ObjectTypeDefinition>(\n o: Q,\n primaryKey: PrimaryKeyType<Q>,\n ): SeedRef<Q> | undefined {\n if (!this.#getObjectTypeMap(o.apiName).has(String(primaryKey))) {\n return;\n }\n return this.#ref(o, primaryKey);\n }\n\n /**\n * Creates an object of the given type, returning a reference to it.\n * @param o Object type definition\n * @param props Object properties, including its primary key\n * @returns Reference to the created object\n */\n create<Q extends ObjectTypeDefinition>(\n o: Q,\n props: SeedProps<Q>,\n ): SeedRef<Q> {\n const objectType = this.#objectType(o.apiName);\n const primaryKeyValue = props[\n objectType.primaryKey as keyof typeof props\n ] as PrimaryKeyType<Q>;\n const stringPrimaryKeyValue = String(primaryKeyValue);\n invariant(\n !this.#getObjectTypeMap(o.apiName).has(stringPrimaryKeyValue),\n `${o.apiName} with primary key ${stringPrimaryKeyValue} already exists.`,\n );\n validateSeedObject(props as Record<string, unknown>, objectType);\n this.#getObjectTypeMap(o.apiName).set(stringPrimaryKeyValue, props);\n const base: OsdkBase<Q> = {\n $apiName: o.apiName,\n $objectSpecifier: createObjectSpecifierFromPrimaryKey(o, primaryKeyValue),\n $objectType: o.apiName,\n $primaryKey: primaryKeyValue,\n $title: props[objectType.titleProperty as keyof typeof props],\n };\n return Object.freeze({\n ...base,\n ...props,\n }) as SeedRef<Q>;\n }\n\n /**\n * Merges the given props into the referenced object, keeping its primary key.\n * Properties not included in `props` are left unchanged; if the object does\n * not yet exist it is created from `props`.\n * @param ref Reference to the object to update\n * @param props Partial object properties to merge in, excluding the primary key\n * @returns The same reference passed in\n */\n update<Q extends ObjectTypeDefinition>(\n ref: SeedRef<Q>,\n props: Partial<\n Omit<SeedProps<Q>, Exclude<Q[\"primaryKeyApiName\"], undefined>>\n >,\n ): SeedRef<Q> {\n const { $apiName, $primaryKey } = ref;\n const objectType = this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n const currentValue = this.#getObjectTypeMap($apiName).get(\n stringPrimaryKeyValue,\n );\n if (!currentValue) {\n consola.warn(\n `Updating ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will create the object regardless.`,\n );\n }\n invariant(\n typeof props[objectType.primaryKey as keyof typeof props] === \"undefined\",\n `Cannot modify primary key ${objectType.primaryKey}`,\n );\n const merged = {\n ...currentValue,\n ...props,\n [objectType.primaryKey]: $primaryKey,\n };\n validateSeedObject(merged as Record<string, unknown>, objectType);\n this.#getObjectTypeMap($apiName).set(stringPrimaryKeyValue, merged);\n return ref;\n }\n\n /**\n * Removes the referenced object from the seed.\n * @param ref Reference to the object to delete\n */\n delete<Q extends ObjectTypeDefinition>(ref: SeedRef<Q>): void {\n const { $apiName, $primaryKey } = ref;\n this.#objectType($apiName);\n const stringPrimaryKeyValue = String($primaryKey);\n if (!this.#getObjectTypeMap($apiName).delete(stringPrimaryKeyValue)) {\n consola.warn(\n `Deleting ${$apiName} with primary key ${stringPrimaryKeyValue} which does not exist. This will be a no-op.`,\n );\n return;\n }\n }\n\n /**\n * Links the source object to one or more targets via the given link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n link<Q extends ObjectTypeDefinition, A extends LinkTypeApiNamesFor<Q>>(\n source: SeedRef<Q>,\n apiName: A,\n target: LinkTargets<Q, A>,\n ): void {\n const targets = (Array.isArray(target) ? target : [target]) as Array<\n SeedRef<ObjectTypeDefinition>\n >;\n for (const t of targets) {\n this.#recordLink(source, apiName, t);\n }\n }\n\n #recordLink(\n source: SeedRef<ObjectTypeDefinition>,\n apiName: string,\n target: SeedRef<ObjectTypeDefinition>,\n ): void {\n this.#links.set(linkIdentity(source, apiName, target), {\n source,\n apiName,\n target,\n });\n }\n\n /**\n * Removes links from the source object to the given targets via the link type.\n * @param source Reference to the source object\n * @param apiName Link type API name\n * @param target Reference (or references) to the target object(s)\n */\n unlink<Q extends ObjectTypeDefinition, A extends LinkTypeApiNamesFor<Q>>(\n source: SeedRef<Q>,\n apiName: A,\n target: LinkTargets<Q, A>,\n ): void {\n const targets = (Array.isArray(target) ? target : [target]) as Array<\n SeedRef<ObjectTypeDefinition>\n >;\n let removed = 0;\n for (const t of targets) {\n if (this.#links.delete(linkIdentity(source, apiName, t))) {\n removed++;\n }\n }\n if (removed === 0) {\n consola.warn(\n `Unlinking ${source.$apiName} with primary key ${String(\n source.$primaryKey,\n )} via '${apiName}' which matches no existing links. This will be a no-op.`,\n );\n }\n }\n\n /**\n * Validates the accumulated objects and links and returns the seed output.\n * @returns The built seed output\n */\n build(): SeedOutput {\n const objects: SeedOutput[\"objects\"] = {};\n const entries = this.#objectMap.entries();\n let nextEntry = entries.next();\n while (!nextEntry.done) {\n const objectTypeApiName = nextEntry.value[0];\n objects[objectTypeApiName] = [];\n const objectMap = nextEntry.value[1];\n const objectEntries = objectMap.entries();\n let nextObjectEntry = objectEntries.next();\n while (!nextObjectEntry.done) {\n objects[objectTypeApiName].push(nextObjectEntry.value[1]);\n nextObjectEntry = objectEntries.next();\n }\n nextEntry = entries.next();\n }\n const links: SeedOutput[\"links\"] = [];\n const linkEntries = this.#links.entries();\n let nextLink = linkEntries.next();\n while (!nextLink.done) {\n const [key, value] = nextLink.value;\n links.push({\n name: key,\n sourceObjectType: value.source.$apiName,\n sourceKey: String(value.source.$primaryKey),\n linkType: value.apiName,\n targetObjectType: value.target.$apiName,\n targetKey: String(value.target.$primaryKey),\n });\n nextLink = linkEntries.next();\n }\n return { objects, links } as SeedOutput;\n }\n\n #getObjectTypeMap(\n objectTypeApiName: string,\n ): Map<string, SeedProps<ObjectTypeDefinition>> {\n if (!this.#objectMap.has(objectTypeApiName)) {\n this.#objectMap.set(objectTypeApiName, new Map());\n }\n return this.#objectMap.get(objectTypeApiName)!;\n }\n}\n\n/**\n * Utility handle for building seeds from a metadata\n * @param ontologyMetadata Ontology metadata to instantiate seed builder from\n * @param fn handle to create seeds, may return an arbitrary value\n * @returns Tuple of [SeedOutput, T]: Seed output and arbitrary value returned from fn\n */\nexport function createSeedWithMetadata<T>(\n ontologyMetadata: Ontology.OntologyFullMetadata,\n fn: SeedFunction<T>,\n): {\n output: SeedOutput;\n context: T;\n} {\n const sb = new SeedBuilder(ontologyMetadata);\n const context = fn(sb);\n return {\n output: sb.build(),\n context,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,mCAAmC,QAAQ,cAAc;AAElE,SAASC,OAAO,QAAQ,SAAS;AACjC,OAAOC,SAAS,MAAM,gBAAgB;AAItC,SAASC,kBAAkB,QAAQ,iBAAiB;AAUpD,SAASC,YAAYA,CACnBC,MAAqC,EACrCC,OAAe,EACfC,MAAqC,EAC7B;EACR,OAAO,CACLF,MAAM,CAACG,QAAQ,EACfC,MAAM,CAACJ,MAAM,CAACK,WAAW,CAAC,EAC1BJ,OAAO,EACPC,MAAM,CAACC,QAAQ,EACfC,MAAM,CAACF,MAAM,CAACG,WAAW,CAAC,CAC3B,CAACC,IAAI,CAAC,GAAG,CAAC;AACb;AAEA,OAAO,MAAMC,WAAW,CAAC;EACvB,CAACC,QAAQ;EACT,CAACC,SAAS;EACV,CAACC,KAAK;;EAEN;AACF;AACA;AACA;EACEC,WAAWA,CAACH,QAAuC,EAAE;IACnD,IAAI,CAAC,CAACA,QAAQ,GAAGA,QAAQ;IACzB,IAAI,CAAC,CAACC,SAAS,GAAG,IAAIG,GAAG,CAAC,CAAC;IAC3B,IAAI,CAAC,CAACF,KAAK,GAAG,IAAIE,GAAG,CAAC,CAAC;IACvB,KAAK,MAAM;MAAEC;I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,SAAS;AA0CV;;;;;;;AAQD,OAAO,iBAAS,uBAAuB,GACrCC,kBAAkB,SAAS,sBAC3BC,IAAI,aAAa,KAChB;CACD,QAAQ;CACR,SAAS;AACV","names":["seed: SeedBuilder","metadata: Ontology.OntologyFullMetadata","seed: SeedOutput","seed?: SeedOutput","o: Q","primaryKey: PrimaryKeyType<Q>","props: SeedProps<Q>","ref: SeedRef<Q>","props: Partial<\n Omit<SeedProps<Q>, Exclude<Q[\"primaryKeyApiName\"], undefined>>\n >","source: SeedRef<Q>","apiName: A","target: LinkTargets<Q, A>","ontologyMetadata: Ontology.OntologyFullMetadata","fn: SeedFunction<T>"],"sources":["../../src/SeedBuilder.ts"],"version":3,"file":"SeedBuilder.d.ts"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/seed-helpers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"tiny-invariant": "^1.3.3"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@osdk/api": "^2.
|
|
36
|
-
"@osdk/client": "^2.
|
|
35
|
+
"@osdk/api": "^2.57.0",
|
|
36
|
+
"@osdk/client": "^2.57.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26.1.1",
|
|
40
40
|
"typescript": "~5.5.4",
|
|
41
41
|
"vitest": "^3.2.4",
|
|
42
|
-
"@osdk/client.test.ontology": "~2.
|
|
42
|
+
"@osdk/client.test.ontology": "~2.57.0",
|
|
43
43
|
"@osdk/monorepo.api-extractor": "~0.7.0",
|
|
44
44
|
"@osdk/monorepo.tsconfig": "~0.7.0"
|
|
45
45
|
},
|