@epsilon-asi/foundation 0.0.6 → 0.0.7

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 (58) hide show
  1. package/LICENSE +147 -0
  2. package/build/decorators/factory/clone.d.ts +1 -1
  3. package/build/decorators/factory/clone.js +23 -8
  4. package/build/decorators/factory/examples/crud.js +3 -1
  5. package/build/decorators/factory/types.d.ts +9 -9
  6. package/build/decorators/types/errors.d.ts +12 -0
  7. package/build/decorators/types/errors.js +13 -0
  8. package/build/decorators/types/extension.d.ts +7 -0
  9. package/build/decorators/types/extension.js +10 -0
  10. package/build/decorators/types/index.d.ts +5 -0
  11. package/build/decorators/types/index.js +24 -0
  12. package/build/decorators/types/typeRegistry.d.ts +2 -0
  13. package/build/decorators/types/typeRegistry.js +353 -0
  14. package/build/decorators/types/types.d.ts +150 -0
  15. package/build/decorators/types/types.js +2 -0
  16. package/build/index.d.ts +1 -0
  17. package/build/index.js +1 -0
  18. package/package.json +7 -4
  19. package/build/decorators/environment/index.d.ts.map +0 -1
  20. package/build/decorators/environment/index.js.map +0 -1
  21. package/build/decorators/factory/clone.d.ts.map +0 -1
  22. package/build/decorators/factory/clone.js.map +0 -1
  23. package/build/decorators/factory/decoratorRegistry.d.ts.map +0 -1
  24. package/build/decorators/factory/decoratorRegistry.js.map +0 -1
  25. package/build/decorators/factory/examples/accessors.d.ts.map +0 -1
  26. package/build/decorators/factory/examples/accessors.js.map +0 -1
  27. package/build/decorators/factory/examples/authorization.d.ts.map +0 -1
  28. package/build/decorators/factory/examples/authorization.js.map +0 -1
  29. package/build/decorators/factory/examples/crud.d.ts.map +0 -1
  30. package/build/decorators/factory/examples/crud.js.map +0 -1
  31. package/build/decorators/factory/examples/orm.d.ts.map +0 -1
  32. package/build/decorators/factory/examples/orm.js.map +0 -1
  33. package/build/decorators/factory/examples/routing.d.ts.map +0 -1
  34. package/build/decorators/factory/examples/routing.js.map +0 -1
  35. package/build/decorators/factory/examples/runExamples.d.ts.map +0 -1
  36. package/build/decorators/factory/examples/runExamples.js.map +0 -1
  37. package/build/decorators/factory/examples/serialization.d.ts.map +0 -1
  38. package/build/decorators/factory/examples/serialization.js.map +0 -1
  39. package/build/decorators/factory/examples/validation.d.ts.map +0 -1
  40. package/build/decorators/factory/examples/validation.js.map +0 -1
  41. package/build/decorators/factory/index.d.ts.map +0 -1
  42. package/build/decorators/factory/index.js.map +0 -1
  43. package/build/decorators/factory/snapshot.d.ts.map +0 -1
  44. package/build/decorators/factory/snapshot.js.map +0 -1
  45. package/build/decorators/factory/symbolMetadata.d.ts.map +0 -1
  46. package/build/decorators/factory/symbolMetadata.js.map +0 -1
  47. package/build/decorators/factory/type-tests/decoratorRegistry.type-test.d.ts +0 -1
  48. package/build/decorators/factory/type-tests/decoratorRegistry.type-test.js +0 -458
  49. package/build/decorators/factory/types.d.ts.map +0 -1
  50. package/build/decorators/factory/types.js.map +0 -1
  51. package/build/decorators/requests/mapping.d.ts.map +0 -1
  52. package/build/decorators/requests/mapping.js.map +0 -1
  53. package/build/decorators/validation/ValidatableClass.d.ts.map +0 -1
  54. package/build/decorators/validation/ValidatableClass.js.map +0 -1
  55. package/build/decorators/validation/validatable.d.ts.map +0 -1
  56. package/build/decorators/validation/validatable.js.map +0 -1
  57. package/build/index.d.ts.map +0 -1
  58. package/build/index.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,147 @@
