@pilotiq/pilotiq 0.21.0 → 0.23.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 (112) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/CHANGELOG.md +107 -0
  3. package/dist/Pilotiq.d.ts +72 -0
  4. package/dist/Pilotiq.d.ts.map +1 -1
  5. package/dist/Pilotiq.js +145 -0
  6. package/dist/Pilotiq.js.map +1 -1
  7. package/dist/PilotiqServiceProvider.d.ts +2 -0
  8. package/dist/PilotiqServiceProvider.d.ts.map +1 -1
  9. package/dist/PilotiqServiceProvider.js +60 -12
  10. package/dist/PilotiqServiceProvider.js.map +1 -1
  11. package/dist/actions/importFactory.d.ts +5 -0
  12. package/dist/actions/importFactory.d.ts.map +1 -1
  13. package/dist/actions/importFactory.js +20 -10
  14. package/dist/actions/importFactory.js.map +1 -1
  15. package/dist/orm/modelDefaults.d.ts +10 -1
  16. package/dist/orm/modelDefaults.d.ts.map +1 -1
  17. package/dist/orm/modelDefaults.js +7 -2
  18. package/dist/orm/modelDefaults.js.map +1 -1
  19. package/dist/pageData/forms.js +3 -3
  20. package/dist/pageData/forms.js.map +1 -1
  21. package/dist/pageData/misc.js +5 -5
  22. package/dist/pageData/misc.js.map +1 -1
  23. package/dist/pageData/navigation.d.ts.map +1 -1
  24. package/dist/pageData/navigation.js +11 -9
  25. package/dist/pageData/navigation.js.map +1 -1
  26. package/dist/pageData/relationPages.d.ts.map +1 -1
  27. package/dist/pageData/relationPages.js +7 -4
  28. package/dist/pageData/relationPages.js.map +1 -1
  29. package/dist/pageData/resourcePages.js +6 -6
  30. package/dist/pageData/resourcePages.js.map +1 -1
  31. package/dist/plugins/index.d.ts +3 -0
  32. package/dist/plugins/index.d.ts.map +1 -1
  33. package/dist/plugins/index.js +1 -0
  34. package/dist/plugins/index.js.map +1 -1
  35. package/dist/plugins/themeEditor.d.ts +20 -1
  36. package/dist/plugins/themeEditor.d.ts.map +1 -1
  37. package/dist/plugins/themeEditor.js +3 -1
  38. package/dist/plugins/themeEditor.js.map +1 -1
  39. package/dist/react/CollabRoomContext.d.ts +12 -0
  40. package/dist/react/CollabRoomContext.d.ts.map +1 -1
  41. package/dist/react/CollabRoomContext.js.map +1 -1
  42. package/dist/react/FormStateContext.d.ts +10 -0
  43. package/dist/react/FormStateContext.d.ts.map +1 -1
  44. package/dist/react/FormStateContext.js +12 -0
  45. package/dist/react/FormStateContext.js.map +1 -1
  46. package/dist/react/PendingSuggestionApplierRegistry.d.ts +12 -0
  47. package/dist/react/PendingSuggestionApplierRegistry.d.ts.map +1 -1
  48. package/dist/react/PendingSuggestionApplierRegistry.js +21 -1
  49. package/dist/react/PendingSuggestionApplierRegistry.js.map +1 -1
  50. package/dist/react/index.d.ts +2 -1
  51. package/dist/react/index.d.ts.map +1 -1
  52. package/dist/react/index.js +2 -1
  53. package/dist/react/index.js.map +1 -1
  54. package/dist/react/useCollabSeed.d.ts +23 -0
  55. package/dist/react/useCollabSeed.d.ts.map +1 -0
  56. package/dist/react/useCollabSeed.js +67 -0
  57. package/dist/react/useCollabSeed.js.map +1 -0
  58. package/dist/routes/globals.d.ts.map +1 -1
  59. package/dist/routes/globals.js +8 -22
  60. package/dist/routes/globals.js.map +1 -1
  61. package/dist/routes/helpers.d.ts +13 -0
  62. package/dist/routes/helpers.d.ts.map +1 -1
  63. package/dist/routes/helpers.js +25 -8
  64. package/dist/routes/helpers.js.map +1 -1
  65. package/dist/routes/resources.d.ts.map +1 -1
  66. package/dist/routes/resources.js +12 -34
  67. package/dist/routes/resources.js.map +1 -1
  68. package/dist/routes/theme.d.ts +4 -2
  69. package/dist/routes/theme.d.ts.map +1 -1
  70. package/dist/routes/theme.js +27 -26
  71. package/dist/routes/theme.js.map +1 -1
  72. package/dist/routes.d.ts.map +1 -1
  73. package/dist/routes.js +65 -37
  74. package/dist/routes.js.map +1 -1
  75. package/dist/theme/index.d.ts +2 -0
  76. package/dist/theme/index.d.ts.map +1 -1
  77. package/dist/theme/index.js +1 -0
  78. package/dist/theme/index.js.map +1 -1
  79. package/dist/theme/storage.d.ts +86 -0
  80. package/dist/theme/storage.d.ts.map +1 -0
  81. package/dist/theme/storage.js +52 -0
  82. package/dist/theme/storage.js.map +1 -0
  83. package/package.json +1 -1
  84. package/src/Pilotiq.perf.test.ts +252 -0
  85. package/src/Pilotiq.test.ts +4 -0
  86. package/src/Pilotiq.ts +166 -0
  87. package/src/PilotiqServiceProvider.ts +63 -11
  88. package/src/actions/importFactory.ts +31 -10
  89. package/src/orm/modelDefaults.ts +15 -2
  90. package/src/pageData/forms.ts +3 -3
  91. package/src/pageData/misc.ts +5 -5
  92. package/src/pageData/navigation.ts +11 -9
  93. package/src/pageData/relationPages.ts +5 -3
  94. package/src/pageData/resourcePages.ts +6 -6
  95. package/src/plugins/index.ts +7 -0
  96. package/src/plugins/themeEditor.test.ts +36 -0
  97. package/src/plugins/themeEditor.ts +22 -1
  98. package/src/react/CollabRoomContext.ts +12 -0
  99. package/src/react/FormStateContext.tsx +13 -0
  100. package/src/react/PendingSuggestionApplierRegistry.test.ts +97 -0
  101. package/src/react/PendingSuggestionApplierRegistry.ts +19 -1
  102. package/src/react/index.ts +2 -0
  103. package/src/react/useCollabSeed.ts +73 -0
  104. package/src/routes/globals.ts +8 -16
  105. package/src/routes/guard.test.ts +325 -0
  106. package/src/routes/helpers.ts +30 -8
  107. package/src/routes/resources.ts +12 -22
  108. package/src/routes/theme.ts +26 -44
  109. package/src/routes.ts +65 -36
  110. package/src/theme/index.ts +6 -0
  111. package/src/theme/storage.test.ts +126 -0
  112. package/src/theme/storage.ts +106 -0
