Skip to content

Commit 7ef8b06

Browse files
build: Release (#2589)
2 parents 26d5cc9 + 365599f commit 7ef8b06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+8205
-8431
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
* text=auto eol=lf
22

33
*.js text
4+
*.ts text
5+
*.mjs text
46
*.html text
57
*.less text
68
*.json text

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

build_releases.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ console.log(`Building JavaScript SDK v${pkg.version}...\n`)
3636

3737
console.log('Cleaning up old builds...\n');
3838

39-
rmDir(path.join(__dirname, 'dist'));
4039
rmDir(path.join(__dirname, 'lib'));
4140

4241
const crossEnv = 'npm run cross-env';
@@ -54,13 +53,9 @@ const gulp = 'npm run gulp';
5453
execCommand(`${crossEnv} PARSE_BUILD=react-native ${gulp} compile`),
5554
]);
5655

57-
console.log('Bundling and minifying for CDN distribution:');
56+
console.log('Bundling and minifying for CDN distribution');
5857
await Promise.all([
59-
execCommand(`${gulp} browserify`),
60-
execCommand(`${gulp} browserify-weapp`),
61-
]);
62-
await Promise.all([
63-
execCommand(`${gulp} minify`),
64-
execCommand(`${gulp} minify-weapp`),
58+
execCommand('npm run build:browser'),
59+
execCommand('npm run build:weapp'),
6560
]);
6661
}());

