@esri/solution-form 5.2.7 → 5.2.9
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 +17 -0
- package/dist/cjs/formUtils.js +62 -17
- package/dist/cjs/formUtils.js.map +1 -1
- package/dist/cjs/post-process.js +1 -1
- package/dist/cjs/post-process.js.map +1 -1
- package/dist/esm/formUtils.d.ts +17 -0
- package/dist/esm/formUtils.js +59 -16
- package/dist/esm/formUtils.js.map +1 -1
- package/dist/esm/post-process.js +1 -1
- package/dist/esm/post-process.js.map +1 -1
- package/package.json +11 -11
package/dist/cjs/formUtils.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import * as common from "@esri/solution-common";
|
|
16
17
|
import JSZip from "jszip";
|
|
17
18
|
/**
|
|
18
19
|
* Detemplatizes Form data and swizzles the AGO ids of a zip object if they are present in the template dictionary.
|
|
@@ -22,3 +23,19 @@ import JSZip from "jszip";
|
|
|
22
23
|
* @returns Promise that resolves to the updated zip object
|
|
23
24
|
*/
|
|
24
25
|
export declare function swizzleFormObject(zipObject: JSZip, templateDictionary: any): Promise<JSZip>;
|
|
26
|
+
/**
|
|
27
|
+
* Updates the binary content of a zip object.
|
|
28
|
+
*
|
|
29
|
+
* @param zipFileItem Zip file item
|
|
30
|
+
* @param templateDictionary Dictionary of replacement values
|
|
31
|
+
* @returns Promise that resolves to the updated zip file item
|
|
32
|
+
*/
|
|
33
|
+
export declare function _updateZipObjectBinaryContent(zipFileItem: common.IZipObjectContentItem, templateDictionary: any): Promise<common.IZipObjectContentItem>;
|
|
34
|
+
/**
|
|
35
|
+
* Updates the text content of a zip object.
|
|
36
|
+
*
|
|
37
|
+
* @param zipFileItem Zip file item
|
|
38
|
+
* @param templateDictionary Dictionary of replacement values
|
|
39
|
+
* @returns Updated zip file item text content
|
|
40
|
+
*/
|
|
41
|
+
export declare function _updateZipObjectTextContent(zipFileItem: common.IZipObjectContentItem, templateDictionary: any): string;
|
package/dist/cjs/formUtils.js
CHANGED
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.swizzleFormObject = void 0;
|
|
18
|
+
exports._updateZipObjectTextContent = exports._updateZipObjectBinaryContent = exports.swizzleFormObject = void 0;
|
|
19
19
|
const tslib_1 = require("tslib");
|
|
20
20
|
const common = tslib_1.__importStar(require("@esri/solution-common"));
|
|
21
|
+
const jszip_1 = tslib_1.__importDefault(require("jszip"));
|
|
21
22
|
// ------------------------------------------------------------------------------------------------------------------ //
|
|
22
23
|
/**
|
|
23
24
|
* Detemplatizes Form data and swizzles the AGO ids of a zip object if they are present in the template dictionary.
|
|
@@ -30,26 +31,70 @@ async function swizzleFormObject(zipObject, templateDictionary) {
|
|
|
30
31
|
// Get the contents of the zip object
|
|
31
32
|
const zipObjectContents = await common.getZipObjectContents(zipObject);
|
|
32
33
|
// Swizzle the contents of each file in a zip file and replace them in the zip object
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
updatedZipContent = updatedZipContent.replace(new RegExp(match, "g"), `${replacement.itemId}`);
|
|
34
|
+
const zipObjectUpdatePromises = [];
|
|
35
|
+
zipObjectContents.forEach((zipFileItem) => {
|
|
36
|
+
// Separate the binary files from the text files
|
|
37
|
+
if (typeof zipFileItem.content === "string") {
|
|
38
|
+
const updatedZipContent = _updateZipObjectTextContent(zipFileItem, templateDictionary);
|
|
39
|
+
// Replace the file content in the zip object
|
|
40
|
+
zipObject.file(zipFileItem.file, updatedZipContent);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Only update XLSX binary files
|
|
44
|
+
if (zipFileItem.file.endsWith(".xlsx")) {
|
|
45
|
+
zipObjectUpdatePromises.push(_updateZipObjectBinaryContent(zipFileItem, templateDictionary));
|
|
47
46
|
}
|
|
48
|
-
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const asyncUpdates = await Promise.all(zipObjectUpdatePromises);
|
|
50
|
+
asyncUpdates.forEach((zipFileItem) => {
|
|
49
51
|
// Replace the file content in the zip object
|
|
50
|
-
zipObject.file(
|
|
52
|
+
zipObject.file(zipFileItem.file, zipFileItem.content);
|
|
51
53
|
});
|
|
52
54
|
return Promise.resolve(zipObject);
|
|
53
55
|
}
|
|
54
56
|
exports.swizzleFormObject = swizzleFormObject;
|
|
57
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
58
|
+
/**
|
|
59
|
+
* Updates the binary content of a zip object.
|
|
60
|
+
*
|
|
61
|
+
* @param zipFileItem Zip file item
|
|
62
|
+
* @param templateDictionary Dictionary of replacement values
|
|
63
|
+
* @returns Promise that resolves to the updated zip file item
|
|
64
|
+
*/
|
|
65
|
+
async function _updateZipObjectBinaryContent(zipFileItem, templateDictionary) {
|
|
66
|
+
const updatedZipContent = await swizzleFormObject(await jszip_1.default.loadAsync(zipFileItem.content), templateDictionary);
|
|
67
|
+
// Replace the file content in the zip file item
|
|
68
|
+
const updatedZipFileItem = {
|
|
69
|
+
file: zipFileItem.file,
|
|
70
|
+
content: await common.zipObjectToZipFile(updatedZipContent, zipFileItem.file)
|
|
71
|
+
};
|
|
72
|
+
return Promise.resolve(updatedZipFileItem);
|
|
73
|
+
}
|
|
74
|
+
exports._updateZipObjectBinaryContent = _updateZipObjectBinaryContent;
|
|
75
|
+
/**
|
|
76
|
+
* Updates the text content of a zip object.
|
|
77
|
+
*
|
|
78
|
+
* @param zipFileItem Zip file item
|
|
79
|
+
* @param templateDictionary Dictionary of replacement values
|
|
80
|
+
* @returns Updated zip file item text content
|
|
81
|
+
*/
|
|
82
|
+
function _updateZipObjectTextContent(zipFileItem, templateDictionary) {
|
|
83
|
+
const agoIdRegEx = common.getAgoIdRegEx();
|
|
84
|
+
// Detemplatize the file content
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
86
|
+
let updatedZipObjectContent = zipFileItem.content;
|
|
87
|
+
updatedZipObjectContent = common.replaceInTemplate(zipFileItem.content, templateDictionary);
|
|
88
|
+
// Find the AGO ids in the file content
|
|
89
|
+
const agoIdMatches = updatedZipObjectContent.match(agoIdRegEx) ?? [];
|
|
90
|
+
// Replace things that look like AGO ids in the file content iff they are present in the template dictionary
|
|
91
|
+
agoIdMatches.forEach((match) => {
|
|
92
|
+
const replacement = templateDictionary[match];
|
|
93
|
+
if (typeof replacement?.itemId === "string") {
|
|
94
|
+
updatedZipObjectContent = updatedZipObjectContent.replace(new RegExp(match, "g"), `${replacement.itemId}`);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return updatedZipObjectContent;
|
|
98
|
+
}
|
|
99
|
+
exports._updateZipObjectTextContent = _updateZipObjectTextContent;
|
|
55
100
|
//# sourceMappingURL=formUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formUtils.js","sourceRoot":"","sources":["../../src/formUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,sEAAgD;
|
|
1
|
+
{"version":3,"file":"formUtils.js","sourceRoot":"","sources":["../../src/formUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,sEAAgD;AAChD,0DAA0B;AAE1B,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,MAAM,uB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AC,IAAI,CAAC;KAC9E,CAAA;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC7C,CAAC;AAbD,sEAaC;AAED;;;;;;GAMG;AACH,SAAgB,2BAA2B,CACzC,WAAyC,EACzC,kBAAuB;IAEvB,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;IAE1C,gCAAgC;IAChC,4EAA4E;IAC5E,IAAI,uBAAuB,GAAG,WAAW,CAAC,OAAiB,CAAC;IAE5D,uBAAuB,GAAG,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IAE5F,uCAAuC;IACvC,MAAM,YAAY,GAAG,uBAAuB,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IAErE,4GAA4G;IAC5G,YAAY,CAAC,OAAO,CAAC,CAAC,KAAa,EAAE,EAAE;QACrC,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,OAAO,WAAW,EAAE,MAAM,KAAK,QAAQ,EAAE;YAC3C,uBAAuB,GAAG,uBAAuB,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;SAC5G;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAxBD,kEAwBC"}
|
package/dist/cjs/post-process.js
CHANGED
|
@@ -56,7 +56,7 @@ async function postProcess(itemId, type, itemInfos, template, templates, templat
|
|
|
56
56
|
if ((0, is_hub_form_template_1.isHubFormTemplate)(template)) {
|
|
57
57
|
return (0, post_process_survey_1.postProcessHubSurvey)(itemId, type, itemInfos, template, templates, templateDictionary, authentication);
|
|
58
58
|
}
|
|
59
|
-
//
|
|
59
|
+
// Update the item's template
|
|
60
60
|
return common.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
|
|
61
61
|
}
|
|
62
62
|
exports.postProcess = postProcess;
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3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,CAAC;AA7CD,kCA6CC"}
|
package/dist/esm/formUtils.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import * as common from "@esri/solution-common";
|
|
16
17
|
import JSZip from "jszip";
|
|
17
18
|
/**
|
|
18
19
|
* Detemplatizes Form data and swizzles the AGO ids of a zip object if they are present in the template dictionary.
|
|
@@ -22,3 +23,19 @@ import JSZip from "jszip";
|
|
|
22
23
|
* @returns Promise that resolves to the updated zip object
|
|
23
24
|
*/
|
|
24
25
|
export declare function swizzleFormObject(zipObject: JSZip, templateDictionary: any): Promise<JSZip>;
|
|
26
|
+
/**
|
|
27
|
+
* Updates the binary content of a zip object.
|
|
28
|
+
*
|
|
29
|
+
* @param zipFileItem Zip file item
|
|
30
|
+
* @param templateDictionary Dictionary of replacement values
|
|
31
|
+
* @returns Promise that resolves to the updated zip file item
|
|
32
|
+
*/
|
|
33
|
+
export declare function _updateZipObjectBinaryContent(zipFileItem: common.IZipObjectContentItem, templateDictionary: any): Promise<common.IZipObjectContentItem>;
|
|
34
|
+
/**
|
|
35
|
+
* Updates the text content of a zip object.
|
|
36
|
+
*
|
|
37
|
+
* @param zipFileItem Zip file item
|
|
38
|
+
* @param templateDictionary Dictionary of replacement values
|
|
39
|
+
* @returns Updated zip file item text content
|
|
40
|
+
*/
|
|
41
|
+
export declare function _updateZipObjectTextContent(zipFileItem: common.IZipObjectContentItem, templateDictionary: any): string;
|
package/dist/esm/formUtils.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import * as common from "@esri/solution-common";
|
|
17
|
+
import JSZip from "jszip";
|
|
17
18
|
// ------------------------------------------------------------------------------------------------------------------ //
|
|
18
19
|
/**
|
|
19
20
|
* Detemplatizes Form data and swizzles the AGO ids of a zip object if they are present in the template dictionary.
|
|
@@ -26,25 +27,67 @@ export async function swizzleFormObject(zipObject, templateDictionary) {
|
|
|
26
27
|
// Get the contents of the zip object
|
|
27
28
|
const zipObjectContents = await common.getZipObjectContents(zipObject);
|
|
28
29
|
// Swizzle the contents of each file in a zip file and replace them in the zip object
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
updatedZipContent = updatedZipContent.replace(new RegExp(match, "g"), `${replacement.itemId}`);
|
|
30
|
+
const zipObjectUpdatePromises = [];
|
|
31
|
+
zipObjectContents.forEach((zipFileItem) => {
|
|
32
|
+
// Separate the binary files from the text files
|
|
33
|
+
if (typeof zipFileItem.content === "string") {
|
|
34
|
+
const updatedZipContent = _updateZipObjectTextContent(zipFileItem, templateDictionary);
|
|
35
|
+
// Replace the file content in the zip object
|
|
36
|
+
zipObject.file(zipFileItem.file, updatedZipContent);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Only update XLSX binary files
|
|
40
|
+
if (zipFileItem.file.endsWith(".xlsx")) {
|
|
41
|
+
zipObjectUpdatePromises.push(_updateZipObjectBinaryContent(zipFileItem, templateDictionary));
|
|
43
42
|
}
|
|
44
|
-
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const asyncUpdates = await Promise.all(zipObjectUpdatePromises);
|
|
46
|
+
asyncUpdates.forEach((zipFileItem) => {
|
|
45
47
|
// Replace the file content in the zip object
|
|
46
|
-
zipObject.file(
|
|
48
|
+
zipObject.file(zipFileItem.file, zipFileItem.content);
|
|
47
49
|
});
|
|
48
50
|
return Promise.resolve(zipObject);
|
|
49
51
|
}
|
|
52
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
53
|
+
/**
|
|
54
|
+
* Updates the binary content of a zip object.
|
|
55
|
+
*
|
|
56
|
+
* @param zipFileItem Zip file item
|
|
57
|
+
* @param templateDictionary Dictionary of replacement values
|
|
58
|
+
* @returns Promise that resolves to the updated zip file item
|
|
59
|
+
*/
|
|
60
|
+
export async function _updateZipObjectBinaryContent(zipFileItem, templateDictionary) {
|
|
61
|
+
const updatedZipContent = await swizzleFormObject(await JSZip.loadAsync(zipFileItem.content), templateDictionary);
|
|
62
|
+
// Replace the file content in the zip file item
|
|
63
|
+
const updatedZipFileItem = {
|
|
64
|
+
file: zipFileItem.file,
|
|
65
|
+
content: await common.zipObjectToZipFile(updatedZipContent, zipFileItem.file)
|
|
66
|
+
};
|
|
67
|
+
return Promise.resolve(updatedZipFileItem);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Updates the text content of a zip object.
|
|
71
|
+
*
|
|
72
|
+
* @param zipFileItem Zip file item
|
|
73
|
+
* @param templateDictionary Dictionary of replacement values
|
|
74
|
+
* @returns Updated zip file item text content
|
|
75
|
+
*/
|
|
76
|
+
export function _updateZipObjectTextContent(zipFileItem, templateDictionary) {
|
|
77
|
+
const agoIdRegEx = common.getAgoIdRegEx();
|
|
78
|
+
// Detemplatize the file content
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
80
|
+
let updatedZipObjectContent = zipFileItem.content;
|
|
81
|
+
updatedZipObjectContent = common.replaceInTemplate(zipFileItem.content, templateDictionary);
|
|
82
|
+
// Find the AGO ids in the file content
|
|
83
|
+
const agoIdMatches = updatedZipObjectContent.match(agoIdRegEx) ?? [];
|
|
84
|
+
// Replace things that look like AGO ids in the file content iff they are present in the template dictionary
|
|
85
|
+
agoIdMatches.forEach((match) => {
|
|
86
|
+
const replacement = templateDictionary[match];
|
|
87
|
+
if (typeof replacement?.itemId === "string") {
|
|
88
|
+
updatedZipObjectContent = updatedZipObjectContent.replace(new RegExp(match, "g"), `${replacement.itemId}`);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return updatedZipObjectContent;
|
|
92
|
+
}
|
|
50
93
|
//# sourceMappingURL=formUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formUtils.js","sourceRoot":"","sources":["../../src/formUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"formUtils.js","sourceRoot":"","sources":["../../src/formUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,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,MAAM,uBAAuB,GAAiD,EAAE,CAAC;IACjF,iBAAiB,CAAC,OAAO,CACvB,CAAC,WAA0C,EAAE,EAAE;QAE7C,gDAAgD;QAChD,IAAI,OAAO,WAAW,CAAC,OAAO,KAAK,QAAQ,EAAE;YAC3C,MAAM,iBAAiB,GAAG,2BAA2B,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;YAEvF,6CAA6C;YAC7C,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;SAErD;aAAM;YACL,gCAAgC;YAChC,IAAI,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACtC,uBAAuB,CAAC,IAAI,CAAC,6BAA6B,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,CAAC;aAC9F;SACF;IACH,CAAC,CACF,CAAC;IAEF,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IAChE,YAAY,CAAC,OA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I,OAAO,WAAW,EAAE,MAAM,KAAK,QAAQ,EAAE;YAC3C,uBAAuB,GAAG,uBAAuB,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;SAC5G;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,uBAAuB,CAAC;AACjC,CAAC"}
|
package/dist/esm/post-process.js
CHANGED
|
@@ -52,7 +52,7 @@ export async function postProcess(itemId, type, itemInfos, template, templates,
|
|
|
52
52
|
if (isHubFormTemplate(template)) {
|
|
53
53
|
return postProcessHubSurvey(itemId, type, itemInfos, template, templates, templateDictionary, authentication);
|
|
54
54
|
}
|
|
55
|
-
//
|
|
55
|
+
// Update the item's template
|
|
56
56
|
return common.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
|
|
57
57
|
}
|
|
58
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,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,MAA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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,6BAA6B;IAC7B,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.9",
|
|
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,21 +23,21 @@
|
|
|
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.106.0",
|
|
27
27
|
"@esri/hub-initiatives": "^14.0.0",
|
|
28
|
-
"@esri/hub-sites": "^14.2.
|
|
28
|
+
"@esri/hub-sites": "^14.2.3",
|
|
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.9",
|
|
31
|
+
"@esri/solution-feature-layer": "^5.2.9",
|
|
32
|
+
"@esri/solution-file": "^5.2.9",
|
|
33
|
+
"@esri/solution-group": "^5.2.9",
|
|
34
|
+
"@esri/solution-simple-types": "^5.2.9",
|
|
35
|
+
"@esri/solution-storymap": "^5.2.9",
|
|
36
36
|
"@types/jasmine": "^5.1.4",
|
|
37
37
|
"fetch-mock": "^7.7.3",
|
|
38
38
|
"jasmine": "^5.1.0",
|
|
39
39
|
"jasmine-core": "^5.1.0",
|
|
40
|
-
"rollup": "^4.
|
|
40
|
+
"rollup": "^4.13.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"tslib": "1.14.1"
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"esri",
|
|
79
79
|
"ES6"
|
|
80
80
|
],
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "bc37cab732ed83b30f5a160915c5f3ed2aaa438e"
|
|
82
82
|
}
|