@@ -1,8 +1,8 @@
1
1
 
2
- > @pilotiq/pilotiq@0.21.0 build /home/runner/work/pilotiq/pilotiq/packages/pilotiq
2
+ > @pilotiq/pilotiq@0.23.0 build /home/runner/work/pilotiq/pilotiq/packages/pilotiq
3
3
  > tsc -p tsconfig.build.json && pnpm run copy-assets
4
4
 
5
5
 
6
- > @pilotiq/pilotiq@0.21.0 copy-assets /home/runner/work/pilotiq/pilotiq/packages/pilotiq
6
+ > @pilotiq/pilotiq@0.23.0 copy-assets /home/runner/work/pilotiq/pilotiq/packages/pilotiq
7
7
  > mkdir -p dist/styles && cp -R src/styles/*.css dist/styles/
8
8
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,112 @@
1
1
  # @pilotiq/pilotiq
2
2
 
3
+ ## 0.23.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b87b2a5: fix(ai): scope inline-diff + chip suggestion appliers by surrounding form id
8
+
9
+ Multi-form pages would route AI suggestions to whichever editor mounted last because both `useAiInlineDiff` and `useAiSuggestionBridge` hard-coded `formId: undefined` when registering their applier — so two editors sharing a field name across forms (e.g. a "summary" `RichTextField` in the main edit form + the same field in a Replicate modal) would race on `registerPendingSuggestionApplier(undefined, fieldName, …)` and the last `useEffect` would win.
10
+
11
+ **`@pilotiq/pilotiq` (minor — new public API, additive)**
12
+
13
+ - New `useFormId(): string | undefined` hook re-exported from `@pilotiq/pilotiq/react`. Reads the surrounding `FormRenderer`'s id from `FormIdContext` and normalizes the sentinel empty string to `undefined`. Adapter packages (Tiptap + future editor adapters) consume this to scope per-field registries by form.
14
+ - `getPendingSuggestionApplier(undefined, fieldName)` now falls back to ANY matching scoped entry when no wildcard entry is registered. Closes the regression that would have followed from adapter scoping: editors now register under their form's id, so the wildcard slot is almost always empty — without the fallback, global producers (suggestions pushed without a `formId`) would silently fail to resolve. Scoped lookups + explicit wildcard registrations preserve their original precedence.
15
+
16
+ **`@pilotiq/tiptap` (patch — internal hook wiring)**
17
+
18
+ `useAiInlineDiff` and `useAiSuggestionBridge` now thread `useFormId()` into `registerPendingSuggestionApplier(formId, fieldName, applier)` and the effect's dep array. No public-surface change; the multi-form routing simply works now.
19
+
20
+ Coverage: 9 new unit tests on `PendingSuggestionApplierRegistry` cover scoped lookup, scoped multi-form disambiguation, the global-producer fallback, precedence (wildcard wins over scoped for undefined lookups when both exist; scoped wins for explicit lookups), unregister cleanup, and re-register identity guard.
21
+
22
+ ## 0.22.0
23
+
24
+ ### Minor Changes
25
+
26
+ - 89a9101: feat(collab): consume `@rudderjs/sync/react`'s collab-room lifecycle via `useCollabSeed` (Phase 6d of the code-quality sweep)
27
+
28
+ The same `provider.once('synced', …)` + empty-fragment seed dance was duplicated across four pilotiq adapters (`TiptapEditor`, `MarkdownEditor`, `CollabTextRenderer`, `CollabCodeMirrorEditor`) and `@pilotiq-pro/collab`'s `useRecordCollabRoom`. `@rudderjs/sync@1.2.0` shipped `@rudderjs/sync/react` with `CollabRoomManager` (cancellation-safe, idempotent stop, optional `y-indexeddb`); this PR threads its synced Promise through pilotiq's open-core `CollabRoom` so adapters can consume the consolidated seed-gate via `useCollabSeed`.
29
+
30
+ **`@pilotiq/pilotiq` (minor — new public API + widened `CollabRoom` shape, both additive)**
31
+
32
+ - `CollabRoom` interface widened with two optional fields:
33
+ - `synced?: Promise<void>` — resolves on the provider's first sync. Stamped by `@pilotiq-pro/collab@>=0.2`'s `<RecordCollabRoom>`; absent for legacy / hand-rolled providers.
34
+ - `persistence?: unknown` — `y-indexeddb` handle, opaque to pilotiq core. Present when the room owner wired offline persistence; absent otherwise.
35
+ - New `useCollabSeed(room, fragmentKey, seedFn)` hook (re-exported from `@pilotiq/pilotiq/react`). Mirrors `@rudderjs/sync/react`'s shape — reimplemented locally so pilotiq core stays free of any hard runtime dep on Yjs. Waits for `room.synced` to resolve, wraps `seedFn` in `ydoc.transact(..., 'pilotiq-collab-seed')`. Consumers manage their own share-type lookup (`doc.getXmlFragment(key)` for Tiptap; `doc.getText(key)` for CodeMirror) and emptiness check, since the share type varies per adapter and pilotiq's `CollabRoom.ydoc` stays `unknown`.
36
+ - `onProviderSynced` is unchanged and still exported for back-compat — legacy rooms without `.synced` short-circuit through `useCollabSeed` immediately (seeded=true with no callback fired), so any adapter still calling `onProviderSynced` keeps working unchanged.
37
+
38
+ **`@pilotiq/tiptap` (patch — internal migration, no public-surface change)**
39
+
40
+ `TiptapEditor`, `MarkdownEditor`, and `CollabTextRenderer` each dropped their inline `useEffect(() => onProviderSynced(provider, trySeed), [editor, collabActive, room])` block in favour of one `useCollabSeed(editor && collabActive ? room : null, collabName, seedFn)`. The shape of the seed (Y.XmlFragment empty-check + `editor.commands.setContent(initialContent)` via the y-prosemirror binding) is unchanged. Roughly −40 LOC per file; the `hasSeeded` `useState` slots are gone (the hook owns dedup).
41
+
42
+ **`@pilotiq/codemirror` (patch — internal migration, additive prop)**
43
+
44
+ - New optional `synced?: Promise<void> | null` prop on `CollabCodeMirrorEditor`. Threaded from the wrapper in `CodeMirrorEditor.tsx`'s `<CollabBranch>` so the renderer can gate the brand-new-record Y.Text seed on the same Promise.
45
+ - Seed logic moved out of the EditorView mount effect to a top-level `useCollabSeed` call. The mount-time pre-seed (`EditorState.create({ doc: yText.toString(), ... })`) is unchanged — that path handles re-mount onto a yText that already has content (e.g. `renameRow` clones); the post-sync seed handles brand-new records where the share is empty after first sync.
46
+ - `onProviderSynced` + `SyncedProviderLike` no longer imported. The `synced` prop is optional with `null` default — passing nothing falls back to seeding immediately, matching the legacy `onProviderSynced(null, …)` no-op posture.
47
+
48
+ No wire-protocol changes. The race window (two peers mounting against a brand-new record may both see "empty" + seed) is unchanged from the prior `onProviderSynced` path; the fix is server-side seed handoff, deferred.
49
+
50
+ Coverage: existing tests pass unchanged (tiptap 183/183, codemirror 22/22, pilotiq monorepo typecheck 9/9). Dual-browser smoke via the existing `pilotiq-pro/e2e/collab` Playwright suite gates the actual sync behaviour.
51
+
52
+ - bf429a1: refactor(theme): decouple theme override persistence behind a `ThemeStorageAdapter`
53
+
54
+ `PilotiqServiceProvider` and the theme editor's PUT/DELETE routes used to hard-code Prisma — `app.make('prisma') as any` + `prisma.panelGlobal.{findUnique,upsert,delete}` — which broke the ORM-agnostic story (`@rudderjs/orm` works fine on Drizzle) and put the only non-test `as any` in the codebase in a hot path. The bare `catch {}` around the boot-time load also swallowed real misconfiguration (misnamed `panelGlobal` schema, Prisma client not connecting) as silently as it swallowed "no overrides persisted yet".
55
+
56
+ This release introduces a `ThemeStorageAdapter` interface — `{ load(), save(overrides), clear() }` — and a `prismaThemeStorage(prisma, { slug })` factory. Pass an explicit adapter via the new `themeEditor({ storage })` option:
57
+
58
+ ```ts
59
+ import { themeEditor, prismaThemeStorage } from "@pilotiq/pilotiq/plugins";
60
+
61
+ Pilotiq.make("Admin").use(
62
+ themeEditor({
63
+ storage: prismaThemeStorage(prisma, { slug: "admin__theme" }),
64
+ })
65
+ );
66
+ ```
67
+
68
+ Apps on Drizzle, a KV store, or filesystem JSON can implement the three methods themselves; the panel only cares about the adapter shape.
69
+
70
+ **Back-compat / deprecation.** Calling `themeEditor()` without `storage` still works for one minor cycle: the service provider falls back to the implicit Prisma adapter at boot, logs a one-time deprecation warning naming the panel, and proceeds as before. The fallback branch will be removed in a future minor — pass `storage` explicitly to silence the warning. Explicit adapters propagate errors normally; the implicit fallback continues to swallow connection / schema errors for back-compat.
71
+
72
+ Tests: new `theme/storage.test.ts` covers the Prisma adapter round-trip (load / save / clear + P2025 "row not found" tolerance + non-P2025 error propagation) and `plugins/themeEditor.test.ts` confirms the option wires the adapter onto the panel.
73
+
74
+ ### Patch Changes
75
+
76
+ - 67aadbd: fix(security): enforce `Pilotiq.guard()` on every panel route via `router.group()`
77
+
78
+ `Pilotiq.guard()` is documented as the 401 layer, but until now the guard callback was only consulted on the `_uploads` route. Every other panel route — list / view / create / edit / delete / `_action` / `_widget` / `_form` / `_table` / `_search`, relation managers, custom pages, theme editor — relied on `cfg.user` returning null + each Resource's `canX(user, …)` defaulting to true.
79
+
80
+ An app that wired `Pilotiq.guard(req => Auth.check())` but shipped any Resource without `canAccess` overrides could expose an unauthenticated, fully-readable admin panel. The intent was documented; the wiring was not there.
81
+
82
+ Fix: wrap every core panel route registration in one `router.group({ middleware: [guardMiddleware] }, …)` call. The guard now runs in front of every handler. Removed the redundant inline guard inside `handleUploadRequest` — the group middleware fires first and the inline check would just double-fire. Plugin routes registered via `plugin.registerRoutes?.(router, pilotiq)` mount OUTSIDE the group; plugins own their own auth posture (public webhooks etc) and should consult `cfg.guard` themselves at handler entry if they want the panel guard.
83
+
84
+ Regression coverage: new `src/routes/guard.test.ts` iterates `router.list()` across a panel touching every register branch (resources + relation managers + globals + custom pages + clusters + theme editor + database notifications) and asserts each route 401s on `guard(() => false)` and reaches its handler on `guard(() => true)`.
85
+
86
+ - f75aa7d: perf: bundle of hot-path wins (Phase 5 of the code-quality sweep)
87
+
88
+ Four independent perf changes that share a release because they're each small and orthogonal. None of these were bottlenecks today; the cost rises around ~50 resources or ~10K imported rows.
89
+
90
+ - **5a — Chunked `Action.import`.** `runImport` used to walk rows serially: 5–10ms per round-trip × 10K rows × 2 round-trips for upsert mode adds up to ~100s of pinned request time. Each row now processes through a chunked `Promise.all` (default `concurrency: 10`). Per-row order within a chunk is non-deterministic; row indices in `summary.errors` still match the original CSV/JSON position. Tunable via `Action.import({ concurrency })`.
91
+
92
+ - **5b — Per-user navigation-badge TTL cache.** Every page render used to re-resolve every `R.navigationBadge()` / `G.navigationBadge()` / `C.navigationBadge()`. A panel with 20 resources each calling `Model.count()` for the badge was 20+ extra queries on every nav. Cache lives on the `Pilotiq` instance, keyed by `(ownerName, userIdentity)`, default TTL 30s. Configurable via `Pilotiq.navigationBadgeTtl(ms)` — pass `0` to disable, `null` to restore the default. User identity sniffs `user.id` (the 99% case for app-supplied users), falls back to JSON.stringify; anonymous requests share one slot.
93
+
94
+ - **5c — Map-indexed slug lookup.** `cfg.resources.find(r => r.getSlug() === slug)` and its siblings were called 16+ times per request across the page-data builders. New `pilotiq.findResource(slug)` / `findGlobal(slug)` / `findPage(slug)` accessors build a lazy `Map<slug, Class>` on first call and invalidate when the matching builder method (`.resources([…])` / `.globals([…])` / `.pages([…])` / `.dashboard(P)` / `.profile(P)`) mutates the array. O(n) → O(1) per lookup; measurable around 100+ resources.
95
+
96
+ - **5d — Parallel policy gates.** ~32 route handlers paired `await policyAccess(R, user)` with `await checkPolicy(() => R.canViewAny(user))` (or `canCreate` / `canEdit(user, undefined)` / `canView(user, undefined)`) serially. New `policyGate(owner, user, predicate)` helper composes both via `Promise.all`. Record-dependent predicates (e.g. `canEdit(user, record)` where `record` is loaded mid-handler) stay sequential — those calls weren't touched. The helper fail-closes on either branch throwing, matching the prior semantics.
97
+
98
+ Coverage: new `Pilotiq.perf.test.ts` covers the 5a/5b/5c surfaces (chunking + index preservation, TTL hit/miss + invalidation paths, Map invalidation across all setter sites). 5d is exercised by the existing authorization / routes tests — the contract is unchanged.
99
+
100
+ No public-surface changes beyond the three new opt-in accessors. Existing routes / callers keep working with their prior shape; the chunking + caching default-on behavior swaps in transparently.
101
+
102
+ - 15661ec: perf(orm): use `.first()` over `paginate(1, 1)` for single-row lookups
103
+
104
+ Three internal callsites — `loadSingularRecord`, `findRecord`, and the relation `childBelongsToParent` IDOR check — were hand-rolling "first matching row" as `paginate(1, 1)` then reading `result.data[0]`. The rudder ORM (and most Laravel-style query builders) ship `.first()` for this case; `paginate(1, 1)` builds + executes a COUNT query plus the data query, where `.first()` is a single `LIMIT 1` SELECT.
105
+
106
+ Added an optional `first?(): Promise<unknown | null>` to the structural `ModelQuery` shape (same pattern as `withTrashed?` / `whereGroup?` / `whereNull?`). Callsites use it when present, fall back to the existing `paginate(1, 1)` shape when absent — so test stubs and user-supplied `ModelLike` implementations don't have to update. The rudder `QueryBuilder` ships it; production paths get a ~half-RTT win on every record edit / view / Global page render / relation-edit IDOR check, with zero behaviour change.
107
+
108
+ No public API change. Existing tests cover both branches.
109
+
3
110
  ## 0.21.0
4
111
 
5
112
  ### Minor Changes
package/dist/Pilotiq.d.ts CHANGED
@@ -6,6 +6,7 @@ import type { ClusterClass } from './Cluster.js';
6
6
  import type { Page } from './Page.js';
7
7
  import type { SchemaDefinition } from './schema/resolveSchema.js';
8
8
  import type { ThemeConfig } from './theme/types.js';
9
+ import type { ThemeStorageAdapter } from './theme/storage.js';
9
10
  import type { UploadAdapter } from './uploads/UploadAdapter.js';
10
11
  import type { UserMenuItem } from './UserMenuItem.js';
11
12
  import type { NavigationBadgeColor } from './Resource.js';
@@ -212,6 +213,16 @@ export interface PilotiqConfig {
212
213
  profilePage?: typeof Page;
213
214
  theme?: ThemeConfig;
214
215
  themeEditor?: boolean;
216
+ /**
217
+ * Theme override persistence adapter — wired via
218
+ * `themeEditor({ storage })`. Reads/writes the JSON blob the editor
219
+ * page produces. Without this, the service provider falls back to
220
+ * the implicit Prisma adapter (auto-resolved via
221
+ * `app.make('prisma')`) for back-compat — that fallback is
222
+ * deprecated and will be removed in a future minor; pass `storage`
223
+ * explicitly.
224
+ */
225
+ themeStorage?: ThemeStorageAdapter;
215
226
  guard?: (req: unknown) => boolean | Promise<boolean>;
