@seedprotocol/sdk 0.2.4 → 0.2.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/dist/{Item-D_fRE67b.js → Item-5bbmH1H4.js} +2 -2
- package/dist/{Item-D_fRE67b.js.map → Item-5bbmH1H4.js.map} +1 -1
- package/dist/{index-DpAde4Hk.js → index-CoqbOXfg.js} +2 -2
- package/dist/index-CoqbOXfg.js.map +1 -0
- package/dist/{index-CaMCzFrd.js → index-s_H8DdLb.js} +59 -55
- package/dist/index-s_H8DdLb.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-DrU0-rhL.js → seed.schema.config-CTpDY6LU.js} +2 -2
- package/dist/{seed.schema.config-DrU0-rhL.js.map → seed.schema.config-CTpDY6LU.js.map} +1 -1
- package/dist/src/actors.ts +292 -7
- package/dist/src/addModelsToDb.ts +3 -3
- package/dist/src/fetchVersions.ts +3 -3
- package/dist/src/getModelSchemas.ts +3 -3
- package/dist/src/getSchemaForItemProperty.ts +3 -2
- package/dist/src/getSchemaUidForModel.ts +3 -3
- package/dist/src/index.ts +4 -21
- package/dist/src/itemMachineSingle.ts +4 -4
- package/dist/src/queries.ts +37 -25
- package/dist/src/syncDbWithEas.ts +10 -2
- package/dist/types/src/Item/service/actors/initialize.d.ts +2 -1
- package/dist/types/src/Item/service/actors/initialize.d.ts.map +1 -1
- package/dist/types/src/browser/schema/file/download/actors.d.ts.map +1 -1
- package/dist/types/src/browser/schema/file/fetchAll/actors.d.ts.map +1 -1
- package/dist/types/src/db/read/getModelSchemas.d.ts.map +1 -1
- package/dist/types/src/db/read/getSchemaUidForModel.d.ts.map +1 -1
- package/dist/types/src/events/item/syncDbWithEas.d.ts.map +1 -1
- package/dist/types/src/helpers/getSchemaForItemProperty.d.ts.map +1 -1
- package/dist/types/src/services/allItems/actors/fetchVersions.d.ts.map +1 -1
- package/dist/types/src/services/global/actors/addModelsToDb.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-CaMCzFrd.js.map +0 -1
- package/dist/index-DpAde4Hk.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'immer';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
export { l as BaseFileManager, a as ImageSrc, I as Item, b as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, n as client, m as eventEmitter, k as getCorrectId, j as getGlobalService, e as useCreateItem, g as useDeleteItem, h as useGlobalServiceStatus, c as useItem, d as useItemProperties, f as useItemProperty, u as useItems, i as useServices, w as withSeed } from './index-
|
|
3
|
+
export { l as BaseFileManager, a as ImageSrc, I as Item, b as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, n as client, m as eventEmitter, k as getCorrectId, j as getGlobalService, e as useCreateItem, g as useDeleteItem, h as useGlobalServiceStatus, c as useItem, d as useItemProperties, f as useItemProperty, u as useItems, i as useServices, w as withSeed } from './index-s_H8DdLb.js';
|
|
4
4
|
import 'tslib';
|
|
5
5
|
import 'xstate';
|
|
6
6
|
import 'arweave';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
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-s_H8DdLb.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'reflect-metadata';
|
|
6
6
|
import 'xstate';
|
|
@@ -75,4 +75,4 @@ const models = {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
export { models };
|
|
78
|
-
//# sourceMappingURL=seed.schema.config-
|
|
78
|
+
//# sourceMappingURL=seed.schema.config-CTpDY6LU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.schema.config-
|
|
1
|
+
{"version":3,"file":"seed.schema.config-CTpDY6LU.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,295 @@
|
|
|
1
1
|
import { EventObject, fromCallback } from 'xstate'
|
|
2
|
-
import {
|
|
2
|
+
import { fetchAllFilesMachine } from '@/browser/schema/file/fetchAll/index'
|
|
3
|
+
import { ARWEAVE_HOST } from '@/services/internal/constants'
|
|
4
|
+
import { GET_FILES_METADATA } from '@/browser/schema/file/queries'
|
|
5
|
+
import { getArweave } from '@/browser/helpers/arweave'
|
|
6
|
+
import { fs } from '@zenfs/core'
|
|
7
|
+
import {
|
|
8
|
+
getDataTypeFromString,
|
|
9
|
+
getMimeType,
|
|
10
|
+
identifyString,
|
|
11
|
+
} from '@/helpers'
|
|
12
|
+
import { appState } from '@/seedSchema'
|
|
13
|
+
import { eq } from 'drizzle-orm'
|
|
14
|
+
import { BaseEasClient } from '@/helpers/BaseEasClient'
|
|
15
|
+
import { BaseQueryClient } from '@/helpers/BaseQueryClient'
|
|
16
|
+
import debug from 'debug'
|
|
17
|
+
import { BaseDb } from '@/db/BaseDb'
|
|
18
|
+
import { saveAppState } from '@/db/write/saveAppState'
|
|
3
19
|
|
|
4
|
-
|
|
5
|
-
({ sendBack, receive, input }) => {},
|
|
6
|
-
)
|
|
20
|
+
const logger = debug('app:file:actors:fetchAll')
|
|
7
21
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 queryClient = BaseQueryClient.getQueryClient()
|
|
44
|
+
const easClient = BaseEasClient.getEasClient()
|
|
45
|
+
|
|
46
|
+
const { filesMetadata } = await queryClient.fetchQuery({
|
|
47
|
+
queryKey: ['getFilesMetadata', ...addresses],
|
|
48
|
+
queryFn: async () =>
|
|
49
|
+
easClient.request(GET_FILES_METADATA, {
|
|
50
|
+
where: {
|
|
51
|
+
attester: {
|
|
52
|
+
in: addresses,
|
|
53
|
+
},
|
|
54
|
+
schema: {
|
|
55
|
+
is: {
|
|
56
|
+
id: {
|
|
57
|
+
equals:
|
|
58
|
+
'0x55fdefb36fcbbaebeb7d6b41dc3a1a9666e4e42154267c889de064faa7ede517',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
return filesMetadata
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_fetchAllMetadataRecords().then((filesMetadata) => {
|
|
70
|
+
sendBack({ type: 'fetchingAllMetadataRecordsSuccess', filesMetadata })
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
return () => { }
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
export const fetchAllBinaryData = fromCallback<
|
|
77
|
+
EventObject,
|
|
78
|
+
typeof fetchAllFilesMachine
|
|
79
|
+
>(({ sendBack, input: { context } }) => {
|
|
80
|
+
const { filesMetadata, addresses } = context
|
|
81
|
+
|
|
82
|
+
const _fetchAllBinaryData = async () => {
|
|
83
|
+
if (!(await fs.promises.exists('/files'))) {
|
|
84
|
+
await fs.promises.mkdir('/files', { recursive: true })
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!(await fs.promises.exists('/files/html'))) {
|
|
88
|
+
await fs.promises.mkdir('/files/html', { recursive: true })
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!(await fs.promises.exists('/files/json'))) {
|
|
92
|
+
await fs.promises.mkdir('/files/json', { recursive: true })
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!(await fs.promises.exists('/files/images'))) {
|
|
96
|
+
await fs.promises.mkdir('/files/images', { recursive: true })
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const appDb = BaseDb.getAppDb()
|
|
100
|
+
|
|
101
|
+
if (!appDb) {
|
|
102
|
+
logger('[fetchAll/actors] [fetchAllBinaryData] seedDb not available')
|
|
103
|
+
return []
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
for (const fileMetadata of filesMetadata) {
|
|
107
|
+
const json = JSON.parse(fileMetadata.decodedDataJson)
|
|
108
|
+
const transactionId = json[0].value.value
|
|
109
|
+
|
|
110
|
+
const excludedTransactionsQuery = await appDb
|
|
111
|
+
.select()
|
|
112
|
+
.from(appState)
|
|
113
|
+
.where(eq(appState.key, 'excludedTransactions'))
|
|
114
|
+
|
|
115
|
+
let excludedTransactions = new Set<string>()
|
|
116
|
+
|
|
117
|
+
if (excludedTransactionsQuery && excludedTransactionsQuery.length === 1) {
|
|
118
|
+
const valueString = excludedTransactionsQuery[0].value
|
|
119
|
+
if (valueString) {
|
|
120
|
+
const excludedTransactionsArray = JSON.parse(valueString)
|
|
121
|
+
excludedTransactions = new Set(excludedTransactionsArray)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (excludedTransactions.has(transactionId)) {
|
|
126
|
+
continue
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const arweave = getArweave()
|
|
130
|
+
|
|
131
|
+
if (!arweave) {
|
|
132
|
+
logger('[fetchAll/actors] [fetchAllBinaryData] arweave not available')
|
|
133
|
+
return []
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
const res = await fetch(
|
|
138
|
+
`https://${ARWEAVE_HOST}/tx/${transactionId}/status`,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
if (res.status !== 200) {
|
|
142
|
+
logger(
|
|
143
|
+
`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
excludedTransactions.add(transactionId)
|
|
147
|
+
|
|
148
|
+
await saveAppState(
|
|
149
|
+
'excludedTransactions',
|
|
150
|
+
JSON.stringify(Array.from(excludedTransactions)),
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
logger(
|
|
154
|
+
'[fetchAll/actors] [fetchAllBinaryData] updated excludedTransactions:',
|
|
155
|
+
excludedTransactions,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
continue
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const dataString = await arweave.transactions
|
|
162
|
+
.getData(transactionId, {
|
|
163
|
+
decode: true,
|
|
164
|
+
string: true,
|
|
165
|
+
})
|
|
166
|
+
.catch((error) => {
|
|
167
|
+
logger(
|
|
168
|
+
`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`,
|
|
169
|
+
error,
|
|
170
|
+
)
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
const dataUint8Array = await arweave.transactions.getData(transactionId)
|
|
174
|
+
// let buffer
|
|
175
|
+
//
|
|
176
|
+
// if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
|
|
177
|
+
// }
|
|
178
|
+
|
|
179
|
+
let contentType = identifyString(dataString)
|
|
180
|
+
if (
|
|
181
|
+
contentType !== 'json' &&
|
|
182
|
+
contentType !== 'base64' &&
|
|
183
|
+
contentType !== 'html'
|
|
184
|
+
) {
|
|
185
|
+
const possibleImageType = getDataTypeFromString(dataString)
|
|
186
|
+
if (!possibleImageType) {
|
|
187
|
+
logger(
|
|
188
|
+
`[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not in expected format: ${possibleImageType}`,
|
|
189
|
+
)
|
|
190
|
+
continue
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
contentType = possibleImageType
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (contentType === 'url') {
|
|
197
|
+
const url = dataString as string
|
|
198
|
+
const response = await fetch(url)
|
|
199
|
+
if (!response.ok) {
|
|
200
|
+
throw new Error(`Failed to fetch image: ${response.statusText}`)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Get the image as a Blob
|
|
204
|
+
const blob = await response.blob()
|
|
205
|
+
const buffer = await blob.arrayBuffer()
|
|
206
|
+
const bufferUint8Array = new Uint8Array(buffer)
|
|
207
|
+
|
|
208
|
+
// Extract the file extension from the URL
|
|
209
|
+
const extensionMatch = url.match(
|
|
210
|
+
/\.(jpg|jpeg|png|gif|bmp|webp|svg)$/i,
|
|
211
|
+
)
|
|
212
|
+
if (!extensionMatch) {
|
|
213
|
+
throw new Error(
|
|
214
|
+
'Unable to determine the file extension from the URL.',
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
const fileExtension = extensionMatch[0] // e.g., ".jpg"
|
|
218
|
+
|
|
219
|
+
// Set the file name (you can customize this)
|
|
220
|
+
// const fileNameFromUrl = `${transactionId}${fileExtension}`
|
|
221
|
+
|
|
222
|
+
await fs.promises.writeFile(
|
|
223
|
+
`/files/images/${transactionId}`,
|
|
224
|
+
bufferUint8Array,
|
|
225
|
+
{
|
|
226
|
+
encoding: 'binary',
|
|
227
|
+
},
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
continue
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
let mimeType = getMimeType(dataString as string)
|
|
234
|
+
let fileExtension = mimeType
|
|
235
|
+
|
|
236
|
+
if (fileExtension && fileExtension?.startsWith('image')) {
|
|
237
|
+
fileExtension = fileExtension.replace('image/', '')
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
let fileName = transactionId
|
|
241
|
+
|
|
242
|
+
if (contentType === 'base64') {
|
|
243
|
+
if (mimeType) {
|
|
244
|
+
fileName += `.${fileExtension}`
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Remove the Base64 header if it exists (e.g., "data:image/png;base64,")
|
|
248
|
+
const base64Data = dataString.split(',').pop() || ''
|
|
249
|
+
|
|
250
|
+
// Decode the Base64 string to binary
|
|
251
|
+
const binaryString = atob(base64Data)
|
|
252
|
+
const length = binaryString.length
|
|
253
|
+
const binaryData = new Uint8Array(length)
|
|
254
|
+
|
|
255
|
+
for (let i = 0; i < length; i++) {
|
|
256
|
+
binaryData[i] = binaryString.charCodeAt(i)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
console.log(`attempting to writeFile to /files/images/${fileName}`)
|
|
260
|
+
|
|
261
|
+
await fs.promises.writeFile(`/files/images/${fileName}`, binaryData, {
|
|
262
|
+
encoding: 'binary',
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
// if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
|
|
266
|
+
// await fs.promises.writeFile(
|
|
267
|
+
// `/files/images/${fileName}`,
|
|
268
|
+
// dataUint8Array,
|
|
269
|
+
// )
|
|
270
|
+
// }
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (contentType === 'html') {
|
|
274
|
+
fileName += '.html'
|
|
275
|
+
await fs.promises.writeFile(`/files/html/${fileName}`, dataString)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (contentType === 'json') {
|
|
279
|
+
fileName += '.json'
|
|
280
|
+
await fs.promises.writeFile(`/files/json/${fileName}`, dataString)
|
|
281
|
+
}
|
|
282
|
+
} catch (error) {
|
|
283
|
+
logger(error)
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return []
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
_fetchAllBinaryData().then((binaryData) => {
|
|
291
|
+
sendBack({ type: 'fetchingAllBinaryDataSuccess', binaryData })
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
return () => { }
|
|
295
|
+
})
|
|
@@ -9,9 +9,6 @@ import { FromCallbackInput, GlobalMachineContext } from '@/types'
|
|
|
9
9
|
import debug from 'debug'
|
|
10
10
|
import { GET_SCHEMAS } from '@/Item/queries'
|
|
11
11
|
|
|
12
|
-
const easClient = BaseEasClient.getEasClient()
|
|
13
|
-
const queryClient = BaseQueryClient.getQueryClient()
|
|
14
|
-
|
|
15
12
|
const logger = debug('app:services:global:actors:addModelsToDb')
|
|
16
13
|
|
|
17
14
|
export const addModelsToDb = fromCallback<
|
|
@@ -101,6 +98,9 @@ export const addModelsToDb = fromCallback<
|
|
|
101
98
|
({ schemaDef }) => schemaDef,
|
|
102
99
|
)
|
|
103
100
|
|
|
101
|
+
const queryClient = BaseQueryClient.getQueryClient()
|
|
102
|
+
const easClient = BaseEasClient.getEasClient()
|
|
103
|
+
|
|
104
104
|
const { schemas } = await queryClient.fetchQuery({
|
|
105
105
|
queryKey: [`getSchemasVersion`],
|
|
106
106
|
queryFn: async () =>
|
|
@@ -5,9 +5,6 @@ import { Attestation } from '@/graphql/gql/graphql'
|
|
|
5
5
|
import { BaseEasClient } from '@/helpers/BaseEasClient'
|
|
6
6
|
import { BaseQueryClient } from '@/helpers/BaseQueryClient'
|
|
7
7
|
|
|
8
|
-
const easClient = BaseEasClient.getEasClient()
|
|
9
|
-
const queryClient = BaseQueryClient.getQueryClient()
|
|
10
|
-
|
|
11
8
|
|
|
12
9
|
export const fetchVersions = fromCallback<
|
|
13
10
|
EventObject,
|
|
@@ -23,6 +20,9 @@ export const fetchVersions = fromCallback<
|
|
|
23
20
|
let itemVersions: Attestation[] | undefined
|
|
24
21
|
|
|
25
22
|
const _fetchVersions = async () => {
|
|
23
|
+
const queryClient = BaseQueryClient.getQueryClient()
|
|
24
|
+
const easClient = BaseEasClient.getEasClient()
|
|
25
|
+
|
|
26
26
|
const seedIds = itemSeeds.map((seed) => seed.id)
|
|
27
27
|
|
|
28
28
|
const results = await queryClient.fetchQuery({
|
|
@@ -9,9 +9,6 @@ import { GET_SCHEMAS } from '@/Item/queries'
|
|
|
9
9
|
import { BaseEasClient } from '@/helpers/BaseEasClient'
|
|
10
10
|
import { BaseQueryClient } from '@/helpers/BaseQueryClient'
|
|
11
11
|
|
|
12
|
-
const easClient = BaseEasClient.getEasClient()
|
|
13
|
-
const queryClient = BaseQueryClient.getQueryClient()
|
|
14
|
-
|
|
15
12
|
|
|
16
13
|
type GetModelSchemasReturn = {
|
|
17
14
|
modelSchemas: GetSchemasQuery
|
|
@@ -71,6 +68,9 @@ export const getModelSchemas: GetModelSchemas = async () => {
|
|
|
71
68
|
schemaStringToModelRecord.set(schemaString, foundModel)
|
|
72
69
|
}
|
|
73
70
|
|
|
71
|
+
const queryClient = BaseQueryClient.getQueryClient()
|
|
72
|
+
const easClient = BaseEasClient.getEasClient()
|
|
73
|
+
|
|
74
74
|
const modelSchemas = await queryClient.fetchQuery({
|
|
75
75
|
queryKey: [`getSchemasAllModels`],
|
|
76
76
|
queryFn: async () =>
|
|
@@ -3,8 +3,6 @@ import { toSnakeCase, BaseEasClient, BaseQueryClient } from '@/helpers'
|
|
|
3
3
|
import { GET_SCHEMAS } from '@/Item/queries'
|
|
4
4
|
import { TypedData } from '@ethereum-attestation-service/eas-sdk/dist/offchain/typed-data-handler'
|
|
5
5
|
|
|
6
|
-
const easClient = BaseEasClient.getEasClient()
|
|
7
|
-
const queryClient = BaseQueryClient.getQueryClient()
|
|
8
6
|
|
|
9
7
|
type GetSchemaForPropertyProps = {
|
|
10
8
|
schemaUid?: string
|
|
@@ -23,6 +21,9 @@ export const getSchemaForItemProperty: GetSchemaForProperty = async ({
|
|
|
23
21
|
const isMissingSchemaUid =
|
|
24
22
|
!schemaUid || schemaUid === 'null' || schemaUid === 'undefined'
|
|
25
23
|
|
|
24
|
+
const queryClient = BaseQueryClient.getQueryClient()
|
|
25
|
+
const easClient = BaseEasClient.getEasClient()
|
|
26
|
+
|
|
26
27
|
let queryParams: { where: SchemaWhereInput } = {
|
|
27
28
|
where: {
|
|
28
29
|
id: {
|
|
@@ -2,13 +2,13 @@ import { GET_SCHEMAS } from '@/Item/queries'
|
|
|
2
2
|
import { BaseEasClient } from '@/helpers/BaseEasClient'
|
|
3
3
|
import { BaseQueryClient } from '@/helpers/BaseQueryClient'
|
|
4
4
|
|
|
5
|
-
const easClient = BaseEasClient.getEasClient()
|
|
6
|
-
const queryClient = BaseQueryClient.getQueryClient()
|
|
7
|
-
|
|
8
5
|
|
|
9
6
|
export const getSchemaUidForModel = async (
|
|
10
7
|
modelName: string,
|
|
11
8
|
): Promise<string> => {
|
|
9
|
+
const queryClient = BaseQueryClient.getQueryClient()
|
|
10
|
+
const easClient = BaseEasClient.getEasClient()
|
|
11
|
+
|
|
12
12
|
const modeType = modelName.toLowerCase()
|
|
13
13
|
|
|
14
14
|
const modelSchemaQuery = await queryClient.fetchQuery({
|
package/dist/src/index.ts
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from '@/browser/schema/file/upload/actors'
|
|
6
|
-
|
|
7
|
-
export const uploadMachine = setup({
|
|
8
|
-
actors: {
|
|
9
|
-
uploadBinaryData,
|
|
10
|
-
uploadMetadata,
|
|
11
|
-
},
|
|
12
|
-
}).createMachine({
|
|
13
|
-
id: 'upload',
|
|
14
|
-
initial: 'idle',
|
|
15
|
-
context: {
|
|
16
|
-
file: '',
|
|
17
|
-
},
|
|
18
|
-
states: {
|
|
19
|
-
idle: {},
|
|
20
|
-
},
|
|
21
|
-
})
|
|
1
|
+
export * from './analyzeInput'
|
|
2
|
+
export * from './saveImageSrc'
|
|
3
|
+
export * from './saveRelation'
|
|
4
|
+
export * from './saveItemStorage'
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { assign, setup } from 'xstate'
|
|
2
2
|
import { MachineIds } from '@/services/internal/constants'
|
|
3
3
|
import { ItemMachineContext } from '@/types'
|
|
4
|
-
import { ItemProperty } from '../../property'
|
|
5
4
|
import { waitForDb } from './actors/waitForDb'
|
|
6
5
|
import { initialize } from './actors/initialize'
|
|
7
6
|
import { hydrateExistingItem } from './actors/hydrateExistingItem'
|
|
8
7
|
import { hydrateNewItem } from './actors/hydrateNewItem'
|
|
9
8
|
import { fetchDataFromEas } from './actors/fetchDataFromEas'
|
|
10
9
|
import { reload } from './actors/reload'
|
|
10
|
+
import { IItemProperty } from '@/interfaces'
|
|
11
11
|
|
|
12
12
|
export const itemMachineSingle = setup({
|
|
13
13
|
types: {
|
|
@@ -46,7 +46,7 @@ export const itemMachineSingle = setup({
|
|
|
46
46
|
actions: assign(({ event, context }) => {
|
|
47
47
|
let { propertyInstances } = context
|
|
48
48
|
if (!propertyInstances) {
|
|
49
|
-
propertyInstances = new Map<string,
|
|
49
|
+
propertyInstances = new Map<string, IItemProperty<any>>()
|
|
50
50
|
}
|
|
51
51
|
const { propertyName, propertyValue } = event
|
|
52
52
|
|
|
@@ -57,7 +57,7 @@ export const itemMachineSingle = setup({
|
|
|
57
57
|
}
|
|
58
58
|
const propertyInstance = propertyInstances.get(
|
|
59
59
|
propertyName,
|
|
60
|
-
) as
|
|
60
|
+
) as IItemProperty<any>
|
|
61
61
|
|
|
62
62
|
propertyInstance.value = propertyValue
|
|
63
63
|
propertyInstances.set(propertyName, propertyInstance)
|
|
@@ -70,7 +70,7 @@ export const itemMachineSingle = setup({
|
|
|
70
70
|
addPropertyInstance: {
|
|
71
71
|
actions: assign(({ context, event }) => {
|
|
72
72
|
const propertyInstances =
|
|
73
|
-
context.propertyInstances || new Map<string,
|
|
73
|
+
context.propertyInstances || new Map<string, IItemProperty<any>>()
|
|
74
74
|
propertyInstances.set(event.propertyName, event.propertyInstance)
|
|
75
75
|
return {
|
|
76
76
|
propertyInstances,
|
package/dist/src/queries.ts
CHANGED
|
@@ -1,30 +1,8 @@
|
|
|
1
1
|
import { graphql } from '@/graphql/gql'
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
query
|
|
5
|
-
|
|
6
|
-
id
|
|
7
|
-
decodedDataJson
|
|
8
|
-
attester
|
|
9
|
-
schema {
|
|
10
|
-
schemaNames {
|
|
11
|
-
name
|
|
12
|
-
}
|
|
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(
|
|
3
|
+
export const GET_FILES_METADATA = graphql(/* GraphQL */ `
|
|
4
|
+
query GetFilesMetadata($where: AttestationWhereInput!) {
|
|
5
|
+
filesMetadata: attestations(
|
|
28
6
|
where: $where
|
|
29
7
|
orderBy: [{ timeCreated: desc }]
|
|
30
8
|
) {
|
|
@@ -32,3 +10,37 @@ export const GET_IMAGE_VERSIONS = graphql(/* GraphQL */ `
|
|
|
32
10
|
}
|
|
33
11
|
}
|
|
34
12
|
`)
|
|
13
|
+
|
|
14
|
+
export const GET_ARWEAVE_TRANSACTIONS = graphql(/* GraphQL */ `
|
|
15
|
+
query GetArweaveTransactions(
|
|
16
|
+
$owners: [String!]
|
|
17
|
+
$first: Int
|
|
18
|
+
$after: String
|
|
19
|
+
) {
|
|
20
|
+
transactions(owners: $owners, first: $first, after: $after) {
|
|
21
|
+
edges {
|
|
22
|
+
cursor
|
|
23
|
+
node {
|
|
24
|
+
id
|
|
25
|
+
anchor
|
|
26
|
+
signature
|
|
27
|
+
block {
|
|
28
|
+
id
|
|
29
|
+
height
|
|
30
|
+
}
|
|
31
|
+
data {
|
|
32
|
+
size
|
|
33
|
+
type
|
|
34
|
+
}
|
|
35
|
+
tags {
|
|
36
|
+
name
|
|
37
|
+
value
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
pageInfo {
|
|
42
|
+
hasNextPage
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`)
|
|
@@ -35,8 +35,7 @@ import { BaseEasClient } from '@/helpers/BaseEasClient'
|
|
|
35
35
|
import { BaseQueryClient } from '@/helpers/BaseQueryClient'
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
const easClient = BaseEasClient.getEasClient()
|
|
38
|
+
|
|
40
39
|
|
|
41
40
|
const relationValuesToExclude = [
|
|
42
41
|
'0x0000000000000000000000000000000000000000000000000000000000000020',
|
|
@@ -87,6 +86,9 @@ const processPropertiesFoundInDb = async ({ foundModel }) => {
|
|
|
87
86
|
|
|
88
87
|
const modelName = foundModel.name
|
|
89
88
|
|
|
89
|
+
const queryClient = BaseQueryClient.getQueryClient()
|
|
90
|
+
const easClient = BaseEasClient.getEasClient()
|
|
91
|
+
|
|
90
92
|
const foundPropertySchemas = await queryClient.fetchQuery({
|
|
91
93
|
queryKey: [`getPropertySchemas${modelName}`],
|
|
92
94
|
queryFn: async () => easClient.request(GET_SCHEMAS, queryVariables),
|
|
@@ -141,6 +143,9 @@ const getSeedsFromSchemaUids = async ({ schemaUids, addresses }) => {
|
|
|
141
143
|
})
|
|
142
144
|
}
|
|
143
145
|
|
|
146
|
+
const queryClient = BaseQueryClient.getQueryClient()
|
|
147
|
+
const easClient = BaseEasClient.getEasClient()
|
|
148
|
+
|
|
144
149
|
const { itemSeeds } = await queryClient.fetchQuery({
|
|
145
150
|
queryKey: [`getSeedsForAllModels`],
|
|
146
151
|
queryFn: async () =>
|
|
@@ -571,6 +576,9 @@ const saveEasPropertiesToDb: SaveEasPropertiesToDb = async ({
|
|
|
571
576
|
}
|
|
572
577
|
|
|
573
578
|
const getRelatedSeedsAndVersions = async () => {
|
|
579
|
+
const queryClient = BaseQueryClient.getQueryClient()
|
|
580
|
+
const easClient = BaseEasClient.getEasClient()
|
|
581
|
+
|
|
574
582
|
const { itemSeeds } = await easClient.request(GET_SEEDS, {
|
|
575
583
|
where: {
|
|
576
584
|
id: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { EventObject } from 'xstate';
|
|
2
|
-
|
|
2
|
+
import { FromCallbackInput, ItemMachineContext } from '@/types';
|
|
3
|
+
export declare const initialize: import("xstate").CallbackActorLogic<EventObject, FromCallbackInput<EventObject, ItemMachineContext<any>>, EventObject>;
|
|
3
4
|
//# sourceMappingURL=initialize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../../../../src/Item/service/actors/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../../../../src/Item/service/actors/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAGlD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE/D,eAAO,MAAM,UAAU,wHAsCtB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../../../../../../src/browser/schema/file/download/actors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../../../../../../src/browser/schema/file/download/actors.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa,KAgCzB,CAAA;AAED,eAAO,MAAM,eAAe,KAe1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../../../../../../src/browser/schema/file/fetchAll/actors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actors.d.ts","sourceRoot":"","sources":["../../../../../../../src/browser/schema/file/fetchAll/actors.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,uBAAuB,KAsClC,CAAA;AAEF,eAAO,MAAM,kBAAkB,KA2N7B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getModelSchemas.d.ts","sourceRoot":"","sources":["../../../../../src/db/read/getModelSchemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"getModelSchemas.d.ts","sourceRoot":"","sources":["../../../../../src/db/read/getModelSchemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAW/D,KAAK,qBAAqB,GAAG;IAC3B,YAAY,EAAE,eAAe,CAAA;IAC7B,yBAAyB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACtC,CAAA;AAED,KAAK,eAAe,GAAG,MAAM,OAAO,CAAC,qBAAqB,CAAC,CAAA;AAE3D,eAAO,MAAM,eAAe,EAAE,eAoE7B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSchemaUidForModel.d.ts","sourceRoot":"","sources":["../../../../../src/db/read/getSchemaUidForModel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getSchemaUidForModel.d.ts","sourceRoot":"","sources":["../../../../../src/db/read/getSchemaUidForModel.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB,cACpB,MAAM,KAChB,OAAO,CAAC,MAAM,CAwBhB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syncDbWithEas.d.ts","sourceRoot":"","sources":["../../../../../src/events/item/syncDbWithEas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAuB,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"syncDbWithEas.d.ts","sourceRoot":"","sources":["../../../../../src/events/item/syncDbWithEas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAuB,MAAM,WAAW,CAAA;AAymBzE,QAAA,MAAM,oBAAoB,EAAE,aAAa,CAAC,GAAG,CA+F5C,CAAA;AAED,OAAO,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSchemaForItemProperty.d.ts","sourceRoot":"","sources":["../../../../src/helpers/getSchemaForItemProperty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,uBAAuB,CAAA;AAGhE,OAAO,EAAE,SAAS,EAAE,MAAM,wEAAwE,CAAA;
|
|
1
|
+
{"version":3,"file":"getSchemaForItemProperty.d.ts","sourceRoot":"","sources":["../../../../src/helpers/getSchemaForItemProperty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,uBAAuB,CAAA;AAGhE,OAAO,EAAE,SAAS,EAAE,MAAM,wEAAwE,CAAA;AAGlG,KAAK,yBAAyB,GAAG;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;CAChC,CAAA;AACD,KAAK,oBAAoB,GAAG,CAC1B,KAAK,EAAE,yBAAyB,KAC7B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;AAC3B,eAAO,MAAM,wBAAwB,EAAE,oBAqDtC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchVersions.d.ts","sourceRoot":"","sources":["../../../../../../src/services/allItems/actors/fetchVersions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAElD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"fetchVersions.d.ts","sourceRoot":"","sources":["../../../../../../src/services/allItems/actors/fetchVersions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAElD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAMnE,eAAO,MAAM,aAAa,uHAwCzB,CAAA"}
|