vovk 3.0.0-draft.99 → 3.0.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 (167) hide show
  1. package/README.md +22 -13
  2. package/bin/index.mjs +10 -0
  3. package/dist/client/createRPC.d.ts +13 -3
  4. package/dist/client/createRPC.js +112 -50
  5. package/dist/client/defaultHandler.d.ts +5 -1
  6. package/dist/client/defaultHandler.js +12 -9
  7. package/dist/client/defaultStreamHandler.d.ts +16 -4
  8. package/dist/client/defaultStreamHandler.js +259 -62
  9. package/dist/client/fetcher.d.ts +41 -3
  10. package/dist/client/fetcher.js +125 -60
  11. package/dist/client/progressive.d.ts +15 -0
  12. package/dist/client/progressive.js +56 -0
  13. package/dist/{utils → client}/serializeQuery.d.ts +2 -2
  14. package/dist/{utils → client}/serializeQuery.js +1 -4
  15. package/dist/core/HttpException.d.ts +16 -0
  16. package/dist/core/HttpException.js +26 -0
  17. package/dist/core/JSONLinesResponder.d.ts +42 -0
  18. package/dist/core/JSONLinesResponder.js +92 -0
  19. package/dist/core/controllersToStaticParams.d.ts +13 -0
  20. package/dist/core/controllersToStaticParams.js +36 -0
  21. package/dist/core/createDecorator.d.ts +12 -0
  22. package/dist/{createDecorator.js → core/createDecorator.js} +18 -12
  23. package/dist/core/decorators.d.ts +59 -0
  24. package/dist/core/decorators.js +132 -0
  25. package/dist/core/getSchema.d.ts +21 -0
  26. package/dist/core/getSchema.js +31 -0
  27. package/dist/core/initSegment.d.ts +33 -0
  28. package/dist/core/initSegment.js +35 -0
  29. package/dist/core/multitenant.d.ts +33 -0
  30. package/dist/core/multitenant.js +132 -0
  31. package/dist/core/resolveGeneratorConfigValues.d.ts +19 -0
  32. package/dist/core/resolveGeneratorConfigValues.js +59 -0
  33. package/dist/{utils → core}/setHandlerSchema.d.ts +2 -2
  34. package/dist/{utils → core}/setHandlerSchema.js +1 -4
  35. package/dist/core/toDownloadResponse.d.ts +11 -0
  36. package/dist/core/toDownloadResponse.js +25 -0
  37. package/dist/core/vovkApp.d.ts +36 -0
  38. package/dist/core/vovkApp.js +316 -0
  39. package/dist/index.d.ts +25 -59
  40. package/dist/index.js +23 -23
  41. package/dist/internal.d.ts +17 -0
  42. package/dist/internal.js +10 -0
  43. package/dist/openapi/error.d.ts +2 -0
  44. package/dist/openapi/error.js +97 -0
  45. package/dist/openapi/openAPIToVovkSchema/applyComponentsSchemas.d.ts +3 -0
  46. package/dist/openapi/openAPIToVovkSchema/applyComponentsSchemas.js +65 -0
  47. package/dist/openapi/openAPIToVovkSchema/index.d.ts +5 -0
  48. package/dist/openapi/openAPIToVovkSchema/index.js +153 -0
  49. package/dist/openapi/openAPIToVovkSchema/inlineRefs.d.ts +9 -0
  50. package/dist/openapi/openAPIToVovkSchema/inlineRefs.js +99 -0
  51. package/dist/openapi/operation.d.ts +10 -0
  52. package/dist/openapi/operation.js +19 -0
  53. package/dist/openapi/tool.d.ts +2 -0
  54. package/dist/openapi/tool.js +12 -0
  55. package/dist/openapi/vovkSchemaToOpenAPI.d.ts +21 -0
  56. package/dist/openapi/vovkSchemaToOpenAPI.js +250 -0
  57. package/dist/req/bufferBody.d.ts +1 -0
  58. package/dist/req/bufferBody.js +30 -0
  59. package/dist/req/parseBody.d.ts +4 -0
  60. package/dist/req/parseBody.js +49 -0
  61. package/dist/req/parseForm.d.ts +1 -0
  62. package/dist/req/parseForm.js +24 -0
  63. package/dist/{utils → req}/parseQuery.d.ts +1 -2
  64. package/dist/{utils → req}/parseQuery.js +2 -5
  65. package/dist/req/reqMeta.d.ts +2 -0
  66. package/dist/{utils → req}/reqMeta.js +1 -4
  67. package/dist/req/reqQuery.d.ts +2 -0
  68. package/dist/req/reqQuery.js +4 -0
  69. package/dist/req/validateContentType.d.ts +1 -0
  70. package/dist/req/validateContentType.js +32 -0
  71. package/dist/samples/createCodeSamples.d.ts +20 -0
  72. package/dist/samples/createCodeSamples.js +293 -0
  73. package/dist/samples/objectToCode.d.ts +8 -0
  74. package/dist/samples/objectToCode.js +38 -0
  75. package/dist/samples/schemaToCode.d.ts +11 -0
  76. package/dist/samples/schemaToCode.js +264 -0
  77. package/dist/samples/schemaToObject.d.ts +2 -0
  78. package/dist/samples/schemaToObject.js +164 -0
  79. package/dist/samples/schemaToTsType.d.ts +2 -0
  80. package/dist/samples/schemaToTsType.js +114 -0
  81. package/dist/tools/ToModelOutput.d.ts +8 -0
  82. package/dist/tools/ToModelOutput.js +10 -0
  83. package/dist/tools/createTool.d.ts +126 -0
  84. package/dist/tools/createTool.js +6 -0
  85. package/dist/tools/createToolFactory.d.ts +135 -0
  86. package/dist/tools/createToolFactory.js +61 -0
  87. package/dist/tools/deriveTools.d.ts +46 -0
  88. package/dist/tools/deriveTools.js +134 -0
  89. package/dist/tools/toModelOutputDefault.d.ts +7 -0
  90. package/dist/tools/toModelOutputDefault.js +7 -0
  91. package/dist/tools/toModelOutputMCP.d.ts +30 -0
  92. package/dist/tools/toModelOutputMCP.js +54 -0
  93. package/dist/tsconfig.tsbuildinfo +1 -0
  94. package/dist/types/client.d.ts +140 -0
  95. package/dist/types/client.js +1 -0
  96. package/dist/types/config.d.ts +151 -0
  97. package/dist/types/config.js +1 -0
  98. package/dist/types/core.d.ts +115 -0
  99. package/dist/types/core.js +1 -0
  100. package/dist/types/enums.d.ts +75 -0
  101. package/dist/{types.js → types/enums.js} +21 -9
  102. package/dist/types/inference.d.ts +117 -0
  103. package/dist/types/inference.js +1 -0
  104. package/dist/types/json-schema.d.ts +51 -0
  105. package/dist/types/json-schema.js +1 -0
  106. package/dist/types/operation.d.ts +5 -0
  107. package/dist/types/operation.js +1 -0
  108. package/dist/types/package.d.ts +544 -0
  109. package/dist/types/package.js +5 -0
  110. package/dist/types/request.d.ts +48 -0
  111. package/dist/types/request.js +1 -0
  112. package/dist/types/standard-schema.d.ts +117 -0
  113. package/dist/types/standard-schema.js +6 -0
  114. package/dist/types/tools.d.ts +43 -0
  115. package/dist/types/tools.js +1 -0
  116. package/dist/types/utils.d.ts +9 -0
  117. package/dist/types/utils.js +1 -0
  118. package/dist/types/validation.d.ts +48 -0
  119. package/dist/types/validation.js +1 -0
  120. package/dist/utils/camelCase.d.ts +6 -0
  121. package/dist/utils/camelCase.js +34 -0
  122. package/dist/utils/deepExtend.d.ts +53 -0
  123. package/dist/utils/deepExtend.js +128 -0
  124. package/dist/utils/fileNameToDisposition.d.ts +1 -0
  125. package/dist/utils/fileNameToDisposition.js +3 -0
  126. package/dist/utils/shim.d.ts +1 -0
  127. package/dist/utils/shim.js +1 -1
  128. package/dist/utils/toKebabCase.d.ts +1 -0
  129. package/dist/utils/toKebabCase.js +5 -0
  130. package/dist/utils/trimPath.d.ts +1 -0
  131. package/dist/utils/trimPath.js +1 -0
  132. package/dist/utils/upperFirst.d.ts +1 -0
  133. package/dist/utils/upperFirst.js +3 -0
  134. package/dist/validation/createStandardValidation.d.ts +268 -0
  135. package/dist/validation/createStandardValidation.js +45 -0
  136. package/dist/validation/createValidateOnClient.d.ts +14 -0
  137. package/dist/validation/createValidateOnClient.js +23 -0
  138. package/dist/validation/procedure.d.ts +261 -0
  139. package/dist/validation/procedure.js +8 -0
  140. package/dist/validation/withValidationLibrary.d.ts +119 -0
  141. package/dist/validation/withValidationLibrary.js +174 -0
  142. package/package.json +44 -10
  143. package/dist/HttpException.d.ts +0 -7
  144. package/dist/HttpException.js +0 -15
  145. package/dist/StreamJSONResponse.d.ts +0 -14
  146. package/dist/StreamJSONResponse.js +0 -57
  147. package/dist/VovkApp.d.ts +0 -29
  148. package/dist/VovkApp.js +0 -188
  149. package/dist/client/index.d.ts +0 -3
  150. package/dist/client/index.js +0 -7
  151. package/dist/client/types.d.ts +0 -104
  152. package/dist/client/types.js +0 -2
  153. package/dist/createDecorator.d.ts +0 -6
  154. package/dist/createVovkApp.d.ts +0 -62
  155. package/dist/createVovkApp.js +0 -118
  156. package/dist/types.d.ts +0 -220
  157. package/dist/utils/generateStaticAPI.d.ts +0 -4
  158. package/dist/utils/generateStaticAPI.js +0 -18
  159. package/dist/utils/getSchema.d.ts +0 -20
  160. package/dist/utils/getSchema.js +0 -33
  161. package/dist/utils/reqForm.d.ts +0 -2
  162. package/dist/utils/reqForm.js +0 -13
  163. package/dist/utils/reqMeta.d.ts +0 -2
  164. package/dist/utils/reqQuery.d.ts +0 -2
  165. package/dist/utils/reqQuery.js +0 -10
  166. package/dist/utils/withValidation.d.ts +0 -20
  167. package/dist/utils/withValidation.js +0 -72
