@vexcms/core 0.0.19 → 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 -3470
- 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,65 @@
|
|
|
1
|
+
import { GenericDataModel, GenericMutationCtx, GenericQueryCtx } from "convex/server";
|
|
2
|
+
import { VexConfig } from "../../config";
|
|
3
|
+
import { AccessCallOptions, MutationCallActionFor, QueryCallActionFor, VexApiAuth } from "../types";
|
|
4
|
+
import { GlobalSlug } from "../../types";
|
|
5
|
+
/**
|
|
6
|
+
* Base server-side args shared by every globals **query** function
|
|
7
|
+
* (`getGlobal`, `findGlobals`). Each concrete function extends this with its
|
|
8
|
+
* own inputs (e.g. `slug`, `populate`, `depth`).
|
|
9
|
+
*
|
|
10
|
+
* The RBAC seam rides on `auth` + `config`: when `config.access` is set, the
|
|
11
|
+
* function runs `hasPermission` for the global's slug using `auth.user` /
|
|
12
|
+
* `auth.organization`. Resolved server-side by the `globalsApi` factory via
|
|
13
|
+
* `resolveGetAuth(getAuth)` — never supplied by the client.
|
|
14
|
+
*
|
|
15
|
+
* @typeParam TDataModel - The project's generated Convex data model.
|
|
16
|
+
*/
|
|
17
|
+
export interface GenericGlobalsQueryServerArgs<TDataModel extends GenericDataModel, TGlobalSlug extends GlobalSlug = GlobalSlug> {
|
|
18
|
+
/**
|
|
19
|
+
* Resolved caller identity for permission checks — `{ user, organization? }`,
|
|
20
|
+
* or omitted when access control is off. `user` may be `null` for an
|
|
21
|
+
* unauthenticated caller (→ no roles → deny). Never a client argument;
|
|
22
|
+
* the factory resolves it from `ctx.auth` per request.
|
|
23
|
+
*/
|
|
24
|
+
auth?: VexApiAuth;
|
|
25
|
+
/** Convex query context (read-only DB access). */
|
|
26
|
+
ctx: GenericQueryCtx<TDataModel>;
|
|
27
|
+
/**
|
|
28
|
+
* The resolved `VexConfig`. Required — supplies `config.access` (the
|
|
29
|
+
* permission matrix the guard enforces) and `config.globals` (used to
|
|
30
|
+
* resolve the `GlobalConfig` for depth-populate and validation).
|
|
31
|
+
*/
|
|
32
|
+
config: VexConfig;
|
|
33
|
+
/** Per-call access overrides. @see {@link AccessCallOptions} */
|
|
34
|
+
access?: AccessCallOptions<QueryCallActionFor<TGlobalSlug>>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Base server-side args shared by every globals **mutation** function
|
|
38
|
+
* (`upsertGlobal`). Mirrors {@link GenericGlobalsQueryServerArgs} but carries a
|
|
39
|
+
* mutation context for writes.
|
|
40
|
+
*
|
|
41
|
+
* The RBAC seam is identical: when `config.access` is set, the function runs
|
|
42
|
+
* `hasPermission` for the global's slug (write actions use `throwOnDenied`).
|
|
43
|
+
*
|
|
44
|
+
* @typeParam TDataModel - The project's generated Convex data model.
|
|
45
|
+
*/
|
|
46
|
+
export interface GenericGlobalsMutationServerArgs<TDataModel extends GenericDataModel, TGlobalSlug extends GlobalSlug = GlobalSlug> {
|
|
47
|
+
/**
|
|
48
|
+
* Resolved caller identity for permission checks — `{ user, organization? }`,
|
|
49
|
+
* or omitted when access control is off. `user` may be `null` for an
|
|
50
|
+
* unauthenticated caller (→ no roles → deny). Never a client argument;
|
|
51
|
+
* the factory resolves it from `ctx.auth` per request.
|
|
52
|
+
*/
|
|
53
|
+
auth?: VexApiAuth;
|
|
54
|
+
/** Convex mutation context (read + write DB access). */
|
|
55
|
+
ctx: GenericMutationCtx<TDataModel>;
|
|
56
|
+
/**
|
|
57
|
+
* The resolved `VexConfig`. Required — supplies `config.access` (the
|
|
58
|
+
* permission matrix the guard enforces) and `config.globals` (used to
|
|
59
|
+
* resolve the target `GlobalConfig` for input validation).
|
|
60
|
+
*/
|
|
61
|
+
config: VexConfig;
|
|
62
|
+
/** Per-call access overrides. @see {@link AccessCallOptions} */
|
|
63
|
+
access?: AccessCallOptions<MutationCallActionFor<TGlobalSlug>>;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/globals/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,6BAA6B,CAC5C,UAAU,SAAS,gBAAgB,EACnC,WAAW,SAAS,UAAU,GAAG,UAAU;IAE3C;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,kDAAkD;IAClD,GAAG,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IACjC;;;;OAIG;IACH,MAAM,EAAE,SAAS,CAAC;IAClB,gEAAgE;IAChE,MAAM,CAAC,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC;CAC7D;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gCAAgC,CAC/C,UAAU,SAAS,gBAAgB,EACnC,WAAW,SAAS,UAAU,GAAG,UAAU;IAE3C;;;;;OAKG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,wDAAwD;IACxD,GAAG,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;IACpC;;;;OAIG;IACH,MAAM,EAAE,SAAS,CAAC;IAClB,gEAAgE;IAChE,MAAM,CAAC,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC;CAChE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a `useConvexMutation` hook bound to the `globals.update` Convex mutation.
|
|
3
|
+
* Call the returned function as `mutationFn` inside `useMutation`.
|
|
4
|
+
*
|
|
5
|
+
* The mutation accepts `{ slug: string, data: Record<string, unknown> }`.
|
|
6
|
+
* Pass user field values in `data` — system keys (`_id`, `_creationTime`, `_slug`)
|
|
7
|
+
* are stripped server-side if they accidentally appear. `GlobalEditView` calls
|
|
8
|
+
* this internally after stripping system keys from the flat form state.
|
|
9
|
+
*
|
|
10
|
+
* Import from `@vexcms/core/client`.
|
|
11
|
+
*
|
|
12
|
+
* @returns A `useConvexMutation`-compatible mutation function.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* import { globals } from "@vexcms/core/client";
|
|
17
|
+
* import { useMutation } from "@tanstack/react-query";
|
|
18
|
+
*
|
|
19
|
+
* const mutation = useMutation({ mutationFn: globals.update() });
|
|
20
|
+
* mutation.mutate({ slug: "siteSettings", data: { siteName: "New Name" } });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function updateGlobal(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../convex").VexGlobalsUpdateArgs, string>>;
|
|
24
|
+
//# sourceMappingURL=upsert.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upsert.client.d.ts","sourceRoot":"","sources":["../../../src/api/globals/upsert.client.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,4JAE3B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { GenericDataModel } from "convex/server";
|
|
2
|
+
import type { GlobalSlug } from "../../types/generated";
|
|
3
|
+
import { GenericGlobalsMutationServerArgs } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Server-side args for `updateGlobal`.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam DataModel - Convex data model.
|
|
8
|
+
* @typeParam TSlug - Global slug.
|
|
9
|
+
*/
|
|
10
|
+
export interface UpsertGlobalServerArgs<DataModel extends GenericDataModel, TGlobalSlug extends GlobalSlug = GlobalSlug> extends GenericGlobalsMutationServerArgs<DataModel, TGlobalSlug> {
|
|
11
|
+
/** The global slug to upsert. Must match a registered global in config. */
|
|
12
|
+
slug: TGlobalSlug;
|
|
13
|
+
/**
|
|
14
|
+
* User field data. May be the full flat document (system keys `_id`,
|
|
15
|
+
* `_creationTime`, `_slug` are stripped server-side) or just the field
|
|
16
|
+
* values. The `GlobalEditView` component sends the flat form values here.
|
|
17
|
+
*/
|
|
18
|
+
data: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Upserts a global document in `vex_globals`. Strips system keys from `data`,
|
|
22
|
+
* validates remaining user fields against the global's Zod schema, then writes
|
|
23
|
+
* `{ slug, data: userFields }` to the DB (re-nesting). Patches if a row
|
|
24
|
+
* already exists for the slug; inserts if not.
|
|
25
|
+
*
|
|
26
|
+
* Throws `ConvexError` on Zod validation failure with structured `errors` payload.
|
|
27
|
+
* Server-side only. Import from `@vexcms/core/server`.
|
|
28
|
+
*
|
|
29
|
+
* @typeParam DataModel - Convex data model.
|
|
30
|
+
* @typeParam TSlug - Global slug.
|
|
31
|
+
* @param args - `{ ctx, slug, data, globalConfig }`.
|
|
32
|
+
* @returns The `_id` of the upserted document as a string.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { updateGlobal } from "@vexcms/core/server";
|
|
37
|
+
*
|
|
38
|
+
* const id = await updateGlobal({
|
|
39
|
+
* ctx,
|
|
40
|
+
* slug: "siteSettings",
|
|
41
|
+
* data: { siteName: "New Name" },
|
|
42
|
+
* globalConfig: config.globals.find((g) => g.slug === "siteSettings")!,
|
|
43
|
+
* });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function upsertGlobal<DataModel extends GenericDataModel, TSlug extends GlobalSlug = GlobalSlug>(args: UpsertGlobalServerArgs<DataModel, TSlug>): Promise<string>;
|
|
47
|
+
//# sourceMappingURL=upsert.server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upsert.server.d.ts","sourceRoot":"","sources":["../../../src/api/globals/upsert.server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAC;AAM3D;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB,CACrC,SAAS,SAAS,gBAAgB,EAClC,WAAW,SAAS,UAAU,GAAG,UAAU,CAC3C,SAAQ,gCAAgC,CAAC,SAAS,EAAE,WAAW,CAAC;IAChE,2EAA2E;IAC3E,IAAI,EAAE,WAAW,CAAC;IAClB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,YAAY,CAChC,SAAS,SAAS,gBAAgB,EAClC,KAAK,SAAS,UAAU,GAAG,UAAU,EACrC,IAAI,EAAE,sBAAsB,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAwDjE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { GenericDataModel, GenericQueryCtx } from "convex/server";
|
|
2
|
+
import type { CollectionSlug } from "../types/generated";
|
|
3
|
+
import type { Populated, PopulateShape } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Walks `docs` and replaces each relationship field listed in `populate` with
|
|
6
|
+
* the resolved target doc(s). Returns a shallow-copied array; original docs
|
|
7
|
+
* are not mutated.
|
|
8
|
+
*
|
|
9
|
+
* The `TPopulate` generic is the caller-supplied populate shape. The return
|
|
10
|
+
* type `Populated<TCollectionSlug, TPopulate>[]` is what TypeScript sees at call sites
|
|
11
|
+
* — the `as unknown as` cast at the bottom bridges runtime
|
|
12
|
+
* `Record<string, unknown>[]` to the compile-time `Populated` shape. All
|
|
13
|
+
* callers (`find`, `get`, `search` server functions) benefit without writing
|
|
14
|
+
* their own casts.
|
|
15
|
+
*
|
|
16
|
+
* @param ctx - The Convex query context (any DataModel).
|
|
17
|
+
* @param docs - Documents to populate.
|
|
18
|
+
* @param populate - Relationship fields to resolve, optionally nested.
|
|
19
|
+
* @returns Same docs with relationship Id arrays replaced by Doc arrays,
|
|
20
|
+
* typed as `Populated<TCollectionSlug, TPopulate>[]`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function populateDocs<DataModel extends GenericDataModel, TCollectionSlug extends CollectionSlug = CollectionSlug, const TPopulate extends PopulateShape<TCollectionSlug> = PopulateShape<TCollectionSlug>>(ctx: GenericQueryCtx<DataModel>, docs: Record<string, unknown>[], populate: TPopulate): Promise<Populated<TCollectionSlug, TPopulate>[]>;
|
|
23
|
+
//# sourceMappingURL=populate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"populate.d.ts","sourceRoot":"","sources":["../../src/api/populate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAyB,MAAM,eAAe,CAAC;AAE9F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,YAAY,CAChC,SAAS,SAAS,gBAAgB,EAClC,eAAe,SAAS,cAAc,GAAG,cAAc,EACvD,KAAK,CAAC,SAAS,SAAS,aAAa,CAAC,eAAe,CAAC,GAAG,aAAa,CAAC,eAAe,CAAC,EAEvF,GAAG,EAAE,eAAe,CAAC,SAAS,CAAC,EAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,QAAQ,EAAE,SAAS,GAClB,OAAO,CAAC,SAAS,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,CAAC,CA4BlD"}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 remove}.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { remove, type RemoveClientArgs } from "@vexcms/core/client";
|
|
10
|
+
* import { useMutation } from "@tanstack/react-query";
|
|
11
|
+
*
|
|
12
|
+
* // Inside a React component:
|
|
13
|
+
* const { mutateAsync } = useMutation({ mutationFn: remove() });
|
|
14
|
+
* await mutateAsync({ id: postId });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export interface RemoveClientArgs<TCollectionSlug extends CollectionSlug> extends GenericMutationClientParams {
|
|
18
|
+
/**
|
|
19
|
+
* Document ID(s) to delete.
|
|
20
|
+
* Pass a single ID in an array for one document, or multiple IDs for bulk delete.
|
|
21
|
+
*/
|
|
22
|
+
ids: GenericId<TCollectionSlug>[];
|
|
23
|
+
/**
|
|
24
|
+
* Optional soft delete field name.
|
|
25
|
+
* If provided, sets this field to `true` instead of permanently deleting.
|
|
26
|
+
* @example "deleted" — sets { deleted: true } on the document(s)
|
|
27
|
+
*/
|
|
28
|
+
softDelete?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns a `mutationFn` for permanently deleting a document from a VexCMS collection.
|
|
32
|
+
*
|
|
33
|
+
* Wraps `useConvexMutation(vexConvexApi.remove)`. Call at the top level of
|
|
34
|
+
* a React component (obeys the Rules of Hooks); pass the return value as
|
|
35
|
+
* `mutationFn` to `useMutation`.
|
|
36
|
+
*
|
|
37
|
+
* Import from `@vexcms/core/client`. For the server-side version, import
|
|
38
|
+
* `remove` from `@vexcms/core/server`.
|
|
39
|
+
*
|
|
40
|
+
* @returns A mutation function compatible with tanstack-query `useMutation`.
|
|
41
|
+
* @see {@link RemoveClientArgs} for the typed args shape.
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* import { remove } from "@vexcms/core/client";
|
|
45
|
+
* import { useMutation } from "@tanstack/react-query";
|
|
46
|
+
*
|
|
47
|
+
* export function DeleteButton({ id }: { id: Id<"posts"> }) {
|
|
48
|
+
* const { mutateAsync, isPending } = useMutation({ mutationFn: remove() });
|
|
49
|
+
* return (
|
|
50
|
+
* <button onClick={() => mutateAsync({ id })}>
|
|
51
|
+
* {isPending ? "Deleting…" : "Delete"}
|
|
52
|
+
* </button>
|
|
53
|
+
* );
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function remove(): import("convex/react").ReactMutation<import("convex/server").FunctionReference<"mutation", "public", import("../convex").VexRemoveArgs, void>>;
|
|
58
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/remove/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,CACtC,SAAQ,2BAA2B;IACnC;;;OAGG;IACH,GAAG,EAAE,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;IAClC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,MAAM,mJAErB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { GenericDataModel } 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 `remove`.
|
|
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 RemoveServerArgs<DataModel extends GenericDataModel, TCollectionSlug extends CollectionSlug> extends GenericMutationServerParams<DataModel> {
|
|
12
|
+
/** The collection slug to insert into. */
|
|
13
|
+
collection: TCollectionSlug;
|
|
14
|
+
/**
|
|
15
|
+
* Document ID(s) to delete.
|
|
16
|
+
* Pass a single ID in an array for one document, or multiple IDs for bulk delete.
|
|
17
|
+
*/
|
|
18
|
+
ids: GenericId<TCollectionSlug>[];
|
|
19
|
+
/**
|
|
20
|
+
* Optional soft delete field name.
|
|
21
|
+
* If provided, sets this field to `true` instead of permanently deleting.
|
|
22
|
+
* @example "deleted" — sets { deleted: true } on the document(s)
|
|
23
|
+
*/
|
|
24
|
+
softDelete?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Deletes one or more documents. Server-side only.
|
|
28
|
+
* Named `remove` to avoid collision with the JavaScript `delete` keyword.
|
|
29
|
+
*
|
|
30
|
+
* Supports both hard delete (permanent) and soft delete (mark as deleted).
|
|
31
|
+
* Pass `softDelete` field name to soft delete instead of permanently removing.
|
|
32
|
+
*
|
|
33
|
+
* Import from `@vexcms/core/server`.
|
|
34
|
+
*
|
|
35
|
+
* @typeParam DataModel - Convex data model (inferred from `args.ctx`).
|
|
36
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
37
|
+
* @param args - `{ ctx, ids, softDelete? }`. `ctx` must be a mutation context.
|
|
38
|
+
* @returns Promise resolving to void.
|
|
39
|
+
* @example Single delete
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { remove } from "@vexcms/core/server";
|
|
42
|
+
*
|
|
43
|
+
* export const deletePost = mutation({
|
|
44
|
+
* args: { id: v.id("posts") },
|
|
45
|
+
* handler: (ctx, args) => remove({ ctx, ids: [args.id] }),
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
* @example Bulk delete
|
|
49
|
+
* ```ts
|
|
50
|
+
* export const bulkDeletePosts = mutation({
|
|
51
|
+
* args: { ids: v.array(v.id("posts")) },
|
|
52
|
+
* handler: (ctx, args) => remove({ ctx, ids: args.ids }),
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
* @example Soft delete
|
|
56
|
+
* ```ts
|
|
57
|
+
* export const softDeletePost = mutation({
|
|
58
|
+
* args: { id: v.id("posts") },
|
|
59
|
+
* handler: (ctx, args) =>
|
|
60
|
+
* remove({ ctx, ids: [args.id], softDelete: "deleted" }),
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function remove<DataModel extends GenericDataModel = GenericDataModel, TCollectionSlug extends CollectionSlug = CollectionSlug>(args: RemoveServerArgs<DataModel, TCollectionSlug>): Promise<void>;
|
|
65
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/api/remove/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,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,0CAA0C;IAC1C,UAAU,EAAE,eAAe,CAAC;IAC5B;;;OAGG;IACH,GAAG,EAAE,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;IAClC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,MAAM,CAC1B,SAAS,SAAS,gBAAgB,GAAG,gBAAgB,EACrD,eAAe,SAAS,cAAc,GAAG,cAAc,EACvD,IAAI,EAAE,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BnE"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type VexSearchArgs } from "../convex";
|
|
2
|
+
import type { CollectionSlug } from "../../types/generated";
|
|
3
|
+
import type { DocReturnItem, GenericQueryClientParams, PaginationOptions, PaginationResult, PopulateShape, VexQueryOptions } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Client-side args for `search`. Extends {@link GenericQueryClientParams}
|
|
6
|
+
* to inherit `ctx?: never` and `populate?: TPopulate`.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
9
|
+
* @typeParam TPopulate - Populate object.
|
|
10
|
+
*/
|
|
11
|
+
export interface SearchClientArgs<TCollectionSlug extends CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug>, D extends number = number> extends GenericQueryClientParams<TCollectionSlug, TPopulate, D> {
|
|
12
|
+
collection: TCollectionSlug;
|
|
13
|
+
query: string;
|
|
14
|
+
searchIndexName: string;
|
|
15
|
+
searchField: string;
|
|
16
|
+
limit?: number;
|
|
17
|
+
paginationOpts?: PaginationOptions;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Client-side args for `search` with PaginationOptions required. Extends {@link GenericQueryClientParams}
|
|
21
|
+
* to inherit `ctx?: never` and `populate?: TPopulate`.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
24
|
+
* @typeParam TPopulate - Populate object.
|
|
25
|
+
*/
|
|
26
|
+
export interface SearchClientPaginatedArgs<TCollectionSlug extends CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug>, D extends number = number> extends GenericQueryClientParams<TCollectionSlug, TPopulate, D> {
|
|
27
|
+
collection: TCollectionSlug;
|
|
28
|
+
query: string;
|
|
29
|
+
searchIndexName: string;
|
|
30
|
+
searchField: string;
|
|
31
|
+
limit?: number;
|
|
32
|
+
paginationOpts: PaginationOptions;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns tanstack-query options for text search in a VexCMS collection.
|
|
36
|
+
* Client-side only — pass to `useQuery` / `useSuspenseQuery`.
|
|
37
|
+
*
|
|
38
|
+
* Import from `@vexcms/core/client`. For the server-side version, import
|
|
39
|
+
* `search` from `@vexcms/core/server`.
|
|
40
|
+
*
|
|
41
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
42
|
+
* @typeParam TPopulate - Populate object.
|
|
43
|
+
* @param args - `{ collection, query, searchIndexName, searchField, limit?, populate? }`.
|
|
44
|
+
* @returns Tanstack-query `queryOptions`.
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* import { search } from "@vexcms/core/client";
|
|
48
|
+
*
|
|
49
|
+
* const { data: authors } = useQuery(
|
|
50
|
+
* search({ collection: "authors", query: q, searchIndexName: "search_name", searchField: "name" }),
|
|
51
|
+
* );
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function search<TCollectionSlug extends CollectionSlug, const TPopulate extends PopulateShape<TCollectionSlug> = Record<string, never>, const D extends number = 0>(args: SearchClientArgs<TCollectionSlug, TPopulate, D> & {
|
|
55
|
+
paginationOpts?: never;
|
|
56
|
+
}): VexQueryOptions<VexSearchArgs, DocReturnItem<TCollectionSlug, TPopulate, D>[]>;
|
|
57
|
+
export declare function search<TCollectionSlug extends CollectionSlug, const TPopulate extends PopulateShape<TCollectionSlug> = Record<string, never>, const D extends number = 0>(args: SearchClientPaginatedArgs<TCollectionSlug, TPopulate, D>): VexQueryOptions<VexSearchArgs, PaginationResult<DocReturnItem<TCollectionSlug, TPopulate, D>>>;
|
|
58
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/api/search/client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EAGb,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB,CAC/B,eAAe,SAAS,cAAc,EACtC,SAAS,SAAS,aAAa,CAAC,eAAe,CAAC,EAChD,CAAC,SAAS,MAAM,GAAG,MAAM,CACzB,SAAQ,wBAAwB,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/D,UAAU,EAAE,eAAe,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,iBAAiB,CAAC;CACpC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB,CACxC,eAAe,SAAS,cAAc,EACtC,SAAS,SAAS,aAAa,CAAC,eAAe,CAAC,EAChD,CAAC,SAAS,MAAM,GAAG,MAAM,CACzB,SAAQ,wBAAwB,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/D,UAAU,EAAE,eAAe,CAAC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,iBAAiB,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,MAAM,CACpB,eAAe,SAAS,cAAc,EACtC,KAAK,CAAC,SAAS,SAAS,aAAa,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9E,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,EAE1B,IAAI,EAAE,gBAAgB,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG;IAAE,cAAc,CAAC,EAAE,KAAK,CAAA;CAAE,GAGjF,eAAe,CAAC,aAAa,EAAE,aAAa,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAClF,wBAAgB,MAAM,CACpB,eAAe,SAAS,cAAc,EACtC,KAAK,CAAC,SAAS,SAAS,aAAa,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9E,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,EAE1B,IAAI,EAAE,yBAAyB,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,GAC7D,eAAe,CAChB,aAAa,EACb,gBAAgB,CAAC,aAAa,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAC/D,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ExpressionOrValue, FilterBuilder, GenericDataModel, NamedTableInfo, TableNamesInDataModel } from "convex/server";
|
|
2
|
+
import type { CollectionSlug } from "../../types/generated";
|
|
3
|
+
import type { DocReturnItem, GenericQueryServerParams, PaginationOptions, PaginationResult, PopulateShape } from "../types";
|
|
4
|
+
/**
|
|
5
|
+
* Server-side args for `search`.
|
|
6
|
+
*
|
|
7
|
+
* Inherits `ctx`, `populate`, `depth`, and `config` (with mutual-exclusion
|
|
8
|
+
* constraints) from {@link GenericQueryServerParams}.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam DataModel - The Convex data model (inferred from `ctx`).
|
|
11
|
+
* @typeParam TCollectionSlug - Collection slug.
|
|
12
|
+
* @typeParam TPopulate - Populate object.
|
|
13
|
+
* @typeParam D - Depth literal (0 = no depth, default).
|
|
14
|
+
*/
|
|
15
|
+
export interface SearchServerArgs<DataModel extends GenericDataModel, TCollectionSlug extends CollectionSlug, TPopulate extends PopulateShape<TCollectionSlug>, D extends number = 0> extends GenericQueryServerParams<DataModel, TCollectionSlug, TPopulate, D> {
|
|
16
|
+
/** The collection to search — must match a registered collection slug. */
|
|
17
|
+
collection: TCollectionSlug;
|
|
18
|
+
/** The search text. Pass `""` to list recent documents (falls back to `.take()`). */
|
|
19
|
+
query: string;
|
|
20
|
+
/** The `.searchIndex()` name declared in the Convex schema (e.g. `"search_name"`). */
|
|
21
|
+
searchIndexName: string;
|
|
22
|
+
/** The field the search index is built on. Must match `searchField` in the index declaration. */
|
|
23
|
+
searchField: string;
|
|
24
|
+
/** Maximum number of results. Defaults to 20. */
|
|
25
|
+
limit?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Pagination options. When provided, the function returns a `PaginationResult`
|
|
28
|
+
* with `{ page, continueCursor, isDone }` instead of a plain array.
|
|
29
|
+
*
|
|
30
|
+
* Uses Convex's native `.paginate(opts)` API under the hood.
|
|
31
|
+
*/
|
|
32
|
+
paginationOpts?: PaginationOptions;
|
|
33
|
+
/**
|
|
34
|
+
* Filter predicate applied after index narrowing. Equivalent to
|
|
35
|
+
* `.filter(q => q.eq(q.field("published"), true))` on the Convex query.
|
|
36
|
+
*
|
|
37
|
+
* Prefer `withIndex` for performance — `filter` scans every document
|
|
38
|
+
* in the range and is O(n). Use `filter` for secondary conditions that
|
|
39
|
+
* can't be expressed as index equality ranges.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* find({ ctx, collection: "posts", filter: q => q.eq(q.field("published"), true) })
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
filter?: (q: FilterBuilder<NamedTableInfo<DataModel, TCollectionSlug extends TableNamesInDataModel<DataModel> ? TCollectionSlug : never>>) => ExpressionOrValue<boolean>;
|
|
47
|
+
}
|
|
48
|
+
export declare function search<DataModel extends GenericDataModel, TCollectionSlug extends CollectionSlug, const TPopulate extends PopulateShape<TCollectionSlug> = Record<string, never>, const D extends number = 0>(args: SearchServerArgs<DataModel, TCollectionSlug, TPopulate, D> & {
|
|
49
|
+
paginationOpts?: never;
|
|
50
|
+
}): Promise<DocReturnItem<TCollectionSlug, TPopulate, D>[]>;
|
|
51
|
+
export declare function search<DataModel extends GenericDataModel, TCollectionSlug extends CollectionSlug, const TPopulate extends PopulateShape<TCollectionSlug> = Record<string, never>, const D extends number = 0>(args: SearchServerArgs<DataModel, TCollectionSlug, TPopulate, D> & {
|
|
52
|
+
paginationOpts: PaginationOptions;
|
|
53
|
+
}): Promise<PaginationResult<DocReturnItem<TCollectionSlug, TPopulate, D>>>;
|
|
54
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/api/search/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,cAAc,EAEd,qBAAqB,EACtB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EAGd,MAAM,UAAU,CAAC;AAIlB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB,CAC/B,SAAS,SAAS,gBAAgB,EAClC,eAAe,SAAS,cAAc,EACtC,SAAS,SAAS,aAAa,CAAC,eAAe,CAAC,EAChD,CAAC,SAAS,MAAM,GAAG,CAAC,CACpB,SAAQ,wBAAwB,CAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC;IAC1E,0EAA0E;IAC1E,UAAU,EAAE,eAAe,CAAC;IAC5B,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,eAAe,EAAE,MAAM,CAAC;IACxB,iGAAiG;IACjG,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,cAAc,CAAC,EAAE,iBAAiB,CAAC;IACnC;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,CACP,CAAC,EAAE,aAAa,CACd,cAAc,CACZ,SAAS,EACT,eAAe,SAAS,qBAAqB,CAAC,SAAS,CAAC,GAAG,eAAe,GAAG,KAAK,CACnF,CACF,KACE,iBAAiB,CAAC,OAAO,CAAC,CAAC;CACjC;AAGD,wBAAsB,MAAM,CAC1B,SAAS,SAAS,gBAAgB,EAClC,eAAe,SAAS,cAAc,EACtC,KAAK,CAAC,SAAS,SAAS,aAAa,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9E,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,EAE1B,IAAI,EAAE,gBAAgB,CAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG;IACjE,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB,GAGA,OAAO,CAAC,aAAa,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAG3D,wBAAsB,MAAM,CAC1B,SAAS,SAAS,gBAAgB,EAClC,eAAe,SAAS,cAAc,EACtC,KAAK,CAAC,SAAS,SAAS,aAAa,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAC9E,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,EAE1B,IAAI,EAAE,gBAAgB,CAAC,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG;IACjE,cAAc,EAAE,iBAAiB,CAAC;CACnC,GACA,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC"}
|