mirror of
https://github.com/strapi/strapi.git
synced 2025-06-27 00:41:25 +00:00
chore: pretty codebase (#18835)
This commit is contained in:
parent
daaec91b04
commit
a549feb253
16
.github/workflows/tests.yml
vendored
16
.github/workflows/tests.yml
vendored
@ -34,6 +34,22 @@ jobs:
|
||||
with:
|
||||
filters: .github/filters.yaml
|
||||
|
||||
pretty:
|
||||
name: 'pretty (node: 20)'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
- uses: nrwl/nx-set-shas@v3
|
||||
- name: Monorepo install
|
||||
uses: ./.github/actions/yarn-nm-install
|
||||
- name: Run lint
|
||||
run: yarn prettier:check
|
||||
|
||||
lint:
|
||||
name: 'lint (node: 20)'
|
||||
needs: [build]
|
||||
|
@ -2,4 +2,4 @@ coverage
|
||||
test-apps
|
||||
dist
|
||||
build
|
||||
.cache
|
||||
.strapi
|
@ -9,6 +9,7 @@ tags:
|
||||
toc_min_heading_level: 2
|
||||
toc_max_heading_level: 3
|
||||
---
|
||||
|
||||
import Type from '@site/docs/api/components/type';
|
||||
|
||||
# Strapi
|
||||
@ -46,6 +47,7 @@ const strapiInstance = new Strapi();
|
||||
```
|
||||
|
||||
### `strapi.container`
|
||||
|
||||
- [<Type>Container</Type>](./container)
|
||||
|
||||
The container provides a simple and efficient way to register and manage resources, making it easy to access and use them throughout the application.
|
||||
@ -54,6 +56,7 @@ By registering a registry with the container, it can be easily retrieved by othe
|
||||
See [Container](./container).
|
||||
|
||||
### `strapi.dirs`
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
Stored paths of file system.
|
||||
@ -66,6 +69,7 @@ Stored paths of file system.
|
||||
- `public`: <Type>String</Type> Path to the folder to serve publicly (like files, images, etc..)
|
||||
|
||||
#### StrapiPathObject
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
A set of paths to specific Strapi project parts.
|
||||
@ -81,6 +85,7 @@ A set of paths to specific Strapi project parts.
|
||||
- `config`: <Type>String</Type> Path to the folder containing project developers' config files
|
||||
|
||||
### `strapi.isLoaded`
|
||||
|
||||
- <Type>Boolean</Type>
|
||||
|
||||
- `true`: Everything (all `register` and `bootstrap` functions available in your strapi project) has been loaded
|
||||
@ -95,23 +100,25 @@ Reload the app.
|
||||
This function defines itself at the construction of the Strapi class.
|
||||
|
||||
### `strapi.server`
|
||||
|
||||
- [<Type>StrapiServer</Type>](./strapi-server)
|
||||
|
||||
Strapi server object.
|
||||
|
||||
### `strapi.fs`
|
||||
|
||||
- [<Type>StrapiFS</Type>](StrapiFS)
|
||||
|
||||
Wrapper around [FS NodeJS module](https://nodejs.org/docs/latest-v18.x/api/fs.html).
|
||||
|
||||
### `strapi.eventHub`
|
||||
|
||||
- [<Type>EventHub</Type>](EventHub)
|
||||
|
||||
The `strapi.eventHub` object is used to manipulate events within a Strapi project. It is an instance of the built-in EventEmitter class from Node.js, which provides a simple way to emit and listen for events.
|
||||
|
||||
The `strapi.eventHub` object is created using the `createEventHub()` function in the [EventHub](EventHub) module of the Strapi core. This function returns a new instance of the EventHub class, which extends the EventEmitter class and adds some additional functionality specific to Strapi.
|
||||
|
||||
|
||||
#### Examples:
|
||||
|
||||
```javascript
|
||||
@ -123,16 +130,19 @@ console.log(`User ${data.id} has been updated`);
|
||||
// Emit a 'user.created' event with some data
|
||||
strapi.eventHub.emit('user.created', { username: 'johndoe', email: 'johndoe@example.com' });
|
||||
```
|
||||
|
||||
In this example, we are emitting a `user.created` event with some data attached to it, and then listening for a user.updated event and logging the data. These events can be used to trigger actions within the Strapi application or to communicate with external systems.
|
||||
|
||||
For more information on how to use the EventEmitter class and its methods, see the [Node.js documentation](ttps://nodejs.org/docs/latest-v18.x/api/events.html#class-eventemitter).
|
||||
|
||||
### `strapi.startupLogger`
|
||||
|
||||
- [<Type>StartupLogger</Type>](StartupLogger)
|
||||
|
||||
Object containing predefined logger functions. Used for Strapi startup. (do not use as a logger elsewhere)
|
||||
|
||||
### `strapi.log`
|
||||
|
||||
- [<Type>Winston</Type>](https://github.com/winstonjs/winston#creating-your-own-logger)
|
||||
|
||||
A logger provided by Strapi that uses the Winston logging library. It is the result of calling the `winston.createLogger()` function with the configuration defined by the user of the Strapi application.
|
||||
@ -140,6 +150,7 @@ A logger provided by Strapi that uses the Winston logging library. It is the res
|
||||
The logger provides various methods for logging messages at different levels of severity, including error, warn, info, verbose, debug, and silly. The logging level can be set via the configuration to control which messages are logged.
|
||||
|
||||
#### Examples
|
||||
|
||||
```javascript
|
||||
// Log an error message
|
||||
strapi.log.error('Failed to start server', { error: err });
|
||||
@ -159,16 +170,19 @@ strapi.log.debug('API request received', { method: req.method, path: req.path })
|
||||
// Log a silly message
|
||||
strapi.log.silly('Entered loop', { count: i });
|
||||
```
|
||||
|
||||
In these examples, we are logging messages at different levels of severity, including error, warn, info, verbose, debug, and silly. We are also passing in metadata as an object in the second parameter of each logging method.
|
||||
|
||||
The messages logged by strapi.log will be output according to the logging configuration set by the user of the Strapi application. This configuration determines which messages are logged and where they are logged (e.g. console, file, etc.).
|
||||
|
||||
### `strapi.cron`
|
||||
|
||||
- [<Type>CronService</Type>](Cron)
|
||||
|
||||
Module to schedule cron jobs for Strapi project. It is an instance of a custom Cron object.
|
||||
|
||||
### `strapi.telemetry`
|
||||
|
||||
- [<Type>TelemetryService</Type>](Telemetry)
|
||||
|
||||
The `strapi.telemetry` property provides access to the telemetry service instance. This service collects anonymous usage data about your Strapi application to help the Strapi team improve the product.
|
||||
@ -176,6 +190,7 @@ The `strapi.telemetry` property provides access to the telemetry service instanc
|
||||
By default, the telemetry service is enabled, but you can disable it by setting the telemetryDisabled property to true in your application's package.json file, or by setting the `STRAPI_TELEMETRY_DISABLED` environment variable to true. You can also disable telemetry programmatically by setting the isDisabled property of the `strapi.telemetry` instance to true.
|
||||
|
||||
### `strapi.requestContext`
|
||||
|
||||
- <Type>Object</Type> Context Storage
|
||||
|
||||
- `run(store, cb)`: <Type>Function</Type>
|
||||
@ -186,6 +201,7 @@ By default, the telemetry service is enabled, but you can disable it by setting
|
||||
The request context stores the ctx object from KoaJS on each request. This allows users to have access to the context from anywhere through the Strapi instance.
|
||||
|
||||
### `strapi.customFields`
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
- `register(customField)`: <Type>Function</Type> Register a new custom field
|
||||
@ -193,6 +209,7 @@ The request context stores the ctx object from KoaJS on each request. This allow
|
||||
This property is a shortcut to `strapi.container.get('custom-fields').add(customField)`.
|
||||
|
||||
#### Examples
|
||||
|
||||
```javascript
|
||||
strapi.customFields.register({
|
||||
name: 'color',
|
||||
@ -202,6 +219,7 @@ This property is a shortcut to `strapi.container.get('custom-fields').add(custom
|
||||
```
|
||||
|
||||
### `strapi.config`
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('config')`.
|
||||
@ -209,6 +227,7 @@ Shortcut to `strapi.container.get('config')`.
|
||||
See the [config container](#config).
|
||||
|
||||
### `strapi.services`
|
||||
|
||||
- <Type>Object[]</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('services').getAll()`.
|
||||
@ -216,6 +235,7 @@ Shortcut to `strapi.container.get('services').getAll()`.
|
||||
See the [services' container](#services).
|
||||
|
||||
### `strapi.service(uid)`
|
||||
|
||||
- `uid`: <Type>String</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('services').get(uid)`.
|
||||
@ -223,6 +243,7 @@ Shortcut to `strapi.container.get('services').get(uid)`.
|
||||
See the [services' container](#services).
|
||||
|
||||
### `strapi.controllers`
|
||||
|
||||
- <Type>Object[]</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('controllers').getAll()`.
|
||||
@ -230,6 +251,7 @@ Shortcut to `strapi.container.get('controllers').getAll()`.
|
||||
See the [controllers' container](#controllers).
|
||||
|
||||
### `strapi.controller(uid)`
|
||||
|
||||
- `uid`: <Type>String</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('controllers').get(uid)`.
|
||||
@ -237,6 +259,7 @@ Shortcut to `strapi.container.get('controllers').get(uid)`.
|
||||
See the [controllers' container](#controllers).
|
||||
|
||||
### `strapi.contentTypes`
|
||||
|
||||
- <Type>Object[]</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('content-types').getAll()`.
|
||||
@ -244,6 +267,7 @@ Shortcut to `strapi.container.get('content-types').getAll()`.
|
||||
See the [content-types' container](#content-types).
|
||||
|
||||
### `strapi.contentType(name)`
|
||||
|
||||
- `name`: <Type>String</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('content-types').get(name)`.
|
||||
@ -251,6 +275,7 @@ Shortcut to `strapi.container.get('content-types').get(name)`.
|
||||
See the [content-types' container](#content-types).
|
||||
|
||||
### `strapi.policies`
|
||||
|
||||
- <Type>Object[]</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('policies').getAll()`.
|
||||
@ -258,6 +283,7 @@ Shortcut to `strapi.container.get('policies').getAll()`.
|
||||
See the [policies' container](#policies).
|
||||
|
||||
### `strapi.policy(name)`
|
||||
|
||||
- `name`: <Type>String</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('policies').get(name)`.
|
||||
@ -265,6 +291,7 @@ Shortcut to `strapi.container.get('policies').get(name)`.
|
||||
See the [policies' container](#policies).
|
||||
|
||||
### `strapi.middlewares`
|
||||
|
||||
- <Type>Object[]</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('middlewares').getAll()`.
|
||||
@ -272,6 +299,7 @@ Shortcut to `strapi.container.get('middlewares').getAll()`.
|
||||
See the [middlewares container](#middlewares).
|
||||
|
||||
### `strapi.middleware(name)`
|
||||
|
||||
- `name`: <Type>String</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('middlewares').get(name)`.
|
||||
@ -279,6 +307,7 @@ Shortcut to `strapi.container.get('middlewares').get(name)`.
|
||||
See the [middlewares container](#middlewares).
|
||||
|
||||
### `strapi.plugins`
|
||||
|
||||
- <Type>Object[]</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('plugins').getAll()`.
|
||||
@ -286,6 +315,7 @@ Shortcut to `strapi.container.get('plugins').getAll()`.
|
||||
See the [plugins' container](#plugins).
|
||||
|
||||
### `strapi.plugin(name)`
|
||||
|
||||
- `name`: <Type>String</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('plugins').get(name)`.
|
||||
@ -293,6 +323,7 @@ Shortcut to `strapi.container.get('plugins').get(name)`.
|
||||
See the [plugins' container](#plugins).
|
||||
|
||||
### `strapi.hooks`
|
||||
|
||||
- <Type>Object[]</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('hooks').getAll()`.
|
||||
@ -300,6 +331,7 @@ Shortcut to `strapi.container.get('hooks').getAll()`.
|
||||
See the [hooks' container](#hooks).
|
||||
|
||||
### `strapi.hook(name)`
|
||||
|
||||
- `name`: <Type>String</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('hooks').get(name)`.
|
||||
@ -307,6 +339,7 @@ Shortcut to `strapi.container.get('hooks').get(name)`.
|
||||
See the [hooks' container](#hooks).
|
||||
|
||||
### `strapi.api`
|
||||
|
||||
- <Type>Object[]</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('apis').getAll()`.
|
||||
@ -314,6 +347,7 @@ Shortcut to `strapi.container.get('apis').getAll()`.
|
||||
See the [apis container](#apis).
|
||||
|
||||
### `strapi.auth`
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('auth')`.
|
||||
@ -321,6 +355,7 @@ Shortcut to `strapi.container.get('auth')`.
|
||||
See the [auth' container](#auth).
|
||||
|
||||
### `strapi.contentAPI`
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('content-api')`.
|
||||
@ -328,6 +363,7 @@ Shortcut to `strapi.container.get('content-api')`.
|
||||
See the [content-api container](#content-api).
|
||||
|
||||
### `strapi.sanitizers`
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('sanitizers')`.
|
||||
@ -335,6 +371,7 @@ Shortcut to `strapi.container.get('sanitizers')`.
|
||||
See the [sanitizers' container](#sanitizers).
|
||||
|
||||
### `strapi.validators`
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
Shortcut to `strapi.container.get('validators')`.
|
||||
@ -342,6 +379,7 @@ Shortcut to `strapi.container.get('validators')`.
|
||||
See the [validators' container](#validators).
|
||||
|
||||
### `strapi.start()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -349,6 +387,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.destroy()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -362,6 +401,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.openAdmin({ isInitialized })`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -369,6 +409,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.postListen()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -376,6 +417,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.listen()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -395,6 +437,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.loadAdmin()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -402,6 +445,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.loadPlugins()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -409,6 +453,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.loadPolicies()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -416,6 +461,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.loadAPIs()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -423,6 +469,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.loadComponents()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -430,6 +477,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.loadMiddlewares()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -437,6 +485,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.loadApp()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -444,6 +493,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.loadSanitizers()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -457,6 +507,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.register()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -464,6 +515,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.bootstrap()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -471,6 +523,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.load()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -478,6 +531,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.startWebhooks()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -491,6 +545,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.runLifecyclesFunctions()`
|
||||
|
||||
- Returns: Promise
|
||||
|
||||
:::info
|
||||
@ -498,6 +553,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.getModel(uid)`
|
||||
|
||||
- `uid`: <Type>String</Type>
|
||||
|
||||
:::info
|
||||
@ -505,6 +561,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `strapi.query(uid)`
|
||||
|
||||
- `uid`: <Type>String</Type>
|
||||
|
||||
:::info
|
||||
@ -516,6 +573,7 @@ TODO
|
||||
The strapi containers are accessible via `strapi.container.get('name-of-the-container')`.
|
||||
|
||||
### `config`
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
- `get(path, defaultValue)`: <Type>Function</Type>
|
||||
@ -608,4 +666,3 @@ TODO
|
||||
:::info
|
||||
TODO
|
||||
:::
|
||||
|
||||
|
@ -8,6 +8,7 @@ tags:
|
||||
toc_min_heading_level: 2
|
||||
toc_max_heading_level: 3
|
||||
---
|
||||
|
||||
import Type from '@site/docs/api/components/type';
|
||||
|
||||
# API
|
||||
|
@ -8,6 +8,7 @@ tags:
|
||||
toc_min_heading_level: 2
|
||||
toc_max_heading_level: 5
|
||||
---
|
||||
|
||||
import Type from '@site/docs/api/components/type';
|
||||
|
||||
# Container
|
||||
@ -32,7 +33,7 @@ const container = createContainer(strapi);
|
||||
|
||||
container.register('config', {
|
||||
get: (configName) => {},
|
||||
set: (configName, value) => {}
|
||||
set: (configName, value) => {},
|
||||
});
|
||||
|
||||
const dbConfig = container.get('config').get('database');
|
||||
@ -95,6 +96,7 @@ container.get('boolean');
|
||||
container.get('boolean', false);
|
||||
// true
|
||||
```
|
||||
|
||||
### `container.extend()`
|
||||
|
||||
:::info
|
||||
|
@ -8,6 +8,7 @@ tags:
|
||||
toc_min_heading_level: 2
|
||||
toc_max_heading_level: 3
|
||||
---
|
||||
|
||||
import Type from '@site/docs/api/components/type';
|
||||
|
||||
# Cron
|
||||
@ -20,7 +21,6 @@ Current state: **Stable**
|
||||
|
||||
The Strapi Cron Service provides a way to add, remove, start, and stop cron jobs in a Strapi application.
|
||||
|
||||
|
||||
## Module: Cron Service
|
||||
|
||||
### createCronService()
|
||||
@ -43,6 +43,7 @@ Adds one or more cron tasks to the service.
|
||||
- If the value is an object, its `task` property is used as the task function, and its `options` property is used as the cron expression options.
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
const { createCronService } = require('packages/core/strapi/lib/services/cron.js');
|
||||
|
||||
@ -71,6 +72,7 @@ Removes a cron task from the service.
|
||||
- The `name` parameter is the name of the task to remove.
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
const { createCronService } = require('packages/core/strapi/lib/services/cron.js');
|
||||
|
||||
@ -99,6 +101,7 @@ Starts the cron service.
|
||||
- Schedules all the cron jobs.
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
const { createCronService } = require('packages/core/strapi/lib/services/cron.js');
|
||||
|
||||
@ -127,6 +130,7 @@ Stops the cron service.
|
||||
- Cancels all the scheduled jobs.
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
const { createCronService } = require('packages/core/strapi/lib/services/cron.js');
|
||||
|
||||
@ -159,6 +163,7 @@ Destroys the cron service.
|
||||
- Clears the list of cron jobs.
|
||||
|
||||
#### Example
|
||||
|
||||
```javascript
|
||||
const { createCronService } = require('packages/core/strapi/lib/services/cron.js');
|
||||
|
||||
@ -184,12 +189,13 @@ cron.destroy();
|
||||
## Properties
|
||||
|
||||
### `cron.jobs`
|
||||
|
||||
- <Type>Array</Type>
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
- `job`: [<Type>Job</Type>](https://github.com/node-schedule/node-schedule) - Job object by node-schedule
|
||||
- `options`: <Type>String</Type> - String representing the recurrence of the job ( like '*/5 * * * *' )
|
||||
- `options`: <Type>String</Type> - String representing the recurrence of the job ( like '_/5 _ \* \* \*' )
|
||||
- `name`: <Type>String</Type> - The name of the task associated to the job
|
||||
|
||||
An array of the cron jobs added to the service.
|
||||
|
@ -8,6 +8,7 @@ tags:
|
||||
toc_min_heading_level: 2
|
||||
toc_max_heading_level: 3
|
||||
---
|
||||
|
||||
import Type from '@site/docs/api/components/type';
|
||||
|
||||
# Strapi Event Hub
|
||||
|
@ -8,6 +8,7 @@ tags:
|
||||
toc_min_heading_level: 2
|
||||
toc_max_heading_level: 3
|
||||
---
|
||||
|
||||
import Type from '@site/docs/api/components/type';
|
||||
|
||||
# API
|
||||
|
@ -8,6 +8,7 @@ tags:
|
||||
toc_min_heading_level: 2
|
||||
toc_max_heading_level: 3
|
||||
---
|
||||
|
||||
import Type from '@site/docs/api/components/type';
|
||||
|
||||
# Strapi File System
|
||||
@ -25,16 +26,19 @@ The Strapi FS module is a wrapper around FS NodeJS module to manipulate local fi
|
||||
### `createStrapiFs(strapi)`
|
||||
|
||||
### `strapiFs.writeAppFile(optPath, data)`
|
||||
|
||||
:::caution
|
||||
Deprecated
|
||||
:::
|
||||
|
||||
### `strapiFs.writePluginFile(plugin, optPath, data)`
|
||||
|
||||
:::caution
|
||||
Deprecated
|
||||
:::
|
||||
|
||||
### `strapiFs.removeAppFile(optPath)`
|
||||
|
||||
:::caution
|
||||
Deprecated
|
||||
:::
|
||||
|
@ -8,6 +8,7 @@ tags:
|
||||
toc_min_heading_level: 2
|
||||
toc_max_heading_level: 5
|
||||
---
|
||||
|
||||
import Type from '@site/docs/api/components/type';
|
||||
|
||||
# Strapi Server
|
||||
@ -107,6 +108,7 @@ TODO
|
||||
:::
|
||||
|
||||
### `StrapiAPIs`
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
- `content-api`: [<Type>API</Type>](API)
|
||||
|
@ -8,6 +8,7 @@ tags:
|
||||
toc_min_heading_level: 2
|
||||
toc_max_heading_level: 3
|
||||
---
|
||||
|
||||
import Type from '@site/docs/api/components/type';
|
||||
|
||||
# Telemetry
|
||||
@ -21,6 +22,7 @@ Current state: **Stable**
|
||||
The telemetry service is responsible for collecting and sending anonymous usage data to Strapi. This service is disabled by default, but can be enabled or disabled via configuration.
|
||||
|
||||
## Usage Information
|
||||
|
||||
The collected usage data is used to help Strapi improve the product by identifying areas of improvement, tracking feature adoption, and measuring performance. You can learn more about the usage data that is collected by visiting the following link:
|
||||
|
||||
https://docs.strapi.io/developer-docs/latest/getting-started/usage-information.html
|
||||
@ -74,6 +76,7 @@ telemetry.destroy();
|
||||
```
|
||||
|
||||
### `telemetry.send(event, payload)`
|
||||
|
||||
- `event`: <Type>String</Type> - The event to be sent.
|
||||
- `payload`: [<Type>TelemetryPayload</Type>](#telemetrypayload) - The payload to be sent with the event.
|
||||
- Returns: Promise
|
||||
@ -89,6 +92,7 @@ telemetry.send('event_name', { key: 'value' });
|
||||
## Types
|
||||
|
||||
### `TelemetryPayload`
|
||||
|
||||
- <Type>Object</Type>
|
||||
|
||||
- `eventProperties`: <Type>Object</Type> An object that contains additional information about the event.
|
||||
|
@ -42,7 +42,6 @@ const { getFeature } = useLicenseLimits();
|
||||
const reviewWorkflowOptions = getFeature('review-workflows');
|
||||
```
|
||||
|
||||
|
||||
## Typescript
|
||||
|
||||
```ts
|
||||
|
@ -56,7 +56,11 @@ import { Box } from '@strapi/design-system';
|
||||
import { useAdminRoles } from 'path/to/hooks';
|
||||
|
||||
const MyComponent = ({ onMoveItem }) => {
|
||||
const { users: [user], isLoading, refetch } = useAdminRoles({ id: 1 });
|
||||
const {
|
||||
users: [user],
|
||||
isLoading,
|
||||
refetch,
|
||||
} = useAdminRoles({ id: 1 });
|
||||
|
||||
return /* ... */;
|
||||
};
|
||||
|
@ -60,7 +60,11 @@ import { Box } from '@strapi/design-system';
|
||||
import { useAdminUsers } from 'path/to/hooks';
|
||||
|
||||
const MyComponent = ({ onMoveItem }) => {
|
||||
const { users: [user], isLoading, refetch } = useAdminUsers({ id: 1 });
|
||||
const {
|
||||
users: [user],
|
||||
isLoading,
|
||||
refetch,
|
||||
} = useAdminUsers({ id: 1 });
|
||||
|
||||
return /* ... */;
|
||||
};
|
||||
|
@ -34,15 +34,13 @@ const Component = () => {
|
||||
} catch (error) {
|
||||
toggleNotification({
|
||||
type: 'warning',
|
||||
message: formatAPIError(error)
|
||||
})
|
||||
}
|
||||
message: formatAPIError(error),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<button onClick={handleDeleteItem}>Delete item</button>
|
||||
)
|
||||
}
|
||||
return <button onClick={handleDeleteItem}>Delete item</button>;
|
||||
};
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
@ -3,27 +3,15 @@
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"docusaurus": "docusaurus",
|
||||
"start": "docusaurus start",
|
||||
"build": "docusaurus build",
|
||||
"swizzle": "docusaurus swizzle",
|
||||
"deploy": "docusaurus deploy",
|
||||
"clear": "docusaurus clear",
|
||||
"deploy": "docusaurus deploy",
|
||||
"docusaurus": "docusaurus",
|
||||
"serve": "docusaurus serve",
|
||||
"write-translations": "docusaurus write-translations",
|
||||
"write-heading-ids": "docusaurus write-heading-ids"
|
||||
},
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "2.2.0",
|
||||
"@docusaurus/preset-classic": "2.2.0",
|
||||
"@mdx-js/react": "^1.6.22",
|
||||
"clsx": "^1.1.1",
|
||||
"prism-react-renderer": "^1.3.3",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@docusaurus/module-type-aliases": "2.2.0"
|
||||
"start": "docusaurus start",
|
||||
"swizzle": "docusaurus swizzle",
|
||||
"write-heading-ids": "docusaurus write-heading-ids",
|
||||
"write-translations": "docusaurus write-translations"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
@ -36,5 +24,17 @@
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@docusaurus/core": "2.2.0",
|
||||
"@docusaurus/preset-classic": "2.2.0",
|
||||
"@mdx-js/react": "^1.6.22",
|
||||
"clsx": "^1.1.1",
|
||||
"prism-react-renderer": "^1.3.3",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@docusaurus/module-type-aliases": "2.2.0"
|
||||
}
|
||||
}
|
||||
|
@ -60,33 +60,19 @@
|
||||
},
|
||||
"enumeration": {
|
||||
"type": "enumeration",
|
||||
"enum": [
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E"
|
||||
]
|
||||
"enum": ["A", "B", "C", "D", "E"]
|
||||
},
|
||||
"single_media": {
|
||||
"type": "media",
|
||||
"multiple": false,
|
||||
"required": false,
|
||||
"allowedTypes": [
|
||||
"images",
|
||||
"files",
|
||||
"videos"
|
||||
]
|
||||
"allowedTypes": ["images", "files", "videos"]
|
||||
},
|
||||
"multiple_media": {
|
||||
"type": "media",
|
||||
"multiple": true,
|
||||
"required": false,
|
||||
"allowedTypes": [
|
||||
"images",
|
||||
"files",
|
||||
"videos"
|
||||
]
|
||||
"allowedTypes": ["images", "files", "videos"]
|
||||
},
|
||||
"json": {
|
||||
"type": "json"
|
||||
@ -103,10 +89,7 @@
|
||||
},
|
||||
"dynamiczone": {
|
||||
"type": "dynamiczone",
|
||||
"components": [
|
||||
"basic.simple",
|
||||
"blog.test-como"
|
||||
]
|
||||
"components": ["basic.simple", "blog.test-como"]
|
||||
},
|
||||
"one_way_tag": {
|
||||
"type": "relation",
|
||||
@ -162,10 +145,7 @@
|
||||
},
|
||||
"cats": {
|
||||
"type": "dynamiczone",
|
||||
"components": [
|
||||
"basic.relation",
|
||||
"basic.simple"
|
||||
]
|
||||
"components": ["basic.relation", "basic.simple"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,10 +47,7 @@
|
||||
}
|
||||
},
|
||||
"type": "dynamiczone",
|
||||
"components": [
|
||||
"basic.relation",
|
||||
"basic.simple"
|
||||
]
|
||||
"components": ["basic.relation", "basic.simple"]
|
||||
},
|
||||
"single_relation": {
|
||||
"type": "component",
|
||||
|
@ -36,13 +36,7 @@
|
||||
"pluginOptions": {}
|
||||
},
|
||||
"priceRange": {
|
||||
"enum": [
|
||||
"very_cheap",
|
||||
"cheap",
|
||||
"average",
|
||||
"expensive",
|
||||
"very_expensive"
|
||||
],
|
||||
"enum": ["very_cheap", "cheap", "average", "expensive", "very_expensive"],
|
||||
"type": "enumeration",
|
||||
"pluginOptions": {
|
||||
"i18n": {
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "strapi-plugin-my-plugin",
|
||||
"version": "0.0.0",
|
||||
"description": "This is the description of my plugin.",
|
||||
"private": true,
|
||||
"description": "This is the description of my plugin.",
|
||||
"strapi": {
|
||||
"name": "my-plugin",
|
||||
"description": "Description of my plugin.",
|
||||
|
@ -45,6 +45,6 @@ function getCodeCommands(files) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
'*.{js,ts}': getCodeCommands,
|
||||
'*.{md,css,scss,yaml,yml}': ['prettier --write'],
|
||||
'*.{js,ts,jsx,tsx,json}': getCodeCommands,
|
||||
'*.{md,mdx,css,scss,yaml,yml}': ['prettier --write'],
|
||||
};
|
||||
|
@ -41,8 +41,10 @@
|
||||
"lint:fix": "nx run-many --target=lint --nx-ignore-cycles -- --fix",
|
||||
"lint:other": "npm run prettier:other -- --check",
|
||||
"prepare": "husky install",
|
||||
"prettier:code": "prettier --cache --cache-strategy content \"**/*.{js,ts}\"",
|
||||
"prettier:other": "prettier --cache --cache-strategy content \"**/*.{md,css,scss,yaml,yml}\"",
|
||||
"prettier:check": "yarn prettier:code --check && yarn prettier:other --check",
|
||||
"prettier:code": "prettier --cache --cache-strategy content \"**/*.{js,ts,jsx,tsx,json}\"",
|
||||
"prettier:other": "prettier --cache --cache-strategy content \"**/*.{md,mdx,css,scss,yaml,yml}\"",
|
||||
"prettier:write": "prettier --write \"**/*.{js,ts,jsx,tsx,json,md,mdx,css,scss,yaml,yml}\"",
|
||||
"setup": "yarn && yarn clean && yarn build",
|
||||
"test:api": "node test/scripts/run-api-tests.js",
|
||||
"test:clean": "rimraf ./coverage",
|
||||
|
@ -5,6 +5,6 @@
|
||||
"compilerOptions": {
|
||||
"types": ["lodash", "jest"],
|
||||
"esModuleInterop": true,
|
||||
"allowJs": true,
|
||||
},
|
||||
"allowJs": true
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ const config: Config = defineConfig({
|
||||
import: './dist/ee/server/index.mjs',
|
||||
require: './dist/ee/server/index.js',
|
||||
runtime: 'node',
|
||||
}
|
||||
},
|
||||
],
|
||||
dist: './dist',
|
||||
/**
|
||||
|
@ -33,11 +33,11 @@
|
||||
"strapi-server.js"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "pack-up build",
|
||||
"lint": "run -T eslint .",
|
||||
"test:unit": "run -T jest",
|
||||
"test:unit:watch": "run -T jest --watch",
|
||||
"test:ts:back": "run -T tsc --noEmit -p server/tsconfig.json",
|
||||
"build": "pack-up build"
|
||||
"test:unit": "run -T jest",
|
||||
"test:unit:watch": "run -T jest --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sindresorhus/slugify": "1.1.0",
|
||||
|
@ -6,4 +6,3 @@
|
||||
"include": ["src"],
|
||||
"exclude": ["*.test.*"]
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"extends": "./tsconfig.json"
|
||||
}
|
||||
|
@ -7,4 +7,3 @@
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
"extends": "tsconfig/client.json",
|
||||
"include": ["./src", "../shared/types.ts"],
|
||||
"compilerOptions": {
|
||||
"rootDir": "../",
|
||||
"rootDir": "../"
|
||||
}
|
||||
}
|
||||
|
@ -53,9 +53,7 @@
|
||||
}
|
||||
},
|
||||
"summary": "",
|
||||
"tags": [
|
||||
"Email"
|
||||
]
|
||||
"tags": ["Email"]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -4,5 +4,5 @@
|
||||
"exclude": ["node_modules"],
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import { Meta } from '@storybook/addon-docs';
|
||||
|
||||
This util is used to format the data received by the backend so it can be used by the admin.
|
||||
It:
|
||||
|
||||
- sets the key `__temp_key__` to each component (easier for reordering repeatable components)
|
||||
- stringifies JSON fields (easier to harmonize the data format for the json editor from user input or backend data)
|
||||
|
||||
@ -19,7 +20,7 @@ import { formatContentTypeData } from '@strapi/helper-plugin';
|
||||
const Compo = ({ allLayoutData }) => {
|
||||
const allLayoutDataRef = useRef(allLayoutData);
|
||||
|
||||
const cleanReceivedData = useCallback(data => {
|
||||
const cleanReceivedData = useCallback((data) => {
|
||||
return formatContentTypeData(
|
||||
data,
|
||||
allLayoutDataRef.current.contentType,
|
||||
|
@ -39,7 +39,7 @@ const GuidedTour = ({ children }) => {
|
||||
init
|
||||
);
|
||||
|
||||
const setCurrentStep = step => {
|
||||
const setCurrentStep = (step) => {
|
||||
// currentStep format: 'contentTypeBuilder.create'
|
||||
|
||||
return dispatch({
|
||||
@ -48,7 +48,7 @@ const GuidedTour = ({ children }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const setGuidedTourVisibility = value => {
|
||||
const setGuidedTourVisibility = (value) => {
|
||||
dispatch({
|
||||
type: 'SET_GUIDED_TOUR_VISIBILITY',
|
||||
value,
|
||||
@ -63,13 +63,13 @@ const GuidedTour = ({ children }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const startSection = sectionName => {
|
||||
const startSection = (sectionName) => {
|
||||
// Add conditions for the section to start, which will allow the ModalGuidedTour to be visible
|
||||
|
||||
return setCurrentStep(`${sectionName}.${step - to - show}`);
|
||||
};
|
||||
|
||||
const setSkipped = value => {
|
||||
const setSkipped = (value) => {
|
||||
dispatch({
|
||||
type: 'SET_SKIPPED',
|
||||
value,
|
||||
|
@ -14,12 +14,18 @@ This hook is used in order to facilitate the select / partial selection of a glo
|
||||
import { useSelectionState } from '@strapi/helper-plugin';
|
||||
|
||||
const Modal = ({ onToggle, isOpen }) => {
|
||||
const [selectedAssets, { selectOne, selectAll, selectOnly, selectMultiple, deselectMultiple, setSelections }] = useSelectionState(
|
||||
const [
|
||||
selectedAssets,
|
||||
{ selectOne, selectAll, selectOnly, selectMultiple, deselectMultiple, setSelections },
|
||||
] = useSelectionState(
|
||||
['id'], // This are the comparaison attribute names
|
||||
[]
|
||||
);
|
||||
|
||||
const elements = [{ id: 1, name: 'Hello' }, { id: 2, name: 'World' }];
|
||||
const elements = [
|
||||
{ id: 1, name: 'Hello' },
|
||||
{ id: 2, name: 'World' },
|
||||
];
|
||||
|
||||
// selectOne({ id: 1 name: 'Hello' }) add the object to the selection list
|
||||
// selectOnly({ id: 1 name: 'Hello' }) add the object to the selection list and remove every others in the list
|
||||
@ -31,7 +37,7 @@ const Modal = ({ onToggle, isOpen }) => {
|
||||
return (
|
||||
<div>
|
||||
<button onClick={() => selectAll(assets)}>Select all</button>
|
||||
{elements.map(el => (
|
||||
{elements.map((el) => (
|
||||
<div key={el.id}>{el.name}</div>
|
||||
))}
|
||||
</div>
|
||||
|
@ -2,7 +2,7 @@
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"noEmit": false,
|
||||
"noEmit": false
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/**"]
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
|
@ -4,7 +4,7 @@
|
||||
"outDir": "dist",
|
||||
"noEmit": false,
|
||||
"emitDeclarationOnly": true,
|
||||
"allowJs": false,
|
||||
"allowJs": false
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/**", "dist"]
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules"]
|
||||
|
@ -14,11 +14,11 @@ into `react-select` are forwarded.
|
||||
<Canvas>
|
||||
<Story name="base">
|
||||
{() => {
|
||||
const [value, setValue] = useState({ value: 22, label: "Folder 2.2" });
|
||||
const [value, setValue] = useState({ value: 22, label: 'Folder 2.2' });
|
||||
const options = [
|
||||
{
|
||||
value: 1,
|
||||
label: 'Folder 1'
|
||||
label: 'Folder 1',
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
@ -26,7 +26,7 @@ into `react-select` are forwarded.
|
||||
children: [
|
||||
{
|
||||
value: 21,
|
||||
label: 'Folder 2.1'
|
||||
label: 'Folder 2.1',
|
||||
},
|
||||
{
|
||||
value: 22,
|
||||
@ -34,27 +34,31 @@ into `react-select` are forwarded.
|
||||
children: [
|
||||
{
|
||||
value: 221,
|
||||
label: 'Folder 2.2.1'
|
||||
label: 'Folder 2.2.1',
|
||||
},
|
||||
{
|
||||
value: 222,
|
||||
label: 'Folder 2.2.2'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
label: 'Folder 2.2.2',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: 3,
|
||||
label: 'Folder 3'
|
||||
}
|
||||
label: 'Folder 3',
|
||||
},
|
||||
];
|
||||
return (
|
||||
<>
|
||||
<SelectTree options={options} defaultValue={value} onChange={({ value, label }) => setValue({ value, label })} />
|
||||
<SelectTree
|
||||
options={options}
|
||||
defaultValue={value}
|
||||
onChange={({ value, label }) => setValue({ value, label })}
|
||||
/>
|
||||
<p>Selected Value: {value.value}</p>
|
||||
</>
|
||||
)
|
||||
);
|
||||
}}
|
||||
</Story>
|
||||
</Canvas>
|
||||
|
@ -19,18 +19,14 @@
|
||||
}
|
||||
},
|
||||
"summary": "",
|
||||
"tags": [
|
||||
"Upload - File"
|
||||
],
|
||||
"tags": ["Upload - File"],
|
||||
"requestBody": {
|
||||
"description": "Upload files",
|
||||
"required": true,
|
||||
"content": {
|
||||
"multipart/form-data": {
|
||||
"schema": {
|
||||
"required": [
|
||||
"files"
|
||||
],
|
||||
"required": ["files"],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
@ -93,9 +89,7 @@
|
||||
}
|
||||
},
|
||||
"summary": "",
|
||||
"tags": [
|
||||
"Upload - File"
|
||||
],
|
||||
"tags": ["Upload - File"],
|
||||
"requestBody": {
|
||||
"description": "Upload files",
|
||||
"required": true,
|
||||
@ -131,9 +125,7 @@
|
||||
},
|
||||
"/upload/files": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Upload - File"
|
||||
],
|
||||
"tags": ["Upload - File"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Get a list of files",
|
||||
@ -165,9 +157,7 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Upload - File"
|
||||
],
|
||||
"tags": ["Upload - File"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Get a specific file",
|
||||
@ -194,9 +184,7 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Upload - File"
|
||||
],
|
||||
"tags": ["Upload - File"],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Delete a file",
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"extends": "tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src"],
|
||||
"exclude": ["node_modules", "**/__tests__/**"]
|
||||
|
@ -60,4 +60,3 @@
|
||||
"plugin.schema.i18n.localized.label-content-type": "Activer la localisation pour ce type de contenu",
|
||||
"plugin.schema.i18n.localized.label-field": "Activer la localisation pour ce champ"
|
||||
}
|
||||
|
@ -3,4 +3,3 @@
|
||||
"plugin.description.short": "將 Strapi 錯誤事件傳送至 Sentry。",
|
||||
"plugin.name": "Sentry"
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user