payload 0.20.10-beta.0 → 1.0.6

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 (56) hide show
  1. package/CHANGELOG.md +89 -379
  2. package/components/styles.css +1 -1
  3. package/dist/admin/components/elements/Banner/index.scss +1 -0
  4. package/dist/admin/components/elements/Nav/index.js +2 -2
  5. package/dist/admin/components/forms/field-types/Array/Array.js +1 -1
  6. package/dist/admin/components/forms/field-types/Blocks/Blocks.js +1 -1
  7. package/dist/admin/components/forms/field-types/Checkbox/index.js +1 -1
  8. package/dist/admin/components/forms/field-types/Code/Code.js +1 -1
  9. package/dist/admin/components/forms/field-types/DateTime/index.js +1 -1
  10. package/dist/admin/components/forms/field-types/Email/index.js +2 -2
  11. package/dist/admin/components/forms/field-types/Group/index.js +1 -1
  12. package/dist/admin/components/forms/field-types/HiddenInput/index.js +1 -1
  13. package/dist/admin/components/forms/field-types/Number/index.js +2 -2
  14. package/dist/admin/components/forms/field-types/Password/index.js +2 -2
  15. package/dist/admin/components/forms/field-types/Point/index.js +4 -4
  16. package/dist/admin/components/forms/field-types/RadioGroup/Input.js +1 -1
  17. package/dist/admin/components/forms/field-types/Relationship/index.js +1 -1
  18. package/dist/admin/components/forms/field-types/RichText/RichText.js +2 -2
  19. package/dist/admin/components/forms/field-types/RichText/elements/upload/Element/index.scss +12 -1
  20. package/dist/admin/components/forms/field-types/RichText/index.scss +7 -0
  21. package/dist/admin/components/forms/field-types/Select/Input.js +2 -2
  22. package/dist/admin/components/forms/field-types/Text/Input.js +2 -2
  23. package/dist/admin/components/forms/field-types/Textarea/Input.js +2 -2
  24. package/dist/admin/components/forms/field-types/Upload/Input.js +1 -1
  25. package/dist/admin/components/views/Global/Default.js +1 -1
  26. package/dist/admin/scss/type.scss +1 -1
  27. package/dist/config/types.d.ts +2 -2
  28. package/dist/index.d.ts +2 -1
  29. package/dist/index.js +10 -93
  30. package/dist/init.d.ts +5 -0
  31. package/dist/init.js +115 -0
  32. package/docs/admin/overview.mdx +4 -0
  33. package/docs/authentication/config.mdx +49 -18
  34. package/package.json +7 -12
  35. package/dist/collections/graphql/resolvers/resolvers.spec.d.ts +0 -1
  36. package/dist/collections/graphql/resolvers/resolvers.spec.js +0 -360
  37. package/dist/collections/operations/local/local.spec.d.ts +0 -1
  38. package/dist/collections/operations/local/local.spec.js +0 -196
  39. package/dist/collections/tests/collections.spec.d.ts +0 -1
  40. package/dist/collections/tests/collections.spec.js +0 -736
  41. package/dist/collections/tests/defaultValue.spec.d.ts +0 -1
  42. package/dist/collections/tests/defaultValue.spec.js +0 -95
  43. package/dist/collections/tests/endpoints.spec.d.ts +0 -1
  44. package/dist/collections/tests/endpoints.spec.js +0 -71
  45. package/dist/collections/tests/hooks.spec.d.ts +0 -1
  46. package/dist/collections/tests/hooks.spec.js +0 -156
  47. package/dist/collections/tests/pointField.spec.d.ts +0 -1
  48. package/dist/collections/tests/pointField.spec.js +0 -219
  49. package/dist/collections/tests/relationships.spec.d.ts +0 -1
  50. package/dist/collections/tests/relationships.spec.js +0 -194
  51. package/dist/express/middleware/errorHandler.spec.d.ts +0 -1
  52. package/dist/express/middleware/errorHandler.spec.js +0 -91
  53. package/dist/globals/requestHandlers/globals.spec.d.ts +0 -4
  54. package/dist/globals/requestHandlers/globals.spec.js +0 -174
  55. package/dist/preferences/graphql/resolvers.spec.d.ts +0 -1
  56. package/dist/preferences/graphql/resolvers.spec.js +0 -115
