@esri/solution-form 5.2.3 → 5.2.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/dist/cjs/convert-item-to-template.d.ts +31 -0
- package/dist/cjs/convert-item-to-template.js +34 -0
- package/dist/cjs/convert-item-to-template.js.map +1 -0
- package/dist/cjs/create-item-from-template.d.ts +31 -0
- package/dist/cjs/create-item-from-template.js +40 -0
- package/dist/cjs/create-item-from-template.js.map +1 -0
- package/dist/cjs/formUtils.d.ts +24 -0
- package/dist/cjs/formUtils.js +55 -0
- package/dist/cjs/formUtils.js.map +1 -0
- package/dist/cjs/helpers/build-create-params.d.ts +30 -0
- package/dist/cjs/helpers/build-create-params.js +78 -0
- package/dist/cjs/helpers/build-create-params.js.map +1 -0
- package/dist/cjs/helpers/create-item-from-hub-template.d.ts +32 -0
- package/dist/cjs/helpers/create-item-from-hub-template.js +80 -0
- package/dist/cjs/helpers/create-item-from-hub-template.js.map +1 -0
- package/dist/cjs/helpers/create-survey.d.ts +30 -0
- package/dist/cjs/helpers/create-survey.js +60 -0
- package/dist/cjs/helpers/create-survey.js.map +1 -0
- package/dist/cjs/helpers/encode-survey-form.d.ts +28 -0
- package/dist/cjs/helpers/encode-survey-form.js +59 -0
- package/dist/cjs/helpers/encode-survey-form.js.map +1 -0
- package/dist/cjs/helpers/is-hub-form-template.d.ts +24 -0
- package/dist/cjs/helpers/is-hub-form-template.js +33 -0
- package/dist/cjs/helpers/is-hub-form-template.js.map +1 -0
- package/dist/cjs/helpers/post-process-survey.d.ts +33 -0
- package/dist/cjs/helpers/post-process-survey.js +82 -0
- package/dist/cjs/helpers/post-process-survey.js.map +1 -0
- package/dist/cjs/index.d.ts +24 -0
- package/dist/cjs/index.js +28 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/post-process.d.ts +27 -0
- package/dist/cjs/post-process.js +63 -0
- package/dist/cjs/post-process.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/package.json +8 -8
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2018 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Manages the creation of Form templates
|
|
18
|
+
*
|
|
19
|
+
* @module convert-item-to-template
|
|
20
|
+
*/
|
|
21
|
+
import { UserSession, IItemTemplate } from "@esri/solution-common";
|
|
22
|
+
/**
|
|
23
|
+
* Creates a template from a Form item
|
|
24
|
+
*
|
|
25
|
+
* @param {any} itemInfo: The base item info
|
|
26
|
+
* @param {UserSession} destAuthentication Credentials for requests to the destination organization
|
|
27
|
+
* @param {UserSession} srcAuthentication Credentials for requests to source items
|
|
28
|
+
* @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
|
|
29
|
+
* @returns {Promise<IItemTemplate>}
|
|
30
|
+
*/
|
|
31
|
+
export declare function convertItemToTemplate(itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession, templateDictionary: any): Promise<IItemTemplate>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2018 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.convertItemToTemplate = void 0;
|
|
19
|
+
const solution_simple_types_1 = require("@esri/solution-simple-types");
|
|
20
|
+
/**
|
|
21
|
+
* Creates a template from a Form item
|
|
22
|
+
*
|
|
23
|
+
* @param {any} itemInfo: The base item info
|
|
24
|
+
* @param {UserSession} destAuthentication Credentials for requests to the destination organization
|
|
25
|
+
* @param {UserSession} srcAuthentication Credentials for requests to source items
|
|
26
|
+
* @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
|
|
27
|
+
* @returns {Promise<IItemTemplate>}
|
|
28
|
+
*/
|
|
29
|
+
function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
|
|
30
|
+
// Delegate to simple types
|
|
31
|
+
return solution_simple_types_1.simpleTypes.convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication, templateDictionary);
|
|
32
|
+
}
|
|
33
|
+
exports.convertItemToTemplate = convertItemToTemplate;
|
|
34
|
+
//# sourceMappingURL=convert-item-to-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-item-to-template.js","sourceRoot":"","sources":["../../src/convert-item-to-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AASH,uEAA0D;AAE1D;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACnC,QAAa,EACb,kBAA+B,EAC/B,iBAA8B,EAC9B,kBAAuB;IAEvB,2BAA2B;IAC3B,OAAO,mCAAW,CAAC,qBAAqB,CACtC,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,CACnB,CAAC;AACJ,CAAC;AAbD,sDAaC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2018 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Manages the deployment items from Form templates.
|
|
18
|
+
*
|
|
19
|
+
* @module create-item-from-template
|
|
20
|
+
*/
|
|
21
|
+
import { UserSession, IItemTemplate, IItemProgressCallback, ICreateItemFromTemplateResponse } from "@esri/solution-common";
|
|
22
|
+
/**
|
|
23
|
+
* Creates a Form item from a template
|
|
24
|
+
*
|
|
25
|
+
* @param {IItemTemplate} template The template
|
|
26
|
+
* @param {any} templateDictionary The template dictionary
|
|
27
|
+
* @param {UserSession} destinationAuthentication The destination user session info
|
|
28
|
+
* @param itemProgressCallback An item progress callback
|
|
29
|
+
* @returns {Promise<ICreateItemFromTemplateResponse>}
|
|
30
|
+
*/
|
|
31
|
+
export declare function createItemFromTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2018 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.createItemFromTemplate = void 0;
|
|
19
|
+
const solution_simple_types_1 = require("@esri/solution-simple-types");
|
|
20
|
+
const is_hub_form_template_1 = require("./helpers/is-hub-form-template");
|
|
21
|
+
const create_item_from_hub_template_1 = require("./helpers/create-item-from-hub-template");
|
|
22
|
+
/**
|
|
23
|
+
* Creates a Form item from a template
|
|
24
|
+
*
|
|
25
|
+
* @param {IItemTemplate} template The template
|
|
26
|
+
* @param {any} templateDictionary The template dictionary
|
|
27
|
+
* @param {UserSession} destinationAuthentication The destination user session info
|
|
28
|
+
* @param itemProgressCallback An item progress callback
|
|
29
|
+
* @returns {Promise<ICreateItemFromTemplateResponse>}
|
|
30
|
+
*/
|
|
31
|
+
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
32
|
+
// Hub Form template custom processing
|
|
33
|
+
if ((0, is_hub_form_template_1.isHubFormTemplate)(template)) {
|
|
34
|
+
return (0, create_item_from_hub_template_1.createItemFromHubTemplate)(template, templateDictionary, destinationAuthentication, itemProgressCallback);
|
|
35
|
+
}
|
|
36
|
+
// otherwise delegate to simple types
|
|
37
|
+
return solution_simple_types_1.simpleTypes.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
|
|
38
|
+
}
|
|
39
|
+
exports.createItemFromTemplate = createItemFromTemplate;
|
|
40
|
+
//# sourceMappingURL=create-item-from-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-item-from-template.js","sourceRoot":"","sources":["../../src/create-item-from-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAcH,uEAA0D;AAC1D,yEAAmE;AACnE,2FAAoF;AAEpF;;;;;;;;GAQG;AACH,SAAgB,sBAAsB,CACpC,QAAuB,EACvB,kBAAuB,EACvB,yBAAsC,EACtC,oBAA2C;IAE3C,sCAAsC;IACtC,IAAI,IAAA,wCAAiB,EAAC,QAAQ,CAAC,EAAE;QAC/B,OAAO,IAAA,yDAAyB,EAC9B,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,CACrB,CAAC;KACH;IAED,qCAAqC;IACrC,OAAO,mCAAW,CAAC,sBAAsB,CACvC,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,CACrB,CAAC;AACJ,CAAC;AAvBD,wDAuBC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2024 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import JSZip from "jszip";
|
|
17
|
+
/**
|
|
18
|
+
* Detemplatizes Form data and swizzles the AGO ids of a zip object if they are present in the template dictionary.
|
|
19
|
+
*
|
|
20
|
+
* @param zipObject Zip file to be modified in place
|
|
21
|
+
* @param templateDictionary Dictionary of replacement values
|
|
22
|
+
* @returns Promise that resolves to the updated zip object
|
|
23
|
+
*/
|
|
24
|
+
export declare function swizzleFormObject(zipObject: JSZip, templateDictionary: any): Promise<JSZip>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2024 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.swizzleFormObject = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const common = tslib_1.__importStar(require("@esri/solution-common"));
|
|
21
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
22
|
+
/**
|
|
23
|
+
* Detemplatizes Form data and swizzles the AGO ids of a zip object if they are present in the template dictionary.
|
|
24
|
+
*
|
|
25
|
+
* @param zipObject Zip file to be modified in place
|
|
26
|
+
* @param templateDictionary Dictionary of replacement values
|
|
27
|
+
* @returns Promise that resolves to the updated zip object
|
|
28
|
+
*/
|
|
29
|
+
async function swizzleFormObject(zipObject, templateDictionary) {
|
|
30
|
+
// Get the contents of the zip object
|
|
31
|
+
const zipObjectContents = await common.getZipObjectContents(zipObject);
|
|
32
|
+
// Swizzle the contents of each file in a zip file and replace them in the zip object
|
|
33
|
+
zipObjectContents.forEach((zipFile) => {
|
|
34
|
+
// Detemplatize the file content
|
|
35
|
+
let updatedZipContent = common.replaceInTemplate(zipFile.content, templateDictionary);
|
|
36
|
+
// Find the AGO ids in the file content
|
|
37
|
+
const agoIdRegEx = common.getAgoIdRegEx();
|
|
38
|
+
const agoIdMatches = updatedZipContent.match(agoIdRegEx) ?? [];
|
|
39
|
+
// Replace the matching AGO id in the file content iff it is present in the template dictionary
|
|
40
|
+
agoIdMatches.forEach((match) => {
|
|
41
|
+
const replacement = templateDictionary[match];
|
|
42
|
+
if (typeof replacement?.itemId === "string") {
|
|
43
|
+
if (match === replacement.itemId) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
updatedZipContent = updatedZipContent.replace(new RegExp(match, "g"), `${replacement.itemId}`);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// Replace the file content in the zip object
|
|
50
|
+
zipObject.file(zipFile.file, updatedZipContent);
|
|
51
|
+
});
|
|
52
|
+
return Promise.resolve(zipObject);
|
|
53
|
+
}
|
|
54
|
+
exports.swizzleFormObject = swizzleFormObject;
|
|
55
|
+
//# sourceMappingURL=formUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formUtils.js","sourceRoot":"","sources":["../../src/formUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,sEAAgD;AAGhD,wHAAwH;AAExH;;;;;;GAMG;AACI,KAAK,UAAU,iBAAiB,CACrC,SAAgB,EAChB,kBAAuB;IAEvB,qCAAqC;IACrC,MAAM,iBAAiB,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAEvE,qFAAqF;IACrF,iBAAiB,CAAC,OAAO,CACvB,CAAC,OAAsC,EAAE,EAAE;QACzC,gCAAgC;QAChC,IAAI,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QAEtF,uCAAuC;QACvC,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QAC1C,MAAM,YAAY,GAAG,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QAE/D,+FAA+F;QAC/F,YAAY,CAAC,OAAO,CAAC,CAAC,KAAa,EAAE,EAAE;YACrC,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC9C,IAAI,OAAO,WAAW,EAAE,MAAM,KAAK,QAAQ,EAAE;gBAC3C,IAAI,KAAK,KAAK,WAAW,CAAC,MAAM,EAAE;oBAAE,OAAO;iBAAE;gBAC7C,iBAAiB,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;aAChG;QACH,CAAC,CAAC,CAAC;QAEH,6CAA6C;QAC7C,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAClD,CAAC,CACF,CAAC;IAEF,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACpC,CAAC;AAhCD,8CAgCC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { IItemTemplate, UserSession, ISurvey123CreateParams } from "@esri/solution-common";
|
|
17
|
+
/**
|
|
18
|
+
* Utility method for creating Survey123 parameters
|
|
19
|
+
*
|
|
20
|
+
* @module build-create-params
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Builds the Survey123 create API parameters
|
|
24
|
+
*
|
|
25
|
+
* @param {IItemTemplate} template The template
|
|
26
|
+
* @param {any} templateDictionary The template dictionary
|
|
27
|
+
* @param {UserSession} destinationAuthentication The destination session info
|
|
28
|
+
* @returns {Promise<ISurvey123CreateParams>}
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildCreateParams(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession): Promise<ISurvey123CreateParams>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2020 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.buildCreateParams = void 0;
|
|
19
|
+
const solution_common_1 = require("@esri/solution-common");
|
|
20
|
+
const encode_survey_form_1 = require("./encode-survey-form");
|
|
21
|
+
/**
|
|
22
|
+
* Utility method for creating Survey123 parameters
|
|
23
|
+
*
|
|
24
|
+
* @module build-create-params
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Builds the Survey123 create API parameters
|
|
28
|
+
*
|
|
29
|
+
* @param {IItemTemplate} template The template
|
|
30
|
+
* @param {any} templateDictionary The template dictionary
|
|
31
|
+
* @param {UserSession} destinationAuthentication The destination session info
|
|
32
|
+
* @returns {Promise<ISurvey123CreateParams>}
|
|
33
|
+
*/
|
|
34
|
+
function buildCreateParams(template, templateDictionary, destinationAuthentication) {
|
|
35
|
+
const { item: { title: originalTitle, description, tags, typeKeywords }, properties: { form: unencodedForm } } = template;
|
|
36
|
+
const { user: { username }, portalBaseUrl: portalUrl, organization: { basemapGalleryGroupQuery, defaultBasemap: { title: basemapTitle } } } = templateDictionary;
|
|
37
|
+
const { token } = destinationAuthentication.toCredential();
|
|
38
|
+
return (0, solution_common_1.getPortalDefaultBasemap)(basemapGalleryGroupQuery, basemapTitle, destinationAuthentication).then(defaultBasemap => {
|
|
39
|
+
// The S123 API appends "Survey-" to the survey title when computing
|
|
40
|
+
// the folder name. We need to use the same prefix to successfully
|
|
41
|
+
// calculate a unique folder name. Afterwards, we can safely remove the
|
|
42
|
+
// prefix from the title
|
|
43
|
+
const folderPrefix = "Survey-";
|
|
44
|
+
const title = (0, solution_common_1.getUniqueTitle)(`${folderPrefix}${originalTitle}`, templateDictionary, "user.folders").replace(folderPrefix, "");
|
|
45
|
+
// set any map question's basemaps to default org basemap
|
|
46
|
+
if (unencodedForm.questions) {
|
|
47
|
+
const updateBasemap = (question) => {
|
|
48
|
+
if (question.maps) {
|
|
49
|
+
question.maps = question.maps.map((map) => ({
|
|
50
|
+
...map,
|
|
51
|
+
itemId: defaultBasemap.id
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
return question;
|
|
55
|
+
};
|
|
56
|
+
unencodedForm.questions = unencodedForm.questions.map((question) => !question.questions
|
|
57
|
+
? updateBasemap(question)
|
|
58
|
+
: {
|
|
59
|
+
...question,
|
|
60
|
+
questions: question.questions.map(updateBasemap)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const form = (0, encode_survey_form_1.encodeSurveyForm)(unencodedForm);
|
|
64
|
+
// intentionally undefined, handled downstream by core logic now
|
|
65
|
+
return {
|
|
66
|
+
description,
|
|
67
|
+
form,
|
|
68
|
+
portalUrl,
|
|
69
|
+
tags,
|
|
70
|
+
title,
|
|
71
|
+
token,
|
|
72
|
+
typeKeywords,
|
|
73
|
+
username
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.buildCreateParams = buildCreateParams;
|
|
78
|
+
//# sourceMappingURL=build-create-params.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-create-params.js","sourceRoot":"","sources":["../../../src/helpers/build-create-params.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2DAM+B;AAC/B,6DAAwD;AAExD;;;;GAIG;AAEH;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAC/B,QAAuB,EACvB,kBAAuB,EACvB,yBAAsC;IAEtC,MAAM,EACJ,IAAI,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,EAC/D,UAAU,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EACpC,GAAG,QAAQ,CAAC;IACb,MAAM,EACJ,IAAI,EAAE,EAAE,QAAQ,EAAE,EAClB,aAAa,EAAE,SAAS,EACxB,YAAY,EAAE,EACZ,wBAAwB,EACxB,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EACxC,EACF,GAAG,kBAAkB,CAAC;IACvB,MAAM,EAAE,KAAK,EAAE,GAAG,yBAAyB,CAAC,YAAY,EAAE,CAAC;IAC3D,OAAO,IAAA,yCAAuB,EAC5B,wBAAwB,EACxB,YAAY,EACZ,yBAAyB,CAC1B,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE;QACtB,oEAAoE;QACpE,kEAAkE;QAClE,uEAAuE;QACvE,wBAAwB;QACxB,MAAM,YAAY,GAAG,SAAS,CAAC;QAC/B,MAAM,KAAK,GAAG,IAAA,gCAAc,EAC1B,GAAG,YAAY,GAAG,aAAa,EAAE,EACjC,kBAAkB,EAClB,cAAc,CACf,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC5B,yDAAyD;QACzD,IAAI,aAAa,CAAC,SAAS,EAAE;YAC3B,MAAM,aAAa,GAAG,CAAC,QAAa,EAAE,EAAE;gBACtC,IAAI,QAAQ,CAAC,IAAI,EAAE;oBACjB,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,CAAC;wBAC/C,GAAG,GAAG;wBACN,MAAM,EAAE,cAAc,CAAC,EAAE;qBAC1B,CAAC,CAAC,CAAC;iBACL;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC,CAAC;YACF,aAAa,CAAC,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CACtE,CAAC,QAAQ,CAAC,SAAS;gBACjB,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC;gBACzB,CAAC,CAAC;oBACA,GAAG,QAAQ;oBACX,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC;iBACjD,CACJ,CAAC;SACH;QACD,MAAM,IAAI,GAAG,IAAA,qCAAgB,EAAC,aAAa,CAAC,CAAC;QAC7C,gEAAgE;QAChE,OAAO;YACL,WAAW;YACX,IAAI;YACJ,SAAS;YACT,IAAI;YACJ,KAAK;YACL,KAAK;YACL,YAAY;YACZ,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAlED,8CAkEC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { IItemTemplate, UserSession, IItemProgressCallback, ICreateItemFromTemplateResponse } from "@esri/solution-common";
|
|
17
|
+
/**
|
|
18
|
+
* Manages the creation of Surveys from Hub Templates
|
|
19
|
+
* via the Survey123 API
|
|
20
|
+
*
|
|
21
|
+
* @module create-item-from-hub-template
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Orchestrates creation of Surveys from Hub templates
|
|
25
|
+
*
|
|
26
|
+
* @param {IItemTemplate} template The template
|
|
27
|
+
* @param {any} templateDictionary The template dictionary
|
|
28
|
+
* @param {UserSession} destinationAuthentication The destination session info
|
|
29
|
+
* @param {Function} itemProgressCallback A progress callback
|
|
30
|
+
* @returns {Promise<ICreateItemFromTemplateResponse>}
|
|
31
|
+
*/
|
|
32
|
+
export declare function createItemFromHubTemplate(template: IItemTemplate, templateDictionary: any, destinationAuthentication: UserSession, itemProgressCallback: IItemProgressCallback): Promise<ICreateItemFromTemplateResponse>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2020 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.createItemFromHubTemplate = void 0;
|
|
19
|
+
const solution_common_1 = require("@esri/solution-common");
|
|
20
|
+
const create_survey_1 = require("./create-survey");
|
|
21
|
+
const build_create_params_1 = require("./build-create-params");
|
|
22
|
+
/**
|
|
23
|
+
* Manages the creation of Surveys from Hub Templates
|
|
24
|
+
* via the Survey123 API
|
|
25
|
+
*
|
|
26
|
+
* @module create-item-from-hub-template
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Orchestrates creation of Surveys from Hub templates
|
|
30
|
+
*
|
|
31
|
+
* @param {IItemTemplate} template The template
|
|
32
|
+
* @param {any} templateDictionary The template dictionary
|
|
33
|
+
* @param {UserSession} destinationAuthentication The destination session info
|
|
34
|
+
* @param {Function} itemProgressCallback A progress callback
|
|
35
|
+
* @returns {Promise<ICreateItemFromTemplateResponse>}
|
|
36
|
+
*/
|
|
37
|
+
function createItemFromHubTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
38
|
+
const interpolatedTemplate = (0, solution_common_1.replaceInTemplate)(template, templateDictionary);
|
|
39
|
+
const { survey123Url } = templateDictionary;
|
|
40
|
+
return (0, build_create_params_1.buildCreateParams)(interpolatedTemplate, templateDictionary, destinationAuthentication)
|
|
41
|
+
.then((params) => {
|
|
42
|
+
return (0, create_survey_1.createSurvey)(params, survey123Url);
|
|
43
|
+
})
|
|
44
|
+
.then((createSurveyResponse) => {
|
|
45
|
+
const { formId, featureServiceId } = createSurveyResponse;
|
|
46
|
+
// Update the item with its thumbnail
|
|
47
|
+
let thumbDef = Promise.resolve(null);
|
|
48
|
+
/* istanbul ignore else */
|
|
49
|
+
if (template.item.thumbnail) {
|
|
50
|
+
thumbDef = (0, solution_common_1.updateItemExtended)({ id: formId }, null, destinationAuthentication, template.item.thumbnail);
|
|
51
|
+
}
|
|
52
|
+
return thumbDef
|
|
53
|
+
.then(() => (0, solution_common_1.getItemBase)(formId, destinationAuthentication))
|
|
54
|
+
.then(item => {
|
|
55
|
+
templateDictionary[interpolatedTemplate.itemId] = {
|
|
56
|
+
itemId: formId
|
|
57
|
+
};
|
|
58
|
+
templateDictionary[interpolatedTemplate.properties.info.serviceInfo.itemId] = {
|
|
59
|
+
itemId: featureServiceId
|
|
60
|
+
};
|
|
61
|
+
itemProgressCallback(interpolatedTemplate.itemId, solution_common_1.EItemProgressStatus.Finished, interpolatedTemplate.estimatedDeploymentCostFactor, formId);
|
|
62
|
+
return {
|
|
63
|
+
item: {
|
|
64
|
+
...template,
|
|
65
|
+
item,
|
|
66
|
+
itemId: formId
|
|
67
|
+
},
|
|
68
|
+
id: formId,
|
|
69
|
+
type: "Form",
|
|
70
|
+
postProcess: true
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
})
|
|
74
|
+
.catch(e => {
|
|
75
|
+
itemProgressCallback(interpolatedTemplate.itemId, solution_common_1.EItemProgressStatus.Failed, 0);
|
|
76
|
+
throw e;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
exports.createItemFromHubTemplate = createItemFromHubTemplate;
|
|
80
|
+
//# sourceMappingURL=create-item-from-hub-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-item-from-hub-template.js","sourceRoot":"","sources":["../../../src/helpers/create-item-from-hub-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2DAW+B;AAC/B,mDAA+C;AAC/C,+DAA0D;AAE1D;;;;;GAKG;AAEH;;;;;;;;GAQG;AACH,SAAgB,yBAAyB,CACvC,QAAuB,EACvB,kBAAuB,EACvB,yBAAsC,EACtC,oBAA2C;IAE3C,MAAM,oBAAoB,GAAG,IAAA,mCAAiB,EAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IAC7E,MAAM,EAAE,YAAY,EAAE,GAAG,kBAAkB,CAAC;IAE5C,OAAO,IAAA,uCAAiB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,CAC1B;SACE,IAAI,CAAC,CAAC,MAA8B,EAAE,EAAE;QACvC,OAAO,IAAA,4BAAY,EAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,oBAA4C,EAAE,EAAE;QACrD,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,oBAAoB,CAAC;QAE1D,qCAAqC;QACrC,IAAI,QAAQ,GAAiB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnD,0BAA0B;QAC1B,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE;YAC3B,QAAQ,GAAG,IAAA,oCAAkB,EAC3B,EAAE,EAAE,EAAE,MAAM,EAAE,EACd,IAAI,EACJ,yBAAyB,EACzB,QAAQ,CAAC,IAAI,CAAC,SAAS,CACxB,CAAC;SACH;QAED,OAAO,QAAQ;aACZ,IAAI,CAAC,GAAG,EAAE,CAAC,IAAA,6BAAW,EAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;aAC1D,IAAI,CAAC,IAAI,CAAC,EAAE;YACX,kBAAkB,CAAC,oBAAoB,CAAC,MAAM,CAAC,GAAG;gBAChD,MAAM,EAAE,MAAM;aACf,CAAC;YACF,kBAAkB,CAChB,oBAAoB,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CACxD,GAAG;gBACF,MAAM,EAAE,gBAAgB;aACzB,CAAC;YACF,oBAAoB,CAClB,oBAAoB,CAAC,MAAM,EAC3B,qCAAmB,CAAC,QAAQ,EAC5B,oBAAoB,CAAC,6BAA6B,EAClD,MAAM,CACP,CAAC;YACF,OAAO;gBACL,IAAI,EAAE;oBACJ,GAAG,QAAQ;oBACX,IAAI;oBACJ,MAAM,EAAE,MAAM;iBACf;gBACD,EAAE,EAAE,MAAM;gBACV,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,IAAI;aAClB,CAAC;QACJ,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,CAAC,EAAE;QACT,oBAAoB,CAClB,oBAAoB,CAAC,MAAM,EAC3B,qCAAmB,CAAC,MAAM,EAC1B,CAAC,CACF,CAAC;QACF,MAAM,CAAC,CAAC;IACV,CAAC,CAAC,CAAC;AACP,CAAC;AArED,8DAqEC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ISurvey123CreateParams, ISurvey123CreateResult } from "@esri/solution-common";
|
|
17
|
+
/**
|
|
18
|
+
* Provides utility method to call Survey123 create endpoint
|
|
19
|
+
*
|
|
20
|
+
* @module create-survey
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Calls the Survey123 create API with the given parameters
|
|
24
|
+
*
|
|
25
|
+
* @param {ISurvey123CreateParams} params
|
|
26
|
+
* @param {string} [survey123Url=https://survey123.arcgis.com] An optional, Survey123 base URL override
|
|
27
|
+
* @throws Will throw if the Survey123 API returns an error response
|
|
28
|
+
* @returns {Promise<ISurvey123CreateResult>}
|
|
29
|
+
*/
|
|
30
|
+
export declare function createSurvey(params: ISurvey123CreateParams, survey123Url?: string): Promise<ISurvey123CreateResult>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2020 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.createSurvey = void 0;
|
|
19
|
+
const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
|
|
20
|
+
/**
|
|
21
|
+
* Provides utility method to call Survey123 create endpoint
|
|
22
|
+
*
|
|
23
|
+
* @module create-survey
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Calls the Survey123 create API with the given parameters
|
|
27
|
+
*
|
|
28
|
+
* @param {ISurvey123CreateParams} params
|
|
29
|
+
* @param {string} [survey123Url=https://survey123.arcgis.com] An optional, Survey123 base URL override
|
|
30
|
+
* @throws Will throw if the Survey123 API returns an error response
|
|
31
|
+
* @returns {Promise<ISurvey123CreateResult>}
|
|
32
|
+
*/
|
|
33
|
+
function createSurvey(params, survey123Url = "https://survey123.arcgis.com") {
|
|
34
|
+
const createUrl = `${survey123Url}/api/survey/create`;
|
|
35
|
+
const ro = {
|
|
36
|
+
credentials: "same-origin",
|
|
37
|
+
method: "POST",
|
|
38
|
+
body: (0, arcgis_rest_request_1.encodeFormData)({
|
|
39
|
+
f: "json",
|
|
40
|
+
...params
|
|
41
|
+
}, true)
|
|
42
|
+
};
|
|
43
|
+
// Using @esri/arcgis-request "request" method was resulting in a 404 for
|
|
44
|
+
// a CORS preflight request related to this request, but calling fetch directly
|
|
45
|
+
// circumvents the issue.
|
|
46
|
+
return fetch(createUrl, ro)
|
|
47
|
+
.then(response => response.json())
|
|
48
|
+
.then(response => {
|
|
49
|
+
if (!response.success) {
|
|
50
|
+
throw new Error(`Failed to create survey: ${response.error.message}`);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
formId: response.id,
|
|
54
|
+
featureServiceId: response.featureService.source.itemId,
|
|
55
|
+
folderId: response.formItemInfo.ownerFolder
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.createSurvey = createSurvey;
|
|
60
|
+
//# sourceMappingURL=create-survey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-survey.js","sourceRoot":"","sources":["../../../src/helpers/create-survey.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAMH,mEAA2D;AAE3D;;;;GAIG;AAEH;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC1B,MAA8B,EAC9B,YAAY,GAAG,8BAA8B;IAE7C,MAAM,SAAS,GAAG,GAAG,YAAY,oBAAoB,CAAC;IACtD,MAAM,EAAE,GAAG;QACT,WAAW,EAAE,aAAmC;QAChD,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAA,oCAAc,EAClB;YACE,CAAC,EAAE,MAAM;YACT,GAAG,MAAM;SACV,EACD,IAAI,CACL;KACF,CAAC;IACF,yEAAyE;IACzE,+EAA+E;IAC/E,yBAAyB;IACzB,OAAO,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;SACxB,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;SACjC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACf,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACrB,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;SACvE;QACD,OAAO;YACL,MAAM,EAAE,QAAQ,CAAC,EAAE;YACnB,gBAAgB,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM;YACvD,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,WAAW;SAC5C,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC;AA/BD,oCA+BC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Manages Survey123 parameter encoding
|
|
18
|
+
*
|
|
19
|
+
* @module encode-survey-form
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* URI Encodes Survey123 form content parameter
|
|
23
|
+
* values
|
|
24
|
+
*
|
|
25
|
+
* @param {any} form Unencoded form data
|
|
26
|
+
* @returns {any} Encoded form data
|
|
27
|
+
*/
|
|
28
|
+
export declare const encodeSurveyForm: (form: any) => any;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2020 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.encodeSurveyForm = void 0;
|
|
19
|
+
const solution_common_1 = require("@esri/solution-common");
|
|
20
|
+
/**
|
|
21
|
+
* Manages Survey123 parameter encoding
|
|
22
|
+
*
|
|
23
|
+
* @module encode-survey-form
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* URI Encodes Survey123 form content parameter
|
|
27
|
+
* values
|
|
28
|
+
*
|
|
29
|
+
* @param {any} form Unencoded form data
|
|
30
|
+
* @returns {any} Encoded form data
|
|
31
|
+
*/
|
|
32
|
+
const encodeSurveyForm = function encodeForm(form) {
|
|
33
|
+
const clone = (0, solution_common_1.cloneObject)(form);
|
|
34
|
+
const props = [
|
|
35
|
+
["header", "content"],
|
|
36
|
+
["subHeader", "content"],
|
|
37
|
+
["footer", "content"],
|
|
38
|
+
["settings", "thankYouScreenContent"]
|
|
39
|
+
];
|
|
40
|
+
const encode = (obj, key) => {
|
|
41
|
+
if (obj && obj[key]) {
|
|
42
|
+
obj[key] = encodeURIComponent(obj[key]);
|
|
43
|
+
}
|
|
44
|
+
return obj;
|
|
45
|
+
};
|
|
46
|
+
// encode props from array above
|
|
47
|
+
props.forEach(([objKey, propKey]) => encode(clone[objKey], propKey));
|
|
48
|
+
const encodeQuestion = (question) => encode(question, "description");
|
|
49
|
+
// encode question descriptions
|
|
50
|
+
clone.questions = (clone.questions || []).map((question) => !question.questions
|
|
51
|
+
? encodeQuestion(question)
|
|
52
|
+
: {
|
|
53
|
+
...question,
|
|
54
|
+
questions: question.questions.map(encodeQuestion)
|
|
55
|
+
});
|
|
56
|
+
return clone;
|
|
57
|
+
};
|
|
58
|
+
exports.encodeSurveyForm = encodeSurveyForm;
|
|
59
|
+
//# sourceMappingURL=encode-survey-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode-survey-form.js","sourceRoot":"","sources":["../../../src/helpers/encode-survey-form.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2DAAoD;AAEpD;;;;GAIG;AAEH;;;;;;GAMG;AACI,MAAM,gBAAgB,GAAG,SAAS,UAAU,CAAC,IAAS;IAC3D,MAAM,KAAK,GAAG,IAAA,6BAAW,EAAC,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG;QACZ,CAAC,QAAQ,EAAE,SAAS,CAAC;QACrB,CAAC,WAAW,EAAE,SAAS,CAAC;QACxB,CAAC,QAAQ,EAAE,SAAS,CAAC;QACrB,CAAC,UAAU,EAAE,uBAAuB,CAAC;KACtC,CAAC;IACF,MAAM,MAAM,GAAG,CACb,GAA8B,EAC9B,GAAW,EACgB,EAAE;QAC7B,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE;YACnB,GAAG,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SACzC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;IAEF,gCAAgC;IAChC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAErE,MAAM,cAAc,GAAG,CAAC,QAAa,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAE1E,+BAA+B;IAC/B,KAAK,CAAC,SAAS,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CAC9D,CAAC,QAAQ,CAAC,SAAS;QACjB,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC;QAC1B,CAAC,CAAC;YACA,GAAG,QAAQ;YACX,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC;SAClD,CACJ,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAlCW,QAAA,gBAAgB,oBAkC3B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import * as common from "@esri/solution-common";
|
|
17
|
+
/**
|
|
18
|
+
* Determines if the given template is a Hub Survey
|
|
19
|
+
* template vs Solutions.js Survey template.
|
|
20
|
+
*
|
|
21
|
+
* @param {IITemTemplate} template A template
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export declare function isHubFormTemplate(template: common.IItemTemplate): boolean;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2020 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.isHubFormTemplate = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
const common = tslib_1.__importStar(require("@esri/solution-common"));
|
|
21
|
+
/**
|
|
22
|
+
* Determines if the given template is a Hub Survey
|
|
23
|
+
* template vs Solutions.js Survey template.
|
|
24
|
+
*
|
|
25
|
+
* @param {IITemTemplate} template A template
|
|
26
|
+
* @returns {boolean}
|
|
27
|
+
*/
|
|
28
|
+
function isHubFormTemplate(template) {
|
|
29
|
+
// relying on basic duck typing vs adding extraneous props during migration
|
|
30
|
+
return !!common.getProp(template, "properties.services");
|
|
31
|
+
}
|
|
32
|
+
exports.isHubFormTemplate = isHubFormTemplate;
|
|
33
|
+
//# sourceMappingURL=is-hub-form-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-hub-form-template.js","sourceRoot":"","sources":["../../../src/helpers/is-hub-form-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,sEAAgD;AAEhD;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,QAA8B;IAC9D,2EAA2E;IAC3E,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;AAC3D,CAAC;AAHD,8CAGC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { UserSession, IItemTemplate } from "@esri/solution-common";
|
|
17
|
+
/**
|
|
18
|
+
* Provides utility method to post process Hub surveys
|
|
19
|
+
*
|
|
20
|
+
* @module post-process-survey
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Performs Survey post processing actions
|
|
24
|
+
*
|
|
25
|
+
* @param {string} itemId The item ID
|
|
26
|
+
* @param {string} type The template/item type
|
|
27
|
+
* @param {any[]} itemInfos An Array of item details
|
|
28
|
+
* @param {IItemTemplate} template The template
|
|
29
|
+
* @param {any} templateDictionary The template dictionary
|
|
30
|
+
* @param {UserSession} authentication The destination session info
|
|
31
|
+
* @returns {Promise<any>}
|
|
32
|
+
*/
|
|
33
|
+
export declare function postProcessHubSurvey(itemId: string, type: string, itemInfos: any[], template: IItemTemplate, templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<any>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2020 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.postProcessHubSurvey = void 0;
|
|
19
|
+
const solution_common_1 = require("@esri/solution-common");
|
|
20
|
+
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
|
|
21
|
+
/**
|
|
22
|
+
* Provides utility method to post process Hub surveys
|
|
23
|
+
*
|
|
24
|
+
* @module post-process-survey
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Performs Survey post processing actions
|
|
28
|
+
*
|
|
29
|
+
* @param {string} itemId The item ID
|
|
30
|
+
* @param {string} type The template/item type
|
|
31
|
+
* @param {any[]} itemInfos An Array of item details
|
|
32
|
+
* @param {IItemTemplate} template The template
|
|
33
|
+
* @param {any} templateDictionary The template dictionary
|
|
34
|
+
* @param {UserSession} authentication The destination session info
|
|
35
|
+
* @returns {Promise<any>}
|
|
36
|
+
*/
|
|
37
|
+
function postProcessHubSurvey(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
|
|
38
|
+
const featureServiceSourceId = template.properties.info.serviceInfo.itemId;
|
|
39
|
+
const { itemId: featureServiceResultId } = templateDictionary[featureServiceSourceId];
|
|
40
|
+
const interpolated = (0, solution_common_1.replaceInTemplate)(template, templateDictionary);
|
|
41
|
+
return (0, solution_common_1.getItemBase)(featureServiceResultId, authentication).then(featureServiceResultBase => {
|
|
42
|
+
const itemUpdates = [
|
|
43
|
+
// fix/update form properties we couldn't control via the API
|
|
44
|
+
{
|
|
45
|
+
id: itemId,
|
|
46
|
+
title: interpolated.item.title,
|
|
47
|
+
snippet: interpolated.item.snippet,
|
|
48
|
+
extent: interpolated.item.extent,
|
|
49
|
+
culture: interpolated.item.culture
|
|
50
|
+
},
|
|
51
|
+
// fix/update feature service properties we couldn't control via the API
|
|
52
|
+
{
|
|
53
|
+
id: featureServiceResultId,
|
|
54
|
+
extent: interpolated.item.extent,
|
|
55
|
+
typeKeywords: [`source-${featureServiceSourceId}`].concat(featureServiceResultBase.typeKeywords)
|
|
56
|
+
}
|
|
57
|
+
];
|
|
58
|
+
const toUpdatePromise = (updatedItem) => (0, solution_common_1.updateItem)(updatedItem, authentication);
|
|
59
|
+
const updatePromises = itemUpdates.map(toUpdatePromise);
|
|
60
|
+
return Promise.all(updatePromises)
|
|
61
|
+
.then(() => {
|
|
62
|
+
const itemIdsToMove = [itemId, featureServiceResultId];
|
|
63
|
+
const toMovePromise = (id) => (0, arcgis_rest_portal_1.moveItem)({
|
|
64
|
+
itemId: id,
|
|
65
|
+
folderId: templateDictionary.folderId,
|
|
66
|
+
authentication: authentication
|
|
67
|
+
});
|
|
68
|
+
const movePromises = itemIdsToMove.map(toMovePromise);
|
|
69
|
+
return Promise.all(movePromises);
|
|
70
|
+
})
|
|
71
|
+
.then(() => (0, solution_common_1.removeFolder)(featureServiceResultBase.ownerFolder, authentication))
|
|
72
|
+
.then(() => {
|
|
73
|
+
// Create a template item for the Feature Service that was created by the API
|
|
74
|
+
const featureServiceTemplate = (0, solution_common_1.createInitializedItemTemplate)(featureServiceResultBase);
|
|
75
|
+
templates.push(featureServiceTemplate);
|
|
76
|
+
template.dependencies.push(featureServiceResultBase.id);
|
|
77
|
+
return true;
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
exports.postProcessHubSurvey = postProcessHubSurvey;
|
|
82
|
+
//# sourceMappingURL=post-process-survey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-process-survey.js","sourceRoot":"","sources":["../../../src/helpers/post-process-survey.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2DAS+B;AAC/B,iEAAoD;AAEpD;;;;GAIG;AAEH;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAClC,MAAc,EACd,IAAY,EACZ,SAAgB,EAChB,QAAuB,EACvB,SAA0B,EAC1B,kBAAuB,EACvB,cAA2B;IAE3B,MAAM,sBAAsB,GAAG,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IAC3E,MAAM,EAAE,MAAM,EAAE,sBAAsB,EAAE,GAAG,kBAAkB,CAC3D,sBAAsB,CACvB,CAAC;IACF,MAAM,YAAY,GAAG,IAAA,mCAAiB,EAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;IACrE,OAAO,IAAA,6BAAW,EAAC,sBAAsB,EAAE,cAAc,CAAC,CAAC,IAAI,CAC7D,wBAAwB,CAAC,EAAE;QACzB,MAAM,WAAW,GAAG;YAClB,6DAA6D;YAC7D;gBACE,EAAE,EAAE,MAAM;gBACV,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC,KAAK;gBAC9B,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO;gBAClC,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,MAAM;gBAChC,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO;aACnC;YACD,wEAAwE;YACxE;gBACE,EAAE,EAAE,sBAAsB;gBAC1B,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,MAAM;gBAChC,YAAY,EAAE,CAAC,UAAU,sBAAsB,EAAE,CAAC,CAAC,MAAM,CACvD,wBAAwB,CAAC,YAAY,CACtC;aACF;SACF,CAAC;QACF,MAAM,eAAe,GAAG,CAAC,WAAwB,EAAE,EAAE,CACnD,IAAA,4BAAU,EAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAC1C,MAAM,cAAc,GAAG,WAAW,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACxD,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;aAC/B,IAAI,CAAC,GAAG,EAAE;YACT,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;YACvD,MAAM,aAAa,GAAG,CAAC,EAAU,EAAE,EAAE,CACnC,IAAA,6BAAQ,EAAC;gBACP,MAAM,EAAE,EAAE;gBACV,QAAQ,EAAE,kBAAkB,CAAC,QAAkB;gBAC/C,cAAc,EAAE,cAAc;aAC/B,CAAC,CAAC;YACL,MAAM,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YACtD,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,EAAE,CACT,IAAA,8BAAY,EAAC,wBAAwB,CAAC,WAAW,EAAE,cAAc,CAAC,CACnE;aACA,IAAI,CAAC,GAAG,EAAE;YACT,6EAA6E;YAC7E,MAAM,sBAAsB,GAAG,IAAA,+CAA6B,EAC1D,wBAAwB,CACzB,CAAC;YACF,SAAS,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YACvC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC;YACxD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC,CACF,CAAC;AACJ,CAAC;AA/DD,oDA+DC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2018 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Manages the creation and deployment of form item types.
|
|
18
|
+
*
|
|
19
|
+
* @module solution-form
|
|
20
|
+
*/
|
|
21
|
+
export * from "./convert-item-to-template";
|
|
22
|
+
export * from "./create-item-from-template";
|
|
23
|
+
export * from "./formUtils";
|
|
24
|
+
export * from "./post-process";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2018 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const tslib_1 = require("tslib");
|
|
19
|
+
/**
|
|
20
|
+
* Manages the creation and deployment of form item types.
|
|
21
|
+
*
|
|
22
|
+
* @module solution-form
|
|
23
|
+
*/
|
|
24
|
+
tslib_1.__exportStar(require("./convert-item-to-template"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./create-item-from-template"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./formUtils"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./post-process"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,qEAA2C;AAC3C,sEAA4C;AAC5C,sDAA4B;AAC5B,yDAA+B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2018 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import * as common from "@esri/solution-common";
|
|
17
|
+
/**
|
|
18
|
+
* Form post-processing actions
|
|
19
|
+
*
|
|
20
|
+
* @param {string} itemId The item ID
|
|
21
|
+
* @param {string} type The template type
|
|
22
|
+
* @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
|
|
23
|
+
* @param {any} templateDictionary The template dictionary
|
|
24
|
+
* @param {UserSession} authentication The destination session info
|
|
25
|
+
* @returns Promise resolving to successfulness of update
|
|
26
|
+
*/
|
|
27
|
+
export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: common.IItemTemplate, templates: common.IItemTemplate[], templateDictionary: any, authentication: common.UserSession): Promise<any>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** @license
|
|
3
|
+
* Copyright 2018 Esri
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.postProcess = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
20
|
+
/**
|
|
21
|
+
* Manages the creation and deployment of form item types.
|
|
22
|
+
*
|
|
23
|
+
* @module post-process
|
|
24
|
+
*/
|
|
25
|
+
const is_hub_form_template_1 = require("./helpers/is-hub-form-template");
|
|
26
|
+
const post_process_survey_1 = require("./helpers/post-process-survey");
|
|
27
|
+
const common = tslib_1.__importStar(require("@esri/solution-common"));
|
|
28
|
+
const formUtils = tslib_1.__importStar(require("./formUtils"));
|
|
29
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
30
|
+
/**
|
|
31
|
+
* Form post-processing actions
|
|
32
|
+
*
|
|
33
|
+
* @param {string} itemId The item ID
|
|
34
|
+
* @param {string} type The template type
|
|
35
|
+
* @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
|
|
36
|
+
* @param {any} templateDictionary The template dictionary
|
|
37
|
+
* @param {UserSession} authentication The destination session info
|
|
38
|
+
* @returns Promise resolving to successfulness of update
|
|
39
|
+
*/
|
|
40
|
+
async function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
|
|
41
|
+
// Fetch the form's zip file
|
|
42
|
+
const formDataResponse = await common.getItemDataAsFile(itemId, "Form", authentication);
|
|
43
|
+
if (formDataResponse) {
|
|
44
|
+
const zipObject = await common.blobToZipObject(formDataResponse);
|
|
45
|
+
// Detemplatize it
|
|
46
|
+
const updatedZipObject = await formUtils.swizzleFormObject(zipObject, templateDictionary);
|
|
47
|
+
// Update the form
|
|
48
|
+
void common.updateItemWithZipObject(updatedZipObject, itemId, authentication);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// If the form data is not found, AGO is slow storing the data; try again
|
|
52
|
+
await common.delay(5000);
|
|
53
|
+
return postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication);
|
|
54
|
+
}
|
|
55
|
+
// If this is a Hub form, post-process it as such
|
|
56
|
+
if ((0, is_hub_form_template_1.isHubFormTemplate)(template)) {
|
|
57
|
+
return (0, post_process_survey_1.postProcessHubSurvey)(itemId, type, itemInfos, template, templates, templateDictionary, authentication);
|
|
58
|
+
}
|
|
59
|
+
// Otherwise, just update the item's template
|
|
60
|
+
return common.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
|
|
61
|
+
}
|
|
62
|
+
exports.postProcess = postProcess;
|
|
63
|
+
//# sourceMappingURL=post-process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-process.js","sourceRoot":"","sources":["../../src/post-process.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH,yEAAmE;AACnE,uEAAqE;AACrE,sEAAgD;AAChD,+DAAyC;AAGzC,wHAAwH;AAExH;;;;;;;;;GASG;AACI,KAAK,UAAU,WAAW,CAC/B,MAAc,EACd,IAAY,EACZ,SAAgB,EAChB,QAA8B,EAC9B,SAAiC,EACjC,kBAAuB,EACvB,cAAkC;IAElC,4BAA4B;IAC5B,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;IACxF,IAAI,gBAAgB,EAAE;QACpB,MAAM,SAAS,GAAU,MAAM,MAAM,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;QAExE,kBAAkB;QAClB,MAAM,gBAAgB,GAAG,MAAM,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;QAE1F,kBAAkB;QAClB,KAAK,MAAM,CAAC,uBAAuB,CAAC,gBAAgB,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;KAE/E;SAAM;QACL,yEAAyE;QACzE,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzB,OAAO,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAE,cAAc,CAAC,CAAC;KACtG;IAED,iDAAiD;IACjD,IAAI,IAAA,wCAAiB,EAAC,QAAQ,CAAC,EAAE;QAC/B,OAAO,IAAA,0CAAoB,EACzB,MAAM,EACN,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,cAAc,CACf,CAAC;KACH;IAED,6CAA6C;IAC7C,OAAO,MAAM,CAAC,gCAAgC,CAC5C,MAAM,EACN,kBAAkB,EAClB,cAAc,CACf,CAAC;AACJ,CAAC;AA7CD,kCA6CC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/solution-form",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.4",
|
|
4
4
|
"description": "Manages the creation and deployment of form item types for @esri/solution.js.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"@esri/hub-initiatives": "^14.0.0",
|
|
28
28
|
"@esri/hub-sites": "^14.2.2",
|
|
29
29
|
"@esri/hub-teams": "^14.1.0",
|
|
30
|
-
"@esri/solution-common": "^5.2.
|
|
31
|
-
"@esri/solution-feature-layer": "^5.2.
|
|
32
|
-
"@esri/solution-file": "^5.2.
|
|
33
|
-
"@esri/solution-group": "^5.2.
|
|
34
|
-
"@esri/solution-simple-types": "^5.2.
|
|
35
|
-
"@esri/solution-storymap": "^5.2.
|
|
30
|
+
"@esri/solution-common": "^5.2.4",
|
|
31
|
+
"@esri/solution-feature-layer": "^5.2.4",
|
|
32
|
+
"@esri/solution-file": "^5.2.4",
|
|
33
|
+
"@esri/solution-group": "^5.2.4",
|
|
34
|
+
"@esri/solution-simple-types": "^5.2.4",
|
|
35
|
+
"@esri/solution-storymap": "^5.2.4",
|
|
36
36
|
"@types/jasmine": "^5.1.4",
|
|
37
37
|
"fetch-mock": "^7.7.3",
|
|
38
38
|
"jasmine": "^5.1.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"esri",
|
|
79
79
|
"ES6"
|
|
80
80
|
],
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "c3329c6814c1d7b898eb130bf3a7feeda12f074f"
|
|
82
82
|
}
|