kitcn 0.25.0 → 0.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aggregate/index.d.ts +10 -10
- package/dist/aggregate/index.js +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/auth/nextjs/index.d.ts +1 -1
- package/dist/{builder-1Vx-tEnS.js → builder-DoeyW4Vq.js} +71 -65
- package/dist/cli.mjs +154 -39
- package/dist/{customFunctions-BbhgdRGl.js → customFunctions-ivbc6-_g.js} +1 -1
- package/dist/{definitions-D9vhJ6OV.js → definitions-Dzk8mSTL.js} +2 -2
- package/dist/{extensions-DzjCJXYl.js → extensions-Blzsyekm.js} +1 -1
- package/dist/{id-Bibg34Yb.js → id-CuSfWa5q.js} +1 -1
- package/dist/{local-env-Du24tdbp.mjs → local-env-Dkh4a_BK.mjs} +1 -0
- package/dist/{middleware-cJDRHTRY.js → middleware-DIj-bwVi.js} +1 -1
- package/dist/orm/aggregate-index/index.js +3 -3
- package/dist/orm/index.d.ts +2 -2
- package/dist/orm/index.js +43 -10
- package/dist/orm/migrations/index.d.ts +1 -1
- package/dist/orm/migrations/index.js +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/{procedure-caller-DIzXfX2E.js → procedure-caller-Dxae9DW5.js} +3 -3
- package/dist/{procedure-name-B09-cf1-.d.ts → procedure-name-l2YusEZI.d.ts} +55 -52
- package/dist/ratelimit/index.js +2 -2
- package/dist/{runtime-DfGsZtx3.js → runtime-BdqTbgKh.js} +9 -3
- package/dist/{schema-Besl-rpv.js → schema-D8sVYuYO.js} +28 -14
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -2
- package/dist/{table-rmJm5Qio.js → table-CX2lnX7e.js} +1 -1
- package/dist/{validators-Dmbhsd3U.js → validators-CIoUYCqO.js} +1 -0
- package/dist/{validators-V4eM2-Jg.d.ts → validators-wOIjhkfN.d.ts} +7 -1
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-mohWFiG0.d.ts → where-clause-compiler-TMNQB6US.d.ts} +103 -56
- package/package.json +4 -3
- package/skills/kitcn/SKILL.md +1 -1
- package/skills/kitcn/references/features/auth-polar.md +2 -2
- package/skills/kitcn/references/features/scheduling.md +1 -1
- package/skills/kitcn/references/setup/auth.md +1 -1
- package/skills/kitcn/references/setup/index.md +3 -3
package/dist/cli.mjs
CHANGED
|
@@ -1,17 +1,51 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as Columns, D as TableName, E as RlsPolicies, O as createSystemFields, S as getRankIndexes, T as OrmSchemaExtensions, _ as loadEsbuild, a as generateMeta, b as getAggregateIndexes, c as resolveSchemaDefaultExport, f as createProjectJiti, g as loadDotenv, h as loadClackPrompts, i as resolveConfiguredBackend, l as schemaDeclaresAggregateIndexes, m as loadBabelParser, n as withLocalCodegenEnv, o as getConvexConfig, p as CRPC_BUILDER_STUB_SOURCE, r as loadCliConfig, s as collectSchemaTables, t as getLocalBackendEnvVars, u as logger, v as highlighter, w as EnableRLS, x as getIndexes, y as isColorEnabled } from "./local-env-
|
|
2
|
+
import { C as Columns, D as TableName, E as RlsPolicies, O as createSystemFields, S as getRankIndexes, T as OrmSchemaExtensions, _ as loadEsbuild, a as generateMeta, b as getAggregateIndexes, c as resolveSchemaDefaultExport, f as createProjectJiti, g as loadDotenv, h as loadClackPrompts, i as resolveConfiguredBackend, l as schemaDeclaresAggregateIndexes, m as loadBabelParser, n as withLocalCodegenEnv, o as getConvexConfig, p as CRPC_BUILDER_STUB_SOURCE, r as loadCliConfig, s as collectSchemaTables, t as getLocalBackendEnvVars, u as logger, v as highlighter, w as EnableRLS, x as getIndexes, y as isColorEnabled } from "./local-env-Dkh4a_BK.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
5
5
|
import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { createHash, randomBytes } from "node:crypto";
|
|
8
8
|
import { execa } from "execa";
|
|
9
|
-
import { createInterface } from "node:readline/promises";
|
|
10
9
|
import os from "node:os";
|
|
10
|
+
import { createInterface } from "node:readline/promises";
|
|
11
11
|
import { diffWords, structuredPatch } from "diff";
|
|
12
12
|
import { parseEnv } from "node:util";
|
|
13
13
|
import { createServer } from "node:http";
|
|
14
14
|
|
|
15
|
+
//#region src/internal/concurrency.ts
|
|
16
|
+
/**
|
|
17
|
+
* Bounded-concurrency fan-out, shared by the ORM write path, relation loading
|
|
18
|
+
* and the CLI's entry-point analyzer.
|
|
19
|
+
*
|
|
20
|
+
* Deliberately dependency-free: ORM callers reach it from a Convex function
|
|
21
|
+
* entry, and Convex bundles every static import of an entry.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Runs `worker` over `items` with at most `limit` in flight. Results keep input
|
|
25
|
+
* order, so callers can rely on a stable mapping back to `items`.
|
|
26
|
+
*
|
|
27
|
+
* Unbounded `Promise.all` is not an option for the ORM caller: a fan-out is
|
|
28
|
+
* bounded only by `mutationMaxRows` (10,000), and that many simultaneous
|
|
29
|
+
* in-flight syscalls is its own failure mode.
|
|
30
|
+
*/
|
|
31
|
+
async function mapWithConcurrency(items, limit, worker) {
|
|
32
|
+
if (items.length === 0) return [];
|
|
33
|
+
const width = Math.max(1, Math.min(limit, items.length));
|
|
34
|
+
const results = new Array(items.length);
|
|
35
|
+
let nextIndex = 0;
|
|
36
|
+
const runWorker = async () => {
|
|
37
|
+
while (true) {
|
|
38
|
+
const index = nextIndex;
|
|
39
|
+
nextIndex += 1;
|
|
40
|
+
if (index >= items.length) return;
|
|
41
|
+
results[index] = await worker(items[index], index);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
await Promise.all(Array.from({ length: width }, () => runWorker()));
|
|
45
|
+
return results;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
15
49
|
//#region src/orm/mutation-utils.ts
|
|
16
50
|
const UTF8_ENCODER = new TextEncoder();
|
|
17
51
|
function getTableName(table) {
|
|
@@ -830,20 +864,32 @@ const collectAnalyzeEntrySelection = async (roots, options) => {
|
|
|
830
864
|
handlerExportsByEntry
|
|
831
865
|
};
|
|
832
866
|
};
|
|
867
|
+
const MAX_ANALYZE_CONCURRENCY = 8;
|
|
868
|
+
/**
|
|
869
|
+
* esbuild bundles are independent, so the entry sweep runs through a bounded
|
|
870
|
+
* pool instead of one build at a time. The cap stays low enough to avoid
|
|
871
|
+
* oversubscribing esbuild's worker pool on small machines.
|
|
872
|
+
*/
|
|
873
|
+
const resolveAnalyzeConcurrency = (taskCount) => {
|
|
874
|
+
if (taskCount <= 1) return 1;
|
|
875
|
+
const cpuCount = os.cpus().length || 1;
|
|
876
|
+
return Math.max(1, Math.min(MAX_ANALYZE_CONCURRENCY, cpuCount - 1, taskCount));
|
|
877
|
+
};
|
|
833
878
|
const collectHotspotRows = async (roots, options, includeDeepData) => {
|
|
834
879
|
const { isolateEntries, generatedEntries, entryPoints, handlerExportsByEntry } = await collectAnalyzeEntrySelection(roots, options);
|
|
835
|
-
const rows =
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
880
|
+
const rows = await mapWithConcurrency(entryPoints, resolveAnalyzeConcurrency(entryPoints.length), async (entryPoint) => {
|
|
881
|
+
try {
|
|
882
|
+
return {
|
|
883
|
+
...await analyzeHotspotEntry(entryPoint, roots.projectRoot, includeDeepData),
|
|
884
|
+
handlerExports: handlerExportsByEntry.get(entryPoint) ?? []
|
|
885
|
+
};
|
|
886
|
+
} catch (error) {
|
|
887
|
+
return {
|
|
888
|
+
entry: path.relative(roots.projectRoot, entryPoint),
|
|
889
|
+
error: error instanceof Error ? error.message : String(error)
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
});
|
|
847
893
|
return {
|
|
848
894
|
isolateEntries,
|
|
849
895
|
generatedEntries,
|
|
@@ -2129,8 +2175,11 @@ const EXACT_VERSION_RE = /^(\d+)\.(\d+)\.\d+$/;
|
|
|
2129
2175
|
const VERSION_IN_SPEC_RE = /(\d+)\.(\d+)(?:\.\d+)?/;
|
|
2130
2176
|
const PLAIN_VERSION_SPEC_RE = /^[\^~]?v?\d+\.\d+(?:\.\d+)?$/;
|
|
2131
2177
|
const UPPER_BOUND_RE = /(?:^|\s)<={0,1}\s*v?(\d+)\.(\d+)(?:\.\d+)?/g;
|
|
2178
|
+
const LOWER_BOUND_RE = /(?:^|\s)>={0,1}\s*v?(\d+)\.(\d+)(?:\.\d+)?/g;
|
|
2132
2179
|
const SUPPORTED_CONCAVE_CLI_VERSION = "0.0.1-alpha.14";
|
|
2133
|
-
const SUPPORTED_CONVEX_VERSION = "1.
|
|
2180
|
+
const SUPPORTED_CONVEX_VERSION = "1.44.0";
|
|
2181
|
+
const SUPPORTED_CONVEX_MIN_VERSION = "1.42";
|
|
2182
|
+
const SUPPORTED_CONVEX_MIN_TYPE_VERSION = "1.42.3";
|
|
2134
2183
|
const SUPPORTED_BETTER_AUTH_VERSION = "1.6.18";
|
|
2135
2184
|
const SUPPORTED_BETTER_AUTH_MIN_VERSION = "1.6.11";
|
|
2136
2185
|
const SUPPORTED_HONO_VERSION = "4.12.9";
|
|
@@ -2140,16 +2189,16 @@ const SUPPORTED_ZOD_VERSION = "4.3.6";
|
|
|
2140
2189
|
const KITCN_INSTALL_SPEC_ENV = "KITCN_INSTALL_SPEC";
|
|
2141
2190
|
const KITCN_RESEND_INSTALL_SPEC_ENV = "KITCN_RESEND_INSTALL_SPEC";
|
|
2142
2191
|
let ownVersion;
|
|
2143
|
-
function getMinimumVersionRange(version) {
|
|
2144
|
-
const match = EXACT_VERSION_RE.exec(version);
|
|
2145
|
-
if (!match) throw new Error(`Unsupported exact version "${version}". Expected x.y.z format.`);
|
|
2146
|
-
return `>=${match[1]}.${match[2]}`;
|
|
2147
|
-
}
|
|
2148
2192
|
function getMinorVersionPeerRange(minimumVersion, supportedVersion) {
|
|
2149
2193
|
const match = EXACT_VERSION_RE.exec(supportedVersion);
|
|
2150
2194
|
if (!match) throw new Error(`Unsupported exact version "${supportedVersion}". Expected x.y.z format.`);
|
|
2151
2195
|
return `>=${minimumVersion} <${match[1]}.${Number(match[2]) + 1}.0`;
|
|
2152
2196
|
}
|
|
2197
|
+
function getNextMinorVersion(version) {
|
|
2198
|
+
const match = EXACT_VERSION_RE.exec(version);
|
|
2199
|
+
if (!match) throw new Error(`Unsupported exact version "${version}". Expected x.y.z format.`);
|
|
2200
|
+
return `${match[1]}.${Number(match[2]) + 1}.0`;
|
|
2201
|
+
}
|
|
2153
2202
|
function getPackageNameFromInstallSpec(spec) {
|
|
2154
2203
|
const normalized = spec.trim();
|
|
2155
2204
|
if (normalized.length === 0) throw new Error("Install spec must be non-empty.");
|
|
@@ -2201,8 +2250,11 @@ function resolveScaffoldInstallSpec(env = process.env) {
|
|
|
2201
2250
|
const SUPPORTED_DEPENDENCY_VERSIONS = {
|
|
2202
2251
|
convex: {
|
|
2203
2252
|
exact: SUPPORTED_CONVEX_VERSION,
|
|
2253
|
+
minimumType: SUPPORTED_CONVEX_MIN_TYPE_VERSION,
|
|
2204
2254
|
range: `^${SUPPORTED_CONVEX_VERSION}`,
|
|
2205
|
-
minimum:
|
|
2255
|
+
minimum: `>=${SUPPORTED_CONVEX_MIN_VERSION}`,
|
|
2256
|
+
maximumExclusive: getNextMinorVersion(SUPPORTED_CONVEX_VERSION),
|
|
2257
|
+
peer: getMinorVersionPeerRange(SUPPORTED_CONVEX_MIN_VERSION, SUPPORTED_CONVEX_VERSION)
|
|
2206
2258
|
},
|
|
2207
2259
|
betterAuth: {
|
|
2208
2260
|
exact: SUPPORTED_BETTER_AUTH_VERSION,
|
|
@@ -2261,20 +2313,31 @@ function compareMajorMinor(aMajor, aMinor, bMajor, bMinor) {
|
|
|
2261
2313
|
if (aMajor !== bMajor) return aMajor - bMajor;
|
|
2262
2314
|
return aMinor - bMinor;
|
|
2263
2315
|
}
|
|
2264
|
-
function
|
|
2316
|
+
function isConcreteVersionSpecOutsideRange(spec, minimum, maximumExclusive) {
|
|
2265
2317
|
const specMatch = VERSION_IN_SPEC_RE.exec(spec);
|
|
2266
2318
|
const minimumMatch = VERSION_IN_SPEC_RE.exec(minimum);
|
|
2267
|
-
|
|
2268
|
-
|
|
2319
|
+
const maximumMatch = VERSION_IN_SPEC_RE.exec(maximumExclusive);
|
|
2320
|
+
if (!specMatch || !minimumMatch || !maximumMatch) return false;
|
|
2321
|
+
const specMajor = Number(specMatch[1]);
|
|
2322
|
+
const specMinor = Number(specMatch[2]);
|
|
2323
|
+
const minimumMajor = Number(minimumMatch[1]);
|
|
2324
|
+
const minimumMinor = Number(minimumMatch[2]);
|
|
2325
|
+
const maximumMajor = Number(maximumMatch[1]);
|
|
2326
|
+
const maximumMinor = Number(maximumMatch[2]);
|
|
2327
|
+
return compareMajorMinor(specMajor, specMinor, minimumMajor, minimumMinor) < 0 || compareMajorMinor(specMajor, specMinor, maximumMajor, maximumMinor) >= 0;
|
|
2269
2328
|
}
|
|
2270
|
-
function
|
|
2329
|
+
function isDeclaredVersionSpecOutsideRange(spec, minimum, maximumExclusive) {
|
|
2271
2330
|
const normalized = spec.trim();
|
|
2272
|
-
if (PLAIN_VERSION_SPEC_RE.test(normalized)) return
|
|
2331
|
+
if (PLAIN_VERSION_SPEC_RE.test(normalized)) return isConcreteVersionSpecOutsideRange(normalized, minimum, maximumExclusive);
|
|
2273
2332
|
const minimumMatch = VERSION_IN_SPEC_RE.exec(minimum);
|
|
2274
|
-
|
|
2333
|
+
const maximumMatch = VERSION_IN_SPEC_RE.exec(maximumExclusive);
|
|
2334
|
+
if (!minimumMatch || !maximumMatch) return false;
|
|
2275
2335
|
const minimumMajor = Number(minimumMatch[1]);
|
|
2276
2336
|
const minimumMinor = Number(minimumMatch[2]);
|
|
2337
|
+
const maximumMajor = Number(maximumMatch[1]);
|
|
2338
|
+
const maximumMinor = Number(maximumMatch[2]);
|
|
2277
2339
|
for (const match of normalized.matchAll(UPPER_BOUND_RE)) if (compareMajorMinor(Number(match[1]), Number(match[2]), minimumMajor, minimumMinor) <= 0) return true;
|
|
2340
|
+
for (const match of normalized.matchAll(LOWER_BOUND_RE)) if (compareMajorMinor(Number(match[1]), Number(match[2]), maximumMajor, maximumMinor) >= 0) return true;
|
|
2278
2341
|
return false;
|
|
2279
2342
|
}
|
|
2280
2343
|
function resolveSupportedDependencyWarnings(cwd = process.cwd()) {
|
|
@@ -2282,18 +2345,18 @@ function resolveSupportedDependencyWarnings(cwd = process.cwd()) {
|
|
|
2282
2345
|
if (!packageJsonPath) return [];
|
|
2283
2346
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
2284
2347
|
const installedConvexVersion = readInstalledDependencyVersion(packageJsonPath, "convex");
|
|
2285
|
-
if (installedConvexVersion &&
|
|
2348
|
+
if (installedConvexVersion && isConcreteVersionSpecOutsideRange(installedConvexVersion, SUPPORTED_DEPENDENCY_VERSIONS.convex.minimum, SUPPORTED_DEPENDENCY_VERSIONS.convex.maximumExclusive)) return [{
|
|
2286
2349
|
packageName: "convex",
|
|
2287
2350
|
current: installedConvexVersion,
|
|
2288
|
-
|
|
2351
|
+
supported: SUPPORTED_DEPENDENCY_VERSIONS.convex.peer,
|
|
2289
2352
|
installSpec: PINNED_CONVEX_INSTALL_SPEC
|
|
2290
2353
|
}];
|
|
2291
2354
|
const convexVersion = readDependencyVersion(packageJson, "convex");
|
|
2292
|
-
if (!convexVersion || !
|
|
2355
|
+
if (!convexVersion || !isDeclaredVersionSpecOutsideRange(convexVersion, SUPPORTED_DEPENDENCY_VERSIONS.convex.minimum, SUPPORTED_DEPENDENCY_VERSIONS.convex.maximumExclusive)) return [];
|
|
2293
2356
|
return [{
|
|
2294
2357
|
packageName: "convex",
|
|
2295
2358
|
current: convexVersion,
|
|
2296
|
-
|
|
2359
|
+
supported: SUPPORTED_DEPENDENCY_VERSIONS.convex.peer,
|
|
2297
2360
|
installSpec: PINNED_CONVEX_INSTALL_SPEC
|
|
2298
2361
|
}];
|
|
2299
2362
|
}
|
|
@@ -3253,7 +3316,7 @@ const upsertReadOptionalRuntimeEnvOption = (source, keys) => {
|
|
|
3253
3316
|
const renderEnvHelperContent = (envFields, existingContent) => {
|
|
3254
3317
|
const fields = resolveBootstrapEnvFields(envFields);
|
|
3255
3318
|
const readOptionalRuntimeEnvKeys = resolveReadOptionalRuntimeEnvKeys(fields);
|
|
3256
|
-
if (!existingContent) return `import { createEnv } from 'kitcn/server';\nimport
|
|
3319
|
+
if (!existingContent) return `import { createEnv } from 'kitcn/server';\nimport * as z from 'zod';\n\nconst envSchema = z.object({\n${fields.map((field) => ` ${field.key}: ${field.schema},`).join("\n")}\n});\n\nexport const getEnv = createEnv({\n${renderReadOptionalRuntimeEnvOption(readOptionalRuntimeEnvKeys)} schema: envSchema,\n});\n`;
|
|
3257
3320
|
const match = existingContent.match(ENV_SCHEMA_RE);
|
|
3258
3321
|
if (!match) throw new Error("Expected env helper to define `const envSchema = z.object({ ... });`.");
|
|
3259
3322
|
const existingBody = match[2];
|
|
@@ -6765,7 +6828,7 @@ const authRegistryItem = defineInternalRegistryItem({
|
|
|
6765
6828
|
//#region src/cli/registry/items/ratelimit/ratelimit-functions.template.ts
|
|
6766
6829
|
const PROJECT_CRPC_IMPORT_PLACEHOLDER$3 = "__KITCN_PROJECT_CRPC_IMPORT__";
|
|
6767
6830
|
const RATELIMIT_FUNCTIONS_TEMPLATE = `import { cleanupRatelimitState } from "kitcn/ratelimit";
|
|
6768
|
-
import
|
|
6831
|
+
import * as z from "zod";
|
|
6769
6832
|
import { privateMutation } from "${PROJECT_CRPC_IMPORT_PLACEHOLDER$3}";
|
|
6770
6833
|
|
|
6771
6834
|
const DEFAULT_BATCH_SIZE = 500;
|
|
@@ -7081,7 +7144,7 @@ import {
|
|
|
7081
7144
|
Text,
|
|
7082
7145
|
} from '@react-email/components';
|
|
7083
7146
|
import { render } from '@react-email/render';
|
|
7084
|
-
import
|
|
7147
|
+
import * as z from 'zod';
|
|
7085
7148
|
import { privateAction } from '${PROJECT_CRPC_IMPORT_PLACEHOLDER$2}';
|
|
7086
7149
|
${PROJECT_GET_ENV_IMPORT_PLACEHOLDER$1}
|
|
7087
7150
|
import { createResendCaller } from '${FUNCTIONS_DIR_IMPORT_PLACEHOLDER$2}/generated/plugins/resend.runtime';
|
|
@@ -7201,7 +7264,7 @@ const RESEND_FUNCTIONS_TEMPLATE = `import {
|
|
|
7201
7264
|
shouldRetry,
|
|
7202
7265
|
} from '@kitcn/resend';
|
|
7203
7266
|
import { eq, inArray } from 'kitcn/orm';
|
|
7204
|
-
import
|
|
7267
|
+
import * as z from 'zod';
|
|
7205
7268
|
import { privateAction, privateMutation, privateQuery } from '${PROJECT_CRPC_IMPORT_PLACEHOLDER$1}';
|
|
7206
7269
|
import { resend } from '${PLUGIN_CONFIG_IMPORT_PLACEHOLDER}';
|
|
7207
7270
|
import {
|
|
@@ -8899,7 +8962,7 @@ function renderInitNextEnvLocalTemplate(source) {
|
|
|
8899
8962
|
//#endregion
|
|
8900
8963
|
//#region src/cli/registry/init/next/init-next-messages.template.ts
|
|
8901
8964
|
const resolveCrpcImportPath = (functionsDirRelative) => functionsDirRelative === "convex" ? "./lib/crpc" : "../lib/crpc";
|
|
8902
|
-
const renderInitNextMessagesTemplate = (functionsDirRelative = "convex/functions") => `import
|
|
8965
|
+
const renderInitNextMessagesTemplate = (functionsDirRelative = "convex/functions") => `import * as z from 'zod';
|
|
8903
8966
|
|
|
8904
8967
|
import { publicMutation, publicQuery } from '${resolveCrpcImportPath(functionsDirRelative)}';
|
|
8905
8968
|
|
|
@@ -14351,6 +14414,54 @@ const assertRawConvexAuthDeploymentReady = () => {
|
|
|
14351
14414
|
const convexUrl = localEnv[projectContext.convexUrlEnvKey]?.trim();
|
|
14352
14415
|
if (!deployment || !convexUrl) throw new Error(RAW_CONVEX_AUTH_DEPLOYMENT_ERROR);
|
|
14353
14416
|
};
|
|
14417
|
+
const runDependencyInstallStage = async (installPlan, stage, execaFn) => {
|
|
14418
|
+
try {
|
|
14419
|
+
await applyDependencyInstallPlan(installPlan, execaFn);
|
|
14420
|
+
} catch (error) {
|
|
14421
|
+
throw new Error(`${stage}: ${error instanceof Error ? error.message : String(error)}`);
|
|
14422
|
+
}
|
|
14423
|
+
};
|
|
14424
|
+
/**
|
|
14425
|
+
* The baseline install and the plugin package install run back to back with no
|
|
14426
|
+
* code between them, so they collapse into a single package-manager call.
|
|
14427
|
+
* Merging only happens when both legs target the same package.json with the
|
|
14428
|
+
* same package manager; otherwise each leg runs on its own.
|
|
14429
|
+
*/
|
|
14430
|
+
const mergeBaselineAndPluginInstall = (baseline, plugin) => {
|
|
14431
|
+
if (!baseline) return null;
|
|
14432
|
+
if (plugin.skipped || !(plugin.packageName && plugin.packageJsonPath)) return null;
|
|
14433
|
+
if (resolve(baseline.cwd) !== resolve(dirname(plugin.packageJsonPath))) return null;
|
|
14434
|
+
if (detectPackageManager(baseline.cwd) !== baseline.packageManager) return null;
|
|
14435
|
+
const pluginSpec = plugin.packageSpec ?? plugin.packageName;
|
|
14436
|
+
const packages = [...baseline.packages, pluginSpec];
|
|
14437
|
+
const { args, command } = resolveDependencyInstallCommand(baseline.packageManager, packages);
|
|
14438
|
+
return {
|
|
14439
|
+
...baseline,
|
|
14440
|
+
args,
|
|
14441
|
+
command,
|
|
14442
|
+
packages
|
|
14443
|
+
};
|
|
14444
|
+
};
|
|
14445
|
+
const installBaselineAndPluginDependencies = async (params) => {
|
|
14446
|
+
const { baseline, plugin, pluginKey, execaFn } = params;
|
|
14447
|
+
const merged = mergeBaselineAndPluginInstall(baseline, plugin);
|
|
14448
|
+
if (merged) {
|
|
14449
|
+
await runDependencyInstallStage(merged, `Installing baseline dependencies and the ${pluginKey} package`, execaFn);
|
|
14450
|
+
return {
|
|
14451
|
+
packageName: plugin.packageName,
|
|
14452
|
+
packageSpec: plugin.packageSpec ?? plugin.packageName,
|
|
14453
|
+
packageJsonPath: plugin.packageJsonPath,
|
|
14454
|
+
installed: true,
|
|
14455
|
+
skipped: false
|
|
14456
|
+
};
|
|
14457
|
+
}
|
|
14458
|
+
await runDependencyInstallStage(baseline, "Installing baseline dependencies", execaFn);
|
|
14459
|
+
try {
|
|
14460
|
+
return await applyPluginDependencyInstall(plugin, execaFn);
|
|
14461
|
+
} catch (error) {
|
|
14462
|
+
throw new Error(`Installing the ${pluginKey} package: ${error instanceof Error ? error.message : String(error)}`);
|
|
14463
|
+
}
|
|
14464
|
+
};
|
|
14354
14465
|
const handleAddCommand = async (argv, deps = {}) => {
|
|
14355
14466
|
const parsed = parseArgs(argv);
|
|
14356
14467
|
if (HELP_FLAGS$10.has(argv[0] ?? "") || HELP_FLAGS$10.has(parsed.restArgs[0] ?? "")) {
|
|
@@ -14464,8 +14575,12 @@ const handleAddCommand = async (argv, deps = {}) => {
|
|
|
14464
14575
|
yes: addArgs.yes,
|
|
14465
14576
|
promptAdapter
|
|
14466
14577
|
});
|
|
14467
|
-
|
|
14468
|
-
|
|
14578
|
+
const dependencyInstall = await installBaselineAndPluginDependencies({
|
|
14579
|
+
baseline: initializationPlan?.dependencyInstall ?? null,
|
|
14580
|
+
plugin: plan.dependency,
|
|
14581
|
+
pluginKey: selectedPlugin,
|
|
14582
|
+
execaFn
|
|
14583
|
+
});
|
|
14469
14584
|
const installedDependencyHints = await applyDependencyHintsInstall(plan.dependencyHints, execaFn);
|
|
14470
14585
|
const payload = {
|
|
14471
14586
|
command: "add",
|
|
@@ -15790,7 +15905,7 @@ function warnSupportedDependencyIssues(command) {
|
|
|
15790
15905
|
const packageManager = detectPackageManager(process.cwd());
|
|
15791
15906
|
for (const warning of resolveSupportedDependencyWarnings()) {
|
|
15792
15907
|
const installCommand = formatDependencyInstallCommand(packageManager, [warning.installSpec]);
|
|
15793
|
-
logger.warn(`⚠️ kitcn expects ${warning.packageName} ${warning.
|
|
15908
|
+
logger.warn(`⚠️ kitcn expects ${warning.packageName} ${warning.supported}; found ${warning.current}. Run \`${installCommand}\` when you can.`);
|
|
15794
15909
|
}
|
|
15795
15910
|
}
|
|
15796
15911
|
const handlePassthroughCommand = async (argv, deps) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as pick, r as omit } from "./upstream-BCgGZX6q.js";
|
|
2
|
-
import { t as addFieldsToValidator } from "./validators-
|
|
2
|
+
import { t as addFieldsToValidator } from "./validators-CIoUYCqO.js";
|
|
3
3
|
|
|
4
4
|
//#region src/internal/upstream/server/customFunctions.ts
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as integer, C as index, I as ConvexColumnBuilder, L as entityKind, M as custom, O as text, t as convexTable } from "./table-
|
|
2
|
-
import { t as defineSchemaExtension } from "./extensions-
|
|
1
|
+
import { A as integer, C as index, I as ConvexColumnBuilder, L as entityKind, M as custom, O as text, t as convexTable } from "./table-CX2lnX7e.js";
|
|
2
|
+
import { t as defineSchemaExtension } from "./extensions-Blzsyekm.js";
|
|
3
3
|
import { v } from "convex/values";
|
|
4
4
|
|
|
5
5
|
//#region src/orm/builders/boolean.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as OrmSchemaExtensionTriggers, l as OrmSchemaExtensionRelations } from "./table-
|
|
1
|
+
import { d as OrmSchemaExtensionTriggers, l as OrmSchemaExtensionRelations } from "./table-CX2lnX7e.js";
|
|
2
2
|
|
|
3
3
|
//#region src/orm/extensions.ts
|
|
4
4
|
function defineChainMethod(target, key, value) {
|
|
@@ -679,6 +679,7 @@ function vRequired(validator) {
|
|
|
679
679
|
case "string": return v.string();
|
|
680
680
|
case "float64": return v.float64();
|
|
681
681
|
case "int64": return v.int64();
|
|
682
|
+
case "commitTs": return v.commitTs();
|
|
682
683
|
case "boolean": return v.boolean();
|
|
683
684
|
case "null": return v.null();
|
|
684
685
|
case "any": return v.any();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as DirectAggregate } from "../../runtime-
|
|
2
|
-
import { a as Columns } from "../../table-
|
|
3
|
-
import { Y as normalizeTemporalComparableValue, _t as
|
|
1
|
+
import { t as DirectAggregate } from "../../runtime-BdqTbgKh.js";
|
|
2
|
+
import { a as Columns } from "../../table-CX2lnX7e.js";
|
|
3
|
+
import { Y as normalizeTemporalComparableValue, _t as PUBLIC_CREATED_AT_FIELD, c as AGGREGATE_ERROR, f as createError, gt as INTERNAL_CREATION_TIME_FIELD, i as AGGREGATE_STATE_TABLE, l as COUNT_ERROR, n as AGGREGATE_EXTREMA_TABLE, o as getAggregateIndexDefinitions, ot as mapWithConcurrency, r as AGGREGATE_MEMBER_TABLE, s as getRankIndexDefinitions, t as AGGREGATE_BUCKET_TABLE, vt as usesSystemCreatedAtAlias } from "../../schema-D8sVYuYO.js";
|
|
4
4
|
|
|
5
5
|
//#region src/orm/aggregate-index/runtime.ts
|
|
6
6
|
const UNDEFINED_SENTINEL = "__kitcnUndefined";
|
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $n as BinaryExpression, $t as OrmLifecycleOperation, A as DatabaseWithMutations, An as ConvexCheckConfig, Ar as AnyColumn, At as VectorQueryConfig, B as RlsContext, Bn as ConvexTextBuilderInitial, Br as IsUnique, Bt as RelationsBuilderColumnConfig, C as MigrationTableName, Cn as aggregateIndex, Cr as notBetween, Ct as OrderDirection, D as defineMigrationSet, Dn as uniqueIndex, Dt as ReturningResult, E as defineMigration, En as searchIndex, Er as startsWith, Et as ReturningAll, Fn as ConvexUniqueConstraintConfig, Fr as ColumnBuilderWithTableName, Ft as ExtractTablesWithRelations, Gt as defineRelations, H as EdgeMetadata, In as check, Ir as ColumnDataType, It as ManyConfig, Jt as ConvexDeletionConfig, Kt as defineRelationsPart, Ln as foreignKey, Lr as DrizzleEntity, Lt as OneConfig, M as OrmReader$1, Mn as ConvexForeignKeyConfig, Mr as ColumnBuilderBaseConfig, Mt as unsetToken, N as OrmWriter$1, Nn as ConvexUniqueConstraintBuilder, Nr as ColumnBuilderRuntimeConfig, O as detectMigrationDrift, On as vectorIndex, Or as SystemFields, Ot as ReturningSelection, Pn as ConvexUniqueConstraintBuilderOn, Pr as ColumnBuilderTypeConfig, Pt as ExtractTablesFromSchema, Qn as TableName, Qt as OrmLifecycleChange, Rn as unique, Rr as HasDefault, Rt as RelationsBuilder, S as MigrationStep, Sn as ConvexVectorIndexConfig, Sr as not, St as OrderByClause, T as buildMigrationPlan, Tn as rankIndex, Tr as or, Tt as PredicateWhereIndexConfig, U as extractRelationsConfig, Un as Brand, Ut as TableRelationalConfig, V as RlsMode, Vn as text, Vr as NotNull, Wn as Columns, Wt as TablesRelationalConfig, Xn as OrmSchemaRelations, Xt as ConvexTableWithColumns, Yn as OrmSchemaExtensions, Yt as ConvexTable, Zn as OrmSchemaTriggers, Zt as DiscriminatorBuilderConfig, _ as MigrationMigrateOne, _n as ConvexSearchIndexBuilder, _r as isNull, _t as MutationPaginateConfig, an as RlsPolicyConfig, ar as and, at as CountConfig, b as MigrationSet, bn as ConvexVectorIndexBuilder, br as lte, bt as MutationReturning, cn as RlsRole, cr as endsWith, ct as FilterOperators, d as MigrationDefinition, dn as ConvexAggregateIndexBuilder, dr as gt, dt as InferModelFromColumns, en as TableConfig, er as ExpressionVisitor, et as AggregateConfig, f as MigrationDirection, fn as ConvexAggregateIndexBuilderOn, fr as gte, ft as InferSelectModel, g as MigrationManifestEntry, gn as ConvexRankIndexBuilderOn, gr as isNotNull, gt as MutationExecutionMode, h as MigrationDriftIssue, hn as ConvexRankIndexBuilder, hr as isFieldReference, ht as MutationExecuteResult, i as OrmMigrationCapability, in as RlsPolicy, ir as UnaryExpression, it as BuildRelationResult, j as DatabaseWithQuery, jn as ConvexForeignKeyBuilder, jr as ColumnBuilder, jt as VectorSearchProvider, kn as ConvexCheckBuilder, kt as UpdateSet, ln as RlsRoleConfig, lr as eq, lt as GetColumnData, m as MigrationDocContext, mn as ConvexIndexBuilderOn, mr as inArray, mt as MutationExecuteConfig, n as OrmCapabilities, nn as deletion, nr as FilterExpression, nt as AggregateResult, on as RlsPolicyToOption, or as between, ot as CountResult, p as MigrationDoc, pn as ConvexIndexBuilder, pr as ilike, pt as InsertValue, qn as OrmSchemaExtensionTables, qt as ConvexDeletionBuilder, r as OrmCapability, rn as discriminator, rr as LogicalExpression, rt as BuildQueryResult, sn as rlsPolicy, sr as contains, st as DBQueryConfig, t as OrmAggregateCapability, tn as convexTable, tr as FieldReference, tt as AggregateFieldValue, u as MigrationAppliedState, un as rlsRole, ur as fieldRef, ut as InferInsertModel, v as MigrationPlan, vn as ConvexSearchIndexBuilderOn, vr as like, vt as MutationPaginatedResult, w as MigrationWriteMode, wn as index, wr as notInArray, wt as PaginatedResult, x as MigrationStateMap, xn as ConvexVectorIndexBuilderOn, xr as ne, xt as MutationRunMode, y as MigrationRunStatus, yn as ConvexSearchIndexConfig, yr as lt, yt as MutationResult, zn as ConvexTextBuilder, zr as IsPrimaryKey, zt as RelationsBuilderColumnBase } from "../capabilities-Bem7xvGK.js";
|
|
2
|
-
import { $ as OrmClientWithApi$1, A as ConvexDateMode, B as ConvexBytesBuilderInitial, C as ConvexNumberBuilderInitial, D as id, E as ConvexIdBuilderInitial, F as custom, G as ConvexBigIntBuilder, H as ConvexBooleanBuilder, I as json, J as CreateOrmOptions, K as ConvexBigIntBuilderInitial, L as objectOf, M as ConvexCustomBuilder, N as ConvexCustomBuilderInitial, O as ConvexDateBuilder, P as arrayOf, Q as OrmClientBase$1, R as unionOf, S as ConvexNumberBuilder, St as defineTriggers, T as ConvexIdBuilder, U as ConvexBooleanBuilderInitial, V as bytes, W as boolean, X as GenericOrmCtx$1, Y as GenericOrm$1, Z as OrmApiResult, _ as ConvexTimestampMode, _t as OrmBeforeResult, a as requireSchemaRelations, at as ScheduledMutationBatchArgs, b as ConvexTextEnumBuilderInitial, bt as OrmTriggerContext, c as TableConfigResult, ct as scheduledDeleteFactory, d as OrmNotFoundError, et as OrmFunctions, f as ConvexVectorBuilder, g as ConvexTimestampBuilderInitial, gt as defineSchemaExtension, h as ConvexTimestampBuilder, ht as SchemaExtension, i as getSchemaTriggers, it as createOrm, j as date, k as ConvexDateBuilderInitial, l as getTableColumns, m as vector, n as defineSchema, nt as OrmWriterCtx, o as asc, ot as scheduledMutationBatchFactory, p as ConvexVectorBuilderInitial, q as bigint, r as getSchemaRelations, rt as ResolveOrmSchema, s as desc, st as ScheduledDeleteArgs, t as WhereClauseResult, tt as OrmReaderCtx, u as getTableConfig, v as timestamp, vt as OrmTableTriggers, w as integer, x as textEnum, xt as OrmTriggers, y as ConvexTextEnumBuilder, yt as OrmTriggerChange, z as ConvexBytesBuilder } from "../where-clause-compiler-
|
|
3
|
-
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-
|
|
2
|
+
import { $ as OrmClientWithApi$1, A as ConvexDateMode, B as ConvexBytesBuilderInitial, C as ConvexNumberBuilderInitial, D as id, E as ConvexIdBuilderInitial, F as custom, G as ConvexBigIntBuilder, H as ConvexBooleanBuilder, I as json, J as CreateOrmOptions, K as ConvexBigIntBuilderInitial, L as objectOf, M as ConvexCustomBuilder, N as ConvexCustomBuilderInitial, O as ConvexDateBuilder, P as arrayOf, Q as OrmClientBase$1, R as unionOf, S as ConvexNumberBuilder, St as defineTriggers, T as ConvexIdBuilder, U as ConvexBooleanBuilderInitial, V as bytes, W as boolean, X as GenericOrmCtx$1, Y as GenericOrm$1, Z as OrmApiResult, _ as ConvexTimestampMode, _t as OrmBeforeResult, a as requireSchemaRelations, at as ScheduledMutationBatchArgs, b as ConvexTextEnumBuilderInitial, bt as OrmTriggerContext, c as TableConfigResult, ct as scheduledDeleteFactory, d as OrmNotFoundError, et as OrmFunctions, f as ConvexVectorBuilder, g as ConvexTimestampBuilderInitial, gt as defineSchemaExtension, h as ConvexTimestampBuilder, ht as SchemaExtension, i as getSchemaTriggers, it as createOrm, j as date, k as ConvexDateBuilderInitial, l as getTableColumns, m as vector, n as defineSchema, nt as OrmWriterCtx, o as asc, ot as scheduledMutationBatchFactory, p as ConvexVectorBuilderInitial, q as bigint, r as getSchemaRelations, rt as ResolveOrmSchema, s as desc, st as ScheduledDeleteArgs, t as WhereClauseResult, tt as OrmReaderCtx, u as getTableConfig, v as timestamp, vt as OrmTableTriggers, w as integer, x as textEnum, xt as OrmTriggers, y as ConvexTextEnumBuilder, yt as OrmTriggerChange, z as ConvexBytesBuilder } from "../where-clause-compiler-TMNQB6US.js";
|
|
3
|
+
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-wOIjhkfN.js";
|
|
4
4
|
import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-DJONf8X5.js";
|
|
5
5
|
import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
|
|
6
6
|
|
package/dist/orm/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as integer, C as index, D as vectorIndex, E as uniqueIndex, F as unionOf, I as ConvexColumnBuilder, L as entityKind, M as custom, N as json, O as text, P as objectOf, S as aggregateIndex, T as searchIndex, a as Columns, b as RlsPolicy, c as OrmSchemaDefinition, d as OrmSchemaExtensionTriggers, f as OrmSchemaExtensions, g as RlsPolicies, h as OrmSchemaTriggers, i as Brand, j as arrayOf, k as createSystemFields, l as OrmSchemaExtensionRelations, m as OrmSchemaRelations, n as deletion, o as EnableRLS, p as OrmSchemaOptions, r as discriminator, s as OrmContext, t as convexTable, u as OrmSchemaExtensionTables, v as TableName, w as rankIndex, x as rlsPolicy, y as TablePolymorphic } from "../table-
|
|
2
|
-
import { d as boolean, i as detectMigrationDrift, l as migrationExtension, n as defineMigration, r as defineMigrationSet, t as buildMigrationPlan } from "../definitions-
|
|
3
|
-
import { a as pretendRequired, i as pretend, n as deprecated } from "../validators-
|
|
4
|
-
import { t as id } from "../id-
|
|
1
|
+
import { A as integer, C as index, D as vectorIndex, E as uniqueIndex, F as unionOf, I as ConvexColumnBuilder, L as entityKind, M as custom, N as json, O as text, P as objectOf, S as aggregateIndex, T as searchIndex, a as Columns, b as RlsPolicy, c as OrmSchemaDefinition, d as OrmSchemaExtensionTriggers, f as OrmSchemaExtensions, g as RlsPolicies, h as OrmSchemaTriggers, i as Brand, j as arrayOf, k as createSystemFields, l as OrmSchemaExtensionRelations, m as OrmSchemaRelations, n as deletion, o as EnableRLS, p as OrmSchemaOptions, r as discriminator, s as OrmContext, t as convexTable, u as OrmSchemaExtensionTables, v as TableName, w as rankIndex, x as rlsPolicy, y as TablePolymorphic } from "../table-CX2lnX7e.js";
|
|
2
|
+
import { d as boolean, i as detectMigrationDrift, l as migrationExtension, n as defineMigration, r as defineMigrationSet, t as buildMigrationPlan } from "../definitions-Dzk8mSTL.js";
|
|
3
|
+
import { a as pretendRequired, i as pretend, n as deprecated } from "../validators-CIoUYCqO.js";
|
|
4
|
+
import { t as id } from "../id-CuSfWa5q.js";
|
|
5
5
|
import { A as or, C as matchLikePattern, D as notIlike, E as notBetween, O as notInArray, S as lte, T as not, _ as isFieldReference, a as between, b as like, c as endsWith, d as filterValueInList, f as filterValuesEqual, g as inArray, h as ilike, i as arrayOverlaps, j as startsWith, k as notLike, l as eq, m as gte, n as arrayContained, o as column, p as gt, r as arrayContains, s as contains, t as and, u as fieldRef, v as isNotNull, w as ne, x as lt, y as isNull } from "../filter-expression-Dydt8wS0.js";
|
|
6
6
|
import { a as indexKeyWithinBounds, c as streamIndexRange, i as getIndexFields, l as isUnsetToken, n as EmptyStream, o as mergedStream, r as QueryStream, s as stream, t as getByIdWithOrmQueryFallback, u as unsetToken } from "../query-context-DOm5Xm3H.js";
|
|
7
|
-
import { $ as serializeFilterExpression, A as ensureNonNullValues, B as getMutationExecutionMode, C as deserializeFilterExpression, D as enforcePolymorphicWrite, E as enforceForeignKeys, F as getChecks, G as getUniqueIndexes, H as getTableColumns$2, I as getColumnName$1, J as normalizeDateFieldsForWrite, K as hardDeleteRow, L as getForeignKeys, M as evaluateCheckConstraintTriState, N as evaluateFilter, O as enforceUniqueIndexes, P as extractPrimaryIdLookup, Q as selectReturningRowWithHydration, R as getMutationAsyncDelayMs, S as decodeUndefinedDeep, T as enforceCheckConstraints, U as getTableDeleteConfig, V as getOrmContext, W as getTableName, X as patchReferencingRows, Y as normalizeTemporalComparableValue, Z as resolveOrmRuntimeDefaults, _ as applyIncomingForeignKeyActionsOnUpdate, _t as
|
|
8
|
-
import { t as defineSchemaExtension } from "../extensions-
|
|
7
|
+
import { $ as serializeFilterExpression, A as ensureNonNullValues, B as getMutationExecutionMode, C as deserializeFilterExpression, D as enforcePolymorphicWrite, E as enforceForeignKeys, F as getChecks, G as getUniqueIndexes, H as getTableColumns$2, I as getColumnName$1, J as normalizeDateFieldsForWrite, K as hardDeleteRow, L as getForeignKeys, M as evaluateCheckConstraintTriState, N as evaluateFilter, O as enforceUniqueIndexes, P as extractPrimaryIdLookup, Q as selectReturningRowWithHydration, R as getMutationAsyncDelayMs, S as decodeUndefinedDeep, T as enforceCheckConstraints, U as getTableDeleteConfig, V as getOrmContext, W as getTableName, X as patchReferencingRows, Y as normalizeTemporalComparableValue, Z as resolveOrmRuntimeDefaults, _ as applyIncomingForeignKeyActionsOnUpdate, _t as PUBLIC_CREATED_AT_FIELD, a as aggregateExtension, at as markLifecycleHookedTables, b as collectMutationRowsBounded, c as AGGREGATE_ERROR, ct as findRelationIndex, d as createCountError, dt as getAggregateIndexes, et as softDeleteRow, ft as getIndexes, g as applyIncomingForeignKeyActionsOnDelete, gt as INTERNAL_CREATION_TIME_FIELD, h as applyDefaults, ht as CREATED_AT_MIGRATION_MESSAGE, it as hasLifecycleHooks, j as ensureNullableColumns, k as ensureDefaultColumns, l as COUNT_ERROR, lt as findSearchIndexByName, m as ensureCountAllowedForRls, mt as resolveIndexOrderPushdown, nt as takeRowsWithinByteBudget, o as getAggregateIndexDefinitions, ot as mapWithConcurrency, p as ensureAggregateAllowedForRls, pt as getRankIndexes, q as hydrateDateFieldsForRead, rt as toConvexFilter, s as getRankIndexDefinitions, st as findIndexForColumns, tt as splitReturningSelection, u as createAggregateError, ut as findVectorIndexByName, v as buildForeignKeyGraph, vt as usesSystemCreatedAtAlias, w as encodeUndefinedDeep, x as collectPrimaryIdLookupRows, y as canUsePrimaryIdLookupCursor, z as getMutationCollectionLimits } from "../schema-D8sVYuYO.js";
|
|
8
|
+
import { t as defineSchemaExtension } from "../extensions-Blzsyekm.js";
|
|
9
9
|
import { compareValues, v } from "convex/values";
|
|
10
10
|
import { defineSchema as defineSchema$1, internalActionGeneric, internalMutationGeneric } from "convex/server";
|
|
11
11
|
|
|
@@ -6142,6 +6142,7 @@ function writerWithHooks(ctx, innerDb, hooksByTable, isWithinHook = false) {
|
|
|
6142
6142
|
patch,
|
|
6143
6143
|
replace,
|
|
6144
6144
|
delete: delete_,
|
|
6145
|
+
vars: innerDb.vars,
|
|
6145
6146
|
system: innerDb.system,
|
|
6146
6147
|
get: innerDb.get.bind(innerDb),
|
|
6147
6148
|
query: innerDb.query.bind(innerDb),
|
|
@@ -6702,11 +6703,43 @@ var ConvexUpdateBuilder = class extends QueryPromise {
|
|
|
6702
6703
|
callCap: scheduleCallCap
|
|
6703
6704
|
};
|
|
6704
6705
|
const fkBatchSize = isPaginated ? pagination.limit : batchSize;
|
|
6706
|
+
const changedFields = new Set(Object.keys(writeSet));
|
|
6707
|
+
const incomingForeignKeys = foreignKeyGraph.incomingByTable.get(tableName) ?? [];
|
|
6708
|
+
const hooksCanWriteMidLoop = hasLifecycleHooks(this.db, tableName) || incomingForeignKeys.some((foreignKey) => hasLifecycleHooks(this.db, foreignKey.sourceTableName));
|
|
6709
|
+
const cascadeTargetsThisTable = incomingForeignKeys.some((foreignKey) => foreignKey.sourceTableName === tableName);
|
|
6710
|
+
const canDerivePostImage = !(hooksCanWriteMidLoop || cascadeTargetsThisTable);
|
|
6711
|
+
const unsetFields = Object.keys(writeSet).filter((field) => writeSet[field] === void 0);
|
|
6712
|
+
const derivePostImage = (candidate) => {
|
|
6713
|
+
if (unsetFields.length === 0) return candidate;
|
|
6714
|
+
const postImage = { ...candidate };
|
|
6715
|
+
for (const field of unsetFields) delete postImage[field];
|
|
6716
|
+
return postImage;
|
|
6717
|
+
};
|
|
6718
|
+
/**
|
|
6719
|
+
* A single-column `references()` FK to `_id` whose column is supplied by
|
|
6720
|
+
* `set()` probes a byte-identical id on every row, and nothing in this loop
|
|
6721
|
+
* can delete that document. Probe it once, then hide those columns from
|
|
6722
|
+
* `enforceForeignKeys` so the remaining keys still get their per-row check.
|
|
6723
|
+
* Composite FKs read columns off `row`, so they genuinely vary.
|
|
6724
|
+
*/
|
|
6725
|
+
const memoizedFkColumns = /* @__PURE__ */ new Set();
|
|
6726
|
+
const perRowFkColumns = /* @__PURE__ */ new Set();
|
|
6727
|
+
for (const foreignKey of getForeignKeys(this.table)) {
|
|
6728
|
+
if (!hooksCanWriteMidLoop && foreignKey.columns.length === 1 && foreignKey.foreignColumns.length === 1 && foreignKey.foreignColumns[0] === "_id" && changedFields.has(foreignKey.columns[0])) {
|
|
6729
|
+
memoizedFkColumns.add(foreignKey.columns[0]);
|
|
6730
|
+
continue;
|
|
6731
|
+
}
|
|
6732
|
+
for (const column of foreignKey.columns) perRowFkColumns.add(column);
|
|
6733
|
+
}
|
|
6734
|
+
for (const column of perRowFkColumns) memoizedFkColumns.delete(column);
|
|
6735
|
+
const residualChangedFields = memoizedFkColumns.size === 0 ? changedFields : new Set([...changedFields].filter((field) => !memoizedFkColumns.has(field)));
|
|
6736
|
+
let foreignKeysProbed = false;
|
|
6705
6737
|
for (const { row, updatedRow, decision } of updates) {
|
|
6706
6738
|
if (!decision.allowed) continue;
|
|
6707
|
-
enforcePolymorphicWrite(this.table, updatedRow, { changedFields
|
|
6739
|
+
enforcePolymorphicWrite(this.table, updatedRow, { changedFields });
|
|
6708
6740
|
enforceCheckConstraints(this.table, updatedRow);
|
|
6709
|
-
await enforceForeignKeys(this.db, this.table, updatedRow, { changedFields:
|
|
6741
|
+
await enforceForeignKeys(this.db, this.table, updatedRow, { changedFields: foreignKeysProbed ? residualChangedFields : changedFields });
|
|
6742
|
+
foreignKeysProbed = true;
|
|
6710
6743
|
await applyIncomingForeignKeyActionsOnUpdate(this.db, this.table, row, updatedRow, {
|
|
6711
6744
|
graph: foreignKeyGraph,
|
|
6712
6745
|
batchSize: fkBatchSize,
|
|
@@ -6723,12 +6756,12 @@ var ConvexUpdateBuilder = class extends QueryPromise {
|
|
|
6723
6756
|
});
|
|
6724
6757
|
await enforceUniqueIndexes(this.db, this.table, updatedRow, {
|
|
6725
6758
|
currentId: row._id,
|
|
6726
|
-
changedFields
|
|
6759
|
+
changedFields
|
|
6727
6760
|
});
|
|
6728
6761
|
await this.db.patch(tableName, row._id, writeSet);
|
|
6729
6762
|
numAffected++;
|
|
6730
6763
|
if (!this.returningFields) continue;
|
|
6731
|
-
const updated = await this.db.get(row._id);
|
|
6764
|
+
const updated = canDerivePostImage ? derivePostImage(updatedRow) : await this.db.get(row._id);
|
|
6732
6765
|
if (!updated) continue;
|
|
6733
6766
|
if (this.returningFields === true) results.push(hydrateDateFieldsForRead(this.table, updated));
|
|
6734
6767
|
else {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { C as MigrationTableName, D as defineMigrationSet, E as defineMigration, O as detectMigrationDrift, S as MigrationStep, T as buildMigrationPlan, _ as MigrationMigrateOne, a as MigrationCancelArgs, b as MigrationSet, c as MigrationStatusArgs, d as MigrationDefinition, f as MigrationDirection, g as MigrationManifestEntry, h as MigrationDriftIssue, l as createMigrationHandlers, m as MigrationDocContext, o as MigrationRunArgs, p as MigrationDoc, s as MigrationRunChunkArgs, u as MigrationAppliedState, v as MigrationPlan, w as MigrationWriteMode, x as MigrationStateMap, y as MigrationRunStatus } from "../../capabilities-Bem7xvGK.js";
|
|
2
|
-
import { Ct as migrationCapability, dt as MIGRATION_STORAGE_TABLE_NAMES, ft as injectMigrationStorageTables, lt as MIGRATION_RUN_TABLE, mt as migrationStorageTables, pt as migrationExtension, ut as MIGRATION_STATE_TABLE } from "../../where-clause-compiler-
|
|
2
|
+
import { Ct as migrationCapability, dt as MIGRATION_STORAGE_TABLE_NAMES, ft as injectMigrationStorageTables, lt as MIGRATION_RUN_TABLE, mt as migrationStorageTables, pt as migrationExtension, ut as MIGRATION_STATE_TABLE } from "../../where-clause-compiler-TMNQB6US.js";
|
|
3
3
|
export { MIGRATION_RUN_TABLE, MIGRATION_STATE_TABLE, MIGRATION_STORAGE_TABLE_NAMES, type MigrationAppliedState, type MigrationCancelArgs, type MigrationDefinition, type MigrationDirection, type MigrationDoc, type MigrationDocContext, type MigrationDriftIssue, type MigrationManifestEntry, type MigrationMigrateOne, type MigrationPlan, type MigrationRunArgs, type MigrationRunChunkArgs, type MigrationRunStatus, type MigrationSet, type MigrationStateMap, type MigrationStatusArgs, type MigrationStep, type MigrationTableName, type MigrationWriteMode, buildMigrationPlan, createMigrationHandlers, defineMigration, defineMigrationSet, detectMigrationDrift, injectMigrationStorageTables, migrationCapability, migrationExtension, migrationStorageTables };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as MIGRATION_RUN_TABLE, c as injectMigrationStorageTables, i as detectMigrationDrift, l as migrationExtension, n as defineMigration, o as MIGRATION_STATE_TABLE, r as defineMigrationSet, s as MIGRATION_STORAGE_TABLE_NAMES, t as buildMigrationPlan, u as migrationStorageTables } from "../../definitions-
|
|
1
|
+
import { a as MIGRATION_RUN_TABLE, c as injectMigrationStorageTables, i as detectMigrationDrift, l as migrationExtension, n as defineMigration, o as MIGRATION_STATE_TABLE, r as defineMigrationSet, s as MIGRATION_STORAGE_TABLE_NAMES, t as buildMigrationPlan, u as migrationStorageTables } from "../../definitions-Dzk8mSTL.js";
|
|
2
2
|
|
|
3
3
|
//#region src/orm/migrations/runtime.ts
|
|
4
4
|
const DEFAULT_BATCH_SIZE = 128;
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as decodeWire, o as encodeWire } from "./transformer-D8wO-kEj.js";
|
|
2
|
-
import { _ as CRPCError } from "./builder-
|
|
3
|
-
import
|
|
2
|
+
import { _ as CRPCError } from "./builder-DoeyW4Vq.js";
|
|
3
|
+
import * as z$1 from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/server/env.ts
|
|
6
6
|
function createEnv(options) {
|
|
@@ -34,7 +34,7 @@ function createEnv(options) {
|
|
|
34
34
|
...Object.fromEntries(Object.entries(schema.shape).map(([key, zodType]) => {
|
|
35
35
|
const result = zodType.safeParse(void 0);
|
|
36
36
|
if (!result.success) {
|
|
37
|
-
if (zodType instanceof z.ZodEnum && Array.isArray(zodType.options) && zodType.options.length > 0) return [key, zodType.options[0]];
|
|
37
|
+
if (zodType instanceof z$1.ZodEnum && Array.isArray(zodType.options) && zodType.options.length > 0) return [key, zodType.options[0]];
|
|
38
38
|
return [key, ""];
|
|
39
39
|
}
|
|
40
40
|
return [key, typeof result.data === "string" ? result.data : void 0];
|