Skip to content

Commit

Permalink
feat: add tests for remote files and licenses
Browse files Browse the repository at this point in the history
Signed-off-by: Jeroen Branje <[email protected]>
  • Loading branch information
jeroenbranje committed Nov 27, 2024
1 parent 6c089ab commit efff671
Show file tree
Hide file tree
Showing 9 changed files with 1,267 additions and 643 deletions.
507 changes: 492 additions & 15 deletions apps/envited.ascs.digital/common/asset/createModifiedManifest.test.ts

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions apps/envited.ascs.digital/common/asset/createModifiedManifest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { equals, evolve, find, includes, map, pipe, prop, propEq, propOr, tail } from 'ramda'
import { equals, evolve, find, includes, map, pipe, propEq, propOr, tail } from 'ramda'

import { formatAssetUri, formatIpfsUri, formatMetadataUri } from './createTokenMetadata.utils'
import { AccessRole, ExtractedFileWithCID, ManifestLink } from './types'
import { formatManifestLinkPath } from './validateAndCreateMetadata.utils'
import { formatManifestLinkPath, isRemoteUrl } from './validateAndCreateMetadata.utils'

export const createModifiedManifest = ({
assetCID,
Expand All @@ -18,9 +18,9 @@ export const createModifiedManifest = ({
'manifest:assetData': map(modifyManifestLink(assetCID, domainMetadataCID, visualizationFiles)),
'manifest:contentData': map(modifyManifestLink(assetCID, domainMetadataCID, visualizationFiles)),
},
// 'manifest:license': {
// 'manifest:licenseData': modifyManifestLink(assetCID, domainMetadataCID),
// }
'manifest:license': {
'manifest:licenseData': modifyManifestLink(assetCID, domainMetadataCID, visualizationFiles),
},
})

export const modifyManifestLink =
Expand Down Expand Up @@ -54,16 +54,20 @@ export const formatManifestUri =
}

if (equals(accessRole)(AccessRole.owner)) {
return `${formatAssetUri(assetCID)}${tail(path)}`
return !isRemoteUrl(path) ? `${formatAssetUri(assetCID)}${tail(path)}` : path
}

if (
equals(accessRole)(AccessRole.registeredUser) ||
(equals(accessRole)(AccessRole.publicUser) && type === 'license')
(equals(accessRole)(AccessRole.registeredUser) && type === 'license')
) {
return `${formatMetadataUri(assetCID)}${tail(path)}`
}

if (equals(accessRole)(AccessRole.publicUser) && type === 'license') {
return path
}

if (equals(accessRole)(AccessRole.publicUser)) {
return `${formatIpfsUri(assetCID)}${tail(path)}`
}
Expand Down
Loading

0 comments on commit efff671

Please sign in to comment.