@noy-db/in-devtools 0.2.0-pre.28 → 0.2.0-pre.30

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/dist/index.cjs CHANGED
@@ -30,14 +30,30 @@ async function listVaults(noydb) {
30
30
  }
31
31
  async function snapshot(vault) {
32
32
  const dump = await vault.dumpSchema({ withStats: true });
33
- const collections = Object.entries(dump.collections).map(([name, desc]) => ({
34
- name,
35
- fields: desc.fields,
36
- indexes: desc.indexes,
37
- refs: desc.refs,
38
- ...desc.stats !== void 0 ? { stats: desc.stats } : {}
39
- }));
40
- return { vault: dump.vault, collections };
33
+ const collections = Object.entries(dump.collections).map(([name, desc]) => {
34
+ let described;
35
+ try {
36
+ const coll = vault.collection(name);
37
+ const collDesc = coll.describe();
38
+ described = collDesc.fields;
39
+ } catch {
40
+ }
41
+ return {
42
+ name,
43
+ fields: desc.fields,
44
+ indexes: desc.indexes,
45
+ refs: desc.refs,
46
+ ...desc.stats !== void 0 ? { stats: desc.stats } : {},
47
+ ...desc.meta !== void 0 ? { meta: desc.meta } : {},
48
+ ...desc.config !== void 0 ? { config: desc.config } : {},
49
+ ...described !== void 0 ? { described } : {}
50
+ };
51
+ });
52
+ return {
53
+ vault: dump.vault,
54
+ collections,
55
+ ...dump.meta !== void 0 ? { meta: dump.meta } : {}
56
+ };
41
57
  }
42
58
 
