@agility/content-fetch 2.0.10 → 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 +624 -569
  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 +117 -63
  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
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,96 @@
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
+ # Canary Release - runs on dev branch pushes after successful tests
65
+ canary-release:
66
+ needs: test
67
+ runs-on: ubuntu-latest
68
+ if: github.ref == 'refs/heads/dev' && github.event_name == 'push' && contains(github.event.head_commit.message, '[publish-canary]')
69
+
70
+ steps:
71
+ - name: Checkout code
72
+ uses: actions/checkout@v4
73
+
74
+ - name: Setup Node.js
75
+ uses: actions/setup-node@v4
76
+ with:
77
+ node-version: '20.x'
78
+ registry-url: 'https://registry.npmjs.org'
79
+
80
+ - name: Restore build artifacts
81
+ uses: actions/cache@v4
82
+ with:
83
+ path: dist
84
+ key: ${{ runner.os }}-build-20.x-${{ github.sha }}
85
+ fail-on-cache-miss: true
86
+
87
+ - name: Set canary version
88
+ run: |
89
+ npm version canary --no-git-tag-version
90
+
91
+ - name: Publish canary to NPM
92
+ run: npm publish --tag canary
93
+ env:
94
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
95
+
96
+
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));
@@ -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>;