@agility/content-fetch 2.0.10 → 3.0.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.
- package/.env +76 -0
- package/.github/workflows/ci-cd.yml +64 -0
- package/build.js +2 -0
- package/dist/api-client.d.ts +2 -2
- package/dist/browser.js +624 -569
- package/dist/methods/getContentItem.d.ts +12 -3
- package/dist/methods/getContentList.d.ts +18 -6
- package/dist/methods/getGallery.d.ts +12 -3
- package/dist/methods/getPage.d.ts +12 -3
- package/dist/methods/getPageByPath.d.ts +12 -3
- package/dist/methods/getSitemapFlat.d.ts +12 -3
- package/dist/methods/getSitemapNested.d.ts +12 -3
- package/dist/methods/getSyncContent.d.ts +12 -3
- package/dist/methods/getSyncPages.d.ts +12 -3
- package/dist/methods/getUrlRedirections.d.ts +12 -3
- package/dist/node.js +117 -63
- package/dist/types/Config.d.ts +5 -0
- package/dist/types/generated/index.d.ts +53 -0
- package/dist/types/generated/v1.d.ts +1336 -0
- package/dist/types/generated/v2.d.ts +1052 -0
- package/dist/types/generated/v3.d.ts +1052 -0
- package/dist/types/index.d.ts +61 -4
- package/dist/types/sdk/Client.d.ts +12 -0
- package/dist/types/sdk/Config.d.ts +49 -0
- package/dist/types/sdk/EnvConfig.d.ts +6 -0
- package/dist/types/sdk/Filter.d.ts +14 -0
- package/dist/types/sdk/FilterLogicOperator.d.ts +17 -0
- package/dist/types/sdk/FilterOperator.d.ts +34 -0
- package/dist/types/sdk/SortDirection.d.ts +17 -0
- package/dist/types/sdk/errors/Errors.d.ts +22 -0
- package/dist/types/sdk/index.d.ts +18 -0
- package/dist/types/v2/ContentItem.d.ts +27 -0
- package/dist/types/v2/ContentZone.d.ts +14 -0
- package/dist/types/v2/MediaItem.d.ts +20 -0
- package/dist/types/v2/MediaItemMetaData.d.ts +17 -0
- package/dist/types/v2/Page.d.ts +40 -0
- package/dist/types/v2/SEO.d.ts +16 -0
- package/dist/types/v2/SitemapVisibility.d.ts +11 -0
- package/dist/types/v2/SystemProperties.d.ts +15 -0
- package/dist/types/v2/index.d.ts +26 -0
- package/dist/utils.d.ts +1 -1
- package/jest.integration.config.js +19 -0
- package/jest.unit.config.js +26 -0
- package/package.json +31 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ApiClientInstance } from '../types/
|
|
1
|
+
import { ApiClientInstance } from '../types/sdk';
|
|
2
|
+
import { ApiTypes } from '../types/generated';
|
|
2
3
|
/**
|
|
3
4
|
* Gets the details of a content item by their Content ID.
|
|
4
5
|
* @memberof AgilityFetch.Client.Content
|
|
@@ -30,7 +31,6 @@ import { ApiClientInstance } from '../types/Client';
|
|
|
30
31
|
* });
|
|
31
32
|
*
|
|
32
33
|
*/
|
|
33
|
-
import { ContentItem } from '../types/ContentItem';
|
|
34
34
|
export interface ContentItemRequestParams {
|
|
35
35
|
contentID: number;
|
|
36
36
|
locale?: string;
|
|
@@ -38,5 +38,14 @@ export interface ContentItemRequestParams {
|
|
|
38
38
|
contentLinkDepth?: number;
|
|
39
39
|
expandAllContentLinks?: boolean;
|
|
40
40
|
}
|
|
41
|
-
declare function getContentItem
|
|
41
|
+
declare function getContentItem(this: ApiClientInstance & {
|
|
42
|
+
config: {
|
|
43
|
+
apiVersion: 'v1';
|
|
44
|
+
};
|
|
45
|
+
}, requestParams: ContentItemRequestParams): Promise<ApiTypes.V1.ContentItem>;
|
|
46
|
+
declare function getContentItem(this: ApiClientInstance & {
|
|
47
|
+
config: {
|
|
48
|
+
apiVersion: 'v3';
|
|
49
|
+
};
|
|
50
|
+
}, requestParams: ContentItemRequestParams): Promise<ApiTypes.V3.ContentItem>;
|
|
42
51
|
export default getContentItem;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { Filter } from '../types/
|
|
2
|
-
import {
|
|
3
|
-
import { SortDirection } from '../types/SortDirection';
|
|
4
|
-
import { ContentList } from '../types/ContentList';
|
|
5
|
-
import { ApiClientInstance } from '../types/Client';
|
|
1
|
+
import { Filter, FilterLogicOperator, SortDirection, ApiClientInstance } from '../types/sdk';
|
|
2
|
+
import { ApiTypes } from '../types/generated';
|
|
6
3
|
/**
|
|
7
4
|
* Retrieves a list of content items by reference name.
|
|
8
5
|
* @memberof AgilityFetch.Client.Content
|
|
@@ -16,6 +13,7 @@ import { ApiClientInstance } from '../types/Client';
|
|
|
16
13
|
* @param {number} [requestParams.skip] - The number of items to skip from the list. Default is **0**. Used for implementing pagination.
|
|
17
14
|
* @param {string} [requestParams.sort] - The field to sort the results by. Example **fields.title** or **properties.modified**.
|
|
18
15
|
* @param {AgilityFetch.Types.SortDirection} [requestParams.direction] - The direction to sort the results by.
|
|
16
|
+
* @param {string} [requestParams.fields] - A comma separated list of the fields to return. Example **fields.title,fields.description**.
|
|
19
17
|
* @param {Array.<AgilityFetch.Types.Filter>} [requestParams.filters] - The collection of filters to filter the results by.
|
|
20
18
|
* @param {AgilityFetch.Types.FilterLogicOperator} [requestParams.filtersLogicOperator] - The logic operator to combine multiple filters.
|
|
21
19
|
* @returns {Promise<AgilityFetch.Types.ContentList>} - Returns a list of content items.
|
|
@@ -48,6 +46,7 @@ import { ApiClientInstance } from '../types/Client';
|
|
|
48
46
|
* locale: 'en-us',
|
|
49
47
|
* take: 50,
|
|
50
48
|
* skip: 0,
|
|
49
|
+
* fields: 'fields.title,fields.description,properties.modified',
|
|
51
50
|
* filters: [
|
|
52
51
|
* {property: 'fields.title', operator: api.types.FilterOperators.EQUAL_TO, value: '"How this site works"'},
|
|
53
52
|
* {property: 'fields.details', operator: api.types.FilterOperators.LIKE, value: '"Lorem ipsum dolar"'}
|
|
@@ -99,6 +98,10 @@ export interface ContentListRequestParams {
|
|
|
99
98
|
* The direction to sort the results by.
|
|
100
99
|
*/
|
|
101
100
|
direction?: SortDirection;
|
|
101
|
+
/**
|
|
102
|
+
* A comma separated list of the fields to return.
|
|
103
|
+
*/
|
|
104
|
+
fields?: string;
|
|
102
105
|
/**
|
|
103
106
|
* Option: you can provide a plain text filter string as opposed to an array of filters. This is useful if you have brackets in your filter expression.
|
|
104
107
|
*/
|
|
@@ -110,5 +113,14 @@ export interface ContentListRequestParams {
|
|
|
110
113
|
filters?: Array<Filter>;
|
|
111
114
|
filtersLogicOperator?: FilterLogicOperator;
|
|
112
115
|
}
|
|
113
|
-
declare function getContentList(this: ApiClientInstance
|
|
116
|
+
declare function getContentList(this: ApiClientInstance & {
|
|
117
|
+
config: {
|
|
118
|
+
apiVersion: 'v1';
|
|
119
|
+
};
|
|
120
|
+
}, requestParams: ContentListRequestParams): Promise<ApiTypes.V1.ContentList>;
|
|
121
|
+
declare function getContentList(this: ApiClientInstance & {
|
|
122
|
+
config: {
|
|
123
|
+
apiVersion: 'v3';
|
|
124
|
+
};
|
|
125
|
+
}, requestParams: ContentListRequestParams): Promise<ApiTypes.V3.ContentList>;
|
|
114
126
|
export default getContentList;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ApiClientInstance } from '../types/sdk';
|
|
2
|
+
import { ApiTypes } from '../types/generated';
|
|
3
3
|
/**
|
|
4
4
|
* Gets the details of a gallery by their Gallery ID.
|
|
5
5
|
* @memberof AgilityFetch.Client.Media
|
|
@@ -29,5 +29,14 @@ import { ApiClientInstance } from '../types/Client';
|
|
|
29
29
|
export interface GalleryRequestParams {
|
|
30
30
|
galleryID: number;
|
|
31
31
|
}
|
|
32
|
-
declare function getGallery(this: ApiClientInstance
|
|
32
|
+
declare function getGallery(this: ApiClientInstance & {
|
|
33
|
+
config: {
|
|
34
|
+
apiVersion: 'v1';
|
|
35
|
+
};
|
|
36
|
+
}, requestParams: GalleryRequestParams): Promise<ApiTypes.V1.Gallery>;
|
|
37
|
+
declare function getGallery(this: ApiClientInstance & {
|
|
38
|
+
config: {
|
|
39
|
+
apiVersion: 'v3';
|
|
40
|
+
};
|
|
41
|
+
}, requestParams: GalleryRequestParams): Promise<ApiTypes.V3.Gallery>;
|
|
33
42
|
export default getGallery;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ApiClientInstance } from '../types/sdk';
|
|
2
|
+
import { ApiTypes } from '../types/generated';
|
|
3
3
|
/**
|
|
4
4
|
* Gets the details of a page by its Page ID.
|
|
5
5
|
* @memberof AgilityFetch.Client.Pages
|
|
@@ -37,5 +37,14 @@ export interface PageRequestParams {
|
|
|
37
37
|
contentLinkDepth?: number;
|
|
38
38
|
languageCode?: string;
|
|
39
39
|
}
|
|
40
|
-
declare function getPage(this: ApiClientInstance
|
|
40
|
+
declare function getPage(this: ApiClientInstance & {
|
|
41
|
+
config: {
|
|
42
|
+
apiVersion: 'v1';
|
|
43
|
+
};
|
|
44
|
+
}, requestParams: PageRequestParams): Promise<ApiTypes.V1.Page>;
|
|
45
|
+
declare function getPage(this: ApiClientInstance & {
|
|
46
|
+
config: {
|
|
47
|
+
apiVersion: 'v3';
|
|
48
|
+
};
|
|
49
|
+
}, requestParams: PageRequestParams): Promise<ApiTypes.V3.Page>;
|
|
41
50
|
export default getPage;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ApiClientInstance } from "../types/sdk";
|
|
2
|
+
import { ApiTypes } from "../types/generated";
|
|
3
3
|
/**
|
|
4
4
|
* Gets the details of a page by its Page ID.
|
|
5
5
|
* @memberof AgilityFetch.Client.Pages
|
|
@@ -38,5 +38,14 @@ export interface PageByPathRequestParams {
|
|
|
38
38
|
contentLinkDepth?: number;
|
|
39
39
|
languageCode?: string;
|
|
40
40
|
}
|
|
41
|
-
declare function getPageByPath(this: ApiClientInstance
|
|
41
|
+
declare function getPageByPath(this: ApiClientInstance & {
|
|
42
|
+
config: {
|
|
43
|
+
apiVersion: 'v1';
|
|
44
|
+
};
|
|
45
|
+
}, requestParams: PageByPathRequestParams): Promise<ApiTypes.V1.Page>;
|
|
46
|
+
declare function getPageByPath(this: ApiClientInstance & {
|
|
47
|
+
config: {
|
|
48
|
+
apiVersion: 'v3';
|
|
49
|
+
};
|
|
50
|
+
}, requestParams: PageByPathRequestParams): Promise<ApiTypes.V3.Page>;
|
|
42
51
|
export default getPageByPath;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ApiClientInstance } from '../types/sdk';
|
|
2
|
+
import { ApiTypes } from '../types/generated';
|
|
3
3
|
/**
|
|
4
4
|
* The sitemap, returned in a flat list, where the dictionary key is the page path. This method is ideal for page routing.
|
|
5
5
|
* @memberof AgilityFetch.Client.Pages
|
|
@@ -33,5 +33,14 @@ export interface SitemapFlatRequestParams {
|
|
|
33
33
|
locale?: string;
|
|
34
34
|
languageCode?: string;
|
|
35
35
|
}
|
|
36
|
-
declare function getSitemapFlat(this: ApiClientInstance
|
|
36
|
+
declare function getSitemapFlat(this: ApiClientInstance & {
|
|
37
|
+
config: {
|
|
38
|
+
apiVersion: 'v1';
|
|
39
|
+
};
|
|
40
|
+
}, requestParams: SitemapFlatRequestParams): Promise<ApiTypes.V1.SitemapFlat>;
|
|
41
|
+
declare function getSitemapFlat(this: ApiClientInstance & {
|
|
42
|
+
config: {
|
|
43
|
+
apiVersion: 'v3';
|
|
44
|
+
};
|
|
45
|
+
}, requestParams: SitemapFlatRequestParams): Promise<ApiTypes.V3.SitemapFlat>;
|
|
37
46
|
export default getSitemapFlat;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ApiClientInstance } from '../types/sdk';
|
|
2
|
+
import { ApiTypes } from '../types/generated';
|
|
3
3
|
/**
|
|
4
4
|
* Gets the sitemap as an array in a nested format, ideal for generating menus.
|
|
5
5
|
* @memberof AgilityFetch.Client.Pages
|
|
@@ -33,5 +33,14 @@ export interface SitemapNestedRequestParams {
|
|
|
33
33
|
locale?: string;
|
|
34
34
|
languageCode?: string;
|
|
35
35
|
}
|
|
36
|
-
declare function getSitemapNested(this: ApiClientInstance
|
|
36
|
+
declare function getSitemapNested(this: ApiClientInstance & {
|
|
37
|
+
config: {
|
|
38
|
+
apiVersion: 'v1';
|
|
39
|
+
};
|
|
40
|
+
}, requestParams: SitemapNestedRequestParams): Promise<ApiTypes.V1.SitemapNested>;
|
|
41
|
+
declare function getSitemapNested(this: ApiClientInstance & {
|
|
42
|
+
config: {
|
|
43
|
+
apiVersion: 'v3';
|
|
44
|
+
};
|
|
45
|
+
}, requestParams: SitemapNestedRequestParams): Promise<ApiTypes.V3.SitemapNested>;
|
|
37
46
|
export default getSitemapNested;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ApiClientInstance } from '../types/sdk';
|
|
2
|
+
import { ApiTypes } from '../types/generated';
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves a list of content items that need to be synced based on the provided sync content items token, and returns the next sync token.
|
|
5
5
|
* @memberof AgilityFetch.Client.Sync
|
|
@@ -39,5 +39,14 @@ export interface SyncContentRequestParams {
|
|
|
39
39
|
pageSize?: number;
|
|
40
40
|
languageCode?: string;
|
|
41
41
|
}
|
|
42
|
-
declare function getSyncContent(this: ApiClientInstance
|
|
42
|
+
declare function getSyncContent(this: ApiClientInstance & {
|
|
43
|
+
config: {
|
|
44
|
+
apiVersion: 'v1';
|
|
45
|
+
};
|
|
46
|
+
}, requestParams: SyncContentRequestParams): Promise<ApiTypes.V1.ContentItemSync>;
|
|
47
|
+
declare function getSyncContent(this: ApiClientInstance & {
|
|
48
|
+
config: {
|
|
49
|
+
apiVersion: 'v3';
|
|
50
|
+
};
|
|
51
|
+
}, requestParams: SyncContentRequestParams): Promise<ApiTypes.V3.ContentItemSync>;
|
|
43
52
|
export default getSyncContent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ApiClientInstance } from '../types/sdk';
|
|
2
|
+
import { ApiTypes } from '../types/generated';
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves a list of pages that need to be synced based on the provided sync pages token, and returns the next sync token.
|
|
5
5
|
* @memberof AgilityFetch.Client.Sync
|
|
@@ -39,5 +39,14 @@ export interface SyncPagesRequestParams {
|
|
|
39
39
|
pageSize?: number;
|
|
40
40
|
languageCode?: string;
|
|
41
41
|
}
|
|
42
|
-
declare function getSyncPages(this: ApiClientInstance
|
|
42
|
+
declare function getSyncPages(this: ApiClientInstance & {
|
|
43
|
+
config: {
|
|
44
|
+
apiVersion: 'v1';
|
|
45
|
+
};
|
|
46
|
+
}, requestParams: SyncPagesRequestParams): Promise<ApiTypes.V1.PageSync>;
|
|
47
|
+
declare function getSyncPages(this: ApiClientInstance & {
|
|
48
|
+
config: {
|
|
49
|
+
apiVersion: 'v3';
|
|
50
|
+
};
|
|
51
|
+
}, requestParams: SyncPagesRequestParams): Promise<ApiTypes.V3.PageSync>;
|
|
43
52
|
export default getSyncPages;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ApiClientInstance } from '../types/sdk';
|
|
2
|
+
import { ApiTypes } from '../types/generated';
|
|
3
3
|
/**
|
|
4
4
|
* Gets the details of a gallery by their Gallery ID.
|
|
5
5
|
* @memberof AgilityFetch.Client.Pages
|
|
@@ -31,5 +31,14 @@ import { ApiClientInstance } from '../types/Client';
|
|
|
31
31
|
export interface UrlRedirectionsRequestParams {
|
|
32
32
|
lastAccessDate?: Date | null;
|
|
33
33
|
}
|
|
34
|
-
declare function getUrlRedirections(this: ApiClientInstance
|
|
34
|
+
declare function getUrlRedirections(this: ApiClientInstance & {
|
|
35
|
+
config: {
|
|
36
|
+
apiVersion: 'v1';
|
|
37
|
+
};
|
|
38
|
+
}, requestParams: UrlRedirectionsRequestParams): Promise<ApiTypes.V1.UrlRedirection[]>;
|
|
39
|
+
declare function getUrlRedirections(this: ApiClientInstance & {
|
|
40
|
+
config: {
|
|
41
|
+
apiVersion: 'v3';
|
|
42
|
+
};
|
|
43
|
+
}, requestParams: UrlRedirectionsRequestParams): Promise<ApiTypes.V3.UrlRedirection[]>;
|
|
35
44
|
export default getUrlRedirections;
|
package/dist/node.js
CHANGED
|
@@ -17,27 +17,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
19
|
// src/index.ts
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
22
|
getApi: () => getApi
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(index_exports);
|
|
25
25
|
|
|
26
26
|
// src/utils.ts
|
|
27
27
|
function logDebug({ config, message }) {
|
|
28
|
-
if (config.logLevel !== "debug" && !config.debug)
|
|
29
|
-
return;
|
|
28
|
+
if (config.logLevel !== "debug" && !config.debug) return;
|
|
30
29
|
console.log("\x1B[33m%s\x1B[0m", message);
|
|
31
30
|
}
|
|
32
31
|
function logInfo({ config, message }) {
|
|
33
|
-
if (config.logLevel !== "debug" && config.logLevel !== "info")
|
|
34
|
-
return;
|
|
32
|
+
if (config.logLevel !== "debug" && config.logLevel !== "info") return;
|
|
35
33
|
console.log("\x1B[33m%s\x1B[0m", message);
|
|
36
34
|
}
|
|
37
35
|
function logError({ config, message }) {
|
|
38
|
-
if (config.logLevel === "silent")
|
|
39
|
-
|
|
40
|
-
console.error("\x1B[41m%s\x1B[0m", message);
|
|
36
|
+
if (config.logLevel === "silent") return;
|
|
37
|
+
console.log(message);
|
|
41
38
|
}
|
|
42
39
|
function buildRequestUrlPath(config, locale) {
|
|
43
40
|
let apiFetchOrPreview = "";
|
|
@@ -49,9 +46,12 @@ function buildRequestUrlPath(config, locale) {
|
|
|
49
46
|
let urlPath = `${config.baseUrl}/${apiFetchOrPreview}/${locale}`;
|
|
50
47
|
return urlPath;
|
|
51
48
|
}
|
|
52
|
-
function buildPathUrl(contentType, referenceName, skip, take, sort, direction, filters, filtersLogicOperator, filterString, contentLinkDepth, expandAllContentLinks) {
|
|
49
|
+
function buildPathUrl(contentType, referenceName, skip, take, sort, direction, filters, filtersLogicOperator, filterString, contentLinkDepth, expandAllContentLinks, fields) {
|
|
53
50
|
let url = `/${contentType}/${referenceName}?contentLinkDepth=${contentLinkDepth}&`;
|
|
54
51
|
filtersLogicOperator = filtersLogicOperator ? ` ${filtersLogicOperator} ` : " AND ";
|
|
52
|
+
if (fields) {
|
|
53
|
+
url += `fields=${encodeURIComponent(fields)}&`;
|
|
54
|
+
}
|
|
55
55
|
if (sort) {
|
|
56
56
|
url += `sort=${sort}&`;
|
|
57
57
|
if (direction) {
|
|
@@ -100,7 +100,61 @@ function isHttps(url) {
|
|
|
100
100
|
return true;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
// src/types/
|
|
103
|
+
// src/types/sdk/FilterOperator.ts
|
|
104
|
+
var FilterOperators = /* @__PURE__ */ ((FilterOperators2) => {
|
|
105
|
+
FilterOperators2["EQUAL_TO"] = "eq";
|
|
106
|
+
FilterOperators2["NOT_EQUAL_TO"] = "ne";
|
|
107
|
+
FilterOperators2["LESS_THAN"] = "lt";
|
|
108
|
+
FilterOperators2["LESS_THAN_OR_EQUAL_TO"] = "lte";
|
|
109
|
+
FilterOperators2["GREATER_THAN"] = "gt";
|
|
110
|
+
FilterOperators2["GREATER_THAN_OR_EQUAL_TO"] = "gte";
|
|
111
|
+
FilterOperators2["RANGE"] = "range";
|
|
112
|
+
FilterOperators2["LIKE"] = "like";
|
|
113
|
+
FilterOperators2["IN"] = "in";
|
|
114
|
+
FilterOperators2["CONTAINS"] = "contains";
|
|
115
|
+
return FilterOperators2;
|
|
116
|
+
})(FilterOperators || {});
|
|
117
|
+
var FilterOperator_default = FilterOperators;
|
|
118
|
+
|
|
119
|
+
// src/types/sdk/FilterLogicOperator.ts
|
|
120
|
+
var FilterLogicOperators = /* @__PURE__ */ ((FilterLogicOperators2) => {
|
|
121
|
+
FilterLogicOperators2["AND"] = "AND";
|
|
122
|
+
FilterLogicOperators2["OR"] = "OR";
|
|
123
|
+
return FilterLogicOperators2;
|
|
124
|
+
})(FilterLogicOperators || {});
|
|
125
|
+
|
|
126
|
+
// src/types/sdk/SortDirection.ts
|
|
127
|
+
var SortDirections = /* @__PURE__ */ ((SortDirections2) => {
|
|
128
|
+
SortDirections2["ASC"] = "asc";
|
|
129
|
+
SortDirections2["DESC"] = "desc";
|
|
130
|
+
return SortDirections2;
|
|
131
|
+
})(SortDirections || {});
|
|
132
|
+
|
|
133
|
+
// src/types/sdk/errors/Errors.ts
|
|
134
|
+
var EvalError = class extends Error {
|
|
135
|
+
constructor(message, asserter = void 0) {
|
|
136
|
+
super(message);
|
|
137
|
+
Error.captureStackTrace?.(this, asserter || this.constructor);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var RangeError = class extends Error {
|
|
141
|
+
constructor(message, asserter = void 0) {
|
|
142
|
+
super(message);
|
|
143
|
+
Error.captureStackTrace?.(this, asserter || this.constructor);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var ReferenceError2 = class extends Error {
|
|
147
|
+
constructor(message, asserter = void 0) {
|
|
148
|
+
super(message);
|
|
149
|
+
Error.captureStackTrace?.(this, asserter || this.constructor);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
var SyntaxError = class extends Error {
|
|
153
|
+
constructor(message, asserter = void 0) {
|
|
154
|
+
super(message);
|
|
155
|
+
Error.captureStackTrace?.(this, asserter || this.constructor);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
104
158
|
var TypeError2 = class extends Error {
|
|
105
159
|
/**
|
|
106
160
|
* @param {string} message The error message
|
|
@@ -111,6 +165,12 @@ var TypeError2 = class extends Error {
|
|
|
111
165
|
Error.captureStackTrace?.(this, asserter || this.constructor);
|
|
112
166
|
}
|
|
113
167
|
};
|
|
168
|
+
var URIError = class extends Error {
|
|
169
|
+
constructor(message, asserter = void 0) {
|
|
170
|
+
super(message);
|
|
171
|
+
Error.captureStackTrace?.(this, asserter || this.constructor);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
114
174
|
|
|
115
175
|
// src/methods/getSitemapFlat.ts
|
|
116
176
|
function getSitemapFlat(requestParams) {
|
|
@@ -194,7 +254,7 @@ function getContentList(requestParams) {
|
|
|
194
254
|
requestParams.referenceName = sanitizeReferenceName(requestParams.referenceName);
|
|
195
255
|
requestParams = { ...defaultParams2, ...requestParams };
|
|
196
256
|
const req = {
|
|
197
|
-
url: buildPathUrl("list", requestParams.referenceName, requestParams.skip, requestParams.take, requestParams.sort, requestParams.direction, requestParams.filters, requestParams.filtersLogicOperator, requestParams.filterString, requestParams.contentLinkDepth, requestParams.expandAllContentLinks),
|
|
257
|
+
url: buildPathUrl("list", requestParams.referenceName, requestParams.skip, requestParams.take, requestParams.sort, requestParams.direction, requestParams.filters, requestParams.filtersLogicOperator, requestParams.filterString, requestParams.contentLinkDepth, requestParams.expandAllContentLinks, requestParams.fields),
|
|
198
258
|
method: "get",
|
|
199
259
|
baseURL: buildRequestUrlPath(this.config, requestParams.locale ? requestParams.locale : requestParams.languageCode),
|
|
200
260
|
headers: buildAuthHeader(this.config),
|
|
@@ -447,9 +507,9 @@ function getSyncPages(requestParams) {
|
|
|
447
507
|
}
|
|
448
508
|
function validateRequestParams10(requestParams) {
|
|
449
509
|
if (!requestParams.languageCode && !requestParams.locale) {
|
|
450
|
-
throw new
|
|
510
|
+
throw new TypeError2("You must include a locale in your request params.");
|
|
451
511
|
} else if (requestParams.syncToken == void 0 || requestParams.syncToken == null) {
|
|
452
|
-
throw new
|
|
512
|
+
throw new TypeError2("You must include a syncToken value your request params. Use zero (0) to start a new sync.");
|
|
453
513
|
} else {
|
|
454
514
|
return;
|
|
455
515
|
}
|
|
@@ -459,40 +519,36 @@ var getSyncPages_default = getSyncPages;
|
|
|
459
519
|
// src/types/index.ts
|
|
460
520
|
var types_exports = {};
|
|
461
521
|
__export(types_exports, {
|
|
522
|
+
EvalError: () => EvalError,
|
|
462
523
|
FilterLogicOperators: () => FilterLogicOperators,
|
|
463
524
|
FilterOperators: () => FilterOperator_default,
|
|
464
|
-
|
|
525
|
+
RangeError: () => RangeError,
|
|
526
|
+
ReferenceError: () => ReferenceError2,
|
|
527
|
+
SortDirections: () => SortDirections,
|
|
528
|
+
SyntaxError: () => SyntaxError,
|
|
529
|
+
TypeError: () => TypeError2,
|
|
530
|
+
URIError: () => URIError,
|
|
531
|
+
V1: () => v1_exports,
|
|
532
|
+
V3: () => v3_exports
|
|
465
533
|
});
|
|
466
534
|
|
|
467
|
-
// src/types/
|
|
468
|
-
var
|
|
469
|
-
FilterOperators2["EQUAL_TO"] = "eq";
|
|
470
|
-
FilterOperators2["NOT_EQUAL_TO"] = "ne";
|
|
471
|
-
FilterOperators2["LESS_THAN"] = "lt";
|
|
472
|
-
FilterOperators2["LESS_THAN_OR_EQUAL_TO"] = "lte";
|
|
473
|
-
FilterOperators2["GREATER_THAN"] = "gt";
|
|
474
|
-
FilterOperators2["GREATER_THAN_OR_EQUAL_TO"] = "gte";
|
|
475
|
-
FilterOperators2["RANGE"] = "range";
|
|
476
|
-
FilterOperators2["LIKE"] = "like";
|
|
477
|
-
FilterOperators2["IN"] = "in";
|
|
478
|
-
FilterOperators2["CONTAINS"] = "contains";
|
|
479
|
-
return FilterOperators2;
|
|
480
|
-
})(FilterOperators || {});
|
|
481
|
-
var FilterOperator_default = FilterOperators;
|
|
535
|
+
// src/types/generated/v1.ts
|
|
536
|
+
var v1_exports = {};
|
|
482
537
|
|
|
483
|
-
// src/types/
|
|
484
|
-
var
|
|
485
|
-
FilterLogicOperators2["AND"] = "AND";
|
|
486
|
-
FilterLogicOperators2["OR"] = "OR";
|
|
487
|
-
return FilterLogicOperators2;
|
|
488
|
-
})(FilterLogicOperators || {});
|
|
538
|
+
// src/types/generated/v3.ts
|
|
539
|
+
var v3_exports = {};
|
|
489
540
|
|
|
490
|
-
// src/types/
|
|
491
|
-
var
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
541
|
+
// src/types/errors/Errors.ts
|
|
542
|
+
var TypeError3 = class extends Error {
|
|
543
|
+
/**
|
|
544
|
+
* @param {string} message The error message
|
|
545
|
+
* @param {Function} [asserter] The assertion function that threw the error. Removes stack-trace noise if provided.
|
|
546
|
+
*/
|
|
547
|
+
constructor(message, asserter) {
|
|
548
|
+
super(message);
|
|
549
|
+
Error.captureStackTrace?.(this, asserter || this.constructor);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
496
552
|
|
|
497
553
|
// src/api-client.ts
|
|
498
554
|
var defaultConfig = {
|
|
@@ -501,6 +557,8 @@ var defaultConfig = {
|
|
|
501
557
|
guid: null,
|
|
502
558
|
apiKey: null,
|
|
503
559
|
locale: null,
|
|
560
|
+
apiVersion: "v3",
|
|
561
|
+
// Default to v3 for better types and modern API
|
|
504
562
|
headers: {},
|
|
505
563
|
requiresGuidInHeaders: false,
|
|
506
564
|
logLevel: "warn",
|
|
@@ -510,7 +568,7 @@ var defaultConfig = {
|
|
|
510
568
|
//caching disabled by default
|
|
511
569
|
}
|
|
512
570
|
};
|
|
513
|
-
function buildBaseUrl(guid) {
|
|
571
|
+
function buildBaseUrl(guid, apiVersion) {
|
|
514
572
|
const baseUrlSuffixes = {
|
|
515
573
|
u: "",
|
|
516
574
|
c: "-ca",
|
|
@@ -519,26 +577,27 @@ function buildBaseUrl(guid) {
|
|
|
519
577
|
d: "-dev",
|
|
520
578
|
us2: "-usa2"
|
|
521
579
|
};
|
|
580
|
+
const versionPath = apiVersion === "v3" ? "/v3" : "";
|
|
522
581
|
const match = guid.match(/-(us2|[ucead])$/);
|
|
523
582
|
if (match) {
|
|
524
583
|
const env = match[1];
|
|
525
584
|
if (baseUrlSuffixes.hasOwnProperty(env)) {
|
|
526
|
-
const
|
|
527
|
-
return
|
|
585
|
+
const url2 = `https://api${baseUrlSuffixes[env]}.aglty.io${versionPath}/${guid}`;
|
|
586
|
+
return url2;
|
|
528
587
|
}
|
|
529
588
|
}
|
|
530
|
-
const
|
|
531
|
-
return
|
|
589
|
+
const url = `https://api-dev.aglty.io${versionPath}/${guid}`;
|
|
590
|
+
return url;
|
|
532
591
|
}
|
|
533
592
|
function validateConfigParams(configParams) {
|
|
534
593
|
if (!configParams.guid || configParams.guid.length == 0) {
|
|
535
|
-
throw new
|
|
594
|
+
throw new TypeError3("You must provide a guid.");
|
|
536
595
|
} else if (!configParams.apiKey || configParams.apiKey.length == 0) {
|
|
537
|
-
throw new
|
|
596
|
+
throw new TypeError3("You must provide an access token.");
|
|
538
597
|
} else if (configParams.caching && isNaN(configParams.caching.maxAge)) {
|
|
539
|
-
throw new
|
|
598
|
+
throw new TypeError3("When specifying a cache maxAge, you must set a number value in miliseconds, i.e. 180000 (3 mins).");
|
|
540
599
|
} else if (configParams.baseUrl && !isHttps(configParams.baseUrl)) {
|
|
541
|
-
throw new
|
|
600
|
+
throw new TypeError3(`When specifying a baseUrl (${configParams.baseUrl}), it must be over HTTPs.`);
|
|
542
601
|
} else {
|
|
543
602
|
return;
|
|
544
603
|
}
|
|
@@ -551,7 +610,7 @@ var ApiClient = class {
|
|
|
551
610
|
...userConfig
|
|
552
611
|
};
|
|
553
612
|
if (!config.baseUrl) {
|
|
554
|
-
config.baseUrl = buildBaseUrl(config?.guid || "");
|
|
613
|
+
config.baseUrl = buildBaseUrl(config?.guid || "", config.apiVersion);
|
|
555
614
|
} else {
|
|
556
615
|
config.requiresGuidInHeaders = true;
|
|
557
616
|
}
|
|
@@ -590,9 +649,9 @@ var ApiClient = class {
|
|
|
590
649
|
//the function that actually makes ALL our requests
|
|
591
650
|
async makeRequest(reqConfig) {
|
|
592
651
|
const isPreview = !!this.config.isPreview;
|
|
593
|
-
|
|
652
|
+
const fullUrl = `${reqConfig.baseURL}${reqConfig.url}`;
|
|
653
|
+
logDebug({ config: this.config, message: `AgilityCMS Fetch API LOG: ${fullUrl}` });
|
|
594
654
|
try {
|
|
595
|
-
const fullUrl = `${reqConfig.baseURL}${reqConfig.url}`;
|
|
596
655
|
let init = {
|
|
597
656
|
...this.config.fetchConfig,
|
|
598
657
|
method: "GET",
|
|
@@ -608,8 +667,9 @@ var ApiClient = class {
|
|
|
608
667
|
}
|
|
609
668
|
const response = await fetch(fullUrl, init);
|
|
610
669
|
if (!response.ok) {
|
|
670
|
+
const fullErrorUrl = `${reqConfig.baseURL}${reqConfig.url}`;
|
|
611
671
|
if (response.status === 404) {
|
|
612
|
-
logInfo({ config: this.config, message: `AgilityCMS Fetch API: Request returned a ${response.status} response for ${
|
|
672
|
+
logInfo({ config: this.config, message: `AgilityCMS Fetch API: Request returned a ${response.status} response for ${fullErrorUrl}. ${response.statusText}` });
|
|
613
673
|
return;
|
|
614
674
|
}
|
|
615
675
|
logError({ config: this.config, message: `AgilityCMS Fetch API ERROR: Request returned a ${response.status} response for ${reqConfig.baseURL}${reqConfig.url}. ${response.statusText}` });
|
|
@@ -627,15 +687,9 @@ var ApiClient = class {
|
|
|
627
687
|
};
|
|
628
688
|
function getApi(config) {
|
|
629
689
|
validateConfigParams(config);
|
|
630
|
-
if (!config.fetchConfig)
|
|
631
|
-
config.fetchConfig = {};
|
|
690
|
+
if (!config.fetchConfig) config.fetchConfig = {};
|
|
632
691
|
return new ApiClient(config);
|
|
633
692
|
}
|
|
634
|
-
|
|
635
|
-
// src/index.ts
|
|
636
|
-
module.exports = {
|
|
637
|
-
getApi
|
|
638
|
-
};
|
|
639
693
|
// Annotate the CommonJS export names for ESM import in node:
|
|
640
694
|
0 && (module.exports = {
|
|
641
695
|
getApi
|
package/dist/types/Config.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export interface Config {
|
|
|
18
18
|
*/
|
|
19
19
|
apiKey?: string | null;
|
|
20
20
|
locale?: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* The API version to use. 'v1' uses legacy string-based data types, 'v3' uses proper data types.
|
|
23
|
+
* Default is 'v3'. Specify 'v1' only if you need legacy compatibility.
|
|
24
|
+
*/
|
|
25
|
+
apiVersion?: 'v1' | 'v3';
|
|
21
26
|
/**
|
|
22
27
|
* Additional headers to include in the request.
|
|
23
28
|
*/
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated API Types
|
|
3
|
+
*
|
|
4
|
+
* This file provides namespaced access to generated types from Swagger specs.
|
|
5
|
+
* Types are organized by API version (V1, V3) for clear separation.
|
|
6
|
+
*/
|
|
7
|
+
import * as V1Schema from './v1';
|
|
8
|
+
import * as V3Schema from './v3';
|
|
9
|
+
export declare namespace ApiTypes {
|
|
10
|
+
namespace V1 {
|
|
11
|
+
type ContentItem = V1Schema.components['schemas']['HeadlessContentItem'];
|
|
12
|
+
type ContentList = V1Schema.components['schemas']['HeadlessContentListResponse'];
|
|
13
|
+
type ContentItemSync = V1Schema.components['schemas']['HeadlessContentItemHeadlessSync'];
|
|
14
|
+
type Page = V1Schema.components['schemas']['HeadlessContentPage'];
|
|
15
|
+
type PageByPath = V1Schema.components['schemas']['HeadlessContentPageByPath'];
|
|
16
|
+
type PageSync = V1Schema.components['schemas']['HeadlessContentPageHeadlessSync'];
|
|
17
|
+
type SitemapFlat = {
|
|
18
|
+
[key: string]: V1Schema.components['schemas']['HeadlessContentSiteMapItem'];
|
|
19
|
+
};
|
|
20
|
+
type SitemapNested = V1Schema.components['schemas']['HeadlessContentSiteMapNestedItem'][];
|
|
21
|
+
type SitemapItem = V1Schema.components['schemas']['HeadlessContentSiteMapItem'];
|
|
22
|
+
type SitemapNestedItem = V1Schema.components['schemas']['HeadlessContentSiteMapNestedItem'];
|
|
23
|
+
type Gallery = V1Schema.components['schemas']['HeadlessGallery'];
|
|
24
|
+
type MediaItem = V1Schema.components['schemas']['HeadlessMediaItem'];
|
|
25
|
+
type UrlRedirection = V1Schema.components['schemas']['UrlRedirection'];
|
|
26
|
+
type ContentZone = V1Schema.components['schemas']['HeadlessContentZone'];
|
|
27
|
+
type ContentItemProperties = V1Schema.components['schemas']['HeadlessContentItemProperties'];
|
|
28
|
+
type ContentItemSeo = V1Schema.components['schemas']['HeadlessContentItemSeo'];
|
|
29
|
+
type PageVisibility = V1Schema.components['schemas']['HeadlessContentPageVisibility'];
|
|
30
|
+
}
|
|
31
|
+
namespace V3 {
|
|
32
|
+
type ContentItem = V3Schema.components['schemas']['HeadlessContentItem'];
|
|
33
|
+
type ContentList = V3Schema.components['schemas']['HeadlessContentListResponse'];
|
|
34
|
+
type ContentItemSync = V3Schema.components['schemas']['HeadlessContentItemHeadlessSync'];
|
|
35
|
+
type Page = V3Schema.components['schemas']['HeadlessContentPage'];
|
|
36
|
+
type PageByPath = V3Schema.components['schemas']['HeadlessContentPageByPath'];
|
|
37
|
+
type PageSync = V3Schema.components['schemas']['HeadlessContentPageHeadlessSync'];
|
|
38
|
+
type SitemapFlat = {
|
|
39
|
+
[key: string]: V3Schema.components['schemas']['HeadlessContentSiteMapItem'];
|
|
40
|
+
};
|
|
41
|
+
type SitemapNested = V3Schema.components['schemas']['HeadlessContentSiteMapNestedItem'][];
|
|
42
|
+
type SitemapItem = V3Schema.components['schemas']['HeadlessContentSiteMapItem'];
|
|
43
|
+
type SitemapNestedItem = V3Schema.components['schemas']['HeadlessContentSiteMapNestedItem'];
|
|
44
|
+
type Gallery = V3Schema.components['schemas']['HeadlessGallery'];
|
|
45
|
+
type MediaItem = V3Schema.components['schemas']['HeadlessMediaItem'];
|
|
46
|
+
type UrlRedirection = V3Schema.components['schemas']['UrlRedirection'];
|
|
47
|
+
type ContentZone = V3Schema.components['schemas']['HeadlessContentZone'];
|
|
48
|
+
type ContentItemProperties = V3Schema.components['schemas']['HeadlessContentItemProperties'];
|
|
49
|
+
type ContentItemSeo = V3Schema.components['schemas']['HeadlessContentItemSeo'];
|
|
50
|
+
type PageVisibility = V3Schema.components['schemas']['HeadlessContentPageVisibility'];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export { V1Schema as V1, V3Schema as V3 };
|