protoobject 1.0.8 → 1.1.0

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,25 +1,41 @@
1
+ # 1.1.0 / 2024-11-15
2
+
3
+ ### :tada: Enhancements
4
+
5
+ - Updated types and tests
6
+
7
+ # 1.0.9 / 2024-11-12
8
+
9
+ ### :tada: Enhancements
10
+
11
+ - Updated dependencies: typescript-eslint
12
+
1
13
  # 1.0.8 / 2024-11-05
2
14
 
3
15
  ### :tada: Enhancements
16
+
4
17
  - Updated dependencies: typescript-eslint
5
18
 
6
19
  # 1.0.7 / 2024-11-02
7
20
 
8
21
  ### :tada: Enhancements
22
+
9
23
  - Updated dependencies: @eslint/js, eslint
10
24
 
11
25
  # 1.0.6 / 2024-10-30
12
26
 
13
27
  ### :tada: Enhancements
28
+
14
29
  - Updated dependencies: typescript-eslint
15
30
 
16
31
  # 1.0.5 / 2024-10-29
17
32
 
18
33
  ### :tada: Enhancements
34
+
19
35
  - Updated dependencies: typescript-eslint
20
36
 
21
37
  # 1.0.4 / 2024-10-28
22
38
 
23
39
  ### :tada: Enhancements
24
- - Updated dependencies: tsx
25
40
 
