@vllnt/convex-slugs 0.1.0-canary.2051641
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 +138 -0
- package/dist/client/index.d.ts +90 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +102 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +27 -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 +67 -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 +7 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/mutations.d.ts +102 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +191 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +44 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +75 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +36 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +27 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/validators.d.ts +30 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +25 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/react/index.d.ts +55 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +40 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared.d.ts +49 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +52 -0
- package/dist/shared.js.map +1 -0
- package/package.json +115 -0
- package/src/client/index.ts +213 -0
- package/src/client/types.ts +29 -0
- package/src/component/_generated/api.ts +54 -0
- package/src/component/_generated/component.ts +90 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +169 -0
- package/src/component/component.test.ts +115 -0
- package/src/component/convex.config.ts +9 -0
- package/src/component/mutations.ts +212 -0
- package/src/component/queries.ts +84 -0
- package/src/component/schema.ts +27 -0
- package/src/component/validators.ts +32 -0
- package/src/react/index.test.tsx +110 -0
- package/src/react/index.tsx +79 -0
- package/src/shared.ts +78 -0
- package/src/test.ts +12 -0
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
* Typesafe environment variables.
|
|
13
|
+
*
|
|
14
|
+
* This includes platform-provided env vars and any variables declared in
|
|
15
|
+
* `convex.config.ts`.
|
|
16
|
+
*/
|
|
17
|
+
type Env = {
|
|
18
|
+
readonly CONVEX_CLOUD_URL: string;
|
|
19
|
+
readonly CONVEX_SITE_URL: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Define a query in this Convex app's public API.
|
|
23
|
+
*
|
|
24
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
25
|
+
*
|
|
26
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
27
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
28
|
+
*/
|
|
29
|
+
export declare const query: QueryBuilder<DataModel, "public">;
|
|
30
|
+
/**
|
|
31
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
32
|
+
*
|
|
33
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
34
|
+
*
|
|
35
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
36
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
37
|
+
*/
|
|
38
|
+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
|
|
39
|
+
/**
|
|
40
|
+
* Define a mutation in this Convex app's public API.
|
|
41
|
+
*
|
|
42
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
43
|
+
*
|
|
44
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
45
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
46
|
+
*/
|
|
47
|
+
export declare const mutation: MutationBuilder<DataModel, "public">;
|
|
48
|
+
/**
|
|
49
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
50
|
+
*
|
|
51
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
52
|
+
*
|
|
53
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
54
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
55
|
+
*/
|
|
56
|
+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
|
|
57
|
+
/**
|
|
58
|
+
* Define an action in this Convex app's public API.
|
|
59
|
+
*
|
|
60
|
+
* An action is a function which can execute any JavaScript code, including non-deterministic
|
|
61
|
+
* code and code with side-effects, like calling third-party services.
|
|
62
|
+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
|
|
63
|
+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
|
|
64
|
+
*
|
|
65
|
+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
|
|
66
|
+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
|
|
67
|
+
*/
|
|
68
|
+
export declare const action: ActionBuilder<DataModel, "public">;
|
|
69
|
+
/**
|
|
70
|
+
* Define an action that is only accessible from other Convex functions (but not from the client).
|
|
71
|
+
*
|
|
72
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
|
|
73
|
+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
|
|
74
|
+
*/
|
|
75
|
+
export declare const internalAction: ActionBuilder<DataModel, "internal">;
|
|
76
|
+
/**
|
|
77
|
+
* Define an HTTP action.
|
|
78
|
+
*
|
|
79
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
80
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
81
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
82
|
+
*
|
|
83
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
84
|
+
* and a Fetch API `Request` object as its second.
|
|
85
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
86
|
+
*/
|
|
87
|
+
export declare const httpAction: HttpActionBuilder;
|
|
88
|
+
export declare const env: Env;
|
|
89
|
+
/**
|
|
90
|
+
* A set of services for use within Convex query functions.
|
|
91
|
+
*
|
|
92
|
+
* The query context is passed as the first argument to any Convex query
|
|
93
|
+
* function run on the server.
|
|
94
|
+
*
|
|
95
|
+
* If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
|
|
96
|
+
*/
|
|
97
|
+
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
98
|
+
/**
|
|
99
|
+
* A set of services for use within Convex mutation functions.
|
|
100
|
+
*
|
|
101
|
+
* The mutation context is passed as the first argument to any Convex mutation
|
|
102
|
+
* function run on the server.
|
|
103
|
+
*
|
|
104
|
+
* If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
|
|
105
|
+
*/
|
|
106
|
+
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
107
|
+
/**
|
|
108
|
+
* A set of services for use within Convex action functions.
|
|
109
|
+
*
|
|
110
|
+
* The action context is passed as the first argument to any Convex action
|
|
111
|
+
* function run on the server.
|
|
112
|
+
*/
|
|
113
|
+
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
114
|
+
/**
|
|
115
|
+
* An interface to read from the database within Convex query functions.
|
|
116
|
+
*
|
|
117
|
+
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
118
|
+
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
119
|
+
* building a query.
|
|
120
|
+
*/
|
|
121
|
+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
122
|
+
/**
|
|
123
|
+
* An interface to read from and write to the database within Convex mutation
|
|
124
|
+
* functions.
|
|
125
|
+
*
|
|
126
|
+
* Convex guarantees that all writes within a single mutation are
|
|
127
|
+
* executed atomically, so you never have to worry about partial writes leaving
|
|
128
|
+
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
129
|
+
* for the guarantees Convex provides your functions.
|
|
130
|
+
*/
|
|
131
|
+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
132
|
+
export {};
|
|
133
|
+
//# 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,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,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;AAE9D;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Generated utilities for implementing server-side Convex query and mutation functions.
|
|
4
|
+
*
|
|
5
|
+
* THIS CODE IS AUTOMATICALLY GENERATED.
|
|
6
|
+
*
|
|
7
|
+
* To regenerate, run `npx convex dev`.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { actionGeneric, httpActionGeneric, queryGeneric, mutationGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, } from "convex/server";
|
|
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 const query = queryGeneric;
|
|
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 const internalQuery = internalQueryGeneric;
|
|
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 const mutation = mutationGeneric;
|
|
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 const internalMutation = internalMutationGeneric;
|
|
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 const action = actionGeneric;
|
|
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 const internalAction = internalActionGeneric;
|
|
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 const httpAction = httpActionGeneric;
|
|
78
|
+
export const env = globalThis
|
|
79
|
+
.process.env;
|
|
80
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/component/_generated/server.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;;;;GAOG;AAaH,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAcvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,KAAK,GAAsC,YAAY,CAAC;AAErE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,oBAAoB,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAyC,eAAe,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC3B,uBAAuB,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,MAAM,GAAuC,aAAa,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GACzB,qBAAqB,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,UAAU,GAAsB,iBAAiB,CAAC;AAC/D,MAAM,CAAC,MAAM,GAAG,GAAS,UAAmD;KACzE,OAAO,CAAC,GAAG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.d.ts","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,SAAS,sDAA2B,CAAC;eAM5B,SAAS"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { defineComponent } from "convex/server";
|
|
2
|
+
const component = defineComponent("slugs");
|
|
3
|
+
// Nest official child components here, e.g.:
|
|
4
|
+
// import sharded from "@convex-dev/sharded-counter/convex.config";
|
|
5
|
+
// component.use(sharded);
|
|
6
|
+
export default component;
|
|
7
|
+
//# sourceMappingURL=convex.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convex.config.js","sourceRoot":"","sources":["../../src/component/convex.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AAE3C,6CAA6C;AAC7C,mEAAmE;AACnE,0BAA0B;AAE1B,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reserve `slug` for `resourceRef` within `scope`. The slug arrives already
|
|
3
|
+
* normalized by the client; `bounds` re-guards empty/oversized input at the
|
|
4
|
+
* trust boundary. If the slug was a live redirect target's source, that stale
|
|
5
|
+
* redirect row is removed (the slug is a live name again).
|
|
6
|
+
*
|
|
7
|
+
* @returns `{ ok: true }`, or `{ ok: false, reason }` where reason is
|
|
8
|
+
* `SLUG_INVALID` (empty/over length) or `SLUG_TAKEN` (already held in scope).
|
|
9
|
+
*/
|
|
10
|
+
export declare const reserve: import("convex/server").RegisteredMutation<"public", {
|
|
11
|
+
bounds: {
|
|
12
|
+
maxLength: number;
|
|
13
|
+
minLength: number;
|
|
14
|
+
};
|
|
15
|
+
resourceRef: string;
|
|
16
|
+
scope: string;
|
|
17
|
+
slug: string;
|
|
18
|
+
}, Promise<{
|
|
19
|
+
ok: boolean;
|
|
20
|
+
reason: "SLUG_INVALID";
|
|
21
|
+
} | {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
reason: "SLUG_TAKEN";
|
|
24
|
+
} | {
|
|
25
|
+
reason?: undefined;
|
|
26
|
+
ok: boolean;
|
|
27
|
+
}>>;
|
|
28
|
+
/**
|
|
29
|
+
* Release `slug` from `scope`. Idempotent — releasing an unheld slug is a no-op.
|
|
30
|
+
* Uses `.first()` so a stray duplicate row degrades to releasing one row instead
|
|
31
|
+
* of throwing. Also deletes all `redirects` rows whose `toSlug` equals the
|
|
32
|
+
* released slug so that `redirectFor(old)` returns `null` after release rather
|
|
33
|
+
* than pointing at a now-dead target.
|
|
34
|
+
*
|
|
35
|
+
* @returns `null`.
|
|
36
|
+
*/
|
|
37
|
+
export declare const release: import("convex/server").RegisteredMutation<"public", {
|
|
38
|
+
scope: string;
|
|
39
|
+
slug: string;
|
|
40
|
+
}, Promise<null>>;
|
|
41
|
+
/**
|
|
42
|
+
* Rename `fromSlug` to `toSlug` within `scope` and record a redirect. `toSlug`
|
|
43
|
+
* arrives normalized; `bounds` re-guards it. On success the slug row is patched,
|
|
44
|
+
* existing redirects that pointed at `fromSlug` are repointed to `toSlug` (so a
|
|
45
|
+
* chain A→B→C collapses to A→C), and a single redirect row per `(scope,
|
|
46
|
+
* fromSlug)` is upserted (patched if present, else inserted) to bound growth.
|
|
47
|
+
*
|
|
48
|
+
* Self-rename (`fromSlug === toSlug`) is rejected with `SLUG_TAKEN` before any
|
|
49
|
+
* DB read, preventing a self-loop redirect from being created.
|
|
50
|
+
*
|
|
51
|
+
* @returns `{ ok: true }`, or `{ ok: false, reason }` where reason is
|
|
52
|
+
* `SLUG_INVALID` (empty/over length `toSlug`), `SLUG_NOT_FOUND` (`fromSlug` not
|
|
53
|
+
* held), or `SLUG_TAKEN` (`toSlug` already held or equals `fromSlug`).
|
|
54
|
+
*/
|
|
55
|
+
export declare const rename: import("convex/server").RegisteredMutation<"public", {
|
|
56
|
+
bounds: {
|
|
57
|
+
maxLength: number;
|
|
58
|
+
minLength: number;
|
|
59
|
+
};
|
|
60
|
+
fromSlug: string;
|
|
61
|
+
scope: string;
|
|
62
|
+
toSlug: string;
|
|
63
|
+
}, Promise<{
|
|
64
|
+
ok: boolean;
|
|
65
|
+
reason: "SLUG_TAKEN";
|
|
66
|
+
} | {
|
|
67
|
+
ok: boolean;
|
|
68
|
+
reason: "SLUG_INVALID";
|
|
69
|
+
} | {
|
|
70
|
+
ok: boolean;
|
|
71
|
+
reason: "SLUG_NOT_FOUND";
|
|
72
|
+
} | {
|
|
73
|
+
reason?: undefined;
|
|
74
|
+
ok: boolean;
|
|
75
|
+
}>>;
|
|
76
|
+
/**
|
|
77
|
+
* Test/repair escape hatch: insert a `slugs` row with no uniqueness check.
|
|
78
|
+
* `internalMutation`, so it is never part of the public client API. Used to
|
|
79
|
+
* simulate a stray duplicate `(scope, slug)` row (Convex indexes are not unique
|
|
80
|
+
* constraints) and verify reads degrade via `.first()` instead of throwing.
|
|
81
|
+
*
|
|
82
|
+
* @returns `null`.
|
|
83
|
+
*/
|
|
84
|
+
export declare const insertRaw: import("convex/server").RegisteredMutation<"internal", {
|
|
85
|
+
resourceRef: string;
|
|
86
|
+
scope: string;
|
|
87
|
+
slug: string;
|
|
88
|
+
}, Promise<null>>;
|
|
89
|
+
/**
|
|
90
|
+
* Test/repair escape hatch: insert a `redirects` row directly. `internalMutation`,
|
|
91
|
+
* never part of the public client API. Used to seed a `(scope, fromSlug)`
|
|
92
|
+
* redirect that coexists with a live slug so `rename`'s upsert-patch branch (one
|
|
93
|
+
* row per source) is exercised.
|
|
94
|
+
*
|
|
95
|
+
* @returns `null`.
|
|
96
|
+
*/
|
|
97
|
+
export declare const insertRedirectRaw: import("convex/server").RegisteredMutation<"internal", {
|
|
98
|
+
fromSlug: string;
|
|
99
|
+
scope: string;
|
|
100
|
+
toSlug: string;
|
|
101
|
+
}, Promise<null>>;
|
|
102
|
+
//# sourceMappingURL=mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;YAUc,cAAc;;;YAYd,YAAY;;;;GAkB5C,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO;;;iBAwBlB,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;YAUe,YAAY;;;YAGZ,cAAc;;;YAYd,gBAAgB;;;;GAwChD,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS;;;;iBAWpB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;;;;iBAW5B,CAAC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { v } from "convex/values";
|
|
2
|
+
import { internalMutation, mutation } from "./_generated/server";
|
|
3
|
+
import { lengthBounds, reserveResult } from "./validators";
|
|
4
|
+
/**
|
|
5
|
+
* Reserve `slug` for `resourceRef` within `scope`. The slug arrives already
|
|
6
|
+
* normalized by the client; `bounds` re-guards empty/oversized input at the
|
|
7
|
+
* trust boundary. If the slug was a live redirect target's source, that stale
|
|
8
|
+
* redirect row is removed (the slug is a live name again).
|
|
9
|
+
*
|
|
10
|
+
* @returns `{ ok: true }`, or `{ ok: false, reason }` where reason is
|
|
11
|
+
* `SLUG_INVALID` (empty/over length) or `SLUG_TAKEN` (already held in scope).
|
|
12
|
+
*/
|
|
13
|
+
export const reserve = mutation({
|
|
14
|
+
args: {
|
|
15
|
+
scope: v.string(),
|
|
16
|
+
slug: v.string(),
|
|
17
|
+
resourceRef: v.string(),
|
|
18
|
+
bounds: lengthBounds,
|
|
19
|
+
},
|
|
20
|
+
returns: reserveResult,
|
|
21
|
+
handler: async (ctx, args) => {
|
|
22
|
+
if (args.slug.length < Math.max(1, args.bounds.minLength)) {
|
|
23
|
+
return { ok: false, reason: "SLUG_INVALID" };
|
|
24
|
+
}
|
|
25
|
+
if (args.slug.length > args.bounds.maxLength) {
|
|
26
|
+
return { ok: false, reason: "SLUG_INVALID" };
|
|
27
|
+
}
|
|
28
|
+
const existing = await ctx.db
|
|
29
|
+
.query("slugs")
|
|
30
|
+
.withIndex("by_scope_slug", (q) => q.eq("scope", args.scope).eq("slug", args.slug))
|
|
31
|
+
.first();
|
|
32
|
+
if (existing !== null) {
|
|
33
|
+
return { ok: false, reason: "SLUG_TAKEN" };
|
|
34
|
+
}
|
|
35
|
+
const dangling = await ctx.db
|
|
36
|
+
.query("redirects")
|
|
37
|
+
.withIndex("by_scope_from", (q) => q.eq("scope", args.scope).eq("fromSlug", args.slug))
|
|
38
|
+
.collect();
|
|
39
|
+
for (const row of dangling) {
|
|
40
|
+
await ctx.db.delete("redirects", row._id);
|
|
41
|
+
}
|
|
42
|
+
await ctx.db.insert("slugs", {
|
|
43
|
+
scope: args.scope,
|
|
44
|
+
slug: args.slug,
|
|
45
|
+
resourceRef: args.resourceRef,
|
|
46
|
+
});
|
|
47
|
+
return { ok: true };
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
/**
|
|
51
|
+
* Release `slug` from `scope`. Idempotent — releasing an unheld slug is a no-op.
|
|
52
|
+
* Uses `.first()` so a stray duplicate row degrades to releasing one row instead
|
|
53
|
+
* of throwing. Also deletes all `redirects` rows whose `toSlug` equals the
|
|
54
|
+
* released slug so that `redirectFor(old)` returns `null` after release rather
|
|
55
|
+
* than pointing at a now-dead target.
|
|
56
|
+
*
|
|
57
|
+
* @returns `null`.
|
|
58
|
+
*/
|
|
59
|
+
export const release = mutation({
|
|
60
|
+
args: { scope: v.string(), slug: v.string() },
|
|
61
|
+
returns: v.null(),
|
|
62
|
+
handler: async (ctx, args) => {
|
|
63
|
+
const existing = await ctx.db
|
|
64
|
+
.query("slugs")
|
|
65
|
+
.withIndex("by_scope_slug", (q) => q.eq("scope", args.scope).eq("slug", args.slug))
|
|
66
|
+
.first();
|
|
67
|
+
if (existing !== null) {
|
|
68
|
+
await ctx.db.delete("slugs", existing._id);
|
|
69
|
+
}
|
|
70
|
+
const inbound = await ctx.db
|
|
71
|
+
.query("redirects")
|
|
72
|
+
.withIndex("by_scope_to", (q) => q.eq("scope", args.scope).eq("toSlug", args.slug))
|
|
73
|
+
.collect();
|
|
74
|
+
for (const row of inbound) {
|
|
75
|
+
await ctx.db.delete("redirects", row._id);
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* Rename `fromSlug` to `toSlug` within `scope` and record a redirect. `toSlug`
|
|
82
|
+
* arrives normalized; `bounds` re-guards it. On success the slug row is patched,
|
|
83
|
+
* existing redirects that pointed at `fromSlug` are repointed to `toSlug` (so a
|
|
84
|
+
* chain A→B→C collapses to A→C), and a single redirect row per `(scope,
|
|
85
|
+
* fromSlug)` is upserted (patched if present, else inserted) to bound growth.
|
|
86
|
+
*
|
|
87
|
+
* Self-rename (`fromSlug === toSlug`) is rejected with `SLUG_TAKEN` before any
|
|
88
|
+
* DB read, preventing a self-loop redirect from being created.
|
|
89
|
+
*
|
|
90
|
+
* @returns `{ ok: true }`, or `{ ok: false, reason }` where reason is
|
|
91
|
+
* `SLUG_INVALID` (empty/over length `toSlug`), `SLUG_NOT_FOUND` (`fromSlug` not
|
|
92
|
+
* held), or `SLUG_TAKEN` (`toSlug` already held or equals `fromSlug`).
|
|
93
|
+
*/
|
|
94
|
+
export const rename = mutation({
|
|
95
|
+
args: {
|
|
96
|
+
scope: v.string(),
|
|
97
|
+
fromSlug: v.string(),
|
|
98
|
+
toSlug: v.string(),
|
|
99
|
+
bounds: lengthBounds,
|
|
100
|
+
},
|
|
101
|
+
returns: reserveResult,
|
|
102
|
+
handler: async (ctx, args) => {
|
|
103
|
+
if (args.fromSlug === args.toSlug) {
|
|
104
|
+
return { ok: false, reason: "SLUG_TAKEN" };
|
|
105
|
+
}
|
|
106
|
+
if (args.toSlug.length < Math.max(1, args.bounds.minLength)) {
|
|
107
|
+
return { ok: false, reason: "SLUG_INVALID" };
|
|
108
|
+
}
|
|
109
|
+
if (args.toSlug.length > args.bounds.maxLength) {
|
|
110
|
+
return { ok: false, reason: "SLUG_INVALID" };
|
|
111
|
+
}
|
|
112
|
+
const from = await ctx.db
|
|
113
|
+
.query("slugs")
|
|
114
|
+
.withIndex("by_scope_slug", (q) => q.eq("scope", args.scope).eq("slug", args.fromSlug))
|
|
115
|
+
.first();
|
|
116
|
+
if (from === null) {
|
|
117
|
+
return { ok: false, reason: "SLUG_NOT_FOUND" };
|
|
118
|
+
}
|
|
119
|
+
const taken = await ctx.db
|
|
120
|
+
.query("slugs")
|
|
121
|
+
.withIndex("by_scope_slug", (q) => q.eq("scope", args.scope).eq("slug", args.toSlug))
|
|
122
|
+
.first();
|
|
123
|
+
if (taken !== null) {
|
|
124
|
+
return { ok: false, reason: "SLUG_TAKEN" };
|
|
125
|
+
}
|
|
126
|
+
await ctx.db.patch("slugs", from._id, { slug: args.toSlug });
|
|
127
|
+
const inbound = await ctx.db
|
|
128
|
+
.query("redirects")
|
|
129
|
+
.withIndex("by_scope_to", (q) => q.eq("scope", args.scope).eq("toSlug", args.fromSlug))
|
|
130
|
+
.collect();
|
|
131
|
+
for (const row of inbound) {
|
|
132
|
+
await ctx.db.patch("redirects", row._id, { toSlug: args.toSlug });
|
|
133
|
+
}
|
|
134
|
+
const existing = await ctx.db
|
|
135
|
+
.query("redirects")
|
|
136
|
+
.withIndex("by_scope_from", (q) => q.eq("scope", args.scope).eq("fromSlug", args.fromSlug))
|
|
137
|
+
.first();
|
|
138
|
+
if (existing !== null) {
|
|
139
|
+
await ctx.db.patch("redirects", existing._id, { toSlug: args.toSlug });
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
await ctx.db.insert("redirects", {
|
|
143
|
+
scope: args.scope,
|
|
144
|
+
fromSlug: args.fromSlug,
|
|
145
|
+
toSlug: args.toSlug,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return { ok: true };
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
/**
|
|
152
|
+
* Test/repair escape hatch: insert a `slugs` row with no uniqueness check.
|
|
153
|
+
* `internalMutation`, so it is never part of the public client API. Used to
|
|
154
|
+
* simulate a stray duplicate `(scope, slug)` row (Convex indexes are not unique
|
|
155
|
+
* constraints) and verify reads degrade via `.first()` instead of throwing.
|
|
156
|
+
*
|
|
157
|
+
* @returns `null`.
|
|
158
|
+
*/
|
|
159
|
+
export const insertRaw = internalMutation({
|
|
160
|
+
args: { scope: v.string(), slug: v.string(), resourceRef: v.string() },
|
|
161
|
+
returns: v.null(),
|
|
162
|
+
handler: async (ctx, args) => {
|
|
163
|
+
await ctx.db.insert("slugs", {
|
|
164
|
+
scope: args.scope,
|
|
165
|
+
slug: args.slug,
|
|
166
|
+
resourceRef: args.resourceRef,
|
|
167
|
+
});
|
|
168
|
+
return null;
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
/**
|
|
172
|
+
* Test/repair escape hatch: insert a `redirects` row directly. `internalMutation`,
|
|
173
|
+
* never part of the public client API. Used to seed a `(scope, fromSlug)`
|
|
174
|
+
* redirect that coexists with a live slug so `rename`'s upsert-patch branch (one
|
|
175
|
+
* row per source) is exercised.
|
|
176
|
+
*
|
|
177
|
+
* @returns `null`.
|
|
178
|
+
*/
|
|
179
|
+
export const insertRedirectRaw = internalMutation({
|
|
180
|
+
args: { scope: v.string(), fromSlug: v.string(), toSlug: v.string() },
|
|
181
|
+
returns: v.null(),
|
|
182
|
+
handler: async (ctx, args) => {
|
|
183
|
+
await ctx.db.insert("redirects", {
|
|
184
|
+
scope: args.scope,
|
|
185
|
+
fromSlug: args.fromSlug,
|
|
186
|
+
toSlug: args.toSlug,
|
|
187
|
+
});
|
|
188
|
+
return null;
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
//# sourceMappingURL=mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AA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
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve `slug` to the `resourceRef` currently holding it within `scope`, or
|
|
3
|
+
* `null`. Uses `.first()` so a stray duplicate row degrades to one answer
|
|
4
|
+
* instead of throwing.
|
|
5
|
+
*
|
|
6
|
+
* @returns The held `resourceRef`, or `null` when the slug is free.
|
|
7
|
+
*/
|
|
8
|
+
export declare const resolve: import("convex/server").RegisteredQuery<"public", {
|
|
9
|
+
scope: string;
|
|
10
|
+
slug: string;
|
|
11
|
+
}, Promise<string | null>>;
|
|
12
|
+
/**
|
|
13
|
+
* Where a renamed `slug` now points within `scope`. After chain repointing this
|
|
14
|
+
* is always the live slug (A→B→C resolves A to C), or `null` when `slug` was
|
|
15
|
+
* never renamed away.
|
|
16
|
+
*
|
|
17
|
+
* @returns The current target slug, or `null`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const redirectFor: import("convex/server").RegisteredQuery<"public", {
|
|
20
|
+
scope: string;
|
|
21
|
+
slug: string;
|
|
22
|
+
}, Promise<string | null>>;
|
|
23
|
+
/**
|
|
24
|
+
* The slug currently held by `resourceRef` within `scope`. Assumes one slug per
|
|
25
|
+
* `(scope, resourceRef)` (the host reserves at most one); returns the first if
|
|
26
|
+
* the host violated that, or `null` when the resource holds none.
|
|
27
|
+
*
|
|
28
|
+
* @returns The held slug, or `null`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const slugForResource: import("convex/server").RegisteredQuery<"public", {
|
|
31
|
+
resourceRef: string;
|
|
32
|
+
scope: string;
|
|
33
|
+
}, Promise<string | null>>;
|
|
34
|
+
/**
|
|
35
|
+
* Test/inspection escape hatch: count `redirects` rows in `scope`. `internalQuery`,
|
|
36
|
+
* never part of the public client API. Used to assert the one-row-per-source
|
|
37
|
+
* bound (redirect chains repoint in place rather than accumulate).
|
|
38
|
+
*
|
|
39
|
+
* @returns The number of redirect rows in the scope.
|
|
40
|
+
*/
|
|
41
|
+
export declare const countRedirects: import("convex/server").RegisteredQuery<"internal", {
|
|
42
|
+
scope: string;
|
|
43
|
+
}, Promise<number>>;
|
|
44
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,eAAO,MAAM,OAAO;;;0BAYlB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;;;0BAYtB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;;;0BAY1B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;mBAUzB,CAAC"}
|