@osdk/client 2.2.0 → 2.2.1

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 (31) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/build/browser/Client.js +1 -1
  3. package/build/browser/Client.js.map +1 -1
  4. package/build/browser/createMediaReferenceProperty.js +7 -1
  5. package/build/browser/createMediaReferenceProperty.js.map +1 -1
  6. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +2 -1
  7. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  8. package/build/browser/object/media.test.js +20 -1
  9. package/build/browser/object/media.test.js.map +1 -1
  10. package/build/browser/util/UserAgent.js +1 -1
  11. package/build/cjs/{chunk-5JZGGCIW.cjs → chunk-LPYAXRWJ.cjs} +14 -14
  12. package/build/cjs/{chunk-5JZGGCIW.cjs.map → chunk-LPYAXRWJ.cjs.map} +1 -1
  13. package/build/cjs/{chunk-HDAQ6JIR.cjs → chunk-UCW7RLKM.cjs} +2 -2
  14. package/build/cjs/{chunk-HDAQ6JIR.cjs.map → chunk-UCW7RLKM.cjs.map} +1 -1
  15. package/build/cjs/index.cjs +56 -49
  16. package/build/cjs/index.cjs.map +1 -1
  17. package/build/cjs/public/internal.cjs +8 -8
  18. package/build/cjs/public/unstable-do-not-use.cjs +8 -8
  19. package/build/esm/Client.js +1 -1
  20. package/build/esm/Client.js.map +1 -1
  21. package/build/esm/createMediaReferenceProperty.js +7 -1
  22. package/build/esm/createMediaReferenceProperty.js.map +1 -1
  23. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +2 -1
  24. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  25. package/build/esm/object/media.test.js +20 -1
  26. package/build/esm/object/media.test.js.map +1 -1
  27. package/build/esm/util/UserAgent.js +1 -1
  28. package/build/types/Client.d.ts +1 -1
  29. package/build/types/createMediaReferenceProperty.d.ts +4 -1
  30. package/build/types/createMediaReferenceProperty.d.ts.map +1 -1
  31. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @osdk/client
2
2
 
3
+ ## 2.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 87e2264: Add 'getMediaReference' method to Media
8
+ - Updated dependencies [87e2264]
9
+ - @osdk/api@2.2.1
10
+ - @osdk/generator-converters@2.2.1
11
+ - @osdk/client.unstable@2.2.1
12
+
3
13
  ## 2.2.0
4
14
 
5
15
  ### Patch Changes
@@ -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.2.0";
24
+ const MaxOsdkVersion = "2.2.1";
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\"> | Experiment<\"2.2.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":[]}
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\"> | Experiment<\"2.2.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.1\";\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":[]}
@@ -16,6 +16,7 @@
16
16
 
17
17
  import * as OntologiesV2 from "@osdk/foundry.ontologies";
