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

Fix sort options serialization #379

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
36 changes: 30 additions & 6 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -9781,7 +9781,11 @@
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ include: ['status', 'type', ...(include.customFields ? ['custom'] : [])].join(','), count: `${include.totalCount}` }, (filter ? { filter } : {})), ((page === null || page === void 0 ? void 0 : page.next) ? { start: page.next } : {})), ((page === null || page === void 0 ? void 0 : page.prev) ? { end: page.prev } : {})), (limit ? { limit } : {})), (sorting.length ? { sort: sorting } : {}));
}
}
Expand Down Expand Up @@ -9913,7 +9917,11 @@
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags = [];
if (include.statusField)
includeFlags.push('status');
Expand Down Expand Up @@ -10008,7 +10016,11 @@
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags = ['channel.status', 'channel.type', 'status'];
if (include.customFields)
includeFlags.push('custom');
Expand Down Expand Up @@ -10084,7 +10096,11 @@
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ include: ['status', 'type', ...(include.customFields ? ['custom'] : [])].join(',') }, (include.totalCount !== undefined ? { count: `${include.totalCount}` } : {})), (filter ? { filter } : {})), ((page === null || page === void 0 ? void 0 : page.next) ? { start: page.next } : {})), ((page === null || page === void 0 ? void 0 : page.prev) ? { end: page.prev } : {})), (limit ? { limit } : {})), (sorting.length ? { sort: sorting } : {}));
}
}
Expand Down Expand Up @@ -10333,7 +10349,11 @@
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags = [];
if (include.statusField)
includeFlags.push('status');
Expand Down Expand Up @@ -10425,7 +10445,11 @@
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags = ['uuid.status', 'uuid.type', 'type'];
if (include.customFields)
includeFlags.push('custom');
Expand Down
2 changes: 1 addition & 1 deletion dist/web/pubnub.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion lib/core/endpoints/objects/channel/get_all.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ class GetAllChannelsMetadataRequest extends request_1.AbstractRequest {
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ include: ['status', 'type', ...(include.customFields ? ['custom'] : [])].join(','), count: `${include.totalCount}` }, (filter ? { filter } : {})), ((page === null || page === void 0 ? void 0 : page.next) ? { start: page.next } : {})), ((page === null || page === void 0 ? void 0 : page.prev) ? { end: page.prev } : {})), (limit ? { limit } : {})), (sorting.length ? { sort: sorting } : {}));
}
}
Expand Down
6 changes: 5 additions & 1 deletion lib/core/endpoints/objects/member/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ class GetChannelMembersRequest extends request_1.AbstractRequest {
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags = [];
if (include.statusField)
includeFlags.push('status');
Expand Down
6 changes: 5 additions & 1 deletion lib/core/endpoints/objects/member/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ class SetChannelMembersRequest extends request_1.AbstractRequest {
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags = ['uuid.status', 'uuid.type', 'type'];
if (include.customFields)
includeFlags.push('custom');
Expand Down
6 changes: 5 additions & 1 deletion lib/core/endpoints/objects/membership/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ class GetUUIDMembershipsRequest extends request_1.AbstractRequest {
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags = [];
if (include.statusField)
includeFlags.push('status');
Expand Down
6 changes: 5 additions & 1 deletion lib/core/endpoints/objects/membership/set.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ class SetUUIDMembershipsRequest extends request_1.AbstractRequest {
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags = ['channel.status', 'channel.type', 'status'];
if (include.customFields)
includeFlags.push('custom');
Expand Down
6 changes: 5 additions & 1 deletion lib/core/endpoints/objects/uuid/get_all.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ class GetAllUUIDMetadataRequest extends request_1.AbstractRequest {
}
get queryParameters() {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => order !== null ? `${option}:${order}` : option);
let sorting = '';
if (typeof sort === 'string')
sorting = sort;
else
sorting = Object.entries(sort !== null && sort !== void 0 ? sort : {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ include: ['status', 'type', ...(include.customFields ? ['custom'] : [])].join(',') }, (include.totalCount !== undefined ? { count: `${include.totalCount}` } : {})), (filter ? { filter } : {})), ((page === null || page === void 0 ? void 0 : page.next) ? { start: page.next } : {})), ((page === null || page === void 0 ? void 0 : page.prev) ? { end: page.prev } : {})), (limit ? { limit } : {})), (sorting.length ? { sort: sorting } : {}));
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/core/endpoints/objects/channel/get_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ export class GetAllChannelsMetadataRequest<

protected get queryParameters(): Query {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort ?? {}).map(([option, order]) =>
order !== null ? `${option}:${order}` : option,
);
let sorting: string | string[] = '';
if (typeof sort === 'string') sorting = sort;
else
sorting = Object.entries(sort ?? {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));

return {
include: ['status', 'type', ...(include!.customFields ? ['custom'] : [])].join(','),
Expand Down
7 changes: 4 additions & 3 deletions src/core/endpoints/objects/member/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ export class GetChannelMembersRequest<

protected get queryParameters(): Query {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort ?? {}).map(([option, order]) =>
order !== null ? `${option}:${order}` : option,
);
let sorting: string | string[] = '';
if (typeof sort === 'string') sorting = sort;
else
sorting = Object.entries(sort ?? {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags: string[] = [];

if (include!.statusField) includeFlags.push('status');
Expand Down
7 changes: 4 additions & 3 deletions src/core/endpoints/objects/member/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ export class SetChannelMembersRequest<

protected get queryParameters(): Query {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort ?? {}).map(([option, order]) =>
order !== null ? `${option}:${order}` : option,
);
let sorting: string | string[] = '';
if (typeof sort === 'string') sorting = sort;
else
sorting = Object.entries(sort ?? {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags: string[] = ['uuid.status', 'uuid.type', 'type'];

if (include!.customFields) includeFlags.push('custom');
Expand Down
7 changes: 4 additions & 3 deletions src/core/endpoints/objects/membership/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ export class GetUUIDMembershipsRequest<

protected get queryParameters(): Query {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort ?? {}).map(([option, order]) =>
order !== null ? `${option}:${order}` : option,
);
let sorting: string | string[] = '';
if (typeof sort === 'string') sorting = sort;
else
sorting = Object.entries(sort ?? {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags: string[] = [];

if (include!.statusField) includeFlags.push('status');
Expand Down
7 changes: 4 additions & 3 deletions src/core/endpoints/objects/membership/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,10 @@ export class SetUUIDMembershipsRequest<

protected get queryParameters(): Query {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort ?? {}).map(([option, order]) =>
order !== null ? `${option}:${order}` : option,
);
let sorting: string | string[] = '';
if (typeof sort === 'string') sorting = sort;
else
sorting = Object.entries(sort ?? {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));
const includeFlags: string[] = ['channel.status', 'channel.type', 'status'];

if (include!.customFields) includeFlags.push('custom');
Expand Down
7 changes: 4 additions & 3 deletions src/core/endpoints/objects/uuid/get_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ export class GetAllUUIDMetadataRequest<

protected get queryParameters(): Query {
const { include, page, filter, sort, limit } = this.parameters;
const sorting = Object.entries(sort ?? {}).map(([option, order]) =>
order !== null ? `${option}:${order}` : option,
);
let sorting: string | string[] = '';
if (typeof sort === 'string') sorting = sort;
else
sorting = Object.entries(sort ?? {}).map(([option, order]) => (order !== null ? `${option}:${order}` : option));

return {
include: ['status', 'type', ...(include!.customFields ? ['custom'] : [])].join(','),
Expand Down
Loading