Skip to content

Commit

Permalink
fix: pagination field not pageSize
Browse files Browse the repository at this point in the history
  • Loading branch information
gmolki committed Nov 15, 2024
1 parent 2bf19cd commit fdefb3f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class AlephHttpClient {
* Watches for new messages on the Aleph network. This method returns a socket that can be used to listen for new messages.
* @param config The filters used to watch for new messages, similar to getMessages.
*/
async watchMessages(config: Omit<GetMessagesConfiguration, 'page' | 'pageSize'>): Promise<AlephSocket> {
async watchMessages(config: Omit<GetMessagesConfiguration, 'page' | 'pagination'>): Promise<AlephSocket> {
return this.messageClient.getMessagesSocket(config)
}
}
Expand Down
14 changes: 7 additions & 7 deletions packages/message/__tests__/base/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ describe('Test features from GetMessage', () => {
describe('Test features from GetMessage', () => {
const client = new BaseMessageClient()
it('Try by pageSize and page', async () => {
it('Try by pagination and page', async () => {
const res = await client.getAll({
pageSize: 5,
pagination: 5,
page: 2,
})
expect(res.messages.length).toStrictEqual(5)
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('Test features from GetMessage', () => {
const aimedType = 'testing_oversize'
const res = await client.getAll({
contentTypes: [aimedType],
pageSize: 10,
pagination: 10,
})
expect(res.messages.length).toBeGreaterThan(0)
Expand All @@ -126,7 +126,7 @@ describe('Test features from GetMessage', () => {
const aimedTag = ['Test']
const res = await client.getAll({
tags: aimedTag,
pageSize: 10,
pagination: 10,
})
expect(res.messages.length).toBeGreaterThan(0)
Expand All @@ -141,7 +141,7 @@ describe('Test features from GetMessage', () => {
const aimedKey = 'InterPlanetaryCloud'
const res = await client.getAll({
contentKeys: [aimedKey],
pageSize: 10,
pagination: 10,
})
expect(res.messages.length).toBeGreaterThan(0)
Expand All @@ -157,7 +157,7 @@ describe('Test features from GetMessage', () => {
const res = await client.getAll({
startDate: aimedStartTime,
endDate: aimedEndTime,
pageSize: 5,
pagination: 5,
})
res.messages.map((item) => {
Expand Down Expand Up @@ -191,7 +191,7 @@ describe('Test features from GetMessage', () => {
typeArray.map(async (type) => {
const res = await client.getAll({
messageTypes: [type],
pageSize: 3,
pagination: 3,
})
expect(checkTypeList(res.messages, type)).toStrictEqual(true)
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/message/__tests__/post/get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Post get tests', () => {

const amends = await post.getAll({
types: [],
pageSize: 5,
pagination: 5,
channels: [channel],
})

Expand Down
4 changes: 2 additions & 2 deletions packages/message/src/base/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class BaseMessageClient {
* @param configuration The message params to make the query.
*/
async getAll({
pageSize = 20,
pagination = 20,
page = 1,
addresses = [],
channels = [],
Expand All @@ -115,7 +115,7 @@ export class BaseMessageClient {
}: GetMessagesConfiguration): Promise<MessagesQueryResponse> {
const any = (value: any) => value && value.length > 0
const params: GetMessagesParams = {
pageSize,
pagination,
page,
addresses: any(addresses) ? addresses.join(',') : undefined,
channels: any(channels) ? channels.join(',') : undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/message/src/base/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type MessagesQueryResponse = {
}

export type GetMessagesConfiguration = {
pageSize?: number
pagination?: number
page?: number
addresses?: string[]
channels?: string[]
Expand All @@ -47,7 +47,7 @@ export type GetMessagesConfiguration = {
}

export type GetMessagesParams = {
pageSize?: number
pagination?: number
page?: number
addresses?: string
channels?: string
Expand Down
6 changes: 3 additions & 3 deletions packages/message/src/post/impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class PostMessageClient {
/**
* Queries the Aleph network for post messages.
* @param types The types of messages to retrieve.
* @param pageSize The number of messages to retrieve.
* @param pagination The number of messages to retrieve.
* @param page The page number to retrieve.
* @param channels The channels to retrieve the messages from.
* @param refs The references to retrieve the messages from.
Expand All @@ -47,7 +47,7 @@ export class PostMessageClient {
*/
async getAll<T = any>({
types = [],
pageSize = 50,
pagination = 50,
page = 1,
channels = [],
refs = [],
Expand All @@ -58,7 +58,7 @@ export class PostMessageClient {
const any = (value: any) => value && value.length > 0
const params: PostQueryParams = {
types,
pageSize,
pagination,
page,
refs: any(refs) ? refs?.join(',') : undefined,
addresses: any(addresses) ? addresses?.join(',') : undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/message/src/post/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type PostContent<T> = BaseContent & {

export type PostGetConfiguration = {
types?: string | string[]
pageSize?: number
pagination?: number
page?: number
refs?: string[]
addresses?: string[]
Expand All @@ -23,7 +23,7 @@ export type PostGetConfiguration = {

export type PostQueryParams = {
types?: string | string[]
pageSize: number
pagination: number
page: number
refs?: string | undefined
addresses?: string | undefined
Expand Down

0 comments on commit fdefb3f

Please sign in to comment.