@osdk/maker 0.14.0-beta.8 → 0.14.0-rc.16
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 +128 -0
- package/README.md +0 -1
- package/build/browser/api/code-snippets/createCodeSnippets.js +94 -0
- package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -0
- package/build/browser/api/code-snippets/snippetTypes.js +61 -0
- package/build/browser/api/code-snippets/snippetTypes.js.map +1 -0
- package/build/browser/api/defineAction.js +6 -0
- package/build/browser/api/defineAction.js.map +1 -1
- package/build/browser/api/defineCreateInterfaceObjectAction.js +8 -7
- package/build/browser/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineDeleteInterfaceObjectAction.js +2 -2
- package/build/browser/api/defineDeleteInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineModifyInterfaceObjectAction.js +8 -7
- package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/defineObject.js +1 -2
- package/build/browser/api/defineObject.js.map +1 -1
- package/build/browser/api/defineOntology.js +5 -1
- package/build/browser/api/defineOntology.js.map +1 -1
- package/build/browser/api/object/ObjectPropertyTypeUserDefinition.js.map +1 -1
- package/build/browser/api/properties/PropertyTypeType.js.map +1 -1
- package/build/browser/api/test/actions.test.js +1252 -10
- package/build/browser/api/test/actions.test.js.map +1 -1
- package/build/browser/api/test/misc.test.js +2 -2
- package/build/browser/api/test/misc.test.js.map +1 -1
- package/build/browser/api/test/spt.test.js +204 -105
- package/build/browser/api/test/spt.test.js.map +1 -1
- package/build/browser/cli/main.js +23 -4
- package/build/browser/cli/main.js.map +1 -1
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +19 -7
- package/build/browser/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/cjs/index.cjs +206 -61
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +15 -6
- package/build/esm/api/code-snippets/createCodeSnippets.js +94 -0
- package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -0
- package/build/esm/api/code-snippets/snippetTypes.js +61 -0
- package/build/esm/api/code-snippets/snippetTypes.js.map +1 -0
- package/build/esm/api/defineAction.js +6 -0
- package/build/esm/api/defineAction.js.map +1 -1
- package/build/esm/api/defineCreateInterfaceObjectAction.js +8 -7
- package/build/esm/api/defineCreateInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineDeleteInterfaceObjectAction.js +2 -2
- package/build/esm/api/defineDeleteInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineModifyInterfaceObjectAction.js +8 -7
- package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/defineObject.js +1 -2
- package/build/esm/api/defineObject.js.map +1 -1
- package/build/esm/api/defineOntology.js +5 -1
- package/build/esm/api/defineOntology.js.map +1 -1
- package/build/esm/api/object/ObjectPropertyTypeUserDefinition.js.map +1 -1
- package/build/esm/api/properties/PropertyTypeType.js.map +1 -1
- package/build/esm/api/test/actions.test.js +1252 -10
- package/build/esm/api/test/actions.test.js.map +1 -1
- package/build/esm/api/test/misc.test.js +2 -2
- package/build/esm/api/test/misc.test.js.map +1 -1
- package/build/esm/api/test/spt.test.js +204 -105
- package/build/esm/api/test/spt.test.js.map +1 -1
- package/build/esm/cli/main.js +23 -4
- package/build/esm/cli/main.js.map +1 -1
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js +19 -7
- package/build/esm/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.js.map +1 -1
- package/build/types/api/code-snippets/createCodeSnippets.d.ts +2 -0
- package/build/types/api/code-snippets/createCodeSnippets.d.ts.map +1 -0
- package/build/types/api/code-snippets/snippetTypes.d.ts +24 -0
- package/build/types/api/code-snippets/snippetTypes.d.ts.map +1 -0
- package/build/types/api/defineAction.d.ts +3 -0
- package/build/types/api/defineAction.d.ts.map +1 -1
- package/build/types/api/defineCreateInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineModifyInterfaceObjectAction.d.ts.map +1 -1
- package/build/types/api/defineOntology.d.ts +1 -1
- package/build/types/api/defineOntology.d.ts.map +1 -1
- package/build/types/api/object/ObjectPropertyTypeUserDefinition.d.ts +1 -1
- package/build/types/api/object/ObjectPropertyTypeUserDefinition.d.ts.map +1 -1
- package/build/types/api/properties/PropertyTypeType.d.ts +11 -4
- package/build/types/api/properties/PropertyTypeType.d.ts.map +1 -1
- package/package.json +8 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propertyTypeTypeToOntologyIrType.js","names":["distributeTypeHelper","propertyTypeTypeToOntologyIrType","type","marking","markingType","structFields","Array","key","structDefinition","fieldTypeDefinition","field","apiName","displayMetadata","displayName","description","undefined","typeClasses","aliases","fieldType","push","struct","analyzerOverride","enableAsciiFolding","isLongText","supportsEfficientLeadingWildcard","supportsExactMatching","
|
|
1
|
+
{"version":3,"file":"propertyTypeTypeToOntologyIrType.js","names":["distributeTypeHelper","propertyTypeTypeToOntologyIrType","type","marking","markingType","structFields","Array","key","structDefinition","fieldTypeDefinition","field","apiName","displayMetadata","displayName","description","undefined","typeClasses","aliases","fieldType","push","struct","analyzerOverride","enableAsciiFolding","isLongText","supportsEfficientLeadingWildcard","supportsExactMatching","supportsFullTextRegex","precision","scale","geohash","mediaReference","geotimeSeriesReference","Error","JSON","stringify"],"sources":["propertyTypeTypeToOntologyIrType.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n OntologyIrStructFieldType,\n OntologyIrType,\n} from \"@osdk/client.unstable\";\nimport type { PropertyTypeType } from \"../../api/properties/PropertyTypeType.js\";\nimport { distributeTypeHelper } from \"../toConjure/distributeTypeHelper.js\";\n\nexport function propertyTypeTypeToOntologyIrType(\n type: PropertyTypeType,\n): OntologyIrType {\n switch (true) {\n case (typeof type === \"object\" && type.type === \"marking\"):\n return {\n \"type\": \"marking\",\n marking: { markingType: type.markingType },\n };\n\n case (typeof type === \"object\" && type.type === \"struct\"):\n const structFields: Array<OntologyIrStructFieldType> = new Array();\n for (const key in type.structDefinition) {\n const fieldTypeDefinition = type.structDefinition[key];\n let field: OntologyIrStructFieldType;\n if (typeof fieldTypeDefinition === \"string\") {\n field = {\n apiName: key,\n displayMetadata: { displayName: key, description: undefined },\n typeClasses: [],\n aliases: [],\n fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition),\n };\n } else {\n // If it is a full form type definition then process it as such\n if (\"fieldType\" in fieldTypeDefinition) {\n field = {\n ...fieldTypeDefinition,\n apiName: key,\n fieldType: propertyTypeTypeToOntologyIrType(\n fieldTypeDefinition.fieldType,\n ),\n typeClasses: fieldTypeDefinition.typeClasses ?? [],\n aliases: fieldTypeDefinition.aliases ?? [],\n };\n } else {\n field = {\n apiName: key,\n displayMetadata: { displayName: key, description: undefined },\n typeClasses: [],\n aliases: [],\n fieldType: propertyTypeTypeToOntologyIrType(fieldTypeDefinition),\n };\n }\n }\n\n structFields.push(field);\n }\n\n return {\n type: \"struct\",\n struct: { structFields },\n };\n\n case (typeof type === \"object\" && type.type === \"string\"):\n return {\n \"type\": \"string\",\n \"string\": {\n analyzerOverride: undefined,\n enableAsciiFolding: type.enableAsciiFolding,\n isLongText: type.isLongText ?? false,\n supportsEfficientLeadingWildcard:\n type.supportsEfficientLeadingWildcard ?? false,\n supportsExactMatching: type.supportsExactMatching ?? true,\n supportsFullTextRegex: type.supportsFullTextRegex,\n },\n };\n\n case (typeof type === \"object\" && type.type === \"decimal\"):\n return {\n \"type\": \"decimal\",\n \"decimal\": {\n precision: type.precision,\n scale: type.scale,\n },\n };\n\n case (type === \"geopoint\"):\n return { type: \"geohash\", geohash: {} };\n\n case (type === \"decimal\"):\n return { type, [type]: { precision: undefined, scale: undefined } };\n\n case (type === \"string\"):\n return {\n type,\n [type]: {\n analyzerOverride: undefined,\n enableAsciiFolding: undefined,\n isLongText: false,\n supportsEfficientLeadingWildcard: false,\n supportsExactMatching: true,\n },\n };\n\n case (type === \"mediaReference\"):\n return {\n type: type,\n mediaReference: {},\n };\n\n case (type === \"geotimeSeries\"):\n return {\n type: \"geotimeSeriesReference\",\n geotimeSeriesReference: {},\n };\n\n default:\n // use helper function to distribute `type` properly\n if (typeof type === \"object\") {\n throw new Error(`Unhandled exotic type: ${JSON.stringify(type)}`);\n }\n return distributeTypeHelper(type);\n }\n}\n"],"mappings":"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","ignoreList":[]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var consola = require('consola');
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var fs3 = require('fs/promises');
|
|
7
|
+
var path3 = require('path');
|
|
8
8
|
var invariant7 = require('tiny-invariant');
|
|
9
9
|
var yargs = require('yargs');
|
|
10
10
|
var helpers = require('yargs/helpers');
|
|
11
|
-
var
|
|
11
|
+
var fs2 = require('fs');
|
|
12
|
+
var typescriptSdkDocs = require('@osdk/typescript-sdk-docs');
|
|
13
|
+
var Mustache = require('mustache');
|
|
12
14
|
var crypto = require('crypto');
|
|
13
15
|
|
|
14
16
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -31,11 +33,12 @@ function _interopNamespace(e) {
|
|
|
31
33
|
return Object.freeze(n);
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
+
var fs3__namespace = /*#__PURE__*/_interopNamespace(fs3);
|
|
37
|
+
var path3__namespace = /*#__PURE__*/_interopNamespace(path3);
|
|
36
38
|
var invariant7__default = /*#__PURE__*/_interopDefault(invariant7);
|
|
37
39
|
var yargs__default = /*#__PURE__*/_interopDefault(yargs);
|
|
38
|
-
var
|
|
40
|
+
var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
|
|
41
|
+
var Mustache__default = /*#__PURE__*/_interopDefault(Mustache);
|
|
39
42
|
|
|
40
43
|
// src/cli/main.ts
|
|
41
44
|
|
|
@@ -343,7 +346,7 @@ function defineObject(objectDef) {
|
|
|
343
346
|
const allFailedValidations = validations.concat(nonExistentInterfaceProperties).filter((val) => val.type === "invalid");
|
|
344
347
|
!(allFailedValidations.length === 0) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "\n" + allFailedValidations.map(formatValidationErrors).join("\n")) : invariant7__default.default(false) : void 0;
|
|
345
348
|
});
|
|
346
|
-
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(
|
|
349
|
+
const flattenedProperties = Object.entries(objectDef.properties ?? {}).map(([apiName2, property]) => convertUserObjectPropertyType(apiName2, property));
|
|
347
350
|
const finalObject = {
|
|
348
351
|
...objectDef,
|
|
349
352
|
apiName,
|
|
@@ -383,7 +386,6 @@ function convertToPluralDisplayName(s) {
|
|
|
383
386
|
return s === void 0 || s == null ? "" : s.endsWith("s") ? uppercaseFirstLetter(s) : uppercaseFirstLetter(s) + "s";
|
|
384
387
|
}
|
|
385
388
|
function convertUserObjectPropertyType(apiName, property) {
|
|
386
|
-
property.apiName = apiName;
|
|
387
389
|
property.displayName = property.displayName ?? uppercaseFirstLetter(apiName);
|
|
388
390
|
return {
|
|
389
391
|
...property,
|
|
@@ -782,14 +784,14 @@ function distributeTypeHelper(type) {
|
|
|
782
784
|
// src/conversion/toMarketplace/propertyTypeTypeToOntologyIrType.ts
|
|
783
785
|
function propertyTypeTypeToOntologyIrType(type) {
|
|
784
786
|
switch (true) {
|
|
785
|
-
case (typeof type === "object" && "
|
|
787
|
+
case (typeof type === "object" && type.type === "marking"):
|
|
786
788
|
return {
|
|
787
789
|
"type": "marking",
|
|
788
790
|
marking: {
|
|
789
791
|
markingType: type.markingType
|
|
790
792
|
}
|
|
791
793
|
};
|
|
792
|
-
case (typeof type === "object" && "
|
|
794
|
+
case (typeof type === "object" && type.type === "struct"):
|
|
793
795
|
const structFields = new Array();
|
|
794
796
|
for (const key in type.structDefinition) {
|
|
795
797
|
const fieldTypeDefinition = type.structDefinition[key];
|
|
@@ -835,15 +837,24 @@ function propertyTypeTypeToOntologyIrType(type) {
|
|
|
835
837
|
structFields
|
|
836
838
|
}
|
|
837
839
|
};
|
|
838
|
-
case (typeof type === "object" && "
|
|
840
|
+
case (typeof type === "object" && type.type === "string"):
|
|
839
841
|
return {
|
|
840
842
|
"type": "string",
|
|
841
843
|
"string": {
|
|
842
844
|
analyzerOverride: void 0,
|
|
843
|
-
enableAsciiFolding:
|
|
844
|
-
isLongText: type.isLongText,
|
|
845
|
-
supportsEfficientLeadingWildcard: type.supportsEfficientLeadingWildcard,
|
|
846
|
-
supportsExactMatching: type.supportsExactMatching
|
|
845
|
+
enableAsciiFolding: type.enableAsciiFolding,
|
|
846
|
+
isLongText: type.isLongText ?? false,
|
|
847
|
+
supportsEfficientLeadingWildcard: type.supportsEfficientLeadingWildcard ?? false,
|
|
848
|
+
supportsExactMatching: type.supportsExactMatching ?? true,
|
|
849
|
+
supportsFullTextRegex: type.supportsFullTextRegex
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
case (typeof type === "object" && type.type === "decimal"):
|
|
853
|
+
return {
|
|
854
|
+
"type": "decimal",
|
|
855
|
+
"decimal": {
|
|
856
|
+
precision: type.precision,
|
|
857
|
+
scale: type.scale
|
|
847
858
|
}
|
|
848
859
|
};
|
|
849
860
|
case type === "geopoint":
|
|
@@ -881,6 +892,9 @@ function propertyTypeTypeToOntologyIrType(type) {
|
|
|
881
892
|
geotimeSeriesReference: {}
|
|
882
893
|
};
|
|
883
894
|
default:
|
|
895
|
+
if (typeof type === "object") {
|
|
896
|
+
throw new Error(`Unhandled exotic type: ${JSON.stringify(type)}`);
|
|
897
|
+
}
|
|
884
898
|
return distributeTypeHelper(type);
|
|
885
899
|
}
|
|
886
900
|
}
|
|
@@ -1443,6 +1457,107 @@ function getFormContentOrdering(action, parameterOrdering) {
|
|
|
1443
1457
|
return formContentOrdering;
|
|
1444
1458
|
}
|
|
1445
1459
|
|
|
1460
|
+
// src/api/code-snippets/snippetTypes.ts
|
|
1461
|
+
var interfaceSnippets = /* @__PURE__ */ (function(interfaceSnippets2) {
|
|
1462
|
+
interfaceSnippets2[interfaceSnippets2["loadInterfacesReference"] = 0] = "loadInterfacesReference";
|
|
1463
|
+
interfaceSnippets2[interfaceSnippets2["loadAllInterfacesReference"] = 1] = "loadAllInterfacesReference";
|
|
1464
|
+
interfaceSnippets2[interfaceSnippets2["loadOrderedInterfacesReference"] = 2] = "loadOrderedInterfacesReference";
|
|
1465
|
+
interfaceSnippets2[interfaceSnippets2["searchInterfacesReference"] = 3] = "searchInterfacesReference";
|
|
1466
|
+
interfaceSnippets2[interfaceSnippets2["loadInterfaceMetadataSnippet"] = 4] = "loadInterfaceMetadataSnippet";
|
|
1467
|
+
interfaceSnippets2[interfaceSnippets2["subscribeToObjectSetInstructions"] = 5] = "subscribeToObjectSetInstructions";
|
|
1468
|
+
return interfaceSnippets2;
|
|
1469
|
+
})({});
|
|
1470
|
+
var actionSnippets = /* @__PURE__ */ (function(actionSnippets2) {
|
|
1471
|
+
actionSnippets2[actionSnippets2["applyAction"] = 0] = "applyAction";
|
|
1472
|
+
actionSnippets2[actionSnippets2["batchApplyAction"] = 1] = "batchApplyAction";
|
|
1473
|
+
return actionSnippets2;
|
|
1474
|
+
})({});
|
|
1475
|
+
var objectSnippets = /* @__PURE__ */ (function(objectSnippets2) {
|
|
1476
|
+
objectSnippets2[objectSnippets2["loadSingleObjectGuide"] = 0] = "loadSingleObjectGuide";
|
|
1477
|
+
objectSnippets2[objectSnippets2["loadObjectsReference"] = 1] = "loadObjectsReference";
|
|
1478
|
+
objectSnippets2[objectSnippets2["loadAllObjectsReference"] = 2] = "loadAllObjectsReference";
|
|
1479
|
+
objectSnippets2[objectSnippets2["loadOrderedInterfacesReference"] = 3] = "loadOrderedInterfacesReference";
|
|
1480
|
+
objectSnippets2[objectSnippets2["searchObjectsGuide"] = 4] = "searchObjectsGuide";
|
|
1481
|
+
objectSnippets2[objectSnippets2["aggregationTemplate"] = 5] = "aggregationTemplate";
|
|
1482
|
+
objectSnippets2[objectSnippets2["objectSetOperationsGuide"] = 6] = "objectSetOperationsGuide";
|
|
1483
|
+
objectSnippets2[objectSnippets2["loadObjectMetadataSnippet"] = 7] = "loadObjectMetadataSnippet";
|
|
1484
|
+
objectSnippets2[objectSnippets2["subscribeToObjectSetInstructions"] = 8] = "subscribeToObjectSetInstructions";
|
|
1485
|
+
return objectSnippets2;
|
|
1486
|
+
})({});
|
|
1487
|
+
var snippetNameMapping = /* @__PURE__ */ new Map([["loadInterfaceMetadataSnippet", "Load {{interfaceName}} metadata"], ["loadInterfacesReference", "Load pages of {{interfaceName}}"], ["loadAllInterfacesReference", "Load all {{interfaceName}}"], ["loadOrderedInterfacesReference", "Load ordered {{interfaceName}}"], ["searchInterfacesReference", "Filtering"], ["subscribeToObjectSetInstructions", "Subscribe to object sets"]]);
|
|
1488
|
+
|
|
1489
|
+
// src/api/code-snippets/createCodeSnippets.ts
|
|
1490
|
+
function createCodeSnippets(ontology, packageName, outputDir) {
|
|
1491
|
+
if (outputDir === void 0) {
|
|
1492
|
+
outputDir = "./code-snippets";
|
|
1493
|
+
}
|
|
1494
|
+
if (!fs2__namespace.existsSync(outputDir)) {
|
|
1495
|
+
fs2__namespace.mkdirSync(outputDir, {
|
|
1496
|
+
recursive: true
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
if (packageName === void 0) {
|
|
1500
|
+
packageName = "";
|
|
1501
|
+
}
|
|
1502
|
+
consola.consola.info("Generating code snippets to ", outputDir);
|
|
1503
|
+
for (const type of Object.values(OntologyEntityTypeEnum)) {
|
|
1504
|
+
for (const object of Object.values(ontology[type])) {
|
|
1505
|
+
let snippet = {};
|
|
1506
|
+
switch (type) {
|
|
1507
|
+
case OntologyEntityTypeEnum.OBJECT_TYPE:
|
|
1508
|
+
snippet = generateObjectSnippet(object, packageName);
|
|
1509
|
+
break;
|
|
1510
|
+
case OntologyEntityTypeEnum.ACTION_TYPE:
|
|
1511
|
+
snippet = generateActionSnippet(object, packageName);
|
|
1512
|
+
break;
|
|
1513
|
+
case OntologyEntityTypeEnum.INTERFACE_TYPE:
|
|
1514
|
+
snippet = generateInterfaceSnippet(object, packageName);
|
|
1515
|
+
break;
|
|
1516
|
+
default:
|
|
1517
|
+
continue;
|
|
1518
|
+
}
|
|
1519
|
+
fs2__namespace.writeFileSync(path3__namespace.join(outputDir, object.apiName), JSON.stringify(snippet));
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
consola.consola.info("Finished Code Snippet Generation");
|
|
1523
|
+
}
|
|
1524
|
+
function generateInterfaceSnippet(interfaceType, packageName) {
|
|
1525
|
+
const interfaceContext = {
|
|
1526
|
+
"interfaceApiName": interfaceType.apiName,
|
|
1527
|
+
"packageName": packageName,
|
|
1528
|
+
"objectOrInterfaceApiName": interfaceType.apiName,
|
|
1529
|
+
"propertyNames": Object.keys(interfaceType.propertiesV2),
|
|
1530
|
+
"interfaceName": interfaceType.displayMetadata.displayName
|
|
1531
|
+
};
|
|
1532
|
+
return getSnippets(interfaceSnippets, interfaceContext);
|
|
1533
|
+
}
|
|
1534
|
+
function generateObjectSnippet(objectType, packageName) {
|
|
1535
|
+
const objectContext = {
|
|
1536
|
+
"objectType": objectType.apiName,
|
|
1537
|
+
"packageName": packageName,
|
|
1538
|
+
"objectOrInterfaceApiName": objectType.apiName
|
|
1539
|
+
};
|
|
1540
|
+
return getSnippets(objectSnippets, objectContext);
|
|
1541
|
+
}
|
|
1542
|
+
function generateActionSnippet(actionType, packageName) {
|
|
1543
|
+
const actionContext = {
|
|
1544
|
+
"actionApiName": actionType.apiName,
|
|
1545
|
+
"packageName": packageName
|
|
1546
|
+
};
|
|
1547
|
+
return getSnippets(actionSnippets, actionContext);
|
|
1548
|
+
}
|
|
1549
|
+
function getSnippets(snippetType, context) {
|
|
1550
|
+
const allSnippets = {};
|
|
1551
|
+
for (const templateName of Object.keys(snippetType).filter((key) => isNaN(Number(key)))) {
|
|
1552
|
+
const versions = Object.values(typescriptSdkDocs.TYPESCRIPT_OSDK_SNIPPETS.versions);
|
|
1553
|
+
const latestTemplate = versions.slice().reverse().find((v) => v.snippets[templateName])?.snippets[templateName].at(-1)?.template ?? "";
|
|
1554
|
+
const renderedTemplate = Mustache__default.default.render(latestTemplate, context);
|
|
1555
|
+
const snippetName = snippetNameMapping.get(templateName);
|
|
1556
|
+
allSnippets[snippetName !== void 0 ? Mustache__default.default.render(snippetName, context) : templateName] = renderedTemplate;
|
|
1557
|
+
}
|
|
1558
|
+
return allSnippets;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1446
1561
|
// src/api/defineOntology.ts
|
|
1447
1562
|
var ontologyDefinition;
|
|
1448
1563
|
var importedTypes;
|
|
@@ -1458,7 +1573,7 @@ function updateOntology(entity) {
|
|
|
1458
1573
|
}
|
|
1459
1574
|
ontologyDefinition[OntologyEntityTypeEnum.VALUE_TYPE][entity.apiName].push(entity);
|
|
1460
1575
|
}
|
|
1461
|
-
async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey) {
|
|
1576
|
+
async function defineOntology(ns, body, outputDir, dependencyFile, codeSnippetFiles, snippetPackageName, snippetFileOutputDir, randomnessKey) {
|
|
1462
1577
|
namespace = ns;
|
|
1463
1578
|
dependencies = {};
|
|
1464
1579
|
ontologyDefinition = {
|
|
@@ -1489,10 +1604,13 @@ async function defineOntology(ns, body, outputDir, dependencyFile, randomnessKey
|
|
|
1489
1604
|
if (dependencyFile) {
|
|
1490
1605
|
writeDependencyFile(dependencyFile);
|
|
1491
1606
|
}
|
|
1607
|
+
if (codeSnippetFiles) {
|
|
1608
|
+
createCodeSnippets(ontologyDefinition, snippetPackageName, snippetFileOutputDir);
|
|
1609
|
+
}
|
|
1492
1610
|
return convertOntologyDefinition(ontologyDefinition, randomnessKey);
|
|
1493
1611
|
}
|
|
1494
1612
|
function writeStaticObjects(outputDir) {
|
|
1495
|
-
const codegenDir =
|
|
1613
|
+
const codegenDir = path3__namespace.resolve(outputDir, "codegen");
|
|
1496
1614
|
const typeDirs = {
|
|
1497
1615
|
[OntologyEntityTypeEnum.SHARED_PROPERTY_TYPE]: "shared-property-types",
|
|
1498
1616
|
[OntologyEntityTypeEnum.ACTION_TYPE]: "action-types",
|
|
@@ -1501,31 +1619,31 @@ function writeStaticObjects(outputDir) {
|
|
|
1501
1619
|
[OntologyEntityTypeEnum.INTERFACE_TYPE]: "interface-types",
|
|
1502
1620
|
[OntologyEntityTypeEnum.VALUE_TYPE]: "value-types"
|
|
1503
1621
|
};
|
|
1504
|
-
if (!
|
|
1505
|
-
|
|
1622
|
+
if (!fs2__namespace.existsSync(codegenDir)) {
|
|
1623
|
+
fs2__namespace.mkdirSync(codegenDir, {
|
|
1506
1624
|
recursive: true
|
|
1507
1625
|
});
|
|
1508
1626
|
}
|
|
1509
1627
|
Object.values(typeDirs).forEach((typeDirNameFromMap) => {
|
|
1510
|
-
const currentTypeDirPath =
|
|
1511
|
-
if (
|
|
1512
|
-
|
|
1628
|
+
const currentTypeDirPath = path3__namespace.join(codegenDir, typeDirNameFromMap);
|
|
1629
|
+
if (fs2__namespace.existsSync(currentTypeDirPath)) {
|
|
1630
|
+
fs2__namespace.rmSync(currentTypeDirPath, {
|
|
1513
1631
|
recursive: true,
|
|
1514
1632
|
force: true
|
|
1515
1633
|
});
|
|
1516
1634
|
}
|
|
1517
|
-
|
|
1635
|
+
fs2__namespace.mkdirSync(currentTypeDirPath, {
|
|
1518
1636
|
recursive: true
|
|
1519
1637
|
});
|
|
1520
1638
|
});
|
|
1521
1639
|
const topLevelExportStatements = [];
|
|
1522
1640
|
Object.entries(ontologyDefinition).forEach(([ontologyTypeEnumKey, entities]) => {
|
|
1523
1641
|
const typeDirName = typeDirs[ontologyTypeEnumKey];
|
|
1524
|
-
const typeDirPath =
|
|
1642
|
+
const typeDirPath = path3__namespace.join(codegenDir, typeDirName);
|
|
1525
1643
|
const entityModuleNames = [];
|
|
1526
1644
|
Object.entries(entities).forEach(([apiName, entity]) => {
|
|
1527
1645
|
const entityFileNameBase = camel(withoutNamespace(apiName)) + (ontologyTypeEnumKey === OntologyEntityTypeEnum.VALUE_TYPE ? "ValueType" : "");
|
|
1528
|
-
const filePath =
|
|
1646
|
+
const filePath = path3__namespace.join(typeDirPath, `${entityFileNameBase}.ts`);
|
|
1529
1647
|
const entityTypeName = getEntityTypeName(ontologyTypeEnumKey);
|
|
1530
1648
|
const entityJSON = JSON.stringify(entity, null, 2).replace(/("__type"\s*:\s*)"([^"]*)"/g, (_, prefix, value) => `${prefix}OntologyEntityTypeEnum.${value}`);
|
|
1531
1649
|
const content = `
|
|
@@ -1537,7 +1655,7 @@ const ${entityFileNameBase}_base: ${entityTypeName} = ${ontologyTypeEnumKey ===
|
|
|
1537
1655
|
|
|
1538
1656
|
export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFileNameBase}_base);
|
|
1539
1657
|
`;
|
|
1540
|
-
|
|
1658
|
+
fs2__namespace.writeFileSync(filePath, content, {
|
|
1541
1659
|
flag: "w"
|
|
1542
1660
|
});
|
|
1543
1661
|
entityModuleNames.push(entityFileNameBase);
|
|
@@ -1548,8 +1666,8 @@ export const ${entityFileNameBase}: ${entityTypeName} = wrapWithProxy(${entityFi
|
|
|
1548
1666
|
});
|
|
1549
1667
|
if (topLevelExportStatements.length > 0) {
|
|
1550
1668
|
const mainIndexContent = dependencyInjectionString() + topLevelExportStatements.join("\n") + "\n";
|
|
1551
|
-
const mainIndexFilePath =
|
|
1552
|
-
|
|
1669
|
+
const mainIndexFilePath = path3__namespace.join(outputDir, "index.ts");
|
|
1670
|
+
fs2__namespace.writeFileSync(mainIndexFilePath, mainIndexContent, {
|
|
1553
1671
|
flag: "w"
|
|
1554
1672
|
});
|
|
1555
1673
|
}
|
|
@@ -1905,7 +2023,7 @@ function getEntityTypeName(type) {
|
|
|
1905
2023
|
}[type];
|
|
1906
2024
|
}
|
|
1907
2025
|
function writeDependencyFile(dependencyFile) {
|
|
1908
|
-
|
|
2026
|
+
fs2__namespace.writeFileSync(dependencyFile, JSON.stringify(dependencies, null, 2));
|
|
1909
2027
|
}
|
|
1910
2028
|
function dependencyInjectionString() {
|
|
1911
2029
|
const namespaceNoDot = namespace.endsWith(".") ? namespace.slice(0, -1) : namespace;
|
|
@@ -1922,20 +2040,20 @@ function addNamespaceIfNone(apiName) {
|
|
|
1922
2040
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
1923
2041
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
1924
2042
|
async function main(args = process.argv) {
|
|
1925
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-
|
|
2043
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-rc.16").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
1926
2044
|
input: {
|
|
1927
2045
|
alias: "i",
|
|
1928
2046
|
describe: "Input file",
|
|
1929
2047
|
type: "string",
|
|
1930
2048
|
default: ".ontology/ontology.ts",
|
|
1931
|
-
coerce:
|
|
2049
|
+
coerce: path3__namespace.resolve
|
|
1932
2050
|
},
|
|
1933
2051
|
output: {
|
|
1934
2052
|
alias: "o",
|
|
1935
2053
|
describe: "Output file",
|
|
1936
2054
|
type: "string",
|
|
1937
2055
|
default: "ontology.json",
|
|
1938
|
-
coerce:
|
|
2056
|
+
coerce: path3__namespace.resolve
|
|
1939
2057
|
},
|
|
1940
2058
|
apiNamespace: {
|
|
1941
2059
|
describe: "Api name prefix for namespaced ontology types",
|
|
@@ -1947,29 +2065,45 @@ async function main(args = process.argv) {
|
|
|
1947
2065
|
describe: "Snapshot directory",
|
|
1948
2066
|
type: "string",
|
|
1949
2067
|
default: "snapshots",
|
|
1950
|
-
coerce:
|
|
2068
|
+
coerce: path3__namespace.resolve
|
|
1951
2069
|
},
|
|
1952
2070
|
outputDir: {
|
|
1953
2071
|
alias: "d",
|
|
1954
2072
|
describe: "Directory for generated ontology entities",
|
|
1955
2073
|
type: "string",
|
|
1956
|
-
coerce:
|
|
2074
|
+
coerce: path3__namespace.resolve
|
|
1957
2075
|
},
|
|
1958
2076
|
valueTypesOutput: {
|
|
1959
2077
|
describe: "Value Type Output File",
|
|
1960
2078
|
type: "string",
|
|
1961
2079
|
default: "value-types.json",
|
|
1962
|
-
coerce:
|
|
2080
|
+
coerce: path3__namespace.resolve
|
|
1963
2081
|
},
|
|
1964
2082
|
dependencies: {
|
|
1965
2083
|
describe: "File to write dependencies to",
|
|
1966
2084
|
type: "string",
|
|
1967
|
-
coerce:
|
|
2085
|
+
coerce: path3__namespace.resolve
|
|
2086
|
+
},
|
|
2087
|
+
generateCodeSnippets: {
|
|
2088
|
+
describe: "Enable code snippet files creation",
|
|
2089
|
+
type: "boolean",
|
|
2090
|
+
default: false
|
|
2091
|
+
},
|
|
2092
|
+
codeSnippetPackageName: {
|
|
2093
|
+
describe: "The package name that will be displayed in the code snippets",
|
|
2094
|
+
default: "",
|
|
2095
|
+
type: "string"
|
|
2096
|
+
},
|
|
2097
|
+
codeSnippetDir: {
|
|
2098
|
+
describe: "Directory for generated code snippet files",
|
|
2099
|
+
type: "string",
|
|
2100
|
+
default: "./",
|
|
2101
|
+
coerce: path3__namespace.resolve
|
|
1968
2102
|
},
|
|
1969
2103
|
randomnessKey: {
|
|
1970
2104
|
describe: "Value used to assure uniqueness of entities",
|
|
1971
2105
|
type: "string",
|
|
1972
|
-
coerce:
|
|
2106
|
+
coerce: path3__namespace.resolve
|
|
1973
2107
|
}
|
|
1974
2108
|
}).parseAsync();
|
|
1975
2109
|
let apiNamespace = "";
|
|
@@ -1979,38 +2113,41 @@ async function main(args = process.argv) {
|
|
|
1979
2113
|
!apiNamespaceRegex.test(apiNamespace) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "API namespace is invalid! It is expected to conform to ^[a-z0-9-]+(.[a-z0-9-]+)*.$") : invariant7__default.default(false) : void 0;
|
|
1980
2114
|
}
|
|
1981
2115
|
consola.consola.info(`Loading ontology from ${commandLineOpts.input}`);
|
|
2116
|
+
if (!commandLineOpts.generateCodeSnippets && (commandLineOpts.codeSnippetPackageName !== "" || commandLineOpts.codeSnippetDir !== path3__namespace.resolve("./"))) {
|
|
2117
|
+
consola.consola.info("Package name and/or directory supplied for code snippets, but code snippet generation is false.");
|
|
2118
|
+
}
|
|
1982
2119
|
if (commandLineOpts.randomnessKey !== void 0) {
|
|
1983
2120
|
!uuidRegex.test(commandLineOpts.randomnessKey) ? process.env.NODE_ENV !== "production" ? invariant7__default.default(false, "Supplied randomness key is not a uuid and shouldn't be used as a uniqueness guarantee") : invariant7__default.default(false) : void 0;
|
|
1984
2121
|
}
|
|
1985
|
-
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.randomnessKey);
|
|
2122
|
+
const ontologyIr = await loadOntology(commandLineOpts.input, apiNamespace, commandLineOpts.outputDir, commandLineOpts.dependencies, commandLineOpts.generateCodeSnippets, commandLineOpts.codeSnippetPackageName, commandLineOpts.codeSnippetDir, commandLineOpts.randomnessKey);
|
|
1986
2123
|
consola.consola.info(`Saving ontology to ${commandLineOpts.output}`);
|
|
1987
|
-
await
|
|
2124
|
+
await fs3__namespace.writeFile(commandLineOpts.output, JSON.stringify(ontologyIr, null, 2));
|
|
1988
2125
|
if (ontologyIr.valueTypes.valueTypes.length > 0 || ontologyIr.importedValueTypes.valueTypes.length > 0) {
|
|
1989
|
-
await
|
|
2126
|
+
await fs3__namespace.writeFile(commandLineOpts.valueTypesOutput, JSON.stringify(ontologyIr.valueTypes, null, 2));
|
|
1990
2127
|
}
|
|
1991
2128
|
}
|
|
1992
|
-
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, randomnessKey) {
|
|
1993
|
-
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, randomnessKey);
|
|
2129
|
+
async function loadOntology(input, apiNamespace, outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey) {
|
|
2130
|
+
const q = await defineOntology(apiNamespace, async () => await import(input), outputDir, dependencyFile, generateCodeSnippets, snippetPackageName, codeSnippetDir, randomnessKey);
|
|
1994
2131
|
return q;
|
|
1995
2132
|
}
|
|
1996
2133
|
var MAX_SEARCH_DEPTH = 5;
|
|
1997
2134
|
function addDependency(namespaceNoDot, fileInPackage) {
|
|
1998
|
-
let dir =
|
|
2135
|
+
let dir = path3__namespace.dirname(fileInPackage);
|
|
1999
2136
|
let packageJsonPath = null;
|
|
2000
2137
|
for (let i = 0; i < MAX_SEARCH_DEPTH; i++) {
|
|
2001
|
-
const candidate =
|
|
2002
|
-
if (
|
|
2138
|
+
const candidate = path3__namespace.join(dir, "package.json");
|
|
2139
|
+
if (fs2__namespace.existsSync(candidate)) {
|
|
2003
2140
|
packageJsonPath = candidate;
|
|
2004
2141
|
break;
|
|
2005
2142
|
}
|
|
2006
|
-
const parentDir =
|
|
2143
|
+
const parentDir = path3__namespace.dirname(dir);
|
|
2007
2144
|
if (parentDir === dir) break;
|
|
2008
2145
|
dir = parentDir;
|
|
2009
2146
|
}
|
|
2010
2147
|
if (!packageJsonPath) {
|
|
2011
2148
|
throw new Error(`Could not find a package.json within ${MAX_SEARCH_DEPTH} parent directories of ${fileInPackage}`);
|
|
2012
2149
|
}
|
|
2013
|
-
const packageJson = JSON.parse(
|
|
2150
|
+
const packageJson = JSON.parse(fs2__namespace.readFileSync(packageJsonPath, "utf-8"));
|
|
2014
2151
|
dependencies[namespaceNoDot] = packageJson.version ?? "";
|
|
2015
2152
|
}
|
|
2016
2153
|
|
|
@@ -2601,8 +2738,14 @@ function addNamespaceToActionDefinition(def) {
|
|
|
2601
2738
|
}));
|
|
2602
2739
|
}
|
|
2603
2740
|
function getInterfaceParameterName(def, parameter) {
|
|
2741
|
+
if (def.useNonNamespacedParameters) {
|
|
2742
|
+
return getNonNamespacedParameterName(def, parameter);
|
|
2743
|
+
}
|
|
2604
2744
|
return isTargetParameter(parameter) || !Object.keys(def.interfaceType.propertiesV2).includes(addNamespaceIfNone(parameter)) ? parameter : addNamespaceIfNone(parameter);
|
|
2605
2745
|
}
|
|
2746
|
+
function getNonNamespacedParameterName(def, parameter) {
|
|
2747
|
+
return def.conflictingParameterOverrides?.[parameter] ?? (parameter.split(".").pop() || parameter);
|
|
2748
|
+
}
|
|
2606
2749
|
function convertMappingValue(value) {
|
|
2607
2750
|
switch (value.type) {
|
|
2608
2751
|
case "uuid":
|
|
@@ -2632,8 +2775,9 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2632
2775
|
addNamespaceToActionDefinition(def);
|
|
2633
2776
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
2634
2777
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
2635
|
-
const
|
|
2636
|
-
const parameterNames = new Set(
|
|
2778
|
+
const sptNames = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
|
|
2779
|
+
const parameterNames = new Set(sptNames.map((apiName) => getInterfaceParameterName(def, apiName)));
|
|
2780
|
+
const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop.sharedPropertyType]));
|
|
2637
2781
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
2638
2782
|
parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
2639
2783
|
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)}`}`;
|
|
@@ -2643,7 +2787,7 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2643
2787
|
}
|
|
2644
2788
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2645
2789
|
}
|
|
2646
|
-
const parameters = createParameters(def,
|
|
2790
|
+
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
2647
2791
|
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2648
2792
|
return defineAction({
|
|
2649
2793
|
apiName: actionApiName,
|
|
@@ -2662,15 +2806,15 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2662
2806
|
interfaceApiName: def.interfaceType.apiName,
|
|
2663
2807
|
objectTypeParameter: CREATE_INTERFACE_OBJECT_PARAMETER,
|
|
2664
2808
|
sharedPropertyValues: {
|
|
2665
|
-
...Object.fromEntries(
|
|
2809
|
+
...Object.fromEntries(sptNames.map((id) => [id, {
|
|
2666
2810
|
type: "parameterId",
|
|
2667
|
-
parameterId: id
|
|
2811
|
+
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
2668
2812
|
}])),
|
|
2669
2813
|
...mappings
|
|
2670
2814
|
}
|
|
2671
2815
|
}
|
|
2672
2816
|
}],
|
|
2673
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def,
|
|
2817
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Array.from(parameterNames), parameters, CREATE_INTERFACE_OBJECT_PARAMETER),
|
|
2674
2818
|
...def.actionLevelValidation ? {
|
|
2675
2819
|
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2676
2820
|
} : {},
|
|
@@ -2862,8 +3006,8 @@ function defineDeleteInterfaceObjectAction(def) {
|
|
|
2862
3006
|
}
|
|
2863
3007
|
}],
|
|
2864
3008
|
entities: {
|
|
2865
|
-
affectedInterfaceTypes: [],
|
|
2866
|
-
affectedObjectTypes: [
|
|
3009
|
+
affectedInterfaceTypes: [def.interfaceType.apiName],
|
|
3010
|
+
affectedObjectTypes: [],
|
|
2867
3011
|
affectedLinkTypes: [],
|
|
2868
3012
|
typeGroups: []
|
|
2869
3013
|
}
|
|
@@ -3121,8 +3265,9 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3121
3265
|
addNamespaceToActionDefinition(def);
|
|
3122
3266
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
3123
3267
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
3124
|
-
const
|
|
3125
|
-
const parameterNames = new Set(
|
|
3268
|
+
const sptNames = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
|
|
3269
|
+
const parameterNames = new Set(sptNames.map((apiName) => getInterfaceParameterName(def, apiName)));
|
|
3270
|
+
const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop.sharedPropertyType]));
|
|
3126
3271
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
3127
3272
|
parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
3128
3273
|
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)}`}`;
|
|
@@ -3132,7 +3277,7 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3132
3277
|
}
|
|
3133
3278
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3134
3279
|
}
|
|
3135
|
-
const parameters = createParameters(def,
|
|
3280
|
+
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
3136
3281
|
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
3137
3282
|
return defineAction({
|
|
3138
3283
|
apiName: actionApiName,
|
|
@@ -3150,15 +3295,15 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3150
3295
|
modifyInterfaceRule: {
|
|
3151
3296
|
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
3152
3297
|
sharedPropertyValues: {
|
|
3153
|
-
...Object.fromEntries(
|
|
3298
|
+
...Object.fromEntries(sptNames.map((id) => [id, {
|
|
3154
3299
|
type: "parameterId",
|
|
3155
|
-
parameterId: id
|
|
3300
|
+
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
3156
3301
|
}])),
|
|
3157
3302
|
...mappings
|
|
3158
3303
|
}
|
|
3159
3304
|
}
|
|
3160
3305
|
}],
|
|
3161
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def,
|
|
3306
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Array.from(parameterNames), parameters, MODIFY_INTERFACE_OBJECT_PARAMETER),
|
|
3162
3307
|
...def.actionLevelValidation ? {
|
|
3163
3308
|
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3164
3309
|
} : {},
|