@vannizhang/living-atlas-content-validator 1.5.19-beta.8 → 1.5.19
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.
- package/README.md +258 -204
- package/dist/configureSettings.d.ts +27 -25
- package/dist/configureSettings.js +14 -13
- package/dist/configureSettings.js.map +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/checkTitleAndSnippetSearchability/matchDateTimeInfo.js +6 -9
- package/dist/lib/checkTitleAndSnippetSearchability/matchDateTimeInfo.js.map +1 -1
- package/dist/lib/config.d.ts +1 -1
- package/dist/lib/config.js +6 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/featureServiceFieldAliases/checkFeatureServiceFieldAliases.d.ts +4 -0
- package/dist/lib/featureServiceFieldAliases/checkFeatureServiceFieldAliases.js +24 -16
- package/dist/lib/featureServiceFieldAliases/checkFeatureServiceFieldAliases.js.map +1 -1
- package/dist/lib/featureServiceFieldAliases/helpers.d.ts +19 -0
- package/dist/lib/featureServiceFieldAliases/helpers.js +48 -0
- package/dist/lib/featureServiceFieldAliases/helpers.js.map +1 -0
- package/dist/lib/featureServiceFieldAliases/scoringConfig.js +1 -1
- package/dist/lib/featureServiceFieldDescriptions/checkFeatureServiceFieldDescriptions.d.ts +4 -0
- package/dist/lib/featureServiceFieldDescriptions/checkFeatureServiceFieldDescriptions.js +37 -18
- package/dist/lib/featureServiceFieldDescriptions/checkFeatureServiceFieldDescriptions.js.map +1 -1
- package/dist/lib/featureServiceFieldDescriptions/helpers.d.ts +20 -0
- package/dist/lib/featureServiceFieldDescriptions/helpers.js +53 -0
- package/dist/lib/featureServiceFieldDescriptions/helpers.js.map +1 -0
- package/dist/lib/featureServiceFieldDescriptions/scoringConfig.js +1 -1
- package/dist/lib/featureServiceFieldValueTypes/checkFeatureServiceFieldValueTypes.d.ts +4 -0
- package/dist/lib/featureServiceFieldValueTypes/checkFeatureServiceFieldValueTypes.js +25 -18
- package/dist/lib/featureServiceFieldValueTypes/checkFeatureServiceFieldValueTypes.js.map +1 -1
- package/dist/lib/featureServiceFieldValueTypes/helpers.d.ts +16 -0
- package/dist/lib/featureServiceFieldValueTypes/helpers.js +35 -0
- package/dist/lib/featureServiceFieldValueTypes/helpers.js.map +1 -0
- package/dist/lib/featureServiceFieldValueTypes/scoringConfig.js +1 -1
- package/dist/lib/ssl/isValidSSL.js +3 -1
- package/dist/lib/ssl/isValidSSL.js.map +1 -1
- package/dist/locale/de.json +21 -24
- package/dist/locale/en.json +7 -10
- package/dist/locale/es.json +21 -24
- package/dist/locale/fr.json +21 -24
- package/dist/locale/ja.json +21 -24
- package/dist/locale/pt-br.json +21 -24
- package/dist/package-info.json +1 -1
- package/dist/services/feature-service/fetchFeatureServiceLayersAndTables.d.ts +11 -6
- package/dist/services/feature-service/fetchFeatureServiceLayersAndTables.js +56 -16
- package/dist/services/feature-service/fetchFeatureServiceLayersAndTables.js.map +1 -1
- package/dist/services/feature-service/getFeatureServerURL.d.ts +12 -0
- package/dist/services/feature-service/getFeatureServerURL.js +37 -0
- package/dist/services/feature-service/getFeatureServerURL.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ The validation process evaluates whether an item meets all necessary criteria, s
|
|
|
14
14
|
- [Installation](#installation)
|
|
15
15
|
- [Usage](#usage)
|
|
16
16
|
- [Configuration](#configuration)
|
|
17
|
-
- [API Reference](#api-reference)
|
|
17
|
+
- [API Reference - Core Functions](#api-reference---core-functions)
|
|
18
18
|
- [validate](#validate)
|
|
19
19
|
- [isValidTitle](#isvalidtitle)
|
|
20
20
|
- [isValidAccessInformation](#isvalidaccessinformation)
|
|
@@ -29,7 +29,11 @@ The validation process evaluates whether an item meets all necessary criteria, s
|
|
|
29
29
|
- [isValidUserProfileName](#isvaliduserprofilename)
|
|
30
30
|
- [isValidUserProfileDescription](#isvaliduserprofiledescription)
|
|
31
31
|
- [isValidUserProfileThumbnail](#isvaliduserprofilethumbnail)
|
|
32
|
+
- [checkFeatureServiceFieldAliases](#checkfeatureservicefieldaliases)
|
|
33
|
+
- [checkFeatureServiceFieldDescriptions](#checkFeatureServiceFieldDescriptions)
|
|
34
|
+
- [checkFeatureServiceFieldValueTypes](#checkFeatureServiceFieldValueTypes)
|
|
32
35
|
- [checkTitleAndSnippetSearchability](#checktitleandsnippetsearchability)
|
|
36
|
+
- [API Reference - Helper Functions](#api-reference---helper-functions)
|
|
33
37
|
- [isEligibleForCheckingTitleAndSnippetSearchability](#iseligibleforcheckingtitleandsnippetsearchability)
|
|
34
38
|
- [matchLocationInfo](#matchlocationinfo)
|
|
35
39
|
- [isRecognizedLocation](#isrecognizedlocation)
|
|
@@ -43,12 +47,8 @@ The validation process evaluates whether an item meets all necessary criteria, s
|
|
|
43
47
|
- [matchDateTimeInfo](#matchdatetimeinfo)
|
|
44
48
|
- [isRecognizedDateTimeInfo](#isrecognizeddatetimeinfo)
|
|
45
49
|
- [isRejectedDateTimeInfo](#isrejecteddatetimeinfo)
|
|
46
|
-
- [checkFeatureServiceFieldAliases](#checkfeatureservicefieldaliases)
|
|
47
|
-
- [checkFeatureServiceFieldDescriptions](#checkFeatureServiceFieldDescriptions)
|
|
48
|
-
- [checkFeatureServiceFieldValueTypes](#checkFeatureServiceFieldValueTypes)
|
|
49
50
|
- [getLivingAtlasSupportedItemTypes](#getlivingatlassupporteditemtypes)
|
|
50
51
|
- [checkIsLivingAtlasSupportedItemType](#checkislivingatlassupporteditemtype)
|
|
51
|
-
|
|
52
52
|
- [Types](#types)
|
|
53
53
|
- [ValidationResult](#validationresult)
|
|
54
54
|
- [ValidationResultStatus](#validationresultstatus)
|
|
@@ -102,26 +102,13 @@ const validationResults = validate(item, userProfile);
|
|
|
102
102
|
|
|
103
103
|
## Configuration
|
|
104
104
|
|
|
105
|
-
The package provides a `configureSettings` function that allows customization of language,
|
|
105
|
+
The package provides a `configureSettings` function that allows customization of language, additional validation patterns and etc.
|
|
106
106
|
|
|
107
107
|
### `configureSettings(params)`
|
|
108
|
-
Configures the package settings including language preferences,
|
|
108
|
+
Configures the package settings including language preferences, additional matching patterns to be used for title and snippet searchability rule and etc. This function should be called before using any validation functionality to ensure the validator operates with the correct context and rule set.
|
|
109
109
|
|
|
110
110
|
**Parameters:**
|
|
111
|
-
- `
|
|
112
|
-
Supported languages:
|
|
113
|
-
- `'en'` (English)
|
|
114
|
-
- `'de'` (German)
|
|
115
|
-
- `'es'` (Spanish)
|
|
116
|
-
- `'fr'` (French)
|
|
117
|
-
- `'ja'` (Japanese)
|
|
118
|
-
- `'pt-br'` (Brazilian Portuguese)
|
|
119
|
-
|
|
120
|
-
- `serviceTier` (`string`, required) - The service tier of the application.
|
|
121
|
-
- `'dev'`: Development tier, points to `devext.arcgis.com`.
|
|
122
|
-
- `'prod'`: Production tier, points to `www.arcgis.com`.
|
|
123
|
-
|
|
124
|
-
- `additionalPatternsForTitleAndSnippetSearchability` (*object*, optional) - Additional validation patterns for title and snippet searchability.
|
|
111
|
+
- `additionalPatternsForTitleAndSnippetSearchability` (*object*, optional) - Additional validation patterns for title and snippet searchability. These additional patterns are global, will be used for all items validated by the package. If you want to use custom patterns for a specific item, you can pass them as options to the [`validate`](#validate) function.
|
|
125
112
|
- `matchingPatternsLocation` (`string[]`) - List of location matching patterns.
|
|
126
113
|
- `rejectedPatternsLocation` (`string[]`) - List of rejected location patterns.
|
|
127
114
|
- `matchingPatternsSource` (`string[]`) - List of source matching patterns.
|
|
@@ -132,9 +119,27 @@ Configures the package settings including language preferences, service tier sel
|
|
|
132
119
|
- `rejectedPatternsYearVintage` (`string[]`) - List of rejected year vintage patterns.
|
|
133
120
|
- `shouldAvoidUsingWordBoundary` (`boolean`) - Determines if word boundaries should be avoided (for non-Latin languages).
|
|
134
121
|
|
|
122
|
+
- `language` (`string`, optional) - This setting determines the language used for displaying messages of the validation results. Default is `'en'`. Supported languages:
|
|
123
|
+
- `'en'` (English)
|
|
124
|
+
- `'de'` (German)
|
|
125
|
+
- `'es'` (Spanish)
|
|
126
|
+
- `'fr'` (French)
|
|
127
|
+
- `'ja'` (Japanese)
|
|
128
|
+
- `'pt-br'` (Brazilian Portuguese)
|
|
129
|
+
|
|
135
130
|
- `profanities` (`string[]`, optional) - List of words considered profane for validation.
|
|
136
131
|
|
|
137
|
-
|
|
132
|
+
- `serviceTier` (`string`, option) - The service tier of the application. Some helper modules (not part of the core evaluation logic) depend on this setting. If you're only using the library to evaluate content, you can safely ignore this.
|
|
133
|
+
- `'dev'`: Development tier, points to `devext.arcgis.com`.
|
|
134
|
+
- `'prod'`: Production tier, points to `www.arcgis.com`.
|
|
135
|
+
|
|
136
|
+
### When should I use `configureSettings`?
|
|
137
|
+
|
|
138
|
+
You should use `configureSettings` if you want to define additional matching patterns for title and snippet searchability, especially in cases where the default patterns may not account for all special scenarios. This is particularly helpful for non-English languages or specialized domains with frequently used terms.
|
|
139
|
+
|
|
140
|
+
The Living Atlas team also uses the `configureSettings` function to incorporate matching patterns suggested by users of the Living Atlas Nomination App.
|
|
141
|
+
|
|
142
|
+
### Example Usage of `configureSettings`
|
|
138
143
|
|
|
139
144
|
```js
|
|
140
145
|
import {
|
|
@@ -142,8 +147,6 @@ import {
|
|
|
142
147
|
} from '@vannizhang/living-atlas-content-validator';
|
|
143
148
|
|
|
144
149
|
configureSettings({
|
|
145
|
-
language: 'en',
|
|
146
|
-
serviceTier: 'prod',
|
|
147
150
|
additionalPatternsForTitleAndSnippetSearchability: {
|
|
148
151
|
matchingPatternsLocation: ['New York', 'Los Angeles'],
|
|
149
152
|
rejectedPatternsLocation: ['Unknown', 'Unknown Location'],
|
|
@@ -155,13 +158,15 @@ configureSettings({
|
|
|
155
158
|
rejectedPatternsYearVintage: ['Unknown', 'Unknown Year Vintage'],
|
|
156
159
|
shouldAvoidUsingWordBoundary: false
|
|
157
160
|
},
|
|
158
|
-
|
|
161
|
+
language: 'en',
|
|
162
|
+
profanities: ['badword1', 'badword2'],
|
|
163
|
+
serviceTier: 'prod',
|
|
159
164
|
});
|
|
160
165
|
```
|
|
161
166
|
|
|
162
|
-
|
|
167
|
+
## API Reference - Core Functions
|
|
163
168
|
|
|
164
|
-
|
|
169
|
+
These are the core functions provided by the package for validating ArcGIS Online items against Living Atlas criteria. The `validate` function serves as the main entry point, performing comprehensive validation by internally invoking the other functions. Each of these functions can also be used independently for targeted validation tasks.
|
|
165
170
|
|
|
166
171
|
### `validate`
|
|
167
172
|
Validates an ArcGIS Online item and its owner's user profile against Living Atlas criteria.
|
|
@@ -180,19 +185,21 @@ validate(
|
|
|
180
185
|
- `item` (`IItem`, required): The ArcGIS Online item to validate.
|
|
181
186
|
- `userProfile` (`IUser`, required): The user profile of the item's owner.
|
|
182
187
|
- `options` (`ValidateOptions`, optional): Additional configuration for validation.
|
|
183
|
-
- `customPatternsForLocationInfo` (`string[]`, optional): Custom patterns for location information.
|
|
184
|
-
- `customPatternsForDataVintageInfo` (`string[]`, optional): Custom patterns for data vintage information.
|
|
185
|
-
- `customPatternsForSourceInfo` (`string[]`, optional): Custom patterns for source information.
|
|
186
|
-
- `customPatternsForTopicInfo` (`string[]`, optional): Custom patterns for topic information.
|
|
187
|
-
- `thumbnailDimension` (`{ width: number; height: number; }`, optional):
|
|
188
|
+
- `customPatternsForLocationInfo` (`string[]`, optional): Custom patterns for identifying location information in the item's title and snippet.
|
|
189
|
+
- `customPatternsForDataVintageInfo` (`string[]`, optional): Custom patterns for identifying data vintage (date/time) information in the item's title and snippet.
|
|
190
|
+
- `customPatternsForSourceInfo` (`string[]`, optional): Custom patterns for identifying source information in the item's title and snippet.
|
|
191
|
+
- `customPatternsForTopicInfo` (`string[]`, optional): Custom patterns for identifying topic information in the item's title and snippet.
|
|
192
|
+
- `thumbnailDimension` (`{ width: number; height: number; }`, optional): The dimensions (in pixels) of the item's largest thumbnail image, used for validating thumbnail requirements.
|
|
193
|
+
- `featureLayers` (`FeatureLayerJSON[]`, optional): An array of [`Feature Layer JSON`](https://developers.arcgis.com/rest/services-reference/online/feature-layer/#json-response-syntax) objects representing the feature layers associated with the Feature Service item. Used for validating field value types, aliases, and descriptions within those layers.
|
|
188
194
|
|
|
189
195
|
**Returns:**
|
|
190
196
|
- `ValidationResult`: An object containing detailed validation results, a total score, and a flag indicating whether the item can be nominated to Living Atlas.
|
|
191
197
|
|
|
192
|
-
**Example
|
|
198
|
+
**Example: Validating an Item Using Custom Matching Patterns**
|
|
193
199
|
```ts
|
|
194
200
|
import { validate } from '@vannizhang/living-atlas-content-validator';
|
|
195
201
|
|
|
202
|
+
// An ArcGIS Online item to validate
|
|
196
203
|
const item = {
|
|
197
204
|
id: 'mock-item-id',
|
|
198
205
|
owner: 'mock-owner',
|
|
@@ -204,6 +211,7 @@ const item = {
|
|
|
204
211
|
// Other properties...
|
|
205
212
|
};
|
|
206
213
|
|
|
214
|
+
// User profile of the owner of the item being validated
|
|
207
215
|
const userProfile = {
|
|
208
216
|
fullName: 'mock-owner',
|
|
209
217
|
description: 'mocked user profile',
|
|
@@ -212,6 +220,7 @@ const userProfile = {
|
|
|
212
220
|
// Other properties...
|
|
213
221
|
};
|
|
214
222
|
|
|
223
|
+
// Custom options for validate function that include custom patterns for location, data vintage, source, and topic information
|
|
215
224
|
const options = {
|
|
216
225
|
customPatternsForLocationInfo: ['New York','Los Angeles'],
|
|
217
226
|
customPatternsForDataVintageInfo: ['bi-weekly'],
|
|
@@ -220,6 +229,59 @@ const options = {
|
|
|
220
229
|
thumbnailDimension: { width: 600, height: 400 },
|
|
221
230
|
};
|
|
222
231
|
|
|
232
|
+
// Validate the item and user profile with options
|
|
233
|
+
const validationResults = validate(item, userProfile, options);
|
|
234
|
+
console.log(validationResults);
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Example: Validating a Feature Service Item with Feature Layers**
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
import { validate } from '@vannizhang/living-atlas-content-validator';
|
|
241
|
+
|
|
242
|
+
// An ArcGIS Online Feature Service item to validate
|
|
243
|
+
const item = {
|
|
244
|
+
id: 'mock-feature-service-id',
|
|
245
|
+
owner: 'mock-owner',
|
|
246
|
+
title: 'US County Boundaries',
|
|
247
|
+
snippet: 'County boundaries for the United States.',
|
|
248
|
+
description: 'This feature service provides detailed county boundaries for the United States, including FIPS codes and population estimates.',
|
|
249
|
+
type: 'Feature Service',
|
|
250
|
+
tags: ['boundaries', 'counties', 'USA'],
|
|
251
|
+
access: 'public',
|
|
252
|
+
// Other properties...
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
// User profile of the owner of the item being validated
|
|
256
|
+
const userProfile = {
|
|
257
|
+
fullName: 'mock-owner',
|
|
258
|
+
description: 'GIS data publisher for US boundaries.',
|
|
259
|
+
thumbnail: 'thumbnail/avatar.png',
|
|
260
|
+
culture: 'en',
|
|
261
|
+
// Other properties...
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// Custom options for validate function that include feature layers associated with the Feature Service item
|
|
265
|
+
const options = {
|
|
266
|
+
featureLayers: [
|
|
267
|
+
{
|
|
268
|
+
id: 0,
|
|
269
|
+
name: 'Counties',
|
|
270
|
+
type: 'Feature Layer',
|
|
271
|
+
description: 'US county boundaries.',
|
|
272
|
+
copyrightText: 'U.S. Census Bureau',
|
|
273
|
+
supportsRollbackOnFailures: true,
|
|
274
|
+
geometryType: 'esriGeometryPolygon',
|
|
275
|
+
fields: [
|
|
276
|
+
{ name: 'NAME', alias: 'County Name', description: { value: 'The name of the county', fieldValueType: 'nameOrTitle' } },
|
|
277
|
+
{ name: 'FIPS', alias: 'FIPS Code', description: { value: 'Federal Information Processing Standard code', fieldValueType: 'uniqueIdentifier' } },
|
|
278
|
+
{ name: 'POP_EST', alias: 'Population Estimate', description: { value: 'Estimated population', fieldValueType: 'countOrAmount' } }
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
],
|
|
282
|
+
thumbnailDimension: { width: 600, height: 400 },
|
|
283
|
+
};
|
|
284
|
+
|
|
223
285
|
const validationResults = validate(item, userProfile, options);
|
|
224
286
|
console.log(validationResults);
|
|
225
287
|
```
|
|
@@ -664,6 +726,156 @@ console.log(validationInfo);
|
|
|
664
726
|
|
|
665
727
|
---
|
|
666
728
|
|
|
729
|
+
|
|
730
|
+
### `checkFeatureServiceFieldAliases`
|
|
731
|
+
Validates that relevant fields in feature layers have appropriate aliases.
|
|
732
|
+
|
|
733
|
+
```ts
|
|
734
|
+
import { checkFeatureServiceFieldAliases } from '@vannizhang/living-atlas-content-validator';
|
|
735
|
+
|
|
736
|
+
checkFeatureServiceFieldAliases(
|
|
737
|
+
item: IItem,
|
|
738
|
+
featureLayers: FeatureLayerJSON[]
|
|
739
|
+
): ValidationInfo
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
**Parameters:**
|
|
743
|
+
- `item` (`IItem`, required): The ArcGIS Online item to validate
|
|
744
|
+
- `featureLayers` (`FeatureLayerJSON[]`, required): An array of [`Feature Layer JSON`](https://developers.arcgis.com/rest/services-reference/online/feature-layer/#json-response-syntax) objects representing the feature layers published to this feature service to check for field aliases.
|
|
745
|
+
|
|
746
|
+
**Returns:**
|
|
747
|
+
- `ValidationInfo`: An object containing the validation result, messages, and scoring for field aliases.
|
|
748
|
+
|
|
749
|
+
**Description:**
|
|
750
|
+
This function checks the provided feature layers for relevant fields and evaluates whether those fields have aliases defined.
|
|
751
|
+
|
|
752
|
+
**Example:**
|
|
753
|
+
```ts
|
|
754
|
+
import { checkFeatureServiceFieldAliases } from '@vannizhang/living-atlas-content-validator';
|
|
755
|
+
|
|
756
|
+
const item = {
|
|
757
|
+
id: 'mock-feature-layer-id',
|
|
758
|
+
type: 'Feature Service',
|
|
759
|
+
// Other properties...
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
const featureLayers = [
|
|
763
|
+
{
|
|
764
|
+
fields: [
|
|
765
|
+
{ name: 'field1', alias: 'Field 1' },
|
|
766
|
+
{ name: 'field2', alias: '' },
|
|
767
|
+
// Other fields...
|
|
768
|
+
],
|
|
769
|
+
// Other properties...
|
|
770
|
+
}
|
|
771
|
+
// Additional feature layers if needed...
|
|
772
|
+
];
|
|
773
|
+
|
|
774
|
+
const validationInfo = checkFeatureServiceFieldAliases(item, featureLayers);
|
|
775
|
+
console.log(validationInfo);
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
---
|
|
779
|
+
|
|
780
|
+
### `checkFeatureServiceFieldDescriptions`
|
|
781
|
+
Validates that relevant fields in feature layers have appropriate descriptions.
|
|
782
|
+
|
|
783
|
+
```ts
|
|
784
|
+
import { checkFeatureServiceFieldDescriptions } from '@vannizhang/living-atlas-content-validator';
|
|
785
|
+
|
|
786
|
+
checkFeatureServiceFieldDescriptions(
|
|
787
|
+
item: IItem,
|
|
788
|
+
featureLayers: FeatureLayerJSON[]
|
|
789
|
+
): ValidationInfo
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
**Parameters:**
|
|
793
|
+
- `item` (`IItem`, required): The ArcGIS Online item to validate, expected to be a feature layer.
|
|
794
|
+
- `featureLayers` (`FeatureLayerJSON[]`, required): An array of [`Feature Layer JSON`](https://developers.arcgis.com/rest/services-reference/online/feature-layer/#json-response-syntax) objects representing the feature layers published to this feature service to check for field descriptions.
|
|
795
|
+
|
|
796
|
+
**Returns:**
|
|
797
|
+
- `ValidationInfo`: An object containing the validation result, messages, score, and scoring factors for field descriptions.
|
|
798
|
+
|
|
799
|
+
**Description:**
|
|
800
|
+
This function checks if the given item is a feature layer and evaluates the presence of field descriptions for relevant fields within the provided feature layers.
|
|
801
|
+
**Example:**
|
|
802
|
+
```ts
|
|
803
|
+
import { checkFeatureServiceFieldDescriptions } from '@vannizhang/living-atlas-content-validator';
|
|
804
|
+
|
|
805
|
+
const item = {
|
|
806
|
+
id: 'mock-feature-layer-id',
|
|
807
|
+
type: 'Feature Service',
|
|
808
|
+
// Other properties...
|
|
809
|
+
};
|
|
810
|
+
|
|
811
|
+
const featureLayers = [
|
|
812
|
+
{
|
|
813
|
+
fields: [
|
|
814
|
+
{ name: 'field1', description: { value: 'Description for field 1' } },
|
|
815
|
+
{ name: 'field2', description: { value: '' } },
|
|
816
|
+
// Other fields...
|
|
817
|
+
],
|
|
818
|
+
// Other properties...
|
|
819
|
+
}
|
|
820
|
+
// Additional feature layers if needed...
|
|
821
|
+
];
|
|
822
|
+
|
|
823
|
+
const validationInfo = checkFeatureServiceFieldDescriptions(item, featureLayers);
|
|
824
|
+
console.log(validationInfo);
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
---
|
|
828
|
+
|
|
829
|
+
### `checkFeatureServiceFieldValueTypes`
|
|
830
|
+
Validates that relevant fields in feature layers have a `fieldValueType` defined in their field descriptions.
|
|
831
|
+
|
|
832
|
+
```ts
|
|
833
|
+
import { checkFeatureServiceFieldValueTypes } from '@vannizhang/living-atlas-content-validator';
|
|
834
|
+
|
|
835
|
+
checkFeatureServiceFieldValueTypes(
|
|
836
|
+
item: IItem,
|
|
837
|
+
featureLayers: FeatureLayerJSON[]
|
|
838
|
+
): ValidationInfo
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
**Parameters:**
|
|
842
|
+
- `item` (`IItem`, required): The ArcGIS Online item to validate.
|
|
843
|
+
- `featureLayers` (`FeatureLayerJSON[]`, required): An array of [`Feature Layer JSON`](https://developers.arcgis.com/rest/services-reference/online/feature-layer/#json-response-syntax) objects representing the feature layers published to this feature service.
|
|
844
|
+
|
|
845
|
+
**Returns:**
|
|
846
|
+
- `ValidationInfo`: An object containing the validation result, messages, and scoring for field value types.
|
|
847
|
+
|
|
848
|
+
**Description:**
|
|
849
|
+
This function checks the provided feature layers for relevant fields and evaluates whether those fields have a `fieldValueType` defined in their descriptions.
|
|
850
|
+
|
|
851
|
+
**Example:**
|
|
852
|
+
```ts
|
|
853
|
+
import { checkFeatureServiceFieldValueTypes } from '@vannizhang/living-atlas-content-validator';
|
|
854
|
+
|
|
855
|
+
const item = {
|
|
856
|
+
id: 'mock-feature-layer-id',
|
|
857
|
+
type: 'Feature Service',
|
|
858
|
+
// Other properties...
|
|
859
|
+
};
|
|
860
|
+
|
|
861
|
+
const featureLayers = [
|
|
862
|
+
{
|
|
863
|
+
fields: [
|
|
864
|
+
{ name: 'field1', description: { fieldValueType: 'type1' } },
|
|
865
|
+
{ name: 'field2', description: { fieldValueType: '' } },
|
|
866
|
+
// Other fields...
|
|
867
|
+
],
|
|
868
|
+
// Other properties...
|
|
869
|
+
}
|
|
870
|
+
// Additional feature layers if needed...
|
|
871
|
+
];
|
|
872
|
+
|
|
873
|
+
const validationInfo = checkFeatureServiceFieldValueTypes(item, featureLayers);
|
|
874
|
+
console.log(validationInfo);
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
---
|
|
878
|
+
|
|
667
879
|
### `checkTitleAndSnippetSearchability`
|
|
668
880
|
Checks for required and recommended text in an item's title and summary (snippet) to ensure they are search-friendly.
|
|
669
881
|
|
|
@@ -715,6 +927,10 @@ console.log(validationInfo);
|
|
|
715
927
|
|
|
716
928
|
---
|
|
717
929
|
|
|
930
|
+
## API Reference - Helper Functions
|
|
931
|
+
|
|
932
|
+
These are helper functions used internally by the core validation functions, but they can also be called independently for specific use cases. For example, a user may call `checkIsLivingAtlasSupportedItemType` to determine if an item is a supported Living Atlas type before invoking validate. Similarly, `isRecognizedLocation` can be used to verify whether a string qualifies as recognized location information before using it as a custom pattern in `matchLocationInfo`.
|
|
933
|
+
|
|
718
934
|
### `isEligibleForCheckingTitleAndSnippetSearchability`
|
|
719
935
|
Determines if an item is eligible for checking title and snippet searchability.
|
|
720
936
|
|
|
@@ -1197,171 +1413,6 @@ const isSupported = checkIsLivingAtlasSupportedItemType(item);
|
|
|
1197
1413
|
console.log(isSupported); // true or false
|
|
1198
1414
|
```
|
|
1199
1415
|
|
|
1200
|
-
---
|
|
1201
|
-
|
|
1202
|
-
### `checkFeatureServiceFieldAliases`
|
|
1203
|
-
Validates that relevant fields in feature layers have appropriate aliases.
|
|
1204
|
-
|
|
1205
|
-
```ts
|
|
1206
|
-
import { checkFeatureServiceFieldAliases } from '@vannizhang/living-atlas-content-validator';
|
|
1207
|
-
|
|
1208
|
-
checkFeatureServiceFieldAliases(
|
|
1209
|
-
item: IItem,
|
|
1210
|
-
featureLayers: FeatureLayerJSON[]
|
|
1211
|
-
): ValidationInfo
|
|
1212
|
-
```
|
|
1213
|
-
|
|
1214
|
-
**Parameters:**
|
|
1215
|
-
- `item` (`IItem`, required): The ArcGIS Online item to validate
|
|
1216
|
-
- `featureLayers` (`FeatureLayerJSON[]`, required): An array of JSON objects representing the feature layers published to this feature service to check for field aliases.
|
|
1217
|
-
|
|
1218
|
-
**Returns:**
|
|
1219
|
-
- `ValidationInfo`: An object containing the validation result, messages, and scoring for field aliases.
|
|
1220
|
-
|
|
1221
|
-
**Description:**
|
|
1222
|
-
This function checks the provided feature layers for relevant fields and evaluates whether those fields have aliases defined. The scoring logic is as follows:
|
|
1223
|
-
- If the item is not a feature layer, the rule does not contribute to the final score (weight is 0).
|
|
1224
|
-
- If there are no feature layers, a message is added and the result is returned.
|
|
1225
|
-
- If none of the relevant fields have aliases, a message is added to prompt adding aliases.
|
|
1226
|
-
- If less than 80% of relevant fields have aliases, a message is added to prompt improvement and half score is given.
|
|
1227
|
-
- If at least 80% of relevant fields have aliases, the rule receives full score.
|
|
1228
|
-
|
|
1229
|
-
**Example:**
|
|
1230
|
-
```ts
|
|
1231
|
-
import { checkFeatureServiceFieldAliases } from '@vannizhang/living-atlas-content-validator';
|
|
1232
|
-
|
|
1233
|
-
const item = {
|
|
1234
|
-
id: 'mock-feature-layer-id',
|
|
1235
|
-
type: 'Feature Service',
|
|
1236
|
-
// Other properties...
|
|
1237
|
-
};
|
|
1238
|
-
|
|
1239
|
-
const featureLayers = [
|
|
1240
|
-
{
|
|
1241
|
-
fields: [
|
|
1242
|
-
{ name: 'field1', alias: 'Field 1' },
|
|
1243
|
-
{ name: 'field2', alias: '' },
|
|
1244
|
-
// Other fields...
|
|
1245
|
-
],
|
|
1246
|
-
// Other properties...
|
|
1247
|
-
}
|
|
1248
|
-
// Additional feature layers if needed...
|
|
1249
|
-
];
|
|
1250
|
-
|
|
1251
|
-
const validationInfo = checkFeatureServiceFieldAliases(item, featureLayers);
|
|
1252
|
-
console.log(validationInfo);
|
|
1253
|
-
```
|
|
1254
|
-
|
|
1255
|
-
---
|
|
1256
|
-
|
|
1257
|
-
### `checkFeatureServiceFieldDescriptions`
|
|
1258
|
-
Validates that relevant fields in feature layers have appropriate descriptions.
|
|
1259
|
-
|
|
1260
|
-
```ts
|
|
1261
|
-
import { checkFeatureServiceFieldDescriptions } from '@vannizhang/living-atlas-content-validator';
|
|
1262
|
-
|
|
1263
|
-
checkFeatureServiceFieldDescriptions(
|
|
1264
|
-
item: IItem,
|
|
1265
|
-
featureLayers: FeatureLayerJSON[]
|
|
1266
|
-
): ValidationInfo
|
|
1267
|
-
```
|
|
1268
|
-
|
|
1269
|
-
**Parameters:**
|
|
1270
|
-
- `item` (`IItem`, required): The ArcGIS Online item to validate, expected to be a feature layer.
|
|
1271
|
-
- `featureLayers` (`FeatureLayerJSON[]`, required): An array of JSON objects representing the feature layers published to this feature service to check for field descriptions.
|
|
1272
|
-
|
|
1273
|
-
**Returns:**
|
|
1274
|
-
- `ValidationInfo`: An object containing the validation result, messages, score, and scoring factors for field descriptions.
|
|
1275
|
-
|
|
1276
|
-
**Description:**
|
|
1277
|
-
This function checks if the given item is a feature layer and evaluates the presence of field descriptions for relevant fields within the provided feature layers. The scoring logic is as follows:
|
|
1278
|
-
- If the item is not a feature layer, the rule does not contribute to the final score (weight is 0).
|
|
1279
|
-
- If there are no feature layers, a message is added and the result is returned.
|
|
1280
|
-
- If none of the relevant fields have descriptions, a message is added and the score is zero.
|
|
1281
|
-
- If less than 80% of relevant fields have descriptions, a message is added and half score is given.
|
|
1282
|
-
- If at least 80% of relevant fields have descriptions, the rule receives full score.
|
|
1283
|
-
|
|
1284
|
-
**Example:**
|
|
1285
|
-
```ts
|
|
1286
|
-
import { checkFeatureServiceFieldDescriptions } from '@vannizhang/living-atlas-content-validator';
|
|
1287
|
-
|
|
1288
|
-
const item = {
|
|
1289
|
-
id: 'mock-feature-layer-id',
|
|
1290
|
-
type: 'Feature Service',
|
|
1291
|
-
// Other properties...
|
|
1292
|
-
};
|
|
1293
|
-
|
|
1294
|
-
const featureLayers = [
|
|
1295
|
-
{
|
|
1296
|
-
fields: [
|
|
1297
|
-
{ name: 'field1', description: { value: 'Description for field 1' } },
|
|
1298
|
-
{ name: 'field2', description: { value: '' } },
|
|
1299
|
-
// Other fields...
|
|
1300
|
-
],
|
|
1301
|
-
// Other properties...
|
|
1302
|
-
}
|
|
1303
|
-
// Additional feature layers if needed...
|
|
1304
|
-
];
|
|
1305
|
-
|
|
1306
|
-
const validationInfo = checkFeatureServiceFieldDescriptions(item, featureLayers);
|
|
1307
|
-
console.log(validationInfo);
|
|
1308
|
-
```
|
|
1309
|
-
|
|
1310
|
-
---
|
|
1311
|
-
|
|
1312
|
-
### `checkFeatureServiceFieldValueTypes`
|
|
1313
|
-
Validates that relevant fields in feature layers have a `fieldValueType` defined in their field descriptions.
|
|
1314
|
-
|
|
1315
|
-
```ts
|
|
1316
|
-
import { checkFeatureServiceFieldValueTypes } from '@vannizhang/living-atlas-content-validator';
|
|
1317
|
-
|
|
1318
|
-
checkFeatureServiceFieldValueTypes(
|
|
1319
|
-
item: IItem,
|
|
1320
|
-
featureLayers: FeatureLayerJSON[]
|
|
1321
|
-
): ValidationInfo
|
|
1322
|
-
```
|
|
1323
|
-
|
|
1324
|
-
**Parameters:**
|
|
1325
|
-
- `item` (`IItem`, required): The ArcGIS Online item to validate.
|
|
1326
|
-
- `featureLayers` (`FeatureLayerJSON[]`, required): An array of JSON objects representing the feature layers published to this feature service.
|
|
1327
|
-
|
|
1328
|
-
**Returns:**
|
|
1329
|
-
- `ValidationInfo`: An object containing the validation result, messages, and scoring for field value types.
|
|
1330
|
-
|
|
1331
|
-
**Description:**
|
|
1332
|
-
This function checks the provided feature layers for relevant fields and evaluates whether those fields have a `fieldValueType` defined in their descriptions. The scoring logic is as follows:
|
|
1333
|
-
- If the item is not a feature layer, the rule does not contribute to the final score (weight is 0).
|
|
1334
|
-
- If there are no feature layers, a message is added and the result is returned.
|
|
1335
|
-
- If there are no relevant fields to check, the rule is considered fully satisfied.
|
|
1336
|
-
- If none of the relevant fields have a `fieldValueType`, a message is added and the score is zero.
|
|
1337
|
-
- If less than 80% of relevant fields have a `fieldValueType`, a message is added and half score is given.
|
|
1338
|
-
- If at least 80% of relevant fields have a `fieldValueType`, the rule receives full score.
|
|
1339
|
-
|
|
1340
|
-
**Example:**
|
|
1341
|
-
```ts
|
|
1342
|
-
import { checkFeatureServiceFieldValueTypes } from '@vannizhang/living-atlas-content-validator';
|
|
1343
|
-
|
|
1344
|
-
const item = {
|
|
1345
|
-
id: 'mock-feature-layer-id',
|
|
1346
|
-
type: 'Feature Service',
|
|
1347
|
-
// Other properties...
|
|
1348
|
-
};
|
|
1349
|
-
|
|
1350
|
-
const featureLayers = [
|
|
1351
|
-
{
|
|
1352
|
-
fields: [
|
|
1353
|
-
{ name: 'field1', description: { fieldValueType: 'type1' } },
|
|
1354
|
-
{ name: 'field2', description: { fieldValueType: '' } },
|
|
1355
|
-
// Other fields...
|
|
1356
|
-
],
|
|
1357
|
-
// Other properties...
|
|
1358
|
-
}
|
|
1359
|
-
// Additional feature layers if needed...
|
|
1360
|
-
];
|
|
1361
|
-
|
|
1362
|
-
const validationInfo = checkFeatureServiceFieldValueTypes(item, featureLayers);
|
|
1363
|
-
console.log(validationInfo);
|
|
1364
|
-
```
|
|
1365
1416
|
|
|
1366
1417
|
## Types
|
|
1367
1418
|
|
|
@@ -1655,21 +1706,24 @@ Below is the list of weights assigned to each validation rule:
|
|
|
1655
1706
|
|
|
1656
1707
|
| Validation Rule | Weight |
|
|
1657
1708
|
|------------------------------------------------|--------|
|
|
1658
|
-
| Check
|
|
1709
|
+
| Check Discoverability of Title and Summary | 16 |
|
|
1659
1710
|
| Check Title | 8 |
|
|
1660
1711
|
| Check Summary | 8 |
|
|
1712
|
+
| Check Thumbnail | 8 |
|
|
1661
1713
|
| Check Description | 8 |
|
|
1662
|
-
| Check Tags | 4 |
|
|
1663
|
-
| Check Discoverability of Title and Summary | 16 |
|
|
1664
1714
|
| Check Terms of Use | 8 |
|
|
1665
1715
|
| Check Credits (Attribution) | 8 |
|
|
1716
|
+
| Check Profile Description | 8 |
|
|
1717
|
+
| Check Feature Service Field Aliases | 8 |
|
|
1718
|
+
| Check Tags | 4 |
|
|
1719
|
+
| Check Profile Thumbnail | 2 |
|
|
1720
|
+
| Check Profile Full Name | 2 |
|
|
1721
|
+
| Check Feature Service Field Descriptions | 2 |
|
|
1722
|
+
| Check Feature Service Field Value Types | 2 |
|
|
1666
1723
|
| Check Sharing Level | 1 |
|
|
1667
1724
|
| Check Delete Protection Setting | 1 |
|
|
1668
1725
|
| Check Deprecated Setting | 1 |
|
|
1669
1726
|
| Check HTTPS in URL | 1 |
|
|
1670
|
-
| Check Profile Thumbnail | 2 |
|
|
1671
|
-
| Check Profile Full Name | 2 |
|
|
1672
|
-
| Check Profile Description | 8 |
|
|
1673
1727
|
|
|
1674
1728
|
## Issues
|
|
1675
1729
|
Find a bug or want to request a new feature? Please let us know by submitting an issue.
|
|
@@ -1,24 +1,5 @@
|
|
|
1
1
|
import { ServiceTier } from './services/shared/config';
|
|
2
2
|
type ConfigureSettingsParams = {
|
|
3
|
-
/**
|
|
4
|
-
* The language of the library. Default is 'en'.
|
|
5
|
-
* This setting determines the language used for displaying messages and of the validation results.
|
|
6
|
-
*
|
|
7
|
-
* Here is list of supported languages:
|
|
8
|
-
* - `en`: English
|
|
9
|
-
* - `de`: German
|
|
10
|
-
* - `es`: Spanish
|
|
11
|
-
* - `fr`: French
|
|
12
|
-
* - `ja`: Japanese
|
|
13
|
-
* - `pt-br`: Brazilian Portuguese
|
|
14
|
-
*/
|
|
15
|
-
language: string;
|
|
16
|
-
/**
|
|
17
|
-
* The service tier of the application. It can be either 'dev' or 'prod'.
|
|
18
|
-
* - `dev`: Development tier, pointing to development services on `devext.arcgis.com`.
|
|
19
|
-
* - `prod`: Production tier, pointing to production services on `www.arcgis.com`.
|
|
20
|
-
*/
|
|
21
|
-
serviceTier: ServiceTier;
|
|
22
3
|
/**
|
|
23
4
|
* additional patterns for title and snippet searchability
|
|
24
5
|
*/
|
|
@@ -102,19 +83,40 @@ type ConfigureSettingsParams = {
|
|
|
102
83
|
*/
|
|
103
84
|
shouldAvoidUsingWordBoundary: boolean;
|
|
104
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* The language of the library. Default is 'en'.
|
|
88
|
+
* This setting determines the language used for displaying messages and of the validation results.
|
|
89
|
+
*
|
|
90
|
+
* Here is list of supported languages:
|
|
91
|
+
* - `en`: English
|
|
92
|
+
* - `de`: German
|
|
93
|
+
* - `es`: Spanish
|
|
94
|
+
* - `fr`: French
|
|
95
|
+
* - `ja`: Japanese
|
|
96
|
+
* - `pt-br`: Brazilian Portuguese
|
|
97
|
+
*/
|
|
98
|
+
language?: string;
|
|
105
99
|
/**
|
|
106
100
|
* An array of profanities to be used for validation.
|
|
107
101
|
* This is used to determine if the title or snippet contains any profanities.
|
|
108
102
|
*/
|
|
109
103
|
profanities?: string[];
|
|
104
|
+
/**
|
|
105
|
+
* Specifies the service tier of the application, either `'dev'` or `'prod'`.
|
|
106
|
+
* Some helper modules (not part of the core evaluation logic) depend on this setting.
|
|
107
|
+
* If you're only using the library to evaluate content, you can safely ignore this.
|
|
108
|
+
*
|
|
109
|
+
* - `'dev'`: Development tier; uses services hosted on `devext.arcgis.com`.
|
|
110
|
+
* - `'prod'`: Production tier; uses services hosted on `www.arcgis.com`.
|
|
111
|
+
*/
|
|
112
|
+
serviceTier?: ServiceTier;
|
|
110
113
|
};
|
|
111
114
|
/**
|
|
112
115
|
* Configures the settings for the application.
|
|
113
116
|
*
|
|
114
117
|
* @param {Object} params - The settings parameters.
|
|
115
|
-
* @param {string} params.serviceTier - The service tier, must be either 'dev' or 'prod'.
|
|
116
118
|
* @param {string} params.language - The language to be set for the application.
|
|
117
|
-
* @param {Object} params.additionalPatternsForTitleAndSnippetSearchability -
|
|
119
|
+
* @param {Object} [params.additionalPatternsForTitleAndSnippetSearchability] - Optional additional patterns for title and snippet searchability.
|
|
118
120
|
* @param {string[]} params.additionalPatternsForTitleAndSnippetSearchability.matchingPatternsLocation - Matching patterns for location.
|
|
119
121
|
* @param {string[]} params.additionalPatternsForTitleAndSnippetSearchability.rejectedPatternsLocation - Rejected patterns for location.
|
|
120
122
|
* @param {string[]} params.additionalPatternsForTitleAndSnippetSearchability.matchingPatternsSource - Matching patterns for source.
|
|
@@ -124,10 +126,10 @@ type ConfigureSettingsParams = {
|
|
|
124
126
|
* @param {string[]} params.additionalPatternsForTitleAndSnippetSearchability.matchingPatternsYearVintage - Matching patterns for year vintage.
|
|
125
127
|
* @param {string[]} params.additionalPatternsForTitleAndSnippetSearchability.rejectedPatternsYearVintage - Rejected patterns for year vintage.
|
|
126
128
|
* @param {boolean} params.additionalPatternsForTitleAndSnippetSearchability.shouldAvoidUsingWordBoundary - Flag to avoid using word boundary.
|
|
127
|
-
* @param {string[]} [params.profanities] -
|
|
129
|
+
* @param {string[]} [params.profanities] - Optional array of profanities to be used for validation.
|
|
130
|
+
* @param {string} [params.serviceTier] - Optional service tier, must be either 'dev' or 'prod'. Defaults to 'prod'.
|
|
128
131
|
*
|
|
129
|
-
* @throws {Error} If the
|
|
130
|
-
* @throws {Error} If the language is not provided.
|
|
132
|
+
* @throws {Error} If the language is not provided or is invalid.
|
|
131
133
|
*/
|
|
132
|
-
export declare const configureSettings: ({
|
|
134
|
+
export declare const configureSettings: ({ language, additionalPatternsForTitleAndSnippetSearchability, profanities, serviceTier, }: ConfigureSettingsParams) => void;
|
|
133
135
|
export {};
|