@strapi/types 0.0.0 → 4.15.0-alpha.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 (103) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +5 -0
  3. package/dist/container.d.ts +5 -0
  4. package/dist/index.d.ts +138 -0
  5. package/dist/modules/auth.d.ts +24 -0
  6. package/dist/modules/content-api.d.ts +29 -0
  7. package/dist/modules/core-store.d.ts +27 -0
  8. package/dist/modules/cron.d.ts +26 -0
  9. package/dist/modules/custom-fields.d.ts +24 -0
  10. package/dist/modules/entity-service/index.d.ts +73 -0
  11. package/dist/modules/entity-service/params/attributes.d.ts +74 -0
  12. package/dist/modules/entity-service/params/data.d.ts +3 -0
  13. package/dist/modules/entity-service/params/fields.d.ts +58 -0
  14. package/dist/modules/entity-service/params/filters/index.d.ts +53 -0
  15. package/dist/modules/entity-service/params/filters/operators.d.ts +8 -0
  16. package/dist/modules/entity-service/params/index.d.ts +132 -0
  17. package/dist/modules/entity-service/params/pagination.d.ts +10 -0
  18. package/dist/modules/entity-service/params/populate.d.ts +68 -0
  19. package/dist/modules/entity-service/params/publication-state.d.ts +15 -0
  20. package/dist/modules/entity-service/params/search.d.ts +1 -0
  21. package/dist/modules/entity-service/params/sort.d.ts +84 -0
  22. package/dist/modules/entity-service/plugin.d.ts +7 -0
  23. package/dist/modules/entity-service/result.d.ts +88 -0
  24. package/dist/modules/entity-validator.d.ts +18 -0
  25. package/dist/modules/event-hub.d.ts +14 -0
  26. package/dist/modules/fetch.d.ts +6 -0
  27. package/dist/modules/metrics.d.ts +7 -0
  28. package/dist/modules/request-context.d.ts +5 -0
  29. package/dist/modules/sanitizers.d.ts +8 -0
  30. package/dist/modules/server.d.ts +30 -0
  31. package/dist/modules/validators.d.ts +8 -0
  32. package/dist/modules/webhook-runner.d.ts +15 -0
  33. package/dist/modules/webhook-store.d.ts +20 -0
  34. package/dist/types/core/attributes/base.d.ts +51 -0
  35. package/dist/types/core/attributes/biginteger.d.ts +4 -0
  36. package/dist/types/core/attributes/blocks.d.ts +4 -0
  37. package/dist/types/core/attributes/boolean.d.ts +6 -0
  38. package/dist/types/core/attributes/common.d.ts +58 -0
  39. package/dist/types/core/attributes/component.d.ts +10 -0
  40. package/dist/types/core/attributes/date-time.d.ts +4 -0
  41. package/dist/types/core/attributes/date.d.ts +4 -0
  42. package/dist/types/core/attributes/decimal.d.ts +4 -0
  43. package/dist/types/core/attributes/dynamic-zone.d.ts +12 -0
  44. package/dist/types/core/attributes/email.d.ts +4 -0
  45. package/dist/types/core/attributes/enumeration.d.ts +8 -0
  46. package/dist/types/core/attributes/float.d.ts +4 -0
  47. package/dist/types/core/attributes/index.d.ts +25 -0
  48. package/dist/types/core/attributes/integer.d.ts +4 -0
  49. package/dist/types/core/attributes/json.d.ts +4 -0
  50. package/dist/types/core/attributes/media.d.ts +12 -0
  51. package/dist/types/core/attributes/password.d.ts +4 -0
  52. package/dist/types/core/attributes/relation.d.ts +75 -0
  53. package/dist/types/core/attributes/richtext.d.ts +4 -0
  54. package/dist/types/core/attributes/string.d.ts +9 -0
  55. package/dist/types/core/attributes/text.d.ts +7 -0
  56. package/dist/types/core/attributes/time.d.ts +4 -0
  57. package/dist/types/core/attributes/timestamp.d.ts +4 -0
  58. package/dist/types/core/attributes/uid.d.ts +15 -0
  59. package/dist/types/core/attributes/utils.d.ts +27 -0
  60. package/dist/types/core/commands/index.d.ts +5 -0
  61. package/dist/types/core/common/api.d.ts +3 -0
  62. package/dist/types/core/common/controller.d.ts +5 -0
  63. package/dist/types/core/common/index.d.ts +18 -0
  64. package/dist/types/core/common/middleware.d.ts +7 -0
  65. package/dist/types/core/common/module.d.ts +24 -0
  66. package/dist/types/core/common/plugin.d.ts +5 -0
  67. package/dist/types/core/common/policy.d.ts +9 -0
  68. package/dist/types/core/common/router.d.ts +34 -0
  69. package/dist/types/core/common/schema.d.ts +2 -0
  70. package/dist/types/core/common/service.d.ts +3 -0
  71. package/dist/types/core/common/uid.d.ts +15 -0
  72. package/dist/types/core/index.d.ts +17 -0
  73. package/dist/types/core/namespace.d.ts +77 -0
  74. package/dist/types/core/plugins/config/index.d.ts +2 -0
  75. package/dist/types/core/plugins/config/strapi-admin/index.d.ts +5 -0
  76. package/dist/types/core/plugins/config/strapi-server/config.d.ts +4 -0
  77. package/dist/types/core/plugins/config/strapi-server/content-types.d.ts +10 -0
  78. package/dist/types/core/plugins/config/strapi-server/controllers.d.ts +7 -0
  79. package/dist/types/core/plugins/config/strapi-server/index.d.ts +20 -0
  80. package/dist/types/core/plugins/config/strapi-server/lifecycle.d.ts +7 -0
  81. package/dist/types/core/plugins/config/strapi-server/routes.d.ts +10 -0
  82. package/dist/types/core/plugins/index.d.ts +5 -0
  83. package/dist/types/core/registry.d.ts +57 -0
  84. package/dist/types/core/schemas/index.d.ts +124 -0
  85. package/dist/types/core/strapi/index.d.ts +25 -0
  86. package/dist/types/core/uid.d.ts +108 -0
  87. package/dist/types/core-api/controller.d.ts +44 -0
  88. package/dist/types/core-api/index.d.ts +3 -0
  89. package/dist/types/core-api/router.d.ts +62 -0
  90. package/dist/types/core-api/service.d.ts +64 -0
  91. package/dist/types/index.d.ts +4 -0
  92. package/dist/types/shared/index.d.ts +3 -0
  93. package/dist/types/shared/registries.d.ts +37 -0
  94. package/dist/types/utils/array.d.ts +15 -0
  95. package/dist/types/utils/expression.d.ts +42 -0
  96. package/dist/types/utils/function.d.ts +2 -0
  97. package/dist/types/utils/guard.d.ts +19 -0
  98. package/dist/types/utils/index.d.ts +25 -0
  99. package/dist/types/utils/object.d.ts +58 -0
  100. package/dist/types/utils/string.d.ts +39 -0
  101. package/dist/types/utils/tuple.d.ts +8 -0
  102. package/index.js +2 -0
  103. package/package.json +70 -5
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015-present Strapi Solutions SAS
2
+
3
+ Portions of the Strapi software are licensed as follows:
4
+
5
+ * All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE".
6
+
7
+ * All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
8
+
9
+ MIT Expat License
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # `@strapi/types`
2
+
3
+ ⚠️ This package is only intended for Strapi internal use and should not be used directly. New versions might break without any prior notice.
4
+
5
+ Any type you should be using should be imported from `@strapi/strapi` instead.
@@ -0,0 +1,5 @@
1
+ export interface Container {
2
+ register<T, U extends string>(name: U, resolver: T): Container;
3
+ get<T = any>(name: string, args?: unknown): T;
4
+ extend(): Container;
5
+ }
@@ -0,0 +1,138 @@
1
+ import type { Database } from '@strapi/database';
2
+ import type { Logger } from '@strapi/logger';
3
+ import type { Server } from './modules/server';
4
+ import type { EventHub } from './modules/event-hub';
5
+ import type { CronService } from './modules/cron';
6
+ import type { WebhookRunner } from './modules/webhook-runner';
7
+ import type { WebhookStore } from './modules/webhook-store';
8
+ import type { CoreStore } from './modules/core-store';
9
+ import type { EntityValidator } from './modules/entity-validator';
10
+ import type * as EntityService from './modules/entity-service';
11
+ import type { TelemetryService } from './modules/metrics';
12
+ import type { RequestContext } from './modules/request-context';
13
+ import type { Common, Shared, Schema, StrapiDirectories } from './types';
14
+ import type * as CustomFields from './modules/custom-fields';
15
+ import type { Fetch } from './modules/fetch';
16
+ import type { AuthenticationService } from './modules/auth';
17
+ import type { ContentApi } from './modules/content-api';
18
+ import type { SanitizersRegistry } from './modules/sanitizers';
19
+ import type { ValidatorsRegistry } from './modules/validators';
20
+ import type { Container } from './container';
21
+ export type * from './types';
22
+ export { Container, Server, EventHub, CronService, WebhookRunner, WebhookStore, CoreStore, EntityValidator, EntityService, TelemetryService, RequestContext, CustomFields, Fetch, AuthenticationService, ContentApi, SanitizersRegistry, ValidatorsRegistry, };
23
+ declare global {
24
+ var strapi: LoadedStrapi;
25
+ namespace NodeJS {
26
+ interface Global {
27
+ strapi: LoadedStrapi;
28
+ }
29
+ }
30
+ }
31
+ export interface Reloader {
32
+ isReloading: boolean;
33
+ isWatching: boolean;
34
+ (): void;
35
+ }
36
+ export interface StartupLogger {
37
+ logStats(): void;
38
+ logFirstStartupMessage(): void;
39
+ logDefaultStartupMessage(): void;
40
+ logStartupMessage({ isInitialized }: {
41
+ isInitialized: boolean;
42
+ }): void;
43
+ }
44
+ export interface StrapiFS {
45
+ writeAppFile(optPath: string | string[], data: string): Promise<void>;
46
+ writePluginFile(plugin: string, optPath: string | string[], data: string): Promise<void>;
47
+ removeAppFile(optPath: string | string[]): Promise<void>;
48
+ appendFile(optPath: string | string[], data: string): void;
49
+ }
50
+ export interface ConfigProvider {
51
+ get<T = unknown>(key: string, defaultVal?: T): T;
52
+ set(path: string, val: unknown): this;
53
+ has(path: string): boolean;
54
+ [key: string]: any;
55
+ }
56
+ export interface Strapi {
57
+ server: Server;
58
+ container: Container;
59
+ log: Logger;
60
+ fs: StrapiFS;
61
+ eventHub: EventHub;
62
+ startupLogger: StartupLogger;
63
+ cron: CronService;
64
+ webhookRunner?: WebhookRunner;
65
+ webhookStore?: WebhookStore;
66
+ store?: CoreStore;
67
+ entityValidator?: EntityValidator;
68
+ entityService?: EntityService.EntityService;
69
+ telemetry: TelemetryService;
70
+ requestContext: RequestContext;
71
+ customFields: CustomFields.CustomFields;
72
+ fetch: Fetch;
73
+ dirs: StrapiDirectories;
74
+ admin?: Common.Module;
75
+ isLoaded: boolean;
76
+ db?: Database;
77
+ app: any;
78
+ EE?: boolean;
79
+ components: Shared.Components;
80
+ reload: Reloader;
81
+ config: ConfigProvider;
82
+ services: Record<string, Common.Service>;
83
+ service(uid: Common.UID.Service): Common.Service;
84
+ controllers: Record<string, Common.Controller>;
85
+ controller(uid: Common.UID.Controller): Common.Controller;
86
+ contentTypes: Shared.ContentTypes;
87
+ contentType(name: Common.UID.ContentType): Schema.ContentType;
88
+ policies: Record<string, Common.Policy>;
89
+ policy(name: string): Common.Policy;
90
+ middlewares: Record<string, Common.MiddlewareFactory>;
91
+ middleware(name: string): Common.MiddlewareFactory;
92
+ plugins: Record<string, Common.Plugin>;
93
+ plugin(name: string): Common.Plugin;
94
+ hooks: Record<string, any>;
95
+ hook(name: string): any;
96
+ api: Record<string, Common.Module>;
97
+ auth: AuthenticationService;
98
+ contentAPI: ContentApi;
99
+ sanitizers: SanitizersRegistry;
100
+ validators: ValidatorsRegistry;
101
+ load(): Promise<Strapi & Required<Strapi>>;
102
+ start(): Promise<Strapi>;
103
+ destroy(): Promise<void>;
104
+ sendStartupTelemetry(): void;
105
+ openAdmin({ isInitialized }: {
106
+ isInitialized: boolean;
107
+ }): void;
108
+ postListen(): Promise<void>;
109
+ listen(): Promise<void>;
110
+ stopWithError(err: unknown, customMessage?: string): never;
111
+ stop(exitCode?: number): never;
112
+ loadAdmin(): Promise<void>;
113
+ loadPlugins(): Promise<void>;
114
+ loadPolicies(): Promise<void>;
115
+ loadAPIs(): Promise<void>;
116
+ loadComponents(): Promise<void>;
117
+ loadMiddlewares(): Promise<void>;
118
+ loadApp(): Promise<void>;
119
+ loadSanitizers(): Promise<void>;
120
+ loadValidators(): Promise<void>;
121
+ registerInternalHooks(): void;
122
+ register(): Promise<Strapi>;
123
+ bootstrap(): Promise<Strapi>;
124
+ startWebhooks(): Promise<void>;
125
+ runLifecyclesFunctions(lifecycleName: 'register' | 'bootstrap' | 'destroy'): Promise<void>;
126
+ getModel<TUID extends Common.UID.Schema>(uid: TUID): TUID extends Common.UID.ContentType ? Schema.ContentType : Schema.Component;
127
+ query(uid: Common.UID.Schema): ReturnType<Database['query']>;
128
+ }
129
+ export interface StrapiOptions {
130
+ appDir?: string;
131
+ distDir?: string;
132
+ autoReload?: boolean;
133
+ serveAdminPanel?: boolean;
134
+ }
135
+ export interface StrapiConstructor {
136
+ new (options?: StrapiOptions): Strapi;
137
+ }
138
+ export type LoadedStrapi = Required<Strapi>;
@@ -0,0 +1,24 @@
1
+ import type { ParameterizedContext } from 'koa';
2
+ import type { Common } from '../types';
3
+ interface AuthenticationResponse {
4
+ authenticated?: boolean;
5
+ credentials?: unknown;
6
+ ability?: unknown;
7
+ error?: Error | null;
8
+ }
9
+ interface AuthenticationInfo {
10
+ strategy: Strategy;
11
+ credentials: unknown;
12
+ ability: unknown;
13
+ }
14
+ interface Strategy {
15
+ name: string;
16
+ authenticate: (ctx: ParameterizedContext) => Promise<AuthenticationResponse>;
17
+ verify?: (auth: AuthenticationInfo, config: Common.RouteConfig['auth']) => Promise<any>;
18
+ }
19
+ export interface AuthenticationService {
20
+ register: (type: string, strategy: Strategy) => AuthenticationService;
21
+ authenticate: Common.MiddlewareHandler;
22
+ verify: (auth: AuthenticationInfo, config?: Common.RouteConfig['auth']) => Promise<any>;
23
+ }
24
+ export {};
@@ -0,0 +1,29 @@
1
+ import permissions from '@strapi/permissions';
2
+ import { providerFactory } from '@strapi/utils';
3
+ import { Common } from '../types';
4
+ export interface Condition {
5
+ name: string;
6
+ [key: string]: unknown;
7
+ }
8
+ type ConditionProvider = {
9
+ register: (condition: Condition) => Promise<void>;
10
+ } & ReturnType<typeof providerFactory>;
11
+ type ActionProvider = {
12
+ register: (action: string, payload: Record<string, unknown>) => Promise<void>;
13
+ } & ReturnType<typeof providerFactory>;
14
+ export interface PermissionUtilities {
15
+ engine: ReturnType<typeof permissions.engine.new>;
16
+ providers: {
17
+ action: ActionProvider;
18
+ condition: ConditionProvider;
19
+ };
20
+ registerActions: () => Promise<void>;
21
+ getActionsMap: () => Record<string, {
22
+ controllers: Record<string, string[]>;
23
+ }>;
24
+ }
25
+ export interface ContentApi {
26
+ permissions: PermissionUtilities;
27
+ getRoutesMap: () => Promise<Record<string, Common.Route[]>>;
28
+ }
29
+ export {};
@@ -0,0 +1,27 @@
1
+ type SetParams = {
2
+ key: string;
3
+ value: unknown;
4
+ type?: string;
5
+ environment?: string;
6
+ name?: string;
7
+ tag?: string;
8
+ };
9
+ type GetParams = {
10
+ key: string;
11
+ type?: string;
12
+ environment?: string;
13
+ name?: string;
14
+ tag?: string;
15
+ };
16
+ type Params = SetParams & GetParams;
17
+ export interface CoreStore {
18
+ (defaultParams: Partial<Params>): {
19
+ get(params: Partial<GetParams>): Promise<unknown>;
20
+ set(params: Partial<SetParams>): Promise<void>;
21
+ delete(params: Partial<GetParams>): Promise<void>;
22
+ };
23
+ get(params: GetParams): Promise<unknown>;
24
+ set(params: SetParams): Promise<void>;
25
+ delete(params: GetParams): Promise<void>;
26
+ }
27
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { Job } from 'node-schedule';
2
+ import type { Strapi } from '..';
3
+ interface JobSpec {
4
+ job: Job;
5
+ options: string | number | Date;
6
+ name: string | null;
7
+ }
8
+ type TaskFn = ({ strapi }: {
9
+ strapi: Strapi;
10
+ }, ...args: unknown[]) => Promise<unknown>;
11
+ type Task = TaskFn | {
12
+ task: TaskFn;
13
+ options: string;
14
+ };
15
+ interface Tasks {
16
+ [key: string]: Task;
17
+ }
18
+ export interface CronService {
19
+ add(tasks: Tasks): CronService;
20
+ remove(name: string): CronService;
21
+ start(): CronService;
22
+ stop(): CronService;
23
+ destroy(): CronService;
24
+ jobs: JobSpec[];
25
+ }
26
+ export {};
@@ -0,0 +1,24 @@
1
+ export interface CustomFieldServerOptions {
2
+ /**
3
+ * The name of the custom field
4
+ */
5
+ name: string;
6
+ /**
7
+ * The name of the plugin creating the custom field
8
+ */
9
+ plugin?: string;
10
+ /**
11
+ * The existing Strapi data type the custom field uses
12
+ */
13
+ type: 'biginteger' | 'boolean' | 'date' | 'datetime' | 'decimal' | 'email' | 'enumeration' | 'float' | 'integer' | 'json' | 'password' | 'richtext' | 'string' | 'text' | 'time' | 'uid';
14
+ /**
15
+ * Settings for the input size in the Admin UI
16
+ */
17
+ inputSize?: {
18
+ default: 4 | 6 | 8 | 12;
19
+ isResizable: boolean;
20
+ };
21
+ }
22
+ export interface CustomFields {
23
+ register: (customFields: CustomFieldServerOptions[] | CustomFieldServerOptions) => void;
24
+ }
@@ -0,0 +1,73 @@
1
+ import type { Attribute, Common, Utils } from '../../types';
2
+ import type { PartialEntity, Entity, Result, PaginatedResult } from './result';
3
+ import type * as Params from './params';
4
+ export type UploadFile = (uid: Common.UID.Schema, entity: Record<string, unknown>, files: Record<string, unknown>) => Promise<void>;
5
+ export * as Params from './params';
6
+ export * from './result';
7
+ export * from './plugin';
8
+ type WrapAction = Omit<keyof EntityService, 'wrapParams' | 'wrapResult' | 'emitEvent'>;
9
+ export interface EntityService {
10
+ uploadFiles: UploadFile;
11
+ wrapParams<TResult extends object = object, TContentTypeUID extends Common.UID.ContentType = Common.UID.ContentType, TParams extends object = object>(params?: TParams, options?: {
12
+ uid: TContentTypeUID;
13
+ action: WrapAction;
14
+ }): Promise<TResult> | TResult;
15
+ wrapResult<TResult = any, TContentTypeUID extends Common.UID.ContentType = Common.UID.ContentType>(result: unknown, options?: {
16
+ uid: TContentTypeUID;
17
+ action: WrapAction;
18
+ [key: string]: unknown;
19
+ }): Promise<TResult> | TResult;
20
+ emitEvent<TContentTypeUID extends Common.UID.ContentType>(uid: TContentTypeUID, event: string, entity: Entity<TContentTypeUID>): Promise<void>;
21
+ findMany<TContentTypeUID extends Common.UID.ContentType, TParams extends Params.Pick<TContentTypeUID, 'fields' | 'filters' | '_q' | 'pagination:offset' | 'sort' | 'populate' | 'publicationState' | 'plugin'>>(uid: TContentTypeUID, params?: TParams): Promise<Utils.Expression.MatchFirst<[
22
+ [
23
+ Common.UID.IsCollectionType<TContentTypeUID>,
24
+ Result<TContentTypeUID, TParams>[]
25
+ ],
26
+ [
27
+ Common.UID.IsSingleType<TContentTypeUID>,
28
+ Result<TContentTypeUID, TParams> | null
29
+ ]
30
+ ], (Result<TContentTypeUID, TParams> | null) | Result<TContentTypeUID, TParams>[]>>;
31
+ findOne<TContentTypeUID extends Common.UID.ContentType, TParams extends Params.Pick<TContentTypeUID, 'fields' | 'populate'>>(uid: TContentTypeUID, entityId: Params.Attribute.ID, params?: TParams): Promise<Result<TContentTypeUID, TParams> | null>;
32
+ delete<TContentTypeUID extends Common.UID.ContentType, TParams extends Params.Pick<TContentTypeUID, 'fields' | 'populate'>>(uid: TContentTypeUID, entityId: Params.Attribute.ID, params?: TParams): Promise<Result<TContentTypeUID, TParams> | null>;
33
+ create<TContentTypeUID extends Common.UID.ContentType, TParams extends Params.Pick<TContentTypeUID, 'data' | 'files' | 'fields' | 'populate'>>(uid: TContentTypeUID, params?: TParams): Promise<Result<TContentTypeUID, TParams>>;
34
+ update<TContentTypeUID extends Common.UID.ContentType, TParams extends Params.Pick<TContentTypeUID, 'data:partial' | 'files' | 'fields' | 'populate'>>(uid: TContentTypeUID, entityId: Params.Attribute.ID, params?: TParams): Promise<Result<TContentTypeUID, TParams> | null>;
35
+ findPage<TContentTypeUID extends Common.UID.ContentType, TParams extends Params.Pick<TContentTypeUID, 'fields' | 'populate' | 'pagination' | 'sort' | 'filters' | '_q' | 'publicationState' | 'plugin'>>(uid: TContentTypeUID, params?: TParams): Promise<PaginatedResult<TContentTypeUID, TParams>>;
36
+ clone<TContentTypeUID extends Common.UID.ContentType, TParams extends Params.Pick<TContentTypeUID, 'data' | 'files' | 'fields' | 'populate'>>(uid: TContentTypeUID, cloneId: Params.Attribute.ID, params?: TParams): Promise<Result<TContentTypeUID, TParams> | null>;
37
+ /**
38
+ * @deprecated
39
+ */
40
+ deleteMany<TContentTypeUID extends Common.UID.ContentType>(uid: TContentTypeUID, params: Params.Pick<TContentTypeUID, 'filters' | '_q'>): Promise<{
41
+ count: number;
42
+ }>;
43
+ /**
44
+ * TODO: seems the same as findMany, it's not returning count by default
45
+ * @deprecated
46
+ */
47
+ findWithRelationCounts<TContentTypeUID extends Common.UID.ContentType, TParams extends Params.Pick<TContentTypeUID, 'fields' | 'filters' | '_q' | 'pagination:offset' | 'sort' | 'populate' | 'publicationState' | 'plugin'>>(uid: TContentTypeUID, params?: TParams): Promise<Result<TContentTypeUID, TParams>[]>;
48
+ /**
49
+ * @deprecated
50
+ */
51
+ findWithRelationCountsPage<TContentTypeUID extends Common.UID.ContentType, TParams extends Params.Pick<TContentTypeUID, 'fields' | 'filters' | '_q' | 'pagination' | 'sort' | 'populate' | 'publicationState' | 'plugin'>>(uid: TContentTypeUID, params?: TParams): Promise<PaginatedResult<TContentTypeUID, TParams>>;
52
+ count<TContentTypeUID extends Common.UID.ContentType>(uid: TContentTypeUID, params?: Params.Pick<TContentTypeUID, 'filters' | '_q'>): Promise<number>;
53
+ /**
54
+ * TODO: Considering making this API public include providing a valid return type
55
+ * @internal
56
+ */
57
+ load<TContentTypeUID extends Common.UID.ContentType, TField extends Attribute.GetPopulatableKeys<TContentTypeUID>>(uid: TContentTypeUID, entity: PartialEntity<TContentTypeUID>, field: Utils.Guard.Never<TField, string>, params?: GetPopulatableFieldParams<TContentTypeUID, TField>): Promise<any>;
58
+ /**
59
+ * TODO: Considering making this API public include providing a valid return type
60
+ * @internal
61
+ */
62
+ loadPages<TContentTypeUID extends Common.UID.ContentType, TField extends Attribute.GetPopulatableKeys<TContentTypeUID>>(uid: TContentTypeUID, entity: PartialEntity<TContentTypeUID>, field: Utils.Guard.Never<TField, string>, params?: GetPopulatableFieldParams<TContentTypeUID, TField>, pagination?: Params.Pagination.Any): Promise<any>;
63
+ }
64
+ type GetPopulatableFieldParams<TContentTypeUID extends Common.UID.ContentType, TField extends Attribute.GetPopulatableKeys<TContentTypeUID>> = Utils.Expression.MatchFirst<[
65
+ [
66
+ Attribute.HasTarget<TContentTypeUID, TField>,
67
+ Params.Populate.NestedParams<Attribute.GetTarget<TContentTypeUID, TField>>
68
+ ],
69
+ [
70
+ Attribute.HasMorphTargets<TContentTypeUID, TField>,
71
+ (Params.Populate.Fragment<Attribute.GetMorphTargets<TContentTypeUID, TField>> | Params.Populate.NestedParams<Common.UID.Schema>)
72
+ ]
73
+ ], Params.Populate.Fragment<Common.UID.Schema> | Params.Populate.NestedParams<Common.UID.Schema>>;
@@ -0,0 +1,74 @@
1
+ import type { Attribute, Common, Utils } from '../../../types';
2
+ export type NonFilterableKind = Extract<Attribute.Kind, 'password' | 'dynamiczone'>;
3
+ export type FilterableKind = Exclude<Attribute.Kind, NonFilterableKind>;
4
+ export type GetNonFilterableKeys<TSchemaUID extends Common.UID.Schema> = Utils.Object.KeysBy<Attribute.GetAll<TSchemaUID>, Attribute.OfType<NonFilterableKind>, string>;
5
+ export type GetScalarKeys<TSchemaUID extends Common.UID.Schema> = Exclude<Attribute.GetKeysByType<TSchemaUID, Attribute.NonPopulatableKind>, GetNonFilterableKeys<TSchemaUID>>;
6
+ export type GetNestedKeys<TSchemaUID extends Common.UID.Schema> = Exclude<Attribute.GetKeysWithTarget<TSchemaUID>, GetNonFilterableKeys<TSchemaUID>>;
7
+ export type ID = `${number}` | number;
8
+ export type BooleanValue = boolean | 'true' | 'false' | 't' | 'f' | '1' | '0' | 1 | 0;
9
+ export type NumberValue = string | number;
10
+ export type DateValue = Attribute.DateValue | number;
11
+ export type TimeValue = Attribute.TimeValue | number;
12
+ export type DateTimeValue = Attribute.DateTimeValue | number;
13
+ export type TimeStampValue = Attribute.TimestampValue;
14
+ /**
15
+ * List of possible values for the scalar attributes
16
+ * Uses the local GetValue to benefit from the values' overrides
17
+ */
18
+ export type ScalarValues = GetValue<Attribute.BigInteger | Attribute.Boolean | Attribute.DateTime | Attribute.Date | Attribute.Decimal | Attribute.Email | Attribute.Enumeration<string[]> | Attribute.Float | Attribute.Integer | Attribute.Blocks | Attribute.JSON | Attribute.RichText | Attribute.String | Attribute.Text | Attribute.Time | Attribute.Timestamp | Attribute.UID<Common.UID.Schema>>;
19
+ /**
20
+ * Attribute.GetValues override with extended values
21
+ */
22
+ export type GetValues<TSchemaUID extends Common.UID.Schema> = {
23
+ id?: ID;
24
+ } & OmitRelationWithoutTarget<TSchemaUID, {
25
+ [TKey in Attribute.GetOptionalKeys<TSchemaUID>]?: GetValue<Attribute.Get<TSchemaUID, TKey>>;
26
+ } & {
27
+ [TKey in Attribute.GetRequiredKeys<TSchemaUID>]-?: GetValue<Attribute.Get<TSchemaUID, TKey>>;
28
+ }>;
29
+ export type OmitRelationWithoutTarget<TSchemaUID extends Common.UID.Schema, TValue> = Omit<TValue, Exclude<Attribute.GetKeysByType<TSchemaUID, 'relation'>, Attribute.GetKeysWithTarget<TSchemaUID>>>;
30
+ /**
31
+ * Attribute.GetValue override with extended values
32
+ *
33
+ * Fallback to unknown if never is found
34
+ */
35
+ export type GetValue<TAttribute extends Attribute.Attribute> = Utils.Expression.If<Utils.Expression.IsNotNever<TAttribute>, Utils.Expression.MatchFirst<[
36
+ [
37
+ Utils.Expression.Extends<TAttribute, Attribute.OfType<'relation'>>,
38
+ TAttribute extends Attribute.Relation<infer _TOrigin, infer TRelationKind, infer TTarget> ? Utils.Expression.If<Utils.Expression.IsNotNever<TTarget>, Attribute.RelationPluralityModifier<TRelationKind, ID>> : never
39
+ ],
40
+ [
41
+ Utils.Expression.Extends<TAttribute, Attribute.OfType<'dynamiczone'>>,
42
+ TAttribute extends Attribute.DynamicZone<infer TComponentsUIDs> ? Array<Utils.Array.Values<TComponentsUIDs> extends infer TComponentUID ? TComponentUID extends Common.UID.Component ? GetValues<TComponentUID> & {
43
+ __component: TComponentUID;
44
+ } : never : never> : never
45
+ ],
46
+ [
47
+ Utils.Expression.Extends<TAttribute, Attribute.OfType<'component'>>,
48
+ TAttribute extends Attribute.Component<infer TComponentUID, infer TRepeatable> ? TComponentUID extends Common.UID.Component ? GetValues<TComponentUID> extends infer TValues ? Utils.Expression.If<TRepeatable, TValues[], TValues> : never : never : never
49
+ ],
50
+ [
51
+ Utils.Expression.Extends<TAttribute, Attribute.Boolean>,
52
+ BooleanValue
53
+ ],
54
+ [
55
+ Utils.Expression.Extends<TAttribute, Attribute.Integer | Attribute.BigInteger | Attribute.Float | Attribute.Decimal>,
56
+ NumberValue
57
+ ],
58
+ [
59
+ Utils.Expression.Extends<TAttribute, Attribute.Time>,
60
+ TimeValue
61
+ ],
62
+ [
63
+ Utils.Expression.Extends<TAttribute, Attribute.Date>,
64
+ DateValue
65
+ ],
66
+ [
67
+ Utils.Expression.Extends<TAttribute, Attribute.Timestamp | Attribute.DateTime>,
68
+ DateTimeValue
69
+ ],
70
+ [
71
+ Utils.Expression.True,
72
+ Attribute.GetValue<TAttribute, unknown>
73
+ ]
74
+ ], unknown>, unknown>;
@@ -0,0 +1,3 @@
1
+ import type { Common } from '../../../types';
2
+ import type * as AttributeUtils from './attributes';
3
+ export type Input<TSchemaUID extends Common.UID.Schema> = AttributeUtils.GetValues<TSchemaUID>;
@@ -0,0 +1,58 @@
1
+ import type { Attribute, Common, Utils } from '../../../types';
2
+ /**
3
+ * Wildcard notation for the fields.
4
+ *
5
+ * When used, it represents every non-populatable field from the given schema
6
+ */
7
+ export type WildcardNotation = '*';
8
+ /**
9
+ * Single non-populatable attribute representation
10
+ *
11
+ * @example
12
+ * type A = 'title'; // ✅
13
+ * type B = 'description'; // ✅
14
+ * type C = 'populatableField'; // ❌
15
+ * type D = '<random_string>'; // ❌
16
+ */
17
+ export type SingleAttribute<TSchemaUID extends Common.UID.Schema> = 'id' | Utils.Guard.Never<Attribute.GetNonPopulatableKeys<TSchemaUID>, string>;
18
+ /**
19
+ * Union of all possible string representation for fields
20
+ *
21
+ * @example
22
+ * type A = 'title'; // ✅
23
+ * type B = 'title,description'; // ✅
24
+ * type C = 'id'; // ✅
25
+ * type D = '*'; // ✅
26
+ * type E = 'populatableField'; // ❌
27
+ * type F = '<random_string>'; // ❌
28
+ */
29
+ export type StringNotation<TSchemaUID extends Common.UID.Schema> = WildcardNotation | SingleAttribute<TSchemaUID> | `${string},${string}`;
30
+ /**
31
+ * Array notation for fields
32
+ *
33
+ * @example
34
+ * type A = ['title']; // ✅
35
+ * type B = ['title', 'description']; // ✅
36
+ * type C = ['id']; // ✅
37
+ * type E = ['*']; // ❌
38
+ * type F = ['populatableField']; // ❌
39
+ * type G = ['<random_string>']; // ❌
40
+ */
41
+ export type ArrayNotation<TSchemaUID extends Common.UID.Schema> = Exclude<StringNotation<TSchemaUID>, WildcardNotation>[];
42
+ /**
43
+ * Represents any notation for a sort (string, array, object)
44
+ *
45
+ * @example
46
+ * type A = '*'; // ✅
47
+ * type B = 'id'; // ✅
48
+ * type C = 'title'; // ✅
49
+ * type D = 'title,description'; // ✅
50
+ * type E = ['title', 'description']; // ✅
51
+ * type F = [id, 'title,description']; // ✅
52
+ * type G = ['*']; // ❌
53
+ * type H = ['populatableField']; // ❌
54
+ * type I = ['<random_string>']; // ❌
55
+ * type J = 'populatableField'; // ❌
56
+ * type K = '<random_string>'; // ❌
57
+ */
58
+ export type Any<TSchemaUID extends Common.UID.Schema> = StringNotation<TSchemaUID> | ArrayNotation<TSchemaUID>;
@@ -0,0 +1,53 @@
1
+ import type { Attribute, Common, Utils } from '../../../../types';
2
+ import type * as Operator from './operators';
3
+ import type * as AttributeUtils from '../attributes';
4
+ import type * as Params from '..';
5
+ export { Operator };
6
+ type IDKey = 'id';
7
+ /**
8
+ * Filter representation for nested attributes
9
+ */
10
+ type NestedAttributeCondition<TSchemaUID extends Common.UID.Schema, TAttributeName extends Attribute.GetKeys<TSchemaUID>> = ObjectNotation<Utils.Guard.Never<Attribute.GetTarget<TSchemaUID, TAttributeName>, Common.UID.Schema>>;
11
+ /**
12
+ * Filter representation for scalar attributes
13
+ */
14
+ type AttributeCondition<TSchemaUID extends Common.UID.Schema, TAttributeName extends IDKey | Attribute.GetKeys<TSchemaUID>> = Utils.Expression.MatchFirst<[
15
+ [
16
+ Utils.Expression.StrictEqual<TAttributeName, IDKey>,
17
+ Params.Attribute.ID
18
+ ],
19
+ [
20
+ Utils.Expression.IsNotNever<TAttributeName>,
21
+ AttributeUtils.GetValue<Attribute.Get<TSchemaUID, Exclude<TAttributeName, IDKey>>>
22
+ ]
23
+ ], AttributeUtils.ScalarValues> extends infer TAttributeValue ? TAttributeValue | ({
24
+ [TIter in Operator.BooleanValue]?: boolean;
25
+ } & {
26
+ [TIter in Operator.DynamicValue]?: TAttributeValue;
27
+ } & {
28
+ [TIter in Operator.DynamicArrayValue]?: TAttributeValue[];
29
+ } & {
30
+ [TIter in Operator.DynamicBoundValue]?: [TAttributeValue, TAttributeValue];
31
+ } & {
32
+ [TIter in Operator.Logical]?: AttributeCondition<TSchemaUID, TAttributeName>;
33
+ } & {
34
+ [TIter in Operator.Group]?: AttributeCondition<TSchemaUID, TAttributeName>[];
35
+ }) : never;
36
+ /**
37
+ * Tree representation of a Strapi filter for a given schema UID
38
+ */
39
+ export type ObjectNotation<TSchemaUID extends Common.UID.Schema> = {
40
+ [TIter in Operator.Group]?: ObjectNotation<TSchemaUID>[];
41
+ } & {
42
+ [TIter in Operator.Logical]?: ObjectNotation<TSchemaUID>;
43
+ } & ([AttributeUtils.GetScalarKeys<TSchemaUID>, AttributeUtils.GetNestedKeys<TSchemaUID>] extends [
44
+ infer TScalarKeys extends AttributeUtils.GetScalarKeys<TSchemaUID>,
45
+ infer TNestedKeys extends AttributeUtils.GetNestedKeys<TSchemaUID>
46
+ ] ? Utils.Expression.If<Utils.Expression.And<Utils.Expression.IsNotNever<TScalarKeys>, Utils.Expression.IsNotNever<TNestedKeys>>, {
47
+ [TIter in IDKey | TScalarKeys]?: AttributeCondition<TSchemaUID, TIter>;
48
+ } & {
49
+ [TIter in TNestedKeys]?: NestedAttributeCondition<TSchemaUID, TIter>;
50
+ }, {
51
+ [TKey in string]?: AttributeCondition<TSchemaUID, never> | NestedAttributeCondition<TSchemaUID, never>;
52
+ }> : never);
53
+ export type Any<TSchemaUID extends Common.UID.Schema> = ObjectNotation<TSchemaUID>;
@@ -0,0 +1,8 @@
1
+ export type Array = '$in' | '$notIn' | '$between';
2
+ export type Group = '$and' | '$or';
3
+ export type Logical = '$not';
4
+ export type BooleanValue = '$null' | '$notNull';
5
+ export type DynamicValue = '$eq' | '$eqi' | '$ne' | '$nei' | '$gt' | '$gte' | '$lt' | '$lte' | '$startsWith' | '$endsWith' | '$startsWithi' | '$endsWithi' | '$contains' | '$notContains' | '$containsi' | '$notContainsi';
6
+ export type DynamicArrayValue = '$in' | '$notIn';
7
+ export type DynamicBoundValue = '$between';
8
+ export type Where = BooleanValue | DynamicValue | DynamicArrayValue | DynamicBoundValue;