Giter VIP home page Giter VIP logo

parse-sdk-js's Introduction

parse-repository-header-sdk-js


Build Status CI alpha Build Status CI beta Build Status CI release Snyk Badge Coverage

Node Version auto-release

npm latest version npm beta version npm alpha version

Backers on Open Collective Sponsors on Open Collective Forum Twitter


A library that gives you access to the powerful Parse Server backend from your JavaScript app. For more information on Parse and its features, see the website, the JavaScript guide, the Cloud Code guide or API Reference.


Getting Started

The easiest way to integrate the Parse SDK into your JavaScript project is through the npm module. However, if you want to use a pre-compiled file, you can fetch it from unpkg. The development version is available at https://unpkg.com/parse/dist/parse.js, and the minified production version is at https://unpkg.com/parse/dist/parse.min.js.

Using Parse on Different Platforms

The JavaScript ecosystem is wide and incorporates a large number of platforms and execution environments. To handle this, the Parse npm module contains special versions of the SDK tailored to use in Node.js and React Native environments. Not all features make sense in all environments, so using the appropriate package will ensure that items like local storage, user sessions, and HTTP requests use appropriate dependencies. For server side rendered applications, you may set the SERVER_RENDERING variable to prevent warnings at runtime.

To use the npm modules for a browser based application, include it as you normally would:

const Parse = require('parse');
// ES6 Minimized
import Parse from 'parse/dist/parse.min.js';

For web worker or browser applications, indexedDB storage is available:

Parse.CoreManager.setStorageController(Parse.IndexedDB);

For server-side applications or Node.js command line tools, include 'parse/node':

// In a node.js environment
const Parse = require('parse/node');

For React Native applications, include 'parse/react-native.js':

// In a React Native application
const Parse = require('parse/react-native.js');

// On React Native >= 0.50 and Parse >= 1.11.0, set the Async
const AsyncStorage = require('@react-native-async-storage/async-storage');
Parse.setAsyncStorage(AsyncStorage);

For WeChat miniprogram, include 'parse/weapp':

// In a WeChat miniprogram
const Parse = require('parse/weapp');

If you want to use a pre-compiled file, you can fetch it from unpkg. The development version is available at https://unpkg.com/parse/dist/parse.weapp.js, and the minified production version is at https://unpkg.com/parse/dist/parse.weapp.min.js.

For TypeScript applications, install '@types/parse':

$ npm install @types/parse

Types are updated manually after every release. If a definition doesn't exist, please submit a pull request to @types/parse

Core Manager

The SDK has a Core Manager that handles all configurations and controllers. These modules can be swapped out for customization before you initialize the SDK. For full list of all available modules take a look at the Core Manager Documentation.

// Configuration example
Parse.CoreManager.set('REQUEST_ATTEMPT_LIMIT', 1)

// Controller example
Parse.CoreManager.setRESTController(MyRESTController);

Compatibility

Parse Server

Parse JS SDK is compatible with the following versions of Parse Server.

Parse JS SDK Parse Server
4.x.x <= 6.x.x
5.x.x >= 7.x.x

Node.js

Parse JS SDK is continuously tested with the most recent releases of Node.js to ensure compatibility. We follow the Node.js Long Term Support plan and only test against versions that are officially supported and have not reached their end-of-life date.

Version Latest Version End-of-Life Compatible
Node.js 18 18.19.0 April 2025 ✅ Yes
Node.js 20 20.10.0 April 2026 ✅ Yes

3rd Party Authentications

Parse Server supports many 3rd Party Authenications. It is possible to linkWith any 3rd Party Authentication by creating a custom authentication module.

Experimenting

You can also use your own forks, and work in progress branches by specifying them:

npm install github:myUsername/Parse-SDK-JS#my-awesome-feature

And don't forget, if you plan to deploy it remotely, you should run npm install with the --save option.

Contributing

We really want Parse to be yours, to see it grow and thrive in the open source community. Please see the Contributing to Parse Javascript SDK guide.

parse-sdk-js's People

Contributors

acinader avatar andrewimm avatar braker1nine avatar cheesykyle avatar davimacedo avatar dblythy avatar dependabot[bot] avatar dplewis avatar flovilmart avatar gfosco avatar greenkeeper[bot] avatar jeffgukang avatar jeromedeleon avatar montymxb avatar mstniy avatar mtrezza avatar noahsilas avatar parseplatformorg avatar peterdotjs avatar raschidjfr avatar sebc99 avatar semantic-release-bot avatar snyk-bot avatar stanleyw avatar stevestencil avatar swittk avatar tomwfox avatar tylerbrock avatar wangmengyan95 avatar wuotr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parse-sdk-js's Issues

query.include is not including what it should

After I changed the Parse version to 1.6.4, query.include stopped working and it is not including the data from the pointer. There was no changes to my code, only the Parse version. When I revert Parse version back to 1.6.2 query.include is works fine again, but I can't use 1.6.2 because of the Relations bug that was fixed on 1.6.4.

Include parse-latest.js within a dist/ directory of the repo

Hi,

I'm currently developing a method to carry out Unit tests on Cloud Code (Something I will probably open source), and was utilising parse-latest.js to include Parse specific functions.

Each time the repo is updated, are you able to include pre-built "parse-latest.js" files for React/Node/Browser, therefore users will not have the trouble of building the files through gulp each time?

Thanks,

beforeSave issues with dirtyKeys

I am running my CloudCode on a node.js server, using webhooks as described in a recent blog post on parse.com, and using CloudCode-Express.

