@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
package/.env
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Agility CMS API Configuration for Integration Tests
|
|
2
|
+
# Copy this file to .env and fill in your values to enable integration testing
|
|
3
|
+
#
|
|
4
|
+
# To run integration tests: RUN_INTEGRATION_TESTS=true npm test
|
|
5
|
+
|
|
6
|
+
# =============================================================================
|
|
7
|
+
# REQUIRED: Agility CMS Instance Configuration
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
# Your Agility CMS instance GUID
|
|
11
|
+
AGILITY_GUID=c741222b-1080-45f6-9a7f-982381c5a485
|
|
12
|
+
|
|
13
|
+
# Your Fetch API key (for live/published content)
|
|
14
|
+
AGILITY_FETCH_API_KEY=UnitTestsFetch.2ace650991363fbcffa6776d411d1b0d616b8e3424ce842b81cba7af0039197e
|
|
15
|
+
|
|
16
|
+
# Your Preview API key (for draft/staging content)
|
|
17
|
+
AGILITY_PREVIEW_API_KEY=UnitTestsPreview.69e6bca345ced0b7ca5ab358b351ea5c870790a5945c25d749a865332906b124
|
|
18
|
+
|
|
19
|
+
# =============================================================================
|
|
20
|
+
# OPTIONAL: API Configuration
|
|
21
|
+
# =============================================================================
|
|
22
|
+
|
|
23
|
+
# API Base URL (defaults to production if not specified)
|
|
24
|
+
# For development: https://api-dev.aglty.io
|
|
25
|
+
# For production: https://api.aglty.io
|
|
26
|
+
AGILITY_BASE_URL=https://api-dev.aglty.io
|
|
27
|
+
|
|
28
|
+
# =============================================================================
|
|
29
|
+
# OPTIONAL: Test Data Configuration
|
|
30
|
+
# =============================================================================
|
|
31
|
+
|
|
32
|
+
# Test content ID that exists in your instance (for getContentItem tests)
|
|
33
|
+
TEST_CONTENT_ID=1
|
|
34
|
+
|
|
35
|
+
# Test content list reference name that exists in your instance
|
|
36
|
+
TEST_CONTENT_LIST_REFERENCE_NAME=posts
|
|
37
|
+
|
|
38
|
+
# Test page ID that exists in your instance
|
|
39
|
+
TEST_PAGE_ID=1
|
|
40
|
+
|
|
41
|
+
# Test page path that exists in your instance (for getPageByPath tests)
|
|
42
|
+
TEST_PAGE_PATH=/
|
|
43
|
+
|
|
44
|
+
# Test channel name (usually 'website')
|
|
45
|
+
TEST_CHANNEL_NAME=website
|
|
46
|
+
|
|
47
|
+
# Test locale/language code
|
|
48
|
+
TEST_LOCALE=en-us
|
|
49
|
+
|
|
50
|
+
# Test gallery ID that exists in your instance
|
|
51
|
+
TEST_GALLERY_ID=1
|
|
52
|
+
|
|
53
|
+
# Specific content IDs for testing (if needed for legacy compatibility)
|
|
54
|
+
TEST_SPECIFIC_CONTENT_ID_1=15
|
|
55
|
+
TEST_SPECIFIC_CONTENT_ID_2=16
|
|
56
|
+
|
|
57
|
+
# Specific page IDs for testing
|
|
58
|
+
TEST_SPECIFIC_PAGE_ID=3
|
|
59
|
+
|
|
60
|
+
# Test content list with nested links (for expandAllContentLinks testing)
|
|
61
|
+
TEST_NESTED_CONTENT_LIST_REFERENCE_NAME=listwithnestedcontentlink
|
|
62
|
+
|
|
63
|
+
# Test sitemap paths
|
|
64
|
+
TEST_SITEMAP_PATH=/posts
|
|
65
|
+
|
|
66
|
+
# =============================================================================
|
|
67
|
+
# OPTIONAL: Test Behavior Configuration
|
|
68
|
+
# =============================================================================
|
|
69
|
+
|
|
70
|
+
# Set to 'true' to run integration tests against real API
|
|
71
|
+
RUN_INTEGRATION_TESTS=true
|
|
72
|
+
DOTENV_LOG=0
|
|
73
|
+
DOTENV_CONFIG_SILENT=true
|
|
74
|
+
|
|
75
|
+
# Test timeout in milliseconds for API calls
|
|
76
|
+
TEST_TIMEOUT=30000
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: CI/CD
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [dev, master]
|
|
6
|
+
push:
|
|
7
|
+
branches: [dev, master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [18.x, 20.x, 22.x]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout code
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ matrix.node-version }}
|
|
25
|
+
cache: 'npm'
|
|
26
|
+
|
|
27
|
+
- name: Cache node_modules
|
|
28
|
+
uses: actions/cache@v4
|
|
29
|
+
with:
|
|
30
|
+
path: |
|
|
31
|
+
node_modules
|
|
32
|
+
~/.npm
|
|
33
|
+
key: ${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }}
|
|
34
|
+
restore-keys: |
|
|
35
|
+
${{ runner.os }}-node-${{ matrix.node-version }}-npm-
|
|
36
|
+
${{ runner.os }}-node-${{ matrix.node-version }}-
|
|
37
|
+
|
|
38
|
+
- name: Install dependencies
|
|
39
|
+
run: npm ci
|
|
40
|
+
|
|
41
|
+
- name: Security audit
|
|
42
|
+
run: npm audit --audit-level moderate
|
|
43
|
+
continue-on-error: true
|
|
44
|
+
|
|
45
|
+
- name: Build project
|
|
46
|
+
run: npm run build
|
|
47
|
+
|
|
48
|
+
- name: Run tests
|
|
49
|
+
run: npm test
|
|
50
|
+
env:
|
|
51
|
+
AGILITY_GUID: ${{ secrets.AGILITY_GUID }}
|
|
52
|
+
AGILITY_FETCH_API_KEY: ${{ secrets.AGILITY_FETCH_API_KEY }}
|
|
53
|
+
AGILITY_PREVIEW_API_KEY: ${{ secrets.AGILITY_PREVIEW_API_KEY }}
|
|
54
|
+
AGILITY_BASE_URL: ${{ secrets.AGILITY_BASE_URL }}
|
|
55
|
+
|
|
56
|
+
- name: Cache build artifacts
|
|
57
|
+
uses: actions/cache@v4
|
|
58
|
+
with:
|
|
59
|
+
path: dist
|
|
60
|
+
key: ${{ runner.os }}-build-${{ matrix.node-version }}-${{ github.sha }}
|
|
61
|
+
restore-keys: |
|
|
62
|
+
${{ runner.os }}-build-${{ matrix.node-version }}-
|
|
63
|
+
|
|
64
|
+
|
package/build.js
CHANGED
|
@@ -13,6 +13,7 @@ esbuild.build({
|
|
|
13
13
|
bundle: true,
|
|
14
14
|
outfile: './dist/browser.js',
|
|
15
15
|
platform: 'browser',
|
|
16
|
+
format: 'esm',
|
|
16
17
|
}).catch(() => process.exit(1));
|
|
17
18
|
|
|
18
19
|
// Build for Node.js
|
|
@@ -21,4 +22,5 @@ esbuild.build({
|
|
|
21
22
|
bundle: true,
|
|
22
23
|
outfile: './dist/node.js',
|
|
23
24
|
platform: 'node',
|
|
25
|
+
format: 'cjs',
|
|
24
26
|
}).catch(() => process.exit(1));
|
package/dist/api-client.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface ApiClientInstance {
|
|
|
16
16
|
makeRequest(req: any): Promise<any>;
|
|
17
17
|
getSitemapFlat(params: SitemapFlatRequestParams): Promise<any>;
|
|
18
18
|
getSitemapNested(params: SitemapNestedRequestParams): Promise<any>;
|
|
19
|
-
getContentItem(params: ContentItemRequestParams): Promise<any>;
|
|
19
|
+
getContentItem<T = any>(params: ContentItemRequestParams): Promise<any>;
|
|
20
20
|
getContentList(params: ContentListRequestParams): Promise<any>;
|
|
21
21
|
getPage(params: PageRequestParams): Promise<any>;
|
|
22
22
|
getPageByPath(params: PageByPathRequestParams): Promise<any>;
|
|
@@ -29,7 +29,7 @@ declare class ApiClient {
|
|
|
29
29
|
config: Config;
|
|
30
30
|
constructor(userConfig: Config);
|
|
31
31
|
types: typeof types;
|
|
32
|
-
getContentItem(params: ContentItemRequestParams): Promise<any>;
|
|
32
|
+
getContentItem<T = any>(params: ContentItemRequestParams): Promise<any>;
|
|
33
33
|
getContentList(params: ContentListRequestParams): Promise<any>;
|
|
34
34
|
getGallery(params: GalleryRequestParams): Promise<any>;
|
|
35
35
|
getPage(params: PageRequestParams): Promise<any>;
|