@strapi/strapi 4.11.0-exp.push-transfer-push-stuck → 4.11.1-beta.0

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 (65) hide show
  1. package/lib/commands/actions/develop/action.js +5 -6
  2. package/lib/commands/actions/ts/generate-types/action.js +12 -9
  3. package/lib/commands/actions/ts/generate-types/command.js +4 -4
  4. package/lib/core/domain/content-type/index.js +1 -7
  5. package/lib/factories.d.ts +21 -0
  6. package/lib/global.d.ts +0 -44
  7. package/lib/index.d.ts +2 -1
  8. package/lib/services/entity-service/index.d.ts +1 -3
  9. package/lib/services/entity-service/index.js +60 -20
  10. package/lib/services/webhook-store.js +32 -4
  11. package/lib/types/core/attributes/base.d.ts +8 -5
  12. package/lib/types/core/attributes/biginteger.d.ts +8 -15
  13. package/lib/types/core/attributes/boolean.d.ts +7 -13
  14. package/lib/types/core/attributes/common.d.ts +46 -20
  15. package/lib/types/core/attributes/component.d.ts +24 -29
  16. package/lib/types/core/attributes/date-time.d.ts +8 -15
  17. package/lib/types/core/attributes/date.d.ts +8 -17
  18. package/lib/types/core/attributes/decimal.d.ts +8 -15
  19. package/lib/types/core/attributes/dynamic-zone.d.ts +18 -21
  20. package/lib/types/core/attributes/email.d.ts +9 -19
  21. package/lib/types/core/attributes/enumeration.d.ts +12 -22
  22. package/lib/types/core/attributes/float.d.ts +8 -17
  23. package/lib/types/core/attributes/integer.d.ts +8 -15
  24. package/lib/types/core/attributes/json.d.ts +8 -11
  25. package/lib/types/core/attributes/media.d.ts +23 -25
  26. package/lib/types/core/attributes/password.d.ts +8 -15
  27. package/lib/types/core/attributes/relation.d.ts +96 -48
  28. package/lib/types/core/attributes/richtext.d.ts +8 -15
  29. package/lib/types/core/attributes/string.d.ts +11 -21
  30. package/lib/types/core/attributes/text.d.ts +11 -21
  31. package/lib/types/core/attributes/time.d.ts +8 -17
  32. package/lib/types/core/attributes/timestamp.d.ts +8 -15
  33. package/lib/types/core/attributes/uid.d.ts +35 -39
  34. package/lib/types/core/attributes/utils.d.ts +69 -79
  35. package/lib/types/core/common/controller.d.ts +8 -0
  36. package/lib/types/core/common/index.d.ts +4 -0
  37. package/lib/types/core/common/schema.d.ts +3 -0
  38. package/lib/types/core/common/service.d.ts +3 -0
  39. package/lib/types/core/common/uid.d.ts +62 -0
  40. package/lib/types/core/index.d.ts +7 -2
  41. package/lib/types/core/namespace.d.ts +99 -0
  42. package/lib/types/core/registry.d.ts +68 -0
  43. package/lib/types/core/schemas/index.d.ts +16 -15
  44. package/lib/types/core/strapi/index.d.ts +7 -11
  45. package/lib/types/core/uid.d.ts +167 -0
  46. package/lib/types/core-api/controller.d.ts +52 -0
  47. package/lib/types/core-api/index.d.ts +3 -0
  48. package/lib/types/core-api/router.d.ts +65 -0
  49. package/lib/types/core-api/service.d.ts +48 -0
  50. package/lib/types/index.d.ts +4 -2
  51. package/lib/types/shared/index.d.ts +1 -0
  52. package/lib/types/shared/registries.d.ts +45 -0
  53. package/lib/types/utils/array.d.ts +25 -0
  54. package/lib/types/utils/expression.d.ts +68 -0
  55. package/lib/types/utils/guard.d.ts +14 -0
  56. package/lib/types/utils/index.d.ts +19 -0
  57. package/lib/types/utils/object.d.ts +29 -0
  58. package/lib/types/utils/string.d.ts +41 -0
  59. package/lib/types/utils/tuple.d.ts +13 -0
  60. package/package.json +17 -17
  61. package/lib/core/registries/services.d.ts +0 -7
  62. package/lib/core-api/controller/index.d.ts +0 -27
  63. package/lib/core-api/service/index.d.ts +0 -25
  64. package/lib/types/factories.d.ts +0 -60
  65. package/lib/types/utils.d.ts +0 -95
