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
@@ -18,7 +18,9 @@ const logger_1 = __importDefault(require("../../../logger"));
18
18
  function parse(context) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
20
  // Load the HTML file for each page
21
- const emailTemplates = context.assets.emailTemplates || [];
21
+ const { emailTemplates } = context.assets;
22
+ if (!emailTemplates)
23
+ return { emailTemplates: null };
22
24
  return {
23
25
  emailTemplates: [
24
26
  ...emailTemplates.map((et) => (Object.assign(Object.assign({}, et), { body: context.loadFile(et.body) }))),
@@ -28,19 +30,20 @@ function parse(context) {
28
30
  }
29
31
  function dump(context) {
30
32
  return __awaiter(this, void 0, void 0, function* () {
31
- let emailTemplates = [...(context.assets.emailTemplates || [])];
32
- if (emailTemplates.length > 0) {
33
- // Create Templates folder
34
- const templatesFolder = path_1.default.join(context.basePath, 'emailTemplates');
35
- fs_extra_1.default.ensureDirSync(templatesFolder);
36
- emailTemplates = emailTemplates.map((template) => {
37
- // Dump template to file
38
- const templateFile = path_1.default.join(templatesFolder, `${template.template}.html`);
39
- logger_1.default.info(`Writing ${templateFile}`);
40
- fs_extra_1.default.writeFileSync(templateFile, template.body);
41
- return Object.assign(Object.assign({}, template), { body: `./emailTemplates/${template.template}.html` });
42
- });
33
+ let emailTemplates = context.assets.emailTemplates;
34
+ if (!emailTemplates) {
35
+ return { emailTemplates: null };
43
36
  }
37
+ // Create Templates folder
38
+ const templatesFolder = path_1.default.join(context.basePath, 'emailTemplates');
39
+ fs_extra_1.default.ensureDirSync(templatesFolder);
40
+ emailTemplates = emailTemplates.map((template) => {
41
+ // Dump template to file
42
+ const templateFile = path_1.default.join(templatesFolder, `${template.template}.html`);
43
+ logger_1.default.info(`Writing ${templateFile}`);
44
+ fs_extra_1.default.writeFileSync(templateFile, template.body);
45
+ return Object.assign(Object.assign({}, template), { body: `./emailTemplates/${template.template}.html` });
46
+ });
44
47
  return { emailTemplates };
45
48
  });
46
49
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedGuardianFactorProviders = {
3
- guardianFactorProviders: unknown[];
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianFactorProviders = ParsedAsset<'guardianFactorProviders', Asset[]>;
5
4
  declare const guardianFactorProvidersHandler: YAMLHandler<ParsedGuardianFactorProviders>;
6
5
  export default guardianFactorProvidersHandler;
@@ -11,9 +11,11 @@ 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
- // nothing to do, set default empty
14
+ const { guardianFactorProviders } = context.assets;
15
+ if (!guardianFactorProviders)
16
+ return { guardianFactorProviders: null };
15
17
  return {
16
- guardianFactorProviders: [...(context.assets.guardianFactorProviders || [])],
18
+ guardianFactorProviders,
17
19
  };
18
20
  });
19
21
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedGuardianFactorTemplates = {
3
- guardianFactorTemplates: unknown[];
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianFactorTemplates = ParsedAsset<'guardianFactorTemplates', Asset[]>;
5
4
  declare const guardianFactorTemplatesHandler: YAMLHandler<ParsedGuardianFactorTemplates>;
6
5
  export default guardianFactorTemplatesHandler;
@@ -11,9 +11,11 @@ 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
- // nothing to do, set default if empty
14
+ const { guardianFactorTemplates } = context.assets;
15
+ if (!guardianFactorTemplates)
16
+ return { guardianFactorTemplates: null };
15
17
  return {
16
- guardianFactorTemplates: [...(context.assets.guardianFactorTemplates || [])],
18
+ guardianFactorTemplates,
17
19
  };
18
20
  });
19
21
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedGuardianFactors = {
3
- guardianFactors: unknown[];
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianFactors = ParsedAsset<'guardianFactors', Asset[]>;
5
4
  declare const guardianFactorsHandler: YAMLHandler<ParsedGuardianFactors>;
6
5
  export default guardianFactorsHandler;
@@ -11,9 +11,11 @@ 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
- // nothing to do, set default if empty
14
+ const { guardianFactors } = context.assets;
15
+ if (!guardianFactors)
16
+ return { guardianFactors: null };
15
17
  return {
16
- guardianFactors: [...(context.assets.guardianFactors || [])],
18
+ guardianFactors,
17
19
  };
18
20
  });
19
21
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } 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 guardianPhoneFactorMessageTypesHandler: YAMLHandler<ParsedGuardianFactorMessageTypes>;
6
5
  export default guardianPhoneFactorMessageTypesHandler;
