@moku-labs/worker 0.9.2 → 0.11.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.
- package/LICENSE +21 -0
- package/README.md +142 -279
- package/dist/index.cjs +4397 -31
- package/dist/index.d.cts +555 -28
- package/dist/index.d.mts +554 -27
- package/dist/index.mjs +4362 -19
- package/package.json +2 -11
- package/dist/cli--EPl98vG.mjs +0 -4175
- package/dist/cli-imQGo0tc.cjs +0 -4275
- package/dist/cli.cjs +0 -4
- package/dist/cli.d.cts +0 -2
- package/dist/cli.d.mts +0 -2
- package/dist/cli.mjs +0 -2
- package/dist/index-CWxQr2Q3.d.cts +0 -531
- package/dist/index-CWxQr2Q3.d.mts +0 -531
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,95 @@
|
|
|
1
|
-
import { a as ResourceManifest, c as WorkerEnv, i as ExternalManifest, l as WorkerEvents, n as cliPlugin, o as SeedConfig, r as DeployReport, s as WorkerConfig, t as deployPlugin, u as WorkerPluginCtx } from "./index-CWxQr2Q3.mjs";
|
|
2
1
|
import { envPlugin, logPlugin } from "@moku-labs/common";
|
|
3
2
|
import { PluginCtx, PluginCtx as PluginCtx$1, PluginInstance } from "@moku-labs/core";
|
|
4
3
|
|
|
5
4
|
//#region \0rolldown/runtime.js
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/config.d.ts
|
|
7
|
+
/** Per-request Cloudflare bindings object (env). Framework-level shared type. */
|
|
8
|
+
type WorkerEnv = Record<string, unknown>;
|
|
9
|
+
/** Global framework config — flat, with complete defaults. */
|
|
10
|
+
type WorkerConfig = {
|
|
11
|
+
stage: "production" | "development" | "test";
|
|
12
|
+
name: string;
|
|
13
|
+
compatibilityDate: string;
|
|
14
|
+
};
|
|
15
|
+
/** Global framework events — declared once, visible to every plugin. */
|
|
16
|
+
type WorkerEvents = {
|
|
17
|
+
"request:start": {
|
|
18
|
+
method: string;
|
|
19
|
+
path: string;
|
|
20
|
+
requestId: string;
|
|
21
|
+
};
|
|
22
|
+
"request:end": {
|
|
23
|
+
method: string;
|
|
24
|
+
path: string;
|
|
25
|
+
status: number;
|
|
26
|
+
ms: number;
|
|
27
|
+
};
|
|
28
|
+
"deploy:phase": {
|
|
29
|
+
phase: string;
|
|
30
|
+
detail?: string;
|
|
31
|
+
};
|
|
32
|
+
"deploy:complete": {
|
|
33
|
+
url: string;
|
|
34
|
+
};
|
|
35
|
+
"provision:resource": {
|
|
36
|
+
kind: "kv" | "r2" | "d1" | "queue" | "do";
|
|
37
|
+
name: string;
|
|
38
|
+
};
|
|
39
|
+
"provision:plan": {
|
|
40
|
+
exists: number;
|
|
41
|
+
missing: number;
|
|
42
|
+
ships: number;
|
|
43
|
+
account: string;
|
|
44
|
+
};
|
|
45
|
+
"provision:skip": {
|
|
46
|
+
kind: "kv" | "r2" | "d1" | "queue" | "do";
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
"auth:verified": {
|
|
50
|
+
account: string;
|
|
51
|
+
accountId: string;
|
|
52
|
+
scopes: string[];
|
|
53
|
+
};
|
|
54
|
+
"dev:phase": {
|
|
55
|
+
phase: string;
|
|
56
|
+
detail?: string;
|
|
57
|
+
};
|
|
58
|
+
"dev:rebuilt": {
|
|
59
|
+
files: number;
|
|
60
|
+
ms: number;
|
|
61
|
+
};
|
|
62
|
+
"dev:error": {
|
|
63
|
+
message: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Worker-bound plugin context for Layer-3 consumer plugins. Aliases the core
|
|
68
|
+
* {@link PluginCtx} with the global {@link WorkerEvents} pre-merged into the event
|
|
69
|
+
* map, so a consumer plugin types its own `config`/`state`/`emit` by passing only
|
|
70
|
+
* its OWN event map — never hand-merging `WorkerEvents`, and never importing from
|
|
71
|
+
* `@moku-labs/core` (a Layer-1 boundary the spec validator flags for consumers).
|
|
72
|
+
*
|
|
73
|
+
* A plugin that resolves sibling plugins also needs a `require` field; intersect the
|
|
74
|
+
* public `Server.RequireFn` for it, exactly as this framework's own plugins do. When
|
|
75
|
+
* you need the unaliased shape (e.g. a different global event map), use the raw
|
|
76
|
+
* re-exported {@link PluginCtx} instead.
|
|
77
|
+
*
|
|
78
|
+
* @template Config - This plugin's own flat configuration object.
|
|
79
|
+
* @template State - This plugin's mutable state (use `Record<string, never>` when stateless).
|
|
80
|
+
* @template Events - This plugin's own event map, merged on top of {@link WorkerEvents}; defaults to none.
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* import type { Server, WorkerPluginCtx } from "@moku-labs/worker";
|
|
84
|
+
* type MyEvents = { "my:done": { id: string } };
|
|
85
|
+
* export type MyCtx = WorkerPluginCtx<MyConfig, Record<string, never>, MyEvents> & {
|
|
86
|
+
* require: Server.RequireFn;
|
|
87
|
+
* };
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
type WorkerPluginCtx<Config, State, Events extends Record<string, unknown> = Record<never, never>> = PluginCtx$1<Config, State, WorkerEvents & Events>;
|
|
6
91
|
declare namespace types_d_exports {
|
|
7
|
-
export { BindingsApi, Config$
|
|
92
|
+
export { BindingsApi, Config$7 as Config, Context };
|
|
8
93
|
}
|
|
9
94
|
/**
|
|
10
95
|
* bindings config. Flat (spec/05 §3,§6) — a complete default so omission
|
|
@@ -15,7 +100,7 @@ declare namespace types_d_exports {
|
|
|
15
100
|
* { required: ["MY_KV", "DB"] }
|
|
16
101
|
* ```
|
|
17
102
|
*/
|
|
18
|
-
type Config$
|
|
103
|
+
type Config$7 = {
|
|
19
104
|
required: string[];
|
|
20
105
|
};
|
|
21
106
|
/**
|
|
@@ -50,7 +135,7 @@ type BindingsApi = {
|
|
|
50
135
|
* api-factory context. State slot is Record<string, never> — bindings holds NO
|
|
51
136
|
* state (F4). Type-argument order is PluginCtx<Config, State, Events>.
|
|
52
137
|
*/
|
|
53
|
-
type Context = PluginCtx$1<Config$
|
|
138
|
+
type Context = PluginCtx$1<Config$7, Record<string, never>, WorkerEvents>;
|
|
54
139
|
//#endregion
|
|
55
140
|
//#region src/plugins/bindings/index.d.ts
|
|
56
141
|
/**
|
|
@@ -62,9 +147,9 @@ type Context = PluginCtx$1<Config$5, Record<string, never>, WorkerEvents>;
|
|
|
62
147
|
*
|
|
63
148
|
* @see README.md
|
|
64
149
|
*/
|
|
65
|
-
declare const bindingsPlugin: import("@moku-labs/core").PluginInstance<"bindings", Config$
|
|
150
|
+
declare const bindingsPlugin: import("@moku-labs/core").PluginInstance<"bindings", Config$7, Record<string, never>, BindingsApi, {}> & Record<never, never>;
|
|
66
151
|
declare namespace types_d_exports$4 {
|
|
67
|
-
export { Api$
|
|
152
|
+
export { Api$4 as Api, CompiledEndpoint, Endpoint, EndpointHandler, MatchResult, Method, PathParams, PathSegment, RequestContext, RequireFn, ServerConfig, ServerCtx, ServerEvents, ServerState };
|
|
68
153
|
}
|
|
69
154
|
/** HTTP method an endpoint matches; "ALL" matches any verb. */
|
|
70
155
|
type Method = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS" | "ALL";
|
|
@@ -191,7 +276,7 @@ type ServerCtx = PluginCtx$1<ServerConfig, ServerState, WorkerEvents & ServerEve
|
|
|
191
276
|
has: (name: string) => boolean;
|
|
192
277
|
};
|
|
193
278
|
/** Public api surface of the server plugin. */
|
|
194
|
-
type Api$
|
|
279
|
+
type Api$4 = {
|
|
195
280
|
/**
|
|
196
281
|
* Route one HTTP request and return its Response (or 404).
|
|
197
282
|
*
|
|
@@ -335,7 +420,7 @@ type EndpointBuilder<Path extends string> = {
|
|
|
335
420
|
*/
|
|
336
421
|
declare const endpoint: <Path extends string>(path: Path) => EndpointBuilder<Path>;
|
|
337
422
|
declare namespace types_d_exports$1 {
|
|
338
|
-
export { Api$
|
|
423
|
+
export { Api$3 as Api, Config$6 as Config, D1Ctx, D1DatabaseApi, D1Instance };
|
|
339
424
|
}
|
|
340
425
|
/**
|
|
341
426
|
* A single D1 database instance: its base Cloudflare name + the env binding it resolves off, plus
|
|
@@ -361,7 +446,7 @@ type D1Instance = {
|
|
|
361
446
|
* { main: { name: "tracker-db", binding: "DB", migrations: "db/migrations" } }
|
|
362
447
|
* ```
|
|
363
448
|
*/
|
|
364
|
-
type Config$
|
|
449
|
+
type Config$6 = Record<string, D1Instance>;
|
|
365
450
|
/**
|
|
366
451
|
* The SQL surface for one D1 database (the thin typed wrappers bound to a single instance).
|
|
367
452
|
*
|
|
@@ -425,7 +510,7 @@ type D1DatabaseApi = {
|
|
|
425
510
|
* await app.d1.use("analytics").run(env, "INSERT INTO events (name) VALUES (?)", "click");
|
|
426
511
|
* ```
|
|
427
512
|
*/
|
|
428
|
-
type Api$
|
|
513
|
+
type Api$3 = D1DatabaseApi & {
|
|
429
514
|
/**
|
|
430
515
|
* Select a specific D1 database instance by its config key.
|
|
431
516
|
*
|
|
@@ -450,7 +535,7 @@ type Api$2 = D1DatabaseApi & {
|
|
|
450
535
|
* Internal context type — own config first, no state, no d1-local events.
|
|
451
536
|
* Intersected with a narrow `require` typed to the one dependency d1 resolves.
|
|
452
537
|
*/
|
|
453
|
-
type D1Ctx = PluginCtx$1<Config$
|
|
538
|
+
type D1Ctx = PluginCtx$1<Config$6, Record<string, never>, WorkerEvents> & {
|
|
454
539
|
/**
|
|
455
540
|
* Resolve a dependency plugin's api. d1 only ever resolves `bindingsPlugin`.
|
|
456
541
|
*
|
|
@@ -470,7 +555,7 @@ type D1Ctx = PluginCtx$1<Config$4, Record<string, never>, WorkerEvents> & {
|
|
|
470
555
|
*
|
|
471
556
|
* @see README.md
|
|
472
557
|
*/
|
|
473
|
-
declare const d1Plugin: import("@moku-labs/core").PluginInstance<"d1", Config$
|
|
558
|
+
declare const d1Plugin: import("@moku-labs/core").PluginInstance<"d1", Config$6, Record<string, never>, {
|
|
474
559
|
use: (key: string) => {
|
|
475
560
|
query: <T = unknown>(env: WorkerEnv, sql: string, ...params: unknown[]) => Promise<D1Result<T>>;
|
|
476
561
|
first: <T = unknown>(env: WorkerEnv, sql: string, ...params: unknown[]) => Promise<T | null>;
|
|
@@ -548,7 +633,7 @@ declare const defineDurableObject: (name: string) => DurableObjectBaseConstructo
|
|
|
548
633
|
readonly doName: string;
|
|
549
634
|
};
|
|
550
635
|
declare namespace types_d_exports$2 {
|
|
551
|
-
export { Api$
|
|
636
|
+
export { Api$2 as Api, Config$5 as Config, Ctx$1 as Ctx, DoInstance };
|
|
552
637
|
}
|
|
553
638
|
/**
|
|
554
639
|
* A single Durable Object instance: the env binding it resolves off plus the EXPORTED class it
|
|
@@ -576,9 +661,9 @@ type DoInstance = {
|
|
|
576
661
|
* { board: { binding: "BOARD", className: "BoardChannel" } }
|
|
577
662
|
* ```
|
|
578
663
|
*/
|
|
579
|
-
type Config$
|
|
664
|
+
type Config$5 = Record<string, DoInstance>;
|
|
580
665
|
/** Public api surface of the durableObjects plugin. */
|
|
581
|
-
type Api$
|
|
666
|
+
type Api$2 = {
|
|
582
667
|
/**
|
|
583
668
|
* Resolve a DurableObjectStub off the request env (logical key -> configured binding).
|
|
584
669
|
*
|
|
@@ -604,7 +689,7 @@ type Api$1 = {
|
|
|
604
689
|
* Internal context type — own config first, no state, no DO events.
|
|
605
690
|
* Intersected with a narrow `require` typed to the one dependency durableObjects resolves.
|
|
606
691
|
*/
|
|
607
|
-
type Ctx$1 = PluginCtx$1<Config$
|
|
692
|
+
type Ctx$1 = PluginCtx$1<Config$5, Record<string, never>, WorkerEvents> & {
|
|
608
693
|
/**
|
|
609
694
|
* Resolve a dependency plugin's api. durableObjects only ever resolves `bindingsPlugin`.
|
|
610
695
|
*
|
|
@@ -635,7 +720,7 @@ type Ctx$1 = PluginCtx$1<Config$3, Record<string, never>, WorkerEvents> & {
|
|
|
635
720
|
* ```
|
|
636
721
|
* @see README.md
|
|
637
722
|
*/
|
|
638
|
-
declare const durableObjectsPlugin: import("@moku-labs/core").PluginInstance<"durableObjects", Config$
|
|
723
|
+
declare const durableObjectsPlugin: import("@moku-labs/core").PluginInstance<"durableObjects", Config$5, Record<string, never>, {
|
|
639
724
|
get: (env: WorkerEnv, logicalName: string, idName: string) => DurableObjectStub;
|
|
640
725
|
deployManifest: () => Array<{
|
|
641
726
|
kind: "do";
|
|
@@ -671,7 +756,7 @@ type KvInstance = {
|
|
|
671
756
|
* { cache: { name: "tracker-cache", binding: "CACHE" } }
|
|
672
757
|
* ```
|
|
673
758
|
*/
|
|
674
|
-
type Config$
|
|
759
|
+
type Config$4 = Record<string, KvInstance>;
|
|
675
760
|
/**
|
|
676
761
|
* The env-first key/value surface for one KV namespace (the methods bound to a single instance).
|
|
677
762
|
*
|
|
@@ -758,9 +843,9 @@ type KvApi = KvNamespaceApi & {
|
|
|
758
843
|
*
|
|
759
844
|
* @see README.md
|
|
760
845
|
*/
|
|
761
|
-
declare const kvPlugin: import("@moku-labs/core").PluginInstance<"kv", Config$
|
|
846
|
+
declare const kvPlugin: import("@moku-labs/core").PluginInstance<"kv", Config$4, Record<string, never>, KvApi, {}> & Record<never, never>;
|
|
762
847
|
declare namespace types_d_exports$3 {
|
|
763
|
-
export { Api, Config$
|
|
848
|
+
export { Api$1 as Api, Config$3 as Config, Ctx, QueueEvents, QueueInstance, QueueProducerApi };
|
|
764
849
|
}
|
|
765
850
|
/**
|
|
766
851
|
* A single Cloudflare Queue instance: its base CF queue name, the producer env binding it
|
|
@@ -793,7 +878,7 @@ type QueueInstance = {
|
|
|
793
878
|
* { activity: { name: "tracker-activity", binding: "ACTIVITY", onMessage: async () => {} } }
|
|
794
879
|
* ```
|
|
795
880
|
*/
|
|
796
|
-
type Config$
|
|
881
|
+
type Config$3 = Record<string, QueueInstance>;
|
|
797
882
|
/** Per-plugin event map for queues. */
|
|
798
883
|
type QueueEvents = {
|
|
799
884
|
"queue:message": {
|
|
@@ -837,7 +922,7 @@ type QueueProducerApi = {
|
|
|
837
922
|
* await app.queues.use("activity").send(env, { id: 2 }); // a named instance
|
|
838
923
|
* ```
|
|
839
924
|
*/
|
|
840
|
-
type Api = QueueProducerApi & {
|
|
925
|
+
type Api$1 = QueueProducerApi & {
|
|
841
926
|
/**
|
|
842
927
|
* Select a specific Queue instance by its config key.
|
|
843
928
|
*
|
|
@@ -878,7 +963,7 @@ type Api = QueueProducerApi & {
|
|
|
878
963
|
* (core's "advanced composition" note), typed to the one dependency queues resolves —
|
|
879
964
|
* `require(bindingsPlugin)` → `BindingsApi`. Core does not export `RequireFunction`.
|
|
880
965
|
*/
|
|
881
|
-
type Ctx = PluginCtx$1<Config$
|
|
966
|
+
type Ctx = PluginCtx$1<Config$3, Record<string, never>, WorkerEvents & QueueEvents> & {
|
|
882
967
|
/**
|
|
883
968
|
* Resolve a dependency plugin's api. queues only ever resolves `bindingsPlugin`.
|
|
884
969
|
*
|
|
@@ -900,7 +985,7 @@ type Ctx = PluginCtx$1<Config$1, Record<string, never>, WorkerEvents & QueueEven
|
|
|
900
985
|
*
|
|
901
986
|
* @see README.md
|
|
902
987
|
*/
|
|
903
|
-
declare const queuesPlugin: import("@moku-labs/core").PluginInstance<"queues", Config$
|
|
988
|
+
declare const queuesPlugin: import("@moku-labs/core").PluginInstance<"queues", Config$3, Record<string, never>, Api$1, {
|
|
904
989
|
"queue:message": {
|
|
905
990
|
queue: string;
|
|
906
991
|
messageId: string;
|
|
@@ -915,7 +1000,7 @@ declare const queuesPlugin: import("@moku-labs/core").PluginInstance<"queues", C
|
|
|
915
1000
|
*
|
|
916
1001
|
* @see README.md
|
|
917
1002
|
*/
|
|
918
|
-
declare const serverPlugin: import("@moku-labs/core").PluginInstance<"server", ServerConfig, ServerState, Api$
|
|
1003
|
+
declare const serverPlugin: import("@moku-labs/core").PluginInstance<"server", ServerConfig, ServerState, Api$4, {
|
|
919
1004
|
"server:matched": {
|
|
920
1005
|
path: string;
|
|
921
1006
|
method: string;
|
|
@@ -1079,6 +1164,448 @@ type StorageCtx = PluginCtx$1<StorageConfig, Record<string, never>, WorkerEvents
|
|
|
1079
1164
|
*/
|
|
1080
1165
|
declare const storagePlugin: import("@moku-labs/core").PluginInstance<"storage", StorageConfig, Record<string, never>, StorageApi, {}> & Record<never, never>;
|
|
1081
1166
|
//#endregion
|
|
1167
|
+
//#region src/plugins/deploy/types.d.ts
|
|
1168
|
+
/**
|
|
1169
|
+
* A web-site build hook wired in from the consumer's deploy/dev script — e.g.
|
|
1170
|
+
* `() => webApp.cli.build()`. This is the seam that lets one small app-side script compose a
|
|
1171
|
+
* Moku Web app with this Worker framework: `dev` / `deploy` invoke it to (re)build the site before
|
|
1172
|
+
* serving or deploying. The hook may resolve ANYTHING — `void`, the web app's own build summary, or
|
|
1173
|
+
* a `{ files }` count; when the resolved value carries a numeric `files` field it is surfaced in
|
|
1174
|
+
* `dev:rebuilt`, otherwise the count is reported as 0. Returning `Promise<unknown>` keeps the hook
|
|
1175
|
+
* assignable from any real build function (whose return type the worker framework cannot know).
|
|
1176
|
+
*
|
|
1177
|
+
* @returns Resolves when the web build completes (the value is read opportunistically for `files`).
|
|
1178
|
+
* @example
|
|
1179
|
+
* ```ts
|
|
1180
|
+
* await server.cli.dev({ webBuild: () => web.cli.build() });
|
|
1181
|
+
* ```
|
|
1182
|
+
*/
|
|
1183
|
+
type WebBuild = () => Promise<unknown>;
|
|
1184
|
+
/**
|
|
1185
|
+
* A per-change INCREMENTAL rebuild hook wired in from the consumer's dev script — e.g.
|
|
1186
|
+
* `(changes) => webApp.cli.update(changes)`. The fast counterpart to {@link WebBuild}: `dev`
|
|
1187
|
+
* calls {@link WebBuild} ONCE for the cold build, then (when this hook is wired) calls `onChange`
|
|
1188
|
+
* with the set of paths changed in the debounce window so the web build can rebuild only what
|
|
1189
|
+
* changed instead of doing a full `webBuild()` every keystroke. Omit it and `dev` keeps doing a
|
|
1190
|
+
* full `webBuild()` per change (the prior behavior). Like {@link WebBuild} it may resolve ANYTHING
|
|
1191
|
+
* (the web build's own summary); the value is read opportunistically for a `files` count.
|
|
1192
|
+
*
|
|
1193
|
+
* @param changes - The paths changed since the last rebuild (the watcher's debounced set).
|
|
1194
|
+
* @returns Resolves when the incremental rebuild completes.
|
|
1195
|
+
* @example
|
|
1196
|
+
* ```ts
|
|
1197
|
+
* await server.cli.dev({ webBuild: () => web.cli.build(), onChange: changes => web.cli.update(changes) });
|
|
1198
|
+
* ```
|
|
1199
|
+
*/
|
|
1200
|
+
type OnChange = (changes: readonly string[]) => Promise<unknown>;
|
|
1201
|
+
/**
|
|
1202
|
+
* The remote seed wired into `deploy({ seed: true })`: which SQL file to load into the REMOTE D1
|
|
1203
|
+
* AFTER a successful deploy (+ migration), and which cached KV keys to clear afterwards so the app
|
|
1204
|
+
* rebuilds them from the freshly-seeded rows. Declarative — the deploy plugin runs no app code, so
|
|
1205
|
+
* the app-specific seed lives in `pluginConfigs.deploy.seed` (config) rather than a deploy hook.
|
|
1206
|
+
*
|
|
1207
|
+
* @example
|
|
1208
|
+
* ```ts
|
|
1209
|
+
* deploy: { seed: { file: "db/seed.sql", resetKv: [{ binding: "BOARDS_KV", key: "boards:index" }] } }
|
|
1210
|
+
* ```
|
|
1211
|
+
*/
|
|
1212
|
+
type SeedConfig = {
|
|
1213
|
+
/** SQL file executed against the remote D1 (e.g. "db/seed.sql"). */file: string; /** The d1 binding to target when more than one database is configured (e.g. "DB"); the sole one otherwise. */
|
|
1214
|
+
binding?: string; /** Cached KV keys to delete after seeding so reads rebuild from the freshly-seeded DB. */
|
|
1215
|
+
resetKv?: {
|
|
1216
|
+
binding: string;
|
|
1217
|
+
key: string;
|
|
1218
|
+
}[];
|
|
1219
|
+
};
|
|
1220
|
+
/** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
|
|
1221
|
+
type Config$2 = {
|
|
1222
|
+
/**
|
|
1223
|
+
* Wrangler config file generated/updated and read by `wrangler deploy`. Default "wrangler.jsonc".
|
|
1224
|
+
* Also the file parsed in the universal/non-moku path.
|
|
1225
|
+
*/
|
|
1226
|
+
configFile: string;
|
|
1227
|
+
/**
|
|
1228
|
+
* The Worker entry module → wrangler `main` (e.g. "src/cloudflare/worker.ts"). Required for any
|
|
1229
|
+
* real Worker deploy (its absence is wrangler's "Missing entry-point" error).
|
|
1230
|
+
*/
|
|
1231
|
+
entry?: string;
|
|
1232
|
+
/**
|
|
1233
|
+
* Enable Node.js compat → `compatibility_flags: ["nodejs_compat"]`. Needed when the Worker bundle
|
|
1234
|
+
* pulls in Node-flavored code (e.g. composing the deploy/cli tooling into the runtime app).
|
|
1235
|
+
*/
|
|
1236
|
+
nodeCompat?: boolean;
|
|
1237
|
+
/**
|
|
1238
|
+
* Static assets served via `env.<binding>` → the wrangler `assets` block. `spa: true` sets
|
|
1239
|
+
* `not_found_handling: "single-page-application"` so client-routed deep links resolve to index.html.
|
|
1240
|
+
*/
|
|
1241
|
+
assets?: {
|
|
1242
|
+
binding: string;
|
|
1243
|
+
directory: string;
|
|
1244
|
+
spa?: boolean;
|
|
1245
|
+
};
|
|
1246
|
+
/**
|
|
1247
|
+
* Escape hatch — extra top-level wrangler keys merged into the generated config for anything the
|
|
1248
|
+
* typed fields above don't cover (`vars`, `routes`, `observability`, `triggers`, …). The
|
|
1249
|
+
* deploy-managed resource keys (name, compatibility_date, kv_namespaces, r2_buckets, d1_databases,
|
|
1250
|
+
* queues, durable_objects, and the auto-derived Durable Object `migrations`) always win over these.
|
|
1251
|
+
*/
|
|
1252
|
+
wrangler?: Record<string, unknown>;
|
|
1253
|
+
/**
|
|
1254
|
+
* Standing CI/automated default for `run()`. When true (or when stdout is non-TTY) the deploy
|
|
1255
|
+
* never prompts and auto-confirms every gate; `run({ ci })` overrides it per call. CF credentials
|
|
1256
|
+
* are read from the env (CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID) via `ctx.env`. Default false.
|
|
1257
|
+
*/
|
|
1258
|
+
ci: boolean; /** Globs watched by `dev()` to trigger a Moku-site rebuild. */
|
|
1259
|
+
watch: string[];
|
|
1260
|
+
/**
|
|
1261
|
+
* Standing default web-site build hook (e.g. `() => webApp.cli.build()`). Usually passed
|
|
1262
|
+
* call-time to `dev` / `deploy` via `opts.webBuild` (the script-driven path); set here only for
|
|
1263
|
+
* a persistent default. When absent, dev() falls back to `buildCommand`, then auto-detects
|
|
1264
|
+
* `scripts/build.ts`.
|
|
1265
|
+
*/
|
|
1266
|
+
webBuild?: WebBuild; /** Shell rebuild fallback (e.g. "bun run scripts/build.ts"); empty → auto-detect scripts/build.ts. */
|
|
1267
|
+
buildCommand: string; /** Apply local D1 migrations before serving when a d1 manifest is present. */
|
|
1268
|
+
migrateLocal: boolean; /** Debounce window (ms) coalescing rapid file changes into one rebuild. */
|
|
1269
|
+
debounceMs: number;
|
|
1270
|
+
/**
|
|
1271
|
+
* The remote seed `deploy({ seed: true })` loads AFTER a successful deploy (+ migration): the SQL
|
|
1272
|
+
* file and the cached KV keys to reset. Omit it and `deploy({ seed: true })` reports a clear
|
|
1273
|
+
* "no seed configured" error instead of silently doing nothing.
|
|
1274
|
+
*/
|
|
1275
|
+
seed?: SeedConfig;
|
|
1276
|
+
};
|
|
1277
|
+
/**
|
|
1278
|
+
* Discriminated union of per-INSTANCE resource descriptors. Each resource plugin's `deployManifest()`
|
|
1279
|
+
* returns an ARRAY of these (one per configured instance). `name` is the base Cloudflare resource
|
|
1280
|
+
* name (stage-suffixed downstream via {@link stageName}); `binding` is the stable env var. Durable
|
|
1281
|
+
* Objects carry no provisioned `name` — they ship with the Worker script — and declare the exported
|
|
1282
|
+
* `className` instead.
|
|
1283
|
+
*/
|
|
1284
|
+
type ResourceManifest = {
|
|
1285
|
+
kind: "r2";
|
|
1286
|
+
name: string;
|
|
1287
|
+
binding: string;
|
|
1288
|
+
upload?: string;
|
|
1289
|
+
} | {
|
|
1290
|
+
kind: "kv";
|
|
1291
|
+
name: string;
|
|
1292
|
+
binding: string;
|
|
1293
|
+
} | {
|
|
1294
|
+
kind: "d1";
|
|
1295
|
+
name: string;
|
|
1296
|
+
binding: string;
|
|
1297
|
+
migrations?: string;
|
|
1298
|
+
} | {
|
|
1299
|
+
kind: "queue";
|
|
1300
|
+
name: string;
|
|
1301
|
+
binding: string;
|
|
1302
|
+
consumer?: boolean;
|
|
1303
|
+
maxBatchTimeout?: number;
|
|
1304
|
+
} | {
|
|
1305
|
+
kind: "do";
|
|
1306
|
+
binding: string;
|
|
1307
|
+
className: string;
|
|
1308
|
+
};
|
|
1309
|
+
/**
|
|
1310
|
+
* The whole deploy manifest the pipeline consumes (assembled, or caller-supplied for the
|
|
1311
|
+
* universal path).
|
|
1312
|
+
*/
|
|
1313
|
+
type ExternalManifest = {
|
|
1314
|
+
/** Worker name. */name: string; /** Cloudflare compatibility date. */
|
|
1315
|
+
compatibilityDate: string; /** Resource descriptors to provision. */
|
|
1316
|
+
resources: ResourceManifest[];
|
|
1317
|
+
};
|
|
1318
|
+
/**
|
|
1319
|
+
* A resource that already exists in the account (the infra preflight discovered it), with its
|
|
1320
|
+
* captured Cloudflare id when the kind has one (kv namespace id, d1 database id).
|
|
1321
|
+
*/
|
|
1322
|
+
type ProvisionedRef = {
|
|
1323
|
+
/** The resource descriptor from the manifest. */resource: ResourceManifest; /** The existing resource's Cloudflare id (kv/d1 only). */
|
|
1324
|
+
id?: string;
|
|
1325
|
+
};
|
|
1326
|
+
/**
|
|
1327
|
+
* Read-only infra preflight result: which declared resources already exist in the Cloudflare
|
|
1328
|
+
* account, which are still missing and must be created, and which ship with the Worker. Produced by
|
|
1329
|
+
* `checkInfra()`. Durable Objects are neither "exists" nor "missing" — the planner never queries the
|
|
1330
|
+
* account for them and never API-provisions them; they are created by `wrangler deploy` (the
|
|
1331
|
+
* auto-derived DO migration), so they get their own `ships` bucket instead of masquerading as
|
|
1332
|
+
* already-existing.
|
|
1333
|
+
*/
|
|
1334
|
+
type InfraPlan = {
|
|
1335
|
+
/** Resolved account display name (or id when the name is unknown). */account: string; /** Resolved Cloudflare account id used for the existence checks. */
|
|
1336
|
+
accountId: string; /** Declared resources the account listing confirmed already exist (with captured ids where applicable). */
|
|
1337
|
+
exists: ProvisionedRef[]; /** Declared resources that do not yet exist and must be created. */
|
|
1338
|
+
missing: ResourceManifest[]; /** Durable Objects that ship with the Worker — created by `wrangler deploy`, never API-provisioned. */
|
|
1339
|
+
ships: ResourceManifest[];
|
|
1340
|
+
};
|
|
1341
|
+
/**
|
|
1342
|
+
* A resource that failed to provision, with the (branded) error message captured so the guided flow
|
|
1343
|
+
* can show WHICH resource failed and why — instead of aborting the whole run on the first failure.
|
|
1344
|
+
*/
|
|
1345
|
+
type ProvisionFailure = {
|
|
1346
|
+
/** The resource descriptor that failed to create. */resource: ResourceManifest; /** The captured error message (e.g. the branded wrangler failure). */
|
|
1347
|
+
error: string;
|
|
1348
|
+
};
|
|
1349
|
+
/**
|
|
1350
|
+
* Outcome of acting on an {@link InfraPlan}: the resources just created, those skipped because they
|
|
1351
|
+
* already existed, those that ship with the Worker (Durable Objects — not created here), those that
|
|
1352
|
+
* FAILED to create, and the merged id map (binding → Cloudflare id) for the config writer.
|
|
1353
|
+
* Provisioning is resilient — a single resource failure is captured here, not thrown, so the guided
|
|
1354
|
+
* flow can report a clear per-resource result.
|
|
1355
|
+
*/
|
|
1356
|
+
type ProvisionResult = {
|
|
1357
|
+
/** Resources created during this run. */created: ProvisionedRef[]; /** Resources skipped because they already existed. */
|
|
1358
|
+
skipped: ProvisionedRef[]; /** Durable Objects that ship with the Worker — not created at the provision step (`wrangler deploy` does). */
|
|
1359
|
+
bundled: ResourceManifest[]; /** Resources that failed to create (captured, not thrown). */
|
|
1360
|
+
failed: ProvisionFailure[]; /** Merged binding → Cloudflare id map (existing + created) for writeWranglerConfig. */
|
|
1361
|
+
ids: Record<string, string>;
|
|
1362
|
+
};
|
|
1363
|
+
/**
|
|
1364
|
+
* Structured outcome of a deploy run (the value `run()` / `cli.deploy()` now resolve to, replacing
|
|
1365
|
+
* the old `void`) so a script can branch on the result instead of guessing from a thrown error. It
|
|
1366
|
+
* is also WHY the post-deploy migration + seed live inside `run()`: the report's `status` is the
|
|
1367
|
+
* single source of truth for whether the worker actually went live, so those remote-DB steps run
|
|
1368
|
+
* only on a successful deploy and never on an aborted one.
|
|
1369
|
+
*
|
|
1370
|
+
* `ok` is true only when the worker is live AND every requested post-step (migration, seed) also
|
|
1371
|
+
* succeeded. `status` is the coarse outcome: `"deployed"` (live, all post-steps ok), `"aborted"`
|
|
1372
|
+
* (a gate was declined or auth was never set up — nothing shipped), `"failed"` (a step errored).
|
|
1373
|
+
*/
|
|
1374
|
+
type DeployReport = {
|
|
1375
|
+
/** True only when the worker is live and every requested post-step (migration, seed) succeeded. */ok: boolean; /** Coarse outcome: "deployed" (live + post-steps ok), "aborted" (a gate declined / auth not set up), "failed" (a step errored). */
|
|
1376
|
+
status: "deployed" | "aborted" | "failed"; /** The resolved deploy stage (resource-name suffix; "production" is bare). */
|
|
1377
|
+
stage: string; /** The live worker URL once `wrangler deploy` succeeded — set even if a later migration/seed failed. */
|
|
1378
|
+
url?: string; /** Provisioning tally: resources created, already-existing, shipped-with-the-Worker (DOs), and failed to create. */
|
|
1379
|
+
resources?: {
|
|
1380
|
+
created: number;
|
|
1381
|
+
exists: number;
|
|
1382
|
+
bundled: number;
|
|
1383
|
+
failed: number;
|
|
1384
|
+
}; /** Remote D1 migration outcome — "skipped" (not requested), "applied", or "failed". */
|
|
1385
|
+
migration: "skipped" | "applied" | "failed"; /** Remote seed outcome — "skipped" (not requested), "applied", or "failed". */
|
|
1386
|
+
seed: "skipped" | "applied" | "failed"; /** Wall-clock duration of the whole run (ms). */
|
|
1387
|
+
elapsedMs: number; /** Branded failure message(s) — empty when `ok`; one per failed step otherwise. */
|
|
1388
|
+
errors: string[];
|
|
1389
|
+
};
|
|
1390
|
+
/** Result of verifying the `.env` Cloudflare API token and resolving its account. */
|
|
1391
|
+
type AuthStatus = {
|
|
1392
|
+
/** Whether the token is present and active. */ok: boolean; /** Resolved account display name (or id when the name is unknown). */
|
|
1393
|
+
account: string; /** Resolved Cloudflare account id. */
|
|
1394
|
+
accountId: string; /** Token scopes, when discoverable (empty otherwise). */
|
|
1395
|
+
scopes: string[];
|
|
1396
|
+
};
|
|
1397
|
+
/** One Cloudflare API-token permission group the app's manifest requires. */
|
|
1398
|
+
type PermissionGroup = {
|
|
1399
|
+
/** Human-readable group label, e.g. "Account · D1". */group: string; /** Permission scope. */
|
|
1400
|
+
scope: "Edit" | "Read"; /** Why it is required, e.g. "d1", "queue", "deploy", "account". */
|
|
1401
|
+
reason: string; /** Whether Cloudflare's stock "Edit Cloudflare Workers" template already includes it. */
|
|
1402
|
+
inBaseTemplate: boolean;
|
|
1403
|
+
};
|
|
1404
|
+
/** The Cloudflare API token this app requires, derived from its manifest. */
|
|
1405
|
+
type TokenRequirement = {
|
|
1406
|
+
/** The recommended starting template. */base: "Edit Cloudflare Workers"; /** The full set of permission groups required. */
|
|
1407
|
+
required: PermissionGroup[]; /** Groups NOT in the base template that the user must add (e.g. D1, Queues). */
|
|
1408
|
+
toAdd: PermissionGroup[];
|
|
1409
|
+
};
|
|
1410
|
+
//#endregion
|
|
1411
|
+
//#region src/plugins/cli/types.d.ts
|
|
1412
|
+
/**
|
|
1413
|
+
* Resolved configuration for the cli plugin. The cli surface is configuration-free: the dev port is
|
|
1414
|
+
* NOT set here (it comes only from `dev({ port })`), so there are no keys to set under
|
|
1415
|
+
* `pluginConfigs.cli`.
|
|
1416
|
+
*/
|
|
1417
|
+
type Config$1 = Record<string, never>;
|
|
1418
|
+
/** Public api surface of the cli plugin, mounted at app.cli.*. */
|
|
1419
|
+
type Api = {
|
|
1420
|
+
/**
|
|
1421
|
+
* Run the Worker locally via Wrangler (delegates to deploy.dev). The dev port comes only from
|
|
1422
|
+
* `opts.port` — the consumer passes it (e.g. parsed from its own CLI flags); it defaults to 8787
|
|
1423
|
+
* when omitted. A failure renders a branded `✗` line and sets a non-zero exit code rather than
|
|
1424
|
+
* throwing a raw stack trace.
|
|
1425
|
+
*
|
|
1426
|
+
* @param opts - Optional port, stage, cold-build hook, and incremental change hook.
|
|
1427
|
+
* @param opts.port - Local dev port to bind. Defaults to 8787 when omitted.
|
|
1428
|
+
* @param opts.stage - Stage for the generated wrangler config's resource names. Falls back to the
|
|
1429
|
+
* `--stage` CLI flag, then the app's configured stage. Pass it explicitly from a script for a
|
|
1430
|
+
* self-documenting `dev({ stage })` instead of relying on the hidden flag.
|
|
1431
|
+
* @param opts.webBuild - Cold-build the web site (e.g. `() => webApp.cli.build()`); also the
|
|
1432
|
+
* per-change rebuild when `onChange` is omitted.
|
|
1433
|
+
* @param opts.onChange - Incremental per-change rebuild (e.g. `changes => webApp.cli.update(changes)`),
|
|
1434
|
+
* so each change rebuilds only the changed paths instead of a full `webBuild()` every keystroke.
|
|
1435
|
+
* @param opts.seed - Load the configured seed (`pluginConfigs.deploy.seed`) into the LOCAL D1 and
|
|
1436
|
+
* reset its cached KV keys before serving — the local analogue of `deploy({ seed: true })`.
|
|
1437
|
+
* @returns Resolves when the dev session ends.
|
|
1438
|
+
* @example
|
|
1439
|
+
* ```ts
|
|
1440
|
+
* await app.cli.dev({ stage: "dev", port: 7878, seed: true, webBuild: () => web.cli.build(), onChange: c => web.cli.update(c) });
|
|
1441
|
+
* ```
|
|
1442
|
+
*/
|
|
1443
|
+
dev(opts?: {
|
|
1444
|
+
port?: number;
|
|
1445
|
+
stage?: string;
|
|
1446
|
+
webBuild?: WebBuild;
|
|
1447
|
+
onChange?: OnChange;
|
|
1448
|
+
seed?: boolean;
|
|
1449
|
+
}): Promise<void>;
|
|
1450
|
+
/**
|
|
1451
|
+
* One-command Cloudflare deploy (delegates to deploy.run), then — only on a successful deploy —
|
|
1452
|
+
* the requested post-deploy remote steps (migration, seed). Guided/interactive by default; pass
|
|
1453
|
+
* `{ ci: true }` for the automated/non-interactive path (CI). Unlike the other verbs this RETURNS
|
|
1454
|
+
* the structured {@link DeployReport} (so a script can branch on the outcome) AND, on a failure,
|
|
1455
|
+
* renders a branded `✗` line + sets a non-zero exit code rather than throwing a raw stack trace.
|
|
1456
|
+
*
|
|
1457
|
+
* @param opts - Optional ci flag, stage, a web build hook, and the post-deploy migration/seed flags.
|
|
1458
|
+
* @param opts.ci - Automated mode: never prompts, auto-confirms. Omit/false → guided on a TTY.
|
|
1459
|
+
* @param opts.stage - Stage for the generated wrangler config's resource names (e.g. "production",
|
|
1460
|
+
* "staging"). Falls back to the `--stage` CLI flag, then the app's configured stage. Pass it
|
|
1461
|
+
* explicitly from a script for a self-documenting `deploy({ stage })` instead of the hidden flag.
|
|
1462
|
+
* @param opts.webBuild - Build the web site first (e.g. `() => webApp.cli.build()`), before deploy.
|
|
1463
|
+
* @param opts.migration - Apply pending remote D1 migrations after a successful deploy (skipped on abort).
|
|
1464
|
+
* @param opts.seed - Load the configured remote seed (`pluginConfigs.deploy.seed`) after a
|
|
1465
|
+
* successful deploy (+ migration); skipped on an aborted deploy.
|
|
1466
|
+
* @returns The deploy report (status, url, resource tally, migration/seed outcome, errors).
|
|
1467
|
+
* @example
|
|
1468
|
+
* ```ts
|
|
1469
|
+
* const report = await app.cli.deploy({ webBuild: () => web.cli.build(), migration: true, seed: true });
|
|
1470
|
+
* if (report.status === "aborted") return; // creds not set up yet — nothing shipped
|
|
1471
|
+
* ```
|
|
1472
|
+
*/
|
|
1473
|
+
deploy(opts?: {
|
|
1474
|
+
ci?: boolean;
|
|
1475
|
+
stage?: string;
|
|
1476
|
+
webBuild?: WebBuild;
|
|
1477
|
+
migration?: boolean;
|
|
1478
|
+
seed?: boolean;
|
|
1479
|
+
}): Promise<DeployReport>;
|
|
1480
|
+
/**
|
|
1481
|
+
* Seed a configured D1 database from a SQL file (delegates to deploy.seed). Local by default
|
|
1482
|
+
* (applies the database's migrations first so its tables exist, then executes the file);
|
|
1483
|
+
* `opts.remote` seeds Cloudflare. A failure renders a branded `✗` line and sets a non-zero exit
|
|
1484
|
+
* code rather than throwing.
|
|
1485
|
+
*
|
|
1486
|
+
* @param sqlFile - Path to the SQL file to execute (e.g. "db/seed.sql").
|
|
1487
|
+
* @param opts - Optional options.
|
|
1488
|
+
* @param opts.binding - The d1 binding to target when more than one is configured (e.g. "DB").
|
|
1489
|
+
* @param opts.remote - Seed the remote (Cloudflare) D1 instead of the local one.
|
|
1490
|
+
* @returns Resolves once the seed completes (or after a failure is rendered).
|
|
1491
|
+
* @example
|
|
1492
|
+
* ```ts
|
|
1493
|
+
* await app.cli.seed("db/seed.sql"); // local; --stage honored
|
|
1494
|
+
* ```
|
|
1495
|
+
*/
|
|
1496
|
+
seed(sqlFile: string, opts?: {
|
|
1497
|
+
binding?: string;
|
|
1498
|
+
remote?: boolean;
|
|
1499
|
+
}): Promise<void>;
|
|
1500
|
+
/**
|
|
1501
|
+
* Verify the `.env` Cloudflare token (no sub), or print the config-derived token-creation
|
|
1502
|
+
* guidance (`"setup"`). Delegates to deploy.verifyAuth() / deploy.tokenInstructions().
|
|
1503
|
+
*
|
|
1504
|
+
* @param sub - Pass "setup" to print token guidance; omit to verify the current token.
|
|
1505
|
+
* @returns Resolves once the auth check or guidance render completes.
|
|
1506
|
+
* @example
|
|
1507
|
+
* ```ts
|
|
1508
|
+
* await app.cli.auth(); // verify the current token
|
|
1509
|
+
* await app.cli.auth("setup"); // print what token to create
|
|
1510
|
+
* ```
|
|
1511
|
+
*/
|
|
1512
|
+
auth(sub?: "setup"): Promise<void>;
|
|
1513
|
+
/**
|
|
1514
|
+
* One-shot preflight report: token + account (verifyAuth) and infra drift (checkInfra),
|
|
1515
|
+
* each rendered as a branded check line.
|
|
1516
|
+
*
|
|
1517
|
+
* @returns Resolves once the report is printed.
|
|
1518
|
+
* @example
|
|
1519
|
+
* ```ts
|
|
1520
|
+
* await app.cli.doctor();
|
|
1521
|
+
* ```
|
|
1522
|
+
*/
|
|
1523
|
+
doctor(): Promise<void>;
|
|
1524
|
+
/**
|
|
1525
|
+
* Print the resolved Cloudflare account for the current `.env` token (delegates to verifyAuth).
|
|
1526
|
+
*
|
|
1527
|
+
* @returns Resolves once the account summary is printed.
|
|
1528
|
+
* @example
|
|
1529
|
+
* ```ts
|
|
1530
|
+
* await app.cli.whoami();
|
|
1531
|
+
* ```
|
|
1532
|
+
*/
|
|
1533
|
+
whoami(): Promise<void>;
|
|
1534
|
+
/**
|
|
1535
|
+
* Run an arbitrary `wrangler` command through the branded CLI — the escape hatch for subcommands
|
|
1536
|
+
* Moku does not wrap (kv / d1 / r2 / queues / secret / tail / …). Streams wrangler's output.
|
|
1537
|
+
*
|
|
1538
|
+
* @param args - The wrangler arguments (e.g. ["kv", "namespace", "list"]).
|
|
1539
|
+
* @returns Resolves once wrangler exits.
|
|
1540
|
+
* @example
|
|
1541
|
+
* ```ts
|
|
1542
|
+
* await app.cli.wrangler(["kv", "namespace", "list"]);
|
|
1543
|
+
* ```
|
|
1544
|
+
*/
|
|
1545
|
+
wrangler(args: string[]): Promise<void>;
|
|
1546
|
+
};
|
|
1547
|
+
//#endregion
|
|
1548
|
+
//#region src/plugins/cli/index.d.ts
|
|
1549
|
+
/**
|
|
1550
|
+
* Standard tier (node-only) — developer-facing CLI surface.
|
|
1551
|
+
*
|
|
1552
|
+
* Mounts `app.cli.dev()` and `app.cli.deploy()` as thin passthroughs to deployPlugin.
|
|
1553
|
+
* Hooks subscribe to the global deploy:phase / provision:resource / deploy:complete events
|
|
1554
|
+
* and print a live progress TUI via the injected ctx.log core API.
|
|
1555
|
+
*
|
|
1556
|
+
* Inline lambdas on `api`/`hooks` preserve event-name inference so the hook map keys
|
|
1557
|
+
* are constrained to `WorkerEvents` keys (spec/15 §5).
|
|
1558
|
+
*
|
|
1559
|
+
* @see README.md
|
|
1560
|
+
*/
|
|
1561
|
+
declare const cliPlugin: import("@moku-labs/core").PluginInstance<"cli", Config$1, Record<string, never>, Api, {}> & Record<never, never>;
|
|
1562
|
+
//#endregion
|
|
1563
|
+
//#region src/plugins/deploy/index.d.ts
|
|
1564
|
+
/**
|
|
1565
|
+
* Complex tier (node-only) — build-time deploy orchestrator over the five resource plugins.
|
|
1566
|
+
*
|
|
1567
|
+
* Assembles each resource plugin's deployManifest() via ctx.require, provisions resources,
|
|
1568
|
+
* generates/updates wrangler config, uploads the R2 upload dir, and runs wrangler deploy.
|
|
1569
|
+
* Also supports a universal path: run({ manifest }) uses a caller-supplied manifest verbatim.
|
|
1570
|
+
*
|
|
1571
|
+
* Emits only the global events `deploy:phase`, `deploy:complete`, and `provision:resource`
|
|
1572
|
+
* (declared in WorkerEvents — no per-plugin events block).
|
|
1573
|
+
*
|
|
1574
|
+
* @see README.md
|
|
1575
|
+
*/
|
|
1576
|
+
declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", Config$2, Record<string, never>, {
|
|
1577
|
+
run(opts?: {
|
|
1578
|
+
ci?: boolean;
|
|
1579
|
+
stage?: string;
|
|
1580
|
+
webBuild?: WebBuild;
|
|
1581
|
+
manifest?: ExternalManifest;
|
|
1582
|
+
migration?: boolean;
|
|
1583
|
+
seed?: boolean;
|
|
1584
|
+
}): Promise<DeployReport>;
|
|
1585
|
+
dev(opts?: {
|
|
1586
|
+
port?: number;
|
|
1587
|
+
stage?: string;
|
|
1588
|
+
webBuild?: WebBuild;
|
|
1589
|
+
onChange?: OnChange;
|
|
1590
|
+
seed?: boolean;
|
|
1591
|
+
}): Promise<void>;
|
|
1592
|
+
seed(sqlFile: string, opts?: {
|
|
1593
|
+
stage?: string;
|
|
1594
|
+
binding?: string;
|
|
1595
|
+
remote?: boolean;
|
|
1596
|
+
}): Promise<void>;
|
|
1597
|
+
init: (opts?: {
|
|
1598
|
+
ci?: boolean;
|
|
1599
|
+
}) => Promise<void>;
|
|
1600
|
+
checkInfra: () => Promise<InfraPlan>;
|
|
1601
|
+
provisionInfra: (plan: InfraPlan) => Promise<ProvisionResult>;
|
|
1602
|
+
verifyAuth: () => Promise<AuthStatus>;
|
|
1603
|
+
requiredToken: () => TokenRequirement;
|
|
1604
|
+
ciToken: () => PermissionGroup[];
|
|
1605
|
+
tokenInstructions: () => string;
|
|
1606
|
+
wrangler: (args: string[]) => Promise<void>;
|
|
1607
|
+
}, {}> & Record<never, never>;
|
|
1608
|
+
//#endregion
|
|
1082
1609
|
//#region src/plugins/stage/index.d.ts
|
|
1083
1610
|
/** This plugin's own config type (Nano tier — declared inline, no types.ts). */
|
|
1084
1611
|
type Config = {
|
|
@@ -1181,7 +1708,7 @@ declare const createPlugin: import("@moku-labs/core").BoundCreatePluginFunction<
|
|
|
1181
1708
|
current: () => "production" | "development" | "test";
|
|
1182
1709
|
}>]>>;
|
|
1183
1710
|
/** The core-bound app factory; wrapped by {@link createApp} to bridge `config.stage`. */
|
|
1184
|
-
declare const boundCreateApp: <const ExtraPlugins extends readonly import("@moku-labs/core").AnyPluginInstance[] = readonly []>(options?: import("@moku-labs/core").CreateAppOptions<WorkerConfig, WorkerEvents, (import("@moku-labs/core").PluginInstance<"bindings", Config$
|
|
1711
|
+
declare const boundCreateApp: <const ExtraPlugins extends readonly import("@moku-labs/core").AnyPluginInstance[] = readonly []>(options?: import("@moku-labs/core").CreateAppOptions<WorkerConfig, WorkerEvents, (import("@moku-labs/core").PluginInstance<"bindings", Config$7, Record<string, never>, BindingsApi, {}> & Record<never, never>) | (import("@moku-labs/core").PluginInstance<"server", ServerConfig, ServerState, Api$4, {
|
|
1185
1712
|
"server:matched": {
|
|
1186
1713
|
path: string;
|
|
1187
1714
|
method: string;
|
|
@@ -1194,7 +1721,7 @@ declare const boundCreateApp: <const ExtraPlugins extends readonly import("@moku
|
|
|
1194
1721
|
isDev: () => boolean;
|
|
1195
1722
|
isProduction: () => boolean;
|
|
1196
1723
|
current: () => "production" | "development" | "test";
|
|
1197
|
-
}>]>> | undefined) => import("@moku-labs/core").App<WorkerConfig, WorkerEvents, (import("@moku-labs/core").PluginInstance<"bindings", Config$
|
|
1724
|
+
}>]>> | undefined) => import("@moku-labs/core").App<WorkerConfig, WorkerEvents, (import("@moku-labs/core").PluginInstance<"bindings", Config$7, Record<string, never>, BindingsApi, {}> & Record<never, never>) | (import("@moku-labs/core").PluginInstance<"server", ServerConfig, ServerState, Api$4, {
|
|
1198
1725
|
"server:matched": {
|
|
1199
1726
|
path: string;
|
|
1200
1727
|
method: string;
|