Everything seems to run smooth, however in my beforeSave triggers I need to check if certain keys are dirty and they never are?

Parse.Cloud.beforeSave("CLASSNAME", function(request, response) {
    console.log(request.object.dirtyKeys()); // always outputs an empty array to the console
    if(request.object.dirty("key") && request.object.get("key")) { // value is a boolean
        // never executes
    }
});

Is this a bug, or am I doing something wrong? Running the same triggers on CloudCode on Parse.com (non-self-hosted), works as expected.

Return Session Token from CloudCode

I don't know if this is the proper place, but this is the issue I'm having:

I want to implement my own authentication method (integrating with a 3rd party service), and for that I have Cloud Function that logs the user in and returns the session token, so that on the client I can call become and effectively log that user in.

Before I enabled revokable sessions this worked fine because I was able to get the user then call user.getSessionToken() and return it.
But after rovocable sessions were enabled the session tokens are always undefined.
The only solution I was able to find is to manually re-login the user in CloudCode, but in order to do that I needed to know the user's password.
So the only was I was able to do it was by changing the user's password to a new random string every login so I could do it in CloudCode and return the session token?

I don't think it is a very good solution and I'm sure there has to be a better way.

Thanks!

Parse 1.6.X does not return values for all columns on query.find

I tried to use Parse.1.6.2 and 1.6.4 today but found the when calling query.find.., objects were returned with only the classname and objectId info. All other columns were absent. Eg.

var Plan = Parse.Object.extend("Plan");

var query = new Parse.Query(Plan);
query.equalTo("user", Parse.User.current());
query.find({
success: function(allPlans) {
console.log(allPlans);
...
},
error: function(err1, err2) {
console.log(err1,err2);
}
});

In the success callback the collection printed to the console only contains objectId and className keys.

Is this a bug with the newer versions of this SDK or am I missing something?

beforeSave makes all fields undefined

When I add a beforeSave function to my Parse hosted CloudCode, all fields in the class I'm saving get changed to undefined. It doesn't matter what I put in the beforeSave code. A simple function like:

Parse.Cloud.beforeSave("chart", function(request, response) {
    console.log("Running beforesave")
     response.success()
});

changes all fields to undefined. If I switch to JSSDK 1.5.0, everything works fine. So it appears to be a bug in 1.6.x and higher.

parent is not defined error when creating a relation in node SDK

I am executing the following code

  var TestObject = Parse.Object.extend("TestObject");
  var testObject = new TestObject();
  testObject.set("Name", "testName");

  testObject.save(null, {
    success: function(testObject) {
      // Execute any logic that should take place after the object is saved.
      console.log('New testObject created with objectId: ' + testObject.id);
      var TestObject2 = Parse.Object.extend("TestObject2");
      var testObject2 = new TestObject2();
      testObject2.set("Name", "testName2");
      testObject2.save(null, {
        success: function(testObject2) {
          // Execute any logic that should take place after the object is saved.
          console.log('New testObject2 created with objectId: ' + testObject2.id);
          var relation = testObject.relation("TestObjectRelation");
          console.log('Make sure the relation exists ' + testObject.relation("TestObjectRelation"));

          relation.add(testObject2);
          testObject.save();
        },
        error: function(testObject2, error) {
          // Execute any logic that should take place if the save fails.
          // error is a Parse.Error with an error code and message.
          console.log('Failed to create new testObject2, with error code: ' + error.message);
        }
      });

    },
    error: function(venue, error) {
      // Execute any logic that should take place if the save fails.
      // error is a Parse.Error with an error code and message.
      console.log('Failed to create new testObject, with error code: ' + error.message);
    }
  });

I create an object, and then create a second object and try to save that as a relation to the first object ... though I am following the documented syntax, I always get the same error

ReferenceError: parent is not defined
at ParseRelation.add (/home/showcast/node_modules/parse/lib/node/ParseRelation.js:102:14)

Is this a bug in the node SDK ? are parse it's self?

Objects are not properly updated

Hey guys,
I've a weird problem. I retrieve objects from my database (Parse.com) and need to update them later on. But if I update them, they're sometimes re-created (new objects are created with the new values). But only sometimes. Below you find the code. Am I something missing?

[...]
var codes = ... // load objects

var response = JSON.parse(response.text);
if (response[0].status == "sent" || response[0].status == "queued"){
for (var i=0; i<codes.length; i++){
codes[i].set("sent", true);
}
}

return Parse.Object.saveAll(codes);

Error on Before Save and After Save at cloud code

Using this code on beforeSave and afterSave methods, saves a blank row with no data :

Parse.Cloud.beforeSave(Parse.Object.extend("Look"), function(request,response) {
     // Set up to modify user data
    alert("Calling before save for look");

    //For Expiring a look when look marked rejected
    for (var i in request.object.dirtyKeys()) {
            alert("Calling before save for look 1");

        var dirtyKey = request.object.dirtyKeys()[i];
        alert("dirty key for look aftersave"+dirtyKey);
        if(dirtyKey == "eventState" && request.object.get("eventState") == 2){
            //Also expire this look
            request.object.set("expired",true);
            alert("Look expired");

            var pushQuery = new Parse.Query(Parse.Installation);
            var userIdQuery = new Parse.Query(Parse.User);
            var message = "Your look has been rejected by the event administrator.";
            var fromUser=request.object.get("fromUser");

            userIdQuery.equalTo("objectId", fromUser);

            pushQuery.matchesQuery('user', userIdQuery);
            Parse.Push.send({
                    where: pushQuery,
                    data: {
                        alert: message,
                        type:"lookRejected"
                    }
            }, {
                success: function() {
                    alert("Push went successfully For Look Rejection!");
                },
                error: function(error) {
                    alert("Error executing: " + error.code + " " + error.message);
                }
            });

        }
    }

    response.success();

});


