@osdk/client 0.14.0 → 0.15.1-main-20240411211601
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{CHANGELOG_OLD.md → CHANGELOG.md} +11 -0
- package/build/js/index.cjs +1451 -123
- package/build/js/index.cjs.map +1 -1
- package/build/js/index.mjs +1443 -105
- package/build/js/index.mjs.map +1 -1
- package/build/types/Client.d.ts +13 -14
- package/build/types/Client.d.ts.map +1 -1
- package/build/types/MinimalClientContext.d.ts +11 -6
- package/build/types/MinimalClientContext.d.ts.map +1 -1
- package/build/types/ObjectSetCreator.d.ts +1 -1
- package/build/types/ObjectSetCreator.d.ts.map +1 -1
- package/build/types/SatisfiesSemver.d.ts +4 -0
- package/build/types/SatisfiesSemver.d.ts.map +1 -0
- package/build/types/SatisfiesSemver.test.d.ts +2 -0
- package/build/types/SatisfiesSemver.test.d.ts.map +1 -0
- package/build/types/actions/Actions.d.ts +1 -1
- package/build/types/actions/Actions.d.ts.map +1 -1
- package/build/types/actions/applyAction.d.ts.map +1 -1
- package/build/types/createClient.d.ts +2 -6
- package/build/types/createClient.d.ts.map +1 -1
- package/build/types/createMinimalClient.d.ts.map +1 -1
- package/build/types/generatedNoCheck/Ontology.d.ts +2 -5
- package/build/types/generatedNoCheck/Ontology.d.ts.map +1 -1
- package/build/types/generatedNoCheck/OntologyMetadata.d.ts +7 -4
- package/build/types/generatedNoCheck/OntologyMetadata.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/actions/actionTakesAttachment.d.ts +2 -0
- package/build/types/generatedNoCheck/ontology/actions/actionTakesAttachment.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/actions/actionTakesObjectSet.d.ts +2 -0
- package/build/types/generatedNoCheck/ontology/actions/actionTakesObjectSet.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/actions/createOffice.d.ts +2 -0
- package/build/types/generatedNoCheck/ontology/actions/createOffice.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/actions/createOfficeAndEmployee.d.ts +2 -0
- package/build/types/generatedNoCheck/ontology/actions/createOfficeAndEmployee.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/actions/moveOffice.d.ts +2 -0
- package/build/types/generatedNoCheck/ontology/actions/moveOffice.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployee.d.ts +2 -0
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployee.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployeeObject.d.ts +2 -0
- package/build/types/generatedNoCheck/ontology/actions/promoteEmployeeObject.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/interfaces/FooInterface.d.ts +5 -2
- package/build/types/generatedNoCheck/ontology/interfaces/FooInterface.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/objects/Employee.d.ts +5 -2
- package/build/types/generatedNoCheck/ontology/objects/Employee.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/objects/ObjectWithTimestampPrimaryKey.d.ts +5 -2
- package/build/types/generatedNoCheck/ontology/objects/ObjectWithTimestampPrimaryKey.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/objects/Office.d.ts +5 -2
- package/build/types/generatedNoCheck/ontology/objects/Office.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/objects/equipment.d.ts +5 -2
- package/build/types/generatedNoCheck/ontology/objects/equipment.d.ts.map +1 -1
- package/build/types/generatedNoCheck/ontology/objects/objectTypeWithAllPropertyTypes.d.ts +5 -2
- package/build/types/generatedNoCheck/ontology/objects/objectTypeWithAllPropertyTypes.d.ts.map +1 -1
- package/build/types/index.d.ts +8 -12
- package/build/types/index.d.ts.map +1 -1
- package/build/types/internal/conversions/legacyToModernSingleAggregationResult.d.ts +1 -1
- package/build/types/internal/conversions/legacyToModernSingleAggregationResult.d.ts.map +1 -1
- package/build/types/internal/conversions/modernToLegacyAggregationClause.d.ts +2 -2
- package/build/types/internal/conversions/modernToLegacyAggregationClause.d.ts.map +1 -1
- package/build/types/internal/conversions/modernToLegacyGroupByClause.d.ts +1 -1
- package/build/types/internal/conversions/modernToLegacyGroupByClause.d.ts.map +1 -1
- package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
- package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
- package/build/types/object/Result.d.ts +12 -0
- package/build/types/object/Result.d.ts.map +1 -0
- package/build/types/object/aggregate.d.ts +1 -1
- package/build/types/object/aggregate.d.ts.map +1 -1
- package/build/types/object/convertWireToOsdkObjects.d.ts +1 -1
- package/build/types/object/convertWireToOsdkObjects.d.ts.map +1 -1
- package/build/types/object/fetchPage.d.ts +9 -5
- package/build/types/object/fetchPage.d.ts.map +1 -1
- package/build/types/object/fetchSingle.d.ts +3 -3
- package/build/types/object/fetchSingle.d.ts.map +1 -1
- package/build/types/objectSet/ObjectSet.d.ts +4 -2
- package/build/types/objectSet/ObjectSet.d.ts.map +1 -1
- package/build/types/objectSet/ObjectSetListenerWebsocket.d.ts +1 -1
- package/build/types/objectSet/ObjectSetListenerWebsocket.d.ts.map +1 -1
- package/build/types/objectSet/createObjectSet.d.ts +1 -1
- package/build/types/objectSet/createObjectSet.d.ts.map +1 -1
- package/build/types/objectSet/toConjureObjectSet.d.ts +1 -1
- package/build/types/ontology/StandardOntologyProvider.d.ts.map +1 -1
- package/build/types/ontology/loadFullObjectMetadata.d.ts.map +1 -1
- package/build/types/ontology/loadInterfaceDefinition.d.ts.map +1 -1
- package/build/types/util/WireObjectSet.d.ts +1 -1
- package/build/types/util/addUserAgent.d.ts +4 -0
- package/build/types/util/addUserAgent.d.ts.map +1 -0
- package/build/types/util/isOntologyObjectV2.d.ts +1 -1
- package/build/types/util/test/mockOntology.d.ts +1 -0
- package/build/types/util/test/mockOntology.d.ts.map +1 -1
- package/build/types/util/toDataValue.d.ts +1 -1
- package/package.json +18 -11
- package/build/js/chunk-AW6UQOAF.cjs +0 -1364
- package/build/js/chunk-AW6UQOAF.cjs.map +0 -1
- package/build/js/chunk-Y7UBQD5N.mjs +0 -1346
- package/build/js/chunk-Y7UBQD5N.mjs.map +0 -1
- package/build/js/public/objects.cjs +0 -16
- package/build/js/public/objects.cjs.map +0 -1
- package/build/js/public/objects.mjs +0 -3
- package/build/js/public/objects.mjs.map +0 -1
- package/build/types/ObjectSetCreator.test.d.ts +0 -2
- package/build/types/ObjectSetCreator.test.d.ts.map +0 -1
- package/build/types/public/objects.d.ts +0 -2
- package/build/types/public/objects.d.ts.map +0 -1
- package/changelog/0.10.0/pr-74.v2.yml +0 -5
- package/changelog/0.10.0/pr-78.v2.yml +0 -5
- package/changelog/0.10.0/pr-79.v2.yml +0 -5
- package/changelog/0.11.0/pr-100.v2.yml +0 -5
- package/changelog/0.11.0/pr-67.v2.yml +0 -5
- package/changelog/0.11.0/pr-83.v2.yml +0 -5
- package/changelog/0.11.0/pr-84.v2.yml +0 -5
- package/changelog/0.11.0/pr-86.v2.yml +0 -5
- package/changelog/0.11.0/pr-88.v2.yml +0 -5
- package/changelog/0.11.0/pr-89.v2.yml +0 -5
- package/changelog/0.11.0/pr-91.v2.yml +0 -5
- package/changelog/0.11.0/pr-95.v2.yml +0 -5
- package/changelog/0.11.0/pr-96.v2.yml +0 -5
- package/changelog/0.11.0/pr-99.v2.yml +0 -5
- package/changelog/0.13.0/pr-101.v2.yml +0 -5
- package/changelog/0.13.0/pr-102.v2.yml +0 -5
- package/changelog/0.13.0/pr-104.v2.yml +0 -5
- package/changelog/0.13.0/pr-106.v2.yml +0 -5
- package/changelog/0.13.0/pr-107.v2.yml +0 -5
- package/changelog/0.13.0/pr-110.v2.yml +0 -5
- package/changelog/0.13.0/pr-111.v2.yml +0 -5
- package/changelog/0.13.0/pr-112.v2.yml +0 -5
- package/changelog/0.13.0/pr-116.v2.yml +0 -5
- package/changelog/0.13.0/pr-117.v2.yml +0 -5
- package/changelog/0.13.0/pr-120.v2.yml +0 -5
- package/changelog/0.13.0/pr-125.v2.yml +0 -5
- package/changelog/0.14.0/pr-122.v2.yml +0 -5
- package/changelog/0.14.0/pr-129.v2.yml +0 -5
- package/changelog/0.14.0/pr-130.v2.yml +0 -5
- package/changelog/0.14.0/pr-131.v2.yml +0 -5
- package/changelog/0.14.0/pr-133.v2.yml +0 -5
- package/changelog/0.14.0/pr-141.v2.yml +0 -5
- package/changelog/0.6.0/pr-9.v2.yml +0 -5
- package/changelog/0.7.0/pr-20.v2.yml +0 -5
- package/changelog/0.7.0/pr-24.v2.yml +0 -5
- package/changelog/0.7.0/pr-28.v2.yml +0 -5
- package/changelog/0.8.0/pr-30.v2.yml +0 -5
- package/changelog/0.9.0/pr-43.v2.yml +0 -5
- package/changelog/0.9.0/pr-45.v2.yml +0 -5
- package/changelog/0.9.0/pr-48.v2.yml +0 -5
- package/changelog/0.9.0/pr-59.v2.yml +0 -5
- package/changelog/0.9.0/pr-65.v2.yml +0 -5
- package/changelog/0.9.0/pr-72.v2.yml +0 -5
- package/changelog/0.9.0/pr-75.v2.yml +0 -5
- package/changelog/@unreleased/.gitkeep +0 -0
package/build/js/index.mjs
CHANGED
|
@@ -1,11 +1,1408 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { createClientContext, PalantirApiError, createFetchHeaderMutator, omniFetch } from '@osdk/shared.net';
|
|
2
|
+
export { isOk } from '@osdk/shared.net';
|
|
3
|
+
import invariant2 from 'tiny-invariant';
|
|
4
|
+
import WebSocket from 'isomorphic-ws';
|
|
5
|
+
import { conjureFetch } from 'conjure-lite';
|
|
6
6
|
import { wireObjectTypeFullMetadataToSdkObjectTypeDefinition, __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition } from '@osdk/generator-converters';
|
|
7
7
|
import deepEqual from 'fast-deep-equal';
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
// src/index.ts
|
|
10
|
+
|
|
11
|
+
// src/actions/ActionValidationError.ts
|
|
12
|
+
var ActionValidationError = class extends Error {
|
|
13
|
+
constructor(validation) {
|
|
14
|
+
super("Validation Error");
|
|
15
|
+
this.validation = validation;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var _applyActionV2 = [1, "/v2/ontologies/{0}/actions/{1}/apply", 3];
|
|
19
|
+
function applyActionV2($ctx, ...args) {
|
|
20
|
+
return omniFetch($ctx, _applyActionV2, ...args);
|
|
21
|
+
}
|
|
22
|
+
function addUserAgent(client, withMetadata) {
|
|
23
|
+
if (withMetadata.osdkMetadata) {
|
|
24
|
+
return {
|
|
25
|
+
...client,
|
|
26
|
+
fetch: createFetchHeaderMutator(client.fetch, (headers) => {
|
|
27
|
+
headers.set("Fetch-User-Agent", withMetadata.osdkMetadata.extraUserAgent);
|
|
28
|
+
return headers;
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return client;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/object/Attachment.ts
|
|
36
|
+
var Attachment = class {
|
|
37
|
+
constructor(rid) {
|
|
38
|
+
this.rid = rid;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
function isAttachment(o) {
|
|
42
|
+
return o instanceof Attachment;
|
|
43
|
+
}
|
|
44
|
+
function legacyToModernSingleAggregationResult(entry) {
|
|
45
|
+
return entry.metrics.reduce((accumulator, curValue) => {
|
|
46
|
+
const parts = curValue.name.split(".");
|
|
47
|
+
if (parts[0] === "count") {
|
|
48
|
+
return accumulator;
|
|
49
|
+
}
|
|
50
|
+
!(parts.length === 2) ? process.env.NODE_ENV !== "production" ? invariant2(false, "assumed we were getting a `${key}.${type}`") : invariant2(false) : void 0;
|
|
51
|
+
if (!(parts[0] in accumulator)) {
|
|
52
|
+
accumulator[parts[0]] = {};
|
|
53
|
+
}
|
|
54
|
+
accumulator[parts[0]][parts[1]] = curValue.value;
|
|
55
|
+
return accumulator;
|
|
56
|
+
}, {});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/internal/conversions/modernToLegacyAggregationClause.ts
|
|
60
|
+
function modernToLegacyAggregationClause(select) {
|
|
61
|
+
return Object.entries(select).flatMap(([k, v]) => {
|
|
62
|
+
if (k === "$count") {
|
|
63
|
+
if (v)
|
|
64
|
+
return {
|
|
65
|
+
type: "count",
|
|
66
|
+
name: "count"
|
|
67
|
+
};
|
|
68
|
+
return [];
|
|
69
|
+
} else if (Array.isArray(v)) {
|
|
70
|
+
return v.map((v2) => {
|
|
71
|
+
return {
|
|
72
|
+
type: v2,
|
|
73
|
+
name: `${k}.${v2}`,
|
|
74
|
+
field: k
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
return [{
|
|
79
|
+
type: v,
|
|
80
|
+
// FIXME v has additional possible values
|
|
81
|
+
name: `${k}.${v}`,
|
|
82
|
+
field: k
|
|
83
|
+
}];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/query/aggregations/GroupByClause.ts
|
|
89
|
+
var DurationMapping = {
|
|
90
|
+
"sec": "SECONDS",
|
|
91
|
+
"seconds": "SECONDS",
|
|
92
|
+
"min": "MINUTES",
|
|
93
|
+
"minute": "MINUTES",
|
|
94
|
+
"minutes": "MINUTES",
|
|
95
|
+
"hr": "HOURS",
|
|
96
|
+
"hrs": "HOURS",
|
|
97
|
+
"hour": "HOURS",
|
|
98
|
+
"hours": "HOURS",
|
|
99
|
+
"day": "DAYS",
|
|
100
|
+
"days": "DAYS",
|
|
101
|
+
"wk": "WEEKS",
|
|
102
|
+
"week": "WEEKS",
|
|
103
|
+
"weeks": "WEEKS",
|
|
104
|
+
"mos": "MONTHS",
|
|
105
|
+
"month": "MONTHS",
|
|
106
|
+
"months": "MONTHS",
|
|
107
|
+
"yr": "YEARS",
|
|
108
|
+
"year": "YEARS",
|
|
109
|
+
"years": "YEARS",
|
|
110
|
+
"quarter": "QUARTERS",
|
|
111
|
+
"quarters": "QUARTERS"
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// src/internal/conversions/modernToLegacyGroupByClause.ts
|
|
115
|
+
function modernToLegacyGroupByClause(groupByClause) {
|
|
116
|
+
if (!groupByClause)
|
|
117
|
+
return [];
|
|
118
|
+
return Object.entries(groupByClause).flatMap(([field, type]) => {
|
|
119
|
+
if (type === "exact") {
|
|
120
|
+
return [{
|
|
121
|
+
type,
|
|
122
|
+
field
|
|
123
|
+
}];
|
|
124
|
+
} else if ("exactWithLimit" in type) {
|
|
125
|
+
{
|
|
126
|
+
return [{
|
|
127
|
+
type: "exact",
|
|
128
|
+
field,
|
|
129
|
+
maxGroupCount: type.exactWithLimit
|
|
130
|
+
}];
|
|
131
|
+
}
|
|
132
|
+
} else if ("fixedWidth" in type) {
|
|
133
|
+
return [{
|
|
134
|
+
type: "fixedWidth",
|
|
135
|
+
field,
|
|
136
|
+
fixedWidth: type.fixedWidth
|
|
137
|
+
}];
|
|
138
|
+
} else if ("ranges" in type) {
|
|
139
|
+
return [{
|
|
140
|
+
type: "ranges",
|
|
141
|
+
field,
|
|
142
|
+
ranges: type.ranges.map((range) => convertRange(range))
|
|
143
|
+
}];
|
|
144
|
+
} else if ("duration" in type) {
|
|
145
|
+
return [{
|
|
146
|
+
type: "duration",
|
|
147
|
+
field,
|
|
148
|
+
value: type.duration[0],
|
|
149
|
+
unit: DurationMapping[type.duration[1]]
|
|
150
|
+
}];
|
|
151
|
+
} else
|
|
152
|
+
return [];
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function convertRange(range) {
|
|
156
|
+
return {
|
|
157
|
+
startValue: range[0],
|
|
158
|
+
endValue: range[1]
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// src/query/WhereClause.ts
|
|
163
|
+
var DistanceUnitMapping = {
|
|
164
|
+
"centimeter": "CENTIMETERS",
|
|
165
|
+
"centimeters": "CENTIMETERS",
|
|
166
|
+
"cm": "CENTIMETERS",
|
|
167
|
+
"meter": "METERS",
|
|
168
|
+
"meters": "METERS",
|
|
169
|
+
"m": "METERS",
|
|
170
|
+
"kilometer": "KILOMETERS",
|
|
171
|
+
"kilometers": "KILOMETERS",
|
|
172
|
+
"km": "KILOMETERS",
|
|
173
|
+
"inch": "INCHES",
|
|
174
|
+
"inches": "INCHES",
|
|
175
|
+
"foot": "FEET",
|
|
176
|
+
"feet": "FEET",
|
|
177
|
+
"yard": "YARDS",
|
|
178
|
+
"yards": "YARDS",
|
|
179
|
+
"mile": "MILES",
|
|
180
|
+
"miles": "MILES",
|
|
181
|
+
"nautical_mile": "NAUTICAL_MILES",
|
|
182
|
+
"nauticalMile": "NAUTICAL_MILES",
|
|
183
|
+
"nautical miles": "NAUTICAL_MILES"
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// src/internal/conversions/modernToLegacyWhereClause.ts
|
|
187
|
+
function modernToLegacyWhereClause(whereClause) {
|
|
188
|
+
if ("$and" in whereClause) {
|
|
189
|
+
return {
|
|
190
|
+
type: "and",
|
|
191
|
+
value: whereClause.$and.map(modernToLegacyWhereClause)
|
|
192
|
+
};
|
|
193
|
+
} else if ("$or" in whereClause) {
|
|
194
|
+
return {
|
|
195
|
+
type: "or",
|
|
196
|
+
value: whereClause.$or.map(modernToLegacyWhereClause)
|
|
197
|
+
};
|
|
198
|
+
} else if ("$not" in whereClause) {
|
|
199
|
+
return {
|
|
200
|
+
type: "not",
|
|
201
|
+
value: modernToLegacyWhereClause(whereClause.$not)
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const parts = Object.entries(whereClause);
|
|
205
|
+
if (parts.length === 1) {
|
|
206
|
+
return handleWherePair(parts[0]);
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
type: "and",
|
|
210
|
+
value: parts.map(handleWherePair)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function makeGeoFilterBbox(field, bbox, filterType) {
|
|
214
|
+
return {
|
|
215
|
+
type: filterType === "$within" ? "withinBoundingBox" : "intersectsBoundingBox",
|
|
216
|
+
field,
|
|
217
|
+
value: {
|
|
218
|
+
topLeft: {
|
|
219
|
+
type: "Point",
|
|
220
|
+
coordinates: [bbox[0], bbox[3]]
|
|
221
|
+
},
|
|
222
|
+
bottomRight: {
|
|
223
|
+
type: "Point",
|
|
224
|
+
coordinates: [bbox[2], bbox[1]]
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function makeGeoFilterPolygon(field, coordinates, filterType) {
|
|
230
|
+
return {
|
|
231
|
+
type: filterType,
|
|
232
|
+
field,
|
|
233
|
+
value: {
|
|
234
|
+
type: "Polygon",
|
|
235
|
+
coordinates
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function handleWherePair([field, filter]) {
|
|
240
|
+
!(filter != null) ? process.env.NODE_ENV !== "production" ? invariant2(false, "Defined key values are only allowed when they are not undefined.") : invariant2(false) : void 0;
|
|
241
|
+
if (typeof filter === "string" || typeof filter === "number" || typeof filter === "boolean") {
|
|
242
|
+
return {
|
|
243
|
+
type: "eq",
|
|
244
|
+
field,
|
|
245
|
+
value: filter
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const keysOfFilter = Object.keys(filter);
|
|
249
|
+
const hasDollarSign = keysOfFilter.some((key) => key.startsWith("$"));
|
|
250
|
+
!(!hasDollarSign || keysOfFilter.length === 1) ? process.env.NODE_ENV !== "production" ? invariant2(false, "WhereClause Filter with multiple clauses isn't allowed") : invariant2(false) : void 0;
|
|
251
|
+
if (!hasDollarSign) {
|
|
252
|
+
throw new Error(`Unsupported filter. Did you forget to use a $-prefixed filter? (${JSON.stringify(filter)})`);
|
|
253
|
+
}
|
|
254
|
+
const firstKey = keysOfFilter[0];
|
|
255
|
+
!(filter[firstKey] != null) ? process.env.NODE_ENV !== "production" ? invariant2(false) : invariant2(false) : void 0;
|
|
256
|
+
if (firstKey === "$ne") {
|
|
257
|
+
return {
|
|
258
|
+
type: "not",
|
|
259
|
+
value: {
|
|
260
|
+
type: "eq",
|
|
261
|
+
field,
|
|
262
|
+
value: filter[firstKey]
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
if (firstKey === "$within") {
|
|
267
|
+
const withinBody = filter[firstKey];
|
|
268
|
+
if (Array.isArray(withinBody)) {
|
|
269
|
+
return makeGeoFilterBbox(field, withinBody, firstKey);
|
|
270
|
+
} else if ("bbox" in withinBody && !("type" in withinBody)) {
|
|
271
|
+
return makeGeoFilterBbox(field, withinBody.bbox, firstKey);
|
|
272
|
+
} else if ("distance" in withinBody && "of" in withinBody) {
|
|
273
|
+
return {
|
|
274
|
+
type: "withinDistanceOf",
|
|
275
|
+
field,
|
|
276
|
+
value: {
|
|
277
|
+
center: Array.isArray(withinBody.of) ? {
|
|
278
|
+
type: "Point",
|
|
279
|
+
coordinates: withinBody.of
|
|
280
|
+
} : withinBody.of,
|
|
281
|
+
distance: {
|
|
282
|
+
value: withinBody.distance[0],
|
|
283
|
+
unit: DistanceUnitMapping[withinBody.distance[1]]
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
} else {
|
|
288
|
+
const coordinates = "polygon" in withinBody ? withinBody.polygon : withinBody.coordinates;
|
|
289
|
+
return makeGeoFilterPolygon(field, coordinates, "withinPolygon");
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (firstKey === "$intersects") {
|
|
293
|
+
const intersectsBody = filter[firstKey];
|
|
294
|
+
if (Array.isArray(intersectsBody)) {
|
|
295
|
+
return makeGeoFilterBbox(field, intersectsBody, firstKey);
|
|
296
|
+
} else if ("bbox" in intersectsBody && !("type" in intersectsBody)) {
|
|
297
|
+
return makeGeoFilterBbox(field, intersectsBody.bbox, firstKey);
|
|
298
|
+
} else {
|
|
299
|
+
const coordinates = "polygon" in intersectsBody ? intersectsBody.polygon : intersectsBody.coordinates;
|
|
300
|
+
return makeGeoFilterPolygon(field, coordinates, "intersectsPolygon");
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return {
|
|
304
|
+
type: firstKey.substring(1),
|
|
305
|
+
field,
|
|
306
|
+
value: filter[firstKey]
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// src/object/Cache.ts
|
|
311
|
+
function createCache(fn) {
|
|
312
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
313
|
+
function get(client, key) {
|
|
314
|
+
if (cache.get(client) == null) {
|
|
315
|
+
cache.set(client, /* @__PURE__ */ new Map());
|
|
316
|
+
}
|
|
317
|
+
let r = cache.get(client).get(key);
|
|
318
|
+
if (r === void 0 && fn !== void 0) {
|
|
319
|
+
return set(client, key, fn(client, key));
|
|
320
|
+
} else {
|
|
321
|
+
return r;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function set(client, key, value) {
|
|
325
|
+
if (cache.get(client) == null) {
|
|
326
|
+
cache.set(client, /* @__PURE__ */ new Map());
|
|
327
|
+
}
|
|
328
|
+
cache.get(client).set(key, value);
|
|
329
|
+
return value;
|
|
330
|
+
}
|
|
331
|
+
function remove(client, key) {
|
|
332
|
+
if (cache.get(client) == null)
|
|
333
|
+
return false;
|
|
334
|
+
return cache.get(client).delete(key);
|
|
335
|
+
}
|
|
336
|
+
return {
|
|
337
|
+
get,
|
|
338
|
+
set,
|
|
339
|
+
remove
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function createAsyncCache(fn, createCacheLocal = createCache) {
|
|
343
|
+
const cache = createCacheLocal();
|
|
344
|
+
const inProgress = createCacheLocal();
|
|
345
|
+
const ret = {
|
|
346
|
+
getOrUndefined: function getOrUndefined(client, key) {
|
|
347
|
+
return cache.get(client, key);
|
|
348
|
+
},
|
|
349
|
+
get: async function get(client, key) {
|
|
350
|
+
return cache.get(client, key) ?? inProgress.get(client, key) ?? ret.set(client, key, fn(client, key));
|
|
351
|
+
},
|
|
352
|
+
set: async function set(client, k, v) {
|
|
353
|
+
try {
|
|
354
|
+
const r = await inProgress.set(client, k, v);
|
|
355
|
+
cache.set(client, k, r);
|
|
356
|
+
inProgress.remove(client, k);
|
|
357
|
+
return r;
|
|
358
|
+
} catch (e) {
|
|
359
|
+
inProgress.remove(client, k);
|
|
360
|
+
throw e;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
return ret;
|
|
365
|
+
}
|
|
366
|
+
var _loadObjectSetV2 = [1, "/v2/ontologies/{0}/objectSets/loadObjects", 3];
|
|
367
|
+
function loadObjectSetV2($ctx, ...args) {
|
|
368
|
+
return omniFetch($ctx, _loadObjectSetV2, ...args);
|
|
369
|
+
}
|
|
370
|
+
var _aggregateObjectSetV2 = [1, "/v2/ontologies/{0}/objectSets/aggregate", 3];
|
|
371
|
+
function aggregateObjectSetV2($ctx, ...args) {
|
|
372
|
+
return omniFetch($ctx, _aggregateObjectSetV2, ...args);
|
|
373
|
+
}
|
|
374
|
+
var _listInterfaceTypes = [0, "/v2/ontologies/{0}/interfaceTypes", 2];
|
|
375
|
+
function listInterfaceTypes($ctx, ...args) {
|
|
376
|
+
return omniFetch($ctx, _listInterfaceTypes, ...args);
|
|
377
|
+
}
|
|
378
|
+
var _getInterfaceType = [0, "/v2/ontologies/{0}/interfaceTypes/{1}", 2];
|
|
379
|
+
function getInterfaceType($ctx, ...args) {
|
|
380
|
+
return omniFetch($ctx, _getInterfaceType, ...args);
|
|
381
|
+
}
|
|
382
|
+
var _searchObjectsForInterface = [1, "/v2/ontologies/{0}/interfaces/{1}/search", 3];
|
|
383
|
+
function searchObjectsForInterface($ctx, ...args) {
|
|
384
|
+
return omniFetch($ctx, _searchObjectsForInterface, ...args);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// src/object/fetchPage.ts
|
|
388
|
+
function augment(type, ...properties) {
|
|
389
|
+
return {
|
|
390
|
+
[type.apiName]: properties
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function objectSetToSearchJsonV2(objectSet, expectedApiName, existingWhere = void 0) {
|
|
394
|
+
if (objectSet.type === "base") {
|
|
395
|
+
if (objectSet.objectType !== expectedApiName) {
|
|
396
|
+
throw new Error(`Expected objectSet.objectType to be ${expectedApiName}, but got ${objectSet.objectType}`);
|
|
397
|
+
}
|
|
398
|
+
return existingWhere;
|
|
399
|
+
}
|
|
400
|
+
if (objectSet.type === "filter") {
|
|
401
|
+
return objectSetToSearchJsonV2(objectSet.objectSet, expectedApiName, existingWhere == null ? objectSet.where : {
|
|
402
|
+
type: "and",
|
|
403
|
+
value: [existingWhere, objectSet.where]
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
throw new Error(`Unsupported objectSet type: ${objectSet.type}`);
|
|
407
|
+
}
|
|
408
|
+
async function fetchInterfacePage(client, interfaceType, args, objectSet) {
|
|
409
|
+
const result = await searchObjectsForInterface(addUserAgent(client, interfaceType), client.ontologyRid, interfaceType.apiName, applyFetchArgs(args, {
|
|
410
|
+
augmentedProperties: args.augment ?? {},
|
|
411
|
+
augmentedSharedPropertyTypes: {},
|
|
412
|
+
otherInterfaceTypes: [],
|
|
413
|
+
selectedObjectTypes: [],
|
|
414
|
+
selectedSharedPropertyTypes: args.select ?? [],
|
|
415
|
+
where: objectSetToSearchJsonV2(objectSet, interfaceType.apiName)
|
|
416
|
+
}), {
|
|
417
|
+
preview: true
|
|
418
|
+
});
|
|
419
|
+
result.data = await convertWireToOsdkObjects(
|
|
420
|
+
client,
|
|
421
|
+
result.data,
|
|
422
|
+
// drop readonly
|
|
423
|
+
interfaceType.apiName,
|
|
424
|
+
!args.includeRid
|
|
425
|
+
);
|
|
426
|
+
return result;
|
|
427
|
+
}
|
|
428
|
+
async function fetchPageInternal(client, objectType, objectSet, args = {}) {
|
|
429
|
+
if (objectType.type === "interface") {
|
|
430
|
+
return await fetchInterfacePage(client, objectType, args, objectSet);
|
|
431
|
+
} else {
|
|
432
|
+
return await fetchObjectPage(client, objectType, args, objectSet);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
async function fetchPageWithErrorsInternal(client, objectType, objectSet, args = {}) {
|
|
436
|
+
try {
|
|
437
|
+
const result = await fetchPageInternal(client, objectType, objectSet, args);
|
|
438
|
+
return {
|
|
439
|
+
value: result
|
|
440
|
+
};
|
|
441
|
+
} catch (e) {
|
|
442
|
+
if (e instanceof Error) {
|
|
443
|
+
return {
|
|
444
|
+
error: e
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
return {
|
|
448
|
+
error: e
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
async function fetchPage(client, objectType, args, objectSet = {
|
|
453
|
+
type: "base",
|
|
454
|
+
objectType: objectType["apiName"]
|
|
455
|
+
}) {
|
|
456
|
+
return fetchPageInternal(client, objectType, objectSet, args);
|
|
457
|
+
}
|
|
458
|
+
function applyFetchArgs(args, body) {
|
|
459
|
+
if (args?.nextPageToken) {
|
|
460
|
+
body.pageToken = args.nextPageToken;
|
|
461
|
+
}
|
|
462
|
+
if (args?.pageSize != null) {
|
|
463
|
+
body.pageSize = args.pageSize;
|
|
464
|
+
}
|
|
465
|
+
if (args?.orderBy != null) {
|
|
466
|
+
body.orderBy = {
|
|
467
|
+
fields: Object.entries(args.orderBy).map(([field, direction]) => ({
|
|
468
|
+
field,
|
|
469
|
+
direction
|
|
470
|
+
}))
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
return body;
|
|
474
|
+
}
|
|
475
|
+
async function fetchObjectPage(client, objectType, args, objectSet) {
|
|
476
|
+
const r = await loadObjectSetV2(addUserAgent(client, objectType), client.ontologyRid, applyFetchArgs(args, {
|
|
477
|
+
objectSet,
|
|
478
|
+
// We have to do the following case because LoadObjectSetRequestV2 isnt readonly
|
|
479
|
+
select: args?.select ?? [],
|
|
480
|
+
// FIXME?
|
|
481
|
+
excludeRid: !args?.includeRid
|
|
482
|
+
}));
|
|
483
|
+
return Promise.resolve({
|
|
484
|
+
data: await convertWireToOsdkObjects(client, r.data, void 0),
|
|
485
|
+
nextPageToken: r.nextPageToken
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// src/object/fetchSingle.ts
|
|
490
|
+
async function fetchSingle(client, objectType, args, objectSet) {
|
|
491
|
+
const result = await fetchPage(client, objectType, {
|
|
492
|
+
...args,
|
|
493
|
+
pageSize: 1
|
|
494
|
+
}, objectSet);
|
|
495
|
+
if (result.data.length !== 1 || result.nextPageToken != null) {
|
|
496
|
+
throw new PalantirApiError(`Expected a single result but got ${result.data.length} instead${result.nextPageToken != null ? " with nextPageToken set" : ""}`);
|
|
497
|
+
}
|
|
498
|
+
return result.data[0];
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// src/object/convertWireToOsdkObjects.ts
|
|
502
|
+
var OriginClient = Symbol();
|
|
503
|
+
var UnderlyingObject = Symbol();
|
|
504
|
+
var InterfaceDefinitions = Symbol();
|
|
505
|
+
var LinkFetcherProxyHandler = class {
|
|
506
|
+
constructor(objDef, primaryKey, client) {
|
|
507
|
+
this.objDef = objDef;
|
|
508
|
+
this.primaryKey = primaryKey;
|
|
509
|
+
this.client = client;
|
|
510
|
+
}
|
|
511
|
+
get(_target, p) {
|
|
512
|
+
const linkDef = this.objDef.links[p];
|
|
513
|
+
if (linkDef == null) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
const objectSet = createObjectSet(this.objDef, this.client).where({
|
|
517
|
+
[this.objDef.primaryKeyApiName]: this.primaryKey
|
|
518
|
+
}).pivotTo(p);
|
|
519
|
+
if (!linkDef.multiplicity) {
|
|
520
|
+
return {
|
|
521
|
+
get: (options) => fetchSingle(this.client, this.objDef, options ?? {}, getWireObjectSet(objectSet))
|
|
522
|
+
};
|
|
523
|
+
} else {
|
|
524
|
+
return objectSet;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
ownKeys() {
|
|
528
|
+
return Object.keys(this.objDef.links);
|
|
529
|
+
}
|
|
530
|
+
getOwnPropertyDescriptor(target, p) {
|
|
531
|
+
return {
|
|
532
|
+
enumerable: true,
|
|
533
|
+
configurable: true,
|
|
534
|
+
get: () => {
|
|
535
|
+
return this.get(target, p);
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
function createPrototype(objDef, client) {
|
|
541
|
+
if (process.env.NODE_ENV !== "production") {
|
|
542
|
+
!(objDef.type === "object") ? process.env.NODE_ENV !== "production" ? invariant2(false, "Expected object definition") : invariant2(false) : void 0;
|
|
543
|
+
}
|
|
544
|
+
const sharedPropertyDefs = {
|
|
545
|
+
$as: {
|
|
546
|
+
value: $as
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
const interfaceProto = Object.defineProperties({}, sharedPropertyDefs);
|
|
550
|
+
const objectProto = Object.defineProperties({}, {
|
|
551
|
+
$link: {
|
|
552
|
+
get: function() {
|
|
553
|
+
return new Proxy({}, new LinkFetcherProxyHandler(objDef, this["$primaryKey"], client));
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
...sharedPropertyDefs
|
|
557
|
+
});
|
|
558
|
+
function $as(newDef) {
|
|
559
|
+
if (typeof newDef === "string") {
|
|
560
|
+
if (newDef === objDef.apiName) {
|
|
561
|
+
return this[UnderlyingObject];
|
|
562
|
+
}
|
|
563
|
+
const def = objDef[InterfaceDefinitions][newDef];
|
|
564
|
+
if (!def) {
|
|
565
|
+
throw new Error(`Object does not implement interface '${newDef}'.`);
|
|
566
|
+
}
|
|
567
|
+
newDef = def;
|
|
568
|
+
} else if (newDef.apiName === objDef.apiName) {
|
|
569
|
+
return this[UnderlyingObject];
|
|
570
|
+
}
|
|
571
|
+
if (newDef.type !== "interface" && newDef.apiName !== this.$apiName) {
|
|
572
|
+
throw new Error(`'${newDef.apiName}' is not an interface of '${this.$objectType}'.`);
|
|
573
|
+
}
|
|
574
|
+
const underlying = this[UnderlyingObject];
|
|
575
|
+
const common = {
|
|
576
|
+
enumerable: true,
|
|
577
|
+
configurable: true
|
|
578
|
+
};
|
|
579
|
+
return Object.create(interfaceProto, {
|
|
580
|
+
$apiName: {
|
|
581
|
+
value: newDef.apiName,
|
|
582
|
+
...common
|
|
583
|
+
},
|
|
584
|
+
$objectType: {
|
|
585
|
+
value: objDef.apiName,
|
|
586
|
+
...common
|
|
587
|
+
},
|
|
588
|
+
$primaryKey: {
|
|
589
|
+
value: this["$primaryKey"],
|
|
590
|
+
...common
|
|
591
|
+
},
|
|
592
|
+
...Object.fromEntries(Object.keys(newDef.properties).map((p) => {
|
|
593
|
+
const value = underlying[objDef.spts[p]];
|
|
594
|
+
return [p, {
|
|
595
|
+
value,
|
|
596
|
+
enumerable: value !== void 0
|
|
597
|
+
}];
|
|
598
|
+
})),
|
|
599
|
+
[UnderlyingObject]: {
|
|
600
|
+
value: underlying
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
return objectProto;
|
|
605
|
+
}
|
|
606
|
+
function createConverter(objDef) {
|
|
607
|
+
const steps = [];
|
|
608
|
+
for (const [key, value] of Object.entries(objDef.properties)) {
|
|
609
|
+
if (value.type === "attachment") {
|
|
610
|
+
steps.push((o) => {
|
|
611
|
+
if (o[key] != null) {
|
|
612
|
+
if (Array.isArray(o[key])) {
|
|
613
|
+
o[key] = o[key].map((a) => new Attachment(a.rid));
|
|
614
|
+
} else {
|
|
615
|
+
o[key] = new Attachment(o[key].rid);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
return steps.length > 0 ? (o) => {
|
|
622
|
+
for (const step of steps) {
|
|
623
|
+
step(o);
|
|
624
|
+
}
|
|
625
|
+
} : void 0;
|
|
626
|
+
}
|
|
627
|
+
var protoConverterCache = createCache((client, objectDef) => {
|
|
628
|
+
const proto = createPrototype(objectDef, client);
|
|
629
|
+
const converter = createConverter(objectDef);
|
|
630
|
+
return [proto, converter];
|
|
631
|
+
});
|
|
632
|
+
async function convertWireToOsdkObjects(client, objects, interfaceApiName, forceRemoveRid = false) {
|
|
633
|
+
if (forceRemoveRid) {
|
|
634
|
+
for (const obj of objects) {
|
|
635
|
+
delete obj.__rid;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
fixObjectPropertiesInline(objects);
|
|
639
|
+
const localObjectCache = createLocalObjectCacheAndInitiatePreseed(objects, client);
|
|
640
|
+
for (const obj of objects) {
|
|
641
|
+
const objectDef = await localObjectCache.get(client, obj.$apiName);
|
|
642
|
+
if (objectDef == null) {
|
|
643
|
+
throw new Error(`Failed to find ontology definition for '${obj.$apiName}'`);
|
|
644
|
+
}
|
|
645
|
+
if (interfaceApiName !== void 0) {
|
|
646
|
+
for (const [sptProp, regularProp] of Object.entries(objectDef.spts)) {
|
|
647
|
+
if (sptProp in obj) {
|
|
648
|
+
const value = obj[sptProp];
|
|
649
|
+
delete obj[sptProp];
|
|
650
|
+
if (value !== void 0) {
|
|
651
|
+
obj[regularProp] = value;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
internalConvertObjectInPlace(objectDef, client, obj);
|
|
657
|
+
}
|
|
658
|
+
if (interfaceApiName) {
|
|
659
|
+
return objects.map((o) => o.$as(interfaceApiName));
|
|
660
|
+
} else {
|
|
661
|
+
return objects;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
function createLocalObjectCacheAndInitiatePreseed(objects, client) {
|
|
665
|
+
const localInterfaceCache = createAsyncCache((client2, apiName) => client2.ontologyProvider.getInterfaceDefinition(apiName));
|
|
666
|
+
const localObjectCache = createAsyncCache(async (client2, apiName) => {
|
|
667
|
+
const objectDef = await client2.ontologyProvider.getObjectDefinition(apiName);
|
|
668
|
+
const interfaceDefs = Object.fromEntries((await Promise.all(objectDef.implements?.map((i) => localInterfaceCache.get(client2, i)) ?? [])).map((i) => [i.apiName, i]));
|
|
669
|
+
if (objectDef[InterfaceDefinitions] == null) {
|
|
670
|
+
Object.defineProperty(objectDef, InterfaceDefinitions, {
|
|
671
|
+
value: interfaceDefs,
|
|
672
|
+
enumerable: false,
|
|
673
|
+
configurable: false,
|
|
674
|
+
writable: false
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
return objectDef;
|
|
678
|
+
});
|
|
679
|
+
const uniqueApiNames = /* @__PURE__ */ new Set();
|
|
680
|
+
for (const {
|
|
681
|
+
$apiName
|
|
682
|
+
} of objects) {
|
|
683
|
+
if (uniqueApiNames.has($apiName))
|
|
684
|
+
continue;
|
|
685
|
+
uniqueApiNames.add($apiName);
|
|
686
|
+
localObjectCache.get(client, $apiName);
|
|
687
|
+
}
|
|
688
|
+
return localObjectCache;
|
|
689
|
+
}
|
|
690
|
+
function fixObjectPropertiesInline(objs) {
|
|
691
|
+
for (const obj of objs) {
|
|
692
|
+
if (obj.__rid) {
|
|
693
|
+
obj.$rid = obj.__rid;
|
|
694
|
+
delete obj.__rid;
|
|
695
|
+
}
|
|
696
|
+
obj.$apiName = obj.__apiName;
|
|
697
|
+
obj.$objectType = obj.__apiName;
|
|
698
|
+
obj.$primaryKey = obj.__primaryKey;
|
|
699
|
+
{
|
|
700
|
+
Object.defineProperties(obj, {
|
|
701
|
+
"__apiName": {
|
|
702
|
+
enumerable: false
|
|
703
|
+
},
|
|
704
|
+
"__primaryKey": {
|
|
705
|
+
enumerable: false
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
function internalConvertObjectInPlace(objectDef, client, obj) {
|
|
712
|
+
const [proto, converter] = protoConverterCache.get(client, objectDef);
|
|
713
|
+
Object.setPrototypeOf(obj, proto);
|
|
714
|
+
Object.defineProperties(obj, {
|
|
715
|
+
[OriginClient]: {
|
|
716
|
+
value: client
|
|
717
|
+
},
|
|
718
|
+
[UnderlyingObject]: {
|
|
719
|
+
value: obj
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
if (converter) {
|
|
723
|
+
converter(obj);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
async function aggregate(clientCtx, objectType, objectSet = {
|
|
727
|
+
type: "base",
|
|
728
|
+
objectType: objectType["apiName"]
|
|
729
|
+
}, req) {
|
|
730
|
+
const body = {
|
|
731
|
+
aggregation: modernToLegacyAggregationClause(req.select),
|
|
732
|
+
groupBy: [],
|
|
733
|
+
where: void 0
|
|
734
|
+
};
|
|
735
|
+
if (req.groupBy) {
|
|
736
|
+
body.groupBy = modernToLegacyGroupByClause(req.groupBy);
|
|
737
|
+
}
|
|
738
|
+
if (req.where) {
|
|
739
|
+
body.where = modernToLegacyWhereClause(req.where);
|
|
740
|
+
}
|
|
741
|
+
const result = await aggregateObjectSetV2(addUserAgent(clientCtx, objectType), clientCtx.ontologyRid, {
|
|
742
|
+
objectSet,
|
|
743
|
+
groupBy: body.groupBy,
|
|
744
|
+
aggregation: body.aggregation
|
|
745
|
+
});
|
|
746
|
+
if (!req.groupBy) {
|
|
747
|
+
!(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;
|
|
748
|
+
return {
|
|
749
|
+
...aggregationToCountResult(result.data[0]),
|
|
750
|
+
...legacyToModernSingleAggregationResult(result.data[0])
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
const ret = result.data.map((entry) => {
|
|
754
|
+
return {
|
|
755
|
+
$group: entry.group,
|
|
756
|
+
...aggregationToCountResult(entry),
|
|
757
|
+
...legacyToModernSingleAggregationResult(entry)
|
|
758
|
+
};
|
|
759
|
+
});
|
|
760
|
+
return ret;
|
|
761
|
+
}
|
|
762
|
+
function aggregationToCountResult(entry) {
|
|
763
|
+
for (const aggregateResult of entry.metrics) {
|
|
764
|
+
if (aggregateResult.name === "count") {
|
|
765
|
+
return {
|
|
766
|
+
$count: aggregateResult.value
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
// src/util/WireObjectSet.ts
|
|
773
|
+
var WIRE_OBJECT_SET_TYPES = /* @__PURE__ */ new Set(["base", "filter", "intersect", "reference", "searchAround", "static", "subtract", "union"]);
|
|
774
|
+
function isWireObjectSet(o) {
|
|
775
|
+
return o != null && typeof o === "object" && WIRE_OBJECT_SET_TYPES.has(o.type);
|
|
776
|
+
}
|
|
777
|
+
var _getObjectTypeV2 = [0, "/v2/ontologies/{0}/objectTypes/{1}"];
|
|
778
|
+
function getObjectTypeV2($ctx, ...args) {
|
|
779
|
+
return omniFetch($ctx, _getObjectTypeV2, ...args);
|
|
780
|
+
}
|
|
781
|
+
var _listOutgoingLinkTypesV2 = [0, "/v2/ontologies/{0}/objectTypes/{1}/outgoingLinkTypes", 2];
|
|
782
|
+
function listOutgoingLinkTypesV2($ctx, ...args) {
|
|
783
|
+
return omniFetch($ctx, _listOutgoingLinkTypesV2, ...args);
|
|
784
|
+
}
|
|
785
|
+
async function createTemporaryObjectSet(ctx, request) {
|
|
786
|
+
return conjureFetch(ctx, `/objectSets/temporary`, "POST", request);
|
|
787
|
+
}
|
|
788
|
+
async function batchEnableWatcher(ctx, request) {
|
|
789
|
+
return conjureFetch(ctx, `/object-set-watcher/batchEnableWatcher`, "POST", request);
|
|
790
|
+
}
|
|
791
|
+
async function loadAllOntologies(ctx, request) {
|
|
792
|
+
return conjureFetch(ctx, `/ontology/ontology/ontologies/load/all`, "POST", request);
|
|
793
|
+
}
|
|
794
|
+
async function loadOntologyEntities(ctx, request) {
|
|
795
|
+
return conjureFetch(ctx, `/ontology/ontology/loadEntities`, "POST", request);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// src/objectSet/toConjureObjectSet.ts
|
|
799
|
+
function toConjureObjectSet(objectSet, objectPropertyMapping) {
|
|
800
|
+
switch (objectSet.type) {
|
|
801
|
+
case "base":
|
|
802
|
+
return {
|
|
803
|
+
type: "base",
|
|
804
|
+
base: {
|
|
805
|
+
objectTypeId: objectPropertyMapping.id
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
case "static":
|
|
809
|
+
return {
|
|
810
|
+
type: "static",
|
|
811
|
+
static: {
|
|
812
|
+
objectRids: objectSet.objects,
|
|
813
|
+
provenance: void 0
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
case "reference":
|
|
817
|
+
return {
|
|
818
|
+
type: "referenced",
|
|
819
|
+
referenced: {
|
|
820
|
+
objectSetRid: objectSet.reference
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
case "filter":
|
|
824
|
+
return {
|
|
825
|
+
type: "filtered",
|
|
826
|
+
filtered: {
|
|
827
|
+
objectSet: toConjureObjectSet(objectSet.objectSet, objectPropertyMapping),
|
|
828
|
+
runtimeDerivedProperties: void 0,
|
|
829
|
+
filter: mapWhereClauseToObjectSetFilter(objectSet.where, objectPropertyMapping)
|
|
830
|
+
}
|
|
831
|
+
};
|
|
832
|
+
case "union":
|
|
833
|
+
return {
|
|
834
|
+
type: "unioned",
|
|
835
|
+
unioned: {
|
|
836
|
+
objectSets: objectSet.objectSets.map((os) => toConjureObjectSet(os, objectPropertyMapping))
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
case "intersect":
|
|
840
|
+
return {
|
|
841
|
+
type: "intersected",
|
|
842
|
+
intersected: {
|
|
843
|
+
objectSets: objectSet.objectSets.map((os) => toConjureObjectSet(os, objectPropertyMapping))
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
case "subtract":
|
|
847
|
+
return {
|
|
848
|
+
type: "subtracted",
|
|
849
|
+
subtracted: {
|
|
850
|
+
objectSets: objectSet.objectSets.map((os) => toConjureObjectSet(os, objectPropertyMapping))
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
case "searchAround":
|
|
854
|
+
throw new Error("not implemented");
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
async function getObjectSetBaseType(objectSet) {
|
|
858
|
+
switch (objectSet.type) {
|
|
859
|
+
case "base":
|
|
860
|
+
return objectSet.objectType;
|
|
861
|
+
case "static":
|
|
862
|
+
throw new Error("not implemented");
|
|
863
|
+
case "reference":
|
|
864
|
+
throw new Error("not implemented");
|
|
865
|
+
case "filter":
|
|
866
|
+
return getObjectSetBaseType(objectSet.objectSet);
|
|
867
|
+
case "union":
|
|
868
|
+
return getObjectSetBaseType(objectSet.objectSets[0]);
|
|
869
|
+
case "intersect":
|
|
870
|
+
return getObjectSetBaseType(objectSet.objectSets[0]);
|
|
871
|
+
case "subtract":
|
|
872
|
+
return getObjectSetBaseType(objectSet.objectSets[0]);
|
|
873
|
+
case "searchAround":
|
|
874
|
+
throw new Error("not implemented");
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
function mapWhereClauseToObjectSetFilter(objectSetFilter, propertyMapping) {
|
|
878
|
+
switch (objectSetFilter.type) {
|
|
879
|
+
case "lt":
|
|
880
|
+
return {
|
|
881
|
+
type: "range",
|
|
882
|
+
range: {
|
|
883
|
+
propertyId: propertyMapping.propertyApiNameToIdMapping[objectSetFilter.field],
|
|
884
|
+
lt: objectSetFilter.value,
|
|
885
|
+
lte: void 0,
|
|
886
|
+
gt: void 0,
|
|
887
|
+
gte: void 0
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
case "gt":
|
|
891
|
+
return {
|
|
892
|
+
type: "range",
|
|
893
|
+
range: {
|
|
894
|
+
propertyId: propertyMapping.propertyApiNameToIdMapping[objectSetFilter.field],
|
|
895
|
+
gt: objectSetFilter.value,
|
|
896
|
+
lte: void 0,
|
|
897
|
+
lt: void 0,
|
|
898
|
+
gte: void 0
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
case "lte":
|
|
902
|
+
return {
|
|
903
|
+
type: "range",
|
|
904
|
+
range: {
|
|
905
|
+
propertyId: propertyMapping.propertyApiNameToIdMapping[objectSetFilter.field],
|
|
906
|
+
lte: objectSetFilter.value,
|
|
907
|
+
lt: void 0,
|
|
908
|
+
gt: void 0,
|
|
909
|
+
gte: void 0
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
case "gte":
|
|
913
|
+
return {
|
|
914
|
+
type: "range",
|
|
915
|
+
range: {
|
|
916
|
+
propertyId: propertyMapping.propertyApiNameToIdMapping[objectSetFilter.field],
|
|
917
|
+
gte: objectSetFilter.value,
|
|
918
|
+
lt: void 0,
|
|
919
|
+
lte: void 0,
|
|
920
|
+
gt: void 0
|
|
921
|
+
}
|
|
922
|
+
};
|
|
923
|
+
case "eq":
|
|
924
|
+
return {
|
|
925
|
+
type: "exactMatch",
|
|
926
|
+
exactMatch: {
|
|
927
|
+
propertyId: propertyMapping.propertyApiNameToIdMapping[objectSetFilter.field],
|
|
928
|
+
terms: []
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
case "and":
|
|
932
|
+
return {
|
|
933
|
+
type: "and",
|
|
934
|
+
and: {
|
|
935
|
+
filters: objectSetFilter.value.map((filter) => mapWhereClauseToObjectSetFilter(filter, propertyMapping))
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
case "or":
|
|
939
|
+
return {
|
|
940
|
+
type: "or",
|
|
941
|
+
or: {
|
|
942
|
+
filters: objectSetFilter.value.map((filter) => mapWhereClauseToObjectSetFilter(filter, propertyMapping))
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
case "isNull":
|
|
946
|
+
return {
|
|
947
|
+
type: "not",
|
|
948
|
+
not: {
|
|
949
|
+
filter: {
|
|
950
|
+
type: "hasProperty",
|
|
951
|
+
hasProperty: {
|
|
952
|
+
propertyId: propertyMapping.propertyApiNameToIdMapping[objectSetFilter.field]
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
case "not":
|
|
958
|
+
return {
|
|
959
|
+
type: "not",
|
|
960
|
+
not: {
|
|
961
|
+
filter: mapWhereClauseToObjectSetFilter(objectSetFilter.value, propertyMapping)
|
|
962
|
+
}
|
|
963
|
+
};
|
|
964
|
+
case "contains":
|
|
965
|
+
case "startsWith":
|
|
966
|
+
case "containsAllTermsInOrder":
|
|
967
|
+
case "containsAnyTerm":
|
|
968
|
+
case "containsAllTerms":
|
|
969
|
+
case "withinDistanceOf":
|
|
970
|
+
case "withinBoundingBox":
|
|
971
|
+
case "intersectsBoundingBox":
|
|
972
|
+
case "doesNotIntersectBoundingBox":
|
|
973
|
+
case "withinPolygon":
|
|
974
|
+
case "intersectsPolygon":
|
|
975
|
+
case "doesNotIntersectPolygon":
|
|
976
|
+
case "containsAllTermsInOrderPrefixLastTerm":
|
|
977
|
+
throw new Error("not implemented");
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
// src/objectSet/ObjectSetListenerWebsocket.ts
|
|
982
|
+
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
983
|
+
var MINIMUM_RECONNECT_DELAY_MS = 5 * 1e3;
|
|
984
|
+
var ObjectSetListenerWebsocket = class _ObjectSetListenerWebsocket {
|
|
985
|
+
static #instances = /* @__PURE__ */ new WeakMap();
|
|
986
|
+
// FIXME
|
|
987
|
+
static getInstance(client) {
|
|
988
|
+
let instance = _ObjectSetListenerWebsocket.#instances.get(client);
|
|
989
|
+
if (instance == null) {
|
|
990
|
+
instance = new _ObjectSetListenerWebsocket(client);
|
|
991
|
+
_ObjectSetListenerWebsocket.#instances.set(client, instance);
|
|
992
|
+
}
|
|
993
|
+
return instance;
|
|
994
|
+
}
|
|
995
|
+
#ws;
|
|
996
|
+
#lastWsConnect = 0;
|
|
997
|
+
#client;
|
|
998
|
+
/** map of listenerId to listener */
|
|
999
|
+
#listeners = /* @__PURE__ */ new Map();
|
|
1000
|
+
/** map of subscriptionId to listenerId */
|
|
1001
|
+
#subscriptionToRequestId = /* @__PURE__ */ new Map();
|
|
1002
|
+
#conjureContext;
|
|
1003
|
+
#metadataContext;
|
|
1004
|
+
#ossContext;
|
|
1005
|
+
constructor(client) {
|
|
1006
|
+
this.#client = client;
|
|
1007
|
+
const stackUrl = new URL(client.stack);
|
|
1008
|
+
this.#conjureContext = {
|
|
1009
|
+
baseUrl: stackUrl.origin,
|
|
1010
|
+
servicePath: "/object-set-watcher/api",
|
|
1011
|
+
fetchFn: client.fetch,
|
|
1012
|
+
tokenProvider: async () => await client.tokenProvider()
|
|
1013
|
+
};
|
|
1014
|
+
this.#ossContext = {
|
|
1015
|
+
baseUrl: stackUrl.origin,
|
|
1016
|
+
servicePath: "/object-set-service/api",
|
|
1017
|
+
fetchFn: client.fetch,
|
|
1018
|
+
tokenProvider: async () => await client.tokenProvider()
|
|
1019
|
+
};
|
|
1020
|
+
this.#metadataContext = {
|
|
1021
|
+
baseUrl: stackUrl.origin,
|
|
1022
|
+
servicePath: "/ontology-metadata/api",
|
|
1023
|
+
fetchFn: client.fetch,
|
|
1024
|
+
tokenProvider: async () => await client.tokenProvider()
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
subscribe(objectSet, listener) {
|
|
1028
|
+
const requestId = crypto.randomUUID();
|
|
1029
|
+
const expiry = setTimeout(() => {
|
|
1030
|
+
this.#expire(requestId);
|
|
1031
|
+
}, ONE_DAY_MS);
|
|
1032
|
+
this.#listeners.set(requestId, {
|
|
1033
|
+
listener,
|
|
1034
|
+
objectSet,
|
|
1035
|
+
expiry
|
|
1036
|
+
});
|
|
1037
|
+
this.#subscribe(requestId, objectSet);
|
|
1038
|
+
return () => {
|
|
1039
|
+
this.#unsubscribe(requestId);
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
async #subscribe(requestId, objectSet) {
|
|
1043
|
+
try {
|
|
1044
|
+
const [temporaryObjectSet] = await Promise.all([
|
|
1045
|
+
// create a time-bounded object set representation for watching
|
|
1046
|
+
this.#createTemporaryObjectSet(objectSet),
|
|
1047
|
+
this.#ensureWebsocket(),
|
|
1048
|
+
// look up the object type's rid and ensure that we have enabled object set watcher for that rid
|
|
1049
|
+
// TODO ???
|
|
1050
|
+
getObjectSetBaseType(objectSet).then((baseType) => getObjectTypeV2(this.#client, this.#client.ontologyRid, baseType)).then((objectType) => this.#enableObjectSetsWatcher([objectType.rid]))
|
|
1051
|
+
]);
|
|
1052
|
+
if (!this.#listeners.has(requestId)) {
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
const subscribe = {
|
|
1056
|
+
id: requestId,
|
|
1057
|
+
requests: [{
|
|
1058
|
+
objectSet: temporaryObjectSet.objectSetRid,
|
|
1059
|
+
objectSetContext: {
|
|
1060
|
+
objectSetFilterContext: {
|
|
1061
|
+
parameterOverrides: {}
|
|
1062
|
+
}
|
|
1063
|
+
},
|
|
1064
|
+
watchAllLinks: false
|
|
1065
|
+
}]
|
|
1066
|
+
};
|
|
1067
|
+
this.#ws?.send(JSON.stringify(subscribe));
|
|
1068
|
+
} catch (error) {
|
|
1069
|
+
this.#getCallbackByRequestId(requestId, "onError")?.(error);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
#expire(requestId) {
|
|
1073
|
+
const state = this.#listeners.get(requestId);
|
|
1074
|
+
if (state) {
|
|
1075
|
+
const {
|
|
1076
|
+
subscriptionId,
|
|
1077
|
+
objectSet
|
|
1078
|
+
} = state;
|
|
1079
|
+
if (subscriptionId) {
|
|
1080
|
+
state.subscriptionId = void 0;
|
|
1081
|
+
this.#subscriptionToRequestId.delete(subscriptionId);
|
|
1082
|
+
}
|
|
1083
|
+
this.#subscribe(requestId, objectSet);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
#unsubscribe(requestId) {
|
|
1087
|
+
const data = this.#listeners.get(requestId);
|
|
1088
|
+
if (data == null) {
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
this.#listeners.delete(requestId);
|
|
1092
|
+
clearTimeout(data.expiry);
|
|
1093
|
+
const {
|
|
1094
|
+
subscriptionId
|
|
1095
|
+
} = data;
|
|
1096
|
+
if (subscriptionId != null) {
|
|
1097
|
+
this.#subscriptionToRequestId.delete(subscriptionId);
|
|
1098
|
+
}
|
|
1099
|
+
if (this.#listeners.size === 0) {
|
|
1100
|
+
this.#destroyWebsocket();
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
async #ensureWebsocket() {
|
|
1104
|
+
if (this.#ws == null) {
|
|
1105
|
+
const {
|
|
1106
|
+
stack,
|
|
1107
|
+
tokenProvider
|
|
1108
|
+
} = this.#client;
|
|
1109
|
+
const base = new URL(stack);
|
|
1110
|
+
const url = `wss://${base.host}/object-set-watcher/ws/subscriptions`;
|
|
1111
|
+
const token = await tokenProvider();
|
|
1112
|
+
if (this.#ws == null) {
|
|
1113
|
+
const nextConnectTime = (this.#lastWsConnect ?? 0) + MINIMUM_RECONNECT_DELAY_MS;
|
|
1114
|
+
if (nextConnectTime > Date.now()) {
|
|
1115
|
+
await new Promise((resolve) => {
|
|
1116
|
+
setTimeout(resolve, nextConnectTime - Date.now());
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
this.#lastWsConnect = Date.now();
|
|
1120
|
+
if (this.#ws == null) {
|
|
1121
|
+
this.#ws = new WebSocket(url, [`Bearer-${token}`]);
|
|
1122
|
+
this.#ws.addEventListener("close", this.#onClose);
|
|
1123
|
+
this.#ws.addEventListener("message", this.#onMessage);
|
|
1124
|
+
this.#ws.addEventListener("open", this.#onOpen);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
if (this.#ws.readyState === WebSocket.CONNECTING) {
|
|
1128
|
+
return new Promise((resolve, reject) => {
|
|
1129
|
+
this.#ws.addEventListener("open", () => {
|
|
1130
|
+
resolve();
|
|
1131
|
+
});
|
|
1132
|
+
this.#ws.addEventListener("error", (event) => {
|
|
1133
|
+
reject(new Error(event.toString()));
|
|
1134
|
+
});
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
#onOpen = () => {
|
|
1140
|
+
for (const [requestId, state] of this.#listeners) {
|
|
1141
|
+
this.#subscribe(requestId, state.objectSet);
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
#onMessage = async (message) => {
|
|
1145
|
+
const data = JSON.parse(message.data.toString());
|
|
1146
|
+
switch (data.type) {
|
|
1147
|
+
case "objectSetChanged": {
|
|
1148
|
+
if (data.objectSetChanged.confidenceValue) {
|
|
1149
|
+
this.#getCallback(data.objectSetChanged.id, "onOutOfDate")?.();
|
|
1150
|
+
break;
|
|
1151
|
+
}
|
|
1152
|
+
const {
|
|
1153
|
+
id: subscriptionId,
|
|
1154
|
+
objects
|
|
1155
|
+
} = data.objectSetChanged;
|
|
1156
|
+
const callback = this.#getCallback(subscriptionId, "onChange");
|
|
1157
|
+
if (callback) {
|
|
1158
|
+
callback(await convertFoundryToOsdkObjects(this.#client, this.#metadataContext, objects));
|
|
1159
|
+
}
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1162
|
+
case "refreshObjectSet": {
|
|
1163
|
+
const {
|
|
1164
|
+
id: subscriptionId
|
|
1165
|
+
} = data.refreshObjectSet;
|
|
1166
|
+
this.#getCallback(subscriptionId, "onOutOfDate")?.();
|
|
1167
|
+
break;
|
|
1168
|
+
}
|
|
1169
|
+
case "subscribeResponses": {
|
|
1170
|
+
const {
|
|
1171
|
+
id: requestId,
|
|
1172
|
+
responses
|
|
1173
|
+
} = data.subscribeResponses;
|
|
1174
|
+
const listenerData = this.#listeners.get(requestId);
|
|
1175
|
+
if (listenerData == null) {
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
if (responses.length !== 1) {
|
|
1179
|
+
throw new Error("Got more than one response but we only expect a single one");
|
|
1180
|
+
}
|
|
1181
|
+
const response = responses[0];
|
|
1182
|
+
switch (response.type) {
|
|
1183
|
+
case "error":
|
|
1184
|
+
this.#getCallbackByRequestId(requestId, "onError")?.(response.error);
|
|
1185
|
+
this.#unsubscribe(requestId);
|
|
1186
|
+
return;
|
|
1187
|
+
case "qos":
|
|
1188
|
+
this.#destroyWebsocket();
|
|
1189
|
+
this.#ensureWebsocket();
|
|
1190
|
+
return;
|
|
1191
|
+
case "success":
|
|
1192
|
+
const {
|
|
1193
|
+
id: subscriptionId
|
|
1194
|
+
} = response.success;
|
|
1195
|
+
listenerData.subscriptionId = subscriptionId;
|
|
1196
|
+
this.#subscriptionToRequestId.set(subscriptionId, requestId);
|
|
1197
|
+
this.#getCallbackByRequestId(requestId, "onOutOfDate")?.();
|
|
1198
|
+
break;
|
|
1199
|
+
default:
|
|
1200
|
+
this.#getCallbackByRequestId(requestId, "onError")?.(response);
|
|
1201
|
+
}
|
|
1202
|
+
break;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
#onClose = () => {
|
|
1207
|
+
this.#destroyWebsocket();
|
|
1208
|
+
};
|
|
1209
|
+
async #enableObjectSetsWatcher(objectTypeRids) {
|
|
1210
|
+
return batchEnableWatcher(this.#conjureContext, {
|
|
1211
|
+
requests: objectTypeRids
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
async #createTemporaryObjectSet(objectSet) {
|
|
1215
|
+
const objectSetBaseType = await getObjectSetBaseType(objectSet);
|
|
1216
|
+
const mapping = await getOntologyPropertyMappingForApiName(this.#client, this.#metadataContext, objectSetBaseType);
|
|
1217
|
+
const temporaryObjectSet = await createTemporaryObjectSet(this.#ossContext, {
|
|
1218
|
+
objectSet: toConjureObjectSet(objectSet, mapping),
|
|
1219
|
+
timeToLive: "ONE_DAY",
|
|
1220
|
+
objectSetFilterContext: {
|
|
1221
|
+
parameterOverrides: {}
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
return {
|
|
1225
|
+
objectSetRid: temporaryObjectSet.objectSetRid
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
#destroyWebsocket = () => {
|
|
1229
|
+
if (this.#ws) {
|
|
1230
|
+
this.#ws.removeEventListener("open", this.#onOpen);
|
|
1231
|
+
this.#ws.removeEventListener("message", this.#onMessage);
|
|
1232
|
+
this.#ws.removeEventListener("close", this.#onClose);
|
|
1233
|
+
if (this.#ws.readyState !== WebSocket.CLOSING && this.#ws.readyState !== WebSocket.CLOSED) {
|
|
1234
|
+
this.#ws.close();
|
|
1235
|
+
}
|
|
1236
|
+
this.#ws = void 0;
|
|
1237
|
+
}
|
|
1238
|
+
this.#subscriptionToRequestId.clear();
|
|
1239
|
+
for (const state of this.#listeners.values()) {
|
|
1240
|
+
state.subscriptionId = void 0;
|
|
1241
|
+
}
|
|
1242
|
+
if (this.#listeners.size > 0) {
|
|
1243
|
+
this.#ensureWebsocket();
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
#getCallbackByRequestId(requestId, type) {
|
|
1247
|
+
const maybeListener = this.#listeners.get(requestId);
|
|
1248
|
+
return maybeListener?.listener?.[type];
|
|
1249
|
+
}
|
|
1250
|
+
#getCallback(subscriptionId, type) {
|
|
1251
|
+
const requestId = this.#subscriptionToRequestId.get(subscriptionId);
|
|
1252
|
+
if (requestId) {
|
|
1253
|
+
return this.#getCallbackByRequestId(requestId, type);
|
|
1254
|
+
}
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
async function convertFoundryToOsdkObjects(client, ctx, objects) {
|
|
1259
|
+
const osdkObjects = await Promise.all(objects.map(async (object) => {
|
|
1260
|
+
const propertyMapping = await getOntologyPropertyMappingForRid(ctx, client.ontologyRid, object.type);
|
|
1261
|
+
const convertedObject = Object.fromEntries([...Object.entries(object.properties).map(([key, value]) => {
|
|
1262
|
+
return [propertyMapping?.propertyIdToApiNameMapping[key], value];
|
|
1263
|
+
}), [propertyMapping?.propertyIdToApiNameMapping[Object.entries(object.key)[0][0]], Object.entries(object.key)[0][1]], ["__apiName", propertyMapping?.apiName], ["$apiName", propertyMapping?.apiName]]);
|
|
1264
|
+
return convertedObject;
|
|
1265
|
+
}));
|
|
1266
|
+
return await convertWireToOsdkObjects(client, osdkObjects, void 0);
|
|
1267
|
+
}
|
|
1268
|
+
var objectTypeMapping = /* @__PURE__ */ new WeakMap();
|
|
1269
|
+
var objectApiNameToRid = /* @__PURE__ */ new Map();
|
|
1270
|
+
async function getOntologyPropertyMappingForApiName(client, ctx, objectApiName) {
|
|
1271
|
+
if (objectApiNameToRid.has(objectApiName)) {
|
|
1272
|
+
return objectTypeMapping.get(ctx)?.get(objectApiNameToRid.get(objectApiName));
|
|
1273
|
+
}
|
|
1274
|
+
const wireObjectType = await getObjectTypeV2(client, client.ontologyRid, objectApiName);
|
|
1275
|
+
return getOntologyPropertyMappingForRid(ctx, client.ontologyRid, wireObjectType.rid);
|
|
1276
|
+
}
|
|
1277
|
+
var cachedAllOntologies;
|
|
1278
|
+
async function getOntologyVersionForRid(ctx, ontologyRid) {
|
|
1279
|
+
cachedAllOntologies ??= await loadAllOntologies(ctx, {});
|
|
1280
|
+
!cachedAllOntologies.ontologies[ontologyRid] ? process.env.NODE_ENV !== "production" ? invariant2(false, "ontology should be loaded") : invariant2(false) : void 0;
|
|
1281
|
+
return cachedAllOntologies.ontologies[ontologyRid].currentOntologyVersion;
|
|
1282
|
+
}
|
|
1283
|
+
async function getOntologyPropertyMappingForRid(ctx, ontologyRid, objectRid) {
|
|
1284
|
+
if (!objectTypeMapping.has(ctx)) {
|
|
1285
|
+
objectTypeMapping.set(ctx, /* @__PURE__ */ new Map());
|
|
1286
|
+
}
|
|
1287
|
+
if (!objectTypeMapping.get(ctx).has(objectRid)) {
|
|
1288
|
+
const ontologyVersion = await getOntologyVersionForRid(ctx, ontologyRid);
|
|
1289
|
+
const body = {
|
|
1290
|
+
objectTypeVersions: {
|
|
1291
|
+
// TODO: Undefined drops this in the body
|
|
1292
|
+
[objectRid]: ontologyVersion
|
|
1293
|
+
},
|
|
1294
|
+
linkTypeVersions: {},
|
|
1295
|
+
loadRedacted: false,
|
|
1296
|
+
includeObjectTypesWithoutSearchableDatasources: true
|
|
1297
|
+
};
|
|
1298
|
+
const entities = await loadOntologyEntities(ctx, body);
|
|
1299
|
+
!entities.objectTypes[objectRid] ? process.env.NODE_ENV !== "production" ? invariant2(false, "object type should be loaded") : invariant2(false) : void 0;
|
|
1300
|
+
const propertyIdToApiNameMapping = Object.fromEntries(Object.values(entities.objectTypes[objectRid].propertyTypes).map((property) => {
|
|
1301
|
+
return [property.id, property.apiName];
|
|
1302
|
+
}));
|
|
1303
|
+
const propertyApiNameToIdMapping = Object.fromEntries(Object.values(entities.objectTypes[objectRid].propertyTypes).map((property) => {
|
|
1304
|
+
return [property.id, property.apiName];
|
|
1305
|
+
}));
|
|
1306
|
+
objectTypeMapping.get(ctx)?.set(objectRid, {
|
|
1307
|
+
apiName: entities.objectTypes[objectRid].apiName,
|
|
1308
|
+
id: entities.objectTypes[objectRid].id,
|
|
1309
|
+
propertyIdToApiNameMapping,
|
|
1310
|
+
propertyApiNameToIdMapping
|
|
1311
|
+
});
|
|
1312
|
+
objectApiNameToRid.set(entities.objectTypes[objectRid].apiName, objectRid);
|
|
1313
|
+
}
|
|
1314
|
+
return objectTypeMapping.get(ctx)?.get(objectRid);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
// src/objectSet/createObjectSet.ts
|
|
1318
|
+
function isObjectTypeDefinition(def) {
|
|
1319
|
+
return def.type === "object";
|
|
1320
|
+
}
|
|
1321
|
+
function isObjectSet(o) {
|
|
1322
|
+
return o != null && typeof o === "object" && isWireObjectSet(objectSetDefinitions.get(o));
|
|
1323
|
+
}
|
|
1324
|
+
function getWireObjectSet(objectSet) {
|
|
1325
|
+
return objectSetDefinitions.get(objectSet);
|
|
1326
|
+
}
|
|
1327
|
+
var objectSetDefinitions = /* @__PURE__ */ new WeakMap();
|
|
1328
|
+
function createObjectSet(objectType, clientCtx, objectSet = {
|
|
1329
|
+
type: "base",
|
|
1330
|
+
objectType: objectType["apiName"]
|
|
1331
|
+
}) {
|
|
1332
|
+
const base = {
|
|
1333
|
+
aggregate: aggregate.bind(globalThis, clientCtx, objectType, objectSet),
|
|
1334
|
+
aggregateOrThrow: aggregate.bind(globalThis, clientCtx, objectType, objectSet),
|
|
1335
|
+
fetchPage: fetchPageInternal.bind(globalThis, clientCtx, objectType, objectSet),
|
|
1336
|
+
fetchPageWithErrors: fetchPageWithErrorsInternal.bind(globalThis, clientCtx, objectType, objectSet),
|
|
1337
|
+
fetchPageOrThrow: fetchPageInternal.bind(globalThis, clientCtx, objectType, objectSet),
|
|
1338
|
+
where: (clause) => {
|
|
1339
|
+
return createObjectSet(objectType, clientCtx, {
|
|
1340
|
+
type: "filter",
|
|
1341
|
+
objectSet,
|
|
1342
|
+
where: modernToLegacyWhereClause(clause)
|
|
1343
|
+
});
|
|
1344
|
+
},
|
|
1345
|
+
pivotTo: function(type) {
|
|
1346
|
+
return createSearchAround(type)();
|
|
1347
|
+
},
|
|
1348
|
+
union: (...objectSets) => {
|
|
1349
|
+
return createObjectSet(objectType, clientCtx, {
|
|
1350
|
+
type: "union",
|
|
1351
|
+
objectSets: [objectSet, ...objectSets.map((os) => objectSetDefinitions.get(os))]
|
|
1352
|
+
});
|
|
1353
|
+
},
|
|
1354
|
+
intersect: (...objectSets) => {
|
|
1355
|
+
return createObjectSet(objectType, clientCtx, {
|
|
1356
|
+
type: "intersect",
|
|
1357
|
+
objectSets: [objectSet, ...objectSets.map((os) => objectSetDefinitions.get(os))]
|
|
1358
|
+
});
|
|
1359
|
+
},
|
|
1360
|
+
subtract: (...objectSets) => {
|
|
1361
|
+
return createObjectSet(objectType, clientCtx, {
|
|
1362
|
+
type: "subtract",
|
|
1363
|
+
objectSets: [objectSet, ...objectSets.map((os) => objectSetDefinitions.get(os))]
|
|
1364
|
+
});
|
|
1365
|
+
},
|
|
1366
|
+
subscribe(listener) {
|
|
1367
|
+
const instance = ObjectSetListenerWebsocket.getInstance(clientCtx);
|
|
1368
|
+
return instance.subscribe(objectSet, listener);
|
|
1369
|
+
},
|
|
1370
|
+
asyncIter: async function* () {
|
|
1371
|
+
let nextPageToken = void 0;
|
|
1372
|
+
do {
|
|
1373
|
+
const result = await base.fetchPage({
|
|
1374
|
+
nextPageToken
|
|
1375
|
+
});
|
|
1376
|
+
for (const obj of await convertWireToOsdkObjects(clientCtx, result.data, void 0)) {
|
|
1377
|
+
yield obj;
|
|
1378
|
+
}
|
|
1379
|
+
} while (nextPageToken != null);
|
|
1380
|
+
},
|
|
1381
|
+
get: isObjectTypeDefinition(objectType) ? async (primaryKey, options) => {
|
|
1382
|
+
const withPk = {
|
|
1383
|
+
type: "filter",
|
|
1384
|
+
objectSet,
|
|
1385
|
+
where: {
|
|
1386
|
+
type: "eq",
|
|
1387
|
+
field: objectType.primaryKeyApiName,
|
|
1388
|
+
value: primaryKey
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
return await fetchSingle(clientCtx, objectType, options, withPk);
|
|
1392
|
+
} : void 0
|
|
1393
|
+
};
|
|
1394
|
+
function createSearchAround(link) {
|
|
1395
|
+
return () => {
|
|
1396
|
+
return createObjectSet(objectType, clientCtx, {
|
|
1397
|
+
type: "searchAround",
|
|
1398
|
+
objectSet,
|
|
1399
|
+
link
|
|
1400
|
+
});
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
objectSetDefinitions.set(base, objectSet);
|
|
1404
|
+
return base;
|
|
1405
|
+
}
|
|
9
1406
|
|
|
10
1407
|
// src/util/isOntologyObjectV2.ts
|
|
11
1408
|
function isOntologyObjectV2(o) {
|
|
@@ -41,17 +1438,9 @@ function toDataValue(value) {
|
|
|
41
1438
|
return value;
|
|
42
1439
|
}
|
|
43
1440
|
|
|
44
|
-
// src/actions/ActionValidationError.ts
|
|
45
|
-
var ActionValidationError = class extends Error {
|
|
46
|
-
constructor(validation) {
|
|
47
|
-
super("Validation Error");
|
|
48
|
-
this.validation = validation;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
1441
|
// src/actions/applyAction.ts
|
|
53
1442
|
async function applyAction(client, action, parameters, options = {}) {
|
|
54
|
-
const response = await applyActionV2(
|
|
1443
|
+
const response = await applyActionV2(addUserAgent(client, action), client.ontologyRid, action.apiName, {
|
|
55
1444
|
parameters: remapActionParams(parameters),
|
|
56
1445
|
options: {
|
|
57
1446
|
mode: options?.validateOnly ? "VALIDATE_ONLY" : "VALIDATE_AND_EXECUTE",
|
|
@@ -84,34 +1473,11 @@ function createActionInvoker(client, action) {
|
|
|
84
1473
|
return applyAction(client, action, ...args);
|
|
85
1474
|
};
|
|
86
1475
|
}
|
|
87
|
-
function createOldActionInvoker(client, ontology) {
|
|
88
|
-
const proxy = new Proxy({}, {
|
|
89
|
-
get: (_target, p, _receiver) => {
|
|
90
|
-
if (typeof p === "string") {
|
|
91
|
-
return createActionInvoker(client, ontology.actions[p]);
|
|
92
|
-
}
|
|
93
|
-
return void 0;
|
|
94
|
-
},
|
|
95
|
-
ownKeys(_target) {
|
|
96
|
-
return Object.keys(ontology.actions);
|
|
97
|
-
},
|
|
98
|
-
getOwnPropertyDescriptor(_target, p) {
|
|
99
|
-
if (typeof p === "string") {
|
|
100
|
-
return {
|
|
101
|
-
enumerable: ontology.actions[p] != null,
|
|
102
|
-
configurable: true,
|
|
103
|
-
value: proxy[p]
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
return proxy;
|
|
109
|
-
}
|
|
110
1476
|
async function loadAllOutgoingLinkTypes(client, objtype) {
|
|
111
1477
|
const linkTypes = [];
|
|
112
1478
|
let pageToken;
|
|
113
1479
|
do {
|
|
114
|
-
const result = await listOutgoingLinkTypesV2(
|
|
1480
|
+
const result = await listOutgoingLinkTypesV2(client, client.ontologyRid, objtype, {
|
|
115
1481
|
pageToken
|
|
116
1482
|
});
|
|
117
1483
|
pageToken = result.nextPageToken;
|
|
@@ -120,24 +1486,20 @@ async function loadAllOutgoingLinkTypes(client, objtype) {
|
|
|
120
1486
|
return linkTypes;
|
|
121
1487
|
}
|
|
122
1488
|
function makeConjureContext(client, servicePath) {
|
|
123
|
-
const baseUrl = client.stack.startsWith("https://") ? client.stack : `https://${client.stack}`;
|
|
124
1489
|
return {
|
|
125
|
-
baseUrl,
|
|
1490
|
+
baseUrl: client.stack,
|
|
126
1491
|
servicePath,
|
|
127
1492
|
fetchFn: client.fetch,
|
|
128
1493
|
tokenProvider: async () => await client.tokenProvider()
|
|
129
1494
|
};
|
|
130
1495
|
}
|
|
131
1496
|
async function loadFullObjectMetadata(client, objtype) {
|
|
132
|
-
const {
|
|
133
|
-
ontologyApiName
|
|
134
|
-
} = client.ontology.metadata;
|
|
135
1497
|
const conjureCtx = makeConjureContext(client, "/ontology-metadata/api");
|
|
136
|
-
const [objectType, linkTypes, interfaceTypes, metadata] = await Promise.all([getObjectTypeV2(
|
|
1498
|
+
const [objectType, linkTypes, interfaceTypes, metadata] = await Promise.all([getObjectTypeV2(client, client.ontologyRid, objtype), loadAllOutgoingLinkTypes(client, objtype), listInterfaceTypes(client, client.ontologyRid, {
|
|
137
1499
|
pageSize: 200,
|
|
138
1500
|
preview: true
|
|
139
1501
|
}), await loadAllOntologies(conjureCtx, {})]);
|
|
140
|
-
const sharedPropertyTypeMapping = await loadSptMap(conjureCtx, metadata, client.
|
|
1502
|
+
const sharedPropertyTypeMapping = await loadSptMap(conjureCtx, metadata, client.ontologyRid, objectType.rid);
|
|
141
1503
|
const full = {
|
|
142
1504
|
implementsInterfaces: interfaceTypes.data.map((i) => i.apiName),
|
|
143
1505
|
linkTypes,
|
|
@@ -158,7 +1520,7 @@ async function loadSptMap(ctx, ontologyMetadata, ontologyRid, objectRid) {
|
|
|
158
1520
|
};
|
|
159
1521
|
const entities = await loadOntologyEntities(ctx, body);
|
|
160
1522
|
const objectType = entities.objectTypes[objectRid];
|
|
161
|
-
!objectType ? process.env.NODE_ENV !== "production" ?
|
|
1523
|
+
!objectType ? process.env.NODE_ENV !== "production" ? invariant2(false, "object type should be loaded") : invariant2(false) : void 0;
|
|
162
1524
|
const sptMap = {};
|
|
163
1525
|
for (const property of Object.values(objectType.propertyTypes)) {
|
|
164
1526
|
if (property.sharedPropertyTypeApiName && property.apiName) {
|
|
@@ -168,10 +1530,7 @@ async function loadSptMap(ctx, ontologyMetadata, ontologyRid, objectRid) {
|
|
|
168
1530
|
return sptMap;
|
|
169
1531
|
}
|
|
170
1532
|
async function loadInterfaceDefinition(client, objtype) {
|
|
171
|
-
const {
|
|
172
|
-
ontologyApiName
|
|
173
|
-
} = client.ontology.metadata;
|
|
174
|
-
const r = await getInterfaceType(createOpenApiRequest(client.stack, client.fetch), ontologyApiName, objtype, {
|
|
1533
|
+
const r = await getInterfaceType(client, client.ontologyRid, objtype, {
|
|
175
1534
|
preview: true
|
|
176
1535
|
});
|
|
177
1536
|
return __UNSTABLE_wireInterfaceTypeV2ToSdkObjectDefinition(r, true);
|
|
@@ -217,90 +1576,69 @@ var createStandardOntologyProviderFactory = (client) => {
|
|
|
217
1576
|
};
|
|
218
1577
|
|
|
219
1578
|
// src/util/UserAgent.ts
|
|
220
|
-
var USER_AGENT = `osdk-client/${"0.
|
|
1579
|
+
var USER_AGENT = `osdk-client/${"0.15.1-main-20240411211601"}`;
|
|
221
1580
|
|
|
222
1581
|
// src/createMinimalClient.ts
|
|
223
1582
|
function createMinimalClient(metadata, stack, tokenProvider, ontologyCachingOptions = {}, fetchFn = global.fetch) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// src/ObjectSetCreator.ts
|
|
233
|
-
function createObjectSetCreator(client, ontology) {
|
|
234
|
-
return new Proxy({}, {
|
|
235
|
-
get: (target, p, receiver) => {
|
|
236
|
-
if (typeof p === "string") {
|
|
237
|
-
return client(ontology.objects[p] ?? ontology.interfaces?.[p]);
|
|
238
|
-
}
|
|
239
|
-
return void 0;
|
|
240
|
-
},
|
|
241
|
-
ownKeys(target) {
|
|
242
|
-
return Object.keys(ontology.objects);
|
|
243
|
-
},
|
|
244
|
-
getOwnPropertyDescriptor(target, p) {
|
|
245
|
-
if (typeof p === "string") {
|
|
246
|
-
return {
|
|
247
|
-
enumerable: ontology.objects[p] != null,
|
|
248
|
-
configurable: true,
|
|
249
|
-
get: () => client(ontology.objects[p] ?? ontology.interfaces?.[p])
|
|
250
|
-
};
|
|
251
|
-
}
|
|
1583
|
+
if (process?.env?.NODE_ENV !== "production") {
|
|
1584
|
+
try {
|
|
1585
|
+
new URL(stack);
|
|
1586
|
+
} catch (e) {
|
|
1587
|
+
const hint = !stack.startsWith("http://") || !stack.startsWith("https://") ? ". Did you forget to add 'http://' or 'https://'?" : "";
|
|
1588
|
+
throw new Error(`Invalid stack URL: ${stack}${hint}`);
|
|
252
1589
|
}
|
|
253
|
-
}
|
|
1590
|
+
}
|
|
1591
|
+
const clientCtx = {
|
|
1592
|
+
...createClientContext({
|
|
1593
|
+
metadata
|
|
1594
|
+
}, stack, tokenProvider, USER_AGENT, fetchFn),
|
|
1595
|
+
ontologyRid: metadata.ontologyRid,
|
|
1596
|
+
ontologyProvider: void 0
|
|
1597
|
+
};
|
|
1598
|
+
clientCtx.ontologyProvider = createStandardOntologyProviderFactory(ontologyCachingOptions)(clientCtx);
|
|
1599
|
+
return clientCtx;
|
|
254
1600
|
}
|
|
255
1601
|
|
|
256
1602
|
// src/createClient.ts
|
|
257
|
-
function
|
|
258
|
-
const clientCtx = createMinimalClient(
|
|
1603
|
+
function createClient(stack, ontologyRid, tokenProvider, HOLD = void 0, fetchFn = fetch) {
|
|
1604
|
+
const clientCtx = createMinimalClient({
|
|
1605
|
+
ontologyRid,
|
|
1606
|
+
userAgent: ""
|
|
1607
|
+
// ontology specific user agent injected elsewhere
|
|
1608
|
+
}, stack, tokenProvider, {}, fetchFn);
|
|
259
1609
|
function clientFn(o) {
|
|
260
1610
|
if (o.type === "object" || o.type === "interface") {
|
|
261
|
-
clientCtx.
|
|
1611
|
+
clientCtx.ontologyProvider.maybeSeed(o);
|
|
262
1612
|
return createObjectSet(o, clientCtx);
|
|
263
1613
|
} else if (o.type === "action") {
|
|
264
|
-
clientCtx.
|
|
1614
|
+
clientCtx.ontologyProvider.maybeSeed(o);
|
|
265
1615
|
return createActionInvoker(clientCtx, o);
|
|
266
1616
|
} else {
|
|
267
|
-
throw new Error("
|
|
1617
|
+
throw new Error("not implemented");
|
|
268
1618
|
}
|
|
269
1619
|
}
|
|
270
|
-
return [clientCtx, clientFn];
|
|
271
|
-
}
|
|
272
|
-
function createClient(ontology, stack, tokenProvider, ontologyCachingOptions = {}, fetchFn = fetch) {
|
|
273
|
-
const [clientCtx, clientFn] = createFutureClientPlus(ontology.metadata, stack, tokenProvider, ontologyCachingOptions, fetchFn);
|
|
274
|
-
const objectSetFactory = (type) => createObjectSet(ontology["objects"][type] ?? ontology["interfaces"]?.[type], clientCtx);
|
|
275
|
-
const oldActionInvoker = createOldActionInvoker(clientCtx, ontology);
|
|
276
1620
|
const client = Object.defineProperties(clientFn, {
|
|
277
|
-
objectSet: {
|
|
278
|
-
get: () => objectSetFactory
|
|
279
|
-
},
|
|
280
|
-
objects: {
|
|
281
|
-
get: () => createObjectSetCreator(client, ontology)
|
|
282
|
-
},
|
|
283
|
-
actions: {
|
|
284
|
-
get: () => oldActionInvoker
|
|
285
|
-
},
|
|
286
1621
|
__UNSTABLE_preexistingObjectSet: {
|
|
287
|
-
get: () => (
|
|
288
|
-
return createObjectSet(
|
|
1622
|
+
get: () => (definition, rid) => {
|
|
1623
|
+
return createObjectSet(definition, clientCtx, {
|
|
289
1624
|
type: "intersect",
|
|
290
1625
|
objectSets: [{
|
|
291
1626
|
type: "base",
|
|
292
|
-
objectType
|
|
1627
|
+
objectType: definition.apiName
|
|
293
1628
|
}, {
|
|
294
1629
|
type: "reference",
|
|
295
1630
|
reference: rid
|
|
296
1631
|
}]
|
|
297
1632
|
});
|
|
298
1633
|
}
|
|
1634
|
+
},
|
|
1635
|
+
ctx: {
|
|
1636
|
+
value: clientCtx
|
|
299
1637
|
}
|
|
300
1638
|
});
|
|
301
1639
|
return client;
|
|
302
1640
|
}
|
|
303
1641
|
|
|
304
|
-
export { ActionValidationError,
|
|
1642
|
+
export { ActionValidationError, augment, createClient };
|
|
305
1643
|
//# sourceMappingURL=out.js.map
|
|
306
1644
|
//# sourceMappingURL=index.mjs.map
|