feat(events,drafts): give sources an immutable id and a scope (#2127, #2027)

A source is keyed by a uuid, owned by the organisation or one person, and
labelled within that scope. The webhook path is a separate unique column, so
renaming either leaves stored events, event types, triggers, groups, mappings
and drafts alone. Delivery policies, sealed secrets and group keys use the id.
This commit is contained in:
sam committed 2026-11-24 02:43:51 +11:00
1 parent 4a9f30ef04
commit 30aa351eb6
54 files changed
+1444 -682

No files matched your search

+249 -101
View File
@@ -997,12 +997,55 @@ components:
rule:
$ref: "#/components/schemas/EventtypeRule"
description: The conditions that identify the type; inferred from the example when absent
source:
source_id:
format: uuid
type: string
required:
- source
- source_id
- name
type: object
CreateSourceInputBody:
additionalProperties: false
properties:
connector:
description: The connector that parses this source's events
type: string
hmac_header:
description: The header that carries the signature (hmac only)
type: string
hmac_prefix:
description: Text before the hex digest in the signature header, such as sha256= (hmac only)
examples:
- sha256=
type: string
hmac_secret:
description: "The shared signing secret (hmac only). Write-only: it is sealed and never returned. When none is stored or sent, one is generated and returned once"
type: string
label:
description: The name people see, unique among the sources of the same owner
maxLength: 100
minLength: 1
type: string
scope:
description: "Who owns the source: the organisation (default) or the caller, who alone can see and use it"
enum:
- org
- person
type: string
verification:
description: "How deliveries are verified: a bearer token, an HMAC-SHA256 signature of the body, or no verification"
enum:
- token
- hmac
- none
type: string
webhook_path:
description: Lowercase letters, digits and hyphens; the webhook URL ends in it. Defaults to the label
type: string
required:
- label
- connector
type: object
CreateTokenInputBody:
additionalProperties: false
properties:
@@ -1123,8 +1166,10 @@ components:
filter: {}
source:
type: string
source_id:
type: string
required:
- source
- source_id
- event_type
- filter
type: object
@@ -1265,6 +1310,9 @@ components:
remote_addr:
type: string
source:
description: The source's label
type: string
source_id:
type: string
verification:
enum:
@@ -1276,7 +1324,6 @@ components:
required:
- id
- received_at
- source
- headers
- body
- verification
@@ -1348,9 +1395,13 @@ components:
type: string
type: object
source:
description: The source's label
type: string
source_id:
type: string
required:
- id
- source_id
- source
- name
- rule
@@ -1399,13 +1450,14 @@ components:
type: string
source:
type: string
source_id:
type: string
type:
type: string
verification:
type: string
required:
- id
- source
- type
- fields
- received_at
@@ -1460,7 +1512,9 @@ components:
- "null"
name:
type: string
source_hint:
source_id:
description: The source the mapping was made for, a hint only
format: uuid
type: string
required:
- name
@@ -1491,7 +1545,8 @@ components:
type: integer
name:
type: string
source_hint:
source_id:
description: The source the mapping was made for, a hint only
type: string
updated_at:
format: date-time
@@ -1499,7 +1554,6 @@ components:
required:
- id
- name
- source_hint
- event_type_id
- fields
- match_count
@@ -1529,10 +1583,14 @@ components:
type: string
filter: {}
source:
description: The source's label
type: string
source_id:
type: string
workflow:
type: string
required:
- source_id
- source
- event_type
- filter
@@ -1549,11 +1607,11 @@ components:
EventsSourceCreated:
additionalProperties: false
properties:
id:
type: string
secret:
description: A signing secret generated for an HMAC source, returned once
type: string
source:
type: string
token:
description: Returned once for a token source; only its hash is stored
type: string
@@ -1561,9 +1619,36 @@ components:
description: Where the sender posts its events
type: string
required:
- source
- id
- url
type: object
EventsSourceSettings:
additionalProperties: false
properties:
connector:
description: The connector that parses this source's events
type: string
hmac_header:
description: The header that carries the signature (hmac only)
type: string
hmac_prefix:
description: Text before the hex digest in the signature header, such as sha256= (hmac only)
examples:
- sha256=
type: string
hmac_secret:
description: "The shared signing secret (hmac only). Write-only: it is sealed and never returned. When none is stored or sent, one is generated and returned once"
type: string
verification:
description: "How deliveries are verified: a bearer token, an HMAC-SHA256 signature of the body, or no verification"
enum:
- token
- hmac
- none
type: string
required:
- connector
type: object
EventsSourceView:
additionalProperties: false
properties:
@@ -1573,21 +1658,26 @@ components:
type: string
delivery_header:
type: string
display_name:
type: string
hmac_header:
type: string
hmac_prefix:
type: string
hmac_secret_set:
type: boolean
id:
type: string
key_fields:
items:
type: string
type:
- array
- "null"
name:
label:
type: string
scope:
enum:
- org
- person
type: string
secret:
type: string
@@ -1602,8 +1692,13 @@ components:
type: boolean
verification:
type: string
webhook_path:
type: string
required:
- name
- id
- scope
- label
- webhook_path
- connector
- key_fields
- token_set
@@ -1660,6 +1755,8 @@ components:
type: string
source:
type: string
source_id:
type: string
status:
enum:
- pending_approval
@@ -1672,7 +1769,6 @@ components:
type: string
required:
- name
- source
- event_type
- filter
- workflow
@@ -1724,10 +1820,10 @@ components:
additionalProperties:
type: string
type: object
source:
source_id:
type: string
required:
- source
- source_id
- key
- schema
- headers
@@ -3203,33 +3299,6 @@ components:
- array
- "null"
type: object
PutSourceInputBody:
additionalProperties: false
properties:
connector:
description: The connector that parses this source's events
type: string
hmac_header:
description: The header that carries the signature (hmac only)
type: string
hmac_prefix:
description: Text before the hex digest in the signature header, such as sha256= (hmac only)
examples:
- sha256=
type: string
hmac_secret:
description: "The shared signing secret (hmac only). Write-only: it is sealed and never returned. When none is stored or sent, one is generated and returned once"
type: string
verification:
description: "How deliveries are verified: a bearer token, an HMAC-SHA256 signature of the body, or no verification"
enum:
- token
- hmac
- none
type: string
required:
- connector
type: object
PutTriggerInputBody:
additionalProperties: false
properties:
@@ -3259,8 +3328,9 @@ components:
pending:
description: Save the trigger waiting for approval; it fires once a person approves it
type: boolean
source:
description: The source whose events fire it; fixed when every is set
source_id:
description: The source whose events fire it; none when every is set
format: uuid
type: string
workflow:
description: The workflow each match runs
@@ -3527,12 +3597,15 @@ components:
type: string
source:
type: string
source_id:
type: string
trigger:
type: string
type:
type: string
required:
- event_id
- source_id
- source
- type
- fields
@@ -4045,14 +4118,16 @@ components:
required:
- signed
type: object
SourceNameInputBody:
SourceLabelInputBody:
additionalProperties: false
properties:
name:
label:
description: The name people see, unique among the sources of the same owner
maxLength: 100
minLength: 1
type: string
required:
- name
- label
type: object
SystemAdminToken:
additionalProperties: false
@@ -4229,6 +4304,15 @@ components:
- completion_tokens
- total_tokens
type: object
WebhookPathInputBody:
additionalProperties: false
properties:
path:
description: Lowercase letters, digits and hyphens; the webhook URL ends in it. Senders must post to the new address.
type: string
required:
- path
type: object
securitySchemes:
bearer:
description: A personal API token, or the bootstrap admin token
@@ -5928,8 +6012,9 @@ paths:
type: integer
- explode: false
in: query
name: source
name: source_id
schema:
format: uuid
type: string
- explode: false
in: query
@@ -8178,42 +8263,13 @@ paths:
summary: List sources
tags:
- Events
/api/sources/{name}:
delete:
operationId: delete-source
parameters:
- in: path
name: name
required: true
schema:
type: string
responses:
"204":
description: No Content
default:
content:
application/problem+json:
schema:
$ref: "#/components/schemas/ErrorModel"
description: Error
summary: Delete a source
tags:
- Events
put:
operationId: put-source
parameters:
- description: Lowercase letters, digits and hyphens; the webhook URL ends in it
in: path
name: name
required: true
schema:
description: Lowercase letters, digits and hyphens; the webhook URL ends in it
type: string
post:
operationId: create-source
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/PutSourceInputBody"
$ref: "#/components/schemas/CreateSourceInputBody"
required: true
responses:
"200":
@@ -8228,17 +8284,71 @@ paths:
schema:
$ref: "#/components/schemas/ErrorModel"
description: Error
summary: Add or update a source, its verification scheme and its token
summary: Add a source, owned by the organisation or by the caller
tags:
- Events
/api/sources/{name}/approve-unsigned:
/api/sources/{id}:
delete:
operationId: delete-source
parameters:
- in: path
name: id
required: true
schema:
format: uuid
type: string
responses:
"204":
description: No Content
default:
content:
application/problem+json:
schema:
$ref: "#/components/schemas/ErrorModel"
description: Error
summary: Delete a source
tags:
- Events
put:
operationId: update-source
parameters:
- in: path
name: id
required: true
schema:
format: uuid
type: string
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/EventsSourceSettings"
required: true
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/EventsSourceCreated"
description: OK
default:
content:
application/problem+json:
schema:
$ref: "#/components/schemas/ErrorModel"
description: Error
summary: Change a source's connector, verification scheme and token
tags:
- Events
/api/sources/{id}/approve-unsigned:
post:
operationId: approve-source-unsigned
parameters:
- in: path
name: name
name: id
required: true
schema:
format: uuid
type: string
responses:
"200":
@@ -8256,14 +8366,15 @@ paths:
summary: Accept deliveries that carry no signature
tags:
- Events
/api/sources/{name}/capture:
/api/sources/{id}/capture:
put:
operationId: set-source-capture
parameters:
- in: path
name: name
name: id
required: true
schema:
format: uuid
type: string
requestBody:
content:
@@ -8287,14 +8398,15 @@ paths:
summary: Keep or stop keeping the headers and payloads a source receives
tags:
- Events
/api/sources/{name}/delivery-header:
/api/sources/{id}/delivery-header:
put:
operationId: set-source-delivery-header
parameters:
- in: path
name: name
name: id
required: true
schema:
format: uuid
type: string
requestBody:
content:
@@ -8318,14 +8430,15 @@ paths:
summary: Name the header a sender repeats when it retries a delivery
tags:
- Events
/api/sources/{name}/key-fields:
/api/sources/{id}/key-fields:
put:
operationId: put-source-key-fields
parameters:
- in: path
name: name
name: id
required: true
schema:
format: uuid
type: string
requestBody:
content:
@@ -8349,20 +8462,21 @@ paths:
summary: Set the fields a source's events are grouped by
tags:
- Events
/api/sources/{name}/name:
/api/sources/{id}/label:
put:
operationId: set-source-name
operationId: set-source-label
parameters:
- in: path
name: name
name: id
required: true
schema:
format: uuid
type: string
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SourceNameInputBody"
$ref: "#/components/schemas/SourceLabelInputBody"
required: true
responses:
"200":
@@ -8377,17 +8491,18 @@ paths:
schema:
$ref: "#/components/schemas/ErrorModel"
description: Error
summary: Label a source
summary: Rename a source
tags:
- Events
/api/sources/{name}/secret:
/api/sources/{id}/secret:
post:
operationId: rotate-source-secret
parameters:
- in: path
name: name
name: id
required: true
schema:
format: uuid
type: string
responses:
"200":
@@ -8405,14 +8520,15 @@ paths:
summary: Replace a signed source's secret and return it once
tags:
- Events
/api/sources/{name}/signing:
/api/sources/{id}/signing:
post:
operationId: set-source-signing
parameters:
- in: path
name: name
name: id
required: true
schema:
format: uuid
type: string
requestBody:
content:
@@ -8436,6 +8552,38 @@ paths:
summary: Require an HMAC signature, or ask to take unsigned deliveries
tags:
- Events
/api/sources/{id}/webhook-path:
put:
operationId: set-source-webhook-path
parameters:
- in: path
name: id
required: true
schema:
format: uuid
type: string
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/WebhookPathInputBody"
required: true
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/EventsSourceView"
description: OK
default:
content:
application/problem+json:
schema:
$ref: "#/components/schemas/ErrorModel"
description: Error
summary: Move the address a source receives deliveries at
tags:
- Events
/api/stream:
get:
operationId: stream-dashboard