@@ -0,0 +1,68 @@
1
+ import type { Utils } from '@strapi/strapi';
2
+
3
+ export type True = true;
4
+ export type False = false;
5
+ export type BooleanValue = True | False;
6
+
7
+ export type Extends<TLeft, TRight> = [TLeft] extends [TRight] ? True : False;
8
+
9
+ export type Not<TExpression extends BooleanValue> = If<TExpression, False, True>;
10
+
11
+ export type If<TExpression extends BooleanValue, TOnTrue, TOnFalse = never> = [
12
+ TExpression
13
+ ] extends [True]
14
+ ? TOnTrue
15
+ : TOnFalse;
16
+
17
+ export type MatchFirst<TTests extends Test[], TDefault = never> = TTests extends [
18
+ infer THead extends Test,
19
+ ...infer TTail extends Test[]
20
+ ]
21
+ ? THead extends Test<infer TExpression, infer TValue>
22
+ ? If<
23
+ TExpression,
24
+ TValue,
25
+ If<Utils.Array.IsNotEmpty<TTail>, MatchFirst<TTail, TDefault>, TDefault>
26
+ >
27
+ : never
28
+ : never;
29
+
30
+ export type MatchAll<TTests extends Test[], TDefault = never> = TTests extends [
31
+ infer THead extends Test,
32
+ ...infer TTail extends Test[]
33
+ ]
34
+ ? THead extends Test<infer TExpression, infer TValue>
35
+ ? Utils.Guard.Never<
36
+ If<TExpression, TValue> | If<Utils.Array.IsNotEmpty<TTail>, MatchAll<TTail, TDefault>>,
37
+ TDefault
38
+ >
39
+ : never
40
+ : never;
41
+
42
+ export type Test<TExpression extends BooleanValue = BooleanValue, TValue = unknown> = [
43
+ TExpression,
44
+ TValue
45
+ ];
46
+
47
+ export type Some<TExpressions extends BooleanValue[]> = TExpressions extends [
48
+ infer THead extends BooleanValue,
49
+ ...infer TTail extends BooleanValue[]
50
+ ]
51
+ ? If<Utils.Array.IsNotEmpty<TTail>, Or<THead, Some<TTail>>, Or<THead, false>>
52
+ : never;
53
+
54
+ export type Every<TExpressions extends BooleanValue[]> = TExpressions extends [
55
+ infer THead extends BooleanValue,
56
+ ...infer TTail extends BooleanValue[]
57
+ ]
58
+ ? If<Utils.Array.IsNotEmpty<TTail>, And<THead, Every<TTail>>, And<THead, True>>
59
+ : never;
60
+
61
+ export type And<TLeft extends BooleanValue, TRight extends BooleanValue> = Extends<
62
+ Extends<TLeft, True> | Extends<TRight, True>,
63
+ True
64
+ >;
65
+
66
+ export type Or<TLeft extends BooleanValue, TRight extends BooleanValue> = Not<
67
+ Extends<Extends<TLeft, True> | Extends<TRight, True>, False>
68
+ >;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Assign a default value `TDefault` to `TValue` if `TValue` is of type `never`
3
+ *
4
+ * @example
5
+ * type X = Never<{ foo: 'bar' }, string>
6
+ * // { foo: 'bar' }
7
+ *
8
+ * type X = Never<never>
9
+ * // unknown
10
+ *
11
+ * type X = Never<never, string>
12
+ * // string
13
+ */
14
+ export type Never<TValue, TDefault = unknown> = [TValue] extends [never] ? TDefault : TValue;
@@ -0,0 +1,19 @@
1
+ export * as Array from './array';
2
+ export * as Guard from './guard';
3
+ export * as Object from './object';
4
+ export * as String from './string';
5
+ export * as Tuple from './tuple';
6
+ export * as Expression from './expression';
7
+
8
+ /**
9
+ * Get the type of a specific key `TKey` in `TValue`
10
+ *
11
+ * @example
12
+ *
13
+ * type X = Get<{ foo: 'bar', 'bar': 'foo' }, 'foo'>
14
+ * // 'bar'
15
+ *
16
+ * type X = Get<{ foo: 'bar', 'bar': 'foo' }, 'bar'>
17
+ * // 'foo'
18
+ */
19
+ export type Get<TValue, TKey extends keyof TValue> = TValue[TKey];
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Retrieve object's (`TValue`) keys if they extends the given `TTest` type.
3
+ *
4
+ * @example
5
+ * type X = KeysBy<{ foo: 'bar', bar: 'foo', foobar: 2 }, string>
6
+ * // 'foo' | 'bar'
7
+ *
8
+ * type Base = { x: 'foo' | 'bar' };
9
+ * type Obj = { foo: { x: 'foo' }, bar: { x: 'bar' }, other: { x: '42' } };
10
+ * type X = KeysBy<Obj, Base>
11
+ * // 'foo' | 'bar'
12
+ */
13
+ export type KeysBy<TValue, TTest> = {
14
+ [key in keyof TValue]: TValue[key] extends TTest ? key : never;
15
+ }[keyof TValue];
16
+
17
+ /**
18
+ * Retrieve object's (`TValue`) properties if their value extends the given `TTest` type.
19
+ *
20
+ * @example
21
+ * type X = KeysBy<{ foo: 'bar', bar: 'foo', foobar: 2 }, string>
22
+ * // { foo: 'bar', bar: 'foo' }
23
+ *
24
+ * type Base = { x: 'foo' | 'bar' };
25
+ * type Obj = { foo: { x: 'foo' }, bar: { x: 'bar' }, other: { x: '42' } };
26
+ * type X = KeysBy<Obj, Base>
27
+ * // { foo: { x: 'foo' }, bar: { x: 'bar' } }
28
+ */
29
+ export type PickBy<TValue, TTest> = Pick<TValue, KeysBy<TValue, TTest>>;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Alias for any literal type (useful for template string parameters)
3
+ */
4
+ export type Literal = string | number | bigint | boolean;
5
+
6
+ /**
7
+ * Used to check if a string includes a given literal
8
+ */
9
+ export type Includes<T extends Literal> = `${string}${T}${string}`;
10
+
11
+ /**
12
+ * Used to make sure the given string is not empty
13
+ */
14
+ export type NonEmpty<T extends string> = T extends '' ? never : T;
15
+
16
+ /**
17
+ * Split the given string into a tuple using the given `TSeparator` literal
18
+ */
19
+ export type Split<
20
+ TValue extends string,
21
+ TSeparator extends Literal
22
+ > = TValue extends `${infer TLeft}${TSeparator}${infer TRight}`
23
+ ? [TLeft, ...Split<TRight, TSeparator>]
24
+ : TValue extends ''
25
+ ? []
26
+ : [TValue];
27
+
28
+ /**
29
+ * Add a literal suffix (`TSuffix`) at the end of the given string
30
+ */
31
+ export type Suffix<TValue extends string, TSuffix extends Literal> = `${TValue}${TSuffix}`;
32
+
33
+ /**
34
+ * Add a literal prefix (`TPrefix`) at the beginning of the given string
35
+ */
36
+ export type Prefix<TValue extends string, TPrefix extends Literal> = `${TPrefix}${TValue}`;
37
+
38
+ /**
39
+ * Creates a record where every key is a string and every value is `T`
40
+ */
41
+ export type Dict<T> = Record<string, T>;
@@ -0,0 +1,13 @@
1
+ import type { Literal } from './string';
2
+
3
+ /**
4
+ * Aggregate the given tuple into a string, separated by the given `TSeparator` literal
5
+ */
6
+ export type Join<TCollection extends unknown[], TSeparator extends Literal> = TCollection extends [
7
+ infer THead extends Literal,
8
+ ...infer TTail
9
+ ]
10
+ ? TTail['length'] extends 0
11
+ ? THead
12
+ : `${THead}${TSeparator}${Join<TTail, TSeparator>}`
13
+ : never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/strapi",
3
- "version": "4.11.0-exp.push-transfer-push-stuck",
3
+ "version": "4.11.1-beta.0",
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",
@@ -81,19 +81,19 @@
81
81
  "dependencies": {
82
82
  "@koa/cors": "3.4.3",
83
83
  "@koa/router": "10.1.1",
84
- "@strapi/admin": "4.11.0-exp.push-transfer-push-stuck",
85
- "@strapi/data-transfer": "4.11.0-exp.push-transfer-push-stuck",
86
- "@strapi/database": "4.11.0-exp.push-transfer-push-stuck",
87
- "@strapi/generate-new": "4.11.0-exp.push-transfer-push-stuck",
88
- "@strapi/generators": "4.11.0-exp.push-transfer-push-stuck",
89
- "@strapi/logger": "4.11.0-exp.push-transfer-push-stuck",
90
- "@strapi/permissions": "4.11.0-exp.push-transfer-push-stuck",
91
- "@strapi/plugin-content-manager": "4.11.0-exp.push-transfer-push-stuck",
92
- "@strapi/plugin-content-type-builder": "4.11.0-exp.push-transfer-push-stuck",
93
- "@strapi/plugin-email": "4.11.0-exp.push-transfer-push-stuck",
94
- "@strapi/plugin-upload": "4.11.0-exp.push-transfer-push-stuck",
95
- "@strapi/typescript-utils": "4.11.0-exp.push-transfer-push-stuck",
96
- "@strapi/utils": "4.11.0-exp.push-transfer-push-stuck",
84
+ "@strapi/admin": "4.11.1-beta.0",
85
+ "@strapi/data-transfer": "4.11.1-beta.0",
86
+ "@strapi/database": "4.11.1-beta.0",
87
+ "@strapi/generate-new": "4.11.1-beta.0",
88
+ "@strapi/generators": "4.11.1-beta.0",
89
+ "@strapi/logger": "4.11.1-beta.0",
90
+ "@strapi/permissions": "4.11.1-beta.0",
91
+ "@strapi/plugin-content-manager": "4.11.1-beta.0",
92
+ "@strapi/plugin-content-type-builder": "4.11.1-beta.0",
93
+ "@strapi/plugin-email": "4.11.1-beta.0",
94
+ "@strapi/plugin-upload": "4.11.1-beta.0",
95
+ "@strapi/typescript-utils": "4.11.1-beta.0",
96
+ "@strapi/utils": "4.11.1-beta.0",
97
97
  "bcryptjs": "2.4.3",
98
98
  "boxen": "5.1.2",
99
99
  "chalk": "4.1.2",
@@ -131,16 +131,16 @@
131
131
  "package-json": "7.0.0",
132
132
  "qs": "6.11.1",
133
133
  "resolve-cwd": "3.0.0",
134
- "semver": "7.3.8",
134
+ "semver": "7.5.1",
135
135
  "statuses": "2.0.1"
136
136
  },
