Skip to content

feat: Deprecation DEPPS9: LiveQuery fields option is renamed to keys #8852

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

Merged
merged 6 commits into from
Feb 14, 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
2 changes: 1 addition & 1 deletion DEPRECATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following is a list of deprecations, according to the [Deprecation Policy](h
| DEPPS6 | Auth providers disabled by default | [#7953](https://github.com/parse-community/parse-server/pull/7953) | 5.3.0 (2022) | 7.0.0 (2024) | deprecated | - |
| DEPPS7 | Remove file trigger syntax `Parse.Cloud.beforeSaveFile((request) => {})` | [#7966](https://github.com/parse-community/parse-server/pull/7966) | 5.3.0 (2022) | 7.0.0 (2024) | removed | - |
| DEPPS8 | Login with expired 3rd party authentication token defaults to `false` | [#7079](https://github.com/parse-community/parse-server/pull/7079) | 5.3.0 (2022) | 7.0.0 (2024) | deprecated | - |
| DEPPS9 | Rename LiveQuery `fields` option to `keys` | [#8389](https://github.com/parse-community/parse-server/issues/8389) | 6.0.0 (2023) | 7.0.0 (2024) | deprecated | - |
| DEPPS9 | Rename LiveQuery `fields` option to `keys` | [#8389](https://github.com/parse-community/parse-server/issues/8389) | 6.0.0 (2023) | 7.0.0 (2024) | removed | - |
| DEPPS10 | Config option `encodeParseObjectInCloudFunction` defaults to `true` | [#8634](https://github.com/parse-community/parse-server/issues/8634) | 6.2.0 (2023) | 8.0.0 (2025) | deprecated | - |

[i_deprecation]: ## "The version and date of the deprecation."
Expand Down
61 changes: 3 additions & 58 deletions spec/ParseLiveQueryServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ describe('ParseLiveQueryServer', function () {
// Make sure we add subscriptionInfo to the client
const args = client.addSubscriptionInfo.calls.first().args;
expect(args[0]).toBe(requestId);
expect(args[1].fields).toBe(query.fields);
expect(args[1].keys).toBe(query.keys);
expect(args[1].sessionToken).toBe(request.sessionToken);
// Make sure we send subscribe response to the client
expect(client.pushSubscribe).toHaveBeenCalledWith(requestId);
Expand Down Expand Up @@ -417,7 +417,7 @@ describe('ParseLiveQueryServer', function () {
// Make sure we add subscriptionInfo to the client 2
args = clientAgain.addSubscriptionInfo.calls.mostRecent().args;
expect(args[0]).toBe(requestIdAgain);
expect(args[1].fields).toBe(queryAgain.fields);
expect(args[1].keys).toBe(queryAgain.keys);
});

it('can handle unsubscribe command without clientId', function () {
Expand Down Expand Up @@ -1081,7 +1081,7 @@ describe('ParseLiveQueryServer', function () {
done();
});

it('can handle create command with fields', async done => {
it('can handle create command with keys', async done => {
jasmine.restoreLibrary('../lib/LiveQuery/Client', 'Client');
const Client = require('../lib/LiveQuery/Client').Client;
const parseLiveQueryServer = new ParseLiveQueryServer({});
Expand Down Expand Up @@ -1131,61 +1131,6 @@ describe('ParseLiveQueryServer', function () {
done();
});

it('can deprecate fields', async () => {
const Deprecator = require('../lib/Deprecator/Deprecator');
const spy = spyOn(Deprecator, 'logRuntimeDeprecation').and.callFake(() => {});
jasmine.restoreLibrary('../lib/LiveQuery/Client', 'Client');
const Client = require('../lib/LiveQuery/Client').Client;
const parseLiveQueryServer = new ParseLiveQueryServer({});
// Make mock request message
const message = generateMockMessage();

const clientId = 1;
const parseWebSocket = {
clientId,
send: jasmine.createSpy('send'),
};
const client = new Client(clientId, parseWebSocket);
spyOn(client, 'pushCreate').and.callThrough();
parseLiveQueryServer.clients.set(clientId, client);

// Add mock subscription
const requestId = 2;
const query = {
className: testClassName,
where: {
key: 'value',
},
fields: ['test'],
};
await addMockSubscription(parseLiveQueryServer, clientId, requestId, parseWebSocket, query);
// Mock _matchesSubscription to return matching
parseLiveQueryServer._matchesSubscription = function (parseObject) {
if (!parseObject) {
return false;
}
return true;
};
parseLiveQueryServer._matchesACL = function () {
return Promise.resolve(true);
};

parseLiveQueryServer._onAfterSave(message);

// Make sure we send create command to client
await timeout();

expect(client.pushCreate).toHaveBeenCalled();
const args = parseWebSocket.send.calls.mostRecent().args;
const toSend = JSON.parse(args[0]);
expect(toSend.object).toBeDefined();
expect(toSend.original).toBeUndefined();
expect(spy).toHaveBeenCalledWith({
usage: 'Subscribing using fields parameter',
solution: `Subscribe using "keys" instead.`,
});
});

it('can handle create command with watch', async () => {
jasmine.restoreLibrary('../lib/LiveQuery/Client', 'Client');
const Client = require('../lib/LiveQuery/Client').Client;
Expand Down
8 changes: 0 additions & 8 deletions src/LiveQuery/ParseLiveQueryServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { LRUCache as LRU } from 'lru-cache';
import UserRouter from '../Routers/UsersRouter';
import DatabaseController from '../Controllers/DatabaseController';
import { isDeepStrictEqual } from 'util';
import Deprecator from '../Deprecator/Deprecator';
import deepcopy from 'deepcopy';

class ParseLiveQueryServer {
Expand Down Expand Up @@ -920,13 +919,6 @@ class ParseLiveQueryServer {
? request.query.keys
: request.query.keys.split(',');
}
if (request.query.fields) {
subscriptionInfo.keys = request.query.fields;
Deprecator.logRuntimeDeprecation({
usage: `Subscribing using fields parameter`,
solution: `Subscribe using "keys" instead.`,
});
}
if (request.query.watch) {
subscriptionInfo.watch = request.query.watch;
}
Expand Down
16 changes: 0 additions & 16 deletions src/LiveQuery/RequestSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ const subscribe = {
where: {
type: 'object',
},
fields: {
type: 'array',
items: {
type: 'string',
},
minItems: 1,
uniqueItems: true,
},
keys: {
type: 'array',
items: {
Expand Down Expand Up @@ -116,14 +108,6 @@ const update = {
where: {
type: 'object',
},
fields: {
type: 'array',
items: {
type: 'string',
},
minItems: 1,
uniqueItems: true,
},
keys: {
type: 'array',
items: {
Expand Down