@nickpaustian/tela 0.1.3 → 0.3.0

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.
@@ -199,6 +199,8 @@ export function libraryRoutes(deps: {
199
199
  ) => (req: T) => Promise<Response>
200
200
  can: Can
201
201
  json: Json
202
+ /** After a picture's words, or whether it exists, changed: so what publishes it can be brought up to date. */
203
+ changed?: (key: string, user: SessionUser) => Promise<void>
202
204
  /** Tela's own browse and describe, for a store that is not a library. */
203
205
  fallback: {
204
206
  list: (req: Req, user: SessionUser) => Promise<Response>
@@ -360,12 +362,16 @@ export function libraryRoutes(deps: {
360
362
  PATCH: either(async (req, user, library) => {
361
363
  const found = await asset(user, library, req.params.key)
362
364
  await changeable(user, library, found)
363
- return json(await upstream(library.client.describe(found.pid, patchOf(await body(req), { defaults: true }))))
365
+ const described = await upstream(library.client.describe(found.pid, patchOf(await body(req), { defaults: true })))
366
+ await deps.changed?.(req.params.key, user)
367
+ return json(described)
364
368
  }, deps.fallback.describe),
365
369
  DELETE: route(async (req, user, library) => {
366
370
  const found = await asset(user, library, req.params.key)
367
371
  await changeable(user, library, found, "delete")
368
- return json(await upstream(library.client.remove(found.pid, reasonOf(await body(req)))))
372
+ const removed = await upstream(library.client.remove(found.pid, reasonOf(await body(req))))
373
+ await deps.changed?.(req.params.key, user)
374
+ return json(removed)
369
375
  }),
370
376
  },
371
377
 
@@ -373,7 +379,9 @@ export function libraryRoutes(deps: {
373
379
  POST: route(async (req, user, library) => {
374
380
  const found = await asset(user, library, req.params.key)
375
381
  await changeable(user, library, found, "delete")
376
- return json(await upstream(library.client.restore(found.pid)))
382
+ const restored = await upstream(library.client.restore(found.pid))
383
+ await deps.changed?.(req.params.key, user)
384
+ return json(restored)
377
385
  }),
378
386
  },
379
387