@abgov/adsp-sdk-mcp-server 1.20.2 → 1.21.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 +5 -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 +10 -0
  49. package/src/http.js +105 -0
  50. package/src/http.js.map +1 -0
  51. package/src/main.js +4 -82
  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: Feedback service
4
- nav_order: 18
5
4
  parent: Services
6
5
  ---
7
6
 
@@ -13,12 +12,34 @@ Feedback service allows users to submit feedback regarding their service interac
13
12
 
14
13
  client `urn:ads:platform:feedback-service`
15
14
 
16
- | name | description |
17
- | :---------------- | :------------------------------------------------- |
18
- | feedback-provider | Provider role that allows a user to send feedback. |
15
+ | name | description |
16
+ | :---------------- | :------------------------------------------------------- |
17
+ | feedback-provider | Provider role that allows a user to send feedback. |
18
+ | feedback-reader | Allows a user to access feedback submitted by end-users. |
19
19
 
20
20
  _Sites_ can be configured to allow anonymous feedback and in that case the send feedback request is not expected to include any credential. For _sites_ that don't allow anonymous feedback, the request must be in the context of a user with the `urn:ads:platform:feedback-service:feedback-provider` client role. In order to allow feedback from all authenticated users of an application, the associated client can include a hardcode role mapper to add the role to access tokens.
21
21
 
22
+ ## Tenancy
23
+
24
+ - **Sending feedback.** Authenticated users send feedback to the tenant of their token, and need the `feedback-provider` role in that tenant. Anonymous requests name the tenant in the `tenant` field of the body (tenant name or tenant URN); without it the request is rejected with 400. Anonymous feedback is only accepted for sites configured with `allowAnonymous`, and is rate limited to 5 requests per 5 minutes per client.
25
+ - **Reading feedback.** Tenant users with the `feedback-reader` role read the feedback of their own tenant. Core users with the role set the `tenantId` query parameter to read a tenant's feedback; without it, `GET /feedback/v1/feedback` reads the feedback of all tenants. Core users must set `tenantId` for the feedback summary.
26
+ - **Sites.** Sites are tenant configuration. `GET /feedback/v1/sites` lists or counts sites across tenants, and is intended for core users.
27
+
28
+ ## API overview
29
+
30
+ All endpoints are under `https://feedback-service.adsp.alberta.ca/feedback/v1`. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
31
+
32
+ | Endpoint | Purpose | Required role |
33
+ | :---------------------------------------- | :------------------------------------------------- | :-------------------------------------------------------- |
34
+ | `POST /feedback/v1/feedback` | Send feedback for a site. | `feedback-provider`, or anonymous for sites that allow it |
35
+ | `GET /feedback/v1/feedback` | Read submitted feedback, newest first. | `feedback-reader` |
36
+ | `GET /feedback/v1/feedback/summary` | Summarize the feedback for a site and time period. | `feedback-reader` |
37
+ | `GET /feedback/v1/sites` | List or count configured sites. | `feedback-reader` (core) |
38
+ | `GET /feedback/v1/script/adspFeedback.js` | Download the feedback widget script. | Anonymous |
39
+ | `GET /feedback/v1/script/integrity` | Get the script digest for Subresource Integrity. | Anonymous |
40
+
41
+ Sites are configured through the [configuration service](configuration-service.md); feedback service has no endpoints of its own for them.
42
+
22
43
  ## Concepts
23
44
 
24
45
  ### Site
@@ -29,6 +50,10 @@ A site represents a website against which feedback can be provided. A site can b
29
50
 
30
51
  The feedback service processes text content of submitted feedback using the [PII service](pii-service.md) to remove personally identifiable information.
31
52
 
53
+ ## Events
54
+
55
+ Feedback service does not send or consume domain events. Received feedback is queued, processed, and then written as `feedback` values to the [value service](value-service.md) under the `feedback-service` namespace.
56
+
32
57
  ## Code examples
33
58
 
34
59
  ### Configure a site
