@sguild/dispatcher 2.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.
- package/README.md +354 -0
- package/contracts/credit-reservation-funding-state/schema/payloads/reservation.funded-v1.json +59 -0
- package/contracts/credit-reservation-funding-state/schema/payloads/reservation.refunded-v1.json +80 -0
- package/contracts/credit-reservation-funding-state/schema/payloads/reservation.refunding-v1.json +74 -0
- package/contracts/credit-reservation-lock/schema/payloads/credit.consumed-v1.json +33 -0
- package/contracts/credit-reservation-lock/schema/payloads/credit.forfeited-v1.json +41 -0
- package/contracts/credit-reservation-lock/schema/payloads/credit.funded-v1.json +31 -0
- package/contracts/credit-reservation-lock/schema/payloads/credit.locked-v1.json +42 -0
- package/contracts/credit-reservation-lock/schema/payloads/credit.purchased-v1.json +39 -0
- package/contracts/credit-reservation-lock/schema/payloads/credit.released-v1.json +61 -0
- package/contracts/credit-reservation-lock/schema/payloads/credit.released-v2.json +77 -0
- package/contracts/credit-reservation-lock/schema/payloads/credit.reserved-v1.json +60 -0
- package/contracts/credit-reservation-lock/schema/payloads/customer.handoff-v1.json +35 -0
- package/contracts/event-envelope/schema/envelope-v1.json +79 -0
- package/contracts/event-types-registry.json +541 -0
- package/contracts/identity/schema/payloads/intake.amended-v1.json +124 -0
- package/contracts/identity/schema/payloads/intake.captured-v2.json +114 -0
- package/contracts/identity/schema/payloads/person.updated-v1.json +99 -0
- package/contracts/lead-lifecycle/schema/payloads/lead.attempt.exhausted-v1.json +36 -0
- package/contracts/lead-lifecycle/schema/payloads/lead.callback.scheduled-v1.json +39 -0
- package/contracts/lead-lifecycle/schema/payloads/lead.created-v1.json +50 -0
- package/contracts/lead-lifecycle/schema/payloads/lead.reached-v1.json +39 -0
- package/contracts/lead-lifecycle/schema/payloads/lead.stage.changed-v1.json +44 -0
- package/contracts/payment-flow/schema/payloads/payment.failed-v1.json +88 -0
- package/contracts/payment-flow/schema/payloads/payment.received-v1.json +69 -0
- package/contracts/refund-flow/schema/payloads/refund.completed-v1.json +75 -0
- package/contracts/refund-flow/schema/payloads/refund.initiated-v1.json +69 -0
- package/dist/config.d.ts +67 -0
- package/dist/config.js +81 -0
- package/dist/dispatcher-errors.d.ts +20 -0
- package/dist/dispatcher-errors.js +42 -0
- package/dist/dispatcher.d.ts +123 -0
- package/dist/dispatcher.js +171 -0
- package/dist/dlq.d.ts +173 -0
- package/dist/dlq.js +391 -0
- package/dist/fanout-drain.d.ts +11 -0
- package/dist/fanout-drain.js +31 -0
- package/dist/fanout.d.ts +144 -0
- package/dist/fanout.js +321 -0
- package/dist/inbox.d.ts +125 -0
- package/dist/inbox.js +120 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +70 -0
- package/dist/internal/id.d.ts +38 -0
- package/dist/internal/id.js +78 -0
- package/dist/internal/pg-search-path.d.ts +34 -0
- package/dist/internal/pg-search-path.js +55 -0
- package/dist/internal/resolve-contract-path.d.ts +41 -0
- package/dist/internal/resolve-contract-path.js +65 -0
- package/dist/observability.d.ts +24 -0
- package/dist/observability.js +37 -0
- package/dist/postgres-consumer.d.ts +175 -0
- package/dist/postgres-consumer.js +561 -0
- package/dist/postgres-transport.d.ts +70 -0
- package/dist/postgres-transport.js +144 -0
- package/dist/producer-db.d.ts +80 -0
- package/dist/producer-db.js +115 -0
- package/dist/registry.d.ts +94 -0
- package/dist/registry.js +99 -0
- package/dist/signature.d.ts +44 -0
- package/dist/signature.js +79 -0
- package/dist/types.d.ts +107 -0
- package/dist/types.js +13 -0
- package/dist/validator.d.ts +60 -0
- package/dist/validator.js +171 -0
- package/package.json +48 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://contracts.sguild/credit-reservation-lock/schema/payloads/credit.funded-v1.json",
|
|
4
|
+
"title": "credit.funded payload v1",
|
|
5
|
+
"description": "Payload for the credit.funded event_type per contracts/credit-reservation-lock/README.md §9.3. Emitted by Revenue when the funding sub-state on a 'reserved' reservation flips from 'pending' to 'funded'. Subscribers: Sales (signal that customer is committing financially), Delivery. Coaching does NOT subscribe; the funding sub-state is Revenue-internal and does not change whether the slot is claimed in the lock-aware availability projection (per coach-availability §4.3.1).",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"credit_reservation_id",
|
|
10
|
+
"funding_source",
|
|
11
|
+
"funded_at"
|
|
12
|
+
],
|
|
13
|
+
"properties": {
|
|
14
|
+
"credit_reservation_id": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"pattern": "^crr_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
17
|
+
},
|
|
18
|
+
"funding_source": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "How the reservation became funded.",
|
|
21
|
+
"enum": [
|
|
22
|
+
"credits_available",
|
|
23
|
+
"invoice_paid"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"funded_at": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"format": "date-time"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://contracts.sguild/credit-reservation-lock/schema/payloads/credit.locked-v1.json",
|
|
4
|
+
"title": "credit.locked payload v1",
|
|
5
|
+
"description": "Payload for the credit.locked event_type per contracts/credit-reservation-lock/README.md §9.4. Emitted by Revenue when the reservation enters 'locked' state at T-48h. Subscribers: Delivery (day-of preparation), Sales (close Lead via the customer.handoff sidecar), Coaching (state-transition only; the slot stays subtracted in the availability projection per coach-availability §4.3.2). The customer.handoff sidecar fires on the first credit.locked per Person.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"credit_reservation_id",
|
|
10
|
+
"lesson_id",
|
|
11
|
+
"person_id",
|
|
12
|
+
"locked_credits",
|
|
13
|
+
"locked_at"
|
|
14
|
+
],
|
|
15
|
+
"properties": {
|
|
16
|
+
"credit_reservation_id": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The reservation transitioning to locked. crr_<UUID v7 canonical>.",
|
|
19
|
+
"pattern": "^crr_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
20
|
+
},
|
|
21
|
+
"lesson_id": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "The Delivery-owned lesson. les_<UUID v7>.",
|
|
24
|
+
"pattern": "^les_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
25
|
+
},
|
|
26
|
+
"person_id": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "The Person whose credit account is locked.",
|
|
29
|
+
"pattern": "^per_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
30
|
+
},
|
|
31
|
+
"locked_credits": {
|
|
32
|
+
"type": "integer",
|
|
33
|
+
"description": "N (positive integer): the credit count posted as the Reservation Lock Debit ledger entry per §7.",
|
|
34
|
+
"minimum": 1
|
|
35
|
+
},
|
|
36
|
+
"locked_at": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"format": "date-time",
|
|
39
|
+
"description": "When the lock posted. Producer's wall-clock in UTC."
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://contracts.sguild/credit-reservation-lock/schema/payloads/credit.purchased-v1.json",
|
|
4
|
+
"title": "credit.purchased payload v1",
|
|
5
|
+
"description": "Payload for the credit.purchased event_type per contracts/credit-reservation-lock/README.md §9.1. Emitted by Revenue when a Purchase Credit ledger entry posts (customer pack purchase). Subscribers: Sales (close out related Leads), Growth (funnel attribution), Delivery (awareness of new credit availability), Platform warehouse.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"credit_account_id",
|
|
10
|
+
"person_id",
|
|
11
|
+
"purchased_credits",
|
|
12
|
+
"order_id",
|
|
13
|
+
"purchased_at"
|
|
14
|
+
],
|
|
15
|
+
"properties": {
|
|
16
|
+
"credit_account_id": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"pattern": "^crd_acct_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
19
|
+
},
|
|
20
|
+
"person_id": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"pattern": "^per_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
23
|
+
},
|
|
24
|
+
"purchased_credits": {
|
|
25
|
+
"type": "integer",
|
|
26
|
+
"description": "N (positive integer): the credit count added to the account by this purchase.",
|
|
27
|
+
"minimum": 1
|
|
28
|
+
},
|
|
29
|
+
"order_id": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "The originating order from Revenue. ord_<UUID v7>.",
|
|
32
|
+
"pattern": "^ord_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
33
|
+
},
|
|
34
|
+
"purchased_at": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"format": "date-time"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://contracts.sguild/credit-reservation-lock/schema/payloads/credit.released-v1.json",
|
|
4
|
+
"title": "credit.released payload v1",
|
|
5
|
+
"description": "Payload for the credit.released event_type per contracts/credit-reservation-lock/README.md §9.6. Emitted by Revenue on '→ released' transition from any source. Subscribers: Delivery, Sales (if pre-lock release of a Lead's first reservation), Coaching (unsubtracts the slot in the availability projection per coach-availability §4.3.2), Platform warehouse. v2 will add a cancellation_reason (or reason_code; naming TBD) per the pending ADR-0006 amendment in 2026-05-02-delivery-refund-cancellation-reason-codes; the v1 payload here is the consumer-stable shape during the SDK gap and the Phase-2 cutover.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"credit_reservation_id",
|
|
10
|
+
"credit_account_id",
|
|
11
|
+
"released_credits",
|
|
12
|
+
"initiator",
|
|
13
|
+
"reversal_reason",
|
|
14
|
+
"cancelled_at"
|
|
15
|
+
],
|
|
16
|
+
"properties": {
|
|
17
|
+
"credit_reservation_id": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "The reservation being released.",
|
|
20
|
+
"pattern": "^crr_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
21
|
+
},
|
|
22
|
+
"credit_account_id": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"pattern": "^crd_acct_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
25
|
+
},
|
|
26
|
+
"released_credits": {
|
|
27
|
+
"type": "integer",
|
|
28
|
+
"description": "N (positive integer).",
|
|
29
|
+
"minimum": 1
|
|
30
|
+
},
|
|
31
|
+
"initiator": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "Who initiated the cancellation per §6 cancellation policy interface and §9.6.",
|
|
34
|
+
"enum": [
|
|
35
|
+
"customer",
|
|
36
|
+
"admin",
|
|
37
|
+
"coach",
|
|
38
|
+
"system_weather",
|
|
39
|
+
"system_logistics",
|
|
40
|
+
"system_unpaid",
|
|
41
|
+
"system_other"
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"reversal_reason": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "The credit-accounting category for the reversal Adjustment per §7.1. 'Credits Released' for normal operational cancellations; 'Administrative Void' for admin overrides or data corrections.",
|
|
47
|
+
"enum": [
|
|
48
|
+
"Credits Released",
|
|
49
|
+
"Administrative Void"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"reason_note": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Optional free-form context. Operator notes, weather event description, etc."
|
|
55
|
+
},
|
|
56
|
+
"cancelled_at": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"format": "date-time"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://contracts.sguild/credit-reservation-lock/schema/payloads/credit.released-v2.json",
|
|
4
|
+
"title": "credit.released payload v2",
|
|
5
|
+
"description": "Payload for the credit.released event_type per contracts/credit-reservation-lock/README.md §9.6 at schema_version 2 (v1.1.0 amendment landed 2026-05-08 per memos/2026-05-08-revenue-refund-reason-codes-signoff and 2026-05-08-delivery-reason-codes-signoff-accepted). Adds the required reason_code field; otherwise identical to v1. Producers SHALL emit at schema_version 2 from the cutover date 2026-05-22; v1 consumers continue to work indefinitely per §11 additive-discipline (the new field is safe-to-ignore on the v1 surface). reason_code is partitioned into the auto-release and explicit-operator subsets per §6.1. Consumers SHALL treat unknown reason_code values as safe-to-ignore per §11 (Phase-2 narrowing may add values as policy work surfaces specifics).",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"credit_reservation_id",
|
|
10
|
+
"credit_account_id",
|
|
11
|
+
"released_credits",
|
|
12
|
+
"initiator",
|
|
13
|
+
"reason_code",
|
|
14
|
+
"reversal_reason",
|
|
15
|
+
"cancelled_at"
|
|
16
|
+
],
|
|
17
|
+
"properties": {
|
|
18
|
+
"credit_reservation_id": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The reservation being released.",
|
|
21
|
+
"pattern": "^crr_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
22
|
+
},
|
|
23
|
+
"credit_account_id": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"pattern": "^crd_acct_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
26
|
+
},
|
|
27
|
+
"released_credits": {
|
|
28
|
+
"type": "integer",
|
|
29
|
+
"description": "N (positive integer).",
|
|
30
|
+
"minimum": 1
|
|
31
|
+
},
|
|
32
|
+
"initiator": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "Who initiated the cancellation per §6 cancellation policy interface and §9.6.",
|
|
35
|
+
"enum": [
|
|
36
|
+
"customer",
|
|
37
|
+
"admin",
|
|
38
|
+
"coach",
|
|
39
|
+
"system_weather",
|
|
40
|
+
"system_logistics",
|
|
41
|
+
"system_unpaid",
|
|
42
|
+
"system_other"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"reason_code": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "Cancellation cause in a refund-flow-actionable way per §6.1. Auto-release subset (no operator approval at the lock-state-machine boundary): site_closure, coach_unavailable_reschedule_failed, force_majeure, weather, administrative_void. Explicit-operator subset (operator confirms refund eligibility): customer_requested_in_window, customer_requested_exception, policy_exception, bad_debt_writeoff. Consumers SHALL treat unknown values as safe-to-ignore per §11.",
|
|
48
|
+
"enum": [
|
|
49
|
+
"site_closure",
|
|
50
|
+
"coach_unavailable_reschedule_failed",
|
|
51
|
+
"force_majeure",
|
|
52
|
+
"weather",
|
|
53
|
+
"administrative_void",
|
|
54
|
+
"customer_requested_in_window",
|
|
55
|
+
"customer_requested_exception",
|
|
56
|
+
"policy_exception",
|
|
57
|
+
"bad_debt_writeoff"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"reversal_reason": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "The credit-accounting category for the reversal Adjustment per §7.1. 'Credits Released' for normal operational cancellations; 'Administrative Void' for admin overrides or data corrections.",
|
|
63
|
+
"enum": [
|
|
64
|
+
"Credits Released",
|
|
65
|
+
"Administrative Void"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"reason_note": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"description": "Optional free-form context. Operator notes, weather event description, etc."
|
|
71
|
+
},
|
|
72
|
+
"cancelled_at": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"format": "date-time"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://contracts.sguild/credit-reservation-lock/schema/payloads/credit.reserved-v1.json",
|
|
4
|
+
"title": "credit.reserved payload v1",
|
|
5
|
+
"description": "Payload for the credit.reserved event_type per contracts/credit-reservation-lock/README.md §9.2. Emitted by Revenue at scheduling. Subscribers: Delivery (awareness of upcoming lesson), Coaching (subtracts the slot in the lock-aware availability projection per coach-availability §4.3.2), Platform warehouse.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"credit_reservation_id",
|
|
10
|
+
"credit_account_id",
|
|
11
|
+
"person_id",
|
|
12
|
+
"lesson_id",
|
|
13
|
+
"organization_id",
|
|
14
|
+
"reserved_credits",
|
|
15
|
+
"reserved_at",
|
|
16
|
+
"lesson_starts_at"
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"credit_reservation_id": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "The reservation per ADR-0002. crr_<UUID v7 canonical>.",
|
|
22
|
+
"pattern": "^crr_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
23
|
+
},
|
|
24
|
+
"credit_account_id": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "The credit account being claimed against. crd_acct_<UUID v7 canonical> per the contract terminology section.",
|
|
27
|
+
"pattern": "^crd_acct_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
28
|
+
},
|
|
29
|
+
"person_id": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "The Person whose credit account is claimed. per_<UUID v7> per ADR-0002.",
|
|
32
|
+
"pattern": "^per_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
33
|
+
},
|
|
34
|
+
"lesson_id": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "The Delivery-owned lesson. les_<UUID v7> per ADR-0002.",
|
|
37
|
+
"pattern": "^les_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
38
|
+
},
|
|
39
|
+
"organization_id": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Tenant scope on the reservation; see ADR-0001 for the tenant model. Today a fixed singleton.",
|
|
42
|
+
"minLength": 1
|
|
43
|
+
},
|
|
44
|
+
"reserved_credits": {
|
|
45
|
+
"type": "integer",
|
|
46
|
+
"description": "N (positive integer): the credit count claimed by this reservation. Determined by the lesson's duration or the offering's reduced credit price for trial lessons.",
|
|
47
|
+
"minimum": 1
|
|
48
|
+
},
|
|
49
|
+
"reserved_at": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"format": "date-time",
|
|
52
|
+
"description": "When the reservation was recorded. Producer's wall-clock in UTC."
|
|
53
|
+
},
|
|
54
|
+
"lesson_starts_at": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"format": "date-time",
|
|
57
|
+
"description": "When the lesson is scheduled to start. Used by consumers (notably Coaching) to scope window math."
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://contracts.sguild/credit-reservation-lock/schema/payloads/customer.handoff-v1.json",
|
|
4
|
+
"title": "customer.handoff payload v1",
|
|
5
|
+
"description": "Payload for the customer.handoff event_type per contracts/credit-reservation-lock/README.md §5 (Customer handoff coupling). Emitted by Revenue immediately after credit.locked when it is the FIRST lock for a Person across all credits and lessons. Subscribers: Delivery (starts customer-tracking record, owns daily-touch responsibility), Sales (closes the originating Lead), Platform warehouse. Idempotent: Revenue tracks per-Person 'first lock fired' state and SHALL NOT re-emit on credit.locked redelivery (§5 Idempotency note). Per §5.1 the handoff is irrevocable; subsequent terminal states on the lock do not retract it.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"person_id",
|
|
10
|
+
"first_lesson_id",
|
|
11
|
+
"credit_reservation_id",
|
|
12
|
+
"handoff_at"
|
|
13
|
+
],
|
|
14
|
+
"properties": {
|
|
15
|
+
"person_id": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "The Person being handed off from Sales' daily-touch responsibility to Delivery's.",
|
|
18
|
+
"pattern": "^per_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
19
|
+
},
|
|
20
|
+
"first_lesson_id": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "The lesson whose first-lock-for-this-Person triggered the handoff.",
|
|
23
|
+
"pattern": "^les_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
24
|
+
},
|
|
25
|
+
"credit_reservation_id": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "The reservation whose locked transition fired this handoff.",
|
|
28
|
+
"pattern": "^crr_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
29
|
+
},
|
|
30
|
+
"handoff_at": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"format": "date-time"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://contracts.sguild/event-envelope/envelope-v1.json",
|
|
4
|
+
"title": "Sguild Event Envelope v1",
|
|
5
|
+
"description": "The shared envelope every cross-domain event rides on, per contracts/event-envelope/README.md (currently v1.0.2). Required and optional fields per §4.1 and §4.2; field rules per §4.3. Per-event-type payload schemas live alongside the producing contract at contracts/<contract>/schema/payloads/<event_type>-v<schema_version>.json and version independently per §8.2.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"required": [
|
|
9
|
+
"event_id",
|
|
10
|
+
"event_type",
|
|
11
|
+
"occurred_at",
|
|
12
|
+
"tenant_id",
|
|
13
|
+
"producer",
|
|
14
|
+
"schema_version",
|
|
15
|
+
"payload"
|
|
16
|
+
],
|
|
17
|
+
"properties": {
|
|
18
|
+
"event_id": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "Globally unique event identifier per ADR-0002. Format: 'evt_' followed by a UUID v7 in canonical form.",
|
|
21
|
+
"pattern": "^evt_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
22
|
+
},
|
|
23
|
+
"event_type": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Hierarchical event-type identifier; dotted lowercase noun.verb. Must be registered in the event-type registry before first use per §10.4.",
|
|
26
|
+
"pattern": "^[a-z][a-z0-9_]*(\\.[a-z][a-z0-9_]*)+$",
|
|
27
|
+
"minLength": 3,
|
|
28
|
+
"maxLength": 128
|
|
29
|
+
},
|
|
30
|
+
"occurred_at": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"format": "date-time",
|
|
33
|
+
"description": "Producer's wall-clock at the moment the event happened. ISO 8601 with timezone, in UTC. Producers MUST NOT backdate or postdate (§4.3)."
|
|
34
|
+
},
|
|
35
|
+
"tenant_id": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Tenant scoping per ADR-0001. Today a fixed singleton. Producers MUST NOT accept tenant_id from untrusted input (§4.3); it comes from request context.",
|
|
38
|
+
"minLength": 1,
|
|
39
|
+
"maxLength": 64
|
|
40
|
+
},
|
|
41
|
+
"producer": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Which domain emitted the event. Closed enum per the closed domain set; 'operations' is the legacy value during the 2026-04-27 to 2026-05-11 deprecation window per v1.0.1 changelog.",
|
|
44
|
+
"enum": [
|
|
45
|
+
"platform",
|
|
46
|
+
"growth",
|
|
47
|
+
"sales",
|
|
48
|
+
"delivery",
|
|
49
|
+
"revenue",
|
|
50
|
+
"coaching",
|
|
51
|
+
"operations"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"schema_version": {
|
|
55
|
+
"type": "integer",
|
|
56
|
+
"description": "Versions the payload shape for this event_type. Independent of envelope version per §8.2. Starts at 1 per §10.4.",
|
|
57
|
+
"minimum": 1
|
|
58
|
+
},
|
|
59
|
+
"payload": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"description": "Event-specific data; shape determined by (event_type, schema_version). Payload schemas live at contracts/<contract>/schema/payloads/<event_type>-v<schema_version>.json and are applied separately by the dispatcher SDK after envelope validation succeeds."
|
|
62
|
+
},
|
|
63
|
+
"subject": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"description": "The primary entity the event is about. Usually a person_id; may be any canonical entity ID per ADR-0002 (lead_*, par_*, coa_*, crd_*, etc.). Optional but SHOULD be set for events whose subject is a Person.",
|
|
66
|
+
"pattern": "^[a-z]{3,4}_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
67
|
+
},
|
|
68
|
+
"actor": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"description": "The human or system that caused the event. Either a person_id (per_<UUID v7>) for human-triggered events or 'system:<domain>' for automated events.",
|
|
71
|
+
"pattern": "^(per_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|system:(platform|growth|sales|delivery|revenue|coaching))$"
|
|
72
|
+
},
|
|
73
|
+
"correlation_id": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"description": "The originating event in a chain. Lets consumers reconstruct cross-domain workflows. Same shape as event_id.",
|
|
76
|
+
"pattern": "^evt_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|