@yeying-community/yeying-client-ts
    Preparing search index...

    Class AssetProvider

    提供对资产的管理,包括查询、版本获取、详情查看、删除等操作

    Index

    Constructors

    Methods

    • 删除资产,根据命名空间 ID 和哈希值删除资产

      Parameters

      • namespaceId: string

        命名空间 ID

      • hash: string

        资产的哈希值

      Returns Promise<void>

      无返回

      NoPermission 没有权限

      ServiceUnavailable 服务不可用

      assetProvider.delete('example-namespace', 'example-hash')
      .then(() => console.log('Asset deleted'))
      .catch(err => console.error(err))
    • 查询资产详情,根据命名空间 ID 和哈希值获取资产元数据

      Parameters

      • namespaceId: string

        命名空间 ID

      • hash: string

        资产的哈希值

      Returns Promise<AssetMetadataJson>

      返回资产元数据

      NotFound

      ServiceUnavailable 服务不可用

      assetProvider.detail('example-namespace', 'example-hash')
      .then(asset => console.log(asset))
      .catch(err => console.error(err))
    • 搜索资产,根据条件和分页参数查询资产列表

      Parameters

      • page: number

        当前页码

      • pageSize: number

        每页显示的条目数

      • Optionalcondition: SearchAssetConditionJson

        搜索条件(部分 SearchAssetCondition 对象)

      Returns Promise<AssetMetadataJson[]>

      返回搜索到的资产元数据列表

      NoPermission 没有权限

      const condition = { namespaceId: 'example-namespace', format: 'example-format' }
      assetProvider.search(1, 10, condition as SearchAssetConditionJson)
      .then(assets => console.log(assets))
      .catch(err => console.error(err))
    • 签名资产元数据,对资产元数据进行签名,并发送签名请求到后端服务。

      Parameters

      Returns Promise<AssetMetadataJson>

      返回签名后的资产元数据

      NoPermission 没有权限

      NotFound 资产不存在

      ServiceUnavailable 服务不可用

      const assetMetadata = { namespaceId: 'example-namespace', hash: 'example-hash', owner: 'example-did' }
      assetProvider.sign(assetMetadata)
      .then(signedAsset => console.log(signedAsset))
      .catch(err => console.error(err))