@absolutejs/sync 2.7.1 → 2.9.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/README.md +2 -0
- package/dist/connectionBroker.d.ts +7 -1
- package/dist/engine/graph.d.ts +6 -4
- package/dist/engine/index.js +4 -3
- package/dist/engine/index.js.map +3 -3
- package/dist/index.js +28 -8
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,6 +64,8 @@ keep granularity deliberately coarse (table/row topics, refetch on change); the
|
|
|
64
64
|
queries are matched incrementally; joins (inner and left), aggregations, and
|
|
65
65
|
top-N ordering are maintained incrementally through a composable operator graph
|
|
66
66
|
(`query(...).filter().join().leftJoin().groupBy().orderBy()`).
|
|
67
|
+
`orderBy({ limit, offset })` accepts either fixed numbers or functions of the
|
|
68
|
+
subscription params/context, so each subscriber can hold a different live page.
|
|
67
69
|
|
|
68
70
|
> Status: **1.0** — public API frozen across all subpaths. See
|
|
69
71
|
> [`CHANGELOG.md`](./CHANGELOG.md). Tier 1 (hub, SSE plugin, browser subscriber,
|
|
@@ -18,12 +18,18 @@ export declare class ConnectionBrokerDrainedError extends Error {
|
|
|
18
18
|
constructor();
|
|
19
19
|
}
|
|
20
20
|
export type ConnectionBrokerOptions<Conn> = {
|
|
21
|
+
/**
|
|
22
|
+
* Whether idle connections may be reused by every tenant or only by the
|
|
23
|
+
* tenant that created them. Use `tenant` for BYO credentials or databases.
|
|
24
|
+
* In tenant mode `maxTotal` caps physical active + idle connections.
|
|
25
|
+
*/
|
|
26
|
+
affinity?: 'shared' | 'tenant';
|
|
21
27
|
/**
|
|
22
28
|
* Open one upstream connection. Called lazily — only when a lease needs
|
|
23
29
|
* a connection and the idle pool is empty. The broker never imports a
|
|
24
30
|
* DB driver; bring postgres-js, `Bun.sql`, or anything else.
|
|
25
31
|
*/
|
|
26
|
-
create: () => Promise<Conn> | Conn;
|
|
32
|
+
create: (tenant: string) => Promise<Conn> | Conn;
|
|
27
33
|
/**
|
|
28
34
|
* Global in-use cap — the whole point of the broker. One shard hosting
|
|
29
35
|
* many tenants shares this many upstream connections, total, no matter
|
package/dist/engine/graph.d.ts
CHANGED
|
@@ -36,15 +36,16 @@ export type GroupByOptions<Row> = {
|
|
|
36
36
|
groupBy?: (row: Row) => RowKey;
|
|
37
37
|
value?: (row: Row) => number;
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
type PageBound<P, Ctx> = number | ((params: P, ctx: Ctx) => number);
|
|
40
|
+
export type OrderByQueryOptions<Row, P = void, Ctx = CollectionContext> = {
|
|
40
41
|
/** Row identity. */
|
|
41
42
|
key: (row: Row) => RowKey;
|
|
42
43
|
/** Sort comparator (ascending). */
|
|
43
44
|
compare: (a: Row, b: Row) => number;
|
|
44
45
|
/** Keep at most this many rows (top-N). */
|
|
45
|
-
limit?:
|
|
46
|
+
limit?: PageBound<P, Ctx>;
|
|
46
47
|
/** Skip this many from the front (pagination). */
|
|
47
|
-
offset?:
|
|
48
|
+
offset?: PageBound<P, Ctx>;
|
|
48
49
|
};
|
|
49
50
|
/** A live, instantiated graph for one subscription. */
|
|
50
51
|
export type GraphInstance<Out> = {
|
|
@@ -64,7 +65,7 @@ export type Query<Row, P = void, Ctx = CollectionContext> = {
|
|
|
64
65
|
selectUnmatched: (left: Row) => Out;
|
|
65
66
|
}) => Query<Out, P, Ctx>;
|
|
66
67
|
groupBy: (options: GroupByOptions<Row>) => Query<AggregateGroup, P, Ctx>;
|
|
67
|
-
orderBy: (options: OrderByQueryOptions<Row>) => Query<Row, P, Ctx>;
|
|
68
|
+
orderBy: (options: OrderByQueryOptions<Row, P, Ctx>) => Query<Row, P, Ctx>;
|
|
68
69
|
/** Source tables this query reads. */
|
|
69
70
|
tables: () => string[];
|
|
70
71
|
/** Instantiate the graph for one subscription's params/ctx. */
|
|
@@ -83,3 +84,4 @@ export type GraphCollectionDefinition<Out, P = void, Ctx = CollectionContext> =
|
|
|
83
84
|
};
|
|
84
85
|
/** Define a collection whose result is maintained by an operator graph. */
|
|
85
86
|
export declare const defineGraphCollection: <Out, P = void, Ctx = CollectionContext>(definition: Omit<GraphCollectionDefinition<Out, P, Ctx>, "kind">) => GraphCollectionDefinition<Out, P, Ctx>;
|
|
87
|
+
export {};
|
package/dist/engine/index.js
CHANGED
|
@@ -778,13 +778,14 @@ var instantiateStream = (source, steps, params, ctx) => {
|
|
|
778
778
|
});
|
|
779
779
|
currentKey = (group) => group.group;
|
|
780
780
|
} else {
|
|
781
|
+
const resolveBound = (bound) => typeof bound === "function" ? bound(params, ctx) : bound;
|
|
781
782
|
stages.push({
|
|
782
783
|
kind: "op",
|
|
783
784
|
op: orderByOp({
|
|
784
785
|
key: step.key,
|
|
785
786
|
compare: step.compare,
|
|
786
|
-
limit: step.limit,
|
|
787
|
-
offset: step.offset
|
|
787
|
+
limit: resolveBound(step.limit),
|
|
788
|
+
offset: resolveBound(step.offset)
|
|
788
789
|
})
|
|
789
790
|
});
|
|
790
791
|
currentKey = step.key;
|
|
@@ -3793,5 +3794,5 @@ export {
|
|
|
3793
3794
|
CdcConsumerSlowError
|
|
3794
3795
|
};
|
|
3795
3796
|
|
|
3796
|
-
//# debugId=
|
|
3797
|
+
//# debugId=2E9D206026F45A4364756E2164756E21
|
|
3797
3798
|
//# sourceMappingURL=index.js.map
|