@twin.org/nft-service 0.0.1-next.3

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.
@@ -0,0 +1,257 @@
1
+ # Class: NftService
2
+
3
+ Service for performing NFT operations to a connector.
4
+
5
+ ## Implements
6
+
7
+ - `INftComponent`
8
+
9
+ ## Constructors
10
+
11
+ ### new NftService()
12
+
13
+ > **new NftService**(`options`?): [`NftService`](NftService.md)
14
+
15
+ Create a new instance of NftService.
16
+
17
+ #### Parameters
18
+
19
+ • **options?**
20
+
21
+ The options for the service.
22
+
23
+ • **options.config?**: [`INftServiceConfig`](../interfaces/INftServiceConfig.md)
24
+
25
+ The configuration for the service.
26
+
27
+ #### Returns
28
+
29
+ [`NftService`](NftService.md)
30
+
31
+ ## Properties
32
+
33
+ ### NAMESPACE
34
+
35
+ > `readonly` `static` **NAMESPACE**: `string` = `"nft"`
36
+
37
+ The namespace supported by the nft service.
38
+
39
+ ***
40
+
41
+ ### CLASS\_NAME
42
+
43
+ > `readonly` **CLASS\_NAME**: `string`
44
+
45
+ Runtime name for the class.
46
+
47
+ #### Implementation of
48
+
49
+ `INftComponent.CLASS_NAME`
50
+
51
+ ## Methods
52
+
53
+ ### mint()
54
+
55
+ > **mint**\<`T`, `U`\>(`issuer`, `tag`, `immutableMetadata`?, `metadata`?, `namespace`?, `identity`?): `Promise`\<`string`\>
56
+
57
+ Mint an NFT.
58
+
59
+ #### Type Parameters
60
+
61
+ • **T** = `unknown`
62
+
63
+ • **U** = `unknown`
64
+
65
+ #### Parameters
66
+
67
+ • **issuer**: `string`
68
+
69
+ The issuer for the NFT, will also be the initial owner.
70
+
71
+ • **tag**: `string`
72
+
73
+ The tag for the NFT.
74
+
75
+ • **immutableMetadata?**: `T`
76
+
77
+ The immutable metadata for the NFT.
78
+
79
+ • **metadata?**: `U`
80
+
81
+ The metadata for the NFT.
82
+
83
+ • **namespace?**: `string`
84
+
85
+ The namespace of the connector to use for the NFT, defaults to service configured namespace.
86
+
87
+ • **identity?**: `string`
88
+
89
+ The identity to perform the nft operation on.
90
+
91
+ #### Returns
92
+
93
+ `Promise`\<`string`\>
94
+
95
+ The id of the created NFT in urn format.
96
+
97
+ #### Implementation of
98
+
99
+ `INftComponent.mint`
100
+
101
+ ***
102
+
103
+ ### resolve()
104
+
105
+ > **resolve**\<`T`, `U`\>(`id`, `identity`?): `Promise`\<`object`\>
106
+
107
+ Resolve an NFT.
108
+
109
+ #### Type Parameters
110
+
111
+ • **T** = `unknown`
112
+
113
+ • **U** = `unknown`
114
+
115
+ #### Parameters
116
+
117
+ • **id**: `string`
118
+
119
+ The id of the NFT to resolve.
120
+
121
+ • **identity?**: `string`
122
+
123
+ The identity to perform the nft operation on.
124
+
125
+ #### Returns
126
+
127
+ `Promise`\<`object`\>
128
+
129
+ The data for the NFT.
130
+
131
+ ##### issuer
132
+
133
+ > **issuer**: `string`
134
+
135
+ ##### owner
136
+
137
+ > **owner**: `string`
138
+
139
+ ##### tag
140
+
141
+ > **tag**: `string`
142
+
143
+ ##### immutableMetadata?
144
+
145
+ > `optional` **immutableMetadata**: `T`
146
+
147
+ ##### metadata?
148
+
149
+ > `optional` **metadata**: `U`
150
+
151
+ #### Implementation of
152
+
153
+ `INftComponent.resolve`
154
+
155
+ ***
156
+
157
+ ### burn()
158
+
159
+ > **burn**(`id`, `identity`?): `Promise`\<`void`\>
160
+
161
+ Burn an NFT.
162
+
163
+ #### Parameters
164
+
165
+ • **id**: `string`
166
+
167
+ The id of the NFT to burn in urn format.
168
+
169
+ • **identity?**: `string`
170
+
171
+ The identity to perform the nft operation on.
172
+
173
+ #### Returns
174
+
175
+ `Promise`\<`void`\>
176
+
177
+ Nothing.
178
+
179
+ #### Implementation of
180
+
181
+ `INftComponent.burn`
182
+
183
+ ***
184
+
185
+ ### transfer()
186
+
187
+ > **transfer**\<`T`\>(`id`, `recipient`, `metadata`?, `identity`?): `Promise`\<`void`\>
188
+
189
+ Transfer an NFT.
190
+
191
+ #### Type Parameters
192
+
193
+ • **T** = `unknown`
194
+
195
+ #### Parameters
196
+
197
+ • **id**: `string`
198
+
199
+ The id of the NFT to transfer in urn format.
200
+
201
+ • **recipient**: `string`
202
+
203
+ The recipient of the NFT.
204
+
205
+ • **metadata?**: `T`
206
+
207
+ Optional mutable data to include during the transfer.
208
+
209
+ • **identity?**: `string`
210
+
211
+ The identity to perform the nft operation on.
212
+
213
+ #### Returns
214
+
215
+ `Promise`\<`void`\>
216
+
217
+ Nothing.
218
+
219
+ #### Implementation of
220
+
221
+ `INftComponent.transfer`
222
+
223
+ ***
224
+
225
+ ### update()
226
+
227
+ > **update**\<`T`\>(`id`, `metadata`, `identity`?): `Promise`\<`void`\>
228
+
229
+ Update the data of the NFT.
230
+
231
+ #### Type Parameters
232
+
233
+ • **T** = `unknown`
234
+
235
+ #### Parameters
236
+
237
+ • **id**: `string`
238
+
239
+ The id of the NFT to update in urn format.
240
+
241
+ • **metadata**: `T`
242
+
243
+ The mutable data to update.
244
+
245
+ • **identity?**: `string`
246
+
247
+ The identity to perform the nft operation on.
248
+
249
+ #### Returns
250
+
251
+ `Promise`\<`void`\>
252
+
253
+ Nothing.
254
+
255
+ #### Implementation of
256
+
257
+ `INftComponent.update`
@@ -0,0 +1,21 @@
1
+ # Function: generateRestRoutesNft()
2
+
3
+ > **generateRestRoutesNft**(`baseRouteName`, `componentName`): `IRestRoute`[]
4
+
5
+ The REST routes for NFT.
6
+
7
+ ## Parameters
8
+
9
+ • **baseRouteName**: `string`
10
+
11
+ Prefix to prepend to the paths.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes stored in the ComponentFactory.
16
+
17
+ ## Returns
18
+
19
+ `IRestRoute`[]
20
+
21
+ The generated routes.
@@ -0,0 +1,25 @@
1
+ # Function: nftBurn()
2
+
3
+ > **nftBurn**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ Burn an NFT.
6
+
7
+ ## Parameters
8
+
9
+ • **httpRequestContext**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `INftBurnRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`INoContentResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: nftMint()
2
+
3
+ > **nftMint**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ICreatedResponse`\>
4
+
5
+ Mint an NFT.
6
+
7
+ ## Parameters
8
+
9
+ • **httpRequestContext**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `INftMintRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`ICreatedResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: nftResolve()
2
+
3
+ > **nftResolve**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INftResolveResponse`\>
4
+
5
+ Resolve an NFT.
6
+
7
+ ## Parameters
8
+
9
+ • **httpRequestContext**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `INftResolveRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`INftResolveResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: nftTransfer()
2
+
3
+ > **nftTransfer**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ Transfer an NFT.
6
+
7
+ ## Parameters
8
+
9
+ • **httpRequestContext**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `INftTransferRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`INoContentResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,25 @@
1
+ # Function: nftUpdate()
2
+
3
+ > **nftUpdate**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`INoContentResponse`\>
4
+
5
+ Update an NFT.
6
+
7
+ ## Parameters
8
+
9
+ • **httpRequestContext**: `IHttpRequestContext`
10
+
11
+ The request context for the API.
12
+
13
+ • **componentName**: `string`
14
+
15
+ The name of the component to use in the routes.
16
+
17
+ • **request**: `INftUpdateRequest`
18
+
19
+ The request.
20
+
21
+ ## Returns
22
+
23
+ `Promise`\<`INoContentResponse`\>
24
+
25
+ The response object with additional http response properties.
@@ -0,0 +1,23 @@
1
+ # @twin.org/nft-service
2
+
3
+ ## Classes
4
+
5
+ - [NftService](classes/NftService.md)
6
+
7
+ ## Interfaces
8
+
9
+ - [INftServiceConfig](interfaces/INftServiceConfig.md)
10
+
11
+ ## Variables
12
+
13
+ - [tagsNft](variables/tagsNft.md)
14
+ - [restEntryPoints](variables/restEntryPoints.md)
15
+
16
+ ## Functions
17
+
18
+ - [generateRestRoutesNft](functions/generateRestRoutesNft.md)
19
+ - [nftMint](functions/nftMint.md)
20
+ - [nftResolve](functions/nftResolve.md)
21
+ - [nftBurn](functions/nftBurn.md)
22
+ - [nftTransfer](functions/nftTransfer.md)
23
+ - [nftUpdate](functions/nftUpdate.md)
@@ -0,0 +1,11 @@
1
+ # Interface: INftServiceConfig
2
+
3
+ Configuration for the NFT Service.
4
+
5
+ ## Properties
6
+
7
+ ### defaultNamespace?
8
+
9
+ > `optional` **defaultNamespace**: `string`
10
+
11
+ What is the default connector to use for NFT. If not provided the first connector from the factory will be used.
@@ -0,0 +1,3 @@
1
+ # Variable: restEntryPoints
2
+
3
+ > `const` **restEntryPoints**: `IRestRouteEntryPoint`[]
@@ -0,0 +1,5 @@
1
+ # Variable: tagsNft
2
+
3
+ > `const` **tagsNft**: `ITag`[]
4
+
5
+ The tag to associate with the routes.
@@ -0,0 +1,13 @@
1
+ {
2
+ "error": {
3
+ "nftService": {
4
+ "namespaceMismatch": "The namespace in the urn \"{id}\" does not match the namespace of the NFT service \"{namespace}\"",
5
+ "noConnectors": "There are no connectors registered with the nft factory",
6
+ "mintFailed": "The minting of the NFT failed",
7
+ "resolveFailed": "The resolving of the NFT failed",
8
+ "burnFailed": "The burning of the NFT failed",
9
+ "transferFailed": "The transfer of the NFT failed",
10
+ "updateFailed": "The update of the NFT failed"
11
+ }
12
+ }
13
+ }
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@twin.org/nft-service",
3
+ "version": "0.0.1-next.3",
4
+ "description": "NFT contract implementation and REST endpoint definitions",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/twinfoundation/nft.git",
8
+ "directory": "packages/nft-service"
9
+ },
10
+ "author": "martyn.janes@iota.org",
11
+ "license": "Apache-2.0",
12
+ "type": "module",
13
+ "engines": {
14
+ "node": ">=20.0.0"
15
+ },
16
+ "scripts": {
17
+ "clean": "rimraf dist coverage docs/reference",
18
+ "build": "tspc",
19
+ "test": "vitest --run --config ./vitest.config.ts --no-cache",
20
+ "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
21
+ "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
22
+ "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
23
+ "bundle": "npm run bundle:esm && npm run bundle:cjs",
24
+ "docs:clean": "rimraf docs/reference",
25
+ "docs:generate": "typedoc",
26
+ "docs:api": "ts-to-openapi ./ts-to-openapi.json ./docs/open-api/spec.json",
27
+ "docs": "npm run docs:clean && npm run docs:generate && npm run docs:api",
28
+ "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
29
+ },
30
+ "dependencies": {
31
+ "@twin.org/api-models": "next",
32
+ "@twin.org/core": "next",
33
+ "@twin.org/entity": "next",
34
+ "@twin.org/nameof": "next",
35
+ "@twin.org/nft-models": "0.0.1-next.3",
36
+ "@twin.org/web": "next"
37
+ },
38
+ "devDependencies": {
39
+ "@twin.org/nameof-transformer": "next",
40
+ "@twin.org/nft-connector-entity-storage": "0.0.1-next.3",
41
+ "@twin.org/ts-to-openapi": "next",
42
+ "@vitest/coverage-v8": "2.1.1",
43
+ "copyfiles": "2.4.1",
44
+ "rimraf": "6.0.1",
45
+ "rollup": "4.22.0",
46
+ "rollup-plugin-typescript2": "0.36.0",
47
+ "ts-patch": "3.2.1",
48
+ "typedoc": "0.26.7",
49
+ "typedoc-plugin-markdown": "4.2.7",
50
+ "typescript": "5.6.2",
51
+ "vitest": "2.1.1"
52
+ },
53
+ "main": "./dist/cjs/index.cjs",
54
+ "module": "./dist/esm/index.mjs",
55
+ "types": "./dist/types/index.d.ts",
56
+ "exports": {
57
+ ".": {
58
+ "require": "./dist/cjs/index.cjs",
59
+ "import": "./dist/esm/index.mjs",
60
+ "types": "./dist/types/index.d.ts"
61
+ },
62
+ "./locales": "./locales"
63
+ },
64
+ "files": [
65
+ "dist/cjs",
66
+ "dist/esm",
67
+ "dist/types",
68
+ "locales",
69
+ "docs"
70
+ ]
71
+ }