@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,31 +1,31 @@
|
|
|
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
|
+
/** @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,36 +1,36 @@
|
|
|
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
|
-
import { simpleTypes } from "@esri/solution-simple-types";
|
|
17
|
-
import { isHubFormTemplate } from "./helpers/is-hub-form-template";
|
|
18
|
-
import { createItemFromHubTemplate } from "./helpers/create-item-from-hub-template";
|
|
19
|
-
/**
|
|
20
|
-
* Creates a Form item from a template
|
|
21
|
-
*
|
|
22
|
-
* @param {IItemTemplate} template The template
|
|
23
|
-
* @param {any} templateDictionary The template dictionary
|
|
24
|
-
* @param {UserSession} destinationAuthentication The destination user session info
|
|
25
|
-
* @param itemProgressCallback An item progress callback
|
|
26
|
-
* @returns {Promise<ICreateItemFromTemplateResponse>}
|
|
27
|
-
*/
|
|
28
|
-
export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
29
|
-
// Hub Form template custom processing
|
|
30
|
-
if (isHubFormTemplate(template)) {
|
|
31
|
-
return createItemFromHubTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
|
|
32
|
-
}
|
|
33
|
-
// otherwise delegate to simple types
|
|
34
|
-
return simpleTypes.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
|
|
35
|
-
}
|
|
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
|
+
import { simpleTypes } from "@esri/solution-simple-types";
|
|
17
|
+
import { isHubFormTemplate } from "./helpers/is-hub-form-template";
|
|
18
|
+
import { createItemFromHubTemplate } from "./helpers/create-item-from-hub-template";
|
|
19
|
+
/**
|
|
20
|
+
* Creates a Form item from a template
|
|
21
|
+
*
|
|
22
|
+
* @param {IItemTemplate} template The template
|
|
23
|
+
* @param {any} templateDictionary The template dictionary
|
|
24
|
+
* @param {UserSession} destinationAuthentication The destination user session info
|
|
25
|
+
* @param itemProgressCallback An item progress callback
|
|
26
|
+
* @returns {Promise<ICreateItemFromTemplateResponse>}
|
|
27
|
+
*/
|
|
28
|
+
export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
29
|
+
// Hub Form template custom processing
|
|
30
|
+
if (isHubFormTemplate(template)) {
|
|
31
|
+
return createItemFromHubTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
|
|
32
|
+
}
|
|
33
|
+
// otherwise delegate to simple types
|
|
34
|
+
return simpleTypes.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
|
|
35
|
+
}
|
|
36
36
|
//# sourceMappingURL=create-item-from-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 { 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
|
+
/** @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,74 +1,74 @@
|
|
|
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 { getUniqueTitle, getPortalDefaultBasemap } from "@esri/solution-common";
|
|
17
|
-
import { encodeSurveyForm } from "./encode-survey-form";
|
|
18
|
-
/**
|
|
19
|
-
* Utility method for creating Survey123 parameters
|
|
20
|
-
*
|
|
21
|
-
* @module build-create-params
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* Builds the Survey123 create API parameters
|
|
25
|
-
*
|
|
26
|
-
* @param {IItemTemplate} template The template
|
|
27
|
-
* @param {any} templateDictionary The template dictionary
|
|
28
|
-
* @param {UserSession} destinationAuthentication The destination session info
|
|
29
|
-
* @returns {Promise<ISurvey123CreateParams>}
|
|
30
|
-
*/
|
|
31
|
-
export function buildCreateParams(template, templateDictionary, destinationAuthentication) {
|
|
32
|
-
const { item: { title: originalTitle, description, tags, typeKeywords }, properties: { form: unencodedForm } } = template;
|
|
33
|
-
const { user: { username }, portalBaseUrl: portalUrl, organization: { basemapGalleryGroupQuery, defaultBasemap: { title: basemapTitle } } } = templateDictionary;
|
|
34
|
-
const { token } = destinationAuthentication.toCredential();
|
|
35
|
-
return getPortalDefaultBasemap(basemapGalleryGroupQuery, basemapTitle, destinationAuthentication).then(defaultBasemap => {
|
|
36
|
-
// The S123 API appends "Survey-" to the survey title when computing
|
|
37
|
-
// the folder name. We need to use the same prefix to successfully
|
|
38
|
-
// calculate a unique folder name. Afterwards, we can safely remove the
|
|
39
|
-
// prefix from the title
|
|
40
|
-
const folderPrefix = "Survey-";
|
|
41
|
-
const title = getUniqueTitle(`${folderPrefix}${originalTitle}`, templateDictionary, "user.folders").replace(folderPrefix, "");
|
|
42
|
-
// set any map question's basemaps to default org basemap
|
|
43
|
-
if (unencodedForm.questions) {
|
|
44
|
-
const updateBasemap = (question) => {
|
|
45
|
-
if (question.maps) {
|
|
46
|
-
question.maps = question.maps.map((map) => ({
|
|
47
|
-
...map,
|
|
48
|
-
itemId: defaultBasemap.id
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
return question;
|
|
52
|
-
};
|
|
53
|
-
unencodedForm.questions = unencodedForm.questions.map((question) => !question.questions
|
|
54
|
-
? updateBasemap(question)
|
|
55
|
-
: {
|
|
56
|
-
...question,
|
|
57
|
-
questions: question.questions.map(updateBasemap)
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
const form = encodeSurveyForm(unencodedForm);
|
|
61
|
-
// intentionally undefined, handled downstream by core logic now
|
|
62
|
-
return {
|
|
63
|
-
description,
|
|
64
|
-
form,
|
|
65
|
-
portalUrl,
|
|
66
|
-
tags,
|
|
67
|
-
title,
|
|
68
|
-
token,
|
|
69
|
-
typeKeywords,
|
|
70
|
-
username
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
}
|
|
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 { getUniqueTitle, getPortalDefaultBasemap } from "@esri/solution-common";
|
|
17
|
+
import { encodeSurveyForm } from "./encode-survey-form";
|
|
18
|
+
/**
|
|
19
|
+
* Utility method for creating Survey123 parameters
|
|
20
|
+
*
|
|
21
|
+
* @module build-create-params
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Builds the Survey123 create API parameters
|
|
25
|
+
*
|
|
26
|
+
* @param {IItemTemplate} template The template
|
|
27
|
+
* @param {any} templateDictionary The template dictionary
|
|
28
|
+
* @param {UserSession} destinationAuthentication The destination session info
|
|
29
|
+
* @returns {Promise<ISurvey123CreateParams>}
|
|
30
|
+
*/
|
|
31
|
+
export function buildCreateParams(template, templateDictionary, destinationAuthentication) {
|
|
32
|
+
const { item: { title: originalTitle, description, tags, typeKeywords }, properties: { form: unencodedForm } } = template;
|
|
33
|
+
const { user: { username }, portalBaseUrl: portalUrl, organization: { basemapGalleryGroupQuery, defaultBasemap: { title: basemapTitle } } } = templateDictionary;
|
|
34
|
+
const { token } = destinationAuthentication.toCredential();
|
|
35
|
+
return getPortalDefaultBasemap(basemapGalleryGroupQuery, basemapTitle, destinationAuthentication).then(defaultBasemap => {
|
|
36
|
+
// The S123 API appends "Survey-" to the survey title when computing
|
|
37
|
+
// the folder name. We need to use the same prefix to successfully
|
|
38
|
+
// calculate a unique folder name. Afterwards, we can safely remove the
|
|
39
|
+
// prefix from the title
|
|
40
|
+
const folderPrefix = "Survey-";
|
|
41
|
+
const title = getUniqueTitle(`${folderPrefix}${originalTitle}`, templateDictionary, "user.folders").replace(folderPrefix, "");
|
|
42
|
+
// set any map question's basemaps to default org basemap
|
|
43
|
+
if (unencodedForm.questions) {
|
|
44
|
+
const updateBasemap = (question) => {
|
|
45
|
+
if (question.maps) {
|
|
46
|
+
question.maps = question.maps.map((map) => ({
|
|
47
|
+
...map,
|
|
48
|
+
itemId: defaultBasemap.id
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
return question;
|
|
52
|
+
};
|
|
53
|
+
unencodedForm.questions = unencodedForm.questions.map((question) => !question.questions
|
|
54
|
+
? updateBasemap(question)
|
|
55
|
+
: {
|
|
56
|
+
...question,
|
|
57
|
+
questions: question.questions.map(updateBasemap)
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const form = encodeSurveyForm(unencodedForm);
|
|
61
|
+
// intentionally undefined, handled downstream by core logic now
|
|
62
|
+
return {
|
|
63
|
+
description,
|
|
64
|
+
form,
|
|
65
|
+
portalUrl,
|
|
66
|
+
tags,
|
|
67
|
+
title,
|
|
68
|
+
token,
|
|
69
|
+
typeKeywords,
|
|
70
|
+
username
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
74
|
//# sourceMappingURL=build-create-params.js.map
|
|
@@ -1,32 +1,32 @@
|
|
|
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>;
|
|
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>;
|
|
@@ -1,76 +1,76 @@
|
|
|
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 { EItemProgressStatus, replaceInTemplate, updateItemExtended, getItemBase } from "@esri/solution-common";
|
|
17
|
-
import { createSurvey } from "./create-survey";
|
|
18
|
-
import { buildCreateParams } from "./build-create-params";
|
|
19
|
-
/**
|
|
20
|
-
* Manages the creation of Surveys from Hub Templates
|
|
21
|
-
* via the Survey123 API
|
|
22
|
-
*
|
|
23
|
-
* @module create-item-from-hub-template
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* Orchestrates creation of Surveys from Hub templates
|
|
27
|
-
*
|
|
28
|
-
* @param {IItemTemplate} template The template
|
|
29
|
-
* @param {any} templateDictionary The template dictionary
|
|
30
|
-
* @param {UserSession} destinationAuthentication The destination session info
|
|
31
|
-
* @param {Function} itemProgressCallback A progress callback
|
|
32
|
-
* @returns {Promise<ICreateItemFromTemplateResponse>}
|
|
33
|
-
*/
|
|
34
|
-
export function createItemFromHubTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
35
|
-
const interpolatedTemplate = replaceInTemplate(template, templateDictionary);
|
|
36
|
-
const { survey123Url } = templateDictionary;
|
|
37
|
-
return buildCreateParams(interpolatedTemplate, templateDictionary, destinationAuthentication)
|
|
38
|
-
.then((params) => {
|
|
39
|
-
return createSurvey(params, survey123Url);
|
|
40
|
-
})
|
|
41
|
-
.then((createSurveyResponse) => {
|
|
42
|
-
const { formId, featureServiceId } = createSurveyResponse;
|
|
43
|
-
// Update the item with its thumbnail
|
|
44
|
-
let thumbDef = Promise.resolve(null);
|
|
45
|
-
/* istanbul ignore else */
|
|
46
|
-
if (template.item.thumbnail) {
|
|
47
|
-
thumbDef = updateItemExtended({ id: formId }, null, destinationAuthentication, template.item.thumbnail);
|
|
48
|
-
}
|
|
49
|
-
return thumbDef
|
|
50
|
-
.then(() => getItemBase(formId, destinationAuthentication))
|
|
51
|
-
.then(item => {
|
|
52
|
-
templateDictionary[interpolatedTemplate.itemId] = {
|
|
53
|
-
itemId: formId
|
|
54
|
-
};
|
|
55
|
-
templateDictionary[interpolatedTemplate.properties.info.serviceInfo.itemId] = {
|
|
56
|
-
itemId: featureServiceId
|
|
57
|
-
};
|
|
58
|
-
itemProgressCallback(interpolatedTemplate.itemId, EItemProgressStatus.Finished, interpolatedTemplate.estimatedDeploymentCostFactor, formId);
|
|
59
|
-
return {
|
|
60
|
-
item: {
|
|
61
|
-
...template,
|
|
62
|
-
item,
|
|
63
|
-
itemId: formId
|
|
64
|
-
},
|
|
65
|
-
id: formId,
|
|
66
|
-
type: "Form",
|
|
67
|
-
postProcess: true
|
|
68
|
-
};
|
|
69
|
-
});
|
|
70
|
-
})
|
|
71
|
-
.catch(e => {
|
|
72
|
-
itemProgressCallback(interpolatedTemplate.itemId, EItemProgressStatus.Failed, 0);
|
|
73
|
-
throw e;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
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 { EItemProgressStatus, replaceInTemplate, updateItemExtended, getItemBase } from "@esri/solution-common";
|
|
17
|
+
import { createSurvey } from "./create-survey";
|
|
18
|
+
import { buildCreateParams } from "./build-create-params";
|
|
19
|
+
/**
|
|
20
|
+
* Manages the creation of Surveys from Hub Templates
|
|
21
|
+
* via the Survey123 API
|
|
22
|
+
*
|
|
23
|
+
* @module create-item-from-hub-template
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Orchestrates creation of Surveys from Hub templates
|
|
27
|
+
*
|
|
28
|
+
* @param {IItemTemplate} template The template
|
|
29
|
+
* @param {any} templateDictionary The template dictionary
|
|
30
|
+
* @param {UserSession} destinationAuthentication The destination session info
|
|
31
|
+
* @param {Function} itemProgressCallback A progress callback
|
|
32
|
+
* @returns {Promise<ICreateItemFromTemplateResponse>}
|
|
33
|
+
*/
|
|
34
|
+
export function createItemFromHubTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
35
|
+
const interpolatedTemplate = replaceInTemplate(template, templateDictionary);
|
|
36
|
+
const { survey123Url } = templateDictionary;
|
|
37
|
+
return buildCreateParams(interpolatedTemplate, templateDictionary, destinationAuthentication)
|
|
38
|
+
.then((params) => {
|
|
39
|
+
return createSurvey(params, survey123Url);
|
|
40
|
+
})
|
|
41
|
+
.then((createSurveyResponse) => {
|
|
42
|
+
const { formId, featureServiceId } = createSurveyResponse;
|
|
43
|
+
// Update the item with its thumbnail
|
|
44
|
+
let thumbDef = Promise.resolve(null);
|
|
45
|
+
/* istanbul ignore else */
|
|
46
|
+
if (template.item.thumbnail) {
|
|
47
|
+
thumbDef = updateItemExtended({ id: formId }, null, destinationAuthentication, template.item.thumbnail);
|
|
48
|
+
}
|
|
49
|
+
return thumbDef
|
|
50
|
+
.then(() => getItemBase(formId, destinationAuthentication))
|
|
51
|
+
.then(item => {
|
|
52
|
+
templateDictionary[interpolatedTemplate.itemId] = {
|
|
53
|
+
itemId: formId
|
|
54
|
+
};
|
|
55
|
+
templateDictionary[interpolatedTemplate.properties.info.serviceInfo.itemId] = {
|
|
56
|
+
itemId: featureServiceId
|
|
57
|
+
};
|
|
58
|
+
itemProgressCallback(interpolatedTemplate.itemId, EItemProgressStatus.Finished, interpolatedTemplate.estimatedDeploymentCostFactor, formId);
|
|
59
|
+
return {
|
|
60
|
+
item: {
|
|
61
|
+
...template,
|
|
62
|
+
item,
|
|
63
|
+
itemId: formId
|
|
64
|
+
},
|
|
65
|
+
id: formId,
|
|
66
|
+
type: "Form",
|
|
67
|
+
postProcess: true
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
})
|
|
71
|
+
.catch(e => {
|
|
72
|
+
itemProgressCallback(interpolatedTemplate.itemId, EItemProgressStatus.Failed, 0);
|
|
73
|
+
throw e;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
76
|
//# 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>;
|