@seedprotocol/sdk 0.2.29 → 0.2.31
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/{Db-lX4nNJTb.js → Db-CPpw7pPl.js} +2 -2
- package/dist/{Db-lX4nNJTb.js.map → Db-CPpw7pPl.js.map} +1 -1
- package/dist/{Db-Bu5Y7_fn.js → Db-DW4cvius.js} +2 -2
- package/dist/{Db-Bu5Y7_fn.js.map → Db-DW4cvius.js.map} +1 -1
- package/dist/{Item-BRHX17yq.js → Item-DJFIzrGb.js} +2 -2
- package/dist/{Item-BRHX17yq.js.map → Item-DJFIzrGb.js.map} +1 -1
- package/dist/{ItemProperty-CZzIP1b8.js → ItemProperty-DabiYJLq.js} +2 -2
- package/dist/{ItemProperty-CZzIP1b8.js.map → ItemProperty-DabiYJLq.js.map} +1 -1
- package/dist/{index-BCmsQoYg.js → index-D3qJ54jj.js} +70 -87
- package/dist/index-D3qJ54jj.js.map +1 -0
- package/dist/{index-DzDVTUae.js → index-MhbsovAK.js} +2 -2
- package/dist/index-MhbsovAK.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/{seed.schema.config-BswsDyRe.js → seed.schema.config-DCFBkB3M.js} +2 -2
- package/dist/{seed.schema.config-BswsDyRe.js.map → seed.schema.config-DCFBkB3M.js.map} +1 -1
- package/dist/src/actors.ts +272 -34
- package/dist/src/createMetadata.ts +1 -1
- package/dist/src/hydrateFromDb.ts +2 -36
- package/dist/src/propertyMachine.ts +1 -1
- package/dist/src/saveItemStorage.ts +1 -1
- package/dist/src/waitForDb.ts +18 -17
- package/dist/types/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/index-BCmsQoYg.js.map +0 -1
- package/dist/index-DzDVTUae.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as Item } from './index-
|
|
1
|
+
export { I as Item } from './index-D3qJ54jj.js';
|
|
2
2
|
import 'immer';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import 'tslib';
|
|
@@ -28,4 +28,4 @@ import 'arweave';
|
|
|
28
28
|
import 'use-immer';
|
|
29
29
|
import '@xstate/react';
|
|
30
30
|
import 'rxjs';
|
|
31
|
-
//# sourceMappingURL=index-
|
|
31
|
+
//# sourceMappingURL=index-MhbsovAK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-MhbsovAK.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'immer';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
export { D as Db, d as ImageSrc, e as Item, f as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, x as client, v as eventEmitter, s as getCorrectId, t as getGlobalService, k as useCreateItem, m as useDeleteItem, n as useGlobalServiceStatus, h as useItem, j as useItemProperties, l as useItemProperty, u as useItems, p as usePersistedSnapshots, o as usePublishItem, r as useService, q as useServices, w as withSeed } from './index-
|
|
3
|
+
export { D as Db, d as ImageSrc, e as Item, f as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, x as client, v as eventEmitter, s as getCorrectId, t as getGlobalService, k as useCreateItem, m as useDeleteItem, n as useGlobalServiceStatus, h as useItem, j as useItemProperties, l as useItemProperty, u as useItems, p as usePersistedSnapshots, o as usePublishItem, r as useService, q as useServices, w as withSeed } from './index-D3qJ54jj.js';
|
|
4
4
|
import 'tslib';
|
|
5
5
|
import 'drizzle-orm';
|
|
6
6
|
export { B as BaseArweaveClient, a as BaseEasClient, c as BaseFileManager, b as BaseQueryClient } from './constants-BjOTXEgm.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
import { T as Text, M as Model } from './index-
|
|
3
|
+
import { T as Text, M as Model } from './index-D3qJ54jj.js';
|
|
4
4
|
import 'immer';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import 'drizzle-orm';
|
|
@@ -75,4 +75,4 @@ const models = {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
export { models };
|
|
78
|
-
//# sourceMappingURL=seed.schema.config-
|
|
78
|
+
//# sourceMappingURL=seed.schema.config-DCFBkB3M.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.schema.config-
|
|
1
|
+
{"version":3,"file":"seed.schema.config-DCFBkB3M.js","sources":["../../src/db/configs/seed.schema.config.ts"],"sourcesContent":["import { Model, Text } from '@/schema'\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,56 +1,294 @@
|
|
|
1
1
|
import { EventObject, fromCallback } from 'xstate'
|
|
2
|
-
import {
|
|
2
|
+
import { fetchAllFilesMachine } from '@/schema/file/fetchAll/index'
|
|
3
|
+
import { ARWEAVE_HOST } from '@/services/internal/constants'
|
|
3
4
|
import { GET_FILES_METADATA } from '@/schema/file/queries'
|
|
5
|
+
import { getArweave } from '@/helpers/ArweaveClient'
|
|
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'
|
|
4
14
|
import { BaseEasClient } from '@/helpers/EasClient/BaseEasClient'
|
|
5
15
|
import { BaseQueryClient } from '@/helpers/QueryClient/BaseQueryClient'
|
|
16
|
+
import debug from 'debug'
|
|
17
|
+
import { BaseDb } from '@/db/Db/BaseDb'
|
|
18
|
+
import { saveAppState } from '@/db/write/saveAppState'
|
|
6
19
|
|
|
20
|
+
const logger = debug('app:file:actors:fetchAll')
|
|
7
21
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
type FileType = {
|
|
23
|
+
mimeType: string
|
|
24
|
+
extension: string
|
|
25
|
+
}
|
|
11
26
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
}
|
|
15
35
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
},
|
|
26
60
|
},
|
|
27
61
|
},
|
|
28
|
-
}
|
|
29
|
-
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
})
|
|
30
65
|
|
|
31
|
-
|
|
32
|
-
|
|
66
|
+
return filesMetadata
|
|
67
|
+
}
|
|
33
68
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
69
|
+
_fetchAllMetadataRecords().then((filesMetadata) => {
|
|
70
|
+
sendBack({ type: 'fetchingAllMetadataRecordsSuccess', filesMetadata })
|
|
71
|
+
})
|
|
37
72
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
73
|
+
return () => { }
|
|
74
|
+
})
|
|
41
75
|
|
|
42
|
-
export const
|
|
76
|
+
export const fetchAllBinaryData = fromCallback<
|
|
43
77
|
EventObject,
|
|
44
|
-
typeof
|
|
45
|
-
>(({ sendBack,
|
|
46
|
-
const { addresses } = context
|
|
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
|
+
}
|
|
47
286
|
|
|
48
|
-
const fetchBinaryData = async () => {
|
|
49
287
|
return []
|
|
50
288
|
}
|
|
51
289
|
|
|
52
|
-
|
|
53
|
-
sendBack({ type: '
|
|
290
|
+
_fetchAllBinaryData().then((binaryData) => {
|
|
291
|
+
sendBack({ type: 'fetchingAllBinaryDataSuccess', binaryData })
|
|
54
292
|
})
|
|
55
293
|
|
|
56
294
|
return () => { }
|
|
@@ -25,7 +25,7 @@ export const createMetadata: CreateMetadata = async (
|
|
|
25
25
|
propertyRecordSchema.localStorageDir &&
|
|
26
26
|
propertyRecordSchema.storageType === 'ItemStorage'
|
|
27
27
|
) {
|
|
28
|
-
metadataValues.refResolvedValue = `${metadataValues.seedLocalId}${propertyRecordSchema.filenameSuffix}`
|
|
28
|
+
metadataValues.refResolvedValue = `${metadataValues.seedUid || metadataValues.seedLocalId}${propertyRecordSchema.filenameSuffix}`
|
|
29
29
|
metadataValues.refValueType = 'file'
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -19,7 +19,6 @@ export const hydrateFromDb = fromCallback<
|
|
|
19
19
|
seedUid,
|
|
20
20
|
seedLocalId,
|
|
21
21
|
propertyName: propertyNameRaw,
|
|
22
|
-
propertyValue,
|
|
23
22
|
propertyRecordSchema,
|
|
24
23
|
modelName,
|
|
25
24
|
} = context
|
|
@@ -116,41 +115,6 @@ export const hydrateFromDb = fromCallback<
|
|
|
116
115
|
let propertyValueProcessed: string | string[] | undefined | null =
|
|
117
116
|
propertyValueFromDb
|
|
118
117
|
|
|
119
|
-
if (propertyName && !propertyNameFromDb) {
|
|
120
|
-
logger(
|
|
121
|
-
`Property name from code is ${propertyName} but has not value in db ${propertyNameFromDb} for Property.${localId}`,
|
|
122
|
-
)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
propertyName &&
|
|
127
|
-
propertyNameFromDb &&
|
|
128
|
-
!propertyNameFromDb.includes(propertyName) &&
|
|
129
|
-
!propertyName.includes(propertyNameFromDb) &&
|
|
130
|
-
propertyNameFromDb !== propertyName
|
|
131
|
-
) {
|
|
132
|
-
logger(
|
|
133
|
-
`Property name from db ${propertyNameFromDb} does not match property name ${propertyName} for Property.${localId}`,
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (propertyValue && propertyValueFromDb !== propertyValue) {
|
|
138
|
-
logger(
|
|
139
|
-
`Property value from db ${propertyValueFromDb} does not match property value ${propertyValue} for Property.${localId}`,
|
|
140
|
-
)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (seedLocalIdFromDb !== seedLocalId) {
|
|
144
|
-
logger(
|
|
145
|
-
`Seed local id from db ${seedLocalIdFromDb} does not match seed local id ${seedLocalId} for Property.${localId}`,
|
|
146
|
-
)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
if (seedUidFromDb !== seedUid) {
|
|
150
|
-
logger(
|
|
151
|
-
`Seed uid from db ${seedUidFromDb} does not match seed uid ${seedUid} for Property.${localId}`,
|
|
152
|
-
)
|
|
153
|
-
}
|
|
154
118
|
|
|
155
119
|
if (
|
|
156
120
|
propertyRecordSchema &&
|
|
@@ -194,6 +158,8 @@ export const hydrateFromDb = fromCallback<
|
|
|
194
158
|
propertyValueFromDb &&
|
|
195
159
|
propertyValueFromDb.length === 66
|
|
196
160
|
) {
|
|
161
|
+
// Here the storageTransactionId is stored on a different record and
|
|
162
|
+
// we want to add it as the refResolvedValue
|
|
197
163
|
const storageTransactionQuery = await appDb
|
|
198
164
|
.select({
|
|
199
165
|
propertyValue: metadata.propertyValue,
|
|
@@ -107,7 +107,7 @@ export const propertyMachine = setup({
|
|
|
107
107
|
actions: assign({
|
|
108
108
|
refResolvedDisplayValue: ({ event }) =>
|
|
109
109
|
event.refResolvedDisplayValue,
|
|
110
|
-
|
|
110
|
+
refResolvedValue: ({ event }) => event.refResolvedValue,
|
|
111
111
|
}),
|
|
112
112
|
},
|
|
113
113
|
resolvingRelatedValueDone: {
|
|
@@ -111,7 +111,7 @@ export const saveItemStorage = fromCallback<
|
|
|
111
111
|
propertyRecordSchema.localStorageDir || propertyData.localStorageDir
|
|
112
112
|
const fileName =
|
|
113
113
|
propertyData.refResolvedValue ||
|
|
114
|
-
`${propertyData.seedLocalId}${propertyRecordSchema.filenameSuffix}`
|
|
114
|
+
`${propertyData.seedUid || propertyData.seedLocalId}${propertyRecordSchema.filenameSuffix}`
|
|
115
115
|
|
|
116
116
|
if (!localStorageDir || !fileName) {
|
|
117
117
|
throw new Error(
|
package/dist/src/waitForDb.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { EventObject, fromCallback } from 'xstate'
|
|
2
|
-
import {
|
|
2
|
+
import { FromCallbackInput, PropertyMachineContext } from '@/types'
|
|
3
3
|
import { BaseDb } from '@/db/Db/BaseDb'
|
|
4
4
|
|
|
5
|
-
export const waitForDb = fromCallback<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export const waitForDb = fromCallback<
|
|
6
|
+
EventObject,
|
|
7
|
+
FromCallbackInput<PropertyMachineContext>
|
|
8
|
+
>(({ sendBack }) => {
|
|
9
|
+
const _waitForDb = new Promise<void>((resolve) => {
|
|
10
|
+
const interval = setInterval(() => {
|
|
11
|
+
const appDb = BaseDb.getAppDb()
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
if (appDb) {
|
|
14
|
+
clearInterval(interval)
|
|
15
|
+
resolve()
|
|
16
|
+
}
|
|
17
|
+
}, 100)
|
|
18
|
+
})
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
)
|
|
20
|
+
_waitForDb.then(() => {
|
|
21
|
+
sendBack({ type: 'waitForDbSuccess' })
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hydrateFromDb.d.ts","sourceRoot":"","sources":["../../../../../../src/ItemProperty/service/actors/hydrateFromDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAOlD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAMpD,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"hydrateFromDb.d.ts","sourceRoot":"","sources":["../../../../../../src/ItemProperty/service/actors/hydrateFromDb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAOlD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAMpD,eAAO,MAAM,aAAa,oGA6PxB,CAAA"}
|
package/package.json
CHANGED