luomus / laji-api

New LajiApi, still in prototype phase
MIT License
0 stars 0 forks source link

Deprecate documents batch upload by POST `/documents` and `/documents/validate` #36

Open olzraiti opened 2 days ago

olzraiti commented 2 days ago

Currently the document batch upload can be done with the same endpoints as validation & document creation. This is completely undocumented (and impossible to document) by our Swagger document. It also makes the code more complicated. This is all inherited from the old API.

The new process goes like this:

  1. Create a batch job by sending a documents array with POST /documents/batch (returns { id: string, phase: "VALIDATING", status: { processed, total, percentage } })
  2. The batch job status can be tracked by GET /documents/batch/:id (the id returned in step 1)
  3. Once the phase is "VALIDATED", the job can be requested to be sent to the store with POST /documents/batch/:id
  4. The batch job status can be tracked by GET /documents/batch/:id (the id returned in step 1). The job has now phase: "SENDING"
  5. Once the status' validated is true, the job can be requested to be sent to the store with POST /documents/batch/:id. Once done, the job has phase: "SENT"
olzraiti commented 2 days ago

After fixed, remove code marked with // TODO REMOVE_AFTER_#36