@abgov/adsp-sdk-mcp-server 0.0.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 (124) hide show
  1. package/README.md +51 -0
  2. package/assets/docs/architecture.md +79 -0
  3. package/assets/docs/getting-started.md +118 -0
  4. package/assets/docs/important-notes.md +47 -0
  5. package/assets/docs/index.md +9 -0
  6. package/assets/docs/platform/deployment.md +80 -0
  7. package/assets/docs/platform/getting-started.md +66 -0
  8. package/assets/docs/platform/operations.md +8 -0
  9. package/assets/docs/platform/platform-django-sdk.md +330 -0
  10. package/assets/docs/platform/platform-dotnet-sdk.md +457 -0
  11. package/assets/docs/platform/platform-flask-sdk.md +355 -0
  12. package/assets/docs/platform/platform-node-sdk.md +433 -0
  13. package/assets/docs/platform/platform-spring-sdk.md +344 -0
  14. package/assets/docs/platform/platform.md +8 -0
  15. package/assets/docs/services/access-service.md +75 -0
  16. package/assets/docs/services/agent-service.md +316 -0
  17. package/assets/docs/services/cache-service.md +61 -0
  18. package/assets/docs/services/calendar-service.md +86 -0
  19. package/assets/docs/services/comment-service.md +87 -0
  20. package/assets/docs/services/configuration-service.md +92 -0
  21. package/assets/docs/services/directory-service.md +57 -0
  22. package/assets/docs/services/event-service.md +122 -0
  23. package/assets/docs/services/feedback-service.md +152 -0
  24. package/assets/docs/services/file-service.md +164 -0
  25. package/assets/docs/services/form-service.md +149 -0
  26. package/assets/docs/services/notification-service.md +151 -0
  27. package/assets/docs/services/pdf-service.md +116 -0
  28. package/assets/docs/services/pii-service.md +45 -0
  29. package/assets/docs/services/push-service.md +106 -0
  30. package/assets/docs/services/services.md +6 -0
  31. package/assets/docs/services/status-service.md +29 -0
  32. package/assets/docs/services/task-service.md +139 -0
  33. package/assets/docs/services/tenant-service.md +18 -0
  34. package/assets/docs/services/token-handler.md +135 -0
  35. package/assets/docs/services/value-service.md +80 -0
  36. package/assets/docs/services/verify-service.md +61 -0
  37. package/assets/docs/tutorials/access-service/access-service.md +9 -0
  38. package/assets/docs/tutorials/access-service/adsp-clients.md +29 -0
  39. package/assets/docs/tutorials/access-service/application-clients.md +61 -0
  40. package/assets/docs/tutorials/access-service/front-end-access.md +53 -0
  41. package/assets/docs/tutorials/access-service/introduction.md +33 -0
  42. package/assets/docs/tutorials/access-service/tenants.md +68 -0
  43. package/assets/docs/tutorials/access-service/themes.md +43 -0
  44. package/assets/docs/tutorials/feedback-service/accessing-data.md +41 -0
  45. package/assets/docs/tutorials/feedback-service/feedback-service.md +9 -0
  46. package/assets/docs/tutorials/feedback-service/installation.md +142 -0
  47. package/assets/docs/tutorials/feedback-service/introduction.md +28 -0
  48. package/assets/docs/tutorials/feedback-service/security.md +40 -0
  49. package/assets/docs/tutorials/feedback-service/triggering.md +21 -0
  50. package/assets/docs/tutorials/file-service/file-service.md +9 -0
  51. package/assets/docs/tutorials/file-service/file-types.md +35 -0
  52. package/assets/docs/tutorials/file-service/introduction.md +34 -0
  53. package/assets/docs/tutorials/file-service/security.md +31 -0
  54. package/assets/docs/tutorials/file-service/working-with.md +65 -0
  55. package/assets/docs/tutorials/form-service/Integration.md +31 -0
  56. package/assets/docs/tutorials/form-service/ai-agent.md +450 -0
  57. package/assets/docs/tutorials/form-service/building-forms.md +264 -0
  58. package/assets/docs/tutorials/form-service/cheat-sheet.md +1461 -0
  59. package/assets/docs/tutorials/form-service/custom-error-messages.md +87 -0
  60. package/assets/docs/tutorials/form-service/data-registers.md +204 -0
  61. package/assets/docs/tutorials/form-service/file-uploader.md +81 -0
  62. package/assets/docs/tutorials/form-service/form-app.md +72 -0
  63. package/assets/docs/tutorials/form-service/form-editor.md +62 -0
  64. package/assets/docs/tutorials/form-service/form-service.md +9 -0
  65. package/assets/docs/tutorials/form-service/form-submissions.md +77 -0
  66. package/assets/docs/tutorials/form-service/instructions.md +173 -0
  67. package/assets/docs/tutorials/form-service/introduction.md +66 -0
  68. package/assets/docs/tutorials/form-service/repeated-items.md +87 -0
  69. package/assets/docs/tutorials/form-service/security.md +36 -0
  70. package/assets/docs/tutorials/form-service/steppers.md +237 -0
  71. package/assets/docs/tutorials/notification-service/emailAttachment.md +75 -0
  72. package/assets/docs/tutorials/notification-service/events.md +20 -0
  73. package/assets/docs/tutorials/notification-service/introduction.md +37 -0
  74. package/assets/docs/tutorials/notification-service/notification-service.md +9 -0
  75. package/assets/docs/tutorials/notification-service/notification-types.md +86 -0
  76. package/assets/docs/tutorials/notification-service/subscribers.md +33 -0
  77. package/assets/docs/tutorials/pdf-service/building-a-template.md +339 -0
  78. package/assets/docs/tutorials/pdf-service/generate-a-pdf.md +150 -0
  79. package/assets/docs/tutorials/pdf-service/handlebars.md +51 -0
  80. package/assets/docs/tutorials/pdf-service/introduction.md +26 -0
  81. package/assets/docs/tutorials/pdf-service/pdf-service.md +9 -0
  82. package/assets/docs/tutorials/pdf-service/puppeteer.md +25 -0
  83. package/assets/docs/tutorials/pdf-service/video.md +18 -0
  84. package/assets/docs/tutorials/status-service/Introduction.md +46 -0
  85. package/assets/docs/tutorials/status-service/health.md +51 -0
  86. package/assets/docs/tutorials/status-service/notices.md +34 -0
  87. package/assets/docs/tutorials/status-service/notifications.md +107 -0
  88. package/assets/docs/tutorials/status-service/status-service.md +9 -0
  89. package/assets/docs/tutorials/status-service/status.md +35 -0
  90. package/assets/docs/tutorials/status-service/webhooks.md +24 -0
  91. package/assets/docs/tutorials/task-service/introduction.md +23 -0
  92. package/assets/docs/tutorials/task-service/task-app.md +43 -0
  93. package/assets/docs/tutorials/task-service/task-definitions.md +49 -0
  94. package/assets/docs/tutorials/task-service/task-queues.md +67 -0
  95. package/assets/docs/tutorials/task-service/task-service.md +9 -0
  96. package/assets/docs/tutorials/tutorials.md +8 -0
  97. package/package.json +18 -0
  98. package/src/docs/docsRepository.d.ts +22 -0
  99. package/src/docs/docsRepository.js +110 -0
  100. package/src/docs/docsRepository.js.map +1 -0
  101. package/src/main.d.ts +2 -0
  102. package/src/main.js +16 -0
  103. package/src/main.js.map +1 -0
  104. package/src/sdk-reference/reference.d.ts +17 -0
  105. package/src/sdk-reference/reference.js +547 -0
  106. package/src/sdk-reference/reference.js.map +1 -0
  107. package/src/sdk-reference/search.d.ts +6 -0
  108. package/src/sdk-reference/search.js +41 -0
  109. package/src/sdk-reference/search.js.map +1 -0
  110. package/src/server.d.ts +6 -0
  111. package/src/server.js +30 -0
  112. package/src/server.js.map +1 -0
  113. package/src/tools/registerDocsTools.d.ts +3 -0
  114. package/src/tools/registerDocsTools.js +66 -0
  115. package/src/tools/registerDocsTools.js.map +1 -0
  116. package/src/tools/registerQuickstartTool.d.ts +2 -0
  117. package/src/tools/registerQuickstartTool.js +82 -0
  118. package/src/tools/registerQuickstartTool.js.map +1 -0
  119. package/src/tools/registerSdkTools.d.ts +2 -0
  120. package/src/tools/registerSdkTools.js +43 -0
  121. package/src/tools/registerSdkTools.js.map +1 -0
  122. package/src/tools/types.d.ts +12 -0
  123. package/src/tools/types.js +3 -0
  124. package/src/tools/types.js.map +1 -0
