@osdk/client 0.17.0 → 0.17.1-main-20240503165126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/js/{chunk-JRMNN5VM.mjs → chunk-266YTVQ7.mjs} +251 -17
  3. package/build/js/chunk-266YTVQ7.mjs.map +1 -0
  4. package/build/js/{chunk-K7HWC7BJ.cjs → chunk-V6Z4RJSB.cjs} +253 -24
  5. package/build/js/chunk-V6Z4RJSB.cjs.map +1 -0
  6. package/build/js/{chunk-CMSW5WNH.browser.mjs → chunk-ZVBTVONX.browser.mjs} +251 -17
  7. package/build/js/chunk-ZVBTVONX.browser.mjs.map +1 -0
  8. package/build/js/index.browser.mjs +1 -256
  9. package/build/js/index.browser.mjs.map +1 -1
  10. package/build/js/index.cjs +7 -259
  11. package/build/js/index.cjs.map +1 -1
  12. package/build/js/index.mjs +1 -256
  13. package/build/js/index.mjs.map +1 -1
  14. package/build/js/{ObjectSetListenerWebsocket-SJQZYVQI.browser.mjs → public/unstable-do-not-use.browser.mjs} +122 -122
  15. package/build/js/public/unstable-do-not-use.browser.mjs.map +1 -0
  16. package/build/js/{ObjectSetListenerWebsocket-Q2PZKFQL.cjs → public/unstable-do-not-use.cjs} +130 -127
  17. package/build/js/public/unstable-do-not-use.cjs.map +1 -0
  18. package/build/js/{ObjectSetListenerWebsocket-YQBSLGBD.mjs → public/unstable-do-not-use.mjs} +122 -122
  19. package/build/js/public/unstable-do-not-use.mjs.map +1 -0
  20. package/build/types/Client.d.ts +8 -7
  21. package/build/types/Client.d.ts.map +1 -1
  22. package/build/types/MinimalClientContext.d.ts +2 -1
  23. package/build/types/MinimalClientContext.d.ts.map +1 -1
  24. package/build/types/UNSTABLE_createClient.d.ts +4 -0
  25. package/build/types/UNSTABLE_createClient.d.ts.map +1 -0
  26. package/build/types/UnstableClient.d.ts +11 -0
  27. package/build/types/UnstableClient.d.ts.map +1 -0
  28. package/build/types/createClient.d.ts +6 -1
  29. package/build/types/createClient.d.ts.map +1 -1
  30. package/build/types/createMinimalClient.d.ts +2 -1
  31. package/build/types/createMinimalClient.d.ts.map +1 -1
  32. package/build/types/generatedNoCheck/OntologyMetadata.d.ts +1 -1
  33. package/build/types/index.d.ts +2 -4
  34. package/build/types/index.d.ts.map +1 -1
  35. package/build/types/object/convertWireToOsdkObjects.d.ts.map +1 -1
  36. package/build/types/objectSet/ObjectSet.d.ts +1 -8
  37. package/build/types/objectSet/ObjectSet.d.ts.map +1 -1
  38. package/build/types/objectSet/ObjectSetFactory.d.ts +6 -0
  39. package/build/types/objectSet/ObjectSetFactory.d.ts.map +1 -0
  40. package/build/types/objectSet/conjureUnionType.d.ts +13 -0
  41. package/build/types/objectSet/conjureUnionType.d.ts.map +1 -0
  42. package/build/types/objectSet/createObjectSet.d.ts.map +1 -1
  43. package/build/types/objectSet/createUnstableObjectSet.d.ts +17 -0
  44. package/build/types/objectSet/createUnstableObjectSet.d.ts.map +1 -0
  45. package/build/types/objectSet/toConjureObjectSet.d.ts.map +1 -1
  46. package/build/types/public/unstable-do-not-use.d.ts +6 -0
  47. package/build/types/public/unstable-do-not-use.d.ts.map +1 -0
  48. package/package.json +3 -3
  49. package/build/js/ObjectSetListenerWebsocket-Q2PZKFQL.cjs.map +0 -1
  50. package/build/js/ObjectSetListenerWebsocket-SJQZYVQI.browser.mjs.map +0 -1
  51. package/build/js/ObjectSetListenerWebsocket-YQBSLGBD.mjs.map +0 -1
  52. package/build/js/chunk-CMSW5WNH.browser.mjs.map +0 -1
  53. package/build/js/chunk-JRMNN5VM.mjs.map +0 -1
  54. package/build/js/chunk-K7HWC7BJ.cjs.map +0 -1
@@ -1,259 +1,4 @@
1
- import { createObjectSet, createAsyncCache, addUserAgent, isAttachment, isWireObjectSet, isObjectSet, getWireObjectSet, getObjectTypeV2, listInterfaceTypes, loadAllOntologies, loadOntologyEntities, getInterfaceType, listOutgoingLinkTypesV2 } from './chunk-CMSW5WNH.browser.mjs';
2
- export { augment } from './chunk-CMSW5WNH.browser.mjs';
3
- import { createClientContext, omniFetch } from '@osdk/shared.net';
1
+ export { ActionValidationError, createClient } from './chunk-ZVBTVONX.browser.mjs';
4
2
  export { isOk } from '@osdk/shared.net';
