@miguelmorales13/nestkit 0.26.0 → 0.29.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 (289) hide show
  1. package/README.md +69 -0
  2. package/dist/alerts/alert-on-failure.decorator.d.ts +5 -0
  3. package/dist/alerts/alert-sinks.d.ts +29 -0
  4. package/dist/alerts/alerts.module.d.ts +19 -0
  5. package/dist/alerts/alerts.options.d.ts +1 -0
  6. package/dist/alerts/alerts.service.d.ts +28 -0
  7. package/dist/alerts/alerts.types.d.ts +66 -0
  8. package/dist/alerts/index.cjs +276 -0
  9. package/dist/alerts/index.d.ts +10 -0
  10. package/dist/alerts/index.js +276 -0
  11. package/dist/alerts/logger-with-alerts.d.ts +18 -0
  12. package/dist/alerts/process-guards.d.ts +21 -0
  13. package/dist/alerts/runtime.d.ts +4 -0
  14. package/dist/audit/index.cjs +13 -13
  15. package/dist/audit/index.js +2 -2
  16. package/dist/auth/index.cjs +21 -21
  17. package/dist/auth/index.js +3 -3
  18. package/dist/auth/oauth/index.cjs +101 -101
  19. package/dist/auth/oauth/index.js +3 -3
  20. package/dist/bootstrap/apply-defaults.d.ts +9 -0
  21. package/dist/bootstrap/index.cjs +7 -6
  22. package/dist/bootstrap/index.js +6 -5
  23. package/dist/chunk-33KFVAUZ.cjs +151 -0
  24. package/dist/chunk-3TUMVLPJ.js +14 -0
  25. package/dist/{chunk-PA24P76K.js → chunk-45SW7FBE.js} +1 -1
  26. package/dist/{chunk-RF75KC63.cjs → chunk-47IYXZHW.cjs} +2 -2
  27. package/dist/{chunk-TUNDBBQF.js → chunk-4WWOKZIO.js} +4 -4
  28. package/dist/{chunk-2DUEQKOI.js → chunk-5LVGCTJ3.js} +4 -4
  29. package/dist/chunk-A6YGIZCQ.cjs +14 -0
  30. package/dist/chunk-A7FI6HXV.js +40 -0
  31. package/dist/chunk-CU4FUIVJ.cjs +8 -0
  32. package/dist/{chunk-FH5UNWWW.cjs → chunk-D35TBVRO.cjs} +4 -4
  33. package/dist/{chunk-4MGIQFAJ.js → chunk-D3DDJWUD.js} +5 -0
  34. package/dist/chunk-DVGPEBUL.js +8 -0
  35. package/dist/{chunk-VKOPDDCC.js → chunk-ENZ7LQRE.js} +1 -1
  36. package/dist/{chunk-3AUOOEQO.cjs → chunk-F77X4QUN.cjs} +2 -2
  37. package/dist/chunk-FBNV5X6C.js +61 -0
  38. package/dist/{chunk-APUFKA4K.cjs → chunk-FDZQCLLK.cjs} +6 -6
  39. package/dist/{chunk-DYHSOULW.js → chunk-IGSNB5BX.js} +1 -1
  40. package/dist/chunk-IVWPA6QH.cjs +90 -0
  41. package/dist/{chunk-LSDY6ETG.cjs → chunk-JJKGQNGD.cjs} +5 -5
  42. package/dist/{chunk-ALIKVFOV.cjs → chunk-JRFE7NSO.cjs} +12 -4
  43. package/dist/{chunk-HVHYZXBB.cjs → chunk-KNU5RN3O.cjs} +3 -3
  44. package/dist/{chunk-52IOOHNX.cjs → chunk-KQPJCVN3.cjs} +26 -26
  45. package/dist/chunk-LGFHLAY3.cjs +61 -0
  46. package/dist/{chunk-2REOCMUD.cjs → chunk-LRX7AMSS.cjs} +6 -1
  47. package/dist/chunk-LU3HO7B3.js +151 -0
  48. package/dist/{chunk-4PFAKLT3.js → chunk-MUWHGBIB.js} +1 -1
  49. package/dist/{chunk-ZJMLEP5H.js → chunk-NJYLQDB3.js} +1 -1
  50. package/dist/{chunk-IFNYRZP2.js → chunk-OSRH6KYZ.js} +4 -4
  51. package/dist/{chunk-6RAPVLJM.js → chunk-OTE77ONL.js} +1 -1
  52. package/dist/chunk-UDACUMLO.cjs +40 -0
  53. package/dist/{chunk-PFHHLB7B.js → chunk-UGAAJRPO.js} +10 -2
  54. package/dist/{chunk-SPTDXUED.cjs → chunk-URLDTS2Q.cjs} +2 -2
  55. package/dist/{chunk-W2T2VFLC.cjs → chunk-VALDHJOO.cjs} +5 -5
  56. package/dist/chunk-WFCQDOSN.js +90 -0
  57. package/dist/consent/consent.interceptor.d.ts +20 -0
  58. package/dist/consent/consent.module.d.ts +25 -0
  59. package/dist/consent/consent.options.d.ts +30 -0
  60. package/dist/consent/consent.port.d.ts +17 -0
  61. package/dist/consent/consent.service.d.ts +44 -0
  62. package/dist/consent/guard/index.cjs +13 -0
  63. package/dist/consent/guard/index.d.ts +31 -0
  64. package/dist/consent/guard/index.js +13 -0
  65. package/dist/consent/index.cjs +271 -0
  66. package/dist/consent/index.d.ts +13 -0
  67. package/dist/consent/index.js +271 -0
  68. package/dist/consent/memory.store.d.ts +7 -0
  69. package/dist/consent/shared/index.cjs +11 -0
  70. package/dist/consent/shared/index.d.ts +19 -0
  71. package/dist/consent/shared/index.js +11 -0
  72. package/dist/consent/typeorm.store.d.ts +22 -0
  73. package/dist/crud/index.cjs +4 -4
  74. package/dist/crud/index.js +3 -3
  75. package/dist/database/postgres/index.cjs +3 -3
  76. package/dist/database/postgres/index.js +2 -2
  77. package/dist/database/supabase/index.cjs +3 -3
  78. package/dist/database/supabase/index.js +2 -2
  79. package/dist/database/typeorm/index.cjs +2 -2
  80. package/dist/database/typeorm/index.js +1 -1
  81. package/dist/devices/device-check.interceptor.d.ts +20 -0
  82. package/dist/devices/devices.module.d.ts +28 -0
  83. package/dist/devices/devices.options.d.ts +53 -0
  84. package/dist/devices/devices.port.d.ts +62 -0
  85. package/dist/devices/devices.service.d.ts +58 -0
  86. package/dist/devices/index.cjs +327 -0
  87. package/dist/devices/index.d.ts +8 -0
  88. package/dist/devices/index.js +327 -0
  89. package/dist/devices/memory.store.d.ts +12 -0
  90. package/dist/email/index.cjs +2 -2
  91. package/dist/email/index.js +1 -1
  92. package/dist/email/nodemailer/index.cjs +2 -2
  93. package/dist/email/nodemailer/index.js +1 -1
  94. package/dist/email/resend/index.cjs +2 -2
  95. package/dist/email/resend/index.js +1 -1
  96. package/dist/entities/index.cjs +1 -1
  97. package/dist/entities/index.js +1 -1
  98. package/dist/errors/index.cjs +7 -7
  99. package/dist/errors/index.js +7 -7
  100. package/dist/events/buses.d.ts +27 -0
  101. package/dist/events/events.controller.d.ts +15 -0
  102. package/dist/events/events.module.d.ts +29 -0
  103. package/dist/events/events.options.d.ts +50 -0
  104. package/dist/events/events.service.d.ts +49 -0
  105. package/dist/events/events.types.d.ts +77 -0
  106. package/dist/events/index.cjs +557 -0
  107. package/dist/events/index.d.ts +10 -0
  108. package/dist/events/index.js +557 -0
  109. package/dist/events/memory-ticket.store.d.ts +9 -0
  110. package/dist/google-business/google-business-http.d.ts +41 -0
  111. package/dist/google-business/google-business.errors.d.ts +75 -0
  112. package/dist/google-business/google-business.mappers.d.ts +52 -0
  113. package/dist/google-business/google-business.module.d.ts +26 -0
  114. package/dist/google-business/google-business.options.d.ts +40 -0
  115. package/dist/google-business/google-business.ports.d.ts +18 -0
  116. package/dist/google-business/google-business.service.d.ts +120 -0
  117. package/dist/google-business/google-business.types.d.ts +155 -0
  118. package/dist/google-business/index.cjs +1025 -0
  119. package/dist/google-business/index.d.ts +15 -0
  120. package/dist/google-business/index.js +1025 -0
  121. package/dist/google-business/testing/google-simulator.d.ts +61 -0
  122. package/dist/hardening/body-limits.d.ts +24 -0
  123. package/dist/hardening/http.types.d.ts +26 -0
  124. package/dist/hardening/index.cjs +179 -0
  125. package/dist/hardening/index.d.ts +19 -0
  126. package/dist/hardening/index.js +179 -0
  127. package/dist/hardening/memory-rate-limit.store.d.ts +10 -0
  128. package/dist/hardening/origin-secret.d.ts +29 -0
  129. package/dist/hardening/rate-limit.decorator.d.ts +8 -0
  130. package/dist/hardening/rate-limit.guard.d.ts +18 -0
  131. package/dist/hardening/rate-limit.module.d.ts +23 -0
  132. package/dist/hardening/rate-limit.options.d.ts +35 -0
  133. package/dist/hardening/rate-limit.port.d.ts +11 -0
  134. package/dist/hardening/redis-rate-limit.store.d.ts +23 -0
  135. package/dist/hardening/trust-proxy.d.ts +22 -0
  136. package/dist/health/health.controller.d.ts +32 -0
  137. package/dist/health/health.module.d.ts +15 -0
  138. package/dist/health/health.options.d.ts +24 -0
  139. package/dist/health/index.cjs +103 -0
  140. package/dist/health/index.d.ts +5 -0
  141. package/dist/health/index.js +103 -0
  142. package/dist/i18n/index.cjs +3 -3
  143. package/dist/i18n/index.js +2 -2
  144. package/dist/idempotency/idempotency.interceptor.d.ts +1 -0
  145. package/dist/idempotency/idempotency.options.d.ts +15 -0
  146. package/dist/idempotency/index.cjs +214 -7
  147. package/dist/idempotency/index.d.ts +5 -0
  148. package/dist/idempotency/index.js +210 -3
  149. package/dist/idempotency/no-idempotency.decorator.d.ts +8 -0
  150. package/dist/idempotency/postgres.store.d.ts +49 -0
  151. package/dist/idempotency/redis.store.d.ts +59 -0
  152. package/dist/index.cjs +21 -20
  153. package/dist/index.js +33 -32
  154. package/dist/invoicing/index.cjs +2 -2
  155. package/dist/invoicing/index.js +1 -1
  156. package/dist/jobs/defer-job.d.ts +10 -0
  157. package/dist/jobs/index.cjs +318 -0
  158. package/dist/jobs/index.d.ts +8 -0
  159. package/dist/jobs/index.js +318 -0
  160. package/dist/jobs/jobs-admin.controller.d.ts +18 -0
  161. package/dist/jobs/jobs.module.d.ts +33 -0
  162. package/dist/jobs/jobs.options.d.ts +62 -0
  163. package/dist/jobs/jobs.service.d.ts +53 -0
  164. package/dist/jobs/jobs.sql.d.ts +11 -0
  165. package/dist/media/index.cjs +14 -14
  166. package/dist/media/index.js +1 -1
  167. package/dist/meta/index.cjs +3 -3
  168. package/dist/meta/index.js +1 -1
  169. package/dist/notifications/index.cjs +375 -0
  170. package/dist/notifications/index.d.ts +8 -0
  171. package/dist/notifications/index.js +375 -0
  172. package/dist/notifications/memory.stores.d.ts +23 -0
  173. package/dist/notifications/notifications.controller.d.ts +11 -0
  174. package/dist/notifications/notifications.module.d.ts +31 -0
  175. package/dist/notifications/notifications.options.d.ts +33 -0
  176. package/dist/notifications/notifications.port.d.ts +97 -0
  177. package/dist/notifications/notifier.service.d.ts +31 -0
  178. package/dist/payments/connect/credentials-cipher.d.ts +14 -0
  179. package/dist/payments/connect/mercadopago-refund.d.ts +118 -0
  180. package/dist/payments/connect/mercadopago-signature.d.ts +6 -0
  181. package/dist/payments/connect/online-checkout.d.ts +69 -0
  182. package/dist/payments/connect/rejection.d.ts +7 -0
  183. package/dist/payments/connect/status.d.ts +20 -0
  184. package/dist/payments/connect/terminal-connections.d.ts +291 -0
  185. package/dist/payments/index.cjs +908 -10
  186. package/dist/payments/index.d.ts +10 -0
  187. package/dist/payments/index.js +900 -2
  188. package/dist/pinterest/index.cjs +3 -3
  189. package/dist/pinterest/index.js +1 -1
  190. package/dist/privacy/anonymizer.d.ts +14 -0
  191. package/dist/privacy/index.cjs +768 -0
  192. package/dist/privacy/index.d.ts +13 -0
  193. package/dist/privacy/index.js +768 -0
  194. package/dist/privacy/memory.store.d.ts +15 -0
  195. package/dist/privacy/privacy.module.d.ts +30 -0
  196. package/dist/privacy/privacy.options.d.ts +43 -0
  197. package/dist/privacy/privacy.port.d.ts +25 -0
  198. package/dist/privacy/privacy.service.d.ts +69 -0
  199. package/dist/privacy/privacy.types.d.ts +125 -0
  200. package/dist/privacy/sql.d.ts +7 -0
  201. package/dist/privacy/sql.store.d.ts +21 -0
  202. package/dist/privacy/zip.d.ts +23 -0
  203. package/dist/push/index.cjs +13 -13
  204. package/dist/push/index.js +5 -5
  205. package/dist/resilience/alert-channels.d.ts +39 -0
  206. package/dist/resilience/alert-errors.interceptor.d.ts +10 -0
  207. package/dist/resilience/alert-on-failure.decorator.d.ts +10 -0
  208. package/dist/resilience/alert.service.d.ts +77 -0
  209. package/dist/resilience/index.cjs +863 -0
  210. package/dist/resilience/index.d.ts +18 -0
  211. package/dist/resilience/index.js +863 -0
  212. package/dist/resilience/memory-alert-store.d.ts +26 -0
  213. package/dist/resilience/provider-health.controller.d.ts +14 -0
  214. package/dist/resilience/provider-unavailable.exception.d.ts +11 -0
  215. package/dist/resilience/resilience.module.d.ts +34 -0
  216. package/dist/resilience/resilience.options.d.ts +28 -0
  217. package/dist/resilience/resilience.types.d.ts +167 -0
  218. package/dist/resilience/resilient-fetch.d.ts +38 -0
  219. package/dist/resilience/runtime.d.ts +24 -0
  220. package/dist/resilience/typeorm/alert.entity.d.ts +21 -0
  221. package/dist/resilience/typeorm/index.cjs +102 -0
  222. package/dist/resilience/typeorm/index.d.ts +3 -0
  223. package/dist/resilience/typeorm/index.js +102 -0
  224. package/dist/resilience/typeorm/typeorm-alert-store.d.ts +39 -0
  225. package/dist/resilience/validate-destination.d.ts +63 -0
  226. package/dist/response/index.cjs +3 -3
  227. package/dist/response/index.js +2 -2
  228. package/dist/scheduling/cron-lock.service.d.ts +36 -0
  229. package/dist/scheduling/cron-unico.decorator.d.ts +27 -0
  230. package/dist/scheduling/fallback.store.d.ts +34 -0
  231. package/dist/scheduling/index.cjs +392 -0
  232. package/dist/scheduling/index.d.ts +18 -0
  233. package/dist/scheduling/index.js +392 -0
  234. package/dist/scheduling/lock-store.port.d.ts +19 -0
  235. package/dist/scheduling/memory.store.d.ts +15 -0
  236. package/dist/scheduling/redis.module.d.ts +31 -0
  237. package/dist/scheduling/redis.store.d.ts +24 -0
  238. package/dist/scheduling/scheduling.module.d.ts +24 -0
  239. package/dist/scheduling/scheduling.options.d.ts +27 -0
  240. package/dist/scheduling/sql.store.d.ts +26 -0
  241. package/dist/secrets/index.cjs +274 -0
  242. package/dist/secrets/index.d.ts +8 -0
  243. package/dist/secrets/index.js +274 -0
  244. package/dist/secrets/secrets.errors.d.ts +6 -0
  245. package/dist/secrets/secrets.module.d.ts +21 -0
  246. package/dist/secrets/secrets.options.d.ts +32 -0
  247. package/dist/secrets/secrets.service.d.ts +54 -0
  248. package/dist/secrets/secrets.transformer.d.ts +33 -0
  249. package/dist/security/hash.d.ts +8 -0
  250. package/dist/security/index.cjs +27 -35
  251. package/dist/security/index.d.ts +5 -0
  252. package/dist/security/index.js +24 -32
  253. package/dist/security/mask.d.ts +22 -0
  254. package/dist/security/signed-grant.d.ts +30 -0
  255. package/dist/storage/index.cjs +2 -2
  256. package/dist/storage/index.js +1 -1
  257. package/dist/stripe/index.cjs +7 -7
  258. package/dist/stripe/index.js +1 -1
  259. package/dist/telegram/index.cjs +2 -2
  260. package/dist/telegram/index.js +1 -1
  261. package/dist/tenancy/app-role.d.ts +24 -0
  262. package/dist/tenancy/db-helpers.d.ts +12 -0
  263. package/dist/tenancy/index.cjs +205 -0
  264. package/dist/tenancy/index.d.ts +14 -0
  265. package/dist/tenancy/index.js +205 -0
  266. package/dist/tenancy/pg/index.cjs +34 -0
  267. package/dist/tenancy/pg/index.d.ts +2 -0
  268. package/dist/tenancy/pg/index.js +34 -0
  269. package/dist/tenancy/pg/with-tenant.d.ts +23 -0
  270. package/dist/tenancy/request-context.d.ts +18 -0
  271. package/dist/tenancy/rls-guardrail.d.ts +38 -0
  272. package/dist/tenancy/scope.d.ts +5 -0
  273. package/dist/tenancy/tenancy.errors.d.ts +5 -0
  274. package/dist/tenancy/tenancy.middleware.d.ts +8 -0
  275. package/dist/tenancy/tenancy.module.d.ts +37 -0
  276. package/dist/tenancy/tenancy.options.d.ts +34 -0
  277. package/dist/tenancy/typeorm/index.cjs +41 -0
  278. package/dist/tenancy/typeorm/index.d.ts +2 -0
  279. package/dist/tenancy/typeorm/index.js +41 -0
  280. package/dist/tenancy/typeorm/with-tenant.d.ts +23 -0
  281. package/dist/tiktok/index.cjs +3 -3
  282. package/dist/tiktok/index.js +1 -1
  283. package/dist/tracking/index.cjs +3 -3
  284. package/dist/tracking/index.js +2 -2
  285. package/dist/umami/index.cjs +4 -4
  286. package/dist/umami/index.js +1 -1
  287. package/dist/whatsapp/index.cjs +2 -2
  288. package/dist/whatsapp/index.js +1 -1
  289. package/package.json +108 -3
