@abgov/adsp-sdk-mcp-server 1.24.0 → 1.24.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.
@@ -5,92 +5,196 @@ parent: Services
5
5
  ---
6
6
 
7
7
  # Configuration service
8
+
8
9
  Configuration service provides a store for infrequently changing configuration and includes a concept of revisions to support 'version locking' of configuration. The service can store arbitrary json objects as configuration with support for optional write-time validation using json schemas.
9
10
 
10
11
  ## Client roles
12
+
11
13
  client `urn:ads:platform:configuration-service`
12
14
 
13
- | name | description |
14
- |:-|:-|
15
- | configuration-admin | Administrator role for configuration service. This role grants read and write access to configuration. It is part of the tenant-admin composite role and allows tenant administrators to configure platform services. |
16
- | configuration-reader | Reader role for configuration service. This role is used to allow service accounts to read configuration. |
15
+ | name | description |
16
+ | :------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | configuration-admin | Administrator role for configuration service. This role grants read and write access to configuration, including creating revisions, setting the active revision, and deleting configuration. It is part of the tenant-admin composite role and allows tenant administrators to configure platform services. |
18
+ | configuration-reader | Reader role for configuration service. This role is used to allow service accounts to read configuration. |
19
+ | configured-service | Service role for configuration service. This role grants service accounts read access to configuration, and lets them update the latest revision, for example to register their configuration on startup. It doesn't allow creating revisions, setting the active revision, or deleting configuration. |
20
+
21
+ Configuration service also accepts the `urn:ads:platform:directory-service:resource-resolver` and `urn:ads:platform:export-service:export-job` roles for reading configuration, so that those platform services can resolve and export configuration resources.
22
+
23
+ ## Tenancy
24
+
25
+ Configuration is either **tenant** configuration, which belongs to one tenant, or **core** (platform) configuration, which has no tenant. Both are identified by the same namespace and name, so a namespace and name can have core configuration and configuration in each tenant.
26
+
27
+ - **Tenant users and service accounts** always act on the configuration of the tenant of their token. On `GET /configuration/v2/configuration/{namespace}/{name}` and `/latest`, they can set the `core` query parameter to read core configuration instead; they can't modify core configuration.
28
+ - **Core users** (platform service accounts) act on the configuration of the tenant given by the `tenantId` query parameter. Without `tenantId`, they act on core configuration, including for writes.
29
+ - **Anonymous requests** to `/active` and `/latest` name the tenant in the `tenant` query parameter, since there is no token. Without it, they read core configuration. Anonymous reads are only allowed when the configuration definition sets `anonymousRead`, and are rate limited to 200 requests per IP address in 5 minutes.
30
+ - **Isolation.** A tenant user's requests are scoped to their tenant; there is no way for them to name another tenant's configuration. Finding configuration with `criteria` can't override the tenant.
31
+ - **Role scope.** Roles are checked in the tenant of the configuration, and core users with a role have it for every tenant. The exception is finding configuration in a namespace, where the configuration-admin role must be held in the tenant; core users need the configured-service or export-job role.
32
+
33
+ ### Combining tenant and core configuration
34
+
35
+ Configuration service stores tenant and core configuration separately and doesn't merge them. Platform services that use the `adsp-service-sdk` (`configurationService.getConfiguration` or `getServiceConfiguration`) request both, as their core service account: once with `tenantId` for the tenant configuration and once without for core configuration. The SDK returns `[tenantConfiguration, coreConfiguration, revision]`, or the result of the `combineConfiguration` function the service passes to `initializePlatform`, so each service decides how a tenant overrides platform defaults. For example, event service merges the event namespaces of the tenant with the core (platform) namespaces, and a core namespace takes precedence over a tenant namespace of the same name.
36
+
37
+ The SDK reads the active revision, falling back to the latest revision (`/active?orLatest=true`), and caches the result. It clears its cache when it receives `configuration-updated` and `active-revision-set` events through the `configuration-updates` stream.
38
+
39
+ ## API overview
40
+
41
+ All endpoints are under `https://configuration-service.adsp.alberta.ca/configuration/v2`. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
42
+
43
+ | Endpoint | Purpose | Required role |
44
+ | :----------------------------------------------------------- | :------------------------------------------------------------ | :-------------------------------------------------------------------- |
45
+ | `GET /configuration/{namespace}` | Find configuration in a namespace. | `configuration-admin` (tenant), `configured-service`, or `export-job` |
46
+ | `GET /configuration/{namespace}/{name}` | Read configuration with its latest and active revisions. | `configuration-reader`, `configuration-admin`, `configured-service` |
47
+ | `PATCH /configuration/{namespace}/{name}` | Update, replace, or remove properties of the latest revision. | `configuration-admin` or `configured-service` |
48
+ | `POST /configuration/{namespace}/{name}` | Create a revision, or set the active revision. | `configuration-admin` |
49
+ | `DELETE /configuration/{namespace}/{name}` | Delete configuration and all its revisions. | `configuration-admin` |
50
+ | `GET /configuration/{namespace}/{name}/latest` | Read the configuration of the latest revision. | Any read role, or anonymous if the definition allows it |
51
+ | `GET /configuration/{namespace}/{name}/active` | Read the active revision. | Any read role, or anonymous if the definition allows it |
52
+ | `GET /configuration/{namespace}/{name}/revisions` | List revisions, newest first. | `configuration-reader`, `configuration-admin`, `configured-service` |
53
+ | `GET /configuration/{namespace}/{name}/revisions/{revision}` | Read the configuration of a revision. | `configuration-reader`, `configuration-admin`, `configured-service` |
54
+
55
+ The read roles also include the directory service `resource-resolver` and export service `export-job` roles. Configuration definitions have no endpoints of their own; they are configuration under `platform:configuration-service` (see [Configuration definition](#configuration-definition)).
17
56
 
18
57
  ## Concepts
58
+
19
59
  ### Configuration definition
20
- Configuration definition is an optional metadata description for a particular *configuration* (identified by a specific namespace and name). The definition provides write-time validation via json schema. Configuration definitions are configured in the [configuration service](configuration-service.md) under the `platform:configuration-service` namespace and name.
60
+
61
+ Configuration definition is an optional metadata description for a particular _configuration_ (identified by a specific namespace and name). The definition provides write-time validation via json schema, and can set `anonymousRead` to allow reading the configuration without a token. Configuration definitions are configured in the configuration service under the `platform:configuration-service` namespace and name, keyed by `{namespace}:{name}`, or by `{namespace}` for a definition that applies to every name in a namespace. Core definitions apply to all tenants; a tenant can add definitions in its own `platform:configuration-service` configuration for configuration that has no core definition.
21
62
 
22
63
  ### Configuration
23
- Configuration stores values represented by a json object at a particular namespace and name. Configuration includes *revisions* that represent current and past value snapshots.
64
+
65
+ Configuration stores values represented by a json object at a particular namespace and name. Configuration includes _revisions_ that represent current and past value snapshots.
24
66
 
25
67
  ### Revision
26
- Revisions are specific snapshots of *configuration*. Updates to configuration values are applied to the latest revision and the current value is captured in a snapshot when a new revision is created. This can be used to version lock configuration for consumers; the configured application should request a specific revision use deployment parameterization mechanisms, like environment variables, to allow for updating to later revisions.
27
68
 
28
- ## Audit
29
- Configuration service records audit events when configuration is updated or deleted, revisions are created, the active revision is set, and configuration definitions change. Audit failures are logged by the SDK and do not fail the configuration operation. The configuration service account requires the `audit-writer` role of `urn:ads:platform:audit-service`.
69
+ Revisions are specific snapshots of _configuration_. Updates to configuration values are applied to the latest revision and the current value is captured in a snapshot when a new revision is created. This can be used to version lock configuration for consumers; the configured application should request a specific revision use deployment parameterization mechanisms, like environment variables, to allow for updating to later revisions.
70
+
71
+ ### Active revision
72
+
73
+ The active revision is the revision that consumers should use. It is set with the `SET-ACTIVE-REVISION` operation, and services that use the `adsp-service-sdk` read it, falling back to the latest revision when none is set.
74
+
75
+ ### Audit
76
+
77
+ Configuration service records audit events to the [audit service](audit-service.md) when tenant configuration is updated or deleted, revisions are created, the active revision is set, and configuration definitions change. Core configuration and the `audit-service` namespace are not audited. Audit failures are logged by the SDK and do not fail the configuration operation. The configuration service account requires the `audit-writer` role of `urn:ads:platform:audit-service`.
78
+
79
+ | Action | Recorded when |
80
+ | :---------------------------------- | :------------------------------------------------------------- |
81
+ | `configuration.updated` | Configuration is updated or replaced. Includes the change set. |
82
+ | `configuration.deleted` | Configuration is deleted. |
83
+ | `configuration.revision-created` | A revision is created. |
84
+ | `configuration.active-revision-set` | The active revision is changed. |
85
+ | `configuration-definition.created` | A definition is added to `platform:configuration-service`. |
86
+ | `configuration-definition.updated` | A definition in `platform:configuration-service` is changed. |
87
+ | `configuration-definition.deleted` | A definition is removed from `platform:configuration-service`. |
30
88
 
31
89
  Audit recording is on by default. Set the environment variable `CONFIGURATION_AUDIT_ENABLED=false` on configuration service to turn it off, or `true` to turn it on regardless of the SDK `AUDIT_ENABLED` variable, which applies when `CONFIGURATION_AUDIT_ENABLED` is not set. The action catalog is still registered while recording is off, so turning it back on needs only a restart.
32
90
 
91
+ ## Events
92
+
93
+ Configuration service sends these domain events, in the `configuration-service` namespace, for tenant configuration. Changes to core configuration don't send `configuration-updated` or `revision-created` events.
94
+
95
+ | Event | Sent when |
96
+ | :---------------------- | :--------------------------------------------------------------------------------------------------------- |
97
+ | `configuration-updated` | The latest revision is changed by `PATCH`. Includes the operation, the update data, and the size in bytes. |
98
+ | `configuration-deleted` | Configuration and its revisions are deleted. |
99
+ | `revision-created` | A revision is created by `CREATE-REVISION`. |
100
+ | `active-revision-set` | The active revision is changed by `SET-ACTIVE-REVISION`. |
101
+
102
+ The `configuration-updates` [push service](push-service.md) stream delivers `configuration-updated`, `revision-created`, and `active-revision-set` events to subscribers with a configuration service role, for cache invalidation. Configuration service doesn't consume domain events.
103
+
33
104
  ## Code examples
105
+
34
106
  ### Read a revision of configuration
107
+
35
108
  ```typescript
36
- const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
37
- const namespace = 'support';
38
- const name = 'formula-values';
39
- const response = await fetch(
40
- `${configurationServiceUrl}/configuration/v2/configuration/${namespace}/${name}/revisions/1`,
41
- {
42
- method: 'GET',
43
- headers: {
44
- 'Authorization': `Bearer ${accessToken}`,
45
- }
46
- }
47
- );
48
- const configuration = await response.json();
109
+ const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
110
+ const namespace = 'support';
111
+ const name = 'formula-values';
112
+ const response = await fetch(
113
+ `${configurationServiceUrl}/configuration/v2/configuration/${namespace}/${name}/revisions/1`,
114
+ {
115
+ method: 'GET',
116
+ headers: {
117
+ Authorization: `Bearer ${accessToken}`,
118
+ },
119
+ },
120
+ );
121
+ const configuration = await response.json();
122
+ ```
123
+
124
+ ### Read tenant and core configuration as a platform service
125
+
126
+ Core service accounts set `tenantId` to read a tenant's configuration, and leave it out to read core configuration.
127
+
128
+ ```typescript
129
+ const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
130
+ const tenantId = 'urn:ads:platform:tenant-service:v2:/tenants/61f2e3a8c9b1d2e3f4a5b6c7';
131
+ const url = `${configurationServiceUrl}/configuration/v2/configuration/platform/event-service/active?orLatest=true`;
132
+ const headers = { Authorization: `Bearer ${accessToken}` };
133
+
134
+ const tenantResponse = await fetch(`${url}&tenantId=${encodeURIComponent(tenantId)}`, { headers });
135
+ const coreResponse = await fetch(url, { headers });
136
+
137
+ const { revision, configuration: tenantConfiguration } = await tenantResponse.json();
138
+ const { configuration: coreConfiguration } = await coreResponse.json();
49
139
  ```
50
140
 
51
141
  ### Update configuration
142
+
52
143
  Updates are applied to the latest revision of configuration.
144
+
53
145
  ```typescript
54
- const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
55
- const namespace = 'support';
56
- const name = 'formula-values';
57
- const request = {
58
- operation: 'UPDATE',
59
- update: {
60
- valueA: 'this is a configuration value',
61
- valueB: 123,
62
- }
63
- }
64
-
65
- await fetch(
66
- `${configurationServiceUrl}/configuration/v2/configuration/${namespace}/${name}`,
67
- {
68
- method: 'PATCH',
69
- headers: {
70
- 'Authorization': `Bearer ${accessToken}`,
71
- 'Content-Type': 'application/json'
72
- },
73
- body: JSON.stringify(request),
74
- }
75
- );
146
+ const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
147
+ const namespace = 'support';
148
+ const name = 'formula-values';
149
+ const request = {
150
+ operation: 'UPDATE',
151
+ update: {
152
+ valueA: 'this is a configuration value',
153
+ valueB: 123,
154
+ },
155
+ };
156
+
157
+ const response = await fetch(`${configurationServiceUrl}/configuration/v2/configuration/${namespace}/${name}`, {
158
+ method: 'PATCH',
159
+ headers: {
160
+ Authorization: `Bearer ${accessToken}`,
161
+ 'Content-Type': 'application/json',
162
+ },
163
+ body: JSON.stringify(request),
164
+ });
165
+ const { latest } = await response.json();
76
166
  ```
77
167
 
78
168
  ### Create a revision
169
+
79
170
  Create a revision to snapshot the latest configuration. The snapshot cannot be modified afterwards.
171
+
172
+ ```typescript
173
+ const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
174
+ const namespace = 'support';
175
+ const name = 'formula-values';
176
+
177
+ const response = await fetch(`${configurationServiceUrl}/configuration/v2/configuration/${namespace}/${name}`, {
178
+ method: 'POST',
179
+ headers: {
180
+ Authorization: `Bearer ${accessToken}`,
181
+ 'Content-Type': 'application/json',
182
+ },
183
+ body: JSON.stringify({ operation: 'CREATE-REVISION' }),
184
+ });
185
+ const { latest } = await response.json();
186
+ ```
187
+
188
+ ### Set the active revision
189
+
80
190
  ```typescript
81
- const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
82
- const namespace = 'support';
83
- const name = 'formula-values';
84
-
85
- await fetch(
86
- `${configurationServiceUrl}/configuration/v2/configuration/${namespace}/${name}`,
87
- {
88
- method: 'POST',
89
- headers: {
90
- 'Authorization': `Bearer ${accessToken}`,
91
- 'Content-Type': 'application/json'
92
- },
93
- body: JSON.stringify({revision: true}),
94
- }
95
- );
191
+ const response = await fetch(`${configurationServiceUrl}/configuration/v2/configuration/${namespace}/${name}`, {
192
+ method: 'POST',
193
+ headers: {
194
+ Authorization: `Bearer ${accessToken}`,
195
+ 'Content-Type': 'application/json',
196
+ },
197
+ body: JSON.stringify({ operation: 'SET-ACTIVE-REVISION', revision: latest.revision }),
198
+ });
199
+ const { active } = await response.json();
96
200
  ```
@@ -15,22 +15,61 @@ client `urn:ads:platform:event-service`
15
15
  | name | description |
16
16
  | :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
17
17
  | 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. |
18
- | 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. |
18
+ | event-admin | Administrator role for managing the tenant's event definitions. It is part of the tenant-admin composite role. |
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 not part of the tenant-admin composite role. |
19
20
 
20
- ## Concepts
21
+ Some endpoints also accept roles of other platform services, so that existing accounts keep working:
21
22
 
22
- ### Event definition
23
+ - Reading event definitions accepts the configuration service `urn:ads:platform:configuration-service:configuration-reader` role as well as `event-admin`.
24
+ - Counting events accepts the value service `urn:ads:platform:value-service:value-reader` role as well as `event-reader`.
25
+
26
+ ## Tenancy
27
+
28
+ - **Tenant users and service accounts** always act on the tenant of their token. A `tenantId` query parameter, or a `tenantId` property in a sent event, is ignored.
29
+ - **Core (platform) service accounts** have no tenant of their own. To send an event on behalf of a tenant, they set `tenantId` to the tenant URN, either in the event body (`"tenantId": "urn:ads:platform:tenant-service:v2:/tenants/{id}"`) or as the `tenantId` query parameter; the query parameter takes precedence. Without either, sending an event responds `400`. Platform services such as form service use this to send their events in the tenant they act for.
30
+ - **Other endpoints** take the tenant from the `tenantId` query parameter for core users. Counting events and changing event definitions respond `400` without it. Reading event definitions without it returns only core definitions.
31
+ - **Event definitions** combine _core_ definitions (registered by platform services for all tenants) with the tenant's own definitions. The definitions API lists both, marked with `isCore`, and can only create, update, or delete tenant definitions. When an event is sent, a core namespace replaces a tenant namespace with the same name, so tenants should use their own namespace names.
32
+ - **Events and the event log** are tenant scoped. Subscribers such as notification service only act on an event for the tenant it was sent in, and event counts only include the tenant's events.
23
33
 
24
- 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.
34
+ ## API overview
35
+
36
+ All endpoints are under `https://event-service.adsp.alberta.ca/event/v1`. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
37
+
38
+ | Endpoint | Purpose | Required role |
39
+ | :------------------------------------------------ | :----------------------------------------------------------------------- | :------------------------------------------------------------ |
40
+ | `POST /event/v1/events` | Send a domain event. | `event-sender` |
41
+ | `GET /event/v1/events/count` | Count events in the event log matching criteria. | `event-reader` or value service `value-reader` |
42
+ | `GET /event/v1/definitions` | List tenant and core event definitions. | `event-admin` or configuration service `configuration-reader` |
43
+ | `GET /event/v1/definitions/{namespace}/{name}` | Read one tenant or core event definition. | `event-admin` or configuration service `configuration-reader` |
44
+ | `POST /event/v1/definitions` | Create a tenant event definition. | `event-admin` |
45
+ | `PATCH /event/v1/definitions/{namespace}/{name}` | Replace the description and payload schema of a tenant event definition. | `event-admin` |
46
+ | `DELETE /event/v1/definitions/{namespace}/{name}` | Delete a tenant event definition. | `event-admin` |
47
+
48
+ Event service has no endpoints for reading event log entries. The event log is stored in the [value service](value-service.md) and is searched with the value API (see [Search the event log](#search-the-event-log)).
49
+
50
+ ## Concepts
25
51
 
26
52
  ### Event
27
53
 
28
54
  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.
29
55
 
56
+ An event is identified by its `namespace` and `name` (each 1 to 50 characters), and includes the `timestamp` when it occurred and a `payload` object. An optional `correlationId` and `context` object let receivers match related events; for example, the event log uses them to find the start of an interval.
57
+
58
+ ### Event definition
59
+
60
+ Event definition is an optional metadata description of a _domain event_ (identified by a specific namespace and name). It includes a description and a `payloadSchema`, which is a JSON schema of the event payload.
61
+
62
+ - **Payload validation.** When an event is sent and a definition exists for its namespace and name, its payload is validated against the payload schema, and an invalid payload responds `400` without sending the event. Events without a definition are _ad hoc_ events: they are sent and logged without validation.
63
+ - **Downstream use.** The payload schema allows the [notification service](notification-service.md) to validate variables within notification message templates.
64
+ - **Storage.** Event definitions are stored in the [configuration service](configuration-service.md) under the `platform:event-service` namespace and name, as a map of namespaces that each contain their definitions. They can be managed with the `/event/v1/definitions` endpoints or with the configuration API. Changes may take a few minutes to apply to sent events because the configuration is cached.
65
+ - **Platform options.** Core definitions registered by platform services can also set `interval`, to record the duration since an earlier correlated event as a metric, and `log.skip`, to leave the event out of the event log.
66
+
30
67
  ### Event log
31
68
 
32
69
  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.
33
70
 
71
+ The event log is stored in the [value service](value-service.md) as the `event-service:event` value. After an event is sent, event service writes a value with the event `correlationId`, the event `context` extended with its `namespace`, `name`, and trace ID, and the event `payload` as `value.payload`. Each entry adds to the `total:count` and `<namespace>:<name>:count` metrics. Events in the `value-service` namespace, and events whose definition sets `log.skip`, are not logged. Logging happens asynchronously, so an event appears in the log shortly after it is sent.
72
+
34
73
  In the tenant management app, the Event log page initially searches **Last 7 days**, covering the preceding 168 hours through the current time, with both UTC timestamp boundaries included in the API request. The date range filter also offers **Last hour**, **Today**, **Last 24 hours**, **Last 30 days**, and **Custom**. Today starts at midnight in Mountain Time (`America/Edmonton`, including daylight saving time). Rolling periods cover the indicated number of elapsed hours or 24-hour days, ending when Search is clicked.
35
74
 
36
75
  Select a period and click **Search** to apply it along with any other filters. Start and end date/time controls display the selected period in Mountain Time. They are disabled for predefined periods and editable for **Custom**, initially filled with the selected period. The end must be later than the start. **Reset** clears other filters and immediately searches Last 7 days again. Removing the date range chip clears the selected period and searches without a lower date limit, retaining other applied filters. Pagination pins an upper timestamp at search time so new events do not shift the result pages or count. Search is disabled when no criteria are selected. An empty result displays **No Events Found**.
@@ -39,11 +78,55 @@ Select a period and click **Search** to apply it along with any other filters. S
39
78
 
40
79
  Event service also records security-sensitive `access-service` (Keycloak) events in the [audit service](audit-service.md). See [access service audit actions](access-service.md#audit-actions).
41
80
 
81
+ ## Events
82
+
83
+ Event service does not define domain events of its own. It routes the events sent to it over RabbitMQ to subscribers, such as the [notification service](notification-service.md) and the [push service](push-service.md).
84
+
85
+ It consumes:
86
+
87
+ - every sent domain event, to write it to the event log;
88
+ - `access-service` events, to record audit entries in the [audit service](audit-service.md);
89
+ - configuration update notifications, to clear its cached configuration, including event definitions.
90
+
42
91
  ## Code examples
43
92
 
93
+ ### Create an event definition
94
+
95
+ ```typescript
96
+ const eventServiceUrl = 'https://event-service.adsp.alberta.ca';
97
+
98
+ const response = await fetch(`${eventServiceUrl}/event/v1/definitions`, {
99
+ method: 'POST',
100
+ headers: {
101
+ Authorization: `Bearer ${accessToken}`,
102
+ 'Content-Type': 'application/json',
103
+ },
104
+ body: JSON.stringify({
105
+ namespace: 'support-program',
106
+ name: 'application-submitted',
107
+ description: 'Signalled when an application is submitted.',
108
+ payloadSchema: {
109
+ type: 'object',
110
+ properties: {
111
+ application: {
112
+ type: 'object',
113
+ properties: { id: { type: 'string' } },
114
+ required: ['id'],
115
+ },
116
+ },
117
+ required: ['application'],
118
+ },
119
+ }),
120
+ });
121
+
122
+ const { namespace, name, isCore } = await response.json();
123
+ ```
124
+
125
+ Send `description: null` when there is no description. A definition that already exists responds `409`; use `PATCH /event/v1/definitions/{namespace}/{name}` to change it.
126
+
44
127
  ### Configure an event definition
45
128
 
46
- Event definitions are configured using the [configuration service](configuration-service.md). Note that new configuration may take up to 15 mins to apply.
129
+ Event definitions can also be configured using the [configuration service](configuration-service.md). Note that new configuration may take up to 15 mins to apply.
47
130
 
48
131
  ```typescript
49
132
  const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
@@ -81,38 +164,60 @@ await fetch(`${configurationServiceUrl}/configuration/v2/configuration/platform/
81
164
  ### Send an event
82
165
 
83
166
  ```typescript
84
- const event = {
167
+ const event = {
168
+ namespace: 'support-program',
169
+ name: 'application-submitted',
170
+ timestamp: '2021-10-12T15:03:50Z',
171
+ correlationId: 'f669be59-bd38-4ca4-8749-19248060fc63',
172
+ context: {},
173
+ payload: {
174
+ application: {
175
+ id: 'f669be59-bd38-4ca4-8749-19248060fc63',
176
+ /* ... */
177
+ },
178
+ applicant: {
179
+ id: 'a8e5ec09-d60a-4c60-94bd-71dc97d8c80e',
180
+ username: 'testy.mctester@acme.com',
181
+ },
182
+ },
183
+ };
184
+
185
+ const response = await fetch('https://event-service.adsp.alberta.ca/event/v1/events', {
186
+ method: 'POST',
187
+ headers: {
188
+ Authorization: `Bearer ${accessToken}`,
189
+ 'Content-Type': 'application/json',
190
+ },
191
+ body: JSON.stringify(event),
192
+ });
193
+
194
+ // 200 when sent; 400 with an errorMessage when the payload does not match the event definition.
195
+ const sent = response.ok;
196
+ ```
197
+
198
+ ### Send an event on behalf of a tenant
199
+
200
+ A core (platform) service account sets the tenant of the event with `tenantId`. Tenant service accounts don't need it.
201
+
202
+ ```typescript
203
+ await fetch('https://event-service.adsp.alberta.ca/event/v1/events', {
204
+ method: 'POST',
205
+ headers: {
206
+ Authorization: `Bearer ${coreServiceAccountToken}`,
207
+ 'Content-Type': 'application/json',
208
+ },
209
+ body: JSON.stringify({
210
+ tenantId: 'urn:ads:platform:tenant-service:v2:/tenants/61f2e3a8c9b1d2e3f4a5b6c7',
85
211
  namespace: 'support-program',
86
212
  name: 'application-submitted',
87
- timestamp: '2021-10-12T15:03:50Z',
88
- correlationId: 'f669be59-bd38-4ca4-8749-19248060fc63',
89
- context: {
90
- },
91
- payload: {
92
- application: {
93
- id: 'f669be59-bd38-4ca4-8749-19248060fc63',
94
- /* ... */
95
- }
96
- applicant: {
97
- id: 'a8e5ec09-d60a-4c60-94bd-71dc97d8c80e',
98
- username: 'testy.mctester@acme.com',
99
- }
100
- }
101
- }
102
-
103
- await fetch(
104
- 'https://event-service.adsp.alberta.ca/event/v1/events',
105
- {
106
- method: 'POST',
107
- headers: {
108
- 'Authorization': `Bearer ${accessToken}`,
109
- 'Content-Type': 'application/json',
110
- },
111
- body: JSON.stringify(event),
112
- }
113
- );
213
+ timestamp: new Date().toISOString(),
214
+ payload: { application: { id: 'f669be59-bd38-4ca4-8749-19248060fc63' } },
215
+ }),
216
+ });
114
217
  ```
115
218
 
219
+ Platform services built with the [Node.js SDK](../platform/platform-node-sdk.md) register their events with the `events` option of `initializePlatform`, which makes them core event definitions, and send them with the SDK `eventService`, which sets `tenantId` in the body for core services.
220
+
116
221
  ### Search the event log
117
222
 
118
223
  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.