diff --git a/package.json b/package.json index 3ec92351a..770f35222 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "2.0.0-rc18", + "version": "2.0.0-rc19", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts", diff --git a/src/nevermined/api/SearchApi.ts b/src/nevermined/api/SearchApi.ts index 80a7496ea..62075d7e2 100644 --- a/src/nevermined/api/SearchApi.ts +++ b/src/nevermined/api/SearchApi.ts @@ -263,7 +263,7 @@ export class SearchApi extends Instantiable { */ public async subscriptionsCreated( account: Account, - nftType?: string, + nftType?: NeverminedNFT721Type | NeverminedNFT1155Type, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -355,8 +355,8 @@ export class SearchApi extends Instantiable { */ public async subscriptionsPurchased( account: Account, - nftType: string, - ercType: 721 | 1155, + nftType?: NeverminedNFT721Type | NeverminedNFT1155Type, + ercType?: 721 | 1155, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -473,6 +473,8 @@ export class SearchApi extends Instantiable { */ public async servicesByNftContract( nftContractAddress: string, + nftType?: NeverminedNFT721Type | NeverminedNFT1155Type, + tokenId?: string, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -487,18 +489,30 @@ export class SearchApi extends Instantiable { bool: { filter: [ { match: { 'service.type': 'metadata' } }, - { - bool: { - should: [ - { match: { 'service.attributes.main.nftType': NeverminedNFT721Type.nft721 } }, - { - match: { - 'service.attributes.main.nftType': NeverminedNFT1155Type.nft1155Credit, - }, + nftType + ? { + match: { + 'service.attributes.main.nftType': nftType, }, - ], - }, - }, + } + : { + bool: { + should: [ + { + match: { + 'service.attributes.main.nftType': + NeverminedNFT721Type.nft721Subscription, + }, + }, + { + match: { + 'service.attributes.main.nftType': + NeverminedNFT1155Type.nft1155Credit, + }, + }, + ], + }, + }, { exists: { field: 'service.attributes.main.webService', @@ -522,6 +536,12 @@ export class SearchApi extends Instantiable { nftContractAddress, }, }, + tokenId && { + match: { + 'service.attributes.serviceAgreementTemplate.conditions.parameters.value': + tokenId, + }, + }, ], }, }, @@ -563,6 +583,7 @@ export class SearchApi extends Instantiable { */ public async servicesBySubscription( subscriptionDid: string, + nftType?: NeverminedNFT721Type | NeverminedNFT1155Type, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -588,6 +609,8 @@ export class SearchApi extends Instantiable { return this.servicesByNftContract( nftContractAddress, + nftType, + subscriptionDid, customNestedQueries, offset, page, @@ -610,6 +633,8 @@ export class SearchApi extends Instantiable { */ public async datasetsByNftContract( nftContractAddress: string, + nftType?: NeverminedNFT721Type | NeverminedNFT1155Type, + tokenId?: string, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -624,18 +649,30 @@ export class SearchApi extends Instantiable { bool: { filter: [ { match: { 'service.type': 'metadata' } }, - { - bool: { - should: [ - { match: { 'service.attributes.main.nftType': NeverminedNFT721Type.nft721 } }, - { - match: { - 'service.attributes.main.nftType': NeverminedNFT1155Type.nft1155Credit, - }, + nftType + ? { + match: { + 'service.attributes.main.nftType': nftType, }, - ], - }, - }, + } + : { + bool: { + should: [ + { + match: { + 'service.attributes.main.nftType': + NeverminedNFT721Type.nft721Subscription, + }, + }, + { + match: { + 'service.attributes.main.nftType': + NeverminedNFT1155Type.nft1155Credit, + }, + }, + ], + }, + }, { match: { 'service.attributes.main.type': 'dataset', @@ -659,6 +696,12 @@ export class SearchApi extends Instantiable { nftContractAddress, }, }, + tokenId && { + match: { + 'service.attributes.serviceAgreementTemplate.conditions.parameters.value': + tokenId, + }, + }, ], }, }, @@ -700,6 +743,7 @@ export class SearchApi extends Instantiable { */ public async datasetsBySubscription( subscriptionDid: string, + nftType?: NeverminedNFT721Type | NeverminedNFT1155Type, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -725,6 +769,8 @@ export class SearchApi extends Instantiable { return this.datasetsByNftContract( nftContractAddress, + nftType, + subscriptionDid, customNestedQueries, offset, page,