@osdk/client 2.23.0 → 2.23.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/build/browser/Client.js +1 -1
  3. package/build/browser/Client.js.map +1 -1
  4. package/build/browser/MinimalClientContext.js.map +1 -1
  5. package/build/browser/actions/applyAction.js +3 -1
  6. package/build/browser/actions/applyAction.js.map +1 -1
  7. package/build/browser/createClient.js +7 -3
  8. package/build/browser/createClient.js.map +1 -1
  9. package/build/browser/createMinimalClient.js +10 -0
  10. package/build/browser/createMinimalClient.js.map +1 -1
  11. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +3 -0
  12. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  13. package/build/browser/internal/conversions/modernToLegacyWhereClause.js +30 -10
  14. package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  15. package/build/browser/object/aggregate.js +2 -1
  16. package/build/browser/object/aggregate.js.map +1 -1
  17. package/build/browser/object/fetchPage.js +6 -3
  18. package/build/browser/object/fetchPage.js.map +1 -1
  19. package/build/browser/objectSet/createObjectSet.js +3 -0
  20. package/build/browser/objectSet/createObjectSet.js.map +1 -1
  21. package/build/browser/public/unstable-do-not-use.js +2 -0
  22. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  23. package/build/browser/queries/applyQuery.js +1 -0
  24. package/build/browser/queries/applyQuery.js.map +1 -1
  25. package/build/browser/scenarios/ScenarioClient.js +202 -0
  26. package/build/browser/scenarios/ScenarioClient.js.map +1 -0
  27. package/build/browser/scenarios/createScenario.js +55 -0
  28. package/build/browser/scenarios/createScenario.js.map +1 -0
  29. package/build/browser/scenarios/withScenario.js +42 -0
  30. package/build/browser/scenarios/withScenario.js.map +1 -0
  31. package/build/browser/util/UserAgent.js +2 -2
  32. package/build/browser/util/UserAgent.js.map +1 -1
  33. package/build/browser/util/toDataValue.js +4 -0
  34. package/build/browser/util/toDataValue.js.map +1 -1
  35. package/build/cjs/MediaReferenceProperty-CBPMMD73.cjs +22 -0
  36. package/build/cjs/{MediaReferenceProperty-Y6R5ASNW.cjs.map → MediaReferenceProperty-CBPMMD73.cjs.map} +1 -1
  37. package/build/cjs/{applyStreamingQuery-F77N7EOP.cjs → applyStreamingQuery-G2PA2SM7.cjs} +11 -11
  38. package/build/cjs/{applyStreamingQuery-F77N7EOP.cjs.map → applyStreamingQuery-G2PA2SM7.cjs.map} +1 -1
  39. package/build/cjs/{chunk-KILPUOJP.cjs → chunk-BV6P25ZM.cjs} +51 -21
  40. package/build/cjs/chunk-BV6P25ZM.cjs.map +1 -0
  41. package/build/cjs/{chunk-3DMI6Z4B.cjs → chunk-IWAZIBOK.cjs} +75 -75
  42. package/build/cjs/{chunk-3DMI6Z4B.cjs.map → chunk-IWAZIBOK.cjs.map} +1 -1
  43. package/build/cjs/{chunk-MURBAIS4.cjs → chunk-NFD4IH4H.cjs} +17 -16
  44. package/build/cjs/chunk-NFD4IH4H.cjs.map +1 -0
  45. package/build/cjs/{chunk-5WD6SB7R.cjs → chunk-WBINM4RT.cjs} +297 -100
  46. package/build/cjs/chunk-WBINM4RT.cjs.map +1 -0
  47. package/build/cjs/{chunk-DOXHU27E.cjs → chunk-YP43NHIA.cjs} +3 -3
  48. package/build/cjs/{chunk-DOXHU27E.cjs.map → chunk-YP43NHIA.cjs.map} +1 -1
  49. package/build/cjs/{chunk-ZPLXXOU6.cjs → chunk-ZFNHWPQA.cjs} +3 -3
  50. package/build/cjs/{chunk-ZPLXXOU6.cjs.map → chunk-ZFNHWPQA.cjs.map} +1 -1
  51. package/build/cjs/index.cjs +13 -13
  52. package/build/cjs/public/experimental.cjs +8 -8
  53. package/build/cjs/public/internal.cjs +8 -8
  54. package/build/cjs/public/observable.cjs +7 -7
  55. package/build/cjs/public/unstable-do-not-use.cjs +37 -12
  56. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  57. package/build/cjs/public/unstable-do-not-use.d.cts +167 -4
  58. package/build/cjs/{transformAndWaitInternal-F3UV33FN.cjs → transformAndWaitInternal-2GORZXPK.cjs} +6 -6
  59. package/build/cjs/{transformAndWaitInternal-F3UV33FN.cjs.map → transformAndWaitInternal-2GORZXPK.cjs.map} +1 -1
  60. package/build/esm/Client.js +1 -1
  61. package/build/esm/Client.js.map +1 -1
  62. package/build/esm/MinimalClientContext.js.map +1 -1
  63. package/build/esm/actions/applyAction.js +3 -1
  64. package/build/esm/actions/applyAction.js.map +1 -1
  65. package/build/esm/createClient.js +7 -3
  66. package/build/esm/createClient.js.map +1 -1
  67. package/build/esm/createMinimalClient.js +10 -0
  68. package/build/esm/createMinimalClient.js.map +1 -1
  69. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +3 -0
  70. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  71. package/build/esm/internal/conversions/modernToLegacyWhereClause.js +30 -10
  72. package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  73. package/build/esm/object/aggregate.js +2 -1
  74. package/build/esm/object/aggregate.js.map +1 -1
  75. package/build/esm/object/fetchPage.js +6 -3
  76. package/build/esm/object/fetchPage.js.map +1 -1
  77. package/build/esm/objectSet/createObjectSet.js +3 -0
  78. package/build/esm/objectSet/createObjectSet.js.map +1 -1
  79. package/build/esm/public/unstable-do-not-use.js +2 -0
  80. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  81. package/build/esm/queries/applyQuery.js +1 -0
  82. package/build/esm/queries/applyQuery.js.map +1 -1
  83. package/build/esm/scenarios/ScenarioClient.js +202 -0
  84. package/build/esm/scenarios/ScenarioClient.js.map +1 -0
  85. package/build/esm/scenarios/createScenario.js +55 -0
  86. package/build/esm/scenarios/createScenario.js.map +1 -0
  87. package/build/esm/scenarios/withScenario.js +42 -0
  88. package/build/esm/scenarios/withScenario.js.map +1 -0
  89. package/build/esm/util/UserAgent.js +2 -2
  90. package/build/esm/util/UserAgent.js.map +1 -1
  91. package/build/esm/util/toDataValue.js +4 -0
  92. package/build/esm/util/toDataValue.js.map +1 -1
  93. package/build/types/Client.d.ts +1 -1
  94. package/build/types/MinimalClientContext.d.ts +1 -0
  95. package/build/types/MinimalClientContext.d.ts.map +1 -1
  96. package/build/types/actions/applyAction.d.ts.map +1 -1
  97. package/build/types/createClient.d.ts.map +1 -1
  98. package/build/types/public/unstable-do-not-use.d.ts +3 -0
  99. package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
  100. package/build/types/queries/applyQuery.d.ts.map +1 -1
  101. package/build/types/scenarios/ScenarioClient.d.ts +131 -0
  102. package/build/types/scenarios/ScenarioClient.d.ts.map +1 -0
  103. package/build/types/scenarios/createScenario.d.ts +21 -0
  104. package/build/types/scenarios/createScenario.d.ts.map +1 -0
  105. package/build/types/scenarios/withScenario.d.ts +23 -0
  106. package/build/types/scenarios/withScenario.d.ts.map +1 -0
  107. package/package.json +14 -14
  108. package/build/cjs/MediaReferenceProperty-Y6R5ASNW.cjs +0 -22
  109. package/build/cjs/chunk-5WD6SB7R.cjs.map +0 -1
  110. package/build/cjs/chunk-KILPUOJP.cjs.map +0 -1
  111. package/build/cjs/chunk-MURBAIS4.cjs.map +0 -1
@@ -1,10 +1,10 @@
1
- import { ObjectOrInterfaceDefinition, PropertyKeys, Augment, Osdk, ObjectSet, WhereClause } from '@osdk/api';
1
+ import { ObjectOrInterfaceDefinition, PropertyKeys, Augment, ObjectTypeDefinition, ObjectIdentifiers, LinkTypeApiNamesFor, MinimalDirectedObjectLinkInstance, Osdk, ObjectSet, WhereClause } from '@osdk/api';
2
2
  export { g as getWireObjectSet, i as isObjectSet } from '../createObjectSet-CC24Xe3h.cjs';
3
3
  export { c as createClientWithTransaction } from '../createClient-DpbwnBdH.cjs';
4
- import { ShapeDefinition, ShapeBaseType, ShapeInstance, NullabilityViolation } from '@osdk/api/unstable';
5
- import { ShapeLinkObjectSetDef } from '@osdk/api/shapes-internal';
6
4
  import { C as Client } from '../Client-ByJ7d2BQ.cjs';
7
5
  export { A as ActionSignatureFromDef, Q as QueryParameterType, a as QueryReturnType } from '../Client-ByJ7d2BQ.cjs';
6
+ import { ShapeDefinition, ShapeBaseType, ShapeInstance, NullabilityViolation } from '@osdk/api/unstable';
7
+ import { ShapeLinkObjectSetDef } from '@osdk/api/shapes-internal';
8
8
  export { CacheEntry, CacheSnapshot, CanonicalizeOptionsInput, CanonicalizedOptions, ObservableClient, ObserveAggregationArgs, ObserveFunctionCallbackArgs, ObserveFunctionOptions, ObserveLinks, ObserveObjectCallbackArgs, ObserveObjectSetArgs, ObserveObjectsCallbackArgs, Observer, Unsubscribable, createObservableClient } from './observable.cjs';
9
9
  import '@osdk/foundry.ontologies';
10
10
  import '@osdk/shared.client';
@@ -21,6 +21,169 @@ interface OsdkConfig {
21
21
  }
22
22
  declare function getOsdkConfig(ontologyRid: string): OsdkConfig;
23
23
 