@@ -11,9 +11,11 @@ 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
- // nothing to do, set default if empty
14
+ const { guardianPhoneFactorMessageTypes } = context.assets;
15
+ if (!guardianPhoneFactorMessageTypes)
16
+ return { guardianPhoneFactorMessageTypes: null };
15
17
  return {
16
- guardianPhoneFactorMessageTypes: Object.assign({}, (context.assets.guardianPhoneFactorMessageTypes || {})),
18
+ guardianPhoneFactorMessageTypes,
17
19
  };
18
20
  });
19
21
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedGuardianPhoneFactorSelectedProvider = {
3
- guardianPhoneFactorSelectedProvider: unknown;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianPhoneFactorSelectedProvider = ParsedAsset<'guardianPhoneFactorSelectedProvider', Asset>;
5
4
  declare const guardianPhoneFactorSelectedProviderHandler: YAMLHandler<ParsedGuardianPhoneFactorSelectedProvider>;
6
5
  export default guardianPhoneFactorSelectedProviderHandler;
@@ -11,9 +11,11 @@ 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
- // nothing to do, set default empty
14
+ const { guardianPhoneFactorSelectedProvider } = context.assets;
15
+ if (!guardianPhoneFactorSelectedProvider)
16
+ return { guardianPhoneFactorSelectedProvider: null };
15
17
  return {
16
- guardianPhoneFactorSelectedProvider: Object.assign({}, (context.assets.guardianPhoneFactorSelectedProvider || {})),
18
+ guardianPhoneFactorSelectedProvider,
17
19
  };
18
20
  });
19
21
  }
@@ -1,6 +1,7 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedGuardianPolicies = {
3
- guardianPolicies: unknown;
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedGuardianPolicies = ParsedAsset<'guardianPolicies', {
4
+ policies: Asset[];
5
+ }>;
5
6
  declare const guardianPoliciesHandler: YAMLHandler<ParsedGuardianPolicies>;
6
7
  export default guardianPoliciesHandler;
@@ -11,9 +11,11 @@ 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
- // nothing to do, set default if empty
14
+ const { guardianPolicies } = context.assets;
15
+ if (!guardianPolicies)
16
+ return { guardianPolicies: null };
15
17
  return {
16
- guardianPolicies: Object.assign({}, (context.assets.guardianPolicies || {})),
18
+ guardianPolicies,
17
19
  };
18
20
  });
19
21
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedHooks = {
3
- hooks: unknown[];
4
- } | {};
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedHooks = ParsedAsset<'hooks', Asset[]>;
5
4
  declare const hooksHandler: YAMLHandler<ParsedHooks>;
6
5
  export default hooksHandler;
@@ -19,12 +19,12 @@ const utils_1 = require("../../../utils");
19
19
  const logger_1 = __importDefault(require("../../../logger"));
20
20
  function parse(context) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- // Load the script file for each hook
