@abyss-project/probe 2.0.0 → 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 (90) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +22 -22
  4. package/dist/api/index.d.ts +2 -1
  5. package/dist/api/index.js +2 -1
  6. package/dist/api/index.js.map +1 -1
  7. package/dist/api/probe-delivery-subscription.api.d.ts +11 -0
  8. package/dist/api/probe-delivery-subscription.api.js +42 -0
  9. package/dist/api/probe-delivery-subscription.api.js.map +1 -0
  10. package/dist/api/probe-delivery-subscription.application.api.d.ts +11 -0
  11. package/dist/api/probe-delivery-subscription.application.api.js +38 -0
  12. package/dist/api/probe-delivery-subscription.application.api.js.map +1 -0
  13. package/dist/api/probe-webhook.application.api.d.ts +1 -1
  14. package/dist/api/probe-webhook.application.api.js.map +1 -1
  15. package/dist/index.d.ts +29 -7
  16. package/dist/index.js +29 -7
  17. package/dist/index.js.map +1 -1
  18. package/dist/types/enum/api-error.enum.d.ts +2 -1
  19. package/dist/types/enum/api-error.enum.js +1 -0
  20. package/dist/types/enum/api-error.enum.js.map +1 -1
  21. package/dist/types/enum/probe-scan.enum.js.map +1 -1
  22. package/dist/types/interface/api/requests/index.d.ts +1 -0
  23. package/dist/types/interface/api/requests/index.js +1 -0
  24. package/dist/types/interface/api/requests/index.js.map +1 -1
  25. package/dist/types/interface/api/requests/probe-delivery-subscription.request.d.ts +23 -0
  26. package/dist/types/interface/api/requests/probe-delivery-subscription.request.js +3 -0
  27. package/dist/types/interface/api/requests/probe-delivery-subscription.request.js.map +1 -0
  28. package/dist/types/interface/api/requests/probe-webhook.request.d.ts +1 -4
  29. package/dist/types/interface/api/responses/index.d.ts +1 -0
  30. package/dist/types/interface/api/responses/index.js +1 -0
  31. package/dist/types/interface/api/responses/index.js.map +1 -1
  32. package/dist/types/interface/api/responses/probe-delivery-subscription.response.d.ts +10 -0
  33. package/dist/types/interface/api/responses/probe-delivery-subscription.response.js +3 -0
  34. package/dist/types/interface/api/responses/probe-delivery-subscription.response.js.map +1 -0
  35. package/dist/types/tests/probe.dto.test.js +22 -0
  36. package/dist/types/tests/probe.dto.test.js.map +1 -1
  37. package/dist/utils/probe-webhook-signature.utils.js.map +1 -1
  38. package/package.json +19 -15
  39. package/src/api/index.ts +2 -1
  40. package/src/api/probe-delivery-subscription.api.ts +183 -0
  41. package/src/api/probe-delivery-subscription.application.api.ts +186 -0
  42. package/src/api/probe-scan.api.test.ts +47 -47
  43. package/src/api/probe-scan.api.ts +203 -203
  44. package/src/api/probe-scan.application.api.test.ts +35 -35
  45. package/src/api/probe-scan.application.api.ts +157 -157
  46. package/src/api/probe-usage.api.ts +47 -47
  47. package/src/api/probe-usage.application.api.ts +25 -25
  48. package/src/api/probe-webhook.application.api.test.ts +18 -18
  49. package/src/api/probe-webhook.application.api.ts +10 -23
  50. package/src/constants/index.ts +1 -1
  51. package/src/index.ts +73 -16
  52. package/src/types/enum/api-error.enum.ts +2 -0
  53. package/src/types/enum/index.ts +2 -2
  54. package/src/types/enum/probe-scan.enum.ts +3 -2
  55. package/src/types/index.ts +2 -2
  56. package/src/types/interface/api/index.ts +5 -5
  57. package/src/types/interface/api/requests/index.ts +1 -0
  58. package/src/types/interface/api/requests/probe-delivery-subscription.request.ts +42 -0
  59. package/src/types/interface/api/requests/probe-scan.request.ts +54 -54
  60. package/src/types/interface/api/requests/probe-usage.request.ts +7 -7
  61. package/src/types/interface/api/requests/probe-webhook.request.ts +9 -11
  62. package/src/types/interface/api/responses/index.ts +1 -0
  63. package/src/types/interface/api/responses/probe-delivery-subscription.response.ts +27 -0
  64. package/src/types/interface/api/responses/probe-scan.response.ts +45 -45
  65. package/src/types/interface/api/responses/probe-usage.response.ts +25 -25
  66. package/src/types/interface/api/responses/probe-webhook.response.ts +24 -24
  67. package/src/types/interface/api/type-message/api-error.ts +7 -7
  68. package/src/types/interface/api/type-message/base-paginate.ts +11 -11
  69. package/src/types/interface/api/type-message/response.ts +6 -6
  70. package/src/types/interface/index.ts +2 -2
  71. package/src/types/interface/models/index.ts +3 -3
  72. package/src/types/interface/models/probe-scan.dto.ts +67 -67
  73. package/src/types/interface/models/probe-webhook-delivery.dto.ts +11 -14
  74. package/src/types/interface/models/probe-webhook.dto.ts +29 -29
  75. package/src/types/tests/probe.dto.test.ts +40 -4
  76. package/src/utils/enum.utils.ts +1 -1
  77. package/src/utils/error.utils.ts +30 -30
  78. package/src/utils/index.ts +4 -4
  79. package/src/utils/probe-scan-cost.utils.ts +101 -101
  80. package/src/utils/probe-webhook-signature.utils.ts +4 -3
  81. package/tsconfig.check.json +15 -15
  82. package/tsconfig.json +36 -36
  83. package/dist/api/probe-webhook.api.d.ts +0 -6
  84. package/dist/api/probe-webhook.api.js +0 -41
  85. package/dist/api/probe-webhook.api.js.map +0 -1
  86. package/dist/api/probe-webhook.api.test.d.ts +0 -1
  87. package/dist/api/probe-webhook.api.test.js +0 -43
  88. package/dist/api/probe-webhook.api.test.js.map +0 -1
  89. package/src/api/probe-webhook.api.test.ts +0 -17
  90. package/src/api/probe-webhook.api.ts +0 -119
