workos 0.0.24 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +13 -0
- package/LICENSE +47 -0
- package/README.md +154 -1
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +163 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.config.d.ts +52 -0
- package/dist/cli.config.js +70 -0
- package/dist/cli.config.js.map +1 -0
- package/dist/package.json +87 -0
- package/dist/src/commands/install-skill.d.ts +20 -0
- package/dist/src/commands/install-skill.js +130 -0
- package/dist/src/commands/install-skill.js.map +1 -0
- package/dist/src/commands/install.d.ts +22 -0
- package/dist/src/commands/install.js +57 -0
- package/dist/src/commands/install.js.map +1 -0
- package/dist/src/commands/login.d.ts +1 -0
- package/dist/src/commands/login.js +141 -0
- package/dist/src/commands/login.js.map +1 -0
- package/dist/src/commands/logout.d.ts +1 -0
- package/dist/src/commands/logout.js +17 -0
- package/dist/src/commands/logout.js.map +1 -0
- package/dist/src/dashboard/components/AnimatedLogo.d.ts +8 -0
- package/dist/src/dashboard/components/AnimatedLogo.js +16 -0
- package/dist/src/dashboard/components/AnimatedLogo.js.map +1 -0
- package/dist/src/dashboard/components/CompletionView.d.ts +13 -0
- package/dist/src/dashboard/components/CompletionView.js +21 -0
- package/dist/src/dashboard/components/CompletionView.js.map +1 -0
- package/dist/src/dashboard/components/ConfirmPrompt.d.ts +9 -0
- package/dist/src/dashboard/components/ConfirmPrompt.js +25 -0
- package/dist/src/dashboard/components/ConfirmPrompt.js.map +1 -0
- package/dist/src/dashboard/components/CredentialsForm.d.ts +10 -0
- package/dist/src/dashboard/components/CredentialsForm.js +47 -0
- package/dist/src/dashboard/components/CredentialsForm.js.map +1 -0
- package/dist/src/dashboard/components/Dashboard.d.ts +3 -0
- package/dist/src/dashboard/components/Dashboard.js +100 -0
- package/dist/src/dashboard/components/Dashboard.js.map +1 -0
- package/dist/src/dashboard/components/DashboardLayout.d.ts +24 -0
- package/dist/src/dashboard/components/DashboardLayout.js +25 -0
- package/dist/src/dashboard/components/DashboardLayout.js.map +1 -0
- package/dist/src/dashboard/components/DiffPanel.d.ts +9 -0
- package/dist/src/dashboard/components/DiffPanel.js +136 -0
- package/dist/src/dashboard/components/DiffPanel.js.map +1 -0
- package/dist/src/dashboard/components/InlinePrompt.d.ts +8 -0
- package/dist/src/dashboard/components/InlinePrompt.js +19 -0
- package/dist/src/dashboard/components/InlinePrompt.js.map +1 -0
- package/dist/src/dashboard/components/OutputPanel.d.ts +10 -0
- package/dist/src/dashboard/components/OutputPanel.js +100 -0
- package/dist/src/dashboard/components/OutputPanel.js.map +1 -0
- package/dist/src/dashboard/components/Panel.d.ts +12 -0
- package/dist/src/dashboard/components/Panel.js +6 -0
- package/dist/src/dashboard/components/Panel.js.map +1 -0
- package/dist/src/dashboard/components/TextInput.d.ts +13 -0
- package/dist/src/dashboard/components/TextInput.js +57 -0
- package/dist/src/dashboard/components/TextInput.js.map +1 -0
- package/dist/src/dashboard/components/WelcomeArt.d.ts +2 -0
- package/dist/src/dashboard/components/WelcomeArt.js +9 -0
- package/dist/src/dashboard/components/WelcomeArt.js.map +1 -0
- package/dist/src/dashboard/hooks/useAnimation.d.ts +7 -0
- package/dist/src/dashboard/hooks/useAnimation.js +24 -0
- package/dist/src/dashboard/hooks/useAnimation.js.map +1 -0
- package/dist/src/dashboard/hooks/useKeyboard.d.ts +8 -0
- package/dist/src/dashboard/hooks/useKeyboard.js +18 -0
- package/dist/src/dashboard/hooks/useKeyboard.js.map +1 -0
- package/dist/src/dashboard/hooks/useTerminalSize.d.ts +8 -0
- package/dist/src/dashboard/hooks/useTerminalSize.js +23 -0
- package/dist/src/dashboard/hooks/useTerminalSize.js.map +1 -0
- package/dist/src/dashboard/index.d.ts +6 -0
- package/dist/src/dashboard/index.js +36 -0
- package/dist/src/dashboard/index.js.map +1 -0
- package/dist/src/dashboard/lib/diff-utils.d.ts +21 -0
- package/dist/src/dashboard/lib/diff-utils.js +271 -0
- package/dist/src/dashboard/lib/diff-utils.js.map +1 -0
- package/dist/src/dashboard/lib/logo-frames.d.ts +20 -0
- package/dist/src/dashboard/lib/logo-frames.js +109 -0
- package/dist/src/dashboard/lib/logo-frames.js.map +1 -0
- package/dist/src/dashboard/lib/welcome-art.d.ts +1 -0
- package/dist/src/dashboard/lib/welcome-art.js +5 -0
- package/dist/src/dashboard/lib/welcome-art.js.map +1 -0
- package/dist/src/dashboard/types.d.ts +5 -0
- package/dist/src/dashboard/types.js +2 -0
- package/dist/src/dashboard/types.js.map +1 -0
- package/dist/src/lib/__tests__/test-utils.d.ts +40 -0
- package/dist/src/lib/__tests__/test-utils.js +108 -0
- package/dist/src/lib/__tests__/test-utils.js.map +1 -0
- package/dist/src/lib/adapters/cli-adapter.d.ts +56 -0
- package/dist/src/lib/adapters/cli-adapter.js +318 -0
- package/dist/src/lib/adapters/cli-adapter.js.map +1 -0
- package/dist/src/lib/adapters/dashboard-adapter.d.ts +30 -0
- package/dist/src/lib/adapters/dashboard-adapter.js +97 -0
- package/dist/src/lib/adapters/dashboard-adapter.js.map +1 -0
- package/dist/src/lib/adapters/index.d.ts +3 -0
- package/dist/src/lib/adapters/index.js +3 -0
- package/dist/src/lib/adapters/index.js.map +1 -0
- package/dist/src/lib/adapters/types.d.ts +41 -0
- package/dist/src/lib/adapters/types.js +2 -0
- package/dist/src/lib/adapters/types.js.map +1 -0
- package/dist/src/lib/agent-interface.d.ts +75 -0
- package/dist/src/lib/agent-interface.js +563 -0
- package/dist/src/lib/agent-interface.js.map +1 -0
- package/dist/src/lib/agent-runner.d.ts +9 -0
- package/dist/src/lib/agent-runner.js +213 -0
- package/dist/src/lib/agent-runner.js.map +1 -0
- package/dist/src/lib/api.d.ts +25 -0
- package/dist/src/lib/api.js +120 -0
- package/dist/src/lib/api.js.map +1 -0
- package/dist/src/lib/config.d.ts +60 -0
- package/dist/src/lib/config.js +88 -0
- package/dist/src/lib/config.js.map +1 -0
- package/dist/src/lib/constants.d.ts +32 -0
- package/dist/src/lib/constants.js +53 -0
- package/dist/src/lib/constants.js.map +1 -0
- package/dist/src/lib/credentials.d.ts +19 -0
- package/dist/src/lib/credentials.js +55 -0
- package/dist/src/lib/credentials.js.map +1 -0
- package/dist/src/lib/env-writer.d.ts +14 -0
- package/dist/src/lib/env-writer.js +39 -0
- package/dist/src/lib/env-writer.js.map +1 -0
- package/dist/src/lib/events.d.ts +114 -0
- package/dist/src/lib/events.js +19 -0
- package/dist/src/lib/events.js.map +1 -0
- package/dist/src/lib/framework-config.d.ts +108 -0
- package/dist/src/lib/framework-config.js +11 -0
- package/dist/src/lib/framework-config.js.map +1 -0
- package/dist/src/lib/helper-functions.d.ts +1 -0
- package/dist/src/lib/helper-functions.js +2 -0
- package/dist/src/lib/helper-functions.js.map +1 -0
- package/dist/src/lib/port-detection.d.ts +7 -0
- package/dist/src/lib/port-detection.js +112 -0
- package/dist/src/lib/port-detection.js.map +1 -0
- package/dist/src/lib/progress-tracker.d.ts +22 -0
- package/dist/src/lib/progress-tracker.js +47 -0
- package/dist/src/lib/progress-tracker.js.map +1 -0
- package/dist/src/lib/run-with-core.d.ts +2 -0
- package/dist/src/lib/run-with-core.js +266 -0
- package/dist/src/lib/run-with-core.js.map +1 -0
- package/dist/src/lib/safe-tools.d.ts +2 -0
- package/dist/src/lib/safe-tools.js +212 -0
- package/dist/src/lib/safe-tools.js.map +1 -0
- package/dist/src/lib/settings.d.ts +59 -0
- package/dist/src/lib/settings.js +36 -0
- package/dist/src/lib/settings.js.map +1 -0
- package/dist/src/lib/token-refresh.d.ts +12 -0
- package/dist/src/lib/token-refresh.js +26 -0
- package/dist/src/lib/token-refresh.js.map +1 -0
- package/dist/src/lib/validation/build-validator.d.ts +9 -0
- package/dist/src/lib/validation/build-validator.js +118 -0
- package/dist/src/lib/validation/build-validator.js.map +1 -0
- package/dist/src/lib/validation/index.d.ts +3 -0
- package/dist/src/lib/validation/index.js +3 -0
- package/dist/src/lib/validation/index.js.map +1 -0
- package/dist/src/lib/validation/types.d.ts +41 -0
- package/dist/src/lib/validation/types.js +2 -0
- package/dist/src/lib/validation/types.js.map +1 -0
- package/dist/src/lib/validation/validator.d.ts +6 -0
- package/dist/src/lib/validation/validator.js +647 -0
- package/dist/src/lib/validation/validator.js.map +1 -0
- package/dist/src/lib/wizard-core.d.ts +200 -0
- package/dist/src/lib/wizard-core.js +392 -0
- package/dist/src/lib/wizard-core.js.map +1 -0
- package/dist/src/lib/wizard-core.types.d.ts +73 -0
- package/dist/src/lib/wizard-core.types.js +2 -0
- package/dist/src/lib/wizard-core.types.js.map +1 -0
- package/dist/src/lib/workos-management.d.ts +32 -0
- package/dist/src/lib/workos-management.js +142 -0
- package/dist/src/lib/workos-management.js.map +1 -0
- package/dist/src/nextjs/nextjs-wizard-agent.d.ts +6 -0
- package/dist/src/nextjs/nextjs-wizard-agent.js +97 -0
- package/dist/src/nextjs/nextjs-wizard-agent.js.map +1 -0
- package/dist/src/nextjs/utils.d.ts +8 -0
- package/dist/src/nextjs/utils.js +53 -0
- package/dist/src/nextjs/utils.js.map +1 -0
- package/dist/src/react/react-wizard-agent.d.ts +2 -0
- package/dist/src/react/react-wizard-agent.js +47 -0
- package/dist/src/react/react-wizard-agent.js.map +1 -0
- package/dist/src/react-router/react-router-wizard-agent.d.ts +6 -0
- package/dist/src/react-router/react-router-wizard-agent.js +103 -0
- package/dist/src/react-router/react-router-wizard-agent.js.map +1 -0
- package/dist/src/react-router/utils.d.ts +19 -0
- package/dist/src/react-router/utils.js +210 -0
- package/dist/src/react-router/utils.js.map +1 -0
- package/dist/src/run.d.ts +24 -0
- package/dist/src/run.js +48 -0
- package/dist/src/run.js.map +1 -0
- package/dist/src/steps/add-or-update-environment-variables.d.ts +10 -0
- package/dist/src/steps/add-or-update-environment-variables.js +155 -0
- package/dist/src/steps/add-or-update-environment-variables.js.map +1 -0
- package/dist/src/steps/index.d.ts +3 -0
- package/dist/src/steps/index.js +4 -0
- package/dist/src/steps/index.js.map +1 -0
- package/dist/src/steps/run-prettier.d.ts +5 -0
- package/dist/src/steps/run-prettier.js +54 -0
- package/dist/src/steps/run-prettier.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +8 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js +7 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/index.d.ts +6 -0
- package/dist/src/steps/upload-environment-variables/index.js +57 -0
- package/dist/src/steps/upload-environment-variables/index.js.map +1 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +14 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.js +104 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.js.map +1 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.d.ts +2 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.js +49 -0
- package/dist/src/tanstack-start/tanstack-start-wizard-agent.js.map +1 -0
- package/dist/src/telemetry.d.ts +2 -0
- package/dist/src/telemetry.js +29 -0
- package/dist/src/telemetry.js.map +1 -0
- package/dist/src/utils/analytics.d.ts +24 -0
- package/dist/src/utils/analytics.js +139 -0
- package/dist/src/utils/analytics.js.map +1 -0
- package/dist/src/utils/bash.d.ts +2 -0
- package/dist/src/utils/bash.js +17 -0
- package/dist/src/utils/bash.js.map +1 -0
- package/dist/src/utils/clack-utils.d.ts +93 -0
- package/dist/src/utils/clack-utils.js +397 -0
- package/dist/src/utils/clack-utils.js.map +1 -0
- package/dist/src/utils/clack.d.ts +5 -0
- package/dist/src/utils/clack.js +34 -0
- package/dist/src/utils/clack.js.map +1 -0
- package/dist/src/utils/cli-symbols.d.ts +32 -0
- package/dist/src/utils/cli-symbols.js +46 -0
- package/dist/src/utils/cli-symbols.js.map +1 -0
- package/dist/src/utils/debug.d.ts +7 -0
- package/dist/src/utils/debug.js +88 -0
- package/dist/src/utils/debug.js.map +1 -0
- package/dist/src/utils/env-parser.d.ts +5 -0
- package/dist/src/utils/env-parser.js +18 -0
- package/dist/src/utils/env-parser.js.map +1 -0
- package/dist/src/utils/environment.d.ts +4 -0
- package/dist/src/utils/environment.js +69 -0
- package/dist/src/utils/environment.js.map +1 -0
- package/dist/src/utils/errors.d.ts +3 -0
- package/dist/src/utils/errors.js +7 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/logging.d.ts +9 -0
- package/dist/src/utils/logging.js +36 -0
- package/dist/src/utils/logging.js.map +1 -0
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +21 -0
- package/dist/src/utils/package-json.js.map +1 -0
- package/dist/src/utils/package-manager.d.ts +21 -0
- package/dist/src/utils/package-manager.js +167 -0
- package/dist/src/utils/package-manager.js.map +1 -0
- package/dist/src/utils/redact.d.ts +5 -0
- package/dist/src/utils/redact.js +29 -0
- package/dist/src/utils/redact.js.map +1 -0
- package/dist/src/utils/semver.d.ts +10 -0
- package/dist/src/utils/semver.js +43 -0
- package/dist/src/utils/semver.js.map +1 -0
- package/dist/src/utils/string.d.ts +1 -0
- package/dist/src/utils/string.js +6 -0
- package/dist/src/utils/string.js.map +1 -0
- package/dist/src/utils/telemetry-client.d.ts +15 -0
- package/dist/src/utils/telemetry-client.js +57 -0
- package/dist/src/utils/telemetry-client.js.map +1 -0
- package/dist/src/utils/telemetry-types.d.ts +51 -0
- package/dist/src/utils/telemetry-types.js +6 -0
- package/dist/src/utils/telemetry-types.js.map +1 -0
- package/dist/src/utils/types.d.ts +80 -0
- package/dist/src/utils/types.js +2 -0
- package/dist/src/utils/types.js.map +1 -0
- package/dist/src/utils/urls.d.ts +7 -0
- package/dist/src/utils/urls.js +8 -0
- package/dist/src/utils/urls.js.map +1 -0
- package/dist/src/utils/vendor/is-unicorn-supported.d.ts +1 -0
- package/dist/src/utils/vendor/is-unicorn-supported.js +21 -0
- package/dist/src/utils/vendor/is-unicorn-supported.js.map +1 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.d.ts +2 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.js +47 -0
- package/dist/src/vanilla-js/vanilla-js-wizard-agent.js.map +1 -0
- package/package.json +76 -84
- package/skills/workos-authkit-base/SKILL.md +113 -0
- package/skills/workos-authkit-nextjs/SKILL.md +115 -0
- package/skills/workos-authkit-react/SKILL.md +91 -0
- package/skills/workos-authkit-react-router/SKILL.md +106 -0
- package/skills/workos-authkit-tanstack-start/SKILL.md +104 -0
- package/skills/workos-authkit-vanilla-js/SKILL.md +81 -0
- package/build/apps/index.js +0 -50
- package/build/apps/slack.js +0 -151
- package/build/cli.js +0 -42
- package/build/config.js +0 -34
- package/build/dev.js +0 -5
- package/build/enable-api-access.png +0 -0
- package/build/groups.js +0 -480
- package/build/index.js +0 -3
- package/build/info.js +0 -69
- package/build/login.js +0 -161
- package/build/main.js +0 -214
- package/build/users.js +0 -402
- package/build/util.js +0 -157
- package/coverage/clover.xml +0 -66
- package/coverage/coverage-final.json +0 -4
- package/coverage/lcov-report/base.css +0 -212
- package/coverage/lcov-report/cli.ts.html +0 -329
- package/coverage/lcov-report/config.ts.html +0 -152
- package/coverage/lcov-report/index.html +0 -119
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -1
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -158
- package/coverage/lcov-report/util.ts.html +0 -350
- package/coverage/lcov.info +0 -121
- package/package-lock.json +0 -7617
- package/tests/util.test.ts +0 -35
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type FrameworkConfig } from './framework-config.js';
|
|
2
|
+
import type { WizardOptions } from '../utils/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Universal agent-powered wizard runner.
|
|
5
|
+
* Handles the complete flow for any framework using WorkOS MCP integration.
|
|
6
|
+
*
|
|
7
|
+
* @returns A detailed summary of what was done and next steps
|
|
8
|
+
*/
|
|
9
|
+
export declare function runAgentWizard(config: FrameworkConfig, options: WizardOptions): Promise<string>;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { SPINNER_MESSAGE } from './framework-config.js';
|
|
2
|
+
import { validateInstallation } from './validation/index.js';
|
|
3
|
+
import { ensurePackageIsInstalled, getOrAskForWorkOSCredentials, getPackageDotJson, isUsingTypeScript, } from '../utils/clack-utils.js';
|
|
4
|
+
import { analytics } from '../utils/analytics.js';
|
|
5
|
+
import { WIZARD_INTERACTION_EVENT_NAME } from './constants.js';
|
|
6
|
+
import { initializeAgent, runAgent } from './agent-interface.js';
|
|
7
|
+
import { uploadEnvironmentVariablesStep } from '../steps/index.js';
|
|
8
|
+
import { autoConfigureWorkOSEnvironment } from './workos-management.js';
|
|
9
|
+
import { detectPort, getCallbackPath } from './port-detection.js';
|
|
10
|
+
import { writeEnvLocal } from './env-writer.js';
|
|
11
|
+
/**
|
|
12
|
+
* Universal agent-powered wizard runner.
|
|
13
|
+
* Handles the complete flow for any framework using WorkOS MCP integration.
|
|
14
|
+
*
|
|
15
|
+
* @returns A detailed summary of what was done and next steps
|
|
16
|
+
*/
|
|
17
|
+
export async function runAgentWizard(config, options) {
|
|
18
|
+
// Emit status for UI adapters to render
|
|
19
|
+
options.emitter?.emit('status', {
|
|
20
|
+
message: `Setting up WorkOS AuthKit for ${config.metadata.name}`,
|
|
21
|
+
});
|
|
22
|
+
const typeScriptDetected = isUsingTypeScript(options);
|
|
23
|
+
// Git check is now handled by the state machine - no need to check here
|
|
24
|
+
// Framework detection and version
|
|
25
|
+
const packageJson = await getPackageDotJson(options);
|
|
26
|
+
await ensurePackageIsInstalled(packageJson, config.detection.packageName, config.detection.packageDisplayName);
|
|
27
|
+
const frameworkVersion = config.detection.getVersion(packageJson);
|
|
28
|
+
// Set analytics tags for framework version
|
|
29
|
+
if (frameworkVersion && config.detection.getVersionBucket) {
|
|
30
|
+
const versionBucket = config.detection.getVersionBucket(frameworkVersion);
|
|
31
|
+
analytics.setTag(`${config.metadata.integration}-version`, versionBucket);
|
|
32
|
+
}
|
|
33
|
+
analytics.capture(WIZARD_INTERACTION_EVENT_NAME, {
|
|
34
|
+
action: 'started agent integration',
|
|
35
|
+
integration: config.metadata.integration,
|
|
36
|
+
});
|
|
37
|
+
// Get WorkOS credentials (API key optional for client-only SDKs)
|
|
38
|
+
const { apiKey, clientId } = await getOrAskForWorkOSCredentials(options, config.environment.requiresApiKey);
|
|
39
|
+
// Check if caller (state machine) already configured WorkOS environment
|
|
40
|
+
// If credentials were passed via options, the caller handled config+env writing
|
|
41
|
+
const callerHandledConfig = Boolean(options.apiKey || options.clientId);
|
|
42
|
+
// Auto-configure WorkOS environment (redirect URI, CORS, homepage)
|
|
43
|
+
// Skip if caller already handled this (prevents duplicate dashboard config output)
|
|
44
|
+
if (!callerHandledConfig && apiKey && config.environment.requiresApiKey) {
|
|
45
|
+
const port = detectPort(config.metadata.integration, options.installDir);
|
|
46
|
+
await autoConfigureWorkOSEnvironment(apiKey, config.metadata.integration, port, {
|
|
47
|
+
homepageUrl: options.homepageUrl,
|
|
48
|
+
redirectUri: options.redirectUri,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Gather framework-specific context (e.g., Next.js router, React Native platform)
|
|
52
|
+
const frameworkContext = config.metadata.gatherContext ? await config.metadata.gatherContext(options) : {};
|
|
53
|
+
// Write environment variables to .env.local BEFORE agent runs
|
|
54
|
+
// Skip if caller already handled this (prevents double-writing)
|
|
55
|
+
if (!callerHandledConfig) {
|
|
56
|
+
const port = detectPort(config.metadata.integration, options.installDir);
|
|
57
|
+
const callbackPath = getCallbackPath(config.metadata.integration);
|
|
58
|
+
const redirectUri = options.redirectUri || `http://localhost:${port}${callbackPath}`;
|
|
59
|
+
// Next.js requires NEXT_PUBLIC_ prefix for client-side env vars
|
|
60
|
+
const redirectUriKey = config.metadata.integration === 'nextjs' ? 'NEXT_PUBLIC_WORKOS_REDIRECT_URI' : 'WORKOS_REDIRECT_URI';
|
|
61
|
+
writeEnvLocal(options.installDir, {
|
|
62
|
+
...(apiKey ? { WORKOS_API_KEY: apiKey } : {}),
|
|
63
|
+
WORKOS_CLIENT_ID: clientId,
|
|
64
|
+
[redirectUriKey]: redirectUri,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Set analytics tags from framework context
|
|
68
|
+
const contextTags = config.analytics.getTags(frameworkContext);
|
|
69
|
+
Object.entries(contextTags).forEach(([key, value]) => {
|
|
70
|
+
analytics.setTag(key, value);
|
|
71
|
+
});
|
|
72
|
+
// Build integration prompt (credentials are already in .env.local)
|
|
73
|
+
const integrationPrompt = buildIntegrationPrompt(config, {
|
|
74
|
+
frameworkVersion: frameworkVersion || 'latest',
|
|
75
|
+
typescript: typeScriptDetected,
|
|
76
|
+
}, frameworkContext);
|
|
77
|
+
// Initialize and run agent
|
|
78
|
+
// Spinner is now handled by adapters listening to agent:start/agent:progress events
|
|
79
|
+
const agent = await initializeAgent({
|
|
80
|
+
workingDirectory: options.installDir,
|
|
81
|
+
workOSApiKey: apiKey,
|
|
82
|
+
workOSApiHost: 'https://api.workos.com',
|
|
83
|
+
}, options);
|
|
84
|
+
// Run agent - errors will throw naturally with skill-based approach
|
|
85
|
+
const agentResult = await runAgent(agent, integrationPrompt, options, {
|
|
86
|
+
spinnerMessage: SPINNER_MESSAGE,
|
|
87
|
+
successMessage: config.ui.successMessage,
|
|
88
|
+
errorMessage: 'Integration failed',
|
|
89
|
+
}, options.emitter);
|
|
90
|
+
// If agent returned an error, throw so state machine can handle it
|
|
91
|
+
if (agentResult.error) {
|
|
92
|
+
await analytics.shutdown('error');
|
|
93
|
+
const message = agentResult.errorMessage || agentResult.error;
|
|
94
|
+
throw new Error(`Agent SDK error: ${message}`);
|
|
95
|
+
}
|
|
96
|
+
// Run post-installation validation
|
|
97
|
+
if (!options.noValidate) {
|
|
98
|
+
options.emitter?.emit('validation:start', { framework: config.metadata.integration });
|
|
99
|
+
const validationResult = await validateInstallation(config.metadata.integration, options.installDir, {
|
|
100
|
+
runBuild: true,
|
|
101
|
+
});
|
|
102
|
+
if (validationResult.issues.length > 0) {
|
|
103
|
+
options.emitter?.emit('validation:issues', { issues: validationResult.issues });
|
|
104
|
+
}
|
|
105
|
+
options.emitter?.emit('validation:complete', {
|
|
106
|
+
passed: validationResult.passed,
|
|
107
|
+
issueCount: validationResult.issues.length,
|
|
108
|
+
durationMs: validationResult.durationMs,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
// Build environment variables from WorkOS credentials
|
|
112
|
+
const envVars = config.environment.getEnvVars(apiKey, clientId);
|
|
113
|
+
// Upload environment variables to hosting providers (if configured)
|
|
114
|
+
let uploadedEnvVars = [];
|
|
115
|
+
if (config.environment.uploadToHosting) {
|
|
116
|
+
uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {
|
|
117
|
+
integration: config.metadata.integration,
|
|
118
|
+
options,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
// Skip MCP server setup for now (WorkOS doesn't need it initially)
|
|
122
|
+
// await addMCPServerToClientsStep({ ... });
|
|
123
|
+
// Build outro message
|
|
124
|
+
const continueUrl = undefined; // No signup flow for WorkOS wizard
|
|
125
|
+
const changes = [
|
|
126
|
+
...config.ui.getOutroChanges(frameworkContext),
|
|
127
|
+
Object.keys(envVars).length > 0 ? `Added environment variables to .env file` : '',
|
|
128
|
+
uploadedEnvVars.length > 0 ? `Uploaded environment variables to your hosting provider` : '',
|
|
129
|
+
].filter(Boolean);
|
|
130
|
+
const nextSteps = [
|
|
131
|
+
...config.ui.getOutroNextSteps(frameworkContext),
|
|
132
|
+
uploadedEnvVars.length === 0 && config.environment.uploadToHosting
|
|
133
|
+
? `Upload your WorkOS credentials to your hosting provider`
|
|
134
|
+
: '',
|
|
135
|
+
].filter(Boolean);
|
|
136
|
+
// Build detailed summary to return to caller (state machine)
|
|
137
|
+
const summary = buildCompletionSummary(config, changes, nextSteps, continueUrl);
|
|
138
|
+
await analytics.shutdown('success');
|
|
139
|
+
return summary;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Build the integration prompt for the agent.
|
|
143
|
+
* Uses skill-based approach where agent invokes framework-specific skill.
|
|
144
|
+
* Note: Credentials are pre-written to .env.local, so not included in prompt.
|
|
145
|
+
*/
|
|
146
|
+
function buildIntegrationPrompt(config, context, frameworkContext) {
|
|
147
|
+
const additionalLines = config.prompts.getAdditionalContextLines
|
|
148
|
+
? config.prompts.getAdditionalContextLines(frameworkContext)
|
|
149
|
+
: [];
|
|
150
|
+
const additionalContext = additionalLines.length > 0 ? '\n' + additionalLines.map((line) => `- ${line}`).join('\n') : '';
|
|
151
|
+
const skillName = config.metadata.skillName;
|
|
152
|
+
if (!skillName) {
|
|
153
|
+
throw new Error(`Framework ${config.metadata.name} missing skillName in config`);
|
|
154
|
+
}
|
|
155
|
+
// Next.js uses NEXT_PUBLIC_ prefix for redirect URI
|
|
156
|
+
const redirectUriEnvVar = config.metadata.integration === 'nextjs' ? 'NEXT_PUBLIC_WORKOS_REDIRECT_URI' : 'WORKOS_REDIRECT_URI';
|
|
157
|
+
return `You are integrating WorkOS AuthKit into this ${config.metadata.name} application.
|
|
158
|
+
|
|
159
|
+
## Project Context
|
|
160
|
+
|
|
161
|
+
- Framework: ${config.metadata.name} ${context.frameworkVersion}
|
|
162
|
+
- TypeScript: ${context.typescript ? 'Yes' : 'No'}${additionalContext}
|
|
163
|
+
|
|
164
|
+
## Environment
|
|
165
|
+
|
|
166
|
+
The following environment variables have been configured in .env.local:
|
|
167
|
+
- WORKOS_API_KEY
|
|
168
|
+
- WORKOS_CLIENT_ID
|
|
169
|
+
- ${redirectUriEnvVar}
|
|
170
|
+
- WORKOS_COOKIE_PASSWORD
|
|
171
|
+
|
|
172
|
+
## Your Task
|
|
173
|
+
|
|
174
|
+
Use the \`${skillName}\` skill to integrate WorkOS AuthKit into this application.
|
|
175
|
+
|
|
176
|
+
The skill contains step-by-step instructions including:
|
|
177
|
+
1. Fetching the SDK documentation
|
|
178
|
+
2. Installing the SDK
|
|
179
|
+
3. Creating the callback route
|
|
180
|
+
4. Setting up middleware/auth handling
|
|
181
|
+
5. Adding authentication UI to the home page
|
|
182
|
+
|
|
183
|
+
Report your progress using [STATUS] prefixes.
|
|
184
|
+
|
|
185
|
+
Begin by invoking the ${skillName} skill.`;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Build a completion summary for the event payload.
|
|
189
|
+
* This is a plain-text summary without styling (adapters handle presentation).
|
|
190
|
+
*/
|
|
191
|
+
function buildCompletionSummary(config, changes, nextSteps, continueUrl) {
|
|
192
|
+
const lines = [];
|
|
193
|
+
lines.push('Successfully installed WorkOS AuthKit!');
|
|
194
|
+
lines.push('');
|
|
195
|
+
if (changes.length > 0) {
|
|
196
|
+
lines.push('What the agent did:');
|
|
197
|
+
changes.forEach((change) => lines.push(`• ${change}`));
|
|
198
|
+
lines.push('');
|
|
199
|
+
}
|
|
200
|
+
if (nextSteps.length > 0) {
|
|
201
|
+
lines.push('Next steps:');
|
|
202
|
+
nextSteps.forEach((step) => lines.push(`• ${step}`));
|
|
203
|
+
lines.push('');
|
|
204
|
+
}
|
|
205
|
+
lines.push(`Learn more: ${config.metadata.docsUrl}`);
|
|
206
|
+
if (continueUrl) {
|
|
207
|
+
lines.push(`Continue onboarding: ${continueUrl}`);
|
|
208
|
+
}
|
|
209
|
+
lines.push('');
|
|
210
|
+
lines.push('Note: This wizard uses an LLM agent to analyze and modify your project. Please review the changes made.');
|
|
211
|
+
return lines.join('\n');
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=agent-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/lib/agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAwB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EACL,wBAAwB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CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACrD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAClC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC;QACvD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1B,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC;QACrD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,eAAe,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAErD,IAAI,WAAW,EAAE,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC,wBAAwB,WAAW,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,yGAAyG,CAAC,CAAC;IAEtH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import { SPINNER_MESSAGE, type FrameworkConfig } from './framework-config.js';\nimport { validateInstallation } from './validation/index.js';\nimport type { WizardOptions } from '../utils/types.js';\nimport {\n ensurePackageIsInstalled,\n getOrAskForWorkOSCredentials,\n getPackageDotJson,\n isUsingTypeScript,\n} from '../utils/clack-utils.js';\nimport { analytics } from '../utils/analytics.js';\nimport { WIZARD_INTERACTION_EVENT_NAME } from './constants.js';\nimport { initializeAgent, runAgent } from './agent-interface.js';\nimport { uploadEnvironmentVariablesStep } from '../steps/index.js';\nimport { autoConfigureWorkOSEnvironment } from './workos-management.js';\nimport { detectPort, getCallbackPath } from './port-detection.js';\nimport { writeEnvLocal } from './env-writer.js';\n\n/**\n * Universal agent-powered wizard runner.\n * Handles the complete flow for any framework using WorkOS MCP integration.\n *\n * @returns A detailed summary of what was done and next steps\n */\nexport async function runAgentWizard(config: FrameworkConfig, options: WizardOptions): Promise<string> {\n // Emit status for UI adapters to render\n options.emitter?.emit('status', {\n message: `Setting up WorkOS AuthKit for ${config.metadata.name}`,\n });\n\n const typeScriptDetected = isUsingTypeScript(options);\n\n // Git check is now handled by the state machine - no need to check here\n\n // Framework detection and version\n const packageJson = await getPackageDotJson(options);\n await ensurePackageIsInstalled(packageJson, config.detection.packageName, config.detection.packageDisplayName);\n\n const frameworkVersion = config.detection.getVersion(packageJson);\n\n // Set analytics tags for framework version\n if (frameworkVersion && config.detection.getVersionBucket) {\n const versionBucket = config.detection.getVersionBucket(frameworkVersion);\n analytics.setTag(`${config.metadata.integration}-version`, versionBucket);\n }\n\n analytics.capture(WIZARD_INTERACTION_EVENT_NAME, {\n action: 'started agent integration',\n integration: config.metadata.integration,\n });\n\n // Get WorkOS credentials (API key optional for client-only SDKs)\n const { apiKey, clientId } = await getOrAskForWorkOSCredentials(options, config.environment.requiresApiKey);\n\n // Check if caller (state machine) already configured WorkOS environment\n // If credentials were passed via options, the caller handled config+env writing\n const callerHandledConfig = Boolean(options.apiKey || options.clientId);\n\n // Auto-configure WorkOS environment (redirect URI, CORS, homepage)\n // Skip if caller already handled this (prevents duplicate dashboard config output)\n if (!callerHandledConfig && apiKey && config.environment.requiresApiKey) {\n const port = detectPort(config.metadata.integration, options.installDir);\n await autoConfigureWorkOSEnvironment(apiKey, config.metadata.integration, port, {\n homepageUrl: options.homepageUrl,\n redirectUri: options.redirectUri,\n });\n }\n\n // Gather framework-specific context (e.g., Next.js router, React Native platform)\n const frameworkContext = config.metadata.gatherContext ? await config.metadata.gatherContext(options) : {};\n\n // Write environment variables to .env.local BEFORE agent runs\n // Skip if caller already handled this (prevents double-writing)\n if (!callerHandledConfig) {\n const port = detectPort(config.metadata.integration, options.installDir);\n const callbackPath = getCallbackPath(config.metadata.integration);\n const redirectUri = options.redirectUri || `http://localhost:${port}${callbackPath}`;\n\n // Next.js requires NEXT_PUBLIC_ prefix for client-side env vars\n const redirectUriKey =\n config.metadata.integration === 'nextjs' ? 'NEXT_PUBLIC_WORKOS_REDIRECT_URI' : 'WORKOS_REDIRECT_URI';\n\n writeEnvLocal(options.installDir, {\n ...(apiKey ? { WORKOS_API_KEY: apiKey } : {}),\n WORKOS_CLIENT_ID: clientId,\n [redirectUriKey]: redirectUri,\n });\n }\n\n // Set analytics tags from framework context\n const contextTags = config.analytics.getTags(frameworkContext);\n Object.entries(contextTags).forEach(([key, value]) => {\n analytics.setTag(key, value);\n });\n\n // Build integration prompt (credentials are already in .env.local)\n const integrationPrompt = buildIntegrationPrompt(\n config,\n {\n frameworkVersion: frameworkVersion || 'latest',\n typescript: typeScriptDetected,\n },\n frameworkContext,\n );\n\n // Initialize and run agent\n // Spinner is now handled by adapters listening to agent:start/agent:progress events\n const agent = await initializeAgent(\n {\n workingDirectory: options.installDir,\n workOSApiKey: apiKey,\n workOSApiHost: 'https://api.workos.com',\n },\n options,\n );\n\n // Run agent - errors will throw naturally with skill-based approach\n const agentResult = await runAgent(\n agent,\n integrationPrompt,\n options,\n {\n spinnerMessage: SPINNER_MESSAGE,\n successMessage: config.ui.successMessage,\n errorMessage: 'Integration failed',\n },\n options.emitter,\n );\n\n // If agent returned an error, throw so state machine can handle it\n if (agentResult.error) {\n await analytics.shutdown('error');\n const message = agentResult.errorMessage || agentResult.error;\n throw new Error(`Agent SDK error: ${message}`);\n }\n\n // Run post-installation validation\n if (!options.noValidate) {\n options.emitter?.emit('validation:start', { framework: config.metadata.integration });\n\n const validationResult = await validateInstallation(config.metadata.integration, options.installDir, {\n runBuild: true,\n });\n\n if (validationResult.issues.length > 0) {\n options.emitter?.emit('validation:issues', { issues: validationResult.issues });\n }\n\n options.emitter?.emit('validation:complete', {\n passed: validationResult.passed,\n issueCount: validationResult.issues.length,\n durationMs: validationResult.durationMs,\n });\n }\n\n // Build environment variables from WorkOS credentials\n const envVars = config.environment.getEnvVars(apiKey, clientId);\n\n // Upload environment variables to hosting providers (if configured)\n let uploadedEnvVars: string[] = [];\n if (config.environment.uploadToHosting) {\n uploadedEnvVars = await uploadEnvironmentVariablesStep(envVars, {\n integration: config.metadata.integration,\n options,\n });\n }\n\n // Skip MCP server setup for now (WorkOS doesn't need it initially)\n // await addMCPServerToClientsStep({ ... });\n\n // Build outro message\n const continueUrl = undefined; // No signup flow for WorkOS wizard\n\n const changes = [\n ...config.ui.getOutroChanges(frameworkContext),\n Object.keys(envVars).length > 0 ? `Added environment variables to .env file` : '',\n uploadedEnvVars.length > 0 ? `Uploaded environment variables to your hosting provider` : '',\n ].filter(Boolean);\n\n const nextSteps = [\n ...config.ui.getOutroNextSteps(frameworkContext),\n uploadedEnvVars.length === 0 && config.environment.uploadToHosting\n ? `Upload your WorkOS credentials to your hosting provider`\n : '',\n ].filter(Boolean);\n\n // Build detailed summary to return to caller (state machine)\n const summary = buildCompletionSummary(config, changes, nextSteps, continueUrl);\n\n await analytics.shutdown('success');\n\n return summary;\n}\n\n/**\n * Build the integration prompt for the agent.\n * Uses skill-based approach where agent invokes framework-specific skill.\n * Note: Credentials are pre-written to .env.local, so not included in prompt.\n */\nfunction buildIntegrationPrompt(\n config: FrameworkConfig,\n context: {\n frameworkVersion: string;\n typescript: boolean;\n },\n frameworkContext: Record<string, any>,\n): string {\n const additionalLines = config.prompts.getAdditionalContextLines\n ? config.prompts.getAdditionalContextLines(frameworkContext)\n : [];\n\n const additionalContext =\n additionalLines.length > 0 ? '\\n' + additionalLines.map((line) => `- ${line}`).join('\\n') : '';\n\n const skillName = config.metadata.skillName;\n if (!skillName) {\n throw new Error(`Framework ${config.metadata.name} missing skillName in config`);\n }\n\n // Next.js uses NEXT_PUBLIC_ prefix for redirect URI\n const redirectUriEnvVar =\n config.metadata.integration === 'nextjs' ? 'NEXT_PUBLIC_WORKOS_REDIRECT_URI' : 'WORKOS_REDIRECT_URI';\n\n return `You are integrating WorkOS AuthKit into this ${config.metadata.name} application.\n\n## Project Context\n\n- Framework: ${config.metadata.name} ${context.frameworkVersion}\n- TypeScript: ${context.typescript ? 'Yes' : 'No'}${additionalContext}\n\n## Environment\n\nThe following environment variables have been configured in .env.local:\n- WORKOS_API_KEY\n- WORKOS_CLIENT_ID\n- ${redirectUriEnvVar}\n- WORKOS_COOKIE_PASSWORD\n\n## Your Task\n\nUse the \\`${skillName}\\` skill to integrate WorkOS AuthKit into this application.\n\nThe skill contains step-by-step instructions including:\n1. Fetching the SDK documentation\n2. Installing the SDK\n3. Creating the callback route\n4. Setting up middleware/auth handling\n5. Adding authentication UI to the home page\n\nReport your progress using [STATUS] prefixes.\n\nBegin by invoking the ${skillName} skill.`;\n}\n\n/**\n * Build a completion summary for the event payload.\n * This is a plain-text summary without styling (adapters handle presentation).\n */\nfunction buildCompletionSummary(\n config: FrameworkConfig,\n changes: string[],\n nextSteps: string[],\n continueUrl: string | undefined,\n): string {\n const lines: string[] = [];\n\n lines.push('Successfully installed WorkOS AuthKit!');\n lines.push('');\n\n if (changes.length > 0) {\n lines.push('What the agent did:');\n changes.forEach((change) => lines.push(`• ${change}`));\n lines.push('');\n }\n\n if (nextSteps.length > 0) {\n lines.push('Next steps:');\n nextSteps.forEach((step) => lines.push(`• ${step}`));\n lines.push('');\n }\n\n lines.push(`Learn more: ${config.metadata.docsUrl}`);\n\n if (continueUrl) {\n lines.push(`Continue onboarding: ${continueUrl}`);\n }\n\n lines.push('');\n lines.push('Note: This wizard uses an LLM agent to analyze and modify your project. Please review the changes made.');\n\n return lines.join('\\n');\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ApiUserSchema: z.ZodObject<{
|
|
3
|
+
distinct_id: z.ZodString;
|
|
4
|
+
organizations: z.ZodArray<z.ZodObject<{
|
|
5
|
+
id: z.ZodUUID;
|
|
6
|
+
}, z.core.$strip>>;
|
|
7
|
+
team: z.ZodObject<{
|
|
8
|
+
id: z.ZodNumber;
|
|
9
|
+
organization: z.ZodUUID;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
organization: z.ZodObject<{
|
|
12
|
+
id: z.ZodUUID;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const ApiProjectSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodNumber;
|
|
17
|
+
uuid: z.ZodUUID;
|
|
18
|
+
organization: z.ZodUUID;
|
|
19
|
+
api_token: z.ZodString;
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export type ApiUser = z.infer<typeof ApiUserSchema>;
|
|
23
|
+
export type ApiProject = z.infer<typeof ApiProjectSchema>;
|
|
24
|
+
export declare function fetchUserData(accessToken: string, baseUrl: string): Promise<ApiUser>;
|
|
25
|
+
export declare function fetchProjectData(accessToken: string, projectId: number, baseUrl: string): Promise<ApiProject>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { analytics } from '../utils/analytics.js';
|
|
3
|
+
export const ApiUserSchema = z.object({
|
|
4
|
+
distinct_id: z.string(),
|
|
5
|
+
organizations: z.array(z.object({
|
|
6
|
+
id: z.uuid(),
|
|
7
|
+
})),
|
|
8
|
+
team: z.object({
|
|
9
|
+
id: z.number(),
|
|
10
|
+
organization: z.uuid(),
|
|
11
|
+
}),
|
|
12
|
+
organization: z.object({
|
|
13
|
+
id: z.uuid(),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
export const ApiProjectSchema = z.object({
|
|
17
|
+
id: z.number(),
|
|
18
|
+
uuid: z.uuid(),
|
|
19
|
+
organization: z.uuid(),
|
|
20
|
+
api_token: z.string(),
|
|
21
|
+
name: z.string(),
|
|
22
|
+
});
|
|
23
|
+
class ApiError extends Error {
|
|
24
|
+
statusCode;
|
|
25
|
+
endpoint;
|
|
26
|
+
constructor(message, statusCode, endpoint) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.statusCode = statusCode;
|
|
29
|
+
this.endpoint = endpoint;
|
|
30
|
+
this.name = 'ApiError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export async function fetchUserData(accessToken, baseUrl) {
|
|
34
|
+
const endpoint = '/api/users/@me/';
|
|
35
|
+
try {
|
|
36
|
+
const response = await fetch(`${baseUrl}${endpoint}`, {
|
|
37
|
+
headers: {
|
|
38
|
+
Authorization: `Bearer ${accessToken}`,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
if (!response.ok) {
|
|
42
|
+
throw await createFetchError(response, endpoint);
|
|
43
|
+
}
|
|
44
|
+
const data = await response.json();
|
|
45
|
+
return ApiUserSchema.parse(data);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const apiError = handleApiError(error, 'fetch user data', endpoint);
|
|
49
|
+
analytics.captureException(apiError, {
|
|
50
|
+
endpoint,
|
|
51
|
+
baseUrl,
|
|
52
|
+
});
|
|
53
|
+
throw apiError;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export async function fetchProjectData(accessToken, projectId, baseUrl) {
|
|
57
|
+
const endpoint = `/api/projects/${projectId}/`;
|
|
58
|
+
try {
|
|
59
|
+
const response = await fetch(`${baseUrl}${endpoint}`, {
|
|
60
|
+
headers: {
|
|
61
|
+
Authorization: `Bearer ${accessToken}`,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
throw await createFetchError(response, endpoint);
|
|
66
|
+
}
|
|
67
|
+
const data = await response.json();
|
|
68
|
+
return ApiProjectSchema.parse(data);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
const apiError = handleApiError(error, 'fetch project data', endpoint);
|
|
72
|
+
analytics.captureException(apiError, {
|
|
73
|
+
endpoint,
|
|
74
|
+
baseUrl,
|
|
75
|
+
projectId,
|
|
76
|
+
});
|
|
77
|
+
throw apiError;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function createFetchError(response, endpoint) {
|
|
81
|
+
let detail;
|
|
82
|
+
try {
|
|
83
|
+
const data = await response.json();
|
|
84
|
+
if (typeof data === 'object' && data !== null && 'detail' in data) {
|
|
85
|
+
detail = String(data.detail);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// Response wasn't JSON
|
|
90
|
+
}
|
|
91
|
+
const error = new Error(`HTTP ${response.status}`);
|
|
92
|
+
error.status = response.status;
|
|
93
|
+
error.endpoint = endpoint;
|
|
94
|
+
error.detail = detail;
|
|
95
|
+
return error;
|
|
96
|
+
}
|
|
97
|
+
function isFetchError(error) {
|
|
98
|
+
return error instanceof Error && 'status' in error && typeof error.status === 'number';
|
|
99
|
+
}
|
|
100
|
+
function handleApiError(error, operation, endpoint) {
|
|
101
|
+
if (isFetchError(error)) {
|
|
102
|
+
const { status, detail } = error;
|
|
103
|
+
if (status === 401) {
|
|
104
|
+
return new ApiError(`Authentication failed while trying to ${operation}`, status, endpoint);
|
|
105
|
+
}
|
|
106
|
+
if (status === 403) {
|
|
107
|
+
return new ApiError(`Access denied while trying to ${operation}`, status, endpoint);
|
|
108
|
+
}
|
|
109
|
+
if (status === 404) {
|
|
110
|
+
return new ApiError(`Resource not found while trying to ${operation}`, status, endpoint);
|
|
111
|
+
}
|
|
112
|
+
const message = detail || `Failed to ${operation}`;
|
|
113
|
+
return new ApiError(message, status, endpoint);
|
|
114
|
+
}
|
|
115
|
+
if (error instanceof z.ZodError) {
|
|
116
|
+
return new ApiError(`Invalid response format while trying to ${operation}`);
|
|
117
|
+
}
|
|
118
|
+
return new ApiError(`Unexpected error while trying to ${operation}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/lib/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,aAAa,EAAE,CAAC,CAAC,KAAK,CACpB,CAAC,CAAC,MAAM,CAAC;QACP,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;KACb,CAAC,CACH;IACD,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QACb,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;QACd,YAAY,EAAE,CAAC,CAAC,IAAI,EAAE;KACvB,CAAC;IACF,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;QACrB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;KACb,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;IACd,YAAY,EAAE,CAAC,CAAC,IAAI,EAAE;IACtB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAKH,MAAM,QAAS,SAAQ,KAAK;IAGR;IACA;IAHlB,YACE,OAAe,EACC,UAAmB,EACnB,QAAiB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,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,MAAM,KAAK,QAAQ,CAAC;AACzG,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,SAAiB,EAAE,QAAgB;IACzE,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;QAEjC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,OAAO,IAAI,QAAQ,CAAC,yCAAyC,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC9F,CAAC;QAED,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,OAAO,IAAI,QAAQ,CAAC,iCAAiC,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACtF,CAAC;QAED,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,OAAO,IAAI,QAAQ,CAAC,sCAAsC,SAAS,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC3F,CAAC;QAED,MAAM,OAAO,GAAG,MAAM,IAAI,aAAa,SAAS,EAAE,CAAC;QACnD,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,KAAK,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;QAChC,OAAO,IAAI,QAAQ,CAAC,2CAA2C,SAAS,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,IAAI,QAAQ,CACjB,oCAAoC,SAAS,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAC7G,CAAC;AACJ,CAAC","sourcesContent":["import { z } from 'zod';\nimport { analytics } from '../utils/analytics.js';\n\nexport const ApiUserSchema = z.object({\n distinct_id: z.string(),\n organizations: z.array(\n z.object({\n id: z.uuid(),\n }),\n ),\n team: z.object({\n id: z.number(),\n organization: z.uuid(),\n }),\n organization: z.object({\n id: z.uuid(),\n }),\n});\n\nexport const ApiProjectSchema = z.object({\n id: z.number(),\n uuid: z.uuid(),\n organization: z.uuid(),\n api_token: z.string(),\n name: z.string(),\n});\n\nexport type ApiUser = z.infer<typeof ApiUserSchema>;\nexport type ApiProject = z.infer<typeof ApiProjectSchema>;\n\nclass ApiError extends Error {\n constructor(\n message: string,\n public readonly statusCode?: number,\n public readonly endpoint?: string,\n ) {\n super(message);\n this.name = 'ApiError';\n }\n}\n\nexport async function fetchUserData(accessToken: string, baseUrl: string): Promise<ApiUser> {\n const endpoint = '/api/users/@me/';\n try {\n const response = await fetch(`${baseUrl}${endpoint}`, {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n throw await createFetchError(response, endpoint);\n }\n\n const data = await response.json();\n return ApiUserSchema.parse(data);\n } catch (error) {\n const apiError = handleApiError(error, 'fetch user data', endpoint);\n analytics.captureException(apiError, {\n endpoint,\n baseUrl,\n });\n throw apiError;\n }\n}\n\nexport async function fetchProjectData(accessToken: string, projectId: number, baseUrl: string): Promise<ApiProject> {\n const endpoint = `/api/projects/${projectId}/`;\n try {\n const response = await fetch(`${baseUrl}${endpoint}`, {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n throw await createFetchError(response, endpoint);\n }\n\n const data = await response.json();\n return ApiProjectSchema.parse(data);\n } catch (error) {\n const apiError = handleApiError(error, 'fetch project data', endpoint);\n analytics.captureException(apiError, {\n endpoint,\n baseUrl,\n projectId,\n });\n throw apiError;\n }\n}\n\ninterface FetchError extends Error {\n status: number;\n endpoint: string;\n detail?: string;\n}\n\nasync function createFetchError(response: Response, endpoint: string): Promise<FetchError> {\n let detail: string | undefined;\n try {\n const data: unknown = await response.json();\n if (typeof data === 'object' && data !== null && 'detail' in data) {\n detail = String((data as { detail: unknown }).detail);\n }\n } catch {\n // Response wasn't JSON\n }\n\n const error = new Error(`HTTP ${response.status}`) as FetchError;\n error.status = response.status;\n error.endpoint = endpoint;\n error.detail = detail;\n return error;\n}\n\nfunction isFetchError(error: unknown): error is FetchError {\n return error instanceof Error && 'status' in error && typeof (error as FetchError).status === 'number';\n}\n\nfunction handleApiError(error: unknown, operation: string, endpoint: string): ApiError {\n if (isFetchError(error)) {\n const { status, detail } = error;\n\n if (status === 401) {\n return new ApiError(`Authentication failed while trying to ${operation}`, status, endpoint);\n }\n\n if (status === 403) {\n return new ApiError(`Access denied while trying to ${operation}`, status, endpoint);\n }\n\n if (status === 404) {\n return new ApiError(`Resource not found while trying to ${operation}`, status, endpoint);\n }\n\n const message = detail || `Failed to ${operation}`;\n return new ApiError(message, status, endpoint);\n }\n\n if (error instanceof z.ZodError) {\n return new ApiError(`Invalid response format while trying to ${operation}`);\n }\n\n return new ApiError(\n `Unexpected error while trying to ${operation}: ${error instanceof Error ? error.message : 'Unknown error'}`,\n );\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { WizardOptions } from '../utils/types.js';
|
|
2
|
+
import { Integration } from './constants.js';
|
|
3
|
+
export declare const INTEGRATION_CONFIG: {
|
|
4
|
+
readonly nextjs: {
|
|
5
|
+
readonly name: "Next.js";
|
|
6
|
+
readonly filterPatterns: ["**/*.{tsx,ts,jsx,js,mjs,cjs}"];
|
|
7
|
+
readonly ignorePatterns: ["node_modules", "dist", "build", "public", "static", "next-env.d.*"];
|
|
8
|
+
readonly detect: (options: Pick<WizardOptions, "installDir">) => Promise<boolean>;
|
|
9
|
+
readonly generateFilesRules: "";
|
|
10
|
+
readonly filterFilesRules: "";
|
|
11
|
+
readonly docsUrl: "https://workos.com/docs/user-management/authkit/nextjs";
|
|
12
|
+
readonly defaultChanges: "• Installed @workos/authkit-nextjs package\n• Initialized WorkOS AuthKit with your credentials\n• Created authentication routes and callbacks\n• Added login/logout UI components";
|
|
13
|
+
readonly nextSteps: "• Customize the auth UI to match your app design\n• Add protected routes using withAuth() middleware\n• Access user session with getUser() in your components";
|
|
14
|
+
};
|
|
15
|
+
readonly react: {
|
|
16
|
+
readonly name: "React (SPA)";
|
|
17
|
+
readonly filterPatterns: ["**/*.{tsx,ts,jsx,js}"];
|
|
18
|
+
readonly ignorePatterns: ["node_modules", "dist", "build", "public", "static", "assets"];
|
|
19
|
+
readonly detect: (options: Pick<WizardOptions, "installDir">) => Promise<boolean>;
|
|
20
|
+
readonly generateFilesRules: "";
|
|
21
|
+
readonly filterFilesRules: "";
|
|
22
|
+
readonly docsUrl: "https://workos.com/docs/user-management/authkit/react";
|
|
23
|
+
readonly defaultChanges: "• Installed @workos/authkit-react package\n• Added AuthKitProvider to wrap your app\n• Created login and callback components";
|
|
24
|
+
readonly nextSteps: "• Use useAuth() hook to access auth state in components\n• Add protected routes with conditional rendering\n• Customize auth UI to match your design";
|
|
25
|
+
};
|
|
26
|
+
readonly "tanstack-start": {
|
|
27
|
+
readonly name: "TanStack Start";
|
|
28
|
+
readonly filterPatterns: ["**/*.{tsx,ts,jsx,js}"];
|
|
29
|
+
readonly ignorePatterns: ["node_modules", "dist", "build", ".vinxi", ".output"];
|
|
30
|
+
readonly detect: (options: Pick<WizardOptions, "installDir">) => Promise<boolean>;
|
|
31
|
+
readonly generateFilesRules: "";
|
|
32
|
+
readonly filterFilesRules: "";
|
|
33
|
+
readonly docsUrl: "https://workos.com/docs/user-management/authkit/tanstack-start";
|
|
34
|
+
readonly defaultChanges: "• Installed WorkOS AuthKit SDK package\n• Added AuthKit middleware and routes\n• Created authentication components";
|
|
35
|
+
readonly nextSteps: "• Use useAuth() hook to access auth state\n• Add protected routes with authentication checks\n• Customize auth UI to match your app";
|
|
36
|
+
};
|
|
37
|
+
readonly "react-router": {
|
|
38
|
+
readonly name: "React Router";
|
|
39
|
+
readonly filterPatterns: ["**/*.{tsx,ts,jsx,js}"];
|
|
40
|
+
readonly ignorePatterns: ["node_modules", "dist", "build", "public", "static", "assets"];
|
|
41
|
+
readonly detect: (options: Pick<WizardOptions, "installDir">) => Promise<boolean>;
|
|
42
|
+
readonly generateFilesRules: "";
|
|
43
|
+
readonly filterFilesRules: "";
|
|
44
|
+
readonly docsUrl: "https://workos.com/docs/user-management/authkit/react-router";
|
|
45
|
+
readonly defaultChanges: "• Installed @workos/authkit-react-router package\n• Added AuthKitProvider with React Router integration\n• Created auth routes and loaders";
|
|
46
|
+
readonly nextSteps: "• Use useAuth() hook in your components\n• Add protected routes with loader functions\n• Customize auth flow to match your needs";
|
|
47
|
+
};
|
|
48
|
+
readonly "vanilla-js": {
|
|
49
|
+
readonly name: "Vanilla JavaScript";
|
|
50
|
+
readonly filterPatterns: ["**/*.{html,js,ts}"];
|
|
51
|
+
readonly ignorePatterns: ["node_modules", "dist", "build"];
|
|
52
|
+
readonly detect: (options: Pick<WizardOptions, "installDir">) => Promise<true>;
|
|
53
|
+
readonly generateFilesRules: "";
|
|
54
|
+
readonly filterFilesRules: "";
|
|
55
|
+
readonly docsUrl: "https://workos.com/docs/user-management/authkit/javascript";
|
|
56
|
+
readonly defaultChanges: "• Installed @workos/authkit-js package (or added CDN script)\n• Created auth initialization and callback handling\n• Added login button and auth state display";
|
|
57
|
+
readonly nextSteps: "• Integrate auth state into your existing UI\n• Add logout functionality where needed\n• Protect pages that require authentication";
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export declare const INTEGRATION_ORDER: readonly [Integration.nextjs, Integration.tanstackStart, Integration.reactRouter, Integration.react, Integration.vanillaJs];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { getPackageDotJson } from '../utils/clack-utils.js';
|
|
2
|
+
import { hasPackageInstalled } from '../utils/package-json.js';
|
|
3
|
+
import { Integration } from './constants.js';
|
|
4
|
+
export const INTEGRATION_CONFIG = {
|
|
5
|
+
[Integration.nextjs]: {
|
|
6
|
+
name: 'Next.js',
|
|
7
|
+
filterPatterns: ['**/*.{tsx,ts,jsx,js,mjs,cjs}'],
|
|
8
|
+
ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static', 'next-env.d.*'],
|
|
9
|
+
detect: async (options) => {
|
|
10
|
+
const packageJson = await getPackageDotJson(options);
|
|
11
|
+
return hasPackageInstalled('next', packageJson);
|
|
12
|
+
},
|
|
13
|
+
generateFilesRules: '',
|
|
14
|
+
filterFilesRules: '',
|
|
15
|
+
docsUrl: 'https://workos.com/docs/user-management/authkit/nextjs',
|
|
16
|
+
defaultChanges: '• Installed @workos/authkit-nextjs package\n• Initialized WorkOS AuthKit with your credentials\n• Created authentication routes and callbacks\n• Added login/logout UI components',
|
|
17
|
+
nextSteps: '• Customize the auth UI to match your app design\n• Add protected routes using withAuth() middleware\n• Access user session with getUser() in your components',
|
|
18
|
+
},
|
|
19
|
+
[Integration.react]: {
|
|
20
|
+
name: 'React (SPA)',
|
|
21
|
+
filterPatterns: ['**/*.{tsx,ts,jsx,js}'],
|
|
22
|
+
ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static', 'assets'],
|
|
23
|
+
detect: async (options) => {
|
|
24
|
+
const packageJson = await getPackageDotJson(options);
|
|
25
|
+
// Detect React without routing frameworks
|
|
26
|
+
const hasReact = hasPackageInstalled('react', packageJson);
|
|
27
|
+
const hasNext = hasPackageInstalled('next', packageJson);
|
|
28
|
+
const hasReactRouter = hasPackageInstalled('react-router', packageJson);
|
|
29
|
+
const hasTanstack = hasPackageInstalled('@tanstack/react-start', packageJson);
|
|
30
|
+
return hasReact && !hasNext && !hasReactRouter && !hasTanstack;
|
|
31
|
+
},
|
|
32
|
+
generateFilesRules: '',
|
|
33
|
+
filterFilesRules: '',
|
|
34
|
+
docsUrl: 'https://workos.com/docs/user-management/authkit/react',
|
|
35
|
+
defaultChanges: '• Installed @workos/authkit-react package\n• Added AuthKitProvider to wrap your app\n• Created login and callback components',
|
|
36
|
+
nextSteps: '• Use useAuth() hook to access auth state in components\n• Add protected routes with conditional rendering\n• Customize auth UI to match your design',
|
|
37
|
+
},
|
|
38
|
+
[Integration.tanstackStart]: {
|
|
39
|
+
name: 'TanStack Start',
|
|
40
|
+
filterPatterns: ['**/*.{tsx,ts,jsx,js}'],
|
|
41
|
+
ignorePatterns: ['node_modules', 'dist', 'build', '.vinxi', '.output'],
|
|
42
|
+
detect: async (options) => {
|
|
43
|
+
const packageJson = await getPackageDotJson(options);
|
|
44
|
+
return hasPackageInstalled('@tanstack/react-start', packageJson);
|
|
45
|
+
},
|
|
46
|
+
generateFilesRules: '',
|
|
47
|
+
filterFilesRules: '',
|
|
48
|
+
docsUrl: 'https://workos.com/docs/user-management/authkit/tanstack-start',
|
|
49
|
+
defaultChanges: '• Installed WorkOS AuthKit SDK package\n• Added AuthKit middleware and routes\n• Created authentication components',
|
|
50
|
+
nextSteps: '• Use useAuth() hook to access auth state\n• Add protected routes with authentication checks\n• Customize auth UI to match your app',
|
|
51
|
+
},
|
|
52
|
+
[Integration.reactRouter]: {
|
|
53
|
+
name: 'React Router',
|
|
54
|
+
filterPatterns: ['**/*.{tsx,ts,jsx,js}'],
|
|
55
|
+
ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static', 'assets'],
|
|
56
|
+
detect: async (options) => {
|
|
57
|
+
const packageJson = await getPackageDotJson(options);
|
|
58
|
+
return hasPackageInstalled('react-router', packageJson);
|
|
59
|
+
},
|
|
60
|
+
generateFilesRules: '',
|
|
61
|
+
filterFilesRules: '',
|
|
62
|
+
docsUrl: 'https://workos.com/docs/user-management/authkit/react-router',
|
|
63
|
+
defaultChanges: '• Installed @workos/authkit-react-router package\n• Added AuthKitProvider with React Router integration\n• Created auth routes and loaders',
|
|
64
|
+
nextSteps: '• Use useAuth() hook in your components\n• Add protected routes with loader functions\n• Customize auth flow to match your needs',
|
|
65
|
+
},
|
|
66
|
+
[Integration.vanillaJs]: {
|
|
67
|
+
name: 'Vanilla JavaScript',
|
|
68
|
+
filterPatterns: ['**/*.{html,js,ts}'],
|
|
69
|
+
ignorePatterns: ['node_modules', 'dist', 'build'],
|
|
70
|
+
detect: async (options) => {
|
|
71
|
+
// Fallback: if no framework detected, assume vanilla JS
|
|
72
|
+
return true;
|
|
73
|
+
},
|
|
74
|
+
generateFilesRules: '',
|
|
75
|
+
filterFilesRules: '',
|
|
76
|
+
docsUrl: 'https://workos.com/docs/user-management/authkit/javascript',
|
|
77
|
+
defaultChanges: '• Installed @workos/authkit-js package (or added CDN script)\n• Created auth initialization and callback handling\n• Added login button and auth state display',
|
|
78
|
+
nextSteps: '• Integrate auth state into your existing UI\n• Add logout functionality where needed\n• Protect pages that require authentication',
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
export const INTEGRATION_ORDER = [
|
|
82
|
+
Integration.nextjs,
|
|
83
|
+
Integration.tanstackStart,
|
|
84
|
+
Integration.reactRouter,
|
|
85
|
+
Integration.react,
|
|
86
|
+
Integration.vanillaJs, // fallback
|
|
87
|
+
];
|
|
88
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAc7C,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE;QACpB,IAAI,EAAE,SAAS;QACf,cAAc,EAAE,CAAC,8BAA8B,CAAC;QAChD,cAAc,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,CAAC;QACrF,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACxB,MAAM,WAAW,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAC;YACrD,OAAO,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAClD,CAAC;QACD,kBAAkB,EAAE,EAAE;QACtB,gBA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CAAC,aAAa;IACzB,WAAW,CAAC,WAAW;IACvB,WAAW,CAAC,KAAK;IACjB,WAAW,CAAC,SAAS,EAAE,WAAW;CAC1B,CAAC","sourcesContent":["import { getPackageDotJson } from '../utils/clack-utils.js';\nimport { hasPackageInstalled } from '../utils/package-json.js';\nimport type { WizardOptions } from '../utils/types.js';\nimport { Integration } from './constants.js';\n\ntype IntegrationConfig = {\n name: string;\n filterPatterns: string[];\n ignorePatterns: string[];\n detect: (options: Pick<WizardOptions, 'installDir'>) => Promise<boolean>;\n generateFilesRules: string;\n filterFilesRules: string;\n docsUrl: string;\n nextSteps: string;\n defaultChanges: string;\n};\n\nexport const INTEGRATION_CONFIG = {\n [Integration.nextjs]: {\n name: 'Next.js',\n filterPatterns: ['**/*.{tsx,ts,jsx,js,mjs,cjs}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static', 'next-env.d.*'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('next', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://workos.com/docs/user-management/authkit/nextjs',\n defaultChanges:\n '• Installed @workos/authkit-nextjs package\\n• Initialized WorkOS AuthKit with your credentials\\n• Created authentication routes and callbacks\\n• Added login/logout UI components',\n nextSteps:\n '• Customize the auth UI to match your app design\\n• Add protected routes using withAuth() middleware\\n• Access user session with getUser() in your components',\n },\n [Integration.react]: {\n name: 'React (SPA)',\n filterPatterns: ['**/*.{tsx,ts,jsx,js}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static', 'assets'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n // Detect React without routing frameworks\n const hasReact = hasPackageInstalled('react', packageJson);\n const hasNext = hasPackageInstalled('next', packageJson);\n const hasReactRouter = hasPackageInstalled('react-router', packageJson);\n const hasTanstack = hasPackageInstalled('@tanstack/react-start', packageJson);\n return hasReact && !hasNext && !hasReactRouter && !hasTanstack;\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://workos.com/docs/user-management/authkit/react',\n defaultChanges:\n '• Installed @workos/authkit-react package\\n• Added AuthKitProvider to wrap your app\\n• Created login and callback components',\n nextSteps:\n '• Use useAuth() hook to access auth state in components\\n• Add protected routes with conditional rendering\\n• Customize auth UI to match your design',\n },\n [Integration.tanstackStart]: {\n name: 'TanStack Start',\n filterPatterns: ['**/*.{tsx,ts,jsx,js}'],\n ignorePatterns: ['node_modules', 'dist', 'build', '.vinxi', '.output'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('@tanstack/react-start', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://workos.com/docs/user-management/authkit/tanstack-start',\n defaultChanges:\n '• Installed WorkOS AuthKit SDK package\\n• Added AuthKit middleware and routes\\n• Created authentication components',\n nextSteps:\n '• Use useAuth() hook to access auth state\\n• Add protected routes with authentication checks\\n• Customize auth UI to match your app',\n },\n [Integration.reactRouter]: {\n name: 'React Router',\n filterPatterns: ['**/*.{tsx,ts,jsx,js}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static', 'assets'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('react-router', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://workos.com/docs/user-management/authkit/react-router',\n defaultChanges:\n '• Installed @workos/authkit-react-router package\\n• Added AuthKitProvider with React Router integration\\n• Created auth routes and loaders',\n nextSteps:\n '• Use useAuth() hook in your components\\n• Add protected routes with loader functions\\n• Customize auth flow to match your needs',\n },\n [Integration.vanillaJs]: {\n name: 'Vanilla JavaScript',\n filterPatterns: ['**/*.{html,js,ts}'],\n ignorePatterns: ['node_modules', 'dist', 'build'],\n detect: async (options) => {\n // Fallback: if no framework detected, assume vanilla JS\n return true;\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://workos.com/docs/user-management/authkit/javascript',\n defaultChanges:\n '• Installed @workos/authkit-js package (or added CDN script)\\n• Created auth initialization and callback handling\\n• Added login button and auth state display',\n nextSteps:\n '• Integrate auth state into your existing UI\\n• Add logout functionality where needed\\n• Protect pages that require authentication',\n },\n} as const satisfies Record<Integration, IntegrationConfig>;\n\nexport const INTEGRATION_ORDER = [\n Integration.nextjs,\n Integration.tanstackStart,\n Integration.reactRouter,\n Integration.react,\n Integration.vanillaJs, // fallback\n] as const;\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare enum Integration {
|
|
2
|
+
nextjs = "nextjs",
|
|
3
|
+
react = "react",
|
|
4
|
+
tanstackStart = "tanstack-start",
|
|
5
|
+
reactRouter = "react-router",
|
|
6
|
+
vanillaJs = "vanilla-js"
|
|
7
|
+
}
|
|
8
|
+
export declare function getIntegrationDescription(type: string): string;
|
|
9
|
+
type IntegrationChoice = {
|
|
10
|
+
name: string;
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function getIntegrationChoices(): IntegrationChoice[];
|
|
14
|
+
export interface Args {
|
|
15
|
+
debug: boolean;
|
|
16
|
+
integration: Integration;
|
|
17
|
+
}
|
|
18
|
+
export declare const IS_DEV: boolean;
|
|
19
|
+
export declare const DEBUG: boolean;
|
|
20
|
+
export declare const WORKOS_DOCS_URL: string;
|
|
21
|
+
export declare const WORKOS_DASHBOARD_URL: string;
|
|
22
|
+
export declare const ISSUES_URL: string;
|
|
23
|
+
export declare const ANALYTICS_ENABLED: boolean;
|
|
24
|
+
export declare const WIZARD_INTERACTION_EVENT_NAME: string;
|
|
25
|
+
export declare const WORKOS_TELEMETRY_ENABLED: boolean;
|
|
26
|
+
export declare const OAUTH_PORT: number;
|
|
27
|
+
/**
|
|
28
|
+
* Common glob patterns to ignore when searching for files.
|
|
29
|
+
* Used by both Next.js and React Router integrations.
|
|
30
|
+
*/
|
|
31
|
+
export declare const IGNORE_PATTERNS: string[];
|
|
32
|
+
export {};
|