@gobing-ai/ts-infra 0.5.5 → 0.5.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAsB,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAO7C,OAAO,KAAK,EAER,2BAA2B,EAC3B,kBAAkB,EAGrB,MAAM,SAAS,CAAC;AAiCjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,cAAc,CAAC,UAAU,GAAG,OAAO,EAAE,OAAO,SAAS,QAAQ,GAAG,WAAW,EAC7F,OAAO,EAAE,2BAA2B,CAAC,UAAU,EAAE,OAAO,CAAC,GAC1D,OAAO,CAAC,kBAAkB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CA6JlD;AAED,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACvE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7D,YAAY,EACR,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,gBAAgB,GACnB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAsB,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAO7C,OAAO,KAAK,EAER,2BAA2B,EAC3B,kBAAkB,EAGrB,MAAM,SAAS,CAAC;AAiCjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAsB,cAAc,CAAC,UAAU,GAAG,OAAO,EAAE,OAAO,SAAS,QAAQ,GAAG,WAAW,EAC7F,OAAO,EAAE,2BAA2B,CAAC,UAAU,EAAE,OAAO,CAAC,GAC1D,OAAO,CAAC,kBAAkB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAgKlD;AAED,YAAY,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACvE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7D,YAAY,EACR,0BAA0B,EAC1B,2BAA2B,EAC3B,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,gBAAgB,GACnB,MAAM,SAAS,CAAC"}
@@ -199,8 +199,11 @@ export async function runApplication(options) {
199
199
  // order, via the host. Each plugin's onStop/onUnload is best-effort, so a
200
200
  // partially-started ring still releases its resources (telemetry, scheduler,
201
201
  // owned DB). Caller-injected services.db is caller-owned and not touched.
202
- await state.pluginHost.stopAll('error');
203
- await state.pluginHost.unloadAll('error');
202
+ // Optional chaining: pluginHost is assigned late in the try — a failure
203
+ // before it (e.g. file-observer setup) must rethrow the ORIGINAL error,
204
+ // not a teardown TypeError masking it.
205
+ await state.pluginHost?.stopAll('error');
206
+ await state.pluginHost?.unloadAll('error');
204
207
  throw error;
205
208
  }
206
209
  }