43
59
  // src/records.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/snapshot.ts","../src/records.ts","../src/events.ts","../src/meter.ts"],"sourcesContent":["import type { Vault } from '@noy-db/hub'\nimport type { Inspector, InspectableContainer, InspectorMeter } from './types.js'\nimport { listVaults, snapshot } from './snapshot.js'\nimport { records } from './records.js'\nimport { subscribe, subscribeConflicts, pendingWrites } from './events.js'\nimport { meterSnapshot } from './meter.js'\n\nexport function createInspector(container: InspectableContainer, opts?: { meter?: InspectorMeter }): Inspector {\n return {\n listVaults: () => listVaults(container),\n snapshot: (vault: Vault) => snapshot(vault),\n records: (vault, collection, opts) => records(vault, collection, opts),\n subscribe: (handler) => subscribe(container, handler),\n subscribeConflicts: (handler) => subscribeConflicts(container, handler),\n pendingWrites: () => pendingWrites(container),\n meterSnapshot: () => meterSnapshot(opts?.meter),\n }\n}\n\nexport type {\n Inspector,\n InspectableContainer,\n VaultInfo,\n InspectorSnapshot,\n InspectorCollection,\n RecordPage,\n InspectorWriteEvent,\n InspectorWriteConflict,\n PendingWrites,\n InspectorMeter,\n} from './types.js'\n","import type { Vault } from '@noy-db/hub'\nimport type { InspectorSnapshot, InspectorCollection, VaultInfo, InspectableContainer } from './types.js'\n\nexport async function listVaults(noydb: InspectableContainer): Promise<ReadonlyArray<VaultInfo>> {\n return noydb.listAccessibleVaults()\n}\n\nexport async function snapshot(vault: Vault): Promise<InspectorSnapshot> {\n // withStats populates per-collection record/byte stats; opaque to the store.\n const dump = await vault.dumpSchema({ withStats: true })\n // Omit `stats` when absent rather than setting it to `undefined` —\n // the repo's tsconfig sets `exactOptionalPropertyTypes`, so an optional\n // `stats?` field must be omitted, not explicitly undefined.\n const collections: InspectorCollection[] = Object.entries(dump.collections).map(([name, desc]) => ({\n name,\n fields: desc.fields,\n indexes: desc.indexes,\n refs: desc.refs,\n ...(desc.stats !== undefined ? { stats: desc.stats } : {}),\n }))\n return { vault: dump.vault, collections }\n}\n","import type { Vault } from '@noy-db/hub'\nimport type { RecordPage } from './types.js'\n\nconst DEFAULT_LIMIT = 50\nconst MAX_LIMIT = 500\n\nfunction clampLimit(n: number | undefined): number {\n if (n === undefined || Number.isNaN(n)) return DEFAULT_LIMIT\n return Math.max(1, Math.min(MAX_LIMIT, Math.floor(n)))\n}\n\nfunction clampOffset(n: number | undefined): number {\n if (n === undefined || Number.isNaN(n) || n < 0) return 0\n return Math.floor(n)\n}\n\nexport async function records(\n vault: Vault,\n collection: string,\n opts: { limit?: number; offset?: number } = {},\n): Promise<RecordPage> {\n const limit = clampLimit(opts.limit)\n const offset = clampOffset(opts.offset)\n // Eager collections only — `list()` throws on lazy (prefetch:false). The\n // error propagates to the caller, which decides how to surface it.\n const all = await vault.collection(collection).list()\n return {\n rows: all.slice(offset, offset + limit),\n total: all.length,\n limit,\n offset,\n }\n}\n","import type { InspectorWriteEvent, InspectorWriteConflict, PendingWrites, InspectableContainer } from './types.js'\n\nexport function subscribe(\n noydb: InspectableContainer,\n handler: (event: InspectorWriteEvent) => void,\n): () => void {\n return noydb.onAfterWrite(handler)\n}\n\nexport function pendingWrites(noydb: InspectableContainer): PendingWrites {\n const q = noydb.writeQueue\n return { pending: q.pending, depth: q.depth }\n}\n\nexport function subscribeConflicts(noydb: InspectableContainer, handler: (c: InspectorWriteConflict) => void): () => void {\n return noydb.onWriteConflict(handler)\n}\n","import type { InspectorMeter } from './types.js'\nimport type { MeterSnapshot } from '@noy-db/to-meter'\n\nexport function meterSnapshot(meter: InspectorMeter | undefined): MeterSnapshot | null {\n return meter ? meter.snapshot() : null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,eAAsB,WAAW,OAAgE;AAC/F,SAAO,MAAM,qBAAqB;AACpC;AAEA,eAAsB,SAAS,OAA0C;AAEvE,QAAM,OAAO,MAAM,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;AAIvD,QAAM,cAAqC,OAAO,QAAQ,KAAK,WAAW,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,OAAO;AAAA,IACjG;AAAA,IACA,QAAQ,KAAK;AAAA,IACb,SAAS,KAAK;AAAA,IACd,MAAM,KAAK;AAAA,IACX,GAAI,KAAK,UAAU,SAAY,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;AAAA,EAC1D,EAAE;AACF,SAAO,EAAE,OAAO,KAAK,OAAO,YAAY;AAC1C;;;AClBA,IAAM,gBAAgB;AACtB,IAAM,YAAY;AAElB,SAAS,WAAW,GAA+B;AACjD,MAAI,MAAM,UAAa,OAAO,MAAM,CAAC,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AChD;AACF;","names":["opts"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/snapshot.ts","../src/records.ts","../src/events.ts","../src/meter.ts"],"sourcesContent":["import type { Vault } from '@noy-db/hub'\nimport type { Inspector, InspectableContainer, InspectorMeter } from './types.js'\nimport { listVaults, snapshot } from './snapshot.js'\nimport { records } from './records.js'\nimport { subscribe, subscribeConflicts, pendingWrites } from './events.js'\nimport { meterSnapshot } from './meter.js'\n\nexport function createInspector(container: InspectableContainer, opts?: { meter?: InspectorMeter }): Inspector {\n return {\n listVaults: () => listVaults(container),\n snapshot: (vault: Vault) => snapshot(vault),\n records: (vault, collection, opts) => records(vault, collection, opts),\n subscribe: (handler) => subscribe(container, handler),\n subscribeConflicts: (handler) => subscribeConflicts(container, handler),\n pendingWrites: () => pendingWrites(container),\n meterSnapshot: () => meterSnapshot(opts?.meter),\n }\n}\n\nexport type {\n Inspector,\n InspectableContainer,\n VaultInfo,\n InspectorSnapshot,\n InspectorCollection,\n RecordPage,\n InspectorWriteEvent,\n InspectorWriteConflict,\n PendingWrites,\n InspectorMeter,\n} from './types.js'\n","import type { Vault } from '@noy-db/hub'\nimport type { InspectorSnapshot, InspectorCollection, VaultInfo, InspectableContainer } from './types.js'\n\nexport async function listVaults(noydb: InspectableContainer): Promise<ReadonlyArray<VaultInfo>> {\n return noydb.listAccessibleVaults()\n}\n\nexport async function snapshot(vault: Vault): Promise<InspectorSnapshot> {\n // withStats populates per-collection record/byte stats; opaque to the store.\n const dump = await vault.dumpSchema({ withStats: true })\n // Omit optional properties when absent rather than setting them to `undefined` —\n // the repo's tsconfig sets `exactOptionalPropertyTypes`, so optional fields must\n // be omitted, not explicitly set to undefined.\n const collections: InspectorCollection[] = Object.entries(dump.collections).map(([name, desc]) => {\n // Attempt to call describe() on the live collection to get rich field descriptors.\n // Guard: a collection that was not live-declared on this Vault instance (e.g. from a\n // prior open or a different process) may throw or return minimal output — skip\n // `described` for it without failing the whole snapshot.\n let described: InspectorCollection['described'] | undefined\n try {\n const coll = vault.collection(name)\n const collDesc = coll.describe()\n described = collDesc.fields\n } catch {\n // Not live-declared or no schema — skip described for this collection.\n }\n\n return {\n name,\n fields: desc.fields,\n indexes: desc.indexes,\n refs: desc.refs,\n ...(desc.stats !== undefined ? { stats: desc.stats } : {}),\n ...(desc.meta !== undefined ? { meta: desc.meta } : {}),\n ...(desc.config !== undefined ? { config: desc.config } : {}),\n ...(described !== undefined ? { described } : {}),\n }\n })\n\n return {\n vault: dump.vault,\n collections,\n ...(dump.meta !== undefined ? { meta: dump.meta } : {}),\n }\n}\n","import type { Vault } from '@noy-db/hub'\nimport type { RecordPage } from './types.js'\n\nconst DEFAULT_LIMIT = 50\nconst MAX_LIMIT = 500\n\nfunction clampLimit(n: number | undefined): number {\n if (n === undefined || Number.isNaN(n)) return DEFAULT_LIMIT\n return Math.max(1, Math.min(MAX_LIMIT, Math.floor(n)))\n}\n\nfunction clampOffset(n: number | undefined): number {\n if (n === undefined || Number.isNaN(n) || n < 0) return 0\n return Math.floor(n)\n}\n\nexport async function records(\n vault: Vault,\n collection: string,\n opts: { limit?: number; offset?: number } = {},\n): Promise<RecordPage> {\n const limit = clampLimit(opts.limit)\n const offset = clampOffset(opts.offset)\n // Eager collections only — `list()` throws on lazy (prefetch:false). The\n // error propagates to the caller, which decides how to surface it.\n const all = await vault.collection(collection).list()\n return {\n rows: all.slice(offset, offset + limit),\n total: all.length,\n limit,\n offset,\n }\n}\n","import type { InspectorWriteEvent, InspectorWriteConflict, PendingWrites, InspectableContainer } from './types.js'\n\nexport function subscribe(\n noydb: InspectableContainer,\n handler: (event: InspectorWriteEvent) => void,\n): () => void {\n return noydb.onAfterWrite(handler)\n}\n\nexport function pendingWrites(noydb: InspectableContainer): PendingWrites {\n const q = noydb.writeQueue\n return { pending: q.pending, depth: q.depth }\n}\n\nexport function subscribeConflicts(noydb: InspectableContainer, handler: (c: InspectorWriteConflict) => void): () => void {\n return noydb.onWriteConflict(handler)\n}\n","import type { InspectorMeter } from './types.js'\nimport type { MeterSnapshot } from '@noy-db/to-meter'\n\nexport function meterSnapshot(meter: InspectorMeter | undefined): MeterSnapshot | null {\n return meter ? meter.snapshot() : null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,eAAsB,WAAW,OAAgE;AAC/F,SAAO,MAAM,qBAAqB;AACpC;AAEA,eAAsB,SAAS,OAA0C;AAEvE,QAAM,OAAO,MAAM,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;AAIvD,QAAM,cAAqC,OAAO,QAAQ,KAAK,WAAW,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM;AAKhG,QAAI;AACJ,QAAI;AACF,YAAM,OAAO,MAAM,WAAW,IAAI;AAClC,YAAM,WAAW,KAAK,SAAS;AAC/B,kBAAY,SAAS;AAAA,IACvB,QAAQ;AAAA,IAER;AAEA,WAAO;AAAA,MACL;AAAA,MACA,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,MAAM,KAAK;AAAA,MACX,GAAI,KAAK,UAAU,SAAY,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;AAAA,MACxD,GAAI,KAAK,SAAS,SAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;AAAA,MACrD,GAAI,KAAK,WAAW,SAAY,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;AAAA,MAC3D,GAAI,cAAc,SAAY,EAAE,UAAU,IAAI,CAAC;AAAA,IACjD;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL,OAAO,KAAK;AAAA,IACZ;AAAA,IACA,GAAI,KAAK,SAAS,SAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;AAAA,EACvD;AACF;;;ACzCA,IAAM,gBAAgB;AACtB,IAAM,YAAY;AAElB,SAAS,WAAW,GAA+B;AACjD,MAAI,MAAM,UAAa,OAAO,MAAM,CAAC,EAAG,QAAO;AAC/C,SAAO,KAAK,IAAI,GA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ED