5
- import { wireObjectTypeFullMetadataToSdkObjectTypeDefinition, __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from '@osdk/generator-converters';
6
- import deepEqual from 'fast-deep-equal';
7
- import invariant from 'tiny-invariant';
8
-
9
- // src/actions/ActionValidationError.ts
10
- var ActionValidationError = class extends Error {
11
- constructor(validation) {
12
- super("Validation Error");
13
- this.validation = validation;
14
- }
15
- };
16
- var _applyActionV2 = [1, "/v2/ontologies/{0}/actions/{1}/apply", 3];
17
- function applyActionV2($ctx, ...args) {
18
- return omniFetch($ctx, _applyActionV2, ...args);
19
- }
20
-
21
- // src/util/isOntologyObjectV2.ts
22
- function isOntologyObjectV2(o) {
23
- return o && typeof o === "object" && typeof o.__apiName === "string" && o.__primaryKey != null;
24
- }
25
-
26
- // src/util/toDataValue.ts
27
- function toDataValue(value) {
28
- if (value == null) {
29
- return value;
30
- }
31
- if (Array.isArray(value) || value instanceof Set) {
32
- return Array.from(value, toDataValue);
33
- }
34
- if (isAttachment(value)) {
35
- return value.rid;
36
- }
37
- if (isOntologyObjectV2(value)) {
38
- return toDataValue(value.__primaryKey);
39
- }
40
- if (isWireObjectSet(value)) {
41
- return value;
42
- }
43
- if (isObjectSet(value)) {
44
- return getWireObjectSet(value);
45
- }
46
- if (typeof value === "object") {
47
- return Object.entries(value).reduce((acc, [key, structValue]) => {
48
- acc[key] = toDataValue(structValue);
49
- return acc;
50
- }, {});
51
- }
52
- return value;
53
- }
54
-
55
- // src/actions/applyAction.ts
56
- async function applyAction(client, action, parameters, options = {}) {
57
- const response = await applyActionV2(addUserAgent(client, action), client.ontologyRid, action.apiName, {
58
- parameters: remapActionParams(parameters),
59
- options: {
60
- mode: options?.validateOnly ? "VALIDATE_ONLY" : "VALIDATE_AND_EXECUTE",
61
- returnEdits: options?.returnEdits ? "ALL" : "NONE"
62
- }
63
- });
64
- if (options?.validateOnly) {
65
- return response.validation;
66
- }
67
- if (response.validation?.result === "INVALID") {
68
- throw new ActionValidationError(response.validation);
69
- }
70
- return options?.returnEdits ? response.edits : void 0;
71
- }
72
- function remapActionParams(params) {
73
- if (params == null) {
74
- return {};
75
- }
76
- const parameterMap = {};
77
- const remappedParams = Object.entries(params).reduce((acc, [key, value]) => {
78
- acc[key] = toDataValue(value);
79
- return acc;
80
- }, parameterMap);
81
- return remappedParams;
82
- }
83
-
84
- // src/actions/createActionInvoker.ts
85
- function createActionInvoker(client, action) {
86
- return function(...args) {
87
- return applyAction(client, action, ...args);
88
- };
89
- }
90
- async function loadAllOutgoingLinkTypes(client, objtype) {
91
- const linkTypes = [];
92
- let pageToken;
93
- do {
94
- const result = await listOutgoingLinkTypesV2(client, client.ontologyRid, objtype, {
95
- pageToken
96
- });
97
- pageToken = result.nextPageToken;
98
- linkTypes.push(...result.data);
99
- } while (pageToken != null);
100
- return linkTypes;
101
- }
102
- function makeConjureContext(client, servicePath) {
103
- return {
104
- baseUrl: client.stack,
105
- servicePath,
106
- fetchFn: client.fetch,
107
- tokenProvider: async () => await client.tokenProvider()
108
- };
109
- }
110
- async function loadFullObjectMetadata(client, objtype) {
111
- const conjureCtx = makeConjureContext(client, "/ontology-metadata/api");
112
- const [objectType, linkTypes, interfaceTypes, metadata] = await Promise.all([getObjectTypeV2(client, client.ontologyRid, objtype), loadAllOutgoingLinkTypes(client, objtype), listInterfaceTypes(client, client.ontologyRid, {
113
- pageSize: 200,
114
- preview: true
115
- }), await loadAllOntologies(conjureCtx, {})]);
116
- const sharedPropertyTypeMapping = await loadSptMap(conjureCtx, metadata, client.ontologyRid, objectType.rid);
117
- const full = {
118
- implementsInterfaces: interfaceTypes.data.map((i) => i.apiName),
119
- linkTypes,
120
- objectType,
121
- sharedPropertyTypeMapping
122
- };
123
- return wireObjectTypeFullMetadataToSdkObjectTypeDefinition(full, true);
124
- }
125
- async function loadSptMap(ctx, ontologyMetadata, ontologyRid, objectRid) {
126
- const ontologyVersion = ontologyMetadata.ontologies[ontologyRid].currentOntologyVersion;
127
- const body = {
128
- objectTypeVersions: {
129
- [objectRid]: ontologyVersion
130
- },
131
- linkTypeVersions: {},
132
- loadRedacted: false,
133
- includeObjectTypesWithoutSearchableDatasources: true
134
- };
135
- const entities = await loadOntologyEntities(ctx, body);
136
- const objectType = entities.objectTypes[objectRid];
137
- !objectType ? process.env.NODE_ENV !== "production" ? invariant(false, "object type should be loaded") : invariant(false) : void 0;
138
- const sptMap = {};
139
- for (const property of Object.values(objectType.propertyTypes)) {
140
- if (property.sharedPropertyTypeApiName && property.apiName) {
141
- sptMap[property.sharedPropertyTypeApiName] = property.apiName;
142
- }
143
- }
144
- return sptMap;
145
- }
146
- async function loadInterfaceDefinition(client, objtype) {
147
- const r = await getInterfaceType(client, client.ontologyRid, objtype, {
148
- preview: true
149
- });
150
- return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);
151
- }
152
-
153
- // src/ontology/StandardOntologyProvider.ts
154
- var alwaysRevalidateDefault = false;
155
- var createStandardOntologyProviderFactory = (client) => {
156
- const alwaysRevalidate = client.alwaysRevalidate ?? alwaysRevalidateDefault;
157
- return (client2) => {
158
- async function loadObject(client3, key, skipCache = false) {
159
- {
160
- return await loadFullObjectMetadata(client3, key);
161
- }
162
- }
163
- async function loadInterface(client3, key, skipCache = false) {
164
- {
165
- return loadInterfaceDefinition(client3, key);
166
- }
167
- }
168
- function makeGetter(fn) {
169
- const cache = createAsyncCache((client3, key) => fn(client3, key, false));
170
- return async (apiName) => {
171
- const n = alwaysRevalidate ? await fn(client2, apiName, true) : await cache.get(client2, apiName);
172
- if (alwaysRevalidate) {
173
- const og = cache.getOrUndefined(client2, apiName);
174
- if (deepEqual(og, n)) {
175
- return og;
176
- } else {
177
- return cache.set(client2, apiName, n);
178
- }
179
- }
180
- return n;
181
- };
182
- }
183
- return {
184
- getObjectDefinition: makeGetter(loadObject),
185
- getInterfaceDefinition: makeGetter(loadInterface),
186
- maybeSeed(definition) {
187
- }
188
- };
189
- };
190
- };
191
-
192
- // src/util/UserAgent.ts
193
- var USER_AGENT = `osdk-client/${"0.17.0"}`;
194
-
195
- // src/createMinimalClient.ts
196
- function createMinimalClient(metadata, stack, tokenProvider, options = {}, fetchFn = global.fetch) {
197
- if (process?.env?.NODE_ENV !== "production") {
198
- try {
199
- new URL(stack);
200
- } catch (e) {
201
- const hint = !stack.startsWith("http://") || !stack.startsWith("https://") ? ". Did you forget to add 'http://' or 'https://'?" : "";
202
- throw new Error(`Invalid stack URL: ${stack}${hint}`);
203
- }
204
- }
205
- const clientCtx = {
206
- ...createClientContext({
207
- metadata
208
- }, stack, tokenProvider, USER_AGENT, fetchFn),
209
- ontologyRid: metadata.ontologyRid,
210
- ontologyProvider: void 0,
211
- logger: options.logger
212
- };
213
- clientCtx.ontologyProvider = createStandardOntologyProviderFactory(options)(clientCtx);
214
- return clientCtx;
215
- }
216
-
217
- // src/createClient.ts
218
- function createClient(stack, ontologyRid, tokenProvider, options = void 0, fetchFn = fetch) {
219
- const clientCtx = createMinimalClient({
220
- ontologyRid,
221
- userAgent: ""
222
- // ontology specific user agent injected elsewhere
223
- }, stack, tokenProvider, options, fetchFn);
224
- function clientFn(o) {
225
- if (o.type === "object" || o.type === "interface") {
226
- clientCtx.ontologyProvider.maybeSeed(o);
227
- return createObjectSet(o, clientCtx);
228
- } else if (o.type === "action") {
229
- clientCtx.ontologyProvider.maybeSeed(o);
230
- return createActionInvoker(clientCtx, o);
231
- } else {
232
- throw new Error("not implemented");
233
- }
234
- }
235
- const client = Object.defineProperties(clientFn, {
236
- __UNSTABLE_preexistingObjectSet: {
237
- get: () => (definition, rid) => {
238
- return createObjectSet(definition, clientCtx, {
239
- type: "intersect",
240
- objectSets: [{
241
- type: "base",
242
- objectType: definition.apiName
243
- }, {
244
- type: "reference",
245
- reference: rid
246
- }]
247
- });
248
- }
249
- },
250
- ctx: {
251
- value: clientCtx
252
- }
253
- });
254
- return client;
255
- }
256
-
257
- export { ActionValidationError, createClient };
258
3
  //# sourceMappingURL=out.js.map
