@osdk/maker 0.14.0-beta.12 → 0.14.0-beta.14
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 +22 -0
- package/build/browser/api/code-snippets/createCodeSnippets.js +7 -4
- package/build/browser/api/code-snippets/createCodeSnippets.js.map +1 -1
- package/build/browser/api/code-snippets/snippetTypes.js +1 -0
- package/build/browser/api/code-snippets/snippetTypes.js.map +1 -1
- 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/defineModifyInterfaceObjectAction.js +8 -7
- package/build/browser/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/browser/api/test/actions.test.js +1243 -1
- package/build/browser/api/test/actions.test.js.map +1 -1
- package/build/browser/cli/main.js +1 -1
- package/build/cjs/index.cjs +28 -16
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +2 -0
- package/build/esm/api/code-snippets/createCodeSnippets.js +7 -4
- package/build/esm/api/code-snippets/createCodeSnippets.js.map +1 -1
- package/build/esm/api/code-snippets/snippetTypes.js +1 -0
- package/build/esm/api/code-snippets/snippetTypes.js.map +1 -1
- 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/defineModifyInterfaceObjectAction.js +8 -7
- package/build/esm/api/defineModifyInterfaceObjectAction.js.map +1 -1
- package/build/esm/api/test/actions.test.js +1243 -1
- package/build/esm/api/test/actions.test.js.map +1 -1
- package/build/esm/cli/main.js +1 -1
- package/build/types/api/code-snippets/createCodeSnippets.d.ts.map +1 -1
- package/build/types/api/code-snippets/snippetTypes.d.ts +1 -0
- package/build/types/api/code-snippets/snippetTypes.d.ts.map +1 -1
- 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/package.json +3 -3
|
@@ -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.
|
|
27
|
+
const commandLineOpts = await yargs(hideBin(args)).version("0.14.0-beta.14" ?? "").wrap(Math.min(150, yargs().terminalWidth())).strict().help().options({
|
|
28
28
|
input: {
|
|
29
29
|
alias: "i",
|
|
30
30
|
describe: "Input file",
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1485,6 +1485,7 @@ var objectSnippets = /* @__PURE__ */ (function(objectSnippets2) {
|
|
|
1485
1485
|
objectSnippets2[objectSnippets2["subscribeToObjectSetInstructions"] = 8] = "subscribeToObjectSetInstructions";
|
|
1486
1486
|
return objectSnippets2;
|
|
1487
1487
|
})({});
|
|
1488
|
+
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
|
|
|
1489
1490
|
// src/api/code-snippets/createCodeSnippets.ts
|
|
1490
1491
|
function createCodeSnippets(ontology, packageName, outputDir) {
|
|
@@ -1526,7 +1527,8 @@ function generateInterfaceSnippet(interfaceType, packageName) {
|
|
|
1526
1527
|
"interfaceApiName": interfaceType.apiName,
|
|
1527
1528
|
"packageName": packageName,
|
|
1528
1529
|
"objectOrInterfaceApiName": interfaceType.apiName,
|
|
1529
|
-
"propertyNames": Object.keys(interfaceType.propertiesV2)
|
|
1530
|
+
"propertyNames": Object.keys(interfaceType.propertiesV2),
|
|
1531
|
+
"interfaceName": interfaceType.displayMetadata.displayName
|
|
1530
1532
|
};
|
|
1531
1533
|
return getSnippets(interfaceSnippets, interfaceContext);
|
|
1532
1534
|
}
|
|
@@ -1548,9 +1550,11 @@ function generateActionSnippet(actionType, packageName) {
|
|
|
1548
1550
|
function getSnippets(snippetType, context) {
|
|
1549
1551
|
const allSnippets = {};
|
|
1550
1552
|
for (const templateName of Object.keys(snippetType).filter((key) => isNaN(Number(key)))) {
|
|
1551
|
-
const
|
|
1553
|
+
const versions = Object.values(typescriptSdkDocs.TYPESCRIPT_OSDK_SNIPPETS.versions);
|
|
1554
|
+
const latestTemplate = versions.slice().reverse().find((v) => v.snippets[templateName])?.snippets[templateName].at(-1)?.template ?? "";
|
|
1552
1555
|
const renderedTemplate = Mustache__default.default.render(latestTemplate, context);
|
|
1553
|
-
|
|
1556
|
+
const snippetName = snippetNameMapping.get(templateName);
|
|
1557
|
+
allSnippets[snippetName !== void 0 ? Mustache__default.default.render(snippetName, context) : templateName] = renderedTemplate;
|
|
1554
1558
|
}
|
|
1555
1559
|
return allSnippets;
|
|
1556
1560
|
}
|
|
@@ -2037,7 +2041,7 @@ function addNamespaceIfNone(apiName) {
|
|
|
2037
2041
|
var apiNamespaceRegex = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.$/;
|
|
2038
2042
|
var uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
2039
2043
|
async function main(args = process.argv) {
|
|
2040
|
-
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.
|
|
2044
|
+
const commandLineOpts = await yargs__default.default(helpers.hideBin(args)).version("0.14.0-beta.14").wrap(Math.min(150, yargs__default.default().terminalWidth())).strict().help().options({
|
|
2041
2045
|
input: {
|
|
2042
2046
|
alias: "i",
|
|
2043
2047
|
describe: "Input file",
|
|
@@ -2735,8 +2739,14 @@ function addNamespaceToActionDefinition(def) {
|
|
|
2735
2739
|
}));
|
|
2736
2740
|
}
|
|
2737
2741
|
function getInterfaceParameterName(def, parameter) {
|
|
2742
|
+
if (def.useNonNamespacedParameters) {
|
|
2743
|
+
return getNonNamespacedParameterName(def, parameter);
|
|
2744
|
+
}
|
|
2738
2745
|
return isTargetParameter(parameter) || !Object.keys(def.interfaceType.propertiesV2).includes(addNamespaceIfNone(parameter)) ? parameter : addNamespaceIfNone(parameter);
|
|
2739
2746
|
}
|
|
2747
|
+
function getNonNamespacedParameterName(def, parameter) {
|
|
2748
|
+
return def.conflictingParameterOverrides?.[parameter] ?? (parameter.split(".").pop() || parameter);
|
|
2749
|
+
}
|
|
2740
2750
|
function convertMappingValue(value) {
|
|
2741
2751
|
switch (value.type) {
|
|
2742
2752
|
case "uuid":
|
|
@@ -2766,8 +2776,9 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2766
2776
|
addNamespaceToActionDefinition(def);
|
|
2767
2777
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
2768
2778
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
2769
|
-
const
|
|
2770
|
-
const parameterNames = new Set(
|
|
2779
|
+
const sptNames = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
|
|
2780
|
+
const parameterNames = new Set(sptNames.map((apiName) => getInterfaceParameterName(def, apiName)));
|
|
2781
|
+
const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop.sharedPropertyType]));
|
|
2771
2782
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
2772
2783
|
parameterNames.add(CREATE_INTERFACE_OBJECT_PARAMETER);
|
|
2773
2784
|
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)}`}`;
|
|
@@ -2777,7 +2788,7 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2777
2788
|
}
|
|
2778
2789
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
2779
2790
|
}
|
|
2780
|
-
const parameters = createParameters(def,
|
|
2791
|
+
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
2781
2792
|
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
2782
2793
|
return defineAction({
|
|
2783
2794
|
apiName: actionApiName,
|
|
@@ -2796,15 +2807,15 @@ function defineCreateInterfaceObjectAction(def) {
|
|
|
2796
2807
|
interfaceApiName: def.interfaceType.apiName,
|
|
2797
2808
|
objectTypeParameter: CREATE_INTERFACE_OBJECT_PARAMETER,
|
|
2798
2809
|
sharedPropertyValues: {
|
|
2799
|
-
...Object.fromEntries(
|
|
2810
|
+
...Object.fromEntries(sptNames.map((id) => [id, {
|
|
2800
2811
|
type: "parameterId",
|
|
2801
|
-
parameterId: id
|
|
2812
|
+
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
2802
2813
|
}])),
|
|
2803
2814
|
...mappings
|
|
2804
2815
|
}
|
|
2805
2816
|
}
|
|
2806
2817
|
}],
|
|
2807
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def,
|
|
2818
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Array.from(parameterNames), parameters, CREATE_INTERFACE_OBJECT_PARAMETER),
|
|
2808
2819
|
...def.actionLevelValidation ? {
|
|
2809
2820
|
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
2810
2821
|
} : {},
|
|
@@ -3255,8 +3266,9 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3255
3266
|
addNamespaceToActionDefinition(def);
|
|
3256
3267
|
const allProperties = getFlattenedInterfaceProperties(def.interfaceType);
|
|
3257
3268
|
validateActionParameters(def, Object.keys(allProperties), def.interfaceType.apiName);
|
|
3258
|
-
const
|
|
3259
|
-
const parameterNames = new Set(
|
|
3269
|
+
const sptNames = Object.keys(allProperties).filter((apiName) => isPropertyParameter(def, apiName, allProperties[apiName].sharedPropertyType.type));
|
|
3270
|
+
const parameterNames = new Set(sptNames.map((apiName) => getInterfaceParameterName(def, apiName)));
|
|
3271
|
+
const propertyMap = Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [getInterfaceParameterName(def, id), prop.sharedPropertyType]));
|
|
3260
3272
|
Object.keys(def.parameterConfiguration ?? {}).forEach((param) => parameterNames.add(getInterfaceParameterName(def, param)));
|
|
3261
3273
|
parameterNames.add(MODIFY_INTERFACE_OBJECT_PARAMETER);
|
|
3262
3274
|
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)}`}`;
|
|
@@ -3266,7 +3278,7 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3266
3278
|
}
|
|
3267
3279
|
validateParameterOrdering(def.parameterOrdering, parameterNames, actionApiName);
|
|
3268
3280
|
}
|
|
3269
|
-
const parameters = createParameters(def,
|
|
3281
|
+
const parameters = createParameters(def, propertyMap, parameterNames, Object.fromEntries(Object.entries(allProperties).map(([id, prop]) => [id, prop.required])));
|
|
3270
3282
|
const mappings = Object.fromEntries(Object.entries(def.nonParameterMappings ?? {}).map(([id, value]) => [id, convertMappingValue(value)]));
|
|
3271
3283
|
return defineAction({
|
|
3272
3284
|
apiName: actionApiName,
|
|
@@ -3284,15 +3296,15 @@ function defineModifyInterfaceObjectAction(def) {
|
|
|
3284
3296
|
modifyInterfaceRule: {
|
|
3285
3297
|
interfaceObjectToModifyParameter: "interfaceObjectToModifyParameter",
|
|
3286
3298
|
sharedPropertyValues: {
|
|
3287
|
-
...Object.fromEntries(
|
|
3299
|
+
...Object.fromEntries(sptNames.map((id) => [id, {
|
|
3288
3300
|
type: "parameterId",
|
|
3289
|
-
parameterId: id
|
|
3301
|
+
parameterId: def.useNonNamespacedParameters ? getNonNamespacedParameterName(def, id) : id
|
|
3290
3302
|
}])),
|
|
3291
3303
|
...mappings
|
|
3292
3304
|
}
|
|
3293
3305
|
}
|
|
3294
3306
|
}],
|
|
3295
|
-
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def,
|
|
3307
|
+
parameterOrdering: def.parameterOrdering ?? createDefaultParameterOrdering(def, Array.from(parameterNames), parameters, MODIFY_INTERFACE_OBJECT_PARAMETER),
|
|
3296
3308
|
...def.actionLevelValidation ? {
|
|
3297
3309
|
validation: convertValidationRule(def.actionLevelValidation, parameters)
|
|
3298
3310
|
} : {},
|