@agility/content-fetch 2.0.9 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/.env +76 -0
  2. package/.github/workflows/ci-cd.yml +96 -0
  3. package/build.js +2 -0
  4. package/dist/api-client.d.ts +2 -2
  5. package/dist/browser.js +623 -564
  6. package/dist/methods/getContentItem.d.ts +12 -3
  7. package/dist/methods/getContentList.d.ts +18 -6
  8. package/dist/methods/getGallery.d.ts +12 -3
  9. package/dist/methods/getPage.d.ts +12 -3
  10. package/dist/methods/getPageByPath.d.ts +12 -3
  11. package/dist/methods/getSitemapFlat.d.ts +12 -3
  12. package/dist/methods/getSitemapNested.d.ts +12 -3
  13. package/dist/methods/getSyncContent.d.ts +12 -3
  14. package/dist/methods/getSyncPages.d.ts +12 -3
  15. package/dist/methods/getUrlRedirections.d.ts +12 -3
  16. package/dist/node.js +125 -67
  17. package/dist/types/Config.d.ts +5 -0
  18. package/dist/types/generated/index.d.ts +53 -0
  19. package/dist/types/generated/v1.d.ts +1336 -0
  20. package/dist/types/generated/v2.d.ts +1052 -0
  21. package/dist/types/index.d.ts +61 -4
  22. package/dist/types/sdk/Client.d.ts +12 -0
  23. package/dist/types/sdk/Config.d.ts +49 -0
  24. package/dist/types/sdk/EnvConfig.d.ts +6 -0
  25. package/dist/types/sdk/Filter.d.ts +14 -0
  26. package/dist/types/sdk/FilterLogicOperator.d.ts +17 -0
  27. package/dist/types/sdk/FilterOperator.d.ts +34 -0
  28. package/dist/types/sdk/SortDirection.d.ts +17 -0
  29. package/dist/types/sdk/errors/Errors.d.ts +22 -0
  30. package/dist/types/sdk/index.d.ts +18 -0
  31. package/dist/types/v2/ContentItem.d.ts +27 -0
  32. package/dist/types/v2/ContentZone.d.ts +14 -0
  33. package/dist/types/v2/MediaItem.d.ts +20 -0
  34. package/dist/types/v2/MediaItemMetaData.d.ts +17 -0
  35. package/dist/types/v2/Page.d.ts +40 -0
  36. package/dist/types/v2/SEO.d.ts +16 -0
  37. package/dist/types/v2/SitemapVisibility.d.ts +11 -0
  38. package/dist/types/v2/SystemProperties.d.ts +15 -0
  39. package/dist/types/v2/index.d.ts +26 -0
  40. package/dist/utils.d.ts +1 -1
  41. package/jest.integration.config.js +19 -0
  42. package/jest.unit.config.js +25 -0
  43. package/package.json +31 -10
