protoobject 1.0.9 → 1.1.1

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/CHANGELOG.md CHANGED
@@ -1,30 +1,46 @@
1
+ # 1.1.1 / 2024-11-19
2
+
3
+ ### :tada: Enhancements
4
+ - Updated dependencies: @eslint/js, eslint, typescript-eslint
5
+
6
+ # 1.1.0 / 2024-11-15
7
+
8
+ ### :tada: Enhancements
9
+
10
+ - Updated types and tests
11
+
1
12
  # 1.0.9 / 2024-11-12
2
13
 
3
14
  ### :tada: Enhancements
15
+
4
16
  - Updated dependencies: typescript-eslint
5
17
 
6
18
  # 1.0.8 / 2024-11-05
7
19
 
8
20
  ### :tada: Enhancements
21
+
9
22
  - Updated dependencies: typescript-eslint
10
23
 
11
24
  # 1.0.7 / 2024-11-02
12
25
 
13
26
  ### :tada: Enhancements
27
+
14
28
  - Updated dependencies: @eslint/js, eslint
15
29
 
16
30
  # 1.0.6 / 2024-10-30
17
31
 
18
32
  ### :tada: Enhancements
33
+
19
34
  - Updated dependencies: typescript-eslint
20
35
 
21
36
  # 1.0.5 / 2024-10-29
22
37
 
23
38
  ### :tada: Enhancements
39
+
24
40
  - Updated dependencies: typescript-eslint
25
41
 
26
42
  # 1.0.4 / 2024-10-28
27
43
 
28
44
  ### :tada: Enhancements
29
- - Updated dependencies: tsx
30
45
 
46
+ - Updated dependencies: tsx
package/README.md CHANGED
@@ -59,7 +59,7 @@ Note that you cannot use static method validation using a decorator in JavaScrip
59
59
 
60
60
  Note the call to `this.assign(data);` in the constructor of your own class. This is due to the code build, which causes your class to first call `super(data);` and then apply the value of the properties specified in the class (if the value is not specified, `undefined` will be applied). This is the reason why `super(data);` will not make an assignment for the properties specified in your class.
61
61
 
