auth0-deploy-cli 7.10.0 → 7.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/lib/context/directory/handlers/actions.d.ts +2 -3
  3. package/lib/context/directory/handlers/actions.js +4 -4
  4. package/lib/context/directory/handlers/attackProtection.d.ts +6 -7
  5. package/lib/context/directory/handlers/attackProtection.js +3 -1
  6. package/lib/context/directory/handlers/branding.d.ts +2 -3
  7. package/lib/context/directory/handlers/branding.js +8 -18
  8. package/lib/context/directory/handlers/clientGrants.d.ts +2 -3
  9. package/lib/context/directory/handlers/clientGrants.js +3 -2
  10. package/lib/context/directory/handlers/clients.d.ts +2 -3
  11. package/lib/context/directory/handlers/clients.js +1 -1
  12. package/lib/context/directory/handlers/connections.d.ts +2 -3
  13. package/lib/context/directory/handlers/connections.js +3 -3
  14. package/lib/context/directory/handlers/databases.d.ts +2 -3
  15. package/lib/context/directory/handlers/databases.js +2 -2
  16. package/lib/context/directory/handlers/emailProvider.d.ts +2 -3
  17. package/lib/context/directory/handlers/emailProvider.js +12 -10
  18. package/lib/context/directory/handlers/emailTemplates.d.ts +2 -3
  19. package/lib/context/directory/handlers/emailTemplates.js +2 -2
  20. package/lib/context/directory/handlers/guardianFactorProviders.d.ts +2 -3
  21. package/lib/context/directory/handlers/guardianFactorProviders.js +1 -1
  22. package/lib/context/directory/handlers/guardianFactorTemplates.d.ts +2 -3
  23. package/lib/context/directory/handlers/guardianFactorTemplates.js +1 -1
  24. package/lib/context/directory/handlers/guardianFactors.d.ts +2 -3
  25. package/lib/context/directory/handlers/guardianFactors.js +1 -1
  26. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.d.ts +2 -3
  27. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +6 -6
  28. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.d.ts +2 -3
  29. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +6 -6
  30. package/lib/context/directory/handlers/guardianPolicies.d.ts +2 -3
  31. package/lib/context/directory/handlers/guardianPolicies.js +6 -6
  32. package/lib/context/directory/handlers/hooks.d.ts +2 -3
  33. package/lib/context/directory/handlers/hooks.js +3 -3
  34. package/lib/context/directory/handlers/index.d.ts +2 -2
  35. package/lib/context/directory/handlers/logStreams.d.ts +2 -4
  36. package/lib/context/directory/handlers/logStreams.js +2 -2
  37. package/lib/context/directory/handlers/migrations.d.ts +2 -3
  38. package/lib/context/directory/handlers/migrations.js +2 -2
  39. package/lib/context/directory/handlers/organizations.d.ts +2 -3
  40. package/lib/context/directory/handlers/organizations.js +1 -1
  41. package/lib/context/directory/handlers/pages.d.ts +2 -3
  42. package/lib/context/directory/handlers/pages.js +2 -2
  43. package/lib/context/directory/handlers/resourceServers.d.ts +2 -3
  44. package/lib/context/directory/handlers/resourceServers.js +1 -1
  45. package/lib/context/directory/handlers/roles.d.ts +2 -3
  46. package/lib/context/directory/handlers/roles.js +1 -1
  47. package/lib/context/directory/handlers/rules.d.ts +2 -3
  48. package/lib/context/directory/handlers/rules.js +2 -2
  49. package/lib/context/directory/handlers/rulesConfigs.d.ts +2 -3
  50. package/lib/context/directory/handlers/rulesConfigs.js +1 -1
  51. package/lib/context/directory/handlers/tenant.d.ts +7 -7
  52. package/lib/context/directory/handlers/tenant.js +11 -10
  53. package/lib/context/directory/handlers/triggers.d.ts +2 -3
  54. package/lib/context/directory/handlers/triggers.js +1 -1
  55. package/lib/context/yaml/handlers/actions.d.ts +2 -3
  56. package/lib/context/yaml/handlers/actions.js +6 -8
  57. package/lib/context/yaml/handlers/attackProtection.d.ts +6 -3
  58. package/lib/context/yaml/handlers/attackProtection.js +9 -1
  59. package/lib/context/yaml/handlers/branding.d.ts +6 -6
  60. package/lib/context/yaml/handlers/branding.js +11 -6
  61. package/lib/context/yaml/handlers/clientGrants.d.ts +2 -3
  62. package/lib/context/yaml/handlers/clientGrants.js +7 -6
  63. package/lib/context/yaml/handlers/clients.d.ts +2 -3
  64. package/lib/context/yaml/handlers/clients.js +6 -3
  65. package/lib/context/yaml/handlers/connections.d.ts +2 -3
  66. package/lib/context/yaml/handlers/connections.js +6 -9
  67. package/lib/context/yaml/handlers/databases.d.ts +3 -4
  68. package/lib/context/yaml/handlers/databases.js +7 -7
  69. package/lib/context/yaml/handlers/emailProvider.d.ts +2 -3
  70. package/lib/context/yaml/handlers/emailProvider.js +17 -10
  71. package/lib/context/yaml/handlers/emailTemplates.d.ts +2 -3
  72. package/lib/context/yaml/handlers/emailTemplates.js +16 -13
  73. package/lib/context/yaml/handlers/guardianFactorProviders.d.ts +2 -3
  74. package/lib/context/yaml/handlers/guardianFactorProviders.js +4 -2
  75. package/lib/context/yaml/handlers/guardianFactorTemplates.d.ts +2 -3
  76. package/lib/context/yaml/handlers/guardianFactorTemplates.js +4 -2
  77. package/lib/context/yaml/handlers/guardianFactors.d.ts +2 -3
  78. package/lib/context/yaml/handlers/guardianFactors.js +4 -2
  79. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.d.ts +2 -3
  80. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +4 -2
  81. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.d.ts +2 -3
  82. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +4 -2
  83. package/lib/context/yaml/handlers/guardianPolicies.d.ts +4 -3
  84. package/lib/context/yaml/handlers/guardianPolicies.js +4 -2
  85. package/lib/context/yaml/handlers/hooks.d.ts +2 -3
  86. package/lib/context/yaml/handlers/hooks.js +20 -19
  87. package/lib/context/yaml/handlers/index.d.ts +1 -1
  88. package/lib/context/yaml/handlers/logStreams.d.ts +2 -4
  89. package/lib/context/yaml/handlers/logStreams.js +4 -1
  90. package/lib/context/yaml/handlers/migrations.d.ts +2 -3
  91. package/lib/context/yaml/handlers/migrations.js +5 -9
  92. package/lib/context/yaml/handlers/organizations.d.ts +2 -1
  93. package/lib/context/yaml/handlers/organizations.js +17 -15
  94. package/lib/context/yaml/handlers/pages.d.ts +2 -3
  95. package/lib/context/yaml/handlers/pages.js +20 -18
  96. package/lib/context/yaml/handlers/resourceServers.d.ts +2 -3
  97. package/lib/context/yaml/handlers/resourceServers.js +8 -13
  98. package/lib/context/yaml/handlers/roles.d.ts +2 -3
  99. package/lib/context/yaml/handlers/roles.js +13 -11
  100. package/lib/context/yaml/handlers/rules.d.ts +2 -3
  101. package/lib/context/yaml/handlers/rules.js +18 -17
  102. package/lib/context/yaml/handlers/rulesConfigs.d.ts +2 -3
  103. package/lib/context/yaml/handlers/rulesConfigs.js +9 -5
  104. package/lib/context/yaml/handlers/tenant.d.ts +2 -3
  105. package/lib/context/yaml/handlers/tenant.js +4 -3
  106. package/lib/context/yaml/handlers/triggers.d.ts +2 -3
  107. package/lib/context/yaml/handlers/triggers.js +2 -2
  108. package/lib/context/yaml/index.js +2 -1
  109. package/lib/tools/auth0/handlers/actions.js +3 -3
  110. package/lib/tools/auth0/handlers/branding.d.ts +2 -2
  111. package/lib/tools/auth0/handlers/clientGrants.js +1 -1
  112. package/lib/tools/auth0/handlers/connections.js +1 -1
  113. package/lib/tools/auth0/handlers/default.js +9 -2
  114. package/lib/tools/auth0/index.js +5 -2
  115. package/lib/tools/utils.d.ts +9 -0
  116. package/lib/tools/utils.js +33 -1
  117. package/lib/types.d.ts +37 -29
  118. package/lib/utils.d.ts +34 -29
  119. package/lib/utils.js +1 -1
  120. package/package.json +7 -4
package/CHANGELOG.md CHANGED
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [7.11.0] - 2022-04-28
11
+
12
+ ### Added
13
+
14
+ - Intelligent scope detection, will skip resources when insufficient scope provided to designated application [#517]
15
+
16
+ ### Fixed
17
+
18
+ - Inconsistencies between resource handlers with respect to empty, null and undefined values [#512]
19
+
10
20
  ## [7.10.0] - 2022-04-26
11
21
 
12
22
  ### Added
@@ -702,7 +712,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
702
712
  [#504]: https://github.com/auth0/auth0-deploy-cli/issues/504
703
713
  [#505]: https://github.com/auth0/auth0-deploy-cli/issues/505
704
714
  [#509]: https://github.com/auth0/auth0-deploy-cli/issues/509
705
- [unreleased]: https://github.com/auth0/auth0-deploy-cli/compare/v7.10.0...HEAD
715
+ [#512]: https://github.com/auth0/auth0-deploy-cli/issues/512
716
+ [#517]: https://github.com/auth0/auth0-deploy-cli/issues/517
717
+ [unreleased]: https://github.com/auth0/auth0-deploy-cli/compare/v7.11.0...HEAD
718
+ [7.11.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.10.0...v7.11.0
706
719
  [7.10.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.9.0...v7.10.0
707
720
  [7.9.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.8.0...v7.9.0
708
721
  [7.8.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.7.1...v7.8.0
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedActions = {
3
- actions: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedActions = ParsedAsset<'actions', Asset[]>;
5
4
  declare const actionsHandler: DirectoryHandler<ParsedActions>;
6
5
  export default actionsHandler;
@@ -21,7 +21,7 @@ const logger_1 = __importDefault(require("../../../logger"));
21
21
  function parse(context) {
22
22
  const actionsFolder = path_1.default.join(context.filePath, tools_1.constants.ACTIONS_DIRECTORY);
23
23
  if (!(0, utils_1.existsMustBeDir)(actionsFolder))
24
- return { actions: undefined }; // Skip
24
+ return { actions: null }; // Skip
25
25
  const files = (0, utils_1.getFiles)(actionsFolder, ['.json']);
26
26
  const actions = files.map((file) => {
27
27
  const action = Object.assign({}, (0, utils_1.loadJSON)(file, context.mappings));
@@ -60,7 +60,7 @@ function mapToAction(filePath, action) {
60
60
  code: mapActionCode(filePath, action),
61
61
  runtime: action.runtime,
62
62
  status: action.status,
63
- dependencies: action.dependencies || [],
63
+ dependencies: action.dependencies,
64
64
  secrets: mapSecrets(action.secrets),
65
65
  supported_triggers: action.supported_triggers,
66
66
  deployed: action.deployed || action.all_changes_deployed,
@@ -68,8 +68,8 @@ function mapToAction(filePath, action) {
68
68
  }
69
69
  function dump(context) {
70
70
  return __awaiter(this, void 0, void 0, function* () {
71
- const actions = [...(context.assets.actions || [])];
72
- if (actions.length < 1)
71
+ const { actions } = context.assets;
72
+ if (!actions)
73
73
  return;
74
74
  // Create Actions folder
75
75
  const actionsFolder = path_1.default.join(context.filePath, tools_1.constants.ACTIONS_DIRECTORY);
@@ -1,10 +1,9 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedAttackProtection = {
3
- attackProtection: {
4
- breachedPasswordDetection: unknown;
5
- bruteForceProtection: unknown;
6
- suspiciousIpThrottling: unknown;
7
- } | undefined;
8
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedAttackProtection = ParsedAsset<'attackProtection', {
4
+ breachedPasswordDetection: Asset;
5
+ bruteForceProtection: Asset;
6
+ suspiciousIpThrottling: Asset;
7
+ }>;
9
8
  declare const attackProtectionHandler: DirectoryHandler<ParsedAttackProtection>;
10
9
  export default attackProtectionHandler;
@@ -29,7 +29,7 @@ function parse(context) {
29
29
  const files = attackProtectionFiles(context.filePath);
30
30
  if (!(0, utils_1.existsMustBeDir)(files.directory)) {
31
31
  return {
32
- attackProtection: undefined,
32
+ attackProtection: null,
33
33
  };
34
34
  }
35
35
  const breachedPasswordDetection = (0, utils_1.loadJSON)(files.breachedPasswordDetection, context.mappings);
@@ -46,6 +46,8 @@ function parse(context) {
46
46
  function dump(context) {
47
47
  return __awaiter(this, void 0, void 0, function* () {
48
48
  const { attackProtection } = context.assets;
49
+ if (!attackProtection)
50
+ return;
49
51
  const files = attackProtectionFiles(context.filePath);
50
52
  fs_extra_1.default.ensureDirSync(files.directory);
51
53
  (0, utils_1.dumpJSON)(files.breachedPasswordDetection, attackProtection.breachedPasswordDetection);
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedBranding = {
3
- branding: unknown | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedBranding = ParsedAsset<'branding', Asset>;
5
4
  declare const brandingHandler: DirectoryHandler<ParsedBranding>;
6
5
  export default brandingHandler;
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
13
  };
@@ -30,11 +19,11 @@ const utils_1 = require("../../../utils");
30
19
  function parse(context) {
31
20
  const brandingDirectory = path_1.default.join(context.filePath, tools_1.constants.BRANDING_DIRECTORY);
32
21
  if (!(0, utils_1.existsMustBeDir)(brandingDirectory))
33
- return { branding: undefined };
22
+ return { branding: null };
34
23
  const branding = (0, utils_1.loadJSON)(path_1.default.join(brandingDirectory, 'branding.json'), context.mappings);
35
24
  const brandingTemplatesFolder = path_1.default.join(brandingDirectory, tools_1.constants.BRANDING_TEMPLATES_DIRECTORY);
36
25
  if (!(0, utils_1.existsMustBeDir)(brandingTemplatesFolder))
37
- return { branding: context.assets.branding };
26
+ return { branding: null };
38
27
  const templatesDefinitionFiles = (0, utils_1.getFiles)(brandingTemplatesFolder, ['.json']);
39
28
  const templates = templatesDefinitionFiles.map((templateDefinitionFile) => {
40
29
  const definition = (0, utils_1.loadJSON)(templateDefinitionFile, context.mappings);
@@ -47,15 +36,16 @@ function parse(context) {
47
36
  }
48
37
  function dump(context) {
49
38
  return __awaiter(this, void 0, void 0, function* () {
50
- const _a = context.assets.branding, { templates = [] } = _a, branding = __rest(_a, ["templates"]);
51
- if (!!branding)
52
- dumpBranding(context);
53
- if (!!templates)
39
+ const { branding } = context.assets;
40
+ if (!branding)
41
+ return;
42
+ dumpBranding(context);
43
+ if (!!branding.templates)
54
44
  dumpBrandingTemplates(context);
55
45
  });
56
46
  }
57
47
  const dumpBrandingTemplates = ({ filePath, assets }) => {
58
- if (!assets || !assets.branding)
48
+ if (!assets.branding || !assets.branding.templates)
59
49
  return;
60
50
  const { branding: { templates = [] }, } = assets;
61
51
  const brandingTemplatesFolder = path_1.default.join(filePath, tools_1.constants.BRANDING_DIRECTORY, tools_1.constants.BRANDING_TEMPLATES_DIRECTORY);
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedClientGrants = {
3
- clientGrants: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedClientGrants = ParsedAsset<'clientGrants', Asset[]>;
5
4
  declare const clientGrantsHandler: DirectoryHandler<ParsedClientGrants>;
6
5
  export default clientGrantsHandler;
@@ -19,7 +19,7 @@ const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
20
  const grantsFolder = path_1.default.join(context.filePath, tools_1.constants.CLIENTS_GRANTS_DIRECTORY);
21
21
  if (!(0, utils_1.existsMustBeDir)(grantsFolder))
22
- return { clientGrants: undefined }; // Skip
22
+ return { clientGrants: null }; // Skip
23
23
  const foundFiles = (0, utils_1.getFiles)(grantsFolder, ['.json']);
24
24
  const clientGrants = foundFiles
25
25
  .map((f) => (0, utils_1.loadJSON)(f, context.mappings))
@@ -38,7 +38,8 @@ function dump(context) {
38
38
  // Convert client_id to the client name for readability
39
39
  clientGrants.forEach((grant) => {
40
40
  const dumpGrant = Object.assign({}, grant);
41
- dumpGrant.client_id = (0, utils_1.convertClientIdToName)(dumpGrant.client_id, context.assets.clientsOrig);
41
+ if (context.assets.clientsOrig)
42
+ dumpGrant.client_id = (0, utils_1.convertClientIdToName)(dumpGrant.client_id, context.assets.clientsOrig);
42
43
  const name = (0, utils_1.sanitize)(`${dumpGrant.client_id} (${dumpGrant.audience})`);
43
44
  const grantFile = path_1.default.join(grantsFolder, `${name}.json`);
44
45
  (0, utils_1.dumpJSON)(grantFile, dumpGrant);
@@ -1,6 +1,5 @@
1
+ import { Asset, ParsedAsset } from '../../../types';
1
2
  import { DirectoryHandler } from '.';
2
- declare type ParsedClients = {
3
- clients: unknown | undefined;
4
- };
3
+ declare type ParsedClients = ParsedAsset<'clients', Asset[]>;
5
4
  declare const clientsHandler: DirectoryHandler<ParsedClients>;
6
5
  export default clientsHandler;
@@ -20,7 +20,7 @@ const utils_1 = require("../../../utils");
20
20
  function parse(context) {
21
21
  const clientsFolder = path_1.default.join(context.filePath, tools_1.constants.CLIENTS_DIRECTORY);
22
22
  if (!(0, utils_1.existsMustBeDir)(clientsFolder))
23
- return { clients: undefined }; // Skip
23
+ return { clients: null }; // Skip
24
24
  const foundFiles = (0, utils_1.getFiles)(clientsFolder, ['.json']);
25
25
  const clients = foundFiles
26
26
  .map((f) => {
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedConnections = {
3
- connections: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedConnections = ParsedAsset<'connections', Asset[]>;
5
4
  declare const connectionsHandler: DirectoryHandler<ParsedConnections>;
6
5
  export default connectionsHandler;
@@ -21,7 +21,7 @@ function parse(context) {
21
21
  const connectionDirectory = context.config.AUTH0_CONNECTIONS_DIRECTORY || tools_1.constants.CONNECTIONS_DIRECTORY;
22
22
  const connectionsFolder = path_1.default.join(context.filePath, connectionDirectory);
23
23
  if (!(0, utils_1.existsMustBeDir)(connectionsFolder))
24
- return { connections: undefined }; // Skip
24
+ return { connections: null }; // Skip
25
25
  const foundFiles = (0, utils_1.getFiles)(connectionsFolder, ['.json']);
26
26
  const connections = foundFiles
27
27
  .map((f) => {
@@ -42,7 +42,7 @@ function parse(context) {
42
42
  }
43
43
  function dump(context) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
- const { connections } = context.assets;
45
+ const { connections, clientsOrig } = context.assets;
46
46
  if (!connections)
47
47
  return; // Skip, nothing to dump
48
48
  const connectionsFolder = path_1.default.join(context.filePath, tools_1.constants.CONNECTIONS_DIRECTORY);
@@ -50,7 +50,7 @@ function dump(context) {
50
50
  // Convert enabled_clients from id to name
51
51
  connections.forEach((connection) => {
52
52
  const dumpedConnection = Object.assign(Object.assign({}, connection), (connection.enabled_clients && {
53
- enabled_clients: (0, utils_1.mapClientID2NameSorted)(connection.enabled_clients, context.assets.clientsOrig),
53
+ enabled_clients: (0, utils_1.mapClientID2NameSorted)(connection.enabled_clients, clientsOrig || []),
54
54
  }));
55
55
  const connectionName = (0, utils_1.sanitize)(dumpedConnection.name);
56
56
  if (dumpedConnection.strategy === 'email') {
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedDatabases = {
3
- databases: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedDatabases = ParsedAsset<'databases', Asset[]>;
5
4
  declare const databasesHandler: DirectoryHandler<ParsedDatabases>;
6
5
  export default databasesHandler;
@@ -52,7 +52,7 @@ function getDatabase(folder, mappings) {
52
52
  function parse(context) {
53
53
  const databaseFolder = path_1.default.join(context.filePath, tools_1.constants.DATABASE_CONNECTIONS_DIRECTORY);
54
54
  if (!(0, utils_1.existsMustBeDir)(databaseFolder))
55
- return { databases: undefined }; // Skip
55
+ return { databases: null }; // Skip
56
56
  const folders = fs_extra_1.default
57
57
  .readdirSync(databaseFolder)
58
58
  .map((f) => path_1.default.join(databaseFolder, f))
@@ -80,7 +80,7 @@ function dump(context) {
80
80
  return name1 > name2 ? 1 : -1;
81
81
  };
82
82
  const formatted = Object.assign(Object.assign(Object.assign({}, database), (database.enabled_clients && {
83
- enabled_clients: (0, utils_1.mapClientID2NameSorted)(database.enabled_clients, context.assets.clientsOrig),
83
+ enabled_clients: (0, utils_1.mapClientID2NameSorted)(database.enabled_clients, context.assets.clientsOrig || []),
84
84
  })), { options: Object.assign(Object.assign({}, database.options), (database.options.customScripts && {
85
85
  customScripts: Object.entries(database.options.customScripts)
86
86
  //@ts-ignore
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedEmailProvider = {
3
- emailProvider: unknown;
4
- } | {};
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedEmailProvider = ParsedAsset<'emailProvider', Asset>;
5
4
  declare const emailProviderHandler: DirectoryHandler<ParsedEmailProvider>;
6
5
  export default emailProviderHandler;
@@ -20,26 +20,28 @@ const defaults_1 = require("../../defaults");
20
20
  function parse(context) {
21
21
  const emailsFolder = path_1.default.join(context.filePath, tools_1.constants.EMAIL_TEMPLATES_DIRECTORY);
22
22
  if (!(0, utils_1.existsMustBeDir)(emailsFolder))
23
- return {}; // Skip
23
+ return { emailProvider: null }; // Skip
24
24
  const providerFile = path_1.default.join(emailsFolder, 'provider.json');
25
25
  if ((0, utils_1.isFile)(providerFile)) {
26
26
  return {
27
27
  emailProvider: (0, utils_1.loadJSON)(providerFile, context.mappings),
28
28
  };
29
29
  }
30
- return {};
30
+ return { emailProvider: null };
31
31
  }
32
32
  function dump(context) {
33
- var _a;
34
33
  return __awaiter(this, void 0, void 0, function* () {
35
- let { emailProvider } = context.assets;
36
- if (!emailProvider)
34
+ if (!context.assets.emailProvider)
37
35
  return; // Skip, nothing to dump
38
- const excludedDefaults = ((_a = context.assets.exclude) === null || _a === void 0 ? void 0 : _a.defaults) || [];
39
- if (!excludedDefaults.includes('emailProvider')) {
40
- // Add placeholder for credentials as they cannot be exported
41
- emailProvider = (0, defaults_1.emailProviderDefaults)(emailProvider);
42
- }
36
+ const emailProvider = (() => {
37
+ var _a;
38
+ const excludedDefaults = ((_a = context.assets.exclude) === null || _a === void 0 ? void 0 : _a.defaults) || [];
39
+ if (!excludedDefaults.includes('emailProvider')) {
40
+ // Add placeholder for credentials as they cannot be exported
41
+ return (0, defaults_1.emailProviderDefaults)(context.assets.emailProvider);
42
+ }
43
+ return context.assets.emailProvider;
44
+ })();
43
45
  const emailsFolder = path_1.default.join(context.filePath, tools_1.constants.EMAIL_TEMPLATES_DIRECTORY);
44
46
  fs_extra_1.default.ensureDirSync(emailsFolder);
45
47
  const emailProviderFile = path_1.default.join(emailsFolder, 'provider.json');
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedEmailTemplates = {
3
- emailTemplates: unknown | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedEmailTemplates = ParsedAsset<'emailTemplates', Asset[]>;
5
4
  declare const emailTemplatesHandler: DirectoryHandler<ParsedEmailTemplates>;
6
5
  export default emailTemplatesHandler;
@@ -20,7 +20,7 @@ const utils_1 = require("../../../utils");
20
20
  function parse(context) {
21
21
  const emailsFolder = path_1.default.join(context.filePath, tools_1.constants.EMAIL_TEMPLATES_DIRECTORY);
22
22
  if (!(0, utils_1.existsMustBeDir)(emailsFolder))
23
- return { emailTemplates: undefined }; // Skip
23
+ return { emailTemplates: null }; // Skip
24
24
  const files = (0, utils_1.getFiles)(emailsFolder, ['.json', '.html']).filter((f) => path_1.default.basename(f) !== 'provider.json');
25
25
  const sorted = {};
26
26
  files.forEach((file) => {
@@ -51,7 +51,7 @@ function parse(context) {
51
51
  }
52
52
  function dump(context) {
53
53
  return __awaiter(this, void 0, void 0, function* () {
54
- const emailTemplates = [...(context.assets.emailTemplates || [])];
54
+ const emailTemplates = context.assets.emailTemplates;
55
55
  if (!emailTemplates)
56
56
  return; // Skip, nothing to dump
57
57
  // Create Templates folder
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedGuardianFactorProviders = {
3
- guardianFactorProviders: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianFactorProviders = ParsedAsset<'guardianFactorProviders', Asset[]>;
5
4
  declare const guardianFactorProvidersHandler: DirectoryHandler<ParsedGuardianFactorProviders>;
6
5
  export default guardianFactorProvidersHandler;
@@ -19,7 +19,7 @@ const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
20
  const factorProvidersFolder = path_1.default.join(context.filePath, tools_1.constants.GUARDIAN_DIRECTORY, tools_1.constants.GUARDIAN_PROVIDERS_DIRECTORY);
21
21
  if (!(0, utils_1.existsMustBeDir)(factorProvidersFolder))
22
- return { guardianFactorProviders: undefined }; // Skip
22
+ return { guardianFactorProviders: null }; // Skip
23
23
  const foundFiles = (0, utils_1.getFiles)(factorProvidersFolder, ['.json']);
24
24
  const guardianFactorProviders = foundFiles
25
25
  .map((f) => (0, utils_1.loadJSON)(f, context.mappings))
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedGuardianFactorTemplates = {
3
- guardianFactorTemplates: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianFactorTemplates = ParsedAsset<'guardianFactorTemplates', Asset[]>;
5
4
  declare const guardianFactorTemplatesHandler: DirectoryHandler<ParsedGuardianFactorTemplates>;
6
5
  export default guardianFactorTemplatesHandler;
@@ -19,7 +19,7 @@ const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
20
  const factorTemplatesFolder = path_1.default.join(context.filePath, tools_1.constants.GUARDIAN_DIRECTORY, tools_1.constants.GUARDIAN_TEMPLATES_DIRECTORY);
21
21
  if (!(0, utils_1.existsMustBeDir)(factorTemplatesFolder))
22
- return { guardianFactorTemplates: undefined }; // Skip
22
+ return { guardianFactorTemplates: null }; // Skip
23
23
  const foundFiles = (0, utils_1.getFiles)(factorTemplatesFolder, ['.json']);
24
24
  const guardianFactorTemplates = foundFiles
25
25
  .map((f) => (0, utils_1.loadJSON)(f, context.mappings))
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedGuardianFactors = {
3
- guardianFactors: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianFactors = ParsedAsset<'guardianFactors', Asset[]>;
5
4
  declare const guardianFactorsHandler: DirectoryHandler<ParsedGuardianFactors>;
6
5
  export default guardianFactorsHandler;
@@ -19,7 +19,7 @@ const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
20
  const factorsFolder = path_1.default.join(context.filePath, tools_1.constants.GUARDIAN_DIRECTORY, tools_1.constants.GUARDIAN_FACTORS_DIRECTORY);
21
21
  if (!(0, utils_1.existsMustBeDir)(factorsFolder))
22
- return { guardianFactors: undefined }; // Skip
22
+ return { guardianFactors: null }; // Skip
23
23
  const foundFiles = (0, utils_1.getFiles)(factorsFolder, ['.json']);
24
24
  const guardianFactors = foundFiles
25
25
  .map((f) => (0, utils_1.loadJSON)(f, context.mappings))
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedGuardianFactorMessageTypes = {
3
- guardianPhoneFactorMessageTypes: unknown;
4
- } | {};
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianFactorMessageTypes = ParsedAsset<'guardianPhoneFactorMessageTypes', Asset>;
5
4
  declare const guardianFactorMessageTypesHandler: DirectoryHandler<ParsedGuardianFactorMessageTypes>;
6
5
  export default guardianFactorMessageTypesHandler;
@@ -19,14 +19,14 @@ const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
20
  const guardianFolder = path_1.default.join(context.filePath, tools_1.constants.GUARDIAN_DIRECTORY);
21
21
  if (!(0, utils_1.existsMustBeDir)(guardianFolder))
22
- return {}; // Skip
22
+ return { guardianPhoneFactorMessageTypes: null }; // Skip
23
23
  const file = path_1.default.join(guardianFolder, 'phoneFactorMessageTypes.json');
24
- if ((0, utils_1.isFile)(file)) {
25
- return {
26
- guardianPhoneFactorMessageTypes: (0, utils_1.loadJSON)(file, context.mappings),
27
- };
24
+ if (!(0, utils_1.isFile)(file)) {
25
+ return { guardianPhoneFactorMessageTypes: null };
28
26
  }
29
- return {};
27
+ return {
28
+ guardianPhoneFactorMessageTypes: (0, utils_1.loadJSON)(file, context.mappings),
29
+ };
30
30
  }
31
31
  function dump(context) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedGuardianFactorSelectedProvider = {
3
- guardianPhoneFactorSelectedProvider: unknown;
4
- } | {};
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianFactorSelectedProvider = ParsedAsset<'guardianPhoneFactorSelectedProvider', Asset>;
5
4
  declare const guardianFactorSelectedProviderHandler: DirectoryHandler<ParsedGuardianFactorSelectedProvider>;
6
5
  export default guardianFactorSelectedProviderHandler;
@@ -19,14 +19,14 @@ const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
20
  const guardianFolder = path_1.default.join(context.filePath, tools_1.constants.GUARDIAN_DIRECTORY);
21
21
  if (!(0, utils_1.existsMustBeDir)(guardianFolder))
22
- return {}; // Skip
22
+ return { guardianPhoneFactorSelectedProvider: null }; // Skip
23
23
  const file = path_1.default.join(guardianFolder, 'phoneFactorSelectedProvider.json');
24
- if ((0, utils_1.isFile)(file)) {
25
- return {
26
- guardianPhoneFactorSelectedProvider: (0, utils_1.loadJSON)(file, context.mappings),
27
- };
24
+ if (!(0, utils_1.isFile)(file)) {
25
+ return { guardianPhoneFactorSelectedProvider: null };
28
26
  }
29
- return {};
27
+ return {
28
+ guardianPhoneFactorSelectedProvider: (0, utils_1.loadJSON)(file, context.mappings),
29
+ };
30
30
  }
31
31
  function dump(context) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedGuardianPolicies = {
3
- guardianPolicies: unknown[];
4
- } | {};
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianPolicies = ParsedAsset<'guardianPolicies', Asset[]>;
5
4
  declare const guardianPoliciesHandler: DirectoryHandler<ParsedGuardianPolicies>;
6
5
  export default guardianPoliciesHandler;
@@ -19,14 +19,14 @@ const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
20
  const guardianFolder = path_1.default.join(context.filePath, tools_1.constants.GUARDIAN_DIRECTORY);
21
21
  if (!(0, utils_1.existsMustBeDir)(guardianFolder))
22
- return {}; // Skip
22
+ return { guardianPolicies: null }; // Skip
23
23
  const file = path_1.default.join(guardianFolder, 'policies.json');
24
- if ((0, utils_1.isFile)(file)) {
25
- return {
26
- guardianPolicies: (0, utils_1.loadJSON)(file, context.mappings),
27
- };
24
+ if (!(0, utils_1.isFile)(file)) {
25
+ return { guardianPolicies: null };
28
26
  }
29
- return {};
27
+ return {
28
+ guardianPolicies: (0, utils_1.loadJSON)(file, context.mappings),
29
+ };
30
30
  }
31
31
  function dump(context) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedHooks = {
3
- hooks: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedHooks = ParsedAsset<'hooks', Asset[]>;
5
4
  declare const hooksHandler: DirectoryHandler<ParsedHooks>;
6
5
  export default hooksHandler;
@@ -20,7 +20,7 @@ const logger_1 = __importDefault(require("../../../logger"));
20
20
  function parse(context) {
21
21
  const hooksFolder = path_1.default.join(context.filePath, tools_1.constants.HOOKS_DIRECTORY);
22
22
  if (!(0, utils_1.existsMustBeDir)(hooksFolder))
23
- return { hooks: undefined }; // Skip
23
+ return { hooks: null }; // Skip
24
24
  const files = (0, utils_1.getFiles)(hooksFolder, ['.json']);
25
25
  const hooks = files.map((f) => {
26
26
  const hook = Object.assign({}, (0, utils_1.loadJSON)(f, context.mappings));
@@ -36,8 +36,8 @@ function parse(context) {
36
36
  }
37
37
  function dump(context) {
38
38
  return __awaiter(this, void 0, void 0, function* () {
39
- const hooks = [...(context.assets.hooks || [])];
40
- if (hooks.length < 1)
39
+ const hooks = context.assets.hooks;
40
+ if (!hooks)
41
41
  return;
42
42
  // Create Hooks folder
43
43
  const hooksFolder = path_1.default.join(context.filePath, tools_1.constants.HOOKS_DIRECTORY);
@@ -1,12 +1,12 @@
1
1
  import DirectoryContext from '..';
2
- import { AssetTypes } from '../../../types';
2
+ import { AssetTypes, Asset } from '../../../types';
3
3
  export declare type DirectoryHandler<T> = {
4
4
  dump: (context: DirectoryContext) => void;
5
5
  parse: (context: DirectoryContext) => T;
6
6
  };
7
7
  declare const directoryHandlers: {
8
8
  [key in AssetTypes]: DirectoryHandler<{
9
- [key: string]: unknown;
9
+ [key: string]: Asset | Asset[] | null;
10
10
  }>;
11
11
  };
12
12
  export default directoryHandlers;
@@ -1,7 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- import { Asset } from '../../../types';
3
- declare type ParsedLogStreams = {
4
- logStreams: Asset[] | undefined;
5
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedLogStreams = ParsedAsset<'logStreams', Asset[]>;
6
4
  declare const logStreamsHandler: DirectoryHandler<ParsedLogStreams>;
7
5
  export default logStreamsHandler;
@@ -19,7 +19,7 @@ const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
20
  const logStreamsDirectory = path_1.default.join(context.filePath, tools_1.constants.LOG_STREAMS_DIRECTORY);
21
21
  if (!(0, utils_1.existsMustBeDir)(logStreamsDirectory))
22
- return { logStreams: undefined }; // Skip
22
+ return { logStreams: null }; // Skip
23
23
  const foundFiles = (0, utils_1.getFiles)(logStreamsDirectory, ['.json']);
24
24
  const logStreams = foundFiles
25
25
  .map((f) => (0, utils_1.loadJSON)(f, context.mappings))
@@ -30,7 +30,7 @@ function parse(context) {
30
30
  }
31
31
  function dump(context) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
- const logStreams = context.assets.logStreams || [];
33
+ const logStreams = context.assets.logStreams;
34
34
  if (!logStreams)
35
35
  return; // Skip, nothing to dump
36
36
  // Create Rules folder
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedMigrations = {
3
- migrations: unknown[];
4
- } | {};
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedMigrations = ParsedAsset<'migrations', Asset[]>;
5
4
  declare const migrationsHandler: DirectoryHandler<ParsedMigrations>;
6
5
  export default migrationsHandler;