changelogs/CHANGELOG_alpha.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# [6.2.0-alpha.3](https://github.com/parse-community/Parse-SDK-JS/compare/6.2.0-alpha.2...6.2.0-alpha.3) (2025-04-15)
2+
3+
4+
### Performance Improvements
5+
6+
* Optimize bundle packaging with Vite ([#2553](https://github.com/parse-community/Parse-SDK-JS/issues/2553)) ([a4b19e5](https://github.com/parse-community/Parse-SDK-JS/commit/a4b19e532ce97fd61632335ca5b8158f756d6fe6))
7+
8+
# [6.2.0-alpha.2](https://github.com/parse-community/Parse-SDK-JS/compare/6.2.0-alpha.1...6.2.0-alpha.2) (2025-04-07)
9+
10+
11+
### Bug Fixes
12+
13+
* Missing error message when returning an internal server error ([#2543](https://github.com/parse-community/Parse-SDK-JS/issues/2543)) ([f91f3f1](https://github.com/parse-community/Parse-SDK-JS/commit/f91f3f10f645acf22d6e54379ad21a1701b5ccba))
14+
15+
# [6.2.0-alpha.1](https://github.com/parse-community/Parse-SDK-JS/compare/6.1.1...6.2.0-alpha.1) (2025-04-07)
16+
17+
18+
### Features
19+
20+
* Add `Uint8Array` support for `Parse.File` data ([#2548](https://github.com/parse-community/Parse-SDK-JS/issues/2548)) ([6f6bb66](https://github.com/parse-community/Parse-SDK-JS/commit/6f6bb660204f3b102f8e4167297327bf12e2e2be))
21+
122
# [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)
223

324

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = tseslint.config({
1414
jsdoc,
1515
},
1616
"rules": {
17-
"indent": ["error", 2],
17+
"indent": ["error", 2, { "SwitchCase": 1 }],
1818
"linebreak-style": ["error", "unix"],
1919
"no-trailing-spaces": 2,
2020
"eol-last": 2,

gulpfile.js

Lines changed: 4 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
const babel = require('gulp-babel');
2-
const browserify = require('browserify');
3-
const derequire = require('gulp-derequire');
42
const gulp = require('gulp');
5-
const insert = require('gulp-insert');
63
const path = require('path');
7-
const rename = require('gulp-rename');
8-
const source = require('vinyl-source-stream');
9-
const uglify = require('gulp-uglify');
104
const watch = require('gulp-watch');
115

126
const BUILD = process.env.PARSE_BUILD || 'browser';
13-
const VERSION = require('./package.json').version;
147

158
const transformRuntime = ["@babel/plugin-transform-runtime", {
169
"corejs": 3,
@@ -32,39 +25,14 @@ const PRESETS = {
3225
'react-native': ["@babel/preset-typescript", 'module:metro-react-native-babel-preset'],
3326
};
3427
const PLUGINS = {
35-
'browser': [transformRuntime, '@babel/plugin-proposal-class-properties', 'inline-package-json',
28+
'browser': [transformRuntime, '@babel/plugin-proposal-class-properties',
3629
['transform-inline-environment-variables', {'exclude': ['SERVER_RENDERING']}]],
37-
'weapp': [transformRuntime, '@babel/plugin-proposal-class-properties', 'inline-package-json',
30+
'weapp': [transformRuntime, '@babel/plugin-proposal-class-properties',
3831
['transform-inline-environment-variables', {'exclude': ['SERVER_RENDERING']}]],
39-
'node': ['inline-package-json', 'transform-inline-environment-variables'],
40-
'react-native': ['inline-package-json', 'transform-inline-environment-variables']
32+
'node': ['transform-inline-environment-variables'],
33+
'react-native': ['transform-inline-environment-variables']
4134
};
4235

43-
const DEV_HEADER = (
44-
'/**\n' +
45-
' * Parse JavaScript SDK v' + VERSION + '\n' +
46-
' *\n' +
47-
' * The source tree of this library can be found at\n' +
48-
' * https://github.com/ParsePlatform/Parse-SDK-JS\n' +
49-
' */\n'
50-
);
51-
52-
const FULL_HEADER = (
53-
'/**\n' +
54-
' * Parse JavaScript SDK v' + VERSION + '\n' +
55-
' *\n' +
56-
' * Copyright 2015-present Parse Platform\n' +
57-
' * All rights reserved.\n' +
58-
' *\n' +
59-
' * The source tree of this library can be found at\n' +
60-
' * https://github.com/ParsePlatform/Parse-SDK-JS\n' +
61-
' *\n' +
62-
' * This source code is licensed under the license found in the LICENSE\n' +
63-
' * file in the root directory of this source tree. Additional legal\n' +
64-
' * information can be found in the NOTICE file in the same directory.\n' +
65-
' */\n'
66-
);
67-
6836
function compileTask(stream) {
6937
return stream
7038
.pipe(babel({
@@ -82,69 +50,6 @@ gulp.task('compile', function() {
8250
return compileTask(gulp.src('src/*.*(js|ts)'));
8351
});
8452

85-
gulp.task('browserify', function(cb) {
86-
const stream = browserify({
87-
builtins: ['_process', 'events'],
88-
entries: 'lib/browser/Parse.js',
89-
standalone: 'Parse'
90-
})
91-
.exclude('xmlhttprequest')
92-
.ignore('_process')
93-
.bundle();
94-
stream.on('end', () => {
95-
cb();
96-
});
97-
return stream.pipe(source('parse.js'))
98-
.pipe(derequire())
99-
.pipe(insert.prepend(DEV_HEADER))
100-
.pipe(gulp.dest('./dist'));
101-
});
102-
103-
104-
gulp.task('browserify-weapp', function(cb) {
105-
const stream = browserify({
106-
builtins: ['_process', 'events'],
107-
entries: 'lib/weapp/Parse.js',
108-
standalone: 'Parse'
109-
})
110-
.exclude('xmlhttprequest')
111-
.ignore('_process')
112-
.bundle();
113-
stream.on('end', () => {
114-
cb();
115-
});
116-
return stream.pipe(source('parse.weapp.js'))
117-
.pipe(derequire())
118-
.pipe(insert.prepend(DEV_HEADER))
119-
.pipe(gulp.dest('./dist'));
120-
});
121-
122-
gulp.task('minify', function() {
123-
return gulp.src('dist/parse.js')
124-
.pipe(uglify())
125-
.pipe(insert.prepend(FULL_HEADER))
126-
.pipe(rename({ extname: '.min.js' }))
127-
.pipe(gulp.dest('./dist'))
128-
});
129-
130-
gulp.task('minify-weapp', function() {
131-
return gulp.src('dist/parse.weapp.js')
132-
.pipe(uglify())
133-
.pipe(insert.prepend(FULL_HEADER))
134-
.pipe(rename({ extname: '.min.js' }))
135-
.pipe(gulp.dest('./dist'))
136-
});
137-
13853
gulp.task('watch', function() {
139-
if (BUILD === 'browser') {
140-
const watcher = gulp.watch('src/*.*(js|ts)', { ignoreInitial: false }, gulp.series('compile', 'browserify', 'minify'));
141-
watcher.on('add', function(path) {
142-
console.log(`File ${path} was added`);
143-
});
144-
watcher.on('change', function(path) {
145-
console.log(`File ${path} was changed`);
146-
});
147-
return watcher;
148-
}
14954
return compileTask(watch('src/*.*(js|ts)', { ignoreInitial: false, verbose: true }));
15055
});

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require('./lib/browser/Parse.js');
1+
module.exports = require('./lib/browser/Parse.js').default;

integration/test/IdempotencyTest.js

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,39 @@
11
'use strict';
2+
const originalFetch = global.fetch;
23

34
const Parse = require('../../node');
45
const sleep = require('./sleep');
5-
66
const Item = Parse.Object.extend('IdempotencyItem');
7-
const RESTController = Parse.CoreManager.getRESTController();
87

9-
const XHR = RESTController._getXHR();
10-
function DuplicateXHR(requestId) {
11-
function XHRWrapper() {
12-
const xhr = new XHR();
13-
const send = xhr.send;
14-
xhr.send = function () {
15-
this.setRequestHeader('X-Parse-Request-Id', requestId);
16-
send.apply(this, arguments);
17-
};
18-
return xhr;
19-
}
20-
return XHRWrapper;
8+
function DuplicateRequestId(requestId) {
9+
global.fetch = async (...args) => {
10+
const options = args[1];
11+
options.headers['X-Parse-Request-Id'] = requestId;
12+
return originalFetch(...args);
13+
};
2114
}
2215

2316
describe('Idempotency', () => {
24-
beforeEach(() => {
25-
RESTController._setXHR(XHR);
17+
afterEach(() => {
18+
global.fetch = originalFetch;
2619
});
2720

2821
it('handle duplicate cloud code function request', async () => {
29-
RESTController._setXHR(DuplicateXHR('1234'));
22+
DuplicateRequestId('1234');
3023
await Parse.Cloud.run('CloudFunctionIdempotency');
3124
await expectAsync(Parse.Cloud.run('CloudFunctionIdempotency')).toBeRejectedWithError(
3225
'Duplicate request'
3326
);
3427
await expectAsync(Parse.Cloud.run('CloudFunctionIdempotency')).toBeRejectedWithError(
3528
'Duplicate request'
3629
);
37-
3830
const query = new Parse.Query(Item);
3931
const results = await query.find();
4032
expect(results.length).toBe(1);
4133
});
4234

4335
it('handle duplicate job request', async () => {
44-
RESTController._setXHR(DuplicateXHR('1234'));
36+
DuplicateRequestId('1234');
4537
const params = { startedBy: 'Monty Python' };
4638
const jobStatusId = await Parse.Cloud.startJob('CloudJob1', params);
4739
await expectAsync(Parse.Cloud.startJob('CloudJob1', params)).toBeRejectedWithError(
@@ -61,12 +53,12 @@ describe('Idempotency', () => {
6153
});
6254

6355
it('handle duplicate POST / PUT request', async () => {
64-
RESTController._setXHR(DuplicateXHR('1234'));
56+
DuplicateRequestId('1234');
6557
const testObject = new Parse.Object('IdempotentTest');
6658
await testObject.save();
6759
await expectAsync(testObject.save()).toBeRejectedWithError('Duplicate request');
6860

69-
RESTController._setXHR(DuplicateXHR('5678'));
61+
DuplicateRequestId('5678');
7062
testObject.set('foo', 'bar');
7163
await testObject.save();
7264
await expectAsync(testObject.save()).toBeRejectedWithError('Duplicate request');

integration/test/ParseDistTest.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ for (const fileName of ['parse.js', 'parse.min.js']) {
88
beforeEach(async () => {
99
browser = await puppeteer.launch({
1010
args: ['--disable-web-security', '--incognito', '--no-sandbox'],
11+
devtools: false,
1112
});
1213
const context = await browser.createBrowserContext();
1314
page = await context.newPage();
@@ -42,7 +43,7 @@ for (const fileName of ['parse.js', 'parse.min.js']) {
4243
expect(obj.id).toEqual(response);
4344
});
4445

45-
it('can cancel save file with uri', async () => {
46+
it('can cancel save file', async () => {
4647
let requestsCount = 0;
4748
let abortedCount = 0;
4849
const promise = resolvingPromise();
@@ -63,11 +64,11 @@ for (const fileName of ['parse.js', 'parse.min.js']) {
6364
}
6465
});
6566
await page.evaluate(async () => {
66-
const parseLogo =
67-
'https://raw.githubusercontent.com/parse-community/parse-server/master/.github/parse-server-logo.png';
68-
const file = new Parse.File('parse-server-logo', { uri: parseLogo });
69-
file.save().then(() => {});
70-
67+
const SIZE_10_MB = 10 * 1024 * 1024;
68+
const file = new Parse.File('test_file.txt', new Uint8Array(SIZE_10_MB));
69+
file.save().then(() => {
70+
fail('should not save');
71+
});
7172
return new Promise(resolve => {
7273
const intervalId = setInterval(() => {
7374
if (file._requestTask && typeof file._requestTask.abort === 'function') {

integration/test/ParseFileTest.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,29 @@ describe('Parse.File', () => {
4343
file.cancel();
4444
});
4545

46+
it('can get file upload / download progress', async () => {
47+
const file = new Parse.File('parse-js-test-file', [61, 170, 236, 120]);
48+
let progress = 0;
49+
await file.save({
50+
progress: (value, loaded, total) => {
51+
progress = value;
52+
expect(loaded).toBeDefined();
53+
expect(total).toBeDefined();
54+
},
55+
});
56+
expect(progress).toBe(1);
57+
progress = 0;
58+
file._data = null;
59+
await file.getData({
60+
progress: (value, loaded, total) => {
61+
progress = value;
62+
expect(loaded).toBeDefined();
63+
expect(total).toBeDefined();
64+
},
65+
});
66+
expect(progress).toBe(1);
67+
});
68+
4669
it('can not get data from unsaved file', async () => {
4770
const file = new Parse.File('parse-server-logo', [61, 170, 236, 120]);
4871
file._data = null;

integration/test/ParseLegacyTest.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
const { Parse } = require('../../node');
4+
5+
describe('Parse Legacy Import', () => {
6+
it('can query object', async () => {
7+
const object = new Parse.Object('TestObject');
8+
object.set('foo', 'bar');
9+
await object.save();
10+
const query = new Parse.Query('TestObject');
11+
const result = await query.get(object.id);
12+
expect(result.id).toBe(object.id);
13+
});
14+
});

integration/test/ParseLocalDatastoreTest.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ function runTest(controller) {
3838
Parse.initialize('integration');
3939
Parse.CoreManager.set('SERVER_URL', serverURL);
4040
Parse.CoreManager.set('MASTER_KEY', 'notsosecret');
41-
const RESTController = Parse.CoreManager.getRESTController();
42-
RESTController._setXHR(require('xmlhttprequest').XMLHttpRequest);
4341
Parse.enableLocalDatastore();
4442
});
4543

@@ -1082,8 +1080,6 @@ function runTest(controller) {
10821080
Parse.initialize('integration');
10831081
Parse.CoreManager.set('SERVER_URL', serverURL);
10841082
Parse.CoreManager.set('MASTER_KEY', 'notsosecret');
1085-
const RESTController = Parse.CoreManager.getRESTController();
1086-
RESTController._setXHR(require('xmlhttprequest').XMLHttpRequest);
10871083
Parse.enableLocalDatastore();
10881084

10891085
const numbers = [];

integration/test/ParseReactNativeTest.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ const LocalDatastoreController =
88
const StorageController = require('../../lib/react-native/StorageController.default').default;
99
const RESTController = require('../../lib/react-native/RESTController').default;
1010

11-
RESTController._setXHR(require('xmlhttprequest').XMLHttpRequest);
12-
1311
describe('Parse React Native', () => {
1412
beforeEach(() => {
1513
// Set up missing controllers and configurations

0 commit comments

Comments
 (0)