workos 0.6.0 → 0.7.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.
Files changed (88) hide show
  1. package/README.md +51 -15
  2. package/dist/bin.js +151 -0
  3. package/dist/bin.js.map +1 -1
  4. package/dist/cli.config.d.ts +1 -0
  5. package/dist/cli.config.js +1 -0
  6. package/dist/cli.config.js.map +1 -1
  7. package/dist/commands/doctor.d.ts +1 -0
  8. package/dist/commands/doctor.js +1 -0
  9. package/dist/commands/doctor.js.map +1 -1
  10. package/dist/commands/env.d.ts +9 -0
  11. package/dist/commands/env.js +188 -0
  12. package/dist/commands/env.js.map +1 -0
  13. package/dist/commands/organization.d.ts +18 -0
  14. package/dist/commands/organization.js +142 -0
  15. package/dist/commands/organization.js.map +1 -0
  16. package/dist/commands/user.d.ts +19 -0
  17. package/dist/commands/user.js +128 -0
  18. package/dist/commands/user.js.map +1 -0
  19. package/dist/dashboard/components/CompletionView.js +5 -1
  20. package/dist/dashboard/components/CompletionView.js.map +1 -1
  21. package/dist/doctor/agent-prompt.d.ts +9 -0
  22. package/dist/doctor/agent-prompt.js +67 -0
  23. package/dist/doctor/agent-prompt.js.map +1 -0
  24. package/dist/doctor/checks/ai-analysis.d.ts +9 -0
  25. package/dist/doctor/checks/ai-analysis.js +122 -0
  26. package/dist/doctor/checks/ai-analysis.js.map +1 -0
  27. package/dist/doctor/checks/auth-patterns.d.ts +2 -0
  28. package/dist/doctor/checks/auth-patterns.js +530 -0
  29. package/dist/doctor/checks/auth-patterns.js.map +1 -0
  30. package/dist/doctor/checks/environment.js +22 -4
  31. package/dist/doctor/checks/environment.js.map +1 -1
  32. package/dist/doctor/checks/framework.js +27 -8
  33. package/dist/doctor/checks/framework.js.map +1 -1
  34. package/dist/doctor/checks/language.d.ts +6 -0
  35. package/dist/doctor/checks/language.js +104 -0
  36. package/dist/doctor/checks/language.js.map +1 -0
  37. package/dist/doctor/checks/sdk.js +113 -22
  38. package/dist/doctor/checks/sdk.js.map +1 -1
  39. package/dist/doctor/index.js +26 -3
  40. package/dist/doctor/index.js.map +1 -1
  41. package/dist/doctor/issues.js +22 -1
  42. package/dist/doctor/issues.js.map +1 -1
  43. package/dist/doctor/output.js +85 -18
  44. package/dist/doctor/output.js.map +1 -1
  45. package/dist/doctor/types.d.ts +38 -0
  46. package/dist/doctor/types.js.map +1 -1
  47. package/dist/lib/adapters/cli-adapter.js +4 -14
  48. package/dist/lib/adapters/cli-adapter.js.map +1 -1
  49. package/dist/lib/adapters/dashboard-adapter.js +3 -16
  50. package/dist/lib/adapters/dashboard-adapter.js.map +1 -1
  51. package/dist/lib/api-key.d.ts +13 -0
  52. package/dist/lib/api-key.js +26 -0
  53. package/dist/lib/api-key.js.map +1 -0
  54. package/dist/lib/config-store.d.ts +27 -0
  55. package/dist/lib/config-store.js +142 -0
  56. package/dist/lib/config-store.js.map +1 -0
  57. package/dist/lib/credential-store.d.ts +4 -0
  58. package/dist/lib/credential-store.js +47 -11
  59. package/dist/lib/credential-store.js.map +1 -1
  60. package/dist/lib/credentials.d.ts +1 -1
  61. package/dist/lib/credentials.js +1 -1
  62. package/dist/lib/credentials.js.map +1 -1
  63. package/dist/lib/run-with-core.js +23 -2
  64. package/dist/lib/run-with-core.js.map +1 -1
  65. package/dist/lib/settings.d.ts +1 -0
  66. package/dist/lib/settings.js.map +1 -1
  67. package/dist/lib/validation/build-validator.js +0 -1
  68. package/dist/lib/validation/build-validator.js.map +1 -1
  69. package/dist/lib/validation/quick-checks.js +0 -1
  70. package/dist/lib/validation/quick-checks.js.map +1 -1
  71. package/dist/lib/workos-api.d.ts +30 -0
  72. package/dist/lib/workos-api.js +69 -0
  73. package/dist/lib/workos-api.js.map +1 -0
  74. package/dist/utils/cli-symbols.d.ts +1 -1
  75. package/dist/utils/lock-art.d.ts +4 -0
  76. package/dist/utils/lock-art.js +73 -0
  77. package/dist/utils/lock-art.js.map +1 -0
  78. package/dist/utils/package-json.d.ts +1 -0
  79. package/dist/utils/package-json.js +11 -0
  80. package/dist/utils/package-json.js.map +1 -1
  81. package/dist/utils/summary-box.d.ts +18 -0
  82. package/dist/utils/summary-box.js +148 -0
  83. package/dist/utils/summary-box.js.map +1 -0
  84. package/dist/utils/table.d.ts +5 -0
  85. package/dist/utils/table.js +18 -0
  86. package/dist/utils/table.js.map +1 -0
  87. package/package.json +1 -1
  88. package/skills/workos-authkit-nextjs/SKILL.md +5 -5
