typeomatica 0.3.39 → 0.3.57

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Type ø matica
1
+ # TypeØmatica
2
2
 
3
3
  [![Coverage Status](https://coveralls.io/repos/github/wentout/typeomatica/badge.svg?branch=main)](https://coveralls.io/github/wentout/typeomatica?branch=main)
4
4
 
@@ -8,37 +8,383 @@
8
8
 
9
9
  [**$ npm install <u>typeomatica</u>**](https://www.npmjs.com/package/typeomatica)
10
10
 
11
-
12
11
  This package is a part of [mnemonica](https://www.npmjs.com/package/mnemonica) project.
13
12
 
14
- Strict Types checker for objects which represent Data Types.
13
+ **Strict Runtime Type Checker for JavaScript Objects**
14
+
15
+ TypeØmatica uses JavaScript Proxies to enforce type safety at runtime, exactly as TypeScript expects at compile time. Once a property is assigned a value, its type is locked and cannot be changed.
16
+
17
+ ---
18
+
19
+ ## Quick Start
20
+
21
+ ```typescript
22
+ import { BaseClass } from 'typeomatica';
23
+
24
+ class User extends BaseClass {
25
+ name: string = 'default';
26
+ age: number = 0;
27
+ }
28
+
29
+ const user = new User();
30
+
31
+ // ✓ Valid assignments
32
+ user.name = 'John';
33
+ user.age = 25;
34
+
35
+ // ✗ Runtime error (even if TypeScript is bypassed with @ts-ignore)
36
+ user.age = '25'; // TypeError: Type Mismatch
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Table of Contents
42
+
43
+ - [What is TypeØmatica?](#what-is-typeomatica)
44
+ - [Installation](#installation)
45
+ - [Core Concepts](#core-concepts)
46
+ - [API Reference](#api-reference)
47
+ - [Usage Patterns](#usage-patterns)
48
+ - [Type Examples](#type-examples)
49
+ - [Working with Wrapped Values](#working-with-wrapped-values)
50
+ - [Error Reference](#error-reference)
51
+ - [Integration with Mnemonica](#integration-with-mnemonica)
52
+
53
+ ---
54
+
55
+ ## What is TypeØmatica?
56
+
57
+ TypeØmatica provides strict runtime type checking for JavaScript objects using Proxy-based interception. It ensures that once a property is initialized with a type, that type cannot be violated at runtime.
58
+
59
+ **Key Features:**
60
+ - Runtime type enforcement (complements TypeScript's compile-time checks)
61
+ - Proxy-based property interception
62
+ - Type locking after initial assignment
63
+ - Prevents prototype mutation, property redefinition, and deletion
64
+
65
+ ---
66
+
67
+ ## Installation
68
+
69
+ ```bash
70
+ npm install typeomatica
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Core Concepts
76
+
77
+ ### How It Works
78
+
79
+ TypeØmatica wraps objects with JavaScript Proxies that intercept:
80
+ - `get` - Property reads
81
+ - `set` - Property writes (with type validation)
82
+ - `setPrototypeOf` - Blocks prototype changes
83
+ - `defineProperty` - Blocks property redefinition
84
+ - `deleteProperty` - Blocks property deletion
85
+
86
+ ### Type Categories
87
+
88
+ | Category | Types | Behavior |
89
+ |----------|-------|----------|
90
+ | `primitives` | string, number, boolean, bigint, symbol, undefined | Type-locked accessors |
91
+ | `nullish` | null | Only null allowed |
92
+ | `objects` | object, arrays, dates | Same constructor type required |
93
+ | `functions` | methods | Restricted on data types |
94
+
95
+ ---
96
+
97
+ ## API Reference
98
+
99
+ ### BaseClass
100
+
101
+ The primary class for strict-type objects.
102
+
103
+ ```typescript
104
+ import { BaseClass } from 'typeomatica';
105
+
106
+ class MyClass extends BaseClass {
107
+ field: string = 'value';
108
+ constructor() {
109
+ super();
110
+ }
111
+ }
112
+ ```
113
+
114
+ ### BasePrototype
115
+
116
+ Functional equivalent of `BaseClass`.
117
+
118
+ ```typescript
119
+ import { BasePrototype } from 'typeomatica';
120
+
121
+ const Base = BasePrototype({ initialProp: 123 });
122
+ class MyClass extends Base { }
123
+ ```
124
+
125
+ ### @Strict() Decorator
126
+
127
+ Apply strict typing without extending BaseClass.
128
+
129
+ ```typescript
130
+ import { Strict } from 'typeomatica';
131
+
132
+ @Strict({ deep: true })
133
+ class MyClass {
134
+ field: number = 0;
135
+ }
136
+ ```
137
+
138
+ **Decorator Arguments:**
139
+ - First argument: Base prototype or options object
140
+ - Second argument: Options object
141
+
142
+ ### Options Interface
143
+
144
+ ```typescript
145
+ interface TypeomaticaOptions {
146
+ strictAccessCheck?: boolean; // default: false
147
+ }
148
+ ```
149
+
150
+ **Options:**
151
+ - `strictAccessCheck: true` - Enables strict receiver checking (throws `ACCESS_DENIED` error when property is accessed from wrong context)
152
+ - `deep: true` - Enable recursive property checking (when using BasePrototype with initial values)
153
+
154
+ ### Usage with Options
155
+
156
+ ```typescript
157
+ // With BaseClass - strict access checking enabled
158
+ class SecureData extends BaseClass {
159
+ secret: string = '';
160
+ constructor() {
161
+ super(undefined, { strictAccessCheck: true });
162
+ }
163
+ }
164
+
165
+ // With BasePrototype - strict access checking enabled
166
+ const SecureBase = BasePrototype({ data: '' }, { strictAccessCheck: true });
167
+ class User extends SecureBase {
168
+ name: string = '';
169
+ }
170
+
171
+ // With @Strict decorator - strict access checking enabled
172
+ @Strict(undefined, { strictAccessCheck: true })
173
+ class Product {
174
+ price: number = 0;
175
+ }
176
+ ```
177
+
178
+ ### Symbol Exports
179
+
180
+ ```typescript
181
+ import {
182
+ SymbolTypeomaticaProxyReference, // Access proxy internals
183
+ SymbolInitialValue // Access original values
184
+ } from 'typeomatica';
185
+ ```
186
+
187
+ ---
15
188
 
16
- # how it works
189
+ ## Usage Patterns
17
190
 
18
- see `test/index.ts`
191
+ ### Pattern 1: Extending BaseClass
19
192
 
20
- ```js
193
+ ```typescript
194
+ import { BaseClass } from 'typeomatica';
21
195
 
22
- class SimpleBase extends BasePrototype {
23
- stringProp = '123';
24
- };
196
+ class User extends BaseClass {
197
+ name: string = '';
198
+ age: number = 0;
199
+ active: boolean = true;
200
+ }
25
201
 
26
- // nect code line will work properly
27
- simpleInstance.stringProp = '321';
202
+ const user = new User();
203
+ user.name = 'John'; // ✓ Works
204
+ user.age = 25; // ✓ Works
28
205
 
29
- // but next code line will throw TypeError('Type Mismatch')
30
206
  // @ts-ignore
31
- simpleInstance.stringProp = 123;
207
+ user.age = '25'; // ✗ TypeError: Type Mismatch
208
+ ```
209
+
210
+ ### Pattern 2: @Strict Decorator
211
+
212
+ ```typescript
213
+ import { Strict } from 'typeomatica';
214
+
215
+ @Strict({ deep: true })
216
+ class Product {
217
+ id: number = 0;
218
+ title: string = '';
219
+ price: number = 0;
220
+ }
32
221
 
222
+ const product = new Product();
223
+ product.price = 29.99; // ✓ Works
224
+ // @ts-ignore
225
+ product.price = '$29.99'; // ✗ TypeError: Type Mismatch
33
226
  ```
34
227
 
35
- That is it. It will be impossible to assign anything else except of:
228
+ ### Pattern 3: BaseClass as Prototype
229
+
230
+ ```typescript
231
+ import { BaseClass } from 'typeomatica';
232
+
233
+ class UserData {
234
+ name: string = 'default';
235
+ age: number = 0;
236
+ }
237
+
238
+ // Inject type checking into prototype chain
239
+ Object.setPrototypeOf(UserData.prototype, new BaseClass({ deep: true }));
36
240
 
37
- ```js
38
- typeof something === 'string'
241
+ const user = new UserData();
242
+ user.name = 'John'; // ✓ Works
243
+ // @ts-ignore
244
+ user.name = 123; // ✗ TypeError: Type Mismatch
39
245
  ```
40
246
 
41
- to `stringProp` in runtime.
247
+ ---
248
+
249
+ ## Type Examples
250
+
251
+ ### Primitives
252
+
253
+ ```typescript
254
+ import { BaseClass } from 'typeomatica';
255
+
256
+ class Primitives extends BaseClass {
257
+ str: string = 'hello';
258
+ num: number = 42;
259
+ bool: boolean = true;
260
+ bigint: bigint = BigInt(100);
261
+ }
262
+
263
+ const p = new Primitives();
264
+ p.str = 'world'; // ✓ Works
265
+ p.num = 100; // ✓ Works
266
+ // @ts-ignore
267
+ p.str = 123; // ✗ TypeError: Type Mismatch
268
+ ```
269
+
270
+ ### Null and Undefined
271
+
272
+ ```typescript
273
+ class Nullable extends BaseClass {
274
+ nullValue: null = null;
275
+ undefinedValue: undefined = undefined;
276
+ }
277
+
278
+ const n = new Nullable();
279
+ n.nullValue = null; // ✓ Works
280
+ // @ts-ignore
281
+ n.nullValue = undefined; // ✗ TypeError: Type Mismatch
282
+ ```
283
+
284
+ ### Objects
285
+
286
+ ```typescript
287
+ class WithObject extends BaseClass {
288
+ data: object = {};
289
+ list: number[] = [];
290
+ }
291
+
292
+ const w = new WithObject();
293
+ w.data = { a: 1 }; // ✓ Works
294
+ w.list = [1, 2, 3]; // ✓ Works
295
+ // @ts-ignore
296
+ w.data = 123; // ✗ TypeError: Type Mismatch
297
+ // @ts-ignore
298
+ w.data = new Set(); // ✗ TypeError: Type Mismatch (Set !== Object)
299
+ ```
300
+
301
+ ---
302
+
303
+ ## Working with Wrapped Values
304
+
305
+ TypeØmatica wraps primitives to enforce type safety. Use `valueOf()` for operations.
306
+
307
+ ### Numeric Operations
308
+
309
+ ```typescript
310
+ class Calc extends BaseClass {
311
+ count: number = 10;
312
+ }
313
+
314
+ const calc = new Calc();
315
+
316
+ // ✗ Direct arithmetic throws
317
+ const result = calc.count + 5; // ReferenceError: Value Access Denied
318
+
319
+ // ✓ Use valueOf()
320
+ const result = calc.count.valueOf() + 5; // 15
321
+ const sum = 3 + +calc.count; // 13
322
+ ```
323
+
324
+ ### String Operations
325
+
326
+ ```typescript
327
+ class Text extends BaseClass {
328
+ message: string = 'hello';
329
+ }
330
+
331
+ const text = new Text();
332
+ text.message.valueOf().toUpperCase(); // 'HELLO'
333
+ text.message.valueOf().length; // 5
334
+ ```
335
+
336
+ ---
337
+
338
+ ## Error Reference
339
+
340
+ | Error Message | Error Type | When Thrown |
341
+ |---------------|------------|-------------|
342
+ | `Type Mismatch` | TypeError | Wrong type assigned to property |
343
+ | `Value Access Denied` | ReferenceError | Property accessed from wrong context (only when `strictAccessCheck: true`) |
344
+ | `Attempt to Access to Undefined Prop` | Error | Reading non-existent property |
345
+ | `Functions are Restricted` | TypeError | Function assigned to data property |
346
+ | `Re-Assirnment is Forbidden` | TypeError | Modifying read-only custom field |
347
+ | `Setting prototype is not allowed` | Error | Calling `Object.setPrototypeOf()` |
348
+ | `Defining new Properties is not allowed` | Error | Calling `Object.defineProperty()` |
349
+ | `Properties Deletion is not allowed` | Error | Calling `delete` on property |
350
+
351
+ ---
352
+
353
+ ## Integration with Mnemonica
354
+
355
+ TypeØmatica integrates seamlessly with [mnemonica](https://www.npmjs.com/package/mnemonica) for combined prototype inheritance and runtime type safety.
356
+
357
+ ```typescript
358
+ import { decorate } from 'mnemonica';
359
+ import { BaseClass, Strict } from 'typeomatica';
360
+
361
+ @decorate()
362
+ @Strict()
363
+ class Entity extends BaseClass {
364
+ id: string = '';
365
+ createdAt: Date = new Date();
366
+ }
367
+
368
+ // Works with mnemonica's inheritance system
369
+ const User = Entity.define('User', function(this: { email: string }) {
370
+ this.email = '';
371
+ });
372
+
373
+ const user = new User();
374
+ // @ts-ignore
375
+ user.email = 123; // ✗ TypeError: Type Mismatch
376
+ ```
377
+
378
+ **Decorator Order Matters:**
379
+ - `@Strict()` must come AFTER `@decorate()` (inner decorator)
380
+ - Decorators apply bottom-to-top
381
+
382
+ For complete integration documentation, see [mnemonica's TypeØmatica guide](https://github.com/wentout/mnemonica/blob/main/core/TypeØmatica.md).
383
+
384
+ ---
385
+
386
+ ## License
387
+
388
+ MIT
42
389
 
43
- As we describe Data Types &mdash; please take a peek for tests directory:
44
- [HERE](https://github.com/wentout/typeomatica/blob/main/test/index.ts).
390
+ Copyright (c) 2019-2024 https://github.com/wentout
package/lib/errors.js CHANGED
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ErrorsNames = void 0;
4
4
  exports.ErrorsNames = {
5
- TYPE_MISMATCH: 'Type Mismatch',
6
- ACCESS_DENIED: 'Value Access Denied',
7
- MISSING_PROP: 'Attempt to Access to Undefined Prop',
8
- RIP_FUNCTIONS: 'Functions are Restricted',
9
- FORBIDDEN_RE: 'Re-Assirnment is Forbidden'
5
+ TYPE_MISMATCH: 'Type Mismatch',
6
+ ACCESS_DENIED: 'Value Access Denied',
7
+ MISSING_PROP: 'Attempt to Access to Undefined Prop',
8
+ RIP_FUNCTIONS: 'Functions are Restricted',
9
+ FORBIDDEN_RE: 'Re-Assirnment is Forbidden'
10
10
  };
11
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2Vycm9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxZQUFZLENBQUM7OztBQUVBLFFBQUEsV0FBVyxHQUFHO0lBQzFCLGFBQWEsRUFBRSxlQUFlO0lBQzlCLGFBQWEsRUFBRSxxQkFBcUI7SUFDcEMsWUFBWSxFQUFFLHFDQUFxQztJQUNuRCxhQUFhLEVBQUUsMEJBQTBCO0lBQ3pDLFlBQVksRUFBRSw0QkFBNEI7Q0FDMUMsQ0FBQyJ9
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2Vycm9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxZQUFZLENBQUM7OztBQUVBLFFBQUEsV0FBVyxHQUFHO0lBQzFCLGFBQWEsRUFBRSxlQUFlO0lBQzlCLGFBQWEsRUFBRSxxQkFBcUI7SUFDcEMsWUFBWSxFQUFFLHFDQUFxQztJQUNuRCxhQUFhLEVBQUUsMEJBQTBCO0lBQ3pDLFlBQVksRUFBRSw0QkFBNEI7Q0FDMUMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIid1c2Ugc3RyaWN0JztcblxuZXhwb3J0IGNvbnN0IEVycm9yc05hbWVzID0ge1xuXHRUWVBFX01JU01BVENIOiAnVHlwZSBNaXNtYXRjaCcsXG5cdEFDQ0VTU19ERU5JRUQ6ICdWYWx1ZSBBY2Nlc3MgRGVuaWVkJyxcblx0TUlTU0lOR19QUk9QOiAnQXR0ZW1wdCB0byBBY2Nlc3MgdG8gVW5kZWZpbmVkIFByb3AnLFxuXHRSSVBfRlVOQ1RJT05TOiAnRnVuY3Rpb25zIGFyZSBSZXN0cmljdGVkJyxcblx0Rk9SQklEREVOX1JFOiAnUmUtQXNzaXJubWVudCBpcyBGb3JiaWRkZW4nXG59OyJdfQ==
package/lib/fields.d.ts CHANGED
@@ -3,10 +3,10 @@ interface FieldDefinition {
3
3
  [SymbolInitialValue]: unknown;
4
4
  }
5
5
  export declare class FieldConstructor implements FieldDefinition {
6
- [SymbolInitialValue]: unknown;
7
- get get(): () => unknown;
8
- get set(): () => never;
9
- constructor(value: unknown);
10
- static get SymbolInitialValue(): symbol;
6
+ [SymbolInitialValue]: unknown;
7
+ get get(): () => unknown;
8
+ get set(): () => never;
9
+ constructor(value: unknown);
10
+ static get SymbolInitialValue(): symbol;
11
11
  }
12
12
  export {};
package/lib/fields.js CHANGED
@@ -1,28 +1,29 @@
1
1
  'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FieldConstructor = void 0;
4
- const errors_1 = require('./errors');
4
+ const errors_1 = require("./errors");
5
5
  const SymbolInitialValue = Symbol('Initial Value');
6
6
  class FieldConstructor {
7
- get get() {
8
- const self = this;
9
- return function () {
10
- return self[SymbolInitialValue];
11
- };
12
- }
13
- get set() {
14
- return function () {
15
- throw new TypeError(errors_1.ErrorsNames.FORBIDDEN_RE);
16
- };
17
- }
18
- constructor(value) {
19
- this[SymbolInitialValue] = value;
20
- }
21
- static get SymbolInitialValue() {
22
- return SymbolInitialValue;
23
- }
7
+ [SymbolInitialValue];
8
+ get get() {
9
+ const self = this;
10
+ return function () {
11
+ return self[SymbolInitialValue];
12
+ };
13
+ }
14
+ get set() {
15
+ return function () {
16
+ throw new TypeError(errors_1.ErrorsNames.FORBIDDEN_RE);
17
+ };
18
+ }
19
+ constructor(value) {
20
+ this[SymbolInitialValue] = value;
21
+ }
22
+ static get SymbolInitialValue() {
23
+ return SymbolInitialValue;
24
+ }
24
25
  }
25
26
  exports.FieldConstructor = FieldConstructor;
26
27
  Object.freeze(FieldConstructor.prototype);
27
28
  Object.seal(FieldConstructor.prototype);
28
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmllbGRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZpZWxkcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxZQUFZLENBQUM7OztBQUViLHFDQUF1QztBQUV2QyxNQUFNLGtCQUFrQixHQUFHLE1BQU0sQ0FBQyxlQUFlLENBQUMsQ0FBQztBQWVuRCxNQUFhLGdCQUFnQjtJQUU1QixJQUFXLEdBQUc7UUFDYixNQUFNLElBQUksR0FBRyxJQUFJLENBQUM7UUFDbEIsT0FBTztZQUNOLE9BQU8sSUFBSSxDQUFDLGtCQUFrQixDQUFDLENBQUM7UUFDakMsQ0FBQyxDQUFDO0lBQ0gsQ0FBQztJQUNELElBQVcsR0FBRztRQUNiLE9BQU87WUFDTixNQUFNLElBQUksU0FBUyxDQUFDLG9CQUFXLENBQUMsWUFBWSxDQUFDLENBQUM7UUFDL0MsQ0FBQyxDQUFDO0lBQ0gsQ0FBQztJQUNELFlBQWEsS0FBYztRQUMxQixJQUFJLENBQUMsa0JBQWtCLENBQUMsR0FBRyxLQUFLLENBQUM7SUFDbEMsQ0FBQztJQUNELE1BQU0sS0FBSyxrQkFBa0I7UUFDNUIsT0FBTyxrQkFBa0IsQ0FBQztJQUMzQixDQUFDO0NBQ0Q7QUFuQkQsNENBbUJDO0FBb0NELE1BQU0sQ0FBQyxNQUFNLENBQUMsZ0JBQWdCLENBQUMsU0FBUyxDQUFDLENBQUM7QUFDMUMsTUFBTSxDQUFDLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxTQUFTLENBQUMsQ0FBQyJ9
29
+ //# sourceMappingURL=data:application/json;base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XG4vLyBcdFx0dGhyb3cgbmV3IEVycm9yKCdicm9rZW4gYmVoYXZpb3VyOiBhc3NpZ25tZW50IHRvIHNldHRlcicpO1xuLy8gXHR9LFxuLy8gXHRjb25maWd1cmFibGU6IGZhbHNlLFxuLy8gXHRlbnVtZXJhYmxlOiB0cnVlLFxuLy8gXHQvLyB3cml0YWJsZTogZmFsc2Vcbi8vIH0pO1xuXG5PYmplY3QuZnJlZXplKEZpZWxkQ29uc3RydWN0b3IucHJvdG90eXBlKTtcbk9iamVjdC5zZWFsKEZpZWxkQ29uc3RydWN0b3IucHJvdG90eXBlKTtcbiJdfQ==
package/lib/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
+ export interface TypeomaticaOptions {
2
+ strictAccessCheck?: boolean;
3
+ }
4
+ export declare const baseTarget: (_proto?: object) => any;
5
+ export declare const SymbolTypeomaticaProxyReference: unique symbol;
1
6
  export declare const BaseConstructorPrototype: {
2
- new (): unknown;
3
- (): void;
7
+ new <T extends object | {}>(_target?: T, options?: TypeomaticaOptions): T;
8
+ <T extends object | {}, S extends T>(_target?: S extends infer S_1 ? S_1 : {}, options?: TypeomaticaOptions): S;
4
9
  };
5
- export declare class BaseClass extends BaseConstructorPrototype {
10
+ export declare class BaseClass {
11
+ constructor(_target?: object, options?: TypeomaticaOptions);
6
12
  }
7
- export { FieldConstructor } from './fields';
8
13
  export declare const SymbolInitialValue: symbol;
9
- type StrictRuntime = {
10
- <T extends object>(...args: unknown[]): T;
11
- };
12
- export declare const Strict: StrictRuntime;
14
+ export declare const Strict: (_target?: object, options?: TypeomaticaOptions) => <T>(cstr: T) => T;