auth0-deploy-cli 7.5.2 → 7.6.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 (68) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/lib/args.js +0 -2
  3. package/lib/commands/import.js +1 -0
  4. package/lib/context/directory/handlers/actions.js +3 -2
  5. package/lib/context/directory/handlers/attackProtection.js +3 -2
  6. package/lib/context/directory/handlers/branding.js +59 -0
  7. package/lib/context/directory/handlers/clientGrants.js +3 -2
  8. package/lib/context/directory/handlers/clients.js +3 -2
  9. package/lib/context/directory/handlers/connections.js +3 -2
  10. package/lib/context/directory/handlers/databases.js +18 -16
  11. package/lib/context/directory/handlers/emailProvider.js +3 -2
  12. package/lib/context/directory/handlers/emailTemplates.js +11 -9
  13. package/lib/context/directory/handlers/guardianFactorProviders.js +3 -2
  14. package/lib/context/directory/handlers/guardianFactorTemplates.js +3 -2
  15. package/lib/context/directory/handlers/guardianFactors.js +3 -2
  16. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +3 -2
  17. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +3 -2
  18. package/lib/context/directory/handlers/guardianPolicies.js +3 -2
  19. package/lib/context/directory/handlers/hooks.js +3 -2
  20. package/lib/context/directory/handlers/index.js +3 -1
  21. package/lib/context/directory/handlers/migrations.js +8 -8
  22. package/lib/context/directory/handlers/organizations.js +3 -2
  23. package/lib/context/directory/handlers/pages.js +18 -18
  24. package/lib/context/directory/handlers/resourceServers.js +3 -2
  25. package/lib/context/directory/handlers/roles.js +3 -2
  26. package/lib/context/directory/handlers/rules.js +3 -2
  27. package/lib/context/directory/handlers/rulesConfigs.js +4 -3
  28. package/lib/context/directory/handlers/tenant.js +5 -3
  29. package/lib/context/directory/handlers/triggers.js +3 -2
  30. package/lib/context/directory/index.js +2 -4
  31. package/lib/context/yaml/handlers/actions.js +4 -3
  32. package/lib/context/yaml/handlers/attackProtection.js +5 -11
  33. package/lib/context/yaml/handlers/branding.js +65 -0
  34. package/lib/context/yaml/handlers/clientGrants.js +3 -2
  35. package/lib/context/yaml/handlers/clients.js +3 -2
  36. package/lib/context/yaml/handlers/connections.js +3 -2
  37. package/lib/context/yaml/handlers/databases.js +3 -2
  38. package/lib/context/yaml/handlers/emailProvider.js +3 -2
  39. package/lib/context/yaml/handlers/emailTemplates.js +3 -2
  40. package/lib/context/yaml/handlers/guardianFactorProviders.js +5 -12
  41. package/lib/context/yaml/handlers/guardianFactorTemplates.js +5 -12
  42. package/lib/context/yaml/handlers/guardianFactors.js +5 -12
  43. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +5 -12
  44. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +5 -12
  45. package/lib/context/yaml/handlers/guardianPolicies.js +5 -12
  46. package/lib/context/yaml/handlers/hooks.js +3 -2
  47. package/lib/context/yaml/handlers/index.js +3 -1
  48. package/lib/context/yaml/handlers/migrations.js +3 -2
  49. package/lib/context/yaml/handlers/organizations.js +3 -2
  50. package/lib/context/yaml/handlers/pages.js +3 -2
  51. package/lib/context/yaml/handlers/resourceServers.js +3 -2
  52. package/lib/context/yaml/handlers/roles.js +3 -2
  53. package/lib/context/yaml/handlers/rules.js +3 -2
  54. package/lib/context/yaml/handlers/rulesConfigs.js +4 -3
  55. package/lib/context/yaml/handlers/tenant.js +3 -2
  56. package/lib/context/yaml/handlers/triggers.js +3 -2
  57. package/lib/context/yaml/index.js +2 -1
  58. package/lib/tools/auth0/handlers/branding.js +67 -13
  59. package/lib/tools/auth0/handlers/default.js +7 -1
  60. package/lib/tools/auth0/handlers/organizations.js +7 -2
  61. package/lib/tools/auth0/handlers/resourceServers.js +7 -2
  62. package/lib/tools/auth0/handlers/roles.js +7 -2
  63. package/lib/tools/auth0/handlers/rules.js +7 -1
  64. package/lib/tools/calculateChanges.js +144 -0
  65. package/lib/tools/constants.js +7 -0
  66. package/lib/tools/utils.js +1 -142
  67. package/package.json +2 -2
  68. package/tsconfig.json +1 -0
