Skip to content

Commit 2d3a197

Browse files
authored
Merge branch 'alpha' into uint8array
2 parents 4d3d281 + 8692022 commit 2d3a197

File tree

6 files changed

+25
-61
lines changed

6 files changed

+25
-61
lines changed

changelogs/CHANGELOG_alpha.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [6.1.0-alpha.5](https://github.com/parse-community/Parse-SDK-JS/compare/6.1.0-alpha.4...6.1.0-alpha.5) (2025-04-02)
2+
3+
4+
### Bug Fixes
5+
6+
* Remove unused option `sessionToken` from `Parse.Query.aggregate` ([#2547](https://github.com/parse-community/Parse-SDK-JS/issues/2547)) ([c7015ba](https://github.com/parse-community/Parse-SDK-JS/commit/c7015ba42c13d7a4bbe5246b0944e64dcea1712f))
7+
18
# [6.1.0-alpha.4](https://github.com/parse-community/Parse-SDK-JS/compare/6.1.0-alpha.3...6.1.0-alpha.4) (2025-03-29)
29

310

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse",
3-
"version": "6.1.0-alpha.4",
3+
"version": "6.1.0-alpha.5",
44
"description": "Parse JavaScript SDK",
55
"homepage": "https://parseplatform.org",
66
"keywords": [

src/ParseQuery.ts

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -780,29 +780,17 @@ class ParseQuery<T extends ParseObject = ParseObject> {
780780
* Executes a distinct query and returns unique values
781781
*
782782
* @param {string} key A field to find distinct values
783-
* @param {object} options
784-
* @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
785783
* @returns {Promise} A promise that is resolved with the query completes.
786784
*/
787-
distinct<K extends keyof T['attributes'], V = T['attributes'][K]>(
788-
key: K,
789-
options?: { sessionToken?: string }
790-
): Promise<V[]> {
791-
options = options || {};
792-
const distinctOptions: { sessionToken?: string; useMasterKey: boolean } = {
793-
useMasterKey: true,
794-
};
795-
if (Object.hasOwn(options, 'sessionToken')) {
796-
distinctOptions.sessionToken = options.sessionToken;
797-
}
785+
distinct<K extends keyof T['attributes'], V = T['attributes'][K]>(key: K): Promise<V[]> {
786+
const distinctOptions = { useMasterKey: true };
798787
this._setRequestTask(distinctOptions);
799-
800-
const controller = CoreManager.getQueryController();
801788
const params = {
802789
distinct: key,
803790
where: this._where,
804791
hint: this._hint,
805792
};
793+
const controller = CoreManager.getQueryController();
806794
return controller.aggregate(this.className, params, distinctOptions).then(results => {
807795
return results.results!;
808796
});
@@ -812,39 +800,28 @@ class ParseQuery<T extends ParseObject = ParseObject> {
812800
* Executes an aggregate query and returns aggregate results
813801
*
814802
* @param {(Array|object)} pipeline Array or Object of stages to process query
815-
* @param {object} options
816-
* @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
817803
* @returns {Promise} A promise that is resolved with the query completes.
818804
*/
819-
aggregate(pipeline: any, options?: { sessionToken?: string }): Promise<any[]> {
820-
options = options || {};
821-
const aggregateOptions: { sessionToken?: string; useMasterKey: boolean } = {
822-
useMasterKey: true,
823-
};
824-
if (Object.hasOwn(options, 'sessionToken')) {
825-
aggregateOptions.sessionToken = options.sessionToken;
826-
}
827-
this._setRequestTask(aggregateOptions);
828-
829-
const controller = CoreManager.getQueryController();
830-
805+
aggregate(pipeline: any): Promise<any[]> {
831806
if (!Array.isArray(pipeline) && typeof pipeline !== 'object') {
832807
throw new Error('Invalid pipeline must be Array or Object');
833808
}
834-
835809
if (Object.keys(this._where || {}).length) {
836810
if (!Array.isArray(pipeline)) {
837811
pipeline = [pipeline];
838812
}
839813
pipeline.unshift({ $match: this._where });
840814
}
841-
842815
const params = {
843816
pipeline,
844817
hint: this._hint,
845818
explain: this._explain,
846819
readPreference: this._readPreference,
847820
};
821+
const aggregateOptions = { useMasterKey: true };
822+
this._setRequestTask(aggregateOptions);
823+
824+
const controller = CoreManager.getQueryController();
848825
return controller.aggregate(this.className, params, aggregateOptions).then(results => {
849826
return results.results!;
850827
});

src/__tests__/ParseQuery-test.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2619,7 +2619,6 @@ describe('ParseQuery', () => {
26192619
},
26202620
});
26212621
expect(options.useMasterKey).toEqual(true);
2622-
expect(options.sessionToken).toEqual('1234');
26232622
expect(options.requestTask).toBeDefined();
26242623
return Promise.resolve({
26252624
results: ['L'],
@@ -2629,9 +2628,7 @@ describe('ParseQuery', () => {
26292628

26302629
const q = new ParseQuery('Item');
26312630
q.equalTo('size', 'small')
2632-
.distinct('size', {
2633-
sessionToken: '1234',
2634-
})
2631+
.distinct('size')
26352632
.then(results => {
26362633
expect(results[0]).toBe('L');
26372634
done();
@@ -2651,7 +2648,6 @@ describe('ParseQuery', () => {
26512648
hint: '_id_',
26522649
});
26532650
expect(options.useMasterKey).toEqual(true);
2654-
expect(options.sessionToken).toEqual('1234');
26552651
expect(options.requestTask).toBeDefined();
26562652
return Promise.resolve({
26572653
results: ['L'],
@@ -2662,9 +2658,7 @@ describe('ParseQuery', () => {
26622658
const q = new ParseQuery('Item');
26632659
q.equalTo('size', 'small')
26642660
.hint('_id_')
2665-
.distinct('size', {
2666-
sessionToken: '1234',
2667-
})
2661+
.distinct('size')
26682662
.then(results => {
26692663
expect(results[0]).toBe('L');
26702664
done();
@@ -2799,17 +2793,14 @@ describe('ParseQuery', () => {
27992793
expect(className).toBe('Item');
28002794
expect(params.pipeline).toEqual([{ group: { objectId: '$name' } }]);
28012795
expect(options.useMasterKey).toEqual(true);
2802-
expect(options.sessionToken).toEqual('1234');
28032796
return Promise.resolve({
28042797
results: [],
28052798
});
28062799
},
28072800
});
28082801

28092802
const q = new ParseQuery('Item');
2810-
q.aggregate(pipeline, {
2811-
sessionToken: '1234',
2812-
}).then(results => {
2803+
q.aggregate(pipeline).then(results => {
28132804
expect(results).toEqual([]);
28142805
done();
28152806
});
@@ -2831,7 +2822,7 @@ describe('ParseQuery', () => {
28312822
// Query
28322823
const q = new ParseQuery('Item');
28332824
q.readPreference('SECONDARY');
2834-
const results = await q.aggregate([], { sessionToken: '1234' });
2825+
const results = await q.aggregate([]);
28352826
// Validate
28362827
expect(results).toEqual([]);
28372828
});
@@ -2845,7 +2836,6 @@ describe('ParseQuery', () => {
28452836
expect(params.pipeline).toEqual([{ group: { objectId: '$name' } }]);
28462837
expect(params.hint).toEqual('_id_');
28472838
expect(options.useMasterKey).toEqual(true);
2848-
expect(options.sessionToken).toEqual('1234');
28492839
return Promise.resolve({
28502840
results: [],
28512841
});
@@ -2854,9 +2844,7 @@ describe('ParseQuery', () => {
28542844

28552845
const q = new ParseQuery('Item');
28562846
q.hint('_id_')
2857-
.aggregate(pipeline, {
2858-
sessionToken: '1234',
2859-
})
2847+
.aggregate(pipeline)
28602848
.then(results => {
28612849
expect(results).toEqual([]);
28622850
done();

types/ParseQuery.d.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,24 +265,16 @@ declare class ParseQuery<T extends ParseObject = ParseObject> {
265265
* Executes a distinct query and returns unique values
266266
*
267267
* @param {string} key A field to find distinct values
268-
* @param {object} options
269-
* @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
270268
* @returns {Promise} A promise that is resolved with the query completes.
271269
*/
272-
distinct<K extends keyof T['attributes'], V = T['attributes'][K]>(key: K, options?: {
273-
sessionToken?: string;
274-
}): Promise<V[]>;
270+
distinct<K extends keyof T['attributes'], V = T['attributes'][K]>(key: K): Promise<V[]>;
275271
/**
276272
* Executes an aggregate query and returns aggregate results
277273
*
278274
* @param {(Array|object)} pipeline Array or Object of stages to process query
279-
* @param {object} options
280-
* @param {string} [options.sessionToken] A valid session token, used for making a request on behalf of a specific user.
281275
* @returns {Promise} A promise that is resolved with the query completes.
282276
*/
283-
aggregate(pipeline: any, options?: {
284-
sessionToken?: string;
285-
}): Promise<any[]>;
277+
aggregate(pipeline: any): Promise<any[]>;
286278
/**
287279
* Retrieves at most one Parse.Object that satisfies this query.
288280
*

0 commit comments

Comments
 (0)