@twin.org/notarization-service 0.0.3-next.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/LICENSE +201 -0
- package/README.md +21 -0
- package/dist/es/index.js +8 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/INotarizationServiceConfig.js +4 -0
- package/dist/es/models/INotarizationServiceConfig.js.map +1 -0
- package/dist/es/models/INotarizationServiceConstructorOptions.js +2 -0
- package/dist/es/models/INotarizationServiceConstructorOptions.js.map +1 -0
- package/dist/es/notarizationRoutes.js +318 -0
- package/dist/es/notarizationRoutes.js.map +1 -0
- package/dist/es/notarizationService.js +151 -0
- package/dist/es/notarizationService.js.map +1 -0
- package/dist/es/restEntryPoints.js +10 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/models/INotarizationServiceConfig.d.ts +9 -0
- package/dist/types/models/INotarizationServiceConstructorOptions.d.ts +10 -0
- package/dist/types/notarizationRoutes.d.ts +53 -0
- package/dist/types/notarizationService.d.ts +57 -0
- package/dist/types/restEntryPoints.d.ts +2 -0
- package/docs/changelog.md +19 -0
- package/docs/examples.md +185 -0
- package/docs/open-api/spec.json +712 -0
- package/docs/reference/classes/NotarizationService.md +219 -0
- package/docs/reference/functions/generateRestRoutesNotarization.md +25 -0
- package/docs/reference/functions/notarizationCreate.md +31 -0
- package/docs/reference/functions/notarizationGet.md +31 -0
- package/docs/reference/functions/notarizationRemove.md +31 -0
- package/docs/reference/functions/notarizationTransfer.md +31 -0
- package/docs/reference/functions/notarizationUpdate.md +31 -0
- package/docs/reference/index.md +24 -0
- package/docs/reference/interfaces/INotarizationServiceConfig.md +11 -0
- package/docs/reference/interfaces/INotarizationServiceConstructorOptions.md +11 -0
- package/docs/reference/variables/restEntryPoints.md +3 -0
- package/docs/reference/variables/tagsNotarization.md +5 -0
- package/locales/en.json +13 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2024 IOTA Stiftung.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# TWIN Notarization Service
|
|
2
|
+
|
|
3
|
+
This package provides notarization service orchestration with REST route generation. It centralises connector resolution behind a consistent interface so applications can invoke notarization actions without coupling to a specific backend.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
npm install @twin.org/notarization-service
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Examples
|
|
12
|
+
|
|
13
|
+
Usage of the APIs is shown in the examples [docs/examples.md](docs/examples.md)
|
|
14
|
+
|
|
15
|
+
## References
|
|
16
|
+
|
|
17
|
+
The API reference is available in [docs/reference/index.md](docs/reference/index.md)
|
|
18
|
+
|
|
19
|
+
## Changelog
|
|
20
|
+
|
|
21
|
+
The changes between each version can be found in [docs/changelog.md](docs/changelog.md)
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Copyright 2026 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
export * from "./models/INotarizationServiceConfig.js";
|
|
4
|
+
export * from "./models/INotarizationServiceConstructorOptions.js";
|
|
5
|
+
export * from "./notarizationRoutes.js";
|
|
6
|
+
export * from "./notarizationService.js";
|
|
7
|
+
export * from "./restEntryPoints.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,wCAAwC,CAAC;AACvD,cAAc,oDAAoD,CAAC;AACnE,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./models/INotarizationServiceConfig.js\";\nexport * from \"./models/INotarizationServiceConstructorOptions.js\";\nexport * from \"./notarizationRoutes.js\";\nexport * from \"./notarizationService.js\";\nexport * from \"./restEntryPoints.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"INotarizationServiceConfig.js","sourceRoot":"","sources":["../../../src/models/INotarizationServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the Notarization Service.\n */\nexport interface INotarizationServiceConfig {\n\t/**\n\t * What is the default connector to use for notarization. If not provided the first connector from the factory will be used.\n\t */\n\tdefaultNamespace?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"INotarizationServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/INotarizationServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { INotarizationServiceConfig } from \"./INotarizationServiceConfig.js\";\n\n/**\n * Options for the notarization service constructor.\n */\nexport interface INotarizationServiceConstructorOptions {\n\t/**\n\t * The configuration for the service.\n\t */\n\tconfig?: INotarizationServiceConfig;\n}\n"]}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { ContextIdHelper, ContextIdKeys, ContextIdStore } from "@twin.org/context";
|
|
2
|
+
import { ComponentFactory, Guards } from "@twin.org/core";
|
|
3
|
+
import { HeaderTypes, HttpStatusCode } from "@twin.org/web";
|
|
4
|
+
/**
|
|
5
|
+
* The source for the routes.
|
|
6
|
+
*/
|
|
7
|
+
const ROUTES_SOURCE = "notarizationRoutes";
|
|
8
|
+
/**
|
|
9
|
+
* The tag to associate with the routes.
|
|
10
|
+
*/
|
|
11
|
+
export const tagsNotarization = [
|
|
12
|
+
{
|
|
13
|
+
name: "Notarization",
|
|
14
|
+
description: "Endpoints which are modelled to access a notarization service."
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* The REST routes for notarization.
|
|
19
|
+
* @param baseRouteName Prefix to prepend to the paths.
|
|
20
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
21
|
+
* @returns The generated routes.
|
|
22
|
+
*/
|
|
23
|
+
export function generateRestRoutesNotarization(baseRouteName, componentName) {
|
|
24
|
+
const createRoute = {
|
|
25
|
+
operationId: "notarizationCreate",
|
|
26
|
+
summary: "Create a notarization",
|
|
27
|
+
tag: tagsNotarization[0].name,
|
|
28
|
+
method: "POST",
|
|
29
|
+
path: `${baseRouteName}/`,
|
|
30
|
+
handler: async (httpRequestContext, request) => notarizationCreate(httpRequestContext, componentName, request),
|
|
31
|
+
requestType: {
|
|
32
|
+
type: "INotarizationCreateRequest",
|
|
33
|
+
examples: [
|
|
34
|
+
{
|
|
35
|
+
id: "notarizationCreateExample",
|
|
36
|
+
request: {
|
|
37
|
+
body: {
|
|
38
|
+
mode: "dynamic",
|
|
39
|
+
data: new Uint8Array(),
|
|
40
|
+
description: "My first notarization"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
responseType: [
|
|
47
|
+
{
|
|
48
|
+
type: "ICreatedResponse",
|
|
49
|
+
examples: [
|
|
50
|
+
{
|
|
51
|
+
id: "notarizationCreateResponseExample",
|
|
52
|
+
response: {
|
|
53
|
+
statusCode: HttpStatusCode.created,
|
|
54
|
+
headers: {
|
|
55
|
+
[HeaderTypes.Location]: "123"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
};
|
|
63
|
+
const removeRoute = {
|
|
64
|
+
operationId: "notarizationRemove",
|
|
65
|
+
summary: "Remove a notarization",
|
|
66
|
+
tag: tagsNotarization[0].name,
|
|
67
|
+
method: "DELETE",
|
|
68
|
+
path: `${baseRouteName}/:id`,
|
|
69
|
+
handler: async (httpRequestContext, request) => notarizationRemove(httpRequestContext, componentName, request),
|
|
70
|
+
requestType: {
|
|
71
|
+
type: "INotarizationRemoveRequest",
|
|
72
|
+
examples: [
|
|
73
|
+
{
|
|
74
|
+
id: "notarizationRemoveExample",
|
|
75
|
+
request: {
|
|
76
|
+
pathParams: {
|
|
77
|
+
id: "123"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
responseType: [
|
|
84
|
+
{
|
|
85
|
+
type: "INoContentResponse",
|
|
86
|
+
examples: [
|
|
87
|
+
{
|
|
88
|
+
id: "notarizationRemoveResponseExample",
|
|
89
|
+
response: {
|
|
90
|
+
statusCode: HttpStatusCode.noContent
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
};
|
|
97
|
+
const getRoute = {
|
|
98
|
+
operationId: "notarizationGet",
|
|
99
|
+
summary: "Get a notarization",
|
|
100
|
+
tag: tagsNotarization[0].name,
|
|
101
|
+
method: "GET",
|
|
102
|
+
path: `${baseRouteName}/:id`,
|
|
103
|
+
handler: async (httpRequestContext, request) => notarizationGet(httpRequestContext, componentName, request),
|
|
104
|
+
requestType: {
|
|
105
|
+
type: "INotarizationGetRequest",
|
|
106
|
+
examples: [
|
|
107
|
+
{
|
|
108
|
+
id: "notarizationGetExample",
|
|
109
|
+
request: {
|
|
110
|
+
pathParams: {
|
|
111
|
+
id: "123"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
responseType: [
|
|
118
|
+
{
|
|
119
|
+
type: "INotarizationGetResponse",
|
|
120
|
+
examples: [
|
|
121
|
+
{
|
|
122
|
+
id: "notarizationGetResponseExample",
|
|
123
|
+
response: {
|
|
124
|
+
body: {
|
|
125
|
+
id: "123",
|
|
126
|
+
mode: "dynamic",
|
|
127
|
+
dateCreated: "2026-01-01T00:00:00.000Z",
|
|
128
|
+
data: new Uint8Array(),
|
|
129
|
+
description: "A notarization"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
};
|
|
137
|
+
const updateRoute = {
|
|
138
|
+
operationId: "notarizationUpdate",
|
|
139
|
+
summary: "Update a notarization",
|
|
140
|
+
tag: tagsNotarization[0].name,
|
|
141
|
+
method: "PUT",
|
|
142
|
+
path: `${baseRouteName}/:id`,
|
|
143
|
+
handler: async (httpRequestContext, request) => notarizationUpdate(httpRequestContext, componentName, request),
|
|
144
|
+
requestType: {
|
|
145
|
+
type: "INotarizationUpdateRequest",
|
|
146
|
+
examples: [
|
|
147
|
+
{
|
|
148
|
+
id: "notarizationUpdateExample",
|
|
149
|
+
request: {
|
|
150
|
+
pathParams: {
|
|
151
|
+
id: "123"
|
|
152
|
+
},
|
|
153
|
+
body: {
|
|
154
|
+
id: "123",
|
|
155
|
+
mode: "dynamic",
|
|
156
|
+
dateCreated: "2026-01-01T00:00:00.000Z",
|
|
157
|
+
data: new Uint8Array(),
|
|
158
|
+
description: "Updated notarization"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
responseType: [
|
|
165
|
+
{
|
|
166
|
+
type: "INoContentResponse",
|
|
167
|
+
examples: [
|
|
168
|
+
{
|
|
169
|
+
id: "notarizationUpdateResponseExample",
|
|
170
|
+
response: {
|
|
171
|
+
statusCode: HttpStatusCode.noContent
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
};
|
|
178
|
+
const transferRoute = {
|
|
179
|
+
operationId: "notarizationTransfer",
|
|
180
|
+
summary: "Transfer a notarization",
|
|
181
|
+
tag: tagsNotarization[0].name,
|
|
182
|
+
method: "POST",
|
|
183
|
+
path: `${baseRouteName}/:id/transfer`,
|
|
184
|
+
handler: async (httpRequestContext, request) => notarizationTransfer(httpRequestContext, componentName, request),
|
|
185
|
+
requestType: {
|
|
186
|
+
type: "INotarizationTransferRequest",
|
|
187
|
+
examples: [
|
|
188
|
+
{
|
|
189
|
+
id: "notarizationTransferExample",
|
|
190
|
+
request: {
|
|
191
|
+
pathParams: {
|
|
192
|
+
id: "123"
|
|
193
|
+
},
|
|
194
|
+
body: {
|
|
195
|
+
recipientAddress: "recipient-address-1"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
responseType: [
|
|
202
|
+
{
|
|
203
|
+
type: "INoContentResponse",
|
|
204
|
+
examples: [
|
|
205
|
+
{
|
|
206
|
+
id: "notarizationTransferResponseExample",
|
|
207
|
+
response: {
|
|
208
|
+
statusCode: HttpStatusCode.noContent
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
]
|
|
214
|
+
};
|
|
215
|
+
return [createRoute, getRoute, removeRoute, updateRoute, transferRoute];
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Perform the create notarization operation.
|
|
219
|
+
* @param httpRequestContext The request context for the API.
|
|
220
|
+
* @param componentName The name of the component to use in the routes.
|
|
221
|
+
* @param request The request.
|
|
222
|
+
* @returns The response object with additional http response properties.
|
|
223
|
+
*/
|
|
224
|
+
export async function notarizationCreate(httpRequestContext, componentName, request) {
|
|
225
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
226
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
227
|
+
const contextIds = await ContextIdStore.getContextIds();
|
|
228
|
+
ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
|
|
229
|
+
const component = ComponentFactory.get(componentName);
|
|
230
|
+
const { namespace, ...notarization } = request.body;
|
|
231
|
+
const result = await component.create(notarization, namespace, contextIds[ContextIdKeys.Organization]);
|
|
232
|
+
return {
|
|
233
|
+
statusCode: HttpStatusCode.created,
|
|
234
|
+
headers: {
|
|
235
|
+
[HeaderTypes.Location]: result
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Perform the remove notarization operation.
|
|
241
|
+
* @param httpRequestContext The request context for the API.
|
|
242
|
+
* @param componentName The name of the component to use in the routes.
|
|
243
|
+
* @param request The request.
|
|
244
|
+
* @returns The response object with additional http response properties.
|
|
245
|
+
*/
|
|
246
|
+
export async function notarizationRemove(httpRequestContext, componentName, request) {
|
|
247
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
248
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
249
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
250
|
+
const contextIds = await ContextIdStore.getContextIds();
|
|
251
|
+
ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
|
|
252
|
+
const component = ComponentFactory.get(componentName);
|
|
253
|
+
await component.remove(request.pathParams.id, contextIds[ContextIdKeys.Organization]);
|
|
254
|
+
return {
|
|
255
|
+
statusCode: HttpStatusCode.noContent
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Perform the get notarization operation.
|
|
260
|
+
* @param httpRequestContext The request context for the API.
|
|
261
|
+
* @param componentName The name of the component to use in the routes.
|
|
262
|
+
* @param request The request.
|
|
263
|
+
* @returns The response object with additional http response properties.
|
|
264
|
+
*/
|
|
265
|
+
export async function notarizationGet(httpRequestContext, componentName, request) {
|
|
266
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
267
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
268
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
269
|
+
const component = ComponentFactory.get(componentName);
|
|
270
|
+
return {
|
|
271
|
+
body: await component.get(request.pathParams.id)
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Perform the update notarization operation.
|
|
276
|
+
* @param httpRequestContext The request context for the API.
|
|
277
|
+
* @param componentName The name of the component to use in the routes.
|
|
278
|
+
* @param request The request.
|
|
279
|
+
* @returns The response object with additional http response properties.
|
|
280
|
+
*/
|
|
281
|
+
export async function notarizationUpdate(httpRequestContext, componentName, request) {
|
|
282
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
283
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
284
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
285
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
286
|
+
const contextIds = await ContextIdStore.getContextIds();
|
|
287
|
+
ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
|
|
288
|
+
const component = ComponentFactory.get(componentName);
|
|
289
|
+
await component.update({
|
|
290
|
+
...request.body,
|
|
291
|
+
id: request.pathParams.id
|
|
292
|
+
}, contextIds[ContextIdKeys.Organization]);
|
|
293
|
+
return {
|
|
294
|
+
statusCode: HttpStatusCode.noContent
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Perform the transfer notarization operation.
|
|
299
|
+
* @param httpRequestContext The request context for the API.
|
|
300
|
+
* @param componentName The name of the component to use in the routes.
|
|
301
|
+
* @param request The request.
|
|
302
|
+
* @returns The response object with additional http response properties.
|
|
303
|
+
*/
|
|
304
|
+
export async function notarizationTransfer(httpRequestContext, componentName, request) {
|
|
305
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
306
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
307
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
308
|
+
Guards.object(ROUTES_SOURCE, "request.body", request.body);
|
|
309
|
+
Guards.stringValue(ROUTES_SOURCE, "request.body.recipientAddress", request.body.recipientAddress);
|
|
310
|
+
const contextIds = await ContextIdStore.getContextIds();
|
|
311
|
+
ContextIdHelper.guard(contextIds, ContextIdKeys.Organization);
|
|
312
|
+
const component = ComponentFactory.get(componentName);
|
|
313
|
+
await component.transfer(request.pathParams.id, request.body.recipientAddress, contextIds[ContextIdKeys.Organization]);
|
|
314
|
+
return {
|
|
315
|
+
statusCode: HttpStatusCode.noContent
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=notarizationRoutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notarizationRoutes.js","sourceRoot":"","sources":["../../src/notarizationRoutes.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAW1D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE5D;;GAEG;AACH,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAW;IACvC;QACC,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,gEAAgE;KAC7E;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAC7C,aAAqB,EACrB,aAAqB;IAErB,MAAM,WAAW,GAA6D;QAC7E,WAA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xD,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAE9D,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAyB,aAAa,CAAC,CAAC;IAC9E,MAAM,SAAS,CAAC,QAAQ,CACvB,OAAO,CAAC,UAAU,CAAC,EAAE,EACrB,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAC7B,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CACtC,CAAC;IAEF,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tICreatedResponse,\n\tIHttpRequestContext,\n\tINoContentResponse,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type {\n\tINotarizationComponent,\n\tINotarizationCreateRequest,\n\tINotarizationGetRequest,\n\tINotarizationGetResponse,\n\tINotarizationRemoveRequest,\n\tINotarizationTransferRequest,\n\tINotarizationUpdateRequest\n} from \"@twin.org/notarization-models\";\nimport { HeaderTypes, HttpStatusCode } from \"@twin.org/web\";\n\n/**\n * The source for the routes.\n */\nconst ROUTES_SOURCE = \"notarizationRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsNotarization: ITag[] = [\n\t{\n\t\tname: \"Notarization\",\n\t\tdescription: \"Endpoints which are modelled to access a notarization service.\"\n\t}\n];\n\n/**\n * The REST routes for notarization.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesNotarization(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst createRoute: IRestRoute<INotarizationCreateRequest, ICreatedResponse> = {\n\t\toperationId: \"notarizationCreate\",\n\t\tsummary: \"Create a notarization\",\n\t\ttag: tagsNotarization[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnotarizationCreate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INotarizationCreateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"notarizationCreateExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tmode: \"dynamic\",\n\t\t\t\t\t\t\tdata: new Uint8Array(),\n\t\t\t\t\t\t\tdescription: \"My first notarization\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICreatedResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"notarizationCreateResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.created,\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.Location]: \"123\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst removeRoute: IRestRoute<INotarizationRemoveRequest, INoContentResponse> = {\n\t\toperationId: \"notarizationRemove\",\n\t\tsummary: \"Remove a notarization\",\n\t\ttag: tagsNotarization[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnotarizationRemove(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INotarizationRemoveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"notarizationRemoveExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"123\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"notarizationRemoveResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.noContent\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst getRoute: IRestRoute<INotarizationGetRequest, INotarizationGetResponse> = {\n\t\toperationId: \"notarizationGet\",\n\t\tsummary: \"Get a notarization\",\n\t\ttag: tagsNotarization[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnotarizationGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INotarizationGetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"notarizationGetExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"123\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INotarizationGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"notarizationGetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tid: \"123\",\n\t\t\t\t\t\t\t\tmode: \"dynamic\",\n\t\t\t\t\t\t\t\tdateCreated: \"2026-01-01T00:00:00.000Z\",\n\t\t\t\t\t\t\t\tdata: new Uint8Array(),\n\t\t\t\t\t\t\t\tdescription: \"A notarization\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst updateRoute: IRestRoute<INotarizationUpdateRequest, INoContentResponse> = {\n\t\toperationId: \"notarizationUpdate\",\n\t\tsummary: \"Update a notarization\",\n\t\ttag: tagsNotarization[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnotarizationUpdate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INotarizationUpdateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"notarizationUpdateExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"123\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tid: \"123\",\n\t\t\t\t\t\t\tmode: \"dynamic\",\n\t\t\t\t\t\t\tdateCreated: \"2026-01-01T00:00:00.000Z\",\n\t\t\t\t\t\t\tdata: new Uint8Array(),\n\t\t\t\t\t\t\tdescription: \"Updated notarization\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"notarizationUpdateResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.noContent\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst transferRoute: IRestRoute<INotarizationTransferRequest, INoContentResponse> = {\n\t\toperationId: \"notarizationTransfer\",\n\t\tsummary: \"Transfer a notarization\",\n\t\ttag: tagsNotarization[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/:id/transfer`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tnotarizationTransfer(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<INotarizationTransferRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"notarizationTransferExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"123\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\trecipientAddress: \"recipient-address-1\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"notarizationTransferResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tstatusCode: HttpStatusCode.noContent\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [createRoute, getRoute, removeRoute, updateRoute, transferRoute];\n}\n\n/**\n * Perform the create notarization operation.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function notarizationCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INotarizationCreateRequest\n): Promise<ICreatedResponse> {\n\tGuards.object<INotarizationCreateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INotarizationCreateRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INotarizationComponent>(componentName);\n\tconst { namespace, ...notarization } = request.body;\n\tconst result = await component.create(\n\t\tnotarization,\n\t\tnamespace,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders: {\n\t\t\t[HeaderTypes.Location]: result\n\t\t}\n\t};\n}\n\n/**\n * Perform the remove notarization operation.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function notarizationRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INotarizationRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<INotarizationRemoveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INotarizationRemoveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INotarizationComponent>(componentName);\n\tawait component.remove(request.pathParams.id, contextIds[ContextIdKeys.Organization]);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Perform the get notarization operation.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function notarizationGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INotarizationGetRequest\n): Promise<INotarizationGetResponse> {\n\tGuards.object<INotarizationGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INotarizationGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<INotarizationComponent>(componentName);\n\n\treturn {\n\t\tbody: await component.get(request.pathParams.id)\n\t};\n}\n\n/**\n * Perform the update notarization operation.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function notarizationUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INotarizationUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.object<INotarizationUpdateRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INotarizationUpdateRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.object<INotarizationUpdateRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INotarizationComponent>(componentName);\n\tawait component.update(\n\t\t{\n\t\t\t...request.body,\n\t\t\tid: request.pathParams.id\n\t\t},\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Perform the transfer notarization operation.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function notarizationTransfer(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: INotarizationTransferRequest\n): Promise<INoContentResponse> {\n\tGuards.object<INotarizationTransferRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<INotarizationTransferRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.object<INotarizationTransferRequest[\"body\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body),\n\t\trequest.body\n\t);\n\tGuards.stringValue(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.body.recipientAddress),\n\t\trequest.body.recipientAddress\n\t);\n\n\tconst contextIds = await ContextIdStore.getContextIds();\n\tContextIdHelper.guard(contextIds, ContextIdKeys.Organization);\n\n\tconst component = ComponentFactory.get<INotarizationComponent>(componentName);\n\tawait component.transfer(\n\t\trequest.pathParams.id,\n\t\trequest.body.recipientAddress,\n\t\tcontextIds[ContextIdKeys.Organization]\n\t);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n"]}
|