everything-dev 1.8.13 → 1.9.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 (60) hide show
  1. package/dist/api-contract.cjs +53 -15
  2. package/dist/api-contract.cjs.map +1 -1
  3. package/dist/api-contract.mjs +53 -15
  4. package/dist/api-contract.mjs.map +1 -1
  5. package/dist/cli/init.cjs +7 -7
  6. package/dist/cli/init.cjs.map +1 -1
  7. package/dist/cli/init.d.cts.map +1 -1
  8. package/dist/cli/init.d.mts.map +1 -1
  9. package/dist/cli/init.mjs +7 -7
  10. package/dist/cli/init.mjs.map +1 -1
  11. package/dist/cli.cjs +46 -0
  12. package/dist/cli.cjs.map +1 -1
  13. package/dist/cli.mjs +46 -0
  14. package/dist/cli.mjs.map +1 -1
  15. package/dist/contract.cjs +20 -1
  16. package/dist/contract.cjs.map +1 -1
  17. package/dist/contract.d.cts +46 -1
  18. package/dist/contract.d.cts.map +1 -1
  19. package/dist/contract.d.mts +46 -1
  20. package/dist/contract.d.mts.map +1 -1
  21. package/dist/contract.meta.cjs +9 -0
  22. package/dist/contract.meta.cjs.map +1 -1
  23. package/dist/contract.meta.d.cts +13 -0
  24. package/dist/contract.meta.d.mts +13 -0
  25. package/dist/contract.meta.mjs +9 -0
  26. package/dist/contract.meta.mjs.map +1 -1
  27. package/dist/contract.mjs +19 -2
  28. package/dist/contract.mjs.map +1 -1
  29. package/dist/index.cjs +2 -0
  30. package/dist/index.d.cts +2 -2
  31. package/dist/index.d.mts +2 -2
  32. package/dist/index.mjs +2 -2
  33. package/dist/orchestrator.cjs +0 -1
  34. package/dist/orchestrator.cjs.map +1 -1
  35. package/dist/orchestrator.d.cts.map +1 -1
  36. package/dist/orchestrator.d.mts.map +1 -1
  37. package/dist/orchestrator.mjs +0 -1
  38. package/dist/orchestrator.mjs.map +1 -1
  39. package/dist/plugin.cjs +81 -3
  40. package/dist/plugin.cjs.map +1 -1
  41. package/dist/plugin.d.cts +22 -1
  42. package/dist/plugin.d.cts.map +1 -1
  43. package/dist/plugin.d.mts +22 -1
  44. package/dist/plugin.d.mts.map +1 -1
  45. package/dist/plugin.mjs +81 -3
  46. package/dist/plugin.mjs.map +1 -1
  47. package/dist/service-descriptor.d.cts +1 -1
  48. package/dist/service-descriptor.d.mts +1 -1
  49. package/dist/types.d.cts +2 -2
  50. package/dist/types.d.mts +2 -2
  51. package/package.json +1 -1
  52. package/skills/dev-workflow/SKILL.md +3 -3
  53. package/src/api-contract.ts +95 -22
  54. package/src/cli/init.ts +8 -11
  55. package/src/cli.ts +62 -0
  56. package/src/contract.meta.ts +9 -0
  57. package/src/contract.ts +21 -0
  58. package/src/orchestrator.ts +0 -19
  59. package/src/plugin.ts +117 -3
  60. package/src/scripts/sync-api-contract.ts +0 -24
@@ -22,6 +22,11 @@ export interface ApiPluginManifest {
22
22
  sha256?: string;
23
23
  };
24
24
  };
25
+ additionalExports?: Array<{
26
+ path: string;
27
+ exports: string[];
28
+ sha256?: string;
29
+ }>;
25
30
  }
26
31
 
