@strapi/strapi 0.0.0-e6cac9fe30 → 0.0.0-fd8e4c6bfa
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.
- package/README.md +1 -1
- package/lib/core-api/service/index.d.ts +6 -3
- package/lib/middlewares/body.js +9 -2
- package/lib/middlewares/cors.js +1 -1
- package/lib/middlewares/security.js +22 -16
- package/lib/services/entity-service/index.js +13 -1
- package/lib/types/core/strapi/index.d.ts +4 -3
- package/lib/types/factories.d.ts +3 -3
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<img src="https://img.shields.io/npm/v/@strapi/strapi/latest.svg" alt="NPM Version" />
|
|
14
14
|
</a>
|
|
15
15
|
<a href="https://github.com/strapi/strapi/actions/workflows/tests.yml">
|
|
16
|
-
<img src="https://github.com/strapi/strapi/actions/workflows/tests.yml/badge.svg?branch=
|
|
16
|
+
<img src="https://github.com/strapi/strapi/actions/workflows/tests.yml/badge.svg?branch=main" alt="Tests" />
|
|
17
17
|
</a>
|
|
18
18
|
<a href="https://discord.strapi.io">
|
|
19
19
|
<img src="https://img.shields.io/discord/811989166782021633?label=Discord" alt="Strapi on Discord" />
|
|
@@ -12,11 +12,14 @@ export interface SingleTypeService extends BaseService {
|
|
|
12
12
|
|
|
13
13
|
export interface CollectionTypeService extends BaseService {
|
|
14
14
|
find?(params: object): Promise<Entity[]> | Entity;
|
|
15
|
-
findOne?(entityId: string,params: object): Promise<Entity> | Entity;
|
|
15
|
+
findOne?(entityId: string, params: object): Promise<Entity> | Entity;
|
|
16
16
|
create?(params: object): Promise<Entity> | Entity;
|
|
17
|
-
update?(entityId: string,params: object): Promise<Entity> | Entity;
|
|
18
|
-
delete?(entityId: string,params: object): Promise<Entity> | Entity;
|
|
17
|
+
update?(entityId: string, params: object): Promise<Entity> | Entity;
|
|
18
|
+
delete?(entityId: string, params: object): Promise<Entity> | Entity;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export type Service = SingleTypeService | CollectionTypeService;
|
|
22
22
|
|
|
23
|
+
export type GenericService = Partial<Service> & {
|
|
24
|
+
[method: string | number | symbol]: <T = any>(...args: any) => T;
|
|
25
|
+
};
|
package/lib/middlewares/body.js
CHANGED
|
@@ -23,12 +23,19 @@ function getFiles(ctx) {
|
|
|
23
23
|
/**
|
|
24
24
|
* @type {import('./').MiddlewareFactory}
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
module.exports = (config, { strapi }) => {
|
|
27
28
|
const bodyConfig = defaultsDeep(defaults, config);
|
|
28
29
|
|
|
30
|
+
let gqlEndpoint;
|
|
31
|
+
if (strapi.plugin('graphql')) {
|
|
32
|
+
const { config: gqlConfig } = strapi.plugin('graphql');
|
|
33
|
+
gqlEndpoint = gqlConfig('endpoint');
|
|
34
|
+
}
|
|
35
|
+
|
|
29
36
|
return async (ctx, next) => {
|
|
30
37
|
// TODO: find a better way later
|
|
31
|
-
if (ctx.url ===
|
|
38
|
+
if (gqlEndpoint && ctx.url === gqlEndpoint) {
|
|
32
39
|
await next();
|
|
33
40
|
} else {
|
|
34
41
|
try {
|
package/lib/middlewares/cors.js
CHANGED
|
@@ -30,22 +30,28 @@ const defaults = {
|
|
|
30
30
|
/**
|
|
31
31
|
* @type {import('./').MiddlewareFactory}
|
|
32
32
|
*/
|
|
33
|
-
module.exports = (config) => (ctx, next) => {
|
|
34
|
-
let helmetConfig = defaultsDeep(defaults, config);
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
module.exports =
|
|
35
|
+
(config, { strapi }) =>
|
|
36
|
+
(ctx, next) => {
|
|
37
|
+
let helmetConfig = defaultsDeep(defaults, config);
|
|
38
|
+
const specialPaths = ['/documentation'];
|
|
39
|
+
|
|
40
|
+
if (strapi.plugin('graphql')) {
|
|
41
|
+
const { config: gqlConfig } = strapi.plugin('graphql');
|
|
42
|
+
specialPaths.push(gqlConfig('endpoint'));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (ctx.method === 'GET' && specialPaths.some((str) => ctx.path.startsWith(str))) {
|
|
46
|
+
helmetConfig = merge(helmetConfig, {
|
|
47
|
+
contentSecurityPolicy: {
|
|
48
|
+
directives: {
|
|
49
|
+
'script-src': ["'self'", "'unsafe-inline'", 'cdn.jsdelivr.net'],
|
|
50
|
+
'img-src': ["'self'", 'data:', 'cdn.jsdelivr.net', 'strapi.io'],
|
|
51
|
+
},
|
|
45
52
|
},
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
49
55
|
|
|
50
|
-
|
|
51
|
-
};
|
|
56
|
+
return helmet(helmetConfig)(ctx, next);
|
|
57
|
+
};
|
|
@@ -228,7 +228,19 @@ const createDefaultImplementation = ({ strapi, db, eventHub, entityValidator })
|
|
|
228
228
|
// select / populate
|
|
229
229
|
const query = transformParamsToQuery(uid, wrappedParams);
|
|
230
230
|
|
|
231
|
-
|
|
231
|
+
const entitiesToDelete = await db.query(uid).findMany(query);
|
|
232
|
+
|
|
233
|
+
if (!entitiesToDelete.length) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const deletedEntities = await db.query(uid).deleteMany(query);
|
|
238
|
+
await Promise.all(entitiesToDelete.map((entity) => deleteComponents(uid, entity)));
|
|
239
|
+
|
|
240
|
+
// Trigger webhooks. One for each entity
|
|
241
|
+
await Promise.all(entitiesToDelete.map((entity) => this.emitEvent(uid, ENTRY_DELETE, entity)));
|
|
242
|
+
|
|
243
|
+
return deletedEntities;
|
|
232
244
|
},
|
|
233
245
|
|
|
234
246
|
load(uid, entity, field, params = {}) {
|
|
@@ -2,7 +2,8 @@ import type Koa from 'koa';
|
|
|
2
2
|
import { Database } from '@strapi/database';
|
|
3
3
|
|
|
4
4
|
import type { StringMap } from './utils';
|
|
5
|
-
import type { GenericController } from '
|
|
5
|
+
import type { GenericController } from '../../../core-api/controller'
|
|
6
|
+
import type { GenericService } from '../../../core-api/service'
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* The Strapi interface implemented by the main Strapi class.
|
|
@@ -33,12 +34,12 @@ export interface Strapi {
|
|
|
33
34
|
*
|
|
34
35
|
* It returns all the registered services
|
|
35
36
|
*/
|
|
36
|
-
readonly services: StringMap<
|
|
37
|
+
readonly services: StringMap<GenericService>;
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Find a service using its unique identifier
|
|
40
41
|
*/
|
|
41
|
-
service<T extends
|
|
42
|
+
service<T extends GenericService = GenericService>(uid: string): T | undefined;
|
|
42
43
|
|
|
43
44
|
/**
|
|
44
45
|
* Getter for the Strapi controllers container
|
package/lib/types/factories.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Service } from '../core-api/service';
|
|
1
|
+
import { Service,GenericService } from '../core-api/service';
|
|
2
2
|
import { Controller, GenericController } from '../core-api/controller';
|
|
3
3
|
import { Middleware } from '../middlewares';
|
|
4
4
|
import { Policy } from '../core/registries/policies';
|
|
@@ -47,14 +47,14 @@ interface Router {
|
|
|
47
47
|
type ControllerCallback<T extends GenericController = GenericController> = (params: {
|
|
48
48
|
strapi: Strapi;
|
|
49
49
|
}) => T;
|
|
50
|
-
type ServiceCallback<T extends
|
|
50
|
+
type ServiceCallback<T extends GenericService = GenericService> = (params: { strapi: Strapi }) => T;
|
|
51
51
|
|
|
52
52
|
export function createCoreRouter(uid: string, cfg?: RouterConfig = {}): () => Router;
|
|
53
53
|
export function createCoreController<T extends GenericController = GenericController>(
|
|
54
54
|
uid: string,
|
|
55
55
|
cfg?: ControllerCallback<T> | T = {}
|
|
56
56
|
): () => T & Controller;
|
|
57
|
-
export function createCoreService<T extends
|
|
57
|
+
export function createCoreService<T extends GenericService = GenericService>(
|
|
58
58
|
uid: string,
|
|
59
59
|
cfg?: ServiceCallback<T> | T = {}
|
|
60
60
|
): () => T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-fd8e4c6bfa",
|
|
4
4
|
"description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -80,17 +80,17 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@koa/cors": "3.1.0",
|
|
82
82
|
"@koa/router": "10.1.1",
|
|
83
|
-
"@strapi/admin": "0.0.0-
|
|
84
|
-
"@strapi/database": "0.0.0-
|
|
85
|
-
"@strapi/generate-new": "0.0.0-
|
|
86
|
-
"@strapi/generators": "0.0.0-
|
|
87
|
-
"@strapi/logger": "0.0.0-
|
|
88
|
-
"@strapi/plugin-content-manager": "0.0.0-
|
|
89
|
-
"@strapi/plugin-content-type-builder": "0.0.0-
|
|
90
|
-
"@strapi/plugin-email": "0.0.0-
|
|
91
|
-
"@strapi/plugin-upload": "0.0.0-
|
|
92
|
-
"@strapi/typescript-utils": "0.0.0-
|
|
93
|
-
"@strapi/utils": "0.0.0-
|
|
83
|
+
"@strapi/admin": "0.0.0-fd8e4c6bfa",
|
|
84
|
+
"@strapi/database": "0.0.0-fd8e4c6bfa",
|
|
85
|
+
"@strapi/generate-new": "0.0.0-fd8e4c6bfa",
|
|
86
|
+
"@strapi/generators": "0.0.0-fd8e4c6bfa",
|
|
87
|
+
"@strapi/logger": "0.0.0-fd8e4c6bfa",
|
|
88
|
+
"@strapi/plugin-content-manager": "0.0.0-fd8e4c6bfa",
|
|
89
|
+
"@strapi/plugin-content-type-builder": "0.0.0-fd8e4c6bfa",
|
|
90
|
+
"@strapi/plugin-email": "0.0.0-fd8e4c6bfa",
|
|
91
|
+
"@strapi/plugin-upload": "0.0.0-fd8e4c6bfa",
|
|
92
|
+
"@strapi/typescript-utils": "0.0.0-fd8e4c6bfa",
|
|
93
|
+
"@strapi/utils": "0.0.0-fd8e4c6bfa",
|
|
94
94
|
"bcryptjs": "2.4.3",
|
|
95
95
|
"boxen": "5.1.2",
|
|
96
96
|
"chalk": "4.1.2",
|
|
@@ -139,5 +139,5 @@
|
|
|
139
139
|
"node": ">=14.19.1 <=16.x.x",
|
|
140
140
|
"npm": ">=6.0.0"
|
|
141
141
|
},
|
|
142
|
-
"gitHead": "
|
|
142
|
+
"gitHead": "fd8e4c6bfa2fd687a3c62f8428e00f3b320c32c2"
|
|
143
143
|
}
|