workos 0.11.2 → 0.12.0-beta.1

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 (169) hide show
  1. package/README.md +163 -6
  2. package/dist/bin.js +20 -1
  3. package/dist/bin.js.map +1 -1
  4. package/dist/check-coverage.ts +237 -0
  5. package/dist/commands/dev.d.ts +23 -0
  6. package/dist/commands/dev.js +139 -0
  7. package/dist/commands/dev.js.map +1 -0
  8. package/dist/commands/emulate.d.ts +6 -0
  9. package/dist/commands/emulate.js +64 -0
  10. package/dist/commands/emulate.js.map +1 -0
  11. package/dist/emulate/core/id.d.ts +33 -0
  12. package/dist/emulate/core/id.js +58 -0
  13. package/dist/emulate/core/id.js.map +1 -0
  14. package/dist/emulate/core/index.d.ts +8 -0
  15. package/dist/emulate/core/index.js +8 -0
  16. package/dist/emulate/core/index.js.map +1 -0
  17. package/dist/emulate/core/jwt.d.ts +28 -0
  18. package/dist/emulate/core/jwt.js +78 -0
  19. package/dist/emulate/core/jwt.js.map +1 -0
  20. package/dist/emulate/core/middleware/auth.d.ts +18 -0
  21. package/dist/emulate/core/middleware/auth.js +28 -0
  22. package/dist/emulate/core/middleware/auth.js.map +1 -0
  23. package/dist/emulate/core/middleware/error-handler.d.ts +22 -0
  24. package/dist/emulate/core/middleware/error-handler.js +72 -0
  25. package/dist/emulate/core/middleware/error-handler.js.map +1 -0
  26. package/dist/emulate/core/pagination.d.ts +21 -0
  27. package/dist/emulate/core/pagination.js +35 -0
  28. package/dist/emulate/core/pagination.js.map +1 -0
  29. package/dist/emulate/core/plugin.d.ts +15 -0
  30. package/dist/emulate/core/plugin.js +2 -0
  31. package/dist/emulate/core/plugin.js.map +1 -0
  32. package/dist/emulate/core/server.d.ts +17 -0
  33. package/dist/emulate/core/server.js +116 -0
  34. package/dist/emulate/core/server.js.map +1 -0
  35. package/dist/emulate/core/store.d.ts +42 -0
  36. package/dist/emulate/core/store.js +148 -0
  37. package/dist/emulate/core/store.js.map +1 -0
  38. package/dist/emulate/index.d.ts +25 -0
  39. package/dist/emulate/index.js +47 -0
  40. package/dist/emulate/index.js.map +1 -0
  41. package/dist/emulate/workos/entities.d.ts +360 -0
  42. package/dist/emulate/workos/entities.js +2 -0
  43. package/dist/emulate/workos/entities.js.map +1 -0
  44. package/dist/emulate/workos/event-bus.d.ts +12 -0
  45. package/dist/emulate/workos/event-bus.js +45 -0
  46. package/dist/emulate/workos/event-bus.js.map +1 -0
  47. package/dist/emulate/workos/helpers.d.ts +63 -0
  48. package/dist/emulate/workos/helpers.js +518 -0
  49. package/dist/emulate/workos/helpers.js.map +1 -0
  50. package/dist/emulate/workos/index.d.ts +91 -0
  51. package/dist/emulate/workos/index.js +319 -0
  52. package/dist/emulate/workos/index.js.map +1 -0
  53. package/dist/emulate/workos/routes/api-keys.d.ts +2 -0
  54. package/dist/emulate/workos/routes/api-keys.js +35 -0
  55. package/dist/emulate/workos/routes/api-keys.js.map +1 -0
  56. package/dist/emulate/workos/routes/audit-logs.d.ts +2 -0
  57. package/dist/emulate/workos/routes/audit-logs.js +107 -0
  58. package/dist/emulate/workos/routes/audit-logs.js.map +1 -0
  59. package/dist/emulate/workos/routes/auth-challenges.d.ts +2 -0
  60. package/dist/emulate/workos/routes/auth-challenges.js +51 -0
  61. package/dist/emulate/workos/routes/auth-challenges.js.map +1 -0
  62. package/dist/emulate/workos/routes/auth-factors.d.ts +2 -0
  63. package/dist/emulate/workos/routes/auth-factors.js +51 -0
  64. package/dist/emulate/workos/routes/auth-factors.js.map +1 -0
  65. package/dist/emulate/workos/routes/auth.d.ts +2 -0
  66. package/dist/emulate/workos/routes/auth.js +349 -0
  67. package/dist/emulate/workos/routes/auth.js.map +1 -0
  68. package/dist/emulate/workos/routes/authorization-checks.d.ts +10 -0
  69. package/dist/emulate/workos/routes/authorization-checks.js +135 -0
  70. package/dist/emulate/workos/routes/authorization-checks.js.map +1 -0
  71. package/dist/emulate/workos/routes/authorization-org-roles.d.ts +2 -0
  72. package/dist/emulate/workos/routes/authorization-org-roles.js +206 -0
  73. package/dist/emulate/workos/routes/authorization-org-roles.js.map +1 -0
  74. package/dist/emulate/workos/routes/authorization-permissions.d.ts +2 -0
  75. package/dist/emulate/workos/routes/authorization-permissions.js +78 -0
  76. package/dist/emulate/workos/routes/authorization-permissions.js.map +1 -0
  77. package/dist/emulate/workos/routes/authorization-resources.d.ts +2 -0
  78. package/dist/emulate/workos/routes/authorization-resources.js +128 -0
  79. package/dist/emulate/workos/routes/authorization-resources.js.map +1 -0
  80. package/dist/emulate/workos/routes/authorization-roles.d.ts +2 -0
  81. package/dist/emulate/workos/routes/authorization-roles.js +136 -0
  82. package/dist/emulate/workos/routes/authorization-roles.js.map +1 -0
  83. package/dist/emulate/workos/routes/config.d.ts +2 -0
  84. package/dist/emulate/workos/routes/config.js +56 -0
  85. package/dist/emulate/workos/routes/config.js.map +1 -0
  86. package/dist/emulate/workos/routes/connect.d.ts +2 -0
  87. package/dist/emulate/workos/routes/connect.js +69 -0
  88. package/dist/emulate/workos/routes/connect.js.map +1 -0
  89. package/dist/emulate/workos/routes/connections.d.ts +2 -0
  90. package/dist/emulate/workos/routes/connections.js +77 -0
  91. package/dist/emulate/workos/routes/connections.js.map +1 -0
  92. package/dist/emulate/workos/routes/data-integrations.d.ts +2 -0
  93. package/dist/emulate/workos/routes/data-integrations.js +55 -0
  94. package/dist/emulate/workos/routes/data-integrations.js.map +1 -0
  95. package/dist/emulate/workos/routes/directories.d.ts +2 -0
  96. package/dist/emulate/workos/routes/directories.js +106 -0
  97. package/dist/emulate/workos/routes/directories.js.map +1 -0
  98. package/dist/emulate/workos/routes/email-verification.d.ts +2 -0
  99. package/dist/emulate/workos/routes/email-verification.js +49 -0
  100. package/dist/emulate/workos/routes/email-verification.js.map +1 -0
  101. package/dist/emulate/workos/routes/events.d.ts +2 -0
  102. package/dist/emulate/workos/routes/events.js +21 -0
  103. package/dist/emulate/workos/routes/events.js.map +1 -0
  104. package/dist/emulate/workos/routes/feature-flags.d.ts +2 -0
  105. package/dist/emulate/workos/routes/feature-flags.js +131 -0
  106. package/dist/emulate/workos/routes/feature-flags.js.map +1 -0
  107. package/dist/emulate/workos/routes/invitations.d.ts +2 -0
  108. package/dist/emulate/workos/routes/invitations.js +125 -0
  109. package/dist/emulate/workos/routes/invitations.js.map +1 -0
  110. package/dist/emulate/workos/routes/legacy-mfa.d.ts +2 -0
  111. package/dist/emulate/workos/routes/legacy-mfa.js +75 -0
  112. package/dist/emulate/workos/routes/legacy-mfa.js.map +1 -0
  113. package/dist/emulate/workos/routes/magic-auth.d.ts +2 -0
  114. package/dist/emulate/workos/routes/magic-auth.js +32 -0
  115. package/dist/emulate/workos/routes/magic-auth.js.map +1 -0
  116. package/dist/emulate/workos/routes/memberships.d.ts +2 -0
  117. package/dist/emulate/workos/routes/memberships.js +118 -0
  118. package/dist/emulate/workos/routes/memberships.js.map +1 -0
  119. package/dist/emulate/workos/routes/organization-domains.d.ts +2 -0
  120. package/dist/emulate/workos/routes/organization-domains.js +58 -0
  121. package/dist/emulate/workos/routes/organization-domains.js.map +1 -0
  122. package/dist/emulate/workos/routes/organizations.d.ts +2 -0
  123. package/dist/emulate/workos/routes/organizations.js +133 -0
  124. package/dist/emulate/workos/routes/organizations.js.map +1 -0
  125. package/dist/emulate/workos/routes/password-reset.d.ts +2 -0
  126. package/dist/emulate/workos/routes/password-reset.js +61 -0
  127. package/dist/emulate/workos/routes/password-reset.js.map +1 -0
  128. package/dist/emulate/workos/routes/pipes.d.ts +2 -0
  129. package/dist/emulate/workos/routes/pipes.js +86 -0
  130. package/dist/emulate/workos/routes/pipes.js.map +1 -0
  131. package/dist/emulate/workos/routes/portal.d.ts +2 -0
  132. package/dist/emulate/workos/routes/portal.js +18 -0
  133. package/dist/emulate/workos/routes/portal.js.map +1 -0
  134. package/dist/emulate/workos/routes/radar.d.ts +2 -0
  135. package/dist/emulate/workos/routes/radar.js +45 -0
  136. package/dist/emulate/workos/routes/radar.js.map +1 -0
  137. package/dist/emulate/workos/routes/sessions.d.ts +2 -0
  138. package/dist/emulate/workos/routes/sessions.js +51 -0
  139. package/dist/emulate/workos/routes/sessions.js.map +1 -0
  140. package/dist/emulate/workos/routes/sso.d.ts +2 -0
  141. package/dist/emulate/workos/routes/sso.js +160 -0
  142. package/dist/emulate/workos/routes/sso.js.map +1 -0
  143. package/dist/emulate/workos/routes/user-features.d.ts +2 -0
  144. package/dist/emulate/workos/routes/user-features.js +50 -0
  145. package/dist/emulate/workos/routes/user-features.js.map +1 -0
  146. package/dist/emulate/workos/routes/users.d.ts +2 -0
  147. package/dist/emulate/workos/routes/users.js +133 -0
  148. package/dist/emulate/workos/routes/users.js.map +1 -0
  149. package/dist/emulate/workos/routes/webhook-endpoints.d.ts +2 -0
  150. package/dist/emulate/workos/routes/webhook-endpoints.js +70 -0
  151. package/dist/emulate/workos/routes/webhook-endpoints.js.map +1 -0
  152. package/dist/emulate/workos/routes/widgets.d.ts +2 -0
  153. package/dist/emulate/workos/routes/widgets.js +27 -0
  154. package/dist/emulate/workos/routes/widgets.js.map +1 -0
  155. package/dist/emulate/workos/store.d.ts +48 -0
  156. package/dist/emulate/workos/store.js +93 -0
  157. package/dist/emulate/workos/store.js.map +1 -0
  158. package/dist/emulate/workos/webhook-signer.d.ts +1 -0
  159. package/dist/emulate/workos/webhook-signer.js +8 -0
  160. package/dist/emulate/workos/webhook-signer.js.map +1 -0
  161. package/dist/gen-routes-lib.spec.ts +659 -0
  162. package/dist/gen-routes-lib.ts +647 -0
  163. package/dist/gen-routes.ts +96 -0
  164. package/dist/lib/dev-command.d.ts +26 -0
  165. package/dist/lib/dev-command.js +122 -0
  166. package/dist/lib/dev-command.js.map +1 -0
  167. package/dist/utils/help-json.js +23 -0
  168. package/dist/utils/help-json.js.map +1 -1
  169. package/package.json +20 -7
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env tsx
2
+ /**
3
+ * Codegen script: reads a WorkOS OpenAPI spec and generates emulator TypeScript
4
+ * files (entities, store, helpers, route stubs).
5
+ *
6
+ * Usage:
7
+ * pnpm gen:routes path/to/openapi.yaml [--out-dir src/emulate/workos/generated]
8
+ * pnpm gen:routes path/to/openapi.json --dry-run
9
+ *
10
+ * The generated code matches the hand-written patterns in src/emulate/workos/.
11
+ * Running twice on the same spec produces identical output (idempotent).
12
+ */
13
+
14
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
15
+ import { resolve, extname, join } from 'node:path';
16
+ import YAML from 'yaml';
17
+
18
+ import {
19
+ type OpenAPISpec,
20
+ parseSpec,
21
+ generateEntities,
22
+ generateStore,
23
+ generateHelpers,
24
+ generateRoutes,
25
+ } from './gen-routes-lib.js';
26
+
27
+ function main(): void {
28
+ const args = process.argv.slice(2);
29
+ const flags = args.filter((a) => a.startsWith('--'));
30
+ const positional = args.filter((a) => !a.startsWith('--'));
31
+
32
+ const specPath = positional[0];
33
+ if (!specPath) {
34
+ console.error('Usage: gen-routes <openapi-spec> [--out-dir <dir>] [--dry-run]');
35
+ process.exit(1);
36
+ }
37
+
38
+ const dryRun = flags.includes('--dry-run');
39
+ const outDirIdx = args.indexOf('--out-dir');
40
+ const outDir = outDirIdx !== -1 ? args[outDirIdx + 1] : 'src/emulate/workos/generated';
41
+
42
+ const resolvedSpec = resolve(specPath);
43
+ if (!existsSync(resolvedSpec)) {
44
+ console.error(`Spec file not found: ${resolvedSpec}`);
45
+ process.exit(1);
46
+ }
47
+
48
+ const raw = readFileSync(resolvedSpec, 'utf-8');
49
+ const ext = extname(resolvedSpec).toLowerCase();
50
+ let spec: OpenAPISpec;
51
+
52
+ if (ext === '.yaml' || ext === '.yml') {
53
+ spec = YAML.parse(raw) as OpenAPISpec;
54
+ } else {
55
+ spec = JSON.parse(raw) as OpenAPISpec;
56
+ }
57
+
58
+ const parsed = parseSpec(spec);
59
+ const output = generateAll(parsed);
60
+
61
+ if (dryRun) {
62
+ for (const [filename, content] of Object.entries(output)) {
63
+ console.log(`--- ${filename} ---`);
64
+ console.log(content);
65
+ console.log('');
66
+ }
67
+ return;
68
+ }
69
+
70
+ const resolvedOutDir = resolve(outDir);
71
+ mkdirSync(resolvedOutDir, { recursive: true });
72
+
73
+ for (const [filename, content] of Object.entries(output)) {
74
+ const filePath = join(resolvedOutDir, filename);
75
+ writeFileSync(filePath, content, 'utf-8');
76
+ console.log(` wrote ${filePath}`);
77
+ }
78
+
79
+ console.log(`\nGenerated ${Object.keys(output).length} files in ${resolvedOutDir}`);
80
+ }
81
+
82
+ function generateAll(parsed: ReturnType<typeof parseSpec>): Record<string, string> {
83
+ const output: Record<string, string> = {};
84
+
85
+ output['entities.ts'] = generateEntities(parsed.entities);
86
+ output['store.ts'] = generateStore(parsed.entities);
87
+ output['helpers.ts'] = generateHelpers(parsed.entities);
88
+
89
+ for (const route of parsed.routes) {
90
+ output[`routes/${route.filename}`] = generateRoutes(route);
91
+ }
92
+
93
+ return output;
94
+ }
95
+
96
+ main();
@@ -0,0 +1,26 @@
1
+ export interface DevCommandResult {
2
+ command: string;
3
+ args: string[];
4
+ framework: string | null;
5
+ }
6
+ interface PackageJson {
7
+ scripts?: Record<string, string>;
8
+ dependencies?: Record<string, string>;
9
+ devDependencies?: Record<string, string>;
10
+ }
11
+ declare function readPackageJson(projectDir: string): PackageJson | null;
12
+ /**
13
+ * Resolve the dev command for a project directory.
14
+ *
15
+ * Priority:
16
+ * 1. `scripts.dev` from package.json (developer's config is authoritative)
17
+ * 2. Framework-specific default based on dependency detection
18
+ * 3. Non-JS framework detection (Django, Rails, Go)
19
+ * 4. Error — no dev command could be resolved
20
+ */
21
+ export declare function resolveDevCommand(projectDir: string): Promise<DevCommandResult>;
22
+ /**
23
+ * Detect the package manager used in the project.
24
+ */
25
+ declare function detectPackageManager(projectDir: string): string;
26
+ export { readPackageJson as _readPackageJson, detectPackageManager as _detectPackageManager };
@@ -0,0 +1,122 @@
1
+ import { readFileSync, existsSync } from 'node:fs';
2
+ import { resolve, join } from 'node:path';
3
+ /**
4
+ * Framework-to-dev-command mapping. Checked in order after package.json detection.
5
+ * Each entry maps a dependency name to a framework display name and default dev command.
6
+ */
7
+ const FRAMEWORK_DEV_COMMANDS = [
8
+ { dep: 'next', framework: 'Next.js', command: 'next', args: ['dev'] },
9
+ { dep: '@remix-run/dev', framework: 'Remix', command: 'remix', args: ['dev'] },
10
+ { dep: 'react-router', framework: 'React Router', command: 'react-router', args: ['dev'] },
11
+ { dep: '@tanstack/react-start', framework: 'TanStack Start', command: 'vinxi', args: ['dev'] },
12
+ { dep: '@sveltejs/kit', framework: 'SvelteKit', command: 'vite', args: ['dev'] },
13
+ { dep: 'vite', framework: 'Vite', command: 'vite', args: ['dev'] },
14
+ { dep: 'nuxt', framework: 'Nuxt', command: 'nuxt', args: ['dev'] },
15
+ { dep: 'express', framework: 'Express', command: 'node', args: ['index.js'] },
16
+ ];
17
+ /**
18
+ * Non-JS framework detection: checks for well-known files in the project directory.
19
+ */
20
+ const NON_JS_FRAMEWORKS = [
21
+ { file: 'manage.py', framework: 'Django', command: 'python', args: ['manage.py', 'runserver'] },
22
+ { file: 'Gemfile', framework: 'Rails', command: 'rails', args: ['server'] },
23
+ { file: 'go.mod', framework: 'Go', command: 'go', args: ['run', '.'] },
24
+ ];
25
+ function readPackageJson(projectDir) {
26
+ const pkgPath = resolve(projectDir, 'package.json');
27
+ if (!existsSync(pkgPath))
28
+ return null;
29
+ try {
30
+ return JSON.parse(readFileSync(pkgPath, 'utf-8'));
31
+ }
32
+ catch {
33
+ return null;
34
+ }
35
+ }
36
+ function hasDependency(pkg, dep) {
37
+ return !!(pkg.dependencies?.[dep] || pkg.devDependencies?.[dep]);
38
+ }
39
+ /**
40
+ * Resolve the npx-style command for a given binary.
41
+ * Returns the binary path under node_modules/.bin if it exists,
42
+ * otherwise returns the bare command name (assumes it's globally available).
43
+ */
44
+ function resolveNodeBin(projectDir, command) {
45
+ const binPath = join(projectDir, 'node_modules', '.bin', command);
46
+ if (existsSync(binPath))
47
+ return binPath;
48
+ return command;
49
+ }
50
+ /**
51
+ * Resolve the dev command for a project directory.
52
+ *
53
+ * Priority:
54
+ * 1. `scripts.dev` from package.json (developer's config is authoritative)
55
+ * 2. Framework-specific default based on dependency detection
56
+ * 3. Non-JS framework detection (Django, Rails, Go)
57
+ * 4. Error — no dev command could be resolved
58
+ */
59
+ export async function resolveDevCommand(projectDir) {
60
+ const pkg = readPackageJson(projectDir);
61
+ if (pkg) {
62
+ // Detect framework from dependencies first (for display purposes)
63
+ let detectedFramework = null;
64
+ for (const entry of FRAMEWORK_DEV_COMMANDS) {
65
+ if (hasDependency(pkg, entry.dep)) {
66
+ detectedFramework = entry.framework;
67
+ break;
68
+ }
69
+ }
70
+ // Priority 1: scripts.dev from package.json
71
+ if (pkg.scripts?.dev) {
72
+ // Use the package manager's run command to execute scripts.dev
73
+ const packageManager = detectPackageManager(projectDir);
74
+ return {
75
+ command: packageManager,
76
+ args: ['run', 'dev'],
77
+ framework: detectedFramework,
78
+ };
79
+ }
80
+ // Priority 2: Framework-specific default
81
+ for (const entry of FRAMEWORK_DEV_COMMANDS) {
82
+ if (hasDependency(pkg, entry.dep)) {
83
+ return {
84
+ command: resolveNodeBin(projectDir, entry.command),
85
+ args: entry.args,
86
+ framework: entry.framework,
87
+ };
88
+ }
89
+ }
90
+ }
91
+ // Priority 3: Non-JS frameworks
92
+ for (const entry of NON_JS_FRAMEWORKS) {
93
+ if (existsSync(resolve(projectDir, entry.file))) {
94
+ return {
95
+ command: entry.command,
96
+ args: entry.args,
97
+ framework: entry.framework,
98
+ };
99
+ }
100
+ }
101
+ // No framework or scripts.dev found
102
+ return {
103
+ command: 'npm',
104
+ args: ['run', 'dev'],
105
+ framework: null,
106
+ };
107
+ }
108
+ /**
109
+ * Detect the package manager used in the project.
110
+ */
111
+ function detectPackageManager(projectDir) {
112
+ if (existsSync(resolve(projectDir, 'pnpm-lock.yaml')))
113
+ return 'pnpm';
114
+ if (existsSync(resolve(projectDir, 'yarn.lock')))
115
+ return 'yarn';
116
+ if (existsSync(resolve(projectDir, 'bun.lockb')) || existsSync(resolve(projectDir, 'bun.lock')))
117
+ return 'bun';
118
+ return 'npm';
119
+ }
120
+ // Export for testing
121
+ export { readPackageJson as _readPackageJson, detectPackageManager as _detectPackageManager };
122
+ //# sourceMappingURL=dev-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-command.js","sourceRoot":"","sources":["../../src/lib/dev-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAc1C;;;GAGG;AACH,MAAM,sBAAsB,GAKvB;IACH,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE;IACrE,EAAE,GAAG,EAAE,gBAAgB,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE;IAC9E,EAAE,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE;IAC1F,EAAE,GAAG,EAAE,uBAAuB,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE;IAC9F,EAAE,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE;IAChF,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE;IAClE,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,E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AK,IAAI,iBAAiB,EAAE,CAAC;QACtC,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAChD,OAAO;gBACL,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,SAAS,EAAE,KAAK,CAAC,SAAS;aAC3B,CAAC;QACJ,CAAC;IACH,CAAC;IAED,oCAAoC;IACpC,OAAO;QACL,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;QACpB,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,oBAAoB,CAAC,UAAkB;IAC9C,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC;IACrE,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAAE,OAAO,MAAM,CAAC;IAChE,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9G,OAAO,KAAK,CAAC;AACf,CAAC;AAED,qBAAqB;AACrB,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,oBAAoB,IAAI,qBAAqB,EAAE,CAAC","sourcesContent":["import { readFileSync, existsSync } from 'node:fs';\nimport { resolve, join } from 'node:path';\n\nexport interface DevCommandResult {\n command: string;\n args: string[];\n framework: string | null;\n}\n\ninterface PackageJson {\n scripts?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n}\n\n/**\n * Framework-to-dev-command mapping. Checked in order after package.json detection.\n * Each entry maps a dependency name to a framework display name and default dev command.\n */\nconst FRAMEWORK_DEV_COMMANDS: Array<{\n dep: string;\n framework: string;\n command: string;\n args: string[];\n}> = [\n { dep: 'next', framework: 'Next.js', command: 'next', args: ['dev'] },\n { dep: '@remix-run/dev', framework: 'Remix', command: 'remix', args: ['dev'] },\n { dep: 'react-router', framework: 'React Router', command: 'react-router', args: ['dev'] },\n { dep: '@tanstack/react-start', framework: 'TanStack Start', command: 'vinxi', args: ['dev'] },\n { dep: '@sveltejs/kit', framework: 'SvelteKit', command: 'vite', args: ['dev'] },\n { dep: 'vite', framework: 'Vite', command: 'vite', args: ['dev'] },\n { dep: 'nuxt', framework: 'Nuxt', command: 'nuxt', args: ['dev'] },\n { dep: 'express', framework: 'Express', command: 'node', args: ['index.js'] },\n];\n\n/**\n * Non-JS framework detection: checks for well-known files in the project directory.\n */\nconst NON_JS_FRAMEWORKS: Array<{\n file: string;\n framework: string;\n command: string;\n args: string[];\n}> = [\n { file: 'manage.py', framework: 'Django', command: 'python', args: ['manage.py', 'runserver'] },\n { file: 'Gemfile', framework: 'Rails', command: 'rails', args: ['server'] },\n { file: 'go.mod', framework: 'Go', command: 'go', args: ['run', '.'] },\n];\n\nfunction readPackageJson(projectDir: string): PackageJson | null {\n const pkgPath = resolve(projectDir, 'package.json');\n if (!existsSync(pkgPath)) return null;\n try {\n return JSON.parse(readFileSync(pkgPath, 'utf-8')) as PackageJson;\n } catch {\n return null;\n }\n}\n\nfunction hasDependency(pkg: PackageJson, dep: string): boolean {\n return !!(pkg.dependencies?.[dep] || pkg.devDependencies?.[dep]);\n}\n\n/**\n * Resolve the npx-style command for a given binary.\n * Returns the binary path under node_modules/.bin if it exists,\n * otherwise returns the bare command name (assumes it's globally available).\n */\nfunction resolveNodeBin(projectDir: string, command: string): string {\n const binPath = join(projectDir, 'node_modules', '.bin', command);\n if (existsSync(binPath)) return binPath;\n return command;\n}\n\n/**\n * Resolve the dev command for a project directory.\n *\n * Priority:\n * 1. `scripts.dev` from package.json (developer's config is authoritative)\n * 2. Framework-specific default based on dependency detection\n * 3. Non-JS framework detection (Django, Rails, Go)\n * 4. Error — no dev command could be resolved\n */\nexport async function resolveDevCommand(projectDir: string): Promise<DevCommandResult> {\n const pkg = readPackageJson(projectDir);\n\n if (pkg) {\n // Detect framework from dependencies first (for display purposes)\n let detectedFramework: string | null = null;\n for (const entry of FRAMEWORK_DEV_COMMANDS) {\n if (hasDependency(pkg, entry.dep)) {\n detectedFramework = entry.framework;\n break;\n }\n }\n\n // Priority 1: scripts.dev from package.json\n if (pkg.scripts?.dev) {\n // Use the package manager's run command to execute scripts.dev\n const packageManager = detectPackageManager(projectDir);\n return {\n command: packageManager,\n args: ['run', 'dev'],\n framework: detectedFramework,\n };\n }\n\n // Priority 2: Framework-specific default\n for (const entry of FRAMEWORK_DEV_COMMANDS) {\n if (hasDependency(pkg, entry.dep)) {\n return {\n command: resolveNodeBin(projectDir, entry.command),\n args: entry.args,\n framework: entry.framework,\n };\n }\n }\n }\n\n // Priority 3: Non-JS frameworks\n for (const entry of NON_JS_FRAMEWORKS) {\n if (existsSync(resolve(projectDir, entry.file))) {\n return {\n command: entry.command,\n args: entry.args,\n framework: entry.framework,\n };\n }\n }\n\n // No framework or scripts.dev found\n return {\n command: 'npm',\n args: ['run', 'dev'],\n framework: null,\n };\n}\n\n/**\n * Detect the package manager used in the project.\n */\nfunction detectPackageManager(projectDir: string): string {\n if (existsSync(resolve(projectDir, 'pnpm-lock.yaml'))) return 'pnpm';\n if (existsSync(resolve(projectDir, 'yarn.lock'))) return 'yarn';\n if (existsSync(resolve(projectDir, 'bun.lockb')) || existsSync(resolve(projectDir, 'bun.lock'))) return 'bun';\n return 'npm';\n}\n\n// Export for testing\nexport { readPackageJson as _readPackageJson, detectPackageManager as _detectPackageManager };\n"]}
@@ -1006,6 +1006,29 @@ const commands = [
1006
1006
  },
1007
1007
  ],
1008
1008
  },
1009
+ // --- Emulator ---
1010
+ {
1011
+ name: 'emulate',
1012
+ description: 'Start a local WorkOS API emulator',
1013
+ options: [
1014
+ { name: 'port', type: 'number', description: 'Port to listen on', required: false, default: 4100, hidden: false },
1015
+ {
1016
+ name: 'seed',
1017
+ type: 'string',
1018
+ description: 'Path to seed config file (YAML or JSON)',
1019
+ required: false,
1020
+ hidden: false,
1021
+ },
1022
+ ],
1023
+ },
1024
+ {
1025
+ name: 'dev',
1026
+ description: 'Start emulator + your app in one command',
1027
+ options: [
1028
+ { name: 'port', type: 'number', description: 'Emulator port', required: false, default: 4100, hidden: false },
1029
+ { name: 'seed', type: 'string', description: 'Path to seed config file', required: false, hidden: false },
1030
+ ],
1031
+ },
1009
1032
  // --- Workflow Commands ---
1010
1033
  {
1011
1034
  name: 'seed',