@osdk/maker 0.13.0-beta.1 → 0.13.0-beta.11

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.
Files changed (60) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/build/browser/api/defineAction.js +57 -20
  3. package/build/browser/api/defineAction.js.map +1 -1
  4. package/build/browser/api/defineInterface.js +11 -6
  5. package/build/browser/api/defineInterface.js.map +1 -1
  6. package/build/browser/api/defineObject.js +2 -0
  7. package/build/browser/api/defineObject.js.map +1 -1
  8. package/build/browser/api/defineOntology.js +40 -109
  9. package/build/browser/api/defineOntology.js.map +1 -1
  10. package/build/browser/api/defineSpt.js.map +1 -1
  11. package/build/browser/api/defineValueType.js +2 -1
  12. package/build/browser/api/defineValueType.js.map +1 -1
  13. package/build/browser/api/markingconstraint.test.js +3 -3
  14. package/build/browser/api/markingconstraint.test.js.map +1 -1
  15. package/build/browser/api/objectStatus.test.js +4 -4
  16. package/build/browser/api/objectStatus.test.js.map +1 -1
  17. package/build/browser/api/overall.test.js +1015 -314
  18. package/build/browser/api/overall.test.js.map +1 -1
  19. package/build/browser/api/propertyConversionUtils.js +3 -1
  20. package/build/browser/api/propertyConversionUtils.js.map +1 -1
  21. package/build/browser/api/types.js.map +1 -1
  22. package/build/browser/cli/main.js +5 -5
  23. package/build/browser/cli/main.js.map +1 -1
  24. package/build/cjs/index.cjs +106 -141
  25. package/build/cjs/index.cjs.map +1 -1
  26. package/build/cjs/index.d.cts +8 -10
  27. package/build/esm/api/defineAction.js +57 -20
  28. package/build/esm/api/defineAction.js.map +1 -1
  29. package/build/esm/api/defineInterface.js +11 -6
  30. package/build/esm/api/defineInterface.js.map +1 -1
  31. package/build/esm/api/defineObject.js +2 -0
  32. package/build/esm/api/defineObject.js.map +1 -1
  33. package/build/esm/api/defineOntology.js +40 -109
  34. package/build/esm/api/defineOntology.js.map +1 -1
  35. package/build/esm/api/defineSpt.js.map +1 -1
  36. package/build/esm/api/defineValueType.js +2 -1
  37. package/build/esm/api/defineValueType.js.map +1 -1
  38. package/build/esm/api/markingconstraint.test.js +3 -3
  39. package/build/esm/api/markingconstraint.test.js.map +1 -1
  40. package/build/esm/api/objectStatus.test.js +4 -4
  41. package/build/esm/api/objectStatus.test.js.map +1 -1
  42. package/build/esm/api/overall.test.js +1015 -314
  43. package/build/esm/api/overall.test.js.map +1 -1
  44. package/build/esm/api/propertyConversionUtils.js +3 -1
  45. package/build/esm/api/propertyConversionUtils.js.map +1 -1
  46. package/build/esm/api/types.js.map +1 -1
  47. package/build/esm/cli/main.js +5 -5
  48. package/build/esm/cli/main.js.map +1 -1
  49. package/build/types/api/defineAction.d.ts.map +1 -1
  50. package/build/types/api/defineInterface.d.ts.map +1 -1
  51. package/build/types/api/defineObject.d.ts.map +1 -1
  52. package/build/types/api/defineOntology.d.ts +1 -6
  53. package/build/types/api/defineOntology.d.ts.map +1 -1
  54. package/build/types/api/defineSpt.d.ts +2 -2
  55. package/build/types/api/defineSpt.d.ts.map +1 -1
  56. package/build/types/api/propertyConversionUtils.d.ts +2 -2
  57. package/build/types/api/propertyConversionUtils.d.ts.map +1 -1
  58. package/build/types/api/types.d.ts +6 -14
  59. package/build/types/api/types.d.ts.map +1 -1
  60. package/package.json +9 -10
