@moku-labs/worker 0.1.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/README.md +376 -0
- package/dist/cli.cjs +743 -0
- package/dist/cli.d.cts +139 -0
- package/dist/cli.d.mts +139 -0
- package/dist/cli.mjs +740 -0
- package/dist/config-AjH57AmD.d.cts +36 -0
- package/dist/config-AjH57AmD.d.mts +36 -0
- package/dist/index.cjs +544 -0
- package/dist/index.d.cts +962 -0
- package/dist/index.d.mts +960 -0
- package/dist/index.mjs +491 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/storage-BaQ6BBtl.cjs +990 -0
- package/dist/storage-bL-U_fkA.mjs +882 -0
- package/package.json +77 -0
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { PluginCtx, PluginInstance } from "@moku-labs/core";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/cli/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* @file cli plugin — type definitions (Config, Api).
|
|
6
|
+
*/
|
|
7
|
+
/** Resolved configuration for the cli plugin. Flat; complete defaults so omission never yields undefined. */
|
|
8
|
+
type Config$1 = {
|
|
9
|
+
/**
|
|
10
|
+
* Default local dev port forwarded to deploy.dev when dev() gets no port.
|
|
11
|
+
* Passed through to `wrangler dev --port <n>`.
|
|
12
|
+
*
|
|
13
|
+
* @default 8787
|
|
14
|
+
*/
|
|
15
|
+
readonly port: number;
|
|
16
|
+
};
|
|
17
|
+
/** Public api surface of the cli plugin, mounted at app.cli.*. */
|
|
18
|
+
type Api = {
|
|
19
|
+
/**
|
|
20
|
+
* Run the Worker locally via Wrangler (delegates to deploy.dev).
|
|
21
|
+
* Defaults port to the configured value (8787) when called with no opts.
|
|
22
|
+
*
|
|
23
|
+
* @param opts - Optional port override.
|
|
24
|
+
* @param opts.port - Local dev port to bind.
|
|
25
|
+
* @returns Resolves when the dev session ends.
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* await app.cli.dev(); // port 8787
|
|
29
|
+
* await app.cli.dev({ port: 3000 }); // port 3000
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
dev(opts?: {
|
|
33
|
+
port?: number;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* One-command guided Cloudflare deploy (delegates to deploy.run).
|
|
37
|
+
* Forwards opts verbatim — passes undefined when called with no opts.
|
|
38
|
+
*
|
|
39
|
+
* @param opts - Optional guided/yes flags.
|
|
40
|
+
* @param opts.guided - Walk through each step interactively.
|
|
41
|
+
* @param opts.yes - Skip confirmation prompts (non-interactive).
|
|
42
|
+
* @returns Resolves once the deploy completes.
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* await app.cli.deploy({ guided: true });
|
|
46
|
+
* await app.cli.deploy({ yes: true }); // CI
|
|
47
|
+
* await app.cli.deploy(); // no opts → undefined forwarded
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
deploy(opts?: {
|
|
51
|
+
guided?: boolean;
|
|
52
|
+
yes?: boolean;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/plugins/cli/index.d.ts
|
|
57
|
+
/**
|
|
58
|
+
* Standard tier (node-only) — developer-facing CLI surface.
|
|
59
|
+
*
|
|
60
|
+
* Mounts `app.cli.dev()` and `app.cli.deploy()` as thin passthroughs to deployPlugin.
|
|
61
|
+
* Hooks subscribe to the global deploy:phase / provision:resource / deploy:complete events
|
|
62
|
+
* and print a live progress TUI via the injected ctx.log core API.
|
|
63
|
+
*
|
|
64
|
+
* Inline lambdas on `api`/`hooks` preserve event-name inference so the hook map keys
|
|
65
|
+
* are constrained to `WorkerEvents` keys (spec/15 §5).
|
|
66
|
+
*
|
|
67
|
+
* @see README.md
|
|
68
|
+
*/
|
|
69
|
+
declare const cliPlugin: import("@moku-labs/core").PluginInstance<"cli", Config$1, Record<string, never>, Api, {}> & Record<never, never>;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/plugins/deploy/types.d.ts
|
|
72
|
+
/** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
|
|
73
|
+
type Config = {
|
|
74
|
+
/**
|
|
75
|
+
* Wrangler config file generated/updated and read by `wrangler deploy`. Default "wrangler.jsonc".
|
|
76
|
+
* Also the file parsed in the universal/non-moku path.
|
|
77
|
+
*/
|
|
78
|
+
configFile: string;
|
|
79
|
+
/**
|
|
80
|
+
* CI mode. When true (or when stdout is non-TTY), the guided flow NEVER prompts.
|
|
81
|
+
* CF credentials are read from the Node env (CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID).
|
|
82
|
+
* Default false.
|
|
83
|
+
*/
|
|
84
|
+
ci: boolean;
|
|
85
|
+
};
|
|
86
|
+
/** Discriminated union of resource descriptors returned by each plugin's deployManifest(). */
|
|
87
|
+
type ResourceManifest = {
|
|
88
|
+
kind: "r2";
|
|
89
|
+
bucket: string;
|
|
90
|
+
upload?: string;
|
|
91
|
+
} | {
|
|
92
|
+
kind: "kv";
|
|
93
|
+
binding: string;
|
|
94
|
+
} | {
|
|
95
|
+
kind: "d1";
|
|
96
|
+
binding: string;
|
|
97
|
+
migrations?: string;
|
|
98
|
+
} | {
|
|
99
|
+
kind: "queue";
|
|
100
|
+
producers: string[];
|
|
101
|
+
} | {
|
|
102
|
+
kind: "do";
|
|
103
|
+
bindings: Record<string, string>;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* The whole deploy manifest the pipeline consumes (assembled, or caller-supplied for the
|
|
107
|
+
* universal path).
|
|
108
|
+
*/
|
|
109
|
+
type ExternalManifest = {
|
|
110
|
+
/** Worker name. */name: string; /** Cloudflare compatibility date. */
|
|
111
|
+
compatibilityDate: string; /** Resource descriptors to provision. */
|
|
112
|
+
resources: ResourceManifest[];
|
|
113
|
+
};
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/plugins/deploy/index.d.ts
|
|
116
|
+
/**
|
|
117
|
+
* Complex tier (node-only) — build-time deploy orchestrator over the five resource plugins.
|
|
118
|
+
*
|
|
119
|
+
* Assembles each resource plugin's deployManifest() via ctx.require, provisions resources,
|
|
120
|
+
* generates/updates wrangler config, uploads the R2 upload dir, and runs wrangler deploy.
|
|
121
|
+
* Also supports a universal path: run({ manifest }) uses a caller-supplied manifest verbatim.
|
|
122
|
+
*
|
|
123
|
+
* @see README.md
|
|
124
|
+
*/
|
|
125
|
+
declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", Config, Record<string, never>, {
|
|
126
|
+
run(opts?: {
|
|
127
|
+
guided?: boolean;
|
|
128
|
+
yes?: boolean;
|
|
129
|
+
manifest?: ExternalManifest;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
dev: (opts?: {
|
|
132
|
+
port?: number;
|
|
133
|
+
}) => Promise<void>;
|
|
134
|
+
init: (opts?: {
|
|
135
|
+
ci?: boolean;
|
|
136
|
+
}) => Promise<void>;
|
|
137
|
+
}, {}> & Record<never, never>;
|
|
138
|
+
//#endregion
|
|
139
|
+
export { type ExternalManifest, type ResourceManifest, cliPlugin, deployPlugin };
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { PluginCtx, PluginInstance } from "@moku-labs/core";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/cli/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* @file cli plugin — type definitions (Config, Api).
|
|
6
|
+
*/
|
|
7
|
+
/** Resolved configuration for the cli plugin. Flat; complete defaults so omission never yields undefined. */
|
|
8
|
+
type Config$1 = {
|
|
9
|
+
/**
|
|
10
|
+
* Default local dev port forwarded to deploy.dev when dev() gets no port.
|
|
11
|
+
* Passed through to `wrangler dev --port <n>`.
|
|
12
|
+
*
|
|
13
|
+
* @default 8787
|
|
14
|
+
*/
|
|
15
|
+
readonly port: number;
|
|
16
|
+
};
|
|
17
|
+
/** Public api surface of the cli plugin, mounted at app.cli.*. */
|
|
18
|
+
type Api = {
|
|
19
|
+
/**
|
|
20
|
+
* Run the Worker locally via Wrangler (delegates to deploy.dev).
|
|
21
|
+
* Defaults port to the configured value (8787) when called with no opts.
|
|
22
|
+
*
|
|
23
|
+
* @param opts - Optional port override.
|
|
24
|
+
* @param opts.port - Local dev port to bind.
|
|
25
|
+
* @returns Resolves when the dev session ends.
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* await app.cli.dev(); // port 8787
|
|
29
|
+
* await app.cli.dev({ port: 3000 }); // port 3000
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
dev(opts?: {
|
|
33
|
+
port?: number;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* One-command guided Cloudflare deploy (delegates to deploy.run).
|
|
37
|
+
* Forwards opts verbatim — passes undefined when called with no opts.
|
|
38
|
+
*
|
|
39
|
+
* @param opts - Optional guided/yes flags.
|
|
40
|
+
* @param opts.guided - Walk through each step interactively.
|
|
41
|
+
* @param opts.yes - Skip confirmation prompts (non-interactive).
|
|
42
|
+
* @returns Resolves once the deploy completes.
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* await app.cli.deploy({ guided: true });
|
|
46
|
+
* await app.cli.deploy({ yes: true }); // CI
|
|
47
|
+
* await app.cli.deploy(); // no opts → undefined forwarded
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
deploy(opts?: {
|
|
51
|
+
guided?: boolean;
|
|
52
|
+
yes?: boolean;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/plugins/cli/index.d.ts
|
|
57
|
+
/**
|
|
58
|
+
* Standard tier (node-only) — developer-facing CLI surface.
|
|
59
|
+
*
|
|
60
|
+
* Mounts `app.cli.dev()` and `app.cli.deploy()` as thin passthroughs to deployPlugin.
|
|
61
|
+
* Hooks subscribe to the global deploy:phase / provision:resource / deploy:complete events
|
|
62
|
+
* and print a live progress TUI via the injected ctx.log core API.
|
|
63
|
+
*
|
|
64
|
+
* Inline lambdas on `api`/`hooks` preserve event-name inference so the hook map keys
|
|
65
|
+
* are constrained to `WorkerEvents` keys (spec/15 §5).
|
|
66
|
+
*
|
|
67
|
+
* @see README.md
|
|
68
|
+
*/
|
|
69
|
+
declare const cliPlugin: import("@moku-labs/core").PluginInstance<"cli", Config$1, Record<string, never>, Api, {}> & Record<never, never>;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/plugins/deploy/types.d.ts
|
|
72
|
+
/** deploy plugin configuration. Flat; complete defaults so omission never yields undefined. */
|
|
73
|
+
type Config = {
|
|
74
|
+
/**
|
|
75
|
+
* Wrangler config file generated/updated and read by `wrangler deploy`. Default "wrangler.jsonc".
|
|
76
|
+
* Also the file parsed in the universal/non-moku path.
|
|
77
|
+
*/
|
|
78
|
+
configFile: string;
|
|
79
|
+
/**
|
|
80
|
+
* CI mode. When true (or when stdout is non-TTY), the guided flow NEVER prompts.
|
|
81
|
+
* CF credentials are read from the Node env (CLOUDFLARE_API_TOKEN / CLOUDFLARE_ACCOUNT_ID).
|
|
82
|
+
* Default false.
|
|
83
|
+
*/
|
|
84
|
+
ci: boolean;
|
|
85
|
+
};
|
|
86
|
+
/** Discriminated union of resource descriptors returned by each plugin's deployManifest(). */
|
|
87
|
+
type ResourceManifest = {
|
|
88
|
+
kind: "r2";
|
|
89
|
+
bucket: string;
|
|
90
|
+
upload?: string;
|
|
91
|
+
} | {
|
|
92
|
+
kind: "kv";
|
|
93
|
+
binding: string;
|
|
94
|
+
} | {
|
|
95
|
+
kind: "d1";
|
|
96
|
+
binding: string;
|
|
97
|
+
migrations?: string;
|
|
98
|
+
} | {
|
|
99
|
+
kind: "queue";
|
|
100
|
+
producers: string[];
|
|
101
|
+
} | {
|
|
102
|
+
kind: "do";
|
|
103
|
+
bindings: Record<string, string>;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* The whole deploy manifest the pipeline consumes (assembled, or caller-supplied for the
|
|
107
|
+
* universal path).
|
|
108
|
+
*/
|
|
109
|
+
type ExternalManifest = {
|
|
110
|
+
/** Worker name. */name: string; /** Cloudflare compatibility date. */
|
|
111
|
+
compatibilityDate: string; /** Resource descriptors to provision. */
|
|
112
|
+
resources: ResourceManifest[];
|
|
113
|
+
};
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/plugins/deploy/index.d.ts
|
|
116
|
+
/**
|
|
117
|
+
* Complex tier (node-only) — build-time deploy orchestrator over the five resource plugins.
|
|
118
|
+
*
|
|
119
|
+
* Assembles each resource plugin's deployManifest() via ctx.require, provisions resources,
|
|
120
|
+
* generates/updates wrangler config, uploads the R2 upload dir, and runs wrangler deploy.
|
|
121
|
+
* Also supports a universal path: run({ manifest }) uses a caller-supplied manifest verbatim.
|
|
122
|
+
*
|
|
123
|
+
* @see README.md
|
|
124
|
+
*/
|
|
125
|
+
declare const deployPlugin: import("@moku-labs/core").PluginInstance<"deploy", Config, Record<string, never>, {
|
|
126
|
+
run(opts?: {
|
|
127
|
+
guided?: boolean;
|
|
128
|
+
yes?: boolean;
|
|
129
|
+
manifest?: ExternalManifest;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
dev: (opts?: {
|
|
132
|
+
port?: number;
|
|
133
|
+
}) => Promise<void>;
|
|
134
|
+
init: (opts?: {
|
|
135
|
+
ci?: boolean;
|
|
136
|
+
}) => Promise<void>;
|
|
137
|
+
}, {}> & Record<never, never>;
|
|
138
|
+
//#endregion
|
|
139
|
+
export { type ExternalManifest, type ResourceManifest, cliPlugin, deployPlugin };
|