@orthacms/content-server 0.4.2 → 0.5.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.
Files changed (246) hide show
  1. package/dist/index.d.ts +16 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +41 -1
  4. package/dist/lib/content.module.d.ts.map +1 -1
  5. package/dist/lib/content.module.js +31 -1
  6. package/dist/lib/copilot/entry-proposal.applier.d.ts.map +1 -1
  7. package/dist/lib/copilot/entry-proposal.applier.js +5 -4
  8. package/dist/lib/docs/describe-content-api.d.ts +7 -0
  9. package/dist/lib/docs/describe-content-api.d.ts.map +1 -1
  10. package/dist/lib/docs/describe-content-api.js +177 -53
  11. package/dist/lib/docs/describe-views-api.d.ts +19 -0
  12. package/dist/lib/docs/describe-views-api.d.ts.map +1 -0
  13. package/dist/lib/docs/describe-views-api.js +76 -0
  14. package/dist/lib/docs/field-schema.d.ts.map +1 -1
  15. package/dist/lib/docs/field-schema.js +36 -2
  16. package/dist/lib/docs/openapi-writer.d.ts +49 -0
  17. package/dist/lib/docs/openapi-writer.d.ts.map +1 -0
  18. package/dist/lib/docs/openapi-writer.js +76 -0
  19. package/dist/lib/docs/public-api-schemas.d.ts +45 -0
  20. package/dist/lib/docs/public-api-schemas.d.ts.map +1 -0
  21. package/dist/lib/docs/public-api-schemas.js +377 -0
  22. package/dist/lib/docs/views-schemas.d.ts +22 -0
  23. package/dist/lib/docs/views-schemas.d.ts.map +1 -0
  24. package/dist/lib/docs/views-schemas.js +156 -0
  25. package/dist/lib/entries/application/use-cases/bulk-publish-entries.use-case.d.ts +8 -2
  26. package/dist/lib/entries/application/use-cases/bulk-publish-entries.use-case.d.ts.map +1 -1
  27. package/dist/lib/entries/application/use-cases/bulk-publish-entries.use-case.js +19 -4
  28. package/dist/lib/entries/application/use-cases/bulk-unpublish-entries.use-case.d.ts +2 -2
  29. package/dist/lib/entries/application/use-cases/bulk-unpublish-entries.use-case.d.ts.map +1 -1
  30. package/dist/lib/entries/application/use-cases/bulk-unpublish-entries.use-case.js +14 -4
  31. package/dist/lib/entries/application/use-cases/publish-entry.use-case.d.ts +6 -8
  32. package/dist/lib/entries/application/use-cases/publish-entry.use-case.d.ts.map +1 -1
  33. package/dist/lib/entries/application/use-cases/publish-entry.use-case.js +10 -4
  34. package/dist/lib/entries/application/use-cases/unpublish-entry.use-case.d.ts +2 -5
  35. package/dist/lib/entries/application/use-cases/unpublish-entry.use-case.d.ts.map +1 -1
  36. package/dist/lib/entries/application/use-cases/unpublish-entry.use-case.js +6 -1
  37. package/dist/lib/entries/domain/entry.d.ts +8 -1
  38. package/dist/lib/entries/domain/entry.d.ts.map +1 -1
  39. package/dist/lib/entries/domain/entry.js +12 -12
  40. package/dist/lib/entries/domain/events/entry-events.d.ts +47 -5
  41. package/dist/lib/entries/domain/events/entry-events.d.ts.map +1 -1
  42. package/dist/lib/entries/domain/events/entry-events.js +26 -10
  43. package/dist/lib/entries/entries.constants.d.ts +10 -2
  44. package/dist/lib/entries/entries.constants.d.ts.map +1 -1
  45. package/dist/lib/entries/entries.constants.js +11 -2
  46. package/dist/lib/entries/http/controllers/bulk-entries.controller.d.ts +2 -2
  47. package/dist/lib/entries/http/controllers/bulk-entries.controller.d.ts.map +1 -1
  48. package/dist/lib/entries/http/controllers/bulk-entries.controller.js +8 -6
  49. package/dist/lib/entries/http/controllers/create-entry.controller.d.ts.map +1 -1
  50. package/dist/lib/entries/http/controllers/create-entry.controller.js +1 -1
  51. package/dist/lib/entries/http/controllers/update-entry.controller.d.ts.map +1 -1
  52. package/dist/lib/entries/http/controllers/update-entry.controller.js +1 -1
  53. package/dist/lib/entries/http/dto/extension-bag.validator.d.ts +14 -0
  54. package/dist/lib/entries/http/dto/extension-bag.validator.d.ts.map +1 -0
  55. package/dist/lib/entries/http/dto/extension-bag.validator.js +42 -0
  56. package/dist/lib/entries/http/dto/save-entry.dto.d.ts +16 -0
  57. package/dist/lib/entries/http/dto/save-entry.dto.d.ts.map +1 -1
  58. package/dist/lib/entries/http/dto/save-entry.dto.js +30 -0
  59. package/dist/lib/entries/infrastructure/persistence/entry-writer.service.d.ts +50 -8
  60. package/dist/lib/entries/infrastructure/persistence/entry-writer.service.d.ts.map +1 -1
  61. package/dist/lib/entries/infrastructure/persistence/entry-writer.service.js +183 -32
  62. package/dist/lib/entries/infrastructure/persistence/relation-link.service.d.ts +38 -5
  63. package/dist/lib/entries/infrastructure/persistence/relation-link.service.d.ts.map +1 -1
  64. package/dist/lib/entries/infrastructure/persistence/relation-link.service.js +38 -6
  65. package/dist/lib/entries/infrastructure/queries/entries.service.d.ts +3 -1
  66. package/dist/lib/entries/infrastructure/queries/entries.service.d.ts.map +1 -1
  67. package/dist/lib/entries/infrastructure/queries/entries.service.js +17 -5
  68. package/dist/lib/entries/infrastructure/queries/entry-match.query.d.ts +82 -0
  69. package/dist/lib/entries/infrastructure/queries/entry-match.query.d.ts.map +1 -0
  70. package/dist/lib/entries/infrastructure/queries/entry-match.query.js +152 -0
  71. package/dist/lib/extension/entry-filter-provider.d.ts +79 -0
  72. package/dist/lib/extension/entry-filter-provider.d.ts.map +1 -0
  73. package/dist/lib/extension/entry-filter-provider.js +149 -0
  74. package/dist/lib/extension/entry-write-extension.d.ts +185 -0
  75. package/dist/lib/extension/entry-write-extension.d.ts.map +1 -0
  76. package/dist/lib/extension/entry-write-extension.js +182 -0
  77. package/dist/lib/extension/read-scope.d.ts +107 -0
  78. package/dist/lib/extension/read-scope.d.ts.map +1 -0
  79. package/dist/lib/extension/read-scope.js +131 -0
  80. package/dist/lib/insights/docs/describe-content-insights-api.d.ts +23 -0
  81. package/dist/lib/insights/docs/describe-content-insights-api.d.ts.map +1 -0
  82. package/dist/lib/insights/docs/describe-content-insights-api.js +329 -0
  83. package/dist/lib/mcp/content-tools.provider.d.ts.map +1 -1
  84. package/dist/lib/mcp/content-tools.provider.js +10 -9
  85. package/dist/lib/public-api/http/controllers/public-entry-writes.controller.d.ts +14 -13
  86. package/dist/lib/public-api/http/controllers/public-entry-writes.controller.d.ts.map +1 -1
  87. package/dist/lib/public-api/http/controllers/public-entry-writes.controller.js +62 -46
  88. package/dist/lib/public-api/http/guards/api-token-workspace.guard.d.ts.map +1 -1
  89. package/dist/lib/public-api/http/guards/api-token-workspace.guard.js +8 -0
  90. package/dist/lib/public-api/infrastructure/public-entries.query.d.ts +14 -1
  91. package/dist/lib/public-api/infrastructure/public-entries.query.d.ts.map +1 -1
  92. package/dist/lib/public-api/infrastructure/public-entries.query.js +20 -3
  93. package/dist/lib/public-api/infrastructure/public-entry-writes.service.d.ts +10 -9
  94. package/dist/lib/public-api/infrastructure/public-entry-writes.service.d.ts.map +1 -1
  95. package/dist/lib/public-api/infrastructure/public-entry-writes.service.js +23 -24
  96. package/dist/lib/public-api/infrastructure/public-expansion.query.d.ts +16 -4
  97. package/dist/lib/public-api/infrastructure/public-expansion.query.d.ts.map +1 -1
  98. package/dist/lib/public-api/infrastructure/public-expansion.query.js +29 -9
  99. package/dist/lib/public-api/infrastructure/token-actor.d.ts +37 -0
  100. package/dist/lib/public-api/infrastructure/token-actor.d.ts.map +1 -0
  101. package/dist/lib/public-api/infrastructure/token-actor.js +58 -0
  102. package/dist/lib/revisions/application/use-cases/restore-revision.use-case.d.ts.map +1 -1
  103. package/dist/lib/revisions/application/use-cases/restore-revision.use-case.js +23 -1
  104. package/dist/lib/revisions/infrastructure/persistence/revision-snapshot.d.ts +7 -1
  105. package/dist/lib/revisions/infrastructure/persistence/revision-snapshot.d.ts.map +1 -1
  106. package/dist/lib/revisions/infrastructure/persistence/revision-snapshot.js +9 -2
  107. package/dist/lib/revisions/infrastructure/purge/revisions-workspace.purger.d.ts +28 -0
  108. package/dist/lib/revisions/infrastructure/purge/revisions-workspace.purger.d.ts.map +1 -0
  109. package/dist/lib/revisions/infrastructure/purge/revisions-workspace.purger.js +52 -0
  110. package/dist/lib/revisions/types/revision-view.d.ts +11 -0
  111. package/dist/lib/revisions/types/revision-view.d.ts.map +1 -1
  112. package/dist/lib/utils/content-plugin.d.ts.map +1 -1
  113. package/dist/lib/utils/content-plugin.js +10 -1
  114. package/dist/lib/utils/content-views-plugin.d.ts +28 -0
  115. package/dist/lib/utils/content-views-plugin.d.ts.map +1 -0
  116. package/dist/lib/utils/content-views-plugin.js +37 -0
  117. package/dist/lib/views/application/queries/saved-views.query.d.ts +16 -0
  118. package/dist/lib/views/application/queries/saved-views.query.d.ts.map +1 -0
  119. package/dist/lib/views/application/queries/saved-views.query.js +46 -0
  120. package/dist/lib/views/application/saved-view-access.service.d.ts +30 -0
  121. package/dist/lib/views/application/saved-view-access.service.d.ts.map +1 -0
  122. package/dist/lib/views/application/saved-view-access.service.js +55 -0
  123. package/dist/lib/views/application/use-cases/create-saved-view.use-case.d.ts +30 -0
  124. package/dist/lib/views/application/use-cases/create-saved-view.use-case.d.ts.map +1 -0
  125. package/dist/lib/views/application/use-cases/create-saved-view.use-case.js +81 -0
  126. package/dist/lib/views/application/use-cases/delete-saved-view.use-case.d.ts +18 -0
  127. package/dist/lib/views/application/use-cases/delete-saved-view.use-case.d.ts.map +1 -0
  128. package/dist/lib/views/application/use-cases/delete-saved-view.use-case.js +56 -0
  129. package/dist/lib/views/application/use-cases/set-default-view.use-case.d.ts +23 -0
  130. package/dist/lib/views/application/use-cases/set-default-view.use-case.d.ts.map +1 -0
  131. package/dist/lib/views/application/use-cases/set-default-view.use-case.js +51 -0
  132. package/dist/lib/views/application/use-cases/update-saved-view.use-case.d.ts +24 -0
  133. package/dist/lib/views/application/use-cases/update-saved-view.use-case.d.ts.map +1 -0
  134. package/dist/lib/views/application/use-cases/update-saved-view.use-case.js +90 -0
  135. package/dist/lib/views/application/view-scope.service.d.ts +25 -0
  136. package/dist/lib/views/application/view-scope.service.d.ts.map +1 -0
  137. package/dist/lib/views/application/view-scope.service.js +45 -0
  138. package/dist/lib/views/content-views.module.d.ts +22 -0
  139. package/dist/lib/views/content-views.module.d.ts.map +1 -0
  140. package/dist/lib/views/content-views.module.js +63 -0
  141. package/dist/lib/views/domain/errors/index.d.ts +6 -0
  142. package/dist/lib/views/domain/errors/index.d.ts.map +1 -0
  143. package/dist/lib/views/domain/errors/index.js +12 -0
  144. package/dist/lib/views/domain/errors/saved-view-forbidden.error.d.ts +10 -0
  145. package/dist/lib/views/domain/errors/saved-view-forbidden.error.d.ts.map +1 -0
  146. package/dist/lib/views/domain/errors/saved-view-forbidden.error.js +16 -0
  147. package/dist/lib/views/domain/errors/saved-view-limit-error.d.ts +9 -0
  148. package/dist/lib/views/domain/errors/saved-view-limit-error.d.ts.map +1 -0
  149. package/dist/lib/views/domain/errors/saved-view-limit-error.js +16 -0
  150. package/dist/lib/views/domain/errors/saved-view-name-taken.error.d.ts +5 -0
  151. package/dist/lib/views/domain/errors/saved-view-name-taken.error.d.ts.map +1 -0
  152. package/dist/lib/views/domain/errors/saved-view-name-taken.error.js +11 -0
  153. package/dist/lib/views/domain/errors/saved-view-not-found.error.d.ts +9 -0
  154. package/dist/lib/views/domain/errors/saved-view-not-found.error.d.ts.map +1 -0
  155. package/dist/lib/views/domain/errors/saved-view-not-found.error.js +15 -0
  156. package/dist/lib/views/domain/events/saved-view-events.d.ts +28 -0
  157. package/dist/lib/views/domain/events/saved-view-events.d.ts.map +1 -0
  158. package/dist/lib/views/domain/events/saved-view-events.js +38 -0
  159. package/dist/lib/views/domain/saved-view.d.ts +66 -0
  160. package/dist/lib/views/domain/saved-view.d.ts.map +1 -0
  161. package/dist/lib/views/domain/saved-view.js +18 -0
  162. package/dist/lib/views/domain/saved-view.repository.d.ts +77 -0
  163. package/dist/lib/views/domain/saved-view.repository.d.ts.map +1 -0
  164. package/dist/lib/views/domain/saved-view.repository.js +5 -0
  165. package/dist/lib/views/http/controllers/saved-views.controller.d.ts +45 -0
  166. package/dist/lib/views/http/controllers/saved-views.controller.d.ts.map +1 -0
  167. package/dist/lib/views/http/controllers/saved-views.controller.js +216 -0
  168. package/dist/lib/views/http/controllers/to-http-error.d.ts +10 -0
  169. package/dist/lib/views/http/controllers/to-http-error.d.ts.map +1 -0
  170. package/dist/lib/views/http/controllers/to-http-error.js +26 -0
  171. package/dist/lib/views/http/dto/save-view.dto.d.ts +54 -0
  172. package/dist/lib/views/http/dto/save-view.dto.d.ts.map +1 -0
  173. package/dist/lib/views/http/dto/save-view.dto.js +230 -0
  174. package/dist/lib/views/http/dto/view-payload.validator.d.ts +20 -0
  175. package/dist/lib/views/http/dto/view-payload.validator.d.ts.map +1 -0
  176. package/dist/lib/views/http/dto/view-payload.validator.js +52 -0
  177. package/dist/lib/views/infrastructure/persistence/drizzle-saved-view.repository.d.ts +26 -0
  178. package/dist/lib/views/infrastructure/persistence/drizzle-saved-view.repository.d.ts.map +1 -0
  179. package/dist/lib/views/infrastructure/persistence/drizzle-saved-view.repository.js +135 -0
  180. package/dist/lib/views/infrastructure/schema/external-refs.d.ts +68 -0
  181. package/dist/lib/views/infrastructure/schema/external-refs.d.ts.map +1 -0
  182. package/dist/lib/views/infrastructure/schema/external-refs.js +29 -0
  183. package/dist/lib/views/infrastructure/schema/index.d.ts +8 -0
  184. package/dist/lib/views/infrastructure/schema/index.d.ts.map +1 -0
  185. package/dist/lib/views/infrastructure/schema/index.js +13 -0
  186. package/dist/lib/views/infrastructure/schema/saved-views.d.ts +275 -0
  187. package/dist/lib/views/infrastructure/schema/saved-views.d.ts.map +1 -0
  188. package/dist/lib/views/infrastructure/schema/saved-views.js +87 -0
  189. package/dist/lib/views/views.constants.d.ts +26 -0
  190. package/dist/lib/views/views.constants.d.ts.map +1 -0
  191. package/dist/lib/views/views.constants.js +28 -0
  192. package/dist/lib/views/views.tokens.d.ts +17 -0
  193. package/dist/lib/views/views.tokens.d.ts.map +1 -0
  194. package/dist/lib/views/views.tokens.js +21 -0
  195. package/migrations/0000_saved_views.sql +29 -0
  196. package/migrations/meta/0000_snapshot.json +256 -0
  197. package/migrations/meta/_journal.json +13 -0
  198. package/package.json +13 -12
  199. package/dist/lib/entries/controllers/bulk-entries.controller.d.ts +0 -26
  200. package/dist/lib/entries/controllers/bulk-entries.controller.d.ts.map +0 -1
  201. package/dist/lib/entries/controllers/create-entry.controller.d.ts +0 -20
  202. package/dist/lib/entries/controllers/create-entry.controller.d.ts.map +0 -1
  203. package/dist/lib/entries/controllers/delete-entry.controller.d.ts +0 -24
  204. package/dist/lib/entries/controllers/delete-entry.controller.d.ts.map +0 -1
  205. package/dist/lib/entries/controllers/get-entry.controller.d.ts +0 -34
  206. package/dist/lib/entries/controllers/get-entry.controller.d.ts.map +0 -1
  207. package/dist/lib/entries/controllers/list-entries.controller.d.ts +0 -20
  208. package/dist/lib/entries/controllers/list-entries.controller.d.ts.map +0 -1
  209. package/dist/lib/entries/controllers/publish-entry.controller.d.ts +0 -19
  210. package/dist/lib/entries/controllers/publish-entry.controller.d.ts.map +0 -1
  211. package/dist/lib/entries/controllers/resolve-type.d.ts +0 -9
  212. package/dist/lib/entries/controllers/resolve-type.d.ts.map +0 -1
  213. package/dist/lib/entries/controllers/update-entry.controller.d.ts +0 -18
  214. package/dist/lib/entries/controllers/update-entry.controller.d.ts.map +0 -1
  215. package/dist/lib/entries/dto/bulk-ids.dto.d.ts +0 -11
  216. package/dist/lib/entries/dto/bulk-ids.dto.d.ts.map +0 -1
  217. package/dist/lib/entries/dto/list-entries-query.dto.d.ts +0 -46
  218. package/dist/lib/entries/dto/list-entries-query.dto.d.ts.map +0 -1
  219. package/dist/lib/entries/dto/relation-delta-map.validator.d.ts +0 -19
  220. package/dist/lib/entries/dto/relation-delta-map.validator.d.ts.map +0 -1
  221. package/dist/lib/entries/dto/save-entry.dto.d.ts +0 -46
  222. package/dist/lib/entries/dto/save-entry.dto.d.ts.map +0 -1
  223. package/dist/lib/entries/infrastructure/persistence/field-selection.d.ts +0 -24
  224. package/dist/lib/entries/infrastructure/persistence/field-selection.d.ts.map +0 -1
  225. package/dist/lib/entries/infrastructure/queries/entry-filter-schema.d.ts +0 -40
  226. package/dist/lib/entries/infrastructure/queries/entry-filter-schema.d.ts.map +0 -1
  227. package/dist/lib/entries/services/entries.service.d.ts +0 -59
  228. package/dist/lib/entries/services/entries.service.d.ts.map +0 -1
  229. package/dist/lib/entries/services/entry-counter.service.d.ts +0 -31
  230. package/dist/lib/entries/services/entry-counter.service.d.ts.map +0 -1
  231. package/dist/lib/entries/services/entry-filter-schema.d.ts +0 -32
  232. package/dist/lib/entries/services/entry-filter-schema.d.ts.map +0 -1
  233. package/dist/lib/entries/services/entry-row.d.ts +0 -56
  234. package/dist/lib/entries/services/entry-row.d.ts.map +0 -1
  235. package/dist/lib/entries/services/entry-writer.service.d.ts +0 -193
  236. package/dist/lib/entries/services/entry-writer.service.d.ts.map +0 -1
  237. package/dist/lib/entries/services/relation-link.service.d.ts +0 -115
  238. package/dist/lib/entries/services/relation-link.service.d.ts.map +0 -1
  239. package/dist/lib/extension/per-locale-relation.d.ts +0 -18
  240. package/dist/lib/extension/per-locale-relation.d.ts.map +0 -1
  241. package/dist/lib/public/controllers/get-public-entry.controller.d.ts +0 -26
  242. package/dist/lib/public/controllers/get-public-entry.controller.d.ts.map +0 -1
  243. package/dist/lib/public/controllers/list-public-entries.controller.d.ts +0 -24
  244. package/dist/lib/public/controllers/list-public-entries.controller.d.ts.map +0 -1
  245. package/dist/lib/public/controllers/public-schema.controller.d.ts +0 -18
  246. package/dist/lib/public/controllers/public-schema.controller.d.ts.map +0 -1