41
+ - 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,191 @@ 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
+ ```typescript
270
+ import { randomUUID } from "node:crypto";
271
+ import { DatabaseSync } from "node:sqlite";
272
+ import {
273
+ ProtoObject,
274
+ ProtoObjectStaticMethods,
275
+ StaticImplements,
276
+ } from "protoobject";
277
+
278
+ export enum RecordState {
279
+ ACTIVE,
280
+ DELETED,
281
+ }
282
+
283
+ export interface BaseRecordStaticMethods<T extends BaseRecord<T>>
284
+ extends ProtoObjectStaticMethods<T> {
285
+ table: string;
286
+ getById<T extends BaseRecord<T>>(
287
+ db: DatabaseSync,
288
+ id: BaseRecord<T>["id"]
289
+ ): Promise<T | undefined>;
290
+ }
291
+
292
+ @StaticImplements<BaseRecordStaticMethods<BaseRecord<any>>>()
293
+ export class BaseRecord<T extends BaseRecord<T>> extends ProtoObject<T> {
294
+ constructor(data?: Partial<T>) {
295
+ super(data);
296
+ if (data) this.assign(data);
297
+ if (typeof this.record_state === "undefined")
298
+ this.record_state = RecordState.ACTIVE;
299
+ if (!this.id) this.id = randomUUID();
300
+ const dt = new Date();
301
+ if (!this.created_at) this.created_at = dt;
302
+ if (!this.updated_at) this.updated_at = dt;
303
+ return this;
304
+ }
305
+
306
+ public static table = `base`;
307
+
308
+ public id!: string;
309
+
310
+ public created_at!: Date;
311
+
312
+ public updated_at!: Date;
313
+
314
+ public record_state!: RecordState;
315
+
316
+ public static async getById<T extends BaseRecord<T>>(
317
+ db: DatabaseSync,
318
+ id: BaseRecord<T>["id"]
319
+ ): Promise<T | undefined> {
320
+ const dbRecord = (await db
321
+ .prepare(`SELECT * FROM ${this.table} WHERE id = ?`)
322
+ .get(id)) as Partial<T>;
323
+ return dbRecord ? this.fromJSON<T>(dbRecord) : undefined;
324
+ }
325
+
326
+ public async reload(db: DatabaseSync): Promise<T> {
327
+ const classNode = this.constructor as BaseRecordStaticMethods<T>;
328
+ const dbRecord = await classNode.getById<T>(db, this.id);
329
+ if (!dbRecord) throw new Error("Not Found");
330
+ return this.assign(classNode.fromJSON(dbRecord));
331
+ }
332
+
333
+ public async insert(db: DatabaseSync): Promise<void> {
334
+ const classNode = this.constructor as BaseRecordStaticMethods<T>;
335
+ this.created_at = new Date();
336
+ this.updated_at = new Date();
337
+ const jsonData = this.toJSON();
338
+ await Promise.resolve(
339
+ db
340
+ .prepare(
341
+ `INSERT INTO ${classNode.table} (${Object.keys(jsonData).join(", ")}) VALUES (${Object.keys(
342
+ jsonData
343
+ )
344
+ .map((e, i) => `?`)
345
+ .join(", ")})`
346
+ )
347
+ .run(...Object.values(jsonData))
348
+ );
349
+ return;
350
+ }
351
+
352
+ public async update(db: DatabaseSync): Promise<void> {
353
+ const classNode = this.constructor as BaseRecordStaticMethods<T>;
354
+ this.updated_at = new Date();
355
+ const jsonData = this.toJSON();
356
+ delete jsonData.id;
357
+ await Promise.resolve(
358
+ db
359
+ .prepare(
360
+ `UPDATE ${classNode.table} SET ${Object.keys(jsonData)
361
+ .map((e, i) => `${e} = ?`)
362
+ .join(", ")} WHERE id = ?`
363
+ )
364
+ .run(...Object.values(jsonData), this.id)
365
+ );
366
+ return;
367
+ }
368
+
369
+ public async softDelete(db: DatabaseSync): Promise<void> {
370
+ this.record_state = RecordState.DELETED;
371
+ this.updated_at = new Date();
372
+ await this.update(db);
373
+ return;
374
+ }
375
+
376
+ public async delete(db: DatabaseSync): Promise<void> {
377
+ const classNode = this.constructor as BaseRecordStaticMethods<T>;
378
+ const jsonData = this.toJSON();
379
+ delete jsonData.id;
380
+ await Promise.resolve(
381
+ db.prepare(`DELETE FROM ${classNode.table} WHERE id = ?`).run(this.id)
382
+ );
383
+ return;
384
+ }
385
+
386
+ public static fromJSON<T>(data: { [key: string]: unknown }) {
387
+ return new this({
388
+ ...super.fromJSON(data),
389
+ created_at:
390
+ typeof data.created_at === "string"
391
+ ? new Date(data.created_at)
392
+ : undefined,
393
+ updated_at:
394
+ typeof data.updated_at === "string"
395
+ ? new Date(data.updated_at)
396
+ : undefined,
397
+ }) as T;
398
+ }
399
+
400
+ public toJSON(): { [key: string]: any } {
401
+ return {
402
+ ...super.toJSON.call(this),
403
+ created_at: this.created_at?.toJSON(),
404
+ updated_at: this.updated_at?.toJSON(),
405
+ };
406
+ }
407
+ }
408
+ ```
409
+
410
+ ### An example of the implementation of an heir from the base class of the SQL database
411
+
412
+ ```typescript
413
+ import { randomUUID } from "crypto";
414
+ import { StaticImplements } from "protoobject";
415
+ import { BaseRecord, BaseRecordStaticMethods } from "./example-base-class";
416
+
417
+ @StaticImplements<BaseRecordStaticMethods<ApplicationRecord>>()
418
+ export class ApplicationRecord extends BaseRecord<ApplicationRecord> {
419
+ constructor(data?: Partial<ApplicationRecord>) {
420
+ super(data);
421
+ if (data) this.assign(data);
422
+ if (!this.api_key) this.api_key = randomUUID();
423
+ }
424
+
425
+ public static override table: string = `applications`;
426
+
427
+ public api_key!: string;
428
+
429
+ public app_name!: PublicKeyCredentialCreationOptions["rp"]["name"];
430
+
431
+ public app_params!: { [key: string]: string | number | boolean | null };
432
+
433
+ public static fromJSON<T>(data: { [key: string]: unknown }) {
434
+ return new ApplicationRecord({
435
+ ...super.fromJSON(data),
436
+ app_params:
437
+ typeof data?.app_params === "string"
438
+ ? JSON.parse(data.app_params)
439
+ : undefined,
440
+ }) as T;
441
+ }
442
+
443
+ public toJSON(): { [key: string]: any } {
444
+ return {
445
+ ...super.toJSON.call(this),
446
+ app_params: this.app_params ? JSON.stringify(this.app_params) : undefined,
447
+ };
448
+ }
449
+ }
450
+ ```
451
+
267
452
  ## LICENSE
268
453
 
269
454
  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","source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C,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.8",
3
+ "version": "1.1.0",
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",
@@ -58,7 +59,7 @@
58
59
  "prettier": "^3.3.3",
59
60
  "tsx": "^4.19.2",
60
61
  "typescript": "^5.6.3",
61
- "typescript-eslint": "^8.13.0"
62
+ "typescript-eslint": "^8.14.0"
62
63
  },
63
64
  "engines": {},
64
65
  "directorie": {