@abgov/adsp-sdk-mcp-server 1.20.2 → 1.22.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.
Files changed (55) hide show
  1. package/README.md +23 -0
  2. package/assets/docs/platform/deployment.md +0 -1
  3. package/assets/docs/platform/getting-started.md +0 -1
  4. package/assets/docs/platform/operations.md +0 -1
  5. package/assets/docs/platform/platform-django-sdk.md +0 -1
  6. package/assets/docs/platform/platform-dotnet-sdk.md +0 -1
  7. package/assets/docs/platform/platform-flask-sdk.md +0 -1
  8. package/assets/docs/platform/platform-node-sdk.md +0 -1
  9. package/assets/docs/platform/platform-spring-sdk.md +0 -1
  10. package/assets/docs/services/access-service-backup-disaster-recovery.md +0 -1
  11. package/assets/docs/services/access-service.md +0 -1
  12. package/assets/docs/services/agent-service.md +0 -1
  13. package/assets/docs/services/cache-service.md +111 -24
  14. package/assets/docs/services/calendar-service.md +96 -18
  15. package/assets/docs/services/comment-service.md +179 -49
  16. package/assets/docs/services/configuration-service.md +0 -1
  17. package/assets/docs/services/directory-service.md +129 -16
  18. package/assets/docs/services/event-service.md +0 -1
  19. package/assets/docs/services/export-service.md +135 -0
  20. package/assets/docs/services/feedback-service.md +46 -10
  21. package/assets/docs/services/file-service.md +0 -1
  22. package/assets/docs/services/form-service.md +0 -1
  23. package/assets/docs/services/notification-service.md +0 -1
  24. package/assets/docs/services/pdf-service.md +113 -44
  25. package/assets/docs/services/pii-service.md +0 -1
  26. package/assets/docs/services/project-planner-service.md +215 -43
  27. package/assets/docs/services/push-service.md +159 -73
  28. package/assets/docs/services/status-service.md +0 -1
  29. package/assets/docs/services/task-service.md +262 -99
  30. package/assets/docs/services/tenant-service.md +113 -2
  31. package/assets/docs/services/token-handler.md +0 -1
  32. package/assets/docs/services/value-service.md +13 -1
  33. package/assets/docs/services/verify-service.md +60 -36
  34. package/assets/docs/tutorials/access-service/access-service.md +0 -1
  35. package/assets/docs/tutorials/feedback-service/feedback-service.md +0 -1
  36. package/assets/docs/tutorials/file-service/file-service.md +0 -1
  37. package/assets/docs/tutorials/form-service/form-service.md +0 -1
  38. package/assets/docs/tutorials/notification-service/notification-service.md +0 -1
  39. package/assets/docs/tutorials/pdf-service/building-a-template.md +2 -2
  40. package/assets/docs/tutorials/pdf-service/generate-a-pdf.md +17 -10
  41. package/assets/docs/tutorials/pdf-service/pdf-service.md +0 -1
  42. package/assets/docs/tutorials/status-service/status-service.md +0 -1
  43. package/assets/docs/tutorials/task-service/introduction.md +1 -1
  44. package/assets/docs/tutorials/task-service/task-definitions.md +1 -1
  45. package/assets/docs/tutorials/task-service/task-queues.md +13 -11
  46. package/assets/docs/tutorials/task-service/task-service.md +0 -1
  47. package/package.json +1 -1
  48. package/src/http.d.ts +3 -0
  49. package/src/http.js +68 -0
  50. package/src/http.js.map +1 -0
  51. package/src/main.js +3 -83
  52. package/src/main.js.map +1 -1
  53. package/src/server.d.ts +6 -0
  54. package/src/server.js +17 -6
  55. package/src/server.js.map +1 -1
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Comment service
4
- nav_order: 16
5
4
  parent: Services
6
5
  ---
7
6
 
@@ -18,70 +17,201 @@ client `urn:ads:platform:comment-service`
18
17
  | comment-admin | Administrator role that grants permission to administer topics and comments. |
19
18
  | topic-setter | Topic setter role that grants permissions to managed topics. |
20
19
 
