@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,394 @@
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.getCustomTermsFeatureTableItemInfo = exports.updateStatusOfCustomTermsInFeatureTable = exports.addCustomTerms2FeatureTable = exports.getCountOfMyCustomTerms = exports.getMyCustomTerms = exports.getSubmittedCustomTerms = exports.getCountOfCustomTerms = exports.getCustomTerms = void 0;
13
+ const addFeatures_1 = require("../shared/addFeatures");
14
+ const applyEdits_1 = require("../shared/applyEdits");
15
+ const getItemInfo_1 = require("../shared/getItemInfo");
16
+ const config_1 = require("./config");
17
+ const helpers_1 = require("./helpers");
18
+ /**
19
+ * Fetches custom terms from the Custom Terms Feature Table based on the provided options.
20
+ *
21
+ * @param {Object} options - The options for fetching custom terms.
22
+ * @param {string} options.token - The authentication token.
23
+ * @param {string[]} [options.status] - The status filter for the custom terms.
24
+ * @param {string[]} options.userIds - The user IDs to filter the custom terms by creator.
25
+ * @param {string[]} [options.fields] - The fields to include in the response.
26
+ *
27
+ * @returns {Promise<CustomTermFeature[]>} A promise that resolves to an array of custom term features.
28
+ *
29
+ * @throws Will throw an error if the response contains an error.
30
+ */
31
+ const getCustomTerms = ({ token, status, userIds, fields, maxNumOfRecords, resultOffset = 0, }) => __awaiter(void 0, void 0, void 0, function* () {
32
+ var _a;
33
+ if (!token) {
34
+ throw new Error('Token is required');
35
+ }
36
+ const CustomTermsFeatureTableUrl = (0, config_1.getCustomTermsFeatureTableUrl)();
37
+ const requestURL = `${CustomTermsFeatureTableUrl}/query`;
38
+ // const whereClause = [
39
+ // `(${CustomTermsFeatureTableField.TERM} IS NOT NULL)`,
40
+ // `(${CustomTermsFeatureTableField.TERM} <> '')`,
41
+ // ];
42
+ // if (userIds && userIds.length > 0) {
43
+ // whereClause.push(
44
+ // `(${CustomTermsFeatureTableField.CREATOR} IN ('${userIds.join(
45
+ // "','"
46
+ // )}'))`
47
+ // );
48
+ // }
49
+ // if (status && status.length > 0) {
50
+ // whereClause.push(
51
+ // `(${CustomTermsFeatureTableField.STATUS} IN ('${status.join(
52
+ // "','"
53
+ // )}'))`
54
+ // );
55
+ // }
56
+ const where = (0, helpers_1.getWhereClause)(userIds, status);
57
+ const outFields = fields && fields.length > 1 ? fields.join(',') : '*';
58
+ const orderByFields = `${config_1.CustomTermsFeatureTableField.EDIT_DATE} desc`;
59
+ const maxRecorsPerRequest = 1000; // Maximum records per request
60
+ // determine the number of records to return
61
+ // if maxNumOfRecords is set, use it, otherwise use maxRecorsPerRequest
62
+ // this is to avoid fetching more records than needed
63
+ const resultRecordCount = Math.min(maxRecorsPerRequest, maxNumOfRecords || maxRecorsPerRequest);
64
+ const allFeatures = [];
65
+ // let resultOffset = 0;
66
+ let exceededTransferLimit = true;
67
+ while (exceededTransferLimit && allFeatures.length < 10000) {
68
+ const queryParams = new URLSearchParams({
69
+ f: 'json',
70
+ token,
71
+ where,
72
+ orderByFields,
73
+ outFields,
74
+ resultRecordCount: resultRecordCount.toString(),
75
+ resultOffset: resultOffset.toString(),
76
+ });
77
+ const res = yield fetch(`${requestURL}?${queryParams.toString()}`);
78
+ const responseBody = yield res.json();
79
+ if (responseBody === null || responseBody === void 0 ? void 0 : responseBody.error) {
80
+ // console.log('Error response:', responseBody);
81
+ throw new Error(((_a = responseBody === null || responseBody === void 0 ? void 0 : responseBody.error) === null || _a === void 0 ? void 0 : _a.message) || 'Failed to fetch custom terms.');
82
+ }
83
+ const features = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.features) || [];
84
+ // if (!features || features.length === 0) {
85
+ // return [];
86
+ // }
87
+ for (const feature of features) {
88
+ if (!(feature === null || feature === void 0 ? void 0 : feature.attributes)) {
89
+ throw new Error('Feature attributes are missing');
90
+ }
91
+ const attributes = (feature === null || feature === void 0 ? void 0 : feature.attributes) || {};
92
+ const customTermFeature = {
93
+ objectId: attributes[config_1.CustomTermsFeatureTableField.OBJECT_ID],
94
+ term: attributes[config_1.CustomTermsFeatureTableField.TERM],
95
+ category: attributes[config_1.CustomTermsFeatureTableField.CATEGORY],
96
+ status: attributes[config_1.CustomTermsFeatureTableField.STATUS],
97
+ creator: attributes[config_1.CustomTermsFeatureTableField.CREATOR],
98
+ creationDate: attributes[config_1.CustomTermsFeatureTableField.CREATION_DATE],
99
+ modifiedDate: attributes[config_1.CustomTermsFeatureTableField.EDIT_DATE],
100
+ editor: attributes[config_1.CustomTermsFeatureTableField.EDITOR],
101
+ title: attributes[config_1.CustomTermsFeatureTableField.TITLE] || '',
102
+ snippet: attributes[config_1.CustomTermsFeatureTableField.SNIPPET] || '',
103
+ itemId: attributes[config_1.CustomTermsFeatureTableField.ITEM_ID] || '',
104
+ note: attributes[config_1.CustomTermsFeatureTableField.NOTE] || '',
105
+ };
106
+ allFeatures.push(customTermFeature);
107
+ }
108
+ // if the maxNumOfRecords is set and the number of features is greater than or equal to the maxNumOfRecords, break the loop
109
+ // this is to avoid fetching more records than needed
110
+ if (maxNumOfRecords && allFeatures.length >= maxNumOfRecords) {
111
+ break;
112
+ }
113
+ exceededTransferLimit = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.exceededTransferLimit) === true;
114
+ resultOffset += resultRecordCount; // Move to the next batch
115
+ }
116
+ return allFeatures;
117
+ });
118
+ exports.getCustomTerms = getCustomTerms;
119
+ /**
120
+ * Retrieves the count of custom terms based on the provided criteria.
121
+ *
122
+ * @param {Object} params - The parameters for the request.
123
+ * @param {string} params.token - The authentication token.
124
+ * @param {CustomTermStatus[]} [params.status] - Optional array of custom term statuses to filter by.
125
+ * @param {string[]} params.userIds - Array of user IDs to filter by.
126
+ *
127
+ * @returns {Promise<number>} - A promise that resolves to the count of custom terms.
128
+ */
129
+ const getCountOfCustomTerms = ({ token, status, userIds, }) => __awaiter(void 0, void 0, void 0, function* () {
130
+ var _b;
131
+ const CustomTermsFeatureTableUrl = (0, config_1.getCustomTermsFeatureTableUrl)();
132
+ const requestURL = `${CustomTermsFeatureTableUrl}/query`;
133
+ if (!token) {
134
+ throw new Error('Token is required');
135
+ }
136
+ const where = (0, helpers_1.getWhereClause)(userIds, status);
137
+ const queryParams = new URLSearchParams({
138
+ f: 'json',
139
+ token,
140
+ where,
141
+ returnCountOnly: 'true',
142
+ outFields: '*',
143
+ resultRecordCount: '0',
144
+ resultOffset: '0',
145
+ });
146
+ const res = yield fetch(`${requestURL}?${queryParams.toString()}`);
147
+ const responseBody = yield res.json();
148
+ if (responseBody === null || responseBody === void 0 ? void 0 : responseBody.error) {
149
+ // console.log('Error response:', responseBody);
150
+ throw new Error(((_b = responseBody === null || responseBody === void 0 ? void 0 : responseBody.error) === null || _b === void 0 ? void 0 : _b.message) ||
151
+ 'Failed to fetch count of custom terms.');
152
+ }
153
+ const count = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.count) || 0;
154
+ return count;
155
+ });
156
+ exports.getCountOfCustomTerms = getCountOfCustomTerms;
157
+ /**
158
+ * Retrieves the custom terms that have been submitted by users for review.
159
+ * The custom terms have a status of 'submitted' meaning they are **pending review** by the Living Atlas team.
160
+ *
161
+ * @param {Object} params - The parameters for retrieving submitted custom terms.
162
+ * @param {string[]} [params.userIds] - Optional array of user IDs to filter the custom terms.
163
+ * @param {boolean} [params.shouldIncludeAllFields=false] - Flag indicating whether to include all fields in the response.
164
+ * @param {string} params.token - The authentication token required to access the custom terms.
165
+ * @returns {Promise<CustomTermFeature[]>} A promise that resolves to an array of submitted custom term features.
166
+ */
167
+ const getSubmittedCustomTerms = ({ userIds, shouldIncludeAllFields = false, token, }) => __awaiter(void 0, void 0, void 0, function* () {
168
+ const fields = shouldIncludeAllFields === false
169
+ ? [
170
+ config_1.CustomTermsFeatureTableField.OBJECT_ID,
171
+ config_1.CustomTermsFeatureTableField.CATEGORY,
172
+ config_1.CustomTermsFeatureTableField.TERM,
173
+ config_1.CustomTermsFeatureTableField.STATUS,
174
+ config_1.CustomTermsFeatureTableField.CREATOR,
175
+ config_1.CustomTermsFeatureTableField.CREATION_DATE,
176
+ config_1.CustomTermsFeatureTableField.EDIT_DATE,
177
+ config_1.CustomTermsFeatureTableField.EDITOR,
178
+ ]
179
+ : undefined;
180
+ const customTerms = yield (0, exports.getCustomTerms)({
181
+ token,
182
+ userIds,
183
+ status: ['submitted'],
184
+ fields,
185
+ });
186
+ return customTerms;
187
+ });
188
+ exports.getSubmittedCustomTerms = getSubmittedCustomTerms;
189
+ /**
190
+ * Get custom terms that are added by the signed-in user.
191
+ *
192
+ * @param userId id of the user
193
+ * @param token authentication token
194
+ * @returns Promise<CustomTermFeature[]> array of custom term features that are added by the signed-in user.
195
+ */
196
+ const getMyCustomTerms = ({ userId, token, maxNumOfRecords, resultOffset, }) => __awaiter(void 0, void 0, void 0, function* () {
197
+ const customTerms = yield (0, exports.getCustomTerms)({
198
+ userIds: [userId],
199
+ fields: [
200
+ config_1.CustomTermsFeatureTableField.OBJECT_ID,
201
+ config_1.CustomTermsFeatureTableField.CATEGORY,
202
+ config_1.CustomTermsFeatureTableField.TERM,
203
+ config_1.CustomTermsFeatureTableField.STATUS,
204
+ config_1.CustomTermsFeatureTableField.CREATOR,
205
+ config_1.CustomTermsFeatureTableField.NOTE,
206
+ config_1.CustomTermsFeatureTableField.CREATION_DATE,
207
+ config_1.CustomTermsFeatureTableField.EDIT_DATE,
208
+ config_1.CustomTermsFeatureTableField.EDITOR,
209
+ ],
210
+ token,
211
+ maxNumOfRecords,
212
+ resultOffset,
213
+ });
214
+ return customTerms;
215
+ });
216
+ exports.getMyCustomTerms = getMyCustomTerms;
217
+ /**
218
+ * Get the count of custom terms that are added by the signed-in user.
219
+ *
220
+ * @param userId id of the user
221
+ * @param token authentication token
222
+ * @returns Promise<number> count of custom terms that are added by the signed-in user.
223
+ */
224
+ const getCountOfMyCustomTerms = (userId, token) => __awaiter(void 0, void 0, void 0, function* () {
225
+ const count = yield (0, exports.getCountOfCustomTerms)({
226
+ userIds: [userId],
227
+ token,
228
+ });
229
+ return count;
230
+ });
231
+ exports.getCountOfMyCustomTerms = getCountOfMyCustomTerms;
232
+ /**
233
+ * Add custom term to the feature table for the Living Atlas team to review
234
+ *
235
+ * @param customTermFeature - The custom term feature to be added.
236
+ * @param token - The authentication token.
237
+ * @returns A promise that resolves to an array of `AddCustomTermFeatureResponse` objects.
238
+ *
239
+ * @remark
240
+ * Here is an example of a failed request with `rollbackOnFailure`. This is caused by the second feature containing invalid data for the `item_id` field.
241
+ *
242
+ * ```
243
+ * {
244
+ * "addResults" : [
245
+ * {
246
+ * "objectId" : 1010,
247
+ * "uniqueId" : 1010,
248
+ * "globalId" : "1F68",
249
+ * "success" : false,
250
+ * "error" : {
251
+ * "code" : 1003,
252
+ * "description" : "Operation rolled back."
253
+ * }
254
+ * },
255
+ * {
256
+ * "objectId" : -1,
257
+ * "uniqueId" : -1,
258
+ * "globalId" : "AE186",
259
+ * "success" : false,
260
+ * "error" : {
261
+ * "code" : 1000,
262
+ * "description" : "String or binary data would be truncated.\r\nThe statement has been terminated."
263
+ * }
264
+ * }
265
+ * ]
266
+ * }
267
+ * ```
268
+ */
269
+ const addCustomTerms2FeatureTable = (data, token) => __awaiter(void 0, void 0, void 0, function* () {
270
+ // const requestURL = `${CustomTermsFeatureTableUrl}/addFeatures`;
271
+ var _c;
272
+ const CustomTermsFeatureTableUrl = (0, config_1.getCustomTermsFeatureTableUrl)();
273
+ if (!token) {
274
+ throw new Error('Token is required');
275
+ }
276
+ for (const d of data) {
277
+ const term = ((_c = d === null || d === void 0 ? void 0 : d.term) === null || _c === void 0 ? void 0 : _c.trim()) || '';
278
+ if (!term || !d.category || !d.title || !d.snippet || !d.itemId) {
279
+ throw new Error(`Missing required fields: ${JSON.stringify(d)}`);
280
+ }
281
+ }
282
+ // status of the term that is added to the feature table
283
+ // all terms that have not been reviewed by the Living Atlas team will have a status of `submitted`
284
+ // once the term is approved or rejected, the status will be updated accordingly
285
+ const status = 'submitted';
286
+ const features = data.map((d) => {
287
+ // // Convert the term to lowercase to ensure consistency.
288
+ // // When the Living Atlas team reviews the term, all terms with different cases will be treated as the same term.
289
+ // // For example, "Climate Change" and "climate change" will be treated as the same term.
290
+ // // Converting to lowercase helps to synchronize the reviewed results back to the feature table.
291
+ // const termLowerCase = d.term.toLowerCase();
292
+ return {
293
+ attributes: {
294
+ [config_1.CustomTermsFeatureTableField.TERM]: d.term,
295
+ [config_1.CustomTermsFeatureTableField.CATEGORY]: d.category,
296
+ [config_1.CustomTermsFeatureTableField.STATUS]: status,
297
+ [config_1.CustomTermsFeatureTableField.TITLE]: d.title,
298
+ [config_1.CustomTermsFeatureTableField.SNIPPET]: d.snippet,
299
+ [config_1.CustomTermsFeatureTableField.ITEM_ID]: d.itemId,
300
+ },
301
+ };
302
+ });
303
+ const res = yield (0, addFeatures_1.addFeatures)({
304
+ token,
305
+ features,
306
+ featureTableUrl: CustomTermsFeatureTableUrl,
307
+ });
308
+ return res;
309
+ // const res = await fetch(requestURL, {
310
+ // method: 'POST',
311
+ // body: new URLSearchParams({
312
+ // f: 'json',
313
+ // token,
314
+ // rollbackOnFailure: 'true',
315
+ // features: JSON.stringify(features),
316
+ // }),
317
+ // });
318
+ // const responseBody = await res.json();
319
+ // if (responseBody?.error) {
320
+ // throw responseBody?.error;
321
+ // }
322
+ // const addResults =
323
+ // responseBody?.addResults as AddCustomTermFeatureResponse[];
324
+ // if (!addResults) {
325
+ // return [];
326
+ // }
327
+ // for (const res of addResults) {
328
+ // if (res?.success !== true) {
329
+ // throw new Error(
330
+ // res?.error?.description || 'Failed to add custom terms.'
331
+ // );
332
+ // }
333
+ // }
334
+ // return addResults as AddCustomTermFeatureResponse[];
335
+ });
336
+ exports.addCustomTerms2FeatureTable = addCustomTerms2FeatureTable;
337
+ /**
338
+ * Updates the status of custom terms in the feature table.
339
+ *
340
+ * @param token - The authentication token required for the operation
341
+ * @param data - An array of objects containing:
342
+ * - objectId: The unique identifier of the custom term
343
+ * - status: The decision made by the Living Atlas team about the term
344
+ * - note: A comment/note left by the Living Atlas team
345
+ *
346
+ * @throws {Error} If token is missing, required fields are not provided, or other operation errors occur
347
+ * @returns A promise that resolves to an array of ApplyEditsResult objects
348
+ */
349
+ const updateStatusOfCustomTermsInFeatureTable = (token, data) => __awaiter(void 0, void 0, void 0, function* () {
350
+ if (!token) {
351
+ throw new Error('Token is required');
352
+ }
353
+ if (!data || data.length === 0) {
354
+ console.warn('No data to update');
355
+ return [];
356
+ }
357
+ const CustomTermsFeatureTableUrl = (0, config_1.getCustomTermsFeatureTableUrl)();
358
+ for (const d of data) {
359
+ if (!d.status || !d.note) {
360
+ throw new Error(`Missing required fields: ${JSON.stringify(d)}`);
361
+ }
362
+ }
363
+ const features = data.map((d) => {
364
+ return {
365
+ attributes: {
366
+ [config_1.CustomTermsFeatureTableField.OBJECT_ID]: d.objectId,
367
+ [config_1.CustomTermsFeatureTableField.STATUS]: d.status,
368
+ [config_1.CustomTermsFeatureTableField.NOTE]: d.note,
369
+ },
370
+ };
371
+ });
372
+ const res = yield (0, applyEdits_1.updateFeatures)({
373
+ token,
374
+ updates: features,
375
+ featureTableUrl: CustomTermsFeatureTableUrl,
376
+ });
377
+ return res;
378
+ });
379
+ exports.updateStatusOfCustomTermsInFeatureTable = updateStatusOfCustomTermsInFeatureTable;
380
+ /**
381
+ * Get the item info for the Custom Terms feature table.
382
+ * @param token - The authentication token required to access the item info.
383
+ * @returns A promise that resolves to an `ItemInfoResponse` object containing metadata about the feature table.
384
+ */
385
+ const getCustomTermsFeatureTableItemInfo = (token) => __awaiter(void 0, void 0, void 0, function* () {
386
+ const itemInfoUrl = (0, config_1.getCustomTermsFeatureTableItemInfoUrl)();
387
+ if (!token) {
388
+ throw new Error('Token is required');
389
+ }
390
+ const res = yield (0, getItemInfo_1.getFeatureLayerItemInfo)(itemInfoUrl, token);
391
+ return res;
392
+ });
393
+ exports.getCustomTermsFeatureTableItemInfo = getCustomTermsFeatureTableItemInfo;
394
+ //# sourceMappingURL=customTerms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customTerms.js","sourceRoot":"","sources":["../../../src/services/custom-terms/customTerms.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAyE;AACzE,qDAAwE;AAExE,uDAG+B;AAC/B,qCAMkB;AAClB,uCAA2C;AA6F3C;;;;;;;;;;;;GAYG;AACI,MAAM,cAAc,GAAG,CAAO,EACjC,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,eAAe,EACf,YAAY,GAAG,CAAC,GACI,EAAgC,EAAE;;IACtD,IAAI,CAAC,KAAK,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;KACxC;IAED,MAAM,0BAA0B,GAAG,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AAC,CAAC;IAEH,MAAM,GAAG,GAAG,MAAM,IAAA,2BAAc,EAAC;QAC7B,KAAK;QACL,OAAO,EAAE,QAAQ;QACjB,eAAe,EAAE,0BAA0B;KAC9C,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACf,CAAC,CAAA,CAAC;AAhDW,QAAA,uCAAuC,2CAgDlD;AAEF;;;;GAIG;AACI,MAAM,kCAAkC,GAAG,CAC9C,KAAa,EACY,EAAE;IAC3B,MAAM,WAAW,GAAG,IAAA,8CAAqC,GAAE,CAAC;IAE5D,IAAI,CAAC,KAAK,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;KACxC;IAED,MAAM,GAAG,GAAG,MAAM,IAAA,qCAAuB,EAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC9D,OAAO,GAAG,CAAC;AACf,CAAC,CAAA,CAAC;AAXW,QAAA,kCAAkC,sCAW7C"}
@@ -0,0 +1,8 @@
1
+ import { CustomTermStatus } from '../shared/config';
2
+ /**
3
+ * Get the where clause to be used to query cumstom terms
4
+ * @param userIds array of user ids
5
+ * @param status array of status
6
+ * @returns the where clause to be used to query cumstom terms
7
+ */
8
+ export declare const getWhereClause: (userIds: string[], status: CustomTermStatus[]) => string;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWhereClause = void 0;
4
+ const config_1 = require("./config");
5
+ /**
6
+ * Get the where clause to be used to query cumstom terms
7
+ * @param userIds array of user ids
8
+ * @param status array of status
9
+ * @returns the where clause to be used to query cumstom terms
10
+ */
11
+ const getWhereClause = (userIds, status) => {
12
+ const whereClause = [
13
+ `(${config_1.CustomTermsFeatureTableField.TERM} IS NOT NULL)`,
14
+ `(${config_1.CustomTermsFeatureTableField.TERM} <> '')`,
15
+ ];
16
+ if (userIds && userIds.length > 0) {
17
+ whereClause.push(`(${config_1.CustomTermsFeatureTableField.CREATOR} IN ('${userIds.join("','")}'))`);
18
+ }
19
+ if (status && status.length > 0) {
20
+ whereClause.push(`(${config_1.CustomTermsFeatureTableField.STATUS} IN ('${status.join("','")}'))`);
21
+ }
22
+ return whereClause.join(' AND ');
23
+ };
24
+ exports.getWhereClause = getWhereClause;
25
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/services/custom-terms/helpers.ts"],"names":[],"mappings":";;;AAAA,qCAAwD;AAGxD;;;;;GAKG;AACI,MAAM,cAAc,GAAG,CAC1B,OAAiB,EACjB,MAA0B,EACpB,EAAE;IACR,MAAM,WAAW,GAAG;QAChB,IAAI,qCAA4B,CAAC,IAAI,eAAe;QACpD,IAAI,qCAA4B,CAAC,IAAI,SAAS;KACjD,CAAC;IAEF,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QAC/B,WAAW,CAAC,IAAI,CACZ,IAAI,qCAA4B,CAAC,OAAO,SAAS,OAAO,CAAC,IAAI,CACzD,KAAK,CACR,KAAK,CACT,CAAC;KACL;IAED,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7B,WAAW,CAAC,IAAI,CACZ,IAAI,qCAA4B,CAAC,MAAM,SAAS,MAAM,CAAC,IAAI,CACvD,KAAK,CACR,KAAK,CACT,CAAC;KACL;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAC;AA1BW,QAAA,cAAc,kBA0BzB"}
@@ -0,0 +1,3 @@
1
+ import { CustomTermFeature, getSubmittedCustomTerms, getMyCustomTerms, addCustomTerms2FeatureTable, updateStatusOfCustomTermsInFeatureTable, getCustomTermsFeatureTableItemInfo } from './customTerms';
2
+ export type { CustomTermFeature };
3
+ export { getSubmittedCustomTerms, getMyCustomTerms, addCustomTerms2FeatureTable, updateStatusOfCustomTermsInFeatureTable, getCustomTermsFeatureTableItemInfo, };
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCustomTermsFeatureTableItemInfo = exports.updateStatusOfCustomTermsInFeatureTable = exports.addCustomTerms2FeatureTable = exports.getMyCustomTerms = exports.getSubmittedCustomTerms = void 0;
4
+ const customTerms_1 = require("./customTerms");
5
+ Object.defineProperty(exports, "getSubmittedCustomTerms", { enumerable: true, get: function () { return customTerms_1.getSubmittedCustomTerms; } });
6
+ Object.defineProperty(exports, "getMyCustomTerms", { enumerable: true, get: function () { return customTerms_1.getMyCustomTerms; } });
7
+ Object.defineProperty(exports, "addCustomTerms2FeatureTable", { enumerable: true, get: function () { return customTerms_1.addCustomTerms2FeatureTable; } });
8
+ Object.defineProperty(exports, "updateStatusOfCustomTermsInFeatureTable", { enumerable: true, get: function () { return customTerms_1.updateStatusOfCustomTermsInFeatureTable; } });
9
+ Object.defineProperty(exports, "getCustomTermsFeatureTableItemInfo", { enumerable: true, get: function () { return customTerms_1.getCustomTermsFeatureTableItemInfo; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/custom-terms/index.ts"],"names":[],"mappings":";;;AAAA,+CAOuB;AAKnB,wGAVA,qCAAuB,OAUA;AACvB,iGAVA,8BAAgB,OAUA;AAChB,4GAVA,yCAA2B,OAUA;AAC3B,wHAVA,qDAAuC,OAUA;AACvC,mHAVA,gDAAkC,OAUA"}
@@ -0,0 +1,31 @@
1
+ export declare enum CustomTermsReviewResultsFeatureTableField {
2
+ OBJECT_ID = "OBJECTID",
3
+ TERM = "term",
4
+ CATEGORY = "category",
5
+ STATUS = "status",
6
+ LIFECYCLE = "lifecycle",
7
+ NOTE = "note",
8
+ CREATION_DATE = "CreationDate",
9
+ CREATOR = "Creator",
10
+ EDIT_DATE = "EditDate",
11
+ EDITOR = "Editor"
12
+ }
13
+ /**
14
+ * Lifecycle status of a custom term review result.
15
+ *
16
+ * - `reviewed`: The term has been reviewed but has not been packaged or deployed yet.
17
+ * - `packaged`: The term has been packaged but has not been deployed yet.
18
+ * - `deployed`: The term has been deployed but has not been archived yet.
19
+ * - `archived`: The review result has been synced back to the custom-terms table and this term has been archived.
20
+ */
21
+ export type CustomTermsReviewResultLifecycle = 'reviewed' | 'packaged' | 'deployed' | 'archived';
22
+ /**
23
+ * Gets the URL for the Custom Terms Review Results feature table based on the current service tier.
24
+ * @returns the URL for the Custom Terms Review Results feature table based on the current service tier.
25
+ */
26
+ export declare const getCustomTermsReviewResultsFeatureTableUrl: () => string;
27
+ /**
28
+ * Gets the URL for the itemInfo endpoint for the Custom Terms Review Results feature table based on the current service tier.
29
+ * @returns The URL for the itemInfo endpoint for the Custom Terms Review Results feature table.
30
+ */
31
+ export declare const getCustomTermsReviewResultsFeatureTableItemInfoUrl: () => string;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCustomTermsReviewResultsFeatureTableItemInfoUrl = exports.getCustomTermsReviewResultsFeatureTableUrl = exports.CustomTermsReviewResultsFeatureTableField = void 0;
4
+ const config_1 = require("../shared/config");
5
+ /**
6
+ * The root URL for the Custom Terms Review Results feature table in the development environment.
7
+ * @see
8
+ * https://servicesdev.arcgis.com/VLx4vrvwONglS8iz/ArcGIS/rest/services/Custom_Terms_Review_Results/FeatureServer
9
+ */
10
+ const CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_ROOT_DEV = 'https://servicesdev.arcgis.com/VLx4vrvwONglS8iz/ArcGIS/rest/services/Custom_Terms_Review_Results/FeatureServer';
11
+ /**
12
+ * The URL for the Custom Terms Review Results feature table in the development environment.
13
+ * @see
14
+ * https://servicesdev.arcgis.com/VLx4vrvwONglS8iz/ArcGIS/rest/services/Custom_Terms_Review_Results/FeatureServer/0
15
+ */
16
+ const CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_URL_DEV = CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_ROOT_DEV + '/0';
17
+ /**
18
+ * The URL for the itemInfo endpoint for the Custom Terms Review Results feature table in the development environment.
19
+ * @see
20
+ * https://servicesdev.arcgis.com/VLx4vrvwONglS8iz/ArcGIS/rest/services/Custom_Terms_Review_Results/FeatureServer/info/itemInfo
21
+ */
22
+ const CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_ITEMINFO_DEV = CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_ROOT_DEV + '/info/itemInfo';
23
+ /**
24
+ * The root URL for the Custom Terms Review Results feature table in the production environment.
25
+ * @see
26
+ * https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/Custom_Terms_Review_Results/FeatureServer
27
+ */
28
+ const CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_ROOT_PROD = 'https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/Custom_Terms_Review_Results/FeatureServer';
29
+ /**
30
+ * The URL for the Custom Terms Review Results feature table in the production environment.
31
+ * @see
32
+ * https://services.arcgis.com/jIL9msH9OI208GCb/ArcGIS/rest/services/Custom_Terms_Review_Results/FeatureServer/0
33
+ */
34
+ const CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_URL_PROD = CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_ROOT_PROD + '/0';
35
+ /**
36
+ * The URL for the itemInfo endpoint for the Custom Terms Review Results feature table in the production environment.
37
+ * @see
38
+ * https://services.arcgis.com/jIL9msH9OI208GCb/ArcGIS/rest/services/Custom_Terms_Review_Results/FeatureServer/info/itemInfo
39
+ */
40
+ const CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_ITEMINFO_PROD = CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_ROOT_PROD + '/info/itemInfo';
41
+ // export const CustomTermsReviewResultsFeatureTableUrl =
42
+ // TIER === 'prod'
43
+ // ? CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_URL_PROD
44
+ // : CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_URL_DEV;
45
+ var CustomTermsReviewResultsFeatureTableField;
46
+ (function (CustomTermsReviewResultsFeatureTableField) {
47
+ CustomTermsReviewResultsFeatureTableField["OBJECT_ID"] = "OBJECTID";
48
+ CustomTermsReviewResultsFeatureTableField["TERM"] = "term";
49
+ CustomTermsReviewResultsFeatureTableField["CATEGORY"] = "category";
50
+ CustomTermsReviewResultsFeatureTableField["STATUS"] = "status";
51
+ CustomTermsReviewResultsFeatureTableField["LIFECYCLE"] = "lifecycle";
52
+ CustomTermsReviewResultsFeatureTableField["NOTE"] = "note";
53
+ CustomTermsReviewResultsFeatureTableField["CREATION_DATE"] = "CreationDate";
54
+ CustomTermsReviewResultsFeatureTableField["CREATOR"] = "Creator";
55
+ CustomTermsReviewResultsFeatureTableField["EDIT_DATE"] = "EditDate";
56
+ CustomTermsReviewResultsFeatureTableField["EDITOR"] = "Editor";
57
+ })(CustomTermsReviewResultsFeatureTableField = exports.CustomTermsReviewResultsFeatureTableField || (exports.CustomTermsReviewResultsFeatureTableField = {}));
58
+ /**
59
+ * Gets the URL for the Custom Terms Review Results feature table based on the current service tier.
60
+ * @returns the URL for the Custom Terms Review Results feature table based on the current service tier.
61
+ */
62
+ const getCustomTermsReviewResultsFeatureTableUrl = () => {
63
+ return config_1.serviceTier === 'prod'
64
+ ? CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_URL_PROD
65
+ : CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_URL_DEV;
66
+ };
67
+ exports.getCustomTermsReviewResultsFeatureTableUrl = getCustomTermsReviewResultsFeatureTableUrl;
68
+ /**
69
+ * Gets the URL for the itemInfo endpoint for the Custom Terms Review Results feature table based on the current service tier.
70
+ * @returns The URL for the itemInfo endpoint for the Custom Terms Review Results feature table.
71
+ */
72
+ const getCustomTermsReviewResultsFeatureTableItemInfoUrl = () => {
73
+ return config_1.serviceTier === 'prod'
74
+ ? CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_ITEMINFO_PROD
75
+ : CUSTOM_TERMS_REVIEW_RESULTS_FEATURE_TABLE_ITEMINFO_DEV;
76
+ };
77
+ exports.getCustomTermsReviewResultsFeatureTableItemInfoUrl = getCustomTermsReviewResultsFeatureTableItemInfoUrl;
78
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/services/custom-terms-review-results/config.ts"],"names":[],"mappings":";;;AAAA,6CAA+C;AAE/C;;;;GAIG;AACH,MAAM,kDAAkD,GACpD,gHAAgH,CAAC;AAErH;;;;GAIG;AACH,MAAM,iDAAiD,GACnD,kDAAkD,GAAG,IAAI,CAAC;AAE9D;;;;GAIG;AACH,MAAM,sDAAsD,GACxD,kDAAkD,GAAG,gBAAgB,CAAC;AAE1E;;;;GAIG;AACH,MAAM,mDAAmD,GACrD,6GAA6G,CAAC;AAElH;;;;GAIG;AACH,MAAM,kDAAkD,GACpD,mDAAmD,GAAG,IAAI,CAAC;AAE/D;;;;GAIG;AACH,MAAM,uDAAuD,GACzD,mDAAmD,GAAG,gBAAgB,CAAC;AAE3E,yDAAyD;AACzD,sBAAsB;AACtB,+DAA+D;AAC/D,+DAA+D;AAE/D,IAAY,yCAWX;AAXD,WAAY,yCAAyC;IACjD,mEAAsB,CAAA;IACtB,0DAAa,CAAA;IACb,kEAAqB,CAAA;IACrB,8DAAiB,CAAA;IACjB,oEAAuB,CAAA;IACvB,0DAAa,CAAA;IACb,2EAA8B,CAAA;IAC9B,gEAAmB,CAAA;IACnB,mEAAsB,CAAA;IACtB,8DAAiB,CAAA;AACrB,CAAC,EAXW,yCAAyC,GAAzC,iDAAyC,KAAzC,iDAAyC,QAWpD;AAgBD;;;GAGG;AACI,MAAM,0CAA0C,GAAG,GAAG,EAAE;IAC3D,OAAO,oBAAW,KAAK,MAAM;QACzB,CAAC,CAAC,kDAAkD;QACpD,CAAC,CAAC,iDAAiD,CAAC;AAC5D,CAAC,CAAC;AAJW,QAAA,0CAA0C,8CAIrD;AAEF;;;GAGG;AACI,MAAM,kDAAkD,GAAG,GAAG,EAAE;IACnE,OAAO,oBAAW,KAAK,MAAM;QACzB,CAAC,CAAC,uDAAuD;QACzD,CAAC,CAAC,sDAAsD,CAAC;AACjE,CAAC,CAAC;AAJW,QAAA,kDAAkD,sDAI7D"}