Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: agility/agility-content-fetch-js-sdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f4a801fa7fb003ec42346e3c48274ee394f1be1c
Choose a base ref
...
head repository: agility/agility-content-fetch-js-sdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2cba3623916b3b508b3e45f51f409e7224f1447a
Choose a head ref

Commits on Jun 27, 2023

  1. Update README.md

    joelvarty authored Jun 27, 2023
    Copy the full SHA
    bf650c3 View commit details

Commits on Aug 2, 2023

  1. Copy the full SHA
    b4fc7a0 View commit details

Commits on Aug 3, 2023

  1. update src files

    5PK committed Aug 3, 2023
    Copy the full SHA
    be4f2d2 View commit details
  2. Copy the full SHA
    ae8f360 View commit details

Commits on Aug 4, 2023

  1. [ts-u] commit new tests, ts

    5PK committed Aug 4, 2023
    Copy the full SHA
    941ce25 View commit details
  2. Copy the full SHA
    f789b31 View commit details
  3. [ts-u] cleanup

    5PK committed Aug 4, 2023
    Copy the full SHA
    2febd14 View commit details

Commits on Aug 9, 2023

  1. Copy the full SHA
    6597317 View commit details
  2. Copy the full SHA
    86740a2 View commit details
  3. Copy the full SHA
    47ed6a3 View commit details
  4. v bump

    joelvarty committed Aug 9, 2023
    Copy the full SHA
    b5492d4 View commit details

Commits on Aug 10, 2023

  1. Copy the full SHA
    0968c4f View commit details

Commits on Aug 14, 2023

  1. version bump

    5PK committed Aug 14, 2023
    Copy the full SHA
    57f1e39 View commit details
  2. modify package.json

    5PK committed Aug 14, 2023
    Copy the full SHA
    888caf1 View commit details
  3. try this

    5PK committed Aug 14, 2023
    Copy the full SHA
    9799c12 View commit details
  4. another try

    5PK committed Aug 14, 2023
    Copy the full SHA
    bb18694 View commit details
  5. esbuild tweaks

    joelvarty committed Aug 14, 2023
    Copy the full SHA
    ebfbc9d View commit details
  6. v bump

    5PK committed Aug 14, 2023
    Copy the full SHA
    0697b78 View commit details

Commits on Aug 15, 2023

  1. Revert "esbuild tweaks"

    This reverts commit ebfbc9d.
    5PK committed Aug 15, 2023
    Copy the full SHA
    cf3fd50 View commit details
  2. working browser build

    5PK committed Aug 15, 2023
    Copy the full SHA
    df63a21 View commit details
  3. get tests working, yarn 1.2

    joelvarty committed Aug 15, 2023
    Copy the full SHA
    d7780dd View commit details

Commits on Aug 31, 2023

  1. add seo to pages, version bump

    5PK committed Aug 31, 2023
    Copy the full SHA
    2fe5811 View commit details
  2. add lockfile

    5PK committed Aug 31, 2023
    Copy the full SHA
    a351851 View commit details

Commits on Sep 8, 2023

  1. Copy the full SHA
    aced4d9 View commit details
  2. Copy the full SHA
    31a5b0b View commit details

Commits on Oct 12, 2023

  1. removed clg

    joelvarty committed Oct 12, 2023
    Copy the full SHA
    e14afa1 View commit details

Commits on Nov 13, 2023

  1. removed axios

    joelvarty committed Nov 13, 2023
    Copy the full SHA
    a97864e View commit details

Commits on Nov 24, 2023

  1. error message fix

    joelvarty committed Nov 24, 2023
    Copy the full SHA
    8df75e5 View commit details

Commits on Jan 9, 2024

  1. Copy the full SHA
    c21acdb View commit details

Commits on Mar 20, 2024

  1. Copy the full SHA
    bf8b043 View commit details
  2. tests passing

    joelvarty committed Mar 20, 2024
    Copy the full SHA
    5fdb35d View commit details

Commits on Mar 21, 2024

  1. v2.0.0

    joelvarty committed Mar 21, 2024
    Copy the full SHA
    2cba362 View commit details
