auth0-deploy-cli 7.4.0 → 7.5.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 (112) hide show
  1. package/.circleci/config.yml +15 -0
  2. package/.github/CODEOWNERS +1 -0
  3. package/.husky/pre-commit +2 -0
  4. package/.nyc_output/60b76a45-577b-4171-9982-a8e836ab7fd6.json +1 -0
  5. package/.nyc_output/processinfo/60b76a45-577b-4171-9982-a8e836ab7fd6.json +1 -0
  6. package/.nyc_output/processinfo/index.json +1 -1
  7. package/CHANGELOG.md +13 -1
  8. package/lib/args.js +89 -81
  9. package/lib/commands/export.js +51 -77
  10. package/lib/commands/import.js +45 -69
  11. package/lib/commands/index.js +11 -20
  12. package/lib/configFactory.js +19 -27
  13. package/lib/context/defaults.js +18 -41
  14. package/lib/context/directory/handlers/actions.js +77 -107
  15. package/lib/context/directory/handlers/attackProtection.js +59 -0
  16. package/lib/context/directory/handlers/clientGrants.js +45 -54
  17. package/lib/context/directory/handlers/clients.js +60 -79
  18. package/lib/context/directory/handlers/connections.js +65 -89
  19. package/lib/context/directory/handlers/databases.js +91 -123
  20. package/lib/context/directory/handlers/emailProvider.js +46 -57
  21. package/lib/context/directory/handlers/emailTemplates.js +67 -80
  22. package/lib/context/directory/handlers/guardianFactorProviders.js +41 -49
  23. package/lib/context/directory/handlers/guardianFactorTemplates.js +41 -49
  24. package/lib/context/directory/handlers/guardianFactors.js +41 -49
  25. package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +40 -50
  26. package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +40 -50
  27. package/lib/context/directory/handlers/guardianPolicies.js +40 -50
  28. package/lib/context/directory/handlers/hooks.js +55 -70
  29. package/lib/context/directory/handlers/index.js +53 -123
  30. package/lib/context/directory/handlers/migrations.js +36 -41
  31. package/lib/context/directory/handlers/organizations.js +54 -69
  32. package/lib/context/directory/handlers/pages.js +72 -86
  33. package/lib/context/directory/handlers/resourceServers.js +41 -49
  34. package/lib/context/directory/handlers/roles.js +49 -62
  35. package/lib/context/directory/handlers/rules.js +52 -68
  36. package/lib/context/directory/handlers/rulesConfigs.js +33 -32
  37. package/lib/context/directory/handlers/tenant.js +52 -47
  38. package/lib/context/directory/handlers/triggers.js +39 -54
  39. package/lib/context/directory/index.js +113 -101
  40. package/lib/context/index.js +96 -105
  41. package/lib/context/yaml/handlers/actions.js +71 -88
  42. package/lib/context/yaml/handlers/attackProtection.js +29 -0
  43. package/lib/context/yaml/handlers/clientGrants.js +36 -29
  44. package/lib/context/yaml/handlers/clients.js +61 -76
  45. package/lib/context/yaml/handlers/connections.js +76 -103
  46. package/lib/context/yaml/handlers/databases.js +64 -79
  47. package/lib/context/yaml/handlers/emailProvider.js +33 -30
  48. package/lib/context/yaml/handlers/emailTemplates.js +45 -54
  49. package/lib/context/yaml/handlers/guardianFactorProviders.js +27 -18
  50. package/lib/context/yaml/handlers/guardianFactorTemplates.js +27 -18
  51. package/lib/context/yaml/handlers/guardianFactors.js +27 -18
  52. package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +27 -20
  53. package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +27 -20
  54. package/lib/context/yaml/handlers/guardianPolicies.js +27 -20
  55. package/lib/context/yaml/handlers/hooks.js +57 -67
  56. package/lib/context/yaml/handlers/index.js +53 -123
  57. package/lib/context/yaml/handlers/migrations.js +23 -24
  58. package/lib/context/yaml/handlers/organizations.js +40 -38
  59. package/lib/context/yaml/handlers/pages.js +49 -58
  60. package/lib/context/yaml/handlers/resourceServers.js +27 -18
  61. package/lib/context/yaml/handlers/roles.js +34 -24
  62. package/lib/context/yaml/handlers/rules.js +48 -58
  63. package/lib/context/yaml/handlers/rulesConfigs.js +27 -18
  64. package/lib/context/yaml/handlers/tenant.js +44 -30
  65. package/lib/context/yaml/handlers/triggers.js +32 -23
  66. package/lib/context/yaml/index.js +127 -142
  67. package/lib/index.js +73 -79
  68. package/lib/logger.js +18 -22
  69. package/lib/readonly.js +74 -66
  70. package/lib/tools/ValidationError.js +8 -13
  71. package/lib/tools/auth0/client.js +143 -133
  72. package/lib/tools/auth0/handlers/actions.js +231 -243
  73. package/lib/tools/auth0/handlers/attackProtection.js +86 -0
  74. package/lib/tools/auth0/handlers/branding.js +47 -46
  75. package/lib/tools/auth0/handlers/clientGrants.js +118 -116
  76. package/lib/tools/auth0/handlers/clients.js +72 -90
  77. package/lib/tools/auth0/handlers/connections.js +150 -118
  78. package/lib/tools/auth0/handlers/databases.js +127 -124
  79. package/lib/tools/auth0/handlers/default.js +186 -189
  80. package/lib/tools/auth0/handlers/emailProvider.js +67 -78
  81. package/lib/tools/auth0/handlers/emailTemplates.js +116 -92
  82. package/lib/tools/auth0/handlers/guardianFactorProviders.js +66 -81
  83. package/lib/tools/auth0/handlers/guardianFactorTemplates.js +60 -71
  84. package/lib/tools/auth0/handlers/guardianFactors.js +56 -63
  85. package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +80 -79
  86. package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +77 -76
  87. package/lib/tools/auth0/handlers/guardianPolicies.js +59 -62
  88. package/lib/tools/auth0/handlers/hooks.js +201 -227
  89. package/lib/tools/auth0/handlers/index.js +53 -111
  90. package/lib/tools/auth0/handlers/migrations.js +99 -79
  91. package/lib/tools/auth0/handlers/organizations.js +225 -247
  92. package/lib/tools/auth0/handlers/pages.js +116 -154
  93. package/lib/tools/auth0/handlers/prompts.js +47 -46
  94. package/lib/tools/auth0/handlers/resourceServers.js +88 -112
  95. package/lib/tools/auth0/handlers/roles.js +203 -220
  96. package/lib/tools/auth0/handlers/rules.js +168 -189
  97. package/lib/tools/auth0/handlers/rulesConfigs.js +54 -63
  98. package/lib/tools/auth0/handlers/tenant.js +88 -64
  99. package/lib/tools/auth0/handlers/triggers.js +126 -126
  100. package/lib/tools/auth0/index.js +92 -85
  101. package/lib/tools/auth0/schema.js +39 -31
  102. package/lib/tools/constants.js +111 -21
  103. package/lib/tools/deploy.js +35 -32
  104. package/lib/tools/index.js +19 -32
  105. package/lib/tools/logger.js +11 -12
  106. package/lib/tools/utils.js +255 -282
  107. package/lib/utils.js +167 -190
  108. package/package.json +4 -3
  109. package/tsconfig.json +96 -0
  110. package/typescript-migration-progress.sh +22 -0
  111. package/.nyc_output/597f412e-a239-4319-ad5b-ddb87fc39e67.json +0 -1
  112. package/.nyc_output/processinfo/597f412e-a239-4319-ad5b-ddb87fc39e67.json +0 -1
