## API Reference - Core Functions

### `isValidTitle`
Validates an item's title against ArcGIS Online and Living Atlas-specific rules.

```ts
import { isValidTitle } from '@vannizhang/living-atlas-content-validator';

isValidTitle(
    item: IItem, 
    prohibitedList?: string[]
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose title needs validation.
- `prohibitedList` (`string[]`, optional): A list of prohibited words or strings. Defaults to `PROHIBITED_LIST`.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the title.

**Example:**
```ts
import { isValidTitle } from '@vannizhang/living-atlas-content-validator';

const item = {
    title: 'Mock Item Title',
    culture: 'en',
    // Other properties...
};

const prohibitedList = ['test', 'demo', 'eval'];

const validationInfo = isValidTitle(item, prohibitedList);
console.log(validationInfo);
```

---

### `isValidAccessInformation`
Validates an item's "Credits (Attribution)" field, which provides information on the source of the item and its copyright status.

```ts
import { isValidAccessInformation } from '@vannizhang/living-atlas-content-validator';

isValidAccessInformation(
    item: IItem
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose "Credits (Attribution)" field needs validation.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the "Credits (Attribution)" field.

**Example:**
```ts
import { isValidAccessInformation } from '@vannizhang/living-atlas-content-validator';

const item = {
    accessInformation: 'National Oceanic and Atmospheric Administration (NOAA)',
    // Other properties...
};

const validationInfo = isValidAccessInformation(item);
console.log(validationInfo);
```

---

### `isValidDescription`
Validates an item's description field.

```ts
import { isValidDescription } from '@vannizhang/living-atlas-content-validator';

isValidDescription(
    item: IItem
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose description field needs validation.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the description field.

**Example:**
```ts
import { isValidDescription } from '@vannizhang/living-atlas-content-validator';

const item = {
    description: 'This is a detailed description of the item. It provides comprehensive information about the data, its sources, and how to use it effectively.',
    // Other properties...
};

const validationInfo = isValidDescription(item);
console.log(validationInfo);
```
---

### `isValidLicenseInfo`
Validates an item's "Terms of Use (license info)" field.

```ts
import { isValidLicenseInfo } from '@vannizhang/living-atlas-content-validator';

isValidLicenseInfo(
    item: IItem
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose "Terms of Use (license info)" field needs validation.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the "Terms of Use (license info)" field.

**Example:**
```ts
import { isValidLicenseInfo } from '@vannizhang/living-atlas-content-validator';

const item = {
    licenseInfo: 'This data is licensed under the Open Data Commons Open Database License (ODbL). For more information, visit <a href="https://opendatacommons.org/licenses/odbl/">ODbL License</a>.',
    // Other properties...
};

const validationInfo = isValidLicenseInfo(item);
console.log(validationInfo);
```

---

### `isValidAccess`
Validates an item's sharing level to ensure it meets Living Atlas requirements.

```ts
import { isValidAccess } from '@vannizhang/living-atlas-content-validator';

isValidAccess(
    item: IItem
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose sharing level needs validation.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the sharing level.

**Example:**
```ts
import { isValidAccess } from '@vannizhang/living-atlas-content-validator';

const item = {
    access: 'public', // Sharing level of the item
    // Other properties...
};

const validationInfo = isValidAccess(item);
console.log(validationInfo);
```

---

### `isValidSummary`
Validates an item's summary (snippet) field.

```ts
import { isValidSummary } from '@vannizhang/living-atlas-content-validator';

isValidSummary(
    item: IItem,
    prohibitedList?: string[]
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose summary (snippet) field needs validation.
- `prohibitedList` (`string[]`, optional): A list of prohibited words or strings. Defaults to `PROHIBITED_LIST`.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the summary field.

**Example:**
```ts
import { isValidSummary } from '@vannizhang/living-atlas-content-validator';

const item = {
    snippet: 'This is a brief summary of the item, providing key details and context for users.',
    culture: 'en',
    // Other properties...
};

const prohibitedList = ['test', 'demo', 'eval'];

const validationInfo = isValidSummary(item, prohibitedList);
console.log(validationInfo);
```

---

### `isValidTags`
Validates an item's tags to ensure they meet ArcGIS Online and Living Atlas-specific rules.

```ts
import { isValidTags } from '@vannizhang/living-atlas-content-validator';

isValidTags(
    item: IItem,
    prohibitedList?: string[]
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose tags need validation.
- `prohibitedList` (`string[]`, optional): A list of prohibited tags. Defaults to `PROHIBITED_LIST`.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the tags.

**Example:**
```ts
import { isValidTags } from '@vannizhang/living-atlas-content-validator';

const item = {
    tags: ['climate', 'renewable energy', 'NOAA'],
    // Other properties...
};

const prohibitedList = ['test', 'demo', 'eval'];

const validationInfo = isValidTags(item, prohibitedList);
console.log(validationInfo);
```

---

### `isValidThumbnail`
Validates an item's thumbnail to ensure it meets Living Atlas-specific rules.

```ts
import { isValidThumbnail } from '@vannizhang/living-atlas-content-validator';

isValidThumbnail(
    item: IItem,
    thumbnailDimension?: { width: number; height: number }
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose thumbnail needs validation.
- `thumbnailDimension` (`{ width: number; height: number }`, optional): The dimensions of the item's thumbnail.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the thumbnail.

**Example:**
```ts
import { isValidThumbnail } from '@vannizhang/living-atlas-content-validator';

const item = {
    thumbnail: 'custom-thumbnail.png',
    // Other properties...
};

const thumbnailDimension = { width: 610, height: 405 };

const validationInfo = isValidThumbnail(item, thumbnailDimension);
console.log(validationInfo);
```

---

### `isDeprecated`
Validates an item's `contentStatus` to ensure it is not marked as **deprecated**.

```ts
import { isDeprecated } from '@vannizhang/living-atlas-content-validator';

isDeprecated(
    item: IItem
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose `contentStatus` needs validation.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the `contentStatus`.

**Example:**
```ts
import { isDeprecated } from '@vannizhang/living-atlas-content-validator';

const item = {
    contentStatus: 'deprecated', // Content status of the item
    // Other properties...
};

const validationInfo = isDeprecated(item);
console.log(validationInfo);
```

---

### `isDeleteProtectionEnabled`
Validates an item's `protected` property to ensure **Delete Protection** is enabled.

```ts
import { isDeleteProtectionEnabled } from '@vannizhang/living-atlas-content-validator';

isDeleteProtectionEnabled(
    item: IItem
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose `protected` property needs validation.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the `protected` property.

**Remark:**
- The delete protection status is **only exposed** to the item owner.

**Example:**
```ts
import { isDeleteProtectionEnabled } from '@vannizhang/living-atlas-content-validator';

const item = {
    protected: true, // Indicates whether Delete Protection is enabled
    // Other properties...
};

const validationInfo = isDeleteProtectionEnabled(item);
console.log(validationInfo);
```

---

### `isValidUserProfileName`
Validates an item owner's profile name to ensure it meets Living Atlas-specific rules.

```ts
import { isValidUserProfileName } from '@vannizhang/living-atlas-content-validator';

isValidUserProfileName(
    userProfile: IUser
): ValidationInfo
```

**Parameters:**
- `userProfile` (`IUser`, required): The user profile of the item's owner.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the user profile name.

**Example:**
```ts
import { isValidUserProfileName } from '@vannizhang/living-atlas-content-validator';

const userProfile = {
    fullName: 'John_Doe',
    culture: 'en',
    // Other properties...
};

const validationInfo = isValidUserProfileName(userProfile);
console.log(validationInfo);
```

---

### `isValidUserProfileDescription`
Validates an item owner's profile description to ensure it meets Living Atlas-specific rules.

```ts
import { isValidUserProfileDescription } from '@vannizhang/living-atlas-content-validator';

isValidUserProfileDescription(
    userProfile: IUser
): ValidationInfo
```

**Parameters:**
- `userProfile` (`IUser`, required): The user profile of the item's owner.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the user profile description.

**Example:**
```ts
import { isValidUserProfileDescription } from '@vannizhang/living-atlas-content-validator';

const userProfile = {
    description: 'I am a GIS professional with expertise in mapping and spatial analysis. Contact me at john.doe@example.com. Visit my portfolio at https://johndoe.com.',
    culture: 'en',
    // Other properties...
};

const validationInfo = isValidUserProfileDescription(userProfile);
console.log(validationInfo);
```

---

### `isValidUserProfileThumbnail`
Validates a user's profile thumbnail to ensure it meets Living Atlas-specific rules.

```ts
import { isValidUserProfileThumbnail } from '@vannizhang/living-atlas-content-validator';

isValidUserProfileThumbnail(
    userProfile: IUser
): ValidationInfo
```

**Parameters:**
- `userProfile` (`IUser`, required): The user profile of the item's owner.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the user profile thumbnail.

**Example:**
```ts
import { isValidUserProfileThumbnail } from '@vannizhang/living-atlas-content-validator';

const userProfile = {
    thumbnail: 'custom-thumbnail.png',
    // Other properties...
};

const validationInfo = isValidUserProfileThumbnail(userProfile);
console.log(validationInfo);
```

---


### `checkFeatureServiceFieldAliases`
This function checks the provided feature layers for relevant fields and evaluates whether those fields have aliases defined.

```ts
import { checkFeatureServiceFieldAliases } from '@vannizhang/living-atlas-content-validator';

checkFeatureServiceFieldAliases(
    item: IItem,
    featureLayers: FeatureLayerJSON[]
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item to validate
- `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.

**Returns:**
- `ValidationInfo`: An object containing the validation result, messages, and scoring for field aliases.

**Example:**
```ts
import { checkFeatureServiceFieldAliases } from '@vannizhang/living-atlas-content-validator';

const item = {
    id: 'mock-feature-layer-id',
    type: 'Feature Service',
    // Other properties...
};

const featureLayers = [
    {
        fields: [
            { name: 'field1', alias: 'Field 1' },
            { name: 'field2', alias: '' },
            // Other fields...
        ],
        // Other properties...
    }
    // Additional feature layers if needed...
];

const validationInfo = checkFeatureServiceFieldAliases(item, featureLayers);
console.log(validationInfo);
```

---

### `checkFeatureServiceFieldDescriptions`
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.

```ts
import { checkFeatureServiceFieldDescriptions } from '@vannizhang/living-atlas-content-validator';

checkFeatureServiceFieldDescriptions(
    item: IItem,
    featureLayers: FeatureLayerJSON[]
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item to validate, expected to be a feature layer.
- `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.

**Returns:**
- `ValidationInfo`: An object containing the validation result, messages, score, and scoring factors for field descriptions.

**Example:**
```ts
import { checkFeatureServiceFieldDescriptions } from '@vannizhang/living-atlas-content-validator';

const item = {
    id: 'mock-feature-layer-id',
    type: 'Feature Service',
    // Other properties...
};

const featureLayers = [
    {
        fields: [
            { name: 'field1', description: { value: 'Description for field 1' } },
            { name: 'field2', description: { value: '' } },
            // Other fields...
        ],
        // Other properties...
    }
    // Additional feature layers if needed...
];

const validationInfo = checkFeatureServiceFieldDescriptions(item, featureLayers);
console.log(validationInfo);
```

---

### `checkFeatureServiceFieldValueTypes`
This function checks the provided feature layers for relevant fields and evaluates whether those fields have a `fieldValueType` defined in their descriptions.

```ts
import { checkFeatureServiceFieldValueTypes } from '@vannizhang/living-atlas-content-validator';

checkFeatureServiceFieldValueTypes(
    item: IItem,
    featureLayers: FeatureLayerJSON[]
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item to validate.
- `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.

**Returns:**
- `ValidationInfo`: An object containing the validation result, messages, and scoring for field value types.


**Example:**
```ts
import { checkFeatureServiceFieldValueTypes } from '@vannizhang/living-atlas-content-validator';

const item = {
    id: 'mock-feature-layer-id',
    type: 'Feature Service',
    // Other properties...
};

const featureLayers = [
    {
        fields: [
            { name: 'field1', description: { fieldValueType: 'type1' } },
            { name: 'field2', description: { fieldValueType: '' } },
            // Other fields...
        ],
        // Other properties...
    }
    // Additional feature layers if needed...
];

const validationInfo = checkFeatureServiceFieldValueTypes(item, featureLayers);
console.log(validationInfo);
```

---

### `checkTitleAndSnippetSearchability`
Checks for required and recommended text in an item's title and summary (snippet) to ensure they are search-friendly.

```ts
import { checkTitleAndSnippetSearchability } from '@vannizhang/living-atlas-content-validator';

checkTitleAndSnippetSearchability(
    item: IItem,
    options?: {
        customPatternsForLocationInfo?: string[];
        customPatternsForDataVintageInfo?: string[];
        customPatternsForSourceInfo?: string[];
        customPatternsForTopicInfo?: string[];
    }
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item whose title and snippet need validation.
- `options` (optional): Custom patterns for matching specific information.
  - `customPatternsForLocationInfo` (`string[]`): Custom patterns for location information.
  - `customPatternsForDataVintageInfo` (`string[]`): Custom patterns for data vintage information.
  - `customPatternsForSourceInfo` (`string[]`): Custom patterns for source information.
  - `customPatternsForTopicInfo` (`string[]`): Custom patterns for topic information.

**Returns:**
- `ValidationInfo`: An object containing the validation results for the title and snippet.

**Example:**
```ts
import { checkTitleAndSnippetSearchability } from '@vannizhang/living-atlas-content-validator';

const item = {
    title: 'Global Earthquake Data 2023',
    snippet: 'Earthquake data from NOAA for the year 2023.',
    // Other properties...
};

const options = {
    customPatternsForLocationInfo: ['Global', 'New York'],
    customPatternsForDataVintageInfo: ['2023', 'Monthly'],
    customPatternsForSourceInfo: ['NOAA', 'Esri'],
    customPatternsForTopicInfo: ['Earthquakes', 'Public Health Dashboard'],
};

const validationInfo = checkTitleAndSnippetSearchability(item, options);
console.log(validationInfo);
```

---

### `checkFeatureServiceCDNSetting`
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.

```ts
import { checkFeatureServiceCDNSetting } from '@vannizhang/living-atlas-content-validator';
checkFeatureServiceCDNSetting(
    item: IItem,
    featureServiceAdminJSON: FeatureServiceAdminJSON
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online Feature Service item to validate
- `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.

**Returns:**
- `ValidationInfo`: An object containing the validation result, messages for the CDN setting.

**Example:**
```ts
import { checkFeatureServiceCDNSetting } from '@vannizhang/living-atlas-content-validator';

const item = {
    id: 'mock-feature-service-id',
    type: 'Feature Service',
    // Other properties...
};

const featureServiceAdminJSON = {
    adminServiceInfo: { 
        "name": "Mock Feature Service",
        "type": "FeatureServer",
        "cacheMaxAge": 3600,
    },
    // Other properties...
};

const validationInfo = checkFeatureServiceCDNSetting(item, featureServiceAdminJSON);
console.log(validationInfo);
```

---

### `checkFeatureServiceExportSetting`
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. 
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.

```ts
import { checkFeatureServiceExportSetting } from '@vannizhang/living-atlas-content-validator';
checkFeatureServiceExportSetting(
    item: IItem,
    featureServiceAdminJSON: FeatureServiceAdminJSON
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online Feature Service item to validate
- `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.

**Returns:**
- `ValidationInfo`: An object containing the validation result, messages for the export setting.


**Example:**
```ts
import { checkFeatureServiceExportSetting } from '@vannizhang/living-atlas-content-validator';

const item = {
    id: 'mock-feature-service-id',
    type: 'Feature Service',
    // Other properties...
};

const featureServiceAdminJSON = {
    capabilities: 'Query,Export',
    // Other properties...
};

const validationInfo = checkFeatureServiceExportSetting(item, featureServiceAdminJSON);
console.log(validationInfo);
```

---

### `checkItemExtent`

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.

```ts
import { checkItemExtent } from '@vannizhang/living-atlas-content-validator';
checkItemExtent(
    item: IItem
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online item to validate.

**Returns:**
- `ValidationInfo`: An object containing the validation result, messages, and scoring for the item's

**Example:**
```ts
import { checkItemExtent } from '@vannizhang/living-atlas-content-validator';
const item = {
    extent: [[-120, -45], [120, 45]], // Example extent
    // Other properties...
};
const validationInfo = checkItemExtent(item);
console.log(validationInfo);
```

---
### `checkFeatureServiceExtents`
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.

```ts
import { checkFeatureServiceExtents } from '@vannizhang/living-atlas-content-validator';
checkFeatureServiceExtents(
    item: IItem,
    {   
        featureLayers: FeatureLayerJSON[]
        featureServiceAdminJSON: FeatureServiceAdminJSON,
        featureServiceRootJSON: FeatureServiceRootJSON
        
    }
): ValidationInfo
```

**Parameters:**
- `item` (`IItem`, required): The ArcGIS Online Feature Service item to validate
- `options` (required): An object containing:
  - `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.
  - `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.
  - `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.

**Returns:**
- `ValidationInfo`: An object containing the validation result, messages, and scoring for the feature service extents.

**Example:**
```ts
import { checkFeatureServiceExtents } from '@vannizhang/living-atlas-content-validator';

// An ArcGIS Online Feature Service item to validate
const item = {
    id: 'mock-feature-service-id',
    type: 'Feature Service',
    // Other properties...
};

// feature layers associated with the Feature Service item
const featureLayers = [
    {
        id: 0,
        name: 'Mock Layer',
        extent: {
            xmin: -120,
            ymin: -45,
            xmax: 120,
            ymax: 45,
            spatialReference: { wkid: 4326 }
        }
    }
    // Additional feature layers if needed...
];

// Feature Service Admin JSON object
const featureServiceAdminJSON = {
    // Mock Feature Service Admin JSON properties...
    initialExtent: {
        xmin: -120,
        ymin: -45,
        xmax: 120,
        ymax: 45,
        spatialReference: { wkid: 4326 }
    },
    fullExtent: {
        xmin: -180,
        ymin: -90,
        xmax: 180,
        ymax: 90,
        spatialReference: { wkid: 4326 }
    },
};

const validationInfo = checkFeatureServiceExtents(item, { featureLayers, featureServiceAdminJSON });
``` 
---