@agility/content-fetch 1.1.2 → 1.1.3
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/.vscode/launch.json +35 -0
- package/dist/agility-content-fetch.browser.js +175 -60
- package/dist/agility-content-fetch.node.js +3717 -992
- package/package.json +1 -1
- package/src/methods/getContentList.js +9 -9
- package/src/types/ContentList.js +1 -1
- package/test/apiClients.config.js +6 -3
- package/test/getContentList.tests.js +2 -2
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ import {buildPathUrl, buildRequestUrlPath, buildAuthHeader } from '../utils'
|
|
|
9
9
|
* @param {string} requestParams.languageCode - DEPRECATED: Use locale instead - The language code of the content you want to retrieve.
|
|
10
10
|
* @param {number} [requestParams.contentLinkDepth] - The depth, representing the levels in which you want linked content auto-resolved. Default is **1**.
|
|
11
11
|
* @param {boolean} [requestParams.expandAllContentLinks] - Whether or not to expand entire linked content references, includings lists and items that are rendered in the CMS as Grid or Link. Default is **false**
|
|
12
|
-
* @param {number} [requestParams.take] - The maximum number of items to retrieve in this request. Default is **10**. Maximum allowed is **
|
|
12
|
+
* @param {number} [requestParams.take] - The maximum number of items to retrieve in this request. Default is **10**. Maximum allowed is **250**.
|
|
13
13
|
* @param {number} [requestParams.skip] - The number of items to skip from the list. Default is **0**. Used for implementing pagination.
|
|
14
14
|
* @param {string} [requestParams.sort] - The field to sort the results by. Example **fields.title** or **properties.modified**.
|
|
15
15
|
* @param {AgilityFetch.Types.SortDirection} [requestParams.direction] - The direction to sort the results by.
|
|
@@ -17,14 +17,14 @@ import {buildPathUrl, buildRequestUrlPath, buildAuthHeader } from '../utils'
|
|
|
17
17
|
* @param {AgilityFetch.Types.FilterLogicOperator} [requestParams.filtersLogicOperator] - The logic operator to combine multiple filters.
|
|
18
18
|
* @returns {Promise<AgilityFetch.Types.ContentList>} - Returns a list of content items.
|
|
19
19
|
* @example
|
|
20
|
-
*
|
|
20
|
+
*
|
|
21
21
|
* import agility from '@agility/content-fetch'
|
|
22
|
-
*
|
|
22
|
+
*
|
|
23
23
|
* const api = agility.getApi({
|
|
24
24
|
* guid: 'ade6cf3c',
|
|
25
25
|
* apiKey: 'defaultlive.201ffdd0841cacad5bb647e76547e918b0c9ecdb8b5ddb3cf92e9a79b03623cb',
|
|
26
26
|
* });
|
|
27
|
-
*
|
|
27
|
+
*
|
|
28
28
|
* api.getContentList({
|
|
29
29
|
* referenceName: 'posts',
|
|
30
30
|
* locale: 'en-us',
|
|
@@ -74,8 +74,8 @@ function getContentList(requestParams) {
|
|
|
74
74
|
headers: buildAuthHeader(this.config),
|
|
75
75
|
params:{}
|
|
76
76
|
};
|
|
77
|
-
|
|
78
|
-
return this.makeRequest(req);
|
|
77
|
+
|
|
78
|
+
return this.makeRequest(req);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
function sanitizeReferenceName(referenceName) {
|
|
@@ -95,9 +95,9 @@ function validateRequestParams(requestParams) {
|
|
|
95
95
|
} else if((requestParams.take || requestParams.take == 0) && !isNaN(requestParams.take) && requestParams.take < 1) {
|
|
96
96
|
//take parameter must be greater than 0
|
|
97
97
|
throw new TypeError('Take parameter must be greater than 0.');
|
|
98
|
-
} else if(requestParams.take && !isNaN(requestParams.take) && requestParams.take >
|
|
99
|
-
//take parameter cannot be greater than
|
|
100
|
-
throw new TypeError('Take parameter must be
|
|
98
|
+
} else if(requestParams.take && !isNaN(requestParams.take) && requestParams.take > 250) {
|
|
99
|
+
//take parameter cannot be greater than 250
|
|
100
|
+
throw new TypeError('Take parameter must be 250 or less.');
|
|
101
101
|
} else if(requestParams.skip && isNaN(requestParams.skip)) {
|
|
102
102
|
//skip parameter must be a number
|
|
103
103
|
throw new TypeError('Skip parameter must be a number.');
|
package/src/types/ContentList.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Defines a **Content List** in the CMS.
|
|
3
3
|
* @typedef ContentList
|
|
4
4
|
* @memberof AgilityFetch.Types
|
|
5
|
-
* @property {Array.<AgilityFetch.Types.ContentItem>} items - The paginated array of items returned by the request. Default *take* is **10** unless otherwise specified (Maximum allowed it **
|
|
5
|
+
* @property {Array.<AgilityFetch.Types.ContentItem>} items - The paginated array of items returned by the request. Default *take* is **10** unless otherwise specified (Maximum allowed it **250**)
|
|
6
6
|
* @property {number} totalCount - The total amount of items in the list. Use this along with *skip* and *take* for pagination.
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -9,7 +9,8 @@ const apiKeyPreview = 'UnitTestsPreview.69e6bca345ced0b7ca5ab358b351ea5c870790a5
|
|
|
9
9
|
function createApiClient() {
|
|
10
10
|
var api = agility.getApi({
|
|
11
11
|
guid: guid,
|
|
12
|
-
|
|
12
|
+
apiKey: apiKeyFetch,
|
|
13
|
+
baseUrl: `https://api-dev.aglty.io/${guid}`
|
|
13
14
|
});
|
|
14
15
|
return api;
|
|
15
16
|
}
|
|
@@ -28,7 +29,8 @@ function createCachedApiClient() {
|
|
|
28
29
|
apiKey: apiKeyFetch,
|
|
29
30
|
caching: {
|
|
30
31
|
maxAge: 5 * 60 * 1000 //==5mins
|
|
31
|
-
}
|
|
32
|
+
},
|
|
33
|
+
baseUrl: `https://api-dev.aglty.io/${guid}`
|
|
32
34
|
});
|
|
33
35
|
return api;
|
|
34
36
|
}
|
|
@@ -37,7 +39,8 @@ function createPreviewApiClient() {
|
|
|
37
39
|
var api = agility.getApi({
|
|
38
40
|
guid: guid,
|
|
39
41
|
apiKey: apiKeyPreview,
|
|
40
|
-
isPreview: true
|
|
42
|
+
isPreview: true,
|
|
43
|
+
baseUrl: `https://api-dev.aglty.io/${guid}`
|
|
41
44
|
});
|
|
42
45
|
return api;
|
|
43
46
|
}
|
|
@@ -115,13 +115,13 @@ describe('getContentList:', function() {
|
|
|
115
115
|
done();
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
-
it('should throw error if take parameter is a number greater than
|
|
118
|
+
it('should throw error if take parameter is a number greater than 250 in getContentList', function(done) {
|
|
119
119
|
expect(function() {
|
|
120
120
|
var api = createApiClient();
|
|
121
121
|
api.getContentList({
|
|
122
122
|
referenceName: 'posts',
|
|
123
123
|
locale: 'en-us',
|
|
124
|
-
take:
|
|
124
|
+
take: 251
|
|
125
125
|
})
|
|
126
126
|
.then(function(contentList) {
|
|
127
127
|
assert.strictEqual(contentList[0].contentID, 24);
|