imean-cassandra-orm 2.3.0 → 2.4.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.
Files changed (3) hide show
  1. package/dist/mod.cjs +31 -6
  2. package/dist/mod.js +31 -6
  3. package/package.json +63 -62
package/dist/mod.cjs CHANGED
@@ -399,7 +399,16 @@ function convertValueToCassandra(value, config) {
399
399
  case "text":
400
400
  return typeof value === "string" ? value : JSON.stringify(value);
401
401
  default:
402
- return value;
402
+ const type = config.type;
403
+ switch (type) {
404
+ case "list<text>":
405
+ case "set<text>":
406
+ return value.map(
407
+ (item) => typeof item === "string" ? item : JSON.stringify(item)
408
+ );
409
+ default:
410
+ return value;
411
+ }
403
412
  }
404
413
  }
405
414
  function convertValueFromCassandra(value, config) {
@@ -420,13 +429,29 @@ function convertValueFromCassandra(value, config) {
420
429
  case "blob":
421
430
  return value instanceof Uint8Array ? value : new Uint8Array(value);
422
431
  case "text":
423
- try {
424
- return JSON.parse(value);
425
- } catch {
426
- return value;
432
+ if (config.type !== "text") {
433
+ try {
434
+ return JSON.parse(value);
435
+ } catch {
436
+ return value;
437
+ }
427
438
  }
428
- default:
429
439
  return value;
440
+ default:
441
+ const type = config.type;
442
+ switch (type) {
443
+ case "list<text>":
444
+ case "set<text>":
445
+ return value.map((item) => {
446
+ try {
447
+ return JSON.parse(item);
448
+ } catch {
449
+ return item;
450
+ }
451
+ });
452
+ default:
453
+ return value;
454
+ }
430
455
  }
431
456
  }
432
457
  var queryHelper = {
package/dist/mod.js CHANGED
@@ -397,7 +397,16 @@ function convertValueToCassandra(value, config) {
397
397
  case "text":
398
398
  return typeof value === "string" ? value : JSON.stringify(value);
399
399
  default:
400
- return value;
400
+ const type = config.type;
401
+ switch (type) {
402
+ case "list<text>":
403
+ case "set<text>":
404
+ return value.map(
405
+ (item) => typeof item === "string" ? item : JSON.stringify(item)
406
+ );
407
+ default:
408
+ return value;
409
+ }
401
410
  }
402
411
  }
403
412
  function convertValueFromCassandra(value, config) {
@@ -418,13 +427,29 @@ function convertValueFromCassandra(value, config) {
418
427
  case "blob":
419
428
  return value instanceof Uint8Array ? value : new Uint8Array(value);
420
429
  case "text":
421
- try {
422
- return JSON.parse(value);
423
- } catch {
424
- return value;
430
+ if (config.type !== "text") {
431
+ try {
432
+ return JSON.parse(value);
433
+ } catch {
434
+ return value;
435
+ }
425
436
  }
426
- default:
427
437
  return value;
438
+ default:
439
+ const type = config.type;
440
+ switch (type) {
441
+ case "list<text>":
442
+ case "set<text>":
443
+ return value.map((item) => {
444
+ try {
445
+ return JSON.parse(item);
446
+ } catch {
447
+ return item;
448
+ }
449
+ });
450
+ default:
451
+ return value;
452
+ }
428
453
  }
429
454
  }
430
455
  var queryHelper = {
package/package.json CHANGED
@@ -1,62 +1,63 @@
1
- {
2
- "name": "imean-cassandra-orm",
3
- "version": "2.3.0",
4
- "description": "cassandra orm",
5
- "keywords": [
6
- "cassandra",
7
- "orm",
8
- "database",
9
- "node"
10
- ],
11
- "author": "imean",
12
- "type": "module",
13
- "license": "MIT",
14
- "main": "dist/mod.js",
15
- "module": "dist/mod.js",
16
- "types": "dist/mod.d.ts",
17
- "exports": {
18
- ".": {
19
- "types": "./dist/mod.d.ts",
20
- "import": "./dist/mod.js",
21
- "require": "./dist/mod.cjs"
22
- }
23
- },
24
- "files": [
25
- "dist",
26
- "README.md",
27
- "LICENSE"
28
- ],
29
- "dependencies": {},
30
- "peerDependencies": {
31
- "zod": "^3.x",
32
- "@opentelemetry/api": "^1.x",
33
- "cassandra-driver": "^4.x"
34
- },
35
- "devDependencies": {
36
- "@opentelemetry/auto-instrumentations-node": "^0.55.3",
37
- "@opentelemetry/exporter-logs-otlp-proto": "^0.57.1",
38
- "@opentelemetry/exporter-metrics-otlp-proto": "^0.57.1",
39
- "@opentelemetry/exporter-trace-otlp-proto": "^0.57.1",
40
- "@opentelemetry/sdk-logs": "^0.57.1",
41
- "@opentelemetry/sdk-metrics": "^1.30.1",
42
- "@opentelemetry/sdk-node": "^0.57.1",
43
- "@opentelemetry/sdk-trace-node": "^1.30.1",
44
- "@opentelemetry/winston-transport": "^0.10.0",
45
- "@types/node": "^20.0.0",
46
- "@vitest/coverage-v8": "^3.0.4",
47
- "tslib": "^2.8.1",
48
- "tsup": "^8.0.1",
49
- "tsx": "^4.19.2",
50
- "typescript": "^5.3.3",
51
- "vite-tsconfig-paths": "^5.1.4",
52
- "vitest": "^3.0.3"
53
- },
54
- "engines": {
55
- "node": ">=20"
56
- },
57
- "scripts": {
58
- "dev": "tsx watch dev.ts",
59
- "build": "tsup",
60
- "test": "vitest run"
61
- }
62
- }
1
+ {
2
+ "name": "imean-cassandra-orm",
3
+ "version": "2.4.0",
4
+ "description": "cassandra orm",
5
+ "keywords": [
6
+ "cassandra",
7
+ "orm",
8
+ "database",
9
+ "node"
10
+ ],
11
+ "author": "imean",
12
+ "type": "module",
13
+ "license": "MIT",
14
+ "main": "dist/mod.js",
15
+ "module": "dist/mod.js",
16
+ "types": "dist/mod.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/mod.d.ts",
20
+ "import": "./dist/mod.js",
21
+ "require": "./dist/mod.cjs"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "README.md",
27
+ "LICENSE"
28
+ ],
29
+ "scripts": {
30
+ "dev": "tsx watch dev.ts",
31
+ "build": "tsup",
32
+ "test": "vitest run",
33
+ "prepublishOnly": "npm run build && npm run test"
34
+ },
35
+ "dependencies": {},
36
+ "peerDependencies": {
37
+ "zod": "^3.x",
38
+ "@opentelemetry/api": "^1.x",
39
+ "cassandra-driver": "^4.x"
40
+ },
41
+ "devDependencies": {
42
+ "@opentelemetry/auto-instrumentations-node": "^0.55.3",
43
+ "@opentelemetry/exporter-logs-otlp-proto": "^0.57.1",
44
+ "@opentelemetry/exporter-metrics-otlp-proto": "^0.57.1",
45
+ "@opentelemetry/exporter-trace-otlp-proto": "^0.57.1",
46
+ "@opentelemetry/sdk-logs": "^0.57.1",
47
+ "@opentelemetry/sdk-metrics": "^1.30.1",
48
+ "@opentelemetry/sdk-node": "^0.57.1",
49
+ "@opentelemetry/sdk-trace-node": "^1.30.1",
50
+ "@opentelemetry/winston-transport": "^0.10.0",
51
+ "@types/node": "^20.0.0",
52
+ "@vitest/coverage-v8": "^3.0.4",
53
+ "tslib": "^2.8.1",
54
+ "tsup": "^8.0.1",
55
+ "tsx": "^4.19.2",
56
+ "typescript": "^5.3.3",
57
+ "vite-tsconfig-paths": "^5.1.4",
58
+ "vitest": "^3.0.3"
59
+ },
60
+ "engines": {
61
+ "node": ">=20"
62
+ }
63
+ }