auth0-deploy-cli 7.3.6 → 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.
- package/.circleci/config.yml +15 -0
- package/.github/CODEOWNERS +1 -0
- package/.husky/pre-commit +6 -0
- package/.husky/pre-push +4 -0
- package/.nyc_output/60b76a45-577b-4171-9982-a8e836ab7fd6.json +1 -0
- package/.nyc_output/processinfo/60b76a45-577b-4171-9982-a8e836ab7fd6.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/CHANGELOG.md +35 -2
- package/lib/args.js +89 -81
- package/lib/commands/export.js +51 -77
- package/lib/commands/import.js +45 -69
- package/lib/commands/index.js +11 -20
- package/lib/configFactory.js +19 -27
- package/lib/context/defaults.js +18 -41
- package/lib/context/directory/handlers/actions.js +77 -107
- package/lib/context/directory/handlers/attackProtection.js +59 -0
- package/lib/context/directory/handlers/clientGrants.js +45 -54
- package/lib/context/directory/handlers/clients.js +60 -79
- package/lib/context/directory/handlers/connections.js +65 -89
- package/lib/context/directory/handlers/databases.js +91 -123
- package/lib/context/directory/handlers/emailProvider.js +46 -57
- package/lib/context/directory/handlers/emailTemplates.js +67 -80
- package/lib/context/directory/handlers/guardianFactorProviders.js +41 -49
- package/lib/context/directory/handlers/guardianFactorTemplates.js +41 -49
- package/lib/context/directory/handlers/guardianFactors.js +41 -49
- package/lib/context/directory/handlers/guardianPhoneFactorMessageTypes.js +40 -50
- package/lib/context/directory/handlers/guardianPhoneFactorSelectedProvider.js +40 -50
- package/lib/context/directory/handlers/guardianPolicies.js +40 -50
- package/lib/context/directory/handlers/hooks.js +55 -70
- package/lib/context/directory/handlers/index.js +53 -123
- package/lib/context/directory/handlers/migrations.js +36 -41
- package/lib/context/directory/handlers/organizations.js +54 -69
- package/lib/context/directory/handlers/pages.js +72 -86
- package/lib/context/directory/handlers/resourceServers.js +41 -49
- package/lib/context/directory/handlers/roles.js +49 -62
- package/lib/context/directory/handlers/rules.js +52 -68
- package/lib/context/directory/handlers/rulesConfigs.js +33 -32
- package/lib/context/directory/handlers/tenant.js +52 -47
- package/lib/context/directory/handlers/triggers.js +39 -54
- package/lib/context/directory/index.js +113 -101
- package/lib/context/index.js +96 -105
- package/lib/context/yaml/handlers/actions.js +71 -88
- package/lib/context/yaml/handlers/attackProtection.js +29 -0
- package/lib/context/yaml/handlers/clientGrants.js +36 -29
- package/lib/context/yaml/handlers/clients.js +61 -76
- package/lib/context/yaml/handlers/connections.js +76 -103
- package/lib/context/yaml/handlers/databases.js +64 -79
- package/lib/context/yaml/handlers/emailProvider.js +33 -30
- package/lib/context/yaml/handlers/emailTemplates.js +45 -54
- package/lib/context/yaml/handlers/guardianFactorProviders.js +27 -18
- package/lib/context/yaml/handlers/guardianFactorTemplates.js +27 -18
- package/lib/context/yaml/handlers/guardianFactors.js +27 -18
- package/lib/context/yaml/handlers/guardianPhoneFactorMessageTypes.js +27 -20
- package/lib/context/yaml/handlers/guardianPhoneFactorSelectedProvider.js +27 -20
- package/lib/context/yaml/handlers/guardianPolicies.js +27 -20
- package/lib/context/yaml/handlers/hooks.js +57 -67
- package/lib/context/yaml/handlers/index.js +53 -123
- package/lib/context/yaml/handlers/migrations.js +23 -24
- package/lib/context/yaml/handlers/organizations.js +40 -38
- package/lib/context/yaml/handlers/pages.js +49 -58
- package/lib/context/yaml/handlers/resourceServers.js +27 -18
- package/lib/context/yaml/handlers/roles.js +34 -24
- package/lib/context/yaml/handlers/rules.js +48 -58
- package/lib/context/yaml/handlers/rulesConfigs.js +27 -18
- package/lib/context/yaml/handlers/tenant.js +44 -30
- package/lib/context/yaml/handlers/triggers.js +32 -23
- package/lib/context/yaml/index.js +127 -142
- package/lib/index.js +73 -79
- package/lib/logger.js +18 -22
- package/lib/readonly.js +74 -66
- package/lib/tools/ValidationError.js +8 -13
- package/lib/tools/auth0/client.js +143 -133
- package/lib/tools/auth0/handlers/actions.js +231 -241
- package/lib/tools/auth0/handlers/attackProtection.js +86 -0
- package/lib/tools/auth0/handlers/branding.js +47 -46
- package/lib/tools/auth0/handlers/clientGrants.js +118 -116
- package/lib/tools/auth0/handlers/clients.js +72 -90
- package/lib/tools/auth0/handlers/connections.js +150 -118
- package/lib/tools/auth0/handlers/databases.js +127 -124
- package/lib/tools/auth0/handlers/default.js +186 -189
- package/lib/tools/auth0/handlers/emailProvider.js +67 -78
- package/lib/tools/auth0/handlers/emailTemplates.js +116 -92
- package/lib/tools/auth0/handlers/guardianFactorProviders.js +66 -81
- package/lib/tools/auth0/handlers/guardianFactorTemplates.js +60 -71
- package/lib/tools/auth0/handlers/guardianFactors.js +56 -63
- package/lib/tools/auth0/handlers/guardianPhoneFactorMessageTypes.js +80 -79
- package/lib/tools/auth0/handlers/guardianPhoneFactorSelectedProvider.js +77 -76
- package/lib/tools/auth0/handlers/guardianPolicies.js +59 -62
- package/lib/tools/auth0/handlers/hooks.js +201 -227
- package/lib/tools/auth0/handlers/index.js +53 -111
- package/lib/tools/auth0/handlers/migrations.js +99 -79
- package/lib/tools/auth0/handlers/organizations.js +225 -247
- package/lib/tools/auth0/handlers/pages.js +116 -154
- package/lib/tools/auth0/handlers/prompts.js +47 -46
- package/lib/tools/auth0/handlers/resourceServers.js +88 -112
- package/lib/tools/auth0/handlers/roles.js +203 -220
- package/lib/tools/auth0/handlers/rules.js +168 -189
- package/lib/tools/auth0/handlers/rulesConfigs.js +54 -63
- package/lib/tools/auth0/handlers/tenant.js +88 -64
- package/lib/tools/auth0/handlers/triggers.js +126 -126
- package/lib/tools/auth0/index.js +92 -85
- package/lib/tools/auth0/schema.js +39 -31
- package/lib/tools/constants.js +111 -21
- package/lib/tools/deploy.js +35 -32
- package/lib/tools/index.js +19 -32
- package/lib/tools/logger.js +11 -12
- package/lib/tools/utils.js +258 -254
- package/lib/utils.js +167 -190
- package/package.json +6 -3
- package/tsconfig.json +96 -0
- package/typescript-migration-progress.sh +22 -0
- package/.nyc_output/8cf4dd0c-1f3a-4ac1-899c-8e453a64221e.json +0 -1
- package/.nyc_output/processinfo/8cf4dd0c-1f3a-4ac1-899c-8e453a64221e.json +0 -1
|
@@ -1,198 +1,177 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _ValidationError2 = _interopRequireDefault(_ValidationError);
|
|
11
|
-
|
|
12
|
-
var _utils = require("../../utils");
|
|
13
|
-
|
|
14
|
-
var _default = require("./default");
|
|
15
|
-
|
|
16
|
-
var _default2 = _interopRequireDefault(_default);
|
|
17
|
-
|
|
18
|
-
var _logger = require("../../logger");
|
|
19
|
-
|
|
20
|
-
var _logger2 = _interopRequireDefault(_logger);
|
|
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
|
+
});
|
|
29
10
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
items: {
|
|
33
|
-
type: 'object',
|
|
34
|
-
default: [],
|
|
35
|
-
properties: {
|
|
36
|
-
script: {
|
|
37
|
-
type: 'string',
|
|
38
|
-
description: 'A script that contains the rule\'s code',
|
|
39
|
-
default: ''
|
|
40
|
-
},
|
|
41
|
-
name: {
|
|
42
|
-
type: 'string',
|
|
43
|
-
description: 'The name of the rule. Can only contain alphanumeric characters, spaces and \'-\'. Can neither start nor end with \'-\' or spaces',
|
|
44
|
-
pattern: '^[^-\\s][a-zA-Z0-9-\\s]+[^-\\s]$'
|
|
45
|
-
},
|
|
46
|
-
order: {
|
|
47
|
-
type: ['number', 'null'],
|
|
48
|
-
description: 'The rule\'s order in relation to other rules. A rule with a lower order than another rule executes first.',
|
|
49
|
-
default: null
|
|
50
|
-
},
|
|
51
|
-
enabled: {
|
|
52
|
-
type: 'boolean',
|
|
53
|
-
description: 'true if the rule is enabled, false otherwise',
|
|
54
|
-
default: true
|
|
55
|
-
},
|
|
56
|
-
stage: {
|
|
57
|
-
type: 'string',
|
|
58
|
-
description: 'The rule\'s execution stage',
|
|
59
|
-
default: 'login_success',
|
|
60
|
-
enum: ['login_success', 'login_failure', 'pre_authorize']
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
required: ['name']
|
|
64
|
-
}
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
13
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.schema = exports.excludeSchema = void 0;
|
|
16
|
+
const ValidationError_1 = __importDefault(require("../../ValidationError"));
|
|
17
|
+
const utils_1 = require("../../utils");
|
|
18
|
+
const default_1 = __importDefault(require("./default"));
|
|
19
|
+
const logger_1 = __importDefault(require("../../logger"));
|
|
20
|
+
exports.excludeSchema = {
|
|
21
|
+
type: 'array',
|
|
22
|
+
items: { type: 'string' }
|
|
23
|
+
};
|
|
24
|
+
exports.schema = {
|
|
25
|
+
type: 'array',
|
|
26
|
+
items: {
|
|
27
|
+
type: 'object',
|
|
28
|
+
default: [],
|
|
29
|
+
properties: {
|
|
30
|
+
script: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'A script that contains the rule\'s code',
|
|
33
|
+
default: ''
|
|
34
|
+
},
|
|
35
|
+
name: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'The name of the rule. Can only contain alphanumeric characters, spaces and \'-\'. Can neither start nor end with \'-\' or spaces',
|
|
38
|
+
pattern: '^[^-\\s][a-zA-Z0-9-\\s]+[^-\\s]$'
|
|
39
|
+
},
|
|
40
|
+
order: {
|
|
41
|
+
type: ['number', 'null'],
|
|
42
|
+
description: 'The rule\'s order in relation to other rules. A rule with a lower order than another rule executes first.',
|
|
43
|
+
default: null
|
|
44
|
+
},
|
|
45
|
+
enabled: {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
description: 'true if the rule is enabled, false otherwise',
|
|
48
|
+
default: true
|
|
49
|
+
},
|
|
50
|
+
stage: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
description: 'The rule\'s execution stage',
|
|
53
|
+
default: 'login_success',
|
|
54
|
+
enum: ['login_success', 'login_failure', 'pre_authorize']
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
required: ['name']
|
|
101
58
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const conflict = existing.find(f => r.order === f.order && r.name !== f.name);
|
|
115
|
-
|
|
116
|
-
if (conflict) {
|
|
117
|
-
nextOrderNo += 1;
|
|
118
|
-
accum.push({ ...conflict,
|
|
119
|
-
order: nextOrderNo
|
|
59
|
+
};
|
|
60
|
+
class RulesHandler extends default_1.default {
|
|
61
|
+
constructor(options) {
|
|
62
|
+
super(Object.assign(Object.assign({}, options), { type: 'rules', stripUpdateFields: ['stage'] // Fields not allowed in updates
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
getType() {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
if (this.existing)
|
|
68
|
+
return this.existing;
|
|
69
|
+
this.existing = yield this.client.rules.getAll({ paginate: true, include_totals: true });
|
|
70
|
+
return this.existing;
|
|
120
71
|
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return accum;
|
|
124
|
-
}, []);
|
|
125
|
-
return {
|
|
126
|
-
del,
|
|
127
|
-
update,
|
|
128
|
-
create,
|
|
129
|
-
reOrder,
|
|
130
|
-
conflicts
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async validate(assets) {
|
|
135
|
-
const {
|
|
136
|
-
rules
|
|
137
|
-
} = assets;
|
|
138
|
-
if (!rules) return;
|
|
139
|
-
const excludedRules = assets.exclude && assets.exclude.rules || [];
|
|
140
|
-
const {
|
|
141
|
-
update,
|
|
142
|
-
create,
|
|
143
|
-
del
|
|
144
|
-
} = await this.calcChanges(assets, true);
|
|
145
|
-
const futureRules = [...create, ...update, ...del.filter(r => excludedRules.includes(r.name))];
|
|
146
|
-
const rulesSameOrder = (0, _utils.duplicateItems)(futureRules, 'order');
|
|
147
|
-
|
|
148
|
-
if (rulesSameOrder.length > 0) {
|
|
149
|
-
const formatted = rulesSameOrder.map(dups => dups.map(d => `${d.name}`));
|
|
150
|
-
throw new _ValidationError2.default(`There are multiple rules for the following stage-order combinations
|
|
151
|
-
${(0, _utils.dumpJSON)(formatted)}.
|
|
152
|
-
Only one rule must be defined for the same order number in a stage.`);
|
|
153
72
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
73
|
+
objString(rule) {
|
|
74
|
+
return super.objString({ name: rule.name, order: rule.order });
|
|
75
|
+
}
|
|
76
|
+
calcChanges(assets, includeExcluded = false) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
let { rules } = assets;
|
|
79
|
+
const excludedRules = (assets.exclude && assets.exclude.rules) || [];
|
|
80
|
+
let existing = yield this.getType();
|
|
81
|
+
// Filter excluded rules
|
|
82
|
+
if (!includeExcluded) {
|
|
83
|
+
rules = rules.filter((r) => !excludedRules.includes(r.name));
|
|
84
|
+
existing = existing.filter((r) => !excludedRules.includes(r.name));
|
|
85
|
+
}
|
|
86
|
+
// Figure out what needs to be updated vs created
|
|
87
|
+
const { del, update, create, conflicts } = (0, utils_1.calcChanges)(this, rules, existing, ['id', 'name']);
|
|
88
|
+
// Figure out the rules that need to be re-ordered
|
|
89
|
+
const futureRules = [...create, ...update];
|
|
90
|
+
const futureMaxOrder = Math.max(...futureRules.map((r) => r.order));
|
|
91
|
+
const existingMaxOrder = Math.max(...existing.map((r) => r.order));
|
|
92
|
+
let nextOrderNo = Math.max(futureMaxOrder, existingMaxOrder);
|
|
93
|
+
const reOrder = futureRules.reduce((accum, r) => {
|
|
94
|
+
const conflict = existing.find((f) => r.order === f.order && r.name !== f.name);
|
|
95
|
+
if (conflict) {
|
|
96
|
+
nextOrderNo += 1;
|
|
97
|
+
accum.push(Object.assign(Object.assign({}, conflict), { order: nextOrderNo }));
|
|
98
|
+
}
|
|
99
|
+
return accum;
|
|
100
|
+
}, []);
|
|
101
|
+
return {
|
|
102
|
+
del,
|
|
103
|
+
update,
|
|
104
|
+
create,
|
|
105
|
+
reOrder,
|
|
106
|
+
conflicts
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
validate(assets) {
|
|
111
|
+
const _super = Object.create(null, {
|
|
112
|
+
validate: { get: () => super.validate }
|
|
113
|
+
});
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const { rules } = assets;
|
|
116
|
+
// Do nothing if not set
|
|
117
|
+
if (!rules)
|
|
118
|
+
return;
|
|
119
|
+
const excludedRules = (assets.exclude && assets.exclude.rules) || [];
|
|
120
|
+
// Figure out what needs to be updated vs created
|
|
121
|
+
const { update, create, del } = yield this.calcChanges(assets, true);
|
|
122
|
+
// Include del rules which are actually not going to be deleted but are excluded
|
|
123
|
+
// they can still muck up the ordering so we must take it into consideration.
|
|
124
|
+
const futureRules = [...create, ...update, ...del.filter((r) => excludedRules.includes(r.name))];
|
|
125
|
+
// Detect rules with the same order
|
|
126
|
+
const rulesSameOrder = (0, utils_1.duplicateItems)(futureRules, 'order');
|
|
127
|
+
if (rulesSameOrder.length > 0) {
|
|
128
|
+
const formatted = rulesSameOrder.map((dups) => dups.map((d) => `${d.name}`));
|
|
129
|
+
throw new ValidationError_1.default(`There are multiple rules for the following stage-order combinations
|
|
130
|
+
${(0, utils_1.dumpJSON)(formatted)}.
|
|
131
|
+
Only one rule must be defined for the same order number in a stage.`);
|
|
132
|
+
}
|
|
133
|
+
// Detect Rules that are changing stage as it's not allowed.
|
|
134
|
+
const existing = yield this.getType();
|
|
135
|
+
const stateChanged = futureRules.reduce((changed, rule) => ([
|
|
136
|
+
...changed,
|
|
137
|
+
...existing.filter((r) => rule.name.toLowerCase() === r.name.toLowerCase() && r.stage !== rule.stage)
|
|
138
|
+
]), []).map((r) => r.name);
|
|
139
|
+
if (stateChanged.length > 0) {
|
|
140
|
+
throw new ValidationError_1.default(`The following rules changed stage which is not allowed:
|
|
141
|
+
${(0, utils_1.dumpJSON)(stateChanged)}.
|
|
161
142
|
Rename the rules to recreate them and avoid this error.`);
|
|
143
|
+
}
|
|
144
|
+
yield _super.validate.call(this, assets);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
processChanges(assets) {
|
|
148
|
+
const _super = Object.create(null, {
|
|
149
|
+
processChanges: { get: () => super.processChanges }
|
|
150
|
+
});
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
const { rules } = assets;
|
|
153
|
+
// Do nothing if not set
|
|
154
|
+
if (!rules)
|
|
155
|
+
return;
|
|
156
|
+
// Figure out what needs to be updated vs created
|
|
157
|
+
const changes = yield this.calcChanges(assets);
|
|
158
|
+
// Temporally re-order rules with conflicting ordering
|
|
159
|
+
yield this.client.pool.addEachTask({
|
|
160
|
+
data: changes.reOrder,
|
|
161
|
+
generator: (rule) => this.client.updateRule({ id: rule.id }, (0, utils_1.stripFields)(rule, this.stripUpdateFields)).then(() => {
|
|
162
|
+
const updated = {
|
|
163
|
+
name: rule.name, stage: rule.stage, order: rule.order, id: rule.id
|
|
164
|
+
};
|
|
165
|
+
logger_1.default.info(`Temporally re-order Rule ${(0, utils_1.dumpJSON)(updated)}`);
|
|
166
|
+
})
|
|
167
|
+
}).promise();
|
|
168
|
+
yield _super.processChanges.call(this, assets, {
|
|
169
|
+
del: changes.del,
|
|
170
|
+
create: changes.create,
|
|
171
|
+
update: changes.update,
|
|
172
|
+
conflicts: changes.conflicts
|
|
173
|
+
});
|
|
174
|
+
});
|
|
162
175
|
}
|
|
163
|
-
|
|
164
|
-
await super.validate(assets);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async processChanges(assets) {
|
|
168
|
-
const {
|
|
169
|
-
rules
|
|
170
|
-
} = assets;
|
|
171
|
-
if (!rules) return;
|
|
172
|
-
const changes = await this.calcChanges(assets);
|
|
173
|
-
await this.client.pool.addEachTask({
|
|
174
|
-
data: changes.reOrder,
|
|
175
|
-
generator: rule => this.client.updateRule({
|
|
176
|
-
id: rule.id
|
|
177
|
-
}, (0, _utils.stripFields)(rule, this.stripUpdateFields)).then(() => {
|
|
178
|
-
const updated = {
|
|
179
|
-
name: rule.name,
|
|
180
|
-
stage: rule.stage,
|
|
181
|
-
order: rule.order,
|
|
182
|
-
id: rule.id
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
_logger2.default.info(`Temporally re-order Rule ${(0, _utils.dumpJSON)(updated)}`);
|
|
186
|
-
})
|
|
187
|
-
}).promise();
|
|
188
|
-
await super.processChanges(assets, {
|
|
189
|
-
del: changes.del,
|
|
190
|
-
create: changes.create,
|
|
191
|
-
update: changes.update,
|
|
192
|
-
conflicts: changes.conflicts
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
176
|
}
|
|
197
|
-
|
|
198
|
-
exports.default = RulesHandler;
|
|
177
|
+
exports.default = RulesHandler;
|
|
@@ -1,67 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
type: '
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
exports.schema = void 0;
|
|
16
|
+
const default_1 = __importDefault(require("./default"));
|
|
17
|
+
exports.schema = {
|
|
18
|
+
type: 'array',
|
|
19
|
+
items: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
key: { type: 'string', pattern: '^[A-Za-z0-9_-]*$' },
|
|
23
|
+
value: { type: 'string' }
|
|
24
|
+
},
|
|
25
|
+
required: ['key', 'value']
|
|
26
26
|
},
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
additionalProperties: false
|
|
27
|
+
additionalProperties: false
|
|
30
28
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
del: [],
|
|
60
|
-
update: rulesConfigs,
|
|
61
|
-
create: []
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
29
|
+
class RulesConfigsHandler extends default_1.default {
|
|
30
|
+
constructor(options) {
|
|
31
|
+
super(Object.assign(Object.assign({}, options), { type: 'rulesConfigs', id: 'key', functions: {
|
|
32
|
+
update: 'set' // Update or Creation of a ruleConfig is via set not update
|
|
33
|
+
} }));
|
|
34
|
+
}
|
|
35
|
+
getType() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
return this.client.rulesConfigs.getAll();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
objString(item) {
|
|
41
|
+
return super.objString({ key: item.key });
|
|
42
|
+
}
|
|
43
|
+
calcChanges(assets) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const { rulesConfigs } = assets;
|
|
46
|
+
// Do nothing if not set
|
|
47
|
+
if (!rulesConfigs || !rulesConfigs.length)
|
|
48
|
+
return {};
|
|
49
|
+
// Intention is to not delete/cleanup old configRules, that needs to be handled manually.
|
|
50
|
+
return {
|
|
51
|
+
del: [],
|
|
52
|
+
update: rulesConfigs,
|
|
53
|
+
create: []
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
65
57
|
}
|
|
66
|
-
|
|
67
|
-
exports.default = RulesConfigsHandler;
|
|
58
|
+
exports.default = RulesConfigsHandler;
|
|
@@ -1,70 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
5
17
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _ValidationError2 = _interopRequireDefault(_ValidationError);
|
|
13
|
-
|
|
14
|
-
var _default = require("./default");
|
|
15
|
-
|
|
16
|
-
var _default2 = _interopRequireDefault(_default);
|
|
17
|
-
|
|
18
|
-
var _pages = require("./pages");
|
|
19
|
-
|
|
20
|
-
var _utils = require("../../utils");
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
|
-
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
25
|
-
|
|
26
|
-
const schema = exports.schema = {
|
|
27
|
-
type: 'object'
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
28
23
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
32
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
33
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
34
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
35
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
36
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
37
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41
38
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
};
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.schema = void 0;
|
|
45
|
+
const ValidationError_1 = __importDefault(require("../../ValidationError"));
|
|
46
|
+
const default_1 = __importStar(require("./default"));
|
|
47
|
+
const pages_1 = require("./pages");
|
|
48
|
+
const utils_1 = require("../../utils");
|
|
49
|
+
exports.schema = {
|
|
50
|
+
type: 'object'
|
|
51
|
+
};
|
|
52
|
+
const blockPageKeys = [...Object.keys(pages_1.pageNameMap), ...Object.values(pages_1.pageNameMap), ...pages_1.supportedPages];
|
|
53
|
+
class TenantHandler extends default_1.default {
|
|
54
|
+
constructor(options) {
|
|
55
|
+
super(Object.assign(Object.assign({}, options), { type: 'tenant' }));
|
|
56
|
+
}
|
|
57
|
+
getType() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const tenant = yield this.client.tenant.getSettings();
|
|
60
|
+
blockPageKeys.forEach((key) => {
|
|
61
|
+
if (tenant[key])
|
|
62
|
+
delete tenant[key];
|
|
63
|
+
});
|
|
64
|
+
return tenant;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
validate(assets) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const { tenant } = assets;
|
|
70
|
+
// Nothing to validate?
|
|
71
|
+
if (!tenant)
|
|
72
|
+
return;
|
|
73
|
+
const pageKeys = Object.keys(tenant).filter((k) => blockPageKeys.includes(k));
|
|
74
|
+
if (pageKeys.length > 0) {
|
|
75
|
+
throw new ValidationError_1.default(`The following pages ${(0, utils_1.dumpJSON)(pageKeys)} were found in tenant settings. Pages should be set separately. Please refer to the documentation.`);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
54
78
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.didUpdate(tenant);
|
|
79
|
+
// Run after other updates so objected can be referenced such as default directory
|
|
80
|
+
processChanges(assets) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const { tenant } = assets;
|
|
83
|
+
if (tenant && Object.keys(tenant).length > 0) {
|
|
84
|
+
yield this.client.tenant.updateSettings(tenant);
|
|
85
|
+
this.updated += 1;
|
|
86
|
+
this.didUpdate(tenant);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
66
89
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
90
|
+
}
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, default_1.order)('100')
|
|
93
|
+
], TenantHandler.prototype, "processChanges", null);
|
|
94
|
+
exports.default = TenantHandler;
|