@vannizhang/living-atlas-content-validator 1.5.17 → 1.5.18-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +1376 -162
  2. package/dist/configureSettings.d.ts +133 -0
  3. package/dist/configureSettings.js +61 -0
  4. package/dist/configureSettings.js.map +1 -0
  5. package/dist/data/TitleSummaryMatchingPatterns_Locations.json +829 -0
  6. package/dist/data/TitleSummaryMatchingPatterns_Sources.json +382 -0
  7. package/dist/data/TitleSummaryMatchingPatterns_Time.json +25 -0
  8. package/dist/data/TitleSummaryMatchingPatterns_Topics.json +1365 -0
  9. package/dist/data/TitleSummaryRejectedPatterns.json +44 -0
  10. package/dist/index.d.ts +27 -9
  11. package/dist/index.js +55 -9
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/accessInformation/isValidAccessInformation.js +4 -6
  14. package/dist/lib/accessInformation/isValidAccessInformation.js.map +1 -1
  15. package/dist/lib/checkProfanities/checkProfanities.d.ts +7 -0
  16. package/dist/lib/checkProfanities/checkProfanities.js +26 -0
  17. package/dist/lib/checkProfanities/checkProfanities.js.map +1 -0
  18. package/dist/lib/checkTitleAndSnippetSearchability/checkTitleAndSnippetSearchability.d.ts +34 -0
  19. package/dist/lib/{recommendedText/checkRecommendedText.js → checkTitleAndSnippetSearchability/checkTitleAndSnippetSearchability.js} +51 -25
  20. package/dist/lib/checkTitleAndSnippetSearchability/checkTitleAndSnippetSearchability.js.map +1 -0
  21. package/dist/lib/checkTitleAndSnippetSearchability/config.d.ts +97 -0
  22. package/dist/lib/checkTitleAndSnippetSearchability/config.js +41 -0
  23. package/dist/lib/checkTitleAndSnippetSearchability/config.js.map +1 -0
  24. package/dist/lib/checkTitleAndSnippetSearchability/data.d.ts +0 -0
  25. package/dist/lib/checkTitleAndSnippetSearchability/data.js +693 -0
  26. package/dist/lib/checkTitleAndSnippetSearchability/data.js.map +1 -0
  27. package/dist/lib/checkTitleAndSnippetSearchability/helpers.d.ts +117 -0
  28. package/dist/lib/checkTitleAndSnippetSearchability/helpers.js +241 -0
  29. package/dist/lib/checkTitleAndSnippetSearchability/helpers.js.map +1 -0
  30. package/dist/lib/checkTitleAndSnippetSearchability/matchDateTimeInfo.d.ts +34 -0
  31. package/dist/lib/checkTitleAndSnippetSearchability/matchDateTimeInfo.js +207 -0
  32. package/dist/lib/checkTitleAndSnippetSearchability/matchDateTimeInfo.js.map +1 -0
  33. package/dist/lib/checkTitleAndSnippetSearchability/matchLocationInfo.d.ts +34 -0
  34. package/dist/lib/checkTitleAndSnippetSearchability/matchLocationInfo.js +170 -0
  35. package/dist/lib/checkTitleAndSnippetSearchability/matchLocationInfo.js.map +1 -0
  36. package/dist/lib/checkTitleAndSnippetSearchability/matchSourceInfo.d.ts +34 -0
  37. package/dist/lib/checkTitleAndSnippetSearchability/matchSourceInfo.js +172 -0
  38. package/dist/lib/checkTitleAndSnippetSearchability/matchSourceInfo.js.map +1 -0
  39. package/dist/lib/checkTitleAndSnippetSearchability/matchTopicInfo.d.ts +36 -0
  40. package/dist/lib/checkTitleAndSnippetSearchability/matchTopicInfo.js +175 -0
  41. package/dist/lib/checkTitleAndSnippetSearchability/matchTopicInfo.js.map +1 -0
  42. package/dist/lib/checkTitleAndSnippetSearchability/scoringConfig.js.map +1 -0
  43. package/dist/lib/config.d.ts +4 -1
  44. package/dist/lib/config.js +5 -5
  45. package/dist/lib/config.js.map +1 -1
  46. package/dist/lib/deleteProtection/isDeleteProtectionEnabled.js +6 -2
  47. package/dist/lib/deleteProtection/isDeleteProtectionEnabled.js.map +1 -1
  48. package/dist/lib/deprecated/isDeprecated.js +5 -2
  49. package/dist/lib/deprecated/isDeprecated.js.map +1 -1
  50. package/dist/lib/description/isValidDescription.js +8 -5
  51. package/dist/lib/description/isValidDescription.js.map +1 -1
  52. package/dist/lib/licenseInfo/isValidLicenseInfo.js +5 -2
  53. package/dist/lib/licenseInfo/isValidLicenseInfo.js.map +1 -1
  54. package/dist/lib/sharing/isValidAccess.js +5 -2
  55. package/dist/lib/sharing/isValidAccess.js.map +1 -1
  56. package/dist/lib/ssl/isValidSSL.js +15 -6
  57. package/dist/lib/ssl/isValidSSL.js.map +1 -1
  58. package/dist/lib/summary/isValidSummary.js +6 -3
  59. package/dist/lib/summary/isValidSummary.js.map +1 -1
  60. package/dist/lib/tags/isValidTags.js +7 -3
  61. package/dist/lib/tags/isValidTags.js.map +1 -1
  62. package/dist/lib/thumbnail/isValidThumbnail.d.ts +6 -1
  63. package/dist/lib/thumbnail/isValidThumbnail.js +10 -7
  64. package/dist/lib/thumbnail/isValidThumbnail.js.map +1 -1
  65. package/dist/lib/title/isValidTitle.js +9 -3
  66. package/dist/lib/title/isValidTitle.js.map +1 -1
  67. package/dist/lib/userProfileDescription/isValidUserProfileDescription.js +44 -38
  68. package/dist/lib/userProfileDescription/isValidUserProfileDescription.js.map +1 -1
  69. package/dist/lib/userProfileName/isValidUserProfileName.js +8 -5
  70. package/dist/lib/userProfileName/isValidUserProfileName.js.map +1 -1
  71. package/dist/lib/userProfileThumbnail/isValidUserProfileThumbnail.js +6 -3
  72. package/dist/lib/userProfileThumbnail/isValidUserProfileThumbnail.js.map +1 -1
  73. package/dist/lib/util/containsNonEnglishCharacters.d.ts +13 -0
  74. package/dist/lib/util/containsNonEnglishCharacters.js +30 -0
  75. package/dist/lib/util/containsNonEnglishCharacters.js.map +1 -0
  76. package/dist/lib/util/countSentences.d.ts +23 -0
  77. package/dist/lib/util/countSentences.js +54 -0
  78. package/dist/lib/util/countSentences.js.map +1 -0
  79. package/dist/lib/util/createWordBoundaryRegex.d.ts +46 -0
  80. package/dist/lib/util/createWordBoundaryRegex.js +77 -0
  81. package/dist/lib/util/createWordBoundaryRegex.js.map +1 -0
  82. package/dist/lib/util/escapeSpecialCharacters.d.ts +7 -0
  83. package/dist/lib/util/escapeSpecialCharacters.js +22 -0
  84. package/dist/lib/util/escapeSpecialCharacters.js.map +1 -0
  85. package/dist/lib/util/getLivingAtlasSupportedItemTypes.d.ts +21 -0
  86. package/dist/lib/util/getLivingAtlasSupportedItemTypes.js +34 -0
  87. package/dist/lib/util/getLivingAtlasSupportedItemTypes.js.map +1 -0
  88. package/dist/lib/util/getNumberOfWords.js +6 -2
  89. package/dist/lib/util/getNumberOfWords.js.map +1 -1
  90. package/dist/lib/util/getScoringRules.js +6 -0
  91. package/dist/lib/util/getScoringRules.js.map +1 -1
  92. package/dist/lib/util/isLayer.js +3 -2
  93. package/dist/lib/util/isLayer.js.map +1 -1
  94. package/dist/lib/util/isUrl.d.ts +6 -0
  95. package/dist/lib/util/isUrl.js +16 -1
  96. package/dist/lib/util/isUrl.js.map +1 -1
  97. package/dist/lib/util/isValidRegexPattern.d.ts +7 -0
  98. package/dist/lib/util/isValidRegexPattern.js +20 -0
  99. package/dist/lib/util/isValidRegexPattern.js.map +1 -0
  100. package/dist/lib/util/sanitizeTags.d.ts +6 -0
  101. package/dist/lib/util/sanitizeTags.js +16 -0
  102. package/dist/lib/util/sanitizeTags.js.map +1 -0
  103. package/dist/lib/util/shouldValidateByBetaRules.js +6 -1
  104. package/dist/lib/util/shouldValidateByBetaRules.js.map +1 -1
  105. package/dist/lib/util/stringsConfig.d.ts +9 -0
  106. package/dist/lib/util/stringsConfig.js +9 -1
  107. package/dist/lib/util/stringsConfig.js.map +1 -1
  108. package/dist/lib/validate/validate.d.ts +57 -12
  109. package/dist/lib/validate/validate.js +87 -213
  110. package/dist/lib/validate/validate.js.map +1 -1
  111. package/dist/lib/validate/validateHelpers.d.ts +63 -0
  112. package/dist/lib/validate/validateHelpers.js +157 -0
  113. package/dist/lib/validate/validateHelpers.js.map +1 -0
  114. package/dist/locale/de.json +1 -1
  115. package/dist/locale/en.json +23 -23
  116. package/dist/locale/es.json +1 -1
  117. package/dist/locale/fr.json +1 -1
  118. package/dist/locale/ja.json +1 -1
  119. package/dist/locale/pt-br.json +1 -1
  120. package/dist/package-info.json +1 -1
  121. package/dist/services/content-validator-assets/config.d.ts +4 -0
  122. package/dist/services/content-validator-assets/config.js +8 -0
  123. package/dist/services/content-validator-assets/config.js.map +1 -0
  124. package/dist/services/content-validator-assets/fetchAdditonalPatterns4TitleAndSnippetSearchability.d.ts +95 -0
  125. package/dist/services/content-validator-assets/fetchAdditonalPatterns4TitleAndSnippetSearchability.js +92 -0
  126. package/dist/services/content-validator-assets/fetchAdditonalPatterns4TitleAndSnippetSearchability.js.map +1 -0
  127. package/dist/services/content-validator-assets/fetchProfanitiesData.d.ts +18 -0
  128. package/dist/services/content-validator-assets/fetchProfanitiesData.js +55 -0
  129. package/dist/services/content-validator-assets/fetchProfanitiesData.js.map +1 -0
  130. package/dist/services/content-validator-assets/helpers.d.ts +16 -0
  131. package/dist/services/content-validator-assets/helpers.js +35 -0
  132. package/dist/services/content-validator-assets/helpers.js.map +1 -0
  133. package/dist/services/custom-terms/config.d.ts +27 -0
  134. package/dist/services/custom-terms/config.js +79 -0
  135. package/dist/services/custom-terms/config.js.map +1 -0
  136. package/dist/services/custom-terms/customTerms.d.ts +229 -0
  137. package/dist/services/custom-terms/customTerms.js +394 -0
  138. package/dist/services/custom-terms/customTerms.js.map +1 -0
  139. package/dist/services/custom-terms/helpers.d.ts +8 -0
  140. package/dist/services/custom-terms/helpers.js +25 -0
  141. package/dist/services/custom-terms/helpers.js.map +1 -0
  142. package/dist/services/custom-terms/index.d.ts +3 -0
  143. package/dist/services/custom-terms/index.js +10 -0
  144. package/dist/services/custom-terms/index.js.map +1 -0
  145. package/dist/services/custom-terms-review-results/config.d.ts +31 -0
  146. package/dist/services/custom-terms-review-results/config.js +78 -0
  147. package/dist/services/custom-terms-review-results/config.js.map +1 -0
  148. package/dist/services/custom-terms-review-results/customTermsReviewResults.d.ts +133 -0
  149. package/dist/services/custom-terms-review-results/customTermsReviewResults.js +276 -0
  150. package/dist/services/custom-terms-review-results/customTermsReviewResults.js.map +1 -0
  151. package/dist/services/custom-terms-review-results/helpers.d.ts +24 -0
  152. package/dist/services/custom-terms-review-results/helpers.js +52 -0
  153. package/dist/services/custom-terms-review-results/helpers.js.map +1 -0
  154. package/dist/services/custom-terms-review-results/index.d.ts +4 -0
  155. package/dist/services/custom-terms-review-results/index.js +13 -0
  156. package/dist/services/custom-terms-review-results/index.js.map +1 -0
  157. package/dist/services/shared/addFeatures.d.ts +28 -0
  158. package/dist/services/shared/addFeatures.js +52 -0
  159. package/dist/services/shared/addFeatures.js.map +1 -0
  160. package/dist/services/shared/applyEdits.d.ts +28 -0
  161. package/dist/services/shared/applyEdits.js +53 -0
  162. package/dist/services/shared/applyEdits.js.map +1 -0
  163. package/dist/services/shared/config.d.ts +44 -0
  164. package/dist/services/shared/config.js +35 -0
  165. package/dist/services/shared/config.js.map +1 -0
  166. package/dist/services/shared/getItemInfo.d.ts +36 -0
  167. package/dist/services/shared/getItemInfo.js +56 -0
  168. package/dist/services/shared/getItemInfo.js.map +1 -0
  169. package/dist/types/index.d.ts +25 -22
  170. package/package.json +4 -3
  171. package/dist/__tests__/test-data/title-summary-data.json +0 -14654
  172. package/dist/data/TitleSummaryMatchingPatterns.json +0 -1902
  173. package/dist/lib/layers/isValidLayerCount.d.ts +0 -12
  174. package/dist/lib/layers/isValidLayerCount.js +0 -171
  175. package/dist/lib/layers/isValidLayerCount.js.map +0 -1
  176. package/dist/lib/layers/scoringConfig.d.ts +0 -10
  177. package/dist/lib/layers/scoringConfig.js +0 -20
  178. package/dist/lib/layers/scoringConfig.js.map +0 -1
  179. package/dist/lib/recommendedText/checkRecommendedText.d.ts +0 -15
  180. package/dist/lib/recommendedText/checkRecommendedText.js.map +0 -1
  181. package/dist/lib/recommendedText/helpers.d.ts +0 -15
  182. package/dist/lib/recommendedText/helpers.js +0 -62
  183. package/dist/lib/recommendedText/helpers.js.map +0 -1
  184. package/dist/lib/recommendedText/matchDateTimeInfo.d.ts +0 -9
  185. package/dist/lib/recommendedText/matchDateTimeInfo.js +0 -81
  186. package/dist/lib/recommendedText/matchDateTimeInfo.js.map +0 -1
  187. package/dist/lib/recommendedText/matchLocationInfo.d.ts +0 -9
  188. package/dist/lib/recommendedText/matchLocationInfo.js +0 -745
  189. package/dist/lib/recommendedText/matchLocationInfo.js.map +0 -1
  190. package/dist/lib/recommendedText/matchSourceInfo.d.ts +0 -9
  191. package/dist/lib/recommendedText/matchSourceInfo.js +0 -32
  192. package/dist/lib/recommendedText/matchSourceInfo.js.map +0 -1
  193. package/dist/lib/recommendedText/matchTopicInfo.d.ts +0 -9
  194. package/dist/lib/recommendedText/matchTopicInfo.js +0 -32
  195. package/dist/lib/recommendedText/matchTopicInfo.js.map +0 -1
  196. package/dist/lib/recommendedText/scoringConfig.js.map +0 -1
  197. /package/dist/lib/{recommendedText → checkTitleAndSnippetSearchability}/scoringConfig.d.ts +0 -0
  198. /package/dist/lib/{recommendedText → checkTitleAndSnippetSearchability}/scoringConfig.js +0 -0
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.updateFeatures = void 0;
13
+ /**
14
+ * Updates features in a feature table using the provided token and updates.
15
+ *
16
+ * @param {Object} params - The parameters for the update operation.
17
+ * @param {string} params.token - The authentication token.
18
+ * @param {Object[]} params.updates - The array of update objects containing attributes to be updated.
19
+ * @param {Object} params.updates[].attributes - The attributes to be updated for each feature.
20
+ * @param {string} params.featureTableUrl - The URL of the feature table to update.
21
+ * @returns {Promise<ApplyEditsResult[]>} - A promise that resolves to an array of ApplyEditsResult objects.
22
+ * @throws {Error} - Throws an error if the update operation fails.
23
+ */
24
+ const updateFeatures = ({ token, updates, featureTableUrl, }) => __awaiter(void 0, void 0, void 0, function* () {
25
+ var _a, _b;
26
+ const requestURL = `${featureTableUrl}/applyEdits`;
27
+ const res = yield fetch(requestURL, {
28
+ method: 'POST',
29
+ body: new URLSearchParams({
30
+ f: 'json',
31
+ token,
32
+ rollbackOnFailure: 'true',
33
+ updates: JSON.stringify(updates),
34
+ }),
35
+ });
36
+ const responseBody = yield res.json();
37
+ if (responseBody === null || responseBody === void 0 ? void 0 : responseBody.error) {
38
+ throw new Error(((_a = responseBody === null || responseBody === void 0 ? void 0 : responseBody.error) === null || _a === void 0 ? void 0 : _a.message) ||
39
+ 'Failed to apply edits to ' + featureTableUrl);
40
+ }
41
+ const updateResults = responseBody === null || responseBody === void 0 ? void 0 : responseBody.updateResults;
42
+ if (!updateResults) {
43
+ return [];
44
+ }
45
+ for (const res of updateResults) {
46
+ if ((res === null || res === void 0 ? void 0 : res.success) !== true) {
47
+ throw new Error(((_b = res === null || res === void 0 ? void 0 : res.error) === null || _b === void 0 ? void 0 : _b.description) || 'Failed to apply edits.');
48
+ }
49
+ }
50
+ return updateResults;
51
+ });
52
+ exports.updateFeatures = updateFeatures;
53
+ //# sourceMappingURL=applyEdits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyEdits.js","sourceRoot":"","sources":["../../../src/services/shared/applyEdits.ts"],"names":[],"mappings":";;;;;;;;;;;;AAmBA;;;;;;;;;;GAUG;AACI,MAAM,cAAc,GAAG,CAAO,EACjC,KAAK,EACL,OAAO,EACP,eAAe,GASlB,EAA+B,EAAE;;IAC9B,MAAM,UAAU,GAAG,GAAG,eAAe,aAAa,CAAC;IAEnD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,UAAU,EAAE;QAChC,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,eAAe,CAAC;YACtB,CAAC,EAAE,MAAM;YACT,KAAK;YACL,iBAAiB,EAAE,MAAM;YACzB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SACnC,CAAC;KACL,CAAC,CAAC;IAEH,MAAM,YAAY,GAAuB,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAE1D,IAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,EAAE;QACrB,MAAM,IAAI,KAAK,CACX,CAAA,MAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,KAAK,0CAAE,OAAO;YACxB,2BAA2B,GAAG,eAAe,CACpD,CAAC;KACL;IAED,MAAM,aAAa,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,aAAmC,CAAC;IAExE,IAAI,CAAC,aAAa,EAAE;QAChB,OAAO,EAAE,CAAC;KACb;IAED,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE;QAC7B,IAAI,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,MAAK,IAAI,EAAE;YACvB,MAAM,IAAI,KAAK,CACX,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,KAAK,0CAAE,WAAW,KAAI,wBAAwB,CACtD,CAAC;SACL;KACJ;IAED,OAAO,aAAmC,CAAC;AAC/C,CAAC,CAAA,CAAC;AAjDW,QAAA,cAAc,kBAiDzB"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Tier of the services.
3
+ * - `dev`: Development tier, pointing to development services on devext.arcgis.com.
4
+ * - `prod`: Production tier, pointing to production services on www.arcgis.com.
5
+ */
6
+ export type ServiceTier = 'prod' | 'dev';
7
+ /**
8
+ * Category of custom term:
9
+ * - `topic`: Topic, to understand what this item is about.
10
+ * - `location`: Location or area of coverage, to understand which geographic area is included.
11
+ * - `Year`: Year or Vintage, to understand the how recently the data was collected or updated.
12
+ * - `source`: Source organization/program, to understand where the item’s content originated
13
+ */
14
+ export type CustomTermCategory = 'topic' | 'location' | 'vintage-year' | 'source';
15
+ /**
16
+ * Represents the status of a custom term in the contribution process.
17
+ *
18
+ * - `staged`: The custom term is in the initial stage and has not yet been submitted.
19
+ * - `submitted`: The custom term has been submitted for review.
20
+ * - `approved`: The custom term has been reviewed and approved.
21
+ * - `rejected`: The custom term has been reviewed and rejected.
22
+ * - `expired`: The custom term has expired and is no longer valid.
23
+ */
24
+ export type CustomTermStatus = 'staged' | 'submitted' | 'approved' | 'rejected' | 'expired';
25
+ /**
26
+ * The service tier of the application.
27
+ * - `dev`: Development tier, pointing to development services on devext.arcgis.com.
28
+ * - `prod`: Production tier, pointing to production services on www.arcgis.com.
29
+ */
30
+ export declare let serviceTier: ServiceTier;
31
+ /**
32
+ * Indicates if the environment is Node.js.
33
+ */
34
+ export declare const isNodeEnv: boolean;
35
+ /**
36
+ * Sets the tier for the services.
37
+ *
38
+ * Why is this needed? Why can't we just use the TIER constant based on the hostname?
39
+ * Because these services can also be used in a node.js environment, where the hostname is not available.
40
+ * That's why we need to set the tier explicitly.
41
+ *
42
+ * @param tier - The tier to set for the services.
43
+ */
44
+ export declare const setServiceTier: (tier: ServiceTier) => void;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ // export const TIER =
3
+ // window.location.hostname === 'livingatlas.arcgis.com' ||
4
+ // window.location.hostname === 'livingatlasstg.arcgis.com'
5
+ // ? 'prod'
6
+ // : 'dev';
7
+ var _a;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.setServiceTier = exports.isNodeEnv = exports.serviceTier = void 0;
10
+ /**
11
+ * The service tier of the application.
12
+ * - `dev`: Development tier, pointing to development services on devext.arcgis.com.
13
+ * - `prod`: Production tier, pointing to production services on www.arcgis.com.
14
+ */
15
+ exports.serviceTier = 'dev';
16
+ /**
17
+ * Indicates if the environment is Node.js.
18
+ */
19
+ exports.isNodeEnv = typeof process !== 'undefined' &&
20
+ (process === null || process === void 0 ? void 0 : process.versions) != null &&
21
+ ((_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) != null;
22
+ /**
23
+ * Sets the tier for the services.
24
+ *
25
+ * Why is this needed? Why can't we just use the TIER constant based on the hostname?
26
+ * Because these services can also be used in a node.js environment, where the hostname is not available.
27
+ * That's why we need to set the tier explicitly.
28
+ *
29
+ * @param tier - The tier to set for the services.
30
+ */
31
+ const setServiceTier = (tier) => {
32
+ exports.serviceTier = tier;
33
+ };
34
+ exports.setServiceTier = setServiceTier;
35
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/services/shared/config.ts"],"names":[],"mappings":";AAAA,sBAAsB;AACtB,+DAA+D;AAC/D,+DAA+D;AAC/D,mBAAmB;AACnB,mBAAmB;;;;AAsCnB;;;;GAIG;AACQ,QAAA,WAAW,GAAgB,KAAK,CAAC;AAE5C;;GAEG;AACU,QAAA,SAAS,GAClB,OAAO,OAAO,KAAK,WAAW;IAC9B,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,IAAI;IACzB,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,0CAAE,IAAI,KAAI,IAAI,CAAC;AAEpC;;;;;;;;GAQG;AACI,MAAM,cAAc,GAAG,CAAC,IAAiB,EAAE,EAAE;IAChD,mBAAW,GAAG,IAAI,CAAC;AACvB,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The response type for the item information fetched from the ArcGIS REST API.
3
+ */
4
+ export type ItemInfoResponse = {
5
+ id: string;
6
+ name: string;
7
+ owner: string;
8
+ guid: string;
9
+ title: string;
10
+ type: string;
11
+ typeKeywords: string[];
12
+ description: string;
13
+ tags: string[];
14
+ snippet: string;
15
+ thumbnail: string;
16
+ extent: number[];
17
+ categorites: null | string[];
18
+ spatialReference: string;
19
+ url: string;
20
+ culture: string;
21
+ licenseInfo: string;
22
+ accessInformation: string;
23
+ properties: string | object;
24
+ access: string;
25
+ size: number;
26
+ };
27
+ /**
28
+ * Fetches the item information for a feature table from the ArcGIS REST API.
29
+ * @param itemInfoEndPoint - The endpoint URL for the itemInfo service of a feature table. This should be the URL to the `/info/itemInfo` endpoint of the feature service.
30
+ * @param token - The authentication token to access the ArcGIS REST API. This is required for accessing secured resources.
31
+ * @returns A promise that resolves to an object containing the item information,
32
+ * or rejects with an error if the request fails or the response is not in the expected format.
33
+ *
34
+ * @see https://developers.arcgis.com/rest/enterprise-administration/server/iteminfo/
35
+ */
36
+ export declare const getFeatureLayerItemInfo: (itemInfoEndPoint: string, token: string) => Promise<ItemInfoResponse>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getFeatureLayerItemInfo = void 0;
13
+ /**
14
+ * Fetches the item information for a feature table from the ArcGIS REST API.
15
+ * @param itemInfoEndPoint - The endpoint URL for the itemInfo service of a feature table. This should be the URL to the `/info/itemInfo` endpoint of the feature service.
16
+ * @param token - The authentication token to access the ArcGIS REST API. This is required for accessing secured resources.
17
+ * @returns A promise that resolves to an object containing the item information,
18
+ * or rejects with an error if the request fails or the response is not in the expected format.
19
+ *
20
+ * @see https://developers.arcgis.com/rest/enterprise-administration/server/iteminfo/
21
+ */
22
+ const getFeatureLayerItemInfo = (itemInfoEndPoint, token) => __awaiter(void 0, void 0, void 0, function* () {
23
+ var _a;
24
+ if (!itemInfoEndPoint || !token) {
25
+ // Validate input parameters
26
+ throw new Error('Both itemInfoEndPoint and token are required');
27
+ }
28
+ try {
29
+ const params = new URLSearchParams({
30
+ f: 'json',
31
+ token,
32
+ });
33
+ const res = yield fetch(itemInfoEndPoint + '?' + params.toString());
34
+ const data = yield res.json();
35
+ if (data === null || data === void 0 ? void 0 : data.error) {
36
+ // Handle the error response from the server
37
+ throw new Error(((_a = data === null || data === void 0 ? void 0 : data.error) === null || _a === void 0 ? void 0 : _a.message) || 'unknown error');
38
+ }
39
+ // Check if the response is in the expected format
40
+ if (!data || typeof data !== 'object') {
41
+ throw new Error('Invalid response format');
42
+ }
43
+ // Check if the response contains the expected properties
44
+ if (!data.id || !data.owner) {
45
+ // Ensure that the required properties are present in the response
46
+ throw new Error('Missing required properties in the response');
47
+ }
48
+ // Return the parsed item info response
49
+ return data;
50
+ }
51
+ catch (error) {
52
+ throw new Error(`Failed to fetch itemInfo (${itemInfoEndPoint}): ${error}`);
53
+ }
54
+ });
55
+ exports.getFeatureLayerItemInfo = getFeatureLayerItemInfo;
56
+ //# sourceMappingURL=getItemInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getItemInfo.js","sourceRoot":"","sources":["../../../src/services/shared/getItemInfo.ts"],"names":[],"mappings":";;;;;;;;;;;;AA2BA;;;;;;;;GAQG;AACI,MAAM,uBAAuB,GAAG,CACnC,gBAAwB,EACxB,KAAa,EACY,EAAE;;IAC3B,IAAI,CAAC,gBAAgB,IAAI,CAAC,KAAK,EAAE;QAC7B,4BAA4B;QAC5B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;KACnE;IAED,IAAI;QACA,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;YAC/B,CAAC,EAAE,MAAM;YACT,KAAK;SACR,CAAC,CAAC;QAEH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,gBAAgB,GAAG,GAAG,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEpE,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAE9B,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,EAAE;YACb,4CAA4C;YAC5C,MAAM,IAAI,KAAK,CAAC,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,OAAO,KAAI,eAAe,CAAC,CAAC;SAC5D;QAED,kDAAkD;QAClD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;SAC9C;QAED,yDAAyD;QACzD,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACzB,kEAAkE;YAClE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAClE;QAED,uCAAuC;QACvC,OAAO,IAAwB,CAAC;KACnC;IAAC,OAAO,KAAK,EAAE;QACZ,MAAM,IAAI,KAAK,CACX,6BAA6B,gBAAgB,MAAM,KAAK,EAAE,CAC7D,CAAC;KACL;AACL,CAAC,CAAA,CAAC;AA1CW,QAAA,uBAAuB,2BA0ClC"}
@@ -38,13 +38,6 @@ export type IItem = {
38
38
  numViews: number;
39
39
  size: number;
40
40
  protected?: boolean;
41
- /**
42
- * dimension of the thumbnail image
43
- */
44
- dimensions?: {
45
- width: number;
46
- height: number;
47
- };
48
41
  [key: string]: any;
49
42
  };
50
43
  /**
@@ -92,15 +85,21 @@ export type ValidationMessage = {
92
85
  code?: string;
93
86
  message: string;
94
87
  };
88
+ /**
89
+ * Represents the status of a validation result for a specific rule.
90
+ * This type indicates the outcome of the validation process for
91
+ * each rule and helps in understanding how well the item meets the
92
+ * criteria defined by the validation rules.
93
+ *
94
+ * The possible values for this type include:
95
+ * - `pass`: The validation rule has been passed successfully.
96
+ * - `warning`: The validation rule has been passed but with some warnings.
97
+ * - `error`: The validation rule has failed and requires attention or correction.
98
+ * - `not-applicable`: The validation rule is not applicable to the item being validated.
99
+ * - `unknown`: The validation status is unknown, which is the default status when a ValidationInfo object is created but the validation process has not yet been executed.
100
+ */
101
+ export type ValidationResultStatus = 'pass' | 'warning' | 'error' | 'not-applicable' | 'unknown';
95
102
  export type ValidationInfo = {
96
- /**
97
- * key of the validation rule
98
- */
99
- property: string;
100
- /**
101
- * if true, this is a critical validation rule
102
- */
103
- critical: boolean;
104
103
  /**
105
104
  * The title string tells the user what this validation rule checks, e.g., "Check Thumbnail" or "Check Number of Layers".
106
105
  */
@@ -129,6 +128,14 @@ export type ValidationInfo = {
129
128
  * A factor ranging between 0 and 1 used to calculate the final score by multiplying it with the weight number.
130
129
  */
131
130
  weightFactor: number;
131
+ /**
132
+ * Status of the validation result
133
+ */
134
+ status: ValidationResultStatus;
135
+ /**
136
+ * if true, this validation rule is a binary check, i.e., it can only pass or fail.
137
+ */
138
+ isBinaryCheck: boolean;
132
139
  };
133
140
  /**
134
141
  * Validation result returned by the `validate` function
@@ -147,10 +154,6 @@ export type ValidationResult = {
147
154
  * validation result of item's Description text
148
155
  */
149
156
  description: ValidationInfo;
150
- /**
151
- * validation result of item's Layers count
152
- */
153
- layerCount: ValidationInfo;
154
157
  /**
155
158
  * validation result of item's License Info
156
159
  */
@@ -202,11 +205,11 @@ export type ValidationResult = {
202
205
  /**
203
206
  * Id of the ArcGIS Online Item
204
207
  */
205
- id?: string;
208
+ id: string;
206
209
  /**
207
210
  * total score of the validation result
208
211
  */
209
- totalScore?: number;
212
+ totalScore: number;
210
213
  /**
211
214
  * if true, this item meets all minimum requirements
212
215
  * and it can be nominated to Living Atlas.
@@ -220,5 +223,5 @@ export type ValidationResult = {
220
223
  * - It has a description text
221
224
  * - The item owner has a user profile description
222
225
  */
223
- canBeNominated?: boolean;
226
+ canBeNominated: boolean;
224
227
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vannizhang/living-atlas-content-validator",
3
- "version": "1.5.17",
3
+ "version": "1.5.18-beta.2",
4
4
  "description": "Validation and Scoring rules for curating content in the ArcGIS Living Atlas",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,14 +16,14 @@
16
16
  "files": [
17
17
  "dist/**/*"
18
18
  ],
19
- "license": "MIT",
19
+ "license": "Apache-2.0",
20
20
  "scripts": {
21
21
  "test": "jest --config jest.config.js --testPathIgnorePatterns=__tests__",
22
22
  "test:benchmarks": "jest --config jest.config.js __tests__/benchmarks/",
23
23
  "test:regression": "jest --config jest.config.js __tests__/regression/",
24
24
  "clean": "rimraf dist",
25
25
  "build": "npm run clean && tsc",
26
- "postbuild": "node ./scripts/addPackageInfo.js",
26
+ "postbuild": "node ./scripts/add-package-info/index.js",
27
27
  "lint": "eslint src --ext .tsx,.ts --cache --fix",
28
28
  "prepare": "husky install && npm run build",
29
29
  "prepublishOnly": "npm run test && npm run lint",
@@ -46,6 +46,7 @@
46
46
  "eslint-plugin-prettier": "^4.2.1",
47
47
  "husky": "^8.0.3",
48
48
  "jest": "^29.5.0",
49
+ "jest-environment-jsdom": "^29.7.0",
49
50
  "lint-staged": "^13.2.1",
50
51
  "prettier": "^2.8.7",
51
52
  "rimraf": "^5.0.0",