@tachybase/utils 0.23.40 → 0.23.47

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/lib/registry.js CHANGED
@@ -23,9 +23,8 @@ __export(registry_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(registry_exports);
25
25
  const _Registry = class _Registry {
26
- map = /* @__PURE__ */ new Map();
27
- options;
28
26
  constructor(options = { override: false }) {
27
+ this.map = /* @__PURE__ */ new Map();
29
28
  this.options = options;
30
29
  }
31
30
  register(key, value) {
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
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
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
6
  var __export = (target, all) => {
8
7
  for (var name in all)
@@ -17,7 +16,6 @@ var __copyProps = (to, from, except, desc) => {
17
16
  return to;
18
17
  };
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
19
  var container_instance_class_exports = {};
22
20
  __export(container_instance_class_exports, {
23
21
  ContainerInstance: () => ContainerInstance
@@ -29,42 +27,40 @@ var import_cannot_instantiate_value = require("./error/cannot-instantiate-value.
29
27
  var import_service_not_found = require("./error/service-not-found.error");
30
28
  var import_token = require("./token.class");
31
29
  const _ContainerInstance = class _ContainerInstance {
32
- /** Container instance id. */
33
- id;
34
- /** Metadata for all registered services in this container. */
35
- metadataMap = /* @__PURE__ */ new Map();
36
- /**
37
- * Services registered with 'multiple: true' are saved as simple services
38
- * with a generated token and the mapping between the original ID and the
39
- * generated one is stored here. This is handled like this to allow simplifying
40
- * the inner workings of the service instance.
41
- */
42
- multiServiceIds = /* @__PURE__ */ new Map();
43
- /**
44
- * All registered handlers. The @Inject() decorator uses handlers internally to mark a property for injection.
45
- **/
46
- handlers = [];
47
- static get default() {
48
- if (!this._default) {
49
- this._default = new _ContainerInstance("default");
50
- import_container_registry.ContainerRegistry.registerContainer(this._default);
51
- }
52
- return this._default;
53
- }
54
- /**
55
- * Indicates if the container has been disposed or not.
56
- * Any function call should fail when called after being disposed.
57
- *
58
- * NOTE: Currently not in used
59
- */
60
- disposed = false;
61
30
  constructor(id) {
31
+ /** Metadata for all registered services in this container. */
32
+ this.metadataMap = /* @__PURE__ */ new Map();
33
+ /**
34
+ * Services registered with 'multiple: true' are saved as simple services
35
+ * with a generated token and the mapping between the original ID and the
36
+ * generated one is stored here. This is handled like this to allow simplifying
37
+ * the inner workings of the service instance.
38
+ */
39
+ this.multiServiceIds = /* @__PURE__ */ new Map();
40
+ /**
41
+ * All registered handlers. The @Inject() decorator uses handlers internally to mark a property for injection.
42
+ **/
43
+ this.handlers = [];
44
+ /**
45
+ * Indicates if the container has been disposed or not.
46
+ * Any function call should fail when called after being disposed.
47
+ *
48
+ * NOTE: Currently not in used
49
+ */
50
+ this.disposed = false;
62
51
  this.id = id;
63
52
  if (id !== "default") {
64
53
  import_container_registry.ContainerRegistry.registerContainer(this);
65
54
  this.handlers = _ContainerInstance.default.handlers || [];
66
55
  }
67
56
  }
57
+ static get default() {
58
+ if (!this._default) {
59
+ this._default = new _ContainerInstance("default");
60
+ import_container_registry.ContainerRegistry.registerContainer(this._default);
61
+ }
62
+ return this._default;
63
+ }
68
64
  /**
69
65
  * Checks if the service with given name or type is registered service container.
70
66
  * Optionally, parameters can be passed in case if instance is initialized in the container for the first time.
@@ -337,11 +333,6 @@ const _ContainerInstance = class _ContainerInstance {
337
333
  }
338
334
  };
339
335
  __name(_ContainerInstance, "ContainerInstance");
340
- /**
341
- * The default global container. By default services are registered into this
342
- * container when registered via `Container.set()` or `@Service` decorator.
343
- */
344
- __publicField(_ContainerInstance, "_default");
345
336
  let ContainerInstance = _ContainerInstance;
346
337
  // Annotate the CommonJS export names for ESM import in node:
347
338
  0 && (module.exports = {
@@ -2,7 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
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
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
6
  var __export = (target, all) => {
8
7
  for (var name in all)
@@ -17,7 +16,6 @@ var __copyProps = (to, from, except, desc) => {
17
16
  return to;
18
17
  };
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
19
  var container_registry_class_exports = {};
22
20
  __export(container_registry_class_exports, {
23
21
  ContainerRegistry: () => ContainerRegistry
@@ -89,7 +87,7 @@ __name(_ContainerRegistry, "ContainerRegistry");
89
87
  *
90
88
  * This map doesn't contains the default container.
91
89
  */
92
- __publicField(_ContainerRegistry, "containerMap", /* @__PURE__ */ new Map());
90
+ _ContainerRegistry.containerMap = /* @__PURE__ */ new Map();
93
91
  let ContainerRegistry = _ContainerRegistry;
94
92
  // Annotate the CommonJS export names for ESM import in node:
95
93
  0 && (module.exports = {
@@ -26,8 +26,8 @@ const _CannotInjectValueError = class _CannotInjectValueError extends Error {
26
26
  super();
27
27
  this.target = target;
28
28
  this.propertyName = propertyName;
29
+ this.name = "CannotInjectValueError";
29
30
  }
30
- name = "CannotInjectValueError";
31
31
  get message() {
32
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
33
  }
@@ -23,15 +23,12 @@ __export(cannot_instantiate_value_error_exports, {
23
23
  module.exports = __toCommonJS(cannot_instantiate_value_error_exports);
24
24
  var import_token = require("../token.class");
25
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
26
  constructor(identifier) {
33
27
  var _a, _b;
34
28
  super();
29
+ this.name = "CannotInstantiateValueError";
30
+ /** Normalized identifier name used in the error message. */
31
+ this.normalizedIdentifier = "<UNKNOWN_IDENTIFIER>";
35
32
  if (typeof identifier === "string") {
36
33
  this.normalizedIdentifier = identifier;
37
34
  } else if (identifier instanceof import_token.Token) {
@@ -40,6 +37,9 @@ const _CannotInstantiateValueError = class _CannotInstantiateValueError extends
40
37
  this.normalizedIdentifier = identifier.name ? `MaybeConstructable<${identifier.name}>` : `MaybeConstructable<${(_b = identifier.prototype) == null ? void 0 : _b.name}>`;
41
38
  }
42
39
  }
40
+ get message() {
41
+ return `Cannot instantiate the requested value for the "${this.normalizedIdentifier}" identifier. The related metadata doesn't contain a factory or a type to instantiate.`;
42
+ }
43
43
  };
44
44
  __name(_CannotInstantiateValueError, "CannotInstantiateValueError");
45
45
  let CannotInstantiateValueError = _CannotInstantiateValueError;
@@ -23,15 +23,12 @@ __export(service_not_found_error_exports, {
23
23
  module.exports = __toCommonJS(service_not_found_error_exports);
24
24
  var import_token = require("../token.class");
25
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
26
  constructor(identifier) {
33
27
  var _a, _b;
34
28
  super();
29
+ this.name = "ServiceNotFoundError";
30
+ /** Normalized identifier name used in the error message. */
31
+ this.normalizedIdentifier = "<UNKNOWN_IDENTIFIER>";
35
32
  if (typeof identifier === "string") {
36
33
  this.normalizedIdentifier = identifier;
37
34
  } else if (identifier instanceof import_token.Token) {
@@ -40,6 +37,9 @@ const _ServiceNotFoundError = class _ServiceNotFoundError extends Error {
40
37
  this.normalizedIdentifier = identifier.name ? `MaybeConstructable<${identifier.name}>` : `MaybeConstructable<${(_b = identifier.prototype) == null ? void 0 : _b.name}>`;
41
38
  }
42
39
  }
40
+ get message() {
41
+ 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.`;
42
+ }
43
43
  };
44
44
  __name(_ServiceNotFoundError, "ServiceNotFoundError");
45
45
  let ServiceNotFoundError = _ServiceNotFoundError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/utils",
3
- "version": "0.23.40",
3
+ "version": "0.23.47",
4
4
  "license": "Apache-2.0",
5
5
  "exports": {
6
6
  ".": {