23
- if (!context.assets.hooks)
24
- return {};
22
+ const { hooks } = context.assets;
23
+ if (!hooks)
24
+ return { hooks: null };
25
25
  return {
26
26
  hooks: [
27
- ...context.assets.hooks.map((hook) => {
27
+ ...hooks.map((hook) => {
28
28
  if (hook.script) {
29
29
  //@ts-ignore TODO: understand why two arguments are passed when context.loadFile only accepts one
30
30
  hook.script = context.loadFile(hook.script, tools_1.constants.HOOKS_DIRECTORY);
@@ -38,22 +38,23 @@ function parse(context) {
38
38
  }
39
39
  function dump(context) {
40
40
  return __awaiter(this, void 0, void 0, function* () {
41
- let hooks = [...(context.assets.hooks || [])];
42
- if (hooks.length > 0) {
43
- // Create hooks folder
44
- const hooksFolder = path_1.default.join(context.basePath, 'hooks');
45
- fs_extra_1.default.ensureDirSync(hooksFolder);
46
- hooks = hooks.map((hook) => {
47
- // Dump hook code to file
48
- // For cases when hook does not have `meta['hook-name']`
49
- hook.name = hook.name || hook.id;
50
- const codeName = (0, utils_1.sanitize)(`${hook.name}.js`);
51
- const codeFile = path_1.default.join(hooksFolder, codeName);
52
- logger_1.default.info(`Writing ${codeFile}`);
53
- fs_extra_1.default.writeFileSync(codeFile, hook.script);
54
- return Object.assign(Object.assign({}, hook), { script: `./hooks/${codeName}` });
55
- });
41
+ let hooks = context.assets.hooks;
42
+ if (!hooks) {
43
+ return { hooks: null };
56
44
  }
45
+ // Create hooks folder
46
+ const hooksFolder = path_1.default.join(context.basePath, 'hooks');
47
+ fs_extra_1.default.ensureDirSync(hooksFolder);
48
+ hooks = hooks.map((hook) => {
49
+ // Dump hook code to file
50
+ // For cases when hook does not have `meta['hook-name']`
51
+ hook.name = hook.name || hook.id;
52
+ const codeName = (0, utils_1.sanitize)(`${hook.name}.js`);
53
+ const codeFile = path_1.default.join(hooksFolder, codeName);
54
+ logger_1.default.info(`Writing ${codeFile}`);
55
+ fs_extra_1.default.writeFileSync(codeFile, hook.script);
56
+ return Object.assign(Object.assign({}, hook), { script: `./hooks/${codeName}` });
57
+ });
57
58
  return { hooks };
58
59
  });
59
60
  }
@@ -1,7 +1,7 @@
1
1
  import YAMLContext from '..';
2
2
  import { AssetTypes } from '../../../types';
3
3
  export declare type YAMLHandler<T> = {
4
- dump: (context: YAMLContext) => Promise<T | {}>;
4
+ dump: (context: YAMLContext) => Promise<T>;
5
5
  parse: (context: YAMLContext) => Promise<T>;
6
6
  };
7
7
  declare const yamlHandlers: {
@@ -1,7 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- import { Asset } from '../../../types';
3
- declare type ParsedLogStreams = {
4
- logStreams: Asset[] | null;
5
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedLogStreams = ParsedAsset<'logStreams', Asset[]>;
6
4
  declare const logStreamsHandler: YAMLHandler<ParsedLogStreams>;
7
5
  export default logStreamsHandler;
@@ -11,8 +11,11 @@ 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 { logStreams } = context.assets;
15
+ if (!logStreams)
16
+ return { logStreams: null };
14
17
  return {
15
- logStreams: context.assets.logStreams || [],
18
+ logStreams,
16
19
  };
17
20
  });
18
21
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } 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: YAMLHandler<ParsedMigrations>;
6
5
  export default migrationsHandler;
@@ -9,20 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- function parse(context) {
12
+ function parseAndDump(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  const { migrations } = context.assets;
15
+ if (!migrations)
16
+ return { migrations: null };
15
17
  return { migrations };
16
18
  });
17
19
  }
18
- function dump(context) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const { migrations } = context.assets;
21
- return { migrations: migrations || {} };
22
- });
23
- }
24
20
  const migrationsHandler = {
25
- parse,
26
- dump,
21
+ parse: parseAndDump,
22
+ dump: parseAndDump,
27
23
  };
28
24
  exports.default = migrationsHandler;
@@ -1,6 +1,7 @@
1
1
  import { YAMLHandler } from '.';
2
+ import { Asset } from '../../../types';
2
3
  declare type ParsedOrganizations = {
3
- organizations: unknown[];
4
+ organizations: Asset[] | null;
4
5
  };
5
6
  declare const organizationsHandler: YAMLHandler<ParsedOrganizations>;
6
7
  export default organizationsHandler;
@@ -12,29 +12,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  function parse(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
14
  const { organizations } = context.assets;
15
+ if (!organizations)
16
+ return { organizations: null };
15
17
  return {
16
- organizations: organizations,
18
+ organizations,
17
19
  };
18
20
  });
19
21
  }
20
22
  function dump(context) {
21
23
  return __awaiter(this, void 0, void 0, function* () {
22
24
  const { organizations } = context.assets;
25
+ if (!organizations)
26
+ return { organizations: null };
23
27
  return {
24
- organizations: [
25
- ...(organizations || []).map((org) => {
26
- if (org.connections.length > 0) {
27
- org.connections = org.connections.map((c) => {
28
- // connection is a computed field
29
- const name = c.connection && c.connection.name;
30
- delete c.connection_id;
31
- delete c.connection;
32
- return Object.assign({ name }, c);
33
- });
34
- }
35
- return org;
36
- }),
37
- ],
28
+ organizations: organizations.map((org) => {
29
+ if (org.connections.length > 0) {
30
+ org.connections = org.connections.map((c) => {
31
+ // connection is a computed field
32
+ const name = c.connection && c.connection.name;
33
+ delete c.connection_id;
34
+ delete c.connection;
35
+ return Object.assign({ name }, c);
36
+ });
37
+ }
38
+ return org;
39
+ }),
38
40
  };
39
41
  });
40
42
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedPages = {
3
- pages: unknown[];
4
- } | {};
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedPages = ParsedAsset<'pages', Asset[]>;
5
4
  declare const pagesHandler: YAMLHandler<ParsedPages>;
6
5
  export default pagesHandler;
@@ -18,33 +18,35 @@ const logger_1 = __importDefault(require("../../../logger"));
18
18
  function parse(context) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
20
  // Load the HTML file for each page
21
- if (!context.assets.pages)
22
- return {};
21
+ const { pages } = context.assets;
22
+ if (!pages)
23
+ return { pages: null };
23
24
  return {
24
25
  pages: [
25
- ...context.assets.pages.map((page) => (Object.assign(Object.assign({}, page), { html: page.html ? context.loadFile(page.html) : '' }))),
26
+ ...pages.map((page) => (Object.assign(Object.assign({}, page), { html: page.html ? context.loadFile(page.html) : '' }))),
26
27
  ],
27
28
  };
28
29
  });