Showing with 5,024 additions and 9,223 deletions.
  1. +0 −7 .babelrc
  2. +2 −1 .gitignore
  3. +4 −0 .npmignore
  4. +0 −35 .vscode/launch.json
  5. +29 −35 README.md
  6. +24 −0 build.js
  7. +6 −0 jest.config.js
  8. +0 −7,179 package-lock.json
  9. +39 −33 package.json
  10. +0 −162 src/api-client.js
  11. +247 −0 src/api-client.ts
  12. +0 −90 src/content-fetch.js
  13. +26 −0 src/index.ts
  14. +29 −14 src/methods/{getContentItem.js → getContentItem.ts}
  15. +0 −140 src/methods/getContentList.js
  16. +162 −0 src/methods/getContentList.ts
  17. +18 −10 src/methods/{getGallery.js → getGallery.ts}
  18. +27 −15 src/methods/{getPage.js → getPage.ts}
  19. +21 −12 src/methods/{getSitemapFlat.js → getSitemapFlat.ts}
  20. +21 −12 src/methods/{getSitemapNested.js → getSitemapNested.ts}
  21. +20 −9 src/methods/{getSyncContent.js → getSyncContent.ts}
  22. +12 −2 src/methods/{getSyncPages.js → getSyncPages.ts}
  23. +19 −10 src/methods/{getUrlRedirections.js → getUrlRedirections.ts}
  24. +16 −0 src/types/Client.ts
  25. +48 −0 src/types/Config.ts
  26. +0 −10 src/types/ContentItem.js
  27. +29 −0 src/types/ContentItem.ts
  28. +6 −0 src/types/{ContentList.js → ContentList.ts}
  29. +5 −0 src/types/ContentReference.ts
  30. +0 −8 src/types/ContentZone.js
  31. +15 −0 src/types/ContentZone.ts
  32. +10 −0 src/types/EnvConfig.ts
  33. +17 −13 src/types/{Filter.js → Filter.ts}
  34. +30 −21 src/types/{FilterLogicOperator.js → FilterLogicOperator.ts}
  35. +29 −29 src/types/{FilterOperator.js → FilterOperator.ts}
  36. +17 −0 src/types/{Gallery.js → Gallery.ts}
  37. +15 −0 src/types/{MediaItem.js → MediaItem.ts}
  38. +7 −0 src/types/{MediaItemMetaData.js → MediaItemMetaData.ts}
  39. +43 −0 src/types/{Page.js → Page.ts}
  40. +17 −0 src/types/SEO.ts
  41. +0 −6 src/types/SitemapFlat.js
  42. +20 −0 src/types/SitemapFlat.ts
  43. +31 −0 src/types/{SitemapFlatItem.js → SitemapFlatItem.ts}
  44. +4 −0 src/types/{SitemapNested.js → SitemapNested.ts}
  45. +17 −0 src/types/{SitemapNestedItem.js → SitemapNestedItem.ts}
  46. +5 −0 src/types/{SitemapVisibility.js → SitemapVisibility.ts}
  47. +31 −21 src/types/{SortDirection.js → SortDirection.ts}
  48. +7 −0 src/types/{SyncContent.js → SyncContent.ts}
  49. +6 −0 src/types/{SyncPages.js → SyncPages.ts}
  50. +7 −0 src/types/{SystemProperties.js → SystemProperties.ts}
  51. +6 −1 src/types/{UrlRedirection.js → UrlRedirection.ts}
  52. +6 −0 src/types/{UrlRedirectionResponse.js → UrlRedirectionResponse.ts}
  53. +51 −0 src/types/errors/Errors.ts
  54. +10 −0 src/types/index.ts
  55. +0 −88 src/utils.js
  56. +117 −0 src/utils.ts
  57. +10 −25 test/{apiClients.config.js → apiClients.config.ts}
  58. +0 −185 test/getApi.tests.js
  59. +153 −0 test/getApi.tests.ts
  60. +0 −200 test/getContentItem.tests.js
  61. +108 −0 test/getContentItem.tests.ts
  62. +0 −371 test/getContentList.tests.js
  63. +329 −0 test/getContentList.tests.ts
  64. +0 −33 test/getGallery.tests.js
  65. +22 −0 test/getGallery.tests.ts
  66. +0 −93 test/getPage.tests.js
  67. +49 −0 test/getPage.tests.ts
  68. +0 −73 test/getSitemapFlat.tests.js
  69. +30 −0 test/getSitemapFlat.tests.ts
  70. +0 −73 test/getSitemapNested.tests.js
  71. +30 −0 test/getSitemapNested.tests.ts
  72. +0 −44 test/getSyncContentItems.tests.js
  73. +25 −0 test/getSyncContentItems.tests.ts
  74. +0 −45 test/getSyncPageItems.tests.js
  75. +27 −0 test/getSyncPageItems.tests.ts
  76. +0 −60 test/getUrlRedirections.tests.js
  77. +40 −0 test/getUrlRedirections.tests.ts
  78. +15 −0 tsconfig.json
  79. +0 −58 webpack.config.js
  80. +2,858 −0 yarn.lock
7 changes: 0 additions & 7 deletions .babelrc

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
/.yarn/

# Runtime data
pids
@@ -65,4 +66,4 @@ typings/
docs/

# ignore the dist folder
dist/
dist/
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/src/
/test/
/docs/
/api-client.ts
35 changes: 0 additions & 35 deletions .vscode/launch.json

This file was deleted.

