protoobject 2.1.1 → 2.1.3

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 (60) hide show
  1. package/{lib → dist}/cjs/classes/proto-object-sqlite.js +4 -4
  2. package/{lib → dist}/cjs/classes/proto-object-stream.js +9 -5
  3. package/{lib → dist}/cjs/utils/protoobject-factory.js +2 -2
  4. package/{lib → dist}/esm/classes/proto-object-sqlite.js +2 -2
  5. package/{lib → dist}/esm/classes/proto-object-stream.js +2 -1
  6. package/{lib → dist}/esm/utils/protoobject-factory.js +1 -1
  7. package/{lib → dist/types}/classes/proto-object-sqlite.d.ts +2 -2
  8. package/{lib → dist/types}/classes/proto-object.d.ts +3 -3
  9. package/{lib → dist/types}/types/collection-transformer.d.ts +1 -1
  10. package/{lib → dist/types}/types/dynamic-methods.d.ts +1 -1
  11. package/{lib → dist/types}/types/record-transformer.d.ts +1 -1
  12. package/{lib → dist/types}/types/static-methods.d.ts +6 -6
  13. package/{lib → dist/types}/utils/protoobject-browser-storage.d.ts +4 -4
  14. package/{lib → dist/types}/utils/protoobject-factory.d.ts +2 -2
  15. package/package.json +24 -19
  16. /package/{lib → dist}/cjs/browser.js +0 -0
  17. /package/{lib → dist}/cjs/classes/proto-object-crypto.js +0 -0
  18. /package/{lib → dist}/cjs/classes/proto-object-fs.js +0 -0
  19. /package/{lib → dist}/cjs/classes/proto-object-tcp.js +0 -0
  20. /package/{lib → dist}/cjs/classes/proto-object.js +0 -0
  21. /package/{lib → dist}/cjs/decorators/static-implements.js +0 -0
  22. /package/{lib → dist}/cjs/index.js +0 -0
  23. /package/{lib → dist}/cjs/package.json +0 -0
  24. /package/{lib → dist}/cjs/types/any-object.js +0 -0
  25. /package/{lib → dist}/cjs/types/browser-storage.js +0 -0
  26. /package/{lib → dist}/cjs/types/collection-transformer.js +0 -0
  27. /package/{lib → dist}/cjs/types/dynamic-methods.js +0 -0
  28. /package/{lib → dist}/cjs/types/record-transformer.js +0 -0
  29. /package/{lib → dist}/cjs/types/static-methods.js +0 -0
  30. /package/{lib → dist}/cjs/types/unknown-object.js +0 -0
  31. /package/{lib → dist}/cjs/types/validator-function.js +0 -0
  32. /package/{lib → dist}/cjs/utils/protoobject-browser-storage.js +0 -0
  33. /package/{lib → dist}/esm/browser.js +0 -0
  34. /package/{lib → dist}/esm/classes/proto-object-crypto.js +0 -0
  35. /package/{lib → dist}/esm/classes/proto-object-fs.js +0 -0
  36. /package/{lib → dist}/esm/classes/proto-object-tcp.js +0 -0
  37. /package/{lib → dist}/esm/classes/proto-object.js +0 -0
  38. /package/{lib → dist}/esm/decorators/static-implements.js +0 -0
  39. /package/{lib → dist}/esm/index.js +0 -0
  40. /package/{lib → dist}/esm/package.json +0 -0
  41. /package/{lib → dist}/esm/types/any-object.js +0 -0
  42. /package/{lib → dist}/esm/types/browser-storage.js +0 -0
  43. /package/{lib → dist}/esm/types/collection-transformer.js +0 -0
  44. /package/{lib → dist}/esm/types/dynamic-methods.js +0 -0
  45. /package/{lib → dist}/esm/types/record-transformer.js +0 -0
  46. /package/{lib → dist}/esm/types/static-methods.js +0 -0
  47. /package/{lib → dist}/esm/types/unknown-object.js +0 -0
  48. /package/{lib → dist}/esm/types/validator-function.js +0 -0
  49. /package/{lib → dist}/esm/utils/protoobject-browser-storage.js +0 -0
  50. /package/{lib → dist/types}/browser.d.ts +0 -0
  51. /package/{lib → dist/types}/classes/proto-object-crypto.d.ts +0 -0
  52. /package/{lib → dist/types}/classes/proto-object-fs.d.ts +0 -0
  53. /package/{lib → dist/types}/classes/proto-object-stream.d.ts +0 -0
  54. /package/{lib → dist/types}/classes/proto-object-tcp.d.ts +0 -0
  55. /package/{lib → dist/types}/decorators/static-implements.d.ts +0 -0
  56. /package/{lib → dist/types}/index.d.ts +0 -0
  57. /package/{lib → dist/types}/types/any-object.d.ts +0 -0
  58. /package/{lib → dist/types}/types/browser-storage.d.ts +0 -0
  59. /package/{lib → dist/types}/types/unknown-object.d.ts +0 -0
  60. /package/{lib → dist/types}/types/validator-function.d.ts +0 -0
