@microsoft/power-apps-cli 0.6.0 → 0.6.4
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/lib/ArgumentProvider.d.ts.map +1 -1
- package/lib/ArgumentProvider.js +11 -7
- package/lib/ArgumentProvider.js.map +1 -1
- package/lib/Authentication/NodeMsalAuthenticationProvider.d.ts +4 -1
- package/lib/Authentication/NodeMsalAuthenticationProvider.d.ts.map +1 -1
- package/lib/Authentication/NodeMsalAuthenticationProvider.js +5 -1
- package/lib/Authentication/NodeMsalAuthenticationProvider.js.map +1 -1
- package/lib/Authentication/PacCliAuthenticationProvider.d.ts +2 -1
- package/lib/Authentication/PacCliAuthenticationProvider.d.ts.map +1 -1
- package/lib/Authentication/PacCliAuthenticationProvider.js +1 -1
- package/lib/Authentication/PacCliAuthenticationProvider.js.map +1 -1
- package/lib/Authentication/ServicePrincipalAuthenticationProvider.d.ts +3 -1
- package/lib/Authentication/ServicePrincipalAuthenticationProvider.d.ts.map +1 -1
- package/lib/Authentication/ServicePrincipalAuthenticationProvider.js +4 -2
- package/lib/Authentication/ServicePrincipalAuthenticationProvider.js.map +1 -1
- package/lib/Cli.d.ts.map +1 -1
- package/lib/Cli.js +1 -2
- package/lib/Cli.js.map +1 -1
- package/lib/CliUtils.d.ts +1 -1
- package/lib/CliUtils.d.ts.map +1 -1
- package/lib/CliUtils.js +36 -9
- package/lib/CliUtils.js.map +1 -1
- package/lib/HttpClient/CliHttpClient.d.ts.map +1 -1
- package/lib/HttpClient/CliHttpClient.js +2 -1
- package/lib/HttpClient/CliHttpClient.js.map +1 -1
- package/lib/Types/Cli.types.d.ts +2 -1
- package/lib/Types/Cli.types.d.ts.map +1 -1
- package/lib/Utils/EnhanceNetworkError.d.ts +14 -0
- package/lib/Utils/EnhanceNetworkError.d.ts.map +1 -0
- package/lib/Utils/EnhanceNetworkError.js +59 -0
- package/lib/Utils/EnhanceNetworkError.js.map +1 -0
- package/lib/Verbs/Init.d.ts.map +1 -1
- package/lib/Verbs/Init.js +3 -0
- package/lib/Verbs/Init.js.map +1 -1
- package/lib/__tests__/E2eTests/basicSetup/loggingConfiguration.test.d.ts +5 -0
- package/lib/__tests__/E2eTests/basicSetup/loggingConfiguration.test.d.ts.map +1 -0
- package/lib/__tests__/E2eTests/basicSetup/loggingConfiguration.test.js +246 -0
- package/lib/__tests__/E2eTests/basicSetup/loggingConfiguration.test.js.map +1 -0
- package/lib/__tests__/E2eTests/cliUsability/cliHelp.test.d.ts +5 -0
- package/lib/__tests__/E2eTests/cliUsability/cliHelp.test.d.ts.map +1 -0
- package/lib/__tests__/E2eTests/cliUsability/cliHelp.test.js +162 -0
- package/lib/__tests__/E2eTests/cliUsability/cliHelp.test.js.map +1 -0
- package/lib/__tests__/E2eTests/cliUsability/logoutReauth.test.d.ts +5 -0
- package/lib/__tests__/E2eTests/cliUsability/logoutReauth.test.d.ts.map +1 -0
- package/lib/__tests__/E2eTests/cliUsability/logoutReauth.test.js +115 -0
- package/lib/__tests__/E2eTests/cliUsability/logoutReauth.test.js.map +1 -0
- package/lib/__tests__/E2eTests/cliUsability/missingParameters.test.d.ts +5 -0
- package/lib/__tests__/E2eTests/cliUsability/missingParameters.test.d.ts.map +1 -0
- package/lib/__tests__/E2eTests/cliUsability/missingParameters.test.js +189 -0
- package/lib/__tests__/E2eTests/cliUsability/missingParameters.test.js.map +1 -0
- package/lib/__tests__/E2eTests/commonUserWorkflowSmokeTest.test.js +8 -6
- package/lib/__tests__/E2eTests/commonUserWorkflowSmokeTest.test.js.map +1 -1
- package/lib/__tests__/E2eTests/e2eConfig.d.ts +95 -0
- package/lib/__tests__/E2eTests/e2eConfig.d.ts.map +1 -0
- package/lib/__tests__/E2eTests/e2eConfig.js +122 -0
- package/lib/__tests__/E2eTests/e2eConfig.js.map +1 -0
- package/lib/__tests__/UnitTests/CliUtils.spec.d.ts +5 -0
- package/lib/__tests__/UnitTests/CliUtils.spec.d.ts.map +1 -0
- package/lib/__tests__/UnitTests/CliUtils.spec.js +94 -0
- package/lib/__tests__/UnitTests/CliUtils.spec.js.map +1 -0
- package/lib/__tests__/UnitTests/ServicePrincipalAuthenticationProvider.spec.js +3 -3
- package/lib/__tests__/UnitTests/ServicePrincipalAuthenticationProvider.spec.js.map +1 -1
- package/lib/__tests__/UnitTests/enhanceNetworkError.test.d.ts +5 -0
- package/lib/__tests__/UnitTests/enhanceNetworkError.test.d.ts.map +1 -0
- package/lib/__tests__/UnitTests/enhanceNetworkError.test.js +177 -0
- package/lib/__tests__/UnitTests/enhanceNetworkError.test.js.map +1 -0
- package/lib/__tests__/helpers/e2eTestHelpers.d.ts.map +1 -1
- package/lib/__tests__/helpers/e2eTestHelpers.js +16 -0
- package/lib/__tests__/helpers/e2eTestHelpers.js.map +1 -1
- package/lib/__tests__/helpers/testHelpers.d.ts +146 -30
- package/lib/__tests__/helpers/testHelpers.d.ts.map +1 -1
- package/lib/__tests__/helpers/testHelpers.js +245 -74
- package/lib/__tests__/helpers/testHelpers.js.map +1 -1
- package/lib-cjs/ArgumentProvider.d.ts.map +1 -1
- package/lib-cjs/ArgumentProvider.js +7 -1
- package/lib-cjs/ArgumentProvider.js.map +1 -1
- package/lib-cjs/Authentication/NodeMsalAuthenticationProvider.d.ts +4 -1
- package/lib-cjs/Authentication/NodeMsalAuthenticationProvider.d.ts.map +1 -1
- package/lib-cjs/Authentication/NodeMsalAuthenticationProvider.js +4 -1
- package/lib-cjs/Authentication/NodeMsalAuthenticationProvider.js.map +1 -1
- package/lib-cjs/Authentication/PacCliAuthenticationProvider.d.ts +2 -1
- package/lib-cjs/Authentication/PacCliAuthenticationProvider.d.ts.map +1 -1
- package/lib-cjs/Authentication/PacCliAuthenticationProvider.js +1 -1
- package/lib-cjs/Authentication/PacCliAuthenticationProvider.js.map +1 -1
- package/lib-cjs/Authentication/ServicePrincipalAuthenticationProvider.d.ts +3 -1
- package/lib-cjs/Authentication/ServicePrincipalAuthenticationProvider.d.ts.map +1 -1
- package/lib-cjs/Authentication/ServicePrincipalAuthenticationProvider.js +4 -2
- package/lib-cjs/Authentication/ServicePrincipalAuthenticationProvider.js.map +1 -1
- package/lib-cjs/Cli.d.ts.map +1 -1
- package/lib-cjs/Cli.js +14 -18
- package/lib-cjs/Cli.js.map +1 -1
- package/lib-cjs/CliUtils.d.ts +1 -1
- package/lib-cjs/CliUtils.d.ts.map +1 -1
- package/lib-cjs/CliUtils.js +38 -11
- package/lib-cjs/CliUtils.js.map +1 -1
- package/lib-cjs/HttpClient/CliHttpClient.d.ts.map +1 -1
- package/lib-cjs/HttpClient/CliHttpClient.js +2 -1
- package/lib-cjs/HttpClient/CliHttpClient.js.map +1 -1
- package/lib-cjs/Types/Cli.types.d.ts +2 -1
- package/lib-cjs/Types/Cli.types.d.ts.map +1 -1
- package/lib-cjs/Utils/EnhanceNetworkError.d.ts +13 -0
- package/lib-cjs/Utils/EnhanceNetworkError.d.ts.map +1 -0
- package/lib-cjs/Utils/EnhanceNetworkError.js +63 -0
- package/lib-cjs/Utils/EnhanceNetworkError.js.map +1 -0
- package/lib-cjs/Verbs/Init.d.ts.map +1 -1
- package/lib-cjs/Verbs/Init.js +4 -0
- package/lib-cjs/Verbs/Init.js.map +1 -1
- package/lib-cjs/__tests__/E2eTests/basicSetup/loggingConfiguration.test.d.ts +4 -0
- package/lib-cjs/__tests__/E2eTests/basicSetup/loggingConfiguration.test.d.ts.map +1 -0
- package/lib-cjs/__tests__/E2eTests/basicSetup/loggingConfiguration.test.js +271 -0
- package/lib-cjs/__tests__/E2eTests/basicSetup/loggingConfiguration.test.js.map +1 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/cliHelp.test.d.ts +4 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/cliHelp.test.d.ts.map +1 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/cliHelp.test.js +187 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/cliHelp.test.js.map +1 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/logoutReauth.test.d.ts +4 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/logoutReauth.test.d.ts.map +1 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/logoutReauth.test.js +140 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/logoutReauth.test.js.map +1 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/missingParameters.test.d.ts +4 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/missingParameters.test.d.ts.map +1 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/missingParameters.test.js +191 -0
- package/lib-cjs/__tests__/E2eTests/cliUsability/missingParameters.test.js.map +1 -0
- package/lib-cjs/__tests__/E2eTests/commonUserWorkflowSmokeTest.test.js +5 -5
- package/lib-cjs/__tests__/E2eTests/commonUserWorkflowSmokeTest.test.js.map +1 -1
- package/lib-cjs/__tests__/E2eTests/e2eConfig.d.ts +94 -0
- package/lib-cjs/__tests__/E2eTests/e2eConfig.d.ts.map +1 -0
- package/lib-cjs/__tests__/E2eTests/e2eConfig.js +149 -0
- package/lib-cjs/__tests__/E2eTests/e2eConfig.js.map +1 -0
- package/lib-cjs/__tests__/UnitTests/CliUtils.spec.d.ts +4 -0
- package/lib-cjs/__tests__/UnitTests/CliUtils.spec.d.ts.map +1 -0
- package/lib-cjs/__tests__/UnitTests/CliUtils.spec.js +97 -0
- package/lib-cjs/__tests__/UnitTests/CliUtils.spec.js.map +1 -0
- package/lib-cjs/__tests__/UnitTests/ServicePrincipalAuthenticationProvider.spec.js +3 -3
- package/lib-cjs/__tests__/UnitTests/ServicePrincipalAuthenticationProvider.spec.js.map +1 -1
- package/lib-cjs/__tests__/UnitTests/enhanceNetworkError.test.d.ts +4 -0
- package/lib-cjs/__tests__/UnitTests/enhanceNetworkError.test.d.ts.map +1 -0
- package/lib-cjs/__tests__/UnitTests/enhanceNetworkError.test.js +179 -0
- package/lib-cjs/__tests__/UnitTests/enhanceNetworkError.test.js.map +1 -0
- package/lib-cjs/__tests__/helpers/e2eTestHelpers.d.ts.map +1 -1
- package/lib-cjs/__tests__/helpers/e2eTestHelpers.js +16 -0
- package/lib-cjs/__tests__/helpers/e2eTestHelpers.js.map +1 -1
- package/lib-cjs/__tests__/helpers/testHelpers.d.ts +146 -30
- package/lib-cjs/__tests__/helpers/testHelpers.d.ts.map +1 -1
- package/lib-cjs/__tests__/helpers/testHelpers.js +242 -98
- package/lib-cjs/__tests__/helpers/testHelpers.js.map +1 -1
- package/node_modules/@microsoft/powerapps-data/package.json +2 -2
- package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/ListTables.d.ts +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/ListTables.d.ts.map +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/ListTables.js +11 -2
- package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/ListTables.js.map +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/modelServiceGenerator.d.ts +10 -0
- package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/modelServiceGenerator.d.ts.map +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/modelServiceGenerator.js +98 -36
- package/node_modules/@microsoft/powerapps-player-actions/lib/CodeGen/modelServiceGenerator.js.map +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/ModelServiceGenerator.spec.js +16 -2
- package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/ModelServiceGenerator.spec.js.map +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/ListTables.d.ts +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/ListTables.d.ts.map +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/ListTables.js +14 -5
- package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/ListTables.js.map +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/modelServiceGenerator.d.ts +10 -0
- package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/modelServiceGenerator.d.ts.map +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/modelServiceGenerator.js +139 -65
- package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/modelServiceGenerator.js.map +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/ModelServiceGenerator.spec.js +31 -1
- package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/ModelServiceGenerator.spec.js.map +1 -1
- package/node_modules/@microsoft/powerapps-player-actions/package.json +2 -2
- package/node_modules/@pa-client/powerapps-player-services/lib/Services/Connectivity/__tests__/ApimService.spec.js +3 -0
- package/node_modules/@pa-client/powerapps-player-services/lib/Services/Connectivity/__tests__/ApimService.spec.js.map +1 -1
- package/node_modules/@pa-client/powerapps-player-services/lib/Services/PlayerLaunchService/PlayerLaunchService.types.d.ts +1 -0
- package/node_modules/@pa-client/powerapps-player-services/lib/Services/PlayerLaunchService/PlayerLaunchService.types.d.ts.map +1 -1
- package/node_modules/@pa-client/powerapps-player-services/lib-cjs/Services/Connectivity/__tests__/ApimService.spec.js +3 -0
- package/node_modules/@pa-client/powerapps-player-services/lib-cjs/Services/Connectivity/__tests__/ApimService.spec.js.map +1 -1
- package/node_modules/@pa-client/powerapps-player-services/lib-cjs/Services/PlayerLaunchService/PlayerLaunchService.types.d.ts +1 -0
- package/node_modules/@pa-client/powerapps-player-services/lib-cjs/Services/PlayerLaunchService/PlayerLaunchService.types.d.ts.map +1 -1
- package/node_modules/@pa-client/powerapps-player-services/package.json +1 -1
- package/package.json +4 -4
package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/CodeGen/modelServiceGenerator.js
CHANGED
|
@@ -878,10 +878,15 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
878
878
|
var requiredFields = this.getRequiredFields(definition);
|
|
879
879
|
var propertiesNode = this.getPropertiesNode(definition);
|
|
880
880
|
// Generate optionset enums first (before the interface)
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
881
|
+
// BUT only for top-level interfaces (addInterfaceName === true)
|
|
882
|
+
// Nested inline objects should not generate enums to avoid exporting them mid-interface
|
|
883
|
+
if (addInterfaceName) {
|
|
884
|
+
// Collect all enums including from nested objects
|
|
885
|
+
var allEnumLines = this.collectAllEnums(modelName, propertiesNode, padding);
|
|
886
|
+
if (allEnumLines.length > 0) {
|
|
887
|
+
lines.push.apply(lines, __spreadArray([], __read(allEnumLines), false));
|
|
888
|
+
lines.push(''); // Add blank line between enums and interface
|
|
889
|
+
}
|
|
885
890
|
}
|
|
886
891
|
this.addInterfaceDeclarationWithPadding(lines, modelName, addInterfaceName, padding);
|
|
887
892
|
try {
|
|
@@ -909,6 +914,55 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
909
914
|
this.closeInterfaceDeclarationWithPadding(lines, padding);
|
|
910
915
|
return lines.join('\n');
|
|
911
916
|
};
|
|
917
|
+
/**
|
|
918
|
+
* Recursively collects all enum declarations from properties, including nested objects.
|
|
919
|
+
* This ensures enums are hoisted to the top level and not exported mid-interface.
|
|
920
|
+
*/
|
|
921
|
+
ModelServiceGenerator.collectAllEnums = function (modelName, propertiesNode, padding) {
|
|
922
|
+
var e_10, _b;
|
|
923
|
+
var enumLines = [];
|
|
924
|
+
try {
|
|
925
|
+
for (var _c = __values(Object.entries(propertiesNode)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
926
|
+
var _e = __read(_d.value, 2), propName = _e[0], propValue = _e[1];
|
|
927
|
+
var propValueAsObject = typeof propValue === 'object' && propValue !== null && !Array.isArray(propValue)
|
|
928
|
+
? propValue
|
|
929
|
+
: undefined;
|
|
930
|
+
if (!propValueAsObject) {
|
|
931
|
+
continue;
|
|
932
|
+
}
|
|
933
|
+
// Check if this property has optionset data
|
|
934
|
+
if (this.hasOptionsetData(propValueAsObject)) {
|
|
935
|
+
var enumName = this.generateOptionsetEnumName(modelName, propName);
|
|
936
|
+
var enumDeclaration = this.generateOptionsetConstDeclaration(enumName, propValueAsObject, padding);
|
|
937
|
+
enumLines.push(enumDeclaration);
|
|
938
|
+
}
|
|
939
|
+
// Recursively collect enums from nested objects
|
|
940
|
+
if (propValueAsObject.properties && typeof propValueAsObject.properties === 'object') {
|
|
941
|
+
var nestedEnums = this.collectAllEnums(modelName, propValueAsObject.properties, padding);
|
|
942
|
+
enumLines.push.apply(enumLines, __spreadArray([], __read(nestedEnums), false));
|
|
943
|
+
}
|
|
944
|
+
// Recursively collect enums from array items
|
|
945
|
+
if (propValueAsObject.type === 'array' &&
|
|
946
|
+
propValueAsObject.items &&
|
|
947
|
+
typeof propValueAsObject.items === 'object' &&
|
|
948
|
+
!Array.isArray(propValueAsObject.items)) {
|
|
949
|
+
var itemsObj = propValueAsObject.items;
|
|
950
|
+
if (itemsObj.properties && typeof itemsObj.properties === 'object') {
|
|
951
|
+
var itemEnums = this.collectAllEnums(modelName, itemsObj.properties, padding);
|
|
952
|
+
enumLines.push.apply(enumLines, __spreadArray([], __read(itemEnums), false));
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
958
|
+
finally {
|
|
959
|
+
try {
|
|
960
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
961
|
+
}
|
|
962
|
+
finally { if (e_10) throw e_10.error; }
|
|
963
|
+
}
|
|
964
|
+
return enumLines;
|
|
965
|
+
};
|
|
912
966
|
/**
|
|
913
967
|
* Checks if a property has optionset data (enum and x-ms-enum-values)
|
|
914
968
|
*/
|
|
@@ -930,7 +984,7 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
930
984
|
* @returns An array of const object declaration strings.
|
|
931
985
|
*/
|
|
932
986
|
ModelServiceGenerator.generateOptionsetEnums = function (modelName, propertiesNode, padding) {
|
|
933
|
-
var
|
|
987
|
+
var e_11, _b;
|
|
934
988
|
var enumLines = [];
|
|
935
989
|
try {
|
|
936
990
|
for (var _c = __values(Object.entries(propertiesNode)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
@@ -946,60 +1000,80 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
946
1000
|
}
|
|
947
1001
|
}
|
|
948
1002
|
}
|
|
949
|
-
catch (
|
|
1003
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
950
1004
|
finally {
|
|
951
1005
|
try {
|
|
952
1006
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
953
1007
|
}
|
|
954
|
-
finally { if (
|
|
1008
|
+
finally { if (e_11) throw e_11.error; }
|
|
955
1009
|
}
|
|
956
1010
|
return enumLines;
|
|
957
1011
|
};
|
|
1012
|
+
/**
|
|
1013
|
+
* Formats an enum label as a quoted string literal, escaping single quotes.
|
|
1014
|
+
* Returns an empty string literal for empty labels.
|
|
1015
|
+
*/
|
|
1016
|
+
ModelServiceGenerator.formatEnumLabel = function (label) {
|
|
1017
|
+
if (!label || (typeof label === 'string' && label.trim() === '')) {
|
|
1018
|
+
return "''"; // Placeholder for empty labels
|
|
1019
|
+
}
|
|
1020
|
+
else {
|
|
1021
|
+
// Escape single quotes in the label to prevent breaking the string literal
|
|
1022
|
+
var escapedLabel = label.replace(/'/g, "\\'");
|
|
1023
|
+
return "'".concat(escapedLabel, "'");
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
958
1026
|
/**
|
|
959
1027
|
* Generates const object declaration for an optionset property.
|
|
960
1028
|
* Creates a const object with typed properties that is compatible with erasableSyntaxOnly.
|
|
961
1029
|
* Also generates a corresponding type alias for type safety.
|
|
962
1030
|
*/
|
|
963
1031
|
ModelServiceGenerator.generateOptionsetConstDeclaration = function (enumName, propValue, padding) {
|
|
964
|
-
|
|
965
|
-
|
|
1032
|
+
var _this = this;
|
|
1033
|
+
// Check for x-ms-enum-values format (array of objects or numbers)
|
|
1034
|
+
var enumValues = propValue['x-ms-enum-values'];
|
|
966
1035
|
var enumLabels = propValue.enum;
|
|
967
1036
|
var lines = [];
|
|
968
1037
|
enumName = (0, codeGenUtils_1.convertToValidIdentifier)(enumName);
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
//
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
var
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1038
|
+
// Check if x-ms-enum-values exists and is an array
|
|
1039
|
+
if (enumValues && Array.isArray(enumValues) && enumLabels && Array.isArray(enumLabels)) {
|
|
1040
|
+
// Check if x-ms-enum-values contains objects with numeric values (Dataverse format)
|
|
1041
|
+
var hasObjectFormat = enumValues.length > 0 && typeof enumValues[0] === 'object' && enumValues[0] !== null;
|
|
1042
|
+
if (hasObjectFormat) {
|
|
1043
|
+
// This is the Swagger format where x-ms-enum-values contains objects like {displayName, value}
|
|
1044
|
+
// Just use the enum array for string union type
|
|
1045
|
+
var labelStrings = enumLabels.map(function (label) { return _this.formatEnumLabel(label); });
|
|
1046
|
+
lines.push("".concat(padding, "export type ").concat(enumName, " = ").concat(labelStrings.join('|'), ";"));
|
|
1047
|
+
}
|
|
1048
|
+
else {
|
|
1049
|
+
// This is the Dataverse format where x-ms-enum-values contains numeric values
|
|
1050
|
+
var enumNumericValues = enumValues;
|
|
1051
|
+
// Generate const object with numeric keys
|
|
1052
|
+
lines.push("".concat(padding, "export const ").concat(enumName, " = {"));
|
|
1053
|
+
// Handle the format where enum contains display names and x-ms-enum-values contains numeric values
|
|
1054
|
+
for (var i = 0; i < enumLabels.length; i++) {
|
|
1055
|
+
var displayName = enumLabels[i]; // e.g., "Preferred Customer"
|
|
1056
|
+
var numericValue = enumNumericValues[i]; // e.g., 1
|
|
1057
|
+
// Use the display name directly as the string value
|
|
1058
|
+
var sanitizedLabel = void 0;
|
|
1059
|
+
if (!displayName || (typeof displayName === 'string' && displayName.trim() === '')) {
|
|
1060
|
+
// Generate a placeholder name for empty labels
|
|
1061
|
+
sanitizedLabel = "EmptyOption".concat(i);
|
|
1062
|
+
}
|
|
1063
|
+
else {
|
|
1064
|
+
sanitizedLabel = (0, nameUtility_1.sanitizeName)(displayName);
|
|
1065
|
+
}
|
|
1066
|
+
var comma = i < enumLabels.length - 1 ? ',' : '';
|
|
1067
|
+
lines.push("".concat(padding, " ").concat(numericValue, ": '").concat(sanitizedLabel, "'").concat(comma));
|
|
985
1068
|
}
|
|
986
|
-
|
|
987
|
-
|
|
1069
|
+
lines.push("".concat(padding, "} as const;"));
|
|
1070
|
+
// Generate type alias for the numeric values
|
|
1071
|
+
lines.push("".concat(padding, "export type ").concat(enumName, " = keyof typeof ").concat(enumName, ";"));
|
|
988
1072
|
}
|
|
989
|
-
lines.push("".concat(padding, "} as const;"));
|
|
990
|
-
// Generate type alias for the numeric values
|
|
991
|
-
lines.push("".concat(padding, "export type ").concat(enumName, " = keyof typeof ").concat(enumName, ";"));
|
|
992
1073
|
}
|
|
993
1074
|
else {
|
|
994
|
-
// This is the path for swaggers where
|
|
995
|
-
var labelStrings = enumLabels.map(function (label) {
|
|
996
|
-
if (!label || (typeof label === 'string' && label.trim() === '')) {
|
|
997
|
-
return "''"; // Placeholder for empty labels
|
|
998
|
-
}
|
|
999
|
-
else {
|
|
1000
|
-
return "'".concat(label, "'");
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1075
|
+
// This is the path for swaggers where only enum array exists (no x-ms-enum-values)
|
|
1076
|
+
var labelStrings = enumLabels.map(function (label) { return _this.formatEnumLabel(label); });
|
|
1003
1077
|
lines.push("".concat(padding, "export type ").concat(enumName, " = ").concat(labelStrings.join('|'), ";"));
|
|
1004
1078
|
}
|
|
1005
1079
|
return lines.join('\n');
|
|
@@ -1389,7 +1463,7 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
1389
1463
|
* It returns an object containing the parameters list and parameters properties.
|
|
1390
1464
|
*/
|
|
1391
1465
|
ModelServiceGenerator.collectParameters = function (operationObject, modelName, imports, parameterTypes) {
|
|
1392
|
-
var
|
|
1466
|
+
var e_12, _b;
|
|
1393
1467
|
var parametersList = [];
|
|
1394
1468
|
var parametersProps = [];
|
|
1395
1469
|
if ('parameters' in operationObject && Array.isArray(operationObject.parameters)) {
|
|
@@ -1404,12 +1478,12 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
1404
1478
|
parametersProps = result[1];
|
|
1405
1479
|
}
|
|
1406
1480
|
}
|
|
1407
|
-
catch (
|
|
1481
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
1408
1482
|
finally {
|
|
1409
1483
|
try {
|
|
1410
1484
|
if (orderedParams_1_1 && !orderedParams_1_1.done && (_b = orderedParams_1.return)) _b.call(orderedParams_1);
|
|
1411
1485
|
}
|
|
1412
|
-
finally { if (
|
|
1486
|
+
finally { if (e_12) throw e_12.error; }
|
|
1413
1487
|
}
|
|
1414
1488
|
}
|
|
1415
1489
|
return { parametersList: parametersList, parametersProps: parametersProps };
|
|
@@ -1999,7 +2073,7 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
1999
2073
|
ModelServiceGenerator.handleDataverseSchema = function (modelName, dataSourceName, schema, outputDir, vfs) {
|
|
2000
2074
|
return __awaiter(this, void 0, void 0, function () {
|
|
2001
2075
|
var schemaObject, schemaProperty, itemsNode, primaryKey, properties, _b, _c, _d, propName, propValue, prop, _e, baseInterface, extendedInterface, hasLookupColumns, combinedModelCode, serviceCode;
|
|
2002
|
-
var
|
|
2076
|
+
var e_13, _f;
|
|
2003
2077
|
return __generator(this, function (_g) {
|
|
2004
2078
|
switch (_g.label) {
|
|
2005
2079
|
case 0:
|
|
@@ -2027,12 +2101,12 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2027
2101
|
}
|
|
2028
2102
|
}
|
|
2029
2103
|
}
|
|
2030
|
-
catch (
|
|
2104
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
2031
2105
|
finally {
|
|
2032
2106
|
try {
|
|
2033
2107
|
if (_c && !_c.done && (_f = _b.return)) _f.call(_b);
|
|
2034
2108
|
}
|
|
2035
|
-
finally { if (
|
|
2109
|
+
finally { if (e_13) throw e_13.error; }
|
|
2036
2110
|
}
|
|
2037
2111
|
}
|
|
2038
2112
|
_e = this.generateDataverseInterfaces(modelName, itemsNode), baseInterface = _e.baseInterface, extendedInterface = _e.extendedInterface;
|
|
@@ -2122,7 +2196,7 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2122
2196
|
* Adds the SharePoint service class definition to the generated code.
|
|
2123
2197
|
*/
|
|
2124
2198
|
ModelServiceGenerator.addSharepointServiceClassDefinition = function (lines, modelName, dataSourceName, schemaJson, primaryKey, hasReferenceEntities) {
|
|
2125
|
-
var
|
|
2199
|
+
var e_14, _b;
|
|
2126
2200
|
this.addServiceClassHeader(lines, modelName, dataSourceName, true);
|
|
2127
2201
|
// Add CRUD methods
|
|
2128
2202
|
var methods = [];
|
|
@@ -2138,12 +2212,12 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2138
2212
|
lines.push.apply(lines, __spreadArray([], __read(method), false));
|
|
2139
2213
|
}
|
|
2140
2214
|
}
|
|
2141
|
-
catch (
|
|
2215
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
2142
2216
|
finally {
|
|
2143
2217
|
try {
|
|
2144
2218
|
if (methods_1_1 && !methods_1_1.done && (_b = methods_1.return)) _b.call(methods_1);
|
|
2145
2219
|
}
|
|
2146
|
-
finally { if (
|
|
2220
|
+
finally { if (e_14) throw e_14.error; }
|
|
2147
2221
|
}
|
|
2148
2222
|
// Add SharePoint-specific methods
|
|
2149
2223
|
this.addGetMethodForReferenceEntities(lines, modelName, dataSourceName, schemaJson);
|
|
@@ -2275,7 +2349,7 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2275
2349
|
* The addSPModelInterfaceDeclaration method generates the TypeScript interface declaration for the model particular to Sharepoint.
|
|
2276
2350
|
*/
|
|
2277
2351
|
ModelServiceGenerator.addSPModelInterfaceDeclaration = function (lines, modelName, propertiesNode, requiredFields, primaryKeyObj, schemaJson) {
|
|
2278
|
-
var
|
|
2352
|
+
var e_15, _b;
|
|
2279
2353
|
var result = this.addSPReferencedEntityModelInterfaceDeclaration(schemaJson, lines);
|
|
2280
2354
|
var referenceEntitiesObjectMapping = result.mapping;
|
|
2281
2355
|
// lines are already updated by the method above
|
|
@@ -2326,12 +2400,12 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2326
2400
|
this.addPropertyDeclaration(baseInterfaceLines, propName, propertiesNode[propName], requiredFields, primaryKeyObj);
|
|
2327
2401
|
}
|
|
2328
2402
|
}
|
|
2329
|
-
catch (
|
|
2403
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
2330
2404
|
finally {
|
|
2331
2405
|
try {
|
|
2332
2406
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
2333
2407
|
}
|
|
2334
|
-
finally { if (
|
|
2408
|
+
finally { if (e_15) throw e_15.error; }
|
|
2335
2409
|
}
|
|
2336
2410
|
baseInterfaceLines.push('}');
|
|
2337
2411
|
baseInterfaceLines.push('');
|
|
@@ -2422,7 +2496,7 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2422
2496
|
* The addModelInterfaceDeclaration method generates the TypeScript interface declaration for the model.
|
|
2423
2497
|
*/
|
|
2424
2498
|
ModelServiceGenerator.addModelInterfaceDeclaration = function (lines, modelName, propertiesNode, requiredFields, primaryKey) {
|
|
2425
|
-
var
|
|
2499
|
+
var e_16, _b;
|
|
2426
2500
|
lines.push("export interface ".concat((0, codeGenUtils_1.convertToValidIdentifier)(modelName), " {"));
|
|
2427
2501
|
primaryKey.value = '';
|
|
2428
2502
|
try {
|
|
@@ -2432,12 +2506,12 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2432
2506
|
this.addPropertyDeclaration(lines, propName, propertiesNode[propName], requiredFields, primaryKey);
|
|
2433
2507
|
}
|
|
2434
2508
|
}
|
|
2435
|
-
catch (
|
|
2509
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
2436
2510
|
finally {
|
|
2437
2511
|
try {
|
|
2438
2512
|
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
2439
2513
|
}
|
|
2440
|
-
finally { if (
|
|
2514
|
+
finally { if (e_16) throw e_16.error; }
|
|
2441
2515
|
}
|
|
2442
2516
|
lines.push('}');
|
|
2443
2517
|
lines.push('');
|
|
@@ -2584,7 +2658,7 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2584
2658
|
* It includes create, update, delete, get, and getAll methods.
|
|
2585
2659
|
*/
|
|
2586
2660
|
ModelServiceGenerator.addServiceMethods = function (lines, modelName, dataSourceName, primaryKey, isADataverseEntity) {
|
|
2587
|
-
var
|
|
2661
|
+
var e_17, _b;
|
|
2588
2662
|
var methods = [];
|
|
2589
2663
|
methods.push(this.generateCreateMethod(modelName, primaryKey));
|
|
2590
2664
|
methods.push(this.generateUpdateMethod(modelName, primaryKey));
|
|
@@ -2601,12 +2675,12 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2601
2675
|
lines.push.apply(lines, __spreadArray([], __read(method), false));
|
|
2602
2676
|
}
|
|
2603
2677
|
}
|
|
2604
|
-
catch (
|
|
2678
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
2605
2679
|
finally {
|
|
2606
2680
|
try {
|
|
2607
2681
|
if (methods_2_1 && !methods_2_1.done && (_b = methods_2.return)) _b.call(methods_2);
|
|
2608
2682
|
}
|
|
2609
|
-
finally { if (
|
|
2683
|
+
finally { if (e_17) throw e_17.error; }
|
|
2610
2684
|
}
|
|
2611
2685
|
};
|
|
2612
2686
|
/*
|
|
@@ -2614,7 +2688,7 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2614
2688
|
* Uses base interface for Create/Update and extended interface for Get/GetAll operations.
|
|
2615
2689
|
*/
|
|
2616
2690
|
ModelServiceGenerator.addDataverseServiceMethods = function (lines, modelName, dataSourceName, primaryKey, hasLookupColumns) {
|
|
2617
|
-
var
|
|
2691
|
+
var e_18, _b;
|
|
2618
2692
|
var methods = [];
|
|
2619
2693
|
methods.push(this.generateDataverseCreateMethod(modelName, primaryKey, hasLookupColumns));
|
|
2620
2694
|
methods.push(this.generateDataverseUpdateMethod(modelName, primaryKey, hasLookupColumns));
|
|
@@ -2629,12 +2703,12 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2629
2703
|
lines.push.apply(lines, __spreadArray([], __read(method), false));
|
|
2630
2704
|
}
|
|
2631
2705
|
}
|
|
2632
|
-
catch (
|
|
2706
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
2633
2707
|
finally {
|
|
2634
2708
|
try {
|
|
2635
2709
|
if (methods_3_1 && !methods_3_1.done && (_b = methods_3.return)) _b.call(methods_3);
|
|
2636
2710
|
}
|
|
2637
|
-
finally { if (
|
|
2711
|
+
finally { if (e_18) throw e_18.error; }
|
|
2638
2712
|
}
|
|
2639
2713
|
};
|
|
2640
2714
|
/*
|
|
@@ -2917,7 +2991,7 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2917
2991
|
ModelServiceGenerator.generateIndexFile = function (outputDir, vfs) {
|
|
2918
2992
|
return __awaiter(this, void 0, void 0, function () {
|
|
2919
2993
|
var indexPath, lines, modelsDir, modelFiles, modelFiles_1, modelFiles_1_1, file, fileName, servicesDir, serviceFiles, serviceFiles_1, serviceFiles_1_1, file, fileName;
|
|
2920
|
-
var
|
|
2994
|
+
var e_19, _b, e_20, _c;
|
|
2921
2995
|
return __generator(this, function (_d) {
|
|
2922
2996
|
switch (_d.label) {
|
|
2923
2997
|
case 0:
|
|
@@ -2941,12 +3015,12 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2941
3015
|
lines.push("export * as ".concat(fileName, " from './models/").concat(fileName, "';"));
|
|
2942
3016
|
}
|
|
2943
3017
|
}
|
|
2944
|
-
catch (
|
|
3018
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
2945
3019
|
finally {
|
|
2946
3020
|
try {
|
|
2947
3021
|
if (modelFiles_1_1 && !modelFiles_1_1.done && (_b = modelFiles_1.return)) _b.call(modelFiles_1);
|
|
2948
3022
|
}
|
|
2949
|
-
finally { if (
|
|
3023
|
+
finally { if (e_19) throw e_19.error; }
|
|
2950
3024
|
}
|
|
2951
3025
|
lines.push('');
|
|
2952
3026
|
}
|
|
@@ -2968,12 +3042,12 @@ var ModelServiceGenerator = /** @class */ (function () {
|
|
|
2968
3042
|
lines.push("export * from './services/".concat(fileName, "';"));
|
|
2969
3043
|
}
|
|
2970
3044
|
}
|
|
2971
|
-
catch (
|
|
3045
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
2972
3046
|
finally {
|
|
2973
3047
|
try {
|
|
2974
3048
|
if (serviceFiles_1_1 && !serviceFiles_1_1.done && (_c = serviceFiles_1.return)) _c.call(serviceFiles_1);
|
|
2975
3049
|
}
|
|
2976
|
-
finally { if (
|
|
3050
|
+
finally { if (e_20) throw e_20.error; }
|
|
2977
3051
|
}
|
|
2978
3052
|
lines.push('');
|
|
2979
3053
|
}
|