package/dist/init.js ADDED
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.initSync = exports.initAsync = exports.init = void 0;
7
+ /* eslint-disable no-param-reassign */
8
+ const express_1 = __importDefault(require("express"));
9
+ const crypto_1 = __importDefault(require("crypto"));
10
+ const authenticate_1 = __importDefault(require("./express/middleware/authenticate"));
11
+ const connect_1 = __importDefault(require("./mongoose/connect"));
12
+ const middleware_1 = __importDefault(require("./express/middleware"));
13
+ const admin_1 = __importDefault(require("./express/admin"));
14
+ const init_1 = __importDefault(require("./auth/init"));
15
+ const access_1 = __importDefault(require("./auth/requestHandlers/access"));
16
+ const init_2 = __importDefault(require("./collections/init"));
17
+ const init_3 = __importDefault(require("./preferences/init"));
18
+ const init_4 = __importDefault(require("./globals/init"));
19
+ const initPlayground_1 = __importDefault(require("./graphql/initPlayground"));
20
+ const static_1 = __importDefault(require("./express/static"));
21
+ const registerSchema_1 = __importDefault(require("./graphql/registerSchema"));
22
+ const graphQLHandler_1 = __importDefault(require("./graphql/graphQLHandler"));
23
+ const build_1 = __importDefault(require("./email/build"));
24
+ const identifyAPI_1 = __importDefault(require("./express/middleware/identifyAPI"));
25
+ const errorHandler_1 = __importDefault(require("./express/middleware/errorHandler"));
26
+ const sendEmail_1 = __importDefault(require("./email/sendEmail"));
27
+ const serverInit_1 = require("./utilities/telemetry/events/serverInit");
28
+ const load_1 = __importDefault(require("./config/load"));
29
+ const logger_1 = __importDefault(require("./utilities/logger"));
30
+ const init = (payload, options) => {
31
+ payload.logger.info('Starting Payload...');
32
+ if (!options.secret) {
33
+ throw new Error('Error: missing secret key. A secret key is needed to secure Payload.');
34
+ }
35
+ if (options.mongoURL !== false && typeof options.mongoURL !== 'string') {
36
+ throw new Error('Error: missing MongoDB connection URL.');
37
+ }
38
+ payload.emailOptions = { ...(options.email) };
39
+ payload.secret = crypto_1.default
40
+ .createHash('sha256')
41
+ .update(options.secret)
42
+ .digest('hex')
43
+ .slice(0, 32);
44
+ payload.local = options.local;
45
+ payload.config = (0, load_1.default)(payload.logger);
46
+ // If not initializing locally, scaffold router
47
+ if (!payload.local) {
48
+ payload.router = express_1.default.Router();
49
+ payload.router.use(...(0, middleware_1.default)(payload));
50
+ (0, init_1.default)(payload);
51
+ }
52
+ // Configure email service
53
+ payload.email = (0, build_1.default)(payload.emailOptions, payload.logger);
54
+ payload.sendEmail = sendEmail_1.default.bind(payload);
55
+ // Initialize collections & globals
56
+ (0, init_2.default)(payload);
57
+ (0, init_4.default)(payload);
58
+ if (!payload.config.graphQL.disable) {
59
+ (0, registerSchema_1.default)(payload);
60
+ }
61
+ // If not initializing locally, set up HTTP routing
62
+ if (!payload.local) {
63
+ options.express.use((req, res, next) => {
64
+ req.payload = payload;
65
+ next();
66
+ });
67
+ payload.express = options.express;
68
+ if (payload.config.rateLimit.trustProxy) {
69
+ payload.express.set('trust proxy', 1);
70
+ }
71
+ (0, admin_1.default)(payload);
72
+ (0, init_3.default)(payload);
73
+ payload.router.get('/access', access_1.default);
74
+ if (!payload.config.graphQL.disable) {
75
+ payload.router.use(payload.config.routes.graphQL, (0, identifyAPI_1.default)('GraphQL'), (req, res) => (0, graphQLHandler_1.default)(req, res)(req, res));
76
+ (0, initPlayground_1.default)(payload);
77
+ }
78
+ // Bind router to API
79
+ payload.express.use(payload.config.routes.api, payload.router);
80
+ // Enable static routes for all collections permitting upload
81
+ (0, static_1.default)(payload);
82
+ payload.errorHandler = (0, errorHandler_1.default)(payload.config, payload.logger);
83
+ payload.router.use(payload.errorHandler);
84
+ payload.authenticate = (0, authenticate_1.default)(payload.config);
85
+ }
86
+ (0, serverInit_1.serverInit)(payload);
87
+ };
88
+ exports.init = init;
89
+ const initAsync = async (payload, options) => {
90
+ payload.logger = (0, logger_1.default)('payload', options.loggerOptions);
91
+ payload.mongoURL = options.mongoURL;
92
+ if (payload.mongoURL) {
93
+ payload.mongoMemoryServer = await (0, connect_1.default)(payload.mongoURL, options.mongoOptions, payload.logger);
94
+ }
95
+ (0, exports.init)(payload, options);
96
+ if (typeof options.onInit === 'function')
97
+ await options.onInit(payload);
98
+ if (typeof payload.config.onInit === 'function')
99
+ await payload.config.onInit(payload);
100
+ };
101
+ exports.initAsync = initAsync;
102
+ const initSync = (payload, options) => {
103
+ payload.logger = (0, logger_1.default)('payload', options.loggerOptions);
104
+ payload.mongoURL = options.mongoURL;
105
+ if (payload.mongoURL) {
106
+ (0, connect_1.default)(payload.mongoURL, options.mongoOptions, payload.logger);
107
+ }
108
+ (0, exports.init)(payload, options);
109
+ if (typeof options.onInit === 'function')
110
+ options.onInit(payload);
111
+ if (typeof payload.config.onInit === 'function')
112
+ payload.config.onInit(payload);
113
+ };
114
+ exports.initSync = initSync;
115
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5pdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbml0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLHNDQUFzQztBQUN0QyxzREFBNEM7QUFDNUMsb0RBQTRCO0FBTTVCLHFGQUE2RDtBQUM3RCxpRUFBaUQ7QUFDakQsc0VBQXFEO0FBQ3JELDREQUF3QztBQUN4Qyx1REFBbUM7QUFDbkMsMkVBQW1EO0FBQ25ELDhEQUFpRDtBQUNqRCw4REFBaUQ7QUFDakQsMERBQXlDO0FBQ3pDLDhFQUE2RDtBQUM3RCw4REFBMEM7QUFDMUMsOEVBQXNEO0FBQ3RELDhFQUFzRDtBQUN0RCwwREFBdUM7QUFDdkMsbUZBQTJEO0FBQzNELHFGQUE2RDtBQUU3RCxrRUFBMEM7QUFFMUMsd0VBQTRGO0FBRTVGLHlEQUF1QztBQUN2QyxnRUFBd0M7QUFFakMsTUFBTSxJQUFJLEdBQUcsQ0FBQyxPQUFnQixFQUFFLE9BQW9CLEVBQVEsRUFBRTtJQUNuRSxPQUFPLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxxQkFBcUIsQ0FBQyxDQUFDO0lBQzNDLElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxFQUFFO1FBQ25CLE1BQU0sSUFBSSxLQUFLLENBQ2Isc0VBQXNFLENBQ3ZFLENBQUM7S0FDSDtJQUVELElBQUksT0FBTyxDQUFDLFFBQVEsS0FBSyxLQUFLLElBQUksT0F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LFFBQVEsRUFBRSxPQUFPLENBQUMsWUFBWSxFQUFFLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztLQUN6RTtJQUVELElBQUEsWUFBSSxFQUFDLE9BQU8sRUFBRSxPQUFPLENBQUMsQ0FBQztJQUV2QixJQUFJLE9BQU8sT0FBTyxDQUFDLE1BQU0sS0FBSyxVQUFVO1FBQUUsT0FBTyxDQUFDLE1BQU0sQ0FBQyxPQUFPLENBQUMsQ0FBQztJQUNsRSxJQUFJLE9BQU8sT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLEtBQUssVUFBVTtRQUFFLE9BQU8sQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0FBQ2xGLENBQUMsQ0FBQztBQVpXLFFBQUEsUUFBUSxZQVluQiJ9
@@ -66,6 +66,10 @@ For example, you may wish to have two Collections that both support `Authenticat
66
66
 
67
67
  This is totally possible. For the above scenario, by specifying `admin: { user: 'admins' }`, your Payload Admin panel will use `admins`. Any users logged in as `customers` will not be able to log in via the Admin panel.
68
68
 
69
+ ### Light and dark modes
70
+
71
+ Users in the admin panel have access to choosing between light mode and dark mode for their editing experience. The setting is managed while logged into the admin UI within the user account page and will be stored with the browser. By default, the operating system preference is detected and used.
72
+
69
73
  ### Restricting user access
70
74
 
71
75
  If you would like to restrict which users from a single Collection can access the Admin panel, you can use the `admin` access control function. [Click here](/docs/access-control/overview#admin) to learn more.
@@ -12,16 +12,18 @@ To enable Authentication on a collection, define an `auth` property and set it t
12
12
 
13
13
  ## Options
14
14
 
15
- | Option | Description |
16
- | ---------------------- | -------------|
17
- | **`useAPIKey`** | Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection. [More](/docs/authentication/config#api-keys) |
18
- | **`tokenExpiration`** | How long (in seconds) to keep the user logged in. JWTs and HTTP-only cookies will both expire at the same time. |
19
- | **`maxLoginAttempts`** | Only allow a user to attempt logging in X amount of times. Automatically locks out a user from authenticating if this limit is passed. Set to `0` to disable. |
20
- | **`lockTime`** | Set the time that a user should be locked out if they fail authentication more times than `maxLoginAttempts` allows for. |
21
- | **`depth`** | How many levels deep a `user` document should be populated when creating the JWT and binding the `user` to the express `req`. Defaults to `0` and should only be modified if absolutely necessary, as this will affect performance. |
22
- | **`cookies`** | Set cookie options, including `secure`, `sameSite`, and `domain`. For advanced users. |
23
- | **`forgotPassword`** | Customize the way that the `forgotPassword` operation functions. [More](/docs/authentication/config#forgot-password) |
24
- | **`verify`** | Set to `true` or pass an object with verification options to require users to verify by email before they are allowed to log into your app. [More](/docs/authentication/config#email-verification) |
15
+ | Option | Description |
16
+ | -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | **`useAPIKey`** | Payload Authentication provides for API keys to be set on each user within an Authentication-enabled Collection. [More](/docs/authentication/config#api-keys) |
18
+ | **`tokenExpiration`** | How long (in seconds) to keep the user logged in. JWTs and HTTP-only cookies will both expire at the same time. |
19
+ | **`maxLoginAttempts`** | Only allow a user to attempt logging in X amount of times. Automatically locks out a user from authenticating if this limit is passed. Set to `0` to disable. |
20
+ | **`lockTime`** | Set the time that a user should be locked out if they fail authentication more times than `maxLoginAttempts` allows for. |
21
+ | **`depth`** | How many levels deep a `user` document should be populated when creating the JWT and binding the `user` to the express `req`. Defaults to `0` and should only be modified if absolutely necessary, as this will affect performance. |
22
+ | **`cookies`** | Set cookie options, including `secure`, `sameSite`, and `domain`. For advanced users. |
23
+ | **`forgotPassword`** | Customize the way that the `forgotPassword` operation functions. [More](/docs/authentication/config#forgot-password) |
24
+ | **`verify`** | Set to `true` or pass an object with verification options to require users to verify by email before they are allowed to log into your app. [More](/docs/authentication/config#email-verification) |
25
+ | **`disableLocalStrategy`** | Advanced - disable Payload's built-in local auth strategy. Only use this property if you have replaced Payload's auth mechanisms with your own. |
26
+ | **`strategies`** | Advanced - an array of PassportJS authentication strategies to extend this collection's authentication with. [More](/docs/authentication/config#strategies) |
25
27
 
26
28
  ### API keys
27
29
 
@@ -37,7 +39,8 @@ Technically, both of these options will work for third-party integrations but th
37
39
  To enable API keys on a collection, set the `useAPIKey` auth option to `true`. From there, a new interface will appear in the Admin panel for each document within the collection that allows you to generate an API key for each user in the Collection.
38
40
 
39
41
  <Banner type="success">
40
- User API keys are encrypted within the database, meaning that if your database is compromised, your API keys will not be.
42
+ User API keys are encrypted within the database, meaning that if your database
43
+ is compromised, your API keys will not be.
41
44
  </Banner>
42
45
 
43
46
  ##### Authenticating via API Key
@@ -45,8 +48,9 @@ To enable API keys on a collection, set the `useAPIKey` auth option to `true`. F
45
48
  To utilize your API key while interacting with the REST or GraphQL API, add the `Authorization` header.
46
49
 
47
50
  **For example, using Fetch:**
51
+
48
52
  ```js
