@dbx-tools/shared-core 0.3.37 → 0.3.40

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "repository": {
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/reggie-db/dbx-tools.git",
6
- "directory": "workspaces/shared/core"
6
+ "directory": "packages/shared/core"
7
7
  },
8
8
  "devDependencies": {
9
9
  "@types/node": "^24.6.0",
@@ -22,13 +22,17 @@
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
- "version": "0.3.37",
25
+ "version": "0.3.40",
26
26
  "types": "index.ts",
27
27
  "type": "module",
28
28
  "exports": {
29
29
  ".": "./index.ts",
30
30
  "./package.json": "./package.json"
31
31
  },
32
+ "files": [
33
+ "index.ts",
34
+ "src"
35
+ ],
32
36
  "peerDependenciesMeta": {
33
37
  "consola": {
34
38
  "optional": true
package/.projen/deps.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "dependencies": [
3
- {
4
- "name": "@types/node",
5
- "version": "^24.6.0",
6
- "type": "build"
7
- },
8
- {
9
- "name": "consola",
10
- "version": "catalog:",
11
- "type": "build"
12
- },
13
- {
14
- "name": "tsx",
15
- "version": "^4.23.0",
16
- "type": "build"
17
- },
18
- {
19
- "name": "typescript",
20
- "type": "build"
21
- },
22
- {
23
- "name": "consola",
24
- "version": "catalog:",
25
- "type": "peer"
26
- },
27
- {
28
- "name": "zod",
29
- "version": "catalog:",
30
- "type": "runtime"
31
- }
32
- ],
33
- "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"pnpm exec projen\"."
34
- }
@@ -1,11 +0,0 @@
1
- {
2
- "files": [
3
- ".projen/deps.json",
4
- ".projen/files.json",
5
- ".projen/tasks.json",
6
- "package.json",
7
- "test/tsconfig.json",
8
- "tsconfig.json"
9
- ],
10
- "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"pnpm exec projen\"."
11
- }
@@ -1,121 +0,0 @@
1
- {
2
- "manifestVersion": 3,
3
- "env": {
4
- "PATH": "$(pnpm -c exec \"node --print process.env.PATH\")"
5
- },
6
- "tasks": {
7
- "build": {
8
- "name": "build",
9
- "description": "Full release build",
10
- "steps": [
11
- {
12
- "spawn": "pre-compile"
13
- },
14
- {
15
- "spawn": "compile"
16
- },
17
- {
18
- "spawn": "post-compile"
19
- },
20
- {
21
- "spawn": "test"
22
- },
23
- {
24
- "spawn": "package"
25
- }
26
- ]
27
- },
28
- "compile": {
29
- "name": "compile",
30
- "description": "Only compile",
31
- "steps": [
32
- {
33
- "execArgs": [
34
- "tsc",
35
- "--build"
36
- ]
37
- }
38
- ]
39
- },
40
- "default": {
41
- "name": "default",
42
- "description": "Synthesize project files",
43
- "steps": [
44
- {
45
- "exec": "pnpm exec projen default",
46
- "cwd": "../../.."
47
- }
48
- ]
49
- },
50
- "install": {
51
- "name": "install",
52
- "description": "Install project dependencies and update lockfile (non-frozen)",
53
- "steps": [
54
- {
55
- "exec": "pnpm i --no-frozen-lockfile"
56
- }
57
- ]
58
- },
59
- "install:ci": {
60
- "name": "install:ci",
61
- "description": "Install project dependencies using frozen lockfile",
62
- "steps": [
63
- {
64
- "exec": "pnpm i --frozen-lockfile"
65
- }
66
- ]
67
- },
68
- "package": {
69
- "name": "package",
70
- "description": "Creates the distribution package",
71
- "steps": [
72
- {
73
- "execArgs": [
74
- "mkdir",
75
- "-p",
76
- "dist/js"
77
- ]
78
- },
79
- {
80
- "execArgs": [
81
- "pnpm",
82
- "pack",
83
- "--pack-destination",
84
- "dist/js"
85
- ]
86
- }
87
- ]
88
- },
89
- "post-compile": {
90
- "name": "post-compile",
91
- "description": "Runs after successful compilation"
92
- },
93
- "pre-compile": {
94
- "name": "pre-compile",
95
- "description": "Prepare the project for compilation"
96
- },
97
- "test": {
98
- "name": "test",
99
- "description": "Run tests",
100
- "steps": [
101
- {
102
- "exec": "tsx --test 'test/**/*.test.ts'"
103
- }
104
- ]
105
- },
106
- "watch": {
107
- "name": "watch",
108
- "description": "Watch & compile in the background",
109
- "steps": [
110
- {
111
- "execArgs": [
112
- "tsc",
113
- "--build",
114
- "-w"
115
- ]
116
- }
117
- ]
118
- }
119
- },
120
- "//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"pnpm exec projen\"."
121
- }
@@ -1,44 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { describe, it } from "node:test";
3
- import { async } from "../index";
4
-
5
- describe("async.combineAbortSignals", () => {
6
- it("returns undefined when every source is absent", () => {
7
- assert.equal(async.combineAbortSignals(), undefined);
8
- assert.equal(async.combineAbortSignals(undefined, undefined), undefined);
9
- });
10
-
11
- it("passes a lone signal through without wrapping it", () => {
12
- const { signal } = new AbortController();
13
- assert.equal(async.combineAbortSignals(signal), signal);
14
- assert.equal(async.combineAbortSignals(undefined, signal, undefined), signal);
15
- });
16
-
17
- it("aborts when any source aborts, carrying that source's reason", () => {
18
- for (const index of [0, 1, 2]) {
19
- const controllers = [new AbortController(), new AbortController(), new AbortController()];
20
- const combined = async.combineAbortSignals(...controllers.map((c) => c.signal));
21
- assert.equal(combined?.aborted, false);
22
- controllers[index]!.abort(new Error(`source ${index}`));
23
- assert.equal(combined?.aborted, true);
24
- assert.equal((combined?.reason as Error).message, `source ${index}`);
25
- }
26
- });
27
-
28
- it("is already aborted when a source aborted before combining", () => {
29
- const early = new AbortController();
30
- early.abort(new Error("gone"));
31
- const combined = async.combineAbortSignals(early.signal, new AbortController().signal);
32
- assert.equal(combined?.aborted, true);
33
- assert.equal((combined?.reason as Error).message, "gone");
34
- });
35
-
36
- it("does not propagate back to the sources", () => {
37
- const first = new AbortController();
38
- const second = new AbortController();
39
- const combined = async.combineAbortSignals(first.signal, second.signal);
40
- first.abort();
41
- assert.equal(combined?.aborted, true);
42
- assert.equal(second.signal.aborted, false);
43
- });
44
- });
@@ -1,33 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { describe, it } from "node:test";
3
- import { brand } from "../index";
4
-
5
- describe("brand context", () => {
6
- it("fills dbx tools defaults", () => {
7
- const context = brand.parseBrandContext();
8
-
9
- assert.equal(context.name, "dbx tools");
10
- assert.equal(context.assets.icon.light, brand.DEFAULT_BRAND_ASSETS.icon.light);
11
- assert.equal(context.colors.primary, "#FF3621");
12
- });
13
-
14
- it("validates nested overrides and preserves defaults", () => {
15
- const context = brand.parseBrandContext({
16
- name: "Example",
17
- colors: { primary: "#123456" },
18
- });
19
-
20
- assert.equal(context.name, "Example");
21
- assert.equal(context.colors.primary, "#123456");
22
- assert.equal(context.colors.background, "#FFFFFF");
23
- });
24
-
25
- it("exports schema and prompt forms for LLM consumers", () => {
26
- const schema = brand.brandContextJsonSchema();
27
- const prompt = brand.brandContextPrompt();
28
-
29
- assert.equal(schema.type, "object");
30
- assert.match(prompt, /dbx tools brand context/);
31
- assert.match(prompt, /"schemaVersion": "1"/);
32
- });
33
- });
package/test/hash.test.ts DELETED
@@ -1,55 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { afterEach, describe, it } from "node:test";
3
- import { hash } from "../index";
4
-
5
- const UUID_V4 = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
6
-
7
- const original = globalThis.crypto;
8
-
9
- const withCrypto = (value: unknown, body: () => void) => {
10
- Object.defineProperty(globalThis, "crypto", { value, configurable: true, writable: true });
11
- try {
12
- body();
13
- } finally {
14
- Object.defineProperty(globalThis, "crypto", {
15
- value: original,
16
- configurable: true,
17
- writable: true,
18
- });
19
- }
20
- };
21
-
22
- describe("hash.id", () => {
23
- afterEach(() => {
24
- assert.equal(globalThis.crypto, original);
25
- });
26
-
27
- it("mints a v4 UUID from crypto.randomUUID when available", () => {
28
- assert.match(hash.id(), UUID_V4);
29
- assert.notEqual(hash.id(), hash.id());
30
- });
31
-
32
- it("returns a short hex slice when a length is given", () => {
33
- assert.match(hash.id(8), /^[0-9a-f]{8}$/);
34
- assert.equal(hash.id(1).length, 1);
35
- });
36
-
37
- it("rejects a non-positive length", () => {
38
- assert.throws(() => hash.id(0), /greater than 0/);
39
- assert.throws(() => hash.id(-1), /greater than 0/);
40
- });
41
-
42
- it("falls back to getRandomValues where randomUUID is absent (plain-http browser)", () => {
43
- withCrypto({ getRandomValues: original.getRandomValues.bind(original) }, () => {
44
- assert.match(hash.id(), UUID_V4);
45
- assert.notEqual(hash.id(), hash.id());
46
- });
47
- });
48
-
49
- it("falls back to Math.random where crypto is absent entirely", () => {
50
- withCrypto(undefined, () => {
51
- assert.match(hash.id(), UUID_V4);
52
- assert.match(hash.id(12), /^[0-9a-f]{12}$/);
53
- });
54
- });
55
- });
package/test/json.test.ts DELETED
@@ -1,42 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { describe, it } from "node:test";
3
- import { json } from "../index";
4
-
5
- describe("json.parse", () => {
6
- it("parses a well-formed document", () => {
7
- assert.deepEqual(json.parse('{"a":1}'), { a: 1 });
8
- assert.deepEqual(json.parse("[1,2]"), [1, 2]);
9
- assert.equal(json.parse('"text"'), "text");
10
- });
11
-
12
- it("returns the fallback for malformed JSON instead of throwing", () => {
13
- assert.equal(json.parse("{not json"), undefined);
14
- assert.deepEqual(json.parse("{not json", { ok: false }), { ok: false });
15
- });
16
-
17
- it("treats absent / blank / non-string input as a miss", () => {
18
- assert.equal(json.parse(undefined), undefined);
19
- assert.equal(json.parse(null), undefined);
20
- assert.equal(json.parse(" "), undefined);
21
- assert.equal(json.parse(42), undefined);
22
- assert.deepEqual(json.parse(undefined, []), []);
23
- });
24
- });
25
-
26
- describe("json.parseRecord", () => {
27
- it("returns the object for a record document", () => {
28
- assert.deepEqual(json.parseRecord('{"name":"pkg"}'), { name: "pkg" });
29
- });
30
-
31
- it("rejects documents that parse to a non-record", () => {
32
- assert.equal(json.parseRecord("[1,2]"), undefined);
33
- assert.equal(json.parseRecord('"text"'), undefined);
34
- assert.equal(json.parseRecord("null"), undefined);
35
- assert.equal(json.parseRecord("7"), undefined);
36
- });
37
-
38
- it("returns undefined for malformed or absent input", () => {
39
- assert.equal(json.parseRecord("{oops"), undefined);
40
- assert.equal(json.parseRecord(undefined), undefined);
41
- });
42
- });
@@ -1,43 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import { describe, it } from "node:test";
3
- import { string } from "../index";
4
-
5
- describe("string.trimToEmpty", () => {
6
- it("trims a string", () => {
7
- assert.equal(string.trimToEmpty(" hi "), "hi");
8
- });
9
-
10
- it("yields an empty string for a non-string or blank value", () => {
11
- assert.equal(string.trimToEmpty(undefined), "");
12
- assert.equal(string.trimToEmpty(null), "");
13
- assert.equal(string.trimToEmpty(42), "");
14
- assert.equal(string.trimToEmpty(" "), "");
15
- });
16
- });
17
-
18
- describe("string.parseList", () => {
19
- it("splits a comma / whitespace separated string", () => {
20
- assert.deepEqual(string.parseList("a, b c,d"), ["a", "b", "c", "d"]);
21
- });
22
-
23
- it("accepts an array and trims its entries", () => {
24
- assert.deepEqual(string.parseList([" a ", "b"]), ["a", "b"]);
25
- });
26
-
27
- it("drops empties and de-duplicates, first occurrence winning", () => {
28
- assert.deepEqual(string.parseList("a,,b, a ,b"), ["a", "b"]);
29
- });
30
-
31
- it("returns an empty list for absent input", () => {
32
- assert.deepEqual(string.parseList(undefined), []);
33
- assert.deepEqual(string.parseList(null), []);
34
- assert.deepEqual(string.parseList(""), []);
35
- });
36
-
37
- it("applies a transform and de-duplicates on the transformed value", () => {
38
- assert.deepEqual(
39
- string.parseList("A, a, B", (entry) => entry.trim().toLowerCase()),
40
- ["a", "b"],
41
- );
42
- });
43
- });
@@ -1,14 +0,0 @@
1
- // ~~ Generated by projen. To modify, edit .projenrc.js and run "pnpm exec projen".
2
- {
3
- "extends": "../tsconfig.json",
4
- "compilerOptions": {
5
- "noEmit": true,
6
- "rootDir": ".."
7
- },
8
- "include": [
9
- "**/*.ts"
10
- ],
11
- "exclude": [
12
- "node_modules"
13
- ]
14
- }
package/tsconfig.json DELETED
@@ -1,40 +0,0 @@
1
- // ~~ Generated by projen. To modify, edit .projenrc.js and run "pnpm exec projen".
2
- {
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "lib",
6
- "alwaysStrict": true,
7
- "declaration": true,
8
- "esModuleInterop": true,
9
- "experimentalDecorators": true,
10
- "inlineSourceMap": true,
11
- "inlineSources": true,
12
- "lib": [
13
- "ES2022",
14
- "WebWorker"
15
- ],
16
- "module": "ESNext",
17
- "noEmitOnError": false,
18
- "noFallthroughCasesInSwitch": true,
19
- "noImplicitAny": true,
20
- "noImplicitReturns": true,
21
- "noImplicitThis": true,
22
- "noUnusedLocals": true,
23
- "noUnusedParameters": true,
24
- "resolveJsonModule": true,
25
- "strict": true,
26
- "strictNullChecks": true,
27
- "strictPropertyInitialization": true,
28
- "stripInternal": true,
29
- "target": "ES2022",
30
- "types": [],
31
- "moduleResolution": "bundler",
32
- "skipLibCheck": true
33
- },
34
- "include": [
35
- "src/**/*.ts"
36
- ],
37
- "exclude": [
38
- "node_modules"
39
- ]
40
- }