@strapi/types 0.0.0 → 4.14.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.
- package/LICENSE +22 -0
- package/README.md +5 -0
- package/dist/container.d.ts +5 -0
- package/dist/index.d.ts +138 -0
- package/dist/modules/auth.d.ts +24 -0
- package/dist/modules/content-api.d.ts +29 -0
- package/dist/modules/core-store.d.ts +27 -0
- package/dist/modules/cron.d.ts +26 -0
- package/dist/modules/custom-fields.d.ts +24 -0
- package/dist/modules/entity-service/index.d.ts +73 -0
- package/dist/modules/entity-service/params/attributes.d.ts +74 -0
- package/dist/modules/entity-service/params/data.d.ts +3 -0
- package/dist/modules/entity-service/params/fields.d.ts +58 -0
- package/dist/modules/entity-service/params/filters/index.d.ts +53 -0
- package/dist/modules/entity-service/params/filters/operators.d.ts +8 -0
- package/dist/modules/entity-service/params/index.d.ts +132 -0
- package/dist/modules/entity-service/params/pagination.d.ts +10 -0
- package/dist/modules/entity-service/params/populate.d.ts +68 -0
- package/dist/modules/entity-service/params/publication-state.d.ts +15 -0
- package/dist/modules/entity-service/params/search.d.ts +1 -0
- package/dist/modules/entity-service/params/sort.d.ts +84 -0
- package/dist/modules/entity-service/plugin.d.ts +7 -0
- package/dist/modules/entity-service/result.d.ts +88 -0
- package/dist/modules/entity-validator.d.ts +18 -0
- package/dist/modules/event-hub.d.ts +14 -0
- package/dist/modules/fetch.d.ts +6 -0
- package/dist/modules/metrics.d.ts +7 -0
- package/dist/modules/request-context.d.ts +5 -0
- package/dist/modules/sanitizers.d.ts +8 -0
- package/dist/modules/server.d.ts +30 -0
- package/dist/modules/validators.d.ts +8 -0
- package/dist/modules/webhook-runner.d.ts +15 -0
- package/dist/modules/webhook-store.d.ts +20 -0
- package/dist/types/core/attributes/base.d.ts +51 -0
- package/dist/types/core/attributes/biginteger.d.ts +4 -0
- package/dist/types/core/attributes/blocks.d.ts +4 -0
- package/dist/types/core/attributes/boolean.d.ts +6 -0
- package/dist/types/core/attributes/common.d.ts +58 -0
- package/dist/types/core/attributes/component.d.ts +10 -0
- package/dist/types/core/attributes/date-time.d.ts +4 -0
- package/dist/types/core/attributes/date.d.ts +4 -0
- package/dist/types/core/attributes/decimal.d.ts +4 -0
- package/dist/types/core/attributes/dynamic-zone.d.ts +12 -0
- package/dist/types/core/attributes/email.d.ts +4 -0
- package/dist/types/core/attributes/enumeration.d.ts +8 -0
- package/dist/types/core/attributes/float.d.ts +4 -0
- package/dist/types/core/attributes/index.d.ts +25 -0
- package/dist/types/core/attributes/integer.d.ts +4 -0
- package/dist/types/core/attributes/json.d.ts +4 -0
- package/dist/types/core/attributes/media.d.ts +12 -0
- package/dist/types/core/attributes/password.d.ts +4 -0
- package/dist/types/core/attributes/relation.d.ts +75 -0
- package/dist/types/core/attributes/richtext.d.ts +4 -0
- package/dist/types/core/attributes/string.d.ts +9 -0
- package/dist/types/core/attributes/text.d.ts +7 -0
- package/dist/types/core/attributes/time.d.ts +4 -0
- package/dist/types/core/attributes/timestamp.d.ts +4 -0
- package/dist/types/core/attributes/uid.d.ts +15 -0
- package/dist/types/core/attributes/utils.d.ts +27 -0
- package/dist/types/core/commands/index.d.ts +5 -0
- package/dist/types/core/common/api.d.ts +3 -0
- package/dist/types/core/common/controller.d.ts +5 -0
- package/dist/types/core/common/index.d.ts +18 -0
- package/dist/types/core/common/middleware.d.ts +7 -0
- package/dist/types/core/common/module.d.ts +24 -0
- package/dist/types/core/common/plugin.d.ts +5 -0
- package/dist/types/core/common/policy.d.ts +9 -0
- package/dist/types/core/common/router.d.ts +34 -0
- package/dist/types/core/common/schema.d.ts +2 -0
- package/dist/types/core/common/service.d.ts +3 -0
- package/dist/types/core/common/uid.d.ts +15 -0
- package/dist/types/core/index.d.ts +17 -0
- package/dist/types/core/namespace.d.ts +77 -0
- package/dist/types/core/plugins/config/index.d.ts +2 -0
- package/dist/types/core/plugins/config/strapi-admin/index.d.ts +5 -0
- package/dist/types/core/plugins/config/strapi-server/config.d.ts +4 -0
- package/dist/types/core/plugins/config/strapi-server/content-types.d.ts +10 -0
- package/dist/types/core/plugins/config/strapi-server/controllers.d.ts +7 -0
- package/dist/types/core/plugins/config/strapi-server/index.d.ts +20 -0
- package/dist/types/core/plugins/config/strapi-server/lifecycle.d.ts +7 -0
- package/dist/types/core/plugins/config/strapi-server/routes.d.ts +10 -0
- package/dist/types/core/plugins/index.d.ts +5 -0
- package/dist/types/core/registry.d.ts +57 -0
- package/dist/types/core/schemas/index.d.ts +124 -0
- package/dist/types/core/strapi/index.d.ts +25 -0
- package/dist/types/core/uid.d.ts +108 -0
- package/dist/types/core-api/controller.d.ts +44 -0
- package/dist/types/core-api/index.d.ts +3 -0
- package/dist/types/core-api/router.d.ts +62 -0
- package/dist/types/core-api/service.d.ts +64 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/shared/index.d.ts +3 -0
- package/dist/types/shared/registries.d.ts +37 -0
- package/dist/types/utils/array.d.ts +15 -0
- package/dist/types/utils/expression.d.ts +42 -0
- package/dist/types/utils/function.d.ts +2 -0
- package/dist/types/utils/guard.d.ts +19 -0
- package/dist/types/utils/index.d.ts +25 -0
- package/dist/types/utils/object.d.ts +58 -0
- package/dist/types/utils/string.d.ts +39 -0
- package/dist/types/utils/tuple.d.ts +8 -0
- package/index.js +2 -0
- package/package.json +70 -5
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Utils } from '..';
|
|
2
|
+
/**
|
|
3
|
+
* Assign a default value `TDefault` to `TValue` if `TValue` is of type `never`
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* type X = Never<{ foo: 'bar' }, string>
|
|
7
|
+
* // { foo: 'bar' }
|
|
8
|
+
*
|
|
9
|
+
* type X = Never<never>
|
|
10
|
+
* // unknown
|
|
11
|
+
*
|
|
12
|
+
* type X = Never<never, string>
|
|
13
|
+
* // string
|
|
14
|
+
*/
|
|
15
|
+
export type Never<TValue, TFallback = unknown> = OfTypes<[never], TValue, TFallback>;
|
|
16
|
+
export type OfTypes<TTypes extends unknown[], TValue, TFallback = unknown> = TTypes extends [
|
|
17
|
+
infer THead extends unknown,
|
|
18
|
+
...infer TTail extends unknown[]
|
|
19
|
+
] ? Utils.Expression.If<Utils.Expression.StrictEqual<TValue, THead>, TFallback, Utils.Expression.If<Utils.Array.IsNotEmpty<TTail>, OfTypes<TTail, TValue, TFallback>, TValue>> : never;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 Function from './function';
|
|
6
|
+
export * as Tuple from './tuple';
|
|
7
|
+
export * as Expression from './expression';
|
|
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];
|
|
20
|
+
export type PartialWithThis<T> = Partial<T> & ThisType<T>;
|
|
21
|
+
export type Without<TLeft, TRight> = {
|
|
22
|
+
[key in Exclude<keyof TLeft, keyof TRight>]?: never;
|
|
23
|
+
};
|
|
24
|
+
export type XOR<TLeft, TRight> = TLeft | TRight extends object ? (Without<TLeft, TRight> & TRight) | (Without<TRight, TLeft> & TLeft) : TLeft | TRight;
|
|
25
|
+
export type Cast<TValue, TType> = TValue extends TType ? TValue : never;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieve object's (`TValue`) keys if they extend 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, TExtract extends keyof any = keyof any> = {
|
|
14
|
+
[key in keyof TValue & TExtract]: TValue[key] extends TTest ? key : never;
|
|
15
|
+
}[keyof TValue & TExtract];
|
|
16
|
+
/**
|
|
17
|
+
* Retrieve object's (`TValue`) keys if they don't extend the given `TTest` type.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* type X = KeysExcept<{ foo: 'bar', bar: 'foo', foobar: 2 }, string>
|
|
21
|
+
* // foobar
|
|
22
|
+
*
|
|
23
|
+
* type Base = { x: 'foo' | 'bar' };
|
|
24
|
+
* type Obj = { foo: { x: 'foo' }, bar: { x: 'bar' }, other: { x: '42' } };
|
|
25
|
+
* type X = KeysBy<Obj, Base>
|
|
26
|
+
* // 'other'
|
|
27
|
+
*/
|
|
28
|
+
export type KeysExcept<TValue, TTest, TExtract extends keyof any = keyof any> = {
|
|
29
|
+
[key in keyof TValue & TExtract]: TValue[key] extends TTest ? never : key;
|
|
30
|
+
}[keyof TValue & TExtract];
|
|
31
|
+
/**
|
|
32
|
+
* Retrieve object's (`TValue`) properties if their value extends the given `TTest` type.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* type X = KeysBy<{ foo: 'bar', bar: 'foo', foobar: 2 }, string>
|
|
36
|
+
* // { foo: 'bar', bar: 'foo' }
|
|
37
|
+
*
|
|
38
|
+
* type Base = { x: 'foo' | 'bar' };
|
|
39
|
+
* type Obj = { foo: { x: 'foo' }, bar: { x: 'bar' }, other: { x: '42' } };
|
|
40
|
+
* type X = KeysBy<Obj, Base>
|
|
41
|
+
* // { foo: { x: 'foo' }, bar: { x: 'bar' } }
|
|
42
|
+
*/
|
|
43
|
+
export type PickBy<TValue, TTest> = Pick<TValue, KeysBy<TValue, TTest>>;
|
|
44
|
+
export type PartialBy<TValue, TKeys extends keyof TValue> = Omit<TValue, TKeys> & Partial<Pick<TValue, TKeys>>;
|
|
45
|
+
/**
|
|
46
|
+
* Retrieve object's (`TObject`) values
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* type X = Values<{ foo: 'bar', bar: 'foo', foobar: 2 }>
|
|
50
|
+
* // 'bar' | 'foo' | 2
|
|
51
|
+
*
|
|
52
|
+
* type Y = Values<{ foo: { x: 'foo' }, bar: { x: 'bar' }, other: { x: '42' } }>
|
|
53
|
+
* // { x: 'foo' } | { x: 'bar' } | { x: '42' }
|
|
54
|
+
*/
|
|
55
|
+
export type Values<TObject extends object> = TObject[keyof TObject];
|
|
56
|
+
export type DeepPartial<TObject> = TObject extends object ? {
|
|
57
|
+
[TKey in keyof TObject]?: DeepPartial<TObject[TKey]>;
|
|
58
|
+
} : TObject;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Utils } from '..';
|
|
2
|
+
/**
|
|
3
|
+
* Alias for any literal type (useful for template string parameters)
|
|
4
|
+
*/
|
|
5
|
+
export type Literal = string | number | bigint | boolean;
|
|
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
|
+
* Used to make sure the given string is not empty
|
|
12
|
+
*/
|
|
13
|
+
export type NonEmpty<T extends string> = T extends '' ? never : T;
|
|
14
|
+
/**
|
|
15
|
+
* Split the given string into a tuple using the given `TSeparator` literal
|
|
16
|
+
*/
|
|
17
|
+
export type Split<TValue extends string, TSeparator extends Literal> = TValue extends `${infer TLeft}${TSeparator}${infer TRight}` ? [TLeft, ...Split<TRight, TSeparator>] : TValue extends '' ? [] : [TValue];
|
|
18
|
+
/**
|
|
19
|
+
* Add a literal suffix (`TSuffix`) at the end of the given string
|
|
20
|
+
*/
|
|
21
|
+
export type Suffix<TValue extends string, TSuffix extends Literal> = `${TValue}${TSuffix}`;
|
|
22
|
+
/**
|
|
23
|
+
* Add a literal prefix (`TPrefix`) at the beginning of the given string
|
|
24
|
+
*/
|
|
25
|
+
export type Prefix<TValue extends string, TPrefix extends Literal> = `${TPrefix}${TValue}`;
|
|
26
|
+
/**
|
|
27
|
+
* Creates an indexed object where every key is a string and every value is `T`
|
|
28
|
+
*/
|
|
29
|
+
export type Dict<T> = {
|
|
30
|
+
[key: string]: T;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Checks if a given string ends with the given literal
|
|
34
|
+
*/
|
|
35
|
+
export type EndsWith<TValue extends string, TSuffix extends Literal> = Utils.Expression.Extends<TValue, `${string}${TSuffix}`>;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if a given string starts with the given literal
|
|
38
|
+
*/
|
|
39
|
+
export type StartsWith<TValue extends string, TPrefix extends Literal> = Utils.Expression.Extends<TValue, `${TPrefix}${string}`>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Literal } from './string';
|
|
2
|
+
/**
|
|
3
|
+
* Aggregate the given tuple into a string, separated by the given `TSeparator` literal
|
|
4
|
+
*/
|
|
5
|
+
export type Join<TCollection extends unknown[], TSeparator extends Literal> = TCollection extends [
|
|
6
|
+
infer THead extends Literal,
|
|
7
|
+
...infer TTail
|
|
8
|
+
] ? TTail['length'] extends 0 ? THead : `${THead}${TSeparator}${Join<TTail, TSeparator>}` : never;
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,8 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/types",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Strapi
|
|
5
|
-
"keywords": [
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"version": "4.14.0",
|
|
4
|
+
"description": "Shared typescript types for Strapi internal use",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"strapi"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://strapi.io",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/strapi/strapi/issues"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git://github.com/strapi/strapi.git"
|
|
15
|
+
},
|
|
16
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Strapi Solutions SAS",
|
|
19
|
+
"email": "hi@strapi.io",
|
|
20
|
+
"url": "https://strapi.io"
|
|
21
|
+
},
|
|
22
|
+
"maintainers": [
|
|
23
|
+
{
|
|
24
|
+
"name": "Strapi Solutions SAS",
|
|
25
|
+
"email": "hi@strapi.io",
|
|
26
|
+
"url": "https://strapi.io"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"main": "index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"./dist",
|
|
33
|
+
"index.js"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "run -T tsc -p tsconfig.build.json",
|
|
37
|
+
"build:ts": "run build",
|
|
38
|
+
"watch": "run -T tsc -p tsconfig.build.json -w --preserveWatchOutput",
|
|
39
|
+
"clean": "run -T rimraf ./dist",
|
|
40
|
+
"prepublishOnly": "yarn clean && yarn build",
|
|
41
|
+
"lint": "run -T eslint .",
|
|
42
|
+
"test:unit": "run -T jest",
|
|
43
|
+
"test:unit:watch": "run -T jest --watch"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@koa/cors": "3.4.3",
|
|
47
|
+
"@koa/router": "10.1.1",
|
|
48
|
+
"@strapi/database": "4.14.0",
|
|
49
|
+
"@strapi/logger": "4.14.0",
|
|
50
|
+
"@strapi/permissions": "4.14.0",
|
|
51
|
+
"@strapi/utils": "4.14.0",
|
|
52
|
+
"commander": "8.3.0",
|
|
53
|
+
"https-proxy-agent": "5.0.1",
|
|
54
|
+
"koa": "2.13.4",
|
|
55
|
+
"node-fetch": "2.7.0",
|
|
56
|
+
"node-schedule": "2.1.0",
|
|
57
|
+
"ts-zen": "https://github.com/strapi/ts-zen#66e02232f5997674cc7032ea3ee59d9864863732"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/jest": "29.5.2",
|
|
61
|
+
"@types/koa": "2.13.4",
|
|
62
|
+
"@types/koa__router": "12.0.0",
|
|
63
|
+
"@types/node-schedule": "2.1.0",
|
|
64
|
+
"eslint-config-custom": "4.14.0",
|
|
65
|
+
"tsconfig": "4.14.0",
|
|
66
|
+
"typescript": "5.2.2"
|
|
67
|
+
},
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": ">=16.0.0 <=20.x.x",
|
|
70
|
+
"npm": ">=6.0.0"
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "09b6d7a4b46a87142d29665052ca22ced29fa56a"
|
|
8
73
|
}
|