@seedprotocol/sdk 0.1.108 → 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.
Files changed (66) hide show
  1. package/dist/bin.js +1 -1
  2. package/dist/{constants-qIJt7998.js → constants-CEnkzyny.js} +3 -3
  3. package/dist/{constants-qIJt7998.js.map → constants-CEnkzyny.js.map} +1 -1
  4. package/dist/{index-BmnXNuNp.js → index-vHcSfvyu.js} +3 -3
  5. package/dist/{index-BmnXNuNp.js.map → index-vHcSfvyu.js.map} +1 -1
  6. package/dist/{index-CsC8qxj6.js → index-vtm826YJ.js} +372 -156
  7. package/dist/index-vtm826YJ.js.map +1 -0
  8. package/dist/main.js +2 -2
  9. package/dist/{seed.schema.config-hUwOwJMn.js → seed.schema.config-Brb7H5eC.js} +3 -3
  10. package/dist/{seed.schema.config-hUwOwJMn.js.map → seed.schema.config-Brb7H5eC.js.map} +1 -1
  11. package/dist/src/ItemProperty.ts +32 -11
  12. package/dist/src/actors.ts +289 -7
  13. package/dist/src/analyzeInput.ts +2 -2
  14. package/dist/src/getItem.ts +1 -1
  15. package/dist/src/getPublishPayload.ts +50 -54
  16. package/dist/src/getPublishUploads.ts +240 -0
  17. package/dist/src/getSegmentedItemProperties.ts +65 -0
  18. package/dist/src/hydrateFromDb.ts +4 -4
  19. package/dist/src/index.ts +62 -10
  20. package/dist/src/propertyMachine.ts +3 -2
  21. package/dist/src/read.ts +1 -1
  22. package/dist/src/resolveRelatedValue.ts +12 -12
  23. package/dist/src/saveImageSrc.ts +5 -5
  24. package/dist/src/saveItemStorage.ts +2 -2
  25. package/dist/src/seed.ts +31 -4
  26. package/dist/types/src/browser/db/read/getPublishPayload.d.ts +9 -1
  27. package/dist/types/src/browser/db/read/getPublishPayload.d.ts.map +1 -1
  28. package/dist/types/src/browser/db/read/getPublishUploads.d.ts +17 -0
  29. package/dist/types/src/browser/db/read/getPublishUploads.d.ts.map +1 -0
  30. package/dist/types/src/browser/helpers/arweave.d.ts.map +1 -0
  31. package/dist/types/src/browser/helpers/getSegmentedItemProperties.d.ts +9 -0
  32. package/dist/types/src/browser/helpers/getSegmentedItemProperties.d.ts.map +1 -0
  33. package/dist/types/src/browser/item/Item.d.ts +3 -1
  34. package/dist/types/src/browser/item/Item.d.ts.map +1 -1
  35. package/dist/types/src/browser/property/ItemProperty.d.ts +195 -56
  36. package/dist/types/src/browser/property/ItemProperty.d.ts.map +1 -1
  37. package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts +1 -2
  38. package/dist/types/src/browser/property/actors/hydrateFromDb.d.ts.map +1 -1
  39. package/dist/types/src/browser/property/actors/initialize.d.ts +1 -2
  40. package/dist/types/src/browser/property/actors/initialize.d.ts.map +1 -1
  41. package/dist/types/src/browser/property/actors/resolveRelatedValue.d.ts +1 -2
  42. package/dist/types/src/browser/property/actors/resolveRelatedValue.d.ts.map +1 -1
  43. package/dist/types/src/browser/property/actors/resolveRemoteStorage.d.ts +1 -2
  44. package/dist/types/src/browser/property/actors/resolveRemoteStorage.d.ts.map +1 -1
  45. package/dist/types/src/browser/property/actors/saveValueToDb/analyzeInput.d.ts +2 -2
  46. package/dist/types/src/browser/property/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
  47. package/dist/types/src/browser/property/actors/saveValueToDb/saveImageSrc.d.ts +2 -2
  48. package/dist/types/src/browser/property/actors/saveValueToDb/saveImageSrc.d.ts.map +1 -1
  49. package/dist/types/src/browser/property/actors/saveValueToDb/saveItemStorage.d.ts +2 -2
  50. package/dist/types/src/browser/property/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
  51. package/dist/types/src/browser/property/actors/saveValueToDb/saveRelation.d.ts +2 -2
  52. package/dist/types/src/browser/property/actors/saveValueToDb/saveRelation.d.ts.map +1 -1
  53. package/dist/types/src/browser/property/actors/waitForDb.d.ts +2 -2
  54. package/dist/types/src/browser/property/actors/waitForDb.d.ts.map +1 -1
  55. package/dist/types/src/browser/property/propertyMachine.d.ts +195 -60
  56. package/dist/types/src/browser/property/propertyMachine.d.ts.map +1 -1
  57. package/dist/types/src/browser/schema/file/index.d.ts +1 -1
  58. package/dist/types/src/browser/schema/file/index.d.ts.map +1 -1
  59. package/dist/types/src/types/item.d.ts +1 -1
  60. package/dist/types/src/types/item.d.ts.map +1 -1
  61. package/dist/types/src/types/property.d.ts +3 -36
  62. package/dist/types/src/types/property.d.ts.map +1 -1
  63. package/package.json +1 -1
  64. package/dist/index-CsC8qxj6.js.map +0 -1
  65. package/dist/types/src/browser/schema/file/arweave.d.ts.map +0 -1
  66. /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
