@osdk/faux 0.1.0-beta.1 → 0.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/browser/FauxFoundry/FauxDataStore.js +2 -1
  3. package/build/browser/FauxFoundry/FauxDataStore.js.map +1 -1
  4. package/build/browser/FauxFoundry/FauxDataStoreBatch.js +3 -0
  5. package/build/browser/FauxFoundry/FauxDataStoreBatch.js.map +1 -1
  6. package/build/browser/FauxFoundry/validateAction.js +2 -2
  7. package/build/browser/FauxFoundry/validateAction.js.map +1 -1
  8. package/build/browser/errors.js +1 -3
  9. package/build/browser/errors.js.map +1 -1
  10. package/build/browser/index.js +0 -1
  11. package/build/browser/index.js.map +1 -1
  12. package/build/cjs/index.cjs +8 -7
  13. package/build/cjs/index.cjs.map +1 -1
  14. package/build/cjs/index.d.cts +12 -11
  15. package/build/esm/FauxFoundry/FauxDataStore.js +2 -1
  16. package/build/esm/FauxFoundry/FauxDataStore.js.map +1 -1
  17. package/build/esm/FauxFoundry/FauxDataStoreBatch.js +3 -0
  18. package/build/esm/FauxFoundry/FauxDataStoreBatch.js.map +1 -1
  19. package/build/esm/FauxFoundry/validateAction.js +2 -2
  20. package/build/esm/FauxFoundry/validateAction.js.map +1 -1
  21. package/build/esm/errors.js +1 -3
  22. package/build/esm/errors.js.map +1 -1
  23. package/build/esm/index.js +0 -1
  24. package/build/esm/index.js.map +1 -1
  25. package/build/types/FauxFoundry/FauxDataStore.d.ts.map +1 -1
  26. package/build/types/FauxFoundry/FauxDataStoreBatch.d.ts +1 -0
  27. package/build/types/FauxFoundry/FauxDataStoreBatch.d.ts.map +1 -1
  28. package/build/types/FauxFoundry/validateAction.d.ts.map +1 -1
  29. package/build/types/errors.d.ts.map +1 -1
  30. package/build/types/index.d.ts +2 -1
  31. package/build/types/index.d.ts.map +1 -1
  32. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @osdk/shared.test
2
2
 
3
+ ## 0.1.0-beta.2
4
+
5
+ ### Minor Changes
6
+
7
+ - e99a614: Split FauxFoundry to its own package
8
+
9
+ ### Patch Changes
10
+
11
+ - @osdk/api@2.3.0-beta.6
12
+ - @osdk/generator-converters@2.3.0-beta.6
13
+
3
14
  ## 2.3.0-beta.5
4
15
 
5
16
  ### Patch Changes
@@ -358,6 +358,7 @@ export class FauxDataStore {
358
358
  return object;
359
359
  }
360
360
  getObjectsOfType(apiName) {
361
+ this.ontology.getObjectTypeFullMetadataOrThrow(apiName);
361
362
  return this.#objects.get(apiName).values();
362
363
  }