216
227
  user?: UserResolver;
217
228
  uploads?: UploadConfig;
@@ -303,6 +314,11 @@ export interface PilotiqConfig {
303
314
  aiSuggestionsMode?: 'auto' | 'review';
304
315
  /** @internal Runtime theme overrides from DB. */
305
316
  _themeOverrides?: Partial<ThemeConfig>;
317
+ /**
318
+ * TTL (milliseconds) for the per-user navigation badge cache. Set to
319
+ * `0` (or `null` via the builder) to disable caching. Default 30000.
320
+ */
321
+ navigationBadgeTtlMs?: number;
306
322
  }
307
323
  /**
308
324
  * Shape a layout-provider component must implement. Receives the
@@ -352,6 +368,21 @@ export interface ComponentSlots {
352
368
  export declare class Pilotiq {
353
369
  private config;
354
370
  private installedPlugins;
371
+ /** Lazy slug-indexed caches. Built on first lookup; invalidated when
372
+ * the underlying setter mutates the matching array. Resources /
373
+ * globals / pages are looked up by slug 16+ times per request across
374
+ * the page-data builders — the linear `Array.find` adds up around 50+
375
+ * resources. */
376
+ private _resourceBySlug?;
377
+ private _globalBySlug?;
378
+ private _pageBySlug?;
379
+ /**
380
+ * Per-user navigation badge cache. Keyed by `${ownerName}|${userKey}`
381
+ * — `userKey` derived from `user.id` (or the primitive user / JSON
382
+ * fallback / `''` for anon). Each entry expires after
383
+ * `getNavigationBadgeTtl()` ms.
384
+ */
385
+ private _navigationBadgeCache;
355
386
  private constructor();
