@esri/solution-form 4.1.2 → 5.0.1

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.
Files changed (41) hide show
  1. package/dist/cjs/convert-item-to-template.d.ts +32 -32
  2. package/dist/cjs/convert-item-to-template.js +34 -34
  3. package/dist/cjs/create-item-from-template.d.ts +31 -31
  4. package/dist/cjs/create-item-from-template.js +39 -39
  5. package/dist/cjs/helpers/build-create-params.d.ts +30 -30
  6. package/dist/cjs/helpers/build-create-params.js +77 -77
  7. package/dist/cjs/helpers/create-item-from-hub-template.d.ts +32 -32
  8. package/dist/cjs/helpers/create-item-from-hub-template.js +79 -79
  9. package/dist/cjs/helpers/create-survey.d.ts +30 -30
  10. package/dist/cjs/helpers/create-survey.js +59 -59
  11. package/dist/cjs/helpers/encode-survey-form.d.ts +28 -28
  12. package/dist/cjs/helpers/encode-survey-form.js +58 -58
  13. package/dist/cjs/helpers/is-hub-form-template.d.ts +24 -24
  14. package/dist/cjs/helpers/is-hub-form-template.js +32 -32
  15. package/dist/cjs/helpers/post-process-survey.d.ts +33 -33
  16. package/dist/cjs/helpers/post-process-survey.js +81 -81
  17. package/dist/cjs/index.d.ts +23 -23
  18. package/dist/cjs/index.js +26 -26
  19. package/dist/cjs/post-process.d.ts +32 -32
  20. package/dist/cjs/post-process.js +43 -43
  21. package/dist/esm/convert-item-to-template.d.ts +32 -32
  22. package/dist/esm/convert-item-to-template.js +30 -30
  23. package/dist/esm/create-item-from-template.d.ts +31 -31
  24. package/dist/esm/create-item-from-template.js +35 -35
  25. package/dist/esm/helpers/build-create-params.d.ts +30 -30
  26. package/dist/esm/helpers/build-create-params.js +73 -73
  27. package/dist/esm/helpers/create-item-from-hub-template.d.ts +32 -32
  28. package/dist/esm/helpers/create-item-from-hub-template.js +75 -75
  29. package/dist/esm/helpers/create-survey.d.ts +30 -30
  30. package/dist/esm/helpers/create-survey.js +55 -55
  31. package/dist/esm/helpers/encode-survey-form.d.ts +28 -28
  32. package/dist/esm/helpers/encode-survey-form.js +54 -54
  33. package/dist/esm/helpers/is-hub-form-template.d.ts +24 -24
  34. package/dist/esm/helpers/is-hub-form-template.js +27 -27
  35. package/dist/esm/helpers/post-process-survey.d.ts +33 -33
  36. package/dist/esm/helpers/post-process-survey.js +77 -77
  37. package/dist/esm/index.d.ts +23 -23
  38. package/dist/esm/index.js +23 -23
  39. package/dist/esm/post-process.d.ts +32 -32
  40. package/dist/esm/post-process.js +39 -39
  41. package/package.json +9 -9
@@ -1,32 +1,32 @@
1
- /** @license
2
- * Copyright 2018 Esri
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- /**
17
- * Manages the creation of Form templates
18
- *
19
- * @module convert-item-to-template
20
- */
21
- import { UserSession, IItemTemplate } from "@esri/solution-common";
22
- /**
23
- * Creates a template from a Form item
24
- *
25
- * @param {string} solutionItemId The solution item ID
26
- * @param {any} itemInfo: The base item info
27
- * @param {UserSession} destAuthentication Credentials for requests to the destination organization
28
- * @param {UserSession} srcAuthentication Credentials for requests to source items
29
- * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
30
- * @returns {Promise<IItemTemplate>}
31
- */
32
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession, templateDictionary: any): Promise<IItemTemplate>;
1
+ /** @license
2
+ * Copyright 2018 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Manages the creation of Form templates
18
+ *
19
+ * @module convert-item-to-template
20
+ */
21
+ import { UserSession, IItemTemplate } from "@esri/solution-common";
22
+ /**
23
+ * Creates a template from a Form item
24
+ *
25
+ * @param {string} solutionItemId The solution item ID
26
+ * @param {any} itemInfo: The base item info
27
+ * @param {UserSession} destAuthentication Credentials for requests to the destination organization
28
+ * @param {UserSession} srcAuthentication Credentials for requests to source items
29
+ * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
30
+ * @returns {Promise<IItemTemplate>}
31
+ */
32
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession, templateDictionary: any): Promise<IItemTemplate>;
@@ -1,35 +1,35 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2018 Esri
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.convertItemToTemplate = void 0;
19
- const solution_simple_types_1 = require("@esri/solution-simple-types");
20
- /**
21
- * Creates a template from a Form item
22
- *
23
- * @param {string} solutionItemId The solution item ID
24
- * @param {any} itemInfo: The base item info
25
- * @param {UserSession} destAuthentication Credentials for requests to the destination organization
26
- * @param {UserSession} srcAuthentication Credentials for requests to source items
27
- * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
28
- * @returns {Promise<IItemTemplate>}
29
- */
30
- function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
31
- // Delegate to simple types
32
- return solution_simple_types_1.simpleTypes.convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary);
33
- }
34
- exports.convertItemToTemplate = convertItemToTemplate;
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2018 Esri
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.convertItemToTemplate = void 0;
19
+ const solution_simple_types_1 = require("@esri/solution-simple-types");
20
+ /**
21
+ * Creates a template from a Form item
22
+ *
23
+ * @param {string} solutionItemId The solution item ID
24
+ * @param {any} itemInfo: The base item info
25
+ * @param {UserSession} destAuthentication Credentials for requests to the destination organization
26
+ * @param {UserSession} srcAuthentication Credentials for requests to source items
27
+ * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
28
+ * @returns {Promise<IItemTemplate>}
29
+ */
30
+ function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
31
+ // Delegate to simple types
32
+ return solution_simple_types_1.simpleTypes.convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary);
33
+ }
34
+ exports.convertItemToTemplate = convertItemToTemplate;
35
35
  //# sourceMappingURL=convert-item-to-template.js.map