363
364
  getObjectsFromObjectSet(parsedBody) {
@@ -365,7 +366,7 @@ export class FauxDataStore {
365
366
  // when we have interfaces in here, we have a little trick for
366
367
  // caching off the important properties
367
368
  let objects = getObjectsFromSet(this, parsedBody.objectSet, undefined);
368
- if (!objects) {
369
+ if (!objects || objects.length === 0) {
369
370
  return {
370
371
  data: [],
371
372
  totalCount: "0",
@@ -1 +1 @@
1
- {"version":3,"file":"FauxDataStore.js","names":["DefaultMap","MultiMap","randomUUID","crypto","invariant","InvalidRequest","ObjectNotFoundError","subSelectProperties","getPaginationParamsFromRequest","OpenApiCallError","pageThroughResponseSearchParams","isBaseServerObject","FauxDataStoreBatch","filterTimeSeriesData","createOrderBySortFn","getObjectsFromSet","objectLocator","parseLocator","validateAction","FauxDataStore","objects","Map","singleLinks","manyLinks","Set","fauxOntology","attachments","timeSeriesData","media","constructor","clear","ontology","assertObjectExists","#assertObjectExists","objectType","primaryKey","getObject","String","assertObjectDoesNotExist","#assertObjectDoesNotExist","errorCode","errorName","errorInstanceId","parameters","registerObject","anyObj","bso","process","env","NODE_ENV","Object","keys","some","s","startsWith","osdkCreatableToBso","apiName","__apiName","$apiName","__primaryKey","$primaryKey","others","get","set","freeze","#osdkCreatableToBso","meta","getObjectTypeFullMetadataOrThrow","realPrimaryKey","maybeTitle","titleProperty","rid","$rid","JSON","stringify","__title","undefined","__rid","replaceObjectOrThrow","x","unregisterObjectOrThrow","delete","registerLink","src","srcLinkName","dst","destLinkName","srcLocator","dstLocator","srcSide","dstSide","getBothLinkTypeSides","linkTypeRid","updateSingleLinkSide","unregisterLink","dstLinkName","removeSingleSideOfLink","registerTimeSeriesData","property","data","getObjectOrThrow","def","properties","dataType","type","getTimeSeriesData","filter","allData","#updateSingleLinkSide","cardinality","linkNameToObj","oldLocator","Error","registerMedia","content","mediaType","path","mediaItemRid","mediaRef","mimeType","reference","mediaSetViewItem","mediaSetRid","mediaSetViewRid","metaData","sizeBytes","byteLength","getMediaOrThrow","obj","propertyDef","propertyBaseType","propertyValue","ret","#removeSingleSideOfLink","locator","linkSide","expectedPriorValue","links","has","remove","object","getObjectByRid","pkToObjects","getLinksOrThrow","linkApiName","linkTypeSide","getLinkTypeSideV2","locators","Array","from","map","a","split","getLinkOrThrow","linkType","targetPrimaryKey","allLinks","l","getObjectsOfType","values","getObjectsFromObjectSet","parsedBody","selected","select","objectSet","totalCount","nextPageToken","orderBy","sort","page","excludeRid","getAttachmentMetadata","propertyName","getAttachmentMetadataByRid","getAttachmentBuffer","applyAction","actionTypeApiName","req","actionDef","getActionDef","actionImpl","getActionImpl","validation","result","batch","r","submissionCriteria","edits","options","mode","returnEdits","objectEdits","batchApplyAction","batchReq","requests","actionType","item"],"sources":["FauxDataStore.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { CompileTimeMetadata, ObjectTypeDefinition } from \"@osdk/api\";\nimport type {\n MediaItemRid,\n MediaReference,\n MediaType,\n} from \"@osdk/foundry.core\";\nimport type * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { DefaultMap, MultiMap } from \"mnemonist\";\nimport { randomUUID } from \"node:crypto\";\nimport * as crypto from \"node:crypto\";\nimport invariant from \"tiny-invariant\";\nimport type { ReadonlyDeep } from \"type-fest\";\nimport { InvalidRequest, ObjectNotFoundError } from \"../errors.js\";\nimport { subSelectProperties } from \"../filterObjects.js\";\nimport { getPaginationParamsFromRequest } from \"../handlers/util/getPaginationParams.js\";\nimport { OpenApiCallError } from \"../handlers/util/handleOpenApiCall.js\";\nimport type { PagedBodyResponseWithTotal } from \"../handlers/util/pageThroughResponseSearchParams.js\";\nimport { pageThroughResponseSearchParams } from \"../handlers/util/pageThroughResponseSearchParams.js\";\nimport {\n type BaseServerObject,\n isBaseServerObject,\n} from \"./BaseServerObject.js\";\nimport type { FauxAttachmentStore } from \"./FauxAttachmentStore.js\";\nimport { FauxDataStoreBatch } from \"./FauxDataStoreBatch.js\";\nimport type { FauxOntology } from \"./FauxOntology.js\";\nimport { filterTimeSeriesData } from \"./filterTimeSeriesData.js\";\nimport { createOrderBySortFn, getObjectsFromSet } from \"./getObjectsFromSet.js\";\nimport type { ObjectLocator } from \"./ObjectLocator.js\";\nimport { objectLocator, parseLocator } from \"./ObjectLocator.js\";\nimport type { JustProps } from \"./typeHelpers/JustProps.js\";\nimport { validateAction } from \"./validateAction.js\";\n\nexport interface MediaMetadataAndContent {\n content: ArrayBuffer;\n mediaRef: MediaReference;\n metaData: OntologiesV2.MediaMetadata;\n}\n\ntype ObjectTypeCreatableWithoutApiName<T extends ObjectTypeDefinition> =\n OrUndefinedToOptional<JustProps<T>>;\n\n/**\n * Represents the properties needed to create an object, specifically,\n * the properties of the object and the $apiName\n */\ntype ObjectTypeCreatable<T extends ObjectTypeDefinition> =\n & ObjectTypeCreatableWithoutApiName<T>\n & { $apiName: CompileTimeMetadata<T>[\"apiName\"] };\n\n/**\n * Helper type for converting `foo: string | undefined` into `foo?: string`\n */\ntype OrUndefinedToOptional<T extends object> =\n & {\n [K in keyof T as T[K] extends undefined ? K : never]?: T[K];\n }\n & {\n [K in keyof T as T[K] extends undefined ? never : K]?: T[K];\n };\n\n/**\n * Type safe object for representing \"client\" side objects.\n */\ninterface BaseObjectTypeCreatable {\n $apiName?: OntologiesV2.ObjectTypeApiName;\n\n /** if present it must match the correct value */\n $primaryKey?: string | number | boolean;\n\n /** If set, will use the as the $rid for the object, otherwise one is created for you */\n $rid?: string;\n\n /**\n * All the properties.\n *\n * FUTURE: This only handles the primitive types right now. If we want to be able to create\n * objects with some helpers for other types, this will need to be updated.\n */\n [key: string]: string | number | boolean | undefined;\n}\n\nexport class FauxDataStore {\n #objects = new DefaultMap<\n OntologiesV2.ObjectTypeApiName,\n Map<string, BaseServerObject>\n >(\n (key) => new Map(),\n );\n\n #singleLinks = new DefaultMap(\n (_objectLocator: ObjectLocator) =>\n new Map<OntologiesV2.LinkTypeApiName, ObjectLocator>(),\n );\n\n #manyLinks = new DefaultMap(\n (_objectLocator: ObjectLocator) => new MultiMap<string, ObjectLocator>(Set),\n );\n\n #fauxOntology: FauxOntology;\n\n #attachments: FauxAttachmentStore;\n\n #timeSeriesData = new DefaultMap(\n (_objectType: OntologiesV2.ObjectTypeApiName) =>\n new DefaultMap((_pk: string) =>\n new DefaultMap((_property: OntologiesV2.PropertyApiName) =>\n [] as Array<OntologiesV2.TimeSeriesPoint>\n )\n ),\n );\n\n #media = new DefaultMap(\n (_objectType: OntologiesV2.ObjectTypeApiName) =>\n new DefaultMap((_propName: OntologiesV2.PropertyApiName) => {\n return new Map<MediaItemRid, MediaMetadataAndContent>();\n }),\n );\n\n constructor(fauxOntology: FauxOntology, attachments: FauxAttachmentStore) {\n this.#fauxOntology = fauxOntology;\n this.#attachments = attachments;\n }\n\n /**\n * Removes all data that is associated with a namespace/ontology.\n *\n * Note: does not clear `attachments` nor does it clear the ontology itself.\n */\n public clear(): void {\n this.#media.clear();\n this.#timeSeriesData.clear();\n this.#manyLinks.clear();\n this.#singleLinks.clear();\n this.#objects.clear();\n }\n\n get ontology(): FauxOntology {\n return this.#fauxOntology;\n }\n\n #assertObjectExists(\n objectType: string,\n primaryKey: string | number | boolean,\n ) {\n if (!this.getObject(objectType, primaryKey)) {\n throw new OpenApiCallError(\n 404,\n ObjectNotFoundError(objectType, String(primaryKey)),\n );\n }\n }\n\n #assertObjectDoesNotExist(\n objectType: string,\n primaryKey: string | number | boolean,\n ): void {\n if (this.getObject(objectType, primaryKey)) {\n throw new OpenApiCallError(\n 500,\n {\n errorCode: \"CONFLICT\",\n errorName: \"ObjectAlreadyExists\",\n errorInstanceId: \"faux-foundry\",\n parameters: {\n objectType,\n primaryKey: String(primaryKey),\n },\n } satisfies OntologiesV2.ObjectAlreadyExists,\n );\n }\n }\n\n /**\n * Version for use in places like @osdk/client.\n *\n * @param obj An `Osdk.Instance` like object for the ObjectType in the generics\n */\n registerObject<T extends ObjectTypeDefinition>(\n objectType: T,\n obj: ObjectTypeCreatable<T> | ObjectTypeCreatableWithoutApiName<T>,\n ): void;\n /**\n * Version of register object generally used in shared.test\n * @param obj A raw server side representation of an object\n *\n * Don't use, its too easy to end up with an any.\n */\n registerObject(obj: BaseServerObject): void;\n registerObject(\n objectType: string | ObjectTypeDefinition | BaseServerObject,\n anyObj?: BaseServerObject | BaseObjectTypeCreatable,\n ): void {\n let bso: BaseServerObject;\n // obj = { ...obj }; // make a copy so we can mutate it\n\n if (isBaseServerObject(objectType)) {\n invariant(\n anyObj == null,\n \"Internal overload should only pass one argument\",\n );\n invariant(\n !Object.keys(objectType).some(s => s.startsWith(\"$\")),\n \"Object should not have any keys starting with $ if it has __apiName\",\n );\n bso = objectType;\n } else if (anyObj == null) {\n invariant(false, \"should not be possible due to overloads\");\n } else if (isBaseServerObject(anyObj)) {\n invariant(\n !Object.keys(anyObj).some(s => s.startsWith(\"$\")),\n \"Object should not have any keys starting with $ if it has __apiName\",\n );\n bso = anyObj;\n } else {\n bso = this.#osdkCreatableToBso(objectType, anyObj);\n }\n\n const apiName = bso.__apiName || bso.$apiName;\n invariant(apiName, \"Object should have an __apiName or $apiName\");\n\n this.#assertObjectDoesNotExist(apiName, bso.__primaryKey);\n\n if (!(\"__apiName\" in bso && \"__primaryKey\" in bso)) {\n invariant(\n \"$apiName\" in bso && \"$primaryKey\" in bso,\n \"Object should have (__apiName and __primaryKey) or ($apiName and $primaryKey)\",\n );\n const { $apiName, $primaryKey, ...others } = bso as\n & {\n $apiName: OntologiesV2.ObjectTypeApiName;\n $primaryKey: string | number | boolean;\n }\n & Record<\n string,\n unknown\n >;\n bso = {\n __apiName: $apiName,\n __primaryKey: $primaryKey,\n ...others,\n };\n }\n this.#assertObjectDoesNotExist(bso.__apiName, bso.__primaryKey);\n this.#objects.get(bso.__apiName).set(\n String(bso.__primaryKey),\n Object.freeze({ ...bso }),\n );\n }\n\n #osdkCreatableToBso(\n objectType: string | ObjectTypeDefinition,\n anyObj: BaseObjectTypeCreatable,\n ) {\n objectType = typeof objectType === \"string\"\n ? objectType\n : objectType.apiName;\n\n if (\"$apiName\" in anyObj) {\n invariant(anyObj.$apiName === objectType);\n }\n const { $apiName, $primaryKey, ...others } = anyObj;\n\n const meta = this.ontology.getObjectTypeFullMetadataOrThrow(\n objectType,\n );\n const realPrimaryKey = anyObj[meta.objectType.primaryKey] as\n | string\n | number\n | boolean;\n\n const maybeTitle = anyObj[meta.objectType.titleProperty];\n const rid = anyObj.$rid\n ?? `ri.phonograph2-objects.main.object.${crypto.randomUUID()}`;\n\n invariant(\n realPrimaryKey != null,\n `Object should have a primary key. ${JSON.stringify(anyObj)}`,\n );\n\n invariant(\n $primaryKey == null || $primaryKey === realPrimaryKey,\n \"Primary key mismatch\",\n );\n\n return {\n __apiName: objectType,\n __primaryKey: realPrimaryKey,\n __title: maybeTitle ? String(maybeTitle) : undefined,\n __rid: rid,\n ...others,\n };\n }\n\n replaceObjectOrThrow(x: BaseServerObject): void {\n this.#assertObjectExists(x.__apiName, x.__primaryKey);\n this.#objects.get(x.__apiName).set(String(x.__primaryKey), x);\n }\n\n /** Throws if the object does not already exist */\n unregisterObjectOrThrow(\n objectType: string,\n primaryKey: string | number | boolean,\n ): void {\n this.#assertObjectExists(objectType, primaryKey);\n this.#objects.get(objectType).delete(String(primaryKey));\n }\n\n registerLink(\n src: BaseServerObject,\n srcLinkName: string,\n dst: BaseServerObject,\n destLinkName: string,\n ): void {\n const srcLocator = objectLocator(src);\n const dstLocator = objectLocator(dst);\n const [srcSide, dstSide] = this.#fauxOntology.getBothLinkTypeSides(\n src.__apiName,\n srcLinkName,\n dst.__apiName,\n );\n\n invariant(\n srcSide.linkTypeRid === dstSide.linkTypeRid,\n `Expected both sides of the link to have the same rid, but got ${srcSide.linkTypeRid} and ${dstSide.linkTypeRid}`,\n );\n invariant(\n dstSide.apiName === destLinkName,\n `Link name mismatch on dst side. Expected ${destLinkName} but found ${dstSide.apiName}`,\n );\n\n this.#updateSingleLinkSide(\n srcSide,\n srcLocator,\n dstSide,\n dstLocator,\n );\n this.#updateSingleLinkSide(\n dstSide,\n dstLocator,\n srcSide,\n srcLocator,\n );\n }\n\n unregisterLink(\n src: BaseServerObject,\n srcLinkName: string,\n dst: BaseServerObject,\n dstLinkName: string,\n ): void {\n const srcLocator = objectLocator(src);\n const dstLocator = objectLocator(dst);\n const [srcSide, dstSide] = this.#fauxOntology.getBothLinkTypeSides(\n src.__apiName,\n srcLinkName,\n dst.__apiName,\n );\n\n invariant(\n dstSide.apiName === dstLinkName,\n `Link name mismatch on dst side. Expected ${dstLinkName} but found ${dstSide.apiName}`,\n );\n\n this.#removeSingleSideOfLink(srcLocator, srcSide, dstLocator);\n this.#removeSingleSideOfLink(dstLocator, dstSide, srcLocator);\n }\n\n registerTimeSeriesData(\n objectType: OntologiesV2.ObjectTypeApiName,\n primaryKey: string,\n property: OntologiesV2.PropertyApiName,\n data: OntologiesV2.TimeSeriesPoint[],\n ): void {\n this.getObjectOrThrow(objectType, primaryKey);\n const def = this.ontology.getObjectTypeFullMetadataOrThrow(objectType);\n invariant(\n def.objectType.properties[property].dataType.type === \"timeseries\"\n || def.objectType.properties[property].dataType.type\n === \"geotimeSeriesReference\",\n );\n this.#timeSeriesData.get(objectType).get(String(primaryKey)).set(\n property,\n data,\n );\n }\n\n getTimeSeriesData(\n objectType: OntologiesV2.ObjectTypeApiName,\n primaryKey: string,\n property: OntologiesV2.PropertyApiName,\n filter?: OntologiesV2.StreamTimeSeriesPointsRequest,\n ): OntologiesV2.TimeSeriesPoint[] {\n this.getObjectOrThrow(objectType, primaryKey);\n const allData = this.#timeSeriesData.get(objectType).get(String(primaryKey))\n .get(\n property,\n );\n if (!filter) return allData;\n return filterTimeSeriesData(allData, filter);\n }\n\n #updateSingleLinkSide(\n srcSide: OntologiesV2.LinkTypeSideV2,\n srcLocator: ObjectLocator,\n dstSide: OntologiesV2.LinkTypeSideV2,\n dstLocator: ObjectLocator,\n ) {\n const srcLinkName = srcSide.apiName;\n if (srcSide.cardinality === \"ONE\") {\n const linkNameToObj = this.#singleLinks.get(srcLocator);\n const oldLocator = linkNameToObj.get(srcLinkName);\n\n if (oldLocator && oldLocator !== dstLocator) {\n // we need to remove the other side's old value\n this.#removeSingleSideOfLink(\n oldLocator,\n dstSide,\n srcLocator,\n );\n }\n linkNameToObj.set(srcLinkName, dstLocator);\n } else if (srcSide.cardinality === \"MANY\") {\n const linkNameToObj = this.#manyLinks.get(srcLocator);\n linkNameToObj.set(srcLinkName, dstLocator);\n } else {\n // \"never\" case\n throw new Error(\"unexpected cardinality: \" + srcSide.cardinality);\n }\n }\n\n registerMedia(\n objectType: OntologiesV2.ObjectTypeApiName,\n property: OntologiesV2.PropertyApiName,\n content: ArrayBuffer,\n mediaType: MediaType,\n path: string | undefined,\n // This should be the correct prefix, per\n // https://github.com/palantir/osdk-ts/pull/1303#discussion_r2001989395\n mediaItemRid: MediaItemRid = `ri.mio.main.media-item.${randomUUID()}`,\n ): MediaReference {\n const mediaRef: ReadonlyDeep<MediaReference> = Object.freeze({\n mimeType: mediaType,\n reference: Object.freeze({\n type: \"mediaSetViewItem\",\n mediaSetViewItem: Object.freeze({\n mediaItemRid,\n mediaSetRid: \"ri.unimplemented.in.shared.test\",\n mediaSetViewRid: \"ri.unimplemented.in.shared.test\",\n }),\n }),\n });\n\n this.#media.get(objectType).get(property).set(\n mediaItemRid,\n Object.freeze({\n content,\n mediaRef,\n metaData: Object.freeze({\n mediaType,\n path,\n sizeBytes: String(content.byteLength),\n }),\n }),\n );\n\n return mediaRef;\n }\n\n getMediaOrThrow(\n objectType: OntologiesV2.ObjectTypeApiName,\n primaryKey: string,\n property: OntologiesV2.PropertyApiName,\n ): MediaMetadataAndContent {\n const obj = this.getObjectOrThrow(objectType, primaryKey);\n const propertyDef =\n this.ontology.getObjectTypeFullMetadataOrThrow(objectType)\n .objectType.properties[property];\n\n if (!propertyDef) {\n // This should be the correct error, per\n // https://github.com/palantir/osdk-ts/pull/1303#discussion_r2001968959\n throw new OpenApiCallError(\n 400,\n {\n errorCode: \"NOT_FOUND\",\n errorName: \"PropertiesNotFound\",\n errorInstanceId: \"faux-foundry\",\n parameters: {\n objectType,\n properties: [property],\n },\n } satisfies OntologiesV2.PropertiesNotFound,\n );\n }\n\n if (propertyDef.dataType.type !== \"mediaReference\") {\n // FIXME: what would the backend do here?\n throw new OpenApiCallError(\n 400,\n {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"InvalidPropertyType\",\n errorInstanceId: \"faux-foundry\",\n parameters: {\n property,\n propertyBaseType: propertyDef.dataType.type,\n },\n } satisfies OntologiesV2.InvalidPropertyType,\n );\n }\n\n const rid = obj[property].reference.mediaSetViewItem.mediaItemRid;\n\n if (!rid || !rid.startsWith(\"ri.\")) {\n throw new OpenApiCallError(\n 400,\n {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"InvalidPropertyValue\",\n errorInstanceId: \"faux-foundry\",\n parameters: {\n property,\n propertyBaseType: propertyDef.dataType.type,\n propertyValue: rid,\n },\n } satisfies OntologiesV2.InvalidPropertyValue,\n );\n }\n\n const ret = this.#media.get(objectType).get(property).get(rid);\n\n if (!ret) {\n throw new OpenApiCallError(400, InvalidRequest(\"Invalid parameters\"));\n }\n return ret;\n }\n\n #removeSingleSideOfLink(\n locator: ObjectLocator,\n linkSide: OntologiesV2.LinkTypeSideV2,\n expectedPriorValue: ObjectLocator,\n ) {\n const destLinkName = linkSide.apiName;\n if (linkSide.cardinality === \"ONE\") {\n const links = this.#singleLinks.get(locator);\n invariant(links.get(destLinkName) === expectedPriorValue);\n links.delete(destLinkName);\n } else {\n const links = this.#manyLinks.get(locator);\n invariant(links.get(destLinkName)?.has(expectedPriorValue));\n links.remove(destLinkName, expectedPriorValue);\n }\n }\n\n getObject(\n apiName: string,\n primaryKey: string | number | boolean,\n ): BaseServerObject | undefined {\n return this.#objects\n .get(apiName)\n .get(String(primaryKey));\n }\n\n getObjectOrThrow(\n apiName: string,\n primaryKey: string | number | boolean,\n ): BaseServerObject {\n const object = this.getObject(apiName, primaryKey);\n\n if (!object) {\n throw new OpenApiCallError(\n 404,\n ObjectNotFoundError(apiName, String(primaryKey)),\n );\n }\n return object;\n }\n\n getObjectByRid(rid: string): BaseServerObject | undefined {\n for (const [, pkToObjects] of this.#objects) {\n for (const [, obj] of pkToObjects) {\n if (obj.__rid === rid) {\n return obj;\n }\n }\n }\n }\n\n getLinksOrThrow(\n apiName: string,\n primaryKey: string | number | boolean,\n linkApiName: string,\n ): BaseServerObject[] {\n const object = this.getObjectOrThrow(apiName, primaryKey);\n\n const linkTypeSide = this.#fauxOntology.getLinkTypeSideV2(\n apiName,\n linkApiName,\n );\n\n if (linkTypeSide.cardinality === \"ONE\") {\n const locator = this.#singleLinks\n .get(objectLocator(object))\n .get(linkApiName);\n if (locator === undefined) {\n return [];\n }\n const { objectType, primaryKey } = parseLocator(locator);\n\n return [this.getObjectOrThrow(objectType, primaryKey)]; // will throw if not found\n } else {\n const locators = this.#manyLinks\n .get(objectLocator(object))\n .get(linkApiName);\n\n return Array.from(locators ?? [])\n .map((a) => {\n const [objectType, primaryKey] = a.split(\":\") ?? [];\n invariant(objectType && primaryKey, \"Invalid locator format\");\n return this.getObjectOrThrow(objectType, primaryKey);\n });\n }\n }\n\n getLinkOrThrow(\n objectType: string,\n primaryKey: string | number | boolean,\n linkType: string,\n targetPrimaryKey: string | number | boolean,\n ): BaseServerObject {\n const allLinks = this.getLinksOrThrow(objectType, primaryKey, linkType);\n const object =\n allLinks.filter(l => String(l.__primaryKey) === targetPrimaryKey)[0];\n\n if (!object) {\n throw new OpenApiCallError(\n 404,\n ObjectNotFoundError(\n `${objectType} -> ${linkType}`,\n String(targetPrimaryKey),\n ),\n );\n }\n return object;\n }\n\n getObjectsOfType(apiName: string): Iterable<BaseServerObject> {\n return this.#objects\n .get(apiName)\n .values();\n }\n\n getObjectsFromObjectSet(\n parsedBody:\n | OntologiesV2.LoadObjectSetV2MultipleObjectTypesRequest\n | OntologiesV2.LoadObjectSetRequestV2,\n ): PagedBodyResponseWithTotal<BaseServerObject> {\n const selected = parsedBody.select;\n // when we have interfaces in here, we have a little trick for\n // caching off the important properties\n let objects = getObjectsFromSet(this, parsedBody.objectSet, undefined);\n\n if (!objects) {\n return {\n data: [],\n totalCount: \"0\",\n nextPageToken: undefined,\n };\n }\n\n if (parsedBody.orderBy) {\n objects = objects.sort(createOrderBySortFn(parsedBody.orderBy));\n }\n\n // finally, if we got interfaces, the objects have names like the interface and we need\n // to return them like the object.\n\n const page = pageThroughResponseSearchParams(\n objects,\n getPaginationParamsFromRequest(parsedBody),\n false,\n );\n\n if (!page) {\n throw new OpenApiCallError(\n 404,\n InvalidRequest(\n `No objects found for ${JSON.stringify(parsedBody)}`,\n ),\n );\n }\n const ret = subSelectProperties(\n page,\n [...selected],\n true,\n parsedBody.excludeRid,\n );\n\n return ret;\n }\n\n getAttachmentMetadata(\n objectType: string,\n primaryKey: string | number | boolean,\n propertyName: string,\n ): OntologiesV2.AttachmentV2 {\n const rid = this.getObjectOrThrow(objectType, primaryKey)[propertyName];\n return this.#attachments.getAttachmentMetadataByRid(rid);\n }\n\n getAttachmentBuffer(\n objectType: string,\n primaryKey: string | number | boolean,\n propertyName: string,\n ): ArrayBuffer {\n const rid = this.getObjectOrThrow(objectType, primaryKey)[propertyName];\n return this.#attachments.getAttachmentBuffer(rid);\n }\n\n applyAction(\n actionTypeApiName: string,\n req: OntologiesV2.ApplyActionRequestV2,\n ): OntologiesV2.SyncApplyActionResponseV2 {\n const actionDef = this.#fauxOntology.getActionDef(actionTypeApiName);\n const actionImpl = this.#fauxOntology.getActionImpl(actionTypeApiName);\n\n const validation = validateAction(req, actionDef, this);\n if (validation.result === \"INVALID\") {\n return { validation };\n }\n\n const batch = new FauxDataStoreBatch(this);\n const r = actionImpl(batch, req, {\n def: actionDef,\n attachments: this.#attachments,\n });\n\n // The legacy actions return the full payload\n // they want to return, so we need to do that\n // but the future is for the actionImpl's to\n // return void and to do validation details here\n if (r) return r;\n\n return {\n validation: {\n parameters: {},\n result: \"VALID\",\n submissionCriteria: [],\n },\n edits: req.options?.mode === \"VALIDATE_AND_EXECUTE\"\n && (\n req.options.returnEdits === \"ALL\"\n || req.options.returnEdits === \"ALL_V2_WITH_DELETIONS\"\n )\n ? {\n type: \"edits\",\n ...batch.objectEdits,\n }\n : undefined,\n };\n }\n\n batchApplyAction(\n actionTypeApiName: string,\n batchReq: OntologiesV2.BatchApplyActionRequestV2,\n ): OntologiesV2.BatchApplyActionResponseV2 {\n const actionDef = this.#fauxOntology.getActionDef(actionTypeApiName);\n const actionImpl = this.#fauxOntology.getActionImpl(actionTypeApiName);\n\n for (const req of batchReq.requests) {\n const result = validateAction(req, actionDef, this);\n if (result.result === \"INVALID\") {\n throw new OpenApiCallError(\n 500,\n {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"ActionValidationFailed\",\n errorInstanceId: \"faux-foundry\",\n parameters: {\n actionType: actionTypeApiName,\n },\n } as OntologiesV2.ActionValidationFailed,\n );\n }\n }\n\n const batch = new FauxDataStoreBatch(this);\n\n const returnLargeScaleEdits = false;\n for (const item of batchReq.requests) {\n actionImpl(\n batch,\n {\n ...item,\n options: {\n mode: \"VALIDATE_AND_EXECUTE\",\n returnEdits: batchReq.options?.returnEdits,\n },\n },\n { def: actionDef, attachments: this.#attachments },\n );\n }\n if (batchReq.options?.returnEdits === \"NONE\") {\n return {};\n }\n\n if (returnLargeScaleEdits) {\n const editedObjectTypes = new Set<OntologiesV2.ObjectTypeApiName>();\n for (const edit of batch.objectEdits.edits) {\n if (\n edit.type === \"modifyObject\" || edit.type === \"addObject\"\n || edit.type === \"deleteObject\"\n ) {\n editedObjectTypes.add(edit.objectType);\n }\n }\n\n return {\n edits: {\n type: \"largeScaleEdits\",\n editedObjectTypes: Array.from(editedObjectTypes),\n },\n };\n }\n\n return {\n edits: {\n type: \"edits\",\n ...batch.objectEdits,\n edits: batch.objectEdits.edits.filter(x =>\n x.type !== \"deleteObject\" && x.type !== \"deleteLink\"\n ),\n },\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAChD,SAASC,UAAU,QAAQ,aAAa;AACxC,OAAO,KAAKC,MAAM,MAAM,aAAa;AACrC,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,cAAc;AAClE,SAASC,mBAAmB,QAAQ,qBAAqB;AACzD,SAASC,8BAA8B,QAAQ,yCAAyC;AACxF,SAASC,gBAAgB,QAAQ,uCAAuC;AAExE,SAASC,+BAA+B,QAAQ,qDAAqD;AACrG,SAEEC,kBAAkB,QACb,uBAAuB;AAE9B,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,mBAAmB,EAAEC,iBAAi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CAACA;MAAY,CACnD,CAAC;IACH;IACA,IAAIuK,QAAQ,CAACL,OAAO,EAAEE,WAAW,KAAK,MAAM,EAAE;MAC5C,OAAO,CAAC,CAAC;IACX;IAqBA,OAAO;MACLH,KAAK,EAAE;QACLnF,IAAI,EAAE,OAAO;QACb,GAAGgF,KAAK,CAACO,WAAW;QACpBJ,KAAK,EAAEH,KAAK,CAACO,WAAW,CAACJ,KAAK,CAACjF,MAAM,CAAC3B,CAAC,IACrCA,CAAC,CAACyB,IAAI,KAAK,cAAc,IAAIzB,CAAC,CAACyB,IAAI,KAAK,YAC1C;MACF;IACF,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"FauxDataStore.js","names":["DefaultMap","MultiMap","randomUUID","crypto","invariant","InvalidRequest","ObjectNotFoundError","subSelectProperties","getPaginationParamsFromRequest","OpenApiCallError","pageThroughResponseSearchParams","isBaseServerObject","FauxDataStoreBatch","filterTimeSeriesData","createOrderBySortFn","getObjectsFromSet","objectLocator","parseLocator","validateAction","FauxDataStore","objects","Map","singleLinks","manyLinks","Set","fauxOntology","attachments","timeSeriesData","media","constructor","clear","ontology","assertObjectExists","#assertObjectExists","objectType","primaryKey","getObject","String","assertObjectDoesNotExist","#assertObjectDoesNotExist","errorCode","errorName","errorInstanceId","parameters","registerObject","anyObj","bso","process","env","NODE_ENV","Object","keys","some","s","startsWith","osdkCreatableToBso","apiName","__apiName","$apiName","__primaryKey","$primaryKey","others","get","set","freeze","#osdkCreatableToBso","meta","getObjectTypeFullMetadataOrThrow","realPrimaryKey","maybeTitle","titleProperty","rid","$rid","JSON","stringify","__title","undefined","__rid","replaceObjectOrThrow","x","unregisterObjectOrThrow","delete","registerLink","src","srcLinkName","dst","destLinkName","srcLocator","dstLocator","srcSide","dstSide","getBothLinkTypeSides","linkTypeRid","updateSingleLinkSide","unregisterLink","dstLinkName","removeSingleSideOfLink","registerTimeSeriesData","property","data","getObjectOrThrow","def","properties","dataType","type","getTimeSeriesData","filter","allData","#updateSingleLinkSide","cardinality","linkNameToObj","oldLocator","Error","registerMedia","content","mediaType","path","mediaItemRid","mediaRef","mimeType","reference","mediaSetViewItem","mediaSetRid","mediaSetViewRid","metaData","sizeBytes","byteLength","getMediaOrThrow","obj","propertyDef","propertyBaseType","propertyValue","ret","#removeSingleSideOfLink","locator","linkSide","expectedPriorValue","links","has","remove","object","getObjectByRid","pkToObjects","getLinksOrThrow","linkApiName","linkTypeSide","getLinkTypeSideV2","locators","Array","from","map","a","split","getLinkOrThrow","linkType","targetPrimaryKey","allLinks","l","getObjectsOfType","values","getObjectsFromObjectSet","parsedBody","selected","select","objectSet","length","totalCount","nextPageToken","orderBy","sort","page","excludeRid","getAttachmentMetadata","propertyName","getAttachmentMetadataByRid","getAttachmentBuffer","applyAction","actionTypeApiName","req","actionDef","getActionDef","actionImpl","getActionImpl","validation","result","batch","r","submissionCriteria","edits","options","mode","returnEdits","objectEdits","batchApplyAction","batchReq","requests","actionType","item"],"sources":["FauxDataStore.ts"],"sourcesContent":["/*\n * Copyright 2023 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 { CompileTimeMetadata, ObjectTypeDefinition } from \"@osdk/api\";\nimport type {\n MediaItemRid,\n MediaReference,\n MediaType,\n} from \"@osdk/foundry.core\";\nimport type * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { DefaultMap, MultiMap } from \"mnemonist\";\nimport { randomUUID } from \"node:crypto\";\nimport * as crypto from \"node:crypto\";\nimport invariant from \"tiny-invariant\";\nimport type { ReadonlyDeep } from \"type-fest\";\nimport { InvalidRequest, ObjectNotFoundError } from \"../errors.js\";\nimport { subSelectProperties } from \"../filterObjects.js\";\nimport { getPaginationParamsFromRequest } from \"../handlers/util/getPaginationParams.js\";\nimport { OpenApiCallError } from \"../handlers/util/handleOpenApiCall.js\";\nimport type { PagedBodyResponseWithTotal } from \"../handlers/util/pageThroughResponseSearchParams.js\";\nimport { pageThroughResponseSearchParams } from \"../handlers/util/pageThroughResponseSearchParams.js\";\nimport {\n type BaseServerObject,\n isBaseServerObject,\n} from \"./BaseServerObject.js\";\nimport type { FauxAttachmentStore } from \"./FauxAttachmentStore.js\";\nimport { FauxDataStoreBatch } from \"./FauxDataStoreBatch.js\";\nimport type { FauxOntology } from \"./FauxOntology.js\";\nimport { filterTimeSeriesData } from \"./filterTimeSeriesData.js\";\nimport { createOrderBySortFn, getObjectsFromSet } from \"./getObjectsFromSet.js\";\nimport type { ObjectLocator } from \"./ObjectLocator.js\";\nimport { objectLocator, parseLocator } from \"./ObjectLocator.js\";\nimport type { JustProps } from \"./typeHelpers/JustProps.js\";\nimport { validateAction } from \"./validateAction.js\";\n\nexport interface MediaMetadataAndContent {\n content: ArrayBuffer;\n mediaRef: MediaReference;\n metaData: OntologiesV2.MediaMetadata;\n}\n\ntype ObjectTypeCreatableWithoutApiName<T extends ObjectTypeDefinition> =\n OrUndefinedToOptional<JustProps<T>>;\n\n/**\n * Represents the properties needed to create an object, specifically,\n * the properties of the object and the $apiName\n */\ntype ObjectTypeCreatable<T extends ObjectTypeDefinition> =\n & ObjectTypeCreatableWithoutApiName<T>\n & { $apiName: CompileTimeMetadata<T>[\"apiName\"] };\n\n/**\n * Helper type for converting `foo: string | undefined` into `foo?: string`\n */\ntype OrUndefinedToOptional<T extends object> =\n & {\n [K in keyof T as T[K] extends undefined ? K : never]?: T[K];\n }\n & {\n [K in keyof T as T[K] extends undefined ? never : K]?: T[K];\n };\n\n/**\n * Type safe object for representing \"client\" side objects.\n */\ninterface BaseObjectTypeCreatable {\n $apiName?: OntologiesV2.ObjectTypeApiName;\n\n /** if present it must match the correct value */\n $primaryKey?: string | number | boolean;\n\n /** If set, will use the as the $rid for the object, otherwise one is created for you */\n $rid?: string;\n\n /**\n * All the properties.\n *\n * FUTURE: This only handles the primitive types right now. If we want to be able to create\n * objects with some helpers for other types, this will need to be updated.\n */\n [key: string]: string | number | boolean | undefined;\n}\n\nexport class FauxDataStore {\n #objects = new DefaultMap<\n OntologiesV2.ObjectTypeApiName,\n Map<string, BaseServerObject>\n >(\n (key) => new Map(),\n );\n\n #singleLinks = new DefaultMap(\n (_objectLocator: ObjectLocator) =>\n new Map<OntologiesV2.LinkTypeApiName, ObjectLocator>(),\n );\n\n #manyLinks = new DefaultMap(\n (_objectLocator: ObjectLocator) => new MultiMap<string, ObjectLocator>(Set),\n );\n\n #fauxOntology: FauxOntology;\n\n #attachments: FauxAttachmentStore;\n\n #timeSeriesData = new DefaultMap(\n (_objectType: OntologiesV2.ObjectTypeApiName) =>\n new DefaultMap((_pk: string) =>\n new DefaultMap((_property: OntologiesV2.PropertyApiName) =>\n [] as Array<OntologiesV2.TimeSeriesPoint>\n )\n ),\n );\n\n #media = new DefaultMap(\n (_objectType: OntologiesV2.ObjectTypeApiName) =>\n new DefaultMap((_propName: OntologiesV2.PropertyApiName) => {\n return new Map<MediaItemRid, MediaMetadataAndContent>();\n }),\n );\n\n constructor(fauxOntology: FauxOntology, attachments: FauxAttachmentStore) {\n this.#fauxOntology = fauxOntology;\n this.#attachments = attachments;\n }\n\n /**\n * Removes all data that is associated with a namespace/ontology.\n *\n * Note: does not clear `attachments` nor does it clear the ontology itself.\n */\n public clear(): void {\n this.#media.clear();\n this.#timeSeriesData.clear();\n this.#manyLinks.clear();\n this.#singleLinks.clear();\n this.#objects.clear();\n }\n\n get ontology(): FauxOntology {\n return this.#fauxOntology;\n }\n\n #assertObjectExists(\n objectType: string,\n primaryKey: string | number | boolean,\n ) {\n if (!this.getObject(objectType, primaryKey)) {\n throw new OpenApiCallError(\n 404,\n ObjectNotFoundError(objectType, String(primaryKey)),\n );\n }\n }\n\n #assertObjectDoesNotExist(\n objectType: string,\n primaryKey: string | number | boolean,\n ): void {\n if (this.getObject(objectType, primaryKey)) {\n throw new OpenApiCallError(\n 500,\n {\n errorCode: \"CONFLICT\",\n errorName: \"ObjectAlreadyExists\",\n errorInstanceId: \"faux-foundry\",\n parameters: {\n objectType,\n primaryKey: String(primaryKey),\n },\n } satisfies OntologiesV2.ObjectAlreadyExists,\n );\n }\n }\n\n /**\n * Version for use in places like @osdk/client.\n *\n * @param obj An `Osdk.Instance` like object for the ObjectType in the generics\n */\n registerObject<T extends ObjectTypeDefinition>(\n objectType: T,\n obj: ObjectTypeCreatable<T> | ObjectTypeCreatableWithoutApiName<T>,\n ): void;\n /**\n * Version of register object generally used in shared.test\n * @param obj A raw server side representation of an object\n *\n * Don't use, its too easy to end up with an any.\n */\n registerObject(obj: BaseServerObject): void;\n registerObject(\n objectType: string | ObjectTypeDefinition | BaseServerObject,\n anyObj?: BaseServerObject | BaseObjectTypeCreatable,\n ): void {\n let bso: BaseServerObject;\n // obj = { ...obj }; // make a copy so we can mutate it\n\n if (isBaseServerObject(objectType)) {\n invariant(\n anyObj == null,\n \"Internal overload should only pass one argument\",\n );\n invariant(\n !Object.keys(objectType).some(s => s.startsWith(\"$\")),\n \"Object should not have any keys starting with $ if it has __apiName\",\n );\n bso = objectType;\n } else if (anyObj == null) {\n invariant(false, \"should not be possible due to overloads\");\n } else if (isBaseServerObject(anyObj)) {\n invariant(\n !Object.keys(anyObj).some(s => s.startsWith(\"$\")),\n \"Object should not have any keys starting with $ if it has __apiName\",\n );\n bso = anyObj;\n } else {\n bso = this.#osdkCreatableToBso(objectType, anyObj);\n }\n\n const apiName = bso.__apiName || bso.$apiName;\n invariant(apiName, \"Object should have an __apiName or $apiName\");\n\n this.#assertObjectDoesNotExist(apiName, bso.__primaryKey);\n\n if (!(\"__apiName\" in bso && \"__primaryKey\" in bso)) {\n invariant(\n \"$apiName\" in bso && \"$primaryKey\" in bso,\n \"Object should have (__apiName and __primaryKey) or ($apiName and $primaryKey)\",\n );\n const { $apiName, $primaryKey, ...others } = bso as\n & {\n $apiName: OntologiesV2.ObjectTypeApiName;\n $primaryKey: string | number | boolean;\n }\n & Record<\n string,\n unknown\n >;\n bso = {\n __apiName: $apiName,\n __primaryKey: $primaryKey,\n ...others,\n };\n }\n this.#assertObjectDoesNotExist(bso.__apiName, bso.__primaryKey);\n this.#objects.get(bso.__apiName).set(\n String(bso.__primaryKey),\n Object.freeze({ ...bso }),\n );\n }\n\n #osdkCreatableToBso(\n objectType: string | ObjectTypeDefinition,\n anyObj: BaseObjectTypeCreatable,\n ) {\n objectType = typeof objectType === \"string\"\n ? objectType\n : objectType.apiName;\n\n if (\"$apiName\" in anyObj) {\n invariant(anyObj.$apiName === objectType);\n }\n const { $apiName, $primaryKey, ...others } = anyObj;\n\n const meta = this.ontology.getObjectTypeFullMetadataOrThrow(\n objectType,\n );\n const realPrimaryKey = anyObj[meta.objectType.primaryKey] as\n | string\n | number\n | boolean;\n\n const maybeTitle = anyObj[meta.objectType.titleProperty];\n const rid = anyObj.$rid\n ?? `ri.phonograph2-objects.main.object.${crypto.randomUUID()}`;\n\n invariant(\n realPrimaryKey != null,\n `Object should have a primary key. ${JSON.stringify(anyObj)}`,\n );\n\n invariant(\n $primaryKey == null || $primaryKey === realPrimaryKey,\n \"Primary key mismatch\",\n );\n\n return {\n __apiName: objectType,\n __primaryKey: realPrimaryKey,\n __title: maybeTitle ? String(maybeTitle) : undefined,\n __rid: rid,\n ...others,\n };\n }\n\n replaceObjectOrThrow(x: BaseServerObject): void {\n this.#assertObjectExists(x.__apiName, x.__primaryKey);\n this.#objects.get(x.__apiName).set(String(x.__primaryKey), x);\n }\n\n /** Throws if the object does not already exist */\n unregisterObjectOrThrow(\n objectType: string,\n primaryKey: string | number | boolean,\n ): void {\n this.#assertObjectExists(objectType, primaryKey);\n this.#objects.get(objectType).delete(String(primaryKey));\n }\n\n registerLink(\n src: BaseServerObject,\n srcLinkName: string,\n dst: BaseServerObject,\n destLinkName: string,\n ): void {\n const srcLocator = objectLocator(src);\n const dstLocator = objectLocator(dst);\n const [srcSide, dstSide] = this.#fauxOntology.getBothLinkTypeSides(\n src.__apiName,\n srcLinkName,\n dst.__apiName,\n );\n\n invariant(\n srcSide.linkTypeRid === dstSide.linkTypeRid,\n `Expected both sides of the link to have the same rid, but got ${srcSide.linkTypeRid} and ${dstSide.linkTypeRid}`,\n );\n invariant(\n dstSide.apiName === destLinkName,\n `Link name mismatch on dst side. Expected ${destLinkName} but found ${dstSide.apiName}`,\n );\n\n this.#updateSingleLinkSide(\n srcSide,\n srcLocator,\n dstSide,\n dstLocator,\n );\n this.#updateSingleLinkSide(\n dstSide,\n dstLocator,\n srcSide,\n srcLocator,\n );\n }\n\n unregisterLink(\n src: BaseServerObject,\n srcLinkName: string,\n dst: BaseServerObject,\n dstLinkName: string,\n ): void {\n const srcLocator = objectLocator(src);\n const dstLocator = objectLocator(dst);\n const [srcSide, dstSide] = this.#fauxOntology.getBothLinkTypeSides(\n src.__apiName,\n srcLinkName,\n dst.__apiName,\n );\n\n invariant(\n dstSide.apiName === dstLinkName,\n `Link name mismatch on dst side. Expected ${dstLinkName} but found ${dstSide.apiName}`,\n );\n\n this.#removeSingleSideOfLink(srcLocator, srcSide, dstLocator);\n this.#removeSingleSideOfLink(dstLocator, dstSide, srcLocator);\n }\n\n registerTimeSeriesData(\n objectType: OntologiesV2.ObjectTypeApiName,\n primaryKey: string,\n property: OntologiesV2.PropertyApiName,\n data: OntologiesV2.TimeSeriesPoint[],\n ): void {\n this.getObjectOrThrow(objectType, primaryKey);\n const def = this.ontology.getObjectTypeFullMetadataOrThrow(objectType);\n invariant(\n def.objectType.properties[property].dataType.type === \"timeseries\"\n || def.objectType.properties[property].dataType.type\n === \"geotimeSeriesReference\",\n );\n this.#timeSeriesData.get(objectType).get(String(primaryKey)).set(\n property,\n data,\n );\n }\n\n getTimeSeriesData(\n objectType: OntologiesV2.ObjectTypeApiName,\n primaryKey: string,\n property: OntologiesV2.PropertyApiName,\n filter?: OntologiesV2.StreamTimeSeriesPointsRequest,\n ): OntologiesV2.TimeSeriesPoint[] {\n this.getObjectOrThrow(objectType, primaryKey);\n const allData = this.#timeSeriesData.get(objectType).get(String(primaryKey))\n .get(\n property,\n );\n if (!filter) return allData;\n return filterTimeSeriesData(allData, filter);\n }\n\n #updateSingleLinkSide(\n srcSide: OntologiesV2.LinkTypeSideV2,\n srcLocator: ObjectLocator,\n dstSide: OntologiesV2.LinkTypeSideV2,\n dstLocator: ObjectLocator,\n ) {\n const srcLinkName = srcSide.apiName;\n if (srcSide.cardinality === \"ONE\") {\n const linkNameToObj = this.#singleLinks.get(srcLocator);\n const oldLocator = linkNameToObj.get(srcLinkName);\n\n if (oldLocator && oldLocator !== dstLocator) {\n // we need to remove the other side's old value\n this.#removeSingleSideOfLink(\n oldLocator,\n dstSide,\n srcLocator,\n );\n }\n linkNameToObj.set(srcLinkName, dstLocator);\n } else if (srcSide.cardinality === \"MANY\") {\n const linkNameToObj = this.#manyLinks.get(srcLocator);\n linkNameToObj.set(srcLinkName, dstLocator);\n } else {\n // \"never\" case\n throw new Error(\"unexpected cardinality: \" + srcSide.cardinality);\n }\n }\n\n registerMedia(\n objectType: OntologiesV2.ObjectTypeApiName,\n property: OntologiesV2.PropertyApiName,\n content: ArrayBuffer,\n mediaType: MediaType,\n path: string | undefined,\n // This should be the correct prefix, per\n // https://github.com/palantir/osdk-ts/pull/1303#discussion_r2001989395\n mediaItemRid: MediaItemRid = `ri.mio.main.media-item.${randomUUID()}`,\n ): MediaReference {\n const mediaRef: ReadonlyDeep<MediaReference> = Object.freeze({\n mimeType: mediaType,\n reference: Object.freeze({\n type: \"mediaSetViewItem\",\n mediaSetViewItem: Object.freeze({\n mediaItemRid,\n mediaSetRid: \"ri.unimplemented.in.shared.test\",\n mediaSetViewRid: \"ri.unimplemented.in.shared.test\",\n }),\n }),\n });\n\n this.#media.get(objectType).get(property).set(\n mediaItemRid,\n Object.freeze({\n content,\n mediaRef,\n metaData: Object.freeze({\n mediaType,\n path,\n sizeBytes: String(content.byteLength),\n }),\n }),\n );\n\n return mediaRef;\n }\n\n getMediaOrThrow(\n objectType: OntologiesV2.ObjectTypeApiName,\n primaryKey: string,\n property: OntologiesV2.PropertyApiName,\n ): MediaMetadataAndContent {\n const obj = this.getObjectOrThrow(objectType, primaryKey);\n const propertyDef =\n this.ontology.getObjectTypeFullMetadataOrThrow(objectType)\n .objectType.properties[property];\n\n if (!propertyDef) {\n // This should be the correct error, per\n // https://github.com/palantir/osdk-ts/pull/1303#discussion_r2001968959\n throw new OpenApiCallError(\n 400,\n {\n errorCode: \"NOT_FOUND\",\n errorName: \"PropertiesNotFound\",\n errorInstanceId: \"faux-foundry\",\n parameters: {\n objectType,\n properties: [property],\n },\n } satisfies OntologiesV2.PropertiesNotFound,\n );\n }\n\n if (propertyDef.dataType.type !== \"mediaReference\") {\n // FIXME: what would the backend do here?\n throw new OpenApiCallError(\n 400,\n {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"InvalidPropertyType\",\n errorInstanceId: \"faux-foundry\",\n parameters: {\n property,\n propertyBaseType: propertyDef.dataType.type,\n },\n } satisfies OntologiesV2.InvalidPropertyType,\n );\n }\n\n const rid = obj[property].reference.mediaSetViewItem.mediaItemRid;\n\n if (!rid || !rid.startsWith(\"ri.\")) {\n throw new OpenApiCallError(\n 400,\n {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"InvalidPropertyValue\",\n errorInstanceId: \"faux-foundry\",\n parameters: {\n property,\n propertyBaseType: propertyDef.dataType.type,\n propertyValue: rid,\n },\n } satisfies OntologiesV2.InvalidPropertyValue,\n );\n }\n\n const ret = this.#media.get(objectType).get(property).get(rid);\n\n if (!ret) {\n throw new OpenApiCallError(400, InvalidRequest(\"Invalid parameters\"));\n }\n return ret;\n }\n\n #removeSingleSideOfLink(\n locator: ObjectLocator,\n linkSide: OntologiesV2.LinkTypeSideV2,\n expectedPriorValue: ObjectLocator,\n ) {\n const destLinkName = linkSide.apiName;\n if (linkSide.cardinality === \"ONE\") {\n const links = this.#singleLinks.get(locator);\n invariant(links.get(destLinkName) === expectedPriorValue);\n links.delete(destLinkName);\n } else {\n const links = this.#manyLinks.get(locator);\n invariant(links.get(destLinkName)?.has(expectedPriorValue));\n links.remove(destLinkName, expectedPriorValue);\n }\n }\n\n getObject(\n apiName: string,\n primaryKey: string | number | boolean,\n ): BaseServerObject | undefined {\n return this.#objects\n .get(apiName)\n .get(String(primaryKey));\n }\n\n getObjectOrThrow(\n apiName: string,\n primaryKey: string | number | boolean,\n ): BaseServerObject {\n const object = this.getObject(apiName, primaryKey);\n\n if (!object) {\n throw new OpenApiCallError(\n 404,\n ObjectNotFoundError(apiName, String(primaryKey)),\n );\n }\n return object;\n }\n\n getObjectByRid(rid: string): BaseServerObject | undefined {\n for (const [, pkToObjects] of this.#objects) {\n for (const [, obj] of pkToObjects) {\n if (obj.__rid === rid) {\n return obj;\n }\n }\n }\n }\n\n getLinksOrThrow(\n apiName: string,\n primaryKey: string | number | boolean,\n linkApiName: string,\n ): BaseServerObject[] {\n const object = this.getObjectOrThrow(apiName, primaryKey);\n\n const linkTypeSide = this.#fauxOntology.getLinkTypeSideV2(\n apiName,\n linkApiName,\n );\n\n if (linkTypeSide.cardinality === \"ONE\") {\n const locator = this.#singleLinks\n .get(objectLocator(object))\n .get(linkApiName);\n if (locator === undefined) {\n return [];\n }\n const { objectType, primaryKey } = parseLocator(locator);\n\n return [this.getObjectOrThrow(objectType, primaryKey)]; // will throw if not found\n } else {\n const locators = this.#manyLinks\n .get(objectLocator(object))\n .get(linkApiName);\n\n return Array.from(locators ?? [])\n .map((a) => {\n const [objectType, primaryKey] = a.split(\":\") ?? [];\n invariant(objectType && primaryKey, \"Invalid locator format\");\n return this.getObjectOrThrow(objectType, primaryKey);\n });\n }\n }\n\n getLinkOrThrow(\n objectType: string,\n primaryKey: string | number | boolean,\n linkType: string,\n targetPrimaryKey: string | number | boolean,\n ): BaseServerObject {\n const allLinks = this.getLinksOrThrow(objectType, primaryKey, linkType);\n const object =\n allLinks.filter(l => String(l.__primaryKey) === targetPrimaryKey)[0];\n\n if (!object) {\n throw new OpenApiCallError(\n 404,\n ObjectNotFoundError(\n `${objectType} -> ${linkType}`,\n String(targetPrimaryKey),\n ),\n );\n }\n return object;\n }\n\n getObjectsOfType(apiName: string): Iterable<BaseServerObject> {\n this.ontology.getObjectTypeFullMetadataOrThrow(apiName);\n return this.#objects\n .get(apiName)\n .values();\n }\n\n getObjectsFromObjectSet(\n parsedBody:\n | OntologiesV2.LoadObjectSetV2MultipleObjectTypesRequest\n | OntologiesV2.LoadObjectSetRequestV2,\n ): PagedBodyResponseWithTotal<BaseServerObject> {\n const selected = parsedBody.select;\n // when we have interfaces in here, we have a little trick for\n // caching off the important properties\n let objects = getObjectsFromSet(this, parsedBody.objectSet, undefined);\n\n if (!objects || objects.length === 0) {\n return {\n data: [],\n totalCount: \"0\",\n nextPageToken: undefined,\n };\n }\n\n if (parsedBody.orderBy) {\n objects = objects.sort(createOrderBySortFn(parsedBody.orderBy));\n }\n\n // finally, if we got interfaces, the objects have names like the interface and we need\n // to return them like the object.\n\n const page = pageThroughResponseSearchParams(\n objects,\n getPaginationParamsFromRequest(parsedBody),\n false,\n );\n\n if (!page) {\n throw new OpenApiCallError(\n 404,\n InvalidRequest(\n `No objects found for ${JSON.stringify(parsedBody)}`,\n ),\n );\n }\n const ret = subSelectProperties(\n page,\n [...selected],\n true,\n parsedBody.excludeRid,\n );\n\n return ret;\n }\n\n getAttachmentMetadata(\n objectType: string,\n primaryKey: string | number | boolean,\n propertyName: string,\n ): OntologiesV2.AttachmentV2 {\n const rid = this.getObjectOrThrow(objectType, primaryKey)[propertyName];\n return this.#attachments.getAttachmentMetadataByRid(rid);\n }\n\n getAttachmentBuffer(\n objectType: string,\n primaryKey: string | number | boolean,\n propertyName: string,\n ): ArrayBuffer {\n const rid = this.getObjectOrThrow(objectType, primaryKey)[propertyName];\n return this.#attachments.getAttachmentBuffer(rid);\n }\n\n applyAction(\n actionTypeApiName: string,\n req: OntologiesV2.ApplyActionRequestV2,\n ): OntologiesV2.SyncApplyActionResponseV2 {\n const actionDef = this.#fauxOntology.getActionDef(actionTypeApiName);\n const actionImpl = this.#fauxOntology.getActionImpl(actionTypeApiName);\n\n const validation = validateAction(req, actionDef, this);\n if (validation.result === \"INVALID\") {\n return { validation };\n }\n\n const batch = new FauxDataStoreBatch(this);\n const r = actionImpl(batch, req, {\n def: actionDef,\n attachments: this.#attachments,\n });\n\n // The legacy actions return the full payload\n // they want to return, so we need to do that\n // but the future is for the actionImpl's to\n // return void and to do validation details here\n if (r) return r;\n\n return {\n validation: {\n parameters: {},\n result: \"VALID\",\n submissionCriteria: [],\n },\n edits: req.options?.mode === \"VALIDATE_AND_EXECUTE\"\n && (\n req.options.returnEdits === \"ALL\"\n || req.options.returnEdits === \"ALL_V2_WITH_DELETIONS\"\n )\n ? {\n type: \"edits\",\n ...batch.objectEdits,\n }\n : undefined,\n };\n }\n\n batchApplyAction(\n actionTypeApiName: string,\n batchReq: OntologiesV2.BatchApplyActionRequestV2,\n ): OntologiesV2.BatchApplyActionResponseV2 {\n const actionDef = this.#fauxOntology.getActionDef(actionTypeApiName);\n const actionImpl = this.#fauxOntology.getActionImpl(actionTypeApiName);\n\n for (const req of batchReq.requests) {\n const result = validateAction(req, actionDef, this);\n if (result.result === \"INVALID\") {\n throw new OpenApiCallError(\n 500,\n {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"ActionValidationFailed\",\n errorInstanceId: \"faux-foundry\",\n parameters: {\n actionType: actionTypeApiName,\n },\n } as OntologiesV2.ActionValidationFailed,\n );\n }\n }\n\n const batch = new FauxDataStoreBatch(this);\n\n const returnLargeScaleEdits = false;\n for (const item of batchReq.requests) {\n actionImpl(\n batch,\n {\n ...item,\n options: {\n mode: \"VALIDATE_AND_EXECUTE\",\n returnEdits: batchReq.options?.returnEdits,\n },\n },\n { def: actionDef, attachments: this.#attachments },\n );\n }\n if (batchReq.options?.returnEdits === \"NONE\") {\n return {};\n }\n\n if (returnLargeScaleEdits) {\n const editedObjectTypes = new Set<OntologiesV2.ObjectTypeApiName>();\n for (const edit of batch.objectEdits.edits) {\n if (\n edit.type === \"modifyObject\" || edit.type === \"addObject\"\n || edit.type === \"deleteObject\"\n ) {\n editedObjectTypes.add(edit.objectType);\n }\n }\n\n return {\n edits: {\n type: \"largeScaleEdits\",\n editedObjectTypes: Array.from(editedObjectTypes),\n },\n };\n }\n\n return {\n edits: {\n type: \"edits\",\n ...batch.objectEdits,\n edits: batch.objectEdits.edits.filter(x =>\n x.type !== \"deleteObject\" && x.type !== \"deleteLink\"\n ),\n },\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,UAAU,EAAEC,QAAQ,QAAQ,WAAW;AAChD,SAASC,UAAU,QAAQ,aAAa;AACxC,OAAO,KAAKC,MAAM,MAAM,aAAa;AACrC,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SAASC,cAAc,EAAEC,mBAAmB,QAAQ,cAAc;AAClE,SAASC,mBAAmB,QAAQ,qBAAqB;AACzD,SAASC,8BAA8B,QAAQ,yCAAyC;AACxF,SAASC,gBAAgB,QAAQ,uCAAuC;AAExE,SAASC,+BAA+B,QAAQ,qDAAqD;AACrG,SAEEC,kBAAkB,QACb,uBAAuB;AAE9B,SAASC,kBAAkB,QAAQ,yBAAyB;AAE5D,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,mBAAmB,EAAEC,iBAAiB,QAAQ,wBAAwB;AAE/E,SAASC,aAAa,EAAEC,YAAY,QAAQ,oBAAoB;AAEhE,SAASC,cAAc,QAAQ,qBAAqB;;AAWpD;AACA;AACA;AACA;;AAKA;AACA;AACA;;AASA;AACA;AACA;;AAmBA,OAAO,MAAMC,aAAa,CAAC;EACzB,CA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,OAAO,CAAC,CAAC;IACX;IAqBA,OAAO;MACLH,KAAK,EAAE;QACLpF,IAAI,EAAE,OAAO;QACb,GAAGiF,KAAK,CAACO,WAAW;QACpBJ,KAAK,EAAEH,KAAK,CAACO,WAAW,CAACJ,KAAK,CAAClF,MAAM,CAAC3B,CAAC,IACrCA,CAAC,CAACyB,IAAI,KAAK,cAAc,IAAIzB,CAAC,CAACyB,IAAI,KAAK,YAC1C;MACF;IACF,CAAC;EACH;AACF","ignoreList":[]}
@@ -36,6 +36,9 @@ export class FauxDataStoreBatch {
36
36
  getObject = (objectType, primaryKey) => {
37
37
  return this.#fauxDataStore.getObjectOrThrow(objectType, primaryKey);
38
38
  };
39
+ getObjects = objectType => {
40
+ return this.#fauxDataStore.getObjectsOfType(objectType);
41
+ };
39
42
  addObject(objectType, primaryKey, object) {
40
43
  const existingObject = this.#fauxDataStore.getObject(objectType, primaryKey);
41
44
  if (existingObject) {
@@ -1 +1 @@
1
- {"version":3,"file":"FauxDataStoreBatch.js","names":["deepEqual","OpenApiCallError","FauxDataStoreBatch","fauxDataStore","objectEdits","addedLinksCount","addedObjectCount","deletedLinksCount","deletedObjectsCount","modifiedObjectsCount","edits","constructor","getObject","objectType","primaryKey","getObjectOrThrow","addObject","object","existingObject","errorCode","errorName","errorInstanceId","parameters","fullMetadata","ontology","getObjectTypeFullMetadataOrThrow","registerObject","__apiName","__primaryKey","push","type","modifyObject","update","origObj","newObj","replaceObjectOrThrow","deleteObject","unregisterObjectOrThrow","addLink","leftObjectType","leftPrimaryKey","leftLinkName","rightObjectType","rightPrimaryKey","leftTypeSideV2","rightTypeSideV2","getBothLinkTypeSides","registerLink","apiName","aSideObject","bSideObject","linkTypeApiNameAtoB","linkTypeApiNameBtoA","removeLink","unregisterLink"],"sources":["FauxDataStoreBatch.ts"],"sourcesContent":["/*\n * Copyright 2023 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 CompileTimeMetadata,\n ObjectTypeDefinition,\n PrimaryKeyType,\n} from \"@osdk/api\";\nimport type * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport deepEqual from \"fast-deep-equal\";\nimport { OpenApiCallError } from \"../handlers/util/handleOpenApiCall.js\";\nimport type { BaseServerObject } from \"./BaseServerObject.js\";\nimport type { FauxDataStore } from \"./FauxDataStore.js\";\nimport type { JustProps } from \"./typeHelpers/JustProps.js\";\n\n/**\n * This is separate from the FauxDataStore so that we can in the future support\n * this not-committing on errors. That functionality just does not exist at the moment\n */\nexport class FauxDataStoreBatch {\n #fauxDataStore: FauxDataStore;\n objectEdits: OntologiesV2.ObjectEdits = {\n addedLinksCount: 0,\n addedObjectCount: 0,\n deletedLinksCount: 0,\n deletedObjectsCount: 0,\n modifiedObjectsCount: 0,\n edits: [],\n };\n\n constructor(fauxDataStore: FauxDataStore) {\n this.#fauxDataStore = fauxDataStore;\n }\n\n getObject = (\n objectType: string,\n primaryKey: string | number | boolean,\n ): BaseServerObject => {\n return this.#fauxDataStore.getObjectOrThrow(\n objectType,\n primaryKey,\n );\n };\n\n public addObject<T extends ObjectTypeDefinition>(\n objectType: T[\"apiName\"],\n primaryKey: PrimaryKeyType<T>,\n update: Omit<JustProps<T>, CompileTimeMetadata<T>[\"primaryKeyApiName\"]>,\n ): void;\n public addObject(\n objectType: string,\n primaryKey: string | number | boolean,\n object: BaseServerObject,\n ): void;\n public addObject(\n objectType: string,\n primaryKey: string | number | boolean,\n object: BaseServerObject,\n ): void {\n const existingObject = this.#fauxDataStore.getObject(\n objectType,\n primaryKey,\n );\n if (existingObject) {\n throw new OpenApiCallError(\n 500,\n {\n errorCode: \"CONFLICT\",\n errorName: \"ObjectAlreadyExists\",\n errorInstanceId: \"\",\n parameters: {\n objectType,\n primaryKey,\n },\n } satisfies OntologiesV2.ObjectAlreadyExists,\n );\n }\n\n const fullMetadata = this.#fauxDataStore.ontology\n .getObjectTypeFullMetadataOrThrow(objectType);\n\n this.#fauxDataStore.registerObject({\n ...object,\n __apiName: objectType,\n __primaryKey: primaryKey,\n [fullMetadata.objectType.primaryKey]: primaryKey,\n });\n this.objectEdits.edits.push({\n type: \"addObject\",\n primaryKey,\n objectType,\n });\n this.objectEdits.addedObjectCount += 1;\n }\n\n public modifyObject<T extends ObjectTypeDefinition>(\n objectType: T[\"apiName\"],\n primaryKey: PrimaryKeyType<T>,\n update: Partial<JustProps<T>>,\n ): void;\n public modifyObject(\n objectType: string,\n primaryKey: string | number | boolean,\n update: Partial<BaseServerObject>,\n ): void;\n public modifyObject(\n objectType: string,\n primaryKey: string | number | boolean,\n update: Partial<BaseServerObject>,\n ): void {\n const origObj = this.#fauxDataStore.getObjectOrThrow(\n objectType,\n primaryKey,\n );\n const newObj = {\n ...origObj,\n ...update,\n };\n\n if (!deepEqual(origObj, newObj)) {\n this.#fauxDataStore.replaceObjectOrThrow(newObj);\n this.objectEdits.edits.push({\n type: \"modifyObject\",\n primaryKey,\n objectType,\n });\n this.objectEdits.modifiedObjectsCount += 1;\n }\n }\n\n deleteObject = (\n objectType: string,\n primaryKey: string | number | boolean,\n ): void => {\n this.#fauxDataStore.unregisterObjectOrThrow(objectType, primaryKey);\n this.objectEdits.edits.push({\n type: \"deleteObject\",\n objectType,\n primaryKey: primaryKey,\n });\n };\n\n addLink = (\n leftObjectType: string,\n leftPrimaryKey: string | number | boolean,\n leftLinkName: string,\n rightObjectType: string,\n rightPrimaryKey: string | number | boolean,\n ): void => {\n const [leftTypeSideV2, rightTypeSideV2] = this.#fauxDataStore.ontology\n .getBothLinkTypeSides(\n leftObjectType,\n leftLinkName,\n rightObjectType,\n );\n\n this.#fauxDataStore.registerLink(\n { __apiName: leftObjectType, __primaryKey: leftPrimaryKey },\n leftTypeSideV2.apiName,\n { __apiName: rightObjectType, __primaryKey: rightPrimaryKey },\n rightTypeSideV2.apiName,\n );\n\n this.objectEdits.edits.push({\n type: \"addLink\",\n aSideObject: {\n objectType: leftObjectType,\n primaryKey: leftPrimaryKey,\n },\n bSideObject: {\n objectType: rightObjectType,\n primaryKey: rightPrimaryKey,\n },\n linkTypeApiNameAtoB: leftLinkName,\n linkTypeApiNameBtoA: rightTypeSideV2.apiName,\n });\n\n this.objectEdits.addedLinksCount += 1;\n };\n\n removeLink = (\n leftObjectType: string,\n leftPrimaryKey: string | number | boolean,\n leftLinkName: string,\n rightObjectType: string,\n rightPrimaryKey: string | number | boolean,\n ): void => {\n const [leftTypeSideV2, rightTypeSideV2] = this.#fauxDataStore.ontology\n .getBothLinkTypeSides(\n leftObjectType,\n leftLinkName,\n rightObjectType,\n );\n\n this.#fauxDataStore.unregisterLink(\n { __apiName: leftObjectType, __primaryKey: leftPrimaryKey },\n leftTypeSideV2.apiName,\n { __apiName: rightObjectType, __primaryKey: rightPrimaryKey },\n rightTypeSideV2.apiName,\n );\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,SAAS,MAAM,iBAAiB;AACvC,SAASC,gBAAgB,QAAQ,uCAAuC;AAKxE;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,CAAC;EAC9B,CAACC,aAAa;EACdC,WAAW,GAA6B;IACtCC,eAAe,EAAE,CAAC;IAClBC,gBAAgB,EAAE,CAAC;IACnBC,iBAAiB,EAAE,CAAC;IACpBC,mBAAmB,EAAE,CAAC;IACtBC,oBAAoB,EAAE,CAAC;IACvBC,KAAK,EAAE;EACT,CAAC;EAEDC,WAAWA,CAACR,aAA4B,EAAE;IACxC,IAAI,CAAC,CAACA,aAAa,GAAGA,aAAa;EACrC;EAE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AU,EAAE6B,eAAe;QAC3B5B,UAAU,EAAE6B;MACd,CAAC;MACDQ,mBAAmB,EAAEV,YAAY;MACjCW,mBAAmB,EAAEP,eAAe,CAACG;IACvC,CAAC,CAAC;IAEF,IAAI,CAAC5C,WAAW,CAACC,eAAe,IAAI,CAAC;EACvC,CAAC;EAEDgD,UAAU,GAAGA,CACXd,cAAsB,EACtBC,cAAyC,EACzCC,YAAoB,EACpBC,eAAuB,EACvBC,eAA0C,KACjC;IACT,MAAM,CAACC,cAAc,EAAEC,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC1C,aAAa,CAACqB,QAAQ,CACnEsB,oBAAoB,CACnBP,cAAc,EACdE,YAAY,EACZC,eACF,CAAC;IAEH,IAAI,CAAC,CAACvC,aAAa,CAACmD,cAAc,CAChC;MAAE3B,SAAS,EAAEY,cAAc;MAAEX,YAAY,EAAEY;IAAe,CAAC,EAC3DI,cAAc,CAACI,OAAO,EACtB;MAAErB,SAAS,EAAEe,eAAe;MAAEd,YAAY,EAAEe;IAAgB,CAAC,EAC7DE,eAAe,CAACG,OAClB,CAAC;EACH,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"FauxDataStoreBatch.js","names":["deepEqual","OpenApiCallError","FauxDataStoreBatch","fauxDataStore","objectEdits","addedLinksCount","addedObjectCount","deletedLinksCount","deletedObjectsCount","modifiedObjectsCount","edits","constructor","getObject","objectType","primaryKey","getObjectOrThrow","getObjects","getObjectsOfType","addObject","object","existingObject","errorCode","errorName","errorInstanceId","parameters","fullMetadata","ontology","getObjectTypeFullMetadataOrThrow","registerObject","__apiName","__primaryKey","push","type","modifyObject","update","origObj","newObj","replaceObjectOrThrow","deleteObject","unregisterObjectOrThrow","addLink","leftObjectType","leftPrimaryKey","leftLinkName","rightObjectType","rightPrimaryKey","leftTypeSideV2","rightTypeSideV2","getBothLinkTypeSides","registerLink","apiName","aSideObject","bSideObject","linkTypeApiNameAtoB","linkTypeApiNameBtoA","removeLink","unregisterLink"],"sources":["FauxDataStoreBatch.ts"],"sourcesContent":["/*\n * Copyright 2023 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 CompileTimeMetadata,\n ObjectTypeDefinition,\n PrimaryKeyType,\n} from \"@osdk/api\";\nimport type * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport deepEqual from \"fast-deep-equal\";\nimport { OpenApiCallError } from \"../handlers/util/handleOpenApiCall.js\";\nimport type { BaseServerObject } from \"./BaseServerObject.js\";\nimport type { FauxDataStore } from \"./FauxDataStore.js\";\nimport type { JustProps } from \"./typeHelpers/JustProps.js\";\n\n/**\n * This is separate from the FauxDataStore so that we can in the future support\n * this not-committing on errors. That functionality just does not exist at the moment\n */\nexport class FauxDataStoreBatch {\n #fauxDataStore: FauxDataStore;\n objectEdits: OntologiesV2.ObjectEdits = {\n addedLinksCount: 0,\n addedObjectCount: 0,\n deletedLinksCount: 0,\n deletedObjectsCount: 0,\n modifiedObjectsCount: 0,\n edits: [],\n };\n\n constructor(fauxDataStore: FauxDataStore) {\n this.#fauxDataStore = fauxDataStore;\n }\n\n getObject = (\n objectType: string,\n primaryKey: string | number | boolean,\n ): BaseServerObject => {\n return this.#fauxDataStore.getObjectOrThrow(\n objectType,\n primaryKey,\n );\n };\n\n getObjects = (objectType: string): Iterable<BaseServerObject> => {\n return this.#fauxDataStore.getObjectsOfType(objectType);\n };\n\n public addObject<T extends ObjectTypeDefinition>(\n objectType: T[\"apiName\"],\n primaryKey: PrimaryKeyType<T>,\n update: Omit<JustProps<T>, CompileTimeMetadata<T>[\"primaryKeyApiName\"]>,\n ): void;\n public addObject(\n objectType: string,\n primaryKey: string | number | boolean,\n object: BaseServerObject,\n ): void;\n public addObject(\n objectType: string,\n primaryKey: string | number | boolean,\n object: BaseServerObject,\n ): void {\n const existingObject = this.#fauxDataStore.getObject(\n objectType,\n primaryKey,\n );\n if (existingObject) {\n throw new OpenApiCallError(\n 500,\n {\n errorCode: \"CONFLICT\",\n errorName: \"ObjectAlreadyExists\",\n errorInstanceId: \"\",\n parameters: {\n objectType,\n primaryKey,\n },\n } satisfies OntologiesV2.ObjectAlreadyExists,\n );\n }\n\n const fullMetadata = this.#fauxDataStore.ontology\n .getObjectTypeFullMetadataOrThrow(objectType);\n\n this.#fauxDataStore.registerObject({\n ...object,\n __apiName: objectType,\n __primaryKey: primaryKey,\n [fullMetadata.objectType.primaryKey]: primaryKey,\n });\n this.objectEdits.edits.push({\n type: \"addObject\",\n primaryKey,\n objectType,\n });\n this.objectEdits.addedObjectCount += 1;\n }\n\n public modifyObject<T extends ObjectTypeDefinition>(\n objectType: T[\"apiName\"],\n primaryKey: PrimaryKeyType<T>,\n update: Partial<JustProps<T>>,\n ): void;\n public modifyObject(\n objectType: string,\n primaryKey: string | number | boolean,\n update: Partial<BaseServerObject>,\n ): void;\n public modifyObject(\n objectType: string,\n primaryKey: string | number | boolean,\n update: Partial<BaseServerObject>,\n ): void {\n const origObj = this.#fauxDataStore.getObjectOrThrow(\n objectType,\n primaryKey,\n );\n const newObj = {\n ...origObj,\n ...update,\n };\n\n if (!deepEqual(origObj, newObj)) {\n this.#fauxDataStore.replaceObjectOrThrow(newObj);\n this.objectEdits.edits.push({\n type: \"modifyObject\",\n primaryKey,\n objectType,\n });\n this.objectEdits.modifiedObjectsCount += 1;\n }\n }\n\n deleteObject = (\n objectType: string,\n primaryKey: string | number | boolean,\n ): void => {\n this.#fauxDataStore.unregisterObjectOrThrow(objectType, primaryKey);\n this.objectEdits.edits.push({\n type: \"deleteObject\",\n objectType,\n primaryKey: primaryKey,\n });\n };\n\n addLink = (\n leftObjectType: string,\n leftPrimaryKey: string | number | boolean,\n leftLinkName: string,\n rightObjectType: string,\n rightPrimaryKey: string | number | boolean,\n ): void => {\n const [leftTypeSideV2, rightTypeSideV2] = this.#fauxDataStore.ontology\n .getBothLinkTypeSides(\n leftObjectType,\n leftLinkName,\n rightObjectType,\n );\n\n this.#fauxDataStore.registerLink(\n { __apiName: leftObjectType, __primaryKey: leftPrimaryKey },\n leftTypeSideV2.apiName,\n { __apiName: rightObjectType, __primaryKey: rightPrimaryKey },\n rightTypeSideV2.apiName,\n );\n\n this.objectEdits.edits.push({\n type: \"addLink\",\n aSideObject: {\n objectType: leftObjectType,\n primaryKey: leftPrimaryKey,\n },\n bSideObject: {\n objectType: rightObjectType,\n primaryKey: rightPrimaryKey,\n },\n linkTypeApiNameAtoB: leftLinkName,\n linkTypeApiNameBtoA: rightTypeSideV2.apiName,\n });\n\n this.objectEdits.addedLinksCount += 1;\n };\n\n removeLink = (\n leftObjectType: string,\n leftPrimaryKey: string | number | boolean,\n leftLinkName: string,\n rightObjectType: string,\n rightPrimaryKey: string | number | boolean,\n ): void => {\n const [leftTypeSideV2, rightTypeSideV2] = this.#fauxDataStore.ontology\n .getBothLinkTypeSides(\n leftObjectType,\n leftLinkName,\n rightObjectType,\n );\n\n this.#fauxDataStore.unregisterLink(\n { __apiName: leftObjectType, __primaryKey: leftPrimaryKey },\n leftTypeSideV2.apiName,\n { __apiName: rightObjectType, __primaryKey: rightPrimaryKey },\n rightTypeSideV2.apiName,\n );\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAOA,SAAS,MAAM,iBAAiB;AACvC,SAASC,gBAAgB,QAAQ,uCAAuC;AAKxE;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,CAAC;EAC9B,CAACC,aAAa;EACdC,WAAW,GAA6B;IACtCC,eAAe,EAAE,CAAC;IAClBC,gBAAgB,EAAE,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e,CAAC,EAC3DI,cAAc,CAACI,OAAO,EACtB;MAAErB,SAAS,EAAEe,eAAe;MAAEd,YAAY,EAAEe;IAAgB,CAAC,EAC7DE,eAAe,CAACG,OAClB,CAAC;IAED,IAAI,CAAC9C,WAAW,CAACM,KAAK,CAACqB,IAAI,CAAC;MAC1BC,IAAI,EAAE,SAAS;MACfmB,WAAW,EAAE;QACXtC,UAAU,EAAE4B,cAAc;QAC1B3B,UAAU,EAAE4B;MACd,CAAC;MACDU,WAAW,EAAE;QACXvC,UAAU,EAAE+B,eAAe;QAC3B9B,UAAU,EAAE+B;MACd,CAAC;MACDQ,mBAAmB,EAAEV,YAAY;MACjCW,mBAAmB,EAAEP,eAAe,CAACG;IACvC,CAAC,CAAC;IAEF,IAAI,CAAC9C,WAAW,CAACC,eAAe,IAAI,CAAC;EACvC,CAAC;EAEDkD,UAAU,GAAGA,CACXd,cAAsB,EACtBC,cAAyC,EACzCC,YAAoB,EACpBC,eAAuB,EACvBC,eAA0C,KACjC;IACT,MAAM,CAACC,cAAc,EAAEC,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC5C,aAAa,CAACuB,QAAQ,CACnEsB,oBAAoB,CACnBP,cAAc,EACdE,YAAY,EACZC,eACF,CAAC;IAEH,IAAI,CAAC,CAACzC,aAAa,CAACqD,cAAc,CAChC;MAAE3B,SAAS,EAAEY,cAAc;MAAEX,YAAY,EAAEY;IAAe,CAAC,EAC3DI,cAAc,CAACI,OAAO,EACtB;MAAErB,SAAS,EAAEe,eAAe;MAAEd,YAAY,EAAEe;IAAgB,CAAC,EAC7DE,eAAe,CAACG,OAClB,CAAC;EACH,CAAC;AACH","ignoreList":[]}
@@ -202,7 +202,7 @@ function matchesOntologyDataType(odt, value) {
202
202
  case "decimal":
203
203
  throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
204
204
  case "double":
205
- throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
205
+ return typeof value === "number";
206
206
  case "float":
207
207
  throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
208
208
  case "integer":
@@ -214,7 +214,7 @@ function matchesOntologyDataType(odt, value) {
214
214
  case "marking":
215
215
  throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
216
216
  case "object":
217
- throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
217
+ return typeof value === "string" || value != null && typeof value === "object" && "$primaryKey" in value;
218
218
  case "objectSet":
219
219
  throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
220
220
  case "set":
@@ -1 +1 @@
1
- {"version":3,"file":"validateAction.js","names":["validateAction","payload","def","dataStore","ret","parameters","submissionCriteria","result","k","v","Object","entries","value","validateActionParameterType","dataType","paramDef","paramKey","required","evaluatedConstraints","baseParam","type","Array","isArray","item","subType","matchesOntologyDataType","isInterfaceActionParam","getObject","objectTypeApiName","primaryKeyValue","isMediaReference","name","fieldType","fields","fieldValue","ontology","getObjectTypeFullMetadata","Error","odt","every","itemType","Number","isInteger","o","mimeType","reference","mediaSetViewItem","mediaSetRid","mediaSetViewRid","mediaItemRid","isPoint","obj","coordinates","length"],"sources":["validateAction.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MediaReference } from \"@osdk/foundry.core\";\nimport type {\n ActionParameterType,\n ActionParameterV2,\n ActionTypeV2,\n ApplyActionRequestV2,\n BatchApplyActionRequestItem,\n OntologyDataType,\n ParameterEvaluationResult,\n ValidateActionResponseV2,\n} from \"@osdk/foundry.ontologies\";\nimport type { FauxDataStore } from \"./FauxDataStore.js\";\n\nexport function validateAction(\n payload: ApplyActionRequestV2 | BatchApplyActionRequestItem,\n def: ActionTypeV2,\n dataStore: FauxDataStore,\n): ValidateActionResponseV2 {\n const ret: ValidateActionResponseV2 = {\n parameters: {},\n submissionCriteria: [],\n result: \"VALID\",\n };\n for (const [k, v] of Object.entries(def.parameters)) {\n const value = payload.parameters[k];\n validateActionParameterType(v.dataType, v, value, ret, k, dataStore);\n }\n\n return ret;\n}\n\n// So far these all basically return the same thing\n// and can likely be rewritten as a function that return boolean\nfunction validateActionParameterType(\n dataType: ActionParameterType,\n paramDef: ActionParameterV2,\n value: unknown,\n ret: ValidateActionResponseV2,\n paramKey: string,\n dataStore: FauxDataStore,\n) {\n if (paramDef.required && value == null) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n result: \"INVALID\",\n evaluatedConstraints: [],\n required: true,\n };\n return;\n }\n if (!paramDef.required && value == null) {\n return;\n }\n\n const baseParam: ParameterEvaluationResult = {\n result: \"INVALID\",\n evaluatedConstraints: [],\n required: paramDef.required,\n };\n\n switch (dataType.type) {\n case \"array\": {\n if (!Array.isArray(value)) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n return;\n }\n for (const item of value) {\n validateActionParameterType(\n dataType.subType,\n paramDef,\n item,\n ret,\n paramKey,\n dataStore,\n );\n }\n return;\n }\n\n case \"attachment\": {\n if (typeof value !== \"string\") {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n }\n return;\n }\n\n case \"boolean\":\n case \"date\":\n case \"long\":\n case \"double\":\n case \"integer\":\n case \"marking\":\n case \"objectSet\":\n case \"timestamp\":\n case \"object\":\n case \"string\":\n if (!matchesOntologyDataType(dataType, value)) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n }\n return;\n case \"geohash\":\n if (!(typeof value === \"string\")) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n }\n return;\n\n case \"geoshape\":\n if (\n !(typeof value === \"object\"\n && (\"coordinates\" in value! || \"geometries\" in value!\n || \"features\" in value!))\n ) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n }\n return;\n case \"interfaceObject\": {\n if (!isInterfaceActionParam(value)) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n } else if (\n dataStore.getObject(\n value.objectTypeApiName,\n value.primaryKeyValue,\n ) == null\n ) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n evaluatedConstraints: [{\n type: \"objectPropertyValue\",\n }],\n };\n }\n return;\n }\n\n case \"mediaReference\": {\n if (!isMediaReference(value)) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n }\n return;\n }\n\n case \"vector\": {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n return;\n }\n\n case \"struct\": {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n return;\n }\n\n for (const { name, fieldType, required } of dataType.fields) {\n const fieldValue = (value as Record<string, unknown>)[name];\n if (\n (required && fieldValue == null)\n || !matchesOntologyDataType(fieldType, fieldValue)\n ) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n\n return;\n }\n }\n\n return;\n }\n\n case \"objectType\": {\n if (\n typeof value !== \"string\"\n || !dataStore.ontology.getObjectTypeFullMetadata(value)\n ) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n return;\n }\n\n return;\n }\n\n default: {\n const _assertNever: never = dataType;\n throw new Error(\n `validateDataType: unknown type`,\n );\n }\n }\n}\n\nfunction matchesOntologyDataType(\n odt: OntologyDataType,\n value: unknown,\n): boolean {\n switch (odt.type) {\n case \"any\":\n return true;\n case \"array\":\n return Array.isArray(value)\n && value.every((v) => matchesOntologyDataType(odt.itemType, v));\n case \"binary\":\n throw new Error(`validateDataType: ${odt.type} not implemented yet.`);\n case \"boolean\":\n return typeof value === \"boolean\";\n case \"byte\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"cipherText\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"date\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"decimal\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"double\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"float\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"integer\":\n return (typeof value === \"number\" && Number.isInteger(value));\n\n case \"long\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"map\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"marking\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"object\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"objectSet\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"set\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"short\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"string\":\n return (typeof value === \"string\");\n\n case \"struct\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"timestamp\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"unsupported\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n default:\n const _assertNever = odt;\n throw new Error(\n `matchesOntologyDataType: ${(odt as any).type} not implemented yet.`,\n );\n }\n}\n\nexport function isMediaReference(o: any): o is MediaReference {\n return typeof o === `object`\n && typeof o.mimeType === \"string\"\n && \"reference\" in o\n && typeof o.reference === \"object\"\n && o.reference.type === \"mediaSetViewItem\"\n && \"mediaSetViewItem\" in o.reference\n && typeof o.reference.mediaSetViewItem === \"object\"\n && typeof o.reference.mediaSetViewItem.mediaSetRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaSetViewRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaItemRid === \"string\";\n}\n\nexport function isInterfaceActionParam(value: any): value is {\n objectTypeApiName: string;\n primaryKeyValue: string | number | boolean;\n} {\n return (\n typeof value === \"object\"\n && \"objectTypeApiName\" in value\n && typeof value.objectTypeApiName === \"string\"\n && \"primaryKeyValue\" in value\n && (typeof value.primaryKeyValue === \"string\"\n || typeof value.primaryKeyValue === \"number\"\n || typeof value.primaryKeyValue === \"boolean\")\n );\n}\n\nfunction isPoint(obj: any): obj is GeoJSON.Point {\n return obj.type === \"Point\"\n && Array.isArray(obj.coordinates)\n && obj.coordinates.length === 2\n && typeof obj.coordinates[0] === \"number\"\n && typeof obj.coordinates[1] === \"number\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,OAAO,SAASA,cAAcA,CAC5BC,OAA2D,EAC3DC,GAAiB,EACjBC,SAAwB,EACE;EAC1B,MAAMC,GAA6B,GAAG;IACpCC,UAAU,EAAE,CAAC,CAAC;IACdC,kBAAkB,EAAE,EAAE;IACtBC,MAAM,EAAE;EACV,CAAC;EACD,KAAK,MAAM,CAACC,CAAC,EAAEC,CAAC,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACT,GAAG,CAACG,UAAU,CAAC,EAAE;IACnD,MAAMO,KAAK,GAAGX,OAAO,CAACI,UAAU,CAACG,CAAC,CAAC;IACnCK,2BAA2B,CAACJ,CAAC,CAACK,QAAQ,EAAEL,CAAC,EAAEG,KAAK,EAA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CAAC,CAACC,QAAQ,KAAK,QAAQ,IAC9B,WAAW,IAAID,CAAC,IAChB,OAAOA,CAAC,CAACE,SAAS,KAAK,QAAQ,IAC/BF,CAAC,CAACE,SAAS,CAACzB,IAAI,KAAK,kBAAkB,IACvC,kBAAkB,IAAIuB,CAAC,CAACE,SAAS,IACjC,OAAOF,CAAC,CAACE,SAAS,CAACC,gBAAgB,KAAK,QAAQ,IAChD,OAAOH,CAAC,CAACE,SAAS,CAACC,gBAAgB,CAACC,WAAW,KAAK,QAAQ,IAC5D,OAAOJ,CAAC,CAACE,SAAS,CAACC,gBAAgB,CAACE,eAAe,KAAK,QAAQ,IAChE,OAAOL,CAAC,CAACE,SAAS,CAACC,gBAAgB,CAACG,YAAY,KAAK,QAAQ;AACpE;AAEA,OAAO,SAASvB,sBAAsBA,CAACd,KAAU,EAG/C;EACA,OACE,OAAOA,KAAK,KAAK,QAAQ,IACtB,mBAAmB,IAAIA,KAAK,IAC5B,OAAOA,KAAK,CAACgB,iBAAiB,KAAK,QAAQ,IAC3C,iBAAiB,IAAIhB,KAAK,KACzB,OAAOA,KAAK,CAACiB,eAAe,KAAK,QAAQ,IACxC,OAAOjB,KAAK,CAACiB,eAAe,KAAK,QAAQ,IACzC,OAAOjB,KAAK,CAACiB,eAAe,KAAK,SAAS,CAAC;AAEpD;AAEA,SAASqB,OAAOA,CAACC,GAAQ,EAAwB;EAC/C,OAAOA,GAAG,CAAC/B,IAAI,KAAK,OAAO,IACtBC,KAAK,CAACC,OAAO,CAAC6B,GAAG,CAACC,WAAW,CAAC,IAC9BD,GAAG,CAACC,WAAW,CAACC,MAAM,KAAK,CAAC,IAC5B,OAAOF,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC,KAAK,QAAQ,IACtC,OAAOD,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC,KAAK,QAAQ;AAC7C","ignoreList":[]}
1
+ {"version":3,"file":"validateAction.js","names":["validateAction","payload","def","dataStore","ret","parameters","submissionCriteria","result","k","v","Object","entries","value","validateActionParameterType","dataType","paramDef","paramKey","required","evaluatedConstraints","baseParam","type","Array","isArray","item","subType","matchesOntologyDataType","isInterfaceActionParam","getObject","objectTypeApiName","primaryKeyValue","isMediaReference","name","fieldType","fields","fieldValue","ontology","getObjectTypeFullMetadata","Error","odt","every","itemType","Number","isInteger","o","mimeType","reference","mediaSetViewItem","mediaSetRid","mediaSetViewRid","mediaItemRid","isPoint","obj","coordinates","length"],"sources":["validateAction.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MediaReference } from \"@osdk/foundry.core\";\nimport type {\n ActionParameterType,\n ActionParameterV2,\n ActionTypeV2,\n ApplyActionRequestV2,\n BatchApplyActionRequestItem,\n OntologyDataType,\n ParameterEvaluationResult,\n ValidateActionResponseV2,\n} from \"@osdk/foundry.ontologies\";\nimport type { FauxDataStore } from \"./FauxDataStore.js\";\n\nexport function validateAction(\n payload: ApplyActionRequestV2 | BatchApplyActionRequestItem,\n def: ActionTypeV2,\n dataStore: FauxDataStore,\n): ValidateActionResponseV2 {\n const ret: ValidateActionResponseV2 = {\n parameters: {},\n submissionCriteria: [],\n result: \"VALID\",\n };\n for (const [k, v] of Object.entries(def.parameters)) {\n const value = payload.parameters[k];\n validateActionParameterType(v.dataType, v, value, ret, k, dataStore);\n }\n\n return ret;\n}\n\n// So far these all basically return the same thing\n// and can likely be rewritten as a function that return boolean\nfunction validateActionParameterType(\n dataType: ActionParameterType,\n paramDef: ActionParameterV2,\n value: unknown,\n ret: ValidateActionResponseV2,\n paramKey: string,\n dataStore: FauxDataStore,\n) {\n if (paramDef.required && value == null) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n result: \"INVALID\",\n evaluatedConstraints: [],\n required: true,\n };\n return;\n }\n if (!paramDef.required && value == null) {\n return;\n }\n\n const baseParam: ParameterEvaluationResult = {\n result: \"INVALID\",\n evaluatedConstraints: [],\n required: paramDef.required,\n };\n\n switch (dataType.type) {\n case \"array\": {\n if (!Array.isArray(value)) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n return;\n }\n for (const item of value) {\n validateActionParameterType(\n dataType.subType,\n paramDef,\n item,\n ret,\n paramKey,\n dataStore,\n );\n }\n return;\n }\n\n case \"attachment\": {\n if (typeof value !== \"string\") {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n }\n return;\n }\n\n case \"boolean\":\n case \"date\":\n case \"long\":\n case \"double\":\n case \"integer\":\n case \"marking\":\n case \"objectSet\":\n case \"timestamp\":\n case \"object\":\n case \"string\":\n if (!matchesOntologyDataType(dataType, value)) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n }\n return;\n case \"geohash\":\n if (!(typeof value === \"string\")) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n }\n return;\n\n case \"geoshape\":\n if (\n !(typeof value === \"object\"\n && (\"coordinates\" in value! || \"geometries\" in value!\n || \"features\" in value!))\n ) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n }\n return;\n case \"interfaceObject\": {\n if (!isInterfaceActionParam(value)) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n } else if (\n dataStore.getObject(\n value.objectTypeApiName,\n value.primaryKeyValue,\n ) == null\n ) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n evaluatedConstraints: [{\n type: \"objectPropertyValue\",\n }],\n };\n }\n return;\n }\n\n case \"mediaReference\": {\n if (!isMediaReference(value)) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n }\n return;\n }\n\n case \"vector\": {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n return;\n }\n\n case \"struct\": {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n return;\n }\n\n for (const { name, fieldType, required } of dataType.fields) {\n const fieldValue = (value as Record<string, unknown>)[name];\n if (\n (required && fieldValue == null)\n || !matchesOntologyDataType(fieldType, fieldValue)\n ) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n\n return;\n }\n }\n\n return;\n }\n\n case \"objectType\": {\n if (\n typeof value !== \"string\"\n || !dataStore.ontology.getObjectTypeFullMetadata(value)\n ) {\n ret.result = \"INVALID\";\n ret.parameters[paramKey] = {\n ...baseParam,\n };\n return;\n }\n\n return;\n }\n\n default: {\n const _assertNever: never = dataType;\n throw new Error(\n `validateDataType: unknown type`,\n );\n }\n }\n}\n\nfunction matchesOntologyDataType(\n odt: OntologyDataType,\n value: unknown,\n): boolean {\n switch (odt.type) {\n case \"any\":\n return true;\n case \"array\":\n return Array.isArray(value)\n && value.every((v) => matchesOntologyDataType(odt.itemType, v));\n case \"binary\":\n throw new Error(`validateDataType: ${odt.type} not implemented yet.`);\n case \"boolean\":\n return typeof value === \"boolean\";\n case \"byte\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"cipherText\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"date\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"decimal\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"double\":\n return typeof value === \"number\";\n\n case \"float\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"integer\":\n return (typeof value === \"number\" && Number.isInteger(value));\n\n case \"long\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"map\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"marking\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"object\":\n return typeof value === \"string\"\n || (value != null && typeof value === \"object\"\n && \"$primaryKey\" in value);\n case \"objectSet\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"set\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"short\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"string\":\n return (typeof value === \"string\");\n\n case \"struct\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"timestamp\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n case \"unsupported\":\n throw new Error(\n `matchesOntologyDataType: ${odt.type} not implemented yet.`,\n );\n default:\n const _assertNever = odt;\n throw new Error(\n `matchesOntologyDataType: ${(odt as any).type} not implemented yet.`,\n );\n }\n}\n\nexport function isMediaReference(o: any): o is MediaReference {\n return typeof o === `object`\n && typeof o.mimeType === \"string\"\n && \"reference\" in o\n && typeof o.reference === \"object\"\n && o.reference.type === \"mediaSetViewItem\"\n && \"mediaSetViewItem\" in o.reference\n && typeof o.reference.mediaSetViewItem === \"object\"\n && typeof o.reference.mediaSetViewItem.mediaSetRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaSetViewRid === \"string\"\n && typeof o.reference.mediaSetViewItem.mediaItemRid === \"string\";\n}\n\nexport function isInterfaceActionParam(value: any): value is {\n objectTypeApiName: string;\n primaryKeyValue: string | number | boolean;\n} {\n return (\n typeof value === \"object\"\n && \"objectTypeApiName\" in value\n && typeof value.objectTypeApiName === \"string\"\n && \"primaryKeyValue\" in value\n && (typeof value.primaryKeyValue === \"string\"\n || typeof value.primaryKeyValue === \"number\"\n || typeof value.primaryKeyValue === \"boolean\")\n );\n}\n\nfunction isPoint(obj: any): obj is GeoJSON.Point {\n return obj.type === \"Point\"\n && Array.isArray(obj.coordinates)\n && obj.coordinates.length === 2\n && typeof obj.coordinates[0] === \"number\"\n && typeof obj.coordinates[1] === \"number\";\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAeA,OAAO,SAASA,cAAcA,CAC5BC,OAA2D,EAC3DC,GAAiB,EACjBC,SAAwB,EACE;EAC1B,MAAMC,GAA6B,GAAG;IACpCC,UAAU,EAAE,CAAC,CAAC;IACdC,kBAAkB,EAAE,EAAE;IACtBC,MAAM,EAAE;EACV,CAAC;EACD,KAAK,MAAM,CAACC,CAAC,EAAEC,CAAC,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACT,GAAG,CAACG,UAAU,CAAC,EAAE;IACnD,MAAMO,KAAK,GAAGX,OAAO,CAACI,UAAU,CAACG,CAAC,CAAC;IACnCK,2BAA2B,CAACJ,CAAC,CAACK,QAAQ,EAAEL,CAAC,EAAEG,KAAK,EAAER,GAAG,EAAEI,CAAC,EAAEL,SAAS,CAAC;EACtE;EAEA,OAAOC,GAAG;AACZ;;AAEA;AACA;AACA,SAASS,2BAA2BA,CAClCC,QAA6B,EAC7BC,QAA2B,EAC3BH,KAAc,EACdR,GAA6B,EAC7BY,QAAgB,EAChBb,SAAwB,EACxB;EACA,IAAIY,QAAQ,CAACE,QAAQ,IAAIL,KAAK,IAAI,IAAI,EAAE;IACtCR,GAAG,CAACG,MAAM,GAAG,SAAS;IACtBH,GAAG,CAACC,UAAU,CAACW,QAAQ,CAAC,GAAG;MACzBT,MAAM,EAAE,SAAS;MACjBW,oBAAoB,EAAE,EAAE;MACxBD,QAAQ,EAAE;IACZ,CAAC;IACD;EACF;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AS,CAACC,gBAAgB,CAACG,YAAY,KAAK,QAAQ;AACpE;AAEA,OAAO,SAASvB,sBAAsBA,CAACd,KAAU,EAG/C;EACA,OACE,OAAOA,KAAK,KAAK,QAAQ,IACtB,mBAAmB,IAAIA,KAAK,IAC5B,OAAOA,KAAK,CAACgB,iBAAiB,KAAK,QAAQ,IAC3C,iBAAiB,IAAIhB,KAAK,KACzB,OAAOA,KAAK,CAACiB,eAAe,KAAK,QAAQ,IACxC,OAAOjB,KAAK,CAACiB,eAAe,KAAK,QAAQ,IACzC,OAAOjB,KAAK,CAACiB,eAAe,KAAK,SAAS,CAAC;AAEpD;AAEA,SAASqB,OAAOA,CAACC,GAAQ,EAAwB;EAC/C,OAAOA,GAAG,CAAC/B,IAAI,KAAK,OAAO,IACtBC,KAAK,CAACC,OAAO,CAAC6B,GAAG,CAACC,WAAW,CAAC,IAC9BD,GAAG,CAACC,WAAW,CAACC,MAAM,KAAK,CAAC,IAC5B,OAAOF,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC,KAAK,QAAQ,IACtC,OAAOD,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC,KAAK,QAAQ;AAC7C","ignoreList":[]}
@@ -58,9 +58,7 @@ export function ObjectNotFoundError(objectType, primaryKey) {
58
58
  errorInstanceId,
59
59
  parameters: {
60
60
  objectType,
61
- primaryKey: {
62
- employeeId: primaryKey
63
- }
61
+ primaryKey
64
62
  }
65
63
  };
66
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["errorInstanceId","objectTypeRid","ObjectTypeDoesNotExistError","objectType","errorCode","errorName","parameters","LinkTypeNotFound","linkType","OntologyNotFoundError","ontology","ontologyRid","apiName","ObjectNotFoundError","primaryKey","employeeId","QueryNotFoundError","queryApiName","query","ActionNotFoundError","actionRid","InvalidRequest","ApplyActionFailedError","ExecuteQueryFailedError","functionRid","functionVersion","message","InvalidContentTypeError","AttachmentSizeExceededLimitError","fileSizeBytes","fileLimitBytes","AttachmentNotFoundError","attachmentRid"],"sources":["errors.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n//\n\nimport type {\n ActionNotFound,\n ApplyActionFailed,\n AttachmentNotFound,\n AttachmentSizeExceededLimit,\n InvalidContentType,\n LinkTypeNotFound as OGLinkTypeNotFound,\n ObjectNotFound,\n ObjectTypeNotFound,\n OntologyNotFound,\n QueryEncounteredUserFacingError,\n QueryNotFound,\n} from \"@osdk/internal.foundry.ontologies\";\nimport type { BaseAPIError } from \"./BaseError.js\";\n\nconst errorInstanceId = \"errorInstanceId\";\nconst objectTypeRid = \"ri.foundry.main.objectType.1\";\n\nexport function ObjectTypeDoesNotExistError(\n objectType: string,\n): ObjectTypeNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"ObjectTypeNotFound\",\n errorInstanceId,\n parameters: {\n objectType,\n objectTypeRid,\n },\n };\n}\n\nexport function LinkTypeNotFound(\n objectType: string,\n linkType: string,\n): OGLinkTypeNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"LinkTypeNotFound\",\n errorInstanceId,\n parameters: {\n objectType,\n linkType,\n },\n };\n}\n\nexport function OntologyNotFoundError(\n ontology: string,\n): OntologyNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"OntologyNotFound\",\n errorInstanceId,\n parameters: {\n ontologyRid: ontology,\n apiName: ontology,\n },\n };\n}\n\nexport function ObjectNotFoundError(\n objectType: string,\n primaryKey: string,\n): ObjectNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"ObjectNotFound\",\n errorInstanceId,\n parameters: {\n objectType,\n primaryKey: {\n employeeId: primaryKey,\n },\n },\n };\n}\n\nexport function QueryNotFoundError(queryApiName: string): QueryNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"QueryNotFound\",\n errorInstanceId,\n parameters: {\n query: queryApiName,\n },\n };\n}\n\nexport function ActionNotFoundError(): ActionNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"ActionNotFound\",\n errorInstanceId,\n parameters: {\n actionRid: \"\",\n },\n };\n}\n\nexport function InvalidRequest(errorName: string): BaseAPIError {\n return {\n errorCode: \"INVALID_REQUEST\",\n errorName,\n errorInstanceId,\n parameters: {},\n };\n}\n\nexport const ApplyActionFailedError: ApplyActionFailed = {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"ApplyActionFailed\",\n errorInstanceId,\n parameters: {},\n};\n\nexport const ExecuteQueryFailedError: QueryEncounteredUserFacingError = {\n errorCode: \"CONFLICT\",\n errorName: \"QueryEncounteredUserFacingError\",\n errorInstanceId,\n parameters: {\n functionRid:\n \"ri.function-registry.main.function.9b55870a-63c7-4d48-8f06-9627c0805968\",\n functionVersion: \"0.11.0\",\n message: \"test failed\",\n },\n};\n\nexport const InvalidContentTypeError: InvalidContentType = {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"InvalidContentType\",\n errorInstanceId,\n parameters: {},\n};\n\nexport const AttachmentSizeExceededLimitError: AttachmentSizeExceededLimit = {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"AttachmentSizeExceededLimit\",\n errorInstanceId,\n parameters: {\n fileSizeBytes: \"230000\",\n fileLimitBytes: \"200000\",\n },\n};\n\nexport const AttachmentNotFoundError: AttachmentNotFound = {\n errorCode: \"NOT_FOUND\",\n errorName: \"AttachmentNotFound\",\n errorInstanceId,\n parameters: {\n attachmentRid:\n \"ri.attachments.main.attachment.86016861-707f-4292-b258-6a7108915a80\",\n },\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;A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AgB;IAC3BL,eAAe;IACfM,UAAU,EAAE;MACVc,SAAS,EAAE;IACb;EACF,CAAC;AACH;AAEA,OAAO,SAASC,cAAcA,CAAChB,SAAiB,EAAgB;EAC9D,OAAO;IACLD,SAAS,EAAE,iBAAiB;IAC5BC,SAAS;IACTL,eAAe;IACfM,UAAU,EAAE,CAAC;EACf,CAAC;AACH;AAEA,OAAO,MAAMgB,sBAAyC,GAAG;EACvDlB,SAAS,EAAE,kBAAkB;EAC7BC,SAAS,EAAE,mBAAmB;EAC9BL,eAAe;EACfM,UAAU,EAAE,CAAC;AACf,CAAC;AAED,OAAO,MAAMiB,uBAAwD,GAAG;EACtEnB,SAAS,EAAE,UAAU;EACrBC,SAAS,EAAE,iCAAiC;EAC5CL,eAAe;EACfM,UAAU,EAAE;IACVkB,WAAW,EACT,yEAAyE;IAC3EC,eAAe,EAAE,QAAQ;IACzBC,OAAO,EAAE;EACX;AACF,CAAC;AAED,OAAO,MAAMC,uBAA2C,GAAG;EACzDvB,SAAS,EAAE,kBAAkB;EAC7BC,SAAS,EAAE,oBAAoB;EAC/BL,eAAe;EACfM,UAAU,EAAE,CAAC;AACf,CAAC;AAED,OAAO,MAAMsB,gCAA6D,GAAG;EAC3ExB,SAAS,EAAE,kBAAkB;EAC7BC,SAAS,EAAE,6BAA6B;EACxCL,eAAe;EACfM,UAAU,EAAE;IACVuB,aAAa,EAAE,QAAQ;IACvBC,cAAc,EAAE;EAClB;AACF,CAAC;AAED,OAAO,MAAMC,uBAA2C,GAAG;EACzD3B,SAAS,EAAE,WAAW;EACtBC,SAAS,EAAE,oBAAoB;EAC/BL,eAAe;EACfM,UAAU,EAAE;IACV0B,aAAa,EACX;EACJ;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"errors.js","names":["errorInstanceId","objectTypeRid","ObjectTypeDoesNotExistError","objectType","errorCode","errorName","parameters","LinkTypeNotFound","linkType","OntologyNotFoundError","ontology","ontologyRid","apiName","ObjectNotFoundError","primaryKey","QueryNotFoundError","queryApiName","query","ActionNotFoundError","actionRid","InvalidRequest","ApplyActionFailedError","ExecuteQueryFailedError","functionRid","functionVersion","message","InvalidContentTypeError","AttachmentSizeExceededLimitError","fileSizeBytes","fileLimitBytes","AttachmentNotFoundError","attachmentRid"],"sources":["errors.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n//\n\nimport type {\n ActionNotFound,\n ApplyActionFailed,\n AttachmentNotFound,\n AttachmentSizeExceededLimit,\n InvalidContentType,\n LinkTypeNotFound as OGLinkTypeNotFound,\n ObjectNotFound,\n ObjectTypeNotFound,\n OntologyNotFound,\n QueryEncounteredUserFacingError,\n QueryNotFound,\n} from \"@osdk/internal.foundry.ontologies\";\nimport type { BaseAPIError } from \"./BaseError.js\";\n\nconst errorInstanceId = \"errorInstanceId\";\nconst objectTypeRid = \"ri.foundry.main.objectType.1\";\n\nexport function ObjectTypeDoesNotExistError(\n objectType: string,\n): ObjectTypeNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"ObjectTypeNotFound\",\n errorInstanceId,\n parameters: {\n objectType,\n objectTypeRid,\n },\n };\n}\n\nexport function LinkTypeNotFound(\n objectType: string,\n linkType: string,\n): OGLinkTypeNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"LinkTypeNotFound\",\n errorInstanceId,\n parameters: {\n objectType,\n linkType,\n },\n };\n}\n\nexport function OntologyNotFoundError(\n ontology: string,\n): OntologyNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"OntologyNotFound\",\n errorInstanceId,\n parameters: {\n ontologyRid: ontology,\n apiName: ontology,\n },\n };\n}\n\nexport function ObjectNotFoundError(\n objectType: string,\n primaryKey: string,\n): ObjectNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"ObjectNotFound\",\n errorInstanceId,\n parameters: {\n objectType,\n primaryKey,\n },\n };\n}\n\nexport function QueryNotFoundError(queryApiName: string): QueryNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"QueryNotFound\",\n errorInstanceId,\n parameters: {\n query: queryApiName,\n },\n };\n}\n\nexport function ActionNotFoundError(): ActionNotFound {\n return {\n errorCode: \"NOT_FOUND\",\n errorName: \"ActionNotFound\",\n errorInstanceId,\n parameters: {\n actionRid: \"\",\n },\n };\n}\n\nexport function InvalidRequest(errorName: string): BaseAPIError {\n return {\n errorCode: \"INVALID_REQUEST\",\n errorName,\n errorInstanceId,\n parameters: {},\n };\n}\n\nexport const ApplyActionFailedError: ApplyActionFailed = {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"ApplyActionFailed\",\n errorInstanceId,\n parameters: {},\n};\n\nexport const ExecuteQueryFailedError: QueryEncounteredUserFacingError = {\n errorCode: \"CONFLICT\",\n errorName: \"QueryEncounteredUserFacingError\",\n errorInstanceId,\n parameters: {\n functionRid:\n \"ri.function-registry.main.function.9b55870a-63c7-4d48-8f06-9627c0805968\",\n functionVersion: \"0.11.0\",\n message: \"test failed\",\n },\n};\n\nexport const InvalidContentTypeError: InvalidContentType = {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"InvalidContentType\",\n errorInstanceId,\n parameters: {},\n};\n\nexport const AttachmentSizeExceededLimitError: AttachmentSizeExceededLimit = {\n errorCode: \"INVALID_ARGUMENT\",\n errorName: \"AttachmentSizeExceededLimit\",\n errorInstanceId,\n parameters: {\n fileSizeBytes: \"230000\",\n fileLimitBytes: \"200000\",\n },\n};\n\nexport const AttachmentNotFoundError: AttachmentNotFound = {\n errorCode: \"NOT_FOUND\",\n errorName: \"AttachmentNotFound\",\n errorInstanceId,\n parameters: {\n attachmentRid:\n \"ri.attachments.main.attachment.86016861-707f-4292-b258-6a7108915a80\",\n },\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAiBA,MAAMA,eAAe,GAAG,iBAAiB;AACzC,MAAMC,aAAa,GAAG,8BAA8B;AAEpD,OAAO,SAASC,2BAA2BA,CACzCC,UAAkB,EACE;EACpB,OAAO;IACLC,SAAS,EAAE,WAAW;IACtBC,SAAS,EAAE,oBAAoB;IAC/BL,eAAe;IACfM,UAAU,EAAE;MACVH,UAAU;MACVF;IACF;EACF,CAAC;AACH;AAEA,OAAO,SAASM,gBAAgBA,CAC9BJ,UAAkB,EAClBK,QAAgB,EACI;EACpB,OAAO;IACLJ,SAAS,EAAE,WAAW;IACtBC,SAAS,EAAE,kBAAkB;IAC7BL,eAAe;IACfM,UAAU,EAAE;MACVH,UAAU;MACVK;IACF;EACF,CAAC;AACH;AAEA,OAAO,SAASC,qBAAqBA,CACnCC,QAAgB,EACE;EAClB,OAAO;IACLN,SAAS,EAAE,WAAW;IACtBC,SAAS,EAAE,kBAAkB;IAC7BL,eAAe;IACfM,UAAU,EAAE;MACVK,WAAW,EAAED,QAAQ;MACrBE,OAAO,EAAEF;IACX;EACF,CAAC;AACH;AAEA,OAAO,SAASG,mBAAmBA,CACjCV,UAAkB,EAClBW,UAAkB,EACF;EAChB,OAAO;IACLV,SAAS,EAAE,WAAW;IACtBC,SAAS,EAAE,gBAAgB;IAC3BL,eAAe;IACfM,UAAU,EAAE;MACVH,UAAU;MACVW;IACF;EACF,CAAC;AACH;AAEA,OAAO,SAASC,kBAAkBA,CAACC,YAAoB,EAAiB;EACtE,OAAO;IACLZ,SAAS,EAAE,WAAW;IACtBC,SAAS,EAAE,eAAe;IAC1BL,eAAe;IACfM,UAAU,EAAE;MACVW,KAAK,EAAED;IACT;EACF,CAAC;AACH;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export { isBaseApiError } from "./BaseError.js";
19
19
  export * as Errors from "./errors.js";
20
20
  export { FauxDataStore } from "./FauxFoundry/FauxDataStore.js";
21
- export { FauxDataStoreBatch } from "./FauxFoundry/FauxDataStoreBatch.js";
22
21
  export { FauxFoundry } from "./FauxFoundry/FauxFoundry.js";
23
22
  export { FauxOntology } from "./FauxFoundry/FauxOntology.js";
24
23
  export { authHandlerMiddleware } from "./handlers/authHandlerMiddleware.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["TypeHelpers","isBaseApiError","Errors","FauxDataStore","FauxDataStoreBatch","FauxFoundry","FauxOntology","authHandlerMiddleware","OpenApiCallError","OntologiesV2","MockOntologiesV2","withoutRid","msw"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * as TypeHelpers from \"./FauxFoundry/typeHelpers/index.js\";\n\nexport { isBaseApiError } from \"./BaseError.js\";\nexport type { BaseAPIError } from \"./BaseError.js\";\nexport * as Errors from \"./errors.js\";\nexport type { FauxActionImpl } from \"./FauxFoundry/FauxActionImpl.js\";\nexport { FauxDataStore } from \"./FauxFoundry/FauxDataStore.js\";\nexport { FauxDataStoreBatch } from \"./FauxFoundry/FauxDataStoreBatch.js\";\nexport { FauxFoundry } from \"./FauxFoundry/FauxFoundry.js\";\nexport { FauxOntology } from \"./FauxFoundry/FauxOntology.js\";\nexport { authHandlerMiddleware } from \"./handlers/authHandlerMiddleware.js\";\nexport { OpenApiCallError } from \"./handlers/util/handleOpenApiCall.js\";\nexport { OntologiesV2 as MockOntologiesV2 } from \"./mock/index.js\";\nexport { withoutRid } from \"./withoutRid.js\";\n\nexport * as msw from \"msw\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,WAAW,MAAM,oCAAoC;AAEjE,SAASC,cAAc,QAAQ,gBAAgB;AAE/C,OAAO,KAAKC,MAAM,MAAM,aAAa;AAErC,SAASC,aAAa,QAAQ,gCAAgC;AAC9D,SAASC,kBAAkB,QAAQ,qCAAqC;AACxE,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,YAAY,QAAQ,+BAA+B;AAC5D,SAASC,qBAAqB,QAAQ,qCAAqC;AAC3E,SAASC,gBAAgB,QAAQ,sCAAsC;AACvE,SAASC,YAAY,IAAIC,gBAAgB,QAAQ,iBAAiB;AAClE,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,OAAO,KAAKC,GAAG,MAAM,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["TypeHelpers","isBaseApiError","Errors","FauxDataStore","FauxFoundry","FauxOntology","authHandlerMiddleware","OpenApiCallError","OntologiesV2","MockOntologiesV2","withoutRid","msw"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * as TypeHelpers from \"./FauxFoundry/typeHelpers/index.js\";\n\nexport { isBaseApiError } from \"./BaseError.js\";\nexport type { BaseAPIError } from \"./BaseError.js\";\nexport * as Errors from \"./errors.js\";\nexport type { BaseServerObject } from \"./FauxFoundry/BaseServerObject.js\";\nexport type { FauxActionImpl } from \"./FauxFoundry/FauxActionImpl.js\";\nexport { FauxDataStore } from \"./FauxFoundry/FauxDataStore.js\";\nexport type { FauxDataStoreBatch } from \"./FauxFoundry/FauxDataStoreBatch.js\";\nexport { FauxFoundry } from \"./FauxFoundry/FauxFoundry.js\";\nexport { FauxOntology } from \"./FauxFoundry/FauxOntology.js\";\nexport { authHandlerMiddleware } from \"./handlers/authHandlerMiddleware.js\";\nexport { OpenApiCallError } from \"./handlers/util/handleOpenApiCall.js\";\nexport { OntologiesV2 as MockOntologiesV2 } from \"./mock/index.js\";\nexport { withoutRid } from \"./withoutRid.js\";\n\nexport * as msw from \"msw\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,WAAW,MAAM,oCAAoC;AAEjE,SAASC,cAAc,QAAQ,gBAAgB;AAE/C,OAAO,KAAKC,MAAM,MAAM,aAAa;AAGrC,SAASC,aAAa,QAAQ,gCAAgC;AAE9D,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,YAAY,QAAQ,+BAA+B;AAC5D,SAASC,qBAAqB,QAAQ,qCAAqC;AAC3E,SAASC,gBAAgB,QAAQ,sCAAsC;AACvE,SAASC,YAAY,IAAIC,gBAAgB,QAAQ,iBAAiB;AAClE,SAASC,UAAU,QAAQ,iBAAiB;AAE5C,OAAO,KAAKC,GAAG,MAAM,KAAK","ignoreList":[]}
@@ -188,9 +188,7 @@ function ObjectNotFoundError(objectType, primaryKey) {
188
188
  errorInstanceId,
189
189
  parameters: {
190
190
  objectType,
191
- primaryKey: {
192
- employeeId: primaryKey
193
- }
191
+ primaryKey
194
192
  }
195
193
  };
196
194
  }
@@ -471,6 +469,9 @@ var FauxDataStoreBatch = class {
471
469
  getObject = (objectType, primaryKey) => {
472
470
  return this.#fauxDataStore.getObjectOrThrow(objectType, primaryKey);
473
471
  };
472
+ getObjects = (objectType) => {
473
+ return this.#fauxDataStore.getObjectsOfType(objectType);
474
+ };
474
475
  addObject(objectType, primaryKey, object) {
475
476
  const existingObject = this.#fauxDataStore.getObject(objectType, primaryKey);
476
477
  if (existingObject) {
@@ -1079,7 +1080,7 @@ function matchesOntologyDataType(odt, value) {
1079
1080
  case "decimal":
1080
1081
  throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
1081
1082
  case "double":
1082
- throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
1083
+ return typeof value === "number";
1083
1084
  case "float":
1084
1085
  throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
1085
1086
  case "integer":
@@ -1091,7 +1092,7 @@ function matchesOntologyDataType(odt, value) {
1091
1092
  case "marking":
1092
1093
  throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
1093
1094
  case "object":
1094
- throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
1095
+ return typeof value === "string" || value != null && typeof value === "object" && "$primaryKey" in value;
1095
1096
  case "objectSet":
1096
1097
  throw new Error(`matchesOntologyDataType: ${odt.type} not implemented yet.`);
1097
1098
  case "set":
@@ -1418,12 +1419,13 @@ var FauxDataStore = class {
1418
1419
  return object;
1419
1420
  }
1420
1421
  getObjectsOfType(apiName) {
1422
+ this.ontology.getObjectTypeFullMetadataOrThrow(apiName);
1421
1423
  return this.#objects.get(apiName).values();
1422
1424
  }
1423
1425
  getObjectsFromObjectSet(parsedBody) {
1424
1426
  const selected = parsedBody.select;
1425
1427
  let objects = getObjectsFromSet(this, parsedBody.objectSet, void 0);
1426
- if (!objects) {
1428
+ if (!objects || objects.length === 0) {
1427
1429
  return {
1428
1430
  data: [],
1429
1431
  totalCount: "0",
@@ -2970,7 +2972,6 @@ function withoutRid(o) {
2970
2972
  exports.msw = msw__namespace;
2971
2973
  exports.Errors = errors_exports;
2972
2974
  exports.FauxDataStore = FauxDataStore;
2973
- exports.FauxDataStoreBatch = FauxDataStoreBatch;
2974
2975
  exports.FauxFoundry = FauxFoundry;
2975
2976
  exports.FauxOntology = FauxOntology;
2976
2977
  exports.MockOntologiesV2 = OntologiesV2_exports2;