@@ -1,4 +1,4 @@
1
- import { AccessibleVault, Vault, WriteHook, Unsubscribe, WriteConflict, WriteQueue, CollectionDescriptor, CollectionStats, WriteEvent } from '@noy-db/hub';
1
+ import { AccessibleVault, Vault, WriteHook, Unsubscribe, WriteConflict, WriteQueue, CollectionDescriptor, CollectionStats, CollectionMeta, DescribedField, CollectionConfig, VaultMeta, WriteEvent } from '@noy-db/hub';
2
2
  import { MeterSnapshot } from '@noy-db/to-meter';
3
3
 
4
4
  /** Minimal structural view of a to-meter handle the inspector reads (no runtime dep). */
@@ -18,11 +18,19 @@ interface InspectorCollection {
18
18
  readonly indexes: CollectionDescriptor['indexes'];
19
19
  readonly refs: CollectionDescriptor['refs'];
20
20
  readonly stats?: CollectionStats;
21
+ /** Collection-level descriptive metadata (label/description/icon). */
22
+ readonly meta?: CollectionMeta;
23
+ /** Per-field rich descriptors from collection.describe() (label/widget/money/dict/…). */
24
+ readonly described?: readonly DescribedField[];
25
+ /** Collection-level configuration (textIndexes/embeddings/crdt/provenance/…). */
26
+ readonly config?: CollectionConfig;
21
27
  }