137
137
  "devDependencies": {
138
138
  "supertest": "6.3.3",
139
- "typescript": "5.0.4"
139
+ "typescript": "5.1.3"
140
140
  },
141
141
  "engines": {
142
142
  "node": ">=14.19.1 <=18.x.x",
143
143
  "npm": ">=6.0.0"
144
144
  },
145
- "gitHead": "90032a791f5413b9f139ea01687eda04c057eacd"
145
+ "gitHead": "30e56b8376b9cb52c39ecd1c3b7d8706688a1685"
146
146
  }
@@ -1,7 +0,0 @@
1
- import { Strapi } from '../../';
2
-
3
- export type Service = {
4
- [key: string]: (...args: any) => any;
5
- };
6
-
7
- export type ServiceFactory = ({ strapi: Strapi }) => Service;
@@ -1,27 +0,0 @@
1
- import { Context, Next } from 'koa';
2
-
3
- type ControllerResponse<T = unknown> = T | Promise<T> | undefined;
4
-
5
- interface Controller {
6
- transformResponse(data: object, meta: object): object;
7
- sanitizeOutput(data: object, ctx: Context): Promise<object>;
8
- sanitizeInput(data: object, ctx: Context): Promise<object>;
9
- }
10
-
11
- export interface SingleTypeController extends Controller {
12
- find?(ctx: Context, next: Next): ControllerResponse;
13
- update?(ctx: Context, next: Next): ControllerResponse;
14
- delete?(ctx: Context, next: Next): ControllerResponse;
15
- }
16
-
17
- export interface CollectionTypeController extends Controller {
18
- find?(ctx: Context, next: Next): ControllerResponse;
19
- findOne?(ctx: Context, next: Next): ControllerResponse;
20
- create?(ctx: Context, next: Next): ControllerResponse;
21
- update?(ctx: Context, next: Next): ControllerResponse;
22
- delete?(ctx: Context, next: Next): ControllerResponse;
23
- }
24
-
25
- export type GenericController = Partial<Controller> & {
26
- [method: string | number | symbol]: (ctx: Context) => unknown;
27
- };
@@ -1,25 +0,0 @@
1
- type Entity = object;
2
-
3
- interface BaseService {
4
- getFetchParams?(params: object): object;
5
- }
6
-
7
- export interface SingleTypeService extends BaseService {
8
- find?(params: object): Promise<Entity> | Entity;
9
- createOrUpdate?(params: object): Promise<Entity> | Entity;
10
- delete?(params: object): Promise<Entity> | Entity;
11
- }
12
-
13
- export interface CollectionTypeService extends BaseService {
14
- find?(params: object): Promise<Entity[]> | Entity;
15
- findOne?(entityId: string, params: object): Promise<Entity> | Entity;
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;
19
- }
20
-
21
- export type Service = SingleTypeService | CollectionTypeService;
22
-
23
- export type GenericService = Partial<Service> & {
24
- [method: string | number | symbol]: (...args: any) => any;
25
- };
@@ -1,60 +0,0 @@
1
- import { Service, GenericService } from '../core-api/service';
2
- import { Controller, GenericController } from '../core-api/controller';
3
- import { Middleware } from '../middlewares';
4
- import { Policy } from '../core/registries/policies';
5
- import { Strapi } from './core/strapi';
6
-
7
- type ControllerConfig<T extends Controller = Controller> = T;
8
-
9
- type ServiceConfig = Service;
10
-
11
- type HandlerConfig = {
12
- auth?: false | { scope: string[] };
13
- policies?: Array<string | Policy | { name: string; config: object }>;
14
- middlewares?: Array<string | Middleware | { name: string; config: object }>;
15
- };
16
-
17
- type SingleTypeRouterConfig = {
18
- find?: HandlerConfig;
19
- update?: HandlerConfig;
20
- delete?: HandlerConfig;
21
- };
22
-
23
- type CollectionTypeRouterConfig = {
24
- find?: HandlerConfig;
25
- findOne?: HandlerConfig;
26
- create?: HandlerConfig;
27
- update?: HandlerConfig;
28
- delete?: HandlerConfig;
29
- };
30
-
31
- type RouterConfig = {
32
- prefix?: string;
33
- only?: string[];
34
- except?: string[];
35
- config: SingleTypeRouterConfig | CollectionTypeRouterConfig;
36
- };
37
-
38
- interface Route {
39
- method: string;
40
- path: string;
41
- }
42
- interface Router {
43
- prefix: string;
44
- routes: Route[];
45
- }
46
-
47
- type ControllerCallback<T extends GenericController = GenericController> = (params: {
48
- strapi: Strapi;
49
- }) => T;
50
- type ServiceCallback<T extends GenericService = GenericService> = (params: { strapi: Strapi }) => T;
51
-
52
- export function createCoreRouter(uid: string, cfg?: RouterConfig = {}): () => Router;
53
- export function createCoreController<T extends GenericController = GenericController>(
54
- uid: string,
55
- cfg?: ControllerCallback<T> | T = {}
56
- ): () => T & Controller;
57
- export function createCoreService<T extends GenericService = GenericService>(
58
- uid: string,
59
- cfg?: ServiceCallback<T> | T = {}
60
- ): () => T;
@@ -1,95 +0,0 @@
1
- /**
2
- *
3
- * Common utilities used across Strapi typings
4
- *
5
- * */
6
-
7
- /**
8
- *
9
- * Extract the array values into an union type
10
- *
11
- **/
12
- export type GetArrayValues<T extends Array<unknown>> = T extends Array<infer U> ? U : never;
13
-
14
- /**
15
- * Creates a record where every key is a string and every value is `T`
16
- */
17
- export type StringRecord<T> = Record<string, T>;
18
-
19
- /**
20
- * Retrieve object's (`T`) keys if they extends the given `U` type.
21
- *
22
- * @example
23
- * type X = KeysBy<{ foo: 'bar', bar: 'foo', foobar: 2 }, string>
24
- * // 'foo' | 'bar'
25
- *
26
- * type Base = { x: 'foo' | 'bar' };
27
- * type Obj = { foo: { x: 'foo' }, bar: { x: 'bar' }, other: { x: '42' } };
28
- * type X = KeysBy<Obj, Base>
29
- * // 'foo' | 'bar'
30
- */
31
- export type KeysBy<T, U> = {
32
- [key in keyof T]: T[key] extends U ? key : never;
33
- }[keyof T];
34
-
35
- /**
36
- * Retrieve object's (`T`) properties if their value extends the given `U` type.
37
- *
38
- * @example
39
- * type X = KeysBy<{ foo: 'bar', bar: 'foo', foobar: 2 }, string>
40
- * // { foo: 'bar', bar: 'foo' }
41
- *
42
- * type Base = { x: 'foo' | 'bar' };
43
- * type Obj = { foo: { x: 'foo' }, bar: { x: 'bar' }, other: { x: '42' } };
44
- * type X = KeysBy<Obj, Base>
45
- * // { foo: { x: 'foo' }, bar: { x: 'bar' } }
46
- */
47
- export type PickBy<T, U> = Pick<T, KeysBy<T, U>>;
48
-
49
- /**
50
- * Assign a default value `U` to `T` if `T` is of type `never`
51
- *
52
- * @example
53
- * type X = NeverGuard<{ foo: 'bar' }, string>
54
- * // { foo: 'bar' }
55
- *
56
- * type X = NeverGuard<never>
57
- * // unknown
58
- *
59
- * type X = NeverGuard<never, string>
60
- * // string
61
- */
62
- export type NeverGuard<T, U = unknown> = [T] extends [never] ? U : T;
63
-
64
- /**
65
- * Dynamic type based on the keys of `Strapi.Schemas`.
66
- * It represents all the registered schemas' UID as a union type.
67
- *
68
- * @example
69
- *
70
- * declare global {
71
- * namespace Strapi {
72
- * interface Schemas {
73
- * 'api::foo.foo': CollectionTypeSchema;
74
- * 'api::bar.bar': ComponentSchema;
75
- * }
76
- * }
77
- * }
78
- *
79
- * type X = SchemaUID;
80
- * // 'api::foo.foo' | 'api::bar.bar'
81
- */
82
- export type SchemaUID = keyof Strapi.Schemas;
83
-
84
- /**
85
- * Get the type of a specific key `U` in `T`
86
- *
87
- * @example
88
- *
89
- * type X = Get<{ foo: 'bar', 'bar': 'foo' }, 'foo'>
90
- * // 'bar'
91
- *
92
- * type X = Get<{ foo: 'bar', 'bar': 'foo' }, 'bar'>
93
- * // 'foo'
94
- */
95
- export type Get<T, U extends keyof T> = T[U];