From 85d6d59d768be9f91c1084d502230f7056a5cfb0 Mon Sep 17 00:00:00 2001 From: enrique Date: Thu, 19 Oct 2023 11:28:16 +0200 Subject: [PATCH 1/4] fix: search by subscription needs to filter by tokenId --- src/nevermined/api/SearchApi.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/nevermined/api/SearchApi.ts b/src/nevermined/api/SearchApi.ts index 80a7496ea..8cb788929 100644 --- a/src/nevermined/api/SearchApi.ts +++ b/src/nevermined/api/SearchApi.ts @@ -473,6 +473,7 @@ export class SearchApi extends Instantiable { */ public async servicesByNftContract( nftContractAddress: string, + tokenId: string, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -522,6 +523,12 @@ export class SearchApi extends Instantiable { nftContractAddress, }, }, + { + match: { + 'service.attributes.serviceAgreementTemplate.conditions.parameters.value': + tokenId, + }, + }, ], }, }, @@ -588,6 +595,7 @@ export class SearchApi extends Instantiable { return this.servicesByNftContract( nftContractAddress, + subscriptionDid, customNestedQueries, offset, page, @@ -610,6 +618,7 @@ export class SearchApi extends Instantiable { */ public async datasetsByNftContract( nftContractAddress: string, + tokenId: string, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -659,6 +668,12 @@ export class SearchApi extends Instantiable { nftContractAddress, }, }, + { + match: { + 'service.attributes.serviceAgreementTemplate.conditions.parameters.value': + tokenId, + }, + }, ], }, }, @@ -725,6 +740,7 @@ export class SearchApi extends Instantiable { return this.datasetsByNftContract( nftContractAddress, + subscriptionDid, customNestedQueries, offset, page, From dc6e90675c88565fc4739ab9fdd63263f7f67f0b Mon Sep 17 00:00:00 2001 From: enrique Date: Thu, 19 Oct 2023 11:36:36 +0200 Subject: [PATCH 2/4] feat: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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", From 418877ed6097e73d0119e533c66e616ea729f012 Mon Sep 17 00:00:00 2001 From: enrique Date: Thu, 19 Oct 2023 11:50:59 +0200 Subject: [PATCH 3/4] fix: add filter by nft type --- src/nevermined/api/SearchApi.ts | 82 ++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/src/nevermined/api/SearchApi.ts b/src/nevermined/api/SearchApi.ts index 8cb788929..77f9a19c3 100644 --- a/src/nevermined/api/SearchApi.ts +++ b/src/nevermined/api/SearchApi.ts @@ -473,7 +473,8 @@ export class SearchApi extends Instantiable { */ public async servicesByNftContract( nftContractAddress: string, - tokenId: string, + nftType?: string, + tokenId?: string, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -488,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', @@ -523,7 +536,7 @@ export class SearchApi extends Instantiable { nftContractAddress, }, }, - { + tokenId && { match: { 'service.attributes.serviceAgreementTemplate.conditions.parameters.value': tokenId, @@ -570,6 +583,7 @@ export class SearchApi extends Instantiable { */ public async servicesBySubscription( subscriptionDid: string, + nftType?: string, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -595,6 +609,7 @@ export class SearchApi extends Instantiable { return this.servicesByNftContract( nftContractAddress, + nftType, subscriptionDid, customNestedQueries, offset, @@ -618,7 +633,8 @@ export class SearchApi extends Instantiable { */ public async datasetsByNftContract( nftContractAddress: string, - tokenId: string, + nftType?: string, + tokenId?: string, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -633,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', @@ -668,7 +696,7 @@ export class SearchApi extends Instantiable { nftContractAddress, }, }, - { + tokenId && { match: { 'service.attributes.serviceAgreementTemplate.conditions.parameters.value': tokenId, @@ -715,6 +743,7 @@ export class SearchApi extends Instantiable { */ public async datasetsBySubscription( subscriptionDid: string, + nftType?: string, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -740,6 +769,7 @@ export class SearchApi extends Instantiable { return this.datasetsByNftContract( nftContractAddress, + nftType, subscriptionDid, customNestedQueries, offset, From 538cb1421c053bae32548eb67ed564769c4d58d7 Mon Sep 17 00:00:00 2001 From: enrique Date: Thu, 19 Oct 2023 12:01:32 +0200 Subject: [PATCH 4/4] fix: add type2 --- src/nevermined/api/SearchApi.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/nevermined/api/SearchApi.ts b/src/nevermined/api/SearchApi.ts index 77f9a19c3..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,7 +473,7 @@ export class SearchApi extends Instantiable { */ public async servicesByNftContract( nftContractAddress: string, - nftType?: string, + nftType?: NeverminedNFT721Type | NeverminedNFT1155Type, tokenId?: string, customNestedQueries?: SearchQuery['query'][], offset = 100, @@ -583,7 +583,7 @@ export class SearchApi extends Instantiable { */ public async servicesBySubscription( subscriptionDid: string, - nftType?: string, + nftType?: NeverminedNFT721Type | NeverminedNFT1155Type, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1, @@ -633,7 +633,7 @@ export class SearchApi extends Instantiable { */ public async datasetsByNftContract( nftContractAddress: string, - nftType?: string, + nftType?: NeverminedNFT721Type | NeverminedNFT1155Type, tokenId?: string, customNestedQueries?: SearchQuery['query'][], offset = 100, @@ -743,7 +743,7 @@ export class SearchApi extends Instantiable { */ public async datasetsBySubscription( subscriptionDid: string, - nftType?: string, + nftType?: NeverminedNFT721Type | NeverminedNFT1155Type, customNestedQueries?: SearchQuery['query'][], offset = 100, page = 1,