1
+ Epsilon ASI Source-Available License
2
+ Version 1.0
3
+
4
+ Copyright (c) 2026 Epsilon ASI. All rights reserved.
5
+
6
+ This license governs use of the software and accompanying files in this
7
+ repository and in the npm packages published from it under the @epsilon-asi
8
+ scope (together, the "Software"). The Software is licensed, not sold. By
9
+ using, copying, modifying, or contributing to the Software you agree to these
10
+ terms. If you do not agree, you may not use the Software.
11
+
12
+ 1. DEFINITIONS
13
+
14
+ "Licensor" means Epsilon ASI, the copyright holder.
15
+ "You" means the individual or legal entity exercising rights under this
16
+ license.
17
+ "Application" means a software product or service that You create which
18
+ uses the Software, or a Modified Version of it, as a component and whose
19
+ primary purpose and value are not the functionality of the Software itself.
20
+ "Modified Version" means any copy of the Software that You have altered,
21
+ extended, or combined with other code, including forks.
22
+ "Official Repository" means the source code repository for the Software
23
+ that is designated and controlled by the Licensor.
24
+ "Contribution" means any modification, addition, or other work that You
25
+ intentionally submit to the Licensor for inclusion in the Software.
26
+
27
+ 2. GRANT OF RIGHTS
28
+
29
+ Subject to the restrictions in Section 3, the Licensor grants You a
30
+ worldwide, royalty-free, non-exclusive, non-transferable license to:
31
+
32
+ a. Install, use, copy, and fork the Software, and create Modified
33
+ Versions of it, for Your own internal use and for use in Your
34
+ Applications, including commercial Applications.
35
+
36
+ b. Distribute the Software or a Modified Version only as an integrated,
37
+ non-separable component of Your Applications, and only to the extent
38
+ necessary for those Applications to run.
39
+
40
+ c. Read, study, and modify the source code of the Software for any purpose
41
+ permitted by this license, including preparing a Contribution.
42
+
43
+ d. Maintain a public or private fork of the Official Repository for the
44
+ purposes in 2(a) and 2(c), provided the fork retains this license and
45
+ all notices, and is not distributed or offered in any way prohibited by
46
+ Section 3.
47
+
48
+ Sale of Your Applications, including Applications built with the Software
49
+ or a Modified Version, is expressly permitted. Nothing in this license
50
+ restricts how You price, license, or distribute Your own Applications.
51
+
52
+ 3. RESTRICTIONS
53
+
54
+ Except as expressly permitted in Section 2, You may not:
55
+
56
+ a. Distribute, publish, sublicense, rent, lease, lend, sell, or resell the
57
+ Software or any Modified Version on a standalone basis, as a library,
58
+ framework, SDK, or developer tool, or under a different name or
59
+ package scope, whether for a fee or free of charge.
60
+
61
+ b. Offer the Software or any Modified Version, or any product or service
62
+ whose primary purpose and value are the functionality of the Software,
63
+ to third parties as a hosted, managed, or embedded service, or as a
64
+ product that competes with the Software or with any product the
65
+ Licensor provides using the Software.
66
+
67
+ c. Remove, obscure, or alter any copyright, license, or attribution notice
68
+ in the Software or any Modified Version, or relicense the Software or
69
+ any Modified Version under different terms.
70
+
71
+ d. Use the Licensor's names, logos, or trademarks except to identify the
72
+ Software as the origin of a component of Your Application, or to
73
+ describe a fork accurately as derived from the Software.
74
+
75
+ Where the Licensor has published the Software under a different license
76
+ for a specific version, that license governs that version.
77
+
78
+ 4. CONTRIBUTIONS
79
+
80
+ a. By submitting a Contribution You grant the Licensor a perpetual,
81
+ worldwide, irrevocable, royalty-free, non-exclusive license, with the
82
+ right to sublicense, to use, reproduce, modify, distribute, publicly
83
+ display, and otherwise exploit the Contribution as part of the Software
84
+ or otherwise, under this license or any other terms the Licensor
85
+ chooses.
86
+
87
+ b. You represent that You have the right to grant the license in 4(a),
88
+ that the Contribution is Your original work or that You otherwise hold
89
+ the rights necessary to submit it, and that it does not knowingly
90
+ violate any third-party rights.
91
+
92
+ c. Once a Contribution is accepted into the Official Repository it becomes
93
+ part of the Software and is governed by this license. You retain
94
+ copyright in Your Contribution but may not exercise rights in the
95
+ combined Software beyond those granted in Section 2.
96
+
97
+ d. The Licensor is under no obligation to accept any Contribution.
98
+
99
+ 5. OWNERSHIP
100
+
101
+ The Software is protected by copyright and other intellectual property
102
+ laws. The Licensor retains all right, title, and interest in and to the
103
+ Software not expressly granted to You in this license. You own the
104
+ copyright in the original portions of Your Modified Versions, subject to
105
+ the Licensor's rights in the underlying Software and the restrictions in
106
+ Section 3.
107
+
108
+ 6. TERMINATION
109
+
110
+ This license terminates automatically if You breach any of its terms. On
111
+ termination You must stop using and distributing the Software and any
112
+ Modified Version and destroy all copies in Your possession, except that
113
+ Applications already distributed to end users in compliance with Section
114
+ 2(b) before termination may continue to be used by those end users.
115
+ Sections 4, 5, 7, 8, and 9 survive termination.
116
+
117
+ 7. DISCLAIMER OF WARRANTY
118
+
119
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
120
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
121
+ FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT.
122
+
123
+ 8. LIMITATION OF LIABILITY
124
+
125
+ IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
126
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING
127
+ FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
128
+ DEALINGS IN THE SOFTWARE, INCLUDING INDIRECT, INCIDENTAL, SPECIAL, OR
129
+ CONSEQUENTIAL DAMAGES OR LOSS OF PROFITS, EVEN IF ADVISED OF THE
130
+ POSSIBILITY OF SUCH DAMAGES.
131
+
132
+ 9. GENERAL
133
+
134
+ This license is governed by the laws of [STATE / COUNTRY], without regard
135
+ to its conflict-of-law rules. If any provision is held unenforceable, the
136
+ remainder of the license remains in effect. This license is the entire
137
+ agreement between You and the Licensor concerning the Software and
138
+ supersedes any prior understanding. The Licensor may publish revised
139
+ versions of this license; each version of the Software is governed by the
140
+ license text distributed with it.
141
+
142
+ This is not an open-source license as defined by the Open Source Initiative.
143
+ It is a source-available license: the source code is public, and You may use
144
+ it, fork it, modify it, build and sell products with it, and contribute to it
145
+ as described above. You may not resell it, redistribute it or a Modified
146
+ Version as a standalone library or service, or offer it as a competing
147
+ product.
@@ -1,3 +1,3 @@
1
- export declare function cloneDeep<T>(value: T, seen?: WeakMap<object, unknown>): T;
1
+ export declare function cloneDeep<T>(value: T, seen?: WeakMap<object, unknown>, created?: object[]): T;
2
2
  export declare function deepFreeze<T>(value: T, seen?: WeakSet<object>): T;