29
30
  }
30
31
  function dump(context) {
31
32
  return __awaiter(this, void 0, void 0, function* () {
32
- let pages = [...(context.assets.pages || [])];
33
- if (pages.length > 0) {
34
- // Create Pages folder
35
- const pagesFolder = path_1.default.join(context.basePath, 'pages');
36
- fs_extra_1.default.ensureDirSync(pagesFolder);
37
- pages = pages.map((page) => {
38
- if (page.name === 'error_page' && page.html === undefined) {
39
- return page;
40
- }
41
- // Dump html to file
42
- const htmlFile = path_1.default.join(pagesFolder, `${page.name}.html`);
43
- logger_1.default.info(`Writing ${htmlFile}`);
44
- fs_extra_1.default.writeFileSync(htmlFile, page.html);
45
- return Object.assign(Object.assign({}, page), { html: `./pages/${page.name}.html` });
46
- });
33
+ let pages = context.assets.pages;
34
+ if (!pages) {
35
+ return { pages: null };
47
36
  }
37
+ // Create Pages folder
38
+ const pagesFolder = path_1.default.join(context.basePath, 'pages');
39
+ fs_extra_1.default.ensureDirSync(pagesFolder);
40
+ pages = pages.map((page) => {
41
+ if (page.name === 'error_page' && page.html === undefined) {
42
+ return page;
43
+ }
44
+ // Dump html to file
45
+ const htmlFile = path_1.default.join(pagesFolder, `${page.name}.html`);
46
+ logger_1.default.info(`Writing ${htmlFile}`);
47
+ fs_extra_1.default.writeFileSync(htmlFile, page.html);
48
+ return Object.assign(Object.assign({}, page), { html: `./pages/${page.name}.html` });
49
+ });
48
50
  return { pages };
49
51
  });
50
52
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedResourceServers = {
3
- resourceServers: unknown[];
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedResourceServers = ParsedAsset<'resourceServers', Asset[]>;
5
4
  declare const resourceServersHandler: YAMLHandler<ParsedResourceServers>;
6
5
  export default resourceServersHandler;
@@ -9,24 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- function parse(context) {
12
+ function dumpAndParse(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
- // nothing to do, set default if empty
14
+ const { resourceServers } = context.assets;
15
+ if (!resourceServers) {
16
+ return { resourceServers: null };
17
+ }
15
18
  return {
16
- resourceServers: context.assets.resourceServers,
17
- };
18
- });
19
- }
20
- function dump(context) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- // nothing to do, set default if empty
23
- return {
24
- resourceServers: [...(context.assets.resourceServers || [])],
19
+ resourceServers,
25
20
  };
26
21
  });
27
22
  }
28
23
  const resourceServersHandler = {
29
- parse,
30
- dump,
24
+ parse: dumpAndParse,
25
+ dump: dumpAndParse,
31
26
  };
32
27
  exports.default = resourceServersHandler;
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedRoles = {
3
- roles: unknown[];
4
- };
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedRoles = ParsedAsset<'roles', Asset[]>;
5
4
  declare const rolesHandler: YAMLHandler<ParsedRoles>;
