@osdk/generator-converters.ontologyir 2.3.0-beta.10

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.
@@ -0,0 +1,832 @@
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 { hash } from "node:crypto";
18
+ /**
19
+ * TypeScript equivalent of OntologyIrToFullMetadataConverter.java
20
+ * Converts ontology IR data to full metadata format for OSDK generation
21
+ */
22
+ export class OntologyIrToFullMetadataConverter {
23
+ /**
24
+ * Main entry point - converts IR to full metadata
25
+ */
26
+ static getFullMetadataFromIr(ir) {
27
+ const interfaceTypes = this.getOsdkInterfaceTypes(Object.values(ir.interfaceTypes));
28
+ const sharedPropertyTypes = this.getOsdkSharedPropertyTypes(Object.values(ir.sharedPropertyTypes));
29
+ const objectTypes = this.getOsdkObjectTypes(Object.values(ir.objectTypes), Object.values(ir.linkTypes));
30
+ const actionTypes = this.getOsdkActionTypes(Object.values(ir.actionTypes));
31
+ return {
32
+ interfaceTypes,
33
+ sharedPropertyTypes,
34
+ objectTypes,
35
+ queryTypes: {},
36
+ actionTypes,
37
+ ontology: {
38
+ apiName: "ontology",
39
+ rid: `ri.00000`,
40
+ displayName: "ontology",
41
+ description: ""
42
+ }
43
+ };
44
+ }
45
+
46
+ /**
47
+ * Convert IR object types to OSDK format
48
+ */
49
+ static getOsdkObjectTypes(objects, links) {
50
+ const linkMappings = this.getLinkMappings(links);
51
+ const result = {};
52
+ for (const fullObject of objects) {
53
+ const object = fullObject.objectType;
54
+ const icon = object.displayMetadata.icon;
55
+ if (icon.type !== "blueprint") {
56
+ throw new Error("Only blueprint icons are supported");
57
+ }
58
+
59
+ // Ensure we have exactly one primary key
60
+ if (object.primaryKeys.length !== 1) {
61
+ throw new Error("Object must have exactly 1 primary key");
62
+ }
63
+ const primaryKey = object.primaryKeys[0];
64
+ const titleProperty = object.titlePropertyTypeRid;
65
+ const properties = {};
66
+ for (const [propKey, prop] of Object.entries(object.propertyTypes)) {
67
+ const visibility = prop.displayMetadata.visibility;
68
+ let visibilityEnum = "NORMAL";
69
+ if (!visibility) {
70
+ visibilityEnum = "NORMAL";
71
+ } else {
72
+ switch (visibility) {
73
+ case "PROMINENT":
74
+ visibilityEnum = "PROMINENT";
75
+ break;
76
+ case "NORMAL":
77
+ visibilityEnum = "NORMAL";
78
+ break;
79
+ case "HIDDEN":
80
+ visibilityEnum = "HIDDEN";
81
+ break;
82
+ default:
83
+ visibilityEnum = "NORMAL";
84
+ }
85
+ }
86
+ const dataType = this.getOsdkPropertyType(prop.type);
87
+ if (dataType) {
88
+ const status = {
89
+ type: prop.status.type,
90
+ ...(prop.status[prop.status.type] ?? {})
91
+ };
92
+ properties[propKey] = {
93
+ displayName: prop.displayMetadata.displayName,
94
+ rid: `ri.${object.apiName}.${propKey}`,
95
+ status,
96
+ description: prop.displayMetadata.description ?? undefined,
97
+ visibility: visibilityEnum,
98
+ dataType
99
+ };
100
+ }
101
+ }
102
+ const objectTypeV2 = {
103
+ apiName: object.apiName,
104
+ description: object.displayMetadata.description ?? undefined,
105
+ displayName: object.displayMetadata.displayName,
106
+ pluralDisplayName: "",
107
+ // Not available in IR
108
+ primaryKey,
109
+ titleProperty,
110
+ icon: {
111
+ type: "blueprint",
112
+ color: icon.blueprint.color,
113
+ name: icon.blueprint.locator
114
+ },
115
+ status: this.convertObjectTypeStatus(object.status),
116
+ properties,
117
+ rid: `ri.${object.apiName}`
118
+ };
119
+ const sharedPropertyTypeMappings = {};
120
+ const implementsInterfaces2 = {};
121
+ for (const ii of object.implementsInterfaces2) {
122
+ const interfaceApiName = ii.interfaceTypeApiName;
123
+ const propertyMappings = {};
124
+ for (const [sharedPropKey, propMapping] of Object.entries(ii.properties)) {
125
+ const propertyApiName = propMapping.propertyTypeRid;
126
+ propertyMappings[sharedPropKey] = propertyApiName;
127
+ sharedPropertyTypeMappings[sharedPropKey] = propertyApiName;
128
+ }
129
+ implementsInterfaces2[interfaceApiName] = {
130
+ properties: propertyMappings
131
+ };
132
+ }
133
+ const objectApiName = object.apiName;
134
+ result[objectApiName] = {
135
+ objectType: objectTypeV2,
136
+ implementsInterfaces: [],
137
+ // Empty for now - legacy field
138
+ implementsInterfaces2,
139
+ sharedPropertyTypeMapping: sharedPropertyTypeMappings,
140
+ linkTypes: linkMappings[objectApiName] || []
141
+ };
142
+ }
143
+ return result;
144
+ }
145
+
146
+ /**
147
+ * Create link mappings from IR link types
148
+ */
149
+ static getLinkMappings(links) {
150
+ const result = {};
151
+ for (const link of links) {
152
+ const linkType = link.linkType;
153
+ const linkStatus = this.convertLinkTypeStatus(linkType.status);
154
+ let mappings;
155
+ switch (linkType.definition.type) {
156
+ case "manyToMany":
157
+ {
158
+ const linkDef = linkType.definition.manyToMany;
159
+ const sideA = {
160
+ apiName: linkDef.objectTypeAToBLinkMetadata.apiName ?? "",
161
+ displayName: linkDef.objectTypeAToBLinkMetadata.displayMetadata.displayName,
162
+ cardinality: "MANY",
163
+ objectTypeApiName: linkDef.objectTypeRidB,
164
+ linkTypeRid: `ri.${linkDef.objectTypeRidA}.${linkType.id}.${linkDef.objectTypeRidB}`,
165
+ status: linkStatus
166
+ };
167
+ const sideB = {
168
+ ...sideA,
169
+ apiName: linkDef.objectTypeBToALinkMetadata.apiName ?? "",
170
+ objectTypeApiName: linkDef.objectTypeRidA
171
+ };
172
+ mappings = {
173
+ [linkDef.objectTypeRidA]: sideA,
174
+ [linkDef.objectTypeRidB]: sideB
175
+ };
176
+ break;
177
+ }
178
+ case "oneToMany":
179
+ {
180
+ const linkDef = linkType.definition.oneToMany;
181
+ const manySide = {
182
+ apiName: linkDef.oneToManyLinkMetadata.apiName ?? "",
183
+ displayName: linkDef.oneToManyLinkMetadata.displayMetadata.displayName,
184
+ objectTypeApiName: linkDef.objectTypeRidOneSide,
185
+ cardinality: "ONE",
186
+ linkTypeRid: `ri.${linkDef.objectTypeRidOneSide}.${linkType.id}.${linkDef.objectTypeRidManySide}`,
187
+ status: linkStatus
188
+ };
189
+ const oneSide = {
190
+ ...manySide,
191
+ cardinality: "MANY",
192
+ apiName: linkDef.manyToOneLinkMetadata.apiName ?? "",
193
+ displayName: linkDef.manyToOneLinkMetadata.displayMetadata.displayName,
194
+ objectTypeApiName: linkDef.objectTypeRidManySide
195
+ };
196
+ mappings = {
197
+ [linkDef.objectTypeRidOneSide]: oneSide,
198
+ [linkDef.objectTypeRidManySide]: manySide
199
+ };
200
+ break;
201
+ }
202
+ default:
203
+ throw new Error("Unknown link definition type");
204
+ }
205
+
206
+ // Add mappings to result
207
+ for (const [objectTypeApiName, linkSide] of Object.entries(mappings)) {
208
+ if (!result[objectTypeApiName]) {
209
+ result[objectTypeApiName] = [];
210
+ }
211
+ result[objectTypeApiName].push(linkSide);
212
+ }
213
+ }
214
+ return result;
215
+ }
216
+
217
+ /**
218
+ * Convert IR action types to OSDK format
219
+ */
220
+ static getOsdkActionTypes(actions) {
221
+ const result = {};
222
+ for (const action of actions) {
223
+ const metadata = action.actionType.metadata;
224
+ const actionType = {
225
+ rid: `ri.action.${metadata.apiName}`,
226
+ apiName: metadata.apiName,
227
+ displayName: metadata.displayMetadata.displayName,
228
+ description: metadata.displayMetadata.description,
229
+ parameters: this.getOsdkActionParameters(action),
230
+ operations: this.getOsdkActionOperations(action),
231
+ status: this.convertActionTypeStatus(metadata.status)
232
+ };
233
+ result[actionType.apiName] = actionType;
234
+ }
235
+ return result;
236
+ }
237
+
238
+ /**
239
+ * Convert action operations from IR
240
+ */
241
+ static getOsdkActionOperations(action) {
242
+ return action.actionType.actionTypeLogic.logic.rules.map(irLogic => {
243
+ switch (irLogic.type) {
244
+ case "addInterfaceRule":
245
+ {
246
+ const r = irLogic.addInterfaceRule;
247
+ return {
248
+ type: "createInterfaceObject",
249
+ interfaceTypeApiName: r.interfaceApiName
250
+ };
251
+ }
252
+ case "addLinkRule":
253
+ throw new Error("Add link rule not supported");
254
+ case "addObjectRule":
255
+ {
256
+ const r = irLogic.addObjectRule;
257
+ return {
258
+ type: "createObject",
259
+ objectTypeApiName: r.objectTypeId
260
+ };
261
+ }
262
+ case "addOrModifyObjectRuleV2":
263
+ {
264
+ const r = irLogic.addOrModifyObjectRuleV2;
265
+ const modifyParamType = action.actionType.metadata.parameters[r.objectToModify].type;
266
+ if (modifyParamType.type === "objectReference") {
267
+ return {
268
+ type: "modifyObject",
269
+ objectTypeApiName: modifyParamType.objectReference.objectTypeId
270
+ };
271
+ } else {
272
+ throw new Error("Unable to convert modifyAction because parameter does not exist");
273
+ }
274
+ }
275
+ case "deleteLinkRule":
276
+ throw new Error("Delete link rule not supported");
277
+ case "deleteObjectRule":
278
+ {
279
+ const r = irLogic.deleteObjectRule;
280
+ const ontologyIrParameter = action.actionType.metadata.parameters[r.objectToDelete];
281
+ if (ontologyIrParameter.type.type !== "objectReference") {
282
+ throw new Error("invalid parameter type");
283
+ }
284
+ return {
285
+ type: "deleteObject",
286
+ objectTypeApiName: ontologyIrParameter.type.objectReference.objectTypeId
287
+ };
288
+ }
289
+ case "modifyInterfaceRule":
290
+ {
291
+ const r = irLogic.modifyInterfaceRule;
292
+ const parameter = action.actionType.metadata.parameters[r.interfaceObjectToModifyParameter];
293
+ if (!parameter) {
294
+ throw new Error("Could not find interface type api name");
295
+ }
296
+ let interfaceTypeApiName = null;
297
+ switch (parameter.type.type) {
298
+ case "interfaceReference":
299
+ interfaceTypeApiName = parameter.type.interfaceReference.interfaceTypeRid;
300
+ break;
301
+ case "interfaceReferenceList":
302
+ interfaceTypeApiName = parameter.type.interfaceReferenceList.interfaceTypeRid;
303
+ break;
304
+ default:
305
+ interfaceTypeApiName = null;
306
+ }
307
+ if (!interfaceTypeApiName) {
308
+ throw new Error("Could not find interface type api name");
309
+ }
310
+ return {
311
+ type: "modifyInterfaceObject",
312
+ interfaceTypeApiName
313
+ };
314
+ }
315
+ case "modifyObjectRule":
316
+ {
317
+ const r = irLogic.modifyObjectRule;
318
+ const modifyParamType = action.actionType.metadata.parameters[r.objectToModify].type;
319
+ if (modifyParamType.type === "objectReference") {
320
+ return {
321
+ type: "modifyObject",
322
+ objectTypeApiName: modifyParamType.objectReference.objectTypeId
323
+ };
324
+ } else {
325
+ throw new Error("Unable to convert modifyAction because parameter does not exist");
326
+ }
327
+ }
328
+ default:
329
+ throw new Error("Unknown logic rule type");
330
+ }
331
+ });
332
+ }
333
+
334
+ /**
335
+ * Convert action parameters from IR
336
+ */
337
+ static getOsdkActionParameters(action) {
338
+ const result = {};
339
+ for (const [paramKey, irParameter] of Object.entries(action.actionType.metadata.parameters)) {
340
+ let dataType;
341
+ switch (irParameter.type.type) {
342
+ case "attachment":
343
+ dataType = {
344
+ type: "attachment"
345
+ };
346
+ break;
347
+ case "attachmentList":
348
+ dataType = {
349
+ type: "array",
350
+ subType: {
351
+ type: "attachment"
352
+ }
353
+ };
354
+ break;
355
+ case "boolean":
356
+ dataType = {
357
+ type: "boolean"
358
+ };
359
+ break;
360
+ case "booleanList":
361
+ dataType = {
362
+ type: "array",
363
+ subType: {
364
+ type: "boolean"
365
+ }
366
+ };
367
+ break;
368
+ case "date":
369
+ dataType = {
370
+ type: "date"
371
+ };
372
+ break;
373
+ case "dateList":
374
+ dataType = {
375
+ type: "array",
376
+ subType: {
377
+ type: "date"
378
+ }
379
+ };
380
+ break;
381
+ case "decimal":
382
+ throw new Error("Decimal type not supported");
383
+ case "decimalList":
384
+ throw new Error("Decimal list type not supported");
385
+ case "double":
386
+ dataType = {
387
+ type: "double"
388
+ };
389
+ break;
390
+ case "doubleList":
391
+ dataType = {
392
+ type: "array",
393
+ subType: {
394
+ type: "double"
395
+ }
396
+ };
397
+ break;
398
+ case "geohash":
399
+ dataType = {
400
+ type: "geohash"
401
+ };
402
+ break;
403
+ case "geohashList":
404
+ dataType = {
405
+ type: "array",
406
+ subType: {
407
+ type: "geohash"
408
+ }
409
+ };
410
+ break;
411
+ case "geoshape":
412
+ dataType = {
413
+ type: "geoshape"
414
+ };
415
+ break;
416
+ case "geoshapeList":
417
+ dataType = {
418
+ type: "array",
419
+ subType: {
420
+ type: "geoshape"
421
+ }
422
+ };
423
+ break;
424
+ case "geotimeSeriesReference":
425
+ throw new Error("Geotime series reference type not supported");
426
+ case "geotimeSeriesReferenceList":
427
+ throw new Error("Geotime series reference list type not supported");
428
+ case "integer":
429
+ dataType = {
430
+ type: "integer"
431
+ };
432
+ break;
433
+ case "integerList":
434
+ dataType = {
435
+ type: "array",
436
+ subType: {
437
+ type: "integer"
438
+ }
439
+ };
440
+ break;
441
+ case "interfaceReference":
442
+ throw new Error("Interface reference type not supported");
443
+ case "interfaceReferenceList":
444
+ throw new Error("Interface reference list type not supported");
445
+ case "long":
446
+ dataType = {
447
+ type: "long"
448
+ };
449
+ break;
450
+ case "longList":
451
+ dataType = {
452
+ type: "array",
453
+ subType: {
454
+ type: "long"
455
+ }
456
+ };
457
+ break;
458
+ case "marking":
459
+ dataType = {
460
+ type: "marking"
461
+ };
462
+ break;
463
+ case "markingList":
464
+ dataType = {
465
+ type: "array",
466
+ subType: {
467
+ type: "marking"
468
+ }
469
+ };
470
+ break;
471
+ case "mediaReference":
472
+ dataType = {
473
+ type: "mediaReference"
474
+ };
475
+ break;
476
+ case "mediaReferenceList":
477
+ dataType = {
478
+ type: "array",
479
+ subType: {
480
+ type: "mediaReference"
481
+ }
482
+ };
483
+ break;
484
+ case "objectReference":
485
+ {
486
+ const t = irParameter.type.objectReference;
487
+ dataType = {
488
+ type: "object",
489
+ objectTypeApiName: t.objectTypeId,
490
+ objectApiName: t.objectTypeId
491
+ };
492
+ break;
493
+ }
494
+ case "objectReferenceList":
495
+ {
496
+ const t = irParameter.type.objectReferenceList;
497
+ dataType = {
498
+ type: "array",
499
+ subType: {
500
+ type: "object",
501
+ objectTypeApiName: t.objectTypeId,
502
+ objectApiName: t.objectTypeId
503
+ }
504
+ };
505
+ break;
506
+ }
507
+ case "objectSetRid":
508
+ dataType = {
509
+ type: "objectSet"
510
+ };
511
+ break;
512
+ case "objectTypeReference":
513
+ dataType = {
514
+ type: "objectType"
515
+ };
516
+ break;
517
+ case "string":
518
+ dataType = {
519
+ type: "string"
520
+ };
521
+ break;
522
+ case "stringList":
523
+ dataType = {
524
+ type: "array",
525
+ subType: {
526
+ type: "string"
527
+ }
528
+ };
529
+ break;
530
+ case "struct":
531
+ throw new Error("Struct type not supported (lazy implementation)");
532
+ case "structList":
533
+ throw new Error("Struct list type not supported");
534
+ case "timeSeriesReference":
535
+ throw new Error("Time series reference type not supported");
536
+ case "timestamp":
537
+ dataType = {
538
+ type: "timestamp"
539
+ };
540
+ break;
541
+ case "timestampList":
542
+ dataType = {
543
+ type: "array",
544
+ subType: {
545
+ type: "timestamp"
546
+ }
547
+ };
548
+ break;
549
+ default:
550
+ throw new Error("Unknown parameter type");
551
+ }
552
+ result[paramKey] = {
553
+ displayName: irParameter.displayMetadata.displayName,
554
+ description: irParameter.displayMetadata.description,
555
+ required: isParameterRequired(action, paramKey),
556
+ dataType
557
+ };
558
+ }
559
+ return result;
560
+ }
561
+
562
+ /**
563
+ * Convert interface types from IR
564
+ */
565
+ static getOsdkInterfaceTypes(interfaces) {
566
+ const result = {};
567
+ for (const interfaceData of interfaces) {
568
+ const interfaceType = interfaceData.interfaceType;
569
+
570
+ // Convert shared properties to interface shared properties
571
+ const properties = {};
572
+ for (const [propKey, propValue] of Object.entries(interfaceType.propertiesV2)) {
573
+ const spt = propValue.sharedPropertyType;
574
+ const dataType = this.getOsdkPropertyType(spt.type);
575
+ if (dataType) {
576
+ properties[propKey] = {
577
+ rid: `ri.interface.${interfaceType.apiName}.${spt.apiName}`,
578
+ apiName: spt.apiName,
579
+ displayName: spt.displayMetadata.displayName,
580
+ description: spt.displayMetadata.description ?? undefined,
581
+ dataType,
582
+ required: false // Default to false for now - this should come from IR if available
583
+ };
584
+ }
585
+ }
586
+ const result_interfaceType = {
587
+ apiName: interfaceType.apiName,
588
+ rid: `ri.interface.${interfaceType.apiName}`,
589
+ properties,
590
+ allProperties: properties,
591
+ // Same as properties for now
592
+ extendsInterfaces: interfaceType.extendsInterfaces.map(val => val),
593
+ allExtendsInterfaces: interfaceType.extendsInterfaces.map(val => val),
594
+ // Same as extendsInterfaces for now
595
+ implementedByObjectTypes: [],
596
+ // Empty for now
597
+ displayName: interfaceType.displayMetadata.displayName,
598
+ description: interfaceType.displayMetadata.description ?? undefined,
599
+ links: this.getOsdkInterfaceLinkTypes(interfaceType.links),
600
+ allLinks: this.getOsdkInterfaceLinkTypes(interfaceType.links) // Same as links for now
601
+ };
602
+ result[result_interfaceType.apiName] = result_interfaceType;
603
+ }
604
+ return result;
605
+ }
606
+
607
+ /**
608
+ * Convert interface link types from IR
609
+ */
610
+ static getOsdkInterfaceLinkTypes(ilts) {
611
+ const result = {};
612
+ for (const ilt of ilts) {
613
+ let linkedEntityApiName;
614
+ switch (ilt.linkedEntityTypeId.type) {
615
+ case "interfaceType":
616
+ {
617
+ const interfaceType = ilt.linkedEntityTypeId.interfaceType;
618
+ linkedEntityApiName = {
619
+ type: "interfaceTypeApiName",
620
+ apiName: interfaceType
621
+ };
622
+ break;
623
+ }
624
+ case "objectType":
625
+ throw new Error("Interface links to object types should not be possible in ontology as code yet");
626
+ default:
627
+ throw new Error("Unknown linked entity type");
628
+ }
629
+ let cardinality;
630
+ switch (ilt.cardinality) {
631
+ case "SINGLE":
632
+ cardinality = "ONE";
633
+ break;
634
+ case "MANY":
635
+ cardinality = "MANY";
636
+ break;
637
+ default:
638
+ throw new Error("Unknown cardinality type");
639
+ }
640
+ const interfaceLinkType = {
641
+ rid: `ri.interfacelink.${linkedEntityApiName.apiName}.${ilt.metadata.apiName}`,
642
+ apiName: ilt.metadata.apiName,
643
+ displayName: ilt.metadata.displayName,
644
+ description: ilt.metadata.description,
645
+ linkedEntityApiName,
646
+ cardinality,
647
+ required: ilt.required
648
+ };
649
+ result[interfaceLinkType.apiName] = interfaceLinkType;
650
+ }
651
+ return result;
652
+ }
653
+
654
+ /**
655
+ * Convert shared property types from IR
656
+ */
657
+ static getOsdkSharedPropertyTypes(spts) {
658
+ const result = {};
659
+ for (const spt of spts) {
660
+ const dataType = this.getOsdkPropertyType(spt.sharedPropertyType.type);
661
+ if (dataType) {
662
+ const sharedPropertyType = {
663
+ rid: `ri.spt.${spt.sharedPropertyType.apiName}`,
664
+ apiName: spt.sharedPropertyType.apiName,
665
+ displayName: spt.sharedPropertyType.displayMetadata.displayName,
666
+ description: spt.sharedPropertyType.displayMetadata.description ?? undefined,
667
+ dataType
668
+ };
669
+ result[sharedPropertyType.apiName] = sharedPropertyType;
670
+ } else {
671
+ throw new Error(`Unsupported property type '${JSON.stringify(spt.sharedPropertyType.type)}' for spt '${spt.sharedPropertyType.apiName}'`);
672
+ }
673
+ }
674
+ return result;
675
+ }
676
+
677
+ /**
678
+ * Convert property types from IR to OSDK format
679
+ */
680
+ static getOsdkPropertyType(type) {
681
+ switch (type.type) {
682
+ case "array":
683
+ {
684
+ const value = type.array;
685
+ const subType = this.getOsdkPropertyType(value.subtype);
686
+ return subType ? {
687
+ type: "array",
688
+ subType
689
+ } : null;
690
+ }
691
+ case "boolean":
692
+ return {
693
+ type: "boolean"
694
+ };
695
+ case "byte":
696
+ return {
697
+ type: "byte"
698
+ };
699
+ case "date":
700
+ return {
701
+ type: "date"
702
+ };
703
+ case "decimal":
704
+ return {
705
+ type: "decimal"
706
+ };
707
+ case "double":
708
+ return {
709
+ type: "double"
710
+ };
711
+ case "float":
712
+ return {
713
+ type: "float"
714
+ };
715
+ case "geohash":
716
+ return {
717
+ type: "geopoint"
718
+ };
719
+ case "geoshape":
720
+ return {
721
+ type: "geoshape"
722
+ };
723
+ case "integer":
724
+ return {
725
+ type: "integer"
726
+ };
727
+ case "long":
728
+ return {
729
+ type: "long"
730
+ };
731
+ case "short":
732
+ return {
733
+ type: "short"
734
+ };
735
+ case "string":
736
+ return {
737
+ type: "string"
738
+ };
739
+ case "experimentalTimeDependentV1":
740
+ return null;
741
+ case "timestamp":
742
+ return {
743
+ type: "timestamp"
744
+ };
745
+ case "attachment":
746
+ return {
747
+ type: "attachment"
748
+ };
749
+ case "marking":
750
+ return {
751
+ type: "marking"
752
+ };
753
+ case "cipherText":
754
+ return null;
755
+ case "mediaReference":
756
+ return null;
757
+ case "vector":
758
+ return null;
759
+ case "geotimeSeriesReference":
760
+ return null;
761
+ case "struct":
762
+ {
763
+ const value = type.struct;
764
+ const ridBase = `ri.struct.${hash("sha256", JSON.stringify(type)).slice(0, 10)}`;
765
+ return {
766
+ type: "struct",
767
+ structFieldTypes: value.structFields.map(field => {
768
+ const fieldDataType = this.getOsdkPropertyType(field.fieldType);
769
+ if (!fieldDataType) {
770
+ throw new Error(`Unsupported field type in struct: ${field.apiName}`);
771
+ }
772
+ return {
773
+ apiName: field.apiName,
774
+ rid: `${ridBase}.${field.apiName}`,
775
+ dataType: fieldDataType
776
+ };
777
+ })
778
+ };
779
+ }
780
+ default:
781
+ return null;
782
+ }
783
+ }
784
+ static convertObjectTypeStatus(status) {
785
+ switch (status.type) {
786
+ case "active":
787
+ return "ACTIVE";
788
+ case "deprecated":
789
+ return "DEPRECATED";
790
+ case "endorsed":
791
+ throw new Error("Endorsed status is not supported yet");
792
+ case "example":
793
+ throw new Error("Example status has no mapping");
794
+ case "experimental":
795
+ return "EXPERIMENTAL";
796
+ default:
797
+ throw new Error(`Unknown object type status: ${status}`);
798
+ }
799
+ }
800
+ static convertActionTypeStatus(status) {
801
+ switch (status.type) {
802
+ case "active":
803
+ return "ACTIVE";
804
+ case "deprecated":
805
+ return "DEPRECATED";
806
+ case "example":
807
+ throw new Error("Example status has no mapping");
808
+ case "experimental":
809
+ return "EXPERIMENTAL";
810
+ default:
811
+ throw new Error(`Unknown action type status: ${status}`);
812
+ }
813
+ }
814
+ static convertLinkTypeStatus(status) {
815
+ switch (status.type) {
816
+ case "active":
817
+ return "ACTIVE";
818
+ case "deprecated":
819
+ return "DEPRECATED";
820
+ case "example":
821
+ throw new Error("Example status has no mapping");
822
+ case "experimental":
823
+ return "EXPERIMENTAL";
824
+ default:
825
+ throw new Error(`Unknown link type status: ${status}`);
826
+ }
827
+ }
828
+ }
829
+ function isParameterRequired(action, paramKey) {
830
+ return action.actionType.actionTypeLogic.validation.parameterValidations[paramKey].defaultValidation.validation.required.type === "required";
831
+ }
832
+ //# sourceMappingURL=OntologyIrToFullMetadataConverter.js.map