@vllnt/convex-buckets 0.1.0-canary.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/LICENSE +21 -0
- package/README.md +157 -0
- package/dist/client/index.d.ts +79 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +86 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +28 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +3 -0
- package/dist/client/types.js.map +1 -0
- package/dist/component/_generated/api.d.ts +38 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +102 -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/dist/component/_generated/server.d.ts +133 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +80 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +4 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/mutations.d.ts +44 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +244 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +41 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +101 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +47 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +31 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/validators.d.ts +26 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +16 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/shared.d.ts +13 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +22 -0
- package/dist/shared.js.map +1 -0
- package/package.json +87 -0
- package/src/client/index.ts +247 -0
- package/src/client/types.ts +33 -0
- package/src/component/_generated/api.ts +54 -0
- package/src/component/_generated/component.ts +123 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +169 -0
- package/src/component/convex.config.ts +5 -0
- package/src/component/mutations.ts +316 -0
- package/src/component/queries.ts +112 -0
- package/src/component/schema.ts +35 -0
- package/src/component/validators.ts +22 -0
- package/src/shared.ts +28 -0
- package/src/test.ts +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bntvllnt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<!-- Badges -->
|
|
2
|
+
|
|
3
|
+
[](https://www.convex.dev/components)
|
|
4
|
+
[](https://www.npmjs.com/package/@vllnt/convex-buckets)
|
|
5
|
+
[](https://github.com/vllnt/convex-buckets/actions/workflows/ci.yml)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
|
|
8
|
+
# @vllnt/convex-buckets
|
|
9
|
+
|
|
10
|
+
Ephemeral groups of opaque `subjectRef`s — matches, lobbies, cohorts.
|
|
11
|
+
|
|
12
|
+
Unreleased private preview; the installation command below describes the planned
|
|
13
|
+
package.
|
|
14
|
+
|
|
15
|
+
Not standing orgs (`@vllnt/convex-memberships`), not liveness
|
|
16
|
+
(`@convex-dev/presence`).
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const buckets = new Buckets(components.buckets);
|
|
20
|
+
const id = await buckets.open(ctx, { capacity: 4 });
|
|
21
|
+
await buckets.join(ctx, id, subjectRef);
|
|
22
|
+
await buckets.lock(ctx, id);
|
|
23
|
+
await buckets.close(ctx, id);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Lifecycle: `open` → `locked` (no new joins) → `closed` (terminal).
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
- **Capacity + OCC** — `memberCount` lives on the bucket row so concurrent joins
|
|
31
|
+
retry instead of overfilling.
|
|
32
|
+
- **Join reasons** — `missing` / `locked` / `closed` / `already_member` /
|
|
33
|
+
`full`.
|
|
34
|
+
- **Leave** while `open` or `locked`, not after `close`.
|
|
35
|
+
- **Pagination** — `paginateMembers` returns a cursor and completion flag;
|
|
36
|
+
`listMembers` is only a bounded preview (default 100, max 500).
|
|
37
|
+
- **Bounded erase** — `eraseBucket` reschedules fenced batches;
|
|
38
|
+
`eraseSubject` deletes one batch per call, without background subject sweeps.
|
|
39
|
+
- **Scopes** — default `"global"`.
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pnpm add @vllnt/convex-buckets
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Peer dependency: `convex@^1.45.0`.
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// convex/convex.config.ts
|
|
53
|
+
import { defineApp } from "convex/server";
|
|
54
|
+
import bucketsConfig from "@vllnt/convex-buckets/convex.config";
|
|
55
|
+
|
|
56
|
+
const app = defineApp();
|
|
57
|
+
app.use(bucketsConfig);
|
|
58
|
+
export default app;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { v } from "convex/values";
|
|
63
|
+
import { components } from "./_generated/api";
|
|
64
|
+
import { mutation } from "./_generated/server";
|
|
65
|
+
import { Buckets } from "@vllnt/convex-buckets";
|
|
66
|
+
|
|
67
|
+
const buckets = new Buckets(components.buckets);
|
|
68
|
+
|
|
69
|
+
export const startMatch = mutation({
|
|
70
|
+
args: {},
|
|
71
|
+
returns: v.string(),
|
|
72
|
+
handler: async (ctx) => {
|
|
73
|
+
const subjectRef = /* host-resolved identity */ "user_1";
|
|
74
|
+
const id = await buckets.open(ctx, { capacity: 4 });
|
|
75
|
+
const joined = await buckets.join(ctx, id, subjectRef);
|
|
76
|
+
if (!joined.joined) throw new Error(joined.reason ?? "join failed");
|
|
77
|
+
return id;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## API Reference
|
|
83
|
+
|
|
84
|
+
| Method | Kind | Result |
|
|
85
|
+
| --------------------------------------------------------- | -------- | -------------------------------------------- |
|
|
86
|
+
| `open(ctx, opts?)` | mutation | `bucketRef` |
|
|
87
|
+
| `join(ctx, bucketRef, subjectRef, scope?)` | mutation | `{ joined, reason? }` |
|
|
88
|
+
| `leave(ctx, bucketRef, subjectRef, scope?)` | mutation | `boolean` |
|
|
89
|
+
| `lock` / `close` | mutation | `boolean` |
|
|
90
|
+
| `get(ctx, bucketRef, scope?)` | query | bucket state or `null` |
|
|
91
|
+
| `listMembers(ctx, bucketRef, scope?, limit?)` | query | bounded preview `{ subjectRef, joinedAt }[]` |
|
|
92
|
+
| `paginateMembers(ctx, bucketRef, paginationOpts, scope?)` | query | `{ page, isDone, continueCursor }` |
|
|
93
|
+
| `eraseBucket` / `eraseSubject` | mutation | `number` deleted this pass |
|
|
94
|
+
|
|
95
|
+
Full reference: [docs/API.md](docs/API.md).
|
|
96
|
+
|
|
97
|
+
## React
|
|
98
|
+
|
|
99
|
+
Backend-only — no `./react` entry.
|
|
100
|
+
|
|
101
|
+
## Security
|
|
102
|
+
|
|
103
|
+
- Auth-agnostic — the host must authorize every read/write and derive allowed
|
|
104
|
+
scopes and subject refs. Scopes are namespaces, not authorization. The
|
|
105
|
+
unauthenticated example is for local testing only.
|
|
106
|
+
- Tables sandboxed — reached only through the exported functions.
|
|
107
|
+
- Capacity is enforced by patching `memberCount` on the bucket document (OCC).
|
|
108
|
+
|
|
109
|
+
## Testing
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
pnpm test
|
|
113
|
+
pnpm test:coverage
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Unit tests use the simulated `convex-test` runtime (`@edge-runtime/vm`), not a
|
|
117
|
+
real backend. `example/convex/actions.ts` additionally checks concurrent
|
|
118
|
+
capacity admission and scheduled cleanup on a real local Convex backend. Run
|
|
119
|
+
with an isolated HOME and
|
|
120
|
+
`CONVEX_AGENT_MODE=anonymous pnpm convex dev --once --local-cloud-port 3330 --local-site-port 3331 --run actions:verify`.
|
|
121
|
+
This is targeted evidence, not proof of every concurrency interleaving.
|
|
122
|
+
|
|
123
|
+
## Cleanup and isolation
|
|
124
|
+
|
|
125
|
+
`eraseBucket` closes the bucket and updates its remaining count in the first
|
|
126
|
+
transaction. Its ref stays reserved until all members are removed. Scheduled
|
|
127
|
+
continuation uses the original document ID, so stale work cannot erase a
|
|
128
|
+
replacement bucket. Return values count only the current batch; completion is
|
|
129
|
+
observed through `get` returning `null`.
|
|
130
|
+
|
|
131
|
+
`eraseSubject` deletes one bounded batch per call and schedules no continuation.
|
|
132
|
+
Block new joins while draining, repeat until it returns zero, then permit joins if
|
|
133
|
+
appropriate. A returned zero is only an observation of current membership, not a
|
|
134
|
+
permanent ban. No queued subject sweep can later remove a recreated membership.
|
|
135
|
+
|
|
136
|
+
Multiple mounts are isolated: `app.use(bucketsConfig, { name: "first" })` and
|
|
137
|
+
`app.use(bucketsConfig, { name: "second" })`, accessed through separate
|
|
138
|
+
`Buckets(components.first)` / `Buckets(components.second)` clients. Scopes
|
|
139
|
+
partition data within one mount.
|
|
140
|
+
|
|
141
|
+
## Contributing
|
|
142
|
+
|
|
143
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
144
|
+
|
|
145
|
+
## Author
|
|
146
|
+
|
|
147
|
+
Built by [bntvllnt](https://github.com/bntvllnt) ·
|
|
148
|
+
[bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
|
|
149
|
+
|
|
150
|
+
Part of the [@vllnt](https://github.com/vllnt) Convex component fleet —
|
|
151
|
+
[vllnt.com](https://vllnt.com)
|
|
152
|
+
|
|
153
|
+
If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { FunctionArgs, FunctionReference, FunctionReturnType, PaginationOptions, PaginationResult } from "convex/server";
|
|
2
|
+
import type { BucketsOptions, BucketState, JoinResult, MemberState, OpenOptions } from "./types.js";
|
|
3
|
+
export type BucketsComponent = {
|
|
4
|
+
mutations: {
|
|
5
|
+
close: FunctionReference<"mutation", "internal", {
|
|
6
|
+
bucketRef: string;
|
|
7
|
+
scope: string;
|
|
8
|
+
}, boolean>;
|
|
9
|
+
eraseBucket: FunctionReference<"mutation", "internal", {
|
|
10
|
+
batch?: number;
|
|
11
|
+
bucketRef: string;
|
|
12
|
+
scope: string;
|
|
13
|
+
}, number>;
|
|
14
|
+
eraseSubject: FunctionReference<"mutation", "internal", {
|
|
15
|
+
batch?: number;
|
|
16
|
+
scope: string;
|
|
17
|
+
subjectRef: string;
|
|
18
|
+
}, number>;
|
|
19
|
+
join: FunctionReference<"mutation", "internal", {
|
|
20
|
+
bucketRef: string;
|
|
21
|
+
scope: string;
|
|
22
|
+
subjectRef: string;
|
|
23
|
+
}, JoinResult>;
|
|
24
|
+
leave: FunctionReference<"mutation", "internal", {
|
|
25
|
+
bucketRef: string;
|
|
26
|
+
scope: string;
|
|
27
|
+
subjectRef: string;
|
|
28
|
+
}, boolean>;
|
|
29
|
+
lock: FunctionReference<"mutation", "internal", {
|
|
30
|
+
bucketRef: string;
|
|
31
|
+
scope: string;
|
|
32
|
+
}, boolean>;
|
|
33
|
+
open: FunctionReference<"mutation", "internal", {
|
|
34
|
+
bucketRef?: string;
|
|
35
|
+
capacity?: number;
|
|
36
|
+
scope: string;
|
|
37
|
+
}, string>;
|
|
38
|
+
};
|
|
39
|
+
queries: {
|
|
40
|
+
get: FunctionReference<"query", "internal", {
|
|
41
|
+
bucketRef: string;
|
|
42
|
+
scope: string;
|
|
43
|
+
}, BucketState | null>;
|
|
44
|
+
listMembers: FunctionReference<"query", "internal", {
|
|
45
|
+
bucketRef: string;
|
|
46
|
+
limit?: number;
|
|
47
|
+
scope: string;
|
|
48
|
+
}, MemberState[]>;
|
|
49
|
+
paginateMembers: FunctionReference<"query", "internal", {
|
|
50
|
+
bucketRef: string;
|
|
51
|
+
paginationOpts: PaginationOptions;
|
|
52
|
+
scope: string;
|
|
53
|
+
}, PaginationResult<MemberState>>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
type RunQueryCtx = {
|
|
57
|
+
runQuery<TQuery extends FunctionReference<"query", "internal">>(reference: TQuery, arguments_: FunctionArgs<TQuery>): Promise<FunctionReturnType<TQuery>>;
|
|
58
|
+
};
|
|
59
|
+
type RunMutationCtx = {
|
|
60
|
+
runMutation<TMutation extends FunctionReference<"mutation", "internal">>(reference: TMutation, arguments_: FunctionArgs<TMutation>): Promise<FunctionReturnType<TMutation>>;
|
|
61
|
+
};
|
|
62
|
+
export declare class Buckets {
|
|
63
|
+
private readonly component;
|
|
64
|
+
private readonly defaultScope;
|
|
65
|
+
constructor(component: BucketsComponent, options?: BucketsOptions);
|
|
66
|
+
private scopeOf;
|
|
67
|
+
open(ctx: RunMutationCtx, options?: OpenOptions): Promise<string>;
|
|
68
|
+
join(ctx: RunMutationCtx, bucketRef: string, subjectRef: string, scope?: string): Promise<JoinResult>;
|
|
69
|
+
leave(ctx: RunMutationCtx, bucketRef: string, subjectRef: string, scope?: string): Promise<boolean>;
|
|
70
|
+
lock(ctx: RunMutationCtx, bucketRef: string, scope?: string): Promise<boolean>;
|
|
71
|
+
close(ctx: RunMutationCtx, bucketRef: string, scope?: string): Promise<boolean>;
|
|
72
|
+
get(ctx: RunQueryCtx, bucketRef: string, scope?: string): Promise<BucketState | null>;
|
|
73
|
+
paginateMembers(ctx: RunQueryCtx, bucketRef: string, paginationOptions: PaginationOptions, scope?: string): Promise<PaginationResult<MemberState>>;
|
|
74
|
+
listMembers(ctx: RunQueryCtx, bucketRef: string, scope?: string, limit?: number): Promise<MemberState[]>;
|
|
75
|
+
eraseBucket(ctx: RunMutationCtx, bucketRef: string, scope?: string, batch?: number): Promise<number>;
|
|
76
|
+
eraseSubject(ctx: RunMutationCtx, subjectRef: string, scope?: string, batch?: number): Promise<number>;
|
|
77
|
+
}
|
|
78
|
+
export { type BucketsOptions, type BucketState, type BucketStatus, type JoinResult, type MemberState, type OpenOptions, } from "./types.js";
|
|
79
|
+
//# 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,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE;QACT,KAAK,EAAE,iBAAiB,CACtB,UAAU,EACV,UAAU,EACV;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EACpC,OAAO,CACR,CAAC;QACF,WAAW,EAAE,iBAAiB,CAC5B,UAAU,EACV,UAAU,EACV;YAAE,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EACpD,MAAM,CACP,CAAC;QACF,YAAY,EAAE,iBAAiB,CAC7B,UAAU,EACV,UAAU,EACV;YAAE,KAAK,CAAC,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,EACrD,MAAM,CACP,CAAC;QACF,IAAI,EAAE,iBAAiB,CACrB,UAAU,EACV,UAAU,EACV;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,EACxD,UAAU,CACX,CAAC;QACF,KAAK,EAAE,iBAAiB,CACtB,UAAU,EACV,UAAU,EACV;YAAE,SAAS,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,EACxD,OAAO,CAC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AE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAMxC;IAGD,WAAW,CACT,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,EAAE,CAAC,CAMxB;IAGD,WAAW,CACT,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAMjB;IAGD,YAAY,CACV,GAAG,EAAE,cAAc,EACnB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAMjB;CACF;AAED,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { DEFAULT_SCOPE } from "../shared.js";
|
|
2
|
+
export class Buckets {
|
|
3
|
+
component;
|
|
4
|
+
defaultScope;
|
|
5
|
+
constructor(component, options = {}) {
|
|
6
|
+
this.component = component;
|
|
7
|
+
this.defaultScope = options.defaultScope ?? DEFAULT_SCOPE;
|
|
8
|
+
}
|
|
9
|
+
scopeOf(scope) {
|
|
10
|
+
return scope ?? this.defaultScope;
|
|
11
|
+
}
|
|
12
|
+
open(ctx, options = {}) {
|
|
13
|
+
return ctx.runMutation(this.component.mutations.open, {
|
|
14
|
+
bucketRef: options.bucketRef,
|
|
15
|
+
capacity: options.capacity,
|
|
16
|
+
scope: this.scopeOf(options.scope),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// eslint-disable-next-line max-params -- Preserve the existing positional public API.
|
|
20
|
+
join(ctx, bucketRef, subjectRef, scope) {
|
|
21
|
+
return ctx.runMutation(this.component.mutations.join, {
|
|
22
|
+
bucketRef,
|
|
23
|
+
scope: this.scopeOf(scope),
|
|
24
|
+
subjectRef,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// eslint-disable-next-line max-params -- Preserve the existing positional public API.
|
|
28
|
+
leave(ctx, bucketRef, subjectRef, scope) {
|
|
29
|
+
return ctx.runMutation(this.component.mutations.leave, {
|
|
30
|
+
bucketRef,
|
|
31
|
+
scope: this.scopeOf(scope),
|
|
32
|
+
subjectRef,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
lock(ctx, bucketRef, scope) {
|
|
36
|
+
return ctx.runMutation(this.component.mutations.lock, {
|
|
37
|
+
bucketRef,
|
|
38
|
+
scope: this.scopeOf(scope),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
close(ctx, bucketRef, scope) {
|
|
42
|
+
return ctx.runMutation(this.component.mutations.close, {
|
|
43
|
+
bucketRef,
|
|
44
|
+
scope: this.scopeOf(scope),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
get(ctx, bucketRef, scope) {
|
|
48
|
+
return ctx.runQuery(this.component.queries.get, {
|
|
49
|
+
bucketRef,
|
|
50
|
+
scope: this.scopeOf(scope),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// eslint-disable-next-line max-params -- Preserve the existing positional public API.
|
|
54
|
+
paginateMembers(ctx, bucketRef, paginationOptions, scope) {
|
|
55
|
+
return ctx.runQuery(this.component.queries.paginateMembers, {
|
|
56
|
+
bucketRef,
|
|
57
|
+
paginationOpts: paginationOptions,
|
|
58
|
+
scope: this.scopeOf(scope),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
// eslint-disable-next-line max-params -- Preserve the existing positional public API.
|
|
62
|
+
listMembers(ctx, bucketRef, scope, limit) {
|
|
63
|
+
return ctx.runQuery(this.component.queries.listMembers, {
|
|
64
|
+
bucketRef,
|
|
65
|
+
limit,
|
|
66
|
+
scope: this.scopeOf(scope),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
// eslint-disable-next-line max-params -- Preserve the existing positional public API.
|
|
70
|
+
eraseBucket(ctx, bucketRef, scope, batch) {
|
|
71
|
+
return ctx.runMutation(this.component.mutations.eraseBucket, {
|
|
72
|
+
batch,
|
|
73
|
+
bucketRef,
|
|
74
|
+
scope: this.scopeOf(scope),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
// eslint-disable-next-line max-params -- Preserve the existing positional public API.
|
|
78
|
+
eraseSubject(ctx, subjectRef, scope, batch) {
|
|
79
|
+
return ctx.runMutation(this.component.mutations.eraseSubject, {
|
|
80
|
+
batch,
|
|
81
|
+
scope: this.scopeOf(scope),
|
|
82
|
+
subjectRef,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AA2F7C,MAAM,OAAO,OAAO;IAIC,SAAS;IAHX,YAAY,CAAS;IAEtC,YACmB,SAA2B,EAC5C,OAAO,GAAmB,EAAE;yBADX,SAAS;QAG1B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,aAAa,CAAC;IAC5D,CAAC;IAEO,OAAO,CAAC,KAAc;QAC5B,OAAO,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,GAAmB,EAAE,OAAO,GAAgB,EAAE;QACjD,OAAO,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE;YACpD,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B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
+
export type BucketStatus = "closed" | "locked" | "open";
|
|
3
|
+
export type BucketState = {
|
|
4
|
+
bucketRef: string;
|
|
5
|
+
capacity?: number;
|
|
6
|
+
closedAt?: number;
|
|
7
|
+
lockedAt?: number;
|
|
8
|
+
memberCount: number;
|
|
9
|
+
openedAt: number;
|
|
10
|
+
status: BucketStatus;
|
|
11
|
+
};
|
|
12
|
+
export type MemberState = {
|
|
13
|
+
joinedAt: number;
|
|
14
|
+
subjectRef: string;
|
|
15
|
+
};
|
|
16
|
+
export type JoinResult = {
|
|
17
|
+
joined: boolean;
|
|
18
|
+
reason?: string;
|
|
19
|
+
};
|
|
20
|
+
export type BucketsOptions = {
|
|
21
|
+
defaultScope?: string;
|
|
22
|
+
};
|
|
23
|
+
export type OpenOptions = {
|
|
24
|
+
bucketRef?: string;
|
|
25
|
+
capacity?: number;
|
|
26
|
+
scope?: string;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,wDAAwD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 mutations from "../mutations.js";
|
|
10
|
+
import type * as queries from "../queries.js";
|
|
11
|
+
import type * as validators from "../validators.js";
|
|
12
|
+
import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
|
|
13
|
+
declare const fullApi: ApiFromModules<{
|
|
14
|
+
mutations: typeof mutations;
|
|
15
|
+
queries: typeof queries;
|
|
16
|
+
validators: typeof validators;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
* ```js
|
|
23
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
|
|
27
|
+
/**
|
|
28
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
29
|
+
*
|
|
30
|
+
* Usage:
|
|
31
|
+
* ```js
|
|
32
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
|
|
36
|
+
export declare const components: {};
|
|
37
|
+
export {};
|
|
38
|
+
//# 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,SAAS,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,KAAK,OAAO,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAGvB,QAAA,MAAM,OAAO,EAAE,cAAc,CAAC;IAC5B,SAAS,EAAE,OAAO,SAAS,CAAC;IAC5B,OAAO,EAAE,OAAO,OAAO,CAAC;IACxB,UAAU,EAAE,OAAO,UAAU,CAAC;CAC/B,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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `api` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
11
|
+
const fullApi = anyApi;
|
|
12
|
+
/**
|
|
13
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```js
|
|
17
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
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
|
+
*/
|
|
29
|
+
export const internal = anyApi;
|
|
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;AAWH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAIR,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,102 @@
|
|
|
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
|
+
mutations: {
|
|
23
|
+
close: FunctionReference<"mutation", "internal", {
|
|
24
|
+
bucketRef: string;
|
|
25
|
+
scope: string;
|
|
26
|
+
}, boolean, Name>;
|
|
27
|
+
eraseBucket: FunctionReference<"mutation", "internal", {
|
|
28
|
+
batch?: number;
|
|
29
|
+
bucketRef: string;
|
|
30
|
+
scope: string;
|
|
31
|
+
}, number, Name>;
|
|
32
|
+
eraseSubject: FunctionReference<"mutation", "internal", {
|
|
33
|
+
batch?: number;
|
|
34
|
+
scope: string;
|
|
35
|
+
subjectRef: string;
|
|
36
|
+
}, number, Name>;
|
|
37
|
+
join: FunctionReference<"mutation", "internal", {
|
|
38
|
+
bucketRef: string;
|
|
39
|
+
scope: string;
|
|
40
|
+
subjectRef: string;
|
|
41
|
+
}, {
|
|
42
|
+
joined: boolean;
|
|
43
|
+
reason?: string;
|
|
44
|
+
}, Name>;
|
|
45
|
+
leave: FunctionReference<"mutation", "internal", {
|
|
46
|
+
bucketRef: string;
|
|
47
|
+
scope: string;
|
|
48
|
+
subjectRef: string;
|
|
49
|
+
}, boolean, Name>;
|
|
50
|
+
lock: FunctionReference<"mutation", "internal", {
|
|
51
|
+
bucketRef: string;
|
|
52
|
+
scope: string;
|
|
53
|
+
}, boolean, Name>;
|
|
54
|
+
open: FunctionReference<"mutation", "internal", {
|
|
55
|
+
bucketRef?: string;
|
|
56
|
+
capacity?: number;
|
|
57
|
+
scope: string;
|
|
58
|
+
}, string, Name>;
|
|
59
|
+
};
|
|
60
|
+
queries: {
|
|
61
|
+
get: FunctionReference<"query", "internal", {
|
|
62
|
+
bucketRef: string;
|
|
63
|
+
scope: string;
|
|
64
|
+
}, null | {
|
|
65
|
+
bucketRef: string;
|
|
66
|
+
capacity?: number;
|
|
67
|
+
closedAt?: number;
|
|
68
|
+
lockedAt?: number;
|
|
69
|
+
memberCount: number;
|
|
70
|
+
openedAt: number;
|
|
71
|
+
status: "open" | "locked" | "closed";
|
|
72
|
+
}, Name>;
|
|
73
|
+
listMembers: FunctionReference<"query", "internal", {
|
|
74
|
+
bucketRef: string;
|
|
75
|
+
limit?: number;
|
|
76
|
+
scope: string;
|
|
77
|
+
}, Array<{
|
|
78
|
+
joinedAt: number;
|
|
79
|
+
subjectRef: string;
|
|
80
|
+
}>, Name>;
|
|
81
|
+
paginateMembers: FunctionReference<"query", "internal", {
|
|
82
|
+
bucketRef: string;
|
|
83
|
+
paginationOpts: {
|
|
84
|
+
cursor: string | null;
|
|
85
|
+
endCursor?: string | null;
|
|
86
|
+
id?: number;
|
|
87
|
+
maximumBytesRead?: number;
|
|
88
|
+
maximumRowsRead?: number;
|
|
89
|
+
numItems: number;
|
|
90
|
+
};
|
|
91
|
+
scope: string;
|
|
92
|
+
}, {
|
|
93
|
+
continueCursor: string;
|
|
94
|
+
isDone: boolean;
|
|
95
|
+
page: Array<{
|
|
96
|
+
joinedAt: number;
|
|
97
|
+
subjectRef: string;
|
|
98
|
+
}>;
|
|
99
|
+
}, Name>;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
//# 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,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AE,MAAM,CAAC;SACf,EACD;YACE,cAAc,EAAE,MAAM,CAAC;YACvB,MAAM,EAAE,OAAO,CAAC;YAChB,IAAI,EAAE,KAAK,CAAC;gBAAE,QAAQ,EAAE,MAAM,CAAC;gBAAC,UAAU,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;SACvD,EACD,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(tableName, 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"}
|