@based/client 3.2.2 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -330
- package/dist/Emitter.d.ts +7 -6
- package/dist/Emitter.js +31 -6
- package/dist/Emitter.js.map +1 -1
- package/dist/authState/parseAuthState.d.ts +3 -0
- package/dist/authState/parseAuthState.js +51 -0
- package/dist/authState/parseAuthState.js.map +1 -0
- package/dist/authState/updateAuthState.d.ts +3 -0
- package/dist/authState/updateAuthState.js +15 -0
- package/dist/authState/updateAuthState.js.map +1 -0
- package/dist/channel/cleanUp.d.ts +2 -0
- package/dist/channel/cleanUp.js +32 -0
- package/dist/channel/cleanUp.js.map +1 -0
- package/dist/channel/index.d.ts +12 -0
- package/dist/channel/index.js +67 -0
- package/dist/channel/index.js.map +1 -0
- package/dist/genObserveId.d.ts +1 -0
- package/dist/genObserveId.js +12 -0
- package/dist/genObserveId.js.map +1 -0
- package/dist/getTargetInfo.d.ts +6 -0
- package/dist/getTargetInfo.js +14 -0
- package/dist/getTargetInfo.js.map +1 -0
- package/dist/getUrlFromOpts.d.ts +3 -0
- package/dist/getUrlFromOpts.js +24 -0
- package/dist/getUrlFromOpts.js.map +1 -0
- package/dist/incoming/debug.d.ts +9 -0
- package/dist/incoming/debug.js +132 -0
- package/dist/incoming/debug.js.map +1 -0
- package/dist/incoming/index.d.ts +2 -0
- package/dist/incoming/index.js +341 -0
- package/dist/incoming/index.js.map +1 -0
- package/dist/incoming/protocol.d.ts +9 -0
- package/dist/incoming/protocol.js +62 -0
- package/dist/incoming/protocol.js.map +1 -0
- package/dist/index.d.ts +69 -127
- package/dist/index.js +224 -15
- package/dist/index.js.map +1 -1
- package/dist/outgoing/debug.d.ts +8 -0
- package/dist/outgoing/debug.js +70 -0
- package/dist/outgoing/debug.js.map +1 -0
- package/dist/outgoing/index.d.ts +14 -0
- package/dist/outgoing/index.js +227 -0
- package/dist/outgoing/index.js.map +1 -0
- package/dist/outgoing/protocol.d.ts +24 -0
- package/dist/outgoing/protocol.js +200 -0
- package/dist/outgoing/protocol.js.map +1 -0
- package/dist/persistentStorage/browser.d.ts +5 -0
- package/dist/persistentStorage/browser.js +150 -0
- package/dist/persistentStorage/browser.js.map +1 -0
- package/dist/persistentStorage/index.d.ts +6 -0
- package/dist/persistentStorage/index.js +56 -0
- package/dist/persistentStorage/index.js.map +1 -0
- package/dist/persistentStorage/node.d.ts +6 -0
- package/dist/persistentStorage/node.js +104 -0
- package/dist/persistentStorage/node.js.map +1 -0
- package/dist/query/index.d.ts +17 -0
- package/dist/query/index.js +112 -0
- package/dist/query/index.js.map +1 -0
- package/dist/stream/fetch.d.ts +4 -0
- package/dist/stream/fetch.js +42 -0
- package/dist/stream/fetch.js.map +1 -0
- package/dist/stream/index.d.ts +4 -0
- package/dist/stream/index.js +65 -0
- package/dist/stream/index.js.map +1 -0
- package/dist/stream/nodeStream.d.ts +7 -0
- package/dist/stream/nodeStream.js +117 -0
- package/dist/stream/nodeStream.js.map +1 -0
- package/dist/stream/types.d.ts +37 -0
- package/dist/stream/types.js +8 -0
- package/dist/stream/types.js.map +1 -0
- package/dist/stream/uploadFileBrowser.d.ts +4 -0
- package/dist/stream/uploadFileBrowser.js +113 -0
- package/dist/stream/uploadFileBrowser.js.map +1 -0
- package/dist/types/auth.d.ts +11 -0
- package/dist/{selvaTypes/get.js → types/auth.js} +1 -1
- package/dist/types/auth.js.map +1 -0
- package/dist/types/cache.d.ts +6 -0
- package/dist/{selvaTypes/set.js → types/cache.js} +1 -1
- package/dist/types/cache.js.map +1 -0
- package/dist/types/channel.d.ts +25 -0
- package/dist/types/channel.js +3 -0
- package/dist/types/channel.js.map +1 -0
- package/dist/types/error.d.ts +36 -0
- package/dist/types/error.js +40 -0
- package/dist/types/error.js.map +1 -0
- package/dist/types/events.d.ts +34 -0
- package/dist/{selvaTypes/schema.js → types/events.js} +1 -1
- package/dist/types/events.js.map +1 -0
- package/dist/types/functions.d.ts +8 -0
- package/dist/types/functions.js +3 -0
- package/dist/types/functions.js.map +1 -0
- package/dist/types/generic.d.ts +20 -0
- package/dist/types/generic.js +3 -0
- package/dist/types/generic.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/{subscriptions → types}/index.js +6 -10
- package/dist/types/index.js.map +1 -0
- package/dist/types/observe.d.ts +46 -0
- package/dist/types/observe.js +3 -0
- package/dist/types/observe.js.map +1 -0
- package/dist/websocket/index.d.ts +1 -1
- package/dist/websocket/index.js +14 -5
- package/dist/websocket/index.js.map +1 -1
- package/package.json +17 -27
- package/dist/Client.d.ts +0 -80
- package/dist/Client.js +0 -271
- package/dist/Client.js.map +0 -1
- package/dist/auth.d.ts +0 -13
- package/dist/auth.js +0 -87
- package/dist/auth.js.map +0 -1
- package/dist/createError.d.ts +0 -3
- package/dist/createError.js +0 -67
- package/dist/createError.js.map +0 -1
- package/dist/debug.d.ts +0 -2
- package/dist/debug.js +0 -21
- package/dist/debug.js.map +0 -1
- package/dist/file/fetch.d.ts +0 -6
- package/dist/file/fetch.js +0 -27
- package/dist/file/fetch.js.map +0 -1
- package/dist/file/getUrl.d.ts +0 -4
- package/dist/file/getUrl.js +0 -42
- package/dist/file/getUrl.js.map +0 -1
- package/dist/file/index.d.ts +0 -6
- package/dist/file/index.js +0 -95
- package/dist/file/index.js.map +0 -1
- package/dist/file/stream/browser.d.ts +0 -7
- package/dist/file/stream/browser.js +0 -17
- package/dist/file/stream/browser.js.map +0 -1
- package/dist/file/stream/index.d.ts +0 -7
- package/dist/file/stream/index.js +0 -86
- package/dist/file/stream/index.js.map +0 -1
- package/dist/file/uploadFileBrowser.d.ts +0 -3
- package/dist/file/uploadFileBrowser.js +0 -72
- package/dist/file/uploadFileBrowser.js.map +0 -1
- package/dist/findPrefix.d.ts +0 -3
- package/dist/findPrefix.js +0 -20
- package/dist/findPrefix.js.map +0 -1
- package/dist/idleTimeout.d.ts +0 -3
- package/dist/idleTimeout.js +0 -17
- package/dist/idleTimeout.js.map +0 -1
- package/dist/observable/index.d.ts +0 -28
- package/dist/observable/index.js +0 -84
- package/dist/observable/index.js.map +0 -1
- package/dist/printBasedObject.d.ts +0 -4
- package/dist/printBasedObject.js +0 -76
- package/dist/printBasedObject.js.map +0 -1
- package/dist/queue.d.ts +0 -5
- package/dist/queue.js +0 -53
- package/dist/queue.js.map +0 -1
- package/dist/request.d.ts +0 -6
- package/dist/request.js +0 -67
- package/dist/request.js.map +0 -1
- package/dist/selvaTypes/get.d.ts +0 -97
- package/dist/selvaTypes/get.js.map +0 -1
- package/dist/selvaTypes/schema.d.ts +0 -89
- package/dist/selvaTypes/schema.js.map +0 -1
- package/dist/selvaTypes/set.d.ts +0 -73
- package/dist/selvaTypes/set.js.map +0 -1
- package/dist/subscriptions/addGetSubscriber.d.ts +0 -3
- package/dist/subscriptions/addGetSubscriber.js +0 -87
- package/dist/subscriptions/addGetSubscriber.js.map +0 -1
- package/dist/subscriptions/addSubscriber.d.ts +0 -2
- package/dist/subscriptions/addSubscriber.js +0 -136
- package/dist/subscriptions/addSubscriber.js.map +0 -1
- package/dist/subscriptions/generateId.d.ts +0 -1
- package/dist/subscriptions/generateId.js +0 -11
- package/dist/subscriptions/generateId.js.map +0 -1
- package/dist/subscriptions/incomingSubscription.d.ts +0 -3
- package/dist/subscriptions/incomingSubscription.js +0 -87
- package/dist/subscriptions/incomingSubscription.js.map +0 -1
- package/dist/subscriptions/incomingSubscriptionDiff.d.ts +0 -3
- package/dist/subscriptions/incomingSubscriptionDiff.js +0 -85
- package/dist/subscriptions/incomingSubscriptionDiff.js.map +0 -1
- package/dist/subscriptions/index.d.ts +0 -10
- package/dist/subscriptions/index.js.map +0 -1
- package/dist/subscriptions/logoutSubscriptions.d.ts +0 -3
- package/dist/subscriptions/logoutSubscriptions.js +0 -36
- package/dist/subscriptions/logoutSubscriptions.js.map +0 -1
- package/dist/subscriptions/removeSendSubscriptionDataFromQueue.d.ts +0 -2
- package/dist/subscriptions/removeSendSubscriptionDataFromQueue.js +0 -14
- package/dist/subscriptions/removeSendSubscriptionDataFromQueue.js.map +0 -1
- package/dist/subscriptions/removeSubscriber.d.ts +0 -2
- package/dist/subscriptions/removeSubscriber.js +0 -44
- package/dist/subscriptions/removeSubscriber.js.map +0 -1
- package/dist/subscriptions/removeUnsubscribesFromQueue.d.ts +0 -2
- package/dist/subscriptions/removeUnsubscribesFromQueue.js +0 -14
- package/dist/subscriptions/removeUnsubscribesFromQueue.js.map +0 -1
- package/dist/subscriptions/sendAllSubscriptions.d.ts +0 -2
- package/dist/subscriptions/sendAllSubscriptions.js +0 -114
- package/dist/subscriptions/sendAllSubscriptions.js.map +0 -1
- package/dist/token.d.ts +0 -4
- package/dist/token.js +0 -35
- package/dist/token.js.map +0 -1
- package/dist/track.d.ts +0 -8
- package/dist/track.js +0 -71
- package/dist/track.js.map +0 -1
- package/docs/auth-based-ui-howto.md +0 -74
- package/docs/auth-howto.md +0 -166
- package/docs/auth.md +0 -93
- package/docs/authorize.md +0 -56
- package/docs/files.md +0 -66
- package/docs/get-started.md +0 -60
- package/docs/get.md +0 -759
- package/docs/schema.md +0 -244
- package/docs/set.md +0 -652
package/docs/files.md
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
## Files
|
|
2
|
-
|
|
3
|
-
Based provides a way to upload and serve user content without hassle using the `client.file()` API.
|
|
4
|
-
Assets uploaded through this tool are then served through a global CDN network, which allows for caching and fast content-delivery.
|
|
5
|
-
|
|
6
|
-
An additional optimization step is executed when the user uploads a video or an image.
|
|
7
|
-
Images are optimized and compressed, and served through an image specific CDN, while videos get transcoded to multiple resolutions, in HLS format.
|
|
8
|
-
|
|
9
|
-
### Introduction
|
|
10
|
-
|
|
11
|
-
Files can be uploaded using the Based client, which in addition to uploading the file, also sets a node of type `file` on the database, which can then be queried and referenced, like you would for any other node.
|
|
12
|
-
|
|
13
|
-
This default type has several fields describing the file, including it's size, mime-type, timestamps for creation and update, progress status, and more. A crucial field is `src`, which contains a link that points to the file (through the appropriate CDN).
|
|
14
|
-
|
|
15
|
-
> :exclamation: Video files will take longer to become available due to the transcoding process.
|
|
16
|
-
|
|
17
|
-
### Usage
|
|
18
|
-
|
|
19
|
-
#### Upload
|
|
20
|
-
|
|
21
|
-
`client.file()` returns a promise that resolves with the new node's ID.
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
import based from '@based/client'
|
|
25
|
-
const client = based({
|
|
26
|
-
org: 'saulx',
|
|
27
|
-
project: 'test',
|
|
28
|
-
env: 'production',
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
const fileId = await client.file({
|
|
32
|
-
contents: 'This is a string I want to store as plain text!',
|
|
33
|
-
mimeType: 'text/plain',
|
|
34
|
-
name: 'my-file-name',
|
|
35
|
-
})
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
The upload progress of the file can then be tracked by _observing_ the `progress` field of the resulting node.
|
|
39
|
-
|
|
40
|
-
#### Accessing the file
|
|
41
|
-
|
|
42
|
-
The file can be accessed by querying the database.
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
const data = await client.get({
|
|
46
|
-
$id: fileId,
|
|
47
|
-
$all: true,
|
|
48
|
-
})
|
|
49
|
-
/*
|
|
50
|
-
data = {
|
|
51
|
-
id: "fi6a535226",
|
|
52
|
-
name: "eb3f67a3bc65325bf739ebddd94403e5(1).png",
|
|
53
|
-
mimeType: "image/png",
|
|
54
|
-
version: "eb3f67a3bc65325bf739ebddd94403e5",
|
|
55
|
-
origin: "https://based-env-files-do-usproduction-enb-xz-apz--orn-t-v-...98446afcb87d.png",
|
|
56
|
-
src: "https://based-2129034536588.imgix.net/fi6a535226/84e62df3-75...98446afcb87d.png",
|
|
57
|
-
progress: 1,
|
|
58
|
-
size: 61901,
|
|
59
|
-
type: "file",
|
|
60
|
-
createdAt: 1650360875043,
|
|
61
|
-
updatedAt: 1650360882865,
|
|
62
|
-
}
|
|
63
|
-
*/
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
When using this API, one should always link to the file using the `src` field, since it's the one using the CDN. Pointing to the `origin` would lead to significantly higher data costs.
|
package/docs/get-started.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<a href="javascript:void(0);" style="pointer-events: none;">
|
|
3
|
-
<img src="../../../.docs/assets/based-logo-black.svg#gh-light-mode-only" style="width: 350px; padding-bottom: 10px;" />
|
|
4
|
-
<img src="../../../.docs/assets/based.svg#gh-dark-mode-only" style="width: 350px; padding-bottom: 10px;" />
|
|
5
|
-
|
|
6
|
-
</a>
|
|
7
|
-
</div>
|
|
8
|
-
|
|
9
|
-
# Getting started
|
|
10
|
-
|
|
11
|
-
The first step in getting started with using Based is creating a new project. To do so, after logging in, click the `+ New Project` button and type in a new project name.
|
|
12
|
-
Each project can have multiple environments (e.g. development and production).
|
|
13
|
-
|
|
14
|
-
Go to the based [dashboard](https://based-website.vercel.app/dashboard)
|
|
15
|
-
|
|
16
|
-
<!-- create-new-project video -->
|
|
17
|
-
|
|
18
|
-
https://user-images.githubusercontent.com/16743760/164229679-0555beb5-4c56-4843-8fc6-266fa7f15ee4.mov
|
|
19
|
-
|
|
20
|
-
In order to start adding data to the project, a **schema** is needed. The schema defines your data types, for examples the users of a chat app. To add a new type, click the `+ Create a new type` button.
|
|
21
|
-
Each type can have any number of fields that describe it, for example a user's email. These can be added in the schema editor using the `+ Add Type` button.
|
|
22
|
-
|
|
23
|
-
<!-- add-user-type-to-schema video-->
|
|
24
|
-
|
|
25
|
-
https://user-images.githubusercontent.com/16743760/164229696-83de5222-2d8c-4778-8769-a0c3eea1f239.mov
|
|
26
|
-
|
|
27
|
-
Next, it's time to add some content! This can be done through the Dashboard using the built-in content editor.
|
|
28
|
-
|
|
29
|
-
<!-- add-content video -->
|
|
30
|
-
|
|
31
|
-
https://user-images.githubusercontent.com/16743760/164229707-bc9652a2-0823-44b7-825d-1efdcc080ce6.mov
|
|
32
|
-
|
|
33
|
-
Once the environment is up and running, it is time to jump into the code side of things.
|
|
34
|
-
|
|
35
|
-
```js
|
|
36
|
-
import based from '@based/client'
|
|
37
|
-
|
|
38
|
-
const client = based({
|
|
39
|
-
org: 'my-org',
|
|
40
|
-
project: 'chat',
|
|
41
|
-
env: 'production',
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
// observe some data
|
|
45
|
-
await client.observe(
|
|
46
|
-
{ $id: 'root', children: { $all: true, $list: true } },
|
|
47
|
-
(data) => {
|
|
48
|
-
console.log(data)
|
|
49
|
-
}
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
// set data
|
|
53
|
-
await client.set({
|
|
54
|
-
type: 'user',
|
|
55
|
-
email: 'francesco@example.com',
|
|
56
|
-
favoriteThing: 'pizza',
|
|
57
|
-
})
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
> [Click here to read more about the Javascript Based SDK](../README.md)
|