@vllnt/convex-api-keys 0.1.0-canary.f67cc26
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 +190 -0
- package/README.md +227 -0
- package/dist/client/_generated/_ignore.d.ts +1 -0
- package/dist/client/_generated/_ignore.d.ts.map +1 -0
- package/dist/client/_generated/_ignore.js +3 -0
- package/dist/client/_generated/_ignore.js.map +1 -0
- package/dist/client/index.d.ts +67 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +93 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +68 -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 +41 -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 +146 -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 +12 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/mutations.d.ts +94 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +456 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +49 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +147 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +70 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +43 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/validators.d.ts +3 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +4 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/log.d.ts +11 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +15 -0
- package/dist/log.js.map +1 -0
- package/dist/shared.d.ts +26 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +60 -0
- package/dist/shared.js.map +1 -0
- package/package.json +96 -0
- package/src/client/_generated/_ignore.ts +1 -0
- package/src/client/index.ts +185 -0
- package/src/client/types.ts +77 -0
- package/src/component/_generated/api.ts +57 -0
- package/src/component/_generated/component.ts +200 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +156 -0
- package/src/component/convex.config.ts +14 -0
- package/src/component/mutations.ts +511 -0
- package/src/component/queries.ts +162 -0
- package/src/component/schema.ts +45 -0
- package/src/component/validators.ts +4 -0
- package/src/log.test.ts +52 -0
- package/src/log.ts +24 -0
- package/src/shared.test.ts +126 -0
- package/src/shared.ts +121 -0
- package/src/test.ts +15 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import type { GenericMutationCtx, GenericQueryCtx, GenericDataModel } from "convex/server";
|
|
2
|
+
import type { ComponentApi } from "../component/_generated/component.js";
|
|
3
|
+
import { sha256Hex } from "../shared.js";
|
|
4
|
+
import type {
|
|
5
|
+
CreateKeyOptions,
|
|
6
|
+
CreateKeyResult,
|
|
7
|
+
ValidationResult,
|
|
8
|
+
KeyMetadata,
|
|
9
|
+
UsageStats,
|
|
10
|
+
RotateResult,
|
|
11
|
+
KeyType,
|
|
12
|
+
KeyStatus,
|
|
13
|
+
} from "./types.js";
|
|
14
|
+
|
|
15
|
+
export type {
|
|
16
|
+
CreateKeyOptions,
|
|
17
|
+
CreateKeyResult,
|
|
18
|
+
ValidationResult,
|
|
19
|
+
KeyMetadata,
|
|
20
|
+
UsageStats,
|
|
21
|
+
RotateResult,
|
|
22
|
+
KeyType,
|
|
23
|
+
KeyStatus,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type RunMutationCtx = Pick<GenericMutationCtx<GenericDataModel>, "runMutation">;
|
|
27
|
+
export type RunQueryCtx = Pick<GenericQueryCtx<GenericDataModel>, "runQuery">;
|
|
28
|
+
|
|
29
|
+
export interface ApiKeysConfig {
|
|
30
|
+
prefix?: string;
|
|
31
|
+
defaultType?: KeyType;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function generateRandomHex(length: number): string {
|
|
35
|
+
const bytes = new Uint8Array(length / 2);
|
|
36
|
+
crypto.getRandomValues(bytes);
|
|
37
|
+
return Array.from(bytes)
|
|
38
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
39
|
+
.join("");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class ApiKeys {
|
|
43
|
+
public component: ComponentApi;
|
|
44
|
+
private prefix: string;
|
|
45
|
+
private defaultType: KeyType;
|
|
46
|
+
|
|
47
|
+
constructor(component: ComponentApi, config?: ApiKeysConfig) {
|
|
48
|
+
this.component = component;
|
|
49
|
+
this.prefix = config?.prefix ?? "vk";
|
|
50
|
+
this.defaultType = config?.defaultType ?? "secret";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async create(
|
|
54
|
+
ctx: RunMutationCtx,
|
|
55
|
+
options: CreateKeyOptions,
|
|
56
|
+
): Promise<CreateKeyResult> {
|
|
57
|
+
const type = options.type ?? this.defaultType;
|
|
58
|
+
const typeShort = type === "publishable" ? "pub" : "secret";
|
|
59
|
+
const env = options.env ?? "live";
|
|
60
|
+
|
|
61
|
+
const lookupPrefix = generateRandomHex(8);
|
|
62
|
+
const secretHex = generateRandomHex(64);
|
|
63
|
+
|
|
64
|
+
const rawKey = [this.prefix, typeShort, env, lookupPrefix, secretHex].join("_");
|
|
65
|
+
const hash = await sha256Hex(rawKey);
|
|
66
|
+
|
|
67
|
+
const result = await ctx.runMutation(this.component.mutations.create, {
|
|
68
|
+
name: options.name,
|
|
69
|
+
ownerId: options.ownerId,
|
|
70
|
+
type,
|
|
71
|
+
scopes: options.scopes,
|
|
72
|
+
tags: options.tags,
|
|
73
|
+
env,
|
|
74
|
+
metadata: options.metadata,
|
|
75
|
+
remaining: options.remaining,
|
|
76
|
+
expiresAt: options.expiresAt,
|
|
77
|
+
keyPrefix: this.prefix,
|
|
78
|
+
lookupPrefix,
|
|
79
|
+
secretHex,
|
|
80
|
+
hash,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return { keyId: result.keyId as string, key: result.key };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async validate(
|
|
87
|
+
ctx: RunMutationCtx,
|
|
88
|
+
args: { key: string },
|
|
89
|
+
): Promise<ValidationResult> {
|
|
90
|
+
return await ctx.runMutation(
|
|
91
|
+
this.component.mutations.validate,
|
|
92
|
+
{ key: args.key },
|
|
93
|
+
) as ValidationResult;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async revoke(ctx: RunMutationCtx, args: { keyId: string }): Promise<void> {
|
|
97
|
+
await ctx.runMutation(this.component.mutations.revoke, { keyId: args.keyId });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async revokeByTag(
|
|
101
|
+
ctx: RunMutationCtx,
|
|
102
|
+
args: { ownerId: string; tag: string },
|
|
103
|
+
): Promise<{ revokedCount: number }> {
|
|
104
|
+
return await ctx.runMutation(this.component.mutations.revokeByTag, args);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async rotate(
|
|
108
|
+
ctx: RunMutationCtx,
|
|
109
|
+
args: { keyId: string; gracePeriodMs?: number },
|
|
110
|
+
): Promise<RotateResult> {
|
|
111
|
+
const lookupPrefix = generateRandomHex(8);
|
|
112
|
+
const secretHex = generateRandomHex(64);
|
|
113
|
+
|
|
114
|
+
return await ctx.runMutation(this.component.mutations.rotate, {
|
|
115
|
+
keyId: args.keyId,
|
|
116
|
+
gracePeriodMs: args.gracePeriodMs,
|
|
117
|
+
lookupPrefix,
|
|
118
|
+
secretHex,
|
|
119
|
+
}) as RotateResult;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async list(
|
|
123
|
+
ctx: RunQueryCtx,
|
|
124
|
+
args: { ownerId: string; env?: string; status?: KeyStatus },
|
|
125
|
+
): Promise<KeyMetadata[]> {
|
|
126
|
+
return await ctx.runQuery(
|
|
127
|
+
this.component.queries.list,
|
|
128
|
+
args,
|
|
129
|
+
) as unknown as KeyMetadata[];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async listByTag(
|
|
133
|
+
ctx: RunQueryCtx,
|
|
134
|
+
args: { ownerId: string; tag: string },
|
|
135
|
+
): Promise<KeyMetadata[]> {
|
|
136
|
+
return await ctx.runQuery(
|
|
137
|
+
this.component.queries.listByTag,
|
|
138
|
+
args,
|
|
139
|
+
) as unknown as KeyMetadata[];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async update(
|
|
143
|
+
ctx: RunMutationCtx,
|
|
144
|
+
args: {
|
|
145
|
+
keyId: string;
|
|
146
|
+
name?: string;
|
|
147
|
+
scopes?: string[];
|
|
148
|
+
tags?: string[];
|
|
149
|
+
metadata?: Record<string, unknown>;
|
|
150
|
+
},
|
|
151
|
+
): Promise<void> {
|
|
152
|
+
await ctx.runMutation(this.component.mutations.update, {
|
|
153
|
+
keyId: args.keyId,
|
|
154
|
+
name: args.name,
|
|
155
|
+
scopes: args.scopes,
|
|
156
|
+
tags: args.tags,
|
|
157
|
+
metadata: args.metadata,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async disable(ctx: RunMutationCtx, args: { keyId: string }): Promise<void> {
|
|
162
|
+
await ctx.runMutation(this.component.mutations.disable, { keyId: args.keyId });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async enable(ctx: RunMutationCtx, args: { keyId: string }): Promise<void> {
|
|
166
|
+
await ctx.runMutation(this.component.mutations.enable, { keyId: args.keyId });
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
async getUsage(
|
|
170
|
+
ctx: RunQueryCtx,
|
|
171
|
+
args: { keyId: string; period?: { start: number; end: number } },
|
|
172
|
+
): Promise<UsageStats> {
|
|
173
|
+
return await ctx.runQuery(this.component.queries.getUsage, {
|
|
174
|
+
keyId: args.keyId,
|
|
175
|
+
period: args.period,
|
|
176
|
+
}) as UsageStats;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async configure(
|
|
180
|
+
ctx: RunMutationCtx,
|
|
181
|
+
args: { cleanupIntervalMs?: number; defaultExpiryMs?: number },
|
|
182
|
+
): Promise<void> {
|
|
183
|
+
await ctx.runMutation(this.component.mutations.configure, args);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { KeyType, KeyStatus, EventType } from "../shared.js";
|
|
2
|
+
|
|
3
|
+
export type { KeyType, KeyStatus, EventType };
|
|
4
|
+
|
|
5
|
+
export interface CreateKeyOptions {
|
|
6
|
+
name: string;
|
|
7
|
+
ownerId: string;
|
|
8
|
+
type?: KeyType;
|
|
9
|
+
scopes?: string[];
|
|
10
|
+
tags?: string[];
|
|
11
|
+
env?: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
remaining?: number;
|
|
14
|
+
expiresAt?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface CreateKeyResult {
|
|
18
|
+
keyId: string;
|
|
19
|
+
key: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ValidationSuccess {
|
|
23
|
+
valid: true;
|
|
24
|
+
keyId: string;
|
|
25
|
+
ownerId: string;
|
|
26
|
+
type: KeyType;
|
|
27
|
+
env: string;
|
|
28
|
+
scopes: string[];
|
|
29
|
+
tags: string[];
|
|
30
|
+
metadata?: Record<string, unknown>;
|
|
31
|
+
remaining?: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ValidationFailure {
|
|
35
|
+
valid: false;
|
|
36
|
+
reason: string;
|
|
37
|
+
retryAfter?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type ValidationResult = ValidationSuccess | ValidationFailure;
|
|
41
|
+
|
|
42
|
+
export interface KeyMetadata {
|
|
43
|
+
keyId: string;
|
|
44
|
+
name: string;
|
|
45
|
+
lookupPrefix: string;
|
|
46
|
+
type: KeyType;
|
|
47
|
+
env: string;
|
|
48
|
+
scopes: string[];
|
|
49
|
+
tags: string[];
|
|
50
|
+
status: KeyStatus;
|
|
51
|
+
metadata?: Record<string, unknown>;
|
|
52
|
+
remaining?: number;
|
|
53
|
+
expiresAt?: number;
|
|
54
|
+
createdAt: number;
|
|
55
|
+
lastUsedAt?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface UsageStats {
|
|
59
|
+
total: number;
|
|
60
|
+
remaining?: number;
|
|
61
|
+
lastUsedAt?: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface RotateResult {
|
|
65
|
+
newKeyId: string;
|
|
66
|
+
newKey: string;
|
|
67
|
+
oldKeyExpiresAt: number;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface KeyEvent {
|
|
71
|
+
keyId: string;
|
|
72
|
+
ownerId: string;
|
|
73
|
+
eventType: EventType;
|
|
74
|
+
reason?: string;
|
|
75
|
+
metadata?: Record<string, unknown>;
|
|
76
|
+
timestamp: number;
|
|
77
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
|
|
11
|
+
import type * as mutations from "../mutations.js";
|
|
12
|
+
import type * as queries from "../queries.js";
|
|
13
|
+
|
|
14
|
+
import type {
|
|
15
|
+
ApiFromModules,
|
|
16
|
+
FilterApi,
|
|
17
|
+
FunctionReference,
|
|
18
|
+
} from "convex/server";
|
|
19
|
+
import { anyApi, componentsGeneric } from "convex/server";
|
|
20
|
+
|
|
21
|
+
const fullApi: ApiFromModules<{
|
|
22
|
+
mutations: typeof mutations;
|
|
23
|
+
queries: typeof queries;
|
|
24
|
+
}> = anyApi as any;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A utility for referencing Convex functions in your app's public API.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* ```js
|
|
31
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const api: FilterApi<
|
|
35
|
+
typeof fullApi,
|
|
36
|
+
FunctionReference<any, "public">
|
|
37
|
+
> = anyApi as any;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A utility for referencing Convex functions in your app's internal API.
|
|
41
|
+
*
|
|
42
|
+
* Usage:
|
|
43
|
+
* ```js
|
|
44
|
+
* const myFunctionReference = internal.myModule.myFunction;
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export const internal: FilterApi<
|
|
48
|
+
typeof fullApi,
|
|
49
|
+
FunctionReference<any, "internal">
|
|
50
|
+
> = anyApi as any;
|
|
51
|
+
|
|
52
|
+
export const components = componentsGeneric() as unknown as {
|
|
53
|
+
rateLimiter: import("@convex-dev/rate-limiter/_generated/component.js").ComponentApi<"rateLimiter">;
|
|
54
|
+
shardedCounter: import("@convex-dev/sharded-counter/_generated/component.js").ComponentApi<"shardedCounter">;
|
|
55
|
+
usageAggregate: import("@convex-dev/aggregate/_generated/component.js").ComponentApi<"usageAggregate">;
|
|
56
|
+
crons: import("@convex-dev/crons/_generated/component.js").ComponentApi<"crons">;
|
|
57
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated `ComponentApi` utility.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { FunctionReference } from "convex/server";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A utility for referencing a Convex component's exposed API.
|
|
15
|
+
*
|
|
16
|
+
* Useful when expecting a parameter like `components.myComponent`.
|
|
17
|
+
* Usage:
|
|
18
|
+
* ```ts
|
|
19
|
+
* async function myFunction(ctx: QueryCtx, component: ComponentApi) {
|
|
20
|
+
* return ctx.runQuery(component.someFile.someQuery, { ...args });
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
25
|
+
{
|
|
26
|
+
mutations: {
|
|
27
|
+
configure: FunctionReference<
|
|
28
|
+
"mutation",
|
|
29
|
+
"internal",
|
|
30
|
+
{ cleanupIntervalMs?: number; defaultExpiryMs?: number },
|
|
31
|
+
null,
|
|
32
|
+
Name
|
|
33
|
+
>;
|
|
34
|
+
create: FunctionReference<
|
|
35
|
+
"mutation",
|
|
36
|
+
"internal",
|
|
37
|
+
{
|
|
38
|
+
env?: string;
|
|
39
|
+
expiresAt?: number;
|
|
40
|
+
hash: string;
|
|
41
|
+
keyPrefix?: string;
|
|
42
|
+
lookupPrefix: string;
|
|
43
|
+
metadata?: any;
|
|
44
|
+
name: string;
|
|
45
|
+
ownerId: string;
|
|
46
|
+
remaining?: number;
|
|
47
|
+
scopes?: Array<string>;
|
|
48
|
+
secretHex: string;
|
|
49
|
+
tags?: Array<string>;
|
|
50
|
+
type?: "secret" | "publishable";
|
|
51
|
+
},
|
|
52
|
+
{ key: string; keyId: string },
|
|
53
|
+
Name
|
|
54
|
+
>;
|
|
55
|
+
disable: FunctionReference<
|
|
56
|
+
"mutation",
|
|
57
|
+
"internal",
|
|
58
|
+
{ keyId: string },
|
|
59
|
+
null,
|
|
60
|
+
Name
|
|
61
|
+
>;
|
|
62
|
+
enable: FunctionReference<
|
|
63
|
+
"mutation",
|
|
64
|
+
"internal",
|
|
65
|
+
{ keyId: string },
|
|
66
|
+
null,
|
|
67
|
+
Name
|
|
68
|
+
>;
|
|
69
|
+
revoke: FunctionReference<
|
|
70
|
+
"mutation",
|
|
71
|
+
"internal",
|
|
72
|
+
{ keyId: string },
|
|
73
|
+
null,
|
|
74
|
+
Name
|
|
75
|
+
>;
|
|
76
|
+
revokeByTag: FunctionReference<
|
|
77
|
+
"mutation",
|
|
78
|
+
"internal",
|
|
79
|
+
{ ownerId: string; tag: string },
|
|
80
|
+
{ revokedCount: number },
|
|
81
|
+
Name
|
|
82
|
+
>;
|
|
83
|
+
rotate: FunctionReference<
|
|
84
|
+
"mutation",
|
|
85
|
+
"internal",
|
|
86
|
+
{
|
|
87
|
+
gracePeriodMs?: number;
|
|
88
|
+
keyId: string;
|
|
89
|
+
lookupPrefix: string;
|
|
90
|
+
secretHex: string;
|
|
91
|
+
},
|
|
92
|
+
{ newKey: string; newKeyId: string; oldKeyExpiresAt: number },
|
|
93
|
+
Name
|
|
94
|
+
>;
|
|
95
|
+
update: FunctionReference<
|
|
96
|
+
"mutation",
|
|
97
|
+
"internal",
|
|
98
|
+
{
|
|
99
|
+
keyId: string;
|
|
100
|
+
metadata?: any;
|
|
101
|
+
name?: string;
|
|
102
|
+
scopes?: Array<string>;
|
|
103
|
+
tags?: Array<string>;
|
|
104
|
+
},
|
|
105
|
+
null,
|
|
106
|
+
Name
|
|
107
|
+
>;
|
|
108
|
+
validate: FunctionReference<
|
|
109
|
+
"mutation",
|
|
110
|
+
"internal",
|
|
111
|
+
{ key: string },
|
|
112
|
+
| {
|
|
113
|
+
env: string;
|
|
114
|
+
keyId: string;
|
|
115
|
+
metadata?: any;
|
|
116
|
+
ownerId: string;
|
|
117
|
+
remaining?: number;
|
|
118
|
+
scopes: Array<string>;
|
|
119
|
+
tags: Array<string>;
|
|
120
|
+
type: "secret" | "publishable";
|
|
121
|
+
valid: true;
|
|
122
|
+
}
|
|
123
|
+
| { reason: string; retryAfter?: number; valid: false },
|
|
124
|
+
Name
|
|
125
|
+
>;
|
|
126
|
+
};
|
|
127
|
+
queries: {
|
|
128
|
+
getUsage: FunctionReference<
|
|
129
|
+
"query",
|
|
130
|
+
"internal",
|
|
131
|
+
{ keyId: string; period?: { end: number; start: number } },
|
|
132
|
+
{ lastUsedAt?: number; remaining?: number; total: number },
|
|
133
|
+
Name
|
|
134
|
+
>;
|
|
135
|
+
list: FunctionReference<
|
|
136
|
+
"query",
|
|
137
|
+
"internal",
|
|
138
|
+
{
|
|
139
|
+
env?: string;
|
|
140
|
+
ownerId: string;
|
|
141
|
+
status?:
|
|
142
|
+
| "active"
|
|
143
|
+
| "disabled"
|
|
144
|
+
| "revoked"
|
|
145
|
+
| "rotating"
|
|
146
|
+
| "expired"
|
|
147
|
+
| "exhausted";
|
|
148
|
+
},
|
|
149
|
+
Array<{
|
|
150
|
+
createdAt: number;
|
|
151
|
+
env: string;
|
|
152
|
+
expiresAt?: number;
|
|
153
|
+
keyId: string;
|
|
154
|
+
lastUsedAt?: number;
|
|
155
|
+
lookupPrefix: string;
|
|
156
|
+
metadata?: any;
|
|
157
|
+
name: string;
|
|
158
|
+
remaining?: number;
|
|
159
|
+
scopes: Array<string>;
|
|
160
|
+
status:
|
|
161
|
+
| "active"
|
|
162
|
+
| "disabled"
|
|
163
|
+
| "revoked"
|
|
164
|
+
| "rotating"
|
|
165
|
+
| "expired"
|
|
166
|
+
| "exhausted";
|
|
167
|
+
tags: Array<string>;
|
|
168
|
+
type: "secret" | "publishable";
|
|
169
|
+
}>,
|
|
170
|
+
Name
|
|
171
|
+
>;
|
|
172
|
+
listByTag: FunctionReference<
|
|
173
|
+
"query",
|
|
174
|
+
"internal",
|
|
175
|
+
{ ownerId: string; tag: string },
|
|
176
|
+
Array<{
|
|
177
|
+
createdAt: number;
|
|
178
|
+
env: string;
|
|
179
|
+
expiresAt?: number;
|
|
180
|
+
keyId: string;
|
|
181
|
+
lastUsedAt?: number;
|
|
182
|
+
lookupPrefix: string;
|
|
183
|
+
metadata?: any;
|
|
184
|
+
name: string;
|
|
185
|
+
remaining?: number;
|
|
186
|
+
scopes: Array<string>;
|
|
187
|
+
status:
|
|
188
|
+
| "active"
|
|
189
|
+
| "disabled"
|
|
190
|
+
| "revoked"
|
|
191
|
+
| "rotating"
|
|
192
|
+
| "expired"
|
|
193
|
+
| "exhausted";
|
|
194
|
+
tags: Array<string>;
|
|
195
|
+
type: "secret" | "publishable";
|
|
196
|
+
}>,
|
|
197
|
+
Name
|
|
198
|
+
>;
|
|
199
|
+
};
|
|
200
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated data model types.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
DataModelFromSchemaDefinition,
|
|
13
|
+
DocumentByName,
|
|
14
|
+
TableNamesInDataModel,
|
|
15
|
+
SystemTableNames,
|
|
16
|
+
} from "convex/server";
|
|
17
|
+
import type { GenericId } from "convex/values";
|
|
18
|
+
import schema from "../schema.js";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The names of all of your Convex tables.
|
|
22
|
+
*/
|
|
23
|
+
export type TableNames = TableNamesInDataModel<DataModel>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The type of a document stored in Convex.
|
|
27
|
+
*
|
|
28
|
+
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
29
|
+
*/
|
|
30
|
+
export type Doc<TableName extends TableNames> = DocumentByName<
|
|
31
|
+
DataModel,
|
|
32
|
+
TableName
|
|
33
|
+
>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* An identifier for a document in Convex.
|
|
37
|
+
*
|
|
38
|
+
* Convex documents are uniquely identified by their `Id`, which is accessible
|
|
39
|
+
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
|
|
40
|
+
*
|
|
41
|
+
* Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
|
|
42
|
+
*
|
|
43
|
+
* IDs are just strings at runtime, but this type can be used to distinguish them from other
|
|
44
|
+
* strings when type checking.
|
|
45
|
+
*
|
|
46
|
+
* @typeParam TableName - A string literal type of the table name (like "users").
|
|
47
|
+
*/
|
|
48
|
+
export type Id<TableName extends TableNames | SystemTableNames> =
|
|
49
|
+
GenericId<TableName>;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* A type describing your Convex data model.
|
|
53
|
+
*
|
|
54
|
+
* This type includes information about what tables you have, the type of
|
|
55
|
+
* documents stored in those tables, and the indexes defined on them.
|
|
56
|
+
*
|
|
57
|
+
* This type is used to parameterize methods like `queryGeneric` and
|
|
58
|
+
* `mutationGeneric` to make them type-safe.
|
|
59
|
+
*/
|
|
60
|
+
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
|