24
+ /**
25
+ * The set of many-to-many link types modified within a scenario for one source object type. Returned as part of
26
+ * {@link ScenarioEditedEntityTypes.linkTypes}.
27
+ */
28
+ interface EditedLinksForObjectType {
29
+ objectTypeApiName: string;
30
+ linkTypes: string[];
31
+ }
32
+ /**
33
+ * The object types and link types that have been modified within a scenario. Only many-to-many link type edits are surfaced via `linkTypes`;
34
+ * one-to-many edits surface as object edits on the object type that owns the foreign key property.
35
+ */
36
+ interface ScenarioEditedEntityTypes {
37
+ objectTypes: string[];
38
+ linkTypes: EditedLinksForObjectType[];
39
+ }
40
+ /**
41
+ * A page of edited object identifiers within a scenario
42
+ * for a given object type. Returned by {@link ScenarioClient.getEditedEntities}. To load full property values,
43
+ * pass the primary keys back through the scenario client, e.g.
44
+ * `scenario(MyObject).where({ $primaryKey: { $in: keys } }).fetchPage()`.
45
+ */
46
+ interface EditedEntitiesPage<Q extends ObjectTypeDefinition> {
47
+ data: ObjectIdentifiers<Q>[];
48
+ nextPageToken?: string;
49
+ }
50
+ /**
51
+ * A page of directed link instances edited within a scenario for a given source object type and link api name.
52
+ * Returned by {@link ScenarioClient.getEditedLinks}. Source and target carry only `$primaryKey` + `$apiName`.
53
+ */
54
+ interface EditedLinksPage<Q extends ObjectOrInterfaceDefinition, LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>> {
55
+ data: MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[];
56
+ nextPageToken?: string;
57
+ }
58
+ /**
59
+ * A {@link Client} attached to an ontology scenario. All read and write operations performed via this client are
60
+ * scoped to that scenario. `ScenarioClient` is a superset of {@link Client}: it is usable anywhere a `Client` is
61
+ * accepted (e.g. as the `scenarioReference` parameter on a scenario-merge action).
62
+ *
63
+ * @beta This is an experimental, unstable feature subject to change.
64
+ */
65
+ interface ScenarioClient extends Client {
66
+ /**
67
+ * Returns the scenario reference for this client. Pass directly to an action whose parameter is typed as
68
+ * `scenarioReference`, or use to inspect the underlying scenario RID.
69
+ */
70
+ getScenarioReference(): {
71
+ scenarioRid: string;
72
+ };
73
+ /**
74
+ * List the object types and many-to-many link types that have been modified within this scenario. Useful as a
75
+ * pre-step before paginating individual edited objects per type.
76
+ */
77
+ getEditedEntityTypes(): Promise<ScenarioEditedEntityTypes>;
78
+ /**
79
+ * Get a page of object identifiers that have been
80
+ * edited within this scenario for the given object type. Use the scenario client to fetch full property values
81
+ * if needed.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * let pageToken: string | undefined;
86
+ * const keys: string[] = [];
87
+ * do {
88
+ * const page = await scenario.getEditedEntities(Doctor, { pageSize: 500, pageToken });
89
+ * keys.push(...page.data.map(o => o.$primaryKey));
90
+ * pageToken = page.nextPageToken;
91
+ * } while (pageToken);
92
+ * ```
93
+ */
94
+ getEditedEntities<Q extends ObjectTypeDefinition>(objectType: Q, options?: {
95
+ pageSize?: number;
96
+ pageToken?: string;
97
+ }): Promise<EditedEntitiesPage<Q>>;
98
+ /**
99
+ * Stream object identifiers for the objects edited within this scenario for the
100
+ * given object type. Pages are fetched lazily and deduplicated by `$primaryKey` across pages (Funnel may return
101
+ * duplicates).
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * for await (const obj of scenario.editedEntitiesAsyncIter(Doctor, { pageSize: 500 })) {
106
+ * // obj.$primaryKey is the unique key for this edited object
107
+ * }
108
+ * ```
109
+ */
110
+ editedEntitiesAsyncIter<Q extends ObjectTypeDefinition>(objectType: Q, options?: {
111
+ pageSize?: number;
112
+ }): AsyncIterableIterator<ObjectIdentifiers<Q>>;
113
+ /**
114
+ * List the outgoing many-to-many link API names that have been modified within this scenario for the given
115
+ * source object type. One-to-many link edits surface as object edits on the FK-owning side and are not returned
116
+ * here.
117
+ */
118
+ getEditedLinkTypes<Q extends ObjectOrInterfaceDefinition>(sourceObjectType: Q): Promise<LinkTypeApiNamesFor<Q>[]>;
119
+ /**
120
+ * Get a page of directed link instances edited within this scenario for a given source object type and link
121
+ * api name. The page form returns a flattened array of `{ source, target, linkType }` triples.
122
+ */
123
+ getEditedLinks<Q extends ObjectOrInterfaceDefinition, LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>>(sourceObjectType: Q, linkType: LINK_TYPE_API_NAME, options?: {
124
+ pageSize?: number;
125
+ pageToken?: string;
126
+ }): Promise<EditedLinksPage<Q, LINK_TYPE_API_NAME>>;
127
+ /**
128
+ * Stream directed link instances edited within this scenario for a given source object type and link api name.
129
+ * Pages are fetched lazily.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * for await (
134
+ * const { source, target, linkType } of scenario.editedLinksAsyncIter(Doctor, "treats")
135
+ * ) {
136
+ * graph.addEdge(source, target, linkType);
137
+ * }
138
+ * ```
139
+ */
140
+ editedLinksAsyncIter<Q extends ObjectOrInterfaceDefinition, LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>>(sourceObjectType: Q, linkType: LINK_TYPE_API_NAME, options?: {
141
+ pageSize?: number;
142
+ }): AsyncIterableIterator<MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>>;
143
+ }
144
+
145
+ /**
146
+ * Mint a fresh ontology scenario and return a client scoped to it.
147
+ *
148
+ * @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)
149
+ * from. Throws at runtime if the client is already scoped to a scenario or transaction. When the base client has a
150
+ * branch set, the newly minted scenario uses that branch as its base.
151
+ * @returns a {@link ScenarioClient} bound to the freshly minted scenario RID.
152
+ *
153
+ * @beta This is an experimental, unstable feature subject to change.
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * import { createScenario } from "@osdk/client/unstable-do-not-use";
158
+ *
159
+ * const scenario = await createScenario(client);
160
+ * const { scenarioRid } = scenario.getScenarioReference();
161
+ * ```
162
+ */
163
+ declare function createScenario(client: Client): Promise<ScenarioClient>;
164
+
165
+ /**
166
+ * Attach to an existing ontology scenario. Synchronous — no network call is made. The returned client scopes all
167
+ * subsequent operations (`fetchPage`, `applyAction`, `executeFunction`, etc.) to the given `scenarioRid`.
168
+ *
169
+ * @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)
170
+ * from. Throws at runtime if the client is already scoped to a scenario or transaction.
171
+ * @param scenarioRid - The RID of the scenario to attach to.
172
+ * @returns a {@link ScenarioClient} bound to `scenarioRid`.
173
+ *
174
+ * @beta This is an experimental, unstable feature subject to change.
175
+ *
176
+ * @example
177
+ * ```ts
178
+ * import { withScenario } from "@osdk/client/unstable-do-not-use";
179
+ *
180
+ * const scenario = withScenario(client, "ri.actions..scenario.abc");
181
+ * const page = await scenario(Doctor).fetchPage();
182
+ * await scenario(Schedule).applyAction({ doctor: page.data[0], shift: "AM" });
183
+ * ```
184
+ */
185
+ declare function withScenario(client: Client, scenarioRid: string): ScenarioClient;
186
+
24
187
  interface ShapeTransformResult<S extends ShapeDefinition<ObjectOrInterfaceDefinition>> {
25
188
  data: ShapeInstance<S> | undefined;
26
189
  dropped: boolean;
@@ -55,4 +218,4 @@ declare function getLinkQueryOptions(linkDef: ShapeLinkObjectSetDef, sourceObjec
55
218
  */
56
219
  declare function buildObjectSetFromLinkDefByType(client: Client, sourceType: ObjectOrInterfaceDefinition, sourcePrimaryKey: unknown, linkDef: ShapeLinkObjectSetDef): Promise<ObjectSet<ObjectOrInterfaceDefinition>>;
57
220
 
58
- export { type OsdkConfig, applyShapeTransformations, applyShapeTransformationsToArray, augment, buildObjectSetFromLinkDefByType, getLinkQueryOptions, getMetaTagContent, getOsdkConfig };
221
+ export { type OsdkConfig, type ScenarioClient, applyShapeTransformations, applyShapeTransformationsToArray, augment, buildObjectSetFromLinkDefByType, createScenario, getLinkQueryOptions, getMetaTagContent, getOsdkConfig, withScenario };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkZPLXXOU6_cjs = require('./chunk-ZPLXXOU6.cjs');
3
+ var chunkZFNHWPQA_cjs = require('./chunk-ZFNHWPQA.cjs');
4
4
  require('./chunk-D26YLHTV.cjs');
5
5
  require('./chunk-74HV6NQQ.cjs');
6
6
  var unstable = require('@osdk/api/unstable');
@@ -11,7 +11,7 @@ async function transformAndWaitInternal(client, mediaSetRid, mediaItemRid, trans
11
11
  const headerParams = token ? {
12
12
  Token: token
13
13
  } : void 0;
14
- const job = await chunkZPLXXOU6_cjs.MediaSet_exports.transform(client, mediaSetRid, mediaItemRid, {
14
+ const job = await chunkZFNHWPQA_cjs.MediaSet_exports.transform(client, mediaSetRid, mediaItemRid, {
15
15
  transformation
16
16
  }, {
17
17
  preview: true
@@ -23,7 +23,7 @@ async function transformAndWaitInternal(client, mediaSetRid, mediaItemRid, trans
23
23
  if (Date.now() >= deadline) {
24
24
  throw new unstable.MediaTransformationTimeoutError(jobId);
25
25
  }
26
- const statusResponse = await chunkZPLXXOU6_cjs.MediaSet_exports.getStatus(client, mediaSetRid, mediaItemRid, jobId, {
26
+ const statusResponse = await chunkZFNHWPQA_cjs.MediaSet_exports.getStatus(client, mediaSetRid, mediaItemRid, jobId, {
27
27
  preview: true
28
28
  }, headerParams);
29
29
  status = statusResponse.status;
@@ -34,11 +34,11 @@ async function transformAndWaitInternal(client, mediaSetRid, mediaItemRid, trans
34
34
  await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
35
35
  }
36
36
  }
37
- return chunkZPLXXOU6_cjs.MediaSet_exports.getResult(client, mediaSetRid, mediaItemRid, jobId, {
37
+ return chunkZFNHWPQA_cjs.MediaSet_exports.getResult(client, mediaSetRid, mediaItemRid, jobId, {
38
38
  preview: true
39
39
  }, headerParams);
40
40
  }
41
41
 
42
42
  exports.transformAndWaitInternal = transformAndWaitInternal;
43
- //# sourceMappingURL=transformAndWaitInternal-F3UV33FN.cjs.map
44
- //# sourceMappingURL=transformAndWaitInternal-F3UV33FN.cjs.map
43
+ //# sourceMappingURL=transformAndWaitInternal-2GORZXPK.cjs.map
44
+ //# sourceMappingURL=transformAndWaitInternal-2GORZXPK.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/util/transformAndWaitInternal.ts"],"names":["MediaSet_exports","MediaTransformationTimeoutError","MediaTransformationFailedError"],"mappings":";;;;;;;AAsBA,eAAsB,yBAAyB,MAAA,EAAQ,WAAA,EAAa,YAAA,EAAc,cAAA,EAAgB,OAAO,OAAA,EAAS;AAChH,EAAA,MAAM,iBAAiB,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,cAAA,IAAkB,KAAM,GAAG,CAAA;AACpE,EAAA,MAAM,gBAAgB,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,aAAA,IAAiB,KAAO,GAAI,CAAA;AACpE,EAAA,MAAM,eAAe,KAAA,GAAQ;AAAA,IAC3B,KAAA,EAAO;AAAA,GACT,GAAI,MAAA;AACJ,EAAA,MAAM,MAAM,MAAMA,kCAAA,CAAU,SAAA,CAAU,MAAA,EAAQ,aAAa,YAAA,EAAc;AAAA,IACvE;AAAA,GACF,EAAG;AAAA,IACD,OAAA,EAAS;AAAA,KACR,YAAY,CAAA;AACf,EAAA,IAAI,SAAS,GAAA,CAAI,MAAA;AACjB,EAAA,MAAM,QAAQ,GAAA,CAAI,KAAA;AAClB,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,EAAI,GAAI,aAAA;AAC9B,EAAA,OAAO,WAAW,YAAA,EAAc;AAC9B,IAAA,IAAI,IAAA,CAAK,GAAA,EAAI,IAAK,QAAA,EAAU;AAC1B,MAAA,MAAM,IAAIC,yCAAgC,KAAK,CAAA;AAAA,IACjD;AACA,IAAA,MAAM,iBAAiB,MAAMD,kCAAA,CAAU,UAAU,MAAA,EAAQ,WAAA,EAAa,cAAc,KAAA,EAAO;AAAA,MACzF,OAAA,EAAS;AAAA,OACR,YAAY,CAAA;AACf,IAAA,MAAA,GAAS,cAAA,CAAe,MAAA;AACxB,IAAA,IAAI,WAAW,QAAA,EAAU;AACvB,MAAA,MAAM,IAAIE,wCAA+B,KAAK,CAAA;AAAA,IAChD;AACA,IAAA,IAAI,WAAW,YAAA,EAAc;AAC3B,MAAA,MAAM,IAAI,OAAA,CAAQ,CAAA,OAAA,KAAW,UAAA,CAAW,OAAA,EAAS,cAAc,CAAC,CAAA;AAAA,IAClE;AAAA,EACF;AACA,EAAA,OAAOF,kCAAA,CAAU,SAAA,CAAU,MAAA,EAAQ,WAAA,EAAa,cAAc,KAAA,EAAO;AAAA,IACnE,OAAA,EAAS;AAAA,KACR,YAAY,CAAA;AACjB","file":"transformAndWaitInternal-F3UV33FN.cjs","sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MediaTransformationFailedError, MediaTransformationTimeoutError } from \"@osdk/api/unstable\";\nimport { MediaSets } from \"@osdk/foundry.mediasets\";\n/**\n * @internal\n * Submits a media transformation job, polls until completion, and returns the result.\n */\nexport async function transformAndWaitInternal(client, mediaSetRid, mediaItemRid, transformation, token, options) {\n const pollIntervalMs = Math.max(options?.pollIntervalMs ?? 3000, 100);\n const pollTimeoutMs = Math.max(options?.pollTimeoutMs ?? 30000, 1000);\n const headerParams = token ? {\n Token: token\n } : undefined;\n const job = await MediaSets.transform(client, mediaSetRid, mediaItemRid, {\n transformation\n }, {\n preview: true\n }, headerParams);\n let status = job.status;\n const jobId = job.jobId;\n const deadline = Date.now() + pollTimeoutMs;\n while (status !== \"SUCCESSFUL\") {\n if (Date.now() >= deadline) {\n throw new MediaTransformationTimeoutError(jobId);\n }\n const statusResponse = await MediaSets.getStatus(client, mediaSetRid, mediaItemRid, jobId, {\n preview: true\n }, headerParams);\n status = statusResponse.status;\n if (status === \"FAILED\") {\n throw new MediaTransformationFailedError(jobId);\n }\n if (status !== \"SUCCESSFUL\") {\n await new Promise(resolve => setTimeout(resolve, pollIntervalMs));\n }\n }\n return MediaSets.getResult(client, mediaSetRid, mediaItemRid, jobId, {\n preview: true\n }, headerParams);\n}"]}
1
+ {"version":3,"sources":["../../src/util/transformAndWaitInternal.ts"],"names":["MediaSet_exports","MediaTransformationTimeoutError","MediaTransformationFailedError"],"mappings":";;;;;;;AAsBA,eAAsB,yBAAyB,MAAA,EAAQ,WAAA,EAAa,YAAA,EAAc,cAAA,EAAgB,OAAO,OAAA,EAAS;AAChH,EAAA,MAAM,iBAAiB,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,cAAA,IAAkB,KAAM,GAAG,CAAA;AACpE,EAAA,MAAM,gBAAgB,IAAA,CAAK,GAAA,CAAI,OAAA,EAAS,aAAA,IAAiB,KAAO,GAAI,CAAA;AACpE,EAAA,MAAM,eAAe,KAAA,GAAQ;AAAA,IAC3B,KAAA,EAAO;AAAA,GACT,GAAI,MAAA;AACJ,EAAA,MAAM,MAAM,MAAMA,kCAAA,CAAU,SAAA,CAAU,MAAA,EAAQ,aAAa,YAAA,EAAc;AAAA,IACvE;AAAA,GACF,EAAG;AAAA,IACD,OAAA,EAAS;AAAA,KACR,YAAY,CAAA;AACf,EAAA,IAAI,SAAS,GAAA,CAAI,MAAA;AACjB,EAAA,MAAM,QAAQ,GAAA,CAAI,KAAA;AAClB,EAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,EAAI,GAAI,aAAA;AAC9B,EAAA,OAAO,WAAW,YAAA,EAAc;AAC9B,IAAA,IAAI,IAAA,CAAK,GAAA,EAAI,IAAK,QAAA,EAAU;AAC1B,MAAA,MAAM,IAAIC,yCAAgC,KAAK,CAAA;AAAA,IACjD;AACA,IAAA,MAAM,iBAAiB,MAAMD,kCAAA,CAAU,UAAU,MAAA,EAAQ,WAAA,EAAa,cAAc,KAAA,EAAO;AAAA,MACzF,OAAA,EAAS;AAAA,OACR,YAAY,CAAA;AACf,IAAA,MAAA,GAAS,cAAA,CAAe,MAAA;AACxB,IAAA,IAAI,WAAW,QAAA,EAAU;AACvB,MAAA,MAAM,IAAIE,wCAA+B,KAAK,CAAA;AAAA,IAChD;AACA,IAAA,IAAI,WAAW,YAAA,EAAc;AAC3B,MAAA,MAAM,IAAI,OAAA,CAAQ,CAAA,OAAA,KAAW,UAAA,CAAW,OAAA,EAAS,cAAc,CAAC,CAAA;AAAA,IAClE;AAAA,EACF;AACA,EAAA,OAAOF,kCAAA,CAAU,SAAA,CAAU,MAAA,EAAQ,WAAA,EAAa,cAAc,KAAA,EAAO;AAAA,IACnE,OAAA,EAAS;AAAA,KACR,YAAY,CAAA;AACjB","file":"transformAndWaitInternal-2GORZXPK.cjs","sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MediaTransformationFailedError, MediaTransformationTimeoutError } from \"@osdk/api/unstable\";\nimport { MediaSets } from \"@osdk/foundry.mediasets\";\n/**\n * @internal\n * Submits a media transformation job, polls until completion, and returns the result.\n */\nexport async function transformAndWaitInternal(client, mediaSetRid, mediaItemRid, transformation, token, options) {\n const pollIntervalMs = Math.max(options?.pollIntervalMs ?? 3000, 100);\n const pollTimeoutMs = Math.max(options?.pollTimeoutMs ?? 30000, 1000);\n const headerParams = token ? {\n Token: token\n } : undefined;\n const job = await MediaSets.transform(client, mediaSetRid, mediaItemRid, {\n transformation\n }, {\n preview: true\n }, headerParams);\n let status = job.status;\n const jobId = job.jobId;\n const deadline = Date.now() + pollTimeoutMs;\n while (status !== \"SUCCESSFUL\") {\n if (Date.now() >= deadline) {\n throw new MediaTransformationTimeoutError(jobId);\n }\n const statusResponse = await MediaSets.getStatus(client, mediaSetRid, mediaItemRid, jobId, {\n preview: true\n }, headerParams);\n status = statusResponse.status;\n if (status === \"FAILED\") {\n throw new MediaTransformationFailedError(jobId);\n }\n if (status !== \"SUCCESSFUL\") {\n await new Promise(resolve => setTimeout(resolve, pollIntervalMs));\n }\n }\n return MediaSets.getResult(client, mediaSetRid, mediaItemRid, jobId, {\n preview: true\n }, headerParams);\n}"]}
@@ -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.23.0";
24
+ const MaxOsdkVersion = "2.23.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 /**\n * Returns the operation surface for the given ontology definition. The shape of the\n * returned value is dispatched on what kind of definition is passed:\n * - object type → the object set type for that ontology object (typically a generated extension of {@link ObjectSet})\n * - interface → a {@link MinimalObjectSet} for the interface\n * - action → a callable with `applyAction` / `batchApplyAction`\n * - query → a callable with `executeFunction`\n * - experiment → the unstable feature surface for that experiment\n *\n * @param o - The object type definition to wrap.\n * @example\n * ```ts\n * const employees = await client(Employee).fetchPage({ $pageSize: 30 });\n * const employee = await client(Employee).fetchOne(12345);\n * ```\n * @returns an object set scoped to all objects of this type.\n */\n <Q extends ObjectTypeDefinition>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? ObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n /**\n * @param o - The interface definition to wrap.\n * @example\n * ```ts\n * const page = await client(MyInterface).fetchPage({ $pageSize: 30 });\n * ```\n * @returns a minimal object set over all objects implementing the interface.\n */\n <Q extends (InterfaceDefinition)>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? MinimalObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n /**\n * @param o - The action definition to invoke.\n * @example\n * ```ts\n * const result = await client(createEmployee).applyAction(\n * { name: \"Jane\", department: \"Engineering\" },\n * { $returnEdits: true },\n * );\n * ```\n * @returns a callable for applying (or batch-applying) the action.\n */\n <Q extends ActionDefinition<any>>(\n o: Q,\n ): ActionSignatureFromDef<Q>;\n\n /**\n * @param o - The query definition to invoke.\n * @example\n * ```ts\n * const result = await client(getEmployeeCount).executeFunction({ department: \"Engineering\" });\n * ```\n * @returns a callable for executing the query function.\n */\n <Q extends QueryDefinition<any>>(\n o: Q,\n ): QuerySignatureFromDef<Q>;\n\n /**\n * @param experiment - The experiment marker that gates an unstable feature.\n * @example\n * ```ts\n * const ref = await client(__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference)\n * .createMediaReference({ data: blob, fileName: \"media.mp4\", objectType: Employee, propertyType: \"photo\" });\n * ```\n * @returns the experiment-specific function surface.\n */\n <\n Q extends\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">\n | Experiment<\"2.2.0\">\n | Experiment<\"2.8.0\">\n | Experiment<\"2.19.0\">,\n >(\n experiment: Q,\n ): ExperimentFns<Q>;\n\n /**\n * Fetches runtime metadata for the given ontology definition. The returned shape\n * is dispatched on the kind of definition passed: {@link ObjectMetadata},\n * {@link InterfaceMetadata}, {@link ActionMetadata}, or {@link QueryMetadata}.\n * @param o - The object type, interface, action, or query definition to look up.\n * @example\n * ```ts\n * const meta = await client.fetchMetadata(Employee);\n * console.log(meta.displayName, meta.description);\n * ```\n * @returns a promise resolving to the metadata for the given definition.\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.23.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;;AA8HA;AACA;AACA,OAAO,MAAMA,iBAAgC,GAAGC,MAAM,CAAC,mBAAmB,CAAC;;AAE3E;AACA,MAAMC,cAAc,GAAG,QAAQ;AAC/B;;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 /**\n * Returns the operation surface for the given ontology definition. The shape of the\n * returned value is dispatched on what kind of definition is passed:\n * - object type → the object set type for that ontology object (typically a generated extension of {@link ObjectSet})\n * - interface → a {@link MinimalObjectSet} for the interface\n * - action → a callable with `applyAction` / `batchApplyAction`\n * - query → a callable with `executeFunction`\n * - experiment → the unstable feature surface for that experiment\n *\n * @param o - The object type definition to wrap.\n * @example\n * ```ts\n * const employees = await client(Employee).fetchPage({ $pageSize: 30 });\n * const employee = await client(Employee).fetchOne(12345);\n * ```\n * @returns an object set scoped to all objects of this type.\n */\n <Q extends ObjectTypeDefinition>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? ObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n /**\n * @param o - The interface definition to wrap.\n * @example\n * ```ts\n * const page = await client(MyInterface).fetchPage({ $pageSize: 30 });\n * ```\n * @returns a minimal object set over all objects implementing the interface.\n */\n <Q extends (InterfaceDefinition)>(\n o: Q,\n ): unknown extends CompileTimeMetadata<Q>[\"objectSet\"] ? MinimalObjectSet<Q>\n : CompileTimeMetadata<Q>[\"objectSet\"];\n\n /**\n * @param o - The action definition to invoke.\n * @example\n * ```ts\n * const result = await client(createEmployee).applyAction(\n * { name: \"Jane\", department: \"Engineering\" },\n * { $returnEdits: true },\n * );\n * ```\n * @returns a callable for applying (or batch-applying) the action.\n */\n <Q extends ActionDefinition<any>>(\n o: Q,\n ): ActionSignatureFromDef<Q>;\n\n /**\n * @param o - The query definition to invoke.\n * @example\n * ```ts\n * const result = await client(getEmployeeCount).executeFunction({ department: \"Engineering\" });\n * ```\n * @returns a callable for executing the query function.\n */\n <Q extends QueryDefinition<any>>(\n o: Q,\n ): QuerySignatureFromDef<Q>;\n\n /**\n * @param experiment - The experiment marker that gates an unstable feature.\n * @example\n * ```ts\n * const ref = await client(__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference)\n * .createMediaReference({ data: blob, fileName: \"media.mp4\", objectType: Employee, propertyType: \"photo\" });\n * ```\n * @returns the experiment-specific function surface.\n */\n <\n Q extends\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">\n | Experiment<\"2.2.0\">\n | Experiment<\"2.8.0\">\n | Experiment<\"2.19.0\">,\n >(\n experiment: Q,\n ): ExperimentFns<Q>;\n\n /**\n * Fetches runtime metadata for the given ontology definition. The returned shape\n * is dispatched on the kind of definition passed: {@link ObjectMetadata},\n * {@link InterfaceMetadata}, {@link ActionMetadata}, or {@link QueryMetadata}.\n * @param o - The object type, interface, action, or query definition to look up.\n * @example\n * ```ts\n * const meta = await client.fetchMetadata(Employee);\n * console.log(meta.displayName, meta.description);\n * ```\n * @returns a promise resolving to the metadata for the given definition.\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.23.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;;AA8HA;AACA;AACA,OAAO,MAAMA,iBAAgC,GAAGC,MAAM,CAAC,mBAAmB,CAAC;;AAE3E;AACA,MAAMC,cAAc,GAAG,QAAQ;AAC/B;;AAEA,MAAMC,YAA2B,GAAGF,MAAM,CAAC,cAAc,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"MinimalClientContext.js","names":[],"sources":["MinimalClientContext.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 { Logger } from \"@osdk/api\";\nimport type { SharedClientContext } from \"@osdk/shared.client2\";\nimport type { convertWireToOsdkObjects } from \"./object/convertWireToOsdkObjects.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport type { OntologyProvider } from \"./ontology/OntologyProvider.js\";\n\ndeclare const tag: unique symbol;\n\nexport type ClientCacheKey = {} & { readonly [tag]: void };\n\nexport type RequestContext = {\n finalMethodCall?: string;\n};\n\nexport interface MinimalClient extends SharedClientContext {\n ontologyRid: string | Promise<string>;\n ontologyProvider: OntologyProvider;\n logger?: Logger;\n branch?: string;\n /** @internal */\n objectSetFactory: ObjectSetFactory<any, any>;\n /** @internal */\n objectFactory: typeof convertWireToOsdkObjects;\n\n transactionId?: string;\n flushEdits?: () => Promise<void>;\n\n clientCacheKey: ClientCacheKey;\n requestContext: RequestContext;\n narrowTypeInterfaceOrObjectMapping: Record<string, \"object\" | \"interface\">;\n}\n\nexport type MinimalClientParams = {\n metadata: MinimalClientMetadata;\n provider: OntologyProvider;\n};\n\nexport interface MinimalClientMetadata {\n ontologyRid: string | Promise<string>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"MinimalClientContext.js","names":[],"sources":["MinimalClientContext.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 { Logger } from \"@osdk/api\";\nimport type { SharedClientContext } from \"@osdk/shared.client2\";\nimport type { convertWireToOsdkObjects } from \"./object/convertWireToOsdkObjects.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport type { OntologyProvider } from \"./ontology/OntologyProvider.js\";\n\ndeclare const tag: unique symbol;\n\nexport type ClientCacheKey = {} & { readonly [tag]: void };\n\nexport type RequestContext = {\n finalMethodCall?: string;\n};\n\nexport interface MinimalClient extends SharedClientContext {\n ontologyRid: string | Promise<string>;\n ontologyProvider: OntologyProvider;\n logger?: Logger;\n branch?: string;\n /** @internal */\n objectSetFactory: ObjectSetFactory<any, any>;\n /** @internal */\n objectFactory: typeof convertWireToOsdkObjects;\n\n transactionId?: string;\n flushEdits?: () => Promise<void>;\n scenarioRid?: string;\n\n clientCacheKey: ClientCacheKey;\n requestContext: RequestContext;\n narrowTypeInterfaceOrObjectMapping: Record<string, \"object\" | \"interface\">;\n}\n\nexport type MinimalClientParams = {\n metadata: MinimalClientMetadata;\n provider: OntologyProvider;\n};\n\nexport interface MinimalClientMetadata {\n ontologyRid: string | Promise<string>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -26,6 +26,7 @@ export async function applyAction(client, action, parameters, options = {}) {
26
26
  })), action);
27
27
  if (Array.isArray(parameters)) {
28
28
  !(client.transactionId == null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Batch actions are not supported for staged edit functions or when supplying a transaction ID") : invariant(false) : void 0;
29
+ !(client.scenarioRid == null) ? process.env.NODE_ENV !== "production" ? invariant(false, "Batch actions are not supported when scoped to a scenario") : invariant(false) : void 0;
29
30
  const response = await Actions.applyBatch(clientWithHeaders, await client.ontologyRid, action.unsanitizedApiName ?? action.apiName, {
30
31
  requests: parameters ? await remapBatchActionParams(parameters, client, await client.ontologyProvider.getActionDefinition(action.unsanitizedApiName ?? action.apiName)) : [],
31
32
  options: {
@@ -45,7 +46,8 @@ export async function applyAction(client, action, parameters, options = {}) {
45
46
  }
46
47
  }, {
47
48
  branch: client.branch,
48
- transactionId: client.transactionId
49
+ transactionId: client.transactionId,
50
+ scenarioRid: client.scenarioRid
49
51
  });
50
52
  if (options?.$validateOnly) {
51
53
  return response.validation;
@@ -1 +1 @@
1
- {"version":3,"file":"applyAction.js","names":["Actions","invariant","addUserAgentAndRequestContextHeaders","augmentRequestContext","toDataValue","ActionValidationError","applyAction","client","action","parameters","options","clientWithHeaders","finalMethodCall","Array","isArray","transactionId","process","env","NODE_ENV","response","applyBatch","ontologyRid","unsanitizedApiName","apiName","requests","remapBatchActionParams","ontologyProvider","getActionDefinition","returnEdits","$returnEdits","branch","edits","type","remapActionResponse","undefined","apply","remapActionParams","mode","$validateOnly","validation","result","params","actionMetadata","parameterMap","key","value","Object","entries","remappedParams","Promise","all","map","param","editResponses","remappedActionResponse","deletedLinksCount","deletedObjectsCount","addedLinks","deletedLinks","addedObjects","deletedObjects","modifiedObjects","editedObjectTypes","editedObjectTypesSet","Set","edit","osdkEdit","linkTypeApiNameAtoB","linkTypeApiNameBtoA","aSideObject","bSideObject","push","add","objectType","primaryKey","console","warn","JSON","stringify"],"sources":["applyAction.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 ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n CompileTimeMetadata as CompileTimeActionMetadata,\n DataValueClientToWire,\n} from \"@osdk/api\";\nimport type {\n BatchApplyActionResponseV2,\n DataValue,\n SyncApplyActionResponseV2,\n} from \"@osdk/foundry.ontologies\";\nimport * as Actions from \"@osdk/foundry.ontologies/Action\";\nimport invariant from \"tiny-invariant\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport type { NOOP } from \"../util/NOOP.js\";\nimport type { NullableProps } from \"../util/NullableProps.js\";\nimport type { PartialBy } from \"../util/partialBy.js\";\nimport { toDataValue } from \"../util/toDataValue.js\";\nimport { ActionValidationError } from \"./ActionValidationError.js\";\n\ntype BaseType<APD extends Pick<ActionMetadata.Parameter<any>, \"type\">> =\n APD[\"type\"] extends ActionMetadata.DataType.Object<infer TTargetType>\n ? ActionParam.ObjectType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.ObjectSet<infer TTargetType>\n ? ActionParam.ObjectSetType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.Struct<infer TStructType>\n ? ActionParam.StructType<TStructType>\n : APD[\"type\"] extends keyof DataValueClientToWire\n ? ActionParam.PrimitiveType<APD[\"type\"]>\n : never;\n\ntype MaybeArrayType<APD extends ActionMetadata.Parameter<any>> =\n APD[\"multiplicity\"] extends true ? Array<BaseType<APD>>\n : BaseType<APD>;\n\ntype NotOptionalParams<X extends ActionParametersDefinition> = {\n [P in keyof X]: MaybeArrayType<X[P]>;\n};\n\nexport type OsdkActionParameters<\n X extends ActionParametersDefinition,\n> = NullableProps<X> extends never ? NotOptionalParams<X>\n : PartialBy<NotOptionalParams<X>, NullableProps<X>>;\n\nexport type ActionSignatureFromDef<\n T extends ActionDefinition<any>,\n> = {\n applyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"]] extends [never]\n ? ActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"];\n\n batchApplyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"]] extends\n [never] ? BatchActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"];\n};\n\ntype ActionParametersDefinition = Record<\n any,\n ActionMetadata.Parameter<any>\n>;\n\nexport type ActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>,\n OP extends ApplyActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport type BatchActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>[],\n OP extends ApplyBatchActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport async function applyAction<\n AD extends ActionDefinition<any>,\n P extends\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n Op extends P extends OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >[] ? ApplyBatchActionOptions\n : ApplyActionOptions,\n>(\n client: MinimalClient,\n action: AD,\n parameters?: P,\n options: Op = {} as Op,\n): Promise<\n ActionReturnTypeForOptions<Op>\n> {\n const clientWithHeaders = addUserAgentAndRequestContextHeaders(\n augmentRequestContext(client, _ => ({ finalMethodCall: \"applyAction\" })),\n action,\n );\n if (Array.isArray(parameters)) {\n invariant(\n client.transactionId == null,\n \"Batch actions are not supported for staged edit functions or when supplying a transaction ID\",\n );\n const response = await Actions.applyBatch(\n clientWithHeaders,\n await client.ontologyRid,\n action.unsanitizedApiName ?? action.apiName,\n {\n requests: parameters\n ? await remapBatchActionParams(\n parameters,\n client,\n await client.ontologyProvider.getActionDefinition(\n action.unsanitizedApiName ?? action.apiName,\n ),\n )\n : [],\n options: {\n returnEdits: options?.$returnEdits ? \"ALL\" : \"NONE\",\n },\n },\n { branch: client.branch },\n );\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n } else {\n const response = await Actions.apply(\n clientWithHeaders,\n await client.ontologyRid,\n action.unsanitizedApiName ?? action.apiName,\n {\n parameters: await remapActionParams(\n parameters as OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >,\n client,\n await client.ontologyProvider.getActionDefinition(\n action.unsanitizedApiName ?? action.apiName,\n ),\n ),\n options: {\n mode: (options as ApplyActionOptions)?.$validateOnly\n ? \"VALIDATE_ONLY\"\n : \"VALIDATE_AND_EXECUTE\",\n returnEdits: options\n ?.$returnEdits\n ? \"ALL_V2_WITH_DELETIONS\"\n : \"NONE\",\n },\n },\n { branch: client.branch, transactionId: client.transactionId },\n );\n\n if ((options as ApplyActionOptions)?.$validateOnly) {\n return response.validation as ActionReturnTypeForOptions<Op>;\n }\n\n if (response.validation && response.validation?.result === \"INVALID\") {\n const validation = response.validation;\n throw new ActionValidationError(validation);\n }\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n }\n}\n\nasync function remapActionParams<AD extends ActionDefinition<any>>(\n params:\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | undefined,\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n): Promise<Record<string, DataValue>> {\n if (params == null) {\n return {};\n }\n\n const parameterMap: { [parameterName: string]: unknown } = {};\n for (const [key, value] of Object.entries(params)) {\n parameterMap[key] = await toDataValue(value, client, actionMetadata);\n }\n\n return parameterMap;\n}\n\nasync function remapBatchActionParams<\n AD extends ActionDefinition<any>,\n>(\n params: OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n) {\n const remappedParams = await Promise.all(params.map(\n async param => {\n return {\n parameters: await remapActionParams<AD>(param, client, actionMetadata),\n };\n },\n ));\n\n return remappedParams;\n}\n\nexport function remapActionResponse(\n response: SyncApplyActionResponseV2 | BatchApplyActionResponseV2,\n): ActionEditResponse | undefined {\n const editResponses = response?.edits;\n if (editResponses?.type === \"edits\") {\n const remappedActionResponse: ActionEditResponse = {\n type: editResponses.type,\n deletedLinksCount: editResponses.deletedLinksCount,\n deletedObjectsCount: editResponses.deletedObjectsCount,\n addedLinks: [],\n deletedLinks: [],\n addedObjects: [],\n deletedObjects: [],\n modifiedObjects: [],\n editedObjectTypes: [],\n };\n\n const editedObjectTypesSet = new Set<string>();\n for (const edit of editResponses.edits) {\n if (edit.type === \"addLink\" || edit.type === \"deleteLink\") {\n const osdkEdit = {\n linkTypeApiNameAtoB: edit.linkTypeApiNameAtoB,\n linkTypeApiNameBtoA: edit.linkTypeApiNameBtoA,\n aSideObject: edit.aSideObject,\n bSideObject: edit.bSideObject,\n };\n edit.type === \"addLink\"\n ? remappedActionResponse.addedLinks.push(\n osdkEdit,\n )\n : remappedActionResponse.deletedLinks?.push(osdkEdit);\n editedObjectTypesSet.add(edit.aSideObject.objectType);\n editedObjectTypesSet.add(edit.bSideObject.objectType);\n } else if (\n edit.type === \"addObject\" || edit.type === \"deleteObject\"\n || edit.type === \"modifyObject\"\n ) {\n const osdkEdit = {\n objectType: edit.objectType,\n primaryKey: edit.primaryKey,\n };\n if (edit.type === \"addObject\") {\n remappedActionResponse.addedObjects.push(osdkEdit);\n } else if (edit.type === \"deleteObject\") {\n remappedActionResponse.deletedObjects?.push(osdkEdit);\n } else if (edit.type === \"modifyObject\") {\n remappedActionResponse.modifiedObjects.push(osdkEdit);\n }\n editedObjectTypesSet.add(edit.objectType);\n } else {\n if (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.warn(\n `Unexpected edit type: ${JSON.stringify(edit)}`,\n );\n }\n }\n }\n remappedActionResponse.editedObjectTypes = [...editedObjectTypesSet];\n return remappedActionResponse;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;A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AAc,EAAE;UACvCsB,sBAAsB,CAACO,eAAe,CAACU,IAAI,CAACL,QAAQ,CAAC;QACvD;QACAH,oBAAoB,CAACS,GAAG,CAACP,IAAI,CAACQ,UAAU,CAAC;MAC3C,CAAC,MAAM;QACL,IAAIzD,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;UACzC;UACAyD,OAAO,CAACC,IAAI,CACV,yBAAyBC,IAAI,CAACC,SAAS,CAACb,IAAI,CAAC,EAC/C,CAAC;QACH;MACF;IACF;IACAX,sBAAsB,CAACQ,iBAAiB,GAAG,CAAC,GAAGC,oBAAoB,CAAC;IACpE,OAAOT,sBAAsB;EAC/B;AACF","ignoreList":[]}
1
+ {"version":3,"file":"applyAction.js","names":["Actions","invariant","addUserAgentAndRequestContextHeaders","augmentRequestContext","toDataValue","ActionValidationError","applyAction","client","action","parameters","options","clientWithHeaders","finalMethodCall","Array","isArray","transactionId","process","env","NODE_ENV","scenarioRid","response","applyBatch","ontologyRid","unsanitizedApiName","apiName","requests","remapBatchActionParams","ontologyProvider","getActionDefinition","returnEdits","$returnEdits","branch","edits","type","remapActionResponse","undefined","apply","remapActionParams","mode","$validateOnly","validation","result","params","actionMetadata","parameterMap","key","value","Object","entries","remappedParams","Promise","all","map","param","editResponses","remappedActionResponse","deletedLinksCount","deletedObjectsCount","addedLinks","deletedLinks","addedObjects","deletedObjects","modifiedObjects","editedObjectTypes","editedObjectTypesSet","Set","edit","osdkEdit","linkTypeApiNameAtoB","linkTypeApiNameBtoA","aSideObject","bSideObject","push","add","objectType","primaryKey","console","warn","JSON","stringify"],"sources":["applyAction.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 ActionEditResponse,\n ActionMetadata,\n ActionParam,\n ActionReturnTypeForOptions,\n ApplyActionOptions,\n ApplyBatchActionOptions,\n CompileTimeMetadata as CompileTimeActionMetadata,\n DataValueClientToWire,\n} from \"@osdk/api\";\nimport type {\n BatchApplyActionResponseV2,\n DataValue,\n SyncApplyActionResponseV2,\n} from \"@osdk/foundry.ontologies\";\nimport * as Actions from \"@osdk/foundry.ontologies/Action\";\nimport invariant from \"tiny-invariant\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport type { NOOP } from \"../util/NOOP.js\";\nimport type { NullableProps } from \"../util/NullableProps.js\";\nimport type { PartialBy } from \"../util/partialBy.js\";\nimport { toDataValue } from \"../util/toDataValue.js\";\nimport { ActionValidationError } from \"./ActionValidationError.js\";\n\ntype BaseType<APD extends Pick<ActionMetadata.Parameter<any>, \"type\">> =\n APD[\"type\"] extends ActionMetadata.DataType.Object<infer TTargetType>\n ? ActionParam.ObjectType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.ObjectSet<infer TTargetType>\n ? ActionParam.ObjectSetType<TTargetType>\n : APD[\"type\"] extends ActionMetadata.DataType.Struct<infer TStructType>\n ? ActionParam.StructType<TStructType>\n : APD[\"type\"] extends keyof DataValueClientToWire\n ? ActionParam.PrimitiveType<APD[\"type\"]>\n : never;\n\ntype MaybeArrayType<APD extends ActionMetadata.Parameter<any>> =\n APD[\"multiplicity\"] extends true ? Array<BaseType<APD>>\n : BaseType<APD>;\n\ntype NotOptionalParams<X extends ActionParametersDefinition> = {\n [P in keyof X]: MaybeArrayType<X[P]>;\n};\n\nexport type OsdkActionParameters<\n X extends ActionParametersDefinition,\n> = NullableProps<X> extends never ? NotOptionalParams<X>\n : PartialBy<NotOptionalParams<X>, NullableProps<X>>;\n\nexport type ActionSignatureFromDef<\n T extends ActionDefinition<any>,\n> = {\n applyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"]] extends [never]\n ? ActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"applyAction\"];\n\n batchApplyAction:\n [CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"]] extends\n [never] ? BatchActionSignature<CompileTimeActionMetadata<T>[\"parameters\"]>\n : CompileTimeActionMetadata<T>[\"signatures\"][\"batchApplyAction\"];\n};\n\ntype ActionParametersDefinition = Record<\n any,\n ActionMetadata.Parameter<any>\n>;\n\nexport type ActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>,\n OP extends ApplyActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport type BatchActionSignature<\n X extends Record<any, ActionMetadata.Parameter<any>>,\n> = <\n A extends NOOP<OsdkActionParameters<X>>[],\n OP extends ApplyBatchActionOptions,\n>(\n args: A,\n options?: OP,\n) => Promise<\n ActionReturnTypeForOptions<OP>\n>;\n\nexport async function applyAction<\n AD extends ActionDefinition<any>,\n P extends\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n Op extends P extends OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >[] ? ApplyBatchActionOptions\n : ApplyActionOptions,\n>(\n client: MinimalClient,\n action: AD,\n parameters?: P,\n options: Op = {} as Op,\n): Promise<\n ActionReturnTypeForOptions<Op>\n> {\n const clientWithHeaders = addUserAgentAndRequestContextHeaders(\n augmentRequestContext(client, _ => ({ finalMethodCall: \"applyAction\" })),\n action,\n );\n if (Array.isArray(parameters)) {\n invariant(\n client.transactionId == null,\n \"Batch actions are not supported for staged edit functions or when supplying a transaction ID\",\n );\n invariant(\n client.scenarioRid == null,\n \"Batch actions are not supported when scoped to a scenario\",\n );\n const response = await Actions.applyBatch(\n clientWithHeaders,\n await client.ontologyRid,\n action.unsanitizedApiName ?? action.apiName,\n {\n requests: parameters\n ? await remapBatchActionParams(\n parameters,\n client,\n await client.ontologyProvider.getActionDefinition(\n action.unsanitizedApiName ?? action.apiName,\n ),\n )\n : [],\n options: {\n returnEdits: options?.$returnEdits ? \"ALL\" : \"NONE\",\n },\n },\n { branch: client.branch },\n );\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n } else {\n const response = await Actions.apply(\n clientWithHeaders,\n await client.ontologyRid,\n action.unsanitizedApiName ?? action.apiName,\n {\n parameters: await remapActionParams(\n parameters as OsdkActionParameters<\n CompileTimeActionMetadata<AD>[\"parameters\"]\n >,\n client,\n await client.ontologyProvider.getActionDefinition(\n action.unsanitizedApiName ?? action.apiName,\n ),\n ),\n options: {\n mode: (options as ApplyActionOptions)?.$validateOnly\n ? \"VALIDATE_ONLY\"\n : \"VALIDATE_AND_EXECUTE\",\n returnEdits: options\n ?.$returnEdits\n ? \"ALL_V2_WITH_DELETIONS\"\n : \"NONE\",\n },\n },\n {\n branch: client.branch,\n transactionId: client.transactionId,\n scenarioRid: client.scenarioRid,\n },\n );\n\n if ((options as ApplyActionOptions)?.$validateOnly) {\n return response.validation as ActionReturnTypeForOptions<Op>;\n }\n\n if (response.validation && response.validation?.result === \"INVALID\") {\n const validation = response.validation;\n throw new ActionValidationError(validation);\n }\n\n const edits = response.edits;\n return (options?.$returnEdits\n ? edits?.type === \"edits\" ? remapActionResponse(response) : edits\n : undefined) as ActionReturnTypeForOptions<Op>;\n }\n}\n\nasync function remapActionParams<AD extends ActionDefinition<any>>(\n params:\n | OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>\n | undefined,\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n): Promise<Record<string, DataValue>> {\n if (params == null) {\n return {};\n }\n\n const parameterMap: { [parameterName: string]: unknown } = {};\n for (const [key, value] of Object.entries(params)) {\n parameterMap[key] = await toDataValue(value, client, actionMetadata);\n }\n\n return parameterMap;\n}\n\nasync function remapBatchActionParams<\n AD extends ActionDefinition<any>,\n>(\n params: OsdkActionParameters<CompileTimeActionMetadata<AD>[\"parameters\"]>[],\n client: MinimalClient,\n actionMetadata: ActionMetadata,\n) {\n const remappedParams = await Promise.all(params.map(\n async param => {\n return {\n parameters: await remapActionParams<AD>(param, client, actionMetadata),\n };\n },\n ));\n\n return remappedParams;\n}\n\nexport function remapActionResponse(\n response: SyncApplyActionResponseV2 | BatchApplyActionResponseV2,\n): ActionEditResponse | undefined {\n const editResponses = response?.edits;\n if (editResponses?.type === \"edits\") {\n const remappedActionResponse: ActionEditResponse = {\n type: editResponses.type,\n deletedLinksCount: editResponses.deletedLinksCount,\n deletedObjectsCount: editResponses.deletedObjectsCount,\n addedLinks: [],\n deletedLinks: [],\n addedObjects: [],\n deletedObjects: [],\n modifiedObjects: [],\n editedObjectTypes: [],\n };\n\n const editedObjectTypesSet = new Set<string>();\n for (const edit of editResponses.edits) {\n if (edit.type === \"addLink\" || edit.type === \"deleteLink\") {\n const osdkEdit = {\n linkTypeApiNameAtoB: edit.linkTypeApiNameAtoB,\n linkTypeApiNameBtoA: edit.linkTypeApiNameBtoA,\n aSideObject: edit.aSideObject,\n bSideObject: edit.bSideObject,\n };\n edit.type === \"addLink\"\n ? remappedActionResponse.addedLinks.push(\n osdkEdit,\n )\n : remappedActionResponse.deletedLinks?.push(osdkEdit);\n editedObjectTypesSet.add(edit.aSideObject.objectType);\n editedObjectTypesSet.add(edit.bSideObject.objectType);\n } else if (\n edit.type === \"addObject\" || edit.type === \"deleteObject\"\n || edit.type === \"modifyObject\"\n ) {\n const osdkEdit = {\n objectType: edit.objectType,\n primaryKey: edit.primaryKey,\n };\n if (edit.type === \"addObject\") {\n remappedActionResponse.addedObjects.push(osdkEdit);\n } else if (edit.type === \"deleteObject\") {\n remappedActionResponse.deletedObjects?.push(osdkEdit);\n } else if (edit.type === \"modifyObject\") {\n remappedActionResponse.modifiedObjects.push(osdkEdit);\n }\n editedObjectTypesSet.add(edit.objectType);\n } else {\n if (process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.warn(\n `Unexpected edit type: ${JSON.stringify(edit)}`,\n );\n }\n }\n }\n remappedActionResponse.editedObjectTypes = [...editedObjectTypesSet];\n return remappedActionResponse;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA,OAAO,KAAKA,OAAO,MAAM,iCAAiC;AAC1D,OAAOC,SAAS,MAAM,gBAAgB;AAEtC,SAASC,oCAAoC,QAAQ,iDAAiD;AACtG,SAASC,qBAAqB,QAAQ,kCAAkC;AAIxE,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,qBAAqB,QAAQ,4BAA4B;AAqElE,OAAO,eAAeC,WAAWA,CAU/BC,MAAqB,EACrBC,MAAU,EACVC,UAAc,EACdC,OAAW,GAAG,CAAC,CAAO,EAGtB;EACA,MAAMC,iBAAiB,GAAGT,oCAAoC,CAC5DC,qBAAqB,CAACI,MAAM,EAAE,OAAM;IAAEK,eAAe,EAAE;EAAc,CAAC,CAAC,CAAC,EACxEJ,MACF,CAAC;EACD,IAAIK,KAAK,CAACC,OAAO,CAACL,UAAU,CAAC,EAAE;IAC7B,EACEF,MAAM,CAACQ,aAAa,IAAI,IAAI,IAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAD9BjB,SAAS,QAEP,8FAA8F,IAFhGA,SAAS;IAIT,EACEM,MAAM,CAACY,WAAW,IAAI,IAAI,IAAAH,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBA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UAAU,CAAC;QACrDV,oBAAoB,CAACS,GAAG,CAACP,IAAI,CAACK,WAAW,CAACG,UAAU,CAAC;MACvD,CAAC,MAAM,IACLR,IAAI,CAACjC,IAAI,KAAK,WAAW,IAAIiC,IAAI,CAACjC,IAAI,KAAK,cAAc,IACtDiC,IAAI,CAACjC,IAAI,KAAK,cAAc,EAC/B;QACA,MAAMkC,QAAQ,GAAG;UACfO,UAAU,EAAER,IAAI,CAACQ,UAAU;UAC3BC,UAAU,EAAET,IAAI,CAACS;QACnB,CAAC;QACD,IAAIT,IAAI,CAACjC,IAAI,KAAK,WAAW,EAAE;UAC7BsB,sBAAsB,CAACK,YAAY,CAACY,IAAI,CAACL,QAAQ,CAAC;QACpD,CAAC,MAAM,IAAID,IAAI,CAACjC,IAAI,KAAK,cAAc,EAAE;UACvCsB,sBAAsB,CAACM,cAAc,EAAEW,IAAI,CAACL,QAAQ,CAAC;QACvD,CAAC,MAAM,IAAID,IAAI,CAACjC,IAAI,KAAK,cAAc,EAAE;UACvCsB,sBAAsB,CAACO,eAAe,CAACU,IAAI,CAACL,QAAQ,CAAC;QACvD;QACAH,oBAAoB,CAACS,GAAG,CAACP,IAAI,CAACQ,UAAU,CAAC;MAC3C,CAAC,MAAM;QACL,IAAI1D,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;UACzC;UACA0D,OAAO,CAACC,IAAI,CACV,yBAAyBC,IAAI,CAACC,SAAS,CAACb,IAAI,CAAC,EAC/C,CAAC;QACH;MACF;IACF;IACAX,sBAAsB,CAACQ,iBAAiB,GAAG,CAAC,GAAGC,oBAAoB,CAAC;IACpE,OAAOT,sBAAsB;EAC/B;AACF","ignoreList":[]}
@@ -51,7 +51,7 @@ class QueryInvoker {
51
51
  }
52
52
 
53
53
  /** @internal */
54
- export function createClientInternal(objectSetFactory, transactionRid, flushEdits, baseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {
54
+ export function createClientInternal(objectSetFactory, transactionRid, flushEdits, scenarioRid, baseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {
55
55
  if (typeof ontologyRid === "string") {
56
56
  if (!ontologyRid.startsWith("ri.")) {
57
57
  throw new Error("Invalid ontology RID");
@@ -72,6 +72,7 @@ export function createClientInternal(objectSetFactory, transactionRid, flushEdit
72
72
  logger: options?.logger ?? new MinimalLogger(),
73
73
  transactionId: transactionRid,
74
74
  flushEdits,
75
+ scenarioRid,
75
76
  branch: options?.UNSTABLE_DO_NOT_USE_BRANCH
76
77
  }, fetchFn, objectSetFactory);
77
78
  return createClientFromContext(clientCtx);
@@ -224,8 +225,11 @@ export function createClientFromContext(clientCtx) {
224
225
  * ```
225
226
  * @returns a {@link Client} configured to talk to the given Foundry stack and ontology
226
227
  */
227
- export const createClient = createClientInternal.bind(undefined, createObjectSet, undefined, undefined);
228
- export const createClientWithTransaction = (transactionRid, flushEdits, ...args) => createClientInternal(createObjectSet, transactionRid, flushEdits, ...args);
228
+ export const createClient = createClientInternal.bind(undefined, createObjectSet, undefined, undefined, undefined);
229
+ export const createClientWithTransaction = (transactionRid, flushEdits, ...args) => createClientInternal(createObjectSet, transactionRid, flushEdits, undefined, ...args);
230
+
231
+ /** @internal */
232
+ export const createClientWithScenario = (scenarioRid, ...args) => createClientInternal(createObjectSet, undefined, undefined, scenarioRid, ...args);
229
233
  function createWithRid(rids) {
230
234
  return {
231
235
  type: "static",
@@ -1 +1 @@
1
- {"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference","__EXPERIMENTAL__NOT_SUPPORTED_YET__executeStreamingFunction","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","__EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet","__EXPERIMENTAL__NOT_SUPPORTED_YET__transformAndWait","symbolClientContext","oldSymbolClientContext","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","makeMediaTransformation","MinimalLogger","fetchPage","fetchStaticRidPage","fetchSingle","createObjectSet","ObjectSetListenerWebsocket","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","transactionRid","flushEdits","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","logger","transactionId","branch","UNSTABLE_DO_NOT_USE_BRANCH","createClientFromContext","fetchMetadata","client","Object","defineProperties","o","type","name","executeStreamingFunction","query","params","applyStreamingQuery","getBulkLinks","objs","linkTypes","createBulkLinksAsyncIterFactory","fetchOneByRid","objectType","rid","createWithRid","createMediaReference","args","data","fileName","propertyType","upload","apiName","mediaItemPath","preview","fetchPageByRid","objectOrInterfaceType","rids","fetchPageByRidNoType","subscribeToNoTypeObjectSet","listener","opts","unsubscribe","getInstance","subscribeWithoutType","reference","includeRid","transformAndWait","transformAndWaitInternal","mediaSetRid","mediaItemRid","token","mediaReference","mediaSetViewItem","transformation","value","createClient","createClientWithTransaction"],"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 FetchPageArgs,\n InterfaceDefinition,\n Logger,\n MediaReference,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectSetSubscription,\n ObjectTypeDefinition,\n Osdk,\n OsdkBase,\n PropertyKeys,\n QueryDefinition,\n SelectArg,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MediaTransformation,\n MinimalObjectSet,\n TransformOptions,\n} from \"@osdk/api/unstable\";\nimport {\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__executeStreamingFunction,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__transformAndWait,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\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 { makeMediaTransformation } from \"./internal/conversions/makeMediaTransformation.js\";\nimport { MinimalLogger } from \"./logger/MinimalLogger.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { fetchPage, fetchStaticRidPage } from \"./object/fetchPage.js\";\nimport { fetchSingle } from \"./object/fetchSingle.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport { ObjectSetListenerWebsocket } from \"./objectSet/ObjectSetListenerWebsocket.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>,\n transactionRid: string | undefined,\n flushEdits: (() => Promise<void>) | undefined,\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options:\n | {\n logger?: Logger;\n UNSTABLE_DO_NOT_USE_BRANCH?: string;\n headers?: Record<string, string>;\n }\n | 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 {\n ...options,\n logger: options?.logger ?? new MinimalLogger(),\n transactionId: transactionRid,\n flushEdits,\n branch: options?.UNSTABLE_DO_NOT_USE_BRANCH,\n },\n fetchFn,\n objectSetFactory,\n );\n\n return createClientFromContext(clientCtx);\n}\n\n/**\n * @internal\n */\nexport function createClientFromContext(clientCtx: MinimalClient) {\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 | Experiment<\"2.8.0\">\n | Experiment<\"2.19.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\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">\n | Experiment<\"2.8.0\">\n | Experiment<\"2.19.0\"> ? { invoke: ExperimentFns<T> }\n : never\n {\n if (o.type === \"object\" || o.type === \"interface\") {\n return clientCtx.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__executeStreamingFunction.name:\n return {\n async *executeStreamingFunction(\n query: QueryDefinition<any>,\n params?: Record<string, any>,\n ) {\n const { applyStreamingQuery } = await import(\n \"./queries/applyStreamingQuery.js\"\n );\n yield* applyStreamingQuery(clientCtx, query, params);\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks.name:\n return {\n async *getBulkLinks(\n objs: Array<OsdkBase<any>>,\n linkTypes: string[],\n ) {\n const { createBulkLinksAsyncIterFactory } = await import(\n \"./__unstable/createBulkLinksAsyncIterFactory.js\"\n );\n yield* createBulkLinksAsyncIterFactory(clientCtx)(\n objs,\n linkTypes,\n );\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:\n return {\n fetchOneByRid: async <\n Q extends ObjectOrInterfaceDefinition,\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 PropertyKeys.Filtered<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 const { upload } = await import(\n \"@osdk/foundry.ontologies/MediaReferenceProperty\"\n );\n return await 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 case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid.name:\n return {\n fetchPageByRid: async <\n Q extends ObjectOrInterfaceDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n const T extends boolean = false,\n const PROPERTY_SECURITIES extends boolean = false,\n >(\n objectOrInterfaceType: Q,\n rids: string[],\n options: FetchPageArgs<\n Q,\n L,\n R,\n any,\n S,\n T,\n never,\n {},\n PROPERTY_SECURITIES\n > = {},\n ) => {\n return await fetchPage(\n clientCtx,\n objectOrInterfaceType,\n options,\n createWithRid(rids),\n );\n },\n fetchPageByRidNoType: async <\n const R extends boolean,\n const S extends NullabilityAdherence,\n const T extends boolean,\n const PROPERTY_SECURITIES extends boolean = false,\n >(\n rids: readonly string[],\n options?: FetchPageArgs<\n ObjectOrInterfaceDefinition,\n any,\n R,\n any,\n S,\n T,\n never,\n {},\n PROPERTY_SECURITIES\n >,\n ) => {\n return await fetchStaticRidPage(\n clientCtx,\n rids,\n options ?? {},\n );\n },\n } as any;\n\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet\n .name:\n return {\n subscribeToNoTypeObjectSet: <R extends boolean = false>(\n rid: string,\n listener: ObjectSetSubscription.Listener<\n ObjectOrInterfaceDefinition,\n never,\n R\n >,\n opts?: { includeRid?: R },\n ) => {\n const unsubscribe = ObjectSetListenerWebsocket\n .getInstance(clientCtx)\n .subscribeWithoutType(\n { type: \"reference\", reference: rid },\n listener as ObjectSetSubscription.Listener<\n ObjectOrInterfaceDefinition,\n never\n >,\n opts?.includeRid ?? false,\n );\n return { unsubscribe };\n },\n } as any;\n\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__transformAndWait.name:\n return {\n transformAndWait: async (args: {\n mediaReference: MediaReference;\n transformation: MediaTransformation;\n options?: TransformOptions;\n }) => {\n const { transformAndWaitInternal } = await import(\n \"./util/transformAndWaitInternal.js\"\n );\n const { mediaSetRid, mediaItemRid, token } =\n args.mediaReference.reference.mediaSetViewItem;\n return transformAndWaitInternal(\n clientCtx,\n mediaSetRid,\n mediaItemRid,\n makeMediaTransformation(args.transformation),\n token,\n args.options,\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\n/**\n * Creates a {@link Client} for interacting with a Foundry Ontology. This is the primary entry point for\n * the OSDK and is typically called once per application during setup. The returned client is then used\n * to load object sets, apply actions, and execute queries against the configured ontology.\n * @param baseUrl - The base URL of the Foundry stack (e.g. `\"https://example.palantirfoundry.com\"`).\n * @param ontologyRid - The ontology RID to scope the client to. May be provided directly or as a `Promise`\n * that resolves to the RID. Typically the generated `$ontologyRid` export from your generated SDK is passed here.\n * @param tokenProvider - A function returning a `Promise` that resolves to a bearer token used to authenticate\n * requests. Typically the OAuth client returned by `createPublicOauthClient` or `createConfidentialOauthClient`\n * from `@osdk/oauth`, which handles caching and refresh; you can also provide a custom function if you\n * manage tokens yourself.\n * @param options - Optional client configuration: a custom `logger`, an experimental `UNSTABLE_DO_NOT_USE_BRANCH`\n * for branch-aware requests, and additional `headers` to include on every request.\n * @param fetchFn - An optional `fetch` implementation to use for all requests. Defaults to the global `fetch`.\n * @example\n * ```ts\n * import { createClient, type Client } from \"@osdk/client\";\n * import { createPublicOauthClient } from \"@osdk/oauth\";\n * import { $ontologyRid } from \"./generatedNoCheck/index.js\";\n *\n * const auth = createPublicOauthClient(\n * \"<your-client-id>\",\n * \"https://example.palantirfoundry.com\",\n * `${window.location.origin}/auth/callback`,\n * );\n *\n * export const client: Client = createClient(\n * \"https://example.palantirfoundry.com\",\n * $ontologyRid,\n * auth,\n * );\n * ```\n * @returns a {@link Client} configured to talk to the given Foundry stack and ontology\n */\nexport const createClient: (\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options?: {\n logger?: Logger;\n /** @beta This is an experimental feature subject to change */\n UNSTABLE_DO_NOT_USE_BRANCH?: string;\n headers?: Record<string, string>;\n } | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n undefined,\n undefined,\n);\n\nexport const createClientWithTransaction: (\n transactionId: string,\n flushEdits: () => Promise<void>,\n ...args: Parameters<typeof createClient>\n) => Client = (transactionRid, flushEdits, ...args) =>\n createClientInternal(\n createObjectSet,\n transactionRid,\n flushEdits,\n ...args,\n ) as Client;\n\nfunction createWithRid(\n rids: string[],\n) {\n const withRid: WireObjectSet = {\n type: \"static\",\n \"objects\": rids,\n };\n\n return withRid;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA,SACEA,uDAAuD,EACvDC,2DAA2D,EAC3DC,gDAAgD,EAChDC,iDAAiD,EACjDC,+CAA+C,EAC/CC,6DAA6D,EAC7DC,mDAAmD,QAC9C,oBAAoB;AAE3B,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AAEnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAqB,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAC1D,SAASC,uBAAuB,QAAQ,mDAAmD;AAC3F,SAASC,aAAa,QAAQ,2BAA2B;AAEzD,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,uBAAuB;AACrE,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,QAAQ,gCAAgC;AAEhE,SAASC,0BAA0B,QAAQ,2CAA2C;AACtF,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,CAACf,WAAW,GAAGA,WAAW,CAACgB,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;IACpE,IAAI,CAACG,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A;AACA;AACA;AACA;AACA,OAAO,MAAMgD,YAWF,GAAGnE,oBAAoB,CAACN,IAAI,CACrCC,SAAS,EACTR,eAAe,EACfQ,SAAS,EACTA,SACF,CAAC;AAED,OAAO,MAAMyE,2BAIF,GAAGA,CAAClE,cAAc,EAAEC,UAAU,EAAE,GAAGmC,IAAI,KAChDtC,oBAAoB,CAClBb,eAAe,EACfe,cAAc,EACdC,UAAU,EACV,GAAGmC,IACL,CAAW;AAEb,SAASF,aAAaA,CACpBY,IAAc,EACd;EAMA,OAL+B;IAC7BzB,IAAI,EAAE,QAAQ;IACd,SAAS,EAAEyB;EACb,CAAC;AAGH","ignoreList":[]}
1
+ {"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference","__EXPERIMENTAL__NOT_SUPPORTED_YET__executeStreamingFunction","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","__EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet","__EXPERIMENTAL__NOT_SUPPORTED_YET__transformAndWait","symbolClientContext","oldSymbolClientContext","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","makeMediaTransformation","MinimalLogger","fetchPage","fetchStaticRidPage","fetchSingle","createObjectSet","ObjectSetListenerWebsocket","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","transactionRid","flushEdits","scenarioRid","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","logger","transactionId","branch","UNSTABLE_DO_NOT_USE_BRANCH","createClientFromContext","fetchMetadata","client","Object","defineProperties","o","type","name","executeStreamingFunction","query","params","applyStreamingQuery","getBulkLinks","objs","linkTypes","createBulkLinksAsyncIterFactory","fetchOneByRid","objectType","rid","createWithRid","createMediaReference","args","data","fileName","propertyType","upload","apiName","mediaItemPath","preview","fetchPageByRid","objectOrInterfaceType","rids","fetchPageByRidNoType","subscribeToNoTypeObjectSet","listener","opts","unsubscribe","getInstance","subscribeWithoutType","reference","includeRid","transformAndWait","transformAndWaitInternal","mediaSetRid","mediaItemRid","token","mediaReference","mediaSetViewItem","transformation","value","createClient","createClientWithTransaction","createClientWithScenario"],"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 FetchPageArgs,\n InterfaceDefinition,\n Logger,\n MediaReference,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectSetSubscription,\n ObjectTypeDefinition,\n Osdk,\n OsdkBase,\n PropertyKeys,\n QueryDefinition,\n SelectArg,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MediaTransformation,\n MinimalObjectSet,\n TransformOptions,\n} from \"@osdk/api/unstable\";\nimport {\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__executeStreamingFunction,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__transformAndWait,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\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 { makeMediaTransformation } from \"./internal/conversions/makeMediaTransformation.js\";\nimport { MinimalLogger } from \"./logger/MinimalLogger.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { fetchPage, fetchStaticRidPage } from \"./object/fetchPage.js\";\nimport { fetchSingle } from \"./object/fetchSingle.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport { ObjectSetListenerWebsocket } from \"./objectSet/ObjectSetListenerWebsocket.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>,\n transactionRid: string | undefined,\n flushEdits: (() => Promise<void>) | undefined,\n scenarioRid: string | undefined,\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options:\n | {\n logger?: Logger;\n UNSTABLE_DO_NOT_USE_BRANCH?: string;\n headers?: Record<string, string>;\n }\n | 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 {\n ...options,\n logger: options?.logger ?? new MinimalLogger(),\n transactionId: transactionRid,\n flushEdits,\n scenarioRid,\n branch: options?.UNSTABLE_DO_NOT_USE_BRANCH,\n },\n fetchFn,\n objectSetFactory,\n );\n\n return createClientFromContext(clientCtx);\n}\n\n/**\n * @internal\n */\nexport function createClientFromContext(clientCtx: MinimalClient) {\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 | Experiment<\"2.8.0\">\n | Experiment<\"2.19.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\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">\n | Experiment<\"2.8.0\">\n | Experiment<\"2.19.0\"> ? { invoke: ExperimentFns<T> }\n : never\n {\n if (o.type === \"object\" || o.type === \"interface\") {\n return clientCtx.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__executeStreamingFunction.name:\n return {\n async *executeStreamingFunction(\n query: QueryDefinition<any>,\n params?: Record<string, any>,\n ) {\n const { applyStreamingQuery } = await import(\n \"./queries/applyStreamingQuery.js\"\n );\n yield* applyStreamingQuery(clientCtx, query, params);\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks.name:\n return {\n async *getBulkLinks(\n objs: Array<OsdkBase<any>>,\n linkTypes: string[],\n ) {\n const { createBulkLinksAsyncIterFactory } = await import(\n \"./__unstable/createBulkLinksAsyncIterFactory.js\"\n );\n yield* createBulkLinksAsyncIterFactory(clientCtx)(\n objs,\n linkTypes,\n );\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:\n return {\n fetchOneByRid: async <\n Q extends ObjectOrInterfaceDefinition,\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 PropertyKeys.Filtered<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 const { upload } = await import(\n \"@osdk/foundry.ontologies/MediaReferenceProperty\"\n );\n return await 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 case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid.name:\n return {\n fetchPageByRid: async <\n Q extends ObjectOrInterfaceDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n const T extends boolean = false,\n const PROPERTY_SECURITIES extends boolean = false,\n >(\n objectOrInterfaceType: Q,\n rids: string[],\n options: FetchPageArgs<\n Q,\n L,\n R,\n any,\n S,\n T,\n never,\n {},\n PROPERTY_SECURITIES\n > = {},\n ) => {\n return await fetchPage(\n clientCtx,\n objectOrInterfaceType,\n options,\n createWithRid(rids),\n );\n },\n fetchPageByRidNoType: async <\n const R extends boolean,\n const S extends NullabilityAdherence,\n const T extends boolean,\n const PROPERTY_SECURITIES extends boolean = false,\n >(\n rids: readonly string[],\n options?: FetchPageArgs<\n ObjectOrInterfaceDefinition,\n any,\n R,\n any,\n S,\n T,\n never,\n {},\n PROPERTY_SECURITIES\n >,\n ) => {\n return await fetchStaticRidPage(\n clientCtx,\n rids,\n options ?? {},\n );\n },\n } as any;\n\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet\n .name:\n return {\n subscribeToNoTypeObjectSet: <R extends boolean = false>(\n rid: string,\n listener: ObjectSetSubscription.Listener<\n ObjectOrInterfaceDefinition,\n never,\n R\n >,\n opts?: { includeRid?: R },\n ) => {\n const unsubscribe = ObjectSetListenerWebsocket\n .getInstance(clientCtx)\n .subscribeWithoutType(\n { type: \"reference\", reference: rid },\n listener as ObjectSetSubscription.Listener<\n ObjectOrInterfaceDefinition,\n never\n >,\n opts?.includeRid ?? false,\n );\n return { unsubscribe };\n },\n } as any;\n\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__transformAndWait.name:\n return {\n transformAndWait: async (args: {\n mediaReference: MediaReference;\n transformation: MediaTransformation;\n options?: TransformOptions;\n }) => {\n const { transformAndWaitInternal } = await import(\n \"./util/transformAndWaitInternal.js\"\n );\n const { mediaSetRid, mediaItemRid, token } =\n args.mediaReference.reference.mediaSetViewItem;\n return transformAndWaitInternal(\n clientCtx,\n mediaSetRid,\n mediaItemRid,\n makeMediaTransformation(args.transformation),\n token,\n args.options,\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\n/**\n * Creates a {@link Client} for interacting with a Foundry Ontology. This is the primary entry point for\n * the OSDK and is typically called once per application during setup. The returned client is then used\n * to load object sets, apply actions, and execute queries against the configured ontology.\n * @param baseUrl - The base URL of the Foundry stack (e.g. `\"https://example.palantirfoundry.com\"`).\n * @param ontologyRid - The ontology RID to scope the client to. May be provided directly or as a `Promise`\n * that resolves to the RID. Typically the generated `$ontologyRid` export from your generated SDK is passed here.\n * @param tokenProvider - A function returning a `Promise` that resolves to a bearer token used to authenticate\n * requests. Typically the OAuth client returned by `createPublicOauthClient` or `createConfidentialOauthClient`\n * from `@osdk/oauth`, which handles caching and refresh; you can also provide a custom function if you\n * manage tokens yourself.\n * @param options - Optional client configuration: a custom `logger`, an experimental `UNSTABLE_DO_NOT_USE_BRANCH`\n * for branch-aware requests, and additional `headers` to include on every request.\n * @param fetchFn - An optional `fetch` implementation to use for all requests. Defaults to the global `fetch`.\n * @example\n * ```ts\n * import { createClient, type Client } from \"@osdk/client\";\n * import { createPublicOauthClient } from \"@osdk/oauth\";\n * import { $ontologyRid } from \"./generatedNoCheck/index.js\";\n *\n * const auth = createPublicOauthClient(\n * \"<your-client-id>\",\n * \"https://example.palantirfoundry.com\",\n * `${window.location.origin}/auth/callback`,\n * );\n *\n * export const client: Client = createClient(\n * \"https://example.palantirfoundry.com\",\n * $ontologyRid,\n * auth,\n * );\n * ```\n * @returns a {@link Client} configured to talk to the given Foundry stack and ontology\n */\nexport const createClient: (\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options?: {\n logger?: Logger;\n /** @beta This is an experimental feature subject to change */\n UNSTABLE_DO_NOT_USE_BRANCH?: string;\n headers?: Record<string, string>;\n } | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n undefined,\n undefined,\n undefined,\n);\n\nexport const createClientWithTransaction: (\n transactionId: string,\n flushEdits: () => Promise<void>,\n ...args: Parameters<typeof createClient>\n) => Client = (transactionRid, flushEdits, ...args) =>\n createClientInternal(\n createObjectSet,\n transactionRid,\n flushEdits,\n undefined,\n ...args,\n ) as Client;\n\n/** @internal */\nexport const createClientWithScenario: (\n scenarioRid: string,\n ...args: Parameters<typeof createClient>\n) => Client = (scenarioRid, ...args) =>\n createClientInternal(\n createObjectSet,\n undefined,\n undefined,\n scenarioRid,\n ...args,\n ) as Client;\n\nfunction createWithRid(\n rids: string[],\n) {\n const withRid: WireObjectSet = {\n type: \"static\",\n \"objects\": rids,\n };\n\n return withRid;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA0BA,SACEA,uDAAuD,EACvDC,2DAA2D,EAC3DC,gDAAgD,EAChDC,iDAAiD,EACjDC,+CAA+C,EAC/CC,6DAA6D,EAC7DC,mDAAmD,QAC9C,oBAAoB;AAE3B,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AAEnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAqB,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAC1D,SAASC,uBAAuB,QAAQ,mDAAmD;AAC3F,SAASC,aAAa,QAAQ,2BAA2B;AAEzD,SAASC,SAAS,EAAEC,kBAAkB,QAAQ,uBAAuB;AACrE,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,QAAQ,gCAAgC;AAEhE,SAASC,0BAA0B,QAAQ,2CAA2C;AACtF,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,CAACf,WAAW,GAAGA,WAAW,CAACgB,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;IACpE,IAAI,CAACG,gBAAgB,GAAGlB,WAAW,CAACgB,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;EAC3E;AAIF;AAEA,MAAMI,YAAY,CAElB;EACEN,WAAWA,CACTC,SAAwB,EACxBM,QAA8B,EAC9B;IACA,IAAI,CAACC,eAAe,GAAGV,UAAU,CAACK,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEM,QAAQ,C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,oBAAoB,CAClBb,eAAe,EACfe,cAAc,EACdC,UAAU,EACVR,SAAS,EACT,GAAG4C,IACL,CAAW;;AAEb;AACA,OAAO,MAAM+B,wBAGF,GAAGA,CAAClE,WAAW,EAAE,GAAGmC,IAAI,KACjCvC,oBAAoB,CAClBb,eAAe,EACfQ,SAAS,EACTA,SAAS,EACTS,WAAW,EACX,GAAGmC,IACL,CAAW;AAEb,SAASF,aAAaA,CACpBY,IAAc,EACd;EAMA,OAL+B;IAC7BzB,IAAI,EAAE,QAAQ;IACd,SAAS,EAAEyB;EACb,CAAC;AAGH","ignoreList":[]}
@@ -30,6 +30,15 @@ export function createMinimalClient(metadata, baseUrl, tokenProvider, options =
30
30
  throw new Error(`Invalid stack URL: ${baseUrl}${hint}`);
31
31
  }
32
32
  }
33
+ const originalFetchFn = fetchFn;
34
+ fetchFn = async (input, init) => {
35
+ const url = new URL(typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url);
36
+ if (/\/scenarios(\/|$)/.test(url.pathname) && !url.searchParams.has("preview")) {
37
+ url.searchParams.set("preview", "true");
38
+ return originalFetchFn(url, init);
39
+ }
40
+ return originalFetchFn(input, init);
41
+ };
33
42
  const minimalClient = {
34
43
  ...createSharedClientContext(baseUrl, tokenProvider, USER_AGENT, fetchFn, options.headers),
35
44
  objectSetFactory,
@@ -37,6 +46,7 @@ export function createMinimalClient(metadata, baseUrl, tokenProvider, options =
37
46
  ontologyRid: metadata.ontologyRid,
38
47
  logger: options.logger,
39
48
  transactionId: options.transactionId,
49
+ scenarioRid: options.scenarioRid,
40
50
  clientCacheKey: {},
41
51
  requestContext: {},
42
52
  branch: options.branch,