@tachybase/utils 0.23.8
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/.turbo/turbo-build.log +9 -0
- package/LICENSE +201 -0
- package/lib/assign.d.ts +9 -0
- package/lib/assign.js +136 -0
- package/lib/client.d.ts +21 -0
- package/lib/client.js +77 -0
- package/lib/cluster.d.ts +2 -0
- package/lib/cluster.js +39 -0
- package/lib/collections-graph.d.ts +16 -0
- package/lib/collections-graph.js +98 -0
- package/lib/common.d.ts +7 -0
- package/lib/common.js +98 -0
- package/lib/currencyUtils.d.ts +44 -0
- package/lib/currencyUtils.js +75 -0
- package/lib/date.d.ts +22 -0
- package/lib/date.js +186 -0
- package/lib/dayjs.d.ts +10 -0
- package/lib/dayjs.js +73 -0
- package/lib/decorators.d.ts +16 -0
- package/lib/decorators.js +94 -0
- package/lib/dom.d.ts +4 -0
- package/lib/dom.js +52 -0
- package/lib/forEach.d.ts +1 -0
- package/lib/forEach.js +36 -0
- package/lib/fs-exists.d.ts +1 -0
- package/lib/fs-exists.js +37 -0
- package/lib/getCurrentStacks.d.ts +1 -0
- package/lib/getCurrentStacks.js +35 -0
- package/lib/getValuesByPath.d.ts +1 -0
- package/lib/getValuesByPath.js +62 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.js +97 -0
- package/lib/isPortalInBody.d.ts +5 -0
- package/lib/isPortalInBody.js +45 -0
- package/lib/json-templates.d.ts +1 -0
- package/lib/json-templates.js +145 -0
- package/lib/koa-multer.d.ts +6 -0
- package/lib/koa-multer.js +83 -0
- package/lib/log.d.ts +1 -0
- package/lib/log.js +30 -0
- package/lib/measure-execution-time.d.ts +1 -0
- package/lib/measure-execution-time.js +35 -0
- package/lib/merge.d.ts +1 -0
- package/lib/merge.js +46 -0
- package/lib/mixin/AsyncEmitter.d.ts +3 -0
- package/lib/mixin/AsyncEmitter.js +73 -0
- package/lib/mixin/index.d.ts +1 -0
- package/lib/mixin/index.js +39 -0
- package/lib/notification.d.ts +1 -0
- package/lib/notification.js +34 -0
- package/lib/number.d.ts +1 -0
- package/lib/number.js +36 -0
- package/lib/parse-date.d.ts +3 -0
- package/lib/parse-date.js +237 -0
- package/lib/parse-filter.d.ts +146 -0
- package/lib/parse-filter.js +305 -0
- package/lib/parseHTML.d.ts +7 -0
- package/lib/parseHTML.js +33 -0
- package/lib/perf-hooks.d.ts +6 -0
- package/lib/perf-hooks.js +60 -0
- package/lib/plugin-symlink.d.ts +4 -0
- package/lib/plugin-symlink.js +131 -0
- package/lib/registry.d.ts +14 -0
- package/lib/registry.js +60 -0
- package/lib/requireModule.d.ts +3 -0
- package/lib/requireModule.js +64 -0
- package/lib/toposort.d.ts +13 -0
- package/lib/toposort.js +90 -0
- package/lib/typedi/container-instance.class.d.ts +109 -0
- package/lib/typedi/container-instance.class.js +349 -0
- package/lib/typedi/container-registry.class.d.ts +51 -0
- package/lib/typedi/container-registry.class.js +97 -0
- package/lib/typedi/decorators/inject-many.decorator.d.ts +8 -0
- package/lib/typedi/decorators/inject-many.decorator.js +56 -0
- package/lib/typedi/decorators/inject.decorator.d.ts +9 -0
- package/lib/typedi/decorators/inject.decorator.js +56 -0
- package/lib/typedi/decorators/service.decorator.d.ts +6 -0
- package/lib/typedi/decorators/service.decorator.js +49 -0
- package/lib/typedi/empty.const.d.ts +6 -0
- package/lib/typedi/empty.const.js +27 -0
- package/lib/typedi/error/cannot-inject-value.error.d.ts +11 -0
- package/lib/typedi/error/cannot-inject-value.error.js +40 -0
- package/lib/typedi/error/cannot-instantiate-value.error.d.ts +11 -0
- package/lib/typedi/error/cannot-instantiate-value.error.js +49 -0
- package/lib/typedi/error/service-not-found.error.d.ts +11 -0
- package/lib/typedi/error/service-not-found.error.js +49 -0
- package/lib/typedi/index.d.ts +17 -0
- package/lib/typedi/index.js +64 -0
- package/lib/typedi/interfaces/container-options.interface.d.ts +45 -0
- package/lib/typedi/interfaces/container-options.interface.js +15 -0
- package/lib/typedi/interfaces/handler.interface.d.ts +27 -0
- package/lib/typedi/interfaces/handler.interface.js +15 -0
- package/lib/typedi/interfaces/service-metadata.interface.d.ts +53 -0
- package/lib/typedi/interfaces/service-metadata.interface.js +15 -0
- package/lib/typedi/interfaces/service-options.interface.d.ts +6 -0
- package/lib/typedi/interfaces/service-options.interface.js +15 -0
- package/lib/typedi/token.class.d.ts +11 -0
- package/lib/typedi/token.class.js +37 -0
- package/lib/typedi/types/abstract-constructable.type.d.ts +9 -0
- package/lib/typedi/types/abstract-constructable.type.js +15 -0
- package/lib/typedi/types/constructable.type.d.ts +10 -0
- package/lib/typedi/types/constructable.type.js +15 -0
- package/lib/typedi/types/container-identifier.type.d.ts +4 -0
- package/lib/typedi/types/container-identifier.type.js +15 -0
- package/lib/typedi/types/container-scope.type.d.ts +1 -0
- package/lib/typedi/types/container-scope.type.js +15 -0
- package/lib/typedi/types/service-identifier.type.d.ts +8 -0
- package/lib/typedi/types/service-identifier.type.js +15 -0
- package/lib/typedi/utils/resolve-to-type-wrapper.util.d.ts +15 -0
- package/lib/typedi/utils/resolve-to-type-wrapper.util.js +39 -0
- package/lib/uid.d.ts +1 -0
- package/lib/uid.js +35 -0
- package/lib/url.d.ts +1 -0
- package/lib/url.js +37 -0
- package/package.json +49 -0
- package/tsconfig.json +31 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
|
+
var container_registry_class_exports = {};
|
|
22
|
+
__export(container_registry_class_exports, {
|
|
23
|
+
ContainerRegistry: () => ContainerRegistry
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(container_registry_class_exports);
|
|
26
|
+
var import_container_instance = require("./container-instance.class");
|
|
27
|
+
const _ContainerRegistry = class _ContainerRegistry {
|
|
28
|
+
/**
|
|
29
|
+
* Registers the given container instance or throws an error.
|
|
30
|
+
*
|
|
31
|
+
* _Note: This function is auto-called when a Container instance is created,
|
|
32
|
+
* it doesn't need to be called manually!_
|
|
33
|
+
*
|
|
34
|
+
* @param container the container to add to the registry
|
|
35
|
+
*/
|
|
36
|
+
static registerContainer(container) {
|
|
37
|
+
if (container instanceof import_container_instance.ContainerInstance === false) {
|
|
38
|
+
throw new Error("Only ContainerInstance instances can be registered.");
|
|
39
|
+
}
|
|
40
|
+
if (_ContainerRegistry.containerMap.has(container.id)) {
|
|
41
|
+
throw new Error("Cannot register container with same ID.");
|
|
42
|
+
}
|
|
43
|
+
_ContainerRegistry.containerMap.set(container.id, container);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns true if a container exists with the given ID or false otherwise.
|
|
47
|
+
*
|
|
48
|
+
* @param container the ID of the container
|
|
49
|
+
*/
|
|
50
|
+
static hasContainer(id) {
|
|
51
|
+
return _ContainerRegistry.containerMap.has(id);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns the container for requested ID or throws an error if no container
|
|
55
|
+
* is registered with the given ID.
|
|
56
|
+
*
|
|
57
|
+
* @param container the ID of the container
|
|
58
|
+
*/
|
|
59
|
+
static getContainer(id) {
|
|
60
|
+
const registeredContainer = this.containerMap.get(id);
|
|
61
|
+
if (registeredContainer === void 0) {
|
|
62
|
+
throw new Error("No container is registered with the given ID.");
|
|
63
|
+
}
|
|
64
|
+
return registeredContainer;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Removes the given container from the registry and disposes all services
|
|
68
|
+
* registered only in this container.
|
|
69
|
+
*
|
|
70
|
+
* This function throws an error if no
|
|
71
|
+
* - container exists with the given ID
|
|
72
|
+
* - any of the registered services threw an error during it's disposal
|
|
73
|
+
*
|
|
74
|
+
* @param container the container to remove from the registry
|
|
75
|
+
*/
|
|
76
|
+
static async removeContainer(container) {
|
|
77
|
+
const registeredContainer = _ContainerRegistry.containerMap.get(container.id);
|
|
78
|
+
if (registeredContainer === void 0) {
|
|
79
|
+
throw new Error("No container is registered with the given ID.");
|
|
80
|
+
}
|
|
81
|
+
_ContainerRegistry.containerMap.delete(container.id);
|
|
82
|
+
await registeredContainer.dispose();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
__name(_ContainerRegistry, "ContainerRegistry");
|
|
86
|
+
/**
|
|
87
|
+
* The list of all known container. Created containers are automatically added
|
|
88
|
+
* to this list. Two container cannot be registered with the same ID.
|
|
89
|
+
*
|
|
90
|
+
* This map doesn't contains the default container.
|
|
91
|
+
*/
|
|
92
|
+
__publicField(_ContainerRegistry, "containerMap", /* @__PURE__ */ new Map());
|
|
93
|
+
let ContainerRegistry = _ContainerRegistry;
|
|
94
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
95
|
+
0 && (module.exports = {
|
|
96
|
+
ContainerRegistry
|
|
97
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Token } from '../token.class';
|
|
2
|
+
/**
|
|
3
|
+
* Injects a list of services into a class property or constructor parameter.
|
|
4
|
+
*/
|
|
5
|
+
export declare function InjectMany(): Function;
|
|
6
|
+
export declare function InjectMany(type?: (type?: any) => Function): Function;
|
|
7
|
+
export declare function InjectMany(serviceName?: string): Function;
|
|
8
|
+
export declare function InjectMany(token: Token<any>): Function;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var inject_many_decorator_exports = {};
|
|
20
|
+
__export(inject_many_decorator_exports, {
|
|
21
|
+
InjectMany: () => InjectMany
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(inject_many_decorator_exports);
|
|
24
|
+
var import_container_instance = require("../container-instance.class");
|
|
25
|
+
var import_cannot_inject_value = require("../error/cannot-inject-value.error");
|
|
26
|
+
var import_resolve_to_type_wrapper = require("../utils/resolve-to-type-wrapper.util");
|
|
27
|
+
function InjectMany(typeOrIdentifier) {
|
|
28
|
+
return function(_, context) {
|
|
29
|
+
if (!context.metadata.injects) {
|
|
30
|
+
context.metadata.injects = [];
|
|
31
|
+
}
|
|
32
|
+
context.metadata.injects.push((target) => {
|
|
33
|
+
const propertyName = context.name;
|
|
34
|
+
const typeWrapper = (0, import_resolve_to_type_wrapper.resolveToTypeWrapper)(typeOrIdentifier, target, propertyName);
|
|
35
|
+
if (typeWrapper === void 0 || typeWrapper.eagerType === void 0 || typeWrapper.eagerType === Object) {
|
|
36
|
+
throw new import_cannot_inject_value.CannotInjectValueError(target, propertyName);
|
|
37
|
+
}
|
|
38
|
+
import_container_instance.ContainerInstance.default.registerHandler({
|
|
39
|
+
object: target,
|
|
40
|
+
propertyName,
|
|
41
|
+
value: /* @__PURE__ */ __name((containerInstance) => {
|
|
42
|
+
const evaluatedLazyType = typeWrapper.lazyType();
|
|
43
|
+
if (evaluatedLazyType === void 0 || evaluatedLazyType === Object) {
|
|
44
|
+
throw new import_cannot_inject_value.CannotInjectValueError(target, propertyName);
|
|
45
|
+
}
|
|
46
|
+
return containerInstance.getMany(evaluatedLazyType);
|
|
47
|
+
}, "value")
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
__name(InjectMany, "InjectMany");
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
InjectMany
|
|
56
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Token } from '../token.class';
|
|
2
|
+
import { Constructable } from '../types/constructable.type';
|
|
3
|
+
/**
|
|
4
|
+
* Injects a service into a class property or constructor parameter.
|
|
5
|
+
*/
|
|
6
|
+
export declare function Inject(): Function;
|
|
7
|
+
export declare function Inject(typeFn: (type?: never) => Constructable<unknown>): Function;
|
|
8
|
+
export declare function Inject(serviceName?: string): Function;
|
|
9
|
+
export declare function Inject(token: Token<unknown>): Function;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var inject_decorator_exports = {};
|
|
20
|
+
__export(inject_decorator_exports, {
|
|
21
|
+
Inject: () => Inject
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(inject_decorator_exports);
|
|
24
|
+
var import_container_instance = require("../container-instance.class");
|
|
25
|
+
var import_cannot_inject_value = require("../error/cannot-inject-value.error");
|
|
26
|
+
var import_resolve_to_type_wrapper = require("../utils/resolve-to-type-wrapper.util");
|
|
27
|
+
function Inject(typeOrIdentifier) {
|
|
28
|
+
return function(_, context) {
|
|
29
|
+
if (!context.metadata.injects) {
|
|
30
|
+
context.metadata.injects = [];
|
|
31
|
+
}
|
|
32
|
+
context.metadata.injects.push((target) => {
|
|
33
|
+
const propertyName = context.name;
|
|
34
|
+
const typeWrapper = (0, import_resolve_to_type_wrapper.resolveToTypeWrapper)(typeOrIdentifier, target, propertyName);
|
|
35
|
+
if (typeWrapper === void 0 || typeWrapper.eagerType === void 0 || typeWrapper.eagerType === Object) {
|
|
36
|
+
throw new import_cannot_inject_value.CannotInjectValueError(target, propertyName);
|
|
37
|
+
}
|
|
38
|
+
import_container_instance.ContainerInstance.default.registerHandler({
|
|
39
|
+
object: target,
|
|
40
|
+
propertyName,
|
|
41
|
+
value: /* @__PURE__ */ __name((containerInstance) => {
|
|
42
|
+
const evaluatedLazyType = typeWrapper.lazyType();
|
|
43
|
+
if (evaluatedLazyType === void 0 || evaluatedLazyType === Object) {
|
|
44
|
+
throw new import_cannot_inject_value.CannotInjectValueError(target, propertyName);
|
|
45
|
+
}
|
|
46
|
+
return containerInstance.get(evaluatedLazyType);
|
|
47
|
+
}, "value")
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
__name(Inject, "Inject");
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
Inject
|
|
56
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ServiceOptions } from '../interfaces/service-options.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Marks class as a service that can be injected using Container.
|
|
4
|
+
*/
|
|
5
|
+
export declare function Service<T = unknown>(): Function;
|
|
6
|
+
export declare function Service<T = unknown>(options: ServiceOptions<T>): Function;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var service_decorator_exports = {};
|
|
20
|
+
__export(service_decorator_exports, {
|
|
21
|
+
Service: () => Service
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(service_decorator_exports);
|
|
24
|
+
var import_container_instance = require("../container-instance.class");
|
|
25
|
+
var import_empty = require("../empty.const");
|
|
26
|
+
function Service(options = {}) {
|
|
27
|
+
return (target, context) => {
|
|
28
|
+
const serviceMetadata = {
|
|
29
|
+
id: options.id || target,
|
|
30
|
+
type: target,
|
|
31
|
+
factory: options.factory || void 0,
|
|
32
|
+
multiple: options.multiple || false,
|
|
33
|
+
eager: options.eager || false,
|
|
34
|
+
scope: options.scope || "container",
|
|
35
|
+
referencedBy: (/* @__PURE__ */ new Map()).set(import_container_instance.ContainerInstance.default.id, import_container_instance.ContainerInstance.default),
|
|
36
|
+
value: import_empty.EMPTY_VALUE
|
|
37
|
+
};
|
|
38
|
+
(context.metadata.injects || []).forEach((inject) => {
|
|
39
|
+
inject(target);
|
|
40
|
+
});
|
|
41
|
+
import_container_instance.ContainerInstance.default.set(serviceMetadata);
|
|
42
|
+
return target;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
__name(Service, "Service");
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
Service
|
|
49
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var empty_const_exports = {};
|
|
19
|
+
__export(empty_const_exports, {
|
|
20
|
+
EMPTY_VALUE: () => EMPTY_VALUE
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(empty_const_exports);
|
|
23
|
+
const EMPTY_VALUE = Symbol("EMPTY_VALUE");
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
EMPTY_VALUE
|
|
27
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Constructable } from '../types/constructable.type';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when DI cannot inject value into property decorated by @Inject decorator.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CannotInjectValueError extends Error {
|
|
6
|
+
private target;
|
|
7
|
+
private propertyName;
|
|
8
|
+
name: string;
|
|
9
|
+
get message(): string;
|
|
10
|
+
constructor(target: Constructable<unknown>, propertyName: string);
|
|
11
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cannot_inject_value_error_exports = {};
|
|
20
|
+
__export(cannot_inject_value_error_exports, {
|
|
21
|
+
CannotInjectValueError: () => CannotInjectValueError
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cannot_inject_value_error_exports);
|
|
24
|
+
const _CannotInjectValueError = class _CannotInjectValueError extends Error {
|
|
25
|
+
constructor(target, propertyName) {
|
|
26
|
+
super();
|
|
27
|
+
this.target = target;
|
|
28
|
+
this.propertyName = propertyName;
|
|
29
|
+
}
|
|
30
|
+
name = "CannotInjectValueError";
|
|
31
|
+
get message() {
|
|
32
|
+
return `Cannot inject value into "${this.target.constructor.name}.${this.propertyName}". Please make sure you setup reflect-metadata properly and you don't use interfaces without service tokens as injection value.`;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
__name(_CannotInjectValueError, "CannotInjectValueError");
|
|
36
|
+
let CannotInjectValueError = _CannotInjectValueError;
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
CannotInjectValueError
|
|
40
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ServiceIdentifier } from '../types/service-identifier.type';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when DI cannot inject value into property decorated by @Inject decorator.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CannotInstantiateValueError extends Error {
|
|
6
|
+
name: string;
|
|
7
|
+
/** Normalized identifier name used in the error message. */
|
|
8
|
+
private normalizedIdentifier;
|
|
9
|
+
get message(): string;
|
|
10
|
+
constructor(identifier: ServiceIdentifier);
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cannot_instantiate_value_error_exports = {};
|
|
20
|
+
__export(cannot_instantiate_value_error_exports, {
|
|
21
|
+
CannotInstantiateValueError: () => CannotInstantiateValueError
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cannot_instantiate_value_error_exports);
|
|
24
|
+
var import_token = require("../token.class");
|
|
25
|
+
const _CannotInstantiateValueError = class _CannotInstantiateValueError extends Error {
|
|
26
|
+
name = "CannotInstantiateValueError";
|
|
27
|
+
/** Normalized identifier name used in the error message. */
|
|
28
|
+
normalizedIdentifier = "<UNKNOWN_IDENTIFIER>";
|
|
29
|
+
get message() {
|
|
30
|
+
return `Cannot instantiate the requested value for the "${this.normalizedIdentifier}" identifier. The related metadata doesn't contain a factory or a type to instantiate.`;
|
|
31
|
+
}
|
|
32
|
+
constructor(identifier) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
super();
|
|
35
|
+
if (typeof identifier === "string") {
|
|
36
|
+
this.normalizedIdentifier = identifier;
|
|
37
|
+
} else if (identifier instanceof import_token.Token) {
|
|
38
|
+
this.normalizedIdentifier = `Token<${identifier.name || "UNSET_NAME"}>`;
|
|
39
|
+
} else if (identifier && (identifier.name || ((_a = identifier.prototype) == null ? void 0 : _a.name))) {
|
|
40
|
+
this.normalizedIdentifier = identifier.name ? `MaybeConstructable<${identifier.name}>` : `MaybeConstructable<${(_b = identifier.prototype) == null ? void 0 : _b.name}>`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
__name(_CannotInstantiateValueError, "CannotInstantiateValueError");
|
|
45
|
+
let CannotInstantiateValueError = _CannotInstantiateValueError;
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
CannotInstantiateValueError
|
|
49
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ServiceIdentifier } from '../types/service-identifier.type';
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when requested service was not found.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ServiceNotFoundError extends Error {
|
|
6
|
+
name: string;
|
|
7
|
+
/** Normalized identifier name used in the error message. */
|
|
8
|
+
private normalizedIdentifier;
|
|
9
|
+
get message(): string;
|
|
10
|
+
constructor(identifier: ServiceIdentifier);
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var service_not_found_error_exports = {};
|
|
20
|
+
__export(service_not_found_error_exports, {
|
|
21
|
+
ServiceNotFoundError: () => ServiceNotFoundError
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(service_not_found_error_exports);
|
|
24
|
+
var import_token = require("../token.class");
|
|
25
|
+
const _ServiceNotFoundError = class _ServiceNotFoundError extends Error {
|
|
26
|
+
name = "ServiceNotFoundError";
|
|
27
|
+
/** Normalized identifier name used in the error message. */
|
|
28
|
+
normalizedIdentifier = "<UNKNOWN_IDENTIFIER>";
|
|
29
|
+
get message() {
|
|
30
|
+
return `Service with "${this.normalizedIdentifier}" identifier was not found in the container. Register it before usage via explicitly calling the "Container.set" function or using the "@Service()" decorator.`;
|
|
31
|
+
}
|
|
32
|
+
constructor(identifier) {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
super();
|
|
35
|
+
if (typeof identifier === "string") {
|
|
36
|
+
this.normalizedIdentifier = identifier;
|
|
37
|
+
} else if (identifier instanceof import_token.Token) {
|
|
38
|
+
this.normalizedIdentifier = `Token<${identifier.name || "UNSET_NAME"}>`;
|
|
39
|
+
} else if (identifier && (identifier.name || ((_a = identifier.prototype) == null ? void 0 : _a.name))) {
|
|
40
|
+
this.normalizedIdentifier = identifier.name ? `MaybeConstructable<${identifier.name}>` : `MaybeConstructable<${(_b = identifier.prototype) == null ? void 0 : _b.name}>`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
__name(_ServiceNotFoundError, "ServiceNotFoundError");
|
|
45
|
+
let ServiceNotFoundError = _ServiceNotFoundError;
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
ServiceNotFoundError
|
|
49
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ContainerInstance } from './container-instance.class';
|
|
2
|
+
export * from './decorators/inject-many.decorator';
|
|
3
|
+
export * from './decorators/inject.decorator';
|
|
4
|
+
export * from './decorators/service.decorator';
|
|
5
|
+
export * from './error/cannot-inject-value.error';
|
|
6
|
+
export * from './error/cannot-instantiate-value.error';
|
|
7
|
+
export * from './error/service-not-found.error';
|
|
8
|
+
export { Handler } from './interfaces/handler.interface';
|
|
9
|
+
export { ServiceMetadata } from './interfaces/service-metadata.interface';
|
|
10
|
+
export { ServiceOptions } from './interfaces/service-options.interface';
|
|
11
|
+
export { Constructable } from './types/constructable.type';
|
|
12
|
+
export { ServiceIdentifier } from './types/service-identifier.type';
|
|
13
|
+
export { ContainerInstance } from './container-instance.class';
|
|
14
|
+
export { Token } from './token.class';
|
|
15
|
+
/** We export the default container under the Container alias. */
|
|
16
|
+
export declare const Container: ContainerInstance;
|
|
17
|
+
export default Container;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var typedi_exports = {};
|
|
20
|
+
__export(typedi_exports, {
|
|
21
|
+
Constructable: () => import_constructable.Constructable,
|
|
22
|
+
Container: () => Container,
|
|
23
|
+
ContainerInstance: () => import_container_instance2.ContainerInstance,
|
|
24
|
+
Handler: () => import_handler.Handler,
|
|
25
|
+
ServiceIdentifier: () => import_service_identifier.ServiceIdentifier,
|
|
26
|
+
ServiceMetadata: () => import_service_metadata.ServiceMetadata,
|
|
27
|
+
ServiceOptions: () => import_service_options.ServiceOptions,
|
|
28
|
+
Token: () => import_token.Token,
|
|
29
|
+
default: () => typedi_default
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(typedi_exports);
|
|
32
|
+
var import_container_instance = require("./container-instance.class");
|
|
33
|
+
__reExport(typedi_exports, require("./decorators/inject-many.decorator"), module.exports);
|
|
34
|
+
__reExport(typedi_exports, require("./decorators/inject.decorator"), module.exports);
|
|
35
|
+
__reExport(typedi_exports, require("./decorators/service.decorator"), module.exports);
|
|
36
|
+
__reExport(typedi_exports, require("./error/cannot-inject-value.error"), module.exports);
|
|
37
|
+
__reExport(typedi_exports, require("./error/cannot-instantiate-value.error"), module.exports);
|
|
38
|
+
__reExport(typedi_exports, require("./error/service-not-found.error"), module.exports);
|
|
39
|
+
var import_handler = require("./interfaces/handler.interface");
|
|
40
|
+
var import_service_metadata = require("./interfaces/service-metadata.interface");
|
|
41
|
+
var import_service_options = require("./interfaces/service-options.interface");
|
|
42
|
+
var import_constructable = require("./types/constructable.type");
|
|
43
|
+
var import_service_identifier = require("./types/service-identifier.type");
|
|
44
|
+
var import_container_instance2 = require("./container-instance.class");
|
|
45
|
+
var import_token = require("./token.class");
|
|
46
|
+
const Container = import_container_instance.ContainerInstance.default;
|
|
47
|
+
var typedi_default = Container;
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
Constructable,
|
|
51
|
+
Container,
|
|
52
|
+
ContainerInstance,
|
|
53
|
+
Handler,
|
|
54
|
+
ServiceIdentifier,
|
|
55
|
+
ServiceMetadata,
|
|
56
|
+
ServiceOptions,
|
|
57
|
+
Token,
|
|
58
|
+
...require("./decorators/inject-many.decorator"),
|
|
59
|
+
...require("./decorators/inject.decorator"),
|
|
60
|
+
...require("./decorators/service.decorator"),
|
|
61
|
+
...require("./error/cannot-inject-value.error"),
|
|
62
|
+
...require("./error/cannot-instantiate-value.error"),
|
|
63
|
+
...require("./error/service-not-found.error")
|
|
64
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface ContainerOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Controls the behavior when a service is already registered with the same ID. The following values are allowed:
|
|
4
|
+
*
|
|
5
|
+
* - `throw` - a `ContainerCannotBeCreatedError` error is raised
|
|
6
|
+
* - `overwrite` - the previous container is disposed and a new one is created
|
|
7
|
+
* - `returnExisting` - returns the existing container or raises a `ContainerCannotBeCreatedError` error if the
|
|
8
|
+
* specified options differ from the options of the existing container
|
|
9
|
+
*
|
|
10
|
+
* The default value is `returnExisting`.
|
|
11
|
+
*/
|
|
12
|
+
onConflict: 'throw' | 'overwrite' | 'returnExisting';
|
|
13
|
+
/**
|
|
14
|
+
* Controls the behavior when a requested type doesn't exists in the current container. The following values are allowed:
|
|
15
|
+
*
|
|
16
|
+
* - `allowLookup` - the parent container will be checked for the dependency
|
|
17
|
+
* - `localOnly` - a `ServiceNotFoundError` error is raised
|
|
18
|
+
*
|
|
19
|
+
* The default value is `allowLookup`.
|
|
20
|
+
*/
|
|
21
|
+
lookupStrategy: 'allowLookup' | 'localOnly';
|
|
22
|
+
/**
|
|
23
|
+
* Enables the lookup for global (singleton) services before checking in the current container. By default every
|
|
24
|
+
* type is first checked in the default container to return singleton services. This check bypasses the lookup strategy,
|
|
25
|
+
* set in the container so if this behavior is not desired it can be disabled via this flag.
|
|
26
|
+
*
|
|
27
|
+
* The default value is `true`.
|
|
28
|
+
*/
|
|
29
|
+
allowSingletonLookup: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Controls how the child container inherits the service definitions from it's parent. The following values are allowed:
|
|
32
|
+
*
|
|
33
|
+
* - `none` - no metadata is inherited
|
|
34
|
+
* - `definitionOnly` - only metadata is inherited, a new instance will be created for each class
|
|
35
|
+
* - eager classes created as soon as the container is created
|
|
36
|
+
* - non-eager classes are created the first time they are requested
|
|
37
|
+
* - `definitionWithValues` - both metadata and service instances are inherited
|
|
38
|
+
* - when parent class is disposed the instances in this container are preserved
|
|
39
|
+
* - if a service is registered but not created yet, it will be shared when created between the two container
|
|
40
|
+
* - newly registered services won't be shared between the two container
|
|
41
|
+
*
|
|
42
|
+
* The default value is `none`.
|
|
43
|
+
*/
|
|
44
|
+
inheritanceStrategy: 'none' | 'definitionOnly' | 'definitionWithValues';
|
|
45
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var container_options_interface_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(container_options_interface_exports);
|