@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,56 +1,56 @@
|
|
|
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 { encodeFormData } from "@esri/arcgis-rest-request";
|
|
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 function createSurvey(params, survey123Url = "https://survey123.arcgis.com") {
|
|
31
|
-
const createUrl = `${survey123Url}/api/survey/create`;
|
|
32
|
-
const ro = {
|
|
33
|
-
credentials: "same-origin",
|
|
34
|
-
method: "POST",
|
|
35
|
-
body: encodeFormData({
|
|
36
|
-
f: "json",
|
|
37
|
-
...params
|
|
38
|
-
}, true)
|
|
39
|
-
};
|
|
40
|
-
// Using @esri/arcgis-request "request" method was resulting in a 404 for
|
|
41
|
-
// a CORS preflight request related to this request, but calling fetch directly
|
|
42
|
-
// circumvents the issue.
|
|
43
|
-
return fetch(createUrl, ro)
|
|
44
|
-
.then(response => response.json())
|
|
45
|
-
.then(response => {
|
|
46
|
-
if (!response.success) {
|
|
47
|
-
throw new Error(`Failed to create survey: ${response.error.message}`);
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
formId: response.id,
|
|
51
|
-
featureServiceId: response.featureService.source.itemId,
|
|
52
|
-
folderId: response.formItemInfo.ownerFolder
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
}
|
|
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 { encodeFormData } from "@esri/arcgis-rest-request";
|
|
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 function createSurvey(params, survey123Url = "https://survey123.arcgis.com") {
|
|
31
|
+
const createUrl = `${survey123Url}/api/survey/create`;
|
|
32
|
+
const ro = {
|
|
33
|
+
credentials: "same-origin",
|
|
34
|
+
method: "POST",
|
|
35
|
+
body: encodeFormData({
|
|
36
|
+
f: "json",
|
|
37
|
+
...params
|
|
38
|
+
}, true)
|
|
39
|
+
};
|
|
40
|
+
// Using @esri/arcgis-request "request" method was resulting in a 404 for
|
|
41
|
+
// a CORS preflight request related to this request, but calling fetch directly
|
|
42
|
+
// circumvents the issue.
|
|
43
|
+
return fetch(createUrl, ro)
|
|
44
|
+
.then(response => response.json())
|
|
45
|
+
.then(response => {
|
|
46
|
+
if (!response.success) {
|
|
47
|
+
throw new Error(`Failed to create survey: ${response.error.message}`);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
formId: response.id,
|
|
51
|
+
featureServiceId: response.featureService.source.itemId,
|
|
52
|
+
folderId: response.formItemInfo.ownerFolder
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
56
|
//# 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,55 +1,55 @@
|
|
|
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 { cloneObject } from "@esri/solution-common";
|
|
17
|
-
/**
|
|
18
|
-
* Manages Survey123 parameter encoding
|
|
19
|
-
*
|
|
20
|
-
* @module encode-survey-form
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* URI Encodes Survey123 form content parameter
|
|
24
|
-
* values
|
|
25
|
-
*
|
|
26
|
-
* @param {any} form Unencoded form data
|
|
27
|
-
* @returns {any} Encoded form data
|
|
28
|
-
*/
|
|
29
|
-
export const encodeSurveyForm = function encodeForm(form) {
|
|
30
|
-
const clone = cloneObject(form);
|
|
31
|
-
const props = [
|
|
32
|
-
["header", "content"],
|
|
33
|
-
["subHeader", "content"],
|
|
34
|
-
["footer", "content"],
|
|
35
|
-
["settings", "thankYouScreenContent"]
|
|
36
|
-
];
|
|
37
|
-
const encode = (obj, key) => {
|
|
38
|
-
if (obj && obj[key]) {
|
|
39
|
-
obj[key] = encodeURIComponent(obj[key]);
|
|
40
|
-
}
|
|
41
|
-
return obj;
|
|
42
|
-
};
|
|
43
|
-
// encode props from array above
|
|
44
|
-
props.forEach(([objKey, propKey]) => encode(clone[objKey], propKey));
|
|
45
|
-
const encodeQuestion = (question) => encode(question, "description");
|
|
46
|
-
// encode question descriptions
|
|
47
|
-
clone.questions = (clone.questions || []).map((question) => !question.questions
|
|
48
|
-
? encodeQuestion(question)
|
|
49
|
-
: {
|
|
50
|
-
...question,
|
|
51
|
-
questions: question.questions.map(encodeQuestion)
|
|
52
|
-
});
|
|
53
|
-
return clone;
|
|
54
|
-
};
|
|
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 { cloneObject } from "@esri/solution-common";
|
|
17
|
+
/**
|
|
18
|
+
* Manages Survey123 parameter encoding
|
|
19
|
+
*
|
|
20
|
+
* @module encode-survey-form
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* URI Encodes Survey123 form content parameter
|
|
24
|
+
* values
|
|
25
|
+
*
|
|
26
|
+
* @param {any} form Unencoded form data
|
|
27
|
+
* @returns {any} Encoded form data
|
|
28
|
+
*/
|
|
29
|
+
export const encodeSurveyForm = function encodeForm(form) {
|
|
30
|
+
const clone = cloneObject(form);
|
|
31
|
+
const props = [
|
|
32
|
+
["header", "content"],
|
|
33
|
+
["subHeader", "content"],
|
|
34
|
+
["footer", "content"],
|
|
35
|
+
["settings", "thankYouScreenContent"]
|
|
36
|
+
];
|
|
37
|
+
const encode = (obj, key) => {
|
|
38
|
+
if (obj && obj[key]) {
|
|
39
|
+
obj[key] = encodeURIComponent(obj[key]);
|
|
40
|
+
}
|
|
41
|
+
return obj;
|
|
42
|
+
};
|
|
43
|
+
// encode props from array above
|
|
44
|
+
props.forEach(([objKey, propKey]) => encode(clone[objKey], propKey));
|
|
45
|
+
const encodeQuestion = (question) => encode(question, "description");
|
|
46
|
+
// encode question descriptions
|
|
47
|
+
clone.questions = (clone.questions || []).map((question) => !question.questions
|
|
48
|
+
? encodeQuestion(question)
|
|
49
|
+
: {
|
|
50
|
+
...question,
|
|
51
|
+
questions: question.questions.map(encodeQuestion)
|
|
52
|
+
});
|
|
53
|
+
return clone;
|
|
54
|
+
};
|
|
55
55
|
//# 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,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
|
-
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 function isHubFormTemplate(template) {
|
|
25
|
-
// relying on basic duck typing vs adding extraneous props during migration
|
|
26
|
-
return !!common.getProp(template, "properties.services");
|
|
27
|
-
}
|
|
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 function isHubFormTemplate(template) {
|
|
25
|
+
// relying on basic duck typing vs adding extraneous props during migration
|
|
26
|
+
return !!common.getProp(template, "properties.services");
|
|
27
|
+
}
|
|
28
28
|
//# sourceMappingURL=is-hub-form-template.js.map
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/** @license
|
|
2
|
-
* Copyright 2020 Esri
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { UserSession, IItemTemplate } from "@esri/solution-common";
|
|
17
|
-
/**
|
|
18
|
-
* Provides utility method to post process Hub surveys
|
|
19
|
-
*
|
|
20
|
-
* @module post-process-survey
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* Performs Survey post processing actions
|
|
24
|
-
*
|
|
25
|
-
* @param {string} itemId The item ID
|
|
26
|
-
* @param {string} type The template/item type
|
|
27
|
-
* @param {any[]} itemInfos An Array of item details
|
|
28
|
-
* @param {IItemTemplate} template The template
|
|
29
|
-
* @param {any} templateDictionary The template dictionary
|
|
30
|
-
* @param {UserSession} authentication The destination session info
|
|
31
|
-
* @returns {Promise<any>}
|
|
32
|
-
*/
|
|
33
|
-
export declare function postProcessHubSurvey(itemId: string, type: string, itemInfos: any[], template: IItemTemplate, templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<any>;
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2020 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { UserSession, IItemTemplate } from "@esri/solution-common";
|
|
17
|
+
/**
|
|
18
|
+
* Provides utility method to post process Hub surveys
|
|
19
|
+
*
|
|
20
|
+
* @module post-process-survey
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* Performs Survey post processing actions
|
|
24
|
+
*
|
|
25
|
+
* @param {string} itemId The item ID
|
|
26
|
+
* @param {string} type The template/item type
|
|
27
|
+
* @param {any[]} itemInfos An Array of item details
|
|
28
|
+
* @param {IItemTemplate} template The template
|
|
29
|
+
* @param {any} templateDictionary The template dictionary
|
|
30
|
+
* @param {UserSession} authentication The destination session info
|
|
31
|
+
* @returns {Promise<any>}
|
|
32
|
+
*/
|
|
33
|
+
export declare function postProcessHubSurvey(itemId: string, type: string, itemInfos: any[], template: IItemTemplate, templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<any>;
|
|
@@ -1,78 +1,78 @@
|
|
|
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 { updateItem, replaceInTemplate, getItemBase, createInitializedItemTemplate, removeFolder } from "@esri/solution-common";
|
|
17
|
-
import { moveItem } from "@esri/arcgis-rest-portal";
|
|
18
|
-
/**
|
|
19
|
-
* Provides utility method to post process Hub surveys
|
|
20
|
-
*
|
|
21
|
-
* @module post-process-survey
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* Performs Survey post processing actions
|
|
25
|
-
*
|
|
26
|
-
* @param {string} itemId The item ID
|
|
27
|
-
* @param {string} type The template/item type
|
|
28
|
-
* @param {any[]} itemInfos An Array of item details
|
|
29
|
-
* @param {IItemTemplate} template The template
|
|
30
|
-
* @param {any} templateDictionary The template dictionary
|
|
31
|
-
* @param {UserSession} authentication The destination session info
|
|
32
|
-
* @returns {Promise<any>}
|
|
33
|
-
*/
|
|
34
|
-
export function postProcessHubSurvey(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
|
|
35
|
-
const featureServiceSourceId = template.properties.info.serviceInfo.itemId;
|
|
36
|
-
const { itemId: featureServiceResultId } = templateDictionary[featureServiceSourceId];
|
|
37
|
-
const interpolated = replaceInTemplate(template, templateDictionary);
|
|
38
|
-
return getItemBase(featureServiceResultId, authentication).then(featureServiceResultBase => {
|
|
39
|
-
const itemUpdates = [
|
|
40
|
-
// fix/update form properties we couldn't control via the API
|
|
41
|
-
{
|
|
42
|
-
id: itemId,
|
|
43
|
-
title: interpolated.item.title,
|
|
44
|
-
snippet: interpolated.item.snippet,
|
|
45
|
-
extent: interpolated.item.extent,
|
|
46
|
-
culture: interpolated.item.culture
|
|
47
|
-
},
|
|
48
|
-
// fix/update feature service properties we couldn't control via the API
|
|
49
|
-
{
|
|
50
|
-
id: featureServiceResultId,
|
|
51
|
-
extent: interpolated.item.extent,
|
|
52
|
-
typeKeywords: [`source-${featureServiceSourceId}`].concat(featureServiceResultBase.typeKeywords)
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
|
-
const toUpdatePromise = (updatedItem) => updateItem(updatedItem, authentication);
|
|
56
|
-
const updatePromises = itemUpdates.map(toUpdatePromise);
|
|
57
|
-
return Promise.all(updatePromises)
|
|
58
|
-
.then(() => {
|
|
59
|
-
const itemIdsToMove = [itemId, featureServiceResultId];
|
|
60
|
-
const toMovePromise = (id) => moveItem({
|
|
61
|
-
itemId: id,
|
|
62
|
-
folderId: templateDictionary.folderId,
|
|
63
|
-
authentication: authentication
|
|
64
|
-
});
|
|
65
|
-
const movePromises = itemIdsToMove.map(toMovePromise);
|
|
66
|
-
return Promise.all(movePromises);
|
|
67
|
-
})
|
|
68
|
-
.then(() => removeFolder(featureServiceResultBase.ownerFolder, authentication))
|
|
69
|
-
.then(() => {
|
|
70
|
-
// Create a template item for the Feature Service that was created by the API
|
|
71
|
-
const featureServiceTemplate = createInitializedItemTemplate(featureServiceResultBase);
|
|
72
|
-
templates.push(featureServiceTemplate);
|
|
73
|
-
template.dependencies.push(featureServiceResultBase.id);
|
|
74
|
-
return true;
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
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 { updateItem, replaceInTemplate, getItemBase, createInitializedItemTemplate, removeFolder } from "@esri/solution-common";
|
|
17
|
+
import { moveItem } from "@esri/arcgis-rest-portal";
|
|
18
|
+
/**
|
|
19
|
+
* Provides utility method to post process Hub surveys
|
|
20
|
+
*
|
|
21
|
+
* @module post-process-survey
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Performs Survey post processing actions
|
|
25
|
+
*
|
|
26
|
+
* @param {string} itemId The item ID
|
|
27
|
+
* @param {string} type The template/item type
|
|
28
|
+
* @param {any[]} itemInfos An Array of item details
|
|
29
|
+
* @param {IItemTemplate} template The template
|
|
30
|
+
* @param {any} templateDictionary The template dictionary
|
|
31
|
+
* @param {UserSession} authentication The destination session info
|
|
32
|
+
* @returns {Promise<any>}
|
|
33
|
+
*/
|
|
34
|
+
export function postProcessHubSurvey(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
|
|
35
|
+
const featureServiceSourceId = template.properties.info.serviceInfo.itemId;
|
|
36
|
+
const { itemId: featureServiceResultId } = templateDictionary[featureServiceSourceId];
|
|
37
|
+
const interpolated = replaceInTemplate(template, templateDictionary);
|
|
38
|
+
return getItemBase(featureServiceResultId, authentication).then(featureServiceResultBase => {
|
|
39
|
+
const itemUpdates = [
|
|
40
|
+
// fix/update form properties we couldn't control via the API
|
|
41
|
+
{
|
|
42
|
+
id: itemId,
|
|
43
|
+
title: interpolated.item.title,
|
|
44
|
+
snippet: interpolated.item.snippet,
|
|
45
|
+
extent: interpolated.item.extent,
|
|
46
|
+
culture: interpolated.item.culture
|
|
47
|
+
},
|
|
48
|
+
// fix/update feature service properties we couldn't control via the API
|
|
49
|
+
{
|
|
50
|
+
id: featureServiceResultId,
|
|
51
|
+
extent: interpolated.item.extent,
|
|
52
|
+
typeKeywords: [`source-${featureServiceSourceId}`].concat(featureServiceResultBase.typeKeywords)
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
const toUpdatePromise = (updatedItem) => updateItem(updatedItem, authentication);
|
|
56
|
+
const updatePromises = itemUpdates.map(toUpdatePromise);
|
|
57
|
+
return Promise.all(updatePromises)
|
|
58
|
+
.then(() => {
|
|
59
|
+
const itemIdsToMove = [itemId, featureServiceResultId];
|
|
60
|
+
const toMovePromise = (id) => moveItem({
|
|
61
|
+
itemId: id,
|
|
62
|
+
folderId: templateDictionary.folderId,
|
|
63
|
+
authentication: authentication
|
|
64
|
+
});
|
|
65
|
+
const movePromises = itemIdsToMove.map(toMovePromise);
|
|
66
|
+
return Promise.all(movePromises);
|
|
67
|
+
})
|
|
68
|
+
.then(() => removeFolder(featureServiceResultBase.ownerFolder, authentication))
|
|
69
|
+
.then(() => {
|
|
70
|
+
// Create a template item for the Feature Service that was created by the API
|
|
71
|
+
const featureServiceTemplate = createInitializedItemTemplate(featureServiceResultBase);
|
|
72
|
+
templates.push(featureServiceTemplate);
|
|
73
|
+
template.dependencies.push(featureServiceResultBase.id);
|
|
74
|
+
return true;
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
78
|
//# sourceMappingURL=post-process-survey.js.map
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/** @license
|
|
2
|
-
* Copyright 2018 Esri
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Manages the creation and deployment of form item types.
|
|
18
|
-
*
|
|
19
|
-
* @module solution-form
|
|
20
|
-
*/
|
|
21
|
-
export * from "./convert-item-to-template";
|
|
22
|
-
export * from "./create-item-from-template";
|
|
23
|
-
export * from "./post-process";
|
|
1
|
+
/** @license
|
|
2
|
+
* Copyright 2018 Esri
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Manages the creation and deployment of form item types.
|
|
18
|
+
*
|
|
19
|
+
* @module solution-form
|
|
20
|
+
*/
|
|
21
|
+
export * from "./convert-item-to-template";
|
|
22
|
+
export * from "./create-item-from-template";
|
|
23
|
+
export * from "./post-process";
|