@wrongstack/requirement-intake 1.0.19 → 1.0.24

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 +31 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -430,6 +430,14 @@ var RequirementIntakeStore = class {
430
430
  return this.baseDir;
431
431
  }
432
432
  recordPath(id) {
433
+ if (!/^[A-Za-z0-9_-]{1,128}$/.test(id)) {
434
+ throw new IntakeValidationError([
435
+ {
436
+ field: "id",
437
+ message: "record id must contain only letters, numbers, underscores, or hyphens"
438
+ }
439
+ ]);
440
+ }
433
441
  return path.join(this.baseDir, `${id}.json`);
434
442
  }
435
443
  // -------------------------------------------------------------------------
@@ -1203,6 +1211,12 @@ function applyAnswerUpdateToRecord(record, answerId, newAnswer) {
1203
1211
  question.answer = newAnswer;
1204
1212
  question.status = "answered";
1205
1213
  }
1214
+ const mapping = ANSWER_FIELD_MAPPING[answer.field];
1215
+ if (mapping) {
1216
+ mapping.set(record, newAnswer);
1217
+ const sourceKey = answer.field;
1218
+ record.fieldSources[sourceKey] = "user";
1219
+ }
1206
1220
  }
1207
1221
  function applyAttachmentToRecord(record, validated, actorId, now) {
1208
1222
  if (record.attachments.length >= MAX_ATTACHMENTS) {
@@ -1305,6 +1319,23 @@ var RequirementIntakeService = class {
1305
1319
  const now = Date.now();
1306
1320
  const record = this.buildNewRecord(validated, ctx, now);
1307
1321
  const result = await this.store.create(record, validated.idempotencyKey?.trim());
1322
+ if (!result.created) {
1323
+ if (result.record.projectId !== ctx.projectId) {
1324
+ throw new IntakeValidationError([
1325
+ {
1326
+ field: "idempotencyKey",
1327
+ message: "idempotency key already used for a different project"
1328
+ }
1329
+ ]);
1330
+ }
1331
+ this.metrics.increment("intake.duplicate_create");
1332
+ this.logger.info("intake", "intake.duplicate_create", {
1333
+ intakeId: result.record.id,
1334
+ projectId: result.record.projectId,
1335
+ actorId: ctx.id
1336
+ });
1337
+ return result;
1338
+ }
1308
1339
  this.logger.info("intake", "intake.created", {
1309
1340
  intakeId: result.record.id,
1310
1341
  projectId: result.record.projectId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/requirement-intake",
3
- "version": "1.0.19",
3
+ "version": "1.0.24",
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.19",
30
+ "@wrongstack/core": "1.0.24",
31
31
  "zod": "4.6.2"
32
32
  },
33
33
  "devDependencies": {