259
4
  //# sourceMappingURL=index.browser.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/actions/ActionValidationError.ts","../../../foundry/build/js/public/OntologiesV2_Action.mjs","../../src/util/isOntologyObjectV2.ts","../../src/util/toDataValue.ts","../../src/actions/applyAction.ts","../../src/actions/createActionInvoker.ts","../../src/createMinimalClient.ts","../../../foundry/build/js/public/OntologiesV2_OntologyV2.mjs","../../src/ontology/StandardOntologyProvider.ts","../../src/ontology/loadFullObjectMetadata.ts","../../src/ontology/loadInterfaceDefinition.ts","../../src/util/UserAgent.ts","../../src/createClient.ts"],"names":["omniFetch","__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition","wireObjectTypeFullMetadataToSdkObjectTypeDefinition","client"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,SAAS,YAAY;;;ACAd,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC/C,YAAY,YAAY;AACtB,UAAM,kBAAkB;AACxB,SAAK,aAAa;AAAA,EACpB;AACF;;;ACrBA,SAAS,iBAAiB;AAG1B,IAAI,iBAAiB,CAAC,GAAG,wCAAwC,CAAC;AAClE,SAAS,cAAc,SAAS,MAAM;AACpC,SAAO,UAAU,MAAM,gBAAgB,GAAG,IAAI;AAChD;;;ACUO,SAAS,mBAAmB,GAAG;AACpC,SAAO,KAAK,OAAO,MAAM,YAAY,OAAO,EAAE,cAAc,YAAY,EAAE,gBAAgB;AAC5F;;;ACQO,SAAS,YAAY,OAAO;AACjC,MAAI,SAAS,MAAM;AAEjB,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQ,KAAK,KAAK,iBAAiB,KAAK;AAChD,WAAO,MAAM,KAAK,OAAO,WAAW;AAAA,EACtC;AAGA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AU,CAAC;AACtC,aAAO,oBAAoB,WAAW,CAAC;AAAA,IACzC,OAAO;AACL,YAAM,IAAI,MAAM,iBAAiB;AAAA,IACnC;AAAA,EACF;AACA,QAAM,SAAS,OAAO,iBAAiB,UAAU;AAAA,IAC/C,iCAAiC;AAAA,MAC/B,KAAK,MAAM,CAAC,YAAY,QAAQ;AAC9B,eAAO,gBAAgB,YAAY,WAAW;AAAA,UAC5C,MAAM;AAAA,UACN,YAAY,CAAC;AAAA,YACX,MAAM;AAAA,YACN,YAAY,WAAW;AAAA,UACzB,GAAG;AAAA,YACD,MAAM;AAAA,YACN,WAAW;AAAA,UACb,CAAC;AAAA,QACH,CAAC;AAAA,MACH;AAAA,IACF;AAAA,IACA,KAAK;AAAA,MACH,OAAO;AAAA,IACT;AAAA,EACF,CAAC;AACD,SAAO;AACT","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 { isOk } from \"@osdk/shared.net\";\nexport { ActionValidationError } from \"./actions/ActionValidationError.js\";\nexport { createClient } from \"./createClient.js\";\nexport { augment } from \"./object/fetchPage.js\";","/*\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 class ActionValidationError extends Error {\n constructor(validation) {\n super(\"Validation Error\");\n this.validation = validation;\n }\n}","import { omniFetch } from '@osdk/shared.net';\n\n// src/public/OntologiesV2_Action.ts\nvar _applyActionV2 = [1, \"/v2/ontologies/{0}/actions/{1}/apply\", 3];\nfunction applyActionV2($ctx, ...args) {\n return omniFetch($ctx, _applyActionV2, ...args);\n}\nvar _applyActionBatchV2 = [1, \"/v2/ontologies/{0}/actions/{1}/applyBatch\", 3];\nfunction applyActionBatchV2($ctx, ...args) {\n return omniFetch($ctx, _applyActionBatchV2, ...args);\n}\nvar _applyActionAsyncV2 = [1, \"/v2/ontologies/{0}/actions/{1}/applyAsync\", 3];\nfunction applyActionAsyncV2($ctx, ...args) {\n return omniFetch($ctx, _applyActionAsyncV2, ...args);\n}\nexport { applyActionAsyncV2, applyActionBatchV2, applyActionV2 };","/*\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 function isOntologyObjectV2(o) {\n return o && typeof o === \"object\" && typeof o.__apiName === \"string\" && o.__primaryKey != null;\n}","/*\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 { isAttachment } from \"../object/Attachment.js\";\nimport { getWireObjectSet, isObjectSet } from \"../objectSet/createObjectSet.js\";\nimport { isOntologyObjectV2 } from \"./isOntologyObjectV2.js\";\nimport { isWireObjectSet } from \"./WireObjectSet.js\";\n\n/**\n * Marshall user-facing data into the wire DataValue type\n *\n * @see DataValue for the expected payloads\n */\nexport function toDataValue(value) {\n if (value == null) {\n // typeof null is 'object' so do this first\n return value;\n }\n\n // arrays and sets are both sent over the wire as arrays\n if (Array.isArray(value) || value instanceof Set) {\n return Array.from(value, toDataValue);\n }\n\n // attachments just send the rid directly\n if (isAttachment(value)) {\n return value.rid;\n }\n\n // objects just send the JSON'd primaryKey\n if (isOntologyObjectV2(value)) {\n return toDataValue(value.__primaryKey);\n }\n\n // object set (the rid as a string (passes through the last return), or the ObjectSet definition directly)\n if (isWireObjectSet(value)) {\n return value;\n }\n if (isObjectSet(value)) {\n return getWireObjectSet(value);\n }\n\n // TODO (during queries implementation)\n // two dimensional aggregation\n // three dimensional aggregation\n\n // struct\n if (typeof value === \"object\") {\n return Object.entries(value).reduce((acc, [key, structValue]) => {\n acc[key] = toDataValue(structValue);\n return acc;\n }, {});\n }\n\n // expected to pass through - boolean, byte, date, decimal, float, double, integer, long, short, string, timestamp\n return value;\n}","/*\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 { applyActionV2 } from \"@osdk/foundry/OntologiesV2_Action\";\nimport { addUserAgent } from \"../util/addUserAgent.js\";\nimport { toDataValue } from \"../util/toDataValue.js\";\nimport { ActionValidationError } from \"./ActionValidationError.js\";\n\n// cannot specify both validateOnly and returnEdits as true\n\nexport async function applyAction(client, action, parameters, options = {}) {\n const response = await applyActionV2(addUserAgent(client, action), client.ontologyRid, action.apiName, {\n parameters: remapActionParams(parameters),\n options: {\n mode: options?.validateOnly ? \"VALIDATE_ONLY\" : \"VALIDATE_AND_EXECUTE\",\n returnEdits: options?.returnEdits ? \"ALL\" : \"NONE\"\n }\n });\n if (options?.validateOnly) {\n return response.validation;\n }\n if (response.validation?.result === \"INVALID\") {\n throw new ActionValidationError(response.validation);\n }\n return options?.returnEdits ? response.edits : undefined;\n}\nfunction remapActionParams(params) {\n if (params == null) {\n return {};\n }\n const parameterMap = {};\n const remappedParams = Object.entries(params).reduce((acc, [key, value]) => {\n acc[key] = toDataValue(value);\n return acc;\n }, parameterMap);\n return remappedParams;\n}","/*\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 { applyAction } from \"./applyAction.js\";\nexport function createActionInvoker(client, action) {\n return function (...args) {\n return applyAction(client, action, ...args);\n };\n}\nexport function createOldActionInvoker(client, ontology) {\n const proxy = new Proxy({}, {\n get: (_target, p, _receiver) => {\n if (typeof p === \"string\") {\n return createActionInvoker(client, ontology.actions[p]);\n }\n return undefined;\n },\n ownKeys(_target) {\n return Object.keys(ontology.actions);\n },\n getOwnPropertyDescriptor(_target, p) {\n if (typeof p === \"string\") {\n return {\n enumerable: ontology.actions[p] != null,\n configurable: true,\n value: proxy[p]\n };\n }\n }\n });\n return proxy;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { createClientContext } from \"@osdk/shared.net\";\nimport { createStandardOntologyProviderFactory } from \"./ontology/StandardOntologyProvider.js\";\nimport { USER_AGENT } from \"./util/UserAgent.js\";\nexport function createMinimalClient(metadata, stack, tokenProvider, options = {}, fetchFn = global.fetch) {\n if (process?.env?.NODE_ENV !== \"production\") {\n try {\n new URL(stack);\n } catch (e) {\n const hint = !stack.startsWith(\"http://\") || !stack.startsWith(\"https://\") ? \". Did you forget to add 'http://' or 'https://'?\" : \"\";\n throw new Error(`Invalid stack URL: ${stack}${hint}`);\n }\n }\n const clientCtx = {\n ...createClientContext({\n metadata\n }, stack, tokenProvider, USER_AGENT, fetchFn),\n ontologyRid: metadata.ontologyRid,\n ontologyProvider: undefined,\n logger: options.logger\n };\n clientCtx.ontologyProvider = createStandardOntologyProviderFactory(options)(clientCtx);\n return clientCtx;\n}","import { omniFetch } from '@osdk/shared.net';\n\n// src/public/OntologiesV2_OntologyV2.ts\nvar _listOntologiesV2 = [0, \"/v2/ontologies\"];\nfunction listOntologiesV2($ctx, ...args) {\n return omniFetch($ctx, _listOntologiesV2, ...args);\n}\nvar _getOntologyV2 = [0, \"/v2/ontologies/{0}\"];\nfunction getOntologyV2($ctx, ...args) {\n return omniFetch($ctx, _getOntologyV2, ...args);\n}\nvar _getOntologyFullMetadata = [0, \"/v2/ontologies/{0}/fullMetadata\"];\nfunction getOntologyFullMetadata($ctx, ...args) {\n return omniFetch($ctx, _getOntologyFullMetadata, ...args);\n}\nexport { getOntologyFullMetadata, getOntologyV2, listOntologiesV2 };","/*\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 { listInterfaceTypes } from \"@osdk/foundry/OntologiesV2_OntologyObjectV2\";\nimport { getOntologyFullMetadata } from \"@osdk/foundry/OntologiesV2_OntologyV2\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition, wireObjectTypeFullMetadataToSdkObjectTypeDefinition } from \"@osdk/generator-converters\";\nimport deepEqual from \"fast-deep-equal\";\nimport { createAsyncCache } from \"../object/Cache.js\";\nimport { loadFullObjectMetadata } from \"./loadFullObjectMetadata.js\";\nimport { loadInterfaceDefinition } from \"./loadInterfaceDefinition.js\";\nconst alwaysRevalidateDefault = false;\n\n// SLLLLLLOOOOOOOWWWW\nasync function fullOntologyLoad(client) {\n return await Promise.all([listInterfaceTypes(client, client.ontologyRid, {\n pageSize: 200,\n preview: true\n }), getOntologyFullMetadata(client, client.ontologyRid)]);\n}\nexport const USE_FULL_ONTOLOGY = false;\nexport const createStandardOntologyProviderFactory = client => {\n const alwaysRevalidate = client.alwaysRevalidate ?? alwaysRevalidateDefault;\n return client => {\n let fullCache;\n async function initLocalCache(client, skipCache) {\n if (skipCache) {\n return await fullOntologyLoad(client);\n }\n if (!fullCache) {\n fullCache = fullOntologyLoad(client);\n }\n return await fullCache;\n }\n async function loadObject(client, key, skipCache = false) {\n if (USE_FULL_ONTOLOGY) {\n const fullCacheLocal = await initLocalCache(client, skipCache);\n return {\n ...wireObjectTypeFullMetadataToSdkObjectTypeDefinition(fullCacheLocal[1].objectTypes[key], true),\n implements: fullCacheLocal[0].data.map(i => i.apiName)\n };\n } else {\n return await loadFullObjectMetadata(client, key);\n }\n }\n async function loadInterface(client, key, skipCache = false) {\n if (USE_FULL_ONTOLOGY) {\n const fullCacheLocal = await initLocalCache(client, skipCache);\n return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(fullCacheLocal[1].interfaceTypes[key], true);\n } else {\n return loadInterfaceDefinition(client, key);\n }\n }\n function makeGetter(fn) {\n const cache = createAsyncCache((client, key) => fn(client, key, false));\n return async apiName => {\n const n = alwaysRevalidate ? await fn(client, apiName, true) : await cache.get(client, apiName);\n if (alwaysRevalidate) {\n const og = cache.getOrUndefined(client, apiName);\n if (deepEqual(og, n)) {\n return og; // ! because we can be sure `n` would throw if it were undefined\n } else {\n return cache.set(client, apiName, n);\n }\n }\n return n;\n };\n }\n return {\n getObjectDefinition: makeGetter(loadObject),\n getInterfaceDefinition: makeGetter(loadInterface),\n maybeSeed(definition) {\n // not using this for now\n }\n };\n };\n};","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getObjectTypeV2, listOutgoingLinkTypesV2 } from \"@osdk/foundry/OntologiesV2_ObjectTypeV2\";\nimport { listInterfaceTypes } from \"@osdk/foundry/OntologiesV2_OntologyObjectV2\";\nimport { wireObjectTypeFullMetadataToSdkObjectTypeDefinition } from \"@osdk/generator-converters\";\nimport invariant from \"tiny-invariant\";\nimport { loadAllOntologies } from \"../generated/ontology-metadata/api/OntologyMetadataService/loadAllOntologies.js\";\nimport { loadOntologyEntities } from \"../generated/ontology-metadata/api/OntologyMetadataService/loadOntologyEntities.js\";\nasync function loadAllOutgoingLinkTypes(client, objtype) {\n const linkTypes = [];\n let pageToken;\n do {\n const result = await listOutgoingLinkTypesV2(client, client.ontologyRid, objtype, {\n pageToken\n });\n pageToken = result.nextPageToken;\n linkTypes.push(...result.data);\n } while (pageToken != null);\n return linkTypes;\n}\nfunction makeConjureContext(client, servicePath) {\n return {\n baseUrl: client.stack,\n servicePath,\n fetchFn: client.fetch,\n tokenProvider: async () => await client.tokenProvider()\n };\n}\nexport async function loadFullObjectMetadata(client, objtype) {\n const conjureCtx = makeConjureContext(client, \"/ontology-metadata/api\");\n const [objectType, linkTypes, interfaceTypes, metadata] = await Promise.all([getObjectTypeV2(client, client.ontologyRid, objtype), loadAllOutgoingLinkTypes(client, objtype), listInterfaceTypes(client, client.ontologyRid, {\n pageSize: 200,\n preview: true\n }), await loadAllOntologies(conjureCtx, {})]);\n const sharedPropertyTypeMapping = await loadSptMap(conjureCtx, metadata, client.ontologyRid, objectType.rid);\n const full = {\n implementsInterfaces: interfaceTypes.data.map(i => i.apiName),\n linkTypes,\n objectType,\n sharedPropertyTypeMapping\n };\n\n // TODO: reuse the loaded interface data!\n return wireObjectTypeFullMetadataToSdkObjectTypeDefinition(full, true);\n}\nasync function loadSptMap(ctx, ontologyMetadata, ontologyRid, objectRid) {\n const ontologyVersion = ontologyMetadata.ontologies[ontologyRid].currentOntologyVersion;\n const body = {\n objectTypeVersions: {\n [objectRid]: ontologyVersion\n },\n linkTypeVersions: {},\n loadRedacted: false,\n includeObjectTypesWithoutSearchableDatasources: true\n };\n const entities = await loadOntologyEntities(ctx, body);\n const objectType = entities.objectTypes[objectRid];\n !objectType ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"object type should be loaded\") : invariant(false) : void 0;\n const sptMap = {};\n for (const property of Object.values(objectType.propertyTypes)) {\n if (property.sharedPropertyTypeApiName && property.apiName) {\n sptMap[property.sharedPropertyTypeApiName] = property.apiName;\n }\n }\n return sptMap;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getInterfaceType } from \"@osdk/foundry/OntologiesV2_OntologyObjectV2\";\nimport { __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from \"@osdk/generator-converters\";\nexport async function loadInterfaceDefinition(client, objtype) {\n const r = await getInterfaceType(client, client.ontologyRid, objtype, {\n preview: true\n });\n return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);\n}","/*\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 = `osdk-client/${process.env.PACKAGE_VERSION}`;","/*\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 { createActionInvoker } from \"./actions/createActionInvoker.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nexport function createClient(stack, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {\n const clientCtx = createMinimalClient({\n ontologyRid,\n userAgent: \"\" // ontology specific user agent injected elsewhere\n }, stack, tokenProvider, options, fetchFn);\n function clientFn(o) {\n if (o.type === \"object\" || o.type === \"interface\") {\n clientCtx.ontologyProvider.maybeSeed(o);\n return createObjectSet(o, clientCtx);\n } else if (o.type === \"action\") {\n clientCtx.ontologyProvider.maybeSeed(o);\n return createActionInvoker(clientCtx, o);\n } else {\n throw new Error(\"not implemented\");\n }\n }\n const client = Object.defineProperties(clientFn, {\n __UNSTABLE_preexistingObjectSet: {\n get: () => (definition, rid) => {\n return createObjectSet(definition, clientCtx, {\n type: \"intersect\",\n objectSets: [{\n type: \"base\",\n objectType: definition.apiName\n }, {\n type: \"reference\",\n reference: rid\n }]\n });\n }\n },\n ctx: {\n value: clientCtx\n }\n });\n return client;\n}"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAiBA,SAAS,YAAY","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 { createClient } from \"./createClient.js\";\nexport { isOk } from \"@osdk/shared.net\";\nexport { ActionValidationError } from \"./actions/ActionValidationError.js\";"]}
