@abyss-project/probe 2.0.1 → 3.0.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 (58) hide show
  1. package/dist/api/index.d.ts +2 -1
  2. package/dist/api/index.js +2 -1
  3. package/dist/api/index.js.map +1 -1
  4. package/dist/api/probe-delivery-subscription.api.d.ts +11 -0
  5. package/dist/api/probe-delivery-subscription.api.js +42 -0
  6. package/dist/api/probe-delivery-subscription.api.js.map +1 -0
  7. package/dist/api/probe-delivery-subscription.application.api.d.ts +11 -0
  8. package/dist/api/probe-delivery-subscription.application.api.js +38 -0
  9. package/dist/api/probe-delivery-subscription.application.api.js.map +1 -0
  10. package/dist/api/probe-webhook.application.api.d.ts +1 -1
  11. package/dist/api/probe-webhook.application.api.js.map +1 -1
  12. package/dist/index.d.ts +29 -7
  13. package/dist/index.js +29 -7
  14. package/dist/index.js.map +1 -1
  15. package/dist/types/enum/api-error.enum.d.ts +2 -1
  16. package/dist/types/enum/api-error.enum.js +1 -0
  17. package/dist/types/enum/api-error.enum.js.map +1 -1
  18. package/dist/types/enum/probe-scan.enum.js.map +1 -1
  19. package/dist/types/interface/api/requests/index.d.ts +1 -0
  20. package/dist/types/interface/api/requests/index.js +1 -0
  21. package/dist/types/interface/api/requests/index.js.map +1 -1
  22. package/dist/types/interface/api/requests/probe-delivery-subscription.request.d.ts +23 -0
  23. package/dist/types/interface/api/requests/probe-delivery-subscription.request.js +3 -0
  24. package/dist/types/interface/api/requests/probe-delivery-subscription.request.js.map +1 -0
  25. package/dist/types/interface/api/requests/probe-webhook.request.d.ts +1 -4
  26. package/dist/types/interface/api/responses/index.d.ts +1 -0
  27. package/dist/types/interface/api/responses/index.js +1 -0
  28. package/dist/types/interface/api/responses/index.js.map +1 -1
  29. package/dist/types/interface/api/responses/probe-delivery-subscription.response.d.ts +10 -0
  30. package/dist/types/interface/api/responses/probe-delivery-subscription.response.js +3 -0
  31. package/dist/types/interface/api/responses/probe-delivery-subscription.response.js.map +1 -0
  32. package/dist/types/tests/probe.dto.test.js +22 -0
  33. package/dist/types/tests/probe.dto.test.js.map +1 -1
  34. package/dist/utils/probe-webhook-signature.utils.js.map +1 -1
  35. package/package.json +10 -1
  36. package/src/api/index.ts +7 -6
  37. package/src/api/probe-delivery-subscription.api.ts +183 -0
  38. package/src/api/probe-delivery-subscription.application.api.ts +186 -0
  39. package/src/api/probe-webhook.application.api.ts +128 -141
  40. package/src/index.ts +262 -205
  41. package/src/types/enum/api-error.enum.ts +35 -33
  42. package/src/types/enum/probe-scan.enum.ts +45 -44
  43. package/src/types/interface/api/requests/index.ts +4 -3
  44. package/src/types/interface/api/requests/probe-delivery-subscription.request.ts +42 -0
  45. package/src/types/interface/api/requests/probe-webhook.request.ts +31 -33
  46. package/src/types/interface/api/responses/index.ts +4 -3
  47. package/src/types/interface/api/responses/probe-delivery-subscription.response.ts +27 -0
  48. package/src/types/interface/models/probe-webhook-delivery.dto.ts +70 -73
  49. package/src/types/tests/probe.dto.test.ts +192 -156
  50. package/src/utils/probe-webhook-signature.utils.ts +57 -56
  51. package/dist/api/probe-webhook.api.d.ts +0 -6
  52. package/dist/api/probe-webhook.api.js +0 -41
  53. package/dist/api/probe-webhook.api.js.map +0 -1
  54. package/dist/api/probe-webhook.api.test.d.ts +0 -1
  55. package/dist/api/probe-webhook.api.test.js +0 -43
  56. package/dist/api/probe-webhook.api.test.js.map +0 -1
  57. package/src/api/probe-webhook.api.test.ts +0 -17
  58. package/src/api/probe-webhook.api.ts +0 -119
@@ -1,119 +0,0 @@
1
- // ──────────────────────────────────────────────
2
- // AbyssProbe webhook subscription API — CRUD over registered `probe_webhooks`
3
- // (create / list / delete / update, + paginated delivery history — mirrors
4
- // apps/api/src/api/controllers/probe-webhook.controller.ts EXACTLY, see that
5
- // file's header comment). No `probe/` path prefix — `@Controller({
6
- // prefixPath: '/webhook' })` mounts directly at `webhook`.
7
- //
8
- // See probe-webhook.application.api.ts for the application/API-key-auth
9
- // counterpart of this client (`/application/:applicationId/webhook...`,
10
- // Phase 3a) — it reuses every request/response type verbatim; only the URL
11
- // prefix, the extra `applicationId` argument, and the auth header differ.
12
- // ──────────────────────────────────────────────
13
-
14
- import { AbyssProbeCore } from '..';
15
- import type {
16
- ICreateProbeWebhookBody,
17
- IUpdateProbeWebhookBody,
18
- IProbeWebhookScopeQuery,
19
- IListProbeWebhookDeliveriesQuery,
20
- ICreateProbeWebhookResponse,
21
- IListProbeWebhookResponse,
22
- IDeleteProbeWebhookResponse,
23
- IUpdateProbeWebhookResponse,
24
- IListProbeWebhookDeliveriesResponse,
25
- } from '../types';
26
-
27
- const DEFAULT_API_KEY_HEADER = 'abyss-api-key';
28
-
29
- function authHeader(apiKey?: string): Record<string, string> {
30
- return apiKey ? { [DEFAULT_API_KEY_HEADER]: apiKey } : {};
31
- }
32
-
33
- /** Renames `organizationId` to the wire's `organization_id` (see probe-scan.api.ts). */
34
- function serializeProbeQuery<T extends object>(query: T): Record<string, unknown> {
35
- const out: Record<string, unknown> = {};
36
- for (const [key, value] of Object.entries(query as Record<string, unknown>)) {
37
- if (value === undefined || value === null) continue;
38
- const wireKey = key === 'organizationId' ? 'organization_id' : key;
39
- out[wireKey] = value instanceof Date ? value.toISOString() : value;
40
- }
41
- return out;
42
- }
43
-
44
- /**
45
- * `POST /webhook` — register a callbackUrl for the caller's scope. The
46
- * response's `secret` field (HMAC signing secret) is returned ONLY here —
47
- * store it immediately, it cannot be re-revealed later.
48
- */
49
- export const createProbeWebhook = async (
50
- body: ICreateProbeWebhookBody,
51
- scope: IProbeWebhookScopeQuery = {},
52
- apiKey?: string,
53
- ): Promise<ICreateProbeWebhookResponse> =>
54
- (
55
- await AbyssProbeCore.axios.post<ICreateProbeWebhookResponse>('webhook', body, {
56
- params: serializeProbeQuery(scope),
57
- headers: authHeader(apiKey),
58
- })
59
- ).data;
60
-
61
- /** `GET /webhook` — flat, scope-filtered list (not paginated — bounded by WEBHOOK_MAX_PER_SCOPE server-side). */
62
- export const listProbeWebhook = async (
63
- scope: IProbeWebhookScopeQuery = {},
64
- apiKey?: string,
65
- ): Promise<IListProbeWebhookResponse> =>
66
- (
67
- await AbyssProbeCore.axios.get<IListProbeWebhookResponse>('webhook', {
68
- params: serializeProbeQuery(scope),
69
- headers: authHeader(apiKey),
70
- })
71
- ).data;
72
-
73
- /** `DELETE /webhook/:webhookId`. */
74
- export const deleteProbeWebhook = async (
75
- webhookId: string,
76
- scope: IProbeWebhookScopeQuery = {},
77
- apiKey?: string,
78
- ): Promise<IDeleteProbeWebhookResponse> =>
79
- (
80
- await AbyssProbeCore.axios.delete<IDeleteProbeWebhookResponse>(`webhook/${webhookId}`, {
81
- params: serializeProbeQuery(scope),
82
- headers: authHeader(apiKey),
83
- })
84
- ).data;
85
-
86
- /**
87
- * `PATCH /webhook/:webhookId` (WS5-5) — edit `callbackUrl` and/or `active`.
88
- * At least one field is required. Scoped like {@link deleteProbeWebhook}
89
- * (404, never 403, for a webhookId outside the resolved scope). The response
90
- * includes `secret` — re-displayable now, see {@link IProbeWebhook}.
91
- */
92
- export const updateProbeWebhook = async (
93
- webhookId: string,
94
- body: IUpdateProbeWebhookBody,
95
- scope: IProbeWebhookScopeQuery = {},
96
- apiKey?: string,
97
- ): Promise<IUpdateProbeWebhookResponse> =>
98
- (
99
- await AbyssProbeCore.axios.patch<IUpdateProbeWebhookResponse>(`webhook/${webhookId}`, body, {
100
- params: serializeProbeQuery(scope),
101
- headers: authHeader(apiKey),
102
- })
103
- ).data;
104
-
105
- /**
106
- * `GET /webhook/:webhookId/deliveries` (WS5-6) — paginated delivery-attempt
107
- * history for one registered webhook. Scoped like {@link deleteProbeWebhook}.
108
- */
109
- export const listProbeWebhookDeliveries = async (
110
- webhookId: string,
111
- query: IListProbeWebhookDeliveriesQuery = {},
112
- apiKey?: string,
113
- ): Promise<IListProbeWebhookDeliveriesResponse> =>
114
- (
115
- await AbyssProbeCore.axios.get<IListProbeWebhookDeliveriesResponse>(
116
- `webhook/${webhookId}/deliveries`,
117
- { params: serializeProbeQuery(query), headers: authHeader(apiKey) },
118
- )
119
- ).data;