@esri/solution-form 6.0.4-alpha.0 → 6.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/dist/cjs/convert-item-to-template.d.ts +0 -31
- package/dist/cjs/convert-item-to-template.js +0 -34
- package/dist/cjs/convert-item-to-template.js.map +0 -1
- package/dist/cjs/create-item-from-template.d.ts +0 -31
- package/dist/cjs/create-item-from-template.js +0 -40
- package/dist/cjs/create-item-from-template.js.map +0 -1
- package/dist/cjs/formUtils.d.ts +0 -82
- package/dist/cjs/formUtils.js +0 -215
- package/dist/cjs/formUtils.js.map +0 -1
- package/dist/cjs/helpers/build-create-params.d.ts +0 -30
- package/dist/cjs/helpers/build-create-params.js +0 -78
- package/dist/cjs/helpers/build-create-params.js.map +0 -1
- package/dist/cjs/helpers/create-item-from-hub-template.d.ts +0 -32
- package/dist/cjs/helpers/create-item-from-hub-template.js +0 -80
- package/dist/cjs/helpers/create-item-from-hub-template.js.map +0 -1
- package/dist/cjs/helpers/create-survey.d.ts +0 -30
- package/dist/cjs/helpers/create-survey.js +0 -60
- package/dist/cjs/helpers/create-survey.js.map +0 -1
- package/dist/cjs/helpers/encode-survey-form.d.ts +0 -28
- package/dist/cjs/helpers/encode-survey-form.js +0 -59
- package/dist/cjs/helpers/encode-survey-form.js.map +0 -1
- package/dist/cjs/helpers/is-hub-form-template.d.ts +0 -24
- package/dist/cjs/helpers/is-hub-form-template.js +0 -33
- package/dist/cjs/helpers/is-hub-form-template.js.map +0 -1
- package/dist/cjs/helpers/post-process-survey.d.ts +0 -33
- package/dist/cjs/helpers/post-process-survey.js +0 -81
- package/dist/cjs/helpers/post-process-survey.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -24
- package/dist/cjs/index.js +0 -28
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/post-process.d.ts +0 -46
- package/dist/cjs/post-process.js +0 -117
- package/dist/cjs/post-process.js.map +0 -1
- package/dist/esm/convert-item-to-template.d.ts +0 -31
- package/dist/esm/convert-item-to-template.js +0 -30
- package/dist/esm/convert-item-to-template.js.map +0 -1
- package/dist/esm/create-item-from-template.d.ts +0 -31
- package/dist/esm/create-item-from-template.js +0 -36
- package/dist/esm/create-item-from-template.js.map +0 -1
- package/dist/esm/formUtils.d.ts +0 -82
- package/dist/esm/formUtils.js +0 -204
- package/dist/esm/formUtils.js.map +0 -1
- package/dist/esm/helpers/build-create-params.d.ts +0 -30
- package/dist/esm/helpers/build-create-params.js +0 -74
- package/dist/esm/helpers/build-create-params.js.map +0 -1
- package/dist/esm/helpers/create-item-from-hub-template.d.ts +0 -32
- package/dist/esm/helpers/create-item-from-hub-template.js +0 -76
- package/dist/esm/helpers/create-item-from-hub-template.js.map +0 -1
- package/dist/esm/helpers/create-survey.d.ts +0 -30
- package/dist/esm/helpers/create-survey.js +0 -56
- package/dist/esm/helpers/create-survey.js.map +0 -1
- package/dist/esm/helpers/encode-survey-form.d.ts +0 -28
- package/dist/esm/helpers/encode-survey-form.js +0 -55
- package/dist/esm/helpers/encode-survey-form.js.map +0 -1
- package/dist/esm/helpers/is-hub-form-template.d.ts +0 -24
- package/dist/esm/helpers/is-hub-form-template.js +0 -28
- package/dist/esm/helpers/is-hub-form-template.js.map +0 -1
- package/dist/esm/helpers/post-process-survey.d.ts +0 -33
- package/dist/esm/helpers/post-process-survey.js +0 -77
- package/dist/esm/helpers/post-process-survey.js.map +0 -1
- package/dist/esm/index.d.ts +0 -24
- package/dist/esm/index.js +0 -25
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/post-process.d.ts +0 -46
- package/dist/esm/post-process.js +0 -110
- package/dist/esm/post-process.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/solution-form",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0-alpha.0",
|
|
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",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"npm-check-updates": "^17.1.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@esri/solution-common": "^6.0
|
|
26
|
-
"@esri/solution-simple-types": "^6.0
|
|
25
|
+
"@esri/solution-common": "^6.1.0-alpha.0",
|
|
26
|
+
"@esri/solution-simple-types": "^6.1.0-alpha.0",
|
|
27
27
|
"jszip": "3.10.1",
|
|
28
28
|
"tslib": "1.14.1"
|
|
29
29
|
},
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"esri",
|
|
64
64
|
"ES6"
|
|
65
65
|
],
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "19cbc20f4da03baa4676b3fad82abcea533432c3"
|
|
67
67
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
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>;
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC,QAAQ,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;AAChH,CAAC;AARD,sDAQC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
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>;
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,EAAC,QAAQ,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;KACjH;IAED,qCAAqC;IACrC,OAAO,mCAAW,CAAC,sBAAsB,CACvC,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,CACrB,CAAC;AACJ,CAAC;AAlBD,wDAkBC"}
|
package/dist/cjs/formUtils.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
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
|
-
import JSZip from "jszip";
|
|
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 declare function swizzleFormObject(zipObject: JSZip, templateDictionary: any): Promise<JSZip>;
|
|
26
|
-
/**
|
|
27
|
-
* Templatizes the content in a form's zip object.
|
|
28
|
-
*
|
|
29
|
-
* @param zipObject Form zip object to templatize; it is modified in place
|
|
30
|
-
* @param templateDictionary Dictionary of values to use when templatizing
|
|
31
|
-
* @returns Promise that resolves to the modified zip object
|
|
32
|
-
*/
|
|
33
|
-
export declare function templatizeFormData(zipObject: JSZip, templateDictionary: any): Promise<JSZip>;
|
|
34
|
-
/**
|
|
35
|
-
* Replaces the feature service url references.
|
|
36
|
-
*
|
|
37
|
-
* @param contents String in which to replace feature service URLs
|
|
38
|
-
* @param templateDictionary Item ids of feature services pointing to feature service URLs
|
|
39
|
-
* @param agoIdTypeRegEx Matcher for AGO ids with "_type" suffix
|
|
40
|
-
* @returns Modified contents
|
|
41
|
-
*/
|
|
42
|
-
export declare function _replaceFeatureServiceURLs(contents: string, templateDictionary: any, agoIdTypeRegEx: RegExp): string;
|
|
43
|
-
/**
|
|
44
|
-
* Replaces the item id references.
|
|
45
|
-
*
|
|
46
|
-
* @param contents String in which to replace the item id references
|
|
47
|
-
* @param templateDictionary Item ids of feature services pointing to feature service URLs
|
|
48
|
-
* @param agoIdTypeRegEx Matcher for AGO ids
|
|
49
|
-
* @returns Modified contents
|
|
50
|
-
*/
|
|
51
|
-
export declare function _replaceItemIds(contents: string, templateDictionary: any, agoIdTypeRegEx: RegExp): string;
|
|
52
|
-
/**
|
|
53
|
-
* Replaces portal base url references.
|
|
54
|
-
*
|
|
55
|
-
* @param contents String in which to replace the portal base url references
|
|
56
|
-
* @param templateDictionary Item ids of feature services pointing to feature service URLs
|
|
57
|
-
* @returns Modified contents
|
|
58
|
-
*/
|
|
59
|
-
export declare function _replacePortalBaseUrls(contents: string, templateDictionary: any): string;
|
|
60
|
-
/**
|
|
61
|
-
* Replaces workflow manager base url references.
|
|
62
|
-
*
|
|
63
|
-
* @param contents String in which to replace the workflow manager base url references
|
|
64
|
-
* @param templateDictionary Item ids of feature services pointing to feature service URLs
|
|
65
|
-
* @returns Modified contents
|
|
66
|
-
*/
|
|
67
|
-
export declare function _replaceWorkflowManagerBaseUrls(contents: string, templateDictionary: any): string;
|
|
68
|
-
/**
|
|
69
|
-
* Updates the binary content of a zip object.
|
|
70
|
-
*
|
|
71
|
-
* @param zipFileItem Zip file item
|
|
72
|
-
* @param templateDictionary Dictionary of replacement values
|
|
73
|
-
* @returns Promise that resolves to the updated zip file item
|
|
74
|
-
*/
|
|
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
|
-
export declare function _updateZipObjectTextContent(zipFileItem: common.IZipObjectContentItem, templateDictionary: any): string;
|
package/dist/cjs/formUtils.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
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._updateZipObjectTextContent = exports._replaceWorkflowManagerBaseUrls = exports._replacePortalBaseUrls = exports._replaceItemIds = exports._replaceFeatureServiceURLs = exports.templatizeFormData = 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
|
-
// Set the file dates to be a day in the past offset for time zone to get around S123 bug with dates during unzipping
|
|
33
|
-
let now = new Date();
|
|
34
|
-
now = new Date(now.valueOf() -
|
|
35
|
-
86400000 - // back up 1 day in milliseconds
|
|
36
|
-
now.getTimezoneOffset() * 1000 * 60);
|
|
37
|
-
// Swizzle the contents of each file in a zip file and replace them in the zip object
|
|
38
|
-
//const zipObjectUpdatePromises: Array<Promise<common.IZipObjectContentItem>> = [];
|
|
39
|
-
zipObjectContents.forEach((zipFileItem) => {
|
|
40
|
-
// Separate the binary files from the text files
|
|
41
|
-
if (typeof zipFileItem.content === "string") {
|
|
42
|
-
const updatedZipContent = _updateZipObjectTextContent(zipFileItem, templateDictionary);
|
|
43
|
-
// Replace the file content in the zip object
|
|
44
|
-
zipObject.file(zipFileItem.file, updatedZipContent, { date: now });
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
// Update XLSX binary files' timestamp to match the other files
|
|
48
|
-
if (zipFileItem.file.endsWith(".xlsx")) {
|
|
49
|
-
zipObject.file(zipFileItem.file, zipFileItem.content, { date: now });
|
|
50
|
-
//zipObjectUpdatePromises.push(_updateZipObjectBinaryContent(zipFileItem, templateDictionary));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
/*
|
|
55
|
-
const asyncUpdates = await Promise.all(zipObjectUpdatePromises);
|
|
56
|
-
asyncUpdates.forEach((zipFileItem: common.IZipObjectContentItem) => {
|
|
57
|
-
// Replace the file content in the zip object
|
|
58
|
-
zipObject.file(zipFileItem.file, zipFileItem.content);
|
|
59
|
-
});
|
|
60
|
-
*/
|
|
61
|
-
return Promise.resolve(zipObject);
|
|
62
|
-
}
|
|
63
|
-
exports.swizzleFormObject = swizzleFormObject;
|
|
64
|
-
/**
|
|
65
|
-
* Templatizes the content in a form's zip object.
|
|
66
|
-
*
|
|
67
|
-
* @param zipObject Form zip object to templatize; it is modified in place
|
|
68
|
-
* @param templateDictionary Dictionary of values to use when templatizing
|
|
69
|
-
* @returns Promise that resolves to the modified zip object
|
|
70
|
-
*/
|
|
71
|
-
async function templatizeFormData(zipObject, templateDictionary) {
|
|
72
|
-
const zipObjectContents = await common.getZipObjectContents(zipObject);
|
|
73
|
-
zipObjectContents.forEach((zipFile) => {
|
|
74
|
-
if (zipFile.file.endsWith(".info") ||
|
|
75
|
-
zipFile.file.endsWith(".itemInfo") ||
|
|
76
|
-
zipFile.file.endsWith(".json") ||
|
|
77
|
-
zipFile.file.endsWith(".webform") ||
|
|
78
|
-
zipFile.file.endsWith(".xml")) {
|
|
79
|
-
let contents = zipFile.content;
|
|
80
|
-
const agoIdTypeRegEx = /\b([0-9A-Fa-f]){32}_type/g;
|
|
81
|
-
// Replace the item id references
|
|
82
|
-
contents = _replaceItemIds(contents, templateDictionary, agoIdTypeRegEx);
|
|
83
|
-
// Replace the feature service url references
|
|
84
|
-
contents = _replaceFeatureServiceURLs(contents, templateDictionary, agoIdTypeRegEx);
|
|
85
|
-
// Replace portal base url references
|
|
86
|
-
contents = _replacePortalBaseUrls(contents, templateDictionary);
|
|
87
|
-
// Replace workflow manager base url references
|
|
88
|
-
contents = _replaceWorkflowManagerBaseUrls(contents, templateDictionary);
|
|
89
|
-
zipObject.file(zipFile.file, contents);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
// Return the modified zip object
|
|
93
|
-
return Promise.resolve(zipObject);
|
|
94
|
-
}
|
|
95
|
-
exports.templatizeFormData = templatizeFormData;
|
|
96
|
-
// ------------------------------------------------------------------------------------------------------------------ //
|
|
97
|
-
/**
|
|
98
|
-
* Replaces the feature service url references.
|
|
99
|
-
*
|
|
100
|
-
* @param contents String in which to replace feature service URLs
|
|
101
|
-
* @param templateDictionary Item ids of feature services pointing to feature service URLs
|
|
102
|
-
* @param agoIdTypeRegEx Matcher for AGO ids with "_type" suffix
|
|
103
|
-
* @returns Modified contents
|
|
104
|
-
*/
|
|
105
|
-
function _replaceFeatureServiceURLs(contents, templateDictionary, agoIdTypeRegEx) {
|
|
106
|
-
let updatedContents = contents;
|
|
107
|
-
const fsIds = Object.keys(templateDictionary).filter((key) => key.match(agoIdTypeRegEx) && templateDictionary[key].type === "Feature Service");
|
|
108
|
-
fsIds.forEach((fsId) => {
|
|
109
|
-
const urlToReplace = templateDictionary[fsId].url;
|
|
110
|
-
const urlReplacement = templateDictionary[urlToReplace];
|
|
111
|
-
if (urlReplacement) {
|
|
112
|
-
updatedContents = updatedContents.replace(new RegExp(urlToReplace, "g"), urlReplacement);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
return updatedContents;
|
|
116
|
-
}
|
|
117
|
-
exports._replaceFeatureServiceURLs = _replaceFeatureServiceURLs;
|
|
118
|
-
/**
|
|
119
|
-
* Replaces the item id references.
|
|
120
|
-
*
|
|
121
|
-
* @param contents String in which to replace the item id references
|
|
122
|
-
* @param templateDictionary Item ids of feature services pointing to feature service URLs
|
|
123
|
-
* @param agoIdTypeRegEx Matcher for AGO ids
|
|
124
|
-
* @returns Modified contents
|
|
125
|
-
*/
|
|
126
|
-
function _replaceItemIds(contents, templateDictionary, agoIdTypeRegEx) {
|
|
127
|
-
let updatedContents = contents;
|
|
128
|
-
const itemIds = Object.keys(templateDictionary)
|
|
129
|
-
.filter((key) => key.match(agoIdTypeRegEx) && templateDictionary[key].type !== "Feature Service")
|
|
130
|
-
.map((key) => key.replace("_type", ""));
|
|
131
|
-
itemIds.forEach((itemId) => {
|
|
132
|
-
updatedContents = updatedContents.replace(new RegExp(itemId, "g"), `{{${itemId}.itemId}}`);
|
|
133
|
-
});
|
|
134
|
-
return updatedContents;
|
|
135
|
-
}
|
|
136
|
-
exports._replaceItemIds = _replaceItemIds;
|
|
137
|
-
/**
|
|
138
|
-
* Replaces portal base url references.
|
|
139
|
-
*
|
|
140
|
-
* @param contents String in which to replace the portal base url references
|
|
141
|
-
* @param templateDictionary Item ids of feature services pointing to feature service URLs
|
|
142
|
-
* @returns Modified contents
|
|
143
|
-
*/
|
|
144
|
-
function _replacePortalBaseUrls(contents, templateDictionary) {
|
|
145
|
-
let updatedContents = contents;
|
|
146
|
-
if (templateDictionary.portalBaseUrl) {
|
|
147
|
-
updatedContents = updatedContents.replace(new RegExp(templateDictionary.portalBaseUrl, "g"), "{{portalBaseUrl}}");
|
|
148
|
-
}
|
|
149
|
-
return updatedContents;
|
|
150
|
-
}
|
|
151
|
-
exports._replacePortalBaseUrls = _replacePortalBaseUrls;
|
|
152
|
-
/**
|
|
153
|
-
* Replaces workflow manager base url references.
|
|
154
|
-
*
|
|
155
|
-
* @param contents String in which to replace the workflow manager base url references
|
|
156
|
-
* @param templateDictionary Item ids of feature services pointing to feature service URLs
|
|
157
|
-
* @returns Modified contents
|
|
158
|
-
*/
|
|
159
|
-
function _replaceWorkflowManagerBaseUrls(contents, templateDictionary) {
|
|
160
|
-
let updatedContents = contents;
|
|
161
|
-
if (templateDictionary.workflowBaseUrl) {
|
|
162
|
-
updatedContents = updatedContents.replace(new RegExp(templateDictionary.workflowBaseUrl, "g"), "{{workflowBaseUrl}}");
|
|
163
|
-
}
|
|
164
|
-
return updatedContents;
|
|
165
|
-
}
|
|
166
|
-
exports._replaceWorkflowManagerBaseUrls = _replaceWorkflowManagerBaseUrls;
|
|
167
|
-
/**
|
|
168
|
-
* Updates the binary content of a zip object.
|
|
169
|
-
*
|
|
170
|
-
* @param zipFileItem Zip file item
|
|
171
|
-
* @param templateDictionary Dictionary of replacement values
|
|
172
|
-
* @returns Promise that resolves to the updated zip file item
|
|
173
|
-
*/
|
|
174
|
-
/*
|
|
175
|
-
export async function _updateZipObjectBinaryContent(
|
|
176
|
-
zipFileItem: common.IZipObjectContentItem,
|
|
177
|
-
templateDictionary: any
|
|
178
|
-
): Promise<common.IZipObjectContentItem> {
|
|
179
|
-
const updatedZipContent = await swizzleFormObject(await JSZip.loadAsync(zipFileItem.content), templateDictionary);
|
|
180
|
-
|
|
181
|
-
// Replace the file content in the zip file item
|
|
182
|
-
const updatedZipFileItem = {
|
|
183
|
-
file: zipFileItem.file,
|
|
184
|
-
content: await common.zipObjectToZipFile(updatedZipContent, zipFileItem.file)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return Promise.resolve(updatedZipFileItem);
|
|
188
|
-
}
|
|
189
|
-
*/
|
|
190
|
-
/**
|
|
191
|
-
* Updates the text content of a zip object.
|
|
192
|
-
*
|
|
193
|
-
* @param zipFileItem Zip file item
|
|
194
|
-
* @param templateDictionary Dictionary of replacement values
|
|
195
|
-
* @returns Updated zip file item text content
|
|
196
|
-
*/
|
|
197
|
-
function _updateZipObjectTextContent(zipFileItem, templateDictionary) {
|
|
198
|
-
const agoIdRegEx = common.getAgoIdRegEx();
|
|
199
|
-
// Detemplatize the file content
|
|
200
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
201
|
-
let updatedZipObjectContent = zipFileItem.content;
|
|
202
|
-
updatedZipObjectContent = common.replaceInTemplate(zipFileItem.content, templateDictionary);
|
|
203
|
-
// Find the AGO ids in the file content
|
|
204
|
-
const agoIdMatches = common.dedupe(updatedZipObjectContent.match(agoIdRegEx) ?? []);
|
|
205
|
-
// Replace things that look like AGO ids in the file content iff they are present in the template dictionary
|
|
206
|
-
agoIdMatches.forEach((match) => {
|
|
207
|
-
const replacement = templateDictionary[match];
|
|
208
|
-
if (typeof replacement?.itemId === "string") {
|
|
209
|
-
updatedZipObjectContent = updatedZipObjectContent.replace(new RegExp(match, "g"), `${replacement.itemId}`);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
return updatedZipObjectContent;
|
|
213
|
-
}
|
|
214
|
-
exports._updateZipObjectTextContent = _updateZipObjectTextContent;
|
|
215
|
-
//# sourceMappingURL=formUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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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,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"}
|
|
@@ -1,30 +0,0 @@
|
|
|
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>;
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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;AAE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,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;oBACE,GAAG,QAAQ;oBACX,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC;iBACjD,CACN,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,CACF,CAAC;AACJ,CAAC;AA/DD,8CA+DC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
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>;
|