@@ -0,0 +1,65 @@
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
+ function parse(context) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ // 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);
26
+ return {
27
+ template: templateDefinition.template,
28
+ body: (0, tools_1.loadFileAndReplaceKeywords)(markupFile, context.mappings)
29
+ };
30
+ });
31
+ return {
32
+ branding: Object.assign(Object.assign({}, branding), { templates })
33
+ };
34
+ });
35
+ }
36
+ function dump(context) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const { branding } = context.assets || { branding: undefined };
39
+ branding.templates = branding.templates || [];
40
+ // create templates folder
41
+ if (branding.templates.length) {
42
+ const brandingTemplatesFolder = path_1.default.join(context.basePath, tools_1.constants.BRANDING_TEMPLATES_YAML_DIRECTORY);
43
+ fs_extra_1.default.ensureDirSync(brandingTemplatesFolder);
44
+ branding.templates = branding.templates.map((templateDefinition) => {
45
+ const file = `${templateDefinition.template}.html`;
46
+ const templateMarkupFile = path_1.default.join(brandingTemplatesFolder, file);
47
+ const markup = templateDefinition.body;
48
+ try {
49
+ fs_extra_1.default.writeFileSync(templateMarkupFile, markup);
50
+ }
51
+ catch (e) {
52
+ throw new Error(`Error writing template file: ${templateDefinition.template}, because: ${e.message}`);
53
+ }
54
+ // save the location as relative file.
55
+ templateDefinition.body = `.${path_1.default.sep}${path_1.default.join(tools_1.constants.BRANDING_TEMPLATES_YAML_DIRECTORY, file)}`;
56
+ return templateDefinition;
57
+ });
58
+ }
59
+ return { branding };
60
+ });
61
+ }
62
+ exports.default = {
63
+ parse,
64
+ dump
65
+ };
@@ -34,7 +34,8 @@ function dump(context) {
34
34
  };
35
35
  });
36
36
  }
37
- exports.default = {
37
+ const clientGrantsHandler = {
38
38
  parse,
39
- dump
39
+ dump,
40
40
  };
41
+ exports.default = clientGrantsHandler;
@@ -60,7 +60,8 @@ function dump(context) {
60
60
  };
61
61
  });
62
62
  }
63
- exports.default = {
63
+ const clientsHandler = {
64
64
  parse,
65
- dump
65
+ dump,
66
66
  };
67
+ exports.default = clientsHandler;
@@ -77,7 +77,8 @@ function dump(context) {
77
77
  };
78
78
  });
79
79
  }
80
- exports.default = {
80
+ const connectionsHandler = {
81
81
  parse,
82
- dump
82
+ dump,
83
83
  };
84
+ exports.default = connectionsHandler;
@@ -62,7 +62,8 @@ function dump(context) {
62
62
  };
63
63
  });
64
64
  }
65
- exports.default = {
65
+ const databasesHandler = {
66
66
  parse,
67
- dump
67
+ dump,
68
68
  };
69
+ exports.default = databasesHandler;
@@ -31,7 +31,8 @@ function dump(context) {
31
31
  };
32
32
  });
33
33
  }
34
- exports.default = {
34
+ const emailProviderHandler = {
35
35
  parse,
36
- dump
36
+ dump,
37
37
  };
38
+ exports.default = emailProviderHandler;
@@ -44,7 +44,8 @@ function dump(context) {
44
44
  return { emailTemplates };
45
45
  });
46
46
  }
