@esri/solution-form 1.1.4 → 1.3.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.
@@ -24,8 +24,9 @@ import { UserSession, IItemTemplate } from "@esri/solution-common";
24
24
  *
25
25
  * @param {string} solutionItemId The solution item ID
26
26
  * @param {any} itemInfo: The base item info
27
- * @param {UserSession} authentication The source user session information
27
+ * @param {UserSession} destAuthentication Credentials for requests to the destination organization
28
+ * @param {UserSession} srcAuthentication Credentials for requests to source items
28
29
  * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
29
30
  * @returns {Promise<IItemTemplate>}
30
31
  */
31
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, authentication: UserSession, templateDictionary: any): Promise<IItemTemplate>;
32
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession, templateDictionary: any): Promise<IItemTemplate>;
@@ -19,12 +19,13 @@ import { simpleTypes } from "@esri/solution-simple-types";
19
19
  *
20
20
  * @param {string} solutionItemId The solution item ID
21
21
  * @param {any} itemInfo: The base item info
22
- * @param {UserSession} authentication The source user session information
22
+ * @param {UserSession} destAuthentication Credentials for requests to the destination organization
23
+ * @param {UserSession} srcAuthentication Credentials for requests to source items
23
24
  * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
24
25
  * @returns {Promise<IItemTemplate>}
25
26
  */
26
- export function convertItemToTemplate(solutionItemId, itemInfo, authentication, templateDictionary) {
27
+ export function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
27
28
  // Delegate to simple types
28
- return simpleTypes.convertItemToTemplate(solutionItemId, itemInfo, authentication, templateDictionary);
29
+ return simpleTypes.convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary);
29
30
  }
30
31
  //# sourceMappingURL=convert-item-to-template.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"convert-item-to-template.js","sourceRoot":"","sources":["../../src/convert-item-to-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,cAA2B,EAC3B,kBAAuB;IAEvB,2BAA2B;IAC3B,OAAO,WAAW,CAAC,qBAAqB,CACtC,cAAc,EACd,QAAQ,EACR,cAAc,EACd,kBAAkB,CACnB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"convert-item-to-template.js","sourceRoot":"","sources":["../../src/convert-item-to-template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D;;;;;;;;;GASG;AACH,MAAM,UAAU,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,kBAA+B,EAC/B,iBAA8B,EAC9B,kBAAuB;IAEvB,2BAA2B;IAC3B,OAAO,WAAW,CAAC,qBAAqB,CACtC,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,CACnB,CAAC;AACJ,CAAC"}
@@ -41,7 +41,7 @@ export function buildCreateParams(template, templateDictionary, destinationAuthe
41
41
  const title = getUniqueTitle(`${folderPrefix}${originalTitle}`, templateDictionary, "user.folders").replace(folderPrefix, "");
42
42
  // set any map question's basemaps to default org basemap
43
43
  if (unencodedForm.questions) {
44
- unencodedForm.questions = unencodedForm.questions.map((question) => {
44
+ const updateBasemap = (question) => {
45
45
  if (question.maps) {
46
46
  question.maps = question.maps.map((map) => ({
47
47
  ...map,
@@ -49,7 +49,13 @@ export function buildCreateParams(template, templateDictionary, destinationAuthe
49
49
  }));
50
50
  }
51
51
  return question;
52
- });
52
+ };
53
+ unencodedForm.questions = unencodedForm.questions.map((question) => !question.questions
54
+ ? updateBasemap(question)
55
+ : {
56
+ ...question,
57
+ questions: question.questions.map(updateBasemap)
58
+ });
53
59
  }
54
60
  const form = encodeSurveyForm(unencodedForm);
55
61
  // intentionally undefined, handled downstream by core logic now
@@ -1 +1 @@
1
- {"version":3,"file":"build-create-params.js","sourceRoot":"","sources":["../../../src/helpers/build-create-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAGL,cAAc,EAEd,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;GAIG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAuB,EACvB,kBAAuB,EACvB,yBAAsC;IAEtC,MAAM,EACJ,IAAI,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,EAC/D,UAAU,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EACpC,GAAG,QAAQ,CAAC;IACb,MAAM,EACJ,IAAI,EAAE,EAAE,QAAQ,EAAE,EAClB,aAAa,EAAE,SAAS,EACxB,YAAY,EAAE,EACZ,wBAAwB,EACxB,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EACxC,EACF,GAAG,kBAAkB,CAAC;IACvB,MAAM,EAAE,KAAK,EAAE,GAAG,yBAAyB,CAAC,YAAY,EAAE,CAAC;IAC3D,OAAO,uBAAuB,CAC5B,wBAAwB,EACxB,YAAY,EACZ,yBAAyB,CAC1B,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE;QACtB,oEAAoE;QACpE,kEAAkE;QAClE,uEAAuE;QACvE,wBAAwB;QACxB,MAAM,YAAY,GAAG,SAAS,CAAC;QAC/B,MAAM,KAAK,GAAG,cAAc,CAC1B,GAAG,YAAY,GAAG,aAAa,EAAE,EACjC,kBAAkB,EAClB,cAAc,CACf,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC5B,yDAAyD;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,CAAC;QAC7C,gEAAgE;QAChE,OAAO;YACL,WAAW;YACX,IAAI;YACJ,SAAS;YACT,IAAI;YACJ,KAAK;YACL,KAAK;YACL,YAAY;YACZ,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -42,8 +42,14 @@ export const encodeSurveyForm = function encodeForm(form) {
42
42
  };
43
43
  // encode props from array above
44
44
  props.forEach(([objKey, propKey]) => encode(clone[objKey], propKey));
45
+ const encodeQuestion = (question) => encode(question, "description");
45
46
  // encode question descriptions
46
- clone.questions = (clone.questions || []).map((question) => encode(question, "description"));
47
+ clone.questions = (clone.questions || []).map((question) => !question.questions
48
+ ? encodeQuestion(question)
49
+ : {
50
+ ...question,
51
+ questions: question.questions.map(encodeQuestion)
52
+ });
47
53
  return clone;
48
54
  };
49
55
  //# sourceMappingURL=encode-survey-form.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"encode-survey-form.js","sourceRoot":"","sources":["../../../src/helpers/encode-survey-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,UAAU,CAAC,IAAS;IAC3D,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG;QACZ,CAAC,QAAQ,EAAE,SAAS,CAAC;QACrB,CAAC,WAAW,EAAE,SAAS,CAAC;QACxB,CAAC,QAAQ,EAAE,SAAS,CAAC;QACrB,CAAC,UAAU,EAAE,uBAAuB,CAAC;KACtC,CAAC;IACF,MAAM,MAAM,GAAG,CACb,GAA8B,EAC9B,GAAW,EACgB,EAAE;QAC7B,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE;YACnB,GAAG,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,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AAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAErE,MAAM,cAAc,GAAG,CAAC,QAAa,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAE1E,+BAA+B;IAC/B,KAAK,CAAC,SAAS,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CAC9D,CAAC,QAAQ,CAAC,SAAS;QACjB,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC;QAC1B,CAAC,CAAC;YACA,GAAG,QAAQ;YACX,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC;SAClD,CACJ,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -24,8 +24,9 @@ import { UserSession, IItemTemplate } from "@esri/solution-common";
24
24
  *
25
25
  * @param {string} solutionItemId The solution item ID
26
26
  * @param {any} itemInfo: The base item info
27
- * @param {UserSession} authentication The source user session information
27
+ * @param {UserSession} destAuthentication Credentials for requests to the destination organization
28
+ * @param {UserSession} srcAuthentication Credentials for requests to source items
28
29
  * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
29
30
  * @returns {Promise<IItemTemplate>}
30
31
  */
31
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, authentication: UserSession, templateDictionary: any): Promise<IItemTemplate>;
32
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession, templateDictionary: any): Promise<IItemTemplate>;
@@ -22,13 +22,14 @@ const solution_simple_types_1 = require("@esri/solution-simple-types");
22
22
  *
23
23
  * @param {string} solutionItemId The solution item ID
24
24
  * @param {any} itemInfo: The base item info
25
- * @param {UserSession} authentication The source user session information
25
+ * @param {UserSession} destAuthentication Credentials for requests to the destination organization
26
+ * @param {UserSession} srcAuthentication Credentials for requests to source items
26
27
  * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
27
28
  * @returns {Promise<IItemTemplate>}
28
29
  */
29
- function convertItemToTemplate(solutionItemId, itemInfo, authentication, templateDictionary) {
30
+ function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
30
31
  // Delegate to simple types
31
- return solution_simple_types_1.simpleTypes.convertItemToTemplate(solutionItemId, itemInfo, authentication, templateDictionary);
32
+ return solution_simple_types_1.simpleTypes.convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary);
32
33
  }
33
34
  exports.convertItemToTemplate = convertItemToTemplate;
34
35
  //# sourceMappingURL=convert-item-to-template.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"convert-item-to-template.js","sourceRoot":"","sources":["../../src/convert-item-to-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AASH,uEAA0D;AAE1D;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,cAA2B,EAC3B,kBAAuB;IAEvB,2BAA2B;IAC3B,OAAO,mCAAW,CAAC,qBAAqB,CACtC,cAAc,EACd,QAAQ,EACR,cAAc,EACd,kBAAkB,CACnB,CAAC;AACJ,CAAC;AAbD,sDAaC"}
