Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 0 additions & 1 deletion .husky/pre-commit

This file was deleted.

6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = tseslint.config({
jsdoc,
},
"rules": {
"indent": ["error", 2],
"indent": ["error", 2, { "SwitchCase": 1 }],
"linebreak-style": ["error", "unix"],
"no-trailing-spaces": 2,
"eol-last": 2,
Expand Down
45 changes: 0 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"gulp-rename": "2.0.0",
"gulp-uglify": "3.0.2",
"gulp-watch": "5.0.1",
"husky": "9.1.7",
"jasmine": "5.6.0",
"jasmine-reporters": "2.5.2",
"jasmine-spec-reporter": "7.0.0",
Expand All @@ -87,7 +86,6 @@
"metro-react-native-babel-preset": "0.77.0",
"mongodb-runner": "5.8.0",
"parse-server": "7.3.0",
"prettier": "3.5.2",
"puppeteer": "24.4.0",
"regenerator-runtime": "0.14.1",
"semantic-release": "24.2.3",
Expand Down Expand Up @@ -117,20 +115,11 @@
"integration": "cross-env TESTING=1 jasmine --config=jasmine.json",
"docs": "jsdoc -c ./jsdoc-conf.json ./src",
"madge:circular": "madge ./src --extensions js,ts --circular",
"prepare": "husky && npm run build",
"pre-commit": "lint-staged",
"prepare": "npm run build",
"release_docs": "./release_docs.sh",
"gulp": "gulp",
"prettier": "prettier --write '{src,integration,types}/{**/*,*}.{js,ts}' && npm run lint:fix",
"cross-env": "cross-env"
},
"lint-staged": {
"{src,integration}/{**/*,*}.{js,ts}": [
"prettier --write",
"eslint --fix --cache",
"git add"
]
},
"engines": {
"node": "18 || 19 || 20 || 22"
},
Expand Down
44 changes: 22 additions & 22 deletions src/EventuallyQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,33 +246,33 @@ const EventuallyQueue = {
return this.remove(queueObject.queueId);
}
switch (queueObject.action) {
case 'save':
// Queued update was overwritten by other request. Do not save
if (
typeof object.updatedAt !== 'undefined' &&
case 'save':
// Queued update was overwritten by other request. Do not save
if (
typeof object.updatedAt !== 'undefined' &&
object.updatedAt > new Date(queueObject.object.createdAt as Date)
) {
return this.remove(queueObject.queueId);
}
try {
await object.save(queueObject.object, queueObject.serverOptions);
await this.remove(queueObject.queueId);
} catch (e) {
if (e.code !== ParseError.CONNECTION_FAILED) {
) {
return this.remove(queueObject.queueId);
}
try {
await object.save(queueObject.object, queueObject.serverOptions);
await this.remove(queueObject.queueId);
} catch (e) {
if (e.code !== ParseError.CONNECTION_FAILED) {
await this.remove(queueObject.queueId);
}
}
}
break;
case 'destroy':
try {
await object.destroy(queueObject.serverOptions);
await this.remove(queueObject.queueId);
} catch (e) {
if (e.code !== ParseError.CONNECTION_FAILED) {
break;
case 'destroy':
try {
await object.destroy(queueObject.serverOptions);
await this.remove(queueObject.queueId);
} catch (e) {
if (e.code !== ParseError.CONNECTION_FAILED) {
await this.remove(queueObject.queueId);
}
}
}
break;
break;
}
},

Expand Down
144 changes: 72 additions & 72 deletions src/LiveQueryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,88 +378,88 @@ class LiveQueryClient {
installationId: data.installationId,
};
switch (data.op) {
case OP_EVENTS.CONNECTED:
if (this.state === CLIENT_STATE.RECONNECTING) {
this.resubscribe();
}
this.emit(CLIENT_EMMITER_TYPES.OPEN);
this.id = data.clientId;
this.connectPromise.resolve();
this.state = CLIENT_STATE.CONNECTED;
break;
case OP_EVENTS.SUBSCRIBED:
if (subscription) {
this.attempts = 1;
subscription.subscribed = true;
subscription.subscribePromise.resolve();
setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response), 200);
}
break;
case OP_EVENTS.ERROR: {
const parseError = new ParseError(data.code, data.error);
if (!this.id) {
this.connectPromise.reject(parseError);
this.state = CLIENT_STATE.DISCONNECTED;
}
if (data.requestId) {
case OP_EVENTS.CONNECTED:
if (this.state === CLIENT_STATE.RECONNECTING) {
this.resubscribe();
}
this.emit(CLIENT_EMMITER_TYPES.OPEN);
this.id = data.clientId;
this.connectPromise.resolve();
this.state = CLIENT_STATE.CONNECTED;
break;
case OP_EVENTS.SUBSCRIBED:
if (subscription) {
subscription.subscribePromise.reject(parseError);
setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error), 200);
this.attempts = 1;
subscription.subscribed = true;
subscription.subscribePromise.resolve();
setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response), 200);
}
} else {
this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
}
if (data.error === 'Additional properties not allowed') {
this.additionalProperties = false;
}
if (data.reconnect) {
this._handleReconnect();
}
break;
}
case OP_EVENTS.UNSUBSCRIBED: {
if (subscription) {
this.subscriptions.delete(data.requestId);
subscription.subscribed = false;
subscription.unsubscribePromise.resolve();
}
break;
}
default: {
// create, update, enter, leave, delete cases
if (!subscription) {
break;
}
let override = false;
if (data.original) {
override = true;
delete data.original.__type;
// Check for removed fields
for (const field in data.original) {
if (!(field in data.object)) {
data.object[field] = undefined;
case OP_EVENTS.ERROR: {
const parseError = new ParseError(data.code, data.error);
if (!this.id) {
this.connectPromise.reject(parseError);
this.state = CLIENT_STATE.DISCONNECTED;
}
if (data.requestId) {
if (subscription) {
subscription.subscribePromise.reject(parseError);
setTimeout(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.ERROR, data.error), 200);
}
} else {
this.emit(CLIENT_EMMITER_TYPES.ERROR, data.error);
}
if (data.error === 'Additional properties not allowed') {
this.additionalProperties = false;
}
data.original = ParseObject.fromJSON(data.original, false);
if (data.reconnect) {
this._handleReconnect();
}
break;
}
delete data.object.__type;
const parseObject = ParseObject.fromJSON(
data.object,
!(subscription.query && subscription.query._select) ? override : false
);

if (data.original) {
subscription.emit(data.op, parseObject, data.original, response);
} else {
subscription.emit(data.op, parseObject, response);
case OP_EVENTS.UNSUBSCRIBED: {
if (subscription) {
this.subscriptions.delete(data.requestId);
subscription.subscribed = false;
subscription.unsubscribePromise.resolve();
}
break;
}
default: {
// create, update, enter, leave, delete cases
if (!subscription) {
break;
}
let override = false;
if (data.original) {
override = true;
delete data.original.__type;
// Check for removed fields
for (const field in data.original) {
if (!(field in data.object)) {
data.object[field] = undefined;
}
}
data.original = ParseObject.fromJSON(data.original, false);
}
delete data.object.__type;
const parseObject = ParseObject.fromJSON(
data.object,
!(subscription.query && subscription.query._select) ? override : false
);

if (data.original) {
subscription.emit(data.op, parseObject, data.original, response);
} else {
subscription.emit(data.op, parseObject, response);
}

const localDatastore = CoreManager.getLocalDatastore();
if (override && localDatastore.isEnabled) {
localDatastore._updateObjectIfPinned(parseObject).then(() => {});
const localDatastore = CoreManager.getLocalDatastore();
if (override && localDatastore.isEnabled) {
localDatastore._updateObjectIfPinned(parseObject).then(() => {});
}
}
}
}
}

_handleWebSocketClose() {
Expand Down
Loading