auth0-deploy-cli 8.1.0 → 8.2.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/.nyc_output/22a18025-9f7a-437a-8a03-9b2d634bd0a0.json +1 -0
- package/.nyc_output/processinfo/22a18025-9f7a-437a-8a03-9b2d634bd0a0.json +1 -0
- package/.nyc_output/processinfo/43514efa-958a-42dc-98b7-6a094257d3c1.json +1 -0
- package/.nyc_output/processinfo/97d5e38d-7d72-4b1a-b747-5dd4b539b6f0.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/CHANGELOG.md +14 -1
- package/coverage/lcov-report/index.html +47 -47
- package/coverage/lcov.info +1948 -1096
- package/docs/configuring-the-deploy-cli.md +8 -0
- package/lib/context/directory/handlers/flowVaultConnections.d.ts +6 -0
- package/lib/context/directory/handlers/flowVaultConnections.js +81 -0
- package/lib/context/directory/handlers/flowVaultConnections.js.map +1 -0
- package/lib/context/directory/handlers/flows.d.ts +6 -0
- package/lib/context/directory/handlers/flows.js +80 -0
- package/lib/context/directory/handlers/flows.js.map +1 -0
- package/lib/context/directory/handlers/forms.d.ts +6 -0
- package/lib/context/directory/handlers/forms.js +80 -0
- package/lib/context/directory/handlers/forms.js.map +1 -0
- package/lib/context/directory/handlers/index.js +6 -0
- package/lib/context/directory/handlers/index.js.map +1 -1
- package/lib/context/yaml/handlers/flowVaultConnections.d.ts +6 -0
- package/lib/context/yaml/handlers/flowVaultConnections.js +66 -0
- package/lib/context/yaml/handlers/flowVaultConnections.js.map +1 -0
- package/lib/context/yaml/handlers/flows.d.ts +6 -0
- package/lib/context/yaml/handlers/flows.js +92 -0
- package/lib/context/yaml/handlers/flows.js.map +1 -0
- package/lib/context/yaml/handlers/forms.d.ts +6 -0
- package/lib/context/yaml/handlers/forms.js +92 -0
- package/lib/context/yaml/handlers/forms.js.map +1 -0
- package/lib/context/yaml/handlers/index.js +6 -0
- package/lib/context/yaml/handlers/index.js.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/tools/auth0/handlers/flowVaultConnections.d.ts +53 -0
- package/lib/tools/auth0/handlers/flowVaultConnections.js +188 -0
- package/lib/tools/auth0/handlers/flowVaultConnections.js.map +1 -0
- package/lib/tools/auth0/handlers/flows.d.ts +32 -0
- package/lib/tools/auth0/handlers/flows.js +156 -0
- package/lib/tools/auth0/handlers/flows.js.map +1 -0
- package/lib/tools/auth0/handlers/forms.d.ts +32 -0
- package/lib/tools/auth0/handlers/forms.js +137 -0
- package/lib/tools/auth0/handlers/forms.js.map +1 -0
- package/lib/tools/auth0/handlers/index.js +6 -0
- package/lib/tools/auth0/handlers/index.js.map +1 -1
- package/lib/tools/constants.d.ts +4 -0
- package/lib/tools/constants.js +26 -0
- package/lib/tools/constants.js.map +1 -1
- package/lib/tools/index.d.ts +4 -0
- package/lib/types.d.ts +7 -1
- package/lib/types.js.map +1 -1
- package/lib/utils.d.ts +7 -0
- package/lib/utils.js +25 -0
- package/lib/utils.js.map +1 -1
- package/package.json +6 -6
- package/.nyc_output/eddfc559-04e8-4f99-adef-dd9503950c80.json +0 -1
- package/.nyc_output/processinfo/20b0af71-c58f-402b-ac9c-4c5b7a505a79.json +0 -1
- package/.nyc_output/processinfo/9b0c8b3d-76ba-4549-b82e-b44e387f2419.json +0 -1
- package/.nyc_output/processinfo/eddfc559-04e8-4f99-adef-dd9503950c80.json +0 -1
- /package/.nyc_output/{20b0af71-c58f-402b-ac9c-4c5b7a505a79.json → 43514efa-958a-42dc-98b7-6a094257d3c1.json} +0 -0
- /package/.nyc_output/{9b0c8b3d-76ba-4549-b82e-b44e387f2419.json → 97d5e38d-7d72-4b1a-b747-5dd4b539b6f0.json} +0 -0
|
@@ -31,6 +31,9 @@ const themes_1 = __importDefault(require("./themes"));
|
|
|
31
31
|
const rules_1 = __importDefault(require("./rules"));
|
|
32
32
|
const rulesConfigs_1 = __importDefault(require("./rulesConfigs"));
|
|
33
33
|
const hooks_1 = __importDefault(require("./hooks"));
|
|
34
|
+
const forms_1 = __importDefault(require("./forms"));
|
|
35
|
+
const flows_1 = __importDefault(require("./flows"));
|
|
36
|
+
const flowVaultConnections_1 = __importDefault(require("./flowVaultConnections"));
|
|
34
37
|
const yamlHandlers = {
|
|
35
38
|
rules: rules_1.default,
|
|
36
39
|
rulesConfigs: rulesConfigs_1.default,
|
|
@@ -60,6 +63,9 @@ const yamlHandlers = {
|
|
|
60
63
|
prompts: prompts_1.default,
|
|
61
64
|
customDomains: customDomains_1.default,
|
|
62
65
|
themes: themes_1.default,
|
|
66
|
+
forms: forms_1.default,
|
|
67
|
+
flows: flows_1.default,
|
|
68
|
+
flowVaultConnections: flowVaultConnections_1.default,
|
|
63
69
|
};
|
|
64
70
|
exports.default = yamlHandlers;
|
|
65
71
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/context/yaml/handlers/index.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAC5B,wDAAgC;AAChC,sDAA8B;AAC9B,oEAA4C;AAC5C,gEAAwC;AACxC,4DAAoC;AACpC,sEAA8C;AAC9C,kEAA0C;AAC1C,wEAAgD;AAChD,wEAAgD;AAChD,wFAAgE;AAChE,wFAAgE;AAChE,wGAAgF;AAChF,gHAAwF;AACxF,0EAAkD;AAClD,oDAA4B;AAC5B,oEAA4C;AAC5C,wDAAgC;AAChC,0DAAkC;AAClC,0EAAkD;AAClD,0DAAkC;AAClC,8DAAsC;AACtC,wDAAgC;AAChC,oEAA4C;AAC5C,sDAA8B;AAC9B,oDAA4B;AAC5B,kEAA0C;AAC1C,oDAA4B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/context/yaml/handlers/index.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAC5B,wDAAgC;AAChC,sDAA8B;AAC9B,oEAA4C;AAC5C,gEAAwC;AACxC,4DAAoC;AACpC,sEAA8C;AAC9C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ED
|
@@ -81,6 +81,10 @@ declare const _default: {
|
|
|
81
81
|
PARTIALS_DIRECTORY: string;
|
|
82
82
|
CUSTOM_DOMAINS_DIRECTORY: string;
|
|
83
83
|
THEMES_DIRECTORY: string;
|
|
84
|
+
CONNECTION_APP_ID: string[];
|
|
85
|
+
FORMS_DIRECTORY: string;
|
|
86
|
+
FLOWS_DIRECTORY: string;
|
|
87
|
+
FLOWS_VAULT_DIRECTORY: string;
|
|
84
88
|
};
|
|
85
89
|
deploy: typeof import("./tools").deploy;
|
|
86
90
|
keywordReplace: typeof import("./tools").keywordReplace;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { GetFlowsVaultConnections200ResponseOneOfInner } from 'auth0';
|
|
2
|
+
import DefaultHandler from './default';
|
|
3
|
+
import { Asset, Assets, CalculatedChanges } from '../../../types';
|
|
4
|
+
export type FlowVaultConnection = {
|
|
5
|
+
name: string;
|
|
6
|
+
app_id: string;
|
|
7
|
+
environment: string;
|
|
8
|
+
setup: object;
|
|
9
|
+
account_name: string;
|
|
10
|
+
ready: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const schema: {
|
|
13
|
+
type: string;
|
|
14
|
+
items: {
|
|
15
|
+
type: string;
|
|
16
|
+
properties: {
|
|
17
|
+
name: {
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
app_id: {
|
|
21
|
+
type: string;
|
|
22
|
+
enum: string[];
|
|
23
|
+
};
|
|
24
|
+
environment: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
setup: {
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
account_name: {
|
|
31
|
+
type: string;
|
|
32
|
+
};
|
|
33
|
+
ready: {
|
|
34
|
+
type: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
required: string[];
|
|
38
|
+
};
|
|
39
|
+
additionalProperties: boolean;
|
|
40
|
+
};
|
|
41
|
+
export default class FlowVaultHandler extends DefaultHandler {
|
|
42
|
+
existing: Asset;
|
|
43
|
+
constructor(options: DefaultHandler);
|
|
44
|
+
getType(): Promise<Asset>;
|
|
45
|
+
processChanges(assets: Assets): Promise<void>;
|
|
46
|
+
getAllFlowConnections(): Promise<GetFlowsVaultConnections200ResponseOneOfInner[]>;
|
|
47
|
+
createVaultConnection(conn: any): Promise<Asset>;
|
|
48
|
+
createVaultConnections(creates: CalculatedChanges['create']): Promise<void>;
|
|
49
|
+
updateVaultConnection(conn: any): Promise<import("auth0").ApiResponse<import("auth0").PostFlowsVaultConnections201Response>>;
|
|
50
|
+
updateVaultConnections(updates: CalculatedChanges['update']): Promise<void>;
|
|
51
|
+
deleteVaultConnection(conn: any): Promise<void>;
|
|
52
|
+
deleteVaultConnections(data: Asset[]): Promise<void>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
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
|
+
exports.schema = void 0;
|
|
16
|
+
const lodash_1 = require("lodash");
|
|
17
|
+
const default_1 = __importDefault(require("./default"));
|
|
18
|
+
const constants_1 = __importDefault(require("../../constants"));
|
|
19
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
20
|
+
exports.schema = {
|
|
21
|
+
type: 'array',
|
|
22
|
+
items: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
name: { type: 'string' },
|
|
26
|
+
app_id: { type: 'string', enum: constants_1.default.CONNECTION_APP_ID },
|
|
27
|
+
environment: { type: 'string' },
|
|
28
|
+
setup: { type: 'object' },
|
|
29
|
+
account_name: { type: 'string' },
|
|
30
|
+
ready: { type: 'boolean' },
|
|
31
|
+
},
|
|
32
|
+
required: ['name', 'app_id'],
|
|
33
|
+
},
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
};
|
|
36
|
+
class FlowVaultHandler extends default_1.default {
|
|
37
|
+
constructor(options) {
|
|
38
|
+
super(Object.assign(Object.assign({}, options), { type: 'flowVaultConnections', id: 'id', stripCreateFields: ['created_at', 'updated_at', 'refreshed_at', 'fingerprint', 'ready'], stripUpdateFields: ['created_at', 'updated_at', 'refreshed_at', 'fingerprint', 'ready'] }));
|
|
39
|
+
}
|
|
40
|
+
getType() {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
if (this.existing) {
|
|
43
|
+
return this.existing;
|
|
44
|
+
}
|
|
45
|
+
this.existing = yield this.getAllFlowConnections();
|
|
46
|
+
return this.existing;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
processChanges(assets) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const { flowVaultConnections } = assets;
|
|
52
|
+
// Do nothing if not set
|
|
53
|
+
if (!flowVaultConnections)
|
|
54
|
+
return;
|
|
55
|
+
const { del, update, create } = yield this.calcChanges(assets);
|
|
56
|
+
logger_1.default.debug(`Start processChanges for flow vault connections [delete:${del.length}] [update:${update.length}], [create:${create.length}]`);
|
|
57
|
+
const changes = [{ del: del }, { create: create }, { update: update }];
|
|
58
|
+
yield Promise.all(changes.map((change) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
switch (true) {
|
|
60
|
+
case change.del && change.del.length > 0:
|
|
61
|
+
yield this.deleteVaultConnections(change.del || []);
|
|
62
|
+
break;
|
|
63
|
+
case change.create && change.create.length > 0:
|
|
64
|
+
yield this.createVaultConnections(change.create);
|
|
65
|
+
break;
|
|
66
|
+
case change.update && change.update.length > 0:
|
|
67
|
+
if (change.update)
|
|
68
|
+
yield this.updateVaultConnections(change.update);
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
})));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
getAllFlowConnections() {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const allFlowConnections = [];
|
|
79
|
+
// paginate without paginate<T> helper as this is not getAll but getAllConnections
|
|
80
|
+
// paginate through all flow connections
|
|
81
|
+
let page = 0;
|
|
82
|
+
while (true) {
|
|
83
|
+
const { data: { connections, total }, } = yield this.client.flows.getAllConnections({
|
|
84
|
+
page: page,
|
|
85
|
+
per_page: 100,
|
|
86
|
+
include_totals: true,
|
|
87
|
+
});
|
|
88
|
+
// if we get an unexpected response, break the loop to avoid infinite loop
|
|
89
|
+
if (!(0, lodash_1.isArray)(allFlowConnections) || typeof total !== 'number') {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
allFlowConnections.push(...connections);
|
|
93
|
+
page += 1;
|
|
94
|
+
if (allFlowConnections.length === total) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return allFlowConnections;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
createVaultConnection(conn) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
if ('ready' in conn) {
|
|
104
|
+
delete conn.ready;
|
|
105
|
+
}
|
|
106
|
+
const { data: created } = yield this.client.flows.createConnection(conn);
|
|
107
|
+
return created;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
createVaultConnections(creates) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
yield this.client.pool
|
|
113
|
+
.addEachTask({
|
|
114
|
+
data: creates || [],
|
|
115
|
+
generator: (item) => this.createVaultConnection(item)
|
|
116
|
+
.then((data) => {
|
|
117
|
+
this.didCreate(data);
|
|
118
|
+
this.created += 1;
|
|
119
|
+
})
|
|
120
|
+
.catch((err) => {
|
|
121
|
+
throw new Error(`Problem creating ${this.type} ${this.objString(item)}\n${err}`);
|
|
122
|
+
}),
|
|
123
|
+
})
|
|
124
|
+
.promise();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
updateVaultConnection(conn) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const { id, name, setup } = conn;
|
|
130
|
+
const params = {
|
|
131
|
+
name,
|
|
132
|
+
};
|
|
133
|
+
if (!(0, lodash_1.isEmpty)(setup)) {
|
|
134
|
+
params.setup = setup;
|
|
135
|
+
}
|
|
136
|
+
const updated = yield this.client.flows.updateConnection({ id: id }, params);
|
|
137
|
+
return updated;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
updateVaultConnections(updates) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
yield this.client.pool
|
|
143
|
+
.addEachTask({
|
|
144
|
+
data: updates || [],
|
|
145
|
+
generator: (item) => this.updateVaultConnection(item)
|
|
146
|
+
.then((data) => {
|
|
147
|
+
this.didUpdate(data);
|
|
148
|
+
this.updated += 1;
|
|
149
|
+
})
|
|
150
|
+
.catch((err) => {
|
|
151
|
+
throw new Error(`Problem updating ${this.type} ${this.objString(item)}\n${err}`);
|
|
152
|
+
}),
|
|
153
|
+
})
|
|
154
|
+
.promise();
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
deleteVaultConnection(conn) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
yield this.client.flows.deleteConnection({ id: conn.id });
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
deleteVaultConnections(data) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
if (this.config('AUTH0_ALLOW_DELETE') === 'true' ||
|
|
165
|
+
this.config('AUTH0_ALLOW_DELETE') === true) {
|
|
166
|
+
yield this.client.pool
|
|
167
|
+
.addEachTask({
|
|
168
|
+
data: data || [],
|
|
169
|
+
generator: (item) => this.deleteVaultConnection(item)
|
|
170
|
+
.then(() => {
|
|
171
|
+
this.didDelete(item);
|
|
172
|
+
this.deleted += 1;
|
|
173
|
+
})
|
|
174
|
+
.catch((err) => {
|
|
175
|
+
throw new Error(`Problem deleting ${this.type} ${this.objString(item)}\n${err}`);
|
|
176
|
+
}),
|
|
177
|
+
})
|
|
178
|
+
.promise();
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
logger_1.default.warn(`Detected the following flow vault connection should be deleted. Doing so may be destructive.\nYou can enable deletes by setting 'AUTH0_ALLOW_DELETE' to true in the config
|
|
182
|
+
\n${data.map((i) => this.objString(i)).join('\n')}`);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.default = FlowVaultHandler;
|
|
188
|
+
//# sourceMappingURL=flowVaultConnections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowVaultConnections.js","sourceRoot":"","sources":["../../../../src/tools/auth0/handlers/flowVaultConnections.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,mCAA0C;AAC1C,wDAAuC;AAEvC,gEAAwC;AACxC,6DAAkC;AAWrB,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAS,CA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EAAE,EAAE,CAAC,CAAC;QAC5D,CAAC;KAAA;IAEK,sBAAsB,CAAC,IAAa;;YACxC,IACE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,KAAK,MAAM;gBAC5C,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,KAAK,IAAI,EAC1C,CAAC;gBACD,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI;qBACnB,WAAW,CAAC;oBACX,IAAI,EAAE,IAAI,IAAI,EAAE;oBAChB,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAClB,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC;yBAC7B,IAAI,CAAC,GAAG,EAAE;wBACT,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;wBACrB,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;oBACpB,CAAC,CAAC;yBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;wBACb,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;oBACnF,CAAC,CAAC;iBACP,CAAC;qBACD,OAAO,EAAE,CAAC;YACf,CAAC;iBAAM,CAAC;gBACN,gBAAG,CAAC,IAAI,CAAC;UACL,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;KAAA;CACF;AAxKD,mCAwKC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GetFlowsVaultConnections200ResponseOneOfInner } from 'auth0';
|
|
2
|
+
import DefaultHandler from './default';
|
|
3
|
+
import { Asset, Assets } from '../../../types';
|
|
4
|
+
export type Flow = {
|
|
5
|
+
name: string;
|
|
6
|
+
body: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const schema: {
|
|
9
|
+
type: string;
|
|
10
|
+
items: {
|
|
11
|
+
type: string;
|
|
12
|
+
properties: {
|
|
13
|
+
name: {
|
|
14
|
+
type: string;
|
|
15
|
+
};
|
|
16
|
+
body: {
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
required: string[];
|
|
21
|
+
};
|
|
22
|
+
additionalProperties: boolean;
|
|
23
|
+
};
|
|
24
|
+
export default class FlowHandler extends DefaultHandler {
|
|
25
|
+
existing: Asset;
|
|
26
|
+
constructor(options: DefaultHandler);
|
|
27
|
+
getType(): Promise<Asset>;
|
|
28
|
+
processChanges(assets: Assets): Promise<void>;
|
|
29
|
+
getAllFlowConnections(): Promise<GetFlowsVaultConnections200ResponseOneOfInner[]>;
|
|
30
|
+
formateFlowConnectionId(flows: any, connectionIdMap: any): Promise<Asset>;
|
|
31
|
+
pargeFlowConnectionName(flows: any, connectionNameMap: any): Promise<Flow[]>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
exports.schema = void 0;
|
|
16
|
+
const lodash_1 = require("lodash");
|
|
17
|
+
const dot_prop_1 = __importDefault(require("dot-prop"));
|
|
18
|
+
const default_1 = __importDefault(require("./default"));
|
|
19
|
+
const client_1 = require("../client");
|
|
20
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
21
|
+
const utils_1 = require("../../../utils");
|
|
22
|
+
exports.schema = {
|
|
23
|
+
type: 'array',
|
|
24
|
+
items: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
properties: {
|
|
27
|
+
name: { type: 'string' },
|
|
28
|
+
body: { type: 'string' },
|
|
29
|
+
},
|
|
30
|
+
required: ['name'],
|
|
31
|
+
},
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
};
|
|
34
|
+
class FlowHandler extends default_1.default {
|
|
35
|
+
constructor(options) {
|
|
36
|
+
super(Object.assign(Object.assign({}, options), { type: 'flows', id: 'id' }));
|
|
37
|
+
}
|
|
38
|
+
getType() {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (this.existing) {
|
|
41
|
+
return this.existing;
|
|
42
|
+
}
|
|
43
|
+
const [flows, allFlowConnections] = yield Promise.all([
|
|
44
|
+
(0, client_1.paginate)(this.client.flows.getAll, {
|
|
45
|
+
paginate: true,
|
|
46
|
+
include_totals: true,
|
|
47
|
+
}),
|
|
48
|
+
this.getAllFlowConnections(),
|
|
49
|
+
]);
|
|
50
|
+
const allFlows = yield Promise.all(flows.map((f) => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const { data: flow } = yield this.client.flows.get({ id: f.id });
|
|
52
|
+
return flow;
|
|
53
|
+
})));
|
|
54
|
+
// create a map for id to name from allFlowConnections
|
|
55
|
+
const connectionIdMap = {};
|
|
56
|
+
allFlowConnections.forEach((c) => {
|
|
57
|
+
connectionIdMap[c.id] = c.name;
|
|
58
|
+
});
|
|
59
|
+
this.existing = yield this.formateFlowConnectionId(allFlows, connectionIdMap);
|
|
60
|
+
return this.existing;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
processChanges(assets) {
|
|
64
|
+
const _super = Object.create(null, {
|
|
65
|
+
processChanges: { get: () => super.processChanges }
|
|
66
|
+
});
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const { flows } = assets;
|
|
69
|
+
// Do nothing if not set
|
|
70
|
+
if (!flows)
|
|
71
|
+
return;
|
|
72
|
+
const allFlowConnections = yield this.getAllFlowConnections();
|
|
73
|
+
// create a map for name to id from allFlowConnections
|
|
74
|
+
const connectionNameMap = {};
|
|
75
|
+
allFlowConnections.forEach((c) => {
|
|
76
|
+
connectionNameMap[c.name] = c.id;
|
|
77
|
+
});
|
|
78
|
+
assets.flows = yield this.pargeFlowConnectionName(flows, connectionNameMap);
|
|
79
|
+
const { del, update, create, conflicts } = yield this.calcChanges(assets);
|
|
80
|
+
const changes = {
|
|
81
|
+
del: del,
|
|
82
|
+
update: update,
|
|
83
|
+
create: create,
|
|
84
|
+
conflicts: conflicts,
|
|
85
|
+
};
|
|
86
|
+
yield _super.processChanges.call(this, assets, Object.assign({}, changes));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
getAllFlowConnections() {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const allFlowConnections = [];
|
|
92
|
+
// paginate without paginate<T> helper as this is not getAll but getAllConnections
|
|
93
|
+
// paginate through all flow connections
|
|
94
|
+
let page = 0;
|
|
95
|
+
while (true) {
|
|
96
|
+
const { data: { connections, total }, } = yield this.client.flows.getAllConnections({
|
|
97
|
+
page: page,
|
|
98
|
+
per_page: 100,
|
|
99
|
+
include_totals: true,
|
|
100
|
+
});
|
|
101
|
+
// if we get an unexpected response, break the loop to avoid infinite loop
|
|
102
|
+
if (!(0, lodash_1.isArray)(allFlowConnections) || typeof total !== 'number') {
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
allFlowConnections.push(...connections);
|
|
106
|
+
page += 1;
|
|
107
|
+
if (allFlowConnections.length === total) {
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return allFlowConnections;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
formateFlowConnectionId(flows, connectionIdMap) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
// replace connection_id with flow connection names
|
|
117
|
+
yield Promise.all(flows.map((flow) => __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const flowConnetions = (0, utils_1.findKeyPathWithValue)(flow, 'connection_id');
|
|
119
|
+
yield Promise.all(flowConnetions.map((f) => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const connectionId = (dot_prop_1.default.get(flow, f.path) || '');
|
|
121
|
+
const flowConnectionName = connectionIdMap[connectionId];
|
|
122
|
+
if (!flowConnectionName) {
|
|
123
|
+
logger_1.default.warn(`Flow connection: ${connectionId} not found for flow:${flow.name}, please verify the flow connection id.`);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
dot_prop_1.default.set(flow, f.path, flowConnectionName);
|
|
127
|
+
}
|
|
128
|
+
})));
|
|
129
|
+
return flow;
|
|
130
|
+
})));
|
|
131
|
+
return flows;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
pargeFlowConnectionName(flows, connectionNameMap) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
// replace connection_id with flow connection names
|
|
137
|
+
const parsedFlows = yield Promise.all(flows.map((flow) => __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
const flowConnetions = (0, utils_1.findKeyPathWithValue)(flow, 'connection_id');
|
|
139
|
+
yield Promise.all(flowConnetions.map((f) => __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
const connectionName = (dot_prop_1.default.get(flow, f.path) || '');
|
|
141
|
+
const flowConnectionId = connectionNameMap[connectionName];
|
|
142
|
+
if (!flowConnectionId) {
|
|
143
|
+
logger_1.default.error(`Flow connection: ${flowConnectionId} not found for flow:${flow.name}, please verify the flow connection name.`);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
dot_prop_1.default.set(flow, f.path, flowConnectionId);
|
|
147
|
+
}
|
|
148
|
+
})));
|
|
149
|
+
return flow;
|
|
150
|
+
})));
|
|
151
|
+
return parsedFlows;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.default = FlowHandler;
|
|
156
|
+
//# sourceMappingURL=flows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flows.js","sourceRoot":"","sources":["../../../../src/tools/auth0/handlers/flows.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAoC;AAKpC,wDAA+B;AAC/B,wDAAkD;AAElD,sCAAqC;AACrC,6DAAkC;AAClC,0CAAsD;AAOzC,QAAA,MAAM,GAAG;IACpB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SACzB;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;KACnB;IACD,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAEF,MAAqB,WAAY,SAAQ,iBAAc;IAGrD,YAAY,OAAuB;QACjC,KAAK,iCACA,OAAO,KACV,IAAI,EAAE,OAAO,EACb,EAAE,EAAE,IAAI,IACR,CAAC;IACL,CAAC;IAEK,OAAO;;YACX,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,OAAO,IAAI,CAAC,QAAQ,CAAC;YACvB,CAAC;YAED,MAAM,CAAC,KAAK,EAAE,kBAAkB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;gBACpD,IAAA,iBAAQ,EAAgC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE;oBAChE,QAAQ,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AAiB,CAAC,cAAc,CAAC,CAAC;oBAC3D,IAAI,CAAC,gBAAgB,EAAE,CAAC;wBACtB,gBAAG,CAAC,KAAK,CACP,oBAAoB,gBAAgB,uBAAuB,IAAI,CAAC,IAAI,2CAA2C,CAChH,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,kBAAO,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;oBAC9C,CAAC;gBACH,CAAC,CAAA,CAAC,CACH,CAAC;gBACF,OAAO,IAAI,CAAC;YACd,CAAC,CAAA,CAAC,CACH,CAAC;YAEF,OAAO,WAAW,CAAC;QACrB,CAAC;KAAA;CACF;AAtJD,8BAsJC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PostForms201Response } from 'auth0';
|
|
2
|
+
import DefaultHandler from './default';
|
|
3
|
+
import { Asset, Assets } from '../../../types';
|
|
4
|
+
export type Form = {
|
|
5
|
+
name: string;
|
|
6
|
+
body: string;
|
|
7
|
+
};
|
|
8
|
+
export type FormResponse = PostForms201Response;
|
|
9
|
+
export declare const schema: {
|
|
10
|
+
type: string;
|
|
11
|
+
items: {
|
|
12
|
+
type: string;
|
|
13
|
+
properties: {
|
|
14
|
+
name: {
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
body: {
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
required: string[];
|
|
22
|
+
};
|
|
23
|
+
additionalProperties: boolean;
|
|
24
|
+
};
|
|
25
|
+
export default class FormsHandler extends DefaultHandler {
|
|
26
|
+
existing: Asset;
|
|
27
|
+
constructor(options: DefaultHandler);
|
|
28
|
+
getType(): Promise<Asset>;
|
|
29
|
+
formateFormFlowId(forms: any, flowIdMap: any): Promise<Asset>;
|
|
30
|
+
pargeFormFlowName(forms: any, flowNameMap: any): Promise<Form[]>;
|
|
31
|
+
processChanges(assets: Assets): Promise<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
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
|
+
exports.schema = void 0;
|
|
16
|
+
const dot_prop_1 = __importDefault(require("dot-prop"));
|
|
17
|
+
const default_1 = __importDefault(require("./default"));
|
|
18
|
+
const logger_1 = __importDefault(require("../../../logger"));
|
|
19
|
+
const client_1 = require("../client");
|
|
20
|
+
const utils_1 = require("../../../utils");
|
|
21
|
+
exports.schema = {
|
|
22
|
+
type: 'array',
|
|
23
|
+
items: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
name: { type: 'string' },
|
|
27
|
+
body: { type: 'string' },
|
|
28
|
+
},
|
|
29
|
+
required: ['name'],
|
|
30
|
+
},
|
|
31
|
+
additionalProperties: false,
|
|
32
|
+
};
|
|
33
|
+
class FormsHandler extends default_1.default {
|
|
34
|
+
constructor(options) {
|
|
35
|
+
super(Object.assign(Object.assign({}, options), { type: 'forms', id: 'id', stripCreateFields: ['created_at', 'updated_at', 'submitted_at', 'embedded_at'], stripUpdateFields: ['created_at', 'updated_at', 'submitted_at', 'embedded_at'] }));
|
|
36
|
+
}
|
|
37
|
+
getType() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
if (this.existing) {
|
|
40
|
+
return this.existing;
|
|
41
|
+
}
|
|
42
|
+
const [forms, flows] = yield Promise.all([
|
|
43
|
+
(0, client_1.paginate)(this.client.forms.getAll, {
|
|
44
|
+
paginate: true,
|
|
45
|
+
include_totals: true,
|
|
46
|
+
}),
|
|
47
|
+
(0, client_1.paginate)(this.client.flows.getAll, {
|
|
48
|
+
paginate: true,
|
|
49
|
+
include_totals: true,
|
|
50
|
+
}),
|
|
51
|
+
]);
|
|
52
|
+
// get more details for each form
|
|
53
|
+
const allForms = yield Promise.all(forms.map((from) => __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const { data: form } = yield this.client.forms.get({ id: from.id });
|
|
55
|
+
return form;
|
|
56
|
+
})));
|
|
57
|
+
// create a map for id to name from allFlows
|
|
58
|
+
const flowIdMap = {};
|
|
59
|
+
flows.forEach((f) => {
|
|
60
|
+
flowIdMap[f.id] = f.name;
|
|
61
|
+
});
|
|
62
|
+
this.existing = yield this.formateFormFlowId(allForms, flowIdMap);
|
|
63
|
+
return this.existing;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
formateFormFlowId(forms, flowIdMap) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
// replace flow_id with flow names
|
|
69
|
+
yield Promise.all(forms.map((form) => __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const flows = (0, utils_1.findKeyPathWithValue)(form, 'flow_id');
|
|
71
|
+
yield Promise.all(flows.map((f) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const flowId = (dot_prop_1.default.get(form, f.path) || '');
|
|
73
|
+
const flowName = flowIdMap[flowId];
|
|
74
|
+
if (!flowName) {
|
|
75
|
+
logger_1.default.warn(`Flow: ${flowId} not found for form:${form.name}, please verify the flow id.`);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
dot_prop_1.default.set(form, f.path, flowName);
|
|
79
|
+
}
|
|
80
|
+
})));
|
|
81
|
+
return form;
|
|
82
|
+
})));
|
|
83
|
+
return forms;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
pargeFormFlowName(forms, flowNameMap) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
// replace flow names with flow_id
|
|
89
|
+
yield Promise.all(forms.map((form) => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const flows = (0, utils_1.findKeyPathWithValue)(form, 'flow_id');
|
|
91
|
+
yield Promise.all(flows.map((f) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const flowName = (dot_prop_1.default.get(form, f.path) || '');
|
|
93
|
+
const flowId = flowNameMap[flowName];
|
|
94
|
+
if (!flowId) {
|
|
95
|
+
logger_1.default.error(`Flow: ${flowName} not found for form:${form.name}, please verify the flow name.`);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
dot_prop_1.default.set(form, f.path, flowNameMap[flowName]);
|
|
99
|
+
}
|
|
100
|
+
})));
|
|
101
|
+
return form;
|
|
102
|
+
})));
|
|
103
|
+
return forms;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
processChanges(assets) {
|
|
107
|
+
const _super = Object.create(null, {
|
|
108
|
+
processChanges: { get: () => super.processChanges }
|
|
109
|
+
});
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const { forms } = assets;
|
|
112
|
+
// Do nothing if not set
|
|
113
|
+
if (!forms)
|
|
114
|
+
return;
|
|
115
|
+
const flows = yield (0, client_1.paginate)(this.client.flows.getAll, {
|
|
116
|
+
paginate: true,
|
|
117
|
+
include_totals: true,
|
|
118
|
+
});
|
|
119
|
+
// create a map for id to name from flows
|
|
120
|
+
const flowNamMap = {};
|
|
121
|
+
flows.forEach((f) => {
|
|
122
|
+
flowNamMap[f.name] = f.id;
|
|
123
|
+
});
|
|
124
|
+
assets.forms = yield this.pargeFormFlowName(forms, flowNamMap);
|
|
125
|
+
const { del, update, create, conflicts } = yield this.calcChanges(assets);
|
|
126
|
+
const changes = {
|
|
127
|
+
del: del,
|
|
128
|
+
update: update,
|
|
129
|
+
create: create,
|
|
130
|
+
conflicts: conflicts,
|
|
131
|
+
};
|
|
132
|
+
yield _super.processChanges.call(this, assets, Object.assign({}, changes));
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.default = FormsHandler;
|
|
137
|
+
//# sourceMappingURL=forms.js.map
|