62
- ```js
62
+ ```javascript
63
63
  class UserAddress extends ProtoObject {
64
64
  constructor(data) {
65
65
  if (data) this.assign(data);
@@ -76,7 +76,7 @@ class UserAddress extends ProtoObject {
76
76
 
77
77
  You can skip fields with standard types `String`, `Number`, `Boolean` and use a superclass converters (`UserRights?.prototype?.toJSON?.call(this)` and `ProtoObject.fromJSON(data)`) for these types, but you must implement the conversion of the remaining types manually.
78
78
 
79
- ```js
79
+ ```javascript
80
80
  const UserRights = protoObjectFactory({
81
81
  fromJSON(data) {
82
82
  return new this({
@@ -99,9 +99,9 @@ Note that you cannot use static method validation using a decorator in JavaScrip
99
99
 
100
100
  Note the call to `this.assign(data);` in the constructor of your own class. This is due to the code build, which causes your class to first call `super(data);` and then apply the value of the properties specified in the class (if the value is not specified, `undefined` will be applied). This is the reason why `super(data);` will not make an assignment for the properties specified in your class.
101
101
 
102
- You can skip fields with standard types `String`, `Number`, `Boolean` and use a superclass converters (`super.toJSON()` and `super.fromJSON(data)`) for these types, but you must implement the conversion of the remaining types manually.
102
+ You can skip fields with standard types `String`, `Number`, `Boolean` and use a superclass converters (`super.toJSON.call(this)` and `super.fromJSON(data)`) for these types, but you must implement the conversion of the remaining types manually.
103
103
 
104
- ```js
104
+ ```javascript
105
105
  class User extends ProtoObject {
106
106
  constructor(data) {
107
107
  super(data);
@@ -121,7 +121,7 @@ class User extends ProtoObject {
121
121
 
122
122
  toJSON() {
123
123
  return {
124
- ...super.toJSON(),
124
+ ...super.toJSON.call(this),
125
125
  createdAt: this.createdAt.toJSON(),
126
126
  photo:
127
127
  this.photo instanceof Buffer ? this.photo.toString("hex") : undefined,
@@ -160,7 +160,7 @@ Note that to check the static properties of a class, you can use the decorator `
160
160
 
161
161
  Note the call to `this.assign(data);` in the constructor of your own class. This is due to the code build, which causes your class to first call `super(data);` and then apply the value of the properties specified in the class (if the value is not specified, `undefined` will be applied). This is the reason why `super(data);` will not make an assignment for the properties specified in your class.
162
162
 
163
- ```js
163
+ ```typescript
164
164
  @StaticImplements<ProtoObjectStaticMethods<UserAddress>>()
165
165
  export class UserAddress extends ProtoObject<UserAddress> {
166
166
  constructor(data?: Partial<UserAddress>) {
@@ -179,7 +179,7 @@ export class UserAddress extends ProtoObject<UserAddress> {
179
179
 
180
180
  You can skip fields with standard types `String`, `Number`, `Boolean` and use a superclass converters (`UserRights?.prototype?.toJSON?.call(this)` and `ProtoObject.fromJSON(data)`) for these types, but you must implement the conversion of the remaining types manually.
181
181
 
182
- ```js
182
+ ```typescript
183
183
  interface IUserRights extends ProtoObject<IUserRights> {
184
184
  isAdmin: boolean;
185
185
  updatedAt: Date;
@@ -206,9 +206,9 @@ Note that to check the static properties of a class, you can use the decorator `
206
206
 
207
207
  Note the call to `this.assign(data);` in the constructor of your own class. This is due to the code build, which causes your class to first call `super(data);` and then apply the value of the properties specified in the class (if the value is not specified, `undefined` will be applied). This is the reason why `super(data);` will not make an assignment for the properties specified in your class.
208
208
 
209
- You can skip fields with standard types `String`, `Number`, `Boolean` and use a superclass converters (`super.toJSON()` and `super.fromJSON(data)`) for these types, but you must implement the conversion of the remaining types manually.
209
+ You can skip fields with standard types `String`, `Number`, `Boolean` and use a superclass converters (`super.toJSON.call(this)` and `super.fromJSON(data)`) for these types, but you must implement the conversion of the remaining types manually.
210
210
 
211
- ```js
211
+ ```typescript
212
212
  @StaticImplements<ProtoObjectStaticMethods<User>>()
213
213
  class User extends ProtoObject<User> {
214
214
  constructor(data?: Partial<User>) {
@@ -231,7 +231,7 @@ class User extends ProtoObject<User> {
231
231
 
232
232
  public toJSON(): { [key: string]: any } {
233
233
  return {
234
- ...super.toJSON(),
234
+ ...super.toJSON.call(this),
235
235
  createdAt: this.createdAt.toJSON(),
236
236
  photo:
237
237
  this.photo instanceof Buffer ? this.photo.toString("hex") : undefined,
@@ -264,6 +264,195 @@ class User extends ProtoObject<User> {
264
264
  }
265
265
  ```
266
266
 
267
+ ### An example of the implementation of the SQL database base class
268
+
269
+ This is an example of creating a basic (abstract) class for working with an SQLite database. Below is an example of an heir of this class, which is a table entry.
270
+
271
+ ```typescript
272
+ import { randomUUID } from "node:crypto";
273
+ import { DatabaseSync } from "node:sqlite";
274
+ import {
275
+ ProtoObject,
276
+ ProtoObjectStaticMethods,
277
+ StaticImplements,
278
+ } from "protoobject";
279
+
280
+ export enum RecordState {
281
+ ACTIVE,
282
+ DELETED,
283
+ }
284
+
285
+ export interface BaseRecordStaticMethods<T extends BaseRecord<T>>
286
+ extends ProtoObjectStaticMethods<T> {
287
+ table: string;
288
+ getById<T extends BaseRecord<T>>(
289
+ db: DatabaseSync,
290
+ id: BaseRecord<T>["id"]
291
+ ): Promise<T | undefined>;
292
+ }
293
+
294
+ @StaticImplements<BaseRecordStaticMethods<BaseRecord<any>>>()
295
+ export class BaseRecord<T extends BaseRecord<T>> extends ProtoObject<T> {
296
+ constructor(data?: Partial<T>) {
297
+ super(data);
298
+ if (data) this.assign(data);
299
+ if (typeof this.record_state === "undefined")
300
+ this.record_state = RecordState.ACTIVE;
301
+ if (!this.id) this.id = randomUUID();
302
+ const dt = new Date();
303
+ if (!this.created_at) this.created_at = dt;
304
+ if (!this.updated_at) this.updated_at = dt;
305
+ return this;
306
+ }
307
+
308
+ public static table = `base`;
309
+
310
+ public id!: string;
311
+
312
+ public created_at!: Date;
313
+
314
+ public updated_at!: Date;
315
+
316
+ public record_state!: RecordState;
317
+
318
+ public static async getById<T extends BaseRecord<T>>(
319
+ db: DatabaseSync,
320
+ id: BaseRecord<T>["id"]
321
+ ): Promise<T | undefined> {
322
+ const dbRecord = (await db
323
+ .prepare(`SELECT * FROM ${this.table} WHERE id = ?`)
324
+ .get(id)) as Partial<T>;
325
+ return dbRecord ? this.fromJSON<T>(dbRecord) : undefined;
326
+ }
327
+
328
+ public async reload(db: DatabaseSync): Promise<T> {
329
+ const classNode = this.constructor as BaseRecordStaticMethods<T>;
330
+ const dbRecord = await classNode.getById<T>(db, this.id);
331
+ if (!dbRecord) throw new Error("Not Found");
332
+ return this.assign(classNode.fromJSON(dbRecord));
333
+ }
334
+
335
+ public async insert(db: DatabaseSync): Promise<void> {
336
+ const classNode = this.constructor as BaseRecordStaticMethods<T>;
337
+ this.created_at = new Date();
338
+ this.updated_at = new Date();
339
+ const jsonData = this.toJSON();
340
+ await Promise.resolve(
341
+ db
342
+ .prepare(
343
+ `INSERT INTO ${classNode.table} (${Object.keys(jsonData).join(", ")}) VALUES (${Object.keys(
344
+ jsonData
345
+ )
346
+ .map((e, i) => `?`)
347
+ .join(", ")})`
348
+ )
349
+ .run(...Object.values(jsonData))
350
+ );
351
+ return;
352
+ }
353
+
354
+ public async update(db: DatabaseSync): Promise<void> {
355
+ const classNode = this.constructor as BaseRecordStaticMethods<T>;
356
+ this.updated_at = new Date();
357
+ const jsonData = this.toJSON();
358
+ delete jsonData.id;
359
+ await Promise.resolve(
360
+ db
361
+ .prepare(
362
+ `UPDATE ${classNode.table} SET ${Object.keys(jsonData)
363
+ .map((e, i) => `${e} = ?`)
364
+ .join(", ")} WHERE id = ?`
365
+ )
366
+ .run(...Object.values(jsonData), this.id)
367
+ );
368
+ return;
369
+ }
370
+
371
+ public async softDelete(db: DatabaseSync): Promise<void> {
372
+ this.record_state = RecordState.DELETED;
373
+ this.updated_at = new Date();
374
+ await this.update(db);
375
+ return;
376
+ }
377
+
378
+ public async delete(db: DatabaseSync): Promise<void> {
379
+ const classNode = this.constructor as BaseRecordStaticMethods<T>;
380
+ const jsonData = this.toJSON();
381
+ delete jsonData.id;
382
+ await Promise.resolve(
383
+ db.prepare(`DELETE FROM ${classNode.table} WHERE id = ?`).run(this.id)
384
+ );
385
+ return;
386
+ }
387
+
388
+ public static fromJSON<T>(data: { [key: string]: unknown }) {
389
+ return new this({
390
+ ...super.fromJSON(data),
391
+ created_at:
392
+ typeof data.created_at === "string"
393
+ ? new Date(data.created_at)
394
+ : undefined,
395
+ updated_at:
396
+ typeof data.updated_at === "string"
397
+ ? new Date(data.updated_at)
398
+ : undefined,
399
+ }) as T;
400
+ }
401
+
402
+ public toJSON(): { [key: string]: any } {
403
+ return {
404
+ ...super.toJSON.call(this),
405
+ created_at: this.created_at?.toJSON(),
406
+ updated_at: this.updated_at?.toJSON(),
407
+ };
408
+ }
409
+ }
410
+ ```
411
+
412
+ ### An example of the implementation of an heir from the base class of the SQL database
413
+
414
+ An example of a simple implementation of a data class based on a base class.
415
+
416
+ ```typescript
417
+ import { randomUUID } from "crypto";
418
+ import { StaticImplements } from "protoobject";
419
+ import { BaseRecord, BaseRecordStaticMethods } from "./example-base-class";
420
+
421
+ @StaticImplements<BaseRecordStaticMethods<ApplicationRecord>>()
422
+ export class ApplicationRecord extends BaseRecord<ApplicationRecord> {
423
+ constructor(data?: Partial<ApplicationRecord>) {
424
+ super(data);
425
+ if (data) this.assign(data);
426
+ if (!this.api_key) this.api_key = randomUUID();
427
+ }
428
+
429
+ public static override table: string = `applications`;
430
+
431
+ public api_key!: string;
432
+
433
+ public app_name!: PublicKeyCredentialCreationOptions["rp"]["name"];
434
+
435
+ public app_params!: { [key: string]: string | number | boolean | null };
436
+
437
+ public static fromJSON<T>(data: { [key: string]: unknown }) {
438
+ return new ApplicationRecord({
439
+ ...super.fromJSON(data),
440
+ app_params:
441
+ typeof data?.app_params === "string"
442
+ ? JSON.parse(data.app_params)
443
+ : undefined,
444
+ }) as T;
445
+ }
446
+
447
+ public toJSON(): { [key: string]: any } {
448
+ return {
449
+ ...super.toJSON.call(this),
450
+ app_params: this.app_params ? JSON.stringify(this.app_params) : undefined,
451
+ };
452
+ }
453
+ }
454
+ ```
455
+
267
456
  ## LICENSE
268
457
 
269
458
  MIT
@@ -32,7 +32,7 @@ export declare class ProtoObject<T extends ProtoObjectDynamicMethods<T>> impleme
32
32
  * @param options.onlyWritable - return only writable properties
33
33
  * @returns - an array of the properties information
34
34
  */
35
- static getEnumerableProperties<T extends ProtoObjectDynamicMethods<T>>(data: {
35
+ static getEnumerableProperties<T extends ProtoObject<T>>(data: {
36
36
  [key: PropertyKey]: unknown;
37
37
  }, options?: {
38
38
  onlyWritable: boolean;
@@ -51,7 +51,7 @@ export declare class ProtoObject<T extends ProtoObjectDynamicMethods<T>> impleme
51
51
  * @param data - an object such as a ProtoObject or its heir or an object property
52
52
  * @returns - an object such as a ProtoObject or its heir or an object property
53
53
  */
54
- static recursiveAssign<T extends ProtoObjectDynamicMethods<T>, K>(obj: unknown, data?: unknown): K;
54
+ static recursiveAssign<T extends ProtoObject<T>, K>(obj: unknown, data?: unknown): K;
55
55
  /**
56
56
  * Deep assign data to an instance of the ProtoObject class or its heir
57
57
  *
@@ -59,7 +59,7 @@ export declare class ProtoObject<T extends ProtoObjectDynamicMethods<T>> impleme
59
59
  * @param data - a ProtoObject class or its heir or any other object
60
60
  * @returns - a assigned ProtoObject class or its heir
61
61
  */
62
- static deepAssign<T extends ProtoObjectDynamicMethods<T>>(obj: T, data?: Partial<T>): T;
62
+ static deepAssign<T extends ProtoObject<T>>(obj: T, data?: Partial<T>): T;
63
63
  /**
64
64
  * The converter of values into simple types
65
65
  *
@@ -80,7 +80,7 @@ export declare class ProtoObject<T extends ProtoObjectDynamicMethods<T>> impleme
80
80
  * @param data - a simple json data
81
81
  * @returns - a ProtoObject class or its heir
82
82
  */
83
- static fromJSON<T extends ProtoObjectDynamicMethods<T>>(data: {
83
+ static fromJSON<T extends ProtoObject<T>>(data: {
84
84
  [key: string]: unknown;
85
85
  }): T;
86
86
  /**
@@ -118,7 +118,7 @@ export declare class ProtoObject<T extends ProtoObjectDynamicMethods<T>> impleme
118
118
  * @param param0.validatorFrom - data validator when converting to a class
119
119
  * @returns data transformer for the ProtoObject class or its heir
120
120
  */
121
- static recordTransformer<T extends ProtoObjectDynamicMethods<T>>({ validatorTo, validatorFrom, }: {
121
+ static recordTransformer<T extends ProtoObject<T>>({ validatorTo, validatorFrom, }: {
122
122
  validatorTo?: ValidatorFunction<T>;
123
123
  validatorFrom?: ValidatorFunction<UnknownObject>;
124
124
  }): {
@@ -133,7 +133,7 @@ export declare class ProtoObject<T extends ProtoObjectDynamicMethods<T>> impleme
133
133
  * @param param0.validatorFrom - data validator when converting to a class
134
134
  * @returns data transformer for the array of the ProtoObject classes or its heirs
135
135
  */
136
- static collectionTransformer<T extends ProtoObjectDynamicMethods<T>>({ validatorTo, validatorFrom, }: {
136
+ static collectionTransformer<T extends ProtoObject<T>>({ validatorTo, validatorFrom, }: {
137
137
  validatorTo?: ValidatorFunction<T>;
138
138
  validatorFrom?: ValidatorFunction<UnknownObject>;
139
139
  }): {
@@ -1 +1 @@
1
- {"version":3,"file":"proto-object.js","sourceRoot":"","sources":["../../src/classes/proto-object.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACH,MAAa,WAAW;IAGtB;;;;OAIG;IACH,YAAY,IAAiB;QAC3B,OAAO,WAAW,CAAC,UAAU,CAAI,IAAoB,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,aAAa,CAAC,IAE3B;QACC,MAAM,KAAK,GAIL,EAAE,CAAC;QACT,wCAAwC;QACxC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,IAAI,GAAG,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACxD,IAAI,IAAI;gBAAE,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,uBAAuB,CACnC,IAEC,EACD,UAAqC,EAAE,YAAY,EAAE,KAAK,EAAE;QAE5D,MAAM,SAAS,GAAG,IAA8C,CAAC;QACjE,OAAO,SAAS;aACb,aAAa,CAAC,IAAI,CAAC;aACnB,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CACP,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG;YACpB,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG;YACpB,IAAI,CAAC,UAAU,CAAC,UAAU,CAC7B;aACA,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CACf,OAAO,EAAE,YAAY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AAE,EAAE,CACN,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,WAAW,KAAK,UAAU,IAAI,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CACrE;qBACA,GAAG,CAAgB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YAC/C,CAAC;YACD,IAAI,CAAC,OAAgB;gBACnB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;oBAAE,OAAO,SAAS,CAAC;gBAC9C,OAAO,OAAO;qBACX,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CACP,CAAC,CAAC,IAAI;oBACN,CAAC,OAAO,aAAa,KAAK,UAAU,IAAI,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CACjE;qBACA,GAAG,CAAI,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YAChD,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AArUD,kCAqUC"}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "protoobject",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
4
4
  "description": "A universal class for creating any JSON objects and simple manipulations with them.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "scripts": {
8
8
  "test:ts": "node --import=tsx --test test/ts/*.test.ts",
9
9
  "test:js": "node --test test/js/*.test.js",
10
+ "test:sql": "node --experimental-sqlite --import=tsx --test test/sql/*.test.ts",
10
11
  "cov": "./node_modules/.bin/nyc npm run test:ts",
11
12
  "lint": "./node_modules/.bin/eslint src/**/*.ts",
12
13
  "prebuild": "npm run lint",
@@ -51,14 +52,14 @@
51
52
  ],
52
53
  "homepage": "https://github.com/dudko-dev/protoobject",
53
54
  "devDependencies": {
54
- "@eslint/js": "^9.14.0",
55
+ "@eslint/js": "^9.15.0",
55
56
  "@types/node": "^22.4.1",
56
- "eslint": "^9.14.0",
57
+ "eslint": "^9.15.0",
57
58
  "nyc": "^17.1.0",
58
59
  "prettier": "^3.3.3",
59
60
  "tsx": "^4.19.2",
60
61
  "typescript": "^5.6.3",
61
- "typescript-eslint": "^8.14.0"
62
+ "typescript-eslint": "^8.15.0"
62
63
  },
63
64
  "engines": {},
64
65
  "directorie": {