Parse.Cloud.afterSave(Parse.Object.extend("Look"), function(request) {
     alert("Calling before save for look");

    var userId = request.object.get("fromUser");
    var inappropriate = request.object.get("inappropriate");
    var like = request.object.get("likes");
    var dislike = request.object.get("dislikes");
    var pushQuery = new Parse.Query(Parse.Installation);
    var userIdQuery = new Parse.Query(Parse.User);
    var message = "The results are in! See what people think of your latest look.";
    var typeObj="like";
         alert("Calling before save for look 1");

    if(typeof dislike != "undefined"){
        like = like + dislike;
    }
    userIdQuery.equalTo("objectId", userId);
    userIdQuery.equalTo("lookResponse", like);


//  if(typeof inappropriate != "undefined" && inappropriate != '' && inappropriate){
//      message = "Your look has been marked inappropriate!!";
//      typeObj="inappropriate";
//  }else{
//      userIdQuery.equalTo("lookResponse", like);
//      message = "Hey! your looks are fetching likes!"
//      typeObj="like";
//  }

         alert("Calling before save for look 2");

    pushQuery.matchesQuery('user', userIdQuery);
    Parse.Push.send({
            where: pushQuery,
            data: {
                alert: message,
                type:typeObj
            }
        }, {
            success: function() {
                alert("Push went successfully!");
            },
            error: function(error) {
                alert("Error executing: " + error.code + " " + error.message);
            }
    });


});

Proposal: The future of Parse.Promise

This is a public discussion around the future of Parse.Promise. As Promises are made more widely available in browsers and Node, we need to consider evolving the currently implementation to meet developer expectations and avoid fragmentation.

This document is simply a proposal, and is by no means a guarantee. We want to get developer feedback as we move the SDK forward, and we hope these discussion issues are a viable way to collect opinions on our proposals.

Parse.Promise today

Parse.Promise was originally built off of the jQuery Deferred model years ago, which means it's almost – but not quite – Promises/A+ compliant. There are a few differences, but the only one that really affects developers involves the handling of exceptions: A+ will catch an exception, while the Deferred model will propagate it upwards.

It turns out that Parse.Promise contains code to adapt to A+ semantics. Internally, we have a flag called isAPlusCompliant which is disabled by default (to maintain consistency with older versions). It's currently scoped within the module and inaccessible from userspace, but we could expose it through static methods or a CoreManager value. If we wish to move Parse.Promise forward, this would be the first step.

While this would bring Parse Promises in line with the Promises/A+ spec, they would not match the behavior of Promises found in JS. This is because the A+ spec only covers how Promises behave when resolved; it does not dictate how Promises are constructed, resolved, or rejected.
A Parse Promise can be constructed with no parameters, and can be resolved or rejected by any code, as the resolution is performed by instance methods:

let myPromise = new Parse.Promise();
// do something...
myPromise.resolve();

Native JS Promises are constructed with a callback method. It is only within this method that the resolve / reject variables are available:

let myPromise = new Promise((resolve, reject) => {
  // do something...
  resolve();
});

As such, code written for one format may be difficult to rewrite into the other format. We would like to add functionality to Parse.Promise, allowing it to be constructed using the native Promise API. Supporting both styles will maintain functionality with older codebases, but allow new developers to use Parse.Promise in a way that matches the native implementation.

Eventually, we would rewrite the internals of the SDK to match this new format. We would also modify Parse.Promise to be backed by native Promises where supported, and continue to use our polyfill when it is not available.

Proposed Timeline:

  • Before 1.7, expose the isAPlusCompliant flag externally, either through methods or a CoreManager value.
  • In 1.7.0, default to having isAPlusCompliant set to true. This behavior can be disabled for legacy purposes, but it will be the default for all future versions.
  • Additionally in 1.7.0, allow Parse.Promise to be constructed in the same way as native Promises (new Promise(callback))
  • In 1.8.0, let Parse.Promise be backed by native promises where supported; continue to polyfill methods in environments that don't include a native Promise implementation
  • In 1.8.0, rewrite the internals of the SDK to use the new Promise(callback) interface.

React Native save - object not updated in storage

I'm using Parse/react-native library.

Steps:
I do some modifications to current user:

user.set("visible", value);
return user.save();

Parse.User.current() and Parse.User.currentAsync() are correctly updated.
In Data Browser the change is also updated.

I do a force close of the app, and when I enter again and fetch Parse.User.curretAsync(), the changes I previously made are gone.

Let me know if you need more informations to reproduce. Thanks!

Cloud code - calling signUp on anonymous user doesn't make user non-anonymous

I'm using this cloud function to upgrade a user from anonymous to real, and then request a password reset, on app https://www.parse.com/apps/invoice-maker-dev

After doing this, I then login with that user on an AndroidDevice, then call ParseAnonymousUtils.isLinked and expected the result to be false (real) but I get true (anonymous).

Looking at the ParseUser in the parse console I see that the user is still anonymous. If I follow a similar process from Android code, the user doesn't remain anonymous (the desired result).

See user bF2wHKAFDM in the screenshot, it does have the username set from the code below, but still is an anonymous user.

What do I need to do to make this user not anonymous?

Thanks! Alex