18
18
  export class MediaReferencePropertyImpl {
19
+ #mediaReference;
19
20
  #triplet;
20
21
  #client;
21
22
  constructor(args) {
@@ -23,10 +24,12 @@ export class MediaReferencePropertyImpl {
23
24
  client,
24
25
  objectApiName,
25
26
  primaryKey,
26
- propertyName
27
+ propertyName,
28
+ mediaReference
27
29
  } = args;
28
30
  this.#client = client;
29
31
  this.#triplet = [objectApiName, primaryKey, propertyName];
32
+ this.#mediaReference = mediaReference;
30
33
  }
31
34
  async fetchContents() {
32
35
  return OntologiesV2.MediaReferenceProperties.getMediaContent(this.#client, await this.#client.ontologyRid, ...this.#triplet, {
@@ -43,5 +46,8 @@ export class MediaReferencePropertyImpl {
43
46
  mediaType: r.mediaType
44
47
  };
45
48
  }
49
+ getMediaReference() {
50
+ return this.#mediaReference;
51
+ }
46
52
  }
47
53
  //# sourceMappingURL=createMediaReferenceProperty.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createMediaReferenceProperty.js","names":["OntologiesV2","MediaReferencePropertyImpl","triplet","client","constructor","args","objectApiName","primaryKey","propertyName","fetchContents","MediaReferenceProperties","getMediaContent","ontologyRid","preview","fetchMetadata","r","getMediaMetadata","path","sizeBytes","Number","mediaType"],"sources":["createMediaReferenceProperty.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 { Media, MediaMetadata } from \"@osdk/api\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\n\nexport class MediaReferencePropertyImpl implements Media {\n #triplet: [string, any, string];\n #client: MinimalClient;\n\n constructor(args: {\n client: MinimalClient;\n objectApiName: string;\n primaryKey: any;\n propertyName: string;\n }) {\n const { client, objectApiName, primaryKey, propertyName } = args;\n this.#client = client;\n this.#triplet = [objectApiName, primaryKey, propertyName];\n }\n\n public async fetchContents(): Promise<Response> {\n return OntologiesV2.MediaReferenceProperties.getMediaContent(\n this.#client,\n await this.#client.ontologyRid,\n ...this.#triplet,\n {\n preview: true, // TODO: Can turn this back off when backend is no longer in beta.\n },\n );\n }\n\n public async fetchMetadata(): Promise<MediaMetadata> {\n const r = await OntologiesV2.MediaReferenceProperties.getMediaMetadata(\n this.#client,\n await this.#client.ontologyRid,\n ...this.#triplet,\n {\n preview: true, // TODO: Can turn this back off when backend is no longer in beta.\n },\n );\n return {\n path: r.path as string,\n sizeBytes: Number(r.sizeBytes),\n mediaType: r.mediaType,\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AAGxD,OAAO,MAAMC,0BAA0B,CAAkB;EACvD,CAACC,OAAO;EACR,CAACC,MAAM;EAEPC,WAAWA,CAACC,IAKX,EAAE;IACD,MAAM;MAAEF,MAAM;MAAEG,aAAa;MAAEC,UAAU;MAAEC;IAAa,CAAC,GAAGH,IAAI;IAChE,IAAI,CAAC,CAACF,MAAM,GAAGA,MAAM;IACrB,IAAI,CAAC,CAACD,OAAO,GAAG,CAACI,aAAa,EAAEC,UAAU,EAAEC,YAAY,CAAC;EAC3D;EAEA,MAAaC,aAAaA,CAAA,EAAsB;IAC9C,OAAOT,YAAY,CAACU,wBAAwB,CAACC,eAAe,CAC1D,IAAI,CAAC,CAACR,MAAM,EACZ,MAAM,IAAI,CAAC,CAACA,MAAM,CAACS,WAAW,EAC9B,GAAG,IAAI,CAAC,CAACV,OAAO,EAChB;MACEW,OAAO,EAAE,IAAI,CAAE;IACjB,CACF,CAAC;EACH;EAEA,MAAaC,aAAaA,CAAA,EAA2B;IACnD,MAAMC,CAAC,GAAG,MAAMf,YAAY,CAACU,wBAAwB,CAACM,gBAAgB,CACpE,IAAI,CAAC,CAACb,MAAM,EACZ,MAAM,IAAI,CAAC,CAACA,MAAM,CAACS,WAAW,EAC9B,GAAG,IAAI,CAAC,CAACV,OAAO,EAChB;MACEW,OAAO,EAAE,IAAI,CAAE;IACjB,CACF,CAAC;IACD,OAAO;MACLI,IAAI,EAAEF,CAAC,CAACE,IAAc;MACtBC,SAAS,EAAEC,MAAM,CAACJ,CAAC,CAACG,SAAS,CAAC;MAC9BE,SAAS,EAAEL,CAAC,CAACK;IACf,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"createMediaReferenceProperty.js","names":["OntologiesV2","MediaReferencePropertyImpl","mediaReference","triplet","client","constructor","args","objectApiName","primaryKey","propertyName","fetchContents","MediaReferenceProperties","getMediaContent","ontologyRid","preview","fetchMetadata","r","getMediaMetadata","path","sizeBytes","Number","mediaType","getMediaReference"],"sources":["createMediaReferenceProperty.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 { Media, MediaMetadata, MediaReference } from \"@osdk/api\";\nimport type { MediaReference as CoreMediaReference } from \"@osdk/foundry.core\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\n\nexport class MediaReferencePropertyImpl implements Media {\n #mediaReference: MediaReference;\n #triplet: [string, any, string];\n #client: MinimalClient;\n\n constructor(args: {\n client: MinimalClient;\n objectApiName: string;\n primaryKey: any;\n propertyName: string;\n mediaReference: CoreMediaReference;\n }) {\n const {\n client,\n objectApiName,\n primaryKey,\n propertyName,\n mediaReference,\n } = args;\n this.#client = client;\n this.#triplet = [objectApiName, primaryKey, propertyName];\n this.#mediaReference = mediaReference;\n }\n\n public async fetchContents(): Promise<Response> {\n return OntologiesV2.MediaReferenceProperties.getMediaContent(\n this.#client,\n await this.#client.ontologyRid,\n ...this.#triplet,\n {\n preview: true, // TODO: Can turn this back off when backend is no longer in beta.\n },\n );\n }\n\n public async fetchMetadata(): Promise<MediaMetadata> {\n const r = await OntologiesV2.MediaReferenceProperties.getMediaMetadata(\n this.#client,\n await this.#client.ontologyRid,\n ...this.#triplet,\n {\n preview: true, // TODO: Can turn this back off when backend is no longer in beta.\n },\n );\n return {\n path: r.path as string,\n sizeBytes: Number(r.sizeBytes),\n mediaType: r.mediaType,\n };\n }\n\n public getMediaReference(): MediaReference {\n return this.#mediaReference;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,KAAKA,YAAY,MAAM,0BAA0B;AAGxD,OAAO,MAAMC,0BAA0B,CAAkB;EACvD,CAACC,cAAc;EACf,CAACC,OAAO;EACR,CAACC,MAAM;EAEPC,WAAWA,CAACC,IAMX,EAAE;IACD,MAAM;MACJF,MAAM;MACNG,aAAa;MACbC,UAAU;MACVC,YAAY;MACZP;IACF,CAAC,GAAGI,IAAI;IACR,IAAI,CAAC,CAACF,MAAM,GAAGA,MAAM;IACrB,IAAI,CAAC,CAACD,OAAO,GAAG,CAACI,aAAa,EAAEC,UAAU,EAAEC,YAAY,CAAC;IACzD,IAAI,CAAC,CAACP,cAAc,GAAGA,cAAc;EACvC;EAEA,MAAaQ,aAAaA,CAAA,EAAsB;IAC9C,OAAOV,YAAY,CAACW,wBAAwB,CAACC,eAAe,CAC1D,IAAI,CAAC,CAACR,MAAM,EACZ,MAAM,IAAI,CAAC,CAACA,MAAM,CAACS,WAAW,EAC9B,GAAG,IAAI,CAAC,CAACV,OAAO,EAChB;MACEW,OAAO,EAAE,IAAI,CAAE;IACjB,CACF,CAAC;EACH;EAEA,MAAaC,aAAaA,CAAA,EAA2B;IACnD,MAAMC,CAAC,GAAG,MAAMhB,YAAY,CAACW,wBAAwB,CAACM,gBAAgB,CACpE,IAAI,CAAC,CAACb,MAAM,EACZ,MAAM,IAAI,CAAC,CAACA,MAAM,CAACS,WAAW,EAC9B,GAAG,IAAI,CAAC,CAACV,OAAO,EAChB;MACEW,OAAO,EAAE,IAAI,CAAE;IACjB,CACF,CAAC;IACD,OAAO;MACLI,IAAI,EAAEF,CAAC,CAACE,IAAc;MACtBC,SAAS,EAAEC,MAAM,CAACJ,CAAC,CAACG,SAAS,CAAC;MAC9BE,SAAS,EAAEL,CAAC,CAACK;IACf,CAAC;EACH;EAEOC,iBAAiBA,CAAA,EAAmB;IACzC,OAAO,IAAI,CAAC,CAACpB,cAAc;EAC7B;AACF","ignoreList":[]}
@@ -155,7 +155,8 @@ function createSpecialProperty(client, objectDef, rawObject, p) {
155
155
  client,
156
156
  objectApiName: objectDef.apiName,
157
157
  primaryKey: rawObject[objectDef.primaryKeyApiName],
158
- propertyName: p
158
+ propertyName: p,
159
+ mediaReference: rawValue
159
160
  });
160
161
  }
