better-convex 0.7.2 → 0.7.3
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/dist/aggregate/index.d.ts +1 -1
- package/dist/auth/http/index.d.ts +1 -1
- package/dist/auth/index.d.ts +4 -4
- package/dist/auth/index.js +5 -4
- package/dist/auth/nextjs/index.d.ts +2 -2
- package/dist/auth/nextjs/index.js +2 -2
- package/dist/{caller-factory-D3OuR1eI.js → caller-factory-4uND4vnj.js} +2 -2
- package/dist/cli.mjs +413 -5
- package/dist/{codegen-Cz1idI3-.mjs → codegen-BS36cYTH.mjs} +88 -5
- package/dist/{create-schema-orm-69VF4CFV.js → create-schema-orm-DtuyK2RB.js} +1 -1
- package/dist/crpc/index.d.ts +2 -2
- package/dist/crpc/index.js +3 -3
- package/dist/customFunctions-C_i_0joT.js +167 -0
- package/dist/{http-types-BCf2wCgp.d.ts → http-types-BsnDV7Je.d.ts} +1 -1
- package/dist/orm/index.d.ts +4 -3
- package/dist/orm/index.js +707 -4
- package/dist/{procedure-caller-CcjtUFvL.d.ts → procedure-caller-Cj_lgUev.d.ts} +4 -19
- package/dist/rsc/index.d.ts +3 -3
- package/dist/rsc/index.js +4 -4
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +4 -3
- package/dist/{types-CIBGEYXq.d.ts → types-DZFvhoPJ.d.ts} +1 -1
- package/dist/{customFunctions-CZnCwoR3.js → validators-B7oIJCAp.js} +67 -165
- package/dist/validators-BDrWGp4M.d.ts +88 -0
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-CRP-i1Qa.d.ts → where-clause-compiler-HUa2223D.d.ts} +106 -2
- package/package.json +1 -1
- /package/dist/{create-schema-BdZOL6ns.js → create-schema-DE9ZtH8n.js} +0 -0
- /package/dist/{error-Be4OcwwD.js → error-C7AOPlv2.js} +0 -0
- /package/dist/{meta-utils-DDVYp9Xf.js → meta-utils-C9_6WIzj.js} +0 -0
- /package/dist/{query-context-DGExXZIV.d.ts → query-context-BMXt2TKe.d.ts} +0 -0
- /package/dist/{query-context-BDSis9rT.js → query-context-yQVARct0.js} +0 -0
- /package/dist/{query-options-B0c1b6pZ.js → query-options-Bjo6j5cC.js} +0 -0
- /package/dist/{transformer-Dh0w2py0.js → transformer-BsX4RWes.js} +0 -0
- /package/dist/{types-DgwvxKbT.d.ts → types-DarApWtO.d.ts} +0 -0
- /package/dist/{types-DwGkkq2s.d.ts → types-kgwiK-xe.d.ts} +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as VRequired } from "./validators-BDrWGp4M.js";
|
|
2
|
+
import { C as HttpProcedure, D as ProcedureMeta, G as DataTransformerOptions, N as MiddlewareBuilder, O as AnyMiddleware, P as MiddlewareFunction, Q as getTransformer, R as Overwrite$1, S as HttpMethod, V as UnsetMarker, c as InferHttpInput, d as CRPCHttpRouter, j as IntersectIfDefined, l as InferHttpOutput, p as HttpRouterRecord, w as HttpProcedureBuilderDef, x as HttpHandlerOpts } from "./http-types-BsnDV7Je.js";
|
|
3
|
+
import { ConvexError, GenericId, GenericValidator, ObjectType, OptionalProperty, PropertyValidators, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VOptional, VRecord, VString, VUnion, Validator } from "convex/values";
|
|
3
4
|
import * as convex_server0 from "convex/server";
|
|
4
|
-
import { ActionBuilder, ArgsArrayToObject, DefaultFunctionArgs, FunctionReference, FunctionReturnType, FunctionVisibility, GenericActionCtx, GenericDataModel,
|
|
5
|
+
import { ActionBuilder, ArgsArrayToObject, DefaultFunctionArgs, FunctionReference, FunctionReturnType, FunctionVisibility, GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx, MutationBuilder, QueryBuilder, RegisteredAction, RegisteredMutation, RegisteredQuery, TableNamesInDataModel } from "convex/server";
|
|
5
6
|
import * as z$1 from "zod/v4";
|
|
6
7
|
import * as zCore from "zod/v4/core";
|
|
7
8
|
import { z } from "zod";
|
|
@@ -16,22 +17,6 @@ type EmptyObject = Record<string, never>;
|
|
|
16
17
|
*/
|
|
17
18
|
type Expand<ObjectType extends Record<any, any>> = ObjectType extends Record<any, any> ? { [Key in keyof ObjectType]: ObjectType[Key] } : never;
|
|
18
19
|
//#endregion
|
|
19
|
-
//#region src/internal/upstream/validators.d.ts
|
|
20
|
-
type NotUndefined$1<T> = Exclude<T, undefined>;
|
|
21
|
-
/**
|
|
22
|
-
* A type that converts an optional validator to a required validator.
|
|
23
|
-
*
|
|
24
|
-
* This is the inverse of `VOptional`. It takes a validator that may be optional
|
|
25
|
-
* and returns the equivalent required validator type.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* type OptionalString = VOptional<VString<string, "required">>;
|
|
30
|
-
* type RequiredString = VRequired<OptionalString>; // VString<string, "required">
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
type VRequired<T extends Validator<any, OptionalProperty, any>> = T extends VId<infer Type, OptionalProperty> ? VId<NotUndefined$1<Type>, 'required'> : T extends VString<infer Type, OptionalProperty> ? VString<NotUndefined$1<Type>, 'required'> : T extends VFloat64<infer Type, OptionalProperty> ? VFloat64<NotUndefined$1<Type>, 'required'> : T extends VInt64<infer Type, OptionalProperty> ? VInt64<NotUndefined$1<Type>, 'required'> : T extends VBoolean<infer Type, OptionalProperty> ? VBoolean<NotUndefined$1<Type>, 'required'> : T extends VNull<infer Type, OptionalProperty> ? VNull<NotUndefined$1<Type>, 'required'> : T extends VAny<infer Type, OptionalProperty> ? VAny<NotUndefined$1<Type>, 'required'> : T extends VLiteral<infer Type, OptionalProperty> ? VLiteral<NotUndefined$1<Type>, 'required'> : T extends VBytes<infer Type, OptionalProperty> ? VBytes<NotUndefined$1<Type>, 'required'> : T extends VObject<infer Type, infer Fields, OptionalProperty, infer FieldPaths> ? VObject<NotUndefined$1<Type>, Fields, 'required', FieldPaths> : T extends VArray<infer Type, infer Element, OptionalProperty> ? VArray<NotUndefined$1<Type>, Element, 'required'> : T extends VRecord<infer Type, infer Key, infer Value, OptionalProperty, infer FieldPaths> ? VRecord<NotUndefined$1<Type>, Key, Value, 'required', FieldPaths> : T extends VUnion<infer Type, infer Members, OptionalProperty, infer FieldPaths> ? VUnion<NotUndefined$1<Type>, Members, 'required', FieldPaths> : never;
|
|
34
|
-
//#endregion
|
|
35
20
|
//#region src/internal/upstream/server/customFunctions.d.ts
|
|
36
21
|
/**
|
|
37
22
|
* A customization of a query, mutation, or action.
|
package/dist/rsc/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as Simplify, r as DistributiveOmit } from "../types-
|
|
2
|
-
import { C as HttpProcedure, G as DataTransformerOptions, V as UnsetMarker, d as CRPCHttpRouter, p as HttpRouterRecord } from "../http-types-
|
|
3
|
-
import { n as CRPCClient } from "../types-
|
|
1
|
+
import { o as Simplify, r as DistributiveOmit } from "../types-kgwiK-xe.js";
|
|
2
|
+
import { C as HttpProcedure, G as DataTransformerOptions, V as UnsetMarker, d as CRPCHttpRouter, p as HttpRouterRecord } from "../http-types-BsnDV7Je.js";
|
|
3
|
+
import { n as CRPCClient } from "../types-DZFvhoPJ.js";
|
|
4
4
|
import { DefaultError, QueryFilters, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
package/dist/rsc/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as defaultIsUnauthorized } from "../error-
|
|
2
|
-
import { n as getFuncRef, r as getFunctionMeta, t as buildMetaIndex } from "../meta-utils-
|
|
3
|
-
import { i as decodeWire, s as getTransformer } from "../transformer-
|
|
4
|
-
import { n as convexInfiniteQueryOptions, r as convexQuery } from "../query-options-
|
|
1
|
+
import { n as defaultIsUnauthorized } from "../error-C7AOPlv2.js";
|
|
2
|
+
import { n as getFuncRef, r as getFunctionMeta, t as buildMetaIndex } from "../meta-utils-C9_6WIzj.js";
|
|
3
|
+
import { i as decodeWire, s as getTransformer } from "../transformer-BsX4RWes.js";
|
|
4
|
+
import { n as convexInfiniteQueryOptions, r as convexQuery } from "../query-options-Bjo6j5cC.js";
|
|
5
5
|
import { convexToJson } from "convex/values";
|
|
6
6
|
import { getFunctionName } from "convex/server";
|
|
7
7
|
import { fetchAction, fetchQuery } from "convex/nextjs";
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as QueryProcedureBuilder, A as GenericCtx, B as ConvexContext, C as CRPC_ERROR_CODE_TO_HTTP, Ct as zodToConvex, D as toCRPCError, E as isCRPCError, F as isRunMutationCtx, G as CallerOpts, H as LazyCaller, I as requireActionCtx, J as createApiLeaf, K as ServerCaller, L as requireMutationCtx, M as isActionCtx, N as isMutationCtx, O as CreateEnvOptions, P as isQueryCtx, Q as ProcedureBuilder, R as requireQueryCtx, S as CRPC_ERROR_CODES_BY_KEY, St as zodOutputToConvexFields, T as getHTTPStatusCodeFromError, U as createLazyCaller, V as createCallerFactory, W as CallerMeta, X as CRPCFunctionTypeHint, Y as ActionProcedureBuilder, Z as MutationProcedureBuilder, _ as WithHttpRouter, _t as zCustomAction, a as ProcedureCaller, at as handleHttpError, b as CRPCError, bt as zid, c as ProcedureFromFunctionReference, ct as ConvexValidatorFromZodOutput, d as createGenericCallerFactory, dt as Zid, et as createMiddlewareFactory, f as createGenericHandlerFactory, ft as ZodFromValidatorBase, g as typedProcedureResolver, gt as withSystemFields, h as defineProcedure, ht as convexToZodFields, i as ProcedureActionCallerFromRegistry, it as extractPathParams, j as RunMutationCtx, k as createEnv, l as ProcedureSchedulableCallerFromRegistry, lt as CustomBuilder, m as createProcedureHandlerFactory, mt as convexToZod, n as GeneratedProcedureRegistry, nt as HttpProcedureBuilder, o as ProcedureCallerFromRegistry, ot as matchPathParams, p as createProcedureCallerFactory, pt as ZodValidatorFromConvex, q as createServerCaller, r as GeneratedProcedureRegistryEntry, rt as createHttpProcedureBuilder, s as ProcedureDefinition, st as ConvexValidatorFromZod, t as CreateProcedureCallerFactoryOptions, tt as initCRPC, u as ProcedureScheduleCallerFromRegistry, ut as ZCustomCtx, v as inferApiInputs, vt as zCustomMutation, w as getCRPCErrorFromUnknown, wt as zodToConvexFields, x as CRPCErrorCode, xt as zodOutputToConvex, y as inferApiOutputs, yt as zCustomQuery, z as requireRunMutationCtx } from "../procedure-caller-
|
|
2
|
-
import { A as GetRawInputFn, B as Simplify, C as HttpProcedure, D as ProcedureMeta, E as InferHttpInput, F as MiddlewareMarker, I as MiddlewareNext, L as MiddlewareResult, M as MergeZodObjects, N as MiddlewareBuilder, O as AnyMiddleware, P as MiddlewareFunction, R as Overwrite, S as HttpMethod, T as HttpRouteDefinition, V as UnsetMarker, _ as extractRouteMap, b as HttpActionHandler, d as CRPCHttpRouter, f as HttpRouterDef, g as createHttpRouterFactory, h as createHttpRouter, j as IntersectIfDefined, k as AnyMiddlewareBuilder, m as HttpRouterWithHono, p as HttpRouterRecord, v as CRPCHonoHandler, w as HttpProcedureBuilderDef, x as HttpHandlerOpts, y as HttpActionConstructor, z as ResolveIfSet } from "../http-types-
|
|
1
|
+
import { $ as QueryProcedureBuilder, A as GenericCtx, B as ConvexContext, C as CRPC_ERROR_CODE_TO_HTTP, Ct as zodToConvex, D as toCRPCError, E as isCRPCError, F as isRunMutationCtx, G as CallerOpts, H as LazyCaller, I as requireActionCtx, J as createApiLeaf, K as ServerCaller, L as requireMutationCtx, M as isActionCtx, N as isMutationCtx, O as CreateEnvOptions, P as isQueryCtx, Q as ProcedureBuilder, R as requireQueryCtx, S as CRPC_ERROR_CODES_BY_KEY, St as zodOutputToConvexFields, T as getHTTPStatusCodeFromError, U as createLazyCaller, V as createCallerFactory, W as CallerMeta, X as CRPCFunctionTypeHint, Y as ActionProcedureBuilder, Z as MutationProcedureBuilder, _ as WithHttpRouter, _t as zCustomAction, a as ProcedureCaller, at as handleHttpError, b as CRPCError, bt as zid, c as ProcedureFromFunctionReference, ct as ConvexValidatorFromZodOutput, d as createGenericCallerFactory, dt as Zid, et as createMiddlewareFactory, f as createGenericHandlerFactory, ft as ZodFromValidatorBase, g as typedProcedureResolver, gt as withSystemFields, h as defineProcedure, ht as convexToZodFields, i as ProcedureActionCallerFromRegistry, it as extractPathParams, j as RunMutationCtx, k as createEnv, l as ProcedureSchedulableCallerFromRegistry, lt as CustomBuilder, m as createProcedureHandlerFactory, mt as convexToZod, n as GeneratedProcedureRegistry, nt as HttpProcedureBuilder, o as ProcedureCallerFromRegistry, ot as matchPathParams, p as createProcedureCallerFactory, pt as ZodValidatorFromConvex, q as createServerCaller, r as GeneratedProcedureRegistryEntry, rt as createHttpProcedureBuilder, s as ProcedureDefinition, st as ConvexValidatorFromZod, t as CreateProcedureCallerFactoryOptions, tt as initCRPC, u as ProcedureScheduleCallerFromRegistry, ut as ZCustomCtx, v as inferApiInputs, vt as zCustomMutation, w as getCRPCErrorFromUnknown, wt as zodToConvexFields, x as CRPCErrorCode, xt as zodOutputToConvex, y as inferApiOutputs, yt as zCustomQuery, z as requireRunMutationCtx } from "../procedure-caller-Cj_lgUev.js";
|
|
2
|
+
import { A as GetRawInputFn, B as Simplify, C as HttpProcedure, D as ProcedureMeta, E as InferHttpInput, F as MiddlewareMarker, I as MiddlewareNext, L as MiddlewareResult, M as MergeZodObjects, N as MiddlewareBuilder, O as AnyMiddleware, P as MiddlewareFunction, R as Overwrite, S as HttpMethod, T as HttpRouteDefinition, V as UnsetMarker, _ as extractRouteMap, b as HttpActionHandler, d as CRPCHttpRouter, f as HttpRouterDef, g as createHttpRouterFactory, h as createHttpRouter, j as IntersectIfDefined, k as AnyMiddlewareBuilder, m as HttpRouterWithHono, p as HttpRouterRecord, v as CRPCHonoHandler, w as HttpProcedureBuilderDef, x as HttpHandlerOpts, y as HttpActionConstructor, z as ResolveIfSet } from "../http-types-BsnDV7Je.js";
|
|
3
3
|
export { ActionProcedureBuilder, AnyMiddleware, AnyMiddlewareBuilder, CRPCError, CRPCErrorCode, CRPCFunctionTypeHint, CRPCHonoHandler, CRPCHttpRouter, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, CallerMeta, CallerOpts, ConvexContext, ConvexValidatorFromZod, ConvexValidatorFromZodOutput, CreateEnvOptions, CreateProcedureCallerFactoryOptions, CustomBuilder, GeneratedProcedureRegistry, GeneratedProcedureRegistryEntry, GenericCtx, GetRawInputFn, HttpActionConstructor, HttpActionHandler, HttpHandlerOpts, HttpMethod, HttpProcedure, HttpProcedureBuilder, HttpProcedureBuilderDef, HttpRouteDefinition, HttpRouterDef, HttpRouterRecord, HttpRouterWithHono, InferHttpInput, IntersectIfDefined, LazyCaller, MergeZodObjects, MiddlewareBuilder, MiddlewareFunction, MiddlewareMarker, MiddlewareNext, MiddlewareResult, MutationProcedureBuilder, Overwrite, ProcedureActionCallerFromRegistry, ProcedureBuilder, ProcedureCaller, ProcedureCallerFromRegistry, ProcedureDefinition, ProcedureFromFunctionReference, ProcedureMeta, ProcedureSchedulableCallerFromRegistry, ProcedureScheduleCallerFromRegistry, QueryProcedureBuilder, ResolveIfSet, RunMutationCtx, ServerCaller, Simplify, UnsetMarker, WithHttpRouter, ZCustomCtx, Zid, ZodFromValidatorBase, ZodValidatorFromConvex, convexToZod, convexToZodFields, createApiLeaf, createCallerFactory, createEnv, createGenericCallerFactory, createGenericHandlerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createProcedureCallerFactory, createProcedureHandlerFactory, createServerCaller, defineProcedure, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getHTTPStatusCodeFromError, handleHttpError, inferApiInputs, inferApiOutputs, initCRPC, isActionCtx, isCRPCError, isMutationCtx, isQueryCtx, isRunMutationCtx, matchPathParams, requireActionCtx, requireMutationCtx, requireQueryCtx, requireRunMutationCtx, toCRPCError, typedProcedureResolver, withSystemFields, zCustomAction, zCustomMutation, zCustomQuery, zid, zodOutputToConvex, zodOutputToConvexFields, zodToConvex, zodToConvexFields };
|
package/dist/server/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
import {
|
|
1
|
+
import { l as pick, o as vRequired, t as addFieldsToValidator } from "../validators-B7oIJCAp.js";
|
|
2
|
+
import { a as isMutationCtx, c as requireActionCtx, d as requireRunMutationCtx, i as isActionCtx, l as requireMutationCtx, n as customCtx, o as isQueryCtx, s as isRunMutationCtx, t as NoOp, u as requireQueryCtx } from "../customFunctions-C_i_0joT.js";
|
|
3
|
+
import { i as decodeWire, o as encodeWire, s as getTransformer } from "../transformer-BsX4RWes.js";
|
|
4
|
+
import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-4uND4vnj.js";
|
|
4
5
|
import { ConvexError, v } from "convex/values";
|
|
5
6
|
import { HttpRouter, actionGeneric, getFunctionName, httpActionGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, makeFunctionReference, mutationGeneric, queryGeneric } from "convex/server";
|
|
6
7
|
import * as z$1 from "zod/v4";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as DeepPartial, o as Simplify, r as DistributiveOmit } from "./types-
|
|
1
|
+
import { n as DeepPartial, o as Simplify, r as DistributiveOmit } from "./types-kgwiK-xe.js";
|
|
2
2
|
import { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
|
|
3
3
|
import { DefaultError, QueryFilters, SkipToken, UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
|
|
4
4
|
import { Watch, WatchQueryOptions } from "convex/react";
|
|
@@ -82,29 +82,6 @@ function assert(value, message) {
|
|
|
82
82
|
if (!value) throw new Error(typeof message === "function" ? message() : message);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/server/context-utils.ts
|
|
87
|
-
const isQueryCtx = (ctx) => "db" in ctx;
|
|
88
|
-
const isMutationCtx = (ctx) => "db" in ctx && "scheduler" in ctx;
|
|
89
|
-
const isActionCtx = (ctx) => "runAction" in ctx;
|
|
90
|
-
const isRunMutationCtx = (ctx) => "runMutation" in ctx;
|
|
91
|
-
const requireQueryCtx = (ctx) => {
|
|
92
|
-
if (!isQueryCtx(ctx)) throw new Error("Query context required");
|
|
93
|
-
return ctx;
|
|
94
|
-
};
|
|
95
|
-
const requireMutationCtx = (ctx) => {
|
|
96
|
-
if (!isMutationCtx(ctx)) throw new Error("Mutation context required");
|
|
97
|
-
return ctx;
|
|
98
|
-
};
|
|
99
|
-
const requireActionCtx = (ctx) => {
|
|
100
|
-
if (!isActionCtx(ctx)) throw new Error("Action context required");
|
|
101
|
-
return ctx;
|
|
102
|
-
};
|
|
103
|
-
const requireRunMutationCtx = (ctx) => {
|
|
104
|
-
if (!isRunMutationCtx(ctx)) throw new Error("Mutation or action context required");
|
|
105
|
-
return ctx;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
85
|
//#endregion
|
|
109
86
|
//#region src/internal/upstream/validators.ts
|
|
110
87
|
function partial(fieldsOrObjOrUnion) {
|
|
@@ -193,6 +170,72 @@ function intersectValidators(fields, fields2) {
|
|
|
193
170
|
}
|
|
194
171
|
/** Mark fields as deprecated with this permissive validator typed as null */
|
|
195
172
|
const deprecated = v.optional(v.any());
|
|
173
|
+
/** A maximally permissive validator that type checks as a given validator.
|
|
174
|
+
*
|
|
175
|
+
* If you want to have types that match some validator but you have invalid data
|
|
176
|
+
* and you want to temporarily not validate schema for this field,
|
|
177
|
+
* you can use this function to cast the permissive validator.
|
|
178
|
+
*
|
|
179
|
+
* Example in a schema:
|
|
180
|
+
* ```ts
|
|
181
|
+
* export default defineSchema({
|
|
182
|
+
* myTable: defineTable({
|
|
183
|
+
* myString: pretend(v.array(v.string())),
|
|
184
|
+
* }),
|
|
185
|
+
* });
|
|
186
|
+
* //...in some mutation
|
|
187
|
+
* ctx.db.insert("myTable", { myString: 123 as any }); // no runtime error
|
|
188
|
+
* ```
|
|
189
|
+
* Example in function argument validation:
|
|
190
|
+
* ```ts
|
|
191
|
+
* const myQuery = defineQuery({
|
|
192
|
+
* args: { myNumber: pretend(v.number()) },
|
|
193
|
+
* handler: async (ctx, args) => {
|
|
194
|
+
* // args.myNumber is typed as number, but it's not validated.
|
|
195
|
+
* const num = typeof args.myNumber === "number" ?
|
|
196
|
+
* args.myNumber : Number(args.myNumber);
|
|
197
|
+
* },
|
|
198
|
+
* });
|
|
199
|
+
*/
|
|
200
|
+
const pretend = (_typeToImmitate) => v.optional(v.any());
|
|
201
|
+
/** A validator that validates as optional but type checks as required.
|
|
202
|
+
*
|
|
203
|
+
* If you want to assume a field is set for type checking, but your data may not
|
|
204
|
+
* actually have it set for all documents (e.g. when adding a new field),
|
|
205
|
+
* you can use this function to allow the field to be unset at runtime.
|
|
206
|
+
* This is unsafe, but can be convenient in these situations:
|
|
207
|
+
*
|
|
208
|
+
* 1. You are developing locally and want to add a required field and write
|
|
209
|
+
* code assuming it is set. Once you push the code & schema, you can update
|
|
210
|
+
* the data to match before running your code.
|
|
211
|
+
* 2. You are going to run a migration right after pushing code, and are ok with
|
|
212
|
+
* and you don't want to edit your code to handle the field being unset,
|
|
213
|
+
* your app being in an inconsistent state until the migration completes.
|
|
214
|
+
*
|
|
215
|
+
* This differs from {@link pretend} in that it type checks the inner validator,
|
|
216
|
+
* if the value is provided.
|
|
217
|
+
*
|
|
218
|
+
* Example in a schema:
|
|
219
|
+
* ```ts
|
|
220
|
+
* export default defineSchema({
|
|
221
|
+
* myTable: defineTable({
|
|
222
|
+
* myString: pretendRequired(v.array(v.string())),
|
|
223
|
+
* }),
|
|
224
|
+
* });
|
|
225
|
+
* //...in some mutation
|
|
226
|
+
* ctx.db.insert("myTable", { myString: undefined }); // no runtime error
|
|
227
|
+
* ```
|
|
228
|
+
* Example in function argument validation:
|
|
229
|
+
* ```ts
|
|
230
|
+
* const myQuery = defineQuery({
|
|
231
|
+
* args: { myNumber: pretendRequired(v.number()) },
|
|
232
|
+
* handler: async (ctx, args) => {
|
|
233
|
+
* // args.myNumber is typed as number, but it might be undefined
|
|
234
|
+
* const num = args.myNumber || 0;
|
|
235
|
+
* },
|
|
236
|
+
* });
|
|
237
|
+
*/
|
|
238
|
+
const pretendRequired = (optionalType) => v.optional(optionalType);
|
|
196
239
|
/**
|
|
197
240
|
* Converts an optional validator to a required validator.
|
|
198
241
|
*
|
|
@@ -233,145 +276,4 @@ function vRequired(validator) {
|
|
|
233
276
|
}
|
|
234
277
|
|
|
235
278
|
//#endregion
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* A helper for defining a Customization when your mod doesn't need to add or remove
|
|
239
|
-
* anything from args.
|
|
240
|
-
* @param modifyCtx A function that defines how to modify the ctx.
|
|
241
|
-
* @returns A ctx delta to be applied to the original ctx.
|
|
242
|
-
*/
|
|
243
|
-
function customCtx(modifyCtx) {
|
|
244
|
-
return {
|
|
245
|
-
args: {},
|
|
246
|
-
input: async (ctx, _, extra) => ({
|
|
247
|
-
ctx: await modifyCtx(ctx, extra),
|
|
248
|
-
args: {}
|
|
249
|
-
})
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* A Customization that doesn't add or remove any context or args.
|
|
254
|
-
*/
|
|
255
|
-
const NoOp = {
|
|
256
|
-
args: {},
|
|
257
|
-
input() {
|
|
258
|
-
return {
|
|
259
|
-
args: {},
|
|
260
|
-
ctx: {}
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
/**
|
|
265
|
-
* customMutation helps define custom behavior on top of `mutation`
|
|
266
|
-
* or `internalMutation` by passing a function that modifies the ctx and args.
|
|
267
|
-
*
|
|
268
|
-
* Example usage:
|
|
269
|
-
* ```js
|
|
270
|
-
* const myMutationBuilder = customMutation(mutation, {
|
|
271
|
-
* args: { sessionId: v.id("sessions") },
|
|
272
|
-
* input: async (ctx, args) => {
|
|
273
|
-
* const user = await getUserOrNull(ctx);
|
|
274
|
-
* const session = await db.get(sessionId);
|
|
275
|
-
* const db = wrapDatabaseReader({ user }, ctx.db, rlsRules);
|
|
276
|
-
* return {
|
|
277
|
-
* ctx: { db, user, session },
|
|
278
|
-
* args: {},
|
|
279
|
-
* onSuccess: ({ result }) => {
|
|
280
|
-
* // Optional callback that runs after the function executes
|
|
281
|
-
* // Has access to resources created during input processing
|
|
282
|
-
* console.log(`User ${user.name} returned:`, result);
|
|
283
|
-
* }
|
|
284
|
-
* };
|
|
285
|
-
* },
|
|
286
|
-
* });
|
|
287
|
-
*
|
|
288
|
-
* // Using the custom builder
|
|
289
|
-
* export const setSomeData = myMutationBuilder({
|
|
290
|
-
* args: { someArg: v.string() },
|
|
291
|
-
* handler: async (ctx, args) => {
|
|
292
|
-
* const { db, user, session, scheduler } = ctx;
|
|
293
|
-
* const { someArg } = args;
|
|
294
|
-
* // ...
|
|
295
|
-
* }
|
|
296
|
-
* });
|
|
297
|
-
* ```
|
|
298
|
-
*
|
|
299
|
-
* Simple usage only modifying ctx:
|
|
300
|
-
* ```js
|
|
301
|
-
* const myUserMutation = customMutation(
|
|
302
|
-
* mutation,
|
|
303
|
-
* customCtx(async (ctx) => {
|
|
304
|
-
* return {
|
|
305
|
-
* // Throws an exception if the user isn't logged in
|
|
306
|
-
* user: await getUserByTokenIdentifier(ctx),
|
|
307
|
-
* };
|
|
308
|
-
* })
|
|
309
|
-
* );
|
|
310
|
-
*
|
|
311
|
-
* // Using it
|
|
312
|
-
* export const setMyName = myUserMutation({
|
|
313
|
-
* args: { name: v.string() },
|
|
314
|
-
* handler: async (ctx, args) => {
|
|
315
|
-
* await ctx.db.patch(ctx.user._id, { name: args.name });
|
|
316
|
-
* },
|
|
317
|
-
* });
|
|
318
|
-
*
|
|
319
|
-
* @param mutation The mutation to be modified. Usually `mutation` or `internalMutation`
|
|
320
|
-
* from `_generated/server`.
|
|
321
|
-
* @param customization The modifier to be applied to the mutation, changing ctx and args.
|
|
322
|
-
* @returns A new mutation builder to define queries with modified ctx and args.
|
|
323
|
-
*/
|
|
324
|
-
function customMutation(mutation, customization) {
|
|
325
|
-
return customFnBuilder(mutation, customization);
|
|
326
|
-
}
|
|
327
|
-
function customFnBuilder(builder, customization) {
|
|
328
|
-
const customInput = customization.input ?? NoOp.input;
|
|
329
|
-
const inputArgs = customization.args ?? NoOp.args;
|
|
330
|
-
return function customBuilder(fn) {
|
|
331
|
-
const { args, handler = fn, returns, ...extra } = fn;
|
|
332
|
-
if (args) return builder({
|
|
333
|
-
args: addFieldsToValidator(args, inputArgs),
|
|
334
|
-
returns,
|
|
335
|
-
handler: async (ctx, allArgs) => {
|
|
336
|
-
const added = await customInput(ctx, pick(allArgs, Object.keys(inputArgs)), extra);
|
|
337
|
-
const args = omit(allArgs, Object.keys(inputArgs));
|
|
338
|
-
const result = await handler({
|
|
339
|
-
...ctx,
|
|
340
|
-
...added.ctx
|
|
341
|
-
}, {
|
|
342
|
-
...args,
|
|
343
|
-
...added.args
|
|
344
|
-
});
|
|
345
|
-
if (added.onSuccess) await added.onSuccess({
|
|
346
|
-
ctx,
|
|
347
|
-
args,
|
|
348
|
-
result
|
|
349
|
-
});
|
|
350
|
-
return result;
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
if (Object.keys(inputArgs).length > 0) throw new Error("If you're using a custom function with arguments for the input customization, you must declare the arguments for the function too.");
|
|
354
|
-
return builder({
|
|
355
|
-
returns: fn.returns,
|
|
356
|
-
handler: async (ctx, args) => {
|
|
357
|
-
const added = await customInput(ctx, args, extra);
|
|
358
|
-
const result = await handler({
|
|
359
|
-
...ctx,
|
|
360
|
-
...added.ctx
|
|
361
|
-
}, {
|
|
362
|
-
...args,
|
|
363
|
-
...added.args
|
|
364
|
-
});
|
|
365
|
-
if (added.onSuccess) await added.onSuccess({
|
|
366
|
-
ctx,
|
|
367
|
-
args,
|
|
368
|
-
result
|
|
369
|
-
});
|
|
370
|
-
return result;
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
//#endregion
|
|
377
|
-
export { partial as a, isMutationCtx as c, requireActionCtx as d, requireMutationCtx as f, pick as g, asyncMap as h, addFieldsToValidator as i, isQueryCtx as l, requireRunMutationCtx as m, customCtx as n, vRequired as o, requireQueryCtx as p, customMutation as r, isActionCtx as s, NoOp as t, isRunMutationCtx as u };
|
|
279
|
+
export { pretendRequired as a, omit as c, pretend as i, pick as l, deprecated as n, vRequired as o, partial as r, asyncMap as s, addFieldsToValidator as t };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { GenericId, GenericValidator, Infer, ObjectType, OptionalProperty, PropertyValidators, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VOptional, VRecord, VString, VUnion, Validator, v } from "convex/values";
|
|
2
|
+
import { GenericDataModel, GenericDatabaseReader, SchemaDefinition, TableNamesInDataModel } from "convex/server";
|
|
3
|
+
|
|
4
|
+
//#region src/internal/upstream/validators.d.ts
|
|
5
|
+
/** Mark fields as deprecated with this permissive validator typed as null */
|
|
6
|
+
declare const deprecated: Validator<null, "optional">;
|
|
7
|
+
/** A maximally permissive validator that type checks as a given validator.
|
|
8
|
+
*
|
|
9
|
+
* If you want to have types that match some validator but you have invalid data
|
|
10
|
+
* and you want to temporarily not validate schema for this field,
|
|
11
|
+
* you can use this function to cast the permissive validator.
|
|
12
|
+
*
|
|
13
|
+
* Example in a schema:
|
|
14
|
+
* ```ts
|
|
15
|
+
* export default defineSchema({
|
|
16
|
+
* myTable: defineTable({
|
|
17
|
+
* myString: pretend(v.array(v.string())),
|
|
18
|
+
* }),
|
|
19
|
+
* });
|
|
20
|
+
* //...in some mutation
|
|
21
|
+
* ctx.db.insert("myTable", { myString: 123 as any }); // no runtime error
|
|
22
|
+
* ```
|
|
23
|
+
* Example in function argument validation:
|
|
24
|
+
* ```ts
|
|
25
|
+
* const myQuery = defineQuery({
|
|
26
|
+
* args: { myNumber: pretend(v.number()) },
|
|
27
|
+
* handler: async (ctx, args) => {
|
|
28
|
+
* // args.myNumber is typed as number, but it's not validated.
|
|
29
|
+
* const num = typeof args.myNumber === "number" ?
|
|
30
|
+
* args.myNumber : Number(args.myNumber);
|
|
31
|
+
* },
|
|
32
|
+
* });
|
|
33
|
+
*/
|
|
34
|
+
declare const pretend: <T extends GenericValidator>(_typeToImmitate: T) => T;
|
|
35
|
+
/** A validator that validates as optional but type checks as required.
|
|
36
|
+
*
|
|
37
|
+
* If you want to assume a field is set for type checking, but your data may not
|
|
38
|
+
* actually have it set for all documents (e.g. when adding a new field),
|
|
39
|
+
* you can use this function to allow the field to be unset at runtime.
|
|
40
|
+
* This is unsafe, but can be convenient in these situations:
|
|
41
|
+
*
|
|
42
|
+
* 1. You are developing locally and want to add a required field and write
|
|
43
|
+
* code assuming it is set. Once you push the code & schema, you can update
|
|
44
|
+
* the data to match before running your code.
|
|
45
|
+
* 2. You are going to run a migration right after pushing code, and are ok with
|
|
46
|
+
* and you don't want to edit your code to handle the field being unset,
|
|
47
|
+
* your app being in an inconsistent state until the migration completes.
|
|
48
|
+
*
|
|
49
|
+
* This differs from {@link pretend} in that it type checks the inner validator,
|
|
50
|
+
* if the value is provided.
|
|
51
|
+
*
|
|
52
|
+
* Example in a schema:
|
|
53
|
+
* ```ts
|
|
54
|
+
* export default defineSchema({
|
|
55
|
+
* myTable: defineTable({
|
|
56
|
+
* myString: pretendRequired(v.array(v.string())),
|
|
57
|
+
* }),
|
|
58
|
+
* });
|
|
59
|
+
* //...in some mutation
|
|
60
|
+
* ctx.db.insert("myTable", { myString: undefined }); // no runtime error
|
|
61
|
+
* ```
|
|
62
|
+
* Example in function argument validation:
|
|
63
|
+
* ```ts
|
|
64
|
+
* const myQuery = defineQuery({
|
|
65
|
+
* args: { myNumber: pretendRequired(v.number()) },
|
|
66
|
+
* handler: async (ctx, args) => {
|
|
67
|
+
* // args.myNumber is typed as number, but it might be undefined
|
|
68
|
+
* const num = args.myNumber || 0;
|
|
69
|
+
* },
|
|
70
|
+
* });
|
|
71
|
+
*/
|
|
72
|
+
declare const pretendRequired: <T extends Validator<any, "required", any>>(optionalType: T) => T;
|
|
73
|
+
type NotUndefined<T> = Exclude<T, undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* A type that converts an optional validator to a required validator.
|
|
76
|
+
*
|
|
77
|
+
* This is the inverse of `VOptional`. It takes a validator that may be optional
|
|
78
|
+
* and returns the equivalent required validator type.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* type OptionalString = VOptional<VString<string, "required">>;
|
|
83
|
+
* type RequiredString = VRequired<OptionalString>; // VString<string, "required">
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
type VRequired<T extends Validator<any, OptionalProperty, any>> = T extends VId<infer Type, OptionalProperty> ? VId<NotUndefined<Type>, 'required'> : T extends VString<infer Type, OptionalProperty> ? VString<NotUndefined<Type>, 'required'> : T extends VFloat64<infer Type, OptionalProperty> ? VFloat64<NotUndefined<Type>, 'required'> : T extends VInt64<infer Type, OptionalProperty> ? VInt64<NotUndefined<Type>, 'required'> : T extends VBoolean<infer Type, OptionalProperty> ? VBoolean<NotUndefined<Type>, 'required'> : T extends VNull<infer Type, OptionalProperty> ? VNull<NotUndefined<Type>, 'required'> : T extends VAny<infer Type, OptionalProperty> ? VAny<NotUndefined<Type>, 'required'> : T extends VLiteral<infer Type, OptionalProperty> ? VLiteral<NotUndefined<Type>, 'required'> : T extends VBytes<infer Type, OptionalProperty> ? VBytes<NotUndefined<Type>, 'required'> : T extends VObject<infer Type, infer Fields, OptionalProperty, infer FieldPaths> ? VObject<NotUndefined<Type>, Fields, 'required', FieldPaths> : T extends VArray<infer Type, infer Element, OptionalProperty> ? VArray<NotUndefined<Type>, Element, 'required'> : T extends VRecord<infer Type, infer Key, infer Value, OptionalProperty, infer FieldPaths> ? VRecord<NotUndefined<Type>, Key, Value, 'required', FieldPaths> : T extends VUnion<infer Type, infer Members, OptionalProperty, infer FieldPaths> ? VUnion<NotUndefined<Type>, Members, 'required', FieldPaths> : never;
|
|
87
|
+
//#endregion
|
|
88
|
+
export { pretendRequired as i, deprecated as n, pretend as r, VRequired as t };
|
package/dist/watcher.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ReturnTypeOrValue, i as KnownKeysOnly, o as Simplify, t as Assume } from "./types-
|
|
1
|
+
import { a as ReturnTypeOrValue, i as KnownKeysOnly, o as Simplify, t as Assume } from "./types-kgwiK-xe.js";
|
|
2
2
|
import * as convex_values0 from "convex/values";
|
|
3
3
|
import { GenericId, Validator, Value } from "convex/values";
|
|
4
4
|
import { DefineSchemaOptions, FilterExpression, GenericDatabaseReader, GenericDatabaseWriter, GenericIndexFields, GenericSchema, GenericTableIndexes, GenericTableSearchIndexes, GenericTableVectorIndexes, IndexRange, IndexRangeBuilder, SchedulableFunctionReference, Scheduler, SchemaDefinition, TableDefinition, VectorFilterBuilder, internalActionGeneric, internalMutationGeneric } from "convex/server";
|
|
@@ -3195,6 +3195,104 @@ type CreateDatabaseOptions = {
|
|
|
3195
3195
|
};
|
|
3196
3196
|
};
|
|
3197
3197
|
//#endregion
|
|
3198
|
+
//#region src/orm/migrations/definitions.d.ts
|
|
3199
|
+
type MigrationDirection = 'up' | 'down';
|
|
3200
|
+
type MigrationRunStatus = 'pending' | 'running' | 'completed' | 'failed' | 'canceled' | 'dry_run' | 'noop';
|
|
3201
|
+
type MigrationWriteMode = 'safe_bypass' | 'normal';
|
|
3202
|
+
type MigrationTableName<TSchema extends TablesRelationalConfig = TablesRelationalConfig> = { [K in keyof TSchema]-?: TSchema[K] extends TableRelationalConfig ? TSchema[K]['name'] : never }[keyof TSchema] & string;
|
|
3203
|
+
type MigrationTableConfigByName<TSchema extends TablesRelationalConfig, TTableName extends MigrationTableName<TSchema>> = { [K in keyof TSchema]-?: TSchema[K] extends TableRelationalConfig ? TSchema[K]['name'] extends TTableName ? TSchema[K] : never : never }[keyof TSchema];
|
|
3204
|
+
type MigrationDoc<TSchema extends TablesRelationalConfig = TablesRelationalConfig, TTableName extends MigrationTableName<TSchema> = MigrationTableName<TSchema>> = MigrationTableConfigByName<TSchema, TTableName> extends TableRelationalConfig ? Partial<InferSelectModel<MigrationTableConfigByName<TSchema, TTableName>['table']>> & Record<string, unknown> : Record<string, unknown>;
|
|
3205
|
+
type MigrationDocContext<TSchema extends TablesRelationalConfig = TablesRelationalConfig> = {
|
|
3206
|
+
db: GenericDatabaseWriter<any>;
|
|
3207
|
+
orm: OrmWriter<TSchema>;
|
|
3208
|
+
migrationId: string;
|
|
3209
|
+
runId: string;
|
|
3210
|
+
direction: MigrationDirection;
|
|
3211
|
+
dryRun: boolean;
|
|
3212
|
+
writeMode: MigrationWriteMode;
|
|
3213
|
+
};
|
|
3214
|
+
type MigrationMigrateOne<TSchema extends TablesRelationalConfig = TablesRelationalConfig, TTableName extends MigrationTableName<TSchema> = MigrationTableName<TSchema>> = (ctx: MigrationDocContext<TSchema>, doc: MigrationDoc<TSchema, TTableName>) => Promise<unknown> | unknown;
|
|
3215
|
+
type MigrationStepByTable<TSchema extends TablesRelationalConfig = TablesRelationalConfig, TTableName extends MigrationTableName<TSchema> = MigrationTableName<TSchema>> = {
|
|
3216
|
+
table: TTableName;
|
|
3217
|
+
batchSize?: number;
|
|
3218
|
+
writeMode?: MigrationWriteMode;
|
|
3219
|
+
migrateOne: MigrationMigrateOne<TSchema, TTableName>;
|
|
3220
|
+
};
|
|
3221
|
+
type MigrationStep<TSchema extends TablesRelationalConfig = TablesRelationalConfig> = { [TTableName in MigrationTableName<TSchema>]: MigrationStepByTable<TSchema, TTableName> }[MigrationTableName<TSchema>];
|
|
3222
|
+
type MigrationDefinition<TSchema extends TablesRelationalConfig = TablesRelationalConfig> = {
|
|
3223
|
+
id: string;
|
|
3224
|
+
name?: string;
|
|
3225
|
+
description?: string;
|
|
3226
|
+
up: MigrationStep<TSchema>;
|
|
3227
|
+
down?: MigrationStep<TSchema>;
|
|
3228
|
+
checksum?: string;
|
|
3229
|
+
};
|
|
3230
|
+
type MigrationManifestEntry<TSchema extends TablesRelationalConfig = TablesRelationalConfig> = MigrationDefinition<TSchema> & {
|
|
3231
|
+
checksum: string;
|
|
3232
|
+
};
|
|
3233
|
+
type MigrationSet<TSchema extends TablesRelationalConfig = TablesRelationalConfig> = {
|
|
3234
|
+
migrations: readonly MigrationManifestEntry<TSchema>[];
|
|
3235
|
+
ids: readonly string[];
|
|
3236
|
+
byId: Readonly<Record<string, MigrationManifestEntry<TSchema>>>;
|
|
3237
|
+
};
|
|
3238
|
+
type MigrationAppliedState = {
|
|
3239
|
+
applied: boolean;
|
|
3240
|
+
checksum?: string;
|
|
3241
|
+
cursor?: string | null;
|
|
3242
|
+
processed?: number;
|
|
3243
|
+
};
|
|
3244
|
+
type MigrationStateMap = Readonly<Record<string, MigrationAppliedState>>;
|
|
3245
|
+
type MigrationDriftIssue = {
|
|
3246
|
+
kind: 'missing_from_manifest';
|
|
3247
|
+
migrationId: string;
|
|
3248
|
+
message: string;
|
|
3249
|
+
} | {
|
|
3250
|
+
kind: 'checksum_mismatch';
|
|
3251
|
+
migrationId: string;
|
|
3252
|
+
message: string;
|
|
3253
|
+
expectedChecksum: string;
|
|
3254
|
+
actualChecksum: string;
|
|
3255
|
+
};
|
|
3256
|
+
type MigrationPlan<TSchema extends TablesRelationalConfig = TablesRelationalConfig> = {
|
|
3257
|
+
direction: MigrationDirection;
|
|
3258
|
+
migrations: readonly MigrationManifestEntry<TSchema>[];
|
|
3259
|
+
};
|
|
3260
|
+
declare function defineMigration<TSchema extends TablesRelationalConfig = TablesRelationalConfig>(migration: MigrationDefinition<TSchema>): MigrationDefinition<TSchema>;
|
|
3261
|
+
declare function defineMigrationSet<TSchema extends TablesRelationalConfig = TablesRelationalConfig>(migrations: readonly MigrationDefinition<TSchema>[]): MigrationSet<TSchema>;
|
|
3262
|
+
declare function detectMigrationDrift<TSchema extends TablesRelationalConfig = TablesRelationalConfig>(params: {
|
|
3263
|
+
migrationSet: MigrationSet<TSchema>;
|
|
3264
|
+
appliedState: MigrationStateMap;
|
|
3265
|
+
}): MigrationDriftIssue[];
|
|
3266
|
+
declare function buildMigrationPlan<TSchema extends TablesRelationalConfig = TablesRelationalConfig>(params: {
|
|
3267
|
+
direction: MigrationDirection;
|
|
3268
|
+
migrationSet: MigrationSet<TSchema>;
|
|
3269
|
+
appliedState: MigrationStateMap;
|
|
3270
|
+
steps?: number;
|
|
3271
|
+
to?: string;
|
|
3272
|
+
}): MigrationPlan<TSchema>;
|
|
3273
|
+
//#endregion
|
|
3274
|
+
//#region src/orm/migrations/runtime.d.ts
|
|
3275
|
+
type MigrationRunArgs = {
|
|
3276
|
+
direction?: MigrationDirection;
|
|
3277
|
+
steps?: number;
|
|
3278
|
+
to?: string;
|
|
3279
|
+
dryRun?: boolean;
|
|
3280
|
+
allowDrift?: boolean;
|
|
3281
|
+
batchSize?: number;
|
|
3282
|
+
restart?: boolean;
|
|
3283
|
+
};
|
|
3284
|
+
type MigrationRunChunkArgs = {
|
|
3285
|
+
runId: string;
|
|
3286
|
+
batchSize?: number;
|
|
3287
|
+
};
|
|
3288
|
+
type MigrationStatusArgs = {
|
|
3289
|
+
runId?: string;
|
|
3290
|
+
limit?: number;
|
|
3291
|
+
};
|
|
3292
|
+
type MigrationCancelArgs = {
|
|
3293
|
+
runId?: string;
|
|
3294
|
+
};
|
|
3295
|
+
//#endregion
|
|
3198
3296
|
//#region src/orm/triggers.d.ts
|
|
3199
3297
|
type MaybePromise<T> = T | Promise<T>;
|
|
3200
3298
|
type AnyRecord = Record<string, unknown>;
|
|
@@ -3286,6 +3384,7 @@ type OrmFunctions = {
|
|
|
3286
3384
|
scheduledMutationBatch: SchedulableFunctionReference;
|
|
3287
3385
|
scheduledDelete: SchedulableFunctionReference;
|
|
3288
3386
|
aggregateBackfillChunk?: SchedulableFunctionReference;
|
|
3387
|
+
migrationRunChunk?: SchedulableFunctionReference;
|
|
3289
3388
|
resetChunk?: SchedulableFunctionReference;
|
|
3290
3389
|
};
|
|
3291
3390
|
type CreateOrmOptions = CreateDatabaseOptions;
|
|
@@ -3314,6 +3413,7 @@ type GenericOrmCtx<Ctx extends {
|
|
|
3314
3413
|
type CreateOrmConfigBase<TSchema extends TablesRelationalConfig> = {
|
|
3315
3414
|
schema: TSchema;
|
|
3316
3415
|
triggers?: OrmTriggers<TSchema, any>;
|
|
3416
|
+
migrations?: MigrationSet<any>;
|
|
3317
3417
|
internalMutation?: typeof internalMutationGeneric;
|
|
3318
3418
|
};
|
|
3319
3419
|
type CreateOrmConfigWithFunctions<TSchema extends TablesRelationalConfig> = CreateOrmConfigBase<TSchema> & {
|
|
@@ -3329,6 +3429,10 @@ type OrmApiResult = {
|
|
|
3329
3429
|
aggregateBackfill: ReturnType<typeof internalMutationGeneric>;
|
|
3330
3430
|
aggregateBackfillChunk: ReturnType<typeof internalMutationGeneric>;
|
|
3331
3431
|
aggregateBackfillStatus: ReturnType<typeof internalMutationGeneric>;
|
|
3432
|
+
migrationRun: ReturnType<typeof internalMutationGeneric>;
|
|
3433
|
+
migrationRunChunk: ReturnType<typeof internalMutationGeneric>;
|
|
3434
|
+
migrationStatus: ReturnType<typeof internalMutationGeneric>;
|
|
3435
|
+
migrationCancel: ReturnType<typeof internalMutationGeneric>;
|
|
3332
3436
|
resetChunk: ReturnType<typeof internalMutationGeneric>;
|
|
3333
3437
|
reset: ReturnType<typeof internalActionGeneric>;
|
|
3334
3438
|
};
|
|
@@ -3460,4 +3564,4 @@ interface IndexLike {
|
|
|
3460
3564
|
indexName: string;
|
|
3461
3565
|
}
|
|
3462
3566
|
//#endregion
|
|
3463
|
-
export {
|
|
3567
|
+
export { DatabaseWithQuery as $, FilterOperators as $n, Columns as $r, defineRelations as $t, MigrationRunArgs as A, index as An, and as Ar, ConvexCustomBuilderInitial as At, MigrationMigrateOne as B, ConvexUniqueConstraintBuilderOn as Bn, isFieldReference as Br, ConvexBigIntBuilderInitial as Bt, OrmBeforeResult as C, ConvexSearchIndexBuilder as Cn, unsetToken as Cr, ConvexIdBuilderInitial as Ct, OrmTriggers as D, ConvexVectorIndexBuilderOn as Dn, FilterExpression$1 as Dr, ConvexDateMode as Dt, OrmTriggerContext as E, ConvexVectorIndexBuilder as En, FieldReference as Er, ConvexDateBuilderInitial as Et, MigrationDirection as F, ConvexCheckBuilder as Fn, fieldRef as Fr, bytes as Ft, MigrationStep as G, AggregateConfig as Gn, lte as Gr, ExtractTablesWithRelations as Gt, MigrationRunStatus as H, check as Hn, isNull as Hr, CountBackfillChunkArgs as Ht, MigrationDoc as I, ConvexCheckConfig as In, gt as Ir, ConvexBooleanBuilder as It, buildMigrationPlan as J, BuildQueryResult as Jn, notBetween as Jr, RelationsBuilder as Jt, MigrationTableName as K, AggregateFieldValue as Kn, ne as Kr, ManyConfig as Kt, MigrationDocContext as L, ConvexForeignKeyBuilder as Ln, gte as Lr, ConvexBooleanBuilderInitial as Lt, MigrationStatusArgs as M, searchIndex as Mn, contains as Mr, json as Mt, MigrationAppliedState as N, uniqueIndex as Nn, endsWith as Nr, ConvexBytesBuilder as Nt, defineTriggers as O, ConvexVectorIndexConfig as On, LogicalExpression as Or, date as Ot, MigrationDefinition as P, vectorIndex as Pn, eq as Pr, ConvexBytesBuilderInitial as Pt, DatabaseWithMutations as Q, DBQueryConfig as Qn, Brand as Qr, TablesRelationalConfig as Qt, MigrationDriftIssue as R, ConvexForeignKeyConfig as Rn, ilike as Rr, boolean as Rt, scheduledDeleteFactory as S, ConvexRankIndexBuilderOn as Sn, VectorSearchProvider as Sr, ConvexIdBuilder as St, OrmTriggerChange as T, ConvexSearchIndexConfig as Tn, ExpressionVisitor as Tr, ConvexDateBuilder as Tt, MigrationSet as U, foreignKey as Un, like as Ur, CountBackfillKickoffArgs as Ut, MigrationPlan as V, ConvexUniqueConstraintConfig as Vn, isNotNull as Vr, bigint as Vt, MigrationStateMap as W, unique as Wn, lt as Wr, CountBackfillStatusArgs as Wt, defineMigrationSet as X, CountConfig as Xn, or as Xr, RelationsBuilderColumnConfig as Xt, defineMigration as Y, BuildRelationResult as Yn, notInArray as Yr, RelationsBuilderColumnBase as Yt, detectMigrationDrift as Z, CountResult as Zn, startsWith as Zr, TableRelationalConfig as Zt, OrmWriterCtx as _, ConvexAggregateIndexBuilder as _n, ReturningAll as _r, ConvexTextBuilderInitial as _t, TableConfigResult as a, ColumnBuilderRuntimeConfig as ai, OrmLifecycleChange as an, MutationExecuteConfig as ar, extractRelationsConfig as at, scheduledMutationBatchFactory as b, ConvexIndexBuilderOn as bn, UpdateSet as br, ConvexNumberBuilderInitial as bt, OrmNotFoundError as c, ColumnDataType as ci, convexTable as cn, MutationPaginateConfig as cr, vector as ct, GenericOrmCtx as d, IsPrimaryKey as di, RlsPolicyConfig as dn, MutationReturning as dr, ConvexTimestampMode as dt, TableName as ei, defineRelationsPart as en, GetColumnData as er, OrmReader as et, OrmApiResult as f, IsUnique as fi, RlsPolicyToOption as fn, MutationRunMode as fr, timestamp as ft, OrmReaderCtx as g, rlsRole as gn, PredicateWhereIndexConfig as gr, ConvexTextBuilder as gt, OrmFunctions as h, RlsRoleConfig as hn, PaginatedResult as hr, textEnum as ht, desc as i, ColumnBuilderBaseConfig as ii, ConvexTableWithColumns as in, InsertValue as ir, EdgeMetadata as it, MigrationRunChunkArgs as j, rankIndex as jn, between as jr, custom as jt, MigrationCancelArgs as k, aggregateIndex as kn, UnaryExpression as kr, ConvexCustomBuilder as kt, CreateOrmOptions as l, DrizzleEntity as li, deletion as ln, MutationPaginatedResult as lr, ConvexTimestampBuilder as lt, OrmClientWithApi as m, RlsRole as mn, OrderDirection as mr, ConvexTextEnumBuilderInitial as mt, defineSchema$1 as n, AnyColumn as ni, ConvexDeletionConfig as nn, InferModelFromColumns as nr, RlsContext as nt, getTableColumns as o, ColumnBuilderTypeConfig as oi, OrmLifecycleOperation as on, MutationExecuteResult as or, ConvexVectorBuilder as ot, OrmClientBase as p, NotNull as pi, rlsPolicy as pn, OrderByClause as pr, ConvexTextEnumBuilder as pt, MigrationWriteMode as q, AggregateResult as qn, not as qr, OneConfig as qt, asc as r, ColumnBuilder as ri, ConvexTable as rn, InferSelectModel as rr, RlsMode as rt, getTableConfig as s, ColumnBuilderWithTableName as si, TableConfig as sn, MutationExecutionMode as sr, ConvexVectorBuilderInitial as st, WhereClauseResult as t, SystemFields as ti, ConvexDeletionBuilder as tn, InferInsertModel as tr, OrmWriter as tt, GenericOrm as u, HasDefault as ui, RlsPolicy as un, MutationResult as ur, ConvexTimestampBuilderInitial as ut, createOrm as v, ConvexAggregateIndexBuilderOn as vn, ReturningResult as vr, text as vt, OrmTableTriggers as w, ConvexSearchIndexBuilderOn as wn, BinaryExpression as wr, id as wt, ScheduledDeleteArgs as x, ConvexRankIndexBuilder as xn, VectorQueryConfig as xr, integer as xt, ScheduledMutationBatchArgs as y, ConvexIndexBuilder as yn, ReturningSelection as yr, ConvexNumberBuilder as yt, MigrationManifestEntry as z, ConvexUniqueConstraintBuilder as zn, inArray as zr, ConvexBigIntBuilder as zt };
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|