pixivflow 2.11.0 → 2.12.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/dist/commands/SchedulerCommand.d.ts.map +1 -1
- package/dist/commands/SchedulerCommand.js +79 -32
- package/dist/commands/SchedulerCommand.js.map +1 -1
- package/dist/commands/SchedulerRunOnceCommand.d.ts.map +1 -1
- package/dist/commands/SchedulerRunOnceCommand.js +5 -1
- package/dist/commands/SchedulerRunOnceCommand.js.map +1 -1
- package/dist/commands/scheduler-runtime.d.ts +4 -2
- package/dist/commands/scheduler-runtime.d.ts.map +1 -1
- package/dist/commands/scheduler-runtime.js +86 -53
- package/dist/commands/scheduler-runtime.js.map +1 -1
- package/dist/config/types.d.ts +24 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/delivery/DeliveryOutbox.d.ts.map +1 -1
- package/dist/delivery/DeliveryOutbox.js +10 -3
- package/dist/delivery/DeliveryOutbox.js.map +1 -1
- package/dist/delivery/HttpMultipartDelivery.d.ts.map +1 -1
- package/dist/delivery/HttpMultipartDelivery.js +5 -1
- package/dist/delivery/HttpMultipartDelivery.js.map +1 -1
- package/dist/delivery/types.d.ts +12 -0
- package/dist/delivery/types.d.ts.map +1 -1
- package/dist/package.json +1 -1
- package/dist/scheduler/MultiScheduleManager.d.ts +9 -12
- package/dist/scheduler/MultiScheduleManager.d.ts.map +1 -1
- package/dist/scheduler/MultiScheduleManager.js +31 -15
- package/dist/scheduler/MultiScheduleManager.js.map +1 -1
- package/dist/scheduler/OccurrenceResolver.d.ts +90 -0
- package/dist/scheduler/OccurrenceResolver.d.ts.map +1 -0
- package/dist/scheduler/OccurrenceResolver.js +127 -0
- package/dist/scheduler/OccurrenceResolver.js.map +1 -0
- package/dist/scheduler/ScheduleTriggerServer.d.ts +35 -30
- package/dist/scheduler/ScheduleTriggerServer.d.ts.map +1 -1
- package/dist/scheduler/ScheduleTriggerServer.js +25 -27
- package/dist/scheduler/ScheduleTriggerServer.js.map +1 -1
- package/dist/scheduler/Scheduler.d.ts +5 -3
- package/dist/scheduler/Scheduler.d.ts.map +1 -1
- package/dist/scheduler/Scheduler.js +9 -6
- package/dist/scheduler/Scheduler.js.map +1 -1
- package/dist/scheduler/SlotCoordinator.d.ts +51 -20
- package/dist/scheduler/SlotCoordinator.d.ts.map +1 -1
- package/dist/scheduler/SlotCoordinator.js +98 -72
- package/dist/scheduler/SlotCoordinator.js.map +1 -1
- package/dist/storage/DatabaseMigration.d.ts.map +1 -1
- package/dist/storage/DatabaseMigration.js +42 -5
- package/dist/storage/DatabaseMigration.js.map +1 -1
- package/dist/storage/repositories/SlotRepository.d.ts +32 -8
- package/dist/storage/repositories/SlotRepository.d.ts.map +1 -1
- package/dist/storage/repositories/SlotRepository.js +69 -15
- package/dist/storage/repositories/SlotRepository.js.map +1 -1
- package/dist/webui/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,95 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SlotCoordinator = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.slotDateForNow = slotDateForNow;
|
|
4
|
+
exports.timezoneForSchedule = timezoneForSchedule;
|
|
6
5
|
const logger_1 = require("../logger");
|
|
7
|
-
|
|
8
|
-
function slotNameForNow(timezone) {
|
|
9
|
-
const hour = new Date(new Date().toLocaleString('en-US', { timeZone: timezone || 'Asia/Shanghai' })).getHours();
|
|
10
|
-
return hour < 13 ? 'morning' : 'evening';
|
|
11
|
-
}
|
|
12
|
-
/** Today's date (YYYY-MM-DD) in the configured scheduler timezone. */
|
|
13
|
-
function slotDateForNow(timezone) {
|
|
14
|
-
const parts = new Intl.DateTimeFormat('en-CA', {
|
|
15
|
-
timeZone: timezone || 'Asia/Shanghai',
|
|
16
|
-
year: 'numeric',
|
|
17
|
-
month: '2-digit',
|
|
18
|
-
day: '2-digit',
|
|
19
|
-
}).formatToParts(new Date());
|
|
20
|
-
const get = (t) => parts.find((p) => p.type === t)?.value ?? '';
|
|
21
|
-
return `${get('year')}-${get('month')}-${get('day')}`;
|
|
22
|
-
}
|
|
23
|
-
function todayInTz(timezone) {
|
|
24
|
-
return slotDateForNow(timezone);
|
|
25
|
-
}
|
|
6
|
+
const OccurrenceResolver_1 = require("./OccurrenceResolver");
|
|
26
7
|
/**
|
|
27
|
-
* Owns the Schedule Slot ledger for one scheduler run.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
8
|
+
* Owns the Schedule Slot ledger for one scheduler run. A Slot is one durable
|
|
9
|
+
* execution occurrence of a Schedule (NOT a morning/evening row). It ensures
|
|
10
|
+
* duplicate/concurrent/retry triggers converge on one slot, completed cells are
|
|
11
|
+
* not re-run, target membership is stable once materialized, and a selected
|
|
12
|
+
* work id stays locked across automatic retries.
|
|
13
|
+
*
|
|
14
|
+
* This class is delivery-agnostic: it knows nothing about TelePost, bots, or any
|
|
15
|
+
* hosting platform — only schedules, targets and the slot ledger.
|
|
30
16
|
*/
|
|
31
17
|
class SlotCoordinator {
|
|
32
18
|
database;
|
|
33
19
|
constructor(database) {
|
|
34
20
|
this.database = database;
|
|
35
21
|
}
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Resolve + validate the canonical occurrence for a trigger. Uses ONLY the
|
|
24
|
+
* schedule's cron + timezone and the trigger instant (never a client-supplied
|
|
25
|
+
* past date). `requestedSlotName` is an optional human label for provenance;
|
|
26
|
+
* identity always derives from the resolved canonical fire time.
|
|
27
|
+
*/
|
|
28
|
+
resolveOccurrence(schedule, config, triggerSource, at = new Date(), requestedSlotName) {
|
|
41
29
|
const graceMin = config.schedulerRuntime?.trigger?.graceMinutes ?? 90;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const scheduledHour = name === 'morning' ? 10 : 18;
|
|
46
|
-
const sched = new Date(`${date}T${String(scheduledHour).padStart(2, '0')}:00:00`);
|
|
47
|
-
// Compare in tz-agnostic wall clock is imprecise; use a coarse grace check:
|
|
48
|
-
// allow when within [scheduled - small lead, scheduled + grace]. Lead 15m.
|
|
49
|
-
const leadMs = 15 * 60_000;
|
|
50
|
-
const graceMs = graceMin * 60_000;
|
|
51
|
-
if (now < sched.getTime() - leadMs) {
|
|
52
|
-
return { error: `slot ${name} for ${date} is not due yet`, status: 425 };
|
|
30
|
+
let occurrence;
|
|
31
|
+
try {
|
|
32
|
+
occurrence = (0, OccurrenceResolver_1.resolveOccurrence)({ schedule, at, triggerSource });
|
|
53
33
|
}
|
|
54
|
-
|
|
55
|
-
return { error:
|
|
34
|
+
catch (error) {
|
|
35
|
+
return { error: error instanceof Error ? error.message : String(error), status: 400 };
|
|
56
36
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
for (const target of targets) {
|
|
66
|
-
if (!target.id)
|
|
67
|
-
continue;
|
|
68
|
-
const cell = this.database.slots.ensureCell(slotId, target.id, target.type);
|
|
69
|
-
if (cell.status === 'submitted' || cell.status === 'no_candidate')
|
|
70
|
-
continue;
|
|
71
|
-
out.push({ target, cell });
|
|
37
|
+
// Internal cron/catch-up are trusted to fire on their own occurrence; the
|
|
38
|
+
// HTTP adapter validates the public grace window so an external clock cannot
|
|
39
|
+
// back-fill history.
|
|
40
|
+
if (triggerSource === 'http' || triggerSource === 'manual') {
|
|
41
|
+
const window = (0, OccurrenceResolver_1.checkOccurrenceWindow)(occurrence, at, graceMin);
|
|
42
|
+
if (!window.ok) {
|
|
43
|
+
return { error: window.error, status: window.status };
|
|
44
|
+
}
|
|
72
45
|
}
|
|
73
|
-
return
|
|
46
|
+
return {
|
|
47
|
+
context: {
|
|
48
|
+
slotId: occurrence.slotId,
|
|
49
|
+
scheduleId: occurrence.scheduleId,
|
|
50
|
+
occurrenceAt: occurrence.occurrenceAt.getTime(),
|
|
51
|
+
occurrenceDate: occurrence.occurrenceDate,
|
|
52
|
+
occurrenceLabel: occurrence.occurrenceLabel,
|
|
53
|
+
timezone: occurrence.timezone,
|
|
54
|
+
triggerSource: occurrence.triggerSource,
|
|
55
|
+
slotName: requestedSlotName?.trim() || occurrence.occurrenceLabel,
|
|
56
|
+
slotDate: occurrence.occurrenceDate,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
74
59
|
}
|
|
75
|
-
/**
|
|
76
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Open (or resume) an occurrence and snapshot its target membership on first
|
|
62
|
+
* creation. A later config reload cannot add/remove cells for this occurrence.
|
|
63
|
+
*/
|
|
64
|
+
begin(slot, schedule, targets) {
|
|
65
|
+
const targetIds = targets.map((t) => t.id).filter((id) => Boolean(id));
|
|
77
66
|
const { slot: slotRec, created } = this.database.slots.getOrCreateSlot(slot.slotId, {
|
|
67
|
+
scheduleId: slot.scheduleId,
|
|
68
|
+
occurrenceAt: slot.occurrenceAt,
|
|
69
|
+
occurrenceDate: slot.occurrenceDate,
|
|
70
|
+
occurrenceLabel: slot.occurrenceLabel,
|
|
71
|
+
timezone: slot.timezone,
|
|
72
|
+
targetIds,
|
|
73
|
+
triggerSource: slot.triggerSource,
|
|
78
74
|
slotDate: slot.slotDate,
|
|
79
75
|
slotName: slot.slotName,
|
|
80
|
-
scheduleId: schedule.id,
|
|
81
|
-
triggerSource: slot.triggerSource,
|
|
82
76
|
});
|
|
83
|
-
if (created)
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
if (created) {
|
|
78
|
+
// Freeze membership: materialize one cell per target id from the snapshot.
|
|
79
|
+
const workTypeById = new Map(targets.map((t) => [t.id, t.type ?? 'unknown']));
|
|
80
|
+
this.database.slots.materializeCells(slot.slotId, targetIds, (id) => workTypeById.get(id) ?? 'unknown');
|
|
81
|
+
logger_1.logger.info('Slot started', { slot: slot.slotId, schedule: schedule.id, targets: targetIds.length });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
86
84
|
logger_1.logger.info('Slot resumed (duplicate trigger or restart)', { slot: slot.slotId, status: slotRec.status });
|
|
85
|
+
}
|
|
87
86
|
if (slotRec.status === 'success' || slotRec.status === 'partial') {
|
|
88
87
|
return { slotRec, alreadyCompleted: true };
|
|
89
88
|
}
|
|
90
89
|
this.database.slots.markSlotStatus(slot.slotId, 'running');
|
|
91
90
|
return { slotRec, alreadyCompleted: false };
|
|
92
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* The targets that still need to run for this occurrence. Membership comes
|
|
94
|
+
* from the materialized snapshot (stable), intersected with the targets the
|
|
95
|
+
* caller currently knows about; terminal cells are skipped on resume.
|
|
96
|
+
*/
|
|
97
|
+
pendingTargets(slotId, targets) {
|
|
98
|
+
const membership = new Set(this.database.slots.getSlotTargetIds(slotId));
|
|
99
|
+
const out = [];
|
|
100
|
+
for (const target of targets) {
|
|
101
|
+
if (!target.id)
|
|
102
|
+
continue;
|
|
103
|
+
if (membership.size > 0 && !membership.has(target.id))
|
|
104
|
+
continue; // config reload: not part of this occurrence
|
|
105
|
+
const cell = this.database.slots.getCell(slotId, target.id);
|
|
106
|
+
if (!cell)
|
|
107
|
+
continue;
|
|
108
|
+
if (cell.status === 'submitted' || cell.status === 'no_candidate')
|
|
109
|
+
continue;
|
|
110
|
+
out.push({ target, cell });
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
93
114
|
/** Lock the selected work for a cell (first selection wins; retries keep it). */
|
|
94
115
|
lockWork(slotId, targetId, workId, workType) {
|
|
95
116
|
this.database.slots.ensureCell(slotId, targetId, workType);
|
|
@@ -104,16 +125,17 @@ class SlotCoordinator {
|
|
|
104
125
|
return; // never downgrade a delivered cell
|
|
105
126
|
this.database.slots.setCellStatus(slotId, targetId, status, error);
|
|
106
127
|
}
|
|
107
|
-
/** Roll cell results up into the slot status
|
|
128
|
+
/** Roll cell results up into the slot status (one place computes the aggregate). */
|
|
108
129
|
finish(slot, schedule, targets) {
|
|
109
|
-
|
|
110
|
-
|
|
130
|
+
const membership = this.database.slots.getSlotTargetIds(slot.slotId);
|
|
131
|
+
const ids = membership.length > 0 ? membership : targets.map((t) => t.id).filter(Boolean);
|
|
132
|
+
for (const targetId of ids) {
|
|
133
|
+
const cell = this.database.slots.getCell(slot.slotId, targetId);
|
|
134
|
+
if (!cell)
|
|
111
135
|
continue;
|
|
112
|
-
|
|
113
|
-
if (!cell || cell.status === 'pending' || cell.status === 'selected') {
|
|
136
|
+
if (cell.status === 'pending' || cell.status === 'selected') {
|
|
114
137
|
// Ran but never reached a terminal state (target threw before delivery).
|
|
115
|
-
|
|
116
|
-
this.database.slots.setCellStatus(slot.slotId, t.id, 'failed', cell.lastError ?? 'target did not complete');
|
|
138
|
+
this.database.slots.setCellStatus(slot.slotId, targetId, 'failed', cell.lastError ?? 'target did not complete');
|
|
117
139
|
}
|
|
118
140
|
}
|
|
119
141
|
const status = this.database.slots.deriveSlotStatus(slot.slotId);
|
|
@@ -147,4 +169,8 @@ class SlotCoordinator {
|
|
|
147
169
|
}
|
|
148
170
|
}
|
|
149
171
|
exports.SlotCoordinator = SlotCoordinator;
|
|
172
|
+
/** Resolve the timezone a schedule runs in (never the server's local tz). */
|
|
173
|
+
function timezoneForSchedule(schedule, config) {
|
|
174
|
+
return (0, OccurrenceResolver_1.scheduleTimezone)(schedule, config.scheduler?.timezone);
|
|
175
|
+
}
|
|
150
176
|
//# sourceMappingURL=SlotCoordinator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlotCoordinator.js","sourceRoot":"","sources":["../../src/scheduler/SlotCoordinator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SlotCoordinator.js","sourceRoot":"","sources":["../../src/scheduler/SlotCoordinator.ts"],"names":[],"mappings":";;;AA4OA,kDAEC;AAtOD,sCAAmC;AACnC,6DAM8B;AA4C9B;;;;;;;;;GASG;AACH,MAAa,eAAe;IACG;IAA7B,YAA6B,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SACnB,CAAC,CAAC,CAAC;QACJ,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpD,OAAO;YACL,UAAU,EAAE,QAAQ,CAAC,EAAE;YACvB,MAAM;YACN,MAAM,EAAG,OAAO,EAAE,MAAqB,IAAI,SAAS;YACpD,gBAAgB,EAAE,IAAI;YACtB,KAAK;SACN,CAAC;IACJ,CAAC;CACF;AApKD,0CAoKC;AAED,6EAA6E;AAC7E,SAAgB,mBAAmB,CAAC,QAAoC,EAAE,MAAwB;IAChG,OAAO,IAAA,qCAAgB,EAAC,QAAQ,EAAE,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseMigration.d.ts","sourceRoot":"","sources":["../../src/storage/DatabaseMigration.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,gBAAgB,CAAC;AAI5C;;GAEG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,cAAc,CAAC,QAAQ;IAExD;;OAEG;IACI,OAAO,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"DatabaseMigration.d.ts","sourceRoot":"","sources":["../../src/storage/DatabaseMigration.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,gBAAgB,CAAC;AAI5C;;GAEG;AACH,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,cAAc,CAAC,QAAQ;IAExD;;OAEG;IACI,OAAO,IAAI,IAAI;CA8MvB"}
|
|
@@ -78,13 +78,24 @@ class DatabaseMigration {
|
|
|
78
78
|
// Schedule Slots: one business batch (e.g. 2026-09-08:morning). A slot
|
|
79
79
|
// groups one run of each enabled target (a "cell"). External triggers
|
|
80
80
|
// and restarts converge on the SAME slot row instead of re-running.
|
|
81
|
+
//
|
|
82
|
+
// A Slot is one durable execution occurrence of a Schedule. Its id is
|
|
83
|
+
// schedule-scoped (`<scheduleId>@<occurrenceStamp>`); occurrence_at is
|
|
84
|
+
// the canonical scheduled fire time in the schedule's own timezone.
|
|
85
|
+
// target_ids snapshots the membership materialized at first run so a
|
|
86
|
+
// later config reload cannot mutate an in-flight occurrence.
|
|
81
87
|
`CREATE TABLE IF NOT EXISTS schedule_slots (
|
|
82
88
|
id TEXT PRIMARY KEY,
|
|
83
|
-
slot_date TEXT NOT NULL,
|
|
84
|
-
slot_name TEXT NOT NULL,
|
|
85
89
|
schedule_id TEXT NOT NULL,
|
|
90
|
+
occurrence_at INTEGER,
|
|
91
|
+
occurrence_date TEXT NOT NULL DEFAULT '',
|
|
92
|
+
occurrence_label TEXT NOT NULL DEFAULT '',
|
|
93
|
+
timezone TEXT NOT NULL DEFAULT 'UTC',
|
|
94
|
+
target_ids TEXT,
|
|
86
95
|
status TEXT NOT NULL DEFAULT 'pending',
|
|
87
96
|
trigger_source TEXT,
|
|
97
|
+
slot_date TEXT NOT NULL DEFAULT '',
|
|
98
|
+
slot_name TEXT NOT NULL DEFAULT '',
|
|
88
99
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
89
100
|
started_at DATETIME,
|
|
90
101
|
completed_at DATETIME,
|
|
@@ -108,6 +119,32 @@ class DatabaseMigration {
|
|
|
108
119
|
UNIQUE(slot_id, target_id)
|
|
109
120
|
)`,
|
|
110
121
|
];
|
|
122
|
+
// Phase 1: create tables (idempotent). Must run before any PRAGMA-based
|
|
123
|
+
// column check, otherwise a fresh DB would report the table as missing and
|
|
124
|
+
// both CREATE and ADD COLUMN would create the same column.
|
|
125
|
+
const createTables = this.db.transaction((stmts) => {
|
|
126
|
+
for (const sql of stmts) {
|
|
127
|
+
this.db.prepare(sql).run();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
createTables(migrations);
|
|
131
|
+
// Phase 2: additive column migrations for databases created before the
|
|
132
|
+
// canonical occurrence model. The table now exists, so PRAGMA reports the
|
|
133
|
+
// true current columns; ALTER only the ones missing on upgraded DBs (fresh
|
|
134
|
+
// DBs already have them from the CREATE above and skip these).
|
|
135
|
+
const slotCols = this.db.prepare(`PRAGMA table_info(schedule_slots)`).all().map((c) => c.name);
|
|
136
|
+
const slotColumnMigrations = {
|
|
137
|
+
occurrence_at: 'ALTER TABLE schedule_slots ADD COLUMN occurrence_at INTEGER',
|
|
138
|
+
occurrence_date: `ALTER TABLE schedule_slots ADD COLUMN occurrence_date TEXT NOT NULL DEFAULT ''`,
|
|
139
|
+
occurrence_label: `ALTER TABLE schedule_slots ADD COLUMN occurrence_label TEXT NOT NULL DEFAULT ''`,
|
|
140
|
+
timezone: `ALTER TABLE schedule_slots ADD COLUMN timezone TEXT NOT NULL DEFAULT 'UTC'`,
|
|
141
|
+
target_ids: 'ALTER TABLE schedule_slots ADD COLUMN target_ids TEXT',
|
|
142
|
+
};
|
|
143
|
+
const columnAlters = [];
|
|
144
|
+
for (const [col, sql] of Object.entries(slotColumnMigrations)) {
|
|
145
|
+
if (!slotCols.includes(col))
|
|
146
|
+
columnAlters.push(sql);
|
|
147
|
+
}
|
|
111
148
|
// Create indexes for better query performance
|
|
112
149
|
const indexes = [
|
|
113
150
|
`CREATE INDEX IF NOT EXISTS idx_downloads_pixiv_id_type ON downloads(pixiv_id, type)`,
|
|
@@ -120,16 +157,16 @@ class DatabaseMigration {
|
|
|
120
157
|
`CREATE INDEX IF NOT EXISTS idx_task_history_task_id ON task_history(task_id)`,
|
|
121
158
|
`CREATE INDEX IF NOT EXISTS idx_task_history_status ON task_history(status)`,
|
|
122
159
|
`CREATE INDEX IF NOT EXISTS idx_task_history_start_time ON task_history(start_time)`,
|
|
123
|
-
`CREATE INDEX IF NOT EXISTS
|
|
160
|
+
`CREATE INDEX IF NOT EXISTS idx_slots_schedule_occ ON schedule_slots(schedule_id, occurrence_at DESC)`,
|
|
124
161
|
`CREATE INDEX IF NOT EXISTS idx_slot_items_slot ON schedule_slot_items(slot_id)`,
|
|
125
162
|
`CREATE INDEX IF NOT EXISTS idx_slot_items_work ON schedule_slot_items(work_id, work_type)`,
|
|
126
163
|
];
|
|
127
|
-
const
|
|
164
|
+
const postMigration = this.db.transaction((stmts) => {
|
|
128
165
|
for (const sql of stmts) {
|
|
129
166
|
this.db.prepare(sql).run();
|
|
130
167
|
}
|
|
131
168
|
});
|
|
132
|
-
|
|
169
|
+
postMigration([...columnAlters, ...indexes]);
|
|
133
170
|
// Add is_active column to config_history if it doesn't exist
|
|
134
171
|
try {
|
|
135
172
|
// Check if column exists by querying pragma_table_info
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseMigration.js","sourceRoot":"","sources":["../../src/storage/DatabaseMigration.ts"],"names":[],"mappings":";;;AACA,4CAAgD;AAChD,sCAAmC;AAEnC;;GAEG;AACH,MAAa,iBAAiB;IACC;IAA7B,YAA6B,EAA2B;QAA3B,OAAE,GAAF,EAAE,CAAyB;IAAG,CAAC;IAE5D;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC;YACH,MAAM,UAAU,GAAG;gBACjB;;;;YAII;gBACJ;;;;;;;;;;;YAWI;gBACJ;;;;;;;YAOI;gBACJ;;;;;;;;;;YAUI;gBACJ;;;;;;;YAOI;gBACJ;;;;;;;;;;;;;YAaI;gBACJ,uEAAuE;gBACvE,sEAAsE;gBACtE,oEAAoE;gBACpE
|
|
1
|
+
{"version":3,"file":"DatabaseMigration.js","sourceRoot":"","sources":["../../src/storage/DatabaseMigration.ts"],"names":[],"mappings":";;;AACA,4CAAgD;AAChD,sCAAmC;AAEnC;;GAEG;AACH,MAAa,iBAAiB;IACC;IAA7B,YAA6B,EAA2B;QAA3B,OAAE,GAAF,EAAE,CAAyB;IAAG,CAAC;IAE5D;;OAEG;IACI,OAAO;QACZ,IAAI,CAAC;YACH,MAAM,UAAU,GAAG;gBACjB;;;;YAII;gBACJ;;;;;;;;;;;YAW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AAC,SAAS,CAC3C,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AApND,8CAoNC"}
|
|
@@ -3,11 +3,21 @@ export type SlotStatus = 'pending' | 'running' | 'success' | 'partial' | 'failed
|
|
|
3
3
|
export type CellStatus = 'pending' | 'selected' | 'submitted' | 'no_candidate' | 'failed';
|
|
4
4
|
export interface SlotRecord {
|
|
5
5
|
id: string;
|
|
6
|
-
|
|
7
|
-
slotName: string;
|
|
6
|
+
/** Schedule this occurrence belongs to (id is already schedule-scoped). */
|
|
8
7
|
scheduleId: string;
|
|
8
|
+
/** Canonical scheduled fire time (epoch ms, UTC); null for legacy rows. */
|
|
9
|
+
occurrenceAt: number | null;
|
|
10
|
+
/** Schedule date (YYYY-MM-DD) in the schedule timezone — display only. */
|
|
11
|
+
occurrenceDate: string;
|
|
12
|
+
/** Wall-clock time-of-day label in tz, e.g. "10:00" — display only. */
|
|
13
|
+
occurrenceLabel: string;
|
|
14
|
+
timezone: string;
|
|
15
|
+
/** Materialized target membership snapshot (JSON array of target ids). */
|
|
16
|
+
targetIds: string[];
|
|
9
17
|
status: SlotStatus;
|
|
10
18
|
triggerSource: string | null;
|
|
19
|
+
slotDate: string;
|
|
20
|
+
slotName: string;
|
|
11
21
|
createdAt: string;
|
|
12
22
|
startedAt: string | null;
|
|
13
23
|
completedAt: string | null;
|
|
@@ -37,26 +47,40 @@ export interface SlotItemRecord {
|
|
|
37
47
|
*/
|
|
38
48
|
export declare class SlotRepository extends BaseRepository {
|
|
39
49
|
/**
|
|
40
|
-
* Fetch an existing slot or create it.
|
|
41
|
-
*
|
|
42
|
-
*
|
|
50
|
+
* Fetch an existing slot or create it. On creation the schedule's target
|
|
51
|
+
* membership is snapshotted (target_ids); a later config reload never mutates
|
|
52
|
+
* this occurrence. Returns `created:false` when the id already existed so the
|
|
53
|
+
* caller resumes rather than restarting.
|
|
43
54
|
*/
|
|
44
55
|
getOrCreateSlot(id: string, data: {
|
|
45
|
-
slotDate: string;
|
|
46
|
-
slotName: string;
|
|
47
56
|
scheduleId: string;
|
|
57
|
+
occurrenceAt?: number | null;
|
|
58
|
+
occurrenceDate?: string;
|
|
59
|
+
occurrenceLabel?: string;
|
|
60
|
+
timezone?: string;
|
|
61
|
+
targetIds: string[];
|
|
48
62
|
triggerSource?: string;
|
|
63
|
+
slotDate?: string;
|
|
64
|
+
slotName?: string;
|
|
49
65
|
}): {
|
|
50
66
|
slot: SlotRecord;
|
|
51
67
|
created: boolean;
|
|
52
68
|
};
|
|
53
69
|
getSlot(id: string): SlotRecord | null;
|
|
54
|
-
|
|
70
|
+
/** Target ids materialized for a slot (stable membership; falls back to []). */
|
|
71
|
+
getSlotTargetIds(id: string): string[];
|
|
55
72
|
getRecentSlots(limit?: number): SlotRecord[];
|
|
56
73
|
markSlotStatus(id: string, status: SlotStatus, error?: string): void;
|
|
57
74
|
/** All cells for a slot (one per target). */
|
|
58
75
|
getCells(slotId: string): SlotItemRecord[];
|
|
59
76
|
getCell(slotId: string, targetId: string): SlotItemRecord | null;
|
|
77
|
+
/**
|
|
78
|
+
* Ensure a cell exists for every target id in the slot's materialized
|
|
79
|
+
* membership. The cell set is fixed at first materialization (the snapshot in
|
|
80
|
+
* schedule_slots.target_ids); a config reload cannot add/remove cells here.
|
|
81
|
+
* Returns the authoritative target ids for this occurrence.
|
|
82
|
+
*/
|
|
83
|
+
materializeCells(slotId: string, targetIds: string[], workTypeByTarget: (id: string) => string): string[];
|
|
60
84
|
/** Create the cell row if it does not exist (idempotent). */
|
|
61
85
|
ensureCell(slotId: string, targetId: string, workType: string): SlotItemRecord;
|
|
62
86
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlotRepository.d.ts","sourceRoot":"","sources":["../../../src/storage/repositories/SlotRepository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS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O1C,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAOvE;;;;;OAKG;IACI,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,EAAE;IAoBhH,6DAA6D;IACtD,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc;IAWrF;;;;OAIG;IACI,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc;IAevG,4FAA4F;IACrF,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAWrD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAShG,qFAAqF;IAC9E,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IAOpD,8CAA8C;IACvC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;IAUnD,OAAO,CAAC,MAAM;IA2Bd,OAAO,CAAC,MAAM;CAef"}
|
|
@@ -13,20 +13,30 @@ const BaseRepository_1 = require("./BaseRepository");
|
|
|
13
13
|
*/
|
|
14
14
|
class SlotRepository extends BaseRepository_1.BaseRepository {
|
|
15
15
|
/**
|
|
16
|
-
* Fetch an existing slot or create it.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* Fetch an existing slot or create it. On creation the schedule's target
|
|
17
|
+
* membership is snapshotted (target_ids); a later config reload never mutates
|
|
18
|
+
* this occurrence. Returns `created:false` when the id already existed so the
|
|
19
|
+
* caller resumes rather than restarting.
|
|
19
20
|
*/
|
|
20
21
|
getOrCreateSlot(id, data) {
|
|
21
|
-
const insert = this.db.prepare(`INSERT INTO schedule_slots
|
|
22
|
-
|
|
22
|
+
const insert = this.db.prepare(`INSERT INTO schedule_slots
|
|
23
|
+
(id, schedule_id, occurrence_at, occurrence_date, occurrence_label, timezone, target_ids,
|
|
24
|
+
status, trigger_source, slot_date, slot_name)
|
|
25
|
+
VALUES
|
|
26
|
+
(@id, @scheduleId, @occurrenceAt, @occurrenceDate, @occurrenceLabel, @timezone, @targetIds,
|
|
27
|
+
'pending', @triggerSource, @slotDate, @slotName)
|
|
23
28
|
ON CONFLICT(id) DO NOTHING`);
|
|
24
29
|
const info = insert.run({
|
|
25
30
|
id,
|
|
26
|
-
slotDate: data.slotDate,
|
|
27
|
-
slotName: data.slotName,
|
|
28
31
|
scheduleId: data.scheduleId,
|
|
32
|
+
occurrenceAt: data.occurrenceAt ?? null,
|
|
33
|
+
occurrenceDate: data.occurrenceDate ?? '',
|
|
34
|
+
occurrenceLabel: data.occurrenceLabel ?? '',
|
|
35
|
+
timezone: data.timezone ?? 'UTC',
|
|
36
|
+
targetIds: JSON.stringify(data.targetIds),
|
|
29
37
|
triggerSource: data.triggerSource ?? null,
|
|
38
|
+
slotDate: data.slotDate ?? data.occurrenceDate ?? '',
|
|
39
|
+
slotName: data.slotName ?? '',
|
|
30
40
|
});
|
|
31
41
|
const created = info.changes > 0;
|
|
32
42
|
return { slot: this.getSlot(id), created };
|
|
@@ -35,15 +45,22 @@ class SlotRepository extends BaseRepository_1.BaseRepository {
|
|
|
35
45
|
const row = this.db.prepare(`SELECT * FROM schedule_slots WHERE id = ?`).get(id);
|
|
36
46
|
return row ? this.toSlot(row) : null;
|
|
37
47
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
/** Target ids materialized for a slot (stable membership; falls back to []). */
|
|
49
|
+
getSlotTargetIds(id) {
|
|
50
|
+
const row = this.db.prepare(`SELECT target_ids FROM schedule_slots WHERE id = ?`).get(id);
|
|
51
|
+
if (!row?.target_ids)
|
|
52
|
+
return [];
|
|
53
|
+
try {
|
|
54
|
+
const parsed = JSON.parse(row.target_ids);
|
|
55
|
+
return Array.isArray(parsed) ? parsed.map(String) : [];
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
43
60
|
}
|
|
44
61
|
getRecentSlots(limit = 14) {
|
|
45
62
|
const rows = this.db
|
|
46
|
-
.prepare(`SELECT * FROM schedule_slots ORDER BY id DESC LIMIT ?`)
|
|
63
|
+
.prepare(`SELECT * FROM schedule_slots ORDER BY COALESCE(occurrence_at, 0) DESC, id DESC LIMIT ?`)
|
|
47
64
|
.all(limit);
|
|
48
65
|
return rows.map((r) => this.toSlot(r));
|
|
49
66
|
}
|
|
@@ -71,6 +88,29 @@ class SlotRepository extends BaseRepository_1.BaseRepository {
|
|
|
71
88
|
.get(slotId, targetId);
|
|
72
89
|
return row ? this.toItem(row) : null;
|
|
73
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Ensure a cell exists for every target id in the slot's materialized
|
|
93
|
+
* membership. The cell set is fixed at first materialization (the snapshot in
|
|
94
|
+
* schedule_slots.target_ids); a config reload cannot add/remove cells here.
|
|
95
|
+
* Returns the authoritative target ids for this occurrence.
|
|
96
|
+
*/
|
|
97
|
+
materializeCells(slotId, targetIds, workTypeByTarget) {
|
|
98
|
+
// The frozen snapshot (schedule_slots.target_ids) is the authority for which
|
|
99
|
+
// cells belong to this occurrence. Intersect with the requested ids so a
|
|
100
|
+
// later config reload can never materialize a cell outside the snapshot.
|
|
101
|
+
const snapshot = new Set(this.getSlotTargetIds(slotId));
|
|
102
|
+
const authorized = snapshot.size > 0 ? targetIds.filter((id) => snapshot.has(id)) : targetIds;
|
|
103
|
+
const insert = this.db.prepare(`INSERT INTO schedule_slot_items (slot_id, target_id, work_type, status)
|
|
104
|
+
VALUES (@slotId, @targetId, @workType, 'pending')
|
|
105
|
+
ON CONFLICT(slot_id, target_id) DO NOTHING`);
|
|
106
|
+
const tx = this.db.transaction((ids) => {
|
|
107
|
+
for (const targetId of ids) {
|
|
108
|
+
insert.run({ slotId, targetId, workType: workTypeByTarget(targetId) || 'unknown' });
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
tx(authorized);
|
|
112
|
+
return authorized;
|
|
113
|
+
}
|
|
74
114
|
/** Create the cell row if it does not exist (idempotent). */
|
|
75
115
|
ensureCell(slotId, targetId, workType) {
|
|
76
116
|
this.db
|
|
@@ -137,13 +177,27 @@ class SlotRepository extends BaseRepository_1.BaseRepository {
|
|
|
137
177
|
return 'failed';
|
|
138
178
|
}
|
|
139
179
|
toSlot(row) {
|
|
180
|
+
let targetIds = [];
|
|
181
|
+
try {
|
|
182
|
+
const parsed = row.target_ids ? JSON.parse(row.target_ids) : [];
|
|
183
|
+
if (Array.isArray(parsed))
|
|
184
|
+
targetIds = parsed.map(String);
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
targetIds = [];
|
|
188
|
+
}
|
|
140
189
|
return {
|
|
141
190
|
id: row.id,
|
|
142
|
-
slotDate: row.slot_date,
|
|
143
|
-
slotName: row.slot_name,
|
|
144
191
|
scheduleId: row.schedule_id,
|
|
192
|
+
occurrenceAt: row.occurrence_at ?? null,
|
|
193
|
+
occurrenceDate: row.occurrence_date ?? '',
|
|
194
|
+
occurrenceLabel: row.occurrence_label ?? '',
|
|
195
|
+
timezone: row.timezone ?? 'UTC',
|
|
196
|
+
targetIds,
|
|
145
197
|
status: row.status,
|
|
146
198
|
triggerSource: row.trigger_source,
|
|
199
|
+
slotDate: row.slot_date ?? '',
|
|
200
|
+
slotName: row.slot_name ?? '',
|
|
147
201
|
createdAt: row.created_at,
|
|
148
202
|
startedAt: row.started_at,
|
|
149
203
|
completedAt: row.completed_at,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SlotRepository.js","sourceRoot":"","sources":["../../../src/storage/repositories/SlotRepository.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;
|
|
1
|
+
{"version":3,"file":"SlotRepository.js","sourceRoot":"","sources":["../../../src/storage/repositories/SlotRepository.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AA2ClD;;;;;;;;GAQG;AACH,MAAa,cAAe,SAAQ,+BAAc;IAChD;;;;;OAKG;IACI,eAAe,CACpB,EAAU,EACV,IAWC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAC5B;;;;;;kCAM4B,CAC7B,CAAC;QACF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC;YACtB,EAAE;YACF,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,IAAI;YACvC,cAAc,EAAE,IAAI,CAAC,cAAc,IAAI,EAAE;YACzC,eAAe,EAAE,IAAI,CAAC,eAAe,IAAI,EAAE;YAC3C,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,KAAK;YAChC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;YACzC,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,IAAI;YACzC,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,IAAI,EAAE;YACpD,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;SAC9B,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAE,EAAE,OAAO,EAAE,CAAC;IAC9C,CAAC;IAEM,OAAO,CAAC,EAAU;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,2CAA2C,CAAC,CAAC,GAAG,CAAC,EAAE,C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