gemi 0.205.3 → 0.206.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/{chunk-k21eg3pn.js → chunk-j9ga7b74.js} +1 -1
- package/dist/{chunk-rbndzqg7.js → chunk-jr5t2hrk.js} +1 -1
- package/dist/{chunk-zwznp46g.js → chunk-qjk68wda.js} +2 -2
- package/dist/{chunk-zwznp46g.js.map → chunk-qjk68wda.js.map} +3 -3
- package/dist/{chunk-bdrce9s8.js → chunk-s4tq4y69.js} +1 -1
- package/dist/{chunk-bz84hrc3.js → chunk-xmpamj50.js} +2 -2
- package/dist/{chunk-bz84hrc3.js.map → chunk-xmpamj50.js.map} +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +527 -148
- package/dist/client/index.js.map +1 -1
- package/dist/client/queryEffects.d.ts +106 -0
- package/dist/client/queryEffects.d.ts.map +1 -0
- package/dist/client/useMultipleQuery.d.ts +83 -0
- package/dist/client/useMultipleQuery.d.ts.map +1 -0
- package/dist/client/useQuery.d.ts +11 -0
- package/dist/client/useQuery.d.ts.map +1 -1
- package/dist/facades/index.js +1 -1
- package/dist/http/index.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/kernel/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/services/change-feed/DatabaseChangeFeedDriver.d.ts +3 -3
- package/dist/services/change-feed/DatabaseChangeFeedDriver.d.ts.map +1 -1
- package/dist/services/index.js +1 -1
- package/package.json +1 -1
- package/skills/gemi-react-best-practices/SKILL.md +3 -1
- package/skills/gemi-react-best-practices/rules/query-multiple-query-per-component.md +68 -0
- /package/dist/{chunk-k21eg3pn.js.map → chunk-j9ga7b74.js.map} +0 -0
- /package/dist/{chunk-rbndzqg7.js.map → chunk-jr5t2hrk.js.map} +0 -0
- /package/dist/{chunk-bdrce9s8.js.map → chunk-s4tq4y69.js.map} +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { QueryResource } from "./QueryResource";
|
|
2
|
+
import { type RetryDelayOption, type RetryOption } from "./retryPolicy";
|
|
3
|
+
/**
|
|
4
|
+
* The per-query work `useQuery` and `useMultipleQuery` share, as plain
|
|
5
|
+
* functions: `useQuery` runs each one from its own effect for its one query,
|
|
6
|
+
* `useMultipleQuery` runs it once per key from a single effect. Keeping the
|
|
7
|
+
* bodies here is what stops the two hooks from drifting apart.
|
|
8
|
+
*/
|
|
9
|
+
/** The config keys these helpers read. */
|
|
10
|
+
export interface QueryEffectConfig {
|
|
11
|
+
retry?: RetryOption;
|
|
12
|
+
retryDelay?: RetryDelayOption;
|
|
13
|
+
retryIntervalOnError?: number;
|
|
14
|
+
staleTime?: number;
|
|
15
|
+
focusThrottleInterval?: number;
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
}
|
|
18
|
+
type Snapshot = ReturnType<QueryResource["peek"]>;
|
|
19
|
+
/**
|
|
20
|
+
* Where a query reads from: the resolved path (route params from the URL,
|
|
21
|
+
* overridden by `options.params`) and the variant key of its `search`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveQueryTarget(url: string, options: {
|
|
24
|
+
params?: Record<string, any>;
|
|
25
|
+
search?: Record<string, any> | null;
|
|
26
|
+
}, routeParams: Record<string, any>): {
|
|
27
|
+
params: Record<string, any>;
|
|
28
|
+
search: Record<string, any>;
|
|
29
|
+
path: string;
|
|
30
|
+
variantKey: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Per-call config over the provider's `queryConfig`. Only *defined* per-call
|
|
34
|
+
* keys participate: a key explicitly set to `undefined` (`{ suspense: cond ?
|
|
35
|
+
* true : undefined }`, forwarding an optional prop) falls through to the
|
|
36
|
+
* provider default instead of clobbering it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function mergeDefinedConfig<C extends object>(base: C, ...overrides: Array<Partial<C> | null | undefined>): C;
|
|
39
|
+
/**
|
|
40
|
+
* A failed `suspense: false` query: schedule the background retry its retry
|
|
41
|
+
* policy allows. The resource owns the timer, one per variant however many
|
|
42
|
+
* readers render it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function retryFailedQuery(resource: QueryResource, variantKey: string, snapshot: Snapshot, cfg: QueryEffectConfig): void;
|
|
45
|
+
/**
|
|
46
|
+
* Coming back online retries a query that failed in a way another attempt
|
|
47
|
+
* might fix, as long as its retry policy would retry that error at all.
|
|
48
|
+
* Silent, and it starts a fresh run of failures. Returns the cleanup.
|
|
49
|
+
*/
|
|
50
|
+
export declare function retryWhenOnline(resource: QueryResource, variantKey: string, getConfig: () => QueryEffectConfig): () => void;
|
|
51
|
+
/** `refetchUntil`'s poll for one query. */
|
|
52
|
+
export interface PollState {
|
|
53
|
+
timer: ReturnType<typeof setTimeout> | null;
|
|
54
|
+
/** The delay `refetchUntil` returned last, handed back as `duration`. */
|
|
55
|
+
duration: number;
|
|
56
|
+
snapshot: unknown;
|
|
57
|
+
resource: unknown;
|
|
58
|
+
variantKey: string | null;
|
|
59
|
+
/** The poll's own refetch is on the wire. */
|
|
60
|
+
awaiting: boolean;
|
|
61
|
+
}
|
|
62
|
+
export declare function createPollState(): PollState;
|
|
63
|
+
/**
|
|
64
|
+
* One step of the `refetchUntil` poll, run after every commit so the
|
|
65
|
+
* predicate always sees the current render's closure. New data (or another
|
|
66
|
+
* resource/variant) clears the pending timer and asks the predicate again; on
|
|
67
|
+
* a plain re-render a pending timer is kept, so frequent renders never push
|
|
68
|
+
* the next refetch back. `paused` (a live channel is open) stops it.
|
|
69
|
+
*/
|
|
70
|
+
export declare function stepPoll(poll: PollState, resource: QueryResource, variantKey: string, snapshot: Snapshot, refetchUntil: ((data: any, duration: number) => number) | undefined, paused: boolean): void;
|
|
71
|
+
/** Unmount: drop the pending poll. */
|
|
72
|
+
export declare function stopPoll(poll: PollState): void;
|
|
73
|
+
/** The `refreshInterval` / HMR `http-reload` reload of one query. */
|
|
74
|
+
export declare function reloadQuery(resource: QueryResource, variantKey: string, cfg: QueryEffectConfig): void;
|
|
75
|
+
/** Subscribe to Vite's `http-reload` event. Returns the cleanup. */
|
|
76
|
+
export declare function onHttpReload(handler: () => void): () => void;
|
|
77
|
+
/** The focus-revalidation guards of one query; they outlive effect re-runs. */
|
|
78
|
+
export interface FocusState {
|
|
79
|
+
/** Only reads that put data on screen enroll a query (not a hover prefetch). */
|
|
80
|
+
eligible: boolean;
|
|
81
|
+
/** The window really lost focus, or the tab was hidden, since the last one. */
|
|
82
|
+
wasAway: boolean;
|
|
83
|
+
/** When the last focus revalidation went out. */
|
|
84
|
+
last: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Revalidate when the tab comes back to the foreground, gated by `staleTime`
|
|
88
|
+
* and always silent. Three guards decide whether a return is owed a request:
|
|
89
|
+
* eligibility, the away latch (`focus` also fires for a dismissed `alert`),
|
|
90
|
+
* and the throttle (an embedded iframe blurs and focuses the window on every
|
|
91
|
+
* click). Both `focus` and `visibilitychange` are listened for because
|
|
92
|
+
* neither covers the other. Returns the cleanup.
|
|
93
|
+
*/
|
|
94
|
+
export declare function revalidateOnFocus(resource: QueryResource, variantKey: string, focus: FocusState, getConfig: () => QueryEffectConfig): () => void;
|
|
95
|
+
/**
|
|
96
|
+
* `mutate(value | updater)` for one query; a bare `mutate()` refetches.
|
|
97
|
+
* Returns whether it went to the wire for a refetch (the caller marks the
|
|
98
|
+
* query as fetched).
|
|
99
|
+
*/
|
|
100
|
+
export declare function mutateQuery(resource: QueryResource, variantKey: string, fn: unknown): "refetch" | "update";
|
|
101
|
+
/**
|
|
102
|
+
* The dev warning for a suspense query a server render had no data for.
|
|
103
|
+
*/
|
|
104
|
+
export declare function warnUnprefetched(url: string, variantKey: string, hook?: string): void;
|
|
105
|
+
export {};
|
|
106
|
+
//# sourceMappingURL=queryEffects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryEffects.d.ts","sourceRoot":"","sources":["../../client/queryEffects.ts"],"names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,UAAU,EACjB,SAAS,EAAE,MAAM,iBAAiB,GACjC,MAAM,IAAI,CAiCZ;AAiBD;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,aAAa,EACvB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,OAAO,GACV,SAAS,GAAG,QAAQ,CAmDtB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,IAAI,SAAa,QAalB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { NestedPrettify } from "../utils/type";
|
|
2
|
+
import { type Config, type Data, type GemiQueryDefaults, type GetRPC, type Options } from "./useQuery";
|
|
3
|
+
/**
|
|
4
|
+
* A key's options: `useQuery`'s config minus `lazy` (a query that waits for a
|
|
5
|
+
* `trigger` does not load with the others; give it its own `useQuery`).
|
|
6
|
+
*/
|
|
7
|
+
export type MultipleQueryConfig<T> = Omit<Config<T>, "lazy">;
|
|
8
|
+
/** One key of `useMultipleQuery`: `[path, options?, config?]`, like `useQuery`'s arguments. */
|
|
9
|
+
export type MultipleQueryEntry<P extends keyof GetRPC = keyof GetRPC> = readonly [path: P] | readonly [path: P, options: Options<P> | undefined] | readonly [
|
|
10
|
+
path: P,
|
|
11
|
+
options: Options<P> | undefined,
|
|
12
|
+
config: MultipleQueryConfig<Data<P>>
|
|
13
|
+
];
|
|
14
|
+
type EntryPath<E> = E extends readonly [infer P extends keyof GetRPC, ...any[]] ? P : never;
|
|
15
|
+
type EntryConfig<E> = E extends readonly [any, any, infer C] ? C : {};
|
|
16
|
+
/** `true`/`false` when the config pins `suspense`, `undefined` when it leaves it open. */
|
|
17
|
+
type SuspenseOf<C> = C extends {
|
|
18
|
+
suspense: infer S;
|
|
19
|
+
} ? [S] extends [undefined] ? undefined : [S] extends [true] ? true : false : undefined;
|
|
20
|
+
type DefaultSuspense = GemiQueryDefaults extends {
|
|
21
|
+
suspense: false;
|
|
22
|
+
} ? false : true;
|
|
23
|
+
type Suspends<C, G> = SuspenseOf<C> extends boolean ? SuspenseOf<C> : SuspenseOf<G> extends boolean ? SuspenseOf<G> : DefaultSuspense;
|
|
24
|
+
type EntryData<E, G> = Suspends<EntryConfig<E>, G> extends true ? NestedPrettify<Data<EntryPath<E>>> : NestedPrettify<Data<EntryPath<E>>> | undefined;
|
|
25
|
+
type Mutate<D> = {
|
|
26
|
+
(value?: D): void;
|
|
27
|
+
(updater?: (data: D) => D): void;
|
|
28
|
+
};
|
|
29
|
+
export interface MultipleQueryReturn<Q, G> {
|
|
30
|
+
/** Each key's data, typed from its route. */
|
|
31
|
+
data: {
|
|
32
|
+
[K in keyof Q]: EntryData<Q[K], G>;
|
|
33
|
+
};
|
|
34
|
+
/** True while at least one key is loading. */
|
|
35
|
+
loading: boolean;
|
|
36
|
+
/** Each key's error, `null` when it has none. */
|
|
37
|
+
error: {
|
|
38
|
+
[K in keyof Q]: Record<string, unknown> | null;
|
|
39
|
+
};
|
|
40
|
+
/** Each key's `mutate`, as `useQuery` returns it. */
|
|
41
|
+
mutate: {
|
|
42
|
+
[K in keyof Q]: Mutate<NestedPrettify<Data<EntryPath<Q[K]>>>>;
|
|
43
|
+
};
|
|
44
|
+
/** Each key's `refetch`. */
|
|
45
|
+
refetch: {
|
|
46
|
+
[K in keyof Q]: () => void;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Several queries in one hook, with one render cycle for all of them.
|
|
51
|
+
*
|
|
52
|
+
* ```tsx
|
|
53
|
+
* const { data, loading, error } = useMultipleQuery({
|
|
54
|
+
* products: ["/products"],
|
|
55
|
+
* category: ["/categories/:categoryId", { params: { categoryId } }],
|
|
56
|
+
* });
|
|
57
|
+
* data.products; // typed from GET /products
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* Each key is `[path, options?, config?]`, the arguments `useQuery` takes,
|
|
61
|
+
* and reads the same cache: a key and a `useQuery` of the same path and
|
|
62
|
+
* search share one request and one cached value.
|
|
63
|
+
*
|
|
64
|
+
* - Under suspense (the default) every key's request goes out in the same
|
|
65
|
+
* render and the component suspends once, until all of them answered.
|
|
66
|
+
* n `useQuery` calls suspend one after the other instead: a request
|
|
67
|
+
* waterfall and about two renders per query.
|
|
68
|
+
* - With `suspense: false`, keys that are loading for the first time hold
|
|
69
|
+
* back the others' answers, so the component renders once with all of them.
|
|
70
|
+
* `loading` is true while at least one key is loading.
|
|
71
|
+
*
|
|
72
|
+
* The optional second argument is config for every key; a key's own config
|
|
73
|
+
* (the tuple's third element) wins over it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function useMultipleQuery<const P extends {
|
|
76
|
+
[K in keyof P]: keyof GetRPC;
|
|
77
|
+
}, const Q extends {
|
|
78
|
+
[K in keyof P]: readonly unknown[];
|
|
79
|
+
}, const G extends MultipleQueryConfig<any> = {}>(queries: {
|
|
80
|
+
[K in keyof P]: MultipleQueryEntry<P[K]>;
|
|
81
|
+
} & Q, config?: G): MultipleQueryReturn<Q, G>;
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=useMultipleQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMultipleQuery.d.ts","sourceRoot":"","sources":["../../client/useMultipleQuery.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAQpD,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,iBAAiB,EACtB,KAAK,MAAM,EACX,KAAK,OAAO,EACb,MAAM,YAAY,CAAC;AAkBpB;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAE7D,+FAA+F;AAC/F,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,MAAM,GAAG,MAAM,MAAM,IAChE,SAAS,CAAC,IAAI,E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AAK,CAAC,CAAC,SAAS,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE,EAE7C,OAAO,EAAE;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,CAAC,EACzD,MAAM,CAAC,EAAE,CAAC,GACT,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -88,11 +88,22 @@ export interface Config<T> {
|
|
|
88
88
|
*/
|
|
89
89
|
live?: LiveChannel;
|
|
90
90
|
}
|
|
91
|
+
type WithOptionalValues<T> = {
|
|
92
|
+
[K in keyof T]: T[K] | null;
|
|
93
|
+
};
|
|
94
|
+
export declare const defaultConfig: Config<any>;
|
|
91
95
|
export type GetRPC = {
|
|
92
96
|
[K in keyof RPC as K extends `GET:${infer P}` ? P : never]: RPC[K];
|
|
93
97
|
};
|
|
94
98
|
export type Data<T extends keyof GetRPC> = GetRPC[T] extends ApiRouterHandler<any, infer Data, any> ? UnwrapPromise<Data> : never;
|
|
99
|
+
type Input<T extends keyof GetRPC> = GetRPC[T] extends ApiRouterHandler<infer I, any, any> ? I : never;
|
|
100
|
+
type QueryOptions<T extends keyof GetRPC> = {
|
|
101
|
+
search?: Partial<WithOptionalValues<Input<T>>>;
|
|
102
|
+
};
|
|
95
103
|
type Error = Record<string, unknown>;
|
|
104
|
+
export declare const defaultOptions: QueryOptions<any> & {
|
|
105
|
+
params?: Record<string, any>;
|
|
106
|
+
};
|
|
96
107
|
export type QueryResult<T extends keyof GetRPC> = NestedPrettify<Data<T> & {}>;
|
|
97
108
|
export type Options<T extends keyof GetRPC> = {
|
|
98
109
|
search?: Record<string, string | number | boolean | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.d.ts","sourceRoot":"","sources":["../../client/useQuery.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,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AE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;AAmBvD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,MAAM,EACtD,GAAG,EAAE,CAAC,EACN,GAAG,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GACxD,WAAW,CAAC,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CA6XrD"}
|
package/dist/facades/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ef as a,Gg as r,Hf as c,Hg as s,If as e,Ig as t,Jf as f,Jg as u,Kf as h,Lf as i,Mf as j,Tf as k,Uf as l,Vf as m,Wf as n,Xf as o,fg as p,rh as v,vg as q}from"../chunk-
|
|
2
|
+
import{Ef as a,Gg as r,Hf as c,Hg as s,If as e,Ig as t,Jf as f,Jg as u,Kf as h,Lf as i,Mf as j,Tf as k,Uf as l,Vf as m,Wf as n,Xf as o,fg as p,rh as v,vg as q}from"../chunk-qjk68wda.js";import"../chunk-hthyn5pj.js";import"../chunk-1em8t2x1.js";import{Wi as b,vj as d,zj as g}from"../chunk-7wzhdq1x.js";import"../chunk-aed0vv5g.js";import"../chunk-jy26hy7z.js";import"../chunk-8ar7180x.js";import"../chunk-yj1h4rzn.js";import"../chunk-3z8d8v8q.js";import"../chunk-wdrmzjtq.js";import"../chunk-6cx6kh04.js";import"../chunk-06w8hhnk.js";import"../chunk-24tj4dzx.js";import"../chunk-xgc5tj8k.js";import"../chunk-etcds9w3.js";import"../chunk-nfher0gz.js";import"../chunk-65btke6p.js";import"../chunk-vyaedzr8.js";import"../chunk-djnn8vvp.js";import"../chunk-tx5zrdmb.js";import"../chunk-0eq7am78.js";import"../chunk-77dt2tap.js";import"../chunk-ne51fxg2.js";import"../chunk-zf1eqgzt.js";export{f as Url,d as Storage,r as Runs,j as Redis,a as Redirect,l as RateLimiter,e as Query,h as Meta,g as Log,m as Lock,c as Lang,s as Features,b as Facade,u as DB,n as Crypt,i as Cookie,o as Connections,t as ConnectionQueries,p as ChangeFeed,k as Cache,q as Broadcast,v as Auth};
|
|
3
3
|
|
|
4
4
|
//# debugId=34483C98FFA730EE64756E2164756E21
|
package/dist/http/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$e as I,Ah as ga,Bh as ha,Cf as J,Ch as ia,Df as K,Dh as ja,Eh as ka,Ff as L,Fh as la,Gf as M,Gh as ma,Hh as na,Ih as oa,Jh as pa,Kh as qa,Lh as ra,Me as t,Mh as sa,Ne as u,Nh as ta,Oe as v,Oh as ua,Pe as w,Qe as x,Re as E,Rg as $,We as F,Ze as G,_e as H,sh as aa,th as ba,uh as ca,xh as da,yh as ea,zh as fa}from"../chunk-
|
|
2
|
+
import{$e as I,Ah as ga,Bh as ha,Cf as J,Ch as ia,Df as K,Dh as ja,Eh as ka,Ff as L,Fh as la,Gf as M,Gh as ma,Hh as na,Ih as oa,Jh as pa,Kh as qa,Lh as ra,Me as t,Mh as sa,Ne as u,Nh as ta,Oe as v,Oh as ua,Pe as w,Qe as x,Re as E,Rg as $,We as F,Ze as G,_e as H,sh as aa,th as ba,uh as ca,xh as da,yh as ea,zh as fa}from"../chunk-qjk68wda.js";import"../chunk-hthyn5pj.js";import"../chunk-1em8t2x1.js";import{Bi as n,Gi as o,Hi as p,Ii as q,Ji as r,Oi as s,Qi as y,Ri as z,Si as A,Ti as B,Ui as C,Vi as D,ej as N,fj as O,gj as P,hj as Q,ij as R,jj as S,kj as T,lj as U,mi as a,mj as V,ni as b,nj as W,oi as d,oj as X,qj as Y,rj as Z,sj as _,ti as e,ui as f,vi as g,wi as h,xi as i,yi as j}from"../chunk-7wzhdq1x.js";import{Ij as c}from"../chunk-aed0vv5g.js";import{Nj as k,Oj as l,Pj as m}from"../chunk-jy26hy7z.js";import"../chunk-8ar7180x.js";import"../chunk-yj1h4rzn.js";import"../chunk-3z8d8v8q.js";import"../chunk-wdrmzjtq.js";import"../chunk-6cx6kh04.js";import"../chunk-06w8hhnk.js";import"../chunk-24tj4dzx.js";import"../chunk-xgc5tj8k.js";import"../chunk-etcds9w3.js";import"../chunk-nfher0gz.js";import"../chunk-65btke6p.js";import"../chunk-vyaedzr8.js";import"../chunk-djnn8vvp.js";import"../chunk-tx5zrdmb.js";import"../chunk-0eq7am78.js";import"../chunk-77dt2tap.js";import"../chunk-ne51fxg2.js";import"../chunk-zf1eqgzt.js";export{g as toRangeHeaderValue,v as toMiddlewareList,k as stateKey,_ as safeFetch,f as resolveRange,e as parseRangeHeader,h as parseContentRange,r as parseByteSize,ia as middlewareConfigDefaults,u as httpError,d as getCookies,j as formatUnsatisfiedContentRange,i as formatContentRange,qa as defineResourcePolicy,ha as defineMiddlewareConfig,n as cspNonce,w as createUnsatisfiableResponse,x as createStreamResponse,L as createFileResponse,I as clientIp,Y as classifyAddress,ca as authorizeChannel,M as ViewRouter,o as ValidationError,V as TooManyRedirectsError,T as TooLargeError,S as TimeoutError,ra as SitemapError,sa as Sitemap,K as SameSiteBounceMiddleware,Z as SafeResponse,N as SafeFetchError,J as SAME_SITE_BOUNCE_PARAM,ta as RobotsTxt,ua as Robots,pa as ResourcePolicy,b as ResourceController,m as RequestState,c as RequestBreakerError,H as RateLimitMiddleware,F as RateLimitExceededError,A as RangeNotSatisfiableError,na as PoliciesServiceProvider,oa as Policies,q as PayloadTooLargeError,B as NotFoundError,W as NetworkError,l as MissingRequestStateError,G as Middleware,fa as McpToolDeclaration,ga as McpRouter,ea as McpRouteDeclaration,da as McpModelParam,p as InvalidValidationRuleError,O as InvalidUrlError,z as InsufficientPermissionsError,X as HttpStatusError,t as HttpResponse,s as HttpRequest,C as FileNotFoundError,R as DnsError,la as CorsMiddleware,a as Controller,U as ContentTypeError,ba as ChannelRouter,aa as ChannelDeclaration,ka as CacheMiddleware,ma as CSRFMiddleware,$ as BodyLimitMiddleware,P as BlockedHostError,Q as BlockedAddressError,y as AuthorizationError,ja as AuthenticationMiddleware,D as AuthenticationError,E as ApiRouter};
|
|
3
3
|
|
|
4
4
|
//# debugId=3F2E457DAA00B39364756E2164756E21
|
package/dist/i18n/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{ra as T}from"../chunk-wpfempaj.js";import"../chunk-hke4hzfm.js";import{pb as D}from"../chunk-4q59y78y.js";import{Je as b,Ke as w}from"../chunk-09hzyf9g.js";import"../chunk-3830ee5d.js";import{Hf as j}from"../chunk-
|
|
2
|
+
import{ra as T}from"../chunk-wpfempaj.js";import"../chunk-hke4hzfm.js";import{pb as D}from"../chunk-4q59y78y.js";import{Je as b,Ke as w}from"../chunk-09hzyf9g.js";import"../chunk-3830ee5d.js";import{Hf as j}from"../chunk-qjk68wda.js";import"../chunk-hthyn5pj.js";import"../chunk-1em8t2x1.js";import"../chunk-7wzhdq1x.js";import"../chunk-aed0vv5g.js";import"../chunk-jy26hy7z.js";import"../chunk-8ar7180x.js";import"../chunk-yj1h4rzn.js";import"../chunk-3z8d8v8q.js";import"../chunk-wdrmzjtq.js";import"../chunk-6cx6kh04.js";import"../chunk-06w8hhnk.js";import"../chunk-24tj4dzx.js";import"../chunk-xgc5tj8k.js";import"../chunk-etcds9w3.js";import"../chunk-nfher0gz.js";import{$l as S,Wl as V,Xl as X,Yl as E,Zl as L,_l as R}from"../chunk-65btke6p.js";import"../chunk-vyaedzr8.js";import"../chunk-djnn8vvp.js";import"../chunk-tx5zrdmb.js";import"../chunk-0eq7am78.js";import"../chunk-77dt2tap.js";import"../chunk-ne51fxg2.js";import"../chunk-zf1eqgzt.js";import{createElement as J,Fragment as M,isValidElement as U}from"react";function $(q,B){let G=Object.values(B).some((z)=>typeof z==="function"&&U(z(""))),Q=/{{([^{}]+?)(?::([^{}\[\]]+?))?(?:\[(.*?)\])?}}/g;if(!G)return q.replace(Q,(W,O,_,Z)=>{let C=O.includes(":")?O.split(":")[0]:O,H=B[C];if(H===void 0)return W;if(typeof H==="function"){let K=H(Z!==void 0?Z:"");if(U(K))throw Error("JSX returned in string context");return String(K)}if(_)switch(_.toLowerCase()){case"number":return Number(H).toString();case"string":return String(H);case"boolean":return Boolean(H).toString();default:return String(H)}return String(H)});else{let z=[],W=0,O=null;while((O=Q.exec(q))!==null){let[_,Z,C,H]=O,F=O.index,K=Z.includes(":")?Z.split(":")[0]:Z;if(F>W)z.push(q.substring(W,F));let Y=B[K];if(Y===void 0)z.push(_);else if(typeof Y==="function"){let A=Y(H!==void 0?H:"");z.push(A)}else if(C)switch(C.toLowerCase()){case"number":z.push(Number(Y).toString());break;case"string":z.push(String(Y));break;case"boolean":z.push(Boolean(Y).toString());break;default:z.push(String(Y))}else z.push(String(Y));W=F+_.length}if(W<q.length)z.push(q.substring(W));return J(M,{},...z)}}class P{name;dictionary;constructor(q,B){this.name=q;this.dictionary=B}reference(q){if(typeof window<"u")throw Error("Cannot use reference in the browser");if(!this.dictionary?.[q])throw Error(`Translation not found for ${String(q)}`);return this.dictionary[q]}render(q,...B){let{locale:G=j.locale(),params:Q}={params:{},...B[0]};if(typeof window<"u")throw Error("Cannot use render in the browser");if(!this.dictionary?.[q]?.[G])throw Error(`Translation not found for ${String(q)} in ${String(G)}`);return $(this.dictionary[q][G],Q??{})}static create(q,B){return new P(q,B)}static text(q,...B){let{locale:G=j.locale(),params:Q}={params:{},...B?.[0]};if(!q?.[G])throw Error(`Translation not found for ${String(G)}`);return $(q[G],Q??{})}}async function N(q,B,...G){let{locale:Q=j.locale(),params:z}={params:{},...G[0]},O=(await q.load(String(Q)))[B];if(typeof O!=="string")throw Error(`Translation not found for "${B}" in "${String(Q)}" (dictionary ${q.id})`);return $(O,z??{})}export{w as translationConfigDefaults,N as translate,V as resolveLocale,X as negotiateLocale,L as isValidTimeZone,b as defineTranslationConfig,T as defineDictionary,R as createFormatter,S as Translator,D as TranslationServiceProvider,P as Dictionary,E as DEFAULT_TIME_ZONE};
|
|
3
3
|
|
|
4
4
|
//# debugId=7A444A0D86D9713664756E2164756E21
|
package/dist/kernel/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ta as E}from"../chunk-6zpf257t.js";import{ob as l}from"../chunk-rjtge67x.js";import{pb as H}from"../chunk-4q59y78y.js";import{$b as I,Cb as g,Db as W,Eb as _,Fb as p,Gb as P,Hb as u,Ib as $,Jb as V,Kb as q,Lb as B,Mb as K,Qb as L,Rb as Q,Sb as T,Wb as U,Xb as y,Yb as F,Zb as C,_b as D,cc as b,fc as f,gc as k,hc as m}from"../chunk-
|
|
2
|
+
import{Ta as E}from"../chunk-6zpf257t.js";import{ob as l}from"../chunk-rjtge67x.js";import{pb as H}from"../chunk-4q59y78y.js";import{$b as I,Cb as g,Db as W,Eb as _,Fb as p,Gb as P,Hb as u,Ib as $,Jb as V,Kb as q,Lb as B,Mb as K,Qb as L,Rb as Q,Sb as T,Wb as U,Xb as y,Yb as F,Zb as C,_b as D,cc as b,fc as f,gc as k,hc as m}from"../chunk-j9ga7b74.js";import"../chunk-v1d7xya8.js";import"../chunk-e0scxs81.js";import"../chunk-p9c5rc1z.js";import"../chunk-9m6mkaqb.js";import{De as h}from"../chunk-vebstesm.js";import"../chunk-09hzyf9g.js";import"../chunk-3830ee5d.js";import{Af as n,Bf as v,ef as d,ff as s,hh as w,lh as A,ph as R}from"../chunk-qjk68wda.js";import"../chunk-hthyn5pj.js";import"../chunk-1em8t2x1.js";import"../chunk-7wzhdq1x.js";import"../chunk-aed0vv5g.js";import"../chunk-jy26hy7z.js";import"../chunk-8ar7180x.js";import"../chunk-yj1h4rzn.js";import{fk as M}from"../chunk-3z8d8v8q.js";import"../chunk-wdrmzjtq.js";import"../chunk-6cx6kh04.js";import"../chunk-06w8hhnk.js";import"../chunk-24tj4dzx.js";import"../chunk-xgc5tj8k.js";import"../chunk-etcds9w3.js";import"../chunk-nfher0gz.js";import"../chunk-wfees83q.js";import"../chunk-65btke6p.js";import{am as O,cm as J}from"../chunk-vyaedzr8.js";import"../chunk-djnn8vvp.js";import"../chunk-tx5zrdmb.js";import"../chunk-0eq7am78.js";import"../chunk-77dt2tap.js";import"../chunk-ne51fxg2.js";import"../chunk-zf1eqgzt.js";var N=[C,I,E,T,L,k,B,Q,D,y,_,U,f,V,F,H,b,K,q,m,$];class S{config={};providers=[];services=[];serviceInstances=[];serviceTokens=new Set;servicesBooted=!1;models=[];app=new J;boot(){if(this.models.length>0)l(...this.models);else a();this.app.config.merge(this.config),J.setInstance(this.app),this.app.registerMany([...N,...this.providers]),this.registerServices()}registerServices(){let j=this.serviceTokens;this.serviceInstances=[],this.serviceTokens=new Set,this.servicesBooted=!1;let X=new Map;for(let z of this.services){let G=typeof z==="function"?new z:z,x=G.constructor;if(!x.token)throw Error(`Service [${x.name}] is listed in \`services\` but does not declare a \`static token\`.`);let Y=X.get(x.token);if(Y)throw Error(`Services [${Y}] and [${x.name}] both declare the token "${x.token}". Tokens are the container's keys, so they must be unique.`);X.set(x.token,x.name);let Z=x;if(!j.has(x.token)&&this.app.bound(Z))throw Error(`Service [${x.name}] declares the token "${x.token}", which is already bound in the container by the framework or a provider. Binding it would replace that service everywhere, so pick a token nothing else owns.`);this.app.instance(Z,G),this.serviceInstances.push(G),this.serviceTokens.add(x.token)}this.app.setShutdownHooks(this.serviceInstances.map((z)=>({name:`${z.constructor.name}.onShutdown`,shutdown:(G)=>z.onShutdown(G)})))}async waitForBoot(){await this.app.boot(),await this.bootServices(),p(this.app)}async bootServices(){if(this.servicesBooted)return;for(let j of this.serviceInstances)await j.boot();this.servicesBooted=!0}shutdown(j){return this.run(()=>this.app.shutdown(j))}run(j){return O.run(this.app,j)}resolve(j){return this.app.make(j)}apiRoutes(){return this.app.make(A)}viewRoutes(){return this.app.make(w)}domains(){return this.app.make(R)}queue(){return this.app.make(h)}mcpHttp(){return this.app.config.get("route.mcp.remote.enabled")===!0?this.app.make(g):null}sockets(){return this.app.config.get("route.channels")?this.app.make(u):null}globalMiddleware(j){return P(j)}destroy(){if(this.app.resolved(W))this.app.make(W).stop();if(this.app.flush(),J.getInstance()===this.app)J.setInstance(void 0);O.disable()}}function a(){if(Bun.env.NODE_ENV==="production")return;let j=M();if(j.length===0)return;console.warn(`[gemi] ${j.length} model${j.length===1?" is":"s are"} registered, but Kernel.models is empty.
|
|
3
3
|
Nested relation reads resolve a model by name, so a policy on a subclass that does not own its
|
|
4
4
|
`+" name is skipped inside every include \u2014 scoped at the root, "+`unscoped in an include, with nothing
|
|
5
5
|
to notice it. Declaring the modules registers each class under its own name and audits the set:
|
package/dist/server/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ra as f}from"../chunk-ba1h9pm6.js";import{Sa as A}from"../chunk-jy61580r.js";import{mm as Q,om as q,pm as w,sm as Z,tm as P,um as y,vm as S,wm as U}from"../chunk-0eq7am78.js";import{Am as H}from"../chunk-77dt2tap.js";import"../chunk-ne51fxg2.js";import{Im as F}from"../chunk-zf1eqgzt.js";var x="/__gemi__/health",$=Symbol.for("gemi.server.health");function V(){let z=globalThis;return z[$]??={lagMs:0,consecutiveBreaches:0,degraded:!1,timer:void 0},z[$]}function W(){let z=V(),B=Q();return{healthy:!B&&!z.degraded,shuttingDown:B,lagMs:z.lagMs,consecutiveBreaches:z.consecutiveBreaches}}function E(z,B){let I=V();I.lagMs=z,I.consecutiveBreaches=z>B.maxLagMs?I.consecutiveBreaches+1:0;let J=I.consecutiveBreaches>=B.breaches;if(J&&!I.degraded)console.warn(`[gemi] Health: degraded (event-loop lag ${Math.round(z)}ms, ${I.consecutiveBreaches} samples in a row over ${B.maxLagMs}ms).`);else if(!J&&I.degraded)console.log(`[gemi] Health: recovered (event-loop lag ${Math.round(z)}ms).`);I.degraded=J}function G(z){let B=V();if(B.timer)return;let I=performance.now()+z.intervalMs;B.timer=setInterval(()=>{let J=performance.now();E(Math.max(0,J-I),z),I=J+z.intervalMs},z.intervalMs),B.timer.unref?.()}function _(z=process.env){return{paths:D(z.GEMI_HEALTH_PATH),intervalMs:O("GEMI_HEALTH_INTERVAL_MS",z.GEMI_HEALTH_INTERVAL_MS,500),maxLagMs:O("GEMI_HEALTH_MAX_LAG_MS",z.GEMI_HEALTH_MAX_LAG_MS,1000),breaches:Math.ceil(O("GEMI_HEALTH_BREACHES",z.GEMI_HEALTH_BREACHES,3))}}function D(z){if(z===void 0||z.trim()==="")return[x];if(z.trim().toLowerCase()==="off")return[];let B=z.split(",").map((J)=>J.trim()).filter(Boolean);if(B.filter((J)=>!J.startsWith("/")).length>0)throw Error(`GEMI_HEALTH_PATH: expected comma-separated paths starting with "/", or "off"; got ${JSON.stringify(z)}.`);return B}function O(z,B,I){if(B===void 0||B.trim()==="")return I;let J=Number(B);if(Number.isFinite(J)&&J>0)return J;return console.warn(`[gemi] Ignoring ${z}="${B}": expected a positive number.`),I}function j(z,B){if(B.length===0)return z;let I=new Set(B);return async(J,K)=>{if(!B.some((b)=>J.url.includes(b))||!I.has(new URL(J.url).pathname))return z(J,K);return y(R(J.method))}}function R(z){let B={"Cache-Control":"no-store","Content-Type":"text/plain; charset=utf-8"};if(z!=="GET"&&z!=="HEAD")return new Response("Method Not Allowed",{status:405,headers:{...B,Allow:"GET, HEAD"}});let{healthy:I,shuttingDown:J}=W();return new Response(z==="HEAD"?null:I?"ok":J?"shutting down":"degraded",{status:I?200:503,headers:B})}var L=Symbol.for("gemi.server.devGeneration"),X={graceMs:1e4,providerTimeoutMs:5000};class Y{app;inFlight=0;waiters=new Set;constructor(z){this.app=z}track(z){return async(B,I)=>{this.inFlight++;try{return await z(B,I)}finally{if(this.inFlight--,this.inFlight===0)this.wake()}}}get pending(){return this.inFlight}async retire({graceMs:z,providerTimeoutMs:B}){try{await this.idle(z),await Promise.resolve().then(()=>this.app.shutdown({timeoutMs:B}))}catch(I){C(I)}}idle(z){if(this.inFlight===0)return Promise.resolve();return new Promise((B)=>{let I=()=>{clearTimeout(J),this.waiters.delete(I),B()},J=setTimeout(I,z);this.waiters.add(I)})}wake(){for(let z of this.waiters)z()}}function N(z,B=X){let I=globalThis,J=I[L];if(I[L]=z,!J||J===z||typeof J.retire!=="function")return Promise.resolve();let K=J.retire.bind(J);return Promise.resolve().then(()=>K(B)).catch(C)}function C(z){console.error("[gemi] Shutting down the application a reload replaced failed:",z)}class k{app;instrumentation;handleSignals;server;stopping;settings;constructor(z){this.app=new A({kernel:z.kernel}),this.handleSignals=z.handleSignals??!0,this.instrumentation=S(z.instrumentation??((B,I)=>I(B)))}async start(){process.env.ROOT_DIR=H();let z=Bun.env.NODE_ENV==="production",B=_();if(z)G(B);let I=j(this.instrumentation,B.paths);if(z){if(this.handleSignals)U(()=>this.stop());this.settings=Z()}try{await this.app.waitForBoot()}catch(J){if(!z)this.app.shutdown({timeoutMs:X.providerTimeoutMs});throw J}if(z){let{httpProd:J}=await import("../chunk-
|
|
2
|
+
import{Ra as f}from"../chunk-ba1h9pm6.js";import{Sa as A}from"../chunk-jy61580r.js";import{mm as Q,om as q,pm as w,sm as Z,tm as P,um as y,vm as S,wm as U}from"../chunk-0eq7am78.js";import{Am as H}from"../chunk-77dt2tap.js";import"../chunk-ne51fxg2.js";import{Im as F}from"../chunk-zf1eqgzt.js";var x="/__gemi__/health",$=Symbol.for("gemi.server.health");function V(){let z=globalThis;return z[$]??={lagMs:0,consecutiveBreaches:0,degraded:!1,timer:void 0},z[$]}function W(){let z=V(),B=Q();return{healthy:!B&&!z.degraded,shuttingDown:B,lagMs:z.lagMs,consecutiveBreaches:z.consecutiveBreaches}}function E(z,B){let I=V();I.lagMs=z,I.consecutiveBreaches=z>B.maxLagMs?I.consecutiveBreaches+1:0;let J=I.consecutiveBreaches>=B.breaches;if(J&&!I.degraded)console.warn(`[gemi] Health: degraded (event-loop lag ${Math.round(z)}ms, ${I.consecutiveBreaches} samples in a row over ${B.maxLagMs}ms).`);else if(!J&&I.degraded)console.log(`[gemi] Health: recovered (event-loop lag ${Math.round(z)}ms).`);I.degraded=J}function G(z){let B=V();if(B.timer)return;let I=performance.now()+z.intervalMs;B.timer=setInterval(()=>{let J=performance.now();E(Math.max(0,J-I),z),I=J+z.intervalMs},z.intervalMs),B.timer.unref?.()}function _(z=process.env){return{paths:D(z.GEMI_HEALTH_PATH),intervalMs:O("GEMI_HEALTH_INTERVAL_MS",z.GEMI_HEALTH_INTERVAL_MS,500),maxLagMs:O("GEMI_HEALTH_MAX_LAG_MS",z.GEMI_HEALTH_MAX_LAG_MS,1000),breaches:Math.ceil(O("GEMI_HEALTH_BREACHES",z.GEMI_HEALTH_BREACHES,3))}}function D(z){if(z===void 0||z.trim()==="")return[x];if(z.trim().toLowerCase()==="off")return[];let B=z.split(",").map((J)=>J.trim()).filter(Boolean);if(B.filter((J)=>!J.startsWith("/")).length>0)throw Error(`GEMI_HEALTH_PATH: expected comma-separated paths starting with "/", or "off"; got ${JSON.stringify(z)}.`);return B}function O(z,B,I){if(B===void 0||B.trim()==="")return I;let J=Number(B);if(Number.isFinite(J)&&J>0)return J;return console.warn(`[gemi] Ignoring ${z}="${B}": expected a positive number.`),I}function j(z,B){if(B.length===0)return z;let I=new Set(B);return async(J,K)=>{if(!B.some((b)=>J.url.includes(b))||!I.has(new URL(J.url).pathname))return z(J,K);return y(R(J.method))}}function R(z){let B={"Cache-Control":"no-store","Content-Type":"text/plain; charset=utf-8"};if(z!=="GET"&&z!=="HEAD")return new Response("Method Not Allowed",{status:405,headers:{...B,Allow:"GET, HEAD"}});let{healthy:I,shuttingDown:J}=W();return new Response(z==="HEAD"?null:I?"ok":J?"shutting down":"degraded",{status:I?200:503,headers:B})}var L=Symbol.for("gemi.server.devGeneration"),X={graceMs:1e4,providerTimeoutMs:5000};class Y{app;inFlight=0;waiters=new Set;constructor(z){this.app=z}track(z){return async(B,I)=>{this.inFlight++;try{return await z(B,I)}finally{if(this.inFlight--,this.inFlight===0)this.wake()}}}get pending(){return this.inFlight}async retire({graceMs:z,providerTimeoutMs:B}){try{await this.idle(z),await Promise.resolve().then(()=>this.app.shutdown({timeoutMs:B}))}catch(I){C(I)}}idle(z){if(this.inFlight===0)return Promise.resolve();return new Promise((B)=>{let I=()=>{clearTimeout(J),this.waiters.delete(I),B()},J=setTimeout(I,z);this.waiters.add(I)})}wake(){for(let z of this.waiters)z()}}function N(z,B=X){let I=globalThis,J=I[L];if(I[L]=z,!J||J===z||typeof J.retire!=="function")return Promise.resolve();let K=J.retire.bind(J);return Promise.resolve().then(()=>K(B)).catch(C)}function C(z){console.error("[gemi] Shutting down the application a reload replaced failed:",z)}class k{app;instrumentation;handleSignals;server;stopping;settings;constructor(z){this.app=new A({kernel:z.kernel}),this.handleSignals=z.handleSignals??!0,this.instrumentation=S(z.instrumentation??((B,I)=>I(B)))}async start(){process.env.ROOT_DIR=H();let z=Bun.env.NODE_ENV==="production",B=_();if(z)G(B);let I=j(this.instrumentation,B.paths);if(z){if(this.handleSignals)U(()=>this.stop());this.settings=Z()}try{await this.app.waitForBoot()}catch(J){if(!z)this.app.shutdown({timeoutMs:X.providerTimeoutMs});throw J}if(z){let{httpProd:J}=await import("../chunk-s4tq4y69.js");this.server=await J(this.app,I)}else{f();let{httpDev:J}=await import("../chunk-jr5t2hrk.js"),K=new Y(this.app);this.server=await J(this.app,K.track(I)),N(K)}return this.server}stop(z={}){let B=this.app.sockets();return this.stopping??=P({server:this.server,closeSockets:B?()=>B.shutdown():void 0,shutdownProviders:(I)=>this.app.shutdown(I),settings:{...this.settings??Z(),...z}}),this.stopping}}export{q as shutdownSignal,W as liveness,Q as isShuttingDown,w as holdShutdown,k as Server};
|
|
3
3
|
|
|
4
4
|
//# debugId=FE20FBD008CD065864756E2164756E21
|
|
@@ -69,9 +69,9 @@ export declare class DatabaseChangeFeedDriver implements ChangeFeedDriver {
|
|
|
69
69
|
close(): Promise<void>;
|
|
70
70
|
}>;
|
|
71
71
|
/**
|
|
72
|
-
* The ORM transaction a publish should be written on
|
|
73
|
-
* driver's own connection, matched by name as the queue's
|
|
74
|
-
* matches it. Never on SQLite, where Bun has one connection and a read on
|
|
72
|
+
* The ORM transaction a publish should be written on, and `heads` read on:
|
|
73
|
+
* one open on this driver's own connection, matched by name as the queue's
|
|
74
|
+
* database driver matches it. Never on SQLite, where Bun has one connection and a read on
|
|
75
75
|
* the pool runs inside the open transaction: a subscriber would deliver an
|
|
76
76
|
* entry that may still roll back, and whose seq would then be reused. There
|
|
77
77
|
* the manager publishes after the commit instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseChangeFeedDriver.d.ts","sourceRoot":"","sources":["../../../services/change-feed/DatabaseChangeFeedDriver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAGpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAA2B,KAAK,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEzF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CACpC,CAAC;AAIF,KAAK,UAAU,GAAG,IAAI,CAAC,kBAAkB,EAAE,KAAK,GAAG,SAAS,CAAC,GAC3D,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,wBAAyB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AM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAwB5E,MAAM,CACV,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,EAChD,QAAQ,EAAE,MAAM,IAAI,GACnB,OAAO,CAAC;QAAE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;IA4BtC;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;CAMpB;AAED,0DAA0D;AAC1D,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAc9E"}
|
package/dist/services/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{rb as v9}from"../chunk-g6tqje74.js";import{$b as k9,Ab as q4,Bb as c1,Cb as mZ,Db as cZ,Eb as Y9,Ib as K9,Jb as G9,Kb as z9,Lb as X9,Mb as F9,Nb as M9,Ob as L9,Pb as N9,Qb as D9,Rb as H9,Sb as U9,Tb as g4,Ub as _6,Vb as w,Wb as x9,Xb as O9,Yb as S9,Zb as R9,_b as _9,ac as f9,bc as C9,cc as V9,dc as T9,ec as P9,fc as b9,gc as w9,hc as q9,sb as IZ,tb as yZ,ub as AZ,vb as hZ,wb as EZ,xb as y4,yb as gZ,zb as w4}from"../chunk-k21eg3pn.js";import{kc as h4}from"../chunk-v1d7xya8.js";import"../chunk-e0scxs81.js";import{$d as dZ,Zd as uZ,_d as pZ,ae as lZ,be as nZ,ce as sZ,de as oZ,ee as aZ,fe as tZ,ge as rZ,he as eZ,ie as W9,je as Z9,ke as $9,le as J9,me as Q9}from"../chunk-p9c5rc1z.js";import{ne as iZ}from"../chunk-9m6mkaqb.js";import{Ae as PZ,Be as bZ,Ce as wZ,De as qZ,Ie as vZ,oe as HZ,pe as UZ,qe as xZ,re as OZ,se as SZ,te as RZ,ue as _Z,ve as kZ,we as fZ,xe as CZ,ye as VZ,ze as TZ}from"../chunk-vebstesm.js";import{Je as B9,Ke as j9}from"../chunk-09hzyf9g.js";import"../chunk-3830ee5d.js";import{$e as D6,$f as _8,$g as GZ,Ag as p8,Bg as d8,Bh as jZ,Cg as l8,Ch as FZ,Dg as n8,Eg as i8,Fg as s8,Kg as U,Lg as m,Mg as o8,Nf as J8,Ng as a8,Of as Q8,Og as t8,Pf as Y8,Pg as r8,Qf as K8,Qg as e8,Rf as G8,Se as N6,Sf as z8,Sg as WZ,Te as P5,Tg as ZZ,Ue as b5,Ug as $Z,Ve as w5,Vg as JZ,Wg as QZ,Xe as q5,Yf as O8,Zf as S8,Zg as YZ,_f as R8,_g as KZ,af as x4,ag as k8,bf as Z6,bg as f8,cf as O4,cg as C8,ch as zZ,df as S4,dg as V8,eg as T8,gg as P8,hf as f6,hg as R6,hh as XZ,if as C6,ig as b8,kf as v5,lf as I5,lh as BZ,mf as y5,mg as w8,nf as A5,ng as q8,of as h5,og as I8,pf as E5,ph as m4,qf as g5,qh as e,rf as m5,rg as y8,sf as c5,sg as A8,tf as o0,tg as h8,uf as u5,ug as E8,vf as p5,wf as d5,wg as g8,xf as l5,xg as m8,yf as n5,yg as c8,zg as u8}from"../chunk-zwznp46g.js";import"../chunk-hthyn5pj.js";import"../chunk-1em8t2x1.js";import{$i as i5,Aj as h1,Oi as b4,Si as J1,Ui as a,Yi as D4,Zi as U1,_i as A1,aj as s5,bj as o5,cj as a5,dj as t5,pj as HW,qj as UW,tj as r5,ui as U4,uj as e5,vi as N4,wi as H1,wj as W8,xj as Z8,yj as $8}from"../chunk-7wzhdq1x.js";import"../chunk-aed0vv5g.js";import{Lj as V}from"../chunk-jy26hy7z.js";import"../chunk-8ar7180x.js";import{$j as d0,Xj as N8,Yj as D8,Zj as v1,_j as H8,ak as U8,bk as x8}from"../chunk-yj1h4rzn.js";import{hk as F8,ik as M8,jk as L8}from"../chunk-3z8d8v8q.js";import"../chunk-wdrmzjtq.js";import{Sk as v8}from"../chunk-6cx6kh04.js";import{Uk as X8,Vk as B8,Wk as j8}from"../chunk-06w8hhnk.js";import"../chunk-24tj4dzx.js";import"../chunk-xgc5tj8k.js";import"../chunk-etcds9w3.js";import"../chunk-nfher0gz.js";import{Ql as _4,Rl as MZ,Sl as LZ,Tl as NZ,Vl as DZ}from"../chunk-wfees83q.js";import"../chunk-65btke6p.js";import{dm as _}from"../chunk-vyaedzr8.js";import"../chunk-djnn8vvp.js";import"../chunk-tx5zrdmb.js";import"../chunk-0eq7am78.js";import"../chunk-77dt2tap.js";import"../chunk-ne51fxg2.js";import{Im as y1}from"../chunk-zf1eqgzt.js";import{Buffer as a0}from"buffer";class t0 extends U1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-njnng5ew.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,J,Q,Y=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Q=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,J=W.type;else $=W.body,Q=W.name,Y=W.bucket??Y,J=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);J=J||void 0;let K=$ instanceof a0?$:$ instanceof Blob||$ instanceof File?a0.from(await $.arrayBuffer()):"",{sdk:G,client:z}=await this.connect();return Z?.throwIfAborted(),await z.send(new G.PutObjectCommand({Bucket:Y,Key:Q,Body:K,ContentType:J}),{abortSignal:Z}),Q}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:J,client:Q}=await this.connect();try{await Q.send(new J.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(Y){if(Y?.name==="NoSuchKey"||Y?.$metadata?.httpStatusCode===404)return;throw Y}}async*pages(W,{bucket:Z,signal:$}){let{sdk:J,client:Q}=await this.connect(),Y;do{$?.throwIfAborted();let K=await Q.send(new J.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:Y}),{abortSignal:$});yield(K.Contents??[]).map((G)=>({name:G.Key,size:G.Size??0,lastModified:G.LastModified??new Date(0)})),Y=K.IsTruncated?K.NextContinuationToken:void 0}while(Y)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){D4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:J,client:Q}=await this.connect(),Y=0;for await(let K of this.pages(W,{...Z,bucket:$})){if(K.length===0)continue;Z.signal?.throwIfAborted();let z=(await Q.send(new J.DeleteObjectsCommand({Bucket:$,Delete:{Objects:K.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(z.length>0){let X=z[0];throw Error(`S3 could not delete ${z.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}Y+=K.length}return Y}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,J;if(typeof W==="string")J=W;else $=W.bucket??$,J=W.name;if(!J)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();Z?.throwIfAborted();let K=await Y.send(new Q.GetObjectCommand({Bucket:$,Key:J}),{abortSignal:Z}),G=A1(K.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(G,{headers:{"Content-Type":K.ContentType,"Content-Length":K.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":K.LastModified?.toUTCString()||"",ETag:K.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:J,range:Q=null}=Z;if(!J)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect(),G;try{G=await K.send(new Y.GetObjectCommand({Bucket:$,Key:J,Range:Q?N4(Q):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new J1(await this.size({name:J,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new a(J);throw j}let z=H1(G.ContentRange),X=Boolean(z)&&G.$metadata?.httpStatusCode===206,B=z?.total??G.ContentLength??0;return{body:G.Body.transformToWebStream(),start:z?.start??0,end:z?.end??B-1,total:B,partial:X,type:G.ContentType??"application/octet-stream",etag:G.ETag||void 0,lastModified:G.LastModified,name:J}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:J,client:Q}=await this.connect();try{return(await Q.send(new J.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(Y){if(Y?.name==="NotFound"||Y?.$metadata?.httpStatusCode===404)throw new a(Z);throw Y}}}import{Buffer as r0}from"buffer";import{Readable as SW}from"stream";function H4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function RW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class e0 extends U1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,J,Q,Y;if(W instanceof Blob)$=W,Q=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,J=W.type;else $=W.body,Q=W.name,Y=W.bucket,J=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let K=$ instanceof r0?$:r0.from(await $.arrayBuffer()),G=await this.blob(Q,Y);return Z?.throwIfAborted(),await G.uploadData(K,{blobHTTPHeaders:J?{blobContentType:J}:void 0,abortSignal:Z}),Q}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let J=Z??this.config.container??process.env.BUCKET_NAME;if(!J)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let Y=(await this.serviceClient()).getContainerClient(J);for await(let K of Y.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:K.name,size:K.properties?.contentLength??0,lastModified:K.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,J=(await this.serviceClient()).getContainerClient(Z),Q=[];for await(let Y of J.listBlobsFlat({prefix:W}))Q.push(Y.name);return Q}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:J,range:Q=null}=W,Y=await this.blob($,J);Z?.throwIfAborted();let K,G,z=Q?.kind==="suffix"||Q?.kind==="offset"&&Q.end===null&&Q.start===0;if(Q&&z){let S=await this.size({name:$,bucket:J}),o=U4(Q,S);if(!o)throw new J1(S);K=o.start,G=o.length}else if(Q?.kind==="offset")K=Q.start,G=Q.end===null?void 0:Q.end-Q.start+1;let X;try{X=await Y.download(K,G,Z?{abortSignal:Z}:void 0)}catch(S){if(RW(S))throw new J1(await this.size({name:$,bucket:J}));if(H4(S))throw new a($);throw S}let B=H1(X.contentRange),j=Boolean(B),L=B?.total??X.contentLength??0,H=await _W(X);if(H instanceof ReadableStream)H=A1(H,Z);return Z?.throwIfAborted(),{body:H,start:B?.start??0,end:B?.end??L-1,total:L,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,J=await this.blob(Z,$);try{return(await J.getProperties()).contentLength??0}catch(Q){if(H4(Q))throw new a(Z);throw Q}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,J=await this.blob(Z,$);try{await J.delete()}catch(Q){if(H4(Q))return;throw Q}}}async function _W(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return SW.toWeb(W.readableStreamBody);return null}function kW(W){return W}class R4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class E1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var W6=1000,fW=60000,CW=`
|
|
2
|
+
import{rb as v9}from"../chunk-g6tqje74.js";import{$b as k9,Ab as q4,Bb as c1,Cb as mZ,Db as cZ,Eb as Y9,Ib as K9,Jb as G9,Kb as z9,Lb as X9,Mb as F9,Nb as M9,Ob as L9,Pb as N9,Qb as D9,Rb as H9,Sb as U9,Tb as g4,Ub as _6,Vb as w,Wb as x9,Xb as O9,Yb as S9,Zb as R9,_b as _9,ac as f9,bc as C9,cc as V9,dc as T9,ec as P9,fc as b9,gc as w9,hc as q9,sb as IZ,tb as yZ,ub as AZ,vb as hZ,wb as EZ,xb as y4,yb as gZ,zb as w4}from"../chunk-j9ga7b74.js";import{kc as h4}from"../chunk-v1d7xya8.js";import"../chunk-e0scxs81.js";import{$d as dZ,Zd as uZ,_d as pZ,ae as lZ,be as nZ,ce as sZ,de as oZ,ee as aZ,fe as tZ,ge as rZ,he as eZ,ie as W9,je as Z9,ke as $9,le as J9,me as Q9}from"../chunk-p9c5rc1z.js";import{ne as iZ}from"../chunk-9m6mkaqb.js";import{Ae as PZ,Be as bZ,Ce as wZ,De as qZ,Ie as vZ,oe as HZ,pe as UZ,qe as xZ,re as OZ,se as SZ,te as RZ,ue as _Z,ve as kZ,we as fZ,xe as CZ,ye as VZ,ze as TZ}from"../chunk-vebstesm.js";import{Je as B9,Ke as j9}from"../chunk-09hzyf9g.js";import"../chunk-3830ee5d.js";import{$e as D6,$f as _8,$g as GZ,Ag as p8,Bg as d8,Bh as jZ,Cg as l8,Ch as FZ,Dg as n8,Eg as i8,Fg as s8,Kg as U,Lg as m,Mg as o8,Nf as J8,Ng as a8,Of as Q8,Og as t8,Pf as Y8,Pg as r8,Qf as K8,Qg as e8,Rf as G8,Se as N6,Sf as z8,Sg as WZ,Te as P5,Tg as ZZ,Ue as b5,Ug as $Z,Ve as w5,Vg as JZ,Wg as QZ,Xe as q5,Yf as O8,Zf as S8,Zg as YZ,_f as R8,_g as KZ,af as x4,ag as k8,bf as Z6,bg as f8,cf as O4,cg as C8,ch as zZ,df as S4,dg as V8,eg as T8,gg as P8,hf as f6,hg as R6,hh as XZ,if as C6,ig as b8,kf as v5,lf as I5,lh as BZ,mf as y5,mg as w8,nf as A5,ng as q8,of as h5,og as I8,pf as E5,ph as m4,qf as g5,qh as e,rf as m5,rg as y8,sf as c5,sg as A8,tf as o0,tg as h8,uf as u5,ug as E8,vf as p5,wf as d5,wg as g8,xf as l5,xg as m8,yf as n5,yg as c8,zg as u8}from"../chunk-qjk68wda.js";import"../chunk-hthyn5pj.js";import"../chunk-1em8t2x1.js";import{$i as i5,Aj as h1,Oi as b4,Si as J1,Ui as a,Yi as D4,Zi as U1,_i as A1,aj as s5,bj as o5,cj as a5,dj as t5,pj as HW,qj as UW,tj as r5,ui as U4,uj as e5,vi as N4,wi as H1,wj as W8,xj as Z8,yj as $8}from"../chunk-7wzhdq1x.js";import"../chunk-aed0vv5g.js";import{Lj as V}from"../chunk-jy26hy7z.js";import"../chunk-8ar7180x.js";import{$j as d0,Xj as N8,Yj as D8,Zj as v1,_j as H8,ak as U8,bk as x8}from"../chunk-yj1h4rzn.js";import{hk as F8,ik as M8,jk as L8}from"../chunk-3z8d8v8q.js";import"../chunk-wdrmzjtq.js";import{Sk as v8}from"../chunk-6cx6kh04.js";import{Uk as X8,Vk as B8,Wk as j8}from"../chunk-06w8hhnk.js";import"../chunk-24tj4dzx.js";import"../chunk-xgc5tj8k.js";import"../chunk-etcds9w3.js";import"../chunk-nfher0gz.js";import{Ql as _4,Rl as MZ,Sl as LZ,Tl as NZ,Vl as DZ}from"../chunk-wfees83q.js";import"../chunk-65btke6p.js";import{dm as _}from"../chunk-vyaedzr8.js";import"../chunk-djnn8vvp.js";import"../chunk-tx5zrdmb.js";import"../chunk-0eq7am78.js";import"../chunk-77dt2tap.js";import"../chunk-ne51fxg2.js";import{Im as y1}from"../chunk-zf1eqgzt.js";import{Buffer as a0}from"buffer";class t0 extends U1{client;config;constructor(...W){super();this.config=W}async connect(){let W=await import("../chunk-njnng5ew.js");return this.client??=new W.S3Client(...this.config),{sdk:W,client:this.client}}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,J,Q,Y=process.env.BUCKET_NAME;if(W instanceof Blob)$=W,Q=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,J=W.type;else $=W.body,Q=W.name,Y=W.bucket??Y,J=W.contentType||($ instanceof Blob||$ instanceof File?$.type:void 0);J=J||void 0;let K=$ instanceof a0?$:$ instanceof Blob||$ instanceof File?a0.from(await $.arrayBuffer()):"",{sdk:G,client:z}=await this.connect();return Z?.throwIfAborted(),await z.send(new G.PutObjectCommand({Bucket:Y,Key:Q,Body:K,ContentType:J}),{abortSignal:Z}),Q}async delete(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME;if(!Z)throw Error("Object name has to be specified");let{sdk:J,client:Q}=await this.connect();try{await Q.send(new J.DeleteObjectCommand({Bucket:$,Key:Z}))}catch(Y){if(Y?.name==="NoSuchKey"||Y?.$metadata?.httpStatusCode===404)return;throw Y}}async*pages(W,{bucket:Z,signal:$}){let{sdk:J,client:Q}=await this.connect(),Y;do{$?.throwIfAborted();let K=await Q.send(new J.ListObjectsV2Command({Bucket:Z??process.env.BUCKET_NAME,Prefix:W,ContinuationToken:Y}),{abortSignal:$});yield(K.Contents??[]).map((G)=>({name:G.Key,size:G.Size??0,lastModified:G.LastModified??new Date(0)})),Y=K.IsTruncated?K.NextContinuationToken:void 0}while(Y)}async*objects(W,Z={}){for await(let $ of this.pages(W,Z))yield*$}async deletePrefix(W,Z={}){D4(W);let $=Z.bucket??process.env.BUCKET_NAME,{sdk:J,client:Q}=await this.connect(),Y=0;for await(let K of this.pages(W,{...Z,bucket:$})){if(K.length===0)continue;Z.signal?.throwIfAborted();let z=(await Q.send(new J.DeleteObjectsCommand({Bucket:$,Delete:{Objects:K.map((X)=>({Key:X.name})),Quiet:!0}}),{abortSignal:Z.signal}))?.Errors??[];if(z.length>0){let X=z[0];throw Error(`S3 could not delete ${z.length} object(s) under "${W}", e.g. "${X.Key}": ${X.Code??"unknown"} ${X.Message??""}`.trim())}Y+=K.length}return Y}async list(W){let{sdk:Z,client:$}=await this.connect();return await $.send(new Z.ListObjectsV2Command({Bucket:process.env.BUCKET_NAME,Prefix:W}))}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=process.env.BUCKET_NAME,J;if(typeof W==="string")J=W;else $=W.bucket??$,J=W.name;if(!J)throw Error("Object name has to be specified");let{sdk:Q,client:Y}=await this.connect();Z?.throwIfAborted();let K=await Y.send(new Q.GetObjectCommand({Bucket:$,Key:J}),{abortSignal:Z}),G=A1(K.Body.transformToWebStream(),Z);return Z?.throwIfAborted(),new Response(G,{headers:{"Content-Type":K.ContentType,"Content-Length":K.ContentLength.toString(),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":K.LastModified?.toUTCString()||"",ETag:K.ETag||""}})}async read(W){let Z=typeof W==="string"?{name:W}:W,$=Z.bucket??process.env.BUCKET_NAME,{name:J,range:Q=null}=Z;if(!J)throw Error("Object name has to be specified");let{sdk:Y,client:K}=await this.connect(),G;try{G=await K.send(new Y.GetObjectCommand({Bucket:$,Key:J,Range:Q?N4(Q):void 0}))}catch(j){if(j?.name==="InvalidRange"||j?.$metadata?.httpStatusCode===416)throw new J1(await this.size({name:J,bucket:$}));if(j?.name==="NoSuchKey"||j?.$metadata?.httpStatusCode===404)throw new a(J);throw j}let z=H1(G.ContentRange),X=Boolean(z)&&G.$metadata?.httpStatusCode===206,B=z?.total??G.ContentLength??0;return{body:G.Body.transformToWebStream(),start:z?.start??0,end:z?.end??B-1,total:B,partial:X,type:G.ContentType??"application/octet-stream",etag:G.ETag||void 0,lastModified:G.LastModified,name:J}}async size(W){let Z=typeof W==="string"?W:W.name,$=(typeof W==="string"?void 0:W.bucket)??process.env.BUCKET_NAME,{sdk:J,client:Q}=await this.connect();try{return(await Q.send(new J.HeadObjectCommand({Bucket:$,Key:Z}))).ContentLength??0}catch(Y){if(Y?.name==="NotFound"||Y?.$metadata?.httpStatusCode===404)throw new a(Z);throw Y}}}import{Buffer as r0}from"buffer";import{Readable as SW}from"stream";function H4(W){return W?.statusCode===404||W?.details?.errorCode==="BlobNotFound"||W?.code==="BlobNotFound"}function RW(W){return W?.statusCode===416||W?.details?.errorCode==="InvalidRange"||W?.code==="InvalidRange"}class e0 extends U1{config;serviceClientPromise=null;constructor(W={}){super();this.config=W}async serviceClient(){if(this.config.serviceClient)return this.config.serviceClient;return this.serviceClientPromise??=(async()=>{let W;try{W=await import("@azure/storage-blob")}catch{throw Error("AzureBlobDriver requires the '@azure/storage-blob' package. Install it with `bun add @azure/storage-blob`, or pass a pre-built `serviceClient`.")}let Z=this.config.connectionString??process.env.AZURE_STORAGE_CONNECTION_STRING;if(this.config.url)return new W.BlobServiceClient(this.config.url,this.config.credential);if(Z)return W.BlobServiceClient.fromConnectionString(Z);throw Error("AzureBlobDriver needs a connection string (AZURE_STORAGE_CONNECTION_STRING), a `url`, or a `serviceClient`.")})(),this.serviceClientPromise}async blob(W,Z){if(!W)throw Error("Object name has to be specified");let $=Z??this.config.container??process.env.BUCKET_NAME;if(!$)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");return(await this.serviceClient()).getContainerClient($).getBlockBlobClient(W)}async put(W,{signal:Z}={}){Z?.throwIfAborted();let $,J,Q,Y;if(W instanceof Blob)$=W,Q=`${Bun.randomUUIDv7()}.${W.type.split("/")[1].split(";")[0]}`,J=W.type;else $=W.body,Q=W.name,Y=W.bucket,J=W.contentType??($ instanceof Blob||$ instanceof File?$.type:void 0);let K=$ instanceof r0?$:r0.from(await $.arrayBuffer()),G=await this.blob(Q,Y);return Z?.throwIfAborted(),await G.uploadData(K,{blobHTTPHeaders:J?{blobContentType:J}:void 0,abortSignal:Z}),Q}async*objects(W,{bucket:Z,signal:$}={}){$?.throwIfAborted();let J=Z??this.config.container??process.env.BUCKET_NAME;if(!J)throw Error("AzureBlobDriver needs a container name, from `bucket`, the `container` config, or BUCKET_NAME.");let Y=(await this.serviceClient()).getContainerClient(J);for await(let K of Y.listBlobsFlat({prefix:W}))$?.throwIfAborted(),yield{name:K.name,size:K.properties?.contentLength??0,lastModified:K.properties?.lastModified??new Date(0)}}async list(W){let Z=this.config.container??process.env.BUCKET_NAME,J=(await this.serviceClient()).getContainerClient(Z),Q=[];for await(let Y of J.listBlobsFlat({prefix:W}))Q.push(Y.name);return Q}async fetch(W,{signal:Z}={}){Z?.throwIfAborted();let $=await this.download(typeof W==="string"?{name:W}:{name:W.name,bucket:W.bucket},Z);return new Response($.body,{headers:{"Content-Type":$.type,"Content-Length":String($.total),"Cache-Control":"private, max-age=12000, must-revalidate","Last-Modified":$.lastModified?.toUTCString()??"",ETag:$.etag??""}})}async read(W){return this.download(typeof W==="string"?{name:W}:W)}async download(W,Z){let{name:$,bucket:J,range:Q=null}=W,Y=await this.blob($,J);Z?.throwIfAborted();let K,G,z=Q?.kind==="suffix"||Q?.kind==="offset"&&Q.end===null&&Q.start===0;if(Q&&z){let S=await this.size({name:$,bucket:J}),o=U4(Q,S);if(!o)throw new J1(S);K=o.start,G=o.length}else if(Q?.kind==="offset")K=Q.start,G=Q.end===null?void 0:Q.end-Q.start+1;let X;try{X=await Y.download(K,G,Z?{abortSignal:Z}:void 0)}catch(S){if(RW(S))throw new J1(await this.size({name:$,bucket:J}));if(H4(S))throw new a($);throw S}let B=H1(X.contentRange),j=Boolean(B),L=B?.total??X.contentLength??0,H=await _W(X);if(H instanceof ReadableStream)H=A1(H,Z);return Z?.throwIfAborted(),{body:H,start:B?.start??0,end:B?.end??L-1,total:L,partial:j,type:X.contentType??"application/octet-stream",etag:X.etag||void 0,lastModified:X.lastModified,name:$}}async size(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,J=await this.blob(Z,$);try{return(await J.getProperties()).contentLength??0}catch(Q){if(H4(Q))throw new a(Z);throw Q}}async delete(W){let Z=typeof W==="string"?W:W.name,$=typeof W==="string"?void 0:W.bucket,J=await this.blob(Z,$);try{await J.delete()}catch(Q){if(H4(Q))return;throw Q}}}async function _W(W){if(W.blobBody)return await W.blobBody;if(W.readableStreamBody)return SW.toWeb(W.readableStreamBody);return null}function kW(W){return W}class R4 extends Error{code="ERR_RATE_LIMITER_TIMEOUT";constructor(W){super(`RedisRateLimiter: Redis did not answer within ${W}ms.`);this.name="RedisRateLimiterTimeoutError"}}class E1 extends Error{code="ERR_RATE_LIMITER_DISCONNECTED";constructor(){super("RedisRateLimiter: the Redis client is not connected.");this.name="RedisRateLimiterDisconnectedError"}}var W6=1000,fW=60000,CW=`
|
|
3
3
|
local currentKey = KEYS[1]
|
|
4
4
|
local previousKey = KEYS[2]
|
|
5
5
|
local limit = tonumber(ARGV[1])
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ description: Best practices for the gemi framework (Bun + Vite + React 19 SSR fu
|
|
|
6
6
|
# gemi Best Practices
|
|
7
7
|
|
|
8
8
|
Rules for building on **gemi**, the full-stack TypeScript framework this app runs on
|
|
9
|
-
(Bun + Vite, React 19 SSR).
|
|
9
|
+
(Bun + Vite, React 19 SSR). 48 rules across 11 categories, ordered by impact.
|
|
10
10
|
|
|
11
11
|
Every rule is derived from the gemi documentation and from patterns that recur across
|
|
12
12
|
gemi codebases. This skill ships with the `gemi` package, so it describes the
|
|
@@ -140,6 +140,7 @@ carried for free.
|
|
|
140
140
|
- `query-suspense-default` - `suspense: true` is the DEFAULT and throws to the nearest boundary
|
|
141
141
|
- `query-lazy-vs-mount-gate` - A lazy query does not refetch when its variant changes
|
|
142
142
|
- `query-share-cache-key` - Identical path + params + search dedupes across components for free
|
|
143
|
+
- `query-multiple-query-per-component` - Never call `useQuery` twice in one component; several reads go through `useMultipleQuery`
|
|
143
144
|
- `query-keep-previous-data` - Keep the previous page rendered while the next variant loads
|
|
144
145
|
- `query-mutate-over-refetch` - Write the cache with `mutate` / `useMutate` / `updates` instead of refetching
|
|
145
146
|
- `query-debounce-search-variant` - Debounce a value before it becomes a query variant
|
|
@@ -216,6 +217,7 @@ Counter-intuitive behaviours that produce silent failures rather than errors:
|
|
|
216
217
|
| `paginate()` silently caps `perPage` at 100 | `orm-paginate-helper` |
|
|
217
218
|
| Command discovery **imports** every file under `app/commands` | `service-lazy-not-module-scope` |
|
|
218
219
|
| A suspending query blanks everything up to the nearest boundary | `query-suspense-default` |
|
|
220
|
+
| Two `useQuery` calls in one component fetch one after the other and render ~2n times | `query-multiple-query-per-component` |
|
|
219
221
|
| Returning `{ error }` from a controller is a **200** the client reads as success | `controller-throw-framework-errors` |
|
|
220
222
|
|
|
221
223
|
## How to Use
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: One Query Hook Per Component — Several Reads Go Through useMultipleQuery
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: n queries, 3 renders instead of 2n + 1, and no request waterfall
|
|
5
|
+
tags: query, suspense, re-renders, waterfall
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## One Query Hook Per Component — Several Reads Go Through useMultipleQuery
|
|
9
|
+
|
|
10
|
+
A component must not call `useQuery` more than once. Each suspending `useQuery`
|
|
11
|
+
throws before the next one runs, so n calls fetch **one after the other** (a
|
|
12
|
+
request waterfall) and render about **2n + 1** times. With `suspense: false` they
|
|
13
|
+
fetch in parallel but still render once per answer (n + 1).
|
|
14
|
+
|
|
15
|
+
`useMultipleQuery` takes the same `[path, options?, config?]` arguments per key,
|
|
16
|
+
sends every request in the same render, suspends once, and commits all keys
|
|
17
|
+
together: **3 renders** under suspense (2 with `suspense: false`), whatever n is.
|
|
18
|
+
It reads the same cache as `useQuery`, so nothing else changes: requests still
|
|
19
|
+
dedupe across components, and `mutate`/`useMutate`/`updates` still reach it.
|
|
20
|
+
|
|
21
|
+
**Incorrect (three requests in sequence, seven renders):**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
function Dashboard({ orgId }: { orgId: string }) {
|
|
25
|
+
const { data: summary } = useQuery("/app/:orgId/summary", { params: { orgId } });
|
|
26
|
+
const { data: lists } = useQuery("/app/:orgId/lists", { params: { orgId } });
|
|
27
|
+
const { data: pending } = useQuery("/app/:orgId/orders/pending-count", {
|
|
28
|
+
params: { orgId },
|
|
29
|
+
});
|
|
30
|
+
// …
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Correct (three requests at once, one commit):**
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { useMultipleQuery } from "gemi/client";
|
|
38
|
+
|
|
39
|
+
function Dashboard({ orgId }: { orgId: string }) {
|
|
40
|
+
const params = { orgId };
|
|
41
|
+
const { data, loading, error, mutate } = useMultipleQuery({
|
|
42
|
+
summary: ["/app/:orgId/summary", { params }],
|
|
43
|
+
lists: ["/app/:orgId/lists", { params }],
|
|
44
|
+
pending: ["/app/:orgId/orders/pending-count", { params }],
|
|
45
|
+
});
|
|
46
|
+
// data.summary, data.lists, data.pending — each typed from its route
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
A key's third element is its `useQuery` config (`staleTime`, `refetchUntil`,
|
|
51
|
+
`live`, `suspense`, …); a second argument applies config to every key.
|
|
52
|
+
|
|
53
|
+
**Exceptions — a second `useQuery` is fine when:**
|
|
54
|
+
|
|
55
|
+
- **One query needs another's answer** (its `params` or `search` come from the
|
|
56
|
+
first query's data). All keys of `useMultipleQuery` are read in the same render,
|
|
57
|
+
so a dependent read has to wait for the first one anyway. Keep the independent
|
|
58
|
+
reads together in one `useMultipleQuery` and the dependent one in its own hook —
|
|
59
|
+
or, better, in a child component that receives the first answer as a prop.
|
|
60
|
+
- **A query is `lazy`** (fetched on `trigger()`): it does not load with the
|
|
61
|
+
others, and `useMultipleQuery` does not take `lazy`.
|
|
62
|
+
- **A paged list** uses `useInfiniteQuery`, which has its own hook.
|
|
63
|
+
|
|
64
|
+
Reading the same query in separate components is not this case: that is one
|
|
65
|
+
query per component, and identical variants share one request
|
|
66
|
+
(`query-share-cache-key`).
|
|
67
|
+
|
|
68
|
+
Reference: <https://nstfkc.github.io/gemi/data-fetching.md>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|