@bluelibs/runner-dev 6.0.0 → 6.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/AI.md +11 -0
- package/README.md +48 -37
- package/dist/cli/generators/artifact.js +2 -14
- package/dist/cli/generators/artifact.js.map +1 -1
- package/dist/cli/generators/common.d.ts +1 -0
- package/dist/cli/generators/common.js +22 -0
- package/dist/cli/generators/common.js.map +1 -1
- package/dist/cli/generators/printNewHelp.js +2 -2
- package/dist/cli/generators/printNewHelp.js.map +1 -1
- package/dist/cli/generators/scaffold/templates/README.md.js +7 -1
- package/dist/cli/generators/scaffold/templates/README.md.js.map +1 -1
- package/dist/cli/generators/scaffold/templates/package.json.d.ts +2 -2
- package/dist/cli/generators/scaffold/templates/package.json.js +2 -2
- package/dist/cli/generators/scaffold/templates/src/main.ts.js +8 -10
- package/dist/cli/generators/scaffold/templates/src/main.ts.js.map +1 -1
- package/dist/cli/generators/templates.js +62 -62
- package/dist/cli/generators/templates.js.map +1 -1
- package/dist/resources/models/initializeFromStore.utils.js +62 -18
- package/dist/resources/models/initializeFromStore.utils.js.map +1 -1
- package/dist/ui/.vite/manifest.json +1 -1
- package/dist/ui/assets/{docs-Btkv97Ls.js → docs-CHvYnckk.js} +2 -2
- package/dist/ui/assets/{docs-Btkv97Ls.js.map → docs-CHvYnckk.js.map} +1 -1
- package/dist/utils/lane-resources.d.ts +1 -1
- package/dist/utils/lane-resources.js +1 -1
- package/dist/utils/lane-resources.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/AI.md
CHANGED
|
@@ -33,6 +33,17 @@ Runner-Dev is a powerful development toolkit for applications built with the **@
|
|
|
33
33
|
| `RunOptions.initMode` | `RunOptions.lifecycleMode` (+ disposal budgets) |
|
|
34
34
|
| `Resource.tunnelInfo` | Removed (hard switch to Event Lane + RPC Lane surfaces) |
|
|
35
35
|
|
|
36
|
+
## Runner 6.1 Migration Notes
|
|
37
|
+
|
|
38
|
+
- Temporal middleware now supports per-key partitioning through `keyBuilder(taskId, input)` on `rateLimit`, `debounce`, and `throttle`.
|
|
39
|
+
- User resources are no longer transparent:
|
|
40
|
+
- root resources can register tasks/resources/middleware directly and be passed to `run(...)`
|
|
41
|
+
- canonical runtime ids retain each user resource segment
|
|
42
|
+
- `runtime-framework-root` is reserved for internal Runner use
|
|
43
|
+
- `resource.subtree(...)` may now receive a policy array; runner-dev merges those policies into one summarized subtree view.
|
|
44
|
+
- `gateway: true` has been removed from user resources, so any references that skipped a user resource segment need to be updated.
|
|
45
|
+
- Advanced Node integrations should now use `runner.node.rpcLanes` for the internal RPC lanes resource id.
|
|
46
|
+
|
|
36
47
|
## Available GraphQL Queries
|
|
37
48
|
|
|
38
49
|
### System Architecture Queries
|
package/README.md
CHANGED
|
@@ -22,18 +22,20 @@ npx @bluelibs/runner-dev
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
+
import { r } from "@bluelibs/runner";
|
|
25
26
|
import { dev } from "@bluelibs/runner-dev";
|
|
26
27
|
|
|
27
|
-
const app =
|
|
28
|
-
|
|
28
|
+
const app = r
|
|
29
|
+
.resource("app")
|
|
30
|
+
.register([
|
|
29
31
|
// your resources,
|
|
30
32
|
dev, // if you are fine with defaults or
|
|
31
33
|
dev.with({
|
|
32
34
|
port: 1337, // default,
|
|
33
35
|
maxEntries: 10000, // how many logs to keep in the store.
|
|
34
36
|
}),
|
|
35
|
-
]
|
|
36
|
-
|
|
37
|
+
])
|
|
38
|
+
.build();
|
|
37
39
|
```
|
|
38
40
|
|
|
39
41
|
## What you get
|
|
@@ -69,6 +71,17 @@ const app = resource({
|
|
|
69
71
|
| N/A | `Event.transactional`, `Event.parallel`, `Event.eventLane`, `Event.rpcLane`, `Task.rpcLane` |
|
|
70
72
|
| `Resource.tunnelInfo` | Removed (hard switch to lane surfaces) |
|
|
71
73
|
|
|
74
|
+
## Runner 6.1 Migration Notes
|
|
75
|
+
|
|
76
|
+
- Temporal middleware now supports per-key partitioning through `keyBuilder(taskId, input)` on `rateLimit`, `debounce`, and `throttle`.
|
|
77
|
+
- Resource ownership is now fully structural for user resources:
|
|
78
|
+
- normal resources can be registered directly at the root and passed to `run(...)`
|
|
79
|
+
- canonical runtime IDs now retain each user resource segment
|
|
80
|
+
- `runtime-framework-root` is reserved for internal Runner use
|
|
81
|
+
- `resource.subtree(...)` can now compose multiple policies with an array, and runner-dev merges them into one summarized introspection view.
|
|
82
|
+
- `gateway: true` has been removed from user resources. Update any string-based task/resource references that previously relied on transparent user resources.
|
|
83
|
+
- Advanced Node integrations should use the internal RPC lanes resource id `runner.node.rpcLanes`.
|
|
84
|
+
|
|
72
85
|
## Table of Contents
|
|
73
86
|
|
|
74
87
|
- [Quickstart Guide](#quickstart)
|
|
@@ -85,20 +98,20 @@ const app = resource({
|
|
|
85
98
|
Register the Dev resources in your Runner root:
|
|
86
99
|
|
|
87
100
|
```ts
|
|
88
|
-
import {
|
|
101
|
+
import { r } from "@bluelibs/runner";
|
|
89
102
|
import { dev } from "@bluelibs/runner-dev";
|
|
90
103
|
|
|
91
|
-
export const app =
|
|
92
|
-
|
|
93
|
-
register
|
|
104
|
+
export const app = r
|
|
105
|
+
.resource("app")
|
|
106
|
+
.register([
|
|
94
107
|
// You can omit .with() if you are fine with defaults.
|
|
95
108
|
dev.with({
|
|
96
109
|
port: 1337, // default
|
|
97
110
|
maxEntries: 1000, // default
|
|
98
111
|
}),
|
|
99
112
|
// rest of your app.
|
|
100
|
-
]
|
|
101
|
-
|
|
113
|
+
])
|
|
114
|
+
.build();
|
|
102
115
|
```
|
|
103
116
|
|
|
104
117
|
### Accessing the UI
|
|
@@ -224,15 +237,15 @@ runner-dev new resource-middleware soft-delete --ns app --dir src --export
|
|
|
224
237
|
|
|
225
238
|
Flags for artifact scaffolding:
|
|
226
239
|
|
|
227
|
-
- `--ns` / `--namespace`: namespace used
|
|
228
|
-
- `--id <id>`: explicit id override (for example: `
|
|
240
|
+
- `--ns` / `--namespace`: namespace used for folders only, mapped to `<dir>/<ns>/<type>` (default: `app`)
|
|
241
|
+
- `--id <id>`: explicit local id override (for example: `save-user`)
|
|
229
242
|
- `--dir <dir>`: base directory under which files are created (default: `src`)
|
|
230
243
|
- `--export`: append a re-export to an `index.ts` in the target folder for better auto-import UX
|
|
231
244
|
- `--dry` / `--dry-run`: print the generated file without writing it
|
|
232
245
|
|
|
233
246
|
Conventions:
|
|
234
247
|
|
|
235
|
-
- Generated ids
|
|
248
|
+
- Generated ids are local ids only and default to the kebab-cased artifact name
|
|
236
249
|
- Folders:
|
|
237
250
|
- resources: `src/resources`
|
|
238
251
|
- tasks: `src/tasks`
|
|
@@ -654,42 +667,40 @@ All Dev UI modals (code viewer, execute, trace view, log details, stats overlay)
|
|
|
654
667
|
- Define an event:
|
|
655
668
|
|
|
656
669
|
```ts
|
|
657
|
-
import {
|
|
670
|
+
import { r } from "@bluelibs/runner";
|
|
658
671
|
|
|
659
|
-
export const userCreated = event<{ id: string; name: string }>(
|
|
660
|
-
id: "evt.user.created",
|
|
661
|
-
});
|
|
672
|
+
export const userCreated = r.event<{ id: string; name: string }>("userCreated").build();
|
|
662
673
|
```
|
|
663
674
|
|
|
664
675
|
- Use it in a task:
|
|
665
676
|
|
|
666
677
|
```ts
|
|
667
|
-
import {
|
|
678
|
+
import { r } from "@bluelibs/runner";
|
|
668
679
|
import { userCreated } from "./events";
|
|
669
680
|
|
|
670
|
-
export const createUser =
|
|
671
|
-
|
|
672
|
-
dependencies
|
|
673
|
-
async
|
|
681
|
+
export const createUser = r
|
|
682
|
+
.task<{ name: string }>("createUser")
|
|
683
|
+
.dependencies({ userCreated })
|
|
684
|
+
.run(async (input, { userCreated }) => {
|
|
674
685
|
const id = crypto.randomUUID();
|
|
675
686
|
await userCreated({ id, name: input.name });
|
|
676
687
|
return { id };
|
|
677
|
-
}
|
|
678
|
-
|
|
688
|
+
})
|
|
689
|
+
.build();
|
|
679
690
|
```
|
|
680
691
|
|
|
681
692
|
- Emit logs:
|
|
682
693
|
|
|
683
694
|
```ts
|
|
684
|
-
import { globals,
|
|
695
|
+
import { globals, r } from "@bluelibs/runner";
|
|
685
696
|
|
|
686
|
-
export const logSomething =
|
|
687
|
-
|
|
688
|
-
dependencies
|
|
689
|
-
async
|
|
697
|
+
export const logSomething = r
|
|
698
|
+
.task("logSomething")
|
|
699
|
+
.dependencies({ logger: globals.resources.logger })
|
|
700
|
+
.run(async (_i, { logger }) => {
|
|
690
701
|
logger.info("Hello world!");
|
|
691
|
-
}
|
|
692
|
-
|
|
702
|
+
})
|
|
703
|
+
.build();
|
|
693
704
|
```
|
|
694
705
|
|
|
695
706
|
## Notes on Overrides
|
|
@@ -726,12 +737,12 @@ The hot-swapping system enables:
|
|
|
726
737
|
Add the swap manager to your app:
|
|
727
738
|
|
|
728
739
|
```ts
|
|
729
|
-
import {
|
|
740
|
+
import { r } from "@bluelibs/runner";
|
|
730
741
|
import { resources as dev } from "@bluelibs/runner-dev";
|
|
731
742
|
|
|
732
|
-
export const app =
|
|
733
|
-
|
|
734
|
-
register
|
|
743
|
+
export const app = r
|
|
744
|
+
.resource("app")
|
|
745
|
+
.register([
|
|
735
746
|
// Core dev resources
|
|
736
747
|
dev.live,
|
|
737
748
|
dev.introspector,
|
|
@@ -741,8 +752,8 @@ export const app = resource({
|
|
|
741
752
|
|
|
742
753
|
// GraphQL server with swap mutations
|
|
743
754
|
dev.server.with({ port: 1337 }),
|
|
744
|
-
]
|
|
745
|
-
|
|
755
|
+
])
|
|
756
|
+
.build();
|
|
746
757
|
```
|
|
747
758
|
|
|
748
759
|
### GraphQL API
|
|
@@ -14,20 +14,8 @@ async function scaffoldArtifact({ kind, name, namespace, baseDir, dryRun = false
|
|
|
14
14
|
const kebab = (0, common_1.toKebabCase)(name);
|
|
15
15
|
const camel = (0, common_1.toCamelCase)(name);
|
|
16
16
|
const pascal = (0, common_1.toPascalCase)(name);
|
|
17
|
-
const id = explicitId ||
|
|
18
|
-
|
|
19
|
-
? "resources"
|
|
20
|
-
: kind === "task"
|
|
21
|
-
? "tasks"
|
|
22
|
-
: kind === "event"
|
|
23
|
-
? "events"
|
|
24
|
-
: kind === "hook"
|
|
25
|
-
? "hooks"
|
|
26
|
-
: kind === "tag"
|
|
27
|
-
? "tags"
|
|
28
|
-
: kind === "task-middleware" || kind === "resource-middleware"
|
|
29
|
-
? "middleware"
|
|
30
|
-
: kind}.${kebab}`;
|
|
17
|
+
const id = explicitId || kebab;
|
|
18
|
+
(0, common_1.validateLocalId)(id);
|
|
31
19
|
// Build directory as: <baseDir>/<namespace segments>/<type-collection>
|
|
32
20
|
const nsSegments = namespace
|
|
33
21
|
.split(".")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../../src/cli/generators/artifact.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../../src/cli/generators/artifact.ts"],"names":[],"mappings":";;;;;AA+BA,4CAqHC;AApJD,4CAAoB;AACpB,2DAA8B;AAC9B,gDAAwB;AACxB,qCAMkB;AAClB,2CAQqB;AAad,KAAK,UAAU,gBAAgB,CAAC,EACrC,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,OAAO,EACP,MAAM,GAAG,KAAK,EACd,QAAQ,GAAG,KAAK,EAChB,UAAU,EACV,KAAK,GAAG,KAAK,GACA;IAOb,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,MAAM,KAAK,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;IAElC,MAAM,EAAE,GAAG,UAAU,IAAI,KAAK,CAAC;IAC/B,IAAA,wBAAe,EAAC,EAAE,CAAC,CAAC;IAEpB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AC,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"}
|
|
@@ -2,3 +2,4 @@ export type ArtifactKind = "project" | "resource" | "task" | "event" | "hook" |
|
|
|
2
2
|
export declare function toKebabCase(input: string): string;
|
|
3
3
|
export declare function toCamelCase(input: string): string;
|
|
4
4
|
export declare function toPascalCase(input: string): string;
|
|
5
|
+
export declare function validateLocalId(id: string): void;
|
|
@@ -3,6 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.toKebabCase = toKebabCase;
|
|
4
4
|
exports.toCamelCase = toCamelCase;
|
|
5
5
|
exports.toPascalCase = toPascalCase;
|
|
6
|
+
exports.validateLocalId = validateLocalId;
|
|
7
|
+
const RESERVED_LOCAL_IDS = new Set([
|
|
8
|
+
"tasks",
|
|
9
|
+
"resources",
|
|
10
|
+
"events",
|
|
11
|
+
"hooks",
|
|
12
|
+
"tags",
|
|
13
|
+
"errors",
|
|
14
|
+
"asyncContexts",
|
|
15
|
+
]);
|
|
6
16
|
function toKebabCase(input) {
|
|
7
17
|
return input
|
|
8
18
|
.replace(/([a-z])([A-Z])/g, "$1-$2")
|
|
@@ -21,4 +31,16 @@ function toPascalCase(input) {
|
|
|
21
31
|
const s = toCamelCase(input);
|
|
22
32
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
23
33
|
}
|
|
34
|
+
function validateLocalId(id) {
|
|
35
|
+
const trimmedId = id.trim();
|
|
36
|
+
if (!trimmedId) {
|
|
37
|
+
throw new Error("Definition id cannot be empty.");
|
|
38
|
+
}
|
|
39
|
+
if (trimmedId.includes(".")) {
|
|
40
|
+
throw new Error(`Definition id "${trimmedId}" is invalid. Use a local id without dots, for example "create-user".`);
|
|
41
|
+
}
|
|
42
|
+
if (RESERVED_LOCAL_IDS.has(trimmedId)) {
|
|
43
|
+
throw new Error(`Definition id "${trimmedId}" is reserved. Choose a different local id.`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
24
46
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/cli/generators/common.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/cli/generators/common.ts"],"names":[],"mappings":";;AAoBA,kCAMC;AAED,kCAMC;AAED,oCAGC;AAED,0CAkBC;AAjDD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,OAAO;IACP,WAAW;IACX,QAAQ;IACR,OAAO;IACP,MAAM;IACN,QAAQ;IACR,eAAe;CAChB,CAAC,CAAC;AAEH,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;AAED,SAAgB,eAAe,CAAC,EAAU;IACxC,MAAM,SAAS,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IAE5B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,kBAAkB,SAAS,uEAAuE,CACnG,CAAC;IACJ,CAAC;IAED,IAAI,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,kBAAkB,SAAS,6CAA6C,CACzE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -37,9 +37,9 @@ function printNewHelp() {
|
|
|
37
37
|
[format_1.c.yellow("--run-tests"), "Run 'npm test' after project scaffold"],
|
|
38
38
|
[
|
|
39
39
|
format_1.c.yellow("--ns=<namespace>"),
|
|
40
|
-
"Namespace for
|
|
40
|
+
"Namespace for folders (default: app). Maps to <dir>/<ns>/<type>.",
|
|
41
41
|
],
|
|
42
|
-
[format_1.c.yellow("--id=<id>"), "Explicit id override (ex:
|
|
42
|
+
[format_1.c.yellow("--id=<id>"), "Explicit local id override (ex: save-user)"],
|
|
43
43
|
[format_1.c.yellow("--dir=<dir>"), "Base directory (default: src)"],
|
|
44
44
|
[format_1.c.yellow("--export"), "Append export to <dir>/.../index.ts"],
|
|
45
45
|
[format_1.c.yellow("--dry"), "Print file to stdout, do not write"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printNewHelp.js","sourceRoot":"","sources":["../../../src/cli/generators/printNewHelp.ts"],"names":[],"mappings":";;AAIA,oCAqFC;AAzFD,sCAA+D;AAE/D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AC,CAAC,GAAG,CAAC,yDAAyD,CAAC,EAAE;YACrE,GAAG,UAAC,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE;YAC3B,GAAG,UAAC,CAAC,GAAG,CACN,iEAAiE,CAClE,EAAE;YACH,GAAG,UAAC,CAAC,GAAG,CACN,4EAA4E,CAC7E,EAAE;SACJ,CAAC,IAAI,CAAC,IAAI,CAAC,EACZ,CAAC,CACF;QACD,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -4,7 +4,7 @@ exports.readme = readme;
|
|
|
4
4
|
function readme(projectName) {
|
|
5
5
|
return `# ${projectName}
|
|
6
6
|
|
|
7
|
-
Generated by \`runner-dev new
|
|
7
|
+
Generated by \`runner-dev new\` for Runner 6.1.
|
|
8
8
|
|
|
9
9
|
## Quick start
|
|
10
10
|
|
|
@@ -19,6 +19,12 @@ The server starts on http://localhost:1337
|
|
|
19
19
|
- Voyager UI: http://localhost:1337/voyager (how the guts of your app look like)
|
|
20
20
|
- Project docs: http://localhost:1337/docs (beautiful docs with live telemetry and easy task and event dispatching)
|
|
21
21
|
|
|
22
|
+
## Runner 6.1 notes
|
|
23
|
+
|
|
24
|
+
- Runtime task and resource ids are structural, so user resource segments stay in canonical ids.
|
|
25
|
+
- \`resource.subtree(...)\` can compose multiple policies with an array.
|
|
26
|
+
- Temporal middleware such as \`rateLimit\`, \`debounce\`, and \`throttle\` support per-key partitioning with \`keyBuilder\`.
|
|
27
|
+
|
|
22
28
|
## Scripts
|
|
23
29
|
|
|
24
30
|
- dev: Run with tsx watch (TypeScript ESM)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"README.md.js","sourceRoot":"","sources":["../../../../../src/cli/generators/scaffold/templates/README.md.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"README.md.js","sourceRoot":"","sources":["../../../../../src/cli/generators/scaffold/templates/README.md.ts"],"names":[],"mappings":";;AAAA,wBAyCC;AAzCD,SAAgB,MAAM,CAAC,WAAmB;IACxC,OAAO,KAAK,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCxB,CAAC;AACF,CAAC"}
|
|
@@ -12,10 +12,10 @@ export declare function packageJson(projectName: string): {
|
|
|
12
12
|
readonly "schema:sdl": "runner-dev schema sdl";
|
|
13
13
|
};
|
|
14
14
|
readonly dependencies: {
|
|
15
|
-
readonly "@bluelibs/runner": "^6.
|
|
15
|
+
readonly "@bluelibs/runner": "^6.1.0";
|
|
16
16
|
};
|
|
17
17
|
readonly devDependencies: {
|
|
18
|
-
readonly "@bluelibs/runner-dev": "^6.
|
|
18
|
+
readonly "@bluelibs/runner-dev": "^6.1.0";
|
|
19
19
|
readonly typescript: "^5.6.3";
|
|
20
20
|
readonly tsx: "^4.19.2";
|
|
21
21
|
readonly jest: "^29.7.0";
|
|
@@ -16,10 +16,10 @@ function packageJson(projectName) {
|
|
|
16
16
|
"schema:sdl": "runner-dev schema sdl",
|
|
17
17
|
},
|
|
18
18
|
dependencies: {
|
|
19
|
-
"@bluelibs/runner": "^6.
|
|
19
|
+
"@bluelibs/runner": "^6.1.0",
|
|
20
20
|
},
|
|
21
21
|
devDependencies: {
|
|
22
|
-
"@bluelibs/runner-dev": "^6.
|
|
22
|
+
"@bluelibs/runner-dev": "^6.1.0",
|
|
23
23
|
typescript: "^5.6.3",
|
|
24
24
|
tsx: "^4.19.2",
|
|
25
25
|
jest: "^29.7.0",
|
|
@@ -2,21 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mainTs = mainTs;
|
|
4
4
|
function mainTs(projectName) {
|
|
5
|
-
return `import {
|
|
5
|
+
return `import { r, run } from '@bluelibs/runner';
|
|
6
6
|
import { dev } from '@bluelibs/runner-dev';
|
|
7
7
|
|
|
8
|
-
// Minimal Runner app using runner-dev's dev resource
|
|
9
|
-
const app = resource({
|
|
10
|
-
|
|
11
|
-
register: [
|
|
8
|
+
// Minimal Runner 6.1 app using a root resource and runner-dev's dev resource
|
|
9
|
+
const app = r.resource('${projectName}')
|
|
10
|
+
.register([
|
|
12
11
|
dev.with({ port: 1337 }),
|
|
13
|
-
]
|
|
14
|
-
|
|
12
|
+
])
|
|
13
|
+
.build();
|
|
15
14
|
|
|
16
15
|
run(app)
|
|
17
|
-
.then(() => {
|
|
18
|
-
|
|
19
|
-
console.log('Runner app started on http://localhost:1337');
|
|
16
|
+
.then(({ logger }) => {
|
|
17
|
+
logger.info('Runner app started on http://localhost:1337');
|
|
20
18
|
})
|
|
21
19
|
.catch((err) => {
|
|
22
20
|
// eslint-disable-next-line no-console
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.ts.js","sourceRoot":"","sources":["../../../../../../src/cli/generators/scaffold/templates/src/main.ts.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"main.ts.js","sourceRoot":"","sources":["../../../../../../src/cli/generators/scaffold/templates/src/main.ts.ts"],"names":[],"mappings":";;AAAA,wBAqBC;AArBD,SAAgB,MAAM,CAAC,WAAmB;IACxC,OAAO;;;;0BAIiB,WAAW;;;;;;;;;;;;;;;CAepC,CAAC;AACF,CAAC"}
|
|
@@ -9,7 +9,7 @@ exports.taskMiddlewareTemplate = taskMiddlewareTemplate;
|
|
|
9
9
|
exports.resourceMiddlewareTemplate = resourceMiddlewareTemplate;
|
|
10
10
|
function resourceTemplate({ header, id, camel, pascal, }) {
|
|
11
11
|
return `${header}
|
|
12
|
-
import {
|
|
12
|
+
import { r } from '@bluelibs/runner';
|
|
13
13
|
|
|
14
14
|
export interface ${pascal}Config {
|
|
15
15
|
// Add your config shape here
|
|
@@ -19,25 +19,25 @@ export interface ${pascal}Value {
|
|
|
19
19
|
// The resource value (what init returns)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export const ${camel} =
|
|
23
|
-
|
|
24
|
-
meta
|
|
22
|
+
export const ${camel} = r
|
|
23
|
+
.resource<${pascal}Config>('${id}')
|
|
24
|
+
.meta({
|
|
25
25
|
title: '${pascal} Resource',
|
|
26
26
|
description: 'TODO: Add description for ${pascal} resource',
|
|
27
|
-
}
|
|
28
|
-
// tags
|
|
29
|
-
// dependencies
|
|
30
|
-
init
|
|
27
|
+
})
|
|
28
|
+
// .tags([])
|
|
29
|
+
// .dependencies({ /* other resources */ })
|
|
30
|
+
.init(async (config, deps): Promise<${pascal}Value> => {
|
|
31
31
|
// Initialize and return the resource value
|
|
32
32
|
return {} as ${pascal}Value;
|
|
33
|
-
}
|
|
34
|
-
// dispose
|
|
35
|
-
|
|
33
|
+
})
|
|
34
|
+
// .dispose(async (value, config, deps) => { /* clean up */ })
|
|
35
|
+
.build();
|
|
36
36
|
`;
|
|
37
37
|
}
|
|
38
38
|
function taskTemplate({ header, id, camel, pascal, }) {
|
|
39
39
|
return `${header}
|
|
40
|
-
import {
|
|
40
|
+
import { r } from '@bluelibs/runner';
|
|
41
41
|
|
|
42
42
|
export interface ${pascal}Input {
|
|
43
43
|
// Define input fields
|
|
@@ -47,65 +47,65 @@ export interface ${pascal}Result {
|
|
|
47
47
|
// Define result fields
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export const ${camel} =
|
|
51
|
-
|
|
52
|
-
meta
|
|
50
|
+
export const ${camel} = r
|
|
51
|
+
.task<${pascal}Input>('${id}')
|
|
52
|
+
.meta({
|
|
53
53
|
title: '${pascal} Task',
|
|
54
54
|
description: 'TODO: Add description for ${pascal} task',
|
|
55
|
-
}
|
|
56
|
-
// middleware
|
|
57
|
-
// dependencies
|
|
58
|
-
run
|
|
55
|
+
})
|
|
56
|
+
// .middleware([])
|
|
57
|
+
// .dependencies({ /* resources */ })
|
|
58
|
+
.run(async (_input, deps): Promise<${pascal}Result> => {
|
|
59
59
|
return {} as ${pascal}Result;
|
|
60
|
-
}
|
|
61
|
-
// inputSchema
|
|
62
|
-
// resultSchema
|
|
63
|
-
|
|
60
|
+
})
|
|
61
|
+
// .inputSchema(...)
|
|
62
|
+
// .resultSchema(...)
|
|
63
|
+
.build();
|
|
64
64
|
`;
|
|
65
65
|
}
|
|
66
66
|
function eventTemplate({ header, id, camel, pascal, }) {
|
|
67
67
|
return `${header}
|
|
68
|
-
import {
|
|
68
|
+
import { r } from '@bluelibs/runner';
|
|
69
69
|
|
|
70
70
|
export interface ${pascal}Payload {
|
|
71
71
|
// Define event payload
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export const ${camel} =
|
|
75
|
-
|
|
76
|
-
meta
|
|
74
|
+
export const ${camel} = r
|
|
75
|
+
.event<${pascal}Payload>('${id}')
|
|
76
|
+
.meta({
|
|
77
77
|
title: '${pascal} Event',
|
|
78
78
|
description: 'TODO: Add description for ${pascal} event',
|
|
79
|
-
}
|
|
80
|
-
// tags
|
|
81
|
-
|
|
79
|
+
})
|
|
80
|
+
// .tags([])
|
|
81
|
+
.build();
|
|
82
82
|
`;
|
|
83
83
|
}
|
|
84
84
|
function hookTemplate({ header, id, camel, pascal, }) {
|
|
85
85
|
return `${header}
|
|
86
|
-
import {
|
|
86
|
+
import { r } from '@bluelibs/runner';
|
|
87
87
|
|
|
88
88
|
export interface ${pascal}Payload {
|
|
89
89
|
// The payload delivered to the hook from the event
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
export const ${camel} =
|
|
93
|
-
|
|
94
|
-
meta
|
|
92
|
+
export const ${camel} = r
|
|
93
|
+
.hook('${id}')
|
|
94
|
+
.meta({
|
|
95
95
|
title: '${pascal} Hook',
|
|
96
96
|
description: 'TODO: Add description for ${pascal} hook',
|
|
97
|
-
}
|
|
98
|
-
// on
|
|
99
|
-
// dependencies
|
|
100
|
-
run
|
|
97
|
+
})
|
|
98
|
+
// .on(someEvent) // import your event and set it here
|
|
99
|
+
// .dependencies({ /* resources */ })
|
|
100
|
+
.run(async (event, deps) => {
|
|
101
101
|
// Implement hook reaction logic
|
|
102
|
-
}
|
|
103
|
-
|
|
102
|
+
})
|
|
103
|
+
.build();
|
|
104
104
|
`;
|
|
105
105
|
}
|
|
106
106
|
function tagTemplate({ header, id, camel, pascal, }) {
|
|
107
107
|
return `${header}
|
|
108
|
-
import {
|
|
108
|
+
import { r } from '@bluelibs/runner';
|
|
109
109
|
|
|
110
110
|
export interface ${pascal}Config {
|
|
111
111
|
// Optional config carried by the tag (available via extract())
|
|
@@ -119,18 +119,18 @@ export interface ${pascal}ResultContract {
|
|
|
119
119
|
// Optional contract for results
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
export const ${camel} =
|
|
123
|
-
|
|
124
|
-
meta
|
|
122
|
+
export const ${camel} = r
|
|
123
|
+
.tag<${pascal}Config, ${pascal}InputContract, ${pascal}ResultContract>('${id}')
|
|
124
|
+
.meta({
|
|
125
125
|
title: '${pascal} Tag',
|
|
126
126
|
description: 'TODO: Add description for ${pascal} tag',
|
|
127
|
-
}
|
|
128
|
-
|
|
127
|
+
})
|
|
128
|
+
.build();
|
|
129
129
|
`;
|
|
130
130
|
}
|
|
131
131
|
function taskMiddlewareTemplate({ header, id, camel, pascal, }) {
|
|
132
132
|
return `${header}
|
|
133
|
-
import {
|
|
133
|
+
import { r } from '@bluelibs/runner';
|
|
134
134
|
|
|
135
135
|
export interface ${pascal}Config {
|
|
136
136
|
// Configuration passed via .with({ ... })
|
|
@@ -144,43 +144,43 @@ export interface ${pascal}Output {
|
|
|
144
144
|
// The task output after middleware
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
export const ${camel} =
|
|
148
|
-
|
|
149
|
-
meta
|
|
147
|
+
export const ${camel} = r
|
|
148
|
+
.taskMiddleware<${pascal}Config, ${pascal}Input, ${pascal}Output>('${id}')
|
|
149
|
+
.meta({
|
|
150
150
|
title: '${pascal} Task Middleware',
|
|
151
151
|
description: 'TODO: Add description for ${pascal} task middleware',
|
|
152
|
-
}
|
|
152
|
+
})
|
|
153
153
|
// Auto-apply globally via resource.subtree({ tasks: { middleware: [${camel}] } })
|
|
154
154
|
// or intercept executions with globals.resources.taskRunner.intercept(...).
|
|
155
|
-
run
|
|
155
|
+
.run(async ({ task, next }, deps, config) => {
|
|
156
156
|
// pre-process task.input
|
|
157
157
|
const result = await next(task.input as ${pascal}Input);
|
|
158
158
|
// post-process result
|
|
159
159
|
return result as ${pascal}Output;
|
|
160
|
-
}
|
|
161
|
-
|
|
160
|
+
})
|
|
161
|
+
.build();
|
|
162
162
|
`;
|
|
163
163
|
}
|
|
164
164
|
function resourceMiddlewareTemplate({ header, id, camel, pascal, }) {
|
|
165
165
|
return `${header}
|
|
166
|
-
import {
|
|
166
|
+
import { r } from '@bluelibs/runner';
|
|
167
167
|
|
|
168
168
|
export interface ${pascal}Config {
|
|
169
169
|
// Configuration passed via .with({ ... })
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
export const ${camel} =
|
|
173
|
-
|
|
174
|
-
meta
|
|
172
|
+
export const ${camel} = r
|
|
173
|
+
.resourceMiddleware<${pascal}Config>('${id}')
|
|
174
|
+
.meta({
|
|
175
175
|
title: '${pascal} Resource Middleware',
|
|
176
176
|
description: 'TODO: Add description for ${pascal} resource middleware',
|
|
177
|
-
}
|
|
178
|
-
run
|
|
177
|
+
})
|
|
178
|
+
.run(async ({ next }, deps, config) => {
|
|
179
179
|
const value = await next();
|
|
180
180
|
// Wrap or augment the resource value here
|
|
181
181
|
return value;
|
|
182
|
-
}
|
|
183
|
-
|
|
182
|
+
})
|
|
183
|
+
.build();
|
|
184
184
|
`;
|
|
185
185
|
}
|
|
186
186
|
//# sourceMappingURL=templates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/cli/generators/templates.ts"],"names":[],"mappings":";;AAOA,4CAgCC;AAED,oCAgCC;AAED,sCAsBC;AAED,oCA0BC;AAED,kCA6BC;AAED,wDAqCC;AAED,gEA0BC;AAxND,SAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,EAAE,EACF,KAAK,EACL,MAAM,GACS;IACf,OAAO,GAAG,MAAM;;;mBAGC,MAAM;;;;mBAIN,MAAM;;;;eAIV,KAAK;
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/cli/generators/templates.ts"],"names":[],"mappings":";;AAOA,4CAgCC;AAED,oCAgCC;AAED,sCAsBC;AAED,oCA0BC;AAED,kCA6BC;AAED,wDAqCC;AAED,gEA0BC;AAxND,SAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,EAAE,EACF,KAAK,EACL,MAAM,GACS;IACf,OAAO,GAAG,MAAM;;;mBAGC,MAAM;;;;mBAIN,MAAM;;;;eAIV,KAAK;cACN,MAAM,YAAY,EAAE;;cAEpB,MAAM;8CAC0B,MAAM;;;;wCAIZ,MAAM;;mBAE3B,MAAM;;;;CAIxB,CAAC;AACF,CAAC;AAED,SAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,EAAE,EACF,KAAK,EACL,MAAM,GACS;IACf,OAAO,GAAG,MAAM;;;mBAGC,MAAM;;;;mBAIN,MAAM;;;;eAIV,KAAK;UACV,MAAM,WAAW,EAAE;;cAEf,MAAM;8CAC0B,MAAM;;;;uCAIb,MAAM;mBAC1B,MAAM;;;;;CAKxB,CAAC;AACF,CAAC;AAED,SAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,EAAE,EACF,KAAK,EACL,MAAM,GACS;IACf,OAAO,GAAG,MAAM;;;mBAGC,MAAM;;;;eAIV,KAAK;WACT,MAAM,aAAa,EAAE;;cAElB,MAAM;8CAC0B,MAAM;;;;CAInD,CAAC;AACF,CAAC;AAED,SAAgB,YAAY,CAAC,EAC3B,MAAM,EACN,EAAE,EACF,KAAK,EACL,MAAM,GACS;IACf,OAAO,GAAG,MAAM;;;mBAGC,MAAM;;;;eAIV,KAAK;WACT,EAAE;;cAEC,MAAM;8CAC0B,MAAM;;;;;;;;CAQnD,CAAC;AACF,CAAC;AAED,SAAgB,WAAW,CAAC,EAC1B,MAAM,EACN,EAAE,EAC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