120 lines
3.2 KiB
TypeScript
Raw Normal View History

2023-08-25 00:08:34 +02:00
/* eslint-disable @typescript-eslint/no-namespace */
2016-03-18 11:12:50 +01:00
/**
* Export shared utilities
*/
2023-08-25 00:08:34 +02:00
import type * as yupTypes from 'yup';
2023-07-19 17:28:08 +02:00
import parseMultipartData from './parse-multipart';
import parseType from './parse-type';
import * as policy from './policy';
import templateConfiguration from './template-configuration';
2023-08-25 00:08:34 +02:00
import { handleYupError, validateYupSchema, validateYupSchemaSync } from './validators';
import * as yup from './yup';
2023-08-01 21:01:49 +02:00
2023-07-19 17:28:08 +02:00
import * as errors from './errors';
import {
nameToSlug,
nameToCollectionName,
getCommonBeginning,
escapeQuery,
stringIncludes,
stringEquals,
2021-08-20 15:23:02 +02:00
isKebabCase,
isCamelCase,
toRegressedEnumValue,
startsWithANumber,
2022-03-15 11:51:43 +01:00
joinBy,
toKebabCase,
2023-06-06 10:58:36 +02:00
} from './string-formatting';
2023-07-19 17:28:08 +02:00
import { removeUndefined, keysDeep } from './object-formatting';
import { getConfigUrls, getAbsoluteAdminUrl, getAbsoluteServerUrl } from './config';
import { generateTimestampCode } from './code-generator';
import * as contentTypes from './content-types';
import env from './env-helper';
import * as relations from './relations';
import setCreatorFields from './set-creator-fields';
import * as hooks from './hooks';
import providerFactory from './provider-factory';
import * as pagination from './pagination';
import sanitize from './sanitize';
import validate from './validate';
2023-07-19 17:28:08 +02:00
import traverseEntity from './traverse-entity';
import { pipeAsync, mapAsync, reduceAsync, forEachAsync } from './async';
import convertQueryParams from './convert-query-params';
import importDefault from './import-default';
import * as template from './template';
import * as file from './file';
import * as traverse from './traverse';
import webhook from './webhook';
import { isOperator, isOperatorOfType } from './operators';
2023-08-25 00:08:34 +02:00
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace utils {
export namespace yup {
export type BaseSchema = yupTypes.BaseSchema;
export type AnySchema = yupTypes.AnySchema;
export type NumberSchema = yupTypes.NumberSchema;
export type StringSchema = yupTypes.StringSchema;
export type BooleanSchema = yupTypes.BooleanSchema;
export type ObjectSchema = yupTypes.AnyObjectSchema;
export type ArraySchema<T extends yupTypes.AnySchema = any> = yupTypes.ArraySchema<T>;
export type LazySchema<T extends yupTypes.AnySchema = any> = ReturnType<
typeof yupTypes.lazy<T>
>;
}
}
// eslint-disable-next-line @typescript-eslint/no-redeclare
const utils = {
2023-07-19 17:28:08 +02:00
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,
2023-07-19 17:28:08 +02:00
traverseEntity,
pipeAsync,
mapAsync,
reduceAsync,
forEachAsync,
convertQueryParams,
importDefault,
template,
file,
traverse,
webhook,
isOperator,
isOperatorOfType,
};
2023-08-25 00:08:34 +02:00
export = utils;