@abgov/adsp-sdk-mcp-server 1.14.0 → 1.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/docs/platform/deployment.md +11 -10
- package/assets/docs/services/access-service-backup-disaster-recovery.md +83 -0
- package/assets/docs/services/audit-service.md +173 -0
- package/assets/docs/services/calendar-service.md +127 -5
- package/assets/docs/services/event-service.md +77 -50
- package/assets/docs/services/form-service.md +40 -1
- package/assets/docs/services/token-handler.md +85 -45
- package/assets/docs/services/value-service.md +82 -5
- package/assets/docs/tutorials/form-service/data-registers.md +40 -45
- package/package.json +2 -1
- package/src/main.js +113 -4
- package/src/main.js.map +1 -1
- package/src/sdk-reference/reference.js +40 -0
- package/src/sdk-reference/reference.js.map +1 -1
|
@@ -15,9 +15,11 @@ client `urn:ads:platform:form-service`
|
|
|
15
15
|
|
|
16
16
|
| name | description |
|
|
17
17
|
|:-|:-|
|
|
18
|
-
| form-admin | Administrator role for form service. This role allows a user to query and unlock forms. |
|
|
18
|
+
| form-admin | Administrator role for form service. This role allows a user to query and unlock forms, and to manage data registers. |
|
|
19
19
|
| intake-application | Intake application role for form service. This role is used to grant a service account the ability to retrieve draft forms and submit forms on behalf of an anonymous applicant. |
|
|
20
20
|
|
|
21
|
+
The data register API also accepts the configuration service role `urn:ads:platform:configuration-service:configuration-admin`, which tenant administrators have by default.
|
|
22
|
+
|
|
21
23
|
|
|
22
24
|
## Concepts
|
|
23
25
|
### Form definition
|
|
@@ -29,6 +31,43 @@ Form represents a particular instance of an application including the informatio
|
|
|
29
31
|
### Draft expiry
|
|
30
32
|
Draft forms include an expiry process so that information entered into draft forms are purged if the draft is abandoned. If a draft form is not accessed for some expiry period, the form is locked and the applicant is notified. In this state, the form cannot be accessed by the applicant but can be unlocked by an administrator. If the form remains in a locked state for some additional expiry period, the form is deleted so that applicant information is not unnecessarily retained.
|
|
31
33
|
|
|
34
|
+
### Data register
|
|
35
|
+
Data register is a named list of values used to populate drop downs and other choice controls in forms. Each value is either a string or an object, such as a `label` and `value` pair. Forms reference a register by its URN in the UI schema. See the [data registers tutorial](../tutorials/form-service/data-registers.md) for how to use registers in a form.
|
|
36
|
+
|
|
37
|
+
## Data registers
|
|
38
|
+
Form service provides an API to manage the data registers of a tenant. Tenant administrators can also manage them in the tenant management webapp under Form service → Register data.
|
|
39
|
+
|
|
40
|
+
Form service stores each register in the [configuration service](configuration-service.md) in two parts:
|
|
41
|
+
- **Definition**: the `data-register:<name>` entry in the tenant's `platform:configuration-service` configuration. It holds the register's schema and description.
|
|
42
|
+
- **Entries**: the configuration with namespace `data-register` and the register's name. It holds the array of values.
|
|
43
|
+
|
|
44
|
+
### Endpoints
|
|
45
|
+
All endpoints require a user with the `urn:ads:platform:form-service:form-admin` role or the `urn:ads:platform:configuration-service:configuration-admin` role, in the context of a tenant. A core user must specify the tenant with the `tenantId` query parameter. Every endpoint returns 401 if the user is not authenticated, 403 if the user has neither role, and 502 if configuration service fails.
|
|
46
|
+
|
|
47
|
+
| Method | Path | Description | Responses |
|
|
48
|
+
|:-|:-|:-|:-|
|
|
49
|
+
| GET | `/form/v1/registers` | Lists the tenant's data registers. | 200 |
|
|
50
|
+
| GET | `/form/v1/registers/{name}` | Gets a data register. | 200, 404 |
|
|
51
|
+
| POST | `/form/v1/registers` | Creates a data register from `name`, `description` and `entries`. `entries` defaults to an empty array. | 201, 400, 409 |
|
|
52
|
+
| PATCH | `/form/v1/registers/{name}` | Updates `description` and/or `entries`. A field that is not sent is left unchanged. | 200, 400, 404 |
|
|
53
|
+
| DELETE | `/form/v1/registers/{name}` | Deletes the data register's entries and definition. | 204, 404 |
|
|
54
|
+
|
|
55
|
+
Registers are returned as `{ namespace: 'data-register', name, description, entries }`.
|
|
56
|
+
|
|
57
|
+
### Rules
|
|
58
|
+
- **Existence**: a register exists only when both its definition (with an array schema) and its entries exist. A register missing either part is not listed. It returns 404 and does not block a create with the same name. This means a create or delete can be retried after a partial failure.
|
|
59
|
+
- **Active revision**: `entries` come from the active revision of the configuration, or from the latest revision if none is active. The form app uses the same revision at runtime.
|
|
60
|
+
- **Writing entries publishes them**: configuration service only writes to the latest revision. When a create or update writes `entries` and an older revision is pinned as active, the pin moves to the revision just written, so the change is live straight away. The older revision stays in the revision history and can be pinned again in configuration service. Updating only `description` leaves the pin alone.
|
|
61
|
+
- **Names**: 1 to 50 letters, numbers, spaces, hyphens and underscores. Names can't start or end with a space. Names are case sensitive.
|
|
62
|
+
- **Entries**: an array whose items are all strings or objects.
|
|
63
|
+
- **URN**: forms reference a register as `urn:ads:platform:configuration:v2:/configuration/data-register/<name>`. The name is not URL encoded in the URN.
|
|
64
|
+
- **Deleting removes data**: a delete removes the register's entries, including their revision history, and its definition. Forms that reference the register lose its options.
|
|
65
|
+
- **Anonymous access**: registers are not readable by anonymous applicants unless `anonymousRead` is set on the definition in configuration service. An update keeps this setting, but the API does not set it.
|
|
66
|
+
- **Errors**: when configuration service rejects a request, form service returns 400. When configuration service fails or denies access, form service returns 502.
|
|
67
|
+
- **Service account role**: form service calls configuration service with its own service account. Deleting a register and moving the active revision need that account to have the configuration service `configuration-admin` role.
|
|
68
|
+
|
|
69
|
+
Form service does not emit its own events for data registers. Configuration service emits `configuration-updated` and `configuration-deleted` for the underlying configuration.
|
|
70
|
+
|
|
32
71
|
## Code examples
|
|
33
72
|
### Create a draft form for an anonymous applicant
|
|
34
73
|
```typescript
|
|
@@ -22,76 +22,88 @@ client `urn:ads:platform:token-handler`
|
|
|
22
22
|
### Clients
|
|
23
23
|
Clients correspond to OAuth clients (OIDC relying party) in [access service](access-service.md). The token handler requires configuration of clients to support client registration in access service. Registration creates confidential clients (with client ID and secret) which are used to authenticate users.
|
|
24
24
|
|
|
25
|
-
Clients are configured in the [configuration service](configuration-service.md) under the `platform:token-handler` namespace and name.
|
|
25
|
+
Clients are configured in the [configuration service](configuration-service.md) under the `platform:token-handler` namespace and name. The frontend application passes the OIDC callback URL at auth initiation time via the `?callbackUrl=` query parameter on the sign in endpoint (e.g. `https://myapp.example.ca/token-handler/clients/my-client/auth?callbackUrl=https://myapp.example.ca/token-handler/clients/my-client/callback`; see [Reverse proxy](#reverse-proxy)). This means no callback URL needs to be stored in the token handler configuration, and the same configuration works across all environments including local development. Redirect URI validation is handled by access service; the `callbackUrl` provided must be registered in the Keycloak client's *Valid Redirect URIs*.
|
|
26
|
+
|
|
27
|
+
> **Deprecated fallback:** Existing configurations with `authCallbackUrl` set will continue to work — the token handler extracts the path from `authCallbackUrl` and combines it with the incoming request's host and protocol when no `?callbackUrl=` query parameter is provided.
|
|
28
|
+
|
|
29
|
+
### Core (platform) clients
|
|
30
|
+
Clients defined in the core configuration (the platform's own `platform:token-handler` configuration) are available to every tenant, in addition to the tenant's own clients. This allows a platform application, such as the preview in the builder app, to use the token handler without each tenant defining the client. Core clients can include `description` and `redirectUris`, and a tenant cannot change or replace them: when a tenant client has the same ID as a core client, the core client is used. The tenant administrator app prevents adding a client with the ID of a core client, so a collision can only occur for a tenant client that was added before the core client.
|
|
31
|
+
|
|
32
|
+
Each tenant still has its own registration of a core client, because registration creates a Keycloak client in the tenant's realm and the client secret is stored per tenant. A tenant administrator registers the client once from the token handler tab (core clients are listed there as platform clients, with their targets and registration status), or by calling the register endpoint. The `redirectUris` of the client configuration are applied as the *Valid Redirect URIs* of the Keycloak client at registration, together with the `callbackUrl` if one is passed. Changing `redirectUris` later does not change clients that are already registered; those are updated in the Keycloak admin console or with the update endpoint.
|
|
33
|
+
|
|
34
|
+
The builder app's preview uses a core client, `builder-preview`, that token handler registers in the core configuration on startup when the `BUILDER_APP_URL` environment variable (the public URL of the builder app) is set. Its redirect URI is on the builder app's origin (`<BUILDER_APP_URL>/token-handler/clients/builder-preview/callback`), so each environment sets its own value. The client is written on every startup, so changes to it are made in the token handler rather than in the core configuration.
|
|
35
|
+
|
|
36
|
+
Administrators can list the clients available to their tenant, core and tenant clients together with their registration status, with `GET /token-handler/v1/clients`. The `core` property of each client indicates whether it is from the core configuration, and `?core=true` returns only core clients.
|
|
26
37
|
|
|
27
38
|
### Targets
|
|
28
39
|
Targets represent upstream services or APIs that the token handler can proxy requests to. For requests from the frontend to the configured targets, token handler will retrieve a valid access token based on the current user session and include it as a bearer token for the upstream request. Target upstream is configured as an ADSP service or API URN, and the URN must have an entry in the [directory service](directory-service.md). Targets are configured as part of clients in the configuration service under the `platform:token-handler` namespace and name.
|
|
29
40
|
|
|
41
|
+
The upstream request only carries the user's access token for authentication. Token handler does not pass on the session cookie, CSRF token or tenant headers of the incoming request, and cookies set by the upstream are not passed back to the frontend. Request paths must stay within the target's base path; paths with dot segments (`.` or `..`) or encoded path separators are rejected as invalid, and the query string is passed through unchanged.
|
|
42
|
+
|
|
43
|
+
Target upstreams are resolved from the directory, where tenant administrators can register entries for their own namespace. The operator of token handler can restrict the hosts that target upstreams may use by setting the `UPSTREAM_ALLOWED_DOMAINS` environment variable to a comma-separated list of host names (e.g. `form-service,api.example.ca`) and wildcards for subdomains (e.g. `*.apps.example.ca`, which does not include `apps.example.ca` itself). An entry can include a port (e.g. `form-service:3333`), in which case the upstream must use that port (the default port for the scheme if the URL has none); an entry without a port allows any port on the host, so list the ports of internal services. When it is set, requests to a target whose upstream does not resolve to an allowed host are rejected. Upstreams in the platform namespace (`urn:ads:platform:...`) are not checked, because only platform administrators can register entries in it, so platform services can use cluster internal URLs without listing them; every other namespace is checked, so tenant entries cannot target internal hosts. Only http and https URLs without credentials are accepted, the scheme is not otherwise restricted, and IPv4 addresses must be listed explicitly. Avoid wildcards for public suffixes (e.g. `*.co.uk`), which allow any domain under them. Host names are matched as they appear in the URL and are not resolved. A wildcard matches subdomains at any depth, so `*.example.ca` allows `www.example.ca` and `a.b.example.ca` but not `example.ca`. When the value is set in a YAML file, such as a ConfigMap, quote it if it starts with `*`, e.g. `'*.example.ca,*.example.org'`. When it is not set, upstreams are not restricted and token handler logs a warning on startup. The setting is not part of the tenant configuration, so tenant administrators cannot change it.
|
|
44
|
+
|
|
45
|
+
### Builder app preview
|
|
46
|
+
The builder app uses the token handler so that the app in its preview can make platform API requests as the signed in user, without holding a token. This is the pattern for a dedicated deployment of an app as well: a static frontend, a `/token-handler` proxy on the app's own origin, a client and its targets.
|
|
47
|
+
|
|
48
|
+
- **Client:** token handler registers the `builder-preview` core client when `BUILDER_APP_URL` is set. Its targets are `form-service` and `file-service`, so those are the services that previewed apps can call. A tenant administrator registers the client once for the tenant in the token handler tab of the tenant management app; until then the builder shows a message that it is required.
|
|
49
|
+
- **Proxy:** the builder's web server proxies `/token-handler/` to the token handler on the builder's origin, so the session cookie is set for the builder's site and the preview, which is served from the builder's origin, gets it.
|
|
50
|
+
- **Sign in:** when the builder loads without a token handler session it redirects to the client's sign in, which returns straight back because the user is already signed in to access service. The preview code does not sign in or handle tokens.
|
|
51
|
+
- **Requests:** `/token-handler/targets/<target>/<service path>`, for example `/token-handler/targets/file-service/file/v1/files`. The React template's `apiFetch` adds the CSRF header that requests other than GET need.
|
|
52
|
+
- **Local development:** the builder's dev server proxies `/token-handler` to the dev token handler and removes the `Secure` flag from its cookies, because Safari does not store `Secure` cookies for `http://localhost`. `http://localhost:4200/token-handler/clients/builder-preview/callback` must be in the client's valid redirect URIs in the tenant's realm.
|
|
53
|
+
- **Limits:** the preview runs on the builder's origin, so the app code shares the origin, and the user's builder session, with the builder. Requests run as the builder's user, limited by the roles that user has. Adding a target to `builder-preview` makes that service available to every previewed app.
|
|
54
|
+
|
|
55
|
+
### Logout
|
|
56
|
+
Frontend applications log users out by navigating the browser to `GET /token-handler/v1/clients/{clientId}/logout`, which can be a plain link. This ends the user's session in token handler, discarding the stored tokens, and redirects to the root of the site. By default this does not end the user's session in [access service](access-service.md), so signing in again from the same browser can complete without entering credentials.
|
|
57
|
+
|
|
58
|
+
Set `keycloakLogout` to `true` on the client to also end the user's single sign on session in access service, so that tokens issued for the session can no longer be refreshed. Logout then redirects the browser to the access service end session endpoint, which returns the browser to the root of the site that the user logged in from (the root of the host of the `callbackUrl` used at login). The client in access service must have that URL (e.g. `https://myapp.example.ca/`) in its *Valid post logout redirect URIs*; otherwise access service shows an error page and the user is not logged out of access service. For this reason it is off by default, and should be enabled once the post logout redirect URI is configured. Sessions that were started before the ID token and site were kept in the session are logged out of token handler only. Requests that another site caused the browser to make (`Sec-Fetch-Site: cross-site`) only end the token handler session, so another site cannot sign users out of access service.
|
|
59
|
+
|
|
30
60
|
### Cross-site request forgery (CSRF)
|
|
31
61
|
The token handler uses sessions and cookies which can be vulnerable to CSRF attacks. A Cookie-to-header token is used as CSRF protection. Frontend applications need to read the value of the `XSRF-TOKEN` cookie and include it as the value of the `X-XSRF-TOKEN` header in requests to *targets*; this behavior is built into [Angular](https://angular.io/guide/http-security-xsrf-protection).
|
|
32
62
|
|
|
33
63
|
### Reverse proxy
|
|
34
64
|
Frontend applications must use a reverse proxy to proxy requests to the token handler from the frontend site domain. The token handler sets a session cookie without the domain attribute, and browsers will associate the cookie with the domain of the authorization callback request. Consequently the cookie will only be included on subsequent requests to the site if that callback request is to the same domain as the rest of the site.
|
|
35
65
|
|
|
36
|
-
|
|
66
|
+
All routes of the token handler are under the `/token-handler/v1` path of its URL, so a single proxy location is enough. The frontend can use any path for it; the examples use `/token-handler`. The frontend then uses these paths:
|
|
37
67
|
|
|
38
|
-
|
|
68
|
+
- Sign in: `/token-handler/clients/${clientId}/auth?tenant=<tenant name>&callbackUrl=<callback URL>`
|
|
69
|
+
- Sign in callback: `/token-handler/clients/${clientId}/callback`; the callback URL passed when signing in is this path on the frontend site.
|
|
70
|
+
- Sign out: `/token-handler/clients/${clientId}/logout`
|
|
71
|
+
- Session information: `/token-handler/sessions`
|
|
72
|
+
- Targets: `/token-handler/targets/${targetId}/...`
|
|
39
73
|
|
|
40
|
-
|
|
41
|
-
location /auth {
|
|
42
|
-
proxy_pass <token handler URL>/token-handler/v1/clients/my-client;
|
|
43
|
-
proxy_set_header Host $host;
|
|
44
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
45
|
-
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
|
46
|
-
proxy_set_header X-Adsp-Tenant <Tenant URN e.g. urn:ads:platform:tenant-service:v2:/tenants/...>;
|
|
47
|
-
}
|
|
74
|
+
The sign in endpoint needs to know the tenant, which is the `tenant` query parameter or the `X-ADSP-TENANT` header. The frontend can hardcode the name of its tenant for the parameter, since the name is the same in every environment (a tenant URN is not). The tenant is kept in the session, so the callback endpoint does not need it. The reverse proxy can set the header to restrict the frontend domain to one tenant, and the header is used instead of the query parameter if both are provided. The value is the name of the tenant (as it is, ignoring case, or in the kebab-case form that has hyphens in place of spaces, e.g. `my-tenant-name`) or a full tenant URN.
|
|
48
75
|
|
|
49
|
-
|
|
50
|
-
proxy_pass <token handler URL>/token-handler/v1/sessions;
|
|
51
|
-
proxy_set_header Host $host;
|
|
52
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
53
|
-
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
|
54
|
-
}
|
|
76
|
+
The proxy should also set the `X-Forwarded-For` and `X-Forwarded-Proto` headers, which the token handler uses for rate limiting and to mark cookies as secure. The `Host` header of the original request is not needed (except by clients that still use the deprecated `authCallbackUrl` fallback).
|
|
55
77
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
78
|
+
#### Nginx configuration example
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
location /token-handler/ {
|
|
82
|
+
proxy_pass <token handler URL>/token-handler/v1/;
|
|
83
|
+
proxy_ssl_server_name on;
|
|
59
84
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
60
85
|
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
|
|
61
86
|
}
|
|
62
87
|
```
|
|
63
88
|
|
|
89
|
+
`proxy_ssl_server_name` is needed when the token handler URL is HTTPS. Use `$scheme` for `X-Forwarded-Proto` if nginx terminates TLS itself. To restrict the frontend domain to one tenant, also add `proxy_set_header X-Adsp-Tenant "<tenant name>";` to the location. The client page in tenant management shows this configuration with the values of the client.
|
|
90
|
+
|
|
64
91
|
### Local development
|
|
65
92
|
There are some special considerations for local development workflows when using the token handler.
|
|
66
93
|
|
|
67
|
-
- Webpack DevServer proxy can be used to proxy requests to the token handler
|
|
68
|
-
-
|
|
69
|
-
- The token handler can only proxy requests to upstream services and APIs that are registered in directory service
|
|
94
|
+
- Webpack DevServer proxy can be used to proxy requests to the token handler. The frontend passes the `tenant` query parameter when it signs in, or the proxy can inject the `X-ADSP-TENANT` header; the tenant name can be used instead of the full URN.
|
|
95
|
+
- The frontend passes `?callbackUrl=http://localhost:<port>/token-handler/clients/<clientId>/callback` when redirecting to the sign in path for local development. Add this URL to the Keycloak client's *Valid Redirect URIs* directly in the access service admin console — no token handler configuration change is required.
|
|
96
|
+
- The token handler can only proxy requests to upstream services and APIs that are registered in directory service; i.e. local running instances of backends cannot be used. In practice, this means that when working with full stack applications, local development of the frontend will require a deployed instance of the backend.
|
|
70
97
|
|
|
71
98
|
#### Webpack DevServer proxy configuration example
|
|
72
99
|
|
|
73
100
|
```json
|
|
74
101
|
{
|
|
75
|
-
"/
|
|
76
|
-
"target": "<token handler URL
|
|
77
|
-
"secure": true,
|
|
78
|
-
"changeOrigin": true,
|
|
79
|
-
"pathRewrite": { "^/auth": "" },
|
|
80
|
-
"headers": {
|
|
81
|
-
"X-ADSP-TENANT": "<Tenant URN e.g. urn:ads:platform:tenant-service:v2:/tenants/...>"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
"/sessions": {
|
|
85
|
-
"target": "<token handler URL>/token-handler/v1/sessions",
|
|
86
|
-
"secure": true,
|
|
87
|
-
"changeOrigin": true,
|
|
88
|
-
"pathRewrite": { "^/sessions": "" }
|
|
89
|
-
},
|
|
90
|
-
"/api": {
|
|
91
|
-
"target": "<token handler URL>/token-handler/v1/targets/my-upstream-api",
|
|
102
|
+
"/token-handler": {
|
|
103
|
+
"target": "<token handler URL>",
|
|
92
104
|
"secure": true,
|
|
93
105
|
"changeOrigin": true,
|
|
94
|
-
"pathRewrite": { "^/
|
|
106
|
+
"pathRewrite": { "^/token-handler": "/token-handler/v1" }
|
|
95
107
|
}
|
|
96
108
|
}
|
|
97
109
|
```
|
|
@@ -99,7 +111,7 @@ There are some special considerations for local development workflows when using
|
|
|
99
111
|
## Code examples
|
|
100
112
|
|
|
101
113
|
### Register a client
|
|
102
|
-
Registering a client creates a confidential client in access service and securely stores the associated client ID and secret in token handler. It is required before token handler can authenticate users using the client.
|
|
114
|
+
Registering a client creates a confidential client in access service and securely stores the associated client ID and secret in token handler. It is required before token handler can authenticate users using the client. The optional `authCallbackUrl` provided here is registered with access service as a valid redirect URI and is not stored in the token handler configuration. If it is not provided, the client is registered without redirect URIs, which must then be added to the client in access service (Keycloak) before users can sign in. Registering a client that is already registered replaces its registration: the previously registered client in access service is deleted, including any redirect URIs configured on it.
|
|
103
115
|
|
|
104
116
|
```typescript
|
|
105
117
|
const response = await fetch(
|
|
@@ -108,10 +120,12 @@ Registering a client creates a confidential client in access service and securel
|
|
|
108
120
|
method: 'POST',
|
|
109
121
|
headers: {
|
|
110
122
|
'Authorization': `Bearer ${accessToken}`,
|
|
123
|
+
'Content-Type': 'application/json',
|
|
111
124
|
},
|
|
112
|
-
body: {
|
|
113
|
-
registrationToken
|
|
114
|
-
|
|
125
|
+
body: JSON.stringify({
|
|
126
|
+
registrationToken,
|
|
127
|
+
authCallbackUrl: 'https://myapp.example.ca/token-handler/clients/my-client/callback',
|
|
128
|
+
}),
|
|
115
129
|
}
|
|
116
130
|
);
|
|
117
131
|
|
|
@@ -120,6 +134,32 @@ Registering a client creates a confidential client in access service and securel
|
|
|
120
134
|
} = await response.json();
|
|
121
135
|
```
|
|
122
136
|
|
|
137
|
+
### Update client registration
|
|
138
|
+
Updating a client's registration allows changing the registered redirect URIs in access service without creating a new client or invalidating existing sessions. This uses the management token stored from the original registration, so no external token is required.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
const response = await fetch(
|
|
142
|
+
`https://adsp.alberta.ca/api/token-handler/v1/clients/${clientId}`,
|
|
143
|
+
{
|
|
144
|
+
method: 'PUT',
|
|
145
|
+
headers: {
|
|
146
|
+
'Authorization': `Bearer ${accessToken}`,
|
|
147
|
+
'Content-Type': 'application/json',
|
|
148
|
+
},
|
|
149
|
+
body: JSON.stringify({
|
|
150
|
+
redirectUris: [
|
|
151
|
+
'https://myapp.example.ca/token-handler/clients/my-client/callback',
|
|
152
|
+
'http://localhost:4200/token-handler/clients/my-client/callback',
|
|
153
|
+
],
|
|
154
|
+
}),
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const {
|
|
159
|
+
updated
|
|
160
|
+
} = await response.json();
|
|
161
|
+
```
|
|
162
|
+
|
|
123
163
|
### Retrieving session information
|
|
124
164
|
Frontend application can determine if the user is logged in and access their session information via the sessions endpoint.
|
|
125
165
|
|
|
@@ -13,16 +13,27 @@ Value service provides an append only time series data store. It serves as the u
|
|
|
13
13
|
|
|
14
14
|
client `urn:ads:platform:value-service`
|
|
15
15
|
|
|
16
|
-
| name | description
|
|
17
|
-
| :----------- |
|
|
18
|
-
| value-reader | Reader role for value service. This role is used to allow users to read values
|
|
19
|
-
| value-writer | Writer role for value service. This role is used to allow service accounts to write values to the value service.
|
|
16
|
+
| name | description |
|
|
17
|
+
| :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| value-reader | Reader role for value service. This role is used to allow users to read values and value definitions. It is part of the tenant-admin composite role and allows tenant administrators to read and search the event log. |
|
|
19
|
+
| value-writer | Writer role for value service. This role is used to allow service accounts to write values to the value service. It also allows users to create, update and delete value definitions, and to read them, since a user with the writer role can also read. |
|
|
20
20
|
|
|
21
21
|
## Concepts
|
|
22
22
|
|
|
23
23
|
### Value definition
|
|
24
24
|
|
|
25
|
-
Value definition is an optional metadata description for a particular _value_ (identified by a specific namespace and name). The definition provides write-time validation via json schema
|
|
25
|
+
Value definition is an optional metadata description for a particular _value_ (identified by a specific namespace and name). The definition provides write-time validation via json schema, and can enable a `value-written` event on each write with `sendWriteEvent`.
|
|
26
|
+
|
|
27
|
+
Value definitions are managed through the value service definitions API (`/value/v1/definitions`). The value service checks the user's roles and then stores the definitions in the [configuration service](configuration-service.md) under the `platform:value-service` namespace and name, using its own service account. Clients do not need configuration service roles to manage value definitions.
|
|
28
|
+
|
|
29
|
+
- Reading definitions requires `value-reader` or `value-writer`. Listing returns tenant and core definitions separately; getting a single definition returns the tenant definition if one exists, otherwise the core definition, with `isCore` indicating which.
|
|
30
|
+
- Creating, updating and deleting definitions requires `value-writer` and applies to tenant definitions only. Core definitions are read-only through this API.
|
|
31
|
+
- The `jsonSchema` of a created or updated definition must be a valid JSON schema, otherwise the request is rejected with a 400.
|
|
32
|
+
- Creating a definition adds its namespace if it does not exist, and fails with a 409 if a tenant or core definition with the same namespace and name already exists.
|
|
33
|
+
- Deleting the last definition in a namespace removes the namespace.
|
|
34
|
+
|
|
35
|
+
> Counting events in the event log is exposed by the [event service](event-service.md#count-events-in-the-event-log).
|
|
36
|
+
> Consumers of the event log count should use that API rather than calling value service directly.
|
|
26
37
|
|
|
27
38
|
### Value
|
|
28
39
|
|
|
@@ -102,3 +113,69 @@ const response = await fetch(`https://value-service.adsp.alberta.ca/value/v1/${n
|
|
|
102
113
|
|
|
103
114
|
const { results, page } = await response.json();
|
|
104
115
|
```
|
|
116
|
+
|
|
117
|
+
### Create a value definition
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
const response = await fetch('https://value-service.adsp.alberta.ca/value/v1/definitions', {
|
|
121
|
+
method: 'POST',
|
|
122
|
+
headers: {
|
|
123
|
+
Authorization: `Bearer ${accessToken}`,
|
|
124
|
+
'Content-Type': 'application/json',
|
|
125
|
+
},
|
|
126
|
+
body: JSON.stringify({
|
|
127
|
+
namespace: 'support',
|
|
128
|
+
name: 'application-stats',
|
|
129
|
+
description: 'Statistics for support applications.',
|
|
130
|
+
jsonSchema: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
properties: { property: { type: 'number' } },
|
|
133
|
+
},
|
|
134
|
+
sendWriteEvent: false,
|
|
135
|
+
}),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const { namespace, name, jsonSchema, isCore } = await response.json();
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Read value definitions
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
const response = await fetch('https://value-service.adsp.alberta.ca/value/v1/definitions', {
|
|
145
|
+
method: 'GET',
|
|
146
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Each is a map of namespace name to { name, definitions }.
|
|
150
|
+
const { tenant, core } = await response.json();
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Update a value definition
|
|
154
|
+
|
|
155
|
+
Properties not included in the request are left unchanged.
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
const namespace = 'support';
|
|
159
|
+
const name = 'application-stats';
|
|
160
|
+
const response = await fetch(`https://value-service.adsp.alberta.ca/value/v1/definitions/${namespace}/${name}`, {
|
|
161
|
+
method: 'PATCH',
|
|
162
|
+
headers: {
|
|
163
|
+
Authorization: `Bearer ${accessToken}`,
|
|
164
|
+
'Content-Type': 'application/json',
|
|
165
|
+
},
|
|
166
|
+
body: JSON.stringify({ description: 'Updated statistics for support applications.' }),
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Delete a value definition
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
const namespace = 'support';
|
|
174
|
+
const name = 'application-stats';
|
|
175
|
+
const response = await fetch(`https://value-service.adsp.alberta.ca/value/v1/definitions/${namespace}/${name}`, {
|
|
176
|
+
method: 'DELETE',
|
|
177
|
+
headers: { Authorization: `Bearer ${accessToken}` },
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const { deleted } = await response.json();
|
|
181
|
+
```
|
|
@@ -14,73 +14,62 @@ achieve this.
|
|
|
14
14
|
|
|
15
15
|
<h3 id="data-registers">Data registers</h3>
|
|
16
16
|
|
|
17
|
-
When
|
|
18
|
-
We have two options to accomplish this operation.
|
|
17
|
+
When a drop down needs a list of values, there are two options.
|
|
19
18
|
|
|
20
19
|
<ol>
|
|
21
20
|
<li>
|
|
22
|
-
|
|
21
|
+
Use an ADSP data register. You manage data registers in the tenant management webapp or through the form service API.
|
|
23
22
|
</li>
|
|
24
23
|
<li>
|
|
25
24
|
Provide a URL REST API endpoint to retrieve the list of values.
|
|
26
25
|
</li>
|
|
27
26
|
</ol>
|
|
28
27
|
|
|
29
|
-
### Using
|
|
28
|
+
### Using a data register
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
A data register is a named list of values. Each value is either a string or an object, for example an object with `label` and `value` properties.
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
#### Managing data registers in the tenant management webapp
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
"type": "array",
|
|
38
|
-
"items": {
|
|
39
|
-
"type": "string"
|
|
40
|
-
},
|
|
41
|
-
"required": [],
|
|
42
|
-
"additionalProperties": true
|
|
43
|
-
}
|
|
44
|
-
```
|
|
34
|
+
Go to Form service → Register data tab.
|
|
45
35
|
|
|
46
|
-
|
|
36
|
+
- Click **Add register data** and enter a name, an optional description and the values. Names can contain letters, numbers, spaces, hyphens and underscores, can't start or end with a space, can be up to 50 characters long, and must be unique within your tenant. Enter the values separated by commas, new lines or semicolons, or select **Use JSON format** and enter a JSON array.
|
|
37
|
+
- Click the eye icon on a register to view its values and copy its URN.
|
|
38
|
+
- Click the edit icon on a register to change its values as a JSON array.
|
|
39
|
+
- Click the delete icon on a register to delete it. Forms that reference a deleted register lose its options.
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
a drop down for array object.
|
|
41
|
+
#### Managing data registers through the API
|
|
50
42
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
"label": {
|
|
61
|
-
"type": "string"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
43
|
+
You can also manage data registers through the form service API at `/form/v1/registers`. This requires the `form-admin` role or the configuration service `configuration-admin` role. See [Form service](/adsp-monorepo/services/form-service.html#data-registers) for the full API.
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
const response = await fetch('https://form-service.adsp.alberta.ca/form/v1/registers', {
|
|
47
|
+
method: 'POST',
|
|
48
|
+
headers: {
|
|
49
|
+
Authorization: `Bearer ${token}`,
|
|
50
|
+
'Content-Type': 'application/json',
|
|
64
51
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
body: JSON.stringify({
|
|
53
|
+
name: 'provinces',
|
|
54
|
+
description: 'Canadian provinces',
|
|
55
|
+
entries: ['Alberta', 'British Columbia', 'Saskatchewan'],
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
69
58
|
```
|
|
70
59
|
|
|
71
|
-
|
|
60
|
+
#### Register values
|
|
72
61
|
|
|
73
|
-
This
|
|
62
|
+
This register holds string values:
|
|
74
63
|
|
|
75
64
|
```
|
|
76
65
|
[
|
|
77
66
|
"value1",
|
|
78
67
|
"value2",
|
|
79
|
-
"value3"
|
|
68
|
+
"value3"
|
|
80
69
|
]
|
|
81
70
|
```
|
|
82
71
|
|
|
83
|
-
This
|
|
72
|
+
This register holds objects with `label` and `value` properties:
|
|
84
73
|
|
|
85
74
|
```
|
|
86
75
|
[
|
|
@@ -88,14 +77,16 @@ This example maps to example 2 from the schema above that has "label" and "value
|
|
|
88
77
|
"label": "label 1",
|
|
89
78
|
"value": "value 1"
|
|
90
79
|
},
|
|
91
|
-
|
|
80
|
+
{
|
|
92
81
|
"label": "label 2",
|
|
93
82
|
"value": "value 2"
|
|
94
83
|
}
|
|
95
84
|
]
|
|
96
85
|
```
|
|
97
86
|
|
|
98
|
-
|
|
87
|
+
Each data register has a URN in the form `urn:ads:platform:configuration:v2:/configuration/data-register/<name>`. You use it in the UI schema to reference the register. Names with spaces are not encoded, so the URN is exactly what the Register data tab shows.
|
|
88
|
+
|
|
89
|
+
Once your data register is set up, go to the form editor and add it to your data and UI schemas for the drop down.
|
|
99
90
|
|
|
100
91
|
#### Data schema
|
|
101
92
|
|
|
@@ -117,9 +108,9 @@ Once you have configured the configuration service schema for your data register
|
|
|
117
108
|
|
|
118
109
|
For the UI schema there are two methods that you use to populate your drop down.
|
|
119
110
|
|
|
120
|
-
The first method is to
|
|
111
|
+
The first method is to reference a data register by its URN.
|
|
121
112
|
|
|
122
|
-
The example below shows
|
|
113
|
+
The example below shows the UI schema you would need.
|
|
123
114
|
|
|
124
115
|
```
|
|
125
116
|
{
|
|
@@ -128,12 +119,16 @@ The example below shows what the UI schema you would need.
|
|
|
128
119
|
"label": "Province",
|
|
129
120
|
"options": {
|
|
130
121
|
"register": {
|
|
131
|
-
"urn": "urn:ads:platform:configuration:v2:/configuration/
|
|
122
|
+
"urn": "urn:ads:platform:configuration:v2:/configuration/data-register/provinces"
|
|
132
123
|
}
|
|
133
124
|
}
|
|
134
125
|
}
|
|
135
126
|
```
|
|
136
127
|
|
|
128
|
+
You can also reference configuration in other namespaces, for example `urn:ads:platform:configuration:v2:/configuration/public-register/public-register-1`. Its configuration definition schema must be an array of strings or an array of objects. You set up these registers directly in configuration service. They aren't managed by the Register data tab or the form service API.
|
|
129
|
+
|
|
130
|
+
By default, only signed-in users can read a register. To use a register in a form that allows anonymous applicants, go to Configuration service → Definitions. Edit the register's definition, which has the namespace `data-register` and the register's name, and select **Allow anonymous access**. The Register data tab and the form service API keep this setting when they update a register, but they never set it.
|
|
131
|
+
|
|
137
132
|
Please refer to [Configuration service](/adsp-monorepo/services/configuration-service.html) for more details.
|
|
138
133
|
|
|
139
134
|
The second method is to use an external REST API endpoint to retrieve data to populate the drop down.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/adsp-sdk-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Government of Alberta - MCP server for ADSP documentation and Node SDK reference lookup.",
|
|
6
6
|
"repository": "https://github.com/GovAlta/adsp-monorepo",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@abgov/adsp-cli": "^1.7.0",
|
|
12
12
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
13
|
+
"express": "^4.21.0",
|
|
13
14
|
"tslib": "^2.3.0",
|
|
14
15
|
"zod": "^3.25.76"
|
|
15
16
|
},
|