@@ -1,164 +1,126 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.schema = exports.pageNameMap = exports.supportedPages = undefined;
7
-
8
- var _default = require("./default");
9
-
10
- var _default2 = _interopRequireDefault(_default);
11
-
12
- var _constants = require("../../constants");
13
-
14
- var _constants2 = _interopRequireDefault(_constants);
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- const supportedPages = exports.supportedPages = _constants2.default.PAGE_NAMES.filter(p => p.includes('.json')).map(p => p.replace('.json', ''));
19
-
20
- const pageNameMap = exports.pageNameMap = {
21
- guardian_multifactor: 'guardian_mfa_page',
22
- password_reset: 'change_password',
23
- error_page: 'error_page'
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
+ });
24
10
  };
25
- const schema = exports.schema = {
26
- type: 'array',
27
- items: {
28
- type: 'object',
29
- properties: {
30
- name: {
31
- type: 'string',
32
- enum: supportedPages
33
- },
34
- html: {
35
- type: 'string',
36
- default: ''
37
- },
38
- url: {
39
- type: 'string'
40
- },
41
- show_log_link: {
42
- type: 'boolean'
43
- },
44
- enabled: {
45
- type: 'boolean'
46
- }
47
- },
48
- required: ['name']
49
- }
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
50
13
  };
