@strapi/utils 4.14.2 → 4.14.4
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/dist/index.d.ts +19 -143
- package/dist/index.js +7223 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7206 -0
- package/dist/index.mjs.map +1 -0
- package/dist/parse-multipart.d.ts +1 -2
- package/dist/print-value.d.ts +1 -1
- package/dist/template-configuration.d.ts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +12 -12
- package/dist/async.js +0 -33
- package/dist/async.js.map +0 -1
- package/dist/code-generator.js +0 -11
- package/dist/code-generator.js.map +0 -1
- package/dist/config.js +0 -79
- package/dist/config.js.map +0 -1
- package/dist/content-types.js +0 -162
- package/dist/content-types.js.map +0 -1
- package/dist/convert-query-params.js +0 -477
- package/dist/convert-query-params.js.map +0 -1
- package/dist/env-helper.js +0 -84
- package/dist/env-helper.js.map +0 -1
- package/dist/errors.js +0 -101
- package/dist/errors.js.map +0 -1
- package/dist/file.js +0 -54
- package/dist/file.js.map +0 -1
- package/dist/format-yup-error.js +0 -17
- package/dist/format-yup-error.js.map +0 -1
- package/dist/hooks.js +0 -89
- package/dist/hooks.js.map +0 -1
- package/dist/import-default.js +0 -9
- package/dist/import-default.js.map +0 -1
- package/dist/object-formatting.js +0 -14
- package/dist/object-formatting.js.map +0 -1
- package/dist/operators.js +0 -72
- package/dist/operators.js.map +0 -1
- package/dist/pagination.js +0 -80
- package/dist/pagination.js.map +0 -1
- package/dist/parse-multipart.js +0 -36
- package/dist/parse-multipart.js.map +0 -1
- package/dist/parse-type.js +0 -108
- package/dist/parse-type.js.map +0 -1
- package/dist/policy.js +0 -109
- package/dist/policy.js.map +0 -1
- package/dist/print-value.js +0 -50
- package/dist/print-value.js.map +0 -1
- package/dist/provider-factory.js +0 -80
- package/dist/provider-factory.js.map +0 -1
- package/dist/relations.js +0 -23
- package/dist/relations.js.map +0 -1
- package/dist/sanitize/index.js +0 -156
- package/dist/sanitize/index.js.map +0 -1
- package/dist/sanitize/sanitizers.js +0 -147
- package/dist/sanitize/sanitizers.js.map +0 -1
- package/dist/sanitize/visitors/index.js +0 -21
- package/dist/sanitize/visitors/index.js.map +0 -1
- package/dist/sanitize/visitors/remove-disallowed-fields.js +0 -83
- package/dist/sanitize/visitors/remove-disallowed-fields.js.map +0 -1
- package/dist/sanitize/visitors/remove-dynamic-zones.js +0 -10
- package/dist/sanitize/visitors/remove-dynamic-zones.js.map +0 -1
- package/dist/sanitize/visitors/remove-morph-to-relations.js +0 -10
- package/dist/sanitize/visitors/remove-morph-to-relations.js.map +0 -1
- package/dist/sanitize/visitors/remove-password.js +0 -9
- package/dist/sanitize/visitors/remove-password.js.map +0 -1
- package/dist/sanitize/visitors/remove-private.js +0 -14
- package/dist/sanitize/visitors/remove-private.js.map +0 -1
- package/dist/sanitize/visitors/remove-restricted-fields.js +0 -25
- package/dist/sanitize/visitors/remove-restricted-fields.js.map +0 -1
- package/dist/sanitize/visitors/remove-restricted-relations.js +0 -88
- package/dist/sanitize/visitors/remove-restricted-relations.js.map +0 -1
- package/dist/set-creator-fields.js +0 -39
- package/dist/set-creator-fields.js.map +0 -1
- package/dist/string-formatting.js +0 -85
- package/dist/string-formatting.js.map +0 -1
- package/dist/template-configuration.js +0 -30
- package/dist/template-configuration.js.map +0 -1
- package/dist/template.js +0 -20
- package/dist/template.js.map +0 -1
- package/dist/traverse/factory.js +0 -127
- package/dist/traverse/factory.js.map +0 -1
- package/dist/traverse/index.js +0 -17
- package/dist/traverse/index.js.map +0 -1
- package/dist/traverse/query-fields.js +0 -35
- package/dist/traverse/query-fields.js.map +0 -1
- package/dist/traverse/query-filters.js +0 -75
- package/dist/traverse/query-filters.js.map +0 -1
- package/dist/traverse/query-populate.js +0 -171
- package/dist/traverse/query-populate.js.map +0 -1
- package/dist/traverse/query-sort.js +0 -117
- package/dist/traverse/query-sort.js.map +0 -1
- package/dist/traverse-entity.js +0 -134
- package/dist/traverse-entity.js.map +0 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/validate/index.js +0 -121
- package/dist/validate/index.js.map +0 -1
- package/dist/validate/utils.js +0 -9
- package/dist/validate/utils.js.map +0 -1
- package/dist/validate/validators.js +0 -115
- package/dist/validate/validators.js.map +0 -1
- package/dist/validate/visitors/index.js +0 -21
- package/dist/validate/visitors/index.js.map +0 -1
- package/dist/validate/visitors/throw-disallowed-fields.js +0 -84
- package/dist/validate/visitors/throw-disallowed-fields.js.map +0 -1
- package/dist/validate/visitors/throw-dynamic-zones.js +0 -11
- package/dist/validate/visitors/throw-dynamic-zones.js.map +0 -1
- package/dist/validate/visitors/throw-morph-to-relations.js +0 -11
- package/dist/validate/visitors/throw-morph-to-relations.js.map +0 -1
- package/dist/validate/visitors/throw-password.js +0 -10
- package/dist/validate/visitors/throw-password.js.map +0 -1
- package/dist/validate/visitors/throw-private.js +0 -15
- package/dist/validate/visitors/throw-private.js.map +0 -1
- package/dist/validate/visitors/throw-restricted-fields.js +0 -24
- package/dist/validate/visitors/throw-restricted-fields.js.map +0 -1
- package/dist/validate/visitors/throw-restricted-relations.js +0 -81
- package/dist/validate/visitors/throw-restricted-relations.js.map +0 -1
- package/dist/validators.js +0 -64
- package/dist/validators.js.map +0 -1
- package/dist/webhook.js +0 -27
- package/dist/webhook.js.map +0 -1
- package/dist/yup.js +0 -108
- package/dist/yup.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,157 +1,33 @@
|
|
|
1
|
-
/// <reference types="koa" />
|
|
2
|
-
/// <reference types="formidable" />
|
|
3
|
-
/// <reference types="lodash" />
|
|
4
1
|
/**
|
|
5
2
|
* Export shared utilities
|
|
6
3
|
*/
|
|
7
|
-
import
|
|
4
|
+
import { parseMultipartData } from './parse-multipart';
|
|
5
|
+
import parseType from './parse-type';
|
|
8
6
|
import * as policy from './policy';
|
|
7
|
+
import { templateConfiguration } from './template-configuration';
|
|
8
|
+
import { handleYupError, validateYupSchema, validateYupSchemaSync } from './validators';
|
|
9
9
|
import * as yup from './yup';
|
|
10
10
|
import * as errors from './errors';
|
|
11
|
+
import { nameToSlug, nameToCollectionName, getCommonBeginning, escapeQuery, stringIncludes, stringEquals, isKebabCase, isCamelCase, toRegressedEnumValue, startsWithANumber, joinBy, toKebabCase } from './string-formatting';
|
|
12
|
+
import { removeUndefined, keysDeep } from './object-formatting';
|
|
13
|
+
import { getConfigUrls, getAbsoluteAdminUrl, getAbsoluteServerUrl } from './config';
|
|
14
|
+
import { generateTimestampCode } from './code-generator';
|
|
11
15
|
import * as contentTypes from './content-types';
|
|
16
|
+
import env from './env-helper';
|
|
12
17
|
import * as relations from './relations';
|
|
18
|
+
import setCreatorFields from './set-creator-fields';
|
|
13
19
|
import * as hooks from './hooks';
|
|
20
|
+
import providerFactory from './provider-factory';
|
|
14
21
|
import * as pagination from './pagination';
|
|
15
|
-
import
|
|
22
|
+
import sanitize from './sanitize';
|
|
23
|
+
import validate from './validate';
|
|
24
|
+
import traverseEntity from './traverse-entity';
|
|
25
|
+
import { pipeAsync, mapAsync, reduceAsync, forEachAsync } from './async';
|
|
26
|
+
import convertQueryParams from './convert-query-params';
|
|
16
27
|
import importDefault from './import-default';
|
|
17
28
|
import * as template from './template';
|
|
18
29
|
import * as file from './file';
|
|
19
30
|
import * as traverse from './traverse';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
type AnySchema = yupTypes.AnySchema;
|
|
24
|
-
type NumberSchema = yupTypes.NumberSchema;
|
|
25
|
-
type StringSchema = yupTypes.StringSchema;
|
|
26
|
-
type BooleanSchema = yupTypes.BooleanSchema;
|
|
27
|
-
type ObjectSchema = yupTypes.AnyObjectSchema;
|
|
28
|
-
type ArraySchema<T extends yupTypes.AnySchema = any> = yupTypes.ArraySchema<T>;
|
|
29
|
-
type LazySchema<T extends yupTypes.AnySchema = any> = ReturnType<typeof yupTypes.lazy<T>>;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
declare const utils: {
|
|
33
|
-
parseMultipartData: (ctx: import("koa").Context) => import("koa").Context | {
|
|
34
|
-
data: any;
|
|
35
|
-
files: import("formidable").Files;
|
|
36
|
-
};
|
|
37
|
-
parseType: <Type extends keyof {
|
|
38
|
-
boolean: boolean;
|
|
39
|
-
integer: number;
|
|
40
|
-
biginteger: number;
|
|
41
|
-
float: number;
|
|
42
|
-
decimal: number;
|
|
43
|
-
time: string;
|
|
44
|
-
date: string;
|
|
45
|
-
timestamp: Date;
|
|
46
|
-
datetime: Date;
|
|
47
|
-
}>(options: import("./parse-type").ParseTypeOptions<Type>) => {
|
|
48
|
-
boolean: boolean;
|
|
49
|
-
integer: number;
|
|
50
|
-
biginteger: number;
|
|
51
|
-
float: number;
|
|
52
|
-
decimal: number;
|
|
53
|
-
time: string;
|
|
54
|
-
date: string;
|
|
55
|
-
timestamp: Date;
|
|
56
|
-
datetime: Date;
|
|
57
|
-
}[Type];
|
|
58
|
-
policy: typeof policy;
|
|
59
|
-
templateConfiguration: (obj: Record<string, unknown>, configPath?: string) => Record<string, unknown>;
|
|
60
|
-
yup: typeof yup;
|
|
61
|
-
handleYupError: (error: yupTypes.ValidationError, errorMessage?: string | undefined) => never;
|
|
62
|
-
validateYupSchema: (schema: yupTypes.AnySchema, options?: {}) => (body: unknown, errorMessage?: string | undefined) => Promise<any>;
|
|
63
|
-
validateYupSchemaSync: (schema: yupTypes.AnySchema, options?: {}) => (body: unknown, errorMessage?: string | undefined) => any;
|
|
64
|
-
errors: typeof errors;
|
|
65
|
-
nameToSlug: (name: string, options?: import("@sindresorhus/slugify").Options) => string;
|
|
66
|
-
nameToCollectionName: (name: string) => string;
|
|
67
|
-
getCommonBeginning: (...strings: string[]) => string;
|
|
68
|
-
escapeQuery: (query: string, charsToEscape: string, escapeChar?: string) => string;
|
|
69
|
-
stringIncludes: (arr: unknown[], val: unknown) => boolean;
|
|
70
|
-
stringEquals: (a: unknown, b: unknown) => boolean;
|
|
71
|
-
isKebabCase: (value: string) => boolean;
|
|
72
|
-
isCamelCase: (value: string) => boolean;
|
|
73
|
-
toRegressedEnumValue: (value: string) => string;
|
|
74
|
-
startsWithANumber: (value: string) => boolean;
|
|
75
|
-
joinBy: (joint: string, ...args: string[]) => string;
|
|
76
|
-
toKebabCase: (value: string) => string;
|
|
77
|
-
removeUndefined: <T extends object>(obj: T) => Partial<T>;
|
|
78
|
-
keysDeep: (obj: object, path?: string[]) => string[];
|
|
79
|
-
getConfigUrls: (config: import("./types").Config, forAdminBuild?: boolean) => {
|
|
80
|
-
serverUrl: string;
|
|
81
|
-
adminUrl: string;
|
|
82
|
-
adminPath: string;
|
|
83
|
-
};
|
|
84
|
-
getAbsoluteAdminUrl: (config: import("./types").Config, forAdminBuild?: boolean) => string;
|
|
85
|
-
getAbsoluteServerUrl: (config: import("./types").Config, forAdminBuild?: boolean) => string;
|
|
86
|
-
generateTimestampCode: (date: Date) => string;
|
|
87
|
-
contentTypes: typeof contentTypes;
|
|
88
|
-
env: (<T_1>(key: string, defaultValue?: T_1 | undefined) => string | T_1 | undefined) & {
|
|
89
|
-
int(key: string, defaultValue?: number | undefined): number | undefined;
|
|
90
|
-
float(key: string, defaultValue?: number | undefined): number | undefined;
|
|
91
|
-
bool(key: string, defaultValue?: boolean | undefined): boolean | undefined;
|
|
92
|
-
json(key: string, defaultValue?: object | undefined): any;
|
|
93
|
-
array(key: string, defaultValue?: string[] | undefined): string[] | undefined;
|
|
94
|
-
date(key: string, defaultValue?: Date | undefined): Date | undefined;
|
|
95
|
-
oneOf(key: string, expectedValues?: unknown[] | undefined, defaultValue?: unknown): unknown;
|
|
96
|
-
};
|
|
97
|
-
relations: typeof relations;
|
|
98
|
-
setCreatorFields: <TData extends object>({ user, isEdition }: import("./set-creator-fields").Options) => <TDataInner extends object = TData>(data: TDataInner) => TDataInner;
|
|
99
|
-
hooks: typeof hooks;
|
|
100
|
-
providerFactory: import("./provider-factory").ProviderFactory;
|
|
101
|
-
pagination: typeof pagination;
|
|
102
|
-
sanitize: {
|
|
103
|
-
contentAPI: {
|
|
104
|
-
input: import("./sanitize").SanitizeFunc;
|
|
105
|
-
output: import("./sanitize").SanitizeFunc;
|
|
106
|
-
query: (query: Record<string, unknown>, schema: import("./types").Model, { auth }?: import("./sanitize").Options) => Promise<Record<string, unknown>>;
|
|
107
|
-
filters: import("./sanitize").SanitizeFunc;
|
|
108
|
-
sort: import("./sanitize").SanitizeFunc;
|
|
109
|
-
fields: import("./sanitize").SanitizeFunc;
|
|
110
|
-
populate: import("./sanitize").SanitizeFunc;
|
|
111
|
-
};
|
|
112
|
-
sanitizers: typeof import("./sanitize/sanitizers");
|
|
113
|
-
visitors: typeof import("./sanitize/visitors");
|
|
114
|
-
};
|
|
115
|
-
validate: {
|
|
116
|
-
contentAPI: {
|
|
117
|
-
input: import("./validate").ValidateFunc;
|
|
118
|
-
query: (query: Record<string, unknown>, schema: import("./types").Model, { auth }?: import("./validate").Options) => Promise<void>;
|
|
119
|
-
filters: import("./validate").ValidateFunc;
|
|
120
|
-
sort: import("./validate").ValidateFunc;
|
|
121
|
-
fields: import("./validate").ValidateFunc;
|
|
122
|
-
};
|
|
123
|
-
validators: typeof import("./validate/validators");
|
|
124
|
-
visitors: typeof import("./validate/visitors");
|
|
125
|
-
};
|
|
126
|
-
traverseEntity: import("lodash").CurriedFunction3<import("./traverse-entity").Visitor, import("./traverse-entity").TraverseOptions, import("./types").Data, Promise<import("./types").Data>>;
|
|
127
|
-
pipeAsync: typeof pipeAsync;
|
|
128
|
-
mapAsync: (...args: any[]) => any;
|
|
129
|
-
reduceAsync: (mixedArray: any[]) => <T_2>(iteratee: (...args: any) => any, initialValue?: T_2 | undefined) => Promise<T_2 | undefined>;
|
|
130
|
-
forEachAsync: <T_3, R>(array: T_3[], func: import("p-map").Mapper<T_3, R>, options: import("p-map").Options) => Promise<void>;
|
|
131
|
-
convertQueryParams: {
|
|
132
|
-
convertSortQueryParams: (sortQuery: string | string[] | import("./convert-query-params").SortParamsObject | import("./convert-query-params").SortParamsObject[]) => import("./convert-query-params").SortMap | import("./convert-query-params").SortMap[];
|
|
133
|
-
convertStartQueryParams: (startQuery: unknown) => number;
|
|
134
|
-
convertLimitQueryParams: (limitQuery: unknown) => number | undefined;
|
|
135
|
-
convertPopulateQueryParams: (populate: string | string[] | import("./convert-query-params").PopulateAttributesParams, schema?: import("./types").Model | undefined, depth?: number) => boolean | string[] | {
|
|
136
|
-
[key: string]: boolean | string[] | any;
|
|
137
|
-
};
|
|
138
|
-
convertFiltersQueryParams: (filters: unknown, schema?: import("./types").Model | undefined) => import("./convert-query-params").WhereQuery;
|
|
139
|
-
convertFieldsQueryParams: (fields: string | string[], depth?: number) => (string | string[]) | undefined;
|
|
140
|
-
convertPublicationStateParams: (schema?: import("./types").Model | undefined, params?: {
|
|
141
|
-
publicationState?: "live" | "preview" | undefined;
|
|
142
|
-
}, query?: import("./convert-query-params").Query) => void;
|
|
143
|
-
transformParamsToQuery: (uid: string, params: import("./convert-query-params").Params) => import("./convert-query-params").Query;
|
|
144
|
-
};
|
|
145
|
-
importDefault: typeof importDefault;
|
|
146
|
-
template: typeof template;
|
|
147
|
-
file: typeof file;
|
|
148
|
-
traverse: typeof traverse;
|
|
149
|
-
webhook: {
|
|
150
|
-
webhookEvents: {
|
|
151
|
-
[x: string]: string;
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
isOperator: (key: string, ignoreCase?: boolean) => boolean;
|
|
155
|
-
isOperatorOfType: (type: string, key: string, ignoreCase?: boolean) => boolean;
|
|
156
|
-
};
|
|
157
|
-
export = utils;
|
|
31
|
+
import webhook from './webhook';
|
|
32
|
+
import { isOperator, isOperatorOfType } from './operators';
|
|
33
|
+
export { parseMultipartData, parseType, policy, templateConfiguration, yup, handleYupError, validateYupSchema, validateYupSchemaSync, errors, nameToSlug, nameToCollectionName, getCommonBeginning, escapeQuery, stringIncludes, stringEquals, isKebabCase, isCamelCase, toRegressedEnumValue, startsWithANumber, joinBy, toKebabCase, removeUndefined, keysDeep, getConfigUrls, getAbsoluteAdminUrl, getAbsoluteServerUrl, generateTimestampCode, contentTypes, env, relations, setCreatorFields, hooks, providerFactory, pagination, sanitize, validate, traverseEntity, pipeAsync, mapAsync, reduceAsync, forEachAsync, convertQueryParams, importDefault, template, file, traverse, webhook, isOperator, isOperatorOfType, };
|