@@ -0,0 +1,26 @@
1
+ import type { AlertKey, AlertRecord, AlertStore, NewAlertRecord } from './resilience.types.js';
2
+ /** Alertas en memoria: para pruebas y desarrollo. Se pierde al reiniciar. */
3
+ export declare class MemoryAlertStore implements AlertStore {
4
+ readonly records: AlertRecord[];
5
+ findOpen(key: AlertKey): Promise<AlertRecord | null>;
6
+ create(input: NewAlertRecord): Promise<AlertRecord>;
7
+ touch(id: string, patch: {
8
+ message: string;
9
+ details?: Record<string, unknown>;
10
+ at: Date;
11
+ }): Promise<AlertRecord>;
12
+ markNotified(id: string, at: Date): Promise<void>;
13
+ listOpen(filter?: {
14
+ provider?: string;
15
+ tenantId?: string;
16
+ }): Promise<AlertRecord[]>;
17
+ resolve(ids: string[], at: Date): Promise<void>;
18
+ list(opts: {
19
+ onlyOpen: boolean;
20
+ cursor?: string;
21
+ limit?: number;
22
+ }): Promise<{
23
+ items: AlertRecord[];
24
+ next: string | null;
25
+ }>;
26
+ }
@@ -0,0 +1,14 @@
1
+ import { type Type } from '@nestjs/common';
2
+ /** Compara en tiempo constante (nunca `!==`, que filtra el token por timing). */
3
+ export declare function tokenMatches(received: string | undefined, expected: string): boolean;
4
+ /**
5
+ * Controlador de salud de proveedores, como mixin (mismo patrón que `createCrudController`):
6
+ * `ResilienceModule` lo usa si hay `rutaSalud`, pero puedes ignorarlo y escribir el tuyo contra
7
+ * `AlertService`.
8
+ *
9
+ * Responde 404 si no hay `salud.token` (la ruta no existe), 401 si la cabecera no coincide y 503
10
+ * mientras haya alertas de plataforma abiertas, para que un monitor externo avise aunque los
11
+ * canales de alerta estén caídos. Declara la ruta pública en tu guard global (p. ej. `@Public()`):
12
+ * la protege su propio token.
13
+ */
14
+ export declare function createProviderHealthController(path: string): Type<unknown>;
@@ -0,0 +1,11 @@
1
+ import { AppException } from '../errors/app.exception.js';
2
+ import type { ProviderFailure } from './resilience.types.js';
3
+ /**
4
+ * El proveedor no respondió (tiempo agotado o sin conexión). Es un 502, nunca un 500: el fallo
5
+ * es de un tercero, no un bug de la API. `url` y `detail` pueden traer detalles internos del
6
+ * proveedor, así que se quedan en el log del servidor y NUNCA viajan en la respuesta HTTP.
7
+ */
8
+ export declare class ProviderUnavailableException extends AppException {
9
+ readonly provider: string;
10
+ constructor(provider: string, info: ProviderFailure);
11
+ }
@@ -0,0 +1,34 @@
1
+ import { type DynamicModule } from '@nestjs/common';
2
+ import type { ResilienceOptions } from './resilience.types.js';
3
+ /**
4
+ * Resiliencia hacia proveedores externos: `fetchResiliente`, alertas con deduplicación y salud.
5
+ *
6
+ * ```ts
7
+ * ResilienceModule.forRoot({
8
+ * proveedores: { pagos: { timeoutMs: 10_000, reintentos: 2, nombre: 'Pagos' }, ia: { idempotente: true } },
9
+ * alertas: { canales: [new WebhookAlertChannel({ url })], almacen: typeOrmAlertStore({ dataSource }) },
10
+ * rutaSalud: 'health/providers',
11
+ * salud: { token: process.env.HEALTH_TOKEN },
12
+ * })
13
+ * ```
14
+ *
15
+ * `fetchResiliente({ proveedor })` y `@AlertarFallo` funcionan también fuera del módulo (scripts):
16
+ * sin él usan valores por omisión y no avisan a nadie.
17
+ */
18
+ export declare class ResilienceModule {
19
+ static forRoot(options?: ResilienceOptions): DynamicModule;
20
+ /**
21
+ * `rutaSalud` va aparte de la fábrica porque la ruta de un controlador se fija al decorarlo,
22
+ * antes de que la fábrica asíncrona corra. El resto (token incluido) sí viene de ella.
23
+ */
24
+ static forRootAsync(config: {
25
+ imports?: any[];
26
+ inject?: any[];
27
+ useFactory: (...args: any[]) => ResilienceOptions | Promise<ResilienceOptions>;
28
+ rutaSalud?: string;
29
+ /** `alertas.interceptorGlobal` también debe saberse al declarar el módulo. */
30
+ interceptorGlobal?: boolean;
31
+ }): DynamicModule;
32
+ private static install;
33
+ private static build;
34
+ }
@@ -0,0 +1,28 @@
1
+ import type { AlertStore, AlertChannelPort, BackoffOptions, HealthOptions, ProviderConfig, ProviderFailure, ResilienceOptions } from './resilience.types.js';
2
+ /** DI token carrying the resolved {@link ResolvedResilienceOptions}. */
3
+ export declare const RESILIENCE_OPTIONS: unique symbol;
4
+ /** DI token of the {@link AlertStore} in use. */
5
+ export declare const ALERT_STORE: unique symbol;
6
+ export declare const DEFAULT_RETRYABLE_STATUS: number[];
7
+ export declare const DEFAULT_ERROR_CODE = "PROVIDER_UNAVAILABLE";
8
+ export interface ResolvedResilienceOptions {
9
+ proveedores: Record<string, ProviderConfig>;
10
+ porDefecto: Required<Pick<ProviderConfig, 'timeoutMs' | 'reintentos'>> & ProviderConfig & {
11
+ backoff: Required<BackoffOptions>;
12
+ };
13
+ alertas: {
14
+ almacen: AlertStore;
15
+ canales: AlertChannelPort[];
16
+ ventanaDedupeMs: number;
17
+ topePorMinuto: number;
18
+ origen: string;
19
+ interceptorGlobal: boolean;
20
+ };
21
+ rutaSalud?: string;
22
+ salud: HealthOptions;
23
+ codigoErrorProveedor: string;
24
+ mensajeProveedor: (provider: string, name: string, info: ProviderFailure) => string;
25
+ }
26
+ export declare const DEFAULT_BACKOFF: Required<BackoffOptions>;
27
+ export declare function defaultMessage(_provider: string, name: string, info: ProviderFailure): string;
28
+ export declare function resolveOptions(options?: ResilienceOptions): ResolvedResilienceOptions;
@@ -0,0 +1,167 @@
1
+ /** Backoff exponencial entre reintentos: `baseMs · factor^n + jitter`; `Retry-After` manda si viene. */
2
+ export interface BackoffOptions {
3
+ /** Espera antes del primer reintento. Por defecto 400 ms. */
4
+ baseMs?: number;
5
+ /** Multiplicador por reintento. Por defecto 2. */
6
+ factor?: number;
7
+ /** Tope de cualquier espera (incluido `Retry-After`). Por defecto 30 s. */
8
+ maxMs?: number;
9
+ /** Ruido aleatorio máximo que se suma a cada espera. Por defecto 100 ms. */
10
+ jitterMs?: number;
11
+ }
12
+ /** Política de un proveedor externo. Todo es opcional: lo que falte sale de `porDefecto`. */
13
+ export interface ProviderConfig {
14
+ /** Tiempo límite de CADA intento. Por defecto 15 s. */
15
+ timeoutMs?: number;
16
+ /** Reintentos además del primer intento. Por defecto 2. */
17
+ reintentos?: number;
18
+ backoff?: BackoffOptions;
19
+ /**
20
+ * `true` si repetir cualquier método es seguro (generar un texto, consultar por POST).
21
+ * Sin esto, solo se reintentan GET/HEAD/OPTIONS/PUT/DELETE y los POST que traen una cabecera
22
+ * de idempotencia. Un POST que cobra o timbra NO se repite solo.
23
+ */
24
+ idempotente?: boolean;
25
+ /** Nombre para personas (mensajes y alertas). Por defecto la clave. */
26
+ nombre?: string;
27
+ /** ¿Hay credenciales/configuración para hablar con él? Alimenta la ruta de salud. Por defecto sí. */
28
+ configurado?: () => boolean;
29
+ /** Códigos HTTP que se reintentan. Por defecto 408, 425, 429, 500, 502, 503, 504. */
30
+ statusReintentables?: number[];
31
+ }
32
+ export type FailureReason = 'timeout' | 'network' | 'http';
33
+ /** Lo que el envoltorio HTTP cuenta de un fallo. `url` NUNCA lleva query string. */
34
+ export interface ProviderFailure {
35
+ reason: FailureReason;
36
+ status?: number;
37
+ attempts: number;
38
+ url: string;
39
+ /** Credenciales de un tenant (no de la plataforma): la alerta es de ámbito tenant. */
40
+ tenantId?: string;
41
+ detail?: string;
42
+ }
43
+ /** Lo que `fetchResiliente` le cuenta a las alertas. Lo implementa `AlertService`. */
44
+ export interface ProviderSink {
45
+ success(provider: string): void;
46
+ failure(provider: string, info: ProviderFailure): void;
47
+ credentials(provider: string, info: ProviderFailure): void;
48
+ }
49
+ export type AlertLevel = 'info' | 'success' | 'warn' | 'error' | 'critical';
50
+ /** Mensaje listo para un canal. */
51
+ export interface AlertMessage {
52
+ title: string;
53
+ text?: string;
54
+ level?: AlertLevel;
55
+ source?: string;
56
+ fields?: Record<string, string | number | boolean>;
57
+ error?: {
58
+ name?: string;
59
+ message: string;
60
+ stack?: string;
61
+ };
62
+ /** Cuántas veces se omitió este mismo aviso por la ventana de deduplicación. */
63
+ repeated?: number;
64
+ /** Datos estructurados de la alerta persistida, si el mensaje viene de una. */
65
+ alert?: AlertRecord & {
66
+ state: 'open' | 'resolved';
67
+ };
68
+ }
69
+ /** Puerto de salida de avisos (webhook, correo, chat…). Nunca debe lanzar; si lanza, se registra y se sigue. */
70
+ export interface AlertChannelPort {
71
+ send(message: AlertMessage): Promise<void>;
72
+ }
73
+ export type AlertScope = 'platform' | 'tenant';
74
+ /** Una fila por (provider, type, tenantId) abierta; acumula `times` y se cierra con `resolvedAt`. */
75
+ export interface AlertRecord {
76
+ id: string;
77
+ provider: string;
78
+ type: string;
79
+ scope: AlertScope;
80
+ tenantId: string | null;
81
+ message: string;
82
+ details: Record<string, unknown>;
83
+ times: number;
84
+ firstAt: Date;
85
+ lastAt: Date;
86
+ notifiedAt: Date | null;
87
+ resolvedAt: Date | null;
88
+ }
89
+ export interface NewAlertRecord {
90
+ provider: string;
91
+ type: string;
92
+ scope: AlertScope;
93
+ tenantId: string | null;
94
+ message: string;
95
+ details: Record<string, unknown>;
96
+ at: Date;
97
+ }
98
+ export interface AlertKey {
99
+ provider: string;
100
+ type: string;
101
+ tenantId?: string | null;
102
+ }
103
+ /**
104
+ * Puerto de persistencia de alertas. nestkit orquesta, el consumidor guarda:
105
+ * hay una implementación en memoria y otra TypeORM (`resilience/typeorm`).
106
+ */
107
+ export interface AlertStore {
108
+ findOpen(key: AlertKey): Promise<AlertRecord | null>;
109
+ create(input: NewAlertRecord): Promise<AlertRecord>;
110
+ /** Suma 1 a `times` (de forma atómica), fija `lastAt`, reemplaza `message` y mezcla `details`. */
111
+ touch(id: string, patch: {
112
+ message: string;
113
+ details?: Record<string, unknown>;
114
+ at: Date;
115
+ }): Promise<AlertRecord>;
116
+ markNotified(id: string, at: Date): Promise<void>;
117
+ listOpen(filter?: {
118
+ provider?: string;
119
+ tenantId?: string;
120
+ }): Promise<AlertRecord[]>;
121
+ resolve(ids: string[], at: Date): Promise<void>;
122
+ /** Paginado por `lastAt` descendente, para una pantalla de administración. Opcional. */
123
+ list?(opts: {
124
+ onlyOpen: boolean;
125
+ cursor?: string;
126
+ limit?: number;
127
+ }): Promise<{
128
+ items: AlertRecord[];
129
+ next: string | null;
130
+ }>;
131
+ }
132
+ export interface AlertsOptions {
133
+ /** Dónde se guardan. Por defecto en memoria (se pierde al reiniciar). */
134
+ almacen?: AlertStore;
135
+ /** A dónde se avisa. Sin canales solo se escribe en el log. */
136
+ canales?: AlertChannelPort[];
137
+ /** Mientras la alerta siga abierta se vuelve a avisar cada tanto. Por defecto 30 min. */
138
+ ventanaDedupeMs?: number;
139
+ /** Tope global de avisos por minuto hacia los canales. Por defecto 15. */
140
+ topePorMinuto?: number;
141
+ /** Etiqueta de origen de los avisos (`source`). */
142
+ origen?: string;
143
+ /** Registra `AlertErrorsInterceptor` como APP_INTERCEPTOR. Por defecto no. */
144
+ interceptorGlobal?: boolean;
145
+ }
146
+ export interface HealthOptions {
147
+ /** Secreto de la ruta de salud. Sin él, la ruta responde 404 (no existe). */
148
+ token?: string;
149
+ /** Cabecera donde viaja. Nunca query string: queda en logs de acceso. Por defecto `x-health-token`. */
150
+ cabecera?: string;
151
+ /** Datos extra que se añaden a la respuesta (conexiones abiertas, cupos…). */
152
+ extra?: () => Promise<Record<string, unknown>> | Record<string, unknown>;
153
+ }
154
+ export interface ResilienceOptions {
155
+ /** Políticas por proveedor, por clave (`stripe`, `facturador`…). */
156
+ proveedores?: Record<string, ProviderConfig>;
157
+ /** Política para lo que no esté en `proveedores`. */
158
+ porDefecto?: ProviderConfig;
159
+ alertas?: AlertsOptions;
160
+ /** Ruta de la salud de proveedores (p. ej. `salud/proveedores`). Sin ella no hay controlador. */
161
+ rutaSalud?: string;
162
+ salud?: HealthOptions;
163
+ /** Código estable de la excepción de proveedor no disponible. Por defecto `PROVIDER_UNAVAILABLE`. */
164
+ codigoErrorProveedor?: string;
165
+ /** Mensaje (para el usuario) de la excepción. Por defecto uno genérico en español. */
166
+ mensajeProveedor?: (provider: string, name: string, info: ProviderFailure) => string;
167
+ }
@@ -0,0 +1,38 @@
1
+ import type { BackoffOptions, ProviderConfig } from './resilience.types.js';
2
+ export interface ResilientFetchOptions extends ProviderConfig {
3
+ /** Clave del proveedor (la de `ResilienceOptions.proveedores`); si no existe, se usa `porDefecto`. */
4
+ proveedor: string;
5
+ /** El proveedor es de este tenant: un 401/403 es alerta del tenant, no de la plataforma. */
6
+ tenantId?: string;
7
+ /** `fetch` a usar (pruebas, `undici`…). Por defecto el global, resuelto en cada llamada. */
8
+ fetchImpl?: typeof fetch;
9
+ /** Espera entre reintentos (pruebas). */
10
+ sleep?: (ms: number) => Promise<void>;
11
+ }
12
+ export declare const sleep: (ms: number) => Promise<void>;
13
+ /** Espera antes del reintento `n` (0-based): base · factor^n + jitter; `Retry-After` manda si viene. */
14
+ export declare function retryDelay(n: number, backoff: Required<BackoffOptions>, retryAfter?: string | null): number;
15
+ /**
16
+ * Nunca guardes la query string de una URL de proveedor: algunos clientes mandan secretos ahí
17
+ * (client_secret, tokens) y esto terminaría en alertas, canales y logs. Solo origin + pathname.
18
+ */
19
+ export declare function stripQuery(url: string): string;
20
+ /**
21
+ * `fetch` con tiempo límite, reintentos y aviso a las alertas. Se inyecta como `fetchImpl` en los
22
+ * adaptadores de nestkit y se usa directo en los clientes propios.
23
+ *
24
+ * - Reintenta solo lo seguro de repetir: GET/HEAD/OPTIONS/PUT/DELETE, un POST con cabecera de
25
+ * idempotencia, o cualquier método si el proveedor es `idempotente`.
26
+ * - Tiempo agotado o red caída: lanza {@link ProviderUnavailableException} (502, nunca 500).
27
+ * - Una respuesta HTTP, aunque sea 5xx, se DEVUELVE (quien llama decide); solo se cuenta en las alertas.
28
+ */
29
+ export declare function fetchResiliente(o: ResilientFetchOptions): typeof fetch;
30
+ /**
31
+ * Reintenta una operación cualquiera cuando `isTransient(error)` lo dice (p. ej. un proveedor que
32
+ * contesta HTTP 200 con un código de "rate limit" en el cuerpo: el `fetch` no lo ve).
33
+ */
34
+ export declare function withRetries<T>(fn: () => Promise<T>, isTransient: (e: unknown) => boolean, opts?: {
35
+ reintentos?: number;
36
+ backoff?: BackoffOptions;
37
+ sleep?: (ms: number) => Promise<void>;
38
+ }): Promise<T>;
@@ -0,0 +1,24 @@
1
+ import { type ResolvedResilienceOptions } from './resilience.options.js';
2
+ import type { AlertMessage, ProviderSink } from './resilience.types.js';
3
+ /** Quien puede mandar avisos ad hoc (lo implementa `AlertService`). */
4
+ export interface AlertNotifier {
5
+ notify(message: AlertMessage & {
6
+ dedupeKey?: string;
7
+ }): void;
8
+ }
9
+ /**
10
+ * Estado de módulo, como `RequestContext`: `fetchResiliente`, `@AlertarFallo` y la excepción se
11
+ * usan fuera de la inyección de dependencias, así que leen su configuración de aquí.
12
+ * `ResilienceModule` la rellena al arrancar; sin módulo (scripts, migraciones) hay valores por
13
+ * omisión y los avisos son un no-op.
14
+ */
15
+ export interface ResilienceRuntime {
16
+ options: ResolvedResilienceOptions;
17
+ sink: ProviderSink | null;
18
+ notifier: AlertNotifier | null;
19
+ }
20
+ export declare const getRuntime: () => ResilienceRuntime;
21
+ export declare function configureRuntime(options: ResolvedResilienceOptions): void;
22
+ export declare function registerAlerts(sink: ProviderSink | null, notifier: AlertNotifier | null): void;
23
+ /** Vuelve al estado inicial (pruebas). */
24
+ export declare function resetRuntime(): void;
@@ -0,0 +1,21 @@
1
+ import { EntitySchema } from 'typeorm';
2
+ import type { AlertRecord } from '../resilience.types.js';
3
+ /**
4
+ * Entidad de alertas con nombre de tabla configurable. Es un `EntitySchema` (sin decoradores)
5
+ * justamente para que el nombre de la tabla sea un parámetro y no una constante del paquete.
6
+ * Regístrala en `entities` de tu `DataSource`.
7
+ *
8
+ * Migración equivalente (Postgres):
9
+ * ```sql
10
+ * CREATE TABLE <tabla> (
11
+ * id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
12
+ * provider text NOT NULL, type text NOT NULL,
13
+ * scope text NOT NULL DEFAULT 'platform', tenant_id uuid NULL,
14
+ * message text NOT NULL, details jsonb NOT NULL DEFAULT '{}',
15
+ * times int NOT NULL DEFAULT 1,
16
+ * first_at timestamptz NOT NULL, last_at timestamptz NOT NULL,
17
+ * notified_at timestamptz NULL, resolved_at timestamptz NULL
18
+ * );
19
+ * ```
20
+ */
21
+ export declare function createAlertEntity(tableName?: string): EntitySchema<AlertRecord>;
@@ -0,0 +1,102 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }require('../../chunk-LRX7AMSS.cjs');
2
+
3
+ // src/resilience/typeorm/alert.entity.ts
4
+ var _typeorm = require('typeorm');
5
+ function createAlertEntity(tableName = "system_alert") {
6
+ return new (0, _typeorm.EntitySchema)({
7
+ name: `Alert_${tableName}`,
8
+ tableName,
9
+ columns: {
10
+ id: { type: "uuid", primary: true, generated: "uuid" },
11
+ provider: { type: "text" },
12
+ type: { type: "text" },
13
+ scope: { type: "text", default: "platform" },
14
+ tenantId: { name: "tenant_id", type: "uuid", nullable: true },
15
+ message: { type: "text" },
16
+ details: { type: "jsonb", default: () => "'{}'" },
17
+ times: { type: "int", default: 1 },
18
+ firstAt: { name: "first_at", type: "timestamptz" },
19
+ lastAt: { name: "last_at", type: "timestamptz" },
20
+ notifiedAt: { name: "notified_at", type: "timestamptz", nullable: true },
21
+ resolvedAt: { name: "resolved_at", type: "timestamptz", nullable: true }
22
+ }
23
+ });
24
+ }
25
+
26
+ // src/resilience/typeorm/typeorm-alert-store.ts
27
+
28
+ var TypeOrmAlertStore = class {
29
+ constructor(options) {
30
+ this.ds = options.dataSource;
31
+ this.entity = _nullishCoalesce(options.entity, () => ( createAlertEntity(options.nombreTabla)));
32
+ }
33
+ get repo() {
34
+ return this.ds.getRepository(this.entity);
35
+ }
36
+ async findOpen(key) {
37
+ return this.repo.findOne({
38
+ where: {
39
+ provider: key.provider,
40
+ type: key.type,
41
+ tenantId: _nullishCoalesce(key.tenantId, () => ( _typeorm.IsNull.call(void 0, ))),
42
+ resolvedAt: _typeorm.IsNull.call(void 0, )
43
+ }
44
+ });
45
+ }
46
+ async create(input) {
47
+ return this.repo.save(
48
+ this.repo.create({
49
+ provider: input.provider,
50
+ type: input.type,
51
+ scope: input.scope,
52
+ tenantId: input.tenantId,
53
+ message: input.message,
54
+ details: input.details,
55
+ times: 1,
56
+ firstAt: input.at,
57
+ lastAt: input.at,
58
+ notifiedAt: null,
59
+ resolvedAt: null
60
+ })
61
+ );
62
+ }
63
+ async touch(id, patch) {
64
+ const current = await this.repo.findOneByOrFail({ id });
65
+ await this.repo.createQueryBuilder().update().set({
66
+ times: () => "times + 1",
67
+ lastAt: patch.at,
68
+ message: patch.message,
69
+ details: { ...current.details, ..._nullishCoalesce(patch.details, () => ( {})) }
70
+ }).where("id = :id", { id }).execute();
71
+ return this.repo.findOneByOrFail({ id });
72
+ }
73
+ async markNotified(id, at) {
74
+ await this.repo.update({ id }, { notifiedAt: at });
75
+ }
76
+ async listOpen(filter = {}) {
77
+ return this.repo.find({
78
+ where: { resolvedAt: _typeorm.IsNull.call(void 0, ), ...filter },
79
+ order: { lastAt: "DESC" }
80
+ });
81
+ }
82
+ async resolve(ids, at) {
83
+ if (ids.length === 0) return;
84
+ await this.repo.createQueryBuilder().update().set({ resolvedAt: at }).where("id IN (:...ids) AND resolved_at IS NULL", { ids }).execute();
85
+ }
86
+ async list(opts) {
87
+ const limit = Math.min(_nullishCoalesce(opts.limit, () => ( 30)), 100);
88
+ const qb = this.repo.createQueryBuilder("a").orderBy("a.last_at", "DESC").limit(limit + 1);
89
+ if (opts.onlyOpen) qb.andWhere("a.resolved_at IS NULL");
90
+ if (opts.cursor) qb.andWhere("a.last_at < :c", { c: new Date(opts.cursor) });
91
+ const rows = await qb.getMany();
92
+ const more = rows.length > limit;
93
+ const items = more ? rows.slice(0, limit) : rows;
94
+ return { items, next: more ? items.at(-1).lastAt.toISOString() : null };
95
+ }
96
+ };
97
+ var typeOrmAlertStore = (options) => new TypeOrmAlertStore(options);
98
+
99
+
100
+
101
+
102
+ exports.TypeOrmAlertStore = TypeOrmAlertStore; exports.createAlertEntity = createAlertEntity; exports.typeOrmAlertStore = typeOrmAlertStore;
@@ -0,0 +1,3 @@
1
+ export { createAlertEntity } from './alert.entity.js';
2
+ export { TypeOrmAlertStore, typeOrmAlertStore } from './typeorm-alert-store.js';
3
+ export type { TypeOrmAlertStoreOptions } from './typeorm-alert-store.js';
@@ -0,0 +1,102 @@
1
+ import "../../chunk-D3DDJWUD.js";
2
+
3
+ // src/resilience/typeorm/alert.entity.ts
4
+ import { EntitySchema } from "typeorm";
5
+ function createAlertEntity(tableName = "system_alert") {
6
+ return new EntitySchema({
7
+ name: `Alert_${tableName}`,
8
+ tableName,
9
+ columns: {
10
+ id: { type: "uuid", primary: true, generated: "uuid" },
11
+ provider: { type: "text" },
12
+ type: { type: "text" },
13
+ scope: { type: "text", default: "platform" },
14
+ tenantId: { name: "tenant_id", type: "uuid", nullable: true },
15
+ message: { type: "text" },
16
+ details: { type: "jsonb", default: () => "'{}'" },
17
+ times: { type: "int", default: 1 },
18
+ firstAt: { name: "first_at", type: "timestamptz" },
19
+ lastAt: { name: "last_at", type: "timestamptz" },
20
+ notifiedAt: { name: "notified_at", type: "timestamptz", nullable: true },
21
+ resolvedAt: { name: "resolved_at", type: "timestamptz", nullable: true }
22
+ }
23
+ });
24
+ }
25
+
26
+ // src/resilience/typeorm/typeorm-alert-store.ts
27
+ import { IsNull } from "typeorm";
28
+ var TypeOrmAlertStore = class {
29
+ constructor(options) {
30
+ this.ds = options.dataSource;
31
+ this.entity = options.entity ?? createAlertEntity(options.nombreTabla);
32
+ }
33
+ get repo() {
34
+ return this.ds.getRepository(this.entity);
35
+ }
36
+ async findOpen(key) {
37
+ return this.repo.findOne({
38
+ where: {
39
+ provider: key.provider,
40
+ type: key.type,
41
+ tenantId: key.tenantId ?? IsNull(),
42
+ resolvedAt: IsNull()
43
+ }
44
+ });
45
+ }
46
+ async create(input) {
47
+ return this.repo.save(
48
+ this.repo.create({
49
+ provider: input.provider,
50
+ type: input.type,
51
+ scope: input.scope,
52
+ tenantId: input.tenantId,
53
+ message: input.message,
54
+ details: input.details,
55
+ times: 1,
56
+ firstAt: input.at,
57
+ lastAt: input.at,
58
+ notifiedAt: null,
59
+ resolvedAt: null
60
+ })
61
+ );
62
+ }
63
+ async touch(id, patch) {
64
+ const current = await this.repo.findOneByOrFail({ id });
65
+ await this.repo.createQueryBuilder().update().set({
66
+ times: () => "times + 1",
67
+ lastAt: patch.at,
68
+ message: patch.message,
69
+ details: { ...current.details, ...patch.details ?? {} }
70
+ }).where("id = :id", { id }).execute();
71
+ return this.repo.findOneByOrFail({ id });
72
+ }
73
+ async markNotified(id, at) {
74
+ await this.repo.update({ id }, { notifiedAt: at });
75
+ }
76
+ async listOpen(filter = {}) {
77
+ return this.repo.find({
78
+ where: { resolvedAt: IsNull(), ...filter },
79
+ order: { lastAt: "DESC" }
80
+ });
81
+ }
82
+ async resolve(ids, at) {
83
+ if (ids.length === 0) return;
84
+ await this.repo.createQueryBuilder().update().set({ resolvedAt: at }).where("id IN (:...ids) AND resolved_at IS NULL", { ids }).execute();
85
+ }
86
+ async list(opts) {
87
+ const limit = Math.min(opts.limit ?? 30, 100);
88
+ const qb = this.repo.createQueryBuilder("a").orderBy("a.last_at", "DESC").limit(limit + 1);
89
+ if (opts.onlyOpen) qb.andWhere("a.resolved_at IS NULL");
90
+ if (opts.cursor) qb.andWhere("a.last_at < :c", { c: new Date(opts.cursor) });
91
+ const rows = await qb.getMany();
92
+ const more = rows.length > limit;
93
+ const items = more ? rows.slice(0, limit) : rows;
94
+ return { items, next: more ? items.at(-1).lastAt.toISOString() : null };
95
+ }
96
+ };
97
+ var typeOrmAlertStore = (options) => new TypeOrmAlertStore(options);
98
+ export {
99
+ TypeOrmAlertStore,
100
+ createAlertEntity,
101
+ typeOrmAlertStore
102
+ };
@@ -0,0 +1,39 @@
1
+ import { type DataSource, type EntitySchema } from 'typeorm';
2
+ import type { AlertKey, AlertRecord, AlertStore, NewAlertRecord } from '../resilience.types.js';
3
+ export interface TypeOrmAlertStoreOptions {
4
+ dataSource: DataSource;
5
+ /** Nombre de la tabla. Por defecto `system_alert`. Ignorado si pasas `entity`. */
6
+ nombreTabla?: string;
7
+ /** Entidad ya creada con {@link createAlertEntity} (la misma que registraste en el DataSource). */
8
+ entity?: EntitySchema<AlertRecord>;
9
+ }
10
+ /** Alertas en Postgres vía TypeORM. `touch` incrementa `times` con un UPDATE atómico. */
11
+ export declare class TypeOrmAlertStore implements AlertStore {
12
+ private readonly entity;
13
+ private readonly ds;
14
+ constructor(options: TypeOrmAlertStoreOptions);
15
+ private get repo();
16
+ findOpen(key: AlertKey): Promise<AlertRecord | null>;
17
+ create(input: NewAlertRecord): Promise<AlertRecord>;
18
+ touch(id: string, patch: {
19
+ message: string;
20
+ details?: Record<string, unknown>;
21
+ at: Date;
22
+ }): Promise<AlertRecord>;
23
+ markNotified(id: string, at: Date): Promise<void>;
24
+ listOpen(filter?: {
25
+ provider?: string;
26
+ tenantId?: string;
27
+ }): Promise<AlertRecord[]>;
28
+ resolve(ids: string[], at: Date): Promise<void>;
29
+ list(opts: {
30
+ onlyOpen: boolean;
31
+ cursor?: string;
32
+ limit?: number;
33
+ }): Promise<{
34
+ items: AlertRecord[];
35
+ next: string | null;
36
+ }>;
37
+ }
38
+ /** Atajo: `alertas: { almacen: typeOrmAlertStore({ dataSource, nombreTabla: 'alerta_sistema' }) }`. */
39
+ export declare const typeOrmAlertStore: (options: TypeOrmAlertStoreOptions) => TypeOrmAlertStore;