22
28
  /** Structure + stats for one open vault. */
23
29
  interface InspectorSnapshot {
24
30
  readonly vault: string;
25
31
  readonly collections: ReadonlyArray<InspectorCollection>;
32
+ /** Vault-level descriptive metadata (label/description/icon). */
33
+ readonly meta?: VaultMeta;
26
34
  }
27
35
  /** A page of decrypted records from one collection. */
28
36
  interface RecordPage {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AccessibleVault, Vault, WriteHook, Unsubscribe, WriteConflict, WriteQueue, CollectionDescriptor, CollectionStats, WriteEvent } from '@noy-db/hub';
1
+ import { AccessibleVault, Vault, WriteHook, Unsubscribe, WriteConflict, WriteQueue, CollectionDescriptor, CollectionStats, CollectionMeta, DescribedField, CollectionConfig, VaultMeta, WriteEvent } from '@noy-db/hub';
2
2
  import { MeterSnapshot } from '@noy-db/to-meter';
3
3
 
4
4
  /** Minimal structural view of a to-meter handle the inspector reads (no runtime dep). */
@@ -18,11 +18,19 @@ interface InspectorCollection {
18
18
  readonly indexes: CollectionDescriptor['indexes'];
19
19
  readonly refs: CollectionDescriptor['refs'];
20
20
  readonly stats?: CollectionStats;
21
+ /** Collection-level descriptive metadata (label/description/icon). */
22
+ readonly meta?: CollectionMeta;
23
+ /** Per-field rich descriptors from collection.describe() (label/widget/money/dict/…). */
24
+ readonly described?: readonly DescribedField[];
25
+ /** Collection-level configuration (textIndexes/embeddings/crdt/provenance/…). */
26
+ readonly config?: CollectionConfig;
21
27
  }