161
162
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createOsdkObject.js","names":["invariant","GeotimeSeriesPropertyImpl","MediaReferencePropertyImpl","TimeSeriesPropertyImpl","hydrateAttachmentFromRidInternal","createObjectSpecifierFromPrimaryKey","get$as","get$link","ClientRef","ObjectDefRef","UnderlyingOsdkObject","specialPropertyTypes","Set","basePropDefs","get","value","update","rawObj","def","createOsdkObject","primaryKeyApiName","Error","apiName","titleProperty","$title","newObject","$primaryKey","enumerable","client","objectDef","simpleOsdkProperties","derivedPropertyTypeByName","Object","defineProperties","propKey","keys","properties","type","has","createSpecialProperty","modifyRdpProperties","freeze","rawValue","definition","operation","num","Number","isSafeInteger","process","env","NODE_ENV","selectedOrCollectedPropertyType","Array","isArray","map","a","rid","rawObject","p","propDef","time","timestamp","coordinates","position","undefined","objectApiName","primaryKey","propertyName"],"sources":["createOsdkObject.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 { Attachment, ReferenceValue } from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { GeotimeSeriesPropertyImpl } from \"../../createGeotimeSeriesProperty.js\";\nimport { MediaReferencePropertyImpl } from \"../../createMediaReferenceProperty.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport type { DerivedPropertyRuntimeMetadata } from \"../../derivedProperties/derivedPropertyRuntimeMetadata.js\";\nimport type { MinimalClient } from \"../../MinimalClientContext.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport { hydrateAttachmentFromRidInternal } from \"../../public-utils/hydrateAttachmentFromRid.js\";\nimport { createObjectSpecifierFromPrimaryKey } from \"../../util/objectSpecifierUtils.js\";\nimport type { SimpleOsdkProperties } from \"../SimpleOsdkProperties.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport {\n ClientRef,\n ObjectDefRef,\n UnderlyingOsdkObject,\n} from \"./InternalSymbols.js\";\nimport type { ObjectHolder } from \"./ObjectHolder.js\";\n\nconst specialPropertyTypes = new Set(\n [\n \"attachment\",\n \"geotimeSeriesReference\",\n \"mediaReference\",\n \"numericTimeseries\",\n \"stringTimeseries\",\n \"sensorTimeseries\",\n ],\n);\n\n// kept separate so we are not redefining these functions\n// every time an object is created.\nconst basePropDefs = {\n \"$as\": {\n get: function(this: ObjectHolder) {\n return get$as(this[ObjectDefRef]);\n },\n },\n \"$link\": {\n get: function(this: ObjectHolder) {\n return get$link(this);\n },\n },\n \"$clone\": {\n value: function(\n this: ObjectHolder,\n update: Record<string, any> | undefined,\n ) {\n // I think `rawObj` is the same thing as `this` and can be removed?\n const rawObj = this[UnderlyingOsdkObject] as SimpleOsdkProperties;\n const def = this[ObjectDefRef];\n\n if (update == null) {\n return createOsdkObject(this[ClientRef], def, { ...rawObj });\n }\n\n if (\n def.primaryKeyApiName in update\n && rawObj[def.primaryKeyApiName] !== update[def.primaryKeyApiName]\n ) {\n throw new Error(\n `Cannot update ${def.apiName} object with differing primary key values `,\n );\n }\n\n if (def.titleProperty in update && !(\"$title\" in update)) {\n update.$title = update[def.titleProperty];\n }\n\n const newObject = { ...this[UnderlyingOsdkObject], ...update };\n return createOsdkObject(this[ClientRef], this[ObjectDefRef], newObject);\n },\n },\n \"$objectSpecifier\": {\n get: function(this: ObjectHolder) {\n const rawObj = this[UnderlyingOsdkObject];\n return createObjectSpecifierFromPrimaryKey(\n this[ObjectDefRef],\n rawObj.$primaryKey,\n );\n },\n enumerable: true,\n },\n};\n\n/**\n * @internal\n * @param client\n * @param objectDef\n * @param simpleOsdkProperties\n */\nexport function createOsdkObject(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n simpleOsdkProperties: SimpleOsdkProperties,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata = {},\n): ObjectHolder {\n // updates the object's \"hidden class/map\".\n const rawObj = simpleOsdkProperties as ObjectHolder;\n Object.defineProperties(\n rawObj,\n {\n [UnderlyingOsdkObject]: {\n enumerable: false,\n value: simpleOsdkProperties,\n },\n [ObjectDefRef]: { value: objectDef, enumerable: false },\n [ClientRef]: { value: client, enumerable: false },\n ...basePropDefs,\n } satisfies Record<keyof ObjectHolder, PropertyDescriptor>,\n );\n\n // Assign the special values\n for (const propKey of Object.keys(rawObj)) {\n if (\n propKey in objectDef.properties\n && typeof (objectDef.properties[propKey].type) === \"string\"\n && specialPropertyTypes.has(objectDef.properties[propKey].type)\n ) {\n rawObj[propKey] = createSpecialProperty(\n client,\n objectDef,\n rawObj,\n propKey,\n );\n } else if (propKey in derivedPropertyTypeByName) {\n rawObj[propKey] = modifyRdpProperties(\n client,\n derivedPropertyTypeByName,\n rawObj[propKey],\n propKey,\n );\n }\n }\n\n return Object.freeze(rawObj);\n}\n\nfunction modifyRdpProperties(\n client: MinimalClient,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n rawValue: any,\n propKey: string,\n): any {\n if (\n derivedPropertyTypeByName[propKey].definition.type === \"selection\"\n && derivedPropertyTypeByName[propKey].definition.operation.type\n === \"count\"\n ) {\n const num = Number(rawValue);\n invariant(\n Number.isSafeInteger(num),\n \"Count aggregation for derived property \" + propKey\n + \" returned a value larger than safe integer.\",\n );\n return num;\n } // Selected or collected properties need to be deserialized specially when constructed with RDP\n else if (\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n != null\n && typeof (derivedPropertyTypeByName[propKey]\n .selectedOrCollectedPropertyType.type)\n === \"string\"\n && specialPropertyTypes.has(\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n .type,\n )\n ) {\n switch (\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n ?.type\n ) {\n case \"attachment\":\n if (Array.isArray(rawValue)) {\n return rawValue.map(a =>\n hydrateAttachmentFromRidInternal(client, a.rid)\n );\n } else {\n return hydrateAttachmentFromRidInternal(\n client,\n (rawValue as Attachment).rid,\n );\n }\n break;\n default:\n invariant(\n false,\n \"Derived property aggregations for Timeseries and Media are not supported\",\n );\n }\n }\n return rawValue;\n}\n\nfunction createSpecialProperty(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n rawObject: ObjectHolder,\n p: keyof typeof rawObject & string | symbol,\n) {\n const rawValue = rawObject[p as any];\n const propDef = objectDef.properties[p as any];\n if (process.env.NODE_ENV !== \"production\") {\n invariant(\n propDef != null && typeof propDef.type === \"string\"\n && specialPropertyTypes.has(propDef.type),\n );\n }\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a => hydrateAttachmentFromRidInternal(client, a.rid));\n }\n return hydrateAttachmentFromRidInternal(\n client,\n (rawValue as Attachment).rid,\n );\n }\n\n if (\n propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\"\n || propDef.type === \"sensorTimeseries\"\n ) {\n return new TimeSeriesPropertyImpl<\n (typeof propDef)[\"type\"] extends \"numericTimeseries\" ? number\n : (typeof propDef)[\"type\"] extends \"stringTimeseries\" ? string\n : number | string\n >(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n );\n }\n\n if (propDef.type === \"geotimeSeriesReference\") {\n return new GeotimeSeriesPropertyImpl<GeoJSON.Point>(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n (rawValue as ReferenceValue).type === \"geotimeSeriesValue\"\n ? {\n time: (rawValue as ReferenceValue).timestamp,\n value: {\n type: \"Point\",\n coordinates: (rawValue as ReferenceValue).position,\n },\n }\n : undefined,\n );\n }\n if (propDef.type === \"mediaReference\") {\n return new MediaReferencePropertyImpl({\n client,\n objectApiName: objectDef.apiName,\n primaryKey: rawObject[objectDef.primaryKeyApiName as string],\n propertyName: p as string,\n });\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,yBAAyB,QAAQ,sCAAsC;AAChF,SAASC,0BAA0B,QAAQ,uCAAuC;AAClF,SAASC,sBAAsB,QAAQ,mCAAmC;AAI1E,SAASC,gCAAgC,QAAQ,gDAAgD;AACjG,SAASC,mCAAmC,QAAQ,oCAAoC;AAExF,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SACEC,SAAS,EACTC,YAAY,EACZC,oBAAoB,QACf,sBAAsB;AAG7B,MAAMC,oBAAoB,GAAG,IAAIC,GAAG,CAClC,CACE,YAAY,EACZ,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,CAEtB,CAAC;;AAED;AACA;AACA,MAAMC,YAAY,GAAG;EACnB,KAAK,EAAE;IACLC,GAAG,EAAE,SAAAA,CAAA,EAA6B;MAChC,OAAOR,MAAM,CAAC,IAAI,CAACG,YAAY,CAAC,CAAC;IACnC;EACF,CAAC;EACD,OAAO,EAAE;IACPK,GAAG,EAAE,SAAAA,CAAA,EAA6B;MAChC,OAAOP,QAAQ,CAAC,IAAI,CAAC;IACvB;EACF,CAAC;EACD,QAAQ,EAAE;IACRQ,KAAK,EAAE,SAAAA,CAELC,MAAuC,EACvC;MACA;MACA,MAAMC,MAAM,GAAG,IAAI,CAACP,oBAAoB,CAAyB;MACjE,MAAMQ,GAAG,GAAG,IAAI,CAACT,YAAY,CAAC;MAE9B,IAAIO,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B,MAAM;MACNqC,aAAa,EAAEpC,SAAS,CAACP,OAAO;MAChC4C,UAAU,EAAET,SAAS,CAAC5B,SAAS,CAACT,iBAAiB,CAAW;MAC5D+C,YAAY,EAAET;IAChB,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
1
+ {"version":3,"file":"createOsdkObject.js","names":["invariant","GeotimeSeriesPropertyImpl","MediaReferencePropertyImpl","TimeSeriesPropertyImpl","hydrateAttachmentFromRidInternal","createObjectSpecifierFromPrimaryKey","get$as","get$link","ClientRef","ObjectDefRef","UnderlyingOsdkObject","specialPropertyTypes","Set","basePropDefs","get","value","update","rawObj","def","createOsdkObject","primaryKeyApiName","Error","apiName","titleProperty","$title","newObject","$primaryKey","enumerable","client","objectDef","simpleOsdkProperties","derivedPropertyTypeByName","Object","defineProperties","propKey","keys","properties","type","has","createSpecialProperty","modifyRdpProperties","freeze","rawValue","definition","operation","num","Number","isSafeInteger","process","env","NODE_ENV","selectedOrCollectedPropertyType","Array","isArray","map","a","rid","rawObject","p","propDef","time","timestamp","coordinates","position","undefined","objectApiName","primaryKey","propertyName","mediaReference"],"sources":["createOsdkObject.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 { MediaReference } from \"@osdk/foundry.core\";\nimport type { Attachment, ReferenceValue } from \"@osdk/foundry.ontologies\";\nimport invariant from \"tiny-invariant\";\nimport { GeotimeSeriesPropertyImpl } from \"../../createGeotimeSeriesProperty.js\";\nimport { MediaReferencePropertyImpl } from \"../../createMediaReferenceProperty.js\";\nimport { TimeSeriesPropertyImpl } from \"../../createTimeseriesProperty.js\";\nimport type { DerivedPropertyRuntimeMetadata } from \"../../derivedProperties/derivedPropertyRuntimeMetadata.js\";\nimport type { MinimalClient } from \"../../MinimalClientContext.js\";\nimport type { FetchedObjectTypeDefinition } from \"../../ontology/OntologyProvider.js\";\nimport { hydrateAttachmentFromRidInternal } from \"../../public-utils/hydrateAttachmentFromRid.js\";\nimport { createObjectSpecifierFromPrimaryKey } from \"../../util/objectSpecifierUtils.js\";\nimport type { SimpleOsdkProperties } from \"../SimpleOsdkProperties.js\";\nimport { get$as } from \"./getDollarAs.js\";\nimport { get$link } from \"./getDollarLink.js\";\nimport {\n ClientRef,\n ObjectDefRef,\n UnderlyingOsdkObject,\n} from \"./InternalSymbols.js\";\nimport type { ObjectHolder } from \"./ObjectHolder.js\";\n\nconst specialPropertyTypes = new Set(\n [\n \"attachment\",\n \"geotimeSeriesReference\",\n \"mediaReference\",\n \"numericTimeseries\",\n \"stringTimeseries\",\n \"sensorTimeseries\",\n ],\n);\n\n// kept separate so we are not redefining these functions\n// every time an object is created.\nconst basePropDefs = {\n \"$as\": {\n get: function(this: ObjectHolder) {\n return get$as(this[ObjectDefRef]);\n },\n },\n \"$link\": {\n get: function(this: ObjectHolder) {\n return get$link(this);\n },\n },\n \"$clone\": {\n value: function(\n this: ObjectHolder,\n update: Record<string, any> | undefined,\n ) {\n // I think `rawObj` is the same thing as `this` and can be removed?\n const rawObj = this[UnderlyingOsdkObject] as SimpleOsdkProperties;\n const def = this[ObjectDefRef];\n\n if (update == null) {\n return createOsdkObject(this[ClientRef], def, { ...rawObj });\n }\n\n if (\n def.primaryKeyApiName in update\n && rawObj[def.primaryKeyApiName] !== update[def.primaryKeyApiName]\n ) {\n throw new Error(\n `Cannot update ${def.apiName} object with differing primary key values `,\n );\n }\n\n if (def.titleProperty in update && !(\"$title\" in update)) {\n update.$title = update[def.titleProperty];\n }\n\n const newObject = { ...this[UnderlyingOsdkObject], ...update };\n return createOsdkObject(this[ClientRef], this[ObjectDefRef], newObject);\n },\n },\n \"$objectSpecifier\": {\n get: function(this: ObjectHolder) {\n const rawObj = this[UnderlyingOsdkObject];\n return createObjectSpecifierFromPrimaryKey(\n this[ObjectDefRef],\n rawObj.$primaryKey,\n );\n },\n enumerable: true,\n },\n};\n\n/**\n * @internal\n * @param client\n * @param objectDef\n * @param simpleOsdkProperties\n */\nexport function createOsdkObject(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n simpleOsdkProperties: SimpleOsdkProperties,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata = {},\n): ObjectHolder {\n // updates the object's \"hidden class/map\".\n const rawObj = simpleOsdkProperties as ObjectHolder;\n Object.defineProperties(\n rawObj,\n {\n [UnderlyingOsdkObject]: {\n enumerable: false,\n value: simpleOsdkProperties,\n },\n [ObjectDefRef]: { value: objectDef, enumerable: false },\n [ClientRef]: { value: client, enumerable: false },\n ...basePropDefs,\n } satisfies Record<keyof ObjectHolder, PropertyDescriptor>,\n );\n\n // Assign the special values\n for (const propKey of Object.keys(rawObj)) {\n if (\n propKey in objectDef.properties\n && typeof (objectDef.properties[propKey].type) === \"string\"\n && specialPropertyTypes.has(objectDef.properties[propKey].type)\n ) {\n rawObj[propKey] = createSpecialProperty(\n client,\n objectDef,\n rawObj,\n propKey,\n );\n } else if (propKey in derivedPropertyTypeByName) {\n rawObj[propKey] = modifyRdpProperties(\n client,\n derivedPropertyTypeByName,\n rawObj[propKey],\n propKey,\n );\n }\n }\n\n return Object.freeze(rawObj);\n}\n\nfunction modifyRdpProperties(\n client: MinimalClient,\n derivedPropertyTypeByName: DerivedPropertyRuntimeMetadata,\n rawValue: any,\n propKey: string,\n): any {\n if (\n derivedPropertyTypeByName[propKey].definition.type === \"selection\"\n && derivedPropertyTypeByName[propKey].definition.operation.type\n === \"count\"\n ) {\n const num = Number(rawValue);\n invariant(\n Number.isSafeInteger(num),\n \"Count aggregation for derived property \" + propKey\n + \" returned a value larger than safe integer.\",\n );\n return num;\n } // Selected or collected properties need to be deserialized specially when constructed with RDP\n else if (\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n != null\n && typeof (derivedPropertyTypeByName[propKey]\n .selectedOrCollectedPropertyType.type)\n === \"string\"\n && specialPropertyTypes.has(\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n .type,\n )\n ) {\n switch (\n derivedPropertyTypeByName[propKey].selectedOrCollectedPropertyType\n ?.type\n ) {\n case \"attachment\":\n if (Array.isArray(rawValue)) {\n return rawValue.map(a =>\n hydrateAttachmentFromRidInternal(client, a.rid)\n );\n } else {\n return hydrateAttachmentFromRidInternal(\n client,\n (rawValue as Attachment).rid,\n );\n }\n break;\n default:\n invariant(\n false,\n \"Derived property aggregations for Timeseries and Media are not supported\",\n );\n }\n }\n return rawValue;\n}\n\nfunction createSpecialProperty(\n client: MinimalClient,\n objectDef: FetchedObjectTypeDefinition,\n rawObject: ObjectHolder,\n p: keyof typeof rawObject & string | symbol,\n) {\n const rawValue = rawObject[p as any];\n const propDef = objectDef.properties[p as any];\n if (process.env.NODE_ENV !== \"production\") {\n invariant(\n propDef != null && typeof propDef.type === \"string\"\n && specialPropertyTypes.has(propDef.type),\n );\n }\n if (propDef.type === \"attachment\") {\n if (Array.isArray(rawValue)) {\n return rawValue.map(a => hydrateAttachmentFromRidInternal(client, a.rid));\n }\n return hydrateAttachmentFromRidInternal(\n client,\n (rawValue as Attachment).rid,\n );\n }\n\n if (\n propDef.type === \"numericTimeseries\"\n || propDef.type === \"stringTimeseries\"\n || propDef.type === \"sensorTimeseries\"\n ) {\n return new TimeSeriesPropertyImpl<\n (typeof propDef)[\"type\"] extends \"numericTimeseries\" ? number\n : (typeof propDef)[\"type\"] extends \"stringTimeseries\" ? string\n : number | string\n >(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n );\n }\n\n if (propDef.type === \"geotimeSeriesReference\") {\n return new GeotimeSeriesPropertyImpl<GeoJSON.Point>(\n client,\n objectDef.apiName,\n rawObject[objectDef.primaryKeyApiName as string],\n p as string,\n (rawValue as ReferenceValue).type === \"geotimeSeriesValue\"\n ? {\n time: (rawValue as ReferenceValue).timestamp,\n value: {\n type: \"Point\",\n coordinates: (rawValue as ReferenceValue).position,\n },\n }\n : undefined,\n );\n }\n if (propDef.type === \"mediaReference\") {\n return new MediaReferencePropertyImpl({\n client,\n objectApiName: objectDef.apiName,\n primaryKey: rawObject[objectDef.primaryKeyApiName as string],\n propertyName: p as string,\n mediaReference: rawValue as MediaReference,\n });\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,yBAAyB,QAAQ,sCAAsC;AAChF,SAASC,0BAA0B,QAAQ,uCAAuC;AAClF,SAASC,sBAAsB,QAAQ,mCAAmC;AAI1E,SAASC,gCAAgC,QAAQ,gDAAgD;AACjG,SAASC,mCAAmC,QAAQ,oCAAoC;AAExF,SAASC,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SACEC,SAAS,EACTC,YAAY,EACZC,oBAAoB,QACf,sBAAsB;AAG7B,MAAMC,oBAAoB,GAAG,IAAIC,GAAG,CAClC,CACE,YAAY,EACZ,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,CAEtB,CAAC;;AAED;AACA;AACA,MAAMC,YAAY,GAAG;EACnB,KAAK,EAAE;IACLC,GAAG,EAAE,SAAAA,CAAA,EAA6B;MAChC,OAAOR,MAAM,CAAC,IAAI,CAACG,YAAY,CAAC,CAAC;IACnC;EACF,CAAC;EACD,OAAO,EAAE;IACPK,GAAG,EAAE,SAAAA,CAAA,EAA6B;MAChC,OAAOP,QAAQ,CAAC,IAAI,CAAC;IACvB;EACF,CAAC;EACD,QAAQ,EAAE;IACRQ,KAAK,EAAE,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QAAQ,CAAoBqB;MAC5C;IACF,CAAC,GACCC,SACN,CAAC;EACH;EACA,IAAIL,OAAO,CAACtB,IAAI,KAAK,gBAAgB,EAAE;IACrC,OAAO,IAAInC,0BAA0B,CAAC;MACpC0B,MAAM;MACNqC,aAAa,EAAEpC,SAAS,CAACP,OAAO;MAChC4C,UAAU,EAAET,SAAS,CAAC5B,SAAS,CAACT,iBAAiB,CAAW;MAC5D+C,YAAY,EAAET,CAAW;MACzBU,cAAc,EAAE1B;IAClB,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
@@ -27,7 +27,7 @@ describe("media", () => {
27
27
  } = testSetup);
28
28
  testSetup.fauxFoundry.getDataStore($ontologyRid).registerMedia(objectTypeWithAllPropertyTypes.apiName, "mediaReference", new TextEncoder().encode(JSON.stringify({
29
29
  content: "Hello World"
30
- })), "application/json", "file1.txt", stubData.objectWithAllPropertyTypes1.mediaReference);
30
+ })), "application/json", "file1.txt", stubData.objectWithAllPropertyTypes1.mediaReference.reference.mediaSetViewItem.mediaItemRid);
31
31
  return () => {
32
32
  testSetup.apiServer.close();
33
33
  };
