resource-engine-fastapi 0.1.0__py3-none-any.whl
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.
- resource_engine_fastapi/__init__.py +39 -0
- resource_engine_fastapi/access.py +110 -0
- resource_engine_fastapi/asyncapi.py +47 -0
- resource_engine_fastapi/auth.py +158 -0
- resource_engine_fastapi/authz.py +100 -0
- resource_engine_fastapi/caching.py +111 -0
- resource_engine_fastapi/docs.py +77 -0
- resource_engine_fastapi/documents.py +219 -0
- resource_engine_fastapi/email_events.py +85 -0
- resource_engine_fastapi/errors.py +178 -0
- resource_engine_fastapi/events.py +109 -0
- resource_engine_fastapi/explorer/__init__.py +441 -0
- resource_engine_fastapi/explorer/assets/auth.js +171 -0
- resource_engine_fastapi/explorer/assets/console.js +340 -0
- resource_engine_fastapi/explorer/assets/events.js +189 -0
- resource_engine_fastapi/explorer/assets/explorer.css +156 -0
- resource_engine_fastapi/explorer/assets/explorer.js +275 -0
- resource_engine_fastapi/explorer/assets/jobs.js +143 -0
- resource_engine_fastapi/explorer/assets/messages.js +85 -0
- resource_engine_fastapi/explorer/assets/publish.js +117 -0
- resource_engine_fastapi/explorer/data.py +84 -0
- resource_engine_fastapi/explorer/events.py +182 -0
- resource_engine_fastapi/explorer/jobs.py +167 -0
- resource_engine_fastapi/explorer/labels.py +198 -0
- resource_engine_fastapi/explorer/locale/ca/LC_MESSAGES/explorer.mo +0 -0
- resource_engine_fastapi/explorer/locale/ca/LC_MESSAGES/explorer.po +417 -0
- resource_engine_fastapi/explorer/locale/es/LC_MESSAGES/explorer.mo +0 -0
- resource_engine_fastapi/explorer/locale/es/LC_MESSAGES/explorer.po +417 -0
- resource_engine_fastapi/explorer/messages.py +73 -0
- resource_engine_fastapi/explorer/publish.py +85 -0
- resource_engine_fastapi/exports.py +186 -0
- resource_engine_fastapi/i18n.py +76 -0
- resource_engine_fastapi/py.typed +0 -0
- resource_engine_fastapi/router.py +1031 -0
- resource_engine_fastapi/versioning.py +49 -0
- resource_engine_fastapi-0.1.0.dist-info/METADATA +32 -0
- resource_engine_fastapi-0.1.0.dist-info/RECORD +39 -0
- resource_engine_fastapi-0.1.0.dist-info/WHEEL +4 -0
- resource_engine_fastapi-0.1.0.dist-info/licenses/LICENSE +202 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
# Spanish translations for resource-engine-fastapi.
|
|
2
|
+
# Copyright (C) 2026 ORGANIZATION
|
|
3
|
+
# This file is distributed under the same license as the resource-engine-fastapi project.
|
|
4
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2026.
|
|
5
|
+
#
|
|
6
|
+
#, fuzzy
|
|
7
|
+
msgid ""
|
|
8
|
+
msgstr ""
|
|
9
|
+
"Project-Id-Version: resource-engine-fastapi VERSION\n"
|
|
10
|
+
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
|
11
|
+
"POT-Creation-Date: 2026-11-28 10:28+0100\n"
|
|
12
|
+
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
13
|
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
14
|
+
"Language: es\n"
|
|
15
|
+
"Language-Team: es <LL@li.org>\n"
|
|
16
|
+
"Plural-Forms: nplurals=3; plural=(n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2);\n"
|
|
17
|
+
"MIME-Version: 1.0\n"
|
|
18
|
+
"Content-Type: text/plain; charset=utf-8\n"
|
|
19
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
20
|
+
"Generated-By: Babel 2.19.0\n"
|
|
21
|
+
|
|
22
|
+
msgid "Calls the running API with your token. Reads only, unless you allow changes."
|
|
23
|
+
msgstr "Llama a la API en funcionamiento con tu token. Solo lee, salvo que permitas cambios."
|
|
24
|
+
|
|
25
|
+
msgid "Access token or API key"
|
|
26
|
+
msgstr "Token de acceso o clave de API"
|
|
27
|
+
|
|
28
|
+
msgid "Kept in this browser tab only"
|
|
29
|
+
msgstr "Solo se guarda en esta pestaña"
|
|
30
|
+
|
|
31
|
+
msgid "Allow changes (create, update, delete, transitions, actions)"
|
|
32
|
+
msgstr "Permitir cambios (crear, modificar, eliminar, transiciones, acciones)"
|
|
33
|
+
|
|
34
|
+
msgid "This operation changes data: tick “Allow changes” first."
|
|
35
|
+
msgstr "Esta operación modifica datos: marca primero «Permitir cambios»."
|
|
36
|
+
|
|
37
|
+
msgid "header"
|
|
38
|
+
msgstr "cabecera"
|
|
39
|
+
|
|
40
|
+
msgid "Body (JSON)"
|
|
41
|
+
msgstr "Cuerpo (JSON)"
|
|
42
|
+
|
|
43
|
+
msgid "Send"
|
|
44
|
+
msgstr "Enviar"
|
|
45
|
+
|
|
46
|
+
msgid "Send the change"
|
|
47
|
+
msgstr "Enviar el cambio"
|
|
48
|
+
|
|
49
|
+
msgid "Sending…"
|
|
50
|
+
msgstr "Enviando…"
|
|
51
|
+
|
|
52
|
+
msgid "Fill in"
|
|
53
|
+
msgstr "Rellena"
|
|
54
|
+
|
|
55
|
+
msgid "The body is not valid JSON"
|
|
56
|
+
msgstr "El cuerpo no es JSON válido"
|
|
57
|
+
|
|
58
|
+
msgid "The API could not be reached"
|
|
59
|
+
msgstr "No se ha podido contactar con la API"
|
|
60
|
+
|
|
61
|
+
msgid "Why was it refused?"
|
|
62
|
+
msgstr "¿Por qué se ha denegado?"
|
|
63
|
+
|
|
64
|
+
msgid "Allowed transitions now"
|
|
65
|
+
msgstr "Transiciones permitidas ahora"
|
|
66
|
+
|
|
67
|
+
msgid "none"
|
|
68
|
+
msgstr "ninguna"
|
|
69
|
+
|
|
70
|
+
msgid "Files are uploaded with the multipart form; use another client."
|
|
71
|
+
msgstr "Los archivos se suben con un formulario multipart; usa otro cliente."
|
|
72
|
+
|
|
73
|
+
msgid "What can I do?"
|
|
74
|
+
msgstr "¿Qué puedo hacer?"
|
|
75
|
+
|
|
76
|
+
msgid "Your roles and the actions you may perform, from the running API."
|
|
77
|
+
msgstr "Tus roles y las acciones que puedes hacer, según la API en funcionamiento."
|
|
78
|
+
|
|
79
|
+
msgid "Only policy editors can see the full explanation. What the API says about you:"
|
|
80
|
+
msgstr "Solo quien edita políticas puede ver la explicación completa. Lo que dice la API de ti:"
|
|
81
|
+
|
|
82
|
+
msgid "Your roles"
|
|
83
|
+
msgstr "Tus roles"
|
|
84
|
+
|
|
85
|
+
msgid "not granted"
|
|
86
|
+
msgstr "no concedido"
|
|
87
|
+
|
|
88
|
+
msgid "Download"
|
|
89
|
+
msgstr "Descargar"
|
|
90
|
+
|
|
91
|
+
msgid "Check the export"
|
|
92
|
+
msgstr "Comprobar la exportación"
|
|
93
|
+
|
|
94
|
+
msgid "Explorer"
|
|
95
|
+
msgstr "Explorador"
|
|
96
|
+
|
|
97
|
+
msgid ""
|
|
98
|
+
"Events committed from now on that you may see: those about records you can read. Payloads and "
|
|
99
|
+
"events about no record need the events:read permission."
|
|
100
|
+
msgstr ""
|
|
101
|
+
"Los eventos confirmados a partir de ahora que puedes ver: los de los registros que puedes leer. "
|
|
102
|
+
"Los datos y los eventos sin registro necesitan el permiso events:read."
|
|
103
|
+
|
|
104
|
+
msgid "Connect"
|
|
105
|
+
msgstr "Conectar"
|
|
106
|
+
|
|
107
|
+
msgid "Disconnect"
|
|
108
|
+
msgstr "Desconectar"
|
|
109
|
+
|
|
110
|
+
msgid "Pause"
|
|
111
|
+
msgstr "Pausar"
|
|
112
|
+
|
|
113
|
+
msgid "Resume"
|
|
114
|
+
msgstr "Continuar"
|
|
115
|
+
|
|
116
|
+
msgid "Clear"
|
|
117
|
+
msgstr "Vaciar"
|
|
118
|
+
|
|
119
|
+
msgid "Resource (channel)"
|
|
120
|
+
msgstr "Recurso (canal)"
|
|
121
|
+
|
|
122
|
+
msgid "Event type"
|
|
123
|
+
msgstr "Tipo de evento"
|
|
124
|
+
|
|
125
|
+
msgid "Schema version"
|
|
126
|
+
msgstr "Versión del esquema"
|
|
127
|
+
|
|
128
|
+
msgid "Record id"
|
|
129
|
+
msgstr "Id del registro"
|
|
130
|
+
|
|
131
|
+
msgid "any"
|
|
132
|
+
msgstr "cualquiera"
|
|
133
|
+
|
|
134
|
+
msgid "Connected: waiting for events…"
|
|
135
|
+
msgstr "Conectado: esperando eventos…"
|
|
136
|
+
|
|
137
|
+
msgid "Disconnected"
|
|
138
|
+
msgstr "Desconectado"
|
|
139
|
+
|
|
140
|
+
msgid "Envelope"
|
|
141
|
+
msgstr "Sobre"
|
|
142
|
+
|
|
143
|
+
msgid "Record as you can read it"
|
|
144
|
+
msgstr "El registro tal como lo puedes leer"
|
|
145
|
+
|
|
146
|
+
msgid "Payload"
|
|
147
|
+
msgstr "Datos"
|
|
148
|
+
|
|
149
|
+
msgid "The payload needs the events:read permission."
|
|
150
|
+
msgstr "Los datos necesitan el permiso events:read."
|
|
151
|
+
|
|
152
|
+
msgid "Handled by"
|
|
153
|
+
msgstr "Tratado por"
|
|
154
|
+
|
|
155
|
+
msgid "No consumer has reported handling it yet."
|
|
156
|
+
msgstr "Ningún consumidor ha informado todavía de que lo haya tratado."
|
|
157
|
+
|
|
158
|
+
msgid "Consumer results are not recorded (no activity log)."
|
|
159
|
+
msgstr "Los resultados de los consumidores no se registran (no hay registro de actividad)."
|
|
160
|
+
|
|
161
|
+
msgid ""
|
|
162
|
+
"The jobs the running workers registered. Run now asks a worker to run one at once: single jobs "
|
|
163
|
+
"still wait for their lease, so they run on one worker at a time."
|
|
164
|
+
msgstr ""
|
|
165
|
+
"Las tareas que han registrado los trabajadores en marcha. Ejecutar ahora pide a un trabajador que"
|
|
166
|
+
" ejecute una enseguida: las tareas únicas siguen esperando su bloqueo, de modo que se ejecutan en"
|
|
167
|
+
" un solo trabajador a la vez."
|
|
168
|
+
|
|
169
|
+
msgid "Schedule"
|
|
170
|
+
msgstr "Planificación"
|
|
171
|
+
|
|
172
|
+
msgid "Workers"
|
|
173
|
+
msgstr "Trabajadores"
|
|
174
|
+
|
|
175
|
+
msgid "Worker"
|
|
176
|
+
msgstr "Trabajador"
|
|
177
|
+
|
|
178
|
+
msgid "Last run"
|
|
179
|
+
msgstr "Última ejecución"
|
|
180
|
+
|
|
181
|
+
#, python-brace-format
|
|
182
|
+
msgid "every {every}"
|
|
183
|
+
msgstr "cada {every}"
|
|
184
|
+
|
|
185
|
+
#, python-brace-format
|
|
186
|
+
msgid "one worker at a time (lease {ttl})"
|
|
187
|
+
msgstr "un trabajador a la vez (bloqueo de {ttl})"
|
|
188
|
+
|
|
189
|
+
msgid "not run yet"
|
|
190
|
+
msgstr "todavía no se ha ejecutado"
|
|
191
|
+
|
|
192
|
+
msgid "Runs"
|
|
193
|
+
msgstr "Ejecuciones"
|
|
194
|
+
|
|
195
|
+
msgid "Run now"
|
|
196
|
+
msgstr "Ejecutar ahora"
|
|
197
|
+
|
|
198
|
+
msgid "No worker has registered jobs yet."
|
|
199
|
+
msgstr "Ningún trabajador ha registrado tareas todavía."
|
|
200
|
+
|
|
201
|
+
msgid "When"
|
|
202
|
+
msgstr "Cuándo"
|
|
203
|
+
|
|
204
|
+
msgid "Outcome"
|
|
205
|
+
msgstr "Resultado"
|
|
206
|
+
|
|
207
|
+
msgid "Duration"
|
|
208
|
+
msgstr "Duración"
|
|
209
|
+
|
|
210
|
+
msgid "Error"
|
|
211
|
+
msgstr "Error"
|
|
212
|
+
|
|
213
|
+
msgid "Waiting for a worker…"
|
|
214
|
+
msgstr "Esperando a un trabajador…"
|
|
215
|
+
|
|
216
|
+
#, python-brace-format
|
|
217
|
+
msgid "Finished: {status}"
|
|
218
|
+
msgstr "Terminada: {status}"
|
|
219
|
+
|
|
220
|
+
msgid "Show"
|
|
221
|
+
msgstr "Mostrar"
|
|
222
|
+
|
|
223
|
+
msgid "Due"
|
|
224
|
+
msgstr "Vencimiento"
|
|
225
|
+
|
|
226
|
+
msgid "overdue"
|
|
227
|
+
msgstr "vencida"
|
|
228
|
+
|
|
229
|
+
msgid "No timed transition is waiting on this record."
|
|
230
|
+
msgstr "Ninguna transición programada espera este registro."
|
|
231
|
+
|
|
232
|
+
msgid "worker"
|
|
233
|
+
msgstr "trabajador"
|
|
234
|
+
|
|
235
|
+
msgid "Filter by verb, path or description"
|
|
236
|
+
msgstr "Filtrar por verbo, ruta o descripción"
|
|
237
|
+
|
|
238
|
+
msgid "Fires"
|
|
239
|
+
msgstr "Se ejecuta"
|
|
240
|
+
|
|
241
|
+
#, python-brace-format
|
|
242
|
+
msgid "after {after} in {states} (counted from {since})"
|
|
243
|
+
msgstr "tras {after} en {states} (contado desde {since})"
|
|
244
|
+
|
|
245
|
+
msgid "read"
|
|
246
|
+
msgstr "leer"
|
|
247
|
+
|
|
248
|
+
msgid "create or run"
|
|
249
|
+
msgstr "crear o ejecutar"
|
|
250
|
+
|
|
251
|
+
msgid "replace"
|
|
252
|
+
msgstr "sustituir"
|
|
253
|
+
|
|
254
|
+
msgid "change"
|
|
255
|
+
msgstr "modificar"
|
|
256
|
+
|
|
257
|
+
msgid "delete"
|
|
258
|
+
msgstr "eliminar"
|
|
259
|
+
|
|
260
|
+
msgid "publish an event"
|
|
261
|
+
msgstr "publicar un evento"
|
|
262
|
+
|
|
263
|
+
msgid "watch events live"
|
|
264
|
+
msgstr "ver eventos en directo"
|
|
265
|
+
|
|
266
|
+
msgid "runs on a schedule"
|
|
267
|
+
msgstr "se ejecuta periódicamente"
|
|
268
|
+
|
|
269
|
+
msgid "CRUD"
|
|
270
|
+
msgstr "CRUD"
|
|
271
|
+
|
|
272
|
+
msgid "Transitions and actions"
|
|
273
|
+
msgstr "Transiciones y acciones"
|
|
274
|
+
|
|
275
|
+
msgid "Relations"
|
|
276
|
+
msgstr "Relaciones"
|
|
277
|
+
|
|
278
|
+
msgid "Documents"
|
|
279
|
+
msgstr "Documentos"
|
|
280
|
+
|
|
281
|
+
msgid "Export and print"
|
|
282
|
+
msgstr "Exportar e imprimir"
|
|
283
|
+
|
|
284
|
+
msgid "Events (pub/sub)"
|
|
285
|
+
msgstr "Eventos (pub/sub)"
|
|
286
|
+
|
|
287
|
+
msgid "Schedule (cron)"
|
|
288
|
+
msgstr "Programación (cron)"
|
|
289
|
+
|
|
290
|
+
msgid "Other"
|
|
291
|
+
msgstr "Otros"
|
|
292
|
+
|
|
293
|
+
msgid "Dry run"
|
|
294
|
+
msgstr "Probar sin publicar"
|
|
295
|
+
|
|
296
|
+
msgid "Publish"
|
|
297
|
+
msgstr "Publicar"
|
|
298
|
+
|
|
299
|
+
msgid "Type the event's name to publish it"
|
|
300
|
+
msgstr "Escribe el nombre del evento para publicarlo"
|
|
301
|
+
|
|
302
|
+
#, python-brace-format
|
|
303
|
+
msgid "Type {type} in the confirmation field to publish it."
|
|
304
|
+
msgstr "Escribe {type} en el campo de confirmación para publicarlo."
|
|
305
|
+
|
|
306
|
+
msgid "Publishing by hand is turned off in this application; dry runs work."
|
|
307
|
+
msgstr "Publicar a mano está desactivado en esta aplicación; las pruebas sí funcionan."
|
|
308
|
+
|
|
309
|
+
msgid ""
|
|
310
|
+
"A dry run checks the payload against the event and the consumers that read it. Publishing writes "
|
|
311
|
+
"it to the outbox, tagged origin=console and audited; the worker sends it like any other event."
|
|
312
|
+
msgstr ""
|
|
313
|
+
"La prueba comprueba los datos contra el evento y los consumidores que lo leen. Publicar lo "
|
|
314
|
+
"escribe en la salida (outbox), marcado con origin=console y auditado; el trabajador lo envía como"
|
|
315
|
+
" cualquier otro evento."
|
|
316
|
+
|
|
317
|
+
msgid "The payload fits the event and its consumers."
|
|
318
|
+
msgstr "Los datos encajan con el evento y sus consumidores."
|
|
319
|
+
|
|
320
|
+
msgid "The payload doesn't fit the event: it can't be published."
|
|
321
|
+
msgstr "Los datos no encajan con el evento: no se puede publicar."
|
|
322
|
+
|
|
323
|
+
msgid "The event accepts it, but some consumers would refuse it."
|
|
324
|
+
msgstr "El evento los acepta, pero algunos consumidores los rechazarían."
|
|
325
|
+
|
|
326
|
+
msgid "Published to the outbox:"
|
|
327
|
+
msgstr "Publicado en la salida (outbox):"
|
|
328
|
+
|
|
329
|
+
msgid "deprecated"
|
|
330
|
+
msgstr "obsoleta"
|
|
331
|
+
|
|
332
|
+
msgid "Check"
|
|
333
|
+
msgstr "Comprobación"
|
|
334
|
+
|
|
335
|
+
msgid "Field"
|
|
336
|
+
msgstr "Campo"
|
|
337
|
+
|
|
338
|
+
msgid "Message"
|
|
339
|
+
msgstr "Mensaje"
|
|
340
|
+
|
|
341
|
+
msgid "the event"
|
|
342
|
+
msgstr "el evento"
|
|
343
|
+
|
|
344
|
+
msgid "consumer"
|
|
345
|
+
msgstr "consumidor"
|
|
346
|
+
|
|
347
|
+
msgid "Authorize"
|
|
348
|
+
msgstr "Autorizar"
|
|
349
|
+
|
|
350
|
+
msgid "Sign in with the identity provider, or paste a token or API key below."
|
|
351
|
+
msgstr "Inicia sesión con el proveedor de identidad, o pega un token o una clave de API abajo."
|
|
352
|
+
|
|
353
|
+
#, python-brace-format
|
|
354
|
+
msgid "Signed in as {name}"
|
|
355
|
+
msgstr "Sesión iniciada como {name}"
|
|
356
|
+
|
|
357
|
+
msgid "Sign out"
|
|
358
|
+
msgstr "Cerrar sesión"
|
|
359
|
+
|
|
360
|
+
msgid "The sign-in failed"
|
|
361
|
+
msgstr "No se ha podido iniciar sesión"
|
|
362
|
+
|
|
363
|
+
msgid "messages"
|
|
364
|
+
msgstr "mensajes"
|
|
365
|
+
|
|
366
|
+
msgid ""
|
|
367
|
+
"Where events wait to be sent, and the ones consumers gave up on. Sending one again reaches only "
|
|
368
|
+
"the consumers that didn't handle it."
|
|
369
|
+
msgstr ""
|
|
370
|
+
"Donde esperan los eventos para enviarse, y los que los consumidores han descartado. Volver a "
|
|
371
|
+
"enviar uno solo llega a los consumidores que no lo han tratado."
|
|
372
|
+
|
|
373
|
+
msgid "Messages not sent yet: the relay keeps retrying them"
|
|
374
|
+
msgstr "Mensajes todavía no enviados: la salida los sigue reintentando"
|
|
375
|
+
|
|
376
|
+
msgid "Messages consumers gave up on"
|
|
377
|
+
msgstr "Mensajes que los consumidores han descartado"
|
|
378
|
+
|
|
379
|
+
msgid "waiting to be sent"
|
|
380
|
+
msgstr "pendiente de enviar"
|
|
381
|
+
|
|
382
|
+
msgid "given up"
|
|
383
|
+
msgstr "descartado"
|
|
384
|
+
|
|
385
|
+
msgid "Every message has been sent."
|
|
386
|
+
msgstr "Se han enviado todos los mensajes."
|
|
387
|
+
|
|
388
|
+
msgid "No consumer has given up on a message."
|
|
389
|
+
msgstr "Ningún consumidor ha descartado ningún mensaje."
|
|
390
|
+
|
|
391
|
+
msgid "Event"
|
|
392
|
+
msgstr "Evento"
|
|
393
|
+
|
|
394
|
+
msgid "Attempts"
|
|
395
|
+
msgstr "Intentos"
|
|
396
|
+
|
|
397
|
+
msgid "Consumer"
|
|
398
|
+
msgstr "Consumidor"
|
|
399
|
+
|
|
400
|
+
msgid "Send again"
|
|
401
|
+
msgstr "Volver a enviar"
|
|
402
|
+
|
|
403
|
+
msgid "Back in the queue: the relay sends it again."
|
|
404
|
+
msgstr "De nuevo en la cola: la salida lo volverá a enviar."
|
|
405
|
+
|
|
406
|
+
msgid "not in the outbox any more"
|
|
407
|
+
msgstr "ya no está en la salida"
|
|
408
|
+
|
|
409
|
+
msgid "Refresh"
|
|
410
|
+
msgstr "Actualizar"
|
|
411
|
+
|
|
412
|
+
msgid "Copy as curl"
|
|
413
|
+
msgstr "Copiar como curl"
|
|
414
|
+
|
|
415
|
+
msgid "Copied to the clipboard. $TOKEN stands for your token."
|
|
416
|
+
msgstr "Copiado al portapapeles. $TOKEN representa tu token."
|
|
417
|
+
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""The explorer's outbox and dead letters.
|
|
2
|
+
|
|
3
|
+
- ``GET <api>/outbox``: messages not sent yet (``events:read``).
|
|
4
|
+
- ``GET <api>/dead-letters``: messages consumers gave up on (``events:read``).
|
|
5
|
+
- ``POST <api>/outbox/{message_id}/send-again``: back to the queue
|
|
6
|
+
(``events:redrive``, audited).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from fastapi import APIRouter, Depends, Query, status
|
|
14
|
+
from fastapi.responses import JSONResponse
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _iso(value: Any) -> str | None:
|
|
18
|
+
return value.isoformat() if value is not None else None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _record(record: Any) -> dict[str, Any]:
|
|
22
|
+
envelope = record.envelope
|
|
23
|
+
return {
|
|
24
|
+
"id": envelope.id,
|
|
25
|
+
"type": envelope.type,
|
|
26
|
+
"resource": envelope.resource,
|
|
27
|
+
"schema_version": envelope.schema_version,
|
|
28
|
+
"attempts": record.attempts,
|
|
29
|
+
"last_error": record.last_error,
|
|
30
|
+
"created_at": _iso(record.created_at or envelope.occurred_at),
|
|
31
|
+
"published": record.published,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def build_messages_router(inspector: Any, *, actor_dependency: Any) -> APIRouter:
|
|
36
|
+
"""The explorer's message views: the outbox and the inbox."""
|
|
37
|
+
router = APIRouter(tags=["explorer"])
|
|
38
|
+
|
|
39
|
+
@router.get("/outbox", summary="Messages not sent yet")
|
|
40
|
+
async def outbox(
|
|
41
|
+
limit: int = Query(50, ge=1, le=500), actor: Any = Depends(actor_dependency)
|
|
42
|
+
) -> list[dict[str, Any]]:
|
|
43
|
+
return [_record(r) for r in await inspector.outbox(actor=actor, limit=limit)]
|
|
44
|
+
|
|
45
|
+
@router.get("/dead-letters", summary="Messages consumers gave up on")
|
|
46
|
+
async def dead_letters(
|
|
47
|
+
limit: int = Query(50, ge=1, le=500), actor: Any = Depends(actor_dependency)
|
|
48
|
+
) -> list[dict[str, Any]]:
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
"message_id": d.message_id,
|
|
52
|
+
"event_type": d.event_type,
|
|
53
|
+
"consumer": d.consumer,
|
|
54
|
+
"error": d.error,
|
|
55
|
+
"at": _iso(d.at),
|
|
56
|
+
"in_outbox": d.in_outbox,
|
|
57
|
+
}
|
|
58
|
+
for d in await inspector.dead_letters(actor=actor, limit=limit)
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
@router.post(
|
|
62
|
+
"/outbox/{message_id}/send-again",
|
|
63
|
+
summary="Send an outbox message again",
|
|
64
|
+
status_code=status.HTTP_202_ACCEPTED,
|
|
65
|
+
)
|
|
66
|
+
async def send_again(message_id: str, actor: Any = Depends(actor_dependency)) -> JSONResponse:
|
|
67
|
+
record = await inspector.send_again(message_id, actor=actor)
|
|
68
|
+
return JSONResponse(_record(record), status_code=status.HTTP_202_ACCEPTED)
|
|
69
|
+
|
|
70
|
+
return router
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
__all__ = ["build_messages_router"]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""The explorer's PUB rows: publishing an event by hand.
|
|
2
|
+
|
|
3
|
+
- ``POST <api>/publish/dry-run``: ``{type, version, payload}`` → the problems
|
|
4
|
+
of the payload against the event and its consumers; nothing is written.
|
|
5
|
+
- ``POST <api>/publish``: the same, published through the outbox, tagged
|
|
6
|
+
``origin=console`` and audited (202 with the envelopes).
|
|
7
|
+
|
|
8
|
+
Both need ``events:publish:<Event>``, granted only by name; publishing also
|
|
9
|
+
needs ``EventPublishing(allow_publish=True)``.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import dataclasses
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
from fastapi import APIRouter, Depends, status
|
|
18
|
+
from fastapi.responses import JSONResponse
|
|
19
|
+
from pydantic import BaseModel, Field
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class PublishRequest(BaseModel):
|
|
23
|
+
"""Body of a dry run or a publish: the event type, its version and its payload."""
|
|
24
|
+
|
|
25
|
+
type: str = Field(description="Event type (InvoiceApproved)")
|
|
26
|
+
version: int | None = Field(default=None, description="Schema version (default: current)")
|
|
27
|
+
payload: dict[str, Any] = Field(default_factory=dict, description="The event's fields")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def build_publish_router(publishing: Any, *, actor_dependency: Any) -> APIRouter:
|
|
31
|
+
"""The explorer's publishing routes: the catalogue, a dry run and a publish."""
|
|
32
|
+
router = APIRouter(prefix="/publish", tags=["explorer"])
|
|
33
|
+
|
|
34
|
+
@router.post("/dry-run", summary="Check an event's payload without publishing it")
|
|
35
|
+
async def dry_run(
|
|
36
|
+
request: PublishRequest, actor: Any = Depends(actor_dependency)
|
|
37
|
+
) -> dict[str, Any]:
|
|
38
|
+
problems = await publishing.validate(
|
|
39
|
+
request.type, request.version, request.payload, actor=actor
|
|
40
|
+
)
|
|
41
|
+
return {
|
|
42
|
+
"problems": [dataclasses.asdict(p) for p in problems],
|
|
43
|
+
"blocking": any(p.check == "event" for p in problems),
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@router.post(
|
|
47
|
+
"", summary="Publish an event through the outbox", status_code=status.HTTP_202_ACCEPTED
|
|
48
|
+
)
|
|
49
|
+
async def publish(
|
|
50
|
+
request: PublishRequest, actor: Any = Depends(actor_dependency)
|
|
51
|
+
) -> JSONResponse:
|
|
52
|
+
envelopes = await publishing.publish(
|
|
53
|
+
request.type, request.version, request.payload, actor=actor
|
|
54
|
+
)
|
|
55
|
+
return JSONResponse(
|
|
56
|
+
{"envelopes": [e.to_dict() for e in envelopes]},
|
|
57
|
+
status_code=status.HTTP_202_ACCEPTED,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
return router
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def publish_config(publishing: Any, api_prefix: str) -> dict[str, Any]:
|
|
64
|
+
"""What the PUB rows need: the publishable events by resource."""
|
|
65
|
+
by_resource: dict[str, list[dict[str, Any]]] = {}
|
|
66
|
+
for event in publishing.catalogue():
|
|
67
|
+
by_resource.setdefault(event.resource or "", []).append(
|
|
68
|
+
{
|
|
69
|
+
"type": event.type,
|
|
70
|
+
"summary": event.summary,
|
|
71
|
+
"versions": [
|
|
72
|
+
{"version": v.version, "example": v.example, "deprecated": v.deprecated}
|
|
73
|
+
for v in event.versions
|
|
74
|
+
],
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
return {
|
|
78
|
+
"dry_run": f"{api_prefix}/publish/dry-run",
|
|
79
|
+
"publish": f"{api_prefix}/publish",
|
|
80
|
+
"enabled": publishing.allow_publish,
|
|
81
|
+
"events": by_resource,
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
__all__ = ["PublishRequest", "build_publish_router", "publish_config"]
|