gemi 0.58.1 → 0.60.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.
- package/dist/ai/Agent.d.ts +33 -0
- package/dist/ai/Agent.d.ts.map +1 -0
- package/dist/ai/AgentController.d.ts +8 -0
- package/dist/ai/AgentController.d.ts.map +1 -0
- package/dist/ai/useChat.d.ts +12 -0
- package/dist/ai/useChat.d.ts.map +1 -0
- package/dist/app/index.js +1 -1
- package/dist/bin/gemi.js +500 -16
- package/dist/bin/gemi.js.map +10 -5
- package/dist/broadcasting/index.js +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-szss069z.js → chunk-06j6rsew.js} +2 -2
- package/dist/{chunk-szss069z.js.map → chunk-06j6rsew.js.map} +1 -1
- package/dist/{chunk-yjzs247s.js → chunk-0fm6jh9b.js} +2 -2
- package/dist/{chunk-yjzs247s.js.map → chunk-0fm6jh9b.js.map} +1 -1
- package/dist/chunk-23h0dmx2.js +5 -0
- package/dist/{chunk-87qab82w.js.map → chunk-23h0dmx2.js.map} +3 -3
- package/dist/{chunk-m3xy5xyf.js → chunk-2cwcfwg3.js} +2 -2
- package/dist/{chunk-m3xy5xyf.js.map → chunk-2cwcfwg3.js.map} +1 -1
- package/dist/{chunk-xzk827r3.js → chunk-2khdxyjb.js} +2 -2
- package/dist/{chunk-xzk827r3.js.map → chunk-2khdxyjb.js.map} +1 -1
- package/dist/{chunk-sy7jbdeb.js → chunk-3296fwss.js} +2 -2
- package/dist/{chunk-sy7jbdeb.js.map → chunk-3296fwss.js.map} +1 -1
- package/dist/{chunk-xdv1b8mr.js → chunk-3gvjn3q4.js} +2 -2
- package/dist/{chunk-xdv1b8mr.js.map → chunk-3gvjn3q4.js.map} +1 -1
- package/dist/{chunk-jhkjz9jr.js → chunk-4dan69s4.js} +2 -2
- package/dist/{chunk-3zxwscmf.js.map → chunk-4dan69s4.js.map} +1 -1
- package/dist/{chunk-hxf1re93.js → chunk-4mcyyh1v.js} +2 -2
- package/dist/{chunk-hxf1re93.js.map → chunk-4mcyyh1v.js.map} +1 -1
- package/dist/{chunk-w62m5f0n.js → chunk-5gdv4n4a.js} +3 -3
- package/dist/{chunk-w62m5f0n.js.map → chunk-5gdv4n4a.js.map} +1 -1
- package/dist/{chunk-j0c6ytkj.js → chunk-8kj3zrm9.js} +3 -3
- package/dist/{chunk-j0c6ytkj.js.map → chunk-8kj3zrm9.js.map} +1 -1
- package/dist/{chunk-0a2xgcj3.js → chunk-98a3k7bp.js} +2 -2
- package/dist/{chunk-0a2xgcj3.js.map → chunk-98a3k7bp.js.map} +1 -1
- package/dist/{chunk-5athahgr.js → chunk-9gsdcjt7.js} +2 -2
- package/dist/{chunk-5athahgr.js.map → chunk-9gsdcjt7.js.map} +1 -1
- package/dist/{chunk-pmhd6zfc.js → chunk-b0t4zp6b.js} +2 -2
- package/dist/{chunk-pmhd6zfc.js.map → chunk-b0t4zp6b.js.map} +1 -1
- package/dist/{chunk-3xadx444.js → chunk-bn1v4sfs.js} +2 -2
- package/dist/{chunk-3xadx444.js.map → chunk-bn1v4sfs.js.map} +1 -1
- package/dist/{chunk-9m2tbf3n.js → chunk-c40n5r4v.js} +2 -2
- package/dist/{chunk-9m2tbf3n.js.map → chunk-c40n5r4v.js.map} +1 -1
- package/dist/{chunk-a2sgjpvq.js → chunk-cejf873g.js} +2 -2
- package/dist/{chunk-a2sgjpvq.js.map → chunk-cejf873g.js.map} +1 -1
- package/dist/{chunk-tss5svjr.js → chunk-cw9y6k15.js} +2 -2
- package/dist/{chunk-tss5svjr.js.map → chunk-cw9y6k15.js.map} +1 -1
- package/dist/{chunk-5n2rvfh3.js → chunk-cyrxdj6a.js} +2 -2
- package/dist/{chunk-5n2rvfh3.js.map → chunk-cyrxdj6a.js.map} +1 -1
- package/dist/chunk-dgasxgsm.js +19 -0
- package/dist/{chunk-hwa5sqw5.js.map → chunk-dgasxgsm.js.map} +6 -6
- package/dist/{chunk-3g5bjvdf.js → chunk-f6dd4gd8.js} +2 -2
- package/dist/{chunk-3g5bjvdf.js.map → chunk-f6dd4gd8.js.map} +1 -1
- package/dist/{chunk-qgxr0g36.js → chunk-fb4cy6sq.js} +2 -2
- package/dist/{chunk-qgxr0g36.js.map → chunk-fb4cy6sq.js.map} +1 -1
- package/dist/{chunk-7ef5n8k2.js → chunk-fbvvqf9b.js} +2 -2
- package/dist/{chunk-7ef5n8k2.js.map → chunk-fbvvqf9b.js.map} +1 -1
- package/dist/{chunk-zbxgbr12.js → chunk-fxy42w6n.js} +2 -2
- package/dist/{chunk-zbxgbr12.js.map → chunk-fxy42w6n.js.map} +1 -1
- package/dist/{chunk-xey9cbap.js → chunk-get4mkx8.js} +2 -2
- package/dist/{chunk-xey9cbap.js.map → chunk-get4mkx8.js.map} +1 -1
- package/dist/{chunk-3zxwscmf.js → chunk-gwchvzdp.js} +2 -2
- package/dist/{chunk-jhkjz9jr.js.map → chunk-gwchvzdp.js.map} +1 -1
- package/dist/{chunk-k0fvsyeh.js → chunk-hsfjt13m.js} +1 -1
- package/dist/{chunk-yf7vz71n.js → chunk-hwhw98hc.js} +1 -1
- package/dist/{chunk-fjm4y8bn.js → chunk-hxb1eg2z.js} +2 -2
- package/dist/{chunk-fjm4y8bn.js.map → chunk-hxb1eg2z.js.map} +1 -1
- package/dist/{chunk-7b0x860b.js → chunk-j06g4sqc.js} +2 -2
- package/dist/{chunk-7b0x860b.js.map → chunk-j06g4sqc.js.map} +1 -1
- package/dist/{chunk-dgsgjg53.js → chunk-j23cengk.js} +2 -2
- package/dist/{chunk-dgsgjg53.js.map → chunk-j23cengk.js.map} +1 -1
- package/dist/{chunk-vj6f2bmb.js → chunk-khf9xda6.js} +3 -3
- package/dist/{chunk-vj6f2bmb.js.map → chunk-khf9xda6.js.map} +1 -1
- package/dist/{chunk-437085pe.js → chunk-p3qd0gqa.js} +2 -2
- package/dist/{chunk-437085pe.js.map → chunk-p3qd0gqa.js.map} +1 -1
- package/dist/{chunk-gw6agevz.js → chunk-pkjq9833.js} +3 -3
- package/dist/{chunk-gw6agevz.js.map → chunk-pkjq9833.js.map} +1 -1
- package/dist/{chunk-7j6wbv12.js → chunk-q0y0j3ne.js} +2 -2
- package/dist/{chunk-7j6wbv12.js.map → chunk-q0y0j3ne.js.map} +1 -1
- package/dist/chunk-q6qghsy7.js +5 -0
- package/dist/{chunk-b35e128b.js.map → chunk-q6qghsy7.js.map} +1 -1
- package/dist/{chunk-wbrj0gya.js → chunk-qva4841r.js} +2 -2
- package/dist/{chunk-wbrj0gya.js.map → chunk-qva4841r.js.map} +1 -1
- package/dist/{chunk-86jebsm4.js → chunk-rkbv3df7.js} +3 -3
- package/dist/{chunk-86jebsm4.js.map → chunk-rkbv3df7.js.map} +1 -1
- package/dist/{chunk-keehyx51.js → chunk-rpjsmr41.js} +2 -2
- package/dist/{chunk-keehyx51.js.map → chunk-rpjsmr41.js.map} +1 -1
- package/dist/{chunk-mwpdp09e.js → chunk-spbgpndn.js} +2 -2
- package/dist/{chunk-mwpdp09e.js.map → chunk-spbgpndn.js.map} +1 -1
- package/dist/{chunk-yy0eb9wn.js → chunk-stq96kya.js} +2 -2
- package/dist/{chunk-yy0eb9wn.js.map → chunk-stq96kya.js.map} +1 -1
- package/dist/{chunk-d125j8t0.js → chunk-tds3xq6b.js} +3 -3
- package/dist/{chunk-d125j8t0.js.map → chunk-tds3xq6b.js.map} +1 -1
- package/dist/{chunk-3337e5g0.js → chunk-tey1xayb.js} +2 -2
- package/dist/{chunk-3337e5g0.js.map → chunk-tey1xayb.js.map} +1 -1
- package/dist/{chunk-w7rf99w6.js → chunk-vj9538yn.js} +2 -2
- package/dist/{chunk-w7rf99w6.js.map → chunk-vj9538yn.js.map} +1 -1
- package/dist/{chunk-yed5whgs.js → chunk-wcv6qtpq.js} +3 -3
- package/dist/{chunk-yed5whgs.js.map → chunk-wcv6qtpq.js.map} +1 -1
- package/dist/{chunk-vr90r27j.js → chunk-wzvs3sym.js} +2 -2
- package/dist/{chunk-vr90r27j.js.map → chunk-wzvs3sym.js.map} +1 -1
- package/dist/{chunk-cyaz97p5.js → chunk-x6y1z4cq.js} +2 -2
- package/dist/{chunk-cyaz97p5.js.map → chunk-x6y1z4cq.js.map} +1 -1
- package/dist/chunk-x8beq9c4.js +55 -0
- package/dist/chunk-x8beq9c4.js.map +11 -0
- package/dist/{chunk-6235kb30.js → chunk-xecj8025.js} +3 -3
- package/dist/{chunk-6235kb30.js.map → chunk-xecj8025.js.map} +1 -1
- package/dist/chunk-y3zz410b.js +6 -0
- package/dist/{chunk-4sz6pwtn.js.map → chunk-y3zz410b.js.map} +2 -2
- package/dist/{chunk-eejmhtnc.js → chunk-y64j80v9.js} +2 -2
- package/dist/{chunk-eejmhtnc.js.map → chunk-y64j80v9.js.map} +1 -1
- package/dist/{chunk-zh2egcyb.js → chunk-ygfwtgvm.js} +2 -2
- package/dist/{chunk-zh2egcyb.js.map → chunk-ygfwtgvm.js.map} +1 -1
- package/dist/{chunk-4yt5x8s2.js → chunk-ys904esh.js} +2 -2
- package/dist/{chunk-4yt5x8s2.js.map → chunk-ys904esh.js.map} +1 -1
- package/dist/{chunk-y6a8r2bn.js → chunk-z1e55w67.js} +3 -3
- package/dist/{chunk-y6a8r2bn.js.map → chunk-z1e55w67.js.map} +1 -1
- package/dist/{chunk-qb5mv6pj.js → chunk-z2tcxwyr.js} +3 -3
- package/dist/{chunk-qb5mv6pj.js.map → chunk-z2tcxwyr.js.map} +1 -1
- package/dist/{chunk-hppagzz4.js → chunk-zhbrkpb3.js} +4 -4
- package/dist/{chunk-hppagzz4.js.map → chunk-zhbrkpb3.js.map} +1 -1
- package/dist/{chunk-grdahng8.js → chunk-zqsfanvk.js} +2 -2
- package/dist/{chunk-grdahng8.js.map → chunk-zqsfanvk.js.map} +1 -1
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +2 -2
- package/dist/config/index.js.map +3 -3
- package/dist/console/run.js +2 -2
- package/dist/console/run.js.map +1 -1
- package/dist/container/index.js +2 -2
- package/dist/container/index.js.map +1 -1
- package/dist/database/index.js +2 -2
- package/dist/database/index.js.map +1 -1
- package/dist/email/index.js +2 -2
- package/dist/email/index.js.map +1 -1
- package/dist/facades/Features.d.ts +67 -1
- package/dist/facades/Features.d.ts.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/foundation/index.js +2 -2
- package/dist/foundation/index.js.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +2 -2
- package/dist/i18n/dictionaryRuntime.js.map +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +2 -2
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +1 -1
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +1 -1
- package/dist/server/Server.d.ts.map +1 -1
- package/dist/server/httpDev.d.ts.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +3 -3
- package/dist/services/events/Event.d.ts +6 -0
- package/dist/services/events/Event.d.ts.map +1 -1
- package/dist/services/features/FeatureFlagStore.d.ts +56 -0
- package/dist/services/features/FeatureFlagStore.d.ts.map +1 -1
- package/dist/services/features/FeatureManager.d.ts +35 -1
- package/dist/services/features/FeatureManager.d.ts.map +1 -1
- package/dist/services/features/types.d.ts +62 -0
- package/dist/services/features/types.d.ts.map +1 -1
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +8 -8
- package/dist/services/index.js.map +3 -3
- package/dist/services/logging/LogManager.d.ts +10 -1
- package/dist/services/logging/LogManager.d.ts.map +1 -1
- package/dist/services/logging/LogServiceProvider.d.ts +10 -0
- package/dist/services/logging/LogServiceProvider.d.ts.map +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/package.json +3 -2
- package/skills/gemi-react-best-practices/SKILL.md +231 -0
- package/skills/gemi-react-best-practices/rules/_sections.md +56 -0
- package/skills/gemi-react-best-practices/rules/_template.md +28 -0
- package/skills/gemi-react-best-practices/rules/bundle-deep-imports.md +48 -0
- package/skills/gemi-react-best-practices/rules/bundle-mount-gate-heavy-panels.md +63 -0
- package/skills/gemi-react-best-practices/rules/client-form-vs-mutation-hooks.md +57 -0
- package/skills/gemi-react-best-practices/rules/client-loading-error-exports.md +54 -0
- package/skills/gemi-react-best-practices/rules/client-no-effect-data-flow.md +68 -0
- package/skills/gemi-react-best-practices/rules/client-typed-links.md +51 -0
- package/skills/gemi-react-best-practices/rules/controller-authorize-every-tenant-read.md +65 -0
- package/skills/gemi-react-best-practices/rules/controller-parse-request-at-the-boundary.md +54 -0
- package/skills/gemi-react-best-practices/rules/controller-redirect-facade-throws.md +68 -0
- package/skills/gemi-react-best-practices/rules/controller-request-schema.md +61 -0
- package/skills/gemi-react-best-practices/rules/controller-throw-framework-errors.md +57 -0
- package/skills/gemi-react-best-practices/rules/i18n-define-dictionary-inline.md +58 -0
- package/skills/gemi-react-best-practices/rules/orm-analytics-connection.md +53 -0
- package/skills/gemi-react-best-practices/rules/orm-include-not-n-plus-one.md +56 -0
- package/skills/gemi-react-best-practices/rules/orm-paginate-helper.md +69 -0
- package/skills/gemi-react-best-practices/rules/orm-plain-rows-by-default.md +55 -0
- package/skills/gemi-react-best-practices/rules/orm-select-narrow.md +58 -0
- package/skills/gemi-react-best-practices/rules/orm-transaction-no-io.md +54 -0
- package/skills/gemi-react-best-practices/rules/orm-transaction-sequential.md +64 -0
- package/skills/gemi-react-best-practices/rules/payload-dont-overprefetch.md +54 -0
- package/skills/gemi-react-best-practices/rules/payload-instant-vs-prefetch.md +58 -0
- package/skills/gemi-react-best-practices/rules/payload-minimal-view-props.md +51 -0
- package/skills/gemi-react-best-practices/rules/payload-parallel-controller-work.md +56 -0
- package/skills/gemi-react-best-practices/rules/payload-prefetch-late-queries.md +58 -0
- package/skills/gemi-react-best-practices/rules/payload-prefetch-mirrors-usequery.md +52 -0
- package/skills/gemi-react-best-practices/rules/query-debounce-search-variant.md +52 -0
- package/skills/gemi-react-best-practices/rules/query-keep-previous-data.md +40 -0
- package/skills/gemi-react-best-practices/rules/query-lazy-vs-mount-gate.md +54 -0
- package/skills/gemi-react-best-practices/rules/query-mutate-over-refetch.md +55 -0
- package/skills/gemi-react-best-practices/rules/query-no-hand-rolled-fetch.md +60 -0
- package/skills/gemi-react-best-practices/rules/query-revalidate-on-focus.md +44 -0
- package/skills/gemi-react-best-practices/rules/query-share-cache-key.md +51 -0
- package/skills/gemi-react-best-practices/rules/query-suspense-default.md +52 -0
- package/skills/gemi-react-best-practices/rules/routing-cache-policy-constants.md +53 -0
- package/skills/gemi-react-best-practices/rules/routing-middleware-dsl.md +60 -0
- package/skills/gemi-react-best-practices/rules/routing-resource-routes.md +59 -0
- package/skills/gemi-react-best-practices/rules/routing-routers-are-classes.md +55 -0
- package/skills/gemi-react-best-practices/rules/service-lazy-not-module-scope.md +63 -0
- package/skills/gemi-react-best-practices/rules/service-queue-is-in-memory.md +52 -0
- package/skills/gemi-react-best-practices/rules/service-static-token-and-name.md +52 -0
- package/skills/gemi-react-best-practices/rules/structure-discovered-vs-registered.md +71 -0
- package/skills/gemi-react-best-practices/rules/structure-do-not-reinvent-the-framework.md +58 -0
- package/skills/gemi-react-best-practices/rules/testing-assert-behaviour-over-markup.md +54 -0
- package/skills/gemi-react-best-practices/rules/testing-match-the-suite.md +57 -0
- package/skills/gemi-react-best-practices/rules/testing-page-seeds-real-inputs.md +65 -0
- package/dist/chunk-01e3gk86.js +0 -55
- package/dist/chunk-01e3gk86.js.map +0 -11
- package/dist/chunk-4sz6pwtn.js +0 -6
- package/dist/chunk-87qab82w.js +0 -5
- package/dist/chunk-b35e128b.js +0 -5
- package/dist/chunk-hwa5sqw5.js +0 -19
- /package/dist/{chunk-k0fvsyeh.js.map → chunk-hsfjt13m.js.map} +0 -0
- /package/dist/{chunk-yf7vz71n.js.map → chunk-hwhw98hc.js.map} +0 -0
|
@@ -6,13 +6,22 @@ export declare class LogManager {
|
|
|
6
6
|
static token: string;
|
|
7
7
|
writer: FileSink;
|
|
8
8
|
isReady: boolean;
|
|
9
|
-
private logsDirPath;
|
|
10
9
|
private flushTimeout;
|
|
11
10
|
private fileSize;
|
|
12
11
|
private writerSize;
|
|
13
12
|
private isCreatingFile;
|
|
14
13
|
private bootPromise;
|
|
15
14
|
currentLogFilePath: string;
|
|
15
|
+
/**
|
|
16
|
+
* Computed per read, not once in the constructor: `Server.start` awaits
|
|
17
|
+
* `waitForBoot()` — where `LogServiceProvider.boot()` builds this directory —
|
|
18
|
+
* and only *then* imports the http layer that sets `ROOT_DIR`. A field
|
|
19
|
+
* initializer (or any `process.env.ROOT_DIR` read here) resolves to
|
|
20
|
+
* `undefined/storage/logs` at boot, which is how every `Log.info()` ended up
|
|
21
|
+
* throwing on an undefined writer. `projectRoot()` is the same rule
|
|
22
|
+
* `httpProd` sets `ROOT_DIR` from, a moment later.
|
|
23
|
+
*/
|
|
24
|
+
private get logsDirPath();
|
|
16
25
|
constructor(config: Required<LogConfig>);
|
|
17
26
|
/**
|
|
18
27
|
* Idempotent. `LogServiceProvider.boot()` calls this so the storage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogManager.d.ts","sourceRoot":"","sources":["../../../services/logging/LogManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"LogManager.d.ts","sourceRoot":"","sources":["../../../services/logging/LogManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAapC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAY,QAAQ,EAAE,MAAM,SAAS,CAAC;AAElD,qBAAa,UAAU;IA0BF,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC;IAzB9C,MAAM,CAAC,KAAK,SAAS;IAErB,MAAM,EAAE,QAAQ,CAAC;IACjB,OAAO,EAAE,OAAO,CAAS;IAEzB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,cAAc,CAAkB;IACxC,OAAO,CAAC,WAAW,CAA8B;IAC1C,kBAAkB,EAAE,MAAM,CAAC;IAElC;;;;;;;;OAQG;IACH,OAAO,KAAK,WAAW,GAEtB;gBAEkB,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC;IAE9C;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAgBP,aAAa;IAWrB,UAAU;IAgDV,GAAG,CACP,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAqE9B,QAAQ;CAkBf"}
|
|
@@ -7,6 +7,16 @@ export declare class LogServiceProvider extends ServiceProvider {
|
|
|
7
7
|
* Resolving here is deliberate: it is the one service whose readiness is a
|
|
8
8
|
* boot-time side effect, and paying for it lazily mid-request would add file
|
|
9
9
|
* IO to whichever handler happened to log first.
|
|
10
|
+
*
|
|
11
|
+
* Only for a process that is serving, though. `runConsole` boots these same
|
|
12
|
+
* providers for every command, as does a migration or a test with a Kernel,
|
|
13
|
+
* and preparing a log file is not free: a `mkdir`, a `readdir`, and — when
|
|
14
|
+
* the newest file still has room — reading its whole text back into a fresh
|
|
15
|
+
* writer, up to `maxFileSize` (10MB by default), in whatever directory the
|
|
16
|
+
* process was started from. `ROOT_DIR` is what `Server.start` sets and
|
|
17
|
+
* nothing else does. Those contexts stay lazy rather than silent: a command
|
|
18
|
+
* that actually logs still gets its file, because `LogManager.log()` boots
|
|
19
|
+
* the manager on first use.
|
|
10
20
|
*/
|
|
11
21
|
boot(): Promise<void>;
|
|
12
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogServiceProvider.d.ts","sourceRoot":"","sources":["../../../services/logging/LogServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAKhE,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,QAAQ;IAaR
|
|
1
|
+
{"version":3,"file":"LogServiceProvider.d.ts","sourceRoot":"","sources":["../../../services/logging/LogServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAKhE,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,QAAQ;IAaR;;;;;;;;;;;;;;;;OAgBG;IACG,IAAI;CAMX"}
|
package/dist/support/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{Ub as Y}from"../chunk-ys904esh.js";import{nf as R}from"../chunk-3296fwss.js";import{vf as F,xf as q}from"../chunk-tds3xq6b.js";import"../chunk-j23cengk.js";import{Af as S,Bf as U,Cf as V,Df as W}from"../chunk-hxb1eg2z.js";import"../chunk-4dan69s4.js";class v{static token;async boot(){}static inject(){if(!this.token)throw Error(`Service [${this.name}] does not declare a \`static token\`, so the container has no key to resolve it by.`);try{return q(this)}catch(x){throw Error(`Could not inject [${this.name}]. Services are constructed when the kernel boots, so `+"inject() only works from code that runs after that \u2014 a constructor default or a method "+`body, never module top level. Check that [${this.name}] is listed in \`services\` on your Kernel.`,{cause:x})}}static with(x){let f=new this;for(let[C,g]of Object.entries(x))if(g!==void 0)f[C]=g;return f}}import{readdir as H}from"fs/promises";import{join as J,parse as z}from"path";var L=[".ts",".tsx",".js",".mjs",".jsx"];function M(x={}){let f={};for(let[C,g]of Object.entries(x))f[C]=B(g);return new F(f)}async function Q(x,f=new F){let C=[];try{C=await H(x)}catch(D){return f}let g=C.filter((D)=>{let{ext:P,name:j}=z(D);return L.includes(P)&&!j.startsWith(".")}).sort();for(let D of g){let{name:P}=z(D),j=await import(J(x,D));f.set(P,B(j))}return f}function B(x){if(x&&typeof x==="object"&&"default"in x)return x.default;return x}export{R as withDefaults,S as sourceFiles,W as projectRoot,Q as loadConfigFrom,V as discoverClasses,M as createConfigRepository,Y as ServiceProvider,v as Service,F as Repository,U as DiscoveryError};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=7CF7DE923F6BD77064756E2164756E21
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"import { readdir } from \"node:fs/promises\";\nimport { join, parse } from \"node:path\";\n\nimport { Repository } from \"./Repository\";\n\nconst CONFIG_EXTENSIONS = [\".ts\", \".tsx\", \".js\", \".mjs\", \".jsx\"];\n\n// Builds a Repository from an already-imported map of config modules. The map\n// key becomes the top-level config key, so `{ mail: mailModule }` is readable\n// as `config.get(\"mail.driver\")`. Each entry may be either the module namespace\n// (its `default` export is unwrapped) or the config object itself.\nexport function createConfigRepository(\n modules: Record<string, any> = {},\n): Repository {\n const items: Record<string, any> = {};\n\n for (const [key, mod] of Object.entries(modules)) {\n items[key] = unwrap(mod);\n }\n\n return new Repository(items);\n}\n\n// Reads every config module in an app's `app/config` directory into a\n// Repository. The file's basename is the top-level key: `app/config/mail.ts`\n// populates `mail.*`. A missing directory yields an empty Repository so apps\n// that declare no config still boot.\nexport async function loadConfigFrom(\n directory: string,\n repository = new Repository(),\n): Promise<Repository> {\n let entries: string[] = [];\n\n try {\n entries = await readdir(directory);\n } catch (err) {\n return repository;\n }\n\n const files = entries\n .filter((entry) => {\n const { ext, name } = parse(entry);\n return CONFIG_EXTENSIONS.includes(ext) && !name.startsWith(\".\");\n })\n .sort();\n\n for (const file of files) {\n const { name } = parse(file);\n const mod = await import(join(directory, file));\n repository.set(name, unwrap(mod));\n }\n\n return repository;\n}\n\nfunction unwrap(mod: any) {\n if (mod && typeof mod === \"object\" && \"default\" in mod) {\n return mod.default;\n }\n return mod;\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";2RAgCO,CAAe,JAAQ,EAOrB,OAMD,AAAI,EAAkB,QAmBrB,OAAS,EAKX,CACH,GAAI,CAAC,KAAK,MACR,MAAU,MACR,YAAY,KAAK,0FACnB,EAGF,GAAI,CACF,OAAO,EAAI,IAAuB,EAClC,MAAO,EAAO,CACd,MAAU,MACR,qBAAqB,KAAK,6DACxB,+FACA,6CAA6C,KAAK,kDAEpD,CAAE,OAAM,CACV,SAoBG,KAAuB,CAAoB,EAA0B,CAC1E,IAAM,EAAW,IAAI,KACrB,QAAY,EAAK,KAAU,OAAO,QAAQ,CAAS,EACjD,GAAI,IAAU,OAAW,EAAS,GAAO,EAE3C,OAAO,EAEX,CChHA,kBAAS,oBACT,eAAS,WAAM,aAIf,IAAM,EAAoB,CAAC,MAAO,OAAQ,MAAO,OAAQ,MAAM,EAMxD,SAAS,CAAsB,CACpC,EAA+B,CAAC,EACpB,CACZ,IAAM,EAA6B,CAAC,EAEpC,QAAY,EAAK,KAAQ,OAAO,QAAQ,CAAO,EAC7C,EAAM,GAAO,EAAO,CAAG,EAGzB,OAAO,IAAI,EAAW,CAAK,EAO7B,eAAsB,CAAc,CAClC,EACA,EAAa,IAAI,EACI,CACrB,IAAI,EAAoB,CAAC,EAEzB,GAAI,CACF,EAAU,MAAM,EAAQ,CAAS,EACjC,MAAO,EAAK,CACZ,OAAO,EAGT,IAAM,EAAQ,EACX,OAAO,CAAC,IAAU,CACjB,IAAQ,MAAK,QAAS,EAAM,CAAK,EACjC,OAAO,EAAkB,SAAS,CAAG,GAAK,CAAC,EAAK,WAAW,GAAG,EAC/D,EACA,KAAK,EAER,QAAW,KAAQ,EAAO,CACxB,IAAQ,QAAS,EAAM,CAAI,EACrB,EAAM,MAAa,SAAK,EAAW,CAAI,GAC7C,EAAW,IAAI,EAAM,EAAO,CAAG,CAAC,EAGlC,OAAO,EAGT,SAAS,CAAM,CAAC,EAAU,CACxB,GAAI,GAAO,OAAO,IAAQ,UAAY,YAAa,EACjD,OAAO,EAAI,QAEb,OAAO",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "7CF7DE923F6BD77064756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gemi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.60.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Enes Tufekci <enes@gemijs.dev>",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"dist/**/*",
|
|
18
|
-
"ide/typescript-plugin/package.json"
|
|
18
|
+
"ide/typescript-plugin/package.json",
|
|
19
|
+
"skills/**/*"
|
|
19
20
|
],
|
|
20
21
|
"module": true,
|
|
21
22
|
"exports": {
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gemi-react-best-practices
|
|
3
|
+
description: Best practices for the gemi framework (Bun + Vite + React 19 SSR full-stack TypeScript framework) — routing, controllers, the ORM, the SSR data payload, useQuery, i18n, jobs/services, and testing. Use when writing, reviewing, or refactoring anything under app/ — views, routers, controllers, models, dictionaries — or when a task mentions slow pages, extra round-trips, N+1 queries, bundle size, or re-renders.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# gemi Best Practices
|
|
7
|
+
|
|
8
|
+
Rules for building on **gemi**, the full-stack TypeScript framework this app runs on
|
|
9
|
+
(Bun + Vite, React 19 SSR). 45 rules across 11 categories, ordered by impact.
|
|
10
|
+
|
|
11
|
+
Every rule is derived from the gemi documentation and from patterns that recur across
|
|
12
|
+
gemi codebases. This skill ships with the `gemi` package, so it describes the
|
|
13
|
+
framework; where it and your app disagree, your app wins (ground rule 2).
|
|
14
|
+
|
|
15
|
+
## When to Apply
|
|
16
|
+
|
|
17
|
+
- Adding or changing a route, view, layout, controller, or middleware
|
|
18
|
+
- Writing a `useQuery` read, a mutation, or a `Query.prefetch`
|
|
19
|
+
- Writing ORM queries — especially list reads, aggregations, and transactions
|
|
20
|
+
- Adding a Job, Service, or one-off Command
|
|
21
|
+
- Writing dictionaries or tests
|
|
22
|
+
- Diagnosing extra round-trips, slow first paint, blank flashes, or bundle growth
|
|
23
|
+
|
|
24
|
+
## Ground Rules That Precede Everything Below
|
|
25
|
+
|
|
26
|
+
1. **Fetch the docs; do not guess an API.** Index (page list + one-line summaries):
|
|
27
|
+
<https://nstfkc.github.io/gemi/llms.txt> — fetch only the pages you need.
|
|
28
|
+
Everything in one file: <https://nstfkc.github.io/gemi/llms-full.txt> (~170 KB).
|
|
29
|
+
2. **`CLAUDE.md` in this app wins** where it and either the docs or this skill
|
|
30
|
+
disagree — it describes *our* app, not the framework in general.
|
|
31
|
+
3. **Mirror existing code.** Don't invent gemi patterns. When a rule here and an
|
|
32
|
+
existing pattern disagree, check git history before "fixing" it.
|
|
33
|
+
4. **Routing is class-based and data is loaded in controllers.** File location
|
|
34
|
+
registers nothing; a view's file name has no relation to its URL.
|
|
35
|
+
5. **Check whether the React Compiler is on before hand-memoizing.** It is enabled
|
|
36
|
+
per app in `gemi.config.ts` via the React plugin's `compiler` option, which the
|
|
37
|
+
gemi template turns on by default — and `GEMI_REACT_COMPILER=off` in the
|
|
38
|
+
environment disables it, so the config is not the last word. With it on, the client build is
|
|
39
|
+
auto-memoized and a hand-written `useMemo` is usually redundant; with it off,
|
|
40
|
+
memoization is manual and load-bearing. The compiler never runs on the SSR view
|
|
41
|
+
build — server rendering is a single pass — so it changes nothing about what a
|
|
42
|
+
controller does.
|
|
43
|
+
|
|
44
|
+
## Rule Categories by Priority
|
|
45
|
+
|
|
46
|
+
| Priority | Category | Impact | Prefix |
|
|
47
|
+
|----------|----------|--------|--------|
|
|
48
|
+
| 0 | Project Structure | HIGH | `structure-` |
|
|
49
|
+
| 1 | Server Payload & Waterfalls | CRITICAL | `payload-` |
|
|
50
|
+
| 2 | Client Data Fetching | CRITICAL | `query-` |
|
|
51
|
+
| 3 | Data Access (ORM) | HIGH | `orm-` |
|
|
52
|
+
| 4 | Routing & Middleware | HIGH | `routing-` |
|
|
53
|
+
| 5 | Controllers & Request Handling | HIGH | `controller-` |
|
|
54
|
+
| 6 | Services, Jobs & Commands | HIGH | `service-` |
|
|
55
|
+
| 7 | Client Components & Navigation | MEDIUM | `client-` |
|
|
56
|
+
| 8 | Bundle Size | MEDIUM | `bundle-` |
|
|
57
|
+
| 9 | Internationalization | MEDIUM | `i18n-` |
|
|
58
|
+
| 10 | Testing | MEDIUM | `testing-` |
|
|
59
|
+
|
|
60
|
+
## Project Structure
|
|
61
|
+
|
|
62
|
+
Everything the framework guarantees lives under `app/`. This is the layout a
|
|
63
|
+
scaffolded project has; the parts marked *discovered* are read by walking the
|
|
64
|
+
directory, so writing the file is the registration.
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
app/
|
|
68
|
+
server.ts server entry - boots the kernel, starts the HTTP server
|
|
69
|
+
client.tsx browser entry - hydrates the React app
|
|
70
|
+
preload.ts optional Bun preload, runs before the server starts
|
|
71
|
+
kernel/Kernel.ts declares `config`, `providers`, and `models`
|
|
72
|
+
config/ runtime config, one file per framework service
|
|
73
|
+
providers/ your own container bindings
|
|
74
|
+
http/
|
|
75
|
+
routes/ api.ts and view.ts - the root routers
|
|
76
|
+
controllers/ controller classes
|
|
77
|
+
requests/ HttpRequest subclasses used for validation
|
|
78
|
+
models/ ORM models (declared on the Kernel)
|
|
79
|
+
generated/ OUTPUT - never hand-edit
|
|
80
|
+
views/ React views, layouts, RootLayout (path is NOT the URL)
|
|
81
|
+
email/ jsx-email templates
|
|
82
|
+
i18n/ dictionaries
|
|
83
|
+
cron/ CronJob classes <- discovered at boot
|
|
84
|
+
jobs/ Job classes <- discovered at boot
|
|
85
|
+
listeners/ Listener classes <- discovered at boot
|
|
86
|
+
commands/ defineCommand chains <- discovered by `gemi run`
|
|
87
|
+
database/prisma.ts the Prisma client instance
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`app/listeners/` is absent from a fresh scaffold; that is not an error, it means
|
|
91
|
+
the app has no listeners yet.
|
|
92
|
+
|
|
93
|
+
### Where a new file goes
|
|
94
|
+
|
|
95
|
+
| Adding a… | Goes in | Reached by |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| page / layout | `app/views/` | a **router**, never its file path |
|
|
98
|
+
| URL, or middleware on one | `app/http/routes/` | mounted from `view.ts` / `api.ts` |
|
|
99
|
+
| handler logic for a route | `app/http/controllers/` | named by a router |
|
|
100
|
+
| request validation | `app/http/requests/` | named by a controller method |
|
|
101
|
+
| ORM model | `app/models/` | the Kernel's `models` |
|
|
102
|
+
| background work | `app/jobs/` | discovery |
|
|
103
|
+
| scheduled work | `app/cron/` | discovery |
|
|
104
|
+
| event handler | `app/listeners/` | discovery |
|
|
105
|
+
| one-off ops task | `app/commands/` | discovery, via `gemi run` |
|
|
106
|
+
| anything with I/O, a client, or state | `app/services/` | the container, by `static token` |
|
|
107
|
+
| container bindings | `app/providers/` | the Kernel's `providers` |
|
|
108
|
+
| settings for a framework service | `app/config/` | the Kernel's `config` |
|
|
109
|
+
| translations | `app/i18n/` | `defineDictionary` |
|
|
110
|
+
| build config (Vite/Bun plugins) | `gemi.config.ts` **at the root** | the CLI — *not* `app/config/` |
|
|
111
|
+
|
|
112
|
+
Two mistakes this table exists to prevent, both of which typecheck and then do
|
|
113
|
+
nothing: putting a view at a path that looks like its URL and expecting it to
|
|
114
|
+
route, and writing a model without declaring it on the Kernel. See
|
|
115
|
+
`structure-discovered-vs-registered` and `structure-do-not-reinvent-the-framework`.
|
|
116
|
+
|
|
117
|
+
## Quick Reference
|
|
118
|
+
|
|
119
|
+
### 0. Project Structure (HIGH)
|
|
120
|
+
|
|
121
|
+
- `structure-discovered-vs-registered` - Four directories register by being walked; models, routers, config and providers are declared
|
|
122
|
+
- `structure-do-not-reinvent-the-framework` - `lib/`, a singleton, a hand-rolled registry: gemi already has each of these with a name
|
|
123
|
+
|
|
124
|
+
### 1. Server Payload & Waterfalls (CRITICAL)
|
|
125
|
+
|
|
126
|
+
The biggest lever in the app. gemi ships a data payload with the SSR HTML; every read
|
|
127
|
+
the client discovers only after hydration costs a round-trip the payload could have
|
|
128
|
+
carried for free.
|
|
129
|
+
|
|
130
|
+
- `payload-prefetch-mirrors-usequery` - A prefetch lands only if path + params + search match the cache key exactly
|
|
131
|
+
- `payload-prefetch-late-queries` - Prefetch reads render discovers late (nested under suspense, conditionally rendered)
|
|
132
|
+
- `payload-instant-vs-prefetch` - `Query.instant` blocks the response; `Query.prefetch` runs in parallel
|
|
133
|
+
- `payload-parallel-controller-work` - `Promise.all` independent work in a controller method
|
|
134
|
+
- `payload-dont-overprefetch` - Popover and heavy-collection reads belong behind a mount gate
|
|
135
|
+
- `payload-minimal-view-props` - Ship the shape the view renders, not the row you loaded
|
|
136
|
+
|
|
137
|
+
### 2. Client Data Fetching (CRITICAL)
|
|
138
|
+
|
|
139
|
+
- `query-no-hand-rolled-fetch` - `useQuery` / mutation hooks, never a raw `fetch`
|
|
140
|
+
- `query-suspense-default` - `suspense: true` is the DEFAULT and throws to the nearest boundary
|
|
141
|
+
- `query-lazy-vs-mount-gate` - A lazy query does not refetch when its variant changes
|
|
142
|
+
- `query-share-cache-key` - Identical path + params + search dedupes across components for free
|
|
143
|
+
- `query-keep-previous-data` - Keep the previous page rendered while the next variant loads
|
|
144
|
+
- `query-mutate-over-refetch` - Write the cache with `mutate` / `useMutate` instead of refetching
|
|
145
|
+
- `query-debounce-search-variant` - Debounce a value before it becomes a query variant
|
|
146
|
+
- `query-revalidate-on-focus` - Opt in only for cross-tab-mutable data; let `staleTime` gate it
|
|
147
|
+
|
|
148
|
+
### 3. Data Access — ORM (HIGH)
|
|
149
|
+
|
|
150
|
+
- `orm-include-not-n-plus-one` - One `include` tree beats a loop of queries (lateral strategy = one round trip)
|
|
151
|
+
- `orm-transaction-sequential` - `Promise.all` inside `Model.transaction` is unsafe — one reserved connection
|
|
152
|
+
- `orm-transaction-no-io` - Keep network calls, uploads and queue pushes out of a transaction callback
|
|
153
|
+
- `orm-analytics-connection` - Heavy admin/cron aggregations run on the analytics pool
|
|
154
|
+
- `orm-paginate-helper` - Use `paginate()` from `gemi/orm`; know its 100-row ceiling
|
|
155
|
+
- `orm-select-narrow` - `select` the columns the response actually serializes
|
|
156
|
+
- `orm-plain-rows-by-default` - Plain rows are free; `track` costs ~100% on a large read
|
|
157
|
+
|
|
158
|
+
### 4. Routing & Middleware (HIGH)
|
|
159
|
+
|
|
160
|
+
- `routing-routers-are-classes` - Routes are declared on router classes, not by file location
|
|
161
|
+
- `routing-middleware-dsl` - Middleware is a string DSL at router or route level; `-name` cancels
|
|
162
|
+
- `routing-cache-policy-constants` - Name cache policies once and reuse the constant
|
|
163
|
+
- `routing-resource-routes` - `resource()` for standard REST, with per-method middleware
|
|
164
|
+
|
|
165
|
+
### 5. Controllers & Request Handling (HIGH)
|
|
166
|
+
|
|
167
|
+
- `controller-request-schema` - Validate with a request schema, not inline checks
|
|
168
|
+
- `controller-throw-framework-errors` - Throw `ValidationError` / auth errors; never invent a response shape
|
|
169
|
+
- `controller-redirect-facade-throws` - Never wrap the `Redirect` facade in try/catch — it works by throwing
|
|
170
|
+
- `controller-authorize-every-tenant-read` - Scope every tenant read, in middleware or an ORM policy
|
|
171
|
+
- `controller-parse-request-at-the-boundary` - Parse the request in the controller; keep utils framework-free
|
|
172
|
+
|
|
173
|
+
### 6. Services, Jobs & Commands (HIGH)
|
|
174
|
+
|
|
175
|
+
- `service-static-token-and-name` - `static token` / `static name` survive minification; class names do not
|
|
176
|
+
- `service-queue-is-in-memory` - The queue is in-process; enqueued work is lost on restart
|
|
177
|
+
- `service-lazy-not-module-scope` - Construct clients lazily — discovery imports every module
|
|
178
|
+
|
|
179
|
+
### 7. Client Components & Navigation (MEDIUM)
|
|
180
|
+
|
|
181
|
+
- `client-typed-links` - Navigate with a typed `Link` / `useNavigate`, not an interpolated path
|
|
182
|
+
- `client-form-vs-mutation-hooks` - `<Form>` first; mutation hooks when you need control
|
|
183
|
+
- `client-loading-error-exports` - A route module's `Loading` / `Error` exports ARE its suspense boundary
|
|
184
|
+
- `client-no-effect-data-flow` - Derive in `useMemo`, reset in the handler, debounce before use
|
|
185
|
+
|
|
186
|
+
### 8. Bundle Size (MEDIUM)
|
|
187
|
+
|
|
188
|
+
- `bundle-deep-imports` - Import UI primitives by deep path; a barrel drags the whole library in
|
|
189
|
+
- `bundle-mount-gate-heavy-panels` - Put heavy subtrees inside the thing that unmounts them
|
|
190
|
+
|
|
191
|
+
### 9. Internationalization (MEDIUM)
|
|
192
|
+
|
|
193
|
+
- `i18n-define-dictionary-inline` - The `defineDictionary` literal must be inline — a helper fails the BUILD
|
|
194
|
+
|
|
195
|
+
### 10. Testing (MEDIUM)
|
|
196
|
+
|
|
197
|
+
- `testing-page-seeds-real-inputs` - Mount with `<Page>` from `gemi/testing`; never mock `gemi/client`
|
|
198
|
+
- `testing-assert-behaviour-over-markup` - Query the DOM; don't scrape `renderToStaticMarkup` output
|
|
199
|
+
- `testing-match-the-suite` - Copy the runner and naming already in the directory; component tests need a DOM
|
|
200
|
+
|
|
201
|
+
## The Gotchas Most Likely to Bite
|
|
202
|
+
|
|
203
|
+
Counter-intuitive behaviours that produce silent failures rather than errors:
|
|
204
|
+
|
|
205
|
+
| Gotcha | Rule |
|
|
206
|
+
|---|---|
|
|
207
|
+
| `Redirect` works by **throwing** — a `try/catch` swallows it | `controller-redirect-facade-throws` |
|
|
208
|
+
| A `defineDictionary` behind a helper passes tests and fails the **build** | `i18n-define-dictionary-inline` |
|
|
209
|
+
| `Promise.all` inside a transaction shares one reserved connection | `orm-transaction-sequential` |
|
|
210
|
+
| A lazy query never refetches when its variant changes | `query-lazy-vs-mount-gate` |
|
|
211
|
+
| A prefetch whose `search` differs primes a slot nothing reads | `payload-prefetch-mirrors-usequery` |
|
|
212
|
+
| A class name is minified in prod — jobs and services need a static string | `service-static-token-and-name` |
|
|
213
|
+
| `paginate()` silently caps `perPage` at 100 | `orm-paginate-helper` |
|
|
214
|
+
| Command discovery **imports** every file under `app/commands` | `service-lazy-not-module-scope` |
|
|
215
|
+
| A suspending query blanks everything up to the nearest boundary | `query-suspense-default` |
|
|
216
|
+
| Returning `{ error }` from a controller is a **200** the client reads as success | `controller-throw-framework-errors` |
|
|
217
|
+
|
|
218
|
+
## How to Use
|
|
219
|
+
|
|
220
|
+
Read a rule file for the full explanation and examples:
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
rules/payload-prefetch-mirrors-usequery.md
|
|
224
|
+
rules/orm-transaction-sequential.md
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Each contains a short why, an incorrect example, a correct example, and — where one
|
|
228
|
+
exists — a link to the gemi documentation page that covers it.
|
|
229
|
+
|
|
230
|
+
`rules/_sections.md` holds the category metadata; `rules/_template.md` is the shape a
|
|
231
|
+
new rule follows.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Sections
|
|
2
|
+
|
|
3
|
+
The section ID (in parentheses) is the filename prefix used to group rules.
|
|
4
|
+
Rules are sorted by title within a section. Files starting with `_` are not rules.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Server Payload & Waterfalls (payload)
|
|
9
|
+
|
|
10
|
+
**Impact:** CRITICAL
|
|
11
|
+
**Description:** gemi renders on the server and ships a data payload with the HTML. Every read the client discovers only after hydration costs a full round-trip the payload could have carried. This is the largest lever in the app.
|
|
12
|
+
|
|
13
|
+
## 2. Client Data Fetching (query)
|
|
14
|
+
|
|
15
|
+
**Impact:** CRITICAL
|
|
16
|
+
**Description:** `useQuery` defaults (suspense on, keepPreviousData on, 5s staleTime, focus revalidation off) are opinionated. Fighting them — or not knowing them — produces blank flashes, dead pagination, and duplicate requests.
|
|
17
|
+
|
|
18
|
+
## 3. Data Access — ORM (orm)
|
|
19
|
+
|
|
20
|
+
**Impact:** HIGH
|
|
21
|
+
**Description:** The ORM is Prisma-typed but gemi-executed, with its own relation-loading strategies, transaction semantics, connection selection, and row-provenance model. Its constraints are not Prisma's.
|
|
22
|
+
|
|
23
|
+
## 4. Routing & Middleware (routing)
|
|
24
|
+
|
|
25
|
+
**Impact:** HIGH
|
|
26
|
+
**Description:** Routing is class-based: routers declare a routes object, and middleware attaches as a string DSL. This is where a URL, its cache policy, and its auth boundary are all defined.
|
|
27
|
+
|
|
28
|
+
## 5. Controllers & Request Handling (controller)
|
|
29
|
+
|
|
30
|
+
**Impact:** HIGH
|
|
31
|
+
**Description:** Controllers hold server logic and own the request boundary — validation, authorization, error shape. The client's error handling is a contract with what a controller throws.
|
|
32
|
+
|
|
33
|
+
## 6. Services, Jobs & Commands (service)
|
|
34
|
+
|
|
35
|
+
**Impact:** HIGH
|
|
36
|
+
**Description:** Long-lived singletons, background work, and one-off ops. Most failures here are invisible in development and appear only in the production build or on a restart.
|
|
37
|
+
|
|
38
|
+
## 7. Client Components & Navigation (client)
|
|
39
|
+
|
|
40
|
+
**Impact:** MEDIUM
|
|
41
|
+
**Description:** React 19 SSR with hydration. Typed navigation, forms, suspense boundaries declared by route module exports, and data flow that does not go through effects.
|
|
42
|
+
|
|
43
|
+
## 8. Bundle Size (bundle)
|
|
44
|
+
|
|
45
|
+
**Impact:** MEDIUM
|
|
46
|
+
**Description:** Vite code-splits per route chunk. Client cost is determined by which module graph a route pulls in and where a heavy subtree is mounted.
|
|
47
|
+
|
|
48
|
+
## 9. Internationalization (i18n)
|
|
49
|
+
|
|
50
|
+
**Impact:** MEDIUM
|
|
51
|
+
**Description:** Two dictionary systems coexist. The newer one is rewritten at build time by a Vite plugin, which constrains how it may be written.
|
|
52
|
+
|
|
53
|
+
## 10. Testing (testing)
|
|
54
|
+
|
|
55
|
+
**Impact:** MEDIUM
|
|
56
|
+
**Description:** Views mount for real with seeded framework inputs, through `<Page>` from `gemi/testing`. Match whichever runner and naming convention the directory already uses — a test the runner never selects is a test that does not exist.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Rule Title Here
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: Optional description of impact (e.g., "20-50% improvement")
|
|
5
|
+
tags: tag1, tag2
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Rule Title Here
|
|
9
|
+
|
|
10
|
+
**Impact: MEDIUM (optional impact description)**
|
|
11
|
+
|
|
12
|
+
Brief explanation of the rule and why it matters. This should be clear and concise, explaining the performance implications.
|
|
13
|
+
|
|
14
|
+
**Incorrect (description of what's wrong):**
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// Bad code example here
|
|
18
|
+
const bad = example()
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Correct (description of what's right):**
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// Good code example here
|
|
25
|
+
const good = example()
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Reference: [Link to documentation or resource](https://example.com)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Import UI Primitives By Deep Path
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: keeps a component library's dependencies out of routes that do not use it
|
|
5
|
+
tags: bundle, imports, barrel, ui
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Import UI Primitives By Deep Path
|
|
9
|
+
|
|
10
|
+
A component library where every primitive is its own module — the shadcn/ui shape,
|
|
11
|
+
and the shape most in-repo `packages/ui` workspaces take — should be imported by deep
|
|
12
|
+
path. A route then pulls in exactly the primitives it uses.
|
|
13
|
+
|
|
14
|
+
A barrel import, or adding a barrel that re-exports everything, pulls the whole
|
|
15
|
+
library and its transitive dependencies (for a Radix-based kit, ~25 packages) into
|
|
16
|
+
every route that touches one button. Tree-shaking does not reliably save you here:
|
|
17
|
+
the library is often source-only with no build step, and a single side-effecting
|
|
18
|
+
module in the barrel's graph defeats it.
|
|
19
|
+
|
|
20
|
+
**Incorrect (drags the library in):**
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { Button, Input, Badge } from "@acme/ui";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Correct (one module each):**
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { Button } from "@acme/ui/components/ui/button";
|
|
30
|
+
import { Input } from "@acme/ui/components/ui/input";
|
|
31
|
+
import { Badge } from "@acme/ui/components/ui/badge";
|
|
32
|
+
import { cn } from "@acme/ui/lib/utils";
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Do not add a barrel** to make the imports shorter. The deep paths are the
|
|
36
|
+
mechanism, not a style preference.
|
|
37
|
+
|
|
38
|
+
Two related notes:
|
|
39
|
+
|
|
40
|
+
- **Check whether your repo has a legacy copy.** A local `app/views/components/ui`
|
|
41
|
+
alongside a shared `packages/ui` means two divergent sets of the same primitives;
|
|
42
|
+
pick the shared one and say so in `CLAUDE.md`.
|
|
43
|
+
- **Keep import paths statically analyzable.** A computed specifier defeats
|
|
44
|
+
tree-shaking and widens what the build has to trace.
|
|
45
|
+
|
|
46
|
+
This matters more under gemi than under a bundler that ships one chunk: each view is
|
|
47
|
+
its own build entry (`preserveEntrySignatures: "strict"`), so a barrel import in one
|
|
48
|
+
view inflates that view's chunk and every chunk that shares its graph.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Put Heavy Subtrees Inside the Thing That Unmounts Them
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: ~47 kB and two queries off the initial load, measured
|
|
5
|
+
tags: bundle, mounting, radix, queries
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Put Heavy Subtrees Inside the Thing That Unmounts Them
|
|
9
|
+
|
|
10
|
+
The cheapest work is work that never mounts. **Let an unmounted subtree be the
|
|
11
|
+
gate**: Radix `PopoverContent`, `DialogContent`,
|
|
12
|
+
`DropdownMenuContent` and the tab primitives do not render their children while
|
|
13
|
+
closed. A component placed inside them costs nothing until the user opens the thing.
|
|
14
|
+
|
|
15
|
+
Hoisting a query or a heavy component *above* that boundary "to keep the parent
|
|
16
|
+
tidy" is how it starts running on every page load for a panel nobody opened. In this
|
|
17
|
+
app that cost ~47 kB resolved across two reads, on every load of the customer app.
|
|
18
|
+
|
|
19
|
+
**Incorrect (reads run on every page load to fill a closed popover):**
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
function ProductPicker() {
|
|
23
|
+
const { data: products } = useQuery("/app/:orgId/products/search", { params });
|
|
24
|
+
const { data: lists } = useQuery("/app/:orgId/lists", { params });
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Popover>
|
|
28
|
+
<PopoverTrigger>Add product</PopoverTrigger>
|
|
29
|
+
<PopoverContent>
|
|
30
|
+
<CatalogSearchPanel products={products} lists={lists} />
|
|
31
|
+
</PopoverContent>
|
|
32
|
+
</Popover>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Correct (the reads move down, inside the content Radix unmounts):**
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
function ProductPicker() {
|
|
41
|
+
return (
|
|
42
|
+
<Popover>
|
|
43
|
+
<PopoverTrigger>Add product</PopoverTrigger>
|
|
44
|
+
<PopoverContent>
|
|
45
|
+
<CatalogSearchPanel orgId={orgId} />
|
|
46
|
+
</PopoverContent>
|
|
47
|
+
</Popover>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function CatalogSearchPanel({ orgId }: { orgId: string }) {
|
|
52
|
+
const { data: products = [] } = useQuery(/* … */, { suspense: false });
|
|
53
|
+
const { data: lists = [] } = useQuery(/* … */, { suspense: false });
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Why mounting rather than `{ lazy: true }`:** a lazy query does not refetch when
|
|
58
|
+
its variant changes, so a searchable or paginated read breaks under it — see
|
|
59
|
+
`query-lazy-vs-mount-gate`.
|
|
60
|
+
|
|
61
|
+
**For a genuinely heavy module** (a chart library, an editor, a PDF renderer) plain
|
|
62
|
+
`React.lazy` + `Suspense` is the right tool; gemi ships no wrapper of its own for
|
|
63
|
+
it, and none is needed.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Reach for Form First, Mutation Hooks When You Need Control
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: CSRF, FormData and field errors for free
|
|
5
|
+
tags: client, forms, mutations, validation
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Reach for Form First, Mutation Hooks When You Need Control
|
|
9
|
+
|
|
10
|
+
`<Form>` wraps a native form and handles what is otherwise hand-written every time:
|
|
11
|
+
collecting fields into `FormData`, attaching the CSRF token, tracking pending state,
|
|
12
|
+
and exposing the server's per-field `validation_error` messages through context.
|
|
13
|
+
|
|
14
|
+
**Incorrect (re-implementing all of it, and losing field errors):**
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
const { trigger, loading } = usePost("/admin/user");
|
|
18
|
+
const [name, setName] = useState("");
|
|
19
|
+
const [errors, setErrors] = useState({});
|
|
20
|
+
|
|
21
|
+
async function onSubmit(e) {
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
const res = await trigger({ name });
|
|
24
|
+
if (res?.error?.kind === "validation_error") setErrors(res.error.messages);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Correct:**
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { Form, ValidationErrors } from "gemi/client";
|
|
32
|
+
|
|
33
|
+
<Form action="/admin/user" method="POST"
|
|
34
|
+
onSuccess={(_data, form) => { form.reset(); push("/admin/users"); }}>
|
|
35
|
+
<input name="name" />
|
|
36
|
+
<ValidationErrors name="name" />
|
|
37
|
+
<FormError />
|
|
38
|
+
<button type="submit">Create</button>
|
|
39
|
+
</Form>;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Inside a `Form`, three hooks read its context: `useFormStatus()`
|
|
43
|
+
(`{ isPending, validationErrors, formError }`), `useMutationStatus()`
|
|
44
|
+
(`{ isPending }`), and `useFormData()` for live `FormData` as the user types. The
|
|
45
|
+
form also carries a `data-loading` attribute for styling.
|
|
46
|
+
|
|
47
|
+
**Use the mutation hooks (`usePost` / `usePut` / `usePatch` / `useDelete`) when the
|
|
48
|
+
write is not a form submission** — a button that toggles a flag, an action in a menu,
|
|
49
|
+
an optimistic list operation. Pair them with `useMutate` to update the reading
|
|
50
|
+
query's cache rather than refetching.
|
|
51
|
+
|
|
52
|
+
**File posts that need to be unit-testable use `usePost` with `FormData`.**
|
|
53
|
+
`useUpload` is XHR-based, which is what gives it progress events and also what makes
|
|
54
|
+
it uninterceptable by MSW under happy-dom — reach for it only when you need the
|
|
55
|
+
progress bar.
|
|
56
|
+
|
|
57
|
+
Reference: <https://nstfkc.github.io/gemi/forms.md>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: A Route Module's Loading and Error Exports Are Its Suspense Boundary
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: correct fallback placement, no full-page blanking
|
|
5
|
+
tags: render, suspense, ssr, boundaries
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## A Route Module's Loading and Error Exports Are Its Suspense Boundary
|
|
9
|
+
|
|
10
|
+
A view module declares its own suspense boundary by exporting `Loading` and
|
|
11
|
+
`Error` **alongside** its default export — there is no separate file convention for
|
|
12
|
+
either. Since
|
|
13
|
+
`useQuery` suspends by default (`query-suspense-default`), a route with no `Loading`
|
|
14
|
+
export falls back to whatever boundary happens to be above it — often a bare
|
|
15
|
+
`<Suspense fallback={null}>`, which blanks the surface.
|
|
16
|
+
|
|
17
|
+
**Incorrect (no boundary of its own; suspending blanks whatever is above):**
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
export default function Todos() {
|
|
21
|
+
const { data } = useQuery("/todos");
|
|
22
|
+
return <ul>{data.map((t) => <li key={t.id}>{t.title}</li>)}</ul>;
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Correct:**
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
export default function Todos() {
|
|
30
|
+
const { data } = useQuery("/todos");
|
|
31
|
+
return <ul>{data.map((t) => <li key={t.id}>{t.title}</li>)}</ul>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function Loading() {
|
|
35
|
+
return <TodosSkeleton />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function Error({ error, resetErrorBoundary }) {
|
|
39
|
+
return <button onClick={() => resetErrorBoundary()}>Retry</button>;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Place the boundary where the blank is acceptable.** A route-level `Loading` is
|
|
44
|
+
right for the route's primary read. For a secondary widget, do not add a boundary —
|
|
45
|
+
give that query `{ suspense: false }` and render its loading state in place, so the
|
|
46
|
+
rest of the page keeps its content.
|
|
47
|
+
|
|
48
|
+
**Do not hand-roll a navigation spinner.** gemi already commits navigations in a
|
|
49
|
+
transition, keeping the previous page visible until the new page's queries resolve,
|
|
50
|
+
and the production shell preloads the chunks in the current route's component chain.
|
|
51
|
+
`Link` sets `data-pending` during navigation if you want to style the transition —
|
|
52
|
+
reach for that before adding state.
|
|
53
|
+
|
|
54
|
+
Reference: <https://nstfkc.github.io/gemi/data-fetching.md>
|