Parse.Cloud.define('requestPasswordResetInBackgroundAnonymous', function(request, response) {
  var googleAccountQuery = new Parse.Query(GoogleAccount);
  var email = request.params.email;

  if (!email || !email.length) 
    response.error('Email parameter required');

  Parse.Cloud.useMasterKey();

  googleAccountQuery.equalTo('name', email);
  googleAccountQuery.ascending('updatedAt'); // in case there are multiple
  googleAccountQuery.first({    
    success: function(googleAccount) {
      if (googleAccount) {
        var account = googleAccount.get("account");

        var userQuery = new Parse.Query(Parse.User);
        userQuery.equalTo('account', account);
        userQuery.ascending('updatedAt');
        userQuery.first({
          success: function(user) {
            if (user) {
              user.setUsername(email);
              user.setPassword('Eq54mY914Tt4:2U7WIf28K+o4483xi3Y');
              user.signUp(null, {
                success: function() {
                  Parse.User.requestPasswordReset(email, {
                    success: function() {
                      response.success();
                    },
                    error: function(error) {
                      response.error('requestPasswordReset failed: ' + error.code + ', ' + error.message);
                    }
                  });
                },
                error: function(user, error) {
                  response.error('signup failed: ' + error.code + ', ' + error.message);
                }
              });
            } else {
              response.error('No ParseUser found for account: ' + account.id);              
            }
          },
          error: function(error) {
            response.error('Error searching for ParseUser by account' + account.id + ': ' + error.code + ', ' + error.message);
          }
        });
      } else {
        response.error('No GoogleAccount found with email: ' + email);
      }
    },
    error: function(error) {
      response.error('Error searching for GoogleAccount with email' + email + ': ' + error.code + ', ' + error.message);
    }
  });  
});

screenshot 2015-09-23 13 03 30

include bug

toJSON has different implementations giving expanded include (correct) and non expanded include (not correct)

