@osdk/client 0.7.0 → 0.9.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-OBZVMJLZ.mjs → chunk-BQNFWSLL.mjs} +130 -54
- package/build/js/chunk-BQNFWSLL.mjs.map +1 -0
- package/build/js/{chunk-EU5GNJBK.cjs → chunk-KAL57TC5.cjs} +129 -53
- package/build/js/chunk-KAL57TC5.cjs.map +1 -0
- package/build/js/index.cjs +32 -14
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +28 -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 +3 -3
- package/build/types/ObjectSetCreator.d.ts +3 -3
- package/build/types/OsdkObjectFrom.d.ts +11 -17
- package/build/types/actions/Actions.d.ts +17 -13
- package/build/types/actions/applyAction.d.ts +3 -10
- package/build/types/actions/createActionInvoker.d.ts +2 -1
- package/build/types/definitions/LinkDefinitions.d.ts +12 -13
- package/build/types/generatedNoCheck/Ontology.d.ts +13 -477
- package/build/types/generatedNoCheck/ontology/actions/actionTakesAttachment.d.ts +22 -10
- package/build/types/generatedNoCheck/ontology/actions/actionTakesObjectSet.d.ts +23 -13
- package/build/types/generatedNoCheck/ontology/actions/createOffice.d.ts +40 -28
- package/build/types/generatedNoCheck/ontology/actions/createOfficeAndEmployee.d.ts +46 -34
- package/build/types/generatedNoCheck/ontology/actions/index.d.ts +7 -7
- package/build/types/generatedNoCheck/ontology/actions/moveOffice.d.ts +40 -28
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployee.d.ts +32 -20
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployeeObject.d.ts +33 -23
- package/build/types/generatedNoCheck/ontology/objects/Employee.d.ts +20 -25
- package/build/types/generatedNoCheck/ontology/objects/ObjectWithTimestampPrimaryKey.d.ts +10 -7
- package/build/types/generatedNoCheck/ontology/objects/Office.d.ts +16 -15
- package/build/types/generatedNoCheck/ontology/objects/equipment.d.ts +10 -7
- package/build/types/generatedNoCheck/ontology/objects/objectTypeWithAllPropertyTypes.d.ts +38 -35
- package/build/types/index.d.ts +3 -1
- package/build/types/internal/conversions/legacyToModernSingleAggregationResult.d.ts +1 -1
- package/build/types/internal/conversions/modernToLegacyAggregationClause.d.ts +1 -2
- package/build/types/internal/conversions/modernToLegacyGroupByClause.d.ts +1 -2
- package/build/types/internal/conversions/modernToLegacyWhereClause.test.d.ts +1 -0
- package/build/types/object/aggregateOrThrow.d.ts +3 -2
- package/build/types/object/fetchPageOrThrow.d.ts +4 -4
- package/build/types/object/followLinkOrThrow.d.ts +1 -1
- package/build/types/object/getLinkedObjectByPkOrThrow.d.ts +1 -1
- package/build/types/object/getLinkedObjectOrThrow.d.ts +5 -2
- package/build/types/object/pageLinkedObjectsOrThrow.d.ts +4 -6
- package/build/types/objectSet/LinkTypesFrom.d.ts +2 -2
- package/build/types/objectSet/ObjectSet.d.ts +13 -11
- package/build/types/objectSet/ObjectSet.test.d.ts +1 -0
- package/build/types/objectSet/ObjectSetListener.d.ts +7 -7
- package/build/types/objectSet/ObjectSetListenerWebsocket.d.ts +2 -2
- package/build/types/objectSet/createObjectSet.d.ts +2 -2
- package/build/types/query/WhereClause.d.ts +46 -7
- package/build/types/query/aggregations/AggregatableKeys.d.ts +3 -3
- package/build/types/query/aggregations/AggregateOpts.d.ts +4 -4
- package/build/types/query/aggregations/AggregationResultsWithGroups.d.ts +4 -4
- package/build/types/query/aggregations/AggregationResultsWithoutGroups.d.ts +5 -5
- package/build/types/query/aggregations/AggregationsClause.d.ts +5 -5
- package/build/types/query/aggregations/AggregationsClause.test.d.ts +4 -2
- package/build/types/query/aggregations/AggregationsResults.d.ts +2 -2
- package/build/types/query/aggregations/GroupByClause.d.ts +4 -4
- package/build/types/query/aggregations/GroupByClause.test.d.ts +2 -1
- package/build/types/util/test/mockOntology.d.ts +50 -48
- package/changelog/0.6.0/pr-9.v2.yml +5 -0
- package/changelog/0.7.0/pr-20.v2.yml +5 -0
- package/changelog/0.7.0/pr-24.v2.yml +5 -0
- package/changelog/0.7.0/pr-28.v2.yml +5 -0
- package/changelog/0.8.0/pr-30.v2.yml +5 -0
- package/changelog/0.9.0/pr-43.v2.yml +5 -0
- package/changelog/0.9.0/pr-45.v2.yml +5 -0
- package/changelog/0.9.0/pr-48.v2.yml +5 -0
- package/changelog/0.9.0/pr-59.v2.yml +5 -0
- package/changelog/0.9.0/pr-65.v2.yml +5 -0
- package/changelog/0.9.0/pr-72.v2.yml +5 -0
- package/changelog/0.9.0/pr-75.v2.yml +5 -0
- package/changelog/@unreleased/.gitkeep +0 -0
- package/package.json +12 -6
- package/build/js/chunk-EU5GNJBK.cjs.map +0 -1
- package/build/js/chunk-OBZVMJLZ.mjs.map +0 -1
- /package/{CHANGELOG.md → CHANGELOG_OLD.md} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aggregateObjectSetV2, loadObjectSetV2, getLinkedObjectV2, listLinkedObjectsV2 } from '@osdk/gateway/requests';
|
|
2
2
|
import { createOpenApiRequest, PalantirApiError } from '@osdk/shared.net';
|
|
3
3
|
import invariant2 from 'tiny-invariant';
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ var __export = (target, all) => {
|
|
|
10
10
|
function legacyToModernSingleAggregationResult(entry) {
|
|
11
11
|
return entry.metrics.reduce((accumulator, curValue) => {
|
|
12
12
|
const parts = curValue.name.split(".");
|
|
13
|
-
!(parts.length
|
|
13
|
+
!(parts.length === 2) ? process.env.NODE_ENV !== "production" ? invariant2(false, "assumed we were getting a `${key}.${type}`") : invariant2(false) : void 0;
|
|
14
14
|
if (!(parts[0] in accumulator)) {
|
|
15
15
|
accumulator[parts[0]] = {};
|
|
16
16
|
}
|
|
@@ -62,6 +62,32 @@ function modernToLegacyGroupByClause(groupByClause) {
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
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
|
|
65
91
|
function modernToLegacyWhereClause(whereClause) {
|
|
66
92
|
if ("$and" in whereClause) {
|
|
67
93
|
return {
|
|
@@ -81,69 +107,115 @@ function modernToLegacyWhereClause(whereClause) {
|
|
|
81
107
|
}
|
|
82
108
|
const parts = Object.entries(whereClause);
|
|
83
109
|
if (parts.length === 1) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
}
|
|
92
130
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
value: filter[type]
|
|
103
|
-
}
|
|
104
|
-
};
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function makeGeoFilterPolygon(field, coordinates, filterType) {
|
|
134
|
+
return {
|
|
135
|
+
type: filterType,
|
|
136
|
+
field,
|
|
137
|
+
value: {
|
|
138
|
+
type: "Polygon",
|
|
139
|
+
coordinates
|
|
105
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") {
|
|
106
146
|
return {
|
|
107
|
-
type,
|
|
147
|
+
type: "eq",
|
|
108
148
|
field,
|
|
109
|
-
value: filter
|
|
149
|
+
value: filter
|
|
110
150
|
};
|
|
111
151
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
type: "not",
|
|
129
|
-
value: {
|
|
130
|
-
type: "eq",
|
|
131
|
-
field,
|
|
132
|
-
value: filter[q]
|
|
133
|
-
}
|
|
134
|
-
};
|
|
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]
|
|
135
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) {
|
|
136
177
|
return {
|
|
137
|
-
type:
|
|
178
|
+
type: "withinDistanceOf",
|
|
138
179
|
field,
|
|
139
|
-
value:
|
|
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
|
+
}
|
|
140
190
|
};
|
|
141
|
-
}
|
|
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]
|
|
142
211
|
};
|
|
143
212
|
}
|
|
144
213
|
|
|
145
214
|
// src/object/aggregateOrThrow.ts
|
|
146
|
-
async function aggregateOrThrow(clientCtx, objectType,
|
|
215
|
+
async function aggregateOrThrow(clientCtx, objectType, objectSet = {
|
|
216
|
+
type: "base",
|
|
217
|
+
objectType: objectType["apiName"]
|
|
218
|
+
}, req) {
|
|
147
219
|
const body = {
|
|
148
220
|
aggregation: modernToLegacyAggregationClause(req.select),
|
|
149
221
|
groupBy: [],
|
|
@@ -155,7 +227,11 @@ async function aggregateOrThrow(clientCtx, objectType, req) {
|
|
|
155
227
|
if (req.where) {
|
|
156
228
|
body.where = modernToLegacyWhereClause(req.where);
|
|
157
229
|
}
|
|
158
|
-
const result = await
|
|
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
|
+
});
|
|
159
235
|
if (!req.groupBy) {
|
|
160
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;
|
|
161
237
|
return legacyToModernSingleAggregationResult(result.data[0]);
|
|
@@ -312,7 +388,7 @@ function convertWireToOsdkObjects(client, objs) {
|
|
|
312
388
|
// src/object/fetchPageOrThrow.ts
|
|
313
389
|
async function fetchPageOrThrow(client, objectType, args, objectSet = {
|
|
314
390
|
type: "base",
|
|
315
|
-
objectType
|
|
391
|
+
objectType: objectType["apiName"]
|
|
316
392
|
}) {
|
|
317
393
|
const body = {
|
|
318
394
|
objectSet,
|
|
@@ -340,4 +416,4 @@ __export(object_exports, {
|
|
|
340
416
|
|
|
341
417
|
export { aggregateOrThrow, convertWireToOsdkObjects, fetchPageOrThrow, isAttachment, modernToLegacyWhereClause, object_exports };
|
|
342
418
|
//# sourceMappingURL=out.js.map
|
|
343
|
-
//# sourceMappingURL=chunk-
|
|
419
|
+
//# sourceMappingURL=chunk-BQNFWSLL.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/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,OA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B,OAAO,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,SAAS,iBAAiB,IAAI;AAChI,2BAAyB,QAAQ,EAAE,IAAI;AAIvC,SAAO;AACT;;;AOxCA;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 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\";\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 ?? [] // FIXME?\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 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?.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 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}\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 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\";"]}
|
|
@@ -16,7 +16,7 @@ var __export = (target, all) => {
|
|
|
16
16
|
function legacyToModernSingleAggregationResult(entry) {
|
|
17
17
|
return entry.metrics.reduce((accumulator, curValue) => {
|
|
18
18
|
const parts = curValue.name.split(".");
|
|
19
|
-
!(parts.length
|
|
19
|
+
!(parts.length === 2) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "assumed we were getting a `${key}.${type}`") : invariant2__default.default(false) : void 0;
|
|
20
20
|
if (!(parts[0] in accumulator)) {
|
|
21
21
|
accumulator[parts[0]] = {};
|
|
22
22
|
}
|
|
@@ -68,6 +68,32 @@ function modernToLegacyGroupByClause(groupByClause) {
|
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
+
|
|
72
|
+
// src/query/WhereClause.ts
|
|
73
|
+
var DistanceUnitMapping = {
|
|
74
|
+
"centimeter": "CENTIMETERS",
|
|
75
|
+
"centimeters": "CENTIMETERS",
|
|
76
|
+
"cm": "CENTIMETERS",
|
|
77
|
+
"meter": "METERS",
|
|
78
|
+
"meters": "METERS",
|
|
79
|
+
"m": "METERS",
|
|
80
|
+
"kilometer": "KILOMETERS",
|
|
81
|
+
"kilometers": "KILOMETERS",
|
|
82
|
+
"km": "KILOMETERS",
|
|
83
|
+
"inch": "INCHES",
|
|
84
|
+
"inches": "INCHES",
|
|
85
|
+
"foot": "FEET",
|
|
86
|
+
"feet": "FEET",
|
|
87
|
+
"yard": "YARDS",
|
|
88
|
+
"yards": "YARDS",
|
|
89
|
+
"mile": "MILES",
|
|
90
|
+
"miles": "MILES",
|
|
91
|
+
"nautical_mile": "NAUTICAL_MILES",
|
|
92
|
+
"nauticalMile": "NAUTICAL_MILES",
|
|
93
|
+
"nautical miles": "NAUTICAL_MILES"
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// src/internal/conversions/modernToLegacyWhereClause.ts
|
|
71
97
|
function modernToLegacyWhereClause(whereClause) {
|
|
72
98
|
if ("$and" in whereClause) {
|
|
73
99
|
return {
|
|
@@ -87,69 +113,115 @@ function modernToLegacyWhereClause(whereClause) {
|
|
|
87
113
|
}
|
|
88
114
|
const parts = Object.entries(whereClause);
|
|
89
115
|
if (parts.length === 1) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
116
|
+
return handleWherePair(parts[0]);
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
type: "and",
|
|
120
|
+
value: parts.map(handleWherePair)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function makeGeoFilterBbox(field, bbox, filterType) {
|
|
124
|
+
return {
|
|
125
|
+
type: filterType === "$within" ? "withinBoundingBox" : "intersectsBoundingBox",
|
|
126
|
+
field,
|
|
127
|
+
value: {
|
|
128
|
+
topLeft: {
|
|
129
|
+
type: "Point",
|
|
130
|
+
coordinates: [bbox[0], bbox[3]]
|
|
131
|
+
},
|
|
132
|
+
bottomRight: {
|
|
133
|
+
type: "Point",
|
|
134
|
+
coordinates: [bbox[2], bbox[1]]
|
|
135
|
+
}
|
|
98
136
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
value: filter[type]
|
|
109
|
-
}
|
|
110
|
-
};
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function makeGeoFilterPolygon(field, coordinates, filterType) {
|
|
140
|
+
return {
|
|
141
|
+
type: filterType,
|
|
142
|
+
field,
|
|
143
|
+
value: {
|
|
144
|
+
type: "Polygon",
|
|
145
|
+
coordinates
|
|
111
146
|
}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function handleWherePair([field, filter]) {
|
|
150
|
+
!(filter != null) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "Defined key values are only allowed when they are not undefined.") : invariant2__default.default(false) : void 0;
|
|
151
|
+
if (typeof filter === "string" || typeof filter === "number") {
|
|
112
152
|
return {
|
|
113
|
-
type,
|
|
153
|
+
type: "eq",
|
|
114
154
|
field,
|
|
115
|
-
value: filter
|
|
155
|
+
value: filter
|
|
116
156
|
};
|
|
117
157
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
type: "not",
|
|
135
|
-
value: {
|
|
136
|
-
type: "eq",
|
|
137
|
-
field,
|
|
138
|
-
value: filter[q]
|
|
139
|
-
}
|
|
140
|
-
};
|
|
158
|
+
const keysOfFilter = Object.keys(filter);
|
|
159
|
+
const hasDollarSign = keysOfFilter.some((key) => key.startsWith("$"));
|
|
160
|
+
!(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "WhereClause Filter with multiple clauses isn't allowed") : invariant2__default.default(false) : void 0;
|
|
161
|
+
if (!hasDollarSign) {
|
|
162
|
+
throw new Error("Unsupported filter. Did you forget to use a $-prefixed filter?");
|
|
163
|
+
}
|
|
164
|
+
const firstKey = keysOfFilter[0];
|
|
165
|
+
!(filter[firstKey] != null) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false) : invariant2__default.default(false) : void 0;
|
|
166
|
+
if (firstKey === "$ne") {
|
|
167
|
+
return {
|
|
168
|
+
type: "not",
|
|
169
|
+
value: {
|
|
170
|
+
type: "eq",
|
|
171
|
+
field,
|
|
172
|
+
value: filter[firstKey]
|
|
141
173
|
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (firstKey === "$within") {
|
|
177
|
+
const withinBody = filter[firstKey];
|
|
178
|
+
if (Array.isArray(withinBody)) {
|
|
179
|
+
return makeGeoFilterBbox(field, withinBody, firstKey);
|
|
180
|
+
} else if ("bbox" in withinBody && !("type" in withinBody)) {
|
|
181
|
+
return makeGeoFilterBbox(field, withinBody.bbox, firstKey);
|
|
182
|
+
} else if ("distance" in withinBody && "of" in withinBody) {
|
|
142
183
|
return {
|
|
143
|
-
type:
|
|
184
|
+
type: "withinDistanceOf",
|
|
144
185
|
field,
|
|
145
|
-
value:
|
|
186
|
+
value: {
|
|
187
|
+
center: Array.isArray(withinBody.of) ? {
|
|
188
|
+
type: "Point",
|
|
189
|
+
coordinates: withinBody.of
|
|
190
|
+
} : withinBody.of,
|
|
191
|
+
distance: {
|
|
192
|
+
value: withinBody.distance[0],
|
|
193
|
+
unit: DistanceUnitMapping[withinBody.distance[1]]
|
|
194
|
+
}
|
|
195
|
+
}
|
|
146
196
|
};
|
|
147
|
-
}
|
|
197
|
+
} else {
|
|
198
|
+
const coordinates = "polygon" in withinBody ? withinBody.polygon : withinBody.coordinates;
|
|
199
|
+
return makeGeoFilterPolygon(field, coordinates, "withinPolygon");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (firstKey === "$intersects") {
|
|
203
|
+
const intersectsBody = filter[firstKey];
|
|
204
|
+
if (Array.isArray(intersectsBody)) {
|
|
205
|
+
return makeGeoFilterBbox(field, intersectsBody, firstKey);
|
|
206
|
+
} else if ("bbox" in intersectsBody && !("type" in intersectsBody)) {
|
|
207
|
+
return makeGeoFilterBbox(field, intersectsBody.bbox, firstKey);
|
|
208
|
+
} else {
|
|
209
|
+
const coordinates = "polygon" in intersectsBody ? intersectsBody.polygon : intersectsBody.coordinates;
|
|
210
|
+
return makeGeoFilterPolygon(field, coordinates, "intersectsPolygon");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
type: firstKey.substring(1),
|
|
215
|
+
field,
|
|
216
|
+
value: filter[firstKey]
|
|
148
217
|
};
|
|
149
218
|
}
|
|
150
219
|
|
|
151
220
|
// src/object/aggregateOrThrow.ts
|
|
152
|
-
async function aggregateOrThrow(clientCtx, objectType,
|
|
221
|
+
async function aggregateOrThrow(clientCtx, objectType, objectSet = {
|
|
222
|
+
type: "base",
|
|
223
|
+
objectType: objectType["apiName"]
|
|
224
|
+
}, req) {
|
|
153
225
|
const body = {
|
|
154
226
|
aggregation: modernToLegacyAggregationClause(req.select),
|
|
155
227
|
groupBy: [],
|
|
@@ -161,7 +233,11 @@ async function aggregateOrThrow(clientCtx, objectType, req) {
|
|
|
161
233
|
if (req.where) {
|
|
162
234
|
body.where = modernToLegacyWhereClause(req.where);
|
|
163
235
|
}
|
|
164
|
-
const result = await requests.
|
|
236
|
+
const result = await requests.aggregateObjectSetV2(shared_net.createOpenApiRequest(clientCtx.stack, clientCtx.fetch), clientCtx.ontology.metadata.ontologyApiName, {
|
|
237
|
+
objectSet,
|
|
238
|
+
groupBy: body.groupBy,
|
|
239
|
+
aggregation: body.aggregation
|
|
240
|
+
});
|
|
165
241
|
if (!req.groupBy) {
|
|
166
242
|
!(result.data.length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "no group by clause should mean only one data result") : invariant2__default.default(false) : void 0;
|
|
167
243
|
return legacyToModernSingleAggregationResult(result.data[0]);
|
|
@@ -318,7 +394,7 @@ function convertWireToOsdkObjects(client, objs) {
|
|
|
318
394
|
// src/object/fetchPageOrThrow.ts
|
|
319
395
|
async function fetchPageOrThrow(client, objectType, args, objectSet = {
|
|
320
396
|
type: "base",
|
|
321
|
-
objectType
|
|
397
|
+
objectType: objectType["apiName"]
|
|
322
398
|
}) {
|
|
323
399
|
const body = {
|
|
324
400
|
objectSet,
|
|
@@ -351,4 +427,4 @@ exports.isAttachment = isAttachment;
|
|
|
351
427
|
exports.modernToLegacyWhereClause = modernToLegacyWhereClause;
|
|
352
428
|
exports.object_exports = object_exports;
|
|
353
429
|
//# sourceMappingURL=out.js.map
|
|
354
|
-
//# sourceMappingURL=chunk-
|
|
430
|
+
//# sourceMappingURL=chunk-KAL57TC5.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/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,4CAA4C,IAAI,UAAU,KAAK,IAAI;AACpJ,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;AACpB,aAAO,EAAE,IAAI,QAAM;AACjB,eAAO;AAAA,UACL,MAAM;AAAA,UACN,MAAM,GAAG,CAAC,IAAI,EAAE;AAAA,UAChB,OAAO;AAAA,QACT;AAAA,MACF,CAAC;AAAA,IACH,OAAO;AACL,aAAO,CAAC;AAAA,QACN,MAAM;AAAA;AAAA,QAEN,MAA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,gBAAU,GAAG;AAAA,IACf;AAAA,EACF;AACF;;;AN1FA,eAAsB,iBAAiB,QAAQ,YAAY,MAAM,YAAY;AAAA,EAC3E,MAAM;AAAA,EACN,YAAY,WAAW,SAAS;AAClC,GAAG;AACD,QAAM,OAAO;AAAA,IACX;AAAA;AAAA,IAEA,QAAQ,MAAM,UAAU,CAAC;AAAA;AAAA,EAC3B;AACA,MAAI,MAAM,eAAe;AACvB,SAAK,YAAY,KAAK;AAAA,EACxB;AACA,MAAI,MAAM,YAAY,MAAM;AAC1B,SAAK,WAAW,KAAK;AAAA,EACvB;AACA,QAAM,IAAI,MAAM,gBAAgBA,sBAAqB,OAAO,OAAO,OAAO,KAAK,GAAG,OAAO,SAAS,SAAS,iBAAiB,IAAI;AAChI,2BAAyB,QAAQ,EAAE,IAAI;AAIvC,SAAO;AACT;;;AOxCA;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 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\";\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 ?? [] // FIXME?\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 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?.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 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}\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 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\";"]}
|