49
- const response = await fetch('http://localhost:3000/api/pages', {
53
+ const response = await fetch("http://localhost:3000/api/pages", {
50
54
  headers: {
51
55
  Authorization: `${collection.labels.singular} API-Key ${YOUR_API_KEY}`,
52
56
  },
@@ -62,8 +66,13 @@ You can customize how the Forgot Password workflow operates with the following o
62
66
  Function that accepts one argument, containing `{ req, token, user }`, that allows for overriding the HTML within emails that are sent to users attempting to reset their password. The function should return a string that supports HTML, which can be a full HTML email.
63
67
 
64
68
  <Banner type="success">
65
- <strong>Tip:</strong><br />
66
- HTML templating can be used to create custom email templates, inline CSS automatically, and more. You can make a reusable function that standardizes all email sent from Payload, which makes sending custom emails more DRY. Payload doesn't ship with an HTML templating engine, so you are free to choose your own.
69
+ <strong>Tip:</strong>
70
+ <br />
71
+ HTML templating can be used to create custom email templates, inline CSS
72
+ automatically, and more. You can make a reusable function that standardizes
73
+ all email sent from Payload, which makes sending custom emails more DRY.
74
+ Payload doesn't ship with an HTML templating engine, so you are free to choose
75
+ your own.
67
76
  </Banner>
68
77
 
69
78
  Example:
@@ -99,8 +108,13 @@ Example:
99
108
  ```
100
109
 
101
110
  <Banner type="warning">
102
- <strong>Important:</strong><br />
103
- If you specify a different URL to send your users to for resetting their password, such as a page on the frontend of your app or similar, you need to handle making the call to the Payload REST or GraphQL reset-password operation yourself on your frontend, using the token that was provided for you. Above, it was passed via query parameter.
111
+ <strong>Important:</strong>
112
+ <br />
113
+ If you specify a different URL to send your users to for resetting their
114
+ password, such as a page on the frontend of your app or similar, you need to
115
+ handle making the call to the Payload REST or GraphQL reset-password operation
116
+ yourself on your frontend, using the token that was provided for you. Above,
117
+ it was passed via query parameter.
104
118
  </Banner>
105
119
 
106
120
  **`generateEmailSubject`**
@@ -153,8 +167,13 @@ Example:
153
167
  ```
154
168
 
155
169
  <Banner type="warning">
156
- <strong>Important:</strong><br />
157
- If you specify a different URL to send your users to for email verification, such as a page on the frontend of your app or similar, you need to handle making the call to the Payload REST or GraphQL verification operation yourself on your frontend, using the token that was provided for you. Above, it was passed via query parameter.
170
+ <strong>Important:</strong>
171
+ <br />
172
+ If you specify a different URL to send your users to for email verification,
173
+ such as a page on the frontend of your app or similar, you need to handle
174
+ making the call to the Payload REST or GraphQL verification operation yourself
175
+ on your frontend, using the token that was provided for you. Above, it was
176
+ passed via query parameter.
158
177
  </Banner>
159
178
 
160
179
  **`generateEmailSubject`**
@@ -177,3 +196,15 @@ Example:
177
196
  }
178
197
  }
179
198
  ```
199
+
200
+ ### Strategies
201
+
202
+ As of Payload `1.0.0`, you can add additional authentication strategies to Payload easily by passing them to your collection's `auth.strategies` array.
203
+
204
+ Behind the scenes, Payload uses PassportJS to power its local authentication strategy, so most strategies listed on the PassportJS website will work seamlessly. Combined with adding custom components to the admin panel's `Login` view, you can create advanced authentication strategies directly within Payload.
205
+
206
+ <Banner type="warning">
207
+ This is an advanced feature, so only attempt this if you are an experienced
208
+ developer. Otherwise, just let Payload's built-in authentication handle user
209
+ auth for you.
210
+ </Banner>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "0.20.10-beta.0",
3
+ "version": "1.0.6",
4
4
  "description": "Node, React and MongoDB Headless CMS and Application Framework",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -32,20 +32,15 @@
32
32
  "build:components": "webpack --config dist/webpack/components.config.js",
33
33
  "build": "yarn copyfiles && yarn build:tsc && yarn build:components",
34
34
  "build:watch": "nodemon --watch 'src/**' --ext 'ts,tsx' --exec 'yarn build:tsc'",
35
- "demo:build:analyze": "cross-env PAYLOAD_CONFIG_PATH=demo/payload.config.ts PAYLOAD_ANALYZE_BUNDLE=true node dist/bin/build",
36
- "demo:build": "cross-env PAYLOAD_CONFIG_PATH=demo/payload.config.ts node dist/bin/build",
37
- "demo:generate:types": "cross-env PAYLOAD_CONFIG_PATH=demo/payload.config.ts node dist/bin/generateTypes",
38
- "demo:generate:graphqlschema": "cross-env PAYLOAD_CONFIG_PATH=demo/payload.config.ts node dist/bin/generateGraphQLSchema",
39
- "demo:serve": "cross-env PAYLOAD_CONFIG_PATH=demo/payload.config.ts NODE_ENV=production nodemon",
40
35
  "dev": "nodemon",
41
- "dev:generatetypes": "node ./test/generateTypes.js",
36
+ "dev:generate-types": "node ./test/generateTypes.js",
42
37
  "pretest": "yarn build",
43
38
  "test": "yarn test:int && yarn test:components",
44
- "test:int": "cross-env NODE_ENV=test DISABLE_LOGGING=true jest --forceExit --detectOpenHandles",
45
- "test:e2e": "cross-env NODE_ENV=test DISABLE_LOGGING=true playwright test",
46
- "test:e2e:headed": "cross-env NODE_ENV=test DISABLE_LOGGING=true playwright test --headed",
47
- "test:e2e:debug": "cross-env PWDEBUG=1 NODE_ENV=test DISABLE_LOGGING=true playwright test",
48
- "test:components": "cross-env PAYLOAD_CONFIG_PATH=demo/payload.config.ts NODE_ENV=test jest --config=jest.components.config.js",
39
+ "test:int": "cross-env DISABLE_LOGGING=true jest --forceExit --detectOpenHandles",
40
+ "test:e2e": "cross-env DISABLE_LOGGING=true playwright test",
41
+ "test:e2e:headed": "cross-env DISABLE_LOGGING=true playwright test --headed",
42
+ "test:e2e:debug": "cross-env PWDEBUG=1 DISABLE_LOGGING=true playwright test",
43
+ "test:components": "cross-env jest --config=jest.components.config.js",
49
44
  "clean": "rimraf dist",
50
45
  "release": "release-it",
51
46
  "release:patch": "release-it patch",