@seedprotocol/sdk 0.1.107 → 0.1.109
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/bin.js +1 -1
- package/dist/{constants-qIJt7998.js → constants-CEnkzyny.js} +3 -3
- package/dist/{constants-qIJt7998.js.map → constants-CEnkzyny.js.map} +1 -1
- package/dist/{index-BmzLHFCL.js → index-vHcSfvyu.js} +3 -3
- package/dist/{index-BmzLHFCL.js.map → index-vHcSfvyu.js.map} +1 -1
- package/dist/{index-Dg23uBJg.js → index-vtm826YJ.js} +377 -161
- package/dist/index-vtm826YJ.js.map +1 -0
- package/dist/main.js +2 -2
- package/dist/{seed.schema.config-C1zm5m77.js → seed.schema.config-Brb7H5eC.js} +3 -3
- package/dist/{seed.schema.config-C1zm5m77.js.map → seed.schema.config-Brb7H5eC.js.map} +1 -1
- package/dist/src/ItemProperty.ts +32 -11
- package/dist/src/actors.ts +289 -7
- package/dist/src/analyzeInput.ts +2 -2
- package/dist/src/getItem.ts +1 -1
- package/dist/src/getPublishPayload.ts +54 -59
- package/dist/src/getPublishUploads.ts +240 -0
- package/dist/src/getSegmentedItemProperties.ts +65 -0
- package/dist/src/hydrateFromDb.ts +4 -4
- package/dist/src/index.ts +62 -10
- package/dist/src/propertyMachine.ts +3 -2
- package/dist/src/read.ts +1 -1
- package/dist/src/resolveRelatedValue.ts +12 -12
- package/dist/src/saveImageSrc.ts +5 -5
- package/dist/src/saveItemStorage.ts +2 -2
- package/dist/types/src/browser/db/read/getPublishPayload.d.ts +9 -1
- package/dist/types/src/browser/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/types/src/browser/db/read/getPublishUploads.d.ts +17 -0
- package/dist/types/src/browser/db/read/getPublishUploads.d.ts.map +1 -0
- package/dist/types/src/browser/helpers/arweave.d.ts.map +1 -0
- package/dist/types/src/browser/helpers/getSegmentedItemProperties.d.ts +9 -0
- package/dist/types/src/browser/helpers/getSegmentedItemProperties.d.ts.map +1 -0
- package/dist/types/src/browser/item/Item.d.ts +3 -1
- package/dist/types/src/browser/item/Item.d.ts.map +1 -1
- package/dist/types/src/browser/property/ItemProperty.d.ts +195 -56
- package/dist/types/src/browser/property/ItemProperty.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts +1 -2
- package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/initialize.d.ts +1 -2
- package/dist/types/src/browser/property/actors/initialize.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/resolveRelatedValue.d.ts +1 -2
- package/dist/types/src/browser/property/actors/resolveRelatedValue.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/resolveRemoteStorage.d.ts +1 -2
- package/dist/types/src/browser/property/actors/resolveRemoteStorage.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/analyzeInput.d.ts +2 -2
- package/dist/types/src/browser/property/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/saveImageSrc.d.ts +2 -2
- package/dist/types/src/browser/property/actors/saveValueToDb/saveImageSrc.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/saveItemStorage.d.ts +2 -2
- package/dist/types/src/browser/property/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/saveValueToDb/saveRelation.d.ts +2 -2
- package/dist/types/src/browser/property/actors/saveValueToDb/saveRelation.d.ts.map +1 -1
- package/dist/types/src/browser/property/actors/waitForDb.d.ts +2 -2
- package/dist/types/src/browser/property/actors/waitForDb.d.ts.map +1 -1
- package/dist/types/src/browser/property/propertyMachine.d.ts +195 -60
- package/dist/types/src/browser/property/propertyMachine.d.ts.map +1 -1
- package/dist/types/src/browser/schema/file/index.d.ts +1 -1
- package/dist/types/src/browser/schema/file/index.d.ts.map +1 -1
- package/dist/types/src/types/item.d.ts +1 -1
- package/dist/types/src/types/item.d.ts.map +1 -1
- package/dist/types/src/types/property.d.ts +3 -36
- package/dist/types/src/types/property.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-Dg23uBJg.js.map +0 -1
- package/dist/types/src/browser/schema/file/arweave.d.ts.map +0 -1
- /package/dist/types/src/browser/{schema/file → helpers}/arweave.d.ts +0 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { Item, ItemProperty } from '@/browser'
|
|
2
|
+
import Transaction from 'arweave/web/lib/transaction'
|
|
3
|
+
import { CreateTransactionInterface } from 'arweave/web'
|
|
4
|
+
import { getArweave } from '@/browser/helpers/arweave'
|
|
5
|
+
import { fs } from '@zenfs/core'
|
|
6
|
+
import { getCorrectId } from '@/browser/helpers'
|
|
7
|
+
import { getSegmentedItemProperties } from '@/browser/helpers/getSegmentedItemProperties'
|
|
8
|
+
import debug from 'debug'
|
|
9
|
+
|
|
10
|
+
const logger = debug('app:item:getPublishUploads')
|
|
11
|
+
|
|
12
|
+
export const getContentHash = async (
|
|
13
|
+
base64: string | null | undefined,
|
|
14
|
+
uint: Uint8Array | undefined,
|
|
15
|
+
): Promise<string> => {
|
|
16
|
+
let data
|
|
17
|
+
|
|
18
|
+
if (base64 && !uint) {
|
|
19
|
+
const encoder = new TextEncoder()
|
|
20
|
+
data = encoder.encode(base64)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (uint) {
|
|
24
|
+
data = uint
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Hash the data with SHA-256
|
|
28
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', data as Uint8Array)
|
|
29
|
+
|
|
30
|
+
// Convert the ArrayBuffer to a hex string
|
|
31
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
|
32
|
+
return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('')
|
|
33
|
+
}
|
|
34
|
+
export const prepareArweaveTransaction = async (
|
|
35
|
+
data: string | Uint8Array,
|
|
36
|
+
contentHash: string | undefined,
|
|
37
|
+
): Promise<Transaction> => {
|
|
38
|
+
const transactionData: Partial<CreateTransactionInterface> = {
|
|
39
|
+
data,
|
|
40
|
+
tags: [],
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const tx = await getArweave()!.createTransaction(transactionData)
|
|
44
|
+
|
|
45
|
+
if (contentHash) {
|
|
46
|
+
logger('contentHash', contentHash)
|
|
47
|
+
logger('adding content hash tag to tx.id:', tx.id)
|
|
48
|
+
tx.addTag('Content-SHA-256', contentHash)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return tx
|
|
52
|
+
}
|
|
53
|
+
export type UploadProperty = {
|
|
54
|
+
itemProperty: ItemProperty<any>
|
|
55
|
+
childProperties: ItemProperty<any>[]
|
|
56
|
+
}
|
|
57
|
+
type ChildUploadData = {
|
|
58
|
+
propertyName: string
|
|
59
|
+
localStoragePath: string
|
|
60
|
+
}
|
|
61
|
+
const processUploadProperty = async (
|
|
62
|
+
uploadProperty: UploadProperty,
|
|
63
|
+
uploads: PublishUpload[],
|
|
64
|
+
relatedItemProperty?: ItemProperty<any>,
|
|
65
|
+
): Promise<PublishUpload[]> => {
|
|
66
|
+
const itemProperty = uploadProperty.itemProperty
|
|
67
|
+
|
|
68
|
+
const childUploads: ChildUploadData[] = []
|
|
69
|
+
|
|
70
|
+
for (const childProperty of uploadProperty.childProperties) {
|
|
71
|
+
const filePath = childProperty.localStoragePath
|
|
72
|
+
|
|
73
|
+
if (!filePath) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`No localStoragePath found for ItemProperty ${childProperty.propertyName}`,
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const exists = await fs.promises.exists(filePath)
|
|
80
|
+
if (!exists) {
|
|
81
|
+
throw new Error(`File doesn't exist at ${filePath}`)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
childUploads.push({
|
|
85
|
+
propertyName: childProperty.propertyName,
|
|
86
|
+
localStoragePath: filePath,
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// const filePath = itemProperty.localStoragePath
|
|
91
|
+
//
|
|
92
|
+
// if (!filePath) {
|
|
93
|
+
// throw new Error(
|
|
94
|
+
// `No localStoragePath found for ItemProperty ${itemProperty.propertyName}`,
|
|
95
|
+
// )
|
|
96
|
+
// }
|
|
97
|
+
//
|
|
98
|
+
// const exists = await fs.promises.exists(filePath)
|
|
99
|
+
// if (!exists) {
|
|
100
|
+
// throw new Error(`File doesn't exist at ${filePath}`)
|
|
101
|
+
//
|
|
102
|
+
// // const handle = await navigator.storage.getDirectory()
|
|
103
|
+
// //
|
|
104
|
+
// // await configureSingle({
|
|
105
|
+
// // backend: WebAccess,
|
|
106
|
+
// // handle,
|
|
107
|
+
// // })
|
|
108
|
+
// }
|
|
109
|
+
//
|
|
110
|
+
// const mainFileContents = await fs.promises.readFile(filePath)
|
|
111
|
+
let fileContents
|
|
112
|
+
let transaction: Transaction
|
|
113
|
+
|
|
114
|
+
if (!childUploads || childUploads.length === 0) {
|
|
115
|
+
if (relatedItemProperty && relatedItemProperty.localStoragePath) {
|
|
116
|
+
const filePath = relatedItemProperty.localStoragePath
|
|
117
|
+
|
|
118
|
+
const exists = await fs.promises.exists(filePath)
|
|
119
|
+
if (!exists) {
|
|
120
|
+
throw new Error(`File doesn't exist at ${filePath}`)
|
|
121
|
+
|
|
122
|
+
// const handle = await navigator.storage.getDirectory()
|
|
123
|
+
//
|
|
124
|
+
// await configureSingle({
|
|
125
|
+
// backend: WebAccess,
|
|
126
|
+
// handle,
|
|
127
|
+
// })
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
fileContents = await fs.promises.readFile(filePath)
|
|
131
|
+
}
|
|
132
|
+
if (!fileContents) {
|
|
133
|
+
return uploads
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (childUploads.length > 0) {
|
|
138
|
+
const separator = '===FILE_SEPARATOR==='
|
|
139
|
+
// let compositeFileContents = `${itemProperty.propertyName}${separator}${mainFileContents}`
|
|
140
|
+
let compositeFileContents = ''
|
|
141
|
+
|
|
142
|
+
for (const childUpload of childUploads) {
|
|
143
|
+
const childUploadContents = await fs.promises.readFile(
|
|
144
|
+
childUpload.localStoragePath,
|
|
145
|
+
)
|
|
146
|
+
compositeFileContents += `${separator}${childUpload.propertyName}${separator}${childUploadContents}`
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
fileContents = Buffer.from(compositeFileContents)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (!fileContents) {
|
|
153
|
+
throw new Error(`No file contents found for ${itemProperty.propertyName}`)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const uint8Array = new Uint8Array(
|
|
157
|
+
fileContents.buffer,
|
|
158
|
+
fileContents.byteOffset,
|
|
159
|
+
fileContents.byteLength,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
const contentHash = await getContentHash(null, uint8Array)
|
|
163
|
+
|
|
164
|
+
transaction = await prepareArweaveTransaction(fileContents, contentHash)
|
|
165
|
+
|
|
166
|
+
let itemPropertyLocalId = relatedItemProperty
|
|
167
|
+
? relatedItemProperty.localId
|
|
168
|
+
: itemProperty.localId
|
|
169
|
+
let itemPropertyName = relatedItemProperty
|
|
170
|
+
? relatedItemProperty.propertyName
|
|
171
|
+
: itemProperty.propertyName
|
|
172
|
+
|
|
173
|
+
uploads.push({
|
|
174
|
+
itemPropertyName,
|
|
175
|
+
itemPropertyLocalId,
|
|
176
|
+
seedLocalId: itemProperty.seedLocalId!,
|
|
177
|
+
versionLocalId: itemProperty.versionLocalId!,
|
|
178
|
+
transactionToSign: transaction,
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
return uploads
|
|
182
|
+
}
|
|
183
|
+
export type PublishUpload = {
|
|
184
|
+
itemPropertyName: string
|
|
185
|
+
itemPropertyLocalId: string
|
|
186
|
+
seedLocalId: string
|
|
187
|
+
versionLocalId: string
|
|
188
|
+
transactionToSign: Transaction
|
|
189
|
+
}
|
|
190
|
+
export const getPublishUploads = async (
|
|
191
|
+
item: Item<any>,
|
|
192
|
+
uploads: PublishUpload[] = [],
|
|
193
|
+
relatedItemProperty?: ItemProperty<any>,
|
|
194
|
+
) => {
|
|
195
|
+
if (item.modelName === 'Post') {
|
|
196
|
+
if (!item.authors) {
|
|
197
|
+
item.authors = [
|
|
198
|
+
'Sr0bIx9Fwj',
|
|
199
|
+
'0xc2879650e9503a303ceb46f966e55baab480b267dc20cede23ef503622eee6d7',
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const { itemUploadProperties, itemRelationProperties } =
|
|
205
|
+
getSegmentedItemProperties(item)
|
|
206
|
+
|
|
207
|
+
for (const uploadProperty of itemUploadProperties) {
|
|
208
|
+
uploads = await processUploadProperty(
|
|
209
|
+
uploadProperty,
|
|
210
|
+
uploads,
|
|
211
|
+
relatedItemProperty,
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
for (const relationProperty of itemRelationProperties) {
|
|
216
|
+
const propertyValue = relationProperty.getService().getSnapshot()
|
|
217
|
+
.context.propertyValue
|
|
218
|
+
|
|
219
|
+
if (!propertyValue || relationProperty.uid) {
|
|
220
|
+
continue
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const { localId: seedLocalId, uid: seedUid } = getCorrectId(propertyValue)
|
|
224
|
+
|
|
225
|
+
const relatedItem = await Item.find({
|
|
226
|
+
seedLocalId,
|
|
227
|
+
seedUid,
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
if (!relatedItem) {
|
|
231
|
+
throw new Error(
|
|
232
|
+
`No relatedItem found for ${relationProperty.propertyName}`,
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
uploads = await getPublishUploads(relatedItem, uploads, relationProperty)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return uploads
|
|
240
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Item } from '@/browser'
|
|
2
|
+
import { UploadProperty } from '@/browser/db/read/getPublishUploads'
|
|
3
|
+
|
|
4
|
+
export const getSegmentedItemProperties = (item: Item<any>) => {
|
|
5
|
+
const itemBasicProperties = []
|
|
6
|
+
const itemRelationProperties = []
|
|
7
|
+
const itemListProperties = []
|
|
8
|
+
const itemUploadProperties: UploadProperty[] = []
|
|
9
|
+
const itemStorageProperties = []
|
|
10
|
+
let itemStorageTransactionProperty: UploadProperty | undefined
|
|
11
|
+
|
|
12
|
+
for (const itemProperty of Object.values(item.properties)) {
|
|
13
|
+
if (!itemProperty.propertyDef) {
|
|
14
|
+
continue
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const isItemStorage =
|
|
18
|
+
itemProperty.propertyDef.storageType &&
|
|
19
|
+
itemProperty.propertyDef.storageType === 'ItemStorage'
|
|
20
|
+
|
|
21
|
+
const isImageSrc =
|
|
22
|
+
itemProperty.propertyDef.dataType === 'Relation' &&
|
|
23
|
+
itemProperty.propertyDef.refValueType === 'ImageSrc'
|
|
24
|
+
|
|
25
|
+
const isStorageTransaction =
|
|
26
|
+
itemProperty.propertyName === 'storageTransactionId'
|
|
27
|
+
|
|
28
|
+
if (itemProperty.propertyDef.dataType === 'Relation') {
|
|
29
|
+
itemRelationProperties.push(itemProperty)
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (itemProperty.propertyDef.dataType === 'List') {
|
|
34
|
+
itemListProperties.push(itemProperty)
|
|
35
|
+
continue
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (isItemStorage) {
|
|
39
|
+
itemStorageProperties.push(itemProperty)
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (isStorageTransaction) {
|
|
44
|
+
itemStorageTransactionProperty = { itemProperty, childProperties: [] }
|
|
45
|
+
continue
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
itemBasicProperties.push(itemProperty)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (itemStorageTransactionProperty && itemStorageProperties.length > 0) {
|
|
52
|
+
itemStorageTransactionProperty.childProperties = itemStorageProperties
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (itemStorageTransactionProperty) {
|
|
56
|
+
itemUploadProperties.push(itemStorageTransactionProperty)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
itemBasicProperties,
|
|
61
|
+
itemRelationProperties,
|
|
62
|
+
itemListProperties,
|
|
63
|
+
itemUploadProperties,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -21,7 +21,7 @@ export const hydrateFromDb = fromCallback<
|
|
|
21
21
|
propertyName: propertyNameRaw,
|
|
22
22
|
propertyValue,
|
|
23
23
|
propertyRecordSchema,
|
|
24
|
-
|
|
24
|
+
modelName,
|
|
25
25
|
} = context
|
|
26
26
|
|
|
27
27
|
let propertyName = propertyNameRaw
|
|
@@ -264,8 +264,8 @@ export const hydrateFromDb = fromCallback<
|
|
|
264
264
|
schemaUid: schemaUidFromDb,
|
|
265
265
|
refValueType,
|
|
266
266
|
localStorageDir,
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
refResolvedValue,
|
|
268
|
+
refResolvedDisplayValue,
|
|
269
269
|
renderValue: refResolvedDisplayValue,
|
|
270
270
|
populatedFromDb: true,
|
|
271
271
|
})
|
|
@@ -278,7 +278,7 @@ export const hydrateFromDb = fromCallback<
|
|
|
278
278
|
const { Item } = await import(`@/browser/item`)
|
|
279
279
|
const item = await Item.find({
|
|
280
280
|
seedLocalId,
|
|
281
|
-
modelName
|
|
281
|
+
modelName,
|
|
282
282
|
})
|
|
283
283
|
if (item) {
|
|
284
284
|
const filePath = `/files/${localStorageDir}/${refResolvedValue}`
|
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
|
})
|
|
@@ -105,8 +105,9 @@ export const propertyMachine = setup({
|
|
|
105
105
|
resolvingRelatedValueSuccess: {
|
|
106
106
|
target: 'idle',
|
|
107
107
|
actions: assign({
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
refResolvedDisplayValue: ({ event }) =>
|
|
109
|
+
event.refResolvedDisplayValue,
|
|
110
|
+
resolvedValue: ({ event }) => event.refResolvedValue,
|
|
110
111
|
}),
|
|
111
112
|
},
|
|
112
113
|
resolvingRelatedValueDone: {
|
package/dist/src/read.ts
CHANGED
|
@@ -50,7 +50,7 @@ export const resolveRelatedValue = fromCallback<
|
|
|
50
50
|
})
|
|
51
51
|
sendBack({
|
|
52
52
|
type: 'resolvingRelatedValueSuccess',
|
|
53
|
-
|
|
53
|
+
refResolvedDisplayValue: contentUrl,
|
|
54
54
|
})
|
|
55
55
|
return true
|
|
56
56
|
}
|
|
@@ -79,8 +79,8 @@ export const resolveRelatedValue = fromCallback<
|
|
|
79
79
|
})
|
|
80
80
|
sendBack({
|
|
81
81
|
type: 'resolvingRelatedValueSuccess',
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
refResolvedDisplayValue: contentUrl,
|
|
83
|
+
refResolvedValue: storageTransactionId,
|
|
84
84
|
})
|
|
85
85
|
return true
|
|
86
86
|
}
|
|
@@ -95,8 +95,8 @@ export const resolveRelatedValue = fromCallback<
|
|
|
95
95
|
})
|
|
96
96
|
sendBack({
|
|
97
97
|
type: 'resolvingRelatedValueSuccess',
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
refResolvedDisplayValue: contentUrl,
|
|
99
|
+
refResolvedValue: storageTransactionId,
|
|
100
100
|
})
|
|
101
101
|
return true
|
|
102
102
|
}
|
|
@@ -122,7 +122,7 @@ export const resolveRelatedValue = fromCallback<
|
|
|
122
122
|
})
|
|
123
123
|
sendBack({
|
|
124
124
|
type: 'resolvingRelatedValueSuccess',
|
|
125
|
-
|
|
125
|
+
refResolvedDisplayValue: contentUrl,
|
|
126
126
|
})
|
|
127
127
|
return true
|
|
128
128
|
}
|
|
@@ -143,7 +143,7 @@ export const resolveRelatedValue = fromCallback<
|
|
|
143
143
|
})
|
|
144
144
|
sendBack({
|
|
145
145
|
type: 'resolvingRelatedValueSuccess',
|
|
146
|
-
|
|
146
|
+
refResolvedDisplayValue: contentUrl,
|
|
147
147
|
})
|
|
148
148
|
return true
|
|
149
149
|
}
|
|
@@ -186,7 +186,7 @@ export const resolveRelatedValue = fromCallback<
|
|
|
186
186
|
})
|
|
187
187
|
sendBack({
|
|
188
188
|
type: 'resolvingRelatedValueSuccess',
|
|
189
|
-
|
|
189
|
+
refResolvedDisplayValue: contentUrl,
|
|
190
190
|
})
|
|
191
191
|
return true
|
|
192
192
|
}
|
|
@@ -282,13 +282,13 @@ export const resolveRelatedValue = fromCallback<
|
|
|
282
282
|
// )
|
|
283
283
|
// }
|
|
284
284
|
//
|
|
285
|
-
// const
|
|
285
|
+
// const refResolvedDisplayValue = storageIdQuery.rows[0][2]
|
|
286
286
|
// let resolvedValue = storageIdQuery.rows[0][3]
|
|
287
287
|
//
|
|
288
|
-
// if (
|
|
288
|
+
// if (refResolvedDisplayValue && resolvedValue) {
|
|
289
289
|
// sendBack({
|
|
290
290
|
// type: 'resolvingRelatedValueSuccess',
|
|
291
|
-
//
|
|
291
|
+
// refResolvedDisplayValue,
|
|
292
292
|
// resolvedValue,
|
|
293
293
|
// })
|
|
294
294
|
// return
|
|
@@ -320,7 +320,7 @@ export const resolveRelatedValue = fromCallback<
|
|
|
320
320
|
//
|
|
321
321
|
// sendBack({
|
|
322
322
|
// type: 'resolvingRelatedValueSuccess',
|
|
323
|
-
//
|
|
323
|
+
// refResolvedDisplayValue: contentUrl,
|
|
324
324
|
// resolvedValue: storageId,
|
|
325
325
|
// })
|
|
326
326
|
// }
|
package/dist/src/saveImageSrc.ts
CHANGED
|
@@ -74,7 +74,7 @@ export const saveImageSrc = fromCallback<
|
|
|
74
74
|
propertyName: propertyNameRaw,
|
|
75
75
|
propertyValue: existingValue,
|
|
76
76
|
propertyRecordSchema,
|
|
77
|
-
|
|
77
|
+
modelName,
|
|
78
78
|
seedLocalId,
|
|
79
79
|
seedUid,
|
|
80
80
|
versionLocalId,
|
|
@@ -182,7 +182,7 @@ export const saveImageSrc = fromCallback<
|
|
|
182
182
|
seedUid,
|
|
183
183
|
versionLocalId,
|
|
184
184
|
versionUid,
|
|
185
|
-
modelName
|
|
185
|
+
modelName,
|
|
186
186
|
schemaUid,
|
|
187
187
|
refSeedType: 'image',
|
|
188
188
|
refModelUid: imageSchemaUid,
|
|
@@ -203,7 +203,7 @@ export const saveImageSrc = fromCallback<
|
|
|
203
203
|
newValue: newImageSeedLocalId,
|
|
204
204
|
seedLocalId,
|
|
205
205
|
versionLocalId,
|
|
206
|
-
modelName
|
|
206
|
+
modelName,
|
|
207
207
|
schemaUid,
|
|
208
208
|
refSeedType: 'image',
|
|
209
209
|
refResolvedDisplayValue,
|
|
@@ -221,8 +221,8 @@ export const saveImageSrc = fromCallback<
|
|
|
221
221
|
refSeedType: 'image',
|
|
222
222
|
refSchemaUid: imageSchemaUid,
|
|
223
223
|
renderValue: refResolvedDisplayValue,
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
refResolvedDisplayValue: refResolvedDisplayValue,
|
|
225
|
+
refResolvedValue: fileName,
|
|
226
226
|
localStorageDir: '/images',
|
|
227
227
|
easDataType: 'bytes32',
|
|
228
228
|
})
|
|
@@ -23,7 +23,7 @@ export const saveItemStorage = fromCallback<
|
|
|
23
23
|
seedUid,
|
|
24
24
|
propertyName,
|
|
25
25
|
propertyRecordSchema,
|
|
26
|
-
|
|
26
|
+
modelName,
|
|
27
27
|
propertyValue: existingValue,
|
|
28
28
|
} = context
|
|
29
29
|
|
|
@@ -82,7 +82,7 @@ export const saveItemStorage = fromCallback<
|
|
|
82
82
|
const propertyDataRows = await createMetadata(
|
|
83
83
|
{
|
|
84
84
|
propertyName,
|
|
85
|
-
modelType:
|
|
85
|
+
modelType: modelName.toLowerCase(),
|
|
86
86
|
seedLocalId,
|
|
87
87
|
seedUid,
|
|
88
88
|
versionLocalId: itemData.latestVersionLocalId,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AttestationRequest } from '@ethereum-attestation-service/eas-sdk';
|
|
2
|
+
import { Item } from '@/browser/item/Item';
|
|
2
3
|
type PublishPayload = {
|
|
3
4
|
localId: string;
|
|
4
5
|
seedIsRevocable: boolean;
|
|
@@ -10,6 +11,13 @@ type PublishPayload = {
|
|
|
10
11
|
propertiesToUpdate: any[];
|
|
11
12
|
};
|
|
12
13
|
type MultiPublishPayload = PublishPayload[];
|
|
13
|
-
|
|
14
|
+
type UploadedTransaction = {
|
|
15
|
+
txId: string;
|
|
16
|
+
itemPropertyLocalId?: string;
|
|
17
|
+
seedLocalId?: string;
|
|
18
|
+
versionLocalId?: string;
|
|
19
|
+
itemPropertyName?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const getPublishPayload: (item: Item<any>, uploadedTransactions: UploadedTransaction[]) => Promise<MultiPublishPayload>;
|
|
14
22
|
export {};
|
|
15
23
|
//# sourceMappingURL=getPublishPayload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPublishPayload.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/db/read/getPublishPayload.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"getPublishPayload.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/db/read/getPublishPayload.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,EAGnB,MAAM,uCAAuC,CAAA;AAS9C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AA0O1C,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,KAAK,mBAAmB,GAAG;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,iBAAiB,SACtB,IAAI,CAAC,GAAG,CAAC,wBACO,mBAAmB,EAAE,KAC1C,OAAO,CAAC,mBAAmB,CAsE7B,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Item, ItemProperty } from '@/browser';
|
|
2
|
+
import Transaction from 'arweave/web/lib/transaction';
|
|
3
|
+
export declare const getContentHash: (base64: string | null | undefined, uint: Uint8Array | undefined) => Promise<string>;
|
|
4
|
+
export declare const prepareArweaveTransaction: (data: string | Uint8Array, contentHash: string | undefined) => Promise<Transaction>;
|
|
5
|
+
export type UploadProperty = {
|
|
6
|
+
itemProperty: ItemProperty<any>;
|
|
7
|
+
childProperties: ItemProperty<any>[];
|
|
8
|
+
};
|
|
9
|
+
export type PublishUpload = {
|
|
10
|
+
itemPropertyName: string;
|
|
11
|
+
itemPropertyLocalId: string;
|
|
12
|
+
seedLocalId: string;
|
|
13
|
+
versionLocalId: string;
|
|
14
|
+
transactionToSign: Transaction;
|
|
15
|
+
};
|
|
16
|
+
export declare const getPublishUploads: (item: Item<any>, uploads?: PublishUpload[], relatedItemProperty?: ItemProperty<any>) => Promise<PublishUpload[]>;
|
|
17
|
+
//# sourceMappingURL=getPublishUploads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPublishUploads.d.ts","sourceRoot":"","sources":["../../../../../../src/browser/db/read/getPublishUploads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC9C,OAAO,WAAW,MAAM,6BAA6B,CAAA;AAUrD,eAAO,MAAM,cAAc,WACjB,MAAM,GAAG,IAAI,GAAG,SAAS,QAC3B,UAAU,GAAG,SAAS,KAC3B,OAAO,CAAC,MAAM,CAkBhB,CAAA;AACD,eAAO,MAAM,yBAAyB,SAC9B,MAAM,GAAG,UAAU,eACZ,MAAM,GAAG,SAAS,KAC9B,OAAO,CAAC,WAAW,CAerB,CAAA;AACD,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,CAAA;IAC/B,eAAe,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,CAAA;CACrC,CAAA;AA+HD,MAAM,MAAM,aAAa,GAAG;IAC1B,gBAAgB,EAAE,MAAM,CAAA;IACxB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,WAAW,CAAA;CAC/B,CAAA;AACD,eAAO,MAAM,iBAAiB,SACtB,IAAI,CAAC,GAAG,CAAC,YACN,aAAa,EAAE,wBACF,YAAY,CAAC,GAAG,CAAC,6BA+CxC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arweave.d.ts","sourceRoot":"","sources":["../../../../../src/browser/helpers/arweave.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,eAAO,MAAM,UAAU,QAAO,OAAO,GAAG,SAyCvC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Item } from '@/browser';
|
|
2
|
+
import { UploadProperty } from '@/browser/db/read/getPublishUploads';
|
|
3
|
+
export declare const getSegmentedItemProperties: (item: Item<any>) => {
|
|
4
|
+
itemBasicProperties: import("@/browser").ItemProperty<any>[];
|
|
5
|
+
itemRelationProperties: import("@/browser").ItemProperty<any>[];
|
|
6
|
+
itemListProperties: import("@/browser").ItemProperty<any>[];
|
|
7
|
+
itemUploadProperties: UploadProperty[];
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=getSegmentedItemProperties.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSegmentedItemProperties.d.ts","sourceRoot":"","sources":["../../../../../src/browser/helpers/getSegmentedItemProperties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAEpE,eAAO,MAAM,0BAA0B,SAAU,IAAI,CAAC,GAAG,CAAC;;;;;CA6DzD,CAAA"}
|
|
@@ -21,7 +21,8 @@ export declare class Item<T extends ModelValues<ModelSchema>> {
|
|
|
21
21
|
getService: () => ActorRefFrom<typeof itemMachineSingle>;
|
|
22
22
|
getEditedProperties: () => Promise<PropertyData[]>;
|
|
23
23
|
publish: () => Promise<void>;
|
|
24
|
-
|
|
24
|
+
getPublishUploads: () => Promise<import("@/browser/db/read/getPublishUploads").PublishUpload[]>;
|
|
25
|
+
getPublishPayload: (uploadedTransactions: any[]) => Promise<{
|
|
25
26
|
localId: string;
|
|
26
27
|
seedIsRevocable: boolean;
|
|
27
28
|
seedSchemaUid: string;
|
|
@@ -31,6 +32,7 @@ export declare class Item<T extends ModelValues<ModelSchema>> {
|
|
|
31
32
|
listOfAttestations: import("@ethereum-attestation-service/eas-sdk").AttestationRequest[];
|
|
32
33
|
propertiesToUpdate: any[];
|
|
33
34
|
}[]>;
|
|
35
|
+
get serviceContext(): import("@/types").ItemMachineContext<any>;
|
|
34
36
|
get seedLocalId(): string;
|
|
35
37
|
get seedUid(): string | undefined;
|
|
36
38
|
get schemaUid(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../../../src/browser/item/Item.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,YAAY,EAAe,YAAY,EAAE,MAAM,QAAQ,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAYjC,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../../../src/browser/item/Item.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACb,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,YAAY,EAAe,YAAY,EAAE,MAAM,QAAQ,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAYjC,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAKhE,qBAAa,IAAI,CAAC,CAAC,SAAS,WAAW,CAAC,WAAW,CAAC;IAClD,OAAO,CAAC,MAAM,CAAC,aAAa,CAGf;IACb,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwC;IACjE,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAqB;IAC3D,CAAC,SAAS,CAAC,UAAO;IAClB,OAAO,CAAC,kBAAkB,CAEC;gBAEf,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;WAyI7B,MAAM,CAAC,CAAC,SAAS,WAAW,CAAC,WAAW,CAAC,EACpD,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,GACvB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;WAqDR,IAAI,CAAC,EAChB,SAAS,EACT,WAAW,EACX,OAAO,GACR,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;WAqBpC,GAAG,CACd,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;WAeV,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAcpD,OAAO,CAAC,uBAAuB;IAwB/B,SAAS,aAAc,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,KAAG,YAAY,CAI7D;IAED,UAAU,QAAO,YAAY,CAAC,OAAO,iBAAiB,CAAC,CAEtD;IAED,mBAAmB,QAAa,OAAO,CAAC,YAAY,EAAE,CAAC,CAKtD;IAED,OAAO,QAAa,OAAO,CAAC,IAAI,CAAC,CAYhC;IAED,iBAAiB,+EAEhB;IAED,iBAAiB,yBAAgC,GAAG,EAAE;;;;;;;;;SAErD;IAED,IAAI,cAAc,8CAEjB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,OAAO,IAAI,MAAM,GAAG,SAAS,CAEhC;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,gBAAgB,IAAI,YAAY,CAEnC;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAElD;IAED,MAAM,IAAI,IAAI;CAIf"}
|