@@ -1 +1 @@
1
- {"version":3,"file":"application-node.d.ts","sourceRoot":"","sources":["../src/application-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAWH,OAAO,KAAK,EACR,2BAA2B,EAC3B,uBAAuB,EAEvB,kBAAkB,EAClB,qBAAqB,EAGrB,QAAQ,EACR,aAAa,EACb,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,qBAAqB,CAAC;AAS7B,kGAAkG;AAClG,qBAAa,qBAAsB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI9B;AAwOD;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,gBAAgB;IACnE,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,uEAAuE;AACvE,MAAM,WAAW,sBAAsB,CAAC,UAAU,GAAG,OAAO,EAAE,OAAO,SAAS,QAAQ,GAAG,WAAW;IAChG,gEAAgE;IAChE,QAAQ,CAAC,YAAY,CAAC,EAAE,uBAAuB,CAAC,UAAU,CAAC,CAAC;IAC5D,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE;QACd,OAAO,CAAC,EAAE,cAAc,CAAC;QACzB,MAAM,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;QAChC,SAAS,CAAC,EAAE,6BAA6B,CAAC;QAC1C,SAAS,CAAC,EAAE,gBAAgB,CAAC;KAChC,CAAC;IACF,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,2BAA2B,CAAC,UAAU,EAAE,OAAO,CAAC,CAA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GAAG,OAAO,EAAE,OAAO,SAAS,QAAQ,GAAG,WAAW;IAChG,gEAAgE;IAChE,QAAQ,CAAC,YAAY,CAAC,EAAE,uBAAuB,CAAC,UAAU,CAAC,CAAC;IAC5D,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE;QACd,OAAO,CAAC,EAAE,cAAc,CAAC;QACzB,MAAM,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;QAChC,SAAS,CAAC,EAAE,6BAA6B,CAAC;QAC1C,SAAS,CAAC,EAAE,gBAAgB,CAAC;KAChC,CAAC;IACF,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,2BAA2B,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC;IACjF,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,kBAAkB,CAAC,UAAU,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACvF,wDAAwD;IACxD,QAAQ,CAAC,IAAI,CAAC,EAAE,CACZ,GAAG,EAAE,kBAAkB,CAAC,UAAU,EAAE,OAAO,CAAC,EAC5C,MAAM,EAAE,qBAAqB,KAC5B,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC7B;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,kBAAkB,CAAC,UAAU,GAAG,OAAO,EAAE,OAAO,SAAS,QAAQ,GAAG,WAAW,EACjG,OAAO,EAAE,sBAAsB,CAAC,UAAU,EAAE,OAAO,CAAC,GACrD,OAAO,CAAC,kBAAkB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAyJlD"}
@@ -346,7 +346,17 @@ export async function runNodeApplication(options) {
346
346
  const injectedFileSystem = createNodeFileSystem();
347
347
  const fileObserverWriter = options.services?.fileObserverWriter ?? {
348
348
  ensureDir: (dir) => {
349
- mkdirSync(dir, { recursive: true });
349
+ try {
350
+ mkdirSync(dir, { recursive: true });
351
+ }
352
+ catch (error) {
353
+ // ensureDir contract: an existing directory is success. Node
354
+ // semantics already suppress EEXIST with `recursive: true`, but
355
+ // Bun on Windows still leaks EEXIST (observed for '.'), so
356
+ // tolerate it explicitly; anything else is a real failure.
357
+ if (error?.code !== 'EEXIST')
358
+ throw error;
359
+ }
350
360
  },
351
361
  appendFile: (path, content) => {
352
362
  appendFileSync(path, content);
@@ -1 +1 @@
1
- {"version":3,"file":"file-observer.d.ts","sourceRoot":"","sources":["../../src/event-bus/file-observer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAC/B,gFAAgF;IAChF,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,+DAA+D;IAC/D,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnE;AAYD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAC9B,YAAY,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAC1C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,kBAAkB,GAC3B,IAAI,CAqGN"}
1
+ {"version":3,"file":"file-observer.d.ts","sourceRoot":"","sources":["../../src/event-bus/file-observer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAC/B,gFAAgF;IAChF,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,+DAA+D;IAC/D,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnE;AAkBD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAC9B,YAAY,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAC1C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,kBAAkB,GAC3B,IAAI,CAqGN"}
@@ -1,7 +1,13 @@
1
1
  import { getLogger } from '../logger.js';
2
- /** Parent directory of a `/`-separated path (no `node:path` dependency). */
2
+ /**
3
+ * Parent directory of a `/`- or `\`-separated path (no `node:path` dependency,
4
+ * ADR-011). Windows paths (`path.resolve` output) are backslash-separated; a
5
+ * `/`-only scan would return `'.'` for them and make the observer mkdir the
6
+ * process cwd — which Bun-on-Windows rejects with EEXIST.
7
+ */
3
8
  function parentDir(filePath) {
4
- const idx = filePath.lastIndexOf('/');
9
+ const sep = filePath.includes('\\') ? '\\' : '/';
10
+ const idx = filePath.lastIndexOf(sep);
5
11
  return idx <= 0 ? '.' : filePath.slice(0, idx);
6
12
  }
7
13
  function isPromiseLike(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobing-ai/ts-infra",
3
- "version": "0.5.5",
3
+ "version": "0.5.9",
4
4
  "description": "@gobing-ai/ts-infra — Infrastructure backbone: event bus, job queue, scheduler, telemetry, API client, and logging.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -78,12 +78,12 @@
78
78
  "release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-infra-v<version> && git push --tags' && exit 1"
79
79
  },
80
80
  "dependencies": {
81
- "@gobing-ai/ts-utils": "^0.5.5",
81
+ "@gobing-ai/ts-utils": "^0.5.9",
82
82
  "@logtape/logtape": "^2.0.0"
83
83
  },
84
84
  "peerDependencies": {
85
- "@gobing-ai/ts-db": "^0.5.5",
86
- "@gobing-ai/ts-runtime": "^0.5.5",
85
+ "@gobing-ai/ts-db": "^0.5.9",
86
+ "@gobing-ai/ts-runtime": "^0.5.9",
87
87
  "@opentelemetry/api": "^1.9.0",
88
88
  "@opentelemetry/sdk-trace-node": "^2.0.0",
89
89
  "@opentelemetry/sdk-metrics": "^2.0.0",
@@ -116,8 +116,8 @@
116
116
  }
117
117
  },
118
118
  "devDependencies": {
119
- "@gobing-ai/ts-db": "^0.5.5",
120
- "@gobing-ai/ts-runtime": "^0.5.5",
119
+ "@gobing-ai/ts-db": "^0.5.9",
120
+ "@gobing-ai/ts-runtime": "^0.5.9",
121
121
  "@types/bun": "1.3.14",
122
122
  "@opentelemetry/api": "^1.9.0",
123
123
  "@opentelemetry/sdk-trace-node": "^2.0.0",
@@ -255,8 +255,11 @@ export async function runApplication<TAppConfig = unknown, TEvents extends Event
255
255
  // order, via the host. Each plugin's onStop/onUnload is best-effort, so a
256
256
  // partially-started ring still releases its resources (telemetry, scheduler,
257
257
  // owned DB). Caller-injected services.db is caller-owned and not touched.
258
- await state.pluginHost.stopAll('error');
259
- await state.pluginHost.unloadAll('error');
258
+ // Optional chaining: pluginHost is assigned late in the try — a failure
259
+ // before it (e.g. file-observer setup) must rethrow the ORIGINAL error,
260
+ // not a teardown TypeError masking it.
261
+ await state.pluginHost?.stopAll('error');
262
+ await state.pluginHost?.unloadAll('error');
260
263
  throw error;
261
264
  }
262
265
  }
@@ -469,7 +469,15 @@ export async function runNodeApplication<TAppConfig = unknown, TEvents extends E
469
469
  const injectedFileSystem = createNodeFileSystem();
470
470
  const fileObserverWriter = options.services?.fileObserverWriter ?? {
471
471
  ensureDir: (dir: string) => {
472
- mkdirSync(dir, { recursive: true });
472
+ try {
473
+ mkdirSync(dir, { recursive: true });
474
+ } catch (error) {
475
+ // ensureDir contract: an existing directory is success. Node
476
+ // semantics already suppress EEXIST with `recursive: true`, but
477
+ // Bun on Windows still leaks EEXIST (observed for '.'), so
478
+ // tolerate it explicitly; anything else is a real failure.
479
+ if ((error as NodeJS.ErrnoException)?.code !== 'EEXIST') throw error;
480
+ }
473
481
  },
474
482
  appendFile: (path: string, content: string) => {
475
483
  appendFileSync(path, content);
@@ -16,9 +16,15 @@ export interface FileObserverWriter {
16
16
  appendFile(path: string, content: string): void | Promise<void>;
17
17
  }
18
18
 
19
- /** Parent directory of a `/`-separated path (no `node:path` dependency). */
19
+ /**
20
+ * Parent directory of a `/`- or `\`-separated path (no `node:path` dependency,
21
+ * ADR-011). Windows paths (`path.resolve` output) are backslash-separated; a
22
+ * `/`-only scan would return `'.'` for them and make the observer mkdir the
23
+ * process cwd — which Bun-on-Windows rejects with EEXIST.
24
+ */
20
25
  function parentDir(filePath: string): string {
21
- const idx = filePath.lastIndexOf('/');
26
+ const sep = filePath.includes('\\') ? '\\' : '/';
27
+ const idx = filePath.lastIndexOf(sep);
22
28
  return idx <= 0 ? '.' : filePath.slice(0, idx);
23
29
  }
24
30