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
@@ -17,10 +17,10 @@ const utils_1 = require("../../../utils");
17
17
  function parse(context) {
18
18
  const baseFolder = path_1.default.join(context.filePath);
19
19
  if (!(0, utils_1.existsMustBeDir)(baseFolder))
20
- return {}; // Skip
20
+ return { migrations: null }; // Skip
21
21
  const migrationsFile = path_1.default.join(baseFolder, 'migrations.json');
22
22
  if (!(0, utils_1.isFile)(migrationsFile))
23
- return {};
23
+ return { migrations: null };
24
24
  /* eslint-disable camelcase */
25
25
  const migrations = (0, utils_1.loadJSON)(migrationsFile, context.mappings);
26
26
  return { migrations };
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedOrganizations = {
3
- organizations: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedOrganizations = ParsedAsset<'organizations', Asset[]>;
5
4
  declare const organizationsHandler: DirectoryHandler<ParsedOrganizations>;
6
5
  export default organizationsHandler;
@@ -19,7 +19,7 @@ const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
20
  const organizationsFolder = path_1.default.join(context.filePath, 'organizations');
21
21
  if (!(0, utils_1.existsMustBeDir)(organizationsFolder))
22
- return { organizations: undefined }; // Skip
22
+ return { organizations: null }; // Skip
23
23
  const files = (0, utils_1.getFiles)(organizationsFolder, ['.json']);
24
24
  const organizations = files.map((f) => {
25
25
  const org = Object.assign({}, (0, utils_1.loadJSON)(f, context.mappings));
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedPages = {
3
- pages: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedPages = ParsedAsset<'pages', Asset[]>;
5
4
  declare const pagesHandler: DirectoryHandler<ParsedPages>;
6
5
  export default pagesHandler;
@@ -20,7 +20,7 @@ const utils_1 = require("../../../utils");
20
20
  function parse(context) {
21
21
  const pagesFolder = path_1.default.join(context.filePath, tools_1.constants.PAGES_DIRECTORY);
22
22
  if (!(0, utils_1.existsMustBeDir)(pagesFolder))
23
- return { pages: undefined }; // Skip
23
+ return { pages: null }; // Skip
24
24
  const files = (0, utils_1.getFiles)(pagesFolder, ['.json', '.html']);
25
25
  const sorted = files.reduce((acc, file) => {
26
26
  const { ext, name } = path_1.default.parse(file);
@@ -49,7 +49,7 @@ function parse(context) {
49
49
  }
50
50
  function dump(context) {
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
- const pages = [...(context.assets.pages || [])];
52
+ const pages = context.assets.pages;
53
53
  if (!pages)
54
54
  return; // Skip, nothing to dump
55
55
  // Create Pages folder
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedResourceServers = {
3
- resourceServers: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedResourceServers = ParsedAsset<'resourceServers', Asset[]>;
5
4
  declare const resourceServersHandler: DirectoryHandler<ParsedResourceServers>;
6
5
  export default resourceServersHandler;
@@ -19,7 +19,7 @@ const utils_1 = require("../../../utils");
19
19
  function parse(context) {
20
20
  const resourceServersFolder = path_1.default.join(context.filePath, tools_1.constants.RESOURCE_SERVERS_DIRECTORY);
21
21
  if (!(0, utils_1.existsMustBeDir)(resourceServersFolder))
22
- return { resourceServers: undefined }; // Skip
22
+ return { resourceServers: null }; // Skip
23
23
  const foundFiles = (0, utils_1.getFiles)(resourceServersFolder, ['.json']);
24
24
  const resourceServers = foundFiles
25
25
  .map((f) => (0, utils_1.loadJSON)(f, context.mappings))
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedRoles = {
3
- roles: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedRoles = ParsedAsset<'roles', Asset[]>;
5
4
  declare const rolesHandler: DirectoryHandler<ParsedRoles>;
6
5
  export default rolesHandler;
@@ -20,7 +20,7 @@ const utils_1 = require("../../../utils");
20
20
  function parse(context) {
21
21
  const rolesFolder = path_1.default.join(context.filePath, tools_1.constants.ROLES_DIRECTORY);
22
22
  if (!(0, utils_1.existsMustBeDir)(rolesFolder))
23
- return { roles: undefined }; // Skip
23
+ return { roles: null }; // Skip
24
24
  const files = (0, utils_1.getFiles)(rolesFolder, ['.json']);
25
25
  const roles = files.map((f) => {
26
26
  const role = Object.assign({}, (0, utils_1.loadJSON)(f, context.mappings));
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from './index';
2
- declare type ParsedRules = {
3
- rules: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedRules = ParsedAsset<'rules', Asset[]>;
5
4
  declare const rulesHandler: DirectoryHandler<ParsedRules>;
6
5
  export default rulesHandler;
@@ -20,7 +20,7 @@ const utils_1 = require("../../../utils");
20
20
  function parse(context) {
21
21
  const rulesFolder = path_1.default.join(context.filePath, tools_1.constants.RULES_DIRECTORY);
22
22
  if (!(0, utils_1.existsMustBeDir)(rulesFolder))
23
- return { rules: undefined }; // Skip
23
+ return { rules: null }; // Skip
24
24
  const files = (0, utils_1.getFiles)(rulesFolder, ['.json']);
25
25
  const rules = files.map((f) => {
26
26
  const rule = Object.assign({}, (0, utils_1.loadJSON)(f, context.mappings));
@@ -35,7 +35,7 @@ function parse(context) {
35
35
  }
36
36
  function dump(context) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
- const rules = [...(context.assets.rules || [])];
38
+ const { rules } = context.assets;
39
39
  if (!rules)
40
40
  return; // Skip, nothing to dump
41
41
  // Create Rules folder
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedRulesConfigs = {
3
- rulesConfigs: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedRulesConfigs = ParsedAsset<'rulesConfigs', Asset[]>;
5
4
  declare const rulesConfigsHandler: DirectoryHandler<ParsedRulesConfigs>;
6
5
  export default rulesConfigsHandler;
@@ -18,7 +18,7 @@ const utils_1 = require("../../../utils");
18
18
  function parse(context) {
19
19
  const rulesConfigsFolder = path_1.default.join(context.filePath, tools_1.constants.RULES_CONFIGS_DIRECTORY);
20
20
  if (!(0, utils_1.existsMustBeDir)(rulesConfigsFolder))
21
- return { rulesConfigs: undefined }; // Skip
21
+ return { rulesConfigs: null }; // Skip
22
22
  const foundFiles = (0, utils_1.getFiles)(rulesConfigsFolder, ['.json']);
23
23
  const rulesConfigs = foundFiles
24
24
  .map((f) => (0, utils_1.loadJSON)(f, context.mappings))
@@ -1,10 +1,10 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedTenant = {
3
- tenant: {
4
- session_lifetime: number;
5
- idle_session_lifetime: number;
6
- [key: string]: unknown;
7
- };
8
- } | {};
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedTenant = ParsedAsset<'tenant', {
4
+ session_lifetime: number;
5
+ idle_session_lifetime: number;
6
+ } & {
7
+ [key: string]: Asset;
8
+ }>;
9
9
  declare const tenantHandler: DirectoryHandler<ParsedTenant>;
10
10
  export default tenantHandler;
@@ -29,18 +29,19 @@ const sessionDurationsToMinutes_1 = require("../../../sessionDurationsToMinutes"
29
29
  function parse(context) {
30
30
  const baseFolder = path_1.default.join(context.filePath);
31
31
  if (!(0, utils_1.existsMustBeDir)(baseFolder))
32
- return {}; // Skip
32
+ return { tenant: null }; // Skip
33
33
  const tenantFile = path_1.default.join(baseFolder, 'tenant.json');
34
- if ((0, utils_1.isFile)(tenantFile)) {
35
- /* eslint-disable camelcase */
36
- const _a = (0, utils_1.loadJSON)(tenantFile, context.mappings), { session_lifetime, idle_session_lifetime } = _a, tenant = __rest(_a, ["session_lifetime", "idle_session_lifetime"]);
37
- (0, utils_1.clearTenantFlags)(tenant);
38
- const sessionDurations = (0, sessionDurationsToMinutes_1.sessionDurationsToMinutes)({ session_lifetime, idle_session_lifetime });
39
- return {
40
- tenant: Object.assign(Object.assign({}, tenant), sessionDurations),
41
- };
34
+ if (!(0, utils_1.isFile)(tenantFile)) {
35
+ return { tenant: null };
42
36
  }
43
- return {};
37
+ /* eslint-disable camelcase */
38
+ const _a = (0, utils_1.loadJSON)(tenantFile, context.mappings), { session_lifetime, idle_session_lifetime } = _a, tenant = __rest(_a, ["session_lifetime", "idle_session_lifetime"]);
39
+ (0, utils_1.clearTenantFlags)(tenant);
40
+ const sessionDurations = (0, sessionDurationsToMinutes_1.sessionDurationsToMinutes)({ session_lifetime, idle_session_lifetime });
41
+ return {
42
+ //@ts-ignore
43
+ tenant: Object.assign(Object.assign({}, tenant), sessionDurations),
44
+ };
44
45
  }
45
46
  function dump(context) {
46
47
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,6 +1,5 @@
1
1
  import { DirectoryHandler } from '.';
2
- declare type ParsedTriggers = {
3
- triggers: unknown[] | undefined;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedTriggers = ParsedAsset<'triggers', Asset[]>;
5
4
  declare const triggersHandler: DirectoryHandler<ParsedTriggers>;
6
5
  export default triggersHandler;
@@ -20,7 +20,7 @@ const logger_1 = __importDefault(require("../../../logger"));
20
20
  function parse(context) {
21
21
  const triggersFolder = path_1.default.join(context.filePath, tools_1.constants.TRIGGERS_DIRECTORY);
22
22
  if (!(0, utils_1.existsMustBeDir)(triggersFolder))
23
- return { triggers: undefined }; // Skip
23
+ return { triggers: null }; // Skip
24
24
  const files = (0, utils_1.getFiles)(triggersFolder, ['.json']);
25
25
  const triggers = Object.assign({}, (0, utils_1.loadJSON)(files[0], context.mappings));
26
26
  return { triggers };
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } 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: YAMLHandler<ParsedActions>;
6
5
  export default ActionsHandler;
@@ -27,15 +27,14 @@ function parseCode(context, code) {
27
27
  function parse(context) {
28
28
  return __awaiter(this, void 0, void 0, function* () {
29
29
  // Load the script file for each action
30
- //@ts-ignore TODO: understand if empty array is intentionally being returned
31
- if (!context.assets.actions)
32
- return [];
33
- const actions = {
30
+ const { actions } = context.assets;
31
+ if (!actions)
32
+ return { actions: null };
33
+ return {
34
34
  actions: [
35
- ...context.assets.actions.map((action) => (Object.assign(Object.assign({}, action), { code: parseCode(context, action.code) }))),
35
+ ...actions.map((action) => (Object.assign(Object.assign({}, action), { code: parseCode(context, action.code) }))),
36
36
  ],
37
37
  };
38
- return actions;
39
38
  });
40
39
  }
41
40
  function mapSecrets(secrets) {
@@ -60,9 +59,8 @@ function mapActionCode(basePath, action) {
60
59
  function dump(context) {
61
60
  return __awaiter(this, void 0, void 0, function* () {
62
61
  const { actions } = context.assets;
63
- //@ts-ignore TODO: need to investigate why returning void here when other handlers do not
64
62
  if (!actions)
65
- return; // Nothing to do
63
+ return { actions: null };
66
64
  return {
67
65
  actions: actions.map((action) => ({
68
66
  name: action.name,
@@ -1,6 +1,9 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedAttackProtection = {
3
- attackProtection: unknown;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedAttackProtection = ParsedAsset<'attackProtection', {
4
+ breachedPasswordDetection: Asset;
5
+ bruteForceProtection: Asset;
6
+ suspiciousIpThrottling: Asset;
7
+ }>;
5
8
  declare const attackProtectionHandler: YAMLHandler<ParsedAttackProtection>;
6
9
  export default attackProtectionHandler;
@@ -11,8 +11,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  function parseAndDump(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
+ const { attackProtection } = context.assets;
15
+ if (!attackProtection)
16
+ return { attackProtection: null };
17
+ const { suspiciousIpThrottling, breachedPasswordDetection, bruteForceProtection } = attackProtection;
14
18
  return {
15
- attackProtection: context.assets.attackProtection || {},
19
+ attackProtection: {
20
+ suspiciousIpThrottling,
21
+ breachedPasswordDetection,
22
+ bruteForceProtection,
23
+ },
16
24
  };
17
25
  });
18
26
  }
@@ -1,13 +1,13 @@
1
1
  import { YAMLHandler } from '.';
2
+ import { Asset, ParsedAsset } from '../../../types';
2
3
  declare type BrandingTemplate = {
3
4
  template: string;
4
5
  body: string;
5
6
  };
6
- declare type ParsedBranding = {
7
- branding: {
8
- templates?: BrandingTemplate[];
9
- [key: string]: unknown;
10
- };
11
- };
7
+ declare type ParsedBranding = ParsedAsset<'branding', {
8
+ [key: string]: Asset;
9
+ } & {
10
+ templates?: BrandingTemplate[];
11
+ }>;
12
12
  declare const brandingHandler: YAMLHandler<ParsedBranding>;
13
13
  export default brandingHandler;
@@ -35,9 +35,12 @@ function parse(context) {
35
35
  templates: [],
36
36
  },
37
37
  };
38
+ if (!context.assets.branding)
39
+ return { branding: null };
38
40
  const _a = context.assets.branding, { templates } = _a, branding = __rest(_a, ["templates"]);
39
- if (!branding && !branding['templates'])
40
- return { branding };
41
+ if (!templates) {
42
+ return { branding: Object.assign({}, branding) };
43
+ }
41
44
  const parsedTemplates = templates.map((templateDefinition) => {
42
45
  const markupFile = path_1.default.join(context.basePath, templateDefinition.body);
43
46
  return {
@@ -53,12 +56,14 @@ function parse(context) {
53
56
  function dump(context) {
54
57
  return __awaiter(this, void 0, void 0, function* () {
55
58
  const { branding } = context.assets;
56
- branding.templates = branding.templates || [];
59
+ if (!branding)
60
+ return { branding: null };
61
+ let templates = branding.templates || [];
57
62
  // create templates folder
58
- if (branding.templates.length) {
63
+ if (templates.length) {
59
64
  const brandingTemplatesFolder = path_1.default.join(context.basePath, tools_1.constants.BRANDING_TEMPLATES_YAML_DIRECTORY);
60
65
  fs_extra_1.default.ensureDirSync(brandingTemplatesFolder);
61
- branding.templates = branding.templates.map((templateDefinition) => {
66
+ templates = templates.map((templateDefinition) => {
62
67
  const file = `${templateDefinition.template}.html`;
63
68
  const templateMarkupFile = path_1.default.join(brandingTemplatesFolder, file);
64
69
  const markup = templateDefinition.body;
@@ -73,7 +78,7 @@ function dump(context) {
73
78
  return templateDefinition;
74
79
  });
75
80
  }
76
- return { branding };
81
+ return { branding: { templates } };
77
82
  });
78
83
  }
79
84
  const brandingHandler = {
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedClientGrants = {
3
- clientGrants: unknown[];
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedClientGrants = ParsedAsset<'clientGrants', Asset[]>;
5
4
  declare const clientGrantsHandler: YAMLHandler<ParsedClientGrants>;
6
5
  export default clientGrantsHandler;
@@ -12,23 +12,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const utils_1 = require("../../../utils");
13
13
  function parse(context) {
14
14
  return __awaiter(this, void 0, void 0, function* () {
15
- // nothing to do, set default empty
15
+ const { clientGrants } = context.assets;
16
+ if (!clientGrants)
17
+ return { clientGrants: null };
16
18
  return {
17
- clientGrants: context.assets.clientGrants,
19
+ clientGrants,
18
20
  };
19
21
  });
20
22
  }
21
23
  function dump(context) {
22
24
  return __awaiter(this, void 0, void 0, function* () {
23
- const { clientGrants } = context.assets;
24
- // Nothing to do
25
+ const { clientGrants, clients } = context.assets;
25
26
  if (!clientGrants)
26
- return {};
27
+ return { clientGrants: null };
27
28
  // Convert client_id to the client name for readability
28
29
  return {
29
30
  clientGrants: clientGrants.map((grant) => {
30
31
  const dumpGrant = Object.assign({}, grant);
31
- dumpGrant.client_id = (0, utils_1.convertClientIdToName)(dumpGrant.client_id, context.assets.clients);
32
+ dumpGrant.client_id = (0, utils_1.convertClientIdToName)(dumpGrant.client_id, clients || []);
32
33
  return dumpGrant;
33
34
  }),
34
35
  };
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedClients = {
3
- clients: unknown[];
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedClients = ParsedAsset<'clients', Asset[]>;
5
4
  declare const clientsHandler: YAMLHandler<ParsedClients>;
6
5
  export default clientsHandler;
@@ -22,8 +22,8 @@ function parse(context) {
22
22
  // Load the HTML file for custom_login_page
23
23
  const { clients } = context.assets;
24
24
  const clientsFolder = path_1.default.join(context.basePath, tools_1.constants.CLIENTS_DIRECTORY);
25
- if (!clients || !clients.length) {
26
- return { clients: context.assets.clients };
25
+ if (!clients) {
26
+ return { clients: null };
27
27
  }
28
28
  return {
29
29
  clients: [
@@ -44,9 +44,12 @@ function dump(context) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
45
  // Save custom_login_page to a separate html file
46
46
  const clientsFolder = path_1.default.join(context.basePath, tools_1.constants.CLIENTS_DIRECTORY);
47
+ const { clients } = context.assets;
48
+ if (!clients)
49
+ return { clients: null };
47
50
  return {
48
51
  clients: [
49
- ...context.assets.clients.map((client) => {
52
+ ...clients.map((client) => {
50
53
  if (client.custom_login_page) {
51
54
  const clientName = (0, utils_1.sanitize)(client.name);
52
55
  const html = client.custom_login_page;
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedConnections = {
3
- connections: unknown[];
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedConnections = ParsedAsset<'connections', Asset[]>;
5
4
  declare const connectionsHandler: YAMLHandler<ParsedConnections>;
6
5
  export default connectionsHandler;
@@ -19,11 +19,10 @@ const logger_1 = __importDefault(require("../../../logger"));
19
19
  const utils_1 = require("../../../utils");
20
20
  function parse(context) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- // Load the HTML file for email connections
23
22
  const { connections } = context.assets;
24
23
  const connectionsFolder = path_1.default.join(context.basePath, tools_1.constants.CONNECTIONS_DIRECTORY);
25
- if (!connections || !connections.length) {
26
- return { connections: context.assets.connections };
24
+ if (!connections) {
25
+ return { connections: null };
27
26
  }
28
27
  return {
29
28
  connections: [
@@ -53,15 +52,13 @@ const getFormattedOptions = (connection, clients) => {
53
52
  };
54
53
  function dump(context) {
55
54
  return __awaiter(this, void 0, void 0, function* () {
56
- const { connections } = context.assets;
57
- // Nothing to do
55
+ const { connections, clients } = context.assets;
58
56
  if (!connections)
59
- return {};
60
- // nothing to do, set default if empty
57
+ return { connections: null };
61
58
  return {
62
59
  connections: connections.map((connection) => {
63
- const dumpedConnection = Object.assign(Object.assign(Object.assign({}, connection), getFormattedOptions(connection, context.assets.clients)), (connection.enabled_clients && {
64
- enabled_clients: (0, utils_1.mapClientID2NameSorted)(connection.enabled_clients, context.assets.clients),
60
+ const dumpedConnection = Object.assign(Object.assign(Object.assign({}, connection), getFormattedOptions(connection, clients)), (connection.enabled_clients && {
61
+ enabled_clients: (0, utils_1.mapClientID2NameSorted)(connection.enabled_clients, clients || []),
65
62
  }));
66
63
  if (dumpedConnection.strategy === 'email') {
67
64
  (0, utils_1.ensureProp)(connection, 'options.email.body');
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedDatabases = {
3
- databases: unknown[];
4
- };
5
- declare const databasesHandler: YAMLHandler<ParsedDatabases | {}>;
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedDatabases = ParsedAsset<'databases', Asset[]>;
4
+ declare const databasesHandler: YAMLHandler<ParsedDatabases>;
6
5
  export default databasesHandler;
@@ -19,11 +19,12 @@ const logger_1 = __importDefault(require("../../../logger"));
19
19
  function parse(context) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
21
  // Load the script file for custom db
22
- if (!context.assets.databases)
23
- return {};
22
+ const { databases } = context.assets;
23
+ if (!databases)
24
+ return { databases: null };
24
25
  return {
25
26
  databases: [
26
- ...context.assets.databases.map((database) => (Object.assign(Object.assign({}, database), { options: Object.assign(Object.assign({}, database.options), (database.options.customScripts && {
27
+ ...databases.map((database) => (Object.assign(Object.assign({}, database), { options: Object.assign(Object.assign({}, database.options), (database.options.customScripts && {
27
28
  customScripts: Object.entries(database.options.customScripts).reduce((scripts, [name, script]) => (Object.assign(Object.assign({}, scripts), { [name]: context.loadFile(script) })), {}),
28
29
  })) }))),
29
30
  ],
@@ -32,10 +33,9 @@ function parse(context) {
32
33
  }
33
34
  function dump(context) {
34
35
  return __awaiter(this, void 0, void 0, function* () {
35
- const { databases } = context.assets;
36
- // Nothing to do
36
+ const { databases, clients } = context.assets;
37
37
  if (!databases)
38
- return {};
38
+ return { databases: null };
39
39
  const sortCustomScripts = ([name1], [name2]) => {
40
40
  if (name1 === name2)
41
41
  return 0;
@@ -44,7 +44,7 @@ function dump(context) {
44
44
  return {
45
45
  databases: [
46
46
  ...databases.map((database) => (Object.assign(Object.assign(Object.assign({}, database), (database.enabled_clients && {
47
- enabled_clients: (0, utils_1.mapClientID2NameSorted)(database.enabled_clients, context.assets.clients),
47
+ enabled_clients: (0, utils_1.mapClientID2NameSorted)(database.enabled_clients, clients || []),
48
48
  })), { options: Object.assign(Object.assign({}, database.options), (database.options.customScripts && {
49
49
  customScripts: Object.entries(database.options.customScripts)
50
50
  .sort(sortCustomScripts)
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } 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: YAMLHandler<ParsedEmailProvider>;
6
5
  export default emailProviderHandler;
@@ -12,23 +12,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const defaults_1 = require("../../defaults");
13
13
  function parse(context) {
14
14
  return __awaiter(this, void 0, void 0, function* () {
15
- // nothing to do, set default if empty
15
+ const { emailProvider } = context.assets;
16
+ if (!emailProvider)
17
+ return { emailProvider: null };
16
18
  return {
17
- emailProvider: Object.assign({}, (context.assets.emailProvider || {})),
19
+ emailProvider,
18
20
  };
19
21
  });
20
22
  }
21
23
  function dump(context) {
22
- var _a;
23
24
  return __awaiter(this, void 0, void 0, function* () {
24
- let { emailProvider } = context.assets;
25
- const excludedDefaults = ((_a = context.assets.exclude) === null || _a === void 0 ? void 0 : _a.defaults) || [];
26
- if (emailProvider && !excludedDefaults.includes('emailProvider')) {
27
- // Add placeholder for credentials as they cannot be exported
28
- emailProvider = (0, defaults_1.emailProviderDefaults)(emailProvider);
29
- }
25
+ if (!context.assets.emailProvider)
26
+ return { emailProvider: null };
27
+ const emailProvider = (() => {
28
+ var _a;
29
+ const { emailProvider } = context.assets;
30
+ const excludedDefaults = ((_a = context.assets.exclude) === null || _a === void 0 ? void 0 : _a.defaults) || [];
31
+ if (emailProvider && !excludedDefaults.includes('emailProvider')) {
32
+ // Add placeholder for credentials as they cannot be exported
33
+ return (0, defaults_1.emailProviderDefaults)(emailProvider);
34
+ }
35
+ return emailProvider;
36
+ })();
30
37
  return {
31
- emailProvider: emailProvider || {},
38
+ emailProvider,
32
39
  };
33
40
  });
34
41
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedEmailTemplates = {
3
- emailTemplates: unknown[];
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedEmailTemplates = ParsedAsset<'emailTemplates', Asset[]>;
5
4
  declare const emailTemplatesHandler: YAMLHandler<ParsedEmailTemplates>;
6
5
  export default emailTemplatesHandler;