- itemModelName,
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
- resolvedValue: refResolvedValue,
268
- resolvedDisplayValue: refResolvedDisplayValue,
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: itemModelName,
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
- uploadBinaryData,
4
- uploadMetadata,
5
- } from '@/browser/schema/file/upload/actors'
3
+ fetchAllBinaryData,
4
+ fetchAllMetadataRecords,
5
+ } from '@/browser/schema/file/fetchAll/actors'
6
+ import { Attestation } from '@/browser/gql/graphql'
6
7
 
7
- export const uploadMachine = setup({
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
- uploadBinaryData,
10
- uploadMetadata,
20
+ fetchAllMetadataRecords,
21
+ fetchAllBinaryData,
11
22
  },
12
23
  }).createMachine({
13
- id: 'upload',
24
+ id: 'fetchAllFiles',
14
25
  initial: 'idle',
15
- context: {
16
- file: '',
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
- resolvedDisplayValue: ({ event }) => event.resolvedDisplayValue,
109
- resolvedValue: ({ event }) => event.resolvedValue,
108
+ refResolvedDisplayValue: ({ event }) =>
109
+ event.refResolvedDisplayValue,
110
+ resolvedValue: ({ event }) => event.refResolvedValue,
110
111
  }),
111
112
  },
112
113
  resolvingRelatedValueDone: {
package/dist/src/read.ts CHANGED
@@ -43,7 +43,7 @@ export const getPropertyData = async (
43
43
 
44
44
  return {
45
45
  ...row,
46
- itemModelName: startCase(row.modelType),
46
+ modelName: startCase(row.modelType),
47
47
  }
48
48
  }
49
49
 
@@ -50,7 +50,7 @@ export const resolveRelatedValue = fromCallback<
50
50
  })
51
51
  sendBack({
52
52
  type: 'resolvingRelatedValueSuccess',
53
- resolvedDisplayValue: contentUrl,
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
- resolvedDisplayValue: contentUrl,
83
- resolvedValue: storageTransactionId,
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
- resolvedDisplayValue: contentUrl,
99
- resolvedValue: storageTransactionId,
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
- resolvedDisplayValue: contentUrl,
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
- resolvedDisplayValue: contentUrl,
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
- resolvedDisplayValue: contentUrl,
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 resolvedDisplayValue = storageIdQuery.rows[0][2]
285
+ // const refResolvedDisplayValue = storageIdQuery.rows[0][2]
286
286
  // let resolvedValue = storageIdQuery.rows[0][3]
287
287
  //
288
- // if (resolvedDisplayValue && resolvedValue) {
288
+ // if (refResolvedDisplayValue && resolvedValue) {
289
289
  // sendBack({
290
290
  // type: 'resolvingRelatedValueSuccess',
291
- // resolvedDisplayValue,
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
- // resolvedDisplayValue: contentUrl,
323
+ // refResolvedDisplayValue: contentUrl,
324
324
  // resolvedValue: storageId,
325
325
  // })
326
326
  // }
@@ -74,7 +74,7 @@ export const saveImageSrc = fromCallback<
74
74
  propertyName: propertyNameRaw,
75
75
  propertyValue: existingValue,
76
76
  propertyRecordSchema,
77
- itemModelName,
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: itemModelName,
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: itemModelName,
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
- resolvedDisplayValue: refResolvedDisplayValue,
225
- resolvedValue: fileName,
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
- itemModelName,
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: itemModelName.toLowerCase(),
85
+ modelType: modelName.toLowerCase(),
86
86
  seedLocalId,
87
87
  seedUid,
88
88
  versionLocalId: itemData.latestVersionLocalId,
package/dist/src/seed.ts CHANGED
@@ -1,10 +1,37 @@
1
- import { SeedConstructorOptions } from '@/types/types'
2
- import { SeedBase } from '@/shared/seed'
1
+ import { isBrowser, isNode, isReactNative } from '@/shared/environment'
2
+ import { Endpoints, SeedConstructorOptions } from '@/types/types'
3
+ import { Subject } from 'rxjs'
3
4
 
4
- class SeedNode extends SeedBase {
5
+ type Environment = 'node' | 'browser' | 'react-native'
6
+
7
+ abstract class SeedBase {
8
+ private readonly _env: Environment = 'browser'
9
+ protected _subject: Subject<void> = new Subject<void>()
10
+
11
+ constructor(props: { endpoints: Endpoints }) {
12
+ console.log('Seed constructor called')
13
+ if (isNode()) {
14
+ this._env = 'node'
15
+ }
16
+ if (isBrowser()) {
17
+ this._env = 'browser'
18
+ }
19
+ if (isReactNative()) {
20
+ this._env = 'react-native'
21
+ }
22
+ }
23
+
24
+ async initialize() {}
25
+
26
+ subscribe(callback: (event: any) => void) {
27
+ return this._subject.subscribe(callback)
28
+ }
29
+ }
30
+
31
+ class SeedSync extends SeedBase {
5
32
  constructor(props: SeedConstructorOptions) {
6
33
  super(props)
7
34
  }
8
35
  }
9
36
 
10
- export { SeedNode }
37
+ export { SeedBase, SeedSync }
@@ -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
- export declare const getPublishPayload: (seedLocalId: string) => Promise<MultiPublishPayload>;
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,EAGnB,MAAM,uCAAuC,CAAA;AAwQ9C,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,CA8D7B,CAAA"}
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