@vexcms/core 0.0.20 → 0.1.0-alpha.2
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 +202 -0
- package/dist/.build +1 -0
- package/dist/access/buildChecks.d.ts +58 -0
- package/dist/access/buildChecks.d.ts.map +1 -0
- package/dist/access/canAccessAdminPanel.d.ts +53 -0
- package/dist/access/canAccessAdminPanel.d.ts.map +1 -0
- package/dist/access/compileConstraints.d.ts +155 -0
- package/dist/access/compileConstraints.d.ts.map +1 -0
- package/dist/access/config.d.ts +62 -0
- package/dist/access/config.d.ts.map +1 -0
- package/dist/access/constants.d.ts +95 -0
- package/dist/access/constants.d.ts.map +1 -0
- package/dist/access/constraintTypes.d.ts +337 -0
- package/dist/access/constraintTypes.d.ts.map +1 -0
- package/dist/access/createAccessQueryBuilder.d.ts +59 -0
- package/dist/access/createAccessQueryBuilder.d.ts.map +1 -0
- package/dist/access/createFilterConstraintBuilder.d.ts +26 -0
- package/dist/access/createFilterConstraintBuilder.d.ts.map +1 -0
- package/dist/access/createIndexConstraintBuilder.d.ts +40 -0
- package/dist/access/createIndexConstraintBuilder.d.ts.map +1 -0
- package/dist/access/hasPermission.d.ts +85 -0
- package/dist/access/hasPermission.d.ts.map +1 -0
- package/dist/access/index.d.ts +13 -0
- package/dist/access/index.d.ts.map +1 -0
- package/dist/access/pickQueryIndex.d.ts +42 -0
- package/dist/access/pickQueryIndex.d.ts.map +1 -0
- package/dist/access/resolveAccessRule.d.ts +85 -0
- package/dist/access/resolveAccessRule.d.ts.map +1 -0
- package/dist/access/types.d.ts +738 -0
- package/dist/access/types.d.ts.map +1 -0
- package/dist/access/validateAccessConstraints.d.ts +57 -0
- package/dist/access/validateAccessConstraints.d.ts.map +1 -0
- package/dist/api/client.d.ts +20 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +117 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/convex.d.ts +296 -0
- package/dist/api/convex.d.ts.map +1 -0
- package/dist/api/create/client.d.ts +50 -0
- package/dist/api/create/client.d.ts.map +1 -0
- package/dist/api/create/server.d.ts +43 -0
- package/dist/api/create/server.d.ts.map +1 -0
- package/dist/api/depth.d.ts +39 -0
- package/dist/api/depth.d.ts.map +1 -0
- package/dist/api/find/client.d.ts +90 -0
- package/dist/api/find/client.d.ts.map +1 -0
- package/dist/api/find/server.d.ts +73 -0
- package/dist/api/find/server.d.ts.map +1 -0
- package/dist/api/get/client.d.ts +56 -0
- package/dist/api/get/client.d.ts.map +1 -0
- package/dist/api/get/server.d.ts +49 -0
- package/dist/api/get/server.d.ts.map +1 -0
- package/dist/api/globals/find.client.d.ts +20 -0
- package/dist/api/globals/find.client.d.ts.map +1 -0
- package/dist/api/globals/find.server.d.ts +29 -0
- package/dist/api/globals/find.server.d.ts.map +1 -0
- package/dist/api/globals/get.client.d.ts +46 -0
- package/dist/api/globals/get.client.d.ts.map +1 -0
- package/dist/api/globals/get.server.d.ts +55 -0
- package/dist/api/globals/get.server.d.ts.map +1 -0
- package/dist/api/globals/types.d.ts +65 -0
- package/dist/api/globals/types.d.ts.map +1 -0
- package/dist/api/globals/upsert.client.d.ts +24 -0
- package/dist/api/globals/upsert.client.d.ts.map +1 -0
- package/dist/api/globals/upsert.server.d.ts +47 -0
- package/dist/api/globals/upsert.server.d.ts.map +1 -0
- package/dist/api/populate.d.ts +23 -0
- package/dist/api/populate.d.ts.map +1 -0
- package/dist/api/remove/client.d.ts +58 -0
- package/dist/api/remove/client.d.ts.map +1 -0
- package/dist/api/remove/server.d.ts +65 -0
- package/dist/api/remove/server.d.ts.map +1 -0
- package/dist/api/search/client.d.ts +58 -0
- package/dist/api/search/client.d.ts.map +1 -0
- package/dist/api/search/server.d.ts +54 -0
- package/dist/api/search/server.d.ts.map +1 -0
- package/dist/api/server.d.ts +370 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +33 -0
- package/dist/api/server.js.map +1 -0
- package/dist/api/types.d.ts +525 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/update/client.d.ts +53 -0
- package/dist/api/update/client.d.ts.map +1 -0
- package/dist/api/update/server.d.ts +47 -0
- package/dist/api/update/server.d.ts.map +1 -0
- package/dist/api/utils.d.ts +57 -0
- package/dist/api/utils.d.ts.map +1 -0
- package/dist/auth/mergeCollections.d.ts +28 -0
- package/dist/auth/mergeCollections.d.ts.map +1 -0
- package/dist/auth/types.d.ts +84 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/chunk-2DU7JDEX.js +1877 -0
- package/dist/chunk-2DU7JDEX.js.map +1 -0
- package/dist/chunk-2IB2DCN7.js +75 -0
- package/dist/chunk-2IB2DCN7.js.map +1 -0
- package/dist/collections/config.d.ts +28 -0
- package/dist/collections/config.d.ts.map +1 -0
- package/dist/collections/constants.d.ts +27 -0
- package/dist/collections/constants.d.ts.map +1 -0
- package/dist/collections/index.d.ts +7 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/indexFields.d.ts +20 -0
- package/dist/collections/indexFields.d.ts.map +1 -0
- package/dist/collections/interfaceGen.d.ts +59 -0
- package/dist/collections/interfaceGen.d.ts.map +1 -0
- package/dist/collections/internal/index.d.ts +2 -0
- package/dist/collections/internal/index.d.ts.map +1 -0
- package/dist/collections/types.d.ts +282 -0
- package/dist/collections/types.d.ts.map +1 -0
- package/dist/collections/utils.d.ts +71 -0
- package/dist/collections/utils.d.ts.map +1 -0
- package/dist/collections/validator.d.ts +73 -0
- package/dist/collections/validator.d.ts.map +1 -0
- package/dist/config/config.d.ts +43 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/sanitizeConfig.d.ts +82 -0
- package/dist/config/sanitizeConfig.d.ts.map +1 -0
- package/dist/config/types.d.ts +316 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/fields/array/config.d.ts +57 -0
- package/dist/fields/array/config.d.ts.map +1 -0
- package/dist/fields/array/index.d.ts +5 -0
- package/dist/fields/array/index.d.ts.map +1 -0
- package/dist/fields/array/inputSchema.d.ts +32 -0
- package/dist/fields/array/inputSchema.d.ts.map +1 -0
- package/dist/fields/array/types.d.ts +127 -0
- package/dist/fields/array/types.d.ts.map +1 -0
- package/dist/fields/array/validator.d.ts +30 -0
- package/dist/fields/array/validator.d.ts.map +1 -0
- package/dist/fields/baseTypes.d.ts +251 -0
- package/dist/fields/baseTypes.d.ts.map +1 -0
- package/dist/fields/blocks/config.d.ts +63 -0
- package/dist/fields/blocks/config.d.ts.map +1 -0
- package/dist/fields/blocks/index.d.ts +5 -0
- package/dist/fields/blocks/index.d.ts.map +1 -0
- package/dist/fields/blocks/inputSchema.d.ts +22 -0
- package/dist/fields/blocks/inputSchema.d.ts.map +1 -0
- package/dist/fields/blocks/types.d.ts +253 -0
- package/dist/fields/blocks/types.d.ts.map +1 -0
- package/dist/fields/blocks/validator.d.ts +32 -0
- package/dist/fields/blocks/validator.d.ts.map +1 -0
- package/dist/fields/checkbox/config.d.ts +46 -0
- package/dist/fields/checkbox/config.d.ts.map +1 -0
- package/dist/fields/checkbox/index.d.ts +5 -0
- package/dist/fields/checkbox/index.d.ts.map +1 -0
- package/dist/fields/checkbox/inputSchema.d.ts +27 -0
- package/dist/fields/checkbox/inputSchema.d.ts.map +1 -0
- package/dist/fields/checkbox/types.d.ts +67 -0
- package/dist/fields/checkbox/types.d.ts.map +1 -0
- package/dist/fields/checkbox/validator.d.ts +34 -0
- package/dist/fields/checkbox/validator.d.ts.map +1 -0
- package/dist/fields/color/config.d.ts +49 -0
- package/dist/fields/color/config.d.ts.map +1 -0
- package/dist/fields/color/convert.d.ts +72 -0
- package/dist/fields/color/convert.d.ts.map +1 -0
- package/dist/fields/color/formats.d.ts +38 -0
- package/dist/fields/color/formats.d.ts.map +1 -0
- package/dist/fields/color/index.d.ts +8 -0
- package/dist/fields/color/index.d.ts.map +1 -0
- package/dist/fields/color/inputSchema.d.ts +29 -0
- package/dist/fields/color/inputSchema.d.ts.map +1 -0
- package/dist/fields/color/types.d.ts +100 -0
- package/dist/fields/color/types.d.ts.map +1 -0
- package/dist/fields/color/utils.d.ts +100 -0
- package/dist/fields/color/utils.d.ts.map +1 -0
- package/dist/fields/color/validator.d.ts +27 -0
- package/dist/fields/color/validator.d.ts.map +1 -0
- package/dist/fields/constants.d.ts +108 -0
- package/dist/fields/constants.d.ts.map +1 -0
- package/dist/fields/date/config.d.ts +57 -0
- package/dist/fields/date/config.d.ts.map +1 -0
- package/dist/fields/date/index.d.ts +5 -0
- package/dist/fields/date/index.d.ts.map +1 -0
- package/dist/fields/date/inputSchema.d.ts +29 -0
- package/dist/fields/date/inputSchema.d.ts.map +1 -0
- package/dist/fields/date/types.d.ts +147 -0
- package/dist/fields/date/types.d.ts.map +1 -0
- package/dist/fields/date/validator.d.ts +34 -0
- package/dist/fields/date/validator.d.ts.map +1 -0
- package/dist/fields/group/config.d.ts +47 -0
- package/dist/fields/group/config.d.ts.map +1 -0
- package/dist/fields/group/index.d.ts +5 -0
- package/dist/fields/group/index.d.ts.map +1 -0
- package/dist/fields/group/inputSchema.d.ts +27 -0
- package/dist/fields/group/inputSchema.d.ts.map +1 -0
- package/dist/fields/group/types.d.ts +105 -0
- package/dist/fields/group/types.d.ts.map +1 -0
- package/dist/fields/group/validator.d.ts +41 -0
- package/dist/fields/group/validator.d.ts.map +1 -0
- package/dist/fields/index.d.ts +20 -0
- package/dist/fields/index.d.ts.map +1 -0
- package/dist/fields/inputSchemas/index.d.ts +23 -0
- package/dist/fields/inputSchemas/index.d.ts.map +1 -0
- package/dist/fields/inputSchemas/utils.d.ts +25 -0
- package/dist/fields/inputSchemas/utils.d.ts.map +1 -0
- package/dist/fields/interfaceGen.d.ts +15 -0
- package/dist/fields/interfaceGen.d.ts.map +1 -0
- package/dist/fields/number/config.d.ts +48 -0
- package/dist/fields/number/config.d.ts.map +1 -0
- package/dist/fields/number/index.d.ts +5 -0
- package/dist/fields/number/index.d.ts.map +1 -0
- package/dist/fields/number/inputSchema.d.ts +23 -0
- package/dist/fields/number/inputSchema.d.ts.map +1 -0
- package/dist/fields/number/types.d.ts +100 -0
- package/dist/fields/number/types.d.ts.map +1 -0
- package/dist/fields/number/validator.d.ts +39 -0
- package/dist/fields/number/validator.d.ts.map +1 -0
- package/dist/fields/relationship/config.d.ts +45 -0
- package/dist/fields/relationship/config.d.ts.map +1 -0
- package/dist/fields/relationship/index.d.ts +5 -0
- package/dist/fields/relationship/index.d.ts.map +1 -0
- package/dist/fields/relationship/inputSchema.d.ts +31 -0
- package/dist/fields/relationship/inputSchema.d.ts.map +1 -0
- package/dist/fields/relationship/types.d.ts +126 -0
- package/dist/fields/relationship/types.d.ts.map +1 -0
- package/dist/fields/relationship/validator.d.ts +27 -0
- package/dist/fields/relationship/validator.d.ts.map +1 -0
- package/dist/fields/select/config.d.ts +59 -0
- package/dist/fields/select/config.d.ts.map +1 -0
- package/dist/fields/select/index.d.ts +5 -0
- package/dist/fields/select/index.d.ts.map +1 -0
- package/dist/fields/select/inputSchema.d.ts +28 -0
- package/dist/fields/select/inputSchema.d.ts.map +1 -0
- package/dist/fields/select/types.d.ts +89 -0
- package/dist/fields/select/types.d.ts.map +1 -0
- package/dist/fields/select/validator.d.ts +31 -0
- package/dist/fields/select/validator.d.ts.map +1 -0
- package/dist/fields/text/config.d.ts +48 -0
- package/dist/fields/text/config.d.ts.map +1 -0
- package/dist/fields/text/index.d.ts +5 -0
- package/dist/fields/text/index.d.ts.map +1 -0
- package/dist/fields/text/inputSchema.d.ts +24 -0
- package/dist/fields/text/inputSchema.d.ts.map +1 -0
- package/dist/fields/text/types.d.ts +132 -0
- package/dist/fields/text/types.d.ts.map +1 -0
- package/dist/fields/text/validator.d.ts +39 -0
- package/dist/fields/text/validator.d.ts.map +1 -0
- package/dist/fields/types.d.ts +135 -0
- package/dist/fields/types.d.ts.map +1 -0
- package/dist/fields/upload/config.d.ts +24 -0
- package/dist/fields/upload/config.d.ts.map +1 -0
- package/dist/fields/upload/index.d.ts +5 -0
- package/dist/fields/upload/index.d.ts.map +1 -0
- package/dist/fields/upload/inputSchema.d.ts +17 -0
- package/dist/fields/upload/inputSchema.d.ts.map +1 -0
- package/dist/fields/upload/types.d.ts +78 -0
- package/dist/fields/upload/types.d.ts.map +1 -0
- package/dist/fields/upload/validator.d.ts +16 -0
- package/dist/fields/upload/validator.d.ts.map +1 -0
- package/dist/fields/url/config.d.ts +49 -0
- package/dist/fields/url/config.d.ts.map +1 -0
- package/dist/fields/url/index.d.ts +5 -0
- package/dist/fields/url/index.d.ts.map +1 -0
- package/dist/fields/url/inputSchema.d.ts +31 -0
- package/dist/fields/url/inputSchema.d.ts.map +1 -0
- package/dist/fields/url/types.d.ts +70 -0
- package/dist/fields/url/types.d.ts.map +1 -0
- package/dist/fields/url/validator.d.ts +37 -0
- package/dist/fields/url/validator.d.ts.map +1 -0
- package/dist/fields/utils.d.ts +47 -0
- package/dist/fields/utils.d.ts.map +1 -0
- package/dist/fields/validators/index.d.ts +23 -0
- package/dist/fields/validators/index.d.ts.map +1 -0
- package/dist/fields/validators/utils.d.ts +24 -0
- package/dist/fields/validators/utils.d.ts.map +1 -0
- package/dist/framework.d.ts +227 -0
- package/dist/framework.d.ts.map +1 -0
- package/dist/globals/config/config.d.ts +1 -0
- package/dist/globals/config/config.d.ts.map +1 -0
- package/dist/globals/config/types.d.ts +1 -0
- package/dist/globals/config/types.d.ts.map +1 -0
- package/dist/globals/config.d.ts +47 -0
- package/dist/globals/config.d.ts.map +1 -0
- package/dist/globals/index.d.ts +5 -0
- package/dist/globals/index.d.ts.map +1 -0
- package/dist/globals/interfaceGen.d.ts +33 -0
- package/dist/globals/interfaceGen.d.ts.map +1 -0
- package/dist/globals/types.d.ts +175 -0
- package/dist/globals/types.d.ts.map +1 -0
- package/dist/globals/utils.d.ts +37 -0
- package/dist/globals/utils.d.ts.map +1 -0
- package/dist/index.d.ts +15 -3165
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2101 -3475
- package/dist/index.js.map +1 -1
- package/dist/media/api/index.d.ts +5 -0
- package/dist/media/api/index.d.ts.map +1 -0
- package/dist/media/api/mutations.d.ts +76 -0
- package/dist/media/api/mutations.d.ts.map +1 -0
- package/dist/media/api/queries.d.ts +28 -0
- package/dist/media/api/queries.d.ts.map +1 -0
- package/dist/media/api/server.d.ts +68 -0
- package/dist/media/api/server.d.ts.map +1 -0
- package/dist/media/api/types.d.ts +171 -0
- package/dist/media/api/types.d.ts.map +1 -0
- package/dist/media/config.d.ts +25 -0
- package/dist/media/config.d.ts.map +1 -0
- package/dist/media/index.d.ts +6 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/types.d.ts +332 -0
- package/dist/media/types.d.ts.map +1 -0
- package/dist/media/utils.d.ts +35 -0
- package/dist/media/utils.d.ts.map +1 -0
- package/dist/media/validators.d.ts +61 -0
- package/dist/media/validators.d.ts.map +1 -0
- package/dist/schema/generateVexSchema.d.ts +36 -0
- package/dist/schema/generateVexSchema.d.ts.map +1 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/migrate.d.ts +73 -0
- package/dist/schema/migrate.d.ts.map +1 -0
- package/dist/types/generateVexTypes.d.ts +41 -0
- package/dist/types/generateVexTypes.d.ts.map +1 -0
- package/dist/types/generated.d.ts +382 -0
- package/dist/types/generated.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils.d.ts +57 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +67 -24
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import type { UseSuspenseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
import type { FunctionReference, GenericDataModel, GenericMutationCtx, GenericQueryCtx, PaginationOptions as ConvexPaginationOptions, PaginationResult as ConvexPaginationResult } from "convex/server";
|
|
3
|
+
import { ADMIN_FIELDS, CheckboxFieldType, DateFieldType, NumberFieldType, SelectFieldType, TextFieldType, type AdminFieldType } from "../fields";
|
|
4
|
+
import type { CollectionsFieldTypeMap, CollectionSlug, CustomActionsBySlug, DocumentBySlug } from "../types/generated";
|
|
5
|
+
import { VexDocument } from "./convex";
|
|
6
|
+
import { VexConfig } from "../config";
|
|
7
|
+
import { QueryAction, DraftAction, CrudAction } from "../access";
|
|
8
|
+
/**
|
|
9
|
+
* Forces TypeScript to eagerly evaluate a mapped/conditional type into a
|
|
10
|
+
* concrete object shape rather than displaying the opaque alias. Without this,
|
|
11
|
+
* hover would show `Populated<"posts", { parent: true }>` instead of the
|
|
12
|
+
* expanded `{ _id: ...; parent: Post[]; ... }` form.
|
|
13
|
+
*/
|
|
14
|
+
export type Prettify<T> = {
|
|
15
|
+
[K in keyof T]: T[K];
|
|
16
|
+
} & {};
|
|
17
|
+
/**
|
|
18
|
+
* Per-call access options. Server-side only — NEVER accept these from a registered
|
|
19
|
+
* Convex function's `args`: an action no role declares falls through to
|
|
20
|
+
* `defaultPermissionMode` (default `allow`), so a client-chosen action reads anything.
|
|
21
|
+
*
|
|
22
|
+
* @typeParam A - Action union accepted for this call shape.
|
|
23
|
+
*/
|
|
24
|
+
export interface AccessCallOptions<A extends string = string> {
|
|
25
|
+
/**
|
|
26
|
+
* Permission action to check instead of the function's natural verb. Use for custom
|
|
27
|
+
* actions (`listFeatured`) and for draft reads (`readDrafts`).
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue the function's natural verb (`read`, `create`, `update`, `delete`)
|
|
30
|
+
*/
|
|
31
|
+
action?: A;
|
|
32
|
+
/**
|
|
33
|
+
* Skip RBAC for this call entirely. Also skips `getAuth`, so a public read costs no
|
|
34
|
+
* session lookup.
|
|
35
|
+
*
|
|
36
|
+
* @defaultValue false
|
|
37
|
+
*/
|
|
38
|
+
bypass?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Actions a query-shaped call may check. `(string & {})` keeps literal autocomplete.
|
|
42
|
+
*
|
|
43
|
+
* NOT `| DraftAction`: `QueryAction` already carries `readDrafts` (the only
|
|
44
|
+
* query-shaped draft verb), so adding the full draft union would offer
|
|
45
|
+
* `saveDraft`/`publish`/`unpublish` - mutation verbs - in every query position.
|
|
46
|
+
*/
|
|
47
|
+
export type QueryCallAction = QueryAction | (string & {});
|
|
48
|
+
/** Actions a mutation-shaped call may check. The draft verbs minus `readDrafts`. */
|
|
49
|
+
export type MutationCallAction = CrudAction | Exclude<DraftAction, QueryAction> | (string & {});
|
|
50
|
+
/** Custom actions of one kind declared for slug `S` in the generated registry. @internal */
|
|
51
|
+
type CustomCallActionsFor<S extends string, K extends "query" | "mutation"> = S extends keyof CustomActionsBySlug ? CustomActionsBySlug[S] extends Record<K, infer A extends string> ? A : never : never;
|
|
52
|
+
/**
|
|
53
|
+
* Actions a query-shaped call on collection `S` may check.
|
|
54
|
+
*
|
|
55
|
+
* Pre-generation the registry is `{}`, so this collapses to {@link QueryCallAction} —
|
|
56
|
+
* arbitrary strings stay accepted, which is what lets core's own tests exercise custom
|
|
57
|
+
* actions against an unaugmented registry. Post-generation the `(string & {})` arm is
|
|
58
|
+
* REPLACED by the slug's declared union: a custom verb autocompletes exactly where it
|
|
59
|
+
* is declared and is a compile error everywhere else.
|
|
60
|
+
*/
|
|
61
|
+
export type QueryCallActionFor<S extends string> = [keyof CustomActionsBySlug] extends [never] ? QueryCallAction : QueryAction | CustomCallActionsFor<S, "query">;
|
|
62
|
+
/** Mutation-shaped counterpart of {@link QueryCallActionFor}. */
|
|
63
|
+
export type MutationCallActionFor<S extends string> = [keyof CustomActionsBySlug] extends [never] ? MutationCallAction : CrudAction | Exclude<DraftAction, QueryAction> | CustomCallActionsFor<S, "mutation">;
|
|
64
|
+
/**
|
|
65
|
+
* Base shape for client-side args of a `vex.*` query function.
|
|
66
|
+
*
|
|
67
|
+
* Carries the `ctx?: never` discriminator (forbids passing a Convex query
|
|
68
|
+
* context) and the `populate` field, since every query function that returns
|
|
69
|
+
* documents supports relationship population (the only outlier is `count`,
|
|
70
|
+
* which returns a number and overrides `populate?: never`).
|
|
71
|
+
*
|
|
72
|
+
* Function-specific args interfaces extend this and add their own per-function
|
|
73
|
+
* fields. `limit` stays per-function because it doesn't apply to single-doc
|
|
74
|
+
* queries (`get`) or scalar queries (`count`).
|
|
75
|
+
*
|
|
76
|
+
* @typeParam TCollectionSlug - The collection slug; used to narrow `populate` keys via
|
|
77
|
+
* `RelationshipKeysOf<TCollectionSlug>`. Defaults to the full `CollectionSlug` union.
|
|
78
|
+
* @typeParam TPopulate - The populate object. Defaults to
|
|
79
|
+
* `Record<string, never>` (no relationships populated).
|
|
80
|
+
*
|
|
81
|
+
* @example Inheritance pattern
|
|
82
|
+
* ```ts
|
|
83
|
+
* // find — adds slug + limit; populate inherited
|
|
84
|
+
* interface FindClientArgs<TCollectionSlug, TPopulate>
|
|
85
|
+
* extends GenericQueryClientParams<TCollectionSlug, TPopulate> {
|
|
86
|
+
* slug: TCollectionSlug;
|
|
87
|
+
* limit?: number;
|
|
88
|
+
* }
|
|
89
|
+
*
|
|
90
|
+
* // get — adds id; populate inherited; no limit (single-doc)
|
|
91
|
+
* interface GetClientArgs<TCollectionSlug, TPopulate>
|
|
92
|
+
* extends GenericQueryClientParams<TCollectionSlug, TPopulate> {
|
|
93
|
+
* id: GenericId<TCollectionSlug>;
|
|
94
|
+
* }
|
|
95
|
+
*
|
|
96
|
+
* // search — adds slug + query + index fields + limit; populate inherited
|
|
97
|
+
* interface SearchClientArgs<TCollectionSlug, TPopulate>
|
|
98
|
+
* extends GenericQueryClientParams<TCollectionSlug, TPopulate> {
|
|
99
|
+
* slug: TCollectionSlug;
|
|
100
|
+
* query: string;
|
|
101
|
+
* searchIndexName: string;
|
|
102
|
+
* searchField: string;
|
|
103
|
+
* limit?: number;
|
|
104
|
+
* }
|
|
105
|
+
*
|
|
106
|
+
* // count — returns a number, has no docs to populate; overrides populate
|
|
107
|
+
* interface CountClientArgs<TCollectionSlug>
|
|
108
|
+
* extends GenericQueryClientParams<TCollectionSlug> {
|
|
109
|
+
* slug: TCollectionSlug;
|
|
110
|
+
* populate?: never;
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export interface GenericQueryClientParams<TCollectionSlug extends CollectionSlug = CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug> = Record<string, never>, D extends number = number> {
|
|
115
|
+
/** Discriminator: client args MUST NOT supply `auth`. */
|
|
116
|
+
auth?: never;
|
|
117
|
+
/** Discriminator: client args MUST NOT supply `ctx`. */
|
|
118
|
+
ctx?: never;
|
|
119
|
+
/** Recursive populate object, type-narrowed against `RelationshipKeysOf<TCollectionSlug>`. */
|
|
120
|
+
populate?: TPopulate;
|
|
121
|
+
/**
|
|
122
|
+
* Auto-populate all relationship fields to this many levels.
|
|
123
|
+
*
|
|
124
|
+
* Inferred as the literal `D` so a wrapper that threads `D` through to its
|
|
125
|
+
* return type narrows accordingly (`depth: 2` → depth-populated doc). A
|
|
126
|
+
* non-literal `number` degrades to `VexDocument` via {@link DepthPopulated}'s
|
|
127
|
+
* guard. `D` defaults to `number`, so wrappers that do not thread it keep the
|
|
128
|
+
* plain passthrough they had before.
|
|
129
|
+
*
|
|
130
|
+
* Use `populate` for documented consumer code; `depth` is internal.
|
|
131
|
+
*/
|
|
132
|
+
depth?: D;
|
|
133
|
+
/**
|
|
134
|
+
* When `true`, the wrapper passes convexQuery's `"skip"` sentinel instead of
|
|
135
|
+
* args, so the query is not issued. Use for conditional queries (e.g. an id
|
|
136
|
+
* that is not known yet) without violating the Rules of Hooks.
|
|
137
|
+
*/
|
|
138
|
+
skip?: boolean;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Base shape for server-side args of a `vex.*` query function.
|
|
142
|
+
*
|
|
143
|
+
* Carries `ctx`, `populate`, `depth`, and `config`. `populate` and `depth`
|
|
144
|
+
* are mutually exclusive — TypeScript enforces this via conditional constraints:
|
|
145
|
+
* `populate` becomes `never` when `D ≠ 0`; `depth` and `config` become `never`
|
|
146
|
+
* when `TPopulate` is non-empty. Passing both is a compile error at the call site.
|
|
147
|
+
*
|
|
148
|
+
* All three query functions (`find`, `get`, `search`) extend this base and
|
|
149
|
+
* inherit these constraints without re-declaring them.
|
|
150
|
+
*
|
|
151
|
+
* @typeParam DataModel - The Convex data model (inferred from `ctx`).
|
|
152
|
+
* @typeParam TCollectionSlug - The collection slug.
|
|
153
|
+
* @typeParam TPopulate - The populate object.
|
|
154
|
+
* @typeParam D - Depth literal (0 = no depth, default). Captured as a literal
|
|
155
|
+
* via `const D extends number = 0` on the implementing function.
|
|
156
|
+
*/
|
|
157
|
+
export interface GenericQueryServerParams<DataModel extends GenericDataModel = GenericDataModel, TCollectionSlug extends CollectionSlug = CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug> = Record<string, never>, D extends number = 0> {
|
|
158
|
+
/** Per-call access overrides. @see {@link AccessCallOptions} */
|
|
159
|
+
access?: AccessCallOptions<QueryCallActionFor<TCollectionSlug>>;
|
|
160
|
+
/** The auth config of the current user making the query.
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* { user: {...}, organization: {...} }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
auth?: VexApiAuth;
|
|
167
|
+
/** Discriminator: server args MUST supply a Convex query context. */
|
|
168
|
+
ctx: GenericQueryCtx<DataModel>;
|
|
169
|
+
/**
|
|
170
|
+
* Recursive populate object, type-narrowed against `RelationshipKeysOf<TCollectionSlug>`.
|
|
171
|
+
* Mutually exclusive with `depth` — becomes `never` when `D ≠ 0`.
|
|
172
|
+
*/
|
|
173
|
+
populate?: [D] extends [0] ? TPopulate : never;
|
|
174
|
+
/**
|
|
175
|
+
* Auto-populate all relationship fields to this many levels.
|
|
176
|
+
* Becomes `never` when `TPopulate` is non-empty. Use `populate` for
|
|
177
|
+
* consumer-facing code; this is an internal escape hatch for `CollectionListView`.
|
|
178
|
+
*/
|
|
179
|
+
depth?: [TPopulate] extends [Record<string, never>] ? D : never;
|
|
180
|
+
/**
|
|
181
|
+
* The resolved `VexConfig`. Required alongside `depth`; passed
|
|
182
|
+
* from the `queryApi` factory closure so the Convex handler has schema info.
|
|
183
|
+
*/
|
|
184
|
+
config?: [TPopulate] extends [Record<string, never>] ? VexConfig : never;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Base shape for client-side args of a `vex.*` mutation function. Mirrors
|
|
188
|
+
* {@link GenericQueryClientParams} but exists separately so query-only
|
|
189
|
+
* options (`populate`) don't leak into the mutation base, and so future
|
|
190
|
+
* mutation-only shared fields have a clear home.
|
|
191
|
+
*/
|
|
192
|
+
export interface GenericMutationClientParams {
|
|
193
|
+
/** Discriminator: client args MUST NOT supply `auth`. */
|
|
194
|
+
auth?: never;
|
|
195
|
+
/** Discriminator: client args MUST NOT supply `ctx`. */
|
|
196
|
+
ctx?: never;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Base shape for server-side args of a `vex.*` mutation function. Used inside
|
|
200
|
+
* custom Convex mutation handlers; receives the Convex mutation context
|
|
201
|
+
* (which is a superset of `GenericQueryCtx` — read+write vs. read-only).
|
|
202
|
+
*
|
|
203
|
+
* @typeParam DataModel - The Convex data model (inferred from `ctx`).
|
|
204
|
+
*/
|
|
205
|
+
export interface GenericMutationServerParams<DataModel extends GenericDataModel, TCollectionSlug extends CollectionSlug = CollectionSlug> {
|
|
206
|
+
/** Per-call access overrides. @see {@link AccessCallOptions} */
|
|
207
|
+
access?: AccessCallOptions<MutationCallActionFor<TCollectionSlug>>;
|
|
208
|
+
/** The auth config of the current user making the query.
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* { user: {...}, organization: {...} }
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
auth?: VexApiAuth;
|
|
215
|
+
/** Discriminator: server args MUST supply a Convex mutation context. */
|
|
216
|
+
ctx: GenericMutationCtx<DataModel>;
|
|
217
|
+
/**
|
|
218
|
+
* The resolved `VexConfig`. Required for rbac access control during operations
|
|
219
|
+
* from the `queryApi` factory closure so the Convex handler has schema info.
|
|
220
|
+
*/
|
|
221
|
+
config: VexConfig;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Returns the union of field keys on `TCollectionSlug` that have field type `TType`.
|
|
225
|
+
*
|
|
226
|
+
* Reads the `CollectionsFieldTypeMap` property on the augmented `GeneratedVexTypes`
|
|
227
|
+
* registry — populated by `vex generate` from the user's collection configs.
|
|
228
|
+
* Returns `never` when the slug has no fields of that type, or when the
|
|
229
|
+
* registry hasn't been augmented yet (fresh project).
|
|
230
|
+
*
|
|
231
|
+
* @typeParam TCollectionSlug - The collection slug.
|
|
232
|
+
* @typeParam TType - The field type literal (e.g., `"text"`, `"relationship"`).
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```ts
|
|
236
|
+
* type AuthorRelationships = FieldKeysOfType<"posts", "relationship">;
|
|
237
|
+
* // → "author" | "category"
|
|
238
|
+
*/
|
|
239
|
+
export type FieldKeysOfType<TCollectionSlug extends CollectionSlug, TType extends AdminFieldType> = TCollectionSlug extends keyof CollectionsFieldTypeMap ? TType extends keyof CollectionsFieldTypeMap[TCollectionSlug] ? CollectionsFieldTypeMap[TCollectionSlug][TType] & string : never : never;
|
|
240
|
+
/** Field keys on `TCollectionSlug` that are relationship fields. */
|
|
241
|
+
export type RelationshipKeysOf<TCollectionSlug extends CollectionSlug> = FieldKeysOfType<TCollectionSlug, typeof ADMIN_FIELDS.relationship.type>;
|
|
242
|
+
/** Field keys on `TCollectionSlug` that are text fields. */
|
|
243
|
+
export type TextKeysOf<TCollectionSlug extends CollectionSlug> = FieldKeysOfType<TCollectionSlug, typeof ADMIN_FIELDS.relationship.type>;
|
|
244
|
+
/**
|
|
245
|
+
* Field keys on `TCollectionSlug` that are sortable in list views (text, number, date,
|
|
246
|
+
* checkbox, select). Used by future `defaultSort` typing and the data-table
|
|
247
|
+
* column registry.
|
|
248
|
+
*/
|
|
249
|
+
export type SortableKeysOf<TCollectionSlug extends CollectionSlug> = FieldKeysOfType<TCollectionSlug, TextFieldType | NumberFieldType | DateFieldType | CheckboxFieldType | SelectFieldType>;
|
|
250
|
+
/**
|
|
251
|
+
* Resolves a relationship field's target slug.
|
|
252
|
+
*
|
|
253
|
+
* Reads the *resolved* `RelationshipField.collection.slug` from the
|
|
254
|
+
* `GeneratedVexTypes` document shape (the relationship field key on a doc
|
|
255
|
+
* stores the target slug as part of its branded `Id<TargetSlug>` type).
|
|
256
|
+
* Falls back to `CollectionSlug` if not resolvable.
|
|
257
|
+
*/
|
|
258
|
+
export type RelationshipTargetOf<TCollectionSlug extends CollectionSlug, TKey extends string> = TCollectionSlug extends keyof DocumentBySlug ? TKey extends keyof DocumentBySlug[TCollectionSlug] ? NonNullable<DocumentBySlug[TCollectionSlug][TKey]> extends ReadonlyArray<{
|
|
259
|
+
__tableName: infer T;
|
|
260
|
+
}> ? T extends CollectionSlug ? T : CollectionSlug : CollectionSlug : CollectionSlug : CollectionSlug;
|
|
261
|
+
/**
|
|
262
|
+
* Recursive populate options, type-restricted to relationship field keys per
|
|
263
|
+
* the augmented `CollectionsFieldTypeMap` registry.
|
|
264
|
+
*
|
|
265
|
+
* @typeParam TCollectionSlug - The collection slug to narrow relationship keys against.
|
|
266
|
+
* Defaults to the full `CollectionSlug` union for internal recursive use.
|
|
267
|
+
*/
|
|
268
|
+
export type PopulateShape<TCollectionSlug extends CollectionSlug = CollectionSlug> = {
|
|
269
|
+
[K in RelationshipKeysOf<TCollectionSlug>]?: true | {
|
|
270
|
+
populate: PopulateShape<RelationshipTargetOf<TCollectionSlug, K>>;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* Result type of a populated query — `Doc<TCollectionSlug>` with each key listed in
|
|
275
|
+
* `TPopulate` replaced from `Id<TargetSlug>[]` to `Doc<TargetSlug>[]`.
|
|
276
|
+
* Recurses if the populate value has a nested `populate` field (D12: unbounded
|
|
277
|
+
* nesting).
|
|
278
|
+
*
|
|
279
|
+
* Keys not in `TPopulate` keep their original `Id[]` type. Non-relationship
|
|
280
|
+
* keys are left untouched.
|
|
281
|
+
*/
|
|
282
|
+
export type Populated<TCollectionSlug extends CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug>> = TCollectionSlug extends keyof DocumentBySlug ? {
|
|
283
|
+
[K in keyof DocumentBySlug[TCollectionSlug]]: K extends keyof TPopulate ? K extends string ? RelationshipTargetOf<TCollectionSlug, K> extends infer Target ? Target extends CollectionSlug ? Target extends keyof DocumentBySlug ? TPopulate[K] extends {
|
|
284
|
+
populate: infer NestedPopulate;
|
|
285
|
+
} ? NestedPopulate extends PopulateShape<Target> ? Populated<Target, NestedPopulate>[] : DocumentBySlug[Target][] : DocumentBySlug[Target][] : DocumentBySlug[TCollectionSlug][K] : DocumentBySlug[TCollectionSlug][K] : DocumentBySlug[TCollectionSlug][K] : DocumentBySlug[TCollectionSlug][K] : DocumentBySlug[TCollectionSlug][K];
|
|
286
|
+
} : never;
|
|
287
|
+
/**
|
|
288
|
+
* Computes the equivalent `PopulateShape` for automatically populating all
|
|
289
|
+
* relationship fields on `TCollectionSlug` to `D` levels deep.
|
|
290
|
+
*
|
|
291
|
+
* This is the type-level counterpart of `buildDepthPopulate`. The computed
|
|
292
|
+
* shape is a valid `PopulateShape<TCollectionSlug>` and can be fed directly into
|
|
293
|
+
* `Populated<TCollectionSlug, DepthPopulate<TCollectionSlug, D>>`.
|
|
294
|
+
*
|
|
295
|
+
* **How the counter works:** `_Counter` is a tuple of `0`s whose `length`
|
|
296
|
+
* tracks how many levels have been descended. At the penultimate level
|
|
297
|
+
* (`[..._Counter, 0]["length"] extends D`) fields are emitted as `true`
|
|
298
|
+
* (populate, no further recursion). At intermediate levels they are emitted as
|
|
299
|
+
* `{ populate: DepthPopulate<Target, D, [..._Counter, 0]> }`.
|
|
300
|
+
*
|
|
301
|
+
* **Practical depth limit: 3.** TypeScript instantiation count grows
|
|
302
|
+
* exponentially with D × relationship-key-count-per-collection. D=1,2,3 is
|
|
303
|
+
* safe for typical VexCMS schemas; D≥4 may cause noticeable `tsc` slowdown.
|
|
304
|
+
* Runtime has no limit.
|
|
305
|
+
*
|
|
306
|
+
* @typeParam TCollectionSlug - The collection slug to start from.
|
|
307
|
+
* @typeParam D - The depth as a literal number (1, 2, or 3 recommended).
|
|
308
|
+
* @typeParam _Counter - Internal tuple counter — callers must not supply this.
|
|
309
|
+
*
|
|
310
|
+
* @example Resolved shape for depth 1 on posts with an author relationship
|
|
311
|
+
* ```ts
|
|
312
|
+
* // DepthPopulate<"posts", 1> → { author?: true }
|
|
313
|
+
* // Equivalent to writing `populate: { author: true }` explicitly
|
|
314
|
+
* ```
|
|
315
|
+
* @example Resolved shape for depth 2
|
|
316
|
+
* ```ts
|
|
317
|
+
* // DepthPopulate<"posts", 2> → { author?: { populate: { team?: true } } }
|
|
318
|
+
* // Equivalent to `populate: { author: { populate: { team: true } } }`
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
export type DepthPopulate<TCollectionSlug extends CollectionSlug, D extends number, _Counter extends 0[] = []> = _Counter["length"] extends D ? Record<string, never> : [..._Counter, 0]["length"] extends D ? {
|
|
322
|
+
[K in RelationshipKeysOf<TCollectionSlug>]?: true;
|
|
323
|
+
} : {
|
|
324
|
+
[K in RelationshipKeysOf<TCollectionSlug>]?: {
|
|
325
|
+
populate: DepthPopulate<RelationshipTargetOf<TCollectionSlug, K>, D, [..._Counter, 0]>;
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Return type of `find` / `get` / `search` when `depth` is provided instead
|
|
330
|
+
* of an explicit `populate` object.
|
|
331
|
+
*
|
|
332
|
+
* Delegates to `Populated<TCollectionSlug, DepthPopulate<TCollectionSlug, D>>` — the same type
|
|
333
|
+
* the explicit populate path produces — so the narrowed shape is identical to
|
|
334
|
+
* what you would get by writing all relationship keys by hand.
|
|
335
|
+
*
|
|
336
|
+
* **Non-literal fallback:** `number extends D` (i.e., `D` is not a literal)
|
|
337
|
+
* short-circuits to `VexDocument` to avoid evaluating an infinite recursive
|
|
338
|
+
* type. `depth` is only called internally with literal values (`1`), so this
|
|
339
|
+
* only fires when depth comes from a non-literal `number` variable.
|
|
340
|
+
*
|
|
341
|
+
* **`depth: 0`** (the default) returns raw un-populated docs — identical to
|
|
342
|
+
* omitting both `depth` and `populate`.
|
|
343
|
+
*
|
|
344
|
+
* @typeParam TCollectionSlug - The collection slug.
|
|
345
|
+
* @typeParam D - The depth literal.
|
|
346
|
+
*/
|
|
347
|
+
export type DepthPopulated<TCollectionSlug extends CollectionSlug, D extends number> = number extends D ? VexDocument : D extends 0 ? TCollectionSlug extends keyof DocumentBySlug ? DocumentBySlug[TCollectionSlug] : never : TCollectionSlug extends keyof DocumentBySlug ? Prettify<Populated<TCollectionSlug, DepthPopulate<TCollectionSlug, D>>> : never;
|
|
348
|
+
/**
|
|
349
|
+
* Tanstack-query options as produced by `convexQuery` for a non-`"skip"` call,
|
|
350
|
+
* with the result pinned to `TReturn` instead of the funcRef's baked type.
|
|
351
|
+
*
|
|
352
|
+
* Named deliberately: publishing this contract as `ReturnType<typeof
|
|
353
|
+
* convexQuery>` instantiates the adapter's generics at their constraints and
|
|
354
|
+
* collapses the query data to `any`.
|
|
355
|
+
*
|
|
356
|
+
* @typeParam TArgs - The endpoint's args shape.
|
|
357
|
+
* @typeParam TReturn - The narrowed return type for this call.
|
|
358
|
+
*/
|
|
359
|
+
export type VexQueryOptions<TArgs extends Record<string, unknown>, TReturn> = Pick<UseSuspenseQueryOptions<TReturn, Error, TReturn, [
|
|
360
|
+
"convexQuery",
|
|
361
|
+
FunctionReference<"query", "public", TArgs, TReturn>,
|
|
362
|
+
TArgs
|
|
363
|
+
]>, "queryKey" | "queryFn" | "staleTime">;
|
|
364
|
+
/**
|
|
365
|
+
* The per-document element type shared by `get`, `find`, and `search`:
|
|
366
|
+
*
|
|
367
|
+
* - No populate + `D = 0` → `DocumentBySlug[TCollectionSlug]` (raw doc).
|
|
368
|
+
* - No populate + `D > 0` → `DepthPopulated<TCollectionSlug, D>`.
|
|
369
|
+
* - With populate → `Prettify<Populated<TCollectionSlug, TPopulate>>`.
|
|
370
|
+
*
|
|
371
|
+
* Resolves to `never` when the slug is absent from the generated registry
|
|
372
|
+
* (pre-`vex generate`). Nullability is applied by the per-operation aliases.
|
|
373
|
+
*
|
|
374
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
375
|
+
* @typeParam TPopulate - Populate object.
|
|
376
|
+
* @typeParam D - Depth literal (0 = none).
|
|
377
|
+
*/
|
|
378
|
+
export type DocReturnItem<TCollectionSlug extends CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug>, D extends number> = [TPopulate] extends [Record<string, never>] ? [D] extends [0] ? TCollectionSlug extends keyof DocumentBySlug ? DocumentBySlug[TCollectionSlug] : never : DepthPopulated<TCollectionSlug, D> : TCollectionSlug extends keyof DocumentBySlug ? Prettify<Populated<TCollectionSlug, TPopulate>> : never;
|
|
379
|
+
/**
|
|
380
|
+
* Return type of `get` — a {@link DocReturnItem}, or `null` when no document
|
|
381
|
+
* matches the id. Shared by the server function and the client wrapper's query
|
|
382
|
+
* data so both narrow identically from the collection slug.
|
|
383
|
+
*
|
|
384
|
+
* The `[never]` guard keeps the unregistered-slug case as `never` rather than
|
|
385
|
+
* collapsing it to `null`.
|
|
386
|
+
*
|
|
387
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
388
|
+
* @typeParam TPopulate - Populate object.
|
|
389
|
+
* @typeParam D - Depth literal (0 = none).
|
|
390
|
+
*/
|
|
391
|
+
export type GetReturn<TCollectionSlug extends CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug>, D extends number = 0> = [DocReturnItem<TCollectionSlug, TPopulate, D>] extends [never] ? never : DocReturnItem<TCollectionSlug, TPopulate, D> | null;
|
|
392
|
+
/**
|
|
393
|
+
* Return type of `find` without `paginationOpts` — an array of
|
|
394
|
+
* {@link DocReturnItem}. Shared by the server function and the client wrapper's
|
|
395
|
+
* query data so both narrow identically from the collection slug.
|
|
396
|
+
*
|
|
397
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
398
|
+
* @typeParam TPopulate - Populate object.
|
|
399
|
+
* @typeParam D - Depth literal (0 = none).
|
|
400
|
+
*/
|
|
401
|
+
export type FindReturn<TCollectionSlug extends CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug>, D extends number = 0> = DocReturnItem<TCollectionSlug, TPopulate, D>[];
|
|
402
|
+
/**
|
|
403
|
+
* Return type of `find` with `paginationOpts` — a Convex `PaginationResult`
|
|
404
|
+
* whose `page` entries are {@link DocReturnItem}.
|
|
405
|
+
*
|
|
406
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
407
|
+
* @typeParam TPopulate - Populate object.
|
|
408
|
+
* @typeParam D - Depth literal (0 = none).
|
|
409
|
+
*/
|
|
410
|
+
export type FindReturnPaginated<TCollectionSlug extends CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug>, D extends number = 0> = PaginationResult<DocReturnItem<TCollectionSlug, TPopulate, D>>;
|
|
411
|
+
/**
|
|
412
|
+
* Return type of `search` without `paginationOpts`. Identical in shape to
|
|
413
|
+
* {@link FindReturn}; kept as a distinct name so each operation's contract can
|
|
414
|
+
* diverge without a breaking rename.
|
|
415
|
+
*
|
|
416
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
417
|
+
* @typeParam TPopulate - Populate object.
|
|
418
|
+
* @typeParam D - Depth literal (0 = none).
|
|
419
|
+
*/
|
|
420
|
+
export type SearchReturn<TCollectionSlug extends CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug>, D extends number = 0> = DocReturnItem<TCollectionSlug, TPopulate, D>[];
|
|
421
|
+
/**
|
|
422
|
+
* Return type of `search` with `paginationOpts`.
|
|
423
|
+
*
|
|
424
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
425
|
+
* @typeParam TPopulate - Populate object.
|
|
426
|
+
* @typeParam D - Depth literal (0 = none).
|
|
427
|
+
*/
|
|
428
|
+
export type SearchReturnPaginated<TCollectionSlug extends CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug>, D extends number = 0> = PaginationResult<DocReturnItem<TCollectionSlug, TPopulate, D>>;
|
|
429
|
+
/**
|
|
430
|
+
* Pagination options for Convex queries.
|
|
431
|
+
* Matches Convex's native `paginationOptsValidator` shape.
|
|
432
|
+
*/
|
|
433
|
+
/**
|
|
434
|
+
* Pagination options for Convex queries.
|
|
435
|
+
*
|
|
436
|
+
* Re-exported from `convex/server` for convenience. This is the exact type
|
|
437
|
+
* that Convex's `.paginate(opts)` API expects.
|
|
438
|
+
*
|
|
439
|
+
* @see https://docs.convex.dev/database/pagination
|
|
440
|
+
*/
|
|
441
|
+
export type PaginationOptions = ConvexPaginationOptions & {
|
|
442
|
+
/**
|
|
443
|
+
* Whether to include total document count in the response.
|
|
444
|
+
*
|
|
445
|
+
* Only runs on the first page (when cursor is null) to avoid wasteful re-counting.
|
|
446
|
+
* Counts all documents matching the current filters/search query.
|
|
447
|
+
*
|
|
448
|
+
* Returns `null` if the count exceeds Convex transaction limits (>32k documents).
|
|
449
|
+
*
|
|
450
|
+
* @default false
|
|
451
|
+
*/
|
|
452
|
+
totalDocs?: boolean;
|
|
453
|
+
};
|
|
454
|
+
/**
|
|
455
|
+
* Pagination result from Convex query.
|
|
456
|
+
*
|
|
457
|
+
* Re-exported from `convex/server`. Returned by queries using `.paginate(opts)`.
|
|
458
|
+
*
|
|
459
|
+
* Includes:
|
|
460
|
+
* - `page: T[]` — Current page of results
|
|
461
|
+
* - `isDone: boolean` — Whether this is the last page
|
|
462
|
+
* - `continueCursor: string` — Cursor to fetch next page
|
|
463
|
+
* - `splitCursor?: string | null` — Cursor to split large pages (optional)
|
|
464
|
+
* - `pageStatus?: "SplitRecommended" | "SplitRequired" | null` — Indicates when to split (optional)
|
|
465
|
+
*
|
|
466
|
+
* @see https://docs.convex.dev/database/pagination
|
|
467
|
+
*/
|
|
468
|
+
export type PaginationResult<T> = ConvexPaginationResult<T> & {
|
|
469
|
+
totalDocs?: number | null;
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* Client-side pagination state.
|
|
473
|
+
* Tracks cursor stack for forward/backward navigation.
|
|
474
|
+
*/
|
|
475
|
+
export interface PaginationState {
|
|
476
|
+
/** Current page number (1-based). */
|
|
477
|
+
currentPage: number;
|
|
478
|
+
/** Items per page. */
|
|
479
|
+
pageSize: number;
|
|
480
|
+
/** Stack of cursors for backward navigation. */
|
|
481
|
+
cursorStack: (string | null)[];
|
|
482
|
+
/** Current cursor (top of stack). */
|
|
483
|
+
cursor: string | null;
|
|
484
|
+
/** Whether there are more pages after current page. */
|
|
485
|
+
hasNextPage: boolean;
|
|
486
|
+
/** Whether there are previous pages. */
|
|
487
|
+
hasPreviousPage: boolean;
|
|
488
|
+
/** Total count of items (optional — requires separate count query). */
|
|
489
|
+
totalCount?: number;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Selection mode for data tables.
|
|
493
|
+
*/
|
|
494
|
+
export type SelectionMode = "none" | "page" | "all" | "inverse";
|
|
495
|
+
/**
|
|
496
|
+
* Selection state for bulk actions.
|
|
497
|
+
*/
|
|
498
|
+
export interface SelectionState {
|
|
499
|
+
/** Set of selected document IDs. */
|
|
500
|
+
selectedIds: Set<string>;
|
|
501
|
+
/** Current selection mode. */
|
|
502
|
+
mode: SelectionMode;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* The resolved caller identity RBAC guards check against. Returned by a
|
|
506
|
+
* user-supplied `getAuth` callback.
|
|
507
|
+
*
|
|
508
|
+
* @see {@link VexApiOptions} for where `getAuth` is configured.
|
|
509
|
+
*/
|
|
510
|
+
export type VexApiAuth = {
|
|
511
|
+
/**
|
|
512
|
+
* Passed as `hasPermission`'s `user` — shape is caller-defined. Must include
|
|
513
|
+
* whatever field `access.userRolesField` names (a role string or string[])
|
|
514
|
+
* for role resolution to succeed; a user object without it resolves to an
|
|
515
|
+
* empty role list and denies every check.
|
|
516
|
+
*/
|
|
517
|
+
user: Record<string, unknown> | null;
|
|
518
|
+
/**
|
|
519
|
+
* Passed as `hasPermission`'s `organization`. Shape is caller-defined; omit
|
|
520
|
+
* when the access config has no `orgCollectionSlug`.
|
|
521
|
+
*/
|
|
522
|
+
organization?: Record<string, unknown>;
|
|
523
|
+
};
|
|
524
|
+
export {};
|
|
525
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,IAAI,uBAAuB,EAC5C,gBAAgB,IAAI,sBAAsB,EAC3C,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,KAAK,cAAc,EACpB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,S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,EAAE,MAAM,CAAC;IACpB,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,WAAW,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;IAC/B,qCAAqC;IACrC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,uDAAuD;IACvD,WAAW,EAAE,OAAO,CAAC;IACrB,wCAAwC;IACxC,eAAe,EAAE,OAAO,CAAC;IACzB,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,MAAM,GACN,KAAK,GACL,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,8BAA8B;IAC9B,IAAI,EAAE,aAAa,CAAC;CACrB;AAQD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACrC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { GenericId } from "convex/values";
|
|
2
|
+
import type { CollectionSlug } from "../../types/generated";
|
|
3
|
+
import type { GenericMutationClientParams } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Client-side args for {@link update}.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { update, type UpdateClientArgs } from "@vexcms/core/client";
|
|
10
|
+
* import { useMutation } from "@tanstack/react-query";
|
|
11
|
+
*
|
|
12
|
+
* // Inside a React component:
|
|
13
|
+
* const { mutateAsync } = useMutation({ mutationFn: update() });
|
|
14
|
+
* await mutateAsync({ id: postId, data: { title: "Updated title" } });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export interface UpdateClientArgs<TCollectionSlug extends CollectionSlug = CollectionSlug> extends GenericMutationClientParams {
|
|
18
|
+
/** The collection slug to patch metadata. */
|
|
19
|
+
collection: TCollectionSlug;
|
|
20
|
+
/** The document ID to update. */
|
|
21
|
+
id: GenericId<TCollectionSlug>;
|
|
22
|
+
/** Partial field values to merge into the document. */
|
|
23
|
+
data: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns a `mutationFn` for patching an existing document in a VexCMS collection.
|
|
27
|
+
*
|
|
28
|
+
* Wraps `useConvexMutation(vexConvexApi.update)`. Call at the top level of
|
|
29
|
+
* a React component (obeys the Rules of Hooks); pass the return value as
|
|
30
|
+
* `mutationFn` to `useMutation`.
|
|
31
|
+
*
|
|
32
|
+
* Import from `@vexcms/core/client`. For the server-side version, import
|
|
33
|
+
* `update` from `@vexcms/core/server`.
|
|
34
|
+
*
|
|
35
|
+
* @returns A mutation function compatible with tanstack-query `useMutation`.
|
|
36
|
+
* @see {@link UpdateClientArgs} for the typed args shape.
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* import { update } from "@vexcms/core/client";
|
|
40
|
+
* import { useMutation } from "@tanstack/react-query";
|
|
41
|
+
*
|
|
42
|
+
* export function EditTitleButton({ id }: { id: Id<"posts"> }) {
|
|
43
|
+
* const { mutateAsync, isPending } = useMutation({ mutationFn: update() });
|
|
44
|
+
* return (
|
|
45
|
+
* <button onClick={() => mutateAsync({ id, data: { title: "New title" } })}>
|
|
46
|
+
* {isPending ? "Saving…" : "Save"}
|
|
47
|
+
* </button>
|
|
48
|
+
* );
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function update(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../convex").VexUpdateArgs, void>>;
|
|
53
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/update/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAG5D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,gBAAgB,CAC/B,eAAe,SAAS,cAAc,GAAG,cAAc,CACvD,SAAQ,2BAA2B;IACnC,6CAA6C;IAC7C,UAAU,EAAE,eAAe,CAAC;IAC5B,iCAAiC;IACjC,EAAE,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;IAC/B,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,MAAM,mJAErB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { BetterOmit, DocumentByName, Expand, GenericDataModel, TableNamesInDataModel } from "convex/server";
|
|
2
|
+
import type { GenericId } from "convex/values";
|
|
3
|
+
import type { CollectionSlug } from "../../types/generated";
|
|
4
|
+
import type { GenericMutationServerParams } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* Server-side args for `update`.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam DataModel - The Convex data model (inferred from `ctx`).
|
|
9
|
+
* @typeParam TCollectionSlug - Collection slug, recovered from the `Id` brand.
|
|
10
|
+
*/
|
|
11
|
+
export interface UpdateServerArgs<DataModel extends GenericDataModel, TCollectionSlug extends CollectionSlug> extends GenericMutationServerParams<DataModel> {
|
|
12
|
+
/** The collection slug to patch this document. */
|
|
13
|
+
collection: TCollectionSlug;
|
|
14
|
+
/** The document ID to patch. */
|
|
15
|
+
id: GenericId<TCollectionSlug>;
|
|
16
|
+
/**
|
|
17
|
+
* Partial field values to merge into the document. Only the keys present
|
|
18
|
+
* here are written; unspecified fields are left unchanged. `_id` and
|
|
19
|
+
* `_creationTime` are excluded — Convex manages them.
|
|
20
|
+
*
|
|
21
|
+
* Passed through `v.any()` at the network boundary; CLI codegen validates
|
|
22
|
+
* the shape against the Convex schema at build time.
|
|
23
|
+
*/
|
|
24
|
+
data: Partial<Expand<BetterOmit<DocumentByName<DataModel, TableNamesInDataModel<DataModel>>, "_creationTime" | "_id">>>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Patches a document by its `Id<TCollectionSlug>`. Only specified fields are updated;
|
|
28
|
+
* unspecified fields are left unchanged. Server-side only.
|
|
29
|
+
*
|
|
30
|
+
* Import from `@vexcms/core/server`.
|
|
31
|
+
*
|
|
32
|
+
* @typeParam DataModel - Convex data model (inferred from `args.ctx`).
|
|
33
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
34
|
+
* @param args - `{ ctx, id, data }`. `ctx` must be a mutation context.
|
|
35
|
+
* @returns Promise resolving to void.
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { update } from "@vexcms/core/server";
|
|
39
|
+
*
|
|
40
|
+
* export const updatePost = mutation({
|
|
41
|
+
* args: { id: v.id("posts"), data: v.any() },
|
|
42
|
+
* handler: (ctx, args) => update({ ctx, id: args.id, data: args.data }),
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function update<DataModel extends GenericDataModel, TCollectionSlug extends CollectionSlug>(args: UpdateServerArgs<DataModel, TCollectionSlug>): Promise<void>;
|
|
47
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/api/update/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAI5D;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAC/B,SAAS,SAAS,gBAAgB,EAClC,eAAe,SAAS,cAAc,CACtC,SAAQ,2BAA2B,CAAC,SAAS,CAAC;IAC9C,kDAAkD;IAClD,UAAU,EAAE,eAAe,CAAC;IAC5B,gCAAgC;IAChC,EAAE,EAAE,SAAS,CAAC,eAAe,CAAC,CAAC;IAC/B;;;;;;;OAOG;IACH,IAAI,EAAE,OAAO,CACX,MAAM,CACJ,UAAU,CACR,cAAc,CAAC,SAAS,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC,EAC3D,eAAe,GAAG,KAAK,CACxB,CACF,CACF,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,MAAM,CAC1B,SAAS,SAAS,gBAAgB,EAClC,eAAe,SAAS,cAAc,EACtC,IAAI,EAAE,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA0BnE"}
|