6
5
  export default rolesHandler;
@@ -11,24 +11,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  function parse(context) {
13
13
  return __awaiter(this, void 0, void 0, function* () {
14
- // nothing to do, set default empty
14
+ const { roles } = context.assets;
15
+ if (!roles)
16
+ return { roles: null };
15
17
  return {
16
- roles: context.assets.roles,
18
+ roles,
17
19
  };
18
20
  });
19
21
  }
20
22
  function dump(context) {
21
23
  return __awaiter(this, void 0, void 0, function* () {
22
- // remove empty descriptions
24
+ const { roles } = context.assets;
25
+ if (!roles)
26
+ return { roles: null };
23
27
  return {
24
- roles: [
25
- ...(context.assets.roles || []).map((role) => {
26
- if (role.description === null) {
27
- delete role.description;
28
- }
29
- return role;
30
- }),
31
- ],
28
+ roles: roles.map((role) => {
29
+ if (role.description === null) {
30
+ delete role.description;
31
+ }
32
+ return role;
33
+ }),
32
34
  };
33
35
  });
34
36
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedRules = {
3
- rules: unknown[];
4
- } | {};
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedRules = ParsedAsset<'rules', Asset[]>;
5
4
  declare const rulesHandler: YAMLHandler<ParsedRules>;
6
5
  export default rulesHandler;
@@ -18,32 +18,33 @@ const utils_1 = require("../../../utils");
18
18
  const logger_1 = __importDefault(require("../../../logger"));
19
19
  function parse(context) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
- // Load the script file for each rule
22
- if (!context.assets.rules)
23
- return {};
21
+ const { rules } = context.assets;
22
+ if (!rules)
23
+ return { rules: null };
24
24
  return {
25
25
  rules: [
26
- ...context.assets.rules.map((rule) => (Object.assign(Object.assign({}, rule), { script: context.loadFile(rule.script) }))),
26
+ ...rules.map((rule) => (Object.assign(Object.assign({}, rule), { script: context.loadFile(rule.script) }))),
27
27
  ],
28
28
  };
29
29
  });
30
30
  }
31
31
  function dump(context) {
32
32
  return __awaiter(this, void 0, void 0, function* () {
33
- let rules = [...(context.assets.rules || [])];
34
- if (rules.length > 0) {
35
- // Create Rules folder
36
- const rulesFolder = path_1.default.join(context.basePath, 'rules');
37
- fs_extra_1.default.ensureDirSync(rulesFolder);
38
- rules = rules.map((rule) => {
39
- // Dump rule to file
40
- const scriptName = (0, utils_1.sanitize)(`${rule.name}.js`);
41
- const scriptFile = path_1.default.join(rulesFolder, scriptName);
42
- logger_1.default.info(`Writing ${scriptFile}`);
43
- fs_extra_1.default.writeFileSync(scriptFile, rule.script);
44
- return Object.assign(Object.assign({}, rule), { script: `./rules/${scriptName}` });
45
- });
33
+ let { rules } = context.assets;
34
+ if (!rules) {
35
+ return { rules: null };
46
36
  }
37
+ // Create Rules folder
38
+ const rulesFolder = path_1.default.join(context.basePath, 'rules');
39
+ fs_extra_1.default.ensureDirSync(rulesFolder);
40
+ rules = rules.map((rule) => {
41
+ // Dump rule to file
42
+ const scriptName = (0, utils_1.sanitize)(`${rule.name}.js`);
43
+ const scriptFile = path_1.default.join(rulesFolder, scriptName);
44
+ logger_1.default.info(`Writing ${scriptFile}`);
45
+ fs_extra_1.default.writeFileSync(scriptFile, rule.script);
46
+ return Object.assign(Object.assign({}, rule), { script: `./rules/${scriptName}` });
47
+ });
47
48
  return { rules };
48
49
  });
49
50
  }
@@ -1,6 +1,5 @@
1
1
  import { YAMLHandler } from '.';
2
- declare type ParsedRulesConfigs = {
3
- rulesConfigs: unknown[];
4
- } | {};
2
+ import { Asset, ParsedAsset } from '../../../types';
3
+ declare type ParsedRulesConfigs = ParsedAsset<'rulesConfigs', Asset[]>;
5
4
  declare const rulesConfigsHandler: YAMLHandler<ParsedRulesConfigs>;
6
5
  export default rulesConfigsHandler;