@@ -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,40 +1,40 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2018 Esri
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.createItemFromTemplate = void 0;
19
- const solution_simple_types_1 = require("@esri/solution-simple-types");
20
- const is_hub_form_template_1 = require("./helpers/is-hub-form-template");
21
- const create_item_from_hub_template_1 = require("./helpers/create-item-from-hub-template");
22
- /**
23
- * Creates a Form item from a template
24
- *
25
- * @param {IItemTemplate} template The template
26
- * @param {any} templateDictionary The template dictionary
27
- * @param {UserSession} destinationAuthentication The destination user session info
28
- * @param itemProgressCallback An item progress callback
29
- * @returns {Promise<ICreateItemFromTemplateResponse>}
30
- */
31
- function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
32
- // Hub Form template custom processing
33
- if ((0, is_hub_form_template_1.isHubFormTemplate)(template)) {
34
- return (0, create_item_from_hub_template_1.createItemFromHubTemplate)(template, templateDictionary, destinationAuthentication, itemProgressCallback);
35
- }
36
- // otherwise delegate to simple types
37
- return solution_simple_types_1.simpleTypes.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
38
- }
39
- exports.createItemFromTemplate = createItemFromTemplate;
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2018 Esri
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.createItemFromTemplate = void 0;
19
+ const solution_simple_types_1 = require("@esri/solution-simple-types");
20
+ const is_hub_form_template_1 = require("./helpers/is-hub-form-template");
21
+ const create_item_from_hub_template_1 = require("./helpers/create-item-from-hub-template");
22
+ /**
23
+ * Creates a Form item from a template
24
+ *
25
+ * @param {IItemTemplate} template The template
26
+ * @param {any} templateDictionary The template dictionary
27
+ * @param {UserSession} destinationAuthentication The destination user session info
28
+ * @param itemProgressCallback An item progress callback
29
+ * @returns {Promise<ICreateItemFromTemplateResponse>}
30
+ */
31
+ function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
32
+ // Hub Form template custom processing
33
+ if ((0, is_hub_form_template_1.isHubFormTemplate)(template)) {
34
+ return (0, create_item_from_hub_template_1.createItemFromHubTemplate)(template, templateDictionary, destinationAuthentication, itemProgressCallback);
35
+ }
36
+ // otherwise delegate to simple types
37
+ return solution_simple_types_1.simpleTypes.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
38
+ }
39
+ exports.createItemFromTemplate = createItemFromTemplate;
40
40
  //# 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,78 +1,78 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2020 Esri
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.buildCreateParams = void 0;
19
- const solution_common_1 = require("@esri/solution-common");
20
- const encode_survey_form_1 = require("./encode-survey-form");
21
- /**
22
- * Utility method for creating Survey123 parameters
23
- *
24
- * @module build-create-params
25
- */
26
- /**
27
- * Builds the Survey123 create API parameters
28
- *
29
- * @param {IItemTemplate} template The template
30
- * @param {any} templateDictionary The template dictionary
31
- * @param {UserSession} destinationAuthentication The destination session info
32
- * @returns {Promise<ISurvey123CreateParams>}
33
- */
34
- function buildCreateParams(template, templateDictionary, destinationAuthentication) {
35
- const { item: { title: originalTitle, description, tags, typeKeywords }, properties: { form: unencodedForm } } = template;
36
- const { user: { username }, portalBaseUrl: portalUrl, organization: { basemapGalleryGroupQuery, defaultBasemap: { title: basemapTitle } } } = templateDictionary;
37
- const { token } = destinationAuthentication.toCredential();
38
- return (0, solution_common_1.getPortalDefaultBasemap)(basemapGalleryGroupQuery, basemapTitle, destinationAuthentication).then(defaultBasemap => {
39
- // The S123 API appends "Survey-" to the survey title when computing
40
- // the folder name. We need to use the same prefix to successfully
41
- // calculate a unique folder name. Afterwards, we can safely remove the
42
- // prefix from the title
43
- const folderPrefix = "Survey-";
44
- const title = (0, solution_common_1.getUniqueTitle)(`${folderPrefix}${originalTitle}`, templateDictionary, "user.folders").replace(folderPrefix, "");
45
- // set any map question's basemaps to default org basemap
46
- if (unencodedForm.questions) {
47
- const updateBasemap = (question) => {
48
- if (question.maps) {
49
- question.maps = question.maps.map((map) => ({
50
- ...map,
51
- itemId: defaultBasemap.id
52
- }));
53
- }
54
- return question;
55
- };
56
- unencodedForm.questions = unencodedForm.questions.map((question) => !question.questions
57
- ? updateBasemap(question)
58
- : {
59
- ...question,
60
- questions: question.questions.map(updateBasemap)
61
- });
62
- }
63
- const form = (0, encode_survey_form_1.encodeSurveyForm)(unencodedForm);
64
- // intentionally undefined, handled downstream by core logic now
65
- return {
66
- description,
67
- form,
68
- portalUrl,
69
- tags,
70
- title,
71
- token,
72
- typeKeywords,
73
- username
74
- };
75
- });
76
- }
77
- exports.buildCreateParams = buildCreateParams;
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2020 Esri
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.buildCreateParams = void 0;
19
+ const solution_common_1 = require("@esri/solution-common");
20
+ const encode_survey_form_1 = require("./encode-survey-form");
21
+ /**
22
+ * Utility method for creating Survey123 parameters
23
+ *
24
+ * @module build-create-params
25
+ */
26
+ /**
27
+ * Builds the Survey123 create API parameters
28
+ *
29
+ * @param {IItemTemplate} template The template
30
+ * @param {any} templateDictionary The template dictionary
31
+ * @param {UserSession} destinationAuthentication The destination session info
32
+ * @returns {Promise<ISurvey123CreateParams>}
33
+ */
34
+ function buildCreateParams(template, templateDictionary, destinationAuthentication) {
35
+ const { item: { title: originalTitle, description, tags, typeKeywords }, properties: { form: unencodedForm } } = template;
36
+ const { user: { username }, portalBaseUrl: portalUrl, organization: { basemapGalleryGroupQuery, defaultBasemap: { title: basemapTitle } } } = templateDictionary;
37
+ const { token } = destinationAuthentication.toCredential();
38
+ return (0, solution_common_1.getPortalDefaultBasemap)(basemapGalleryGroupQuery, basemapTitle, destinationAuthentication).then(defaultBasemap => {
39
+ // The S123 API appends "Survey-" to the survey title when computing
40
+ // the folder name. We need to use the same prefix to successfully
41
+ // calculate a unique folder name. Afterwards, we can safely remove the
42
+ // prefix from the title
43
+ const folderPrefix = "Survey-";
44
+ const title = (0, solution_common_1.getUniqueTitle)(`${folderPrefix}${originalTitle}`, templateDictionary, "user.folders").replace(folderPrefix, "");
45
+ // set any map question's basemaps to default org basemap
46
+ if (unencodedForm.questions) {
47
+ const updateBasemap = (question) => {
48
+ if (question.maps) {
49
+ question.maps = question.maps.map((map) => ({
50
+ ...map,
51
+ itemId: defaultBasemap.id
52
+ }));
53
+ }
54
+ return question;
55
+ };
56
+ unencodedForm.questions = unencodedForm.questions.map((question) => !question.questions
57
+ ? updateBasemap(question)
58
+ : {
59
+ ...question,
60
+ questions: question.questions.map(updateBasemap)
61
+ });
62
+ }
63
+ const form = (0, encode_survey_form_1.encodeSurveyForm)(unencodedForm);
64
+ // intentionally undefined, handled downstream by core logic now
65
+ return {
66
+ description,
67
+ form,
68
+ portalUrl,
69
+ tags,
70
+ title,
71
+ token,
72
+ typeKeywords,
73
+ username
74
+ };
75
+ });
76
+ }
77
+ exports.buildCreateParams = buildCreateParams;
78
78
  //# 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>;