Skip to content

Commit

Permalink
Merge pull request #598 from nevermined-io/fix/queries-by-subscription
Browse files Browse the repository at this point in the history
fix: search by subscription needs to filter by tokenId
  • Loading branch information
eruizgar91 authored Oct 19, 2023
2 parents 8b61061 + 538cb14 commit 93adf6e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
96 changes: 71 additions & 25 deletions src/nevermined/api/SearchApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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',
Expand All @@ -522,6 +536,12 @@ export class SearchApi extends Instantiable {
nftContractAddress,
},
},
tokenId && {
match: {
'service.attributes.serviceAgreementTemplate.conditions.parameters.value':
tokenId,
},
},
],
},
},
Expand Down Expand Up @@ -563,6 +583,7 @@ export class SearchApi extends Instantiable {
*/
public async servicesBySubscription(
subscriptionDid: string,
nftType?: NeverminedNFT721Type | NeverminedNFT1155Type,
customNestedQueries?: SearchQuery['query'][],
offset = 100,
page = 1,
Expand All @@ -588,6 +609,8 @@ export class SearchApi extends Instantiable {

return this.servicesByNftContract(
nftContractAddress,
nftType,
subscriptionDid,
customNestedQueries,
offset,
page,
Expand All @@ -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,
Expand All @@ -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',
Expand All @@ -659,6 +696,12 @@ export class SearchApi extends Instantiable {
nftContractAddress,
},
},
tokenId && {
match: {
'service.attributes.serviceAgreementTemplate.conditions.parameters.value':
tokenId,
},
},
],
},
},
Expand Down Expand Up @@ -700,6 +743,7 @@ export class SearchApi extends Instantiable {
*/
public async datasetsBySubscription(
subscriptionDid: string,
nftType?: NeverminedNFT721Type | NeverminedNFT1155Type,
customNestedQueries?: SearchQuery['query'][],
offset = 100,
page = 1,
Expand All @@ -725,6 +769,8 @@ export class SearchApi extends Instantiable {

return this.datasetsByNftContract(
nftContractAddress,
nftType,
subscriptionDid,
customNestedQueries,
offset,
page,
Expand Down

0 comments on commit 93adf6e

Please sign in to comment.