@vannizhang/living-atlas-content-validator 1.5.19-beta.9 → 1.5.20-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +416 -209
- package/dist/configureSettings.d.ts +14 -26
- package/dist/configureSettings.js +26 -21
- package/dist/configureSettings.js.map +1 -1
- package/dist/index.d.ts +20 -3
- package/dist/index.js +39 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/accessInformation/isValidAccessInformation.js +1 -0
- package/dist/lib/accessInformation/isValidAccessInformation.js.map +1 -1
- package/dist/lib/checkTitleAndSnippetSearchability/checkTitleAndSnippetSearchability.js +1 -0
- package/dist/lib/checkTitleAndSnippetSearchability/checkTitleAndSnippetSearchability.js.map +1 -1
- package/dist/lib/config.d.ts +6 -1
- package/dist/lib/config.js +43 -1
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/deleteProtection/isDeleteProtectionEnabled.js +1 -0
- package/dist/lib/deleteProtection/isDeleteProtectionEnabled.js.map +1 -1
- package/dist/lib/deprecated/isDeprecated.js +1 -0
- package/dist/lib/deprecated/isDeprecated.js.map +1 -1
- package/dist/lib/description/isValidDescription.js +1 -0
- package/dist/lib/description/isValidDescription.js.map +1 -1
- package/dist/lib/featureServiceCDNSetting/checkFeatureServiceCDNSetting.d.ts +10 -0
- package/dist/lib/featureServiceCDNSetting/checkFeatureServiceCDNSetting.js +52 -0
- package/dist/lib/featureServiceCDNSetting/checkFeatureServiceCDNSetting.js.map +1 -0
- package/dist/lib/featureServiceExportDataSetting/checkFeatureServiceExportSetting.d.ts +8 -0
- package/dist/lib/featureServiceExportDataSetting/checkFeatureServiceExportSetting.js +54 -0
- package/dist/lib/featureServiceExportDataSetting/checkFeatureServiceExportSetting.js.map +1 -0
- package/dist/lib/featureServiceExtents/checkFeatureServiceExtents.d.ts +16 -0
- package/dist/lib/featureServiceExtents/checkFeatureServiceExtents.js +83 -0
- package/dist/lib/featureServiceExtents/checkFeatureServiceExtents.js.map +1 -0
- package/dist/lib/featureServiceExtents/checkFeatureServiceExtentsHelpers.d.ts +17 -0
- package/dist/lib/featureServiceExtents/checkFeatureServiceExtentsHelpers.js +33 -0
- package/dist/lib/featureServiceExtents/checkFeatureServiceExtentsHelpers.js.map +1 -0
- package/dist/lib/featureServiceFieldAliases/checkFeatureServiceFieldAliases.js +18 -13
- 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/featureServiceFieldDescriptions/checkFeatureServiceFieldDescriptions.js +31 -15
- 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/featureServiceFieldIndexes/checkFeatureServiceFieldIndexes.d.ts +10 -0
- package/dist/lib/featureServiceFieldIndexes/checkFeatureServiceFieldIndexes.js +53 -0
- package/dist/lib/featureServiceFieldIndexes/checkFeatureServiceFieldIndexes.js.map +1 -0
- package/dist/lib/featureServiceFieldIndexes/featureServiceFieldIndexesHelpers.d.ts +7 -0
- package/dist/lib/featureServiceFieldIndexes/featureServiceFieldIndexesHelpers.js +27 -0
- package/dist/lib/featureServiceFieldIndexes/featureServiceFieldIndexesHelpers.js.map +1 -0
- package/dist/lib/featureServiceFieldValueTypes/checkFeatureServiceFieldValueTypes.js +19 -15
- 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/itemExtent/checkItemExtent.d.ts +27 -0
- package/dist/lib/itemExtent/checkItemExtent.js +102 -0
- package/dist/lib/itemExtent/checkItemExtent.js.map +1 -0
- package/dist/lib/itemExtent/checkItemExtentHelpers.d.ts +38 -0
- package/dist/lib/itemExtent/checkItemExtentHelpers.js +132 -0
- package/dist/lib/itemExtent/checkItemExtentHelpers.js.map +1 -0
- package/dist/lib/itemExtent/scoringConfig.d.ts +9 -0
- package/dist/lib/itemExtent/scoringConfig.js +13 -0
- package/dist/lib/itemExtent/scoringConfig.js.map +1 -0
- package/dist/lib/licenseInfo/isValidLicenseInfo.js +1 -0
- package/dist/lib/licenseInfo/isValidLicenseInfo.js.map +1 -1
- package/dist/lib/sharing/isValidAccess.js +1 -0
- package/dist/lib/sharing/isValidAccess.js.map +1 -1
- package/dist/lib/ssl/isValidSSL.js +6 -1
- package/dist/lib/ssl/isValidSSL.js.map +1 -1
- package/dist/lib/summary/isValidSummary.js +1 -0
- package/dist/lib/summary/isValidSummary.js.map +1 -1
- package/dist/lib/tags/isValidTags.js +1 -0
- package/dist/lib/tags/isValidTags.js.map +1 -1
- package/dist/lib/thumbnail/isValidThumbnail.js +1 -0
- package/dist/lib/thumbnail/isValidThumbnail.js.map +1 -1
- package/dist/lib/title/isValidTitle.js +1 -0
- package/dist/lib/title/isValidTitle.js.map +1 -1
- package/dist/lib/userProfileDescription/isValidUserProfileDescription.js +1 -0
- package/dist/lib/userProfileDescription/isValidUserProfileDescription.js.map +1 -1
- package/dist/lib/userProfileName/isValidUserProfileName.js +1 -0
- package/dist/lib/userProfileName/isValidUserProfileName.js.map +1 -1
- package/dist/lib/userProfileThumbnail/isValidUserProfileThumbnail.js +1 -0
- package/dist/lib/userProfileThumbnail/isValidUserProfileThumbnail.js.map +1 -1
- package/dist/lib/util/isFeatureService.d.ts +6 -0
- package/dist/lib/util/isFeatureService.js +21 -1
- package/dist/lib/util/isFeatureService.js.map +1 -1
- package/dist/lib/util/shouldValidateByBetaRules.d.ts +0 -1
- package/dist/lib/util/shouldValidateByBetaRules.js +27 -26
- package/dist/lib/util/shouldValidateByBetaRules.js.map +1 -1
- package/dist/lib/util/stringsConfig.d.ts +5 -1
- package/dist/lib/util/stringsConfig.js +60 -22
- package/dist/lib/util/stringsConfig.js.map +1 -1
- package/dist/lib/validate/validate.d.ts +14 -2
- package/dist/lib/validate/validate.js +28 -1
- package/dist/lib/validate/validate.js.map +1 -1
- package/dist/locale/en.json +50 -10
- package/dist/package-info.json +1 -1
- package/dist/services/feature-service/fetchFeatureServiceAdminJSON.d.ts +14 -0
- package/dist/services/feature-service/fetchFeatureServiceAdminJSON.js +57 -0
- package/dist/services/feature-service/fetchFeatureServiceAdminJSON.js.map +1 -0
- 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/fetchFeatureServiceRootJSON.d.ts +16 -0
- package/dist/services/feature-service/fetchFeatureServiceRootJSON.js +84 -0
- package/dist/services/feature-service/fetchFeatureServiceRootJSON.js.map +1 -0
- 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 +180 -2
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/locale/de.json +0 -204
- package/dist/locale/es.json +0 -204
- package/dist/locale/fr.json +0 -204
- package/dist/locale/ja.json +0 -204
- package/dist/locale/pt-br.json +0 -204
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,14 @@ 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)
|
|
35
|
+
- [checkFeatureServiceCDNSetting](#checkfeatureservicecdnsetting)
|
|
36
|
+
- [checkFeatureServiceExportSetting](#checkfeatureserviceexportsetting)
|
|
32
37
|
- [checkTitleAndSnippetSearchability](#checktitleandsnippetsearchability)
|
|
38
|
+
- [checkItemExtent](#checkitemextent)
|
|
39
|
+
- [API Reference - Helper Functions](#api-reference---helper-functions)
|
|
33
40
|
- [isEligibleForCheckingTitleAndSnippetSearchability](#iseligibleforcheckingtitleandsnippetsearchability)
|
|
34
41
|
- [matchLocationInfo](#matchlocationinfo)
|
|
35
42
|
- [isRecognizedLocation](#isrecognizedlocation)
|
|
@@ -43,12 +50,8 @@ The validation process evaluates whether an item meets all necessary criteria, s
|
|
|
43
50
|
- [matchDateTimeInfo](#matchdatetimeinfo)
|
|
44
51
|
- [isRecognizedDateTimeInfo](#isrecognizeddatetimeinfo)
|
|
45
52
|
- [isRejectedDateTimeInfo](#isrejecteddatetimeinfo)
|
|
46
|
-
- [checkFeatureServiceFieldAliases](#checkfeatureservicefieldaliases)
|
|
47
|
-
- [checkFeatureServiceFieldDescriptions](#checkFeatureServiceFieldDescriptions)
|
|
48
|
-
- [checkFeatureServiceFieldValueTypes](#checkFeatureServiceFieldValueTypes)
|
|
49
53
|
- [getLivingAtlasSupportedItemTypes](#getlivingatlassupporteditemtypes)
|
|
50
54
|
- [checkIsLivingAtlasSupportedItemType](#checkislivingatlassupporteditemtype)
|
|
51
|
-
|
|
52
55
|
- [Types](#types)
|
|
53
56
|
- [ValidationResult](#validationresult)
|
|
54
57
|
- [ValidationResultStatus](#validationresultstatus)
|
|
@@ -102,26 +105,13 @@ const validationResults = validate(item, userProfile);
|
|
|
102
105
|
|
|
103
106
|
## Configuration
|
|
104
107
|
|
|
105
|
-
The package provides a `configureSettings` function that allows customization of language,
|
|
108
|
+
The package provides a `configureSettings` function that allows customization of language, additional validation patterns and etc.
|
|
106
109
|
|
|
107
110
|
### `configureSettings(params)`
|
|
108
|
-
Configures the package settings including language preferences,
|
|
111
|
+
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
112
|
|
|
110
113
|
**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.
|
|
114
|
+
- `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
115
|
- `matchingPatternsLocation` (`string[]`) - List of location matching patterns.
|
|
126
116
|
- `rejectedPatternsLocation` (`string[]`) - List of rejected location patterns.
|
|
127
117
|
- `matchingPatternsSource` (`string[]`) - List of source matching patterns.
|
|
@@ -132,9 +122,27 @@ Configures the package settings including language preferences, service tier sel
|
|
|
132
122
|
- `rejectedPatternsYearVintage` (`string[]`) - List of rejected year vintage patterns.
|
|
133
123
|
- `shouldAvoidUsingWordBoundary` (`boolean`) - Determines if word boundaries should be avoided (for non-Latin languages).
|
|
134
124
|
|
|
125
|
+
- `language` (`string`, optional) - This setting determines the language used for displaying messages of the validation results. Default is `'en'`. Supported languages:
|
|
126
|
+
- `'en'` (English)
|
|
127
|
+
- `'de'` (German)
|
|
128
|
+
- `'es'` (Spanish)
|
|
129
|
+
- `'fr'` (French)
|
|
130
|
+
- `'ja'` (Japanese)
|
|
131
|
+
- `'pt-br'` (Brazilian Portuguese)
|
|
132
|
+
|
|
135
133
|
- `profanities` (`string[]`, optional) - List of words considered profane for validation.
|
|
136
134
|
|
|
137
|
-
|
|
135
|
+
- `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.
|
|
136
|
+
- `'dev'`: Development tier, points to `devext.arcgis.com`.
|
|
137
|
+
- `'prod'`: Production tier, points to `www.arcgis.com`.
|
|
138
|
+
|
|
139
|
+
### When should I use `configureSettings`?
|
|
140
|
+
|
|
141
|
+
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.
|
|
142
|
+
|
|
143
|
+
The Living Atlas team also uses the `configureSettings` function to incorporate matching patterns suggested by users of the Living Atlas Nomination App.
|
|
144
|
+
|
|
145
|
+
### Example Usage of `configureSettings`
|
|
138
146
|
|
|
139
147
|
```js
|
|
140
148
|
import {
|
|
@@ -142,8 +150,6 @@ import {
|
|
|
142
150
|
} from '@vannizhang/living-atlas-content-validator';
|
|
143
151
|
|
|
144
152
|
configureSettings({
|
|
145
|
-
language: 'en',
|
|
146
|
-
serviceTier: 'prod',
|
|
147
153
|
additionalPatternsForTitleAndSnippetSearchability: {
|
|
148
154
|
matchingPatternsLocation: ['New York', 'Los Angeles'],
|
|
149
155
|
rejectedPatternsLocation: ['Unknown', 'Unknown Location'],
|
|
@@ -155,13 +161,15 @@ configureSettings({
|
|
|
155
161
|
rejectedPatternsYearVintage: ['Unknown', 'Unknown Year Vintage'],
|
|
156
162
|
shouldAvoidUsingWordBoundary: false
|
|
157
163
|
},
|
|
158
|
-
|
|
164
|
+
language: 'en',
|
|
165
|
+
profanities: ['badword1', 'badword2'],
|
|
166
|
+
serviceTier: 'prod',
|
|
159
167
|
});
|
|
160
168
|
```
|
|
161
169
|
|
|
162
|
-
|
|
170
|
+
## API Reference - Core Functions
|
|
163
171
|
|
|
164
|
-
|
|
172
|
+
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
173
|
|
|
166
174
|
### `validate`
|
|
167
175
|
Validates an ArcGIS Online item and its owner's user profile against Living Atlas criteria.
|
|
@@ -185,7 +193,8 @@ validate(
|
|
|
185
193
|
- `customPatternsForSourceInfo` (`string[]`, optional): Custom patterns for identifying source information in the item's title and snippet.
|
|
186
194
|
- `customPatternsForTopicInfo` (`string[]`, optional): Custom patterns for identifying topic information in the item's title and snippet.
|
|
187
195
|
- `thumbnailDimension` (`{ width: number; height: number; }`, optional): The dimensions (in pixels) of the item's largest thumbnail image, used for validating thumbnail requirements.
|
|
188
|
-
- `featureLayers` (`FeatureLayerJSON[]`, optional): An array of `
|
|
196
|
+
- `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.
|
|
197
|
+
- `featureServiceAdminJSON` (`FeatureServiceAdminJSON`, optional): The [`Feature Service Admin JSON`](https://developers.arcgis.com/rest/services-reference/enterprise/hosted-feature-service/) object representing the Feature Service item's administrative settings. Used for checking the advisories of the Feature Service.
|
|
189
198
|
|
|
190
199
|
**Returns:**
|
|
191
200
|
- `ValidationResult`: An object containing detailed validation results, a total score, and a flag indicating whether the item can be nominated to Living Atlas.
|
|
@@ -258,6 +267,7 @@ const userProfile = {
|
|
|
258
267
|
|
|
259
268
|
// Custom options for validate function that include feature layers associated with the Feature Service item
|
|
260
269
|
const options = {
|
|
270
|
+
// feature layers associated with the Feature Service item
|
|
261
271
|
featureLayers: [
|
|
262
272
|
{
|
|
263
273
|
id: 0,
|
|
@@ -274,6 +284,15 @@ const options = {
|
|
|
274
284
|
]
|
|
275
285
|
}
|
|
276
286
|
],
|
|
287
|
+
// Feature Service Admin JSON object
|
|
288
|
+
featureServiceAdminJSON: {
|
|
289
|
+
adminServiceInfo: {
|
|
290
|
+
"name": "US County Boundaries",
|
|
291
|
+
"type": "FeatureServer",
|
|
292
|
+
"cacheMaxAge": 3600,
|
|
293
|
+
},
|
|
294
|
+
// Other properties...
|
|
295
|
+
},
|
|
277
296
|
thumbnailDimension: { width: 600, height: 400 },
|
|
278
297
|
};
|
|
279
298
|
|
|
@@ -606,7 +625,7 @@ isDeleteProtectionEnabled(
|
|
|
606
625
|
- `ValidationInfo`: An object containing the validation results for the `protected` property.
|
|
607
626
|
|
|
608
627
|
**Remark:**
|
|
609
|
-
- The delete protection status is **only exposed** to the item owner.
|
|
628
|
+
- The delete protection status is **only exposed** to the item owner.
|
|
610
629
|
|
|
611
630
|
**Example:**
|
|
612
631
|
```ts
|
|
@@ -721,6 +740,149 @@ console.log(validationInfo);
|
|
|
721
740
|
|
|
722
741
|
---
|
|
723
742
|
|
|
743
|
+
|
|
744
|
+
### `checkFeatureServiceFieldAliases`
|
|
745
|
+
This function checks the provided feature layers for relevant fields and evaluates whether those fields have aliases defined.
|
|
746
|
+
|
|
747
|
+
```ts
|
|
748
|
+
import { checkFeatureServiceFieldAliases } from '@vannizhang/living-atlas-content-validator';
|
|
749
|
+
|
|
750
|
+
checkFeatureServiceFieldAliases(
|
|
751
|
+
item: IItem,
|
|
752
|
+
featureLayers: FeatureLayerJSON[]
|
|
753
|
+
): ValidationInfo
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
**Parameters:**
|
|
757
|
+
- `item` (`IItem`, required): The ArcGIS Online item to validate
|
|
758
|
+
- `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.
|
|
759
|
+
|
|
760
|
+
**Returns:**
|
|
761
|
+
- `ValidationInfo`: An object containing the validation result, messages, and scoring for field aliases.
|
|
762
|
+
|
|
763
|
+
**Example:**
|
|
764
|
+
```ts
|
|
765
|
+
import { checkFeatureServiceFieldAliases } from '@vannizhang/living-atlas-content-validator';
|
|
766
|
+
|
|
767
|
+
const item = {
|
|
768
|
+
id: 'mock-feature-layer-id',
|
|
769
|
+
type: 'Feature Service',
|
|
770
|
+
// Other properties...
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
const featureLayers = [
|
|
774
|
+
{
|
|
775
|
+
fields: [
|
|
776
|
+
{ name: 'field1', alias: 'Field 1' },
|
|
777
|
+
{ name: 'field2', alias: '' },
|
|
778
|
+
// Other fields...
|
|
779
|
+
],
|
|
780
|
+
// Other properties...
|
|
781
|
+
}
|
|
782
|
+
// Additional feature layers if needed...
|
|
783
|
+
];
|
|
784
|
+
|
|
785
|
+
const validationInfo = checkFeatureServiceFieldAliases(item, featureLayers);
|
|
786
|
+
console.log(validationInfo);
|
|
787
|
+
```
|
|
788
|
+
|
|
789
|
+
---
|
|
790
|
+
|
|
791
|
+
### `checkFeatureServiceFieldDescriptions`
|
|
792
|
+
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.
|
|
793
|
+
|
|
794
|
+
```ts
|
|
795
|
+
import { checkFeatureServiceFieldDescriptions } from '@vannizhang/living-atlas-content-validator';
|
|
796
|
+
|
|
797
|
+
checkFeatureServiceFieldDescriptions(
|
|
798
|
+
item: IItem,
|
|
799
|
+
featureLayers: FeatureLayerJSON[]
|
|
800
|
+
): ValidationInfo
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
**Parameters:**
|
|
804
|
+
- `item` (`IItem`, required): The ArcGIS Online item to validate, expected to be a feature layer.
|
|
805
|
+
- `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.
|
|
806
|
+
|
|
807
|
+
**Returns:**
|
|
808
|
+
- `ValidationInfo`: An object containing the validation result, messages, score, and scoring factors for field descriptions.
|
|
809
|
+
|
|
810
|
+
**Example:**
|
|
811
|
+
```ts
|
|
812
|
+
import { checkFeatureServiceFieldDescriptions } from '@vannizhang/living-atlas-content-validator';
|
|
813
|
+
|
|
814
|
+
const item = {
|
|
815
|
+
id: 'mock-feature-layer-id',
|
|
816
|
+
type: 'Feature Service',
|
|
817
|
+
// Other properties...
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
const featureLayers = [
|
|
821
|
+
{
|
|
822
|
+
fields: [
|
|
823
|
+
{ name: 'field1', description: { value: 'Description for field 1' } },
|
|
824
|
+
{ name: 'field2', description: { value: '' } },
|
|
825
|
+
// Other fields...
|
|
826
|
+
],
|
|
827
|
+
// Other properties...
|
|
828
|
+
}
|
|
829
|
+
// Additional feature layers if needed...
|
|
830
|
+
];
|
|
831
|
+
|
|
832
|
+
const validationInfo = checkFeatureServiceFieldDescriptions(item, featureLayers);
|
|
833
|
+
console.log(validationInfo);
|
|
834
|
+
```
|
|
835
|
+
|
|
836
|
+
---
|
|
837
|
+
|
|
838
|
+
### `checkFeatureServiceFieldValueTypes`
|
|
839
|
+
This function checks the provided feature layers for relevant fields and evaluates whether those fields have a `fieldValueType` defined in their descriptions.
|
|
840
|
+
|
|
841
|
+
```ts
|
|
842
|
+
import { checkFeatureServiceFieldValueTypes } from '@vannizhang/living-atlas-content-validator';
|
|
843
|
+
|
|
844
|
+
checkFeatureServiceFieldValueTypes(
|
|
845
|
+
item: IItem,
|
|
846
|
+
featureLayers: FeatureLayerJSON[]
|
|
847
|
+
): ValidationInfo
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
**Parameters:**
|
|
851
|
+
- `item` (`IItem`, required): The ArcGIS Online item to validate.
|
|
852
|
+
- `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.
|
|
853
|
+
|
|
854
|
+
**Returns:**
|
|
855
|
+
- `ValidationInfo`: An object containing the validation result, messages, and scoring for field value types.
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
**Example:**
|
|
859
|
+
```ts
|
|
860
|
+
import { checkFeatureServiceFieldValueTypes } from '@vannizhang/living-atlas-content-validator';
|
|
861
|
+
|
|
862
|
+
const item = {
|
|
863
|
+
id: 'mock-feature-layer-id',
|
|
864
|
+
type: 'Feature Service',
|
|
865
|
+
// Other properties...
|
|
866
|
+
};
|
|
867
|
+
|
|
868
|
+
const featureLayers = [
|
|
869
|
+
{
|
|
870
|
+
fields: [
|
|
871
|
+
{ name: 'field1', description: { fieldValueType: 'type1' } },
|
|
872
|
+
{ name: 'field2', description: { fieldValueType: '' } },
|
|
873
|
+
// Other fields...
|
|
874
|
+
],
|
|
875
|
+
// Other properties...
|
|
876
|
+
}
|
|
877
|
+
// Additional feature layers if needed...
|
|
878
|
+
];
|
|
879
|
+
|
|
880
|
+
const validationInfo = checkFeatureServiceFieldValueTypes(item, featureLayers);
|
|
881
|
+
console.log(validationInfo);
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
---
|
|
885
|
+
|
|
724
886
|
### `checkTitleAndSnippetSearchability`
|
|
725
887
|
Checks for required and recommended text in an item's title and summary (snippet) to ensure they are search-friendly.
|
|
726
888
|
|
|
@@ -772,6 +934,199 @@ console.log(validationInfo);
|
|
|
772
934
|
|
|
773
935
|
---
|
|
774
936
|
|
|
937
|
+
### `checkFeatureServiceCDNSetting`
|
|
938
|
+
This function checks the CDN setting of the provided Feature Service item using its administrative JSON data. It evaluates whether the CDN is enabled and provides relevant messages. This check is advisory and does not impact the overall validation score of the item. If the CDN is not enabled, a warning message is returned to inform the user about the benefits of enabling CDN for better performance and scalability.
|
|
939
|
+
|
|
940
|
+
```ts
|
|
941
|
+
import { checkFeatureServiceCDNSetting } from '@vannizhang/living-atlas-content-validator';
|
|
942
|
+
checkFeatureServiceCDNSetting(
|
|
943
|
+
item: IItem,
|
|
944
|
+
featureServiceAdminJSON: FeatureServiceAdminJSON
|
|
945
|
+
): ValidationInfo
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
**Parameters:**
|
|
949
|
+
- `item` (`IItem`, required): The ArcGIS Online Feature Service item to validate
|
|
950
|
+
- `featureServiceAdminJSON` (`FeatureServiceAdminJSON`, required): The [`Feature Service Admin JSON`](https://developers.arcgis.com/rest/services-reference/enterprise/hosted-feature-service/) object representing the Feature Service item's administrative settings.
|
|
951
|
+
|
|
952
|
+
**Returns:**
|
|
953
|
+
- `ValidationInfo`: An object containing the validation result, messages for the CDN setting.
|
|
954
|
+
|
|
955
|
+
**Example:**
|
|
956
|
+
```ts
|
|
957
|
+
import { checkFeatureServiceCDNSetting } from '@vannizhang/living-atlas-content-validator';
|
|
958
|
+
|
|
959
|
+
const item = {
|
|
960
|
+
id: 'mock-feature-service-id',
|
|
961
|
+
type: 'Feature Service',
|
|
962
|
+
// Other properties...
|
|
963
|
+
};
|
|
964
|
+
|
|
965
|
+
const featureServiceAdminJSON = {
|
|
966
|
+
adminServiceInfo: {
|
|
967
|
+
"name": "Mock Feature Service",
|
|
968
|
+
"type": "FeatureServer",
|
|
969
|
+
"cacheMaxAge": 3600,
|
|
970
|
+
},
|
|
971
|
+
// Other properties...
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
const validationInfo = checkFeatureServiceCDNSetting(item, featureServiceAdminJSON);
|
|
975
|
+
console.log(validationInfo);
|
|
976
|
+
```
|
|
977
|
+
|
|
978
|
+
---
|
|
979
|
+
|
|
980
|
+
### `checkFeatureServiceExportSetting`
|
|
981
|
+
This function checks the export setting of the provided Feature Service item using its administrative JSON data. It evaluates whether the export capability is enabled and provides relevant messages.
|
|
982
|
+
This check is advisory and does not impact the overall validation score of the item. If the export setting is enabled, a warning message is returned to inform the user to make sure that exporting data aligns with their data sharing policies.
|
|
983
|
+
|
|
984
|
+
```ts
|
|
985
|
+
import { checkFeatureServiceExportSetting } from '@vannizhang/living-atlas-content-validator';
|
|
986
|
+
checkFeatureServiceExportSetting(
|
|
987
|
+
item: IItem,
|
|
988
|
+
featureServiceAdminJSON: FeatureServiceAdminJSON
|
|
989
|
+
): ValidationInfo
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
**Parameters:**
|
|
993
|
+
- `item` (`IItem`, required): The ArcGIS Online Feature Service item to validate
|
|
994
|
+
- `featureServiceAdminJSON` (`FeatureServiceAdminJSON`, required): The [`Feature Service Admin JSON`](https://developers.arcgis.com/rest/services-reference/enterprise/hosted-feature-service/) object representing the Feature Service item's administrative settings.
|
|
995
|
+
|
|
996
|
+
**Returns:**
|
|
997
|
+
- `ValidationInfo`: An object containing the validation result, messages for the export setting.
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
**Example:**
|
|
1001
|
+
```ts
|
|
1002
|
+
import { checkFeatureServiceExportSetting } from '@vannizhang/living-atlas-content-validator';
|
|
1003
|
+
|
|
1004
|
+
const item = {
|
|
1005
|
+
id: 'mock-feature-service-id',
|
|
1006
|
+
type: 'Feature Service',
|
|
1007
|
+
// Other properties...
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
const featureServiceAdminJSON = {
|
|
1011
|
+
capabilities: 'Query,Export',
|
|
1012
|
+
// Other properties...
|
|
1013
|
+
};
|
|
1014
|
+
|
|
1015
|
+
const validationInfo = checkFeatureServiceExportSetting(item, featureServiceAdminJSON);
|
|
1016
|
+
console.log(validationInfo);
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
---
|
|
1020
|
+
|
|
1021
|
+
### `checkItemExtent`
|
|
1022
|
+
|
|
1023
|
+
This function checks whether the provided item's spatial extent is valid and meaningful. It evaluates if the extent is defined, not empty, and represents a real-world area.
|
|
1024
|
+
|
|
1025
|
+
```ts
|
|
1026
|
+
import { checkItemExtent } from '@vannizhang/living-atlas-content-validator';
|
|
1027
|
+
checkItemExtent(
|
|
1028
|
+
item: IItem
|
|
1029
|
+
): ValidationInfo
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
**Parameters:**
|
|
1033
|
+
- `item` (`IItem`, required): The ArcGIS Online item to validate.
|
|
1034
|
+
|
|
1035
|
+
**Returns:**
|
|
1036
|
+
- `ValidationInfo`: An object containing the validation result, messages, and scoring for the item's
|
|
1037
|
+
|
|
1038
|
+
**Example:**
|
|
1039
|
+
```ts
|
|
1040
|
+
import { checkItemExtent } from '@vannizhang/living-atlas-content-validator';
|
|
1041
|
+
const item = {
|
|
1042
|
+
extent: [[-120, -45], [120, 45]], // Example extent
|
|
1043
|
+
// Other properties...
|
|
1044
|
+
};
|
|
1045
|
+
const validationInfo = checkItemExtent(item);
|
|
1046
|
+
console.log(validationInfo);
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
---
|
|
1050
|
+
### `checkFeatureServiceExtents`
|
|
1051
|
+
This function checks whether the provided feature service has valid initial and full extents defined in its service root JSON. It also checks the extents of each feature layer within the service to ensure they are provided.
|
|
1052
|
+
|
|
1053
|
+
```ts
|
|
1054
|
+
import { checkFeatureServiceExtents } from '@vannizhang/living-atlas-content-validator';
|
|
1055
|
+
checkFeatureServiceExtents(
|
|
1056
|
+
item: IItem,
|
|
1057
|
+
{
|
|
1058
|
+
featureLayers: FeatureLayerJSON[]
|
|
1059
|
+
featureServiceAdminJSON: FeatureServiceAdminJSON,
|
|
1060
|
+
featureServiceRootJSON: FeatureServiceRootJSON
|
|
1061
|
+
|
|
1062
|
+
}
|
|
1063
|
+
): ValidationInfo
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
**Parameters:**
|
|
1067
|
+
- `item` (`IItem`, required): The ArcGIS Online Feature Service item to validate
|
|
1068
|
+
- `options` (required): An object containing:
|
|
1069
|
+
- `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.
|
|
1070
|
+
- `featureServiceAdminJSON` (`FeatureServiceAdminJSON`, optional): The [`Feature Service Admin JSON`](https://developers.arcgis.com/rest/services-reference/enterprise/hosted-feature-service/) object representing the Feature Service item's administrative settings. If not provided, only the feature service root JSON will be used for extent validation.
|
|
1071
|
+
- `featureServiceRootJSON` (`FeatureServiceRootJSON`, optional): The [`Feature Service Root JSON`](https://developers.arcgis.com/rest/services-reference/enterprise/feature-service/) object representing the root information of the Feature Service. This is used to validate the initial and full extents of the feature service if the admin JSON is not provided.
|
|
1072
|
+
|
|
1073
|
+
**Returns:**
|
|
1074
|
+
- `ValidationInfo`: An object containing the validation result, messages, and scoring for the feature service extents.
|
|
1075
|
+
|
|
1076
|
+
**Example:**
|
|
1077
|
+
```ts
|
|
1078
|
+
import { checkFeatureServiceExtents } from '@vannizhang/living-atlas-content-validator';
|
|
1079
|
+
|
|
1080
|
+
// An ArcGIS Online Feature Service item to validate
|
|
1081
|
+
const item = {
|
|
1082
|
+
id: 'mock-feature-service-id',
|
|
1083
|
+
type: 'Feature Service',
|
|
1084
|
+
// Other properties...
|
|
1085
|
+
};
|
|
1086
|
+
|
|
1087
|
+
// feature layers associated with the Feature Service item
|
|
1088
|
+
const featureLayers = [
|
|
1089
|
+
{
|
|
1090
|
+
id: 0,
|
|
1091
|
+
name: 'Mock Layer',
|
|
1092
|
+
extent: {
|
|
1093
|
+
xmin: -120,
|
|
1094
|
+
ymin: -45,
|
|
1095
|
+
xmax: 120,
|
|
1096
|
+
ymax: 45,
|
|
1097
|
+
spatialReference: { wkid: 4326 }
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
// Additional feature layers if needed...
|
|
1101
|
+
];
|
|
1102
|
+
|
|
1103
|
+
// Feature Service Admin JSON object
|
|
1104
|
+
const featureServiceAdminJSON = {
|
|
1105
|
+
// Mock Feature Service Admin JSON properties...
|
|
1106
|
+
initialExtent: {
|
|
1107
|
+
xmin: -120,
|
|
1108
|
+
ymin: -45,
|
|
1109
|
+
xmax: 120,
|
|
1110
|
+
ymax: 45,
|
|
1111
|
+
spatialReference: { wkid: 4326 }
|
|
1112
|
+
},
|
|
1113
|
+
fullExtent: {
|
|
1114
|
+
xmin: -180,
|
|
1115
|
+
ymin: -90,
|
|
1116
|
+
xmax: 180,
|
|
1117
|
+
ymax: 90,
|
|
1118
|
+
spatialReference: { wkid: 4326 }
|
|
1119
|
+
},
|
|
1120
|
+
};
|
|
1121
|
+
|
|
1122
|
+
const validationInfo = checkFeatureServiceExtents(item, { featureLayers, featureServiceAdminJSON });
|
|
1123
|
+
```
|
|
1124
|
+
---
|
|
1125
|
+
|
|
1126
|
+
## API Reference - Helper Functions
|
|
1127
|
+
|
|
1128
|
+
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`.
|
|
1129
|
+
|
|
775
1130
|
### `isEligibleForCheckingTitleAndSnippetSearchability`
|
|
776
1131
|
Determines if an item is eligible for checking title and snippet searchability.
|
|
777
1132
|
|
|
@@ -1196,7 +1551,7 @@ console.log(isRejected); // true or false
|
|
|
1196
1551
|
---
|
|
1197
1552
|
|
|
1198
1553
|
### `getLivingAtlasSupportedItemTypes`
|
|
1199
|
-
|
|
1554
|
+
This function returns an array containing all the predefined item types that are supported by Living Atlas from the configuration.
|
|
1200
1555
|
|
|
1201
1556
|
```ts
|
|
1202
1557
|
import { getLivingAtlasSupportedItemTypes } from '@vannizhang/living-atlas-content-validator';
|
|
@@ -1207,9 +1562,6 @@ getLivingAtlasSupportedItemTypes(): LivingAtlasSupportedItemType[]
|
|
|
1207
1562
|
**Returns:**
|
|
1208
1563
|
- `LivingAtlasSupportedItemType[]`: An array of Living Atlas supported item types.
|
|
1209
1564
|
|
|
1210
|
-
**Description:**
|
|
1211
|
-
This function creates a new array containing all the predefined item types that are supported by Living Atlas from the configuration.
|
|
1212
|
-
|
|
1213
1565
|
**Example:**
|
|
1214
1566
|
```ts
|
|
1215
1567
|
import { getLivingAtlasSupportedItemTypes } from '@vannizhang/living-atlas-content-validator';
|
|
@@ -1221,8 +1573,7 @@ console.log(supportedItemTypes);
|
|
|
1221
1573
|
---
|
|
1222
1574
|
|
|
1223
1575
|
### `checkIsLivingAtlasSupportedItemType`
|
|
1224
|
-
|
|
1225
|
-
|
|
1576
|
+
This function determines whether the provided item type string is included in the predefined list of item types supported by Living Atlas.
|
|
1226
1577
|
```ts
|
|
1227
1578
|
import { checkIsLivingAtlasSupportedItemType } from '@vannizhang/living-atlas-content-validator';
|
|
1228
1579
|
|
|
@@ -1237,9 +1588,6 @@ checkIsLivingAtlasSupportedItemType(
|
|
|
1237
1588
|
**Returns:**
|
|
1238
1589
|
- `boolean`: `true` if the item type is supported by Living Atlas, otherwise `false`.
|
|
1239
1590
|
|
|
1240
|
-
**Description:**
|
|
1241
|
-
This function determines whether the provided item type string is included in the predefined list of item types supported by Living Atlas.
|
|
1242
|
-
|
|
1243
1591
|
**Example:**
|
|
1244
1592
|
```ts
|
|
1245
1593
|
import { checkIsLivingAtlasSupportedItemType } from '@vannizhang/living-atlas-content-validator';
|
|
@@ -1254,171 +1602,6 @@ const isSupported = checkIsLivingAtlasSupportedItemType(item);
|
|
|
1254
1602
|
console.log(isSupported); // true or false
|
|
1255
1603
|
```
|
|
1256
1604
|
|
|
1257
|
-
---
|
|
1258
|
-
|
|
1259
|
-
### `checkFeatureServiceFieldAliases`
|
|
1260
|
-
Validates that relevant fields in feature layers have appropriate aliases.
|
|
1261
|
-
|
|
1262
|
-
```ts
|
|
1263
|
-
import { checkFeatureServiceFieldAliases } from '@vannizhang/living-atlas-content-validator';
|
|
1264
|
-
|
|
1265
|
-
checkFeatureServiceFieldAliases(
|
|
1266
|
-
item: IItem,
|
|
1267
|
-
featureLayers: FeatureLayerJSON[]
|
|
1268
|
-
): ValidationInfo
|
|
1269
|
-
```
|
|
1270
|
-
|
|
1271
|
-
**Parameters:**
|
|
1272
|
-
- `item` (`IItem`, required): The ArcGIS Online item to validate
|
|
1273
|
-
- `featureLayers` (`FeatureLayerJSON[]`, required): An array of JSON objects representing the feature layers published to this feature service to check for field aliases.
|
|
1274
|
-
|
|
1275
|
-
**Returns:**
|
|
1276
|
-
- `ValidationInfo`: An object containing the validation result, messages, and scoring for field aliases.
|
|
1277
|
-
|
|
1278
|
-
**Description:**
|
|
1279
|
-
This function checks the provided feature layers for relevant fields and evaluates whether those fields have aliases defined. The scoring logic is as follows:
|
|
1280
|
-
- If the item is not a feature layer, the rule does not contribute to the final score (weight is 0).
|
|
1281
|
-
- If there are no feature layers, a message is added and the result is returned.
|
|
1282
|
-
- If none of the relevant fields have aliases, a message is added to prompt adding aliases.
|
|
1283
|
-
- If less than 80% of relevant fields have aliases, a message is added to prompt improvement and half score is given.
|
|
1284
|
-
- If at least 80% of relevant fields have aliases, the rule receives full score.
|
|
1285
|
-
|
|
1286
|
-
**Example:**
|
|
1287
|
-
```ts
|
|
1288
|
-
import { checkFeatureServiceFieldAliases } from '@vannizhang/living-atlas-content-validator';
|
|
1289
|
-
|
|
1290
|
-
const item = {
|
|
1291
|
-
id: 'mock-feature-layer-id',
|
|
1292
|
-
type: 'Feature Service',
|
|
1293
|
-
// Other properties...
|
|
1294
|
-
};
|
|
1295
|
-
|
|
1296
|
-
const featureLayers = [
|
|
1297
|
-
{
|
|
1298
|
-
fields: [
|
|
1299
|
-
{ name: 'field1', alias: 'Field 1' },
|
|
1300
|
-
{ name: 'field2', alias: '' },
|
|
1301
|
-
// Other fields...
|
|
1302
|
-
],
|
|
1303
|
-
// Other properties...
|
|
1304
|
-
}
|
|
1305
|
-
// Additional feature layers if needed...
|
|
1306
|
-
];
|
|
1307
|
-
|
|
1308
|
-
const validationInfo = checkFeatureServiceFieldAliases(item, featureLayers);
|
|
1309
|
-
console.log(validationInfo);
|
|
1310
|
-
```
|
|
1311
|
-
|
|
1312
|
-
---
|
|
1313
|
-
|
|
1314
|
-
### `checkFeatureServiceFieldDescriptions`
|
|
1315
|
-
Validates that relevant fields in feature layers have appropriate descriptions.
|
|
1316
|
-
|
|
1317
|
-
```ts
|
|
1318
|
-
import { checkFeatureServiceFieldDescriptions } from '@vannizhang/living-atlas-content-validator';
|
|
1319
|
-
|
|
1320
|
-
checkFeatureServiceFieldDescriptions(
|
|
1321
|
-
item: IItem,
|
|
1322
|
-
featureLayers: FeatureLayerJSON[]
|
|
1323
|
-
): ValidationInfo
|
|
1324
|
-
```
|
|
1325
|
-
|
|
1326
|
-
**Parameters:**
|
|
1327
|
-
- `item` (`IItem`, required): The ArcGIS Online item to validate, expected to be a feature layer.
|
|
1328
|
-
- `featureLayers` (`FeatureLayerJSON[]`, required): An array of JSON objects representing the feature layers published to this feature service to check for field descriptions.
|
|
1329
|
-
|
|
1330
|
-
**Returns:**
|
|
1331
|
-
- `ValidationInfo`: An object containing the validation result, messages, score, and scoring factors for field descriptions.
|
|
1332
|
-
|
|
1333
|
-
**Description:**
|
|
1334
|
-
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:
|
|
1335
|
-
- If the item is not a feature layer, the rule does not contribute to the final score (weight is 0).
|
|
1336
|
-
- If there are no feature layers, a message is added and the result is returned.
|
|
1337
|
-
- If none of the relevant fields have descriptions, a message is added and the score is zero.
|
|
1338
|
-
- If less than 80% of relevant fields have descriptions, a message is added and half score is given.
|
|
1339
|
-
- If at least 80% of relevant fields have descriptions, the rule receives full score.
|
|
1340
|
-
|
|
1341
|
-
**Example:**
|
|
1342
|
-
```ts
|
|
1343
|
-
import { checkFeatureServiceFieldDescriptions } from '@vannizhang/living-atlas-content-validator';
|
|
1344
|
-
|
|
1345
|
-
const item = {
|
|
1346
|
-
id: 'mock-feature-layer-id',
|
|
1347
|
-
type: 'Feature Service',
|
|
1348
|
-
// Other properties...
|
|
1349
|
-
};
|
|
1350
|
-
|
|
1351
|
-
const featureLayers = [
|
|
1352
|
-
{
|
|
1353
|
-
fields: [
|
|
1354
|
-
{ name: 'field1', description: { value: 'Description for field 1' } },
|
|
1355
|
-
{ name: 'field2', description: { value: '' } },
|
|
1356
|
-
// Other fields...
|
|
1357
|
-
],
|
|
1358
|
-
// Other properties...
|
|
1359
|
-
}
|
|
1360
|
-
// Additional feature layers if needed...
|
|
1361
|
-
];
|
|
1362
|
-
|
|
1363
|
-
const validationInfo = checkFeatureServiceFieldDescriptions(item, featureLayers);
|
|
1364
|
-
console.log(validationInfo);
|
|
1365
|
-
```
|
|
1366
|
-
|
|
1367
|
-
---
|
|
1368
|
-
|
|
1369
|
-
### `checkFeatureServiceFieldValueTypes`
|
|
1370
|
-
Validates that relevant fields in feature layers have a `fieldValueType` defined in their field descriptions.
|
|
1371
|
-
|
|
1372
|
-
```ts
|
|
1373
|
-
import { checkFeatureServiceFieldValueTypes } from '@vannizhang/living-atlas-content-validator';
|
|
1374
|
-
|
|
1375
|
-
checkFeatureServiceFieldValueTypes(
|
|
1376
|
-
item: IItem,
|
|
1377
|
-
featureLayers: FeatureLayerJSON[]
|
|
1378
|
-
): ValidationInfo
|
|
1379
|
-
```
|
|
1380
|
-
|
|
1381
|
-
**Parameters:**
|
|
1382
|
-
- `item` (`IItem`, required): The ArcGIS Online item to validate.
|
|
1383
|
-
- `featureLayers` (`FeatureLayerJSON[]`, required): An array of JSON objects representing the feature layers published to this feature service.
|
|
1384
|
-
|
|
1385
|
-
**Returns:**
|
|
1386
|
-
- `ValidationInfo`: An object containing the validation result, messages, and scoring for field value types.
|
|
1387
|
-
|
|
1388
|
-
**Description:**
|
|
1389
|
-
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:
|
|
1390
|
-
- If the item is not a feature layer, the rule does not contribute to the final score (weight is 0).
|
|
1391
|
-
- If there are no feature layers, a message is added and the result is returned.
|
|
1392
|
-
- If there are no relevant fields to check, the rule is considered fully satisfied.
|
|
1393
|
-
- If none of the relevant fields have a `fieldValueType`, a message is added and the score is zero.
|
|
1394
|
-
- If less than 80% of relevant fields have a `fieldValueType`, a message is added and half score is given.
|
|
1395
|
-
- If at least 80% of relevant fields have a `fieldValueType`, the rule receives full score.
|
|
1396
|
-
|
|
1397
|
-
**Example:**
|
|
1398
|
-
```ts
|
|
1399
|
-
import { checkFeatureServiceFieldValueTypes } from '@vannizhang/living-atlas-content-validator';
|
|
1400
|
-
|
|
1401
|
-
const item = {
|
|
1402
|
-
id: 'mock-feature-layer-id',
|
|
1403
|
-
type: 'Feature Service',
|
|
1404
|
-
// Other properties...
|
|
1405
|
-
};
|
|
1406
|
-
|
|
1407
|
-
const featureLayers = [
|
|
1408
|
-
{
|
|
1409
|
-
fields: [
|
|
1410
|
-
{ name: 'field1', description: { fieldValueType: 'type1' } },
|
|
1411
|
-
{ name: 'field2', description: { fieldValueType: '' } },
|
|
1412
|
-
// Other fields...
|
|
1413
|
-
],
|
|
1414
|
-
// Other properties...
|
|
1415
|
-
}
|
|
1416
|
-
// Additional feature layers if needed...
|
|
1417
|
-
];
|
|
1418
|
-
|
|
1419
|
-
const validationInfo = checkFeatureServiceFieldValueTypes(item, featureLayers);
|
|
1420
|
-
console.log(validationInfo);
|
|
1421
|
-
```
|
|
1422
1605
|
|
|
1423
1606
|
## Types
|
|
1424
1607
|
|
|
@@ -1521,6 +1704,23 @@ export type ValidationResult = {
|
|
|
1521
1704
|
*/
|
|
1522
1705
|
userProfileThumbnail: ValidationInfo;
|
|
1523
1706
|
};
|
|
1707
|
+
/**
|
|
1708
|
+
* advisory validation results that do not impact the overall score.
|
|
1709
|
+
*/
|
|
1710
|
+
advisories: {
|
|
1711
|
+
/**
|
|
1712
|
+
* Advisory validation result for CDN settings of a feature service item.
|
|
1713
|
+
*/
|
|
1714
|
+
featureServiceCdnSetting: null,
|
|
1715
|
+
/**
|
|
1716
|
+
* Advisory validation result for field indexes of a feature service item.
|
|
1717
|
+
*/
|
|
1718
|
+
featureServiceFieldIndexes: null,
|
|
1719
|
+
/**
|
|
1720
|
+
* Advisory validation result for data export settings of a feature service item.
|
|
1721
|
+
*/
|
|
1722
|
+
featureServiceExportDataSetting: null,
|
|
1723
|
+
},
|
|
1524
1724
|
/**
|
|
1525
1725
|
* The ArcGIS Online Item ID.
|
|
1526
1726
|
*/
|
|
@@ -1613,6 +1813,10 @@ export type ValidationInfo = {
|
|
|
1613
1813
|
* if true, this validation rule is a binary check, i.e., it can only pass or fail.
|
|
1614
1814
|
*/
|
|
1615
1815
|
isBinaryCheck: boolean;
|
|
1816
|
+
/**
|
|
1817
|
+
* if true, this validation rule is advisory and does not impact the overall score.
|
|
1818
|
+
*/
|
|
1819
|
+
isAdvisory: boolean;
|
|
1616
1820
|
};
|
|
1617
1821
|
```
|
|
1618
1822
|
|
|
@@ -1712,21 +1916,24 @@ Below is the list of weights assigned to each validation rule:
|
|
|
1712
1916
|
|
|
1713
1917
|
| Validation Rule | Weight |
|
|
1714
1918
|
|------------------------------------------------|--------|
|
|
1715
|
-
| Check
|
|
1919
|
+
| Check Discoverability of Title and Summary | 16 |
|
|
1716
1920
|
| Check Title | 8 |
|
|
1717
1921
|
| Check Summary | 8 |
|
|
1922
|
+
| Check Thumbnail | 8 |
|
|
1718
1923
|
| Check Description | 8 |
|
|
1719
|
-
| Check Tags | 4 |
|
|
1720
|
-
| Check Discoverability of Title and Summary | 16 |
|
|
1721
1924
|
| Check Terms of Use | 8 |
|
|
1722
1925
|
| Check Credits (Attribution) | 8 |
|
|
1926
|
+
| Check Profile Description | 8 |
|
|
1927
|
+
| Check Feature Service Field Aliases | 8 |
|
|
1928
|
+
| Check Tags | 4 |
|
|
1929
|
+
| Check Profile Thumbnail | 2 |
|
|
1930
|
+
| Check Profile Full Name | 2 |
|
|
1931
|
+
| Check Feature Service Field Descriptions | 2 |
|
|
1932
|
+
| Check Feature Service Field Value Types | 2 |
|
|
1723
1933
|
| Check Sharing Level | 1 |
|
|
1724
1934
|
| Check Delete Protection Setting | 1 |
|
|
1725
1935
|
| Check Deprecated Setting | 1 |
|
|
1726
1936
|
| Check HTTPS in URL | 1 |
|
|
1727
|
-
| Check Profile Thumbnail | 2 |
|
|
1728
|
-
| Check Profile Full Name | 2 |
|
|
1729
|
-
| Check Profile Description | 8 |
|
|
1730
1937
|
|
|
1731
1938
|
## Issues
|
|
1732
1939
|
Find a bug or want to request a new feature? Please let us know by submitting an issue.
|