auth0-deploy-cli 7.8.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 (137) hide show
  1. package/CHANGELOG.md +40 -1
  2. package/README.md +2 -2
  3. package/lib/context/directory/handlers/actions.d.ts +2 -3
  4. package/lib/context/directory/handlers/actions.js +4 -4
  5. package/lib/context/directory/handlers/attackProtection.d.ts +6 -7
  6. package/lib/context/directory/handlers/attackProtection.js +3 -1
  7. package/lib/context/directory/handlers/branding.d.ts +2 -3
  8. package/lib/context/directory/handlers/branding.js +45 -21
  9. package/lib/context/directory/handlers/clientGrants.d.ts +2 -3
  10. package/lib/context/directory/handlers/clientGrants.js +3 -2
  11. package/lib/context/directory/handlers/clients.d.ts +2 -3
  12. package/lib/context/directory/handlers/clients.js +1 -1
  13. package/lib/context/directory/handlers/connections.d.ts +2 -3
  14. package/lib/context/directory/handlers/connections.js +3 -3
  15. package/lib/context/directory/handlers/databases.d.ts +2 -3
  16. package/lib/context/directory/handlers/databases.js +2 -2
  17. package/lib/context/directory/handlers/emailProvider.d.ts +2 -3
  18. package/lib/context/directory/handlers/emailProvider.js +12 -10
  19. package/lib/context/directory/handlers/emailTemplates.d.ts +2 -3
  20. package/lib/context/directory/handlers/emailTemplates.js +2 -2
  21. package/lib/context/directory/handlers/guardianFactorProviders.d.ts +2 -3
  22. package/lib/context/directory/handlers/guardianFactorProviders.js +1 -1
  23. package/lib/context/directory/handlers/guardianFactorTemplates.d.ts +2 -3
  24. package/lib/context/directory/handlers/guardianFactorTemplates.js +1 -1
  25. package/lib/context/directory/handlers/guardianFactors.d.ts +2 -3
  26. package/lib/context/directory/handlers/guardianFactors.js +1 -1
  27. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.d.ts +2 -3
  28. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +6 -6
  29. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.d.ts +2 -3
  30. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +6 -6
  31. package/lib/context/directory/handlers/guardianPolicies.d.ts +2 -3
  32. package/lib/context/directory/handlers/guardianPolicies.js +6 -6
  33. package/lib/context/directory/handlers/hooks.d.ts +2 -3
  34. package/lib/context/directory/handlers/hooks.js +3 -3
  35. package/lib/context/directory/handlers/index.d.ts +2 -2
  36. package/lib/context/directory/handlers/index.js +2 -0
  37. package/lib/context/directory/handlers/logStreams.d.ts +5 -0
  38. package/lib/context/directory/handlers/logStreams.js +49 -0
  39. package/lib/context/directory/handlers/migrations.d.ts +2 -3
  40. package/lib/context/directory/handlers/migrations.js +2 -2
  41. package/lib/context/directory/handlers/organizations.d.ts +2 -3
  42. package/lib/context/directory/handlers/organizations.js +1 -1
  43. package/lib/context/directory/handlers/pages.d.ts +2 -3
  44. package/lib/context/directory/handlers/pages.js +2 -2
  45. package/lib/context/directory/handlers/resourceServers.d.ts +2 -3
  46. package/lib/context/directory/handlers/resourceServers.js +1 -1
  47. package/lib/context/directory/handlers/roles.d.ts +2 -3
  48. package/lib/context/directory/handlers/roles.js +1 -1
  49. package/lib/context/directory/handlers/rules.d.ts +2 -3
  50. package/lib/context/directory/handlers/rules.js +2 -2
  51. package/lib/context/directory/handlers/rulesConfigs.d.ts +2 -3
  52. package/lib/context/directory/handlers/rulesConfigs.js +1 -1
  53. package/lib/context/directory/handlers/tenant.d.ts +7 -7
  54. package/lib/context/directory/handlers/tenant.js +11 -10
  55. package/lib/context/directory/handlers/triggers.d.ts +2 -3
  56. package/lib/context/directory/handlers/triggers.js +1 -1
  57. package/lib/context/yaml/handlers/actions.d.ts +2 -3
  58. package/lib/context/yaml/handlers/actions.js +6 -8
  59. package/lib/context/yaml/handlers/attackProtection.d.ts +6 -3
  60. package/lib/context/yaml/handlers/attackProtection.js +9 -1
  61. package/lib/context/yaml/handlers/branding.d.ts +9 -2
  62. package/lib/context/yaml/handlers/branding.js +33 -11
  63. package/lib/context/yaml/handlers/clientGrants.d.ts +2 -3
  64. package/lib/context/yaml/handlers/clientGrants.js +7 -6
  65. package/lib/context/yaml/handlers/clients.d.ts +2 -3
  66. package/lib/context/yaml/handlers/clients.js +6 -3
  67. package/lib/context/yaml/handlers/connections.d.ts +2 -3
  68. package/lib/context/yaml/handlers/connections.js +6 -9
  69. package/lib/context/yaml/handlers/databases.d.ts +3 -4
  70. package/lib/context/yaml/handlers/databases.js +7 -7
  71. package/lib/context/yaml/handlers/emailProvider.d.ts +2 -3
  72. package/lib/context/yaml/handlers/emailProvider.js +17 -10
  73. package/lib/context/yaml/handlers/emailTemplates.d.ts +2 -3
  74. package/lib/context/yaml/handlers/emailTemplates.js +16 -13
  75. package/lib/context/yaml/handlers/guardianFactorProviders.d.ts +2 -3
  76. package/lib/context/yaml/handlers/guardianFactorProviders.js +4 -2
  77. package/lib/context/yaml/handlers/guardianFactorTemplates.d.ts +2 -3
  78. package/lib/context/yaml/handlers/guardianFactorTemplates.js +4 -2
  79. package/lib/context/yaml/handlers/guardianFactors.d.ts +2 -3
  80. package/lib/context/yaml/handlers/guardianFactors.js +4 -2
  81. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.d.ts +2 -3
  82. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +4 -2
  83. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.d.ts +2 -3
  84. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +4 -2
  85. package/lib/context/yaml/handlers/guardianPolicies.d.ts +4 -3
  86. package/lib/context/yaml/handlers/guardianPolicies.js +4 -2
  87. package/lib/context/yaml/handlers/hooks.d.ts +2 -3
  88. package/lib/context/yaml/handlers/hooks.js +20 -19
  89. package/lib/context/yaml/handlers/index.d.ts +1 -1
  90. package/lib/context/yaml/handlers/index.js +2 -0
  91. package/lib/context/yaml/handlers/logStreams.d.ts +5 -0
  92. package/lib/context/yaml/handlers/logStreams.js +26 -0
  93. package/lib/context/yaml/handlers/migrations.d.ts +2 -3
  94. package/lib/context/yaml/handlers/migrations.js +5 -9
  95. package/lib/context/yaml/handlers/organizations.d.ts +2 -1
  96. package/lib/context/yaml/handlers/organizations.js +17 -15
  97. package/lib/context/yaml/handlers/pages.d.ts +2 -3
  98. package/lib/context/yaml/handlers/pages.js +20 -18
  99. package/lib/context/yaml/handlers/resourceServers.d.ts +2 -3
  100. package/lib/context/yaml/handlers/resourceServers.js +8 -13
  101. package/lib/context/yaml/handlers/roles.d.ts +2 -3
  102. package/lib/context/yaml/handlers/roles.js +13 -11
  103. package/lib/context/yaml/handlers/rules.d.ts +2 -3
  104. package/lib/context/yaml/handlers/rules.js +18 -17
  105. package/lib/context/yaml/handlers/rulesConfigs.d.ts +2 -3
  106. package/lib/context/yaml/handlers/rulesConfigs.js +9 -5
  107. package/lib/context/yaml/handlers/tenant.d.ts +2 -3
  108. package/lib/context/yaml/handlers/tenant.js +4 -3
  109. package/lib/context/yaml/handlers/triggers.d.ts +2 -3
  110. package/lib/context/yaml/handlers/triggers.js +2 -2
  111. package/lib/context/yaml/index.js +2 -1
  112. package/lib/index.d.ts +1 -0
  113. package/lib/tools/auth0/handlers/actions.js +3 -3
  114. package/lib/tools/auth0/handlers/branding.d.ts +2 -2
  115. package/lib/tools/auth0/handlers/clientGrants.js +1 -1
  116. package/lib/tools/auth0/handlers/connections.js +1 -1
  117. package/lib/tools/auth0/handlers/default.js +10 -2
  118. package/lib/tools/auth0/handlers/index.d.ts +5 -0
  119. package/lib/tools/auth0/handlers/index.js +2 -0
  120. package/lib/tools/auth0/handlers/logStreams.d.ts +40 -0
  121. package/lib/tools/auth0/handlers/logStreams.js +77 -0
  122. package/lib/tools/auth0/handlers/organizations.js +1 -1
  123. package/lib/tools/auth0/handlers/resourceServers.js +1 -1
  124. package/lib/tools/auth0/handlers/roles.js +1 -1
  125. package/lib/tools/auth0/handlers/rules.js +1 -1
  126. package/lib/tools/auth0/index.js +5 -2
  127. package/lib/tools/calculateChanges.d.ts +2 -2
  128. package/lib/tools/calculateChanges.js +2 -2
  129. package/lib/tools/constants.d.ts +1 -0
  130. package/lib/tools/constants.js +1 -0
  131. package/lib/tools/index.d.ts +1 -0
  132. package/lib/tools/utils.d.ts +9 -0
  133. package/lib/tools/utils.js +34 -2
  134. package/lib/types.d.ts +39 -29
  135. package/lib/utils.d.ts +34 -28
  136. package/lib/utils.js +1 -1
  137. package/package.json +11 -8