@@ -1,273 +1,21 @@
1
1
  'use strict';
2
2
 
3
- var chunkK7HWC7BJ_cjs = require('./chunk-K7HWC7BJ.cjs');
3
+ var chunkV6Z4RJSB_cjs = require('./chunk-V6Z4RJSB.cjs');
4
4
  var shared_net = require('@osdk/shared.net');
5
- var generatorConverters = require('@osdk/generator-converters');
6
- var deepEqual = require('fast-deep-equal');
7
- var invariant = require('tiny-invariant');
8
5
 
9
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
6
 
11
- var deepEqual__default = /*#__PURE__*/_interopDefault(deepEqual);
12
- var invariant__default = /*#__PURE__*/_interopDefault(invariant);
13
7
 
14
- // src/actions/ActionValidationError.ts
15
- var ActionValidationError = class extends Error {
16
- constructor(validation) {
17
- super("Validation Error");
18
- this.validation = validation;
19
- }
20
- };
21
- var _applyActionV2 = [1, "/v2/ontologies/{0}/actions/{1}/apply", 3];
22
- function applyActionV2($ctx, ...args) {
23
- return shared_net.omniFetch($ctx, _applyActionV2, ...args);
24
- }
25
-
26
- // src/util/isOntologyObjectV2.ts
27
- function isOntologyObjectV2(o) {
28
- return o && typeof o === "object" && typeof o.__apiName === "string" && o.__primaryKey != null;
29
- }
30
-
31
- // src/util/toDataValue.ts
32
- function toDataValue(value) {
33
- if (value == null) {
34
- return value;
35
- }
36
- if (Array.isArray(value) || value instanceof Set) {
37
- return Array.from(value, toDataValue);
38
- }
39
- if (chunkK7HWC7BJ_cjs.isAttachment(value)) {
40
- return value.rid;
41
- }
42
- if (isOntologyObjectV2(value)) {
43
- return toDataValue(value.__primaryKey);
44
- }
45
- if (chunkK7HWC7BJ_cjs.isWireObjectSet(value)) {
46
- return value;
47
- }
48
- if (chunkK7HWC7BJ_cjs.isObjectSet(value)) {
49
- return chunkK7HWC7BJ_cjs.getWireObjectSet(value);
50
- }
51
- if (typeof value === "object") {
52
- return Object.entries(value).reduce((acc, [key, structValue]) => {
53
- acc[key] = toDataValue(structValue);
54
- return acc;
55
- }, {});
56
- }
57
- return value;
58
- }
59
-
60
- // src/actions/applyAction.ts
61
- async function applyAction(client, action, parameters, options = {}) {
62
- const response = await applyActionV2(chunkK7HWC7BJ_cjs.addUserAgent(client, action), client.ontologyRid, action.apiName, {
63
- parameters: remapActionParams(parameters),
64
- options: {
65
- mode: options?.validateOnly ? "VALIDATE_ONLY" : "VALIDATE_AND_EXECUTE",
66
- returnEdits: options?.returnEdits ? "ALL" : "NONE"
67
- }
68
- });
69
- if (options?.validateOnly) {
70
- return response.validation;
71
- }
72
- if (response.validation?.result === "INVALID") {
73
- throw new ActionValidationError(response.validation);
74
- }
75
- return options?.returnEdits ? response.edits : void 0;
76
- }
77
- function remapActionParams(params) {
78
- if (params == null) {
79
- return {};
80
- }
81
- const parameterMap = {};
82
- const remappedParams = Object.entries(params).reduce((acc, [key, value]) => {
83
- acc[key] = toDataValue(value);
84
- return acc;
85
- }, parameterMap);
86
- return remappedParams;
87
- }
88
-
89
- // src/actions/createActionInvoker.ts
90
- function createActionInvoker(client, action) {
91
- return function(...args) {
92
- return applyAction(client, action, ...args);
93
- };
94
- }
95
- async function loadAllOutgoingLinkTypes(client, objtype) {
96
- const linkTypes = [];
97
- let pageToken;
98
- do {
99
- const result = await chunkK7HWC7BJ_cjs.listOutgoingLinkTypesV2(client, client.ontologyRid, objtype, {
100
- pageToken
101
- });
102
- pageToken = result.nextPageToken;
103
- linkTypes.push(...result.data);
104
- } while (pageToken != null);
105
- return linkTypes;
106
- }
107
- function makeConjureContext(client, servicePath) {
108
- return {
109
- baseUrl: client.stack,
110
- servicePath,
111
- fetchFn: client.fetch,
112
- tokenProvider: async () => await client.tokenProvider()
113
- };
114
- }
115
- async function loadFullObjectMetadata(client, objtype) {
116
- const conjureCtx = makeConjureContext(client, "/ontology-metadata/api");
117
- const [objectType, linkTypes, interfaceTypes, metadata] = await Promise.all([chunkK7HWC7BJ_cjs.getObjectTypeV2(client, client.ontologyRid, objtype), loadAllOutgoingLinkTypes(client, objtype), chunkK7HWC7BJ_cjs.listInterfaceTypes(client, client.ontologyRid, {
118
- pageSize: 200,
119
- preview: true
120
- }), await chunkK7HWC7BJ_cjs.loadAllOntologies(conjureCtx, {})]);
121
- const sharedPropertyTypeMapping = await loadSptMap(conjureCtx, metadata, client.ontologyRid, objectType.rid);
122
- const full = {
123
- implementsInterfaces: interfaceTypes.data.map((i) => i.apiName),
124
- linkTypes,
125
- objectType,
126
- sharedPropertyTypeMapping
127
- };
128
- return generatorConverters.wireObjectTypeFullMetadataToSdkObjectTypeDefinition(full, true);
129
- }
130
- async function loadSptMap(ctx, ontologyMetadata, ontologyRid, objectRid) {
131
- const ontologyVersion = ontologyMetadata.ontologies[ontologyRid].currentOntologyVersion;
132
- const body = {
133
- objectTypeVersions: {
134
- [objectRid]: ontologyVersion
135
- },
136
- linkTypeVersions: {},
137
- loadRedacted: false,
138
- includeObjectTypesWithoutSearchableDatasources: true
139
- };
140
- const entities = await chunkK7HWC7BJ_cjs.loadOntologyEntities(ctx, body);
141
- const objectType = entities.objectTypes[objectRid];
142
- !objectType ? process.env.NODE_ENV !== "production" ? invariant__default.default(false, "object type should be loaded") : invariant__default.default(false) : void 0;
143
- const sptMap = {};
144
- for (const property of Object.values(objectType.propertyTypes)) {
145
- if (property.sharedPropertyTypeApiName && property.apiName) {
146
- sptMap[property.sharedPropertyTypeApiName] = property.apiName;
147
- }
148
- }
149
- return sptMap;
150
- }
151
- async function loadInterfaceDefinition(client, objtype) {
152
- const r = await chunkK7HWC7BJ_cjs.getInterfaceType(client, client.ontologyRid, objtype, {
153
- preview: true
154
- });
155
- return generatorConverters.__UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);
156
- }
157
-
158
- // src/ontology/StandardOntologyProvider.ts
159
- var alwaysRevalidateDefault = false;
160
- var createStandardOntologyProviderFactory = (client) => {
161
- const alwaysRevalidate = client.alwaysRevalidate ?? alwaysRevalidateDefault;
162
- return (client2) => {
163
- async function loadObject(client3, key, skipCache = false) {
164
- {
165
- return await loadFullObjectMetadata(client3, key);
166
- }
167
- }
168
- async function loadInterface(client3, key, skipCache = false) {
169
- {
170
- return loadInterfaceDefinition(client3, key);
171
- }
172
- }
173
- function makeGetter(fn) {
174
- const cache = chunkK7HWC7BJ_cjs.createAsyncCache((client3, key) => fn(client3, key, false));
175
- return async (apiName) => {
176
- const n = alwaysRevalidate ? await fn(client2, apiName, true) : await cache.get(client2, apiName);
177
- if (alwaysRevalidate) {
178
- const og = cache.getOrUndefined(client2, apiName);
179
- if (deepEqual__default.default(og, n)) {
180
- return og;
181
- } else {
182
- return cache.set(client2, apiName, n);
183
- }
184
- }
185
- return n;
186
- };
187
- }
188
- return {
189
- getObjectDefinition: makeGetter(loadObject),
190
- getInterfaceDefinition: makeGetter(loadInterface),
191
- maybeSeed(definition) {
192
- }
193
- };
194
- };
195
- };
196
-
197
- // src/util/UserAgent.ts
198
- var USER_AGENT = `osdk-client/${"0.17.0"}`;
199
-
200
- // src/createMinimalClient.ts
201
- function createMinimalClient(metadata, stack, tokenProvider, options = {}, fetchFn = global.fetch) {
202
- if (process?.env?.NODE_ENV !== "production") {
203
- try {
204
- new URL(stack);
205
- } catch (e) {
206
- const hint = !stack.startsWith("http://") || !stack.startsWith("https://") ? ". Did you forget to add 'http://' or 'https://'?" : "";
207
- throw new Error(`Invalid stack URL: ${stack}${hint}`);
208
- }
209
- }
210
- const clientCtx = {
211
- ...shared_net.createClientContext({
212
- metadata
213
- }, stack, tokenProvider, USER_AGENT, fetchFn),
214
- ontologyRid: metadata.ontologyRid,
215
- ontologyProvider: void 0,
216
- logger: options.logger
217
- };
218
- clientCtx.ontologyProvider = createStandardOntologyProviderFactory(options)(clientCtx);
219
- return clientCtx;
220
- }
221
-
222
- // src/createClient.ts
223
- function createClient(stack, ontologyRid, tokenProvider, options = void 0, fetchFn = fetch) {
224
- const clientCtx = createMinimalClient({
225
- ontologyRid,
226
- userAgent: ""
227
- // ontology specific user agent injected elsewhere
228
- }, stack, tokenProvider, options, fetchFn);
229
- function clientFn(o) {
230
- if (o.type === "object" || o.type === "interface") {
231
- clientCtx.ontologyProvider.maybeSeed(o);
232
- return chunkK7HWC7BJ_cjs.createObjectSet(o, clientCtx);
233
- } else if (o.type === "action") {
234
- clientCtx.ontologyProvider.maybeSeed(o);
235
- return createActionInvoker(clientCtx, o);
236
- } else {
237
- throw new Error("not implemented");
238
- }
239
- }
240
- const client = Object.defineProperties(clientFn, {
241
- __UNSTABLE_preexistingObjectSet: {
242
- get: () => (definition, rid) => {
243
- return chunkK7HWC7BJ_cjs.createObjectSet(definition, clientCtx, {
244
- type: "intersect",
245
- objectSets: [{
246
- type: "base",
247
- objectType: definition.apiName
248
- }, {
249
- type: "reference",
250
- reference: rid
251
- }]
252
- });
253
- }
254
- },
255
- ctx: {
256
- value: clientCtx
257
- }
258
- });
259
- return client;
260
- }
261
-
262
- Object.defineProperty(exports, 'augment', {
8
+ Object.defineProperty(exports, 'ActionValidationError', {
9
+ enumerable: true,
10
+ get: function () { return chunkV6Z4RJSB_cjs.ActionValidationError; }
11
+ });
12
+ Object.defineProperty(exports, 'createClient', {
263
13
  enumerable: true,
264
- get: function () { return chunkK7HWC7BJ_cjs.augment; }
14
+ get: function () { return chunkV6Z4RJSB_cjs.createClient; }
265
15
  });
266
16
  Object.defineProperty(exports, 'isOk', {
267
17
  enumerable: true,
268
18
  get: function () { return shared_net.isOk; }
269
19
  });
270
- exports.ActionValidationError = ActionValidationError;
271
- exports.createClient = createClient;
272
20
  //# sourceMappingURL=out.js.map
273
21
  //# sourceMappingURL=index.cjs.map