@@ -0,0 +1,57 @@
1
+ ---
2
+ layout: page
3
+ title: Directory service
4
+ nav_order: 3
5
+ parent: Services
6
+ ---
7
+
8
+ # Directory service
9
+
10
+ Directory service is a register of services and APIs. It allows you to find service URLs matched to logical URNs of the form: `urn:ads:{namespace}:{service}:{api}`. Consumers can use this service for client-side service discovery. The directory service also provides a resource API that allows tagging of resources under APIs registered in the directory; this allows users to tag and search for resources across APIs.
11
+
12
+ ## Client roles
13
+
14
+ client `urn:ads:platform:directory-service`
15
+
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. |
22
+
23
+ The directory service API allows anonymous read access of entries.
24
+
25
+ ## Concepts
26
+
27
+ ### 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.
29
+
30
+ ### Resource
31
+ 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
+
33
+ #### URN convention
34
+ 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
+
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`.
37
+
38
+ ### 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.
40
+
41
+ ### Tag
42
+ Tags are simple string labels that can be associated to resources, and can be used to represent categories and projects.
43
+
44
+ ## Code examples
45
+
46
+ ### Reading the directory
47
+
48
+ ```typescript
49
+ const response = await fetch('https://directory.adsp.alberta.ca/directory/v2/namespaces/platform/entries', {
50
+ method: 'GET',
51
+ headers: {
52
+ Authorization: `Bearer ${accessToken}`,
53
+ },
54
+ });
55
+
56
+ const entries = await response.json();
57
+ ```
@@ -0,0 +1,122 @@
1
+ ---
2
+ layout: page
3
+ title: Event service
4
+ nav_order: 5
5
+ parent: Services
6
+ ---
7
+
8
+ # Event service
9
+ Event service allows consumers to send domain events. These events can be used to support additional capabilities aside from the application itself; out of the box, the event service logs domain events to the event log which can be used for traceability of domain operations.
10
+
11
+ ## Client roles
12
+ client `urn:ads:platform:event-service`
13
+
14
+ | name | description |
15
+ |:-|:-|
16
+ | event-sender | Sender role for event service. This role is used to allow a service account to send domain events via the event service. Note that the account with the role will be able to send any domain event including platform defined events. |
17
+
18
+ ## Concepts
19
+ ### Event definition
20
+ Event definition is an optional metadata description of a *domain event* (identified by a specific namespace and name). They are used for downstream capabilities. For example, the payload schema description allows the [notification service](notification-service.md) to validate variables within notification message templates. Event definitions are configured in the [configuration service](configuration-service.md) under the `platform:event-service` namespace and name.
21
+
22
+ ### Event
23
+ Domain events represent key changes at a domain model level. For example, an intake application process could include events like: application draft created, application submitted, application processing started, application processing completed.
24
+
25
+ ### Event log
26
+ Event log records all *events* emitted via the event service and keeps basic metrics including a count of different events. These metrics can represent key domain metrics; in the intake application example, the count of application submitted events represents the volume of applications.
27
+
28
+ ## Code examples
29
+ ### Configure an event definition
30
+ Event definitions are configured using the [configuration service](configuration-service.md). Note that new configuration may take up to 15 mins to apply.
31
+
32
+ ```typescript
33
+ const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
34
+ const request = {
35
+ operation: 'UPDATE',
36
+ update: {
37
+ 'domain-service': {
38
+ name: 'domain-service',
39
+ definitions: {
40
+ 'domain-event': {
41
+ name: 'domain-event',
42
+ description: 'Signalled on significant domain state change.',
43
+ payloadSchema: {
44
+ type: 'object',
45
+ properties: {
46
+ value: { type: 'string' }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+
55
+ await fetch(
56
+ `${configurationServiceUrl}/configuration/v2/configuration/platform/event-service`,
57
+ {
58
+ method: 'PATCH',
59
+ headers: {
60
+ 'Authorization': `Bearer ${accessToken}`,
61
+ 'Content-Type': 'application/json'
62
+ },
63
+ body: JSON.stringify(request),
64
+ }
65
+ );
66
+ ```
67
+
68
+ ### Send an event
69
+ ```typescript
70
+ const event = {
71
+ namespace: 'support-program',
72
+ name: 'application-submitted',
73
+ timestamp: '2021-10-12T15:03:50Z',
74
+ correlationId: 'f669be59-bd38-4ca4-8749-19248060fc63',
75
+ context: {
76
+ },
77
+ payload: {
78
+ application: {
79
+ id: 'f669be59-bd38-4ca4-8749-19248060fc63',
80
+ /* ... */
81
+ }
82
+ applicant: {
83
+ id: 'a8e5ec09-d60a-4c60-94bd-71dc97d8c80e',
84
+ username: 'testy.mctester@acme.com',
85
+ }
86
+ }
87
+ }
88
+
89
+ await fetch(
90
+ 'https://event-service.adsp.alberta.ca/event/v1/events',
91
+ {
92
+ method: 'POST',
93
+ headers: {
94
+ 'Authorization': `Bearer ${accessToken}`,
95
+ 'Content-Type': 'application/json',
96
+ },
97
+ body: JSON.stringify(event),
98
+ }
99
+ );
100
+ ```
101
+
102
+ ### Search the event log
103
+ The event log is stored as a value (event-service:event) in the [value service](value-service.md) and can be queried using the value API.
104
+
105
+ ```typescript
106
+ const valueServiceUrl = 'https://value-service.adsp.alberta.ca';
107
+ const top = 50;
108
+ const timestampMin = `2021-10-10T12:00:00Z`;
109
+
110
+ const response = await fetch(
111
+ `${valueServiceUrl}/value/v1/event-service/values/event?top=${top}&timestampMin=${timestampMin}`,
112
+ {
113
+ method: 'GET',
114
+ headers: { Authorization: `Bearer ${accessToken}` }
115
+ }
116
+ );
117
+
118
+ const {
119
+ results,
120
+ page,
121
+ } = await response.json();
122
+ ```
@@ -0,0 +1,152 @@
1
+ ---
2
+ layout: page
3
+ title: Feedback service
4
+ nav_order: 18
5
+ parent: Services
6
+ ---
7
+
8
+ # Feedback service
9
+ Feedback service allows users to submit feedback regarding their service interaction. It includes an backend API and a frontend widget.
10
+
11
+ ## Client roles
12
+ client `urn:ads:platform:feedback-service`
13
+
14
+ | name | description |
15
+ |:-|:-|
16
+ | feedback-provider | Provider role that allows a user to send feedback. |
17
+
18
+ *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.
19
+
20
+ ## Concepts
21
+ ### Site
22
+ A site represents a website against which feedback can be provided. A site can be configured to allow anonymous feedback, so that feedback is accepted from unauthenticated users. This may decrease the quality of feedback. Note that the feedback API does not (and is not reliably able to) check that feedback originates from the associated site. Sites are configured in the [configuration service](configuration-service.md) under the `platform:feedback-service` namespace and name.
23
+
24
+ ### Feedback anonymization
25
+ The feedback service processes text content of submitted feedback using the [PII service](pii-service.md) to remove personally identifiable information.
26
+
27
+ ## Code examples
28
+ ### Configure a site
29
+ Sites are configured using the [configuration service](configuration-service.md). Note that new configuration may take up to 15 mins to apply.
30
+
31
+ ```typescript
32
+ const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
33
+
34
+ const request = {
35
+ operation: 'UPDATE',
36
+ update: {
37
+ sites: [{
38
+ url: 'https://my-application.alberta.ca',
39
+ allowAnonymous: false,
40
+ }]
41
+ }
42
+ }
43
+
44
+ await fetch(
45
+ `${configurationServiceUrl}/configuration/v2/configuration/platform/feedback-service`,
46
+ {
47
+ method: 'PATCH',
48
+ headers: {
49
+ 'Authorization': `Bearer ${accessToken}`,
50
+ 'Content-Type': 'application/json'
51
+ },
52
+ body: JSON.stringify(request),
53
+ }
54
+ );
55
+ ```
56
+
57
+ ### Attach feedback widget
58
+ Feedback service provides a script for a frontend widget. The script sets a `adspFeedback` global variable when it is loaded, then the hosting site needs to initialize the widget with the name of the associated tenant.
59
+
60
+ ```html
61
+ <head>
62
+ <!-- Site head -->
63
+ <script src="https://feedback-service.adsp.alberta.ca/feedback/v1/script/adspFeedback.js"></script>
64
+ </head>
65
+ ...
66
+ <body>
67
+ <!-- Site body -->
68
+ <script>adspFeedback.initialize({tenant: 'My Tenant'})</script>
69
+ <body>
70
+ ```
71
+
72
+ The widget uses the location from which it is loaded to determine the feedback API URL, and uses the current site location for the context of the feedback. However, the hosting application can customize the widget behaviour via its interface.
73
+
74
+ ```typescript
75
+
76
+ interface AdspFeedback {
77
+ initialize(options: FeedbackOptions): void;
78
+ }
79
+
80
+ interface FeedbackOptions {
81
+ tenant?: string;
82
+ name?: string;
83
+ site?: string;
84
+ apiUrl?: string;
85
+ getAccessToken?: () => Promise<string>;
86
+ getContext?: () => Promise<FeedbackContext>;
87
+ }
88
+
89
+ export interface FeedbackContext {
90
+ site: string;
91
+ view: string;
92
+ correlationId?: string;
93
+ }
94
+ ```
95
+
96
+ ### Send feedback
97
+ The `rating` field accepts one of the following values:
98
+
99
+ | Value | Description |
100
+ |:-|:-|
101
+ | terrible | Very Difficult |
102
+ | bad | Difficult |
103
+ | neutral | Neutral |
104
+ | good | Easy |
105
+ | delightful | Very Easy |
106
+
107
+ ```typescript
108
+ const feedback = {
109
+ tenant: 'My Tenant',
110
+ context: {
111
+ site: 'https://my-application.alberta.ca',
112
+ view: '/site-view',
113
+ },
114
+ rating: 'good',
115
+ comment: 'My experience was pretty good.',
116
+ technicalIssue: 'I experienced some issues with slow loading.',
117
+ }
118
+
119
+ await fetch(
120
+ `https://feedback-service.adsp.alberta.ca/feedback/v1/feedback`,
121
+ {
122
+ method: 'POST',
123
+ headers: {
124
+ 'Authorization': `Bearer ${accessToken}`,
125
+ 'Content-Type': 'application/json',
126
+ },
127
+ body: JSON.stringify(feedback),
128
+ }
129
+ );
130
+ ```
131
+
132
+ ### Retrieving feedback
133
+ After anonymization, feedback is written to the [value service](value-service.md) and can be retrieved via its API.
134
+
135
+ ```typescript
136
+ const valueServiceUrl = 'https://value-service.adsp.alberta.ca';
137
+ const top = 50;
138
+ const timestampMin = `2024-10-10T12:00:00Z`;
139
+
140
+ const response = await fetch(
141
+ `${valueServiceUrl}/value/v1/feedback-service/values/feedback?top=${top}&timestampMin=${timestampMin}`,
142
+ {
143
+ method: 'GET',
144
+ headers: { Authorization: `Bearer ${accessToken}` }
145
+ }
146
+ );
147
+
148
+ const {
149
+ results,
150
+ page,
151
+ } = await response.json();
152
+ ```
@@ -0,0 +1,164 @@
1
+ ---
2
+ layout: page
3
+ title: File service
4
+ nav_order: 8
5
+ parent: Services
6
+ ---
7
+
8
+ # File service
9
+ File service provides the ability to upload and download files. Applications can upload files via multipart/form-data requests with the file and related metadata, then later allow users to access metadata of or download the file.
10
+
11
+ The file service uses anti-virus services to scan uploaded files. Download of files that have not been scanned requires an explicit `unsafe=true` parameter.
12
+
13
+
14
+ ## Client roles
15
+ client `urn:ads:platform:file-service`
16
+
17
+ | name | description |
18
+ |:-|:-|
19
+ | file-service-admin | Administrator role for the file service. This role grants read and write access across all files. |
20
+
21
+ File access is controlled by configuration of `readRoles` and `updateRoles` on each file type.
22
+
23
+ ## Concepts
24
+ ### File type
25
+ File type represents a category of files with specific access roles. For example, a 'Supporting Documents' file type may allow `intake-application` role to upload files and `assessor` role to download the files. File types are configured in the [configuration service](configuration-service.md) under the `platform:file-service` namespace and name.
26
+
27
+ ### File
28
+ A file represents an uploaded file and consists of a minimal metadata record and the actual file that was uploaded. File service provides minimal metadata and does not support extensible metadata; keep additional values in a domain record and reference it using `recordId`.
29
+
30
+ ## Code examples
31
+ ### Configure a file type
32
+ File types are configured using the [configuration service](configuration-service.md). Note that new configuration may take up to 15 mins to apply.
33
+
34
+ ```typescript
35
+ const configurationServiceUrl = 'https://configuration-service.adsp.alberta.ca';
36
+ const request = {
37
+ operation: 'UPDATE',
38
+ update: {
39
+ 'supporting-document': {
40
+ id: 'supporting-document',
41
+ name: 'Support Document',
42
+ anonymousRead: false,
43
+ readRoles: ['assessor'],
44
+ updateRoles: ['applicant'],
45
+ }
46
+ }
47
+ }
48
+
49
+ await fetch(
50
+ `${configurationServiceUrl}/configuration/v2/configuration/platform/file-service`,
51
+ {
52
+ method: 'PATCH',
53
+ headers: {
54
+ 'Authorization': `Bearer ${accessToken}`,
55
+ 'Content-Type': 'application/json'
56
+ },
57
+ body: JSON.stringify(request),
58
+ }
59
+ );
60
+ ```
61
+
62
+ ### Upload a file
63
+ ```typescript
64
+ // Note that the file needs to be last.
65
+ const formData = new FormData();
66
+ formData.append('type', 'supporting-docs');
67
+ // Use filename to override the original name of the file.
68
+ formData.append('filename', 'proof-of-income.pdf');
69
+ // Use recordId to reference the associated record.
70
+ formData.append('recordId', '8bcbc6b1-600a-40c5-99c8-d02734f97ca5');
71
+ formData.append('file', selectedFile);
72
+
73
+ await fetch(
74
+ 'https://file-service.adsp.alberta.ca/file/v1/files',
75
+ {
76
+ method: 'POST',
77
+ headers: { Authorization: `Bearer ${accessToken}` },
78
+ body: formData,
79
+ }
80
+ );
81
+ ```
82
+
83
+ Note that file service requires an authenticated user for uploads. In order to allow public upload, proxy the request and add service account access token in the server.
84
+
85
+ ```typescript
86
+ app.use(
87
+ '/api/upload',
88
+ proxy('https://file-service.adsp.alberta.ca', {
89
+ proxyReqPathResolver: function() {
90
+ return '/file/v1/files';
91
+ },
92
+ proxyReqOptDecorator: async (proxyReq) => {
93
+ const accessToken = await getServiceAccountToken();
94
+ proxyReq.headers['Authorization'] = `Bearer ${accessToken}`;
95
+ return proxyReq;
96
+ },
97
+ })
98
+ );
99
+ ```
100
+
101
+ ### Find files
102
+ ```typescript
103
+ const top = 10;
104
+ const criteria = { typeEquals: 'supporting-docs' };
105
+ await fetch(
106
+ `${fileServiceUrl}/file/v1/files?top=${top}&criteria=${JSON.stringify(criteria)}`,
107
+ {
108
+ method: 'GET',
109
+ headers: { Authorization: `Bearer ${accessToken}` },
110
+ }
111
+ );
112
+ ```
113
+
114
+ ### Get file metadata
115
+ ```typescript
116
+ const response = await fetch(
117
+ `${fileServiceUrl}/file/v1/files/84401bb2-1f49-42ef-92b0-649e6c0e7462`,
118
+ {
119
+ method: 'GET',
120
+ headers: { Authorization: `Bearer ${accessToken}` },
121
+ }
122
+ );
123
+
124
+ const {
125
+ typeName,
126
+ filename,
127
+ size,
128
+ recordId,
129
+ } = await response.json();
130
+ ```
131
+
132
+ ### Download a file
133
+ ```typescript
134
+ await fetch(
135
+ `${fileServiceUrl}/file/v1/files/a217db73-0c29-4fbd-b576-49d049f855a6/download`,
136
+ {
137
+ method: 'GET',
138
+ headers: { Authorization: `Bearer ${accessToken}` },
139
+ }
140
+ );
141
+ ```
142
+
143
+ Use `unsafe=true` to download a file before it has been virus scanned.
144
+
145
+ ```typescript
146
+ await fetch(
147
+ `${fileServiceUrl}/file/v1/files/a217db73-0c29-4fbd-b576-49d049f855a6/download?unsafe=true`,
148
+ {
149
+ method: 'GET',
150
+ headers: { Authorization: `Bearer ${accessToken}` },
151
+ }
152
+ );
153
+ ```
154
+
155
+ ### Delete a file
156
+ ```typescript
157
+ await fetch(
158
+ `${fileServiceUrl}/file/v1/files/a217db73-0c29-4fbd-b576-49d049f855a6`,
159
+ {
160
+ method: 'DELETE',
161
+ headers: { Authorization: `Bearer ${accessToken}` },
162
+ }
163
+ );
164
+ ```
@@ -0,0 +1,149 @@
1
+ ---
2
+ layout: page
3
+ title: Form service
4
+ nav_order: 14
5
+ parent: Services
6
+ ---
7
+
8
+ # Form service
9
+ Form service provides for temporary storage of draft forms with support for verify code based access. This permits applicants to draft and submit forms without a user account.
10
+
11
+ The form service also includes a set of *events* and a *notification type* for keeping applicants updated on the status of their submission.
12
+
13
+ ## Client roles
14
+ client `urn:ads:platform:form-service`
15
+
16
+ | name | description |
17
+ |:-|:-|
18
+ | form-admin | Administrator role for form service. This role allows a user to query and unlock forms. |
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
+
21
+
22
+ ## Concepts
23
+ ### Form definition
24
+ Form definition describes a type of form including the allowed applicant and assessor roles and whether anonymous applicants are permitted. Form definitions are configured in the [configuration service](configuration-service.md) under the `platform:form-service` namespace and name.
25
+
26
+ ### Form
27
+ Form represents a particular instance of an application including the information entered by the *applicant*. Each form is associated with a *definition* and has a status. Statuses represent the lifecycle steps of the form and include: Draft, Locked, Submitted, and Archived.
28
+
29
+ ### Draft expiry
30
+ 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
+
32
+ ## Code examples
33
+ ### Create a draft form for an anonymous applicant
34
+ ```typescript
35
+ const form = {
36
+ definitionId,
37
+ applicant: {
38
+ addressAs: 'A.N.Other',
39
+ channels: [{
40
+ channel: 'email',
41
+ address: 'a.n.other@acme.org'
42
+ }]
43
+ }
44
+ }
45
+
46
+ const response = await fetch(
47
+ 'https://form-service.adsp.alberta.ca/form/v1/forms',
48
+ {
49
+ method: 'POST',
50
+ headers: {
51
+ 'Authorization': `Bearer ${accessToken}`,
52
+ 'Content-Type': 'application/json',
53
+ },
54
+ body: JSON.stringify(form),
55
+ }
56
+ );
57
+
58
+ const {
59
+ id,
60
+ definitionId,
61
+ status,
62
+ created,
63
+ createdBy,
64
+ lastAccessed,
65
+ } = response.json();
66
+ ```
67
+
68
+ ### Access form data using a time limited code.
69
+ Intake applications can retrieve form data on behalf of anonymous applicants by requesting a time limited code to be sent to the applicant. The code is provided to the API and verified when requesting the form data.
70
+ ```typescript
71
+ // Send a code to the applicant.
72
+ await fetch(
73
+ `https://form-service.adsp.alberta.ca/form/v1/forms/${formId}`,
74
+ {
75
+ method: 'POST',
76
+ headers: {
77
+ 'Authorization': `Bearer ${accessToken}`,
78
+ 'Content-Type': 'application/json',
79
+ },
80
+ body: JSON.stringify({
81
+ operation: 'send-code',
82
+ }),
83
+ }
84
+ );
85
+
86
+ // Get the code via user input and send it to the API to access the form data.
87
+ const response = await fetch(
88
+ `https://form-service.adsp.alberta.ca/form/v1/forms/${formId}/data?code=${code}`,
89
+ {
90
+ method: 'GET',
91
+ headers: { Authorization: `Bearer ${accessToken}` },
92
+ }
93
+ );
94
+
95
+ const {
96
+ data,
97
+ files,
98
+ } = await response.json();
99
+ ```
100
+
101
+ ### Update data in a draft form
102
+ ```typescript
103
+ const formData = {
104
+ data: {}
105
+ files: {
106
+ 'proof-of-status': fileUrn,
107
+ }
108
+ }
109
+
110
+ const response = await fetch(
111
+ `https://form-service.adsp.alberta.ca/form/v1/forms/${formId}/data`,
112
+ {
113
+ method: 'PUT',
114
+ headers: {
115
+ 'Authorization': `Bearer ${accessToken}`,
116
+ 'Content-Type': 'application/json',
117
+ },
118
+ body: JSON.stringify(formData),
119
+ }
120
+ );
121
+
122
+ const {
123
+ data,
124
+ files,
125
+ } = await response.json();
126
+ ```
127
+
128
+ ### Submit a form
129
+ ```typescript
130
+ const response = await fetch(
131
+ `https://form-service.adsp.alberta.ca/form/v1/forms/${formId}`,
132
+ {
133
+ method: 'POST',
134
+ headers: {
135
+ 'Authorization': `Bearer ${accessToken}`,
136
+ 'Content-Type': 'application/json',
137
+ },
138
+ body: JSON.stringify({
139
+ operation: 'submit'
140
+ }),
141
+ }
142
+ );
143
+
144
+ const {
145
+ id,
146
+ status,
147
+ submitted,
148
+ } = await response.json();
149
+ ```