package/CHANGELOG.md CHANGED
@@ -7,6 +7,36 @@ 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
+
20
+ ## [7.10.0] - 2022-04-26
21
+
22
+ ### Added
23
+
24
+ - Branding support for directory format [#505]
25
+
26
+ ### Fixed
27
+
28
+ - More comprehensive support for deletions through `AUTH0_ALLOW_DELETE` [#509]
29
+
30
+ ## [7.9.0] - 2022-04-19
31
+
32
+ ### Added
33
+
34
+ - Log streams support [#495]
35
+
36
+ ### Fixed
37
+
38
+ - `##` String keyword replacements now work when nested inside `@@` array replacements [#504]
39
+
10
40
  ## [7.8.0] - 2022-04-14
11
41
 
12
42
  ### Added
@@ -677,8 +707,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
677
707
  [#481]: https://github.com/auth0/auth0-deploy-cli/issues/481
678
708
  [#482]: https://github.com/auth0/auth0-deploy-cli/issues/482
679
709
  [#485]: https://github.com/auth0/auth0-deploy-cli/issues/485
710
+ [#495]: https://github.com/auth0/auth0-deploy-cli/issues/495
680
711
  [#497]: https://github.com/auth0/auth0-deploy-cli/issues/497
681
- [unreleased]: https://github.com/auth0/auth0-deploy-cli/compare/v7.8.0...HEAD
712
+ [#504]: https://github.com/auth0/auth0-deploy-cli/issues/504
713
+ [#505]: https://github.com/auth0/auth0-deploy-cli/issues/505
714
+ [#509]: https://github.com/auth0/auth0-deploy-cli/issues/509
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
719
+ [7.10.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.9.0...v7.10.0
720
+ [7.9.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.8.0...v7.9.0
682
721
  [7.8.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.7.1...v7.8.0
683
722
  [7.7.1]: https://github.com/auth0/auth0-deploy-cli/compare/v7.7.0...v7.7.1
684
723
  [7.7.0]: https://github.com/auth0/auth0-deploy-cli/compare/v7.6.0...v7.7.0
package/README.md CHANGED
@@ -7,7 +7,7 @@ The `auth0-deploy-cli` tool supports the importing and exporting of Auth0 Tenant
7
7
  Supported Auth0 Management API resources
8
8
 
9
9
  - [x] [Actions](https://auth0.com/docs/api/management/v2/#!/Actions/get_actions)
10
- - [ ] [Branding](https://auth0.com/docs/api/management/v2/#!/Branding/get_branding)
10
+ - [x] [Branding](https://auth0.com/docs/api/management/v2/#!/Branding/get_branding)
11
11
  - [x] [Clients (Applications)](https://auth0.com/docs/api/management/v2#!/Clients/get_clients)
12
12
  - [x] [Client Grants](https://auth0.com/docs/api/management/v2#!/Client_Grants/get_client_grants)
13
13
  - [x] [Connections](https://auth0.com/docs/api/management/v2#!/Connections/get_connections)
@@ -16,7 +16,7 @@ Supported Auth0 Management API resources
16
16
  - [x] [Grants](https://auth0.com/docs/api/management/v2#!/Grants/get_grants)
17
17
  - [x] [Hooks](https://auth0.com/docs/api/management/v2#!/Hooks/get_hooks)
18
18
  - [x] [Hook Secrets](https://auth0.com/docs/api/management/v2/#!/Hooks/get_secrets)
19
- - [ ] [Log Streams](https://auth0.com/docs/api/management/v2#!/Log_Streams/get_log_streams)
19
+ - [x] [Log Streams](https://auth0.com/docs/api/management/v2#!/Log_Streams/get_log_streams)
20
20
  - [ ] [Logs](https://auth0.com/docs/api/management/v2#!/Logs/get_logs)
21
21
  - [x] [Organizations](https://auth0.com/docs/api/management/v2#!/Organizations/get_organizations)
22
22
  - [ ] [Prompts](https://auth0.com/docs/api/management/v2#!/Prompts/get_prompts)
@@ -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;
@@ -17,9 +17,13 @@ const path_1 = __importDefault(require("path"));
17
17
  const tools_1 = require("../../../tools");
18
18
  const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
- const brandingTemplatesFolder = path_1.default.join(context.filePath, tools_1.constants.BRANDING_DIRECTORY, tools_1.constants.BRANDING_TEMPLATES_DIRECTORY);
20
+ const brandingDirectory = path_1.default.join(context.filePath, tools_1.constants.BRANDING_DIRECTORY);
21
+ if (!(0, utils_1.existsMustBeDir)(brandingDirectory))
22
+ return { branding: null };
23
+ const branding = (0, utils_1.loadJSON)(path_1.default.join(brandingDirectory, 'branding.json'), context.mappings);
24
+ const brandingTemplatesFolder = path_1.default.join(brandingDirectory, tools_1.constants.BRANDING_TEMPLATES_DIRECTORY);
21
25
  if (!(0, utils_1.existsMustBeDir)(brandingTemplatesFolder))
22
- return { branding: context.assets.branding };
26
+ return { branding: null };
23
27
  const templatesDefinitionFiles = (0, utils_1.getFiles)(brandingTemplatesFolder, ['.json']);
24
28
  const templates = templatesDefinitionFiles.map((templateDefinitionFile) => {
25
29
  const definition = (0, utils_1.loadJSON)(templateDefinitionFile, context.mappings);
@@ -27,32 +31,52 @@ function parse(context) {
27
31
  return definition;
28
32
  }, {});
29
33
  return {
30
- branding: {
31
- templates,
32
- },
34
+ branding: Object.assign(Object.assign({}, branding), { templates }),
33
35
  };
34
36
  }
35
37
  function dump(context) {
36
38
  return __awaiter(this, void 0, void 0, function* () {
37
39
  const { branding } = context.assets;
38
- if (!branding || !branding.templates || !branding.templates)
39
- return; // Skip, nothing to dump
40
- const brandingTemplatesFolder = path_1.default.join(context.filePath, tools_1.constants.BRANDING_DIRECTORY, tools_1.constants.BRANDING_TEMPLATES_DIRECTORY);
41
- fs_extra_1.default.ensureDirSync(brandingTemplatesFolder);
42
- branding.templates.forEach((templateDefinition) => {
43
- const markup = templateDefinition.body;
44
- try {
45
- fs_extra_1.default.writeFileSync(path_1.default.join(brandingTemplatesFolder, `${templateDefinition.template}.html`), markup);
46
- }
47
- catch (e) {
48
- throw new Error(`Error writing template file: ${templateDefinition.template}, because: ${e.message}`);
49
- }
50
- // save the location as relative file.
51
- templateDefinition.body = `.${path_1.default.sep}${templateDefinition.template}.html`;
52
- (0, utils_1.dumpJSON)(path_1.default.join(brandingTemplatesFolder, `${templateDefinition.template}.json`), templateDefinition);
53
- });
40
+ if (!branding)
41
+ return;
42
+ dumpBranding(context);
43
+ if (!!branding.templates)
44
+ dumpBrandingTemplates(context);
54
45
  });
55
46
  }
47
+ const dumpBrandingTemplates = ({ filePath, assets }) => {
48
+ if (!assets.branding || !assets.branding.templates)
49
+ return;
50
+ const { branding: { templates = [] }, } = assets;
51
+ const brandingTemplatesFolder = path_1.default.join(filePath, tools_1.constants.BRANDING_DIRECTORY, tools_1.constants.BRANDING_TEMPLATES_DIRECTORY);
52
+ fs_extra_1.default.ensureDirSync(brandingTemplatesFolder);
53
+ templates.forEach((templateDefinition) => {
54
+ const markup = templateDefinition.body;
55
+ try {
56
+ fs_extra_1.default.writeFileSync(path_1.default.join(brandingTemplatesFolder, `${templateDefinition.template}.html`), markup);
57
+ }
58
+ catch (e) {
59
+ throw new Error(`Error writing template file: ${templateDefinition.template}, because: ${e.message}`);
60
+ }
61
+ // save the location as relative file.
62
+ templateDefinition.body = `.${path_1.default.sep}${templateDefinition.template}.html`;
63
+ (0, utils_1.dumpJSON)(path_1.default.join(brandingTemplatesFolder, `${templateDefinition.template}.json`), templateDefinition);
64
+ });
65
+ };
66
+ const dumpBranding = ({ filePath, assets }) => {
67
+ if (!assets || !assets.branding)
68
+ return;
69
+ const { branding } = assets;
70
+ const brandingWithoutTemplates = (() => {
71
+ const newBranding = Object.assign({}, branding);
72
+ delete newBranding.templates;
73
+ return newBranding;
74
+ })();
75
+ const brandingDirectory = path_1.default.join(filePath, tools_1.constants.BRANDING_DIRECTORY);
76
+ fs_extra_1.default.ensureDirSync(brandingDirectory);
77
+ const brandingFilePath = path_1.default.join(brandingDirectory, 'branding.json');
78
+ (0, utils_1.dumpJSON)(brandingFilePath, brandingWithoutTemplates);
79
+ };
56
80
  const brandingHandler = {
57
81
  parse,
58
82
  dump,
@@ -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;