@osdk/client 2.2.0-beta.1 → 2.2.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/build/browser/Client.js +1 -1
  3. package/build/browser/Client.js.map +1 -1
  4. package/build/browser/createClient.js +3 -3
  5. package/build/browser/createClient.js.map +1 -1
  6. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js +2 -2
  7. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  8. package/build/browser/object/convertWireToOsdkObjects.js +1 -1
  9. package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
  10. package/build/browser/objectSet/ObjectSet.test.js +3 -1
  11. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  12. package/build/browser/util/UserAgent.js +1 -1
  13. package/build/cjs/{chunk-ACX536BS.cjs → chunk-T5UE6BI7.cjs} +14 -14
  14. package/build/cjs/{chunk-ACX536BS.cjs.map → chunk-T5UE6BI7.cjs.map} +1 -1
  15. package/build/cjs/{chunk-FEUFIE6T.cjs → chunk-X7WGNFZ4.cjs} +2 -2
  16. package/build/cjs/{chunk-FEUFIE6T.cjs.map → chunk-X7WGNFZ4.cjs.map} +1 -1
  17. package/build/cjs/index.cjs +46 -46
  18. package/build/cjs/index.cjs.map +1 -1
  19. package/build/cjs/public/internal.cjs +6 -6
  20. package/build/cjs/public/unstable-do-not-use.cjs +3 -3
  21. package/build/esm/Client.js +1 -1
  22. package/build/esm/Client.js.map +1 -1
  23. package/build/esm/createClient.js +3 -3
  24. package/build/esm/createClient.js.map +1 -1
  25. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js +2 -2
  26. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  27. package/build/esm/object/convertWireToOsdkObjects.js +1 -1
  28. package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
  29. package/build/esm/objectSet/ObjectSet.test.js +3 -1
  30. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  31. package/build/esm/util/UserAgent.js +1 -1
  32. package/build/types/Client.d.ts +1 -1
  33. package/build/types/createClient.d.ts.map +1 -1
  34. package/package.json +7 -7
@@ -1,20 +1,20 @@
1
1
  'use strict';
2
2
 
3
- var chunkACX536BS_cjs = require('../chunk-ACX536BS.cjs');
4
- var chunkFEUFIE6T_cjs = require('../chunk-FEUFIE6T.cjs');
3
+ var chunkT5UE6BI7_cjs = require('../chunk-T5UE6BI7.cjs');
4
+ var chunkX7WGNFZ4_cjs = require('../chunk-X7WGNFZ4.cjs');
5
5
  require('../chunk-Q7SFCCGT.cjs');
6
6
 
7
7
  // src/public-utils/createAndFetchTempObjectSetRid.ts
