@osdk/client 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/js/chunk-GOBQUVQZ.mjs +1138 -0
- package/build/js/chunk-GOBQUVQZ.mjs.map +1 -0
- package/build/js/chunk-LK4VDWCG.cjs +1151 -0
- package/build/js/chunk-LK4VDWCG.cjs.map +1 -0
- package/build/js/index.cjs +101 -636
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +99 -634
- package/build/js/index.mjs.map +1 -1
- package/build/js/public/objects.cjs +5 -5
- package/build/js/public/objects.mjs +1 -1
- package/build/types/Client.d.ts +11 -5
- package/build/types/MinimalClientContext.d.ts +13 -0
- package/build/types/ObjectSetCreator.d.ts +6 -4
- package/build/types/OsdkObjectFrom.d.ts +11 -11
- package/build/types/actions/Actions.d.ts +5 -4
- package/build/types/actions/applyAction.d.ts +2 -2
- package/build/types/actions/createActionInvoker.d.ts +5 -4
- package/build/types/createClient.d.ts +5 -2
- package/build/types/createMinimalClient.d.ts +3 -0
- package/build/types/definitions/LinkDefinitions.d.ts +8 -12
- package/build/types/generatedNoCheck/Ontology.d.ts +5 -5
- package/build/types/generatedNoCheck/index.d.ts +3 -0
- package/build/types/generatedNoCheck/ontology/actions/actionTakesAttachment.d.ts +1 -1
- package/build/types/generatedNoCheck/ontology/actions/actionTakesObjectSet.d.ts +2 -2
- package/build/types/generatedNoCheck/ontology/actions/createOffice.d.ts +4 -4
- package/build/types/generatedNoCheck/ontology/actions/createOfficeAndEmployee.d.ts +5 -5
- package/build/types/generatedNoCheck/ontology/actions/moveOffice.d.ts +4 -4
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployee.d.ts +3 -3
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployeeObject.d.ts +4 -4
- package/build/types/generatedNoCheck/ontology/objects/Employee.d.ts +13 -37
- package/build/types/generatedNoCheck/ontology/objects/ObjectWithTimestampPrimaryKey.d.ts +6 -15
- package/build/types/generatedNoCheck/ontology/objects/Office.d.ts +10 -29
- package/build/types/generatedNoCheck/ontology/objects/equipment.d.ts +6 -16
- package/build/types/generatedNoCheck/ontology/objects/objectTypeWithAllPropertyTypes.d.ts +34 -155
- package/build/types/index.d.ts +3 -1
- package/build/types/object/Cache.d.ts +33 -0
- package/build/types/object/aggregate.d.ts +11 -0
- package/build/types/object/convertWireToOsdkObjects.d.ts +2 -3
- package/build/types/object/fetchPage.d.ts +22 -0
- package/build/types/object/fetchPage.test.d.ts +1 -0
- package/build/types/object/fetchSingle.d.ts +6 -0
- package/build/types/object/index.d.ts +2 -2
- package/build/types/objectSet/LinkUtils.d.ts +3 -0
- package/build/types/objectSet/ObjectSet.d.ts +18 -10
- package/build/types/objectSet/ObjectSetListenerWebsocket.d.ts +4 -4
- package/build/types/objectSet/createObjectSet.d.ts +4 -3
- package/build/types/ontology/OntologyProvider.d.ts +20 -0
- package/build/types/ontology/loadFullObjectMetadata.d.ts +3 -0
- package/build/types/ontology/providers/StandardOntologyProvider.d.ts +5 -0
- package/build/types/ontology/providers/StandardOntologyProvider.test.d.ts +1 -0
- package/build/types/query/WhereClause.d.ts +2 -1
- package/build/types/query/aggregations/AggregatableKeys.d.ts +1 -1
- package/build/types/query/aggregations/AggregateOpts.d.ts +3 -3
- package/build/types/query/aggregations/AggregationResultsWithGroups.d.ts +9 -4
- package/build/types/query/aggregations/AggregationResultsWithoutGroups.d.ts +4 -1
- package/build/types/query/aggregations/AggregationsClause.d.ts +5 -2
- package/build/types/query/aggregations/AggregationsClause.test.d.ts +2 -0
- package/build/types/query/aggregations/AggregationsResults.d.ts +3 -2
- package/build/types/query/aggregations/GroupByClause.d.ts +8 -0
- package/build/types/query/aggregations/GroupByClause.test.d.ts +1 -0
- package/build/types/query/aggregations/GroupByMapper.d.ts +7 -1
- package/build/types/util/test/mockOntology.d.ts +3 -0
- package/changelog/0.11.0/pr-100.v2.yml +5 -0
- package/changelog/0.11.0/pr-67.v2.yml +5 -0
- package/changelog/0.11.0/pr-83.v2.yml +5 -0
- package/changelog/0.11.0/pr-84.v2.yml +5 -0
- package/changelog/0.11.0/pr-86.v2.yml +5 -0
- package/changelog/0.11.0/pr-88.v2.yml +5 -0
- package/changelog/0.11.0/pr-89.v2.yml +5 -0
- package/changelog/0.11.0/pr-91.v2.yml +5 -0
- package/changelog/0.11.0/pr-95.v2.yml +5 -0
- package/changelog/0.11.0/pr-96.v2.yml +5 -0
- package/changelog/0.11.0/pr-99.v2.yml +5 -0
- package/package.json +8 -6
- package/build/js/chunk-MVO52VHK.cjs +0 -458
- package/build/js/chunk-MVO52VHK.cjs.map +0 -1
- package/build/js/chunk-XI2O777X.mjs +0 -447
- package/build/js/chunk-XI2O777X.mjs.map +0 -1
- package/build/types/createCachedOntologyTransform.d.ts +0 -7
- package/build/types/object/aggregateOrThrow.d.ts +0 -6
- package/build/types/object/fetchPageOrThrow.d.ts +0 -19
- package/build/types/object/getLinkedObjectByPkOrThrow.d.ts +0 -5
- package/build/types/object/getLinkedObjectOrThrow.d.ts +0 -7
- package/build/types/object/pageLinkedObjectsOrThrow.d.ts +0 -7
- package/build/types/objectSet/LinkTypesFrom.d.ts +0 -2
- /package/build/types/object/{aggregateOrThrow.test.d.ts → aggregate.test.d.ts} +0 -0
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
import { aggregateObjectSetV2, loadObjectSetV2, getLinkedObjectV2, listLinkedObjectsV2 } from '@osdk/gateway/requests';
|
|
2
|
-
import { createOpenApiRequest, PalantirApiError } from '@osdk/shared.net';
|
|
3
|
-
import invariant2 from 'tiny-invariant';
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
function legacyToModernSingleAggregationResult(entry) {
|
|
11
|
-
return entry.metrics.reduce((accumulator, curValue) => {
|
|
12
|
-
const parts = curValue.name.split(".");
|
|
13
|
-
!(parts.length === 2) ? process.env.NODE_ENV !== "production" ? invariant2(false, "assumed we were getting a `${key}.${type}`") : invariant2(false) : void 0;
|
|
14
|
-
if (!(parts[0] in accumulator)) {
|
|
15
|
-
accumulator[parts[0]] = {};
|
|
16
|
-
}
|
|
17
|
-
accumulator[parts[0]][parts[1]] = curValue.value;
|
|
18
|
-
return accumulator;
|
|
19
|
-
}, {});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// src/internal/conversions/modernToLegacyAggregationClause.ts
|
|
23
|
-
function modernToLegacyAggregationClause(select) {
|
|
24
|
-
return Object.entries(select).flatMap(([k, v]) => {
|
|
25
|
-
if (Array.isArray(v)) {
|
|
26
|
-
return v.map((v2) => {
|
|
27
|
-
return {
|
|
28
|
-
type: v2,
|
|
29
|
-
name: `${k}.${v2}`,
|
|
30
|
-
field: k
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
} else {
|
|
34
|
-
return [{
|
|
35
|
-
type: v,
|
|
36
|
-
// FIXME v has additional possible values
|
|
37
|
-
name: `${k}.${v}`,
|
|
38
|
-
field: k
|
|
39
|
-
}];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/internal/conversions/modernToLegacyGroupByClause.ts
|
|
45
|
-
function modernToLegacyGroupByClause(groupByClause) {
|
|
46
|
-
if (!groupByClause)
|
|
47
|
-
return [];
|
|
48
|
-
return Object.entries(groupByClause).flatMap(([field, type]) => {
|
|
49
|
-
if (type === "exact") {
|
|
50
|
-
return [{
|
|
51
|
-
type,
|
|
52
|
-
field
|
|
53
|
-
}];
|
|
54
|
-
} else if (type.exactWithLimit) {
|
|
55
|
-
return [{
|
|
56
|
-
type: "exact",
|
|
57
|
-
field,
|
|
58
|
-
maxGroupCount: type.exactWithLimit
|
|
59
|
-
}];
|
|
60
|
-
} else {
|
|
61
|
-
return [];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// src/query/WhereClause.ts
|
|
67
|
-
var DistanceUnitMapping = {
|
|
68
|
-
"centimeter": "CENTIMETERS",
|
|
69
|
-
"centimeters": "CENTIMETERS",
|
|
70
|
-
"cm": "CENTIMETERS",
|
|
71
|
-
"meter": "METERS",
|
|
72
|
-
"meters": "METERS",
|
|
73
|
-
"m": "METERS",
|
|
74
|
-
"kilometer": "KILOMETERS",
|
|
75
|
-
"kilometers": "KILOMETERS",
|
|
76
|
-
"km": "KILOMETERS",
|
|
77
|
-
"inch": "INCHES",
|
|
78
|
-
"inches": "INCHES",
|
|
79
|
-
"foot": "FEET",
|
|
80
|
-
"feet": "FEET",
|
|
81
|
-
"yard": "YARDS",
|
|
82
|
-
"yards": "YARDS",
|
|
83
|
-
"mile": "MILES",
|
|
84
|
-
"miles": "MILES",
|
|
85
|
-
"nautical_mile": "NAUTICAL_MILES",
|
|
86
|
-
"nauticalMile": "NAUTICAL_MILES",
|
|
87
|
-
"nautical miles": "NAUTICAL_MILES"
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// src/internal/conversions/modernToLegacyWhereClause.ts
|
|
91
|
-
function modernToLegacyWhereClause(whereClause) {
|
|
92
|
-
if ("$and" in whereClause) {
|
|
93
|
-
return {
|
|
94
|
-
type: "and",
|
|
95
|
-
value: whereClause.$and.map(modernToLegacyWhereClause)
|
|
96
|
-
};
|
|
97
|
-
} else if ("$or" in whereClause) {
|
|
98
|
-
return {
|
|
99
|
-
type: "or",
|
|
100
|
-
value: whereClause.$or.map(modernToLegacyWhereClause)
|
|
101
|
-
};
|
|
102
|
-
} else if ("$not" in whereClause) {
|
|
103
|
-
return {
|
|
104
|
-
type: "not",
|
|
105
|
-
value: modernToLegacyWhereClause(whereClause.$not)
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
const parts = Object.entries(whereClause);
|
|
109
|
-
if (parts.length === 1) {
|
|
110
|
-
return handleWherePair(parts[0]);
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
type: "and",
|
|
114
|
-
value: parts.map(handleWherePair)
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function makeGeoFilterBbox(field, bbox, filterType) {
|
|
118
|
-
return {
|
|
119
|
-
type: filterType === "$within" ? "withinBoundingBox" : "intersectsBoundingBox",
|
|
120
|
-
field,
|
|
121
|
-
value: {
|
|
122
|
-
topLeft: {
|
|
123
|
-
type: "Point",
|
|
124
|
-
coordinates: [bbox[0], bbox[3]]
|
|
125
|
-
},
|
|
126
|
-
bottomRight: {
|
|
127
|
-
type: "Point",
|
|
128
|
-
coordinates: [bbox[2], bbox[1]]
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function makeGeoFilterPolygon(field, coordinates, filterType) {
|
|
134
|
-
return {
|
|
135
|
-
type: filterType,
|
|
136
|
-
field,
|
|
137
|
-
value: {
|
|
138
|
-
type: "Polygon",
|
|
139
|
-
coordinates
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function handleWherePair([field, filter]) {
|
|
144
|
-
!(filter != null) ? process.env.NODE_ENV !== "production" ? invariant2(false, "Defined key values are only allowed when they are not undefined.") : invariant2(false) : void 0;
|
|
145
|
-
if (typeof filter === "string" || typeof filter === "number") {
|
|
146
|
-
return {
|
|
147
|
-
type: "eq",
|
|
148
|
-
field,
|
|
149
|
-
value: filter
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
const keysOfFilter = Object.keys(filter);
|
|
153
|
-
const hasDollarSign = keysOfFilter.some((key) => key.startsWith("$"));
|
|
154
|
-
!(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant2(false, "WhereClause Filter with multiple clauses isn't allowed") : invariant2(false) : void 0;
|
|
155
|
-
if (!hasDollarSign) {
|
|
156
|
-
throw new Error("Unsupported filter. Did you forget to use a $-prefixed filter?");
|
|
157
|
-
}
|
|
158
|
-
const firstKey = keysOfFilter[0];
|
|
159
|
-
!(filter[firstKey] != null) ? process.env.NODE_ENV !== "production" ? invariant2(false) : invariant2(false) : void 0;
|
|
160
|
-
if (firstKey === "$ne") {
|
|
161
|
-
return {
|
|
162
|
-
type: "not",
|
|
163
|
-
value: {
|
|
164
|
-
type: "eq",
|
|
165
|
-
field,
|
|
166
|
-
value: filter[firstKey]
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
if (firstKey === "$within") {
|
|
171
|
-
const withinBody = filter[firstKey];
|
|
172
|
-
if (Array.isArray(withinBody)) {
|
|
173
|
-
return makeGeoFilterBbox(field, withinBody, firstKey);
|
|
174
|
-
} else if ("bbox" in withinBody && !("type" in withinBody)) {
|
|
175
|
-
return makeGeoFilterBbox(field, withinBody.bbox, firstKey);
|
|
176
|
-
} else if ("distance" in withinBody && "of" in withinBody) {
|
|
177
|
-
return {
|
|
178
|
-
type: "withinDistanceOf",
|
|
179
|
-
field,
|
|
180
|
-
value: {
|
|
181
|
-
center: Array.isArray(withinBody.of) ? {
|
|
182
|
-
type: "Point",
|
|
183
|
-
coordinates: withinBody.of
|
|
184
|
-
} : withinBody.of,
|
|
185
|
-
distance: {
|
|
186
|
-
value: withinBody.distance[0],
|
|
187
|
-
unit: DistanceUnitMapping[withinBody.distance[1]]
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
} else {
|
|
192
|
-
const coordinates = "polygon" in withinBody ? withinBody.polygon : withinBody.coordinates;
|
|
193
|
-
return makeGeoFilterPolygon(field, coordinates, "withinPolygon");
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (firstKey === "$intersects") {
|
|
197
|
-
const intersectsBody = filter[firstKey];
|
|
198
|
-
if (Array.isArray(intersectsBody)) {
|
|
199
|
-
return makeGeoFilterBbox(field, intersectsBody, firstKey);
|
|
200
|
-
} else if ("bbox" in intersectsBody && !("type" in intersectsBody)) {
|
|
201
|
-
return makeGeoFilterBbox(field, intersectsBody.bbox, firstKey);
|
|
202
|
-
} else {
|
|
203
|
-
const coordinates = "polygon" in intersectsBody ? intersectsBody.polygon : intersectsBody.coordinates;
|
|
204
|
-
return makeGeoFilterPolygon(field, coordinates, "intersectsPolygon");
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return {
|
|
208
|
-
type: firstKey.substring(1),
|
|
209
|
-
field,
|
|
210
|
-
value: filter[firstKey]
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// src/object/aggregateOrThrow.ts
|
|
215
|
-
async function aggregateOrThrow(clientCtx, objectType, objectSet = {
|
|
216
|
-
type: "base",
|
|
217
|
-
objectType: objectType["apiName"]
|
|
218
|
-
}, req) {
|
|
219
|
-
const body = {
|
|
220
|
-
aggregation: modernToLegacyAggregationClause(req.select),
|
|
221
|
-
groupBy: [],
|
|
222
|
-
where: void 0
|
|
223
|
-
};
|
|
224
|
-
if (req.groupBy) {
|
|
225
|
-
body.groupBy = modernToLegacyGroupByClause(req.groupBy);
|
|
226
|
-
}
|
|
227
|
-
if (req.where) {
|
|
228
|
-
body.where = modernToLegacyWhereClause(req.where);
|
|
229
|
-
}
|
|
230
|
-
const result = await aggregateObjectSetV2(createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, {
|
|
231
|
-
objectSet,
|
|
232
|
-
groupBy: body.groupBy,
|
|
233
|
-
aggregation: body.aggregation
|
|
234
|
-
});
|
|
235
|
-
if (!req.groupBy) {
|
|
236
|
-
!(result.data.length === 1) ? process.env.NODE_ENV !== "production" ? invariant2(false, "no group by clause should mean only one data result") : invariant2(false) : void 0;
|
|
237
|
-
return legacyToModernSingleAggregationResult(result.data[0]);
|
|
238
|
-
}
|
|
239
|
-
const ret = result.data.map((entry) => {
|
|
240
|
-
return {
|
|
241
|
-
$group: entry.group,
|
|
242
|
-
...legacyToModernSingleAggregationResult(entry)
|
|
243
|
-
};
|
|
244
|
-
});
|
|
245
|
-
return ret;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// src/createCachedOntologyTransform.ts
|
|
249
|
-
function createCachedOntologyTransform(creator) {
|
|
250
|
-
const cache = /* @__PURE__ */ new Map();
|
|
251
|
-
return (ontology, type) => {
|
|
252
|
-
const objectDefinition = ontology.objects[type];
|
|
253
|
-
let result = cache.get(objectDefinition);
|
|
254
|
-
if (result == null) {
|
|
255
|
-
result = creator(ontology, type);
|
|
256
|
-
cache.set(objectDefinition, result);
|
|
257
|
-
}
|
|
258
|
-
return result;
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// src/object/Attachment.ts
|
|
263
|
-
var Attachment = class {
|
|
264
|
-
constructor(rid) {
|
|
265
|
-
this.rid = rid;
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
function isAttachment(o) {
|
|
269
|
-
return o instanceof Attachment;
|
|
270
|
-
}
|
|
271
|
-
async function getLinkedObjectByPkOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, options) {
|
|
272
|
-
const object = await getLinkedObjectV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {
|
|
273
|
-
select: options?.select ?? [],
|
|
274
|
-
excludeRid: !options?.includeRid
|
|
275
|
-
});
|
|
276
|
-
const objects = [object];
|
|
277
|
-
convertWireToOsdkObjects(client, objects);
|
|
278
|
-
return objects[0];
|
|
279
|
-
}
|
|
280
|
-
async function pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, options) {
|
|
281
|
-
const page = await listLinkedObjectsV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, {
|
|
282
|
-
pageSize: options?.pageSize,
|
|
283
|
-
pageToken: options?.nextPageToken,
|
|
284
|
-
select: options?.select ?? [],
|
|
285
|
-
excludeRid: !options?.includeRid
|
|
286
|
-
});
|
|
287
|
-
convertWireToOsdkObjects(client, page.data);
|
|
288
|
-
return {
|
|
289
|
-
nextPageToken: page.nextPageToken,
|
|
290
|
-
data: page.data
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// src/object/getLinkedObjectOrThrow.ts
|
|
295
|
-
async function getLinkedObjectOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, select) {
|
|
296
|
-
const result = await pageLinkedObjectsOrThrow(client, sourceApiName, primaryKey, linkTypeApiName, {
|
|
297
|
-
pageSize: 1,
|
|
298
|
-
select
|
|
299
|
-
});
|
|
300
|
-
if (result.data.length !== 1 || result.nextPageToken != null) {
|
|
301
|
-
throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? " with nextPageToken set" : ""}`);
|
|
302
|
-
}
|
|
303
|
-
return result.data[0];
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// src/object/convertWireToOsdkObjects.ts
|
|
307
|
-
var getPrototype = createCachedOntologyTransform(createPrototype);
|
|
308
|
-
var getConverter = createCachedOntologyTransform(createConverter);
|
|
309
|
-
var OriginClient = Symbol();
|
|
310
|
-
function createPrototype(ontology, type) {
|
|
311
|
-
const objDef = ontology.objects[type];
|
|
312
|
-
const proto = {};
|
|
313
|
-
if (!objDef) {
|
|
314
|
-
return proto;
|
|
315
|
-
}
|
|
316
|
-
Object.defineProperty(proto, "$link", {
|
|
317
|
-
get: function() {
|
|
318
|
-
const client = this[OriginClient];
|
|
319
|
-
const primaryKey = this["__primaryKey"];
|
|
320
|
-
return new Proxy({}, {
|
|
321
|
-
get(_target, p, _receiver) {
|
|
322
|
-
const linkDef = objDef.links[p];
|
|
323
|
-
if (linkDef == null) {
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
if (!linkDef.multiplicity) {
|
|
327
|
-
return {
|
|
328
|
-
get: (options) => getLinkedObjectOrThrow(client, type, primaryKey, p, options?.select)
|
|
329
|
-
};
|
|
330
|
-
} else {
|
|
331
|
-
return {
|
|
332
|
-
get: (targetPrimaryKey, options) => getLinkedObjectByPkOrThrow(client, type, primaryKey, p, targetPrimaryKey, options),
|
|
333
|
-
fetchPageOrThrow: (options) => pageLinkedObjectsOrThrow(client, type, primaryKey, p, {
|
|
334
|
-
nextPageToken: options?.nextPageToken,
|
|
335
|
-
pageSize: options?.pageSize,
|
|
336
|
-
select: options?.select
|
|
337
|
-
})
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
},
|
|
343
|
-
enumerable: false,
|
|
344
|
-
configurable: false
|
|
345
|
-
});
|
|
346
|
-
return proto;
|
|
347
|
-
}
|
|
348
|
-
function createConverter(ontology, type) {
|
|
349
|
-
const objDef = ontology.objects[type];
|
|
350
|
-
if (!objDef) {
|
|
351
|
-
return false;
|
|
352
|
-
}
|
|
353
|
-
const steps = [];
|
|
354
|
-
for (const [key, value] of Object.entries(objDef.properties)) {
|
|
355
|
-
if (value.type === "attachment") {
|
|
356
|
-
steps.push((o) => {
|
|
357
|
-
if (o[key] != null) {
|
|
358
|
-
if (Array.isArray(o[key])) {
|
|
359
|
-
o[key] = o[key].map((a) => new Attachment(a.rid));
|
|
360
|
-
} else {
|
|
361
|
-
o[key] = new Attachment(o[key].rid);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
return steps.length > 0 ? (o) => {
|
|
368
|
-
for (const step of steps) {
|
|
369
|
-
step(o);
|
|
370
|
-
}
|
|
371
|
-
} : false;
|
|
372
|
-
}
|
|
373
|
-
function convertWireToOsdkObjects(client, objs) {
|
|
374
|
-
for (const obj of objs) {
|
|
375
|
-
if (obj.__rid) {
|
|
376
|
-
obj.$rid = obj.__rid;
|
|
377
|
-
delete obj.__rid;
|
|
378
|
-
}
|
|
379
|
-
obj.$apiName = obj.__apiName;
|
|
380
|
-
obj.$objectType = obj.__apiName;
|
|
381
|
-
obj.$primaryKey = obj.__primaryKey;
|
|
382
|
-
{
|
|
383
|
-
Object.defineProperties(obj, {
|
|
384
|
-
"__apiName": {
|
|
385
|
-
enumerable: false
|
|
386
|
-
},
|
|
387
|
-
"__primaryKey": {
|
|
388
|
-
enumerable: false
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
const proto = getPrototype(client.ontology, obj.__apiName);
|
|
393
|
-
const converter = getConverter(client.ontology, obj.__apiName);
|
|
394
|
-
Object.setPrototypeOf(obj, proto);
|
|
395
|
-
Object.defineProperty(obj, OriginClient, {
|
|
396
|
-
value: client,
|
|
397
|
-
enumerable: false,
|
|
398
|
-
configurable: false,
|
|
399
|
-
writable: false
|
|
400
|
-
});
|
|
401
|
-
if (converter) {
|
|
402
|
-
converter(obj);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// src/object/fetchPageOrThrow.ts
|
|
408
|
-
async function fetchPageOrThrow(client, objectType, args, objectSet = {
|
|
409
|
-
type: "base",
|
|
410
|
-
objectType: objectType["apiName"]
|
|
411
|
-
}) {
|
|
412
|
-
const body = {
|
|
413
|
-
objectSet,
|
|
414
|
-
// We have to do the following case because LoadObjectSetRequestV2 isnt readonly
|
|
415
|
-
select: args?.select ?? [],
|
|
416
|
-
// FIXME?
|
|
417
|
-
excludeRid: !args?.includeRid
|
|
418
|
-
};
|
|
419
|
-
if (args?.nextPageToken) {
|
|
420
|
-
body.pageToken = args.nextPageToken;
|
|
421
|
-
}
|
|
422
|
-
if (args?.pageSize != null) {
|
|
423
|
-
body.pageSize = args.pageSize;
|
|
424
|
-
}
|
|
425
|
-
if (args?.orderBy != null) {
|
|
426
|
-
body.orderBy = {
|
|
427
|
-
fields: Object.entries(args.orderBy).map(([field, direction]) => ({
|
|
428
|
-
field,
|
|
429
|
-
direction
|
|
430
|
-
}))
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
const r = await loadObjectSetV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, body);
|
|
434
|
-
convertWireToOsdkObjects(client, r.data);
|
|
435
|
-
return r;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
// src/object/index.ts
|
|
439
|
-
var object_exports = {};
|
|
440
|
-
__export(object_exports, {
|
|
441
|
-
aggregateOrThrow: () => aggregateOrThrow,
|
|
442
|
-
fetchPageOrThrow: () => fetchPageOrThrow
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
export { aggregateOrThrow, convertWireToOsdkObjects, fetchPageOrThrow, isAttachment, modernToLegacyWhereClause, object_exports };
|
|
446
|
-
//# sourceMappingURL=out.js.map
|
|
447
|
-
//# sourceMappingURL=chunk-XI2O777X.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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/query/WhereClause.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"],"mappings":";;;;;;;AAgBA,SAAS,4BAA4B;AACrC,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,WAAW,KAAK,QAAQ,IAAI,aAAa,eAAe,UAAU,OAAO,4C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AAAA;AAAA,IAEA,QAAQ,MAAM,UAAU,CAAC;AAAA;AAAA,IAEzB,YAAY,CAAC,MAAM;AAAA,EACrB;AACA,MAAI,MAAM,eAAe;AACvB,SAAK,YAAY,KAAK;AAAA,EACxB;AACA,MAAI,MAAM,YAAY,MAAM;AAC1B,SAAK,WAAW,KAAK;AAAA,EACvB;AACA,MAAI,MAAM,WAAW,MAAM;AACzB,SAAK,UAAU;AAAA,MACb,QAAQ,OAAO,QAAQ,KAAK,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,SAAS,OAAO;AAAA,QAChE;AAAA,QACA;AAAA,MACF,EAAE;AAAA,IACJ;AAAA,EACF;AACA,QAAM,IAAI,MAAM,gBAAgBA,sBAAqB,OAAO,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,SAAS,iBAAiB,IAAI;AAChI,2BAAyB,QAAQ,EAAE,IAAI;AAIvC,SAAO;AACT;;;AOlDA;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 { aggregateObjectSetV2 } 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, objectSet = {\n type: \"base\",\n objectType: objectType[\"apiName\"]\n}, 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 }\n const result = await aggregateObjectSetV2(createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, {\n objectSet,\n groupBy: body.groupBy,\n aggregation: body.aggregation\n });\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 ...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\";\nimport { DistanceUnitMapping } from \"../../query/WhereClause.js\";\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 return handleWherePair(parts[0]);\n }\n return {\n type: \"and\",\n value: parts.map(handleWherePair)\n };\n}\nfunction makeGeoFilterBbox(field, bbox, filterType) {\n return {\n type: filterType === \"$within\" ? \"withinBoundingBox\" : \"intersectsBoundingBox\",\n field,\n value: {\n topLeft: {\n type: \"Point\",\n coordinates: [bbox[0], bbox[3]]\n },\n bottomRight: {\n type: \"Point\",\n coordinates: [bbox[2], bbox[1]]\n }\n }\n };\n}\nfunction makeGeoFilterPolygon(field, coordinates, filterType) {\n return {\n type: filterType,\n field,\n value: {\n type: \"Polygon\",\n coordinates\n }\n };\n}\nfunction handleWherePair([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 const keysOfFilter = Object.keys(filter);\n\n // If any of the keys start with `$` then they must be the only one.\n // e.g. `where({ name: { $eq: \"foo\", $ne: \"bar\" } })` is invalid currently\n const hasDollarSign = keysOfFilter.some(key => key.startsWith(\"$\"));\n !(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"WhereClause Filter with multiple clauses isn't allowed\") : invariant(false) : void 0;\n if (!hasDollarSign) {\n // Future case for structs\n throw new Error(\"Unsupported filter. Did you forget to use a $-prefixed filter?\");\n }\n const firstKey = keysOfFilter[0];\n !(filter[firstKey] != null) ? process.env.NODE_ENV !== \"production\" ? invariant(false) : invariant(false) : void 0;\n if (firstKey === \"$ne\") {\n return {\n type: \"not\",\n value: {\n type: \"eq\",\n field,\n value: filter[firstKey]\n }\n };\n }\n if (firstKey === \"$within\") {\n const withinBody = filter[firstKey];\n if (Array.isArray(withinBody)) {\n return makeGeoFilterBbox(field, withinBody, firstKey);\n } else if (\"bbox\" in withinBody && !(\"type\" in withinBody)) {\n return makeGeoFilterBbox(field, withinBody.bbox, firstKey);\n } else if (\"distance\" in withinBody && \"of\" in withinBody) {\n return {\n type: \"withinDistanceOf\",\n field,\n value: {\n center: Array.isArray(withinBody.of) ? {\n type: \"Point\",\n coordinates: withinBody.of\n } : withinBody.of,\n distance: {\n value: withinBody.distance[0],\n unit: DistanceUnitMapping[withinBody.distance[1]]\n }\n }\n };\n } else {\n const coordinates = \"polygon\" in withinBody ? withinBody.polygon : withinBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"withinPolygon\");\n }\n }\n if (firstKey === \"$intersects\") {\n const intersectsBody = filter[firstKey];\n if (Array.isArray(intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody, firstKey);\n } else if (\"bbox\" in intersectsBody && !(\"type\" in intersectsBody)) {\n return makeGeoFilterBbox(field, intersectsBody.bbox, firstKey);\n } else {\n const coordinates = \"polygon\" in intersectsBody ? intersectsBody.polygon : intersectsBody.coordinates;\n return makeGeoFilterPolygon(field, coordinates, \"intersectsPolygon\");\n }\n }\n return {\n type: firstKey.substring(1),\n field,\n value: filter[firstKey]\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\n// We need to conditional here to force the union to be distributed\n\nexport const DistanceUnitMapping = {\n \"centimeter\": \"CENTIMETERS\",\n \"centimeters\": \"CENTIMETERS\",\n \"cm\": \"CENTIMETERS\",\n \"meter\": \"METERS\",\n \"meters\": \"METERS\",\n \"m\": \"METERS\",\n \"kilometer\": \"KILOMETERS\",\n \"kilometers\": \"KILOMETERS\",\n \"km\": \"KILOMETERS\",\n \"inch\": \"INCHES\",\n \"inches\": \"INCHES\",\n \"foot\": \"FEET\",\n \"feet\": \"FEET\",\n \"yard\": \"YARDS\",\n \"yards\": \"YARDS\",\n \"mile\": \"MILES\",\n \"miles\": \"MILES\",\n \"nautical_mile\": \"NAUTICAL_MILES\",\n \"nauticalMile\": \"NAUTICAL_MILES\",\n \"nautical miles\": \"NAUTICAL_MILES\"\n};\n\n// FIXME we need to represent all types","/*\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: objectType[\"apiName\"]\n}) {\n const body = {\n objectSet,\n // We have to do the following case because LoadObjectSetRequestV2 isnt readonly\n select: args?.select ?? [],\n // FIXME?\n excludeRid: !args?.includeRid\n };\n if (args?.nextPageToken) {\n body.pageToken = args.nextPageToken;\n }\n if (args?.pageSize != null) {\n body.pageSize = args.pageSize;\n }\n if (args?.orderBy != null) {\n body.orderBy = {\n fields: Object.entries(args.orderBy).map(([field, direction]) => ({\n field,\n direction\n }))\n };\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, options) {\n const object = await getLinkedObjectV2(createOpenApiRequest(client.stack, client.fetch), client.ontology.metadata.ontologyApiName, sourceApiName, primaryKey, linkTypeApiName, linkedObjectPrimaryKey, {\n select: options?.select ?? [],\n excludeRid: !options?.includeRid\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 excludeRid: !options?.includeRid\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 if (!objDef) {\n return proto;\n }\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),\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 return proto;\n}\n\n// preprocess the ontology definition to more quickly apply object conversions when needed\nfunction createConverter(ontology, type) {\n const objDef = ontology.objects[type];\n if (!objDef) {\n return false;\n }\n const steps = [];\n for (const [key, value] of Object.entries(objDef.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}\nconst isAfterFeb2024OrNewApis = false;\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 if (obj.__rid) {\n obj.$rid = obj.__rid;\n delete obj.__rid;\n }\n\n // Backend returns as __apiName but we want to stick to $ structure\n obj.$apiName = obj.__apiName;\n\n // for now these are the same but when we start doing interface projections the $objectType will always be underlying and\n // the $apiName will be for the current view (in current designs)\n obj.$objectType = obj.__apiName;\n\n // copying over for now as its always returned. In the future, this should just be inferred from underlying\n obj.$primaryKey = obj.__primaryKey;\n\n // After Feb 2024 (unless we have new apis):\n if (isAfterFeb2024OrNewApis) {\n delete obj.__apiName;\n delete obj.__primaryKey;\n } else {\n // Hide these from things like `console.log` so that people\n // don't think to use them.\n Object.defineProperties(obj, {\n \"__apiName\": {\n enumerable: false\n },\n \"__primaryKey\": {\n enumerable: false\n }\n });\n }\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 converter(obj);\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\";"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ObjectTypeKeysFrom, OntologyDefinition } from "@osdk/api";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a getter function that caches based on the ontology.objects[type] value
|
|
4
|
-
*
|
|
5
|
-
* 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
|
|
6
|
-
*/
|
|
7
|
-
export declare function createCachedOntologyTransform<O extends OntologyDefinition<any>, K extends ObjectTypeKeysFrom<O>, T>(creator: (ontology: O, type: K) => T): (ontology: O, type: K) => T;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ObjectOrInterfaceDefinition } from "@osdk/api";
|
|
2
|
-
import type { ObjectSet } from "@osdk/gateway/types";
|
|
3
|
-
import type { ClientContext } from "@osdk/shared.net";
|
|
4
|
-
import type { AggregateOpts } from "../query/aggregations/AggregateOpts.js";
|
|
5
|
-
import type { AggregationsResults } from "../query/index.js";
|
|
6
|
-
export declare function aggregateOrThrow<Q extends ObjectOrInterfaceDefinition, const AO extends AggregateOpts<Q, any>>(clientCtx: ClientContext<any>, objectType: Q, objectSet: ObjectSet | undefined, req: AO): Promise<AggregationsResults<Q, AO>>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ObjectOrInterfaceDefinition, ObjectOrInterfacePropertyKeysFrom2, ObjectTypeDefinition } from "@osdk/api";
|
|
2
|
-
import type { ObjectSet } from "@osdk/gateway/types";
|
|
3
|
-
import type { ClientContext } from "@osdk/shared.net";
|
|
4
|
-
import type { OsdkObjectFrom } from "../OsdkObjectFrom.js";
|
|
5
|
-
import type { PageResult } from "../PageResult.js";
|
|
6
|
-
export interface SelectArg<Q extends ObjectOrInterfaceDefinition<any, any>, L = ObjectOrInterfacePropertyKeysFrom2<Q>, R extends boolean = false> {
|
|
7
|
-
select?: readonly L[];
|
|
8
|
-
includeRid?: R;
|
|
9
|
-
}
|
|
10
|
-
export interface OrderByArg<Q extends ObjectOrInterfaceDefinition<any, any>, L extends ObjectOrInterfacePropertyKeysFrom2<Q> = ObjectOrInterfacePropertyKeysFrom2<Q>> {
|
|
11
|
-
orderBy?: {
|
|
12
|
-
[K in L]?: "asc" | "desc";
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
export interface FetchPageOrThrowArgs<Q extends ObjectOrInterfaceDefinition<any, any>, L = ObjectOrInterfacePropertyKeysFrom2<Q>, R extends boolean = false> extends SelectArg<Q, L, R>, OrderByArg<Q, ObjectOrInterfacePropertyKeysFrom2<Q>> {
|
|
16
|
-
nextPageToken?: string;
|
|
17
|
-
pageSize?: number;
|
|
18
|
-
}
|
|
19
|
-
export declare function fetchPageOrThrow<Q extends ObjectOrInterfaceDefinition, const A extends FetchPageOrThrowArgs<Q, any, any>>(client: ClientContext<any>, objectType: Q, args: A, objectSet?: ObjectSet): Promise<PageResult<OsdkObjectFrom<Q extends ObjectTypeDefinition<any> ? Q : never, A["select"] extends readonly string[] ? A["select"][number] : ObjectOrInterfacePropertyKeysFrom2<Q>, A["includeRid"] extends true ? true : false>>>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ObjectTypeKeysFrom, ObjectTypeLinkKeysFrom, ObjectTypeLinkTargetTypeFrom, OntologyDefinition } from "@osdk/api";
|
|
2
|
-
import type { ClientContext } from "@osdk/shared.net";
|
|
3
|
-
import type { OsdkObjectFrom } from "../OsdkObjectFrom.js";
|
|
4
|
-
import type { SelectArg } from "./fetchPageOrThrow.js";
|
|
5
|
-
export declare function getLinkedObjectByPkOrThrow<O extends OntologyDefinition<any>, T extends ObjectTypeKeysFrom<O> & string, L extends ObjectTypeLinkKeysFrom<O, T> & string, S extends SelectArg<ObjectTypeLinkTargetTypeFrom<O, T, L>> = SelectArg<ObjectTypeLinkTargetTypeFrom<O, T, L>>>(client: ClientContext<O>, sourceApiName: T, primaryKey: any, linkTypeApiName: L, linkedObjectPrimaryKey: any, options?: S): Promise<OsdkObjectFrom<O["objects"][T]>>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ObjectTypeKeysFrom, ObjectTypeLinkKeysFrom2, OntologyDefinition } from "@osdk/api";
|
|
2
|
-
import { type ClientContext } from "@osdk/shared.net";
|
|
3
|
-
import type { SelectArg } from "./fetchPageOrThrow.js";
|
|
4
|
-
export declare function getLinkedObjectOrThrow<O extends OntologyDefinition<any>, T extends ObjectTypeKeysFrom<O> & string, L extends ObjectTypeLinkKeysFrom2<O["objects"][T]> & string, S extends SelectArg<O["objects"][T]>["select"]>(client: ClientContext<O>, sourceApiName: T, primaryKey: any, linkTypeApiName: L, select?: S): Promise<import("../OsdkObjectFrom.js").OsdkObjectFrom<O["objects"][T]["links"][ObjectTypeLinkKeysFrom2<O["objects"][T]>]["__Mark"], import("./pageLinkedObjectsOrThrow.js").SelectArgToKeys<{
|
|
5
|
-
readonly pageSize: 1;
|
|
6
|
-
readonly select: S | undefined;
|
|
7
|
-
}>>>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ObjectOrInterfacePropertyKeysFrom2, ObjectTypeKeysFrom, ObjectTypeLinkKeysFrom2, OntologyDefinition } from "@osdk/api";
|
|
2
|
-
import { type ClientContext } from "@osdk/shared.net";
|
|
3
|
-
import type { OsdkObjectFrom } from "../OsdkObjectFrom.js";
|
|
4
|
-
import type { PageResult } from "../PageResult.js";
|
|
5
|
-
import type { FetchPageOrThrowArgs, SelectArg } from "./fetchPageOrThrow.js";
|
|
6
|
-
export type SelectArgToKeys<A extends SelectArg<any>> = A["select"] extends readonly string[] ? A["select"][number] : A extends SelectArg<infer Q> ? ObjectOrInterfacePropertyKeysFrom2<Q> : never;
|
|
7
|
-
export declare function pageLinkedObjectsOrThrow<O extends OntologyDefinition<any>, T_SourceTypeKey extends ObjectTypeKeysFrom<O>, T_LinkApiName extends ObjectTypeLinkKeysFrom2<O["objects"][T_SourceTypeKey]>, Q extends O["objects"][T_SourceTypeKey]["links"][T_LinkApiName]["__Mark"], const A extends FetchPageOrThrowArgs<Q>>(client: ClientContext<O>, sourceApiName: T_SourceTypeKey & string, primaryKey: any, linkTypeApiName: string, options: A): Promise<PageResult<OsdkObjectFrom<Q, SelectArgToKeys<A>>>>;
|
|
File without changes
|