Skip to content

feat: add batch interpretation endpoint #90

Description

@MagPasulke

Feature: Batch interpretation endpoint

Goal

Support interpreting many input strings in one request for high-throughput scanner scenarios.

Draft API

Ednpoint Design tbd, consider BATCH like in odata

Single RuleSet, multiple inputs. Reuse existing auth/cache/factory flow and execute interpreter per item.

Request example

{
  "items": [
    { "id": "scan-001", "source": "01076123456789001724063010ABC123" },
    { "id": "scan-002", "source": "01076123456789001724070110XYZ999" }
  ],
  "options": {
    "stopOnFirstError": false,
    "includeTrace": false
  }
}

Response example

{
  "rulesetId": "RS_PACK_LABEL",
  "summary": {
    "total": 2,
    "ok": 2,
    "failed": 0,
    "durationMs": 14
  },
  "results": [
    {
      "id": "scan-001",
      "status": "ok",
      "result": {
        "material": "7612345678900",
        "expiryDate": "2024-06-30",
        "batch": "ABC123"
      }
    },
    {
      "id": "scan-002",
      "status": "ok",
      "result": {
        "material": "7612345678900",
        "expiryDate": "2024-07-01",
        "batch": "XYZ999"
      }
    }
  ]
}

Behavior draft

  1. Max items: 500 (configurable).
  2. id required and unique within request.
  3. Per-item isolation by default (stopOnFirstError=false).
  4. Per-item error shape: { id, status: "error", error: { code, message } }.
  5. HTTP status semantics:
    • 200 when request envelope valid (even mixed item errors)
    • 400 malformed payload / duplicate ids / too many items
    • 401/403 auth
    • 404 ruleset not found
  6. Optional includeTrace=true returns applied rule IDs + intermediate values per item.

Implementation notes

  • Add route in zasis_cl_http_handler for :batch.
  • Load RuleSet once via zasis_cl_ruleset_factory.
  • Iterate items and execute zasis_cl_interpreter per item.
  • Return ordered results matching input order + summary counters.

Acceptance criteria

  • Batch endpoint supports at least 500 items (configurable).
  • One failing item does not fail whole batch by default.
  • Output preserves item order and includes per-item status.
  • Validation and error semantics implemented as drafted.
  • Add/adjust tests (npm test, and npm run icf-test for HTTP stack changes).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions