@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.
- package/commonjs/src/caching/cache-manager.js +98 -0
- package/commonjs/src/caching/cache.decorator.js +69 -0
- package/commonjs/src/caching/cache.js +6 -0
- package/commonjs/src/caching/index.js +23 -0
- package/commonjs/src/caching/invalidate-cache.decorator.js +92 -0
- package/commonjs/src/caching/memoize.decorator.js +36 -0
- package/commonjs/src/caching/node-cache-memoize.adapter.js +49 -0
- package/commonjs/src/cli/action.js +65 -0
- package/commonjs/src/cli/command.js +127 -0
- package/commonjs/src/cli/index.js +61 -0
- package/commonjs/src/cli/module.type.js +18 -0
- package/commonjs/src/cli/options.js +115 -0
- package/commonjs/src/collections/collections.js +21 -0
- package/commonjs/src/collections/find-duplicates.js +35 -0
- package/commonjs/src/collections/index.js +52 -0
- package/commonjs/src/collections/merge-arrays.js +34 -0
- package/commonjs/src/collections/sum.js +63 -0
- package/commonjs/src/collections/unique-objects.js +39 -0
- package/commonjs/src/composition/index.js +4 -0
- package/commonjs/src/configuration/configuration.types.js +11 -0
- package/commonjs/src/configuration/index.js +18 -0
- package/commonjs/src/diagnostics/index.js +22 -0
- package/commonjs/src/diagnostics/trace.js +86 -0
- package/commonjs/src/extensibility/decorator-factory-base.js +22 -0
- package/commonjs/src/extensibility/decorator-factory.js +31 -0
- package/commonjs/src/extensibility/extension.js +37 -0
- package/commonjs/src/extensibility/index.js +23 -0
- package/commonjs/src/extensibility/mixwith.js +36 -0
- package/commonjs/src/extensibility/pipeline.js +56 -0
- package/commonjs/src/extensibility/step.js +18 -0
- package/commonjs/src/interop/docker/docker.js +54 -0
- package/commonjs/src/interop/errors/interop.error.js +12 -0
- package/commonjs/src/interop/git/git.js +134 -0
- package/commonjs/src/interop/git/git.types.js +4 -0
- package/commonjs/src/interop/index.js +97 -0
- package/commonjs/src/interop/node/index.js +18 -0
- package/commonjs/src/interop/node/node.js +45 -0
- package/commonjs/src/interop/npm/npm.js +231 -0
- package/commonjs/src/interop/npm/npm.types.js +16 -0
- package/commonjs/src/interop/pnpm/pnpm.js +34 -0
- package/commonjs/src/interop/pnpm/pnpm.types.js +4 -0
- package/commonjs/src/interop/shell/shell.argv.js +45 -0
- package/commonjs/src/interop/shell/shell.js +105 -0
- package/commonjs/src/interop/shell/shell.types.js +4 -0
- package/commonjs/src/interop/types/detect-package-manager.js +71 -0
- package/commonjs/src/interop/types/package-manager.js +4 -0
- package/commonjs/src/interop/yarn/yarn.js +34 -0
- package/commonjs/src/interop/yarn/yarn.types.js +4 -0
- package/commonjs/src/io/copy-file.js +25 -0
- package/commonjs/src/io/delete-file.js +21 -0
- package/commonjs/src/io/directory-exists.js +24 -0
- package/commonjs/src/io/file-exists.js +19 -0
- package/commonjs/src/io/find-directories.js +21 -0
- package/commonjs/src/io/find-file.js +45 -0
- package/commonjs/src/io/index.js +66 -0
- package/commonjs/src/io/io.js +28 -0
- package/commonjs/src/io/read-file.js +39 -0
- package/commonjs/src/io/remove-dir.js +22 -0
- package/commonjs/src/io/types/directory.type.js +4 -0
- package/commonjs/src/io/types/file.js +28 -0
- package/commonjs/src/io/types/index.js +19 -0
- package/commonjs/src/io/url-to-path.js +33 -0
- package/commonjs/src/io/watch.js +261 -0
- package/commonjs/src/io/write-file.js +30 -0
- package/commonjs/src/objects/deep-merge.js +67 -0
- package/commonjs/src/objects/index.js +11 -0
- package/commonjs/src/reflection/index.js +20 -0
- package/commonjs/src/reflection/types/index.js +18 -0
- package/commonjs/src/reflection/types/reflection.types.js +26 -0
- package/commonjs/src/reflection/utilities.js +118 -0
- package/commonjs/src/semver/index.js +18 -0
- package/commonjs/src/semver/semver.js +92 -0
- package/commonjs/src/system/camel-case.js +13 -0
- package/commonjs/src/system/debounce.js +19 -0
- package/commonjs/src/system/decorator.js +46 -0
- package/commonjs/src/system/environment.js +23 -0
- package/commonjs/src/system/function.types.js +18 -0
- package/commonjs/src/system/index.js +24 -0
- package/commonjs/src/system/retry.decorator.js +40 -0
- package/commonjs/src/system/sleep.js +13 -0
- package/commonjs/src/system/type.utils.js +4 -0
- package/commonjs/src/testing/flush-promises.js +16 -0
- package/commonjs/src/testing/glob-with-memfs.js +22 -0
- package/commonjs/src/testing/index.js +22 -0
- package/commonjs/src/testing/memfs.js +52 -0
- package/commonjs/src/testing/mock-logger.js +36 -0
- package/commonjs/src/testing/spy-on-constructor.js +27 -0
- package/es6/src/caching/cache-manager.js +82 -0
- package/es6/src/caching/cache.decorator.js +51 -0
- package/es6/src/caching/cache.js +3 -0
- package/es6/src/caching/index.js +6 -0
- package/es6/src/caching/invalidate-cache.decorator.js +71 -0
- package/es6/src/caching/memoize.decorator.js +27 -0
- package/es6/src/caching/node-cache-memoize.adapter.js +37 -0
- package/es6/src/cli/action.js +47 -0
- package/es6/src/cli/command.js +106 -0
- package/es6/src/cli/index.js +4 -0
- package/es6/src/cli/module.type.js +11 -0
- package/es6/src/cli/options.js +76 -0
- package/es6/src/collections/collections.js +4 -0
- package/es6/src/collections/find-duplicates.js +17 -0
- package/es6/src/collections/index.js +1 -0
- package/es6/src/collections/merge-arrays.js +16 -0
- package/es6/src/collections/sum.js +45 -0
- package/es6/src/collections/unique-objects.js +21 -0
- package/es6/src/composition/index.js +1 -0
- package/es6/src/configuration/configuration.types.js +1 -0
- package/es6/src/configuration/index.js +1 -0
- package/es6/src/diagnostics/index.js +1 -0
- package/es6/src/diagnostics/trace.js +68 -0
- package/es6/src/extensibility/decorator-factory-base.js +39 -0
- package/es6/src/extensibility/decorator-factory.js +21 -0
- package/es6/src/extensibility/extension.js +27 -0
- package/es6/src/extensibility/index.js +6 -0
- package/es6/src/extensibility/mixwith.js +26 -0
- package/es6/src/extensibility/pipeline.js +46 -0
- package/es6/src/extensibility/step.js +16 -0
- package/es6/src/interop/docker/docker.js +44 -0
- package/es6/src/interop/errors/interop.error.js +2 -0
- package/es6/src/interop/git/git.js +124 -0
- package/es6/src/interop/git/git.types.js +1 -0
- package/es6/src/interop/index.js +21 -0
- package/es6/src/interop/node/index.js +1 -0
- package/es6/src/interop/node/node.js +35 -0
- package/es6/src/interop/npm/npm.js +180 -0
- package/es6/src/interop/npm/npm.types.js +6 -0
- package/es6/src/interop/pnpm/pnpm.js +24 -0
- package/es6/src/interop/pnpm/pnpm.types.js +1 -0
- package/es6/src/interop/shell/shell.argv.js +35 -0
- package/es6/src/interop/shell/shell.js +95 -0
- package/es6/src/interop/shell/shell.types.js +1 -0
- package/es6/src/interop/types/detect-package-manager.js +50 -0
- package/es6/src/interop/types/package-manager.js +1 -0
- package/es6/src/interop/yarn/yarn.js +24 -0
- package/es6/src/interop/yarn/yarn.types.js +1 -0
- package/es6/src/io/copy-file.js +10 -0
- package/es6/src/io/delete-file.js +6 -0
- package/es6/src/io/directory-exists.js +9 -0
- package/es6/src/io/file-exists.js +9 -0
- package/es6/src/io/find-directories.js +11 -0
- package/es6/src/io/find-file.js +27 -0
- package/es6/src/io/index.js +2 -0
- package/es6/src/io/io.js +11 -0
- package/es6/src/io/read-file.js +13 -0
- package/es6/src/io/remove-dir.js +7 -0
- package/es6/src/io/types/directory.type.js +1 -0
- package/es6/src/io/types/file.js +18 -0
- package/es6/src/io/types/index.js +2 -0
- package/es6/src/io/url-to-path.js +15 -0
- package/es6/src/io/watch.js +238 -0
- package/es6/src/io/write-file.js +15 -0
- package/es6/src/objects/deep-merge.js +57 -0
- package/es6/src/objects/index.js +1 -0
- package/es6/src/reflection/index.js +3 -0
- package/es6/src/reflection/types/index.js +1 -0
- package/es6/src/reflection/types/reflection.types.js +8 -0
- package/es6/src/reflection/utilities.js +74 -0
- package/es6/src/semver/index.js +1 -0
- package/es6/src/semver/semver.js +71 -0
- package/es6/src/system/camel-case.js +3 -0
- package/es6/src/system/debounce.js +9 -0
- package/es6/src/system/decorator.js +30 -0
- package/es6/src/system/environment.js +5 -0
- package/es6/src/system/function.types.js +26 -0
- package/es6/src/system/index.js +7 -0
- package/es6/src/system/retry.decorator.js +30 -0
- package/es6/src/system/sleep.js +3 -0
- package/es6/src/system/type.utils.js +1 -0
- package/es6/src/testing/flush-promises.js +6 -0
- package/es6/src/testing/glob-with-memfs.js +20 -0
- package/es6/src/testing/index.js +5 -0
- package/es6/src/testing/memfs.js +25 -0
- package/es6/src/testing/mock-logger.js +26 -0
- package/es6/src/testing/spy-on-constructor.js +31 -0
- package/package.json +106 -0
- package/types/src/caching/cache-manager.d.ts +59 -0
- package/types/src/caching/cache.d.ts +11 -0
- package/types/src/caching/cache.decorator.d.ts +18 -0
- package/types/src/caching/index.d.ts +6 -0
- package/types/src/caching/invalidate-cache.decorator.d.ts +17 -0
- package/types/src/caching/memoize.decorator.d.ts +16 -0
- package/types/src/caching/node-cache-memoize.adapter.d.ts +22 -0
- package/types/src/cli/action.d.ts +36 -0
- package/types/src/cli/command.d.ts +34 -0
- package/types/src/cli/index.d.ts +7 -0
- package/types/src/cli/module.type.d.ts +36 -0
- package/types/src/cli/options.d.ts +28 -0
- package/types/src/collections/collections.d.ts +4 -0
- package/types/src/collections/find-duplicates.d.ts +2 -0
- package/types/src/collections/index.d.ts +1 -0
- package/types/src/collections/merge-arrays.d.ts +2 -0
- package/types/src/collections/sum.d.ts +4 -0
- package/types/src/collections/unique-objects.d.ts +2 -0
- package/types/src/composition/index.d.ts +37 -0
- package/types/src/configuration/configuration.types.d.ts +10 -0
- package/types/src/configuration/index.d.ts +1 -0
- package/types/src/diagnostics/index.d.ts +1 -0
- package/types/src/diagnostics/trace.d.ts +10 -0
- package/types/src/extensibility/decorator-factory-base.d.ts +39 -0
- package/types/src/extensibility/decorator-factory.d.ts +19 -0
- package/types/src/extensibility/extension.d.ts +9 -0
- package/types/src/extensibility/index.d.ts +6 -0
- package/types/src/extensibility/mixwith.d.ts +6 -0
- package/types/src/extensibility/pipeline.d.ts +12 -0
- package/types/src/extensibility/step.d.ts +16 -0
- package/types/src/interop/docker/docker.d.ts +19 -0
- package/types/src/interop/errors/interop.error.d.ts +2 -0
- package/types/src/interop/git/git.d.ts +16 -0
- package/types/src/interop/git/git.types.d.ts +14 -0
- package/types/src/interop/index.d.ts +14 -0
- package/types/src/interop/node/index.d.ts +1 -0
- package/types/src/interop/node/node.d.ts +5 -0
- package/types/src/interop/npm/npm.d.ts +29 -0
- package/types/src/interop/npm/npm.types.d.ts +24 -0
- package/types/src/interop/pnpm/pnpm.d.ts +9 -0
- package/types/src/interop/pnpm/pnpm.types.d.ts +3 -0
- package/types/src/interop/shell/shell.argv.d.ts +5 -0
- package/types/src/interop/shell/shell.d.ts +6 -0
- package/types/src/interop/shell/shell.types.d.ts +9 -0
- package/types/src/interop/types/detect-package-manager.d.ts +4 -0
- package/types/src/interop/types/package-manager.d.ts +10 -0
- package/types/src/interop/yarn/yarn.d.ts +9 -0
- package/types/src/interop/yarn/yarn.types.d.ts +3 -0
- package/types/src/io/copy-file.d.ts +4 -0
- package/types/src/io/delete-file.d.ts +1 -0
- package/types/src/io/directory-exists.d.ts +1 -0
- package/types/src/io/file-exists.d.ts +1 -0
- package/types/src/io/find-directories.d.ts +2 -0
- package/types/src/io/find-file.d.ts +9 -0
- package/types/src/io/index.d.ts +2 -0
- package/types/src/io/io.d.ts +11 -0
- package/types/src/io/read-file.d.ts +4 -0
- package/types/src/io/remove-dir.d.ts +5 -0
- package/types/src/io/types/directory.type.d.ts +4 -0
- package/types/src/io/types/file.d.ts +20 -0
- package/types/src/io/types/index.d.ts +2 -0
- package/types/src/io/url-to-path.d.ts +2 -0
- package/types/src/io/watch.d.ts +16 -0
- package/types/src/io/write-file.d.ts +5 -0
- package/types/src/objects/deep-merge.d.ts +41 -0
- package/types/src/objects/index.d.ts +1 -0
- package/types/src/reflection/index.d.ts +3 -0
- package/types/src/reflection/types/index.d.ts +1 -0
- package/types/src/reflection/types/reflection.types.d.ts +21 -0
- package/types/src/reflection/utilities.d.ts +27 -0
- package/types/src/semver/index.d.ts +1 -0
- package/types/src/semver/semver.d.ts +18 -0
- package/types/src/system/camel-case.d.ts +1 -0
- package/types/src/system/debounce.d.ts +1 -0
- package/types/src/system/decorator.d.ts +15 -0
- package/types/src/system/environment.d.ts +6 -0
- package/types/src/system/function.types.d.ts +55 -0
- package/types/src/system/index.d.ts +7 -0
- package/types/src/system/retry.decorator.d.ts +6 -0
- package/types/src/system/sleep.d.ts +1 -0
- package/types/src/system/type.utils.d.ts +1 -0
- package/types/src/testing/flush-promises.d.ts +1 -0
- package/types/src/testing/glob-with-memfs.d.ts +3 -0
- package/types/src/testing/index.d.ts +5 -0
- package/types/src/testing/memfs.d.ts +5 -0
- package/types/src/testing/mock-logger.d.ts +13 -0
- 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 @@
|
|
|
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,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 @@
|
|
|
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,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
|
+
};
|