Rebuilds the qbit on QQQ 4.1.0-RC.4 per the assessment (QRun-IO/qqq#1105, decisions D1-D8): - webhooks_endpoint, webhooks_endpoint_secret, webhooks_subscription, webhooks_delivery and webhooks_delivery_attempt (snake_case, webhooks_ prefix), permissions webhooks.view / manage / admin - Standard Webhooks signing with per-endpoint secrets (AES-GCM or env references) and overlapping rotation - SSRF-safe client: private, loopback, link-local and metadata ranges blocked, DNS pinned, no redirects, timeouts, size cap, admin-only internal allowlist (shared/ is an internal copy of QRun-IO/qqq#1109, replaced at RC.5) - event sources: table insert/update/delete (record change listener), process completed/failed, ESB topics (own events skipped, CloudEvent id dedup), custom events and a channel API for other qbits - delivery: unique attempt-row claims with leases (no double sends across replicas), retries with backoff, Retry-After, dead letters and Replay, serial mode, per-endpoint rate limits, health with probation and auto-disable, alerts through the Alerts SPI when present, retention - subscriptions: record filters, record security, read permission check, detail levels, include and exclude fields, payload customizer hook - app home dashboard, actions with the standard review/result screens, ESB / Quick Search / API integration hooks - JaCoCo gate, Checkstyle in verify, Maven wrapper, default 4.1 profile, Postgres DDL in docs/ddl The 0.x sources stay in the tree, excluded from the build, until their removal is approved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
112 lines
4.2 KiB
Java
112 lines
4.2 KiB
Java
/*
|
|
* QQQ - Low-code Application Framework for Engineers.
|
|
* Copyright (C) 2021-2025. Kingsrook, LLC
|
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
|
* contact@kingsrook.com
|
|
* https://github.com/Kingsrook/
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.kingsrook.qbits.webhooks;
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import com.kingsrook.qbits.webhooks.metadata.WebhooksTables;
|
|
|
|
|
|
/*******************************************************************************
|
|
** What a host wires into its ESB, Quick Search and API, without this qbit
|
|
** depending on those modules (the same opt-in hooks as qbit-sql-workbench).
|
|
**
|
|
** <ul>
|
|
** <li>{@link #esbTableNames()}: publish these tables' inserts, updates and
|
|
** deletes to an ESB topic (the main tables).</li>
|
|
** <li>{@link #quickSearchTables()}: index these in Quick Search, with field
|
|
** weights.</li>
|
|
** <li>{@link #apiTableNames()}: expose these in the host's QQQ API. The API
|
|
** gets exactly the admin's rules: the same permissions, customizers and
|
|
** read-only tables.</li>
|
|
** </ul>
|
|
*******************************************************************************/
|
|
public final class WebhooksIntegrations
|
|
{
|
|
/*******************************************************************************
|
|
** A table for Quick Search: field weights, the timestamp for incremental
|
|
** indexing, and the record label.
|
|
*******************************************************************************/
|
|
public record SearchableTable(String tableName, Map<String, Integer> fieldWeights, String basepullTimestamp, String recordLabelFormat, List<String> recordLabelFields)
|
|
{
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
** Utility class.
|
|
*******************************************************************************/
|
|
private WebhooksIntegrations()
|
|
{
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
** Tables to publish on the ESB.
|
|
*******************************************************************************/
|
|
public static List<String> esbTableNames()
|
|
{
|
|
return (WebhooksTables.MAIN);
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
** Tables for the host's QQQ API.
|
|
*******************************************************************************/
|
|
public static List<String> apiTableNames()
|
|
{
|
|
return (WebhooksTables.MAIN);
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
** Tables for Quick Search.
|
|
*******************************************************************************/
|
|
public static List<SearchableTable> quickSearchTables()
|
|
{
|
|
Map<String, Integer> endpoint = new LinkedHashMap<>();
|
|
endpoint.put("name", 10);
|
|
endpoint.put("url", 6);
|
|
endpoint.put("description", 3);
|
|
|
|
Map<String, Integer> subscription = new LinkedHashMap<>();
|
|
subscription.put("eventTypeName", 8);
|
|
subscription.put("description", 4);
|
|
|
|
Map<String, Integer> delivery = new LinkedHashMap<>();
|
|
delivery.put("eventId", 10);
|
|
delivery.put("sourceEventId", 6);
|
|
delivery.put("eventTypeName", 5);
|
|
delivery.put("sourceRecordId", 4);
|
|
delivery.put("lastError", 2);
|
|
|
|
return (List.of(
|
|
new SearchableTable(WebhooksTables.ENDPOINT, endpoint, "modifyDate", "%s", List.of("name")),
|
|
new SearchableTable(WebhooksTables.SUBSCRIPTION, subscription, "modifyDate", "Subscription to %s", List.of("eventTypeName")),
|
|
new SearchableTable(WebhooksTables.DELIVERY, delivery, "modifyDate", "%s delivery %s", List.of("eventTypeName", "eventId"))));
|
|
}
|
|
}
|