@vllnt/convex-flags 0.1.0-canary.9d01801
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 +123 -0
- package/dist/client/index.d.ts +76 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +55 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +19 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +2 -0
- package/dist/client/types.js.map +1 -0
- package/dist/component/_generated/api.d.ts +20 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +15 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +57 -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 +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -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 +7 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/mutations.d.ts +19 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +75 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +30 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +52 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +23 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +10 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/validators.d.ts +38 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +24 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/shared.d.ts +19 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +12 -0
- package/dist/shared.js.map +1 -0
- package/package.json +97 -0
- package/src/client/index.ts +117 -0
- package/src/client/types.ts +21 -0
- package/src/component/_generated/api.ts +36 -0
- package/src/component/_generated/component.ts +74 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/convex.config.ts +9 -0
- package/src/component/mutations.ts +89 -0
- package/src/component/queries.ts +55 -0
- package/src/component/schema.ts +10 -0
- package/src/component/validators.ts +26 -0
- package/src/shared.ts +21 -0
- package/src/test.ts +17 -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,123 @@
|
|
|
1
|
+
<!-- Badges -->
|
|
2
|
+
[](https://www.convex.dev/components)
|
|
3
|
+
[](https://www.npmjs.com/package/@vllnt/convex-flags)
|
|
4
|
+
[](https://github.com/vllnt/convex-flags/actions/workflows/ci.yml)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
7
|
+
# @vllnt/convex-flags
|
|
8
|
+
|
|
9
|
+
Feature flags as a Convex component — boolean kill-switches evaluated on the backend and streamed to every connected client in real time, no redeploy and no third-party flag SaaS.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const flags = new Flags(components.flags);
|
|
13
|
+
await flags.enable(ctx, "new-checkout");
|
|
14
|
+
const enabled = await flags.isEnabled(ctx, "new-checkout"); // reactive in a query
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Boolean kill-switches** — backend-evaluated, reactive, streamed to clients.
|
|
20
|
+
- **Data isolation** — definitions live in the component's own sandboxed `flags` table; no blast radius into your schema.
|
|
21
|
+
- **Reuse** — mount into any Convex backend with one `app.use()`.
|
|
22
|
+
- **Real-time** — flag changes propagate through the same subscription mechanism as your app data.
|
|
23
|
+
- **Dual-target** — runs unchanged on Convex Cloud and self-hosted `convex-backend`.
|
|
24
|
+
- **Auth-agnostic** — domain- and auth-neutral; the host gates every management call.
|
|
25
|
+
|
|
26
|
+
> **Planned (post-0.1.0):** multivariate variants, percentage rollouts, attribute targeting, per-environment rules, and React hooks. Agents must not implement these without an explicit instruction.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @vllnt/convex-flags
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Register the component in your app's `convex/convex.config.ts`:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { defineApp } from "convex/server";
|
|
38
|
+
import flags from "@vllnt/convex-flags/convex.config";
|
|
39
|
+
|
|
40
|
+
const app = defineApp();
|
|
41
|
+
app.use(flags);
|
|
42
|
+
export default app;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Peer dependency: `convex@^1.41.0`.
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// convex/flags.ts — instantiate once and re-export.
|
|
51
|
+
import { Flags } from "@vllnt/convex-flags";
|
|
52
|
+
import { components } from "./_generated/api";
|
|
53
|
+
|
|
54
|
+
export const flags = new Flags(components.flags);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// Flags are data — create them from your own authorized mutations (host owns auth),
|
|
59
|
+
// then evaluate inside any query, mutation, or action.
|
|
60
|
+
import { query } from "./_generated/server";
|
|
61
|
+
import { flags } from "./flags";
|
|
62
|
+
|
|
63
|
+
export const setup = async (ctx) => {
|
|
64
|
+
await flags.define(ctx, { key: "new-checkout", value: false, description: "Rebuilt checkout" });
|
|
65
|
+
await flags.enable(ctx, "new-checkout"); // or flags.disable(ctx, key)
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const checkout = query({
|
|
69
|
+
args: {},
|
|
70
|
+
handler: async (ctx) =>
|
|
71
|
+
(await flags.isEnabled(ctx, "new-checkout"))
|
|
72
|
+
? loadNewCheckout(ctx)
|
|
73
|
+
: loadLegacyCheckout(ctx),
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## API Reference
|
|
78
|
+
|
|
79
|
+
| Method | Kind | Result |
|
|
80
|
+
|--------|------|--------|
|
|
81
|
+
| `isEnabled(ctx, key)` | query | `boolean` (`false` for undefined keys) |
|
|
82
|
+
| `evaluate(ctx, key)` | query | `FlagEvaluation` (`value` + `reason`) |
|
|
83
|
+
| `get(ctx, key)` | query | `FlagDoc \| null` |
|
|
84
|
+
| `list(ctx)` | query | `FlagDoc[]` |
|
|
85
|
+
| `all(ctx)` | query | `Record<string, FlagEvaluation>` (reactive bootstrap) |
|
|
86
|
+
| `define(ctx, definition)` | mutation | Create or update a flag (host gates access) |
|
|
87
|
+
| `enable(ctx, key)` / `disable(ctx, key)` | mutation | Set the flag value |
|
|
88
|
+
| `remove(ctx, key)` | mutation | Hard-delete a flag |
|
|
89
|
+
|
|
90
|
+
Full reference: [docs/API.md](docs/API.md).
|
|
91
|
+
|
|
92
|
+
## Security
|
|
93
|
+
|
|
94
|
+
- Auth-agnostic — all management mutations are internal; wrap them in your own authorized mutations and apply auth there.
|
|
95
|
+
- Flag keys are opaque host-chosen strings; the component never interprets or validates their structure.
|
|
96
|
+
- Tables are sandboxed — the component never reads host or sibling tables.
|
|
97
|
+
|
|
98
|
+
See [docs/API.md](docs/API.md).
|
|
99
|
+
|
|
100
|
+
## Testing
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pnpm test # single run
|
|
104
|
+
pnpm test:coverage # enforced 100% on covered files
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Tests run against the real component runtime via `convex-test` (`@edge-runtime/vm`), not mocks.
|
|
108
|
+
|
|
109
|
+
## Contributing
|
|
110
|
+
|
|
111
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
112
|
+
|
|
113
|
+
## Author
|
|
114
|
+
|
|
115
|
+
Built by [bntvllnt](https://github.com/bntvllnt) · [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
|
|
116
|
+
|
|
117
|
+
Part of the [@vllnt](https://github.com/vllnt) Convex component fleet — [vllnt.com](https://vllnt.com)
|
|
118
|
+
|
|
119
|
+
If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
MIT
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
|
|
2
|
+
import type { FlagDefinition, FlagDoc, FlagEvaluation } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The component's function references, as exposed on the host via
|
|
5
|
+
* `components.flags`.
|
|
6
|
+
*/
|
|
7
|
+
export interface FlagsComponent {
|
|
8
|
+
mutations: {
|
|
9
|
+
define: FunctionReference<"mutation", "internal", {
|
|
10
|
+
key: string;
|
|
11
|
+
value: boolean;
|
|
12
|
+
description?: string;
|
|
13
|
+
}, string>;
|
|
14
|
+
enable: FunctionReference<"mutation", "internal", {
|
|
15
|
+
key: string;
|
|
16
|
+
}, null>;
|
|
17
|
+
disable: FunctionReference<"mutation", "internal", {
|
|
18
|
+
key: string;
|
|
19
|
+
}, null>;
|
|
20
|
+
remove: FunctionReference<"mutation", "internal", {
|
|
21
|
+
key: string;
|
|
22
|
+
}, null>;
|
|
23
|
+
};
|
|
24
|
+
queries: {
|
|
25
|
+
get: FunctionReference<"query", "internal", {
|
|
26
|
+
key: string;
|
|
27
|
+
}, FlagDoc | null>;
|
|
28
|
+
list: FunctionReference<"query", "internal", Record<string, never>, FlagDoc[]>;
|
|
29
|
+
evaluate: FunctionReference<"query", "internal", {
|
|
30
|
+
key: string;
|
|
31
|
+
}, FlagEvaluation>;
|
|
32
|
+
all: FunctionReference<"query", "internal", Record<string, never>, Record<string, FlagEvaluation>>;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
interface RunQueryCtx {
|
|
36
|
+
runQuery<Q extends FunctionReference<"query", "internal">>(reference: Q, args: FunctionArgs<Q>): Promise<FunctionReturnType<Q>>;
|
|
37
|
+
}
|
|
38
|
+
interface RunMutationCtx {
|
|
39
|
+
runMutation<M extends FunctionReference<"mutation", "internal">>(reference: M, args: FunctionArgs<M>): Promise<FunctionReturnType<M>>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Consumer-facing client for `@vllnt/convex-flags`. Construct with the mounted
|
|
43
|
+
* component ref, then call from host queries/mutations/actions. The host owns
|
|
44
|
+
* auth: gate the management methods (`define`, `enable`, `disable`, `remove`)
|
|
45
|
+
* behind your own authorized mutations.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const flags = new Flags(components.flags);
|
|
50
|
+
* if (await flags.isEnabled(ctx, "new-checkout")) { ... }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare class Flags {
|
|
54
|
+
private readonly component;
|
|
55
|
+
constructor(component: FlagsComponent);
|
|
56
|
+
/** Create a flag, or update it if the key already exists. Returns its id. */
|
|
57
|
+
define(ctx: RunMutationCtx, definition: FlagDefinition): Promise<string>;
|
|
58
|
+
/** Turn a flag on. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
59
|
+
enable(ctx: RunMutationCtx, key: string): Promise<null>;
|
|
60
|
+
/** Turn a flag off. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
61
|
+
disable(ctx: RunMutationCtx, key: string): Promise<null>;
|
|
62
|
+
/** Permanently delete a flag. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
63
|
+
remove(ctx: RunMutationCtx, key: string): Promise<null>;
|
|
64
|
+
/** Fetch a single flag definition, or `null` if undefined. */
|
|
65
|
+
get(ctx: RunQueryCtx, key: string): Promise<FlagDoc | null>;
|
|
66
|
+
/** List every flag definition. */
|
|
67
|
+
list(ctx: RunQueryCtx): Promise<FlagDoc[]>;
|
|
68
|
+
/** Evaluate a flag, returning its value and the reason it was served. */
|
|
69
|
+
evaluate(ctx: RunQueryCtx, key: string): Promise<FlagEvaluation>;
|
|
70
|
+
/** Evaluate a flag and return just its boolean value (default `false`). */
|
|
71
|
+
isEnabled(ctx: RunQueryCtx, key: string): Promise<boolean>;
|
|
72
|
+
/** Evaluate every flag — the bootstrap payload for a reactive client. */
|
|
73
|
+
all(ctx: RunQueryCtx): Promise<Record<string, FlagEvaluation>>;
|
|
74
|
+
}
|
|
75
|
+
export type { FlagDefinition, FlagDoc, FlagEvaluation };
|
|
76
|
+
//# 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,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE;QACT,MAAM,EAAE,iBAAiB,CACvB,UAAU,EACV,UAAU,EACV;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,OAAO,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAA;SAAE,EACrD,MAAM,CACP,CAAC;QACF,MAAM,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,IAAI,CAAC,CAAC;QACzE,OAAO,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,IAAI,CAAC,CAAC;QAC1E,MAAM,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,IAAI,CAAC,CAAC;KAC1E,CAAC;IACF,OAAO,EAAE;QACP,GAAG,EAAE,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC;QAC7E,IAAI,EAAE,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,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,CAAC,IAAI,CAAC;IAIvD,8DAA8D;IAC9D,GAAG,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAI3D,kCAAkC;IAClC,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAI1C,yEAAyE;IACzE,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAIhE,2EAA2E;IACrE,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhE,yEAAyE;IACzE,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAG/D;AAED,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consumer-facing client for `@vllnt/convex-flags`. Construct with the mounted
|
|
3
|
+
* component ref, then call from host queries/mutations/actions. The host owns
|
|
4
|
+
* auth: gate the management methods (`define`, `enable`, `disable`, `remove`)
|
|
5
|
+
* behind your own authorized mutations.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const flags = new Flags(components.flags);
|
|
10
|
+
* if (await flags.isEnabled(ctx, "new-checkout")) { ... }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export class Flags {
|
|
14
|
+
component;
|
|
15
|
+
constructor(component) {
|
|
16
|
+
this.component = component;
|
|
17
|
+
}
|
|
18
|
+
/** Create a flag, or update it if the key already exists. Returns its id. */
|
|
19
|
+
define(ctx, definition) {
|
|
20
|
+
return ctx.runMutation(this.component.mutations.define, definition);
|
|
21
|
+
}
|
|
22
|
+
/** Turn a flag on. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
23
|
+
enable(ctx, key) {
|
|
24
|
+
return ctx.runMutation(this.component.mutations.enable, { key });
|
|
25
|
+
}
|
|
26
|
+
/** Turn a flag off. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
27
|
+
disable(ctx, key) {
|
|
28
|
+
return ctx.runMutation(this.component.mutations.disable, { key });
|
|
29
|
+
}
|
|
30
|
+
/** Permanently delete a flag. Throws `FLAG_NOT_FOUND` if the key is undefined. */
|
|
31
|
+
remove(ctx, key) {
|
|
32
|
+
return ctx.runMutation(this.component.mutations.remove, { key });
|
|
33
|
+
}
|
|
34
|
+
/** Fetch a single flag definition, or `null` if undefined. */
|
|
35
|
+
get(ctx, key) {
|
|
36
|
+
return ctx.runQuery(this.component.queries.get, { key });
|
|
37
|
+
}
|
|
38
|
+
/** List every flag definition. */
|
|
39
|
+
list(ctx) {
|
|
40
|
+
return ctx.runQuery(this.component.queries.list, {});
|
|
41
|
+
}
|
|
42
|
+
/** Evaluate a flag, returning its value and the reason it was served. */
|
|
43
|
+
evaluate(ctx, key) {
|
|
44
|
+
return ctx.runQuery(this.component.queries.evaluate, { key });
|
|
45
|
+
}
|
|
46
|
+
/** Evaluate a flag and return just its boolean value (default `false`). */
|
|
47
|
+
async isEnabled(ctx, key) {
|
|
48
|
+
return (await this.evaluate(ctx, key)).value;
|
|
49
|
+
}
|
|
50
|
+
/** Evaluate every flag — the bootstrap payload for a reactive client. */
|
|
51
|
+
all(ctx) {
|
|
52
|
+
return ctx.runQuery(this.component.queries.all, {});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAuDA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,KAAK;IACa;IAA7B,YAA6B,SAAyB;QAAzB,cAAS,GAAT,SAAS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AAC;IAED,2EAA2E;IAC3E,KAAK,CAAC,SAAS,CAAC,GAAgB,EAAE,GAAW;QAC3C,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/C,CAAC;IAED,yEAAyE;IACzE,GAAG,CAAC,GAAgB;QAClB,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EvalReason, FlagEvaluation } from "../shared.js";
|
|
2
|
+
/** A flag document as returned by the component queries. */
|
|
3
|
+
export interface FlagDoc {
|
|
4
|
+
_id: string;
|
|
5
|
+
_creationTime: number;
|
|
6
|
+
key: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
value: boolean;
|
|
9
|
+
createdAt: number;
|
|
10
|
+
updatedAt: number;
|
|
11
|
+
}
|
|
12
|
+
/** A flag definition passed to {@link Flags.define}. */
|
|
13
|
+
export interface FlagDefinition {
|
|
14
|
+
key: string;
|
|
15
|
+
value: boolean;
|
|
16
|
+
description?: string;
|
|
17
|
+
}
|
|
18
|
+
export type { EvalReason, FlagEvaluation };
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE/D,4DAA4D;AAC5D,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wDAAwD;AACxD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
|
|
12
|
+
declare const fullApi: ApiFromModules<{
|
|
13
|
+
mutations: typeof mutations;
|
|
14
|
+
queries: typeof queries;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
|
|
17
|
+
export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
|
|
18
|
+
export declare const components: import("convex/server").AnyChildComponents;
|
|
19
|
+
export {};
|
|
20
|
+
//# 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;AAE9C,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;CACzB,CAAiB,CAAC;AAEnB,eAAO,MAAM,GAAG,EAAE,SAAS,CACzB,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACjB,CAAC;AAElB,eAAO,MAAM,QAAQ,EAAE,SAAS,CAC9B,OAAO,OAAO,EACd,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CACnB,CAAC;AAElB,eAAO,MAAM,UAAU,4CAAsB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export const api = anyApi;
|
|
13
|
+
export const internal = anyApi;
|
|
14
|
+
export const components = componentsGeneric();
|
|
15
|
+
//# 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;AAUH,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,OAAO,GAGR,MAAa,CAAC;AAEnB,MAAM,CAAC,MAAM,GAAG,GAGZ,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,QAAQ,GAGjB,MAAa,CAAC;AAElB,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
type FlagDoc = {
|
|
11
|
+
_id: string;
|
|
12
|
+
_creationTime: number;
|
|
13
|
+
key: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
value: boolean;
|
|
16
|
+
createdAt: number;
|
|
17
|
+
updatedAt: number;
|
|
18
|
+
};
|
|
19
|
+
type FlagEvaluation = {
|
|
20
|
+
value: boolean;
|
|
21
|
+
reason: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A utility for referencing a Convex component's exposed API.
|
|
25
|
+
*
|
|
26
|
+
* Useful when expecting a parameter like `components.flags`.
|
|
27
|
+
*/
|
|
28
|
+
export type ComponentApi<Name extends string | undefined = string | undefined> = {
|
|
29
|
+
mutations: {
|
|
30
|
+
define: FunctionReference<"mutation", "internal", {
|
|
31
|
+
key: string;
|
|
32
|
+
value: boolean;
|
|
33
|
+
description?: string;
|
|
34
|
+
}, string, Name>;
|
|
35
|
+
enable: FunctionReference<"mutation", "internal", {
|
|
36
|
+
key: string;
|
|
37
|
+
}, null, Name>;
|
|
38
|
+
disable: FunctionReference<"mutation", "internal", {
|
|
39
|
+
key: string;
|
|
40
|
+
}, null, Name>;
|
|
41
|
+
remove: FunctionReference<"mutation", "internal", {
|
|
42
|
+
key: string;
|
|
43
|
+
}, null, Name>;
|
|
44
|
+
};
|
|
45
|
+
queries: {
|
|
46
|
+
get: FunctionReference<"query", "internal", {
|
|
47
|
+
key: string;
|
|
48
|
+
}, FlagDoc | null, Name>;
|
|
49
|
+
list: FunctionReference<"query", "internal", {}, Array<FlagDoc>, Name>;
|
|
50
|
+
evaluate: FunctionReference<"query", "internal", {
|
|
51
|
+
key: string;
|
|
52
|
+
}, FlagEvaluation, Name>;
|
|
53
|
+
all: FunctionReference<"query", "internal", {}, Record<string, FlagEvaluation>, Name>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export {};
|
|
57
|
+
//# 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,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,cAAc,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD;;;;GAIG;AACH,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,IAC3E;IACE,SAAS,EAAE;QACT,MAAM,EAAE,iBAAiB,CACvB,UAAU,EACV,UAAU,EACV;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,OAAO,CAAC;YAAC,WAAW,CAAC,EAAE,MAAM,CAAA;SAAE,EACrD,MAAM,EACN,IAAI,CACL,CAAC;QACF,MAAM,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC/E,OAAO,EAAE,iBAAiB,CACxB,UAAU,EACV,UAAU,EACV;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EACf,IAAI,EACJ,IAAI,CACL,CAAC;QACF,MAAM,EAAE,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;KAChF,CAAC;IACF,OAAO,EAAE;QACP,GAAG,EAAE,iBAAiB,CACpB,OAAO,EACP,UAAU,EACV;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EACf,OAAO,GAAG,IAAI,EACd,IAAI,CACL,CAAC;QACF,IAAI,EAAE,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;QACvE,QAAQ,EAAE,iBAAiB,CACzB,OAAO,EACP,UAAU,EACV;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EACf,cAAc,EACd,IAAI,CACL,CAAC;QACF,GAAG,EAAE,iBAAiB,CACpB,OAAO,EACP,UAAU,EACV,EAAE,EACF,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EAC9B,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataModel.js","sourceRoot":"","sources":["../../../src/component/_generated/dataModel.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
3
|
+
*
|
|
4
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
5
|
+
*
|
|
6
|
+
* To regenerate, run `npx convex dev`.
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { ActionBuilder, HttpActionBuilder, MutationBuilder, QueryBuilder, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter } from "convex/server";
|
|
10
|
+
import type { DataModel } from "./dataModel.js";
|
|
11
|
+
/**
|
|
12
|
+
* Define a query in this Convex app's public API.
|
|
13
|
+
*
|
|
14
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
15
|
+
*
|
|
16
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
17
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
18
|
+
*/
|
|
19
|
+
export declare const query: QueryBuilder<DataModel, "public">;
|
|
20
|
+
/**
|
|
21
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
22
|
+
*
|
|
23
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
24
|
+
*
|
|
25
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
26
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
27
|
+
*/
|
|
28
|
+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
29
|
+
/**
|
|
30
|
+
* Define a mutation in this Convex app's public API.
|
|
31
|
+
*
|
|
32
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
33
|
+
*
|
|
34
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
35
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
36
|
+
*/
|
|
37
|
+
export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
38
|
+
/**
|
|
39
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
40
|
+
*
|
|
41
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
42
|
+
*
|
|
43
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
44
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
45
|
+
*/
|
|
46
|
+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
47
|
+
/**
|
|
48
|
+
* Define an action in this Convex app's public API.
|
|
49
|
+
*
|
|
50
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
51
|
+
* code and code with side-effects, like calling third-party services.
|
|
52
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
53
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
54
|
+
*
|
|
55
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
56
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
57
|
+
*/
|
|
58
|
+
export declare const action: ActionBuilder<DataModel, "public">;
|
|
59
|
+
/**
|
|
60
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
61
|
+
*
|
|
62
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
63
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
64
|
+
*/
|
|
65
|
+
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
66
|
+
/**
|
|
67
|
+
* Define an HTTP action.
|
|
68
|
+
*
|
|
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.
|
|
76
|
+
*/
|
|
77
|
+
export declare const httpAction: HttpActionBuilder;
|
|
78
|
+
/**
|
|
79
|
+
* A set of services for use within Convex query functions.
|
|
80
|
+
*
|
|
81
|
+
* The query context is passed as the first argument to any Convex query
|
|
82
|
+
* function run on the server.
|
|
83
|
+
*
|
|
84
|
+
* If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
|
|
85
|
+
*/
|
|
86
|
+
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
87
|
+
/**
|
|
88
|
+
* A set of services for use within Convex mutation functions.
|
|
89
|
+
*
|
|
90
|
+
* The mutation context is passed as the first argument to any Convex mutation
|
|
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.
|
|
94
|
+
*/
|
|
95
|
+
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
96
|
+
/**
|
|
97
|
+
* A set of services for use within Convex action functions.
|
|
98
|
+
*
|
|
99
|
+
* The action context is passed as the first argument to any Convex action
|
|
100
|
+
* function run on the server.
|
|
101
|
+
*/
|
|
102
|
+
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
103
|
+
/**
|
|
104
|
+
* An interface to read from the database within Convex query functions.
|
|
105
|
+
*
|
|
106
|
+
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
107
|
+
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
108
|
+
* building a query.
|
|
109
|
+
*/
|
|
110
|
+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
111
|
+
/**
|
|
112
|
+
* An interface to read from and write to the database within Convex mutation
|
|
113
|
+
* functions.
|
|
114
|
+
*
|
|
115
|
+
* Convex guarantees that all writes within a single mutation are
|
|
116
|
+
* executed atomically, so you never have to worry about partial writes leaving
|
|
117
|
+
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
118
|
+
* for the guarantees Convex provides your functions.
|
|
119
|
+
*/
|
|
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,EAClB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAUvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,YAAY,CAAC,SAAS,EAAE,QAAQ,CAA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