64 changes: 29 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,73 +2,71 @@
[![Netlify Status](https://api.netlify.com/api/v1/badges/c45f5d6e-923b-4019-820e-826e6185017d/deploy-status)](https://app.netlify.com/sites/agilitydocs/deploys)

# Agility Content Fetch JS SDK
This is the official JavaScript library for accessing live and preview content from your [Agility CMS](https://agilitycms.com) instance.

This is the official JavaScript/TypeScript library for accessing live and preview content from your [Agility CMS](https://agilitycms.com) instance.

You can use this in both node and browser based JS apps.

Don't have an Agility CMS instance? Sign up for [Free (forever)](https://account.agilitycms.com/sign-up?product=agility-free) today!
Don't have an Agility CMS instance? Sign up for [Free Trial](https://agilitycms.com/free) today!

## Features

- Queries the high-availability, CDN backed Agility Fetch REST API
- Get a sitemap for a given channel
- Get a page, including its content zones, modules, and their content
- Get a content item
- Query a content list using a filter syntax
- Get the details of a media gallery
- Keep track of syncing content to your app
- Optional in-memory caching

## Getting Started
In order to use this sdk, you'll need to install the script and you'll also need to authenticate your requests.

In order to use this sdk, you'll need to install the `@agility/content-fetch` package and you'll also need to authenticate your requests.

### Prerequisites
You must have access to an Agility instance to retrieve the *guid* and generate your *apiKey*. Or, you must have these values provided to you.

You must have access to an Agility instance to retrieve the _guid_ and generate your _apiKey_. Or, you must have these values provided to you.

### Installation
Install it using **npm** (recommended):

**npm**

```
npm install @agility/content-fetch
```

If necessary, you can also reference a standalone package that can be used in a browser using a traditional **script** tag. In this case, the sdk can be accessed using a global variable by name of `agility`:
```html
<!-- Use a specific version (i.e. 0.4.2) -->
<script type="text/javascript" src="https://unpkg.com/@agility/content-fetch@0.4.2/dist/agility-content-fetch.browser.js"></script>
**yarn**

<!-- Or, Use the latest version -->
<script type="text/javascript" src="https://unpkg.com/@agility/content-fetch@latest/dist/agility-content-fetch.browser.js"></script>
```
yarn add @agility/content-fetch
```

### Making a Request

```javascript
import agility from '@agility/content-fetch'
import agility from "@agility/content-fetch"

//initialize the api client
const api = agility.getApi({
guid: 'ade6cf3c',
apiKey: 'defaultlive.201ffdd0841cacad5bb647e76547e918b0c9ecdb8b5ddb3cf92e9a79b03623cb'
});

//make the request: get a content item with the ID '22'
api.getContentItem({
contentID: 22,
locale: 'en-us'
guid: "[guid]",
apiKey: "[your-api-key]",
})
.then(function(contentItem) {
//on success
console.log(contentItem);

//make the request: get a content item with the ID 22 in locale 'en-us'
const contentItems = await api.getContentItem({
contentID: 22,
locale: "en-us",
})
.catch(function(error) {
//on error
console.log(error);
});
```

## Documentation

Full documentation for this SDK can be found in our [Agility Fetch JS SDK Reference Doc](https://agilitydocs.netlify.com/agility-content-fetch-js-sdk/).

For docs & help around Agility CMS, please see [Agility CMS Documentation](https://help.agilitycms.com/hc/en-us)

## Tutorials

[About the Content Fetch API](https://help.agilitycms.com/hc/en-us/articles/360031985112-About-the-Content-Fetch-API)

[Authenticating your Content Fetch API Calls](https://help.agilitycms.com/hc/en-us/articles/360032225191-Authenticating-your-Content-Fetch-API-Calls)
@@ -92,17 +90,13 @@ For docs & help around Agility CMS, please see [Agility CMS Documentation](https
[Content Webhooks](https://help.agilitycms.com/hc/en-us/articles/360035934911)

## Contributing

If you would like to contribute to this SDK, you can fork the repository and submit a pull request. We'd love to include your updates.

### Running the Tests

An essential part of contributing to this SDK is adding and running unit tests to ensure the stability of the project.

```
> npm run test
```







24 changes: 24 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const esbuild = require('esbuild');
const { execSync } = require('child_process');
const path = require('path');

console.log("Building...", path.resolve(__dirname, "src/index.ts"))
console.log("Building...", path.resolve(__dirname, "dist/browser.js"))

execSync('tsc --emitDeclarationOnly');

// Build for browser
esbuild.build({
entryPoints: ['./src/index.ts'],
bundle: true,
outfile: './dist/browser.js',
platform: 'browser',
}).catch(() => process.exit(1));

// Build for Node.js
esbuild.build({
entryPoints: ['./src/index.ts'],
bundle: true,
outfile: './dist/node.js',
platform: 'node',
}).catch(() => process.exit(1));
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["<rootDir>/test/**/*.tests.ts"],
};

Loading