json[attr] = (0, _encode2['default'])(attrs[attr], false, true);
(https://parse.com/docs/downloads -- also the version i think is working in parse hosting)

means that pointers are not expanded, but NPM version of parse is

json[attr] = (0, _encode2['default'])(attrs[attr], false, false);
(https://github.com/ParsePlatform/Parse-SDK-JS)

above works in local debug but on cloud it breaks....

key: 'toJSON',
value: function toJSON() {
var json = {};
var attrs = this.attributes;
for (var attr in attrs) {
if ((attr === 'createdAt' || attr === 'updatedAt') && attrs[attr].toJSON) {
json[attr] = attrs[attr].toJSON();
} else {
json[attr] = (0, _encode2['default'])(attrs[attr], false, true);
}
}
var pending = this._getPendingOps();
for (var attr in pending[0]) {
json[attr] = pending[0][attr].toJSON();
}

            if (this.id) {
                json.objectId = this.id;
            }
            return json;
        }

Saving a Parse.com object with a custom 'objectId'

I'm trying to save a Parse.com Object with a custom objectId, but the object is not saved at all. I'm using the Javascript API. Here is an example:

var newsfeed = new Parse.Object("Newsfeed");
newsfeed.id = 'customid';
newsfeed.save();

But when looking at the list of Newsfeed object on Parse data it is not there.

If this is not possible there should be at least an error message.

dotted includes not returning from toJSON

1.6.6 resolves the problem with includes, but dotted includes such as myObject.createdUserRef does expand myObject, but doesn't expand createdUserRef pointer. extension of bug #32

Custom Analytics is not working anymore

The custom analytics is not working anymore since October 6th.
Everything seems to be working nicely on the client side

curl -i 'https://api.parse.com/1/events/push_clicked' -H 'Origin: https://notifiche.repubblica.it' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36' -H 'Content-Type: text/plain' -H 'Accept: */*' -H 'Referer: https://notifiche.repubblica.it/nazionale/redirect?redirect=http%3A%2F%2Flarep.it%2F1NOqUCn&kwnocache=907' -H 'Connection: keep-alive' --data-binary '{"dimensions":{"browser":"Chrome Desktop"},"_ApplicationId":"Value of ApplicationId","_JavaScriptKey":"Value of JavaScriptKey","_ClientVersion":"js1.4.2","_InstallationId":"a2a264b9-0a3c-e97e-caf4-2d140e6e53ab"}' --compressed HTTP/1.1 200 OK Access-Control-Allow-Methods: * Access-Control-Allow-Origin: * Content-Type: application/json; charset=utf-8 Date: Mon, 12 Oct 2015 15:04:38 GMT Server: nginx/1.6.0 X-Parse-Platform: G1 X-Runtime: 0.153381 Content-Length: 3 Connection: keep-alive

but on the Custom Analytics breakdown doesn't appear anything
schermata 2015-10-12 alle 17 42 59

License and patent packaging should be included in the website- and cdn-hosted SDK releases

Currently the only available licensing information in these single-file releases is a notice describing that the license/patent grants are included in the root dir of the source tree, and no such source tree exists in those distributions. As an end-user, this feels like I need to also include those files in the source tree of the projects that consume the library, even when the rest of the project is not covered by these same terms. Because of this ambiguity the only legally safe option I have is to not include this vital piece of code in my source distributions. However, injecting the actual license and patent information into the single-file distributions instead of the notice that's there now would fix this.

Maximum call stack size exceeded error after upgrading from 1.5.0 to 1.6.2

ref: https://developers.facebook.com/bugs/1478633002464123/

We have just upgraded from 1.5.0 to 1.6.2. ParseUser has a pointer to a Profile for that user, and the Profile has a pointer back to the ParseUser it belongs to. When the user logs out and logs back in again (i.e. you call Parse.User.logIn(...) and then Parse.User.logout and then Parse.User.logIn(...) again), we get this error:

screen shot 2015-09-22 at 09 21 52

What's happening is that when Parse.User.logIn is called, setCurrentUser calls user.toJSON(). The first time this happens, encode is called on the Profile pointer in the user object, and this encodes the Profile object by returning value.toPointer(). However, when I log out and log back in with the same user, this doesn't happen, because when getState is called for the Profile object, both the objectCache and serverData elements of the state object contain values. So when encode is called on the Profile pointer, value._getServerData() returns some content, and so it isn't encoded using value.toPointer(). This is where the fatal recursion kicks off.

I can work around this issue by calling Parse.Object._clearAllState() after Parse.User.logOut. Can you advise whether this work-around is sufficient for us to upgrade to 1.6.2, or would there be potential undesirable side-effects?

JSPM registry entry for Parse

Hi Andrew et al, I have a similar use case as Issue #26

This is to support the Parse+Backbone distribution I'm open sourcing to continue support for Backbone. I'm distributing it in two ways:

First, I will be creating a standalone bundle by modifying the current build process w/ Browserify combining Parse browser SDK w/ my Backbone fork. This will handle the folks that just need to import one ES5 bundle with Parse+Backbone.

However, it would be really handy to have a separate Git repo that just contains the latest built browser bundle. The reasoning for this is supporting SystemJS / JSPM as it would be great to be able to pull in just the Parse browser SDK bundle from a git repo as a dependency. When installing the NPM package via JSPM it pulls in everything and the kitchen sink of course including node and react-native runtimes and really muddies up the SystemJS config.js file with all the unneeded dependencies to run the Parse browser SDK. In regard to Issue #26 even if you added the lib / dist directories and content JSPM will still pull it all in which is undesirable. Therefore having a separate Git repo with the latest built browser SDK is really handy. This will allow folks to install the official Parse browser bundle repo and my Backbone fork as raw source into SystemJS via JSPM via Git.

Either you guys do it or I do it and I'd prefer Parse does it so that things stay up to date w/ timely updates.

FYI, I have converted Backbone 1.2.3 to ES6, modularized it and have made it extendable through constructor injection. This makes it easy to provide just the modifications for Parse support in addition to any further modifications to Backbone as desired in a clean / ES6 manner. This is why it's desirable to pull in the ES6 Backbone source and link it against the Parse browser bundle.

Thanks for considering this request...

Uncaught TypeError: provider.getAuthType is not a function

_linkWith @ parse-latest.js:7350
success @ parse-latest.js:7370
exports.default.init._ParseUser2.default._registerAuthenticationProvider.authenticate.FB.login.scope @ parse-latest.js:504
window.FB.v.__wrapper @ sdk.js:98
window.FB.ea.permissions.oauth.transform @ sdk.js:118
window.FB.ia.prepareCall @ sdk.js:118
o @ sdk.js:119
window.FB.k.provide.login @ sdk.js:120
(anonymous function) @ sdk.js:100
(anonymous function) @ sdk.js:98
authenticate @ parse-latest.js:501
_linkWith @ parse-latest.js:7360
_logInWith @ parse-latest.js:7972
logIn @ parse-latest.js:599
$scope.login @ welcome.js:15
fn @ VM27794:4
(anonymous function) @ ionic.bundle.js:57514
parent.$get.Scope.$eval @ ionic.bundle.js:24673
parent.$get.Scope.$apply @ ionic.bundle.js:24772
(anonymous function) @ ionic.bundle.js:57513
eventHandler @ ionic.bundle.js:12098
triggerMouseEvent @ ionic.bundle.js:2865
tapClick @ ionic.bundle.js:2854
tapMouseUp @ ionic.bundle.js:2927
.

Parse.Config in Cloud Coude

I don't seem to be able to get my Config object when calling Parse.Config in cloud code. I understand that the .get() method is asynchronous, and so may not be retrieved at the time of an HTTP request, but I figured I should be able to make a Config object a class variable, and set it on the success callback of the get() method.

From my testing, I don't seem to ever hit my callback (success or error) when calling Parse.Config.get()

Is this intended behavior? I am able to manage my Config object in client-side Javascript with no problems.

adding the ability to listen to changes of the current user on different browser tabs

on older versions (Parse JS SDK <= 1.5.0), i've used this hack (in the browser):

// Detect Parse session change in another tab
const STORAGE_KEY = `Parse/${Parse.applicationId}/currentUser`;

addEventListener('storage', function({ key, storageArea }) {
  if ((storageArea === localStorage) && (key === STORAGE_KEY)) {
    Parse.User._currentUser = null;
    Parse.User._currentUserMatchesDisk = false;
    Parse.User._currentAsync()
      .fail(Parse.Promise.as)
      .then(function() {
        // ··· dispatch changed event if needed
      });
  }
}, false);

i think this ability can be useful for everyone, because it's nice when an app reacts to a session change in all tabs instead of seeing outdated version in another tab.

i think it this ability need a proper API rather than workaround. i understand it's also a tricky thing to implement because of the different platforms, but i can be possible if we extend ParseUser class and SessionController.

the bug feature of storage event is that it only dispatches when the change happened on another tab's / window's Storage object. what make this feature easier to apply.

No 'Access-Control-Allow-Origin' header is present on the requested resource

I am querying some data using the JS SDK. It has been working for me however today when I run it again I get no data returned but the following in console:
XMLHttpRequest cannot load https://api.parse.com/1/classes/MyClass. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.0.108:8100' is therefore not allowed access. The response had HTTP status code 502.

But I have changed nothing in my code or on the Parse core...

problem using parse promises

Hi All,
I want to execute the following scenario:-

  1. Check if the object with ID exist in class data
    Does not exist:---Create the new entry in the database
    Exists :---Update some of the fields based on the input params
    2)After saving send the push notification

Below is my code:

query.first().then(function(results) {
// Create a trivial resolved promise as a base case.
var promise = Parse.Promise.as();

        AnsPtr = results.get("AnsPtr");
        //Max 10 Answers can be stored after that the answer will be overwritten.
        AnsPtr = AnsPtr % 10;
        console.log("new query succcess i got ansptr--"+AnsPtr);
        return promise;

}).then(function(){ //Saving the content in the database
if(request.params.Answer != null )
{
Answer = request.params.Answer;
listing.set("Answer_"+AnsPtr, Answer);
// Increment the current value of the quantity key by 1
listing.increment("AnsPtr");
console.log("save contetnt failure i got ansptr--"+AnsPtr);
}
listing.save(null).then(function(listing) {
// The save was successful.
console.log("I saving");
}, function(error) {
// The save failed. Error is an instance of Parse.Error.
});
}).then(function(){
console.log("I am final succcess");
});
My Expectation:--
"12 new query succcess i got ansptr--"+AnsPtr);
"34--save contetnt failure i got ansptr--"+AnsPtr);
"56--I saving");
"78-I am final succcess");

Actual behavior:
"12 new query succcess i got ansptr--"+AnsPtr);
"34--save contetnt failure i got ansptr--"+AnsPtr);
"78-I am final succcess");
"56--I saving");

Please point me in case i misunderstood promises or missed something..

-Rajender Jindal

NullPointerException when retreiving from Parse Cloud function

I have a problem #159, parse-community/Parse-SDK-Android#159 (comment)
Hasn't been resolved in JS SDK 1.6.7, Android 1.10.3

Android Code

   ParseCloud.callFunctionInBackground("schedule", new HashMap<String, Object>(), new FunctionCallback<List<Object>>() {
        public void done(List<Object> itemList, ParseException e) {
            if (e == null) {
                arraySchedule.addAll(itemList);
            } else {
                Log.d("item", "Error: " + e.getMessage());
            }
        }
    });

and it's work well in JavaScript.

        Parse.Cloud.run('schedule', {}, {
          success: function(results) {
            // TODO
          },
          error: function(error) {
          }
        });

Cloud Code

Parse.Cloud.define("schedule", function(request, response) {

    var ScheduleToday = Parse.Object.extend("LiveScheduleToday");
    var scheduleTodayQuery = new Parse.Query(ScheduleToday);
    scheduleTodayQuery.include("contentId");
    scheduleTodayQuery.include("contentId.VodCategory");

    scheduleTodayQuery.find().then( function(result) {
        response.success(result);
    });
});

Here is the adb log.

could not parse date: {"iso":"2015-10-16T02:33:11.095Z","__type":"Date"}
java.text.ParseException: Unparseable date: "{"iso":"2015-10-16T02:33:11.095Z","__type":"Date"}" (at offset 0)
at java.text.DateFormat.parse(DateFormat.java:555)
at com.parse.ParseDateFormat.parse(ParseDateFormat.java:42)
at com.parse.ParseObject.mergeFromServer(ParseObject.java:990)
at com.parse.ParseObject.fromJSON(ParseObject.java:686)
at com.parse.ParseDecoder.decode(ParseDecoder.java:125)
at com.parse.ParseDecoder.convertJSONArrayToList(ParseDecoder.java:45)
at com.parse.ParseDecoder.decode(ParseDecoder.java:71)
at com.parse.ParseCloudCodeController.convertCloudResponse(ParseCloudCodeController.java:52)
at com.parse.ParseCloudCodeController$1.then(ParseCloudCodeController.java:36)
at bolts.Task$14.run(Task.java:784)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeImmediately(Task.java:775)
at bolts.Task.continueWith(Task.java:574)
at bolts.Task.continueWith(Task.java:585)
at bolts.Task$12.then(Task.java:679)
at bolts.Task$12.then(Task.java:667)
at bolts.Task$15.run(Task.java:825)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeAfterTask(Task.java:816)
at bolts.Task.access$200(Task.java:32)
at bolts.Task$11.then(Task.java:621)
at bolts.Task$11.then(Task.java:618)
at bolts.Task.runContinuations(Task.java:861)
at bolts.Task.access$600(Task.java:32)
at bolts.Task$TaskCompletionSource.trySetResult(Task.java:916)
at bolts.Task$TaskCompletionSource.setResult(Task.java:950)
at bolts.Task$15$1.then(Task.java:842)
at bolts.Task$15$1.then(Task.java:829)
at bolts.Task$14.run(Task.java:784)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeImmediately(Task.java:775)
at bolts.Task.continueWith(Task.java:574)
at bolts.Task.continueWith(Task.java:585)
at bolts.Task$15.run(Task.java:829)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeAfterTask(Task.java:816)
at bolts.Task.access$200(Task.java:32)
at bolts.Task$11.then(Task.java:621)
at bolts.Task$11.then(Task.java:618)
at bolts.Task.runContinuations(Task.java:861)
at bolts.Task.access$600(Task.java:32)
at bolts.Task$TaskCompletionSource.trySetResult(Task.java:916)
at bolts.Task$TaskCompletionSource.setResult(Task.java:950)
at bolts.Task$15$1.then(Task.java:842)
at bolts.Task$15$1.then(Task.java:829)
at bolts.Task$14.run(Task.java:784)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
at bolts.Task.completeImmediately(Task.java:775)
at bolts.Task.continueWith(Task.java:574)
at bolts.Task.continueWith(Task.java:585)
at bolts.Task$15.run(Task.java:829)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

Add browser dist files to npm

It would make life easier when working on projects not using browserify (or similar) if the browser dist files were published to npm.

EDIT: I should have mentioned that I meant when using npm 3 as a front end package manager.

query.select() is ignored with version 1.6.4

In the following code the "query.select" will be ignored with version 1.6.4, but works in version 1.5.0.

var Objekt = Parse.Object.extend("objekt");
var query = new Parse.Query(Objekt);
query.select("title");
query.find({
  success:function(results) {
for (var i = 0; i < results.length; i++) {
      var object = results[i];
      console.log(object.id + ' - ' + object.get('title'));
    }
  }
});

Frequent timeouts, ECONNRESET, and ECONNREFUSED on Node 0.12.7

We receive frequent timeouts, ECONNRESET, and ECONNREFUSED responses to Parse queries, saves, and updates. This is with Parse JS SDK 1.5.0 running on NodeJS 0.12.7, though we have experienced this issue for a while on our databases across various previous versions.

"Received an error with invalid JSON from Parse: Error: connect ETIMEDOUT\n at exports._errnoException (util.js:746:11)\n at TCPConnectWrap.afterConnect as oncomplete"

"Received an error with invalid JSON from Parse: Error: read ECONNRESET\n at exports._errnoException (util.js:746:11)\n at TCP.onread (net.js:559:26)"

"Received an error with invalid JSON from Parse: Error: connect ECONNREFUSED\n at exports._errnoException (util.js:746:11)\n at TCPConnectWrap.afterConnect as oncomplete"

We have no timeout issues with any of our other third party API calls, including logging and various mongodb stores. We've reviewed our maxSockets and other request() calls inside our own Node.JS code. We are normally processing 156 requests per minute, with 450 Parse JS SDK queries and saves per minute. We receive roughly 1 timeout or ECONN* message every 2 minutes.

I'm worried this will just be marked as "not a bug" of the JS SDK specifically, but we are having difficulty getting any feedback or support on these frequent issues through any of the Parse channels.

Bug on Parse.Query, trying to include keys but the server doesn't fetch the information

Hello. I'm mostly Android and iOS developer. I've always created my own backend for Android or iOS, so when I had some tables with pointers and I needed the information, I used to do my query including keys by include(String string) or the iOS version: [PFObject includeKey:NSString* key] and I get my pointers fetched.

Now I'm trying to do another project, which envolves the Javascript SDK on CloudCode and the pointers were not being fetched at the end... for more details, please see my question on StackOverflow: http://stackoverflow.com/questions/33059768/parse-com-javascript-sdk-using-include-but-not-working?noredirect=1#comment54030428_33059768

Changing the file /path/to/parse_project/.parse.project (hidden), I changed the "jssdk" : "latest" for "jssdk" : "1.4.2" so basically I downgraded my version, and it works perfectly now.

So I think it's a bug in the Javascript SDK.

Unable to login using js sdk

I was trying to login a user using following code from the docs:

<script src="http://www.parsecdn.com/js/parse-latest.js"></script>
Parse.User.logIn("myname", "mypass", {
  success: function(user) {
    // Do stuff after successful login.
  },
  error: function(user, error) {
    // The login failed. Check error to see why.
  }
});

The server returned 404 and the response was

{"code":101,"error":"invalid login parameters"}

I also found out that the sample todo app also has this issue.

Is there anything wrong with the login service?

Issues retreiving cached cookie in IE 10 and below

I am getting the following error on IE10 and below when I attempt to retrieve a cashed user object or make any parse query

Object doesn't support property or method 'fromJSON'

the issue seems to be coming from line 832 in ParseUser.js

var current = ParseUser.fromJSON(userData);

Proposal: Deprecate Backbone-style callbacks

For legacy reasons, the SDK currently supports handling asynchronous actions through two separate methods: Backbone-style success/error callbacks, and Promises. We would like to explore the idea of deprecating the callbacks interface in favor of only using Promises, and we would like community input on this decision.

Why deprecate this piece of the SDK?
We believe that the callbacks format is a less-than-optimal approach to structuring asynchronous code. With ES6, Promises are a feature of the JS language, and we want to discourage async formats that allow developers to fall into "callback hell."
From a code perspective, these require internal methods to have a bunch of boilerplate in order to support wrapping controller methods that use Promises. Removing these callbacks would reduce complexity and remove bytes from nearly every publicly-exposed method.

Proposed deprecation path:
In 1.7.0, using Backbone callbacks will log a warning that the format is now deprecated, and will be removed in 1.8. These warning will only be in the non-minified SDK, so they will not affect production.
In 1.8.0, we completely remove callbacks support.

Need Backbone support for latest SDK

I am currently building an backbone app (items added to a table for each Google form submitted for review). I am on parse 1.2.13 JS SDK.

Migrating to 1.6 will obviously mess up my working code since there is no Collection class.

I am somewhat new to web development. Could someone let me know if Backbone support is in the works or if there is a simple workaround?

Thanks!

Relation data not retrieved in subquery

I have the following code

for (var i = 0; i < events.length; i++) {
                  var event = results[i];
                  var relation = event.relation("Artists");

                  var query3 = relation.query();
                  query3.find({
                    success: function(results) {
                      console.log("Successfully retrieved " + results.length + " results.");
                      if(results.length >0)
                      {

                      }
                    },
                    error: function(error) {
                      console.log("Error: " + error.code + " " + error.message);

                    }
                  });
                } // End For Loop

events is returned from the another query, eveything works, but the relation object that is retrieved, is always empty (length 0). I think this is a bug in the code ... I'm using the latest SDK in Node

ParseUser._linkWith call to provider.authenticate need to reject promise on error

At approx. at line 100 in ParseUser.js, these lines

this._linkWith(provider, opts).then(() => {
            promise.resolve(this);
          });

recursively call _linkWith and only handle the smooth sailing case. However, it's still possible for this error to happen { code=208, message="Another user is already linked to this facebook id."}. A promise.reject call is needed to propagate the error message.

How to return array of Parse Objects instead of array of pointers in Cloud Code?

I perform a query and get an array of parse objects. But when I try to return them using response.success(results), they get converted into just pointers. Here is the log just before I call response.success(results):

[{
      "ans1Goals": 1,
      "ans2Goals": 2,
      "ansSpectators": 21400,
      "createdAt": "2015-10-05T11:00:38.447Z",
      "position": 1,
      "updatedAt": "2015-10-27T10:18:55.294Z",
      "objectId": "39QCu6oTBx"
    }]

and this is what I receive from calling response.success(results):

    [{
      "__type": "Pointer",
      "className": "Answers",
      "objectId": "39QCu6oTBx"
    }]

Why is this happening? On the client side, iOS and Android, we need the parse objects, otherwise with the pointers we will have to make another request to fetch the data. I don't want to return JSON because we have subclassed parse objects in iOS and Android and this should happen automatically, just like when we make queries directly from the clients. Having to parse JSON into ParseObjects defeats the purpose of subclassing in the first place. Thanks for any insight!

Parse.User.current() replacement in query

I'm seeing this error when I run my React Native app:

My observe() function:

  observe: function() {
    return {
      user: ParseReact.currentUser,
      current: new Parse.Query('Idea')
        .equalTo('User', Parse.User.current())
        .equalTo('State', Config.IDEA_STATES[Config.CURRENT]),
    };
  },

image

I tried using Parse.User.currentAsync(), but that returns a Promise instead of Parse.Object. How do I filter by current user in my subscription query?

.existed() not working properly in Parse Javascript SDK 1.6.4

In the afterSave of my parse object subclasses, I call .existed() on the request object.

I have had this code for quite a while, but only recently do existing object return false for .existed(). I tried to change the SDK to 1.6.2 and 1.6.0 but still ran into the same issue

using semver

since in the version 1.6.x there were intreduce so many breaking changing it would be appropriate to bump to ver 2.0.0.
those breaking changes can make lots of code breaks for NPM users

edit: also using tags of release in this repository can be very helpful

Parse.User.current() doesn't update local storage.

Parse.User.current() updates on save() in the current session - but if you do a browser refresh (F5/CMD+R) the content is lost. The only way to update it is to force a logOut() and then logIn() again. Parse.user.current().fetch() is supposed to bring the localStorage up to date - but that is not happening.

Let me know if you need any more to reproduce.

matchesQuery API on a Relation gives error code 102

We have added a "joinCommunity" relation to the User object and use the following query.

new Parse.Query("User").matchesQuery("joinCommunity", new Parse.Query("Community").equalTo("objectId", "acMv7RpF1l")).find()

The above gives the following error in SDK v1.6.2:
{code: 102, message: "bad type for $inQuery"}

The SAME query works in v1.5.0.

URL's not available through JS API

I am using the Javascript API to enable users to share an object from the app. This creates a sharable link.

What is failing?

It doesn't receive the "link" column/data (which is a string). All other columns come through fine (such as files, numbers, and other strings).

Is there a trick with Parse and sharing URL's?

My HTML is fine, I"ve pasted my javascript is here http://pastebin.com/wp0n4tNm

Make promises A+ compliant

For consistency with other promise libs I'm using it would be great if Parse promises were A+ compliant.

I see this has been anticipated, per

// We may want to expose this value at a later time, so that Promises/A+ style
// can be employed instead
var isPromisesAPlusCompliant = false;

Would be great if this was the default!

Thanks!

request parameter in beforeSave() doesn't contain any stored values sent from android app

This is my android code :

 ParseObject parseObject = new ParseObject("likes");
                ParseObject parseuser=ParseObject.createWithoutData(ParseUser.class,post.getPosAuthorObjectId());
                ParseObject parsepost=ParseObject.createWithoutData("posts",post.getObjectId());
                parsepost.put("postAuthor",parseuser);
                parseObject.put("ownerId", ParseObject.createWithoutData(ParseUser.class, ParseUser.getCurrentUser().getObjectId()));
                parseObject.put("postId",parsepost);
                parseObject.saveInBackground

**I am trying to send some data regarding the user's id along with the post object so as to save the post object into the "likes" class and do changes in the post owner's attributes using masterkey without fetching the id of the post owner in a separate query as it is already stored in my android code .**In my experimental beforeSave():

Parse.Cloud.beforeSave("likes",function(request,response){
    var posts = Parse.Object.extend("posts");
    var post=new posts();
    var post=request.object.get("postId");
    var user=Parse.Object.extend(Parse.User);
    var user=new Parse.User();
    var  id =post.object.get("postAuthor").id;
    if(id!=null){
        response.success();
    }
    else{
        response.error("The id is null");
    }
 });

Basically I am trying to retrieve the user id saved in the postobject and sent to the request parameter .But the output of my experiment is always null.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.