@bluelibs/runner-dev 4.2.1 → 4.3.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/AI.md +5 -0
- package/LICENSE.md +7 -0
- package/README.md +60 -3
- package/dist/cli/generators/artifact.d.ts +17 -0
- package/dist/cli/generators/artifact.js +77 -0
- package/dist/cli/generators/artifact.js.map +1 -0
- package/dist/cli/generators/common.d.ts +4 -0
- package/dist/cli/generators/common.js +24 -0
- package/dist/cli/generators/common.js.map +1 -0
- package/dist/cli/generators/templates.d.ts +13 -0
- package/dist/cli/generators/templates.js +138 -0
- package/dist/cli/generators/templates.js.map +1 -0
- package/dist/cli/init.js +226 -70
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/query.js +5 -0
- package/dist/cli/query.js.map +1 -1
- package/dist/cli.js +40 -8
- package/dist/cli.js.map +1 -1
- package/dist/resources/live.resource.d.ts +2 -0
- package/dist/resources/live.resource.js +4 -1
- package/dist/resources/live.resource.js.map +1 -1
- package/dist/ui/.vite/manifest.json +2 -2
- package/dist/ui/assets/docs-8CBtAUCD.css +1 -0
- package/dist/ui/assets/docs-Cx3wVsAT.js +419 -0
- package/dist/ui/assets/docs-Cx3wVsAT.js.map +1 -0
- package/package.json +2 -2
- package/dist/ui/assets/docs-78NQSj_E.css +0 -1
- package/dist/ui/assets/docs-CpHhwKvy.js +0 -416
- package/dist/ui/assets/docs-CpHhwKvy.js.map +0 -1
package/AI.md
CHANGED
|
@@ -304,6 +304,11 @@ npx @bluelibs/runner-dev query 'query { tasks { id } }' \
|
|
|
304
304
|
--entry-file ./src/main.ts --export app
|
|
305
305
|
```
|
|
306
306
|
|
|
307
|
+
Selection logic:
|
|
308
|
+
- If `--entry-file` is provided, dry-run mode is used (no server; requires ts-node).
|
|
309
|
+
- Otherwise, the CLI uses a remote endpoint via `--endpoint` or `ENDPOINT/GRAPHQL_ENDPOINT`.
|
|
310
|
+
- If neither is provided, the command errors.
|
|
311
|
+
|
|
307
312
|
**Generate a project overview:**
|
|
308
313
|
```bash
|
|
309
314
|
ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev overview --details 10
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2024-present Theodor Diaconu <theodor@bluelibs.com>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -120,6 +120,19 @@ Help:
|
|
|
120
120
|
npx @bluelibs/runner-dev --help
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
+
Run CLI from TypeScript (no build):
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Using ts-node ESM loader
|
|
127
|
+
node --loader ts-node/esm src/cli.ts query 'query { tasks { id } }' --entry-file ./src/main.ts
|
|
128
|
+
|
|
129
|
+
# Or with tsx (recommended DX)
|
|
130
|
+
npx tsx src/cli.ts query 'query { tasks { id } }' --entry-file ./src/main.ts
|
|
131
|
+
|
|
132
|
+
# Or classic ts-node when configured
|
|
133
|
+
npx ts-node src/cli.ts query 'query { tasks { id } }' --entry-file ./src/main.ts
|
|
134
|
+
```
|
|
135
|
+
|
|
123
136
|
Create new project:
|
|
124
137
|
|
|
125
138
|
```bash
|
|
@@ -154,6 +167,43 @@ npx @bluelibs/runner-dev new my-awesome-app --install --run-tests
|
|
|
154
167
|
npx @bluelibs/runner-dev new my-awesome-app --install --run
|
|
155
168
|
```
|
|
156
169
|
|
|
170
|
+
Scaffold artifacts (resource | task | event | tag | taskMiddleware | resourceMiddleware):
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# General form
|
|
174
|
+
npx @bluelibs/runner-dev new <kind> <name> [--ns app] [--dir src] [--export] [--dry]
|
|
175
|
+
|
|
176
|
+
# Examples
|
|
177
|
+
npx @bluelibs/runner-dev new resource user-service --ns app --dir src --export
|
|
178
|
+
npx @bluelibs/runner-dev new task create-user --ns app.users --dir src --export
|
|
179
|
+
npx @bluelibs/runner-dev new event user-registered --ns app.users --dir src --export
|
|
180
|
+
npx @bluelibs/runner-dev new tag http --ns app.web --dir src --export
|
|
181
|
+
npx @bluelibs/runner-dev new taskMiddleware auth --ns app --dir src --export
|
|
182
|
+
npx @bluelibs/runner-dev new resourceMiddleware soft-delete --ns app --dir src --export
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Flags for artifact scaffolding:
|
|
186
|
+
|
|
187
|
+
- `--ns` / `--namespace`: namespace used when generating the id (default: `app`)
|
|
188
|
+
- `--id <id>`: explicit id override (for example: `app.tasks.save`)
|
|
189
|
+
- `--dir <dir>`: base directory under which files are created (default: `src`)
|
|
190
|
+
- `--export`: append a re-export to an `index.ts` in the target folder for better auto-import UX
|
|
191
|
+
- `--dry` / `--dry-run`: print the generated file without writing it
|
|
192
|
+
|
|
193
|
+
Conventions:
|
|
194
|
+
|
|
195
|
+
- Generated ids follow: `<namespace>.(resources|tasks|events|tags|middleware).<kebab-name>`
|
|
196
|
+
- Folders:
|
|
197
|
+
- resources: `src/resources`
|
|
198
|
+
- tasks: `src/tasks`
|
|
199
|
+
- events: `src/events`
|
|
200
|
+
- tags: `src/tags`
|
|
201
|
+
- task middleware: `src/middleware/task`
|
|
202
|
+
- resource middleware: `src/middleware/resource`
|
|
203
|
+
- The `--export` flag will add `export * from './<name>';` to the folder's `index.ts` (created if missing).
|
|
204
|
+
|
|
205
|
+
Tip: run `npx @bluelibs/runner-dev new help` to see the full usage and examples for artifact scaffolding.
|
|
206
|
+
|
|
157
207
|
Note: the `new` command requires the target directory to be empty. If the directory exists and is not empty, the command aborts with an error.
|
|
158
208
|
|
|
159
209
|
The project name must contain only letters, numbers, dashes, and underscores.
|
|
@@ -170,9 +220,10 @@ Ping endpoint:
|
|
|
170
220
|
ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev ping
|
|
171
221
|
```
|
|
172
222
|
|
|
173
|
-
Run a query:
|
|
223
|
+
Run a query (two modes):
|
|
174
224
|
|
|
175
225
|
```bash
|
|
226
|
+
# Remote mode (HTTP endpoint)
|
|
176
227
|
ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev query 'query { tasks { id } }'
|
|
177
228
|
|
|
178
229
|
# With variables and pretty output
|
|
@@ -184,9 +235,12 @@ ENDPOINT=http://localhost:1337/graphql \
|
|
|
184
235
|
|
|
185
236
|
# Add a namespace sugar to inject idIncludes/filter automatically
|
|
186
237
|
ENDPOINT=http://localhost:1337/graphql npx @bluelibs/runner-dev query 'query { tasks { id } }' --namespace task.
|
|
238
|
+
|
|
239
|
+
# Dry‑run mode (no server) — uses a TS entry file
|
|
240
|
+
npx @bluelibs/runner-dev query 'query { tasks { id } }' --entry-file ./src/main.ts
|
|
187
241
|
```
|
|
188
242
|
|
|
189
|
-
Dry‑run (no server):
|
|
243
|
+
Dry‑run (no server) details:
|
|
190
244
|
|
|
191
245
|
```bash
|
|
192
246
|
# Using a TS entry file default export
|
|
@@ -201,7 +255,10 @@ npx @bluelibs/runner-dev query 'query { tasks { id } }' \
|
|
|
201
255
|
# - Dry‑run compiles your entry, builds the Runner Store in-memory, and executes the query against
|
|
202
256
|
# an in-memory GraphQL schema. No HTTP server is started.
|
|
203
257
|
# - TypeScript only. Requires ts-node at runtime. If missing, you'll be prompted to install it.
|
|
204
|
-
# -
|
|
258
|
+
# - Selection logic:
|
|
259
|
+
# - If --entry-file is provided, dry‑run mode is used (no server).
|
|
260
|
+
# - Otherwise, remote mode is used via --endpoint or ENDPOINT/GRAPHQL_ENDPOINT.
|
|
261
|
+
# - If neither an endpoint nor an entry file is provided, the command errors.
|
|
205
262
|
```
|
|
206
263
|
|
|
207
264
|
Project overview (Markdown):
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ArtifactKind } from "./common";
|
|
2
|
+
export type ArtifactArgs = {
|
|
3
|
+
kind: Exclude<ArtifactKind, "project">;
|
|
4
|
+
name: string;
|
|
5
|
+
namespace: string;
|
|
6
|
+
baseDir: string;
|
|
7
|
+
dryRun?: boolean;
|
|
8
|
+
addIndex?: boolean;
|
|
9
|
+
explicitId?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function scaffoldArtifact({ kind, name, namespace, baseDir, dryRun, addIndex, explicitId, }: ArtifactArgs): Promise<{
|
|
12
|
+
filePath: string;
|
|
13
|
+
id: string;
|
|
14
|
+
relDir: string;
|
|
15
|
+
exported: boolean;
|
|
16
|
+
content?: string;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.scaffoldArtifact = scaffoldArtifact;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const common_1 = require("./common");
|
|
11
|
+
const templates_1 = require("./templates");
|
|
12
|
+
async function scaffoldArtifact({ kind, name, namespace, baseDir, dryRun = false, addIndex = false, explicitId, }) {
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
const kebab = (0, common_1.toKebabCase)(name);
|
|
15
|
+
const camel = (0, common_1.toCamelCase)(name);
|
|
16
|
+
const pascal = (0, common_1.toPascalCase)(name);
|
|
17
|
+
const id = explicitId ||
|
|
18
|
+
`${namespace}.${kind === "resource"
|
|
19
|
+
? "resources"
|
|
20
|
+
: kind === "task"
|
|
21
|
+
? "tasks"
|
|
22
|
+
: kind === "event"
|
|
23
|
+
? "events"
|
|
24
|
+
: kind === "tag"
|
|
25
|
+
? "tags"
|
|
26
|
+
: kind === "taskMiddleware" || kind === "resourceMiddleware"
|
|
27
|
+
? "middleware"
|
|
28
|
+
: kind}.${kebab}`;
|
|
29
|
+
const relDir = kind === "resource"
|
|
30
|
+
? path_1.default.join(baseDir, "resources")
|
|
31
|
+
: kind === "task"
|
|
32
|
+
? path_1.default.join(baseDir, "tasks")
|
|
33
|
+
: kind === "event"
|
|
34
|
+
? path_1.default.join(baseDir, "events")
|
|
35
|
+
: kind === "tag"
|
|
36
|
+
? path_1.default.join(baseDir, "tags")
|
|
37
|
+
: kind === "taskMiddleware"
|
|
38
|
+
? path_1.default.join(baseDir, "middleware", "task")
|
|
39
|
+
: path_1.default.join(baseDir, "middleware", "resource");
|
|
40
|
+
const filePath = path_1.default.join(cwd, relDir, `${kebab}.ts`);
|
|
41
|
+
const header = `/**\n * Generated by runner-dev new ${kind} ${name}\n * - Namespace: ${namespace}\n * - File: ${path_1.default.relative(cwd, filePath)}\n */`;
|
|
42
|
+
const content = kind === "resource"
|
|
43
|
+
? (0, templates_1.resourceTemplate)({ header, id, camel, pascal })
|
|
44
|
+
: kind === "task"
|
|
45
|
+
? (0, templates_1.taskTemplate)({ header, id, camel, pascal })
|
|
46
|
+
: kind === "event"
|
|
47
|
+
? (0, templates_1.eventTemplate)({ header, id, camel, pascal })
|
|
48
|
+
: kind === "tag"
|
|
49
|
+
? (0, templates_1.tagTemplate)({ header, id, camel, pascal })
|
|
50
|
+
: kind === "taskMiddleware"
|
|
51
|
+
? (0, templates_1.taskMiddlewareTemplate)({ header, id, camel, pascal })
|
|
52
|
+
: (0, templates_1.resourceMiddlewareTemplate)({ header, id, camel, pascal });
|
|
53
|
+
if (dryRun) {
|
|
54
|
+
return { filePath, id, relDir, exported: false, content };
|
|
55
|
+
}
|
|
56
|
+
await promises_1.default.mkdir(path_1.default.dirname(filePath), { recursive: true });
|
|
57
|
+
await promises_1.default.writeFile(filePath, content, { encoding: "utf8" });
|
|
58
|
+
let exported = false;
|
|
59
|
+
if (addIndex) {
|
|
60
|
+
const indexPath = path_1.default.join(cwd, relDir, "index.ts");
|
|
61
|
+
const exportLine = `export * from './${kebab}';\n`;
|
|
62
|
+
try {
|
|
63
|
+
const existing = fs_1.default.existsSync(indexPath)
|
|
64
|
+
? await promises_1.default.readFile(indexPath, "utf8")
|
|
65
|
+
: "";
|
|
66
|
+
if (!existing.includes(exportLine)) {
|
|
67
|
+
await promises_1.default.appendFile(indexPath, exportLine, { encoding: "utf8" });
|
|
68
|
+
}
|
|
69
|
+
exported = true;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
exported = false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return { filePath, id, relDir, exported };
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../../src/cli/generators/artifact.ts"],"names":[],"mappings":";;;;;AAuBA,4CA4FC;AAnHD,4CAAoB;AACpB,2DAA8B;AAC9B,gDAAwB;AACxB,qCAAgF;AAChF,2CAOqB;AAYd,KAAK,UAAU,gBAAgB,CAAC,EACrC,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,OAAO,EACP,MAAM,GAAG,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AK,EAAE,OAAO,EAAE,CAAC;IAC5D,CAAC;IAED,MAAM,kBAAG,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,kBAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAE7D,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG,oBAAoB,KAAK,MAAM,CAAC;QACnD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC;gBACvC,CAAC,CAAC,MAAM,kBAAG,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBACvC,CAAC,CAAC,EAAE,CAAC;YACP,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;gBACnC,MAAM,kBAAG,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;YACpE,CAAC;YACD,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC;QAAC,MAAM,CAAC;YACP,QAAQ,GAAG,KAAK,CAAC;QACnB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type ArtifactKind = "project" | "resource" | "task" | "event" | "tag" | "taskMiddleware" | "resourceMiddleware";
|
|
2
|
+
export declare function toKebabCase(input: string): string;
|
|
3
|
+
export declare function toCamelCase(input: string): string;
|
|
4
|
+
export declare function toPascalCase(input: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toKebabCase = toKebabCase;
|
|
4
|
+
exports.toCamelCase = toCamelCase;
|
|
5
|
+
exports.toPascalCase = toPascalCase;
|
|
6
|
+
function toKebabCase(input) {
|
|
7
|
+
return input
|
|
8
|
+
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
9
|
+
.replace(/[^a-zA-Z0-9]+/g, "-")
|
|
10
|
+
.replace(/^-+|-+$/g, "")
|
|
11
|
+
.toLowerCase();
|
|
12
|
+
}
|
|
13
|
+
function toCamelCase(input) {
|
|
14
|
+
const s = toKebabCase(input)
|
|
15
|
+
.split("-")
|
|
16
|
+
.map((p, i) => (i === 0 ? p : p.charAt(0).toUpperCase() + p.slice(1)))
|
|
17
|
+
.join("");
|
|
18
|
+
return s || "item";
|
|
19
|
+
}
|
|
20
|
+
function toPascalCase(input) {
|
|
21
|
+
const s = toCamelCase(input);
|
|
22
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/cli/generators/common.ts"],"names":[],"mappings":";;AASA,kCAMC;AAED,kCAMC;AAED,oCAGC;AAnBD,SAAgB,WAAW,CAAC,KAAa;IACvC,OAAO,KAAK;SACT,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;SAC9B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,WAAW,EAAE,CAAC;AACnB,CAAC;AAED,SAAgB,WAAW,CAAC,KAAa;IACvC,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC;SACzB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACrE,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,OAAO,CAAC,IAAI,MAAM,CAAC;AACrB,CAAC;AAED,SAAgB,YAAY,CAAC,KAAa;IACxC,MAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type TemplateParams = {
|
|
2
|
+
header: string;
|
|
3
|
+
id: string;
|
|
4
|
+
camel: string;
|
|
5
|
+
pascal: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function resourceTemplate({ header, id, camel, pascal, }: TemplateParams): string;
|
|
8
|
+
export declare function taskTemplate({ header, id, camel, pascal, }: TemplateParams): string;
|
|
9
|
+
export declare function eventTemplate({ header, id, camel, pascal, }: TemplateParams): string;
|
|
10
|
+
export declare function tagTemplate({ header, id, camel, pascal, }: TemplateParams): string;
|
|
11
|
+
export declare function taskMiddlewareTemplate({ header, id, camel, pascal, }: TemplateParams): string;
|
|
12
|
+
export declare function resourceMiddlewareTemplate({ header, id, camel, pascal, }: TemplateParams): string;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resourceTemplate = resourceTemplate;
|
|
4
|
+
exports.taskTemplate = taskTemplate;
|
|
5
|
+
exports.eventTemplate = eventTemplate;
|
|
6
|
+
exports.tagTemplate = tagTemplate;
|
|
7
|
+
exports.taskMiddlewareTemplate = taskMiddlewareTemplate;
|
|
8
|
+
exports.resourceMiddlewareTemplate = resourceMiddlewareTemplate;
|
|
9
|
+
function resourceTemplate({ header, id, camel, pascal, }) {
|
|
10
|
+
return `${header}
|
|
11
|
+
import { resource } from '@bluelibs/runner';
|
|
12
|
+
|
|
13
|
+
export interface ${pascal}Config {
|
|
14
|
+
// Add your config shape here
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ${pascal}Value {
|
|
18
|
+
// The resource value (what init returns)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const ${camel} = resource({
|
|
22
|
+
id: '${id}',
|
|
23
|
+
// tags: [],
|
|
24
|
+
// dependencies: { /* other resources */ },
|
|
25
|
+
init: async (_config: ${pascal}Config, _deps): Promise<${pascal}Value> => {
|
|
26
|
+
// Initialize and return the resource value
|
|
27
|
+
return {} as ${pascal}Value;
|
|
28
|
+
},
|
|
29
|
+
// dispose: async (value, _config, _deps) => { /* clean up */ },
|
|
30
|
+
});
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
function taskTemplate({ header, id, camel, pascal, }) {
|
|
34
|
+
return `${header}
|
|
35
|
+
import { task } from '@bluelibs/runner';
|
|
36
|
+
|
|
37
|
+
export interface ${pascal}Input {
|
|
38
|
+
// Define input fields
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ${pascal}Result {
|
|
42
|
+
// Define result fields
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const ${camel} = task({
|
|
46
|
+
id: '${id}',
|
|
47
|
+
// middleware: [],
|
|
48
|
+
// dependencies: { /* resources */ },
|
|
49
|
+
run: async (_input: ${pascal}Input, _deps): Promise<${pascal}Result> => {
|
|
50
|
+
return {} as ${pascal}Result;
|
|
51
|
+
},
|
|
52
|
+
// inputSchema,
|
|
53
|
+
// resultSchema,
|
|
54
|
+
});
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
function eventTemplate({ header, id, camel, pascal, }) {
|
|
58
|
+
return `${header}
|
|
59
|
+
import { event } from '@bluelibs/runner';
|
|
60
|
+
|
|
61
|
+
export interface ${pascal}Payload {
|
|
62
|
+
// Define event payload
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const ${camel} = event<${pascal}Payload>({
|
|
66
|
+
id: '${id}',
|
|
67
|
+
// tags: [],
|
|
68
|
+
});
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
function tagTemplate({ header, id, camel, pascal, }) {
|
|
72
|
+
return `${header}
|
|
73
|
+
import { tag } from '@bluelibs/runner';
|
|
74
|
+
|
|
75
|
+
export interface ${pascal}Config {
|
|
76
|
+
// Optional config carried by the tag (available via extract())
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface ${pascal}InputContract {
|
|
80
|
+
// Optional contract for inputs when used on tasks/middleware/resources
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ${pascal}ResultContract {
|
|
84
|
+
// Optional contract for results
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export const ${camel} = tag<${pascal}Config, ${pascal}InputContract, ${pascal}ResultContract>({
|
|
88
|
+
id: '${id}',
|
|
89
|
+
});
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
function taskMiddlewareTemplate({ header, id, camel, pascal, }) {
|
|
93
|
+
return `${header}
|
|
94
|
+
import { taskMiddleware } from '@bluelibs/runner';
|
|
95
|
+
|
|
96
|
+
export interface ${pascal}Config {
|
|
97
|
+
// Configuration passed via .with({ ... })
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface ${pascal}Input {
|
|
101
|
+
// The task input before middleware
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface ${pascal}Output {
|
|
105
|
+
// The task output after middleware
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const ${camel} = taskMiddleware<${pascal}Config, ${pascal}Input, ${pascal}Output>({
|
|
109
|
+
id: '${id}',
|
|
110
|
+
// everywhere: true,
|
|
111
|
+
run: async ({ task, next }, _deps, _config) => {
|
|
112
|
+
// pre-process task.input
|
|
113
|
+
const result = await next(task.input as ${pascal}Input);
|
|
114
|
+
// post-process result
|
|
115
|
+
return result as ${pascal}Output;
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
`;
|
|
119
|
+
}
|
|
120
|
+
function resourceMiddlewareTemplate({ header, id, camel, pascal, }) {
|
|
121
|
+
return `${header}
|
|
122
|
+
import { resourceMiddleware } from '@bluelibs/runner';
|
|
123
|
+
|
|
124
|
+
export interface ${pascal}Config {
|
|
125
|
+
// Configuration passed via .with({ ... })
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const ${camel} = resourceMiddleware<${pascal}Config>({
|
|
129
|
+
id: '${id}',
|
|
130
|
+
run: async ({ next }, _deps, _config) => {
|
|
131
|
+
const value = await next();
|
|
132
|
+
// Wrap or augment the resource value here
|
|
133
|
+
return value;
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/cli/generators/templates.ts"],"names":[],"mappings":";;AAOA,4CA4BC;AAED,oCA4BC;AAED,sCAkBC;AAED,kCAyBC;AAED,wDAgCC;AAED,gEAsBC;AAnKD,SAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,EAAE,EACF,KAAK,EACL,MAAM,GACS;IACf,OAAO,GAAG,MAAM;;;mBAGC,MAAM;;;;mBAIN,MAAM;;;;eAIV,KAAK;SACX,EAAE;;;0BAGe,MAAM,2BAA2B,MAAM;;mBAE9C,MAAM;;;;CAIxB,CAAC;AACF,CAAC;AAED,SAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,EAAE,EACF,KAAK,EACL,MAAM,GACS;IACf,OAAO,GAAG,MAAM;;;mBAGC,MAAM;;;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