@osdk/client 2.35.0 → 2.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/browser/Client.js +1 -1
  3. package/build/browser/Client.js.map +1 -1
  4. package/build/browser/scenarios/ScenarioClient.js +5 -3
  5. package/build/browser/scenarios/ScenarioClient.js.map +1 -1
  6. package/build/browser/scenarios/createScenario.js +3 -5
  7. package/build/browser/scenarios/createScenario.js.map +1 -1
  8. package/build/browser/scenarios/withScenario.js +2 -1
  9. package/build/browser/scenarios/withScenario.js.map +1 -1
  10. package/build/browser/util/UserAgent.js +2 -2
  11. package/build/cjs/{applyStreamingQuery-IWZCZA6J.cjs → applyStreamingQuery-RK2N6TJ5.cjs} +9 -9
  12. package/build/cjs/{applyStreamingQuery-IWZCZA6J.cjs.map → applyStreamingQuery-RK2N6TJ5.cjs.map} +1 -1
  13. package/build/cjs/{chunk-A4LQCGPA.cjs → chunk-53ODHT6J.cjs} +47 -47
  14. package/build/cjs/{chunk-A4LQCGPA.cjs.map → chunk-53ODHT6J.cjs.map} +1 -1
  15. package/build/cjs/{chunk-CWBZEZQC.cjs → chunk-QUF62D2S.cjs} +76 -76
  16. package/build/cjs/{chunk-CWBZEZQC.cjs.map → chunk-QUF62D2S.cjs.map} +1 -1
  17. package/build/cjs/{chunk-LWT7AZZD.cjs → chunk-VD4QAB27.cjs} +13 -13
  18. package/build/cjs/{chunk-LWT7AZZD.cjs.map → chunk-VD4QAB27.cjs.map} +1 -1
  19. package/build/cjs/{chunk-ZLUXOM2B.cjs → chunk-ZSQBDK7L.cjs} +2 -2
  20. package/build/cjs/{chunk-ZLUXOM2B.cjs.map → chunk-ZSQBDK7L.cjs.map} +1 -1
  21. package/build/cjs/index.cjs +11 -11
  22. package/build/cjs/public/experimental.cjs +6 -6
  23. package/build/cjs/public/internal.cjs +7 -7
  24. package/build/cjs/public/observable.cjs +5 -5
  25. package/build/cjs/public/unstable-do-not-use.cjs +14 -17
  26. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  27. package/build/cjs/public/unstable-do-not-use.d.cts +5 -3
  28. package/build/esm/Client.js +1 -1
  29. package/build/esm/Client.js.map +1 -1
  30. package/build/esm/scenarios/ScenarioClient.js +5 -3
  31. package/build/esm/scenarios/ScenarioClient.js.map +1 -1
  32. package/build/esm/scenarios/createScenario.js +3 -5
  33. package/build/esm/scenarios/createScenario.js.map +1 -1
  34. package/build/esm/scenarios/withScenario.js +2 -1
  35. package/build/esm/scenarios/withScenario.js.map +1 -1
  36. package/build/esm/util/UserAgent.js +2 -2
  37. package/build/types/Client.d.ts +1 -1
  38. package/build/types/scenarios/createScenario.d.ts +3 -2
  39. package/build/types/scenarios/createScenario.d.ts.map +1 -1
  40. package/build/types/scenarios/withScenario.d.ts +2 -1
  41. package/build/types/scenarios/withScenario.d.ts.map +1 -1
  42. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @osdk/client
2
2
 
3
+ ## 2.36.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 83d2603: withScenario / createScenario now ignore an active transaction on the supplied client (logging a console.warn and scoping to the scenario) instead of throwing.
8
+
9
+ ### Patch Changes
10
+
11
+ - @osdk/api@2.36.0
12
+ - @osdk/client.unstable@2.36.0
13
+ - @osdk/generator-converters@2.36.0
14
+
3
15
  ## 2.35.0
4
16
 
5
17
  ### Patch Changes
@@ -21,7 +21,7 @@
21
21
  export const additionalContext = Symbol("additionalContext");
22
22
 
23
23
  // BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.
24
- const MaxOsdkVersion = "2.35.0";
24
+ const MaxOsdkVersion = "2.36.0";
25
25
  // END: THIS IS GENERATED CODE. DO NOT EDIT.
26
26
 
27
27
  const ErrorMessage = Symbol("ErrorMessage");
