diff --git a/packages/api/src/bindings.d.ts b/packages/api/src/bindings.d.ts index a74ee07d1c..b3c78d1dd8 100644 --- a/packages/api/src/bindings.d.ts +++ b/packages/api/src/bindings.d.ts @@ -80,6 +80,10 @@ export type NFT = { /** * Name of the JWT token used to create this NFT. */ + name?: string + /** + * Optional name of the file(s) uploaded as NFT. + */ scope: string /** * Date this NFT was created in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: YYYY-MM-DDTHH:MM:SSZ. diff --git a/packages/api/src/routes/nfts-upload.js b/packages/api/src/routes/nfts-upload.js index f00e2893ba..439c48a96c 100644 --- a/packages/api/src/routes/nfts-upload.js +++ b/packages/api/src/routes/nfts-upload.js @@ -68,6 +68,8 @@ export async function nftUpload(event, ctx) { let structure /** @type {Blob} */ let car + /** @type {string} */ + let name if (isCar) { car = blob @@ -111,6 +113,7 @@ export async function nftUpload(event, ctx) { * structure: DagStructure * files: Array<{ name: string; type?: string }> * meta?: Record + * name?: string * }} UploadCarInput * @param {UploadCarInput} params */ @@ -127,7 +130,7 @@ export async function uploadCar(params) { * @param {CarStat} stat */ export async function uploadCarWithStat( - { ctx, user, key, car, uploadType = 'Car', mimeType, files, meta }, + { ctx, user, key, car, uploadType = 'Car', mimeType, files, meta, name }, stat ) { const [added, backupUrl] = await Promise.all([ @@ -150,6 +153,7 @@ export async function uploadCarWithStat( meta, key_id: key?.id, backup_urls: backupUrl ? [backupUrl] : [], + name: name, }) return upload diff --git a/packages/api/src/utils/db-transforms.js b/packages/api/src/utils/db-transforms.js index 827773be0a..fd3aeb6245 100644 --- a/packages/api/src/utils/db-transforms.js +++ b/packages/api/src/utils/db-transforms.js @@ -28,6 +28,7 @@ export function toNFTResponse(upload, sourceCid) { scope: upload.key ? upload.key.name : 'session', files: upload.files, size: upload.content.dag_size || 0, + name: upload.name, pin: { cid: sourceCid || upload.source_cid, created: upload.content.pin[0].inserted_at,