@@ -0,0 +1,188 @@
1
+ import chalk from 'chalk';
2
+ import clack from '../utils/clack.js';
3
+ import { getConfig, saveConfig } from '../lib/config-store.js';
4
+ const ENV_NAME_REGEX = /^[a-z0-9\-_]+$/;
5
+ function validateEnvName(name) {
6
+ if (!ENV_NAME_REGEX.test(name)) {
7
+ return 'Name must contain only lowercase letters, numbers, hyphens, and underscores';
8
+ }
9
+ return undefined;
10
+ }
11
+ function getOrCreateConfig() {
12
+ return getConfig() ?? { environments: {} };
13
+ }
14
+ export async function runEnvAdd(options) {
15
+ let { name, apiKey, endpoint } = options;
16
+ const { clientId } = options;
17
+ if (name && apiKey) {
18
+ // Non-interactive mode
19
+ const nameError = validateEnvName(name);
20
+ if (nameError) {
21
+ clack.log.error(nameError);
22
+ process.exit(1);
23
+ }
24
+ }
25
+ else {
26
+ // Interactive mode
27
+ const nameResult = await clack.text({
28
+ message: 'Enter a name for the environment (e.g., production, sandbox, local)',
29
+ validate: (value) => validateEnvName(value),
30
+ });
31
+ if (clack.isCancel(nameResult))
32
+ process.exit(0);
33
+ name = nameResult;
34
+ const typeResult = await clack.select({
35
+ message: 'Select the environment type',
36
+ options: [
37
+ { value: 'production', label: 'Production' },
38
+ { value: 'sandbox', label: 'Sandbox' },
39
+ ],
40
+ });
41
+ if (clack.isCancel(typeResult))
42
+ process.exit(0);
43
+ const apiKeyResult = await clack.password({
44
+ message: 'Enter the API key for this environment',
45
+ validate: (value) => {
46
+ if (!value)
47
+ return 'API key is required';
48
+ return undefined;
49
+ },
50
+ });
51
+ if (clack.isCancel(apiKeyResult))
52
+ process.exit(0);
53
+ apiKey = apiKeyResult;
54
+ const config = getOrCreateConfig();
55
+ const isFirst = Object.keys(config.environments).length === 0;
56
+ config.environments[name] = {
57
+ name,
58
+ type: typeResult,
59
+ apiKey,
60
+ ...(clientId && { clientId }),
61
+ ...(endpoint && { endpoint }),
62
+ };
63
+ // Auto-set active environment if it's the first one
64
+ if (isFirst) {
65
+ config.activeEnvironment = name;
66
+ }
67
+ saveConfig(config);
68
+ clack.log.success(`Environment ${chalk.bold(name)} added`);
69
+ if (isFirst) {
70
+ clack.log.info(`Set as active environment`);
71
+ }
72
+ return;
73
+ }
74
+ // Non-interactive path
75
+ const config = getOrCreateConfig();
76
+ const isFirst = Object.keys(config.environments).length === 0;
77
+ // Detect type from API key prefix
78
+ const type = apiKey.startsWith('sk_test_') ? 'sandbox' : 'production';
79
+ config.environments[name] = {
80
+ name: name,
81
+ type,
82
+ apiKey,
83
+ ...(clientId && { clientId }),
84
+ ...(endpoint && { endpoint }),
85
+ };
86
+ if (isFirst) {
87
+ config.activeEnvironment = name;
88
+ }
89
+ saveConfig(config);
90
+ clack.log.success(`Environment ${chalk.bold(name)} added`);
91
+ if (isFirst) {
92
+ clack.log.info(`Set as active environment`);
93
+ }
94
+ }
95
+ export async function runEnvRemove(name) {
96
+ const config = getConfig();
97
+ if (!config || Object.keys(config.environments).length === 0) {
98
+ clack.log.error('No environments configured. Run `workos env add` to get started.');
99
+ process.exit(1);
100
+ }
101
+ if (!config.environments[name]) {
102
+ const available = Object.keys(config.environments).join(', ');
103
+ clack.log.error(`Environment "${name}" not found. Available: ${available}`);
104
+ process.exit(1);
105
+ }
106
+ delete config.environments[name];
107
+ // Clear active environment if it was the removed one
108
+ if (config.activeEnvironment === name) {
109
+ const remaining = Object.keys(config.environments);
110
+ config.activeEnvironment = remaining.length > 0 ? remaining[0] : undefined;
111
+ if (config.activeEnvironment) {
112
+ clack.log.info(`Active environment switched to ${chalk.bold(config.activeEnvironment)}`);
113
+ }
114
+ }
115
+ saveConfig(config);
116
+ clack.log.success(`Environment ${chalk.bold(name)} removed`);
117
+ }
118
+ export async function runEnvSwitch(name) {
119
+ const config = getConfig();
120
+ if (!config || Object.keys(config.environments).length === 0) {
121
+ clack.log.error('No environments configured. Run `workos env add` to get started.');
122
+ process.exit(1);
123
+ }
124
+ if (name) {
125
+ if (!config.environments[name]) {
126
+ const available = Object.keys(config.environments).join(', ');
127
+ clack.log.error(`Environment "${name}" not found. Available: ${available}`);
128
+ process.exit(1);
129
+ }
130
+ }
131
+ else {
132
+ // Interactive selection
133
+ const options = Object.entries(config.environments).map(([key, env]) => {
134
+ let label = key;
135
+ if (env.type === 'sandbox')
136
+ label += ` [Sandbox]`;
137
+ if (env.endpoint)
138
+ label += ` [${env.endpoint}]`;
139
+ if (key === config.activeEnvironment)
140
+ label += chalk.green(' (active)');
141
+ return { value: key, label };
142
+ });
143
+ const selected = await clack.select({
144
+ message: 'Select an environment',
145
+ options,
146
+ });
147
+ if (clack.isCancel(selected))
148
+ process.exit(0);
149
+ name = selected;
150
+ }
151
+ config.activeEnvironment = name;
152
+ saveConfig(config);
153
+ const env = config.environments[name];
154
+ let label = chalk.bold(name);
155
+ if (env.type === 'sandbox')
156
+ label += ` [Sandbox]`;
157
+ if (env.endpoint)
158
+ label += ` [${env.endpoint}]`;
159
+ clack.log.success(`Switched to environment ${label}`);
160
+ }
161
+ export async function runEnvList() {
162
+ const config = getConfig();
163
+ if (!config || Object.keys(config.environments).length === 0) {
164
+ clack.log.info('No environments configured. Run `workos env add` to get started.');
165
+ return;
166
+ }
167
+ const entries = Object.entries(config.environments);
168
+ const nameW = Math.max(6, ...entries.map(([k]) => k.length)) + 2;
169
+ const typeW = 12;
170
+ const header = [
171
+ chalk.yellow(' '),
172
+ chalk.yellow('Name'.padEnd(nameW)),
173
+ chalk.yellow('Type'.padEnd(typeW)),
174
+ chalk.yellow('Endpoint'),
175
+ ].join(' ');
176
+ const separator = chalk.dim('─'.repeat(header.length));
177
+ console.log(header);
178
+ console.log(separator);
179
+ for (const [key, env] of entries) {
180
+ const isActive = key === config.activeEnvironment;
181
+ const marker = isActive ? chalk.green('▸ ') : ' ';
182
+ const name = isActive ? chalk.green(key.padEnd(nameW)) : key.padEnd(nameW);
183
+ const type = env.type === 'sandbox' ? 'Sandbox' : 'Production';
184
+ const endpoint = env.endpoint || chalk.dim('default');
185
+ console.log([marker, name, type.padEnd(typeW), endpoint].join(' '));
186
+ }
187
+ }
188
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/commands/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,UAAU,EAA4B,MAAM,wBAAwB,CAAC;AAGzF,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,SAAS,eAAe,CAAC,IAAY;IACnC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,6EAA6E,CAAC;IACvF,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAK/B;IACC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACzC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE7B,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;QACnB,uBAAuB;QACvB,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,SAAS,EAAE,CAAC;YACd,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC3B,OAAO,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AC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3E,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC;QAC/D,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEtD,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACvE,CAAC;AACH,CAAC","sourcesContent":["import chalk from 'chalk';\nimport clack from '../utils/clack.js';\nimport { getConfig, saveConfig, setInsecureConfigStorage } from '../lib/config-store.js';\nimport type { CliConfig, EnvironmentConfig } from '../lib/config-store.js';\n\nconst ENV_NAME_REGEX = /^[a-z0-9\\-_]+$/;\n\nfunction validateEnvName(name: string): string | undefined {\n if (!ENV_NAME_REGEX.test(name)) {\n return 'Name must contain only lowercase letters, numbers, hyphens, and underscores';\n }\n return undefined;\n}\n\nfunction getOrCreateConfig(): CliConfig {\n return getConfig() ?? { environments: {} };\n}\n\nexport async function runEnvAdd(options: {\n name?: string;\n apiKey?: string;\n clientId?: string;\n endpoint?: string;\n}): Promise<void> {\n let { name, apiKey, endpoint } = options;\n const { clientId } = options;\n\n if (name && apiKey) {\n // Non-interactive mode\n const nameError = validateEnvName(name);\n if (nameError) {\n clack.log.error(nameError);\n process.exit(1);\n }\n } else {\n // Interactive mode\n const nameResult = await clack.text({\n message: 'Enter a name for the environment (e.g., production, sandbox, local)',\n validate: (value) => validateEnvName(value),\n });\n if (clack.isCancel(nameResult)) process.exit(0);\n name = nameResult;\n\n const typeResult = await clack.select({\n message: 'Select the environment type',\n options: [\n { value: 'production', label: 'Production' },\n { value: 'sandbox', label: 'Sandbox' },\n ],\n });\n if (clack.isCancel(typeResult)) process.exit(0);\n\n const apiKeyResult = await clack.password({\n message: 'Enter the API key for this environment',\n validate: (value) => {\n if (!value) return 'API key is required';\n return undefined;\n },\n });\n if (clack.isCancel(apiKeyResult)) process.exit(0);\n apiKey = apiKeyResult;\n\n const config = getOrCreateConfig();\n const isFirst = Object.keys(config.environments).length === 0;\n\n config.environments[name] = {\n name,\n type: typeResult as 'production' | 'sandbox',\n apiKey,\n ...(clientId && { clientId }),\n ...(endpoint && { endpoint }),\n };\n\n // Auto-set active environment if it's the first one\n if (isFirst) {\n config.activeEnvironment = name;\n }\n\n saveConfig(config);\n clack.log.success(`Environment ${chalk.bold(name)} added`);\n if (isFirst) {\n clack.log.info(`Set as active environment`);\n }\n return;\n }\n\n // Non-interactive path\n const config = getOrCreateConfig();\n const isFirst = Object.keys(config.environments).length === 0;\n\n // Detect type from API key prefix\n const type: 'production' | 'sandbox' = apiKey.startsWith('sk_test_') ? 'sandbox' : 'production';\n\n config.environments[name!] = {\n name: name!,\n type,\n apiKey,\n ...(clientId && { clientId }),\n ...(endpoint && { endpoint }),\n };\n\n if (isFirst) {\n config.activeEnvironment = name;\n }\n\n saveConfig(config);\n clack.log.success(`Environment ${chalk.bold(name)} added`);\n if (isFirst) {\n clack.log.info(`Set as active environment`);\n }\n}\n\nexport async function runEnvRemove(name: string): Promise<void> {\n const config = getConfig();\n if (!config || Object.keys(config.environments).length === 0) {\n clack.log.error('No environments configured. Run `workos env add` to get started.');\n process.exit(1);\n }\n\n if (!config.environments[name]) {\n const available = Object.keys(config.environments).join(', ');\n clack.log.error(`Environment \"${name}\" not found. Available: ${available}`);\n process.exit(1);\n }\n\n delete config.environments[name];\n\n // Clear active environment if it was the removed one\n if (config.activeEnvironment === name) {\n const remaining = Object.keys(config.environments);\n config.activeEnvironment = remaining.length > 0 ? remaining[0] : undefined;\n if (config.activeEnvironment) {\n clack.log.info(`Active environment switched to ${chalk.bold(config.activeEnvironment)}`);\n }\n }\n\n saveConfig(config);\n clack.log.success(`Environment ${chalk.bold(name)} removed`);\n}\n\nexport async function runEnvSwitch(name?: string): Promise<void> {\n const config = getConfig();\n if (!config || Object.keys(config.environments).length === 0) {\n clack.log.error('No environments configured. Run `workos env add` to get started.');\n process.exit(1);\n }\n\n if (name) {\n if (!config.environments[name]) {\n const available = Object.keys(config.environments).join(', ');\n clack.log.error(`Environment \"${name}\" not found. Available: ${available}`);\n process.exit(1);\n }\n } else {\n // Interactive selection\n const options = Object.entries(config.environments).map(([key, env]) => {\n let label = key;\n if (env.type === 'sandbox') label += ` [Sandbox]`;\n if (env.endpoint) label += ` [${env.endpoint}]`;\n if (key === config.activeEnvironment) label += chalk.green(' (active)');\n return { value: key, label };\n });\n\n const selected = await clack.select({\n message: 'Select an environment',\n options,\n });\n if (clack.isCancel(selected)) process.exit(0);\n name = selected as string;\n }\n\n config.activeEnvironment = name;\n saveConfig(config);\n\n const env = config.environments[name];\n let label = chalk.bold(name);\n if (env.type === 'sandbox') label += ` [Sandbox]`;\n if (env.endpoint) label += ` [${env.endpoint}]`;\n clack.log.success(`Switched to environment ${label}`);\n}\n\nexport async function runEnvList(): Promise<void> {\n const config = getConfig();\n if (!config || Object.keys(config.environments).length === 0) {\n clack.log.info('No environments configured. Run `workos env add` to get started.');\n return;\n }\n\n const entries = Object.entries(config.environments);\n\n const nameW = Math.max(6, ...entries.map(([k]) => k.length)) + 2;\n const typeW = 12;\n\n const header = [\n chalk.yellow(' '),\n chalk.yellow('Name'.padEnd(nameW)),\n chalk.yellow('Type'.padEnd(typeW)),\n chalk.yellow('Endpoint'),\n ].join(' ');\n\n const separator = chalk.dim('─'.repeat(header.length));\n\n console.log(header);\n console.log(separator);\n\n for (const [key, env] of entries) {\n const isActive = key === config.activeEnvironment;\n const marker = isActive ? chalk.green('▸ ') : ' ';\n const name = isActive ? chalk.green(key.padEnd(nameW)) : key.padEnd(nameW);\n const type = env.type === 'sandbox' ? 'Sandbox' : 'Production';\n const endpoint = env.endpoint || chalk.dim('default');\n\n console.log([marker, name, type.padEnd(typeW), endpoint].join(' '));\n }\n}\n"]}
@@ -0,0 +1,18 @@
1
+ interface DomainData {
2
+ domain: string;
3
+ state: string;
4
+ }
5
+ export declare function parseDomainArgs(args: string[]): DomainData[];
6
+ export declare function runOrgCreate(name: string, domainArgs: string[], apiKey: string, baseUrl?: string): Promise<void>;
7
+ export declare function runOrgUpdate(orgId: string, name: string, apiKey: string, domain?: string, state?: string, baseUrl?: string): Promise<void>;
8
+ export declare function runOrgGet(orgId: string, apiKey: string, baseUrl?: string): Promise<void>;
9
+ export interface OrgListOptions {
10
+ domain?: string;
11
+ limit?: number;
12
+ before?: string;
13
+ after?: string;
14
+ order?: string;
15
+ }
16
+ export declare function runOrgList(options: OrgListOptions, apiKey: string, baseUrl?: string): Promise<void>;
17
+ export declare function runOrgDelete(orgId: string, apiKey: string, baseUrl?: string): Promise<void>;
18
+ export {};
@@ -0,0 +1,142 @@
1
+ import chalk from 'chalk';
2
+ import { workosRequest, WorkOSApiError } from '../lib/workos-api.js';
3
+ import { formatTable } from '../utils/table.js';
4
+ export function parseDomainArgs(args) {
5
+ return args.map((arg) => {
6
+ const parts = arg.split(':');
7
+ return {
8
+ domain: parts[0],
9
+ state: parts[1] || 'verified',
10
+ };
11
+ });
12
+ }
13
+ function handleApiError(error) {
14
+ if (error instanceof WorkOSApiError) {
15
+ if (error.statusCode === 401) {
16
+ console.error(chalk.red('Invalid API key. Check your environment configuration.'));
17
+ }
18
+ else if (error.statusCode === 404) {
19
+ console.error(chalk.red(`Organization not found.`));
20
+ }
21
+ else if (error.statusCode === 422 && error.errors?.length) {
22
+ console.error(chalk.red(error.errors.map((e) => e.message).join(', ')));
23
+ }
24
+ else {
25
+ console.error(chalk.red(error.message));
26
+ }
27
+ }
28
+ else {
29
+ console.error(chalk.red(error instanceof Error ? error.message : 'Unknown error'));
30
+ }
31
+ process.exit(1);
32
+ }
33
+ export async function runOrgCreate(name, domainArgs, apiKey, baseUrl) {
34
+ const body = { name };
35
+ const domains = parseDomainArgs(domainArgs);
36
+ if (domains.length > 0) {
37
+ body.domain_data = domains;
38
+ }
39
+ try {
40
+ const org = await workosRequest({
41
+ method: 'POST',
42
+ path: '/organizations',
43
+ apiKey,
44
+ baseUrl,
45
+ body,
46
+ });
47
+ console.log(chalk.green('Created organization'));
48
+ console.log(JSON.stringify(org, null, 2));
49
+ }
50
+ catch (error) {
51
+ handleApiError(error);
52
+ }
53
+ }
54
+ export async function runOrgUpdate(orgId, name, apiKey, domain, state, baseUrl) {
55
+ const body = { name };
56
+ if (domain) {
57
+ body.domain_data = [{ domain, state: state || 'verified' }];
58
+ }
59
+ try {
60
+ const org = await workosRequest({
61
+ method: 'PUT',
62
+ path: `/organizations/${orgId}`,
63
+ apiKey,
64
+ baseUrl,
65
+ body,
66
+ });
67
+ console.log(chalk.green('Updated organization'));
68
+ console.log(JSON.stringify(org, null, 2));
69
+ }
70
+ catch (error) {
71
+ handleApiError(error);
72
+ }
73
+ }
74
+ export async function runOrgGet(orgId, apiKey, baseUrl) {
75
+ try {
76
+ const org = await workosRequest({
77
+ method: 'GET',
78
+ path: `/organizations/${orgId}`,
79
+ apiKey,
80
+ baseUrl,
81
+ });
82
+ console.log(JSON.stringify(org, null, 2));
83
+ }
84
+ catch (error) {
85
+ handleApiError(error);
86
+ }
87
+ }
88
+ export async function runOrgList(options, apiKey, baseUrl) {
89
+ try {
90
+ const result = await workosRequest({
91
+ method: 'GET',
92
+ path: '/organizations',
93
+ apiKey,
94
+ baseUrl,
95
+ params: {
96
+ domains: options.domain,
97
+ limit: options.limit,
98
+ before: options.before,
99
+ after: options.after,
100
+ order: options.order,
101
+ },
102
+ });
103
+ if (result.data.length === 0) {
104
+ console.log('No organizations found.');
105
+ return;
106
+ }
107
+ const rows = result.data.map((org) => [
108
+ org.id,
109
+ org.name,
110
+ org.domains.map((d) => d.domain).join(', ') || chalk.dim('none'),
111
+ ]);
112
+ console.log(formatTable([{ header: 'ID' }, { header: 'Name' }, { header: 'Domains' }], rows));
113
+ const { before, after } = result.list_metadata;
114
+ if (before && after) {
115
+ console.log(chalk.dim(`Before: ${before} After: ${after}`));
116
+ }
117
+ else if (before) {
118
+ console.log(chalk.dim(`Before: ${before}`));
119
+ }
120
+ else if (after) {
121
+ console.log(chalk.dim(`After: ${after}`));
122
+ }
123
+ }
124
+ catch (error) {
125
+ handleApiError(error);
126
+ }
127
+ }
128
+ export async function runOrgDelete(orgId, apiKey, baseUrl) {
129
+ try {
130
+ await workosRequest({
131
+ method: 'DELETE',
132
+ path: `/organizations/${orgId}`,
133
+ apiKey,
134
+ baseUrl,
135
+ });
136
+ console.log(chalk.green(`Deleted organization ${orgId}`));
137
+ }
138
+ catch (error) {
139
+ handleApiError(error);
140
+ }
141
+ }
142
+ //# sourceMappingURL=organization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.js","sourceRoot":"","sources":["../../src/commands/organization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAqBhD,MAAM,UAAU,eAAe,CAAC,IAAc;IAC5C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QACtB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC7B,OAAO;YACL,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;YAChB,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,UAAU;SAC9B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;QACpC,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;YAC7B,OAAO,CAAC,KA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Request, WorkOSApiError } from '../lib/workos-api.js';\nimport type { WorkOSListResponse } from '../lib/workos-api.js';\nimport { formatTable } from '../utils/table.js';\n\ninterface OrganizationDomain {\n id: string;\n domain: string;\n state: 'verified' | 'pending';\n}\n\ninterface Organization {\n id: string;\n name: string;\n domains: OrganizationDomain[];\n created_at: string;\n updated_at: string;\n}\n\ninterface DomainData {\n domain: string;\n state: string;\n}\n\nexport function parseDomainArgs(args: string[]): DomainData[] {\n return args.map((arg) => {\n const parts = arg.split(':');\n return {\n domain: parts[0],\n state: parts[1] || 'verified',\n };\n });\n}\n\nfunction handleApiError(error: unknown): never {\n if (error instanceof WorkOSApiError) {\n if (error.statusCode === 401) {\n console.error(chalk.red('Invalid API key. Check your environment configuration.'));\n } else if (error.statusCode === 404) {\n console.error(chalk.red(`Organization not found.`));\n } else if (error.statusCode === 422 && error.errors?.length) {\n console.error(chalk.red(error.errors.map((e) => e.message).join(', ')));\n } else {\n console.error(chalk.red(error.message));\n }\n } else {\n console.error(chalk.red(error instanceof Error ? error.message : 'Unknown error'));\n }\n process.exit(1);\n}\n\nexport async function runOrgCreate(\n name: string,\n domainArgs: string[],\n apiKey: string,\n baseUrl?: string,\n): Promise<void> {\n const body: Record<string, unknown> = { name };\n const domains = parseDomainArgs(domainArgs);\n if (domains.length > 0) {\n body.domain_data = domains;\n }\n\n try {\n const org = await workosRequest<Organization>({\n method: 'POST',\n path: '/organizations',\n apiKey,\n baseUrl,\n body,\n });\n console.log(chalk.green('Created organization'));\n console.log(JSON.stringify(org, null, 2));\n } catch (error) {\n handleApiError(error);\n }\n}\n\nexport async function runOrgUpdate(\n orgId: string,\n name: string,\n apiKey: string,\n domain?: string,\n state?: string,\n baseUrl?: string,\n): Promise<void> {\n const body: Record<string, unknown> = { name };\n if (domain) {\n body.domain_data = [{ domain, state: state || 'verified' }];\n }\n\n try {\n const org = await workosRequest<Organization>({\n method: 'PUT',\n path: `/organizations/${orgId}`,\n apiKey,\n baseUrl,\n body,\n });\n console.log(chalk.green('Updated organization'));\n console.log(JSON.stringify(org, null, 2));\n } catch (error) {\n handleApiError(error);\n }\n}\n\nexport async function runOrgGet(orgId: string, apiKey: string, baseUrl?: string): Promise<void> {\n try {\n const org = await workosRequest<Organization>({\n method: 'GET',\n path: `/organizations/${orgId}`,\n apiKey,\n baseUrl,\n });\n console.log(JSON.stringify(org, null, 2));\n } catch (error) {\n handleApiError(error);\n }\n}\n\nexport interface OrgListOptions {\n domain?: string;\n limit?: number;\n before?: string;\n after?: string;\n order?: string;\n}\n\nexport async function runOrgList(options: OrgListOptions, apiKey: string, baseUrl?: string): Promise<void> {\n try {\n const result = await workosRequest<WorkOSListResponse<Organization>>({\n method: 'GET',\n path: '/organizations',\n apiKey,\n baseUrl,\n params: {\n domains: options.domain,\n limit: options.limit,\n before: options.before,\n after: options.after,\n order: options.order,\n },\n });\n\n if (result.data.length === 0) {\n console.log('No organizations found.');\n return;\n }\n\n const rows = result.data.map((org) => [\n org.id,\n org.name,\n org.domains.map((d) => d.domain).join(', ') || chalk.dim('none'),\n ]);\n\n console.log(formatTable([{ header: 'ID' }, { header: 'Name' }, { header: 'Domains' }], rows));\n\n const { before, after } = result.list_metadata;\n if (before && after) {\n console.log(chalk.dim(`Before: ${before} After: ${after}`));\n } else if (before) {\n console.log(chalk.dim(`Before: ${before}`));\n } else if (after) {\n console.log(chalk.dim(`After: ${after}`));\n }\n } catch (error) {\n handleApiError(error);\n }\n}\n\nexport async function runOrgDelete(orgId: string, apiKey: string, baseUrl?: string): Promise<void> {\n try {\n await workosRequest({\n method: 'DELETE',\n path: `/organizations/${orgId}`,\n apiKey,\n baseUrl,\n });\n console.log(chalk.green(`Deleted organization ${orgId}`));\n } catch (error) {\n handleApiError(error);\n }\n}\n"]}
@@ -0,0 +1,19 @@
1
+ export declare function runUserGet(userId: string, apiKey: string, baseUrl?: string): Promise<void>;
2
+ export interface UserListOptions {
3
+ email?: string;
4
+ organization?: string;
5
+ limit?: number;
6
+ before?: string;
7
+ after?: string;
8
+ order?: string;
9
+ }
10
+ export declare function runUserList(options: UserListOptions, apiKey: string, baseUrl?: string): Promise<void>;
11
+ export interface UserUpdateOptions {
12
+ firstName?: string;
13
+ lastName?: string;
14
+ emailVerified?: boolean;
15
+ password?: string;
16
+ externalId?: string;
17
+ }
18
+ export declare function runUserUpdate(userId: string, apiKey: string, options: UserUpdateOptions, baseUrl?: string): Promise<void>;
19
+ export declare function runUserDelete(userId: string, apiKey: string, baseUrl?: string): Promise<void>;
@@ -0,0 +1,128 @@
1
+ import chalk from 'chalk';
2
+ import { workosRequest, WorkOSApiError } from '../lib/workos-api.js';
3
+ import { formatTable } from '../utils/table.js';
4
+ function handleApiError(error) {
5
+ if (error instanceof WorkOSApiError) {
6
+ if (error.statusCode === 401) {
7
+ console.error(chalk.red('Invalid API key. Check your environment configuration.'));
8
+ }
9
+ else if (error.statusCode === 404) {
10
+ console.error(chalk.red('User not found.'));
11
+ }
12
+ else if (error.statusCode === 422 && error.errors?.length) {
13
+ console.error(chalk.red(error.errors.map((e) => e.message).join(', ')));
14
+ }
15
+ else {
16
+ console.error(chalk.red(error.message));
17
+ }
18
+ }
19
+ else {
20
+ console.error(chalk.red(error instanceof Error ? error.message : 'Unknown error'));
21
+ }
22
+ process.exit(1);
23
+ }
24
+ export async function runUserGet(userId, apiKey, baseUrl) {
25
+ try {
26
+ const user = await workosRequest({
27
+ method: 'GET',
28
+ path: `/user_management/users/${userId}`,
29
+ apiKey,
30
+ baseUrl,
31
+ });
32
+ console.log(JSON.stringify(user, null, 2));
33
+ }
34
+ catch (error) {
35
+ handleApiError(error);
36
+ }
37
+ }
38
+ export async function runUserList(options, apiKey, baseUrl) {
39
+ try {
40
+ const result = await workosRequest({
41
+ method: 'GET',
42
+ path: '/user_management/users',
43
+ apiKey,
44
+ baseUrl,
45
+ params: {
46
+ email: options.email,
47
+ organization_id: options.organization,
48
+ limit: options.limit,
49
+ before: options.before,
50
+ after: options.after,
51
+ order: options.order,
52
+ },
53
+ });
54
+ if (result.data.length === 0) {
55
+ console.log('No users found.');
56
+ return;
57
+ }
58
+ const rows = result.data.map((user) => [
59
+ user.id,
60
+ user.email,
61
+ user.first_name || chalk.dim('-'),
62
+ user.last_name || chalk.dim('-'),
63
+ user.email_verified ? 'Yes' : 'No',
64
+ ]);
65
+ console.log(formatTable([
66
+ { header: 'ID' },
67
+ { header: 'Email' },
68
+ { header: 'First Name' },
69
+ { header: 'Last Name' },
70
+ { header: 'Verified' },
71
+ ], rows));
72
+ const { before, after } = result.list_metadata;
73
+ if (before && after) {
74
+ console.log(chalk.dim(`Before: ${before} After: ${after}`));
75
+ }
76
+ else if (before) {
77
+ console.log(chalk.dim(`Before: ${before}`));
78
+ }
79
+ else if (after) {
80
+ console.log(chalk.dim(`After: ${after}`));
81
+ }
82
+ }
83
+ catch (error) {
84
+ handleApiError(error);
85
+ }
86
+ }
87
+ export async function runUserUpdate(userId, apiKey, options, baseUrl) {
88
+ const body = {};
89
+ if (options.firstName !== undefined)
90
+ body.first_name = options.firstName;
91
+ if (options.lastName !== undefined)
92
+ body.last_name = options.lastName;
93
+ if (options.emailVerified !== undefined)
94
+ body.email_verified = options.emailVerified;
95
+ if (options.password !== undefined)
96
+ body.password = options.password;
97
+ if (options.externalId !== undefined)
98
+ body.external_id = options.externalId;
99
+ try {
100
+ const user = await workosRequest({
101
+ method: 'PUT',
102
+ path: `/user_management/users/${userId}`,
103
+ apiKey,
104
+ baseUrl,
105
+ body,
106
+ });
107
+ console.log(chalk.green('Updated user'));
108
+ console.log(JSON.stringify(user, null, 2));
109
+ }
110
+ catch (error) {
111
+ handleApiError(error);
112
+ }
113
+ }
114
+ export async function runUserDelete(userId, apiKey, baseUrl) {
115
+ try {
116
+ await workosRequest({
117
+ method: 'DELETE',
118
+ path: `/user_management/users/${userId}`,
119
+ apiKey,
120
+ baseUrl,
121
+ });
122
+ console.log(chalk.green(`Deleted user ${userId}`));
123
+ }
124
+ catch (error) {
125
+ handleApiError(error);
126
+ }
127
+ }
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OAAO,KAAK,EAAE,CAAC;QACf,cAAc,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;AACH,CAAC","sourcesContent":["import chalk from 'chalk';\nimport { workosRequest, WorkOSApiError } from '../lib/workos-api.js';\nimport type { WorkOSListResponse } from '../lib/workos-api.js';\nimport { formatTable } from '../utils/table.js';\n\ninterface User {\n id: string;\n email: string;\n first_name: string;\n last_name: string;\n email_verified: boolean;\n created_at: string;\n updated_at: string;\n}\n\nfunction handleApiError(error: unknown): never {\n if (error instanceof WorkOSApiError) {\n if (error.statusCode === 401) {\n console.error(chalk.red('Invalid API key. Check your environment configuration.'));\n } else if (error.statusCode === 404) {\n console.error(chalk.red('User not found.'));\n } else if (error.statusCode === 422 && error.errors?.length) {\n console.error(chalk.red(error.errors.map((e) => e.message).join(', ')));\n } else {\n console.error(chalk.red(error.message));\n }\n } else {\n console.error(chalk.red(error instanceof Error ? error.message : 'Unknown error'));\n }\n process.exit(1);\n}\n\nexport async function runUserGet(userId: string, apiKey: string, baseUrl?: string): Promise<void> {\n try {\n const user = await workosRequest<User>({\n method: 'GET',\n path: `/user_management/users/${userId}`,\n apiKey,\n baseUrl,\n });\n console.log(JSON.stringify(user, null, 2));\n } catch (error) {\n handleApiError(error);\n }\n}\n\nexport interface UserListOptions {\n email?: string;\n organization?: string;\n limit?: number;\n before?: string;\n after?: string;\n order?: string;\n}\n\nexport async function runUserList(options: UserListOptions, apiKey: string, baseUrl?: string): Promise<void> {\n try {\n const result = await workosRequest<WorkOSListResponse<User>>({\n method: 'GET',\n path: '/user_management/users',\n apiKey,\n baseUrl,\n params: {\n email: options.email,\n organization_id: options.organization,\n limit: options.limit,\n before: options.before,\n after: options.after,\n order: options.order,\n },\n });\n\n if (result.data.length === 0) {\n console.log('No users found.');\n return;\n }\n\n const rows = result.data.map((user) => [\n user.id,\n user.email,\n user.first_name || chalk.dim('-'),\n user.last_name || chalk.dim('-'),\n user.email_verified ? 'Yes' : 'No',\n ]);\n\n console.log(\n formatTable(\n [\n { header: 'ID' },\n { header: 'Email' },\n { header: 'First Name' },\n { header: 'Last Name' },\n { header: 'Verified' },\n ],\n rows,\n ),\n );\n\n const { before, after } = result.list_metadata;\n if (before && after) {\n console.log(chalk.dim(`Before: ${before} After: ${after}`));\n } else if (before) {\n console.log(chalk.dim(`Before: ${before}`));\n } else if (after) {\n console.log(chalk.dim(`After: ${after}`));\n }\n } catch (error) {\n handleApiError(error);\n }\n}\n\nexport interface UserUpdateOptions {\n firstName?: string;\n lastName?: string;\n emailVerified?: boolean;\n password?: string;\n externalId?: string;\n}\n\nexport async function runUserUpdate(\n userId: string,\n apiKey: string,\n options: UserUpdateOptions,\n baseUrl?: string,\n): Promise<void> {\n const body: Record<string, unknown> = {};\n if (options.firstName !== undefined) body.first_name = options.firstName;\n if (options.lastName !== undefined) body.last_name = options.lastName;\n if (options.emailVerified !== undefined) body.email_verified = options.emailVerified;\n if (options.password !== undefined) body.password = options.password;\n if (options.externalId !== undefined) body.external_id = options.externalId;\n\n try {\n const user = await workosRequest<User>({\n method: 'PUT',\n path: `/user_management/users/${userId}`,\n apiKey,\n baseUrl,\n body,\n });\n console.log(chalk.green('Updated user'));\n console.log(JSON.stringify(user, null, 2));\n } catch (error) {\n handleApiError(error);\n }\n}\n\nexport async function runUserDelete(userId: string, apiKey: string, baseUrl?: string): Promise<void> {\n try {\n await workosRequest({\n method: 'DELETE',\n path: `/user_management/users/${userId}`,\n apiKey,\n baseUrl,\n });\n console.log(chalk.green(`Deleted user ${userId}`));\n } catch (error) {\n handleApiError(error);\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { Box, Text, useInput, useApp } from 'ink';
4
+ import { getLockArt } from '../../utils/lock-art.js';
4
5
  export function CompletionView({ success, summary, outputLog }) {
5
6
  const { exit } = useApp();
6
7
  const [scrollOffset, setScrollOffset] = useState(Math.max(0, outputLog.length - 20));
@@ -16,6 +17,9 @@ export function CompletionView({ success, summary, outputLog }) {
16
17
  }
17
18
  });
18
19
  const visibleLines = outputLog.slice(scrollOffset, scrollOffset + 20);
19
- return (_jsxs(Box, { flexDirection: "column", padding: 1, width: "100%", height: "100%", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, color: success ? 'green' : 'red', children: success ? ' Installation Complete' : '✗ Installation Failed' }) }), summary && (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { children: summary }) })), _jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", flexGrow: 1, paddingX: 1, children: [_jsxs(Text, { bold: true, dimColor: true, children: ["Output Log [", scrollOffset + 1, "-", scrollOffset + visibleLines.length, " of ", outputLog.length, "]"] }), visibleLines.map((line, i) => (_jsx(Text, { color: line.isError ? 'red' : line.isStatus ? 'yellow' : undefined, children: line.text }, i)))] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "\u2191/\u2193 to scroll, Enter or Q to exit" }) })] }));
20
+ const expression = success ? 'success' : 'error';
21
+ const lockLines = getLockArt(expression, false);
22
+ const color = success ? 'green' : 'red';
23
+ return (_jsxs(Box, { flexDirection: "column", padding: 1, width: "100%", height: "100%", children: [_jsxs(Box, { marginBottom: 1, children: [_jsx(Box, { flexDirection: "column", marginRight: 2, children: lockLines.map((line, i) => (_jsx(Text, { color: color, children: line }, i))) }), _jsxs(Box, { flexDirection: "column", justifyContent: "center", children: [_jsx(Text, { bold: true, color: color, children: success ? 'WorkOS AuthKit Installed' : 'Installation Failed' }), summary && _jsx(Text, { dimColor: true, children: summary })] })] }), _jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", flexGrow: 1, paddingX: 1, children: [_jsxs(Text, { bold: true, dimColor: true, children: ["Output Log [", scrollOffset + 1, "-", scrollOffset + visibleLines.length, " of ", outputLog.length, "]"] }), visibleLines.map((line, i) => (_jsx(Text, { color: line.isError ? 'red' : line.isStatus ? 'yellow' : undefined, children: line.text }, i)))] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "\u2191/\u2193 to scroll, Enter or Q to exit" }) })] }));
20
24
  }
21
25
  //# sourceMappingURL=CompletionView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CompletionView.js","sourceRoot":"","sources":["../../../src/dashboard/components/CompletionView.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAclD,MAAM,UAAU,cAAc,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAuB;IACjF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC;IAErF,QAAQ,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtB,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,eAAe,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;QACnD,CAAC;aAAM,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YACzB,eAAe,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;QACtE,CAAC;aAAM,IAAI,GAAG,CAAC,MAAM,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YACvC,IAAI,EAAE,CAAC;QACT,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,C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App } from 'ink';\n\ninterface OutputLine {\n text: string;\n isError?: boolean;\n isStatus?: boolean;\n}\n\ninterface CompletionViewProps {\n success: boolean;\n summary?: string;\n outputLog: OutputLine[];\n}\n\nexport function CompletionView({ success, summary, outputLog }: CompletionViewProps): React.ReactElement {\n const { exit } = useApp();\n const [scrollOffset, setScrollOffset] = useState(Math.max(0, outputLog.length - 20));\n\n useInput((input, key) => {\n if (key.upArrow) {\n setScrollOffset((prev) => Math.max(0, prev - 1));\n } else if (key.downArrow) {\n setScrollOffset((prev) => Math.min(outputLog.length - 1, prev + 1));\n } else if (key.return || input === 'q') {\n exit();\n }\n });\n\n const visibleLines = outputLog.slice(scrollOffset, scrollOffset + 20);\n\n return (\n <Box flexDirection=\"column\" padding={1} width=\"100%\" height=\"100%\">\n {/* Header */}\n <Box marginBottom={1}>\n <Text bold color={success ? 'green' : 'red'}>\n {success ? ' Installation Complete' : 'Installation Failed'}\n </Text>\n </Box>\n\n {summary && (\n <Box marginBottom={1}>\n <Text>{summary}</Text>\n </Box>\n )}\n\n {/* Scrollable Log */}\n <Box flexDirection=\"column\" borderStyle=\"round\" borderColor=\"gray\" flexGrow={1} paddingX={1}>\n <Text bold dimColor>\n Output Log [{scrollOffset + 1}-{scrollOffset + visibleLines.length} of {outputLog.length}]\n </Text>\n {visibleLines.map((line, i) => (\n <Text key={i} color={line.isError ? 'red' : line.isStatus ? 'yellow' : undefined}>\n {line.text}\n </Text>\n ))}\n </Box>\n\n {/* Footer */}\n <Box marginTop={1}>\n <Text dimColor>↑/↓ to scroll, Enter or Q to exit</Text>\n </Box>\n </Box>\n );\n}\n"]}
1
+ {"version":3,"file":"CompletionView.js","sourceRoot":"","sources":["../../../src/dashboard/components/CompletionView.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAClD,OAA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AE,CAAC,YACf,KAAC,IAAI,IAAC,QAAQ,kEAAyC,GACnD,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import React, { useState } from 'react';\nimport { Box, Text, useInput, useApp } from 'ink';\nimport { getLockArt, type LockExpression } from '../../utils/lock-art.js';\n\ninterface OutputLine {\n text: string;\n isError?: boolean;\n isStatus?: boolean;\n}\n\ninterface CompletionViewProps {\n success: boolean;\n summary?: string;\n outputLog: OutputLine[];\n}\n\nexport function CompletionView({ success, summary, outputLog }: CompletionViewProps): React.ReactElement {\n const { exit } = useApp();\n const [scrollOffset, setScrollOffset] = useState(Math.max(0, outputLog.length - 20));\n\n useInput((input, key) => {\n if (key.upArrow) {\n setScrollOffset((prev) => Math.max(0, prev - 1));\n } else if (key.downArrow) {\n setScrollOffset((prev) => Math.min(outputLog.length - 1, prev + 1));\n } else if (key.return || input === 'q') {\n exit();\n }\n });\n\n const visibleLines = outputLog.slice(scrollOffset, scrollOffset + 20);\n\n const expression: LockExpression = success ? 'success' : 'error';\n const lockLines = getLockArt(expression, false);\n const color = success ? 'green' : 'red';\n\n return (\n <Box flexDirection=\"column\" padding={1} width=\"100%\" height=\"100%\">\n {/* Lock + Header */}\n <Box marginBottom={1}>\n <Box flexDirection=\"column\" marginRight={2}>\n {lockLines.map((line, i) => (\n <Text key={i} color={color}>\n {line}\n </Text>\n ))}\n </Box>\n <Box flexDirection=\"column\" justifyContent=\"center\">\n <Text bold color={color}>\n {success ? 'WorkOS AuthKit Installed' : 'Installation Failed'}\n </Text>\n {summary && <Text dimColor>{summary}</Text>}\n </Box>\n </Box>\n\n {/* Scrollable Log */}\n <Box flexDirection=\"column\" borderStyle=\"round\" borderColor=\"gray\" flexGrow={1} paddingX={1}>\n <Text bold dimColor>\n Output Log [{scrollOffset + 1}-{scrollOffset + visibleLines.length} of {outputLog.length}]\n </Text>\n {visibleLines.map((line, i) => (\n <Text key={i} color={line.isError ? 'red' : line.isStatus ? 'yellow' : undefined}>\n {line.text}\n </Text>\n ))}\n </Box>\n\n {/* Footer */}\n <Box marginTop={1}>\n <Text dimColor>↑/↓ to scroll, Enter or Q to exit</Text>\n </Box>\n </Box>\n );\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { LanguageInfo, FrameworkInfo, SdkInfo, EnvironmentInfo, Issue } from './types.js';
2
+ export interface AnalysisContext {
3
+ language: LanguageInfo;
4
+ framework: FrameworkInfo;
5
+ sdk: SdkInfo;
6
+ environment: EnvironmentInfo;
7
+ existingIssues: Issue[];
8
+ }
9
+ export declare function buildDoctorPrompt(context: AnalysisContext): string;