From 2dbe99ebe98e702cc19e67257f3f4ab64f16de40 Mon Sep 17 00:00:00 2001 From: Roy Scheeren Date: Fri, 22 Nov 2024 19:07:01 +0100 Subject: [PATCH] refactor(envited.ascs.digital): debug Signed-off-by: Roy Scheeren --- .../common/asset/validateAndCreateMetadata.ts | 8 -------- .../common/asset/validateAndCreateMetadata.utils.ts | 1 + .../aws/handlers/processAssetUpload/processAssetUpload.ts | 4 ---- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/apps/envited.ascs.digital/common/asset/validateAndCreateMetadata.ts b/apps/envited.ascs.digital/common/asset/validateAndCreateMetadata.ts index 10b5143c..5f355348 100644 --- a/apps/envited.ascs.digital/common/asset/validateAndCreateMetadata.ts +++ b/apps/envited.ascs.digital/common/asset/validateAndCreateMetadata.ts @@ -220,12 +220,8 @@ export const _validateAndCreateMetadata = }) => async (byteArray: Uint8Array, asset: Asset) => { try { - console.log('2a') const { conforms, reports, data } = await getShaclSchemaAndValidate(byteArray) - console.log('2b') - console.log(byteArray) const assetCID = await createFilename(byteArray) - console.log(assetCID) const domainMetadataCID = await createFilename(data.domainMetadata) const connection = await db() @@ -233,18 +229,15 @@ export const _validateAndCreateMetadata = if (!user) { throw new Error('User not found') } - console.log('2c') const [issuer] = await connection.getUserWithProfileById(user.issuerId) if (!issuer) { throw new Error('Issuer not found') } - console.log('2d') const files = await getFilesAsPathAndByteArrayFromManifest(byteArray, data.manifest) const visualization = filter(propEq('visualization', 'type'))(files.publicUser) as ExtractedFile[] const visualizationFiles = await getAllFilenamesFromFiles(visualization) const displayUri = find(propEq('visualization', 'type'))(visualizationFiles) as ExtractedFileWithCID - console.log('2e') const modifiedManifest = createModifiedManifest({ assetCID, domainMetadataCID, @@ -264,7 +257,6 @@ export const _validateAndCreateMetadata = manifest: data.manifest, domainMetadata: data.domainMetadata, }) - console.log('2f') return { conforms, reports, diff --git a/apps/envited.ascs.digital/common/asset/validateAndCreateMetadata.utils.ts b/apps/envited.ascs.digital/common/asset/validateAndCreateMetadata.utils.ts index c7d49c84..9de0cdd1 100644 --- a/apps/envited.ascs.digital/common/asset/validateAndCreateMetadata.utils.ts +++ b/apps/envited.ascs.digital/common/asset/validateAndCreateMetadata.utils.ts @@ -27,6 +27,7 @@ export const _createFilename = ({ raw, sha256, CID }: { raw: any; sha256: Hasher<'sha2-256', 18>; CID: any }) => async (byteArray: any) => { try { + console.log(typeof byteArray, instanceof byteArray) const rawBytes = raw.encode(byteArray) const hash = await sha256.digest(rawBytes) const cid = CID.create(1, raw.code, hash) diff --git a/apps/envited.ascs.digital/common/aws/handlers/processAssetUpload/processAssetUpload.ts b/apps/envited.ascs.digital/common/aws/handlers/processAssetUpload/processAssetUpload.ts index e2295831..9b83c943 100644 --- a/apps/envited.ascs.digital/common/aws/handlers/processAssetUpload/processAssetUpload.ts +++ b/apps/envited.ascs.digital/common/aws/handlers/processAssetUpload/processAssetUpload.ts @@ -59,7 +59,6 @@ export const _main = }): S3Handler => async event => { try { - console.log(1) // Read uploaded asset const s3Record = event.Records[0].s3 @@ -71,14 +70,12 @@ export const _main = if (isNil(Body)) { return } - console.log(2) const uploadedFile = await Body.transformToByteArray() // Validate uploaded asset const asset = await getAsset(Key) const { conforms, metadata, assetCID, modifiedManifest, files, visualizationFiles } = await validateAndCreateMetadata(uploadedFile, asset) - console.log(3) if (!conforms) { // Revert if validation fails await deleteFile({ Bucket, Key }) @@ -86,7 +83,6 @@ export const _main = return } - console.log(4) // Copy asset ZIP file to S3 with CID as name await copyFile({ Bucket,