baqend / js-sdk Goto Github PK
View Code? Open in Web Editor NEWBaqend JavaScript SDK and CLI for High-Performance Websites
Home Page: https://www.baqend.com
License: MIT License
Baqend JavaScript SDK and CLI for High-Performance Websites
Home Page: https://www.baqend.com
License: MIT License
Hey,
as per title. Running
npm install -save baqend
throws a missing peer dependency for [email protected]
-- UNMET PEER DEPENDENCY websocket@^1.0.22
npm WARN [email protected] requires a peer of websocket@^1.0.22 but none was installed.
Running on Windows 10.
λ node -v v6.5.0
λ npm -v 3.10.3
I am trying to start a Facebook oAuth login flow from my expo.io app with the following code:
_PressLearnMore = () => { db.User.loginWithFacebook("xxx").then((user) => { db.User.me == user; }); };
An error raises immediately:
Can't find variable: open
EntityManager.js:976:9
I had to modify some parts of the baqend.js to make it work with Fusetools. The changes were required because Fusetools does not support window.sessionStorage
but it has a shim for window.localStorage
so i just changed the sessionStorage
to localStorage
.
Besides that in different places it tries to access the browser window api but as Fuse doesn't support it I had to change those parts as well. i.e I made the isChrome
variable to False
by default, similarly I changed
if (secure === undefined) { secure = window.location.protocol == 'https:'; }
to
if (secure === undefined) { secure = false; }
and this line: xhr.upload.onprogress = message.progress();
to this xhr.onprogress = message.progress();
These changes made it successfully work on local preview on MacOS and iOS but doesn't work on Android.
I hope together we can find a solution for it.
Thanks
Hey there,
i have a short question:
I play around with baqend and react + react-redux. https://github.com/KillerCodeMonkey/baqend-blog-admin-react/tree/redux
The problem is, that the reducers should not manipulate the state directly. They should return new instances of objects or arrays, so the change-detection works and the views are rendered again.
I have a model called "Post". If an action updates a post like
post.save().then(updatedPost => dispatch(....))
the associated reducers are listening to this, but needs to return the post as a new object.
I tried something like that:
const postJSON = Object.assign({}, action.post.toJSON(), { acl: null })
return db.Post.fromJSON(postJSON)
Sadly i get exact the same reference.
Do you have any ideas?
Hi,
For evaluation purpose I tried to build the application and it showed the following error
Failed to minify the code from this file:
./node_modules/baqend/lib/util/Metadata.js:12
Apparently it doesn't affect the produced application.
Hey,
I just noticed that a file from my static files deployment was missing. I did some digging and stumbled upon this line:
Line 144 in c306294
index += 1
evaluates to the updated value of index, so the first element in files
is always skipped.
I'm sure it could be fixed easily by moving the update expression out of the array index:
const file = files[index];
index += 1
Hey!
I'm updating an old app, and thought I'd try to update the baqend SDK it uses.
After updating from 2.14.1 to 3.1.4, I keep on getting
{
"status": 412,
"message": "Precondition Failed"
}
On seemingly all the queries that use the depth option, for example
import {db as baqend} from 'baqend'
baqend.ActivityCategory
.find()
.equal('id', category)
.singleResult({depth: 1})
I sadly don't have the time to troubleshoot this further now, maybe there's just something weird in our setup.
I'll get back to troubleshooting sometime next week. Do you have any suggestions until then, @fbuecklers? 🤞
Hey there,
i've tried to show an image in my app.
I have a model with an attribute preview_image
of type File and an reference to a file in /file/www/images/...
.
Now i want to show this image in my app using the way provided in your guide.
let file = new db.File(post.preview_image)
But it does not work.
I tried the other approach like:
post.load()
or
db.Post.resultList({ depth: true})
to get all referenced objects without an extra operation.
But with no luck.
How should i do it?
Thanks you!
prerelease
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the prerelease
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
Good luck with your project ✨
Your semantic-release bot 📦🚀
When I try to deploy via CLI I get the message
App not found.
while app name is fully correct. I used the CLI like: baqend deploy -F build app-name
. baqend apps
lists my app correctly and the possibility of typing errors is excluded.
Hey there,
it is me again *narf :).
I played around a little bit deeper and i do not get it why the "depth" option leads to such a mass of additional requests.
e.g. I have blog Posts -> connected to a Set of Comments and Tags.
When i do the following:
db.Post.find().resultList({depth: 1})
There is a request for each comment. What is quite heavy and costs time, bandwidth and requests ;).
I would expect (from a mongodb/mongoose background) that there is one request populate
ing the comments and retrieve them as a list.
I'd like to point out, that the typing for db.File.headers
is a little off. Sure, it's an object
, but this leads to the side-effect that I cannot access any property on it without re-casting it to any
.
Can you change its type to any
?
How to fix this problem: Error: This functionality is only available, if the optional rxjs dependency is also provided ? The error appeared after updating Angular to v14.
Test
Is it possible to modify the schema from the clien (javascript SDK)t? Am I missing functionality already here?
I would like to make changes programmatically. Perhaps this should be guarded with Roles.
I spent some time digging into the documentation but didn't find anything suggesting that this could be done, but I very well may be overlooking.
When auto-generating typescript typing via baqend typings my-app
, the typing for Files are incorrect.
F.e.
interface Notification extends binding.Entity {
date: Date;
image: undefined;
}
the image is undefined although it's a File.
it should look like this
interface Notification extends binding.Entity {
date: Date;
image: binding.File;
}
Same goes for typings with File in a List Array<undefined>
-> Array<binding.File>
.
A note: afaik Array typings are supossed to be written in the synatax binding.File[]
and not Array<binding.File>.
hey there,
i recognized that if i try to save text of an textarea with newlines, the line breaks are gone after i save the entry.
I want to store markdown in a next step of my blog application and without linebreaks this would be difficult.
Is this known or unwanted or is there something like special type for that purpose?
Thanks in advance.
Heyho,
i am playing around with baqend + angular 2 and i am at a point, where i want to test a service, that is using baqend.
So how can i easily mock/stub the db object?
I'm using Baqend with next.js which leads to the problem that my code is run server side and client side which makes connecting to Baqend a bit of a problem because I don't have one single point in my applications lifecycle where I can connect.
My solution was this piece of code
BaqendApi.connect = function() {
return new Promise((resolve, reject) => {
if (DB.User) {
resolve();
} else {
DB.ready(resolve);
if (!BaqendApi.connecting) {
BaqendApi.connecting = true;
BaqendApi.connected = true;
console.log("Connecting to Baqend");
DB.connect(Config.baqendApp);
}
}
});
};
As you can see this function returns a promise that resolves once Baqend is connected (mostly immediately).
While I was developing I forgot to call this function before doing some Baqend stuff and I could still load objects from Baqend but not update them.
DB.Page.load("/db/Page/d42c5a70-d301-41ab-bb8e-9fc47def0d4e").then(response => {
response.route = "/test";
response.save().then(r => {
console.log(r);
})
});
This code would print the correctly updated object on the console but there was only one GET request being made. No update or save request was sent to Baqend.
let thing = new DB.Thing({type: "Test", data: data});
return thing.insert();
This code however would correctly insert the object. My ACL was set to public on everything so that was not the cause.
I'm sure this has something to do with the whole server side connection, client side connection, hot reload jimbo jambo that is going on on my end but it would still be nice to get an error of some kind if I call update and there isn't even a request being send.
Using baqend 2.13.0 in angular 7 project.
There is a compile time error after using resultStream() instead of resultList().
Error:
Type 'import("/home/harishm/xxx/node_modules/baqend/node_modules/rxjs/Observable").Observable<any>' is not assignable to type 'import("/home/harishm/xxx/node_modules/rxjs/internal/Observable").Observable<any>'.
Property 'operator' is protected in type 'Observable<any>' but public in type 'Observable<any>'. [2322]
rxjs/internal/Observable is conflicting with /rxjs/Observable
Hello,
I have a Joomla Site with Speed Kit for Plesk.
Before activating Speed Kit for the domain Speed Kit predicted a speed increase that would result in a loading time of around 500ms.
After activating Speed Kit the result is just a faktor of 1.1 to 1.8 depending whether I turn of a separate css and js acceleration plugin and the gzip compression within Joomla.
The page loading time is not near 500ms it's around 4 to 6 seconds.
Info: Newest Joomla version, PHP 7.3, around 25 elements to load with the Joomla compression plugin active and around 50 with it deactivated, page size around 2.5 MB.
Is there something I should check or configure to improve the result? Or is the acceleration generally not working so well with Joomla?
Thanks for your help.
On Android only, when I create a new project in Expo and then install baqend like this:
npm install baqend --save
Then use it in the project by importing it:
import { db } from 'baqend';
The android emulator (and my phone) starts throwing errors.
At first I thought maybe it was one of the other libraries I'm using, but in order to track this down, I started a brand new project in Expo, then started added packages one at a time.
Here's the package.json:
{
"name": "my-new-project",
"main": "node_modules/expo/AppEntry.js",
"private": true,
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/samples": "2.1.1",
"baqend": "2.8.5",
"expo": "29.0.0",
"react": "16.3.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",
"react-navigation": "^2.9.3"
},
"devDependencies": {
"jest-expo": "29.0.0"
}
}
Now you will notice that in the above I'm using 2.8.5. I tested several releases while troubleshooting and found that 2.8.5 and lower produces one error. The more recent releases produce a different error.
2.8.5 version procudes this errror (on the packager):
/Documents/my-new-project/node_modules/baqend/dist/baqend.js: Unknown plugin "transform-proto-to-assign" specified in "/Users/chris/Documents/my-new-project/node_modules/baqend/.babelrc" at 0, attempted to resolve relative to "/Users/chris/Documents/my-new-project/node_modules/baqend"
And this error on the Android emulator (Android 7):
The development server returned response error code: 500
URL: http://localhost:19003/node_modules/expo/AppEntry.bundle?platform=android&dev=true&minify=false&hot=false&assetPlugin=%2FUsers%2Fchris%2FDocuments%2Fmy-new-project%2Fnode_modules%2Fexpo%2Ftools%2FhashAssetFiles
Body:
{"type":"TransformError","lineNumber":0,"errors":[{"description":"/Users/chris/Documents/my-new-project/node_modules/baqend/dist/baqend.js: Unknown plugin \"transform-proto-to-assign\" specified in \"/Users/chris/Documents/my-new-project/node_modules/baqend/.babelrc\" at 0, attempted to resolve relative to \"/Users/chris/Documents/my-new-project/node_modules/baqend\"","lineNumber":0}],"name":"SyntaxError","message":"/Users/chris/Documents/my-new-project/node_modules/baqend/dist/baqend.js: Unknown plugin \"transform-proto-to-assign\" specified in \"/Users/chris/Documents/my-new-project/node_modules/baqend/.babelrc\" at 0, attempted to resolve relative to \"/Users/chris/Documents/my-new-project/node_modules/baqend\"","stack":"ReferenceError: Unknown plugin \"transform-proto-to-assign\" specified in \"/Users/chris/Documents/my-new-project/node_modules/baqend/.babelrc\" at 0, attempted to resolve relative to \"/Users/chris/Documents/my-new-project/node_modules/baqend\"\n at /Users/chris/Documents/my-new-project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17\n at Array.map (native)\n at Function.normalisePlugins (/Users/chris/Documents/my-new-project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)\n at OptionManager.mergeOptions (/Users/chris/Documents/my-new-project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)\n at OptionManager.init (/Users/chris/Documents/my-new-project/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)\n at File.initOptions (/Users/chris/Documents/my-new-project/node_modules/babel-core/lib/transformation/file/index.js:212:65)\n at new File (/Users/chris/Documents/my-new-project/node_modules/babel-core/lib/transformation/file/index.js:135:24)\n at Pipeline.transform (/Users/chris/Documents/my-new-project/node_modules/babel-core/lib/transformation/pipeline.js:46:16)\n at Object.transform (/Users/chris/Documents/my-new-project/node_modules/metro/src/transformer.js:135:5)"}
processBundleResult
BundleDownloader.java:268
access$200
BundleDownloader.java:35
onChunkComplete
BundleDownloader.java:195
emitChunk
MultipartStreamReader.java:76
readAllParts
MultipartStreamReader.java:154
processMultipartResponse
BundleDownloader.java:179
access$100
BundleDownloader.java:35
onResponse
BundleDownloader.java:148
execute
RealCall.java:135
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1162
run
ThreadPoolExecutor.java:636
run
Thread.java:764
Now, when I use any version greater than 2.8.5 I get a different error.
Here is the error using 2.12.3 (in this case its the error is only on the phone, no errors in the packager):
is not iterable!
exports
_for-of.js:14:51
<unknown>
_collection.js:61:41
Set
es6.set.js:8:37
<unknown>
Asset.js:21:30
loadModuleImplementation
require.js:214:12
guardedLoadModule
require.js:141:45
_require
require.js:132:20
Asset
index.js:3:11
Asset
Expo.js:62:33
_callee$
App.js:32:6
tryCatch
runtime.js:62:44
invoke
runtime.js:296:30
<unknown>
runtime.js:114:28
tryCatch
runtime.js:62:44
invoke
runtime.js:152:28
<unknown>
runtime.js:195:17
tryCallTwo
core.js:45:7
doResolve
core.js:200:23
Promise
core.js:66:12
callInvokeWithMethodAndArg
runtime.js:194:27
enqueue
runtime.js:217:12
<unknown>
runtime.js:114:28
async
runtime.js:241:8
_callee
App.js:30:24
_callee$
AppLoading.js:48:12
tryCatch
runtime.js:62:44
invoke
runtime.js:296:30
<unknown>
runtime.js:114:28
tryCatch
runtime.js:62:44
invoke
runtime.js:152:28
<unknown>
runtime.js:195:17
tryCallTwo
core.js:45:7
doResolve
core.js:200:23
Promise
core.js:66:12
callInvokeWithMethodAndArg
runtime.js:194:27
enqueue
runtime.js:217:12
<unknown>
runtime.js:114:28
async
runtime.js:241:8
_callee
AppLoading.js:42:35
componentDidMount
AppLoading.js:31:6
proxiedComponentDidMount
createPrototypeProxy.js:61:45
commitLifeCycles
ReactNativeRenderer-dev.js:10627:12
commitAllLifeCycles
ReactNativeRenderer-dev.js:12512:10
invokeGuardedCallback
ReactNativeRenderer-dev.js:39:15
invokeGuardedCallback
ReactNativeRenderer-dev.js:221:34
commitRoot
ReactNativeRenderer-dev.js:12677:10
completeRoot
ReactNativeRenderer-dev.js:13685:46
performWorkOnRoot
ReactNativeRenderer-dev.js:13635:23
performWork
ReactNativeRenderer-dev.js:13545:26
performSyncWork
ReactNativeRenderer-dev.js:13506:16
requestWork
ReactNativeRenderer-dev.js:13392:6
scheduleWorkImpl
ReactNativeRenderer-dev.js:13259:24
scheduleWork
ReactNativeRenderer-dev.js:13207:28
scheduleRootUpdate
ReactNativeRenderer-dev.js:13930:17
_updateContainerAtExpirationTime
ReactNativeRenderer-dev.js:13966:6
updateContainer
ReactNativeRenderer-dev.js:13991:8
render
ReactNativeRenderer-dev.js:14726:35
renderApplication
renderApplication.js:49:21
run
AppRegistry.js:102:10
runApplication
AppRegistry.js:194:26
__callFunction
MessageQueue.js:351:47
<unknown>
MessageQueue.js:116:26
__guardSafe
MessageQueue.js:314:6
callFunctionReturnFlushedQueue
MessageQueue.js:115:17
What would be awesome is for the latest version of the sdk to work on the latest version of expo.
To replicate:
In expo, create "my new project" use Tabbed Navigation preset.
Open it up on your android phone over wifi or use the android emulator. It works fine.
Now go to the newly created my-new-project folder and run npm install baqend --save
this installs 2.12.3.
Then open up /screens/HomeScreen.js and add import { db } from 'baqend' to the top
Save it. Restart packager. Re-open project on your phone or emulator. Error happens as app starts.
Please let me know if I can help fix this. I'm not a really a developer but I'll do what I can.
Hi,
I tried to build ti.Module by titaniumifier and cloned this branch to my machine.
In the root I started:
titaniumifier --out dist
and got:
/usr/local/lib/node_modules/titaniumifier/node_modules/bluebird/js/main/promise.js:677
throw e;
^
Error: Cannot find module 'jahcode' from '/Users/fuerst/Documents/APPC_WORKSPACE/TiBaqend/lib'
Its right there is no jahcode in the repo. How can I fix it?
Please visit this issue for clarification:
mobxjs/mobx#1468
the main problem is that mobx observables won't react to changes on the Proxy-properties returned by baqend. the author of mobx claims that this cannot be an issue with mobx itself but the implementation of the proxy. somehow it is not possible to make them observable.
my workaround for this is to create an object-literal from to proxy-data with .toJSON()
and re-create the Proxy later when saving, deleting etc. via .fromJSON()
. This kind of works but is not free of implications when handling Dates or Files.
See my workaround:
function createViewModel<T>(
Class: binding.EntityFactory<any>,
item: binding.Entity,
type?: misc.Type,
refViewModel?: misc.ViewModel
): T {
const viewModel: T & misc.ViewModel<T> = item.toJSON({
depth: true
}) as any;
// convert all date-values and images
[...Object.keys(Class.prototype), 'key'].forEach(key =>
preserveItemValues(item, key, viewModel)
);
viewModel.restore = async function() {
// `fromJSON` doesn't consider Dates
// specify which dates will be formated
const keepValues = Object.entries(this).reduce(
(memo, [key, value]) => {
if (value instanceof Date) {
return [...memo, { key, value }];
}
return memo;
},
[] as { key: string; value: any }[]
);
const item = Class.fromJSON(this);
// assign values to be kept
keepValues.forEach(({ key, value }) => (item[key] = value));
// sync changes back to ref-viewModel
if (refViewModel) {
Object.keys(Class.prototype).forEach(key => {
refViewModel[key] = this[key];
});
}
return item;
};
viewModel.ref = item;
viewModel.type = type;
viewModel.isViewmodel = true;
return viewModel;
}
I would love to see real support for mobx observables in the future :)
Hi,
Are you planing to implement a load for all users?
Thanks.
Hey, i just went through the toodle
example on your website and then wanted to try the realtime queries … adjusted it to to use baquend/realtime
+ resultStream
but im getting this error in Chrome 70:
WebSocket connection to 'wss://toodle.app.baqend.com/v1/events' failed: Error during WebSocket handshake: Unexpected response code: 404
at baqend-realtime.js:19644
Are the realtime features not supported by this example (and community edition)?
If you use a SSR framework like Next.js or Nuxt.js you can't use the Baqend JS SDK properly. Serialization and therefore correct client side hydration is not possible. This has to do with non-POJOs that can't be serialized on the server.
Because of that the framework triggers another call (client-side) on first render to Baqend to fetch the same data.
tl;dr: I don't know if this will ever be possible because the serialization can't handle functions or non-POJOs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.