@@ -1,4 +1,4 @@
1
- import { ActionTypeApiName, ParameterId, OntologyIrBaseParameterType_decimal, OntologyIrBaseParameterType_decimalList, OntologyIrBaseParameterType_timestamp, OntologyIrBaseParameterType_timestampList, OntologyIrBaseParameterType_objectReference, OntologyIrBaseParameterType_objectReferenceList, OntologyIrBaseParameterType_objectSetRid, OntologyIrBaseParameterType_objectTypeReference, OntologyIrBaseParameterType_interfaceReference, OntologyIrBaseParameterType_interfaceReferenceList, OntologyIrBaseParameterType_struct, OntologyIrBaseParameterType_structList, OntologyIrLabelledValue, OntologyIrConditionValue, OntologyIrParameterDateRangeValue, InterfaceTypeApiName, OntologyIrCondition, OntologyIrParameterPrefill, OntologyIrLogicRule, SectionId, ActionTypeStatus_deprecated, OntologyIrActionTypeEntities, OntologyIrFormContent, OntologyIrValidationRule, DisplayMetadataConfigurationDefaultLayout, DisplayMetadataConfigurationDisplayAndFormat, ButtonDisplayMetadata, OntologyIrMarketplaceInterfaceType, StructFieldType, ValueTypeApiNameReference, Visibility, SharedPropertyTypeGothamMapping, InterfaceTypeStatus, OntologyIrPropertyType, ValueTypeApiName, ValueTypeDisplayMetadata, ValueTypeStatus, ValueTypeVersion, BaseType, ValueTypeDataConstraint, ExampleValue, ValidationRuleDisplayMetadata, OntologyIrLogicRuleValue_parameterId, OntologyIrLogicRuleValue_staticValue, OntologyIrLogicRuleValue_objectParameterPropertyValue, OntologyIrLogicRuleValue_interfaceParameterPropertyValue, OntologyIrLogicRuleValue_synchronousWebhookOutput, LinkTypeMetadata, OntologyIrLinkTypeStatus, DataConstraint, FailureMessage, OntologyIrObjectType, OntologyIr, OntologyIrValueTypeBlockData, OntologyIrType } from '@osdk/client.unstable';
1
+ import { ActionTypeApiName, ParameterId, OntologyIrBaseParameterType_decimal, OntologyIrBaseParameterType_decimalList, OntologyIrBaseParameterType_timestamp, OntologyIrBaseParameterType_timestampList, OntologyIrBaseParameterType_objectReference, OntologyIrBaseParameterType_objectReferenceList, OntologyIrBaseParameterType_objectSetRid, OntologyIrBaseParameterType_objectTypeReference, OntologyIrBaseParameterType_interfaceReference, OntologyIrBaseParameterType_interfaceReferenceList, OntologyIrBaseParameterType_struct, OntologyIrBaseParameterType_structList, OntologyIrLabelledValue, OntologyIrConditionValue, OntologyIrParameterDateRangeValue, InterfaceTypeApiName, OntologyIrCondition, OntologyIrParameterPrefill, OntologyIrLogicRule, SectionId, ActionTypeStatus_deprecated, OntologyIrActionTypeEntities, OntologyIrFormContent, OntologyIrValidationRule, DisplayMetadataConfigurationDefaultLayout, DisplayMetadataConfigurationDisplayAndFormat, ButtonDisplayMetadata, OntologyIrMarketplaceInterfaceType, StructFieldType, OntologyIrValueTypeReferenceWithMetadata, Visibility, SharedPropertyTypeGothamMapping, InterfaceTypeStatus, OntologyIrPropertyType, ValueTypeApiName, ValueTypeDisplayMetadata, ValueTypeStatus, ValueTypeVersion, BaseType, ValueTypeDataConstraint, ExampleValue, ValidationRuleDisplayMetadata, OntologyIrLogicRuleValue_parameterId, OntologyIrLogicRuleValue_staticValue, OntologyIrLogicRuleValue_objectParameterPropertyValue, OntologyIrLogicRuleValue_interfaceParameterPropertyValue, OntologyIrLogicRuleValue_synchronousWebhookOutput, LinkTypeMetadata, OntologyIrLinkTypeStatus, DataConstraint, FailureMessage, OntologyIrObjectType, OntologyIr, OntologyIrType } from '@osdk/client.unstable';
2
2
 
3
3
  declare function main(args?: string[]): Promise<void>;
4
4
 
@@ -196,7 +196,8 @@ interface ActionTypeInner {
196
196
  displayAndFormat: DisplayMetadataConfigurationDisplayAndFormat;
197
197
  submissionMetadata: SubmissionMetadata;
198
198
  }
199
- type ActionLevelValidationDefinition = {
199
+ type ActionLevelValidationDefinition = Array<ActionLevelValidationRule>;
200
+ type ActionLevelValidationRule = {
200
201
  condition: ConditionDefinition;
201
202
  displayMetadata?: ValidationRuleDisplayMetadata;
202
203
  };
@@ -282,7 +283,7 @@ interface InterfacePropertyType {
282
283
  sharedPropertyType: SharedPropertyType;
283
284
  required: boolean;
284
285
  }
285
- interface InterfaceType extends OntologyEntityBase, Omit<OntologyIrMarketplaceInterfaceType, "properties" | "allProperties" | "allLinks" | "extendsInterfaces" | "allExtendsInterfaces" | "propertiesV2" | "allPropertiesV2" | "propertiesV3" | "allPropertiesV3"> {
286
+ interface InterfaceType extends OntologyEntityBase, Omit<OntologyIrMarketplaceInterfaceType, "properties" | "propertiesV2" | "propertiesV3" | "extendsInterfaces"> {
286
287
  propertiesV2: Record<string, InterfacePropertyType>;
287
288
  extendsInterfaces: Array<InterfaceType>;
288
289
  status: InterfaceTypeStatus;
@@ -293,7 +294,7 @@ interface PropertyType {
293
294
  array?: boolean;
294
295
  description?: string;
295
296
  displayName?: string;
296
- valueType?: ValueTypeApiNameReference;
297
+ valueType?: OntologyIrValueTypeReferenceWithMetadata;
297
298
  visibility?: Visibility;
298
299
  typeClasses?: TypeClass[];
299
300
  nullability?: Nullability;
@@ -581,6 +582,7 @@ interface ValueTypeType_timestamp {
581
582
  type ValueTypeType = ValueTypeType_array | ValueTypeType_boolean | ValueTypeType_binary | ValueTypeType_byte | ValueTypeType_date | ValueTypeType_decimal | ValueTypeType_double | ValueTypeType_float | ValueTypeType_integer | ValueTypeType_long | ValueTypeType_map | ValueTypeType_optional | ValueTypeType_short | ValueTypeType_string | ValueTypeType_structV2 | ValueTypeType_timestamp;
582
583
  type ValueTypeDefinitionVersion = OntologyEntityBase & {
583
584
  apiName: ValueTypeApiName;
585
+ packageNamespace: string;
584
586
  displayMetadata: ValueTypeDisplayMetadata;
585
587
  status: ValueTypeStatus;
586
588
  version: ValueTypeVersion;
@@ -678,11 +680,7 @@ declare function defineObject(objectDef: ObjectTypeDefinition): ObjectTypeDefini
678
680
  declare function convertToDisplayName(s: string | undefined | null): string;
679
681
  declare function convertToPluralDisplayName(s: string | undefined | null): string;
680
682
 
681
- type OntologyAndValueTypeIrs = {
682
- ontology: OntologyIr;
683
- valueType: OntologyIrValueTypeBlockData;
684
- };
685
- declare function defineOntology(ns: string, body: () => void | Promise<void>, outputDir: string | undefined, dependencyFile?: string): Promise<OntologyAndValueTypeIrs>;
683
+ declare function defineOntology(ns: string, body: () => void | Promise<void>, outputDir: string | undefined, dependencyFile?: string): Promise<OntologyIr>;
686
684
  declare function dumpOntologyFullMetadata(): OntologyIr;
687
685
  declare function addNamespaceIfNone(apiName: string): string;
688
686
 
@@ -692,7 +690,7 @@ interface SharedPropertyTypeDefinition {
692
690
  array?: boolean;
693
691
  description?: string;
694
692
  displayName?: string;
695
- valueType?: ValueTypeApiNameReference;
693
+ valueType?: OntologyIrValueTypeReferenceWithMetadata;
696
694
  visibility?: Visibility;
697
695
  typeClasses?: SharedPropertyType["typeClasses"];
698
696
  gothamMapping?: SharedPropertyTypeGothamMapping;
@@ -17,7 +17,7 @@
17
17
  import { consola } from "consola";
18
18
  import invariant from "tiny-invariant";
19
19
  import { convertToDisplayName, getAllInterfaceProperties } from "./defineObject.js";
20
- import { namespace, ontologyDefinition, updateOntology } from "./defineOntology.js";
20
+ import { importedTypes, namespace, ontologyDefinition, updateOntology } from "./defineOntology.js";
21
21
  import { convertConditionDefinition, convertMappingValue } from "./ontologyUtils.js";
22
22
  import { CREATE_OR_MODIFY_OBJECT_PARAMETER, MODIFY_OBJECT_PARAMETER, OntologyEntityTypeEnum } from "./types.js";
23
23
  export function defineCreateInterfaceObjectAction(interfaceType, objectType, validation) {
@@ -86,7 +86,7 @@ export function defineCreateInterfaceObjectAction(interfaceType, objectType, val
86
86
  }
87
87
  }],
88
88
  ...(validation ? {
89
- validation: [convertValidationRule(validation)]
89
+ validation: convertValidationRule(validation)
90
90
  } : {})
91
91
  });
92
92
  }
@@ -99,7 +99,7 @@ export function defineCreateObjectAction(def) {
99
99
  if (def.parameterOrdering) {
100
100
  validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
101
101
  }
102
- const parameters = createParameters(def, parameterNames, true);
102
+ const parameters = createParameters(def, parameterNames);
103
103
  const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
104
104
  return defineAction({
105
105
  apiName: actionApiName,
@@ -128,7 +128,7 @@ export function defineCreateObjectAction(def) {
128
128
  }],
129
129
  parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters),
130
130
  ...(def.actionLevelValidation ? {
131
- validation: [convertValidationRule(def.actionLevelValidation)]
131
+ validation: convertValidationRule(def.actionLevelValidation)
132
132
  } : {}),
133
133
  ...(def.defaultFormat && {
134
134
  defaultFormat: def.defaultFormat
@@ -211,7 +211,7 @@ export function defineModifyInterfaceObjectAction(interfaceType, objectType, val
211
211
  }
212
212
  }],
213
213
  ...(validation ? {
214
- validation: [convertValidationRule(validation)]
214
+ validation: convertValidationRule(validation)
215
215
  } : {})
216
216
  });
217
217
  }
@@ -228,7 +228,7 @@ export function defineModifyObjectAction(def) {
228
228
  }
229
229
  validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
230
230
  }
