@osdk/maker 0.14.0-beta.4 → 0.14.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.
@@ -24,7 +24,7 @@ import { defineOntology } from "../api/defineOntology.js";
24
24
  const apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
25
25
  const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
26
26
  export default async function main(args = process.argv) {
27
- const commandLineOpts = await yargs(hideBin(args)).version("0.14.0-beta.4" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
27
+ const commandLineOpts = await yargs(hideBin(args)).version("0.14.0-beta.5" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
28
28
  input: {
29
29
  alias: "i",
30
30
  describe: "Input file",
@@ -1705,7 +1705,7 @@ function addNamespaceIfNone(apiName) {
1705
1705
  var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
1706
1706
  var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
1707
1707
  async function main(args = process.argv) {
1708
- const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.4").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
1708
+ const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.5").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
1709
1709
  input: {
1710
1710
  alias: "i",
1711
1711
  describe: "Input file",
@@ -2375,9 +2375,16 @@ function isTargetParameter(parameterId) {
2375
2375
  return parameterId === MODIFY_OBJECT_PARAMETER || parameterId === CREATE_OR_MODIFY_OBJECT_PARAMETER || parameterId === CREATE_INTERFACE_OBJECT_PARAMETER || parameterId === MODIFY_INTERFACE_OBJECT_PARAMETER;
2376
2376
  }
2377
2377
  function addNamespaceToActionDefinition(def) {
2378
- def.parameterConfiguration = Object.fromEntries(Object.entries(def.parameterConfiguration ?? {}).map(([id, config]) => [isTargetParameter(id) ? id : addNamespaceIfNone(id), config]));
2378
+ def.parameterConfiguration = Object.fromEntries(Object.entries(def.parameterConfiguration ?? {}).map(([id, config]) => [getInterfaceParameterName(def, id), config]));
2379
2379
  def.nonParameterMappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [addNamespaceIfNone(id), value]));
2380
- def.excludedProperties = def.excludedProperties ?? [].map((id) => addNamespaceIfNone(id));
2380
+ def.excludedProperties = (def.excludedProperties ?? []).map((id) => addNamespaceIfNone(id));
2381
+ def.sections = def.sections?.map((section) => ({
2382
+ ...section,
2383
+ parameters: section.parameters.map((p) => getInterfaceParameterName(def, p))
2384
+ }));
2385
+ }
2386
+ function getInterfaceParameterName(def, parameter) {
2387
+ return isTargetParameter(parameter) || !Object.keys(def.interfaceType.propertiesV2).includes(addNamespaceIfNone(parameter)) ? parameter : addNamespaceIfNone(parameter);
2381
2388
  }
2382
2389
  function convertMappingValue(value) {
2383
2390
  switch (value.type) {
@@ -2410,7 +2417,7 @@ function defineCreateInterfaceObjectAction(def) {
2410
2417
  validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
2411
2418
  const propertyParameters = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
2412
2419
  const parameterNames = new Set(propertyParameters);
2413
- Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(isTargetParameter(param) ? param : addNamespaceIfNone(param)));
2420
+ Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
2414
2421
  parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);
2415
2422
  const actionApiName = def.apiName ?? `create-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
2416
2423
  if (def.parameterOrdering) {
@@ -2447,9 +2454,18 @@ function defineCreateInterfaceObjectAction(def) {
2447
2454
  }
2448
2455
  }],
2449
2456
  parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(allProperties), parameters, CREATE_INTERFACE_OBJECT_PARAMETER),
2450
- ...def.validation ? {
2451
- validation: convertValidationRule(def.validation)
2452
- } : {}
2457
+ ...def.actionLevelValidation ? {
2458
+ actionLevelValidation: convertValidationRule(def.actionLevelValidation, parameters)
2459
+ } : {},
2460
+ ...def.enableLayoutSwitch && {
2461
+ enableLayoutSwitch: def.enableLayoutSwitch
2462
+ },
2463
+ ...def.sections && {
2464
+ sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
2465
+ },
2466
+ ...def.submissionMetadata && {
2467
+ submissionMetadata: def.submissionMetadata
2468
+ }
2453
2469
  });
2454
2470
  }
2455
2471
 
@@ -2848,7 +2864,7 @@ function defineModifyInterfaceObjectAction(def) {
2848
2864
  validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
2849
2865
  const propertyParameters = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
2850
2866
  const parameterNames = new Set(propertyParameters);
2851
- Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(isTargetParameter(param) ? param : addNamespaceIfNone(param)));
2867
+ Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
2852
2868
  parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);
2853
2869
  const actionApiName = def.apiName ?? `modify-${kebab(def.interfaceType.apiName.split(".").pop() ?? def.interfaceType.apiName)}${def.objectType === void 0 ? "" : `-${kebab(def.objectType.apiName.split(".").pop() ?? def.objectType.apiName)}`}`;
2854
2870
  if (def.parameterOrdering) {
@@ -2884,9 +2900,18 @@ function defineModifyInterfaceObjectAction(def) {
2884
2900
  }
2885
2901
  }],
2886
2902
  parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Object.keys(allProperties), parameters, MODIFY_INTERFACE_OBJECT_PARAMETER),
2887
- ...def.validation ? {
2888
- validation: convertValidationRule(def.validation)
2889
- } : {}
2903
+ ...def.actionLevelValidation ? {
2904
+ validation: convertValidationRule(def.actionLevelValidation, parameters)
2905
+ } : {},
2906
+ ...def.enableLayoutSwitch && {
2907
+ enableLayoutSwitch: def.enableLayoutSwitch
2908
+ },
2909
+ ...def.sections && {
2910
+ sections: Object.fromEntries(def.sections.map((section) => [section.id, section]))
2911
+ },
2912
+ ...def.submissionMetadata && {
2913
+ submissionMetadata: def.submissionMetadata
2914
+ }
2890
2915
  });
2891
2916
  }
2892
2917