@convex-dev/sharded-counter 0.1.7 → 0.2.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 +39 -41
- package/dist/{commonjs/client → client}/index.d.ts +6 -12
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js.map +1 -0
- package/dist/component/_generated/api.d.ts +34 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/{src → dist}/component/_generated/api.js +11 -3
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +46 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/{src → dist}/component/_generated/server.d.ts +10 -38
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/{esm/component → component}/_generated/server.js +9 -5
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/{commonjs/component → component}/public.d.ts +1 -1
- package/dist/component/public.d.ts.map +1 -0
- package/dist/component/public.js.map +1 -0
- package/dist/{commonjs/component → component}/schema.d.ts +2 -2
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js.map +1 -0
- package/package.json +62 -38
- package/src/client/index.ts +4 -34
- package/src/component/_generated/api.ts +50 -0
- package/src/component/_generated/component.ts +63 -0
- package/src/component/_generated/server.ts +161 -0
- package/src/component/counter.test.ts +12 -9
- package/src/test.ts +18 -0
- package/dist/commonjs/client/index.d.ts.map +0 -1
- package/dist/commonjs/client/index.js.map +0 -1
- package/dist/commonjs/component/_generated/api.d.ts +0 -14
- package/dist/commonjs/component/_generated/api.d.ts.map +0 -1
- package/dist/commonjs/component/_generated/api.js +0 -22
- package/dist/commonjs/component/_generated/api.js.map +0 -1
- package/dist/commonjs/component/_generated/server.d.ts +0 -64
- package/dist/commonjs/component/_generated/server.d.ts.map +0 -1
- package/dist/commonjs/component/_generated/server.js +0 -74
- package/dist/commonjs/component/_generated/server.js.map +0 -1
- package/dist/commonjs/component/convex.config.d.ts.map +0 -1
- package/dist/commonjs/component/convex.config.js.map +0 -1
- package/dist/commonjs/component/public.d.ts.map +0 -1
- package/dist/commonjs/component/public.js.map +0 -1
- package/dist/commonjs/component/schema.d.ts.map +0 -1
- package/dist/commonjs/component/schema.js.map +0 -1
- package/dist/commonjs/package.json +0 -3
- package/dist/esm/client/index.d.ts +0 -178
- package/dist/esm/client/index.d.ts.map +0 -1
- package/dist/esm/client/index.js +0 -193
- package/dist/esm/client/index.js.map +0 -1
- package/dist/esm/component/_generated/api.d.ts +0 -14
- package/dist/esm/component/_generated/api.d.ts.map +0 -1
- package/dist/esm/component/_generated/api.js +0 -22
- package/dist/esm/component/_generated/api.js.map +0 -1
- package/dist/esm/component/_generated/server.d.ts +0 -64
- package/dist/esm/component/_generated/server.d.ts.map +0 -1
- package/dist/esm/component/_generated/server.js.map +0 -1
- package/dist/esm/component/convex.config.d.ts +0 -3
- package/dist/esm/component/convex.config.d.ts.map +0 -1
- package/dist/esm/component/convex.config.js +0 -3
- package/dist/esm/component/convex.config.js.map +0 -1
- package/dist/esm/component/public.d.ts +0 -23
- package/dist/esm/component/public.d.ts.map +0 -1
- package/dist/esm/component/public.js +0 -115
- package/dist/esm/component/public.js.map +0 -1
- package/dist/esm/component/schema.d.ts +0 -15
- package/dist/esm/component/schema.d.ts.map +0 -1
- package/dist/esm/component/schema.js +0 -10
- package/dist/esm/component/schema.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/src/component/_generated/api.d.ts +0 -67
- package/src/component/_generated/server.js +0 -90
- /package/dist/{commonjs/client → client}/index.js +0 -0
- /package/dist/{commonjs/component → component}/convex.config.d.ts +0 -0
- /package/dist/{commonjs/component → component}/convex.config.js +0 -0
- /package/dist/{commonjs/component → component}/public.js +0 -0
- /package/dist/{commonjs/component → component}/schema.js +0 -0
- /package/src/component/_generated/{dataModel.d.ts → dataModel.ts} +0 -0
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
<!-- START: Include on https://convex.dev/components -->
|
|
6
6
|
|
|
7
|
-
This component adds counters to Convex. It acts as a key-value store from
|
|
8
|
-
|
|
7
|
+
This component adds counters to Convex. It acts as a key-value store from string
|
|
8
|
+
to number, with sharding to increase throughput when updating values.
|
|
9
9
|
|
|
10
10
|
Since it's built on Convex, everything is automatically consistent, reactive,
|
|
11
11
|
and cached. Since it's built with [Components](https://convex.dev/components),
|
|
@@ -18,8 +18,8 @@ For example, if you want to display
|
|
|
18
18
|
count the checkboxes in real-time while allowing a lot of the boxes to change in
|
|
19
19
|
parallel.
|
|
20
20
|
|
|
21
|
-
More generally, whenever you have a counter that is changing frequently, you
|
|
22
|
-
|
|
21
|
+
More generally, whenever you have a counter that is changing frequently, you can
|
|
22
|
+
use this component to keep track of it efficiently.
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
25
|
export const checkBox = mutation({
|
|
@@ -46,16 +46,17 @@ export const getCount = query({
|
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
This relies on the assumption that you need to frequently modify the counter,
|
|
49
|
-
but only need to read its value from a query, or infrequently in a mutation.
|
|
50
|
-
|
|
49
|
+
but only need to read its value from a query, or infrequently in a mutation. If
|
|
50
|
+
you read the count every time you modify it, you lose the sharding benefit.
|
|
51
51
|
|
|
52
52
|
## Pre-requisite: Convex
|
|
53
53
|
|
|
54
|
-
You'll need an existing Convex project to use the component.
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
You'll need an existing Convex project to use the component. Convex is a hosted
|
|
55
|
+
backend platform, including a database, serverless functions, and a ton more you
|
|
56
|
+
can learn about [here](https://docs.convex.dev/get-started).
|
|
57
57
|
|
|
58
|
-
Run `npm create convex` or follow any of the
|
|
58
|
+
Run `npm create convex` or follow any of the
|
|
59
|
+
[quickstarts](https://docs.convex.dev/home) to set one up.
|
|
59
60
|
|
|
60
61
|
## Installation
|
|
61
62
|
|
|
@@ -65,13 +66,13 @@ First, install the component package:
|
|
|
65
66
|
npm install @convex-dev/sharded-counter
|
|
66
67
|
```
|
|
67
68
|
|
|
68
|
-
Then, create a `convex.config.ts` file in your app's `convex/` folder and
|
|
69
|
-
component by calling `use`:
|
|
69
|
+
Then, create a `convex.config.ts` file in your app's `convex/` folder and
|
|
70
|
+
install the component by calling `use`:
|
|
70
71
|
|
|
71
72
|
```ts
|
|
72
73
|
// convex/convex.config.ts
|
|
73
74
|
import { defineApp } from "convex/server";
|
|
74
|
-
import shardedCounter from "@convex-dev/sharded-counter/convex.config";
|
|
75
|
+
import shardedCounter from "@convex-dev/sharded-counter/convex.config.js";
|
|
75
76
|
|
|
76
77
|
const app = defineApp();
|
|
77
78
|
app.use(shardedCounter);
|
|
@@ -79,8 +80,8 @@ app.use(shardedCounter);
|
|
|
79
80
|
export default app;
|
|
80
81
|
```
|
|
81
82
|
|
|
82
|
-
Finally, create a new `ShardedCounter` within your `convex/` folder, and point
|
|
83
|
-
the installed component.
|
|
83
|
+
Finally, create a new `ShardedCounter` within your `convex/` folder, and point
|
|
84
|
+
it to the installed component.
|
|
84
85
|
|
|
85
86
|
```ts
|
|
86
87
|
import { components } from "./_generated/api";
|
|
@@ -156,7 +157,7 @@ friends for each user, and you don't care about throughput for a single user,
|
|
|
156
157
|
you would declare ShardedCounter like so:
|
|
157
158
|
|
|
158
159
|
```ts
|
|
159
|
-
const friendCounts = new ShardedCounter<
|
|
160
|
+
const friendCounts = new ShardedCounter<Id<"users">>(
|
|
160
161
|
components.shardedCounter,
|
|
161
162
|
{ defaultShards: 1 },
|
|
162
163
|
);
|
|
@@ -175,8 +176,8 @@ to get an accurate count. This takes a read dependency on all shard documents.
|
|
|
175
176
|
- In a mutation, that means any modification to the counter causes an
|
|
176
177
|
[OCC](https://docs.convex.dev/error#1) conflict.
|
|
177
178
|
|
|
178
|
-
You can reduce contention by estimating the count: read from a smaller number
|
|
179
|
-
|
|
179
|
+
You can reduce contention by estimating the count: read from a smaller number of
|
|
180
|
+
shards and extrapolate based on the total number of shards.
|
|
180
181
|
|
|
181
182
|
```ts
|
|
182
183
|
const estimatedCheckboxCount = await counter.estimateCount(ctx, "checkboxes");
|
|
@@ -190,9 +191,9 @@ from more shards, at the cost of more contention:
|
|
|
190
191
|
const estimateFromThree = await counter.estimateCount(ctx, "checkboxes", 3);
|
|
191
192
|
```
|
|
192
193
|
|
|
193
|
-
If the counter was accumulated from many
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
If the counter was accumulated from many small `counter.inc` and `counter.dec`
|
|
195
|
+
calls, then they should be uniformly distributed across the shards, so estimated
|
|
196
|
+
counts will be accurate.
|
|
196
197
|
|
|
197
198
|
In some cases the counter will not be evenly distributed:
|
|
198
199
|
|
|
@@ -201,8 +202,8 @@ In some cases the counter will not be evenly distributed:
|
|
|
201
202
|
values, because each operation only changes a single shard
|
|
202
203
|
- If the number of shards changed
|
|
203
204
|
|
|
204
|
-
In these cases, the count might not be evenly distributed across the shards.
|
|
205
|
-
|
|
205
|
+
In these cases, the count might not be evenly distributed across the shards. To
|
|
206
|
+
repair such cases, you can call:
|
|
206
207
|
|
|
207
208
|
```ts
|
|
208
209
|
await counter.rebalance(ctx, "checkboxes");
|
|
@@ -211,23 +212,21 @@ await counter.rebalance(ctx, "checkboxes");
|
|
|
211
212
|
Which will even out the count across shards.
|
|
212
213
|
|
|
213
214
|
You may change the number of shards for a key, by changing the second argument
|
|
214
|
-
to the `ShardedCounter` constructor. If you decrease the number of shards,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
In this case, you should call `counter.rebalance` to delete
|
|
215
|
+
to the `ShardedCounter` constructor. If you decrease the number of shards, you
|
|
216
|
+
will be left with extra shards that won't be written to but are still read when
|
|
217
|
+
computing `count`. In this case, you should call `counter.rebalance` to delete
|
|
218
218
|
the extraneous shards.
|
|
219
219
|
|
|
220
|
-
NOTE: `counter.rebalance` reads and writes all shards, so it could cause
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
NOTE: `counter.rebalance` reads and writes all shards, so it could cause more
|
|
221
|
+
OCCs, and it's recommended you call it sparingly, from the Convex dashboard or
|
|
222
|
+
from an infrequent cron.
|
|
223
223
|
|
|
224
|
-
NOTE: counts are floats, and floating point arithmetic isn't infinitely
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
224
|
+
NOTE: counts are floats, and floating point arithmetic isn't infinitely precise.
|
|
225
|
+
Even if you always add and subtract integers, you may get a fractional counts,
|
|
226
|
+
especially if you use `estimateCount` or `rebalance`. Values distributed across
|
|
227
|
+
shards may be added in different combinations, and
|
|
228
228
|
[floating point arithmetic isn't associative](https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html).
|
|
229
|
-
You can use `Math.round` to ensure your final count is an integer, if
|
|
230
|
-
desired.
|
|
229
|
+
You can use `Math.round` to ensure your final count is an integer, if desired.
|
|
231
230
|
|
|
232
231
|
## Counting documents in a table
|
|
233
232
|
|
|
@@ -262,8 +261,7 @@ async function insertUser(ctx, user) {
|
|
|
262
261
|
```
|
|
263
262
|
|
|
264
263
|
3. Register a [Trigger](https://www.npmjs.com/package/convex-helpers#triggers),
|
|
265
|
-
which automatically runs code when a mutation changes the
|
|
266
|
-
data in a table.
|
|
264
|
+
which automatically runs code when a mutation changes the data in a table.
|
|
267
265
|
|
|
268
266
|
```ts
|
|
269
267
|
// Triggers hook up writes to the table to the ShardedCounter.
|
|
@@ -312,9 +310,9 @@ Walkthrough of steps:
|
|
|
312
310
|
2. Create a new document in this table, with fields
|
|
313
311
|
`{ creationTime: 0, id: "", isDone: false }`
|
|
314
312
|
3. Wherever you want to update a counter based on a document changing, wrap the
|
|
315
|
-
update in a conditional, so it only gets updated if the backfill has
|
|
316
|
-
that document. In the example, you would be changing
|
|
317
|
-
to be implemented as `insertUserDuringBackfill`.
|
|
313
|
+
update in a conditional, so it only gets updated if the backfill has
|
|
314
|
+
processed that document. In the example, you would be changing
|
|
315
|
+
`insertUserBeforeBackfill` to be implemented as `insertUserDuringBackfill`.
|
|
318
316
|
4. Define backfill functions similar to `backfillUsers` and `backfillUsersBatch`
|
|
319
317
|
5. Call `backfillUsersBatch` from the dashboard.
|
|
320
318
|
6. Remove the conditional when updating counters. In the example, you would be
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DocumentByName,
|
|
2
|
-
import { GenericId } from "convex/values";
|
|
3
|
-
import {
|
|
1
|
+
import type { DocumentByName, GenericDataModel, GenericMutationCtx, GenericQueryCtx, TableNamesInDataModel } from "convex/server";
|
|
2
|
+
import type { GenericId } from "convex/values";
|
|
3
|
+
import type { ComponentApi } from "../component/_generated/component.js";
|
|
4
4
|
/**
|
|
5
5
|
* A sharded counter is a map from string -> counter, where each counter can
|
|
6
6
|
* be incremented or decremented atomically.
|
|
@@ -22,7 +22,7 @@ export declare class ShardedCounter<ShardsKey extends string> {
|
|
|
22
22
|
* @param options.defaultShards The number of shards for each counter, for
|
|
23
23
|
* keys not in `options.shards`.
|
|
24
24
|
*/
|
|
25
|
-
constructor(component:
|
|
25
|
+
constructor(component: ComponentApi, options?: {
|
|
26
26
|
shards?: Partial<Record<ShardsKey, number>>;
|
|
27
27
|
defaultShards?: number;
|
|
28
28
|
});
|
|
@@ -85,7 +85,7 @@ export declare class ShardedCounter<ShardsKey extends string> {
|
|
|
85
85
|
*
|
|
86
86
|
* Use this to reduce contention when reading the counter.
|
|
87
87
|
*/
|
|
88
|
-
estimateCount<Name extends ShardsKey>(ctx: RunQueryCtx, name: Name, readFromShards?: number): Promise<
|
|
88
|
+
estimateCount<Name extends ShardsKey>(ctx: RunQueryCtx, name: Name, readFromShards?: number): Promise<any>;
|
|
89
89
|
/**
|
|
90
90
|
* Returns an object with methods to update and query the counter for key
|
|
91
91
|
* `name`. For fixed keys, you can call `counter.for("<key>")` to get methods
|
|
@@ -142,7 +142,7 @@ export declare class ShardedCounter<ShardsKey extends string> {
|
|
|
142
142
|
*
|
|
143
143
|
* Use this to reduce contention when reading the counter.
|
|
144
144
|
*/
|
|
145
|
-
estimateCount: (ctx: RunQueryCtx, readFromShards?: number) => Promise<
|
|
145
|
+
estimateCount: (ctx: RunQueryCtx, readFromShards?: number) => Promise<any>;
|
|
146
146
|
};
|
|
147
147
|
trigger<Ctx extends RunMutationCtx, Name extends ShardsKey>(name: Name): Trigger<Ctx, GenericDataModel, TableNamesInDataModel<GenericDataModel>>;
|
|
148
148
|
}
|
|
@@ -168,11 +168,5 @@ type RunQueryCtx = {
|
|
|
168
168
|
type RunMutationCtx = {
|
|
169
169
|
runMutation: GenericMutationCtx<GenericDataModel>["runMutation"];
|
|
170
170
|
};
|
|
171
|
-
export type OpaqueIds<T> = T extends GenericId<infer _T> ? string : T extends (infer U)[] ? OpaqueIds<U>[] : T extends object ? {
|
|
172
|
-
[K in keyof T]: OpaqueIds<T[K]>;
|
|
173
|
-
} : T;
|
|
174
|
-
export type UseApi<API> = Expand<{
|
|
175
|
-
[mod in keyof API]: API[mod] extends FunctionReference<infer FType, "public", infer FArgs, infer FReturnType, infer FComponentPath> ? FunctionReference<FType, "internal", OpaqueIds<FArgs>, OpaqueIds<FReturnType>, FComponentPath> : UseApi<API[mod]>;
|
|
176
|
-
}>;
|
|
177
171
|
export {};
|
|
178
172
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACtB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MA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E,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC;YACnE;;;;;eAKG;YACH,aAAa,EAAE,KAAK,EAAE,GAAgB,EAAE,iBAAyB,CAAC,EAAE,EAAE,CACpE,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,cAAc,CAAC;SAChD,CAAC;IACJ,CAAC;IACD,OAAO,CACL,IAAU;QAEV,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;YAC3B,IAAI,MAAM,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;gBAClC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC5B,CAAC;iBAAM,IAAI,MAAM,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;gBACzC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated `api` utility.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `npx convex dev`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type * as public_ from "../public.js";
|
|
10
|
+
import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
|
|
11
|
+
declare const fullApi: ApiFromModules<{
|
|
12
|
+
public: typeof public_;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
16
|
+
*
|
|
17
|
+
* Usage:
|
|
18
|
+
* ```js
|
|
19
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
|
|
23
|
+
/**
|
|
24
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
25
|
+
*
|
|
26
|
+
* Usage:
|
|
27
|
+
* ```js
|
|
28
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
|
|
32
|
+
export declare const components: {};
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,OAAO,MAAM,cAAc,CAAC;AAE7C,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAGvB,QAAA,MAAM,OAAO,EAAE,cAAc,CAAC;IAC5B,MAAM,EAAE,OAAO,OAAO,CAAC;CACxB,CAAiB,CAAC;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG,EAAE,SAAS,CACzB,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACjB,CAAC;AAElB;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,CAC9B,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CACnB,CAAC;AAElB,eAAO,MAAM,UAAU,EAAqC,EAAE,CAAC"}
|
|
@@ -7,11 +7,10 @@
|
|
|
7
7
|
* To regenerate, run `npx convex dev`.
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
10
|
import { anyApi, componentsGeneric } from "convex/server";
|
|
12
|
-
|
|
11
|
+
const fullApi = anyApi;
|
|
13
12
|
/**
|
|
14
|
-
* A utility for referencing Convex functions in your app's API.
|
|
13
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
15
14
|
*
|
|
16
15
|
* Usage:
|
|
17
16
|
* ```js
|
|
@@ -19,5 +18,14 @@ import { anyApi, componentsGeneric } from "convex/server";
|
|
|
19
18
|
* ```
|
|
20
19
|
*/
|
|
21
20
|
export const api = anyApi;
|
|
21
|
+
/**
|
|
22
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* ```js
|
|
26
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
22
29
|
export const internal = anyApi;
|
|
23
30
|
export const components = componentsGeneric();
|
|
31
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/component/_generated/api.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AASH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAER,MAAa,CAAC;AAEnB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,GAAG,GAGZ,MAAa,CAAC;AAElB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAGjB,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAmB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated `ComponentApi` utility.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `npx convex dev`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { FunctionReference } from "convex/server";
|
|
10
|
+
/**
|
|
11
|
+
* A utility for referencing a Convex component's exposed API.
|
|
12
|
+
*
|
|
13
|
+
* Useful when expecting a parameter like `components.myComponent`.
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```ts
|
|
16
|
+
* async function myFunction(ctx: QueryCtx, component: ComponentApi) {
|
|
17
|
+
* return ctx.runQuery(component.someFile.someQuery, { ...args });
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export type ComponentApi<Name extends string | undefined = string | undefined> = {
|
|
22
|
+
public: {
|
|
23
|
+
add: FunctionReference<"mutation", "internal", {
|
|
24
|
+
count: number;
|
|
25
|
+
name: string;
|
|
26
|
+
shard?: number;
|
|
27
|
+
shards?: number;
|
|
28
|
+
}, number, Name>;
|
|
29
|
+
count: FunctionReference<"query", "internal", {
|
|
30
|
+
name: string;
|
|
31
|
+
}, number, Name>;
|
|
32
|
+
estimateCount: FunctionReference<"query", "internal", {
|
|
33
|
+
name: string;
|
|
34
|
+
readFromShards?: number;
|
|
35
|
+
shards?: number;
|
|
36
|
+
}, any, Name>;
|
|
37
|
+
rebalance: FunctionReference<"mutation", "internal", {
|
|
38
|
+
name: string;
|
|
39
|
+
shards?: number;
|
|
40
|
+
}, any, Name>;
|
|
41
|
+
reset: FunctionReference<"mutation", "internal", {
|
|
42
|
+
name: string;
|
|
43
|
+
}, any, Name>;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/component.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAC3E;IACE,MAAM,EAAE;QACN,GAAG,EAAE,iBAAiB,CACpB,UAAU,EACV,UAAU,EACV;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,EAChE,MAAM,EACN,IAAI,CACL,CAAC;QACF,KAAK,EAAE,iBAAiB,CACtB,OAAO,EACP,UAAU,EACV;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAChB,MAAM,EACN,IAAI,CACL,CAAC;QACF,aAAa,EAAE,iBAAiB,CAC9B,OAAO,EACP,UAAU,EACV;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,cAAc,CAAC,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,EAC1D,GAAG,EACH,IAAI,CACL,CAAC;QACF,SAAS,EAAE,iBAAiB,CAC1B,UAAU,EACV,UAAU,EACV;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,EACjC,GAAG,EACH,IAAI,CACL,CAAC;QACF,KAAK,EAAE,iBAAiB,CACtB,UAAU,EACV,UAAU,EACV;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAChB,GAAG,EACH,IAAI,CACL,CAAC;KACH,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/component/_generated/component.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated data model types.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `npx convex dev`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { DataModelFromSchemaDefinition, DocumentByName, TableNamesInDataModel, SystemTableNames } from "convex/server";
|
|
10
|
+
import type { GenericId } from "convex/values";
|
|
11
|
+
import schema from "../schema.js";
|
|
12
|
+
/**
|
|
13
|
+
* The names of all of your Convex tables.
|
|
14
|
+
*/
|
|
15
|
+
export type TableNames = TableNamesInDataModel<DataModel>;
|
|
16
|
+
/**
|
|
17
|
+
* The type of a document stored in Convex.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
20
|
+
*/
|
|
21
|
+
export type Doc<TableName extends TableNames> = DocumentByName<DataModel, TableName>;
|
|
22
|
+
/**
|
|
23
|
+
* An identifier for a document in Convex.
|
|
24
|
+
*
|
|
25
|
+
* Convex documents are uniquely identified by their `Id`, which is accessible
|
|
26
|
+
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
|
|
27
|
+
*
|
|
28
|
+
* Documents can be loaded using `db.get(id)` in query and mutation functions.
|
|
29
|
+
*
|
|
30
|
+
* IDs are just strings at runtime, but this type can be used to distinguish them from other
|
|
31
|
+
* strings when type checking.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
34
|
+
*/
|
|
35
|
+
export type Id<TableName extends TableNames | SystemTableNames> = GenericId<TableName>;
|
|
36
|
+
/**
|
|
37
|
+
* A type describing your Convex data model.
|
|
38
|
+
*
|
|
39
|
+
* This type includes information about what tables you have, the type of
|
|
40
|
+
* documents stored in those tables, and the indexes defined on them.
|
|
41
|
+
*
|
|
42
|
+
* This type is used to parameterize methods like `queryGeneric` and
|
|
43
|
+
* `mutationGeneric` to make them type-safe.
|
|
44
|
+
*/
|
|
45
|
+
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
|
|
46
|
+
//# sourceMappingURL=dataModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataModel.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/dataModel.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,6BAA6B,EAC7B,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,MAAM,GAAG,CAAC,SAAS,SAAS,UAAU,IAAI,cAAc,CAC5D,SAAS,EACT,SAAS,CACV,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,EAAE,CAAC,SAAS,SAAS,UAAU,GAAG,gBAAgB,IAC5D,SAAS,CAAC,SAAS,CAAC,CAAC;AAEvB;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GAAG,6BAA6B,CAAC,OAAO,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataModel.js","sourceRoot":"","sources":["../../../src/component/_generated/dataModel.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AASH,OAAO,MAAM,MAAM,cAAc,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
1
|
/**
|
|
3
2
|
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
3
|
*
|
|
@@ -7,27 +6,8 @@
|
|
|
7
6
|
* To regenerate, run `npx convex dev`.
|
|
8
7
|
* @module
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
ActionBuilder,
|
|
13
|
-
AnyComponents,
|
|
14
|
-
HttpActionBuilder,
|
|
15
|
-
MutationBuilder,
|
|
16
|
-
QueryBuilder,
|
|
17
|
-
GenericActionCtx,
|
|
18
|
-
GenericMutationCtx,
|
|
19
|
-
GenericQueryCtx,
|
|
20
|
-
GenericDatabaseReader,
|
|
21
|
-
GenericDatabaseWriter,
|
|
22
|
-
FunctionReference,
|
|
23
|
-
} from "convex/server";
|
|
9
|
+
import type { ActionBuilder, HttpActionBuilder, MutationBuilder, QueryBuilder, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter } from "convex/server";
|
|
24
10
|
import type { DataModel } from "./dataModel.js";
|
|
25
|
-
|
|
26
|
-
type GenericCtx =
|
|
27
|
-
| GenericActionCtx<DataModel>
|
|
28
|
-
| GenericMutationCtx<DataModel>
|
|
29
|
-
| GenericQueryCtx<DataModel>;
|
|
30
|
-
|
|
31
11
|
/**
|
|
32
12
|
* Define a query in this Convex app's public API.
|
|
33
13
|
*
|
|
@@ -37,7 +17,6 @@ type GenericCtx =
|
|
|
37
17
|
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
38
18
|
*/
|
|
39
19
|
export declare const query: QueryBuilder<DataModel, "public">;
|
|
40
|
-
|
|
41
20
|
/**
|
|
42
21
|
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
43
22
|
*
|
|
@@ -47,7 +26,6 @@ export declare const query: QueryBuilder<DataModel, "public">;
|
|
|
47
26
|
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
48
27
|
*/
|
|
49
28
|
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
50
|
-
|
|
51
29
|
/**
|
|
52
30
|
* Define a mutation in this Convex app's public API.
|
|
53
31
|
*
|
|
@@ -57,7 +35,6 @@ export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
|
57
35
|
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
58
36
|
*/
|
|
59
37
|
export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
60
|
-
|
|
61
38
|
/**
|
|
62
39
|
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
63
40
|
*
|
|
@@ -67,7 +44,6 @@ export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
|
67
44
|
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
68
45
|
*/
|
|
69
46
|
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
70
|
-
|
|
71
47
|
/**
|
|
72
48
|
* Define an action in this Convex app's public API.
|
|
73
49
|
*
|
|
@@ -80,7 +56,6 @@ export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
|
80
56
|
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
81
57
|
*/
|
|
82
58
|
export declare const action: ActionBuilder<DataModel, "public">;
|
|
83
|
-
|
|
84
59
|
/**
|
|
85
60
|
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
86
61
|
*
|
|
@@ -88,38 +63,36 @@ export declare const action: ActionBuilder<DataModel, "public">;
|
|
|
88
63
|
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
89
64
|
*/
|
|
90
65
|
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
91
|
-
|
|
92
66
|
/**
|
|
93
67
|
* Define an HTTP action.
|
|
94
68
|
*
|
|
95
|
-
*
|
|
96
|
-
* deployment if the requests matches the path and method where
|
|
97
|
-
* is routed. Be sure to route your
|
|
69
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
70
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
71
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
98
72
|
*
|
|
99
|
-
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
73
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
74
|
+
* and a Fetch API `Request` object as its second.
|
|
100
75
|
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
101
76
|
*/
|
|
102
77
|
export declare const httpAction: HttpActionBuilder;
|
|
103
|
-
|
|
104
78
|
/**
|
|
105
79
|
* A set of services for use within Convex query functions.
|
|
106
80
|
*
|
|
107
81
|
* The query context is passed as the first argument to any Convex query
|
|
108
82
|
* function run on the server.
|
|
109
83
|
*
|
|
110
|
-
*
|
|
111
|
-
* read-only.
|
|
84
|
+
* If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
|
|
112
85
|
*/
|
|
113
86
|
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
114
|
-
|
|
115
87
|
/**
|
|
116
88
|
* A set of services for use within Convex mutation functions.
|
|
117
89
|
*
|
|
118
90
|
* The mutation context is passed as the first argument to any Convex mutation
|
|
119
91
|
* function run on the server.
|
|
92
|
+
*
|
|
93
|
+
* If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
|
|
120
94
|
*/
|
|
121
95
|
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
122
|
-
|
|
123
96
|
/**
|
|
124
97
|
* A set of services for use within Convex action functions.
|
|
125
98
|
*
|
|
@@ -127,7 +100,6 @@ export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
|
127
100
|
* function run on the server.
|
|
128
101
|
*/
|
|
129
102
|
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
130
|
-
|
|
131
103
|
/**
|
|
132
104
|
* An interface to read from the database within Convex query functions.
|
|
133
105
|
*
|
|
@@ -136,7 +108,6 @@ export type ActionCtx = GenericActionCtx<DataModel>;
|
|
|
136
108
|
* building a query.
|
|
137
109
|
*/
|
|
138
110
|
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
139
|
-
|
|
140
111
|
/**
|
|
141
112
|
* An interface to read from and write to the database within Convex mutation
|
|
142
113
|
* functions.
|
|
@@ -147,3 +118,4 @@ export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
|
147
118
|
* for the guarantees Convex provides your functions.
|
|
148
119
|
*/
|
|
149
120
|
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
121
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,kBAAkB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
|
9
9
|
*/
|
|
10
|
-
import { actionGeneric, httpActionGeneric, queryGeneric, mutationGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric,
|
|
10
|
+
import { actionGeneric, httpActionGeneric, queryGeneric, mutationGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, } from "convex/server";
|
|
11
11
|
/**
|
|
12
12
|
* Define a query in this Convex app's public API.
|
|
13
13
|
*
|
|
@@ -64,11 +64,15 @@ export const action = actionGeneric;
|
|
|
64
64
|
*/
|
|
65
65
|
export const internalAction = internalActionGeneric;
|
|
66
66
|
/**
|
|
67
|
-
* Define
|
|
67
|
+
* Define an HTTP action.
|
|
68
68
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
69
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
70
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
71
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
72
|
+
*
|
|
73
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
74
|
+
* and a Fetch API `Request` object as its second.
|
|
75
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
72
76
|
*/
|
|
73
77
|
export const httpAction = httpActionGeneric;
|
|
74
78
|
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAaH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAGvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAsC,YAAY,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,oBAAoB,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAyC,eAAe,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC3B,uBAAuB,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuC,aAAa,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GACzB,qBAAqB,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsB,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":";AAEA,wBAAiD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAe,eAAe,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -2,8 +2,8 @@ export declare const DEFAULT_SHARD_COUNT = 16;
|
|
|
2
2
|
export declare const add: import("convex/server").RegisteredMutation<"public", {
|
|
3
3
|
shard?: number | undefined;
|
|
4
4
|
shards?: number | undefined;
|
|
5
|
-
name: string;
|
|
6
5
|
count: number;
|
|
6
|
+
name: string;
|
|
7
7
|
}, Promise<number>>;
|
|
8
8
|
export declare const count: import("convex/server").RegisteredQuery<"public", {
|
|
9
9
|
name: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/component/public.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,eAAO,MAAM,GAAG;;;;;mBA6Bd,CAAC;AAEH,eAAO,MAAM,KAAK;;mBAUhB,CAAC;AAEH,eAAO,MAAM,SAAS;;;iBA2BpB,CAAC;AAEH,eAAO,MAAM,KAAK;;iBAWhB,CAAC;AAEH,eAAO,MAAM,aAAa;;;;mBA2BxB,CAAC"}
|