Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buttercms

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buttercms - npm Package Compare versions

Comparing version 1.2.15 to 2.0.0

.nvmrc

97

__tests__/butter.test.js

@@ -1,36 +0,83 @@

const butter = require('../lib/butter')('api_token');
import Butter from "../lib/butter.js";
test('should retrive a single page', async () => {
const singlePageResponse = await butter.page.retrieve('*', 'example-news-page', {
"locale": "en",
"preview": 1
})
const butter = Butter("api_token");
const response = await singlePageResponse.data;
const status_code = await singlePageResponse.status;
test(
"should retrieve a single page",
async () => {
await expect(status_code).toEqual(200);
const singlePageResponse = await butter.page.retrieve(
"*",
"example-news-page",
{
"locale": "en",
"preview": 1
}
)
await expect(response.data.fields.headline).toEqual("This is an example news page");
await expect(response.data.slug).toEqual("example-news-page")
await expect(response.data.page_type).not.toEqual("sport")
});
const response = await singlePageResponse;
test('should list pages by single-pages', async () => {
const singlePageResponse = await butter.page.list('*')
await expect(response.data.fields.headline).toEqual("This is an example news page");
await expect(response.data.slug).toEqual("example-news-page")
await expect(response.data.page_type).not.toEqual("sport")
const response = await singlePageResponse.data;
const status_code = await singlePageResponse.status;
return
}
);
await expect(status_code).toEqual(200);
test(
"should respond with error when access a bad page slug",
async () => {
try {
const singlePageResponse = await butter.page.retrieve(
"*",
"fake-post-slug",
{
"locale": "en",
"preview": 1
}
)
}
catch (error) {
await expect(error).toBeInstanceOf(Error);
await expect(error.message).toEqual("TypeError: Failed to fetch");
}
return
await expect(response.meta.count).toEqual(2);
await expect(response.data).toHaveLength(2);
}
);
const firstPage = response.data[0];
test(
"should list pages by single-pages",
async () => {
const response = await butter.page.list('*')
await expect(response.meta.count).toEqual(2);
await expect(response.data).toHaveLength(2);
const firstPage = response.data[0];
await expect(firstPage).toHaveProperty('slug', 'single-page-1');
await expect(firstPage).toHaveProperty('fields.title', 'This is a single page');
await expect(firstPage).not.toHaveProperty('date_time');
}
)
await expect(firstPage).toHaveProperty('slug', 'single-page-1');
await expect(firstPage).toHaveProperty('fields.title', 'This is a single page');
test(
"should catch and relay error when page type not found",
async () => {
try {
await butter.page.list('as')
}
catch (error) {
await expect(error).toBeDefined();
await expect(error).toBeInstanceOf(Error);
await expect(error.message).toEqual("Error: Not found");
}
await expect(firstPage).not.toHaveProperty('date_time');
})
return
}
)
# Changelog
## [2.0.0](https://github.com/ButterCMS/buttercms-js/)(2023-02-01)
### Added
- Added support for Node.js v18
- Added support for native fetch API
- Added explicit `cancelRequest` method to cancel requests
- Added native fetch timeout support
- Added 'onRequest' hook to modify request before it is sent
- Added 'onError' hook to inspect error before it is thrown if error before server
- Added 'onError' hook to inspect error after it is thrown if error is from fetch or internal browser issue
- Added 'onResponse' hook to inspect response before it is returned
### Removed
- Removed support for Node.js v14 and v16
- Removed support for axios
## [1.2.16](https://github.com/ButterCMS/buttercms-js/releases/tag/Node-Pre-16) (2023-12-07)
This is the last release for Node v14 (and 16) and uses axios for API requests. This branch will no longer be maintained.
## Updated
- Updated version number
## [1.2.15](https://github.com/ButterCMS/buttercms-js/compare/v1.2.14...v1.2.15) (2023-10-23)

@@ -4,0 +28,0 @@

@@ -1,3 +0,3 @@