@@ -9,6 +9,8 @@ const workspaces_server_1 = require("@orthacms/workspaces-server");
9
9
  const content_tokens_1 = require("../../../content.tokens");
10
10
  const workspace_grants_query_1 = require("../../../content-types/queries/workspace-grants.query");
11
11
  const public_entry_writes_service_1 = require("../../infrastructure/public-entry-writes.service");
12
+ const token_actor_1 = require("../../infrastructure/token-actor");
13
+ const current_api_token_decorator_1 = require("../decorators/current-api-token.decorator");
12
14
  const api_token_guard_1 = require("../guards/api-token.guard");
13
15
  const api_token_workspace_guard_1 = require("../guards/api-token-workspace.guard");
14
16
  const public_save_entry_dto_1 = require("../dto/public-save-entry.dto");
@@ -54,9 +56,9 @@ let PublicEntryWritesController = class PublicEntryWritesController {
54
56
  this.writes = writes;
55
57
  }
56
58
  /** `POST /api/v1/content/:typeName` — create a draft entry. */
57
- async create(typeName, body, workspaceId) {
59
+ async create(typeName, body, workspaceId, token) {
58
60
  const { type, granted } = await (0, resolve_granted_type_1.resolveGrantedType)(this.registry, this.grants, typeName, workspaceId);
59
- return this.writes.create(type, body, workspaceId, granted);
61
+ return this.writes.create(type, body, workspaceId, granted, (0, token_actor_1.toTokenActor)(token));
60
62
  }
61
63
  // ---- batches -----------------------------------------------------------
62
64
  //
@@ -66,24 +68,24 @@ let PublicEntryWritesController = class PublicEntryWritesController {
66
68
  // that turns a mis-ordered match into a 400, not a substitute for the order.
67
69
  // Same arrangement, same reason, as the admin's `BulkEntriesController`.
68
70
  /** `POST /api/v1/content/:typeName/bulk` — create and/or update many entries. */
69
- async bulkSave(typeName, body, workspaceId) {
71
+ async bulkSave(typeName, body, workspaceId, token) {
70
72
  const { type, granted } = await (0, resolve_granted_type_1.resolveGrantedType)(this.registry, this.grants, typeName, workspaceId);
71
- return this.writes.bulkSave(type, body.items, workspaceId, granted);
73
+ return this.writes.bulkSave(type, body.items, workspaceId, granted, (0, token_actor_1.toTokenActor)(token));
72
74
  }
73
75
  /** `POST /api/v1/content/:typeName/bulk/publish` — take many entries live. */
74
- async bulkPublish(typeName, body, workspaceId) {
76
+ async bulkPublish(typeName, body, workspaceId, token) {
75
77
  const { type } = await (0, resolve_granted_type_1.resolveGrantedType)(this.registry, this.grants, typeName, workspaceId);
76
- return this.writes.bulkPublish(type, body.ids, workspaceId);
78
+ return this.writes.bulkPublish(type, body.ids, workspaceId, (0, token_actor_1.toTokenActor)(token));
77
79
  }
78
80
  /** `POST /api/v1/content/:typeName/bulk/unpublish` — take many off the air. */
79
- async bulkUnpublish(typeName, body, workspaceId) {
81
+ async bulkUnpublish(typeName, body, workspaceId, token) {
80
82
  const { type } = await (0, resolve_granted_type_1.resolveGrantedType)(this.registry, this.grants, typeName, workspaceId);
81
- return this.writes.bulkUnpublish(type, body.ids, workspaceId);
83
+ return this.writes.bulkUnpublish(type, body.ids, workspaceId, (0, token_actor_1.toTokenActor)(token));
82
84
  }
83
85
  /** `POST /api/v1/content/:typeName/bulk/delete` — remove many entries. */
84
- async bulkRemove(typeName, body, workspaceId) {
86
+ async bulkRemove(typeName, body, workspaceId, token) {
85
87
  const { type } = await (0, resolve_granted_type_1.resolveGrantedType)(this.registry, this.grants, typeName, workspaceId);
86
- return this.writes.bulkRemove(type, body.ids, workspaceId);
88
+ return this.writes.bulkRemove(type, body.ids, workspaceId, (0, token_actor_1.toTokenActor)(token));
87
89
  }
88
90
  // ---- addressed by translation group -----------------------------------
89
91
  //
@@ -91,60 +93,61 @@ let PublicEntryWritesController = class PublicEntryWritesController {
91
93
  // cannot collide on segment count, but Express matches in declaration order
92
94
  // and literal-prefixed routes belong ahead of wildcards.
93
95
  /** `PATCH /api/v1/content/:typeName/group/:localeGroupId` */
94
- updateByGroup(typeName, localeGroupId, body, query, workspaceId) {
95
- return this.applyUpdate(typeName, { localeGroupId }, body, workspaceId, query.locale);
96
+ updateByGroup(typeName, localeGroupId, body, query, workspaceId, token) {
97
+ return this.applyUpdate(typeName, { localeGroupId }, body, workspaceId, query.locale, token);
96
98
  }
97
99
  /** `POST /api/v1/content/:typeName/group/:localeGroupId/publish` */
98
- publishByGroup(typeName, localeGroupId, query, workspaceId) {
99
- return this.applyPublish(typeName, { localeGroupId }, workspaceId, query.locale, true);
100
+ publishByGroup(typeName, localeGroupId, query, workspaceId, token) {
101
+ return this.applyPublish(typeName, { localeGroupId }, workspaceId, query.locale, true, token);
100
102
  }
101
103
  /** `POST /api/v1/content/:typeName/group/:localeGroupId/unpublish` */
102
- unpublishByGroup(typeName, localeGroupId, query, workspaceId) {
103
- return this.applyPublish(typeName, { localeGroupId }, workspaceId, query.locale, false);
104
+ unpublishByGroup(typeName, localeGroupId, query, workspaceId, token) {
105
+ return this.applyPublish(typeName, { localeGroupId }, workspaceId, query.locale, false, token);
104
106
  }
105
107
  /** `DELETE /api/v1/content/:typeName/group/:localeGroupId` */
106
- removeByGroup(typeName, localeGroupId, query, workspaceId) {
107
- return this.applyRemove(typeName, { localeGroupId }, workspaceId, query.locale);
108
+ removeByGroup(typeName, localeGroupId, query, workspaceId, token) {
109
+ return this.applyRemove(typeName, { localeGroupId }, workspaceId, query.locale, token);
108
110
  }
109
111
  // ---- addressed by entry id ---------------------------------------------
110
112
  /** `PATCH /api/v1/content/:typeName/:id` — replace an entry's values. */
111
- update(typeName, id, body, workspaceId) {
113
+ update(typeName, id, body, workspaceId, token) {
112
114
  // No locale: an entry id already names exactly one row, in whatever
113
115
  // locale it happens to be.
114
- return this.applyUpdate(typeName, { id }, body, workspaceId, undefined);
116
+ return this.applyUpdate(typeName, { id }, body, workspaceId, undefined, token);
115
117
  }
116
118
  /** `POST /api/v1/content/:typeName/:id/publish` — take an entry live. */
117
- publish(typeName, id, workspaceId) {
118
- return this.applyPublish(typeName, { id }, workspaceId, undefined, true);
119
+ publish(typeName, id, workspaceId, token) {
120
+ return this.applyPublish(typeName, { id }, workspaceId, undefined, true, token);
119
121
  }
120
122
  /** `POST /api/v1/content/:typeName/:id/unpublish` — take it off the air. */
121
- unpublish(typeName, id, workspaceId) {
122
- return this.applyPublish(typeName, { id }, workspaceId, undefined, false);
123
+ unpublish(typeName, id, workspaceId, token) {
124
+ return this.applyPublish(typeName, { id }, workspaceId, undefined, false, token);
123
125
  }
124
126
  /** `DELETE /api/v1/content/:typeName/:id` — remove an entry. */
125
- remove(typeName, id, workspaceId) {
126
- return this.applyRemove(typeName, { id }, workspaceId, undefined);
127
+ remove(typeName, id, workspaceId, token) {
128
+ return this.applyRemove(typeName, { id }, workspaceId, undefined, token);
127
129
  }
128
130
  // ---- the shared handlers, one per write --------------------------------
129
131
  //
130
132
  // Each is called by both addressing forms, so the pair stays a routing
131
133
  // detail and never a behavioural fork — the same arrangement as the reads.
132
134
  /** @see update */
133
- async applyUpdate(typeName, locator, body, workspaceId, locale) {
135
+ async applyUpdate(typeName, locator, body, workspaceId, locale, token) {
134
136
  const { type, granted } = await (0, resolve_granted_type_1.resolveGrantedType)(this.registry, this.grants, typeName, workspaceId);
135
- return this.writes.update(type, locator, body, workspaceId, granted, locale);
137
+ return this.writes.update(type, locator, body, workspaceId, granted, locale, (0, token_actor_1.toTokenActor)(token));
136
138
  }
137
139
  /** @see publish */
138
- async applyPublish(typeName, locator, workspaceId, locale, live) {
140
+ async applyPublish(typeName, locator, workspaceId, locale, live, token) {
139
141
  const { type, granted } = await (0, resolve_granted_type_1.resolveGrantedType)(this.registry, this.grants, typeName, workspaceId);
142
+ const actor = (0, token_actor_1.toTokenActor)(token);
140
143
  return live
141
- ? this.writes.publish(type, locator, workspaceId, granted, locale)
142
- : this.writes.unpublish(type, locator, workspaceId, granted, locale);
144
+ ? this.writes.publish(type, locator, workspaceId, granted, locale, actor)
145
+ : this.writes.unpublish(type, locator, workspaceId, granted, locale, actor);
143
146
  }
144
147
  /** @see remove */
145
- async applyRemove(typeName, locator, workspaceId, locale) {
148
+ async applyRemove(typeName, locator, workspaceId, locale, token) {
146
149
  const { type } = await (0, resolve_granted_type_1.resolveGrantedType)(this.registry, this.grants, typeName, workspaceId);
147
- await this.writes.remove(type, locator, workspaceId, locale);
150
+ await this.writes.remove(type, locator, workspaceId, locale, (0, token_actor_1.toTokenActor)(token));
148
151
  }
149
152
  };
150
153
  exports.PublicEntryWritesController = PublicEntryWritesController;
@@ -158,8 +161,9 @@ tslib_1.__decorate([
158
161
  tslib_1.__param(0, (0, common_1.Param)('typeName')),
159
162
  tslib_1.__param(1, (0, common_1.Body)()),
160
163
  tslib_1.__param(2, (0, workspaces_server_1.CurrentWorkspace)()),
164
+ tslib_1.__param(3, (0, current_api_token_decorator_1.CurrentApiToken)()),
161
165
  tslib_1.__metadata("design:type", Function),
162
- tslib_1.__metadata("design:paramtypes", [String, public_save_entry_dto_1.PublicSaveEntryDto, String]),
166
+ tslib_1.__metadata("design:paramtypes", [String, public_save_entry_dto_1.PublicSaveEntryDto, String, Object]),
163
167
  tslib_1.__metadata("design:returntype", Promise)
164
168
  ], PublicEntryWritesController.prototype, "create", null);
165
169
  tslib_1.__decorate([
@@ -173,8 +177,9 @@ tslib_1.__decorate([
173
177
  tslib_1.__param(0, (0, common_1.Param)('typeName')),
174
178
  tslib_1.__param(1, (0, common_1.Body)()),
175
179
  tslib_1.__param(2, (0, workspaces_server_1.CurrentWorkspace)()),
180
+ tslib_1.__param(3, (0, current_api_token_decorator_1.CurrentApiToken)()),
176
181
  tslib_1.__metadata("design:type", Function),
177
- tslib_1.__metadata("design:paramtypes", [String, public_bulk_dto_1.PublicBulkSaveDto, String]),
182
+ tslib_1.__metadata("design:paramtypes", [String, public_bulk_dto_1.PublicBulkSaveDto, String, Object]),
178
183
  tslib_1.__metadata("design:returntype", Promise)
179
184
  ], PublicEntryWritesController.prototype, "bulkSave", null);
180
185
  tslib_1.__decorate([
@@ -188,8 +193,9 @@ tslib_1.__decorate([
188
193
  tslib_1.__param(0, (0, common_1.Param)('typeName')),
189
194
  tslib_1.__param(1, (0, common_1.Body)()),
190
195
  tslib_1.__param(2, (0, workspaces_server_1.CurrentWorkspace)()),
196
+ tslib_1.__param(3, (0, current_api_token_decorator_1.CurrentApiToken)()),
191
197
  tslib_1.__metadata("design:type", Function),
192
- tslib_1.__metadata("design:paramtypes", [String, public_bulk_dto_1.PublicBulkIdsDto, String]),
198
+ tslib_1.__metadata("design:paramtypes", [String, public_bulk_dto_1.PublicBulkIdsDto, String, Object]),
193
199
  tslib_1.__metadata("design:returntype", Promise)
194
200
  ], PublicEntryWritesController.prototype, "bulkPublish", null);
195
201
  tslib_1.__decorate([
@@ -203,8 +209,9 @@ tslib_1.__decorate([
203
209
  tslib_1.__param(0, (0, common_1.Param)('typeName')),
204
210
  tslib_1.__param(1, (0, common_1.Body)()),
205
211
  tslib_1.__param(2, (0, workspaces_server_1.CurrentWorkspace)()),
212
+ tslib_1.__param(3, (0, current_api_token_decorator_1.CurrentApiToken)()),
206
213
  tslib_1.__metadata("design:type", Function),
207
- tslib_1.__metadata("design:paramtypes", [String, public_bulk_dto_1.PublicBulkIdsDto, String]),
214
+ tslib_1.__metadata("design:paramtypes", [String, public_bulk_dto_1.PublicBulkIdsDto, String, Object]),
208
215
  tslib_1.__metadata("design:returntype", Promise)
209
216
  ], PublicEntryWritesController.prototype, "bulkUnpublish", null);
210
217
  tslib_1.__decorate([
@@ -218,8 +225,9 @@ tslib_1.__decorate([
218
225
  tslib_1.__param(0, (0, common_1.Param)('typeName')),
219
226
  tslib_1.__param(1, (0, common_1.Body)()),
220
227
  tslib_1.__param(2, (0, workspaces_server_1.CurrentWorkspace)()),
228
+ tslib_1.__param(3, (0, current_api_token_decorator_1.CurrentApiToken)()),
221
229
  tslib_1.__metadata("design:type", Function),
222
- tslib_1.__metadata("design:paramtypes", [String, public_bulk_dto_1.PublicBulkIdsDto, String]),
230
+ tslib_1.__metadata("design:paramtypes", [String, public_bulk_dto_1.PublicBulkIdsDto, String, Object]),
223
231
  tslib_1.__metadata("design:returntype", Promise)
224
232
  ], PublicEntryWritesController.prototype, "bulkRemove", null);
225
233
  tslib_1.__decorate([
@@ -234,9 +242,10 @@ tslib_1.__decorate([
234
242
  tslib_1.__param(2, (0, common_1.Body)()),
235
243
  tslib_1.__param(3, (0, common_1.Query)()),
236
244
  tslib_1.__param(4, (0, workspaces_server_1.CurrentWorkspace)()),
245
+ tslib_1.__param(5, (0, current_api_token_decorator_1.CurrentApiToken)()),
237
246
  tslib_1.__metadata("design:type", Function),
238
247
  tslib_1.__metadata("design:paramtypes", [String, String, public_save_entry_dto_1.PublicSaveEntryDto,
239
- public_list_entries_query_dto_1.PublicEntryQueryDto, String]),
248
+ public_list_entries_query_dto_1.PublicEntryQueryDto, String, Object]),
240
249
  tslib_1.__metadata("design:returntype", Promise)
241
250
  ], PublicEntryWritesController.prototype, "updateByGroup", null);
242
251
  tslib_1.__decorate([
@@ -247,8 +256,9 @@ tslib_1.__decorate([
247
256
  tslib_1.__param(1, (0, common_1.Param)('localeGroupId', common_1.ParseUUIDPipe)),
248
257
  tslib_1.__param(2, (0, common_1.Query)()),
249
258
  tslib_1.__param(3, (0, workspaces_server_1.CurrentWorkspace)()),
259
+ tslib_1.__param(4, (0, current_api_token_decorator_1.CurrentApiToken)()),
250
260
  tslib_1.__metadata("design:type", Function),
251
- tslib_1.__metadata("design:paramtypes", [String, String, public_list_entries_query_dto_1.PublicEntryQueryDto, String]),
261
+ tslib_1.__metadata("design:paramtypes", [String, String, public_list_entries_query_dto_1.PublicEntryQueryDto, String, Object]),
252
262
  tslib_1.__metadata("design:returntype", Promise)
253
263
  ], PublicEntryWritesController.prototype, "publishByGroup", null);
254
264
  tslib_1.__decorate([
@@ -259,8 +269,9 @@ tslib_1.__decorate([
259
269
  tslib_1.__param(1, (0, common_1.Param)('localeGroupId', common_1.ParseUUIDPipe)),
260
270
  tslib_1.__param(2, (0, common_1.Query)()),
261
271
  tslib_1.__param(3, (0, workspaces_server_1.CurrentWorkspace)()),
272
+ tslib_1.__param(4, (0, current_api_token_decorator_1.CurrentApiToken)()),
262
273
  tslib_1.__metadata("design:type", Function),
263
- tslib_1.__metadata("design:paramtypes", [String, String, public_list_entries_query_dto_1.PublicEntryQueryDto, String]),
274
+ tslib_1.__metadata("design:paramtypes", [String, String, public_list_entries_query_dto_1.PublicEntryQueryDto, String, Object]),
264
275
  tslib_1.__metadata("design:returntype", Promise)
265
276
  ], PublicEntryWritesController.prototype, "unpublishByGroup", null);
266
277
  tslib_1.__decorate([
@@ -275,8 +286,9 @@ tslib_1.__decorate([
275
286
  tslib_1.__param(1, (0, common_1.Param)('localeGroupId', common_1.ParseUUIDPipe)),
276
287
  tslib_1.__param(2, (0, common_1.Query)()),
277
288
  tslib_1.__param(3, (0, workspaces_server_1.CurrentWorkspace)()),
289
+ tslib_1.__param(4, (0, current_api_token_decorator_1.CurrentApiToken)()),
278
290
  tslib_1.__metadata("design:type", Function),
279
- tslib_1.__metadata("design:paramtypes", [String, String, public_list_entries_query_dto_1.PublicEntryQueryDto, String]),
291
+ tslib_1.__metadata("design:paramtypes", [String, String, public_list_entries_query_dto_1.PublicEntryQueryDto, String, Object]),
280
292
  tslib_1.__metadata("design:returntype", Promise)
281
293
  ], PublicEntryWritesController.prototype, "removeByGroup", null);
282
294
  tslib_1.__decorate([
@@ -290,8 +302,9 @@ tslib_1.__decorate([
290
302
  tslib_1.__param(1, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
291
303
  tslib_1.__param(2, (0, common_1.Body)()),
292
304
  tslib_1.__param(3, (0, workspaces_server_1.CurrentWorkspace)()),
305
+ tslib_1.__param(4, (0, current_api_token_decorator_1.CurrentApiToken)()),
293
306
  tslib_1.__metadata("design:type", Function),
294
- tslib_1.__metadata("design:paramtypes", [String, String, public_save_entry_dto_1.PublicSaveEntryDto, String]),
307
+ tslib_1.__metadata("design:paramtypes", [String, String, public_save_entry_dto_1.PublicSaveEntryDto, String, Object]),
295
308
  tslib_1.__metadata("design:returntype", Promise)
296
309
  ], PublicEntryWritesController.prototype, "update", null);
297
310
  tslib_1.__decorate([
@@ -304,8 +317,9 @@ tslib_1.__decorate([
304
317
  tslib_1.__param(0, (0, common_1.Param)('typeName')),
305
318
  tslib_1.__param(1, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
306
319
  tslib_1.__param(2, (0, workspaces_server_1.CurrentWorkspace)()),
320
+ tslib_1.__param(3, (0, current_api_token_decorator_1.CurrentApiToken)()),
307
321
  tslib_1.__metadata("design:type", Function),
308
- tslib_1.__metadata("design:paramtypes", [String, String, String]),
322
+ tslib_1.__metadata("design:paramtypes", [String, String, String, Object]),
309
323
  tslib_1.__metadata("design:returntype", Promise)
310
324
  ], PublicEntryWritesController.prototype, "publish", null);
311
325
  tslib_1.__decorate([
@@ -318,8 +332,9 @@ tslib_1.__decorate([
318
332
  tslib_1.__param(0, (0, common_1.Param)('typeName')),
319
333
  tslib_1.__param(1, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
320
334
  tslib_1.__param(2, (0, workspaces_server_1.CurrentWorkspace)()),
335
+ tslib_1.__param(3, (0, current_api_token_decorator_1.CurrentApiToken)()),
321
336
  tslib_1.__metadata("design:type", Function),
322
- tslib_1.__metadata("design:paramtypes", [String, String, String]),
337
+ tslib_1.__metadata("design:paramtypes", [String, String, String, Object]),
323
338
  tslib_1.__metadata("design:returntype", Promise)
324
339
  ], PublicEntryWritesController.prototype, "unpublish", null);
325
340
  tslib_1.__decorate([
@@ -333,8 +348,9 @@ tslib_1.__decorate([
333
348
  tslib_1.__param(0, (0, common_1.Param)('typeName')),
334
349
  tslib_1.__param(1, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
335
350
  tslib_1.__param(2, (0, workspaces_server_1.CurrentWorkspace)()),
351
+ tslib_1.__param(3, (0, current_api_token_decorator_1.CurrentApiToken)()),
336
352
  tslib_1.__metadata("design:type", Function),
337
- tslib_1.__metadata("design:paramtypes", [String, String, String]),
353
+ tslib_1.__metadata("design:paramtypes", [String, String, String, Object]),
338
354
  tslib_1.__metadata("design:returntype", Promise)
339
355
  ], PublicEntryWritesController.prototype, "remove", null);
340
356
  exports.PublicEntryWritesController = PublicEntryWritesController = tslib_1.__decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"api-token-workspace.guard.d.ts","sourceRoot":"","sources":["../../../../../src/lib/public-api/http/guards/api-token-workspace.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,WAAW,EACX,gBAAgB,EAInB,MAAM,gBAAgB,CAAC;AAOxB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,sBAAuB,YAAW,WAAW;IACtD,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO;CAmClD"}
1
+ {"version":3,"file":"api-token-workspace.guard.d.ts","sourceRoot":"","sources":["../../../../../src/lib/public-api/http/guards/api-token-workspace.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,WAAW,EACX,gBAAgB,EAInB,MAAM,gBAAgB,CAAC;AAOxB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,sBAAuB,YAAW,WAAW;IACtD,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO;CA6ClD"}
@@ -38,6 +38,14 @@ let ApiTokenWorkspaceGuard = class ApiTokenWorkspaceGuard {
38
38
  request.workspaceId = token.workspaceIds[0];
39
39
  return true;
40
40
  }
41
+ // A token can end up covering *nothing*: deleting a workspace
42
+ // narrows every token's bucket and deliberately stops short of
43
+ // revoking the credential, which is not the purger's call to make.
44
+ // Asking that caller to name one of zero workspaces is advice they
45
+ // cannot follow, so say what is actually true instead.
46
+ if (token.workspaceIds.length === 0) {
47
+ throw new common_1.ForbiddenException('This token has no workspaces left — every workspace it covered has been deleted. Issue a new token.');
48
+ }
41
49
  throw new common_1.BadRequestException(`This token covers ${token.workspaceIds.length} workspaces — name the one you want with the X-Workspace-Id header.`);
42
50
  }
43
51
  if (!workspaces_server_1.WORKSPACE_ID_PATTERN.test(requested)) {
@@ -1,5 +1,6 @@
1
1
  import { type Database } from '@orthacms/database';
2
2
  import { type ContentEntryExtension } from '../../extension/entry-extension';
3
+ import { ContentReadScopeRegistry } from '../../extension/read-scope';
3
4
  import { type AnyContentType } from '../../types/content-type';
4
5
  import { RelationLinkService } from '../../entries/infrastructure/persistence/relation-link.service';
5
6
  import type { PublicMediaFieldView, PublicRelationFieldView } from '../types/public-expansion';
@@ -49,7 +50,8 @@ export declare class PublicEntriesQuery {
49
50
  private readonly expansion;
50
51
  private readonly relationLinks;
51
52
  private readonly extension?;
52
- constructor(db: Database, expansion: PublicExpansionQuery, relationLinks: RelationLinkService, extension?: ContentEntryExtension | undefined);
53
+ private readonly readScopes?;
54
+ constructor(db: Database, expansion: PublicExpansionQuery, relationLinks: RelationLinkService, extension?: ContentEntryExtension | undefined, readScopes?: ContentReadScopeRegistry | undefined);
53
55
  /**
54
56
  * One page of a type's publicly readable entries. Count and page share the
55
57
  * WHERE and run concurrently, so the request pays the slower of the two.
@@ -225,6 +227,17 @@ export declare class PublicEntriesQuery {
225
227
  * visibility rule in exactly one respect and inherits the rest verbatim.
226
228
  */
227
229
  private liveWhere;
230
+ /**
231
+ * The fragments contributed by the bound `CONTENT_READ_SCOPE` providers.
232
+ *
233
+ * Applied here, in {@link liveWhere}, rather than in `readableWhere`: this
234
+ * is the clause every public read shares — the list, the single-entry read
235
+ * and the translation lookup that deliberately steps around the locale
236
+ * scope all pass through it — so a scope cannot be missed by a read that
237
+ * chose the narrower helper. AND-ed like everything else around them, which
238
+ * is what makes a scope structurally incapable of widening a read.
239
+ */
240
+ private readScopeWhere;
228
241
  /**
229
242
  * The publish-state clause. `published` — the default and everything a
230
243
  * read-only token can ask for — is the API's headline rule; the other two
@@ -1 +1 @@
1
- {"version":3,"file":"public-entries.query.d.ts","sourceRoot":"","sources":["../../../../src/lib/public-api/infrastructure/public-entries.query.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAEH,KAAK,qBAAqB,EAC7B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,gEAAgE,CAAC;AACrG,OAAO,KAAK,EACR,oBAAoB,EACpB,uBAAuB,EAC1B,MAAM,2BAA2B,CAAC;AAKnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAGH,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EACjC,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAc9E;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAClB;IAAE,QAAQ,CAAC,EAAE,EAAE,M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pB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAQnC;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,OAAO,CAAC,UAAU;IA6BlB,mEAAmE;IACnE,OAAO,CAAC,WAAW;IAMnB;;;;OAIG;IACG,aAAa,CACf,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,EACjC,MAAM,CAAC,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,eAAe,GAC7B,OAAO,CAAC,uBAAuB,CAAC;IAyCnC,yEAAyE;IACnE,OAAO,CACT,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,SAA0B,EAC/B,UAAU,CAAC,EAAE,eAAe,GAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAyBhD;;;;;OAKG;YACW,WAAW;IAoBzB;;;;;;;;;;;;;;;;;;;;OAoBG;YACW,eAAe;IAoB7B;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAcrB;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IAajB;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW;IAcnB;;;;;;;OAOG;IACH,OAAO,CAAC,OAAO;CAmBlB"}
1
+ {"version":3,"file":"public-entries.query.d.ts","sourceRoot":"","sources":["../../../../src/lib/public-api/infrastructure/public-entries.query.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAA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GAC7B,OAAO,CAAC,uBAAuB,CAAC;IAyCnC,yEAAyE;IACnE,OAAO,CACT,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,SAA0B,EAC/B,UAAU,CAAC,EAAE,eAAe,GAC7B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAyBhD;;;;;OAKG;YACW,WAAW;IAoBzB;;;;;;;;;;;;;;;;;;;;OAoBG;YACW,eAAe;IAoB7B;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAcrB;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IAcjB;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAOtB;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW;IAcnB;;;;;;;OAOG;IACH,OAAO,CAAC,OAAO;CAmBlB"}
@@ -7,6 +7,7 @@ const drizzle_orm_1 = require("drizzle-orm");
7
7
  const database_1 = require("@orthacms/database");
8
8
  const utils_server_1 = require("@orthacms/utils-server");
9
9
  const entry_extension_1 = require("../../extension/entry-extension");
10
+ const read_scope_1 = require("../../extension/read-scope");
10
11
  const content_type_1 = require("../../types/content-type");
11
12
  const fields_1 = require("../../types/fields");
12
13
  const relation_link_service_1 = require("../../entries/infrastructure/persistence/relation-link.service");
@@ -48,11 +49,13 @@ let PublicEntriesQuery = class PublicEntriesQuery {
48
49
  expansion;
49
50
  relationLinks;
50
51
  extension;
51
- constructor(db, expansion, relationLinks, extension) {
52
+ readScopes;
53
+ constructor(db, expansion, relationLinks, extension, readScopes) {
52
54
  this.db = db;
53
55
  this.expansion = expansion;
54
56
  this.relationLinks = relationLinks;
55
57
  this.extension = extension;
58
+ this.readScopes = readScopes;
56
59
  }
57
60
  /**
58
61
  * One page of a type's publicly readable entries. Count and page share the
@@ -500,7 +503,20 @@ let PublicEntriesQuery = class PublicEntriesQuery {
500
503
  */
501
504
  liveWhere(type, workspaceId, visibility = 'published') {
502
505
  const table = type.table;
503
- return (0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(table['workspaceId'], workspaceId), this.statusWhere(type, visibility), type.paranoid ? (0, drizzle_orm_1.isNull)(table['deletedAt']) : undefined);
506
+ return (0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(table['workspaceId'], workspaceId), this.statusWhere(type, visibility), type.paranoid ? (0, drizzle_orm_1.isNull)(table['deletedAt']) : undefined, ...this.readScopeWhere(type, workspaceId));
507
+ }
508
+ /**
509
+ * The fragments contributed by the bound `CONTENT_READ_SCOPE` providers.
510
+ *
511
+ * Applied here, in {@link liveWhere}, rather than in `readableWhere`: this
512
+ * is the clause every public read shares — the list, the single-entry read
513
+ * and the translation lookup that deliberately steps around the locale
514
+ * scope all pass through it — so a scope cannot be missed by a read that
515
+ * chose the narrower helper. AND-ed like everything else around them, which
516
+ * is what makes a scope structurally incapable of widening a read.
517
+ */
518
+ readScopeWhere(type, workspaceId) {
519
+ return this.readScopes?.fragments({ type, workspaceId }) ?? [];
504
520
  }
505
521
  /**
506
522
  * The publish-state clause. `published` — the default and everything a
@@ -552,6 +568,7 @@ exports.PublicEntriesQuery = PublicEntriesQuery = tslib_1.__decorate([
552
568
  tslib_1.__param(0, (0, database_1.InjectDatabase)()),
553
569
  tslib_1.__param(3, (0, common_1.Optional)()),
554
570
  tslib_1.__param(3, (0, common_1.Inject)(entry_extension_1.CONTENT_ENTRY_EXTENSION)),
571
+ tslib_1.__param(4, (0, common_1.Optional)()),
555
572
  tslib_1.__metadata("design:paramtypes", [Object, public_expansion_query_1.PublicExpansionQuery,
556
- relation_link_service_1.RelationLinkService, Object])
573
+ relation_link_service_1.RelationLinkService, Object, read_scope_1.ContentReadScopeRegistry])
557
574
  ], PublicEntriesQuery);
@@ -1,3 +1,4 @@
1
+ import type { EventActor } from '@orthacms/database';
1
2
  import type { AnyContentType } from '../../types/content-type';
2
3
  import { EntryWriterService } from '../../entries/infrastructure/persistence/entry-writer.service';
3
4
  import { PublishEntryUseCase } from '../../entries/application/use-cases/publish-entry.use-case';
@@ -56,7 +57,7 @@ export declare class PublicEntryWritesService {
56
57
  * of starting one, which is how a new locale of an existing record is
57
58
  * written.
58
59
  */
59
- create(type: AnyContentType, body: PublicSaveEntryDto, workspaceId: string, grantedTypes: ReadonlySet<string>): Promise<PublicEntry>;
60
+ create(type: AnyContentType, body: PublicSaveEntryDto, workspaceId: string, grantedTypes: ReadonlySet<string>, actor?: EventActor): Promise<PublicEntry>;
60
61
  /**
61
62
  * Update an entry's values and apply its relation deltas. On a publishable
62
63
  * type this moves a published row back to `draft` while its published
@@ -82,7 +83,7 @@ export declare class PublicEntryWritesService {
82
83
  * group write at the default-locale row. Which is exactly what it did, until
83
84
  * a live check caught a German update rewriting the English article.
84
85
  */
85
- update(type: AnyContentType, locator: EntryLocator, body: PublicSaveEntryDto, workspaceId: string, grantedTypes: ReadonlySet<string>, locale?: string): Promise<PublicEntry>;
86
+ update(type: AnyContentType, locator: EntryLocator, body: PublicSaveEntryDto, workspaceId: string, grantedTypes: ReadonlySet<string>, locale?: string, actor?: EventActor): Promise<PublicEntry>;
86
87
  /**
87
88
  * Save many entries of one type in a single request — the batch form of
88
89
  * {@link create} and {@link update}, and the reason it is one method rather
@@ -112,7 +113,7 @@ export declare class PublicEntryWritesService {
112
113
  * would spend a fan-out contending with itself; sequential also makes the
113
114
  * per-item results deterministic, which a caller diffing two runs relies on.
114
115
  */
115
- bulkSave(type: AnyContentType, items: readonly PublicBulkSaveItemDto[], workspaceId: string, grantedTypes: ReadonlySet<string>): Promise<PublicBulkSaveResult>;
116
+ bulkSave(type: AnyContentType, items: readonly PublicBulkSaveItemDto[], workspaceId: string, grantedTypes: ReadonlySet<string>, actor?: EventActor): Promise<PublicBulkSaveResult>;
116
117
  /**
117
118
  * The values bag an update submits: the stored values with the caller's
118
119
  * merged over them (see {@link update}), minus any single relation the
@@ -141,7 +142,7 @@ export declare class PublicEntryWritesService {
141
142
  * workspace-scoped, so an id from another workspace is reported as
142
143
  * `not-found` — the same answer an id that never existed gets.
143
144
  */
144
- bulkPublish(type: AnyContentType, ids: string[], workspaceId: string): Promise<BulkPublishResult>;
145
+ bulkPublish(type: AnyContentType, ids: string[], workspaceId: string, actor?: EventActor): Promise<BulkPublishResult>;
145
146
  /**
146
147
  * Take many entries off the air, reverting each to a draft.
147
148
  *
@@ -151,7 +152,7 @@ export declare class PublicEntryWritesService {
151
152
  * actually transitioned, and one `entry.unpublished` event is emitted per
152
153
  * transition — never per submitted id.
153
154
  */
154
- bulkUnpublish(type: AnyContentType, ids: string[], workspaceId: string): Promise<BulkActionResult>;
155
+ bulkUnpublish(type: AnyContentType, ids: string[], workspaceId: string, actor?: EventActor): Promise<BulkActionResult>;
155
156
  /**
156
157
  * Remove many entries — soft-deleting on a `paranoid` type (recoverable
157
158
  * from the admin's trash) and hard-deleting otherwise, exactly as
@@ -160,11 +161,11 @@ export declare class PublicEntryWritesService {
160
161
  * Rows, not records: on a localized type this deletes the listed locales
161
162
  * and leaves their siblings live.
162
163
  */
163
- bulkRemove(type: AnyContentType, ids: string[], workspaceId: string): Promise<BulkActionResult>;
164
+ bulkRemove(type: AnyContentType, ids: string[], workspaceId: string, actor?: EventActor): Promise<BulkActionResult>;
164
165
  /** Take an entry live. 422 when the stored draft no longer validates. */
165
- publish(type: AnyContentType, locator: EntryLocator, workspaceId: string, grantedTypes: ReadonlySet<string>, locale?: string): Promise<PublicEntry>;
166
+ publish(type: AnyContentType, locator: EntryLocator, workspaceId: string, grantedTypes: ReadonlySet<string>, locale?: string, actor?: EventActor): Promise<PublicEntry>;
166
167
  /** Take an entry back off the air, reverting it to a draft. */
167
- unpublish(type: AnyContentType, locator: EntryLocator, workspaceId: string, grantedTypes: ReadonlySet<string>, locale?: string): Promise<PublicEntry>;
168
+ unpublish(type: AnyContentType, locator: EntryLocator, workspaceId: string, grantedTypes: ReadonlySet<string>, locale?: string, actor?: EventActor): Promise<PublicEntry>;
168
169
  /**
169
170
  * Remove an entry — soft delete on a `paranoid` type (recoverable from the
170
171
  * admin's trash), a hard delete otherwise. Either way it leaves the public
@@ -174,7 +175,7 @@ export declare class PublicEntryWritesService {
174
175
  * German article leaves the English one live. Deleting a whole group means
175
176
  * deleting each locale.
176
177
  */
177
- remove(type: AnyContentType, locator: EntryLocator, workspaceId: string, locale?: string): Promise<void>;
178
+ remove(type: AnyContentType, locator: EntryLocator, workspaceId: string, locale?: string, actor?: EventActor): Promise<void>;
178
179
  /**
179
180
  * Re-read a just-written row through the public projection.
180
181
  *
@@ -1 +1 @@
1
- {"version":3,"file":"public-entry-writes.service.d.ts","sourceRoot":"","sources":["../../../../src/lib/public-api/infrastructure/public-entry-writes.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+DAA+D,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,MAAM,4DAA4D,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,8DAA8D,CAAC;AACrG,OAAO,EAAE,yBAAyB,EAAE,MAAM,mEAAmE,CAAC;AAC9G,OAAO,EAAE,2BAA2B,EAAE,MAAM,qEAAqE,CAAC;AAClH,OAAO,KAAK,EACR,gBAAgB,EAChB,iBAAiB,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAKH,KAAK,oBAAoB,EAC5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAC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pB,OAAO,CAAC,iBAAiB,CAAC;IAI7B;;;;;;;;OAQG;IACH,aAAa,CACT,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,MAAM,EAAE,EACb,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,gBAAgB,CAAC;IAI5B;;;;;;;OAOG;IACH,UAAU,CACN,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,MAAM,EAAE,EACb,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,gBAAgB,CAAC;IAI5B,yEAAyE;IACnE,OAAO,CACT,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,EACjC,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC;IAYvB,+DAA+D;IACzD,SAAS,CACX,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,EACjC,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC;IAYvB;;;;;;;;OAQG;IACG,MAAM,CACR,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC;IAUhB;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ;CAenB"}
1
+ {"version":3,"file":"public-entry-writes.service.d.ts","sourceRoot":"","sources":["../../../../src/lib/public-api/infrastructure/public-entry-writes.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,+DAA+D,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,M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C,MAAM,CAAC,EACjC,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,WAAW,CAAC;IAYvB,+DAA+D;IACzD,SAAS,CACX,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,EACjC,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,WAAW,CAAC;IAYvB;;;;;;;;OAQG;IACG,MAAM,CACR,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,IAAI,CAAC;IAehB;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ;CAenB"}
@@ -65,14 +65,13 @@ let PublicEntryWritesService = class PublicEntryWritesService {
65
65
  * of starting one, which is how a new locale of an existing record is
66
66
  * written.
67
67
  */
68
- async create(type, body, workspaceId, grantedTypes) {
68
+ async create(type, body, workspaceId, grantedTypes, actor) {
69
69
  const record = await this.writer.create(type, body.values, workspaceId, body.relations, body.locale, body.localeGroupId,
70
- // Revisions record a *user* id, and a token is not a user. Writing
71
- // the token id into that column would make the history resolve it to
72
- // a nonexistent person; null is the honest answer for "not a user".
73
- // Attributing a token's writes is a real gap it wants its own
74
- // column, not a misused one.
75
- null);
70
+ // The **token** is the actor. Its id never reaches the revision's
71
+ // `created_by` that column really is a `users` FK, and the writer's
72
+ // `revisionActorId` is what keeps the two apart but it does reach
73
+ // the audit row, which carries an `actor_type` saying what it names.
74
+ actor ?? null);
76
75
  return this.readBack(type, record.id, workspaceId, grantedTypes, body);
77
76
  }
78
77
  /**
@@ -100,7 +99,7 @@ let PublicEntryWritesService = class PublicEntryWritesService {
100
99
  * group write at the default-locale row. Which is exactly what it did, until
101
100
  * a live check caught a German update rewriting the English article.
102
101
  */
103
- async update(type, locator, body, workspaceId, grantedTypes, locale) {
102
+ async update(type, locator, body, workspaceId, grantedTypes, locale, actor) {
104
103
  const row = await this.entries.resolveWritableRow(type, locator, workspaceId, locale);
105
104
  const id = row['id'];
106
105
  await this.writer.update(type, id,
@@ -109,7 +108,7 @@ let PublicEntryWritesService = class PublicEntryWritesService {
109
108
  // column and are absent from it, which is correct: those move only
110
109
  // through `relations` deltas, and a delta left unsent changes
111
110
  // nothing by construction.
112
- this.mergedValues(type, row, body), workspaceId, body.relations, null);
111
+ this.mergedValues(type, row, body), workspaceId, body.relations, actor ?? null);
113
112
  return this.readBack(type, id, workspaceId, grantedTypes, { locale });
114
113
  }
115
114
  /**
@@ -141,7 +140,7 @@ let PublicEntryWritesService = class PublicEntryWritesService {
141
140
  * would spend a fan-out contending with itself; sequential also makes the
142
141
  * per-item results deterministic, which a caller diffing two runs relies on.
143
142
  */
144
- async bulkSave(type, items, workspaceId, grantedTypes) {
143
+ async bulkSave(type, items, workspaceId, grantedTypes, actor) {
145
144
  const results = [];
146
145
  for (const [index, item] of items.entries()) {
147
146
  // Resolved inside the loop, and inside the try: a malformed
@@ -154,8 +153,8 @@ let PublicEntryWritesService = class PublicEntryWritesService {
154
153
  const resolved = (0, bulk_save_op_1.resolveBulkSaveOp)(item);
155
154
  op = resolved.op;
156
155
  const entry = resolved.op === public_bulk_1.BULK_SAVE_OP.Create
157
- ? await this.create(type, item, workspaceId, grantedTypes)
158
- : await this.update(type, resolved.locator, item, workspaceId, grantedTypes, resolved.locale);
156
+ ? await this.create(type, item, workspaceId, grantedTypes, actor)
157
+ : await this.update(type, resolved.locator, item, workspaceId, grantedTypes, resolved.locale, actor);
159
158
  results.push({ index, op: resolved.op, ok: true, entry });
160
159
  }
161
160
  catch (error) {
@@ -215,8 +214,8 @@ let PublicEntryWritesService = class PublicEntryWritesService {
215
214
  * workspace-scoped, so an id from another workspace is reported as
216
215
  * `not-found` — the same answer an id that never existed gets.
217
216
  */
218
- bulkPublish(type, ids, workspaceId) {
219
- return this.bulkPublishEntries.execute(type, ids, workspaceId);
217
+ bulkPublish(type, ids, workspaceId, actor) {
218
+ return this.bulkPublishEntries.execute(type, ids, workspaceId, actor);
220
219
  }
221
220
  /**
222
221
  * Take many entries off the air, reverting each to a draft.
@@ -227,8 +226,8 @@ let PublicEntryWritesService = class PublicEntryWritesService {
227
226
  * actually transitioned, and one `entry.unpublished` event is emitted per
228
227
  * transition — never per submitted id.
229
228
  */
230
- bulkUnpublish(type, ids, workspaceId) {
231
- return this.bulkUnpublishEntries.execute(type, ids, workspaceId);
229
+ bulkUnpublish(type, ids, workspaceId, actor) {
230
+ return this.bulkUnpublishEntries.execute(type, ids, workspaceId, actor);
232
231
  }
233
232
  /**
234
233
  * Remove many entries — soft-deleting on a `paranoid` type (recoverable
@@ -238,21 +237,21 @@ let PublicEntryWritesService = class PublicEntryWritesService {
238
237
  * Rows, not records: on a localized type this deletes the listed locales
239
238
  * and leaves their siblings live.
240
239
  */
241
- bulkRemove(type, ids, workspaceId) {
242
- return this.writer.bulkRemove(type, ids, workspaceId);
240
+ bulkRemove(type, ids, workspaceId, actor) {
241
+ return this.writer.bulkRemove(type, ids, workspaceId, actor);
243
242
  }
244
243
  /** Take an entry live. 422 when the stored draft no longer validates. */
245
- async publish(type, locator, workspaceId, grantedTypes, locale) {
244
+ async publish(type, locator, workspaceId, grantedTypes, locale, actor) {
246
245
  const row = await this.entries.resolveWritableRow(type, locator, workspaceId, locale);
247
246
  const id = row['id'];
248
- await this.publishEntry.execute(type, id, workspaceId);
247
+ await this.publishEntry.execute(type, id, workspaceId, actor);
249
248
  return this.readBack(type, id, workspaceId, grantedTypes, { locale });
250
249
  }
251
250
  /** Take an entry back off the air, reverting it to a draft. */
252
- async unpublish(type, locator, workspaceId, grantedTypes, locale) {
251
+ async unpublish(type, locator, workspaceId, grantedTypes, locale, actor) {
253
252
  const row = await this.entries.resolveWritableRow(type, locator, workspaceId, locale);
254
253
  const id = row['id'];
255
- await this.unpublishEntry.execute(type, id, workspaceId);
254
+ await this.unpublishEntry.execute(type, id, workspaceId, actor);
256
255
  return this.readBack(type, id, workspaceId, grantedTypes, { locale });
257
256
  }
258
257
  /**
@@ -264,9 +263,9 @@ let PublicEntryWritesService = class PublicEntryWritesService {
264
263
  * German article leaves the English one live. Deleting a whole group means
265
264
  * deleting each locale.
266
265
  */
267
- async remove(type, locator, workspaceId, locale) {
266
+ async remove(type, locator, workspaceId, locale, actor) {
268
267
  const row = await this.entries.resolveWritableRow(type, locator, workspaceId, locale);
269
- await this.writer.remove(type, row['id'], workspaceId);
268
+ await this.writer.remove(type, row['id'], workspaceId, actor);
270
269
  }
271
270
  /**
272
271
  * Re-read a just-written row through the public projection.