@seedprotocol/sdk 0.1.90 → 0.1.91
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-4AsvJICt.js → index-B3xp2pDI.js} +6 -6
- package/dist/{index-4AsvJICt.js.map → index-B3xp2pDI.js.map} +1 -1
- package/dist/{index-C4VKEAXQ.js → index-j7sFsIYr.js} +187 -179
- package/dist/index-j7sFsIYr.js.map +1 -0
- package/dist/main.js +5 -5
- package/dist/{seed.schema.config-_TspGuXU.js → seed.schema.config-BRGl01il.js} +6 -6
- package/dist/{seed.schema.config-_TspGuXU.js.map → seed.schema.config-BRGl01il.js.map} +1 -1
- package/dist/src/actors.ts +289 -7
- package/dist/src/analyzeInput.ts +11 -2
- package/dist/src/getPublishPayload.ts +8 -43
- package/dist/src/index.ts +62 -10
- package/dist/types/src/browser/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/types/src/browser/helpers.d.ts +7 -0
- package/dist/types/src/browser/helpers.d.ts.map +1 -1
- package/dist/types/src/browser/property/ItemProperty.d.ts +4 -4
- package/dist/types/src/browser/property/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
- package/dist/types/src/browser/property/propertyMachine.d.ts +8 -8
- package/dist/types/src/browser/services/global/globalMachine.d.ts +22 -22
- package/package.json +1 -1
- package/dist/index-C4VKEAXQ.js.map +0 -1
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-j7sFsIYr.js';
|
|
2
2
|
import 'immer';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import './constants-rmQ8zg8_.js';
|
|
@@ -19,14 +19,14 @@ import '@tanstack/react-query';
|
|
|
19
19
|
import 'graphql-request';
|
|
20
20
|
import '@tanstack/query-sync-storage-persister';
|
|
21
21
|
import '@tanstack/react-query-persist-client';
|
|
22
|
-
import '
|
|
23
|
-
import '@xstate/react';
|
|
24
|
-
import 'eventemitter3';
|
|
22
|
+
import 'rxjs';
|
|
25
23
|
import 'pluralize';
|
|
24
|
+
import 'eventemitter3';
|
|
26
25
|
import '@statelyai/inspect';
|
|
27
|
-
import 'rxjs';
|
|
28
26
|
import 'drizzle-orm/sqlite-proxy';
|
|
29
27
|
import '@zenfs/dom';
|
|
28
|
+
import 'use-immer';
|
|
29
|
+
import '@xstate/react';
|
|
30
30
|
import 'thirdweb';
|
|
31
31
|
import '@ethereum-attestation-service/eas-sdk';
|
|
32
32
|
//# sourceMappingURL=main.js.map
|
|
@@ -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-j7sFsIYr.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'reflect-metadata';
|
|
6
6
|
import 'xstate';
|
|
@@ -21,14 +21,14 @@ import '@tanstack/react-query';
|
|
|
21
21
|
import 'graphql-request';
|
|
22
22
|
import '@tanstack/query-sync-storage-persister';
|
|
23
23
|
import '@tanstack/react-query-persist-client';
|
|
24
|
-
import '
|
|
25
|
-
import '@xstate/react';
|
|
26
|
-
import 'eventemitter3';
|
|
24
|
+
import 'rxjs';
|
|
27
25
|
import 'immer';
|
|
28
26
|
import 'pluralize';
|
|
27
|
+
import 'eventemitter3';
|
|
29
28
|
import '@statelyai/inspect';
|
|
30
|
-
import 'rxjs';
|
|
31
29
|
import 'drizzle-orm/sqlite-proxy';
|
|
30
|
+
import 'use-immer';
|
|
31
|
+
import '@xstate/react';
|
|
32
32
|
|
|
33
33
|
let Seed = class Seed {
|
|
34
34
|
};
|
|
@@ -76,4 +76,4 @@ const models = {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
export { models };
|
|
79
|
-
//# sourceMappingURL=seed.schema.config-
|
|
79
|
+
//# sourceMappingURL=seed.schema.config-BRGl01il.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.schema.config-
|
|
1
|
+
{"version":3,"file":"seed.schema.config-BRGl01il.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;;;;;"}
|
package/dist/src/actors.ts
CHANGED
|
@@ -1,10 +1,292 @@
|
|
|
1
1
|
import { EventObject, fromCallback } from 'xstate'
|
|
2
|
-
import {
|
|
2
|
+
import { fetchAllFilesMachine } from '@/browser/schema/file/fetchAll/index'
|
|
3
|
+
import { ARWEAVE_HOST } from '@/browser/services/internal/constants'
|
|
4
|
+
import { GET_FILES_METADATA } from '@/browser/schema/file/queries'
|
|
5
|
+
import { getArweave } from '../arweave'
|
|
6
|
+
import { fs } from '@zenfs/core'
|
|
7
|
+
import {
|
|
8
|
+
getDataTypeFromString,
|
|
9
|
+
getMimeType,
|
|
10
|
+
identifyString,
|
|
11
|
+
} from '@/shared/helpers'
|
|
12
|
+
import { appState } from 'src/shared/seedSchema'
|
|
13
|
+
import { eq } from 'drizzle-orm'
|
|
14
|
+
import { easClient, queryClient } from '@/browser/helpers'
|
|
15
|
+
import debug from 'debug'
|
|
16
|
+
import { getAppDb } from '@/browser/db/sqlWasmClient'
|
|
3
17
|
|
|
4
|
-
|
|
5
|
-
({ sendBack, receive, input }) => {},
|
|
6
|
-
)
|
|
18
|
+
import { saveAppState } from '@/browser/db/write/saveAppState'
|
|
7
19
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
20
|
+
const logger = debug('app:file:actors:fetchAll')
|
|
21
|
+
|
|
22
|
+
type FileType = {
|
|
23
|
+
mimeType: string
|
|
24
|
+
extension: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Map of common MIME types to file extensions
|
|
28
|
+
const fileTypeMap: Record<string, FileType> = {
|
|
29
|
+
'image/jpeg': { mimeType: 'image/jpeg', extension: '.jpg' },
|
|
30
|
+
'image/png': { mimeType: 'image/png', extension: '.png' },
|
|
31
|
+
'application/json': { mimeType: 'application/json', extension: '.json' },
|
|
32
|
+
'text/plain': { mimeType: 'text/plain', extension: '.txt' },
|
|
33
|
+
// Add more MIME types and file extensions as needed
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const fetchAllMetadataRecords = fromCallback<
|
|
37
|
+
EventObject,
|
|
38
|
+
typeof fetchAllFilesMachine
|
|
39
|
+
>(({ sendBack, receive, input: { context, event } }) => {
|
|
40
|
+
const { addresses } = context
|
|
41
|
+
|
|
42
|
+
const _fetchAllMetadataRecords = async () => {
|
|
43
|
+
const { filesMetadata } = await queryClient.fetchQuery({
|
|
44
|
+
queryKey: ['getFilesMetadata', ...addresses],
|
|
45
|
+
queryFn: async () =>
|
|
46
|
+
easClient.request(GET_FILES_METADATA, {
|
|
47
|
+
where: {
|
|
48
|
+
attester: {
|
|
49
|
+
in: addresses,
|
|
50
|
+
},
|
|
51
|
+
schema: {
|
|
52
|
+
is: {
|
|
53
|
+
id: {
|
|
54
|
+
equals:
|
|
55
|
+
'0x55fdefb36fcbbaebeb7d6b41dc3a1a9666e4e42154267c889de064faa7ede517',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
return filesMetadata
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
_fetchAllMetadataRecords().then((filesMetadata) => {
|
|
67
|
+
sendBack({ type: 'fetchingAllMetadataRecordsSuccess', filesMetadata })
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
return () => {}
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
export const fetchAllBinaryData = fromCallback<
|
|
74
|
+
EventObject,
|
|
75
|
+
typeof fetchAllFilesMachine
|
|
76
|
+
>(({ sendBack, input: { context } }) => {
|
|
77
|
+
const { filesMetadata, addresses } = context
|
|
78
|
+
|
|
79
|
+
const _fetchAllBinaryData = async () => {
|
|
80
|
+
if (!(await fs.promises.exists('/files'))) {
|
|
81
|
+
await fs.promises.mkdir('/files', { recursive: true })
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!(await fs.promises.exists('/files/html'))) {
|
|
85
|
+
await fs.promises.mkdir('/files/html', { recursive: true })
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!(await fs.promises.exists('/files/json'))) {
|
|
89
|
+
await fs.promises.mkdir('/files/json', { recursive: true })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!(await fs.promises.exists('/files/images'))) {
|
|
93
|
+
await fs.promises.mkdir('/files/images', { recursive: true })
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const appDb = getAppDb()
|
|
97
|
+
|
|
98
|
+
if (!appDb) {
|
|
99
|
+
logger('[fetchAll/actors] [fetchAllBinaryData] seedDb not available')
|
|
100
|
+
return []
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
for (const fileMetadata of filesMetadata) {
|
|
104
|
+
const json = JSON.parse(fileMetadata.decodedDataJson)
|
|
105
|
+
const transactionId = json[0].value.value
|
|
106
|
+
|
|
107
|
+
const excludedTransactionsQuery = await appDb
|
|
108
|
+
.select()
|
|
109
|
+
.from(appState)
|
|
110
|
+
.where(eq(appState.key, 'excludedTransactions'))
|
|
111
|
+
|
|
112
|
+
let excludedTransactions = new Set<string>()
|
|
113
|
+
|
|
114
|
+
if (excludedTransactionsQuery && excludedTransactionsQuery.length === 1) {
|
|
115
|
+
const valueString = excludedTransactionsQuery[0].value
|
|
116
|
+
if (valueString) {
|
|
117
|
+
const excludedTransactionsArray = JSON.parse(valueString)
|
|
118
|
+
excludedTransactions = new Set(excludedTransactionsArray)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (excludedTransactions.has(transactionId)) {
|
|
123
|
+
continue
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const arweave = getArweave()
|
|
127
|
+
|
|
128
|
+
if (!arweave) {
|
|
129
|
+
logger('[fetchAll/actors] [fetchAllBinaryData] arweave not available')
|
|
130
|
+
return []
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
const res = await fetch(
|
|
135
|
+
`https://${ARWEAVE_HOST}/tx/${transactionId}/status`,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
if (res.status !== 200) {
|
|
139
|
+
logger(
|
|
140
|
+
`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
excludedTransactions.add(transactionId)
|
|
144
|
+
|
|
145
|
+
await saveAppState(
|
|
146
|
+
'excludedTransactions',
|
|
147
|
+
JSON.stringify(Array.from(excludedTransactions)),
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
logger(
|
|
151
|
+
'[fetchAll/actors] [fetchAllBinaryData] updated excludedTransactions:',
|
|
152
|
+
excludedTransactions,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
continue
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const dataString = await arweave.transactions
|
|
159
|
+
.getData(transactionId, {
|
|
160
|
+
decode: true,
|
|
161
|
+
string: true,
|
|
162
|
+
})
|
|
163
|
+
.catch((error) => {
|
|
164
|
+
logger(
|
|
165
|
+
`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`,
|
|
166
|
+
error,
|
|
167
|
+
)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
const dataUint8Array = await arweave.transactions.getData(transactionId)
|
|
171
|
+
// let buffer
|
|
172
|
+
//
|
|
173
|
+
// if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
|
|
174
|
+
// }
|
|
175
|
+
|
|
176
|
+
let contentType = identifyString(dataString)
|
|
177
|
+
if (
|
|
178
|
+
contentType !== 'json' &&
|
|
179
|
+
contentType !== 'base64' &&
|
|
180
|
+
contentType !== 'html'
|
|
181
|
+
) {
|
|
182
|
+
const possibleImageType = getDataTypeFromString(dataString)
|
|
183
|
+
if (!possibleImageType) {
|
|
184
|
+
logger(
|
|
185
|
+
`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not in expected format: ${possibleImageType}`,
|
|
186
|
+
)
|
|
187
|
+
continue
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
contentType = possibleImageType
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (contentType === 'url') {
|
|
194
|
+
const url = dataString as string
|
|
195
|
+
const response = await fetch(url)
|
|
196
|
+
if (!response.ok) {
|
|
197
|
+
throw new Error(`Failed to fetch image: ${response.statusText}`)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Get the image as a Blob
|
|
201
|
+
const blob = await response.blob()
|
|
202
|
+
const buffer = await blob.arrayBuffer()
|
|
203
|
+
const bufferUint8Array = new Uint8Array(buffer)
|
|
204
|
+
|
|
205
|
+
// Extract the file extension from the URL
|
|
206
|
+
const extensionMatch = url.match(
|
|
207
|
+
/\.(jpg|jpeg|png|gif|bmp|webp|svg)$/i,
|
|
208
|
+
)
|
|
209
|
+
if (!extensionMatch) {
|
|
210
|
+
throw new Error(
|
|
211
|
+
'Unable to determine the file extension from the URL.',
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
const fileExtension = extensionMatch[0] // e.g., ".jpg"
|
|
215
|
+
|
|
216
|
+
// Set the file name (you can customize this)
|
|
217
|
+
// const fileNameFromUrl = `${transactionId}${fileExtension}`
|
|
218
|
+
|
|
219
|
+
await fs.promises.writeFile(
|
|
220
|
+
`/files/images/${transactionId}`,
|
|
221
|
+
bufferUint8Array,
|
|
222
|
+
{
|
|
223
|
+
encoding: 'binary',
|
|
224
|
+
},
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
continue
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let mimeType = getMimeType(dataString as string)
|
|
231
|
+
let fileExtension = mimeType
|
|
232
|
+
|
|
233
|
+
if (fileExtension && fileExtension?.startsWith('image')) {
|
|
234
|
+
fileExtension = fileExtension.replace('image/', '')
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
let fileName = transactionId
|
|
238
|
+
|
|
239
|
+
if (contentType === 'base64') {
|
|
240
|
+
if (mimeType) {
|
|
241
|
+
fileName += `.${fileExtension}`
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Remove the Base64 header if it exists (e.g., "data:image/png;base64,")
|
|
245
|
+
const base64Data = dataString.split(',').pop() || ''
|
|
246
|
+
|
|
247
|
+
// Decode the Base64 string to binary
|
|
248
|
+
const binaryString = atob(base64Data)
|
|
249
|
+
const length = binaryString.length
|
|
250
|
+
const binaryData = new Uint8Array(length)
|
|
251
|
+
|
|
252
|
+
for (let i = 0; i < length; i++) {
|
|
253
|
+
binaryData[i] = binaryString.charCodeAt(i)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
console.log(`attempting to writeFile to /files/images/${fileName}`)
|
|
257
|
+
|
|
258
|
+
await fs.promises.writeFile(`/files/images/${fileName}`, binaryData, {
|
|
259
|
+
encoding: 'binary',
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
// if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
|
|
263
|
+
// await fs.promises.writeFile(
|
|
264
|
+
// `/files/images/${fileName}`,
|
|
265
|
+
// dataUint8Array,
|
|
266
|
+
// )
|
|
267
|
+
// }
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (contentType === 'html') {
|
|
271
|
+
fileName += '.html'
|
|
272
|
+
await fs.promises.writeFile(`/files/html/${fileName}`, dataString)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (contentType === 'json') {
|
|
276
|
+
fileName += '.json'
|
|
277
|
+
await fs.promises.writeFile(`/files/json/${fileName}`, dataString)
|
|
278
|
+
}
|
|
279
|
+
} catch (error) {
|
|
280
|
+
logger(error)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return []
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
_fetchAllBinaryData().then((binaryData) => {
|
|
288
|
+
sendBack({ type: 'fetchingAllBinaryDataSuccess', binaryData })
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
return () => {}
|
|
292
|
+
})
|
package/dist/src/analyzeInput.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
SaveValueToDbEvent,
|
|
7
7
|
} from '@/types/property'
|
|
8
8
|
import { updateItemPropertyValue } from '@/browser/db/write/updateItemPropertyValue'
|
|
9
|
+
import { getSchemaForProperty } from '@/browser/helpers'
|
|
9
10
|
|
|
10
11
|
export const analyzeInput = fromCallback<
|
|
11
12
|
EventObject,
|
|
@@ -20,9 +21,10 @@ export const analyzeInput = fromCallback<
|
|
|
20
21
|
propertyValue: existingValue,
|
|
21
22
|
propertyRecordSchema,
|
|
22
23
|
itemModelName,
|
|
23
|
-
schemaUid,
|
|
24
24
|
} = context
|
|
25
25
|
|
|
26
|
+
let { schemaUid } = context
|
|
27
|
+
|
|
26
28
|
let newValue: ItemPropertyValueType
|
|
27
29
|
|
|
28
30
|
if (event) {
|
|
@@ -75,8 +77,15 @@ export const analyzeInput = fromCallback<
|
|
|
75
77
|
return false
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
if (!schemaUid) {
|
|
81
|
+
const schemaFromEas = await getSchemaForProperty({ propertyName })
|
|
82
|
+
if (schemaFromEas) {
|
|
83
|
+
schemaUid = schemaFromEas.id
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
78
87
|
await updateItemPropertyValue({
|
|
79
|
-
localId
|
|
88
|
+
localId,
|
|
80
89
|
propertyName,
|
|
81
90
|
newValue,
|
|
82
91
|
seedLocalId,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GET_SCHEMAS } from '@/browser'
|
|
2
1
|
import { getItem } from '@/browser/db/read/getItem'
|
|
3
2
|
import {
|
|
4
3
|
defaultAttestationData,
|
|
@@ -10,9 +9,7 @@ import {
|
|
|
10
9
|
AttestationRequest,
|
|
11
10
|
SchemaEncoder,
|
|
12
11
|
} from '@ethereum-attestation-service/eas-sdk'
|
|
13
|
-
import {
|
|
14
|
-
import { toSnakeCase } from '@/shared/helpers'
|
|
15
|
-
import { SchemaWhereInput } from '@/browser/gql/graphql'
|
|
12
|
+
import { getSchemaForProperty } from '@/browser/helpers'
|
|
16
13
|
|
|
17
14
|
type PublishPayload = {
|
|
18
15
|
localId: string
|
|
@@ -45,48 +42,16 @@ export const getPublishPayload = async (
|
|
|
45
42
|
const propertiesToUpdate = []
|
|
46
43
|
|
|
47
44
|
for (const [propertyName, itemProperty] of Object.entries(item.properties)) {
|
|
48
|
-
if (!itemProperty.value) {
|
|
45
|
+
if (!itemProperty.value || !itemProperty.propertyDef) {
|
|
49
46
|
continue
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
where: {
|
|
54
|
-
id: {
|
|
55
|
-
equals: itemProperty.schemaUid,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (!itemProperty.schemaUid) {
|
|
61
|
-
queryParams = {
|
|
62
|
-
where: {
|
|
63
|
-
schemaNames: {
|
|
64
|
-
some: {
|
|
65
|
-
name: {
|
|
66
|
-
equals: toSnakeCase(propertyName),
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
}
|
|
72
|
-
}
|
|
49
|
+
const foundPropertySchema = await getSchemaForProperty(itemProperty)
|
|
73
50
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
!foundPropertySchema ||
|
|
81
|
-
!foundPropertySchema.schemas ||
|
|
82
|
-
foundPropertySchema.schemas.length === 0
|
|
83
|
-
) {
|
|
84
|
-
console.error(`Property schema not found for ${propertyName}`)
|
|
85
|
-
continue
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (!itemProperty.propertyDef) {
|
|
89
|
-
continue
|
|
51
|
+
if (!foundPropertySchema) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`No schema found for property ${itemProperty.propertyName} ${itemProperty.localId}`,
|
|
54
|
+
)
|
|
90
55
|
}
|
|
91
56
|
|
|
92
57
|
const easDataType =
|
|
@@ -96,7 +61,7 @@ export const getPublishPayload = async (
|
|
|
96
61
|
{ name: propertyName, type: easDataType, value: itemProperty.value },
|
|
97
62
|
]
|
|
98
63
|
|
|
99
|
-
const easSchemaDefinition = foundPropertySchema.
|
|
64
|
+
const easSchemaDefinition = foundPropertySchema.schema
|
|
100
65
|
|
|
101
66
|
const dataEncoder = new SchemaEncoder(easSchemaDefinition)
|
|
102
67
|
|
package/dist/src/index.ts
CHANGED
|
@@ -1,21 +1,73 @@
|
|
|
1
|
-
import { setup } from 'xstate'
|
|
1
|
+
import { assign, setup } from 'xstate'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from '@/browser/schema/file/
|
|
3
|
+
fetchAllBinaryData,
|
|
4
|
+
fetchAllMetadataRecords,
|
|
5
|
+
} from '@/browser/schema/file/fetchAll/actors'
|
|
6
|
+
import { Attestation } from '@/browser/gql/graphql'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
type FetchAllFilesMachineContext = {
|
|
9
|
+
addresses: string[]
|
|
10
|
+
dbsLoaded: boolean
|
|
11
|
+
filesMetadata?: Attestation[]
|
|
12
|
+
filesBlobData?: any[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const fetchAllFilesMachine = setup({
|
|
16
|
+
types: {
|
|
17
|
+
context: {} as FetchAllFilesMachineContext,
|
|
18
|
+
},
|
|
8
19
|
actors: {
|
|
9
|
-
|
|
10
|
-
|
|
20
|
+
fetchAllMetadataRecords,
|
|
21
|
+
fetchAllBinaryData,
|
|
11
22
|
},
|
|
12
23
|
}).createMachine({
|
|
13
|
-
id: '
|
|
24
|
+
id: 'fetchAllFiles',
|
|
14
25
|
initial: 'idle',
|
|
15
|
-
context: {
|
|
16
|
-
|
|
26
|
+
context: ({ input }) =>
|
|
27
|
+
({
|
|
28
|
+
...input,
|
|
29
|
+
dbsLoaded: false,
|
|
30
|
+
}) as FetchAllFilesMachineContext,
|
|
31
|
+
on: {
|
|
32
|
+
allDbsLoaded: {
|
|
33
|
+
target: '.fetchingAllMetadataRecords',
|
|
34
|
+
actions: assign({
|
|
35
|
+
dbsLoaded: true,
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
17
38
|
},
|
|
18
39
|
states: {
|
|
19
40
|
idle: {},
|
|
41
|
+
fetchingAllMetadataRecords: {
|
|
42
|
+
on: {
|
|
43
|
+
fetchingAllMetadataRecordsSuccess: {
|
|
44
|
+
target: 'fetchingAllBinaryData',
|
|
45
|
+
actions: assign({
|
|
46
|
+
filesMetadata: ({ event }) => event.filesMetadata,
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
invoke: {
|
|
51
|
+
src: 'fetchAllMetadataRecords',
|
|
52
|
+
input: ({ context, event }) => ({ context, event }),
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
fetchingAllBinaryData: {
|
|
56
|
+
on: {
|
|
57
|
+
fetchingAllBinaryDataSuccess: {
|
|
58
|
+
target: 'success',
|
|
59
|
+
actions: assign({
|
|
60
|
+
filesBlobData: ({ event }) => event.filesBlobData,
|
|
61
|
+
}),
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
invoke: {
|
|
65
|
+
src: 'fetchAllBinaryData',
|
|
66
|
+
input: ({ context }) => ({ context }),
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
success: {
|
|
70
|
+
type: 'final',
|
|
71
|
+
},
|
|
20
72
|
},
|
|
21
73
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPublishPayload.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/db/read/getPublishPayload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPublishPayload.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/db/read/getPublishPayload.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,kBAAkB,EAEnB,MAAM,uCAAuC,CAAA;AAG9C,KAAK,cAAc,GAAG;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,OAAO,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,kBAAkB,EAAE,kBAAkB,EAAE,CAAA;IACxC,kBAAkB,EAAE,GAAG,EAAE,CAAA;CAC1B,CAAA;AAED,KAAK,mBAAmB,GAAG,cAAc,EAAE,CAAA;AAE3C,eAAO,MAAM,iBAAiB,gBACf,MAAM,KAClB,OAAO,CAAC,mBAAmB,CAgE7B,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { GraphQLClient } from 'graphql-request';
|
|
3
3
|
import { ActionFunction } from 'xstate';
|
|
4
|
+
import { Schema } from '@/browser/gql/graphql';
|
|
4
5
|
export declare const queryClient: QueryClient;
|
|
5
6
|
export declare const easClient: GraphQLClient;
|
|
6
7
|
export declare const arweaveClient: GraphQLClient;
|
|
@@ -16,5 +17,11 @@ type UpdateMachineContext = {
|
|
|
16
17
|
actions: ActionFunction<any, any, any, any, any, any, any, any, any>[] | any;
|
|
17
18
|
};
|
|
18
19
|
export declare const updateMachineContext: UpdateMachineContext;
|
|
20
|
+
type GetSchemaForPropertyProps = {
|
|
21
|
+
schemaUid?: string;
|
|
22
|
+
propertyName: string;
|
|
23
|
+
};
|
|
24
|
+
type GetSchemaForProperty = (props: GetSchemaForPropertyProps) => Promise<Schema | void>;
|
|
25
|
+
export declare const getSchemaForProperty: GetSchemaForProperty;
|
|
19
26
|
export {};
|
|
20
27
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/browser/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAU/C,OAAO,EAAE,cAAc,EAAU,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/browser/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAU/C,OAAO,EAAE,cAAc,EAAU,MAAM,QAAQ,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAoB,MAAM,uBAAuB,CAAA;AAIhE,eAAO,MAAM,WAAW,aAOtB,CAAA;AAWF,eAAO,MAAM,SAAS,eAAkC,CAAA;AACxD,eAAO,MAAM,aAAa,eAAsC,CAAA;AAEhE,eAAO,MAAM,eAAe,4CAE3B,CAAA;AAED,KAAK,kBAAkB,GAAG;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,YAAY,GAAG,CAAC,YAAY,EAAE,MAAM,KAAK,kBAAkB,CAAA;AAEhE,eAAO,MAAM,YAAY,EAAE,YAe1B,CAAA;AAED,eAAO,MAAM,qBAAqB,SAC1B,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAQ5B,CAAA;AAED,KAAK,oBAAoB,GAAG;IAC1B,OAAO,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,CAAA;CAC7E,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE,oBAelC,CAAA;AAED,KAAK,yBAAyB,GAAG;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,oBAAoB,GAAG,CAC1B,KAAK,EAAE,yBAAyB,KAC7B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;AAE3B,eAAO,MAAM,oBAAoB,EAAE,oBAmClC,CAAA"}
|
|
@@ -34,13 +34,13 @@ export declare class ItemProperty<PropertyType> {
|
|
|
34
34
|
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<PropertyMachineContext>, import("xstate").EventObject>;
|
|
35
35
|
id: string | undefined;
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
src: "
|
|
37
|
+
hydrateFromDb: {
|
|
38
|
+
src: "hydrateFromDb";
|
|
39
39
|
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<PropertyMachineContext, import("xstate").EventObject>, import("xstate").EventObject>;
|
|
40
40
|
id: string | undefined;
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
src: "
|
|
42
|
+
initialize: {
|
|
43
|
+
src: "initialize";
|
|
44
44
|
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<PropertyMachineContext, import("xstate").EventObject>, import("xstate").EventObject>;
|
|
45
45
|
id: string | undefined;
|
|
46
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeInput.d.ts","sourceRoot":"","sources":["../../../../../../../src/browser/property/actors/saveValueToDb/analyzeInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"analyzeInput.d.ts","sourceRoot":"","sources":["../../../../../../../src/browser/property/actors/saveValueToDb/analyzeInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,kBAAkB,CAAA;AAIzB,eAAO,MAAM,YAAY,8HAoGvB,CAAA"}
|
|
@@ -7,13 +7,13 @@ export declare const propertyMachine: import("xstate").StateMachine<PropertyMach
|
|
|
7
7
|
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<PropertyMachineContext>, import("xstate").EventObject>;
|
|
8
8
|
id: string | undefined;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
src: "
|
|
10
|
+
hydrateFromDb: {
|
|
11
|
+
src: "hydrateFromDb";
|
|
12
12
|
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<PropertyMachineContext, import("xstate").EventObject>, import("xstate").EventObject>;
|
|
13
13
|
id: string | undefined;
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
src: "
|
|
15
|
+
initialize: {
|
|
16
|
+
src: "initialize";
|
|
17
17
|
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<PropertyMachineContext, import("xstate").EventObject>, import("xstate").EventObject>;
|
|
18
18
|
id: string | undefined;
|
|
19
19
|
};
|
|
@@ -53,13 +53,13 @@ export declare const propertyMachine: import("xstate").StateMachine<PropertyMach
|
|
|
53
53
|
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<PropertyMachineContext>, import("xstate").EventObject>;
|
|
54
54
|
id: string | undefined;
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
src: "
|
|
56
|
+
hydrateFromDb: {
|
|
57
|
+
src: "hydrateFromDb";
|
|
58
58
|
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<PropertyMachineContext, import("xstate").EventObject>, import("xstate").EventObject>;
|
|
59
59
|
id: string | undefined;
|
|
60
60
|
};
|
|
61
|
-
|
|
62
|
-
src: "
|
|
61
|
+
initialize: {
|
|
62
|
+
src: "initialize";
|
|
63
63
|
logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<PropertyMachineContext, import("xstate").EventObject>, import("xstate").EventObject>;
|
|
64
64
|
id: string | undefined;
|
|
65
65
|
};
|