Skip to content

Commit

Permalink
fix(app-context): fix sort options serialization
Browse files Browse the repository at this point in the history
Fix issue because of which single string sort option wasn't serialized properly.
  • Loading branch information
parfeon committed Jun 6, 2024
1 parent 78744e1 commit 5d55461
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 31 deletions.
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

0 comments on commit 5d55461

Please sign in to comment.