47
- exports.default = {
47
+ const emailTemplatesHandler = {
48
48
  parse,
49
- dump
49
+ dump,
50
50
  };
51
+ exports.default = emailTemplatesHandler;
@@ -9,15 +9,7 @@ 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) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- // nothing to do, set default if empty
15
- return {
16
- guardianFactorProviders: [...context.assets.guardianFactorProviders || []]
17
- };
18
- });
19
- }
20
- function dump(context) {
12
+ function parseAndDump(context) {
21
13
  return __awaiter(this, void 0, void 0, function* () {
22
14
  // nothing to do, set default empty
23
15
  return {
@@ -25,7 +17,8 @@ function dump(context) {
25
17
  };
26
18
  });
27
19
  }
28
- exports.default = {
29
- parse,
30
- dump
20
+ const guardianFactorProvidersHandler = {
21
+ parse: parseAndDump,
22
+ dump: parseAndDump,
31
23
  };
24
+ exports.default = guardianFactorProvidersHandler;
@@ -9,7 +9,7 @@ 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
  // nothing to do, set default if empty
15
15
  return {
@@ -17,15 +17,8 @@ function parse(context) {
17
17
  };
18
18
  });
19
19
  }
20
- function dump(context) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- // nothing to do, set default empty
23
- return {
24
- guardianFactorTemplates: [...context.assets.guardianFactorTemplates || []]
25
- };
26
- });
27
- }
28
- exports.default = {
29
- parse,
30
- dump
20
+ const guardianFactorTemplatesHandler = {
21
+ parse: parseAndDump,
22
+ dump: parseAndDump,
31
23
  };
24
+ exports.default = guardianFactorTemplatesHandler;
@@ -9,7 +9,7 @@ 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
  // nothing to do, set default if empty
15
15
  return {
@@ -17,15 +17,8 @@ function parse(context) {
17
17
  };
18
18
  });
19
19
  }
20
- function dump(context) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- // nothing to do, set default empty
23
- return {
24
- guardianFactors: [...context.assets.guardianFactors || []]
25
- };
26
- });
27
- }
28
- exports.default = {
29
- parse,
30
- dump
20
+ const guardianFactorsHandler = {
21
+ parse: parseAndDump,
22
+ dump: parseAndDump,
31
23
  };
24
+ exports.default = guardianFactorsHandler;
@@ -9,7 +9,7 @@ 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
  // nothing to do, set default if empty
15
15
  return {
@@ -17,15 +17,8 @@ function parse(context) {
17
17
  };
18
18
  });
19
19
  }
20
- function dump(context) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- // nothing to do, set default empty
23
- return {
24
- guardianPhoneFactorMessageTypes: Object.assign({}, context.assets.guardianPhoneFactorMessageTypes || {})
25
- };
26
- });
27
- }
28
- exports.default = {
29
- parse,
30
- dump
20
+ const guardianPhoneFactorMessageTypesHandler = {
21
+ parse: parseAndDump,
22
+ dump: parseAndDump,
31
23
  };
24
+ exports.default = guardianPhoneFactorMessageTypesHandler;
@@ -9,15 +9,7 @@ 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) {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- // nothing to do, set default if empty
15
- return {
16
- guardianPhoneFactorSelectedProvider: Object.assign({}, context.assets.guardianPhoneFactorSelectedProvider || {})
17
- };
18
- });
19
- }
20
- function dump(context) {
12
+ function parseAndDump(context) {
21
13
  return __awaiter(this, void 0, void 0, function* () {
22
14
  // nothing to do, set default empty
23
15
  return {
@@ -25,7 +17,8 @@ function dump(context) {
25
17
  };
26
18
  });
27
19
  }
28
- exports.default = {
29
- parse,
30
- dump
20
+ const guardianPhoneFactorSelectedProviderHandler = {
21
+ parse: parseAndDump,
22
+ dump: parseAndDump,
31
23
  };
24
+ exports.default = guardianPhoneFactorSelectedProviderHandler;
@@ -9,7 +9,7 @@ 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
  // nothing to do, set default if empty
15
15
  return {
@@ -17,15 +17,8 @@ function parse(context) {
17
17
  };
18
18
  });
19
19
  }
20
- function dump(context) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- // nothing to do, set default empty
23
- return {
24
- guardianPolicies: Object.assign({}, context.assets.guardianPolicies || {})
25
- };
26
- });
27
- }
28
- exports.default = {
29
- parse,
30
- dump
20
+ const guardianPoliciesHandler = {
21
+ parse: parseAndDump,
22
+ dump: parseAndDump,
31
23
  };
24
+ exports.default = guardianPoliciesHandler;
@@ -56,7 +56,8 @@ function dump(context) {
56
56
  return { hooks };
57
57
  });
58
58
  }
