kitcn 0.15.6 → 0.15.8
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/orm/index.d.ts +1 -1
- package/dist/orm/index.js +87 -60
- package/dist/react/index.d.ts +6 -2
- package/dist/react/index.js +5 -4
- package/dist/solid/index.d.ts +14 -3
- package/dist/solid/index.js +5 -2
- package/dist/{where-clause-compiler-DcEhkJ12.d.ts → where-clause-compiler-CgQj3ZHP.d.ts} +0 -2
- package/package.json +1 -1
- package/skills/kitcn/references/features/auth.md +9 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-
|
|
1
|
+
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-CgQj3ZHP.js";
|
|
2
2
|
import * as convex_values0 from "convex/values";
|
|
3
3
|
import { GenericId, Infer, Value } from "convex/values";
|
|
4
4
|
import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
|
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-
|
|
1
|
+
import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-CgQj3ZHP.js";
|
|
2
2
|
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BhsByJeg.js";
|
|
3
3
|
import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-CNo9ffvI.js";
|
|
4
4
|
import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
|
package/dist/orm/index.js
CHANGED
|
@@ -584,6 +584,71 @@ const deserializeFilterExpression = (expression) => {
|
|
|
584
584
|
if (!nested) throw new Error("Serialized unary operand is missing.");
|
|
585
585
|
return createUnaryExpression(unary.operator, nested);
|
|
586
586
|
};
|
|
587
|
+
const PRIMARY_ID_LOOKUP_CURSOR_PREFIX = "kitcn:primary-id:";
|
|
588
|
+
const dedupePrimaryIds = (values) => Array.from(new Map(values.map((value) => [String(value), value])).values());
|
|
589
|
+
const parsePrimaryIdLookupCursor = (cursor) => {
|
|
590
|
+
if (cursor === null) return 0;
|
|
591
|
+
if (!cursor.startsWith(PRIMARY_ID_LOOKUP_CURSOR_PREFIX)) throw new Error("Invalid primary id mutation cursor.");
|
|
592
|
+
const offset = Number(cursor.slice(17));
|
|
593
|
+
if (!Number.isInteger(offset) || offset < 0) throw new Error("Invalid primary id mutation cursor.");
|
|
594
|
+
return offset;
|
|
595
|
+
};
|
|
596
|
+
const canUsePrimaryIdLookupCursor = (cursor) => cursor === null || cursor === void 0 || cursor.startsWith(PRIMARY_ID_LOOKUP_CURSOR_PREFIX);
|
|
597
|
+
const extractPrimaryIdLookup = (expression) => {
|
|
598
|
+
if (!expression || expression.type !== "binary") return null;
|
|
599
|
+
const binary = expression;
|
|
600
|
+
const [left, right] = binary.operands;
|
|
601
|
+
if (binary.operator === "eq") {
|
|
602
|
+
if (isFieldReference(left) && left.fieldName === "_id") {
|
|
603
|
+
if (isFieldReference(right)) return null;
|
|
604
|
+
return {
|
|
605
|
+
kind: "eq",
|
|
606
|
+
values: [right]
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
if (isFieldReference(right) && right.fieldName === "_id") {
|
|
610
|
+
if (isFieldReference(left)) return null;
|
|
611
|
+
return {
|
|
612
|
+
kind: "eq",
|
|
613
|
+
values: [left]
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
if (binary.operator === "inArray" && isFieldReference(left) && left.fieldName === "_id" && Array.isArray(right)) return {
|
|
618
|
+
kind: "in",
|
|
619
|
+
values: dedupePrimaryIds(right)
|
|
620
|
+
};
|
|
621
|
+
return null;
|
|
622
|
+
};
|
|
623
|
+
const windowPrimaryIdLookup = (lookup, pagination) => {
|
|
624
|
+
if (!pagination) return {
|
|
625
|
+
continueCursor: null,
|
|
626
|
+
isDone: true,
|
|
627
|
+
values: lookup.values
|
|
628
|
+
};
|
|
629
|
+
const offset = parsePrimaryIdLookupCursor(pagination.cursor);
|
|
630
|
+
const nextOffset = offset + pagination.limit;
|
|
631
|
+
const values = lookup.values.slice(offset, nextOffset);
|
|
632
|
+
const isDone = nextOffset >= lookup.values.length;
|
|
633
|
+
return {
|
|
634
|
+
continueCursor: isDone ? null : `${PRIMARY_ID_LOOKUP_CURSOR_PREFIX}${nextOffset}`,
|
|
635
|
+
isDone,
|
|
636
|
+
values
|
|
637
|
+
};
|
|
638
|
+
};
|
|
639
|
+
const collectPrimaryIdLookupRows = async (db, tableName, lookup, options) => {
|
|
640
|
+
if (!options.pagination && lookup.values.length > options.maxRows) throw new Error(`${options.operation} exceeded mutationMaxRows (${options.maxRows}) on "${tableName}". Narrow the filter or increase defineSchema(..., { defaults: { mutationMaxRows } }).`);
|
|
641
|
+
if (!options.pagination && lookup.values.length > options.batchSize) throw new Error(`${options.operation} matched more than mutationBatchSize (${options.batchSize}) primary ids on "${tableName}". Use executeAsync({ batchSize }) or paginate() to split the mutation.`);
|
|
642
|
+
const primaryIdWindow = windowPrimaryIdLookup(lookup, options.pagination);
|
|
643
|
+
if (primaryIdWindow.values.length > options.maxRows) throw new Error(`${options.operation} exceeded mutationMaxRows (${options.maxRows}) on "${tableName}". Narrow the filter or increase defineSchema(..., { defaults: { mutationMaxRows } }).`);
|
|
644
|
+
const normalizedIds = primaryIdWindow.values.filter((value) => value !== null && value !== void 0).map((value) => db.normalizeId(tableName, value)).filter((value) => value !== null);
|
|
645
|
+
const fetchedRows = await Promise.all(normalizedIds.map((value) => db.get(value)));
|
|
646
|
+
return {
|
|
647
|
+
continueCursor: primaryIdWindow.continueCursor,
|
|
648
|
+
isDone: primaryIdWindow.isDone,
|
|
649
|
+
rows: fetchedRows.filter((row) => !!row)
|
|
650
|
+
};
|
|
651
|
+
};
|
|
587
652
|
const DEFAULT_MUTATION_BATCH_SIZE = 400;
|
|
588
653
|
const DEFAULT_MUTATION_LEAF_BATCH_SIZE = 1600;
|
|
589
654
|
const DEFAULT_MUTATION_MAX_ROWS = 1e4;
|
|
@@ -7431,27 +7496,6 @@ var ConvexDeleteBuilder = class extends QueryPromise {
|
|
|
7431
7496
|
this.allowFullScanFlag = true;
|
|
7432
7497
|
return this;
|
|
7433
7498
|
}
|
|
7434
|
-
getIdEquality() {
|
|
7435
|
-
const expression = this.whereExpression;
|
|
7436
|
-
if (!expression || expression.type !== "binary") return { matched: false };
|
|
7437
|
-
if (expression.operator !== "eq") return { matched: false };
|
|
7438
|
-
const [left, right] = expression.operands;
|
|
7439
|
-
if (isFieldReference(left) && left.fieldName === "_id") {
|
|
7440
|
-
if (isFieldReference(right)) return { matched: false };
|
|
7441
|
-
return {
|
|
7442
|
-
matched: true,
|
|
7443
|
-
value: right
|
|
7444
|
-
};
|
|
7445
|
-
}
|
|
7446
|
-
if (isFieldReference(right) && right.fieldName === "_id") {
|
|
7447
|
-
if (isFieldReference(left)) return { matched: false };
|
|
7448
|
-
return {
|
|
7449
|
-
matched: true,
|
|
7450
|
-
value: left
|
|
7451
|
-
};
|
|
7452
|
-
}
|
|
7453
|
-
return { matched: false };
|
|
7454
|
-
}
|
|
7455
7499
|
soft() {
|
|
7456
7500
|
this.deleteModeOverride = "soft";
|
|
7457
7501
|
this.scheduledDelayMs = void 0;
|
|
@@ -7547,15 +7591,17 @@ var ConvexDeleteBuilder = class extends QueryPromise {
|
|
|
7547
7591
|
let rows;
|
|
7548
7592
|
let continueCursor = null;
|
|
7549
7593
|
let isDone = true;
|
|
7550
|
-
const
|
|
7551
|
-
if (
|
|
7552
|
-
const
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7594
|
+
const primaryIdLookup = canUsePrimaryIdLookupCursor(pagination?.cursor) ? extractPrimaryIdLookup(this.whereExpression) : null;
|
|
7595
|
+
if (primaryIdLookup) {
|
|
7596
|
+
const primaryIdRows = await collectPrimaryIdLookupRows(this.db, tableName, primaryIdLookup, {
|
|
7597
|
+
operation: "delete",
|
|
7598
|
+
pagination,
|
|
7599
|
+
batchSize,
|
|
7600
|
+
maxRows
|
|
7601
|
+
});
|
|
7602
|
+
continueCursor = primaryIdRows.continueCursor;
|
|
7603
|
+
isDone = primaryIdRows.isDone;
|
|
7604
|
+
rows = primaryIdRows.rows;
|
|
7559
7605
|
} else if (this.whereExpression) {
|
|
7560
7606
|
const compiled = new WhereClauseCompiler(tableName, getIndexes(this.table).map((index) => ({
|
|
7561
7607
|
indexName: index.name,
|
|
@@ -8598,27 +8644,6 @@ var ConvexUpdateBuilder = class extends QueryPromise {
|
|
|
8598
8644
|
this.allowFullScanFlag = true;
|
|
8599
8645
|
return this;
|
|
8600
8646
|
}
|
|
8601
|
-
getIdEquality() {
|
|
8602
|
-
const expression = this.whereExpression;
|
|
8603
|
-
if (!expression || expression.type !== "binary") return { matched: false };
|
|
8604
|
-
if (expression.operator !== "eq") return { matched: false };
|
|
8605
|
-
const [left, right] = expression.operands;
|
|
8606
|
-
if (isFieldReference(left) && left.fieldName === "_id") {
|
|
8607
|
-
if (isFieldReference(right)) return { matched: false };
|
|
8608
|
-
return {
|
|
8609
|
-
matched: true,
|
|
8610
|
-
value: right
|
|
8611
|
-
};
|
|
8612
|
-
}
|
|
8613
|
-
if (isFieldReference(right) && right.fieldName === "_id") {
|
|
8614
|
-
if (isFieldReference(left)) return { matched: false };
|
|
8615
|
-
return {
|
|
8616
|
-
matched: true,
|
|
8617
|
-
value: left
|
|
8618
|
-
};
|
|
8619
|
-
}
|
|
8620
|
-
return { matched: false };
|
|
8621
|
-
}
|
|
8622
8647
|
async executeAsync(...args) {
|
|
8623
8648
|
const config = args[0];
|
|
8624
8649
|
return this.execute({
|
|
@@ -8709,15 +8734,17 @@ var ConvexUpdateBuilder = class extends QueryPromise {
|
|
|
8709
8734
|
let rows;
|
|
8710
8735
|
let continueCursor = null;
|
|
8711
8736
|
let isDone = true;
|
|
8712
|
-
const
|
|
8713
|
-
if (
|
|
8714
|
-
const
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8737
|
+
const primaryIdLookup = canUsePrimaryIdLookupCursor(pagination?.cursor) ? extractPrimaryIdLookup(this.whereExpression) : null;
|
|
8738
|
+
if (primaryIdLookup) {
|
|
8739
|
+
const primaryIdRows = await collectPrimaryIdLookupRows(this.db, tableName, primaryIdLookup, {
|
|
8740
|
+
operation: "update",
|
|
8741
|
+
pagination,
|
|
8742
|
+
batchSize,
|
|
8743
|
+
maxRows
|
|
8744
|
+
});
|
|
8745
|
+
continueCursor = primaryIdRows.continueCursor;
|
|
8746
|
+
isDone = primaryIdRows.isDone;
|
|
8747
|
+
rows = primaryIdRows.rows;
|
|
8721
8748
|
} else if (this.whereExpression) {
|
|
8722
8749
|
const compiled = new WhereClauseCompiler(tableName, getIndexes(this.table).map((index) => ({
|
|
8723
8750
|
indexName: index.name,
|
package/dist/react/index.d.ts
CHANGED
|
@@ -39,6 +39,9 @@ declare function isAuthMutationError(error: unknown): error is AuthMutationError
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/react/auth-mutations.d.ts
|
|
41
41
|
type MutationOptionsHook<TData, TVariables = void> = (options?: Omit<UseMutationOptions<TData, DefaultError, TVariables>, 'mutationFn'>) => UseMutationOptions<TData, DefaultError, TVariables>;
|
|
42
|
+
type SignInMutationOptionsHook<TData, TVariables = void> = (options?: Omit<UseMutationOptions<TData, DefaultError, TVariables>, 'mutationFn'> & {
|
|
43
|
+
signInMethod?: string;
|
|
44
|
+
}) => UseMutationOptions<TData, DefaultError, TVariables>;
|
|
42
45
|
type AnyAuthFn = (...args: never[]) => unknown;
|
|
43
46
|
type MutationArgsWithFetchOptions = {
|
|
44
47
|
fetchOptions?: Record<string, unknown>;
|
|
@@ -72,8 +75,9 @@ type AuthClient = {
|
|
|
72
75
|
signOut?: AnyAuthFn;
|
|
73
76
|
signIn?: {
|
|
74
77
|
anonymous?: AnyAuthFn;
|
|
75
|
-
social?: AnyAuthFn;
|
|
76
78
|
email?: AnyAuthFn;
|
|
79
|
+
social?: AnyAuthFn;
|
|
80
|
+
[method: string]: AnyAuthFn | undefined;
|
|
77
81
|
};
|
|
78
82
|
signUp?: {
|
|
79
83
|
email?: AnyAuthFn;
|
|
@@ -105,7 +109,7 @@ type AuthClient = {
|
|
|
105
109
|
type AuthMutationsResult = {
|
|
106
110
|
useSignOutMutationOptions: MutationOptionsHook<unknown, MutationArgsWithFetchOptions | void>;
|
|
107
111
|
useSignInSocialMutationOptions: MutationOptionsHook<unknown, unknown>;
|
|
108
|
-
useSignInMutationOptions:
|
|
112
|
+
useSignInMutationOptions: SignInMutationOptionsHook<unknown, unknown>;
|
|
109
113
|
useSignUpMutationOptions: MutationOptionsHook<unknown, unknown>;
|
|
110
114
|
};
|
|
111
115
|
declare function createAuthMutations(authClient: AuthClient): AuthMutationsResult;
|
package/dist/react/index.js
CHANGED
|
@@ -1574,12 +1574,13 @@ function createAuthMutations(authClient) {
|
|
|
1574
1574
|
const useSignInMutationOptions = ((options) => {
|
|
1575
1575
|
const authStoreApi = useAuthStore();
|
|
1576
1576
|
const convexQueryClient = useConvexQueryClient();
|
|
1577
|
+
const { signInMethod = "email", ...mutationOptions } = options ?? {};
|
|
1577
1578
|
return {
|
|
1578
|
-
...
|
|
1579
|
+
...mutationOptions,
|
|
1579
1580
|
mutationFn: async (args) => {
|
|
1580
|
-
const
|
|
1581
|
-
if (typeof
|
|
1582
|
-
const res = await callAuthMethod(
|
|
1581
|
+
const signIn = authClient.signIn?.[signInMethod];
|
|
1582
|
+
if (typeof signIn !== "function") throw new Error(`Auth client does not expose signIn.${signInMethod}`);
|
|
1583
|
+
const res = await callAuthMethod(signIn, withDisabledSessionSignal(args));
|
|
1583
1584
|
if (res?.error) throw toAuthMutationError(res.error);
|
|
1584
1585
|
seedReturnedToken(authStoreApi, res);
|
|
1585
1586
|
await hydrateReturnedSession(authClient, res);
|
package/dist/solid/index.d.ts
CHANGED
|
@@ -148,12 +148,23 @@ declare function isAuthMutationError(error: unknown): error is AuthMutationError
|
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/solid/auth-mutations.d.ts
|
|
150
150
|
type MutationOptionsHook<TData, TVariables = void> = (options?: Omit<SolidMutationOptions<TData, DefaultError, TVariables>, 'mutationFn'>) => SolidMutationOptions<TData, DefaultError, TVariables>;
|
|
151
|
+
type SignInMethod<T extends AuthClient> = Extract<keyof T['signIn'], string>;
|
|
152
|
+
type EmailSignInMutationOptions<T extends AuthClient> = Omit<SolidMutationOptions<Awaited<ReturnType<T['signIn']['email']>>, DefaultError, Parameters<T['signIn']['email']>[0]>, 'mutationFn'> & {
|
|
153
|
+
signInMethod?: 'email';
|
|
154
|
+
};
|
|
155
|
+
type CustomSignInMutationOptions<T extends AuthClient, TMethod extends SignInMethod<T>> = Omit<SolidMutationOptions<Awaited<ReturnType<T['signIn'][TMethod]>>, DefaultError, Parameters<T['signIn'][TMethod]>[0]>, 'mutationFn'> & {
|
|
156
|
+
signInMethod: TMethod;
|
|
157
|
+
};
|
|
158
|
+
type SignInMutationOptionsHook<T extends AuthClient> = {
|
|
159
|
+
(options?: EmailSignInMutationOptions<T>): SolidMutationOptions<Awaited<ReturnType<T['signIn']['email']>>, DefaultError, Parameters<T['signIn']['email']>[0]>;
|
|
160
|
+
<TMethod extends Exclude<SignInMethod<T>, 'email'>>(options: CustomSignInMutationOptions<T, TMethod>): SolidMutationOptions<Awaited<ReturnType<T['signIn'][TMethod]>>, DefaultError, Parameters<T['signIn'][TMethod]>[0]>;
|
|
161
|
+
};
|
|
151
162
|
type AnyFn = (...args: any[]) => Promise<any>;
|
|
152
163
|
type AuthClient = {
|
|
153
164
|
signOut: AnyFn;
|
|
154
|
-
signIn: {
|
|
155
|
-
social: AnyFn;
|
|
165
|
+
signIn: Record<string, AnyFn> & {
|
|
156
166
|
email: AnyFn;
|
|
167
|
+
social: AnyFn;
|
|
157
168
|
};
|
|
158
169
|
signUp: {
|
|
159
170
|
email: AnyFn;
|
|
@@ -162,7 +173,7 @@ type AuthClient = {
|
|
|
162
173
|
type AuthMutationsResult<T extends AuthClient> = {
|
|
163
174
|
useSignOutMutationOptions: MutationOptionsHook<Awaited<ReturnType<T['signOut']>>, Parameters<T['signOut']>[0] | void>;
|
|
164
175
|
useSignInSocialMutationOptions: MutationOptionsHook<Awaited<ReturnType<T['signIn']['social']>>, Parameters<T['signIn']['social']>[0]>;
|
|
165
|
-
useSignInMutationOptions:
|
|
176
|
+
useSignInMutationOptions: SignInMutationOptionsHook<T>;
|
|
166
177
|
useSignUpMutationOptions: MutationOptionsHook<Awaited<ReturnType<T['signUp']['email']>>, Parameters<T['signUp']['email']>[0]>;
|
|
167
178
|
};
|
|
168
179
|
/**
|
package/dist/solid/index.js
CHANGED
|
@@ -1728,10 +1728,13 @@ function createAuthMutations(authClient) {
|
|
|
1728
1728
|
});
|
|
1729
1729
|
const useSignInMutationOptions = ((options) => {
|
|
1730
1730
|
const authStoreApi = useAuthStore();
|
|
1731
|
+
const { signInMethod = "email", ...mutationOptions } = options ?? {};
|
|
1731
1732
|
return {
|
|
1732
|
-
...
|
|
1733
|
+
...mutationOptions,
|
|
1733
1734
|
mutationFn: async (args) => {
|
|
1734
|
-
const
|
|
1735
|
+
const signIn = authClient.signIn[signInMethod];
|
|
1736
|
+
if (typeof signIn !== "function") throw new Error(`Auth client does not expose signIn.${signInMethod}`);
|
|
1737
|
+
const res = await signIn(args);
|
|
1735
1738
|
if (res?.error) throw new AuthMutationError(res.error);
|
|
1736
1739
|
seedReturnedToken(authStoreApi, res);
|
|
1737
1740
|
await ensureAuth(authStoreApi);
|
|
@@ -2284,7 +2284,6 @@ declare class ConvexDeleteBuilder<TTable extends ConvexTable<any>, TReturning ex
|
|
|
2284
2284
|
returning<TSelection extends ReturningSelection<TTable>>(fields: TSelection): ConvexDeleteWithout<ConvexDeleteBuilder<TTable, TSelection, TMode, THasWhereOrAllowFullScan>, 'returning'>;
|
|
2285
2285
|
paginate(config: MutationPaginateConfig): ConvexDeleteWithout<ConvexDeleteBuilder<TTable, TReturning, 'paged', THasWhereOrAllowFullScan>, 'paginate'>;
|
|
2286
2286
|
allowFullScan(): ConvexDeleteBuilder<TTable, TReturning, TMode, true>;
|
|
2287
|
-
private getIdEquality;
|
|
2288
2287
|
soft(): this;
|
|
2289
2288
|
hard(): this;
|
|
2290
2289
|
scheduled(config: {
|
|
@@ -2892,7 +2891,6 @@ declare class ConvexUpdateBuilder<TTable extends ConvexTable<any>, TReturning ex
|
|
|
2892
2891
|
returning<TSelection extends ReturningSelection<TTable>>(fields: TSelection): ConvexUpdateWithout<ConvexUpdateBuilder<TTable, TSelection, TMode, THasWhereOrAllowFullScan>, 'returning'>;
|
|
2893
2892
|
paginate(config: MutationPaginateConfig): ConvexUpdateWithout<ConvexUpdateBuilder<TTable, TReturning, 'paged', THasWhereOrAllowFullScan>, 'paginate'>;
|
|
2894
2893
|
allowFullScan(): ConvexUpdateBuilder<TTable, TReturning, TMode, true>;
|
|
2895
|
-
private getIdEquality;
|
|
2896
2894
|
executeAsync(this: ConvexUpdateExecutableThis<TTable, TReturning, TMode>, ...args: TMode extends 'single' ? [config?: Omit<MutationExecuteConfig, 'mode'>] : [config: never]): Promise<TMode extends 'single' ? MutationExecuteResult<TTable, TReturning, 'single'> : never>;
|
|
2897
2895
|
execute(this: ConvexUpdateExecutableThis<TTable, TReturning, TMode>, ...args: TMode extends 'single' ? [config?: MutationExecuteConfig] : [config?: never]): Promise<MutationExecuteResult<TTable, TReturning, TMode>>;
|
|
2898
2896
|
}
|
package/package.json
CHANGED
|
@@ -326,6 +326,15 @@ const signUp = useMutation(useSignUpMutationOptions({ onSuccess: () => router.pu
|
|
|
326
326
|
signUp.mutate({ callbackURL: window.location.origin, email, name, password });
|
|
327
327
|
```
|
|
328
328
|
|
|
329
|
+
**Plugin sign-in methods** (requires the matching Better Auth client plugin):
|
|
330
|
+
```ts
|
|
331
|
+
const signIn = useMutation(useSignInMutationOptions({
|
|
332
|
+
signInMethod: 'username',
|
|
333
|
+
onSuccess: () => router.push('/'),
|
|
334
|
+
}));
|
|
335
|
+
signIn.mutate({ callbackURL: window.location.origin, password, username });
|
|
336
|
+
```
|
|
337
|
+
|
|
329
338
|
### Sign Out
|
|
330
339
|
|
|
331
340
|
```ts
|