@decohere/core 0.0.1-dev.116

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 (262) hide show
  1. package/commonjs/src/caching/cache-manager.js +98 -0
  2. package/commonjs/src/caching/cache.decorator.js +69 -0
  3. package/commonjs/src/caching/cache.js +6 -0
  4. package/commonjs/src/caching/index.js +23 -0
  5. package/commonjs/src/caching/invalidate-cache.decorator.js +92 -0
  6. package/commonjs/src/caching/memoize.decorator.js +36 -0
  7. package/commonjs/src/caching/node-cache-memoize.adapter.js +49 -0
  8. package/commonjs/src/cli/action.js +65 -0
  9. package/commonjs/src/cli/command.js +127 -0
  10. package/commonjs/src/cli/index.js +61 -0
  11. package/commonjs/src/cli/module.type.js +18 -0
  12. package/commonjs/src/cli/options.js +115 -0
  13. package/commonjs/src/collections/collections.js +21 -0
  14. package/commonjs/src/collections/find-duplicates.js +35 -0
  15. package/commonjs/src/collections/index.js +52 -0
  16. package/commonjs/src/collections/merge-arrays.js +34 -0
  17. package/commonjs/src/collections/sum.js +63 -0
  18. package/commonjs/src/collections/unique-objects.js +39 -0
  19. package/commonjs/src/composition/index.js +4 -0
  20. package/commonjs/src/configuration/configuration.types.js +11 -0
  21. package/commonjs/src/configuration/index.js +18 -0
  22. package/commonjs/src/diagnostics/index.js +22 -0
  23. package/commonjs/src/diagnostics/trace.js +86 -0
  24. package/commonjs/src/extensibility/decorator-factory-base.js +22 -0
  25. package/commonjs/src/extensibility/decorator-factory.js +31 -0
  26. package/commonjs/src/extensibility/extension.js +37 -0
  27. package/commonjs/src/extensibility/index.js +23 -0
  28. package/commonjs/src/extensibility/mixwith.js +36 -0
  29. package/commonjs/src/extensibility/pipeline.js +56 -0
  30. package/commonjs/src/extensibility/step.js +18 -0
  31. package/commonjs/src/interop/docker/docker.js +54 -0
  32. package/commonjs/src/interop/errors/interop.error.js +12 -0
  33. package/commonjs/src/interop/git/git.js +134 -0
  34. package/commonjs/src/interop/git/git.types.js +4 -0
  35. package/commonjs/src/interop/index.js +97 -0
  36. package/commonjs/src/interop/node/index.js +18 -0
  37. package/commonjs/src/interop/node/node.js +45 -0
  38. package/commonjs/src/interop/npm/npm.js +231 -0
  39. package/commonjs/src/interop/npm/npm.types.js +16 -0
  40. package/commonjs/src/interop/pnpm/pnpm.js +34 -0
  41. package/commonjs/src/interop/pnpm/pnpm.types.js +4 -0
  42. package/commonjs/src/interop/shell/shell.argv.js +45 -0
  43. package/commonjs/src/interop/shell/shell.js +105 -0
  44. package/commonjs/src/interop/shell/shell.types.js +4 -0
  45. package/commonjs/src/interop/types/detect-package-manager.js +71 -0
  46. package/commonjs/src/interop/types/package-manager.js +4 -0
  47. package/commonjs/src/interop/yarn/yarn.js +34 -0
  48. package/commonjs/src/interop/yarn/yarn.types.js +4 -0
  49. package/commonjs/src/io/copy-file.js +25 -0
  50. package/commonjs/src/io/delete-file.js +21 -0
  51. package/commonjs/src/io/directory-exists.js +24 -0
  52. package/commonjs/src/io/file-exists.js +19 -0
  53. package/commonjs/src/io/find-directories.js +21 -0
  54. package/commonjs/src/io/find-file.js +45 -0
  55. package/commonjs/src/io/index.js +66 -0
  56. package/commonjs/src/io/io.js +28 -0
  57. package/commonjs/src/io/read-file.js +39 -0
  58. package/commonjs/src/io/remove-dir.js +22 -0
  59. package/commonjs/src/io/types/directory.type.js +4 -0
  60. package/commonjs/src/io/types/file.js +28 -0
  61. package/commonjs/src/io/types/index.js +19 -0
  62. package/commonjs/src/io/url-to-path.js +33 -0
  63. package/commonjs/src/io/watch.js +261 -0
  64. package/commonjs/src/io/write-file.js +30 -0
  65. package/commonjs/src/objects/deep-merge.js +67 -0
  66. package/commonjs/src/objects/index.js +11 -0
  67. package/commonjs/src/reflection/index.js +20 -0
  68. package/commonjs/src/reflection/types/index.js +18 -0
  69. package/commonjs/src/reflection/types/reflection.types.js +26 -0
  70. package/commonjs/src/reflection/utilities.js +118 -0
  71. package/commonjs/src/semver/index.js +18 -0
  72. package/commonjs/src/semver/semver.js +92 -0
  73. package/commonjs/src/system/camel-case.js +13 -0
  74. package/commonjs/src/system/debounce.js +19 -0
  75. package/commonjs/src/system/decorator.js +46 -0
  76. package/commonjs/src/system/environment.js +23 -0
  77. package/commonjs/src/system/function.types.js +18 -0
  78. package/commonjs/src/system/index.js +24 -0
  79. package/commonjs/src/system/retry.decorator.js +40 -0
  80. package/commonjs/src/system/sleep.js +13 -0
  81. package/commonjs/src/system/type.utils.js +4 -0
  82. package/commonjs/src/testing/flush-promises.js +16 -0
  83. package/commonjs/src/testing/glob-with-memfs.js +22 -0
  84. package/commonjs/src/testing/index.js +22 -0
  85. package/commonjs/src/testing/memfs.js +52 -0
  86. package/commonjs/src/testing/mock-logger.js +36 -0
  87. package/commonjs/src/testing/spy-on-constructor.js +27 -0
  88. package/es6/src/caching/cache-manager.js +82 -0
  89. package/es6/src/caching/cache.decorator.js +51 -0
  90. package/es6/src/caching/cache.js +3 -0
  91. package/es6/src/caching/index.js +6 -0
  92. package/es6/src/caching/invalidate-cache.decorator.js +71 -0
  93. package/es6/src/caching/memoize.decorator.js +27 -0
  94. package/es6/src/caching/node-cache-memoize.adapter.js +37 -0
  95. package/es6/src/cli/action.js +47 -0
  96. package/es6/src/cli/command.js +106 -0
  97. package/es6/src/cli/index.js +4 -0
  98. package/es6/src/cli/module.type.js +11 -0
  99. package/es6/src/cli/options.js +76 -0
  100. package/es6/src/collections/collections.js +4 -0
  101. package/es6/src/collections/find-duplicates.js +17 -0
  102. package/es6/src/collections/index.js +1 -0
  103. package/es6/src/collections/merge-arrays.js +16 -0
  104. package/es6/src/collections/sum.js +45 -0
  105. package/es6/src/collections/unique-objects.js +21 -0
  106. package/es6/src/composition/index.js +1 -0
  107. package/es6/src/configuration/configuration.types.js +1 -0
  108. package/es6/src/configuration/index.js +1 -0
  109. package/es6/src/diagnostics/index.js +1 -0
  110. package/es6/src/diagnostics/trace.js +68 -0
  111. package/es6/src/extensibility/decorator-factory-base.js +39 -0
  112. package/es6/src/extensibility/decorator-factory.js +21 -0
  113. package/es6/src/extensibility/extension.js +27 -0
  114. package/es6/src/extensibility/index.js +6 -0
  115. package/es6/src/extensibility/mixwith.js +26 -0
  116. package/es6/src/extensibility/pipeline.js +46 -0
  117. package/es6/src/extensibility/step.js +16 -0
  118. package/es6/src/interop/docker/docker.js +44 -0
  119. package/es6/src/interop/errors/interop.error.js +2 -0
  120. package/es6/src/interop/git/git.js +124 -0
  121. package/es6/src/interop/git/git.types.js +1 -0
  122. package/es6/src/interop/index.js +21 -0
  123. package/es6/src/interop/node/index.js +1 -0
  124. package/es6/src/interop/node/node.js +35 -0
  125. package/es6/src/interop/npm/npm.js +180 -0
  126. package/es6/src/interop/npm/npm.types.js +6 -0
  127. package/es6/src/interop/pnpm/pnpm.js +24 -0
  128. package/es6/src/interop/pnpm/pnpm.types.js +1 -0
  129. package/es6/src/interop/shell/shell.argv.js +35 -0
  130. package/es6/src/interop/shell/shell.js +95 -0
  131. package/es6/src/interop/shell/shell.types.js +1 -0
  132. package/es6/src/interop/types/detect-package-manager.js +50 -0
  133. package/es6/src/interop/types/package-manager.js +1 -0
  134. package/es6/src/interop/yarn/yarn.js +24 -0
  135. package/es6/src/interop/yarn/yarn.types.js +1 -0
  136. package/es6/src/io/copy-file.js +10 -0
  137. package/es6/src/io/delete-file.js +6 -0
  138. package/es6/src/io/directory-exists.js +9 -0
  139. package/es6/src/io/file-exists.js +9 -0
  140. package/es6/src/io/find-directories.js +11 -0
  141. package/es6/src/io/find-file.js +27 -0
  142. package/es6/src/io/index.js +2 -0
  143. package/es6/src/io/io.js +11 -0
  144. package/es6/src/io/read-file.js +13 -0
  145. package/es6/src/io/remove-dir.js +7 -0
  146. package/es6/src/io/types/directory.type.js +1 -0
  147. package/es6/src/io/types/file.js +18 -0
  148. package/es6/src/io/types/index.js +2 -0
  149. package/es6/src/io/url-to-path.js +15 -0
  150. package/es6/src/io/watch.js +238 -0
  151. package/es6/src/io/write-file.js +15 -0
  152. package/es6/src/objects/deep-merge.js +57 -0
  153. package/es6/src/objects/index.js +1 -0
  154. package/es6/src/reflection/index.js +3 -0
  155. package/es6/src/reflection/types/index.js +1 -0
  156. package/es6/src/reflection/types/reflection.types.js +8 -0
  157. package/es6/src/reflection/utilities.js +74 -0
  158. package/es6/src/semver/index.js +1 -0
  159. package/es6/src/semver/semver.js +71 -0
  160. package/es6/src/system/camel-case.js +3 -0
  161. package/es6/src/system/debounce.js +9 -0
  162. package/es6/src/system/decorator.js +30 -0
  163. package/es6/src/system/environment.js +5 -0
  164. package/es6/src/system/function.types.js +26 -0
  165. package/es6/src/system/index.js +7 -0
  166. package/es6/src/system/retry.decorator.js +30 -0
  167. package/es6/src/system/sleep.js +3 -0
  168. package/es6/src/system/type.utils.js +1 -0
  169. package/es6/src/testing/flush-promises.js +6 -0
  170. package/es6/src/testing/glob-with-memfs.js +20 -0
  171. package/es6/src/testing/index.js +5 -0
  172. package/es6/src/testing/memfs.js +25 -0
  173. package/es6/src/testing/mock-logger.js +26 -0
  174. package/es6/src/testing/spy-on-constructor.js +31 -0
  175. package/package.json +106 -0
  176. package/types/src/caching/cache-manager.d.ts +59 -0
  177. package/types/src/caching/cache.d.ts +11 -0
  178. package/types/src/caching/cache.decorator.d.ts +18 -0
  179. package/types/src/caching/index.d.ts +6 -0
  180. package/types/src/caching/invalidate-cache.decorator.d.ts +17 -0
  181. package/types/src/caching/memoize.decorator.d.ts +16 -0
  182. package/types/src/caching/node-cache-memoize.adapter.d.ts +22 -0
  183. package/types/src/cli/action.d.ts +36 -0
  184. package/types/src/cli/command.d.ts +34 -0
  185. package/types/src/cli/index.d.ts +7 -0
  186. package/types/src/cli/module.type.d.ts +36 -0
  187. package/types/src/cli/options.d.ts +28 -0
  188. package/types/src/collections/collections.d.ts +4 -0
  189. package/types/src/collections/find-duplicates.d.ts +2 -0
  190. package/types/src/collections/index.d.ts +1 -0
  191. package/types/src/collections/merge-arrays.d.ts +2 -0
  192. package/types/src/collections/sum.d.ts +4 -0
  193. package/types/src/collections/unique-objects.d.ts +2 -0
  194. package/types/src/composition/index.d.ts +37 -0
  195. package/types/src/configuration/configuration.types.d.ts +10 -0
  196. package/types/src/configuration/index.d.ts +1 -0
  197. package/types/src/diagnostics/index.d.ts +1 -0
  198. package/types/src/diagnostics/trace.d.ts +10 -0
  199. package/types/src/extensibility/decorator-factory-base.d.ts +39 -0
  200. package/types/src/extensibility/decorator-factory.d.ts +19 -0
  201. package/types/src/extensibility/extension.d.ts +9 -0
  202. package/types/src/extensibility/index.d.ts +6 -0
  203. package/types/src/extensibility/mixwith.d.ts +6 -0
  204. package/types/src/extensibility/pipeline.d.ts +12 -0
  205. package/types/src/extensibility/step.d.ts +16 -0
  206. package/types/src/interop/docker/docker.d.ts +19 -0
  207. package/types/src/interop/errors/interop.error.d.ts +2 -0
  208. package/types/src/interop/git/git.d.ts +16 -0
  209. package/types/src/interop/git/git.types.d.ts +14 -0
  210. package/types/src/interop/index.d.ts +14 -0
  211. package/types/src/interop/node/index.d.ts +1 -0
  212. package/types/src/interop/node/node.d.ts +5 -0
  213. package/types/src/interop/npm/npm.d.ts +29 -0
  214. package/types/src/interop/npm/npm.types.d.ts +24 -0
  215. package/types/src/interop/pnpm/pnpm.d.ts +9 -0
  216. package/types/src/interop/pnpm/pnpm.types.d.ts +3 -0
  217. package/types/src/interop/shell/shell.argv.d.ts +5 -0
  218. package/types/src/interop/shell/shell.d.ts +6 -0
  219. package/types/src/interop/shell/shell.types.d.ts +9 -0
  220. package/types/src/interop/types/detect-package-manager.d.ts +4 -0
  221. package/types/src/interop/types/package-manager.d.ts +10 -0
  222. package/types/src/interop/yarn/yarn.d.ts +9 -0
  223. package/types/src/interop/yarn/yarn.types.d.ts +3 -0
  224. package/types/src/io/copy-file.d.ts +4 -0
  225. package/types/src/io/delete-file.d.ts +1 -0
  226. package/types/src/io/directory-exists.d.ts +1 -0
  227. package/types/src/io/file-exists.d.ts +1 -0
  228. package/types/src/io/find-directories.d.ts +2 -0
  229. package/types/src/io/find-file.d.ts +9 -0
  230. package/types/src/io/index.d.ts +2 -0
  231. package/types/src/io/io.d.ts +11 -0
  232. package/types/src/io/read-file.d.ts +4 -0
  233. package/types/src/io/remove-dir.d.ts +5 -0
  234. package/types/src/io/types/directory.type.d.ts +4 -0
  235. package/types/src/io/types/file.d.ts +20 -0
  236. package/types/src/io/types/index.d.ts +2 -0
  237. package/types/src/io/url-to-path.d.ts +2 -0
  238. package/types/src/io/watch.d.ts +16 -0
  239. package/types/src/io/write-file.d.ts +5 -0
  240. package/types/src/objects/deep-merge.d.ts +41 -0
  241. package/types/src/objects/index.d.ts +1 -0
  242. package/types/src/reflection/index.d.ts +3 -0
  243. package/types/src/reflection/types/index.d.ts +1 -0
  244. package/types/src/reflection/types/reflection.types.d.ts +21 -0
  245. package/types/src/reflection/utilities.d.ts +27 -0
  246. package/types/src/semver/index.d.ts +1 -0
  247. package/types/src/semver/semver.d.ts +18 -0
  248. package/types/src/system/camel-case.d.ts +1 -0
  249. package/types/src/system/debounce.d.ts +1 -0
  250. package/types/src/system/decorator.d.ts +15 -0
  251. package/types/src/system/environment.d.ts +6 -0
  252. package/types/src/system/function.types.d.ts +55 -0
  253. package/types/src/system/index.d.ts +7 -0
  254. package/types/src/system/retry.decorator.d.ts +6 -0
  255. package/types/src/system/sleep.d.ts +1 -0
  256. package/types/src/system/type.utils.d.ts +1 -0
  257. package/types/src/testing/flush-promises.d.ts +1 -0
  258. package/types/src/testing/glob-with-memfs.d.ts +3 -0
  259. package/types/src/testing/index.d.ts +5 -0
  260. package/types/src/testing/memfs.d.ts +5 -0
  261. package/types/src/testing/mock-logger.d.ts +13 -0
  262. package/types/src/testing/spy-on-constructor.d.ts +21 -0
