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 1 month ago

olzraiti commented 1 month 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 1 month ago

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

olzraiti commented 1 month ago

commit https://github.com/luomus/laji-api/commit/55919ab9e4c4cbf98798d7ebbe03a0a4214ba690 accidentally points to this, it shouldn't have closed this