@osdk/client 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/build/js/{chunk-MT2HE6AQ.mjs → chunk-DVD5PAXO.mjs} +119 -8
- package/build/js/chunk-DVD5PAXO.mjs.map +1 -0
- package/build/js/{chunk-CCKGGMYW.cjs → chunk-YVZITKIQ.cjs} +117 -6
- package/build/js/chunk-YVZITKIQ.cjs.map +1 -0
- package/build/js/index.cjs +15 -13
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +12 -10
- package/build/js/index.mjs.map +1 -1
- package/build/js/public/objects.cjs +3 -3
- package/build/js/public/objects.mjs +1 -1
- package/build/types/Client.d.ts +2 -2
- package/build/types/Definitions.d.ts +4 -4
- package/build/types/OsdkObjectFrom.d.ts +2 -0
- package/build/types/definitions/LinkDefinitions.d.ts +19 -0
- package/build/types/definitions/LinkDefinitions.test.d.ts +1 -0
- package/build/types/generated/object-set-service/api/ObjectSetServiceV2/getLinks.d.ts +1 -1
- package/build/types/generated/ontology-metadata/api/GetFeatureConfigurationsResponse.d.ts +1 -0
- package/build/types/generated/ontology-metadata/api/OntologyMetadataGothamTypeMappingService/checkTranslationEligibility.d.ts +8 -0
- package/build/types/generated/ontology-metadata/api/OntologyMetadataGothamTypeMappingService.d.ts +1 -0
- package/build/types/generated/ontology-metadata/api/TypeGroupGetOrganizationsRequest.d.ts +7 -0
- package/build/types/generated/ontology-metadata/api/TypeGroupGetOrganizationsResponse.d.ts +9 -0
- package/build/types/generated/ontology-metadata/api/TypeGroupOrgsService/getOrganizationsForTypeGroups.d.ts +9 -0
- package/build/types/generated/ontology-metadata/api/TypeGroupOrgsService/setOrganizationsForTypeGroups.d.ts +9 -0
- package/build/types/generated/ontology-metadata/api/TypeGroupOrgsService.d.ts +2 -0
- package/build/types/generated/ontology-metadata/api/TypeGroupSetOrganizationsRequest.d.ts +11 -0
- package/build/types/generated/ontology-metadata/api/index.d.ts +4 -0
- package/build/types/generated/ontology-metadata/api/search/ActionTypeClause.d.ts +5 -1
- package/build/types/generated/ontology-metadata/api/typemapping/CaseSensitiveGothamObjectTypeUri.d.ts +6 -0
- package/build/types/generated/ontology-metadata/api/typemapping/CaseSensitiveGothamPropertyTypeUri.d.ts +6 -0
- package/build/types/generated/ontology-metadata/api/typemapping/CheckTranslationEligibilityRequest.d.ts +8 -0
- package/build/types/generated/ontology-metadata/api/typemapping/CheckTranslationEligibilityResponse.d.ts +7 -0
- package/build/types/generated/ontology-metadata/api/typemapping/ClientTranslationEligibilityResult.d.ts +10 -0
- package/build/types/generated/ontology-metadata/api/typemapping/GothamDatasourceDelegateId.d.ts +5 -0
- package/build/types/generated/ontology-metadata/api/typemapping/IntegrationClientType.d.ts +4 -0
- package/build/types/generated/ontology-metadata/api/typemapping/LoadGothamTypeInstallationStatusesResponse.d.ts +4 -4
- package/build/types/generated/ontology-metadata/api/typemapping/TranslatableDatasource.d.ts +5 -0
- package/build/types/generated/ontology-metadata/api/typemapping/TranslationEligibility.d.ts +11 -0
- package/build/types/generated/ontology-metadata/api/typemapping/UntranslatableSecurity.d.ts +7 -0
- package/build/types/generated/ontology-metadata/api/typemapping/UntranslatableSecurityFailureType.d.ts +1 -0
- package/build/types/generated/ontology-metadata/api/typemapping/index.d.ts +11 -0
- package/build/types/generated/ontology-metadata/branch/api/BranchStatus.d.ts +11 -1
- package/build/types/generated/ontology-metadata/branch/api/LoadOntologyBranchMarkingsRequest.d.ts +2 -0
- package/build/types/generated/ontology-metadata/branch/api/LoadOntologyBranchMarkingsResponse.d.ts +4 -0
- package/build/types/generated/ontology-metadata/branch/api/MediaReferencePropertyTypeConstraintError.d.ts +9 -0
- package/build/types/generated/ontology-metadata/branch/api/MediaReferencePropertyTypeHasNoDatasourcesError.d.ts +9 -0
- package/build/types/generated/ontology-metadata/branch/api/OntologyBranchService/loadOntologyBranchMarkings.d.ts +9 -0
- package/build/types/generated/ontology-metadata/branch/api/OntologyBranchService/setOntologyBranchOrganizationMarkings.d.ts +2 -2
- package/build/types/generated/ontology-metadata/branch/api/OntologyBranchService.d.ts +1 -0
- package/build/types/generated/ontology-metadata/branch/api/ValidationError.d.ts +6 -1
- package/build/types/generated/ontology-metadata/branch/api/index.d.ts +4 -0
- package/build/types/generatedNoCheck/Ontology.d.ts +483 -0
- package/build/types/generatedNoCheck/OntologyMetadata.d.ts +5 -0
- package/build/types/generatedNoCheck/index.d.ts +1 -0
- package/build/types/generatedNoCheck/ontology/actions/actionTakesObjectSet.d.ts +15 -0
- package/build/types/generatedNoCheck/ontology/actions/createOffice.d.ts +35 -0
- package/build/types/generatedNoCheck/ontology/actions/createOfficeAndEmployee.d.ts +45 -0
- package/build/types/generatedNoCheck/ontology/actions/index.d.ts +6 -0
- package/build/types/generatedNoCheck/ontology/actions/moveOffice.d.ts +35 -0
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployee.d.ts +27 -0
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployeeObject.d.ts +30 -0
- package/build/types/generatedNoCheck/ontology/interfaces.d.ts +1 -0
- package/build/types/generatedNoCheck/ontology/objects/Employee.d.ts +49 -0
- package/build/types/generatedNoCheck/ontology/objects/ObjectWithTimestampPrimaryKey.d.ts +18 -0
- package/build/types/generatedNoCheck/ontology/objects/Office.d.ts +35 -0
- package/build/types/generatedNoCheck/ontology/objects/equipment.d.ts +18 -0
- package/build/types/generatedNoCheck/ontology/objects/objectTypeWithAllPropertyTypes.d.ts +158 -0
- package/build/types/generatedNoCheck/ontology/objects.d.ts +5 -0
- package/build/types/internal/conversions/legacyToModernSingleAggregationResult.d.ts +2 -2
- package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts +2 -2
- package/build/types/object/Attachment.d.ts +8 -0
- package/build/types/object/ObjectDefinitions.test.d.ts +1 -0
- package/build/types/object/convertWireToOsdkObjects.d.ts +5 -3
- package/build/types/object/convertWireToOsdkObjects.test.d.ts +1 -0
- package/build/types/object/fetchPageOrThrow.d.ts +6 -4
- package/build/types/object/getLinkedObjectByPkOrThrow.d.ts +4 -0
- package/build/types/object/getLinkedObjectOrThrow.d.ts +4 -0
- package/build/types/object/object.test.d.ts +1 -0
- package/build/types/object/pageLinkedObjectsOrThrow.d.ts +9 -0
- package/build/types/objectSet/ObjectSet.d.ts +2 -5
- package/build/types/objectSet/ObjectSetListenerWebsocket.d.ts +2 -2
- package/build/types/objectSet/createObjectSet.d.ts +3 -3
- package/build/types/objectSet/toConjureObjectSet.d.ts +3 -3
- package/build/types/query/WhereClause.d.ts +2 -2
- package/build/types/util/test/mockOntology.d.ts +59 -0
- package/package.json +8 -3
- package/build/js/chunk-CCKGGMYW.cjs.map +0 -1
- package/build/js/chunk-MT2HE6AQ.mjs.map +0 -1
- package/build/types/internal/net/V2_BASE.d.ts +0 -1
- package/build/types/internal/net/index.d.ts +0 -1
- package/build/types/internal/net/types.d.ts +0 -357
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @osdk/client
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 206c2275: Bump conjure-lite dependency to pick up an explicit license
|
|
8
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- af6a26c0: Add support for object->object links through the object.$link namespace
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 07107577: Add where clause support for contains filter
|
|
18
|
+
|
|
3
19
|
## 0.2.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { aggregateObjectsV2, loadObjectSetV2 } from '@osdk/gateway/requests';
|
|
2
|
-
import { createOpenApiRequest } from '@osdk/shared.net';
|
|
1
|
+
import { aggregateObjectsV2, loadObjectSetV2, getLinkedObjectV2, listLinkedObjectsV2 } from '@osdk/gateway/requests';
|
|
2
|
+
import { createOpenApiRequest, PalantirApiError } from '@osdk/shared.net';
|
|
3
3
|
import invariant2 from 'tiny-invariant';
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -183,11 +183,82 @@ function createCachedOntologyTransform(creator) {
|
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
// src/object/Attachment.ts
|
|
187
|
+
var Attachment = class {
|
|
188
|
+
constructor(rid) {
|
|
189
|
+
this.rid = rid;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, select) {
|
|
193
|
+
const object = await getLinkedObjectV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {
|
|
194
|
+
select: select ?? []
|
|
195
|
+
});
|
|
196
|
+
const objects = [object];
|
|
197
|
+
convertWireToOsdkObjects(client, objects);
|
|
198
|
+
return objects[0];
|
|
199
|
+
}
|
|
200
|
+
async function pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, options) {
|
|
201
|
+
const page = await listLinkedObjectsV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, {
|
|
202
|
+
pageSize: options?.pageSize,
|
|
203
|
+
pageToken: options?.nextPageToken,
|
|
204
|
+
select: options?.select ?? []
|
|
205
|
+
});
|
|
206
|
+
convertWireToOsdkObjects(client, page.data);
|
|
207
|
+
return {
|
|
208
|
+
nextPageToken: page.nextPageToken,
|
|
209
|
+
data: page.data
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// src/object/getLinkedObjectOrThrow.ts
|
|
214
|
+
async function getLinkedObjectOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, select) {
|
|
215
|
+
const result = await pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, {
|
|
216
|
+
pageSize: 1,
|
|
217
|
+
select
|
|
218
|
+
});
|
|
219
|
+
if (result.data.length !== 1 || result.nextPageToken != null) {
|
|
220
|
+
throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? " with nextPageToken set" : ""}`);
|
|
221
|
+
}
|
|
222
|
+
return result.data[0];
|
|
223
|
+
}
|
|
224
|
+
|
|
186
225
|
// src/object/convertWireToOsdkObjects.ts
|
|
187
226
|
var getPrototype = createCachedOntologyTransform(createPrototype);
|
|
227
|
+
var getConverter = createCachedOntologyTransform(createConverter);
|
|
228
|
+
var OriginClient = Symbol();
|
|
188
229
|
function createPrototype(ontology, type) {
|
|
189
|
-
ontology.objects[type];
|
|
230
|
+
const objDef = ontology.objects[type];
|
|
190
231
|
const proto = {};
|
|
232
|
+
Object.defineProperty(proto, "$link", {
|
|
233
|
+
get: function() {
|
|
234
|
+
const client = this[OriginClient];
|
|
235
|
+
const primaryKey = this["__primaryKey"];
|
|
236
|
+
return new Proxy({}, {
|
|
237
|
+
get(_target, p, _receiver) {
|
|
238
|
+
const linkDef = objDef.links[p];
|
|
239
|
+
if (linkDef == null) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (!linkDef.multiplicity) {
|
|
243
|
+
return {
|
|
244
|
+
get: (options) => getLinkedObjectOrThrow(client, type, primaryKey, p, options?.select)
|
|
245
|
+
};
|
|
246
|
+
} else {
|
|
247
|
+
return {
|
|
248
|
+
get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options?.select),
|
|
249
|
+
fetchPageOrThrow: (options) => pageLinkedObjectsOrThrow(client, type, primaryKey, p, {
|
|
250
|
+
nextPageToken: options?.nextPageToken,
|
|
251
|
+
pageSize: options?.pageSize,
|
|
252
|
+
select: options?.select
|
|
253
|
+
})
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
enumerable: false,
|
|
260
|
+
configurable: false
|
|
261
|
+
});
|
|
191
262
|
Object.defineProperty(proto, "__name", {
|
|
192
263
|
value: type,
|
|
193
264
|
enumerable: false,
|
|
@@ -196,12 +267,49 @@ function createPrototype(ontology, type) {
|
|
|
196
267
|
});
|
|
197
268
|
return proto;
|
|
198
269
|
}
|
|
199
|
-
function
|
|
200
|
-
const
|
|
270
|
+
function createConverter(ontology, type) {
|
|
271
|
+
const steps = [];
|
|
272
|
+
for (const [key, value] of Object.entries(ontology.objects[type].properties)) {
|
|
273
|
+
if (value.type === "attachment") {
|
|
274
|
+
steps.push((o) => {
|
|
275
|
+
if (o[key] != null) {
|
|
276
|
+
if (Array.isArray(o[key])) {
|
|
277
|
+
o[key] = o[key].map((a) => new Attachment(a.rid));
|
|
278
|
+
} else {
|
|
279
|
+
o[key] = new Attachment(o[key].rid);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return steps.length > 0 ? (o) => {
|
|
286
|
+
for (const step of steps) {
|
|
287
|
+
step(o);
|
|
288
|
+
}
|
|
289
|
+
} : false;
|
|
290
|
+
}
|
|
291
|
+
function convertWireToOsdkObjects(client, objs) {
|
|
201
292
|
for (const obj of objs) {
|
|
293
|
+
const proto = getPrototype(client.ontology, obj.__apiName);
|
|
294
|
+
const converter = getConverter(client.ontology, obj.__apiName);
|
|
202
295
|
Object.setPrototypeOf(obj, proto);
|
|
296
|
+
Object.defineProperty(obj, OriginClient, {
|
|
297
|
+
value: client,
|
|
298
|
+
enumerable: false,
|
|
299
|
+
configurable: false,
|
|
300
|
+
writable: false
|
|
301
|
+
});
|
|
302
|
+
if (converter) {
|
|
303
|
+
for (const obj2 of objs) {
|
|
304
|
+
Object.setPrototypeOf(obj2, proto);
|
|
305
|
+
converter(obj2);
|
|
306
|
+
}
|
|
307
|
+
} else {
|
|
308
|
+
for (const obj2 of objs) {
|
|
309
|
+
Object.setPrototypeOf(obj2, proto);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
203
312
|
}
|
|
204
|
-
return objs;
|
|
205
313
|
}
|
|
206
314
|
|
|
207
315
|
// src/object/fetchPageOrThrow.ts
|
|
@@ -218,8 +326,11 @@ async function fetchPageOrThrow(client, objectType, args, objectSet = {
|
|
|
218
326
|
if (args?.nextPageToken) {
|
|
219
327
|
body.pageToken = args.nextPageToken;
|
|
220
328
|
}
|
|
329
|
+
if (args?.pageSize != null) {
|
|
330
|
+
body.pageSize = args.pageSize;
|
|
331
|
+
}
|
|
221
332
|
const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, body);
|
|
222
|
-
convertWireToOsdkObjects(client,
|
|
333
|
+
convertWireToOsdkObjects(client, r.data);
|
|
223
334
|
return r;
|
|
224
335
|
}
|
|
225
336
|
|
|
@@ -232,4 +343,4 @@ __export(object_exports, {
|
|
|
232
343
|
|
|
233
344
|
export { aggregateOrThrow, convertWireToOsdkObjects, fetchPageOrThrow, modernToLegacyWhereClause, object_exports };
|
|
234
345
|
//# sourceMappingURL=out.js.map
|
|
235
|
-
//# sourceMappingURL=chunk-
|
|
346
|
+
//# sourceMappingURL=chunk-DVD5PAXO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/object/aggregateOrThrow.ts","../../src/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/internal/conversions/modernToLegacyAggregationClause.ts","../../src/internal/conversions/modernToLegacyGroupByClause.ts","../../src/internal/conversions/modernToLegacyWhereClause.ts","../../src/object/fetchPageOrThrow.ts","../../src/createCachedOntologyTransform.ts","../../src/object/Attachment.ts","../../src/object/getLinkedObjectByPkOrThrow.ts","../../src/object/getLinkedObjectOrThrow.ts","../../src/object/pageLinkedObjectsOrThrow.ts","../../src/object/convertWireToOsdkObjects.ts","../../src/object/index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AE,IAAI;AAIvC,SAAO;AACT;;;AOzCA;AAAA;AAAA;AAAA;AAAA","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 { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport invariant from \"tiny-invariant\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions/index.js\";\nexport async function aggregateOrThrow(clientCtx, objectType, req) {\n const body = {\n aggregation: modernToLegacyAggregationClause(req.select),\n groupBy: [],\n where: undefined\n };\n if (req.groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.groupBy);\n }\n if (req.where) {\n body.where = modernToLegacyWhereClause(req.where);\n // TODO: orderBy\n // TODO The token stuff here sucks\n }\n\n const result = await aggregateObjectsV2(createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, objectType, body);\n if (!req.groupBy) {\n !(result.data.length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"no group by clause should mean only one data result\") : invariant(false) : void 0;\n return legacyToModernSingleAggregationResult(result.data[0]);\n }\n const ret = result.data.map(entry => {\n return {\n group: entry.group,\n values: legacyToModernSingleAggregationResult(entry)\n };\n }); // fixme\n\n return ret; // FIXME\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 invariant from \"tiny-invariant\";\nexport function legacyToModernSingleAggregationResult(entry) {\n return entry.metrics.reduce((accumulator, curValue) => {\n const parts = curValue.name.split(\".\");\n !(parts.length == 2) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"assumed we were getting a `${key}.${type}`\") : invariant(false) : void 0;\n if (!(parts[0] in accumulator)) {\n accumulator[parts[0]] = {};\n }\n accumulator[parts[0]][parts[1]] = curValue.value;\n return accumulator;\n }, {});\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 function modernToLegacyAggregationClause(select) {\n return Object.entries(select).flatMap(([k, v]) => {\n if (Array.isArray(v)) {\n return v.map(v2 => {\n return {\n type: v2,\n name: `${k}.${v2}`,\n field: k\n };\n });\n } else {\n return [{\n type: v,\n // FIXME v has additional possible values\n name: `${k}.${v}`,\n field: k\n }];\n }\n });\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 function modernToLegacyGroupByClause(groupByClause) {\n if (!groupByClause) return [];\n return Object.entries(groupByClause).flatMap(([field, type]) => {\n if (type === \"exact\") {\n return [{\n type,\n field\n }];\n } else if (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\n }\n });\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 invariant from \"tiny-invariant\";\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause)\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause)\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not)\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n const [field, filter] = parts[0];\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([field, filter]) => {\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\n };\n })\n };\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 { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function fetchPageOrThrow(client, objectType, args, objectSet = {\n type: \"base\",\n objectType\n}) {\n const body = {\n objectSet,\n // We have to do the following case because LoadObjectSetRequestV2 isnt readonly\n select: args?.select ?? [] // FIXME?\n };\n\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n if (args?.pageSize != null) {\n body.pageSize = args.pageSize;\n }\n const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, body);\n convertWireToOsdkObjects(client, r.data);\n\n // any is okay here because we have properly converted the wire objects via prototypes\n // which don't type out correctly.\n return r;\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\n/**\n * Creates a getter function that caches based on the ontology.objects[type] value\n *\n * Any extra arguments are passed through, but only the first args passed in will be used and are not considered as part of the caching\n */\nexport function createCachedOntologyTransform(creator) {\n // We can use the ObjectTypeDefinition as the key because it will be a globally unique singleton\n // Use Map instead of WeakMap here so usage for things like object prototypes do not churn over time\n const cache = new Map();\n return (ontology, type) => {\n const objectDefinition = ontology.objects[type];\n let result = cache.get(objectDefinition);\n if (result == null) {\n result = creator(ontology, type);\n cache.set(objectDefinition, result);\n }\n return result;\n };\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 class Attachment {\n constructor(rid) {\n this.rid = rid;\n }\n}\nexport function isAttachment(o) {\n return o instanceof Attachment;\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 { getLinkedObjectV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, select) {\n const object = await getLinkedObjectV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {\n select: select ?? []\n });\n const objects = [object];\n convertWireToOsdkObjects(client, objects);\n return objects[0];\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 { PalantirApiError } from \"@osdk/shared.net\";\nimport { pageLinkedObjectsOrThrow } from \"./pageLinkedObjectsOrThrow.js\";\nexport async function getLinkedObjectOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, select) {\n const result = await pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, {\n pageSize: 1,\n select\n });\n if (result.data.length !== 1 || result.nextPageToken != null) {\n throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? \" with nextPageToken set\" : \"\"}`);\n }\n return result.data[0];\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 { listLinkedObjectsV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, options) {\n const page = await listLinkedObjectsV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, {\n pageSize: options?.pageSize,\n pageToken: options?.nextPageToken,\n select: options?.select ?? []\n });\n convertWireToOsdkObjects(client, page.data);\n return {\n nextPageToken: page.nextPageToken,\n data: page.data\n };\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 { createCachedOntologyTransform } from \"../createCachedOntologyTransform.js\";\nimport { Attachment } from \"./Attachment.js\";\nimport { getLinkedObjectByPkOrThrow } from \"./getLinkedObjectByPkOrThrow.js\";\nimport { getLinkedObjectOrThrow } from \"./getLinkedObjectOrThrow.js\";\nimport { pageLinkedObjectsOrThrow } from \"./pageLinkedObjectsOrThrow.js\";\nconst getPrototype = createCachedOntologyTransform(createPrototype);\nconst getConverter = createCachedOntologyTransform(createConverter);\nconst OriginClient = Symbol();\nfunction createPrototype(ontology, type) {\n const objDef = ontology.objects[type];\n const proto = {};\n Object.defineProperty(proto, \"$link\", {\n get: function () {\n const client = this[OriginClient];\n const primaryKey = this[\"__primaryKey\"];\n return new Proxy({}, {\n get(_target, p, _receiver) {\n const linkDef = objDef.links[p];\n if (linkDef == null) {\n return;\n }\n if (!linkDef.multiplicity) {\n return {\n get: options => getLinkedObjectOrThrow(client, type, primaryKey, p, options?.select)\n };\n } else {\n return {\n get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options?.select),\n fetchPageOrThrow: options => pageLinkedObjectsOrThrow(client, type, primaryKey, p, {\n nextPageToken: options?.nextPageToken,\n pageSize: options?.pageSize,\n select: options?.select\n })\n };\n }\n }\n });\n },\n enumerable: false,\n configurable: false\n });\n\n // Earlier versions of \"2.0\" included this by hand (even though it seems the wire gives it to us anyway).\n // Its deprecated but I'm it for now (lets delete after Dec 31, 2023) so our beta users can transition.\n Object.defineProperty(proto, \"__name\", {\n value: type,\n enumerable: false,\n configurable: false,\n writable: false\n });\n return proto;\n}\n\n// preprocess the ontology definition to more quickly apply object conversions when needed\nfunction createConverter(ontology, type) {\n const steps = [];\n for (const [key, value] of Object.entries(ontology.objects[type].properties)) {\n // attachments need a wrapper to provide functionality and to identify them at serialization time\n if (value.type === \"attachment\") {\n steps.push(o => {\n if (o[key] != null) {\n if (Array.isArray(o[key])) {\n o[key] = o[key].map(a => new Attachment(a.rid));\n } else {\n o[key] = new Attachment(o[key].rid);\n }\n }\n });\n }\n }\n return steps.length > 0 ? o => {\n for (const step of steps) {\n step(o);\n }\n } : false;\n}\n\n/**\n * @param objs the objects to be converted, the contents of this array will be mutated\n */\nexport function convertWireToOsdkObjects(client, objs) {\n for (const obj of objs) {\n const proto = getPrototype(client.ontology, obj.__apiName);\n const converter = getConverter(client.ontology, obj.__apiName);\n Object.setPrototypeOf(obj, proto);\n Object.defineProperty(obj, OriginClient, {\n value: client,\n enumerable: false,\n configurable: false,\n writable: false\n });\n if (converter) {\n for (const obj of objs) {\n Object.setPrototypeOf(obj, proto);\n converter(obj);\n }\n } else {\n for (const obj of objs) {\n Object.setPrototypeOf(obj, proto);\n }\n }\n }\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 { aggregateOrThrow } from \"./aggregateOrThrow.js\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow.js\";"]}
|
|
@@ -189,11 +189,82 @@ function createCachedOntologyTransform(creator) {
|
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
// src/object/Attachment.ts
|
|
193
|
+
var Attachment = class {
|
|
194
|
+
constructor(rid) {
|
|
195
|
+
this.rid = rid;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, select) {
|
|
199
|
+
const object = await requests.getLinkedObjectV2(shared_net.createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {
|
|
200
|
+
select: select ?? []
|
|
201
|
+
});
|
|
202
|
+
const objects = [object];
|
|
203
|
+
convertWireToOsdkObjects(client, objects);
|
|
204
|
+
return objects[0];
|
|
205
|
+
}
|
|
206
|
+
async function pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, options) {
|
|
207
|
+
const page = await requests.listLinkedObjectsV2(shared_net.createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, {
|
|
208
|
+
pageSize: options?.pageSize,
|
|
209
|
+
pageToken: options?.nextPageToken,
|
|
210
|
+
select: options?.select ?? []
|
|
211
|
+
});
|
|
212
|
+
convertWireToOsdkObjects(client, page.data);
|
|
213
|
+
return {
|
|
214
|
+
nextPageToken: page.nextPageToken,
|
|
215
|
+
data: page.data
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/object/getLinkedObjectOrThrow.ts
|
|
220
|
+
async function getLinkedObjectOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, select) {
|
|
221
|
+
const result = await pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, {
|
|
222
|
+
pageSize: 1,
|
|
223
|
+
select
|
|
224
|
+
});
|
|
225
|
+
if (result.data.length !== 1 || result.nextPageToken != null) {
|
|
226
|
+
throw new shared_net.PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? " with nextPageToken set" : ""}`);
|
|
227
|
+
}
|
|
228
|
+
return result.data[0];
|
|
229
|
+
}
|
|
230
|
+
|
|
192
231
|
// src/object/convertWireToOsdkObjects.ts
|
|
193
232
|
var getPrototype = createCachedOntologyTransform(createPrototype);
|
|
233
|
+
var getConverter = createCachedOntologyTransform(createConverter);
|
|
234
|
+
var OriginClient = Symbol();
|
|
194
235
|
function createPrototype(ontology, type) {
|
|
195
|
-
ontology.objects[type];
|
|
236
|
+
const objDef = ontology.objects[type];
|
|
196
237
|
const proto = {};
|
|
238
|
+
Object.defineProperty(proto, "$link", {
|
|
239
|
+
get: function() {
|
|
240
|
+
const client = this[OriginClient];
|
|
241
|
+
const primaryKey = this["__primaryKey"];
|
|
242
|
+
return new Proxy({}, {
|
|
243
|
+
get(_target, p, _receiver) {
|
|
244
|
+
const linkDef = objDef.links[p];
|
|
245
|
+
if (linkDef == null) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (!linkDef.multiplicity) {
|
|
249
|
+
return {
|
|
250
|
+
get: (options) => getLinkedObjectOrThrow(client, type, primaryKey, p, options?.select)
|
|
251
|
+
};
|
|
252
|
+
} else {
|
|
253
|
+
return {
|
|
254
|
+
get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options?.select),
|
|
255
|
+
fetchPageOrThrow: (options) => pageLinkedObjectsOrThrow(client, type, primaryKey, p, {
|
|
256
|
+
nextPageToken: options?.nextPageToken,
|
|
257
|
+
pageSize: options?.pageSize,
|
|
258
|
+
select: options?.select
|
|
259
|
+
})
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
},
|
|
265
|
+
enumerable: false,
|
|
266
|
+
configurable: false
|
|
267
|
+
});
|
|
197
268
|
Object.defineProperty(proto, "__name", {
|
|
198
269
|
value: type,
|
|
199
270
|
enumerable: false,
|
|
@@ -202,12 +273,49 @@ function createPrototype(ontology, type) {
|
|
|
202
273
|
});
|
|
203
274
|
return proto;
|
|
204
275
|
}
|
|
205
|
-
function
|
|
206
|
-
const
|
|
276
|
+
function createConverter(ontology, type) {
|
|
277
|
+
const steps = [];
|
|
278
|
+
for (const [key, value] of Object.entries(ontology.objects[type].properties)) {
|
|
279
|
+
if (value.type === "attachment") {
|
|
280
|
+
steps.push((o) => {
|
|
281
|
+
if (o[key] != null) {
|
|
282
|
+
if (Array.isArray(o[key])) {
|
|
283
|
+
o[key] = o[key].map((a) => new Attachment(a.rid));
|
|
284
|
+
} else {
|
|
285
|
+
o[key] = new Attachment(o[key].rid);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return steps.length > 0 ? (o) => {
|
|
292
|
+
for (const step of steps) {
|
|
293
|
+
step(o);
|
|
294
|
+
}
|
|
295
|
+
} : false;
|
|
296
|
+
}
|
|
297
|
+
function convertWireToOsdkObjects(client, objs) {
|
|
207
298
|
for (const obj of objs) {
|
|
299
|
+
const proto = getPrototype(client.ontology, obj.__apiName);
|
|
300
|
+
const converter = getConverter(client.ontology, obj.__apiName);
|
|
208
301
|
Object.setPrototypeOf(obj, proto);
|
|
302
|
+
Object.defineProperty(obj, OriginClient, {
|
|
303
|
+
value: client,
|
|
304
|
+
enumerable: false,
|
|
305
|
+
configurable: false,
|
|
306
|
+
writable: false
|
|
307
|
+
});
|
|
308
|
+
if (converter) {
|
|
309
|
+
for (const obj2 of objs) {
|
|
310
|
+
Object.setPrototypeOf(obj2, proto);
|
|
311
|
+
converter(obj2);
|
|
312
|
+
}
|
|
313
|
+
} else {
|
|
314
|
+
for (const obj2 of objs) {
|
|
315
|
+
Object.setPrototypeOf(obj2, proto);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
209
318
|
}
|
|
210
|
-
return objs;
|
|
211
319
|
}
|
|
212
320
|
|
|
213
321
|
// src/object/fetchPageOrThrow.ts
|
|
@@ -224,8 +332,11 @@ async function fetchPageOrThrow(client, objectType, args, objectSet = {
|
|
|
224
332
|
if (args?.nextPageToken) {
|
|
225
333
|
body.pageToken = args.nextPageToken;
|
|
226
334
|
}
|
|
335
|
+
if (args?.pageSize != null) {
|
|
336
|
+
body.pageSize = args.pageSize;
|
|
337
|
+
}
|
|
227
338
|
const r = await requests.loadObjectSetV2(shared_net.createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, body);
|
|
228
|
-
convertWireToOsdkObjects(client,
|
|
339
|
+
convertWireToOsdkObjects(client, r.data);
|
|
229
340
|
return r;
|
|
230
341
|
}
|
|
231
342
|
|
|
@@ -242,4 +353,4 @@ exports.fetchPageOrThrow = fetchPageOrThrow;
|
|
|
242
353
|
exports.modernToLegacyWhereClause = modernToLegacyWhereClause;
|
|
243
354
|
exports.object_exports = object_exports;
|
|
244
355
|
//# sourceMappingURL=out.js.map
|
|
245
|
-
//# sourceMappingURL=chunk-
|
|
356
|
+
//# sourceMappingURL=chunk-YVZITKIQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/object/aggregateOrThrow.ts","../../src/internal/conversions/legacyToModernSingleAggregationResult.ts","../../src/internal/conversions/modernToLegacyAggregationClause.ts","../../src/internal/conversions/modernToLegacyGroupByClause.ts","../../src/internal/conversions/modernToLegacyWhereClause.ts","../../src/object/fetchPageOrThrow.ts","../../src/createCachedOntologyTransform.ts","../../src/object/Attachment.ts","../../src/object/getLinkedObjectByPkOrThrow.ts","../../src/object/getLinkedObjectOrThrow.ts","../../src/object/pageLinkedObjectsOrThrow.ts","../../src/object/convertWireToOsdkObjects.ts","../../src/object/index.ts"],"names":["invariant","createOpenApiRequest","obj"],"mappings":";;;;;;;AAgBA,SAAS,0BAA0B;AACnC,SAAS,4BAA4B;AACrC,OAAOA,gBAAe;;;ACFtB,OAAO,eAAe;AACf,SAAS,sCAAsC,OAAO;AAC3D,SAAO,MAAM,QAAQ,OAAO,CAAC,aAAa,aAAa;AACrD,UAAM,QAAQ,SAAS,KAAK,MAAM,GAAG;AACrC,MAAE,MAAM,UAAU,KAAK,QAAQ,IAAI,aAAa,eAAe,UAAU,OAAO,4CAA4C,IAAI,UAAU,KAAK,IAAI;AACnJ,QAAI,EAAE,MAAM,CAAC,KAAK,cAAc;AAC9B,kBAAY,MAAM,CAAC,CAAC,IAAI,CAAC;AAAA,IAC3B;AACA,gBAAY,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,SAAS;AAC3C,WAAO;AAAA,EACT,GAAG,CAAC,CAAC;AACP;;;ACXO,SAAS,gCAAgC,QAAQ;AACtD,SAAO,OAAO,QAAQ,MAAM,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM;AAChD,QAAI,MAAM,QAAQ,CAAC,GAAG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,iBAAWA,QAAO,MAAM;AACtB,eAAO,eAAeA,MAAK,KAAK;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AACF;;;ANnGA,eAAsB,iBAAiB,QAAQ,YAAY,MAAM,YAAY;AAAA,EAC3E,MAAM;AAAA,EACN;AACF,GAAG;AACD,QAAM,OAAO;AAAA,IACX;AAAA;AAAA,IAEA,QAAQ,MAAM,UAAU,CAAC;AAAA;AAAA,EAC3B;AAEA,MAAI,MAAM,eAAe;AACvB,SAAK,YAAY,KAAK;AAAA,EACxB;AACA,MAAI,MAAM,YAAY,MAAM;AAC1B,SAAK,WAAW,KAAK;AAAA,EACvB;AACA,QAAM,IAAI,MAAM,gBAAgBD,sBAAqB,OAAO,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,SAAS,iBAAiB,IAAI;AAChI,2BAAyB,QAAQ,EAAE,IAAI;AAIvC,SAAO;AACT;;;AOzCA;AAAA;AAAA;AAAA;AAAA","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 { aggregateObjectsV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport invariant from \"tiny-invariant\";\nimport { legacyToModernSingleAggregationResult, modernToLegacyAggregationClause, modernToLegacyGroupByClause, modernToLegacyWhereClause } from \"../internal/conversions/index.js\";\nexport async function aggregateOrThrow(clientCtx, objectType, req) {\n const body = {\n aggregation: modernToLegacyAggregationClause(req.select),\n groupBy: [],\n where: undefined\n };\n if (req.groupBy) {\n body.groupBy = modernToLegacyGroupByClause(req.groupBy);\n }\n if (req.where) {\n body.where = modernToLegacyWhereClause(req.where);\n // TODO: orderBy\n // TODO The token stuff here sucks\n }\n\n const result = await aggregateObjectsV2(createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, objectType, body);\n if (!req.groupBy) {\n !(result.data.length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"no group by clause should mean only one data result\") : invariant(false) : void 0;\n return legacyToModernSingleAggregationResult(result.data[0]);\n }\n const ret = result.data.map(entry => {\n return {\n group: entry.group,\n values: legacyToModernSingleAggregationResult(entry)\n };\n }); // fixme\n\n return ret; // FIXME\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 invariant from \"tiny-invariant\";\nexport function legacyToModernSingleAggregationResult(entry) {\n return entry.metrics.reduce((accumulator, curValue) => {\n const parts = curValue.name.split(\".\");\n !(parts.length == 2) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"assumed we were getting a `${key}.${type}`\") : invariant(false) : void 0;\n if (!(parts[0] in accumulator)) {\n accumulator[parts[0]] = {};\n }\n accumulator[parts[0]][parts[1]] = curValue.value;\n return accumulator;\n }, {});\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 function modernToLegacyAggregationClause(select) {\n return Object.entries(select).flatMap(([k, v]) => {\n if (Array.isArray(v)) {\n return v.map(v2 => {\n return {\n type: v2,\n name: `${k}.${v2}`,\n field: k\n };\n });\n } else {\n return [{\n type: v,\n // FIXME v has additional possible values\n name: `${k}.${v}`,\n field: k\n }];\n }\n });\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 function modernToLegacyGroupByClause(groupByClause) {\n if (!groupByClause) return [];\n return Object.entries(groupByClause).flatMap(([field, type]) => {\n if (type === \"exact\") {\n return [{\n type,\n field\n }];\n } else if (type.exactWithLimit) {\n return [{\n type: \"exact\",\n field,\n maxGroupCount: type.exactWithLimit\n }];\n } else {\n return [];\n }\n });\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 invariant from \"tiny-invariant\";\nexport function modernToLegacyWhereClause(whereClause) {\n if (\"$and\" in whereClause) {\n return {\n type: \"and\",\n value: whereClause.$and.map(modernToLegacyWhereClause)\n };\n } else if (\"$or\" in whereClause) {\n return {\n type: \"or\",\n value: whereClause.$or.map(modernToLegacyWhereClause)\n };\n } else if (\"$not\" in whereClause) {\n return {\n type: \"not\",\n value: modernToLegacyWhereClause(whereClause.$not)\n };\n }\n const parts = Object.entries(whereClause);\n if (parts.length === 1) {\n const [field, filter] = parts[0];\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const type = Object.keys(filter)[0];\n !(filter[type] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (type === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[type]\n }\n };\n }\n return {\n type,\n field,\n value: filter[type]\n };\n }\n return {\n type: \"and\",\n value: Object.entries(whereClause).map(([field, filter]) => {\n !(filter != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"Defined key values are only allowed when they are not undefined.\") : invariant(false) : void 0;\n if (typeof filter === \"string\" || typeof filter === \"number\") {\n return {\n type: \"eq\",\n field,\n value: filter\n };\n }\n !(Object.keys(filter).length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple properties isn't allowed\") : invariant(false) : void 0;\n const q = Object.keys(filter)[0];\n !(filter[q] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (q === \"ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[q]\n }\n };\n }\n return {\n type: q,\n field,\n value: filter[q]\n };\n })\n };\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 { loadObjectSetV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function fetchPageOrThrow(client, objectType, args, objectSet = {\n type: \"base\",\n objectType\n}) {\n const body = {\n objectSet,\n // We have to do the following case because LoadObjectSetRequestV2 isnt readonly\n select: args?.select ?? [] // FIXME?\n };\n\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n if (args?.pageSize != null) {\n body.pageSize = args.pageSize;\n }\n const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, body);\n convertWireToOsdkObjects(client, r.data);\n\n // any is okay here because we have properly converted the wire objects via prototypes\n // which don't type out correctly.\n return r;\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\n/**\n * Creates a getter function that caches based on the ontology.objects[type] value\n *\n * Any extra arguments are passed through, but only the first args passed in will be used and are not considered as part of the caching\n */\nexport function createCachedOntologyTransform(creator) {\n // We can use the ObjectTypeDefinition as the key because it will be a globally unique singleton\n // Use Map instead of WeakMap here so usage for things like object prototypes do not churn over time\n const cache = new Map();\n return (ontology, type) => {\n const objectDefinition = ontology.objects[type];\n let result = cache.get(objectDefinition);\n if (result == null) {\n result = creator(ontology, type);\n cache.set(objectDefinition, result);\n }\n return result;\n };\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 class Attachment {\n constructor(rid) {\n this.rid = rid;\n }\n}\nexport function isAttachment(o) {\n return o instanceof Attachment;\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 { getLinkedObjectV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, select) {\n const object = await getLinkedObjectV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {\n select: select ?? []\n });\n const objects = [object];\n convertWireToOsdkObjects(client, objects);\n return objects[0];\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 { PalantirApiError } from \"@osdk/shared.net\";\nimport { pageLinkedObjectsOrThrow } from \"./pageLinkedObjectsOrThrow.js\";\nexport async function getLinkedObjectOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, select) {\n const result = await pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, {\n pageSize: 1,\n select\n });\n if (result.data.length !== 1 || result.nextPageToken != null) {\n throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? \" with nextPageToken set\" : \"\"}`);\n }\n return result.data[0];\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 { listLinkedObjectsV2 } from \"@osdk/gateway/requests\";\nimport { createOpenApiRequest } from \"@osdk/shared.net\";\nimport { convertWireToOsdkObjects } from \"./convertWireToOsdkObjects.js\";\nexport async function pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, options) {\n const page = await listLinkedObjectsV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, {\n pageSize: options?.pageSize,\n pageToken: options?.nextPageToken,\n select: options?.select ?? []\n });\n convertWireToOsdkObjects(client, page.data);\n return {\n nextPageToken: page.nextPageToken,\n data: page.data\n };\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 { createCachedOntologyTransform } from \"../createCachedOntologyTransform.js\";\nimport { Attachment } from \"./Attachment.js\";\nimport { getLinkedObjectByPkOrThrow } from \"./getLinkedObjectByPkOrThrow.js\";\nimport { getLinkedObjectOrThrow } from \"./getLinkedObjectOrThrow.js\";\nimport { pageLinkedObjectsOrThrow } from \"./pageLinkedObjectsOrThrow.js\";\nconst getPrototype = createCachedOntologyTransform(createPrototype);\nconst getConverter = createCachedOntologyTransform(createConverter);\nconst OriginClient = Symbol();\nfunction createPrototype(ontology, type) {\n const objDef = ontology.objects[type];\n const proto = {};\n Object.defineProperty(proto, \"$link\", {\n get: function () {\n const client = this[OriginClient];\n const primaryKey = this[\"__primaryKey\"];\n return new Proxy({}, {\n get(_target, p, _receiver) {\n const linkDef = objDef.links[p];\n if (linkDef == null) {\n return;\n }\n if (!linkDef.multiplicity) {\n return {\n get: options => getLinkedObjectOrThrow(client, type, primaryKey, p, options?.select)\n };\n } else {\n return {\n get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options?.select),\n fetchPageOrThrow: options => pageLinkedObjectsOrThrow(client, type, primaryKey, p, {\n nextPageToken: options?.nextPageToken,\n pageSize: options?.pageSize,\n select: options?.select\n })\n };\n }\n }\n });\n },\n enumerable: false,\n configurable: false\n });\n\n // Earlier versions of \"2.0\" included this by hand (even though it seems the wire gives it to us anyway).\n // Its deprecated but I'm it for now (lets delete after Dec 31, 2023) so our beta users can transition.\n Object.defineProperty(proto, \"__name\", {\n value: type,\n enumerable: false,\n configurable: false,\n writable: false\n });\n return proto;\n}\n\n// preprocess the ontology definition to more quickly apply object conversions when needed\nfunction createConverter(ontology, type) {\n const steps = [];\n for (const [key, value] of Object.entries(ontology.objects[type].properties)) {\n // attachments need a wrapper to provide functionality and to identify them at serialization time\n if (value.type === \"attachment\") {\n steps.push(o => {\n if (o[key] != null) {\n if (Array.isArray(o[key])) {\n o[key] = o[key].map(a => new Attachment(a.rid));\n } else {\n o[key] = new Attachment(o[key].rid);\n }\n }\n });\n }\n }\n return steps.length > 0 ? o => {\n for (const step of steps) {\n step(o);\n }\n } : false;\n}\n\n/**\n * @param objs the objects to be converted, the contents of this array will be mutated\n */\nexport function convertWireToOsdkObjects(client, objs) {\n for (const obj of objs) {\n const proto = getPrototype(client.ontology, obj.__apiName);\n const converter = getConverter(client.ontology, obj.__apiName);\n Object.setPrototypeOf(obj, proto);\n Object.defineProperty(obj, OriginClient, {\n value: client,\n enumerable: false,\n configurable: false,\n writable: false\n });\n if (converter) {\n for (const obj of objs) {\n Object.setPrototypeOf(obj, proto);\n converter(obj);\n }\n } else {\n for (const obj of objs) {\n Object.setPrototypeOf(obj, proto);\n }\n }\n }\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 { aggregateOrThrow } from \"./aggregateOrThrow.js\";\nexport { fetchPageOrThrow } from \"./fetchPageOrThrow.js\";"]}
|
package/build/js/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYVZITKIQ_cjs = require('./chunk-YVZITKIQ.cjs');
|
|
4
4
|
var shared_net = require('@osdk/shared.net');
|
|
5
5
|
var requests = require('@osdk/gateway/requests');
|
|
6
6
|
var WebSocket = require('isomorphic-ws');
|
|
@@ -238,6 +238,7 @@ function mapWhereClauseToObjectSetFilter(objectSetFilter, propertyMapping) {
|
|
|
238
238
|
case "withinPolygon":
|
|
239
239
|
case "intersectsPolygon":
|
|
240
240
|
case "doesNotIntersectPolygon":
|
|
241
|
+
case "containsAllTermsInOrderPrefixLastTerm":
|
|
241
242
|
throw new Error("not implemented");
|
|
242
243
|
}
|
|
243
244
|
}
|
|
@@ -524,8 +525,9 @@ async function convertFoundryToOsdkObjects(client, ctx, objects) {
|
|
|
524
525
|
const convertedObject = Object.fromEntries([...Object.entries(object.properties).map(([key, value]) => {
|
|
525
526
|
return [propertyMapping?.propertyIdToApiNameMapping[key], value];
|
|
526
527
|
}), [propertyMapping?.propertyIdToApiNameMapping[Object.entries(object.key)[0][0]], Object.entries(object.key)[0][1]], ["__apiName", propertyMapping?.apiName]]);
|
|
527
|
-
return
|
|
528
|
+
return convertedObject;
|
|
528
529
|
}));
|
|
530
|
+
chunkYVZITKIQ_cjs.convertWireToOsdkObjects(client, osdkObjects);
|
|
529
531
|
return osdkObjects;
|
|
530
532
|
}
|
|
531
533
|
var objectTypeMapping = /* @__PURE__ */ new WeakMap();
|
|
@@ -579,7 +581,7 @@ async function getOntologyPropertyMappingForRid(ctx, ontologyRid, objectRid) {
|
|
|
579
581
|
|
|
580
582
|
// src/objectSet/createObjectSet.ts
|
|
581
583
|
var searchAroundPrefix = "searchAround_";
|
|
582
|
-
function createObjectSet2(objectType, clientCtx,
|
|
584
|
+
function createObjectSet2(objectType, clientCtx, objectSet = {
|
|
583
585
|
type: "base",
|
|
584
586
|
objectType
|
|
585
587
|
}) {
|
|
@@ -595,29 +597,29 @@ function createObjectSet2(objectType, clientCtx, opts, objectSet = {
|
|
|
595
597
|
// throw "TODO";
|
|
596
598
|
// },
|
|
597
599
|
aggregateOrThrow: async (req) => {
|
|
598
|
-
return
|
|
600
|
+
return chunkYVZITKIQ_cjs.aggregateOrThrow(clientCtx, objectType, req);
|
|
599
601
|
},
|
|
600
602
|
// fetchPage: async (args?: { nextPageToken?: string }) => {
|
|
601
603
|
// throw "TODO";
|
|
602
604
|
// },
|
|
603
605
|
fetchPageOrThrow: async (args) => {
|
|
604
|
-
return
|
|
606
|
+
return chunkYVZITKIQ_cjs.fetchPageOrThrow(clientCtx, objectType, args ?? {}, objectSet);
|
|
605
607
|
},
|
|
606
608
|
// asyncIter: () => {
|
|
607
609
|
// throw "";
|
|
608
610
|
// },
|
|
609
611
|
where: (clause) => {
|
|
610
|
-
return createObjectSet2(objectType, clientCtx,
|
|
612
|
+
return createObjectSet2(objectType, clientCtx, {
|
|
611
613
|
type: "filter",
|
|
612
614
|
objectSet,
|
|
613
|
-
where:
|
|
615
|
+
where: chunkYVZITKIQ_cjs.modernToLegacyWhereClause(clause)
|
|
614
616
|
});
|
|
615
617
|
},
|
|
616
618
|
// [Symbol.asyncIterator]: () => {
|
|
617
619
|
// throw "";
|
|
618
620
|
// },
|
|
619
|
-
pivotTo: function(type
|
|
620
|
-
return createSearchAround(type)()
|
|
621
|
+
pivotTo: function(type) {
|
|
622
|
+
return createSearchAround(type)();
|
|
621
623
|
},
|
|
622
624
|
subscribe(listener) {
|
|
623
625
|
const instance = ObjectSetListenerWebsocket.getInstance(clientCtx);
|
|
@@ -626,7 +628,7 @@ function createObjectSet2(objectType, clientCtx, opts, objectSet = {
|
|
|
626
628
|
};
|
|
627
629
|
function createSearchAround(link) {
|
|
628
630
|
return () => {
|
|
629
|
-
return createObjectSet2(objectType, clientCtx, {
|
|
631
|
+
return createObjectSet2(objectType, clientCtx, {
|
|
630
632
|
type: "searchAround",
|
|
631
633
|
objectSet,
|
|
632
634
|
link
|
|
@@ -657,7 +659,7 @@ function createObjectSetCreator(client) {
|
|
|
657
659
|
// src/createClient.ts
|
|
658
660
|
function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {
|
|
659
661
|
const clientCtx = shared_net.createClientContext(ontology, stack, tokenProvider, "@osdk/client/0.0.0 ()", fetchFn);
|
|
660
|
-
const objectSetFactory = (type
|
|
662
|
+
const objectSetFactory = (type) => createObjectSet2(type, clientCtx);
|
|
661
663
|
const client = Object.defineProperties({}, {
|
|
662
664
|
objectSet: {
|
|
663
665
|
get: () => objectSetFactory
|
|
@@ -670,7 +672,7 @@ function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {
|
|
|
670
672
|
},
|
|
671
673
|
__UNSTABLE_preexistingObjectSet: {
|
|
672
674
|
get: () => (objectType, rid) => {
|
|
673
|
-
return createObjectSet2(objectType, clientCtx, {
|
|
675
|
+
return createObjectSet2(objectType, clientCtx, {
|
|
674
676
|
type: "intersect",
|
|
675
677
|
objectSets: [{
|
|
676
678
|
type: "base",
|
|
@@ -688,7 +690,7 @@ function createClient(ontology, stack, tokenProvider, fetchFn = fetch) {
|
|
|
688
690
|
|
|
689
691
|
Object.defineProperty(exports, 'Objects', {
|
|
690
692
|
enumerable: true,
|
|
691
|
-
get: function () { return
|
|
693
|
+
get: function () { return chunkYVZITKIQ_cjs.object_exports; }
|
|
692
694
|
});
|
|
693
695
|
Object.defineProperty(exports, 'createClientContext', {
|
|
694
696
|
enumerable: true,
|