@@ -1,101 +1,101 @@
1
- // ──────────────────────────────────────────────
2
- // AbyssProbe scan cost model — pure, shared (client + server, no endpoint).
3
- //
4
- // Ported from abyss-storage's OWN weighted AV-scan cost model
5
- // (`apps/api/src/services/av-scan-usage.ts#computeAvScanCost`, introduced in
6
- // storage commit 317e4a0 "wire the weighted AV-scan quota", since made dead
7
- // code there by the AV v3 Phase 3b-2 hand-off — "storage never bills —
8
- // AbyssProbe does" — but the FORMULA itself is exactly what AbyssProbe's own
9
- // weighted billing needs, so it is ported here verbatim rather than
10
- // reinvented):
11
- //
12
- // cost = round( (BASE + K_MB * ceil(sizeOctet / 1 MiB)) * MODE_WEIGHT[mode] )
13
- //
14
- // ASYNC costs LESS than SYNC (MODE_WEIGHT.async=1 < MODE_WEIGHT.sync=3) — a
15
- // synchronous scan holds the caller's request (and an engine worker) until
16
- // the verdict and cannot be batched/load-balanced, so it costs more than an
17
- // asynchronous (queued) scan of the SAME bytes. This is the numeric backing
18
- // for the scanner UI's "l'analyse en arrière-plan économise des tokens"
19
- // tooltip (WS1).
20
- //
21
- // PURE + DETERMINISTIC + no I/O: this is the SINGLE source of truth for
22
- // AbyssProbe's scan cost, used on BOTH sides of the wire —
23
- // - server (apps/api/src/services/probe-scan.service.ts): the REAL cost
24
- // billed via recordProbeScanUsage and persisted on probe_scans.costUnits
25
- // once a scan reaches a verdict (DONE).
26
- // - client (the AbyssProbe UI, or any external caller): a cost PREVIEW
27
- // before scanning — call this with the picked file's size and the
28
- // intended mode to show the estimated token cost, matching exactly what
29
- // the server will bill (no separate "estimate" formula to drift out of
30
- // sync with the real one — same function, same constants, both sides).
31
- //
32
- // Deliberately NOT exposed as an HTTP endpoint (no `POST /scan/estimate`):
33
- // the whole point of a pure function is that the client can compute it
34
- // locally, instantly, with zero round-trip — see this package's root README
35
- // note on `sdk.probe.*`'s HTTP-call-only convention; a helper like this one
36
- // (and `verifyProbeWebhookSignature` before it) is instead a plain top-level
37
- // export, not a `sdk.probe.*` method.
38
- // ──────────────────────────────────────────────
39
-
40
- import { ProbeScanMode } from '../types';
41
-
42
- /** Flat floor every scanned file pays (the "one scan" cost). Tunable. */
43
- export const PROBE_SCAN_COST_BASE = 1;
44
-
45
- /** Additional units per (ceil'd) mebibyte of scanned bytes. Tunable. */
46
- export const PROBE_SCAN_COST_K_MB = 1;
47
-
48
- /**
49
- * Per-mode cost multiplier. A synchronous scan blocks the caller's request
50
- * (and an engine worker) until the verdict and cannot be queued/batched, so
51
- * it costs strictly MORE than an asynchronous scan of the same bytes —
52
- * ASYNC < SYNC is a load-bearing invariant relied on by the scanner UI's
53
- * "background analysis saves tokens" messaging (WS1). Tunable, but this
54
- * ordering must never be inverted.
55
- */
56
- export const PROBE_SCAN_COST_MODE_WEIGHT: Record<ProbeScanMode, number> = {
57
- [ProbeScanMode.ASYNC]: 1,
58
- [ProbeScanMode.SYNC]: 3,
59
- };
60
-
61
- /** One mebibyte, the unit the per-MB term is quantised to. */
62
- const ONE_MB = 1024 * 1024;
63
-
64
- /**
65
- * Weighted cost of one AbyssProbe scan, in `ACCOUNT_AV_SCAN_UNITS` ("tokens"
66
- * in the UI). Pure + deterministic — same inputs always produce the same
67
- * output, no I/O, safe to call from a browser or a server.
68
- *
69
- * Returns `0` for a non-finite / non-positive `sizeOctet` (nothing to scan,
70
- * nothing to bill) rather than throwing — a defensive, never-crash contract
71
- * appropriate for a client-side cost preview that might run ahead of full
72
- * input validation (e.g. while a file is still being selected).
73
- *
74
- * `mode` defaults to the (cheaper) ASYNC weight when given an unrecognised
75
- * value, mirroring the ported formula's own `MODE_WEIGHT[mode] ?? MODE_WEIGHT.async`
76
- * fallback — never silently the MORE expensive weight.
77
- *
78
- * `mode`'s type is widened to `| 'sync' | 'async'` alongside the enum
79
- * itself, NOT just `ProbeScanMode`: apps/api's own server-side
80
- * `database/probe-scan.enum.ts#ProbeScanMode` is a SEPARATE TypeScript enum
81
- * declaration (kept server-local — see that file's header comment on why —
82
- * with the identical 'sync'/'async' runtime values, so the wire format never
83
- * drifts). TypeScript string enums are nominal: a same-valued member of that
84
- * OTHER enum is not directly assignable to THIS package's `ProbeScanMode`
85
- * parameter type, but IS assignable to a plain string-literal type matching
86
- * its value — so the server can call this exact function (`scan.mode`,
87
- * `estimateProbeScanCost`'s whole reason for living being ONE shared formula
88
- * on both sides of the wire, see this file's header comment) without a cast.
89
- */
90
- export const estimateProbeScanCost = (
91
- sizeOctet: number,
92
- mode: ProbeScanMode | 'sync' | 'async',
93
- ): number => {
94
- if (!Number.isFinite(sizeOctet) || sizeOctet <= 0) {
95
- return 0;
96
- }
97
- const megabytes = Math.ceil(sizeOctet / ONE_MB);
98
- const weight =
99
- PROBE_SCAN_COST_MODE_WEIGHT[mode] ?? PROBE_SCAN_COST_MODE_WEIGHT[ProbeScanMode.ASYNC];
100
- return Math.round((PROBE_SCAN_COST_BASE + PROBE_SCAN_COST_K_MB * megabytes) * weight);
101
- };
1
+ // ──────────────────────────────────────────────
2
+ // AbyssProbe scan cost model — pure, shared (client + server, no endpoint).
3
+ //
4
+ // Ported from abyss-storage's OWN weighted AV-scan cost model
5
+ // (`apps/api/src/services/av-scan-usage.ts#computeAvScanCost`, introduced in
6
+ // storage commit 317e4a0 "wire the weighted AV-scan quota", since made dead
7
+ // code there by the AV v3 Phase 3b-2 hand-off — "storage never bills —
8
+ // AbyssProbe does" — but the FORMULA itself is exactly what AbyssProbe's own
9
+ // weighted billing needs, so it is ported here verbatim rather than
10
+ // reinvented):
11
+ //
12
+ // cost = round( (BASE + K_MB * ceil(sizeOctet / 1 MiB)) * MODE_WEIGHT[mode] )
13
+ //
14
+ // ASYNC costs LESS than SYNC (MODE_WEIGHT.async=1 < MODE_WEIGHT.sync=3) — a
15
+ // synchronous scan holds the caller's request (and an engine worker) until
16
+ // the verdict and cannot be batched/load-balanced, so it costs more than an
17
+ // asynchronous (queued) scan of the SAME bytes. This is the numeric backing
18
+ // for the scanner UI's "l'analyse en arrière-plan économise des tokens"
19
+ // tooltip (WS1).
20
+ //
21
+ // PURE + DETERMINISTIC + no I/O: this is the SINGLE source of truth for
22
+ // AbyssProbe's scan cost, used on BOTH sides of the wire —
23
+ // - server (apps/api/src/services/probe-scan.service.ts): the REAL cost
24
+ // billed via recordProbeScanUsage and persisted on probe_scans.costUnits
25
+ // once a scan reaches a verdict (DONE).
26
+ // - client (the AbyssProbe UI, or any external caller): a cost PREVIEW
27
+ // before scanning — call this with the picked file's size and the
28
+ // intended mode to show the estimated token cost, matching exactly what
29
+ // the server will bill (no separate "estimate" formula to drift out of
30
+ // sync with the real one — same function, same constants, both sides).
31
+ //
32
+ // Deliberately NOT exposed as an HTTP endpoint (no `POST /scan/estimate`):
33
+ // the whole point of a pure function is that the client can compute it
34
+ // locally, instantly, with zero round-trip — see this package's root README
35
+ // note on `sdk.probe.*`'s HTTP-call-only convention; a helper like this one
36
+ // (and `verifyProbeWebhookSignature` before it) is instead a plain top-level
37
+ // export, not a `sdk.probe.*` method.
38
+ // ──────────────────────────────────────────────
39
+
40
+ import { ProbeScanMode } from '../types';
41
+
42
+ /** Flat floor every scanned file pays (the "one scan" cost). Tunable. */
43
+ export const PROBE_SCAN_COST_BASE = 1;
44
+
45
+ /** Additional units per (ceil'd) mebibyte of scanned bytes. Tunable. */
46
+ export const PROBE_SCAN_COST_K_MB = 1;
47
+
48
+ /**
49
+ * Per-mode cost multiplier. A synchronous scan blocks the caller's request
50
+ * (and an engine worker) until the verdict and cannot be queued/batched, so
51
+ * it costs strictly MORE than an asynchronous scan of the same bytes —
52
+ * ASYNC < SYNC is a load-bearing invariant relied on by the scanner UI's
53
+ * "background analysis saves tokens" messaging (WS1). Tunable, but this
54
+ * ordering must never be inverted.
55
+ */
56
+ export const PROBE_SCAN_COST_MODE_WEIGHT: Record<ProbeScanMode, number> = {
57
+ [ProbeScanMode.ASYNC]: 1,
58
+ [ProbeScanMode.SYNC]: 3,
59
+ };
60
+
61
+ /** One mebibyte, the unit the per-MB term is quantised to. */
62
+ const ONE_MB = 1024 * 1024;
63
+
64
+ /**
65
+ * Weighted cost of one AbyssProbe scan, in `ACCOUNT_AV_SCAN_UNITS` ("tokens"
66
+ * in the UI). Pure + deterministic — same inputs always produce the same
67
+ * output, no I/O, safe to call from a browser or a server.
68
+ *
69
+ * Returns `0` for a non-finite / non-positive `sizeOctet` (nothing to scan,
70
+ * nothing to bill) rather than throwing — a defensive, never-crash contract
71
+ * appropriate for a client-side cost preview that might run ahead of full
72
+ * input validation (e.g. while a file is still being selected).
73
+ *
74
+ * `mode` defaults to the (cheaper) ASYNC weight when given an unrecognised
75
+ * value, mirroring the ported formula's own `MODE_WEIGHT[mode] ?? MODE_WEIGHT.async`
76
+ * fallback — never silently the MORE expensive weight.
77
+ *
78
+ * `mode`'s type is widened to `| 'sync' | 'async'` alongside the enum
79
+ * itself, NOT just `ProbeScanMode`: apps/api's own server-side
80
+ * `database/probe-scan.enum.ts#ProbeScanMode` is a SEPARATE TypeScript enum
81
+ * declaration (kept server-local — see that file's header comment on why —
82
+ * with the identical 'sync'/'async' runtime values, so the wire format never
83
+ * drifts). TypeScript string enums are nominal: a same-valued member of that
84
+ * OTHER enum is not directly assignable to THIS package's `ProbeScanMode`
85
+ * parameter type, but IS assignable to a plain string-literal type matching
86
+ * its value — so the server can call this exact function (`scan.mode`,
87
+ * `estimateProbeScanCost`'s whole reason for living being ONE shared formula
88
+ * on both sides of the wire, see this file's header comment) without a cast.
89
+ */
90
+ export const estimateProbeScanCost = (
91
+ sizeOctet: number,
92
+ mode: ProbeScanMode | 'sync' | 'async',
93
+ ): number => {
94
+ if (!Number.isFinite(sizeOctet) || sizeOctet <= 0) {
95
+ return 0;
96
+ }
97
+ const megabytes = Math.ceil(sizeOctet / ONE_MB);
98
+ const weight =
99
+ PROBE_SCAN_COST_MODE_WEIGHT[mode] ?? PROBE_SCAN_COST_MODE_WEIGHT[ProbeScanMode.ASYNC];
100
+ return Math.round((PROBE_SCAN_COST_BASE + PROBE_SCAN_COST_K_MB * megabytes) * weight);
101
+ };
@@ -1,7 +1,8 @@
1
1
  // ──────────────────────────────────────────────
2
- // AbyssProbe webhook signature verification (helper for RECEIVERS of a
3
- // webhook delivery — the abyss-main UI/abyss-storage/any external
4
- // integrator that registered a callbackUrl).
2
+ // AbyssProbe webhook signature verification (helper for the RECEIVER of the
3
+ // internal webhook — AbyssStorage's antivirus subscription — until its client
4
+ // subscriptions move to Flow, P5 #792 L2). A client's own subscription is
5
+ // signed by Flow, whose helper verifies it.
5
6
  //
6
7
  // Mirrors this package's own extraction-webhook.utils.ts
7
8
  // (verifyExtractionWebhook) — the same package's own precedent for this
@@ -1,15 +1,15 @@
1
- {
2
- // Perimetre de VERIFICATION, distinct de celui du build.
3
- //
4
- // `tsconfig.json` exclut `src/**/*.spec.ts` parce qu'il sert a emettre `dist/`, ou une spec
5
- // n'a rien a faire. Mais eslint s'appuie sur ce meme fichier via `parserOptions.project` :
6
- // les cinq specs du paquet sortaient donc en « Parsing error: that TSConfig does not include
7
- // this file », mesure du 2026-09-09, et n'etaient lintees par personne.
8
- //
9
- // Ce fichier sert uniquement a eslint. Il n'emet rien et ne change pas ce que `build` produit.
10
- "extends": "./tsconfig.json",
11
- "compilerOptions": {
12
- "noEmit": true
13
- },
14
- "exclude": ["./dist/**/*"]
15
- }
1
+ {
2
+ // Perimetre de VERIFICATION, distinct de celui du build.
3
+ //
4
+ // `tsconfig.json` exclut `src/**/*.spec.ts` parce qu'il sert a emettre `dist/`, ou une spec
5
+ // n'a rien a faire. Mais eslint s'appuie sur ce meme fichier via `parserOptions.project` :
6
+ // les cinq specs du paquet sortaient donc en « Parsing error: that TSConfig does not include
7
+ // this file », mesure du 2026-09-09, et n'etaient lintees par personne.
8
+ //
9
+ // Ce fichier sert uniquement a eslint. Il n'emet rien et ne change pas ce que `build` produit.
10
+ "extends": "./tsconfig.json",
11
+ "compilerOptions": {
12
+ "noEmit": true
13
+ },
14
+ "exclude": ["./dist/**/*"]
15
+ }
package/tsconfig.json CHANGED
@@ -1,36 +1,36 @@
1
- {
2
- "compilerOptions": {
3
- "incremental": false,
4
- "target": "es2021",
5
- "lib": [
6
- "dom",
7
- "es2021"
8
- ],
9
- "experimentalDecorators": true,
10
- "emitDecoratorMetadata": true,
11
- "module": "commonjs",
12
- "rootDir": "src",
13
- "moduleResolution": "node",
14
- "resolveJsonModule": true,
15
- "allowJs": true,
16
- "declaration": true,
17
- "sourceMap": true,
18
- "outDir": "./dist",
19
- "removeComments": true,
20
- "allowSyntheticDefaultImports": true,
21
- "esModuleInterop": true,
22
- "forceConsistentCasingInFileNames": true,
23
- "strict": true,
24
- "strictNullChecks": true,
25
- "strictFunctionTypes": true,
26
- "strictPropertyInitialization": false,
27
- "skipLibCheck": true
28
- },
29
- "include": [
30
- "./src"
31
- ],
32
- "exclude": [
33
- "./dist/**/*",
34
- "./src/**/*.spec.ts"
35
- ]
36
- }
1
+ {
2
+ "compilerOptions": {
3
+ "incremental": false,
4
+ "target": "es2021",
5
+ "lib": [
6
+ "dom",
7
+ "es2021"
8
+ ],
9
+ "experimentalDecorators": true,
10
+ "emitDecoratorMetadata": true,
11
+ "module": "commonjs",
12
+ "rootDir": "src",
13
+ "moduleResolution": "node",
14
+ "resolveJsonModule": true,
15
+ "allowJs": true,
16
+ "declaration": true,
17
+ "sourceMap": true,
18
+ "outDir": "./dist",
19
+ "removeComments": true,
20
+ "allowSyntheticDefaultImports": true,
21
+ "esModuleInterop": true,
22
+ "forceConsistentCasingInFileNames": true,
23
+ "strict": true,
24
+ "strictNullChecks": true,
25
+ "strictFunctionTypes": true,
26
+ "strictPropertyInitialization": false,
27
+ "skipLibCheck": true
28
+ },
29
+ "include": [
30
+ "./src"
31
+ ],
32
+ "exclude": [
33
+ "./dist/**/*",
34
+ "./src/**/*.spec.ts"
35
+ ]
36
+ }
@@ -1,6 +0,0 @@
1
- import type { ICreateProbeWebhookBody, IUpdateProbeWebhookBody, IProbeWebhookScopeQuery, IListProbeWebhookDeliveriesQuery, ICreateProbeWebhookResponse, IListProbeWebhookResponse, IDeleteProbeWebhookResponse, IUpdateProbeWebhookResponse, IListProbeWebhookDeliveriesResponse } from '../types';
2
- export declare const createProbeWebhook: (body: ICreateProbeWebhookBody, scope?: IProbeWebhookScopeQuery, apiKey?: string) => Promise<ICreateProbeWebhookResponse>;
3
- export declare const listProbeWebhook: (scope?: IProbeWebhookScopeQuery, apiKey?: string) => Promise<IListProbeWebhookResponse>;
4
- export declare const deleteProbeWebhook: (webhookId: string, scope?: IProbeWebhookScopeQuery, apiKey?: string) => Promise<IDeleteProbeWebhookResponse>;
5
- export declare const updateProbeWebhook: (webhookId: string, body: IUpdateProbeWebhookBody, scope?: IProbeWebhookScopeQuery, apiKey?: string) => Promise<IUpdateProbeWebhookResponse>;
6
- export declare const listProbeWebhookDeliveries: (webhookId: string, query?: IListProbeWebhookDeliveriesQuery, apiKey?: string) => Promise<IListProbeWebhookDeliveriesResponse>;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listProbeWebhookDeliveries = exports.updateProbeWebhook = exports.deleteProbeWebhook = exports.listProbeWebhook = exports.createProbeWebhook = void 0;
4
- const __1 = require("..");
5
- const DEFAULT_API_KEY_HEADER = 'abyss-api-key';
6
- function authHeader(apiKey) {
7
- return apiKey ? { [DEFAULT_API_KEY_HEADER]: apiKey } : {};
8
- }
9
- function serializeProbeQuery(query) {
10
- const out = {};
11
- for (const [key, value] of Object.entries(query)) {
12
- if (value === undefined || value === null)
13
- continue;
14
- const wireKey = key === 'organizationId' ? 'organization_id' : key;
15
- out[wireKey] = value instanceof Date ? value.toISOString() : value;
16
- }
17
- return out;
18
- }
19
- const createProbeWebhook = async (body, scope = {}, apiKey) => (await __1.AbyssProbeCore.axios.post('webhook', body, {
20
- params: serializeProbeQuery(scope),
21
- headers: authHeader(apiKey),
22
- })).data;
23
- exports.createProbeWebhook = createProbeWebhook;
24
- const listProbeWebhook = async (scope = {}, apiKey) => (await __1.AbyssProbeCore.axios.get('webhook', {
25
- params: serializeProbeQuery(scope),
26
- headers: authHeader(apiKey),
27
- })).data;
28
- exports.listProbeWebhook = listProbeWebhook;
29
- const deleteProbeWebhook = async (webhookId, scope = {}, apiKey) => (await __1.AbyssProbeCore.axios.delete(`webhook/${webhookId}`, {
30
- params: serializeProbeQuery(scope),
31
- headers: authHeader(apiKey),
32
- })).data;
33
- exports.deleteProbeWebhook = deleteProbeWebhook;
34
- const updateProbeWebhook = async (webhookId, body, scope = {}, apiKey) => (await __1.AbyssProbeCore.axios.patch(`webhook/${webhookId}`, body, {
35
- params: serializeProbeQuery(scope),
36
- headers: authHeader(apiKey),
37
- })).data;
38
- exports.updateProbeWebhook = updateProbeWebhook;
39
- const listProbeWebhookDeliveries = async (webhookId, query = {}, apiKey) => (await __1.AbyssProbeCore.axios.get(`webhook/${webhookId}/deliveries`, { params: serializeProbeQuery(query), headers: authHeader(apiKey) })).data;
40
- exports.listProbeWebhookDeliveries = listProbeWebhookDeliveries;
41
- //# sourceMappingURL=probe-webhook.api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"probe-webhook.api.js","sourceRoot":"","sources":["../../src/api/probe-webhook.api.ts"],"names":[],"mappings":";;;AAaA,0BAAoC;AAapC,MAAM,sBAAsB,GAAG,eAAe,CAAC;AAE/C,SAAS,UAAU,CAAC,MAAe;IACjC,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5D,CAAC;AAGD,SAAS,mBAAmB,CAAmB,KAAQ;IACrD,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;QAC5E,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QACpD,MAAM,OAAO,GAAG,GAAG,KAAK,gBAAgB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC;QACnE,GAAG,CAAC,OAAO,CAAC,GAAG,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACrE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAOM,MAAM,kBAAkB,GAAG,KAAK,EACrC,IAA6B,EAC7B,QAAiC,EAAE,EACnC,MAAe,EACuB,EAAE,CACxC,CACE,MAAM,kBAAc,CAAC,KAAK,CAAC,IAAI,CAA8B,SAAS,EAAE,IAAI,EAAE;IAC5E,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC;IAClC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC;CAC5B,CAAC,CACH,CAAC,IAAI,CAAC;AAVI,QAAA,kBAAkB,sBAUtB;AAGF,MAAM,gBAAgB,GAAG,KAAK,EACnC,QAAiC,EAAE,EACnC,MAAe,EACqB,EAAE,CACtC,CACE,MAAM,kBAAc,CAAC,KAAK,CAAC,GAAG,CAA4B,SAAS,EAAE;IACnE,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC;IAClC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC;CAC5B,CAAC,CACH,CAAC,IAAI,CAAC;AATI,QAAA,gBAAgB,oBASpB;AAGF,MAAM,kBAAkB,GAAG,KAAK,EACrC,SAAiB,EACjB,QAAiC,EAAE,EACnC,MAAe,EACuB,EAAE,CACxC,CACE,MAAM,kBAAc,CAAC,KAAK,CAAC,MAAM,CAA8B,WAAW,SAAS,EAAE,EAAE;IACrF,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC;IAClC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC;CAC5B,CAAC,CACH,CAAC,IAAI,CAAC;AAVI,QAAA,kBAAkB,sBAUtB;AAQF,MAAM,kBAAkB,GAAG,KAAK,EACrC,SAAiB,EACjB,IAA6B,EAC7B,QAAiC,EAAE,EACnC,MAAe,EACuB,EAAE,CACxC,CACE,MAAM,kBAAc,CAAC,KAAK,CAAC,KAAK,CAA8B,WAAW,SAAS,EAAE,EAAE,IAAI,EAAE;IAC1F,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC;IAClC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC;CAC5B,CAAC,CACH,CAAC,IAAI,CAAC;AAXI,QAAA,kBAAkB,sBAWtB;AAMF,MAAM,0BAA0B,GAAG,KAAK,EAC7C,SAAiB,EACjB,QAA0C,EAAE,EAC5C,MAAe,EAC+B,EAAE,CAChD,CACE,MAAM,kBAAc,CAAC,KAAK,CAAC,GAAG,CAC5B,WAAW,SAAS,aAAa,EACjC,EAAE,MAAM,EAAE,mBAAmB,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,CACpE,CACF,CAAC,IAAI,CAAC;AAVI,QAAA,0BAA0B,8BAU9B"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- const api = __importStar(require("./probe-webhook.api"));
37
- const _create = api.createProbeWebhook;
38
- const _list = api.listProbeWebhook;
39
- const _delete = api.deleteProbeWebhook;
40
- void _create;
41
- void _list;
42
- void _delete;
43
- //# sourceMappingURL=probe-webhook.api.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"probe-webhook.api.test.js","sourceRoot":"","sources":["../../src/api/probe-webhook.api.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,yDAA2C;AAI3C,MAAM,OAAO,GAAkC,GAAG,CAAC,kBAAkB,CAAC;AACtE,MAAM,KAAK,GAAgC,GAAG,CAAC,gBAAgB,CAAC;AAChE,MAAM,OAAO,GAAkC,GAAG,CAAC,kBAAkB,CAAC;AAEtE,KAAK,OAAO,CAAC;AACb,KAAK,KAAK,CAAC;AACX,KAAK,OAAO,CAAC"}
@@ -1,17 +0,0 @@
1
- // Type-level compile test for the probe-webhook api surface.
2
- // No jest runner in this SDK package; compile guard only.
3
- // Run: npx tsc --noEmit (from packages/abyss_probe_core), or `npm run build`.
4
-
5
- import * as api from './probe-webhook.api';
6
-
7
- // All three functions must be exported — deliberately no update/reset-secret
8
- // (see probe-webhook.controller.ts's header comment on the small CRUD surface).
9
- const _create: typeof api.createProbeWebhook = api.createProbeWebhook;
10
- const _list: typeof api.listProbeWebhook = api.listProbeWebhook;
11
- const _delete: typeof api.deleteProbeWebhook = api.deleteProbeWebhook;
12
-
13
- void _create;
14
- void _list;
15
- void _delete;
16
-
17
- export {};
@@ -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;