appflare 0.2.19 → 0.2.21

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.
@@ -27,8 +27,14 @@ function findNearestPackageDir(startDir: string): string {
27
27
  }
28
28
  }
29
29
 
30
- export async function runBuild(configPath?: string): Promise<void> {
30
+ export async function runBuild(
31
+ configPath?: string,
32
+ options: { build?: boolean } = {},
33
+ ): Promise<void> {
31
34
  const loadedConfig = await loadConfig(configPath);
35
+ if (options.build !== undefined) {
36
+ loadedConfig.config.build = options.build;
37
+ }
32
38
  await generateArtifacts(loadedConfig);
33
39
  if (loadedConfig.wranglerOutDirAbs === loadedConfig.outDirAbs) {
34
40
  process.stdout.write(
@@ -44,11 +50,11 @@ export async function runBuild(configPath?: string): Promise<void> {
44
50
 
45
51
  export async function runDev(
46
52
  configPath?: string,
47
- watch = false,
53
+ options: { watch?: boolean; build?: boolean } = {},
48
54
  ): Promise<void> {
49
- await runBuild(configPath);
55
+ await runBuild(configPath, { build: options.build });
50
56
 
51
- if (!watch) {
57
+ if (!options.watch) {
52
58
  return;
53
59
  }
54
60
 
@@ -64,7 +70,7 @@ export async function runDev(
64
70
 
65
71
  isRunning = true;
66
72
  try {
67
- await runBuild(configPath);
73
+ await runBuild(configPath, { build: options.build });
68
74
  } catch (error) {
69
75
  process.stderr.write(`❌ Build failed: ${(error as Error).message}\n`);
70
76
  } finally {
package/cli/generate.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { mkdir } from "node:fs/promises";
2
+ import { existsSync } from "node:fs";
2
3
  import { relative, resolve } from "node:path";
3
4
  import { generateAuthConfigSource } from "./templates/auth/config";
4
5
  import { generateClientArtifacts } from "./templates/core/client.artifacts";
@@ -154,4 +155,21 @@ export async function generateArtifacts(
154
155
  if (exitCode !== 0) {
155
156
  throw new Error(`better-auth generation failed with exit code ${exitCode}`);
156
157
  }
158
+
159
+ const tsconfigPath = resolve(configDir, "tsconfig.json");
160
+ if (loadedConfig.config.build && existsSync(tsconfigPath)) {
161
+ const npxCmd = process.platform === "win32" ? "npx.cmd" : "npx";
162
+ const tsBuild = Bun.spawn([npxCmd, "tsc", "--build"], {
163
+ cwd: configDir,
164
+ stdout: "inherit",
165
+ stderr: "inherit",
166
+ });
167
+
168
+ const tsBuildExitCode = await tsBuild.exited;
169
+ if (tsBuildExitCode !== 0) {
170
+ throw new Error(
171
+ `TypeScript build failed with exit code ${tsBuildExitCode}`,
172
+ );
173
+ }
174
+ }
157
175
  }
package/cli/index.ts CHANGED
@@ -20,8 +20,9 @@ program
20
20
  "Path to appflare.config.ts",
21
21
  "appflare.config.ts",
22
22
  )
23
- .action(async (options: { config: string }) => {
24
- await runBuild(options.config);
23
+ .option("--no-build", "Skip TypeScript build step")
24
+ .action(async (options: { config: string; build: boolean }) => {
25
+ await runBuild(options.config, { build: options.build });
25
26
  });
26
27
 
27
28
  program
@@ -33,9 +34,12 @@ program
33
34
  "appflare.config.ts",
34
35
  )
35
36
  .option("-w, --watch", "Watch scanDir and regenerate on changes", false)
36
- .action(async (options: { config: string; watch: boolean }) => {
37
- await runDev(options.config, options.watch);
38
- });
37
+ .option("--no-build", "Skip TypeScript build step")
38
+ .action(
39
+ async (options: { config: string; watch: boolean; build: boolean }) => {
40
+ await runDev(options.config, { watch: options.watch, build: options.build });
41
+ },
42
+ );
39
43
 
40
44
  program
41
45
  .command("migrate")
@@ -92,6 +92,7 @@ const appflareConfigSchema = z
92
92
  scheduler: schedulerConfigSchema.optional(),
93
93
  realtime: realtimeConfigSchema.optional(),
94
94
  wranglerOverrides: z.record(z.string(), z.unknown()).optional(),
95
+ build: z.boolean().optional(),
95
96
  })
96
97
  .strict();
97
98
 
@@ -154,6 +155,7 @@ function normalizeConfig(input: AppflareConfig): NormalizedAppflareConfig {
154
155
  wranglerOverrides: removeLegacySchedulerOverride(input.wranglerOverrides),
155
156
  wranglerOutDir:
156
157
  input.wranglerOutDir ?? input.wranglerOutPath ?? input.outDir,
158
+ build: input.build ?? true,
157
159
  };
158
160
  }
159
161
 
@@ -2,7 +2,7 @@ export function buildStoragePageRuntime(): string {
2
2
  return `
3
3
  const buildStorageListingContent = (listed: any, prefix: string) => {
4
4
  const parts = prefix.split('/').filter(Boolean);
5
- const breadcrumbs = [];
5
+ const breadcrumbs: any[] = [];
6
6
  let currentPath = '';
7
7
  const visibleObjects = listed.objects.filter((obj: any) => !obj.key.endsWith('/.keep'));
8
8
 
@@ -170,7 +170,7 @@ export function buildTableGetRoute(
170
170
  \t\tlet countQuery = db.select({ count: sql\`count(*)\` }).from(tableSchema);
171
171
 
172
172
  \t\tif (search) {
173
- \t\t\tconst searchConditions = [];
173
+ const searchConditions: any[] = [];
174
174
  \t\t\t${searchConditions}
175
175
  \t\t\tif (searchConditions.length > 0) {
176
176
  \t\t\t\tquery = query.where(or(...searchConditions)) as any;
@@ -103,7 +103,7 @@ export function buildTablePostRoutes(
103
103
  \t\tif (mode === 'all-matching') {
104
104
  \t\t\tlet deleteQuery = db.delete(tableSchema);
105
105
  \t\t\tif (search) {
106
- \t\t\t\tconst searchConditions = [];
106
+ const searchConditions: any[] = [];
107
107
  \t\t\t\t${searchConditions}
108
108
  \t\t\t\tif (searchConditions.length > 0) {
109
109
  \t\t\t\t\tdeleteQuery = deleteQuery.where(or(...searchConditions)) as any;
@@ -25,7 +25,7 @@ export function handleOperationError(
25
25
  validationMessage: string,
26
26
  ): Response {
27
27
  if (error instanceof AppflareHandledError) {
28
- return c.json(error.payload, error.status);
28
+ return c.json(error.payload, error.status as any);
29
29
  }
30
30
 
31
31
  if (error instanceof ZodError) {
@@ -9,14 +9,10 @@ export async function executeCronTriggers(
9
9
  return;
10
10
  }
11
11
 
12
- if (cronHandlers.length === 0) {
13
- return;
14
- }
15
-
16
12
  const ctx = await createSchedulerExecutionContext(env, options);
17
13
 
18
14
  for (const cronEntry of cronHandlers) {
19
- if (!cronEntry.cronTriggers.includes(cronValue)) {
15
+ if (!(cronEntry.cronTriggers as readonly string[]).includes(cronValue)) {
20
16
  continue;
21
17
  }
22
18
 
@@ -131,7 +131,7 @@ function registerRealtimeRoutes(
131
131
  } | null;
132
132
  return c.json(
133
133
  { message: payload?.message ?? "Unable to remove subscription" },
134
- response.status,
134
+ response.status as any,
135
135
  );
136
136
  }
137
137
 
@@ -29,7 +29,7 @@ export async function executeScheduledBatch(
29
29
 
30
30
  const operation = (schedulerHandlers as Record<string, {
31
31
  definition: {
32
- handler: (ctx: typeof ctx, args: unknown) => Promise<void> | void;
32
+ handler: (ctx: AppflareContext, args: unknown) => Promise<void> | void;
33
33
  };
34
34
  schema: z.ZodTypeAny;
35
35
  }>)[task];
@@ -57,7 +57,7 @@ export function registerGeneratedStorageRoutes(
57
57
  }, 200);
58
58
  } catch (error) {
59
59
  if (error instanceof AppflareHandledError) {
60
- return c.json(error.payload, error.status);
60
+ return c.json(error.payload, error.status as any);
61
61
  }
62
62
 
63
63
  return c.json(
@@ -89,7 +89,7 @@ export function registerGeneratedStorageRoutes(
89
89
  }, 200);
90
90
  } catch (error) {
91
91
  if (error instanceof AppflareHandledError) {
92
- return c.json(error.payload, error.status);
92
+ return c.json(error.payload, error.status as any);
93
93
  }
94
94
 
95
95
  return c.json(
@@ -119,7 +119,7 @@ export function registerGeneratedStorageRoutes(
119
119
  }, 200);
120
120
  } catch (error) {
121
121
  if (error instanceof AppflareHandledError) {
122
- return c.json(error.payload, error.status);
122
+ return c.json(error.payload, error.status as any);
123
123
  }
124
124
 
125
125
  return c.json(
@@ -137,7 +137,7 @@ export function registerGeneratedStorageRoutes(
137
137
  return c.json({ ok: true, path }, 200);
138
138
  } catch (error) {
139
139
  if (error instanceof AppflareHandledError) {
140
- return c.json(error.payload, error.status);
140
+ return c.json(error.payload, error.status as any);
141
141
  }
142
142
 
143
143
  return c.json(
@@ -181,7 +181,7 @@ export function registerGeneratedStorageRoutes(
181
181
  return c.json(result, 200);
182
182
  } catch (error) {
183
183
  if (error instanceof AppflareHandledError) {
184
- return c.json(error.payload, error.status);
184
+ return c.json(error.payload, error.status as any);
185
185
  }
186
186
 
187
187
  return c.json(
@@ -481,11 +481,7 @@ function hasManyToManyRelationsInWith(
481
481
  }
482
482
 
483
483
  const nestedWith = relationValue.with;
484
- if (
485
- hasManyToManyRelationsInWith(relationName, nestedWith) ||
486
- (manyToMany &&
487
- hasManyToManyRelationsInWith(manyToMany.targetTable, nestedWith))
488
- ) {
484
+ if (hasManyToManyRelationsInWith(relationName, nestedWith)) {
489
485
  return true;
490
486
  }
491
487
  }
@@ -577,7 +573,7 @@ type RelationWithAggregatePlan = Record<string, RelationWithAggregatePlanEntry>;
577
573
 
578
574
  function hasRelationAggregatePlanEntries(
579
575
  plan: RelationWithAggregatePlan | undefined,
580
- ): boolean {
576
+ ): plan is RelationWithAggregatePlan {
581
577
  return !!plan && Object.keys(plan).length > 0;
582
578
  }
583
579
 
package/cli/types.ts CHANGED
@@ -72,6 +72,7 @@ export type AppflareConfig = {
72
72
  scheduler?: AppflareSchedulerConfig;
73
73
  realtime?: AppflareRealtimeConfig;
74
74
  wranglerOverrides?: JsonObject;
75
+ build?: boolean;
75
76
  };
76
77
 
77
78
  export type NormalizedAppflareConfig = Omit<
@@ -96,6 +97,7 @@ export type NormalizedAppflareConfig = Omit<
96
97
  | "protocol"
97
98
  >
98
99
  >;
100
+ build: boolean;
99
101
  };
100
102
 
101
103
  export type LoadedAppflareConfig = {
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }