@abgov/adsp-sdk-mcp-server 1.14.0 → 1.15.1
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/assets/docs/platform/deployment.md +11 -10
- package/assets/docs/services/access-service-backup-disaster-recovery.md +83 -0
- package/assets/docs/services/audit-service.md +173 -0
- package/assets/docs/services/calendar-service.md +127 -5
- package/assets/docs/services/event-service.md +77 -50
- package/assets/docs/services/form-service.md +40 -1
- package/assets/docs/services/token-handler.md +85 -45
- package/assets/docs/services/value-service.md +82 -5
- package/assets/docs/tutorials/form-service/data-registers.md +40 -45
- package/package.json +2 -1
- package/src/main.js +113 -4
- package/src/main.js.map +1 -1
- package/src/sdk-reference/reference.js +40 -0
- package/src/sdk-reference/reference.js.map +1 -1
|
@@ -15,6 +15,7 @@ communicate over APIs and RabbitMQ, and so deployment into other hosting environ
|
|
|
15
15
|
## Prerequisites
|
|
16
16
|
|
|
17
17
|
<!-- tags: [keycloak] -->
|
|
18
|
+
|
|
18
19
|
A few prerequisites are needed to set up an ADSP deployment:
|
|
19
20
|
|
|
20
21
|
1. [Keycloak](https://www.keycloak.org/) is used as an IAM solution. Realms provide tenants with user access management under their own administrative control.
|
|
@@ -37,28 +38,29 @@ The tenant service creates realms for new tenants using a service account.
|
|
|
37
38
|
Platform micro-services make requests under a non-tenant 'core' context. This is handled with a 'core' realm in Keycloak.
|
|
38
39
|
|
|
39
40
|
1. Create a 'core' realm in Keycloak.
|
|
40
|
-
2. Create public
|
|
41
|
-
3. Create confidential
|
|
42
|
-
4. Create confidential
|
|
41
|
+
2. Create public _client_ with _Standard Flow_ enabled for tenant administration application: `urn:ads:platform:tenant-admin-app`.
|
|
42
|
+
3. Create confidential _clients_ with service accounts for `urn:ads:platform:subscriber-gateway` and `urn:ads:platform:api-docs-app`.
|
|
43
|
+
4. Create confidential _clients_ with service accounts for backend micro-services including:
|
|
43
44
|
- `urn:ads:platform:tenant-service`
|
|
44
45
|
- `urn:ads:platform:event-service`
|
|
45
46
|
- `urn:ads:platform:value-service`
|
|
46
47
|
- ...
|
|
47
|
-
5. Create service
|
|
48
|
+
5. Create service _client roles_:
|
|
48
49
|
- In `urn:ads:platform:value-service`, create `value-reader` and `value-writer` roles.
|
|
49
50
|
- In `urn:ads:platform:event-service`, create `event-sender` role.
|
|
50
|
-
- In `urn:ads:platform:configuration-service`, create
|
|
51
|
+
- In `urn:ads:platform:configuration-service`, create `configured-service` role.
|
|
51
52
|
- In `urn:ads:platform:notification-service`, create `subscription-app` role.
|
|
52
53
|
- In `urn:ads:platform:verify-service`, create `code-generator` and `code-verifier` roles.
|
|
53
|
-
- In `urn:ads:platform:tenant-service`, create `platform-service` role, enable
|
|
54
|
-
6. Assign roles to
|
|
54
|
+
- In `urn:ads:platform:tenant-service`, create `platform-service` role, enable _composite roles_, and add `event-sender` and `configured-service` client roles from above.
|
|
55
|
+
6. Assign roles to _clients_
|
|
55
56
|
- Grant the service accounts the `platform-service` role.
|
|
56
|
-
- Grant `urn:ads:platform:event-service` the `value-writer` role
|
|
57
|
+
- Grant `urn:ads:platform:event-service` the `value-writer` role, so it can log events, and the `value-reader`
|
|
58
|
+
role, so it can count events on behalf of event log API consumers.
|
|
57
59
|
- Grant `urn:ads:platform:notification-service` the `code-generator` and `code-verifier` roles.
|
|
58
60
|
- Grant `urn:ads:platform:subscriber-gateway` and `urn:ads:platform:form-service` the `subscription-app` role.
|
|
59
61
|
|
|
60
|
-
|
|
61
62
|
## RabbitMQ configuration
|
|
63
|
+
|
|
62
64
|
Some platform services communicate over RabbitMQ. The exchange and queue configuration required is contained in the code, but manual configuration is necessary to create the accounts. All accounts should access a common vhost in RabbitMQ.
|
|
63
65
|
|
|
64
66
|
1. Create accounts for platform services including:
|
|
@@ -77,4 +79,3 @@ References for configuration in the form of ConfigMaps and Secrets are included
|
|
|
77
79
|
2. Set appropriate values in the ConfigMaps and Secrets and apply to environments.
|
|
78
80
|
3. Create a service account in 'build' with edit permission to other projects for the pipeline.
|
|
79
81
|
4. Process and apply managed templates, and/or set service account token in GitHub for the pipeline.
|
|
80
|
-
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Access service backup and disaster recovery
|
|
4
|
+
nav_order: 3
|
|
5
|
+
parent: Services
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Access service backup and disaster recovery
|
|
9
|
+
|
|
10
|
+
## Introduction
|
|
11
|
+
|
|
12
|
+
The ADSP Access Service provides authentication and identity management for the platform. It is deployed as Keycloak on the Government of Alberta's Azure Red Hat OpenShift (ARO) cluster, in the `adsp-prod` namespace.
|
|
13
|
+
|
|
14
|
+
This document describes recovery responsibilities and validation for the Access Service. Keycloak deployment configuration, secrets, themes, and other artifacts outside the database must also be recoverable.
|
|
15
|
+
|
|
16
|
+
## Access Service Cluster in ARO
|
|
17
|
+
|
|
18
|
+
The Keycloak service is configured in high-availability (HA) mode, running three instances in the `adsp-prod` ARO environment behind a traffic proxy. A health-check monitor tracks Keycloak, and Azure alerts are configured to notify administrators of CPU or traffic issues. This application-level HA setup provides instance redundancy so authentication can continue if an instance becomes unavailable. End-to-end availability depends on traffic reaching healthy instances and the database and ARO platform remaining available. Failover testing and distribution across separate failure zones still need confirmation.
|
|
19
|
+
|
|
20
|
+
End-to-end availability also depends on the GoA-managed database and the ARO platform. Confirm the database failover arrangements and the behavior of the service during an instance or platform failure with the responsible teams.
|
|
21
|
+
|
|
22
|
+
This is a high-level view of the intended strategy. Instance failover, failure-zone coverage, and database recovery still need confirmation.
|
|
23
|
+
|
|
24
|
+
### Recovery coverage
|
|
25
|
+
|
|
26
|
+
The supplied information references an ARO backup and restore, but does not confirm whether the database and all required Access Service data were included or whether end-to-end recovery was tested. Confirm backup coverage and the results of the latest recovery test.
|
|
27
|
+
|
|
28
|
+
## Database
|
|
29
|
+
|
|
30
|
+
Keycloak stores realm and identity data, including users, clients, and roles, in its database. The database is managed by the Government of Alberta Dev/Ops team, which owns its backup and recovery. The database technology, availability design, failover process, backup schedule, and recovery objectives have not been confirmed. Confirm these details with GoA Dev/Ops. ARO application backups do not necessarily include the separately managed database.
|
|
31
|
+
|
|
32
|
+
## Responsibilities
|
|
33
|
+
|
|
34
|
+
| Responsibility | Owner |
|
|
35
|
+
| ------------------------------------------------------------------- | ------------------------------------------------ |
|
|
36
|
+
| Database backup, retention, protection, and restore | GoA Dev/Ops team |
|
|
37
|
+
| Provide database recovery objectives and restore procedure | GoA Dev/Ops team |
|
|
38
|
+
| Coordinate the Keycloak incident and recovery validation | ADSP team |
|
|
39
|
+
| Restore or redeploy Keycloak configuration and supporting artifacts | To be confirmed with the ADSP service owner |
|
|
40
|
+
| Confirm tenant and application access after recovery | ADSP team with affected tenant/application teams |
|
|
41
|
+
|
|
42
|
+
Confirm these ownership boundaries and the applicable operational contacts with both teams.
|
|
43
|
+
|
|
44
|
+
## Recovery information to confirm
|
|
45
|
+
|
|
46
|
+
The following information is not currently documented and must be confirmed with GoA Dev/Ops, the ADSP service owner, or the OpenShift team as applicable before this document can be treated as an approved recovery runbook.
|
|
47
|
+
|
|
48
|
+
| Item | Confirmed value |
|
|
49
|
+
| ------------------------------------------------------------------------ | --------------- |
|
|
50
|
+
| Database availability and failover arrangements | To be confirmed |
|
|
51
|
+
| Database backup schedule, retention, and recovery objectives | To be confirmed |
|
|
52
|
+
| Database restore process and escalation contact | To be confirmed |
|
|
53
|
+
| Whether backups cover all required Access Service data and configuration | To be confirmed |
|
|
54
|
+
| How traffic moves to healthy instances during a failure | To be confirmed |
|
|
55
|
+
| Whether instances are distributed across separate failure zones | To be confirmed |
|
|
56
|
+
| Frequency and results of end-to-end failover and recovery tests | To be confirmed |
|
|
57
|
+
|
|
58
|
+
## Recovery procedure
|
|
59
|
+
|
|
60
|
+
1. **Declare and coordinate the incident.** The ADSP incident lead records the impact, affected environments, and time detected, then contacts GoA Dev/Ops through the agreed incident channel. Do not attempt an independent database restore or modify the managed database outside the approved process.
|
|
61
|
+
2. **Confirm the recovery point.** GoA Dev/Ops confirms the available restore points, expected data-loss window, and estimated recovery time with the ADSP incident lead before proceeding.
|
|
62
|
+
3. **Restore the database.** GoA Dev/Ops performs the database recovery using its approved process and confirms when the database is ready for Keycloak.
|
|
63
|
+
4. **Recover the Access Service.** The service owner restores the application and its required configuration using the approved ARO recovery process, reconnects it to the recovered database, and confirms that healthy instances can serve authentication requests.
|
|
64
|
+
5. **Validate service behavior.** Complete the checks below before declaring the Access Service recovered. Coordinate tenant-specific checks with affected tenant/application teams.
|
|
65
|
+
6. **Communicate and document.** Report service status and any known data-loss window to stakeholders. Record the incident timeline, restore point, validation results, and follow-up actions.
|
|
66
|
+
|
|
67
|
+
## Post-recovery validation
|
|
68
|
+
|
|
69
|
+
- Keycloak starts successfully and its administrative interface is available to authorized operators.
|
|
70
|
+
- All three intended Keycloak instances are healthy, and authentication continues if one instance becomes unavailable.
|
|
71
|
+
- OpenID Connect discovery and token endpoints respond as expected for the affected realms.
|
|
72
|
+
- A controlled test account can authenticate, and a test service account can obtain a token where applicable.
|
|
73
|
+
- Test tokens contain the expected issuer, audience, and roles, and a representative ADSP service accepts the token.
|
|
74
|
+
- A sample of affected tenant realms, clients, users, and roles is present and usable. Coordinate tenant-specific verification with tenant administrators.
|
|
75
|
+
- Tenant administration and dependent application workflows are confirmed with their owners.
|
|
76
|
+
- The health-check monitor reports the Keycloak service as healthy after recovery.
|
|
77
|
+
- Azure CPU and traffic metrics are available, and alert notifications are working.
|
|
78
|
+
|
|
79
|
+
Use non-production test accounts where possible. Do not use real user credentials as recovery test data.
|
|
80
|
+
|
|
81
|
+
## Review
|
|
82
|
+
|
|
83
|
+
Review this document with GoA Dev/Ops and the ADSP service owner, fill in the recovery information above, and update it after a restore test or a material change to the Keycloak deployment or database service.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Audit service
|
|
4
|
+
parent: Services
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Audit service action catalogs
|
|
8
|
+
|
|
9
|
+
The action catalog registers the classification of audit actions. Registering an action does not
|
|
10
|
+
generate audit records. Event ingestion, metadata validation of individual events, history storage,
|
|
11
|
+
SIEM forwarding, and retention execution are separate capabilities, not implemented by this catalog.
|
|
12
|
+
|
|
13
|
+
## Configuration contract
|
|
14
|
+
|
|
15
|
+
Audit Service registers a namespace-level schema at startup through `initializePlatform` with
|
|
16
|
+
`configuration.useNamespace: true`. The definition is the `audit-service` entry in Core
|
|
17
|
+
`platform:configuration-service`. It appears under **Configuration service > Definitions > Core definitions**.
|
|
18
|
+
Registration follows the SDK's asynchronous startup behavior: inspect registration logs and the stored
|
|
19
|
+
definition before onboarding applications; a listening HTTP server alone does not prove registration succeeded.
|
|
20
|
+
|
|
21
|
+
Each application stores a complete catalog in `audit-service:actions-<application>`, in its tenant
|
|
22
|
+
or in Core for shared actions:
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"kind": "actionCatalog",
|
|
27
|
+
"application": "case-service",
|
|
28
|
+
"actions": {
|
|
29
|
+
"case.update": {
|
|
30
|
+
"version": 1,
|
|
31
|
+
"category": "administrative",
|
|
32
|
+
"severity": "info",
|
|
33
|
+
"retentionClass": "compliance",
|
|
34
|
+
"resourceType": "case",
|
|
35
|
+
"captureChangeSet": true,
|
|
36
|
+
"forwardToSiem": false,
|
|
37
|
+
"metadataSchema": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"properties": { "reason": { "type": "string" } }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`application` is a lowercase kebab-case identifier, at most 40 characters. The API's `namespace`
|
|
47
|
+
is this same identifier, **not** the Configuration Service namespace `audit-service`. For an SDK
|
|
48
|
+
client it should equal `serviceId.service`. Applications are trusted to register only their own
|
|
49
|
+
catalog; Configuration Service roles do not provide application-level write isolation.
|
|
50
|
+
|
|
51
|
+
Actions require a positive integer `version`, `category` (`administrative`, `runtime`, `security`,
|
|
52
|
+
`data-access`), `severity` (`info`, `warning`, `critical`), and a kebab-case `retentionClass`.
|
|
53
|
+
Optional fields are `description`, `resourceType`, `captureChangeSet`, `forwardToSiem`, and
|
|
54
|
+
`metadataSchema`. The two flags resolve to `false` when omitted. An omitted metadata schema imposes
|
|
55
|
+
no action-specific metadata constraint. The listing returns any supplied schema intact.
|
|
56
|
+
Unknown document and definition fields are rejected. Action keys omit the event outcome suffix.
|
|
57
|
+
|
|
58
|
+
The namespace schema also preserves `retentionSettings` and `applicationRetentionSettings` document
|
|
59
|
+
shapes, with positive integer `classes.<class>.days`. No default periods are created here.
|
|
60
|
+
Resolving or validating cross-document retention class references belongs to the retention work.
|
|
61
|
+
|
|
62
|
+
### Registering through the SDK
|
|
63
|
+
|
|
64
|
+
`auditDefinitions()` turns application constants into a map keyed by action name and rejects
|
|
65
|
+
duplicate names at startup:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { adspId, AuditAction, auditDefinitions } from '@abgov/adsp-service-sdk';
|
|
69
|
+
|
|
70
|
+
const serviceId = adspId`urn:ads:case-team:case-service`;
|
|
71
|
+
const ACTIONS = {
|
|
72
|
+
UPDATE_CASE: {
|
|
73
|
+
name: 'case.update',
|
|
74
|
+
version: 1,
|
|
75
|
+
category: 'administrative',
|
|
76
|
+
severity: 'info',
|
|
77
|
+
retentionClass: 'compliance',
|
|
78
|
+
},
|
|
79
|
+
} satisfies Record<string, AuditAction>;
|
|
80
|
+
|
|
81
|
+
// Include this entry in initializeService's serviceConfigurations.
|
|
82
|
+
const serviceConfigurations = [
|
|
83
|
+
{
|
|
84
|
+
serviceId: adspId`urn:ads:platform:audit-service`,
|
|
85
|
+
configuration: [
|
|
86
|
+
{
|
|
87
|
+
name: `actions-${serviceId.service}`,
|
|
88
|
+
operation: 'REPLACE' as const,
|
|
89
|
+
configuration: {
|
|
90
|
+
kind: 'actionCatalog',
|
|
91
|
+
application: serviceId.service,
|
|
92
|
+
actions: auditDefinitions(ACTIONS),
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Use `initializePlatform` for a Core platform service. The same registration entry then creates a
|
|
101
|
+
shared Core catalog. Existing SDK registrations continue to use `UPDATE` unless a named document
|
|
102
|
+
explicitly selects `REPLACE`. For direct Configuration Service calls, PATCH the named catalog with
|
|
103
|
+
`{ "operation": "REPLACE", "configuration": <complete catalog> }`.
|
|
104
|
+
|
|
105
|
+
Replacing one application's document cannot delete another application's catalog, including during
|
|
106
|
+
concurrent registration. Replacing its action map removes obsolete definitions, unlike a shallow
|
|
107
|
+
`UPDATE` merge. Concurrent writers to the _same_ application remain last-writer-wins; coordinate
|
|
108
|
+
those deployments. Only trusted administrators/deployment accounts should have write access.
|
|
109
|
+
|
|
110
|
+
If an active revision is set, changing latest alone may not publish the change. Create and activate
|
|
111
|
+
revisions through the normal Configuration Service workflow, with a configuration-admin account.
|
|
112
|
+
|
|
113
|
+
## Loading and cache behavior
|
|
114
|
+
|
|
115
|
+
The service reads active revisions with fallback to latest, through the existing SDK configuration
|
|
116
|
+
service. It merges tenant and Core maps **by action name**, with the entire Core definition winning
|
|
117
|
+
on conflicts. Tenant-only actions remain. An empty tenant catalog does not hide shared Core actions.
|
|
118
|
+
The stored `application` must match the requested configuration name.
|
|
119
|
+
|
|
120
|
+
The SDK caches converted documents by tenant, configuration namespace, and document name. Core
|
|
121
|
+
documents are shared deliberately. The combine function uses the SDK's existing memoization.
|
|
122
|
+
Tenant `configuration-updated` and `active-revision-set` notifications invalidate the affected
|
|
123
|
+
entry; the next request reloads it. Core changes also have the TTL backstop; do not assume a Core
|
|
124
|
+
write emits a tenant notification.
|
|
125
|
+
|
|
126
|
+
`useLongConfigurationCacheTTL` is **false**, retaining the SDK's 900-second (15-minute) TTL.
|
|
127
|
+
With Configuration Service available, a missed notification is picked up on the first request
|
|
128
|
+
after expiry, plus fetch latency. An update notice normally refreshes on the next request; there is
|
|
129
|
+
no measured end-to-end notification latency guarantee yet. Register actions before deploying code
|
|
130
|
+
that emits them.
|
|
131
|
+
|
|
132
|
+
Audit Service uses the SDK's existing error handling. Configuration HTTP or converter failures are
|
|
133
|
+
logged and returned as `null`, so the catalog API cannot reliably distinguish those failures from
|
|
134
|
+
missing configuration. If neither scope supplies a catalog, it returns 404; if one scope succeeds,
|
|
135
|
+
it can return a partial catalog without the failed scope. A registered empty catalog retains its
|
|
136
|
+
`actions: {}`. Errors that still propagate, such as token acquisition failures, and application-name
|
|
137
|
+
consistency failures are returned as 503.
|
|
138
|
+
|
|
139
|
+
**Deferred by the MVP scope decision:** stale-on-error after invalidation/expiry, explicit cache
|
|
140
|
+
capacity limits, and stronger invalidation/in-flight refresh guarantees. Existing unexpired
|
|
141
|
+
configuration cache entries avoid configuration HTTP reads, but token retrieval remains an SDK
|
|
142
|
+
dependency. Once an entry expires or is invalidated, a configuration HTTP failure resolves to null;
|
|
143
|
+
the SDK does not retain the old value for fallback. Reliable failure-versus-absence distinction is
|
|
144
|
+
also deferred. These OSP-730 acceptance criteria are not claimed complete.
|
|
145
|
+
|
|
146
|
+
## Listing definitions
|
|
147
|
+
|
|
148
|
+
```http
|
|
149
|
+
GET /audit/v1/case-service/actions
|
|
150
|
+
Authorization: Bearer <token with audit-reader>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Returns a JSON array, with each action's `name` plus its definition fields. Optional absent
|
|
154
|
+
`resourceType`, `description`, and `metadataSchema` remain omitted.
|
|
155
|
+
|
|
156
|
+
| Status | Meaning |
|
|
157
|
+
| ------ | --------------------------------------------------------------------------------- |
|
|
158
|
+
| 200 | Resolved definitions; `[]` means registered but empty. |
|
|
159
|
+
| 400 | Invalid application/namespace or tenant ID format. |
|
|
160
|
+
| 401 | Not authenticated. |
|
|
161
|
+
| 403 | No `audit-reader`, or a tenant caller attempted to select a different tenant. |
|
|
162
|
+
| 404 | Neither scope supplied a catalog; this can also result from SDK-handled failures. |
|
|
163
|
+
| 503 | A propagated SDK error or application-name consistency failure; retry. |
|
|
164
|
+
|
|
165
|
+
`audit-reader` is tenant-wide: callers can read any namespace in their tenant, not only their own.
|
|
166
|
+
A Core caller with the role can select a tenant via
|
|
167
|
+
`?tenantId=urn:ads:platform:tenant-service:v2:/tenants/<id>`. A Core request without tenant context
|
|
168
|
+
reads Core catalogs only. The service registers this role for tenant provisioning; existing tenants
|
|
169
|
+
still need their normal role provisioning/assignment process.
|
|
170
|
+
|
|
171
|
+
The catalog governs future write classification, not history access. Removing a definition performs
|
|
172
|
+
no audit-record deletion. History readability after deregistration must also be verified when the
|
|
173
|
+
history endpoint/storage work is integrated; this scaffold has no history API.
|
|
@@ -15,22 +15,76 @@ client `urn:ads:platform:calendar-service`
|
|
|
15
15
|
|
|
16
16
|
| name | description |
|
|
17
17
|
|:-|:-|
|
|
18
|
-
| calendar-admin | Administrator role for calendar service. This role allows a user to
|
|
18
|
+
| calendar-admin | Administrator role for calendar service. This role allows a user to create, update, and delete the tenant's calendar definitions, and to read and update events in any calendar. It is part of the tenant-admin composite role. |
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
`calendar-admin` is a Keycloak client role. It is created under the `urn:ads:platform:calendar-service` client when a tenant realm is created, and tenant administrators have it through the `tenant-admin` composite role. If your realm does not include it (for example, the realm was created before calendar service was available), add it from the *Service roles* tab of Access service in tenant administration. See [Access management](../important-notes.md#access-management).
|
|
21
|
+
|
|
22
|
+
Access to events is primarily controlled by each calendar's `readRoles` and `updateRoles`. Read roles grant access to private events and their attendees; update roles also grant permission to create, update, and delete events and attendees. `calendar-admin` grants both for all calendars.
|
|
21
23
|
|
|
22
24
|
## Concepts
|
|
23
25
|
### Dates
|
|
24
26
|
Calendar service provides informational endpoints for Dates that includes information like which days are business days and which are holidays.
|
|
25
27
|
|
|
26
28
|
### Calendar
|
|
27
|
-
|
|
29
|
+
A calendar is a container for *events*. Each calendar has a name, display name, and description, which are publicly accessible, and the `readRoles` and `updateRoles` that control access to its events.
|
|
30
|
+
|
|
31
|
+
Calendar definitions are stored in the [configuration service](configuration-service.md) under the `platform:calendar-service` namespace and name. Each definition has a `source`:
|
|
32
|
+
- `tenant` calendars are created and managed by the tenant using the calendar service API or the calendar service page in tenant administration.
|
|
33
|
+
- `core` calendars are registered by platform services, such as the `form-intake` calendar of form service. Tenants can use core calendars but cannot change them; they are view-only in tenant administration.
|
|
34
|
+
|
|
35
|
+
| Method | Path | Description | Required role |
|
|
36
|
+
|:-|:-|:-|:-|
|
|
37
|
+
| `GET` | `/calendar/v1/calendars` | Lists calendar definitions with their `source`. Anonymous requests only receive core calendars. | None |
|
|
38
|
+
| `GET` | `/calendar/v1/calendars/{name}` | Retrieves a calendar. | None |
|
|
39
|
+
| `POST` | `/calendar/v1/calendars` | Creates a tenant calendar. Returns 201 with the calendar. | `calendar-admin` |
|
|
40
|
+
| `PUT` | `/calendar/v1/calendars/{name}` | Replaces a tenant calendar. Returns 200 with the calendar. | `calendar-admin` |
|
|
41
|
+
| `DELETE` | `/calendar/v1/calendars/{name}` | Deletes a tenant calendar that has no events. Returns 204. | `calendar-admin` |
|
|
42
|
+
|
|
43
|
+
`calendar-admin` is sufficient to manage tenant calendars; `configuration-admin` is not required. Anonymous requests for a specific calendar, including its public events, must identify the tenant by name using the `tenant` query parameter. Platform (core) users specify the tenant using the `tenantId` query parameter.
|
|
44
|
+
|
|
45
|
+
Create and update requests take a body with the following properties; other properties are not allowed.
|
|
46
|
+
|
|
47
|
+
| property | required | description |
|
|
48
|
+
|:-|:-|:-|
|
|
49
|
+
| `name` | yes | Up to 50 letters, numbers, spaces, hyphens, or underscores. On update, this must match `{name}` in the path. |
|
|
50
|
+
| `displayName` | yes | Display name of up to 32 characters; cannot be blank. |
|
|
51
|
+
| `description` | no | Description of up to 250 characters. |
|
|
52
|
+
| `readRoles` | yes | Roles that can read private events and attendees. Can be an empty array. |
|
|
53
|
+
| `updateRoles` | yes | Roles that can read and change events and attendees. Can be an empty array. |
|
|
54
|
+
|
|
55
|
+
Create, update, and delete requests return:
|
|
56
|
+
- 400 if the request body or calendar name is invalid.
|
|
57
|
+
- 401 if the request is not authenticated.
|
|
58
|
+
- 403 if the user does not have the `calendar-admin` role in the tenant.
|
|
59
|
+
- 404 on update or delete if the tenant has no calendar with that name. Core calendars cannot be updated or deleted.
|
|
60
|
+
- 409 on create if a tenant or core calendar with the name already exists, or on delete if the calendar has events.
|
|
61
|
+
- 502 if the configuration service is unavailable.
|
|
62
|
+
|
|
63
|
+
Successful changes signal `calendar-definition-created`, `calendar-definition-updated`, and `calendar-definition-deleted` [domain events](event-service.md). Each event includes the calendar definition and the user who made the change.
|
|
28
64
|
|
|
29
65
|
### Calendar event
|
|
30
|
-
|
|
66
|
+
Calendar events represent a scheduled activity. Each event has some basic name and description information as well as start and end time. Events can be made public so that anonymous users can read their fields; their attendees remain accessible only to authorized users.
|
|
67
|
+
|
|
68
|
+
### Recurring event
|
|
69
|
+
An event can optionally repeat by including a `recurrence`. The model is a subset of the iCalendar (RFC 5545) recurrence rule:
|
|
70
|
+
|
|
71
|
+
| Property | Description |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `frequency` | `daily`, `weekly`, `monthly`, or `yearly`. Monthly and yearly use the day of the event start; months or years without that day (e.g. the 31st, Feb 29) are skipped. |
|
|
74
|
+
| `interval` | Optional, defaults to 1. For example, `weekly` with `interval: 2` is every two weeks. |
|
|
75
|
+
| `daysOfWeek` | Optional, weekly only. Values from `MO`, `TU`, `WE`, `TH`, `FR`, `SA`, `SU`. Must include the day of the event start. |
|
|
76
|
+
| `end.until` | Optional. Last date (inclusive) that an occurrence can start. |
|
|
77
|
+
| `end.count` | Optional. Number of occurrences, including the first. Can't be used with `until`. |
|
|
78
|
+
|
|
79
|
+
The event `start` and `end` are the first occurrence. Occurrences are generated in Mountain time and keep the same local time across daylight saving changes.
|
|
80
|
+
|
|
81
|
+
- Retrieving events with `from` and `to` returns each occurrence in the range. Occurrences have the `id` of the recurring event and a `recurrenceId` with the original start of the occurrence.
|
|
82
|
+
- Retrieving events without `from` and `to` returns each recurring event once.
|
|
83
|
+
- Updating or deleting the event applies to all occurrences.
|
|
84
|
+
- `DELETE /calendar/v1/calendars/{name}/events/{id}/occurrences/{date}` cancels one occurrence. Cancelled occurrences are listed in `recurrence.exclusions` of the event and can't be restored.
|
|
31
85
|
|
|
32
86
|
### Attendee
|
|
33
|
-
Attendees represent people attending a particular *event*.
|
|
87
|
+
Attendees represent people attending a particular *event*. Blank attendees (no name or email) can be created to represent available appointment slots.
|
|
34
88
|
|
|
35
89
|
## Code examples
|
|
36
90
|
### Getting business days
|
|
@@ -53,6 +107,37 @@ Calendar service API provides information endpoints for dates, including which d
|
|
|
53
107
|
} = await response.json();
|
|
54
108
|
```
|
|
55
109
|
|
|
110
|
+
### Creating a calendar
|
|
111
|
+
Requires the `calendar-admin` role.
|
|
112
|
+
```typescript
|
|
113
|
+
const calendar = {
|
|
114
|
+
name: 'site-inspections',
|
|
115
|
+
displayName: 'Site inspections',
|
|
116
|
+
description: 'Calendar of scheduled site inspections.',
|
|
117
|
+
readRoles: ['inspection-viewer'],
|
|
118
|
+
updateRoles: ['inspection-scheduler'],
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const response = await fetch(
|
|
122
|
+
'https://calendar-service.adsp.alberta.ca/calendar/v1/calendars',
|
|
123
|
+
{
|
|
124
|
+
method: 'POST',
|
|
125
|
+
headers: {
|
|
126
|
+
'Authorization': `Bearer ${accessToken}`,
|
|
127
|
+
'Content-Type': 'application/json',
|
|
128
|
+
},
|
|
129
|
+
body: JSON.stringify(calendar),
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const {
|
|
134
|
+
urn,
|
|
135
|
+
name,
|
|
136
|
+
displayName,
|
|
137
|
+
source,
|
|
138
|
+
} = await response.json();
|
|
139
|
+
```
|
|
140
|
+
|
|
56
141
|
### Creating a calendar event
|
|
57
142
|
```typescript
|
|
58
143
|
const calendarEvent = {
|
|
@@ -84,3 +169,40 @@ Calendar service API provides information endpoints for dates, including which d
|
|
|
84
169
|
isPublic,
|
|
85
170
|
} = await response.json();
|
|
86
171
|
```
|
|
172
|
+
|
|
173
|
+
### Creating a recurring calendar event
|
|
174
|
+
```typescript
|
|
175
|
+
const calendarEvent = {
|
|
176
|
+
name: 'Team meeting',
|
|
177
|
+
start: '2026-09-29T10:00:00-06:00',
|
|
178
|
+
end: '2026-09-29T11:00:00-06:00',
|
|
179
|
+
recurrence: {
|
|
180
|
+
frequency: 'weekly',
|
|
181
|
+
daysOfWeek: ['TU'],
|
|
182
|
+
end: { until: '2026-12-15' },
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const response = await fetch(
|
|
187
|
+
`https://calendar-service.adsp.alberta.ca/calendar/v1/calendars/${calendar}/events`,
|
|
188
|
+
{
|
|
189
|
+
method: 'POST',
|
|
190
|
+
headers: {
|
|
191
|
+
'Authorization': `Bearer ${accessToken}`,
|
|
192
|
+
'Content-Type': 'application/json',
|
|
193
|
+
},
|
|
194
|
+
body: JSON.stringify(calendarEvent),
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
const { id } = await response.json();
|
|
199
|
+
|
|
200
|
+
// Cancel the October 13 occurrence only.
|
|
201
|
+
await fetch(
|
|
202
|
+
`https://calendar-service.adsp.alberta.ca/calendar/v1/calendars/${calendar}/events/${id}/occurrences/2026-10-13`,
|
|
203
|
+
{
|
|
204
|
+
method: 'DELETE',
|
|
205
|
+
headers: { 'Authorization': `Bearer ${accessToken}` },
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
```
|
|
@@ -6,66 +6,73 @@ parent: Services
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Event service
|
|
9
|
+
|
|
9
10
|
Event service allows consumers to send domain events. These events can be used to support additional capabilities aside from the application itself; out of the box, the event service logs domain events to the event log which can be used for traceability of domain operations.
|
|
10
11
|
|
|
11
12
|
## Client roles
|
|
13
|
+
|
|
12
14
|
client `urn:ads:platform:event-service`
|
|
13
15
|
|
|
14
|
-
| name
|
|
15
|
-
|
|
16
|
+
| name | description |
|
|
17
|
+
| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
16
18
|
| event-sender | Sender role for event service. This role is used to allow a service account to send domain events via the event service. Note that the account with the role will be able to send any domain event including platform defined events. |
|
|
19
|
+
| event-reader | Reader role for event service. This role is used to allow users to query the event log, including counting events matching search criteria. It is part of the tenant-admin composite role. |
|
|
17
20
|
|
|
18
21
|
## Concepts
|
|
22
|
+
|
|
19
23
|
### Event definition
|
|
20
|
-
|
|
24
|
+
|
|
25
|
+
Event definition is an optional metadata description of a _domain event_ (identified by a specific namespace and name). They are used for downstream capabilities. For example, the payload schema description allows the [notification service](notification-service.md) to validate variables within notification message templates. Event definitions are configured in the [configuration service](configuration-service.md) under the `platform:event-service` namespace and name.
|
|
21
26
|
|
|
22
27
|
### Event
|
|
28
|
+
|
|
23
29
|
Domain events represent key changes at a domain model level. For example, an intake application process could include events like: application draft created, application submitted, application processing started, application processing completed.
|
|
24
30
|
|
|
25
31
|
### Event log
|
|
26
|
-
|
|
32
|
+
|
|
33
|
+
Event log records all _events_ emitted via the event service and keeps basic metrics including a count of different events. These metrics can represent key domain metrics; in the intake application example, the count of application submitted events represents the volume of applications.
|
|
27
34
|
|
|
28
35
|
## Code examples
|
|
36
|
+
|
|
29
37
|
### Configure an event definition
|
|
38
|
+
|
|
30
39
|
Event definitions are configured using the [configuration service](configuration-service.md). Note that new configuration may take up to 15 mins to apply.
|
|
31
40
|
|
|
32
41
|
```typescript
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
await fetch(
|
|
56
|
-
`${configurationServiceUrl}/configuration/v2/configuration/platform/event-service`,
|
|
57
|
-
{
|
|
58
|
-
method: 'PATCH',
|
|
59
|
-
headers: {
|
|
60
|
-
'Authorization': `Bearer ${accessToken}`,
|
|
61
|
-
'Content-Type': 'application/json'
|
|
42
|
+
const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
|
|
43
|
+
const request = {
|
|
44
|
+
operation: 'UPDATE',
|
|
45
|
+
update: {
|
|
46
|
+
'domain-service': {
|
|
47
|
+
name: 'domain-service',
|
|
48
|
+
definitions: {
|
|
49
|
+
'domain-event': {
|
|
50
|
+
name: 'domain-event',
|
|
51
|
+
description: 'Signalled on significant domain state change.',
|
|
52
|
+
payloadSchema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
value: { type: 'string' },
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
62
59
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
await fetch(`${configurationServiceUrl}/configuration/v2/configuration/platform/event-service`, {
|
|
65
|
+
method: 'PATCH',
|
|
66
|
+
headers: {
|
|
67
|
+
Authorization: `Bearer ${accessToken}`,
|
|
68
|
+
'Content-Type': 'application/json',
|
|
69
|
+
},
|
|
70
|
+
body: JSON.stringify(request),
|
|
71
|
+
});
|
|
66
72
|
```
|
|
67
73
|
|
|
68
74
|
### Send an event
|
|
75
|
+
|
|
69
76
|
```typescript
|
|
70
77
|
const event = {
|
|
71
78
|
namespace: 'support-program',
|
|
@@ -100,23 +107,43 @@ Event definitions are configured using the [configuration service](configuration
|
|
|
100
107
|
```
|
|
101
108
|
|
|
102
109
|
### Search the event log
|
|
110
|
+
|
|
103
111
|
The event log is stored as a value (event-service:event) in the [value service](value-service.md) and can be queried using the value API.
|
|
104
112
|
|
|
105
113
|
```typescript
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
114
|
+
const valueServiceUrl = 'https://value-service.adsp.alberta.ca';
|
|
115
|
+
const top = 50;
|
|
116
|
+
const timestampMin = `2021-10-10T12:00:00Z`;
|
|
109
117
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
const response = await fetch(
|
|
119
|
+
`${valueServiceUrl}/value/v1/event-service/values/event?top=${top}×tampMin=${timestampMin}`,
|
|
120
|
+
{
|
|
121
|
+
method: 'GET',
|
|
122
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const { results, page } = await response.json();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Count events in the event log
|
|
130
|
+
|
|
131
|
+
The count of events matching the event log search criteria is available directly from the event service, so
|
|
132
|
+
consumers do not need to use the value API. Namespace and name are each optional and independent of one another;
|
|
133
|
+
other supplied criteria (timestamp range, correlation ID) are combined with namespace and name when determining
|
|
134
|
+
the count.
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const eventServiceUrl = 'https://event-service.adsp.alberta.ca';
|
|
138
|
+
const timestampMin = `2021-10-10T12:00:00Z`;
|
|
139
|
+
|
|
140
|
+
const response = await fetch(
|
|
141
|
+
`${eventServiceUrl}/event/v1/events/count?namespace=application-events×tampMin=${timestampMin}`,
|
|
142
|
+
{
|
|
143
|
+
method: 'GET',
|
|
144
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
145
|
+
},
|
|
146
|
+
);
|
|
117
147
|
|
|
118
|
-
|
|
119
|
-
results,
|
|
120
|
-
page,
|
|
121
|
-
} = await response.json();
|
|
148
|
+
const { count } = await response.json();
|
|
122
149
|
```
|