8
8
  async function createAndFetchTempObjectSetRid(client, objectSet) {
9
- const response = await chunkFEUFIE6T_cjs.OntologyObjectSet_exports.createTemporary(client, await client[chunkFEUFIE6T_cjs.additionalContext].ontologyRid, {
10
- objectSet: chunkACX536BS_cjs.getWireObjectSet(objectSet)
9
+ const response = await chunkX7WGNFZ4_cjs.OntologyObjectSet_exports.createTemporary(client, await client[chunkX7WGNFZ4_cjs.additionalContext].ontologyRid, {
10
+ objectSet: chunkT5UE6BI7_cjs.getWireObjectSet(objectSet)
11
11
  });
12
12
  return response.objectSetRid;
13
13
  }
14
14
 
15
15
  // src/public-utils/hydrateObjectSetFromRid.ts
16
16
  function hydrateObjectSetFromRid(client, definition, rid) {
17
- return chunkACX536BS_cjs.createObjectSet(definition, client[chunkFEUFIE6T_cjs.additionalContext], {
17
+ return chunkT5UE6BI7_cjs.createObjectSet(definition, client[chunkX7WGNFZ4_cjs.additionalContext], {
18
18
  type: "intersect",
19
19
  objectSets: [{
20
20
  type: "base",
@@ -28,7 +28,7 @@ function hydrateObjectSetFromRid(client, definition, rid) {
28
28
 
29
29
  Object.defineProperty(exports, "hydrateAttachmentFromRid", {
30
30
  enumerable: true,
31
- get: function () { return chunkACX536BS_cjs.hydrateAttachmentFromRid; }
31
+ get: function () { return chunkT5UE6BI7_cjs.hydrateAttachmentFromRid; }
32
32
  });
33
33
  exports.createAndFetchTempObjectSetRid = createAndFetchTempObjectSetRid;
34
34
  exports.hydrateObjectSetFromRid = hydrateObjectSetFromRid;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkFEUFIE6T_cjs = require('../chunk-FEUFIE6T.cjs');
3
+ var chunkX7WGNFZ4_cjs = require('../chunk-X7WGNFZ4.cjs');
4
4
  require('../chunk-Q7SFCCGT.cjs');
5
5
  var rxjs = require('rxjs');
6
6
  var invariant2 = require('tiny-invariant');
@@ -739,7 +739,7 @@ var OptimisticJob = class {
739
739
  return this;
740
740
  },
741
741
  createObject(type, pk, properties) {
742
- const create = store.client[chunkFEUFIE6T_cjs.additionalContext].objectFactory2(store.client[chunkFEUFIE6T_cjs.additionalContext], [{
742
+ const create = store.client[chunkX7WGNFZ4_cjs.additionalContext].objectFactory2(store.client[chunkX7WGNFZ4_cjs.additionalContext], [{
743
743
  $primaryKey: pk,
744
744
  $apiName: type.apiName,
745
745
  $objectType: type.apiName,
@@ -1241,7 +1241,7 @@ function createObservableClient(client) {
1241
1241
 
1242
1242
  Object.defineProperty(exports, "augment", {
1243
1243
  enumerable: true,
1244
- get: function () { return chunkFEUFIE6T_cjs.augment; }
1244
+ get: function () { return chunkX7WGNFZ4_cjs.augment; }
1245
1245
  });
1246
1246
  exports.createObservableClient = createObservableClient;
1247
1247
  //# sourceMappingURL=unstable-do-not-use.cjs.map
@@ -21,7 +21,7 @@
21
21
  export const additionalContext = Symbol("additionalContext");
22
22
 
23
23
  // BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.
24
- const MaxOsdkVersion = "2.1.0";
24
+ const MaxOsdkVersion = "2.2.0";
25
25
  // END: THIS IS GENERATED CODE. DO NOT EDIT.
26
26
 
27
27
  const ErrorMessage = Symbol("ErrorMessage");
@@ -1 +1 @@
1
- {"version":3,"file":"Client.js","names":["additionalContext","Symbol","MaxOsdkVersion","ErrorMessage"],"sources":["Client.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 ActionDefinition,\n ActionMetadata,\n CompileTimeMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n VersionBound,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport type { SharedClient } from \"@osdk/shared.client2\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\nimport type { SatisfiesSemver } from \"./SatisfiesSemver.js\";\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\ntype OldSharedClient = import(\"@osdk/shared.client\").SharedClient;\n\nexport type CheckVersionBound<Q> = Q extends VersionBound<infer V> ? (\n SatisfiesSemver<V, MaxOsdkVersion> extends true ? Q\n : Q & {\n [ErrorMessage]:\n `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\n }\n )\n : Q;\n\nexport interface Client extends SharedClient, OldSharedClient {\n <Q extends ObjectTypeDefinition>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? ObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends (InterfaceDefinition)>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? MinimalObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends ActionDefinition<any>>(\n o: Q,\n ): ActionSignatureFromDef<Q>;\n\n <Q extends QueryDefinition<any>>(\n o: Q,\n ): QuerySignatureFromDef<Q>;\n\n <Q extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">>(\n experiment: Q,\n ): ExperimentFns<Q>;\n\n fetchMetadata<\n Q extends (\n | ObjectTypeDefinition\n | InterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n ),\n >(o: Q): Promise<\n Q extends ObjectTypeDefinition ? ObjectMetadata\n : Q extends InterfaceDefinition ? InterfaceMetadata\n : Q extends ActionDefinition<any> ? ActionMetadata\n : Q extends QueryDefinition<any> ? QueryMetadata\n : never\n >;\n\n /** @internal */\n [additionalContext]: MinimalClient;\n}\n\n// DO NOT EXPORT FROM PACKAGE\n/** @internal */\nexport const additionalContext: unique symbol = Symbol(\"additionalContext\");\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.1.0\";\n// END: THIS IS GENERATED CODE. DO NOT EDIT.\nexport type MaxOsdkVersion = typeof MaxOsdkVersion;\nconst ErrorMessage: unique symbol = Symbol(\"ErrorMessage\");\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA;;AAsDA;AACA;AACA,OAAO,MAAMA,iBAAgC,GAAGC,MAAM,CAAC,mBAAmB,CAAC;;AAE3E;AACA,MAAMC,cAAc,GAAG,OAAO;AAC9B;;AAEA,MAAMC,YAA2B,GAAGF,MAAM,CAAC,cAAc,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Client.js","names":["additionalContext","Symbol","MaxOsdkVersion","ErrorMessage"],"sources":["Client.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 ActionDefinition,\n ActionMetadata,\n CompileTimeMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n VersionBound,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport type { SharedClient } from \"@osdk/shared.client2\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\nimport type { SatisfiesSemver } from \"./SatisfiesSemver.js\";\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\ntype OldSharedClient = import(\"@osdk/shared.client\").SharedClient;\n\nexport type CheckVersionBound<Q> = Q extends VersionBound<infer V> ? (\n SatisfiesSemver<V, MaxOsdkVersion> extends true ? Q\n : Q & {\n [ErrorMessage]:\n `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\n }\n )\n : Q;\n\nexport interface Client extends SharedClient, OldSharedClient {\n <Q extends ObjectTypeDefinition>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? ObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends (InterfaceDefinition)>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? MinimalObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n <Q extends ActionDefinition<any>>(\n o: Q,\n ): ActionSignatureFromDef<Q>;\n\n <Q extends QueryDefinition<any>>(\n o: Q,\n ): QuerySignatureFromDef<Q>;\n\n <Q extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">>(\n experiment: Q,\n ): ExperimentFns<Q>;\n\n fetchMetadata<\n Q extends (\n | ObjectTypeDefinition\n | InterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n ),\n >(o: Q): Promise<\n Q extends ObjectTypeDefinition ? ObjectMetadata\n : Q extends InterfaceDefinition ? InterfaceMetadata\n : Q extends ActionDefinition<any> ? ActionMetadata\n : Q extends QueryDefinition<any> ? QueryMetadata\n : never\n >;\n\n /** @internal */\n [additionalContext]: MinimalClient;\n}\n\n// DO NOT EXPORT FROM PACKAGE\n/** @internal */\nexport const additionalContext: unique symbol = Symbol(\"additionalContext\");\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.2.0\";\n// END: THIS IS GENERATED CODE. DO NOT EDIT.\nexport type MaxOsdkVersion = typeof MaxOsdkVersion;\nconst ErrorMessage: unique symbol = Symbol(\"ErrorMessage\");\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA;;AAsDA;AACA;AACA,OAAO,MAAMA,iBAAgC,GAAGC,MAAM,CAAC,mBAAmB,CAAC;;AAE3E;AACA,MAAMC,cAAc,GAAG,OAAO;AAC9B;;AAEA,MAAMC,YAA2B,GAAGF,MAAM,CAAC,cAAc,CAAC","ignoreList":[]}
@@ -94,10 +94,10 @@ baseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {
94
94
  const {
95
95
  data,
96
96
  fileName,
97
- objectTypeApi,
98
- propertyTypeApi
97
+ objectType,
98
+ propertyType
99
99
  } = args;
100
- return await OntologiesV2.MediaReferenceProperties.upload(clientCtx, await clientCtx.ontologyRid, objectTypeApi, propertyTypeApi, data, {
100
+ return await OntologiesV2.MediaReferenceProperties.upload(clientCtx, await clientCtx.ontologyRid, objectType.apiName, propertyType, data, {
101
101
  mediaItemPath: fileName,
102
102
  preview: true
103
103
  });
@@ -1 +1 @@
1
- {"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","OntologiesV2","symbolClientContext","oldSymbolClientContext","createBulkLinksAsyncIterFactory","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","fetchSingle","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","fetchMetadata","client","Object","defineProperties","o","type","name","getBulkLinks","fetchOneByRid","objectType","rid","createWithRid","createMediaReference","args","data","fileName","objectTypeApi","propertyTypeApi","MediaReferenceProperties","upload","mediaItemPath","preview","value","createClient"],"sources":["createClient.ts"],"sourcesContent":["/*\n * Copyright 2024 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 ActionDefinition,\n InterfaceDefinition,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SelectArg,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport {\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { additionalContext, type Client } from \"./Client.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport type { Logger } from \"./Logger.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { fetchSingle } from \"./object/fetchSingle.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\n\n// We import it this way to keep compatible with CJS. If we referenced the\n// value of `symbolClientContext` directly, then we would have to a dynamic import\n// in `createClientInternal` which would make it async and a break.\n// Since this is just a string in `@osdk/shared.client2` instead of a symbol,\n// we can safely perform this trick.\ntype newSymbolClientContext =\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n typeof import(\"@osdk/shared.client2\").symbolClientContext;\n\nclass ActionInvoker<Q extends ActionDefinition<any>>\n implements ActionSignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n actionDef: ActionDefinition<any>,\n ) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n\n applyAction: (...args: any[]) => any;\n batchApplyAction: (...args: any[]) => any;\n}\n\nclass QueryInvoker<Q extends QueryDefinition<any>>\n implements QuerySignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n queryDef: QueryDefinition<any>,\n ) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n\n executeFunction: (...args: any[]) => any;\n}\n\n/** @internal */\nexport function createClientInternal(\n objectSetFactory: ObjectSetFactory<any, any>, // first so i can bind\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options: { logger?: Logger } | undefined = undefined,\n fetchFn: typeof globalThis.fetch = fetch,\n): Client {\n if (typeof ontologyRid === \"string\") {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n ontologyRid.then((ontologyRid) => {\n if (!ontologyRid.startsWith(\"ri.\")) {\n // FIXME this promise is not await so this just shows up as an unhandled promise rejection\n throw new Error(\"Invalid ontology RID\");\n }\n });\n }\n\n const clientCtx: MinimalClient = createMinimalClient(\n { ontologyRid },\n baseUrl,\n tokenProvider,\n options,\n fetchFn,\n objectSetFactory,\n );\n\n function clientFn<\n T extends\n | ObjectOrInterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">,\n >(o: T): T extends ObjectTypeDefinition ? ObjectSet<T>\n : T extends InterfaceDefinition ? MinimalObjectSet<T>\n : T extends ActionDefinition<any> ? ActionSignatureFromDef<T>\n : T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : T extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">\n ? { invoke: ExperimentFns<T> }\n : never\n {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx) as any;\n } else if (o.type === \"action\") {\n return new ActionInvoker(\n clientCtx,\n o,\n ) as (T extends ActionDefinition<any>\n // first `as` to the action definition for our \"real\" typecheck\n ? ActionSignatureFromDef<T>\n : never) as any; // then as any for dealing with the conditional return value\n } else if (o.type === \"query\") {\n return new QueryInvoker(\n clientCtx,\n o,\n ) as (T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : never) as any;\n } else if (o.type === \"experiment\") {\n switch (o.name) {\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks.name:\n return {\n getBulkLinks: createBulkLinksAsyncIterFactory(\n clientCtx,\n ),\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:\n return {\n fetchOneByRid: async <\n Q extends ObjectTypeDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectType: Q,\n rid: string,\n options: SelectArg<Q, L, R, S>,\n ) => {\n return await fetchSingle(\n clientCtx,\n objectType,\n options,\n createWithRid(\n rid,\n ),\n ) as Osdk<Q>;\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference.name:\n return {\n createMediaReference: async (args: {\n data: Blob;\n fileName: string;\n objectTypeApi: string;\n propertyTypeApi: string;\n }) => {\n const { data, fileName, objectTypeApi, propertyTypeApi } = args;\n return await OntologiesV2.MediaReferenceProperties.upload(\n clientCtx,\n await clientCtx.ontologyRid,\n objectTypeApi,\n propertyTypeApi,\n data,\n {\n mediaItemPath: fileName,\n preview: true,\n },\n );\n },\n } as any;\n }\n\n throw new Error(\"not implemented\");\n } else {\n throw new Error(\"not implemented\");\n }\n }\n\n const fetchMetadata = fetchMetadataInternal.bind(\n undefined,\n clientCtx,\n );\n\n const symbolClientContext: newSymbolClientContext = \"__osdkClientContext\";\n\n const client: Client = Object.defineProperties<Client>(\n clientFn as Client,\n {\n [oldSymbolClientContext]: {\n value: clientCtx,\n },\n [symbolClientContext]: {\n value: clientCtx,\n },\n [additionalContext]: {\n value: clientCtx,\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n } satisfies Record<keyof Client, PropertyDescriptor>,\n );\n\n return client;\n}\n\nexport const createClient: (\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options?: {\n logger?: Logger;\n } | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n);\n\nfunction createWithRid(\n rid: string,\n) {\n const withRid: WireObjectSet = {\n type: \"static\",\n \"objects\": [rid],\n };\n\n return withRid;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA,SACEA,uDAAuD,EACvDC,gDAAgD,EAChDC,+CAA+C,QAC1C,oBAAoB;AAE3B,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AACnF,SAASC,+BAA+B,QAAQ,iDAAiD;AAEjG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAqB,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAG1D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,QAAQ,gCAAgC;AAEhE,SAASC,UAAU,QAAQ,yBAAyB;;AAGpD;AACA;AACA;AACA;AACA;;AAKA,MAAMC,aAAa,CAEnB;EACEC,WAAWA,CACTC,SAAwB,EACxBC,SAAgC,EAChC;IACA;IACA;IACA;IACA;IACA,IAAI,CAACV,WAAW,GAAGA,WAAW,CAACW,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;IACpE,IAAI,CAACG,gBAAgB,GAAGb,WAAW,CAACW,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;EAC3E;AAIF;AAEA,MAAMI,YAAY,CAElB;EACEN,WAAWA,CACTC,S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EAAEzC;IACT,CAAC;IACDmB,aAAa,EAAE;MACbsB,KAAK,EAAEtB;IACT;EACF,CACF,CAAC;EAED,OAAOC,MAAM;AACf;AAEA,OAAO,MAAMsB,YAQF,GAAGlC,oBAAoB,CAACN,IAAI,CACrCC,SAAS,EACTP,eACF,CAAC;AAED,SAASkC,aAAaA,CACpBD,GAAW,EACX;EAMA,OAL+B;IAC7BL,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAACK,GAAG;EACjB,CAAC;AAGH","ignoreList":[]}
1
+ {"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","OntologiesV2","symbolClientContext","oldSymbolClientContext","createBulkLinksAsyncIterFactory","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","fetchSingle","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","fetchMetadata","client","Object","defineProperties","o","type","name","getBulkLinks","fetchOneByRid","objectType","rid","createWithRid","createMediaReference","args","data","fileName","propertyType","MediaReferenceProperties","upload","apiName","mediaItemPath","preview","value","createClient"],"sources":["createClient.ts"],"sourcesContent":["/*\n * Copyright 2024 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 ActionDefinition,\n FilteredPropertyKeys,\n InterfaceDefinition,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SelectArg,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport {\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { additionalContext, type Client } from \"./Client.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport type { Logger } from \"./Logger.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { fetchSingle } from \"./object/fetchSingle.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\n\n// We import it this way to keep compatible with CJS. If we referenced the\n// value of `symbolClientContext` directly, then we would have to a dynamic import\n// in `createClientInternal` which would make it async and a break.\n// Since this is just a string in `@osdk/shared.client2` instead of a symbol,\n// we can safely perform this trick.\ntype newSymbolClientContext =\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n typeof import(\"@osdk/shared.client2\").symbolClientContext;\n\nclass ActionInvoker<Q extends ActionDefinition<any>>\n implements ActionSignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n actionDef: ActionDefinition<any>,\n ) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n\n applyAction: (...args: any[]) => any;\n batchApplyAction: (...args: any[]) => any;\n}\n\nclass QueryInvoker<Q extends QueryDefinition<any>>\n implements QuerySignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n queryDef: QueryDefinition<any>,\n ) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n\n executeFunction: (...args: any[]) => any;\n}\n\n/** @internal */\nexport function createClientInternal(\n objectSetFactory: ObjectSetFactory<any, any>, // first so i can bind\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options: { logger?: Logger } | undefined = undefined,\n fetchFn: typeof globalThis.fetch = fetch,\n): Client {\n if (typeof ontologyRid === \"string\") {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n ontologyRid.then((ontologyRid) => {\n if (!ontologyRid.startsWith(\"ri.\")) {\n // FIXME this promise is not await so this just shows up as an unhandled promise rejection\n throw new Error(\"Invalid ontology RID\");\n }\n });\n }\n\n const clientCtx: MinimalClient = createMinimalClient(\n { ontologyRid },\n baseUrl,\n tokenProvider,\n options,\n fetchFn,\n objectSetFactory,\n );\n\n function clientFn<\n T extends\n | ObjectOrInterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">,\n >(o: T): T extends ObjectTypeDefinition ? ObjectSet<T>\n : T extends InterfaceDefinition ? MinimalObjectSet<T>\n : T extends ActionDefinition<any> ? ActionSignatureFromDef<T>\n : T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : T extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">\n ? { invoke: ExperimentFns<T> }\n : never\n {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx) as any;\n } else if (o.type === \"action\") {\n return new ActionInvoker(\n clientCtx,\n o,\n ) as (T extends ActionDefinition<any>\n // first `as` to the action definition for our \"real\" typecheck\n ? ActionSignatureFromDef<T>\n : never) as any; // then as any for dealing with the conditional return value\n } else if (o.type === \"query\") {\n return new QueryInvoker(\n clientCtx,\n o,\n ) as (T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : never) as any;\n } else if (o.type === \"experiment\") {\n switch (o.name) {\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks.name:\n return {\n getBulkLinks: createBulkLinksAsyncIterFactory(\n clientCtx,\n ),\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:\n return {\n fetchOneByRid: async <\n Q extends ObjectTypeDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectType: Q,\n rid: string,\n options: SelectArg<Q, L, R, S>,\n ) => {\n return await fetchSingle(\n clientCtx,\n objectType,\n options,\n createWithRid(\n rid,\n ),\n ) as Osdk<Q>;\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference.name:\n return {\n createMediaReference: async <\n Q extends ObjectTypeDefinition,\n const L extends FilteredPropertyKeys<Q, \"mediaReference\">,\n >(args: {\n data: Blob;\n fileName: string;\n objectType: Q;\n propertyType: L;\n }) => {\n const { data, fileName, objectType, propertyType } = args;\n return await OntologiesV2.MediaReferenceProperties.upload(\n clientCtx,\n await clientCtx.ontologyRid,\n objectType.apiName,\n propertyType as string,\n data,\n {\n mediaItemPath: fileName,\n preview: true,\n },\n );\n },\n } as any;\n }\n\n throw new Error(\"not implemented\");\n } else {\n throw new Error(\"not implemented\");\n }\n }\n\n const fetchMetadata = fetchMetadataInternal.bind(\n undefined,\n clientCtx,\n );\n\n const symbolClientContext: newSymbolClientContext = \"__osdkClientContext\";\n\n const client: Client = Object.defineProperties<Client>(\n clientFn as Client,\n {\n [oldSymbolClientContext]: {\n value: clientCtx,\n },\n [symbolClientContext]: {\n value: clientCtx,\n },\n [additionalContext]: {\n value: clientCtx,\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n } satisfies Record<keyof Client, PropertyDescriptor>,\n );\n\n return client;\n}\n\nexport const createClient: (\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options?: {\n logger?: Logger;\n } | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n);\n\nfunction createWithRid(\n rid: string,\n) {\n const withRid: WireObjectSet = {\n type: \"static\",\n \"objects\": [rid],\n };\n\n return withRid;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA,SACEA,uDAAuD,EACvDC,gDAAgD,EAChDC,+CAA+C,QAC1C,oBAAoB;AAE3B,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AACnF,SAASC,+BAA+B,QAAQ,iDAAiD;AAEjG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAqB,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAG1D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,QAAQ,gCAAgC;AAEhE,SAASC,UAAU,QAAQ,yBAAyB;;AAGpD;AACA;AACA;AACA;AACA;;AAKA,MAAMC,aAAa,CAEnB;EACEC,WAAWA,CACTC,SAAwB,EACxBC,SAAgC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,IAAIvB,KAAK,CAAC,iBAAiB,CAAC;IACpC,CAAC,MAAM;MACL,MAAM,IAAIA,KAAK,CAAC,iBAAiB,CAAC;IACpC;EACF,CAAC,EAWC;IACE,CAAC5B,sBAAsB,GAAG;MACxBoD,KAAK,EAAEzC;IACT,CAAC;IACD,CARgD,qBAAqB,GAQ9C;MACrByC,KAAK,EAAEzC;IACT,CAAC;IACD,CAACR,iBAAiB,GAAG;MACnBiD,KAAK,EAAEzC;IACT,CAAC;IACDmB,aAAa,EAAE;MACbsB,KAAK,EAAEtB;IACT;EACF,CACF,CAAC;EAED,OAAOC,MAAM;AACf;AAEA,OAAO,MAAMsB,YAQF,GAAGlC,oBAAoB,CAACN,IAAI,CACrCC,SAAS,EACTP,eACF,CAAC;AAED,SAASkC,aAAaA,CACpBD,GAAW,EACX;EAMA,OAL+B;IAC7BL,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAACK,GAAG;EACjB,CAAC;AAGH","ignoreList":[]}
@@ -50,7 +50,7 @@ describe(createWithPropertiesObjectSet, () => {
50
50
  type: "methodInput"
51
51
  }, map);
52
52
  const clause = {
53
- "derivedPropertyName": base => base.pivotTo("lead").aggregate("startDate:approximatePercentile", {
53
+ "derivedPropertyName": base => base.pivotTo("lead").aggregate("employeeId:approximatePercentile", {
54
54
  percentile: 0.5
55
55
  }),
56
56
  "secondaryDerivedPropertyName": base => base.pivotTo("lead").aggregate("fullName:collectSet", {
@@ -72,7 +72,7 @@ describe(createWithPropertiesObjectSet, () => {
72
72
  },
73
73
  "operation": {
74
74
  "approximatePercentile": 0.5,
75
- "selectedPropertyApiName": "startDate",
75
+ "selectedPropertyApiName": "employeeId",
76
76
  "type": "approximatePercentile",
77
77
  },
78
78
  "type": "selection",
@@ -1 +1 @@
1
- {"version":3,"file":"createWithPropertiesObjectSet.test.js","names":["Employee","describe","expect","it","createWithPropertiesObjectSet","map","Map","deriveObjectSet","type","result","base","pivotTo","selectProperty","definition","get","toMatchInlineSnapshot","clause","aggregate","percentile","limit","secondResult","secondDefinition"],"sources":["createWithPropertiesObjectSet.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DerivedProperty } from \"@osdk/api\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { DerivedPropertyDefinition } from \"@osdk/foundry.ontologies\";\nimport { describe, expect, it } from \"vitest\";\nimport { createWithPropertiesObjectSet } from \"./createWithPropertiesObjectSet.js\";\n\ndescribe(createWithPropertiesObjectSet, () => {\n it(\"correctly creates basic object set with derived properties\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"employeeId\"),\n } satisfies DerivedProperty.Clause<Employee>;\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n\n it(\"correctly handles multiple definitions in one clause\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"startDate:approximatePercentile\", {\n percentile: 0.5,\n }),\n\n \"secondaryDerivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"fullName:collectSet\", {\n limit: 10,\n }),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n const secondResult = clause[\"secondaryDerivedPropertyName\"](\n deriveObjectSet,\n );\n const secondDefinition = map.get(secondResult);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"approximatePercentile\": 0.5,\n \"selectedPropertyApiName\": \"startDate\",\n \"type\": \"approximatePercentile\",\n },\n \"type\": \"selection\",\n }\n `);\n\n expect(secondDefinition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"limit\": 10,\n \"selectedPropertyApiName\": \"fullName\",\n \"type\": \"collectSet\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,4BAA4B;AAErD,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,6BAA6B,QAAQ,oCAAoC;AAElFH,QAAQ,CAACG,6BAA6B,EAAE,MAAM;EAC5CD,EAAE,CAAC,4DAA4D,EAAE,MAAM;IACrE,MAAME,GAAG,GAAG,IAAIC,GAAG,CAAiC,CAAC;IACrD,MAAMC,eAAe,GAAGH,6BAA6B,CAACJ,QAAQ,EAAE;MAC9DQ,IAAI,EAAE;IACR,CAAC,EAAEH,GAAG,CAAC;IAOP,MAAMI,MAAM,GALG;MACb,qBAAqB,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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;IAEJb,MAAM,CAACmB,gBAAgB,CAAC,CAACN,qBAAqB,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"createWithPropertiesObjectSet.test.js","names":["Employee","describe","expect","it","createWithPropertiesObjectSet","map","Map","deriveObjectSet","type","result","base","pivotTo","selectProperty","definition","get","toMatchInlineSnapshot","clause","aggregate","percentile","limit","secondResult","secondDefinition"],"sources":["createWithPropertiesObjectSet.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DerivedProperty } from \"@osdk/api\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { DerivedPropertyDefinition } from \"@osdk/foundry.ontologies\";\nimport { describe, expect, it } from \"vitest\";\nimport { createWithPropertiesObjectSet } from \"./createWithPropertiesObjectSet.js\";\n\ndescribe(createWithPropertiesObjectSet, () => {\n it(\"correctly creates basic object set with derived properties\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").selectProperty(\"employeeId\"),\n } satisfies DerivedProperty.Clause<Employee>;\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"get\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n\n it(\"correctly handles multiple definitions in one clause\", () => {\n const map = new Map<any, DerivedPropertyDefinition>();\n const deriveObjectSet = createWithPropertiesObjectSet(Employee, {\n type: \"methodInput\",\n }, map);\n\n const clause: DerivedProperty.Clause<Employee> = {\n \"derivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"employeeId:approximatePercentile\", {\n percentile: 0.5,\n }),\n\n \"secondaryDerivedPropertyName\": (base) =>\n base.pivotTo(\"lead\").aggregate(\"fullName:collectSet\", {\n limit: 10,\n }),\n };\n\n const result = clause[\"derivedPropertyName\"](deriveObjectSet);\n const definition = map.get(result);\n\n const secondResult = clause[\"secondaryDerivedPropertyName\"](\n deriveObjectSet,\n );\n const secondDefinition = map.get(secondResult);\n\n expect(definition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"approximatePercentile\": 0.5,\n \"selectedPropertyApiName\": \"employeeId\",\n \"type\": \"approximatePercentile\",\n },\n \"type\": \"selection\",\n }\n `);\n\n expect(secondDefinition).toMatchInlineSnapshot(`\n {\n \"objectSet\": {\n \"link\": \"lead\",\n \"objectSet\": {\n \"type\": \"methodInput\",\n },\n \"type\": \"searchAround\",\n },\n \"operation\": {\n \"limit\": 10,\n \"selectedPropertyApiName\": \"fullName\",\n \"type\": \"collectSet\",\n },\n \"type\": \"selection\",\n }\n `);\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ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,CAAC;IACL,CAAC;IAED,MAAMV,MAAM,GAAGO,MAAM,CAAC,qBAAqB,CAAC,CAACT,eAAe,CAAC;IAC7D,MAAMM,UAAU,GAAGR,GAAG,CAACS,GAAG,CAACL,MAAM,CAAC;IAElC,MAAMW,YAAY,GAAGJ,MAAM,CAAC,8BAA8B,CAAC,CACzDT,eACF,CAAC;IACD,MAAMc,gBAAgB,GAAGhB,GAAG,CAACS,GAAG,CAACM,YAAY,CAAC;IAE9ClB,MAAM,CAACW,UAAU,CAAC,CAACE,qBAAqB,CAAC;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;IAEJb,MAAM,CAACmB,gBAAgB,CAAC,CAACN,qBAAqB,CAAC;AACnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,CAAC;EACN,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -141,7 +141,7 @@ function reframeAsObjectInPlace(objectDef, interfaceApiName, rawObj) {
141
141
  }
142
142
  function isConforming(client, def, obj, propsToCheck) {
143
143
  for (const propName of propsToCheck) {
144
- if (def.properties[propName].nullable === false && obj[propName] == null) {
144
+ if (propName in def.properties && def.properties[propName].nullable === false && obj[propName] == null) {
145
145
  if (process.env.NODE_ENV !== "production") {
146
146
  client.logger?.debug({
147
147
  obj: {
@@ -1 +1 @@
1
- {"version":3,"file":"convertWireToOsdkObjects.js","names":["invariant","createOsdkObject","convertWireToOsdkObjects","client","objects","interfaceApiName","forceRemoveRid","selectedProps","strictNonNull","logger","debug","fixObjectPropertiesInPlace","ifaceDef","ontologyProvider","getInterfaceDefinition","undefined","ifaceSelected","Object","keys","properties","ret","rawObj","objectDef","getObjectDefinition","$apiName","process","env","NODE_ENV","objProps","conforming","invariantInterfacesAsViews","apiName","isConforming","reframeAsObjectInPlace","convertInterfacePropNamesToObjectPropNames","Error","osdkObject","$as","push","convertWireToOsdkObjects2","interfaceToObjectTypeMappings","interfaceToObjMapping","filter","val","includes","values","primaryKeyApiName","ifacePropsToMap","map","ifaceProp","interfaceMap","newProps","sptProp","regularProp","entries","value","assign","$primaryKey","def","obj","propsToCheck","propName","nullable","$objectType","warning","warn","console","error","objs","__rid","$rid","__apiName","__primaryKey","$title","__title"],"sources":["convertWireToOsdkObjects.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 InterfaceMetadata,\n NullabilityAdherence,\n ObjectMetadata,\n ObjectOrInterfaceDefinition,\n Osdk,\n} from \"@osdk/api\";\nimport type {\n InterfaceToObjectTypeMappings,\n InterfaceTypeApiName,\n OntologyObjectV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n type FetchedObjectTypeDefinition,\n} from \"../ontology/OntologyProvider.js\";\nimport { createOsdkObject } from \"./convertWireToOsdkObjects/createOsdkObject.js\";\n\n/**\n * If interfaceApiName is not undefined, converts the instances of the\n * interface into their respective\n * underlying concrete types and then returns the $as() representation\n * for the consumers.\n *\n * Otherwise just does the conversion\n *\n * May mutate in place for performance reasons. If you need a clean copy,\n * keep it first.\n *\n * However, you must use the returned value, which will be whatever is correct.\n *\n * @internal\n * @param interfaceApiName - if undefined\n */\nexport async function convertWireToOsdkObjects(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n): Promise<Osdk.Instance<ObjectOrInterfaceDefinition>[]> {\n client.logger?.debug(`START convertWireToOsdkObjects()`);\n\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ifaceDef = interfaceApiName\n ? await client.ontologyProvider.getInterfaceDefinition(interfaceApiName)\n : undefined;\n const ifaceSelected = ifaceDef\n ? (selectedProps ?? Object.keys(ifaceDef.properties))\n : undefined;\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (ifaceDef && ifaceSelected) {\n // API returns interface spt names but we cache by real values\n invariantInterfacesAsViews(objectDef, ifaceDef.apiName, client);\n\n conforming &&= isConforming(client, ifaceDef, rawObj, ifaceSelected);\n\n reframeAsObjectInPlace(objectDef, ifaceDef.apiName, rawObj);\n\n objProps = convertInterfacePropNamesToObjectPropNames(\n objectDef,\n ifaceDef.apiName,\n ifaceSelected,\n );\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject = createOsdkObject(client, objectDef, rawObj);\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n client.logger?.debug(`END convertWireToOsdkObjects()`);\n return ret;\n}\n\n/**\n * @internal\n */\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n interfaceToObjectTypeMappings: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n > = {},\n): Promise<Osdk.Instance<ObjectOrInterfaceDefinition>[]> {\n client.logger?.debug(`START convertWireToOsdkObjects2()`);\n\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n const interfaceToObjMapping = interfaceApiName\n ? interfaceToObjectTypeMappings[interfaceApiName as InterfaceTypeApiName][\n rawObj.$apiName\n ]\n : undefined;\n\n const ifaceSelected = interfaceApiName && interfaceToObjMapping\n ? (selectedProps\n ? Object.keys(interfaceToObjMapping).filter(\n val => {\n selectedProps?.includes(interfaceToObjMapping[val]);\n },\n )\n : [\n ...Object.values(interfaceToObjMapping),\n objectDef.primaryKeyApiName,\n ])\n : undefined;\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (interfaceApiName && ifaceSelected) {\n invariantInterfacesAsViews(objectDef, interfaceApiName, client);\n\n objProps = ifaceSelected;\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject = createOsdkObject(client, objectDef, rawObj);\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n client.logger?.debug(`END convertWireToOsdkObjects2()`);\n return ret;\n}\n\n/**\n * Utility function that lets us take down selected property names from an interface\n * and convert them to an array of property names on an object.\n */\nfunction convertInterfacePropNamesToObjectPropNames(\n objectDef: FetchedObjectTypeDefinition & { interfaceMap: {} },\n interfaceApiName: string,\n ifacePropsToMap: readonly string[],\n) {\n return ifacePropsToMap.map((ifaceProp) =>\n objectDef.interfaceMap[interfaceApiName][ifaceProp]\n );\n}\n\n/**\n * Takes a raw object from the wire (contextually as an interface) and\n * updates the fields to reflect the underlying objectDef instead\n * @param objectDef\n * @param interfaceApiName\n * @param client\n * @param rawObj\n */\nfunction reframeAsObjectInPlace(\n objectDef: FetchedObjectTypeDefinition & { interfaceMap: {} },\n interfaceApiName: string,\n rawObj: OntologyObjectV2,\n) {\n const newProps: Record<string, any> = {};\n for (\n const [sptProp, regularProp] of Object.entries(\n objectDef.interfaceMap[interfaceApiName],\n )\n ) {\n if (sptProp in rawObj) {\n const value = rawObj[sptProp];\n delete rawObj[sptProp];\n if (value !== undefined) {\n newProps[regularProp] = value;\n }\n }\n }\n Object.assign(rawObj, newProps);\n\n if (!(objectDef.primaryKeyApiName in rawObj)) {\n rawObj[objectDef.primaryKeyApiName] = rawObj.$primaryKey;\n }\n}\n\nfunction isConforming(\n client: MinimalClient,\n def:\n | InterfaceMetadata\n | ObjectMetadata,\n obj: OntologyObjectV2,\n propsToCheck: readonly string[],\n) {\n for (const propName of propsToCheck) {\n if (def.properties[propName].nullable === false && obj[propName] == null) {\n if (process.env.NODE_ENV !== \"production\") {\n client.logger?.debug(\n {\n obj: {\n $objectType: obj[\"$objectType\"],\n $primaryKey: obj[\"$primaryKey\"],\n },\n },\n `Found object that does not conform to its definition. Expected ${def.apiName}'s ${propName} to not be null.`,\n );\n }\n return false;\n }\n }\n return true;\n}\n\nfunction invariantInterfacesAsViews(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n client: MinimalClient,\n): asserts objectDef is typeof objectDef & { interfaceMap: {} } {\n if (objectDef.interfaceMap?.[interfaceApiName] == null) {\n const warning =\n \"Interfaces are only supported 'as views' but your metadata object is missing the correct information. This suggests your interfaces have not been migrated to the newer version yet and you cannot use this version of the SDK.\";\n if (client.logger) {\n client.logger.warn(warning);\n } else {\n // eslint-disable-next-line no-console\n console.error(`WARNING! ${warning}`);\n }\n throw new Error(warning);\n }\n}\n\nfunction fixObjectPropertiesInPlace(\n objs: OntologyObjectV2[],\n forceRemoveRid: boolean,\n) {\n for (const obj of objs) {\n if (forceRemoveRid) {\n delete obj.__rid;\n }\n\n if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName ??= obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.$apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey ??= obj.__primaryKey;\n obj.$title ??= obj.__title;\n\n // we don't want people to use these\n delete obj.__apiName;\n delete obj.__primaryKey;\n delete obj.__title;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,OAAOA,SAAS,MAAM,gBAAgB;AAKtC,SAASC,gBAAgB,QAAQ,gDAAgD;;AAEjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwBA,CAC5CC,MAAqB,EACrBC,OAA2B,EAC3BC,gBAAoC,EACpCC,cAAuB,GAAG,KAAK,EAC/BC,aAAqC,EACrCC,aAAmC,GAAG,KAAK,EACY;EACvDL,MAAM,CAACM,MAAM,EAAEC,KAAK,CAAC,kCAAkC,CAAC;EAExDC,0BAA0B,CAACP,OAAO,EAAEE,cAAc,CAAC;EAEnD,MAAMM,QAAQ,GAAGP,gBAAgB,GAC7B,MAAMF,MAAM,CAACU,gBAAgB,CAACC,sBAAsB,CAACT,gBAAgB,CAAC,GACtEU,SAAS;EACb,MAAMC,aAAa,GAAGJ,QAAQ,GACzBL,aAAa,IAAIU,MAAM,CAACC,IAAI,CAACN,QAAQ,CAACO,UAAU,CAAC,GAClDJ,SAAS;EAEb,MAAMK,GAAG,GAAG,EAAE;EACd,KAAK,MAAMC,MAAM,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/B,0BAA0BA,CACjCR,SAAsC,EACtCjB,gBAAwB,EACxBF,MAAqB,EACyC;EAC9D,IAAImB,SAAS,CAAC4B,YAAY,GAAG7C,gBAAgB,CAAC,IAAI,IAAI,EAAE;IACtD,MAAM2D,OAAO,GACX,iOAAiO;IACnO,IAAI7D,MAAM,CAACM,MAAM,EAAE;MACjBN,MAAM,CAACM,MAAM,CAACwD,IAAI,CAACD,OAAO,CAAC;IAC7B,CAAC,MAAM;MACL;MACAE,OAAO,CAACC,KAAK,CAAC,YAAYH,OAAO,EAAE,CAAC;IACtC;IACA,MAAM,IAAI7B,KAAK,CAAC6B,OAAO,CAAC;EAC1B;AACF;AAEA,SAASrD,0BAA0BA,CACjCyD,IAAwB,EACxB9D,cAAuB,EACvB;EACA,KAAK,MAAMqD,GAAG,IAAIS,IAAI,EAAE;IACtB,IAAI9D,cAAc,EAAE;MAClB,OAAOqD,GAAG,CAACU,KAAK;IAClB;IAEA,IAAIV,GAAG,CAACU,KAAK,EAAE;MACbV,GAAG,CAACW,IAAI,GAAGX,GAAG,CAACU,KAAK;MACpB,OAAOV,GAAG,CAACU,KAAK;IAClB;;IAEA;IACAV,GAAG,CAACnC,QAAQ,KAAKmC,GAAG,CAACY,SAAS;;IAE9B;IACA;IACAZ,GAAG,CAACI,WAAW,GAAGJ,GAAG,CAACnC,QAAQ;;IAE9B;IACAmC,GAAG,CAACF,WAAW,KAAKE,GAAG,CAACa,YAAY;IACpCb,GAAG,CAACc,MAAM,KAAKd,GAAG,CAACe,OAAO;;IAE1B;IACA,OAAOf,GAAG,CAACY,SAAS;IACpB,OAAOZ,GAAG,CAACa,YAAY;IACvB,OAAOb,GAAG,CAACe,OAAO;EACpB;AACF","ignoreList":[]}
1
+ {"version":3,"file":"convertWireToOsdkObjects.js","names":["invariant","createOsdkObject","convertWireToOsdkObjects","client","objects","interfaceApiName","forceRemoveRid","selectedProps","strictNonNull","logger","debug","fixObjectPropertiesInPlace","ifaceDef","ontologyProvider","getInterfaceDefinition","undefined","ifaceSelected","Object","keys","properties","ret","rawObj","objectDef","getObjectDefinition","$apiName","process","env","NODE_ENV","objProps","conforming","invariantInterfacesAsViews","apiName","isConforming","reframeAsObjectInPlace","convertInterfacePropNamesToObjectPropNames","Error","osdkObject","$as","push","convertWireToOsdkObjects2","interfaceToObjectTypeMappings","interfaceToObjMapping","filter","val","includes","values","primaryKeyApiName","ifacePropsToMap","map","ifaceProp","interfaceMap","newProps","sptProp","regularProp","entries","value","assign","$primaryKey","def","obj","propsToCheck","propName","nullable","$objectType","warning","warn","console","error","objs","__rid","$rid","__apiName","__primaryKey","$title","__title"],"sources":["convertWireToOsdkObjects.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 InterfaceMetadata,\n NullabilityAdherence,\n ObjectMetadata,\n ObjectOrInterfaceDefinition,\n Osdk,\n} from \"@osdk/api\";\nimport type {\n InterfaceToObjectTypeMappings,\n InterfaceTypeApiName,\n OntologyObjectV2,\n} from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n type FetchedObjectTypeDefinition,\n} from \"../ontology/OntologyProvider.js\";\nimport { createOsdkObject } from \"./convertWireToOsdkObjects/createOsdkObject.js\";\n\n/**\n * If interfaceApiName is not undefined, converts the instances of the\n * interface into their respective\n * underlying concrete types and then returns the $as() representation\n * for the consumers.\n *\n * Otherwise just does the conversion\n *\n * May mutate in place for performance reasons. If you need a clean copy,\n * keep it first.\n *\n * However, you must use the returned value, which will be whatever is correct.\n *\n * @internal\n * @param interfaceApiName - if undefined\n */\nexport async function convertWireToOsdkObjects(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n): Promise<Osdk.Instance<ObjectOrInterfaceDefinition>[]> {\n client.logger?.debug(`START convertWireToOsdkObjects()`);\n\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ifaceDef = interfaceApiName\n ? await client.ontologyProvider.getInterfaceDefinition(interfaceApiName)\n : undefined;\n const ifaceSelected = ifaceDef\n ? (selectedProps ?? Object.keys(ifaceDef.properties))\n : undefined;\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (ifaceDef && ifaceSelected) {\n // API returns interface spt names but we cache by real values\n invariantInterfacesAsViews(objectDef, ifaceDef.apiName, client);\n\n conforming &&= isConforming(client, ifaceDef, rawObj, ifaceSelected);\n\n reframeAsObjectInPlace(objectDef, ifaceDef.apiName, rawObj);\n\n objProps = convertInterfacePropNamesToObjectPropNames(\n objectDef,\n ifaceDef.apiName,\n ifaceSelected,\n );\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject = createOsdkObject(client, objectDef, rawObj);\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n client.logger?.debug(`END convertWireToOsdkObjects()`);\n return ret;\n}\n\n/**\n * @internal\n */\nexport async function convertWireToOsdkObjects2(\n client: MinimalClient,\n objects: OntologyObjectV2[],\n interfaceApiName: string | undefined,\n forceRemoveRid: boolean = false,\n selectedProps?: ReadonlyArray<string>,\n strictNonNull: NullabilityAdherence = false,\n interfaceToObjectTypeMappings: Record<\n InterfaceTypeApiName,\n InterfaceToObjectTypeMappings\n > = {},\n): Promise<Osdk.Instance<ObjectOrInterfaceDefinition>[]> {\n client.logger?.debug(`START convertWireToOsdkObjects2()`);\n\n fixObjectPropertiesInPlace(objects, forceRemoveRid);\n\n const ret = [];\n for (const rawObj of objects) {\n const objectDef = await client.ontologyProvider.getObjectDefinition(\n rawObj.$apiName,\n );\n invariant(objectDef, `Missing definition for '${rawObj.$apiName}'`);\n\n const interfaceToObjMapping = interfaceApiName\n ? interfaceToObjectTypeMappings[interfaceApiName as InterfaceTypeApiName][\n rawObj.$apiName\n ]\n : undefined;\n\n const ifaceSelected = interfaceApiName && interfaceToObjMapping\n ? (selectedProps\n ? Object.keys(interfaceToObjMapping).filter(\n val => {\n selectedProps?.includes(interfaceToObjMapping[val]);\n },\n )\n : [\n ...Object.values(interfaceToObjMapping),\n objectDef.primaryKeyApiName,\n ])\n : undefined;\n\n // default value for when we are checking an object\n let objProps;\n\n let conforming = true;\n if (interfaceApiName && ifaceSelected) {\n invariantInterfacesAsViews(objectDef, interfaceApiName, client);\n\n objProps = ifaceSelected;\n } else {\n objProps = selectedProps ?? Object.keys(objectDef.properties);\n }\n\n conforming &&= isConforming(client, objectDef, rawObj, objProps);\n\n if (strictNonNull === \"throw\" && !conforming) {\n throw new Error(\n \"Unable to safely convert objects as some non nullable properties are null\",\n );\n } else if (strictNonNull === \"drop\" && !conforming) {\n continue;\n }\n\n let osdkObject = createOsdkObject(client, objectDef, rawObj);\n if (interfaceApiName) osdkObject = osdkObject.$as(interfaceApiName);\n\n ret.push(osdkObject);\n }\n\n client.logger?.debug(`END convertWireToOsdkObjects2()`);\n return ret;\n}\n\n/**\n * Utility function that lets us take down selected property names from an interface\n * and convert them to an array of property names on an object.\n */\nfunction convertInterfacePropNamesToObjectPropNames(\n objectDef: FetchedObjectTypeDefinition & { interfaceMap: {} },\n interfaceApiName: string,\n ifacePropsToMap: readonly string[],\n) {\n return ifacePropsToMap.map((ifaceProp) =>\n objectDef.interfaceMap[interfaceApiName][ifaceProp]\n );\n}\n\n/**\n * Takes a raw object from the wire (contextually as an interface) and\n * updates the fields to reflect the underlying objectDef instead\n * @param objectDef\n * @param interfaceApiName\n * @param client\n * @param rawObj\n */\nfunction reframeAsObjectInPlace(\n objectDef: FetchedObjectTypeDefinition & { interfaceMap: {} },\n interfaceApiName: string,\n rawObj: OntologyObjectV2,\n) {\n const newProps: Record<string, any> = {};\n for (\n const [sptProp, regularProp] of Object.entries(\n objectDef.interfaceMap[interfaceApiName],\n )\n ) {\n if (sptProp in rawObj) {\n const value = rawObj[sptProp];\n delete rawObj[sptProp];\n if (value !== undefined) {\n newProps[regularProp] = value;\n }\n }\n }\n Object.assign(rawObj, newProps);\n\n if (!(objectDef.primaryKeyApiName in rawObj)) {\n rawObj[objectDef.primaryKeyApiName] = rawObj.$primaryKey;\n }\n}\n\nfunction isConforming(\n client: MinimalClient,\n def:\n | InterfaceMetadata\n | ObjectMetadata,\n obj: OntologyObjectV2,\n propsToCheck: readonly string[],\n) {\n for (const propName of propsToCheck) {\n if (\n propName in def.properties && def.properties[propName].nullable === false\n && obj[propName] == null\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n client.logger?.debug(\n {\n obj: {\n $objectType: obj[\"$objectType\"],\n $primaryKey: obj[\"$primaryKey\"],\n },\n },\n `Found object that does not conform to its definition. Expected ${def.apiName}'s ${propName} to not be null.`,\n );\n }\n return false;\n }\n }\n return true;\n}\n\nfunction invariantInterfacesAsViews(\n objectDef: FetchedObjectTypeDefinition,\n interfaceApiName: string,\n client: MinimalClient,\n): asserts objectDef is typeof objectDef & { interfaceMap: {} } {\n if (objectDef.interfaceMap?.[interfaceApiName] == null) {\n const warning =\n \"Interfaces are only supported 'as views' but your metadata object is missing the correct information. This suggests your interfaces have not been migrated to the newer version yet and you cannot use this version of the SDK.\";\n if (client.logger) {\n client.logger.warn(warning);\n } else {\n // eslint-disable-next-line no-console\n console.error(`WARNING! ${warning}`);\n }\n throw new Error(warning);\n }\n}\n\nfunction fixObjectPropertiesInPlace(\n objs: OntologyObjectV2[],\n forceRemoveRid: boolean,\n) {\n for (const obj of objs) {\n if (forceRemoveRid) {\n delete obj.__rid;\n }\n\n if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName ??= obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.$apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey ??= obj.__primaryKey;\n obj.$title ??= obj.__title;\n\n // we don't want people to use these\n delete obj.__apiName;\n delete obj.__primaryKey;\n delete obj.__title;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,OAAOA,SAAS,MAAM,gBAAgB;AAKtC,SAASC,gBAAgB,QAAQ,gDAAgD;;AAEjF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,wBAAwBA,CAC5CC,MAAqB,EACrBC,OAA2B,EAC3BC,gBAAoC,EACpCC,cAAuB,GAAG,KAAK,EAC/BC,aAAqC,EACrCC,aAAmC,GAAG,KAAK,EACY;EACvDL,MAAM,CAACM,MAAM,EAAEC,KAAK,CAAC,kCAAkC,CAAC;EAExDC,0BAA0B,CAACP,OAAO,EAAEE,cAAc,CAAC;EAEnD,MAAMM,QAAQ,GAAGP,gBAAgB,GAC7B,MAAMF,MAAM,CAACU,gBAAgB,CAACC,sBAAsB,CAACT,gBAAgB,CAAC,GACtEU,S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IACvB,OAAOb,GAAG,CAACe,OAAO;EACpB;AACF","ignoreList":[]}
@@ -605,7 +605,9 @@ describe("ObjectSet", () => {
605
605
  expect(objectWithRdp.derivedPropertyName).toBe(1);
606
606
  const objectWithUndefinedRdp = await client(Employee).withProperties({
607
607
  "derivedPropertyName": base => base.pivotTo("lead").selectProperty("employeeId")
608
- }).fetchOne(50036);
608
+ }).fetchOne(50036, {
609
+ $select: ["derivedPropertyName"]
610
+ });
609
611
  expect(objectWithUndefinedRdp.derivedPropertyName).toBeUndefined();
610
612
  });
611
613
  });