@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
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { assign, setup } from 'xstate'
|
|
2
|
-
import { PropertyMachineContext } from '@/types'
|
|
3
|
-
|
|
4
|
-
import { resolveRemoteStorage } from '@/ItemProperty/service/actors/resolveRemoteStorage'
|
|
5
|
-
import { waitForDb } from '@/ItemProperty/service/actors/waitForDb'
|
|
6
|
-
import { initialize } from '@/ItemProperty/service/actors/initialize'
|
|
7
|
-
import { resolveRelatedValue } from '@/ItemProperty/service/actors/resolveRelatedValue'
|
|
8
|
-
import { hydrateFromDb } from '@/ItemProperty/service/actors/hydrateFromDb'
|
|
9
|
-
import {
|
|
10
|
-
saveImageSrc,
|
|
11
|
-
saveItemStorage,
|
|
12
|
-
saveRelation,
|
|
13
|
-
} from '@/ItemProperty/service/actors/saveValueToDb'
|
|
14
|
-
import { analyzeInput } from '@/ItemProperty/service/actors/saveValueToDb/analyzeInput' // import { updateMachineContext } from '@/helpers'
|
|
15
|
-
// import { updateMachineContext } from '@/helpers'
|
|
16
|
-
|
|
17
|
-
export const propertyMachine = setup({
|
|
18
|
-
types: {
|
|
19
|
-
context: {} as PropertyMachineContext,
|
|
20
|
-
input: {} as PropertyMachineContext,
|
|
21
|
-
},
|
|
22
|
-
// actions: {
|
|
23
|
-
// updateContext: updateMachineContext,
|
|
24
|
-
// },
|
|
25
|
-
actors: {
|
|
26
|
-
waitForDb,
|
|
27
|
-
hydrateFromDb,
|
|
28
|
-
initialize,
|
|
29
|
-
resolveRelatedValue,
|
|
30
|
-
resolveRemoteStorage,
|
|
31
|
-
analyzeInput,
|
|
32
|
-
saveImageSrc,
|
|
33
|
-
saveRelation,
|
|
34
|
-
saveItemStorage,
|
|
35
|
-
},
|
|
36
|
-
}).createMachine({
|
|
37
|
-
id: 'itemProperty',
|
|
38
|
-
initial: 'waitingForDb',
|
|
39
|
-
context: ({ input }) => input as PropertyMachineContext,
|
|
40
|
-
on: {
|
|
41
|
-
// reload: '.hydratingFromDb',
|
|
42
|
-
save: {
|
|
43
|
-
actions: assign({
|
|
44
|
-
isSaving: true,
|
|
45
|
-
}),
|
|
46
|
-
target: '.saving',
|
|
47
|
-
},
|
|
48
|
-
updateContext: {
|
|
49
|
-
actions: assign(({ context, event }) => {
|
|
50
|
-
const newContext = Object.assign({}, context)
|
|
51
|
-
|
|
52
|
-
for (let i = 0; i < Object.keys(event).length; i++) {
|
|
53
|
-
const key = Object.keys(event)[i]
|
|
54
|
-
if (key === 'type') {
|
|
55
|
-
continue
|
|
56
|
-
}
|
|
57
|
-
newContext[key] = event[key]
|
|
58
|
-
}
|
|
59
|
-
return newContext
|
|
60
|
-
}),
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
states: {
|
|
64
|
-
idle: {},
|
|
65
|
-
waitingForDb: {
|
|
66
|
-
on: {
|
|
67
|
-
waitForDbSuccess: {
|
|
68
|
-
target: 'hydratingFromDb',
|
|
69
|
-
actions: assign({
|
|
70
|
-
isDbReady: true,
|
|
71
|
-
}),
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
invoke: {
|
|
75
|
-
src: 'waitForDb',
|
|
76
|
-
input: ({ context }) => ({ context }),
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
hydratingFromDb: {
|
|
80
|
-
on: {
|
|
81
|
-
hydrateFromDbSuccess: 'initializing',
|
|
82
|
-
},
|
|
83
|
-
invoke: {
|
|
84
|
-
src: 'hydrateFromDb',
|
|
85
|
-
input: ({ context }) => ({ context }),
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
initializing: {
|
|
89
|
-
on: {
|
|
90
|
-
initializeSuccess: 'idle',
|
|
91
|
-
isRelatedProperty: {
|
|
92
|
-
target: 'resolvingRelatedValue',
|
|
93
|
-
},
|
|
94
|
-
hasRemoteBackup: {
|
|
95
|
-
target: 'resolvingRemoteStorage',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
invoke: {
|
|
99
|
-
src: 'initialize',
|
|
100
|
-
input: ({ context, event }) => ({ context, event }),
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
resolvingRelatedValue: {
|
|
104
|
-
on: {
|
|
105
|
-
resolvingRelatedValueSuccess: {
|
|
106
|
-
target: 'idle',
|
|
107
|
-
actions: assign({
|
|
108
|
-
refResolvedDisplayValue: ({ event }) =>
|
|
109
|
-
event.refResolvedDisplayValue,
|
|
110
|
-
refResolvedValue: ({ event }) => event.refResolvedValue,
|
|
111
|
-
}),
|
|
112
|
-
},
|
|
113
|
-
resolvingRelatedValueDone: {
|
|
114
|
-
target: 'idle',
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
invoke: {
|
|
118
|
-
src: 'resolveRelatedValue',
|
|
119
|
-
input: ({ context }) => ({ context }),
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
resolvingRemoteStorage: {
|
|
123
|
-
on: {
|
|
124
|
-
resolveRemoteStorageSuccess: {
|
|
125
|
-
target: 'idle',
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
invoke: {
|
|
129
|
-
src: 'resolveRemoteStorage',
|
|
130
|
-
input: ({ context }) => ({ context }),
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
saving: {
|
|
134
|
-
initial: 'analyzingInput',
|
|
135
|
-
states: {
|
|
136
|
-
analyzingInput: {
|
|
137
|
-
on: {
|
|
138
|
-
saveValueToDbSuccess: {
|
|
139
|
-
target: 'doneSaving',
|
|
140
|
-
},
|
|
141
|
-
saveImageSrc: 'savingImageSrc',
|
|
142
|
-
saveRelation: 'savingRelation',
|
|
143
|
-
saveItemStorage: 'savingItemStorage',
|
|
144
|
-
},
|
|
145
|
-
invoke: {
|
|
146
|
-
src: 'analyzeInput',
|
|
147
|
-
input: ({ context, event }) => ({ context, event }),
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
savingImageSrc: {
|
|
151
|
-
on: {
|
|
152
|
-
saveImageSrcSuccess: 'doneSaving',
|
|
153
|
-
},
|
|
154
|
-
invoke: {
|
|
155
|
-
src: 'saveImageSrc',
|
|
156
|
-
input: ({ context, event }) => ({ context, event }),
|
|
157
|
-
},
|
|
158
|
-
},
|
|
159
|
-
savingRelation: {
|
|
160
|
-
on: {
|
|
161
|
-
saveRelationSuccess: 'doneSaving',
|
|
162
|
-
},
|
|
163
|
-
invoke: {
|
|
164
|
-
src: 'saveRelation',
|
|
165
|
-
input: ({ context, event }) => ({ context, event }),
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
savingItemStorage: {
|
|
169
|
-
on: {
|
|
170
|
-
saveItemStorageSuccess: 'doneSaving',
|
|
171
|
-
},
|
|
172
|
-
invoke: {
|
|
173
|
-
src: 'saveItemStorage',
|
|
174
|
-
input: ({ context, event }) => ({ context, event }),
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
doneSaving: {
|
|
178
|
-
type: 'final',
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
onDone: {
|
|
182
|
-
target: 'idle',
|
|
183
|
-
actions: assign(({ context }) => {
|
|
184
|
-
return {
|
|
185
|
-
isSaving: false,
|
|
186
|
-
}
|
|
187
|
-
}),
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
// conflict: {
|
|
193
|
-
// on: {
|
|
194
|
-
// resolveConflict: {
|
|
195
|
-
// target: 'saving',
|
|
196
|
-
// actions: assign({
|
|
197
|
-
// data: ({ context, event }) => event.output,
|
|
198
|
-
// }),
|
|
199
|
-
// },
|
|
200
|
-
// },
|
|
201
|
-
// },
|
|
202
|
-
})
|
package/dist/src/publish.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { getGlobalService } from '@/services/global'
|
|
2
|
-
|
|
3
|
-
type PublishItemRequestEvent = {
|
|
4
|
-
seedLocalId: string
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
type PublishItemRequestHandler = (
|
|
8
|
-
event: PublishItemRequestEvent,
|
|
9
|
-
) => Promise<void>
|
|
10
|
-
|
|
11
|
-
export const publishItemRequestHandler: PublishItemRequestHandler = async ({
|
|
12
|
-
seedLocalId,
|
|
13
|
-
}) => {
|
|
14
|
-
const globalService = getGlobalService()
|
|
15
|
-
globalService.subscribe((snapshot) => {
|
|
16
|
-
if (
|
|
17
|
-
!snapshot ||
|
|
18
|
-
!snapshot.context ||
|
|
19
|
-
!snapshot.context.publishItemService
|
|
20
|
-
) {
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
globalService.send({
|
|
25
|
-
type: 'publishItemRequest',
|
|
26
|
-
seedLocalId,
|
|
27
|
-
})
|
|
28
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { setup } from 'xstate'
|
|
2
|
-
import { validateItemData } from './actors/validateItemData'
|
|
3
|
-
import { PublishMachineStates } from '@/services/internal/constants'
|
|
4
|
-
import { PublishMachineContext } from '@/types'
|
|
5
|
-
import { createPublishAttempt } from './actors/createPublishAttempt'
|
|
6
|
-
import { updateMachineContext } from '@/helpers/updateMachineContext'
|
|
7
|
-
import { preparePublishRequestData } from '@/services/publish/actors/preparePublishRequestData'
|
|
8
|
-
import { upload } from '@/services/publish/actors/upload'
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
VALIDATING_ITEM_DATA,
|
|
12
|
-
CREATING_PUBLISH_ATTEMPT,
|
|
13
|
-
PREPARING_PUBLISH_REQUEST_DATA,
|
|
14
|
-
UPLOADING,
|
|
15
|
-
PUBLISHING,
|
|
16
|
-
IDLE,
|
|
17
|
-
} = PublishMachineStates
|
|
18
|
-
|
|
19
|
-
export const publishMachine = setup({
|
|
20
|
-
types: {
|
|
21
|
-
context: {} as PublishMachineContext,
|
|
22
|
-
input: {} as PublishMachineContext,
|
|
23
|
-
},
|
|
24
|
-
actors: {
|
|
25
|
-
validateItemData,
|
|
26
|
-
createPublishAttempt,
|
|
27
|
-
upload,
|
|
28
|
-
preparePublishRequestData,
|
|
29
|
-
},
|
|
30
|
-
}).createMachine({
|
|
31
|
-
id: 'publish',
|
|
32
|
-
initial: VALIDATING_ITEM_DATA,
|
|
33
|
-
context: ({ input }) => input,
|
|
34
|
-
on: {
|
|
35
|
-
updateContext: updateMachineContext,
|
|
36
|
-
},
|
|
37
|
-
states: {
|
|
38
|
-
[VALIDATING_ITEM_DATA]: {
|
|
39
|
-
on: {
|
|
40
|
-
validateItemDataSuccess: [CREATING_PUBLISH_ATTEMPT],
|
|
41
|
-
},
|
|
42
|
-
invoke: {
|
|
43
|
-
src: 'validateItemData',
|
|
44
|
-
input: ({ context }) => ({ context }),
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
[CREATING_PUBLISH_ATTEMPT]: {
|
|
48
|
-
on: {
|
|
49
|
-
createPublishAttemptSuccess: [UPLOADING],
|
|
50
|
-
},
|
|
51
|
-
invoke: {
|
|
52
|
-
src: 'createPublishAttempt',
|
|
53
|
-
input: ({ context }) => ({ context }),
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
[UPLOADING]: {
|
|
57
|
-
on: {
|
|
58
|
-
uploadingSuccess: [PREPARING_PUBLISH_REQUEST_DATA],
|
|
59
|
-
},
|
|
60
|
-
invoke: {
|
|
61
|
-
src: 'upload',
|
|
62
|
-
input: ({ context }) => ({ context }),
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
[PREPARING_PUBLISH_REQUEST_DATA]: {
|
|
66
|
-
on: {
|
|
67
|
-
preparePublishRequestDataSuccess: [UPLOADING],
|
|
68
|
-
},
|
|
69
|
-
invoke: {
|
|
70
|
-
src: 'preparePublishRequestData',
|
|
71
|
-
input: ({ context }) => ({ context }),
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
[PUBLISHING]: {},
|
|
75
|
-
[IDLE]: {},
|
|
76
|
-
},
|
|
77
|
-
})
|
package/dist/src/queries.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { graphql } from '@/graphql/gql'
|
|
2
|
-
|
|
3
|
-
export const GET_SCHEMA_UIDS_FOR_MODELS = graphql(/* GraphQL */ `
|
|
4
|
-
query GetSchemaUids($where: SchemaWhereInput!) {
|
|
5
|
-
schemaUids: schemata(where: $where) {
|
|
6
|
-
id
|
|
7
|
-
schema
|
|
8
|
-
schemaNames {
|
|
9
|
-
name
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
`)
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseDb } from '@/db/Db/BaseDb'
|
|
2
|
-
import { seeds } from '@/seedSchema'
|
|
3
|
-
import { eq, or } from 'drizzle-orm'
|
|
4
|
-
|
|
5
|
-
export const recoverDeletedItem = async ({ seedLocalId, seedUid }: { seedLocalId: string, seedUid: string }) => {
|
|
6
|
-
const appDb = BaseDb.getAppDb()
|
|
7
|
-
|
|
8
|
-
await appDb
|
|
9
|
-
.update(seeds)
|
|
10
|
-
.set({
|
|
11
|
-
_markedForDeletion: 0,
|
|
12
|
-
})
|
|
13
|
-
.where(or(eq(seeds.localId, seedLocalId), eq(seeds.uid, seedUid)))
|
|
14
|
-
}
|
package/dist/src/reload.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { EventObject, fromCallback } from 'xstate'
|
|
2
|
-
import { FromCallbackInput } from '@/types/machines'
|
|
3
|
-
import { ItemMachineContext } from '@/types/item'
|
|
4
|
-
|
|
5
|
-
export const reload = fromCallback<
|
|
6
|
-
EventObject,
|
|
7
|
-
FromCallbackInput<ItemMachineContext<any>>
|
|
8
|
-
>(({ sendBack, input: { context } }) => {
|
|
9
|
-
const { propertyInstances } = context
|
|
10
|
-
|
|
11
|
-
const _reload = async () => {
|
|
12
|
-
if (!propertyInstances) {
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
for (const propertyInstance of propertyInstances.values()) {
|
|
17
|
-
if (propertyInstance) {
|
|
18
|
-
const propertyRecordSchema = propertyInstance.propertyDef
|
|
19
|
-
if (
|
|
20
|
-
propertyRecordSchema &&
|
|
21
|
-
propertyRecordSchema.storageType &&
|
|
22
|
-
propertyRecordSchema.storageType === 'ItemStorage'
|
|
23
|
-
) {
|
|
24
|
-
propertyInstance.getService().send({ type: 'reload' })
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
_reload().then(() => {
|
|
31
|
-
sendBack({ type: 'reloadSuccess' })
|
|
32
|
-
})
|
|
33
|
-
})
|
package/dist/src/request.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { getItem } from '@/db/read/getItem'
|
|
2
|
-
import { eventEmitter } from '@/eventBus'
|
|
3
|
-
|
|
4
|
-
const activeItemRequests = new Set<string>()
|
|
5
|
-
|
|
6
|
-
const queue = new Map<string, Record<string, unknown>>()
|
|
7
|
-
|
|
8
|
-
export const itemRequestHandler = async (event) => {
|
|
9
|
-
const { seedLocalId, seedUid, modelName, eventId } = event
|
|
10
|
-
|
|
11
|
-
if (activeItemRequests.has(seedLocalId)) {
|
|
12
|
-
queue.set(seedLocalId, event)
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const item = await getItem({
|
|
17
|
-
modelName,
|
|
18
|
-
seedLocalId,
|
|
19
|
-
seedUid,
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
if (!item) {
|
|
23
|
-
console.warn(
|
|
24
|
-
`[item/events] [itemRequestHandler] no item for seedLocalId ${seedLocalId} or versionUid ${seedUid}`,
|
|
25
|
-
)
|
|
26
|
-
if (eventId) {
|
|
27
|
-
eventEmitter.emit(`item.${modelName}.${seedLocalId}.response`, {
|
|
28
|
-
item,
|
|
29
|
-
eventId,
|
|
30
|
-
})
|
|
31
|
-
}
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
eventEmitter.emit(`item.${modelName}.${seedLocalId}.response`, {
|
|
36
|
-
item,
|
|
37
|
-
eventId,
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
queue.delete(seedLocalId)
|
|
41
|
-
if (queue.size > 0 && queue.has(seedLocalId)) {
|
|
42
|
-
const nextEvent = queue.get(seedLocalId)
|
|
43
|
-
await itemRequestHandler(nextEvent)
|
|
44
|
-
}
|
|
45
|
-
}
|
package/dist/src/requestAll.ts
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { eventEmitter } from '@/eventBus'
|
|
2
|
-
import { getItemsData } from '@/db/read/getItems'
|
|
3
|
-
import debug from 'debug'
|
|
4
|
-
import { getModel } from '@/stores/modelClass'
|
|
5
|
-
import { BaseItem } from '@/Item/BaseItem'
|
|
6
|
-
|
|
7
|
-
const logger = debug('app:events:requestAll')
|
|
8
|
-
|
|
9
|
-
const cache = new Map<string, Map<string, BaseItem<any>>>()
|
|
10
|
-
|
|
11
|
-
let modelCount = 0
|
|
12
|
-
|
|
13
|
-
const handleRequestAll = async (event) => {
|
|
14
|
-
const { modelName, eventId } = event
|
|
15
|
-
|
|
16
|
-
let modelItemsCache
|
|
17
|
-
|
|
18
|
-
if (cache.has(modelName)) {
|
|
19
|
-
modelItemsCache = cache.get(modelName)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (modelItemsCache && modelName === 'Identity' && modelCount <= 1) {
|
|
23
|
-
// Send what we have while we update the cache
|
|
24
|
-
eventEmitter.emit(`item.${modelName}.requestAll.response`, {
|
|
25
|
-
items: Array.from(modelItemsCache.values()),
|
|
26
|
-
eventId,
|
|
27
|
-
})
|
|
28
|
-
modelCount++
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (!modelItemsCache) {
|
|
32
|
-
modelItemsCache = new Map()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const itemsData = await getItemsData({ modelName })
|
|
36
|
-
|
|
37
|
-
const cacheKeys = Array.from(modelItemsCache.keys())
|
|
38
|
-
|
|
39
|
-
const keysInDb = []
|
|
40
|
-
|
|
41
|
-
const returnItems = []
|
|
42
|
-
|
|
43
|
-
const ModelClass = getModel(modelName)
|
|
44
|
-
|
|
45
|
-
for (const itemData of itemsData) {
|
|
46
|
-
returnItems.push(
|
|
47
|
-
await BaseItem.create({
|
|
48
|
-
...itemData,
|
|
49
|
-
modelName,
|
|
50
|
-
}),
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (modelName === 'Identity' && modelCount <= 1) {
|
|
55
|
-
logger(
|
|
56
|
-
`[XXXXXX] [handleRequestAll] ${ModelClass?.originalConstructor.name}:`,
|
|
57
|
-
returnItems.length,
|
|
58
|
-
)
|
|
59
|
-
eventEmitter.emit(`item.${modelName}.requestAll.response`, {
|
|
60
|
-
items: returnItems,
|
|
61
|
-
eventId,
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
for (const returnItem of returnItems) {
|
|
66
|
-
const itemCacheKey = `${returnItem.seedLocalId}_${returnItem.seedUid || ''}`
|
|
67
|
-
keysInDb.push(itemCacheKey)
|
|
68
|
-
const existingCacheKey = cacheKeys.find((ck) => ck.includes(itemCacheKey))
|
|
69
|
-
|
|
70
|
-
if (!existingCacheKey) {
|
|
71
|
-
modelItemsCache.set(itemCacheKey, returnItem)
|
|
72
|
-
continue
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (existingCacheKey) {
|
|
76
|
-
const existingItem = modelItemsCache.get(existingCacheKey)
|
|
77
|
-
if (!existingItem) {
|
|
78
|
-
console.error(
|
|
79
|
-
'[events/requestAll] [getItemsDataFromDb] no existingItem for cache key',
|
|
80
|
-
existingCacheKey,
|
|
81
|
-
modelItemsCache,
|
|
82
|
-
)
|
|
83
|
-
continue
|
|
84
|
-
}
|
|
85
|
-
for (const [key, value] of Object.entries(returnItem)) {
|
|
86
|
-
if (key === 'seedLocalId' || key === 'seedUid') {
|
|
87
|
-
continue
|
|
88
|
-
}
|
|
89
|
-
existingItem[key] = value
|
|
90
|
-
}
|
|
91
|
-
modelItemsCache.set(existingCacheKey, existingItem)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Remove any stale items from the cache that were deleted from the DB
|
|
96
|
-
if (keysInDb.length !== cacheKeys.length) {
|
|
97
|
-
for (const cacheKey of cacheKeys) {
|
|
98
|
-
if (!keysInDb.includes(cacheKey)) {
|
|
99
|
-
modelItemsCache.delete(cacheKey)
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
cache.set(modelName, modelItemsCache)
|
|
105
|
-
|
|
106
|
-
if (modelName === 'Identity' && modelCount <= 1) {
|
|
107
|
-
logger(
|
|
108
|
-
`[XXXXXX] [getItemsDataFromDb] ${modelName} responding with`,
|
|
109
|
-
Array.from(modelItemsCache.values()),
|
|
110
|
-
)
|
|
111
|
-
eventEmitter.emit(`item.${modelName}.requestAll.response`, {
|
|
112
|
-
items: Array.from(modelItemsCache.values()),
|
|
113
|
-
eventId,
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export const itemRequestAllHandler = async (event) => {
|
|
119
|
-
logger('[events/requestAll] Request all items', event)
|
|
120
|
-
await handleRequestAll(event)
|
|
121
|
-
// eventQueue.push(event, (err) => {
|
|
122
|
-
// if (err) {
|
|
123
|
-
// console.error(err)
|
|
124
|
-
// }
|
|
125
|
-
// if (!err) {
|
|
126
|
-
// logger('[events/requestAll] Request all items done without error')
|
|
127
|
-
// }
|
|
128
|
-
// })
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// export const getItemCache = () => {
|
|
132
|
-
// return itemCache
|
|
133
|
-
// }
|
|
134
|
-
|
|
135
|
-
type CreateItemCacheKeyParams = {
|
|
136
|
-
seedLocalId?: string
|
|
137
|
-
seedUid?: string
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
type CreateItemCacheKey = (
|
|
141
|
-
itemData: CreateItemCacheKeyParams,
|
|
142
|
-
) => string | undefined
|
|
143
|
-
|
|
144
|
-
export const createItemCacheKey: CreateItemCacheKey = (itemData) => {
|
|
145
|
-
if (!itemData || (!itemData.seedLocalId && !itemData.seedUid)) {
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
return `${itemData.seedLocalId}_${itemData.seedUid || ''}`
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// export const updateItemCache = (itemCacheKey: string, item: Item<any>) => {
|
|
152
|
-
// itemCache.set(itemCacheKey, item)
|
|
153
|
-
// }
|
|
154
|
-
//
|
|
155
|
-
// export const deleteItemFromCache = (itemCacheKey: string) => {
|
|
156
|
-
// itemCache.delete(itemCacheKey)
|
|
157
|
-
// }
|