1
+ {"version":3,"file":"convert-item-to-template.js","sourceRoot":"","sources":["../../src/convert-item-to-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AASH,uEAA0D;AAE1D;;;;;;;;;GASG;AACH,SAAgB,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,kBAA+B,EAC/B,iBAA8B,EAC9B,kBAAuB;IAEvB,2BAA2B;IAC3B,OAAO,mCAAW,CAAC,qBAAqB,CACtC,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,CACnB,CAAC;AACJ,CAAC;AAfD,sDAeC"}
@@ -44,7 +44,7 @@ function buildCreateParams(template, templateDictionary, destinationAuthenticati
44
44
  const title = (0, solution_common_1.getUniqueTitle)(`${folderPrefix}${originalTitle}`, templateDictionary, "user.folders").replace(folderPrefix, "");
45
45
  // set any map question's basemaps to default org basemap
46
46
  if (unencodedForm.questions) {
47
- unencodedForm.questions = unencodedForm.questions.map((question) => {
47
+ const updateBasemap = (question) => {
48
48
  if (question.maps) {
49
49
  question.maps = question.maps.map((map) => ({
50
50
  ...map,
@@ -52,7 +52,13 @@ function buildCreateParams(template, templateDictionary, destinationAuthenticati
52
52
  }));
53
53
  }
54
54
  return question;
55
- });
55
+ };
56
+ unencodedForm.questions = unencodedForm.questions.map((question) => !question.questions
57
+ ? updateBasemap(question)
58
+ : {
59
+ ...question,
60
+ questions: question.questions.map(updateBasemap)
61
+ });
56
62
  }
57
63
  const form = (0, encode_survey_form_1.encodeSurveyForm)(unencodedForm);
58
64
  // intentionally undefined, handled downstream by core logic now
@@ -1 +1 @@
1
- {"version":3,"file":"build-create-params.js","sourceRoot":"","sources":["../../../src/helpers/build-create-params.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2DAM+B;AAC/B,6DAAwD;AAExD;;;;GAIG;AAEH;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAC/B,QAAuB,EACvB,kBAAuB,EACvB,yBAAsC;IAEtC,MAAM,EACJ,IAAI,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,EAC/D,UAAU,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EACpC,GAAG,QAAQ,CAAC;IACb,MAAM,EACJ,IAAI,EAAE,EAAE,QAAQ,EAAE,EAClB,aAAa,EAAE,SAAS,EACxB,YAAY,EAAE,EACZ,wBAAwB,EACxB,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,EACxC,EACF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,CAAC,CAAC,CAAC;iBACL;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC,CAAC;YACF,aAAa,CAAC,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CACtE,CAAC,QAAQ,CAAC,SAAS;gBACjB,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC;gBACzB,CAAC,CAAC;oBACA,GAAG,QAAQ;oBACX,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC;iBACjD,CACJ,CAAC;SACH;QACD,MAAM,IAAI,GAAG,IAAA,qCAAgB,EAAC,aAAa,CAAC,CAAC;QAC7C,gEAAgE;QAChE,OAAO;YACL,WAAW;YACX,IAAI;YACJ,SAAS;YACT,IAAI;YACJ,KAAK;YACL,KAAK;YACL,YAAY;YACZ,QAAQ;SACT,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAlED,8CAkEC"}
@@ -45,8 +45,14 @@ const encodeSurveyForm = function encodeForm(form) {
45
45
  };
46
46
  // encode props from array above
47
47
  props.forEach(([objKey, propKey]) => encode(clone[objKey], propKey));
48
+ const encodeQuestion = (question) => encode(question, "description");
48
49
  // encode question descriptions
49
- clone.questions = (clone.questions || []).map((question) => encode(question, "description"));
50
+ clone.questions = (clone.questions || []).map((question) => !question.questions
51
+ ? encodeQuestion(question)
52
+ : {
53
+ ...question,
54
+ questions: question.questions.map(encodeQuestion)
55
+ });
50
56
  return clone;
51
57
  };
52
58
  exports.encodeSurveyForm = encodeSurveyForm;
@@ -1 +1 @@
1
- {"version":3,"file":"encode-survey-form.js","sourceRoot":"","sources":["../../../src/helpers/encode-survey-form.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2DAAoD;AAEpD;;;;GAIG;AAEH;;;;;;GAMG;AACI,MAAM,gBAAgB,GAAG,SAAS,UAAU,CAAC,IAAS;IAC3D,MAAM,KAAK,GAAG,IAAA,6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AAC,WAAW,EAAE,SAAS,CAAC;QACxB,CAAC,QAAQ,EAAE,SAAS,CAAC;QACrB,CAAC,UAAU,EAAE,uBAAuB,CAAC;KACtC,CAAC;IACF,MAAM,MAAM,GAAG,CACb,GAA8B,EAC9B,GAAW,EACgB,EAAE;QAC7B,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE;YACnB,GAAG,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SACzC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;IAEF,gCAAgC;IAChC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAErE,MAAM,cAAc,GAAG,CAAC,QAAa,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAE1E,+BAA+B;IAC/B,KAAK,CAAC,SAAS,GAAG,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAa,EAAE,EAAE,CAC9D,CAAC,QAAQ,CAAC,SAAS;QACjB,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC;QAC1B,CAAC,CAAC;YACA,GAAG,QAAQ;YACX,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC;SAClD,CACJ,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAlCW,QAAA,gBAAgB,oBAkC3B"}
@@ -16,7 +16,8 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.isHubFormTemplate = void 0;
19
- const common = require("@esri/solution-common");
19
+ const tslib_1 = require("tslib");
20
+ const common = (0, tslib_1.__importStar)(require("@esri/solution-common"));
20
21
  /**
21
22
  * Determines if the given template is a Hub Survey
22
23
  * template vs Solutions.js Survey template.
@@ -1 +1 @@
1
- {"version":3,"file":"is-hub-form-template.js","sourceRoot":"","sources":["../../../src/helpers/is-hub-form-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,gDAAgD;AAEhD;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,QAA8B;IAC9D,2EAA2E;IAC3E,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;AAC3D,CAAC;AAHD,8CAGC"}
1
+ {"version":3,"file":"is-hub-form-template.js","sourceRoot":"","sources":["../../../src/helpers/is-hub-form-template.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,2EAAgD;AAEhD;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,QAA8B;IAC9D,2EAA2E;IAC3E,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;AAC3D,CAAC;AAHD,8CAGC"}
@@ -24,8 +24,9 @@ import { UserSession, IItemTemplate } from "@esri/solution-common";
24
24
  *
25
25
  * @param {string} solutionItemId The solution item ID
26
26
  * @param {any} itemInfo: The base item info
27
- * @param {UserSession} authentication The source user session information
27
+ * @param {UserSession} destAuthentication Credentials for requests to the destination organization
28
+ * @param {UserSession} srcAuthentication Credentials for requests to source items
28
29
  * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
29
30
  * @returns {Promise<IItemTemplate>}
30
31
  */
31
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, authentication: UserSession, templateDictionary: any): Promise<IItemTemplate>;
32
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: UserSession, srcAuthentication: UserSession, templateDictionary: any): Promise<IItemTemplate>;
@@ -1,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-form - v1.1.4 - Apache-2.0
3
- * Copyright (c) 2018-2021 Esri, Inc.
4
- * Tue Oct 26 2021 15:15:38 GMT-0700 (Pacific Daylight Time)
2
+ * @esri/solution-form - v1.3.1 - Apache-2.0
3
+ * Copyright (c) 2018-2022 Esri, Inc.
4
+ * Thu Feb 17 2022 10:45:17 GMT-0800 (Pacific Standard Time)
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -18,8 +18,28 @@
18
18
  (function (global, factory) {
19
19
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/solution-simple-types'), require('@esri/solution-common'), require('@esri/arcgis-rest-request'), require('@esri/arcgis-rest-portal')) :
20
20
  typeof define === 'function' && define.amd ? define(['exports', '@esri/solution-simple-types', '@esri/solution-common', '@esri/arcgis-rest-request', '@esri/arcgis-rest-portal'], factory) :
21
- (global = global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution, global.arcgisSolution, global.arcgisRest, global.arcgisRest));
22
- }(this, (function (exports, solutionSimpleTypes, common, arcgisRestRequest, arcgisRestPortal) { 'use strict';
21
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution, global.arcgisSolution, global.arcgisRest, global.arcgisRest));
22
+ })(this, (function (exports, solutionSimpleTypes, common, arcgisRestRequest, arcgisRestPortal) { 'use strict';
23
+
24
+ function _interopNamespace(e) {
25
+ if (e && e.__esModule) return e;
26
+ var n = Object.create(null);
27
+ if (e) {
28
+ Object.keys(e).forEach(function (k) {
29
+ if (k !== 'default') {
30
+ var d = Object.getOwnPropertyDescriptor(e, k);
31
+ Object.defineProperty(n, k, d.get ? d : {
32
+ enumerable: true,
33
+ get: function () { return e[k]; }
34
+ });
35
+ }
36
+ });
37
+ }
38
+ n["default"] = e;
39
+ return Object.freeze(n);
40
+ }
41
+
42
+ var common__namespace = /*#__PURE__*/_interopNamespace(common);
23
43
 
24
44
  /** @license
25
45
  * Copyright 2018 Esri
@@ -41,13 +61,14 @@
41
61
  *
42
62
  * @param {string} solutionItemId The solution item ID
43
63
  * @param {any} itemInfo: The base item info
44
- * @param {UserSession} authentication The source user session information
64
+ * @param {UserSession} destAuthentication Credentials for requests to the destination organization
65
+ * @param {UserSession} srcAuthentication Credentials for requests to source items
45
66
  * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
46
67
  * @returns {Promise<IItemTemplate>}
47
68
  */
48
- function convertItemToTemplate(solutionItemId, itemInfo, authentication, templateDictionary) {
69
+ function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
49
70
  // Delegate to simple types
50
- return solutionSimpleTypes.simpleTypes.convertItemToTemplate(solutionItemId, itemInfo, authentication, templateDictionary);
71
+ return solutionSimpleTypes.simpleTypes.convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary);
51
72
  }
52
73
 
53
74
  /** @license
@@ -74,7 +95,7 @@
74
95
  */
75
96
  function isHubFormTemplate(template) {
76
97
  // relying on basic duck typing vs adding extraneous props during migration
77
- return !!common.getProp(template, "properties.services");
98
+ return !!common__namespace.getProp(template, "properties.services");
78
99
  }
79
100
 
80
101
  /** @license
@@ -175,8 +196,14 @@
175
196
  };
176
197
  // encode props from array above
177
198
  props.forEach(([objKey, propKey]) => encode(clone[objKey], propKey));
199
+ const encodeQuestion = (question) => encode(question, "description");
178
200
  // encode question descriptions
179
- clone.questions = (clone.questions || []).map((question) => encode(question, "description"));
201
+ clone.questions = (clone.questions || []).map((question) => !question.questions
202
+ ? encodeQuestion(question)
203
+ : {
204
+ ...question,
205
+ questions: question.questions.map(encodeQuestion)
206
+ });
180
207
  return clone;
181
208
  };
182
209
 
@@ -221,7 +248,7 @@
221
248
  const title = common.getUniqueTitle(`${folderPrefix}${originalTitle}`, templateDictionary, "user.folders").replace(folderPrefix, "");
222
249
  // set any map question's basemaps to default org basemap
223
250
  if (unencodedForm.questions) {
224
- unencodedForm.questions = unencodedForm.questions.map((question) => {
251
+ const updateBasemap = (question) => {
225
252
  if (question.maps) {
226
253
  question.maps = question.maps.map((map) => ({
227
254
  ...map,
@@ -229,7 +256,13 @@
229
256
  }));
230
257
  }
231
258
  return question;
232
- });
259
+ };
260
+ unencodedForm.questions = unencodedForm.questions.map((question) => !question.questions
261
+ ? updateBasemap(question)
262
+ : {
263
+ ...question,
264
+ questions: question.questions.map(updateBasemap)
265
+ });
233
266
  }
234
267
  const form = encodeSurveyForm(unencodedForm);
235
268
  // intentionally undefined, handled downstream by core logic now
@@ -466,5 +499,5 @@
466
499
 
467
500
  Object.defineProperty(exports, '__esModule', { value: true });
468
501
 
469
- })));
502
+ }));
470
503
  //# sourceMappingURL=form.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.umd.js","sources":["../../src/convert-item-to-template.ts","../../src/helpers/is-hub-form-template.ts","../../src/helpers/create-survey.ts","../../src/helpers/encode-survey-form.ts","../../src/helpers/build-create-params.ts","../../src/helpers/create-item-from-hub-template.ts","../../src/create-item-from-template.ts","../../src/helpers/post-process-survey.ts","../../src/post-process.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation of Form templates\r\n *\r\n * @module convert-item-to-template\r\n */\r\n\r\nimport { UserSession, IItemTemplate } from \"@esri/solution-common\";\r\nimport { simpleTypes } from \"@esri/solution-simple-types\";\r\n\r\n/**\r\n * Creates a template from a Form item\r\n *\r\n * @param {string} solutionItemId The solution item ID\r\n * @param {any} itemInfo: The base item info\r\n * @param {UserSession} authentication The source user session information\r\n * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @returns {Promise<IItemTemplate>}\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n authentication: UserSession,\r\n templateDictionary: any\r\n): Promise<IItemTemplate> {\r\n // Delegate to simple types\r\n return simpleTypes.convertItemToTemplate(\r\n solutionItemId,\r\n itemInfo,\r\n authentication,\r\n templateDictionary\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n/**\r\n * Determines if the given template is a Hub Survey\r\n * template vs Solutions.js Survey template.\r\n *\r\n * @param {IITemTemplate} template A template\r\n * @returns {boolean}\r\n */\r\nexport function isHubFormTemplate(template: common.IItemTemplate): boolean {\r\n // relying on basic duck typing vs adding extraneous props during migration\r\n return !!common.getProp(template, \"properties.services\");\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n ISurvey123CreateParams,\r\n ISurvey123CreateResult\r\n} from \"@esri/solution-common\";\r\nimport { encodeFormData } from \"@esri/arcgis-rest-request\";\r\n\r\n/**\r\n * Provides utility method to call Survey123 create endpoint\r\n *\r\n * @module create-survey\r\n */\r\n\r\n/**\r\n * Calls the Survey123 create API with the given parameters\r\n *\r\n * @param {ISurvey123CreateParams} params\r\n * @param {string} [survey123Url=https://survey123.arcgis.com] An optional, Survey123 base URL override\r\n * @throws Will throw if the Survey123 API returns an error response\r\n * @returns {Promise<ISurvey123CreateResult>}\r\n */\r\nexport function createSurvey(\r\n params: ISurvey123CreateParams,\r\n survey123Url = \"https://survey123.arcgis.com\"\r\n): Promise<ISurvey123CreateResult> {\r\n const createUrl = `${survey123Url}/api/survey/create`;\r\n const ro = {\r\n credentials: \"same-origin\" as RequestCredentials,\r\n method: \"POST\",\r\n body: encodeFormData(\r\n {\r\n f: \"json\",\r\n ...params\r\n },\r\n true\r\n )\r\n };\r\n // Using @esri/arcgis-request \"request\" method was resulting in a 404 for\r\n // a CORS preflight request related to this request, but calling fetch directly\r\n // circumvents the issue.\r\n return fetch(createUrl, ro)\r\n .then(response => response.json())\r\n .then(response => {\r\n if (!response.success) {\r\n throw new Error(`Failed to create survey: ${response.error.message}`);\r\n }\r\n return {\r\n formId: response.id,\r\n featureServiceId: response.featureService.source.itemId,\r\n folderId: response.formItemInfo.ownerFolder\r\n };\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { cloneObject } from \"@esri/solution-common\";\r\n\r\n/**\r\n * Manages Survey123 parameter encoding\r\n *\r\n * @module encode-survey-form\r\n */\r\n\r\n/**\r\n * URI Encodes Survey123 form content parameter\r\n * values\r\n *\r\n * @param {any} form Unencoded form data\r\n * @returns {any} Encoded form data\r\n */\r\nexport const encodeSurveyForm = function encodeForm(form: any) {\r\n const clone = cloneObject(form);\r\n const props = [\r\n [\"header\", \"content\"],\r\n [\"subHeader\", \"content\"],\r\n [\"footer\", \"content\"],\r\n [\"settings\", \"thankYouScreenContent\"]\r\n ];\r\n const encode = (\r\n obj: { [key: string]: string },\r\n key: string\r\n ): { [key: string]: string } => {\r\n if (obj && obj[key]) {\r\n obj[key] = encodeURIComponent(obj[key]);\r\n }\r\n return obj;\r\n };\r\n\r\n // encode props from array above\r\n props.forEach(([objKey, propKey]) => encode(clone[objKey], propKey));\r\n\r\n // encode question descriptions\r\n clone.questions = (clone.questions || []).map((question: any) =>\r\n encode(question, \"description\")\r\n );\r\n\r\n return clone;\r\n};\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n UserSession,\r\n getUniqueTitle,\r\n ISurvey123CreateParams,\r\n getPortalDefaultBasemap\r\n} from \"@esri/solution-common\";\r\nimport { encodeSurveyForm } from \"./encode-survey-form\";\r\n\r\n/**\r\n * Utility method for creating Survey123 parameters\r\n *\r\n * @module build-create-params\r\n */\r\n\r\n/**\r\n * Builds the Survey123 create API parameters\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination session info\r\n * @returns {Promise<ISurvey123CreateParams>}\r\n */\r\nexport function buildCreateParams(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession\r\n): Promise<ISurvey123CreateParams> {\r\n const {\r\n item: { title: originalTitle, description, tags, typeKeywords },\r\n properties: { form: unencodedForm }\r\n } = template;\r\n const {\r\n user: { username },\r\n portalBaseUrl: portalUrl,\r\n organization: {\r\n basemapGalleryGroupQuery,\r\n defaultBasemap: { title: basemapTitle }\r\n }\r\n } = templateDictionary;\r\n const { token } = destinationAuthentication.toCredential();\r\n return getPortalDefaultBasemap(\r\n basemapGalleryGroupQuery,\r\n basemapTitle,\r\n destinationAuthentication\r\n ).then(defaultBasemap => {\r\n // The S123 API appends \"Survey-\" to the survey title when computing\r\n // the folder name. We need to use the same prefix to successfully\r\n // calculate a unique folder name. Afterwards, we can safely remove the\r\n // prefix from the title\r\n const folderPrefix = \"Survey-\";\r\n const title = getUniqueTitle(\r\n `${folderPrefix}${originalTitle}`,\r\n templateDictionary,\r\n \"user.folders\"\r\n ).replace(folderPrefix, \"\");\r\n // set any map question's basemaps to default org basemap\r\n if (unencodedForm.questions) {\r\n unencodedForm.questions = unencodedForm.questions.map((question: any) => {\r\n if (question.maps) {\r\n question.maps = question.maps.map((map: any) => ({\r\n ...map,\r\n itemId: defaultBasemap.id\r\n }));\r\n }\r\n return question;\r\n });\r\n }\r\n const form = encodeSurveyForm(unencodedForm);\r\n // intentionally undefined, handled downstream by core logic now\r\n return {\r\n description,\r\n form,\r\n portalUrl,\r\n tags,\r\n title,\r\n token,\r\n typeKeywords,\r\n username\r\n };\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n UserSession,\r\n IItemProgressCallback,\r\n ICreateItemFromTemplateResponse,\r\n EItemProgressStatus,\r\n replaceInTemplate,\r\n updateItemExtended,\r\n ISurvey123CreateParams,\r\n ISurvey123CreateResult,\r\n getItemBase\r\n} from \"@esri/solution-common\";\r\nimport { createSurvey } from \"./create-survey\";\r\nimport { buildCreateParams } from \"./build-create-params\";\r\n\r\n/**\r\n * Manages the creation of Surveys from Hub Templates\r\n * via the Survey123 API\r\n *\r\n * @module create-item-from-hub-template\r\n */\r\n\r\n/**\r\n * Orchestrates creation of Surveys from Hub templates\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination session info\r\n * @param {Function} itemProgressCallback A progress callback\r\n * @returns {Promise<ICreateItemFromTemplateResponse>}\r\n */\r\nexport function createItemFromHubTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n const interpolatedTemplate = replaceInTemplate(template, templateDictionary);\r\n const { survey123Url } = templateDictionary;\r\n\r\n return buildCreateParams(\r\n interpolatedTemplate,\r\n templateDictionary,\r\n destinationAuthentication\r\n )\r\n .then((params: ISurvey123CreateParams) => {\r\n return createSurvey(params, survey123Url);\r\n })\r\n .then((createSurveyResponse: ISurvey123CreateResult) => {\r\n const { formId, featureServiceId } = createSurveyResponse;\r\n\r\n // Update the item with its thumbnail\r\n let thumbDef: Promise<any> = Promise.resolve(null);\r\n /* istanbul ignore else */\r\n if (template.item.thumbnail) {\r\n thumbDef = updateItemExtended(\r\n { id: formId },\r\n null,\r\n destinationAuthentication,\r\n template.item.thumbnail\r\n );\r\n }\r\n\r\n return thumbDef\r\n .then(() => getItemBase(formId, destinationAuthentication))\r\n .then(item => {\r\n templateDictionary[interpolatedTemplate.itemId] = {\r\n itemId: formId\r\n };\r\n templateDictionary[\r\n interpolatedTemplate.properties.info.serviceInfo.itemId\r\n ] = {\r\n itemId: featureServiceId\r\n };\r\n itemProgressCallback(\r\n interpolatedTemplate.itemId,\r\n EItemProgressStatus.Finished,\r\n interpolatedTemplate.estimatedDeploymentCostFactor,\r\n formId\r\n );\r\n return {\r\n item: {\r\n ...template,\r\n item,\r\n itemId: formId\r\n },\r\n id: formId,\r\n type: \"Form\",\r\n postProcess: true\r\n };\r\n });\r\n })\r\n .catch(e => {\r\n itemProgressCallback(\r\n interpolatedTemplate.itemId,\r\n EItemProgressStatus.Failed,\r\n 0\r\n );\r\n throw e;\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the deployment items from Form templates.\r\n *\r\n * @module create-item-from-template\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n IItemProgressCallback,\r\n ICreateItemFromTemplateResponse\r\n} from \"@esri/solution-common\";\r\nimport { simpleTypes } from \"@esri/solution-simple-types\";\r\nimport { isHubFormTemplate } from \"./helpers/is-hub-form-template\";\r\nimport { createItemFromHubTemplate } from \"./helpers/create-item-from-hub-template\";\r\n\r\n/**\r\n * Creates a Form item from a template\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination user session info\r\n * @param itemProgressCallback An item progress callback\r\n * @returns {Promise<ICreateItemFromTemplateResponse>}\r\n */\r\nexport function createItemFromTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n // Hub Form template custom processing\r\n if (isHubFormTemplate(template)) {\r\n return createItemFromHubTemplate(\r\n template,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n );\r\n }\r\n\r\n // otherwise delegate to simple types\r\n return simpleTypes.createItemFromTemplate(\r\n template,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n updateItem,\r\n replaceInTemplate,\r\n getItemBase,\r\n createInitializedItemTemplate,\r\n removeFolder,\r\n IItemUpdate\r\n} from \"@esri/solution-common\";\r\nimport { moveItem } from \"@esri/arcgis-rest-portal\";\r\n\r\n/**\r\n * Provides utility method to post process Hub surveys\r\n *\r\n * @module post-process-survey\r\n */\r\n\r\n/**\r\n * Performs Survey post processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template/item type\r\n * @param {any[]} itemInfos An Array of item details\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns {Promise<any>}\r\n */\r\nexport function postProcessHubSurvey(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n const featureServiceSourceId = template.properties.info.serviceInfo.itemId;\r\n const { itemId: featureServiceResultId } = templateDictionary[\r\n featureServiceSourceId\r\n ];\r\n const interpolated = replaceInTemplate(template, templateDictionary);\r\n return getItemBase(featureServiceResultId, authentication).then(\r\n featureServiceResultBase => {\r\n const itemUpdates = [\r\n // fix/update form properties we couldn't control via the API\r\n {\r\n id: itemId,\r\n title: interpolated.item.title,\r\n snippet: interpolated.item.snippet,\r\n extent: interpolated.item.extent,\r\n culture: interpolated.item.culture\r\n },\r\n // fix/update feature service properties we couldn't control via the API\r\n {\r\n id: featureServiceResultId,\r\n extent: interpolated.item.extent,\r\n typeKeywords: [`source-${featureServiceSourceId}`].concat(\r\n featureServiceResultBase.typeKeywords\r\n )\r\n }\r\n ];\r\n const toUpdatePromise = (updatedItem: IItemUpdate) =>\r\n updateItem(updatedItem, authentication);\r\n const updatePromises = itemUpdates.map(toUpdatePromise);\r\n return Promise.all(updatePromises)\r\n .then(() => {\r\n const itemIdsToMove = [itemId, featureServiceResultId];\r\n const toMovePromise = (id: string) =>\r\n moveItem({\r\n itemId: id,\r\n folderId: templateDictionary.folderId as string,\r\n authentication: authentication\r\n });\r\n const movePromises = itemIdsToMove.map(toMovePromise);\r\n return Promise.all(movePromises);\r\n })\r\n .then(() =>\r\n removeFolder(featureServiceResultBase.ownerFolder, authentication)\r\n )\r\n .then(() => {\r\n // Create a template item for the Feature Service that was created by the API\r\n const featureServiceTemplate = createInitializedItemTemplate(\r\n featureServiceResultBase\r\n );\r\n templates.push(featureServiceTemplate);\r\n template.dependencies.push(featureServiceResultBase.id);\r\n return true;\r\n });\r\n }\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of form item types.\r\n *\r\n * @module post-process\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n updateItemTemplateFromDictionary\r\n} from \"@esri/solution-common\";\r\nimport { isHubFormTemplate } from \"./helpers/is-hub-form-template\";\r\nimport { postProcessHubSurvey } from \"./helpers/post-process-survey\";\r\n\r\n/**\r\n * Form post-processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\nexport function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n if (isHubFormTemplate(template)) {\r\n return postProcessHubSurvey(\r\n itemId,\r\n type,\r\n itemInfos,\r\n template,\r\n templates,\r\n templateDictionary,\r\n authentication\r\n );\r\n }\r\n\r\n return updateItemTemplateFromDictionary(\r\n itemId,\r\n templateDictionary,\r\n authentication\r\n );\r\n}\r\n"],"names":["simpleTypes","common.getProp","encodeFormData","cloneObject","getPortalDefaultBasemap","getUniqueTitle","replaceInTemplate","updateItemExtended","getItemBase","EItemProgressStatus","updateItem","moveItem","removeFolder","createInitializedItemTemplate","updateItemTemplateFromDictionary"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;EAyBA;;;;;;;;;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C;EACJ,CAAC;;EC5GD;;;;;;;;;;;;;;;AAgBA,EAcA;;;;;;;;;;AAUA,WAAgB,WAAW,CACzB,MAAc,EACd,IAAY,EACZ,SAAgB,EAChB,QAAuB,EACvB,SAA0B,EAC1B,kBAAuB,EACvB,cAA2B;MAE3B,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE;UAC/B,OAAO,oBAAoB,CACzB,MAAM,EACN,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,cAAc,CACf,CAAC;OACH;MAED,OAAOC,uCAAgC,CACrC,MAAM,EACN,kBAAkB,EAClB,cAAc,CACf,CAAC;EACJ,CAAC;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"form.umd.js","sources":["../../src/convert-item-to-template.ts","../../src/helpers/is-hub-form-template.ts","../../src/helpers/create-survey.ts","../../src/helpers/encode-survey-form.ts","../../src/helpers/build-create-params.ts","../../src/helpers/create-item-from-hub-template.ts","../../src/create-item-from-template.ts","../../src/helpers/post-process-survey.ts","../../src/post-process.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation of Form templates\r\n *\r\n * @module convert-item-to-template\r\n */\r\n\r\nimport { UserSession, IItemTemplate } from \"@esri/solution-common\";\r\nimport { simpleTypes } from \"@esri/solution-simple-types\";\r\n\r\n/**\r\n * Creates a template from a Form item\r\n *\r\n * @param {string} solutionItemId The solution item ID\r\n * @param {any} itemInfo: The base item info\r\n * @param {UserSession} destAuthentication Credentials for requests to the destination organization\r\n * @param {UserSession} srcAuthentication Credentials for requests to source items\r\n * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @returns {Promise<IItemTemplate>}\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: UserSession,\r\n srcAuthentication: UserSession,\r\n templateDictionary: any\r\n): Promise<IItemTemplate> {\r\n // Delegate to simple types\r\n return simpleTypes.convertItemToTemplate(\r\n solutionItemId,\r\n itemInfo,\r\n destAuthentication,\r\n srcAuthentication,\r\n templateDictionary\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n/**\r\n * Determines if the given template is a Hub Survey\r\n * template vs Solutions.js Survey template.\r\n *\r\n * @param {IITemTemplate} template A template\r\n * @returns {boolean}\r\n */\r\nexport function isHubFormTemplate(template: common.IItemTemplate): boolean {\r\n // relying on basic duck typing vs adding extraneous props during migration\r\n return !!common.getProp(template, \"properties.services\");\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n ISurvey123CreateParams,\r\n ISurvey123CreateResult\r\n} from \"@esri/solution-common\";\r\nimport { encodeFormData } from \"@esri/arcgis-rest-request\";\r\n\r\n/**\r\n * Provides utility method to call Survey123 create endpoint\r\n *\r\n * @module create-survey\r\n */\r\n\r\n/**\r\n * Calls the Survey123 create API with the given parameters\r\n *\r\n * @param {ISurvey123CreateParams} params\r\n * @param {string} [survey123Url=https://survey123.arcgis.com] An optional, Survey123 base URL override\r\n * @throws Will throw if the Survey123 API returns an error response\r\n * @returns {Promise<ISurvey123CreateResult>}\r\n */\r\nexport function createSurvey(\r\n params: ISurvey123CreateParams,\r\n survey123Url = \"https://survey123.arcgis.com\"\r\n): Promise<ISurvey123CreateResult> {\r\n const createUrl = `${survey123Url}/api/survey/create`;\r\n const ro = {\r\n credentials: \"same-origin\" as RequestCredentials,\r\n method: \"POST\",\r\n body: encodeFormData(\r\n {\r\n f: \"json\",\r\n ...params\r\n },\r\n true\r\n )\r\n };\r\n // Using @esri/arcgis-request \"request\" method was resulting in a 404 for\r\n // a CORS preflight request related to this request, but calling fetch directly\r\n // circumvents the issue.\r\n return fetch(createUrl, ro)\r\n .then(response => response.json())\r\n .then(response => {\r\n if (!response.success) {\r\n throw new Error(`Failed to create survey: ${response.error.message}`);\r\n }\r\n return {\r\n formId: response.id,\r\n featureServiceId: response.featureService.source.itemId,\r\n folderId: response.formItemInfo.ownerFolder\r\n };\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { cloneObject } from \"@esri/solution-common\";\r\n\r\n/**\r\n * Manages Survey123 parameter encoding\r\n *\r\n * @module encode-survey-form\r\n */\r\n\r\n/**\r\n * URI Encodes Survey123 form content parameter\r\n * values\r\n *\r\n * @param {any} form Unencoded form data\r\n * @returns {any} Encoded form data\r\n */\r\nexport const encodeSurveyForm = function encodeForm(form: any) {\r\n const clone = cloneObject(form);\r\n const props = [\r\n [\"header\", \"content\"],\r\n [\"subHeader\", \"content\"],\r\n [\"footer\", \"content\"],\r\n [\"settings\", \"thankYouScreenContent\"]\r\n ];\r\n const encode = (\r\n obj: { [key: string]: string },\r\n key: string\r\n ): { [key: string]: string } => {\r\n if (obj && obj[key]) {\r\n obj[key] = encodeURIComponent(obj[key]);\r\n }\r\n return obj;\r\n };\r\n\r\n // encode props from array above\r\n props.forEach(([objKey, propKey]) => encode(clone[objKey], propKey));\r\n\r\n const encodeQuestion = (question: any) => encode(question, \"description\");\r\n\r\n // encode question descriptions\r\n clone.questions = (clone.questions || []).map((question: any) =>\r\n !question.questions\r\n ? encodeQuestion(question)\r\n : {\r\n ...question,\r\n questions: question.questions.map(encodeQuestion)\r\n }\r\n );\r\n\r\n return clone;\r\n};\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n UserSession,\r\n getUniqueTitle,\r\n ISurvey123CreateParams,\r\n getPortalDefaultBasemap\r\n} from \"@esri/solution-common\";\r\nimport { encodeSurveyForm } from \"./encode-survey-form\";\r\n\r\n/**\r\n * Utility method for creating Survey123 parameters\r\n *\r\n * @module build-create-params\r\n */\r\n\r\n/**\r\n * Builds the Survey123 create API parameters\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination session info\r\n * @returns {Promise<ISurvey123CreateParams>}\r\n */\r\nexport function buildCreateParams(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession\r\n): Promise<ISurvey123CreateParams> {\r\n const {\r\n item: { title: originalTitle, description, tags, typeKeywords },\r\n properties: { form: unencodedForm }\r\n } = template;\r\n const {\r\n user: { username },\r\n portalBaseUrl: portalUrl,\r\n organization: {\r\n basemapGalleryGroupQuery,\r\n defaultBasemap: { title: basemapTitle }\r\n }\r\n } = templateDictionary;\r\n const { token } = destinationAuthentication.toCredential();\r\n return getPortalDefaultBasemap(\r\n basemapGalleryGroupQuery,\r\n basemapTitle,\r\n destinationAuthentication\r\n ).then(defaultBasemap => {\r\n // The S123 API appends \"Survey-\" to the survey title when computing\r\n // the folder name. We need to use the same prefix to successfully\r\n // calculate a unique folder name. Afterwards, we can safely remove the\r\n // prefix from the title\r\n const folderPrefix = \"Survey-\";\r\n const title = getUniqueTitle(\r\n `${folderPrefix}${originalTitle}`,\r\n templateDictionary,\r\n \"user.folders\"\r\n ).replace(folderPrefix, \"\");\r\n // set any map question's basemaps to default org basemap\r\n if (unencodedForm.questions) {\r\n const updateBasemap = (question: any) => {\r\n if (question.maps) {\r\n question.maps = question.maps.map((map: any) => ({\r\n ...map,\r\n itemId: defaultBasemap.id\r\n }));\r\n }\r\n return question;\r\n };\r\n unencodedForm.questions = unencodedForm.questions.map((question: any) =>\r\n !question.questions\r\n ? updateBasemap(question)\r\n : {\r\n ...question,\r\n questions: question.questions.map(updateBasemap)\r\n }\r\n );\r\n }\r\n const form = encodeSurveyForm(unencodedForm);\r\n // intentionally undefined, handled downstream by core logic now\r\n return {\r\n description,\r\n form,\r\n portalUrl,\r\n tags,\r\n title,\r\n token,\r\n typeKeywords,\r\n username\r\n };\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n UserSession,\r\n IItemProgressCallback,\r\n ICreateItemFromTemplateResponse,\r\n EItemProgressStatus,\r\n replaceInTemplate,\r\n updateItemExtended,\r\n ISurvey123CreateParams,\r\n ISurvey123CreateResult,\r\n getItemBase\r\n} from \"@esri/solution-common\";\r\nimport { createSurvey } from \"./create-survey\";\r\nimport { buildCreateParams } from \"./build-create-params\";\r\n\r\n/**\r\n * Manages the creation of Surveys from Hub Templates\r\n * via the Survey123 API\r\n *\r\n * @module create-item-from-hub-template\r\n */\r\n\r\n/**\r\n * Orchestrates creation of Surveys from Hub templates\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination session info\r\n * @param {Function} itemProgressCallback A progress callback\r\n * @returns {Promise<ICreateItemFromTemplateResponse>}\r\n */\r\nexport function createItemFromHubTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n const interpolatedTemplate = replaceInTemplate(template, templateDictionary);\r\n const { survey123Url } = templateDictionary;\r\n\r\n return buildCreateParams(\r\n interpolatedTemplate,\r\n templateDictionary,\r\n destinationAuthentication\r\n )\r\n .then((params: ISurvey123CreateParams) => {\r\n return createSurvey(params, survey123Url);\r\n })\r\n .then((createSurveyResponse: ISurvey123CreateResult) => {\r\n const { formId, featureServiceId } = createSurveyResponse;\r\n\r\n // Update the item with its thumbnail\r\n let thumbDef: Promise<any> = Promise.resolve(null);\r\n /* istanbul ignore else */\r\n if (template.item.thumbnail) {\r\n thumbDef = updateItemExtended(\r\n { id: formId },\r\n null,\r\n destinationAuthentication,\r\n template.item.thumbnail\r\n );\r\n }\r\n\r\n return thumbDef\r\n .then(() => getItemBase(formId, destinationAuthentication))\r\n .then(item => {\r\n templateDictionary[interpolatedTemplate.itemId] = {\r\n itemId: formId\r\n };\r\n templateDictionary[\r\n interpolatedTemplate.properties.info.serviceInfo.itemId\r\n ] = {\r\n itemId: featureServiceId\r\n };\r\n itemProgressCallback(\r\n interpolatedTemplate.itemId,\r\n EItemProgressStatus.Finished,\r\n interpolatedTemplate.estimatedDeploymentCostFactor,\r\n formId\r\n );\r\n return {\r\n item: {\r\n ...template,\r\n item,\r\n itemId: formId\r\n },\r\n id: formId,\r\n type: \"Form\",\r\n postProcess: true\r\n };\r\n });\r\n })\r\n .catch(e => {\r\n itemProgressCallback(\r\n interpolatedTemplate.itemId,\r\n EItemProgressStatus.Failed,\r\n 0\r\n );\r\n throw e;\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the deployment items from Form templates.\r\n *\r\n * @module create-item-from-template\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n IItemProgressCallback,\r\n ICreateItemFromTemplateResponse\r\n} from \"@esri/solution-common\";\r\nimport { simpleTypes } from \"@esri/solution-simple-types\";\r\nimport { isHubFormTemplate } from \"./helpers/is-hub-form-template\";\r\nimport { createItemFromHubTemplate } from \"./helpers/create-item-from-hub-template\";\r\n\r\n/**\r\n * Creates a Form item from a template\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination user session info\r\n * @param itemProgressCallback An item progress callback\r\n * @returns {Promise<ICreateItemFromTemplateResponse>}\r\n */\r\nexport function createItemFromTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n // Hub Form template custom processing\r\n if (isHubFormTemplate(template)) {\r\n return createItemFromHubTemplate(\r\n template,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n );\r\n }\r\n\r\n // otherwise delegate to simple types\r\n return simpleTypes.createItemFromTemplate(\r\n template,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n updateItem,\r\n replaceInTemplate,\r\n getItemBase,\r\n createInitializedItemTemplate,\r\n removeFolder,\r\n IItemUpdate\r\n} from \"@esri/solution-common\";\r\nimport { moveItem } from \"@esri/arcgis-rest-portal\";\r\n\r\n/**\r\n * Provides utility method to post process Hub surveys\r\n *\r\n * @module post-process-survey\r\n */\r\n\r\n/**\r\n * Performs Survey post processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template/item type\r\n * @param {any[]} itemInfos An Array of item details\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns {Promise<any>}\r\n */\r\nexport function postProcessHubSurvey(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n const featureServiceSourceId = template.properties.info.serviceInfo.itemId;\r\n const { itemId: featureServiceResultId } = templateDictionary[\r\n featureServiceSourceId\r\n ];\r\n const interpolated = replaceInTemplate(template, templateDictionary);\r\n return getItemBase(featureServiceResultId, authentication).then(\r\n featureServiceResultBase => {\r\n const itemUpdates = [\r\n // fix/update form properties we couldn't control via the API\r\n {\r\n id: itemId,\r\n title: interpolated.item.title,\r\n snippet: interpolated.item.snippet,\r\n extent: interpolated.item.extent,\r\n culture: interpolated.item.culture\r\n },\r\n // fix/update feature service properties we couldn't control via the API\r\n {\r\n id: featureServiceResultId,\r\n extent: interpolated.item.extent,\r\n typeKeywords: [`source-${featureServiceSourceId}`].concat(\r\n featureServiceResultBase.typeKeywords\r\n )\r\n }\r\n ];\r\n const toUpdatePromise = (updatedItem: IItemUpdate) =>\r\n updateItem(updatedItem, authentication);\r\n const updatePromises = itemUpdates.map(toUpdatePromise);\r\n return Promise.all(updatePromises)\r\n .then(() => {\r\n const itemIdsToMove = [itemId, featureServiceResultId];\r\n const toMovePromise = (id: string) =>\r\n moveItem({\r\n itemId: id,\r\n folderId: templateDictionary.folderId as string,\r\n authentication: authentication\r\n });\r\n const movePromises = itemIdsToMove.map(toMovePromise);\r\n return Promise.all(movePromises);\r\n })\r\n .then(() =>\r\n removeFolder(featureServiceResultBase.ownerFolder, authentication)\r\n )\r\n .then(() => {\r\n // Create a template item for the Feature Service that was created by the API\r\n const featureServiceTemplate = createInitializedItemTemplate(\r\n featureServiceResultBase\r\n );\r\n templates.push(featureServiceTemplate);\r\n template.dependencies.push(featureServiceResultBase.id);\r\n return true;\r\n });\r\n }\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of form item types.\r\n *\r\n * @module post-process\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n updateItemTemplateFromDictionary\r\n} from \"@esri/solution-common\";\r\nimport { isHubFormTemplate } from \"./helpers/is-hub-form-template\";\r\nimport { postProcessHubSurvey } from \"./helpers/post-process-survey\";\r\n\r\n/**\r\n * Form post-processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\nexport function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n if (isHubFormTemplate(template)) {\r\n return postProcessHubSurvey(\r\n itemId,\r\n type,\r\n itemInfos,\r\n template,\r\n templates,\r\n templateDictionary,\r\n authentication\r\n );\r\n }\r\n\r\n return updateItemTemplateFromDictionary(\r\n itemId,\r\n templateDictionary,\r\n authentication\r\n );\r\n}\r\n"],"names":["simpleTypes","common","encodeFormData","cloneObject","getPortalDefaultBasemap","getUniqueTitle","replaceInTemplate","updateItemExtended","getItemBase","EItemProgressStatus","updateItem","moveItem","removeFolder","createInitializedItemTemplate","updateItemTemplateFromDictionary"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;EAyBA;;;;;;;;;;WAUgB,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,kBAA+B,EAC/B,iBAA8B,EAC9B,kBAAuB;;MAGvB,OAAOA,+BAAW,CAAC,qBAAqB,CACtC,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,CACnB,CAAC;EACJ;;EClDA;;;;;;;;;;;;;;;EAkBA;;;;;;;WAOgB,iBAAiB,CAAC,QAA8B;;MAE9D,OAAO,CAAC,CAACC,iBAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;EAC3D;;EC5BA;;;;;;;;;;;;;;;EAsBA;;;;;EAMA;;;;;;;;WAQgB,YAAY,CAC1B,MAA8B,EAC9B,YAAY,GAAG,8BAA8B;MAE7C,MAAM,SAAS,GAAG,GAAG,YAAY,oBAAoB,CAAC;MACtD,MAAM,EAAE,GAAG;UACT,WAAW,EAAE,aAAmC;UAChD,MAAM,EAAE,MAAM;UACd,IAAI,EAAEC,gCAAc,CAClB;cACE,CAAC,EAAE,MAAM;cACT,GAAG,MAAM;WACV,EACD,IAAI,CACL;OACF,CAAC;;;;MAIF,OAAO,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;WACxB,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;WACjC,IAAI,CAAC,QAAQ;UACZ,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;cACrB,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,KAAK,C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AG,CAAC,EAAU,KAC/BC,yBAAQ,CAAC;kBACP,MAAM,EAAE,EAAE;kBACV,QAAQ,EAAE,kBAAkB,CAAC,QAAkB;kBAC/C,cAAc,EAAE,cAAc;eAC/B,CAAC,CAAC;cACL,MAAM,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;cACtD,OAAO,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;WAClC,CAAC;eACD,IAAI,CAAC,MACJC,mBAAY,CAAC,wBAAwB,CAAC,WAAW,EAAE,cAAc,CAAC,CACnE;eACA,IAAI,CAAC;;cAEJ,MAAM,sBAAsB,GAAGC,oCAA6B,CAC1D,wBAAwB,CACzB,CAAC;cACF,SAAS,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;cACvC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC;cACxD,OAAO,IAAI,CAAC;WACb,CAAC,CAAC;OACN,CACF,CAAC;EACJ;;EC5GA;;;;;;;;;;;;;;;EA8BA;;;;;;;;;;WAUgB,WAAW,CACzB,MAAc,EACd,IAAY,EACZ,SAAgB,EAChB,QAAuB,EACvB,SAA0B,EAC1B,kBAAuB,EACvB,cAA2B;MAE3B,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE;UAC/B,OAAO,oBAAoB,CACzB,MAAM,EACN,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,SAAS,EACT,kBAAkB,EAClB,cAAc,CACf,CAAC;OACH;MAED,OAAOC,uCAAgC,CACrC,MAAM,EACN,kBAAkB,EAClB,cAAc,CACf,CAAC;EACJ;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-form - v1.1.4 - Apache-2.0
3
- * Copyright (c) 2018-2021 Esri, Inc.
4
- * Tue Oct 26 2021 15:15:44 GMT-0700 (Pacific Daylight Time)
2
+ * @esri/solution-form - v1.3.1 - Apache-2.0
3
+ * Copyright (c) 2018-2022 Esri, Inc.
4
+ * Thu Feb 17 2022 10:45:26 GMT-0800 (Pacific Standard Time)
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -15,5 +15,5 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/solution-simple-types"),require("@esri/solution-common"),require("@esri/arcgis-rest-request"),require("@esri/arcgis-rest-portal")):"function"==typeof define&&define.amd?define(["exports","@esri/solution-simple-types","@esri/solution-common","@esri/arcgis-rest-request","@esri/arcgis-rest-portal"],t):t((e=e||self).arcgisSolution=e.arcgisSolution||{},e.arcgisSolution,e.arcgisSolution,e.arcgisRest,e.arcgisRest)}(this,(function(e,t,r,o,n){"use strict";function i(e){return!!r.getProp(e,"properties.services")}function s(e,t,o){const{item:{title:n,description:i,tags:s,typeKeywords:a},properties:{form:m}}=e,{user:{username:u},portalBaseUrl:c,organization:{basemapGalleryGroupQuery:p,defaultBasemap:{title:l}}}=t,{token:d}=o.toCredential();return r.getPortalDefaultBasemap(p,l,o).then((e=>{const o="Survey-",p=r.getUniqueTitle(`Survey-${n}`,t,"user.folders").replace(o,"");m.questions&&(m.questions=m.questions.map((t=>(t.maps&&(t.maps=t.maps.map((t=>({...t,itemId:e.id})))),t))));const l=function(e){const t=r.cloneObject(e),o=(e,t)=>(e&&e[t]&&(e[t]=encodeURIComponent(e[t])),e);return[["header","content"],["subHeader","content"],["footer","content"],["settings","thankYouScreenContent"]].forEach((([e,r])=>o(t[e],r))),t.questions=(t.questions||[]).map((e=>o(e,"description"))),t}(m);return{description:i,form:l,portalUrl:c,tags:s,title:p,token:d,typeKeywords:a,username:u}}))}function a(e,t,n,i){const a=r.replaceInTemplate(e,t),{survey123Url:m}=t;return s(a,t,n).then((e=>function(e,t="https://survey123.arcgis.com"){const r=`${t}/api/survey/create`,n={credentials:"same-origin",method:"POST",body:o.encodeFormData({f:"json",...e},!0)};return fetch(r,n).then((e=>e.json())).then((e=>{if(!e.success)throw new Error(`Failed to create survey: ${e.error.message}`);return{formId:e.id,featureServiceId:e.featureService.source.itemId,folderId:e.formItemInfo.ownerFolder}}))}(e,m))).then((o=>{const{formId:s,featureServiceId:m}=o;let u=Promise.resolve(null);return e.item.thumbnail&&(u=r.updateItemExtended({id:s},null,n,e.item.thumbnail)),u.then((()=>r.getItemBase(s,n))).then((o=>(t[a.itemId]={itemId:s},t[a.properties.info.serviceInfo.itemId]={itemId:m},i(a.itemId,r.EItemProgressStatus.Finished,a.estimatedDeploymentCostFactor,s),{item:{...e,item:o,itemId:s},id:s,type:"Form",postProcess:!0})))})).catch((e=>{throw i(a.itemId,r.EItemProgressStatus.Failed,0),e}))}e.convertItemToTemplate=function(e,r,o,n){return t.simpleTypes.convertItemToTemplate(e,r,o,n)},e.createItemFromTemplate=function(e,r,o,n){return i(e)?a(e,r,o,n):t.simpleTypes.createItemFromTemplate(e,r,o,n)},e.postProcess=function(e,t,o,s,a,m,u){return i(s)?function(e,t,o,i,s,a,m){const u=i.properties.info.serviceInfo.itemId,{itemId:c}=a[u],p=r.replaceInTemplate(i,a);return r.getItemBase(c,m).then((t=>{const o=[{id:e,title:p.item.title,snippet:p.item.snippet,extent:p.item.extent,culture:p.item.culture},{id:c,extent:p.item.extent,typeKeywords:[`source-${u}`].concat(t.typeKeywords)}].map((e=>r.updateItem(e,m)));return Promise.all(o).then((()=>{const t=[e,c].map((e=>n.moveItem({itemId:e,folderId:a.folderId,authentication:m})));return Promise.all(t)})).then((()=>r.removeFolder(t.ownerFolder,m))).then((()=>{const e=r.createInitializedItemTemplate(t);return s.push(e),i.dependencies.push(t.id),!0}))}))}(e,0,0,s,a,m,u):r.updateItemTemplateFromDictionary(e,m,u)},Object.defineProperty(e,"__esModule",{value:!0})}));
18
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/solution-simple-types"),require("@esri/solution-common"),require("@esri/arcgis-rest-request"),require("@esri/arcgis-rest-portal")):"function"==typeof define&&define.amd?define(["exports","@esri/solution-simple-types","@esri/solution-common","@esri/arcgis-rest-request","@esri/arcgis-rest-portal"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisSolution=e.arcgisSolution||{},e.arcgisSolution,e.arcgisSolution,e.arcgisRest,e.arcgisRest)}(this,(function(e,t,r,o,n){"use strict";function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=s(r);function u(e){return!!i.getProp(e,"properties.services")}function a(e,t,o){const{item:{title:n,description:s,tags:i,typeKeywords:u},properties:{form:a}}=e,{user:{username:c},portalBaseUrl:m,organization:{basemapGalleryGroupQuery:l,defaultBasemap:{title:p}}}=t,{token:d}=o.toCredential();return r.getPortalDefaultBasemap(l,p,o).then((e=>{const o="Survey-",l=r.getUniqueTitle(`Survey-${n}`,t,"user.folders").replace(o,"");if(a.questions){const t=t=>(t.maps&&(t.maps=t.maps.map((t=>({...t,itemId:e.id})))),t);a.questions=a.questions.map((e=>e.questions?{...e,questions:e.questions.map(t)}:t(e)))}const p=function(e){const t=r.cloneObject(e),o=(e,t)=>(e&&e[t]&&(e[t]=encodeURIComponent(e[t])),e);[["header","content"],["subHeader","content"],["footer","content"],["settings","thankYouScreenContent"]].forEach((([e,r])=>o(t[e],r)));const n=e=>o(e,"description");return t.questions=(t.questions||[]).map((e=>e.questions?{...e,questions:e.questions.map(n)}:n(e))),t}(a);return{description:s,form:p,portalUrl:m,tags:i,title:l,token:d,typeKeywords:u,username:c}}))}function c(e,t,n,s){const i=r.replaceInTemplate(e,t),{survey123Url:u}=t;return a(i,t,n).then((e=>function(e,t="https://survey123.arcgis.com"){const r=`${t}/api/survey/create`,n={credentials:"same-origin",method:"POST",body:o.encodeFormData({f:"json",...e},!0)};return fetch(r,n).then((e=>e.json())).then((e=>{if(!e.success)throw new Error(`Failed to create survey: ${e.error.message}`);return{formId:e.id,featureServiceId:e.featureService.source.itemId,folderId:e.formItemInfo.ownerFolder}}))}(e,u))).then((o=>{const{formId:u,featureServiceId:a}=o;let c=Promise.resolve(null);return e.item.thumbnail&&(c=r.updateItemExtended({id:u},null,n,e.item.thumbnail)),c.then((()=>r.getItemBase(u,n))).then((o=>(t[i.itemId]={itemId:u},t[i.properties.info.serviceInfo.itemId]={itemId:a},s(i.itemId,r.EItemProgressStatus.Finished,i.estimatedDeploymentCostFactor,u),{item:{...e,item:o,itemId:u},id:u,type:"Form",postProcess:!0})))})).catch((e=>{throw s(i.itemId,r.EItemProgressStatus.Failed,0),e}))}e.convertItemToTemplate=function(e,r,o,n,s){return t.simpleTypes.convertItemToTemplate(e,r,o,n,s)},e.createItemFromTemplate=function(e,r,o,n){return u(e)?c(e,r,o,n):t.simpleTypes.createItemFromTemplate(e,r,o,n)},e.postProcess=function(e,t,o,s,i,a,c){return u(s)?function(e,t,o,s,i,u,a){const c=s.properties.info.serviceInfo.itemId,{itemId:m}=u[c],l=r.replaceInTemplate(s,u);return r.getItemBase(m,a).then((t=>{const o=[{id:e,title:l.item.title,snippet:l.item.snippet,extent:l.item.extent,culture:l.item.culture},{id:m,extent:l.item.extent,typeKeywords:[`source-${c}`].concat(t.typeKeywords)}].map((e=>r.updateItem(e,a)));return Promise.all(o).then((()=>{const t=[e,m].map((e=>n.moveItem({itemId:e,folderId:u.folderId,authentication:a})));return Promise.all(t)})).then((()=>r.removeFolder(t.ownerFolder,a))).then((()=>{const e=r.createInitializedItemTemplate(t);return i.push(e),s.dependencies.push(t.id),!0}))}))}(e,0,0,s,i,a,c):r.updateItemTemplateFromDictionary(e,a,c)},Object.defineProperty(e,"__esModule",{value:!0})}));
19
19
  //# sourceMappingURL=form.umd.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.umd.min.js","sources":["../../src/helpers/is-hub-form-template.ts","../../src/helpers/build-create-params.ts","../../src/helpers/encode-survey-form.ts","../../src/helpers/create-item-from-hub-template.ts","../../src/helpers/create-survey.ts","../../src/convert-item-to-template.ts","../../src/create-item-from-template.ts","../../src/post-process.ts","../../src/helpers/post-process-survey.ts"],"sourcesContent":["/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n/**\r\n * Determines if the given template is a Hub Survey\r\n * template vs Solutions.js Survey template.\r\n *\r\n * @param {IITemTemplate} template A template\r\n * @returns {boolean}\r\n */\r\nexport function isHubFormTemplate(template: common.IItemTemplate): boolean {\r\n // relying on basic duck typing vs adding extraneous props during migration\r\n return !!common.getProp(template, \"properties.services\");\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n UserSession,\r\n getUniqueTitle,\r\n ISurvey123CreateParams,\r\n getPortalDefaultBasemap\r\n} from \"@esri/solution-common\";\r\nimport { encodeSurveyForm } from \"./encode-survey-form\";\r\n\r\n/**\r\n * Utility method for creating Survey123 parameters\r\n *\r\n * @module build-create-params\r\n */\r\n\r\n/**\r\n * Builds the Survey123 create API parameters\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination session info\r\n * @returns {Promise<ISurvey123CreateParams>}\r\n */\r\nexport function buildCreateParams(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession\r\n): Promise<ISurvey123CreateParams> {\r\n const {\r\n item: { title: originalTitle, description, tags, typeKeywords },\r\n properties: { form: unencodedForm }\r\n } = template;\r\n const {\r\n user: { username },\r\n portalBaseUrl: portalUrl,\r\n organization: {\r\n basemapGalleryGroupQuery,\r\n defaultBasemap: { title: basemapTitle }\r\n }\r\n } = templateDictionary;\r\n const { token } = destinationAuthentication.toCredential();\r\n return getPortalDefaultBasemap(\r\n basemapGalleryGroupQuery,\r\n basemapTitle,\r\n destinationAuthentication\r\n ).then(defaultBasemap => {\r\n // The S123 API appends \"Survey-\" to the survey title when computing\r\n // the folder name. We need to use the same prefix to successfully\r\n // calculate a unique folder name. Afterwards, we can safely remove the\r\n // prefix from the title\r\n const folderPrefix = \"Survey-\";\r\n const title = getUniqueTitle(\r\n `${folderPrefix}${originalTitle}`,\r\n templateDictionary,\r\n \"user.folders\"\r\n ).replace(folderPrefix, \"\");\r\n // set any map question's basemaps to default org basemap\r\n if (unencodedForm.questions) {\r\n unencodedForm.questions = unencodedForm.questions.map((question: any) => {\r\n if (question.maps) {\r\n question.maps = question.maps.map((map: any) => ({\r\n ...map,\r\n itemId: defaultBasemap.id\r\n }));\r\n }\r\n return question;\r\n });\r\n }\r\n const form = encodeSurveyForm(unencodedForm);\r\n // intentionally undefined, handled downstream by core logic now\r\n return {\r\n description,\r\n form,\r\n portalUrl,\r\n tags,\r\n title,\r\n token,\r\n typeKeywords,\r\n username\r\n };\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { cloneObject } from \"@esri/solution-common\";\r\n\r\n/**\r\n * Manages Survey123 parameter encoding\r\n *\r\n * @module encode-survey-form\r\n */\r\n\r\n/**\r\n * URI Encodes Survey123 form content parameter\r\n * values\r\n *\r\n * @param {any} form Unencoded form data\r\n * @returns {any} Encoded form data\r\n */\r\nexport const encodeSurveyForm = function encodeForm(form: any) {\r\n const clone = cloneObject(form);\r\n const props = [\r\n [\"header\", \"content\"],\r\n [\"subHeader\", \"content\"],\r\n [\"footer\", \"content\"],\r\n [\"settings\", \"thankYouScreenContent\"]\r\n ];\r\n const encode = (\r\n obj: { [key: string]: string },\r\n key: string\r\n ): { [key: string]: string } => {\r\n if (obj && obj[key]) {\r\n obj[key] = encodeURIComponent(obj[key]);\r\n }\r\n return obj;\r\n };\r\n\r\n // encode props from array above\r\n props.forEach(([objKey, propKey]) => encode(clone[objKey], propKey));\r\n\r\n // encode question descriptions\r\n clone.questions = (clone.questions || []).map((question: any) =>\r\n encode(question, \"description\")\r\n );\r\n\r\n return clone;\r\n};\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n UserSession,\r\n IItemProgressCallback,\r\n ICreateItemFromTemplateResponse,\r\n EItemProgressStatus,\r\n replaceInTemplate,\r\n updateItemExtended,\r\n ISurvey123CreateParams,\r\n ISurvey123CreateResult,\r\n getItemBase\r\n} from \"@esri/solution-common\";\r\nimport { createSurvey } from \"./create-survey\";\r\nimport { buildCreateParams } from \"./build-create-params\";\r\n\r\n/**\r\n * Manages the creation of Surveys from Hub Templates\r\n * via the Survey123 API\r\n *\r\n * @module create-item-from-hub-template\r\n */\r\n\r\n/**\r\n * Orchestrates creation of Surveys from Hub templates\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination session info\r\n * @param {Function} itemProgressCallback A progress callback\r\n * @returns {Promise<ICreateItemFromTemplateResponse>}\r\n */\r\nexport function createItemFromHubTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n const interpolatedTemplate = replaceInTemplate(template, templateDictionary);\r\n const { survey123Url } = templateDictionary;\r\n\r\n return buildCreateParams(\r\n interpolatedTemplate,\r\n templateDictionary,\r\n destinationAuthentication\r\n )\r\n .then((params: ISurvey123CreateParams) => {\r\n return createSurvey(params, survey123Url);\r\n })\r\n .then((createSurveyResponse: ISurvey123CreateResult) => {\r\n const { formId, featureServiceId } = createSurveyResponse;\r\n\r\n // Update the item with its thumbnail\r\n let thumbDef: Promise<any> = Promise.resolve(null);\r\n /* istanbul ignore else */\r\n if (template.item.thumbnail) {\r\n thumbDef = updateItemExtended(\r\n { id: formId },\r\n null,\r\n destinationAuthentication,\r\n template.item.thumbnail\r\n );\r\n }\r\n\r\n return thumbDef\r\n .then(() => getItemBase(formId, destinationAuthentication))\r\n .then(item => {\r\n templateDictionary[interpolatedTemplate.itemId] = {\r\n itemId: formId\r\n };\r\n templateDictionary[\r\n interpolatedTemplate.properties.info.serviceInfo.itemId\r\n ] = {\r\n itemId: featureServiceId\r\n };\r\n itemProgressCallback(\r\n interpolatedTemplate.itemId,\r\n EItemProgressStatus.Finished,\r\n interpolatedTemplate.estimatedDeploymentCostFactor,\r\n formId\r\n );\r\n return {\r\n item: {\r\n ...template,\r\n item,\r\n itemId: formId\r\n },\r\n id: formId,\r\n type: \"Form\",\r\n postProcess: true\r\n };\r\n });\r\n })\r\n .catch(e => {\r\n itemProgressCallback(\r\n interpolatedTemplate.itemId,\r\n EItemProgressStatus.Failed,\r\n 0\r\n );\r\n throw e;\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n ISurvey123CreateParams,\r\n ISurvey123CreateResult\r\n} from \"@esri/solution-common\";\r\nimport { encodeFormData } from \"@esri/arcgis-rest-request\";\r\n\r\n/**\r\n * Provides utility method to call Survey123 create endpoint\r\n *\r\n * @module create-survey\r\n */\r\n\r\n/**\r\n * Calls the Survey123 create API with the given parameters\r\n *\r\n * @param {ISurvey123CreateParams} params\r\n * @param {string} [survey123Url=https://survey123.arcgis.com] An optional, Survey123 base URL override\r\n * @throws Will throw if the Survey123 API returns an error response\r\n * @returns {Promise<ISurvey123CreateResult>}\r\n */\r\nexport function createSurvey(\r\n params: ISurvey123CreateParams,\r\n survey123Url = \"https://survey123.arcgis.com\"\r\n): Promise<ISurvey123CreateResult> {\r\n const createUrl = `${survey123Url}/api/survey/create`;\r\n const ro = {\r\n credentials: \"same-origin\" as RequestCredentials,\r\n method: \"POST\",\r\n body: encodeFormData(\r\n {\r\n f: \"json\",\r\n ...params\r\n },\r\n true\r\n )\r\n };\r\n // Using @esri/arcgis-request \"request\" method was resulting in a 404 for\r\n // a CORS preflight request related to this request, but calling fetch directly\r\n // circumvents the issue.\r\n return fetch(createUrl, ro)\r\n .then(response => response.json())\r\n .then(response => {\r\n if (!response.success) {\r\n throw new Error(`Failed to create survey: ${response.error.message}`);\r\n }\r\n return {\r\n formId: response.id,\r\n featureServiceId: response.featureService.source.itemId,\r\n folderId: response.formItemInfo.ownerFolder\r\n };\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation of Form templates\r\n *\r\n * @module convert-item-to-template\r\n */\r\n\r\nimport { UserSession, IItemTemplate } from \"@esri/solution-common\";\r\nimport { simpleTypes } from \"@esri/solution-simple-types\";\r\n\r\n/**\r\n * Creates a template from a Form item\r\n *\r\n * @param {string} solutionItemId The solution item ID\r\n * @param {any} itemInfo: The base item info\r\n * @param {UserSession} authentication The source user session information\r\n * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @returns {Promise<IItemTemplate>}\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n authentication: UserSession,\r\n templateDictionary: any\r\n): Promise<IItemTemplate> {\r\n // Delegate to simple types\r\n return simpleTypes.convertItemToTemplate(\r\n solutionItemId,\r\n itemInfo,\r\n authentication,\r\n templateDictionary\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the deployment items from Form templates.\r\n *\r\n * @module create-item-from-template\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n IItemProgressCallback,\r\n ICreateItemFromTemplateResponse\r\n} from \"@esri/solution-common\";\r\nimport { simpleTypes } from \"@esri/solution-simple-types\";\r\nimport { isHubFormTemplate } from \"./helpers/is-hub-form-template\";\r\nimport { createItemFromHubTemplate } from \"./helpers/create-item-from-hub-template\";\r\n\r\n/**\r\n * Creates a Form item from a template\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination user session info\r\n * @param itemProgressCallback An item progress callback\r\n * @returns {Promise<ICreateItemFromTemplateResponse>}\r\n */\r\nexport function createItemFromTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n // Hub Form template custom processing\r\n if (isHubFormTemplate(template)) {\r\n return createItemFromHubTemplate(\r\n template,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n );\r\n }\r\n\r\n // otherwise delegate to simple types\r\n return simpleTypes.createItemFromTemplate(\r\n template,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of form item types.\r\n *\r\n * @module post-process\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n updateItemTemplateFromDictionary\r\n} from \"@esri/solution-common\";\r\nimport { isHubFormTemplate } from \"./helpers/is-hub-form-template\";\r\nimport { postProcessHubSurvey } from \"./helpers/post-process-survey\";\r\n\r\n/**\r\n * Form post-processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\nexport function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n if (isHubFormTemplate(template)) {\r\n return postProcessHubSurvey(\r\n itemId,\r\n type,\r\n itemInfos,\r\n template,\r\n templates,\r\n templateDictionary,\r\n authentication\r\n );\r\n }\r\n\r\n return updateItemTemplateFromDictionary(\r\n itemId,\r\n templateDictionary,\r\n authentication\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n updateItem,\r\n replaceInTemplate,\r\n getItemBase,\r\n createInitializedItemTemplate,\r\n removeFolder,\r\n IItemUpdate\r\n} from \"@esri/solution-common\";\r\nimport { moveItem } from \"@esri/arcgis-rest-portal\";\r\n\r\n/**\r\n * Provides utility method to post process Hub surveys\r\n *\r\n * @module post-process-survey\r\n */\r\n\r\n/**\r\n * Performs Survey post processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template/item type\r\n * @param {any[]} itemInfos An Array of item details\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns {Promise<any>}\r\n */\r\nexport function postProcessHubSurvey(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n const featureServiceSourceId = template.properties.info.serviceInfo.itemId;\r\n const { itemId: featureServiceResultId } = templateDictionary[\r\n featureServiceSourceId\r\n ];\r\n const interpolated = replaceInTemplate(template, templateDictionary);\r\n return getItemBase(featureServiceResultId, authentication).then(\r\n featureServiceResultBase => {\r\n const itemUpdates = [\r\n // fix/update form properties we couldn't control via the API\r\n {\r\n id: itemId,\r\n title: interpolated.item.title,\r\n snippet: interpolated.item.snippet,\r\n extent: interpolated.item.extent,\r\n culture: interpolated.item.culture\r\n },\r\n // fix/update feature service properties we couldn't control via the API\r\n {\r\n id: featureServiceResultId,\r\n extent: interpolated.item.extent,\r\n typeKeywords: [`source-${featureServiceSourceId}`].concat(\r\n featureServiceResultBase.typeKeywords\r\n )\r\n }\r\n ];\r\n const toUpdatePromise = (updatedItem: IItemUpdate) =>\r\n updateItem(updatedItem, authentication);\r\n const updatePromises = itemUpdates.map(toUpdatePromise);\r\n return Promise.all(updatePromises)\r\n .then(() => {\r\n const itemIdsToMove = [itemId, featureServiceResultId];\r\n const toMovePromise = (id: string) =>\r\n moveItem({\r\n itemId: id,\r\n folderId: templateDictionary.folderId as string,\r\n authentication: authentication\r\n });\r\n const movePromises = itemIdsToMove.map(toMovePromise);\r\n return Promise.all(movePromises);\r\n })\r\n .then(() =>\r\n removeFolder(featureServiceResultBase.ownerFolder, authentication)\r\n )\r\n .then(() => {\r\n // Create a template item for the Feature Service that was created by the API\r\n const featureServiceTemplate = createInitializedItemTemplate(\r\n featureServiceResultBase\r\n );\r\n templates.push(featureServiceTemplate);\r\n template.dependencies.push(featureServiceResultBase.id);\r\n return true;\r\n });\r\n }\r\n );\r\n}\r\n"],"names":["isHubFormTemplate","template","common.getProp","buildCreateParams","templateDictionary","destinationAuthentication","item","title","originalTitle","description","tags","typeKeywords","properties","form","unencodedForm","user","username","portalBaseUrl","portalUrl","organization","basemapGalleryGroupQuery","defaultBasemap","basemapTitle","token","toCredential","getPortalDefaultBasemap","then","folderPrefix","getUniqueTitle","replace","questions","map","question","maps","itemId","id","clone","cloneObject","encode","obj","key","encodeURIComponent","forEach","objKey","propKey","encodeSurveyForm","createItemFromHubTemplate","itemProgressCallback","interpolatedTemplate","replaceInTemplate","survey123Url","params","createUrl","ro","credentials","method","body","encodeFormData","f","fetch","response","json","success","Error","error","message","formId","featureServiceId","featureService","source","folderId","formItemInfo","ownerFolder","createSurvey","createSurveyResponse","thumbDef","Promise","resolve","thumbnail","updateItemExtended","getItemBase","info","serviceInfo","EItemProgressStatus","Finished","estimatedDeploymentCostFactor","type","postProcess","catch","e","Failed","solutionItemId","itemInfo","authentication","simpleTypes","convertItemToTemplate","createItemFromTemplate","itemInfos","templates","featureServiceSourceId","featureServiceResultId","interpolated","featureServiceResultBase","updatePromises","snippet","extent","culture","concat","updatedItem","updateItem","all","movePromises","moveItem","removeFolder","featureServiceTemplate","createInitializedItemTemplate","push","dependencies","postProcessHubSurvey","updateItemTemplateFromDictionary"],"mappings":";;;;;;;;;;;;;;;;;yiBAyBgBA,EAAkBC,GAEhC,QAASC,UAAeD,EAAU,gCCYpBE,EACdF,EACAG,EACAC,GAEA,MACEC,MAAQC,MAAOC,EAAaC,YAAEA,EAAWC,KAAEA,EAAIC,aAAEA,GACjDC,YAAcC,KAAMC,IAClBb,GAEFc,MAAMC,SAAEA,GACRC,cAAeC,EACfC,cAAcC,yBACZA,EACAC,gBAAkBd,MAAOe,KAEzBlB,GACEmB,MAAEA,GAAUlB,EAA0BmB,eAC5C,OAAOC,0BACLL,EACAE,EACAjB,GACAqB,MAAKL,IAKL,MAAMM,EAAe,UACfpB,EAAQqB,iBACZ,UAAkBpB,IAClBJ,EACA,gBACAyB,QAAQF,EAAc,IAEpBb,EAAcgB,YAChBhB,EAAcgB,UAAYhB,EAAcgB,UAAUC,KAAKC,IACjDA,EAASC,OACXD,EAASC,KAAOD,EAASC,KAAKF,KAAKA,QAC9BA,EACHG,OAAQb,EAAec,QAGpBH,MAGX,MAAMnB,ECrDsB,SAAoBA,GAClD,MAAMuB,EAAQC,cAAYxB,GAOpByB,EAAS,CACbC,EACAC,KAEID,GAAOA,EAAIC,KACbD,EAAIC,GAAOC,mBAAmBF,EAAIC,KAE7BD,GAWT,MAxBc,CACZ,CAAC,SAAU,WACX,CAAC,YAAa,WACd,CAAC,SAAU,WACX,CAAC,WAAY,0BAaTG,SAAQ,EAAEC,EAAQC,KAAaN,EAAOF,EAAMO,GAASC,KAG3DR,EAAMN,WAAaM,EAAMN,WAAa,IAAIC,KAAKC,GAC7CM,EAAON,EAAU,iBAGZI,ED2BQS,CAAiB/B,GAE9B,MAAO,CACLL,YAAAA,EACAI,KAAAA,EACAK,UAAAA,EACAR,KAAAA,EACAH,MAAAA,EACAgB,MAAAA,EACAZ,aAAAA,EACAK,SAAAA,eE/CU8B,EACd7C,EACAG,EACAC,EACA0C,GAEA,MA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-form-template.ts","../../src/helpers/build-create-params.ts","../../src/helpers/encode-survey-form.ts","../../src/helpers/create-item-from-hub-template.ts","../../src/helpers/create-survey.ts","../../src/convert-item-to-template.ts","../../src/create-item-from-template.ts","../../src/post-process.ts","../../src/helpers/post-process-survey.ts"],"sourcesContent":["/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n/**\r\n * Determines if the given template is a Hub Survey\r\n * template vs Solutions.js Survey template.\r\n *\r\n * @param {IITemTemplate} template A template\r\n * @returns {boolean}\r\n */\r\nexport function isHubFormTemplate(template: common.IItemTemplate): boolean {\r\n // relying on basic duck typing vs adding extraneous props during migration\r\n return !!common.getProp(template, \"properties.services\");\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n UserSession,\r\n getUniqueTitle,\r\n ISurvey123CreateParams,\r\n getPortalDefaultBasemap\r\n} from \"@esri/solution-common\";\r\nimport { encodeSurveyForm } from \"./encode-survey-form\";\r\n\r\n/**\r\n * Utility method for creating Survey123 parameters\r\n *\r\n * @module build-create-params\r\n */\r\n\r\n/**\r\n * Builds the Survey123 create API parameters\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination session info\r\n * @returns {Promise<ISurvey123CreateParams>}\r\n */\r\nexport function buildCreateParams(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession\r\n): Promise<ISurvey123CreateParams> {\r\n const {\r\n item: { title: originalTitle, description, tags, typeKeywords },\r\n properties: { form: unencodedForm }\r\n } = template;\r\n const {\r\n user: { username },\r\n portalBaseUrl: portalUrl,\r\n organization: {\r\n basemapGalleryGroupQuery,\r\n defaultBasemap: { title: basemapTitle }\r\n }\r\n } = templateDictionary;\r\n const { token } = destinationAuthentication.toCredential();\r\n return getPortalDefaultBasemap(\r\n basemapGalleryGroupQuery,\r\n basemapTitle,\r\n destinationAuthentication\r\n ).then(defaultBasemap => {\r\n // The S123 API appends \"Survey-\" to the survey title when computing\r\n // the folder name. We need to use the same prefix to successfully\r\n // calculate a unique folder name. Afterwards, we can safely remove the\r\n // prefix from the title\r\n const folderPrefix = \"Survey-\";\r\n const title = getUniqueTitle(\r\n `${folderPrefix}${originalTitle}`,\r\n templateDictionary,\r\n \"user.folders\"\r\n ).replace(folderPrefix, \"\");\r\n // set any map question's basemaps to default org basemap\r\n if (unencodedForm.questions) {\r\n const updateBasemap = (question: any) => {\r\n if (question.maps) {\r\n question.maps = question.maps.map((map: any) => ({\r\n ...map,\r\n itemId: defaultBasemap.id\r\n }));\r\n }\r\n return question;\r\n };\r\n unencodedForm.questions = unencodedForm.questions.map((question: any) =>\r\n !question.questions\r\n ? updateBasemap(question)\r\n : {\r\n ...question,\r\n questions: question.questions.map(updateBasemap)\r\n }\r\n );\r\n }\r\n const form = encodeSurveyForm(unencodedForm);\r\n // intentionally undefined, handled downstream by core logic now\r\n return {\r\n description,\r\n form,\r\n portalUrl,\r\n tags,\r\n title,\r\n token,\r\n typeKeywords,\r\n username\r\n };\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport { cloneObject } from \"@esri/solution-common\";\r\n\r\n/**\r\n * Manages Survey123 parameter encoding\r\n *\r\n * @module encode-survey-form\r\n */\r\n\r\n/**\r\n * URI Encodes Survey123 form content parameter\r\n * values\r\n *\r\n * @param {any} form Unencoded form data\r\n * @returns {any} Encoded form data\r\n */\r\nexport const encodeSurveyForm = function encodeForm(form: any) {\r\n const clone = cloneObject(form);\r\n const props = [\r\n [\"header\", \"content\"],\r\n [\"subHeader\", \"content\"],\r\n [\"footer\", \"content\"],\r\n [\"settings\", \"thankYouScreenContent\"]\r\n ];\r\n const encode = (\r\n obj: { [key: string]: string },\r\n key: string\r\n ): { [key: string]: string } => {\r\n if (obj && obj[key]) {\r\n obj[key] = encodeURIComponent(obj[key]);\r\n }\r\n return obj;\r\n };\r\n\r\n // encode props from array above\r\n props.forEach(([objKey, propKey]) => encode(clone[objKey], propKey));\r\n\r\n const encodeQuestion = (question: any) => encode(question, \"description\");\r\n\r\n // encode question descriptions\r\n clone.questions = (clone.questions || []).map((question: any) =>\r\n !question.questions\r\n ? encodeQuestion(question)\r\n : {\r\n ...question,\r\n questions: question.questions.map(encodeQuestion)\r\n }\r\n );\r\n\r\n return clone;\r\n};\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n IItemTemplate,\r\n UserSession,\r\n IItemProgressCallback,\r\n ICreateItemFromTemplateResponse,\r\n EItemProgressStatus,\r\n replaceInTemplate,\r\n updateItemExtended,\r\n ISurvey123CreateParams,\r\n ISurvey123CreateResult,\r\n getItemBase\r\n} from \"@esri/solution-common\";\r\nimport { createSurvey } from \"./create-survey\";\r\nimport { buildCreateParams } from \"./build-create-params\";\r\n\r\n/**\r\n * Manages the creation of Surveys from Hub Templates\r\n * via the Survey123 API\r\n *\r\n * @module create-item-from-hub-template\r\n */\r\n\r\n/**\r\n * Orchestrates creation of Surveys from Hub templates\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination session info\r\n * @param {Function} itemProgressCallback A progress callback\r\n * @returns {Promise<ICreateItemFromTemplateResponse>}\r\n */\r\nexport function createItemFromHubTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n const interpolatedTemplate = replaceInTemplate(template, templateDictionary);\r\n const { survey123Url } = templateDictionary;\r\n\r\n return buildCreateParams(\r\n interpolatedTemplate,\r\n templateDictionary,\r\n destinationAuthentication\r\n )\r\n .then((params: ISurvey123CreateParams) => {\r\n return createSurvey(params, survey123Url);\r\n })\r\n .then((createSurveyResponse: ISurvey123CreateResult) => {\r\n const { formId, featureServiceId } = createSurveyResponse;\r\n\r\n // Update the item with its thumbnail\r\n let thumbDef: Promise<any> = Promise.resolve(null);\r\n /* istanbul ignore else */\r\n if (template.item.thumbnail) {\r\n thumbDef = updateItemExtended(\r\n { id: formId },\r\n null,\r\n destinationAuthentication,\r\n template.item.thumbnail\r\n );\r\n }\r\n\r\n return thumbDef\r\n .then(() => getItemBase(formId, destinationAuthentication))\r\n .then(item => {\r\n templateDictionary[interpolatedTemplate.itemId] = {\r\n itemId: formId\r\n };\r\n templateDictionary[\r\n interpolatedTemplate.properties.info.serviceInfo.itemId\r\n ] = {\r\n itemId: featureServiceId\r\n };\r\n itemProgressCallback(\r\n interpolatedTemplate.itemId,\r\n EItemProgressStatus.Finished,\r\n interpolatedTemplate.estimatedDeploymentCostFactor,\r\n formId\r\n );\r\n return {\r\n item: {\r\n ...template,\r\n item,\r\n itemId: formId\r\n },\r\n id: formId,\r\n type: \"Form\",\r\n postProcess: true\r\n };\r\n });\r\n })\r\n .catch(e => {\r\n itemProgressCallback(\r\n interpolatedTemplate.itemId,\r\n EItemProgressStatus.Failed,\r\n 0\r\n );\r\n throw e;\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n ISurvey123CreateParams,\r\n ISurvey123CreateResult\r\n} from \"@esri/solution-common\";\r\nimport { encodeFormData } from \"@esri/arcgis-rest-request\";\r\n\r\n/**\r\n * Provides utility method to call Survey123 create endpoint\r\n *\r\n * @module create-survey\r\n */\r\n\r\n/**\r\n * Calls the Survey123 create API with the given parameters\r\n *\r\n * @param {ISurvey123CreateParams} params\r\n * @param {string} [survey123Url=https://survey123.arcgis.com] An optional, Survey123 base URL override\r\n * @throws Will throw if the Survey123 API returns an error response\r\n * @returns {Promise<ISurvey123CreateResult>}\r\n */\r\nexport function createSurvey(\r\n params: ISurvey123CreateParams,\r\n survey123Url = \"https://survey123.arcgis.com\"\r\n): Promise<ISurvey123CreateResult> {\r\n const createUrl = `${survey123Url}/api/survey/create`;\r\n const ro = {\r\n credentials: \"same-origin\" as RequestCredentials,\r\n method: \"POST\",\r\n body: encodeFormData(\r\n {\r\n f: \"json\",\r\n ...params\r\n },\r\n true\r\n )\r\n };\r\n // Using @esri/arcgis-request \"request\" method was resulting in a 404 for\r\n // a CORS preflight request related to this request, but calling fetch directly\r\n // circumvents the issue.\r\n return fetch(createUrl, ro)\r\n .then(response => response.json())\r\n .then(response => {\r\n if (!response.success) {\r\n throw new Error(`Failed to create survey: ${response.error.message}`);\r\n }\r\n return {\r\n formId: response.id,\r\n featureServiceId: response.featureService.source.itemId,\r\n folderId: response.formItemInfo.ownerFolder\r\n };\r\n });\r\n}\r\n","/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation of Form templates\r\n *\r\n * @module convert-item-to-template\r\n */\r\n\r\nimport { UserSession, IItemTemplate } from \"@esri/solution-common\";\r\nimport { simpleTypes } from \"@esri/solution-simple-types\";\r\n\r\n/**\r\n * Creates a template from a Form item\r\n *\r\n * @param {string} solutionItemId The solution item ID\r\n * @param {any} itemInfo: The base item info\r\n * @param {UserSession} destAuthentication Credentials for requests to the destination organization\r\n * @param {UserSession} srcAuthentication Credentials for requests to source items\r\n * @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements\r\n * @returns {Promise<IItemTemplate>}\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: UserSession,\r\n srcAuthentication: UserSession,\r\n templateDictionary: any\r\n): Promise<IItemTemplate> {\r\n // Delegate to simple types\r\n return simpleTypes.convertItemToTemplate(\r\n solutionItemId,\r\n itemInfo,\r\n destAuthentication,\r\n srcAuthentication,\r\n templateDictionary\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the deployment items from Form templates.\r\n *\r\n * @module create-item-from-template\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n IItemProgressCallback,\r\n ICreateItemFromTemplateResponse\r\n} from \"@esri/solution-common\";\r\nimport { simpleTypes } from \"@esri/solution-simple-types\";\r\nimport { isHubFormTemplate } from \"./helpers/is-hub-form-template\";\r\nimport { createItemFromHubTemplate } from \"./helpers/create-item-from-hub-template\";\r\n\r\n/**\r\n * Creates a Form item from a template\r\n *\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} destinationAuthentication The destination user session info\r\n * @param itemProgressCallback An item progress callback\r\n * @returns {Promise<ICreateItemFromTemplateResponse>}\r\n */\r\nexport function createItemFromTemplate(\r\n template: IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: UserSession,\r\n itemProgressCallback: IItemProgressCallback\r\n): Promise<ICreateItemFromTemplateResponse> {\r\n // Hub Form template custom processing\r\n if (isHubFormTemplate(template)) {\r\n return createItemFromHubTemplate(\r\n template,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n );\r\n }\r\n\r\n // otherwise delegate to simple types\r\n return simpleTypes.createItemFromTemplate(\r\n template,\r\n templateDictionary,\r\n destinationAuthentication,\r\n itemProgressCallback\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of form item types.\r\n *\r\n * @module post-process\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n updateItemTemplateFromDictionary\r\n} from \"@esri/solution-common\";\r\nimport { isHubFormTemplate } from \"./helpers/is-hub-form-template\";\r\nimport { postProcessHubSurvey } from \"./helpers/post-process-survey\";\r\n\r\n/**\r\n * Form post-processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\nexport function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n if (isHubFormTemplate(template)) {\r\n return postProcessHubSurvey(\r\n itemId,\r\n type,\r\n itemInfos,\r\n template,\r\n templates,\r\n templateDictionary,\r\n authentication\r\n );\r\n }\r\n\r\n return updateItemTemplateFromDictionary(\r\n itemId,\r\n templateDictionary,\r\n authentication\r\n );\r\n}\r\n","/** @license\r\n * Copyright 2020 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\nimport {\r\n UserSession,\r\n IItemTemplate,\r\n updateItem,\r\n replaceInTemplate,\r\n getItemBase,\r\n createInitializedItemTemplate,\r\n removeFolder,\r\n IItemUpdate\r\n} from \"@esri/solution-common\";\r\nimport { moveItem } from \"@esri/arcgis-rest-portal\";\r\n\r\n/**\r\n * Provides utility method to post process Hub surveys\r\n *\r\n * @module post-process-survey\r\n */\r\n\r\n/**\r\n * Performs Survey post processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template/item type\r\n * @param {any[]} itemInfos An Array of item details\r\n * @param {IItemTemplate} template The template\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns {Promise<any>}\r\n */\r\nexport function postProcessHubSurvey(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: IItemTemplate,\r\n templates: IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: UserSession\r\n): Promise<any> {\r\n const featureServiceSourceId = template.properties.info.serviceInfo.itemId;\r\n const { itemId: featureServiceResultId } = templateDictionary[\r\n featureServiceSourceId\r\n ];\r\n const interpolated = replaceInTemplate(template, templateDictionary);\r\n return getItemBase(featureServiceResultId, authentication).then(\r\n featureServiceResultBase => {\r\n const itemUpdates = [\r\n // fix/update form properties we couldn't control via the API\r\n {\r\n id: itemId,\r\n title: interpolated.item.title,\r\n snippet: interpolated.item.snippet,\r\n extent: interpolated.item.extent,\r\n culture: interpolated.item.culture\r\n },\r\n // fix/update feature service properties we couldn't control via the API\r\n {\r\n id: featureServiceResultId,\r\n extent: interpolated.item.extent,\r\n typeKeywords: [`source-${featureServiceSourceId}`].concat(\r\n featureServiceResultBase.typeKeywords\r\n )\r\n }\r\n ];\r\n const toUpdatePromise = (updatedItem: IItemUpdate) =>\r\n updateItem(updatedItem, authentication);\r\n const updatePromises = itemUpdates.map(toUpdatePromise);\r\n return Promise.all(updatePromises)\r\n .then(() => {\r\n const itemIdsToMove = [itemId, featureServiceResultId];\r\n const toMovePromise = (id: string) =>\r\n moveItem({\r\n itemId: id,\r\n folderId: templateDictionary.folderId as string,\r\n authentication: authentication\r\n });\r\n const movePromises = itemIdsToMove.map(toMovePromise);\r\n return Promise.all(movePromises);\r\n })\r\n .then(() =>\r\n removeFolder(featureServiceResultBase.ownerFolder, authentication)\r\n )\r\n .then(() => {\r\n // Create a template item for the Feature Service that was created by the API\r\n const featureServiceTemplate = createInitializedItemTemplate(\r\n featureServiceResultBase\r\n );\r\n templates.push(featureServiceTemplate);\r\n template.dependencies.push(featureServiceResultBase.id);\r\n return true;\r\n });\r\n }\r\n );\r\n}\r\n"],"names":["isHubFormTemplate","template","common","getProp","buildCreateParams","templateDictionary","destinationAuthentication","item","title","originalTitle","description","tags","typeKeywords","properties","form","unencodedForm","user","username","portalBaseUrl","portalUrl","organization","basemapGalleryGroupQuery","defaultBasemap","basemapTitle","token","toCredential","getPortalDefaultBasemap","then","folderPrefix","getUniqueTitle","replace","questions","updateBasemap","question","maps","map","itemId","id","clone","cloneObject","encode","obj","key","encodeURIComponent","forEach","objKey","propKey","encodeQuestion","encodeSurveyForm","createItemFromHubTemplate","itemProgressCallback","interpolatedTemplate","replaceInTemplate","survey123Url","params","createUrl","ro","credentials","method","body","encodeFormData","f","fetch","response","json","success","Error","error","message","formId","featureServiceId","featureService","source","folderId","formItemInfo","ownerFolder","createSurvey","createSurveyResponse","thumbDef","Promise","resolve","thumbnail","updateItemExtended","getItemBase","info","serviceInfo","EItemProgressStatus","Finished","estimatedDeploymentCostFactor","type","postProcess","catch","e","Failed","solutionItemId","itemInfo","destAuthentication","srcAuthentication","simpleTypes","convertItemToTemplate","createItemFromTemplate","itemInfos","templates","authentication","featureServiceSourceId","featureServiceResultId","interpolated","featureServiceResultBase","updatePromises","snippet","extent","culture","concat","updatedItem","updateItem","all","movePromises","moveItem","removeFolder","featureServiceTemplate","createInitializedItemTemplate","push","dependencies","postProcessHubSurvey","updateItemTemplateFromDictionary"],"mappings":";;;;;;;;;;;;;;;;;63BAyBgBA,EAAkBC,GAEhC,QAASC,EAAOC,QAAQF,EAAU,gCCYpBG,EACdH,EACAI,EACAC,GAEA,MACEC,MAAQC,MAAOC,EAAaC,YAAEA,EAAWC,KAAEA,EAAIC,aAAEA,GACjDC,YAAcC,KAAMC,IAClBd,GAEFe,MAAMC,SAAEA,GACRC,cAAeC,EACfC,cAAcC,yBACZA,EACAC,gBAAkBd,MAAOe,KAEzBlB,GACEmB,MAAEA,GAAUlB,EAA0BmB,eAC5C,OAAOC,0BACLL,EACAE,EACAjB,GACAqB,MAAKL,IAKL,MAAMM,EAAe,UACfpB,EAAQqB,iBACZ,UAAkBpB,IAClBJ,EACA,gBACAyB,QAAQF,EAAc,IAExB,GAAIb,EAAcgB,UAAW,CAC3B,MAAMC,EAAiBC,IACjBA,EAASC,OACXD,EAASC,KAAOD,EAASC,KAAKC,KAAKA,QAC9BA,EACHC,OAAQd,EAAee,QAGpBJ,GAETlB,EAAcgB,UAAYhB,EAAcgB,UAAUI,KAAKF,GACpDA,EAASF,UAEN,IACGE,EACHF,UAAWE,EAASF,UAAUI,IAAIH,IAHlCA,EAAcC,KAOtB,MAAMnB,EC7DsB,SAAoBA,GAClD,MAAMwB,EAAQC,cAAYzB,GAOpB0B,EAAS,CACbC,EACAC,KAEID,GAAOA,EAAIC,KACbD,EAAIC,GAAOC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WD,EAAaV,KAE1B,OAAOxB,QAAQoC,IAAIP,GAChBjF,MAAK,KACJ,MAOMyF,EAPgB,CAAChF,EAAQqE,GAOItE,KANZE,GACrBgF,WAAS,CACPjF,OAAQC,EACRoC,SAAUpE,EAAmBoE,SAC7B8B,eAAgBA,MAGpB,OAAOxB,QAAQoC,IAAIC,MAEpBzF,MAAK,IACJ2F,eAAaX,EAAyBhC,YAAa4B,KAEpD5E,MAAK,KAEJ,MAAM4F,EAAyBC,gCAC7Bb,GAIF,OAFAL,EAAUmB,KAAKF,GACftH,EAASyH,aAAaD,KAAKd,EAAyBtE,KAC7C,QDtDNsF,CACLvF,EACAqD,EACAY,EACApG,EACAqG,EACAjG,EACAkG,GAIGqB,mCACLxF,EACA/B,EACAkG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/solution-form",
3
- "version": "1.1.4",
3
+ "version": "1.3.1",
4
4
  "description": "Manages the creation and deployment of form item types for @esri/solution.js.",
5
5
  "main": "dist/node/index.js",
6
6
  "unpkg": "dist/umd/file.umd.min.js",
@@ -13,37 +13,36 @@
13
13
  "dist/**"
14
14
  ],
15
15
  "devDependencies": {
16
- "@esri/arcgis-rest-auth": "3.4.2",
17
- "@esri/arcgis-rest-feature-layer": "3.4.2",
18
- "@esri/arcgis-rest-portal": "3.4.2",
19
- "@esri/arcgis-rest-request": "3.4.2",
20
- "@esri/arcgis-rest-service-admin": "3.4.2",
21
- "@esri/hub-common": "9.2.0",
22
- "@esri/hub-initiatives": "9.2.0",
23
- "@esri/hub-sites": "9.2.0",
24
- "@esri/hub-teams": "9.2.0",
25
- "rollup": "^1.22.0",
26
- "typescript": "^4.3.4"
16
+ "@esri/arcgis-rest-auth": "3.4.3",
17
+ "@esri/arcgis-rest-feature-layer": "3.4.3",
18
+ "@esri/arcgis-rest-portal": "3.4.3",
19
+ "@esri/arcgis-rest-request": "3.4.3",
20
+ "@esri/arcgis-rest-service-admin": "3.4.3",
21
+ "@esri/hub-common": "9.15.0",
22
+ "@esri/hub-initiatives": "9.15.0",
23
+ "@esri/hub-sites": "9.15.0",
24
+ "@esri/hub-teams": "9.15.0",
25
+ "rollup": "^2.60.0"
27
26
  },
28
27
  "peerDependencies": {
29
- "@esri/arcgis-rest-auth": "3.4.2",
30
- "@esri/arcgis-rest-feature-layer": "3.4.2",
31
- "@esri/arcgis-rest-portal": "3.4.2",
32
- "@esri/arcgis-rest-request": "3.4.2",
33
- "@esri/arcgis-rest-service-admin": "3.4.2",
34
- "@esri/hub-common": "9.2.0",
35
- "@esri/hub-initiatives": "9.2.0",
36
- "@esri/hub-sites": "9.2.0",
37
- "@esri/hub-teams": "9.2.0"
28
+ "@esri/arcgis-rest-auth": "3.4.3",
29
+ "@esri/arcgis-rest-feature-layer": "3.4.3",
30
+ "@esri/arcgis-rest-portal": "3.4.3",
31
+ "@esri/arcgis-rest-request": "3.4.3",
32
+ "@esri/arcgis-rest-service-admin": "3.4.3",
33
+ "@esri/hub-common": "9.15.0",
34
+ "@esri/hub-initiatives": "9.15.0",
35
+ "@esri/hub-sites": "9.15.0",
36
+ "@esri/hub-teams": "9.15.0"
38
37
  },
39
38
  "dependencies": {
40
- "@esri/solution-common": "^1.1.4",
41
- "@esri/solution-feature-layer": "^1.1.4",
42
- "@esri/solution-file": "^1.1.4",
43
- "@esri/solution-group": "^1.1.4",
44
- "@esri/solution-simple-types": "^1.1.4",
45
- "@esri/solution-storymap": "^1.1.4",
46
- "tslib": "^1.13.0"
39
+ "@esri/solution-common": "^1.3.1",
40
+ "@esri/solution-feature-layer": "^1.3.1",
41
+ "@esri/solution-file": "^1.3.1",
42
+ "@esri/solution-group": "^1.3.1",
43
+ "@esri/solution-simple-types": "^1.3.1",
44
+ "@esri/solution-storymap": "^1.3.1",
45
+ "tslib": "1.13.0"
47
46
  },
48
47
  "scripts": {
49
48
  "prepare": "npm run build",
@@ -80,5 +79,5 @@
80
79
  "esri",
81
80
  "ES6"
82
81
  ],
83
- "gitHead": "85775515ebd9e68d836d60ea1aa99ebdcde7771e"
82
+ "gitHead": "70c45e0eb9c745f7dbc0f8b6ce3654921cca11a0"
84
83
  }