better-convex 0.7.3 → 0.8.0
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/aggregate/index.js +1 -1
- package/dist/auth/http/index.d.ts +1 -1
- package/dist/auth/index.d.ts +10 -10
- package/dist/auth/index.js +5 -5
- package/dist/auth/nextjs/index.d.ts +2 -2
- package/dist/auth/nextjs/index.js +2 -2
- package/dist/{caller-factory-4uND4vnj.js → caller-factory-CCsm4Dut.js} +2 -2
- package/dist/cli.mjs +1 -0
- package/dist/{create-schema-orm-DtuyK2RB.js → create-schema-orm-OcyA0apQ.js} +10 -13
- package/dist/crpc/index.d.ts +2 -2
- package/dist/crpc/index.js +3 -3
- package/dist/{customFunctions-C_i_0joT.js → customFunctions-RnzME_cJ.js} +1 -1
- package/dist/{http-types-BsnDV7Je.d.ts → http-types-BK7FuIcR.d.ts} +1 -1
- package/dist/id-BcBb900m.js +121 -0
- package/dist/orm/index.d.ts +4 -4
- package/dist/orm/index.js +60 -222
- package/dist/plugins/index.d.ts +9 -0
- package/dist/plugins/index.js +3 -0
- package/dist/plugins/ratelimit/index.d.ts +222 -0
- package/dist/plugins/ratelimit/index.js +846 -0
- package/dist/plugins/ratelimit/react/index.d.ts +76 -0
- package/dist/plugins/ratelimit/react/index.js +294 -0
- package/dist/{procedure-caller-Cj_lgUev.d.ts → procedure-caller-DYjpq7rG.d.ts} +2 -2
- package/dist/rsc/index.d.ts +3 -3
- package/dist/rsc/index.js +4 -4
- package/dist/runtime-C0WcYGY0.js +1028 -0
- package/dist/schema-Bx6j2doh.js +204 -0
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +4 -4
- package/dist/{runtime-B9xQFY8W.js → table-B7yzBihE.js} +3 -1088
- package/dist/text-enum-CFdcLUuw.js +30 -0
- package/dist/{types-DZFvhoPJ.d.ts → types-f53SgpBL.d.ts} +1 -1
- package/dist/{where-clause-compiler-HUa2223D.d.ts → where-clause-compiler-BIjTkVVJ.d.ts} +34 -2
- package/package.json +4 -1
- /package/dist/{create-schema-DE9ZtH8n.js → create-schema-BsN0jL5S.js} +0 -0
- /package/dist/{error-C7AOPlv2.js → error-CAGGSN5H.js} +0 -0
- /package/dist/{meta-utils-C9_6WIzj.js → meta-utils-NRyocOSc.js} +0 -0
- /package/dist/{query-context-yQVARct0.js → query-context-DEUFBhXS.js} +0 -0
- /package/dist/{query-context-BMXt2TKe.d.ts → query-context-ji7By8u0.d.ts} +0 -0
- /package/dist/{query-options-Bjo6j5cC.js → query-options-CSCmKYdJ.js} +0 -0
- /package/dist/{transformer-BsX4RWes.js → transformer-ogg-4d78.js} +0 -0
- /package/dist/{types-kgwiK-xe.d.ts → types-BTb_4BaU.d.ts} +0 -0
- /package/dist/{types-DarApWtO.d.ts → types-CM67ko7K.d.ts} +0 -0
- /package/dist/{validators-BDrWGp4M.d.ts → validators-BcQFm1oY.d.ts} +0 -0
- /package/dist/{validators-B7oIJCAp.js → validators-D_i3BK7v.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { T as entityKind, w as ConvexColumnBuilder } from "./table-B7yzBihE.js";
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
|
|
4
|
+
//#region src/orm/builders/text-enum.ts
|
|
5
|
+
var ConvexTextEnumBuilder = class extends ConvexColumnBuilder {
|
|
6
|
+
static [entityKind] = "ConvexTextEnumBuilder";
|
|
7
|
+
constructor(name, values) {
|
|
8
|
+
super(name, "string", "ConvexText");
|
|
9
|
+
this.config.values = [...values];
|
|
10
|
+
}
|
|
11
|
+
_enumValidator() {
|
|
12
|
+
const literals = this.config.values.map((value) => v.literal(value));
|
|
13
|
+
if (literals.length === 1) return literals[0];
|
|
14
|
+
return v.union(...literals);
|
|
15
|
+
}
|
|
16
|
+
get convexValidator() {
|
|
17
|
+
const base = this._enumValidator();
|
|
18
|
+
if (this.config.notNull) return base;
|
|
19
|
+
return v.optional(v.union(v.null(), base));
|
|
20
|
+
}
|
|
21
|
+
build() {
|
|
22
|
+
return this.convexValidator;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
function textEnum(values) {
|
|
26
|
+
return new ConvexTextEnumBuilder("", values);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { textEnum as t };
|
|
@@ -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-BTb_4BaU.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";
|
|
@@ -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-BTb_4BaU.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";
|
|
@@ -336,6 +336,11 @@ type OrmTableDeleteConfig = {
|
|
|
336
336
|
mode: OrmDeleteMode;
|
|
337
337
|
delayMs?: number;
|
|
338
338
|
};
|
|
339
|
+
type OrmSchemaPlugin = {
|
|
340
|
+
key: string;
|
|
341
|
+
tableNames: readonly string[];
|
|
342
|
+
inject: <TSchema extends Record<string, unknown>>(schema: TSchema) => TSchema & Record<string, unknown>;
|
|
343
|
+
};
|
|
339
344
|
declare const TableName: unique symbol;
|
|
340
345
|
declare const Columns: unique symbol;
|
|
341
346
|
declare const Brand: unique symbol;
|
|
@@ -343,6 +348,7 @@ declare const RlsPolicies: unique symbol;
|
|
|
343
348
|
declare const EnableRLS: unique symbol;
|
|
344
349
|
declare const TableDeleteConfig: unique symbol;
|
|
345
350
|
declare const OrmSchemaDefinition: unique symbol;
|
|
351
|
+
declare const OrmSchemaPluginTables: unique symbol;
|
|
346
352
|
//#endregion
|
|
347
353
|
//#region src/orm/filter-expression.d.ts
|
|
348
354
|
/**
|
|
@@ -2071,6 +2077,19 @@ declare function bytes<TName extends string>(name: TName): ConvexBytesBuilderIni
|
|
|
2071
2077
|
//#endregion
|
|
2072
2078
|
//#region src/orm/builders/custom.d.ts
|
|
2073
2079
|
type AnyValidator = Validator<any, any, any>;
|
|
2080
|
+
type AnyColumnBuilder = ColumnBuilder<any, any, any>;
|
|
2081
|
+
interface NestedShapeInput {
|
|
2082
|
+
[key: string]: NestedInput;
|
|
2083
|
+
}
|
|
2084
|
+
type NestedInput = AnyValidator | AnyColumnBuilder | NestedShapeInput;
|
|
2085
|
+
type InferBuilderNestedValue<TBuilder extends AnyColumnBuilder> = TBuilder['_'] extends {
|
|
2086
|
+
$type: infer TType;
|
|
2087
|
+
} ? TType : TBuilder['_'] extends {
|
|
2088
|
+
data: infer TData;
|
|
2089
|
+
} ? TData : never;
|
|
2090
|
+
type InferValidatorNestedValue<TValidator extends AnyValidator> = Exclude<TValidator['type'], undefined>;
|
|
2091
|
+
type InferNestedValue<TInput extends NestedInput> = TInput extends AnyColumnBuilder ? InferBuilderNestedValue<TInput> : TInput extends AnyValidator ? InferValidatorNestedValue<TInput> : TInput extends NestedShapeInput ? InferObjectShape<TInput> : never;
|
|
2092
|
+
type InferObjectShape<TShape extends NestedShapeInput> = { [K in keyof TShape]: InferNestedValue<TShape[K]> };
|
|
2074
2093
|
type ConvexCustomBuilderInitial<TName extends string, TValidator extends AnyValidator> = ConvexCustomBuilder<{
|
|
2075
2094
|
name: TName;
|
|
2076
2095
|
dataType: 'any';
|
|
@@ -2089,6 +2108,18 @@ declare class ConvexCustomBuilder<T extends ColumnBuilderBaseConfig<'any', 'Conv
|
|
|
2089
2108
|
}
|
|
2090
2109
|
declare function custom<TValidator extends AnyValidator>(validator: TValidator): ConvexCustomBuilderInitial<'', TValidator>;
|
|
2091
2110
|
declare function custom<TName extends string, TValidator extends AnyValidator>(name: TName, validator: TValidator): ConvexCustomBuilderInitial<TName, TValidator>;
|
|
2111
|
+
/**
|
|
2112
|
+
* Creates an array column from a nested validator or builder.
|
|
2113
|
+
*
|
|
2114
|
+
* Values in nested arrays are always compiled as required validators.
|
|
2115
|
+
*/
|
|
2116
|
+
declare function arrayOf<TElement extends NestedInput>(element: TElement): $Type<ConvexCustomBuilderInitial<"", convex_values0.VArray<any[], AnyValidator, "required">>, InferNestedValue<TElement>[]>;
|
|
2117
|
+
/**
|
|
2118
|
+
* Creates an object column from a nested shape of validators/builders.
|
|
2119
|
+
*
|
|
2120
|
+
* Fields in nested objects are always compiled as required validators.
|
|
2121
|
+
*/
|
|
2122
|
+
declare function objectOf<TShape extends NestedShapeInput>(shape: TShape): $Type<ConvexCustomBuilderInitial<"", AnyValidator>, InferObjectShape<TShape>>;
|
|
2092
2123
|
/**
|
|
2093
2124
|
* Convenience wrapper for Convex "JSON" values.
|
|
2094
2125
|
*
|
|
@@ -3522,6 +3553,7 @@ declare function desc<TBuilder extends ColumnBuilder<any, any, any>>(builder: TB
|
|
|
3522
3553
|
type BetterConvexSchemaOptions<StrictTableNameTypes extends boolean> = DefineSchemaOptions<StrictTableNameTypes> & {
|
|
3523
3554
|
strict?: boolean;
|
|
3524
3555
|
defaults?: OrmRuntimeDefaults;
|
|
3556
|
+
plugins?: readonly OrmSchemaPlugin[];
|
|
3525
3557
|
};
|
|
3526
3558
|
/**
|
|
3527
3559
|
* Better Convex schema definition
|
|
@@ -3564,4 +3596,4 @@ interface IndexLike {
|
|
|
3564
3596
|
indexName: string;
|
|
3565
3597
|
}
|
|
3566
3598
|
//#endregion
|
|
3567
|
-
export { DatabaseWithQuery as $,
|
|
3599
|
+
export { DatabaseWithQuery as $, CountResult as $n, startsWith as $r, TableRelationalConfig as $t, MigrationRunArgs as A, ConvexVectorIndexConfig as An, LogicalExpression as Ar, ConvexCustomBuilderInitial as At, MigrationMigrateOne as B, ConvexForeignKeyConfig as Bn, ilike as Br, boolean as Bt, OrmBeforeResult as C, ConvexRankIndexBuilder as Cn, VectorQueryConfig as Cr, ConvexIdBuilderInitial as Ct, OrmTriggers as D, ConvexSearchIndexConfig as Dn, ExpressionVisitor as Dr, ConvexDateMode as Dt, OrmTriggerContext as E, ConvexSearchIndexBuilderOn as En, BinaryExpression as Er, ConvexDateBuilderInitial as Et, MigrationDirection as F, uniqueIndex as Fn, endsWith as Fr, ConvexBytesBuilder as Ft, MigrationStep as G, foreignKey as Gn, like as Gr, CountBackfillKickoffArgs as Gt, MigrationRunStatus as H, ConvexUniqueConstraintBuilderOn as Hn, isFieldReference as Hr, ConvexBigIntBuilderInitial as Ht, MigrationDoc as I, vectorIndex as In, eq as Ir, ConvexBytesBuilderInitial as It, buildMigrationPlan as J, AggregateFieldValue as Jn, ne as Jr, ManyConfig as Jt, MigrationTableName as K, unique as Kn, lt as Kr, CountBackfillStatusArgs as Kt, MigrationDocContext as L, ConvexCheckBuilder as Ln, fieldRef as Lr, bytes as Lt, MigrationStatusArgs as M, index as Mn, and as Mr, custom as Mt, MigrationAppliedState as N, rankIndex as Nn, between as Nr, json as Nt, defineTriggers as O, ConvexVectorIndexBuilder as On, FieldReference as Or, date as Ot, MigrationDefinition as P, searchIndex as Pn, contains as Pr, objectOf as Pt, DatabaseWithMutations as Q, CountConfig as Qn, or as Qr, RelationsBuilderColumnConfig as Qt, MigrationDriftIssue as R, ConvexCheckConfig as Rn, gt as Rr, ConvexBooleanBuilder as Rt, scheduledDeleteFactory as S, ConvexIndexBuilderOn as Sn, UpdateSet as Sr, ConvexIdBuilder as St, OrmTriggerChange as T, ConvexSearchIndexBuilder as Tn, unsetToken as Tr, ConvexDateBuilder as Tt, MigrationSet as U, ConvexUniqueConstraintConfig as Un, isNotNull as Ur, bigint as Ut, MigrationPlan as V, ConvexUniqueConstraintBuilder as Vn, inArray as Vr, ConvexBigIntBuilder as Vt, MigrationStateMap as W, check as Wn, isNull as Wr, CountBackfillChunkArgs as Wt, defineMigrationSet as X, BuildQueryResult as Xn, notBetween as Xr, RelationsBuilder as Xt, defineMigration as Y, AggregateResult as Yn, not as Yr, OneConfig as Yt, detectMigrationDrift as Z, BuildRelationResult as Zn, notInArray as Zr, RelationsBuilderColumnBase as Zt, OrmWriterCtx as _, NotNull as _i, RlsRoleConfig as _n, PaginatedResult as _r, ConvexTextBuilderInitial as _t, TableConfigResult as a, SystemFields as ai, ConvexTable as an, InferSelectModel as ar, extractRelationsConfig as at, scheduledMutationBatchFactory as b, ConvexAggregateIndexBuilderOn as bn, ReturningResult as br, ConvexNumberBuilderInitial as bt, OrmNotFoundError as c, ColumnBuilderBaseConfig as ci, OrmLifecycleOperation as cn, MutationExecuteResult as cr, vector as ct, GenericOrmCtx as d, ColumnBuilderWithTableName as di, deletion as dn, MutationPaginatedResult as dr, ConvexTimestampMode as dt, Brand as ei, TablesRelationalConfig as en, DBQueryConfig as er, OrmReader as et, OrmApiResult as f, ColumnDataType as fi, RlsPolicy as fn, MutationResult as fr, timestamp as ft, OrmReaderCtx as g, IsUnique as gi, RlsRole as gn, OrderDirection as gr, ConvexTextBuilder as gt, OrmFunctions as h, IsPrimaryKey as hi, rlsPolicy as hn, OrderByClause as hr, textEnum as ht, desc as i, TableName as ii, ConvexDeletionConfig as in, InferModelFromColumns as ir, EdgeMetadata as it, MigrationRunChunkArgs as j, aggregateIndex as jn, UnaryExpression as jr, arrayOf as jt, MigrationCancelArgs as k, ConvexVectorIndexBuilderOn as kn, FilterExpression$1 as kr, ConvexCustomBuilder as kt, CreateOrmOptions as l, ColumnBuilderRuntimeConfig as li, TableConfig as ln, MutationExecutionMode as lr, ConvexTimestampBuilder as lt, OrmClientWithApi as m, HasDefault as mi, RlsPolicyToOption as mn, MutationRunMode as mr, ConvexTextEnumBuilderInitial as mt, defineSchema$1 as n, OrmSchemaPlugin as ni, defineRelationsPart as nn, GetColumnData as nr, RlsContext as nt, getTableColumns as o, AnyColumn as oi, ConvexTableWithColumns as on, InsertValue as or, ConvexVectorBuilder as ot, OrmClientBase as p, DrizzleEntity as pi, RlsPolicyConfig as pn, MutationReturning as pr, ConvexTextEnumBuilder as pt, MigrationWriteMode as q, AggregateConfig as qn, lte as qr, ExtractTablesWithRelations as qt, asc as r, OrmSchemaPluginTables as ri, ConvexDeletionBuilder as rn, InferInsertModel as rr, RlsMode as rt, getTableConfig as s, ColumnBuilder as si, OrmLifecycleChange as sn, MutationExecuteConfig as sr, ConvexVectorBuilderInitial as st, WhereClauseResult as t, Columns as ti, defineRelations as tn, FilterOperators as tr, OrmWriter as tt, GenericOrm as u, ColumnBuilderTypeConfig as ui, convexTable as un, MutationPaginateConfig as ur, ConvexTimestampBuilderInitial as ut, createOrm as v, rlsRole as vn, PredicateWhereIndexConfig as vr, text as vt, OrmTableTriggers as w, ConvexRankIndexBuilderOn as wn, VectorSearchProvider as wr, id as wt, ScheduledDeleteArgs as x, ConvexIndexBuilder as xn, ReturningSelection as xr, integer as xt, ScheduledMutationBatchArgs as y, ConvexAggregateIndexBuilder as yn, ReturningAll as yr, ConvexNumberBuilder as yt, MigrationManifestEntry as z, ConvexForeignKeyBuilder as zn, gte as zr, ConvexBooleanBuilderInitial as zt };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-convex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Better Convex - React Query integration and CLI tools for Convex",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"convex",
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"./auth/nextjs": "./dist/auth/nextjs/index.js",
|
|
21
21
|
"./crpc": "./dist/crpc/index.js",
|
|
22
22
|
"./orm": "./dist/orm/index.js",
|
|
23
|
+
"./plugins": "./dist/plugins/index.js",
|
|
24
|
+
"./plugins/ratelimit": "./dist/plugins/ratelimit/index.js",
|
|
25
|
+
"./plugins/ratelimit/react": "./dist/plugins/ratelimit/react/index.js",
|
|
23
26
|
"./react": "./dist/react/index.js",
|
|
24
27
|
"./rsc": "./dist/rsc/index.js",
|
|
25
28
|
"./server": "./dist/server/index.js",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|