356
387
  static make(name: string): Pilotiq;
357
388
  path(p: string): this;
@@ -732,12 +763,53 @@ export declare class Pilotiq {
732
763
  getAiSuggestionsMode(): 'auto' | 'review';
733
764
  /** @internal */
734
765
  enableThemeEditor(): void;
766
+ /** @internal — assign the storage adapter resolved by the
767
+ * `themeEditor({ storage })` plugin OR by the service provider's
768
+ * back-compat Prisma fallback. Both writers funnel through this
769
+ * setter so the route handlers consume a single slot. */
770
+ _setThemeStorage(adapter: ThemeStorageAdapter | undefined): void;
771
+ /** @internal — the active theme storage adapter (explicit or the
772
+ * boot-time Prisma fallback). Routes read from here. */
773
+ getThemeStorage(): ThemeStorageAdapter | undefined;
735
774
  /** @internal */
736
775
  setThemeOverrides(overrides: Partial<ThemeConfig> | undefined): void;
737
776
  /** @internal — returns code defaults merged with DB overrides. Returns an
738
777
  * empty config when the theme editor is on so the built-in default preset
739
778
  * still resolves and the editor can persist overrides on top. */
740
779
  getMergedTheme(): ThemeConfig | undefined;
780
+ /**
781
+ * Slug-indexed lookup for resources. O(1) replacement for
782
+ * `cfg.resources.find(r => r.getSlug() === slug)`. Built lazily on
783
+ * first call; invalidated when `.resources([…])` is reassigned.
784
+ */
785
+ findResource(slug: string): ResourceClass | undefined;
786
+ /** Slug-indexed lookup for globals. See `findResource`. */
787
+ findGlobal(slug: string): GlobalClass | undefined;
788
+ /** Slug-indexed lookup for pages. See `findResource`. */
789
+ findPage(slug: string): typeof Page | undefined;
790
+ /**
791
+ * TTL (milliseconds) for the per-user navigation badge cache. Badges
792
+ * resolve once per `(owner, userIdentity)` pair and serve from the
793
+ * in-memory cache until the TTL elapses; the cache covers the
794
+ * common case where a panel with N resources each running
795
+ * `Model.count()` for a sidebar badge would otherwise issue N queries
796
+ * on every page nav.
797
+ *
798
+ * Pass `0` (or `null`) to disable caching entirely. Default 30000.
799
+ */
800
+ navigationBadgeTtl(ms: number | null): this;
801
+ /** @internal — resolved TTL in milliseconds. Default 30s. `0`
802
+ * disables caching (each request re-resolves). */
803
+ getNavigationBadgeTtl(): number;
804
+ /** @internal — cache key for one (owner, user) pair. */
805
+ navigationBadgeCacheKey(ownerName: string, user: unknown): string;
806
+ /** @internal — read-through cache for a single owner's badge value.
807
+ * Caller supplies the resolver; cache wraps it with the configured
808
+ * TTL. When TTL is 0 the resolver is invoked unconditionally and
809
+ * nothing is stored. */
810
+ resolveNavigationBadge(ownerName: string, user: unknown, resolver: () => Promise<string | undefined>): Promise<string | undefined>;
811
+ /** @internal — test seam; clears the per-user badge cache. */
812
+ _clearNavigationBadgeCache(): void;
741
813
  /** @internal */
742
814
  getConfig(): Readonly<PilotiqConfig>;
743
815
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"Pilotiq.d.ts","sourceRoot":"","sources":["../src/Pilotiq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACzD,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,cAAc,EACd,eAAe,EAChB,MAAM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SAAS;IAOrD,2DAA2D;IAC3D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAOjD,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,IAAI,GAAG,SAAS;IAO/C;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAW3C;uDACmD;IACnD,qBAAqB,IAAI,MAAM;IAI/B,wDAAwD;IACxD,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM;IAIjE;;;6BAGyB;IACnB,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAO,OAAO,EAClB,QAAQ,EAAG,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAC3C,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAc9B,8DAA8D;IAC9D,0BAA0B,IAAI,IAAI;IAIlC,gBAAgB;IAChB,SAAS,IAAI,QAAQ,CAAC,aAAa,CAAC;IAIpC,gBAAgB;IAChB,UAAU,IAAI,SAAS,aAAa,EAAE;CAGvC"}
package/dist/Pilotiq.js CHANGED
@@ -2,6 +2,21 @@ import { validateRightPanel, findDuplicateRightPanelId, } from './RightPanel.js'
2
2
  export class Pilotiq {
3
3
  config;
4
4
  installedPlugins = [];
5
+ /** Lazy slug-indexed caches. Built on first lookup; invalidated when
6
+ * the underlying setter mutates the matching array. Resources /
7
+ * globals / pages are looked up by slug 16+ times per request across
8
+ * the page-data builders — the linear `Array.find` adds up around 50+
9
+ * resources. */
10
+ _resourceBySlug;
11
+ _globalBySlug;
12
+ _pageBySlug;
13
+ /**
14
+ * Per-user navigation badge cache. Keyed by `${ownerName}|${userKey}`
15
+ * — `userKey` derived from `user.id` (or the primitive user / JSON
16
+ * fallback / `''` for anon). Each entry expires after
17
+ * `getNavigationBadgeTtl()` ms.
18
+ */
19
+ _navigationBadgeCache = new Map();
5
20
  constructor(name) {
6
21
  this.config = {
7
22
  name,
@@ -27,14 +42,17 @@ export class Pilotiq {
27
42
  }
28
43
  resources(r) {
29
44
  this.config.resources = r;
45
+ delete this._resourceBySlug;
30
46
  return this;
31
47
  }
32
48
  globals(g) {
33
49
  this.config.globals = g;
50
+ delete this._globalBySlug;
34
51
  return this;
35
52
  }
36
53
  pages(p) {
37
54
  this.config.pages = p;
55
+ delete this._pageBySlug;
38
56
  return this;
39
57
  }
40
58
  clusters(c) {
@@ -76,6 +94,7 @@ export class Pilotiq {
76
94
  this.config.dashboardPage = P;
77
95
  if (!this.config.pages.includes(P)) {
78
96
  this.config.pages = [...this.config.pages, P];
97
+ delete this._pageBySlug;
79
98
  }
80
99
  return this;
81
100
  }
@@ -98,6 +117,7 @@ export class Pilotiq {
98
117
  this.config.profilePage = P;
99
118
  if (!this.config.pages.includes(P)) {
100
119
  this.config.pages = [...this.config.pages, P];
120
+ delete this._pageBySlug;
101
121
  }
102
122
  return this;
103
123
  }
@@ -558,6 +578,23 @@ export class Pilotiq {
558
578
  enableThemeEditor() {
559
579
  this.config.themeEditor = true;
560
580
  }
581
+ /** @internal — assign the storage adapter resolved by the
582
+ * `themeEditor({ storage })` plugin OR by the service provider's
583
+ * back-compat Prisma fallback. Both writers funnel through this
584
+ * setter so the route handlers consume a single slot. */
585
+ _setThemeStorage(adapter) {
586
+ if (adapter === undefined) {
587
+ delete this.config.themeStorage;
588
+ }
589
+ else {
590
+ this.config.themeStorage = adapter;
591
+ }
592
+ }
593
+ /** @internal — the active theme storage adapter (explicit or the
594
+ * boot-time Prisma fallback). Routes read from here. */
595
+ getThemeStorage() {
596
+ return this.config.themeStorage;
597
+ }
561
598
  /** @internal */
562
599
  setThemeOverrides(overrides) {
563
600
  if (overrides === undefined) {
@@ -577,6 +614,82 @@ export class Pilotiq {
577
614
  return undefined;
578
615
  return { ...base, ...overrides };
579
616
  }
617
+ /**
618
+ * Slug-indexed lookup for resources. O(1) replacement for
619
+ * `cfg.resources.find(r => r.getSlug() === slug)`. Built lazily on
620
+ * first call; invalidated when `.resources([…])` is reassigned.
621
+ */
622
+ findResource(slug) {
623
+ if (!this._resourceBySlug) {
624
+ this._resourceBySlug = new Map(this.config.resources.map(r => [r.getSlug(), r]));
625
+ }
626
+ return this._resourceBySlug.get(slug);
627
+ }
628
+ /** Slug-indexed lookup for globals. See `findResource`. */
629
+ findGlobal(slug) {
630
+ if (!this._globalBySlug) {
631
+ this._globalBySlug = new Map(this.config.globals.map(g => [g.getSlug(), g]));
632
+ }
633
+ return this._globalBySlug.get(slug);
634
+ }
635
+ /** Slug-indexed lookup for pages. See `findResource`. */
636
+ findPage(slug) {
637
+ if (!this._pageBySlug) {
638
+ this._pageBySlug = new Map(this.config.pages.map(p => [p.getSlug(), p]));
639
+ }
640
+ return this._pageBySlug.get(slug);
641
+ }
642
+ /**
643
+ * TTL (milliseconds) for the per-user navigation badge cache. Badges
644
+ * resolve once per `(owner, userIdentity)` pair and serve from the
645
+ * in-memory cache until the TTL elapses; the cache covers the
646
+ * common case where a panel with N resources each running
647
+ * `Model.count()` for a sidebar badge would otherwise issue N queries
648
+ * on every page nav.
649
+ *
650
+ * Pass `0` (or `null`) to disable caching entirely. Default 30000.
651
+ */
652
+ navigationBadgeTtl(ms) {
653
+ if (ms === null) {
654
+ delete this.config.navigationBadgeTtlMs;
655
+ }
656
+ else {
657
+ this.config.navigationBadgeTtlMs = Math.max(0, ms);
658
+ }
659
+ // Bust on reconfigure so the new TTL doesn't reuse stale slots.
660
+ this._navigationBadgeCache.clear();
661
+ return this;
662
+ }
663
+ /** @internal — resolved TTL in milliseconds. Default 30s. `0`
664
+ * disables caching (each request re-resolves). */
665
+ getNavigationBadgeTtl() {
666
+ return this.config.navigationBadgeTtlMs ?? 30_000;
667
+ }
668
+ /** @internal — cache key for one (owner, user) pair. */
669
+ navigationBadgeCacheKey(ownerName, user) {
670
+ return `${ownerName}|${userIdentityKey(user)}`;
671
+ }
672
+ /** @internal — read-through cache for a single owner's badge value.
673
+ * Caller supplies the resolver; cache wraps it with the configured
674
+ * TTL. When TTL is 0 the resolver is invoked unconditionally and
675
+ * nothing is stored. */
676
+ async resolveNavigationBadge(ownerName, user, resolver) {
677
+ const ttl = this.getNavigationBadgeTtl();
678
+ if (ttl <= 0)
679
+ return resolver();
680
+ const key = this.navigationBadgeCacheKey(ownerName, user);
681
+ const now = Date.now();
682
+ const hit = this._navigationBadgeCache.get(key);
683
+ if (hit && hit.expires > now)
684
+ return hit.value;
685
+ const value = await resolver();
686
+ this._navigationBadgeCache.set(key, { value, expires: now + ttl });
687
+ return value;
688
+ }
689
+ /** @internal — test seam; clears the per-user badge cache. */
690
+ _clearNavigationBadgeCache() {
691
+ this._navigationBadgeCache.clear();
692
+ }
580
693
  /** @internal */
581
694
  getConfig() {
582
695
  return this.config;
@@ -586,4 +699,36 @@ export class Pilotiq {
586
699
  return this.installedPlugins;
587
700
  }
588
701
  }
702
+ /**
703
+ * Stable cache key derived from a user object. Pilotiq treats the user
704
+ * as opaque, so we sniff the common shapes:
705
+ *
706
+ * 1. `null` / `undefined` — anonymous request; everyone shares one slot.
707
+ * 2. Primitive (string / number / bigint / boolean) — stringify directly.
708
+ * 3. Object with `id` — `String(user.id)` (the 99% case for app-supplied users).
709
+ * 4. Other objects — `JSON.stringify` as a last resort; falls back to a
710
+ * sentinel if stringify throws (cycles).
711
+ *
712
+ * Two distinct users with the same `id` collide, but that's the same
713
+ * collision the rest of the framework already trusts.
714
+ */
715
+ function userIdentityKey(user) {
716
+ if (user === null || user === undefined)
717
+ return '';
718
+ const t = typeof user;
719
+ if (t === 'string' || t === 'number' || t === 'bigint' || t === 'boolean')
720
+ return String(user);
721
+ if (t === 'object') {
722
+ const u = user;
723
+ if (u.id !== undefined && u.id !== null)
724
+ return String(u.id);
725
+ try {
726
+ return JSON.stringify(user);
727
+ }
728
+ catch {
729
+ return '__opaque__';
730
+ }
731
+ }
732
+ return '__opaque__';
733
+ }
589
734
  //# sourceMappingUR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ACxB,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAA;IACpC,CAAC;IAED,gBAAgB;IAChB,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,gBAAgB;IAChB,UAAU;QACR,OAAO,IAAI,CAAC,gBAAgB,CAAA;IAC9B,CAAC;CACF;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,eAAe,CAAC,IAAa;IACpC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IAClD,MAAM,CAAC,GAAG,OAAO,IAAI,CAAA;IACrB,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAA;IAC9F,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;QACnB,MAAM,CAAC,GAAG,IAAwB,CAAA;QAClC,IAAI,CAAC,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,CAAC,EAAE,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;QAC5D,IAAI,CAAC;YAAC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,OAAO,YAAY,CAAA;QAAC,CAAC;IACnE,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { ServiceProvider } from '@rudderjs/core';
2
2
  import type { Application } from '@rudderjs/core';
3
3
  import type { Pilotiq } from './Pilotiq.js';
4
+ /** @internal — test seam; resets the "deprecation already warned" memo. */
5
+ export declare function _resetThemeFallbackWarned(): void;
4
6
  /**
5
7
  * Register one or more Pilotiq panels and mount their view routes.
6
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"PilotiqServiceProvider.d.ts","sourceRoot":"","sources":["../src/PilotiqServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AA+C3C;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,SAAS,EAAE,OAAO,EAAE,GACnB,KAAK,GAAG,EAAE,WAAW,KAAK,eAAe,CAM3C"}
1
+ {"version":3,"file":"PilotiqServiceProvider.d.ts","sourceRoot":"","sources":["../src/PilotiqServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AA4F3C,2EAA2E;AAC3E,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CACrB,SAAS,EAAE,OAAO,EAAE,GACnB,KAAK,GAAG,EAAE,WAAW,KAAK,eAAe,CAM3C"}
@@ -1,7 +1,10 @@
1
1
  import { ServiceProvider } from '@rudderjs/core';
2
2
  import { PilotiqRegistry } from './PilotiqRegistry.js';
3
3
  import { registerPilotiqRoutes } from './routes.js';
4
+ import { migrateThemeOverrides } from './theme/migrate.js';
5
+ import { prismaThemeStorage } from './theme/storage.js';
4
6
  // ─── Service Provider ─────────────────────────────────────
7
+ const autoFallbackWarned = new Set();
5
8
  class PilotiqServiceProvider extends ServiceProvider {
6
9
  panels;
7
10
  constructor(app, panels) {
@@ -16,25 +19,70 @@ class PilotiqServiceProvider extends ServiceProvider {
16
19
  }
17
20
  async boot() {
18
21
  const { router } = await import('@rudderjs/router');
19
- // Load saved theme overrides from DB for panels with themeEditor enabled
20
22
  for (const panel of PilotiqRegistry.all()) {
21
23
  if (panel.getConfig().themeEditor) {
22
- try {
23
- const prisma = this.app.make('prisma');
24
- const slug = `${panel.getConfig().name}__theme`;
25
- const row = await prisma.panelGlobal.findUnique({ where: { slug } });
26
- if (row?.data) {
27
- const raw = typeof row.data === 'string' ? JSON.parse(row.data) : row.data;
28
- const { migrateThemeOverrides } = await import('./theme/migrate.js');
29
- panel.setThemeOverrides(migrateThemeOverrides(raw));
30
- }
31
- }
32
- catch { /* no DB or no table — use code defaults */ }
24
+ await loadThemeOverrides(this.app, panel);
33
25
  }
34
26
  registerPilotiqRoutes(router, panel);
35
27
  }
36
28
  }
37
29
  }
30
+ /**
31
+ * Resolve the panel's theme storage adapter and hydrate any persisted
32
+ * overrides onto the panel.
33
+ *
34
+ * - Explicit `themeEditor({ storage })`: errors bubble (the user opted
35
+ * in, misconfiguration should surface loudly).
36
+ * - Implicit Prisma fallback: errors swallowed for back-compat with a
37
+ * one-time deprecation warning. Removing this branch is the breaking
38
+ * change scheduled for the next minor.
39
+ */
40
+ async function loadThemeOverrides(app, panel) {
41
+ const adapter = resolveThemeStorage(app, panel);
42
+ if (!adapter)
43
+ return;
44
+ const isExplicit = panel.getConfig().themeStorage === adapter;
45
+ if (!isExplicit)
46
+ panel._setThemeStorage(adapter);
47
+ try {
48
+ const overrides = await adapter.load();
49
+ if (overrides)
50
+ panel.setThemeOverrides(migrateThemeOverrides(overrides));
51
+ }
52
+ catch (e) {
53
+ if (isExplicit)
54
+ throw e;
55
+ // Implicit fallback: swallow connection / schema errors. Removed
56
+ // alongside the auto-fallback branch in a future minor.
57
+ }
58
+ }
59
+ function resolveThemeStorage(app, panel) {
60
+ const explicit = panel.getConfig().themeStorage;
61
+ if (explicit)
62
+ return explicit;
63
+ let prisma;
64
+ try {
65
+ prisma = app.make('prisma');
66
+ }
67
+ catch {
68
+ return null;
69
+ }
70
+ if (!prisma || typeof prisma.panelGlobal?.findUnique !== 'function')
71
+ return null;
72
+ const panelName = panel.getConfig().name;
73
+ if (!autoFallbackWarned.has(panelName)) {
74
+ autoFallbackWarned.add(panelName);
75
+ console.warn(`[pilotiq] themeEditor() on panel "${panelName}" is using the implicit ` +
76
+ `Prisma fallback for theme persistence. Pass storage explicitly — ` +
77
+ `themeEditor({ storage: prismaThemeStorage(prisma, { slug: '${panelName}__theme' }) }) — ` +
78
+ `the implicit fallback is deprecated and will be removed in a future minor.`);
79
+ }
80
+ return prismaThemeStorage(prisma, { slug: `${panelName}__theme` });
81
+ }
82
+ /** @internal — test seam; resets the "deprecation already warned" memo. */
83
+ export function _resetThemeFallbackWarned() {
84
+ autoFallbackWarned.clear();
85
+ }
38
86
  // ─── Factory ──────────────────────────────────────────────
39
87
  /**
40
88
  * Register one or more Pilotiq panels and mount their view routes.