kitcn 0.12.14 → 0.12.15
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.
|
@@ -2204,13 +2204,14 @@ const JITI_EXPORT_CONDITION_PRIORITY = [
|
|
|
2204
2204
|
"default",
|
|
2205
2205
|
"require"
|
|
2206
2206
|
];
|
|
2207
|
-
const SERVER_PARSER_SHIM_SOURCE = `const
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2207
|
+
const SERVER_PARSER_SHIM_SOURCE = `const createMiddleware = (handler = undefined) => ({
|
|
2208
|
+
_handler: handler,
|
|
2209
|
+
pipe(nextHandler) {
|
|
2210
|
+
return createMiddleware(nextHandler);
|
|
2211
|
+
},
|
|
2212
|
+
});
|
|
2213
|
+
|
|
2214
|
+
const createProcedureBuilder = () => {
|
|
2214
2215
|
const builder = {
|
|
2215
2216
|
internal() {
|
|
2216
2217
|
return builder;
|
|
@@ -2353,13 +2354,14 @@ const ensureServerParserShim = (cwd) => {
|
|
|
2353
2354
|
if (!fs.existsSync(shimPath) || fs.readFileSync(shimPath, "utf8") !== SERVER_PARSER_SHIM_SOURCE) fs.writeFileSync(shimPath, SERVER_PARSER_SHIM_SOURCE, "utf8");
|
|
2354
2355
|
return shimPath;
|
|
2355
2356
|
};
|
|
2357
|
+
const getProjectServerParserShimPath = (cwd = process.cwd()) => ensureServerParserShim(cwd);
|
|
2356
2358
|
const createProjectJiti = (cwd = process.cwd()) => createJiti(cwd, {
|
|
2357
2359
|
interopDefault: true,
|
|
2358
2360
|
moduleCache: false,
|
|
2359
2361
|
alias: {
|
|
2360
2362
|
...buildLocalPackageExportAliases(cwd, "kitcn"),
|
|
2361
2363
|
...buildLocalPackageExportAliases(cwd, "convex"),
|
|
2362
|
-
"kitcn/server":
|
|
2364
|
+
"kitcn/server": getProjectServerParserShimPath(cwd)
|
|
2363
2365
|
}
|
|
2364
2366
|
});
|
|
2365
2367
|
|
|
@@ -4230,6 +4232,13 @@ export type MutationCtx = ServerMutationCtx;
|
|
|
4230
4232
|
export type ActionCtx = ServerActionCtx;
|
|
4231
4233
|
export type GenericCtx = QueryCtx | MutationCtx | ActionCtx;
|
|
4232
4234
|
|
|
4235
|
+
const createMiddleware = (handler?: unknown) => ({
|
|
4236
|
+
_handler: handler,
|
|
4237
|
+
pipe(nextHandler?: unknown) {
|
|
4238
|
+
return createMiddleware(nextHandler);
|
|
4239
|
+
},
|
|
4240
|
+
});
|
|
4241
|
+
|
|
4233
4242
|
const createProcedureBuilder = () => {
|
|
4234
4243
|
const builder = {
|
|
4235
4244
|
internal() {
|
|
@@ -4256,6 +4265,9 @@ const createProcedureBuilder = () => {
|
|
|
4256
4265
|
action(handler?: unknown) {
|
|
4257
4266
|
return handler ?? builder;
|
|
4258
4267
|
},
|
|
4268
|
+
middleware(handler?: unknown) {
|
|
4269
|
+
return createMiddleware(handler);
|
|
4270
|
+
},
|
|
4259
4271
|
};
|
|
4260
4272
|
|
|
4261
4273
|
return builder;
|
|
@@ -4271,12 +4283,16 @@ export const initCRPC = {
|
|
|
4271
4283
|
context() {
|
|
4272
4284
|
return this;
|
|
4273
4285
|
},
|
|
4286
|
+
middleware(handler?: unknown) {
|
|
4287
|
+
return createMiddleware(handler);
|
|
4288
|
+
},
|
|
4274
4289
|
create() {
|
|
4275
4290
|
return {
|
|
4276
4291
|
query: createProcedureBuilder(),
|
|
4277
4292
|
mutation: createProcedureBuilder(),
|
|
4278
4293
|
action: createProcedureBuilder(),
|
|
4279
4294
|
httpAction: createProcedureBuilder(),
|
|
4295
|
+
middleware: createMiddleware,
|
|
4280
4296
|
router: (record = {}) => record,
|
|
4281
4297
|
};
|
|
4282
4298
|
},
|
|
@@ -4921,13 +4937,21 @@ function isCRPCHttpRouter(value) {
|
|
|
4921
4937
|
* Import a module using jiti and extract cRPC metadata from exports.
|
|
4922
4938
|
*/
|
|
4923
4939
|
async function parseModuleRuntime(filePath, jitiInstance) {
|
|
4940
|
+
const source = fs.readFileSync(filePath, "utf8");
|
|
4941
|
+
const rewrittenSource = source.replaceAll(/from\s+(['"])kitcn\/server\1/g, `from ${JSON.stringify(normalizeImportPath(getProjectServerParserShimPath()))}`);
|
|
4942
|
+
const importPath = rewrittenSource === source ? filePath : (() => {
|
|
4943
|
+
const tempFilePath = `${filePath}.kitcn-parse.ts`;
|
|
4944
|
+
fs.writeFileSync(tempFilePath, rewrittenSource, "utf8");
|
|
4945
|
+
return tempFilePath;
|
|
4946
|
+
})();
|
|
4924
4947
|
const result = {};
|
|
4925
4948
|
const httpRoutes = {};
|
|
4926
4949
|
const procedures = [];
|
|
4927
4950
|
const isHttp = filePath.endsWith("http.ts");
|
|
4928
|
-
const module = await jitiInstance.import(
|
|
4951
|
+
const module = await jitiInstance.import(importPath);
|
|
4929
4952
|
if (!module || typeof module !== "object") {
|
|
4930
4953
|
if (isHttp) logger.error(" http.ts: module is empty or not an object");
|
|
4954
|
+
if (importPath !== filePath) fs.rmSync(importPath, { force: true });
|
|
4931
4955
|
return {
|
|
4932
4956
|
meta: null,
|
|
4933
4957
|
httpRoutes: {},
|
|
@@ -4962,6 +4986,7 @@ async function parseModuleRuntime(filePath, jitiInstance) {
|
|
|
4962
4986
|
};
|
|
4963
4987
|
}
|
|
4964
4988
|
}
|
|
4989
|
+
if (importPath !== filePath) fs.rmSync(importPath, { force: true });
|
|
4965
4990
|
return {
|
|
4966
4991
|
meta: Object.keys(result).length > 0 ? result : null,
|
|
4967
4992
|
httpRoutes,
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as resolvePluginPreset, A as resolveConfiguredBackend, B as runConvexInitIfNeeded, C as isInitialized, D as readPackageVersions, E as parseInitCommandArgs, F as runAfterScaffoldScript, G as trackProcess, H as runInitCommandFlow, I as runAggregateBackfillFlow, J as collectPluginScaffoldTemplates, K as withWorkingDirectory, L as runAggregatePruneFlow, M as resolveInitProjectDir, N as resolveMigrationConfig, O as resolveBackfillConfig, P as resolveRunDeps, Q as resolveAddTemplateDefaults, R as runBackendFunction, S as isEntryPoint, T as parseBackendRunJson, Tt as highlighter, U as runMigrationCreate, V as runDevSchemaBackfillIfNeeded, W as runMigrationFlow, X as promptForPluginSelection, Y as filterScaffoldTemplatePathMap, Z as promptForScaffoldTemplateSelection, _ as formatInfoOutput, _t as inspectPluginDependencyInstall, a as cleanup, at as isSupportedPluginKey, b as hasRemoteConvexDeploymentEnv, bt as serializeEnvValue, c as createCommandEnv, ct as assertSchemaFileExists, d as extractBackfillCliOptions, dt as getSchemaFilePath, et as resolvePresetScaffoldTemplates, f as extractConcaveRunTargetArgs, ft as readPluginLockfile, g as formatDocsOutput, gt as applyPluginDependencyInstall, h as extractResetCliOptions, ht as applyPlanningDependencyInstall, i as buildInitializationPlan, it as getSupportedPluginKeys, j as resolveDocTopic, k as resolveCodegenTrimSegments, l as ensureConvexGitignoreEntry, lt as collectInstalledPluginKeys, m as extractMigrationDownOptions, mt as applyDependencyHintsInstall, n as applyPluginInstallPlanFiles, nt as resolveTemplatesByIdOrThrow, o as createBackendAdapter, ot as buildPluginInstallPlan, p as extractMigrationCliOptions, pt as resolveSchemaInstalledPlugins, q as createSpinner, r as assertNoRemovedDevPreRunFlag, rt as getPluginCatalogEntry, s as createBackendCommandEnv, st as resolvePluginScaffoldRoots, t as applyDependencyInstallPlan, tt as resolveTemplateSelectionSource, u as extractBackendRunTargetArgs, ut as getPluginLockfilePath, v as getAggregateBackfillDeploymentKey, vt as resolveProjectScaffoldContext, w as parseArgs, wt as logger, x as isConvexDevPreRunConflictFlag, xt as stripConvexCommandNoise, y as getDevAggregateBackfillStatePath, yt as resolveAuthEnvState, z as runConfiguredCodegen } from "./backend-core-
|
|
2
|
+
import { $ as resolvePluginPreset, A as resolveConfiguredBackend, B as runConvexInitIfNeeded, C as isInitialized, D as readPackageVersions, E as parseInitCommandArgs, F as runAfterScaffoldScript, G as trackProcess, H as runInitCommandFlow, I as runAggregateBackfillFlow, J as collectPluginScaffoldTemplates, K as withWorkingDirectory, L as runAggregatePruneFlow, M as resolveInitProjectDir, N as resolveMigrationConfig, O as resolveBackfillConfig, P as resolveRunDeps, Q as resolveAddTemplateDefaults, R as runBackendFunction, S as isEntryPoint, T as parseBackendRunJson, Tt as highlighter, U as runMigrationCreate, V as runDevSchemaBackfillIfNeeded, W as runMigrationFlow, X as promptForPluginSelection, Y as filterScaffoldTemplatePathMap, Z as promptForScaffoldTemplateSelection, _ as formatInfoOutput, _t as inspectPluginDependencyInstall, a as cleanup, at as isSupportedPluginKey, b as hasRemoteConvexDeploymentEnv, bt as serializeEnvValue, c as createCommandEnv, ct as assertSchemaFileExists, d as extractBackfillCliOptions, dt as getSchemaFilePath, et as resolvePresetScaffoldTemplates, f as extractConcaveRunTargetArgs, ft as readPluginLockfile, g as formatDocsOutput, gt as applyPluginDependencyInstall, h as extractResetCliOptions, ht as applyPlanningDependencyInstall, i as buildInitializationPlan, it as getSupportedPluginKeys, j as resolveDocTopic, k as resolveCodegenTrimSegments, l as ensureConvexGitignoreEntry, lt as collectInstalledPluginKeys, m as extractMigrationDownOptions, mt as applyDependencyHintsInstall, n as applyPluginInstallPlanFiles, nt as resolveTemplatesByIdOrThrow, o as createBackendAdapter, ot as buildPluginInstallPlan, p as extractMigrationCliOptions, pt as resolveSchemaInstalledPlugins, q as createSpinner, r as assertNoRemovedDevPreRunFlag, rt as getPluginCatalogEntry, s as createBackendCommandEnv, st as resolvePluginScaffoldRoots, t as applyDependencyInstallPlan, tt as resolveTemplateSelectionSource, u as extractBackendRunTargetArgs, ut as getPluginLockfilePath, v as getAggregateBackfillDeploymentKey, vt as resolveProjectScaffoldContext, w as parseArgs, wt as logger, x as isConvexDevPreRunConflictFlag, xt as stripConvexCommandNoise, y as getDevAggregateBackfillStatePath, yt as resolveAuthEnvState, z as runConfiguredCodegen } from "./backend-core-DA9iT-To.mjs";
|
|
3
3
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import path, { delimiter, dirname, join, relative, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
package/dist/watcher.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as resolveConfiguredBackend, Ct as getConvexConfig, P as resolveRunDeps, St as generateMeta, wt as logger } from "./backend-core-
|
|
2
|
+
import { A as resolveConfiguredBackend, Ct as getConvexConfig, P as resolveRunDeps, St as generateMeta, wt as logger } from "./backend-core-DA9iT-To.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|