@c9up/ream 0.2.7 → 0.2.9
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/dist/HttpKernel.d.ts.map +1 -1
- package/dist/HttpKernel.js +10 -0
- package/dist/HttpKernel.js.map +1 -1
- package/dist/Ignitor.d.ts.map +1 -1
- package/dist/Ignitor.js +51 -3
- package/dist/Ignitor.js.map +1 -1
- package/dist/commands/Migrate.d.ts +9 -0
- package/dist/commands/Migrate.d.ts.map +1 -0
- package/dist/commands/Migrate.js +16 -0
- package/dist/commands/Migrate.js.map +1 -0
- package/dist/commands/MigrateBase.d.ts +27 -0
- package/dist/commands/MigrateBase.d.ts.map +1 -0
- package/dist/commands/MigrateBase.js +77 -0
- package/dist/commands/MigrateBase.js.map +1 -0
- package/dist/commands/MigrateRollback.d.ts +9 -0
- package/dist/commands/MigrateRollback.d.ts.map +1 -0
- package/dist/commands/MigrateRollback.js +16 -0
- package/dist/commands/MigrateRollback.js.map +1 -0
- package/dist/commands/MigrateStatus.d.ts +9 -0
- package/dist/commands/MigrateStatus.d.ts.map +1 -0
- package/dist/commands/MigrateStatus.js +19 -0
- package/dist/commands/MigrateStatus.js.map +1 -0
- package/dist/commands/ScheduleList.d.ts +18 -0
- package/dist/commands/ScheduleList.d.ts.map +1 -0
- package/dist/commands/ScheduleList.js +55 -0
- package/dist/commands/ScheduleList.js.map +1 -0
- package/dist/commands/ScheduleRun.d.ts +19 -0
- package/dist/commands/ScheduleRun.d.ts.map +1 -0
- package/dist/commands/ScheduleRun.js +61 -0
- package/dist/commands/ScheduleRun.js.map +1 -0
- package/dist/commands/index.d.ts +15 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +63 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/scheduler_resolver.d.ts +12 -0
- package/dist/commands/scheduler_resolver.d.ts.map +1 -0
- package/dist/commands/scheduler_resolver.js +19 -0
- package/dist/commands/scheduler_resolver.js.map +1 -0
- package/dist/debug.d.ts +22 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +23 -0
- package/dist/debug.js.map +1 -0
- package/dist/dumper/Dumper.d.ts +80 -0
- package/dist/dumper/Dumper.d.ts.map +1 -0
- package/dist/dumper/Dumper.js +129 -0
- package/dist/dumper/Dumper.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/middleware/Pipeline.d.ts.map +1 -1
- package/dist/middleware/Pipeline.js +7 -0
- package/dist/middleware/Pipeline.js.map +1 -1
- package/dist/repl/Repl.d.ts +88 -0
- package/dist/repl/Repl.d.ts.map +1 -0
- package/dist/repl/Repl.js +123 -0
- package/dist/repl/Repl.js.map +1 -0
- package/dist/services/dumper.d.ts +25 -0
- package/dist/services/dumper.d.ts.map +1 -0
- package/dist/services/dumper.js +27 -0
- package/dist/services/dumper.js.map +1 -0
- package/dist/services/repl.d.ts +19 -0
- package/dist/services/repl.d.ts.map +1 -0
- package/dist/services/repl.js +19 -0
- package/dist/services/repl.js.map +1 -0
- package/events.win32-x64-msvc.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +21 -1
- package/scheduler.win32-x64-msvc.node +0 -0
- package/src/HttpKernel.ts +27 -0
- package/src/Ignitor.ts +51 -3
- package/src/commands/Migrate.ts +18 -0
- package/src/commands/MigrateBase.ts +81 -0
- package/src/commands/MigrateRollback.ts +18 -0
- package/src/commands/MigrateStatus.ts +22 -0
- package/src/commands/ScheduleList.ts +66 -0
- package/src/commands/ScheduleRun.ts +65 -0
- package/src/commands/index.ts +73 -0
- package/src/commands/scheduler_resolver.ts +23 -0
- package/src/debug.ts +25 -0
- package/src/dumper/Dumper.ts +164 -0
- package/src/index.ts +1 -1
- package/src/middleware/Pipeline.ts +7 -0
- package/src/repl/Repl.ts +162 -0
- package/src/services/dumper.ts +30 -0
- package/src/services/repl.ts +21 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `schedule:list` — every registered task, when it next fires, and how its past
|
|
3
|
+
* runs went.
|
|
4
|
+
*
|
|
5
|
+
* The columns are the operator's questions in order: is my task registered at
|
|
6
|
+
* all, on what schedule, when does it fire next, when did it last fire, and is
|
|
7
|
+
* it failing. Stats come from the scheduler's own tracker, so a task that has
|
|
8
|
+
* never run reads as `—` rather than a zero that looks like a result.
|
|
9
|
+
*/
|
|
10
|
+
import { BaseCommand } from '../console/BaseCommand.js';
|
|
11
|
+
import { resolveScheduler } from './scheduler_resolver.js';
|
|
12
|
+
/** Over-long names and cron expressions are truncated so the table stays a table. */
|
|
13
|
+
function truncate(value, width) {
|
|
14
|
+
return value.length > width ? `${value.slice(0, width - 1)}…` : value;
|
|
15
|
+
}
|
|
16
|
+
function asDate(ms) {
|
|
17
|
+
return ms === null ? '—' : new Date(ms).toISOString();
|
|
18
|
+
}
|
|
19
|
+
export default class ScheduleList extends BaseCommand {
|
|
20
|
+
static commandName = 'schedule:list';
|
|
21
|
+
static description = 'List every registered scheduled task, its next run and its stats';
|
|
22
|
+
static options = { startApp: true };
|
|
23
|
+
async run() {
|
|
24
|
+
const scheduler = await resolveScheduler(this);
|
|
25
|
+
if (!scheduler)
|
|
26
|
+
return;
|
|
27
|
+
const tasks = scheduler.listTasks();
|
|
28
|
+
if (tasks.length === 0) {
|
|
29
|
+
this.logger.info('No scheduled tasks registered.');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.logger.log([
|
|
33
|
+
'NAME'.padEnd(32),
|
|
34
|
+
'CRON'.padEnd(18),
|
|
35
|
+
'NEXT RUN'.padEnd(22),
|
|
36
|
+
'LAST RUN'.padEnd(22),
|
|
37
|
+
'RUNS'.padStart(6),
|
|
38
|
+
'ERR'.padStart(5),
|
|
39
|
+
'AVG(ms)'.padStart(9),
|
|
40
|
+
].join(' '));
|
|
41
|
+
for (const task of tasks) {
|
|
42
|
+
const stats = scheduler.getStats(task.name);
|
|
43
|
+
this.logger.log([
|
|
44
|
+
truncate(task.name, 32).padEnd(32),
|
|
45
|
+
truncate(task.cronExpr, 18).padEnd(18),
|
|
46
|
+
asDate(task.nextRun).padEnd(22),
|
|
47
|
+
asDate(stats.lastRunMs).padEnd(22),
|
|
48
|
+
String(stats.runCount).padStart(6),
|
|
49
|
+
String(stats.errorCount).padStart(5),
|
|
50
|
+
String(Math.round(stats.avgDurationMs)).padStart(9),
|
|
51
|
+
].join(' '));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=ScheduleList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScheduleList.js","sourceRoot":"","sources":["../../src/commands/ScheduleList.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D,qFAAqF;AACrF,SAAS,QAAQ,CAAC,KAAa,EAAE,KAAa;IAC5C,OAAO,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAA;AACvE,CAAC;AAED,SAAS,MAAM,CAAC,EAAiB;IAC/B,OAAO,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;AACvD,CAAC;AAED,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IACnD,MAAM,CAAU,WAAW,GAAG,eAAe,CAAA;IAC7C,MAAM,CAAU,WAAW,GAAG,kEAAkE,CAAA;IAChG,MAAM,CAAU,OAAO,GAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IAE5D,KAAK,CAAC,GAAG;QACP,MAAM,SAAS,GAAG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AM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACpC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;aACpD,CAAC,IAAI,CAAC,GAAG,CAAC,CACZ,CAAA;QACH,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `schedule:run <name>` — run one registered task immediately.
|
|
3
|
+
*
|
|
4
|
+
* An admin override: it calls the task body directly, so it bypasses both the
|
|
5
|
+
* cron schedule and the distributed lock. That is the point — you reach for it
|
|
6
|
+
* when a task must run now, or to see it fail with your own eyes — and it is
|
|
7
|
+
* also why the exit codes are distinct: `1` the task failed, `2` no such task,
|
|
8
|
+
* `3` an invocation of it is already in flight.
|
|
9
|
+
*/
|
|
10
|
+
import { BaseCommand } from '../console/BaseCommand.js';
|
|
11
|
+
import type { CommandOptions } from '../console/types.js';
|
|
12
|
+
export default class ScheduleRun extends BaseCommand {
|
|
13
|
+
static commandName: string;
|
|
14
|
+
static description: string;
|
|
15
|
+
static options: CommandOptions;
|
|
16
|
+
name: string;
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ScheduleRun.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScheduleRun.d.ts","sourceRoot":"","sources":["../../src/commands/ScheduleRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAGzD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW;IAClD,OAAgB,WAAW,SAAiB;IAC5C,OAAgB,WAAW,SAAkE;IAC7F,OAAgB,OAAO,EAAE,cAAc,CAAqB;IAGpD,IAAI,EAAE,MAAM,CAAA;IAEd,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAyC3B"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `schedule:run <name>` — run one registered task immediately.
|
|
3
|
+
*
|
|
4
|
+
* An admin override: it calls the task body directly, so it bypasses both the
|
|
5
|
+
* cron schedule and the distributed lock. That is the point — you reach for it
|
|
6
|
+
* when a task must run now, or to see it fail with your own eyes — and it is
|
|
7
|
+
* also why the exit codes are distinct: `1` the task failed, `2` no such task,
|
|
8
|
+
* `3` an invocation of it is already in flight.
|
|
9
|
+
*/
|
|
10
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
13
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
|
+
};
|
|
16
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
17
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
18
|
+
};
|
|
19
|
+
import { BaseCommand } from '../console/BaseCommand.js';
|
|
20
|
+
import { args } from '../console/decorators.js';
|
|
21
|
+
import { resolveScheduler } from './scheduler_resolver.js';
|
|
22
|
+
export default class ScheduleRun extends BaseCommand {
|
|
23
|
+
static commandName = 'schedule:run';
|
|
24
|
+
static description = 'Run a registered scheduled task once, now (bypasses the lock)';
|
|
25
|
+
static options = { startApp: true };
|
|
26
|
+
async run() {
|
|
27
|
+
// Rejected here rather than in the scheduler so the message arrives without
|
|
28
|
+
// the operator first paying for a boot.
|
|
29
|
+
if (this.name.trim() === '') {
|
|
30
|
+
this.logger.error('Task name cannot be empty. Usage: schedule:run <name>');
|
|
31
|
+
this.exitCode = 1;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const scheduler = await resolveScheduler(this);
|
|
35
|
+
if (!scheduler)
|
|
36
|
+
return;
|
|
37
|
+
const result = await scheduler.runTaskNow(this.name);
|
|
38
|
+
const duration = Math.round(result.durationMs);
|
|
39
|
+
if (result.outcome === 'unknown') {
|
|
40
|
+
this.logger.error(`Unknown task: ${this.name}. Run "schedule:list" to see the registered tasks.`);
|
|
41
|
+
this.exitCode = 2;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (result.outcome === 'already-running') {
|
|
45
|
+
this.logger.error(`Task ${this.name} is already running in this process — skipped. Try again once it completes.`);
|
|
46
|
+
this.exitCode = 3;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (result.outcome === 'completed') {
|
|
50
|
+
this.logger.success(`${this.name} completed in ${duration} ms`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.logger.error(`${this.name} failed after ${duration} ms: ${result.error?.message || 'unknown error'}`);
|
|
54
|
+
this.exitCode = 1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
__decorate([
|
|
58
|
+
args.string({ description: 'Task name, as `schedule:list` prints it' }),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], ScheduleRun.prototype, "name", void 0);
|
|
61
|
+
//# sourceMappingURL=ScheduleRun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScheduleRun.js","sourceRoot":"","sources":["../../src/commands/ScheduleRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;;;;;;;;;;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,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MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,iBAAiB,QAAQ,KAAK,CAAC,CAAA;YAC/D,OAAM;QACR,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,GAAG,IAAI,CAAC,IAAI,iBAAiB,QAAQ,QAAQ,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,CACxF,CAAA;QACD,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAA;IACnB,CAAC;;AA1CO;IADP,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;;yCACpD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@c9up/ream/commands` — the commands the framework itself ships.
|
|
3
|
+
*
|
|
4
|
+
* The shape AdonisJS uses for `@adonisjs/core/commands`: a module answering
|
|
5
|
+
* `getMetaData()` then `getCommand()`, so listing a command does not import it.
|
|
6
|
+
*
|
|
7
|
+
* The kernel registers this loader on its own rather than waiting for an entry
|
|
8
|
+
* in `reamrc.commands` — the deviation from AdonisJS, where the starter kit
|
|
9
|
+
* lists it. These commands were part of the `ream` binary before they were
|
|
10
|
+
* classes, and an application that upgrades must not silently lose them.
|
|
11
|
+
*/
|
|
12
|
+
import type { CommandClass, SerializedCommand } from '../console/types.js';
|
|
13
|
+
export declare function getMetaData(): Promise<SerializedCommand[]>;
|
|
14
|
+
export declare function getCommand(metadata: SerializedCommand): Promise<CommandClass | null>;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AA4C1E,wBAAsB,WAAW,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAUhE;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAI1F"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@c9up/ream/commands` — the commands the framework itself ships.
|
|
3
|
+
*
|
|
4
|
+
* The shape AdonisJS uses for `@adonisjs/core/commands`: a module answering
|
|
5
|
+
* `getMetaData()` then `getCommand()`, so listing a command does not import it.
|
|
6
|
+
*
|
|
7
|
+
* The kernel registers this loader on its own rather than waiting for an entry
|
|
8
|
+
* in `reamrc.commands` — the deviation from AdonisJS, where the starter kit
|
|
9
|
+
* lists it. These commands were part of the `ream` binary before they were
|
|
10
|
+
* classes, and an application that upgrades must not silently lose them.
|
|
11
|
+
*/
|
|
12
|
+
const COMMANDS = [
|
|
13
|
+
// The registry commands first: a data package registers its runner, and
|
|
14
|
+
// these drive whatever registered — they name no store.
|
|
15
|
+
{
|
|
16
|
+
commandName: 'migrate',
|
|
17
|
+
description: 'Run pending migrations for every registered migration source',
|
|
18
|
+
load: () => import('./Migrate.js'),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
commandName: 'migrate:rollback',
|
|
22
|
+
description: 'Roll back the last batch for every registered migration source',
|
|
23
|
+
load: () => import('./MigrateRollback.js'),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
commandName: 'migrate:status',
|
|
27
|
+
description: 'Show applied and pending migrations for every source',
|
|
28
|
+
load: () => import('./MigrateStatus.js'),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
commandName: 'schedule:list',
|
|
32
|
+
description: 'List every registered scheduled task, its next run and its stats',
|
|
33
|
+
load: () => import('./ScheduleList.js'),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
commandName: 'schedule:run',
|
|
37
|
+
description: 'Run a registered scheduled task once, now (bypasses the lock)',
|
|
38
|
+
load: () => import('./ScheduleRun.js'),
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
/** `migrate:status` → `migrate`; a name without a colon has no namespace. */
|
|
42
|
+
function namespaceOf(commandName) {
|
|
43
|
+
const colon = commandName.indexOf(':');
|
|
44
|
+
return colon === -1 ? null : commandName.slice(0, colon);
|
|
45
|
+
}
|
|
46
|
+
export async function getMetaData() {
|
|
47
|
+
return COMMANDS.map((entry) => ({
|
|
48
|
+
commandName: entry.commandName,
|
|
49
|
+
namespace: namespaceOf(entry.commandName),
|
|
50
|
+
description: entry.description,
|
|
51
|
+
aliases: [],
|
|
52
|
+
options: { startApp: true },
|
|
53
|
+
args: [],
|
|
54
|
+
flags: [],
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
export async function getCommand(metadata) {
|
|
58
|
+
const entry = COMMANDS.find((command) => command.commandName === metadata.commandName);
|
|
59
|
+
if (!entry)
|
|
60
|
+
return null;
|
|
61
|
+
return (await entry.load()).default;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH,MAAM,QAAQ,GAAqB;IACjC,wEAAwE;IACxE,wDAAwD;IACxD;QACE,WAAW,EAAE,SAAS;QACtB,WAAW,EAAE,8DAA8D;QAC3E,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC;KACnC;IACD;QACE,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,gEAAgE;QAC7E,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC;KAC3C;IACD;QACE,WAAW,EAAE,gBAAgB;QAC7B,WAAW,EAAE,sDAAsD;QACnE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC;KACzC;IACD;QACE,WAAW,EAAE,eAAe;QAC5B,WAAW,EAAE,kEAAkE;QAC/E,IA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for the `schedule:*` commands.
|
|
3
|
+
*
|
|
4
|
+
* Shared because the failure is the same one on both, and it is a
|
|
5
|
+
* configuration mistake rather than a crash: the provider is simply not in the
|
|
6
|
+
* list, and the message has to say so — a container error mentioning an
|
|
7
|
+
* unbound `scheduler` binding tells an operator nothing.
|
|
8
|
+
*/
|
|
9
|
+
import type { BaseCommand } from '../console/BaseCommand.js';
|
|
10
|
+
import type { Scheduler } from '../scheduler/Scheduler.js';
|
|
11
|
+
export declare function resolveScheduler(command: BaseCommand): Promise<Scheduler | undefined>;
|
|
12
|
+
//# sourceMappingURL=scheduler_resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler_resolver.d.ts","sourceRoot":"","sources":["../../src/commands/scheduler_resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAE1D,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAU3F"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the scheduler for the `schedule:*` commands.
|
|
3
|
+
*
|
|
4
|
+
* Shared because the failure is the same one on both, and it is a
|
|
5
|
+
* configuration mistake rather than a crash: the provider is simply not in the
|
|
6
|
+
* list, and the message has to say so — a container error mentioning an
|
|
7
|
+
* unbound `scheduler` binding tells an operator nothing.
|
|
8
|
+
*/
|
|
9
|
+
export async function resolveScheduler(command) {
|
|
10
|
+
try {
|
|
11
|
+
return await command.app.container.resolve('scheduler');
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
command.logger.error('No ScheduleProvider is registered. Add ScheduleProvider to the providers list in reamrc.ts.');
|
|
15
|
+
command.exitCode = 2;
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=scheduler_resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduler_resolver.js","sourceRoot":"","sources":["../../src/commands/scheduler_resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAoB;IACzD,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAY,WAAW,CAAC,CAAA;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,6FAA6F,CAC9F,CAAA;QACD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACpB,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
|
package/dist/debug.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug channels, off unless `NODE_DEBUG` names them — the shape AdonisJS
|
|
3
|
+
* uses (`NODE_DEBUG=adonisjs:http`).
|
|
4
|
+
*
|
|
5
|
+
* NODE_DEBUG=ream:http ream serve
|
|
6
|
+
* NODE_DEBUG=ream:* ream serve
|
|
7
|
+
*
|
|
8
|
+
* These are for the framework's own tracing: which route a request matched,
|
|
9
|
+
* which middleware ran, what status came back. They are NOT request logging —
|
|
10
|
+
* a production request log belongs to the app's logger (`ctx.logger`), which
|
|
11
|
+
* is correlation-scoped and structured. Neither framework prints one by
|
|
12
|
+
* default, and this is the switch for when you need to see the plumbing.
|
|
13
|
+
*
|
|
14
|
+
* `debuglog` returns a no-op when the channel is off, so an inactive probe
|
|
15
|
+
* costs a call. Guard with `.enabled` anywhere the ARGUMENTS would cost
|
|
16
|
+
* something to build — the per-request probes below all do.
|
|
17
|
+
*/
|
|
18
|
+
/** Routing, middleware and response tracing. AdonisJS `adonisjs:http`. */
|
|
19
|
+
export declare const debugHttp: import("util").DebugLogger;
|
|
20
|
+
/** Boot: providers, preloads, container bindings. AdonisJS `adonisjs:core`. */
|
|
21
|
+
export declare const debugCore: import("util").DebugLogger;
|
|
22
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,0EAA0E;AAC1E,eAAO,MAAM,SAAS,4BAAwB,CAAA;AAE9C,+EAA+E;AAC/E,eAAO,MAAM,SAAS,4BAAwB,CAAA"}
|
package/dist/debug.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug channels, off unless `NODE_DEBUG` names them — the shape AdonisJS
|
|
3
|
+
* uses (`NODE_DEBUG=adonisjs:http`).
|
|
4
|
+
*
|
|
5
|
+
* NODE_DEBUG=ream:http ream serve
|
|
6
|
+
* NODE_DEBUG=ream:* ream serve
|
|
7
|
+
*
|
|
8
|
+
* These are for the framework's own tracing: which route a request matched,
|
|
9
|
+
* which middleware ran, what status came back. They are NOT request logging —
|
|
10
|
+
* a production request log belongs to the app's logger (`ctx.logger`), which
|
|
11
|
+
* is correlation-scoped and structured. Neither framework prints one by
|
|
12
|
+
* default, and this is the switch for when you need to see the plumbing.
|
|
13
|
+
*
|
|
14
|
+
* `debuglog` returns a no-op when the channel is off, so an inactive probe
|
|
15
|
+
* costs a call. Guard with `.enabled` anywhere the ARGUMENTS would cost
|
|
16
|
+
* something to build — the per-request probes below all do.
|
|
17
|
+
*/
|
|
18
|
+
import { debuglog } from 'node:util';
|
|
19
|
+
/** Routing, middleware and response tracing. AdonisJS `adonisjs:http`. */
|
|
20
|
+
export const debugHttp = debuglog('ream:http');
|
|
21
|
+
/** Boot: providers, preloads, container bindings. AdonisJS `adonisjs:core`. */
|
|
22
|
+
export const debugCore = debuglog('ream:core');
|
|
23
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAA;AAE9C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value dumping — AdonisJS's `Dumper`, in shape and in method names.
|
|
3
|
+
*
|
|
4
|
+
* import { dd } from '@c9up/ream/services/dumper'
|
|
5
|
+
* dd(user) // prints and stops the process
|
|
6
|
+
*
|
|
7
|
+
* import dumper from '@c9up/ream/services/dumper'
|
|
8
|
+
* response.send(dumper.dumpToHtml(user, { cspNonce: response.nonce }))
|
|
9
|
+
*
|
|
10
|
+
* The rendering is `node:util`'s `inspect`, not a dependency. It already knows
|
|
11
|
+
* about depth limits, circular references, getters, Maps, Sets and typed
|
|
12
|
+
* arrays, and it colours for a terminal — which is the whole of the ANSI side.
|
|
13
|
+
* The HTML side escapes that same output rather than building a second
|
|
14
|
+
* formatter, so the two can never describe a value differently.
|
|
15
|
+
*/
|
|
16
|
+
/** Where a dump was written, so the output can say so. */
|
|
17
|
+
export interface DumpSource {
|
|
18
|
+
location: string;
|
|
19
|
+
line: number;
|
|
20
|
+
}
|
|
21
|
+
/** Knobs for the terminal rendering — AdonisJS `ConsoleDumpConfig`. */
|
|
22
|
+
export interface ConsoleDumpConfig {
|
|
23
|
+
/** How deep to walk before printing `[Object]`. Default 4. */
|
|
24
|
+
depth?: number;
|
|
25
|
+
/** Colour the output. Default: whether stdout is a TTY. */
|
|
26
|
+
colors?: boolean;
|
|
27
|
+
/** Show non-enumerable properties. Default false. */
|
|
28
|
+
showHidden?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** Knobs for the HTML rendering — AdonisJS `HTMLDumpConfig`. */
|
|
31
|
+
export interface HTMLDumpConfig {
|
|
32
|
+
/** How deep to walk. Default 4. */
|
|
33
|
+
depth?: number;
|
|
34
|
+
/** Show non-enumerable properties. Default false. */
|
|
35
|
+
showHidden?: boolean;
|
|
36
|
+
/** Style overrides for the emitted `<pre>`, as CSS declarations. */
|
|
37
|
+
styles?: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
export declare class Dumper {
|
|
40
|
+
#private;
|
|
41
|
+
/** Configure the HTML rendering. Chainable, as in AdonisJS. */
|
|
42
|
+
configureHtmlOutput(config: HTMLDumpConfig): this;
|
|
43
|
+
/** Configure the terminal rendering. Chainable, as in AdonisJS. */
|
|
44
|
+
configureAnsiOutput(config: ConsoleDumpConfig): this;
|
|
45
|
+
/**
|
|
46
|
+
* The `<style>` a page needs before its first HTML dump.
|
|
47
|
+
*
|
|
48
|
+
* Takes a CSP nonce because a page that sets a nonce-based policy rejects an
|
|
49
|
+
* unattributed inline `<style>` — and a dump landing in a page that silently
|
|
50
|
+
* drops its styling is worse than no dump. `response.nonce` is what to pass.
|
|
51
|
+
*/
|
|
52
|
+
getHeadElements(cspNonce?: string): string;
|
|
53
|
+
/** Render `value` for a terminal. */
|
|
54
|
+
dumpToAnsi(value: unknown, options?: {
|
|
55
|
+
title?: string;
|
|
56
|
+
source?: DumpSource;
|
|
57
|
+
}): string;
|
|
58
|
+
/**
|
|
59
|
+
* Render `value` as HTML.
|
|
60
|
+
*
|
|
61
|
+
* The inspected output is escaped before it reaches the page: a dumped value
|
|
62
|
+
* is by definition data someone else may control, and a dump is something
|
|
63
|
+
* you reach for while debugging — exactly when a script tag in a field name
|
|
64
|
+
* would be least expected.
|
|
65
|
+
*/
|
|
66
|
+
dumpToHtml(value: unknown, options?: {
|
|
67
|
+
cspNonce?: string;
|
|
68
|
+
title?: string;
|
|
69
|
+
source?: DumpSource;
|
|
70
|
+
}): string;
|
|
71
|
+
/**
|
|
72
|
+
* Dump and die — print to stderr and stop the process.
|
|
73
|
+
*
|
|
74
|
+
* `traceSourceIndex` selects which stack frame to report as the dump site:
|
|
75
|
+
* 1 is the caller of `dd`, which is right when `dd` is called directly, and
|
|
76
|
+
* a wrapper passes 2.
|
|
77
|
+
*/
|
|
78
|
+
dd(value: unknown, traceSourceIndex?: number): void;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=Dumper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dumper.d.ts","sourceRoot":"","sources":["../../src/dumper/Dumper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,gEAAgE;AAChE,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAaD,qBAAa,MAAM;;IAIjB,+DAA+D;IAC/D,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IAKjD,mEAAmE;IACnE,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAKpD;;;;;;OAMG;IACH,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAS1C,qCAAqC;IACrC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,UAAU,CAAA;KAAE,GAAG,MAAM;IAarF;;;;;;;OAOG;IACH,UAAU,CACR,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,UAAU,CAAA;KAAE,GACnE,MAAM;IAaT;;;;;;OAMG;IACH,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,gBAAgB,SAAI,GAAG,IAAI;CAI/C"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value dumping — AdonisJS's `Dumper`, in shape and in method names.
|
|
3
|
+
*
|
|
4
|
+
* import { dd } from '@c9up/ream/services/dumper'
|
|
5
|
+
* dd(user) // prints and stops the process
|
|
6
|
+
*
|
|
7
|
+
* import dumper from '@c9up/ream/services/dumper'
|
|
8
|
+
* response.send(dumper.dumpToHtml(user, { cspNonce: response.nonce }))
|
|
9
|
+
*
|
|
10
|
+
* The rendering is `node:util`'s `inspect`, not a dependency. It already knows
|
|
11
|
+
* about depth limits, circular references, getters, Maps, Sets and typed
|
|
12
|
+
* arrays, and it colours for a terminal — which is the whole of the ANSI side.
|
|
13
|
+
* The HTML side escapes that same output rather than building a second
|
|
14
|
+
* formatter, so the two can never describe a value differently.
|
|
15
|
+
*/
|
|
16
|
+
import { inspect } from 'node:util';
|
|
17
|
+
import { escapeHTML } from '../helpers/string.js';
|
|
18
|
+
const DEFAULT_STYLES = {
|
|
19
|
+
'background-color': '#0b0b0d',
|
|
20
|
+
color: '#e6e6e6',
|
|
21
|
+
padding: '1rem',
|
|
22
|
+
'border-radius': '6px',
|
|
23
|
+
'font-family': 'ui-monospace, SFMono-Regular, Menlo, monospace',
|
|
24
|
+
'font-size': '13px',
|
|
25
|
+
'line-height': '1.5',
|
|
26
|
+
'overflow-x': 'auto',
|
|
27
|
+
};
|
|
28
|
+
export class Dumper {
|
|
29
|
+
#html = {};
|
|
30
|
+
#ansi = {};
|
|
31
|
+
/** Configure the HTML rendering. Chainable, as in AdonisJS. */
|
|
32
|
+
configureHtmlOutput(config) {
|
|
33
|
+
this.#html = { ...this.#html, ...config };
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
/** Configure the terminal rendering. Chainable, as in AdonisJS. */
|
|
37
|
+
configureAnsiOutput(config) {
|
|
38
|
+
this.#ansi = { ...this.#ansi, ...config };
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The `<style>` a page needs before its first HTML dump.
|
|
43
|
+
*
|
|
44
|
+
* Takes a CSP nonce because a page that sets a nonce-based policy rejects an
|
|
45
|
+
* unattributed inline `<style>` — and a dump landing in a page that silently
|
|
46
|
+
* drops its styling is worse than no dump. `response.nonce` is what to pass.
|
|
47
|
+
*/
|
|
48
|
+
getHeadElements(cspNonce) {
|
|
49
|
+
const nonce = cspNonce ? ` nonce="${escapeHTML(cspNonce)}"` : '';
|
|
50
|
+
const styles = { ...DEFAULT_STYLES, ...this.#html.styles };
|
|
51
|
+
const declarations = Object.entries(styles)
|
|
52
|
+
.map(([property, value]) => ` ${property}: ${value};`)
|
|
53
|
+
.join('\n');
|
|
54
|
+
return `<style${nonce}>\n.ream-dump {\n${declarations}\n}\n</style>`;
|
|
55
|
+
}
|
|
56
|
+
/** Render `value` for a terminal. */
|
|
57
|
+
dumpToAnsi(value, options) {
|
|
58
|
+
const body = inspect(value, {
|
|
59
|
+
depth: this.#ansi.depth ?? 4,
|
|
60
|
+
colors: this.#ansi.colors ?? process.stdout.isTTY === true,
|
|
61
|
+
showHidden: this.#ansi.showHidden ?? false,
|
|
62
|
+
// Long strings and arrays are the reason someone is dumping; truncating
|
|
63
|
+
// them defeats the call.
|
|
64
|
+
maxStringLength: null,
|
|
65
|
+
maxArrayLength: null,
|
|
66
|
+
});
|
|
67
|
+
return [header(options), body].filter(Boolean).join('\n');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Render `value` as HTML.
|
|
71
|
+
*
|
|
72
|
+
* The inspected output is escaped before it reaches the page: a dumped value
|
|
73
|
+
* is by definition data someone else may control, and a dump is something
|
|
74
|
+
* you reach for while debugging — exactly when a script tag in a field name
|
|
75
|
+
* would be least expected.
|
|
76
|
+
*/
|
|
77
|
+
dumpToHtml(value, options) {
|
|
78
|
+
const body = inspect(value, {
|
|
79
|
+
depth: this.#html.depth ?? 4,
|
|
80
|
+
colors: false,
|
|
81
|
+
showHidden: this.#html.showHidden ?? false,
|
|
82
|
+
maxStringLength: null,
|
|
83
|
+
maxArrayLength: null,
|
|
84
|
+
});
|
|
85
|
+
const heading = header(options);
|
|
86
|
+
const label = heading ? `<div class="ream-dump-header">${escapeHTML(heading)}</div>` : '';
|
|
87
|
+
return `${this.getHeadElements(options?.cspNonce)}\n${label}<pre class="ream-dump">${escapeHTML(body)}</pre>`;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Dump and die — print to stderr and stop the process.
|
|
91
|
+
*
|
|
92
|
+
* `traceSourceIndex` selects which stack frame to report as the dump site:
|
|
93
|
+
* 1 is the caller of `dd`, which is right when `dd` is called directly, and
|
|
94
|
+
* a wrapper passes 2.
|
|
95
|
+
*/
|
|
96
|
+
dd(value, traceSourceIndex = 1) {
|
|
97
|
+
process.stderr.write(`${this.dumpToAnsi(value, { source: callSite(traceSourceIndex) })}\n`);
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** `title` and `source` as one line, or nothing when neither is given. */
|
|
102
|
+
function header(options) {
|
|
103
|
+
const parts = [];
|
|
104
|
+
if (options?.title)
|
|
105
|
+
parts.push(options.title);
|
|
106
|
+
if (options?.source)
|
|
107
|
+
parts.push(`${options.source.location}:${options.source.line}`);
|
|
108
|
+
return parts.join(' — ');
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Where `dd` was called, read from a thrown stack.
|
|
112
|
+
*
|
|
113
|
+
* Best-effort: a bundled or minified frame may not parse, and a dump that
|
|
114
|
+
* cannot name its own line is still a useful dump — so a miss returns nothing
|
|
115
|
+
* rather than throwing on the debugging path.
|
|
116
|
+
*/
|
|
117
|
+
function callSite(index) {
|
|
118
|
+
const frames = new Error().stack?.split('\n').slice(1);
|
|
119
|
+
const frame = frames?.[index];
|
|
120
|
+
if (!frame)
|
|
121
|
+
return undefined;
|
|
122
|
+
const match = /\(?(.+):(\d+):\d+\)?$/.exec(frame.trim());
|
|
123
|
+
const location = match?.[1];
|
|
124
|
+
const line = match?.[2];
|
|
125
|
+
if (!location || !line)
|
|
126
|
+
return undefined;
|
|
127
|
+
return { location, line: Number(line) };
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=Dumper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dumper.js","sourceRoot":"","sources":["../../src/dumper/Dumper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AA4BjD,MAAM,cAAc,GAA2B;IAC7C,kBAAkB,EAAE,SAAS;IAC7B,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,MAAM;IACf,eAAe,EAAE,KAAK;IACtB,aAAa,EAAE,gDAAgD;IAC/D,WAAW,EAAE,MAAM;IACnB,aAAa,EAAE,KAAK;IACpB,YAAY,EAAE,MAAM;CACrB,CAAA;AAED,MAAM,OAAO,MAAM;IACjB,KAAK,GAAmB,EAAE,CAAA;IAC1B,KAAK,GAAsB,EAAE,CAAA;IAE7B,+DAA+D;IAC/D,mBAAmB,CAAC,MAAsB;QACxC,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,IAAI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,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;IACpF,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,SAAS,QAAQ,CAAC,KAAa;IAC7B,MAAM,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACtD,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,CAAA;IAC7B,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IAC5B,MAAM,KAAK,GAAG,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;IACxD,MAAM,QAAQ,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IAC3B,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IACvB,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAA;IACxC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAA;AACzC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -119,5 +119,5 @@ export { BaseEvent, Emitter, type EmitterResolver, type ListenerClass, } from '.
|
|
|
119
119
|
export { type BufferedEvent, type BufferedEventName, type EventFinder, EventsBuffer, } from './events/EventsBuffer.js';
|
|
120
120
|
export type { ErrorReporter, LockBackend, RunTaskOutcome, ScheduleEvent, ScheduleEventSink, ScheduleInvocation, ScheduleMetadata, ScheduleProviderOptions, SchedulerOptions, ScheduleTaskCompletedEvent, ScheduleTaskFailedEvent, ScheduleTaskSkippedEvent, ScheduleTaskStartedEvent, TaskInfo, TaskStats, } from './scheduler/index.js';
|
|
121
121
|
export { getScheduleMetadata, MemoryLockBackend, SCHEDULE_METADATA_KEY, Schedule, ScheduleProvider, Scheduler, StatsTracker, } from './scheduler/index.js';
|
|
122
|
-
export declare const VERSION = "0.2.
|
|
122
|
+
export declare const VERSION = "0.2.9";
|
|
123
123
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -91,5 +91,5 @@ export { defineConfig as defineEventsConfig } from './events/config.js';
|
|
|
91
91
|
export { BaseEvent, Emitter, } from './events/Emitter.js';
|
|
92
92
|
export { EventsBuffer, } from './events/EventsBuffer.js';
|
|
93
93
|
export { getScheduleMetadata, MemoryLockBackend, SCHEDULE_METADATA_KEY, Schedule, ScheduleProvider, Scheduler, StatsTracker, } from './scheduler/index.js';
|
|
94
|
-
export const VERSION = '0.2.
|
|
94
|
+
export const VERSION = '0.2.9';
|
|
95
95
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pipeline.d.ts","sourceRoot":"","sources":["../../src/middleware/Pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"Pipeline.d.ts","sourceRoot":"","sources":["../../src/middleware/Pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEzD,MAAM,MAAM,kBAAkB,GAAG,CAC/B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KACtB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAEzB,0EAA0E;AAC1E,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,OAAO,EAAE,CAAA;IACjB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,CAAC,IAAI,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|
12
12
|
*/
|
|
13
|
+
import { debugHttp } from '../debug.js';
|
|
13
14
|
import { ReamError } from '../errors/ReamError.js';
|
|
14
15
|
import { E_FORBIDDEN, E_UNAUTHORIZED, E_VALIDATION_ERROR } from '../http/Exception.js';
|
|
15
16
|
function isThrownValidationFailure(value) {
|
|
@@ -125,6 +126,12 @@ function composeMiddleware(middleware) {
|
|
|
125
126
|
const fn = i < middleware.length ? middleware[i] : finalNext;
|
|
126
127
|
if (!fn)
|
|
127
128
|
return;
|
|
129
|
+
if (debugHttp.enabled && i < middleware.length) {
|
|
130
|
+
// `fn.name` is what a named middleware function or a bound class
|
|
131
|
+
// method carries; an inline arrow has none, and its position is the
|
|
132
|
+
// only thing that identifies it.
|
|
133
|
+
debugHttp('middleware %d/%d %s', i + 1, middleware.length, fn.name || '(anonymous)');
|
|
134
|
+
}
|
|
128
135
|
await fn(ctx, () => dispatch(i + 1));
|
|
129
136
|
}
|
|
130
137
|
await dispatch(0);
|