59
- exports.default = {
59
+ const hooksHandler = {
60
60
  parse,
61
- dump
61
+ dump,
62
62
  };
63
+ exports.default = hooksHandler;
@@ -27,6 +27,7 @@ const migrations_1 = __importDefault(require("./migrations"));
27
27
  const actions_1 = __importDefault(require("./actions"));
28
28
  const triggers_1 = __importDefault(require("./triggers"));
29
29
  const attackProtection_1 = __importDefault(require("./attackProtection"));
30
+ const branding_1 = __importDefault(require("./branding"));
30
31
  exports.default = {
31
32
  rules: rules_1.default,
32
33
  hooks: hooks_1.default,
@@ -51,5 +52,6 @@ exports.default = {
51
52
  actions: actions_1.default,
52
53
  organizations: organizations_1.default,
53
54
  triggers: triggers_1.default,
54
- attackProtection: attackProtection_1.default
55
+ attackProtection: attackProtection_1.default,
56
+ branding: branding_1.default
55
57
  };
@@ -21,7 +21,8 @@ function dump(context) {
21
21
  return { migrations: migrations || {} };
22
22
  });
23
23
  }
24
- exports.default = {
24
+ const migrationsHandler = {
25
25
  parse,
26
- dump
26
+ dump,
27
27
  };
28
+ exports.default = migrationsHandler;
@@ -38,7 +38,8 @@ function dump(context) {
38
38
  };
39
39
  });
40
40
  }
41
- exports.default = {
41
+ const organizationsHandler = {
42
42
  parse,
43
- dump
43
+ dump,
44
44
  };
45
+ exports.default = organizationsHandler;
@@ -48,7 +48,8 @@ function dump(context) {
48
48
  return { pages };
49
49
  });
50
50
  }
51
- exports.default = {
51
+ const pagesHandler = {
52
52
  parse,
53
- dump
53
+ dump,
54
54
  };
55
+ exports.default = pagesHandler;
@@ -25,7 +25,8 @@ function dump(context) {
25
25
  };
26
26
  });
27
27
  }
28
- exports.default = {
28
+ const resourceServersHandler = {
29
29
  parse,
30
- dump
30
+ dump,
31
31
  };
32
+ exports.default = resourceServersHandler;
@@ -32,7 +32,8 @@ function dump(context) {
32
32
  };
33
33
  });
34
34
  }
35
- exports.default = {
35
+ const rolesHandler = {
36
36
  parse,
37
- dump
37
+ dump,
38
38
  };
39
+ exports.default = rolesHandler;
@@ -47,7 +47,8 @@ function dump(context) {
47
47
  return { rules };
48
48
  });
49
49
  }
50
- exports.default = {
50
+ const rulesHandler = {
51
51
  parse,
52
- dump
52
+ dump,
53
53
  };
54
+ exports.default = rulesHandler;
@@ -17,7 +17,7 @@ function parse(context) {
17
17
  };
18
18
  });
19
19
  }
20
- function dump() {
20
+ function dump(_context) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  // do not export rulesConfigs as its values cannot be extracted
23
23
  return {
@@ -25,7 +25,8 @@ function dump() {
25
25
  };
26
26
  });
27
27
  }
28
- exports.default = {
28
+ const rulesConfigsHandler = {
29
29
  parse,
30
- dump
30
+ dump,
31
31
  };
32
+ exports.default = rulesConfigsHandler;
@@ -42,7 +42,8 @@ function dump(context) {
42
42
  return { tenant };
43
43
  });
44
44
  }
45
- exports.default = {
45
+ const tenantHandler = {
46
46
  parse,
47
- dump
47
+ dump,
48
48
  };
49
+ exports.default = tenantHandler;
@@ -30,7 +30,8 @@ function dump(context) {
30
30
  };
31
31
  });
32
32
  }
33
- exports.default = {
33
+ const triggersHandler = {
34
34
  parse,
35
- dump
35
+ dump,
36
36
  };
37
+ exports.default = triggersHandler;
@@ -39,6 +39,7 @@ class default_1 {
39
39
  };
40
40
  this.basePath = config.AUTH0_BASE_PATH;
41
41
  if (!this.basePath) {
42
+ //@ts-ignore because this looks to be a bug, but do not want to introduce regression; more investigation needed
42
43
  this.basePath = (typeof configFile === 'object') ? process.cwd() : path_1.default.dirname(this.configFile);
43
44
  }
44
45
  }
@@ -69,7 +70,7 @@ class default_1 {
69
70
  }
70
71
  // Run initial schema check to ensure valid YAML
