appflare 0.2.24 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/templates/core/app-creation.ts +1 -1
- package/cli/templates/core/client/appflare.ts +1 -1
- package/cli/templates/core/client/handlers/index.ts +3 -4
- package/cli/templates/core/export.ts +2 -2
- package/cli/templates/handlers/generators/registration/modules/cron.ts +1 -1
- package/cli/templates/handlers/registration.ts +10 -2
- package/dist/cli/index.d.mts +2 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +18 -11
- package/dist/cli/index.mjs +18 -11
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ app.use('*', cors({
|
|
|
7
7
|
if (!allowedDomains) {
|
|
8
8
|
return origin; // Allow everything if not set
|
|
9
9
|
}
|
|
10
|
-
const allowed = allowedDomains.split(',').map(d => d.trim());
|
|
10
|
+
const allowed = allowedDomains.split(',').map((d: string) => d.trim());
|
|
11
11
|
if (allowed.includes('*')) {
|
|
12
12
|
return origin;
|
|
13
13
|
}
|
|
@@ -83,7 +83,7 @@ export class Appflare<Options extends BetterAuthClientOptions = InferredAuthOpti
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
this.auth = createAuthClient<Options>({
|
|
86
|
-
...(mergedAuthOptions as Options),
|
|
86
|
+
...(mergedAuthOptions as unknown as Options),
|
|
87
87
|
baseURL: \`\${this.endpoint}\${options.authPath ?? "/api/auth"}\`,
|
|
88
88
|
fetch: request,
|
|
89
89
|
});
|
|
@@ -369,8 +369,7 @@ export const ${schemaType} = ${operation.schemaConst};`;
|
|
|
369
369
|
const queryTree = renderTreeObject(createTree(queryOperations));
|
|
370
370
|
const mutationTree = renderTreeObject(createTree(mutationOperations));
|
|
371
371
|
|
|
372
|
-
return `import
|
|
373
|
-
import { z } from "zod";
|
|
372
|
+
return `import { z } from "zod";
|
|
374
373
|
import type {
|
|
375
374
|
AppflareErrorMode,
|
|
376
375
|
AppflareRequestError,
|
|
@@ -667,12 +666,12 @@ async function requestRoute<TOutput>(
|
|
|
667
666
|
...(init.method === "POST" ? { "content-type": "application/json" } : {}),
|
|
668
667
|
};
|
|
669
668
|
|
|
670
|
-
const response =
|
|
669
|
+
const response = await fetch(requestUrl, {
|
|
671
670
|
method: init.method,
|
|
672
671
|
headers,
|
|
673
672
|
body: init.method === "POST" ? JSON.stringify(init.input ?? {}) : undefined,
|
|
674
673
|
signal: init.options?.signal,
|
|
675
|
-
})
|
|
674
|
+
});
|
|
676
675
|
|
|
677
676
|
const responseText = await response.text();
|
|
678
677
|
let body: unknown = undefined;
|
|
@@ -3,10 +3,10 @@ export function generateExport(): string {
|
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
\tfetch: app.fetch,
|
|
6
|
-
queue: async (batch, env) => {
|
|
6
|
+
queue: async (batch: { messages?: Array<{ body?: unknown }> }, env: Record<string, unknown>) => {
|
|
7
7
|
await executeScheduledBatch(batch, env, generatedHandlerOptions);
|
|
8
8
|
},
|
|
9
|
-
scheduled: async (controller, env) => {
|
|
9
|
+
scheduled: async (controller: { cron: string }, env: Record<string, unknown>) => {
|
|
10
10
|
await executeCronTriggers(controller, env, generatedHandlerOptions);
|
|
11
11
|
},
|
|
12
12
|
};
|
|
@@ -12,7 +12,7 @@ export async function executeCronTriggers(
|
|
|
12
12
|
const ctx = await createSchedulerExecutionContext(env, options);
|
|
13
13
|
|
|
14
14
|
for (const cronEntry of cronHandlers) {
|
|
15
|
-
if (!
|
|
15
|
+
if (!cronEntry.cronTriggers.includes(cronValue)) {
|
|
16
16
|
continue;
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -57,8 +57,16 @@ declare global {
|
|
|
57
57
|
interface AppflareSchedulerHandlerMap extends GeneratedSchedulerPayloadMap {}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
type CronHandlerEntry = {
|
|
61
|
+
taskName: string;
|
|
62
|
+
cronTriggers: readonly string[];
|
|
63
|
+
definition: {
|
|
64
|
+
handler: (ctx: AppflareContext) => void | Promise<void>;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const cronHandlers: readonly CronHandlerEntry[] = [${cronEntries || "\n"}
|
|
69
|
+
];
|
|
62
70
|
|
|
63
71
|
const storageHandlers = [${storageHandlersEntries || "\n"}
|
|
64
72
|
] as const;
|
package/dist/cli/index.js
CHANGED
|
@@ -141,7 +141,7 @@ export class Appflare<Options extends BetterAuthClientOptions = InferredAuthOpti
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
this.auth = createAuthClient<Options>({
|
|
144
|
-
...(mergedAuthOptions as Options),
|
|
144
|
+
...(mergedAuthOptions as unknown as Options),
|
|
145
145
|
baseURL: \`\${this.endpoint}\${options.authPath ?? "/api/auth"}\`,
|
|
146
146
|
fetch: request,
|
|
147
147
|
});
|
|
@@ -361,8 +361,7 @@ export const ${d} = ${u.schemaConst};`}).join(`
|
|
|
361
361
|
|
|
362
362
|
`),i=t.map(u=>On(u)).join(`
|
|
363
363
|
|
|
364
|
-
`),s=V(oe(n)),l=V(oe(r));return `import
|
|
365
|
-
import { z } from "zod";
|
|
364
|
+
`),s=V(oe(n)),l=V(oe(r));return `import { z } from "zod";
|
|
366
365
|
import type {
|
|
367
366
|
AppflareErrorMode,
|
|
368
367
|
AppflareRequestError,
|
|
@@ -660,12 +659,12 @@ async function requestRoute<TOutput>(
|
|
|
660
659
|
...(init.method === "POST" ? { "content-type": "application/json" } : {}),
|
|
661
660
|
};
|
|
662
661
|
|
|
663
|
-
const response =
|
|
662
|
+
const response = await fetch(requestUrl, {
|
|
664
663
|
method: init.method,
|
|
665
664
|
headers,
|
|
666
665
|
body: init.method === "POST" ? JSON.stringify(init.input ?? {}) : undefined,
|
|
667
666
|
signal: init.options?.signal,
|
|
668
|
-
})
|
|
667
|
+
});
|
|
669
668
|
|
|
670
669
|
const responseText = await response.text();
|
|
671
670
|
let body: unknown = undefined;
|
|
@@ -5858,7 +5857,7 @@ export async function executeCronTriggers(
|
|
|
5858
5857
|
const ctx = await createSchedulerExecutionContext(env, options);
|
|
5859
5858
|
|
|
5860
5859
|
for (const cronEntry of cronHandlers) {
|
|
5861
|
-
if (!
|
|
5860
|
+
if (!cronEntry.cronTriggers.includes(cronValue)) {
|
|
5862
5861
|
continue;
|
|
5863
5862
|
}
|
|
5864
5863
|
|
|
@@ -5908,9 +5907,17 @@ declare global {
|
|
|
5908
5907
|
interface AppflareSchedulerHandlerMap extends GeneratedSchedulerPayloadMap {}
|
|
5909
5908
|
}
|
|
5910
5909
|
|
|
5911
|
-
|
|
5910
|
+
type CronHandlerEntry = {
|
|
5911
|
+
taskName: string;
|
|
5912
|
+
cronTriggers: readonly string[];
|
|
5913
|
+
definition: {
|
|
5914
|
+
handler: (ctx: AppflareContext) => void | Promise<void>;
|
|
5915
|
+
};
|
|
5916
|
+
};
|
|
5917
|
+
|
|
5918
|
+
const cronHandlers: readonly CronHandlerEntry[] = [${u||`
|
|
5912
5919
|
`}
|
|
5913
|
-
]
|
|
5920
|
+
];
|
|
5914
5921
|
|
|
5915
5922
|
const storageHandlers = [${c||`
|
|
5916
5923
|
`}
|
|
@@ -5992,7 +5999,7 @@ app.use('*', cors({
|
|
|
5992
5999
|
if (!allowedDomains) {
|
|
5993
6000
|
return origin; // Allow everything if not set
|
|
5994
6001
|
}
|
|
5995
|
-
const allowed = allowedDomains.split(',').map(d => d.trim());
|
|
6002
|
+
const allowed = allowedDomains.split(',').map((d: string) => d.trim());
|
|
5996
6003
|
if (allowed.includes('*')) {
|
|
5997
6004
|
return origin;
|
|
5998
6005
|
}
|
|
@@ -6004,10 +6011,10 @@ app.use('*', cors({
|
|
|
6004
6011
|
|
|
6005
6012
|
export default {
|
|
6006
6013
|
fetch: app.fetch,
|
|
6007
|
-
queue: async (batch, env) => {
|
|
6014
|
+
queue: async (batch: { messages?: Array<{ body?: unknown }> }, env: Record<string, unknown>) => {
|
|
6008
6015
|
await executeScheduledBatch(batch, env, generatedHandlerOptions);
|
|
6009
6016
|
},
|
|
6010
|
-
scheduled: async (controller, env) => {
|
|
6017
|
+
scheduled: async (controller: { cron: string }, env: Record<string, unknown>) => {
|
|
6011
6018
|
await executeCronTriggers(controller, env, generatedHandlerOptions);
|
|
6012
6019
|
},
|
|
6013
6020
|
};
|
package/dist/cli/index.mjs
CHANGED
|
@@ -141,7 +141,7 @@ export class Appflare<Options extends BetterAuthClientOptions = InferredAuthOpti
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
this.auth = createAuthClient<Options>({
|
|
144
|
-
...(mergedAuthOptions as Options),
|
|
144
|
+
...(mergedAuthOptions as unknown as Options),
|
|
145
145
|
baseURL: \`\${this.endpoint}\${options.authPath ?? "/api/auth"}\`,
|
|
146
146
|
fetch: request,
|
|
147
147
|
});
|
|
@@ -361,8 +361,7 @@ export const ${d} = ${u.schemaConst};`}).join(`
|
|
|
361
361
|
|
|
362
362
|
`),i=t.map(u=>On(u)).join(`
|
|
363
363
|
|
|
364
|
-
`),s=V(oe(n)),l=V(oe(r));return `import
|
|
365
|
-
import { z } from "zod";
|
|
364
|
+
`),s=V(oe(n)),l=V(oe(r));return `import { z } from "zod";
|
|
366
365
|
import type {
|
|
367
366
|
AppflareErrorMode,
|
|
368
367
|
AppflareRequestError,
|
|
@@ -660,12 +659,12 @@ async function requestRoute<TOutput>(
|
|
|
660
659
|
...(init.method === "POST" ? { "content-type": "application/json" } : {}),
|
|
661
660
|
};
|
|
662
661
|
|
|
663
|
-
const response =
|
|
662
|
+
const response = await fetch(requestUrl, {
|
|
664
663
|
method: init.method,
|
|
665
664
|
headers,
|
|
666
665
|
body: init.method === "POST" ? JSON.stringify(init.input ?? {}) : undefined,
|
|
667
666
|
signal: init.options?.signal,
|
|
668
|
-
})
|
|
667
|
+
});
|
|
669
668
|
|
|
670
669
|
const responseText = await response.text();
|
|
671
670
|
let body: unknown = undefined;
|
|
@@ -5858,7 +5857,7 @@ export async function executeCronTriggers(
|
|
|
5858
5857
|
const ctx = await createSchedulerExecutionContext(env, options);
|
|
5859
5858
|
|
|
5860
5859
|
for (const cronEntry of cronHandlers) {
|
|
5861
|
-
if (!
|
|
5860
|
+
if (!cronEntry.cronTriggers.includes(cronValue)) {
|
|
5862
5861
|
continue;
|
|
5863
5862
|
}
|
|
5864
5863
|
|
|
@@ -5908,9 +5907,17 @@ declare global {
|
|
|
5908
5907
|
interface AppflareSchedulerHandlerMap extends GeneratedSchedulerPayloadMap {}
|
|
5909
5908
|
}
|
|
5910
5909
|
|
|
5911
|
-
|
|
5910
|
+
type CronHandlerEntry = {
|
|
5911
|
+
taskName: string;
|
|
5912
|
+
cronTriggers: readonly string[];
|
|
5913
|
+
definition: {
|
|
5914
|
+
handler: (ctx: AppflareContext) => void | Promise<void>;
|
|
5915
|
+
};
|
|
5916
|
+
};
|
|
5917
|
+
|
|
5918
|
+
const cronHandlers: readonly CronHandlerEntry[] = [${u||`
|
|
5912
5919
|
`}
|
|
5913
|
-
]
|
|
5920
|
+
];
|
|
5914
5921
|
|
|
5915
5922
|
const storageHandlers = [${c||`
|
|
5916
5923
|
`}
|
|
@@ -5992,7 +5999,7 @@ app.use('*', cors({
|
|
|
5992
5999
|
if (!allowedDomains) {
|
|
5993
6000
|
return origin; // Allow everything if not set
|
|
5994
6001
|
}
|
|
5995
|
-
const allowed = allowedDomains.split(',').map(d => d.trim());
|
|
6002
|
+
const allowed = allowedDomains.split(',').map((d: string) => d.trim());
|
|
5996
6003
|
if (allowed.includes('*')) {
|
|
5997
6004
|
return origin;
|
|
5998
6005
|
}
|
|
@@ -6004,10 +6011,10 @@ app.use('*', cors({
|
|
|
6004
6011
|
|
|
6005
6012
|
export default {
|
|
6006
6013
|
fetch: app.fetch,
|
|
6007
|
-
queue: async (batch, env) => {
|
|
6014
|
+
queue: async (batch: { messages?: Array<{ body?: unknown }> }, env: Record<string, unknown>) => {
|
|
6008
6015
|
await executeScheduledBatch(batch, env, generatedHandlerOptions);
|
|
6009
6016
|
},
|
|
6010
|
-
scheduled: async (controller, env) => {
|
|
6017
|
+
scheduled: async (controller: { cron: string }, env: Record<string, unknown>) => {
|
|
6011
6018
|
await executeCronTriggers(controller, env, generatedHandlerOptions);
|
|
6012
6019
|
},
|
|
6013
6020
|
};
|