@wrongstack/requirement-intake 1.0.27 → 1.0.28

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.
Files changed (2) hide show
  1. package/dist/index.js +39 -38
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -386,9 +386,7 @@ function pendingQuestions(record) {
386
386
  return record.questions.filter((question) => question.status === "unanswered").sort((a, b) => a.order - b.order);
387
387
  }
388
388
  function upsertQuestion(record, template) {
389
- const existing = record.questions.find(
390
- (question) => question.field === template.field && question.status !== "skipped"
391
- );
389
+ const existing = record.questions.find((question) => question.field === template.field);
392
390
  if (existing) return false;
393
391
  record.questions.push(makeQuestion(template, record.questions.length, false));
394
392
  return true;
@@ -460,8 +458,11 @@ var RequirementIntakeStore = class {
460
458
  try {
461
459
  const raw = await fsp.readFile(this.recordPath(id), "utf8");
462
460
  return JSON.parse(raw);
463
- } catch {
464
- return null;
461
+ } catch (error) {
462
+ if (error instanceof IntakeValidationError || error.code === "ENOENT") {
463
+ return null;
464
+ }
465
+ throw error;
465
466
  }
466
467
  }
467
468
  async exists(id) {
@@ -1704,22 +1705,22 @@ var RequirementIntakeService = class {
1704
1705
  async cancelIntake(id, ctx, reason, expectedVersion) {
1705
1706
  const record = await this.requireRecord(id, ctx, "cancel");
1706
1707
  assertTransition(record.status, "cancelled");
1707
- const updated = await this.store.update(
1708
- id,
1709
- {
1710
- actorId: ctx.id,
1711
- actorType: ctx.type,
1712
- action: "cancelled",
1713
- from: record.status,
1714
- to: "cancelled",
1715
- expectedVersion
1716
- },
1717
- (next) => {
1718
- next.status = "cancelled";
1719
- next.cancelledAt = Date.now();
1720
- next.cancelledReason = reason?.trim() || void 0;
1721
- }
1722
- );
1708
+ let previousStatus = record.status;
1709
+ const meta = {
1710
+ actorId: ctx.id,
1711
+ actorType: ctx.type,
1712
+ action: "cancelled",
1713
+ from: record.status,
1714
+ to: "cancelled",
1715
+ expectedVersion
1716
+ };
1717
+ const updated = await this.store.update(id, meta, (next) => {
1718
+ assertTransition(next.status, "cancelled");
1719
+ previousStatus = meta.from = next.status;
1720
+ next.status = "cancelled";
1721
+ next.cancelledAt = Date.now();
1722
+ next.cancelledReason = reason?.trim() || void 0;
1723
+ });
1723
1724
  this.metrics.increment("intake.cancelled");
1724
1725
  this.logger.info("intake", "intake.cancelled", {
1725
1726
  intakeId: updated.id,
@@ -1731,7 +1732,7 @@ var RequirementIntakeService = class {
1731
1732
  projectId: updated.projectId,
1732
1733
  actorId: ctx.id,
1733
1734
  actorType: ctx.type,
1734
- previousStatus: record.status,
1735
+ previousStatus,
1735
1736
  status: "cancelled"
1736
1737
  });
1737
1738
  return updated;
@@ -1739,21 +1740,21 @@ var RequirementIntakeService = class {
1739
1740
  async archiveIntake(id, ctx, expectedVersion) {
1740
1741
  const record = await this.requireRecord(id, ctx, "archive");
1741
1742
  assertTransition(record.status, "archived");
1742
- const updated = await this.store.update(
1743
- id,
1744
- {
1745
- actorId: ctx.id,
1746
- actorType: ctx.type,
1747
- action: "archived",
1748
- from: record.status,
1749
- to: "archived",
1750
- expectedVersion
1751
- },
1752
- (next) => {
1753
- next.status = "archived";
1754
- next.archivedAt = Date.now();
1755
- }
1756
- );
1743
+ let previousStatus = record.status;
1744
+ const meta = {
1745
+ actorId: ctx.id,
1746
+ actorType: ctx.type,
1747
+ action: "archived",
1748
+ from: record.status,
1749
+ to: "archived",
1750
+ expectedVersion
1751
+ };
1752
+ const updated = await this.store.update(id, meta, (next) => {
1753
+ assertTransition(next.status, "archived");
1754
+ previousStatus = meta.from = next.status;
1755
+ next.status = "archived";
1756
+ next.archivedAt = Date.now();
1757
+ });
1757
1758
  this.metrics.increment("intake.archived");
1758
1759
  this.logger.info("intake", "intake.archived", {
1759
1760
  intakeId: updated.id,
@@ -1765,7 +1766,7 @@ var RequirementIntakeService = class {
1765
1766
  projectId: updated.projectId,
1766
1767
  actorId: ctx.id,
1767
1768
  actorType: ctx.type,
1768
- previousStatus: record.status,
1769
+ previousStatus,
1769
1770
  status: "archived"
1770
1771
  });
1771
1772
  return updated;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/requirement-intake",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack Requirements Intake — collect, preserve, validate, normalize, and submit unstructured software development requests as structured intake records. Upstream of spec-driven development: it never plans, specifies, or implements.",
6
6
  "repository": {
@@ -27,7 +27,7 @@
27
27
  "!dist/**/*.map"
28
28
  ],
29
29
  "dependencies": {
30
- "@wrongstack/core": "1.0.27",
30
+ "@wrongstack/core": "1.0.28",
31
31
  "zod": "4.6.2"
32
32
  },
33
33
  "devDependencies": {