@@ -40,8 +40,8 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.ProtoObjectSQLite = exports.RecordState = void 0;
42
42
  const node_crypto_1 = require("node:crypto");
43
- const proto_object_1 = require("./proto-object");
44
- const static_implements_1 = require("../decorators/static-implements");
43
+ const proto_object_js_1 = require("./proto-object.js");
44
+ const static_implements_js_1 = require("../decorators/static-implements.js");
45
45
  /* eslint-disable no-unused-vars, @typescript-eslint/no-shadow */
46
46
  var RecordState;
47
47
  (function (RecordState) {
@@ -54,11 +54,11 @@ var RecordState;
54
54
  * Extends ProtoObject with database operations using node:sqlite
55
55
  */
56
56
  let ProtoObjectSQLite = (() => {
57
- let _classDecorators = [(0, static_implements_1.StaticImplements)()];
57
+ let _classDecorators = [(0, static_implements_js_1.StaticImplements)()];
58
58
  let _classDescriptor;
59
59
  let _classExtraInitializers = [];
60
60
  let _classThis;
61
- let _classSuper = proto_object_1.ProtoObject;
61
+ let _classSuper = proto_object_js_1.ProtoObject;
62
62
  var ProtoObjectSQLite = _classThis = class extends _classSuper {
63
63
  constructor(data) {
64
64
  super(data);
@@ -4,11 +4,15 @@
4
4
  * @description Provides methods for efficient streaming serialization and deserialization
5
5
  * @author Siarhei Dudko <siarhei@dudko.dev>
6
6
  */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
7
10
  Object.defineProperty(exports, "__esModule", { value: true });
8
11
  exports.ProtoObjectStream = void 0;
9
12
  /* eslint-disable no-unused-vars */
10
13
  const node_stream_1 = require("node:stream");
11
- const objectstream_1 = require("@sergdudko/objectstream");
14
+ const objectstream_1 = __importDefault(require("@sergdudko/objectstream"));
15
+ const { Stringifer, Parser } = objectstream_1.default;
12
16
  /**
13
17
  * Utility class for streaming ProtoObject serialization using @sergdudko/objectstream
14
18
  */
@@ -26,7 +30,7 @@ class ProtoObjectStream {
26
30
  const plainObject = chunk && typeof chunk.toJSON === "function"
27
31
  ? chunk.toJSON()
28
32
  : chunk;
29
- const stringifer = new objectstream_1.Stringifer();
33
+ const stringifer = new Stringifer();
30
34
  let result = "";
31
35
  stringifer.on("data", (data) => {
32
36
  result += data.toString();
@@ -56,7 +60,7 @@ class ProtoObjectStream {
56
60
  objectMode: true,
57
61
  transform(chunk, encoding, callback) {
58
62
  try {
59
- const parser = new objectstream_1.Parser();
63
+ const parser = new Parser();
60
64
  parser.on("data", (obj) => {
61
65
  // Convert plain object back to ProtoObject instance if fromJSON exists
62
66
  const result = objectClass && typeof objectClass.fromJSON === "function"
@@ -99,7 +103,7 @@ class ProtoObjectStream {
99
103
  try {
100
104
  if (Buffer.isBuffer(chunk)) {
101
105
  // Buffer to object - deserialize
102
- const parser = new objectstream_1.Parser();
106
+ const parser = new Parser();
103
107
  parser.on("data", (obj) => {
104
108
  const result = objectClass &&
105
109
  typeof objectClass.fromJSON === "function"
@@ -118,7 +122,7 @@ class ProtoObjectStream {
118
122
  !Buffer.isBuffer(chunk)) {
119
123
  // Object to buffer - serialize (but not if it's already a Buffer)
120
124
  const plainObject = chunk.toJSON();
121
- const stringifer = new objectstream_1.Stringifer();
125
+ const stringifer = new Stringifer();
122
126
  let result = "";
123
127
  stringifer.on("data", (data) => {
124
128
  result += data.toString();
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.protoObjectFactory = protoObjectFactory;
4
- const proto_object_1 = require("../classes/proto-object");
4
+ const proto_object_js_1 = require("../classes/proto-object.js");
5
5
  /**
6
6
  * A factory for creating classes based on the ProtoObject class
7
7
  *
@@ -9,7 +9,7 @@ const proto_object_1 = require("../classes/proto-object");
9
9
  * @returns - an ProtoObject's heir
10
10
  */
11
11
  function protoObjectFactory(methods) {
12
- class CProtoObject extends proto_object_1.ProtoObject {
12
+ class CProtoObject extends proto_object_js_1.ProtoObject {
13
13
  constructor(data) {
14
14
  super(data);
15
15
  if (methods) {
@@ -37,8 +37,8 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
37
37
  return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
38
38
  };
39
39
  import { randomUUID } from "node:crypto";
40
- import { ProtoObject } from "./proto-object";
41
- import { StaticImplements } from "../decorators/static-implements";
40
+ import { ProtoObject } from "./proto-object.js";
41
+ import { StaticImplements } from "../decorators/static-implements.js";
42
42
  /* eslint-disable no-unused-vars, @typescript-eslint/no-shadow */
43
43
  export var RecordState;
44
44
  (function (RecordState) {
@@ -5,7 +5,8 @@
5
5
  */
6
6
  /* eslint-disable no-unused-vars */
7
7
  import { Transform } from "node:stream";
8
- import { Stringifer, Parser } from "@sergdudko/objectstream";
8
+ import pkg from "@sergdudko/objectstream";
9
+ const { Stringifer, Parser } = pkg;
9
10
  /**
10
11
  * Utility class for streaming ProtoObject serialization using @sergdudko/objectstream
11
12
  */
@@ -1,4 +1,4 @@
1
- import { ProtoObject } from "../classes/proto-object";
1
+ import { ProtoObject } from "../classes/proto-object.js";
2
2
  /**
3
3
  * A factory for creating classes based on the ProtoObject class
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { DatabaseSync } from "node:sqlite";
2
- import { ProtoObject } from "./proto-object";
3
- import { ProtoObjectStaticMethods } from "../types/static-methods";
2
+ import { ProtoObject } from "./proto-object.js";
3
+ import { ProtoObjectStaticMethods } from "../types/static-methods.js";
4
4
  export declare enum RecordState {
5
5
  ACTIVE = 0,
6
6
  DELETED = 1
@@ -1,6 +1,6 @@
1
- import { UnknownObject } from "../types/unknown-object";
2
- import { ProtoObjectDynamicMethods } from "../types/dynamic-methods";
3
- import { ValidatorFunction } from "../types/validator-function";
1
+ import { UnknownObject } from "../types/unknown-object.js";
2
+ import { ProtoObjectDynamicMethods } from "../types/dynamic-methods.js";
3
+ import { ValidatorFunction } from "../types/validator-function.js";
4
4
  /**
5
5
  * A universal class for creating any JSON objects and simple manipulations with them.
6
6
  */
@@ -1,4 +1,4 @@
1
- import { ProtoObjectDynamicMethods } from "./dynamic-methods";
1
+ import { ProtoObjectDynamicMethods } from "./dynamic-methods.js";
2
2
  /**
3
3
  * A data transformer for the array of ProtoObject classes or its heirs
4
4
  *
@@ -1,4 +1,4 @@
1
- import { AnyObject } from "./any-object";
1
+ import { AnyObject } from "./any-object.js";
2
2
  /**
3
3
  * Dynamic methods of the ProtoObject class and its heirs
4
4
  */
@@ -1,4 +1,4 @@
1
- import { ProtoObjectDynamicMethods } from "./dynamic-methods";
1
+ import { ProtoObjectDynamicMethods } from "./dynamic-methods.js";
2
2
  /**
3
3
  * A data transformer for the ProtoObject class or its heir
4
4
  *
@@ -1,9 +1,9 @@
1
- import { AnyObject } from "./any-object";
2
- import { UnknownObject } from "./unknown-object";
3
- import { RecordTransformer } from "./record-transformer";
4
- import { ProtoObjectDynamicMethods } from "./dynamic-methods";
5
- import { CollectionTransformer } from "./collection-transformer";
6
- import { ValidatorFunction } from "./validator-function";
1
+ import { AnyObject } from "./any-object.js";
2
+ import { UnknownObject } from "./unknown-object.js";
3
+ import { RecordTransformer } from "./record-transformer.js";
4
+ import { ProtoObjectDynamicMethods } from "./dynamic-methods.js";
5
+ import { CollectionTransformer } from "./collection-transformer.js";
6
+ import { ValidatorFunction } from "./validator-function.js";
7
7
  /**
8
8
  * Static methods of the ProtoObject class and its heirs
9
9
  */
@@ -1,7 +1,7 @@
1
- import { ProtoObject } from "../classes/proto-object";
2
- import { ProtoObjectStaticMethods } from "../types/static-methods";
3
- import type { StorageType, StorageOptions } from "../types/browser-storage";
4
- export type { StorageType, StorageOptions } from "../types/browser-storage";
1
+ import { ProtoObject } from "../classes/proto-object.js";
2
+ import { ProtoObjectStaticMethods } from "../types/static-methods.js";
3
+ import type { StorageType, StorageOptions } from "../types/browser-storage.js";
4
+ export type { StorageType, StorageOptions } from "../types/browser-storage.js";
5
5
  /**
6
6
  * Universal ProtoObject browser storage utility
7
7
  * Supports localStorage, sessionStorage, IndexedDB, cookies, BroadcastChannel, and Web Workers
@@ -1,5 +1,5 @@
1
- import { ProtoObjectDynamicMethods } from "../types/dynamic-methods";
2
- import { ProtoObjectStaticMethods } from "../types/static-methods";
1
+ import { ProtoObjectDynamicMethods } from "../types/dynamic-methods.js";
2
+ import { ProtoObjectStaticMethods } from "../types/static-methods.js";
3
3
  /**
4
4
  * A factory for creating classes based on the ProtoObject class
5
5
  *
package/package.json CHANGED
@@ -1,36 +1,40 @@
1
1
  {
2
2
  "name": "protoobject",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "A universal class for creating any JSON objects and simple manipulations with them.",
5
- "main": "./lib/cjs/index.js",
6
- "module": "./lib/esm/index.js",
7
- "types": "./lib/index.d.ts",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.js",
7
+ "types": "./dist/types/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
10
  "import": {
11
- "types": "./lib/index.d.ts",
12
- "default": "./lib/esm/index.js"
11
+ "types": "./dist/types/index.d.ts",
12
+ "default": "./dist/esm/index.js"
13
13
  },
14
14
  "require": {
15
- "types": "./lib/index.d.ts",
16
- "default": "./lib/cjs/index.js"
15
+ "types": "./dist/types/index.d.ts",
16
+ "default": "./dist/cjs/index.js"
17
17
  }
18
18
  },
19
19
  "./browser": {
20
20
  "import": {
21
- "types": "./lib/browser.d.ts",
22
- "default": "./lib/esm/browser.js"
21
+ "types": "./dist/types/browser.d.ts",
22
+ "default": "./dist/esm/browser.js"
23
23
  },
24
24
  "require": {
25
- "types": "./lib/browser.d.ts",
26
- "default": "./lib/cjs/browser.js"
25
+ "types": "./dist/types/browser.d.ts",
26
+ "default": "./dist/cjs/browser.js"
27
27
  }
28
28
  },
29
29
  "./package.json": "./package.json"
30
30
  },
31
- "browser": "./lib/esm/browser.js",
31
+ "browser": "./dist/esm/browser.js",
32
32
  "files": [
33
- "lib/**/*"
33
+ "dist/esm/**/*.js{,on}",
34
+ "dist/cjs/**/*.js{,on}",
35
+ "dist/types/**/*",
36
+ "README.md",
37
+ "LICENSE"
34
38
  ],
35
39
  "scripts": {
36
40
  "test": "npm run test:ts && npm run test:js && npm run test:sql && npm run test:sqlite && npm run test:stream && npm run test:crypto && npm run test:fs && npm run test:tcp && npm run test:browser-node && npm run test:transformers",
@@ -48,13 +52,12 @@
48
52
  "cov": "./node_modules/.bin/nyc npm run test:ts",
49
53
  "lint": "./node_modules/.bin/eslint src/**/*.ts",
50
54
  "prebuild": "npm run lint",
51
- "build": "npm run build:clean && npm run build:cjs && npm run build:esm && npm run build:types && npm run build:package-json && npm run build:fix-esm",
52
- "build:clean": "rm -rf lib",
55
+ "build": "npm run build:clean && npm run build:cjs && npm run build:esm && npm run build:types && npm run build:package-json",
56
+ "build:clean": "rm -rf dist",
53
57
  "build:cjs": "./node_modules/.bin/tsc -p tsconfig.cjs.json",
54
58
  "build:esm": "./node_modules/.bin/tsc -p tsconfig.esm.json",
55
59
  "build:types": "./node_modules/.bin/tsc -p tsconfig.types.json",
56
- "build:package-json": "echo '{\"type\":\"commonjs\"}' > lib/cjs/package.json && echo '{\"type\":\"module\"}' > lib/esm/package.json",
57
- "build:fix-esm": "node fix-esm-imports.js",
60
+ "build:package-json": "echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json && echo '{\"type\":\"module\"}' > dist/esm/package.json",
58
61
  "example:stream-chat:server": "node --import=tsx examples/stream-chat/server.ts",
59
62
  "example:stream-chat:client": "node --import=tsx examples/stream-chat/client.ts",
60
63
  "update": "eval \"$(node -e 'const t = require(`./package.json`);const ignore = require(`./ignoreUpdatesModules.json`);console.log(`npm i ${(Object.keys(t.dependencies || {}).filter((e)=>ignore.base.indexOf(e) === -1).map((e)=>(`${e}@latest`)).join(` `))} --save&&npm i ${(Object.keys(t.devDependencies || {}).filter((e)=>ignore.dev.indexOf(e) === -1).map((e)=>(`${e}@latest`)).join(` `))} --save-dev`);')\""
@@ -110,7 +113,9 @@
110
113
  "typescript": "^5.9.3",
111
114
  "typescript-eslint": "^8.46.1"
112
115
  },
113
- "engines": {},
116
+ "engines": {
117
+ "node": ">=16"
118
+ },
114
119
  "directorie": {
115
120
  "man": "./docs/",
116
121
  "test": "./test/"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes