@seedprotocol/sdk 0.2.51 → 0.2.52
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/{ArweaveClient-D1TsTBoj.js → ArweaveClient-D5iJisYr.js} +2 -2
- package/dist/{ArweaveClient-DpdXUcVJ.js.map → ArweaveClient-D5iJisYr.js.map} +1 -1
- package/dist/{ArweaveClient-DpdXUcVJ.js → ArweaveClient-HEIIuOfB.js} +2 -2
- package/dist/{ArweaveClient-D1TsTBoj.js.map → ArweaveClient-HEIIuOfB.js.map} +1 -1
- package/dist/{Db-quJxmvHH.js → Db-D-BsZYlN.js} +3 -3
- package/dist/{Db-quJxmvHH.js.map → Db-D-BsZYlN.js.map} +1 -1
- package/dist/{Db-DMJ0v3gO.js → Db-Dpsbk_T7.js} +3 -3
- package/dist/{Db-DMJ0v3gO.js.map → Db-Dpsbk_T7.js.map} +1 -1
- package/dist/{EasClient-ClZDuT3o.js → EasClient-D3wKgt0o.js} +2 -2
- package/dist/{EasClient-DfnGY_2X.js.map → EasClient-D3wKgt0o.js.map} +1 -1
- package/dist/{EasClient-DfnGY_2X.js → EasClient-jqkT2ZBt.js} +2 -2
- package/dist/{EasClient-ClZDuT3o.js.map → EasClient-jqkT2ZBt.js.map} +1 -1
- package/dist/{FileManager-texI7UwL.js → FileManager-4mWYO3Mt.js} +3 -5
- package/dist/FileManager-4mWYO3Mt.js.map +1 -0
- package/dist/{Item-D4n439Ei.js → Item-CqWdJsyg.js} +3 -3
- package/dist/{Item-D4n439Ei.js.map → Item-CqWdJsyg.js.map} +1 -1
- package/dist/{ItemProperty-Be5ymRVT.js → ItemProperty-BpBW3IWx.js} +3 -3
- package/dist/{ItemProperty-Be5ymRVT.js.map → ItemProperty-BpBW3IWx.js.map} +1 -1
- package/dist/{QueryClient-B1HkAaJo.js → QueryClient-CBOP3OoU.js} +2 -2
- package/dist/{QueryClient-B1HkAaJo.js.map → QueryClient-CBOP3OoU.js.map} +1 -1
- package/dist/{QueryClient-BPoc9eBn.js → QueryClient-bKb3SB0W.js} +2 -2
- package/dist/{QueryClient-BPoc9eBn.js.map → QueryClient-bKb3SB0W.js.map} +1 -1
- package/dist/bin.js +5 -5
- package/dist/{constants-5PxfAeqj.js → constants-CIDbABDz.js} +2 -2
- package/dist/{constants-5PxfAeqj.js.map → constants-CIDbABDz.js.map} +1 -1
- package/dist/{index-BeKRizLf.js → index-BRxO1tLl.js} +257 -145
- package/dist/index-BRxO1tLl.js.map +1 -0
- package/dist/{index-BLla2o05.js → index-d8Qsot6w.js} +3 -3
- package/dist/index-d8Qsot6w.js.map +1 -0
- package/dist/main.js +2 -2
- package/dist/package.json +189 -0
- package/dist/{seed.schema.config-CMpV_hyS.js → seed.schema.config-CPRn6KVL.js} +3 -3
- package/dist/{seed.schema.config-CMpV_hyS.js.map → seed.schema.config-CPRn6KVL.js.map} +1 -1
- package/dist/types/src/client/BaseClientManager.d.ts +7 -0
- package/dist/types/src/client/BaseClientManager.d.ts.map +1 -0
- package/dist/types/src/client/actions/setAddresses.d.ts +2 -0
- package/dist/types/src/client/actions/setAddresses.d.ts.map +1 -0
- package/dist/types/src/client/actors/initialize.d.ts +4 -0
- package/dist/types/src/client/actors/initialize.d.ts.map +1 -0
- package/dist/types/src/client/actors/saveAppState.d.ts +5 -0
- package/dist/types/src/client/actors/saveAppState.d.ts.map +1 -0
- package/dist/types/src/client/clientManagerMachine.d.ts +19 -0
- package/dist/types/src/client/clientManagerMachine.d.ts.map +1 -0
- package/dist/types/src/client/index.d.ts +41 -0
- package/dist/types/src/client/index.d.ts.map +1 -0
- package/dist/types/src/client.d.ts.map +1 -1
- package/dist/types/src/node/helpers/FileManager.d.ts.map +1 -1
- package/dist/types/src/services/internal/actors/validateInput.d.ts.map +1 -1
- package/dist/types/src/types/machines.d.ts +5 -0
- package/dist/types/src/types/machines.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/FileManager-texI7UwL.js.map +0 -1
- package/dist/index-BLla2o05.js.map +0 -1
- package/dist/index-BeKRizLf.js.map +0 -1
- package/dist/src/AppStateSchema.ts +0 -10
- package/dist/src/ArweaveClient.ts +0 -13
- package/dist/src/Attestation.ts +0 -21
- package/dist/src/BaseArweaveClient.ts +0 -13
- package/dist/src/BaseDb.ts +0 -35
- package/dist/src/BaseEasClient.ts +0 -13
- package/dist/src/BaseFileManager.ts +0 -56
- package/dist/src/BaseItem.ts +0 -413
- package/dist/src/BaseItemProperty.ts +0 -416
- package/dist/src/BaseQueryClient.ts +0 -13
- package/dist/src/ConfigSchema.ts +0 -15
- package/dist/src/Db.ts +0 -78
- package/dist/src/EasClient.ts +0 -13
- package/dist/src/FileDownloader.ts +0 -63
- package/dist/src/FileManager.ts +0 -57
- package/dist/src/IDb.ts +0 -7
- package/dist/src/IEasClient.ts +0 -2
- package/dist/src/IItem.ts +0 -26
- package/dist/src/IItemProperty.ts +0 -28
- package/dist/src/IQueryClient.ts +0 -4
- package/dist/src/ImageResizer.ts +0 -81
- package/dist/src/Item.ts +0 -12
- package/dist/src/ItemProperty.ts +0 -9
- package/dist/src/MetadataSchema.ts +0 -28
- package/dist/src/ModelSchema.ts +0 -46
- package/dist/src/ModelUidSchema.ts +0 -16
- package/dist/src/PropertyUidSchema.ts +0 -16
- package/dist/src/QueryClient.ts +0 -22
- package/dist/src/Schema.ts +0 -17
- package/dist/src/SeedProtocolSdk.d.ts +0 -19
- package/dist/src/SeedSchema.ts +0 -29
- package/dist/src/VersionSchema.ts +0 -16
- package/dist/src/actors.ts +0 -295
- package/dist/src/addModelsToDb.ts +0 -152
- package/dist/src/allItems.ts +0 -31
- package/dist/src/analyzeInput.ts +0 -144
- package/dist/src/browser.app.db.config.ts +0 -27
- package/dist/src/browser.ts +0 -30
- package/dist/src/checkStatus.ts +0 -50
- package/dist/src/client.ts +0 -148
- package/dist/src/configureFs.ts +0 -94
- package/dist/src/connectToDb.ts +0 -41
- package/dist/src/connectionManager.ts +0 -67
- package/dist/src/constants.ts +0 -125
- package/dist/src/content-hash.ts +0 -30
- package/dist/src/create.ts +0 -39
- package/dist/src/createMetadata.ts +0 -77
- package/dist/src/createNewItem.ts +0 -61
- package/dist/src/createPublishAttempt.ts +0 -16
- package/dist/src/createSeed.ts +0 -31
- package/dist/src/createSeeds.ts +0 -24
- package/dist/src/createVersion.ts +0 -33
- package/dist/src/dbMachine.ts +0 -182
- package/dist/src/deleteItem.ts +0 -19
- package/dist/src/download.ts +0 -202
- package/dist/src/drizzle.ts +0 -78
- package/dist/src/eas.ts +0 -40
- package/dist/src/environment.ts +0 -35
- package/dist/src/eventBus.ts +0 -5
- package/dist/src/events.ts +0 -14
- package/dist/src/fetchDataFromEas.ts +0 -94
- package/dist/src/fetchDbData.ts +0 -19
- package/dist/src/fetchRelatedItems.ts +0 -184
- package/dist/src/fetchSeeds.ts +0 -52
- package/dist/src/fetchVersions.ts +0 -49
- package/dist/src/files.ts +0 -81
- package/dist/src/filesDownload.ts +0 -326
- package/dist/src/fragment-masking.ts +0 -87
- package/dist/src/getExistingItem.ts +0 -60
- package/dist/src/getItem.ts +0 -32
- package/dist/src/getItemData.ts +0 -99
- package/dist/src/getItemProperties.ts +0 -56
- package/dist/src/getItemProperty.ts +0 -34
- package/dist/src/getItems.ts +0 -70
- package/dist/src/getMetadata.ts +0 -40
- package/dist/src/getModelSchemas.ts +0 -89
- package/dist/src/getPropertyData.ts +0 -50
- package/dist/src/getPublishPayload.ts +0 -355
- package/dist/src/getPublishUploads.ts +0 -207
- package/dist/src/getRelationValueData.ts +0 -27
- package/dist/src/getSchemaForItemProperty.ts +0 -68
- package/dist/src/getSchemaForModel.ts +0 -42
- package/dist/src/getSchemaUidForModel.ts +0 -32
- package/dist/src/getSeedData.ts +0 -34
- package/dist/src/getSegmentedItemProperties.ts +0 -65
- package/dist/src/getStorageTransactionIdForSeedUid.ts +0 -38
- package/dist/src/getVersionData.ts +0 -46
- package/dist/src/getVersionsForVersionUids.ts +0 -39
- package/dist/src/globalMachine.ts +0 -280
- package/dist/src/gql.ts +0 -118
- package/dist/src/graphql.ts +0 -3209
- package/dist/src/helpers.ts +0 -273
- package/dist/src/hydrateExistingItem.ts +0 -137
- package/dist/src/hydrateFromDb.ts +0 -270
- package/dist/src/hydrateNewItem.ts +0 -34
- package/dist/src/imageResize.ts +0 -507
- package/dist/src/index.d.ts +0 -5
- package/dist/src/index.ts +0 -4
- package/dist/src/initialize.ts +0 -124
- package/dist/src/internalMachine.ts +0 -238
- package/dist/src/itemMachineAll.ts +0 -157
- package/dist/src/itemMachineSingle.ts +0 -158
- package/dist/src/loadAppDb.ts +0 -47
- package/dist/src/machines.ts +0 -60
- package/dist/src/metadataLatest.ts +0 -34
- package/dist/src/migrate.ts +0 -53
- package/dist/src/model.ts +0 -72
- package/dist/src/modelClass.ts +0 -19
- package/dist/src/node.app.db.config.ts +0 -41
- package/dist/src/prepareDb.ts +0 -29
- package/dist/src/preparePublishRequestData.ts +0 -81
- package/dist/src/processItems.ts +0 -74
- package/dist/src/property.ts +0 -156
- package/dist/src/propertyMachine.ts +0 -202
- package/dist/src/publish.ts +0 -28
- package/dist/src/publishMachine.ts +0 -77
- package/dist/src/queries.ts +0 -13
- package/dist/src/recoverDeletedItem.ts +0 -14
- package/dist/src/reload.ts +0 -33
- package/dist/src/request.ts +0 -45
- package/dist/src/requestAll.ts +0 -157
- package/dist/src/resolveRelatedValue.ts +0 -367
- package/dist/src/resolveRemoteStorage.ts +0 -88
- package/dist/src/saveAppState.ts +0 -19
- package/dist/src/saveConfig.ts +0 -88
- package/dist/src/saveDataToDb.ts +0 -145
- package/dist/src/saveImageSrc.ts +0 -242
- package/dist/src/saveItemStorage.ts +0 -156
- package/dist/src/saveMetadata.ts +0 -18
- package/dist/src/savePublishService.ts +0 -30
- package/dist/src/saveRelation.ts +0 -112
- package/dist/src/seed.schema.config.ts +0 -25
- package/dist/src/seed.ts +0 -10
- package/dist/src/seedProtocol.ts +0 -17
- package/dist/src/services.ts +0 -365
- package/dist/src/sqlWasmClient.ts +0 -88
- package/dist/src/syncDbWithEas.ts +0 -628
- package/dist/src/trash.ts +0 -29
- package/dist/src/ts-to-proto.ts +0 -101
- package/dist/src/types.ts +0 -12
- package/dist/src/updateItemPropertyValue.ts +0 -243
- package/dist/src/updateMachineContext.ts +0 -21
- package/dist/src/updateMetadata.ts +0 -59
- package/dist/src/upload.ts +0 -86
- package/dist/src/validate.ts +0 -45
- package/dist/src/validateInput.ts +0 -47
- package/dist/src/validateItemData.ts +0 -20
- package/dist/src/versionData.ts +0 -24
- package/dist/src/waitForDb.ts +0 -25
- package/dist/src/waitForFiles.ts +0 -34
- package/dist/src/wasm.d.ts +0 -8300
package/dist/src/dbMachine.ts
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { assign, setup } from 'xstate'
|
|
2
|
-
import {
|
|
3
|
-
DB_CHECK_STATUS_EXISTS,
|
|
4
|
-
DB_CHECK_STATUS_UPDATE_PATHS,
|
|
5
|
-
DB_CREATING_SUCCESS,
|
|
6
|
-
DB_MIGRATING_SUCCESS,
|
|
7
|
-
DB_MIGRATING_WAIT,
|
|
8
|
-
DB_VALIDATING_SUCCESS,
|
|
9
|
-
DB_VALIDATING_WAIT,
|
|
10
|
-
DB_WAITING_FOR_FILES_RECEIVED,
|
|
11
|
-
DbState,
|
|
12
|
-
MachineIds,
|
|
13
|
-
} from '../internal/constants'
|
|
14
|
-
import debug from 'debug'
|
|
15
|
-
import { DbServiceContext } from '@/types'
|
|
16
|
-
import { checkStatus } from '@/services/db/actors/checkStatus'
|
|
17
|
-
import { connectToDb } from '@/services/db/actors/connectToDb'
|
|
18
|
-
import { validate } from '@/services/db/actors/validate'
|
|
19
|
-
import { migrate } from '@/services/db/actors/migrate'
|
|
20
|
-
import { waitForFiles } from './actors/waitForFiles'
|
|
21
|
-
|
|
22
|
-
const logger = debug('app:services:db:machine')
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
CHECKING_STATUS,
|
|
26
|
-
VALIDATING,
|
|
27
|
-
WAITING_FOR_FILES,
|
|
28
|
-
CONNECTING_TO_DB,
|
|
29
|
-
MIGRATING,
|
|
30
|
-
} = DbState
|
|
31
|
-
|
|
32
|
-
const dbMachine = setup({
|
|
33
|
-
types: {
|
|
34
|
-
context: {} as Partial<DbServiceContext>,
|
|
35
|
-
input: {} as Partial<DbServiceContext> | undefined,
|
|
36
|
-
},
|
|
37
|
-
actors: {
|
|
38
|
-
checkStatus,
|
|
39
|
-
validate,
|
|
40
|
-
connectToDb,
|
|
41
|
-
migrate,
|
|
42
|
-
waitForFiles,
|
|
43
|
-
},
|
|
44
|
-
}).createMachine({
|
|
45
|
-
id: MachineIds.DB,
|
|
46
|
-
initial: CHECKING_STATUS,
|
|
47
|
-
context: ({ input }) => input as DbServiceContext,
|
|
48
|
-
on: {
|
|
49
|
-
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
50
|
-
actions: assign({
|
|
51
|
-
hasFiles: ({ event }) => {
|
|
52
|
-
logger('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event)
|
|
53
|
-
return true
|
|
54
|
-
},
|
|
55
|
-
}),
|
|
56
|
-
},
|
|
57
|
-
updateHasFiles: {
|
|
58
|
-
target: `.${CHECKING_STATUS}`,
|
|
59
|
-
actions: assign({
|
|
60
|
-
hasFiles: ({ context, event }) => {
|
|
61
|
-
logger('[db/machine] updateHasFiles event:', event)
|
|
62
|
-
logger('[db/machine] updateHasFiles context:', context)
|
|
63
|
-
return event.hasFiles
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
// always: {
|
|
69
|
-
// target: `.${CHECKING_STATUS}`,
|
|
70
|
-
// guard: ({ context, event }) => context.hasFiles && event.type === 'updateHasFiles',
|
|
71
|
-
// },
|
|
72
|
-
states: {
|
|
73
|
-
idle: {
|
|
74
|
-
on: {
|
|
75
|
-
start: CHECKING_STATUS,
|
|
76
|
-
},
|
|
77
|
-
meta: {
|
|
78
|
-
displayText: 'DB starting ...',
|
|
79
|
-
percentComplete: 0,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
[CHECKING_STATUS]: {
|
|
83
|
-
on: {
|
|
84
|
-
[DB_CHECK_STATUS_UPDATE_PATHS]: {
|
|
85
|
-
actions: assign({
|
|
86
|
-
pathToDb: ({ event }) => event.pathToDb,
|
|
87
|
-
pathToDir: ({ event }) => event.pathToDir,
|
|
88
|
-
pathToDbDir: ({ event }) => event.pathToDbDir,
|
|
89
|
-
}),
|
|
90
|
-
},
|
|
91
|
-
[DB_CHECK_STATUS_EXISTS]: CONNECTING_TO_DB,
|
|
92
|
-
},
|
|
93
|
-
invoke: {
|
|
94
|
-
src: 'checkStatus',
|
|
95
|
-
input: ({ context, event }) => ({ context, event }),
|
|
96
|
-
},
|
|
97
|
-
meta: {
|
|
98
|
-
displayText: 'Checking DB status',
|
|
99
|
-
percentComplete: 60,
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
[CONNECTING_TO_DB]: {
|
|
103
|
-
on: {
|
|
104
|
-
[DB_CREATING_SUCCESS]: {
|
|
105
|
-
target: VALIDATING,
|
|
106
|
-
actions: assign({
|
|
107
|
-
dbId: ({ event }) => event.dbId,
|
|
108
|
-
}),
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
invoke: {
|
|
112
|
-
src: 'connectToDb',
|
|
113
|
-
input: ({ context }) => ({ context }),
|
|
114
|
-
},
|
|
115
|
-
meta: {
|
|
116
|
-
displayText: 'Connecting to local DB',
|
|
117
|
-
percentComplete: 70,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
[VALIDATING]: {
|
|
121
|
-
on: {
|
|
122
|
-
[DB_VALIDATING_SUCCESS]: {
|
|
123
|
-
target: MIGRATING,
|
|
124
|
-
// guard: ({ context }) => context.hasFiles,
|
|
125
|
-
},
|
|
126
|
-
[DB_VALIDATING_WAIT]: {
|
|
127
|
-
target: WAITING_FOR_FILES,
|
|
128
|
-
// guard: ({ context }) => !context.hasFiles,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
invoke: {
|
|
132
|
-
src: 'validate',
|
|
133
|
-
input: ({ context }) => ({ context }),
|
|
134
|
-
},
|
|
135
|
-
meta: {
|
|
136
|
-
displayText: 'Validating DB',
|
|
137
|
-
percentComplete: 80,
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
// Here we're waiting for migration and schema files to be downloaded
|
|
141
|
-
[WAITING_FOR_FILES]: {
|
|
142
|
-
on: {
|
|
143
|
-
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
144
|
-
target: MIGRATING,
|
|
145
|
-
actions: assign({
|
|
146
|
-
hasFiles: true,
|
|
147
|
-
}),
|
|
148
|
-
},
|
|
149
|
-
[DB_MIGRATING_SUCCESS]: 'ready',
|
|
150
|
-
},
|
|
151
|
-
invoke: {
|
|
152
|
-
src: 'waitForFiles',
|
|
153
|
-
input: ({ context }) => ({ context }),
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
[MIGRATING]: {
|
|
157
|
-
on: {
|
|
158
|
-
[DB_MIGRATING_WAIT]: WAITING_FOR_FILES,
|
|
159
|
-
[DB_MIGRATING_SUCCESS]: {
|
|
160
|
-
target: 'ready',
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
invoke: {
|
|
164
|
-
src: 'migrate',
|
|
165
|
-
input: ({ context }) => ({ context }),
|
|
166
|
-
},
|
|
167
|
-
meta: {
|
|
168
|
-
displayText: 'Migrating DB',
|
|
169
|
-
percentComplete: 90,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
ready: {
|
|
173
|
-
target: 'idle',
|
|
174
|
-
meta: {
|
|
175
|
-
displayText: 'Wrapping up the db ...',
|
|
176
|
-
percentComplete: 100,
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
export { dbMachine }
|
package/dist/src/deleteItem.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BaseDb } from '@/db/Db/BaseDb'
|
|
2
|
-
import { seeds } from '@/seedSchema'
|
|
3
|
-
import { eq, or } from 'drizzle-orm'
|
|
4
|
-
|
|
5
|
-
type DeleteItemProps = {
|
|
6
|
-
seedLocalId?: string
|
|
7
|
-
seedUid?: string
|
|
8
|
-
}
|
|
9
|
-
type DeleteItem = (props: DeleteItemProps) => Promise<void>
|
|
10
|
-
export const deleteItem: DeleteItem = async ({ seedLocalId, seedUid }) => {
|
|
11
|
-
const appDb = BaseDb.getAppDb()
|
|
12
|
-
|
|
13
|
-
await appDb
|
|
14
|
-
.update(seeds)
|
|
15
|
-
.set({
|
|
16
|
-
_markedForDeletion: 1,
|
|
17
|
-
})
|
|
18
|
-
.where(or(eq(seeds.localId, seedLocalId), eq(seeds.uid, seedUid)))
|
|
19
|
-
}
|
package/dist/src/download.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { syncDbFiles } from '@/services/internal/helpers'
|
|
2
|
-
import { eventEmitter } from '@/eventBus'
|
|
3
|
-
import fs from '@zenfs/core'
|
|
4
|
-
import { ARWEAVE_HOST } from '@/services/internal/constants'
|
|
5
|
-
import { appState } from '@/seedSchema'
|
|
6
|
-
import { eq } from 'drizzle-orm'
|
|
7
|
-
import { getAddressesFromDb } from '@/helpers/db'
|
|
8
|
-
import {
|
|
9
|
-
BaseFileManager,
|
|
10
|
-
} from '@/helpers'
|
|
11
|
-
import { GET_FILES_METADATA } from '@/schema/file/queries'
|
|
12
|
-
import debug from 'debug'
|
|
13
|
-
import { getGlobalService } from '@/services'
|
|
14
|
-
import { waitFor } from 'xstate'
|
|
15
|
-
import { getMetadata } from '@/db/read/getMetadata'
|
|
16
|
-
import { saveMetadata } from '@/db/write/saveMetadata'
|
|
17
|
-
import { GET_TRANSACTION_TAGS } from '@/helpers/ArweaveClient/queries'
|
|
18
|
-
import { saveAppState } from '@/db/write/saveAppState'
|
|
19
|
-
import { BaseDb } from '@/db/Db/BaseDb'
|
|
20
|
-
import { BaseEasClient, BaseQueryClient, BaseArweaveClient } from '@/helpers'
|
|
21
|
-
import { getArweave } from '@/helpers/ArweaveClient'
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const logger = debug('app:files:download')
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export const downloadAllFilesRequestHandler = async ({
|
|
28
|
-
endpoints,
|
|
29
|
-
eventId,
|
|
30
|
-
}) => {
|
|
31
|
-
await syncDbFiles(endpoints)
|
|
32
|
-
|
|
33
|
-
eventEmitter.emit('fs.downloadAll.success', { eventId })
|
|
34
|
-
eventEmitter.emit('fs.downloadAllBinary.request', { endpoints })
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const downloadAllFilesBinaryRequestHandler = async () => {
|
|
38
|
-
let addresses: string[] | undefined
|
|
39
|
-
|
|
40
|
-
if (BaseDb.isAppDbReady()) {
|
|
41
|
-
addresses = await getAddressesFromDb()
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!BaseDb.isAppDbReady()) {
|
|
45
|
-
const globalService = getGlobalService()
|
|
46
|
-
const internalService = globalService.getSnapshot().context.internalService
|
|
47
|
-
if (internalService) {
|
|
48
|
-
await waitFor(internalService, (snapshot) => {
|
|
49
|
-
return snapshot.value === 'ready'
|
|
50
|
-
})
|
|
51
|
-
addresses = await getAddressesFromDb()
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!addresses || addresses.length === 0) {
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const queryClient = BaseQueryClient.getQueryClient()
|
|
60
|
-
const easClient = BaseEasClient.getEasClient()
|
|
61
|
-
|
|
62
|
-
const { filesMetadata } = await queryClient.fetchQuery({
|
|
63
|
-
queryKey: ['getFilesMetadata', ...addresses],
|
|
64
|
-
queryFn: async () =>
|
|
65
|
-
easClient.request(GET_FILES_METADATA, {
|
|
66
|
-
where: {
|
|
67
|
-
attester: {
|
|
68
|
-
in: addresses,
|
|
69
|
-
},
|
|
70
|
-
schema: {
|
|
71
|
-
is: {
|
|
72
|
-
id: {
|
|
73
|
-
equals:
|
|
74
|
-
'0x55fdefb36fcbbaebeb7d6b41dc3a1a9666e4e42154267c889de064faa7ede517',
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
}),
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
await BaseFileManager.createDirIfNotExists('/files')
|
|
83
|
-
await BaseFileManager.createDirIfNotExists('/files/html')
|
|
84
|
-
await BaseFileManager.createDirIfNotExists('/files/json')
|
|
85
|
-
await BaseFileManager.createDirIfNotExists('/files/images')
|
|
86
|
-
|
|
87
|
-
const appDb = BaseDb.getAppDb()
|
|
88
|
-
|
|
89
|
-
if (!appDb) {
|
|
90
|
-
console.warn('[fetchAll/actors] [fetchAllBinaryData] seedDb not available')
|
|
91
|
-
return []
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const excludedTransactionsQuery = await appDb
|
|
95
|
-
.select()
|
|
96
|
-
.from(appState)
|
|
97
|
-
.where(eq(appState.key, 'excludedTransactions'))
|
|
98
|
-
|
|
99
|
-
let excludedTransactions = new Set<string>()
|
|
100
|
-
|
|
101
|
-
if (excludedTransactionsQuery && excludedTransactionsQuery.length === 1) {
|
|
102
|
-
const valueString = excludedTransactionsQuery[0].value
|
|
103
|
-
if (valueString) {
|
|
104
|
-
const excludedTransactionsArray = JSON.parse(valueString)
|
|
105
|
-
excludedTransactions = new Set(excludedTransactionsArray)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const transactionIds = []
|
|
110
|
-
|
|
111
|
-
for (const fileMetadata of filesMetadata) {
|
|
112
|
-
const json = JSON.parse(fileMetadata.decodedDataJson)
|
|
113
|
-
const transactionId = json[0].value.value
|
|
114
|
-
if (excludedTransactions.has(transactionId)) {
|
|
115
|
-
continue
|
|
116
|
-
}
|
|
117
|
-
transactionIds.push(transactionId)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const arweave = getArweave()
|
|
121
|
-
|
|
122
|
-
if (!arweave) {
|
|
123
|
-
console.warn(
|
|
124
|
-
'[fetchAll/actors] [fetchAllBinaryData] arweave not available',
|
|
125
|
-
)
|
|
126
|
-
return []
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const arweaveClient = BaseArweaveClient.getArweaveClient()
|
|
130
|
-
|
|
131
|
-
const transactionIdsToDownload = []
|
|
132
|
-
|
|
133
|
-
for (const transactionId of transactionIds) {
|
|
134
|
-
|
|
135
|
-
try {
|
|
136
|
-
const res = await fetch(
|
|
137
|
-
`https://${ARWEAVE_HOST}/tx/${transactionId}/status`,
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
if (res.status !== 200) {
|
|
141
|
-
logger(
|
|
142
|
-
`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`,
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
excludedTransactions.add(transactionId)
|
|
146
|
-
|
|
147
|
-
await saveAppState(
|
|
148
|
-
'excludedTransactions',
|
|
149
|
-
JSON.stringify(Array.from(excludedTransactions)),
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
continue
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const { tags: tagsResult } = await queryClient.fetchQuery({
|
|
156
|
-
queryKey: ['getTransactionTags', transactionId],
|
|
157
|
-
queryFn: async () =>
|
|
158
|
-
arweaveClient.request(GET_TRANSACTION_TAGS, {
|
|
159
|
-
transactionId,
|
|
160
|
-
}),
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
const tags = tagsResult.tags || []
|
|
164
|
-
|
|
165
|
-
if (tagsResult.tags && tagsResult.tags.length > 0) {
|
|
166
|
-
for (const { name, value } of tags) {
|
|
167
|
-
if (name === 'Content-SHA-256') {
|
|
168
|
-
const metadataRecord = await getMetadata({
|
|
169
|
-
storageTransactionId: transactionId,
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
if (metadataRecord) {
|
|
173
|
-
await saveMetadata(metadataRecord, {
|
|
174
|
-
contentHash: value,
|
|
175
|
-
})
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
transactionIdsToDownload.push(transactionId)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
} catch (error) {
|
|
186
|
-
logger(error)
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
console.log('[download] Calling downloadAllFiles with transactionIdsToDownload', transactionIdsToDownload)
|
|
191
|
-
|
|
192
|
-
await BaseFileManager.downloadAllFiles({
|
|
193
|
-
transactionIds: transactionIdsToDownload,
|
|
194
|
-
arweaveHost: ARWEAVE_HOST,
|
|
195
|
-
excludedTransactions,
|
|
196
|
-
})
|
|
197
|
-
|
|
198
|
-
await BaseFileManager.resizeAllImages({
|
|
199
|
-
width: 480,
|
|
200
|
-
height: 480,
|
|
201
|
-
})
|
|
202
|
-
}
|
package/dist/src/drizzle.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
import fs from 'fs'
|
|
3
|
-
import pluralize from 'pluralize'
|
|
4
|
-
import { camelCase, snakeCase } from 'lodash-es'
|
|
5
|
-
import * as nunjucks from 'nunjucks'
|
|
6
|
-
import { ILoader } from 'nunjucks'
|
|
7
|
-
import { ModelClassType } from '@/types'
|
|
8
|
-
import { SCHEMA_NJK } from '@/helpers/constants'
|
|
9
|
-
import {
|
|
10
|
-
appGeneratedSchemaDir,
|
|
11
|
-
dotSeedDir,
|
|
12
|
-
templatePath,
|
|
13
|
-
} from '@/node/constants'
|
|
14
|
-
import { getTsImport } from '@/node/helpers'
|
|
15
|
-
|
|
16
|
-
const TemplateLoader: ILoader = {
|
|
17
|
-
getSource: (name: string) => {
|
|
18
|
-
let templateFilePath
|
|
19
|
-
if (name.includes(templatePath)) {
|
|
20
|
-
templateFilePath = name
|
|
21
|
-
} else {
|
|
22
|
-
templateFilePath = path.join(templatePath, path.basename(name))
|
|
23
|
-
}
|
|
24
|
-
const src = fs.readFileSync(templateFilePath, 'utf-8')
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
path: name,
|
|
28
|
-
src,
|
|
29
|
-
noCache: false,
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Configure Nunjucks
|
|
35
|
-
const env = new nunjucks.Environment(TemplateLoader)
|
|
36
|
-
|
|
37
|
-
env.addFilter('camelCase', camelCase)
|
|
38
|
-
env.addFilter('snakeCase', snakeCase)
|
|
39
|
-
env.addFilter('pluralize', pluralize)
|
|
40
|
-
|
|
41
|
-
const generateDrizzleSchemaCode = (
|
|
42
|
-
modelName: string,
|
|
43
|
-
modelClass: ModelClassType,
|
|
44
|
-
): string => {
|
|
45
|
-
const listProperties = Object.entries(modelClass.schema).filter(
|
|
46
|
-
([key, propertyDef]) => propertyDef?.dataType === 'List',
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
const filePath = path.join(templatePath, SCHEMA_NJK)
|
|
50
|
-
|
|
51
|
-
const schemaCode = env.render(filePath, {
|
|
52
|
-
modelName,
|
|
53
|
-
modelClass,
|
|
54
|
-
listProperties,
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
return schemaCode
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export const createDrizzleSchemaFilesFromConfig = async () => {
|
|
61
|
-
const schemaFilePath = path.join(dotSeedDir, 'schema.ts') // Developer created file with model definitions
|
|
62
|
-
|
|
63
|
-
const { models } = await getTsImport<{
|
|
64
|
-
models: Record<string, ModelClassType>
|
|
65
|
-
}>(schemaFilePath)
|
|
66
|
-
|
|
67
|
-
for (const [modelName, modelClass] of Object.entries(models)) {
|
|
68
|
-
const code = generateDrizzleSchemaCode(modelName, modelClass)
|
|
69
|
-
|
|
70
|
-
if (!fs.existsSync(appGeneratedSchemaDir)) {
|
|
71
|
-
fs.mkdirSync(appGeneratedSchemaDir)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const filePath = path.join(appGeneratedSchemaDir, `${modelName}Schema.ts`)
|
|
75
|
-
|
|
76
|
-
await fs.promises.writeFile(filePath, code).catch((e) => console.error(e))
|
|
77
|
-
}
|
|
78
|
-
}
|
package/dist/src/eas.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { toSnakeCase } from '@/helpers'
|
|
2
|
-
import { getSchemaForItemProperty } from '@/helpers/getSchemaForItemProperty'
|
|
3
|
-
|
|
4
|
-
const schemaUidForSchemaDefinition = new Map<string, string>()
|
|
5
|
-
|
|
6
|
-
export const setSchemaUidForSchemaDefinition = ({ text, schemaUid }) => {
|
|
7
|
-
const propertySnakeCase = toSnakeCase(text)
|
|
8
|
-
schemaUidForSchemaDefinition.set(propertySnakeCase, schemaUid)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const getSchemaUidForSchemaDefinition = (schemaText: string) => {
|
|
12
|
-
const textSnakeCase = toSnakeCase(schemaText)
|
|
13
|
-
if (!schemaUidForSchemaDefinition.has(textSnakeCase)) {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
return schemaUidForSchemaDefinition.get(textSnakeCase)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const fetchSchemaUids = async () => {
|
|
20
|
-
const versionSchemaUid = await getSchemaForItemProperty({
|
|
21
|
-
propertyName: 'version',
|
|
22
|
-
easDataType: 'bytes32',
|
|
23
|
-
})
|
|
24
|
-
if (versionSchemaUid) {
|
|
25
|
-
setSchemaUidForSchemaDefinition({
|
|
26
|
-
text: 'version',
|
|
27
|
-
schemaUid: versionSchemaUid,
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
const imageSchemaUid = await getSchemaForItemProperty({
|
|
31
|
-
propertyName: 'image',
|
|
32
|
-
easDataType: 'bytes32',
|
|
33
|
-
})
|
|
34
|
-
if (imageSchemaUid) {
|
|
35
|
-
setSchemaUidForSchemaDefinition({
|
|
36
|
-
text: 'image',
|
|
37
|
-
schemaUid: imageSchemaUid,
|
|
38
|
-
})
|
|
39
|
-
}
|
|
40
|
-
}
|
package/dist/src/environment.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export const isNode = (): boolean => {
|
|
2
|
-
return (
|
|
3
|
-
typeof process !== 'undefined' &&
|
|
4
|
-
process.versions != null &&
|
|
5
|
-
process.versions.node != null
|
|
6
|
-
)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const isBrowser = (): boolean => {
|
|
10
|
-
return !isElectron() && typeof window !== 'undefined' && typeof window.document !== 'undefined'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const isReactNative = (): boolean => {
|
|
14
|
-
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative'
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const isElectron = (): boolean => {
|
|
18
|
-
return typeof process !== 'undefined' && process.versions != null && process.versions.electron != null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const getEnvironment = (): string => {
|
|
22
|
-
if (isBrowser()) {
|
|
23
|
-
return 'browser'
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (isElectron()) {
|
|
27
|
-
return 'electron'
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (isReactNative()) {
|
|
31
|
-
return 'react-native'
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return 'node'
|
|
35
|
-
}
|
package/dist/src/eventBus.ts
DELETED
package/dist/src/events.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { eventEmitter } from '@/eventBus'
|
|
2
|
-
import debug from 'debug'
|
|
3
|
-
|
|
4
|
-
const logger = debug('app:services:events')
|
|
5
|
-
|
|
6
|
-
const handleServiceSaveState = (event: any) => {
|
|
7
|
-
const { state, serviceId } = event
|
|
8
|
-
logger(`[browser] [service.saveState.request] serviceId: ${serviceId}`)
|
|
9
|
-
localStorage.setItem(`seed_sdk_service_${serviceId}`, JSON.stringify(state))
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const setupServicesEventHandlers = () => {
|
|
13
|
-
eventEmitter.addListener('service.saveState.request', handleServiceSaveState)
|
|
14
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { EventObject, fromCallback } from 'xstate'
|
|
2
|
-
import { GET_PROPERTIES } from '@/Item/queries'
|
|
3
|
-
import { itemMachineSingle } from '@/Item/service/itemMachineSingle'
|
|
4
|
-
import { PropertyType } from '@/seedSchema'
|
|
5
|
-
import { Attestation } from '@/graphql/gql/graphql'
|
|
6
|
-
import { ModelClassType } from '@/types'
|
|
7
|
-
import { BaseEasClient, BaseQueryClient } from '@/helpers'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export const fetchDataFromEas = fromCallback<
|
|
11
|
-
EventObject,
|
|
12
|
-
typeof itemMachineSingle
|
|
13
|
-
>(({ sendBack, input: { context } }) => {
|
|
14
|
-
const { ModelClass, modelTableName, versionUid } = context
|
|
15
|
-
|
|
16
|
-
const propertiesMetadata = new Map<string, PropertyType>()
|
|
17
|
-
|
|
18
|
-
// EAS is the final source of truth, so we need to see if our Item is
|
|
19
|
-
// already represented there. Then we need to intelligently sync/merge
|
|
20
|
-
// with whatever new data has been created on the device before the sync.
|
|
21
|
-
for (const [propertyName, propertyMetadata] of Object.entries(
|
|
22
|
-
(ModelClass as ModelClassType).schema,
|
|
23
|
-
)) {
|
|
24
|
-
if (propertyMetadata) {
|
|
25
|
-
propertiesMetadata.set(propertyName, propertyMetadata)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
sendBack({ type: 'updatePropertiesMetadata', propertiesMetadata })
|
|
30
|
-
|
|
31
|
-
if (!versionUid) {
|
|
32
|
-
// In this case this is a local only item, so we don't need to fetch anything
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const _fetchDataFromEas = async (): Promise<void> => {
|
|
37
|
-
const queryClient = BaseQueryClient.getQueryClient()
|
|
38
|
-
const easClient = BaseEasClient.getEasClient()
|
|
39
|
-
|
|
40
|
-
// Fetch Properties by versionUid
|
|
41
|
-
const { itemProperties } = await queryClient.fetchQuery({
|
|
42
|
-
queryKey: ['getProperties', versionUid],
|
|
43
|
-
queryFn: async () =>
|
|
44
|
-
easClient.request(GET_PROPERTIES, {
|
|
45
|
-
where: {
|
|
46
|
-
refUID: {
|
|
47
|
-
in: [versionUid],
|
|
48
|
-
},
|
|
49
|
-
decodedDataJson: {
|
|
50
|
-
not: {
|
|
51
|
-
// The first of many filters to keep bad data out
|
|
52
|
-
contains:
|
|
53
|
-
'"value":"0x0000000000000000000000000000000000000000000000000000000000000020"',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
}),
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
// Filter properties by schemaId
|
|
61
|
-
const selectedPropertiesMap: {
|
|
62
|
-
[schemaId: string]: Attestation[]
|
|
63
|
-
} = {}
|
|
64
|
-
itemProperties.forEach((property) => {
|
|
65
|
-
const existingProperties = selectedPropertiesMap[property.schemaId] || []
|
|
66
|
-
existingProperties.push(property)
|
|
67
|
-
selectedPropertiesMap[property.schemaId] = existingProperties
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
// For each schemaId, sort property Attestations by timeCreated DESC
|
|
71
|
-
Object.keys(selectedPropertiesMap).forEach((schemaId) => {
|
|
72
|
-
const sorted = selectedPropertiesMap[schemaId].sort((a, b) => {
|
|
73
|
-
return a.timeCreated - b.timeCreated
|
|
74
|
-
})
|
|
75
|
-
selectedPropertiesMap[schemaId] = sorted
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
Object.keys(selectedPropertiesMap).forEach((schemaId) => {
|
|
79
|
-
// TODO: Finish this logic
|
|
80
|
-
// console.log('[singleItemActors] [fetchDataFromEas] schemaId', schemaId)
|
|
81
|
-
// sendBack({ type: 'addPropertyAttestation', schemaId })
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
// Attach processed properties to the itemService/itemMachine context
|
|
85
|
-
sendBack({
|
|
86
|
-
type: 'updatedPropertiesBySchemaUid',
|
|
87
|
-
propertiesBySchemaUid: selectedPropertiesMap,
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
_fetchDataFromEas().then(() => {
|
|
92
|
-
sendBack({ type: 'fetchDataFromEasSuccess' })
|
|
93
|
-
})
|
|
94
|
-
})
|
package/dist/src/fetchDbData.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { EventObject, fromCallback } from 'xstate'
|
|
2
|
-
import { AllItemsMachineContext, FromCallbackInput } from '@/types'
|
|
3
|
-
|
|
4
|
-
export const fetchDbData = fromCallback<
|
|
5
|
-
EventObject,
|
|
6
|
-
FromCallbackInput<AllItemsMachineContext>
|
|
7
|
-
>(
|
|
8
|
-
({ sendBack, input: { context } }) => {
|
|
9
|
-
const { modelNamePlural, times } = context
|
|
10
|
-
|
|
11
|
-
const _fetchDbData = async (): Promise<void> => { }
|
|
12
|
-
|
|
13
|
-
_fetchDbData().then(() => {
|
|
14
|
-
sendBack({ type: 'fetchDbDataSuccess' })
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
return () => { }
|
|
18
|
-
},
|
|
19
|
-
)
|