@@ -138,20 +163,31 @@ await fetch(`https://feedback-service.adsp.alberta.ca/feedback/v1/feedback`, {
138
163
 
139
164
  ### Retrieving feedback
140
165
 
141
- After anonymization, feedback is written to the [value service](value-service.md) and can be retrieved via its API.
166
+ Users with the `feedback-reader` role can read feedback, after anonymization, from the feedback API. Use `page.next` from the response as `after` to read the next page.
142
167
 
143
168
  ```typescript
144
- const valueServiceUrl = 'https://value-service.adsp.alberta.ca';
145
- const top = 50;
146
- const timestampMin = `2024-10-10T12:00:00Z`;
169
+ const feedbackServiceUrl = 'https://feedback-service.adsp.alberta.ca';
170
+ const site = encodeURIComponent('https://my-application.alberta.ca');
147
171
 
148
172
  const response = await fetch(
149
- `${valueServiceUrl}/value/v1/feedback-service/values/feedback?top=${top}&timestampMin=${timestampMin}`,
173
+ `${feedbackServiceUrl}/feedback/v1/feedback?site=${site}&top=50&start=2024-10-10T12:00:00Z`,
150
174
  {
151
175
  method: 'GET',
152
176
  headers: { Authorization: `Bearer ${accessToken}` },
153
177
  },
154
178
  );
155
179
 
156
- const { results, page } = await response.json();
180
+ const { feedback, page } = await response.json();
181
+ // feedback[0].value.rating, feedback[0].value.comment, page.next
182
+ ```
183
+
184
+ ### Summarize feedback for a site
185
+
186
+ ```typescript
187
+ const response = await fetch(`${feedbackServiceUrl}/feedback/v1/feedback/summary?site=${site}`, {
188
+ method: 'GET',
189
+ headers: { Authorization: `Bearer ${accessToken}` },
190
+ });
191
+
192
+ const { totalResponses, averageRating, responsesWithComments, responsesWithIssues } = await response.json();
157
193
  ```
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: File service
4
- nav_order: 8
5
4
  parent: Services
6
5
  ---
7
6
 
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Form service
4
- nav_order: 14
5
4
  parent: Services
6
5
  ---
7
6
 
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: Notification service
4
- nav_order: 9
5
4
  parent: Services
6
5
  ---
7
6
 
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: PDF service
4
- nav_order: 15
5
4
  parent: Services
6
5
  ---
7
6
 
@@ -13,25 +12,98 @@ PDF service provides utility PDF operations like generation of PDFs from templat
13
12
 
14
13
  client `urn:ads:platform:pdf-service`
15
14
 
16
- | name | description |
17
- | :------------ | :----------------------------------------------------------------------------------------------------- |
18
- | pdf-generator | Generator role for the PDF service. This role grants the ability to generate PDF files from templates. |
15
+ | name | description |
16
+ | :------------ | :------------------------------------------------------------------------------------------------------------------- |
17
+ | pdf-admin | Administrator role for the PDF service. This role grants the ability to create, update, and delete PDF templates. |
18
+ | pdf-generator | Generator role for the PDF service. This role grants the ability to generate PDF files from templates and read jobs. |
19
+
20
+ Both roles are included in the tenant admin role. Reading templates does not need a role: any authenticated user of the tenant can list and get them.
21
+
22
+ ## Tenancy
23
+
24
+ Templates and jobs belong to a tenant.
25
+
26
+ - **Tenant users and service accounts** always act on the tenant of their token. Any `tenantId` query parameter is ignored.
27
+ - **Core (platform) users and service accounts** act on the tenant given by the `tenantId` query parameter (for example, `?tenantId=urn:ads:platform:tenant-service:v2:/tenants/{id}`). They must set it when creating, updating, or deleting templates, and when generating PDFs. Without it, listing and getting templates returns only platform templates.
28
+ - **Platform versus tenant templates.** The templates available to a tenant combine the tenant's own templates with _platform_ templates configured by ADSP for all tenants. A platform template replaces a tenant template with the same ID, and creating a template with the ID of a platform template responds `409`.
29
+ - **Isolation.** A template ID that exists only in another tenant responds `404`. A job of another tenant responds `403`.
30
+ - **Role scope.** pdf-admin and pdf-generator can be held in the tenant, or by a core user, for template management and generation. Reading a job (`GET /jobs/{jobId}`) requires pdf-generator in the job's tenant; core users can't read jobs, and should use the job events instead.
31
+
32
+ ## API overview
33
+
34
+ All endpoints are under `https://pdf-service.adsp.alberta.ca/pdf/v1` and require a bearer token. See the [API documentation](https://api.adsp.alberta.ca) for request and response schemas.
35
+
36
+ | Area | Endpoints | Required role |
37
+ | :-------- | :----------------------------------------------------------------------------------- | :-------------------------------- |
38
+ | Templates | `GET /templates`, `GET /templates/{templateId}` | Any authenticated user |
39
+ | | `POST /templates`, `PATCH /templates/{templateId}`, `DELETE /templates/{templateId}` | pdf-admin |
40
+ | Jobs | `POST /jobs` | pdf-generator |
41
+ | | `GET /jobs/{jobId}` | pdf-generator in the job's tenant |
42
+
43
+ Templates can also be managed directly in the [configuration service](configuration-service.md) under `platform:pdf-service`, or in the tenant admin app. Generated PDFs are downloaded through the [file service](file-service.md); the PDF service has no download endpoint.
19
44
 
20
45
  ## Concepts
21
46
 
22
47
  ### PDF template
23
48
 
24
- _Templates_ represent a standard PDF document with template variables for its contents.
49
+ _Templates_ represent a standard PDF document with template variables for its contents. A template has a body (`template`), and optional `header`, `footer`, and `additionalStyles` (CSS shared by the body, header, and footer). Content is HTML with [Handlebars](/adsp-monorepo/tutorials/pdf-service/handlebars.html) expressions, evaluated with a context of `{ data }`, so variables look like {% raw %}`{{ data.myProperty }}`{% endraw %}. Templates are stored in the configuration service. The template ID is derived from its name when it is created through the API.
25
50
 
26
51
  ### Job
27
52
 
28
- PDF service performs operations asynchronously using a job queue. _Jobs_ represent the state of those operations in the queue and are retained for around 24 hrs.
53
+ PDF service generates PDFs asynchronously using a job queue. _Jobs_ represent the state of a generation request:
54
+
55
+ 1. `POST /jobs` checks the template, the role, and the optional file type, then creates a job with status `queued`, puts it on the work queue, and sends `pdf-generation-queued`. It responds with the job straight away.
56
+ 2. A worker renders the template with the request's `data` using [Puppeteer](/adsp-monorepo/tutorials/pdf-service/puppeteer.html), and uploads the PDF to the [file service](file-service.md). The file name's extension is replaced with `.pdf`, and the file's record ID is the request's `recordId`, or the job ID.
57
+ 3. When the upload succeeds, the job status changes to `completed` with a `result` that holds the file `id`, `urn`, and `filename`, and `pdf-generated` is sent.
58
+ 4. If generation fails, the work item may be retried. When it fails without a retry, the job status changes to `failed` and `pdf-generation-failed` is sent with the error.
59
+
60
+ Job state is kept for about 24 hours after its last update; after that `GET /jobs/{jobId}` responds `404`. The generated file is kept by the file service according to its file type.
61
+
62
+ ### File type
63
+
64
+ Generated PDFs are uploaded as the `generated-pdf` file type by default. It is readable by pdf-generator, and its files are deleted after 30 days. To keep PDFs longer or control who can read them, create your own file type in the file service and set `fileType` in the request. The PDF service uploads with a platform service account, so the file type needs `urn:ads:platform:tenant-service:platform-service` in its update roles. The service also registers `pdf-template-assets`, an anonymously readable file type for images used in templates.
65
+
66
+ ## Events
67
+
68
+ The PDF service sends the following domain events under the `pdf-service` namespace. Each event's `correlationId` is the job ID, and its `context` is the request's `context` plus `jobId` and `templateId`.
69
+
70
+ | Event | Description |
71
+ | :---------------------- | :---------------------------------------------------------------------------------------------- |
72
+ | `pdf-generation-queued` | A generation job was queued. Payload has `jobId`, `templateId`, and `requestedBy`. |
73
+ | `pdf-generated` | A PDF was generated and uploaded. Payload also has `file` with the `id`, `urn`, and `filename`. |
74
+ | `pdf-generation-failed` | A generation job failed. Payload has `jobId`, `templateId`, `requestedBy`, and `error`. |
75
+
76
+ These events are available on the [push service](push-service.md) stream `pdf-generation-updates`, for subscribers with the pdf-generator role. The PDF service doesn't consume events from other services.
29
77
 
30
78
  ## Code examples
31
79
 
32
80
  ### Configure a template
33
81
 
34
- Templates are configured using the [configuration service](configuration-service.md).
82
+ Users with the pdf-admin role can create a template. The ID is derived from the name, so this creates `submission-summary`.
83
+
84
+ {% raw %}
85
+
86
+ ```typescript
87
+ const response = await fetch('https://pdf-service.adsp.alberta.ca/pdf/v1/templates', {
88
+ method: 'POST',
89
+ headers: {
90
+ Authorization: `Bearer ${accessToken}`,
91
+ 'Content-Type': 'application/json',
92
+ },
93
+ body: JSON.stringify({
94
+ name: 'Submission summary',
95
+ description: 'Provides a summary of the submission',
96
+ // HTML with handlebars template string
97
+ template: '<p>Submitted by {{ data.applicant.name }}</p>',
98
+ }),
99
+ });
100
+
101
+ const { id } = await response.json();
102
+ ```
103
+
104
+ {% endraw %}
105
+
106
+ Templates can also be configured using the [configuration service](configuration-service.md).
35
107
 
36
108
  ```typescript
37
109
  const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
@@ -60,57 +132,54 @@ await fetch(`${configurationServiceUrl}/configuration/v2/configuration/platform/
60
132
 
61
133
  ### Create a PDF generation job
62
134
 
63
- Generated PDFs are uploaded to the [file service](file-service.md) and the _file type_ used can be specified in the request. This allows you to generate a PDF file that can be directly downloaded by authorized users.
135
+ Generated PDFs are uploaded to the [file service](file-service.md) and the _file type_ used can be specified in the request. This allows you to generate a PDF file that can be directly downloaded by authorized users. The service responds `400` if the file type doesn't exist.
136
+
137
+ {% raw %}
64
138
 
65
139
  ```typescript
66
- const request = {
67
- operation: 'generate',
68
- templateId: 'submission-summary',
69
- filename: 'my-submission-summary.pdf'
70
- fileType: 'submission-documents',
71
- // Template is hydrated with a context of { data }; variables in the template should look like {{ data.myProperty }}.
72
- data: {},
73
- }
74
-
75
- const response = await fetch(
76
- 'https://pdf-service.adsp.alberta.ca/pdf/v1/jobs',
77
- {
78
- method: 'POST',
79
- headers: {
80
- 'Authorization': `Bearer ${accessToken}`,
81
- 'Content-Type': 'application/json'
82
- },
83
- body: JSON.stringify(request),
84
- }
85
- );
86
-
87
- const {
88
- urn,
89
- id,
90
- status,
91
- } = await response.json();
140
+ const request = {
141
+ operation: 'generate',
142
+ templateId: 'submission-summary',
143
+ filename: 'my-submission-summary.pdf',
144
+ fileType: 'submission-documents',
145
+ // Template is hydrated with a context of { data }; variables in the template should look like {{ data.myProperty }}.
146
+ data: { applicant: { name: 'Test User' } },
147
+ };
148
+
149
+ const response = await fetch('https://pdf-service.adsp.alberta.ca/pdf/v1/jobs', {
150
+ method: 'POST',
151
+ headers: {
152
+ Authorization: `Bearer ${accessToken}`,
153
+ 'Content-Type': 'application/json',
154
+ },
155
+ body: JSON.stringify(request),
156
+ });
157
+
158
+ const { urn, id: jobId, status } = await response.json();
92
159
  ```
93
160
 
161
+ {% endraw %}
162
+
94
163
  ### Retrieving the generated PDF
95
164
 
96
- Generated PDFs are uploaded to the file service.
165
+ Poll the job until its status is `completed` (or `failed`), then download the file from the file service.
97
166
 
98
167
  ```typescript
99
168
  const response = await fetch(`https://pdf-service.adsp.alberta.ca/pdf/v1/jobs/${jobId}`, {
100
169
  method: 'GET',
101
170
  headers: {
102
171
  Authorization: `Bearer ${accessToken}`,
103
- 'Content-Type': 'application/json',
104
172
  },
105
173
  });
106
174
 
107
- const {
108
- status,
109
- result: { urn, id: fileId },
110
- } = await response.json();
175
+ const { status, result } = await response.json();
111
176
 
112
- await fetch(`https://file-service.adsp.alberta.ca/file/v1/files/${fileId}/download`, {
113
- method: 'GET',
114
- headers: { Authorization: `Bearer ${accessToken}` },
115
- });
177
+ if (status === 'completed') {
178
+ await fetch(`https://file-service.adsp.alberta.ca/file/v1/files/${result.id}/download`, {
179
+ method: 'GET',
180
+ headers: { Authorization: `Bearer ${accessToken}` },
181
+ });
182
+ }
116
183
  ```
184
+
185
+ Instead of polling, you can listen for `pdf-service:pdf-generated` on the `pdf-generation-updates` stream of the [push service](push-service.md), and read the file ID from `event.payload.file.id`.
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  layout: page
3
3
  title: PII service
4
- nav_order: 19
5
4
  parent: Services
6
5
  ---
7
6