@esri/solution-form 5.2.2 → 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/formUtils.d.ts +24 -0
- package/dist/cjs/formUtils.js +55 -0
- package/dist/cjs/formUtils.js.map +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/post-process.d.ts +2 -7
- package/dist/cjs/post-process.js +22 -3
- package/dist/cjs/post-process.js.map +1 -1
- package/dist/esm/formUtils.d.ts +24 -0
- package/dist/esm/formUtils.js +50 -0
- package/dist/esm/formUtils.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +3 -0
- package/dist/esm/post-process.d.ts +2 -7
- package/dist/esm/post-process.js +21 -3
- package/dist/esm/post-process.js.map +1 -1
- package/package.json +9 -9
|
@@ -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"}
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -23,5 +23,6 @@ const tslib_1 = require("tslib");
|
|
|
23
23
|
*/
|
|
24
24
|
tslib_1.__exportStar(require("./convert-item-to-template"), exports);
|
|
25
25
|
tslib_1.__exportStar(require("./create-item-from-template"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./formUtils"), exports);
|
|
26
27
|
tslib_1.__exportStar(require("./post-process"), exports);
|
|
27
28
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,qEAA2C;AAC3C,sEAA4C;AAC5C,yDAA+B"}
|
|
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"}
|
|
@@ -13,12 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
* Manages the creation and deployment of form item types.
|
|
18
|
-
*
|
|
19
|
-
* @module post-process
|
|
20
|
-
*/
|
|
21
|
-
import { UserSession, IItemTemplate } from "@esri/solution-common";
|
|
16
|
+
import * as common from "@esri/solution-common";
|
|
22
17
|
/**
|
|
23
18
|
* Form post-processing actions
|
|
24
19
|
*
|
|
@@ -29,4 +24,4 @@ import { UserSession, IItemTemplate } from "@esri/solution-common";
|
|
|
29
24
|
* @param {UserSession} authentication The destination session info
|
|
30
25
|
* @returns Promise resolving to successfulness of update
|
|
31
26
|
*/
|
|
32
|
-
export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: IItemTemplate, templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<any>;
|
|
27
|
+
export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: common.IItemTemplate, templates: common.IItemTemplate[], templateDictionary: any, authentication: common.UserSession): Promise<any>;
|
package/dist/cjs/post-process.js
CHANGED
|
@@ -16,14 +16,17 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.postProcess = void 0;
|
|
19
|
+
const tslib_1 = require("tslib");
|
|
19
20
|
/**
|
|
20
21
|
* Manages the creation and deployment of form item types.
|
|
21
22
|
*
|
|
22
23
|
* @module post-process
|
|
23
24
|
*/
|
|
24
|
-
const solution_common_1 = require("@esri/solution-common");
|
|
25
25
|
const is_hub_form_template_1 = require("./helpers/is-hub-form-template");
|
|
26
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
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
27
30
|
/**
|
|
28
31
|
* Form post-processing actions
|
|
29
32
|
*
|
|
@@ -34,11 +37,27 @@ const post_process_survey_1 = require("./helpers/post-process-survey");
|
|
|
34
37
|
* @param {UserSession} authentication The destination session info
|
|
35
38
|
* @returns Promise resolving to successfulness of update
|
|
36
39
|
*/
|
|
37
|
-
function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
|
|
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
|
|
38
56
|
if ((0, is_hub_form_template_1.isHubFormTemplate)(template)) {
|
|
39
57
|
return (0, post_process_survey_1.postProcessHubSurvey)(itemId, type, itemInfos, template, templates, templateDictionary, authentication);
|
|
40
58
|
}
|
|
41
|
-
|
|
59
|
+
// Otherwise, just update the item's template
|
|
60
|
+
return common.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
|
|
42
61
|
}
|
|
43
62
|
exports.postProcess = postProcess;
|
|
44
63
|
//# sourceMappingURL=post-process.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-process.js","sourceRoot":"","sources":["../../src/post-process.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
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"}
|
|
@@ -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,50 @@
|
|
|
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 * as common from "@esri/solution-common";
|
|
17
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
18
|
+
/**
|
|
19
|
+
* Detemplatizes Form data and swizzles the AGO ids of a zip object if they are present in the template dictionary.
|
|
20
|
+
*
|
|
21
|
+
* @param zipObject Zip file to be modified in place
|
|
22
|
+
* @param templateDictionary Dictionary of replacement values
|
|
23
|
+
* @returns Promise that resolves to the updated zip object
|
|
24
|
+
*/
|
|
25
|
+
export async function swizzleFormObject(zipObject, templateDictionary) {
|
|
26
|
+
// Get the contents of the zip object
|
|
27
|
+
const zipObjectContents = await common.getZipObjectContents(zipObject);
|
|
28
|
+
// Swizzle the contents of each file in a zip file and replace them in the zip object
|
|
29
|
+
zipObjectContents.forEach((zipFile) => {
|
|
30
|
+
// Detemplatize the file content
|
|
31
|
+
let updatedZipContent = common.replaceInTemplate(zipFile.content, templateDictionary);
|
|
32
|
+
// Find the AGO ids in the file content
|
|
33
|
+
const agoIdRegEx = common.getAgoIdRegEx();
|
|
34
|
+
const agoIdMatches = updatedZipContent.match(agoIdRegEx) ?? [];
|
|
35
|
+
// Replace the matching AGO id in the file content iff it is present in the template dictionary
|
|
36
|
+
agoIdMatches.forEach((match) => {
|
|
37
|
+
const replacement = templateDictionary[match];
|
|
38
|
+
if (typeof replacement?.itemId === "string") {
|
|
39
|
+
if (match === replacement.itemId) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
updatedZipContent = updatedZipContent.replace(new RegExp(match, "g"), `${replacement.itemId}`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
// Replace the file content in the zip object
|
|
46
|
+
zipObject.file(zipFile.file, updatedZipContent);
|
|
47
|
+
});
|
|
48
|
+
return Promise.resolve(zipObject);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=formUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formUtils.js","sourceRoot":"","sources":["../../src/formUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAGhD,wHAAwH;AAExH;;;;;;GAMG;AACH,MAAM,CAAC,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"}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
|
@@ -13,12 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
* Manages the creation and deployment of form item types.
|
|
18
|
-
*
|
|
19
|
-
* @module post-process
|
|
20
|
-
*/
|
|
21
|
-
import { UserSession, IItemTemplate } from "@esri/solution-common";
|
|
16
|
+
import * as common from "@esri/solution-common";
|
|
22
17
|
/**
|
|
23
18
|
* Form post-processing actions
|
|
24
19
|
*
|
|
@@ -29,4 +24,4 @@ import { UserSession, IItemTemplate } from "@esri/solution-common";
|
|
|
29
24
|
* @param {UserSession} authentication The destination session info
|
|
30
25
|
* @returns Promise resolving to successfulness of update
|
|
31
26
|
*/
|
|
32
|
-
export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: IItemTemplate, templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<any>;
|
|
27
|
+
export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: common.IItemTemplate, templates: common.IItemTemplate[], templateDictionary: any, authentication: common.UserSession): Promise<any>;
|
package/dist/esm/post-process.js
CHANGED
|
@@ -18,9 +18,11 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @module post-process
|
|
20
20
|
*/
|
|
21
|
-
import { updateItemTemplateFromDictionary } from "@esri/solution-common";
|
|
22
21
|
import { isHubFormTemplate } from "./helpers/is-hub-form-template";
|
|
23
22
|
import { postProcessHubSurvey } from "./helpers/post-process-survey";
|
|
23
|
+
import * as common from "@esri/solution-common";
|
|
24
|
+
import * as formUtils from "./formUtils";
|
|
25
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
24
26
|
/**
|
|
25
27
|
* Form post-processing actions
|
|
26
28
|
*
|
|
@@ -31,10 +33,26 @@ import { postProcessHubSurvey } from "./helpers/post-process-survey";
|
|
|
31
33
|
* @param {UserSession} authentication The destination session info
|
|
32
34
|
* @returns Promise resolving to successfulness of update
|
|
33
35
|
*/
|
|
34
|
-
export function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
|
|
36
|
+
export async function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
|
|
37
|
+
// Fetch the form's zip file
|
|
38
|
+
const formDataResponse = await common.getItemDataAsFile(itemId, "Form", authentication);
|
|
39
|
+
if (formDataResponse) {
|
|
40
|
+
const zipObject = await common.blobToZipObject(formDataResponse);
|
|
41
|
+
// Detemplatize it
|
|
42
|
+
const updatedZipObject = await formUtils.swizzleFormObject(zipObject, templateDictionary);
|
|
43
|
+
// Update the form
|
|
44
|
+
void common.updateItemWithZipObject(updatedZipObject, itemId, authentication);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// If the form data is not found, AGO is slow storing the data; try again
|
|
48
|
+
await common.delay(5000);
|
|
49
|
+
return postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication);
|
|
50
|
+
}
|
|
51
|
+
// If this is a Hub form, post-process it as such
|
|
35
52
|
if (isHubFormTemplate(template)) {
|
|
36
53
|
return postProcessHubSurvey(itemId, type, itemInfos, template, templates, templateDictionary, authentication);
|
|
37
54
|
}
|
|
38
|
-
|
|
55
|
+
// Otherwise, just update the item's template
|
|
56
|
+
return common.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
|
|
39
57
|
}
|
|
40
58
|
//# sourceMappingURL=post-process.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-process.js","sourceRoot":"","sources":["../../src/post-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"post-process.js","sourceRoot":"","sources":["../../src/post-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAGzC,wHAAwH;AAExH;;;;;;;;;GASG;AACH,MAAM,CAAC,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,iBAAiB,CAAC,QAAQ,CAAC,EAAE;QAC/B,OAAO,oBAAoB,CACzB,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"}
|
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",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"@esri/arcgis-rest-portal": "^3.7.0",
|
|
24
24
|
"@esri/arcgis-rest-request": "^3.7.0",
|
|
25
25
|
"@esri/arcgis-rest-service-admin": "^3.7.0",
|
|
26
|
-
"@esri/hub-common": "^14.
|
|
26
|
+
"@esri/hub-common": "^14.97.0",
|
|
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
|
}
|