21
- Topic administer, read, or comment access is controlled by configuration of `adminRoles`, `readerRoles`, and `commenterRoles` on each topic type.
20
+ These client roles grant the following:
21
+
22
+ - **comment-admin** is an administrator of every topic type of the tenant: it can read and comment on any topic, and update or delete any comment. It can also manage topic types and topics, and search comments across topics with `GET /comments`. It is included in the tenant admin role.
23
+ - **topic-setter** is for the applications and service accounts that set up topics. It can manage topic types, create, update, and delete topics, and read any topic and its comments. It doesn't grant permission to post comments.
24
+
25
+ Both roles also work as core (platform) roles for managing topic types and topics, and reading topics. Comment and administrator access through a topic type (below) requires a role held in the tenant.
26
+
27
+ ### Topic type roles
28
+ Access to the comments of a topic is mostly set by its *topic type*, which configures three lists of roles. The roles are any roles of the tenant's users, for example realm roles or client roles of the tenant's own applications. A user needs one of the roles, held in the topic's tenant:
29
+
30
+ | Topic type property | Permits |
31
+ |:-|:-|
32
+ | `adminRoles` | Read topics of the type, post comments, and update or delete any comment. The comment-admin role always has this access. |
33
+ | `commenterRoles` | Read topics of the type, post comments, and update or delete the user's own comments. |
34
+ | `readerRoles` | Read topics of the type and their comments. |
35
+
36
+ A topic can also list user IDs in its `commenters`, for people outside these roles, like the person a case is about. Commenters can read the topic and post comments, and update or delete their own comments. Comments returned to them have the names of other users removed.
37
+
38
+ Two roles of other platform services also apply:
39
+
40
+ - The [directory service](directory-service.md) `urn:ads:platform:directory-service:resource-resolver` role can retrieve any topic, so that topic URNs resolve to their names.
41
+ - The export service `urn:ads:platform:export-service:export-job` role can list all topics and search comments, so topics and comments can be exported.
42
+
43
+ ## Tenancy
44
+ Topic types, topics, and comments all belong to one tenant.
45
+
46
+ - **Tenant users and service accounts** always act on the tenant of their token. Any `tenantId` query parameter is ignored.
47
+ - **Core (platform) users and service accounts** have no tenant of their own, so they must set the `tenantId` query parameter (for example, `?tenantId=urn:ads:platform:tenant-service:v2:/tenants/{id}`) on every request. A value that isn't a tenant URN responds `400`. Only `GET /topic-types` handles a missing tenant, by returning just the platform topic types; other endpoints fail without a clear error, so always include it.
48
+ - **Topic types** combine *platform* types (configured by ADSP for all tenants) with the tenant's own types. A tenant type with the same ID as a platform type replaces it. Topics can use either. `GET /topic-types` returns them separately as `tenant` and `core`, while `GET`, `PATCH`, and `DELETE /topic-types/{topicTypeId}` act only on the tenant's own types, so platform types respond `404` there.
49
+ - **Isolation.** A topic or comment ID from another tenant responds `404`, not `403`, so callers can't tell whether it exists.
50
+ - **Role scope.** Roles in a topic type's `adminRoles`, `commenterRoles`, and `readerRoles`, and the comment-admin role for comments, must be held in the topic's tenant. The comment-admin and topic-setter roles grant topic type and topic management, and reading topics, as core roles too. `GET /comments` accepts only tenant roles.
51
+
52
+ ## API overview
53
+ All endpoints are under `https://comment-service.adsp.alberta.ca/comment/v1` and require a bearer token. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
54
+
55
+ | Area | Endpoints | Required role |
56
+ |:-|:-|:-|
57
+ | Topic types | `GET /topic-types`, `POST /topic-types`, `GET\|PATCH\|DELETE /topic-types/{topicTypeId}` | comment-admin or topic-setter |
58
+ | Topics | `GET /topics` | Any authenticated user; results include only topics the user can read |
59
+ | | `POST /topics`, `PATCH\|DELETE /topics/{topicId}` | comment-admin or topic-setter |
60
+ | | `GET /topics/{topicId}` | Read access to the topic (see [Topic type roles](#topic-type-roles)), comment-admin, topic-setter, or the directory resource-resolver |
61
+ | Topic comments | `GET /topics/{topicId}/comments`, `GET /topics/{topicId}/comments/{commentId}` | Read access to the topic, comment-admin, or topic-setter |
62
+ | | `POST /topics/{topicId}/comments` | Comment access to the topic: the type's `adminRoles` or `commenterRoles`, comment-admin, or listed in the topic's `commenters` |
63
+ | | `PATCH\|DELETE /topics/{topicId}/comments/{commentId}` | The type's `adminRoles` or comment-admin, or the comment's author with comment access |
64
+ | Comment search | `GET /comments` | comment-admin or export-job; with `criteria.typeIdEquals`, read access to the type instead |
65
+
66
+ Topic types are stored in the [configuration service](configuration-service.md). The `/topic-types` endpoints read and write that configuration for you, and you can also edit it there directly.
22
67
 
23
68
  ## Concepts
24
69
  ### Topic type
25
- Topic type is configuration for a category of *topics*. The type includes configuration of roles allowed to administer, read, or comment on topics of the type. Topic types are configured in the [configuration service](configuration-service.md) under the `platform:comment-service` namespace and name.
70
+ Topic type is configuration for a category of *topics*. The type includes configuration of roles allowed to administer, read, or comment on topics of the type (see [Topic type roles](#topic-type-roles)), and the security classification of new topics of the type. Topic types are configured in the [configuration service](configuration-service.md) under the `platform:comment-service` namespace and name, keyed by type ID. A topic type can't be deleted while topics of the type exist.
26
71
 
27
72
  ### Topic
28
- Topics are aggregate roots of *comments* and represent the subject of associated *comments*. Topics are intended to reference entities in other domain models so that comments can be recorded against any entity.
73
+ Topics are aggregate roots of *comments* and represent the subject of associated *comments*. Topics are intended to reference entities in other domain models so that comments can be recorded against any entity, using `resourceId`. Each topic has a URN (`urn:ads:platform:comment-service:v1:/topics/{id}`) that the [directory service](directory-service.md) can resolve. A topic's `requiresAttention` flag is set or cleared by the `requiresAttention` value of a new comment, for example so that a worker can find topics with unanswered questions. Deleting a topic also deletes its comments.
29
74
 
30
75
  ### Comment
31
- Comments represent user authored descriptive information regarding a *topic* like notes or discussions.
76
+ Comments represent user authored descriptive information regarding a *topic* like notes or discussions. A comment has an optional `title`, `content`, and an optional `context` object for application data, such as the step of a process the comment is about.
77
+
78
+ ## Events
79
+ The comment service sends the following domain events under the `comment-service` namespace. Each event includes the topic, and the comment events also include the comment. The correlation ID is the topic's `resourceId`, or the topic URN when it has none.
80
+
81
+ | Event | Description |
82
+ |:-|:-|
83
+ | `topic-created` | Signalled when a topic is created. |
84
+ | `topic-updated` | Signalled when a topic is updated. |
85
+ | `topic-deleted` | Signalled when a topic is deleted. |
86
+ | `comment-created` | Signalled when a comment is created. |
87
+ | `comment-updated` | Signalled when a comment is updated. |
88
+ | `comment-deleted` | Signalled when a comment is deleted. |
89
+
90
+ The service doesn't consume events from other services. Changes to topic types are configuration updates, recorded by the [configuration service](configuration-service.md).
32
91
 
33
92
  ## Code examples
93
+ ### Create a topic type
94
+ Users or service accounts with the comment-admin or topic-setter role can create topic types for their tenant. The new type's commenter roles are set with `writeRoles`, and it has no admin roles until you update it. The service responds `409` if a type with the ID or name already exists.
95
+
96
+ ```typescript
97
+ const response = await fetch('https://comment-service.adsp.alberta.ca/comment/v1/topic-types', {
98
+ method: 'POST',
99
+ headers: {
100
+ Authorization: `Bearer ${accessToken}`,
101
+ 'Content-Type': 'application/json',
102
+ },
103
+ body: JSON.stringify({
104
+ id: 'case-notes',
105
+ name: 'Case notes',
106
+ readerRoles: ['case-auditor'],
107
+ writeRoles: ['case-worker'],
108
+ }),
109
+ });
110
+
111
+ const { id, name, readerRoles, commenterRoles } = await response.json();
112
+ ```
113
+
114
+ ### Update the roles of a topic type
115
+ Properties not in the request keep their values.
116
+
117
+ ```typescript
118
+ const response = await fetch('https://comment-service.adsp.alberta.ca/comment/v1/topic-types/case-notes', {
119
+ method: 'PATCH',
120
+ headers: {
121
+ Authorization: `Bearer ${accessToken}`,
122
+ 'Content-Type': 'application/json',
123
+ },
124
+ body: JSON.stringify({
125
+ adminRoles: ['case-supervisor'],
126
+ securityClassification: 'protected b',
127
+ }),
128
+ });
129
+
130
+ const { adminRoles, commenterRoles, readerRoles, securityClassification } = await response.json();
131
+ ```
34
132
 
35
133
  ### Create a topic
36
- Create a topic referencing a case so that comments on the case can be created. `typeId` is the ID of a configured Topic type.
134
+ Create a topic referencing a case so that comments on the case can be created. `typeId` is the ID of a configured topic type. A platform service account also sets the `tenantId` query parameter.
37
135
 
38
136
  ```typescript
39
- const response = await fetch(
40
- 'https://comment-service.adsp.alberta.ca/comment/v1/topics',
41
- {
42
- method: 'POST',
43
- headers: {
44
- 'Authorization': `Bearer ${accessToken}`,
45
- },
46
- body: {
47
- typeId: 'case-notes',
48
- name: 'Comments on Case-123'
49
- resourceId: 'urn:ads:demo:case-services:v1:/cases/case-123'
50
- },
51
- }
52
- );
53
-
54
- const {
55
- id,
56
- urn,
57
- name,
58
- resourceId,
59
- securityClassification
60
- } = await response.json();
137
+ const response = await fetch('https://comment-service.adsp.alberta.ca/comment/v1/topics', {
138
+ method: 'POST',
139
+ headers: {
140
+ Authorization: `Bearer ${accessToken}`,
141
+ 'Content-Type': 'application/json',
142
+ },
143
+ body: JSON.stringify({
144
+ typeId: 'case-notes',
145
+ name: 'Comments on case-123',
146
+ resourceId: 'urn:ads:demo:case-service:v1:/cases/case-123',
147
+ }),
148
+ });
149
+
150
+ const { id, urn, name, resourceId, securityClassification } = await response.json();
151
+ ```
152
+
153
+ ### Find the topic of an entity
154
+ Criteria are URL-encoded JSON. Results include only the topics the user can read.
155
+
156
+ ```typescript
157
+ const criteria = JSON.stringify({ resourceIdEquals: 'urn:ads:demo:case-service:v1:/cases/case-123' });
158
+ const response = await fetch(
159
+ `https://comment-service.adsp.alberta.ca/comment/v1/topics?criteria=${encodeURIComponent(criteria)}`,
160
+ {
161
+ headers: { Authorization: `Bearer ${accessToken}` },
162
+ }
163
+ );
164
+
165
+ const { results, page } = await response.json();
166
+ const topicId = results[0]?.id;
61
167
  ```
62
168
 
63
169
  ### Add a comment to a topic
64
- Add a comment against an existing topic, so that it can be retrieved and read later.
170
+ Add a comment against an existing topic, so that it can be retrieved and read later. Set `requiresAttention` to flag the topic for follow up.
65
171
 
66
172
  ```typescript
67
- const response = await fetch(
68
- `https://comment-service.adsp.alberta.ca/comment/v1/topics/${topicId}/comments`,
69
- {
70
- method: 'POST',
71
- headers: {
72
- 'Authorization': `Bearer ${accessToken}`,
73
- },
74
- body: {
75
- title,
76
- comment
77
- },
78
- }
79
- );
80
-
81
- const {
82
- id,
83
- title,
84
- comment,
85
- createdBy
86
- } = await response.json();
173
+ const response = await fetch(`https://comment-service.adsp.alberta.ca/comment/v1/topics/${topicId}/comments`, {
174
+ method: 'POST',
175
+ headers: {
176
+ Authorization: `Bearer ${accessToken}`,
177
+ 'Content-Type': 'application/json',
178
+ },
179
+ body: JSON.stringify({
180
+ title: 'Follow up call',
181
+ content: 'Called the applicant to confirm the mailing address.',
182
+ requiresAttention: true,
183
+ }),
184
+ });
185
+
186
+ const { id, title, content, createdBy, createdOn } = await response.json();
187
+ ```
188
+
189
+ ### Read the comments of a topic
190
+ Comments are returned newest first. Use `page.next` as the `after` value to get the next page.
191
+
192
+ ```typescript
193
+ const response = await fetch(
194
+ `https://comment-service.adsp.alberta.ca/comment/v1/topics/${topicId}/comments?top=20`,
195
+ {
196
+ headers: { Authorization: `Bearer ${accessToken}` },
197
+ }
198
+ );
199
+
200
+ const { results, page } = await response.json();
201
+ const nextPage = page.next;
202
+ ```
203
+
204
+ ### Search comments of a topic type
205
+ Users who can read a topic type can search comments across its topics. Without `typeIdEquals`, the search requires the comment-admin role.
206
+
207
+ ```typescript
208
+ const criteria = JSON.stringify({ typeIdEquals: 'case-notes', titleOrContentLike: 'address' });
209
+ const response = await fetch(
210
+ `https://comment-service.adsp.alberta.ca/comment/v1/comments?criteria=${encodeURIComponent(criteria)}`,
211
+ {
212
+ headers: { Authorization: `Bearer ${accessToken}` },
213
+ }
214
+ );
215
+
216
+ const { results, page } = await response.json();
87
217
  ```
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Configuration service
4
- nav_order: 4
5
4
  parent: Services
6
5
  ---
7
6
 
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Directory service
4
- nav_order: 3
5
4
  parent: Services
6
5
  ---
7
6
 
@@ -13,50 +12,164 @@ Directory service is a register of services and APIs. It allows you to find serv
13
12
 
14
13
  client `urn:ads:platform:directory-service`
15
14
 
16
- | name | description |
17
- | :-------------- | :----------------------------------------------------------------------------------------------------- |
18
- | directory-admin | Administrator role for directory service. This role allows administrators to modify directory entries. |
19
- | resource-browser| Resource browser role for the directory service that grants access to resources and tags. |
20
- | resource-tagger | Resource tagger role for the directory service that allows tagging and untagging resources. |
21
- | resource-resolver | Resource resolver used by the directory. Resource APIs should give read access to the role. |
15
+ | name | description |
16
+ | :---------------- | :------------------------------------------------------------------------------------------------------------------------ |
17
+ | directory-admin | Administrator role for directory service. Allows adding, updating, and deleting entries, and deleting tags and resources. |
18
+ | resource-browser | Resource browser role for the directory service that grants access to resources and tags. |
19
+ | resource-tagger | Resource tagger role for the directory service that allows tagging and untagging resources. Also grants read access. |
20
+ | resource-resolver | Resource resolver used by the directory. Resource APIs should give read access to the role. |
22
21
 
23
- The directory service API allows anonymous read access of entries.
22
+ The directory-admin, resource-browser, and resource-tagger roles are part of the tenant admin role.
23
+
24
+ Reading directory entries does not require a token; the directory API allows anonymous read access.
25
+
26
+ ## Tenancy
27
+
28
+ Each tenant has a directory **namespace** named after the tenant: the tenant name in kebab case (for example `test-tenant` for the tenant named Test Tenant). Platform services are registered in the `platform` namespace, which is the namespace the SDK reads.
29
+
30
+ - **Directory API (`/directory/v2`)**: the namespace in the path selects the tenant. The directory looks up the tenant by name (hyphens read as spaces, ignoring case) and responds `404` if no tenant has that name.
31
+ - Reads are anonymous, so any caller can read the entries of any namespace.
32
+ - Writes require the directory-admin role held by a user or service account **of the namespace's tenant**. Core (platform) users and users of other tenants receive `403`. `POST /namespaces` creates the namespace of the caller's own tenant, so it also requires a tenant user or service account.
33
+ - **Resource API (`/resource/v1`)**: tags and resources belong to one tenant, and tenant users always act on the tenant of their token. A tag or resource of another tenant responds `404`, is left out of lists, and deletes respond `deleted: false`; the directory never responds `403` for it.
34
+ - Core (platform) users are refused (`403`) by all resource endpoints except `GET /tags/{tag}`, which allows core users with the resource-browser, resource-tagger, or resource-resolver role. They act on the tenant given by the `tenantId` query parameter, and on platform tags without it.
35
+ - **Resource types** are configured in the [configuration service](configuration-service.md) under `platform:directory-service`. The directory combines the platform (core) configuration with the tenant's configuration by API; where both configure the same API, the platform configuration is used.
36
+
37
+ ## API overview
38
+
39
+ The directory API is under `https://directory-service.adsp.alberta.ca/directory/v2` and the resource API is under `https://directory-service.adsp.alberta.ca/resource/v1`. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
40
+
41
+ | Area | Endpoints | Required role |
42
+ | :---------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------- |
43
+ | Directory entries | `GET /directory/v2/namespaces/{namespace}/entries`, `GET .../services/{service}`, `GET .../services/{service}/apis`, `GET .../services/{service}/apis/{api}` | None (anonymous) |
44
+ | | `POST /directory/v2/namespaces` | directory-admin |
45
+ | | `POST .../services`, `PATCH\|DELETE .../services/{service}`, `POST .../services/{service}/apis`, `PATCH\|DELETE .../services/{service}/apis/{api}` | directory-admin in the namespace's tenant |
46
+ | Tags | `GET /resource/v1/tags`, `GET /resource/v1/tags/{tag}/resources` | resource-browser or resource-tagger |
47
+ | | `GET /resource/v1/tags/{tag}` | resource-browser, resource-tagger, or resource-resolver (core users allowed) |
48
+ | | `POST /resource/v1/tags` (tag and untag) | resource-tagger |
49
+ | | `DELETE /resource/v1/tags/{tag}` | directory-admin |
50
+ | Resources | `GET /resource/v1/resources`, `GET /resource/v1/resources/{resource}`, `GET /resource/v1/resources/{resource}/tags` | resource-browser or resource-tagger |
51
+ | | `DELETE /resource/v1/resources/{resource}` | directory-admin |
52
+
53
+ `...` stands for `/directory/v2/namespaces/{namespace}`. Resource URNs in paths must be URL encoded. Resource types have no endpoints of their own; they are managed through the [configuration service](configuration-service.md).
24
54
 
25
55
  ## Concepts
26
56
 
27
57
  ### Entry
28
- Entries represent a registered service or API in the directory. Tenant entries are created under a tenant namespace based on the tenant name.
58
+
59
+ Entries represent a registered service or API in the directory. Tenant entries are created under a tenant namespace based on the tenant name. A service entry is named after the service (for example `form-service`), and an API entry is named `{service}:{api}` (for example `form-service:v1`). The URN of an entry is `urn:ads:{namespace}:{service}` or `urn:ads:{namespace}:{service}:{api}`. An API entry can exist without its service entry.
60
+
61
+ ### Service metadata
62
+
63
+ Services can publish metadata, such as their name, description, and links to their APIs and documentation, at the service URL. `GET .../services/{service}` returns the service entry with that metadata, which the directory retrieves from the service and caches for 5 minutes.
29
64
 
30
65
  ### Resource
66
+
31
67
  A resource is something addressable at a path under an API registered in the directory that can be tagged. The directory does not understand the domain specific concept represented by each resource, but supports tagging and untagging resources so that resources across different APIs can be categorized and group together.
32
68
 
33
69
  #### URN convention
70
+
34
71
  The directory uses a URN convention to resolve full request paths to resources. The resource URN is expected to be in the form `urn:ads:{namespace}:{service}:{api}:{resource}`, and the resource segment is assumed to be the relative path under the API. The directory looks up the API URL, then joins the resource path under the API path for the resource URL.
35
72
 
36
- For example `urn:ads:platform:file-service:v1:/files/ff118afa-f74e-44ac-8866-7ebd5a43cb4c` resolves to API URL `https://file-service.adsp.alberta.ca/file/v1` and resource path `/files/ff118afa-f74e-44ac-8866-7ebd5a43cb4c` resulting in resource URL of `https://file-service.adsp.alberta.ca/file/v1//files/ff118afa-f74e-44ac-8866-7ebd5a43cb4c`.
73
+ For example `urn:ads:platform:file-service:v1:/files/ff118afa-f74e-44ac-8866-7ebd5a43cb4c` resolves to API URL `https://file-service.adsp.alberta.ca/file/v1` and resource path `/files/ff118afa-f74e-44ac-8866-7ebd5a43cb4c` resulting in resource URL of `https://file-service.adsp.alberta.ca/file/v1/files/ff118afa-f74e-44ac-8866-7ebd5a43cb4c`.
37
74
 
38
75
  ### Resource type
39
- Resource types are configuration that tell the directory how to resolve the name and description of a resource from the return value of a GET request to the resource path on its associated API. They can indicate if a domain event represents the deletion of a resource, so that deletions can cascade to the directory.
76
+
77
+ Resource types are configuration that tell the directory how to resolve the name and description of a resource from the return value of a GET request to the resource path on its associated API. They can indicate if a domain event represents the deletion of a resource, so that deletions can cascade to the directory. When a new resource is tagged, the directory resolves its name, description, and type in the background, using the directory's own service account; resource APIs should give the resource-resolver role read access.
40
78
 
41
79
  ### Tag
42
- Tags are simple string labels that can be associated to resources, and can be used to represent categories and projects.
80
+
81
+ Tags are simple string labels that can be associated to resources, and can be used to represent categories and projects. Each tag has a `label` and a `value`; the value is the label in kebab case unless one is given, and identifies the tag in paths.
43
82
 
44
83
  ## Audit
84
+
45
85
  Directory service records an audit event when entries (services and APIs), namespaces, tags, or tagged resources are created, changed, or deleted. Reads and bootstrap seeding are not audited. Audit failures are logged by the SDK and do not fail the directory operation. The directory service account requires the `audit-writer` role of `urn:ads:platform:audit-service`.
46
86
 
47
87
  Audit recording is on by default. Set the environment variable `DIRECTORY_AUDIT_ENABLED=false` on directory service to turn it off, or `true` to turn it on regardless of the SDK `AUDIT_ENABLED` variable, which applies when `DIRECTORY_AUDIT_ENABLED` is not set. The action catalog is still registered while recording is off, so turning it back on needs only a restart.
48
88
 
89
+ ## Events
90
+
91
+ The directory service sends the following domain events under the `directory-service` namespace:
92
+
93
+ | Event | Description |
94
+ | :--------------------------- | :---------------------------------------------------------------- |
95
+ | `entry-updated` | A directory entry was added or its URL updated. |
96
+ | `entry-deleted` | A directory entry was deleted. |
97
+ | `tagged-resource` | A tag was added to a resource. |
98
+ | `untagged-resource` | A tag was removed from a resource. |
99
+ | `resource-deleted` | A resource was deleted. |
100
+ | `tag-deleted` | A tag was deleted. |
101
+ | `resource-resolution-failed` | A resource associated with a resource type could not be resolved. |
102
+
103
+ The `directory-entry-updates` stream in the [push service](push-service.md) provides the `entry-updated` and `entry-deleted` events to platform services.
104
+
105
+ The directory consumes its own `tagged-resource` events to resolve new resources, and the delete events configured on resource types to delete the matching resources.
106
+
49
107
  ## Code examples
50
108
 
51
- ### Reading the directory
109
+ ### Read the entries of a namespace
110
+
111
+ ```typescript
112
+ const response = await fetch('https://directory-service.adsp.alberta.ca/directory/v2/namespaces/platform/entries');
113
+
114
+ // Each entry has urn, url, service, and namespace.
115
+ const entries: { urn: string; url: string }[] = await response.json();
116
+ const formApi = entries.find(({ urn }) => urn === 'urn:ads:platform:form-service:v1');
117
+ ```
118
+
119
+ ### Register a service API
120
+
121
+ Users with the directory-admin role can add entries to the namespace of their tenant. The directory responds `409` if the entry already exists; use `PATCH` to change its URL.
122
+
123
+ ```typescript
124
+ const response = await fetch(
125
+ 'https://directory-service.adsp.alberta.ca/directory/v2/namespaces/test-tenant/services/case-service/apis',
126
+ {
127
+ method: 'POST',
128
+ headers: {
129
+ Authorization: `Bearer ${accessToken}`,
130
+ 'Content-Type': 'application/json',
131
+ },
132
+ body: JSON.stringify({ api: 'v1', url: 'https://case-service.test.gov.ab.ca/case/v1' }),
133
+ },
134
+ );
135
+
136
+ // Entry as stored, for example { service: 'case-service:v1', host: 'https://case-service.test.gov.ab.ca/case/v1' }.
137
+ const { service, host } = await response.json();
138
+ ```
139
+
140
+ ### Tag a resource
141
+
142
+ Users with the resource-tagger role can tag resources under APIs registered in the directory.
52
143
 
53
144
  ```typescript
54
- const response = await fetch('https://directory.adsp.alberta.ca/directory/v2/namespaces/platform/entries', {
55
- method: 'GET',
145
+ const response = await fetch('https://directory-service.adsp.alberta.ca/resource/v1/tags', {
146
+ method: 'POST',
56
147
  headers: {
57
148
  Authorization: `Bearer ${accessToken}`,
149
+ 'Content-Type': 'application/json',
58
150
  },
151
+ body: JSON.stringify({
152
+ operation: 'tag-resource',
153
+ tag: { label: 'Priority applications' },
154
+ resource: { urn: 'urn:ads:platform:file-service:v1:/files/ff118afa-f74e-44ac-8866-7ebd5a43cb4c' },
155
+ }),
59
156
  });
60
157
 
61
- const entries = await response.json();
158
+ // tagged is false if the resource already had the tag.
159
+ const { tagged, tag } = await response.json();
160
+ ```
161
+
162
+ ### Find the resources with a tag
163
+
164
+ ```typescript
165
+ const response = await fetch(
166
+ 'https://directory-service.adsp.alberta.ca/resource/v1/tags/priority-applications/resources?top=50&includeRepresents=true',
167
+ {
168
+ headers: { Authorization: `Bearer ${accessToken}` },
169
+ },
170
+ );
171
+
172
+ // _embedded.represents is the resource retrieved from its API, for resources that match a resource type.
173
+ const { results, page } = await response.json();
174
+ const next = page.next; // Pass as the after parameter for the next page.
62
175
  ```
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Event service
4
- nav_order: 5
5
4
  parent: Services
6
5
  ---
7
6
 
@@ -0,0 +1,135 @@
1
+ ---
2
+ layout: page
3
+ title: Export service
4
+ parent: Services
5
+ ---
6
+
7
+ # Export service
8
+
9
+ Export service exports API resources of other services to files. An application queues an export _job_ for a resource, such as the forms of a form definition, and the service reads every page of the resource in the background, writes the results as a CSV or JSON file, and uploads the file to the [file service](file-service.md). Applications poll the job, or listen for export events through the [push service](push-service.md), and then download the file.
10
+
11
+ ## Client roles
12
+
13
+ client `urn:ads:platform:export-service`
14
+
15
+ | name | description |
16
+ | :--------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
17
+ | exporter | Exporter role that allows creation of export jobs. It also allows reading jobs created by other users, reading the default `export-file` files, and subscribing to the `export-updates` stream. Included in the tenant admin role. |
18
+ | export-job | Export job role assigned to the export service service account. Services grant this role read access to the resources they allow to be exported. |
19
+
20
+ Services can also allow their own roles to export their resources. Export _sources_ in the `platform:export-service` configuration map a service or API URN to `exporterRoles`. For example, [form service](form-service.md) configures `urn:ads:platform:form-service` so that users with the `urn:ads:platform:form-service:form-admin` role can export forms without the exporter role.
21
+
22
+ ## Tenancy
23
+
24
+ - **Which tenant is used.** Tenant users and service accounts create jobs in the tenant of their token. Core users with the exporter role must set the `tenantId` query parameter when creating a job; the job is created in that tenant.
25
+ - **Reading the resource.** The job reads the resource with the export service's own service account, which has the `export-job` role, and passes the job's tenant as the `tenantId` query parameter. The requesting user's roles are checked when the job is created, not when the resource is read.
26
+ - **Role scope.** The exporter role, and any exporter roles configured for a source, must be held in the tenant of the request. A core user's exporter role also allows creating jobs.
27
+ - **Configuration.** Export sources are read from the `platform:export-service` configuration. When the platform (core) configuration has `sources`, such as the sources registered by form service, they replace the tenant's `sources` as a whole, so tenant sources apply only where there are no platform sources.
28
+ - **Export files** are uploaded to the job's tenant.
29
+ - **Reading jobs.** The user who created a job can always read it. Other users need the exporter role in the tenant of their token. Core users can read only the jobs they created.
30
+
31
+ ## API overview
32
+
33
+ All endpoints are under `https://export-service.adsp.alberta.ca/export/v1` and require a bearer token. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
34
+
35
+ | Endpoint | Purpose | Required role |
36
+ | :---------------------------- | :------------------------------------------ | :---------------------------------------------------------- |
37
+ | `POST /export/v1/jobs` | Queue a job to export a resource to a file. | `exporter`, or an exporter role configured for the resource |
38
+ | `GET /export/v1/jobs/{jobId}` | Get the status and result file of a job. | Creator of the job, or `exporter` |
39
+
40
+ Export files are downloaded through the [file service](file-service.md), and export sources are configured through the [configuration service](configuration-service.md); export service has no endpoints of its own for them.
41
+
42
+ ## Concepts
43
+
44
+ ### Export job
45
+
46
+ An export job is a request to export one resource. Creating a job queues it in a work queue and responds immediately with the job `id`, `urn`, and `status` of `queued`. The service then:
47
+
48
+ 1. resolves `resourceId` to a URL using the [directory service](directory-service.md);
49
+ 2. reads the resource 200 results at a time, using the `page.next` cursor of the response as `after` for the next page (up to 10,000 pages), with any `params` added to the query;
50
+ 3. takes the records from `resultsPath` (default `results`) of each response;
51
+ 4. writes the records in the `format` (`csv` or `json`) with its `formatOptions`, and uploads the file;
52
+ 5. sets the job `status` to `completed` with the file in `result`, or to `failed`.
53
+
54
+ Failed jobs are not retried. Job status is kept for 24 hours after it was last updated; after that the job responds 404.
55
+
56
+ ### Resource
57
+
58
+ The `resourceId` is the URN of an API resource, such as `urn:ads:platform:form-service:v1:/forms`. The resource must accept the `tenantId`, `top`, and `after` query parameters, and must allow the `urn:ads:platform:export-service:export-job` role. Form, task, value, comment, and configuration services grant the `export-job` role access to resources that support export.
59
+
60
+ ### Format
61
+
62
+ - **csv** flattens each record, so nested properties become columns such as `data.firstName`. Set `formatOptions.columns` to choose and order the columns, and to set headers: `[{ "key": "data.firstName", "header": "First name" }]`.
63
+ - **json** writes the records as a JSON array. Set `formatOptions.fields` to include only some properties, and `formatOptions.pretty` to indent the output.
64
+
65
+ ### Export file
66
+
67
+ By default, export files are uploaded with the `export-file` file type, which is Protected B, can be read by users with the exporter role, and is deleted after 30 days. Set `fileType` to upload to one of the tenant's own file types instead, for example to give different roles access. The file name is `filename` (default `exported`) with the extension of the format.
68
+
69
+ ## Events
70
+
71
+ Export service sends these events in the `export-service` namespace. The job ID is the event `correlationId`.
72
+
73
+ | Event | Description |
74
+ | :----------------- | :---------------------------------------------------------------------------------------- |
75
+ | `export-queued` | A job is queued. Includes `jobId`, `resourceId`, `format`, `filename`, and `requestedBy`. |
76
+ | `export-completed` | A job is completed. Includes the `file` (`id`, `urn`, and `filename`) and `requestedBy`. |
77
+ | `export-failed` | A job failed. Includes the `error` message and `requestedBy`. |
78
+
79
+ The `export-updates` [push service](push-service.md) stream includes all three events, and requires the exporter role to subscribe. The `export-completed` event also records the export duration as an interval metric from `export-queued`.
80
+
81
+ Export service doesn't consume domain events. It listens for configuration updates to refresh its cached export sources.
82
+
83
+ ## Code examples
84
+
85
+ ### Export a resource
86
+
87
+ Queue a job to export the forms of a form definition to CSV.
88
+
89
+ ```typescript
90
+ const exportServiceUrl = 'https://export-service.adsp.alberta.ca';
91
+
92
+ const response = await fetch(`${exportServiceUrl}/export/v1/jobs`, {
93
+ method: 'POST',
94
+ headers: {
95
+ Authorization: `Bearer ${accessToken}`,
96
+ 'Content-Type': 'application/json',
97
+ },
98
+ body: JSON.stringify({
99
+ resourceId: 'urn:ads:platform:form-service:v1:/forms',
100
+ format: 'csv',
101
+ filename: 'Forms-2026-10-01',
102
+ params: {
103
+ includeData: true,
104
+ criteria: JSON.stringify({ definitionIdEquals: 'income-support-application' }),
105
+ },
106
+ formatOptions: {
107
+ columns: ['id', 'status', { key: 'data.firstName', header: 'First name' }],
108
+ },
109
+ }),
110
+ });
111
+
112
+ const { id, status } = await response.json();
113
+ // id: 'a66ccc16-28fc-44fb-a499-d12df0262b8b', status: 'queued'
114
+ ```
115
+
116
+ ### Get the export file
117
+
118
+ Poll the job until it is completed, then download the file from the file service.
119
+
120
+ ```typescript
121
+ const jobResponse = await fetch(`${exportServiceUrl}/export/v1/jobs/${id}`, {
122
+ headers: { Authorization: `Bearer ${accessToken}` },
123
+ });
124
+
125
+ const { status, result } = await jobResponse.json();
126
+ if (status === 'completed') {
127
+ // result: { id: '51091c0d-...', urn: 'urn:ads:platform:file-service:v1:/files/51091c0d-...', filename: 'Forms-2026-10-01.csv' }
128
+ const fileResponse = await fetch(`https://file-service.adsp.alberta.ca/file/v1/files/${result.id}/download`, {
129
+ headers: { Authorization: `Bearer ${accessToken}` },
130
+ });
131
+ const csv = await fileResponse.text();
132
+ }
133
+ ```
134
+
135
+ Instead of polling, applications can connect to the `export-updates` stream of the push service and wait for the `export-service:export-completed` or `export-service:export-failed` event with the job ID in `payload.jobId`.