22
28
  /** Structure + stats for one open vault. */
23
29
  interface InspectorSnapshot {
24
30
  readonly vault: string;
25
31
  readonly collections: ReadonlyArray<InspectorCollection>;
32
+ /** Vault-level descriptive metadata (label/description/icon). */
33
+ readonly meta?: VaultMeta;
26
34
  }
27
35
  /** A page of decrypted records from one collection. */
28
36
  interface RecordPage {
package/dist/index.js CHANGED
@@ -4,14 +4,30 @@ async function listVaults(noydb) {
4
4
  }
5
5
  async function snapshot(vault) {
6
6
  const dump = await vault.dumpSchema({ withStats: true });
7
- const collections = Object.entries(dump.collections).map(([name, desc]) => ({
8
- name,
9
- fields: desc.fields,
10
- indexes: desc.indexes,
11
- refs: desc.refs,
12
- ...desc.stats !== void 0 ? { stats: desc.stats } : {}
13
- }));
14
- return { vault: dump.vault, collections };
7
+ const collections = Object.entries(dump.collections).map(([name, desc]) => {
8
+ let described;
9
+ try {
10
+ const coll = vault.collection(name);
11
+ const collDesc = coll.describe();
12
+ described = collDesc.fields;
13
+ } catch {
14
+ }
15
+ return {
16
+ name,
17
+ fields: desc.fields,
18
+ indexes: desc.indexes,
19
+ refs: desc.refs,
20
+ ...desc.stats !== void 0 ? { stats: desc.stats } : {},
21
+ ...desc.meta !== void 0 ? { meta: desc.meta } : {},
22
+ ...desc.config !== void 0 ? { config: desc.config } : {},
23
+ ...described !== void 0 ? { described } : {}
24
+ };
25
+ });
26
+ return {
27
+ vault: dump.vault,
28
+ collections,
29
+ ...dump.meta !== void 0 ? { meta: dump.meta } : {}
30
+ };
15
31
  }
16
32
 
17
33
  // src/records.ts
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/snapshot.ts","../src/records.ts","../src/events.ts","../src/meter.ts","../src/index.ts"],"sourcesContent":["import type { Vault } from '@noy-db/hub'\nimport type { InspectorSnapshot, InspectorCollection, VaultInfo, InspectableContainer } from './types.js'\n\nexport async function listVaults(noydb: InspectableContainer): Promise<ReadonlyArray<VaultInfo>> {\n return noydb.listAccessibleVaults()\n}\n\nexport async function snapshot(vault: Vault): Promise<InspectorSnapshot> {\n // withStats populates per-collection record/byte stats; opaque to the store.\n const dump = await vault.dumpSchema({ withStats: true })\n // Omit `stats` when absent rather than setting it to `undefined` —\n // the repo's tsconfig sets `exactOptionalPropertyTypes`, so an optional\n // `stats?` field must be omitted, not explicitly undefined.\n const collections: InspectorCollection[] = Object.entries(dump.collections).map(([name, desc]) => ({\n name,\n fields: desc.fields,\n indexes: desc.indexes,\n refs: desc.refs,\n ...(desc.stats !== undefined ? { stats: desc.stats } : {}),\n }))\n return { vault: dump.vault, collections }\n}\n","import type { Vault } from '@noy-db/hub'\nimport type { RecordPage } from './types.js'\n\nconst DEFAULT_LIMIT = 50\nconst MAX_LIMIT = 500\n\nfunction clampLimit(n: number | undefined): number {\n if (n === undefined || Number.isNaN(n)) return DEFAULT_LIMIT\n return Math.max(1, Math.min(MAX_LIMIT, Math.floor(n)))\n}\n\nfunction clampOffset(n: number | undefined): number {\n if (n === undefined || Number.isNaN(n) || n < 0) return 0\n return Math.floor(n)\n}\n\nexport async function records(\n vault: Vault,\n collection: string,\n opts: { limit?: number; offset?: number } = {},\n): Promise<RecordPage> {\n const limit = clampLimit(opts.limit)\n const offset = clampOffset(opts.offset)\n // Eager collections only — `list()` throws on lazy (prefetch:false). The\n // error propagates to the caller, which decides how to surface it.\n const all = await vault.collection(collection).list()\n return {\n rows: all.slice(offset, offset + limit),\n total: all.length,\n limit,\n offset,\n }\n}\n","import type { InspectorWriteEvent, InspectorWriteConflict, PendingWrites, InspectableContainer } from './types.js'\n\nexport function subscribe(\n noydb: InspectableContainer,\n handler: (event: InspectorWriteEvent) => void,\n): () => void {\n return noydb.onAfterWrite(handler)\n}\n\nexport function pendingWrites(noydb: InspectableContainer): PendingWrites {\n const q = noydb.writeQueue\n return { pending: q.pending, depth: q.depth }\n}\n\nexport function subscribeConflicts(noydb: InspectableContainer, handler: (c: InspectorWriteConflict) => void): () => void {\n return noydb.onWriteConflict(handler)\n}\n","import type { InspectorMeter } from './types.js'\nimport type { MeterSnapshot } from '@noy-db/to-meter'\n\nexport function meterSnapshot(meter: InspectorMeter | undefined): MeterSnapshot | null {\n return meter ? meter.snapshot() : null\n}\n","import type { Vault } from '@noy-db/hub'\nimport type { Inspector, InspectableContainer, InspectorMeter } from './types.js'\nimport { listVaults, snapshot } from './snapshot.js'\nimport { records } from './records.js'\nimport { subscribe, subscribeConflicts, pendingWrites } from './events.js'\nimport { meterSnapshot } from './meter.js'\n\nexport function createInspector(container: InspectableContainer, opts?: { meter?: InspectorMeter }): Inspector {\n return {\n listVaults: () => listVaults(container),\n snapshot: (vault: Vault) => snapshot(vault),\n records: (vault, collection, opts) => records(vault, collection, opts),\n subscribe: (handler) => subscribe(container, handler),\n subscribeConflicts: (handler) => subscribeConflicts(container, handler),\n pendingWrites: () => pendingWrites(container),\n meterSnapshot: () => meterSnapshot(opts?.meter),\n }\n}\n\nexport type {\n Inspector,\n InspectableContainer,\n VaultInfo,\n InspectorSnapshot,\n InspectorCollection,\n RecordPage,\n InspectorWriteEvent,\n InspectorWriteConflict,\n PendingWrites,\n InspectorMeter,\n} from './types.js'\n"],"mappings":";AAGA,eAAsB,WAAW,OAAgE;AAC/F,SAAO,MAAM,qBAAqB;AACpC;AAEA,eAAsB,SAAS,OAA0C;AAEvE,QAAM,OAAO,MAAM,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;AAIvD,QAAM,cAAqC,OAAO,QAAQ,KAAK,W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S,gBAAgB,WAAiC,MAA8C;AAC7G,SAAO;AAAA,IACL,YAAY,MAAM,WAAW,SAAS;AAAA,IACtC,UAAU,CAAC,UAAiB,SAAS,KAAK;AAAA,IAC1C,SAAS,CAAC,OAAO,YAAYA,UAAS,QAAQ,OAAO,YAAYA,KAAI;AAAA,IACrE,WAAW,CAAC,YAAY,UAAU,WAAW,OAAO;AAAA,IACpD,oBAAoB,CAAC,YAAY,mBAAmB,WAAW,OAAO;AAAA,IACtE,eAAe,MAAM,cAAc,SAAS;AAAA,IAC5C,eAAe,MAAM,cAAc,MAAM,KAAK;AAAA,EAChD;AACF;","names":["opts"]}
1
+ {"version":3,"sources":["../src/snapshot.ts","../src/records.ts","../src/events.ts","../src/meter.ts","../src/index.ts"],"sourcesContent":["import type { Vault } from '@noy-db/hub'\nimport type { InspectorSnapshot, InspectorCollection, VaultInfo, InspectableContainer } from './types.js'\n\nexport async function listVaults(noydb: InspectableContainer): Promise<ReadonlyArray<VaultInfo>> {\n return noydb.listAccessibleVaults()\n}\n\nexport async function snapshot(vault: Vault): Promise<InspectorSnapshot> {\n // withStats populates per-collection record/byte stats; opaque to the store.\n const dump = await vault.dumpSchema({ withStats: true })\n // Omit optional properties when absent rather than setting them to `undefined` —\n // the repo's tsconfig sets `exactOptionalPropertyTypes`, so optional fields must\n // be omitted, not explicitly set to undefined.\n const collections: InspectorCollection[] = Object.entries(dump.collections).map(([name, desc]) => {\n // Attempt to call describe() on the live collection to get rich field descriptors.\n // Guard: a collection that was not live-declared on this Vault instance (e.g. from a\n // prior open or a different process) may throw or return minimal output — skip\n // `described` for it without failing the whole snapshot.\n let described: InspectorCollection['described'] | undefined\n try {\n const coll = vault.collection(name)\n const collDesc = coll.describe()\n described = collDesc.fields\n } catch {\n // Not live-declared or no schema — skip described for this collection.\n }\n\n return {\n name,\n fields: desc.fields,\n indexes: desc.indexes,\n refs: desc.refs,\n ...(desc.stats !== undefined ? { stats: desc.stats } : {}),\n ...(desc.meta !== undefined ? { meta: desc.meta } : {}),\n ...(desc.config !== undefined ? { config: desc.config } : {}),\n ...(described !== undefined ? { described } : {}),\n }\n })\n\n return {\n vault: dump.vault,\n collections,\n ...(dump.meta !== undefined ? { meta: dump.meta } : {}),\n }\n}\n","import type { Vault } from '@noy-db/hub'\nimport type { RecordPage } from './types.js'\n\nconst DEFAULT_LIMIT = 50\nconst MAX_LIMIT = 500\n\nfunction clampLimit(n: number | undefined): number {\n if (n === undefined || Number.isNaN(n)) return DEFAULT_LIMIT\n return Math.max(1, Math.min(MAX_LIMIT, Math.floor(n)))\n}\n\nfunction clampOffset(n: number | undefined): number {\n if (n === undefined || Number.isNaN(n) || n < 0) return 0\n return Math.floor(n)\n}\n\nexport async function records(\n vault: Vault,\n collection: string,\n opts: { limit?: number; offset?: number } = {},\n): Promise<RecordPage> {\n const limit = clampLimit(opts.limit)\n const offset = clampOffset(opts.offset)\n // Eager collections only — `list()` throws on lazy (prefetch:false). The\n // error propagates to the caller, which decides how to surface it.\n const all = await vault.collection(collection).list()\n return {\n rows: all.slice(offset, offset + limit),\n total: all.length,\n limit,\n offset,\n }\n}\n","import type { InspectorWriteEvent, InspectorWriteConflict, PendingWrites, InspectableContainer } from './types.js'\n\nexport function subscribe(\n noydb: InspectableContainer,\n handler: (event: InspectorWriteEvent) => void,\n): () => void {\n return noydb.onAfterWrite(handler)\n}\n\nexport function pendingWrites(noydb: InspectableContainer): PendingWrites {\n const q = noydb.writeQueue\n return { pending: q.pending, depth: q.depth }\n}\n\nexport function subscribeConflicts(noydb: InspectableContainer, handler: (c: InspectorWriteConflict) => void): () => void {\n return noydb.onWriteConflict(handler)\n}\n","import type { InspectorMeter } from './types.js'\nimport type { MeterSnapshot } from '@noy-db/to-meter'\n\nexport function meterSnapshot(meter: InspectorMeter | undefined): MeterSnapshot | null {\n return meter ? meter.snapshot() : null\n}\n","import type { Vault } from '@noy-db/hub'\nimport type { Inspector, InspectableContainer, InspectorMeter } from './types.js'\nimport { listVaults, snapshot } from './snapshot.js'\nimport { records } from './records.js'\nimport { subscribe, subscribeConflicts, pendingWrites } from './events.js'\nimport { meterSnapshot } from './meter.js'\n\nexport function createInspector(container: InspectableContainer, opts?: { meter?: InspectorMeter }): Inspector {\n return {\n listVaults: () => listVaults(container),\n snapshot: (vault: Vault) => snapshot(vault),\n records: (vault, collection, opts) => records(vault, collection, opts),\n subscribe: (handler) => subscribe(container, handler),\n subscribeConflicts: (handler) => subscribeConflicts(container, handler),\n pendingWrites: () => pendingWrites(container),\n meterSnapshot: () => meterSnapshot(opts?.meter),\n }\n}\n\nexport type {\n Inspector,\n InspectableContainer,\n VaultInfo,\n InspectorSnapshot,\n InspectorCollection,\n RecordPage,\n InspectorWriteEvent,\n InspectorWriteConflict,\n PendingWrites,\n InspectorMeter,\n} from './types.js'\n"],"mappings":";AAGA,eAAsB,WAAW,OAAgE;AAC/F,SAAO,MAAM,qBAAqB;AACpC;AAEA,eAAsB,SAAS,OAA0C;AAEvE,QAAM,OAAO,MAAM,MAAM,WAAW,EAAE,WAAW,KAAK,CAAC;AAIvD,QAAM,cAAqC,OAAO,QAAQ,KAAK,WAAW,EAAE,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM;AAKhG,QAAI;AACJ,QAAI;AACF,YAAM,OAAO,MAAM,WAAW,IAAI;AAClC,YAAM,WAAW,KAAK,SAAS;AAC/B,kBAAY,SAAS;AAAA,IACvB,QAAQ;AAAA,IAER;AAEA,WAAO;AAAA,MACL;AAAA,MACA,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,MACd,MAAM,KAAK;AAAA,MACX,GAAI,KAAK,UAAU,SAAY,EAAE,OAAO,KAAK,MAAM,IAAI,CAAC;AAAA,MACxD,GAAI,KAAK,SAAS,SAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;AAAA,MACrD,GAAI,KAAK,WAAW,SAAY,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;AAAA,MAC3D,GAAI,cAAc,SAAY,EAAE,UAAU,IAA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C,UAAiB,SAAS,KAAK;AAAA,IAC1C,SAAS,CAAC,OAAO,YAAYA,UAAS,QAAQ,OAAO,YAAYA,KAAI;AAAA,IACrE,WAAW,CAAC,YAAY,UAAU,WAAW,OAAO;AAAA,IACpD,oBAAoB,CAAC,YAAY,mBAAmB,WAAW,OAAO;AAAA,IACtE,eAAe,MAAM,cAAc,SAAS;AAAA,IAC5C,eAAe,MAAM,cAAc,MAAM,KAAK;AAAA,EAChD;AACF;","names":["opts"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noy-db/in-devtools",
3
- "version": "0.2.0-pre.28",
3
+ "version": "0.2.0-pre.30",
4
4
  "description": "Framework-agnostic read-only inspector for a live noy-db — vaults, collections, schema, stats, records, and live writes.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,11 +23,11 @@
23
23
  "dist"
24
24
  ],
25
25
  "peerDependencies": {
26
- "@noy-db/hub": "0.2.0-pre.28"
26
+ "@noy-db/hub": "0.2.0-pre.30"
27
27
  },
28
28
  "devDependencies": {
29
- "@noy-db/hub": "0.2.0-pre.28",
30
- "@noy-db/to-meter": "0.2.0-pre.28"
29
+ "@noy-db/hub": "0.2.0-pre.30",
30
+ "@noy-db/to-meter": "0.2.0-pre.30"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup",