@absolutejs/vulnerabilities-postgres 0.6.1 → 0.7.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.
package/dist/alerts.d.ts CHANGED
@@ -77,6 +77,8 @@ export declare class VulnerabilityAlertConflictError extends Error {
77
77
  }
78
78
  export declare class VulnerabilityAlertNotFoundError extends Error {
79
79
  }
80
+ export declare class VulnerabilityAlertValidationError extends Error {
81
+ }
80
82
  export type VulnerabilityAlertPolicyStore = {
81
83
  activate: (input: {
82
84
  activatedAt: string;
package/dist/index.js CHANGED
@@ -23,6 +23,9 @@ class VulnerabilityAlertConflictError extends Error {
23
23
 
24
24
  class VulnerabilityAlertNotFoundError extends Error {
25
25
  }
26
+
27
+ class VulnerabilityAlertValidationError extends Error {
28
+ }
26
29
  var IDENTIFIER = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
27
30
  var tables = (prefix) => ({
28
31
  deliveries: `${prefix}_alert_deliveries`,
@@ -150,10 +153,15 @@ var createPostgresVulnerabilityAlertStores = (options) => {
150
153
  const alertPolicies = {
151
154
  activate: async (input) => {
152
155
  await ready();
153
- const configuration = validateVulnerabilityAlertConfiguration(input.configuration);
156
+ let configuration;
157
+ try {
158
+ configuration = validateVulnerabilityAlertConfiguration(input.configuration);
159
+ } catch (error) {
160
+ throw new VulnerabilityAlertValidationError(error instanceof Error ? error.message : "Policy is invalid");
161
+ }
154
162
  const reason = input.reason.trim();
155
163
  if (!reason)
156
- throw new Error("Policy activation reason is required");
164
+ throw new VulnerabilityAlertValidationError("Policy activation reason is required");
157
165
  return transaction(sql, async (tx) => {
158
166
  await tx`SELECT pg_advisory_xact_lock(hashtext(${`vulnerability-alert-policy:${input.tenantId}`}))`;
159
167
  const [latest] = await tx`SELECT COALESCE(MAX(version), 0)::integer AS version FROM ${tx.unsafe(table.policies)} WHERE tenant_id = ${input.tenantId}`;
@@ -1299,6 +1307,7 @@ export {
1299
1307
  vulnerabilityAlertPostgresSchemaSql,
1300
1308
  createPostgresVulnerabilityStore,
1301
1309
  createPostgresVulnerabilityAlertStores,
1310
+ VulnerabilityAlertValidationError,
1302
1311
  VulnerabilityAlertNotFoundError,
1303
1312
  VulnerabilityAlertConflictError
1304
1313
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/vulnerabilities-postgres",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Durable Postgres feeds, findings, alert incidents, policy history, delivery queues, remediation evidence, and risk assessments for AbsoluteJS vulnerability management.",
5
5
  "type": "module",
6
6
  "license": "BSL-1.1",
@@ -53,7 +53,7 @@
53
53
  ],
54
54
  "dependencies": {
55
55
  "@absolutejs/manifest": "0.3.0",
56
- "@absolutejs/vulnerabilities": ">=0.10.0 <0.11.0",
56
+ "@absolutejs/vulnerabilities": ">=0.14.0 <0.15.0",
57
57
  "@sinclair/typebox": "0.34.52"
58
58
  },
59
59
  "peerDependencies": {