@@ -0,0 +1,41 @@
1
+ type TAllKeys<T> = T extends unknown ? keyof T : never;
2
+ type TIndexValue<T, K extends PropertyKey, D = never> = T extends unknown ? K extends keyof T ? T[K] : D : never;
3
+ type TPartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>> extends infer O ? {
4
+ [P in keyof O]: O[P];
5
+ } : never;
6
+ type TFunction = (...a: unknown[]) => unknown;
7
+ type TPrimitives = string | number | boolean | bigint | symbol | Date | TFunction;
8
+ type TMerged<T> = [T] extends [Array<unknown>] ? {
9
+ [K in keyof T]: TMerged<T[K]>;
10
+ } : [T] extends [TPrimitives] ? T : [T] extends [object] ? TPartialKeys<{
11
+ [K in TAllKeys<T>]: TMerged<TIndexValue<T, K>>;
12
+ }, never> : T;
13
+ export declare const merge: {
14
+ <T extends object[]>(...objects: T): TMerged<T[number]>;
15
+ options: IOptions;
16
+ withOptions<R = unknown, T extends object[] = object[]>(options: Partial<IOptions>, ...objects: T): R;
17
+ };
18
+ interface IOptions {
19
+ /**
20
+ * When `true`, values explicitly provided as `undefined` will override existing values, though properties that are simply omitted won't affect anything.
21
+ * When `false`, values explicitly provided as `undefined` won't override existing values.
22
+ *
23
+ * Default: `true`
24
+ */
25
+ allowUndefinedOverrides: boolean;
26
+ /**
27
+ * When `true` it will merge array properties.
28
+ * When `false` it will replace array properties with the last instance entirely instead of merging their contents.
29
+ *
30
+ * Default: `true`
31
+ */
32
+ mergeArrays: boolean;
33
+ /**
34
+ * When `true` it will ensure there are no duplicate array items.
35
+ * When `false` it will allow duplicates when merging arrays.
36
+ *
37
+ * Default: `true`
38
+ */
39
+ uniqueArrayItems: boolean;
40
+ }
41
+ export {};
@@ -0,0 +1 @@
1
+ export { merge } from "./deep-merge.js";
@@ -0,0 +1,3 @@
1
+ import "reflect-metadata";
2
+ export * from "./types/index.js";
3
+ export * from "./utilities.js";
@@ -0,0 +1 @@
1
+ export * from "./reflection.types.js";
@@ -0,0 +1,21 @@
1
+ export type Constructable<T extends object = object> = {
2
+ new (...args: any[]): T;
3
+ } & Type;
4
+ export type Field = {
5
+ key: string;
6
+ propertyDescriptor: PropertyDescriptor;
7
+ };
8
+ export type FunctionType = (...args: unknown[]) => unknown | unknown[] | undefined | Promise<unknown>;
9
+ export type ReflectMeta = "paramtypes" | "type";
10
+ export declare const MetaDataOwners: {
11
+ Hearth: string;
12
+ Reflect: string;
13
+ };
14
+ export declare const ReflectionMeta: {
15
+ paramtypes: string;
16
+ type: string;
17
+ };
18
+ export type Type = {
19
+ prototype: object;
20
+ name?: string;
21
+ };
@@ -0,0 +1,27 @@
1
+ import { type Constructable, type Field, type FunctionType, type Type } from "./types/reflection.types.js";
2
+ export declare const isPrimitiveOrDateType: (type: Type) => boolean;
3
+ export declare const isDateType: (type: Type) => boolean;
4
+ export declare function isConstructable(type: Constructable | object | FunctionType): type is Constructable;
5
+ export declare const isArrayType: (type: Type) => boolean;
6
+ export declare function getMeta<T>(key: string, target: object, propertyKey?: string): T;
7
+ export declare function getFunctions(object: Constructable): PropertyDescriptor[];
8
+ export declare function getFunction(object: Constructable, functionName: string): PropertyDescriptor;
9
+ export declare function getFunctionMetadata<T>(key: string, target: object, func: FunctionType): T;
10
+ export declare function getFunctionArgs(target: object, func: FunctionType): Type[];
11
+ /**
12
+ * @description Gets the fields from an object
13
+ * @param object
14
+ * @returns
15
+ */
16
+ export declare function getFields<T>(object: T): Field[];
17
+ export declare function getFieldType(target: object, fieldName: string): Type;
18
+ export declare function getArgumentMeta<T>(key: string, target: FunctionType, argIndex: number): T;
19
+ export declare function defineMeta<T>(key: string, value: T, target: object): void;
20
+ /**
21
+ * @description Facade function to define metadata for a function argument
22
+ * @param key
23
+ * @param value
24
+ * @param func
25
+ * @param argIndex
26
+ */
27
+ export declare function defineArgumentMeta<T>(key: string, value: T, func: FunctionType, argIndex: number): void;
@@ -0,0 +1 @@
1
+ export * from "./semver.js";
@@ -0,0 +1,18 @@
1
+ export type VersionType = "major" | "minor" | "patch" | "prerelease";
2
+ export declare const VersionTypes: {
3
+ major: "major";
4
+ minor: "minor";
5
+ patch: "patch";
6
+ prerelease: "prerelease";
7
+ };
8
+ export declare class SemverError extends Error {
9
+ constructor(message: string);
10
+ }
11
+ export declare class Semver {
12
+ private version;
13
+ constructor(version: string);
14
+ increment(versionType: VersionType, preid?: string): Semver;
15
+ toString(): string;
16
+ private ensureValid;
17
+ private parse;
18
+ }
@@ -0,0 +1 @@
1
+ export declare function lowerCamelCase(val: any): string;
@@ -0,0 +1 @@
1
+ export declare function debounce<T extends unknown[]>(callback: (...args: T) => Promise<void>, delay: number): (...args: T) => void;
@@ -0,0 +1,15 @@
1
+ export declare abstract class FunctionDecorator<TOptions = undefined> {
2
+ protected options: TOptions;
3
+ constructor();
4
+ abstract decorator(target: object, propertyKey: string, descriptor: PropertyDescriptor): any;
5
+ decoratorFactory(options?: TOptions): any;
6
+ }
7
+ /**
8
+ * Skips the decorated method decorator if any of the named environment variables equal "true".
9
+ * Useful for disabling decorators like @cache() during unit tests or via feature flags.
10
+ *
11
+ * @example @ignoreIf("TEST", "DISABLE_CACHE")
12
+ */
13
+ export declare function ignoreIf(...envVars: string[]): (_: object, __: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
14
+ /** @deprecated Use ignoreIf("TEST") instead */
15
+ export declare function ignoreDuringUnitTest(): (_: object, __: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -0,0 +1,6 @@
1
+ export type Environment = "production" | "development";
2
+ export declare const Environments: {
3
+ production: "production";
4
+ development: "development";
5
+ };
6
+ export declare const DefaultEnvironment: "development";
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Generic function type that can replace arrow function signatures.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * // Instead of: (arg1: string, arg2: number) => boolean
7
+ * type MyCallback = Func<[string, number], boolean>;
8
+ *
9
+ * // Instead of: (data: any) => void
10
+ * type MyHandler = Func<[any], void>;
11
+ *
12
+ * // Instead of: () => Promise<string>
13
+ * type MyAsyncFunc = Func<[], Promise<string>>;
14
+ * ```
15
+ */
16
+ export type Func<TArgs extends readonly unknown[] = [], TReturn = void> = (...args: TArgs) => TReturn;
17
+ /**
18
+ * Async function type that returns a Promise.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Instead of: (id: string) => Promise<User>
23
+ * type GetUser = AsyncFunc<[string], User>;
24
+ *
25
+ * // Instead of: () => Promise<void>
26
+ * type InitFunc = AsyncFunc<[], void>;
27
+ * ```
28
+ */
29
+ export type AsyncFunc<TArgs extends readonly unknown[] = [], TReturn = void> = Func<TArgs, Promise<TReturn>>;
30
+ /**
31
+ * Predicate function type that returns a boolean.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * // Instead of: (item: T) => boolean
36
+ * type Filter<T> = Predicate<[T]>;
37
+ *
38
+ * // Instead of: (a: number, b: number) => boolean
39
+ * type Comparator = Predicate<[number, number]>;
40
+ * ```
41
+ */
42
+ export type Predicate<TArgs extends readonly unknown[] = []> = Func<TArgs, boolean>;
43
+ /**
44
+ * Action function type that returns void.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // Instead of: (event: Event) => void
49
+ * type EventHandler = Action<[Event]>;
50
+ *
51
+ * // Instead of: () => void
52
+ * type Callback = Action<[]>;
53
+ * ```
54
+ */
55
+ export type Action<TArgs extends readonly unknown[] = []> = Func<TArgs, void>;
@@ -0,0 +1,7 @@
1
+ export * from "./camel-case.js";
2
+ export * from "./debounce.js";
3
+ export * from "./decorator.js";
4
+ export * from "./environment.js";
5
+ export * from "./function.types.js";
6
+ export * from "./retry.decorator.js";
7
+ export * from "./type.utils.js";
@@ -0,0 +1,6 @@
1
+ export type RetryOptions = {
2
+ attempts?: number;
3
+ delayMs?: number;
4
+ shouldRetry?: (error: unknown) => boolean;
5
+ };
6
+ export declare const retry: (options?: RetryOptions) => any;
@@ -0,0 +1 @@
1
+ export declare const sleep: (ms: number) => Promise<unknown>;
@@ -0,0 +1 @@
1
+ export type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
@@ -0,0 +1 @@
1
+ export declare function flushPromises(): Promise<unknown>;
@@ -0,0 +1,3 @@
1
+ export declare function withMemfsFsForGlob<TGlobModule extends {
2
+ glob: (...args: unknown[]) => unknown;
3
+ }>(actual: TGlobModule): TGlobModule;
@@ -0,0 +1,5 @@
1
+ export * from "./flush-promises.js";
2
+ export * from "./glob-with-memfs.js";
3
+ export * from "./memfs.js";
4
+ export * from "./mock-logger.js";
5
+ export * from "./spy-on-constructor.js";
@@ -0,0 +1,5 @@
1
+ export declare function resetMemfs(): void;
2
+ export declare function seedMemfs(files: Record<string, string>): void;
3
+ export declare function createTestFile(filePath: string, content: string | Buffer): void;
4
+ export declare function readFile(filePath: string): Promise<string>;
5
+ export declare function fileExists(filePath: string): boolean;
@@ -0,0 +1,13 @@
1
+ export type LoggerMethod = (msg: string | number | object, ...args: unknown[]) => void;
2
+ export type TestLogger = {
3
+ fatal: LoggerMethod;
4
+ error: LoggerMethod;
5
+ warn: LoggerMethod;
6
+ info: LoggerMethod;
7
+ debug: LoggerMethod;
8
+ trace: LoggerMethod;
9
+ isLevelEnabled(level: string): boolean;
10
+ readonly currentLevel: string;
11
+ readonly logLevels: Record<string, number>;
12
+ };
13
+ export declare function createMockLogger(): TestLogger;
@@ -0,0 +1,21 @@
1
+ import { vi } from "vitest";
2
+ import type { Constructable } from "../reflection/index.js";
3
+ /**
4
+ * Creates a Proxy around a class constructor that intercepts `new` calls,
5
+ * records arguments via a spy, and delegates to the real constructor.
6
+ *
7
+ * Use this to assert what was injected into a class by a DI container
8
+ * (e.g. Container) without changing actual behavior.
9
+ *
10
+ * The proxy copies all `reflect-metadata` entries from the original class
11
+ * so that DI metadata (`design:paramtypes`) remains intact.
12
+ *
13
+ * @example
14
+ * const { spy, Proxy: SpiedService } = spyOnConstructor(MyService);
15
+ * // use SpiedService in place of MyService when wiring the container
16
+ * expect(spy).toHaveBeenCalledWith(expect.any(ExpectedDependency));
17
+ */
18
+ export declare function spyOnConstructor<T extends Constructable>(Target: T): {
19
+ spy: ReturnType<typeof vi.fn>;
20
+ Proxy: T;
21
+ };