Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow filtering by personalization #313

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/runtime/src/useCases/common/Schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22258,6 +22258,19 @@ export const GetRelationshipTemplatesRequest: any = {
}
}
]
},
"forIdentity": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -22829,6 +22842,19 @@ export const GetTokensRequest: any = {
}
}
]
},
"forIdentity": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
},
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface GetRelationshipTemplatesQuery {
createdBy?: string | string[];
createdByDevice?: string | string[];
maxNumberOfAllocations?: string | string[];
forIdentity?: string | string[];
}

export interface GetRelationshipTemplatesRequest {
Expand All @@ -35,7 +36,8 @@ export class GetRelationshipTemplatesUseCase extends UseCase<GetRelationshipTemp
[nameof<RelationshipTemplateDTO>((r) => r.expiresAt)]: true,
[nameof<RelationshipTemplateDTO>((r) => r.createdBy)]: true,
[nameof<RelationshipTemplateDTO>((r) => r.createdByDevice)]: true,
[nameof<RelationshipTemplateDTO>((r) => r.maxNumberOfAllocations)]: true
[nameof<RelationshipTemplateDTO>((r) => r.maxNumberOfAllocations)]: true,
[nameof<RelationshipTemplateDTO>((r) => r.forIdentity)]: true
},
alias: {
[nameof<RelationshipTemplateDTO>((r) => r.isOwn)]: nameof<RelationshipTemplate>((r) => r.isOwn),
Expand All @@ -47,7 +49,8 @@ export class GetRelationshipTemplatesUseCase extends UseCase<GetRelationshipTemp
)}`,
[nameof<RelationshipTemplateDTO>((r) => r.maxNumberOfAllocations)]: `${nameof<RelationshipTemplate>((r) => r.cache)}.${nameof<CachedRelationshipTemplate>(
(t) => t.maxNumberOfAllocations
)}`
)}`,
[nameof<RelationshipTemplateDTO>((r) => r.forIdentity)]: `${nameof<RelationshipTemplate>((r) => r.cache)}.${nameof<CachedRelationshipTemplate>((t) => t.forIdentity)}`
}
});

Expand Down
7 changes: 5 additions & 2 deletions packages/runtime/src/useCases/transport/tokens/GetTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface GetTokensQuery {
createdBy?: string | string[];
createdByDevice?: string | string[];
expiresAt?: string | string[];
forIdentity?: string | string[];
}

export interface GetTokensRequest {
Expand All @@ -31,13 +32,15 @@ export class GetTokensUseCase extends UseCase<GetTokensRequest, TokenDTO[]> {
[nameof<TokenDTO>((t) => t.createdAt)]: true,
[nameof<TokenDTO>((t) => t.createdBy)]: true,
[nameof<TokenDTO>((t) => t.createdByDevice)]: true,
[nameof<TokenDTO>((t) => t.expiresAt)]: true
[nameof<TokenDTO>((t) => t.expiresAt)]: true,
[nameof<TokenDTO>((t) => t.forIdentity)]: true
},
alias: {
[nameof<TokenDTO>((t) => t.createdAt)]: `${nameof<Token>((t) => t.cache)}.${[nameof<CachedToken>((t) => t.createdAt)]}`,
[nameof<TokenDTO>((t) => t.createdBy)]: `${nameof<Token>((t) => t.cache)}.${[nameof<CachedToken>((t) => t.createdBy)]}`,
[nameof<TokenDTO>((t) => t.createdByDevice)]: `${nameof<Token>((t) => t.cache)}.${[nameof<CachedToken>((t) => t.createdByDevice)]}`,
[nameof<TokenDTO>((t) => t.expiresAt)]: `${nameof<Token>((t) => t.cache)}.${[nameof<CachedToken>((t) => t.expiresAt)]}`
[nameof<TokenDTO>((t) => t.expiresAt)]: `${nameof<Token>((t) => t.cache)}.${[nameof<CachedToken>((t) => t.expiresAt)]}`,
[nameof<TokenDTO>((t) => t.forIdentity)]: `${nameof<Token>((t) => t.cache)}.${[nameof<CachedToken>((t) => t.forIdentity)]}`
}
});

Expand Down
6 changes: 4 additions & 2 deletions packages/runtime/test/transport/relationshipTemplates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ describe("RelationshipTemplates query", () => {
await runtimeServices1.transport.relationshipTemplates.createOwnRelationshipTemplate({
maxNumberOfAllocations: 1,
expiresAt: DateTime.utc().plus({ minutes: 10 }).toString(),
content: emptyRelationshipTemplateContent
content: emptyRelationshipTemplateContent,
forIdentity: runtimeServices1.address
})
).value;
const conditions = new QueryParamConditions<GetRelationshipTemplatesQuery>(template, runtimeServices1.transport)
Expand All @@ -285,7 +286,8 @@ describe("RelationshipTemplates query", () => {
.addDateSet("expiresAt")
.addStringSet("createdBy")
.addStringSet("createdByDevice")
.addNumberSet("maxNumberOfAllocations");
.addNumberSet("maxNumberOfAllocations")
.addStringSet("forIdentity");

await conditions.executeTests((c, q) => c.relationshipTemplates.getRelationshipTemplates({ query: q }));
});
Expand Down
5 changes: 3 additions & 2 deletions packages/runtime/test/transport/tokens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ describe("Tokens errors", () => {

describe("Tokens query", () => {
test("query own tokens", async () => {
const token = await uploadOwnToken(runtimeServices1.transport);
const token = await uploadOwnToken(runtimeServices1.transport, runtimeServices1.address);
const conditions = new QueryParamConditions<GetTokensQuery>(token, runtimeServices1.transport)
.addDateSet("expiresAt")
.addDateSet("createdAt")
.addStringSet("createdByDevice");
.addStringSet("createdByDevice")
.addStringSet("forIdentity");
await conditions.executeTests((c, q) => c.tokens.getTokens({ query: q, ownerRestriction: OwnerRestriction.Own }));
});

Expand Down