3
3
  export declare function immutableClone<T>(value: T): T;
@@ -6,7 +6,7 @@ exports.immutableClone = immutableClone;
6
6
  function isObjectLike(value) {
7
7
  return (typeof value === 'object' && value !== null) || typeof value === 'function';
8
8
  }
9
- function cloneDeep(value, seen = new WeakMap()) {
9
+ function cloneDeep(value, seen = new WeakMap(), created) {
10
10
  if (!isObjectLike(value))
11
11
  return value;
12
12
  if (typeof value === 'function')
@@ -15,42 +15,50 @@ function cloneDeep(value, seen = new WeakMap()) {
15
15
  if (existing !== undefined)
16
16
  return existing;
17
17
  if (value instanceof Date) {
18
- return new Date(value.getTime());
18
+ const cloned = new Date(value.getTime());
19
+ created === null || created === void 0 ? void 0 : created.push(cloned);
20
+ return cloned;
19
21
  }
20
22
  if (value instanceof RegExp) {
21
- return new RegExp(value.source, value.flags);
23
+ const cloned = new RegExp(value.source, value.flags);
24
+ created === null || created === void 0 ? void 0 : created.push(cloned);
25
+ return cloned;
22
26
  }
23
27
  if (value instanceof Map) {
24
28
  const cloned = new Map();
25
29
  seen.set(value, cloned);
30
+ created === null || created === void 0 ? void 0 : created.push(cloned);
26
31
  for (const [key, mapValue] of value.entries()) {
27
- cloned.set(cloneDeep(key, seen), cloneDeep(mapValue, seen));
32
+ cloned.set(cloneDeep(key, seen, created), cloneDeep(mapValue, seen, created));
28
33
  }
29
34
  return cloned;
30
35
  }
31
36
  if (value instanceof Set) {
32
37
  const cloned = new Set();
33
38
  seen.set(value, cloned);
39
+ created === null || created === void 0 ? void 0 : created.push(cloned);
34
40
  for (const setValue of value.values()) {
35
- cloned.add(cloneDeep(setValue, seen));
41
+ cloned.add(cloneDeep(setValue, seen, created));
36
42
  }
37
43
  return cloned;
38
44
  }
39
45
  if (Array.isArray(value)) {
40
46
  const cloned = [];
41
47
  seen.set(value, cloned);
48
+ created === null || created === void 0 ? void 0 : created.push(cloned);
42
49
  for (const item of value)
43
- cloned.push(cloneDeep(item, seen));
50
+ cloned.push(cloneDeep(item, seen, created));
44
51
  return cloned;
45
52
  }
46
53
  const cloned = Object.create(Object.getPrototypeOf(value));
47
54
  seen.set(value, cloned);
55
+ created === null || created === void 0 ? void 0 : created.push(cloned);
48
56
  for (const key of Reflect.ownKeys(value)) {
49
57
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
50
58
  if (descriptor === undefined)
51
59
  continue;
52
60
  if ('value' in descriptor) {
53
- descriptor.value = cloneDeep(descriptor.value, seen);
61
+ descriptor.value = cloneDeep(descriptor.value, seen, created);
54
62
  }
55
63
  Object.defineProperty(cloned, key, descriptor);
56
64
  }
@@ -81,5 +89,12 @@ function deepFreeze(value, seen = new WeakSet()) {
81
89
  return Object.freeze(value);
82
90
  }
83
91
  function immutableClone(value) {
84
- return deepFreeze(cloneDeep(value));
92
+ // Freeze only the objects cloneDeep made. Values it shares by reference (functions, and anything
93
+ // reachable from them) still belong to the caller. A shallow freeze of each is enough: every
94
+ // object cloneDeep made is in `created`, and no getter is invoked along the way.
95
+ const created = [];
96
+ const cloned = cloneDeep(value, new WeakMap(), created);
97
+ for (const node of created)
98
+ Object.freeze(node);
99
+ return cloned;
85
100
  }
@@ -101,7 +101,8 @@ let UserCrud = (() => {
101
101
  })();
102
102
  exports.UserCrud = UserCrud;
103
103
  function buildCrudSummary() {
104
- const snapshot = registry.read(UserCrud);
104
+ const testUser = new UserCrud();
105
+ const snapshot = registry.read(testUser);
105
106
  const resource = snapshot.firstClass('resource');
106
107
  if (resource === undefined)
107
108
  throw new Error('Missing @Resource metadata.');
@@ -118,3 +119,4 @@ function buildCrudSummary() {
118
119
  }),
119
120
  };
120
121
  }
122
+ console.log(buildCrudSummary());
@@ -52,20 +52,20 @@ export interface DecorationRecord {
52
52
  private: boolean;
53
53
  order: number;
54
54
  }
55
- export interface RegistryMetadataSnapshot {
55
+ export interface RegistryMetadataSnapshot<DecoratorName extends string = string> {
56
56
  readonly all: readonly DecorationRecord[];
57
57
  readonly classes: readonly DecorationRecord[];
58
58
  readonly properties: readonly DecorationRecord[];
59
59
  readonly methods: readonly DecorationRecord[];
60
60
  readonly accessors: readonly DecorationRecord[];
61
- firstClass(decorator: string): DecorationRecord | undefined;
62
- classRecords(decorator?: string): readonly DecorationRecord[];
63
- propertyRecords(decorator?: string): readonly DecorationRecord[];
64
- methodRecords(decorator?: string): readonly DecorationRecord[];
65
- accessorRecords(decorator?: string): readonly DecorationRecord[];
66
- propertyMap(decorator?: string): ReadonlyMap<string | symbol, readonly DecorationRecord[]>;
67
- methodMap(decorator?: string): ReadonlyMap<string | symbol, readonly DecorationRecord[]>;
68
- accessorMap(decorator?: string): ReadonlyMap<string | symbol, readonly DecorationRecord[]>;
61
+ firstClass(decorator: DecoratorName): DecorationRecord | undefined;
62
+ classRecords(decorator?: DecoratorName): readonly DecorationRecord[];
63
+ propertyRecords(decorator?: DecoratorName): readonly DecorationRecord[];
64
+ methodRecords(decorator?: DecoratorName): readonly DecorationRecord[];
65
+ accessorRecords(decorator?: DecoratorName): readonly DecorationRecord[];
66
+ propertyMap(decorator?: DecoratorName): ReadonlyMap<string | symbol, readonly DecorationRecord[]>;
67
+ methodMap(decorator?: DecoratorName): ReadonlyMap<string | symbol, readonly DecorationRecord[]>;
68
+ accessorMap(decorator?: DecoratorName): ReadonlyMap<string | symbol, readonly DecorationRecord[]>;
69
69
  }
70
70
  export interface CreateDecoratorRegistryOptions {
71
71
  namespace?: string;
@@ -0,0 +1,12 @@
1
+ export interface TypeRegistryErrorDetails {
2
+ typeName?: string;
3
+ field?: string;
4
+ extension?: string;
5
+ cause?: unknown;
6
+ }
7
+ export declare class TypeRegistryError extends Error {
8
+ readonly typeName?: string;
9
+ readonly field?: string;
10
+ readonly extension?: string;
11
+ constructor(message: string, details?: TypeRegistryErrorDetails);
12
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeRegistryError = void 0;
4
+ class TypeRegistryError extends Error {
5
+ constructor(message, details = {}) {
6
+ super(message, details.cause !== undefined ? { cause: details.cause } : undefined);
7
+ this.name = 'TypeRegistryError';
8
+ this.typeName = details.typeName;
9
+ this.field = details.field;
10
+ this.extension = details.extension;
11
+ }
12
+ }
13
+ exports.TypeRegistryError = TypeRegistryError;
@@ -0,0 +1,7 @@
1
+ import type { z } from 'zod/v4';
2
+ import type { TypeExtension } from './types';
3
+ /**
4
+ * Declares a type extension. Exists for inference: the key stays a literal and the
5
+ * `decorators` callback is typed by the `field` and `type` option schemas.
6
+ */
7
+ export declare function defineTypeExtension<TKey extends string, TField extends z.ZodType | undefined = undefined, TType extends z.ZodType | undefined = undefined, TDecorators extends object = {}>(extension: TypeExtension<TKey, TField, TType, TDecorators>): TypeExtension<TKey, TField, TType, TDecorators>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineTypeExtension = defineTypeExtension;
4
+ /**
5
+ * Declares a type extension. Exists for inference: the key stays a literal and the
6
+ * `decorators` callback is typed by the `field` and `type` option schemas.
7
+ */
8
+ function defineTypeExtension(extension) {
9
+ return Object.freeze(Object.assign({}, extension));
10
+ }
@@ -0,0 +1,5 @@
1
+ export { createTypeRegistry } from './typeRegistry';
2
+ export { defineTypeExtension } from './extension';
3
+ export { TypeRegistryError } from './errors';
4
+ export type { TypeRegistryErrorDetails } from './errors';
5
+ export * from './types';
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.TypeRegistryError = exports.defineTypeExtension = exports.createTypeRegistry = void 0;
18
+ var typeRegistry_1 = require("./typeRegistry");
19
+ Object.defineProperty(exports, "createTypeRegistry", { enumerable: true, get: function () { return typeRegistry_1.createTypeRegistry; } });
20
+ var extension_1 = require("./extension");
21
+ Object.defineProperty(exports, "defineTypeExtension", { enumerable: true, get: function () { return extension_1.defineTypeExtension; } });
22
+ var errors_1 = require("./errors");
23
+ Object.defineProperty(exports, "TypeRegistryError", { enumerable: true, get: function () { return errors_1.TypeRegistryError; } });
24
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,2 @@
1
+ import type { CreateTypeRegistryOptions, TypeRegistry } from './types';
2
+ export declare function createTypeRegistry(options?: CreateTypeRegistryOptions): TypeRegistry;