51
-
52
- class PageHandler extends _default2.default {
53
- constructor(options) {
54
- super({ ...options,
55
- type: 'pages'
56
- });
57
- }
58
-
59
- objString(page) {
60
- return super.objString({
61
- name: page.name,
62
- enabled: page.enabled
63
- });
64
- }
65
-
66
- async updateLoginPage(page) {
67
- const globalClient = await this.client.clients.getAll({
68
- is_global: true,
69
- paginate: true,
70
- include_totals: true
71
- });
72
-
73
- if (!globalClient[0]) {
74
- throw new Error('Unable to find global client id when trying to update the login page');
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.schema = exports.pageNameMap = exports.supportedPages = void 0;
16
+ const default_1 = __importDefault(require("./default"));
17
+ const constants_1 = __importDefault(require("../../constants"));
18
+ exports.supportedPages = constants_1.default.PAGE_NAMES
19
+ .filter((p) => p.includes('.json'))
20
+ .map((p) => p.replace('.json', ''));
21
+ exports.pageNameMap = {
22
+ guardian_multifactor: 'guardian_mfa_page',
23
+ password_reset: 'change_password',
24
+ error_page: 'error_page'
25
+ };
26
+ // With this schema, we can only validate property types but not valid properties on per type basis
27
+ exports.schema = {
28
+ type: 'array',
29
+ items: {
30
+ type: 'object',
31
+ properties: {
32
+ name: { type: 'string', enum: exports.supportedPages },
33
+ html: { type: 'string', default: '' },
34
+ url: { type: 'string' },
35
+ show_log_link: { type: 'boolean' },
36
+ enabled: { type: 'boolean' }
37
+ },
38
+ required: ['name']
75
39
  }
76
-
77
- await this.client.clients.update({
78
- client_id: globalClient[0].client_id
79
- }, {
80
- custom_login_page: page.html,
81
- custom_login_page_on: page.enabled
82
- });
83
- this.updated += 1;
84
- this.didUpdate(page);
85
- }
86
-
87
- async updatePages(pages) {
88
- const toUpdate = pages.filter(p => supportedPages.includes(p.name));
89
- const update = toUpdate.reduce((accum, page) => {
90
- if (supportedPages.includes(page.name)) {
91
- const pageName = pageNameMap[page.name];
92
-
93
- if (!pageName) {
94
- throw new Error(`Unable to map page ${page.name} into tenant level page setting`);
95
- }
96
-
97
- accum[pageName] = { ...page
98
- };
99
- delete accum[pageName].name;
100
- }
101
-
102
- return accum;
103
- }, {});
104
-
105
- if (Object.keys(update).length) {
106
- await this.client.tenant.updateSettings(update);
40
+ };
41
+ class PageHandler extends default_1.default {
42
+ constructor(options) {
43
+ super(Object.assign(Object.assign({}, options), { type: 'pages' }));
107
44
  }
108
-
109
- toUpdate.forEach(page => {
110
- this.updated += 1;
111
- this.didUpdate(page);
112
- });
113
- }
114
-
115
- async getType() {
116
- const pages = [];
117
- const globalClient = await this.client.clients.getAll({
118
- is_global: true,
119
- paginate: true,
120
- include_totals: true
121
- });
122
-
123
- if (!globalClient[0]) {
124
- throw new Error('Unable to find global client id when trying to dump the login page');
45
+ objString(page) {
46
+ return super.objString({ name: page.name, enabled: page.enabled });
125
47
  }
126
-
127
- if (globalClient[0].custom_login_page) {
128
- pages.push({
129
- name: 'login',
130
- enabled: globalClient[0].custom_login_page_on,
131
- html: globalClient[0].custom_login_page
132
- });
48
+ updateLoginPage(page) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const globalClient = yield this.client.clients.getAll({ is_global: true, paginate: true, include_totals: true });
51
+ if (!globalClient[0]) {
52
+ throw new Error('Unable to find global client id when trying to update the login page');
53
+ }
54
+ yield this.client.clients.update({ client_id: globalClient[0].client_id }, {
55
+ custom_login_page: page.html,
56
+ custom_login_page_on: page.enabled
57
+ });
58
+ this.updated += 1;
59
+ this.didUpdate(page);
60
+ });
133
61
  }
134
-
135
- const tenantSettings = await this.client.tenant.getSettings();
136
- Object.entries(pageNameMap).forEach(([key, name]) => {
137
- const page = tenantSettings[name];
138
-
139
- if (tenantSettings[name]) {
140
- pages.push({ ...page,
141
- name: key
62
+ updatePages(pages) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const toUpdate = pages.filter((p) => exports.supportedPages.includes(p.name));
65
+ const update = toUpdate.reduce((accum, page) => {
66
+ if (exports.supportedPages.includes(page.name)) {
67
+ const pageName = exports.pageNameMap[page.name];
68
+ if (!pageName) {
69
+ throw new Error(`Unable to map page ${page.name} into tenant level page setting`);
70
+ }
71
+ accum[pageName] = Object.assign({}, page);
72
+ delete accum[pageName].name;
73
+ }
74
+ return accum;
75
+ }, {});
76
+ if (Object.keys(update).length) {
77
+ yield this.client.tenant.updateSettings(update);
78
+ }
79
+ toUpdate.forEach((page) => {
80
+ this.updated += 1;
81
+ this.didUpdate(page);
82
+ });
83
+ });
84
+ }
85
+ getType() {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ const pages = [];
88
+ // Login page is handled via the global client
89
+ const globalClient = yield this.client.clients.getAll({ is_global: true, paginate: true, include_totals: true });
90
+ if (!globalClient[0]) {
91
+ throw new Error('Unable to find global client id when trying to dump the login page');
92
+ }
93
+ if (globalClient[0].custom_login_page) {
94
+ pages.push({
95
+ name: 'login',
96
+ enabled: globalClient[0].custom_login_page_on,
97
+ html: globalClient[0].custom_login_page
98
+ });
99
+ }
100
+ const tenantSettings = yield this.client.tenant.getSettings();
101
+ Object.entries(exports.pageNameMap).forEach(([key, name]) => {
102
+ const page = tenantSettings[name];
103
+ if (tenantSettings[name]) {
104
+ pages.push(Object.assign(Object.assign({}, page), { name: key }));
105
+ }
106
+ });
107
+ return pages;
108
+ });
109
+ }
110
+ processChanges(assets) {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ const { pages } = assets;
113
+ // Do nothing if not set
114
+ if (!pages)
115
+ return;
116
+ // Login page is handled via the global client
117
+ const loginPage = pages.find((p) => p.name === 'login');
118
+ if (loginPage) {
119
+ yield this.updateLoginPage(loginPage);
120
+ }
121
+ // Rest of pages are on tenant level settings
122
+ yield this.updatePages(pages.filter((p) => p.name !== 'login'));
142
123
  });
143
- }
144
- });
145
- return pages;
146
- }
147
-
148
- async processChanges(assets) {
149
- const {
150
- pages
151
- } = assets;
152
- if (!pages) return;
153
- const loginPage = pages.find(p => p.name === 'login');
154
-
155
- if (loginPage) {
156
- await this.updateLoginPage(loginPage);
157
124
  }
158
-
159
- await this.updatePages(pages.filter(p => p.name !== 'login'));
160
- }
161
-
162
125
  }
