@strapi/strapi 4.11.0 → 4.11.1-beta.1

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 (61) 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/factories.d.ts +21 -0
  5. package/lib/global.d.ts +0 -44
  6. package/lib/index.d.ts +2 -1
  7. package/lib/types/core/attributes/base.d.ts +8 -5
  8. package/lib/types/core/attributes/biginteger.d.ts +8 -15
  9. package/lib/types/core/attributes/boolean.d.ts +7 -13
  10. package/lib/types/core/attributes/common.d.ts +46 -20
  11. package/lib/types/core/attributes/component.d.ts +24 -29
  12. package/lib/types/core/attributes/date-time.d.ts +8 -15
  13. package/lib/types/core/attributes/date.d.ts +8 -17
  14. package/lib/types/core/attributes/decimal.d.ts +8 -15
  15. package/lib/types/core/attributes/dynamic-zone.d.ts +18 -21
  16. package/lib/types/core/attributes/email.d.ts +9 -19
  17. package/lib/types/core/attributes/enumeration.d.ts +12 -22
  18. package/lib/types/core/attributes/float.d.ts +8 -17
  19. package/lib/types/core/attributes/integer.d.ts +8 -15
  20. package/lib/types/core/attributes/json.d.ts +8 -11
  21. package/lib/types/core/attributes/media.d.ts +23 -25
  22. package/lib/types/core/attributes/password.d.ts +8 -15
  23. package/lib/types/core/attributes/relation.d.ts +96 -48
  24. package/lib/types/core/attributes/richtext.d.ts +8 -15
  25. package/lib/types/core/attributes/string.d.ts +11 -21
  26. package/lib/types/core/attributes/text.d.ts +11 -21
  27. package/lib/types/core/attributes/time.d.ts +8 -17
  28. package/lib/types/core/attributes/timestamp.d.ts +8 -15
  29. package/lib/types/core/attributes/uid.d.ts +35 -39
  30. package/lib/types/core/attributes/utils.d.ts +69 -79
  31. package/lib/types/core/common/controller.d.ts +8 -0
  32. package/lib/types/core/common/index.d.ts +4 -0
  33. package/lib/types/core/common/schema.d.ts +3 -0
  34. package/lib/types/core/common/service.d.ts +3 -0
  35. package/lib/types/core/common/uid.d.ts +62 -0
  36. package/lib/types/core/index.d.ts +7 -2
  37. package/lib/types/core/namespace.d.ts +99 -0
  38. package/lib/types/core/registry.d.ts +68 -0
  39. package/lib/types/core/schemas/index.d.ts +16 -15
  40. package/lib/types/core/strapi/index.d.ts +6 -10
  41. package/lib/types/core/uid.d.ts +167 -0
  42. package/lib/types/core-api/controller.d.ts +52 -0
  43. package/lib/types/core-api/index.d.ts +3 -0
  44. package/lib/types/core-api/router.d.ts +65 -0
  45. package/lib/types/core-api/service.d.ts +50 -0
  46. package/lib/types/index.d.ts +4 -2
  47. package/lib/types/shared/index.d.ts +1 -0
  48. package/lib/types/shared/registries.d.ts +45 -0
  49. package/lib/types/utils/array.d.ts +25 -0
  50. package/lib/types/utils/expression.d.ts +68 -0
  51. package/lib/types/utils/guard.d.ts +14 -0
  52. package/lib/types/utils/index.d.ts +19 -0
  53. package/lib/types/utils/object.d.ts +29 -0
  54. package/lib/types/utils/string.d.ts +41 -0
  55. package/lib/types/utils/tuple.d.ts +13 -0
  56. package/package.json +16 -16
  57. package/lib/core/registries/services.d.ts +0 -7
  58. package/lib/core-api/controller/index.d.ts +0 -27
  59. package/lib/core-api/service/index.d.ts +0 -25
  60. package/lib/types/factories.d.ts +0 -60
  61. package/lib/types/utils.d.ts +0 -95
@@ -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];