231
- const parameters = createParameters(def, parameterNames, false);
231
+ const parameters = createParameters(def, parameterNames);
232
232
  parameters.forEach(p => {
233
233
  if (p.id !== MODIFY_OBJECT_PARAMETER && p.defaultValue === undefined) {
234
234
  p.defaultValue = {
@@ -268,7 +268,7 @@ export function defineModifyObjectAction(def) {
268
268
  },
269
269
  parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, MODIFY_OBJECT_PARAMETER),
270
270
  ...(def.actionLevelValidation ? {
271
- validation: [convertValidationRule(def.actionLevelValidation)]
271
+ validation: convertValidationRule(def.actionLevelValidation)
272
272
  } : {}),
273
273
  ...(def.defaultFormat && {
274
274
  defaultFormat: def.defaultFormat
@@ -321,7 +321,7 @@ export function defineDeleteObjectAction(def) {
321
321
  typeGroups: []
322
322
  },
323
323
  ...(def.actionLevelValidation ? {
324
- validation: [convertValidationRule(def.actionLevelValidation)]
324
+ validation: convertValidationRule(def.actionLevelValidation)
325
325
  } : {})
326
326
  });
327
327
  }
@@ -338,7 +338,7 @@ export function defineCreateOrModifyObjectAction(def) {
338
338
  }
339
339
  validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
340
340
  }
341
- const parameters = createParameters(def, parameterNames, false);
341
+ const parameters = createParameters(def, parameterNames);
342
342
  parameters.forEach(p => {
343
343
  if (p.id !== CREATE_OR_MODIFY_OBJECT_PARAMETER && p.defaultValue === undefined) {
344
344
  p.defaultValue = {
@@ -378,7 +378,7 @@ export function defineCreateOrModifyObjectAction(def) {
378
378
  },
379
379
  parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, parameters, CREATE_OR_MODIFY_OBJECT_PARAMETER),
380
380
  ...(def.actionLevelValidation ? {
381
- validation: [convertValidationRule(def.actionLevelValidation)]
381
+ validation: convertValidationRule(def.actionLevelValidation)
382
382
  } : {}),
383
383
  ...(def.defaultFormat && {
384
384
  defaultFormat: def.defaultFormat
@@ -419,6 +419,41 @@ export function defineAction(actionDef) {
419
419
  if (rule.type === "deleteObjectRule") {
420
420
  !parameterIds.some(id => id === rule.deleteObjectRule.objectToDelete) ? process.env.NODE_ENV !== "production" ? invariant(false, `Object to delete parameter must be defined in parameters`) : invariant(false) : void 0;
421
421
  }
422
+ if (rule.type === "modifyInterfaceRule") {
423
+ // all referenced SPTs exist globally
424
+ Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach(spt => {
425
+ !(ontologyDefinition.SHARED_PROPERTY_TYPE[spt] !== undefined || importedTypes.SHARED_PROPERTY_TYPE[spt] !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Shared property type ${spt} does not exist.
426
+ If this SPT was imported, you may need to use [spt.apiName] as the key so that it is qualified with the right namespace`) : invariant(false) : void 0;
427
+ });
428
+
429
+ // The there must be a parameter for the interface, and the interface there must exist
430
+ const interfaceParam = actionDef.parameters.find(p => p.id === rule.modifyInterfaceRule.interfaceObjectToModifyParameter);
431
+ !(interfaceParam !== undefined && typeof interfaceParam.type === "object" && (interfaceParam.type.type === "interfaceReference" || interfaceParam.type.type === "interfaceReferenceList")) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface object to modify parameter must be an interface reference`) : invariant(false) : void 0;
432
+ const interfaceReference = interfaceParam.type.type === "interfaceReference" ? interfaceParam.type.interfaceReference.interfaceTypeRid : interfaceParam.type.interfaceReferenceList.interfaceTypeRid;
433
+ !(ontologyDefinition.INTERFACE_TYPE[interfaceReference] !== undefined || importedTypes.INTERFACE_TYPE[interfaceReference] !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface type ${interfaceReference} does not exist`) : invariant(false) : void 0;
434
+
435
+ // All referenced SPTs must exist on the interface
436
+ const interfaceType = ontologyDefinition.INTERFACE_TYPE[interfaceReference];
437
+ Object.keys(rule.modifyInterfaceRule.sharedPropertyValues).forEach(spt => {
438
+ !(interfaceType.propertiesV2[spt] !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Shared property type ${spt} does not exist in interface type ${interfaceReference}`) : invariant(false) : void 0;
439
+ });
440
+ }
441
+ if (rule.type === "addInterfaceRule") {
442
+ // All referenced SPTs must exist globally
443
+ Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach(spt => {
444
+ !(ontologyDefinition.SHARED_PROPERTY_TYPE[spt] !== undefined || importedTypes.SHARED_PROPERTY_TYPE[spt] !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Shared property type ${spt} does not exist.
445
+ If this SPT was imported, you may need to use [spt.apiName] as the key so that it is qualified with the right namespace`) : invariant(false) : void 0;
446
+ });
447
+
448
+ // The referenced interface must exist globally
449
+ const interfaceType = ontologyDefinition.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName] ?? importedTypes.INTERFACE_TYPE[rule.addInterfaceRule.interfaceApiName];
450
+ !(interfaceType !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Interface type ${rule.addInterfaceRule.interfaceApiName} does not exist`) : invariant(false) : void 0;
451
+
452
+ // All referenced SPTs must exist on the interface
453
+ Object.keys(rule.addInterfaceRule.sharedPropertyValues).forEach(spt => {
454
+ !(interfaceType.propertiesV2[spt] !== undefined) ? process.env.NODE_ENV !== "production" ? invariant(false, `Shared property type ${spt} does not exist in interface type ${interfaceType.apiName}`) : invariant(false) : void 0;
455
+ });
456
+ }
422
457
  });
423
458
  const fullAction = {
424
459
  ...actionDef,
@@ -435,7 +470,7 @@ export function defineAction(actionDef) {
435
470
  updateOntology(fullAction);
436
471
  return fullAction;
437
472
  }
438
- function createParameters(def, parameterSet, defaultRequired) {
473
+ function createParameters(def, parameterSet) {
439
474
  const targetParam = [];
440
475
  parameterSet.forEach(name => {
441
476
  if (name === MODIFY_OBJECT_PARAMETER) {
@@ -497,13 +532,13 @@ function createParameters(def, parameterSet, defaultRequired) {
497
532
  validation: def.parameterConfiguration?.[id] !== undefined ? {
498
533
  ...def.parameterConfiguration?.[id],
499
534
  allowedValues: def.parameterConfiguration?.[id].allowedValues ?? (def.parameterConfiguration?.[id].customParameterType ? extractAllowedValuesFromActionParameterType(def.parameterConfiguration?.[id].customParameterType) : extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)),
500
- required: def.parameterConfiguration?.[id].required ?? defaultRequired
535
+ required: def.parameterConfiguration?.[id].required ?? def.objectType.properties?.[id]?.nullability?.noNulls ?? false
501
536
  } : {
502
537
  required: def.objectType.properties?.[id].array ?? false ? {
503
538
  listLength: def.objectType.properties?.[id].nullability?.noEmptyCollections ? {
504
539
  min: 1
505
540
  } : {}
506
- } : def.objectType.properties?.[id].nullability?.noNulls ?? defaultRequired,
541
+ } : def.objectType.properties?.[id].nullability?.noNulls ?? false,
507
542
  allowedValues: extractAllowedValuesFromPropertyType(def.objectType.properties?.[id].type)
508
543
  },
509
544
  defaultValue: def.parameterConfiguration?.[id]?.defaultValue,
@@ -788,13 +823,15 @@ function sanitize(s) {
788
823
  return s.includes(".") ? s : namespace + s;
789
824
  }
790
825
  function convertValidationRule(actionValidation) {
791
- return {
792
- condition: convertConditionDefinition(actionValidation.condition),
793
- displayMetadata: actionValidation.displayMetadata ?? {
794
- failureMessage: "Did not satisfy validation",
795
- typeClasses: []
796
- }
797
- };
826
+ return actionValidation.map(rule => {
827
+ return {
828
+ condition: convertConditionDefinition(rule.condition),
829
+ displayMetadata: rule.displayMetadata ?? {
830
+ failureMessage: "Did not satisfy validation",
831
+ typeClasses: []
832
+ }
833
+ };
834
+ });
798
835
  }
799
836
  function validateActionConfiguration(action) {
800
837
  const seenParameterIds = new Set();