71
72
  const auth0 = new tools_1.Auth0(this.mgmtClient, this.assets, (0, utils_1.toConfigFn)(this.config));
72
- yield auth0.validate('validate');
73
+ yield auth0.validate();
73
74
  // Allow handlers to process the assets such as loading files etc
74
75
  yield Promise.all(Object.entries(handlers_1.default).map(([name, handler]) => __awaiter(this, void 0, void 0, function* () {
75
76
  try {
@@ -14,25 +14,59 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.schema = void 0;
16
16
  const default_1 = __importDefault(require("./default"));
17
- exports.schema = { type: 'object' };
17
+ const constants_1 = __importDefault(require("../../constants"));
18
+ const logger_1 = __importDefault(require("../../../logger"));
19
+ exports.schema = {
20
+ type: 'object',
21
+ properties: {
22
+ templates: {
23
+ type: 'array',
24
+ items: {
25
+ type: 'object',
26
+ properties: {
27
+ template: { type: 'string' },
28
+ body: { type: 'string' }
29
+ }
30
+ }
31
+ }
32
+ }
33
+ };
18
34
  class BrandingHandler extends default_1.default {
19
35
  constructor(options) {
20
36
  super(Object.assign(Object.assign({}, options), { type: 'branding' }));
21
37
  }
22
38
  getType() {
23
39
  return __awaiter(this, void 0, void 0, function* () {
24
- // in case client version does not support branding
25
- if (!this.client.branding || typeof this.client.branding.getSettings !== 'function') {
26
- return {};
27
- }
40
+ let branding = {};
28
41
  try {
29
- return yield this.client.branding.getSettings();
42
+ // in case client version does not support branding
43
+ if (this.client.branding && typeof this.client.branding.getSettings === 'function') {
44
+ branding = yield this.client.branding.getSettings();
45
+ }
46
+ // in case client version does not custom domains
47
+ if (this.client.customDomains && typeof this.client.customDomains.getAll === 'function') {
48
+ const customDomains = yield this.client.customDomains.getAll();
49
+ // templates are only supported if there's custom domains.
50
+ if (customDomains && customDomains.length) {
51
+ const payload = yield this.client.branding.getUniversalLoginTemplate();
52
+ branding.templates = [
53
+ {
54
+ template: constants_1.default.UNIVERSAL_LOGIN_TEMPLATE,
55
+ body: payload.body
56
+ }
57
+ ];
58
+ }
59
+ }
60
+ return branding;
30
61
  }
31
62
  catch (err) {
63
+ logger_1.default.debug(`Error calling branding API, ${err.message}, status code: ${err.statusCode}`);
64
+ if (err.statusCode === 403)
65
+ return branding;
32
66
  if (err.statusCode === 404)
33
- return {};
67
+ return branding;
34
68
  if (err.statusCode === 501)
35
- return {};
69
+ return branding;
36
70
  throw err;
37
71
  }
38
72
  });
@@ -40,12 +74,32 @@ class BrandingHandler extends default_1.default {
40
74
  processChanges(assets) {
41
75
  return __awaiter(this, void 0, void 0, function* () {
42
76
  const { branding } = assets;
43
- // Do nothing if not set
44
- if (!branding || !Object.keys(branding).length)
77
+ // quit early if there's no branding to process.
78
+ if (!branding)
45
79
  return;
46
- yield this.client.branding.updateSettings({}, branding);
47
- this.updated += 1;
48
- this.didUpdate(branding);
80
+ // remove templates, we only want top level branding settings for this API call
81
+ const brandingSettings = Object.assign({}, branding);
82
+ delete brandingSettings.templates;
83
+ // Do nothing if not set
84
+ if (brandingSettings && Object.keys(brandingSettings).length) {
85
+ yield this.client.branding.updateSettings({}, brandingSettings);
86
+ this.updated += 1;
87
+ this.didUpdate(brandingSettings);
88
+ }
89
+ // handle templates
90
+ if (branding.templates && branding.templates.length) {
91
+ const unknownTemplates = branding.templates.filter((t) => !constants_1.default.SUPPORTED_BRANDING_TEMPLATES.includes(t.template)).map((t) => t.template);
92
+ if (unknownTemplates.length) {
93
+ // throw a helpful warning for unknown templates, the context handlers are unaware of which are supported, that's all handled here.
94
+ logger_1.default.warn(`Found unknown branding template(s): ${unknownTemplates.join().toString()}. Supported branding templates are: ${constants_1.default.SUPPORTED_BRANDING_TEMPLATES.join()}.`);
95
+ }
96
+ const templateDefinition = branding.templates.find((t) => t.template === constants_1.default.UNIVERSAL_LOGIN_TEMPLATE);
97
+ if (templateDefinition && templateDefinition.body) {
98
+ yield this.client.branding.setUniversalLoginTemplate({}, { template: templateDefinition.body });
99
+ this.updated += 1;
100
+ this.didUpdate(branding.templates);
101
+ }
102
+ }
49
103
  });
50
104
  }
51
105
  }
@@ -16,6 +16,7 @@ exports.order = void 0;
16
16
  const ValidationError_1 = __importDefault(require("../../ValidationError"));
17
17
  const logger_1 = __importDefault(require("../../logger"));
18
18
  const utils_1 = require("../../utils");
19
+ const calculateChanges_1 = require("../../calculateChanges");
19
20
  function order(value) {
20
21
  return function decorator(t, n, descriptor) {
21
22
  descriptor.value.order = value; // eslint-disable-line
@@ -82,7 +83,12 @@ class DefaultHandler {
82
83
  return {};
83
84
  const existing = yield this.getType();
84
85
  // Figure out what needs to be updated vs created
85
- return (0, utils_1.calcChanges)(this, typeAssets, existing, this.identifiers);
86
+ return (0, calculateChanges_1.calculateChanges)({
87
+ handler: this,
88
+ assets: typeAssets,
89
+ existing,
90
+ identifiers: this.identifiers
91
+ });
86
92
  });
87
93
  }
88
94
  validate(assets) {
@@ -44,7 +44,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
44
44
  exports.schema = void 0;
45
45
  const lodash_1 = __importDefault(require("lodash"));
46
46
  const default_1 = __importStar(require("./default"));
47
- const utils_1 = require("../../utils");
47
+ const calculateChanges_1 = require("../../calculateChanges");
48
48
  const logger_1 = __importDefault(require("../../logger"));
49
49
  exports.schema = {
50
50
  type: 'array',
@@ -208,7 +208,12 @@ class OrganizationsHandler extends default_1.default {
208
208
  return Object.assign(Object.assign({}, connection), { connection_id: (existingConnections.find((c) => c.name === name) || {}).id });
209
209
  }).filter((connection) => !!connection.connection_id);
210
210
  });
211
- const changes = (0, utils_1.calcChanges)(this, organizations, existing, ['id', 'name']);
211
+ const changes = (0, calculateChanges_1.calculateChanges)({
212
+ handler: this,
213
+ assets: organizations,
214
+ existing,
215
+ identifiers: ['id', 'name']
216
+ });
212
217
  logger_1.default.debug(`Start processChanges for organizations [delete:${changes.del.length}] [update:${changes.update.length}], [create:${changes.create.length}]`);
213
218
  const myChanges = [{ del: changes.del }, { create: changes.create }, { update: changes.update }];
214
219
  yield Promise.all(myChanges.map((change) => __awaiter(this, void 0, void 0, function* () {
@@ -16,7 +16,7 @@ exports.schema = exports.excludeSchema = void 0;
16
16
  const ValidationError_1 = __importDefault(require("../../ValidationError"));
17
17
  const constants_1 = __importDefault(require("../../constants"));
18
18
  const default_1 = __importDefault(require("./default"));
19
- const utils_1 = require("../../utils");
19
+ const calculateChanges_1 = require("../../calculateChanges");
20
20
  exports.excludeSchema = {
21
21
  type: 'array',
22
22
  items: { type: 'string' }
@@ -71,7 +71,12 @@ class ResourceServersHandler extends default_1.default {
71
71
  // Filter excluded
72
72
  resourceServers = resourceServers.filter((r) => !excluded.includes(r.name));
73
73
  existing = existing.filter((r) => !excluded.includes(r.name));
74
- return (0, utils_1.calcChanges)(this, resourceServers, existing, ['id', 'identifier']);
74
+ return (0, calculateChanges_1.calculateChanges)({
75
+ handler: this,
76
+ assets: resourceServers,
77
+ existing,
78
+ identifiers: ['id', 'identifier']
79
+ });
75
80
  });
76
81
  }
77
82
  validate(assets) {