@@ -56,5 +56,24 @@ describe("media", () => {
56
56
  content: "Hello World"
57
57
  });
58
58
  });
59
+ it("gets media reference successfully", async () => {
60
+ const result = await client(objectTypeWithAllPropertyTypes).where({
61
+ id: stubData.objectWithAllPropertyTypes1.id
62
+ }).fetchPage();
63
+ const object1 = result.data[0];
64
+ expect(object1.mediaReference).toBeDefined();
65
+ const mediaReference = object1.mediaReference?.getMediaReference();
66
+ expect(mediaReference).toEqual({
67
+ mimeType: "application/pdf",
68
+ reference: {
69
+ type: "mediaSetViewItem",
70
+ mediaSetViewItem: {
71
+ mediaSetRid: "ri.mio.main.media-set.4153d42f-ca4b-4e42-8ca5-8e6aa7edb642",
72
+ mediaSetViewRid: "ri.mio.main.view.82a798ad-d637-4595-acc6-987bcf16629b",
73
+ mediaItemRid: "ri.mio.main.media-item.001ec98b-1620-4814-9e17-8e9c4e536225"
74
+ }
75
+ }
76
+ });
77
+ });
59
78
  });
60
79
  //# sourceMappingURL=media.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"media.test.js","names":["$ontologyRid","objectTypeWithAllPropertyTypes","LegacyFauxFoundry","startNodeApiServer","stubData","beforeAll","describe","expect","it","createClient","client","testSetup","fauxFoundry","getDataStore","registerMedia","apiName","TextEncoder","encode","JSON","stringify","content","objectWithAllPropertyTypes1","mediaReference","apiServer","close","result","where","id","fetchPage","object1","data","toBeDefined","mediaMetadata","fetchMetadata","toEqual","path","mediaType","sizeBytes","mediaContent","fetchContents","json"],"sources":["media.test.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 {\n $ontologyRid,\n objectTypeWithAllPropertyTypes,\n} from \"@osdk/client.test.ontology\";\nimport {\n LegacyFauxFoundry,\n startNodeApiServer,\n stubData,\n} from \"@osdk/shared.test\";\nimport { beforeAll, describe, expect, it } from \"vitest\";\nimport type { Client } from \"../Client.js\";\nimport { createClient } from \"../createClient.js\";\n\ndescribe(\"media\", () => {\n let client: Client;\n\n beforeAll(() => {\n const testSetup = startNodeApiServer(\n new LegacyFauxFoundry(),\n createClient,\n );\n\n ({ client } = testSetup);\n\n testSetup.fauxFoundry\n .getDataStore($ontologyRid)\n .registerMedia(\n objectTypeWithAllPropertyTypes.apiName,\n \"mediaReference\",\n new TextEncoder().encode(\n JSON.stringify({ content: \"Hello World\" }),\n ),\n \"application/json\",\n \"file1.txt\",\n stubData.objectWithAllPropertyTypes1.mediaReference,\n );\n\n return () => {\n testSetup.apiServer.close();\n };\n });\n\n it(\"reads media metadata successfully\", async () => {\n const result = await client(\n objectTypeWithAllPropertyTypes,\n )\n .where({ id: stubData.objectWithAllPropertyTypes1.id }).fetchPage();\n\n const object1 = result.data[0];\n expect(object1.mediaReference).toBeDefined();\n const mediaMetadata = await object1.mediaReference?.fetchMetadata();\n expect(mediaMetadata).toEqual({\n path: \"file1.txt\",\n mediaType: \"application/json\",\n sizeBytes: 25,\n });\n });\n\n it(\"reads media content successfully\", async () => {\n const result = await client(objectTypeWithAllPropertyTypes)\n .where({ id: stubData.objectWithAllPropertyTypes1.id }).fetchPage();\n\n const object1 = result.data[0];\n expect(object1.mediaReference).toBeDefined();\n const mediaContent = await object1?.mediaReference?.fetchContents();\n expect(await mediaContent!.json()).toEqual({\n content: \"Hello World\",\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,YAAY,EACZC,8BAA8B,QACzB,4BAA4B;AACnC,SACEC,iBAAiB,EACjBC,kBAAkB,EAClBC,QAAQ,QACH,mBAAmB;AAC1B,SAASC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAExD,SAASC,YAAY,QAAQ,oBAAoB;AAEjDH,QAAQ,CAAC,OAAO,EAAE,MAAM;EACtB,IAAII,MAAc;EAElBL,SAAS,CAAC,MAAM;IACd,MAAMM,SAAS,GAAGR,kBAAkB,CAClC,IAAID,iBAAiB,CAAC,CAAC,EACvBO,YACF,CAAC;IAED,CAAC;MAAEC;IAAO,CAAC,GAAGC,SAAS;IAEvBA,SAAS,CAACC,WAAW,CAClBC,YAAY,CAACb,YAAY,CAAC,CAC1Bc,aAAa,CACZb,8BAA8B,CAACc,OAAO,EACtC,gBAAgB,EAChB,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CACtBC,IAAI,CAACC,SAAS,CAAC;MAAEC,OAAO,EAAE;IAAc,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AAY,CAAEE,IAAI,CAAC,CAAC,CAAC,CAACN,OAAO,CAAC;MACzCd,OAAO,EAAE;IACX,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"media.test.js","names":["$ontologyRid","objectTypeWithAllPropertyTypes","LegacyFauxFoundry","startNodeApiServer","stubData","beforeAll","describe","expect","it","createClient","client","testSetup","fauxFoundry","getDataStore","registerMedia","apiName","TextEncoder","encode","JSON","stringify","content","objectWithAllPropertyTypes1","mediaReference","reference","mediaSetViewItem","mediaItemRid","apiServer","close","result","where","id","fetchPage","object1","data","toBeDefined","mediaMetadata","fetchMetadata","toEqual","path","mediaType","sizeBytes","mediaContent","fetchContents","json","getMediaReference","mimeType","type","mediaSetRid","mediaSetViewRid"],"sources":["media.test.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 {\n $ontologyRid,\n objectTypeWithAllPropertyTypes,\n} from \"@osdk/client.test.ontology\";\nimport {\n LegacyFauxFoundry,\n startNodeApiServer,\n stubData,\n} from \"@osdk/shared.test\";\nimport { beforeAll, describe, expect, it } from \"vitest\";\nimport type { Client } from \"../Client.js\";\nimport { createClient } from \"../createClient.js\";\n\ndescribe(\"media\", () => {\n let client: Client;\n\n beforeAll(() => {\n const testSetup = startNodeApiServer(\n new LegacyFauxFoundry(),\n createClient,\n );\n\n ({ client } = testSetup);\n\n testSetup.fauxFoundry\n .getDataStore($ontologyRid)\n .registerMedia(\n objectTypeWithAllPropertyTypes.apiName,\n \"mediaReference\",\n new TextEncoder().encode(\n JSON.stringify({ content: \"Hello World\" }),\n ),\n \"application/json\",\n \"file1.txt\",\n stubData.objectWithAllPropertyTypes1.mediaReference.reference\n .mediaSetViewItem.mediaItemRid,\n );\n\n return () => {\n testSetup.apiServer.close();\n };\n });\n\n it(\"reads media metadata successfully\", async () => {\n const result = await client(\n objectTypeWithAllPropertyTypes,\n )\n .where({ id: stubData.objectWithAllPropertyTypes1.id }).fetchPage();\n\n const object1 = result.data[0];\n expect(object1.mediaReference).toBeDefined();\n const mediaMetadata = await object1.mediaReference?.fetchMetadata();\n expect(mediaMetadata).toEqual({\n path: \"file1.txt\",\n mediaType: \"application/json\",\n sizeBytes: 25,\n });\n });\n\n it(\"reads media content successfully\", async () => {\n const result = await client(objectTypeWithAllPropertyTypes)\n .where({ id: stubData.objectWithAllPropertyTypes1.id }).fetchPage();\n\n const object1 = result.data[0];\n expect(object1.mediaReference).toBeDefined();\n const mediaContent = await object1?.mediaReference?.fetchContents();\n expect(await mediaContent!.json()).toEqual({\n content: \"Hello World\",\n });\n });\n\n it(\"gets media reference successfully\", async () => {\n const result = await client(objectTypeWithAllPropertyTypes)\n .where({ id: stubData.objectWithAllPropertyTypes1.id }).fetchPage();\n\n const object1 = result.data[0];\n expect(object1.mediaReference).toBeDefined();\n const mediaReference = object1.mediaReference?.getMediaReference();\n expect(mediaReference).toEqual({\n mimeType: \"application/pdf\",\n reference: {\n type: \"mediaSetViewItem\",\n mediaSetViewItem: {\n mediaSetRid:\n \"ri.mio.main.media-set.4153d42f-ca4b-4e42-8ca5-8e6aa7edb642\",\n mediaSetViewRid:\n \"ri.mio.main.view.82a798ad-d637-4595-acc6-987bcf16629b\",\n mediaItemRid:\n \"ri.mio.main.media-item.001ec98b-1620-4814-9e17-8e9c4e536225\",\n },\n },\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,YAAY,EACZ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,CAACe,OAAO,CAAC;MAC7BQ,QAAQ,EAAE,iBAAiB;MAC3BtB,SAAS,EAAE;QACTuB,IAAI,EAAE,kBAAkB;QACxBtB,gBAAgB,EAAE;UAChBuB,WAAW,EACT,4DAA4D;UAC9DC,eAAe,EACb,uDAAuD;UACzDvB,YAAY,EACV;QACJ;MACF;IACF,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -14,5 +14,5 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export const USER_AGENT = `osdk-client/${"2.2.0"}`;