163
-
164
- exports.default = PageHandler;
126
+ exports.default = PageHandler;
@@ -1,51 +1,52 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.schema = undefined;
7
-
8
- var _default = require("./default");
9
-
10
- var _default2 = _interopRequireDefault(_default);
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- const schema = exports.schema = {
15
- type: 'object'
16
- };
17
-
18
- class PromptsHandler extends _default2.default {
19
- constructor(options) {
20
- super({ ...options,
21
- type: 'prompts'
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());
22
9
  });
23
- }
24
-
25
- async getType() {
26
- if (!this.client.prompts || typeof this.client.prompts.getSettings !== 'function') {
27
- return {};
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
+ exports.schema = void 0;
16
+ const default_1 = __importDefault(require("./default"));
17
+ exports.schema = { type: 'object' };
18
+ class PromptsHandler extends default_1.default {
19
+ constructor(options) {
20
+ super(Object.assign(Object.assign({}, options), { type: 'prompts' }));
21
+ }
22
+ getType() {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ // in case client version does not support branding
25
+ if (!this.client.prompts || typeof this.client.prompts.getSettings !== 'function') {
26
+ return {};
27
+ }
28
+ try {
29
+ return yield this.client.prompts.getSettings();
30
+ }
31
+ catch (err) {
32
+ if (err.statusCode === 404)
33
+ return {};
34
+ if (err.statusCode === 501)
35
+ return {};
36
+ throw err;
37
+ }
38
+ });
28
39
  }
29
-
30
- try {
31
- return await this.client.prompts.getSettings();
32
- } catch (err) {
33
- if (err.statusCode === 404) return {};
34
- if (err.statusCode === 501) return {};
35
- throw err;
40
+ processChanges(assets) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const { prompts } = assets;
43
+ // Do nothing if not set
44
+ if (!prompts || !Object.keys(prompts).length)
45
+ return;
46
+ yield this.client.prompts.updateSettings({}, prompts);
47
+ this.updated += 1;
48
+ this.didUpdate(prompts);
49
+ });
36
50
  }