module.exports = {
export default {
setupFilesAfterEnv: ['./jest.setup.js'],
}

@@ -1,2 +0,2 @@

const server = require('./mocks/server.js');
import { server } from "./mocks/server.js";

@@ -3,0 +3,0 @@ beforeAll(() => server.listen())

'use strict';
var BUTTER_CLIENT_VERSION = '1.2.15'; // {x-release-please-version}
import { BUTTER_CLIENT_VERSION } from './constants.js';
const axios = require('axios').default;
import Author from './resources/Author.js';
import Category from './resources/Category.js';
import Content from './resources/Content.js';
import Feed from './resources/Feed.js';
import Page from './resources/Page.js';
import Post from './resources/Post.js';
import Tag from './resources/Tag.js';
var resources = {
Post: require('./resources/Post'),
Category: require('./resources/Category'),
Tag: require('./resources/Tag'),
Author: require('./resources/Author'),
Feed: require('./resources/Feed'),
Content: require('./resources/Content'),
Page: require('./resources/Page')
}
function Butter(apiToken, testMode, timeout, axiosHook) {
if (!(this instanceof Butter)) {
return new Butter(apiToken, testMode, timeout, axiosHook);
}
if (!apiToken) {
throw 'ButterCMS API token not set';
}
// Use live mode by default
var testMode = testMode || false;
// 3000ms timeout by default
var timeout = timeout || 3000;
var requestMethods = this._prepMethods(apiToken, testMode, timeout, axiosHook);
this._prepResources(requestMethods);
/**
* An object mapping the names of resources to their corresponding modules.
* Each module provides methods for interacting with a specific type of resource in the ButterCMS API.
*
* @type {Object}
* @property {Object} Author - The module for interacting with author resources.
* @property {Object} Category - The module for interacting with category resources.
* @property {Object} Content - The module for interacting with content resources.
* @property {Object} Feed - The module for interacting with feed resources.
* @property {Object} Page - The module for interacting with page resources.
* @property {Object} Post - The module for interacting with post resources.
* @property {Object} Tag - The module for interacting with tag resources.
*/
const resources = {
Author,
Category,
Content,
Feed,
Page,
Post,
Tag,
}
Butter.prototype = {
version: BUTTER_CLIENT_VERSION,
_prepResources: function(requestMethods) {
for (var name in resources) {
this[
name[0].toLowerCase() + name.substring(1)
] = new resources[name](requestMethods);
/**
* Default export function for the ButterCMS library.
*
* @param {string} apiToken - The API token for the ButterCMS service.
* @param {Object} [options={}] - Optional configuration options for the ButterCMS service.
* @throws Will throw an error if the API token is not set.
* @returns {Butter} An instance of the ButterCMS service.
*/
export default function (apiToken, options = {}) {
if (!apiToken) {
throw 'ButterCMS API token not set';
}
},
_prepMethods: function(apiToken, testMode, timeout, axiosHook) {
return {
get: function(url, params) {
var headers = {'X-Butter-Client': 'JS/' + BUTTER_CLIENT_VERSION}
// detect if library is called in server side
if (typeof window === 'undefined'){
headers['Accept-Encoding'] = 'gzip'
}
var conn = axios.create({
baseURL: 'https://api.buttercms.com/v2',
timeout: timeout,
headers: headers
});
if (axiosHook) {
axiosHook(conn)
}
if (!(this instanceof Butter)) {
return new Butter(apiToken, options);
}
var params = params || {};
return Butter
};
// Add api token to query string
params.auth_token = apiToken;
/**
* The Butter function is the main entry point for interacting with the ButterCMS API.
* It takes an API token and an options object as parameters, and returns an object
* that provides methods for interacting with different types of resources in the API.
*
* @param {string} apiToken - The API token for the ButterCMS service.
* @param {Object} options - Configuration options for the ButterCMS service.
* @property {string} options.cache - The cache mode for requests (default is "default").
* @property {Function} options.onError - A function to be called when an error occurs during a request.
* @property {Function} options.onRequest - A function to be called just before a request is made.
* @property {Function} options.onResponse - A function to be called when a response is received.
* @property {boolean} options.testMode - Whether to use test mode or live mode (default is false, which means live mode).
* @property {number} options.timeout - The timeout for requests in milliseconds (default is 3000ms).
* @returns {Object} An object that provides methods for interacting with the ButterCMS API.
*/
function Butter (apiToken, options ) {
const {
cache = "default",
onError = null,
onRequest = null,
onResponse = null,
testMode = false,
timeout = 3000,
} = options;
// Append &test=1&preview=1 query strings
if (testMode) {
params.test = 1
params.preview = 1
}
const config = {
apiToken,
cache,
onError,
onRequest,
onResponse,
testMode,
timeout,
}
return conn.get(url, {params: params})
}
return {
version: BUTTER_CLIENT_VERSION,
...mapResources(resources, config)
}
}
}
module.exports = Butter;
/**
* Maps resource functions to their respective keys in lowercase.
*
* @param {Object} resources - An object containing resource functions.
* @param {Object} config - The configuration object to pass to each resource function.
* @returns {Object} An object with the same keys as `resources`, but in lowercase, and values as the result of calling the respective function with `config`.
*/
function mapResources (resources, config) {
return Object.keys(resources)
.reduce(
(funcs, key) => ({
...funcs,
[key.toLocaleLowerCase()]: resources[key](config)
}),
{}
)
}
'use strict';
function Author(conn) {
this._conn = conn;
}
import useButter from "../useButter.js";
Author.prototype = {
list: function(options) {
return this._conn.get('authors/', options)
},
retrieve: function(slug, options) {
return this._conn.get('authors/'+slug+'/', options)
}
/**
* Creates an object for interacting with author resources in the ButterCMS API.
*
* @param {Object} [config={}] - Configuration options for the ButterCMS service.
* @property {string} config.apiToken - The API token for the ButterCMS service.
* @property {string} config.cache - The cache mode for requests (default is "default").
* @property {Function} config.onError - A function to be called when an error occurs during a request.
* @property {Function} config.onRequest - A function to be called just before a request is made.
* @property {Function} config.onResponse - A function to be called when a response is received.
* @property {boolean} config.testMode - Whether to use test mode or live mode (default is false, which means live mode).
* @property {number} config.timeout - The timeout for requests in milliseconds (default is 3000ms).
* @returns {Object} An object containing methods to interact with author resources.
* @property {Function} cancelRequest - A function to cancel the fetch request.
* @property {Function} list - A function to retrieve a list of author resources.
* @property {Function} retrieve - A function to retrieve a specific author resource.
*/
export default function Author (config = {}) {
const {
cancelRequest,
list,
retrieve
} = useButter("author", config);
return {
cancelRequest,
list,
retrieve
}
}
module.exports = Author;
'use strict';
function Category(conn) {
this._conn = conn;
}
import useButter from "../useButter.js";
Category.prototype = {
list: function(options) {
return this._conn.get('categories/', options)
},
retrieve: function(slug, options) {
return this._conn.get('categories/'+slug+'/', options)
}
/**
* Creates an object for interacting with category resources in the ButterCMS API.
*
* @param {Object} [config={}] - Configuration options for the ButterCMS service.
* @property {string} config.apiToken - The API token for the ButterCMS service.
* @property {string} config.cache - The cache mode for requests (default is "default").
* @property {Function} config.onError - A function to be called when an error occurs during a request.
* @property {Function} config.onRequest - A function to be called just before a request is made.
* @property {Function} config.onResponse - A function to be called when a response is received.
* @property {boolean} config.testMode - Whether to use test mode or live mode (default is false, which means live mode).
* @property {number} config.timeout - The timeout for requests in milliseconds (default is 3000ms).
* @returns {Object} An object containing methods to interact with category resources.
* @property {Function} cancelRequest - A function to cancel the fetch request.
* @property {Function} list - A function to retrieve a list of category resources.
* @property {Function} retrieve - A function to retrieve a specific category resource.
*/
export default function Category (config = {}) {
const {
cancelRequest,
list,
retrieve
} = useButter("category", config);
return {
cancelRequest,
list,
retrieve
}
}
module.exports = Category;
'use strict';
function Content(conn) {
this._conn = conn;
}
import useButter from "../useButter.js";
Content.prototype = {
retrieve: function(keys, options) {
var keys = keys || [];
var options = options || {};
var params = Object.assign({keys: keys.join()}, options);
/**
* Creates an object for interacting with content resources in the ButterCMS API.
*
* @param {Object} [config={}] - Configuration options for the ButterCMS service.
* @property {string} config.apiToken - The API token for the ButterCMS service.
* @property {string} config.cache - The cache mode for requests (default is "default").
* @property {Function} config.onError - A function to be called when an error occurs during a request.
* @property {Function} config.onRequest - A function to be called just before a request is made.
* @property {Function} config.onResponse - A function to be called when a response is received.
* @property {boolean} config.testMode - Whether to use test mode or live mode (default is false, which means live mode).
* @property {number} config.timeout - The timeout for requests in milliseconds (default is 3000ms).
* @returns {Object} An object containing methods to interact with content resources.
* @property {Function} cancelRequest - A function to cancel the fetch request.
* @property {Function} retrieve - A function to retrieve content resources.
*/
export default function Content (config = {}) {
const {
cancelRequest,
retrieve
} = useButter("content", config);
return this._conn.get('content/', params)
}
}
module.exports = Content;
return {
cancelRequest,
retrieve
}
};
'use strict';
function Feed(conn) {
this._conn = conn;
}
import useButter from "../useButter.js";
Feed.prototype = {
retrieve: function(type, options) {
return this._conn.get('feeds/'+type+'/', options)
}
/**
* Creates an object for interacting with feed resources in the ButterCMS API.
*
* @param {Object} [config={}] - Configuration options for the ButterCMS service.
* @property {string} config.apiToken - The API token for the ButterCMS service.
* @property {string} config.cache - The cache mode for requests (default is "default").
* @property {Function} config.onError - A function to be called when an error occurs during a request.
* @property {Function} config.onRequest - A function to be called just before a request is made.
* @property {Function} config.onResponse - A function to be called when a response is received.
* @property {boolean} config.testMode - Whether to use test mode or live mode (default is false, which means live mode).
* @property {number} config.timeout - The timeout for requests in milliseconds (default is 3000ms).
* @returns {Object} An object containing methods to interact with feed resources.
* @property {Function} cancelRequest - A function to cancel the fetch request.
* @property {Function} retrieve - A function to retrieve feed resources.
*/
export default function Feed (config = {}) {
const {
cancelRequest,
retrieve
} = useButter("feed", config);
return {
cancelRequest,
retrieve
}
}
module.exports = Feed;
'use strict';
function Page(conn) {
this._conn = conn;
}
import useButter from "../useButter.js";
Page.prototype = {
list: function(page_type, options) {
return this._conn.get('pages/'+page_type+'/', options)
},
retrieve: function(page_type, page_slug, options) {
return this._conn.get('pages/'+page_type+'/'+page_slug+'/', options)
},
search: function(query, options) {
var options = options || {};
options.query = query || '';
/**
* Creates an object for interacting with page resources in the ButterCMS API.
*
* @param {Object} [config={}] - Configuration options for the ButterCMS service.
* @property {string} config.apiToken - The API token for the ButterCMS service.
* @property {string} config.cache - The cache mode for requests (default is "default").
* @property {Function} config.onError - A function to be called when an error occurs during a request.
* @property {Function} config.onRequest - A function to be called just before a request is made.
* @property {Function} config.onResponse - A function to be called when a response is received.
* @property {boolean} config.testMode - Whether to use test mode or live mode (default is false, which means live mode).
* @property {number} config.timeout - The timeout for requests in milliseconds (default is 3000ms).
* @returns {Object} An object containing methods to interact with page resources.
* @property {Function} cancelRequest - A function to cancel the fetch request.
* @property {Function} list - A function to retrieve a list of page resources.
* @property {Function} retrieve - A function to retrieve a specific page resource.
* @property {Function} search - A function to search within page resources.
*/
export default function Page (config = {}) {
const {
cancelRequest,
retrieve,
search
} = useButter("page", config);
return this._conn.get('pages/search/', options)
}
}
module.exports = Page;
return {
cancelRequest,
/**
* Retrieves a list of page resources from the ButterCMS API.
*
* @async
* @function list
* @param {string} pageType - The type of page to retrieve.
* @param {Object} options - Additional options for the request.
* @returns {Promise<Object>} A promise that resolves to the list of page resources.
*/
async list (pageType, options) {
return await retrieve(
pageType,
options,
);
},
/**
* Retrieves a specific page resource from the ButterCMS API.
*
* @async
* @function retrieve
* @param {string} pageType - The type of page to retrieve.
* @param {string} pageSlug - The slug of the specific page to retrieve.
* @param {Object} options - Additional options for the request.
* @returns {Promise<Object>} A promise that resolves to the specific page resource.
*/
async retrieve (pageType, pageSlug, options) {
return await retrieve(
`${ pageType }/${ pageSlug }`,
options,
);
},
search,
}
};
'use strict';
function Post(conn) {
this._conn = conn;
}
import useButter from "../useButter.js";
Post.prototype = {
list: function(options) {
return this._conn.get('posts/', options)
},
retrieve: function(slug, options) {
return this._conn.get('posts/'+slug+'/', options)
},
search: function(query, options) {
var options = options || {};
options.query = query || '';
/**
* Creates an object for interacting with post resources in the ButterCMS API.
*
* @param {Object} [config={}] - Configuration options for the ButterCMS service.
* @property {string} config.apiToken - The API token for the ButterCMS service.
* @property {string} config.cache - The cache mode for requests (default is "default").
* @property {Function} config.onError - A function to be called when an error occurs during a request.
* @property {Function} config.onRequest - A function to be called just before a request is made.
* @property {Function} config.onResponse - A function to be called when a response is received.
* @property {boolean} config.testMode - Whether to use test mode or live mode (default is false, which means live mode).
* @property {number} config.timeout - The timeout for requests in milliseconds (default is 3000ms).
* @returns {Object} An object containing methods to interact with post resources.
* @property {Function} cancelRequest - A function to cancel the fetch request.
* @property {Function} list - A function to retrieve a list of post resources.
* @property {Function} retrieve - A function to retrieve a specific post resource.
* @property {Function} search - A function to search within post resources.
*/
export default function Post (config = {}) {
const {
cancelRequest,
list,
retrieve,
search
} = useButter("post", config);
return this._conn.get('posts/search/', options)
}
}
module.exports = Post;
return {
cancelRequest,
list,
retrieve,
search
}
};
'use strict';
function Tag(conn) {
this._conn = conn;
}
import useButter from "../useButter.js";
Tag.prototype = {
list: function(options) {
return this._conn.get('tags/', options)
},
retrieve: function(slug, options) {
return this._conn.get('tags/'+slug+'/', options)
}
/**
* Creates an object for interacting with tag resources in the ButterCMS API.
*
* @param {Object} [config={}] - Configuration options for the ButterCMS service.
* @property {string} config.apiToken - The API token for the ButterCMS service.
* @property {string} config.cache - The cache mode for requests (default is "default").
* @property {Function} config.onError - A function to be called when an error occurs during a request.
* @property {Function} config.onRequest - A function to be called just before a request is made.
* @property {Function} config.onResponse - A function to be called when a response is received.
* @property {boolean} config.testMode - Whether to use test mode or live mode (default is false, which means live mode).
* @property {number} config.timeout - The timeout for requests in milliseconds (default is 3000ms).
* @returns {Object} An object containing methods to interact with tag resources.
* @property {Function} cancelRequest - A function to cancel the fetch request.
* @property {Function} list - A function to retrieve a list of tag resources.
* @property {Function} retrieve - A function to retrieve a specific tag resource.
*/
export default function Tag (config = {}) {
const {
cancelRequest,
list,
retrieve
} = useButter("tag", config);
return {
cancelRequest,
list,
retrieve
}
}
module.exports = Tag;

@@ -1,27 +0,39 @@

const msw = require("msw");
const page = require('./responses/page/page.json');
const pageList = require('./responses/page/list.json');
import { http, HttpResponse } from 'msw'
import page from "./responses/page/page.json";
import pageList from "./responses/page/list.json";
const singlePostHandler =
msw.rest.get("https://api.buttercms.com/v2/pages/*/example-news-page/", (_, res, ctx) => {
return res(ctx.status(200), ctx.json(page));
})
const singlePostHandler = http.get(
"https://api.buttercms.com/v2/pages/*/example-news-page/",
() => HttpResponse.json(page)
)
const failedSinglePostHandler =
msw.rest.get("https://api.buttercms.com/v2/pages/*/fake-post-slug/", (_, res, ctx) => {
return res(ctx.status(401));
})
const failedSinglePostHandler = http.get(
"https://api.buttercms.com/v2/pages/*/fake-post-slug/",
() => HttpResponse.error("Failed to fetch")
)
const listPageHandler =
msw.rest.get("https://api.buttercms.com/v2/pages/*/", (_, res, ctx) => {
return res(
ctx.status(200),
ctx.json(pageList)
const listPageHandlerError = http.get(
"https://api.buttercms.com/v2/pages/as/",
() => HttpResponse.json(
{
detail: "Error: Not found",
},
{
status: 404
}
)
})
)
module.exports = [
const listPageHandler = http.get(
"https://api.buttercms.com/v2/pages/*/",
() => HttpResponse.json(pageList)
)
export default [
singlePostHandler,
failedSinglePostHandler,
listPageHandlerError,
listPageHandler,
];

@@ -1,6 +0,4 @@

const msw = require('msw/node');
const handlers = require('./handlers.js')
import { setupServer } from "msw/node"
import handlers from "./handlers.js"
const server = msw.setupServer(...handlers)
module.exports = server
export const server = setupServer(...handlers)
{
"name": "buttercms",
"version": "1.2.15",
"version": "2.0.0",
"description": "ButterCMS API Client",

@@ -13,8 +13,8 @@ "keywords": [

"engines": {
"node": ">=0.10.32"
"node": ">=18.17.1"
},
"scripts": {
"build": "webpack && uglifyjs ./dist/butter.js -c -m -o ./dist/butter.min.js",
"run-implementation-test": "cd tests && python3 -m http.server",
"test-build": "webpack && uglifyjs ./dist/butter.js -c -m -o ./tests/lib/butter.min.js",
"run-dev": "cd tests && python3 -m http.server",
"build-dev": "webpack && uglifyjs ./dist/butter.js -c -m -o ./tests/lib/butter.min.js",
"test": "npm run build && npm run test:all",

@@ -33,14 +33,11 @@ "test:all": "npm run jest",

"types": "lib/butter.d.ts",
"type": "commonjs",
"dependencies": {
"axios": "~0.21.1"
},
"type": "module",
"license": "MIT",
"devDependencies": {
"jest": "^29.4.1",
"msw": "^1.1.0",
"jest": "^29.7.0",
"msw": "^2.0.11",
"uglify-js": "^3.17.4",
"webpack": "^5.81.0",
"webpack-cli": "^5.0.2"
"webpack": "^5.90.1",
"webpack-cli": "^5.1.4"
}
}

@@ -11,3 +11,3 @@ # ButterCMS JS client

Requires Node.js version 10 or greater.
Requires Node.js version 18 or greater.

@@ -30,11 +30,7 @@ ```bash

```js
const butter = require('buttercms')('api_token_567abe');
```
Using ES6 or Typescript:
```js
import Butter from 'buttercms';
const butter = Butter('api_token_567abe');
import Butter from "buttercms";
const butter = Butter("api_token_567abe");
```

@@ -46,3 +42,3 @@

<script>
const butter = Butter('api_token_567abe');
const butter = Butter("api_token_567abe");
</script>

@@ -55,7 +51,24 @@ ```

// Get blog posts
butter.post.list({page: 1, page_size: 10}).then(function(response) {
console.log(response)
})
butter.post.list({page: 1, page_size: 10})
.then(function(response) {
console.log(response)
})
.catch(function(error) {
console.error(error)
})
```
If using `async`/`await`:
```js
async function getPosts() {
try {
const response = await butter.post.list({page: 1, page_size: 10});
console.log(response);
} catch (error) {
console.error(error);
}
}
```
## Pages

@@ -68,6 +81,8 @@

* `list(page_type[, params])`
* `search(query[, params])`
* `cancelRequest()`
```js
// Get page
butter.page.retrieve('casestudy', 'acme-co').then(function(resp) {
butter.page.retrieve("casestudy", "acme-co").then(function(resp) {
console.log(resp)

@@ -77,2 +92,15 @@ });

If using `async`/`await`:
```js
async function getPage() {
try {
const response = await butter.page.retrieve("casestudy", "acme-co");
console.log(response);
} catch (error) {
console.error(error);
}
}
```
## Collections

@@ -82,10 +110,24 @@

* `retrieve(collection[, params])`
* `cancelRequest()`
```js
// Get FAQ
butter.content.retrieve(["faq"], {locale: 'es'}).then(function(resp) {
butter.content.retrieve("faq", {locale: "es"}).then(function(resp) {
console.log(resp)
});
```
If using `async`/`await`:
```js
async function getFAQ() {
try {
const response = await butter.content.retrieve("faq", {locale: "es"});
console.log(response);
} catch (error) {
console.error(error);
}
}
```
### Preview mode

@@ -96,3 +138,6 @@

```js
const butter = require('buttercms')('your butter API token', true);
const butter = Butter(
"your butter API token",
{ testMode: true }
);
```

@@ -103,3 +148,6 @@

```js
const butter = require('buttercms')('your butter API token', process.env.BUTTER_PREVIEW_MODE);
const butter = Butter(
"your butter API token",
{ testMode: process.env.BUTTER_PREVIEW_MODE }
);
```

@@ -113,13 +161,18 @@

* `search(query[, params])`
* `cancelRequest()`
* category
* `retrieve(slug[, params])`
* `list([params])`
* `cancelRequest()`
* tag
* `retrieve(slug[, params])`
* `list([params])`
* `cancelRequest()`
* author
* `retrieve(slug[, params])`
* `list([params])`
* `cancelRequest()`
* feed
* `retrieve(type[, params])`
* `cancelRequest()`

@@ -133,21 +186,98 @@ See our [node app](https://github.com/buttercms/nodejs-cms-express-blog) for a full example.

```js
const butter = require('buttercms')('your butter API token', false, 5000);
const butter = Butter(
"your butter API token",
{ timeout: 5000 }
);
```
## Axios hook
## Caching
If you need to custom headers, caching, automatic retry or any other specific functionality on the transport layer, you can hook up into the [Axios](https://github.com/axios/axios) instance creation process. Supply the `axiosHook` callback parameter and Butter will call you when Axios is being created:
The default cache is set to `default`:
```js
function axiosHook(axios) {
axios.interceptors.request.use(function requestLogger(config) {
console.warn("Axios requested", config.url, config.params)
const butter = Butter(
"your butter API token",
{ cache: "only-if-cached" }
);
```
return config;
})
}
## Canceling a request
const butter = require('buttercms')('your butter API token', false, 5000, axiosHook);
Each resource returns a `cancelRequest` method that can be used to cancel a request:
```js
butter.post.cancelRequest();
```
This will cancel all pending requests for that resource type. It will catch the cancelation and return a rejected Promise for your `.catch()` method or be able to be caught in an `async` function via a `try`/`catch` block.
## Hooks
If you need to custom headers, caching, automatic retry or any other specific functionality on the transport layer, you can hook up into our fetch hooks. The following hooks are available as Butter configuration options:
```js
const butter = Butter(
"your butter API token",
{
onError: Function,
onRequest: Function,
onResponse: Function
}
);
```
**onRequest** - called prior to making a request to the API. This can be declared as an async function to allow for async operations to be performed before the request is made.
`onRequest(resource, config)`
`resource` - The resource is the Butter API endpoint to be called
`config` - This is the configuration object that will be used to make the request
`config` includes:
`cancelRequest` - A function that can be called to cancel the request in the hook
`headers` - The headers that will be sent with the request. This is in the JS `Headers` API format. Users are able to modify these headers in the hook.
`options` - Options are the original config options set when initializing the Butter instance. This includes the `cache`, `testMode`, `timeout`. Hook functions are not included in this object.
`params` - The query parameters that will be sent with the request. Users are able to modify these parameters in the hook.
`type` - The type of resource api that is being requested. This string helps the developer to differentiate what resource is being called in the global hook.
`options`, `headers`, and `params` are to be returned by the onRequest hook for further processing and request.
**onResponse** - called after a response is received from the API. This can be declared as an async function to allow for async operations to be performed after the response is received.
`onResponse (response, config)`
`response` - The response object that was received from the API. This is in the JS `Fetch Response` API format and is a clone of the original response object. This will allow the user to parse the response to get the data they need whether it be JSON, text, blob, etc. The original response will be returned as JSON to the resource function call's promise resolution.
`config` - This is the configuration object that was used to make the request
`config` includes:
`options` - Options are the original config options set when initializing the Butter instance. This includes the `cache`, `testMode`, `timeout`. Hook functions are not included in this object.
`params` - The query parameters were sent with the request.
`type` - The type of resource api that was requested. This string helps the developer to differentiate what resource was called in the global hook.
`onResponse` expects no return values.
**onError** - called when an error is received from the API. This is not considered an async function.
`onError (errors, config)`
`errors` - the errors returned from the API and/or the fetch request. Comes in the following object format:
```
{
details: "Error details",
}
```
`config` includes:
`options` - Options are the original config options set when initializing the Butter instance. This includes the `cache`, `testMode`, `timeout`. Hook functions are not included in this object.
`params` - The query parameters were sent with the request.
`type` - The type of resource api that was requested. This string helps the developer to differentiate what resource was called in the global hook.
`onError` expects no return values.
## Documentation

@@ -154,0 +284,0 @@

@@ -1,1 +0,1 @@

var Butter;(()=>{"use strict";var r={628:(e,t,r)=>{var a="1.2.11";const c=r(218).default;var n={Post:r(728),Category:r(788),Tag:r(985),Author:r(298),Feed:r(863),Content:r(461),Page:r(881)};function o(e,t,r,n){if(!(this instanceof o))return new o(e,t,r,n);if(!e)throw"ButterCMS API token not set";e=this._prepMethods(e,t=t||!1,r=r||3e3,n);this._prepResources(e)}o.prototype={version:a,_prepResources:function(e){for(var t in n)this[t[0].toLowerCase()+t.substring(1)]=new n[t](e)},_prepMethods:function(n,o,i,s){return{get:function(e,t){var r={"X-Butter-Client":"JS/"+a},r=("undefined"==typeof window&&(r["Accept-Encoding"]="gzip"),c.create({baseURL:"https://api.buttercms.com/v2",timeout:i,headers:r}));return s&&s(r),(t=t||{}).auth_token=n,o&&(t.test=1,t.preview=1),r.get(e,{params:t})}}}},e.exports=o},298:e=>{function t(e){this._conn=e}t.prototype={list:function(e){return this._conn.get("authors/",e)},retrieve:function(e,t){return this._conn.get("authors/"+e+"/",t)}},e.exports=t},788:e=>{function t(e){this._conn=e}t.prototype={list:function(e){return this._conn.get("categories/",e)},retrieve:function(e,t){return this._conn.get("categories/"+e+"/",t)}},e.exports=t},461:e=>{function t(e){this._conn=e}t.prototype={retrieve:function(e,t){e=e||[],t=t||{};e=Object.assign({keys:e.join()},t);return this._conn.get("content/",e)}},e.exports=t},863:e=>{function t(e){this._conn=e}t.prototype={retrieve:function(e,t){return this._conn.get("feeds/"+e+"/",t)}},e.exports=t},881:e=>{function t(e){this._conn=e}t.prototype={list:function(e,t){return this._conn.get("pages/"+e+"/",t)},retrieve:function(e,t,r){return this._conn.get("pages/"+e+"/"+t+"/",r)},search:function(e,t){return(t=t||{}).query=e||"",this._conn.get("pages/search/",t)}},e.exports=t},728:e=>{function t(e){this._conn=e}t.prototype={list:function(e){return this._conn.get("posts/",e)},retrieve:function(e,t){return this._conn.get("posts/"+e+"/",t)},search:function(e,t){return(t=t||{}).query=e||"",this._conn.get("posts/search/",t)}},e.exports=t},985:e=>{function t(e){this._conn=e}t.prototype={list:function(e){return this._conn.get("tags/",e)},retrieve:function(e,t){return this._conn.get("tags/"+e+"/",t)}},e.exports=t},218:(L,D,e)=>{function k(e,t){return function(){return e.apply(t,arguments)}}const q=Object.prototype["toString"],c=Object["getPrototypeOf"],r=(t=Object.create(null),e=>{e=q.call(e);return t[e]||(t[e]=e.slice(8,-1).toLowerCase())});var t,n,I;const o=t=>(t=t.toLowerCase(),e=>r(e)===t),i=t=>e=>typeof e===t,a=Array["isArray"],s=i("undefined"),M=o("ArrayBuffer"),z=i("string"),u=i("function"),H=i("number"),l=e=>null!==e&&"object"==typeof e,f=e=>{var t;return"object"===r(e)&&!(null!==(t=c(e))&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},J=o("Date"),W=o("File"),K=o("Blob"),V=o("FileList"),G=o("URLSearchParams");function d(r,n,{allOwnKeys:o=!1}={}){if(null!=r){let t,e;if("object"!=typeof r&&(r=[r]),a(r))for(t=0,e=r.length;t<e;t++)n.call(null,r[t],t,r);else{const e=o?Object.getOwnPropertyNames(r):Object.keys(r),s=e.length;var i;for(t=0;t<s;t++)i=e[t],n.call(null,r[i],i,r)}}}function $(e,t){t=t.toLowerCase();var r=Object.keys(e);let n,o=r.length;for(;0<o--;)if(t===(n=r[o]).toLowerCase())return n;return null}const X="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:e.g,Q=e=>!s(e)&&e!==X,Z=(n="undefined"!=typeof Uint8Array&&c(Uint8Array),o("HTMLFormElement")),Y=(I=[Object.prototype["hasOwnProperty"]][0],(e,t)=>I.call(e,t)),ee=o("RegExp"),te=(r,n)=>{const e=Object.getOwnPropertyDescriptors(r),o={};d(e,(e,t)=>{!1!==n(e,t,r)&&(o[t]=e)}),Object.defineProperties(r,o)},p="abcdefghijklmnopqrstuvwxyz",re="0123456789",ne={DIGIT:re,ALPHA:p,ALPHA_DIGIT:p+p.toUpperCase()+re};var h={isArray:a,isArrayBuffer:M,isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&u(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{var t;return e&&("function"==typeof FormData&&e instanceof FormData||u(e.append)&&("formdata"===(t=r(e))||"object"===t&&u(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&M(e.buffer)},isString:z,isNumber:H,isBoolean:e=>!0===e||!1===e,isObject:l,isPlainObject:f,isUndefined:s,isDate:J,isFile:W,isBlob:K,isRegExp:ee,isFunction:u,isStream:e=>l(e)&&u(e.pipe),isURLSearchParams:G,isTypedArray:e=>n&&e instanceof n,isFileList:V,forEach:d,merge:function r(){const n=(Q(this)&&this||{})["caseless"],o={},i=(e,t)=>{t=n&&$(o,t)||t;f(o[t])&&f(e)?o[t]=r(o[t],e):f(e)?o[t]=r({},e):a(e)?o[t]=e.slice():o[t]=e};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&d(arguments[e],i);return o},extend:(r,e,n,{allOwnKeys:t}={})=>(d(e,(e,t)=>{n&&u(e)?r[t]=k(e,n):r[t]=e},{allOwnKeys:t}),r),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>e=65279===e.charCodeAt(0)?e.slice(1):e,inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let o,i,s;var a={};if(t=t||{},null!=e)do{for(o=Object.getOwnPropertyNames(e),i=o.length;0<i--;)s=o[i],n&&!n(s,e,t)||a[s]||(t[s]=e[s],a[s]=!0)}while((e=!1!==r&&c(e))&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:r,kindOfTest:o,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;e=e.indexOf(t,r);return-1!==e&&e===r},toArray:e=>{if(!e)return null;if(a(e))return e;let t=e.length;if(!H(t))return null;for(var r=new Array(t);0<t--;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);for(var n;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{for(var r,n=[];null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:Z,hasOwnProperty:Y,hasOwnProp:Y,reduceDescriptors:te,freezeMethods:n=>{te(n,(e,t)=>{if(u(n)&&-1!==["arguments","caller","callee"].indexOf(t))return!1;var r=n[t];u(r)&&(e.enumerable=!1,"writable"in e?e.writable=!1:e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")}))})},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach(e=>{r[e]=!0})};return a(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(e,t)=>(e=+e,Number.isFinite(e)?e:t),findKey:$,global:X,isContextDefined:Q,ALPHABET:ne,generateString:(e=16,t=ne.ALPHA_DIGIT)=>{let r="";for(var n=t["length"];e--;)r+=t[Math.random()*n|0];return r},isSpecCompliantForm:function(e){return!!(e&&u(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),o=(e,r)=>{if(l(e)){if(0<=t.indexOf(e))return;if(!("toJSON"in e)){t[r]=e;const n=a(e)?[]:{};return d(e,(e,t)=>{e=o(e,r+1);s(e)||(n[t]=e)}),t[r]=void 0,n}}return e};return o(e,0)}};function m(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}h.inherits(m,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:h.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const oe=m.prototype,ie={};function g(e){return h.isPlainObject(e)||h.isArray(e)}function se(e){return h.endsWith(e,"[]")?e.slice(0,-2):e}function ae(e,t,r){return e?e.concat(t).map(function(e,t){return e=se(e),!r&&t?"["+e+"]":e}).join(r?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{ie[e]={value:e}}),Object.defineProperties(m,ie),Object.defineProperty(oe,"isAxiosError",{value:!0}),m.from=(e,t,r,n,o,i)=>{var s=Object.create(oe);return h.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e),m.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};const ce=h.toFlatObject(h,{},null,function(e){return/^is[A-Z]/.test(e)});function y(e,i,t){if(!h.isObject(e))throw new TypeError("target must be an object");i=i||new FormData;const s=(t=h.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!h.isUndefined(t[e])})).metaTokens,o=t.visitor||n,a=t.dots,c=t.indexes,r=(t.Blob||"undefined"!=typeof Blob&&Blob)&&h.isSpecCompliantForm(i);if(!h.isFunction(o))throw new TypeError("visitor must be a function");function u(e){if(null===e)return"";if(h.isDate(e))return e.toISOString();if(!r&&h.isBlob(e))throw new m("Blob is not supported. Use a Buffer instead.");return h.isArrayBuffer(e)||h.isTypedArray(e)?r&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function n(e,r,t){let n=e;if(e&&!t&&"object"==typeof e)if(h.endsWith(r,"{}"))r=s?r:r.slice(0,-2),e=JSON.stringify(e);else if(h.isArray(e)&&(o=e,h.isArray(o))&&!o.some(g)||(h.isFileList(e)||h.endsWith(r,"[]"))&&(n=h.toArray(e)))return r=se(r),n.forEach(function(e,t){h.isUndefined(e)||null===e||i.append(!0===c?ae([r],t,a):null===c?r:r+"[]",u(e))}),!1;var o;return!!g(e)||(i.append(ae(t,r,a),u(e)),!1)}const l=[],f=Object.assign(ce,{defaultVisitor:n,convertValue:u,isVisitable:g});if(h.isObject(e))return function r(e,n){if(!h.isUndefined(e)){if(-1!==l.indexOf(e))throw Error("Circular reference detected in "+n.join("."));l.push(e),h.forEach(e,function(e,t){!0===(!(h.isUndefined(e)||null===e)&&o.call(i,e,h.isString(t)?t.trim():t,n,f))&&r(e,n?n.concat(t):[t])}),l.pop()}}(e),i;throw new TypeError("data must be an object")}function ue(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function b(e,t){this._pairs=[],e&&y(e,this,t)}e=b.prototype;function le(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function fe(e,t,r){if(t){var n=r&&r.encode||le,o=r&&r.serialize,o=o?o(t,r):h.isURLSearchParams(t)?t.toString():new b(t,r).toString(n);if(o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}}return e}e.append=function(e,t){this._pairs.push([e,t])},e.toString=function(t){const r=t?function(e){return t.call(this,e,ue)}:ue;return this._pairs.map(function(e){return r(e[0])+"="+r(e[1])},"").join("&")};var de=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){h.forEach(this.handlers,function(e){null!==e&&t(e)})}},pe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},w={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:b,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},isStandardBrowserEnv:("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&"undefined"!=typeof window&&"undefined"!=typeof document,isStandardBrowserWebWorkerEnv:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,protocols:["http","https","file","blob","url","data"]};function he(e){if(h.isFormData(e)&&h.isFunction(e.entries)){const r={};return h.forEachEntry(e,(e,t)=>{!function e(t,r,n,o){var i=t[o++],s=Number.isFinite(+i),a=o>=t.length,i=!i&&h.isArray(n)?n.length:i;return a?h.hasOwnProp(n,i)?n[i]=[n[i],r]:n[i]=r:(n[i]&&h.isObject(n[i])||(n[i]=[]),e(t,r,n[i],o)&&h.isArray(n[i])&&(n[i]=function(e){var t={},r=Object.keys(e);let n;var o,i=r.length;for(n=0;n<i;n++)t[o=r[n]]=e[o];return t}(n[i]))),!s}(h.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0]),t,r,0)}),r}return null}const me={"Content-Type":void 0},E={transitional:pe,adapter:["xhr","http"],transformRequest:[function(e,t){var r,n,o=t.getContentType()||"",i=-1<o.indexOf("application/json"),s=h.isObject(e);if(s&&h.isHTMLForm(e)&&(e=new FormData(e)),h.isFormData(e))return i?JSON.stringify(he(e)):e;if(!(h.isArrayBuffer(e)||h.isBuffer(e)||h.isStream(e)||h.isFile(e)||h.isBlob(e))){if(h.isArrayBufferView(e))return e.buffer;if(h.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();if(s){if(-1<o.indexOf("application/x-www-form-urlencoded"))return r=e,n=this.formSerializer,y(r,new w.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return w.isNode&&h.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},n)).toString();if((r=h.isFileList(e))||-1<o.indexOf("multipart/form-data")){const t=this.env&&this.env.FormData;return y(r?{"files[]":e}:e,t&&new t,this.formSerializer)}}if(s||i){t.setContentType("application/json",!1);var a=e;if(h.isString(a))try{return(0,JSON.parse)(a),h.trim(a)}catch(a){if("SyntaxError"!==a.name)throw a}return(0,JSON.stringify)(a)}}return e}],transformResponse:[function(e){const t=this.transitional||E.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&h.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw m.from(e,m.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:w.classes.FormData,Blob:w.classes.Blob},validateStatus:function(e){return 200<=e&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};h.forEach(["delete","get","head"],function(e){E.headers[e]={}}),h.forEach(["post","put","patch"],function(e){E.headers[e]=h.merge(me)});var O=E;const ge=h.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ye=Symbol("internals");function v(e){return e&&String(e).trim().toLowerCase()}function S(e){return!1===e||null==e?e:h.isArray(e)?e.map(S):String(e)}function R(e,t,r,n,o){return h.isFunction(n)?n.call(this,t,r):h.isString(t=o?r:t)&&(h.isString(n)?-1!==t.indexOf(n):h.isRegExp(n)&&n.test(t))}class A{constructor(e){e&&this.set(e)}set(e,t,r){const o=this;function n(e,t,r){var n=v(t);if(!n)throw new Error("header name must be a non-empty string");n=h.findKey(o,n);n&&void 0!==o[n]&&!0!==r&&(void 0!==r||!1===o[n])||(o[n||t]=S(e))}var i=(e,r)=>h.forEach(e,(e,t)=>n(e,t,r));return h.isPlainObject(e)||e instanceof this.constructor?i(e,t):h.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?i((()=>{const t={};let r,n,o;return e&&e.split("\n").forEach(function(e){o=e.indexOf(":"),r=e.substring(0,o).trim().toLowerCase(),n=e.substring(o+1).trim(),!r||t[r]&&ge[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t})(),t):null!=e&&n(t,e,r),this}get(e,t){if(e=v(e)){var r=h.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t){for(var n,o=e,i=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;n=s.exec(o);)i[n[1]]=n[2];return i}if(h.isFunction(t))return t.call(this,e,r);if(h.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){return!!(e=v(e))&&!(!(e=h.findKey(this,e))||void 0===this[e]||t&&!R(0,this[e],e,t))}delete(e,t){const r=this;let n=!1;function o(e){(e=v(e))&&(e=h.findKey(r,e))&&(!t||R(0,r[e],e,t))&&(delete r[e],n=!0)}return h.isArray(e)?e.forEach(o):o(e),n}clear(e){var t=Object.keys(this);let r=t.length,n=!1;for(;r--;){var o=t[r];e&&!R(0,this[o],o,e,!0)||(delete this[o],n=!0)}return n}normalize(n){const o=this,i={};return h.forEach(this,(e,t)=>{var r=h.findKey(i,t);r?(o[r]=S(e),delete o[t]):((r=n?t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r):String(t).trim())!==t&&delete o[t],o[r]=S(e),i[r]=!0)}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(r){const n=Object.create(null);return h.forEach(this,(e,t)=>{null!=e&&!1!==e&&(n[t]=r&&h.isArray(e)?e.join(", "):e)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(e=>r.set(e)),r}static accessor(e){const n=(this[ye]=this[ye]={accessors:{}}).accessors,s=this.prototype;function t(e){var t=v(e);if(!n[t]){{var r=s,o=e;const i=h.toCamelCase(" "+o);["get","set","has"].forEach(n=>{Object.defineProperty(r,n+i,{value:function(e,t,r){return this[n].call(this,o,e,t,r)},configurable:!0})})}n[t]=!0}}return h.isArray(e)?e.forEach(t):t(e),this}}A.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),h.freezeMethods(A.prototype),h.freezeMethods(A);var T=A;function _(e,t){const r=this||O,n=t||r,o=T.from(n.headers);let i=n.data;return h.forEach(e,function(e){i=e.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function be(e){return!(!e||!e.__CANCEL__)}function x(e,t,r){m.call(this,null==e?"canceled":e,m.ERR_CANCELED,t,r),this.name="CanceledError"}h.inherits(x,m,{__CANCEL__:!0});var we=w.isStandardBrowserEnv?{write:function(e,t,r,n,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),h.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),h.isString(n)&&s.push("path="+n),h.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){e=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function Ee(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?(e=e,(r=t)?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e):t;var r}var Oe=w.isStandardBrowserEnv?function(){const r=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let t;function o(e){let t=e;return r&&(n.setAttribute("href",t),t=n.href),n.setAttribute("href",t),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=o(window.location.href),function(e){e=h.isString(e)?o(e):e;return e.protocol===t.protocol&&e.host===t.host}}():function(){return!0};function ve(i,s){let a=0;const c=function(){const i=new Array(50),s=new Array(50);let a,c=0,u=0;return function(e){var t=Date.now(),r=s[u];a=a||t,i[c]=e,s[c]=t;let n=u,o=0;for(;n!==c;)o+=i[n++],n%=50;return(c=(c+1)%50)===u&&(u=(u+1)%50),!(t-a<250)&&(e=r&&t-r)?Math.round(1e3*o/e):void 0}}();return e=>{var t=e.loaded,r=e.lengthComputable?e.total:void 0,n=t-a,o=c(n),n={loaded:a=t,total:r,progress:r?t/r:void 0,bytes:n,rate:o||void 0,estimated:o&&r&&t<=r?(r-t)/o:void 0,event:e};n[s?"download":"upload"]=!0,i(n)}}const j={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(l){return new Promise(function(r,n){var e=l.data;const t=T.from(l.headers).normalize(),o=l.responseType;let i;function s(){l.cancelToken&&l.cancelToken.unsubscribe(i),l.signal&&l.signal.removeEventListener("abort",i)}h.isFormData(e)&&(w.isStandardBrowserEnv||w.isStandardBrowserWebWorkerEnv)&&t.setContentType(!1);let a=new XMLHttpRequest;if(l.auth){const r=l.auth.username||"",n=l.auth.password?unescape(encodeURIComponent(l.auth.password)):"";t.set("Authorization","Basic "+btoa(r+":"+n))}var c=Ee(l.baseURL,l.url);function u(){var e,t;a&&(e=T.from("getAllResponseHeaders"in a&&a.getAllResponseHeaders()),e={data:o&&"text"!==o&&"json"!==o?a.response:a.responseText,status:a.status,statusText:a.statusText,headers:e,config:l,request:a},t=e.config.validateStatus,e.status&&t&&!t(e.status)?(t=new m("Request failed with status code "+e.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e),n(t)):r(e),s(),a=null)}if(a.open(l.method.toUpperCase(),fe(c,l.params,l.paramsSerializer),!0),a.timeout=l.timeout,"onloadend"in a?a.onloadend=u:a.onreadystatechange=function(){a&&4===a.readyState&&(0!==a.status||a.responseURL&&0===a.responseURL.indexOf("file:"))&&setTimeout(u)},a.onabort=function(){a&&(n(new m("Request aborted",m.ECONNABORTED,l,a)),a=null)},a.onerror=function(){n(new m("Network Error",m.ERR_NETWORK,l,a)),a=null},a.ontimeout=function(){let e=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded";var t=l.transitional||pe;l.timeoutErrorMessage&&(e=l.timeoutErrorMessage),n(new m(e,t.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,l,a)),a=null},w.isStandardBrowserEnv){const r=(l.withCredentials||Oe(c))&&l.xsrfCookieName&&we.read(l.xsrfCookieName);r&&t.set(l.xsrfHeaderName,r)}void 0===e&&t.setContentType(null),"setRequestHeader"in a&&h.forEach(t.toJSON(),function(e,t){a.setRequestHeader(t,e)}),h.isUndefined(l.withCredentials)||(a.withCredentials=!!l.withCredentials),o&&"json"!==o&&(a.responseType=l.responseType),"function"==typeof l.onDownloadProgress&&a.addEventListener("progress",ve(l.onDownloadProgress,!0)),"function"==typeof l.onUploadProgress&&a.upload&&a.upload.addEventListener("progress",ve(l.onUploadProgress)),(l.cancelToken||l.signal)&&(i=e=>{a&&(n(!e||e.type?new x(null,l,a):e),a.abort(),a=null)},l.cancelToken&&l.cancelToken.subscribe(i),l.signal)&&(l.signal.aborted?i():l.signal.addEventListener("abort",i));c=(c=/^([-+\w]{1,25})(:?\/\/|:)/.exec(c))&&c[1]||"";c&&-1===w.protocols.indexOf(c)?n(new m("Unsupported protocol "+c+":",m.ERR_BAD_REQUEST,l)):a.send(e||null)})}};function C(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new x(null,e)}function Se(t){return C(t),t.headers=T.from(t.headers),t.data=_.call(t,t.transformRequest),-1!==["post","put","patch"].indexOf(t.method)&&t.headers.setContentType("application/x-www-form-urlencoded",!1),(t=>{var r=(t=h.isArray(t)?t:[t])["length"];let n,o;for(let e=0;e<r&&(n=t[e],!(o=h.isString(n)?j[n.toLowerCase()]:n));e++);if(!o){if(!1===o)throw new m(`Adapter ${n} is not supported by the environment`,"ERR_NOT_SUPPORT");throw new Error(h.hasOwnProp(j,n)?`Adapter '${n}' is not available in the build`:`Unknown adapter '${n}'`)}if(h.isFunction(o))return o;throw new TypeError("adapter is not a function")})(t.adapter||O.adapter)(t).then(function(e){return C(t),e.data=_.call(t,t.transformResponse,e),e.headers=T.from(e.headers),e},function(e){return be(e)||(C(t),e&&e.response&&(e.response.data=_.call(t,t.transformResponse,e.response),e.response.headers=T.from(e.response.headers))),Promise.reject(e)})}h.forEach(j,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const Re=e=>e instanceof T?e.toJSON():e;function N(n,o){o=o||{};const i={};function s(e,t,r){return h.isPlainObject(e)&&h.isPlainObject(t)?h.merge.call({caseless:r},e,t):h.isPlainObject(t)?h.merge({},t):h.isArray(t)?t.slice():t}function a(e,t,r){return h.isUndefined(t)?h.isUndefined(e)?void 0:s(void 0,e,r):s(e,t,r)}function e(e,t){if(!h.isUndefined(t))return s(void 0,t)}function t(e,t){return h.isUndefined(t)?h.isUndefined(e)?void 0:s(void 0,e):s(void 0,t)}function c(e,t,r){return r in o?s(e,t):r in n?s(void 0,e):void 0}const u={url:e,method:e,data:e,baseURL:t,transformRequest:t,transformResponse:t,paramsSerializer:t,timeout:t,timeoutMessage:t,withCredentials:t,adapter:t,responseType:t,xsrfCookieName:t,xsrfHeaderName:t,onUploadProgress:t,onDownloadProgress:t,decompress:t,maxContentLength:t,maxBodyLength:t,beforeRedirect:t,transport:t,httpAgent:t,httpsAgent:t,cancelToken:t,socketPath:t,responseEncoding:t,validateStatus:c,headers:(e,t)=>a(Re(e),Re(t),!0)};return h.forEach(Object.keys(n).concat(Object.keys(o)),function(e){var t=u[e]||a,r=t(n[e],o[e],e);h.isUndefined(r)&&t!==c||(i[e]=r)}),i}const Ae={},Te=(["object","boolean","number","function","string","symbol"].forEach((t,r)=>{Ae[t]=function(e){return typeof e===t||"a"+(r<1?"n ":" ")+t}}),{});Ae.transitional=function(n,o,r){function i(e,t){return"[Axios v1.3.6] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(e,t,r)=>{if(!1===n)throw new m(i(t," has been removed"+(o?" in "+o:"")),m.ERR_DEPRECATED);return o&&!Te[t]&&(Te[t]=!0,console.warn(i(t," has been deprecated since v"+o+" and will be removed in the near future"))),!n||n(e,t,r)}};var _e={assertOptions:function(e,t,r){if("object"!=typeof e)throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);var n=Object.keys(e);let o=n.length;for(;0<o--;){var i=n[o],s=t[i];if(s){const t=e[i],r=void 0===t||s(t,i,e);if(!0!==r)throw new m("option "+i+" must be "+r,m.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}},validators:Ae};const P=_e.validators;class U{constructor(e){this.defaults=e,this.interceptors={request:new de,response:new de}}request(t,r){"string"==typeof t?(r=r||{}).url=t:r=t||{};const{transitional:e,paramsSerializer:n,headers:o}=r=N(this.defaults,r);var i;void 0!==e&&_e.assertOptions(e,{silentJSONParsing:P.transitional(P.boolean),forcedJSONParsing:P.transitional(P.boolean),clarifyTimeoutError:P.transitional(P.boolean)},!1),null!=n&&(h.isFunction(n)?r.paramsSerializer={serialize:n}:_e.assertOptions(n,{encode:P.function,serialize:P.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase(),(i=o&&h.merge(o.common,o[r.method]))&&h.forEach(["delete","get","head","post","put","patch","common"],e=>{delete o[e]}),r.headers=T.concat(i,o);const s=[];let a=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(r)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const c=[];let u;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,f=0;if(a){l=s.length;let e=r;for(f=0;f<l;){const t=s[f++],r=s[f++];try{e=t(e)}catch(t){r.call(this,t);break}}try{u=Se.call(this,e)}catch(t){return Promise.reject(t)}for(f=0,l=c.length;f<l;)u=u.then(c[f++],c[f++])}else{const t=[Se.bind(this),void 0];for(t.unshift.apply(t,s),t.push.apply(t,c),l=t.length,u=Promise.resolve(r);f<l;)u=u.then(t[f++],t[f++])}return u}getUri(e){return fe(Ee((e=N(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}h.forEach(["delete","get","head","options"],function(r){U.prototype[r]=function(e,t){return this.request(N(t||{},{method:r,url:e,data:(t||{}).data}))}}),h.forEach(["post","put","patch"],function(o){function e(n){return function(e,t,r){return this.request(N(r||{},{method:o,headers:n?{"Content-Type":"multipart/form-data"}:{},url:e,data:t}))}}U.prototype[o]=e(),U.prototype[o+"Form"]=e(!0)});var B=U;e=class Ce{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(e){n=e});const o=this;this.promise.then(t=>{if(o._listeners){let e=o._listeners.length;for(;0<e--;)o._listeners[e](t);o._listeners=null}}),this.promise.then=e=>{let t;return(e=new Promise(e=>{o.subscribe(e),t=e}).then(e)).cancel=function(){o.unsubscribe(t)},e},e(function(e,t,r){o.reason||(o.reason=new x(e,t,r),n(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){this._listeners&&-1!==(e=this._listeners.indexOf(e))&&this._listeners.splice(e,1)}static source(){let t;return{token:new Ce(function(e){t=e}),cancel:t}}};const xe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(xe).forEach(([e,t])=>{xe[t]=e});var je=xe,F=function t(r){var e=new B(r),n=k(B.prototype.request,e);return h.extend(n,B.prototype,e,{allOwnKeys:!0}),h.extend(n,e,null,{allOwnKeys:!0}),n.create=function(e){return t(N(r,e))},n}(O);F.Axios=B,F.CanceledError=x,F.CancelToken=e,F.isCancel=be,F.VERSION="1.3.6",F.toFormData=y,F.AxiosError=m,F.Cancel=F.CanceledError,F.all=function(e){return Promise.all(e)},F.spread=function(t){return function(e){return t.apply(null,e)}},F.isAxiosError=function(e){return h.isObject(e)&&!0===e.isAxiosError},F.mergeConfig=N,F.AxiosHeaders=T,F.formToJSON=e=>he(h.isHTMLForm(e)?new FormData(e):e),F.HttpStatusCode=je,F.default=F,L.exports=F}},n={};function o(e){var t=n[e];return void 0!==t||(t=n[e]={exports:{}},r[e](t,t.exports,o)),t.exports}o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();var e=o(628);Butter=e})();
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Butter=t():e.Butter=t()}(this,()=>(()=>{"use strict";var r={d:(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},e={};r.d(e,{default:()=>function(e,t={}){if(e)return this instanceof n?n:new n(e,t);throw"ButterCMS API token not set"}});const j="2.0.0",t={author:"authors",category:"categories",content:"content",feed:"feeds",page:"pages",post:"posts",tag:"tags"};function E(e,t){const{onError:n,onRequest:r,onResponse:o,...a}=t.config,{auth_token:s,test:c,preview:i,...u}=t.params;n&&n(e,{options:a,params:u,type:t.type})}function C(e,t,n){t={auth_token:t};return n.testMode&&(t.test=1,t.preview=1),{...e,...t}}function o(m,g){e=m;const y=`https://api.buttercms.com/v2/${t[e]}/`,q=m.replace(m[0],m[0].toUpperCase()),{cancelRequest:w,controller:b}=function(e){const t=new AbortController;return{cancelRequest:async function(){await t.abort(e+": Request cancelled")},controller:t}}(q);var e;async function n(e=y,t={}){const{apiToken:n,...r}=g,o=new Headers({"Content-Type":"application/json","X-Butter-Client":"JS/"+j});"undefined"==typeof window&&o.append("Accept-Encoding","gzip");var{config:t,headers:a,params:s}=await async function(e,t,n){const{onError:r,onRequest:o,onResponse:a,...s}=n.config;var c,i;return o?({headers:e,options:c,params:i}=await o(e,{cancelRequest:n.cancelRequest,headers:n.headers,options:s,params:n.params,type:n.type}),{config:{...c,onError:r,onRequest:o,onResponse:a},headers:e,params:C(i,t,c)}):{...n,params:C(n.params,t,s)}}(e,n,{cancelRequest:w,config:r,headers:o,params:t,type:m});try{const{cleanup:g,signal:j}=function(e,t,n){const r=setTimeout(()=>{e.abort(t+`: Request timed out after ${n}ms.`)},n);return{cleanup:()=>clearTimeout(r),signal:e.signal}}(b,q,t.timeout),E=await fetch(e+"?"+new URLSearchParams(s),{cache:t.cache,method:"GET",headers:a,signal:j});if(g(),200!==E.status)throw{response:E,config:t,params:s};{var c=E;var i={config:t,params:s,type:m};const{onError:u,onRequest:p,onResponse:l,...f}=i.config,{auth_token:d,test:v,preview:R,...h}=i.params;if(l){const u=c.clone();await l(u,{options:f,params:h,type:i.type})}return await c.json();return await void 0}}catch(e){if(e.response){const j=(await e.response.json())["detail"];return E(j,{config:e.config,params:e.params,type:m}),Promise.reject(new Error(j))}{const j=b.signal.reason&&b.signal.aborted?b.signal.reason:e;return E(j,{config:t,params:s,type:m}),Promise.reject(new Error(j))}}}return{cancelRequest:w,list:async function(e={}){return n(y,e)},retrieve:async function(e,t){return n(y+e+"/",t)},search:async function(e="",t={}){return t.query=e,n(y+"search/",t)}}}const u={Author:function(e={}){var{cancelRequest:e,list:t,retrieve:n}=o("author",e);return{cancelRequest:e,list:t,retrieve:n}},Category:function(e={}){var{cancelRequest:e,list:t,retrieve:n}=o("category",e);return{cancelRequest:e,list:t,retrieve:n}},Content:function(e={}){var{cancelRequest:e,retrieve:t}=o("content",e);return{cancelRequest:e,retrieve:t}},Feed:function(e={}){var{cancelRequest:e,retrieve:t}=o("feed",e);return{cancelRequest:e,retrieve:t}},Page:function(e={}){const{cancelRequest:t,retrieve:r,search:n}=o("page",e);return{cancelRequest:t,list:async(e,t)=>r(e,t),retrieve:async(e,t,n)=>r(e+"/"+t,n),search:n}},Post:function(e={}){var{cancelRequest:e,list:t,retrieve:n,search:r}=o("post",e);return{cancelRequest:e,list:t,retrieve:n,search:r}},Tag:function(e={}){var{cancelRequest:e,list:t,retrieve:n}=o("tag",e);return{cancelRequest:e,list:t,retrieve:n}}};function n(e,t){var n,r,{cache:t="default",onError:o=null,onRequest:a=null,onResponse:s=null,testMode:c=!1,timeout:i=3e3}=t;return{version:j,...(n=u,r={apiToken:e,cache:t,onError:o,onRequest:a,onResponse:s,testMode:c,timeout:i},Object.keys(n).reduce((e,t)=>({...e,[t.toLocaleLowerCase()]:n[t](r)}),{}))}}return e.default})());

@@ -1,10 +0,23 @@

var path = require('path');
import * as url from 'url';
import path from "path";
import webpack from "webpack";
module.exports = {
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
export default {
entry: './lib/butter.js',
mode: "production",
output: {
filename: 'butter.js',
globalObject: "this",
library: 'Butter',
libraryTarget: 'umd',
libraryExport: 'default',
path: path.resolve(__dirname, 'dist')
}
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
})
]
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc