@rockcarver/frodo-lib 0.17.3 → 0.17.4
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/CHANGELOG.md +5 -1
- package/cjs/api/Saml2Api.js +36 -14
- package/cjs/api/Saml2Api.js.map +1 -1
- package/cjs/api/ScriptApi.js +23 -2
- package/cjs/api/ScriptApi.js.map +1 -1
- package/cjs/ops/IdpOps.js +3 -3
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/JourneyOps.js +49 -35
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/JourneyOps.test.js.map +1 -1
- package/cjs/ops/OpsTypes.js.map +1 -1
- package/cjs/ops/Saml2Ops.js +104 -57
- package/cjs/ops/Saml2Ops.js.map +1 -1
- package/cjs/ops/Saml2Ops.test.js.map +1 -1
- package/cjs/ops/ScriptOps.js +193 -186
- package/cjs/ops/ScriptOps.js.map +1 -1
- package/cjs/ops/ScriptOps.test.js.map +1 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +5 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney1.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney2.journey.json +76 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney3.journey.json +873 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney4.journey.json +930 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney5.journey.json +873 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney6.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney7.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney8.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney9.journey.json +148 -0
- package/esm/api/Saml2Api.mjs +17 -1
- package/esm/api/ScriptApi.mjs +17 -2
- package/esm/ops/IdpOps.mjs +4 -4
- package/esm/ops/JourneyOps.mjs +30 -21
- package/esm/ops/JourneyOps.test.mjs +220 -246
- package/esm/ops/Saml2Ops.mjs +66 -31
- package/esm/ops/Saml2Ops.test.mjs +399 -333
- package/esm/ops/ScriptOps.mjs +148 -152
- package/esm/ops/ScriptOps.test.mjs +282 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.mjs +4 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney1.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney2.journey.json +76 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney3.journey.json +873 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney4.journey.json +930 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney5.journey.json +873 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney6.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney7.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney8.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney9.journey.json +148 -0
- package/package.json +10 -2
- package/types/api/Saml2Api.d.ts +8 -1
- package/types/api/Saml2Api.d.ts.map +1 -1
- package/types/api/ScriptApi.d.ts +7 -1
- package/types/api/ScriptApi.d.ts.map +1 -1
- package/types/ops/IdpOps.d.ts.map +1 -1
- package/types/ops/JourneyOps.d.ts +17 -3
- package/types/ops/JourneyOps.d.ts.map +1 -1
- package/types/ops/OpsTypes.d.ts +1 -1
- package/types/ops/OpsTypes.d.ts.map +1 -1
- package/types/ops/Saml2Ops.d.ts +24 -12
- package/types/ops/Saml2Ops.d.ts.map +1 -1
- package/types/ops/ScriptOps.d.ts +56 -20
- package/types/ops/ScriptOps.d.ts.map +1 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +1 -0
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.17.4] - 2023-01-05
|
|
11
|
+
|
|
10
12
|
## [0.17.3] - 2022-12-30
|
|
11
13
|
|
|
12
14
|
## [0.17.2] - 2022-12-26
|
|
@@ -901,7 +903,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
901
903
|
- Fixed problem with adding connection profiles
|
|
902
904
|
- Miscellaneous bug fixes
|
|
903
905
|
|
|
904
|
-
[Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.17.
|
|
906
|
+
[Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.17.4...HEAD
|
|
907
|
+
|
|
908
|
+
[0.17.4]: https://github.com/rockcarver/frodo-lib/compare/v0.17.3...v0.17.4
|
|
905
909
|
|
|
906
910
|
[0.17.3]: https://github.com/rockcarver/frodo-lib/compare/v0.17.2...v0.17.3
|
|
907
911
|
|
package/cjs/api/Saml2Api.js
CHANGED
|
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createProvider = createProvider;
|
|
7
|
-
exports.
|
|
7
|
+
exports.deleteProviderByLocationAndId = deleteProviderByLocationAndId;
|
|
8
|
+
exports.deleteRawProvider = deleteRawProvider;
|
|
8
9
|
exports.findProviders = findProviders;
|
|
9
10
|
exports.getProviderByLocationAndId = getProviderByLocationAndId;
|
|
10
11
|
exports.getProviderMetadata = getProviderMetadata;
|
|
@@ -93,9 +94,10 @@ function getProviderByLocationAndId(_x, _x2) {
|
|
|
93
94
|
return _getProviderByLocationAndId.apply(this, arguments);
|
|
94
95
|
}
|
|
95
96
|
/**
|
|
96
|
-
*
|
|
97
|
-
* @param {string}
|
|
98
|
-
* @
|
|
97
|
+
* Geta SAML2 entity provider by location and id
|
|
98
|
+
* @param {string} location Entity provider location (hosted or remote)
|
|
99
|
+
* @param {string} entityId64 Base64-encoded provider entity id
|
|
100
|
+
* @returns {Promise} a promise that resolves to a saml2 entity provider object
|
|
99
101
|
*/
|
|
100
102
|
function _getProviderByLocationAndId() {
|
|
101
103
|
_getProviderByLocationAndId = _asyncToGenerator(function* (location, entityId64) {
|
|
@@ -109,6 +111,26 @@ function _getProviderByLocationAndId() {
|
|
|
109
111
|
});
|
|
110
112
|
return _getProviderByLocationAndId.apply(this, arguments);
|
|
111
113
|
}
|
|
114
|
+
function deleteProviderByLocationAndId(_x3, _x4) {
|
|
115
|
+
return _deleteProviderByLocationAndId.apply(this, arguments);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get a SAML2 entity provider's metadata URL by entity id
|
|
119
|
+
* @param {string} entityId SAML2 entity id
|
|
120
|
+
* @returns {string} the URL to get the metadata from
|
|
121
|
+
*/
|
|
122
|
+
function _deleteProviderByLocationAndId() {
|
|
123
|
+
_deleteProviderByLocationAndId = _asyncToGenerator(function* (location, entityId64) {
|
|
124
|
+
var urlString = _util.default.format(providerByLocationAndIdURLTemplate, state.getHost(), (0, _ApiUtils.getCurrentRealmPath)(), location, entityId64);
|
|
125
|
+
var {
|
|
126
|
+
data
|
|
127
|
+
} = yield (0, _BaseApi.generateAmApi)(getApiConfig()).delete(urlString, {
|
|
128
|
+
withCredentials: true
|
|
129
|
+
});
|
|
130
|
+
return data;
|
|
131
|
+
});
|
|
132
|
+
return _deleteProviderByLocationAndId.apply(this, arguments);
|
|
133
|
+
}
|
|
112
134
|
function getProviderMetadataUrl(entityId) {
|
|
113
135
|
return _util.default.format(metadataByEntityIdURLTemplate, state.getHost(), encodeURIComponent(entityId), state.getRealm());
|
|
114
136
|
}
|
|
@@ -118,7 +140,7 @@ function getProviderMetadataUrl(entityId) {
|
|
|
118
140
|
* @param {String} entityId SAML2 entity id
|
|
119
141
|
* @returns {Promise} a promise that resolves to an object containing a SAML2 metadata
|
|
120
142
|
*/
|
|
121
|
-
function getProviderMetadata(
|
|
143
|
+
function getProviderMetadata(_x5) {
|
|
122
144
|
return _getProviderMetadata.apply(this, arguments);
|
|
123
145
|
}
|
|
124
146
|
/**
|
|
@@ -139,7 +161,7 @@ function _getProviderMetadata() {
|
|
|
139
161
|
});
|
|
140
162
|
return _getProviderMetadata.apply(this, arguments);
|
|
141
163
|
}
|
|
142
|
-
function createProvider(
|
|
164
|
+
function createProvider(_x6, _x7, _x8) {
|
|
143
165
|
return _createProvider.apply(this, arguments);
|
|
144
166
|
}
|
|
145
167
|
/**
|
|
@@ -170,7 +192,7 @@ function _createProvider() {
|
|
|
170
192
|
});
|
|
171
193
|
return _createProvider.apply(this, arguments);
|
|
172
194
|
}
|
|
173
|
-
function updateProvider(
|
|
195
|
+
function updateProvider(_x9, _x10) {
|
|
174
196
|
return _updateProvider.apply(this, arguments);
|
|
175
197
|
} // Contributions using legacy APIs. Need to investigate if those will be deprecated in the future
|
|
176
198
|
/**
|
|
@@ -190,15 +212,15 @@ function _updateProvider() {
|
|
|
190
212
|
});
|
|
191
213
|
return _updateProvider.apply(this, arguments);
|
|
192
214
|
}
|
|
193
|
-
function
|
|
194
|
-
return
|
|
215
|
+
function deleteRawProvider(_x11) {
|
|
216
|
+
return _deleteRawProvider.apply(this, arguments);
|
|
195
217
|
}
|
|
196
218
|
/**
|
|
197
219
|
* Retrieves all entity providers using the legacy federation enpoints.
|
|
198
220
|
* @returns {Promise} a promise that resolves to an object containing an array of providers
|
|
199
221
|
*/
|
|
200
|
-
function
|
|
201
|
-
|
|
222
|
+
function _deleteRawProvider() {
|
|
223
|
+
_deleteRawProvider = _asyncToGenerator(function* (entityId) {
|
|
202
224
|
var urlString = _util.default.format(samlApplicationByEntityIdURLTemplate, state.getHost(), (0, _ApiUtils.getCurrentRealmPath)(), entityId);
|
|
203
225
|
var {
|
|
204
226
|
data
|
|
@@ -207,7 +229,7 @@ function _deleteProvider() {
|
|
|
207
229
|
});
|
|
208
230
|
return data;
|
|
209
231
|
});
|
|
210
|
-
return
|
|
232
|
+
return _deleteRawProvider.apply(this, arguments);
|
|
211
233
|
}
|
|
212
234
|
function getRawProviders() {
|
|
213
235
|
return _getRawProviders.apply(this, arguments);
|
|
@@ -229,7 +251,7 @@ function _getRawProviders() {
|
|
|
229
251
|
});
|
|
230
252
|
return _getRawProviders.apply(this, arguments);
|
|
231
253
|
}
|
|
232
|
-
function getRawProvider(
|
|
254
|
+
function getRawProvider(_x12) {
|
|
233
255
|
return _getRawProvider.apply(this, arguments);
|
|
234
256
|
}
|
|
235
257
|
/**
|
|
@@ -250,7 +272,7 @@ function _getRawProvider() {
|
|
|
250
272
|
});
|
|
251
273
|
return _getRawProvider.apply(this, arguments);
|
|
252
274
|
}
|
|
253
|
-
function putRawProvider(
|
|
275
|
+
function putRawProvider(_x13, _x14) {
|
|
254
276
|
return _putRawProvider.apply(this, arguments);
|
|
255
277
|
}
|
|
256
278
|
function _putRawProvider() {
|
package/cjs/api/Saml2Api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Saml2Api.js","names":["providerByLocationAndIdURLTemplate","createHostedProviderURLTemplate","createRemoteProviderURLTemplate","queryAllProvidersURLTemplate","queryProvidersByEntityIdURLTemplate","metadataByEntityIdURLTemplate","samlApplicationQueryURLTemplateRaw","samlApplicationByEntityIdURLTemplate","apiVersion","getApiConfig","configPath","getCurrentRealmPath","path","getProviders","urlString","util","format","state","getHost","data","generateAmApi","get","withCredentials","findProviders","filter","fields","encodeURIComponent","join","getProviderByLocationAndId","location","entityId64","getProviderMetadataUrl","entityId","getRealm","getProviderMetadata","createProvider","providerData","metaData","postData","_","cloneDeep","standardMetadata","post","updateProvider","_id","put","deleteProvider","delete","getRawProviders","getRawProvider","putRawProvider","entityData"],"sources":["api/Saml2Api.ts"],"sourcesContent":["import _ from 'lodash';\nimport util from 'util';\nimport * as state from '../shared/State';\nimport { generateAmApi } from './BaseApi';\nimport { getCurrentRealmPath } from './utils/ApiUtils';\n\nconst providerByLocationAndIdURLTemplate = '%s/json%s/realm-config/saml2/%s/%s';\nconst createHostedProviderURLTemplate =\n '%s/json%s/realm-config/saml2/hosted/?_action=create';\nconst createRemoteProviderURLTemplate =\n '%s/json%s/realm-config/saml2/remote/?_action=importEntity';\nconst queryAllProvidersURLTemplate =\n '%s/json%s/realm-config/saml2?_queryFilter=true';\nconst queryProvidersByEntityIdURLTemplate =\n '%s/json%s/realm-config/saml2?_queryFilter=%s&_fields=%s';\nconst metadataByEntityIdURLTemplate =\n '%s/saml2/jsp/exportmetadata.jsp?entityid=%s&realm=%s';\nconst samlApplicationQueryURLTemplateRaw =\n '%s/json%s/realm-config/federation/entityproviders/saml2?_queryFilter=true';\nconst samlApplicationByEntityIdURLTemplate =\n '%s/json%s/realm-config/federation/entityproviders/saml2/%s';\nconst apiVersion = 'protocol=2.1,resource=1.0';\nconst getApiConfig = () => {\n const configPath = getCurrentRealmPath();\n return {\n path: `${configPath}/realm-config/saml2`,\n apiVersion,\n };\n};\n\n/**\n * Get all SAML2 entity providers\n * @returns {Promise} a promise that resolves to an array of saml2 entity stubs\n */\nexport async function getProviders() {\n const urlString = util.format(\n queryAllProvidersURLTemplate,\n state.getHost(),\n getCurrentRealmPath()\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Find all providers matching the filter and return the requested fields\n * @param {string} filter CREST filter string, eg \"entityId+eq+'${entityId}'\" or \"true\" for all providers\n * @param {string[]} fields array of field names to include in the response\n * @returns {Promise} a promise that resolves to an object containing an array of saml2 entities\n */\nexport async function findProviders(filter = 'true', fields = ['*']) {\n const urlString = util.format(\n queryProvidersByEntityIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n encodeURIComponent(filter),\n fields.join(',')\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Geta SAML2 entity provider by location and id\n * @param {string} location Entity provider location (hosted or remote)\n * @param {string} entityId64 Base64-encoded provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function getProviderByLocationAndId(\n location: string,\n entityId64: string\n) {\n const urlString = util.format(\n providerByLocationAndIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n location,\n entityId64\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get a SAML2 entity provider's metadata URL by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {string} the URL to get the metadata from\n */\nexport function getProviderMetadataUrl(entityId: string): string {\n return util.format(\n metadataByEntityIdURLTemplate,\n state.getHost(),\n encodeURIComponent(entityId),\n state.getRealm()\n );\n}\n\n/**\n * Get a SAML2 entity provider's metadata by entity id\n * @param {String} entityId SAML2 entity id\n * @returns {Promise} a promise that resolves to an object containing a SAML2 metadata\n */\nexport async function getProviderMetadata(entityId) {\n const { data } = await generateAmApi(getApiConfig()).get(\n getProviderMetadataUrl(entityId),\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Create a SAML2 entity provider\n * @param {String} location 'hosted' or 'remote'\n * @param {Object} providerData Object representing a SAML entity provider\n * @param {String} metaData Base64-encoded metadata XML. Only required for remote providers\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function createProvider(location, providerData, metaData) {\n let postData = _.cloneDeep(providerData);\n let urlString = util.format(\n createHostedProviderURLTemplate,\n state.getHost(),\n getCurrentRealmPath()\n );\n\n if (location === 'remote') {\n /**\n * Remote entity providers must be created using XML metadata\n */\n urlString = util.format(\n createRemoteProviderURLTemplate,\n state.getHost(),\n getCurrentRealmPath()\n );\n postData = {\n standardMetadata: metaData,\n };\n }\n\n const { data } = await generateAmApi(getApiConfig()).post(\n urlString,\n postData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Update SAML2 entity provider\n * @param {String} location Entity provider location (hosted or remote)\n * @param {Object} providerData Object representing a SAML entity provider\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function updateProvider(location, providerData) {\n const urlString = util.format(\n providerByLocationAndIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n location,\n providerData._id\n );\n const { data } = await generateAmApi(getApiConfig()).put(\n urlString,\n providerData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n// Contributions using legacy APIs. Need to investigate if those will be deprecated in the future\n\n/**\n * Deletes a SAML2 entity provider by entity id\n * @param {string} entityId Provider entity id\n * @returns {Promise} a promise that resolves to a provider object\n */\nexport async function deleteProvider(entityId) {\n const urlString = util.format(\n samlApplicationByEntityIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n entityId\n );\n const { data } = await generateAmApi(getApiConfig()).delete(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawProviders() {\n const urlString = util.format(\n samlApplicationQueryURLTemplateRaw,\n state.getHost(),\n getCurrentRealmPath()\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Gets the data for an entity provider including the raw XML.\n * @param {string} entityId The entity provider id\n * @returns Promise that when resolved includes the configuration and raw xml for a SAML entity provider\n */\nexport async function getRawProvider(entityId: string) {\n const urlString = util.format(\n samlApplicationByEntityIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n encodeURIComponent(entityId)\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Stores a new SAML2 entity provider\n * @param {string} entityId The entity provider id\n * @param {string} entityData The actual data containing the entity provider configuration\n * @returns {Promise} Promise that resolves to a provider object\n */\nexport async function putRawProvider(entityId: string, entityData) {\n const urlString = util.format(\n samlApplicationByEntityIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n encodeURIComponent(entityId)\n );\n const { data } = await generateAmApi(getApiConfig()).put(\n urlString,\n entityData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAAuD;AAAA;AAAA;AAAA;AAAA;AAEvD,IAAMA,kCAAkC,GAAG,oCAAoC;AAC/E,IAAMC,+BAA+B,GACnC,qDAAqD;AACvD,IAAMC,+BAA+B,GACnC,2DAA2D;AAC7D,IAAMC,4BAA4B,GAChC,gDAAgD;AAClD,IAAMC,mCAAmC,GACvC,yDAAyD;AAC3D,IAAMC,6BAA6B,GACjC,sDAAsD;AACxD,IAAMC,kCAAkC,GACtC,2EAA2E;AAC7E,IAAMC,oCAAoC,GACxC,4DAA4D;AAC9D,IAAMC,UAAU,GAAG,2BAA2B;AAC9C,IAAMC,YAAY,GAAG,MAAM;EACzB,IAAMC,UAAU,GAAG,IAAAC,6BAAmB,GAAE;EACxC,OAAO;IACLC,IAAI,YAAKF,UAAU,wBAAqB;IACxCF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AAHA,SAIsBK,YAAY;EAAA;AAAA;AAYlC;AACA;AACA;AACA;AACA;AACA;AALA;EAAA,kCAZO,aAA8B;IACnC,IAAMC,SAAS,GAAGC,aAAI,CAACC,MAAM,CAC3Bb,4BAA4B,EAC5Bc,KAAK,CAACC,OAAO,EAAE,EACf,IAAAP,6BAAmB,GAAE,CACtB;IACD,IAAM;MAAEQ;IAAK,CAAC,SAAS,IAAAC,sBAAa,EAACX,YAAY,EAAE,CAAC,CAACY,GAAG,CAACP,SAAS,EAAE;MAClEQ,eAAe,EAAE;IACnB,CAAC,CAAC;IACF,OAAOH,IAAI;EACb,CAAC;EAAA;AAAA;AAAA,SAQqBI,aAAa;EAAA;AAAA;AAcnC;AACA;AACA;AACA;AACA;AACA;AALA;EAAA,mCAdO,aA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C3BT,oCAAoC,EACpCU,KAAK,CAACC,OAAO,EAAE,EACf,IAAAP,6BAAmB,GAAE,EACrBe,kBAAkB,CAACM,QAAQ,CAAC,CAC7B;IACD,IAAM;MAAEb;IAAK,CAAC,SAAS,IAAAC,sBAAa,EAACX,YAAY,EAAE,CAAC,CAACY,GAAG,CAACP,SAAS,EAAE;MAClEQ,eAAe,EAAE;IACnB,CAAC,CAAC;IACF,OAAOH,IAAI;EACb,CAAC;EAAA;AAAA;AAAA,SAQqB+B,cAAc;EAAA;AAAA;AAAA;EAAA,oCAA7B,WAA8BlB,QAAgB,EAAEmB,UAAU,EAAE;IACjE,IAAMrC,SAAS,GAAGC,aAAI,CAACC,MAAM,CAC3BT,oCAAoC,EACpCU,KAAK,CAACC,OAAO,EAAE,EACf,IAAAP,6BAAmB,GAAE,EACrBe,kBAAkB,CAACM,QAAQ,CAAC,CAC7B;IACD,IAAM;MAAEb;IAAK,CAAC,SAAS,IAAAC,sBAAa,EAACX,YAAY,EAAE,CAAC,CAACoC,GAAG,CACtD/B,SAAS,EACTqC,UAAU,EACV;MACE7B,eAAe,EAAE;IACnB,CAAC,CACF;IACD,OAAOH,IAAI;EACb,CAAC;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"Saml2Api.js","names":["providerByLocationAndIdURLTemplate","createHostedProviderURLTemplate","createRemoteProviderURLTemplate","queryAllProvidersURLTemplate","queryProvidersByEntityIdURLTemplate","metadataByEntityIdURLTemplate","samlApplicationQueryURLTemplateRaw","samlApplicationByEntityIdURLTemplate","apiVersion","getApiConfig","configPath","getCurrentRealmPath","path","getProviders","urlString","util","format","state","getHost","data","generateAmApi","get","withCredentials","findProviders","filter","fields","encodeURIComponent","join","getProviderByLocationAndId","location","entityId64","deleteProviderByLocationAndId","delete","getProviderMetadataUrl","entityId","getRealm","getProviderMetadata","createProvider","providerData","metaData","postData","_","cloneDeep","standardMetadata","post","updateProvider","_id","put","deleteRawProvider","getRawProviders","getRawProvider","putRawProvider","entityData"],"sources":["api/Saml2Api.ts"],"sourcesContent":["import _ from 'lodash';\nimport util from 'util';\nimport * as state from '../shared/State';\nimport { generateAmApi } from './BaseApi';\nimport { getCurrentRealmPath } from './utils/ApiUtils';\n\nconst providerByLocationAndIdURLTemplate = '%s/json%s/realm-config/saml2/%s/%s';\nconst createHostedProviderURLTemplate =\n '%s/json%s/realm-config/saml2/hosted/?_action=create';\nconst createRemoteProviderURLTemplate =\n '%s/json%s/realm-config/saml2/remote/?_action=importEntity';\nconst queryAllProvidersURLTemplate =\n '%s/json%s/realm-config/saml2?_queryFilter=true';\nconst queryProvidersByEntityIdURLTemplate =\n '%s/json%s/realm-config/saml2?_queryFilter=%s&_fields=%s';\nconst metadataByEntityIdURLTemplate =\n '%s/saml2/jsp/exportmetadata.jsp?entityid=%s&realm=%s';\nconst samlApplicationQueryURLTemplateRaw =\n '%s/json%s/realm-config/federation/entityproviders/saml2?_queryFilter=true';\nconst samlApplicationByEntityIdURLTemplate =\n '%s/json%s/realm-config/federation/entityproviders/saml2/%s';\nconst apiVersion = 'protocol=2.1,resource=1.0';\nconst getApiConfig = () => {\n const configPath = getCurrentRealmPath();\n return {\n path: `${configPath}/realm-config/saml2`,\n apiVersion,\n };\n};\n\n/**\n * Get all SAML2 entity providers\n * @returns {Promise} a promise that resolves to an array of saml2 entity stubs\n */\nexport async function getProviders() {\n const urlString = util.format(\n queryAllProvidersURLTemplate,\n state.getHost(),\n getCurrentRealmPath()\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Find all providers matching the filter and return the requested fields\n * @param {string} filter CREST filter string, eg \"entityId+eq+'${entityId}'\" or \"true\" for all providers\n * @param {string[]} fields array of field names to include in the response\n * @returns {Promise} a promise that resolves to an object containing an array of saml2 entities\n */\nexport async function findProviders(filter = 'true', fields = ['*']) {\n const urlString = util.format(\n queryProvidersByEntityIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n encodeURIComponent(filter),\n fields.join(',')\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Geta SAML2 entity provider by location and id\n * @param {string} location Entity provider location (hosted or remote)\n * @param {string} entityId64 Base64-encoded provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function getProviderByLocationAndId(\n location: string,\n entityId64: string\n) {\n const urlString = util.format(\n providerByLocationAndIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n location,\n entityId64\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Geta SAML2 entity provider by location and id\n * @param {string} location Entity provider location (hosted or remote)\n * @param {string} entityId64 Base64-encoded provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function deleteProviderByLocationAndId(\n location: string,\n entityId64: string\n) {\n const urlString = util.format(\n providerByLocationAndIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n location,\n entityId64\n );\n const { data } = await generateAmApi(getApiConfig()).delete(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get a SAML2 entity provider's metadata URL by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {string} the URL to get the metadata from\n */\nexport function getProviderMetadataUrl(entityId: string): string {\n return util.format(\n metadataByEntityIdURLTemplate,\n state.getHost(),\n encodeURIComponent(entityId),\n state.getRealm()\n );\n}\n\n/**\n * Get a SAML2 entity provider's metadata by entity id\n * @param {String} entityId SAML2 entity id\n * @returns {Promise} a promise that resolves to an object containing a SAML2 metadata\n */\nexport async function getProviderMetadata(entityId) {\n const { data } = await generateAmApi(getApiConfig()).get(\n getProviderMetadataUrl(entityId),\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Create a SAML2 entity provider\n * @param {String} location 'hosted' or 'remote'\n * @param {Object} providerData Object representing a SAML entity provider\n * @param {String} metaData Base64-encoded metadata XML. Only required for remote providers\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function createProvider(location, providerData, metaData) {\n let postData = _.cloneDeep(providerData);\n let urlString = util.format(\n createHostedProviderURLTemplate,\n state.getHost(),\n getCurrentRealmPath()\n );\n\n if (location === 'remote') {\n /**\n * Remote entity providers must be created using XML metadata\n */\n urlString = util.format(\n createRemoteProviderURLTemplate,\n state.getHost(),\n getCurrentRealmPath()\n );\n postData = {\n standardMetadata: metaData,\n };\n }\n\n const { data } = await generateAmApi(getApiConfig()).post(\n urlString,\n postData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Update SAML2 entity provider\n * @param {String} location Entity provider location (hosted or remote)\n * @param {Object} providerData Object representing a SAML entity provider\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function updateProvider(location, providerData) {\n const urlString = util.format(\n providerByLocationAndIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n location,\n providerData._id\n );\n const { data } = await generateAmApi(getApiConfig()).put(\n urlString,\n providerData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n// Contributions using legacy APIs. Need to investigate if those will be deprecated in the future\n\n/**\n * Deletes a SAML2 entity provider by entity id\n * @param {string} entityId Provider entity id\n * @returns {Promise} a promise that resolves to a provider object\n */\nexport async function deleteRawProvider(entityId) {\n const urlString = util.format(\n samlApplicationByEntityIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n entityId\n );\n const { data } = await generateAmApi(getApiConfig()).delete(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Retrieves all entity providers using the legacy federation enpoints.\n * @returns {Promise} a promise that resolves to an object containing an array of providers\n */\nexport async function getRawProviders() {\n const urlString = util.format(\n samlApplicationQueryURLTemplateRaw,\n state.getHost(),\n getCurrentRealmPath()\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Gets the data for an entity provider including the raw XML.\n * @param {string} entityId The entity provider id\n * @returns Promise that when resolved includes the configuration and raw xml for a SAML entity provider\n */\nexport async function getRawProvider(entityId: string) {\n const urlString = util.format(\n samlApplicationByEntityIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n encodeURIComponent(entityId)\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Stores a new SAML2 entity provider\n * @param {string} entityId The entity provider id\n * @param {string} entityData The actual data containing the entity provider configuration\n * @returns {Promise} Promise that resolves to a provider object\n */\nexport async function putRawProvider(entityId: string, entityData) {\n const urlString = util.format(\n samlApplicationByEntityIdURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n encodeURIComponent(entityId)\n );\n const { data } = await generateAmApi(getApiConfig()).put(\n urlString,\n entityData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAAuD;AAAA;AAAA;AAAA;AAAA;AAEvD,IAAMA,kCAAkC,GAAG,oCAAoC;AAC/E,IAAMC,+BAA+B,GACnC,qDAAqD;AACvD,IAAMC,+BAA+B,GACnC,2DAA2D;AAC7D,IAAMC,4BAA4B,GAChC,gDAAgD;AAClD,IAAMC,mCAAmC,GACvC,yDAAyD;AAC3D,IAAMC,6BAA6B,GACjC,sDAAsD;AACxD,IAAMC,kCAAkC,GACtC,2EAA2E;AAC7E,IAAMC,oCAAoC,GACxC,4DAA4D;AAC9D,IAAMC,UAAU,GAAG,2BAA2B;AAC9C,IAAMC,YAAY,GAAG,MAAM;EACzB,IAAMC,UAAU,GAAG,IAAAC,6BAAmB,GAAE;EACxC,OAAO;IACLC,IAAI,YAAKF,UAAU,wBAAqB;IACxCF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AAHA,SAIsBK,YAAY;EAAA;AAAA;AAYlC;AACA;AACA;AACA;AACA;AACA;AALA;EAAA,kCAZO,aAA8B;IACnC,IAAMC,SAAS,GAAGC,aAAI,CAACC,MA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GAAGC,aAAI,CAACC,MAAM,CAC3BT,oCAAoC,EACpCU,KAAK,CAACC,OAAO,EAAE,EACf,IAAAP,6BAAmB,GAAE,EACrBe,kBAAkB,CAACQ,QAAQ,CAAC,CAC7B;IACD,IAAM;MAAEf;IAAK,CAAC,SAAS,IAAAC,sBAAa,EAACX,YAAY,EAAE,CAAC,CAACsC,GAAG,CACtDjC,SAAS,EACTsC,UAAU,EACV;MACE9B,eAAe,EAAE;IACnB,CAAC,CACF;IACD,OAAOH,IAAI;EACb,CAAC;EAAA;AAAA"}
|
package/cjs/api/ScriptApi.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.deleteScript = deleteScript;
|
|
6
7
|
exports.getScript = getScript;
|
|
7
8
|
exports.getScriptByName = getScriptByName;
|
|
8
9
|
exports.getScripts = getScripts;
|
|
@@ -57,11 +58,11 @@ function getScriptByName(_x) {
|
|
|
57
58
|
/**
|
|
58
59
|
* Get script by id
|
|
59
60
|
* @param {String} scriptId script uuid/name
|
|
60
|
-
* @returns {Promise} a promise that resolves to
|
|
61
|
+
* @returns {Promise} a promise that resolves to a script object
|
|
61
62
|
*/
|
|
62
63
|
function _getScriptByName() {
|
|
63
64
|
_getScriptByName = _asyncToGenerator(function* (scriptName) {
|
|
64
|
-
var urlString = _util.default.format(scriptQueryURLTemplate, state.getHost(), (0, _ApiUtils.getCurrentRealmPath)(), scriptName);
|
|
65
|
+
var urlString = _util.default.format(scriptQueryURLTemplate, state.getHost(), (0, _ApiUtils.getCurrentRealmPath)(), encodeURIComponent(scriptName));
|
|
65
66
|
var {
|
|
66
67
|
data
|
|
67
68
|
} = yield (0, _BaseApi.generateAmApi)(getApiConfig()).get(urlString, {
|
|
@@ -95,6 +96,11 @@ function _getScript() {
|
|
|
95
96
|
function putScript(_x3, _x4) {
|
|
96
97
|
return _putScript.apply(this, arguments);
|
|
97
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Delete script by id
|
|
101
|
+
* @param {String} scriptId script uuid/name
|
|
102
|
+
* @returns {Promise} a promise that resolves to a script object
|
|
103
|
+
*/
|
|
98
104
|
function _putScript() {
|
|
99
105
|
_putScript = _asyncToGenerator(function* (scriptId, scriptData) {
|
|
100
106
|
var urlString = _util.default.format(scriptURLTemplate, state.getHost(), (0, _ApiUtils.getCurrentRealmPath)(), scriptId);
|
|
@@ -107,4 +113,19 @@ function _putScript() {
|
|
|
107
113
|
});
|
|
108
114
|
return _putScript.apply(this, arguments);
|
|
109
115
|
}
|
|
116
|
+
function deleteScript(_x5) {
|
|
117
|
+
return _deleteScript.apply(this, arguments);
|
|
118
|
+
}
|
|
119
|
+
function _deleteScript() {
|
|
120
|
+
_deleteScript = _asyncToGenerator(function* (scriptId) {
|
|
121
|
+
var urlString = _util.default.format(scriptURLTemplate, state.getHost(), (0, _ApiUtils.getCurrentRealmPath)(), scriptId);
|
|
122
|
+
var {
|
|
123
|
+
data
|
|
124
|
+
} = yield (0, _BaseApi.generateAmApi)(getApiConfig()).delete(urlString, {
|
|
125
|
+
withCredentials: true
|
|
126
|
+
});
|
|
127
|
+
return data;
|
|
128
|
+
});
|
|
129
|
+
return _deleteScript.apply(this, arguments);
|
|
130
|
+
}
|
|
110
131
|
//# sourceMappingURL=ScriptApi.js.map
|
package/cjs/api/ScriptApi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptApi.js","names":["scriptURLTemplate","scriptListURLTemplate","scriptQueryURLTemplate","apiVersion","getApiConfig","path","getCurrentRealmPath","getScripts","urlString","util","format","state","getHost","data","generateAmApi","get","withCredentials","getScriptByName","scriptName","getScript","scriptId","putScript","scriptData","put"],"sources":["api/ScriptApi.ts"],"sourcesContent":["import util from 'util';\nimport { generateAmApi } from './BaseApi';\nimport { getCurrentRealmPath } from './utils/ApiUtils';\nimport * as state from '../shared/State';\n\nconst scriptURLTemplate = '%s/json%s/scripts/%s';\nconst scriptListURLTemplate = '%s/json%s/scripts?_queryFilter=true';\nconst scriptQueryURLTemplate =\n '%s/json%s/scripts?_queryFilter=name+eq+%%22%s%%22';\nconst apiVersion = 'protocol=2.0,resource=1.0';\nconst getApiConfig = () => {\n return {\n path: `/json${getCurrentRealmPath()}/scripts`,\n apiVersion,\n };\n};\n\n/**\n * Get all scripts\n * @returns {Promise} a promise that resolves to an object containing an array of script objects\n */\nexport async function getScripts() {\n const urlString = util.format(\n scriptListURLTemplate,\n state.getHost(),\n getCurrentRealmPath()\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get script by name\n * @param {String} scriptName script name\n * @returns {Promise} a promise that resolves to an object containing a script object\n */\nexport async function getScriptByName(scriptName) {\n const urlString = util.format(\n scriptQueryURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n scriptName\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get script by id\n * @param {String} scriptId script uuid/name\n * @returns {Promise} a promise that resolves to
|
|
1
|
+
{"version":3,"file":"ScriptApi.js","names":["scriptURLTemplate","scriptListURLTemplate","scriptQueryURLTemplate","apiVersion","getApiConfig","path","getCurrentRealmPath","getScripts","urlString","util","format","state","getHost","data","generateAmApi","get","withCredentials","getScriptByName","scriptName","encodeURIComponent","getScript","scriptId","putScript","scriptData","put","deleteScript","delete"],"sources":["api/ScriptApi.ts"],"sourcesContent":["import util from 'util';\nimport { generateAmApi } from './BaseApi';\nimport { getCurrentRealmPath } from './utils/ApiUtils';\nimport * as state from '../shared/State';\n\nconst scriptURLTemplate = '%s/json%s/scripts/%s';\nconst scriptListURLTemplate = '%s/json%s/scripts?_queryFilter=true';\nconst scriptQueryURLTemplate =\n '%s/json%s/scripts?_queryFilter=name+eq+%%22%s%%22';\nconst apiVersion = 'protocol=2.0,resource=1.0';\nconst getApiConfig = () => {\n return {\n path: `/json${getCurrentRealmPath()}/scripts`,\n apiVersion,\n };\n};\n\n/**\n * Get all scripts\n * @returns {Promise} a promise that resolves to an object containing an array of script objects\n */\nexport async function getScripts() {\n const urlString = util.format(\n scriptListURLTemplate,\n state.getHost(),\n getCurrentRealmPath()\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get script by name\n * @param {String} scriptName script name\n * @returns {Promise} a promise that resolves to an object containing a script object\n */\nexport async function getScriptByName(scriptName) {\n const urlString = util.format(\n scriptQueryURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n encodeURIComponent(scriptName)\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get script by id\n * @param {String} scriptId script uuid/name\n * @returns {Promise} a promise that resolves to a script object\n */\nexport async function getScript(scriptId) {\n const urlString = util.format(\n scriptURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n scriptId\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Put script\n * @param {string} scriptId script uuid\n * @param {Object} scriptData script object\n * @returns {Promise} a promise that resolves to an object containing a script object\n */\nexport async function putScript(scriptId, scriptData) {\n const urlString = util.format(\n scriptURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n scriptId\n );\n const { data } = await generateAmApi(getApiConfig()).put(\n urlString,\n scriptData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Delete script by id\n * @param {String} scriptId script uuid/name\n * @returns {Promise} a promise that resolves to a script object\n */\nexport async function deleteScript(scriptId) {\n const urlString = util.format(\n scriptURLTemplate,\n state.getHost(),\n getCurrentRealmPath(),\n scriptId\n );\n const { data } = await generateAmApi(getApiConfig()).delete(urlString, {\n withCredentials: true,\n });\n return data;\n}\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AAAyC;AAAA;AAAA;AAAA;A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ider() {
|
|
|
205
205
|
var scriptData = importData.script[scriptId];
|
|
206
206
|
if (scriptId && scriptData) {
|
|
207
207
|
scriptData.script = (0, _ExportImportUtils.convertTextArrayToBase64)(scriptData.script);
|
|
208
|
-
yield (0, _ScriptOps.
|
|
208
|
+
yield (0, _ScriptOps.putScript)(scriptId, scriptData);
|
|
209
209
|
}
|
|
210
210
|
yield putProviderByTypeAndId(importData.idp[idpId]._type._id, idpId, importData.idp[idpId]);
|
|
211
211
|
return true;
|
|
@@ -229,7 +229,7 @@ function _importFirstSocialProvider() {
|
|
|
229
229
|
var scriptData = importData.script[scriptId];
|
|
230
230
|
if (scriptId && scriptData) {
|
|
231
231
|
scriptData.script = (0, _ExportImportUtils.convertTextArrayToBase64)(scriptData.script);
|
|
232
|
-
yield (0, _ScriptOps.
|
|
232
|
+
yield (0, _ScriptOps.putScript)(scriptId, scriptData);
|
|
233
233
|
}
|
|
234
234
|
yield putProviderByTypeAndId(importData.idp[idpId]._type._id, idpId, importData.idp[idpId]);
|
|
235
235
|
return true;
|
|
@@ -250,7 +250,7 @@ function _importSocialProviders() {
|
|
|
250
250
|
var scriptData = _objectSpread({}, importData.script[scriptId]);
|
|
251
251
|
if (scriptId && scriptData) {
|
|
252
252
|
scriptData.script = (0, _ExportImportUtils.convertTextArrayToBase64)(scriptData.script);
|
|
253
|
-
yield (0, _ScriptOps.
|
|
253
|
+
yield (0, _ScriptOps.putScript)(scriptId, scriptData);
|
|
254
254
|
}
|
|
255
255
|
yield putProviderByTypeAndId(importData.idp[idpId]._type._id, idpId, importData.idp[idpId]);
|
|
256
256
|
} catch (error) {
|
package/cjs/ops/IdpOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdpOps.js","names":["createIdpExportTemplate","meta","getMetadata","script","idp","getSocialIdentityProviders","result","_getSocialIdentityProviders","getSocialProvider","providerId","response","foundProviders","filter","provider","_id","length","Error","putProviderByTypeAndId","providerType","providerData","debugMessage","_putProviderByTypeAndId","importError","status","data","message","validAttributes","detail","push","attribute","Object","keys","includes","state","getVerbose","printMessage","deleteSocialProvider","deleteProviderByTypeAndId","_type","exportSocialProvider","idpData","exportData","transform","scriptData","getScript","convertBase64TextToArray","exportSocialProviders","allIdpsData","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","importSocialProvider","importData","idpId","scriptId","convertTextArrayToBase64","createOrUpdateScript","importFirstSocialProvider","importSocialProviders","outcome","error"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import {\n deleteProviderByTypeAndId,\n getSocialIdentityProviders as _getSocialIdentityProviders,\n putProviderByTypeAndId as _putProviderByTypeAndId,\n} from '../api/SocialIdentityProvidersApi';\nimport { getScript } from '../api/ScriptApi';\nimport { createOrUpdateScript } from './ScriptOps';\nimport {\n convertBase64TextToArray,\n convertTextArrayToBase64,\n} from './utils/ExportImportUtils';\nimport {\n printMessage,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from './utils/Console';\nimport { ExportMetaData } from './OpsTypes';\nimport { ScriptSkeleton, SocialIdpSkeleton } from '../api/ApiTypes';\nimport { getMetadata } from './utils/ExportImportUtils';\nimport * as state from '../shared/State';\nimport { debugMessage } from './utils/Console';\n\nexport interface SocialProviderExportInterface {\n meta?: ExportMetaData;\n script: Record<string, ScriptSkeleton>;\n idp: Record<string, SocialIdpSkeleton>;\n}\n\n/**\n * Create an empty idp export template\n * @returns {SocialProviderExportInterface} an empty idp export template\n */\nfunction createIdpExportTemplate(): SocialProviderExportInterface {\n return {\n meta: getMetadata(),\n script: {},\n idp: {},\n } as SocialProviderExportInterface;\n}\n\n/**\n * Get all social identity providers\n * @returns {Promise} a promise that resolves to an object containing an array of social identity providers\n */\nexport async function getSocialIdentityProviders() {\n const { result } = await _getSocialIdentityProviders();\n return result;\n}\n\n/**\n * Get social identity provider by id\n * @param {String} providerId social identity provider id/name\n * @returns {Promise} a promise that resolves a social identity provider object\n */\nexport async function getSocialProvider(providerId) {\n const response = await getSocialIdentityProviders();\n const foundProviders = response.filter(\n (provider) => provider._id === providerId\n );\n switch (foundProviders.length) {\n case 1:\n return foundProviders[0];\n case 0:\n throw new Error(`Provider '${providerId}' not found`);\n default:\n throw new Error(\n `${foundProviders.length} providers '${providerId}' found`\n );\n }\n}\n\nexport async function putProviderByTypeAndId(\n providerType: string,\n providerId: string,\n providerData: object\n) {\n debugMessage(`IdpOps.putProviderByTypeAndId: start`);\n try {\n const response = await _putProviderByTypeAndId(\n providerType,\n providerId,\n providerData\n );\n debugMessage(`IdpOps.putProviderByTypeAndId: end`);\n return response;\n } catch (importError) {\n if (\n importError.response?.status === 400 &&\n importError.response?.data?.message === 'Invalid attribute specified.'\n ) {\n const { validAttributes } = importError.response.data.detail;\n validAttributes.push('_id', '_type');\n for (const attribute of Object.keys(providerData)) {\n if (!validAttributes.includes(attribute)) {\n if (state.getVerbose())\n printMessage(\n `\\nRemoving invalid attribute: ${attribute}`,\n 'warn',\n false\n );\n delete providerData[attribute];\n }\n }\n if (state.getVerbose()) printMessage('\\n', 'warn', false);\n const response = await _putProviderByTypeAndId(\n providerType,\n providerId,\n providerData\n );\n debugMessage(`IdpOps.putProviderByTypeAndId: end (after retry)`);\n return response;\n } else {\n // re-throw unhandleable error\n throw importError;\n }\n }\n}\n\n/**\n * Delete social identity provider by id\n * @param {String} providerId social identity provider id/name\n * @returns {Promise} a promise that resolves a social identity provider object\n */\nexport async function deleteSocialProvider(\n providerId: string\n): Promise<unknown> {\n const response = await getSocialIdentityProviders();\n const foundProviders = response.filter(\n (provider) => provider._id === providerId\n );\n switch (foundProviders.length) {\n case 1:\n return await deleteProviderByTypeAndId(\n foundProviders[0]._type._id,\n foundProviders[0]._id\n );\n case 0:\n throw new Error(`Provider '${providerId}' not found`);\n default:\n throw new Error(\n `${foundProviders.length} providers '${providerId}' found`\n );\n }\n}\n\n/**\n * Export social provider by id\n * @param {string} providerId provider id/name\n * @returns {Promise<SocialProviderExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\nexport async function exportSocialProvider(\n providerId: string\n): Promise<SocialProviderExportInterface> {\n debugMessage(`IdpOps.exportSocialProvider: start`);\n const idpData = await getSocialProvider(providerId);\n const exportData = createIdpExportTemplate();\n exportData.idp[idpData._id] = idpData;\n if (idpData.transform) {\n const scriptData = await getScript(idpData.transform);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n exportData.script[idpData.transform] = scriptData;\n }\n debugMessage(`IdpOps.exportSocialProvider: end`);\n return exportData;\n}\n\n/**\n * Export all providers\n * @returns {Promise<SocialProviderExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\nexport async function exportSocialProviders(): Promise<SocialProviderExportInterface> {\n const exportData = createIdpExportTemplate();\n const allIdpsData = await getSocialIdentityProviders();\n createProgressIndicator(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressIndicator(`Exporting provider ${idpData._id}`);\n exportData.idp[idpData._id] = idpData;\n if (idpData.transform) {\n // eslint-disable-next-line no-await-in-loop\n const scriptData = await getScript(idpData.transform);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n exportData.script[idpData.transform] = scriptData;\n }\n }\n stopProgressIndicator(`${allIdpsData.length} providers exported.`);\n return exportData;\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {SocialProviderExportInterface} importData import data\n */\nexport async function importSocialProvider(\n providerId: string,\n importData: SocialProviderExportInterface\n): Promise<boolean> {\n for (const idpId of Object.keys(importData.idp)) {\n if (idpId === providerId) {\n const scriptId = importData.idp[idpId].transform;\n const scriptData = importData.script[scriptId as string];\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await createOrUpdateScript(scriptId, scriptData);\n }\n await putProviderByTypeAndId(\n importData.idp[idpId]._type._id,\n idpId,\n importData.idp[idpId]\n );\n return true;\n }\n }\n return false;\n}\n\n/**\n * Import first provider\n * @param {SocialProviderExportInterface} importData import data\n */\nexport async function importFirstSocialProvider(\n importData: SocialProviderExportInterface\n): Promise<boolean> {\n for (const idpId of Object.keys(importData.idp)) {\n const scriptId = importData.idp[idpId].transform;\n const scriptData = importData.script[scriptId as string];\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await createOrUpdateScript(scriptId, scriptData);\n }\n await putProviderByTypeAndId(\n importData.idp[idpId]._type._id,\n idpId,\n importData.idp[idpId]\n );\n return true;\n }\n return false;\n}\n\n/**\n * Import all providers\n * @param {SocialProviderExportInterface} importData import data\n */\nexport async function importSocialProviders(\n importData: SocialProviderExportInterface\n): Promise<boolean> {\n let outcome = true;\n for (const idpId of Object.keys(importData.idp)) {\n try {\n const scriptId = importData.idp[idpId].transform;\n const scriptData = { ...importData.script[scriptId as string] };\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await createOrUpdateScript(scriptId, scriptData);\n }\n await putProviderByTypeAndId(\n importData.idp[idpId]._type._id,\n idpId,\n importData.idp[idpId]\n );\n } catch (error) {\n printMessage(error.response?.data || error, 'error');\n printMessage(`\\nError importing provider ${idpId}`, 'error');\n outcome = false;\n }\n }\n return outcome;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAKA;AACA;AACA;AAIA;AASA;AAAyC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASzC;AACA;AACA;AACA;AACA,SAASA,uBAAuB,GAAkC;EAChE,OAAO;IACLC,IAAI,EAAE,IAAAC,8BAAW,GAAE;IACnBC,MAAM,EAAE,CAAC,CAAC;IACVC,GAAG,EAAE,CAAC;EACR,CAAC;AACH;;AAEA;AACA;AACA;AACA;AAHA,SAIsBC,0BAA0B;EAAA;AAAA;AAKhD;AACA;AACA;AACA;AACA;AAJA;EAAA,iDALO,aAA4C;IACjD,IAAM;MAAEC;IAAO,CAAC,SAAS,IAAAC,sDAA2B,GAAE;IACtD,OAAOD,MAAM;EACf,CAAC;EAAA;AAAA;AAAA,SAOqBE,iBAAiB;EAAA;AAAA;AAAA;EAAA,uCAAhC,W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QACpD,IAAAzB,qBAAY,uCAA+BkB,KAAK,GAAI,OAAO,CAAC;QAC5DM,OAAO,GAAG,KAAK;MACjB;IACF;IACA,OAAOA,OAAO;EAChB,CAAC;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"file":"IdpOps.js","names":["createIdpExportTemplate","meta","getMetadata","script","idp","getSocialIdentityProviders","result","_getSocialIdentityProviders","getSocialProvider","providerId","response","foundProviders","filter","provider","_id","length","Error","putProviderByTypeAndId","providerType","providerData","debugMessage","_putProviderByTypeAndId","importError","status","data","message","validAttributes","detail","push","attribute","Object","keys","includes","state","getVerbose","printMessage","deleteSocialProvider","deleteProviderByTypeAndId","_type","exportSocialProvider","idpData","exportData","transform","scriptData","getScript","convertBase64TextToArray","exportSocialProviders","allIdpsData","createProgressIndicator","updateProgressIndicator","stopProgressIndicator","importSocialProvider","importData","idpId","scriptId","convertTextArrayToBase64","putScript","importFirstSocialProvider","importSocialProviders","outcome","error"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import {\n deleteProviderByTypeAndId,\n getSocialIdentityProviders as _getSocialIdentityProviders,\n putProviderByTypeAndId as _putProviderByTypeAndId,\n} from '../api/SocialIdentityProvidersApi';\nimport { getScript } from '../api/ScriptApi';\nimport { putScript } from './ScriptOps';\nimport {\n convertBase64TextToArray,\n convertTextArrayToBase64,\n} from './utils/ExportImportUtils';\nimport {\n printMessage,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from './utils/Console';\nimport { ExportMetaData } from './OpsTypes';\nimport { ScriptSkeleton, SocialIdpSkeleton } from '../api/ApiTypes';\nimport { getMetadata } from './utils/ExportImportUtils';\nimport * as state from '../shared/State';\nimport { debugMessage } from './utils/Console';\n\nexport interface SocialProviderExportInterface {\n meta?: ExportMetaData;\n script: Record<string, ScriptSkeleton>;\n idp: Record<string, SocialIdpSkeleton>;\n}\n\n/**\n * Create an empty idp export template\n * @returns {SocialProviderExportInterface} an empty idp export template\n */\nfunction createIdpExportTemplate(): SocialProviderExportInterface {\n return {\n meta: getMetadata(),\n script: {},\n idp: {},\n } as SocialProviderExportInterface;\n}\n\n/**\n * Get all social identity providers\n * @returns {Promise} a promise that resolves to an object containing an array of social identity providers\n */\nexport async function getSocialIdentityProviders() {\n const { result } = await _getSocialIdentityProviders();\n return result;\n}\n\n/**\n * Get social identity provider by id\n * @param {String} providerId social identity provider id/name\n * @returns {Promise} a promise that resolves a social identity provider object\n */\nexport async function getSocialProvider(providerId) {\n const response = await getSocialIdentityProviders();\n const foundProviders = response.filter(\n (provider) => provider._id === providerId\n );\n switch (foundProviders.length) {\n case 1:\n return foundProviders[0];\n case 0:\n throw new Error(`Provider '${providerId}' not found`);\n default:\n throw new Error(\n `${foundProviders.length} providers '${providerId}' found`\n );\n }\n}\n\nexport async function putProviderByTypeAndId(\n providerType: string,\n providerId: string,\n providerData: object\n) {\n debugMessage(`IdpOps.putProviderByTypeAndId: start`);\n try {\n const response = await _putProviderByTypeAndId(\n providerType,\n providerId,\n providerData\n );\n debugMessage(`IdpOps.putProviderByTypeAndId: end`);\n return response;\n } catch (importError) {\n if (\n importError.response?.status === 400 &&\n importError.response?.data?.message === 'Invalid attribute specified.'\n ) {\n const { validAttributes } = importError.response.data.detail;\n validAttributes.push('_id', '_type');\n for (const attribute of Object.keys(providerData)) {\n if (!validAttributes.includes(attribute)) {\n if (state.getVerbose())\n printMessage(\n `\\nRemoving invalid attribute: ${attribute}`,\n 'warn',\n false\n );\n delete providerData[attribute];\n }\n }\n if (state.getVerbose()) printMessage('\\n', 'warn', false);\n const response = await _putProviderByTypeAndId(\n providerType,\n providerId,\n providerData\n );\n debugMessage(`IdpOps.putProviderByTypeAndId: end (after retry)`);\n return response;\n } else {\n // re-throw unhandleable error\n throw importError;\n }\n }\n}\n\n/**\n * Delete social identity provider by id\n * @param {String} providerId social identity provider id/name\n * @returns {Promise} a promise that resolves a social identity provider object\n */\nexport async function deleteSocialProvider(\n providerId: string\n): Promise<unknown> {\n const response = await getSocialIdentityProviders();\n const foundProviders = response.filter(\n (provider) => provider._id === providerId\n );\n switch (foundProviders.length) {\n case 1:\n return await deleteProviderByTypeAndId(\n foundProviders[0]._type._id,\n foundProviders[0]._id\n );\n case 0:\n throw new Error(`Provider '${providerId}' not found`);\n default:\n throw new Error(\n `${foundProviders.length} providers '${providerId}' found`\n );\n }\n}\n\n/**\n * Export social provider by id\n * @param {string} providerId provider id/name\n * @returns {Promise<SocialProviderExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\nexport async function exportSocialProvider(\n providerId: string\n): Promise<SocialProviderExportInterface> {\n debugMessage(`IdpOps.exportSocialProvider: start`);\n const idpData = await getSocialProvider(providerId);\n const exportData = createIdpExportTemplate();\n exportData.idp[idpData._id] = idpData;\n if (idpData.transform) {\n const scriptData = await getScript(idpData.transform);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n exportData.script[idpData.transform] = scriptData;\n }\n debugMessage(`IdpOps.exportSocialProvider: end`);\n return exportData;\n}\n\n/**\n * Export all providers\n * @returns {Promise<SocialProviderExportInterface>} a promise that resolves to a SocialProviderExportInterface object\n */\nexport async function exportSocialProviders(): Promise<SocialProviderExportInterface> {\n const exportData = createIdpExportTemplate();\n const allIdpsData = await getSocialIdentityProviders();\n createProgressIndicator(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressIndicator(`Exporting provider ${idpData._id}`);\n exportData.idp[idpData._id] = idpData;\n if (idpData.transform) {\n // eslint-disable-next-line no-await-in-loop\n const scriptData = await getScript(idpData.transform);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n exportData.script[idpData.transform] = scriptData;\n }\n }\n stopProgressIndicator(`${allIdpsData.length} providers exported.`);\n return exportData;\n}\n\n/**\n * Import provider by id/name\n * @param {string} providerId provider id/name\n * @param {SocialProviderExportInterface} importData import data\n */\nexport async function importSocialProvider(\n providerId: string,\n importData: SocialProviderExportInterface\n): Promise<boolean> {\n for (const idpId of Object.keys(importData.idp)) {\n if (idpId === providerId) {\n const scriptId = importData.idp[idpId].transform as string;\n const scriptData = importData.script[scriptId as string];\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(scriptId, scriptData);\n }\n await putProviderByTypeAndId(\n importData.idp[idpId]._type._id,\n idpId,\n importData.idp[idpId]\n );\n return true;\n }\n }\n return false;\n}\n\n/**\n * Import first provider\n * @param {SocialProviderExportInterface} importData import data\n */\nexport async function importFirstSocialProvider(\n importData: SocialProviderExportInterface\n): Promise<boolean> {\n for (const idpId of Object.keys(importData.idp)) {\n const scriptId = importData.idp[idpId].transform as string;\n const scriptData = importData.script[scriptId as string];\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(scriptId, scriptData);\n }\n await putProviderByTypeAndId(\n importData.idp[idpId]._type._id,\n idpId,\n importData.idp[idpId]\n );\n return true;\n }\n return false;\n}\n\n/**\n * Import all providers\n * @param {SocialProviderExportInterface} importData import data\n */\nexport async function importSocialProviders(\n importData: SocialProviderExportInterface\n): Promise<boolean> {\n let outcome = true;\n for (const idpId of Object.keys(importData.idp)) {\n try {\n const scriptId = importData.idp[idpId].transform as string;\n const scriptData = { ...importData.script[scriptId as string] };\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n await putScript(scriptId, scriptData);\n }\n await putProviderByTypeAndId(\n importData.idp[idpId]._type._id,\n idpId,\n importData.idp[idpId]\n );\n } catch (error) {\n printMessage(error.response?.data || error, 'error');\n printMessage(`\\nError importing provider ${idpId}`, 'error');\n outcome = false;\n }\n }\n return outcome;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAKA;AACA;AACA;AAIA;AASA;AAAyC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASzC;AACA;AACA;AACA;AACA,SAASA,uBAAuB,GAAkC;EAChE,OAAO;IACLC,IAAI,EAAE,IAAAC,8BAAW,GAAE;IACnBC,MAAM,EAAE,CAAC,CAAC;IACVC,GAAG,E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B,CAC1BmC,UAAU,CAAChD,GAAG,CAACiD,KAAK,CAAC,CAACf,KAAK,CAACxB,GAAG,EAC/BuC,KAAK,EACLD,UAAU,CAAChD,GAAG,CAACiD,KAAK,CAAC,CACtB;MACH,CAAC,CAAC,OAAOO,KAAK,EAAE;QAAA;QACd,IAAAzB,qBAAY,EAAC,oBAAAyB,KAAK,CAAClD,QAAQ,oDAAd,gBAAgBc,IAAI,KAAIoC,KAAK,EAAE,OAAO,CAAC;QACpD,IAAAzB,qBAAY,uCAA+BkB,KAAK,GAAI,OAAO,CAAC;QAC5DM,OAAO,GAAG,KAAK;MACjB;IACF;IACA,OAAOA,OAAO;EAChB,CAAC;EAAA;AAAA"}
|
package/cjs/ops/JourneyOps.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.enableJourney = enableJourney;
|
|
|
13
13
|
exports.exportJourney = exportJourney;
|
|
14
14
|
exports.fileByIdTreeExportResolver = void 0;
|
|
15
15
|
exports.findOrphanedNodes = findOrphanedNodes;
|
|
16
|
+
exports.getJourney = getJourney;
|
|
16
17
|
exports.getJourneyClassification = getJourneyClassification;
|
|
17
18
|
exports.getJourneys = getJourneys;
|
|
18
19
|
exports.getNodeRef = getNodeRef;
|
|
@@ -61,7 +62,7 @@ var emptyScriptPlaceholder = '[Empty]';
|
|
|
61
62
|
*/
|
|
62
63
|
function createSingleTreeExportTemplate() {
|
|
63
64
|
return {
|
|
64
|
-
meta:
|
|
65
|
+
meta: (0, _ExportImportUtils.getMetadata)(),
|
|
65
66
|
innerNodes: {},
|
|
66
67
|
nodes: {},
|
|
67
68
|
scripts: {},
|
|
@@ -80,7 +81,7 @@ function createSingleTreeExportTemplate() {
|
|
|
80
81
|
*/
|
|
81
82
|
function createMultiTreeExportTemplate() {
|
|
82
83
|
return {
|
|
83
|
-
meta:
|
|
84
|
+
meta: (0, _ExportImportUtils.getMetadata)(),
|
|
84
85
|
trees: {}
|
|
85
86
|
};
|
|
86
87
|
}
|
|
@@ -449,25 +450,37 @@ function getJourneys() {
|
|
|
449
450
|
return _getJourneys.apply(this, arguments);
|
|
450
451
|
}
|
|
451
452
|
/**
|
|
452
|
-
*
|
|
453
|
-
* @param {
|
|
454
|
-
* @
|
|
453
|
+
* Get a journey/tree without all its nodes and dependencies.
|
|
454
|
+
* @param {string} journeyId journey id/name
|
|
455
|
+
* @returns {Promise<TreeSkeleton>} a promise that resolves to a journey object
|
|
455
456
|
*/
|
|
456
457
|
function _getJourneys() {
|
|
457
458
|
_getJourneys = _asyncToGenerator(function* () {
|
|
458
|
-
var
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
(0, _Console.printMessage)(error.response.data, 'error');
|
|
464
|
-
}
|
|
465
|
-
journeys.sort((a, b) => a._id.localeCompare(b._id));
|
|
466
|
-
return journeys;
|
|
459
|
+
var {
|
|
460
|
+
result
|
|
461
|
+
} = yield (0, _TreeApi.getTrees)();
|
|
462
|
+
result.sort((a, b) => a._id.localeCompare(b._id));
|
|
463
|
+
return result;
|
|
467
464
|
});
|
|
468
465
|
return _getJourneys.apply(this, arguments);
|
|
469
466
|
}
|
|
470
|
-
function
|
|
467
|
+
function getJourney(_x5) {
|
|
468
|
+
return _getJourney.apply(this, arguments);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Helper to import a tree with all dependencies from a `SingleTreeExportInterface` object (typically read from a file)
|
|
472
|
+
* @param {SingleTreeExportInterface} treeObject tree object containing tree and all its dependencies
|
|
473
|
+
* @param {TreeImportOptions} options import options
|
|
474
|
+
* @returns {Promise<boolean>} a promise that resolves to true if no errors occurred during import
|
|
475
|
+
*/
|
|
476
|
+
function _getJourney() {
|
|
477
|
+
_getJourney = _asyncToGenerator(function* (journeyId) {
|
|
478
|
+
var response = yield (0, _TreeApi.getTree)(journeyId);
|
|
479
|
+
return response;
|
|
480
|
+
});
|
|
481
|
+
return _getJourney.apply(this, arguments);
|
|
482
|
+
}
|
|
483
|
+
function importJourney(_x6, _x7) {
|
|
471
484
|
return _importJourney.apply(this, arguments);
|
|
472
485
|
}
|
|
473
486
|
/**
|
|
@@ -501,8 +514,10 @@ function _importJourney() {
|
|
|
501
514
|
} else if (!(0, _Base.isBase64Encoded)(scriptObject['script'])) {
|
|
502
515
|
scriptObject['script'] = (0, _Base.encode)(JSON.parse(scriptObject['script']));
|
|
503
516
|
}
|
|
504
|
-
|
|
505
|
-
|
|
517
|
+
try {
|
|
518
|
+
yield (0, _ScriptOps.putScript)(scriptId, scriptObject);
|
|
519
|
+
} catch (error) {
|
|
520
|
+
throw new Error("Error importing script ".concat(scriptObject['name'], " (").concat(scriptId, ") in journey ").concat(treeId, ": ").concat(error.message));
|
|
506
521
|
}
|
|
507
522
|
if (verbose) (0, _Console.printMessage)('');
|
|
508
523
|
}
|
|
@@ -804,10 +819,11 @@ function _importJourney() {
|
|
|
804
819
|
throw new Error("\nError importing journey flow ".concat(treeId));
|
|
805
820
|
}
|
|
806
821
|
}
|
|
822
|
+
return true;
|
|
807
823
|
});
|
|
808
824
|
return _importJourney.apply(this, arguments);
|
|
809
825
|
}
|
|
810
|
-
function resolveDependencies(
|
|
826
|
+
function resolveDependencies(_x8, _x9, _x10, _x11) {
|
|
811
827
|
return _resolveDependencies.apply(this, arguments);
|
|
812
828
|
}
|
|
813
829
|
/**
|
|
@@ -867,7 +883,7 @@ function _resolveDependencies() {
|
|
|
867
883
|
});
|
|
868
884
|
return _resolveDependencies.apply(this, arguments);
|
|
869
885
|
}
|
|
870
|
-
function importAllJourneys(
|
|
886
|
+
function importAllJourneys(_x12, _x13) {
|
|
871
887
|
return _importAllJourneys.apply(this, arguments);
|
|
872
888
|
}
|
|
873
889
|
/**
|
|
@@ -942,7 +958,7 @@ var onlineTreeExportResolver = /*#__PURE__*/function () {
|
|
|
942
958
|
useStringArrays: false
|
|
943
959
|
});
|
|
944
960
|
});
|
|
945
|
-
return function onlineTreeExportResolver(
|
|
961
|
+
return function onlineTreeExportResolver(_x14) {
|
|
946
962
|
return _ref.apply(this, arguments);
|
|
947
963
|
};
|
|
948
964
|
}();
|
|
@@ -977,7 +993,7 @@ var fileByIdTreeExportResolver = /*#__PURE__*/function () {
|
|
|
977
993
|
}
|
|
978
994
|
return treeExport;
|
|
979
995
|
});
|
|
980
|
-
return function fileByIdTreeExportResolver(
|
|
996
|
+
return function fileByIdTreeExportResolver(_x15) {
|
|
981
997
|
return _ref2.apply(this, arguments);
|
|
982
998
|
};
|
|
983
999
|
}();
|
|
@@ -1014,7 +1030,7 @@ function createFileParamTreeExportResolver(file) {
|
|
|
1014
1030
|
}
|
|
1015
1031
|
return treeExport;
|
|
1016
1032
|
});
|
|
1017
|
-
return function fileParamTreeExportResolver(
|
|
1033
|
+
return function fileParamTreeExportResolver(_x16) {
|
|
1018
1034
|
return _ref3.apply(this, arguments);
|
|
1019
1035
|
};
|
|
1020
1036
|
}();
|
|
@@ -1029,7 +1045,7 @@ function createFileParamTreeExportResolver(file) {
|
|
|
1029
1045
|
* @param {TreeExportResolverInterface} resolveTreeExport tree export resolver callback function
|
|
1030
1046
|
* @returns {Promise<TreeDependencyMapInterface>} a promise that resolves to a tree dependency map
|
|
1031
1047
|
*/
|
|
1032
|
-
function getTreeDescendents(
|
|
1048
|
+
function getTreeDescendents(_x17) {
|
|
1033
1049
|
return _getTreeDescendents.apply(this, arguments);
|
|
1034
1050
|
}
|
|
1035
1051
|
/**
|
|
@@ -1134,7 +1150,7 @@ function _findOrphanedNodes() {
|
|
|
1134
1150
|
});
|
|
1135
1151
|
return _findOrphanedNodes.apply(this, arguments);
|
|
1136
1152
|
}
|
|
1137
|
-
function removeOrphanedNodes(
|
|
1153
|
+
function removeOrphanedNodes(_x18) {
|
|
1138
1154
|
return _removeOrphanedNodes.apply(this, arguments);
|
|
1139
1155
|
}
|
|
1140
1156
|
/**
|
|
@@ -1231,7 +1247,7 @@ function getJourneyClassification(journey) {
|
|
|
1231
1247
|
* @param {string} journeyId journey id/name
|
|
1232
1248
|
* @param {Object} options deep=true also delete all the nodes and inner nodes, verbose=true print verbose info
|
|
1233
1249
|
*/
|
|
1234
|
-
function deleteJourney(
|
|
1250
|
+
function deleteJourney(_x19, _x20) {
|
|
1235
1251
|
return _deleteJourney.apply(this, arguments);
|
|
1236
1252
|
}
|
|
1237
1253
|
/**
|
|
@@ -1240,13 +1256,11 @@ function deleteJourney(_x18, _x19) {
|
|
|
1240
1256
|
*/
|
|
1241
1257
|
function _deleteJourney() {
|
|
1242
1258
|
_deleteJourney = _asyncToGenerator(function* (journeyId, options) {
|
|
1243
|
-
var progress = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
1244
|
-
var {
|
|
1245
|
-
deep
|
|
1246
|
-
} = options;
|
|
1247
1259
|
var {
|
|
1260
|
+
deep,
|
|
1248
1261
|
verbose
|
|
1249
1262
|
} = options;
|
|
1263
|
+
var progress = !('progress' in options) ? true : options.progress;
|
|
1250
1264
|
var status = {
|
|
1251
1265
|
nodes: {}
|
|
1252
1266
|
};
|
|
@@ -1348,7 +1362,7 @@ function _deleteJourney() {
|
|
|
1348
1362
|
}
|
|
1349
1363
|
return status;
|
|
1350
1364
|
});
|
|
1351
|
-
return function (
|
|
1365
|
+
return function (_x24) {
|
|
1352
1366
|
return _ref4.apply(this, arguments);
|
|
1353
1367
|
};
|
|
1354
1368
|
}()).catch(error => {
|
|
@@ -1361,7 +1375,7 @@ function _deleteJourney() {
|
|
|
1361
1375
|
});
|
|
1362
1376
|
return _deleteJourney.apply(this, arguments);
|
|
1363
1377
|
}
|
|
1364
|
-
function deleteJourneys(
|
|
1378
|
+
function deleteJourneys(_x21) {
|
|
1365
1379
|
return _deleteJourneys.apply(this, arguments);
|
|
1366
1380
|
}
|
|
1367
1381
|
/**
|
|
@@ -1379,8 +1393,8 @@ function _deleteJourneys() {
|
|
|
1379
1393
|
(0, _Console.createProgressIndicator)(trees.length, 'Deleting journeys...');
|
|
1380
1394
|
for (var tree of trees) {
|
|
1381
1395
|
if (verbose) (0, _Console.printMessage)('');
|
|
1382
|
-
|
|
1383
|
-
status[tree._id] = yield deleteJourney(tree._id, options
|
|
1396
|
+
options['progress'] = false;
|
|
1397
|
+
status[tree._id] = yield deleteJourney(tree._id, options);
|
|
1384
1398
|
(0, _Console.updateProgressIndicator)("".concat(tree._id));
|
|
1385
1399
|
// introduce a 100ms wait to allow the progress bar to update before the next verbose message prints from the async function
|
|
1386
1400
|
if (verbose)
|
|
@@ -1406,7 +1420,7 @@ function _deleteJourneys() {
|
|
|
1406
1420
|
});
|
|
1407
1421
|
return _deleteJourneys.apply(this, arguments);
|
|
1408
1422
|
}
|
|
1409
|
-
function enableJourney(
|
|
1423
|
+
function enableJourney(_x22) {
|
|
1410
1424
|
return _enableJourney.apply(this, arguments);
|
|
1411
1425
|
}
|
|
1412
1426
|
/**
|
|
@@ -1429,7 +1443,7 @@ function _enableJourney() {
|
|
|
1429
1443
|
});
|
|
1430
1444
|
return _enableJourney.apply(this, arguments);
|
|
1431
1445
|
}
|
|
1432
|
-
function disableJourney(
|
|
1446
|
+
function disableJourney(_x23) {
|
|
1433
1447
|
return _disableJourney.apply(this, arguments);
|
|
1434
1448
|
}
|
|
1435
1449
|
function _disableJourney() {
|