@seedprotocol/sdk 0.4.4 → 0.4.6
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 +38 -348
- package/dist/{ArweaveClient-DkNLWiSZ.js → ArweaveClient-Caio37h1.js} +8 -8
- package/dist/ArweaveClient-Caio37h1.js.map +1 -0
- package/dist/{ArweaveClient-CczHvccG.js → ArweaveClient-DLKAaS3K.js} +8 -8
- package/dist/ArweaveClient-DLKAaS3K.js.map +1 -0
- package/dist/{Db-DJvjXVlp.js → Db-C9fppVRl.js} +9 -9
- package/dist/Db-C9fppVRl.js.map +1 -0
- package/dist/{Db-BzQR2KX9.js → Db-DJAG-5Di.js} +13 -11
- package/dist/Db-DJAG-5Di.js.map +1 -0
- package/dist/{EasClient-CHQYmjj2.js → EasClient-DQGAIj-b.js} +8 -8
- package/dist/EasClient-DQGAIj-b.js.map +1 -0
- package/dist/{EasClient-CodrIgW-.js → EasClient-T7Nx9185.js} +8 -8
- package/dist/EasClient-T7Nx9185.js.map +1 -0
- package/dist/{FileManager-BbvkZJCH.js → FileManager-BohtoKYo.js} +10 -9
- package/dist/FileManager-BohtoKYo.js.map +1 -0
- package/dist/{FileManager-BIVsDnMu.js → FileManager-d64CkqXy.js} +8 -8
- package/dist/FileManager-d64CkqXy.js.map +1 -0
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/service/actors/fetchDataFromEas.d.ts.map +1 -1
- package/dist/Item/service/actors/loadOrCreateItem.d.ts.map +1 -1
- package/dist/Item/service/actors/runPublish.d.ts.map +1 -1
- package/dist/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/ItemProperty/service/actors/resolveRelatedValue.d.ts.map +1 -1
- package/dist/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
- package/dist/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts.map +1 -1
- package/dist/Model/Model.d.ts.map +1 -1
- package/dist/Model/service/actors/createModelProperties.d.ts.map +1 -1
- package/dist/Model/service/actors/loadOrCreateModel.d.ts.map +1 -1
- package/dist/Model/service/actors/validateModel.d.ts.map +1 -1
- package/dist/ModelProperty/ModelProperty.d.ts.map +1 -1
- package/dist/ModelProperty/service/actors/compareAndMarkDraft.d.ts.map +1 -1
- package/dist/ModelProperty/service/actors/saveToSchema.d.ts.map +1 -1
- package/dist/ModelProperty/service/actors/validateProperty.d.ts.map +1 -1
- package/dist/{ModelProperty-gjcA83Mq.js → ModelProperty-Cpd9xiIM.js} +67 -768
- package/dist/ModelProperty-Cpd9xiIM.js.map +1 -0
- package/dist/{PathResolver-kGzba-zC.js → PathResolver-CLZUWoX2.js} +8 -8
- package/dist/PathResolver-CLZUWoX2.js.map +1 -0
- package/dist/{PathResolver-9zAzPhee.js → PathResolver-D6M0rzKV.js} +8 -8
- package/dist/PathResolver-D6M0rzKV.js.map +1 -0
- package/dist/{QueryClient-C7ZkTT0z.js → QueryClient-BUoz2Vb0.js} +8 -8
- package/dist/QueryClient-BUoz2Vb0.js.map +1 -0
- package/dist/{QueryClient-CEtsek7Q.js → QueryClient-COQ_Rs4-.js} +8 -8
- package/dist/QueryClient-COQ_Rs4-.js.map +1 -0
- package/dist/Schema/Schema.d.ts.map +1 -1
- package/dist/Schema/service/actors/createModelInstances.d.ts.map +1 -1
- package/dist/Schema/service/actors/loadOrCreateSchema.d.ts.map +1 -1
- package/dist/Schema/service/actors/verifyModelInstancesInCache.d.ts.map +1 -1
- package/dist/Schema/service/actors/writePropertiesToDb.d.ts.map +1 -1
- package/dist/Schema/service/addModelsMachine.d.ts.map +1 -1
- package/dist/{Schema-ClTcpgbt.js → Schema-BZKBy5Tx.js} +799 -62
- package/dist/Schema-BZKBy5Tx.js.map +1 -0
- package/dist/{SchemaValidationService-BfoEiHNr.js → SchemaValidationService-F8No7BHp.js} +7 -7
- package/dist/SchemaValidationService-F8No7BHp.js.map +1 -0
- package/dist/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/browser/react/itemProperty.d.ts.map +1 -1
- package/dist/cjs/{ModelProperty-BRKRREYP.js → ModelProperty-B4pV91tc.js} +78 -438
- package/dist/cjs/ModelProperty-B4pV91tc.js.map +1 -0
- package/dist/cjs/{Schema-CV9hMg8m.js → Schema-TErl3J36.js} +437 -93
- package/dist/cjs/Schema-TErl3J36.js.map +1 -0
- package/dist/cjs/{SchemaValidationService-DUtQUerg.js → SchemaValidationService-p5BbJV9T.js} +3 -3
- package/dist/cjs/{SchemaValidationService-DUtQUerg.js.map → SchemaValidationService-p5BbJV9T.js.map} +1 -1
- package/dist/cjs/{getItem-BThT-UOt.js → getItem-BrnLfC12.js} +3 -3
- package/dist/cjs/{getItem-BThT-UOt.js.map → getItem-BrnLfC12.js.map} +1 -1
- package/dist/cjs/{getPublishPayload-CKZ7rVbU.js → getPublishPayload-BcjCN_bD.js} +8 -6
- package/dist/cjs/getPublishPayload-BcjCN_bD.js.map +1 -0
- package/dist/cjs/{getPublishUploads-CuGIvV-Q.js → getPublishUploads-5_oXzwol.js} +4 -4
- package/dist/cjs/{getPublishUploads-CuGIvV-Q.js.map → getPublishUploads-5_oXzwol.js.map} +1 -1
- package/dist/cjs/{getSegmentedItemProperties-BCJXJlTR.js → getSegmentedItemProperties-WFdizUDv.js} +2 -2
- package/dist/cjs/{getSegmentedItemProperties-BCJXJlTR.js.map → getSegmentedItemProperties-WFdizUDv.js.map} +1 -1
- package/dist/cjs/{index-CbTBDqTJ.js → index-BrmvhXsG.js} +3 -3
- package/dist/cjs/index-BrmvhXsG.js.map +1 -0
- package/dist/cjs/{index-C3j3m34a.js → index-CXI4VF1H.js} +12351 -12189
- package/dist/cjs/index-CXI4VF1H.js.map +1 -0
- package/dist/client/actors/platformClassesInit.d.ts.map +1 -1
- package/dist/client/actors/saveAppState.d.ts.map +1 -1
- package/dist/db/read/getModelSchemas.d.ts.map +1 -1
- package/dist/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/db/write/createNewItem.d.ts.map +1 -1
- package/dist/eas.d.ts.map +1 -1
- package/dist/events/files/download.d.ts.map +1 -1
- package/dist/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/{getItem-BWPo8wd0.js → getItem-DaQVdeae.js} +8 -8
- package/dist/getItem-DaQVdeae.js.map +1 -0
- package/dist/{getPublishPayload-Caw2laZM.js → getPublishPayload-CWiLI1yd.js} +12 -10
- package/dist/getPublishPayload-CWiLI1yd.js.map +1 -0
- package/dist/{getPublishUploads-MlyBuoXh.js → getPublishUploads-DhvcKD_9.js} +9 -9
- package/dist/getPublishUploads-DhvcKD_9.js.map +1 -0
- package/dist/{getSegmentedItemProperties-COLLdDo4.js → getSegmentedItemProperties-Cp4kcWIF.js} +2 -2
- package/dist/getSegmentedItemProperties-Cp4kcWIF.js.map +1 -0
- package/dist/helpers/db.d.ts.map +1 -1
- package/dist/helpers/property.d.ts.map +1 -1
- package/dist/helpers/schema.d.ts.map +1 -1
- package/dist/helpers/updateSchema.d.ts.map +1 -1
- package/dist/imports/json.d.ts.map +1 -1
- package/dist/{index-D2OGsG4v.js → index-DBy53qbb.js} +2 -2
- package/dist/index-DBy53qbb.js.map +1 -0
- package/dist/{ClientManager-DoHUt8tU.js → index-Dk73a7JE.js} +11781 -11613
- package/dist/index-Dk73a7JE.js.map +1 -0
- package/dist/{index-B9i_mXXp.js → index-LfXKx_PE.js} +9 -9
- package/dist/index-LfXKx_PE.js.map +1 -0
- package/dist/main.cjs +2 -2
- package/dist/main.js +16 -13
- package/dist/main.js.map +1 -1
- package/dist/node/db/Db.d.ts.map +1 -1
- package/dist/node.js +15 -15
- package/dist/node.js.map +1 -1
- package/dist/{property-fK7tSUDX.js → property-1o2MvYTm.js} +10 -4
- package/dist/property-1o2MvYTm.js.map +1 -0
- package/dist/{queries-DGOk16cd.js → queries-DA4G0iEN.js} +2 -2
- package/dist/queries-DA4G0iEN.js.map +1 -0
- package/dist/services/publish/actors/preparePublishRequestData.d.ts.map +1 -1
- package/dist/services/publish/actors/upload.d.ts.map +1 -1
- package/dist/services/write/actors/validateEntity.d.ts.map +1 -1
- package/dist/services/write/actors/writeToDatabase.d.ts.map +1 -1
- package/dist/vite.js.map +1 -1
- package/package.json +8 -4
- package/dist/ArweaveClient-CczHvccG.js.map +0 -1
- package/dist/ArweaveClient-DkNLWiSZ.js.map +0 -1
- package/dist/ClientManager-DoHUt8tU.js.map +0 -1
- package/dist/Db-BzQR2KX9.js.map +0 -1
- package/dist/Db-DJvjXVlp.js.map +0 -1
- package/dist/EasClient-CHQYmjj2.js.map +0 -1
- package/dist/EasClient-CodrIgW-.js.map +0 -1
- package/dist/FileManager-BIVsDnMu.js.map +0 -1
- package/dist/FileManager-BbvkZJCH.js.map +0 -1
- package/dist/ModelProperty-gjcA83Mq.js.map +0 -1
- package/dist/PathResolver-9zAzPhee.js.map +0 -1
- package/dist/PathResolver-kGzba-zC.js.map +0 -1
- package/dist/QueryClient-C7ZkTT0z.js.map +0 -1
- package/dist/QueryClient-CEtsek7Q.js.map +0 -1
- package/dist/Schema-ClTcpgbt.js.map +0 -1
- package/dist/SchemaValidationService-BfoEiHNr.js.map +0 -1
- package/dist/cjs/ModelProperty-BRKRREYP.js.map +0 -1
- package/dist/cjs/Schema-CV9hMg8m.js.map +0 -1
- package/dist/cjs/getPublishPayload-CKZ7rVbU.js.map +0 -1
- package/dist/cjs/index-C3j3m34a.js.map +0 -1
- package/dist/cjs/index-CbTBDqTJ.js.map +0 -1
- package/dist/getItem-BWPo8wd0.js.map +0 -1
- package/dist/getPublishPayload-Caw2laZM.js.map +0 -1
- package/dist/getPublishUploads-MlyBuoXh.js.map +0 -1
- package/dist/getSegmentedItemProperties-COLLdDo4.js.map +0 -1
- package/dist/index-B9i_mXXp.js.map +0 -1
- package/dist/index-D2OGsG4v.js.map +0 -1
- package/dist/property-fK7tSUDX.js.map +0 -1
- package/dist/queries-DGOk16cd.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,377 +1,67 @@
|
|
|
1
1
|
# Seed Protocol SDK
|
|
2
2
|
|
|
3
|
-
The official SDK for [Seed Protocol](https://seedprotocol.io
|
|
3
|
+
The official JavaScript/TypeScript SDK for [Seed Protocol](https://seedprotocol.io)—a local-first, decentralized data layer.
|
|
4
4
|
|
|
5
|
-
|
|
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).
|
|
5
|
+
**[→ Full documentation at seedprotocol.io](https://seedprotocol.io)**
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
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).
|
|
18
|
-
|
|
19
|
-
## Installing
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm install @seedprotocol/sdk
|
|
23
|
-
# or
|
|
24
|
-
pnpm add @seedprotocol/sdk
|
|
25
|
-
# or
|
|
26
|
-
bun add @seedprotocol/sdk
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Module System Support
|
|
30
|
-
|
|
31
|
-
The SDK supports both ESM and CommonJS module systems:
|
|
32
|
-
|
|
33
|
-
**ESM (Recommended):**
|
|
34
|
-
```javascript
|
|
35
|
-
import { Model, Property, Item } from '@seedprotocol/sdk'
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**CommonJS:**
|
|
39
|
-
```javascript
|
|
40
|
-
const { Model, Property, Item } = require('@seedprotocol/sdk')
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Getting Started
|
|
44
|
-
|
|
45
|
-
The first thing to do when integrating Seed SDK is define your data model by creating a configuration file in the root
|
|
46
|
-
of your project. The SDK supports the following file names (in order of preference):
|
|
47
|
-
|
|
48
|
-
- `seed.config.ts` (recommended)
|
|
49
|
-
- `seed.schema.ts`
|
|
50
|
-
- `schema.ts` (legacy)
|
|
51
|
-
|
|
52
|
-
As an example, here's the actual data model for PermaPress using `seed.config.ts`:
|
|
53
|
-
|
|
54
|
-
```typescript
|
|
55
|
-
import { ImageSrc, List, Model, Relation, Text } from '@/browser/schema'
|
|
56
|
-
|
|
57
|
-
@Model
|
|
58
|
-
class Image {
|
|
59
|
-
@Text() storageTransactionId!: string
|
|
60
|
-
@Text() uri!: string
|
|
61
|
-
@Text() alt!: string
|
|
62
|
-
@ImageSrc() src!: string
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@Model
|
|
66
|
-
class Post {
|
|
67
|
-
@Text() title!: string
|
|
68
|
-
@Text() summary!: string
|
|
69
|
-
@Relation('Image', 'ImageSrc') featureImage!: string
|
|
70
|
-
@Text('ItemStorage', '/html', '.html') html!: string
|
|
71
|
-
@Text('ItemStorage', '/json', '.json') json!: string
|
|
72
|
-
@Text() storageTransactionId!: string
|
|
73
|
-
@List('Identity') authors!: string[]
|
|
74
|
-
@Text() importUrl!: string
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@Model
|
|
78
|
-
class Identity {
|
|
79
|
-
@Text() name!: string
|
|
80
|
-
@Text() profile!: string
|
|
81
|
-
@Text() displayName!: string
|
|
82
|
-
@Relation('Image', 'ImageSrc') avatarImage!: string
|
|
83
|
-
@Relation('Image', 'ImageSrc') coverImage!: string
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@Model
|
|
87
|
-
class Link {
|
|
88
|
-
@Text() url!: string
|
|
89
|
-
@Text() text!: string
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const models = {
|
|
93
|
-
Identity,
|
|
94
|
-
Image,
|
|
95
|
-
Link,
|
|
96
|
-
Post,
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const endpoints = {
|
|
100
|
-
filePaths: '/api/seed/migrations',
|
|
101
|
-
files: '/app-files',
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export { models, endpoints }
|
|
105
|
-
|
|
106
|
-
export default { models, endpoints }
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
This will create a database locally in the browser with all the tables and fields necessary to support your Models.
|
|
111
|
-
|
|
112
|
-
> [!NOTE]
|
|
113
|
-
> The database is a SQLite file stored
|
|
114
|
-
> in [OPFS](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system).
|
|
115
|
-
> We recommend using
|
|
116
|
-
> the [OPFS Explorer](https://chromewebstore.google.com/detail/opfs-explorer/acndjpgkpaclldomagafnognkcgjignd)
|
|
117
|
-
> browser extension to see the files managed by the SDK.
|
|
118
|
-
|
|
119
|
-
Notice that we create relationships by defining a `Property` that takes its related `Model` as its type. For one-to-many
|
|
120
|
-
relationships, we use the `List` type and pass in the `Model` type we want.
|
|
121
|
-
|
|
122
|
-
So creating a Post would look like this:
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
import { Post, Image, Identity } from './seed/models'
|
|
126
|
-
import html from './index.html'
|
|
127
|
-
|
|
128
|
-
const image = await Image.create({
|
|
129
|
-
src: 'https://imgr.com/image.jpg',
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
const author = await Identity.create({
|
|
133
|
-
name: 'Keith Axline',
|
|
134
|
-
profile: 'Developer for Seed Protocol',
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
const authors = [
|
|
138
|
-
author
|
|
139
|
-
]
|
|
140
|
-
|
|
141
|
-
const post = await Post.create({
|
|
142
|
-
title: 'Some title',
|
|
143
|
-
summary: 'My summary',
|
|
144
|
-
featureImage: image,
|
|
145
|
-
authors,
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
await post.publish()
|
|
149
|
-
|
|
150
|
-
// And later when we want to update the post
|
|
151
|
-
post.title = 'Something else'
|
|
152
|
-
|
|
153
|
-
await post.publish()
|
|
154
|
-
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Usage
|
|
158
|
-
|
|
159
|
-
### `Item`
|
|
160
|
-
|
|
161
|
-
Create
|
|
162
|
-
|
|
163
|
-
```typescript
|
|
164
|
-
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### Files
|
|
168
|
-
|
|
169
|
-
Subscribe to events:
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
import { SeedFile } from '@seedprotocol/sdk'
|
|
7
|
+
---
|
|
173
8
|
|
|
174
|
-
|
|
9
|
+
## What it does
|
|
175
10
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
11
|
+
- **Local-first ORM** — Define models and properties; the SDK stores data in SQLite and OPFS in the user’s browser.
|
|
12
|
+
- **Decentralized sync** — Data is read from and written to the [Ethereum Attestation Service (EAS)](https://attest.sh) and [Arweave](https://www.arweave.org). No backend for you to run or maintain.
|
|
13
|
+
- **No custody** — User data stays on public infrastructure and in the user’s browser, not on your servers.
|
|
179
14
|
|
|
180
|
-
|
|
15
|
+
Built and used by [PermaPress](https://permapress.xyz), the first client for Seed Protocol (by [JournoLabs](https://journolabs.xyz)).
|
|
181
16
|
|
|
182
|
-
|
|
17
|
+
## Documentation
|
|
183
18
|
|
|
184
|
-
|
|
19
|
+
For setup, schema definition, models, items, files, and React integration, see:
|
|
185
20
|
|
|
186
|
-
|
|
187
|
-
const fileFromPath = new SeedFile('path/to/file.txt')
|
|
21
|
+
**https://seedprotocol.io**
|
|
188
22
|
|
|
189
|
-
|
|
23
|
+
## Requirements
|
|
190
24
|
|
|
191
|
-
|
|
25
|
+
- **Node.js** `>= 20` and `<= 24`
|
|
26
|
+
- **Browser** support: modern browsers with OPFS (e.g. Chromium-based, recent Firefox)
|
|
192
27
|
|
|
193
|
-
|
|
28
|
+
## Installation
|
|
194
29
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
30
|
+
```bash
|
|
31
|
+
bun add @seedprotocol/sdk
|
|
32
|
+
# or
|
|
33
|
+
npm install @seedprotocol/sdk
|
|
34
|
+
# or
|
|
35
|
+
pnpm add @seedprotocol/sdk
|
|
198
36
|
```
|
|
199
37
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
```typescript
|
|
203
|
-
import { SeedFileSystem } from '@seedprotocol/sdk'
|
|
204
|
-
|
|
205
|
-
const fs = new SeedFileSystem()
|
|
206
|
-
|
|
207
|
-
fs.subscribe(( event, status ) => {
|
|
208
|
-
console.log(`Event: ${event}, Status: ${status}`)
|
|
209
|
-
if ( event === 'connection.success' && status === 'connected' ) {
|
|
210
|
-
console.log('Connected to user\'s file system')
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if ( event === 'connection.error' ) {
|
|
214
|
-
console.error('Error connecting to user\'s file system', event.error)
|
|
215
|
-
}
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
await fs.connect() // User prompted to connect browser wallet
|
|
219
|
-
|
|
220
|
-
const files = await fs.listFiles('/')
|
|
221
|
-
|
|
222
|
-
files.forEach(file => {
|
|
223
|
-
console.log(file.name)
|
|
224
|
-
console.log(file.size)
|
|
225
|
-
console.log(file.seedPath) // Each wallet address has a virtual root directory with directories and file system paths
|
|
226
|
-
})
|
|
38
|
+
**Optional (React):** If you use React hooks (`useModel`, `useSchema`, etc.), install peer dependencies:
|
|
227
39
|
|
|
40
|
+
```bash
|
|
41
|
+
bun add react @tanstack/react-query
|
|
228
42
|
```
|
|
229
43
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
```typescript
|
|
44
|
+
## Quick start
|
|
233
45
|
|
|
234
|
-
|
|
46
|
+
1. **Define your schema** in a config file at the project root: `seed.config.ts` (recommended), `seed.schema.ts`, or `schema.ts`.
|
|
235
47
|
|
|
236
|
-
|
|
48
|
+
2. **Use the SDK** in your app:
|
|
237
49
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
await imgFromUrl.save()
|
|
241
|
-
|
|
242
|
-
const imgBlob = imgFromUrl.blob()
|
|
243
|
-
const imgBuffer = imgFromUrl.buffer()
|
|
244
|
-
const imgDataUrl = imgFromUrl.dataUrl()
|
|
50
|
+
```ts
|
|
51
|
+
import { Model, Property, Item } from '@seedprotocol/sdk'
|
|
245
52
|
|
|
53
|
+
// Define models in your schema; then create and publish items:
|
|
54
|
+
const post = await Post.create({ title: 'Hello', summary: '...', ... })
|
|
55
|
+
await post.publish()
|
|
246
56
|
```
|
|
247
57
|
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
Title: Seed Protocol SDK
|
|
251
|
-
---
|
|
252
|
-
%%{
|
|
253
|
-
init: {
|
|
254
|
-
'theme': 'base',
|
|
255
|
-
'themeVariables': {
|
|
256
|
-
'primaryColor': '#e0f2fe',
|
|
257
|
-
'primaryTextColor': '#0c4a6e',
|
|
258
|
-
'primaryBorderColor': '#38bdf8',
|
|
259
|
-
'lineColor': '#475569',
|
|
260
|
-
'secondaryColor': '#d9f99d',
|
|
261
|
-
'tertiaryColor': '#fff',
|
|
262
|
-
'tertiaryBorderColor': '#7e22ce',
|
|
263
|
-
'tertiaryTextColor': '#7e22ce',
|
|
264
|
-
'clusterBkg': '#fff'
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}%%
|
|
268
|
-
flowchart TD
|
|
269
|
-
A{Developer}
|
|
270
|
-
B{User}
|
|
271
|
-
C{Seed Dev}
|
|
272
|
-
N{SDK}
|
|
273
|
-
Q[App Code]
|
|
274
|
-
D[(sdk_config_db)]
|
|
275
|
-
E[(seed)]
|
|
276
|
-
L[(seeds_db)]
|
|
277
|
-
G[Schema/Migration files
|
|
278
|
-
browser/db/seedSchema]
|
|
279
|
-
H[Schema/Migration files
|
|
280
|
-
.seed/schema]
|
|
281
|
-
R[Schema/Migration files
|
|
282
|
-
node/db/sdkSchema]
|
|
283
|
-
|
|
284
|
-
I[browser.seed.db.config.mjs]
|
|
285
|
-
J[sdk.db.config.mjs]
|
|
286
|
-
|
|
287
|
-
O[files.json
|
|
288
|
-
seed/endpoint/list]
|
|
289
|
-
P[Files
|
|
290
|
-
seed/endpoint/files]
|
|
291
|
-
|
|
292
|
-
S[$> seed init]
|
|
293
|
-
T[scripts/bin]
|
|
58
|
+
For full guides on schema, models, properties, items, files, and the CLI, see **[the docs](https://seedprotocol.io)**.
|
|
294
59
|
|
|
295
|
-
|
|
296
|
-
C--changes Seeds or Versions --> I
|
|
297
|
-
C-- changes Models or Properties --> J
|
|
298
|
-
J-- generates -->R
|
|
299
|
-
I-- generates --> G
|
|
300
|
-
subgraph Package Bundle
|
|
301
|
-
R
|
|
302
|
-
G
|
|
303
|
-
end
|
|
304
|
-
end
|
|
60
|
+
## Module support
|
|
305
61
|
|
|
62
|
+
- **ESM** (recommended): `import { Model, Property, Item } from '@seedprotocol/sdk'`
|
|
63
|
+
- **CommonJS**: `const { Model, Property, Item } = require('@seedprotocol/sdk')`
|
|
306
64
|
|
|
65
|
+
## License
|
|
307
66
|
|
|
308
|
-
|
|
309
|
-
A-- adds Models and Properties --> K
|
|
310
|
-
subgraph SDK
|
|
311
|
-
D
|
|
312
|
-
H
|
|
313
|
-
end
|
|
314
|
-
A-- runs --> S
|
|
315
|
-
S-- calls --> T
|
|
316
|
-
T-- reads--> K
|
|
317
|
-
T-- generates --> D
|
|
318
|
-
T-- generates --> H
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
subgraph App Server
|
|
322
|
-
H-- served at endpoint --> O
|
|
323
|
-
H-- served at endpoint --> P
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
subgraph Browser
|
|
329
|
-
B-- adds data--> Q
|
|
330
|
-
subgraph App
|
|
331
|
-
Q-- calls SDK--> N
|
|
332
|
-
subgraph SDK
|
|
333
|
-
E-- notifies -->N
|
|
334
|
-
N<-- files . json --> O
|
|
335
|
-
N<-- files --> P
|
|
336
|
-
N-- updates -->E
|
|
337
|
-
N-- updates --> L
|
|
338
|
-
|
|
339
|
-
end
|
|
340
|
-
end
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
A[Versions From EAS]
|
|
347
|
-
B[Seeds From EAS]
|
|
348
|
-
C[List of Items]
|
|
349
|
-
D[List of Properties]
|
|
350
|
-
E{Property Machine}
|
|
351
|
-
F{Item Machine}
|
|
352
|
-
G{Items Machine}
|
|
353
|
-
|
|
354
|
-
```mermaid
|
|
355
|
-
sequenceDiagram
|
|
356
|
-
Items Service ->>+ EAS: Seeds Request
|
|
357
|
-
EAS -->>+ Items Service: Seed Attestations
|
|
358
|
-
loop Each Seed Attestation
|
|
359
|
-
Items Service ->>+ Items Service: Extract Seed Uid
|
|
360
|
-
end
|
|
361
|
-
Note over Items Service: Now we have SeedUid[]
|
|
362
|
-
Items Service ->>+ EAS: Versions Request w/ SeedUid[]
|
|
363
|
-
EAS -->>+ Items Service: Version Attestations
|
|
364
|
-
loop Each SeedUid
|
|
365
|
-
Items Service ->>+ Items Service: Sort Version Uids DESC
|
|
366
|
-
end
|
|
367
|
-
loop Each most recent Version for Seed
|
|
368
|
-
Items Service ->>+ Item Service: Create Item
|
|
369
|
-
end
|
|
370
|
-
Note over Items Service: Now we have VersionUid[] for each SeedUid<br />sorted by `createdAt` DESC
|
|
371
|
-
Item Service ->>+ EAS: Properties Request w/ VersionUid[]
|
|
372
|
-
EAS -->>+ Item Service: Properties Attestations
|
|
373
|
-
loop Each Property Attestation
|
|
374
|
-
Item Service ->>+ Property Service: Create Property Service
|
|
375
|
-
end
|
|
376
|
-
Note over Item Service: Now has all Property Services<br />under this._services
|
|
377
|
-
```
|
|
67
|
+
MIT
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { u as BaseArweaveClient } from './index-Dk73a7JE.js';
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
3
|
import Arweave from 'arweave';
|
|
4
|
-
import { G as GET_TRANSACTION_TAGS } from './queries-
|
|
4
|
+
import { G as GET_TRANSACTION_TAGS } from './queries-DA4G0iEN.js';
|
|
5
5
|
import debug from 'debug';
|
|
6
6
|
import 'xstate';
|
|
7
|
+
import 'drizzle-orm/sqlite-core';
|
|
7
8
|
import 'drizzle-orm';
|
|
9
|
+
import 'nanoid';
|
|
10
|
+
import 'nanoid-dictionary';
|
|
8
11
|
import 'pluralize';
|
|
12
|
+
import 'ethers';
|
|
9
13
|
import 'rxjs';
|
|
10
14
|
import 'lodash-es';
|
|
11
15
|
import 'drizzle-orm/casing';
|
|
12
|
-
import '@sinclair/typebox';
|
|
13
16
|
import 'eventemitter3';
|
|
14
|
-
import '
|
|
15
|
-
import 'nanoid';
|
|
16
|
-
import 'nanoid-dictionary';
|
|
17
|
-
import 'ethers';
|
|
17
|
+
import '@sinclair/typebox';
|
|
18
18
|
|
|
19
19
|
const logger = debug("seedSdk:browser:ArweaveClient");
|
|
20
20
|
// Cached Arweave instance
|
|
@@ -199,4 +199,4 @@ class ArweaveClient extends BaseArweaveClient {
|
|
|
199
199
|
BaseArweaveClient.setPlatformClass(ArweaveClient);
|
|
200
200
|
|
|
201
201
|
export { ArweaveClient };
|
|
202
|
-
//# sourceMappingURL=ArweaveClient-
|
|
202
|
+
//# sourceMappingURL=ArweaveClient-Caio37h1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArweaveClient-Caio37h1.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { u as BaseArweaveClient } from './index-Dk73a7JE.js';
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
3
|
import Arweave from 'arweave';
|
|
4
|
-
import { G as GET_TRANSACTION_TAGS } from './queries-
|
|
4
|
+
import { G as GET_TRANSACTION_TAGS } from './queries-DA4G0iEN.js';
|
|
5
5
|
import debug from 'debug';
|
|
6
6
|
import 'xstate';
|
|
7
|
+
import 'drizzle-orm/sqlite-core';
|
|
7
8
|
import 'drizzle-orm';
|
|
9
|
+
import 'nanoid';
|
|
10
|
+
import 'nanoid-dictionary';
|
|
8
11
|
import 'pluralize';
|
|
12
|
+
import 'ethers';
|
|
9
13
|
import 'rxjs';
|
|
10
14
|
import 'lodash-es';
|
|
11
15
|
import 'drizzle-orm/casing';
|
|
12
|
-
import '@sinclair/typebox';
|
|
13
16
|
import 'eventemitter3';
|
|
14
|
-
import '
|
|
15
|
-
import 'nanoid';
|
|
16
|
-
import 'nanoid-dictionary';
|
|
17
|
-
import 'ethers';
|
|
17
|
+
import '@sinclair/typebox';
|
|
18
18
|
|
|
19
19
|
const logger = debug('seedSdk:node:ArweaveClient');
|
|
20
20
|
// Cached Arweave instance
|
|
@@ -199,4 +199,4 @@ class ArweaveClient extends BaseArweaveClient {
|
|
|
199
199
|
BaseArweaveClient.setPlatformClass(ArweaveClient);
|
|
200
200
|
|
|
201
201
|
export { ArweaveClient };
|
|
202
|
-
//# sourceMappingURL=ArweaveClient-
|
|
202
|
+
//# sourceMappingURL=ArweaveClient-DLKAaS3K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArweaveClient-DLKAaS3K.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { p as BaseDb,
|
|
1
|
+
import { p as BaseDb, x as BaseFileManager } from './index-Dk73a7JE.js';
|
|
2
2
|
import debug from 'debug';
|
|
3
3
|
import { sql } from 'drizzle-orm';
|
|
4
4
|
import { readMigrationFiles } from 'drizzle-orm/migrator';
|
|
5
5
|
import { drizzle } from 'drizzle-orm/sqlite-proxy';
|
|
6
6
|
import { migrate } from 'drizzle-orm/sqlite-proxy/migrator';
|
|
7
|
-
import { s as schema } from './index-
|
|
7
|
+
import { s as schema } from './index-DBy53qbb.js';
|
|
8
8
|
import { SQLocalDrizzle } from 'sqlocal/drizzle';
|
|
9
9
|
import { Observable, distinctUntilChanged } from 'rxjs';
|
|
10
10
|
import 'xstate';
|
|
11
|
-
import 'pluralize';
|
|
12
|
-
import 'lodash-es';
|
|
13
|
-
import 'drizzle-orm/casing';
|
|
14
|
-
import '@sinclair/typebox';
|
|
15
|
-
import 'arweave';
|
|
16
|
-
import 'eventemitter3';
|
|
17
11
|
import 'drizzle-orm/sqlite-core';
|
|
18
12
|
import 'nanoid';
|
|
19
13
|
import 'nanoid-dictionary';
|
|
14
|
+
import 'pluralize';
|
|
20
15
|
import 'ethers';
|
|
16
|
+
import 'lodash-es';
|
|
17
|
+
import 'drizzle-orm/casing';
|
|
18
|
+
import 'eventemitter3';
|
|
19
|
+
import 'arweave';
|
|
20
|
+
import '@sinclair/typebox';
|
|
21
21
|
|
|
22
22
|
// This file embeds the drizzle migration files as strings for browser runtime
|
|
23
23
|
// These files are copied from src/db/drizzle at build time
|
|
@@ -1511,4 +1511,4 @@ class Db extends BaseDb {
|
|
|
1511
1511
|
}
|
|
1512
1512
|
|
|
1513
1513
|
export { Db };
|
|
1514
|
-
//# sourceMappingURL=Db-
|
|
1514
|
+
//# sourceMappingURL=Db-C9fppVRl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Db-C9fppVRl.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { p as BaseDb,
|
|
1
|
+
import { p as BaseDb, y as appState } from './index-Dk73a7JE.js';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import debug from 'debug';
|
|
4
|
-
import { s as schema } from './index-
|
|
4
|
+
import { s as schema } from './index-DBy53qbb.js';
|
|
5
5
|
import fs__default from 'fs';
|
|
6
6
|
import { createClient } from '@libsql/client';
|
|
7
7
|
import { drizzle } from 'drizzle-orm/libsql';
|
|
8
8
|
import { pushSQLiteSchema } from 'drizzle-kit/api';
|
|
9
9
|
import { interval, startWith, switchMap, distinctUntilChanged } from 'rxjs';
|
|
10
10
|
import 'xstate';
|
|
11
|
+
import 'drizzle-orm/sqlite-core';
|
|
11
12
|
import 'drizzle-orm';
|
|
13
|
+
import 'nanoid';
|
|
14
|
+
import 'nanoid-dictionary';
|
|
12
15
|
import 'pluralize';
|
|
16
|
+
import 'ethers';
|
|
13
17
|
import 'lodash-es';
|
|
14
18
|
import 'drizzle-orm/casing';
|
|
15
|
-
import '@sinclair/typebox';
|
|
16
|
-
import 'arweave';
|
|
17
19
|
import 'eventemitter3';
|
|
18
|
-
import '
|
|
19
|
-
import '
|
|
20
|
-
import 'nanoid-dictionary';
|
|
21
|
-
import 'ethers';
|
|
20
|
+
import 'arweave';
|
|
21
|
+
import '@sinclair/typebox';
|
|
22
22
|
|
|
23
23
|
const logger = debug('seedSdk:node:db:Db');
|
|
24
24
|
const getConfig = async (dotSeedDir, config) => {
|
|
25
25
|
// Create config inline - config values can be passed in or use defaults
|
|
26
|
-
const
|
|
26
|
+
const drizzleKitMod = await import('drizzle-kit');
|
|
27
|
+
const { defineConfig } = drizzleKitMod;
|
|
27
28
|
const appSchemaDir = config?.schemaDir || path.join(dotSeedDir, 'schema');
|
|
28
29
|
const outDir = config?.outDir || `${dotSeedDir}/db`;
|
|
29
30
|
const dbUrl = config?.dbUrl || `${dotSeedDir}/db/seed.db`;
|
|
@@ -239,7 +240,8 @@ class Db extends BaseDb {
|
|
|
239
240
|
// In drizzle-kit, migrations are generated in the 'out' directory (which is pathToDbDir)
|
|
240
241
|
// migrate(this.db, { migrationsFolder: pathToDbDir })
|
|
241
242
|
// NEW CODE: Use libsql migrator
|
|
242
|
-
const
|
|
243
|
+
const migratorMod = await import('drizzle-orm/libsql/migrator');
|
|
244
|
+
const { migrate } = migratorMod;
|
|
243
245
|
// migrationsFolder should point to the directory containing migration SQL files
|
|
244
246
|
// In drizzle-kit, migrations are generated in the 'out' directory (which is pathToDbDir)
|
|
245
247
|
await migrate(this.db, { migrationsFolder: pathToDbDir });
|
|
@@ -340,4 +342,4 @@ class Db extends BaseDb {
|
|
|
340
342
|
BaseDb.setPlatformClass(Db);
|
|
341
343
|
|
|
342
344
|
export { Db };
|
|
343
|
-
//# sourceMappingURL=Db-
|
|
345
|
+
//# sourceMappingURL=Db-DJAG-5Di.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Db-DJAG-5Di.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { w as BaseEasClient, E as EAS_ENDPOINT } from './index-Dk73a7JE.js';
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
3
|
import 'xstate';
|
|
4
|
+
import 'drizzle-orm/sqlite-core';
|
|
4
5
|
import 'drizzle-orm';
|
|
6
|
+
import 'nanoid';
|
|
7
|
+
import 'nanoid-dictionary';
|
|
5
8
|
import 'debug';
|
|
6
9
|
import 'pluralize';
|
|
10
|
+
import 'ethers';
|
|
7
11
|
import 'rxjs';
|
|
8
12
|
import 'lodash-es';
|
|
9
13
|
import 'drizzle-orm/casing';
|
|
10
|
-
import '@sinclair/typebox';
|
|
11
|
-
import 'arweave';
|
|
12
14
|
import 'eventemitter3';
|
|
13
|
-
import '
|
|
14
|
-
import '
|
|
15
|
-
import 'nanoid-dictionary';
|
|
16
|
-
import 'ethers';
|
|
15
|
+
import 'arweave';
|
|
16
|
+
import '@sinclair/typebox';
|
|
17
17
|
|
|
18
18
|
class EasClient extends BaseEasClient {
|
|
19
19
|
static getEasClient() {
|
|
@@ -26,4 +26,4 @@ class EasClient extends BaseEasClient {
|
|
|
26
26
|
BaseEasClient.setPlatformClass(EasClient);
|
|
27
27
|
|
|
28
28
|
export { EasClient };
|
|
29
|
-
//# sourceMappingURL=EasClient-
|
|
29
|
+
//# sourceMappingURL=EasClient-DQGAIj-b.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EasClient-DQGAIj-b.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { w as BaseEasClient, E as EAS_ENDPOINT } from './index-Dk73a7JE.js';
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
3
|
import 'xstate';
|
|
4
|
+
import 'drizzle-orm/sqlite-core';
|
|
4
5
|
import 'drizzle-orm';
|
|
6
|
+
import 'nanoid';
|
|
7
|
+
import 'nanoid-dictionary';
|
|
5
8
|
import 'debug';
|
|
6
9
|
import 'pluralize';
|
|
10
|
+
import 'ethers';
|
|
7
11
|
import 'rxjs';
|
|
8
12
|
import 'lodash-es';
|
|
9
13
|
import 'drizzle-orm/casing';
|
|
10
|
-
import '@sinclair/typebox';
|
|
11
|
-
import 'arweave';
|
|
12
14
|
import 'eventemitter3';
|
|
13
|
-
import '
|
|
14
|
-
import '
|
|
15
|
-
import 'nanoid-dictionary';
|
|
16
|
-
import 'ethers';
|
|
15
|
+
import 'arweave';
|
|
16
|
+
import '@sinclair/typebox';
|
|
17
17
|
|
|
18
18
|
class EasClient extends BaseEasClient {
|
|
19
19
|
static getEasClient() {
|
|
@@ -26,4 +26,4 @@ class EasClient extends BaseEasClient {
|
|
|
26
26
|
BaseEasClient.setPlatformClass(EasClient);
|
|
27
27
|
|
|
28
28
|
export { EasClient };
|
|
29
|
-
//# sourceMappingURL=EasClient-
|
|
29
|
+
//# sourceMappingURL=EasClient-T7Nx9185.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EasClient-T7Nx9185.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|