@@ -1,4 +1,61 @@
1
- import FilterOperators from "./FilterOperator";
2
- import { FilterLogicOperators } from "./FilterLogicOperator";
3
- import { SortDirections } from "./SortDirection";
4
- export { FilterOperators, FilterLogicOperators, SortDirections };
1
+ /**
2
+ * Agility Content Fetch SDK Types
3
+ *
4
+ * This is the main entry point for all types used in the SDK.
5
+ * It combines generated API response types with SDK-specific types.
6
+ */
7
+ export { ApiTypes, V1, V2 } from './generated';
8
+ export * from './sdk';
9
+ import { ApiTypes } from './generated';
10
+ /**
11
+ * @deprecated Use ApiTypes.V1.ContentItem or ApiTypes.V2.ContentItem instead
12
+ * This will be removed in v4.0.0
13
+ */
14
+ export type ContentItem<T = {
15
+ [key: string]: any;
16
+ }> = ApiTypes.V1.ContentItem;
17
+ /**
18
+ * @deprecated Use ApiTypes.V1.Page or ApiTypes.V2.Page instead
19
+ * This will be removed in v4.0.0
20
+ */
21
+ export type Page = ApiTypes.V1.Page;
22
+ /**
23
+ * @deprecated Use ApiTypes.V1.Gallery or ApiTypes.V2.Gallery instead
24
+ * This will be removed in v4.0.0
25
+ */
26
+ export type Gallery = ApiTypes.V1.Gallery;
27
+ /**
28
+ * @deprecated Use ApiTypes.V1.MediaItem or ApiTypes.V2.MediaItem instead
29
+ * This will be removed in v4.0.0
30
+ */
31
+ export type MediaItem = ApiTypes.V1.MediaItem;
32
+ /**
33
+ * @deprecated Use ApiTypes.V1.SitemapFlat or ApiTypes.V2.SitemapFlat instead
34
+ * This will be removed in v4.0.0
35
+ */
36
+ export type SitemapFlat = ApiTypes.V1.SitemapFlat;
37
+ /**
38
+ * @deprecated Use ApiTypes.V1.SitemapNested or ApiTypes.V2.SitemapNested instead
39
+ * This will be removed in v4.0.0
40
+ */
41
+ export type SitemapNested = ApiTypes.V1.SitemapNested;
42
+ /**
43
+ * @deprecated Use ApiTypes.V1.ContentList or ApiTypes.V2.ContentList instead
44
+ * This will be removed in v4.0.0
45
+ */
46
+ export type ContentList = ApiTypes.V1.ContentList;
47
+ /**
48
+ * @deprecated Use ApiTypes.V1.ContentItemSync or ApiTypes.V2.ContentItemSync instead
49
+ * This will be removed in v4.0.0
50
+ */
51
+ export type SyncContent = ApiTypes.V1.ContentItemSync;
52
+ /**
53
+ * @deprecated Use ApiTypes.V1.PageSync or ApiTypes.V2.PageSync instead
54
+ * This will be removed in v4.0.0
55
+ */
56
+ export type SyncPages = ApiTypes.V1.PageSync;
57
+ /**
58
+ * @deprecated Use ApiTypes.V1.UrlRedirection or ApiTypes.V2.UrlRedirection instead
59
+ * This will be removed in v4.0.0
60
+ */
61
+ export type URLRedirection = ApiTypes.V1.UrlRedirection;
@@ -0,0 +1,12 @@
1
+ import { Config } from "./Config";
2
+ export interface RequestParams {
3
+ url: string;
4
+ method: string;
5
+ baseURL: string | null;
6
+ headers: any;
7
+ params: any;
8
+ }
9
+ export interface ApiClientInstance {
10
+ config: Config;
11
+ makeRequest(req: RequestParams): Promise<any>;
12
+ }
@@ -0,0 +1,49 @@
1
+ export interface Config {
2
+ /**
3
+ * The optional baseUrl for the API. If not provided, the API will use the default baseUrl for the instance.
4
+ * This is mostly used for testing purposes.
5
+ */
6
+ baseUrl?: string | null;
7
+ /**
8
+ * If true, the API will use the Preview API. If false, it will use the Fetch API. Default is false.
9
+ * Make sure the API Key provided matches this value.
10
+ */
11
+ isPreview?: boolean;
12
+ /**
13
+ * The guid that represents your instance.
14
+ */
15
+ guid?: string | null;
16
+ /**
17
+ * The Fetch or Preview API key.
18
+ */
19
+ apiKey?: string | null;
20
+ locale?: string | null;
21
+ /**
22
+ * The API version to use. 'v1' uses legacy string-based data types, 'v2' uses proper data types.
23
+ * Default is 'v2'. Specify 'v1' only if you need legacy compatibility.
24
+ */
25
+ apiVersion?: 'v1' | 'v2';
26
+ /**
27
+ * Additional headers to include in the request.
28
+ */
29
+ headers?: {
30
+ [key: string]: string;
31
+ };
32
+ requiresGuidInHeaders?: boolean;
33
+ /**
34
+ * The logging level. Default is 'warn'.
35
+ */
36
+ logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent';
37
+ /**
38
+ * Used for debugging purposes. Default is false.
39
+ */
40
+ debug?: boolean;
41
+ /**
42
+ * Optional Caching options. Caching is disabled by default.
43
+ * This is mostly used for Next.js and other server-side rendering frameworks.
44
+ */
45
+ caching?: {
46
+ maxAge?: number;
47
+ };
48
+ fetchConfig?: any;
49
+ }
@@ -0,0 +1,6 @@
1
+ export interface EnvConfig {
2
+ baseUrl: string | null;
3
+ isPreview: boolean;
4
+ guid: string | null;
5
+ apiKey: string | null;
6
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Defines a **Filter** for filtering lists.
3
+ * @typedef Filter
4
+ * @memberof AgilityFetch.Types
5
+ * @property {string} property - The property to filter the request on.
6
+ * @property {AgilityFetch.Types.FilterOperator} operator - The operator to use for the filter.
7
+ * @property {string} value - The value to compare for the property.
8
+ */
9
+ export interface Filter {
10
+ property: string;
11
+ operator: FilterOperator | "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "range" | "like" | "in" | "contains";
12
+ value: string;
13
+ }
14
+ export type FilterOperator = "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "range" | "like" | "in" | "contains";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Defines a FilterLogicOperator - Refer to {@link AgilityFetch.Types.FilterLogicOperators} Enum for available Logic Operators.
3
+ * @typedef {string} FilterLogicOperator
4
+ * @memberOf AgilityFetch.Types
5
+ */
6
+ /**
7
+ * Enum of FilterLogicOperators.
8
+ * @enum {FilterLogicOperator} FilterLogicOperators
9
+ * @memberOf AgilityFetch.Types
10
+ * @default AND
11
+ * @readonly
12
+ */
13
+ export type FilterLogicOperator = "AND" | "OR";
14
+ export declare enum FilterLogicOperators {
15
+ AND = "AND",
16
+ OR = "OR"
17
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Defines a FilterOperator - Refer to {@link AgilityFetch.Types.FilterOperators} Enum for available Operators.
3
+ * @typedef {string} FilterOperator
4
+ * @memberOf AgilityFetch.Types
5
+ */
6
+ /**
7
+ * Enum of FilterOperators.
8
+ * @enum {FilterOperator} FilterOperators
9
+ * @memberOf AgilityFetch.Types
10
+ * @readonly
11
+ */
12
+ declare enum FilterOperators {
13
+ /** Equal To */
14
+ EQUAL_TO = "eq",
15
+ /** Not Equal To */
16
+ NOT_EQUAL_TO = "ne",
17
+ /** Less Than */
18
+ LESS_THAN = "lt",
19
+ /** Less Than or Equal To */
20
+ LESS_THAN_OR_EQUAL_TO = "lte",
21
+ /** Greater Than */
22
+ GREATER_THAN = "gt",
23
+ /** Greater Than or Equal To */
24
+ GREATER_THAN_OR_EQUAL_TO = "gte",
25
+ /** Range */
26
+ RANGE = "range",
27
+ /** Like (string only) */
28
+ LIKE = "like",
29
+ /** In (multiple values) */
30
+ IN = "in",
31
+ /** Contains (string only) */
32
+ CONTAINS = "contains"
33
+ }
34
+ export default FilterOperators;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Defines a Sort Direction - Refer to {@link AgilityFetch.Types.SortDirections} Enum for available Sort Directions.
3
+ * @typedef {string} SortDirection
4
+ * @memberOf AgilityFetch.Types
5
+ */
6
+ /**
7
+ * Enum of SortDirections.
8
+ * @enum {SortDirection} SortDirections
9
+ * @memberOf AgilityFetch.Types
10
+ * @default ASC
11
+ * @readonly
12
+ */
13
+ export type SortDirection = "asc" | "desc";
14
+ export declare enum SortDirections {
15
+ ASC = "asc",
16
+ DESC = "desc"
17
+ }
@@ -0,0 +1,22 @@
1
+ export declare class EvalError extends Error {
2
+ constructor(message?: string, asserter?: any);
3
+ }
4
+ export declare class RangeError extends Error {
5
+ constructor(message?: string, asserter?: any);
6
+ }
7
+ export declare class ReferenceError extends Error {
8
+ constructor(message?: string, asserter?: any);
9
+ }
10
+ export declare class SyntaxError extends Error {
11
+ constructor(message?: string, asserter?: any);
12
+ }
13
+ export declare class TypeError extends Error {
14
+ /**
15
+ * @param {string} message The error message
16
+ * @param {Function} [asserter] The assertion function that threw the error. Removes stack-trace noise if provided.
17
+ */
18
+ constructor(message: string, asserter?: any);
19
+ }
20
+ export declare class URIError extends Error {
21
+ constructor(message?: string, asserter?: any);
22
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * SDK-Specific Types
3
+ *
4
+ * These types are specific to the SDK implementation and are manually maintained.
5
+ * They include configuration, client interfaces, filtering, and error types.
6
+ */
7
+ export * from './Config';
8
+ export * from './EnvConfig';
9
+ export * from './Client';
10
+ export * from './Filter';
11
+ export * from './FilterOperator';
12
+ export * from './FilterLogicOperator';
13
+ export * from './SortDirection';
14
+ export * from './errors/Errors';
15
+ import FilterOperators from './FilterOperator';
16
+ import { FilterLogicOperators } from './FilterLogicOperator';
17
+ import { SortDirections } from './SortDirection';
18
+ export { FilterOperators, FilterLogicOperators, SortDirections };
@@ -0,0 +1,27 @@
1
+ import { SEOPropertiesV2 } from "./SEO";
2
+ interface ContentItemPropertiesV2 {
3
+ state: number;
4
+ modified: Date;
5
+ versionID: number;
6
+ referenceName: string;
7
+ definitionName: string;
8
+ itemOrder: number;
9
+ }
10
+ /**
11
+ * Defines a **Content Item** in the CMS (V2 API with proper data types)
12
+ * @typedef ContentItemV2
13
+ * @memberof AgilityFetch.Types.V2
14
+ * @property {number} contentID - The unique ID of the content item in this language.
15
+ * @property {ContentItemPropertiesV2} properties - The system properties of the content item.
16
+ * @property {Object} fields - A dictionary of the fields and the values of the content item.
17
+ * @property {SEOPropertiesV2} seo - Any SEO related fields for the content item. This is only returned for Dynamic Page Items.
18
+ */
19
+ export interface ContentItemV2<T = {
20
+ [key: string]: any;
21
+ }> {
22
+ contentID: number;
23
+ properties: ContentItemPropertiesV2;
24
+ fields: T;
25
+ seo?: SEOPropertiesV2;
26
+ }
27
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Defines a **Content Zone** on a page in the CMS (V2 API with proper data types).
3
+ * @typedef ContentZoneV2
4
+ * @memberof AgilityFetch.Types.V2
5
+ * @property {string} module - The reference name of the module definition of this module.
6
+ * @property {AgilityFetch.Types.V2.ContentItemV2} item - The contentItem representing the content of this module.
7
+ */
8
+ import { ContentItemV2 } from "./ContentItem";
9
+ import { ContentReference } from "../ContentReference";
10
+ export interface ContentZoneV2 {
11
+ module: string;
12
+ item: ContentItemV2 | ContentReference;
13
+ customData?: any;
14
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Defines a **MediaItem** in the CMS (V2 API with proper data types)
3
+ * @typedef MediaItemV2
4
+ * @memberof AgilityFetch.Types.V2
5
+ * @property {number} mediaID - The unique ID of the media item.
6
+ * @property {string} fileName - The file name of the media item.
7
+ * @property {string} url - The url of the media item.
8
+ * @property {number} size - The size of the media item in bytes.
9
+ * @property {Date} modifiedOn - The last modified date and time of the media item.
10
+ * @property {AgilityFetch.Types.V2.MediaItemMetaDataV2} metaData - Meta data for the media item.
11
+ */
12
+ import { MediaItemMetaDataV2 } from "./MediaItemMetaData";
13
+ export interface MediaItemV2 {
14
+ mediaID: number;
15
+ fileName: string;
16
+ url: string;
17
+ size: number;
18
+ modifiedOn: Date;
19
+ metaData: MediaItemMetaDataV2;
20
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Defines a **MediaItemMetaData** in the CMS (V2 API with proper data types)
3
+ * @typedef MediaItemMetaDataV2
4
+ * @memberof AgilityFetch.Types.V2
5
+ * @property {string} Title - The title meta data of the media item.
6
+ * @property {string} Description - The description meta data of the media item.
7
+ * @property {string} LinkUrl - The link url meta data of the media item.
8
+ * @property {number} pixelHeight - The height in pixels of the media item.
9
+ * @property {number} pixelWidth - The width in pixels of the media item.
10
+ */
11
+ export interface MediaItemMetaDataV2 {
12
+ Title: string;
13
+ Description: string;
14
+ LinkUrl: string;
15
+ pixelHeight: number;
16
+ pixelWidth: number;
17
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Defines a **Page** in the CMS (V2 API with proper data types).
3
+ * @typedef PageV2
4
+ * @memberof AgilityFetch.Types.V2
5
+ * @property {number} pageID - The unique ID of the page in this language.
6
+ * @property {string} name - The friendly url slug for the page - this is used to make up the URL.
7
+ * @property {string} path - The url path for this page.
8
+ * @property {string} title - The page title for the page, used for SEO and appears in the browser bar/tab.
9
+ * @property {string} menuText - And alternate text field, often used in dynamic menu generation.
10
+ * @property {string} pageType - The type of page. Valid values include *static*, *dynamic*, *dynamic_node*, *link*, and *folder*.
11
+ * @property {string} templateName - The name of the Page Template this page uses.
12
+ * @property {boolean} securePage - This value represents whether this page should be secured within the website.
13
+ * @property {AgilityFetch.Types.V2.SystemPropertiesV2} properties The system properties of this page item.
14
+ * @property {Object.<string, AgilityFetch.Types.V2.ContentZoneV2>} zones - Contains a dictionary of content zones for this page and the modules in each zone.
15
+ * @property {string} [redirectUrl] - If this page is a *link*, then this property will show the intended destination redirect.
16
+ * @property {number} [dynamicItemContentID] - If this page is a dynamic page, then this property will show the associated contentID of the dynamic content item.
17
+ * @property {AgilityFetch.Types.V2.SitemapVisibilityV2} visible - Object that contains properties pertaining to the intended visibility of this page for seo and menus.
18
+ */
19
+ import { ContentZoneV2 } from "./ContentZone";
20
+ import { SystemPropertiesV2 } from "./SystemProperties";
21
+ import { SitemapVisibilityV2 } from "./SitemapVisibility";
22
+ import { SEOPropertiesV2 } from "./SEO";
23
+ export interface PageV2 {
24
+ pageID: number;
25
+ name: string;
26
+ path: string;
27
+ title: string;
28
+ menuText: string;
29
+ pageType: "static" | "dynamic" | "dynamic_node" | "link" | "folder";
30
+ templateName: string;
31
+ securePage: boolean;
32
+ properties: SystemPropertiesV2;
33
+ zones: {
34
+ [key: string]: ContentZoneV2[];
35
+ };
36
+ redirectUrl?: string;
37
+ dynamicItemContentID?: number;
38
+ visible: SitemapVisibilityV2;
39
+ seo?: SEOPropertiesV2;
40
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Defines the SEO properties for a content item (V2 API with proper data types).
3
+ * @interface SEOPropertiesV2
4
+ * @property {string} metaDescription - The meta description for the content item.
5
+ * @property {string} metaKeywords - The meta keywords for the content item.
6
+ * @property {string} metaHTML - The meta HTML for the content item.
7
+ * @property {boolean} menuVisible - Whether the content item should be visible in the menu.
8
+ * @property {boolean} sitemapVisible - Whether the content item should be visible in the sitemap.
9
+ */
10
+ export interface SEOPropertiesV2 {
11
+ metaDescription: string;
12
+ metaKeywords: string;
13
+ metaHTML: string;
14
+ menuVisible: boolean;
15
+ sitemapVisible: boolean;
16
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Defines a page's visibility (V2 API with proper data types).
3
+ * @typedef SitemapVisibilityV2
4
+ * @memberof AgilityFetch.Types.V2
5
+ * @property {boolean} menu - If set to true, this page should be hidden from menus.
6
+ * @property {boolean} sitemap - If set to true, this page should be hidden from the sitemap and not accessible by robots.
7
+ */
8
+ export interface SitemapVisibilityV2 {
9
+ menu: boolean;
10
+ sitemap: boolean;
11
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Defines the common **System Properties** of pages and content items in the CMS (V2 API with proper data types).
3
+ * @typedef SystemPropertiesV2
4
+ * @memberof AgilityFetch.Types.V2
5
+ * @property {Date} created - The date/time this item was created.
6
+ * @property {Date} modified - The date/time this item was last modified.
7
+ * @property {number} state - The **state** of this content item. **1** = *Staging*, **2** = *Published*, **3** = *Deleted*, **4** = *Approved*, **5** = *AwaitingApproval*, **6** = *Declined*, **7** = *Unpublished*
8
+ * @property {number} versionID - The unique versionID of this content item.
9
+ */
10
+ export interface SystemPropertiesV2 {
11
+ created: Date;
12
+ modified: Date;
13
+ state: 1 | 2 | 3 | 4 | 5 | 6 | 7;
14
+ versionID: number;
15
+ }
@@ -0,0 +1,26 @@
1
+ export * from './ContentItem';
2
+ export * from './ContentZone';
3
+ export * from './MediaItem';
4
+ export * from './MediaItemMetaData';
5
+ export * from './Page';
6
+ export * from './SEO';
7
+ export * from './SitemapVisibility';
8
+ export * from './SystemProperties';
9
+ export { Config } from '../Config';
10
+ export { ContentList } from '../ContentList';
11
+ export { ContentReference } from '../ContentReference';
12
+ export { Filter } from '../Filter';
13
+ export { FilterLogicOperator } from '../FilterLogicOperator';
14
+ export { default as FilterOperators } from '../FilterOperator';
15
+ export { Gallery } from '../Gallery';
16
+ export { SortDirection } from '../SortDirection';
17
+ export { SitemapFlat } from '../SitemapFlat';
18
+ export { SitemapFlatItem } from '../SitemapFlatItem';
19
+ export { SitemapNested } from '../SitemapNested';
20
+ export { SitemapNestedItem } from '../SitemapNestedItem';
21
+ export { SyncContent } from '../SyncContent';
22
+ export { SyncPages } from '../SyncPages';
23
+ export { URLRedirection } from '../UrlRedirection';
24
+ export { URLRedirectionResponse } from '../UrlRedirectionResponse';
25
+ export { EnvConfig } from '../EnvConfig';
26
+ export * from '../errors/Errors';
package/dist/utils.d.ts CHANGED
@@ -8,7 +8,7 @@ declare function logInfo({ config, message }: LogProps): void;
8
8
  declare function logWarning({ config, message }: LogProps): void;
9
9
  declare function logError({ config, message }: LogProps): void;
10
10
  declare function buildRequestUrlPath(config: any, locale: any): string;
11
- declare function buildPathUrl(contentType: any, referenceName: any, skip: any, take: any, sort: any, direction: any, filters: any, filtersLogicOperator: any, filterString: any, contentLinkDepth: any, expandAllContentLinks: any): string;
11
+ declare function buildPathUrl(contentType: any, referenceName: any, skip: any, take: any, sort: any, direction: any, filters: any, filtersLogicOperator: any, filterString: any, contentLinkDepth: any, expandAllContentLinks: any, fields: any): string;
12
12
  declare function buildAuthHeader(config: any): any;
13
13
  declare function isHttps(url: any): boolean;
14
14
  export { buildPathUrl, buildAuthHeader, buildRequestUrlPath, isHttps, logError, logDebug, logInfo, logWarning };
@@ -0,0 +1,19 @@
1
+ const baseConfig = require('./jest.config.js');
2
+
3
+ // Suppress dotenv logs before any tests run
4
+ process.env.DOTENV_CONFIG_SILENT = 'true';
5
+
6
+ module.exports = {
7
+ ...baseConfig,
8
+ displayName: 'Integration Tests',
9
+ testMatch: [
10
+ '<rootDir>/test/integration/**/*.integration.test.ts',
11
+ '<rootDir>/test/integration/**/*.integration.test.js'
12
+ ],
13
+ testTimeout: 30000, // Integration tests can be slower
14
+ setupFilesAfterEnv: [
15
+ '<rootDir>/test/integration/setup.ts'
16
+ ],
17
+ // Don't collect coverage for integration tests
18
+ collectCoverage: false
19
+ };
@@ -0,0 +1,25 @@
1
+ const baseConfig = require('./jest.config.js');
2
+
3
+ module.exports = {
4
+ ...baseConfig,
5
+ displayName: 'Unit Tests',
6
+ testMatch: [
7
+ '<rootDir>/test/unit/**/*.test.ts',
8
+ '<rootDir>/test/unit/**/*.test.js'
9
+ ],
10
+ testTimeout: 5000, // Unit tests should be fast
11
+ collectCoverageFrom: [
12
+ 'src/**/*.{ts,js}',
13
+ '!src/**/*.d.ts',
14
+ '!src/types/generated/**',
15
+ '!**/node_modules/**'
16
+ ],
17
+ coverageThreshold: {
18
+ global: {
19
+ branches: 80,
20
+ functions: 80,
21
+ lines: 80,
22
+ statements: 80
23
+ }
24
+ }
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agility/content-fetch",
3
- "version": "2.0.9",
3
+ "version": "2.1.0",
4
4
  "description": "JS/TS library for the Agility Fetch API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,9 +19,20 @@
19
19
  },
20
20
  "scripts": {
21
21
  "clean": "rimraf dist",
22
+ "types:generate": "npm run types:generate:dev",
23
+ "types:generate:dev": "npm run types:generate:dev:v1 && npm run types:generate:dev:v2",
24
+ "types:generate:dev:v1": "openapi-typescript https://api-dev.aglty.io/swagger/v1/swagger.json -o src/types/generated/v1.ts",
25
+ "types:generate:dev:v2": "openapi-typescript https://api-dev.aglty.io/swagger/v2/swagger.json -o src/types/generated/v2.ts",
26
+ "types:generate:prod": "npm run types:generate:prod:v1 && npm run types:generate:prod:v2",
27
+ "types:generate:prod:v1": "openapi-typescript https://api.aglty.io/swagger/v1/swagger.json -o src/types/generated/v1.ts",
28
+ "types:generate:prod:v2": "openapi-typescript https://api.aglty.io/swagger/v2/swagger.json -o src/types/generated/v2.ts",
22
29
  "build": "node build.js",
23
- "prepare": "yarn build",
24
- "test": "jest",
30
+ "prepare": "npm run build",
31
+ "test": "npm run test:all",
32
+ "test:unit": "jest --config jest.unit.config.js",
33
+ "test:integration": "jest --config jest.integration.config.js",
34
+ "test:all": "npm run test:unit && npm run test:integration",
35
+ "test:legacy": "jest",
25
36
  "generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
26
37
  },
27
38
  "keywords": [
@@ -38,16 +49,26 @@
38
49
  "Aaron Taylor"
39
50
  ],
40
51
  "license": "MIT",
41
- "dependencies": {},
42
52
  "devDependencies": {
43
53
  "@types/jest": "^29.5.3",
44
54
  "@types/node": "^18.11.9",
45
55
  "agility-jsdoc-template": "1.0.3",
46
- "esbuild": "^0.19.0",
47
- "jest": "^29.6.2",
48
- "npm-dts": "^1.3.12",
49
- "rimraf": "^5.0.1",
50
- "ts-jest": "^29.1.1",
56
+ "dotenv": "^17.2.3",
57
+ "esbuild": "0.25.0",
58
+ "jest": "30.0.0",
59
+ "npm-dts": "1.3.13",
60
+ "openapi-typescript": "^7.9.1",
61
+ "rimraf": "6.0.1",
62
+ "ts-jest": "^29.4.4",
51
63
  "typescript": "^5.1.6"
64
+ },
65
+ "overrides": {
66
+ "braces": "^3.0.3",
67
+ "micromatch": "^4.0.8",
68
+ "cross-spawn": "^7.0.5",
69
+ "brace-expansion": "^1.1.12",
70
+ "tmp": "^0.2.4",
71
+ "@babel/helpers": "^7.26.10",
72
+ "glob": "^10.0.0"
52
73
  }
53
- }
74
+ }