37
- }
38
-
39
- async processChanges(assets) {
40
- const {
41
- prompts
42
- } = assets;
43
- if (!prompts || !Object.keys(prompts).length) return;
44
- await this.client.prompts.updateSettings({}, prompts);
45
- this.updated += 1;
46
- this.didUpdate(prompts);
47
- }
48
-
49
51
  }
50
-
51
- exports.default = PromptsHandler;
52
+ exports.default = PromptsHandler;
@@ -1,118 +1,94 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.schema = exports.excludeSchema = undefined;
7
-
8
- var _ValidationError = require("../../ValidationError");
9
-
10
- var _ValidationError2 = _interopRequireDefault(_ValidationError);
11
-
12
- var _constants = require("../../constants");
13
-
14
- var _constants2 = _interopRequireDefault(_constants);
15
-
16
- var _default = require("./default");
17
-
18
- var _default2 = _interopRequireDefault(_default);
19
-
20
- var _utils = require("../../utils");
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
- const excludeSchema = exports.excludeSchema = {
25
- type: 'array',
26
- items: {
27
- type: 'string'
28
- }
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 };
29
13
  };
30
- const schema = exports.schema = {
31
- type: 'array',
32
- items: {
33
- type: 'object',
34
- properties: {
35
- name: {
36
- type: 'string'
37
- },
38
- identifier: {
39
- type: 'string'
40
- },
41
- scopes: {
42
- type: 'array',
43
- items: {
44
- type: 'object',
45
- properties: {
46
- name: {
47
- type: 'string'
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.schema = exports.excludeSchema = void 0;
16
+ const ValidationError_1 = __importDefault(require("../../ValidationError"));
17
+ const constants_1 = __importDefault(require("../../constants"));
18
+ const default_1 = __importDefault(require("./default"));
19
+ const utils_1 = require("../../utils");
20
+ exports.excludeSchema = {
21
+ type: 'array',
22
+ items: { type: 'string' }
23
+ };
24
+ exports.schema = {
25
+ type: 'array',
26
+ items: {
27
+ type: 'object',
28
+ properties: {
29
+ name: { type: 'string' },
30
+ identifier: { type: 'string' },
31
+ scopes: {
32
+ type: 'array',
33
+ items: {
34
+ type: 'object',
35
+ properties: {
36
+ name: { type: 'string' },
37
+ description: { type: 'string' }
38
+ }
39
+ }
48
40
  },
49
- description: {
50
- type: 'string'
51
- }
52
- }
53
- }
54
- },
55
- enforce_policies: {
56
- type: 'boolean'
57
- },
58
- token_dialect: {
59
- type: 'string'
60
- }
61
- },
62
- required: ['name', 'identifier']
63
- }
41
+ enforce_policies: { type: 'boolean' },
42
+ token_dialect: { type: 'string' }
43
+ },
44
+ required: ['name', 'identifier']
45
+ }
64
46
  };
65
-
66
- class ResourceServersHandler extends _default2.default {
67
- constructor(options) {
68
- super({ ...options,
69
- type: 'resourceServers',
70
- stripUpdateFields: ['identifier']
71
- });
72
- }
73
-
74
- objString(resourceServer) {
75
- return super.objString({
76
- name: resourceServer.name,
77
- identifier: resourceServer.identifier
78
- });
79
- }
80
-
81
- async getType() {
82
- if (this.existing) return this.existing;
83
- const resourceServers = await this.client.resourceServers.getAll({
84
- paginate: true,
85
- include_totals: true
86
- });
87
- return resourceServers.filter(rs => rs.name !== _constants2.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
88
- }
89
-
90
- async calcChanges(assets) {
91
- let {
92
- resourceServers
93
- } = assets;
94
- if (!resourceServers) return {};
95
- const excluded = assets.exclude && assets.exclude.resourceServers || [];
96
- let existing = await this.getType();
97
- resourceServers = resourceServers.filter(r => !excluded.includes(r.name));
98
- existing = existing.filter(r => !excluded.includes(r.name));
99
- return (0, _utils.calcChanges)(this, resourceServers, existing, ['id', 'identifier']);
100
- }
101
-
102
- async validate(assets) {
103
- const {
104
- resourceServers
105
- } = assets;
106
- if (!resourceServers) return;
107
- const mgmtAPIResource = resourceServers.find(r => r.name === _constants2.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
108
-
109
- if (mgmtAPIResource) {
110
- throw new _ValidationError2.default(`You can not configure the '${_constants2.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME}'.`);
47
+ class ResourceServersHandler extends default_1.default {
48
+ constructor(options) {
49
+ super(Object.assign(Object.assign({}, options), { type: 'resourceServers', stripUpdateFields: ['identifier'] // Fields not allowed in updates
50
+ }));
51
+ }
52
+ objString(resourceServer) {
53
+ return super.objString({ name: resourceServer.name, identifier: resourceServer.identifier });
54
+ }
55
+ getType() {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ if (this.existing)
58
+ return this.existing;
59
+ const resourceServers = yield this.client.resourceServers.getAll({ paginate: true, include_totals: true });
60
+ return resourceServers.filter((rs) => rs.name !== constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
61
+ });
62
+ }
63
+ calcChanges(assets) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ let { resourceServers } = assets;
66
+ // Do nothing if not set
67
+ if (!resourceServers)
68
+ return {};
69
+ const excluded = (assets.exclude && assets.exclude.resourceServers) || [];
70
+ let existing = yield this.getType();
71
+ // Filter excluded
72
+ resourceServers = resourceServers.filter((r) => !excluded.includes(r.name));
73
+ existing = existing.filter((r) => !excluded.includes(r.name));
74
+ return (0, utils_1.calcChanges)(this, resourceServers, existing, ['id', 'identifier']);
75
+ });
76
+ }
77
+ validate(assets) {
78
+ const _super = Object.create(null, {
79
+ validate: { get: () => super.validate }
80
+ });
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ const { resourceServers } = assets;
83
+ // Do nothing if not set
84
+ if (!resourceServers)
85
+ return;
86
+ const mgmtAPIResource = resourceServers.find((r) => r.name === constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME);
87
+ if (mgmtAPIResource) {
88
+ throw new ValidationError_1.default(`You can not configure the '${constants_1.default.RESOURCE_SERVERS_MANAGEMENT_API_NAME}'.`);
89
+ }
90
+ yield _super.validate.call(this, assets);
91
+ });
111
92
  }
112
-
113
- await super.validate(assets);
114
- }
115
-
116
93
  }
117
-
118
- exports.default = ResourceServersHandler;
94
+ exports.default = ResourceServersHandler;