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
@@ -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;
@@ -28,6 +28,7 @@ const organizations_1 = __importDefault(require("./organizations"));
28
28
  const triggers_1 = __importDefault(require("./triggers"));
29
29
  const attackProtection_1 = __importDefault(require("./attackProtection"));
30
30
  const branding_1 = __importDefault(require("./branding"));
31
+ const logStreams_1 = __importDefault(require("./logStreams"));
31
32
  const directoryHandlers = {
32
33
  rules: rules_1.default,
33
34
  rulesConfigs: rulesConfigs_1.default,
@@ -54,5 +55,6 @@ const directoryHandlers = {
54
55
  triggers: triggers_1.default,
55
56
  attackProtection: attackProtection_1.default,
56
57
  branding: branding_1.default,
58
+ logStreams: logStreams_1.default,
57
59
  };
58
60
  exports.default = directoryHandlers;
@@ -0,0 +1,5 @@
1
+ import { DirectoryHandler } from '.';
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedLogStreams = ParsedAsset<'logStreams', Asset[]>;
4
+ declare const logStreamsHandler: DirectoryHandler<ParsedLogStreams>;
5
+ export default logStreamsHandler;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const fs_extra_1 = __importDefault(require("fs-extra"));
16
+ const path_1 = __importDefault(require("path"));
17
+ const tools_1 = require("../../../tools");
18
+ const utils_1 = require("../../../utils");
19
+ function parse(context) {
20
+ const logStreamsDirectory = path_1.default.join(context.filePath, tools_1.constants.LOG_STREAMS_DIRECTORY);
21
+ if (!(0, utils_1.existsMustBeDir)(logStreamsDirectory))
22
+ return { logStreams: null }; // Skip
23
+ const foundFiles = (0, utils_1.getFiles)(logStreamsDirectory, ['.json']);
24
+ const logStreams = foundFiles
25
+ .map((f) => (0, utils_1.loadJSON)(f, context.mappings))
26
+ .filter((p) => Object.keys(p).length > 0); // Filter out empty rulesConfigs
27
+ return {
28
+ logStreams,
29
+ };
30
+ }
31
+ function dump(context) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const logStreams = context.assets.logStreams;
34
+ if (!logStreams)
35
+ return; // Skip, nothing to dump
36
+ // Create Rules folder
37
+ const logStreamsDirectory = path_1.default.join(context.filePath, tools_1.constants.LOG_STREAMS_DIRECTORY);
38
+ fs_extra_1.default.ensureDirSync(logStreamsDirectory);
39
+ logStreams.forEach((logStream) => {
40
+ const ruleFile = path_1.default.join(logStreamsDirectory, `${(0, utils_1.sanitize)(logStream.name)}.json`);
41
+ (0, utils_1.dumpJSON)(ruleFile, logStream);
42
+ });
43
+ });
44
+ }
45
+ const logStreamsHandler = {
46
+ parse,
47
+ dump,
48
+ };
49
+ exports.default = logStreamsHandler;
@@ -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;
@@ -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,6 +1,13 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedBranding = {
3
- branding: unknown;
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type BrandingTemplate = {
4
+ template: string;
5
+ body: string;
4
6
  };
7
+ declare type ParsedBranding = ParsedAsset<'branding', {
8
+ [key: string]: Asset;
9
+ } & {
10
+ templates?: BrandingTemplate[];
11
+ }>;
5
12
  declare const brandingHandler: YAMLHandler<ParsedBranding>;
6
13
  export default brandingHandler;
@@ -8,6 +8,17 @@ 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
+ };
11
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
24
  };
@@ -18,30 +29,41 @@ const tools_1 = require("../../../tools");
18
29
  function parse(context) {
19
30
  return __awaiter(this, void 0, void 0, function* () {
20
31
  // Load the HTML file for each page
21
- const { branding } = context.assets;
22
- if (!branding || !branding.templates)
23
- return { branding };
24
- const templates = branding.templates.map((templateDefinition) => {
25
- const markupFile = path_1.default.join(templateDefinition.body);
32
+ if (!context.assets.branding)
33
+ return {
34
+ branding: {
35
+ templates: [],
36
+ },
37
+ };
38
+ if (!context.assets.branding)
39
+ return { branding: null };
40
+ const _a = context.assets.branding, { templates } = _a, branding = __rest(_a, ["templates"]);
41
+ if (!templates) {
42
+ return { branding: Object.assign({}, branding) };
43
+ }
44
+ const parsedTemplates = templates.map((templateDefinition) => {
45
+ const markupFile = path_1.default.join(context.basePath, templateDefinition.body);
26
46
  return {
27
47
  template: templateDefinition.template,
28
48
  body: (0, tools_1.loadFileAndReplaceKeywords)(markupFile, context.mappings),
29
49
  };
30
50
  });
31
51
  return {
32
- branding: Object.assign(Object.assign({}, branding), { templates }),
52
+ branding: Object.assign(Object.assign({}, branding), { templates: parsedTemplates }),
33
53
  };
34
54
  });
35
55
  }
36
56
  function dump(context) {
37
57
  return __awaiter(this, void 0, void 0, function* () {
38
- const { branding } = context.assets || { branding: undefined };
39
- branding.templates = branding.templates || [];
58
+ const { branding } = context.assets;
59
+ if (!branding)
60
+ return { branding: null };
61
+ let templates = branding.templates || [];
40
62
  // create templates folder
41
- if (branding.templates.length) {
63
+ if (templates.length) {
42
64
  const brandingTemplatesFolder = path_1.default.join(context.basePath, tools_1.constants.BRANDING_TEMPLATES_YAML_DIRECTORY);
43
65
  fs_extra_1.default.ensureDirSync(brandingTemplatesFolder);
44
- branding.templates = branding.templates.map((templateDefinition) => {
66
+ templates = templates.map((templateDefinition) => {
45
67
  const file = `${templateDefinition.template}.html`;
46
68
  const templateMarkupFile = path_1.default.join(brandingTemplatesFolder, file);
47
69
  const markup = templateDefinition.body;
@@ -56,7 +78,7 @@ function dump(context) {
56
78
  return templateDefinition;
57
79
  });
58
80
  }
59
- return { branding };
81
+ return { branding: { templates } };
60
82
  });
61
83
  }
62
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;