@osdk/api 2.8.0-beta.2 → 2.8.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/build/browser/aggregate/StringFilter.js.map +1 -1
- package/build/browser/mapping/DataValueMapping.js.map +1 -1
- package/build/browser/ontology/QueryDefinition.js.map +1 -1
- package/build/browser/queries/Queries.js.map +1 -1
- package/build/cjs/{ObjectSet-CqVqDXKn.d.cts → ObjectSet-ChROetz0.d.cts} +14 -2
- package/build/cjs/index.d.cts +9 -5
- package/build/cjs/public/unstable.d.cts +2 -2
- package/build/esm/aggregate/StringFilter.js.map +1 -1
- package/build/esm/mapping/DataValueMapping.js.map +1 -1
- package/build/esm/ontology/QueryDefinition.js.map +1 -1
- package/build/esm/queries/Queries.js.map +1 -1
- package/build/types/aggregate/StringFilter.d.ts +9 -1
- package/build/types/aggregate/StringFilter.d.ts.map +1 -1
- package/build/types/mapping/DataValueMapping.d.ts +2 -2
- package/build/types/mapping/DataValueMapping.d.ts.map +1 -1
- package/build/types/ontology/QueryDefinition.d.ts +1 -1
- package/build/types/ontology/QueryDefinition.d.ts.map +1 -1
- package/build/types/queries/Queries.d.ts +2 -0
- package/build/types/queries/Queries.d.ts.map +1 -1
- package/package.json +1 -1
- package/build/browser/OsdkObjectFrom.test.js +0 -204
- package/build/browser/OsdkObjectFrom.test.js.map +0 -1
- package/build/browser/aggregate/AggregationsClause.test.js +0 -21
- package/build/browser/aggregate/AggregationsClause.test.js.map +0 -1
- package/build/browser/definitions/LinkDefinitions.test.js +0 -26
- package/build/browser/definitions/LinkDefinitions.test.js.map +0 -1
- package/build/browser/groupby/GroupByClause.test.js +0 -21
- package/build/browser/groupby/GroupByClause.test.js.map +0 -1
- package/build/browser/junk.test.js +0 -23
- package/build/browser/junk.test.js.map +0 -1
- package/build/browser/object/ObjectDefinitions.test.js +0 -28
- package/build/browser/object/ObjectDefinitions.test.js.map +0 -1
- package/build/browser/objectSet/ObjectSet.test.js +0 -736
- package/build/browser/objectSet/ObjectSet.test.js.map +0 -1
- package/build/browser/ontology/ObjectSpecifier.test.js +0 -53
- package/build/browser/ontology/ObjectSpecifier.test.js.map +0 -1
- package/build/browser/ontology/SimplePropertyDef.test.js +0 -48
- package/build/browser/ontology/SimplePropertyDef.test.js.map +0 -1
- package/build/esm/OsdkObjectFrom.test.js +0 -204
- package/build/esm/OsdkObjectFrom.test.js.map +0 -1
- package/build/esm/aggregate/AggregationsClause.test.js +0 -21
- package/build/esm/aggregate/AggregationsClause.test.js.map +0 -1
- package/build/esm/definitions/LinkDefinitions.test.js +0 -26
- package/build/esm/definitions/LinkDefinitions.test.js.map +0 -1
- package/build/esm/groupby/GroupByClause.test.js +0 -21
- package/build/esm/groupby/GroupByClause.test.js.map +0 -1
- package/build/esm/junk.test.js +0 -23
- package/build/esm/junk.test.js.map +0 -1
- package/build/esm/object/ObjectDefinitions.test.js +0 -28
- package/build/esm/object/ObjectDefinitions.test.js.map +0 -1
- package/build/esm/objectSet/ObjectSet.test.js +0 -736
- package/build/esm/objectSet/ObjectSet.test.js.map +0 -1
- package/build/esm/ontology/ObjectSpecifier.test.js +0 -53
- package/build/esm/ontology/ObjectSpecifier.test.js.map +0 -1
- package/build/esm/ontology/SimplePropertyDef.test.js +0 -48
- package/build/esm/ontology/SimplePropertyDef.test.js.map +0 -1
- package/build/types/OsdkObjectFrom.test.d.ts +0 -1
- package/build/types/OsdkObjectFrom.test.d.ts.map +0 -1
- package/build/types/aggregate/AggregationsClause.test.d.ts +0 -46
- package/build/types/aggregate/AggregationsClause.test.d.ts.map +0 -1
- package/build/types/definitions/LinkDefinitions.test.d.ts +0 -1
- package/build/types/definitions/LinkDefinitions.test.d.ts.map +0 -1
- package/build/types/groupby/GroupByClause.test.d.ts +0 -23
- package/build/types/groupby/GroupByClause.test.d.ts.map +0 -1
- package/build/types/junk.test.d.ts +0 -1
- package/build/types/junk.test.d.ts.map +0 -1
- package/build/types/object/ObjectDefinitions.test.d.ts +0 -1
- package/build/types/object/ObjectDefinitions.test.d.ts.map +0 -1
- package/build/types/objectSet/ObjectSet.test.d.ts +0 -2
- package/build/types/objectSet/ObjectSet.test.d.ts.map +0 -1
- package/build/types/ontology/ObjectSpecifier.test.d.ts +0 -1
- package/build/types/ontology/ObjectSpecifier.test.d.ts.map +0 -1
- package/build/types/ontology/SimplePropertyDef.test.d.ts +0 -1
- package/build/types/ontology/SimplePropertyDef.test.d.ts.map +0 -1
|
@@ -1,736 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
import { describe, expectTypeOf, it, test, vi } from "vitest";
|
|
18
|
-
import { EmployeeApiTest } from "../test/EmployeeApiTest.js";
|
|
19
|
-
import { FooInterfaceApiTest } from "../test/FooInterfaceApiTest.js";
|
|
20
|
-
async function* asyncIterateLinkOnce() {
|
|
21
|
-
const obj = {
|
|
22
|
-
$apiName: undefined,
|
|
23
|
-
$primaryKey: undefined
|
|
24
|
-
};
|
|
25
|
-
yield Promise.resolve({
|
|
26
|
-
source: obj,
|
|
27
|
-
target: obj,
|
|
28
|
-
linkTypeApiName: undefined
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
export function createMockObjectSet() {
|
|
32
|
-
let fauxObject, fauxResults, fauxObjectSet;
|
|
33
|
-
|
|
34
|
-
// eslint-disable-next-line prefer-const
|
|
35
|
-
fauxObject = {
|
|
36
|
-
$link: {
|
|
37
|
-
peeps: {
|
|
38
|
-
$objectSetInternals: {
|
|
39
|
-
def: {}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
fauxResults = {
|
|
45
|
-
data: [fauxObject]
|
|
46
|
-
};
|
|
47
|
-
fauxObjectSet = {
|
|
48
|
-
where: vi.fn(() => {
|
|
49
|
-
return fauxObjectSet;
|
|
50
|
-
}),
|
|
51
|
-
withProperties: vi.fn(() => {
|
|
52
|
-
return fauxObjectSet;
|
|
53
|
-
}),
|
|
54
|
-
fetchPage: vi.fn(() => Promise.resolve(fauxResults)),
|
|
55
|
-
fetchPageWithErrors: vi.fn(() => Promise.resolve({
|
|
56
|
-
value: fauxResults
|
|
57
|
-
})),
|
|
58
|
-
fetchOne: vi.fn(() => fauxObject),
|
|
59
|
-
asyncIter: vi.fn(() => {
|
|
60
|
-
return {};
|
|
61
|
-
}),
|
|
62
|
-
aggregate: vi.fn(() => {
|
|
63
|
-
return {};
|
|
64
|
-
}),
|
|
65
|
-
pivotTo: vi.fn(() => {
|
|
66
|
-
return fauxObjectSet;
|
|
67
|
-
}),
|
|
68
|
-
nearestNeighbors: vi.fn(() => {
|
|
69
|
-
return fauxObjectSet;
|
|
70
|
-
}),
|
|
71
|
-
experimental_asyncIterLinks: vi.fn(asyncIterateLinkOnce)
|
|
72
|
-
};
|
|
73
|
-
return fauxObjectSet;
|
|
74
|
-
}
|
|
75
|
-
describe("ObjectSet", () => {
|
|
76
|
-
const fauxObjectSet = createMockObjectSet();
|
|
77
|
-
createMockObjectSet();
|
|
78
|
-
describe("normal", () => {
|
|
79
|
-
test("select none", async () => {
|
|
80
|
-
await fauxObjectSet.fetchPage();
|
|
81
|
-
expectTypeOf().toEqualTypeOf();
|
|
82
|
-
|
|
83
|
-
// Do it again but be explicit about the params to be sure
|
|
84
|
-
// we don't break them
|
|
85
|
-
await fauxObjectSet.fetchPage();
|
|
86
|
-
});
|
|
87
|
-
test("select one", async () => {
|
|
88
|
-
await fauxObjectSet.fetchPage({
|
|
89
|
-
"$select": ["fullName"]
|
|
90
|
-
});
|
|
91
|
-
expectTypeOf().toEqualTypeOf();
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
describe("includeAllBaseObjectProperties", () => {
|
|
95
|
-
it("has the right types if you pass true", async () => {
|
|
96
|
-
const fetchPageResult = await fauxObjectSet.where({
|
|
97
|
-
class: "idk"
|
|
98
|
-
}).fetchPage({
|
|
99
|
-
$includeAllBaseObjectProperties: true
|
|
100
|
-
});
|
|
101
|
-
expectTypeOf(fetchPageResult).toEqualTypeOf();
|
|
102
|
-
const asyncIterResult = fauxObjectSet.where({
|
|
103
|
-
class: "idk"
|
|
104
|
-
}).asyncIter({
|
|
105
|
-
$includeAllBaseObjectProperties: true
|
|
106
|
-
});
|
|
107
|
-
expectTypeOf(asyncIterResult).toEqualTypeOf();
|
|
108
|
-
});
|
|
109
|
-
it("does not let you pass partial $select and true", async () => {
|
|
110
|
-
await fauxObjectSet.where({
|
|
111
|
-
class: "idk"
|
|
112
|
-
}).fetchPage({
|
|
113
|
-
// @ts-expect-error
|
|
114
|
-
$includeAllBaseObjectProperties: true,
|
|
115
|
-
$select: ["attachment"]
|
|
116
|
-
});
|
|
117
|
-
fauxObjectSet.where({
|
|
118
|
-
class: "idk"
|
|
119
|
-
}).asyncIter({
|
|
120
|
-
// @ts-expect-error
|
|
121
|
-
$includeAllBaseObjectProperties: true,
|
|
122
|
-
$select: ["attachment"]
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
it("does let you pass full select options and false", async () => {
|
|
126
|
-
await fauxObjectSet.where({
|
|
127
|
-
class: "idk"
|
|
128
|
-
}).fetchPage({
|
|
129
|
-
$includeAllBaseObjectProperties: true,
|
|
130
|
-
// this select list is intended to represent all properties on `EmployeeApiTest`,
|
|
131
|
-
// so if you get an error here later and you added properties to that object,
|
|
132
|
-
// be sure to add them here too.
|
|
133
|
-
$select: ["attachment", "class", "employeeId", "fullName", "geopoint", "geotimeSeriesReference", "isActive", "mediaReference", "timeseries", "dateOfJoining", "hourlyRate", "yearsOfExperience", "rank", "performanceScore", "mediaReference", "lastUpdated", "skillSet", "skillSetEmbedding"]
|
|
134
|
-
});
|
|
135
|
-
await fauxObjectSet.where({
|
|
136
|
-
class: "idk"
|
|
137
|
-
}).fetchPage({
|
|
138
|
-
$includeAllBaseObjectProperties: true,
|
|
139
|
-
// this select list is intended to represent all properties on `EmployeeApiTest`,
|
|
140
|
-
// so if you get an error here later and you added properties to that object,
|
|
141
|
-
// be sure to add them here too.
|
|
142
|
-
$select: ["attachment", "class", "employeeId", "fullName", "geopoint", "geotimeSeriesReference", "isActive", "mediaReference", "timeseries", "dateOfJoining", "hourlyRate", "yearsOfExperience", "rank", "performanceScore", "mediaReference", "lastUpdated", "skillSet", "skillSetEmbedding"]
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
test("includeRid", async () => {
|
|
147
|
-
const x = await fauxObjectSet.where({
|
|
148
|
-
class: "idk"
|
|
149
|
-
}).fetchPage({
|
|
150
|
-
$includeRid: true
|
|
151
|
-
});
|
|
152
|
-
expectTypeOf(x).toEqualTypeOf();
|
|
153
|
-
});
|
|
154
|
-
test("pivotTo", async () => {
|
|
155
|
-
await fauxObjectSet.pivotTo("peeps").fetchPage({});
|
|
156
|
-
const subselect = await fauxObjectSet.pivotTo("peeps").fetchPage({
|
|
157
|
-
$select: ["employeeId", "class"]
|
|
158
|
-
});
|
|
159
|
-
expectTypeOf(subselect).toEqualTypeOf();
|
|
160
|
-
});
|
|
161
|
-
describe(".withProperties", () => {
|
|
162
|
-
test("single property", async () => {
|
|
163
|
-
const withA = fauxObjectSet.withProperties({
|
|
164
|
-
"a": base => {
|
|
165
|
-
return base.pivotTo("lead").aggregate("class:exactDistinct");
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
expectTypeOf(withA).toEqualTypeOf();
|
|
169
|
-
await withA.fetchPage();
|
|
170
|
-
expectTypeOf().toEqualTypeOf();
|
|
171
|
-
expectTypeOf().toEqualTypeOf();
|
|
172
|
-
});
|
|
173
|
-
it("can be sub-selected", () => {
|
|
174
|
-
fauxObjectSet.withProperties({
|
|
175
|
-
"derivedPropertyName": base => base.pivotTo("lead").selectProperty("employeeId")
|
|
176
|
-
}).fetchOne(3, {
|
|
177
|
-
$select: ["derivedPropertyName"]
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
test("multiple properties", async () => {
|
|
181
|
-
const withFamily = fauxObjectSet.withProperties({
|
|
182
|
-
"mom": base => base.pivotTo("lead").aggregate("$count"),
|
|
183
|
-
"dad": base => base.pivotTo("lead").selectProperty("fullName"),
|
|
184
|
-
"sister": base => base.pivotTo("lead").aggregate("class:collectList")
|
|
185
|
-
});
|
|
186
|
-
expectTypeOf(withFamily).toEqualTypeOf();
|
|
187
|
-
await withFamily.fetchPage();
|
|
188
|
-
expectTypeOf().toEqualTypeOf();
|
|
189
|
-
expectTypeOf().toEqualTypeOf();
|
|
190
|
-
expectTypeOf().toEqualTypeOf();
|
|
191
|
-
expectTypeOf().toEqualTypeOf();
|
|
192
|
-
});
|
|
193
|
-
describe("called in succession", () => {
|
|
194
|
-
test("independently", () => {
|
|
195
|
-
const withMom = fauxObjectSet.withProperties({
|
|
196
|
-
"mom": base => base.pivotTo("lead").aggregate("$count")
|
|
197
|
-
});
|
|
198
|
-
const withParents = withMom.withProperties({
|
|
199
|
-
"dad": base => base.pivotTo("lead").selectProperty("fullName")
|
|
200
|
-
});
|
|
201
|
-
expectTypeOf(withParents).toEqualTypeOf();
|
|
202
|
-
});
|
|
203
|
-
test.todo("with calculated properties");
|
|
204
|
-
});
|
|
205
|
-
describe("nullability", () => {
|
|
206
|
-
it("count, exactDistinct, and approximateDistinct aren't nullable", async () => {
|
|
207
|
-
const withFamily = fauxObjectSet.withProperties({
|
|
208
|
-
"mom": base => base.pivotTo("lead").aggregate("$count"),
|
|
209
|
-
"dad": base => base.pivotTo("lead").aggregate("class:exactDistinct"),
|
|
210
|
-
"sis": base => base.pivotTo("lead").aggregate("class:approximateDistinct")
|
|
211
|
-
});
|
|
212
|
-
await withFamily.fetchPage();
|
|
213
|
-
expectTypeOf().toEqualTypeOf();
|
|
214
|
-
});
|
|
215
|
-
it("collectSet, collectList, selectProperty, and numeric aggregations are nullable", async () => {
|
|
216
|
-
const withAggregations = fauxObjectSet.withProperties({
|
|
217
|
-
"collectSet": base => base.pivotTo("lead").aggregate("class:collectSet"),
|
|
218
|
-
"select": base => base.pivotTo("lead").selectProperty("fullName"),
|
|
219
|
-
"collectList": base => base.pivotTo("lead").aggregate("class:collectList"),
|
|
220
|
-
"min": base => base.pivotTo("lead").aggregate("employeeId:max"),
|
|
221
|
-
"max": base => base.pivotTo("lead").aggregate("employeeId:min"),
|
|
222
|
-
"sum": base => base.pivotTo("lead").aggregate("employeeId:sum"),
|
|
223
|
-
"avg": base => base.pivotTo("lead").aggregate("employeeId:avg"),
|
|
224
|
-
"approximatePercentile": base => base.pivotTo("lead").aggregate("employeeId:approximatePercentile")
|
|
225
|
-
});
|
|
226
|
-
await withAggregations.fetchPage();
|
|
227
|
-
expectTypeOf().toEqualTypeOf();
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
describe("fetch functions return correct Osdk.Instance", () => {
|
|
231
|
-
const withFamily = fauxObjectSet.withProperties({
|
|
232
|
-
"mom": base => base.pivotTo("lead").aggregate("$count"),
|
|
233
|
-
"dad": base => base.pivotTo("lead").selectProperty("fullName"),
|
|
234
|
-
"sister": base => base.pivotTo("lead").aggregate("class:collectList")
|
|
235
|
-
});
|
|
236
|
-
it("works with .where", async () => {
|
|
237
|
-
const where = withFamily.where({
|
|
238
|
-
"mom": 1
|
|
239
|
-
});
|
|
240
|
-
const whereResults = await where.fetchPage();
|
|
241
|
-
|
|
242
|
-
// Checks that if you did an `await where.fetchPage()` that you can then
|
|
243
|
-
// pass/assign it to something explicit.
|
|
244
|
-
// Checks that if you did an `await where.fetchPage()` that you can then
|
|
245
|
-
// pass/assign it to something explicit.
|
|
246
|
-
whereResults.data[0];
|
|
247
|
-
whereResults.data[0].$link.peeps.$objectSetInternals.def; // same as above but with expectTypeOf
|
|
248
|
-
expectTypeOf().toEqualTypeOf();
|
|
249
|
-
expectTypeOf().toEqualTypeOf();
|
|
250
|
-
|
|
251
|
-
// Checks that when you directly assign, it infers correctly.
|
|
252
|
-
// Sometimes an explicit assignment can affect how typescript infers
|
|
253
|
-
// types.
|
|
254
|
-
await where.fetchPage();
|
|
255
|
-
await withFamily.fetchOne(1);
|
|
256
|
-
await withFamily.fetchOne(1);
|
|
257
|
-
});
|
|
258
|
-
it("works with .async", () => {
|
|
259
|
-
withFamily.asyncIter();
|
|
260
|
-
expectTypeOf().toEqualTypeOf();
|
|
261
|
-
});
|
|
262
|
-
it("Works with no select", async () => {
|
|
263
|
-
await withFamily.fetchPage();
|
|
264
|
-
expectTypeOf().toEqualTypeOf();
|
|
265
|
-
});
|
|
266
|
-
it("Works with selecting all RDPs", async () => {
|
|
267
|
-
await withFamily.fetchPage({
|
|
268
|
-
$select: ["mom", "dad", "sister"]
|
|
269
|
-
});
|
|
270
|
-
expectTypeOf().toEqualTypeOf();
|
|
271
|
-
expectTypeOf().toEqualTypeOf();
|
|
272
|
-
});
|
|
273
|
-
it("Works with selecting some RDPs", async () => {
|
|
274
|
-
await withFamily.fetchPage({
|
|
275
|
-
$select: ["mom"]
|
|
276
|
-
});
|
|
277
|
-
expectTypeOf().toEqualTypeOf();
|
|
278
|
-
});
|
|
279
|
-
it("Works with selecting all non-RDP's", async () => {
|
|
280
|
-
await withFamily.fetchPage({
|
|
281
|
-
$select: ["employeeId", "fullName", "class", "attachment", "geopoint", "timeseries", "mediaReference", "geotimeSeriesReference", "isActive", "yearsOfExperience", "rank", "performanceScore", "hourlyRate", "dateOfJoining", "lastUpdated", "skillSet", "skillSetEmbedding"]
|
|
282
|
-
});
|
|
283
|
-
expectTypeOf().toEqualTypeOf();
|
|
284
|
-
expectTypeOf().toEqualTypeOf();
|
|
285
|
-
});
|
|
286
|
-
it("Works with selecting some non-RDP's", async () => {
|
|
287
|
-
await withFamily.fetchPage({
|
|
288
|
-
$select: ["class"]
|
|
289
|
-
});
|
|
290
|
-
expectTypeOf().toEqualTypeOf();
|
|
291
|
-
});
|
|
292
|
-
it("Works with selecting a mix", async () => {
|
|
293
|
-
await withFamily.fetchPage({
|
|
294
|
-
$select: ["class", "mom"]
|
|
295
|
-
});
|
|
296
|
-
expectTypeOf().toEqualTypeOf();
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
it("allows extracting the type", () => {
|
|
300
|
-
fauxObjectSet.withProperties({
|
|
301
|
-
"mom": base => base.pivotTo("lead").aggregate("$count")
|
|
302
|
-
});
|
|
303
|
-
expectTypeOf().toEqualTypeOf();
|
|
304
|
-
fauxObjectSet.withProperties({
|
|
305
|
-
"mom": base => base.pivotTo("lead").aggregate("$count")
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
it("Defining the Type", () => {
|
|
309
|
-
fauxObjectSet.withProperties({
|
|
310
|
-
"mom": base => base.pivotTo("lead").aggregate("$count")
|
|
311
|
-
});
|
|
312
|
-
});
|
|
313
|
-
it("has correct aggregation keys", () => {
|
|
314
|
-
fauxObjectSet.withProperties({
|
|
315
|
-
"integer": base => base.pivotTo("lead").aggregate("$count"),
|
|
316
|
-
"integerNumericAgg": base => base.pivotTo("lead").aggregate("employeeId:sum"),
|
|
317
|
-
"string": base => base.pivotTo("lead").aggregate("class:collectList"),
|
|
318
|
-
"stringDoesNotHaveNumericAgg": base =>
|
|
319
|
-
// @ts-expect-error
|
|
320
|
-
base.pivotTo("lead").aggregate("class:sum"),
|
|
321
|
-
"isActive": base => base.pivotTo("lead").aggregate("isActive:approximateDistinct"),
|
|
322
|
-
"attachment": base => base.pivotTo("lead").aggregate("attachment:collectList"),
|
|
323
|
-
"geopoint": base => base.pivotTo("lead").aggregate("geopoint:collectList"),
|
|
324
|
-
"numericTimeseries": base =>
|
|
325
|
-
// @ts-expect-error
|
|
326
|
-
base.pivotTo("lead").aggregate("timeseries:sum"),
|
|
327
|
-
"numericTimeseriesExactDistinct": base => base.pivotTo("lead").aggregate("timeseries:exactDistinct"),
|
|
328
|
-
"mediaReference": base =>
|
|
329
|
-
// @ts-expect-error
|
|
330
|
-
base.pivotTo("lead").aggregate("mediaReference:avg"),
|
|
331
|
-
"mediaReferenceExactDistinct": base => base.pivotTo("lead").aggregate("mediaReference:exactDistinct"),
|
|
332
|
-
"geotimeSeriesReference": base =>
|
|
333
|
-
// @ts-expect-error
|
|
334
|
-
base.pivotTo("lead").aggregate("geotimeSeriesReference:sum"),
|
|
335
|
-
"geotimeSeriesReferenceExactDistinct": base => base.pivotTo("lead").aggregate("geotimeSeriesReference:exactDistinct"),
|
|
336
|
-
"lastUpdated": base => {
|
|
337
|
-
base.pivotTo("lead").aggregate("lastUpdated:approximateDistinct");
|
|
338
|
-
base.pivotTo("lead").aggregate("lastUpdated:exactDistinct");
|
|
339
|
-
base.pivotTo("lead").aggregate("lastUpdated:max");
|
|
340
|
-
base.pivotTo("lead").aggregate("lastUpdated:min");
|
|
341
|
-
base.pivotTo("lead").aggregate("lastUpdated:collectList");
|
|
342
|
-
return base.pivotTo("lead").aggregate("lastUpdated:collectSet");
|
|
343
|
-
},
|
|
344
|
-
"dateOfJoining": base => {
|
|
345
|
-
base.pivotTo("lead").aggregate("dateOfJoining:approximateDistinct");
|
|
346
|
-
base.pivotTo("lead").aggregate("dateOfJoining:exactDistinct");
|
|
347
|
-
base.pivotTo("lead").aggregate("dateOfJoining:max");
|
|
348
|
-
base.pivotTo("lead").aggregate("dateOfJoining:min");
|
|
349
|
-
base.pivotTo("lead").aggregate("dateOfJoining:collectList");
|
|
350
|
-
return base.pivotTo("lead").aggregate("dateOfJoining:collectSet");
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
it("has correct aggregation return types", async () => {
|
|
355
|
-
const aggTestObjectSet = fauxObjectSet.withProperties({
|
|
356
|
-
"maxHasSameType": base => base.pivotTo("lead").aggregate("dateOfJoining:max"),
|
|
357
|
-
"minHasSameType": base => base.pivotTo("lead").aggregate("dateOfJoining:min"),
|
|
358
|
-
"approximateDistinctNumberNoUndefined": base => base.pivotTo("lead").aggregate("employeeId:approximateDistinct"),
|
|
359
|
-
"exactDistinctNumberNoUndefined": base => base.pivotTo("lead").aggregate("employeeId:exactDistinct"),
|
|
360
|
-
"countNumberNoUndefined": base => base.pivotTo("lead").aggregate("$count"),
|
|
361
|
-
"sumNumber": base => base.pivotTo("lead").aggregate("employeeId:sum"),
|
|
362
|
-
"avgNumber": base => base.pivotTo("lead").aggregate("employeeId:avg")
|
|
363
|
-
}).fetchPage();
|
|
364
|
-
const result = (await aggTestObjectSet).data[0];
|
|
365
|
-
expectTypeOf((await aggTestObjectSet).data[0]).toEqualTypeOf();
|
|
366
|
-
expectTypeOf(result.maxHasSameType).toEqualTypeOf();
|
|
367
|
-
expectTypeOf(result.minHasSameType).toEqualTypeOf();
|
|
368
|
-
expectTypeOf(result.approximateDistinctNumberNoUndefined).toEqualTypeOf();
|
|
369
|
-
expectTypeOf(result.exactDistinctNumberNoUndefined).toEqualTypeOf();
|
|
370
|
-
expectTypeOf(result.countNumberNoUndefined).toEqualTypeOf();
|
|
371
|
-
expectTypeOf(result.sumNumber).toEqualTypeOf();
|
|
372
|
-
expectTypeOf(result.avgNumber).toEqualTypeOf();
|
|
373
|
-
});
|
|
374
|
-
it("Merged object type is equivalent to original", () => {
|
|
375
|
-
// should be assignable. testing explicitly due to break in 2.2 release.
|
|
376
|
-
|
|
377
|
-
expectTypeOf().branded.toEqualTypeOf();
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
describe("aggregate", () => {
|
|
381
|
-
it("has correct aggregation keys", () => {
|
|
382
|
-
void fauxObjectSet.aggregate({
|
|
383
|
-
"$select": {
|
|
384
|
-
"lastUpdated:max": "asc",
|
|
385
|
-
"lastUpdated:min": "desc",
|
|
386
|
-
"lastUpdated:approximateDistinct": "asc",
|
|
387
|
-
"lastUpdated:exactDistinct": "desc",
|
|
388
|
-
"dateOfJoining:max": "desc",
|
|
389
|
-
"dateOfJoining:min": "asc",
|
|
390
|
-
"dateOfJoining:approximateDistinct": "asc",
|
|
391
|
-
"dateOfJoining:exactDistinct": "desc"
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
describe("expressions", () => {
|
|
397
|
-
"Test all property types";
|
|
398
|
-
|
|
399
|
-
describe("numeric expressions", () => {
|
|
400
|
-
it("provides correct methods off of selected numeric derived property definitions", () => {
|
|
401
|
-
fauxObjectSet.withProperties({
|
|
402
|
-
"myProp1": base => {
|
|
403
|
-
const selectedInteger = base.pivotTo("lead").selectProperty("employeeId");
|
|
404
|
-
expectTypeOf(selectedInteger).toEqualTypeOf;
|
|
405
|
-
selectedInteger.add(1);
|
|
406
|
-
selectedInteger.subtract(1);
|
|
407
|
-
selectedInteger.multiply(1);
|
|
408
|
-
selectedInteger.divide(1);
|
|
409
|
-
selectedInteger.abs();
|
|
410
|
-
selectedInteger.negate();
|
|
411
|
-
selectedInteger.max(1);
|
|
412
|
-
selectedInteger.min(1);
|
|
413
|
-
|
|
414
|
-
// @ts-expect-error
|
|
415
|
-
selectedInteger.extractPart("1");
|
|
416
|
-
expectTypeOf(base.pivotTo("lead").selectProperty("performanceScore")).toEqualTypeOf();
|
|
417
|
-
expectTypeOf(base.pivotTo("lead").selectProperty("rank")).toEqualTypeOf();
|
|
418
|
-
expectTypeOf(base.pivotTo("lead").selectProperty("yearsOfExperience")).toEqualTypeOf();
|
|
419
|
-
expectTypeOf(base.pivotTo("lead").selectProperty("hourlyRate")).toEqualTypeOf();
|
|
420
|
-
return selectedInteger;
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
});
|
|
424
|
-
it("provides correct methods off of selection definitions", () => {
|
|
425
|
-
fauxObjectSet.withProperties({
|
|
426
|
-
"myProp1": base => {
|
|
427
|
-
const selectedInteger = base.pivotTo("lead").selectProperty("employeeId");
|
|
428
|
-
expectTypeOf(selectedInteger).toEqualTypeOf;
|
|
429
|
-
selectedInteger.add(1);
|
|
430
|
-
selectedInteger.subtract(1);
|
|
431
|
-
selectedInteger.multiply(1);
|
|
432
|
-
selectedInteger.divide(1);
|
|
433
|
-
selectedInteger.abs();
|
|
434
|
-
selectedInteger.negate();
|
|
435
|
-
selectedInteger.max(1);
|
|
436
|
-
selectedInteger.min(1);
|
|
437
|
-
|
|
438
|
-
// @ts-expect-error
|
|
439
|
-
selectedInteger.extractPart("1");
|
|
440
|
-
expectTypeOf(base.pivotTo("lead").selectProperty("performanceScore")).toEqualTypeOf();
|
|
441
|
-
expectTypeOf(base.pivotTo("lead").selectProperty("rank")).toEqualTypeOf();
|
|
442
|
-
expectTypeOf(base.pivotTo("lead").selectProperty("yearsOfExperience")).toEqualTypeOf();
|
|
443
|
-
expectTypeOf(base.pivotTo("lead").selectProperty("hourlyRate")).toEqualTypeOf();
|
|
444
|
-
return selectedInteger;
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
it("provides correct methods off of aggregated properties", () => {
|
|
449
|
-
fauxObjectSet.withProperties({
|
|
450
|
-
"myProp1": base => {
|
|
451
|
-
const maxAggregation = base.pivotTo("lead").aggregate("employeeId:max");
|
|
452
|
-
expectTypeOf(maxAggregation).toEqualTypeOf;
|
|
453
|
-
maxAggregation.add(1);
|
|
454
|
-
maxAggregation.subtract(1);
|
|
455
|
-
maxAggregation.multiply(1);
|
|
456
|
-
maxAggregation.divide(1);
|
|
457
|
-
maxAggregation.abs();
|
|
458
|
-
maxAggregation.negate();
|
|
459
|
-
maxAggregation.max(1);
|
|
460
|
-
maxAggregation.min(1);
|
|
461
|
-
expectTypeOf(base.pivotTo("peeps").aggregate("employeeId:sum")).toEqualTypeOf();
|
|
462
|
-
expectTypeOf(base.pivotTo("peeps").aggregate("employeeId:avg")).toEqualTypeOf();
|
|
463
|
-
expectTypeOf(base.pivotTo("peeps").aggregate("employeeId:min")).toEqualTypeOf();
|
|
464
|
-
const collectList = base.pivotTo("peeps").aggregate("employeeId:collectList");
|
|
465
|
-
expectTypeOf(collectList).toEqualTypeOf();
|
|
466
|
-
|
|
467
|
-
// @ts-expect-error
|
|
468
|
-
collectList.plus(1);
|
|
469
|
-
expectTypeOf(base.pivotTo("peeps").aggregate("employeeId:collectList")).toEqualTypeOf();
|
|
470
|
-
return maxAggregation;
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
it("correctly coerces numeric types", () => {
|
|
475
|
-
fauxObjectSet.withProperties({
|
|
476
|
-
"myProp1": base => {
|
|
477
|
-
const intAndLong = base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("yearsOfExperience")).add(base.selectProperty("employeeId"));
|
|
478
|
-
expectTypeOf(intAndLong).toEqualTypeOf();
|
|
479
|
-
const intAndDouble = base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("performanceScore")).add(base.selectProperty("employeeId"));
|
|
480
|
-
expectTypeOf(intAndDouble).toEqualTypeOf();
|
|
481
|
-
const longAndDouble = base.pivotTo("lead").selectProperty("yearsOfExperience").add(base.selectProperty("performanceScore")).add(base.selectProperty("yearsOfExperience"));
|
|
482
|
-
expectTypeOf(longAndDouble).toEqualTypeOf();
|
|
483
|
-
const longAndLong = base.pivotTo("lead").selectProperty("yearsOfExperience").add(base.selectProperty("yearsOfExperience"));
|
|
484
|
-
expectTypeOf(longAndLong).toEqualTypeOf();
|
|
485
|
-
const intAndInt = base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("employeeId"));
|
|
486
|
-
expectTypeOf(intAndInt).toEqualTypeOf();
|
|
487
|
-
const intLongDoubleChain = base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("yearsOfExperience")).add(base.selectProperty("employeeId")).add(base.selectProperty("performanceScore")).add(base.selectProperty("employeeId"));
|
|
488
|
-
expectTypeOf(intLongDoubleChain).toEqualTypeOf();
|
|
489
|
-
const shortAndIntReturnsInt = base.pivotTo("lead").selectProperty("rank").add(base.selectProperty("employeeId"));
|
|
490
|
-
expectTypeOf(shortAndIntReturnsInt).toEqualTypeOf();
|
|
491
|
-
const shortAndFloatReturnsDouble = base.pivotTo("lead").selectProperty("rank").add(base.selectProperty("hourlyRate"));
|
|
492
|
-
expectTypeOf(shortAndFloatReturnsDouble).toEqualTypeOf();
|
|
493
|
-
return intLongDoubleChain;
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
});
|
|
497
|
-
it("allows adding number literals as a double", () => {
|
|
498
|
-
fauxObjectSet.withProperties({
|
|
499
|
-
"myProp1": base => {
|
|
500
|
-
const plus = base.pivotTo("lead").selectProperty("employeeId").add(1);
|
|
501
|
-
expectTypeOf(plus).toEqualTypeOf();
|
|
502
|
-
return plus;
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
it("allows adding literals via base.constant", () => {
|
|
507
|
-
fauxObjectSet.withProperties({
|
|
508
|
-
"myProp1": base => {
|
|
509
|
-
const plus = base.pivotTo("lead").selectProperty("employeeId").add(base.constant.double(1));
|
|
510
|
-
expectTypeOf(plus).toEqualTypeOf();
|
|
511
|
-
const intPlusIntReturnsInt = base.pivotTo("lead").selectProperty("employeeId").add(base.constant.integer(1));
|
|
512
|
-
expectTypeOf(intPlusIntReturnsInt).toEqualTypeOf();
|
|
513
|
-
return plus;
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
});
|
|
517
|
-
it("allows correctly typed nested property definitions", () => {
|
|
518
|
-
fauxObjectSet.withProperties({
|
|
519
|
-
"myProp1": base => {
|
|
520
|
-
const nested = base.pivotTo("lead").selectProperty("employeeId").add(base.pivotTo("peeps").aggregate("employeeId:sum"));
|
|
521
|
-
expectTypeOf(nested).toEqualTypeOf();
|
|
522
|
-
return nested;
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
});
|
|
526
|
-
it("allows correctly types property keys off the linked OT", () => {
|
|
527
|
-
fauxObjectSet.withProperties({
|
|
528
|
-
"myProp1": base => {
|
|
529
|
-
const nested = base.pivotTo("lead").selectProperty("employeeId").add(base.selectProperty("performanceScore"));
|
|
530
|
-
expectTypeOf(nested).toEqualTypeOf();
|
|
531
|
-
return nested;
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
// it("allows correctly types property keys off the base OT", () => {});
|
|
537
|
-
});
|
|
538
|
-
describe("datetime expressions", () => {
|
|
539
|
-
it("provides correct methods off of datetime selections", () => {
|
|
540
|
-
fauxObjectSet.withProperties({
|
|
541
|
-
"myProp1": base => {
|
|
542
|
-
const selectedDatetime = base.pivotTo("lead").selectProperty("dateOfJoining");
|
|
543
|
-
expectTypeOf(selectedDatetime).toEqualTypeOf();
|
|
544
|
-
selectedDatetime.max(base.selectProperty("dateOfJoining"));
|
|
545
|
-
selectedDatetime.min(base.selectProperty("lastUpdated"));
|
|
546
|
-
expectTypeOf(base.pivotTo("lead").selectProperty("lastUpdated")).toEqualTypeOf();
|
|
547
|
-
return selectedDatetime;
|
|
548
|
-
}
|
|
549
|
-
});
|
|
550
|
-
});
|
|
551
|
-
it("correctly coerces datetime types", () => {
|
|
552
|
-
fauxObjectSet.withProperties({
|
|
553
|
-
"myProp1": base => {
|
|
554
|
-
const max = base.pivotTo("lead").selectProperty("dateOfJoining").max(base.selectProperty("lastUpdated"));
|
|
555
|
-
expectTypeOf(max).toEqualTypeOf();
|
|
556
|
-
const min = base.pivotTo("lead").selectProperty("dateOfJoining").min(base.selectProperty("dateOfJoining"));
|
|
557
|
-
expectTypeOf(min).toEqualTypeOf();
|
|
558
|
-
return max;
|
|
559
|
-
}
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
|
-
it("allows adding literals via base.constant", () => {
|
|
563
|
-
fauxObjectSet.withProperties({
|
|
564
|
-
"myProp1": base => {
|
|
565
|
-
const dateAndDateReturnDate = base.pivotTo("lead").selectProperty("dateOfJoining").min(base.constant.datetime("2025-01-01T00:00:00Z"));
|
|
566
|
-
expectTypeOf(dateAndDateReturnDate).toEqualTypeOf();
|
|
567
|
-
const dateAndTimeReturnTime = base.pivotTo("lead").selectProperty("dateOfJoining").min(base.constant.timestamp("2025-01-01T00:00:00Z"));
|
|
568
|
-
expectTypeOf(dateAndTimeReturnTime).toEqualTypeOf();
|
|
569
|
-
return dateAndTimeReturnTime;
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
});
|
|
573
|
-
it("allows correctly typed nested property definitions", () => {
|
|
574
|
-
fauxObjectSet.withProperties({
|
|
575
|
-
"myProp1": base => {
|
|
576
|
-
const nested = base.pivotTo("lead").selectProperty("dateOfJoining").min(base.pivotTo("lead").pivotTo("lead").selectProperty("lastUpdated"));
|
|
577
|
-
expectTypeOf(nested).toEqualTypeOf();
|
|
578
|
-
return nested;
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
});
|
|
582
|
-
it("allows correctly typed property keys off the linked OT", () => {
|
|
583
|
-
fauxObjectSet.withProperties({
|
|
584
|
-
"myProp1": base => {
|
|
585
|
-
const nested = base.pivotTo("lead").selectProperty("dateOfJoining").min(base.selectProperty("lastUpdated"));
|
|
586
|
-
expectTypeOf(nested).toEqualTypeOf();
|
|
587
|
-
return nested;
|
|
588
|
-
}
|
|
589
|
-
});
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
// it("allows correctly typed property keys off the base OT", () => {});
|
|
593
|
-
});
|
|
594
|
-
});
|
|
595
|
-
describe("nearestNeighbors", () => {
|
|
596
|
-
it("has correct nearest neighbors object set query return type", () => {
|
|
597
|
-
const nearestNeighborsObjectSet = fauxObjectSet.nearestNeighbors("textQuery", 3, "skillSetEmbedding");
|
|
598
|
-
expectTypeOf(nearestNeighborsObjectSet).toEqualTypeOf();
|
|
599
|
-
});
|
|
600
|
-
it("allows text queries", async () => {
|
|
601
|
-
const nearestNeighborsObjectSet = fauxObjectSet.nearestNeighbors("textQuery", 3, "skillSetEmbedding");
|
|
602
|
-
const {
|
|
603
|
-
data: employees
|
|
604
|
-
} = await nearestNeighborsObjectSet.fetchPage();
|
|
605
|
-
expectTypeOf(employees).toEqualTypeOf();
|
|
606
|
-
});
|
|
607
|
-
it("allows vector queries", async () => {
|
|
608
|
-
const vectorQuery = Array.from({
|
|
609
|
-
length: 1536
|
|
610
|
-
}, () => 0.3);
|
|
611
|
-
const nearestNeighborsObjectSet = fauxObjectSet.nearestNeighbors(vectorQuery, 3, "skillSetEmbedding");
|
|
612
|
-
const {
|
|
613
|
-
data: employees
|
|
614
|
-
} = await nearestNeighborsObjectSet.fetchPage();
|
|
615
|
-
expectTypeOf(employees).toEqualTypeOf();
|
|
616
|
-
});
|
|
617
|
-
it("only supports queries on vector properties", () => {
|
|
618
|
-
fauxObjectSet.nearestNeighbors("textQuery", 3,
|
|
619
|
-
// @ts-expect-error
|
|
620
|
-
"skillSet");
|
|
621
|
-
});
|
|
622
|
-
it("appropriately types fetchPage ordered by relevance", async () => {
|
|
623
|
-
const nearestNeighborsObjectSet = await fauxObjectSet.nearestNeighbors("textQuery", 3, "skillSetEmbedding").fetchPage({
|
|
624
|
-
$orderBy: "relevance"
|
|
625
|
-
});
|
|
626
|
-
expectTypeOf(nearestNeighborsObjectSet.data[0]).toEqualTypeOf();
|
|
627
|
-
});
|
|
628
|
-
it("appropriately types fetchPageWithErrors ordered by relevance", async () => {
|
|
629
|
-
const nearestNeighborsObjectSetWithErrors = await fauxObjectSet.nearestNeighbors("textQuery", 3, "skillSetEmbedding").fetchPageWithErrors({
|
|
630
|
-
$orderBy: "relevance"
|
|
631
|
-
});
|
|
632
|
-
expectTypeOf(nearestNeighborsObjectSetWithErrors.value.data[0]).toEqualTypeOf();
|
|
633
|
-
});
|
|
634
|
-
it("appropriately types asyncIters ordered by relevance", () => {
|
|
635
|
-
const asyncIter = fauxObjectSet.nearestNeighbors("textQuery", 3, "skillSetEmbedding").asyncIter({
|
|
636
|
-
$orderBy: "relevance"
|
|
637
|
-
});
|
|
638
|
-
expectTypeOf(asyncIter).toEqualTypeOf();
|
|
639
|
-
});
|
|
640
|
-
it("no arbitrary order bys", () => {
|
|
641
|
-
const knn = fauxObjectSet.nearestNeighbors("textQuery", 3, "skillSetEmbedding");
|
|
642
|
-
|
|
643
|
-
// @ts-expect-error
|
|
644
|
-
void knn.fetchPage({
|
|
645
|
-
$orderBy: "invalid"
|
|
646
|
-
});
|
|
647
|
-
// @ts-expect-error
|
|
648
|
-
void knn.fetchPageWithErrors({
|
|
649
|
-
$orderBy: "invalid"
|
|
650
|
-
});
|
|
651
|
-
// @ts-expect-error
|
|
652
|
-
void knn.asyncIter({
|
|
653
|
-
$orderBy: "random"
|
|
654
|
-
});
|
|
655
|
-
});
|
|
656
|
-
it("does not include score for property order by", async () => {
|
|
657
|
-
const nearestNeighborsObjectSet = await fauxObjectSet.nearestNeighbors("textQuery", 3, "skillSetEmbedding").fetchPage({
|
|
658
|
-
$orderBy: {
|
|
659
|
-
"fullName": "desc"
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
expectTypeOf(nearestNeighborsObjectSet.data[0]).not.toHaveProperty("$score");
|
|
663
|
-
const nearestNeighborsObjectSetWithErrors = await fauxObjectSet.nearestNeighbors("textQuery", 3, "skillSetEmbedding").fetchPageWithErrors({
|
|
664
|
-
$orderBy: {
|
|
665
|
-
"fullName": "desc"
|
|
666
|
-
}
|
|
667
|
-
});
|
|
668
|
-
expectTypeOf(nearestNeighborsObjectSetWithErrors.value?.data[0]).not.toHaveProperty("$score");
|
|
669
|
-
});
|
|
670
|
-
});
|
|
671
|
-
describe("narrowToType", () => {
|
|
672
|
-
it("restricts casting from interface to object type", () => {
|
|
673
|
-
const objectSet = {
|
|
674
|
-
narrowToType: () => {}
|
|
675
|
-
};
|
|
676
|
-
objectSet.narrowToType(EmployeeApiTest);
|
|
677
|
-
objectSet.narrowToType(FooInterfaceApiTest);
|
|
678
|
-
objectSet.narrowToType({
|
|
679
|
-
type: "interface",
|
|
680
|
-
apiName: "AnyInterface :)"
|
|
681
|
-
});
|
|
682
|
-
|
|
683
|
-
// @ts-expect-error
|
|
684
|
-
objectSet.narrowToType({
|
|
685
|
-
type: "object",
|
|
686
|
-
apiName: "NotImplemented"
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
// Interfaces that don't have any implementedBy fields should still accept any interface
|
|
690
|
-
|
|
691
|
-
({
|
|
692
|
-
narrowToType: () => {}
|
|
693
|
-
}).narrowToType({
|
|
694
|
-
type: "interface",
|
|
695
|
-
apiName: "NotImplemented"
|
|
696
|
-
});
|
|
697
|
-
});
|
|
698
|
-
it("restricts casting from object type to interface", () => {
|
|
699
|
-
expectTypeOf().toEqualTypeOf();
|
|
700
|
-
expectTypeOf().toEqualTypeOf();
|
|
701
|
-
});
|
|
702
|
-
});
|
|
703
|
-
describe("asyncIterLinks", async () => {
|
|
704
|
-
it("typechecks self-referential one link", async () => {
|
|
705
|
-
for await (const {
|
|
706
|
-
source,
|
|
707
|
-
target,
|
|
708
|
-
linkType
|
|
709
|
-
} of fauxObjectSet.experimental_asyncIterLinks(["lead"])) {
|
|
710
|
-
expectTypeOf(source).toEqualTypeOf();
|
|
711
|
-
expectTypeOf(target).toEqualTypeOf();
|
|
712
|
-
expectTypeOf(source.$apiName).toBeString();
|
|
713
|
-
expectTypeOf(target.$apiName).toBeString();
|
|
714
|
-
expectTypeOf(source.$primaryKey).toBeNumber();
|
|
715
|
-
expectTypeOf(target.$primaryKey).toBeNumber();
|
|
716
|
-
expectTypeOf(linkType).toEqualTypeOf();
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
it("typechecks self-referential multiple links", async () => {
|
|
720
|
-
for await (const {
|
|
721
|
-
source,
|
|
722
|
-
target,
|
|
723
|
-
linkType
|
|
724
|
-
} of fauxObjectSet.experimental_asyncIterLinks(["lead", "peeps"])) {
|
|
725
|
-
expectTypeOf(source).toEqualTypeOf();
|
|
726
|
-
expectTypeOf(target).toEqualTypeOf();
|
|
727
|
-
expectTypeOf(source.$apiName).toBeString();
|
|
728
|
-
expectTypeOf(target.$apiName).toBeString();
|
|
729
|
-
expectTypeOf(source.$primaryKey).toBeNumber();
|
|
730
|
-
expectTypeOf(target.$primaryKey).toBeNumber();
|
|
731
|
-
expectTypeOf(linkType).toEqualTypeOf();
|
|
732
|
-
}
|
|
733
|
-
});
|
|
734
|
-
});
|
|
735
|
-
});
|
|
736
|
-
//# sourceMappingURL=ObjectSet.test.js.map
|