27
32
  interface ContractSource {
@@ -136,6 +141,51 @@ async function remoteContractSource(opts: {
136
141
  };
137
142
  }
138
143
 
144
+ async function fetchAuthExportTypes(opts: {
145
+ baseUrl: string;
146
+ runtimeDir: string;
147
+ manifest: ApiPluginManifest;
148
+ }): Promise<string | null> {
149
+ if (!opts.manifest.additionalExports || opts.manifest.additionalExports.length === 0) {
150
+ return null;
151
+ }
152
+
153
+ const authExportEntry = opts.manifest.additionalExports.find(
154
+ (entry) => entry.path.includes("auth-export") || entry.path.endsWith("auth-export.d.ts"),
155
+ );
156
+
157
+ if (!authExportEntry) {
158
+ return null;
159
+ }
160
+
161
+ const exportUrl = `${trimTrailingSlash(opts.baseUrl)}/${authExportEntry.path.replace(/^\.\//, "")}`;
162
+ const response = await fetch(exportUrl);
163
+ if (!response.ok) {
164
+ console.warn(`[API Contract] Failed to fetch auth export types: ${response.status}`);
165
+ return null;
166
+ }
167
+
168
+ const content = await response.text();
169
+ if (authExportEntry.sha256 && authExportEntry.sha256 !== sha256(content)) {
170
+ console.warn("[API Contract] Auth export types checksum mismatch");
171
+ return null;
172
+ }
173
+
174
+ const generatedPath = join(opts.runtimeDir, "auth", "auth-export.d.ts");
175
+ mkdirSync(dirname(generatedPath), { recursive: true });
176
+ writeFileIfChanged(generatedPath, content);
177
+
178
+ return generatedPath;
179
+ }
180
+
181
+ function writeAuthTypesGen(configDir: string, authExportPath: string) {
182
+ const authTypesPath = join(configDir, "ui", "src", "auth-types.gen.ts");
183
+ const importPath = toImportPath(authTypesPath, authExportPath);
184
+ const content = `export type { createAuthInstance } from "${importPath}";\n`;
185
+ mkdirSync(dirname(authTypesPath), { recursive: true });
186
+ writeFileIfChanged(authTypesPath, content);
187
+ }
188
+
139
189
  async function resolveContractSource(opts: {
140
190
  configDir: string;
141
191
  runtimeDir: string;
@@ -202,6 +252,7 @@ function writeGeneratedFiles(opts: {
202
252
  sources: ContractSource[];
203
253
  pluginKeys: string[];
204
254
  authSource: ContractSource | null;
255
+ authExportPath?: string | null;
205
256
  }) {
206
257
  const baseSource = opts.sources.find((source) => source.key === "api");
207
258
  const pluginSources = opts.pluginKeys
@@ -245,6 +296,7 @@ function writeGeneratedFiles(opts: {
245
296
  writeFileIfChanged(uiContractPath, `${uiLines.join("\n")}\n`);
246
297
 
247
298
  // --- Generate api/src/plugins-client.gen.ts ---
299
+ // Includes both plugin contracts AND auth as a unified PluginsClient type
248
300
  const pluginsClientPath = join(opts.configDir, "api", "src", "plugins-client.gen.ts");
249
301
  const pluginsClientLines: string[] = [];
250
302
 
@@ -255,6 +307,13 @@ function writeGeneratedFiles(opts: {
255
307
  );
256
308
  }
257
309
 
310
+ if (opts.authSource) {
311
+ const authImportPath = toImportPath(pluginsClientPath, opts.authSource.sourceFilePath);
312
+ pluginsClientLines.push(
313
+ `import type { ContractType as ${opts.authSource.importName} } from "${authImportPath}";`,
314
+ );
315
+ }
316
+
258
317
  pluginsClientLines.push(
259
318
  'import type { ContractRouterClient, AnyContractRouter } from "@orpc/contract";',
260
319
  );
@@ -263,11 +322,16 @@ function writeGeneratedFiles(opts: {
263
322
  );
264
323
  pluginsClientLines.push("");
265
324
 
266
- if (pluginSources.length === 0) {
325
+ const allPluginSources = [...pluginSources];
326
+ if (opts.authSource) {
327
+ allPluginSources.push({ ...opts.authSource, key: "auth" });
328
+ }
329
+
330
+ if (allPluginSources.length === 0) {
267
331
  pluginsClientLines.push("export type PluginsClient = Record<string, never>;");
268
332
  } else {
269
333
  pluginsClientLines.push("export type PluginsClient = {");
270
- for (const source of pluginSources) {
334
+ for (const source of allPluginSources) {
271
335
  const key = /^[$A-Z_][0-9A-Z_$]*$/i.test(source.key)
272
336
  ? source.key
273
337
  : JSON.stringify(source.key);
@@ -279,26 +343,9 @@ function writeGeneratedFiles(opts: {
279
343
  mkdirSync(dirname(pluginsClientPath), { recursive: true });
280
344
  writeFileIfChanged(pluginsClientPath, `${pluginsClientLines.join("\n")}\n`);
281
345
 
282
- // --- Generate api/src/auth-client.gen.ts ---
283
- if (opts.authSource) {
284
- const authClientPath = join(opts.configDir, "api", "src", "auth-client.gen.ts");
285
- const authClientLines: string[] = [];
286
-
287
- const importPath = toImportPath(authClientPath, opts.authSource.sourceFilePath);
288
- authClientLines.push(
289
- `import type { ContractType as ${opts.authSource.importName} } from "${importPath}";`,
290
- );
291
- authClientLines.push(
292
- 'import type { ContractRouterClient, AnyContractRouter } from "@orpc/contract";',
293
- );
294
- authClientLines.push(
295
- "type ClientFactory<C extends AnyContractRouter> = (context?: Record<string, unknown>) => ContractRouterClient<C>;",
296
- );
297
- authClientLines.push("");
298
- authClientLines.push(`export type AuthClient = ClientFactory<${opts.authSource.importName}>;`);
299
-
300
- mkdirSync(dirname(authClientPath), { recursive: true });
301
- writeFileIfChanged(authClientPath, `${authClientLines.join("\n")}\n`);
346
+ // --- Generate ui/src/auth-types.gen.ts ---
347
+ if (opts.authExportPath) {
348
+ writeAuthTypesGen(opts.configDir, opts.authExportPath);
302
349
  }
303
350
 
304
351
  return uiContractPath;
@@ -322,6 +369,7 @@ export async function syncApiContractBridge(opts: {
322
369
  let manifest: ApiPluginManifest | null = null;
323
370
  let generatedPath: string | null = null;
324
371
  let authSource: ContractSource | null = null;
372
+ let authExportPath: string | null = null;
325
373
 
326
374
  const baseSource = await resolveContractSource({
327
375
  configDir: opts.configDir,
@@ -347,6 +395,30 @@ export async function syncApiContractBridge(opts: {
347
395
  if (authSource.generatedPath) {
348
396
  generatedPath = authSource.generatedPath;
349
397
  }
398
+
399
+ // Fetch auth additional exports (auth-export.d.ts) for remote auth
400
+ if (opts.runtimeConfig.auth.url && opts.runtimeConfig.auth.source !== "local") {
401
+ try {
402
+ const authManifest = await fetchApiPluginManifest(opts.runtimeConfig.auth.url);
403
+ const fetchedAuthExportPath = await fetchAuthExportTypes({
404
+ baseUrl: opts.runtimeConfig.auth.url,
405
+ runtimeDir,
406
+ manifest: authManifest,
407
+ });
408
+ if (fetchedAuthExportPath) {
409
+ authExportPath = fetchedAuthExportPath;
410
+ }
411
+ } catch (error) {
412
+ console.warn(
413
+ `[API Contract] Failed to fetch auth additional exports: ${error instanceof Error ? error.message : String(error)}`,
414
+ );
415
+ }
416
+ }
417
+
418
+ // Fallback to local auth export source if remote fetch failed or auth is local
419
+ if (!authExportPath) {
420
+ authExportPath = join(opts.configDir, "plugins", "auth", "src", "auth-export.ts");
421
+ }
350
422
  }
351
423
 
352
424
  for (const [key, plugin] of pluginEntries) {
@@ -377,6 +449,7 @@ export async function syncApiContractBridge(opts: {
377
449
  sources,
378
450
  pluginKeys: allPluginKeys,
379
451
  authSource,
452
+ authExportPath,
380
453
  });
381
454
 
382
455
  if (opts.runtimeConfig.api.source !== "local") {
package/src/cli/init.ts CHANGED
@@ -399,11 +399,11 @@ export async function personalizeConfig(
399
399
  rewrite("start", "packages/everything-dev/cli.js", "node_modules/.bin/bos");
400
400
 
401
401
  if (scripts.postinstall) {
402
- delete scripts.postinstall;
402
+ scripts.postinstall = "bos types gen";
403
403
  }
404
404
  if (scripts.typecheck) {
405
405
  scripts.typecheck = scripts.typecheck
406
- .replace("bun run sync:api-contract && ", "")
406
+ .replace("bun run types:gen && ", "")
407
407
  .replace(/bun run --cwd packages\/everything-dev typecheck & ?/, "");
408
408
  if (!opts.withHost) {
409
409
  scripts.typecheck = scripts.typecheck.replace(/bun run --cwd host tsc --noEmit & ?/, "");
@@ -456,15 +456,6 @@ export async function personalizeConfig(
456
456
  writeFileSync(genContractPath, `export type ApiContract = Record<string, never>;\n`);
457
457
  }
458
458
 
459
- const authClientGenPath = join(destination, "api", "src", "auth-client.gen.ts");
460
- if (!existsSync(authClientGenPath)) {
461
- mkdirSync(dirname(authClientGenPath), { recursive: true });
462
- writeFileSync(
463
- authClientGenPath,
464
- `import type { ContractRouterClient, AnyContractRouter } from "@orpc/contract";\ntype ClientFactory<C extends AnyContractRouter> = (context?: Record<string, unknown>) => ContractRouterClient<C>;\nexport type AuthClient = ClientFactory<any>;\n`,
465
- );
466
- }
467
-
468
459
  const pluginsClientGenPath = join(destination, "api", "src", "plugins-client.gen.ts");
469
460
  if (!existsSync(pluginsClientGenPath)) {
470
461
  mkdirSync(dirname(pluginsClientGenPath), { recursive: true });
@@ -473,6 +464,12 @@ export async function personalizeConfig(
473
464
  `import type { ContractRouterClient, AnyContractRouter } from "@orpc/contract";\ntype ClientFactory<C extends AnyContractRouter> = (context?: Record<string, unknown>) => ContractRouterClient<C>;\nexport type PluginsClient = Record<string, never>;\n`,
474
465
  );
475
466
  }
467
+
468
+ const authTypesGenPath = join(destination, "ui", "src", "auth-types.gen.ts");
469
+ if (!existsSync(authTypesGenPath)) {
470
+ mkdirSync(dirname(authTypesGenPath), { recursive: true });
471
+ writeFileSync(authTypesGenPath, `export type { createAuthInstance } from "better-auth";\n`);
472
+ }
476
473
  }
477
474
 
478
475
  export async function runBunInstall(destination: string): Promise<void> {
package/src/cli.ts CHANGED
@@ -46,6 +46,34 @@ function formatTimeAgo(isoTimestamp: string): string {
46
46
  return isoTimestamp.split("T")[0] ?? isoTimestamp;
47
47
  }
48
48
 
49
+ async function warnIfOutdated(client: any, command: string): Promise<void> {
50
+ if (!["dev", "build", "start"].includes(command)) return;
51
+
52
+ try {
53
+ const status = await client.status();
54
+ if (status.status === "error" || !status.packages) return;
55
+
56
+ const outdated = status.packages.filter(
57
+ (p: { name: string; installed?: string; latest?: string }) =>
58
+ p.installed && p.latest && p.installed !== p.latest,
59
+ );
60
+
61
+ if (outdated.length === 0) return;
62
+
63
+ console.log();
64
+ console.log(colors.yellow(` ! Outdated packages detected:`));
65
+ for (const pkg of outdated) {
66
+ console.log(colors.dim(` ${pkg.name} ${pkg.installed} → ${pkg.latest}`));
67
+ }
68
+ console.log(
69
+ colors.dim(` Run ${colors.cyan("bos upgrade")} to update packages and sync template files.`),
70
+ );
71
+ console.log();
72
+ } catch {
73
+ // silently ignore if status check fails
74
+ }
75
+ }
76
+
49
77
  async function main() {
50
78
  const args = process.argv.slice(2);
51
79
 
@@ -87,6 +115,8 @@ async function main() {
87
115
 
88
116
  const client = plugin.createClient();
89
117
 
118
+ await warnIfOutdated(client, command);
119
+
90
120
  try {
91
121
  const input = parseCommandInput(descriptor, commandArgs);
92
122
  const result = await (client as any)[descriptor.key](input);
@@ -310,6 +340,38 @@ async function main() {
310
340
  return;
311
341
  }
312
342
 
343
+ if (descriptor.key === "typesGen") {
344
+ console.log();
345
+ if (result.status === "error") {
346
+ console.error(`[CLI] ${result.error || "Unknown error"}`);
347
+ process.exit(1);
348
+ }
349
+ console.log(colors.green(`${icons.ok} Types generated`));
350
+ if (result.source) {
351
+ console.log(
352
+ ` ${colors.dim("Mode:")} ${result.source === "remote" ? colors.cyan("remote") : colors.dim("local")}`,
353
+ );
354
+ }
355
+ if (result.generated.length > 0) {
356
+ console.log(` ${colors.dim("Generated:")}`);
357
+ for (const f of result.generated) console.log(` ${colors.dim(f)}`);
358
+ }
359
+ if (result.fetched.length > 0) {
360
+ console.log(` ${colors.dim("Fetched from remote:")}`);
361
+ for (const url of result.fetched) console.log(` ${colors.dim(url)}`);
362
+ }
363
+ if (result.skipped.length > 0) {
364
+ console.log(` ${colors.dim("Skipped (local):")}`);
365
+ for (const s of result.skipped) console.log(` ${colors.dim(s)}`);
366
+ }
367
+ if (result.failed.length > 0) {
368
+ console.log(` ${colors.yellow("Failed:")}`);
369
+ for (const f of result.failed) console.log(` ${colors.error(f)}`);
370
+ }
371
+ console.log();
372
+ return;
373
+ }
374
+
313
375
  if (result?.status === "error") {
314
376
  console.error(`[CLI] ${result.error || "Unknown error"}`);
315
377
  process.exit(1);
@@ -121,6 +121,15 @@ export const cliCommandMeta = {
121
121
  noSync: { description: "Only upgrade packages, skip template sync" },
122
122
  },
123
123
  },
124
+ typesGen: {
125
+ commandPath: ["types", "gen"],
126
+ summary: "Generate type definitions from configured API and plugin contracts",
127
+ interactive: false,
128
+ fields: {
129
+ env: { description: "Environment: development (default) or production" },
130
+ dryRun: { description: "Preview what would be fetched without writing files" },
131
+ },
132
+ },
124
133
  status: {
125
134
  commandPath: ["status"],
126
135
  summary: "Show project health, versions, and update availability",
package/src/contract.ts CHANGED
@@ -221,6 +221,21 @@ export const StatusResultSchema = z.object({
221
221
  error: z.string().optional(),
222
222
  });
223
223
 
224
+ export const TypesGenOptionsSchema = z.object({
225
+ env: z.enum(["development", "production"]).optional(),
226
+ dryRun: z.boolean().default(false),
227
+ });
228
+
229
+ export const TypesGenResultSchema = z.object({
230
+ status: z.enum(["success", "error"]),
231
+ generated: z.array(z.string()),
232
+ fetched: z.array(z.string()),
233
+ skipped: z.array(z.string()),
234
+ failed: z.array(z.string()),
235
+ source: z.enum(["local", "remote"]).optional(),
236
+ error: z.string().optional(),
237
+ });
238
+
224
239
  export const bosContract = oc.router({
225
240
  dev: oc.route({ method: "POST", path: "/dev" }).input(DevOptionsSchema).output(DevResultSchema),
226
241
  start: oc
@@ -266,6 +281,10 @@ export const bosContract = oc.router({
266
281
  .input(UpgradeOptionsSchema)
267
282
  .output(UpgradeResultSchema),
268
283
  status: oc.route({ method: "GET", path: "/status" }).output(StatusResultSchema),
284
+ typesGen: oc
285
+ .route({ method: "POST", path: "/types/gen" })
286
+ .input(TypesGenOptionsSchema)
287
+ .output(TypesGenResultSchema),
269
288
  });
270
289
 
271
290
  export type DevOptions = z.infer<typeof DevOptionsSchema>;
@@ -289,3 +308,5 @@ export type SyncResult = z.infer<typeof SyncResultSchema>;
289
308
  export type UpgradeOptions = z.infer<typeof UpgradeOptionsSchema>;
290
309
  export type UpgradeResult = z.infer<typeof UpgradeResultSchema>;
291
310
  export type StatusResult = z.infer<typeof StatusResultSchema>;
311
+ export type TypesGenOptions = z.infer<typeof TypesGenOptionsSchema>;
312
+ export type TypesGenResult = z.infer<typeof TypesGenResultSchema>;
@@ -1,4 +1,3 @@
1
- import { createConnection } from "node:net";
2
1
  import { Command } from "@effect/platform";
3
2
  import type { ExitCode } from "@effect/platform/CommandExecutor";
4
3
  import { Deferred, Effect, Option, Ref, Stream } from "effect";
@@ -66,24 +65,6 @@ const probeHttpOk = (url: string, timeoutMs = 400) =>
66
65
  catch: () => false,
67
66
  });
68
67
 
69
- const probeTcpOpen = (port: number, timeoutMs = 250) =>
70
- Effect.async<boolean>((resume) => {
71
- const socket = createConnection({ host: "127.0.0.1", port });
72
- const timer = setTimeout(() => {
73
- socket.destroy();
74
- resume(Effect.succeed(false));
75
- }, timeoutMs);
76
- socket.once("connect", () => {
77
- clearTimeout(timer);
78
- socket.destroy();
79
- resume(Effect.succeed(true));
80
- });
81
- socket.once("error", () => {
82
- clearTimeout(timer);
83
- resume(Effect.succeed(false));
84
- });
85
- });
86
-
87
68
  const detectStatus = (
88
69
  line: string,
89
70
  descriptor: ServiceDescriptor,
package/src/plugin.ts CHANGED
@@ -40,6 +40,7 @@ import {
40
40
  type PublishOptions,
41
41
  type StartOptions,
42
42
  type SyncOptions,
43
+ type TypesGenOptions,
43
44
  type UpgradeOptions,
44
45
  } from "./contract";
45
46
  import { devApp, startApp } from "./dev-session";
@@ -94,7 +95,7 @@ function ensureEnvFile(configDir: string): void {
94
95
  .join("\n");
95
96
 
96
97
  writeFileSync(envPath, updated);
97
- console.log(`[CLI] Created .env from .env.example with generated BETTER_AUTH_SECRET`);
98
+ p.log.info(`Created .env from .env.example with generated BETTER_AUTH_SECRET`);
98
99
  }
99
100
 
100
101
  const buildCommands: Record<string, { cmd: string; args: string[] }> = {
@@ -256,8 +257,11 @@ function listPluginAttachments(config: BosConfig | null) {
256
257
  .sort((a, b) => a.key.localeCompare(b.key));
257
258
  }
258
259
 
259
- async function refreshApiContractBridge(configDir: string): Promise<void> {
260
- const refreshed = await loadConfig({ cwd: configDir, env: "development" });
260
+ async function refreshApiContractBridge(
261
+ configDir: string,
262
+ env: "development" | "production" = "development",
263
+ ): Promise<void> {
264
+ const refreshed = await loadConfig({ cwd: configDir, env });
261
265
  if (!refreshed) return;
262
266
 
263
267
  await syncApiContractBridge({
@@ -1467,6 +1471,116 @@ export default createPlugin({
1467
1471
  }
1468
1472
  }),
1469
1473
 
1474
+ typesGen: builder.typesGen.handler(async ({ input }: { input: TypesGenOptions }) => {
1475
+ try {
1476
+ const configPath = findConfigPath();
1477
+ if (!configPath) {
1478
+ return {
1479
+ status: "error" as const,
1480
+ generated: [],
1481
+ fetched: [],
1482
+ skipped: [],
1483
+ failed: [],
1484
+ error: "No bos.config.json found in current directory",
1485
+ };
1486
+ }
1487
+
1488
+ const projectDir = resolve(dirname(configPath));
1489
+ const env =
1490
+ input.env ?? (process.env.NODE_ENV === "production" ? "production" : "development");
1491
+
1492
+ const refreshed = await loadConfig({ cwd: projectDir, env });
1493
+ if (!refreshed) {
1494
+ return {
1495
+ status: "error" as const,
1496
+ generated: [],
1497
+ fetched: [],
1498
+ skipped: [],
1499
+ failed: [],
1500
+ error: "Failed to load bos.config.json",
1501
+ };
1502
+ }
1503
+
1504
+ if (input.dryRun) {
1505
+ const pluginEntries = Object.entries(refreshed.runtime.plugins ?? {});
1506
+ const fetched: string[] = [];
1507
+ const skipped: string[] = [];
1508
+
1509
+ if (refreshed.runtime.api.source !== "local") {
1510
+ fetched.push(refreshed.runtime.api.url);
1511
+ } else {
1512
+ skipped.push("api (local)");
1513
+ }
1514
+
1515
+ if (refreshed.runtime.auth) {
1516
+ if (refreshed.runtime.auth.source !== "local") {
1517
+ fetched.push(refreshed.runtime.auth.url);
1518
+ } else {
1519
+ skipped.push("auth (local)");
1520
+ }
1521
+ }
1522
+
1523
+ for (const [key, plugin] of pluginEntries) {
1524
+ if (plugin.url && plugin.source !== "local") {
1525
+ fetched.push(plugin.url);
1526
+ } else if (plugin.localPath) {
1527
+ skipped.push(`${key} (local)`);
1528
+ }
1529
+ }
1530
+
1531
+ return {
1532
+ status: "success" as const,
1533
+ generated: [
1534
+ "ui/src/api-contract.gen.ts",
1535
+ "ui/src/auth-types.gen.ts",
1536
+ "api/src/plugins-client.gen.ts",
1537
+ "api/src/auth-client.gen.ts",
1538
+ ],
1539
+ fetched,
1540
+ skipped,
1541
+ failed: [],
1542
+ source: refreshed.runtime.api.source,
1543
+ };
1544
+ }
1545
+
1546
+ const result = await syncApiContractBridge({
1547
+ configDir: projectDir,
1548
+ runtimeConfig: refreshed.runtime,
1549
+ apiBaseUrl: refreshed.runtime.api.url,
1550
+ });
1551
+
1552
+ const generated = [
1553
+ "ui/src/api-contract.gen.ts",
1554
+ "api/src/plugins-client.gen.ts",
1555
+ "api/src/auth-client.gen.ts",
1556
+ ];
1557
+ if (
1558
+ refreshed.runtime.auth &&
1559
+ (refreshed.runtime.auth.source !== "local" || refreshed.runtime.auth.localPath)
1560
+ ) {
1561
+ generated.push("ui/src/auth-types.gen.ts");
1562
+ }
1563
+
1564
+ return {
1565
+ status: "success" as const,
1566
+ generated,
1567
+ fetched: result.source === "remote" ? [refreshed.runtime.api.url] : [],
1568
+ skipped: result.source === "local" ? ["api (local)"] : [],
1569
+ failed: [],
1570
+ source: result.source,
1571
+ };
1572
+ } catch (error) {
1573
+ return {
1574
+ status: "error" as const,
1575
+ generated: [],
1576
+ fetched: [],
1577
+ skipped: [],
1578
+ failed: [],
1579
+ error: error instanceof Error ? error.message : "Unknown error",
1580
+ };
1581
+ }
1582
+ }),
1583
+
1470
1584
  status: builder.status.handler(async () => {
1471
1585
  try {
1472
1586
  const configPath = findConfigPath();
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env bun
2
-
3
- import { dirname } from "node:path";
4
- import { syncApiContractBridge } from "../api-contract";
5
- import { loadConfig } from "../config";
6
-
7
- async function main() {
8
- const result = await loadConfig({ cwd: process.cwd(), env: "development" });
9
- if (!result) {
10
- throw new Error("No bos.config.json found");
11
- }
12
-
13
- const configDir = dirname(result.source.path);
14
- await syncApiContractBridge({
15
- configDir,
16
- runtimeConfig: result.runtime,
17
- apiBaseUrl: result.runtime.api.url,
18
- });
19
- }
20
-
21
- main().catch((error) => {
22
- console.error("[sync-api-contract]", error instanceof Error ? error.message : String(error));
23
- process.exit(1);
24
- });