kitcn 0.12.22 → 0.12.24
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/auth/client/index.js +1 -1
- package/dist/{auth-store-C0iMu34r.js → auth-store-CwGbvP_s.js} +8 -3
- package/dist/{backend-core-DBBEoGeA.mjs → backend-core-B7rj84wH.mjs} +32 -5
- package/dist/cli.mjs +1 -1
- package/dist/react/index.js +1 -1
- package/dist/watcher.mjs +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { C as readAuthSessionFallbackData, D as CRPCClientError, O as defaultIsUnauthorized, S as clearAuthSessionFallback, T as writeAuthSessionFallbackData, d as isSessionSyncGraceActive, g as useAuthValue, h as useAuthStore, n as AuthProvider, o as FetchAccessTokenContext, t as AUTH_SESSION_SYNC_GRACE_MS, u as decodeJwtExp, w as readAuthSessionFallbackToken } from "../../auth-store-
|
|
2
|
+
import { C as readAuthSessionFallbackData, D as CRPCClientError, O as defaultIsUnauthorized, S as clearAuthSessionFallback, T as writeAuthSessionFallbackData, d as isSessionSyncGraceActive, g as useAuthValue, h as useAuthStore, n as AuthProvider, o as FetchAccessTokenContext, t as AUTH_SESSION_SYNC_GRACE_MS, u as decodeJwtExp, w as readAuthSessionFallbackToken } from "../../auth-store-CwGbvP_s.js";
|
|
3
3
|
import { convexClient } from "@convex-dev/better-auth/client/plugins";
|
|
4
4
|
import { ConvexProviderWithAuth, useConvexAuth } from "convex/react";
|
|
5
5
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
@@ -142,7 +142,10 @@ const { AuthProvider, useAuthStore, useAuthState, useAuthValue } = createAtomSto
|
|
|
142
142
|
function useSafeConvexAuth() {
|
|
143
143
|
const authStore = useAuthStore();
|
|
144
144
|
const bridgeAuth = useConvexAuthBridge();
|
|
145
|
-
if (authStore.store) return
|
|
145
|
+
if (authStore.store) return {
|
|
146
|
+
isAuthenticated: useAuthValue("isAuthenticated"),
|
|
147
|
+
isLoading: useAuthValue("isLoading")
|
|
148
|
+
};
|
|
146
149
|
if (bridgeAuth !== null) return bridgeAuth;
|
|
147
150
|
return {
|
|
148
151
|
isAuthenticated: false,
|
|
@@ -188,9 +191,11 @@ const useAuth = () => {
|
|
|
188
191
|
isAuthenticated: false,
|
|
189
192
|
isLoading: true
|
|
190
193
|
};
|
|
191
|
-
const
|
|
194
|
+
const token = useAuthValue("token");
|
|
195
|
+
const isAuthenticated = useAuthValue("isAuthenticated");
|
|
196
|
+
const isLoading = useAuthValue("isLoading");
|
|
192
197
|
return {
|
|
193
|
-
hasSession: !!
|
|
198
|
+
hasSession: !!token,
|
|
194
199
|
isAuthenticated,
|
|
195
200
|
isLoading
|
|
196
201
|
};
|
|
@@ -9469,7 +9469,8 @@ const AUTH_CONVEX_HTTP_CALL_RE = /registerRoutes\(http,\s*getAuth,\s*\{/;
|
|
|
9469
9469
|
const AUTH_CONVEX_HTTP_ROUTER_RE = /const\s+http\s*=\s*httpRouter\(\);?/;
|
|
9470
9470
|
const AUTH_CONVEX_SCHEMA_CALL_RE = /defineSchema\(\s*\{/;
|
|
9471
9471
|
const AUTH_CONVEX_APP_IMPORT_RE = /import App from ['"][^'"]+['"];?/;
|
|
9472
|
-
const
|
|
9472
|
+
const AUTH_CONVEX_PROVIDER_IMPORT_RE = /import\s+\{\s*ConvexProvider,\s*ConvexReactClient\s*\}\s+from\s+['"]convex\/react['"];?/;
|
|
9473
|
+
const AUTH_PROVIDER_REACT_NODE_IMPORT_RE = /import\s+type\s+\{\s*ReactNode\s*\}\s+from\s+['"]react['"];?/;
|
|
9473
9474
|
const AUTH_CONVEX_NEXT_PROVIDER_RETURN_RE = /<ConvexProvider client=\{convex\}>[\s\S]*?<\/ConvexProvider>/;
|
|
9474
9475
|
const AUTH_CONVEX_REACT_PROVIDER_OPEN_RE = /<ConvexProvider client=\{convex\}>/;
|
|
9475
9476
|
const AUTH_CONVEX_REACT_PROVIDER_CLOSE_RE = /<\/ConvexProvider>/;
|
|
@@ -9783,15 +9784,20 @@ function buildAuthConvexSchemaPlanFile(params) {
|
|
|
9783
9784
|
skipReason: "schema.ts already registers auth tables."
|
|
9784
9785
|
});
|
|
9785
9786
|
}
|
|
9787
|
+
function patchAuthConvexProviderSource(source) {
|
|
9788
|
+
let nextSource = source;
|
|
9789
|
+
if (!nextSource.includes("from 'kitcn/auth/client'")) nextSource = nextSource.replace(AUTH_CONVEX_PROVIDER_IMPORT_RE, "import { ConvexAuthProvider } from 'kitcn/auth/client';\nimport { ConvexReactClient } from 'convex/react';");
|
|
9790
|
+
if (!nextSource.includes("import { authClient } from '@/lib/convex/auth-client';")) nextSource = nextSource.replace(AUTH_PROVIDER_REACT_NODE_IMPORT_RE, "import type { ReactNode } from 'react';\nimport { authClient } from '@/lib/convex/auth-client';");
|
|
9791
|
+
if (!nextSource.includes("<ConvexAuthProvider")) nextSource = nextSource.replace(AUTH_CONVEX_NEXT_PROVIDER_RETURN_RE, "<ConvexAuthProvider authClient={authClient} client={convex}>{children}</ConvexAuthProvider>");
|
|
9792
|
+
return nextSource;
|
|
9793
|
+
}
|
|
9786
9794
|
function buildAuthConvexNextProviderPlanFile(params) {
|
|
9787
9795
|
const projectContext = params.roots.projectContext;
|
|
9788
9796
|
if (!projectContext || projectContext.mode !== "next-app") throw new Error("Auth preset \"convex\" requires a supported Next or Vite app shell.");
|
|
9789
9797
|
const providerPath = resolve(process.cwd(), projectContext.componentsDir, "ConvexClientProvider.tsx");
|
|
9790
9798
|
if (!fs.existsSync(providerPath)) throw new Error("Auth preset \"convex\" for Next apps expects components/ConvexClientProvider.tsx.");
|
|
9791
9799
|
let source = fs.readFileSync(providerPath, "utf8");
|
|
9792
|
-
|
|
9793
|
-
if (!source.includes("import { authClient } from '@/lib/convex/auth-client';")) source = source.replace("import type { ReactNode } from 'react';", "import type { ReactNode } from 'react';\nimport { authClient } from '@/lib/convex/auth-client';");
|
|
9794
|
-
if (!source.includes("<ConvexAuthProvider")) source = source.replace(AUTH_CONVEX_NEXT_PROVIDER_RETURN_RE, "<ConvexAuthProvider authClient={authClient} client={convex}>{children}</ConvexAuthProvider>");
|
|
9800
|
+
source = patchAuthConvexProviderSource(source);
|
|
9795
9801
|
return createPlanFile({
|
|
9796
9802
|
kind: "scaffold",
|
|
9797
9803
|
filePath: providerPath,
|
|
@@ -9801,6 +9807,20 @@ function buildAuthConvexNextProviderPlanFile(params) {
|
|
|
9801
9807
|
skipReason: "Convex client provider already includes auth."
|
|
9802
9808
|
});
|
|
9803
9809
|
}
|
|
9810
|
+
function buildAuthConvexStartProviderPlanFile(params) {
|
|
9811
|
+
const projectContext = params.roots.projectContext;
|
|
9812
|
+
if (!projectContext || projectContext.framework !== "tanstack-start") throw new Error("Auth preset \"convex\" requires a supported TanStack Start app shell.");
|
|
9813
|
+
const providerPath = resolve(process.cwd(), projectContext.convexClientDir, "convex-provider.tsx");
|
|
9814
|
+
if (!fs.existsSync(providerPath)) throw new Error("Auth preset \"convex\" for TanStack Start expects src/lib/convex/convex-provider.tsx.");
|
|
9815
|
+
return createPlanFile({
|
|
9816
|
+
kind: "scaffold",
|
|
9817
|
+
filePath: providerPath,
|
|
9818
|
+
content: patchAuthConvexProviderSource(fs.readFileSync(providerPath, "utf8")),
|
|
9819
|
+
createReason: "Create auth-aware Start provider.",
|
|
9820
|
+
updateReason: "Update Start provider with auth.",
|
|
9821
|
+
skipReason: "Start provider already includes auth."
|
|
9822
|
+
});
|
|
9823
|
+
}
|
|
9804
9824
|
function buildAuthConvexReactEntryPlanFile(params) {
|
|
9805
9825
|
const projectContext = params.roots.projectContext;
|
|
9806
9826
|
if (!projectContext || projectContext.mode !== "react") throw new Error("Auth preset \"convex\" requires a supported Next or Vite app shell.");
|
|
@@ -9820,7 +9840,10 @@ function buildAuthConvexReactEntryPlanFile(params) {
|
|
|
9820
9840
|
});
|
|
9821
9841
|
}
|
|
9822
9842
|
function buildAuthConvexProviderPlanFile(params) {
|
|
9823
|
-
|
|
9843
|
+
const projectContext = params.roots.projectContext;
|
|
9844
|
+
if (projectContext?.mode === "next-app") return buildAuthConvexNextProviderPlanFile(params);
|
|
9845
|
+
if (projectContext?.framework === "tanstack-start") return buildAuthConvexStartProviderPlanFile(params);
|
|
9846
|
+
return buildAuthConvexReactEntryPlanFile(params);
|
|
9824
9847
|
}
|
|
9825
9848
|
const authRegistryItem = defineInternalRegistryItem({
|
|
9826
9849
|
item: {
|
|
@@ -9871,6 +9894,10 @@ const authRegistryItem = defineInternalRegistryItem({
|
|
|
9871
9894
|
...template,
|
|
9872
9895
|
content: AUTH_START_CLIENT_TEMPLATE
|
|
9873
9896
|
};
|
|
9897
|
+
if (template.id === "auth-client-convex") return {
|
|
9898
|
+
...template,
|
|
9899
|
+
content: AUTH_CONVEX_REACT_CLIENT_TEMPLATE
|
|
9900
|
+
};
|
|
9874
9901
|
return template;
|
|
9875
9902
|
});
|
|
9876
9903
|
return templates.filter((template) => template.id !== "auth-page" && template.id !== "auth-page-convex").map((template) => {
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as resolveAddTemplateDefaults, A as resolveConfiguredBackend, B as runConvexInitIfNeeded, C as isInitialized, D as readPackageVersions, E as parseInitCommandArgs, Et as highlighter, F as runAfterScaffoldScript, G as trackProcess, H as runInitCommandFlow, I as runAggregateBackfillFlow, J as createSpinner, K as withLocalCodegenEnv, L as runAggregatePruneFlow, M as resolveInitProjectDir, N as resolveMigrationConfig, O as resolveBackfillConfig, P as resolveRunDeps, Q as promptForScaffoldTemplateSelection, R as runBackendFunction, S as isEntryPoint, St as stripConvexCommandNoise, T as parseBackendRunJson, Tt as logger, U as runMigrationCreate, V as runDevSchemaBackfillIfNeeded, W as runMigrationFlow, X as filterScaffoldTemplatePathMap, Y as collectPluginScaffoldTemplates, Z as promptForPluginSelection, _ as formatInfoOutput, _t as applyPluginDependencyInstall, a as cleanup, at as getSupportedPluginKeys, b as hasRemoteConvexDeploymentEnv, bt as resolveAuthEnvState, c as createCommandEnv, ct as resolvePluginScaffoldRoots, d as extractBackfillCliOptions, dt as getPluginLockfilePath, et as resolvePluginPreset, f as extractConcaveRunTargetArgs, ft as getSchemaFilePath, g as formatDocsOutput, gt as applyPlanningDependencyInstall, h as extractResetCliOptions, ht as applyDependencyHintsInstall, i as buildInitializationPlan, it as getPluginCatalogEntry, j as resolveDocTopic, k as resolveCodegenTrimSegments, l as ensureConvexGitignoreEntry, lt as assertSchemaFileExists, m as extractMigrationDownOptions, mt as resolveSchemaInstalledPlugins, n as applyPluginInstallPlanFiles, nt as resolveTemplateSelectionSource, o as createBackendAdapter, ot as isSupportedPluginKey, p as extractMigrationCliOptions, pt as readPluginLockfile, q as withWorkingDirectory, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplatesByIdOrThrow, s as createBackendCommandEnv, st as buildPluginInstallPlan, t as applyDependencyInstallPlan, tt as resolvePresetScaffoldTemplates, u as extractBackendRunTargetArgs, ut as collectInstalledPluginKeys, v as getAggregateBackfillDeploymentKey, vt as inspectPluginDependencyInstall, w as parseArgs, x as isConvexDevPreRunConflictFlag, xt as serializeEnvValue, y as getDevAggregateBackfillStatePath, yt as resolveProjectScaffoldContext, z as runConfiguredCodegen } from "./backend-core-
|
|
2
|
+
import { $ as resolveAddTemplateDefaults, A as resolveConfiguredBackend, B as runConvexInitIfNeeded, C as isInitialized, D as readPackageVersions, E as parseInitCommandArgs, Et as highlighter, F as runAfterScaffoldScript, G as trackProcess, H as runInitCommandFlow, I as runAggregateBackfillFlow, J as createSpinner, K as withLocalCodegenEnv, L as runAggregatePruneFlow, M as resolveInitProjectDir, N as resolveMigrationConfig, O as resolveBackfillConfig, P as resolveRunDeps, Q as promptForScaffoldTemplateSelection, R as runBackendFunction, S as isEntryPoint, St as stripConvexCommandNoise, T as parseBackendRunJson, Tt as logger, U as runMigrationCreate, V as runDevSchemaBackfillIfNeeded, W as runMigrationFlow, X as filterScaffoldTemplatePathMap, Y as collectPluginScaffoldTemplates, Z as promptForPluginSelection, _ as formatInfoOutput, _t as applyPluginDependencyInstall, a as cleanup, at as getSupportedPluginKeys, b as hasRemoteConvexDeploymentEnv, bt as resolveAuthEnvState, c as createCommandEnv, ct as resolvePluginScaffoldRoots, d as extractBackfillCliOptions, dt as getPluginLockfilePath, et as resolvePluginPreset, f as extractConcaveRunTargetArgs, ft as getSchemaFilePath, g as formatDocsOutput, gt as applyPlanningDependencyInstall, h as extractResetCliOptions, ht as applyDependencyHintsInstall, i as buildInitializationPlan, it as getPluginCatalogEntry, j as resolveDocTopic, k as resolveCodegenTrimSegments, l as ensureConvexGitignoreEntry, lt as assertSchemaFileExists, m as extractMigrationDownOptions, mt as resolveSchemaInstalledPlugins, n as applyPluginInstallPlanFiles, nt as resolveTemplateSelectionSource, o as createBackendAdapter, ot as isSupportedPluginKey, p as extractMigrationCliOptions, pt as readPluginLockfile, q as withWorkingDirectory, r as assertNoRemovedDevPreRunFlag, rt as resolveTemplatesByIdOrThrow, s as createBackendCommandEnv, st as buildPluginInstallPlan, t as applyDependencyInstallPlan, tt as resolvePresetScaffoldTemplates, u as extractBackendRunTargetArgs, ut as collectInstalledPluginKeys, v as getAggregateBackfillDeploymentKey, vt as inspectPluginDependencyInstall, w as parseArgs, x as isConvexDevPreRunConflictFlag, xt as serializeEnvValue, y as getDevAggregateBackfillStatePath, yt as resolveProjectScaffoldContext, z as runConfiguredCodegen } from "./backend-core-B7rj84wH.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/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { D as CRPCClientError, E as writeAuthSessionFallbackToken, O as defaultIsUnauthorized, S as clearAuthSessionFallback, T as writeAuthSessionFallbackData, _ as useConvexAuthBridge, a as ConvexProviderWithAuth, b as useMaybeAuth, c as MaybeUnauthenticated, d as isSessionSyncGraceActive, f as useAuth, g as useAuthValue, h as useAuthStore, i as ConvexAuthBridge, k as isCRPCClientError, l as Unauthenticated, m as useAuthState, n as AuthProvider, o as FetchAccessTokenContext, p as useAuthGuard, r as Authenticated, s as MaybeAuthenticated, t as AUTH_SESSION_SYNC_GRACE_MS, u as decodeJwtExp, v as useFetchAccessToken, x as useSafeConvexAuth, y as useIsAuth } from "../auth-store-
|
|
2
|
+
import { D as CRPCClientError, E as writeAuthSessionFallbackToken, O as defaultIsUnauthorized, S as clearAuthSessionFallback, T as writeAuthSessionFallbackData, _ as useConvexAuthBridge, a as ConvexProviderWithAuth, b as useMaybeAuth, c as MaybeUnauthenticated, d as isSessionSyncGraceActive, f as useAuth, g as useAuthValue, h as useAuthStore, i as ConvexAuthBridge, k as isCRPCClientError, l as Unauthenticated, m as useAuthState, n as AuthProvider, o as FetchAccessTokenContext, p as useAuthGuard, r as Authenticated, s as MaybeAuthenticated, t as AUTH_SESSION_SYNC_GRACE_MS, u as decodeJwtExp, v as useFetchAccessToken, x as useSafeConvexAuth, y as useIsAuth } from "../auth-store-CwGbvP_s.js";
|
|
3
3
|
import { ConvexProvider, ConvexReactClient, ConvexReactClient as ConvexReactClient$1, useAction, useConvex, useMutation } from "convex/react";
|
|
4
4
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
package/dist/watcher.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as resolveConfiguredBackend, Ct as generateMeta, K as withLocalCodegenEnv, P as resolveRunDeps, Tt as logger, wt as getConvexConfig } from "./backend-core-
|
|
2
|
+
import { A as resolveConfiguredBackend, Ct as generateMeta, K as withLocalCodegenEnv, P as resolveRunDeps, Tt as logger, wt as getConvexConfig } from "./backend-core-B7rj84wH.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
|