@esri/solution-form 4.1.2 → 5.0.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/dist/cjs/convert-item-to-template.d.ts +32 -32
- package/dist/cjs/convert-item-to-template.js +34 -34
- package/dist/cjs/create-item-from-template.d.ts +31 -31
- package/dist/cjs/create-item-from-template.js +39 -39
- package/dist/cjs/helpers/build-create-params.d.ts +30 -30
- package/dist/cjs/helpers/build-create-params.js +77 -77
- package/dist/cjs/helpers/create-item-from-hub-template.d.ts +32 -32
- package/dist/cjs/helpers/create-item-from-hub-template.js +79 -79
- package/dist/cjs/helpers/create-survey.d.ts +30 -30
- package/dist/cjs/helpers/create-survey.js +59 -59
- package/dist/cjs/helpers/encode-survey-form.d.ts +28 -28
- package/dist/cjs/helpers/encode-survey-form.js +58 -58
- package/dist/cjs/helpers/is-hub-form-template.d.ts +24 -24
- package/dist/cjs/helpers/is-hub-form-template.js +32 -32
- package/dist/cjs/helpers/post-process-survey.d.ts +33 -33
- package/dist/cjs/helpers/post-process-survey.js +81 -81
- package/dist/cjs/index.d.ts +23 -23
- package/dist/cjs/index.js +26 -26
- package/dist/cjs/post-process.d.ts +32 -32
- package/dist/cjs/post-process.js +43 -43
- package/dist/esm/convert-item-to-template.d.ts +32 -32
- package/dist/esm/convert-item-to-template.js +30 -30
- package/dist/esm/create-item-from-template.d.ts +31 -31
- package/dist/esm/create-item-from-template.js +35 -35
- package/dist/esm/helpers/build-create-params.d.ts +30 -30
- package/dist/esm/helpers/build-create-params.js +73 -73
- package/dist/esm/helpers/create-item-from-hub-template.d.ts +32 -32
- package/dist/esm/helpers/create-item-from-hub-template.js +75 -75
- package/dist/esm/helpers/create-survey.d.ts +30 -30
- package/dist/esm/helpers/create-survey.js +55 -55
- package/dist/esm/helpers/encode-survey-form.d.ts +28 -28
- package/dist/esm/helpers/encode-survey-form.js +54 -54
- package/dist/esm/helpers/is-hub-form-template.d.ts +24 -24
- package/dist/esm/helpers/is-hub-form-template.js +27 -27
- package/dist/esm/helpers/post-process-survey.d.ts +33 -33
- package/dist/esm/helpers/post-process-survey.js +77 -77
- package/dist/esm/index.d.ts +23 -23
- package/dist/esm/index.js +23 -23
- package/dist/esm/post-process.d.ts +32 -32
- package/dist/esm/post-process.js +39 -39
- package/package.json +8 -8
|
@@ -1,80 +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;
|
|
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
80
|
//# sourceMappingURL=create-item-from-hub-template.js.map
|
|
@@ -1,30 +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>;
|
|
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>;
|
|
@@ -1,60 +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;
|
|
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
60
|
//# sourceMappingURL=create-survey.js.map
|
|
@@ -1,28 +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;
|
|
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;
|
|
@@ -1,59 +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;
|
|
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
59
|
//# sourceMappingURL=encode-survey-form.js.map
|
|
@@ -1,24 +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;
|
|
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;
|
|
@@ -1,33 +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;
|
|
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
33
|
//# sourceMappingURL=is-hub-form-template.js.map
|