@@ -0,0 +1,117 @@
1
+ /** The Standard Typed interface. This is a base type extended by other specs. */
2
+ export interface StandardTypedV1<Input = unknown, Output = Input> {
3
+ /** The Standard properties. */
4
+ readonly '~standard': StandardTypedV1.Props<Input, Output>;
5
+ }
6
+ export declare namespace StandardTypedV1 {
7
+ /** The Standard Typed properties interface. */
8
+ interface Props<Input = unknown, Output = Input> {
9
+ /** The version number of the standard. */
10
+ readonly version: 1;
11
+ /** The vendor name of the schema library. */
12
+ readonly vendor: string;
13
+ /** Inferred types associated with the schema. */
14
+ readonly types?: Types<Input, Output> | undefined;
15
+ }
16
+ /** The Standard Typed types interface. */
17
+ interface Types<Input = unknown, Output = Input> {
18
+ /** The input type of the schema. */
19
+ readonly input: Input;
20
+ /** The output type of the schema. */
21
+ readonly output: Output;
22
+ }
23
+ /** Infers the input type of a Standard Typed. */
24
+ type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema['~standard']['types']>['input'];
25
+ /** Infers the output type of a Standard Typed. */
26
+ type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema['~standard']['types']>['output'];
27
+ }
28
+ /** The Standard Schema interface. */
29
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
30
+ /** The Standard Schema properties. */
31
+ readonly '~standard': StandardSchemaV1.Props<Input, Output>;
32
+ }
33
+ export declare namespace StandardSchemaV1 {
34
+ /** The Standard Schema properties interface. */
35
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
36
+ /** Validates unknown input values. */
37
+ readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
38
+ }
39
+ /** The result interface of the validate function. */
40
+ type Result<Output> = SuccessResult<Output> | FailureResult;
41
+ /** The result interface if validation succeeds. */
42
+ interface SuccessResult<Output> {
43
+ /** The typed output value. */
44
+ readonly value: Output;
45
+ /** A falsy value for `issues` indicates success. */
46
+ readonly issues?: undefined;
47
+ }
48
+ interface Options {
49
+ /** Explicit support for additional vendor-specific parameters, if needed. */
50
+ readonly libraryOptions?: Record<string, unknown> | undefined;
51
+ }
52
+ /** The result interface if validation fails. */
53
+ interface FailureResult {
54
+ /** The issues of failed validation. */
55
+ readonly issues: ReadonlyArray<Issue>;
56
+ }
57
+ /** The issue interface of the failure output. */
58
+ interface Issue {
59
+ /** The error message of the issue. */
60
+ readonly message: string;
61
+ /** The path of the issue, if any. */
62
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
63
+ }
64
+ /** The path segment interface of the issue. */
65
+ interface PathSegment {
66
+ /** The key representing a path segment. */
67
+ readonly key: PropertyKey;
68
+ }
69
+ /** The Standard types interface. */
70
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {
71
+ }
72
+ /** Infers the input type of a Standard. */
73
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
74
+ /** Infers the output type of a Standard. */
75
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
76
+ }
77
+ /** The Standard JSON Schema interface. */
78
+ export interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
79
+ /** The Standard JSON Schema properties. */
80
+ readonly '~standard': StandardJSONSchemaV1.Props<Input, Output>;
81
+ }
82
+ export declare namespace StandardJSONSchemaV1 {
83
+ /** The Standard JSON Schema properties interface. */
84
+ interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
85
+ /** Methods for generating the input/output JSON Schema. */
86
+ readonly jsonSchema: StandardJSONSchemaV1.Converter;
87
+ }
88
+ /** The Standard JSON Schema converter interface. */
89
+ interface Converter {
90
+ /** Converts the input type to JSON Schema. May throw if conversion is not supported. */
91
+ readonly input: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
92
+ /** Converts the output type to JSON Schema. May throw if conversion is not supported. */
93
+ readonly output: (options: StandardJSONSchemaV1.Options) => Record<string, unknown>;
94
+ }
95
+ /**
96
+ * The target version of the generated JSON Schema.
97
+ *
98
+ * It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
99
+ *
100
+ * The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
101
+ */
102
+ type Target = 'draft-2020-12' | 'draft-07' | 'openapi-3.0' | ({} & string);
103
+ /** The options for the input/output methods. */
104
+ interface Options {
105
+ /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
106
+ readonly target: Target;
107
+ /** Explicit support for additional vendor-specific parameters, if needed. */
108
+ readonly libraryOptions?: Record<string, unknown> | undefined;
109
+ }
110
+ /** The Standard types interface. */
111
+ interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {
112
+ }
113
+ /** Infers the input type of a Standard. */
114
+ type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
115
+ /** Infers the output type of a Standard. */
116
+ type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
117
+ }
@@ -0,0 +1,6 @@
1
+ /* eslint-disable @typescript-eslint/no-empty-object-type */
2
+ /* eslint-disable @typescript-eslint/no-namespace */
3
+ // #########################
4
+ // ### Standard Typed ###
5
+ // #########################
6
+ export {};
@@ -0,0 +1,43 @@
1
+ import type { VovkJSONSchemaBase } from './json-schema.js';
2
+ import type { VovkRequest } from './request.js';
3
+ import type { CombinedSpec } from './validation.js';
4
+ import type { KnownAny } from './utils.js';
5
+ export type ToModelOutputFn<TInput, TOutput, TFormattedOutput> = (result: TOutput | Error, tool: VovkTool<TInput, TOutput, unknown>, req: Pick<VovkRequest, 'vovk'> | null) => TFormattedOutput | Promise<TFormattedOutput>;
6
+ interface VovkToolCommon<TInput = unknown, TOutput = unknown, TFormattedOutput = unknown, TIsDerived extends boolean = boolean> {
7
+ execute: (input: TInput, options?: unknown) => TFormattedOutput | Promise<TFormattedOutput>;
8
+ name: string;
9
+ title: string | undefined;
10
+ description: string;
11
+ parameters: {
12
+ type?: 'object';
13
+ properties?: {
14
+ body?: VovkJSONSchemaBase;
15
+ query?: VovkJSONSchemaBase;
16
+ params?: VovkJSONSchemaBase;
17
+ };
18
+ required?: ('body' | 'query' | 'params')[];
19
+ additionalProperties?: false;
20
+ };
21
+ inputSchema: TIsDerived extends true ? undefined : TInput extends undefined ? undefined : CombinedSpec<TInput>;
22
+ outputSchema: TIsDerived extends true ? CombinedSpec | undefined : TOutput extends undefined ? undefined : CombinedSpec<TOutput>;
23
+ inputSchemas: TIsDerived extends true ? {
24
+ body?: CombinedSpec;
25
+ query?: CombinedSpec;
26
+ params?: CombinedSpec;
27
+ } : undefined;
28
+ type: 'function';
29
+ }
30
+ export type VovkToolDerived<TInput, TOutput, TFormattedOutput> = VovkToolCommon<TInput, TOutput, TFormattedOutput, true>;
31
+ export type VovkToolNonDerived<TInput, TOutput, TFormattedOutput> = VovkToolCommon<TInput, TOutput, TFormattedOutput, false>;
32
+ /**
33
+ * Vovk tool type, which can be either derived or non-derived.
34
+ * @see https://vovk.dev/tools
35
+ */
36
+ export type VovkTool<TInput = KnownAny, TOutput = KnownAny, TFormattedOutput = KnownAny> = VovkToolDerived<TInput, TOutput, TFormattedOutput> | VovkToolNonDerived<TInput, TOutput, TFormattedOutput>;
37
+ export type VovkToolOptions = {
38
+ hidden?: boolean;
39
+ name?: string;
40
+ title?: string;
41
+ description?: string;
42
+ };
43
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ export type RequireFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
2
+ export type IsEmptyObject<T> = T extends object ? keyof T extends never ? true : T extends Partial<T> ? Partial<T> extends T ? true : false : false : false;
3
+ export type Prettify<T> = {
4
+ [K in keyof T]: T[K];
5
+ } & {};
6
+ export type KnownAny = any;
7
+ export type StaticClass = Function;
8
+ export type IsAny<T> = 0 extends 1 & T ? true : false;
9
+ export type IsNotAny<T> = IsAny<T> extends true ? false : true;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ import type { StandardSchemaV1, StandardJSONSchemaV1 } from './standard-schema.js';
2
+ import type { KnownAny } from './utils.js';
3
+ import type { VovkHandlerSchema, VovkSchema } from './core.js';
4
+ import type { textTypes } from '../req/parseBody.js';
5
+ export interface CombinedProps<Input = unknown, Output = Input> extends StandardSchemaV1.Props<Input, Output>, StandardJSONSchemaV1.Props<Input, Output> {
6
+ }
7
+ /**
8
+ * An interface that combines StandardJSONSchema and StandardSchema.
9
+ * */
10
+ export interface CombinedSpec<Input = unknown, Output = Input> {
11
+ '~standard': CombinedProps<Input, Output>;
12
+ }
13
+ export declare namespace CombinedSpec {
14
+ type Target = StandardJSONSchemaV1.Target;
15
+ type InferInput<T extends StandardSchemaV1> = StandardSchemaV1.InferInput<T>;
16
+ type InferOutput<T extends StandardSchemaV1> = StandardSchemaV1.InferOutput<T>;
17
+ type SuccessResult<T> = StandardSchemaV1.SuccessResult<T>;
18
+ }
19
+ /** Application MIME types that are parsed as text (derived from parseBody.ts textTypes). */
20
+ type TextLikeApplicationType = (typeof textTypes)[number];
21
+ export type ContentType = 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded' | 'text/plain' | 'application/octet-stream' | TextLikeApplicationType | `text/${string}` | `application/${string}` | `${string}+json` | `${string}+xml` | `${string}+text` | `${string}+yaml` | `${string}+json-seq` | '*/*' | (string & {});
22
+ export type NormalizeContentType<T extends ContentType | ContentType[]> = T extends ContentType[] ? T : [T & ContentType];
23
+ export type BodyTypeFromContentType<T extends ContentType[], TBody> = T[number] extends infer A ? A extends '*/*' ? TBody | URLSearchParams | FormData | ArrayBuffer | Uint8Array | Blob : A extends 'application/json' | `${string}+json` ? TBody | Blob : A extends 'multipart/form-data' ? TBody | FormData | Blob : A extends 'application/x-www-form-urlencoded' ? TBody | URLSearchParams | FormData | Blob : A extends `text/${string}` | TextLikeApplicationType | `${string}+xml` | `${string}+text` | `${string}+yaml` | `${string}+json-seq` ? string | Blob : ArrayBuffer | Uint8Array | Blob : never;
24
+ export type VovkTypedProcedure<T extends (...args: KnownAny[]) => unknown, B = unknown, Q = unknown, P = unknown, O = unknown, I = unknown, TContentType extends ContentType | ContentType[] = ['application/json']> = T & {
25
+ __types: {
26
+ body: B;
27
+ query: Q;
28
+ params: P;
29
+ output: O;
30
+ iteration: I;
31
+ contentType: NormalizeContentType<TContentType>;
32
+ };
33
+ isRPC?: boolean;
34
+ };
35
+ /**
36
+ * Client-side validation function type.
37
+ * @see https://vovk.dev/imports
38
+ */
39
+ export type VovkValidateOnClient<TFetcherOptions> = (input: {
40
+ body?: unknown;
41
+ query?: unknown;
42
+ params?: unknown;
43
+ meta?: unknown;
44
+ } & TFetcherOptions, validation: Omit<Exclude<VovkHandlerSchema['validation'], undefined>, 'output' | 'iteration'>, meta: {
45
+ fullSchema: VovkSchema;
46
+ endpoint: string;
47
+ }) => KnownAny | Promise<KnownAny>;
48
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Converts string to camel case.
3
+ * @param {*} input - The value to convert to camel case.
4
+ * @returns {string}
5
+ */
6
+ export declare function camelCase(input: string): string;
@@ -0,0 +1,34 @@
1
+ // Convert any value to string
2
+ function toString(value) {
3
+ return value == null ? '' : String(value);
4
+ }
5
+ // Regex to match words (including Unicode letters & digits)
6
+ const reUnicodeWord = /[\p{Lu}]{2,}(?=[\p{Lu}][\p{Ll}]+[0-9]*|\b)|[\p{Lu}]?[\p{Ll}]+[0-9]*|[\p{Lu}]|[0-9]+/gu;
7
+ /**
8
+ * Splits string into an array of words based on Unicode word boundaries
9
+ * @param {string} str
10
+ * @returns {string[]}
11
+ */
12
+ function unicodeWords(str) {
13
+ return str.match(reUnicodeWord) || [];
14
+ }
15
+ /**
16
+ * Converts string to camel case.
17
+ * @param {*} input - The value to convert to camel case.
18
+ * @returns {string}
19
+ */
20
+ export function camelCase(input) {
21
+ const str = toString(input);
22
+ // replace separators with space
23
+ const sanitized = str.replace(/[\s_-]+/g, ' ').trim();
24
+ const words = unicodeWords(sanitized);
25
+ return words
26
+ .map((word, index) => {
27
+ const lower = word.toLowerCase();
28
+ if (index === 0) {
29
+ return lower;
30
+ }
31
+ return lower.charAt(0).toUpperCase() + lower.slice(1);
32
+ })
33
+ .join('');
34
+ }
@@ -0,0 +1,53 @@
1
+ /*!
2
+ * @description Recursive object extending
3
+ * @author Viacheslav Lotsmanov <lotsmanov89@gmail.com>
4
+ * @license MIT
5
+ *
6
+ * The MIT License (MIT)
7
+ *
8
+ * Copyright (c) 2013-2018 Viacheslav Lotsmanov
9
+ *
10
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
11
+ * this software and associated documentation files (the "Software"), to deal in
12
+ * the Software without restriction, including without limitation the rights to
13
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14
+ * the Software, and to permit persons to whom the Software is furnished to do so,
15
+ * subject to the following conditions:
16
+ *
17
+ * The above copyright notice and this permission notice shall be included in all
18
+ * copies or substantial portions of the Software.
19
+ *
20
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+ type DeepPartial<T> = {
28
+ [P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends object ? DeepPartial<T[P]> : T[P];
29
+ };
30
+ type SpecificValue = Buffer | Date | RegExp;
31
+ declare function isSpecificValue(val: any): val is SpecificValue;
32
+ declare function cloneSpecificValue(val: SpecificValue): SpecificValue;
33
+ /**
34
+ * Recursive cloning array.
35
+ */
36
+ declare function deepCloneArray<T = any>(arr: T[]): T[];
37
+ declare function safeGetProperty<T extends object>(object: T, property: PropertyKey): any;
38
+ /**
39
+ * Extending object that entered in first argument.
40
+ *
41
+ * Returns extended object or false if have no target object or incorrect type.
42
+ *
43
+ * If you wish to clone source object (without modify it), just use empty new
44
+ * object as first argument, like this:
45
+ * deepExtend({}, yourObj_1, [yourObj_N]);
46
+ */
47
+ declare function deepExtend<T extends object>(...args: [T, ...Partial<T>[]]): T;
48
+ declare function deepExtend<T extends object, U extends object>(target: T, source: U): T & U;
49
+ declare function deepExtend<T extends object, U extends object, V extends object>(target: T, source1: U, source2: V): T & U & V;
50
+ declare function deepExtend<T extends object, U extends object, V extends object, W extends object>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
51
+ declare function deepExtend<T extends object>(target: T, ...sources: any[]): T;
52
+ export { deepExtend, deepCloneArray, isSpecificValue, cloneSpecificValue, safeGetProperty };
53
+ export type { DeepPartial, SpecificValue };
@@ -0,0 +1,128 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /*!
3
+ * @description Recursive object extending
4
+ * @author Viacheslav Lotsmanov <lotsmanov89@gmail.com>
5
+ * @license MIT
6
+ *
7
+ * The MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2013-2018 Viacheslav Lotsmanov
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
12
+ * this software and associated documentation files (the "Software"), to deal in
13
+ * the Software without restriction, including without limitation the rights to
14
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
15
+ * the Software, and to permit persons to whom the Software is furnished to do so,
16
+ * 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
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
23
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
24
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
25
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ */
28
+ 'use strict';
29
+ function isSpecificValue(val) {
30
+ return val instanceof Buffer || val instanceof Date || val instanceof RegExp;
31
+ }
32
+ function cloneSpecificValue(val) {
33
+ if (val instanceof Buffer) {
34
+ const x = Buffer.alloc ? Buffer.alloc(val.length) : Buffer.from(val);
35
+ val.copy(x);
36
+ return x;
37
+ }
38
+ else if (val instanceof Date) {
39
+ return new Date(val.getTime());
40
+ }
41
+ else if (val instanceof RegExp) {
42
+ return new RegExp(val);
43
+ }
44
+ else {
45
+ throw new Error('Unexpected situation');
46
+ }
47
+ }
48
+ /**
49
+ * Recursive cloning array.
50
+ */
51
+ function deepCloneArray(arr) {
52
+ const clone = [];
53
+ arr.forEach((item, index) => {
54
+ if (typeof item === 'object' && item !== null) {
55
+ if (Array.isArray(item)) {
56
+ clone[index] = deepCloneArray(item);
57
+ }
58
+ else if (isSpecificValue(item)) {
59
+ clone[index] = cloneSpecificValue(item);
60
+ }
61
+ else {
62
+ clone[index] = deepExtend({}, item);
63
+ }
64
+ }
65
+ else {
66
+ clone[index] = item;
67
+ }
68
+ });
69
+ return clone;
70
+ }
71
+ function safeGetProperty(object, property) {
72
+ return property === '__proto__' ? undefined : object[property];
73
+ }
74
+ function deepExtend(...args) {
75
+ if (args.length < 1 || typeof args[0] !== 'object') {
76
+ return false;
77
+ }
78
+ if (args.length < 2) {
79
+ return args[0];
80
+ }
81
+ const target = args[0];
82
+ // convert arguments to array and cut off target object
83
+ const sources = args.slice(1);
84
+ sources.forEach((obj) => {
85
+ // skip argument if isn't an object, is null, or is an array
86
+ if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
87
+ return;
88
+ }
89
+ Object.keys(obj).forEach((key) => {
90
+ const src = safeGetProperty(target, key); // source value
91
+ const val = safeGetProperty(obj, key); // new value
92
+ // recursion prevention
93
+ if (val === target) {
94
+ return;
95
+ }
96
+ else if (typeof val !== 'object' || val === null) {
97
+ /**
98
+ * if new value isn't object then just overwrite by new value
99
+ * instead of extending.
100
+ */
101
+ target[key] = val;
102
+ return;
103
+ }
104
+ // just clone arrays (and recursive clone objects inside)
105
+ else if (Array.isArray(val)) {
106
+ target[key] = deepCloneArray(val);
107
+ return;
108
+ }
109
+ // custom cloning and overwrite for specific objects
110
+ else if (isSpecificValue(val)) {
111
+ target[key] = cloneSpecificValue(val);
112
+ return;
113
+ }
114
+ // overwrite by new value if source isn't object or array
115
+ else if (typeof src !== 'object' || src === null || Array.isArray(src)) {
116
+ target[key] = deepExtend({}, val);
117
+ return;
118
+ }
119
+ // source value and new value is objects both, extending...
120
+ else {
121
+ target[key] = deepExtend(src, val);
122
+ return;
123
+ }
124
+ });
125
+ });
126
+ return target;
127
+ }
128
+ export { deepExtend, deepCloneArray, isSpecificValue, cloneSpecificValue, safeGetProperty };
@@ -0,0 +1 @@
1
+ export declare function fileNameToDisposition(filename: string): string;
@@ -0,0 +1,3 @@
1
+ export function fileNameToDisposition(filename) {
2
+ return `attachment; filename="${filename.replace(/[^\x20-\x7E]|"/g, '_')}"; filename*=UTF-8''${encodeURIComponent(filename)}`;
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  if (typeof Symbol.dispose !== 'symbol') {
3
2
  Object.defineProperty(Symbol, 'dispose', {
4
3
  configurable: false,
@@ -15,3 +14,4 @@ if (typeof Symbol.asyncDispose !== 'symbol') {
15
14
  value: Symbol.for('asyncDispose'),
16
15
  });
17
16
  }
17
+ export {};
@@ -0,0 +1 @@
1
+ export declare const toKebabCase: (str: string) => string;
@@ -0,0 +1,5 @@
1
+ export const toKebabCase = (str) => str
2
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2') // Add hyphen between lowercase/digit and uppercase
3
+ .replace(/([A-Z])([A-Z])(?=[a-z])/g, '$1-$2') // Add hyphen between uppercase letters if the second one is followed by a lowercase
4
+ .toLowerCase()
5
+ .replace(/^-/, ''); // Remove leading hyphen
@@ -0,0 +1 @@
1
+ export declare const trimPath: (path: string) => string;
@@ -0,0 +1 @@
1
+ export const trimPath = (path) => path.trim().replace(/^\/|\/$/g, '');
@@ -0,0 +1 @@
1
+ export declare function upperFirst(str: string): string;
@@ -0,0 +1,3 @@
1
+ export function upperFirst(str) {
2
+ return str.charAt(0).toUpperCase() + str.slice(1);
3
+ }