@osdk/maker-experimental 0.6.0-beta.3 → 0.6.0-beta.5
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 +31 -0
- package/build/browser/api/defineOntologyV2.js +9 -3
- package/build/browser/api/defineOntologyV2.js.map +1 -1
- package/build/browser/cli/generateBackingDataset.js +250 -0
- package/build/browser/cli/generateBackingDataset.js.map +1 -0
- package/build/browser/cli/main.js +60 -7
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/cli/marketplaceSerialization/BlockGeneratorResult.js.map +1 -1
- package/build/browser/util/generateRid.js +10 -4
- package/build/browser/util/generateRid.js.map +1 -1
- package/build/cjs/{ActionTypeShapeExtractor-5IVLHAPH.cjs → ActionTypeShapeExtractor-UWC4CVHX.cjs} +4 -4
- package/build/cjs/{ActionTypeShapeExtractor-5IVLHAPH.cjs.map → ActionTypeShapeExtractor-UWC4CVHX.cjs.map} +1 -1
- package/build/cjs/{chunk-AWYOBJ25.cjs → chunk-JC573VYW.cjs} +13 -6
- package/build/cjs/chunk-JC573VYW.cjs.map +1 -0
- package/build/cjs/index.cjs +270 -38
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +6 -1
- package/build/esm/api/defineOntologyV2.js +9 -3
- package/build/esm/api/defineOntologyV2.js.map +1 -1
- package/build/esm/cli/generateBackingDataset.js +250 -0
- package/build/esm/cli/generateBackingDataset.js.map +1 -0
- package/build/esm/cli/main.js +60 -7
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/cli/marketplaceSerialization/BlockGeneratorResult.js.map +1 -1
- package/build/esm/util/generateRid.js +10 -4
- package/build/esm/util/generateRid.js.map +1 -1
- package/build/types/api/defineOntologyV2.d.ts +6 -1
- package/build/types/api/defineOntologyV2.d.ts.map +1 -1
- package/build/types/cli/generateBackingDataset.d.ts +16 -0
- package/build/types/cli/generateBackingDataset.d.ts.map +1 -0
- package/build/types/cli/main.d.ts.map +1 -1
- package/build/types/cli/marketplaceSerialization/BlockGeneratorResult.d.ts +2 -2
- package/build/types/cli/marketplaceSerialization/BlockGeneratorResult.d.ts.map +1 -1
- package/build/types/util/generateRid.d.ts +4 -2
- package/build/types/util/generateRid.d.ts.map +1 -1
- package/package.json +6 -6
- package/build/browser/api/overall.test.js +0 -713
- package/build/browser/api/overall.test.js.map +0 -1
- package/build/browser/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js +0 -562
- package/build/browser/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js.map +0 -1
- package/build/browser/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js +0 -677
- package/build/browser/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js.map +0 -1
- package/build/cjs/chunk-AWYOBJ25.cjs.map +0 -1
- package/build/esm/api/overall.test.js +0 -713
- package/build/esm/api/overall.test.js.map +0 -1
- package/build/esm/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js +0 -562
- package/build/esm/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.js.map +0 -1
- package/build/esm/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js +0 -677
- package/build/esm/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.js.map +0 -1
- package/build/types/api/overall.test.d.ts +0 -1
- package/build/types/api/overall.test.d.ts.map +0 -1
- package/build/types/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.d.ts +0 -1
- package/build/types/conversion/toMarketplace/shapeExtractors/ActionTypeShapeExtractor.test.d.ts.map +0 -1
- package/build/types/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.d.ts +0 -1
- package/build/types/conversion/toMarketplace/shapeExtractors/ObjectTypeShapeExtractor.test.d.ts.map +0 -1
|
@@ -1,677 +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, expect, it } from "vitest";
|
|
18
|
-
import { ObjectTypeShapeExtractor } from "./ObjectTypeShapeExtractor.js";
|
|
19
|
-
|
|
20
|
-
// Mock BiMap implementation for testing
|
|
21
|
-
class MockBiMap {
|
|
22
|
-
constructor(entries) {
|
|
23
|
-
this.forward = new Map(entries);
|
|
24
|
-
this.backward = new Map(entries.map(([k, v]) => [v, k]));
|
|
25
|
-
}
|
|
26
|
-
asMap() {
|
|
27
|
-
return this.forward;
|
|
28
|
-
}
|
|
29
|
-
get(key) {
|
|
30
|
-
return this.forward.get(key);
|
|
31
|
-
}
|
|
32
|
-
put(key, value) {
|
|
33
|
-
this.forward.set(key, value);
|
|
34
|
-
this.backward.set(value, key);
|
|
35
|
-
}
|
|
36
|
-
inverse() {
|
|
37
|
-
return new MockBiMap(Array.from(this.backward.entries()));
|
|
38
|
-
}
|
|
39
|
-
entries() {
|
|
40
|
-
return this.forward.entries();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Helper to create a mock OntologyRidGenerator with overrides
|
|
45
|
-
function createMockRidGenerator(overrides = {}) {
|
|
46
|
-
return {
|
|
47
|
-
getActionTypeRids: () => new MockBiMap([]),
|
|
48
|
-
getParameterRidAndIds: () => new Map(),
|
|
49
|
-
getInterfaceRids: () => new MockBiMap([]),
|
|
50
|
-
getSharedPropertyTypeRids: () => new MockBiMap([]),
|
|
51
|
-
getInterfaceLinkTypeRids: () => new MockBiMap([]),
|
|
52
|
-
getInterfacePropertyTypeRids: () => new MockBiMap([]),
|
|
53
|
-
getPropertyTypeRids: () => new MockBiMap([]),
|
|
54
|
-
getDatasourceLocators: () => new MockBiMap([]),
|
|
55
|
-
getFilesDatasourceLocators: () => new MockBiMap([]),
|
|
56
|
-
getGeotimeSeriesIntegrationRids: () => new MockBiMap([]),
|
|
57
|
-
getTimeSeriesSyncs: () => new MockBiMap([]),
|
|
58
|
-
getColumnShapes: () => new MockBiMap([]),
|
|
59
|
-
getObjectTypeRids: () => new MockBiMap([]),
|
|
60
|
-
getLinkTypeRids: () => new MockBiMap([]),
|
|
61
|
-
getGroupIds: () => new MockBiMap([]),
|
|
62
|
-
getConsumedValueTypeReferences: () => new MockBiMap([]),
|
|
63
|
-
getProducedValueTypeReferences: () => new Map(),
|
|
64
|
-
valueTypeMappingForReference: () => ({
|
|
65
|
-
input: "",
|
|
66
|
-
output: ""
|
|
67
|
-
}),
|
|
68
|
-
hashString: input => input,
|
|
69
|
-
generateRid: key => key,
|
|
70
|
-
generateRidForInterface: apiName => `interface.${apiName}`,
|
|
71
|
-
generateRidForInterfaceLinkType: (apiName, interfaceTypeApiName) => `interface-link.${interfaceTypeApiName}.${apiName}`,
|
|
72
|
-
generateRidForObjectType: apiName => `object.${apiName}`,
|
|
73
|
-
generateRidForValueType: (apiName, version) => ({
|
|
74
|
-
rid: `vt.${apiName}.${version}`,
|
|
75
|
-
versionId: version
|
|
76
|
-
}),
|
|
77
|
-
generateRidForTimeSeriesSync: name => `ts.${name}`,
|
|
78
|
-
generateRidForLinkType: linkTypeId => `link.${linkTypeId}`,
|
|
79
|
-
generateRidForGeotimeSeriesIntegration: name => `geotime.${name}`,
|
|
80
|
-
generateRidForActionType: apiName => `action.${apiName}`,
|
|
81
|
-
generateRidForParameter: (actionTypeApiName, parameterId) => `param.${actionTypeApiName}.${parameterId}`,
|
|
82
|
-
generateSptRid: apiName => `spt.${apiName}`,
|
|
83
|
-
generatePropertyRid: (apiName, objectTypeApiName) => `prop.${objectTypeApiName}.${apiName}`,
|
|
84
|
-
generateInterfacePropertyTypeRid: (apiName, interfaceTypeApiName) => `interface-prop.${interfaceTypeApiName}.${apiName}`,
|
|
85
|
-
generateStructFieldRid: (propertyApiName, apiName) => `struct-field.${propertyApiName}.${apiName}`,
|
|
86
|
-
generateLocator: dataSetName => ({
|
|
87
|
-
rid: `dataset.${dataSetName}`,
|
|
88
|
-
branchId: "main"
|
|
89
|
-
}),
|
|
90
|
-
generateStreamLocator: streamName => ({
|
|
91
|
-
streamLocatorRid: `stream.${streamName}`,
|
|
92
|
-
branchId: "main"
|
|
93
|
-
}),
|
|
94
|
-
generateRestrictedViewLocator: restrictedViewName => ({
|
|
95
|
-
rid: `restricted-view.${restrictedViewName}`
|
|
96
|
-
}),
|
|
97
|
-
generateMediaSetViewLocator: mediaSetViewName => ({
|
|
98
|
-
mediaSetRid: `media-set.${mediaSetViewName}`,
|
|
99
|
-
mediaSetViewRid: `media-set-view.${mediaSetViewName}`,
|
|
100
|
-
mediaSetBranchRid: `media-set-branch.${mediaSetViewName}`
|
|
101
|
-
}),
|
|
102
|
-
toBlockInternalId: readableId => {
|
|
103
|
-
return readableId;
|
|
104
|
-
},
|
|
105
|
-
getObjectTypeIds: () => new MockBiMap([]),
|
|
106
|
-
generateObjectTypeId: objectTypeApiName => objectTypeApiName.replace(/\./g, "-").toLowerCase(),
|
|
107
|
-
generateDatasourceRid: datasourceName => `ri.ontology.main.datasource.${datasourceName}`,
|
|
108
|
-
generateValidationRuleRid: (actionTypeApiName, index) => `validation-rule.${actionTypeApiName}.${index}`,
|
|
109
|
-
generateSectionRid: sectionId => `ri.ontology-metadata.temp.section.${sectionId}`,
|
|
110
|
-
generatePropertySecurityGroupRid: groupName => `ri.ontology-metadata.temp.property-security-group.${groupName}`,
|
|
111
|
-
...overrides
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
describe("ObjectTypeShapeExtractor", () => {
|
|
115
|
-
describe("constructor", () => {
|
|
116
|
-
it("should create extractor without randomness key", () => {
|
|
117
|
-
const extractor = new ObjectTypeShapeExtractor();
|
|
118
|
-
expect(extractor).toBeDefined();
|
|
119
|
-
});
|
|
120
|
-
it("should create extractor with randomness key", () => {
|
|
121
|
-
const extractor = new ObjectTypeShapeExtractor("test-key");
|
|
122
|
-
expect(extractor).toBeDefined();
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
describe("extract", () => {
|
|
126
|
-
it("should extract basic object type with properties", () => {
|
|
127
|
-
const ridGenerator = createMockRidGenerator({
|
|
128
|
-
getPropertyTypeRids: () => new MockBiMap([["employee.id", "ri.ontology.main.property-type.employee.id"], ["employee.name", "ri.ontology.main.property-type.employee.name"]])
|
|
129
|
-
});
|
|
130
|
-
const extractor = new ObjectTypeShapeExtractor();
|
|
131
|
-
const result = extractor.extract("employee", {
|
|
132
|
-
objectType: {
|
|
133
|
-
apiName: "Employee",
|
|
134
|
-
rid: "ri.ontology.main.object-type.employee",
|
|
135
|
-
id: "employee-id",
|
|
136
|
-
displayMetadata: {
|
|
137
|
-
displayName: "Employee",
|
|
138
|
-
description: "An employee in the organization",
|
|
139
|
-
pluralDisplayName: "Employees",
|
|
140
|
-
visibility: "NORMAL",
|
|
141
|
-
icon: {
|
|
142
|
-
type: "blueprint",
|
|
143
|
-
blueprint: {
|
|
144
|
-
locator: "person",
|
|
145
|
-
color: "#2D72D2"
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
primaryKeys: ["ri.ontology.main.property-type.employee.id"],
|
|
150
|
-
propertyTypes: {
|
|
151
|
-
"ri.ontology.main.property-type.employee.id": {
|
|
152
|
-
rid: "ri.ontology.main.property-type.employee.id",
|
|
153
|
-
apiName: "id",
|
|
154
|
-
displayMetadata: {
|
|
155
|
-
displayName: "ID",
|
|
156
|
-
description: "Employee ID",
|
|
157
|
-
visibility: "NORMAL"
|
|
158
|
-
},
|
|
159
|
-
type: {
|
|
160
|
-
type: "string",
|
|
161
|
-
string: {
|
|
162
|
-
isLongText: false,
|
|
163
|
-
supportsExactMatching: true
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
id: "employee-id-pt-id",
|
|
167
|
-
indexedForSearch: true,
|
|
168
|
-
status: {
|
|
169
|
-
type: "active",
|
|
170
|
-
active: {}
|
|
171
|
-
},
|
|
172
|
-
typeClasses: []
|
|
173
|
-
},
|
|
174
|
-
"ri.ontology.main.property-type.employee.name": {
|
|
175
|
-
rid: "ri.ontology.main.property-type.employee.name",
|
|
176
|
-
apiName: "name",
|
|
177
|
-
displayMetadata: {
|
|
178
|
-
displayName: "Name",
|
|
179
|
-
description: "Employee name",
|
|
180
|
-
visibility: "NORMAL"
|
|
181
|
-
},
|
|
182
|
-
type: {
|
|
183
|
-
type: "string",
|
|
184
|
-
string: {
|
|
185
|
-
isLongText: false,
|
|
186
|
-
supportsExactMatching: true
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
id: "employee-name-pt-id",
|
|
190
|
-
indexedForSearch: true,
|
|
191
|
-
status: {
|
|
192
|
-
type: "active",
|
|
193
|
-
active: {}
|
|
194
|
-
},
|
|
195
|
-
typeClasses: []
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
titlePropertyTypeRid: "ri.ontology.main.property-type.employee.name",
|
|
199
|
-
status: {
|
|
200
|
-
type: "active",
|
|
201
|
-
active: {}
|
|
202
|
-
},
|
|
203
|
-
redacted: false,
|
|
204
|
-
implementsInterfaces: [],
|
|
205
|
-
implementsInterfaces2: [],
|
|
206
|
-
allImplementsInterfaces: {},
|
|
207
|
-
traits: {
|
|
208
|
-
workflowObjectTypeTraits: {}
|
|
209
|
-
},
|
|
210
|
-
typeGroups: []
|
|
211
|
-
},
|
|
212
|
-
datasources: [],
|
|
213
|
-
entityMetadata: {
|
|
214
|
-
aliases: [],
|
|
215
|
-
arePatchesEnabled: true,
|
|
216
|
-
diffEdits: false,
|
|
217
|
-
entityConfig: {
|
|
218
|
-
objectDbTypeConfigs: {}
|
|
219
|
-
},
|
|
220
|
-
targetStorageBackend: {
|
|
221
|
-
type: "objectStorageV2",
|
|
222
|
-
objectStorageV2: {}
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
writebackDatasets: []
|
|
226
|
-
}, ridGenerator);
|
|
227
|
-
|
|
228
|
-
// Should have output shapes for object type
|
|
229
|
-
expect(result.outputShapes.has("employee")).toBe(true);
|
|
230
|
-
|
|
231
|
-
// Output shapes will include object type + any properties that have readable IDs
|
|
232
|
-
expect(result.outputShapes.size).toBeGreaterThanOrEqual(1);
|
|
233
|
-
const objectTypeShape = result.outputShapes.get("employee");
|
|
234
|
-
expect(objectTypeShape).toBeDefined();
|
|
235
|
-
expect(objectTypeShape?.type).toBe("objectType");
|
|
236
|
-
if (objectTypeShape?.type === "objectType") {
|
|
237
|
-
expect(objectTypeShape.objectType.about.fallbackTitle).toBe("Employee");
|
|
238
|
-
expect(objectTypeShape.objectType.about.fallbackDescription).toBe("An employee in the organization");
|
|
239
|
-
expect(objectTypeShape.objectType.editsSupport).toBe("EDITS_ENABLED");
|
|
240
|
-
expect(objectTypeShape.objectType.objectsBackendVersion).toBe("V2");
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
it("should handle object type with dataset datasource", () => {
|
|
244
|
-
const datasetLocator = {
|
|
245
|
-
type: "dataset",
|
|
246
|
-
dataset: {
|
|
247
|
-
rid: "ri.foundry.main.dataset.person",
|
|
248
|
-
branch: "main"
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
const ridGenerator = createMockRidGenerator({
|
|
252
|
-
getPropertyTypeRids: () => new MockBiMap([["person.id", "ri.ontology.main.property-type.person.id"]]),
|
|
253
|
-
getDatasourceLocators: () => new MockBiMap([["person-dataset", datasetLocator]]),
|
|
254
|
-
getColumnShapes: () => new MockBiMap([["person-dataset.person_id", {
|
|
255
|
-
datasource: datasetLocator,
|
|
256
|
-
name: "person_id"
|
|
257
|
-
}]])
|
|
258
|
-
});
|
|
259
|
-
const extractor = new ObjectTypeShapeExtractor();
|
|
260
|
-
const result = extractor.extract("person", {
|
|
261
|
-
objectType: {
|
|
262
|
-
apiName: "Person",
|
|
263
|
-
rid: "ri.ontology.main.object-type.person",
|
|
264
|
-
id: "person-id",
|
|
265
|
-
displayMetadata: {
|
|
266
|
-
displayName: "Person",
|
|
267
|
-
pluralDisplayName: "People",
|
|
268
|
-
visibility: "NORMAL",
|
|
269
|
-
icon: {
|
|
270
|
-
type: "blueprint",
|
|
271
|
-
blueprint: {
|
|
272
|
-
locator: "person",
|
|
273
|
-
color: "#2D72D2"
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
primaryKeys: ["ri.ontology.main.property-type.person.id"],
|
|
278
|
-
propertyTypes: {
|
|
279
|
-
"ri.ontology.main.property-type.person.id": {
|
|
280
|
-
rid: "ri.ontology.main.property-type.person.id",
|
|
281
|
-
apiName: "id",
|
|
282
|
-
displayMetadata: {
|
|
283
|
-
displayName: "ID",
|
|
284
|
-
visibility: "NORMAL"
|
|
285
|
-
},
|
|
286
|
-
type: {
|
|
287
|
-
type: "string",
|
|
288
|
-
string: {
|
|
289
|
-
isLongText: false,
|
|
290
|
-
supportsExactMatching: true
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
id: "person-id-pt-id",
|
|
294
|
-
indexedForSearch: true,
|
|
295
|
-
status: {
|
|
296
|
-
type: "active",
|
|
297
|
-
active: {}
|
|
298
|
-
},
|
|
299
|
-
typeClasses: []
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
titlePropertyTypeRid: "ri.ontology.main.property-type.person.id",
|
|
303
|
-
status: {
|
|
304
|
-
type: "active",
|
|
305
|
-
active: {}
|
|
306
|
-
},
|
|
307
|
-
redacted: false,
|
|
308
|
-
implementsInterfaces: [],
|
|
309
|
-
implementsInterfaces2: [],
|
|
310
|
-
allImplementsInterfaces: {},
|
|
311
|
-
traits: {
|
|
312
|
-
workflowObjectTypeTraits: {}
|
|
313
|
-
},
|
|
314
|
-
typeGroups: []
|
|
315
|
-
},
|
|
316
|
-
datasources: [{
|
|
317
|
-
rid: "ri.foundry.main.datasource.person-dataset",
|
|
318
|
-
datasource: {
|
|
319
|
-
type: "datasetV2",
|
|
320
|
-
datasetV2: {
|
|
321
|
-
datasetRid: "ri.foundry.main.dataset.person",
|
|
322
|
-
branchId: "main",
|
|
323
|
-
propertyMapping: {
|
|
324
|
-
"ri.ontology.main.property-type.person.id": {
|
|
325
|
-
type: "column",
|
|
326
|
-
column: "person_id"
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}],
|
|
332
|
-
entityMetadata: {
|
|
333
|
-
aliases: [],
|
|
334
|
-
arePatchesEnabled: false,
|
|
335
|
-
diffEdits: false,
|
|
336
|
-
entityConfig: {
|
|
337
|
-
objectDbTypeConfigs: {}
|
|
338
|
-
},
|
|
339
|
-
targetStorageBackend: {
|
|
340
|
-
type: "objectStorageV2",
|
|
341
|
-
objectStorageV2: {}
|
|
342
|
-
}
|
|
343
|
-
},
|
|
344
|
-
writebackDatasets: []
|
|
345
|
-
}, ridGenerator);
|
|
346
|
-
|
|
347
|
-
// Should have input shapes for dataset
|
|
348
|
-
expect(result.inputShapes.size).toBeGreaterThan(0);
|
|
349
|
-
expect(result.inputShapes.has("person-dataset")).toBe(true);
|
|
350
|
-
const datasetShape = result.inputShapes.get("person-dataset");
|
|
351
|
-
expect(datasetShape).toBeDefined();
|
|
352
|
-
expect(datasetShape?.type).toBe("tabularDatasource");
|
|
353
|
-
if (datasetShape?.type === "tabularDatasource") {
|
|
354
|
-
expect(datasetShape.tabularDatasource.supportedTypes).toEqual(["DATASET", "RESTRICTED_VIEW"]);
|
|
355
|
-
expect(datasetShape.tabularDatasource.about.fallbackTitle).toBe("person-dataset");
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
it("should handle object type with stream datasource", () => {
|
|
359
|
-
const streamLocator = {
|
|
360
|
-
type: "stream",
|
|
361
|
-
stream: {
|
|
362
|
-
rid: "ri.foundry.main.stream.event",
|
|
363
|
-
branch: "main"
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
const ridGenerator = createMockRidGenerator({
|
|
367
|
-
getPropertyTypeRids: () => new MockBiMap([["event.id", "ri.ontology.main.property-type.event.id"]]),
|
|
368
|
-
getDatasourceLocators: () => new MockBiMap([["event-stream", streamLocator]]),
|
|
369
|
-
getColumnShapes: () => new MockBiMap([["event-stream.event_id", {
|
|
370
|
-
datasource: streamLocator,
|
|
371
|
-
name: "event_id"
|
|
372
|
-
}]])
|
|
373
|
-
});
|
|
374
|
-
const extractor = new ObjectTypeShapeExtractor();
|
|
375
|
-
const result = extractor.extract("event", {
|
|
376
|
-
objectType: {
|
|
377
|
-
apiName: "Event",
|
|
378
|
-
rid: "ri.ontology.main.object-type.event",
|
|
379
|
-
id: "event-id",
|
|
380
|
-
displayMetadata: {
|
|
381
|
-
displayName: "Event",
|
|
382
|
-
pluralDisplayName: "Events",
|
|
383
|
-
visibility: "NORMAL",
|
|
384
|
-
icon: {
|
|
385
|
-
type: "blueprint",
|
|
386
|
-
blueprint: {
|
|
387
|
-
locator: "flash",
|
|
388
|
-
color: "#2D72D2"
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
primaryKeys: ["ri.ontology.main.property-type.event.id"],
|
|
393
|
-
propertyTypes: {
|
|
394
|
-
"ri.ontology.main.property-type.event.id": {
|
|
395
|
-
rid: "ri.ontology.main.property-type.event.id",
|
|
396
|
-
apiName: "id",
|
|
397
|
-
displayMetadata: {
|
|
398
|
-
displayName: "ID",
|
|
399
|
-
visibility: "NORMAL"
|
|
400
|
-
},
|
|
401
|
-
type: {
|
|
402
|
-
type: "string",
|
|
403
|
-
string: {
|
|
404
|
-
isLongText: false,
|
|
405
|
-
supportsExactMatching: true
|
|
406
|
-
}
|
|
407
|
-
},
|
|
408
|
-
id: "event-id-pt-id",
|
|
409
|
-
indexedForSearch: true,
|
|
410
|
-
status: {
|
|
411
|
-
type: "active",
|
|
412
|
-
active: {}
|
|
413
|
-
},
|
|
414
|
-
typeClasses: []
|
|
415
|
-
}
|
|
416
|
-
},
|
|
417
|
-
titlePropertyTypeRid: "ri.ontology.main.property-type.event.id",
|
|
418
|
-
status: {
|
|
419
|
-
type: "active",
|
|
420
|
-
active: {}
|
|
421
|
-
},
|
|
422
|
-
redacted: false,
|
|
423
|
-
implementsInterfaces: [],
|
|
424
|
-
implementsInterfaces2: [],
|
|
425
|
-
allImplementsInterfaces: {},
|
|
426
|
-
traits: {
|
|
427
|
-
workflowObjectTypeTraits: {}
|
|
428
|
-
},
|
|
429
|
-
typeGroups: []
|
|
430
|
-
},
|
|
431
|
-
datasources: [{
|
|
432
|
-
rid: "ri.foundry.main.datasource.event-stream",
|
|
433
|
-
datasource: {
|
|
434
|
-
type: "streamV2",
|
|
435
|
-
streamV2: {
|
|
436
|
-
streamLocator: {
|
|
437
|
-
streamLocatorRid: "ri.foundry.main.stream.event",
|
|
438
|
-
branchId: "main"
|
|
439
|
-
},
|
|
440
|
-
propertyMapping: {
|
|
441
|
-
"ri.ontology.main.property-type.event.id": "event_id"
|
|
442
|
-
},
|
|
443
|
-
retentionPolicy: {
|
|
444
|
-
type: "none",
|
|
445
|
-
none: {}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}],
|
|
450
|
-
entityMetadata: {
|
|
451
|
-
aliases: [],
|
|
452
|
-
arePatchesEnabled: false,
|
|
453
|
-
diffEdits: false,
|
|
454
|
-
entityConfig: {
|
|
455
|
-
objectDbTypeConfigs: {}
|
|
456
|
-
},
|
|
457
|
-
targetStorageBackend: {
|
|
458
|
-
type: "objectStorageV2",
|
|
459
|
-
objectStorageV2: {}
|
|
460
|
-
}
|
|
461
|
-
},
|
|
462
|
-
writebackDatasets: []
|
|
463
|
-
}, ridGenerator);
|
|
464
|
-
|
|
465
|
-
// Should have input shapes for stream
|
|
466
|
-
expect(result.inputShapes.has("event-stream")).toBe(true);
|
|
467
|
-
const streamShape = result.inputShapes.get("event-stream");
|
|
468
|
-
expect(streamShape).toBeDefined();
|
|
469
|
-
expect(streamShape?.type).toBe("tabularDatasource");
|
|
470
|
-
if (streamShape?.type === "tabularDatasource") {
|
|
471
|
-
expect(streamShape.tabularDatasource.supportedTypes).toEqual(["STREAM"]);
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
it("should apply randomness key to block shape IDs", () => {
|
|
475
|
-
const ridGenerator = createMockRidGenerator({
|
|
476
|
-
getPropertyTypeRids: () => new MockBiMap([["task.id", "ri.ontology.main.property-type.task.id"]])
|
|
477
|
-
});
|
|
478
|
-
const extractor = new ObjectTypeShapeExtractor("random123");
|
|
479
|
-
const result = extractor.extract("task", {
|
|
480
|
-
objectType: {
|
|
481
|
-
apiName: "Task",
|
|
482
|
-
rid: "ri.ontology.main.object-type.task",
|
|
483
|
-
id: "task-id",
|
|
484
|
-
displayMetadata: {
|
|
485
|
-
displayName: "Task",
|
|
486
|
-
pluralDisplayName: "Tasks",
|
|
487
|
-
visibility: "NORMAL",
|
|
488
|
-
icon: {
|
|
489
|
-
type: "blueprint",
|
|
490
|
-
blueprint: {
|
|
491
|
-
locator: "document",
|
|
492
|
-
color: "#2D72D2"
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
},
|
|
496
|
-
primaryKeys: ["ri.ontology.main.property-type.task.id"],
|
|
497
|
-
propertyTypes: {
|
|
498
|
-
"ri.ontology.main.property-type.task.id": {
|
|
499
|
-
rid: "ri.ontology.main.property-type.task.id",
|
|
500
|
-
apiName: "id",
|
|
501
|
-
displayMetadata: {
|
|
502
|
-
displayName: "ID",
|
|
503
|
-
visibility: "NORMAL"
|
|
504
|
-
},
|
|
505
|
-
type: {
|
|
506
|
-
type: "string",
|
|
507
|
-
string: {
|
|
508
|
-
isLongText: false,
|
|
509
|
-
supportsExactMatching: true
|
|
510
|
-
}
|
|
511
|
-
},
|
|
512
|
-
id: "task-id-pt-id",
|
|
513
|
-
indexedForSearch: true,
|
|
514
|
-
status: {
|
|
515
|
-
type: "active",
|
|
516
|
-
active: {}
|
|
517
|
-
},
|
|
518
|
-
typeClasses: []
|
|
519
|
-
}
|
|
520
|
-
},
|
|
521
|
-
titlePropertyTypeRid: "ri.ontology.main.property-type.task.id",
|
|
522
|
-
status: {
|
|
523
|
-
type: "active",
|
|
524
|
-
active: {}
|
|
525
|
-
},
|
|
526
|
-
redacted: false,
|
|
527
|
-
implementsInterfaces: [],
|
|
528
|
-
implementsInterfaces2: [],
|
|
529
|
-
allImplementsInterfaces: {},
|
|
530
|
-
traits: {
|
|
531
|
-
workflowObjectTypeTraits: {}
|
|
532
|
-
},
|
|
533
|
-
typeGroups: []
|
|
534
|
-
},
|
|
535
|
-
datasources: [],
|
|
536
|
-
entityMetadata: {
|
|
537
|
-
aliases: [],
|
|
538
|
-
arePatchesEnabled: false,
|
|
539
|
-
diffEdits: false,
|
|
540
|
-
entityConfig: {
|
|
541
|
-
objectDbTypeConfigs: {}
|
|
542
|
-
},
|
|
543
|
-
targetStorageBackend: {
|
|
544
|
-
type: "objectStorageV2",
|
|
545
|
-
objectStorageV2: {}
|
|
546
|
-
}
|
|
547
|
-
},
|
|
548
|
-
writebackDatasets: []
|
|
549
|
-
}, ridGenerator);
|
|
550
|
-
const taskShape = result.outputShapes.get("task");
|
|
551
|
-
expect(taskShape).toBeDefined();
|
|
552
|
-
if (taskShape?.type === "objectType") {
|
|
553
|
-
// Property type references should include randomness key if there are properties
|
|
554
|
-
const propertyShape = result.outputShapes.get("task.id");
|
|
555
|
-
if (propertyShape && propertyShape.type === "property") {
|
|
556
|
-
// Check that the property reference in object type includes randomness key
|
|
557
|
-
const propertyRefs = taskShape.objectType.propertyTypes;
|
|
558
|
-
if (propertyRefs.length > 0) {
|
|
559
|
-
expect(propertyRefs[0]).toContain("task.id");
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
it("should handle empty datasources", () => {
|
|
565
|
-
const ridGenerator = createMockRidGenerator();
|
|
566
|
-
const extractor = new ObjectTypeShapeExtractor();
|
|
567
|
-
const result = extractor.extract("simple", {
|
|
568
|
-
objectType: {
|
|
569
|
-
apiName: "Simple",
|
|
570
|
-
rid: "ri.ontology.main.object-type.simple",
|
|
571
|
-
id: "simple-id",
|
|
572
|
-
displayMetadata: {
|
|
573
|
-
displayName: "Simple",
|
|
574
|
-
pluralDisplayName: "Simples",
|
|
575
|
-
visibility: "NORMAL",
|
|
576
|
-
icon: {
|
|
577
|
-
type: "blueprint",
|
|
578
|
-
blueprint: {
|
|
579
|
-
locator: "cube",
|
|
580
|
-
color: "#2D72D2"
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
|
-
primaryKeys: ["ri.ontology.main.property-type.simple.id"],
|
|
585
|
-
propertyTypes: {},
|
|
586
|
-
titlePropertyTypeRid: "ri.ontology.main.property-type.simple.id",
|
|
587
|
-
status: {
|
|
588
|
-
type: "active",
|
|
589
|
-
active: {}
|
|
590
|
-
},
|
|
591
|
-
redacted: false,
|
|
592
|
-
implementsInterfaces: [],
|
|
593
|
-
implementsInterfaces2: [],
|
|
594
|
-
allImplementsInterfaces: {},
|
|
595
|
-
traits: {
|
|
596
|
-
workflowObjectTypeTraits: {}
|
|
597
|
-
},
|
|
598
|
-
typeGroups: []
|
|
599
|
-
},
|
|
600
|
-
datasources: [],
|
|
601
|
-
entityMetadata: {
|
|
602
|
-
aliases: [],
|
|
603
|
-
arePatchesEnabled: false,
|
|
604
|
-
diffEdits: false,
|
|
605
|
-
entityConfig: {
|
|
606
|
-
objectDbTypeConfigs: {}
|
|
607
|
-
},
|
|
608
|
-
targetStorageBackend: {
|
|
609
|
-
type: "objectStorageV2",
|
|
610
|
-
objectStorageV2: {}
|
|
611
|
-
}
|
|
612
|
-
},
|
|
613
|
-
writebackDatasets: []
|
|
614
|
-
}, ridGenerator);
|
|
615
|
-
expect(result.outputShapes.size).toBe(1); // Just the object type
|
|
616
|
-
expect(result.inputShapes.size).toBe(0); // No datasources
|
|
617
|
-
});
|
|
618
|
-
it("should handle edits disabled correctly", () => {
|
|
619
|
-
const ridGenerator = createMockRidGenerator();
|
|
620
|
-
const extractor = new ObjectTypeShapeExtractor();
|
|
621
|
-
const result = extractor.extract("readonly", {
|
|
622
|
-
objectType: {
|
|
623
|
-
apiName: "ReadOnly",
|
|
624
|
-
rid: "ri.ontology.main.object-type.readonly",
|
|
625
|
-
id: "readonly-id",
|
|
626
|
-
displayMetadata: {
|
|
627
|
-
displayName: "Read Only",
|
|
628
|
-
pluralDisplayName: "Read Only",
|
|
629
|
-
visibility: "NORMAL",
|
|
630
|
-
icon: {
|
|
631
|
-
type: "blueprint",
|
|
632
|
-
blueprint: {
|
|
633
|
-
locator: "lock",
|
|
634
|
-
color: "#2D72D2"
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
},
|
|
638
|
-
primaryKeys: ["ri.ontology.main.property-type.readonly.id"],
|
|
639
|
-
propertyTypes: {},
|
|
640
|
-
titlePropertyTypeRid: "ri.ontology.main.property-type.readonly.id",
|
|
641
|
-
status: {
|
|
642
|
-
type: "active",
|
|
643
|
-
active: {}
|
|
644
|
-
},
|
|
645
|
-
redacted: false,
|
|
646
|
-
implementsInterfaces: [],
|
|
647
|
-
implementsInterfaces2: [],
|
|
648
|
-
allImplementsInterfaces: {},
|
|
649
|
-
traits: {
|
|
650
|
-
workflowObjectTypeTraits: {}
|
|
651
|
-
},
|
|
652
|
-
typeGroups: []
|
|
653
|
-
},
|
|
654
|
-
datasources: [],
|
|
655
|
-
entityMetadata: {
|
|
656
|
-
aliases: [],
|
|
657
|
-
arePatchesEnabled: false,
|
|
658
|
-
diffEdits: false,
|
|
659
|
-
entityConfig: {
|
|
660
|
-
objectDbTypeConfigs: {}
|
|
661
|
-
},
|
|
662
|
-
targetStorageBackend: {
|
|
663
|
-
type: "objectStorageV2",
|
|
664
|
-
objectStorageV2: {}
|
|
665
|
-
}
|
|
666
|
-
},
|
|
667
|
-
writebackDatasets: []
|
|
668
|
-
}, ridGenerator);
|
|
669
|
-
const objectTypeShape = result.outputShapes.get("readonly");
|
|
670
|
-
expect(objectTypeShape).toBeDefined();
|
|
671
|
-
if (objectTypeShape?.type === "objectType") {
|
|
672
|
-
expect(objectTypeShape.objectType.editsSupport).toBe("EDITS_DISABLED");
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
});
|
|
676
|
-
});
|
|
677
|
-
//# sourceMappingURL=ObjectTypeShapeExtractor.test.js.map
|