@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,133 @@
1
+ import { CustomTermsReviewResultLifecycle } from './config';
2
+ import { CustomTermCategory, CustomTermStatus } from '../shared/config';
3
+ import { AddFeaturesResponse } from '../shared/addFeatures';
4
+ import { ApplyEditsResult } from '../shared/applyEdits';
5
+ import { ItemInfoResponse } from '../shared/getItemInfo';
6
+ /**
7
+ * Represents the feature of a custom term review result.
8
+ */
9
+ export type CustomTermReviewResultFeature = {
10
+ /**
11
+ * objectId of the feature
12
+ */
13
+ objectId: number;
14
+ /**
15
+ * the term that is added by the user
16
+ */
17
+ term: string;
18
+ /**
19
+ * the category of the term
20
+ */
21
+ category: CustomTermCategory;
22
+ /**
23
+ * the status of the custom term, which is the decision made by the curator,
24
+ * should be 'approved' or 'rejected'
25
+ */
26
+ status: CustomTermStatus;
27
+ /**
28
+ * lifecycle of this review result
29
+ */
30
+ lifeCycle: CustomTermsReviewResultLifecycle;
31
+ /**
32
+ * the note of the term added by the curator who reviewed the term
33
+ */
34
+ note: string;
35
+ /**
36
+ * date when the term was last edited
37
+ */
38
+ editor: string;
39
+ /**
40
+ * the user who last edited the term
41
+ */
42
+ editDate: number;
43
+ };
44
+ /**
45
+ * Fetches the review results for a custom term.
46
+ *
47
+ * @param {Object} params - The parameters for fetching the review results.
48
+ * @param {string} params.term - The custom term to review.
49
+ * @param {CustomTermCategory} params.category - The category of the custom term.
50
+ * @param {string} params.token - The authentication token.
51
+ * @param {CustomTermsReviewResultLifecycle[]} params.lifeCycles - An optional array of lifecycle values to filter the results.
52
+ * @returns {Promise<CustomTermReviewResultFeature[]>} A promise that resolves to an array of custom term review result features.
53
+ * @throws {Error} If no token is provided or if the fetch request fails.
54
+ */
55
+ export declare const getReviewResultsByTermAndCategory: ({ term, category, lifeCycles, token, }: {
56
+ term: string;
57
+ category: CustomTermCategory;
58
+ token: string;
59
+ lifeCycles?: CustomTermsReviewResultLifecycle[];
60
+ }) => Promise<CustomTermReviewResultFeature[]>;
61
+ /**
62
+ * Retrieves all custom terms review results that are not archived.
63
+ *
64
+ * @param token - The authentication token to access the custom terms review results.
65
+ * @returns A promise that resolves to an array of `CustomTermReviewResultFeature` objects.
66
+ */
67
+ export declare const getUnarchivedReviewResults: (token: string) => Promise<CustomTermReviewResultFeature[]>;
68
+ /**
69
+ * Retrieves the custom terms review results that have been reviewed but not yet packaged.
70
+ *
71
+ * @param token - The authentication token to access the custom terms review results.
72
+ * @returns A promise that resolves to an array of `CustomTermReviewResultFeature` objects.
73
+ */
74
+ export declare const getReviewedReviewResults: (token: string) => Promise<CustomTermReviewResultFeature[]>;
75
+ /**
76
+ * Retrieves the custom terms review results that have been packaged but not yet deployed.
77
+ *
78
+ * @param token - The authentication token required to access the custom terms review results.
79
+ * @returns A promise that resolves to an array of CustomTermReviewResultFeature objects.
80
+ */
81
+ export declare const getPackagedReviewResults: (token: string) => Promise<CustomTermReviewResultFeature[]>;
82
+ /**
83
+ * Retrieves the custom terms review results that have been deployed.
84
+ *
85
+ * @param token - The authentication token required to access the custom terms review results.
86
+ * @returns A promise that resolves to an array of CustomTermReviewResultFeature objects.
87
+ */
88
+ export declare const getDeployedReviewResults: (token: string) => Promise<CustomTermReviewResultFeature[]>;
89
+ /**
90
+ * Adds review results to the feature table.
91
+ *
92
+ * @param {string} token - The authentication token.
93
+ * @param {Array<{ term: string; category: CustomTermCategory; status: CustomTermStatus; note: string }>} data - The data of review results to be added.
94
+ * @returns {Promise<AddFeaturesResponse[]>} A promise that resolves to an array of AddFeaturesResponse objects.
95
+ *
96
+ * @throws {Error} - Throws an error if the token is not provided or if any required fields are missing in the data.
97
+ */
98
+ export declare const addReviewResults2FeatureTable: (token: string, data: {
99
+ term: string;
100
+ category: CustomTermCategory;
101
+ status: CustomTermStatus;
102
+ note: string;
103
+ }[]) => Promise<AddFeaturesResponse[]>;
104
+ /**
105
+ * Updates review results in the feature table.
106
+ *
107
+ * @param token - The authentication token required for the update.
108
+ * @param data - An array of objects containing the review results to be updated.
109
+ * @param data[].objectId - The object ID of the feature to be updated.
110
+ * @param data[].term - The term associated with the review result.
111
+ * @param data[].category - The category of the custom term.
112
+ * @param data[].status - The status of the custom term.
113
+ * @param data[].note - A note associated with the review result.
114
+ * @param data[].lifecycle - The lifecycle status of the review result.
115
+ * @returns A promise that resolves to an array of ApplyEditsResult objects.
116
+ * @throws Will throw an error if the token is not provided.
117
+ * @throws Will throw an error if any term is empty.
118
+ * @throws Will throw an error if any required fields are missing.
119
+ */
120
+ export declare const updateReviewResultsInFeatureTable: (token: string, data: {
121
+ objectId: number;
122
+ term: string;
123
+ category: CustomTermCategory;
124
+ status: CustomTermStatus;
125
+ note: string;
126
+ lifecycle: CustomTermsReviewResultLifecycle;
127
+ }[]) => Promise<ApplyEditsResult[]>;
128
+ /**
129
+ * Get the item info for the Custom Terms Review Results feature table.
130
+ * @param token - The authentication token required to access the item info.
131
+ * @returns A promise that resolves to an `ItemInfoResponse` object containing metadata about the feature table.
132
+ */
133
+ export declare const getCustomTermsReviewResultsFeatureTableItemInfo: (token: string) => Promise<ItemInfoResponse>;
@@ -0,0 +1,276 @@
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.getCustomTermsReviewResultsFeatureTableItemInfo = exports.updateReviewResultsInFeatureTable = exports.addReviewResults2FeatureTable = exports.getDeployedReviewResults = exports.getPackagedReviewResults = exports.getReviewedReviewResults = exports.getUnarchivedReviewResults = exports.getReviewResultsByTermAndCategory = void 0;
13
+ const config_1 = require("./config");
14
+ const addFeatures_1 = require("../shared/addFeatures");
15
+ const helpers_1 = require("./helpers");
16
+ const applyEdits_1 = require("../shared/applyEdits");
17
+ const getItemInfo_1 = require("../shared/getItemInfo");
18
+ /**
19
+ * Fetches the review results for a custom term.
20
+ *
21
+ * @param {Object} params - The parameters for fetching the review results.
22
+ * @param {string} params.term - The custom term to review.
23
+ * @param {CustomTermCategory} params.category - The category of the custom term.
24
+ * @param {string} params.token - The authentication token.
25
+ * @param {CustomTermsReviewResultLifecycle[]} params.lifeCycles - An optional array of lifecycle values to filter the results.
26
+ * @returns {Promise<CustomTermReviewResultFeature[]>} A promise that resolves to an array of custom term review result features.
27
+ * @throws {Error} If no token is provided or if the fetch request fails.
28
+ */
29
+ const getReviewResultsByTermAndCategory = ({ term, category, lifeCycles, token, }) => __awaiter(void 0, void 0, void 0, function* () {
30
+ var _a;
31
+ if (!token) {
32
+ throw new Error('No token found');
33
+ }
34
+ const CustomTermsReviewResultsFeatureTableUrl = (0, config_1.getCustomTermsReviewResultsFeatureTableUrl)();
35
+ const requestURL = `${CustomTermsReviewResultsFeatureTableUrl}/query`;
36
+ // const where = [
37
+ // `(${CustomTermsReviewResultsFeatureTableField.TERM} = '${term}')`,
38
+ // `(${CustomTermsReviewResultsFeatureTableField.CATEGORY} = '${category}')`,
39
+ // ];
40
+ // if (lifeCycles?.length) {
41
+ // where.push(
42
+ // `(${
43
+ // CustomTermsReviewResultsFeatureTableField.LIFECYCLE
44
+ // } IN ('${lifeCycles.join("','")}'))`
45
+ // );
46
+ // }
47
+ const whereClause = (0, helpers_1.getWhereClause2QueryReviewResultsByTermAndCategory)(term, category, lifeCycles);
48
+ const queryParams = new URLSearchParams({
49
+ where: whereClause,
50
+ outFields: '*',
51
+ f: 'json',
52
+ token,
53
+ resultRecordCount: '1',
54
+ });
55
+ const response = yield fetch(`${requestURL}?${queryParams.toString()}`);
56
+ const data = yield response.json();
57
+ if (data.error) {
58
+ throw new Error(((_a = data === null || data === void 0 ? void 0 : data.error) === null || _a === void 0 ? void 0 : _a.message) ||
59
+ 'Failed to fetch custom terms review results');
60
+ }
61
+ const features = (data === null || data === void 0 ? void 0 : data.features) || [];
62
+ return features.map(helpers_1.formatAsCustomTermReviewResultFeature);
63
+ });
64
+ exports.getReviewResultsByTermAndCategory = getReviewResultsByTermAndCategory;
65
+ /**
66
+ * Fetches custom terms review results.
67
+ *
68
+ * @param {Object} params - The parameters for fetching custom terms review results.
69
+ * @param {string} params.token - The authentication token required for the request.
70
+ * @param {string[]} [params.liecycles] - An optional array of lifecycle values to filter the results.
71
+ * @returns {Promise<CustomTermReviewResultFeature[]>} A promise that resolves to an array of custom term review result features.
72
+ * @throws {Error} Throws an error if the token is not provided or if the fetch request fails.
73
+ */
74
+ const getReviewResults = ({ token, liecycles, }) => __awaiter(void 0, void 0, void 0, function* () {
75
+ var _b;
76
+ if (!token) {
77
+ throw new Error('No token found');
78
+ }
79
+ const CustomTermsReviewResultsFeatureTableUrl = (0, config_1.getCustomTermsReviewResultsFeatureTableUrl)();
80
+ const requestURL = `${CustomTermsReviewResultsFeatureTableUrl}/query`;
81
+ const whereClause = [
82
+ `(${config_1.CustomTermsReviewResultsFeatureTableField.TERM} IS NOT NULL)`,
83
+ `(${config_1.CustomTermsReviewResultsFeatureTableField.TERM} <> '')`,
84
+ ];
85
+ if (liecycles === null || liecycles === void 0 ? void 0 : liecycles.length) {
86
+ whereClause.push(`(${config_1.CustomTermsReviewResultsFeatureTableField.LIFECYCLE} IN ('${liecycles.join("','")}'))`);
87
+ }
88
+ const where = whereClause.join(' AND ');
89
+ const outFields = '*';
90
+ const allFeatures = [];
91
+ const resultRecordCount = 1000;
92
+ let resultOffset = 0;
93
+ let exceededTransferLimit = true;
94
+ while (exceededTransferLimit) {
95
+ const queryParams = new URLSearchParams({
96
+ where,
97
+ outFields,
98
+ f: 'json',
99
+ token,
100
+ resultOffset: resultOffset.toString(),
101
+ resultRecordCount: resultRecordCount.toString(),
102
+ });
103
+ const response = yield fetch(`${requestURL}?${queryParams.toString()}`);
104
+ const data = yield response.json();
105
+ if (data.error) {
106
+ throw new Error(((_b = data === null || data === void 0 ? void 0 : data.error) === null || _b === void 0 ? void 0 : _b.message) ||
107
+ 'Failed to fetch custom terms review results');
108
+ }
109
+ const features = (data === null || data === void 0 ? void 0 : data.features) || [];
110
+ for (const feature of features) {
111
+ allFeatures.push((0, helpers_1.formatAsCustomTermReviewResultFeature)(feature));
112
+ }
113
+ exceededTransferLimit = (data === null || data === void 0 ? void 0 : data.exceededTransferLimit) || false;
114
+ resultOffset += resultRecordCount;
115
+ }
116
+ return allFeatures;
117
+ });
118
+ /**
119
+ * Retrieves all custom terms review results that are not archived.
120
+ *
121
+ * @param token - The authentication token to access the custom terms review results.
122
+ * @returns A promise that resolves to an array of `CustomTermReviewResultFeature` objects.
123
+ */
124
+ const getUnarchivedReviewResults = (token) => __awaiter(void 0, void 0, void 0, function* () {
125
+ return getReviewResults({
126
+ token,
127
+ liecycles: ['reviewed', 'packaged', 'deployed'],
128
+ });
129
+ });
130
+ exports.getUnarchivedReviewResults = getUnarchivedReviewResults;
131
+ /**
132
+ * Retrieves the custom terms review results that have been reviewed but not yet packaged.
133
+ *
134
+ * @param token - The authentication token to access the custom terms review results.
135
+ * @returns A promise that resolves to an array of `CustomTermReviewResultFeature` objects.
136
+ */
137
+ const getReviewedReviewResults = (token) => __awaiter(void 0, void 0, void 0, function* () {
138
+ return getReviewResults({
139
+ token,
140
+ liecycles: ['reviewed'],
141
+ });
142
+ });
143
+ exports.getReviewedReviewResults = getReviewedReviewResults;
144
+ /**
145
+ * Retrieves the custom terms review results that have been packaged but not yet deployed.
146
+ *
147
+ * @param token - The authentication token required to access the custom terms review results.
148
+ * @returns A promise that resolves to an array of CustomTermReviewResultFeature objects.
149
+ */
150
+ const getPackagedReviewResults = (token) => __awaiter(void 0, void 0, void 0, function* () {
151
+ return getReviewResults({
152
+ token,
153
+ liecycles: ['packaged'],
154
+ });
155
+ });
156
+ exports.getPackagedReviewResults = getPackagedReviewResults;
157
+ /**
158
+ * Retrieves the custom terms review results that have been deployed.
159
+ *
160
+ * @param token - The authentication token required to access the custom terms review results.
161
+ * @returns A promise that resolves to an array of CustomTermReviewResultFeature objects.
162
+ */
163
+ const getDeployedReviewResults = (token) => __awaiter(void 0, void 0, void 0, function* () {
164
+ return getReviewResults({
165
+ token,
166
+ liecycles: ['deployed'],
167
+ });
168
+ });
169
+ exports.getDeployedReviewResults = getDeployedReviewResults;
170
+ /**
171
+ * Adds review results to the feature table.
172
+ *
173
+ * @param {string} token - The authentication token.
174
+ * @param {Array<{ term: string; category: CustomTermCategory; status: CustomTermStatus; note: string }>} data - The data of review results to be added.
175
+ * @returns {Promise<AddFeaturesResponse[]>} A promise that resolves to an array of AddFeaturesResponse objects.
176
+ *
177
+ * @throws {Error} - Throws an error if the token is not provided or if any required fields are missing in the data.
178
+ */
179
+ const addReviewResults2FeatureTable = (token, data) => __awaiter(void 0, void 0, void 0, function* () {
180
+ // const requestURL = `${CustomTermsReviewResultsFeatureTableUrl}/addFeatures`;
181
+ const CustomTermsReviewResultsFeatureTableUrl = (0, config_1.getCustomTermsReviewResultsFeatureTableUrl)();
182
+ if (!token) {
183
+ throw new Error('Token is required');
184
+ }
185
+ for (const d of data) {
186
+ const term = d.term ? d.term.trim() : '';
187
+ if (!term || !d.category || !d.status || !d.note) {
188
+ throw new Error(`Missing required fields: ${JSON.stringify(d)}`);
189
+ }
190
+ }
191
+ const lifeCycle = 'reviewed';
192
+ const features = data.map((d) => {
193
+ // const termLowerCase = d.term.toLowerCase();
194
+ return {
195
+ attributes: {
196
+ [config_1.CustomTermsReviewResultsFeatureTableField.TERM]: d.term,
197
+ [config_1.CustomTermsReviewResultsFeatureTableField.CATEGORY]: d.category,
198
+ [config_1.CustomTermsReviewResultsFeatureTableField.STATUS]: d.status,
199
+ [config_1.CustomTermsReviewResultsFeatureTableField.LIFECYCLE]: lifeCycle,
200
+ [config_1.CustomTermsReviewResultsFeatureTableField.NOTE]: d.note || '',
201
+ },
202
+ };
203
+ });
204
+ const res = yield (0, addFeatures_1.addFeatures)({
205
+ featureTableUrl: CustomTermsReviewResultsFeatureTableUrl,
206
+ features,
207
+ token,
208
+ });
209
+ return res;
210
+ });
211
+ exports.addReviewResults2FeatureTable = addReviewResults2FeatureTable;
212
+ /**
213
+ * Updates review results in the feature table.
214
+ *
215
+ * @param token - The authentication token required for the update.
216
+ * @param data - An array of objects containing the review results to be updated.
217
+ * @param data[].objectId - The object ID of the feature to be updated.
218
+ * @param data[].term - The term associated with the review result.
219
+ * @param data[].category - The category of the custom term.
220
+ * @param data[].status - The status of the custom term.
221
+ * @param data[].note - A note associated with the review result.
222
+ * @param data[].lifecycle - The lifecycle status of the review result.
223
+ * @returns A promise that resolves to an array of ApplyEditsResult objects.
224
+ * @throws Will throw an error if the token is not provided.
225
+ * @throws Will throw an error if any term is empty.
226
+ * @throws Will throw an error if any required fields are missing.
227
+ */
228
+ const updateReviewResultsInFeatureTable = (token, data) => __awaiter(void 0, void 0, void 0, function* () {
229
+ if (!token) {
230
+ throw new Error('Token is required');
231
+ }
232
+ const CustomTermsReviewResultsFeatureTableUrl = (0, config_1.getCustomTermsReviewResultsFeatureTableUrl)();
233
+ for (const d of data) {
234
+ const term = d.term ? d.term.trim() : '';
235
+ if (!term) {
236
+ throw new Error(`Term cannot be empty: ${JSON.stringify(d)}`);
237
+ }
238
+ if (Object.values(d).some((value) => !value)) {
239
+ throw new Error(`Missing required fields: ${JSON.stringify(d)}`);
240
+ }
241
+ }
242
+ const features = data.map((d) => {
243
+ return {
244
+ attributes: {
245
+ [config_1.CustomTermsReviewResultsFeatureTableField.OBJECT_ID]: d.objectId,
246
+ [config_1.CustomTermsReviewResultsFeatureTableField.TERM]: d.term,
247
+ [config_1.CustomTermsReviewResultsFeatureTableField.CATEGORY]: d.category,
248
+ [config_1.CustomTermsReviewResultsFeatureTableField.STATUS]: d.status,
249
+ [config_1.CustomTermsReviewResultsFeatureTableField.LIFECYCLE]: d.lifecycle,
250
+ [config_1.CustomTermsReviewResultsFeatureTableField.NOTE]: d.note,
251
+ },
252
+ };
253
+ });
254
+ const res = yield (0, applyEdits_1.updateFeatures)({
255
+ token,
256
+ updates: features,
257
+ featureTableUrl: CustomTermsReviewResultsFeatureTableUrl,
258
+ });
259
+ return res;
260
+ });
261
+ exports.updateReviewResultsInFeatureTable = updateReviewResultsInFeatureTable;
262
+ /**
263
+ * Get the item info for the Custom Terms Review Results feature table.
264
+ * @param token - The authentication token required to access the item info.
265
+ * @returns A promise that resolves to an `ItemInfoResponse` object containing metadata about the feature table.
266
+ */
267
+ const getCustomTermsReviewResultsFeatureTableItemInfo = (token) => __awaiter(void 0, void 0, void 0, function* () {
268
+ const itemInfoUrl = (0, config_1.getCustomTermsReviewResultsFeatureTableItemInfoUrl)();
269
+ if (!token) {
270
+ throw new Error('Token is required');
271
+ }
272
+ const res = yield (0, getItemInfo_1.getFeatureLayerItemInfo)(itemInfoUrl, token);
273
+ return res;
274
+ });
275
+ exports.getCustomTermsReviewResultsFeatureTableItemInfo = getCustomTermsReviewResultsFeatureTableItemInfo;
276
+ //# sourceMappingURL=customTermsReviewResults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customTermsReviewResults.js","sourceRoot":"","sources":["../../../src/services/custom-terms-review-results/customTermsReviewResults.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAMkB;AAElB,uDAAyE;AACzE,uCAGmB;AACnB,qDAAwE;AACxE,uDAG+B;AAsD/B;;;;;;;;;;GAUG;AACI,MAAM,iCAAiC,GAAG,CAAO,EACpD,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,KAAK,GAMR,EAA4C,EAAE;;IAC3C,IAAI,CAAC,KAAK,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;KACrC;IAED,MAAM,uCAAuC,GACzC,IAAA,mDAA0C,GAAE,CAAC;IAEjD,MAAM,UAAU,GAAG,GAAG,uCAAuC,QAAQ,CAAC;IAEtE,kBAAkB;IAClB,yEAAyE;IACzE,iFAAiF;IACjF,KAAK;IAEL,4BAA4B;IAC5B,kBAAkB;IAClB,eAAe;IACf,kEAAkE;IAClE,+CAA+C;IAC/C,SAAS;IACT,IAAI;IAEJ,MAAM,WAAW,GAAG,IAAA,4DAAkD,EAClE,IAAI,EACJ,QAAQ,EACR,UAAU,CACb,CAAC;IAEF,MAAM,WAAW,GAAG,IAAI,eAAe,CAAC;QACpC,KAAK,EAAE,WAAW;QAClB,SAAS,EAAE,GAAG;QACd,CAAC,EAAE,MAAM;QACT,KAAK;QACL,iBAAiB,EAAE,GAAG;KACzB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,UAAU,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACxE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAEnC,IAAI,IAAI,CAAC,KAAK,EAAE;QACZ,MAAM,IAAI,KAAK,CACX,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IA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24 @@
1
+ import { CustomTermCategory } from '../shared/config';
2
+ import { CustomTermsReviewResultLifecycle } from './config';
3
+ import { CustomTermReviewResultFeature } from './customTermsReviewResults';
4
+ /**
5
+ * Formats a given feature object into a `CustomTermReviewResultFeature`.
6
+ *
7
+ * @param feature - The feature object containing attributes to be formatted.
8
+ * @returns A `CustomTermReviewResultFeature` object with the formatted attributes.
9
+ */
10
+ export declare const formatAsCustomTermReviewResultFeature: (feature: {
11
+ attributes: {
12
+ [key: string]: any;
13
+ };
14
+ }) => CustomTermReviewResultFeature;
15
+ /**
16
+ * Builds a SQL WHERE clause for querying review results by term and category.
17
+ *
18
+ * @param {string} term - The term to search for (will be properly escaped for SQL).
19
+ * @param {CustomTermCategory} category - The category to filter by.
20
+ * @param {CustomTermsReviewResultLifecycle[]} [lifeCycles] - Optional array of lifecycle values to filter by.
21
+ * @returns {string} A SQL WHERE clause for filtering review results.
22
+ * @throws {Error} If term or category is not provided.
23
+ */
24
+ export declare const getWhereClause2QueryReviewResultsByTermAndCategory: (term: string, category: CustomTermCategory, lifeCycles?: CustomTermsReviewResultLifecycle[]) => string;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWhereClause2QueryReviewResultsByTermAndCategory = exports.formatAsCustomTermReviewResultFeature = void 0;
4
+ const config_1 = require("./config");
5
+ /**
6
+ * Formats a given feature object into a `CustomTermReviewResultFeature`.
7
+ *
8
+ * @param feature - The feature object containing attributes to be formatted.
9
+ * @returns A `CustomTermReviewResultFeature` object with the formatted attributes.
10
+ */
11
+ const formatAsCustomTermReviewResultFeature = (feature) => {
12
+ const attributes = (feature === null || feature === void 0 ? void 0 : feature.attributes) || {};
13
+ const customTermReviewResultFeature = {
14
+ objectId: attributes[config_1.CustomTermsReviewResultsFeatureTableField.OBJECT_ID],
15
+ term: attributes[config_1.CustomTermsReviewResultsFeatureTableField.TERM],
16
+ category: attributes[config_1.CustomTermsReviewResultsFeatureTableField.CATEGORY],
17
+ status: attributes[config_1.CustomTermsReviewResultsFeatureTableField.STATUS],
18
+ lifeCycle: attributes[config_1.CustomTermsReviewResultsFeatureTableField.LIFECYCLE],
19
+ note: attributes[config_1.CustomTermsReviewResultsFeatureTableField.NOTE] || '',
20
+ editDate: attributes[config_1.CustomTermsReviewResultsFeatureTableField.EDIT_DATE] ||
21
+ null,
22
+ editor: attributes[config_1.CustomTermsReviewResultsFeatureTableField.EDITOR] || '',
23
+ };
24
+ return customTermReviewResultFeature;
25
+ };
26
+ exports.formatAsCustomTermReviewResultFeature = formatAsCustomTermReviewResultFeature;
27
+ /**
28
+ * Builds a SQL WHERE clause for querying review results by term and category.
29
+ *
30
+ * @param {string} term - The term to search for (will be properly escaped for SQL).
31
+ * @param {CustomTermCategory} category - The category to filter by.
32
+ * @param {CustomTermsReviewResultLifecycle[]} [lifeCycles] - Optional array of lifecycle values to filter by.
33
+ * @returns {string} A SQL WHERE clause for filtering review results.
34
+ * @throws {Error} If term or category is not provided.
35
+ */
36
+ const getWhereClause2QueryReviewResultsByTermAndCategory = (term, category, lifeCycles) => {
37
+ if (!term || !(term === null || term === void 0 ? void 0 : term.trim()) || !category) {
38
+ throw new Error('Term and category are required to build the where clause');
39
+ }
40
+ // To escape a single quote in SQL, we need to give it twice, i.e., 'Esri''s Homepage'. That's two single-quote characters, not a double-quote.
41
+ term = term.replace(/'/g, "''");
42
+ const where = [
43
+ `(${config_1.CustomTermsReviewResultsFeatureTableField.TERM} = '${term}')`,
44
+ `(${config_1.CustomTermsReviewResultsFeatureTableField.CATEGORY} = '${category}')`,
45
+ ];
46
+ if (lifeCycles === null || lifeCycles === void 0 ? void 0 : lifeCycles.length) {
47
+ where.push(`(${config_1.CustomTermsReviewResultsFeatureTableField.LIFECYCLE} IN ('${lifeCycles.join("','")}'))`);
48
+ }
49
+ return where.join(' AND ');
50
+ };
51
+ exports.getWhereClause2QueryReviewResultsByTermAndCategory = getWhereClause2QueryReviewResultsByTermAndCategory;
52
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/services/custom-terms-review-results/helpers.ts"],"names":[],"mappings":";;;AACA,qCAGkB;AAGlB;;;;;GAKG;AACI,MAAM,qCAAqC,GAAG,CAAC,OAIrD,EAAiC,EAAE;IAChC,MAAM,UAAU,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,KAAI,EAAE,CAAC;IAE7C,MAAM,6BAA6B,GAAkC;QACjE,QAAQ,EACJ,UAAU,CAAC,kDAAyC,CAAC,SAAS,CAAC;QACnE,IAAI,EAAE,UAAU,CAAC,kDAAyC,CAAC,IAAI,CAAC;QAChE,QAAQ,EACJ,UAAU,CAAC,kDAAyC,CAAC,QAAQ,CAAC;QAClE,MAAM,EAAE,UAAU,CAAC,kDAAyC,CAAC,MAAM,CAAC;QACpE,SAAS,EACL,UAAU,CAAC,kDAAyC,CAAC,SAAS,CAAC;QACnE,IAAI,EAAE,UAAU,CAAC,kDAAyC,CAAC,IAAI,CAAC,IAAI,EAAE;QACtE,QAAQ,EACJ,UAAU,CAAC,kDAAyC,CAAC,SAAS,CAAC;YAC/D,IAAI;QACR,MAAM,EACF,UAAU,CAAC,kDAAyC,CAAC,MAAM,CAAC,IAAI,EAAE;KACzE,CAAC;IAEF,OAAO,6BAA6B,CAAC;AACzC,CAAC,CAAC;AAzBW,QAAA,qCAAqC,yCAyBhD;AAEF;;;;;;;;GAQG;AACI,MAAM,kDAAkD,GAAG,CAC9D,IAAY,EACZ,QAA4B,EAC5B,UAA+C,EACzC,EAAE;IACR,IAAI,CAAC,IAAI,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAE,CAAA,IAAI,CAAC,QAAQ,EAAE;QACrC,MAAM,IAAI,KAAK,CACX,0DAA0D,CAC7D,CAAC;KACL;IAED,+IAA+I;IAC/I,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAEhC,MAAM,KAAK,GAAG;QACV,IAAI,kDAAyC,CAAC,IAAI,OAAO,IAAI,IAAI;QACjE,IAAI,kDAAyC,CAAC,QAAQ,OAAO,QAAQ,IAAI;KAC5E,CAAC;IAEF,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,EAAE;QACpB,KAAK,CAAC,IAAI,CACN,IACI,kDAAyC,CAAC,SAC9C,SAAS,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CACvC,CAAC;KACL;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC,CAAC;AA5BW,QAAA,kDAAkD,sDA4B7D"}
@@ -0,0 +1,4 @@
1
+ import { addReviewResults2FeatureTable, getPackagedReviewResults, getReviewedReviewResults, getUnarchivedReviewResults, getDeployedReviewResults, getReviewResultsByTermAndCategory, CustomTermReviewResultFeature, updateReviewResultsInFeatureTable, getCustomTermsReviewResultsFeatureTableItemInfo } from './customTermsReviewResults';
2
+ export { addReviewResults2FeatureTable, updateReviewResultsInFeatureTable, getPackagedReviewResults, getReviewedReviewResults, getUnarchivedReviewResults, getDeployedReviewResults, getReviewResultsByTermAndCategory, getCustomTermsReviewResultsFeatureTableItemInfo, };
3
+ import { CustomTermsReviewResultLifecycle } from './config';
4
+ export type { CustomTermsReviewResultLifecycle, CustomTermReviewResultFeature };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCustomTermsReviewResultsFeatureTableItemInfo = exports.getReviewResultsByTermAndCategory = exports.getDeployedReviewResults = exports.getUnarchivedReviewResults = exports.getReviewedReviewResults = exports.getPackagedReviewResults = exports.updateReviewResultsInFeatureTable = exports.addReviewResults2FeatureTable = void 0;
4
+ const customTermsReviewResults_1 = require("./customTermsReviewResults");
5
+ Object.defineProperty(exports, "addReviewResults2FeatureTable", { enumerable: true, get: function () { return customTermsReviewResults_1.addReviewResults2FeatureTable; } });
6
+ Object.defineProperty(exports, "getPackagedReviewResults", { enumerable: true, get: function () { return customTermsReviewResults_1.getPackagedReviewResults; } });
7
+ Object.defineProperty(exports, "getReviewedReviewResults", { enumerable: true, get: function () { return customTermsReviewResults_1.getReviewedReviewResults; } });
8
+ Object.defineProperty(exports, "getUnarchivedReviewResults", { enumerable: true, get: function () { return customTermsReviewResults_1.getUnarchivedReviewResults; } });
9
+ Object.defineProperty(exports, "getDeployedReviewResults", { enumerable: true, get: function () { return customTermsReviewResults_1.getDeployedReviewResults; } });
10
+ Object.defineProperty(exports, "getReviewResultsByTermAndCategory", { enumerable: true, get: function () { return customTermsReviewResults_1.getReviewResultsByTermAndCategory; } });
11
+ Object.defineProperty(exports, "updateReviewResultsInFeatureTable", { enumerable: true, get: function () { return customTermsReviewResults_1.updateReviewResultsInFeatureTable; } });
12
+ Object.defineProperty(exports, "getCustomTermsReviewResultsFeatureTableItemInfo", { enumerable: true, get: function () { return customTermsReviewResults_1.getCustomTermsReviewResultsFeatureTableItemInfo; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/custom-terms-review-results/index.ts"],"names":[],"mappings":";;;AAAA,yEAUoC;AAGhC,8GAZA,wDAA6B,OAYA;AAE7B,yGAbA,mDAAwB,OAaA;AACxB,yGAbA,mDAAwB,OAaA;AACxB,2GAbA,qDAA0B,OAaA;AAC1B,yGAbA,mDAAwB,OAaA;AACxB,kHAbA,4DAAiC,OAaA;AALjC,kHANA,4DAAiC,OAMA;AAMjC,gIAXA,0EAA+C,OAWA"}
@@ -0,0 +1,28 @@
1
+ export type AddFeaturesResponse = {
2
+ objectId: number;
3
+ success: boolean;
4
+ error?: {
5
+ code: string;
6
+ description: string;
7
+ };
8
+ };
9
+ /**
10
+ * Adds features to a feature table.
11
+ *
12
+ * @param {Object} params - The parameters for adding features.
13
+ * @param {string} params.token - The authentication token.
14
+ * @param {Array<Object>} params.features - The features to add.
15
+ * @param {Object} params.features[].attributes - The attributes of the feature.
16
+ * @param {string} params.featureTableUrl - The URL of the feature table.
17
+ * @returns {Promise<AddCustomTermFeatureResponse[]>} A promise that resolves to an array of add feature responses.
18
+ * @throws Will throw an error if the request fails or if any feature addition is unsuccessful.
19
+ */
20
+ export declare const addFeatures: ({ token, features, featureTableUrl, }: {
21
+ token: string;
22
+ features: {
23
+ attributes: {
24
+ [key: string]: any;
25
+ };
26
+ }[];
27
+ featureTableUrl: string;
28
+ }) => Promise<AddFeaturesResponse[]>;
@@ -0,0 +1,52 @@
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.addFeatures = void 0;
13
+ /**
14
+ * Adds features to a feature table.
15
+ *
16
+ * @param {Object} params - The parameters for adding features.
17
+ * @param {string} params.token - The authentication token.
18
+ * @param {Array<Object>} params.features - The features to add.
19
+ * @param {Object} params.features[].attributes - The attributes of the feature.
20
+ * @param {string} params.featureTableUrl - The URL of the feature table.
21
+ * @returns {Promise<AddCustomTermFeatureResponse[]>} A promise that resolves to an array of add feature responses.
22
+ * @throws Will throw an error if the request fails or if any feature addition is unsuccessful.
23
+ */
24
+ const addFeatures = ({ token, features, featureTableUrl, }) => __awaiter(void 0, void 0, void 0, function* () {
25
+ var _a, _b;
26
+ const requestURL = `${featureTableUrl}/addFeatures`;
27
+ const res = yield fetch(requestURL, {
28
+ method: 'POST',
29
+ body: new URLSearchParams({
30
+ f: 'json',
31
+ token,
32
+ rollbackOnFailure: 'true',
33
+ features: JSON.stringify(features),
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) || 'Failed to add custom terms.');
39
+ }
40
+ const addResults = responseBody === null || responseBody === void 0 ? void 0 : responseBody.addResults;
41
+ if (!addResults) {
42
+ return [];
43
+ }
44
+ for (const res of addResults) {
45
+ if ((res === null || res === void 0 ? void 0 : res.success) !== true) {
46
+ throw new Error(((_b = res === null || res === void 0 ? void 0 : res.error) === null || _b === void 0 ? void 0 : _b.description) || 'Failed to add custom terms.');
47
+ }
48
+ }
49
+ return addResults;
50
+ });
51
+ exports.addFeatures = addFeatures;
52
+ //# sourceMappingURL=addFeatures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addFeatures.js","sourceRoot":"","sources":["../../../src/services/shared/addFeatures.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA;;;;;;;;;;GAUG;AACI,MAAM,WAAW,GAAG,CAAO,EAC9B,KAAK,EACL,QAAQ,EACR,eAAe,GASlB,EAAkC,EAAE;;IACjC,MAAM,UAAU,GAAG,GAAG,eAAe,cAAc,CAAC;IAEpD,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,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;SACrC,CAAC;KACL,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAEtC,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,KAAI,6BAA6B,CAChE,CAAC;KACL;IAED,MAAM,UAAU,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,UAAmC,CAAC;IAErE,IAAI,CAAC,UAAU,EAAE;QACb,OAAO,EAAE,CAAC;KACb;IAED,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE;QAC1B,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,6BAA6B,CAC3D,CAAC;SACL;KACJ;IAED,OAAO,UAAmC,CAAC;AAC/C,CAAC,CAAA,CAAC;AAhDW,QAAA,WAAW,eAgDtB"}
@@ -0,0 +1,28 @@
1
+ export type ApplyEditsResult = {
2
+ objectId: number;
3
+ success: boolean;
4
+ error?: {
5
+ code: string;
6
+ description: string;
7
+ };
8
+ };
9
+ /**
10
+ * Updates features in a feature table using the provided token and updates.
11
+ *
12
+ * @param {Object} params - The parameters for the update operation.
13
+ * @param {string} params.token - The authentication token.
14
+ * @param {Object[]} params.updates - The array of update objects containing attributes to be updated.
15
+ * @param {Object} params.updates[].attributes - The attributes to be updated for each feature.
16
+ * @param {string} params.featureTableUrl - The URL of the feature table to update.
17
+ * @returns {Promise<ApplyEditsResult[]>} - A promise that resolves to an array of ApplyEditsResult objects.
18
+ * @throws {Error} - Throws an error if the update operation fails.
19
+ */
20
+ export declare const updateFeatures: ({ token, updates, featureTableUrl, }: {
21
+ token: string;
22
+ updates: {
23
+ attributes: {
24
+ [key: string]: any;
25
+ };
26
+ }[];
27
+ featureTableUrl: string;
28
+ }) => Promise<ApplyEditsResult[]>;