17
+ export const USER_AGENT = `osdk-client/${"2.2.1"}`;
18
18
  //# sourceMappingURL=UserAgent.js.map
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkHDAQ6JIR_cjs = require('./chunk-HDAQ6JIR.cjs');
3
+ var chunkUCW7RLKM_cjs = require('./chunk-UCW7RLKM.cjs');
4
4
  var shared_net_errors = require('@osdk/shared.net.errors');
5
5
  var invariant5 = require('tiny-invariant');
6
6
  var api = require('@osdk/api');
@@ -13,16 +13,16 @@ var WebSocket__default = /*#__PURE__*/_interopDefault(WebSocket);
13
13
 
14
14
  // src/public-utils/hydrateAttachmentFromRid.ts
15
15
  function hydrateAttachmentFromRid(client, rid) {
16
- return hydrateAttachmentFromRidInternal(client[chunkHDAQ6JIR_cjs.additionalContext], rid);
16
+ return hydrateAttachmentFromRidInternal(client[chunkUCW7RLKM_cjs.additionalContext], rid);
17
17
  }
18
18
  function hydrateAttachmentFromRidInternal(client, rid) {
19
19
  return {
20
20
  rid,
21
21
  async fetchContents() {
22
- return chunkHDAQ6JIR_cjs.Attachment_exports.read(client, rid);
22
+ return chunkUCW7RLKM_cjs.Attachment_exports.read(client, rid);
23
23
  },
24
24
  async fetchMetadata() {
25
- const r = await chunkHDAQ6JIR_cjs.Attachment_exports.get(client, rid);
25
+ const r = await chunkUCW7RLKM_cjs.Attachment_exports.get(client, rid);
26
26
  return {
27
27
  ...r,
28
28
  sizeBytes: Number(r.sizeBytes)
@@ -98,7 +98,7 @@ var MinimalLogger = class _MinimalLogger extends BaseLogger {
98
98
  }
99
99
  };
100
100
  async function fetchSingle(client, objectType, args, objectSet) {
101
- const result = await chunkHDAQ6JIR_cjs.fetchPage(client, objectType, {
101
+ const result = await chunkUCW7RLKM_cjs.fetchPage(client, objectType, {
102
102
  ...args,
103
103
  $pageSize: 1
104
104
  }, objectSet);
@@ -468,15 +468,15 @@ function convertRange(range) {
468
468
  }
469
469
 
470
470
  // src/object/aggregate.ts
471
- async function aggregate(clientCtx, objectType, objectSet = chunkHDAQ6JIR_cjs.resolveBaseObjectSetType(objectType), req) {
472
- chunkHDAQ6JIR_cjs.resolveBaseObjectSetType(objectType);
471
+ async function aggregate(clientCtx, objectType, objectSet = chunkUCW7RLKM_cjs.resolveBaseObjectSetType(objectType), req) {
472
+ chunkUCW7RLKM_cjs.resolveBaseObjectSetType(objectType);
473
473
  const body = {
474
474
  aggregation: modernToLegacyAggregationClause(req.$select),
475
475
  groupBy: []};
476
476
  if (req.$groupBy) {
477
477
  body.groupBy = modernToLegacyGroupByClause(req.$groupBy);
478
478
  }
479
- const result = await chunkHDAQ6JIR_cjs.OntologyObjectSet_exports.aggregate(chunkHDAQ6JIR_cjs.addUserAgentAndRequestContextHeaders(clientCtx, objectType), await clientCtx.ontologyRid, {
479
+ const result = await chunkUCW7RLKM_cjs.OntologyObjectSet_exports.aggregate(chunkUCW7RLKM_cjs.addUserAgentAndRequestContextHeaders(clientCtx, objectType), await clientCtx.ontologyRid, {
480
480
  objectSet,
481
481
  groupBy: body.groupBy,
482
482
  aggregation: body.aggregation
@@ -955,15 +955,15 @@ function getWireObjectSet(objectSet) {
955
955
  return objectSetDefinitions.get(objectSet);
956
956
  }
957
957
  var objectSetDefinitions = /* @__PURE__ */ new WeakMap();
958
- function createObjectSet(objectType, clientCtx, objectSet = chunkHDAQ6JIR_cjs.resolveBaseObjectSetType(objectType)) {
958
+ function createObjectSet(objectType, clientCtx, objectSet = chunkUCW7RLKM_cjs.resolveBaseObjectSetType(objectType)) {
959
959
  const base = {
960
960
  aggregate: aggregate.bind(globalThis, augmentRequestContext(clientCtx, (_) => ({
961
961
  finalMethodCall: "aggregate"
962
962
  })), objectType, objectSet),
963
- fetchPage: chunkHDAQ6JIR_cjs.fetchPageInternal.bind(globalThis, augmentRequestContext(clientCtx, (_) => ({
963
+ fetchPage: chunkUCW7RLKM_cjs.fetchPageInternal.bind(globalThis, augmentRequestContext(clientCtx, (_) => ({
964
964
  finalMethodCall: "fetchPage"
965
965
  })), objectType, objectSet),
966
- fetchPageWithErrors: chunkHDAQ6JIR_cjs.fetchPageWithErrorsInternal.bind(globalThis, augmentRequestContext(clientCtx, (_) => ({
966
+ fetchPageWithErrors: chunkUCW7RLKM_cjs.fetchPageWithErrorsInternal.bind(globalThis, augmentRequestContext(clientCtx, (_) => ({
967
967
  finalMethodCall: "fetchPageWithErrors"
968
968
  })), objectType, objectSet),
969
969
  where: (clause) => {
@@ -997,7 +997,7 @@ function createObjectSet(objectType, clientCtx, objectSet = chunkHDAQ6JIR_cjs.re
997
997
  asyncIter: async function* (args) {
998
998
  let $nextPageToken = void 0;
999
999
  do {
1000
- const result = await chunkHDAQ6JIR_cjs.fetchPageInternal(augmentRequestContext(clientCtx, (_) => ({
1000
+ const result = await chunkUCW7RLKM_cjs.fetchPageInternal(augmentRequestContext(clientCtx, (_) => ({
1001
1001
  finalMethodCall: "asyncIter"
1002
1002
  })), objectType, objectSet, {
1003
1003
  ...args,
@@ -1083,5 +1083,5 @@ exports.hydrateAttachmentFromRid = hydrateAttachmentFromRid;
1083
1083
  exports.hydrateAttachmentFromRidInternal = hydrateAttachmentFromRidInternal;
1084
1084
  exports.isObjectSet = isObjectSet;
1085
1085
  exports.isWireObjectSet = isWireObjectSet;
1086
- //# sourceMappingURL=chunk-5JZGGCIW.cjs.map
1087
- //# sourceMappingURL=chunk-5JZGGCIW.cjs.map
1086
+ //# sourceMappingURL=chunk-LPYAXRWJ.cjs.map
1087
+ //# sourceMappingURL=chunk-LPYAXRWJ.cjs.map