@shardworks/nexus-core 0.1.17 → 0.1.19

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,QAAQ,EAAE,OAAO,CAAC;IAClB,kCAAkC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,CAiE9D"}
package/dist/dispatch.js DELETED
@@ -1,56 +0,0 @@
1
- /**
2
- * dispatch — core logic for posting commissions to the guild.
3
- *
4
- * Creates a commission record in the Ledger and optionally assigns it to an anima.
5
- * The dispatch implement and CLI both call this function.
6
- */
7
- import Database from 'better-sqlite3';
8
- import { ledgerPath } from "./nexus-home.js";
9
- import { readGuildConfig } from "./guild-config.js";
10
- /**
11
- * Post a commission to the guild.
12
- *
13
- * Creates a commission in the Ledger. If an anima is specified, validates that
14
- * the anima exists and is active, then creates an assignment record.
15
- */
16
- export function dispatch(opts) {
17
- const { home, spec, workshop, anima } = opts;
18
- // Validate workshop exists in guild.json
19
- const config = readGuildConfig(home);
20
- if (!(workshop in config.workshops)) {
21
- const available = Object.keys(config.workshops).join(', ') || '(none)';
22
- throw new Error(`Workshop "${workshop}" not found in guild.json. Available workshops: ${available}`);
23
- }
24
- const db = new Database(ledgerPath(home));
25
- db.pragma('foreign_keys = ON');
26
- try {
27
- const initialStatus = anima ? 'assigned' : 'posted';
28
- // Create commission
29
- const insertCommission = db.prepare(`INSERT INTO commissions (content, status, workshop) VALUES (?, ?, ?)`);
30
- const commissionResult = insertCommission.run(spec, initialStatus, workshop);
31
- const commissionId = Number(commissionResult.lastInsertRowid);
32
- let assigned = false;
33
- let assignedTo;
34
- if (anima) {
35
- // Validate anima exists and is active
36
- const animaRow = db.prepare(`SELECT id, status FROM animas WHERE name = ?`).get(anima);
37
- if (!animaRow) {
38
- throw new Error(`Anima "${anima}" not found in the Ledger.`);
39
- }
40
- if (animaRow.status !== 'active') {
41
- throw new Error(`Anima "${anima}" is not active (status: ${animaRow.status}).`);
42
- }
43
- // Create assignment
44
- db.prepare(`INSERT INTO commission_assignments (commission_id, anima_id) VALUES (?, ?)`).run(commissionId, animaRow.id);
45
- assigned = true;
46
- assignedTo = anima;
47
- }
48
- // Audit log
49
- db.prepare(`INSERT INTO audit_log (actor, action, target_type, target_id, detail) VALUES (?, ?, ?, ?, ?)`).run('dispatch', assigned ? 'commission_dispatched_and_assigned' : 'commission_dispatched', 'commission', commissionId, JSON.stringify({ workshop, anima: assignedTo }));
50
- return { commissionId, assigned, assignedTo };
51
- }
52
- finally {
53
- db.close();
54
- }
55
- }
56
- //# sourceMappingURL=dispatch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAsBpD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAqB;IAC5C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAE7C,yCAAyC;IACzC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