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