@seedprotocol/sdk 0.1.60 → 0.1.61
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 +66 -45
- package/dist/{index-4a6qGsTX.js → index-BBcjMsIh.js} +5 -4
- package/dist/{index-4a6qGsTX.js.map → index-BBcjMsIh.js.map} +1 -1
- package/dist/{index-BE0vEP7p.js → index-tV-MoWhc.js} +2 -2
- package/dist/index-tV-MoWhc.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-CFOCE176.js → seed.schema.config-BkdBBwUC.js} +2 -2
- package/dist/{seed.schema.config-CFOCE176.js.map → seed.schema.config-BkdBBwUC.js.map} +1 -1
- package/dist/src/item.ts +1 -0
- package/dist/types/src/browser/react/item.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-BE0vEP7p.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Seed Protocol SDK
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
informed
|
|
5
|
-
and generating feedback.
|
|
3
|
+
The official SDK for [Seed Protocol](https://seedprotocol.io/).
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
The SDK is a heavily opinionated ORM that saves its database (SQLite) and files (OPFS) within the user's browser. All
|
|
6
|
+
user data
|
|
7
|
+
is fetched from, or written to, the Ethereum Attestation Service (EAS) and Arweave (More attestation services
|
|
8
|
+
and decentralized storage providers will be supported in the future).
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
- Track this research here: [TypeORM Sqlite Wasm](https://github.com/JournoDAO/typeorm-sqlite-wasm)
|
|
11
|
-
- What would the tooling look like to allow export of data model as ProtoBuf and/or JSON Schema?
|
|
12
|
-
- Looking at [ts-proto](https://github.com/stephenh/ts-proto) for Typescript
|
|
10
|
+
With all the remote storage on decentralized, public infrastructure, there's no server component to manage or rely on.
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
The hope is that this local-first and distributed approach will make it easier for developers to build apps with Seed
|
|
13
|
+
Protocol
|
|
14
|
+
without ever custodying user data on their own infrastructure.
|
|
15
|
+
|
|
16
|
+
The SDK is currently used and developed by [PermaPress](https://permapress.xyz), the first client for Seed Protocol.
|
|
17
|
+
PermaPress is a product developed by JournoLabs (formerly JournoDAO).
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
## Installing
|
|
17
20
|
|
|
18
21
|
```bash
|
|
19
22
|
yarn add @seedprotocol/sdk
|
|
@@ -21,47 +24,65 @@ yarn add @seedprotocol/sdk
|
|
|
21
24
|
|
|
22
25
|
## Getting Started
|
|
23
26
|
|
|
24
|
-
The first thing to do when integrating Seed SDK is define
|
|
27
|
+
The first thing to do when integrating Seed SDK is define your data model by placing a `schema.ts` file in the root
|
|
28
|
+
of your project.
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
our `Models`, their `Properties`, and what type of data each `Property` is expecting.
|
|
30
|
+
As an example, here's the actual data model for PermaPress:
|
|
28
31
|
|
|
29
32
|
```typescript=
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
33
|
+
import { ImageSrc, List, Model, Relation, Text } from '@/browser/schema'
|
|
34
|
+
|
|
35
|
+
@Model
|
|
36
|
+
class Image {
|
|
37
|
+
@Text() storageTransactionId!: string
|
|
38
|
+
@Text() uri!: string
|
|
39
|
+
@Text() alt!: string
|
|
40
|
+
@ImageSrc() src!: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Model
|
|
44
|
+
class Post {
|
|
45
|
+
@Text() title!: string
|
|
46
|
+
@Text() summary!: string
|
|
47
|
+
@Relation('Image', 'ImageSrc') featureImage!: string
|
|
48
|
+
@Text('ItemStorage', '/html', '.html') html!: string
|
|
49
|
+
@Text('ItemStorage', '/json', '.json') json!: string
|
|
50
|
+
@Text() storageTransactionId!: string
|
|
51
|
+
@List('Identity') authors!: string[]
|
|
52
|
+
@Text() importUrl!: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Model
|
|
56
|
+
class Identity {
|
|
57
|
+
@Text() name!: string
|
|
58
|
+
@Text() profile!: string
|
|
59
|
+
@Text() displayName!: string
|
|
60
|
+
@Relation('Image', 'ImageSrc') avatarImage!: string
|
|
61
|
+
@Relation('Image', 'ImageSrc') coverImage!: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Model
|
|
65
|
+
class Link {
|
|
66
|
+
@Text() url!: string
|
|
67
|
+
@Text() text!: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const models = {
|
|
60
71
|
Identity,
|
|
61
72
|
Image,
|
|
62
73
|
Link,
|
|
63
74
|
Post,
|
|
64
|
-
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const endpoints = {
|
|
78
|
+
filePaths: '/api/seed/migrations',
|
|
79
|
+
files: '/app-files',
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { models, endpoints }
|
|
83
|
+
|
|
84
|
+
export default { models, endpoints }
|
|
85
|
+
|
|
65
86
|
```
|
|
66
87
|
|
|
67
88
|
This will create a database locally in the browser with all the tables and fields necessary to support your Models. Feel
|
|
@@ -989,7 +989,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
989
989
|
if (propertyRecordSchema &&
|
|
990
990
|
propertyRecordSchema.storageType &&
|
|
991
991
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
992
|
-
const { Item } = yield import('./index-
|
|
992
|
+
const { Item } = yield import('./index-tV-MoWhc.js');
|
|
993
993
|
const item = yield Item.find({
|
|
994
994
|
seedLocalId,
|
|
995
995
|
modelName: itemModelName,
|
|
@@ -2877,7 +2877,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2877
2877
|
if (!models$1) {
|
|
2878
2878
|
return;
|
|
2879
2879
|
}
|
|
2880
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2880
|
+
const { models: SeedModels } = yield import('./seed.schema.config-BkdBBwUC.js');
|
|
2881
2881
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2882
2882
|
let hasModelsInDb = false;
|
|
2883
2883
|
const schemaDefsByModelName = new Map();
|
|
@@ -6451,6 +6451,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
6451
6451
|
});
|
|
6452
6452
|
if (!foundItem) {
|
|
6453
6453
|
logger$2('[useItem] [getItemFromDb] no item found', modelName, seedLocalId);
|
|
6454
|
+
isReadingDb.current = false;
|
|
6454
6455
|
return;
|
|
6455
6456
|
}
|
|
6456
6457
|
setItem(foundItem);
|
|
@@ -6767,7 +6768,7 @@ const client = {
|
|
|
6767
6768
|
console.error('fs listeners not ready during init');
|
|
6768
6769
|
}
|
|
6769
6770
|
globalService.send({ type: 'init', endpoints, models, addresses });
|
|
6770
|
-
import('./seed.schema.config-
|
|
6771
|
+
import('./seed.schema.config-BkdBBwUC.js').then(({ models }) => {
|
|
6771
6772
|
for (const [key, value] of Object.entries(models)) {
|
|
6772
6773
|
setModel(key, value);
|
|
6773
6774
|
}
|
|
@@ -7340,4 +7341,4 @@ if (isNode()) {
|
|
|
7340
7341
|
}
|
|
7341
7342
|
|
|
7342
7343
|
export { GET_SCHEMAS as G, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, GET_SEEDS as a, GET_SEED_IDS as b, GET_STORAGE_TRANSACTION_ID as c, GET_VERSIONS as d, GET_PROPERTIES as e, GET_ALL_PROPERTIES_FOR_ALL_VERSIONS as f, itemMachineAll as g, ImageSrc as h, itemMachineSingle as i, ItemProperty as j, useItem as k, useItemProperties as l, useCreateItem as m, useItemProperty as n, useDeleteItem as o, useGlobalServiceStatus as p, useServices as q, getGlobalService as r, client as s, getCorrectId as t, useItems as u, withSeed as w };
|
|
7343
|
-
//# sourceMappingURL=index-
|
|
7344
|
+
//# sourceMappingURL=index-BBcjMsIh.js.map
|