@osdk/client 2.61.0 → 2.62.0-main-691c32ec3df9b0dc7e1edc66fdc28690dc9410b6
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.
- package/CHANGELOG.md +17 -0
- package/build/browser/Client.js +1 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/createClient.js +8 -1
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/scenarios/ScenarioClient.js +43 -1
- package/build/browser/scenarios/ScenarioClient.js.map +1 -1
- package/build/browser/util/UserAgent.js +2 -2
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/browser/util/resolveBranch.js +68 -0
- package/build/browser/util/resolveBranch.js.map +1 -0
- package/build/cjs/{applyStreamingQuery-LWMQIM2A.cjs → applyStreamingQuery-P4Q3KDSJ.cjs} +8 -8
- package/build/cjs/{applyStreamingQuery-LWMQIM2A.cjs.map → applyStreamingQuery-P4Q3KDSJ.cjs.map} +1 -1
- package/build/cjs/{chunk-7OV445PV.cjs → chunk-INZZEEZW.cjs} +13 -13
- package/build/cjs/{chunk-7OV445PV.cjs.map → chunk-INZZEEZW.cjs.map} +1 -1
- package/build/cjs/{chunk-Z7JGRZFA.cjs → chunk-LGO2MJ4C.cjs} +80 -80
- package/build/cjs/{chunk-Z7JGRZFA.cjs.map → chunk-LGO2MJ4C.cjs.map} +1 -1
- package/build/cjs/{chunk-6PYKTSSA.cjs → chunk-LXRIHNPC.cjs} +102 -48
- package/build/cjs/chunk-LXRIHNPC.cjs.map +1 -0
- package/build/cjs/{chunk-P6T2ZSKG.cjs → chunk-Q74YOU43.cjs} +8 -8
- package/build/cjs/{chunk-P6T2ZSKG.cjs.map → chunk-Q74YOU43.cjs.map} +1 -1
- package/build/cjs/{chunk-OED5MHLX.cjs → chunk-YM4REFZE.cjs} +2 -2
- package/build/cjs/{chunk-OED5MHLX.cjs.map → chunk-YM4REFZE.cjs.map} +1 -1
- package/build/cjs/{createClient-DN8qGXVs.d.cts → createClient-DqAttwya.d.cts} +17 -2
- package/build/cjs/index.cjs +11 -11
- package/build/cjs/index.d.cts +1 -1
- package/build/cjs/public/experimental.cjs +9 -9
- package/build/cjs/public/experimental.d.cts +2 -2
- package/build/cjs/public/internal.cjs +7 -7
- package/build/cjs/public/observable.cjs +5 -5
- package/build/cjs/public/unstable-do-not-use.cjs +16 -16
- package/build/cjs/public/unstable-do-not-use.d.cts +2 -2
- package/build/cjs/{withScenario-CJN1flg_.d.cts → withScenario-CwHWdp9K.d.cts} +35 -0
- package/build/esm/Client.js +1 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/createClient.js +8 -1
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/scenarios/ScenarioClient.js +43 -1
- package/build/esm/scenarios/ScenarioClient.js.map +1 -1
- package/build/esm/util/UserAgent.js +2 -2
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/esm/util/resolveBranch.js +68 -0
- package/build/esm/util/resolveBranch.js.map +1 -0
- package/build/types/Client.d.ts +1 -1
- package/build/types/createClient.d.ts +17 -2
- package/build/types/createClient.d.ts.map +1 -1
- package/build/types/scenarios/ScenarioClient.d.ts +35 -0
- package/build/types/scenarios/ScenarioClient.d.ts.map +1 -1
- package/build/types/util/resolveBranch.d.ts +28 -0
- package/build/types/util/resolveBranch.d.ts.map +1 -0
- package/package.json +9 -9
- package/build/cjs/chunk-6PYKTSSA.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @osdk/client
|
|
2
2
|
|
|
3
|
+
## 2.62.0-main-691c32ec3df9b0dc7e1edc66fdc28690dc9410b6
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 691c32e: The client is now branch-aware without configuration. When `UNSTABLE_DO_NOT_USE_BRANCH` is omitted, the branch is read from the `VITE_FOUNDRY_BRANCH_RID` environment variable that Foundry runtimes set to the branch the application is checked out on, so objects, actions, and queries read and write on that branch.
|
|
8
|
+
|
|
9
|
+
An explicitly supplied branch still wins, and `UNSTABLE_DO_NOT_USE_BRANCH` now accepts `null` to pin the client to the default branch while checked out on a branch.
|
|
10
|
+
|
|
11
|
+
- 13649db: Add `getConflictingObjects` (paginated) and `conflictingObjectsAsyncIter` (auto-paginating) methods to `ScenarioClient`. Lets consumers discover which objects have edits that conflict with changes on a scenario's base before merge. Beta — surface may change.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @osdk/api@2.62.0-main-691c32ec3df9b0dc7e1edc66fdc28690dc9410b6
|
|
16
|
+
- @osdk/client.unstable@2.62.0-main-691c32ec3df9b0dc7e1edc66fdc28690dc9410b6
|
|
17
|
+
- @osdk/generator-converters@2.62.0-main-691c32ec3df9b0dc7e1edc66fdc28690dc9410b6
|
|
18
|
+
- @osdk/shared.test@2.41.1-main-691c32ec3df9b0dc7e1edc66fdc28690dc9410b6
|
|
19
|
+
|
|
3
20
|
## 2.61.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/build/browser/Client.js
CHANGED
|
@@ -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.
|
|
24
|
+
const MaxOsdkVersion = "2.62.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\";\n\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> =\n Q extends VersionBound<infer V>\n ? SatisfiesSemver<V, MaxOsdkVersion> extends true\n ? Q\n : Q & {\n [ErrorMessage]: `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\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\"]\n ? 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\"]\n ? 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>>(o: Q): 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>>(o: Q): QuerySignatureFromDef<Q>;\n\n /**\n * @param experiment - The experiment marker that gates an unstable feature.\n * @example\n * ```ts\n * const employee = await client(__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid)\n * .fetchOneByRid(Employee, \"ri.phonograph2-objects.main.object.1234\");\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.59.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,\n ): Promise<\n Q extends ObjectTypeDefinition\n ? ObjectMetadata\n : Q extends InterfaceDefinition\n ? InterfaceMetadata\n : Q extends ActionDefinition<any>\n ? ActionMetadata\n : Q extends QueryDefinition<any>\n ? QueryMetadata\n : never\n >;\n\n /** @internal */\n [additionalContext]: MinimalClient;\n}\n\n// DO NOT EXPORT FROM PACKAGE\n/** @internal */\nexport const additionalContext: unique symbol = Symbol(\"additionalContext\");\n\n// BEGIN: THIS IS GENERATED CODE. DO NOT EDIT.\nconst MaxOsdkVersion = \"2.
|
|
1
|
+
{"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\";\n\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> =\n Q extends VersionBound<infer V>\n ? SatisfiesSemver<V, MaxOsdkVersion> extends true\n ? Q\n : Q & {\n [ErrorMessage]: `Your SDK requires a semver compatible version with ${V}. You have ${MaxOsdkVersion}. Update your package.json`;\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\"]\n ? 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\"]\n ? 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>>(o: Q): 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>>(o: Q): QuerySignatureFromDef<Q>;\n\n /**\n * @param experiment - The experiment marker that gates an unstable feature.\n * @example\n * ```ts\n * const employee = await client(__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid)\n * .fetchOneByRid(Employee, \"ri.phonograph2-objects.main.object.1234\");\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.59.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,\n ): Promise<\n Q extends ObjectTypeDefinition\n ? ObjectMetadata\n : Q extends InterfaceDefinition\n ? InterfaceMetadata\n : Q extends ActionDefinition<any>\n ? ActionMetadata\n : Q extends QueryDefinition<any>\n ? 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.62.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;;AA2BA;;AAkIA;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":[]}
|
|
@@ -27,6 +27,7 @@ import { fetchSingle } from "./object/fetchSingle.js";
|
|
|
27
27
|
import { createObjectSet } from "./objectSet/createObjectSet.js";
|
|
28
28
|
import { ObjectSetListenerWebsocket } from "./objectSet/ObjectSetListenerWebsocket.js";
|
|
29
29
|
import { applyQuery } from "./queries/applyQuery.js";
|
|
30
|
+
import { resolveBranch } from "./util/resolveBranch.js";
|
|
30
31
|
|
|
31
32
|
// We import it this way to keep compatible with CJS. If we referenced the
|
|
32
33
|
// value of `symbolClientContext` directly, then we would have to a dynamic import
|
|
@@ -73,7 +74,7 @@ export function createClientInternal(objectSetFactory, transactionRid, flushEdit
|
|
|
73
74
|
transactionId: transactionRid,
|
|
74
75
|
flushEdits,
|
|
75
76
|
scenarioRid,
|
|
76
|
-
branch: options?.UNSTABLE_DO_NOT_USE_BRANCH,
|
|
77
|
+
branch: resolveBranch(options?.UNSTABLE_DO_NOT_USE_BRANCH),
|
|
77
78
|
createSubscriptionConnection: subscribeConnectionFn
|
|
78
79
|
}, fetchFn, objectSetFactory);
|
|
79
80
|
return createClientFromContext(clientCtx);
|
|
@@ -198,6 +199,12 @@ export function createClientFromContext(clientCtx) {
|
|
|
198
199
|
* manage tokens yourself.
|
|
199
200
|
* @param options - Optional client configuration: a custom `logger`, an experimental `UNSTABLE_DO_NOT_USE_BRANCH`
|
|
200
201
|
* for branch-aware requests, and additional `headers` to include on every request.
|
|
202
|
+
*
|
|
203
|
+
* The client is branch-aware without configuration. If `UNSTABLE_DO_NOT_USE_BRANCH` is not supplied, the
|
|
204
|
+
* branch is read from the `VITE_FOUNDRY_BRANCH_RID` environment variable, which Foundry runtimes set to
|
|
205
|
+
* the branch the application is checked out on; objects, actions, and queries then read and write on that
|
|
206
|
+
* branch. An explicitly supplied branch always takes precedence, and `null` pins the client to the default
|
|
207
|
+
* branch even while checked out on a branch.
|
|
201
208
|
* @param fetchFn - An optional `fetch` implementation to use for all requests. Defaults to the global `fetch`.
|
|
202
209
|
* @example
|
|
203
210
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__executeStreamingFunction","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","__EXPERIMENTAL__NOT_SUPPORTED_YET__linkSubscriptions","__EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet","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","subscribeConnectionFn","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","logger","transactionId","branch","UNSTABLE_DO_NOT_USE_BRANCH","createSubscriptionConnection","createClientFromContext","fetchMetadata","client","Object","defineProperties","o","type","name","executeStreamingFunction","query","params","applyStreamingQuery","getBulkLinks","objs","linkTypes","createBulkLinksAsyncIterFactory","subscribeToLinks","objectType","args","pendingSubscription","LinkSubscriptionWebsocket","getInstance","subscribe","unsubscribe","fetchOneByRid","rid","createWithRid","fetchPageByRid","objectOrInterfaceType","rids","fetchPageByRidNoType","subscribeToNoTypeObjectSet","listener","opts","subscribeWithoutType","reference","includeRid","transformAndWaitInternal","mediaSetRid","mediaItemRid","token","media","getMediaReference","mediaSetViewItem","transformation","value","createClient","createClientWithTransaction","createClientWithSubscriptionConnection","createClientWithScenario","objects"],"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 LinkTypeApiNamesFor,\n Logger,\n Media,\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 LinkSubscription,\n MediaTransformation,\n MinimalObjectSet,\n TransformOptions,\n} from \"@osdk/api/unstable\";\nimport {\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__linkSubscriptions,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet,\n transformAndWait,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\n\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\";\nimport type { CreateSubscriptionConnectionFn } from \"./SubscriptionConnection.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<\n Q extends ActionDefinition<any>,\n> implements ActionSignatureFromDef<Q> {\n constructor(clientCtx: MinimalClient, actionDef: ActionDefinition<any>) {\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<\n Q extends QueryDefinition<any>,\n> implements QuerySignatureFromDef<Q> {\n constructor(clientCtx: MinimalClient, queryDef: QueryDefinition<any>) {\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 subscribeConnectionFn: CreateSubscriptionConnectionFn | 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 createSubscriptionConnection: subscribeConnectionFn,\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.59.0\">\n | Experiment<\"2.8.0\">\n | Experiment<\"2.19.0\">,\n >(\n o: T,\n ): T extends ObjectTypeDefinition\n ? ObjectSet<T>\n : T extends InterfaceDefinition\n ? MinimalObjectSet<T>\n : T extends ActionDefinition<any>\n ? ActionSignatureFromDef<T>\n : T extends QueryDefinition<any>\n ? QuerySignatureFromDef<T>\n : T extends\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">\n | Experiment<\"2.59.0\">\n | Experiment<\"2.8.0\">\n | Experiment<\"2.19.0\">\n ? { invoke: ExperimentFns<T> }\n : never {\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(clientCtx, o) 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(clientCtx, o) as T extends QueryDefinition<any>\n ? 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 } =\n await import(\"./queries/applyStreamingQuery.js\");\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 } =\n await import(\"./__unstable/createBulkLinksAsyncIterFactory.js\");\n yield* createBulkLinksAsyncIterFactory(clientCtx)(\n objs,\n linkTypes,\n );\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__linkSubscriptions.name:\n return {\n subscribeToLinks: (\n objectType: ObjectTypeDefinition,\n args: LinkSubscription.Args<\n ObjectTypeDefinition,\n LinkTypeApiNamesFor<ObjectTypeDefinition>\n >,\n ) => {\n const pendingSubscription =\n import(\"./objectSet/LinkSubscriptionWebsocket.js\").then(\n ({ LinkSubscriptionWebsocket }) =>\n LinkSubscriptionWebsocket.getInstance(clientCtx).subscribe(\n objectType,\n args,\n ),\n );\n return {\n unsubscribe: async () => (await pendingSubscription)(),\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([rid]),\n )) as Osdk<Q>;\n },\n } as any;\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(clientCtx, rids, options ?? {});\n },\n } as any;\n\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet.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.getInstance(\n 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 transformAndWait.name:\n return {\n transformAndWait: async (args: {\n media: Media;\n transformation: MediaTransformation;\n options?: TransformOptions;\n }) => {\n const { transformAndWaitInternal } =\n await import(\"./util/transformAndWaitInternal.js\");\n const { mediaSetRid, mediaItemRid, token } =\n args.media.getMediaReference().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(undefined, clientCtx);\n\n const symbolClientContext: newSymbolClientContext = \"__osdkClientContext\";\n\n const client: Client = Object.defineProperties<Client>(clientFn as Client, {\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 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 | {\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 }\n | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n undefined,\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 undefined,\n ...args,\n ) as Client;\n\n/**\n * Creates a {@link Client} whose `objectSet.subscribe()` calls are routed through a caller-supplied\n * connection factory instead of the default `WebSocket`. This lets an embedder (e.g. an embedded\n * backend) supply an alternate transport that speaks the same `StreamMessage` wire protocol — the\n * OSDK subscription machinery (wire→OSDK conversion, multiplexing, reconnection, heartbeats) is\n * unchanged; only the underlying connection is swapped.\n *\n * @param createSubscriptionConnection - A zero-arg factory returning a {@link SubscriptionConnection}\n * (or a promise of one), used for every subscription connection.\n * @param args - The remaining {@link createClient} arguments (`baseUrl`, `ontologyRid`,\n * `tokenProvider`, `options`, `fetchFn`).\n */\nexport const createClientWithSubscriptionConnection: (\n createSubscriptionConnection: CreateSubscriptionConnectionFn,\n ...args: Parameters<typeof createClient>\n) => Client = (createSubscriptionConnection, ...args) =>\n createClientInternal(\n createObjectSet,\n undefined,\n undefined,\n undefined,\n createSubscriptionConnection,\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 undefined,\n ...args,\n ) as Client;\n\nfunction createWithRid(rids: string[]) {\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;;AA4BA,SACEA,2DAA2D,EAC3DC,gDAAgD,EAChDC,iDAAiD,EACjDC,+CAA+C,EAC/CC,oDAAoD,EACpDC,6DAA6D,EAC7DC,gBAAgB,QACX,oBAAoB;AAE3B,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AAGnF,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,E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W;AAEb,SAASQ,aAAaA,CAACG,IAAc,EAAE;EAMrC,OAL+B;IAC7BvB,IAAI,EAAE,QAAQ;IACd4C,OAAO,EAAErB;EACX,CAAC;AAGH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__executeStreamingFunction","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchPageByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","__EXPERIMENTAL__NOT_SUPPORTED_YET__linkSubscriptions","__EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet","transformAndWait","symbolClientContext","oldSymbolClientContext","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","makeMediaTransformation","MinimalLogger","fetchPage","fetchStaticRidPage","fetchSingle","createObjectSet","ObjectSetListenerWebsocket","applyQuery","resolveBranch","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","transactionRid","flushEdits","scenarioRid","subscribeConnectionFn","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","logger","transactionId","branch","UNSTABLE_DO_NOT_USE_BRANCH","createSubscriptionConnection","createClientFromContext","fetchMetadata","client","Object","defineProperties","o","type","name","executeStreamingFunction","query","params","applyStreamingQuery","getBulkLinks","objs","linkTypes","createBulkLinksAsyncIterFactory","subscribeToLinks","objectType","args","pendingSubscription","LinkSubscriptionWebsocket","getInstance","subscribe","unsubscribe","fetchOneByRid","rid","createWithRid","fetchPageByRid","objectOrInterfaceType","rids","fetchPageByRidNoType","subscribeToNoTypeObjectSet","listener","opts","subscribeWithoutType","reference","includeRid","transformAndWaitInternal","mediaSetRid","mediaItemRid","token","media","getMediaReference","mediaSetViewItem","transformation","value","createClient","createClientWithTransaction","createClientWithSubscriptionConnection","createClientWithScenario","objects"],"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 LinkTypeApiNamesFor,\n Logger,\n Media,\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 LinkSubscription,\n MediaTransformation,\n MinimalObjectSet,\n TransformOptions,\n} from \"@osdk/api/unstable\";\nimport {\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__linkSubscriptions,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet,\n transformAndWait,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\n\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\";\nimport type { CreateSubscriptionConnectionFn } from \"./SubscriptionConnection.js\";\nimport { resolveBranch } from \"./util/resolveBranch.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<\n Q extends ActionDefinition<any>,\n> implements ActionSignatureFromDef<Q> {\n constructor(clientCtx: MinimalClient, actionDef: ActionDefinition<any>) {\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<\n Q extends QueryDefinition<any>,\n> implements QuerySignatureFromDef<Q> {\n constructor(clientCtx: MinimalClient, queryDef: QueryDefinition<any>) {\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 subscribeConnectionFn: CreateSubscriptionConnectionFn | 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 | null;\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: resolveBranch(options?.UNSTABLE_DO_NOT_USE_BRANCH),\n createSubscriptionConnection: subscribeConnectionFn,\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.59.0\">\n | Experiment<\"2.8.0\">\n | Experiment<\"2.19.0\">,\n >(\n o: T,\n ): T extends ObjectTypeDefinition\n ? ObjectSet<T>\n : T extends InterfaceDefinition\n ? MinimalObjectSet<T>\n : T extends ActionDefinition<any>\n ? ActionSignatureFromDef<T>\n : T extends QueryDefinition<any>\n ? QuerySignatureFromDef<T>\n : T extends\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">\n | Experiment<\"2.59.0\">\n | Experiment<\"2.8.0\">\n | Experiment<\"2.19.0\">\n ? { invoke: ExperimentFns<T> }\n : never {\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(clientCtx, o) 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(clientCtx, o) as T extends QueryDefinition<any>\n ? 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 } =\n await import(\"./queries/applyStreamingQuery.js\");\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 } =\n await import(\"./__unstable/createBulkLinksAsyncIterFactory.js\");\n yield* createBulkLinksAsyncIterFactory(clientCtx)(\n objs,\n linkTypes,\n );\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__linkSubscriptions.name:\n return {\n subscribeToLinks: (\n objectType: ObjectTypeDefinition,\n args: LinkSubscription.Args<\n ObjectTypeDefinition,\n LinkTypeApiNamesFor<ObjectTypeDefinition>\n >,\n ) => {\n const pendingSubscription =\n import(\"./objectSet/LinkSubscriptionWebsocket.js\").then(\n ({ LinkSubscriptionWebsocket }) =>\n LinkSubscriptionWebsocket.getInstance(clientCtx).subscribe(\n objectType,\n args,\n ),\n );\n return {\n unsubscribe: async () => (await pendingSubscription)(),\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([rid]),\n )) as Osdk<Q>;\n },\n } as any;\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(clientCtx, rids, options ?? {});\n },\n } as any;\n\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__subscribeToNoTypeObjectSet.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.getInstance(\n 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 transformAndWait.name:\n return {\n transformAndWait: async (args: {\n media: Media;\n transformation: MediaTransformation;\n options?: TransformOptions;\n }) => {\n const { transformAndWaitInternal } =\n await import(\"./util/transformAndWaitInternal.js\");\n const { mediaSetRid, mediaItemRid, token } =\n args.media.getMediaReference().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(undefined, clientCtx);\n\n const symbolClientContext: newSymbolClientContext = \"__osdkClientContext\";\n\n const client: Client = Object.defineProperties<Client>(clientFn as Client, {\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 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 *\n * The client is branch-aware without configuration. If `UNSTABLE_DO_NOT_USE_BRANCH` is not supplied, the\n * branch is read from the `VITE_FOUNDRY_BRANCH_RID` environment variable, which Foundry runtimes set to\n * the branch the application is checked out on; objects, actions, and queries then read and write on that\n * branch. An explicitly supplied branch always takes precedence, and `null` pins the client to the default\n * branch even while checked out on a branch.\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 | {\n logger?: Logger;\n /**\n * The Foundry branch to scope every request to.\n *\n * When omitted (or `undefined`), the branch is read from the\n * `VITE_FOUNDRY_BRANCH_RID` environment variable, which Foundry runtimes\n * set to the branch the application is checked out on. Pass `null` to\n * ignore the environment and use the default branch.\n *\n * @beta This is an experimental feature subject to change\n */\n UNSTABLE_DO_NOT_USE_BRANCH?: string | null;\n headers?: Record<string, string>;\n }\n | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n undefined,\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 undefined,\n ...args,\n ) as Client;\n\n/**\n * Creates a {@link Client} whose `objectSet.subscribe()` calls are routed through a caller-supplied\n * connection factory instead of the default `WebSocket`. This lets an embedder (e.g. an embedded\n * backend) supply an alternate transport that speaks the same `StreamMessage` wire protocol — the\n * OSDK subscription machinery (wire→OSDK conversion, multiplexing, reconnection, heartbeats) is\n * unchanged; only the underlying connection is swapped.\n *\n * @param createSubscriptionConnection - A zero-arg factory returning a {@link SubscriptionConnection}\n * (or a promise of one), used for every subscription connection.\n * @param args - The remaining {@link createClient} arguments (`baseUrl`, `ontologyRid`,\n * `tokenProvider`, `options`, `fetchFn`).\n */\nexport const createClientWithSubscriptionConnection: (\n createSubscriptionConnection: CreateSubscriptionConnectionFn,\n ...args: Parameters<typeof createClient>\n) => Client = (createSubscriptionConnection, ...args) =>\n createClientInternal(\n createObjectSet,\n undefined,\n undefined,\n undefined,\n createSubscriptionConnection,\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 undefined,\n ...args,\n ) as Client;\n\nfunction createWithRid(rids: string[]) {\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;;AA4BA,SACEA,2DAA2D,EAC3DC,gDAAgD,EAChDC,iDAAiD,EACjDC,+CAA+C,EAC/CC,oDAAoD,EACpDC,6DAA6D,EAC7DC,gBAAgB,QACX,oBAAoB;AAE3B,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AAGnF,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAqB,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,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uBAAuB,CAACyD,IAAI,CAAC0B,cAAc,CAAC,EAC5CJ,KAAK,EACLtB,IAAI,CAAC7B,OACP,CAAC;YACH;UACF,CAAC;MACL;MAEA,MAAM,IAAII,KAAK,CAAC,iBAAiB,CAAC;IACpC,CAAC,MAAM;MACL,MAAM,IAAIA,KAAK,CAAC,iBAAiB,CAAC;IACpC;EACF,CAAC,EAM0E;IACzE,CAACrC,sBAAsB,GAAG;MACxByF,KAAK,EAAEzE;IACT,CAAC;IACD,CANkD,qBAAqB,GAMhD;MACrByE,KAAK,EAAEzE;IACT,CAAC;IACD,CAACd,iBAAiB,GAAG;MACnBuF,KAAK,EAAEzE;IACT,CAAC;IACD6B,aAAa,EAAE;MACb4C,KAAK,EAAE5C;IACT;EACF,CAAoD,CAAC;EAErD,OAAOC,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM4C,YAsBF,GAAGlE,oBAAoB,CAACN,IAAI,CACrCC,SAAS,EACTT,eAAe,EACfS,SAAS,EACTA,SAAS,EACTA,SAAS,EACTA,SACF,CAAC;AAED,OAAO,MAAMwE,2BAIF,GAAGA,CAACjE,cAAc,EAAEC,UAAU,EAAE,GAAGmC,IAAI,KAChDtC,oBAAoB,CAClBd,eAAe,EACfgB,cAAc,EACdC,UAAU,EACVR,SAAS,EACTA,SAAS,EACT,GAAG2C,IACL,CAAW;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAM8B,sCAGF,GAAGA,CAACjD,4BAA4B,EAAE,GAAGmB,IAAI,KAClDtC,oBAAoB,CAClBd,eAAe,EACfS,SAAS,EACTA,SAAS,EACTA,SAAS,EACTwB,4BAA4B,EAC5B,GAAGmB,IACL,CAAW;;AAEb;AACA,OAAO,MAAM+B,wBAGF,GAAGA,CAACjE,WAAW,EAAE,GAAGkC,IAAI,KACjCtC,oBAAoB,CAClBd,eAAe,EACfS,SAAS,EACTA,SAAS,EACTS,WAAW,EACXT,SAAS,EACT,GAAG2C,IACL,CAAW;AAEb,SAASQ,aAAaA,CAACG,IAAc,EAAE;EAMrC,OAL+B;IAC7BvB,IAAI,EAAE,QAAQ;IACd4C,OAAO,EAAErB;EACX,CAAC;AAGH","ignoreList":[]}
|
|
@@ -41,6 +41,11 @@ import { createClientWithScenario } from "../createClient.js";
|
|
|
41
41
|
* Returned by {@link EXPERIMENTAL_ScenarioClient.getEditedLinks}. Source and target carry only `$primaryKey` + `$apiName`.
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* A page of object identifiers whose edits within a scenario conflict with edits to the scenario's base. Returned by
|
|
46
|
+
* {@link EXPERIMENTAL_ScenarioClient.getConflictingObjects}. Results contain only `$primaryKey` + `$apiName`.
|
|
47
|
+
*/
|
|
48
|
+
|
|
44
49
|
/**
|
|
45
50
|
* A {@link Client} attached to an ontology scenario. All read and write operations performed via this client are
|
|
46
51
|
* scoped to that scenario. `EXPERIMENTAL_ScenarioClient` is a superset of {@link Client}.
|
|
@@ -71,7 +76,10 @@ export function buildScenarioClient(parent, scenarioRid) {
|
|
|
71
76
|
}
|
|
72
77
|
const inner = createClientWithScenario(scenarioRid, ctx.baseUrl, ctx.ontologyRid, ctx.tokenProvider, {
|
|
73
78
|
logger: ctx.logger,
|
|
74
|
-
|
|
79
|
+
// `?? null` so the scenario client inherits the parent's already-resolved
|
|
80
|
+
// branch rather than re-resolving from the environment. A parent that
|
|
81
|
+
// resolved to no branch must stay on the default branch here too.
|
|
82
|
+
UNSTABLE_DO_NOT_USE_BRANCH: ctx.branch ?? null
|
|
75
83
|
}, ctx.fetch);
|
|
76
84
|
const innerCtx = inner[additionalContext];
|
|
77
85
|
async function getEditedEntities(objectType, options) {
|
|
@@ -131,6 +139,22 @@ export function buildScenarioClient(parent, scenarioRid) {
|
|
|
131
139
|
nextPageToken: response.nextPageToken
|
|
132
140
|
};
|
|
133
141
|
}
|
|
142
|
+
async function getConflictingObjects(objectType, options) {
|
|
143
|
+
const ontologyRid = await innerCtx.ontologyRid;
|
|
144
|
+
const response = await OntologyScenarios.listScenarioConflictingObjects(innerCtx, ontologyRid, scenarioRid, objectType.apiName, {
|
|
145
|
+
pageSize: options?.pageSize,
|
|
146
|
+
pageToken: options?.pageToken,
|
|
147
|
+
preview: true
|
|
148
|
+
});
|
|
149
|
+
const data = response.data.map(entry => ({
|
|
150
|
+
$apiName: entry.objectTypeApiName,
|
|
151
|
+
$primaryKey: entry.primaryKeyValue
|
|
152
|
+
}));
|
|
153
|
+
return {
|
|
154
|
+
data,
|
|
155
|
+
nextPageToken: response.nextPageToken
|
|
156
|
+
};
|
|
157
|
+
}
|
|
134
158
|
return Object.defineProperties(inner, {
|
|
135
159
|
getScenarioReference: {
|
|
136
160
|
value: () => scenarioRid
|
|
@@ -195,6 +219,24 @@ export function buildScenarioClient(parent, scenarioRid) {
|
|
|
195
219
|
pageToken = page.nextPageToken;
|
|
196
220
|
} while (pageToken != null);
|
|
197
221
|
}
|
|
222
|
+
},
|
|
223
|
+
getConflictingObjects: {
|
|
224
|
+
value: getConflictingObjects
|
|
225
|
+
},
|
|
226
|
+
conflictingObjectsAsyncIter: {
|
|
227
|
+
value: async function* (objectType, options) {
|
|
228
|
+
let pageToken;
|
|
229
|
+
do {
|
|
230
|
+
const page = await getConflictingObjects(objectType, {
|
|
231
|
+
pageSize: options?.pageSize,
|
|
232
|
+
pageToken
|
|
233
|
+
});
|
|
234
|
+
for (const object of page.data) {
|
|
235
|
+
yield object;
|
|
236
|
+
}
|
|
237
|
+
pageToken = page.nextPageToken;
|
|
238
|
+
} while (pageToken != null);
|
|
239
|
+
}
|
|
198
240
|
}
|
|
199
241
|
});
|
|
200
242
|
}
|
|
@@ -1 +1 @@
|
|
|
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\";\n\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,QAAQ,0BAA0B;AAE5D,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,KACZ,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,UAAU,CAAC,IAC1D,OAAQA,KAAK,CACVC,oBAAoB,KAAK,UAAU;AAE1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjCC,MAAc,EACdC,WAAmB,EACU;EAC7B,MAAMC,GAAkB,GAAGF,MAAM,CAACN,iBAAiB,CAAC;EAEpD,IAAIQ,GAAG,CAACC,aAAa,IAAI,IAAI,EAAE;IAC7B;IACAC,OAAO,CAACC,IAAI,CACV,6IACF,CAAC;EACH;EACA,IAAIH,GAAG,CAACD,WAAW,IAAI,IAAI,EAAE;IAC3B,MAAM,IAAIK,KAAK,CACb,gHACF,CAAC;EACH;EAEA,MAAMC,KAAa,GAAGZ,wBAAwB,CAC5CM,WAAW,EACXC,GAAG,CAAC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rC,KAAK,EAAEqC;IACT,CAAC;IACD6B,oBAAoB,EAAE;MACpBlE,KAAK,EA3CT,gBAAAA,CAIEsC,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","getConflictingObjects","listScenarioConflictingObjects","objectTypeApiName","primaryKeyValue","Object","defineProperties","getEditedEntityTypes","listScenarioEditedEntityTypes","objectTypes","linkTypes","editedEntitiesAsyncIter","seen","Set","page","obj","key","has","add","getEditedLinkTypes","listScenarioEditedLinkTypes","editedLinksAsyncIter","link","conflictingObjectsAsyncIter","object"],"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\";\n\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 page of object identifiers whose edits within a scenario conflict with edits to the scenario's base. Returned by\n * {@link EXPERIMENTAL_ScenarioClient.getConflictingObjects}. Results contain only `$primaryKey` + `$apiName`.\n */\nexport interface ConflictingObjectsPage<Q extends ObjectTypeDefinition> {\n data: ObjectIdentifiers<Q>[];\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 /**\n * Get a page of object identifiers whose scenario edits conflict with edits to the scenario's base for the given\n * object type. Conflict detection may report false positives when object versions change without user-visible data\n * changes. Results are a point-in-time check, and include only objects the caller may view and the backend can resolve,\n * and may become stale before merge. Use the base client and scenario client to load both object states for review.\n *\n * `pageSize` bounds the number of objects examined, not the number of conflicts returned, so a page may contain fewer\n * results than requested while still returning `nextPageToken`.\n */\n getConflictingObjects<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<ConflictingObjectsPage<Q>>;\n\n /**\n * Stream object identifiers for the objects whose scenario edits conflict with edits to the scenario's base for the\n * given object type. Pages are fetched lazily.\n *\n * @example\n * ```ts\n * for await (const obj of scenario.conflictingObjectsAsyncIter(Doctor, { pageSize: 500 })) {\n * // obj.$primaryKey identifies an object with a conflicting scenario edit\n * }\n * ```\n */\n conflictingObjectsAsyncIter<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<ObjectIdentifiers<Q>>;\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 // `?? null` so the scenario client inherits the parent's already-resolved\n // branch rather than re-resolving from the environment. A parent that\n // resolved to no branch must stay on the default branch here too.\n UNSTABLE_DO_NOT_USE_BRANCH: ctx.branch ?? null,\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 async function getConflictingObjects<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number; pageToken?: string },\n ): Promise<ConflictingObjectsPage<Q>> {\n const ontologyRid = await innerCtx.ontologyRid;\n const response = await OntologyScenarios.listScenarioConflictingObjects(\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 $apiName: entry.objectTypeApiName as Q[\"apiName\"],\n $primaryKey: entry.primaryKeyValue as PrimaryKeyType<Q>,\n }));\n return {\n data,\n nextPageToken: response.nextPageToken,\n };\n }\n\n async function* conflictingObjectsAsyncIter<Q extends ObjectTypeDefinition>(\n objectType: Q,\n options?: { pageSize?: number },\n ): AsyncIterableIterator<ObjectIdentifiers<Q>> {\n let pageToken: string | undefined;\n do {\n const page = await getConflictingObjects(objectType, {\n pageSize: options?.pageSize,\n pageToken,\n });\n for (const object of page.data) {\n yield object;\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 getConflictingObjects: {\n value: getConflictingObjects,\n },\n conflictingObjectsAsyncIter: {\n value: conflictingObjectsAsyncIter,\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;AAE5D,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;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAgIA,OAAO,SAASC,gBAAgBA,CAC9BC,KAAc,EACwB;EACtC,OACEA,KAAK,IAAI,IAAI,KACZ,OAAOA,KAAK,KAAK,QAAQ,IAAI,OAAOA,KAAK,KAAK,UAAU,CAAC,IAC1D,OAAQA,KAAK,CACVC,oBAAoB,KAAK,UAAU;AAE1C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjCC,MAAc,EACdC,WAAmB,EACU;EAC7B,MAAMC,GAAkB,GAAGF,MAAM,CAACN,iBAAiB,CAAC;EAEpD,IAAIQ,GAAG,CAACC,aAAa,IAAI,IAAI,EAAE;IAC7B;IACAC,OAAO,CAACC,IAAI,CACV,6IACF,CAAC;EACH;EACA,IAAIH,GAAG,CAACD,WAAW,IAAI,IAAI,EAAE;IAC3B,MAAM,IAAIK,KAAK,CACb,gHACF,CAAC;EACH;EAEA,MAAMC,KAAa,GAAGZ,wBAAwB,CAC5CM,WAAW,EACXC,GAAG,CAACM,OAAO,EACXN,GAAG,CAACO,WAAW,EACfP,GAAG,CAACQ,aAAa,EACjB;IACEC,MAAM,EAAET,GAAG,CAACS,MAAM;IAClB;IACA;IACA;IACAC,0BAA0B,EAAEV,GAAG,CAACW,MAAM,IAAI;E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EJ,OAAO,EAAEI,QAAQ;YAC3BC;UACF,CAAC,CAAC;UACF,KAAK,MAAM+C,MAAM,IAAIV,IAAI,CAACnC,IAAI,EAAE;YAC9B,MAAM6C,MAAM;UACd;UACA/C,SAAS,GAAGqC,IAAI,CAAC3B,aAAa;QAChC,CAAC,QAAQV,SAAS,IAAI,IAAI;MAC5B;IA6BE;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
export const USER_AGENT = `osdk-client/${"2.
|
|
18
|
-
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.
|
|
17
|
+
export const USER_AGENT = `osdk-client/${"2.62.0-main-691c32ec3df9b0dc7e1edc66fdc28690dc9410b6"}`;
|
|
18
|
+
export const OBSERVABLE_USER_AGENT = `osdk-observable-client/${"2.62.0-main-691c32ec3df9b0dc7e1edc66fdc28690dc9410b6"}`;
|
|
19
19
|
//# sourceMappingURL=UserAgent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAgent.js","names":["USER_AGENT","OBSERVABLE_USER_AGENT"],"sources":["UserAgent.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const USER_AGENT: string = `osdk-client/${process.env.PACKAGE_VERSION}`;\nexport const OBSERVABLE_USER_AGENT: string = `osdk-observable-client/${process.env.PACKAGE_VERSION}`;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,UAAkB,GAAG,
|
|
1
|
+
{"version":3,"file":"UserAgent.js","names":["USER_AGENT","OBSERVABLE_USER_AGENT"],"sources":["UserAgent.ts"],"sourcesContent":["/*\n * Copyright 2023 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport const USER_AGENT: string = `osdk-client/${process.env.PACKAGE_VERSION}`;\nexport const OBSERVABLE_USER_AGENT: string = `osdk-observable-client/${process.env.PACKAGE_VERSION}`;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,UAAkB,GAAG,uEAA4C;AAC9E,OAAO,MAAMC,qBAA6B,GAAG,kFAAuD","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The environment variable that a Foundry runtime sets to the RID of the branch
|
|
19
|
+
* the application is currently checked out on.
|
|
20
|
+
*
|
|
21
|
+
* It is set by the in-platform dev server, by CI when building a pull request
|
|
22
|
+
* preview, and by local tooling. When it is absent the application is running
|
|
23
|
+
* against the default (`main`) branch.
|
|
24
|
+
*/
|
|
25
|
+
export const FOUNDRY_BRANCH_RID_ENV_VAR = "VITE_FOUNDRY_BRANCH_RID";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Reads the whole `import.meta.env` object so builds without it safely return
|
|
29
|
+
* `undefined`. A direct member access would fail in the CommonJS build.
|
|
30
|
+
*/
|
|
31
|
+
function getImportMetaEnv() {
|
|
32
|
+
return import.meta.env;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Trims branch values and treats blanks as absent to avoid sending an empty
|
|
37
|
+
* `branch` query parameter.
|
|
38
|
+
*/
|
|
39
|
+
function normalizeBranch(branch) {
|
|
40
|
+
if (typeof branch !== "string") {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const trimmed = branch.trim();
|
|
44
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Determines the branch a client should use.
|
|
49
|
+
*
|
|
50
|
+
* An explicitly supplied branch always wins, so application code and any
|
|
51
|
+
* existing `fetch` or client overrides keep their current behavior. `null`
|
|
52
|
+
* explicitly means "no branch", which is how a caller pins to the default
|
|
53
|
+
* branch while checked out on a branch.
|
|
54
|
+
*
|
|
55
|
+
* `undefined` — including the `undefined` that a generated SDK's `$branch`
|
|
56
|
+
* export carries when the SDK was generated against the default branch — falls
|
|
57
|
+
* back to {@link FOUNDRY_BRANCH_RID_ENV_VAR}. That fallback is the point: a
|
|
58
|
+
* repository checked out on a branch reads that branch's data even if its
|
|
59
|
+
* generated SDK predates the checkout.
|
|
60
|
+
*
|
|
61
|
+
* @param explicitBranch - the branch supplied by the caller, if any
|
|
62
|
+
* @param env - the environment to read from. Defaults to `import.meta.env`;
|
|
63
|
+
* supply it to test without depending on the ambient environment.
|
|
64
|
+
*/
|
|
65
|
+
export function resolveBranch(explicitBranch, env = getImportMetaEnv()) {
|
|
66
|
+
return explicitBranch !== undefined ? normalizeBranch(explicitBranch) : normalizeBranch(env?.[FOUNDRY_BRANCH_RID_ENV_VAR]);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=resolveBranch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveBranch.js","names":["FOUNDRY_BRANCH_RID_ENV_VAR","getImportMetaEnv","import","meta","env","normalizeBranch","branch","undefined","trimmed","trim","length","resolveBranch","explicitBranch"],"sources":["resolveBranch.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\n/**\n * The environment variable that a Foundry runtime sets to the RID of the branch\n * the application is currently checked out on.\n *\n * It is set by the in-platform dev server, by CI when building a pull request\n * preview, and by local tooling. When it is absent the application is running\n * against the default (`main`) branch.\n */\nexport const FOUNDRY_BRANCH_RID_ENV_VAR: string = \"VITE_FOUNDRY_BRANCH_RID\";\n\n/**\n * Reads the whole `import.meta.env` object so builds without it safely return\n * `undefined`. A direct member access would fail in the CommonJS build.\n */\nfunction getImportMetaEnv(): Record<string, string | undefined> | undefined {\n return (\n import.meta as ImportMeta & { env?: Record<string, string | undefined> }\n ).env;\n}\n\n/**\n * Trims branch values and treats blanks as absent to avoid sending an empty\n * `branch` query parameter.\n */\nfunction normalizeBranch(\n branch: string | null | undefined,\n): string | undefined {\n if (typeof branch !== \"string\") {\n return undefined;\n }\n const trimmed = branch.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\n/**\n * Determines the branch a client should use.\n *\n * An explicitly supplied branch always wins, so application code and any\n * existing `fetch` or client overrides keep their current behavior. `null`\n * explicitly means \"no branch\", which is how a caller pins to the default\n * branch while checked out on a branch.\n *\n * `undefined` — including the `undefined` that a generated SDK's `$branch`\n * export carries when the SDK was generated against the default branch — falls\n * back to {@link FOUNDRY_BRANCH_RID_ENV_VAR}. That fallback is the point: a\n * repository checked out on a branch reads that branch's data even if its\n * generated SDK predates the checkout.\n *\n * @param explicitBranch - the branch supplied by the caller, if any\n * @param env - the environment to read from. Defaults to `import.meta.env`;\n * supply it to test without depending on the ambient environment.\n */\nexport function resolveBranch(\n explicitBranch: string | null | undefined,\n env: Record<string, string | undefined> | undefined = getImportMetaEnv(),\n): string | undefined {\n return explicitBranch !== undefined\n ? normalizeBranch(explicitBranch)\n : normalizeBranch(env?.[FOUNDRY_BRANCH_RID_ENV_VAR]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,0BAAkC,GAAG,yBAAyB;;AAE3E;AACA;AACA;AACA;AACA,SAASC,gBAAgBA,CAAA,EAAmD;EAC1E,OACEC,MAAM,CAACC,IAAI,CACXC,GAAG;AACP;;AAEA;AACA;AACA;AACA;AACA,SAASC,eAAeA,CACtBC,MAAiC,EACb;EACpB,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;IAC9B,OAAOC,SAAS;EAClB;EACA,MAAMC,OAAO,GAAGF,MAAM,CAACG,IAAI,CAAC,CAAC;EAC7B,OAAOD,OAAO,CAACE,MAAM,GAAG,CAAC,GAAGF,OAAO,GAAGD,SAAS;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,aAAaA,CAC3BC,cAAyC,EACzCR,GAAmD,GAAGH,gBAAgB,CAAC,CAAC,EACpD;EACpB,OAAOW,cAAc,KAAKL,SAAS,GAC/BF,eAAe,CAACO,cAAc,CAAC,GAC/BP,eAAe,CAACD,GAAG,GAAGJ,0BAA0B,CAAC,CAAC;AACxD","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkINZZEEZW_cjs = require('./chunk-INZZEEZW.cjs');
|
|
4
|
+
var chunkYM4REFZE_cjs = require('./chunk-YM4REFZE.cjs');
|
|
5
5
|
var chunkQ7QYW5NE_cjs = require('./chunk-Q7QYW5NE.cjs');
|
|
6
6
|
require('./chunk-Q7SFCCGT.cjs');
|
|
7
7
|
|
|
@@ -17,21 +17,21 @@ async function* applyStreamingQuery(client, query, params) {
|
|
|
17
17
|
if (client.flushEdits != null) {
|
|
18
18
|
await client.flushEdits();
|
|
19
19
|
}
|
|
20
|
-
const response = await streamingExecute(
|
|
20
|
+
const response = await streamingExecute(chunkYM4REFZE_cjs.addUserAgentAndRequestContextHeaders(chunkYM4REFZE_cjs.augmentRequestContext(client, (_) => ({
|
|
21
21
|
finalMethodCall: "applyStreamingQuery"
|
|
22
22
|
})), query), query.apiName, {
|
|
23
23
|
ontology: await client.ontologyRid,
|
|
24
|
-
parameters: params ? await
|
|
24
|
+
parameters: params ? await chunkINZZEEZW_cjs.remapQueryParams(params, client, qd.parameters) : {},
|
|
25
25
|
version: query.isFixedVersion ? query.version : void 0,
|
|
26
26
|
branch: client.branch
|
|
27
27
|
}, {
|
|
28
28
|
transactionId: client.transactionId,
|
|
29
29
|
preview: true
|
|
30
30
|
});
|
|
31
|
-
const definitions = await
|
|
31
|
+
const definitions = await chunkINZZEEZW_cjs.getRequiredDefinitions(qd.output, client);
|
|
32
32
|
for await (const event of response) {
|
|
33
33
|
if (event.type !== "data") continue;
|
|
34
|
-
const remapped = await
|
|
34
|
+
const remapped = await chunkINZZEEZW_cjs.remapQueryResponse(client, qd.output, event.value, definitions);
|
|
35
35
|
if (qd.output.type === "array" && Array.isArray(remapped)) {
|
|
36
36
|
for (const item of remapped) {
|
|
37
37
|
yield item;
|
|
@@ -43,5 +43,5 @@ async function* applyStreamingQuery(client, query, params) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
exports.applyStreamingQuery = applyStreamingQuery;
|
|
46
|
-
//# sourceMappingURL=applyStreamingQuery-
|
|
47
|
-
//# sourceMappingURL=applyStreamingQuery-
|
|
46
|
+
//# sourceMappingURL=applyStreamingQuery-P4Q3KDSJ.cjs.map
|
|
47
|
+
//# sourceMappingURL=applyStreamingQuery-P4Q3KDSJ.cjs.map
|