Skip to content

Commit 4d62c21

Browse files
committed
Merge remote-tracking branch 'upstream/alpha' into alpha
2 parents 9f504a9 + 7bc91d9 commit 4d62c21

File tree

12 files changed

+283
-184
lines changed

12 files changed

+283
-184
lines changed

changelogs/CHANGELOG_alpha.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1+
# [3.5.0-alpha.3](https://github.com/parse-community/Parse-SDK-JS/compare/3.5.0-alpha.2...3.5.0-alpha.3) (2022-09-14)
2+
3+
4+
### Bug Fixes
5+
6+
* `Schema.addField` does not correctly add value of type `Date` ([#1544](https://github.com/parse-community/Parse-SDK-JS/issues/1544)) ([15111f7](https://github.com/parse-community/Parse-SDK-JS/commit/15111f74a658eefc71a50b6bfb3d25c7997d26a2))
7+
8+
# [3.5.0-alpha.2](https://github.com/parse-community/Parse-SDK-JS/compare/3.5.0-alpha.1...3.5.0-alpha.2) (2022-09-12)
9+
10+
11+
### Bug Fixes
12+
13+
* remove base64 validation due to validation inefficiency ([#1543](https://github.com/parse-community/Parse-SDK-JS/issues/1543)) ([473949d](https://github.com/parse-community/Parse-SDK-JS/commit/473949d514a395cf3656b03e083e30fff6e2f22c))
14+
15+
# [3.5.0-alpha.1](https://github.com/parse-community/Parse-SDK-JS/compare/3.4.4-alpha.2...3.5.0-alpha.1) (2022-09-08)
16+
17+
18+
### Features
19+
20+
* add `json` option to `Parse.Query.each()` ([#1539](https://github.com/parse-community/Parse-SDK-JS/issues/1539)) ([89fd5ec](https://github.com/parse-community/Parse-SDK-JS/commit/89fd5ec6a8e210de3946434c6c88d6de87b6635c))
21+
* add json option to query.each ([299fb0d](https://github.com/parse-community/Parse-SDK-JS/commit/299fb0d49cbbd3c95c2e8a61744bd03e93c33d36))
22+
23+
## [3.4.4-alpha.2](https://github.com/parse-community/Parse-SDK-JS/compare/3.4.4-alpha.1...3.4.4-alpha.2) (2022-08-16)
24+
25+
26+
### Bug Fixes
27+
28+
* `Parse.User.signUp()` does not pass context to Cloud Code ([#1527](https://github.com/parse-community/Parse-SDK-JS/issues/1527)) ([53edcfd](https://github.com/parse-community/Parse-SDK-JS/commit/53edcfd7ad1bd075a6097ba3c129c5f0998ffbfa))
29+
30+
## [3.4.4-alpha.1](https://github.com/parse-community/Parse-SDK-JS/compare/3.4.3...3.4.4-alpha.1) (2022-07-28)
31+
32+
33+
### Bug Fixes
34+
35+
* creating a Parse.File with base64 string fails for some encodings ([#1517](https://github.com/parse-community/Parse-SDK-JS/issues/1517)) ([0439862](https://github.com/parse-community/Parse-SDK-JS/commit/0439862cd83dc37f8f3571b68fdaccb6b11b540d))
36+
* subscription to a LiveQuery containing `ParseQuery.select` overrides properties ([#1488](https://github.com/parse-community/Parse-SDK-JS/issues/1488)) ([b80eee4](https://github.com/parse-community/Parse-SDK-JS/commit/b80eee4b010b60d37b34b566880ed19f05d4c801))
37+
138
## [3.4.3-alpha.3](https://github.com/parse-community/Parse-SDK-JS/compare/3.4.3-alpha.2...3.4.3-alpha.3) (2022-07-02)
239

340

integration/test/ParseQueryTest.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ describe('Parse Query', () => {
7070
assert.strictEqual(result.foo, 'bar');
7171
assert.strictEqual(result.className, 'TestObject');
7272
assert.strictEqual(result.objectId, object.id);
73+
74+
await query.each((obj) => {
75+
assert.strictEqual(obj instanceof Parse.Object, false);
76+
assert.strictEqual(obj.foo, 'bar');
77+
assert.strictEqual(obj.className, 'TestObject');
78+
assert.strictEqual(obj.objectId, object.id);
79+
}, { json: true });
7380
});
7481

7582
it('can do query with count', async () => {

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse",
3-
"version": "3.4.4-beta.1",
3+
"version": "3.5.0-alpha.3",
44
"description": "The Parse JavaScript SDK",
55
"homepage": "https://parseplatform.org/",
66
"keywords": [
@@ -73,7 +73,7 @@
7373
"gulp-rename": "2.0.0",
7474
"gulp-uglify": "3.0.2",
7575
"gulp-watch": "5.0.1",
76-
"husky": "4.3.5",
76+
"husky": "4.3.8",
7777
"jasmine": "3.5.0",
7878
"jasmine-reporters": "2.3.2",
7979
"jasmine-spec-reporter": "6.0.0",

src/ParseFile.js

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,6 @@ export type FileSource =
4242
type: string,
4343
};
4444

45-
const base64Regex = new RegExp(
46-
'([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))',
47-
'i'
48-
);
49-
50-
const dataUriRegex = new RegExp(
51-
`^data:([a-zA-Z]+\\/[-a-zA-Z0-9+.]+(;[a-z-]+=[a-zA-Z0-9+.-]+)?)?(;base64)?,(${base64Regex.source})*$`,
52-
'i'
53-
);
54-
5545
function b64Digit(number: number): string {
5646
if (number < 26) {
5747
return String.fromCharCode(65 + number);
@@ -145,29 +135,13 @@ class ParseFile {
145135
type: specifiedType,
146136
};
147137
} else if (data && typeof data.base64 === 'string') {
148-
// Check if data URI or base64 string is valid
149-
const validationRegex = new RegExp(base64Regex.source + '|' + dataUriRegex.source, 'i');
150-
if (!validationRegex.test(data.base64)) {
151-
throw new Error(
152-
'Cannot create a Parse.File without valid data URIs or base64 encoded data.'
153-
);
154-
}
155-
156138
const base64 = data.base64.split(',').slice(-1)[0];
157-
let type =
158-
specifiedType || data.base64.split(';').slice(0, 1)[0].split(':').slice(1, 2)[0] || '';
159-
160-
// https://tools.ietf.org/html/rfc2397
161-
// If <mediatype> is omitted, it defaults to text/plain;charset=US-ASCII.
162-
// As a shorthand, "text/plain" can be omitted but the charset parameter supplied.
163-
if (dataUriRegex.test(data.base64)) {
164-
type = type || 'text/plain';
165-
}
166-
139+
const dataType =
140+
specifiedType || data.base64.split(';').slice(0, 1)[0].split(':').slice(1, 2)[0] || 'text/plain';
167141
this._source = {
168142
format: 'base64',
169143
base64,
170-
type,
144+
type: dataType,
171145
};
172146
} else {
173147
throw new TypeError('Cannot create a Parse.File with that data.');

src/ParseQuery.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,9 @@ class ParseQuery {
990990
if (options.hasOwnProperty('context') && typeof options.context === 'object') {
991991
findOptions.context = options.context;
992992
}
993+
if (options.hasOwnProperty('json')) {
994+
findOptions.json = options.json;
995+
}
993996

994997
let finished = false;
995998
let previousResults = [];
@@ -1030,6 +1033,7 @@ class ParseQuery {
10301033
* be used for this request.
10311034
* <li>sessionToken: A valid session token, used for making a request on
10321035
* behalf of a specific user.
1036+
* <li>json: Return raw json without converting to Parse.Object
10331037
* </ul>
10341038
* @returns {Promise} A promise that will be fulfilled once the
10351039
* iteration has completed.

src/ParseSchema.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,14 @@ class ParseSchema {
241241
if (options.defaultValue !== undefined) {
242242
fieldOptions.defaultValue = options.defaultValue;
243243
}
244+
if (type === 'Date') {
245+
if (options && options.defaultValue) {
246+
fieldOptions.defaultValue = {
247+
__type: 'Date',
248+
iso: new Date(options.defaultValue),
249+
};
250+
}
251+
}
244252
this._fields[name] = fieldOptions;
245253
return this;
246254
}
@@ -310,12 +318,6 @@ class ParseSchema {
310318
* @returns {Parse.Schema} Returns the schema, so you can chain this call.
311319
*/
312320
addDate(name: string, options: FieldOptions) {
313-
if (options && options.defaultValue) {
314-
options.defaultValue = {
315-
__type: 'Date',
316-
iso: new Date(options.defaultValue),
317-
};
318-
}
319321
return this.addField(name, 'Date', options);
320322
}
321323

src/ParseUser.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,12 @@ class ParseUser extends ParseObject {
425425
if (options.hasOwnProperty('installationId')) {
426426
signupOptions.installationId = options.installationId;
427427
}
428+
if (
429+
options.hasOwnProperty('context') &&
430+
Object.prototype.toString.call(options.context) === '[object Object]'
431+
) {
432+
signupOptions.context = options.context;
433+
}
428434

429435
const controller = CoreManager.getUserController();
430436
return controller.signUp(this, attrs, signupOptions);

src/__tests__/ParseFile-test.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,22 @@ describe('ParseFile', () => {
6060
process.env.PARSE_BUILD = 'node';
6161
});
6262

63-
it('can create files with base64 encoding', () => {
63+
it('can create files with base64 encoding (no padding)', () => {
64+
const file = new ParseFile('parse.txt', { base64: 'YWJj' });
65+
expect(file._source.base64).toBe('YWJj');
66+
expect(file._source.type).toBe('text/plain');
67+
});
68+
69+
it('can create files with base64 encoding (1 padding)', () => {
70+
const file = new ParseFile('parse.txt', { base64: 'YWI=' });
71+
expect(file._source.base64).toBe('YWI=');
72+
expect(file._source.type).toBe('text/plain');
73+
});
74+
75+
it('can create files with base64 encoding (2 padding)', () => {
6476
const file = new ParseFile('parse.txt', { base64: 'ParseA==' });
6577
expect(file._source.base64).toBe('ParseA==');
66-
expect(file._source.type).toBe('');
78+
expect(file._source.type).toBe('text/plain');
6779
});
6880

6981
it('can set the default type to be text/plain when using base64', () => {
@@ -152,12 +164,6 @@ describe('ParseFile', () => {
152164
expect(function () {
153165
new ParseFile('parse.txt', 'string');
154166
}).toThrow('Cannot create a Parse.File with that data.');
155-
156-
expect(function () {
157-
new ParseFile('parse.txt', {
158-
base64: 'abc',
159-
});
160-
}).toThrow('Cannot create a Parse.File without valid data URIs or base64 encoded data.');
161167
});
162168

163169
it('throws with invalid base64', () => {

src/__tests__/ParseQuery-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,13 @@ describe('ParseQuery', () => {
13761376
expect(result.size).toBe('small');
13771377
expect(result.name).toEqual('Product 3');
13781378
expect(result.className).toEqual('Item');
1379+
1380+
await q.each((obj) => {
1381+
expect(obj.objectId).toBe('I1');
1382+
expect(obj.size).toBe('small');
1383+
expect(obj.name).toEqual('Product 3');
1384+
expect(obj.className).toEqual('Item');
1385+
}, { json: true });
13791386
});
13801387

13811388
it('will error when getting a nonexistent object', done => {

0 commit comments

Comments
 (0)