@seedprotocol/sdk 0.1.76 → 0.1.77
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/dist/{index-nyYoS6hl.js → index-BH0P1ozi.js} +30 -9
- package/dist/index-BH0P1ozi.js.map +1 -0
- package/dist/{index-D5bGQvS6.js → index-BpkGOxI0.js} +2 -2
- package/dist/{index-D5bGQvS6.js.map → index-BpkGOxI0.js.map} +1 -1
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-CaxQONHV.js → seed.schema.config-CR4yAjam.js} +2 -2
- package/dist/{seed.schema.config-CaxQONHV.js.map → seed.schema.config-CR4yAjam.js.map} +1 -1
- package/dist/src/hydrateFromDb.ts +36 -6
- package/dist/src/initialize.ts +33 -119
- package/dist/src/queries.ts +27 -6
- package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/index-nyYoS6hl.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-
|
|
1
|
+
export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-BH0P1ozi.js';
|
|
2
2
|
import './constants-rmQ8zg8_.js';
|
|
3
3
|
import '@ethereum-attestation-service/eas-sdk';
|
|
4
4
|
import 'thirdweb';
|
|
@@ -29,4 +29,4 @@ import 'rxjs';
|
|
|
29
29
|
import 'drizzle-orm/sqlite-proxy';
|
|
30
30
|
import '@zenfs/dom';
|
|
31
31
|
import 'arweave';
|
|
32
|
-
//# sourceMappingURL=index-
|
|
32
|
+
//# sourceMappingURL=index-BpkGOxI0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-BpkGOxI0.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { j as ImageSrc, I as Item, k as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, t as client, v as getCorrectId, s as getGlobalService, n as useCreateItem, p as useDeleteItem, q as useGlobalServiceStatus, l as useItem, m as useItemProperties, o as useItemProperty, u as useItems, r as useServices, w as withSeed } from './index-
|
|
1
|
+
export { j as ImageSrc, I as Item, k as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, t as client, v as getCorrectId, s as getGlobalService, n as useCreateItem, p as useDeleteItem, q as useGlobalServiceStatus, l as useItem, m as useItemProperties, o as useItemProperty, u as useItems, r as useServices, w as withSeed } from './index-BH0P1ozi.js';
|
|
2
2
|
import 'immer';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import './constants-rmQ8zg8_.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as __decorate, a as __metadata } from './constants-rmQ8zg8_.js';
|
|
2
2
|
import 'drizzle-orm';
|
|
3
|
-
import { T as Text, M as Model } from './index-
|
|
3
|
+
import { T as Text, M as Model } from './index-BH0P1ozi.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'reflect-metadata';
|
|
6
6
|
import 'xstate';
|
|
@@ -76,4 +76,4 @@ const models = {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
export { models };
|
|
79
|
-
//# sourceMappingURL=seed.schema.config-
|
|
79
|
+
//# sourceMappingURL=seed.schema.config-CR4yAjam.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.schema.config-
|
|
1
|
+
{"version":3,"file":"seed.schema.config-CR4yAjam.js","sources":["../../src/shared/configs/seed.schema.config.ts"],"sourcesContent":["import { Model, Text } from '@/browser'\n\n@Model\nclass Seed {\n @Text() uid!: string\n @Text() type!: string\n}\n\n@Model\nclass Version {\n @Text() seedUid!: string\n @Text() note!: string\n}\n\n@Model\nclass Metadata {\n @Text() key!: string\n @Text() value!: string\n}\n\nexport const models = {\n Seed,\n Version,\n Metadata,\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,IAAI,GAAV,MAAM,IAAI,CAAA;CAGT;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAa,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA;AAFjB,IAAI,GAAA,UAAA,CAAA;IADT;AACK,CAAA,EAAA,IAAI,CAGT;AAGD,IAAM,OAAO,GAAb,MAAM,OAAO,CAAA;CAGZ;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAiB,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA;AAChB,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA;AAFjB,OAAO,GAAA,UAAA,CAAA;IADZ;AACK,CAAA,EAAA,OAAO,CAGZ;AAGD,IAAM,QAAQ,GAAd,MAAM,QAAQ,CAAA;CAGb;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAa,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAe,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA;AAFlB,QAAQ,GAAA,UAAA,CAAA;IADb;AACK,CAAA,EAAA,QAAQ,CAGb;AAEY,MAAA,MAAM,GAAG;IACpB,IAAI;IACJ,OAAO;IACP,QAAQ;;;;;"}
|
|
@@ -46,13 +46,14 @@ export const hydrateFromDb = fromCallback<
|
|
|
46
46
|
const _hydrateFromDb = async () => {
|
|
47
47
|
const appDb = getAppDb()
|
|
48
48
|
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
if (
|
|
49
|
+
const isRelation =
|
|
52
50
|
propertyRecordSchema &&
|
|
53
51
|
propertyRecordSchema.ref &&
|
|
54
52
|
propertyRecordSchema.dataType === 'Relation'
|
|
55
|
-
|
|
53
|
+
|
|
54
|
+
const whereClauses = []
|
|
55
|
+
|
|
56
|
+
if (isRelation) {
|
|
56
57
|
let missingPropertyNameVariant
|
|
57
58
|
if (propertyName.endsWith('Id')) {
|
|
58
59
|
missingPropertyNameVariant = propertyName.slice(0, -2)
|
|
@@ -106,11 +107,10 @@ export const hydrateFromDb = fromCallback<
|
|
|
106
107
|
versionLocalId: versionLocalIdFromDb,
|
|
107
108
|
versionUid: versionUidFromDb,
|
|
108
109
|
refValueType,
|
|
109
|
-
refResolvedValue,
|
|
110
110
|
localStorageDir,
|
|
111
111
|
} = firstRow
|
|
112
112
|
|
|
113
|
-
let { refResolvedDisplayValue } = firstRow
|
|
113
|
+
let { refResolvedDisplayValue, refResolvedValue } = firstRow
|
|
114
114
|
|
|
115
115
|
let propertyValueProcessed: string | string[] | undefined | null =
|
|
116
116
|
propertyValueFromDb
|
|
@@ -185,6 +185,36 @@ export const hydrateFromDb = fromCallback<
|
|
|
185
185
|
) {
|
|
186
186
|
dir = 'images'
|
|
187
187
|
}
|
|
188
|
+
|
|
189
|
+
if (
|
|
190
|
+
!refResolvedValue &&
|
|
191
|
+
propertyValueFromDb &&
|
|
192
|
+
propertyValueFromDb.length === 66
|
|
193
|
+
) {
|
|
194
|
+
const storageTransactionQuery = await appDb
|
|
195
|
+
.select({
|
|
196
|
+
propertyValue: metadata.propertyValue,
|
|
197
|
+
})
|
|
198
|
+
.from(metadata)
|
|
199
|
+
.where(
|
|
200
|
+
and(
|
|
201
|
+
eq(metadata.seedUid, propertyValueFromDb),
|
|
202
|
+
eq(metadata.propertyName, 'storageTransactionId'),
|
|
203
|
+
),
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
if (storageTransactionQuery && storageTransactionQuery.length > 0) {
|
|
207
|
+
const row = storageTransactionQuery[0]
|
|
208
|
+
refResolvedValue = row.propertyValue
|
|
209
|
+
console.log('storageTransactionId', refResolvedValue)
|
|
210
|
+
await updateMetadata({
|
|
211
|
+
localId,
|
|
212
|
+
refResolvedValue,
|
|
213
|
+
localStorageDir: '/images',
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
188
218
|
const filePath = `/files/${dir}/${refResolvedValue}`
|
|
189
219
|
const fileExists = await fs.promises.exists(filePath)
|
|
190
220
|
if (fileExists) {
|
package/dist/src/initialize.ts
CHANGED
|
@@ -1,127 +1,41 @@
|
|
|
1
|
-
import { EventObject, fromCallback
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
let environment = 'browser'
|
|
25
|
-
|
|
26
|
-
if (isNode()) {
|
|
27
|
-
environment = 'node'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (isReactNative()) {
|
|
31
|
-
environment = 'react-native'
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let internalSubscription: Subscription | undefined
|
|
35
|
-
let easSubscription: Subscription | undefined
|
|
36
|
-
|
|
37
|
-
if (environment === 'browser' && models) {
|
|
38
|
-
const _initFileSystem = async (): Promise<void> => {
|
|
39
|
-
return
|
|
40
|
-
// return new Promise((resolve) => {
|
|
41
|
-
// })
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const _initInternal = async (): Promise<void> => {
|
|
45
|
-
return new Promise((resolve) => {
|
|
46
|
-
internalSubscription = internalService.subscribe((snapshot) => {
|
|
47
|
-
logger('[sdk] [internal] snapshot', snapshot)
|
|
48
|
-
if (snapshot.value === 'ready') {
|
|
49
|
-
resolve()
|
|
50
|
-
}
|
|
1
|
+
import { EventObject, fromCallback } from 'xstate'
|
|
2
|
+
import { itemMachineSingle } from '@/browser/item/single/itemMachineSingle'
|
|
3
|
+
import pluralize from 'pluralize'
|
|
4
|
+
import { getExistingItem } from '@/browser/db/read'
|
|
5
|
+
|
|
6
|
+
export const initialize = fromCallback<EventObject, typeof itemMachineSingle>(
|
|
7
|
+
({ sendBack, input: { context } }) => {
|
|
8
|
+
const { seedLocalId, seedUid, ModelClass } = context
|
|
9
|
+
|
|
10
|
+
const modelName = ModelClass.originalConstructor.name
|
|
11
|
+
const modelNamePlural = pluralize(modelName)
|
|
12
|
+
const modelTableName = modelNamePlural.toLowerCase()
|
|
13
|
+
|
|
14
|
+
const _intialize = async (): Promise<void> => {
|
|
15
|
+
const existingItem = await getExistingItem({ seedUid, seedLocalId })
|
|
16
|
+
|
|
17
|
+
if (existingItem) {
|
|
18
|
+
sendBack({
|
|
19
|
+
type: 'hasExistingItem',
|
|
20
|
+
modelName,
|
|
21
|
+
modelTableName,
|
|
22
|
+
modelNamePlural,
|
|
23
|
+
existingItem,
|
|
51
24
|
})
|
|
52
|
-
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const _initAllItemsServices = async (): Promise<void> => {
|
|
57
|
-
const appDb = getAppDb()
|
|
58
|
-
|
|
59
|
-
const rows = await appDb
|
|
60
|
-
.select()
|
|
61
|
-
.from(appState)
|
|
62
|
-
.where(like(appState.key, 'snapshot__%'))
|
|
63
|
-
|
|
64
|
-
const payloadObj = {
|
|
65
|
-
create: {},
|
|
66
|
-
restore: {},
|
|
25
|
+
return
|
|
67
26
|
}
|
|
68
27
|
|
|
69
|
-
const modelNamesRestored: string[] = []
|
|
70
|
-
|
|
71
|
-
if (rows && rows.length > 0) {
|
|
72
|
-
for (const row of rows) {
|
|
73
|
-
const modelName = row.key.replace('snapshot__', '')
|
|
74
|
-
payloadObj.restore[modelName] = JSON.parse(row.value)
|
|
75
|
-
modelNamesRestored.push(modelName)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
for (const [modelName, ModelClass] of Object.entries(models)) {
|
|
79
|
-
if (!modelNamesRestored.includes(modelName)) {
|
|
80
|
-
payloadObj.create[modelName] = ModelClass
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
28
|
sendBack({
|
|
84
|
-
type:
|
|
85
|
-
|
|
29
|
+
type: 'isNewItem',
|
|
30
|
+
modelName,
|
|
31
|
+
modelTableName,
|
|
32
|
+
modelNamePlural,
|
|
86
33
|
})
|
|
87
34
|
}
|
|
88
35
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// return new Promise((resolve) => {
|
|
93
|
-
// easSubscription = easService.subscribe((snapshot) => {
|
|
94
|
-
// if (snapshot.value === 'ready') {
|
|
95
|
-
// resolve()
|
|
96
|
-
// }
|
|
97
|
-
// })
|
|
98
|
-
// easService.send({ type: 'init', endpoints, models })
|
|
99
|
-
// })
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
_initFileSystem().then(() => {
|
|
103
|
-
logger('[global/actors] File system initialized')
|
|
36
|
+
_intialize().then(() => {
|
|
37
|
+
sendBack({ type: 'initializeSuccess' })
|
|
38
|
+
return
|
|
104
39
|
})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
.then(() => {
|
|
108
|
-
return _initAllItemsServices()
|
|
109
|
-
})
|
|
110
|
-
.then(() => {
|
|
111
|
-
logger('[global/actors] Internal initialized')
|
|
112
|
-
sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY })
|
|
113
|
-
internalSubscription?.unsubscribe()
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
// _initEas().then(() => {
|
|
117
|
-
// logger('EAS initialized')
|
|
118
|
-
// })
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
sendBack({ type: GLOBAL_INITIALIZING_SEND_CONFIG, environment })
|
|
122
|
-
|
|
123
|
-
return () => {
|
|
124
|
-
internalSubscription?.unsubscribe()
|
|
125
|
-
easSubscription?.unsubscribe()
|
|
126
|
-
}
|
|
127
|
-
})
|
|
40
|
+
},
|
|
41
|
+
)
|
package/dist/src/queries.ts
CHANGED
|
@@ -1,13 +1,34 @@
|
|
|
1
1
|
import { graphql } from '@/browser/gql'
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
query
|
|
5
|
-
|
|
3
|
+
export const GET_IMAGE_SEEDS = graphql(/* GraphQL */ `
|
|
4
|
+
query GetImageSeeds($where: AttestationWhereInput!) {
|
|
5
|
+
imageSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {
|
|
6
6
|
id
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
decodedDataJson
|
|
8
|
+
attester
|
|
9
|
+
schema {
|
|
10
|
+
schemaNames {
|
|
11
|
+
name
|
|
12
|
+
}
|
|
10
13
|
}
|
|
14
|
+
refUID
|
|
15
|
+
revoked
|
|
16
|
+
schemaId
|
|
17
|
+
txid
|
|
18
|
+
timeCreated
|
|
19
|
+
time
|
|
20
|
+
isOffchain
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`)
|
|
24
|
+
|
|
25
|
+
export const GET_IMAGE_VERSIONS = graphql(/* GraphQL */ `
|
|
26
|
+
query GetImageVersions($where: AttestationWhereInput!) {
|
|
27
|
+
imageVersions: attestations(
|
|
28
|
+
where: $where
|
|
29
|
+
orderBy: [{ timeCreated: desc }]
|
|
30
|
+
) {
|
|
31
|
+
...attestationFields
|
|
11
32
|
}
|
|
12
33
|
}
|
|
13
34
|
`)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydrateFromDb.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/property/actors/hydrateFromDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAOlD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAIzD,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"hydrateFromDb.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/property/actors/hydrateFromDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAOlD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAIzD,eAAO,MAAM,aAAa,uHAkRxB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seedprotocol/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.77",
|
|
4
4
|
"description": "The SDK for Seed Protocol",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/types/src/index.d.ts",
|
|
@@ -87,7 +87,6 @@
|
|
|
87
87
|
"ts-proto": "^2.2.5",
|
|
88
88
|
"tslib": "~2.8.1",
|
|
89
89
|
"use-immer": "^0.10.0",
|
|
90
|
-
"vite": "^5.4.10",
|
|
91
90
|
"xstate": "^5.18.2"
|
|
92
91
|
},
|
|
93
92
|
"devDependencies": {
|
|
@@ -153,6 +152,7 @@
|
|
|
153
152
|
"tailwindcss": "^3.4.14",
|
|
154
153
|
"ts-api-utils": "~1.4.0",
|
|
155
154
|
"typescript": "~5.6.3",
|
|
155
|
+
"vite": "^6.0.3",
|
|
156
156
|
"vite-plugin-dts": "^4.3.0",
|
|
157
157
|
"vite-plugin-node-polyfills": "^0.22.0",
|
|
158
158
|
"vite-plugin-static-copy": "^2.1.0",
|