@@ -1 +1 @@
1
- {"version":3,"file":"Client.js","names":["additionalContext","Symbol","MaxOsdkVersion","ErrorMessage"],"sources":["Client.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionMetadata,\n CompileTimeMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n QueryDefinition,\n QueryMetadata,\n VersionBound,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport type { SharedClient } from \"@osdk/shared.client2\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\nimport type { SatisfiesSemver } from \"./SatisfiesSemver.js\";\n\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\ntype OldSharedClient = import(\"@osdk/shared.client\").SharedClient;\n\nexport type CheckVersionBound<Q> = Q extends VersionBound<infer V> ? (\n SatisfiesSemver<V, MaxOsdkVersion> extends true ? Q\n : Q & {\n [ErrorMessage]:\n `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\n }\n )\n : Q;\n\nexport interface Client extends SharedClient, OldSharedClient {\n /**\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.35.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.36.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":[]}
@@ -53,8 +53,9 @@ export function isScenarioClient(value) {
53
53
  }
54
54
 
55
55
  /**
56
- * Shared internal builder used by both {@link withScenario} and {@link createScenario}. Validates the parent client
57
- * is not already inside a scenario or transaction, then constructs a fresh {@link Client} via
56
+ * Shared internal builder used by both {@link withScenario} and {@link createScenario}. Throws if the parent client
57
+ * is already inside a scenario. If the parent client has an active transaction, the transaction is ignored (a warning
58
+ * is logged) and the client is scoped to the scenario instead. Constructs a fresh {@link Client} via
58
59
  * `createClientWithScenario` and decorates it with {@link EXPERIMENTAL_ScenarioClient}-only methods.
59
60
  *
60
61
  * @internal
@@ -62,7 +63,8 @@ export function isScenarioClient(value) {
62
63
  export function buildScenarioClient(parent, scenarioRid) {
63
64
  const ctx = parent[additionalContext];
64
65
  if (ctx.transactionId != null) {
65
- throw new Error("withScenario / createScenario: the supplied client already has an active transaction. Scenarios cannot be nested on transactions.");
66
+ // eslint-disable-next-line no-console
67
+ console.warn("withScenario / createScenario: the supplied client has an active transaction. Ignoring the transaction and scoping to the scenario instead.");
66
68
  }
67
69
  if (ctx.scenarioRid != null) {
68
70
  throw new Error("withScenario / createScenario: the supplied client already has an active scenario. Scenarios cannot be nested.");
@@ -1 +1 @@
1
- {"version":3,"file":"ScenarioClient.js","names":["OntologyScenarios","additionalContext","createClientWithScenario","isScenarioClient","value","getScenarioReference","buildScenarioClient","parent","scenarioRid","ctx","transactionId","Error","inner","baseUrl","ontologyRid","tokenProvider","logger","UNSTABLE_DO_NOT_USE_BRANCH","branch","fetch","innerCtx","getEditedEntities","objectType","options","response","listScenarioEditedObjects","apiName","pageSize","pageToken","preview","data","map","entry","wire","$apiName","__apiName","$primaryKey","__primaryKey","nextPageToken","getEditedLinks","sourceObjectType","linkType","listScenarioEditedLinks","sourceWire","sourceObject","source","linked","linkedObjects","targetWire","targetObject","target","push","Object","defineProperties","getEditedEntityTypes","listScenarioEditedEntityTypes","objectTypes","linkTypes","editedEntitiesAsyncIter","seen","Set","page","obj","key","has","add","getEditedLinkTypes","listScenarioEditedLinkTypes","editedLinksAsyncIter","link"],"sources":["ScenarioClient.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n LinkTypeApiNamesFor,\n MinimalDirectedObjectLinkInstance,\n ObjectIdentifiers,\n ObjectOrInterfaceDefinition,\n ObjectTypeDefinition,\n PrimaryKeyType,\n} from \"@osdk/api\";\nimport { OntologyScenarios } from \"@osdk/foundry.ontologies\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientWithScenario } from \"../createClient.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\n/**\n * The set of many-to-many link types modified within a scenario for one source object type. Returned as part of\n * {@link ScenarioEditedEntityTypes.linkTypes}.\n */\nexport interface EditedLinksForObjectType {\n objectTypeApiName: string;\n linkTypes: string[];\n}\n\n/**\n * The object types and link types that have been modified within a scenario. Only many-to-many link type edits are\n * surfaced via `linkTypes`; one-to-many edits surface as object edits on the object type that owns the foreign key\n * property.\n */\nexport interface ScenarioEditedEntityTypes {\n objectTypes: string[];\n linkTypes: EditedLinksForObjectType[];\n}\n\n/**\n * A page of edited object identifiers within a scenario for a given object type. Returned by\n * {@link EXPERIMENTAL_ScenarioClient.getEditedEntities}. To load full property values, pass the primary keys back\n * through the scenario client, e.g.\n * `scenario(MyObject).where({ $primaryKey: { $in: keys } }).fetchPage()`.\n */\nexport interface EditedEntitiesPage<Q extends ObjectTypeDefinition> {\n data: ObjectIdentifiers<Q>[];\n nextPageToken?: string;\n}\n\n/**\n * A page of directed link instances edited within a scenario for a given source object type and link api name.\n * Returned by {@link EXPERIMENTAL_ScenarioClient.getEditedLinks}. Source and target carry only `$primaryKey` + `$apiName`.\n */\nexport interface EditedLinksPage<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n> {\n data: MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[];\n nextPageToken?: string;\n}\n\n/**\n * A {@link Client} attached to an ontology scenario. All read and write operations performed via this client are\n * scoped to that scenario. `EXPERIMENTAL_ScenarioClient` is a superset of {@link Client}.\n *\n * @beta This is an experimental, unstable feature subject to change.\n */\nexport interface EXPERIMENTAL_ScenarioClient extends Client {\n /**\n * The scenario RID this client is scoped to.\n */\n getScenarioReference(): string;\n\n /**\n * List the object types and many-to-many link types that have been modified within this scenario. Useful as a\n * pre-step before paginating individual edited objects per type.\n */\n getEditedEntityTypes(): Promise<ScenarioEditedEntityTypes>;\n\n /**\n * Get a page of object identifiers that have been\n * edited within this scenario for the given object type. Use the scenario client to fetch full property values\n * if needed.\n *\n * @example\n * ```ts\n * let pageToken: string | undefined;\n * const keys: string[] = [];\n * do {\n * const page = await scenario.getEditedEntities(Doctor, { pageSize: 500, pageToken });\n * keys.push(...page.data.map(o => o.$primaryKey));\n * pageToken = page.nextPageToken;\n * } while (pageToken);\n * ```\n */\n getEditedEntities<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedEntitiesPage<Q>>;\n\n /**\n * Stream object identifiers for the objects edited within this scenario for the\n * given object type. Pages are fetched lazily and deduplicated by `$primaryKey` across pages (Funnel may return\n * duplicates).\n *\n * @example\n * ```ts\n * for await (const obj of scenario.editedEntitiesAsyncIter(Doctor, { pageSize: 500 })) {\n * // obj.$primaryKey is the unique key for this edited object\n * }\n * ```\n */\n editedEntitiesAsyncIter<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<ObjectIdentifiers<Q>>;\n\n /**\n * List the outgoing many-to-many link API names that have been modified within this scenario for the given\n * source object type. One-to-many link edits surface as object edits on the FK-owning side and are not returned\n * here.\n */\n getEditedLinkTypes<Q extends ObjectOrInterfaceDefinition>(\n sourceObjectType: Q,\n ): Promise<LinkTypeApiNamesFor<Q>[]>;\n\n /**\n * Get a page of directed link instances edited within this scenario for a given source object type and link\n * api name. The page form returns a flattened array of `{ source, target, linkType }` triples.\n */\n getEditedLinks<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedLinksPage<Q, LINK_TYPE_API_NAME>>;\n\n /**\n * Stream directed link instances edited within this scenario for a given source object type and link api name.\n * Pages are fetched lazily.\n *\n * @example\n * ```ts\n * for await (\n * const { source, target, linkType } of scenario.editedLinksAsyncIter(Doctor, \"treats\")\n * ) {\n * graph.addEdge(source, target, linkType);\n * }\n * ```\n */\n editedLinksAsyncIter<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<\n MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>\n >;\n}\n\nexport function isScenarioClient(\n value: unknown,\n): value is EXPERIMENTAL_ScenarioClient {\n return (\n value != null\n && (typeof value === \"object\" || typeof value === \"function\")\n && typeof (value as { getScenarioReference?: unknown })\n .getScenarioReference === \"function\"\n );\n}\n\n/**\n * Shared internal builder used by both {@link withScenario} and {@link createScenario}. Validates the parent client\n * is not already inside a scenario or transaction, then constructs a fresh {@link Client} via\n * `createClientWithScenario` and decorates it with {@link EXPERIMENTAL_ScenarioClient}-only methods.\n *\n * @internal\n */\nexport function buildScenarioClient(\n parent: Client,\n scenarioRid: string,\n): EXPERIMENTAL_ScenarioClient {\n const ctx: MinimalClient = parent[additionalContext];\n\n if (ctx.transactionId != null) {\n throw new Error(\n \"withScenario / createScenario: the supplied client already has an active transaction. Scenarios cannot be nested on transactions.\",\n );\n }\n if (ctx.scenarioRid != null) {\n throw new Error(\n \"withScenario / createScenario: the supplied client already has an active scenario. Scenarios cannot be nested.\",\n );\n }\n\n const inner: Client = createClientWithScenario(\n scenarioRid,\n ctx.baseUrl,\n ctx.ontologyRid,\n ctx.tokenProvider,\n {\n logger: ctx.logger,\n UNSTABLE_DO_NOT_USE_BRANCH: ctx.branch,\n },\n ctx.fetch,\n );\n\n const innerCtx: MinimalClient = inner[additionalContext];\n\n async function getEditedEntityTypes(): Promise<ScenarioEditedEntityTypes> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedEntityTypes(\n innerCtx,\n ontologyRid,\n scenarioRid,\n { preview: true },\n );\n return {\n objectTypes: response.objectTypes,\n linkTypes: response.linkTypes,\n };\n }\n\n async function getEditedEntities<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedEntitiesPage<Q>> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedObjects(\n innerCtx,\n ontologyRid,\n scenarioRid,\n objectType.apiName,\n {\n pageSize: options?.pageSize,\n pageToken: options?.pageToken,\n preview: true,\n },\n );\n const data: ObjectIdentifiers<Q>[] = response.data.map((entry) => {\n const wire = entry as { __apiName?: unknown; __primaryKey?: unknown };\n return {\n $apiName: wire.__apiName as Q[\"apiName\"],\n $primaryKey: wire.__primaryKey as PrimaryKeyType<Q>,\n };\n });\n return {\n data,\n nextPageToken: response.nextPageToken,\n };\n }\n\n async function* editedEntitiesAsyncIter<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<ObjectIdentifiers<Q>> {\n const seen = new Set<unknown>();\n let pageToken: string | undefined;\n do {\n const page = await getEditedEntities(objectType, {\n pageSize: options?.pageSize,\n pageToken,\n });\n for (const obj of page.data) {\n const key = obj.$primaryKey;\n if (seen.has(key)) continue;\n seen.add(key);\n yield obj;\n }\n pageToken = page.nextPageToken;\n } while (pageToken != null);\n }\n\n async function getEditedLinkTypes<Q extends ObjectOrInterfaceDefinition>(\n sourceObjectType: Q,\n ): Promise<LinkTypeApiNamesFor<Q>[]> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedLinkTypes(\n innerCtx,\n ontologyRid,\n scenarioRid,\n sourceObjectType.apiName,\n { preview: true },\n );\n return response.data as LinkTypeApiNamesFor<Q>[];\n }\n\n async function getEditedLinks<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedLinksPage<Q, LINK_TYPE_API_NAME>> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedLinks(\n innerCtx,\n ontologyRid,\n scenarioRid,\n sourceObjectType.apiName,\n linkType as string,\n {\n pageSize: options?.pageSize,\n pageToken: options?.pageToken,\n preview: true,\n },\n );\n\n const data: MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[] = [];\n for (const entry of response.data) {\n const sourceWire = entry.sourceObject as\n | { __apiName?: unknown; __primaryKey?: unknown }\n | undefined;\n if (sourceWire?.__apiName == null || sourceWire.__primaryKey == null) {\n continue;\n }\n const source = {\n $apiName: sourceWire.__apiName,\n $primaryKey: sourceWire.__primaryKey,\n } as MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[\"source\"];\n\n for (const linked of entry.linkedObjects) {\n const targetWire = linked.targetObject as\n | { __apiName?: unknown; __primaryKey?: unknown }\n | undefined;\n if (targetWire?.__apiName == null || targetWire.__primaryKey == null) {\n continue;\n }\n const target = {\n $apiName: targetWire.__apiName,\n $primaryKey: targetWire.__primaryKey,\n } as MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[\"target\"];\n\n data.push({\n source,\n target,\n linkType: ((linked.linkType as string | undefined)\n ?? linkType) as LINK_TYPE_API_NAME,\n });\n }\n }\n\n return { data, nextPageToken: response.nextPageToken };\n }\n\n async function* editedLinksAsyncIter<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<\n MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>\n > {\n let pageToken: string | undefined;\n do {\n const page = await getEditedLinks(sourceObjectType, linkType, {\n pageSize: options?.pageSize,\n pageToken,\n });\n for (const link of page.data) {\n yield link;\n }\n pageToken = page.nextPageToken;\n } while (pageToken != null);\n }\n\n return Object.defineProperties(inner, {\n getScenarioReference: {\n value: () => scenarioRid,\n },\n getEditedEntityTypes: {\n value: getEditedEntityTypes,\n },\n getEditedEntities: {\n value: getEditedEntities,\n },\n editedEntitiesAsyncIter: {\n value: editedEntitiesAsyncIter,\n },\n getEditedLinkTypes: {\n value: getEditedLinkTypes,\n },\n getEditedLinks: {\n value: getEditedLinks,\n },\n editedLinksAsyncIter: {\n value: editedLinksAsyncIter,\n },\n }) as EXPERIMENTAL_ScenarioClient;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,iBAAiB,QAAqB,cAAc;AAC7D,SAASC,wBAAwB,QAAQ,oBAAoB;;AAG7D;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AAkGA,OAAO,SAASC,gBAAgBA,CAC9BC,KAAc,EACwB;EACtC,OACEA,KAAK,IAAI,IAAI,KACT,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,UAAU,CAAC,IAC1D,OAAQA,KAAK,CACXC,oBAAoB,KAAK,UAAU;AAE5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAm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E;MAClB9D,KAAK,EA9GT,eAAAA,CACEoC,gBAAmB,EACgB;QACnC,MAAM1B,WAAW,GAAG,MAAMM,QAAQ,CAACN,WAAW;QAC9C,MAAMU,QAAQ,GAAG,MAAMxB,iBAAiB,CAACmE,2BAA2B,CAClE/C,QAAQ,EACRN,WAAW,EACXN,WAAW,EACXgC,gBAAgB,CAACd,OAAO,EACxB;UAAEG,OAAO,EAAE;QAAK,CAClB,CAAC;QACD,OAAOL,QAAQ,CAACM,IAAI;MACtB;IAmGE,CAAC;IACDS,cAAc,EAAE;MACdnC,KAAK,EAAEmC;IACT,CAAC;IACD6B,oBAAoB,EAAE;MACpBhE,KAAK,EA3CT,gBAAAA,CAIEoC,gBAAmB,EACnBC,QAA4B,EAC5BlB,OAA+B,EAG/B;QACA,IAAIK,SAA6B;QACjC,GAAG;UACD,MAAMiC,IAAI,GAAG,MAAMtB,cAAc,CAACC,gBAAgB,EAAEC,QAAQ,EAAE;YAC5Dd,QAAQ,EAAEJ,OAAO,EAAEI,QAAQ;YAC3BC;UACF,CAAC,CAAC;UACF,KAAK,MAAMyC,IAAI,IAAIR,IAAI,CAAC/B,IAAI,EAAE;YAC5B,MAAMuC,IAAI;UACZ;UACAzC,SAAS,GAAGiC,IAAI,CAACvB,aAAa;QAChC,CAAC,QAAQV,SAAS,IAAI,IAAI;MAC5B;IAuBE;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"ScenarioClient.js","names":["OntologyScenarios","additionalContext","createClientWithScenario","isScenarioClient","value","getScenarioReference","buildScenarioClient","parent","scenarioRid","ctx","transactionId","console","warn","Error","inner","baseUrl","ontologyRid","tokenProvider","logger","UNSTABLE_DO_NOT_USE_BRANCH","branch","fetch","innerCtx","getEditedEntities","objectType","options","response","listScenarioEditedObjects","apiName","pageSize","pageToken","preview","data","map","entry","wire","$apiName","__apiName","$primaryKey","__primaryKey","nextPageToken","getEditedLinks","sourceObjectType","linkType","listScenarioEditedLinks","sourceWire","sourceObject","source","linked","linkedObjects","targetWire","targetObject","target","push","Object","defineProperties","getEditedEntityTypes","listScenarioEditedEntityTypes","objectTypes","linkTypes","editedEntitiesAsyncIter","seen","Set","page","obj","key","has","add","getEditedLinkTypes","listScenarioEditedLinkTypes","editedLinksAsyncIter","link"],"sources":["ScenarioClient.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n LinkTypeApiNamesFor,\n MinimalDirectedObjectLinkInstance,\n ObjectIdentifiers,\n ObjectOrInterfaceDefinition,\n ObjectTypeDefinition,\n PrimaryKeyType,\n} from \"@osdk/api\";\nimport { OntologyScenarios } from \"@osdk/foundry.ontologies\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientWithScenario } from \"../createClient.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\n\n/**\n * The set of many-to-many link types modified within a scenario for one source object type. Returned as part of\n * {@link ScenarioEditedEntityTypes.linkTypes}.\n */\nexport interface EditedLinksForObjectType {\n objectTypeApiName: string;\n linkTypes: string[];\n}\n\n/**\n * The object types and link types that have been modified within a scenario. Only many-to-many link type edits are\n * surfaced via `linkTypes`; one-to-many edits surface as object edits on the object type that owns the foreign key\n * property.\n */\nexport interface ScenarioEditedEntityTypes {\n objectTypes: string[];\n linkTypes: EditedLinksForObjectType[];\n}\n\n/**\n * A page of edited object identifiers within a scenario for a given object type. Returned by\n * {@link EXPERIMENTAL_ScenarioClient.getEditedEntities}. To load full property values, pass the primary keys back\n * through the scenario client, e.g.\n * `scenario(MyObject).where({ $primaryKey: { $in: keys } }).fetchPage()`.\n */\nexport interface EditedEntitiesPage<Q extends ObjectTypeDefinition> {\n data: ObjectIdentifiers<Q>[];\n nextPageToken?: string;\n}\n\n/**\n * A page of directed link instances edited within a scenario for a given source object type and link api name.\n * Returned by {@link EXPERIMENTAL_ScenarioClient.getEditedLinks}. Source and target carry only `$primaryKey` + `$apiName`.\n */\nexport interface EditedLinksPage<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n> {\n data: MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[];\n nextPageToken?: string;\n}\n\n/**\n * A {@link Client} attached to an ontology scenario. All read and write operations performed via this client are\n * scoped to that scenario. `EXPERIMENTAL_ScenarioClient` is a superset of {@link Client}.\n *\n * @beta This is an experimental, unstable feature subject to change.\n */\nexport interface EXPERIMENTAL_ScenarioClient extends Client {\n /**\n * The scenario RID this client is scoped to.\n */\n getScenarioReference(): string;\n\n /**\n * List the object types and many-to-many link types that have been modified within this scenario. Useful as a\n * pre-step before paginating individual edited objects per type.\n */\n getEditedEntityTypes(): Promise<ScenarioEditedEntityTypes>;\n\n /**\n * Get a page of object identifiers that have been\n * edited within this scenario for the given object type. Use the scenario client to fetch full property values\n * if needed.\n *\n * @example\n * ```ts\n * let pageToken: string | undefined;\n * const keys: string[] = [];\n * do {\n * const page = await scenario.getEditedEntities(Doctor, { pageSize: 500, pageToken });\n * keys.push(...page.data.map(o => o.$primaryKey));\n * pageToken = page.nextPageToken;\n * } while (pageToken);\n * ```\n */\n getEditedEntities<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedEntitiesPage<Q>>;\n\n /**\n * Stream object identifiers for the objects edited within this scenario for the\n * given object type. Pages are fetched lazily and deduplicated by `$primaryKey` across pages (Funnel may return\n * duplicates).\n *\n * @example\n * ```ts\n * for await (const obj of scenario.editedEntitiesAsyncIter(Doctor, { pageSize: 500 })) {\n * // obj.$primaryKey is the unique key for this edited object\n * }\n * ```\n */\n editedEntitiesAsyncIter<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<ObjectIdentifiers<Q>>;\n\n /**\n * List the outgoing many-to-many link API names that have been modified within this scenario for the given\n * source object type. One-to-many link edits surface as object edits on the FK-owning side and are not returned\n * here.\n */\n getEditedLinkTypes<Q extends ObjectOrInterfaceDefinition>(\n sourceObjectType: Q,\n ): Promise<LinkTypeApiNamesFor<Q>[]>;\n\n /**\n * Get a page of directed link instances edited within this scenario for a given source object type and link\n * api name. The page form returns a flattened array of `{ source, target, linkType }` triples.\n */\n getEditedLinks<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedLinksPage<Q, LINK_TYPE_API_NAME>>;\n\n /**\n * Stream directed link instances edited within this scenario for a given source object type and link api name.\n * Pages are fetched lazily.\n *\n * @example\n * ```ts\n * for await (\n * const { source, target, linkType } of scenario.editedLinksAsyncIter(Doctor, \"treats\")\n * ) {\n * graph.addEdge(source, target, linkType);\n * }\n * ```\n */\n editedLinksAsyncIter<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<\n MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>\n >;\n}\n\nexport function isScenarioClient(\n value: unknown,\n): value is EXPERIMENTAL_ScenarioClient {\n return (\n value != null\n && (typeof value === \"object\" || typeof value === \"function\")\n && typeof (value as { getScenarioReference?: unknown })\n .getScenarioReference === \"function\"\n );\n}\n\n/**\n * Shared internal builder used by both {@link withScenario} and {@link createScenario}. Throws if the parent client\n * is already inside a scenario. If the parent client has an active transaction, the transaction is ignored (a warning\n * is logged) and the client is scoped to the scenario instead. Constructs a fresh {@link Client} via\n * `createClientWithScenario` and decorates it with {@link EXPERIMENTAL_ScenarioClient}-only methods.\n *\n * @internal\n */\nexport function buildScenarioClient(\n parent: Client,\n scenarioRid: string,\n): EXPERIMENTAL_ScenarioClient {\n const ctx: MinimalClient = parent[additionalContext];\n\n if (ctx.transactionId != null) {\n // eslint-disable-next-line no-console\n console.warn(\n \"withScenario / createScenario: the supplied client has an active transaction. Ignoring the transaction and scoping to the scenario instead.\",\n );\n }\n if (ctx.scenarioRid != null) {\n throw new Error(\n \"withScenario / createScenario: the supplied client already has an active scenario. Scenarios cannot be nested.\",\n );\n }\n\n const inner: Client = createClientWithScenario(\n scenarioRid,\n ctx.baseUrl,\n ctx.ontologyRid,\n ctx.tokenProvider,\n {\n logger: ctx.logger,\n UNSTABLE_DO_NOT_USE_BRANCH: ctx.branch,\n },\n ctx.fetch,\n );\n\n const innerCtx: MinimalClient = inner[additionalContext];\n\n async function getEditedEntityTypes(): Promise<ScenarioEditedEntityTypes> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedEntityTypes(\n innerCtx,\n ontologyRid,\n scenarioRid,\n { preview: true },\n );\n return {\n objectTypes: response.objectTypes,\n linkTypes: response.linkTypes,\n };\n }\n\n async function getEditedEntities<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedEntitiesPage<Q>> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedObjects(\n innerCtx,\n ontologyRid,\n scenarioRid,\n objectType.apiName,\n {\n pageSize: options?.pageSize,\n pageToken: options?.pageToken,\n preview: true,\n },\n );\n const data: ObjectIdentifiers<Q>[] = response.data.map((entry) => {\n const wire = entry as { __apiName?: unknown; __primaryKey?: unknown };\n return {\n $apiName: wire.__apiName as Q[\"apiName\"],\n $primaryKey: wire.__primaryKey as PrimaryKeyType<Q>,\n };\n });\n return {\n data,\n nextPageToken: response.nextPageToken,\n };\n }\n\n async function* editedEntitiesAsyncIter<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<ObjectIdentifiers<Q>> {\n const seen = new Set<unknown>();\n let pageToken: string | undefined;\n do {\n const page = await getEditedEntities(objectType, {\n pageSize: options?.pageSize,\n pageToken,\n });\n for (const obj of page.data) {\n const key = obj.$primaryKey;\n if (seen.has(key)) continue;\n seen.add(key);\n yield obj;\n }\n pageToken = page.nextPageToken;\n } while (pageToken != null);\n }\n\n async function getEditedLinkTypes<Q extends ObjectOrInterfaceDefinition>(\n sourceObjectType: Q,\n ): Promise<LinkTypeApiNamesFor<Q>[]> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedLinkTypes(\n innerCtx,\n ontologyRid,\n scenarioRid,\n sourceObjectType.apiName,\n { preview: true },\n );\n return response.data as LinkTypeApiNamesFor<Q>[];\n }\n\n async function getEditedLinks<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<EditedLinksPage<Q, LINK_TYPE_API_NAME>> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioEditedLinks(\n innerCtx,\n ontologyRid,\n scenarioRid,\n sourceObjectType.apiName,\n linkType as string,\n {\n pageSize: options?.pageSize,\n pageToken: options?.pageToken,\n preview: true,\n },\n );\n\n const data: MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[] = [];\n for (const entry of response.data) {\n const sourceWire = entry.sourceObject as\n | { __apiName?: unknown; __primaryKey?: unknown }\n | undefined;\n if (sourceWire?.__apiName == null || sourceWire.__primaryKey == null) {\n continue;\n }\n const source = {\n $apiName: sourceWire.__apiName,\n $primaryKey: sourceWire.__primaryKey,\n } as MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[\"source\"];\n\n for (const linked of entry.linkedObjects) {\n const targetWire = linked.targetObject as\n | { __apiName?: unknown; __primaryKey?: unknown }\n | undefined;\n if (targetWire?.__apiName == null || targetWire.__primaryKey == null) {\n continue;\n }\n const target = {\n $apiName: targetWire.__apiName,\n $primaryKey: targetWire.__primaryKey,\n } as MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>[\"target\"];\n\n data.push({\n source,\n target,\n linkType: ((linked.linkType as string | undefined)\n ?? linkType) as LINK_TYPE_API_NAME,\n });\n }\n }\n\n return { data, nextPageToken: response.nextPageToken };\n }\n\n async function* editedLinksAsyncIter<\n Q extends ObjectOrInterfaceDefinition,\n LINK_TYPE_API_NAME extends LinkTypeApiNamesFor<Q>,\n >(\n sourceObjectType: Q,\n linkType: LINK_TYPE_API_NAME,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<\n MinimalDirectedObjectLinkInstance<Q, LINK_TYPE_API_NAME>\n > {\n let pageToken: string | undefined;\n do {\n const page = await getEditedLinks(sourceObjectType, linkType, {\n pageSize: options?.pageSize,\n pageToken,\n });\n for (const link of page.data) {\n yield link;\n }\n pageToken = page.nextPageToken;\n } while (pageToken != null);\n }\n\n return Object.defineProperties(inner, {\n getScenarioReference: {\n value: () => scenarioRid,\n },\n getEditedEntityTypes: {\n value: getEditedEntityTypes,\n },\n getEditedEntities: {\n value: getEditedEntities,\n },\n editedEntitiesAsyncIter: {\n value: editedEntitiesAsyncIter,\n },\n getEditedLinkTypes: {\n value: getEditedLinkTypes,\n },\n getEditedLinks: {\n value: getEditedLinks,\n },\n editedLinksAsyncIter: {\n value: editedLinksAsyncIter,\n },\n }) as EXPERIMENTAL_ScenarioClient;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,iBAAiB,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AAI;UACZ;UACAzC,SAAS,GAAGiC,IAAI,CAACvB,aAAa;QAChC,CAAC,QAAQV,SAAS,IAAI,IAAI;MAC5B;IAuBE;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -22,8 +22,9 @@ import { buildScenarioClient } from "./ScenarioClient.js";
22
22
  * Mint a fresh ontology scenario and return a client scoped to it.
23
23
  *
24
24
  * @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)
25
- * from. Throws at runtime if the client is already scoped to a scenario or transaction. When the base client has a
26
- * branch set, the newly minted scenario uses that branch as its base.
25
+ * from. Throws at runtime if the client is already scoped to a scenario. If the client has an active transaction,
26
+ * the transaction is ignored (a warning is logged) and the client is scoped to the new scenario. When the base
27
+ * client has a branch set, the newly minted scenario uses that branch as its base.
27
28
  * @returns a {@link EXPERIMENTAL_ScenarioClient} bound to the freshly minted scenario RID.
28
29
  *
29
30
  * @beta This is an experimental, unstable feature subject to change.
@@ -38,9 +39,6 @@ import { buildScenarioClient } from "./ScenarioClient.js";
38
39
  */
39
40
  export async function createScenario(client) {
40
41
  const ctx = client[additionalContext];
41
- if (ctx.transactionId != null) {
42
- throw new Error("createScenario: the supplied client already has an active transaction. Scenarios cannot be nested on transactions.");
43
- }
44
42
  if (ctx.scenarioRid != null) {
45
43
  throw new Error("createScenario: the supplied client already has an active scenario. Scenarios cannot be nested.");
46
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createScenario.js","names":["OntologyScenarios","additionalContext","buildScenarioClient","createScenario","client","ctx","transactionId","Error","scenarioRid","response","ontologyRid","branch","base","type","preview"],"sources":["createScenario.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OntologyScenarios } from \"@osdk/foundry.ontologies\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n buildScenarioClient,\n type EXPERIMENTAL_ScenarioClient,\n} from \"./ScenarioClient.js\";\n\n/**\n * Mint a fresh ontology scenario and return a client scoped to it.\n *\n * @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)\n * from. Throws at runtime if the client is already scoped to a scenario or transaction. When the base client has a\n * branch set, the newly minted scenario uses that branch as its base.\n * @returns a {@link EXPERIMENTAL_ScenarioClient} bound to the freshly minted scenario RID.\n *\n * @beta This is an experimental, unstable feature subject to change.\n *\n * @example\n * ```ts\n * import { createScenario } from \"@osdk/client/unstable-do-not-use\";\n *\n * const scenario = await createScenario(client);\n * const scenarioRid = scenario.getScenarioReference();\n * ```\n */\nexport async function createScenario(\n client: Client,\n): Promise<EXPERIMENTAL_ScenarioClient> {\n const ctx: MinimalClient = client[additionalContext];\n\n if (ctx.transactionId != null) {\n throw new Error(\n \"createScenario: the supplied client already has an active transaction. Scenarios cannot be nested on transactions.\",\n );\n }\n if (ctx.scenarioRid != null) {\n throw new Error(\n \"createScenario: the supplied client already has an active scenario. Scenarios cannot be nested.\",\n );\n }\n\n const response = await OntologyScenarios.createScenario(\n ctx,\n await ctx.ontologyRid,\n ctx.branch != null\n ? { base: { type: \"branch\", branch: ctx.branch } }\n : {},\n { preview: true },\n );\n\n return buildScenarioClient(client, response.scenarioRid);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,iBAAiB,QAAqB,cAAc;AAE7D,SACEC,mBAAmB,QAEd,qBAAqB;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,cAAcA,CAClCC,MAAc,EACwB;EACtC,MAAMC,GAAkB,GAAGD,MAAM,CAACH,iBAAiB,CAAC;EAEpD,IAAII,GAAG,CAACC,aAAa,IAAI,IAAI,EAAE;IAC7B,MAAM,IAAIC,KAAK,CACb,oHACF,CAAC;EACH;EACA,IAAIF,GAAG,CAACG,WAAW,IAAI,IAAI,EAAE;IAC3B,MAAM,IAAID,KAAK,CACb,iGACF,CAAC;EACH;EAEA,MAAME,QAAQ,GAAG,MAAMT,iBAAiB,CAACG,cAAc,CACrDE,GAAG,EACH,MAAMA,GAAG,CAACK,WAAW,EACrBL,GAAG,CAACM,MAAM,IAAI,IAAI,GACd;IAAEC,IAAI,EAAE;MAAEC,IAAI,EAAE,QAAQ;MAAEF,MAAM,EAAEN,GAAG,CAACM;IAAO;EAAE,CAAC,GAChD,CAAC,CAAC,EACN;IAAEG,OAAO,EAAE;EAAK,CAClB,CAAC;EAED,OAAOZ,mBAAmB,CAACE,MAAM,EAAEK,QAAQ,CAACD,WAAW,CAAC;AAC1D","ignoreList":[]}
1
+ {"version":3,"file":"createScenario.js","names":["OntologyScenarios","additionalContext","buildScenarioClient","createScenario","client","ctx","scenarioRid","Error","response","ontologyRid","branch","base","type","preview"],"sources":["createScenario.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OntologyScenarios } from \"@osdk/foundry.ontologies\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport type { MinimalClient } from \"../MinimalClientContext.js\";\nimport {\n buildScenarioClient,\n type EXPERIMENTAL_ScenarioClient,\n} from \"./ScenarioClient.js\";\n\n/**\n * Mint a fresh ontology scenario and return a client scoped to it.\n *\n * @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)\n * from. Throws at runtime if the client is already scoped to a scenario. If the client has an active transaction,\n * the transaction is ignored (a warning is logged) and the client is scoped to the new scenario. When the base\n * client has a branch set, the newly minted scenario uses that branch as its base.\n * @returns a {@link EXPERIMENTAL_ScenarioClient} bound to the freshly minted scenario RID.\n *\n * @beta This is an experimental, unstable feature subject to change.\n *\n * @example\n * ```ts\n * import { createScenario } from \"@osdk/client/unstable-do-not-use\";\n *\n * const scenario = await createScenario(client);\n * const scenarioRid = scenario.getScenarioReference();\n * ```\n */\nexport async function createScenario(\n client: Client,\n): Promise<EXPERIMENTAL_ScenarioClient> {\n const ctx: MinimalClient = client[additionalContext];\n\n if (ctx.scenarioRid != null) {\n throw new Error(\n \"createScenario: the supplied client already has an active scenario. Scenarios cannot be nested.\",\n );\n }\n\n const response = await OntologyScenarios.createScenario(\n ctx,\n await ctx.ontologyRid,\n ctx.branch != null\n ? { base: { type: \"branch\", branch: ctx.branch } }\n : {},\n { preview: true },\n );\n\n return buildScenarioClient(client, response.scenarioRid);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,iBAAiB,QAAqB,cAAc;AAE7D,SACEC,mBAAmB,QAEd,qBAAqB;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,cAAcA,CAClCC,MAAc,EACwB;EACtC,MAAMC,GAAkB,GAAGD,MAAM,CAACH,iBAAiB,CAAC;EAEpD,IAAII,GAAG,CAACC,WAAW,IAAI,IAAI,EAAE;IAC3B,MAAM,IAAIC,KAAK,CACb,iGACF,CAAC;EACH;EAEA,MAAMC,QAAQ,GAAG,MAAMR,iBAAiB,CAACG,cAAc,CACrDE,GAAG,EACH,MAAMA,GAAG,CAACI,WAAW,EACrBJ,GAAG,CAACK,MAAM,IAAI,IAAI,GACd;IAAEC,IAAI,EAAE;MAAEC,IAAI,EAAE,QAAQ;MAAEF,MAAM,EAAEL,GAAG,CAACK;IAAO;EAAE,CAAC,GAChD,CAAC,CAAC,EACN;IAAEG,OAAO,EAAE;EAAK,CAClB,CAAC;EAED,OAAOX,mBAAmB,CAACE,MAAM,EAAEI,QAAQ,CAACF,WAAW,CAAC;AAC1D","ignoreList":[]}
@@ -21,7 +21,8 @@ import { buildScenarioClient } from "./ScenarioClient.js";
21
21
  * subsequent operations (`fetchPage`, `applyAction`, `executeFunction`, etc.) to the given `scenarioRid`.
22
22
  *
23
23
  * @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)
24
- * from. Throws at runtime if the client is already scoped to a scenario or transaction.
24
+ * from. Throws at runtime if the client is already scoped to a scenario. If the client has an active transaction,
25
+ * the transaction is ignored (a warning is logged) and the client is scoped to the scenario.
25
26
  * @param scenarioRid - The RID of the scenario to attach to.
26
27
  * @returns a {@link EXPERIMENTAL_ScenarioClient} bound to `scenarioRid`.
27
28
  *
@@ -1 +1 @@
1
- {"version":3,"file":"withScenario.js","names":["buildScenarioClient","withScenario","client","scenarioRid"],"sources":["withScenario.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client } from \"../Client.js\";\nimport {\n buildScenarioClient,\n type EXPERIMENTAL_ScenarioClient,\n} from \"./ScenarioClient.js\";\n\n/**\n * Attach to an existing ontology scenario. Synchronous — no network call is made. The returned client scopes all\n * subsequent operations (`fetchPage`, `applyAction`, `executeFunction`, etc.) to the given `scenarioRid`.\n *\n * @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)\n * from. Throws at runtime if the client is already scoped to a scenario or transaction.\n * @param scenarioRid - The RID of the scenario to attach to.\n * @returns a {@link EXPERIMENTAL_ScenarioClient} bound to `scenarioRid`.\n *\n * @beta This is an experimental, unstable feature subject to change.\n *\n * @example\n * ```ts\n * import { withScenario } from \"@osdk/client/unstable-do-not-use\";\n *\n * const scenario = withScenario(client, \"ri.actions..scenario.abc\");\n * const page = await scenario(Doctor).fetchPage();\n * await scenario(Schedule).applyAction({ doctor: page.data[0], shift: \"AM\" });\n * ```\n */\nexport function withScenario(\n client: Client,\n scenarioRid: string,\n): EXPERIMENTAL_ScenarioClient {\n return buildScenarioClient(client, scenarioRid);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,mBAAmB,QAEd,qBAAqB;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAC1BC,MAAc,EACdC,WAAmB,EACU;EAC7B,OAAOH,mBAAmB,CAACE,MAAM,EAAEC,WAAW,CAAC;AACjD","ignoreList":[]}
1
+ {"version":3,"file":"withScenario.js","names":["buildScenarioClient","withScenario","client","scenarioRid"],"sources":["withScenario.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client } from \"../Client.js\";\nimport {\n buildScenarioClient,\n type EXPERIMENTAL_ScenarioClient,\n} from \"./ScenarioClient.js\";\n\n/**\n * Attach to an existing ontology scenario. Synchronous — no network call is made. The returned client scopes all\n * subsequent operations (`fetchPage`, `applyAction`, `executeFunction`, etc.) to the given `scenarioRid`.\n *\n * @param client - The base {@link Client} to derive context (`baseUrl`, `ontologyRid`, `tokenProvider`, `branch`, …)\n * from. Throws at runtime if the client is already scoped to a scenario. If the client has an active transaction,\n * the transaction is ignored (a warning is logged) and the client is scoped to the scenario.\n * @param scenarioRid - The RID of the scenario to attach to.\n * @returns a {@link EXPERIMENTAL_ScenarioClient} bound to `scenarioRid`.\n *\n * @beta This is an experimental, unstable feature subject to change.\n *\n * @example\n * ```ts\n * import { withScenario } from \"@osdk/client/unstable-do-not-use\";\n *\n * const scenario = withScenario(client, \"ri.actions..scenario.abc\");\n * const page = await scenario(Doctor).fetchPage();\n * await scenario(Schedule).applyAction({ doctor: page.data[0], shift: \"AM\" });\n * ```\n */\nexport function withScenario(\n client: Client,\n scenarioRid: string,\n): EXPERIMENTAL_ScenarioClient {\n return buildScenarioClient(client, scenarioRid);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,mBAAmB,QAEd,qBAAqB;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAC1BC,MAAc,EACdC,WAAmB,EACU;EAC7B,OAAOH,mBAAmB,CAACE,MAAM,EAAEC,WAAW,CAAC;AACjD","ignoreList":[]}
@@ -14,6 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export const USER_AGENT = `osdk-client/${"2.35.0"}`;
18
- export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.35.0"}`;
17
+ export const USER_AGENT = `osdk-client/${"2.36.0"}`;
18
+ export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.36.0"}`;
19
19
  //# sourceMappingURL=UserAgent.js.map
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkLWT7AZZD_cjs = require('./chunk-LWT7AZZD.cjs');
4
- var chunkZLUXOM2B_cjs = require('./chunk-ZLUXOM2B.cjs');
3
+ var chunkVD4QAB27_cjs = require('./chunk-VD4QAB27.cjs');
4
+ var chunkZSQBDK7L_cjs = require('./chunk-ZSQBDK7L.cjs');
5
5
  require('./chunk-ROJIXXGF.cjs');
6
6
  var chunkH6PXPU6F_cjs = require('./chunk-H6PXPU6F.cjs');
7
7
  require('./chunk-Q7SFCCGT.cjs');
@@ -18,11 +18,11 @@ async function* applyStreamingQuery(client, query, params) {
18
18
  if (client.flushEdits != null) {
19
19
  await client.flushEdits();
20
20
  }
21
- const response = await streamingExecute(chunkZLUXOM2B_cjs.addUserAgentAndRequestContextHeaders(chunkZLUXOM2B_cjs.augmentRequestContext(client, (_) => ({
21
+ const response = await streamingExecute(chunkZSQBDK7L_cjs.addUserAgentAndRequestContextHeaders(chunkZSQBDK7L_cjs.augmentRequestContext(client, (_) => ({
22
22
  finalMethodCall: "applyStreamingQuery"
23
23
  })), query), query.apiName, {
24
24
  ontology: await client.ontologyRid,
25
- parameters: params ? await chunkLWT7AZZD_cjs.remapQueryParams(params, client, qd.parameters) : {},
25
+ parameters: params ? await chunkVD4QAB27_cjs.remapQueryParams(params, client, qd.parameters) : {},
26
26
  version: query.isFixedVersion ? query.version : void 0,
27
27
  branch: client.branch
28
28
  }, {
@@ -32,15 +32,15 @@ async function* applyStreamingQuery(client, query, params) {
32
32
  if (response.body == null) {
33
33
  throw new Error("streamingExecute returned no response body");
34
34
  }
35
- const definitions = await chunkLWT7AZZD_cjs.getRequiredDefinitions(qd.output, client);
35
+ const definitions = await chunkVD4QAB27_cjs.getRequiredDefinitions(qd.output, client);
36
36
  const reader = response.body.getReader();
37
- for await (const line of chunkLWT7AZZD_cjs.parseNdjsonStream(chunkLWT7AZZD_cjs.iterateReadableStream(reader))) {
37
+ for await (const line of chunkVD4QAB27_cjs.parseNdjsonStream(chunkVD4QAB27_cjs.iterateReadableStream(reader))) {
38
38
  if (line.type === "error") {
39
39
  const err = new Error(`${line.errorName} (${line.errorCode}) [${line.errorInstanceId}]: ${line.errorDescription ?? ""}`);
40
40
  Object.assign(err, line);
41
41
  throw err;
42
42
  }
43
- const remapped = await chunkLWT7AZZD_cjs.remapQueryResponse(client, qd.output, line.value, definitions);
43
+ const remapped = await chunkVD4QAB27_cjs.remapQueryResponse(client, qd.output, line.value, definitions);
44
44
  if (qd.output.type === "array" && Array.isArray(remapped)) {
45
45
  for (const item of remapped) {
46
46
  yield item;
@@ -52,5 +52,5 @@ async function* applyStreamingQuery(client, query, params) {
52
52
  }
53
53
 
54
54
  exports.applyStreamingQuery = applyStreamingQuery;
55
- //# sourceMappingURL=applyStreamingQuery-IWZCZA6J.cjs.map
56
- //# sourceMappingURL=applyStreamingQuery-IWZCZA6J.cjs.map
55
+ //# sourceMappingURL=applyStreamingQuery-RK2N6TJ5.cjs.map
56
+ //# sourceMappingURL=applyStreamingQuery-RK2N6TJ5.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/@osdk+foundry.functions@2.63.0/node_modules/@osdk/foundry.functions/build/esm/public/Query.js","../../src/queries/applyStreamingQuery.ts"],"names":["foundryPlatformFetch","addUserAgentAndRequest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,IAAA,EAAM;AACzB,IAAA,MAAM,IAAI,MAAM,4CAA4C,CAAA;AAAA,EAC9D;AACA,EAAA,MAAM,WAAA,GAAc,MAAMC,wCAAA,CAAuB,EAAA,CAAG,QAAQ,MAAM,CAAA;AAClE,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,IAAA,CAAK,SAAA,EAAU;AACvC,EAAA,WAAA,MAAiB,IAAA,IAAQC,mCAAA,CAAkBC,uCAAA,CAAsB,MAAM,CAAC,CAAA,EAAG;AACzE,IAAA,IAAI,IAAA,CAAK,SAAS,OAAA,EAAS;AACzB,MAAA,MAAM,MAAM,IAAI,KAAA,CAAM,CAAA,EAAG,IAAA,CAAK,SAAS,CAAA,EAAA,EAAK,IAAA,CAAK,SAAS,CAAA,GAAA,EAAM,KAAK,eAAe,CAAA,GAAA,EAAM,IAAA,CAAK,gBAAA,IAAoB,EAAE,CAAA,CAAE,CAAA;AACvH,MAAA,MAAA,CAAO,MAAA,CAAO,KAAK,IAAI,CAAA;AACvB,MAAA,MAAM,GAAA;AAAA,IACR;AACA,IAAA,MAAM,QAAA,GAAW,MAAMC,oCAAA,CAAmB,MAAA,EAAQ,GAAG,MAAA,EAAQ,IAAA,CAAK,OAAO,WAAW,CAAA;AACpF,IAAA,IAAI,GAAG,MAAA,CAAO,IAAA,KAAS,WAAW,KAAA,CAAM,OAAA,CAAQ,QAAQ,CAAA,EAAG;AACzD,MAAA,KAAA,MAAW,QAAQ,QAAA,EAAU;AAC3B,QAAA,MAAM,IAAA;AAAA,MACR;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAM,QAAA;AAAA,IACR;AAAA,EACF;AACF","file":"applyStreamingQuery-IWZCZA6J.cjs","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 */\nimport { foundryPlatformFetch as $foundryPlatformFetch } from \"@osdk/shared.net.platformapi\";\n//\nconst _get = [0, \"/v2/functions/queries/{0}\", 2];\n/**\n * Gets a specific query type with the given API name. By default, this gets the latest version of the query.\n *\n * @alpha\n *\n * Required Scopes: [api:functions-read]\n * URL: /v2/functions/queries/{queryApiName}\n */\nexport function get($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _get, ...args);\n}\nconst _getByRid = [0, \"/v2/functions/queries/getByRid\", 2];\n/**\n * Gets a specific query type with the given RID. By default, this gets the latest version of the query.\n *\n * @alpha\n *\n * Required Scopes: [api:functions-read]\n * URL: /v2/functions/queries/getByRid\n */\nexport function getByRid($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _getByRid, ...args);\n}\nconst _getByRidBatch = [1, \"/v2/functions/queries/getByRidBatch\", 3];\n/**\n * Gets a list of query types by RID in bulk. By default, this gets the latest version of each query.\n *\n * Queries are filtered from the response if they don't exist or the requesting token lacks the required\n * permissions.\n *\n * The maximum batch size for this endpoint is 100.\n *\n * @alpha\n *\n * Required Scopes: [api:functions-read]\n * URL: /v2/functions/queries/getByRidBatch\n */\nexport function getByRidBatch($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _getByRidBatch, ...args);\n}\nconst _execute = [1, \"/v2/functions/queries/{0}/execute\", 7];\n/**\n * Executes a Query using the given parameters. By default, this executes the latest version of the query.\n *\n * This endpoint is maintained for backward compatibility only.\n *\n * For all new implementations, use the `streamingExecute` endpoint, which supports all function types\n * and provides enhanced functionality.\n *\n * @alpha\n *\n * Required Scopes: [api:functions-read]\n * URL: /v2/functions/queries/{queryApiName}/execute\n */\nexport function execute($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _execute, ...args);\n}\nconst _streamingExecute = [1, \"/v2/functions/queries/{0}/streamingExecute\", 7,, \"application/octet-stream\"];\n/**\n * Executes a Query using the given parameters, returning results as an NDJSON stream. By default, this executes the latest version of the query.\n *\n * This endpoint supports all Query functions. The endpoint name 'streamingExecute' refers to the NDJSON\n * streaming response format. Both streaming and non-streaming functions can use this endpoint.\n * Non-streaming functions return a single-line NDJSON response, while streaming functions return multi-line NDJSON responses.\n * This is the recommended endpoint for all query execution.\n *\n * The response is returned as a binary stream in NDJSON (Newline Delimited JSON) format, where each line\n * is a StreamingExecuteQueryResponse containing either a data batch or an error.\n *\n * For a function returning a list of 5 records with a batch size of 3, the response stream would contain\n * two lines. The first line contains the first 3 items, and the second line contains the remaining 2 items:\n *\n * ```\n * {\"type\":\"data\",\"value\":[{\"productId\":\"SKU-001\",\"price\":29.99},{\"productId\":\"SKU-002\",\"price\":49.99},{\"productId\":\"SKU-003\",\"price\":19.99}]}\n * {\"type\":\"data\",\"value\":[{\"productId\":\"SKU-004\",\"price\":39.99},{\"productId\":\"SKU-005\",\"price\":59.99}]}\n * ```\n *\n * Each line is a separate JSON object followed by a newline character. Clients should parse the stream\n * line-by-line to process results as they arrive. If an error occurs during execution, the stream will\n * contain an error line:\n *\n * ```\n * {\"type\":\"error\",\"errorCode\":\"INVALID_ARGUMENT\",\"errorName\":\"QueryRuntimeError\",\"errorInstanceId\":\"3f8a9c7b-2e4d-4a1f-9b8c-7d6e5f4a3b2c\",\"errorDescription\":\"Division by zero\",\"parameters\":{}}\n * ```\n *\n * @alpha\n *\n * Required Scopes: [api:functions-read]\n * URL: /v2/functions/queries/{queryApiName}/streamingExecute\n */\nexport function streamingExecute($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _streamingExecute, ...args);\n}\nconst _executeAsync = [1, \"/v2/functions/queries/{0}/executeAsync\", 7];\n/**\n * Submits a Query for asynchronous execution. Returns either an execution ID\n * for polling, or the complete result if execution finished immediately.\n *\n * Use the Execution resource's getResult endpoint to poll for the\n * result of a submitted execution.\n *\n * @alpha\n *\n * Required Scopes: [api:functions-execute]\n * URL: /v2/functions/queries/{queryApiName}/executeAsync\n */\nexport function executeAsync($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _executeAsync, ...args);\n}","/*\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 * as Functions from \"@osdk/foundry.functions/Query\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport { iterateReadableStream, parseNdjsonStream } from \"../util/streamutils.js\";\nimport { getRequiredDefinitions, remapQueryParams, remapQueryResponse } from \"./applyQuery.js\";\nexport async function* applyStreamingQuery(client, query, params) {\n const qd = await client.ontologyProvider.getQueryDefinition(query.apiName, query.isFixedVersion ? query.version : undefined);\n if (client.flushEdits != null) {\n await client.flushEdits();\n }\n const response = await Functions.streamingExecute(addUserAgentAndRequestContextHeaders(augmentRequestContext(client, _ => ({\n finalMethodCall: \"applyStreamingQuery\"\n })), query), query.apiName, {\n ontology: await client.ontologyRid,\n parameters: params ? await remapQueryParams(params, client, qd.parameters) : {},\n version: query.isFixedVersion ? query.version : undefined,\n branch: client.branch\n }, {\n transactionId: client.transactionId,\n preview: true\n });\n if (response.body == null) {\n throw new Error(\"streamingExecute returned no response body\");\n }\n const definitions = await getRequiredDefinitions(qd.output, client);\n const reader = response.body.getReader();\n for await (const line of parseNdjsonStream(iterateReadableStream(reader))) {\n if (line.type === \"error\") {\n const err = new Error(`${line.errorName} (${line.errorCode}) [${line.errorInstanceId}]: ${line.errorDescription ?? \"\"}`);\n Object.assign(err, line);\n throw err;\n }\n const remapped = await remapQueryResponse(client, qd.output, line.value, definitions);\n if (qd.output.type === \"array\" && Array.isArray(remapped)) {\n for (const item of remapped) {\n yield item;\n }\n } else {\n yield remapped;\n }\n }\n}"]}
1
+ {"version":3,"sources":["../../../../node_modules/.pnpm/@osdk+foundry.functions@2.63.0/node_modules/@osdk/foundry.functions/build/esm/public/Query.js","../../src/queries/applyStreamingQuery.ts"],"names":["foundryPlatformFetch","addUserAgentAndRequestContextHeaders","augmentRequestContext","remapQueryParams","getRequiredDefinitions","parseNdjsonStream","iterateReadableStream","remapQueryResponse"],"mappings":";;;;;;;;;AA2EA,IAAM,oBAAoB,CAAC,CAAA,EAAG,4CAAA,EAA8C,CAAA,IAAI,0BAA0B,CAAA;AAiCnG,SAAS,gBAAA,CAAiB,SAAS,IAAA,EAAM;AAC9C,EAAA,OAAOA,sCAAA,CAAsB,IAAA,EAAM,iBAAA,EAAmB,GAAG,IAAI,CAAA;AAC/D;;;ACzFA,gBAAuB,mBAAA,CAAoB,MAAA,EAAQ,KAAA,EAAO,MAAA,EAAQ;AAChE,EAAA,MAAM,EAAA,GAAK,MAAM,MAAA,CAAO,gBAAA,CAAiB,kBAAA,CAAmB,KAAA,CAAM,OAAA,EAAS,KAAA,CAAM,cAAA,GAAiB,KAAA,CAAM,OAAA,GAAU,MAAS,CAAA;AAC3H,EAAA,IAAI,MAAA,CAAO,cAAc,IAAA,EAAM;AAC7B,IAAA,MAAM,OAAO,UAAA,EAAW;AAAA,EAC1B;AACA,EAAA,MAAM,WAAW,MAAgB,gBAAA,CAAiBC,sDAAA,CAAqCC,uCAAA,CAAsB,QAAQ,CAAA,CAAA,MAAM;AAAA,IACzH,eAAA,EAAiB;AAAA,GACnB,CAAE,CAAA,EAAG,KAAK,CAAA,EAAG,MAAM,OAAA,EAAS;AAAA,IAC1B,QAAA,EAAU,MAAM,MAAA,CAAO,WAAA;AAAA,IACvB,UAAA,EAAY,SAAS,MAAMC,kCAAA,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M,IAAA;AAAA,MACR;AAAA,IACF,CAAA,MAAO;AACL,MAAA,MAAM,QAAA;AAAA,IACR;AAAA,EACF;AACF","file":"applyStreamingQuery-RK2N6TJ5.cjs","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 */\nimport { foundryPlatformFetch as $foundryPlatformFetch } from \"@osdk/shared.net.platformapi\";\n//\nconst _get = [0, \"/v2/functions/queries/{0}\", 2];\n/**\n * Gets a specific query type with the given API name. By default, this gets the latest version of the query.\n *\n * @alpha\n *\n * Required Scopes: [api:functions-read]\n * URL: /v2/functions/queries/{queryApiName}\n */\nexport function get($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _get, ...args);\n}\nconst _getByRid = [0, \"/v2/functions/queries/getByRid\", 2];\n/**\n * Gets a specific query type with the given RID. By default, this gets the latest version of the query.\n *\n * @alpha\n *\n * Required Scopes: [api:functions-read]\n * URL: /v2/functions/queries/getByRid\n */\nexport function getByRid($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _getByRid, ...args);\n}\nconst _getByRidBatch = [1, \"/v2/functions/queries/getByRidBatch\", 3];\n/**\n * Gets a list of query types by RID in bulk. By default, this gets the latest version of each query.\n *\n * Queries are filtered from the response if they don't exist or the requesting token lacks the required\n * permissions.\n *\n * The maximum batch size for this endpoint is 100.\n *\n * @alpha\n *\n * Required Scopes: [api:functions-read]\n * URL: /v2/functions/queries/getByRidBatch\n */\nexport function getByRidBatch($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _getByRidBatch, ...args);\n}\nconst _execute = [1, \"/v2/functions/queries/{0}/execute\", 7];\n/**\n * Executes a Query using the given parameters. By default, this executes the latest version of the query.\n *\n * This endpoint is maintained for backward compatibility only.\n *\n * For all new implementations, use the `streamingExecute` endpoint, which supports all function types\n * and provides enhanced functionality.\n *\n * @alpha\n *\n * Required Scopes: [api:functions-read]\n * URL: /v2/functions/queries/{queryApiName}/execute\n */\nexport function execute($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _execute, ...args);\n}\nconst _streamingExecute = [1, \"/v2/functions/queries/{0}/streamingExecute\", 7,, \"application/octet-stream\"];\n/**\n * Executes a Query using the given parameters, returning results as an NDJSON stream. By default, this executes the latest version of the query.\n *\n * This endpoint supports all Query functions. The endpoint name 'streamingExecute' refers to the NDJSON\n * streaming response format. Both streaming and non-streaming functions can use this endpoint.\n * Non-streaming functions return a single-line NDJSON response, while streaming functions return multi-line NDJSON responses.\n * This is the recommended endpoint for all query execution.\n *\n * The response is returned as a binary stream in NDJSON (Newline Delimited JSON) format, where each line\n * is a StreamingExecuteQueryResponse containing either a data batch or an error.\n *\n * For a function returning a list of 5 records with a batch size of 3, the response stream would contain\n * two lines. The first line contains the first 3 items, and the second line contains the remaining 2 items:\n *\n * ```\n * {\"type\":\"data\",\"value\":[{\"productId\":\"SKU-001\",\"price\":29.99},{\"productId\":\"SKU-002\",\"price\":49.99},{\"productId\":\"SKU-003\",\"price\":19.99}]}\n * {\"type\":\"data\",\"value\":[{\"productId\":\"SKU-004\",\"price\":39.99},{\"productId\":\"SKU-005\",\"price\":59.99}]}\n * ```\n *\n * Each line is a separate JSON object followed by a newline character. Clients should parse the stream\n * line-by-line to process results as they arrive. If an error occurs during execution, the stream will\n * contain an error line:\n *\n * ```\n * {\"type\":\"error\",\"errorCode\":\"INVALID_ARGUMENT\",\"errorName\":\"QueryRuntimeError\",\"errorInstanceId\":\"3f8a9c7b-2e4d-4a1f-9b8c-7d6e5f4a3b2c\",\"errorDescription\":\"Division by zero\",\"parameters\":{}}\n * ```\n *\n * @alpha\n *\n * Required Scopes: [api:functions-read]\n * URL: /v2/functions/queries/{queryApiName}/streamingExecute\n */\nexport function streamingExecute($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _streamingExecute, ...args);\n}\nconst _executeAsync = [1, \"/v2/functions/queries/{0}/executeAsync\", 7];\n/**\n * Submits a Query for asynchronous execution. Returns either an execution ID\n * for polling, or the complete result if execution finished immediately.\n *\n * Use the Execution resource's getResult endpoint to poll for the\n * result of a submitted execution.\n *\n * @alpha\n *\n * Required Scopes: [api:functions-execute]\n * URL: /v2/functions/queries/{queryApiName}/executeAsync\n */\nexport function executeAsync($ctx, ...args) {\n return $foundryPlatformFetch($ctx, _executeAsync, ...args);\n}","/*\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 * as Functions from \"@osdk/foundry.functions/Query\";\nimport { addUserAgentAndRequestContextHeaders } from \"../util/addUserAgentAndRequestContextHeaders.js\";\nimport { augmentRequestContext } from \"../util/augmentRequestContext.js\";\nimport { iterateReadableStream, parseNdjsonStream } from \"../util/streamutils.js\";\nimport { getRequiredDefinitions, remapQueryParams, remapQueryResponse } from \"./applyQuery.js\";\nexport async function* applyStreamingQuery(client, query, params) {\n const qd = await client.ontologyProvider.getQueryDefinition(query.apiName, query.isFixedVersion ? query.version : undefined);\n if (client.flushEdits != null) {\n await client.flushEdits();\n }\n const response = await Functions.streamingExecute(addUserAgentAndRequestContextHeaders(augmentRequestContext(client, _ => ({\n finalMethodCall: \"applyStreamingQuery\"\n })), query), query.apiName, {\n ontology: await client.ontologyRid,\n parameters: params ? await remapQueryParams(params, client, qd.parameters) : {},\n version: query.isFixedVersion ? query.version : undefined,\n branch: client.branch\n }, {\n transactionId: client.transactionId,\n preview: true\n });\n if (response.body == null) {\n throw new Error(\"streamingExecute returned no response body\");\n }\n const definitions = await getRequiredDefinitions(qd.output, client);\n const reader = response.body.getReader();\n for await (const line of parseNdjsonStream(iterateReadableStream(reader))) {\n if (line.type === \"error\") {\n const err = new Error(`${line.errorName} (${line.errorCode}) [${line.errorInstanceId}]: ${line.errorDescription ?? \"\"}`);\n Object.assign(err, line);\n throw err;\n }\n const remapped = await remapQueryResponse(client, qd.output, line.value, definitions);\n if (qd.output.type === \"array\" && Array.isArray(remapped)) {\n for (const item of remapped) {\n yield item;\n }\n } else {\n yield remapped;\n }\n }\n}"]}