@seedprotocol/sdk 0.2.50 → 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-Dcqcpsq4.js → ArweaveClient-D5iJisYr.js} +2 -2
- package/dist/{ArweaveClient-Dcqcpsq4.js.map → ArweaveClient-D5iJisYr.js.map} +1 -1
- package/dist/{ArweaveClient-Dh7LRIqD.js → ArweaveClient-HEIIuOfB.js} +2 -2
- package/dist/{ArweaveClient-Dh7LRIqD.js.map → ArweaveClient-HEIIuOfB.js.map} +1 -1
- package/dist/{Db-jJH2s0gO.js → Db-D-BsZYlN.js} +3 -3
- package/dist/{Db-jJH2s0gO.js.map → Db-D-BsZYlN.js.map} +1 -1
- package/dist/{Db-BwkMqaQe.js → Db-Dpsbk_T7.js} +3 -3
- package/dist/{Db-BwkMqaQe.js.map → Db-Dpsbk_T7.js.map} +1 -1
- package/dist/{EasClient-A1xC7Gm-.js → EasClient-D3wKgt0o.js} +2 -2
- package/dist/{EasClient-m2mXad59.js.map → EasClient-D3wKgt0o.js.map} +1 -1
- package/dist/{EasClient-m2mXad59.js → EasClient-jqkT2ZBt.js} +2 -2
- package/dist/{EasClient-A1xC7Gm-.js.map → EasClient-jqkT2ZBt.js.map} +1 -1
- package/dist/{FileManager-Dv2zn1RW.js → FileManager-4mWYO3Mt.js} +3 -5
- package/dist/FileManager-4mWYO3Mt.js.map +1 -0
- package/dist/{Item-DI3FxVPV.js → Item-CqWdJsyg.js} +3 -3
- package/dist/{Item-DI3FxVPV.js.map → Item-CqWdJsyg.js.map} +1 -1
- package/dist/{ItemProperty-CxNUwVnR.js → ItemProperty-BpBW3IWx.js} +3 -3
- package/dist/{ItemProperty-CxNUwVnR.js.map → ItemProperty-BpBW3IWx.js.map} +1 -1
- package/dist/{QueryClient-C-hFMF2j.js → QueryClient-CBOP3OoU.js} +2 -2
- package/dist/{QueryClient-C-hFMF2j.js.map → QueryClient-CBOP3OoU.js.map} +1 -1
- package/dist/{QueryClient-C02sPZ-K.js → QueryClient-bKb3SB0W.js} +2 -2
- package/dist/{QueryClient-C02sPZ-K.js.map → QueryClient-bKb3SB0W.js.map} +1 -1
- package/dist/bin.js +5 -5
- package/dist/{constants-C03RQQht.js → constants-CIDbABDz.js} +5 -2
- package/dist/constants-CIDbABDz.js.map +1 -0
- package/dist/{index-CKrLHw3B.js → index-BRxO1tLl.js} +300 -149
- package/dist/index-BRxO1tLl.js.map +1 -0
- package/dist/{index-Dv8GeuSw.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-1s-iWHq_.js → seed.schema.config-CPRn6KVL.js} +3 -3
- package/dist/{seed.schema.config-1s-iWHq_.js.map → seed.schema.config-CPRn6KVL.js.map} +1 -1
- package/dist/types/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
- package/dist/types/src/browser/helpers/FileManager.d.ts +1 -0
- package/dist/types/src/browser/helpers/FileManager.d.ts.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/helpers/FileManager/BaseFileManager.d.ts +1 -0
- package/dist/types/src/helpers/FileManager/BaseFileManager.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-Dv2zn1RW.js.map +0 -1
- package/dist/constants-C03RQQht.js.map +0 -1
- package/dist/index-CKrLHw3B.js.map +0 -1
- package/dist/index-Dv8GeuSw.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 -52
- 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 -155
- 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
|
@@ -2,7 +2,7 @@ import { immerable, produce, enableMapSet } from 'immer';
|
|
|
2
2
|
import 'reflect-metadata';
|
|
3
3
|
import { Type } from '@sinclair/typebox';
|
|
4
4
|
import { fromCallback, setup, assign, waitFor, createActor, raise } from 'xstate';
|
|
5
|
-
import {
|
|
5
|
+
import { c as BaseQueryClient, a as BaseEasClient, G as GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY, f as GLOBAL_INITIALIZING_SEND_CONFIG, g as GLOBAL_INITIALIZING_CREATE_ALL_ITEMS_SERVICES, h as GLOBAL_ADDING_MODELS_TO_DB_SUCCESS, D as DB_CHECK_STATUS_UPDATE_PATHS, i as DB_CHECK_STATUS_EXISTS, d as BROWSER_FS_TOP_DIR, j as DB_CREATING_SUCCESS, k as DB_VALIDATING_SUCCESS, l as DB_VALIDATING_WAIT, b as BaseFileManager, m as DB_MIGRATING_SUCCESS, n as DB_WAITING_FOR_FILES_RECEIVED, M as MachineIds, o as DB_MIGRATING_WAIT, p as DbState, I as INTERNAL_VALIDATING_INPUT_SUCCESS, q as ARWEAVE_HOST, B as BaseArweaveClient, r as INTERNAL_CONFIGURING_FS_SUCCESS, s as INTERNAL_SAVING_CONFIG_SUCCESS, t as INTERNAL_LOADING_APP_DB_SUCCESS, u as DB_ON_SNAPSHOT, v as DB_NAME_APP, w as InternalState, P as PublishMachineStates, x as GlobalState, y as INTERNAL_DATA_TYPES, z as ImageSize, C as internalPropertyNames, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, F as defaultAttestationData } from './constants-CIDbABDz.js';
|
|
6
6
|
import debug from 'debug';
|
|
7
7
|
import pluralize from 'pluralize';
|
|
8
8
|
import { sqliteTable, text, int, unique } from 'drizzle-orm/sqlite-core';
|
|
@@ -259,7 +259,7 @@ const getExistingItem = async ({ seedLocalId, seedUid, }) => {
|
|
|
259
259
|
return matchingRow;
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
-
const initialize$
|
|
262
|
+
const initialize$4 = fromCallback(({ sendBack, input: { context } }) => {
|
|
263
263
|
const { seedLocalId, seedUid, ModelClass } = context;
|
|
264
264
|
if (!ModelClass) {
|
|
265
265
|
throw new Error('ModelClass is required');
|
|
@@ -294,7 +294,7 @@ const initialize$3 = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
294
294
|
|
|
295
295
|
const eventEmitter = new EventEmitter();
|
|
296
296
|
|
|
297
|
-
const logger$
|
|
297
|
+
const logger$s = debug('app:shared:helpers');
|
|
298
298
|
const { alphanumeric } = nanoIdDictionary;
|
|
299
299
|
const generateId = () => {
|
|
300
300
|
return customAlphabet(alphanumeric, 10)();
|
|
@@ -351,7 +351,7 @@ const convertTxIdToImageSrc = async (txId) => {
|
|
|
351
351
|
const imageFilePath = `/files/images/${txId}`;
|
|
352
352
|
const fileExists = await fs.promises.exists(imageFilePath);
|
|
353
353
|
if (!fileExists) {
|
|
354
|
-
logger$
|
|
354
|
+
logger$s(`[ItemView] [updateImageSrc] ${imageFilePath} does not exist`);
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
357
|
const uint = await fs.promises.readFile(imageFilePath);
|
|
@@ -1233,8 +1233,8 @@ const getEnvironment = () => {
|
|
|
1233
1233
|
return 'node';
|
|
1234
1234
|
};
|
|
1235
1235
|
|
|
1236
|
-
const logger$
|
|
1237
|
-
const initialize$
|
|
1236
|
+
const logger$r = debug('app:services:global:actors:initialize');
|
|
1237
|
+
const initialize$3 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
1238
1238
|
const { internalService, models, endpoints, arweaveDomain, addresses, } = context;
|
|
1239
1239
|
if (!internalService) {
|
|
1240
1240
|
throw new Error('internalService is required');
|
|
@@ -1252,7 +1252,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
1252
1252
|
const _initInternal = async () => {
|
|
1253
1253
|
return new Promise((resolve) => {
|
|
1254
1254
|
internalSubscription = internalService.subscribe((snapshot) => {
|
|
1255
|
-
logger$
|
|
1255
|
+
logger$r('[sdk] [internal] snapshot', snapshot);
|
|
1256
1256
|
if (snapshot.value === 'ready') {
|
|
1257
1257
|
resolve();
|
|
1258
1258
|
}
|
|
@@ -1297,7 +1297,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
1297
1297
|
await fetchSchemaUids();
|
|
1298
1298
|
};
|
|
1299
1299
|
_initFileSystem().then(() => {
|
|
1300
|
-
logger$
|
|
1300
|
+
logger$r('[global/actors] File system initialized');
|
|
1301
1301
|
});
|
|
1302
1302
|
_initInternal()
|
|
1303
1303
|
.then(() => {
|
|
@@ -1307,7 +1307,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
1307
1307
|
return _initEas();
|
|
1308
1308
|
})
|
|
1309
1309
|
.then(() => {
|
|
1310
|
-
logger$
|
|
1310
|
+
logger$r('[global/actors] Internal initialized');
|
|
1311
1311
|
sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY });
|
|
1312
1312
|
internalSubscription?.unsubscribe();
|
|
1313
1313
|
});
|
|
@@ -1320,7 +1320,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
1320
1320
|
};
|
|
1321
1321
|
});
|
|
1322
1322
|
|
|
1323
|
-
const logger$
|
|
1323
|
+
const logger$q = debug('app:services:global:actors:getSchemaForModel');
|
|
1324
1324
|
const getSchemaForModel = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
1325
1325
|
const { modelName } = event;
|
|
1326
1326
|
if (!modelName) {
|
|
@@ -1336,12 +1336,12 @@ const getSchemaForModel = fromCallback(({ sendBack, input: { context, event } })
|
|
|
1336
1336
|
if (!model) {
|
|
1337
1337
|
throw new Error(`Model ${modelName} not found`);
|
|
1338
1338
|
}
|
|
1339
|
-
logger$
|
|
1339
|
+
logger$q('[service/actor] [getSchemaForModel] model:', model);
|
|
1340
1340
|
sendBack({ type: 'schemaForModel', schema: model.schema });
|
|
1341
1341
|
return () => { };
|
|
1342
1342
|
});
|
|
1343
1343
|
|
|
1344
|
-
const logger$
|
|
1344
|
+
const logger$p = debug('app:services:global:actors:addModelsToDb');
|
|
1345
1345
|
const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
1346
1346
|
const { models: models$1 } = context;
|
|
1347
1347
|
const _addModelsToDb = async () => {
|
|
@@ -1349,7 +1349,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1349
1349
|
if (!models$1) {
|
|
1350
1350
|
return;
|
|
1351
1351
|
}
|
|
1352
|
-
const { models: SeedModels } = await import('./seed.schema.config-
|
|
1352
|
+
const { models: SeedModels } = await import('./seed.schema.config-CPRn6KVL.js');
|
|
1353
1353
|
const allModels = {
|
|
1354
1354
|
...SeedModels,
|
|
1355
1355
|
...models$1,
|
|
@@ -1357,7 +1357,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1357
1357
|
let hasModelsInDb = false;
|
|
1358
1358
|
const schemaDefsByModelName = new Map();
|
|
1359
1359
|
for (const [modelName, _] of Object.entries(allModels)) {
|
|
1360
|
-
logger$
|
|
1360
|
+
logger$p('[helpers/db] [addModelsToInternalDb] starting modelName:', modelName);
|
|
1361
1361
|
let foundModel;
|
|
1362
1362
|
const foundModelsQuery = await appDb
|
|
1363
1363
|
.select()
|
|
@@ -1367,7 +1367,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1367
1367
|
await appDb.insert(models).values({
|
|
1368
1368
|
name: modelName,
|
|
1369
1369
|
});
|
|
1370
|
-
logger$
|
|
1370
|
+
logger$p('[global/actors] [addModelsToDb] inserted model:', modelName);
|
|
1371
1371
|
const foundModels = await appDb
|
|
1372
1372
|
.select({
|
|
1373
1373
|
id: models.id,
|
|
@@ -1437,10 +1437,10 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1437
1437
|
return () => { };
|
|
1438
1438
|
});
|
|
1439
1439
|
|
|
1440
|
-
const logger$
|
|
1440
|
+
const logger$o = debug('app:services:db:actors:checkStatus');
|
|
1441
1441
|
const checkStatus = fromCallback(({ sendBack, input: { context } }) => {
|
|
1442
1442
|
const { dbName } = context;
|
|
1443
|
-
logger$
|
|
1443
|
+
logger$o('[db/actors] checkStatus context', context);
|
|
1444
1444
|
const pathToDir = `${BROWSER_FS_TOP_DIR}`;
|
|
1445
1445
|
const pathToDbDir = `${pathToDir}/db`;
|
|
1446
1446
|
const pathToDb = `${pathToDbDir}/${dbName}.sqlite3`;
|
|
@@ -1471,9 +1471,9 @@ const checkStatus = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1471
1471
|
});
|
|
1472
1472
|
});
|
|
1473
1473
|
|
|
1474
|
-
const logger$
|
|
1474
|
+
const logger$n = debug('app:services:db:actors:connectToDb');
|
|
1475
1475
|
const connectToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
1476
|
-
logger$
|
|
1476
|
+
logger$n('[db/actors] connectToDb context', context);
|
|
1477
1477
|
const { dbName, pathToDir } = context;
|
|
1478
1478
|
if (!pathToDir || !dbName) {
|
|
1479
1479
|
throw new Error('pathToDir and dbName are required');
|
|
@@ -1526,7 +1526,7 @@ const validate = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1526
1526
|
});
|
|
1527
1527
|
});
|
|
1528
1528
|
|
|
1529
|
-
const saveAppState = async (key, value) => {
|
|
1529
|
+
const saveAppState$1 = async (key, value) => {
|
|
1530
1530
|
const appDb = BaseDb.getAppDb();
|
|
1531
1531
|
await appDb
|
|
1532
1532
|
.insert(appState)
|
|
@@ -1802,7 +1802,7 @@ class FileDownloader {
|
|
|
1802
1802
|
localExcludedTransactions.add(e.data.transactionId);
|
|
1803
1803
|
}
|
|
1804
1804
|
if (e.data.done) {
|
|
1805
|
-
saveAppState('excludedTransactions', JSON.stringify(Array.from(localExcludedTransactions)))
|
|
1805
|
+
saveAppState$1('excludedTransactions', JSON.stringify(Array.from(localExcludedTransactions)))
|
|
1806
1806
|
.then(() => {
|
|
1807
1807
|
resolve(e.data);
|
|
1808
1808
|
})
|
|
@@ -2256,7 +2256,7 @@ class ImageResizer {
|
|
|
2256
2256
|
}
|
|
2257
2257
|
}
|
|
2258
2258
|
|
|
2259
|
-
const logger$
|
|
2259
|
+
const logger$m = debug('app:browser:helpers:FileManager');
|
|
2260
2260
|
class FileManager extends BaseFileManager {
|
|
2261
2261
|
static async readFileAsBuffer(filePath) {
|
|
2262
2262
|
return new Promise((resolve, reject) => {
|
|
@@ -2362,7 +2362,7 @@ class FileManager extends BaseFileManager {
|
|
|
2362
2362
|
const startTime = Date.now();
|
|
2363
2363
|
let isBusy = false;
|
|
2364
2364
|
const cancelableInterval = new CancelableInterval(async (stop) => {
|
|
2365
|
-
logger$
|
|
2365
|
+
logger$m('waitForFile', filePath);
|
|
2366
2366
|
if (isBusy) {
|
|
2367
2367
|
return;
|
|
2368
2368
|
}
|
|
@@ -2429,6 +2429,45 @@ class FileManager extends BaseFileManager {
|
|
|
2429
2429
|
// )
|
|
2430
2430
|
});
|
|
2431
2431
|
}
|
|
2432
|
+
static async saveFile(filePath, content) {
|
|
2433
|
+
try {
|
|
2434
|
+
// Get a handle to the OPFS root directory
|
|
2435
|
+
const root = await navigator.storage.getDirectory();
|
|
2436
|
+
// Split the file path into directory and file name
|
|
2437
|
+
const pathParts = filePath.split('/');
|
|
2438
|
+
const fileName = pathParts.pop();
|
|
2439
|
+
if (!fileName)
|
|
2440
|
+
throw new Error('Invalid file path');
|
|
2441
|
+
// Traverse directories and create them if they don't exist
|
|
2442
|
+
let currentDir = root;
|
|
2443
|
+
for (const part of pathParts) {
|
|
2444
|
+
if (part !== '') {
|
|
2445
|
+
currentDir = await currentDir.getDirectoryHandle(part, { create: true });
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
// Get the file handle and create the file if it doesn't exist
|
|
2449
|
+
const fileHandle = await currentDir.getFileHandle(fileName, { create: true });
|
|
2450
|
+
// Create a writable stream and write the content
|
|
2451
|
+
const writable = await fileHandle.createWritable();
|
|
2452
|
+
if (typeof content === 'string') {
|
|
2453
|
+
await writable.write(content);
|
|
2454
|
+
}
|
|
2455
|
+
else if (content instanceof Blob) {
|
|
2456
|
+
await writable.write(content);
|
|
2457
|
+
}
|
|
2458
|
+
else if (content instanceof ArrayBuffer) {
|
|
2459
|
+
await writable.write(new Blob([content]));
|
|
2460
|
+
}
|
|
2461
|
+
else {
|
|
2462
|
+
throw new Error('Unsupported content type');
|
|
2463
|
+
}
|
|
2464
|
+
await writable.close();
|
|
2465
|
+
console.log(`File written successfully: ${filePath}`);
|
|
2466
|
+
}
|
|
2467
|
+
catch (error) {
|
|
2468
|
+
console.error(`Error writing to OPFS: ${error.message}`);
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2432
2471
|
}
|
|
2433
2472
|
BaseFileManager.setPlatformClass(FileManager);
|
|
2434
2473
|
class CancelableInterval {
|
|
@@ -2483,10 +2522,10 @@ var FileManager$1 = /*#__PURE__*/Object.freeze({
|
|
|
2483
2522
|
FileManager: FileManager
|
|
2484
2523
|
});
|
|
2485
2524
|
|
|
2486
|
-
const logger$
|
|
2525
|
+
const logger$l = debug('app:services:db:actors:migrate');
|
|
2487
2526
|
const migrate = fromCallback(({ sendBack, input: { context } }) => {
|
|
2488
2527
|
const { pathToDbDir, dbId, dbName } = context;
|
|
2489
|
-
logger$
|
|
2528
|
+
logger$l('[db/actors] migrate context', context);
|
|
2490
2529
|
let journalExists = false;
|
|
2491
2530
|
const _checkForFiles = async () => {
|
|
2492
2531
|
const journalPath = `/${pathToDbDir}/meta/_journal.json`;
|
|
@@ -2530,7 +2569,7 @@ const waitForFiles$1 = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2530
2569
|
});
|
|
2531
2570
|
});
|
|
2532
2571
|
|
|
2533
|
-
const logger$
|
|
2572
|
+
const logger$k = debug('app:services:db:machine');
|
|
2534
2573
|
const { CHECKING_STATUS, VALIDATING, WAITING_FOR_FILES, CONNECTING_TO_DB, MIGRATING, } = DbState;
|
|
2535
2574
|
const dbMachine = setup({
|
|
2536
2575
|
types: {
|
|
@@ -2552,7 +2591,7 @@ const dbMachine = setup({
|
|
|
2552
2591
|
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
2553
2592
|
actions: assign({
|
|
2554
2593
|
hasFiles: ({ event }) => {
|
|
2555
|
-
logger$
|
|
2594
|
+
logger$k('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event);
|
|
2556
2595
|
return true;
|
|
2557
2596
|
},
|
|
2558
2597
|
}),
|
|
@@ -2561,8 +2600,8 @@ const dbMachine = setup({
|
|
|
2561
2600
|
target: `.${CHECKING_STATUS}`,
|
|
2562
2601
|
actions: assign({
|
|
2563
2602
|
hasFiles: ({ context, event }) => {
|
|
2564
|
-
logger$
|
|
2565
|
-
logger$
|
|
2603
|
+
logger$k('[db/machine] updateHasFiles event:', event);
|
|
2604
|
+
logger$k('[db/machine] updateHasFiles context:', context);
|
|
2566
2605
|
return event.hasFiles;
|
|
2567
2606
|
},
|
|
2568
2607
|
}),
|
|
@@ -2688,9 +2727,6 @@ const validateInput = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2688
2727
|
if (!endpoints || !endpoints.filePaths || !endpoints.files) {
|
|
2689
2728
|
throw new Error('validateInput called with invalid endpoints');
|
|
2690
2729
|
}
|
|
2691
|
-
if (!addresses || !addresses.length) {
|
|
2692
|
-
throw new Error('validateInput called with invalid addresses');
|
|
2693
|
-
}
|
|
2694
2730
|
if (!filesDir) {
|
|
2695
2731
|
if (isBrowser()) {
|
|
2696
2732
|
filesDir = '/';
|
|
@@ -2729,13 +2765,13 @@ const prepareDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2729
2765
|
});
|
|
2730
2766
|
});
|
|
2731
2767
|
|
|
2732
|
-
const logger$
|
|
2768
|
+
const logger$j = debug('app:services:internal:helpers');
|
|
2733
2769
|
/**
|
|
2734
2770
|
* Recursively create directories if they don't exist.
|
|
2735
2771
|
* @param {string} dirPath - The directory path to create.
|
|
2736
2772
|
*/
|
|
2737
2773
|
const createDirectories = async (dirPath) => {
|
|
2738
|
-
const dirPathExists = await
|
|
2774
|
+
const dirPathExists = await BaseFileManager.pathExists(dirPath);
|
|
2739
2775
|
if (dirPathExists) {
|
|
2740
2776
|
return;
|
|
2741
2777
|
}
|
|
@@ -2793,11 +2829,11 @@ class FileDownloadManager {
|
|
|
2793
2829
|
}
|
|
2794
2830
|
try {
|
|
2795
2831
|
await fs.promises.writeFile(localFilePath, fileData);
|
|
2796
|
-
logger$
|
|
2832
|
+
logger$j(`[downloadFile] Wrote file async to ${localFilePath}`);
|
|
2797
2833
|
}
|
|
2798
2834
|
catch (error) {
|
|
2799
2835
|
fs.writeFileSync(localFilePath, fileData);
|
|
2800
|
-
logger$
|
|
2836
|
+
logger$j(`[downloadFile] Wrote file sync to ${localFilePath}`);
|
|
2801
2837
|
}
|
|
2802
2838
|
}
|
|
2803
2839
|
async start() {
|
|
@@ -2887,7 +2923,7 @@ const syncDbFiles = async ({ filePaths, files }) => {
|
|
|
2887
2923
|
await downloadManager.start();
|
|
2888
2924
|
// await fetchFilesRecursively(files, BROWSER_FS_TOP_DIR, fileList)
|
|
2889
2925
|
await confirmFilesExist(fileList);
|
|
2890
|
-
logger$
|
|
2926
|
+
logger$j('[syncDbFiles] Files synced!');
|
|
2891
2927
|
};
|
|
2892
2928
|
|
|
2893
2929
|
const GET_FILES_METADATA = graphql(/* GraphQL */ `
|
|
@@ -2980,10 +3016,10 @@ const GET_TRANSACTION_TAGS = graphql(/* GraphQL */ `
|
|
|
2980
3016
|
|
|
2981
3017
|
const initArweaveClient = async () => {
|
|
2982
3018
|
if (isBrowser()) {
|
|
2983
|
-
(await import('./ArweaveClient-
|
|
3019
|
+
(await import('./ArweaveClient-D5iJisYr.js')).ArweaveClient;
|
|
2984
3020
|
}
|
|
2985
3021
|
if (!isBrowser()) {
|
|
2986
|
-
(await import('./ArweaveClient-
|
|
3022
|
+
(await import('./ArweaveClient-HEIIuOfB.js')).ArweaveClient;
|
|
2987
3023
|
}
|
|
2988
3024
|
};
|
|
2989
3025
|
let domain = 'arweave.net';
|
|
@@ -3026,7 +3062,7 @@ const setArweaveDomain = (newDomain) => {
|
|
|
3026
3062
|
domain = newDomain;
|
|
3027
3063
|
};
|
|
3028
3064
|
|
|
3029
|
-
const logger$
|
|
3065
|
+
const logger$i = debug('app:files:download');
|
|
3030
3066
|
const downloadAllFilesRequestHandler = async ({ endpoints, eventId, }) => {
|
|
3031
3067
|
await syncDbFiles(endpoints);
|
|
3032
3068
|
eventEmitter.emit('fs.downloadAll.success', { eventId });
|
|
@@ -3110,9 +3146,9 @@ const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
3110
3146
|
try {
|
|
3111
3147
|
const res = await fetch(`https://${ARWEAVE_HOST}/tx/${transactionId}/status`);
|
|
3112
3148
|
if (res.status !== 200) {
|
|
3113
|
-
logger$
|
|
3149
|
+
logger$i(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`);
|
|
3114
3150
|
excludedTransactions.add(transactionId);
|
|
3115
|
-
await saveAppState('excludedTransactions', JSON.stringify(Array.from(excludedTransactions)));
|
|
3151
|
+
await saveAppState$1('excludedTransactions', JSON.stringify(Array.from(excludedTransactions)));
|
|
3116
3152
|
continue;
|
|
3117
3153
|
}
|
|
3118
3154
|
const { tags: tagsResult } = await queryClient.fetchQuery({
|
|
@@ -3139,7 +3175,7 @@ const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
3139
3175
|
transactionIdsToDownload.push(transactionId);
|
|
3140
3176
|
}
|
|
3141
3177
|
catch (error) {
|
|
3142
|
-
logger$
|
|
3178
|
+
logger$i(error);
|
|
3143
3179
|
}
|
|
3144
3180
|
}
|
|
3145
3181
|
console.log('[download] Calling downloadAllFiles with transactionIdsToDownload', transactionIdsToDownload);
|
|
@@ -3190,14 +3226,14 @@ const isFsInitialized = () => {
|
|
|
3190
3226
|
return isInitialized;
|
|
3191
3227
|
};
|
|
3192
3228
|
|
|
3193
|
-
const logger$
|
|
3229
|
+
const logger$h = debug('app:internal:actors:configureFs');
|
|
3194
3230
|
const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
3195
3231
|
const { endpoints, appDbService, filesDir, } = context;
|
|
3196
|
-
logger$
|
|
3232
|
+
logger$h('[internal/actors] [configureFs] Configuring FS');
|
|
3197
3233
|
const _configureFs = async () => {
|
|
3198
|
-
logger$
|
|
3199
|
-
logger$
|
|
3200
|
-
logger$
|
|
3234
|
+
logger$h('[internal/actors] [configureFs] calling _configureFs');
|
|
3235
|
+
logger$h('[internal/actors] [configureFs] areFsListenersReady:', areFsListenersReady());
|
|
3236
|
+
logger$h('[internal/actors] [configureFs] isFsInitialized:', isFsInitialized());
|
|
3201
3237
|
await waitForEvent({
|
|
3202
3238
|
req: {
|
|
3203
3239
|
eventLabel: 'fs.downloadAll.request',
|
|
@@ -3214,7 +3250,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3214
3250
|
}
|
|
3215
3251
|
if (journalExists) {
|
|
3216
3252
|
appDbService.send({ type: DB_WAITING_FOR_FILES_RECEIVED });
|
|
3217
|
-
logger$
|
|
3253
|
+
logger$h('[internal/actors] [configureFs] fs configured!');
|
|
3218
3254
|
return true;
|
|
3219
3255
|
}
|
|
3220
3256
|
sendBack({ type: 'shouldWaitForFiles' });
|
|
@@ -3247,7 +3283,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3247
3283
|
return () => { };
|
|
3248
3284
|
});
|
|
3249
3285
|
|
|
3250
|
-
const logger$
|
|
3286
|
+
const logger$g = debug('app:services:internal:actors:saveConfig');
|
|
3251
3287
|
const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
3252
3288
|
if (typeof window === 'undefined') {
|
|
3253
3289
|
console.error('seedInitBrowser called from non-browser context');
|
|
@@ -3308,20 +3344,20 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3308
3344
|
value: arweaveDomain || 'arweave.net',
|
|
3309
3345
|
},
|
|
3310
3346
|
});
|
|
3311
|
-
logger$
|
|
3347
|
+
logger$g('[sdk] [internal/actors] Should be done saving');
|
|
3312
3348
|
}
|
|
3313
3349
|
catch (error) {
|
|
3314
3350
|
console.error('Error saving config:', error);
|
|
3315
3351
|
}
|
|
3316
3352
|
};
|
|
3317
3353
|
_saveConfig().then(() => {
|
|
3318
|
-
logger$
|
|
3354
|
+
logger$g('[sdk] [internal/actors] Successfully saved config');
|
|
3319
3355
|
return sendBack({ type: INTERNAL_SAVING_CONFIG_SUCCESS });
|
|
3320
3356
|
});
|
|
3321
3357
|
return () => { };
|
|
3322
3358
|
});
|
|
3323
3359
|
|
|
3324
|
-
const logger$
|
|
3360
|
+
const logger$f = debug('app:services:internal:actors:loadAppDb');
|
|
3325
3361
|
const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
3326
3362
|
const { appDbService } = context;
|
|
3327
3363
|
let subscription;
|
|
@@ -3342,7 +3378,7 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3342
3378
|
};
|
|
3343
3379
|
_loadAppDb().then(() => {
|
|
3344
3380
|
sendBack({ type: INTERNAL_LOADING_APP_DB_SUCCESS });
|
|
3345
|
-
logger$
|
|
3381
|
+
logger$f('[sdk] [internal/actors] Successfully loaded app DB');
|
|
3346
3382
|
});
|
|
3347
3383
|
return () => {
|
|
3348
3384
|
if (subscription) {
|
|
@@ -3372,7 +3408,7 @@ const waitForFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3372
3408
|
});
|
|
3373
3409
|
});
|
|
3374
3410
|
|
|
3375
|
-
const logger$
|
|
3411
|
+
const logger$e = debug('app:services:internal:machine');
|
|
3376
3412
|
createBrowserInspector({
|
|
3377
3413
|
autoStart: false,
|
|
3378
3414
|
});
|
|
@@ -3492,7 +3528,7 @@ const internalMachine = setup({
|
|
|
3492
3528
|
[INTERNAL_LOADING_APP_DB_SUCCESS]: {
|
|
3493
3529
|
target: SAVING_CONFIG,
|
|
3494
3530
|
actions: () => {
|
|
3495
|
-
logger$
|
|
3531
|
+
logger$e('[sdk] [internal/index] App DB loaded!');
|
|
3496
3532
|
},
|
|
3497
3533
|
},
|
|
3498
3534
|
},
|
|
@@ -3518,7 +3554,7 @@ const internalMachine = setup({
|
|
|
3518
3554
|
},
|
|
3519
3555
|
ready: {
|
|
3520
3556
|
entry: () => {
|
|
3521
|
-
logger$
|
|
3557
|
+
logger$e('[sdk] [internal/index] Ready!');
|
|
3522
3558
|
},
|
|
3523
3559
|
meta: {
|
|
3524
3560
|
displayText: "Crossing the t's ...",
|
|
@@ -3533,7 +3569,7 @@ const internalMachine = setup({
|
|
|
3533
3569
|
},
|
|
3534
3570
|
},
|
|
3535
3571
|
entry: () => {
|
|
3536
|
-
logger$
|
|
3572
|
+
logger$e('[sdk] [internal/index] Error!');
|
|
3537
3573
|
},
|
|
3538
3574
|
meta: {
|
|
3539
3575
|
displayText: 'Whoops! Something went wrong.',
|
|
@@ -3577,7 +3613,7 @@ const internalMachine = setup({
|
|
|
3577
3613
|
// })
|
|
3578
3614
|
// internalService.start()
|
|
3579
3615
|
|
|
3580
|
-
const initialize$
|
|
3616
|
+
const initialize$2 = fromCallback(({ sendBack, input: { context } }) => {
|
|
3581
3617
|
const { modelName, modelAddedToDb, ModelClass, times } = context;
|
|
3582
3618
|
const newTimes = {
|
|
3583
3619
|
initialize: {
|
|
@@ -3710,7 +3746,7 @@ const fetchDbData = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3710
3746
|
return () => { };
|
|
3711
3747
|
});
|
|
3712
3748
|
|
|
3713
|
-
const logger$
|
|
3749
|
+
const logger$d = debug('app:allItemsActors:fetchSeeds');
|
|
3714
3750
|
const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
|
|
3715
3751
|
const { queryVariables, modelName } = context;
|
|
3716
3752
|
if (!queryVariables) {
|
|
@@ -3722,7 +3758,7 @@ const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
3722
3758
|
const queryClient = BaseQueryClient.getQueryClient();
|
|
3723
3759
|
const easClient = BaseEasClient.getEasClient();
|
|
3724
3760
|
const cachedResults = queryClient.getQueryData(queryKey);
|
|
3725
|
-
logger$
|
|
3761
|
+
logger$d(`[allItemsActors] [fetchSeeds] cachedResults ${Date.now()}`, cachedResults);
|
|
3726
3762
|
const results = await queryClient.fetchQuery({
|
|
3727
3763
|
queryKey,
|
|
3728
3764
|
queryFn: async () => easClient.request(GET_SEEDS, queryVariables),
|
|
@@ -3940,7 +3976,7 @@ const itemMachineAll = setup({
|
|
|
3940
3976
|
input: {},
|
|
3941
3977
|
},
|
|
3942
3978
|
actors: {
|
|
3943
|
-
initialize: initialize$
|
|
3979
|
+
initialize: initialize$2,
|
|
3944
3980
|
fetchDbData,
|
|
3945
3981
|
fetchSeeds,
|
|
3946
3982
|
fetchVersions,
|
|
@@ -4171,13 +4207,13 @@ const preparePublishRequestData = fromCallback(({ sendBack, input: { context } }
|
|
|
4171
4207
|
});
|
|
4172
4208
|
});
|
|
4173
4209
|
|
|
4174
|
-
const logger$
|
|
4210
|
+
const logger$c = debug('app:services:publish:actors:upload');
|
|
4175
4211
|
const upload = fromCallback(({ sendBack, input: { context } }) => {
|
|
4176
4212
|
const { localId } = context;
|
|
4177
4213
|
const _upload = async () => {
|
|
4178
4214
|
const item = await BaseItem.find({ seedLocalId: localId });
|
|
4179
4215
|
if (!item) {
|
|
4180
|
-
logger$
|
|
4216
|
+
logger$c('no item with localId', localId);
|
|
4181
4217
|
return false;
|
|
4182
4218
|
}
|
|
4183
4219
|
const editedProperties = await item.getEditedProperties();
|
|
@@ -4287,7 +4323,7 @@ const savePublishService = fromCallback(({ sendBack, input: { event, context } }
|
|
|
4287
4323
|
return;
|
|
4288
4324
|
}
|
|
4289
4325
|
const _savePublishService = async () => {
|
|
4290
|
-
await saveAppState(`snapshot__publishItemService`, JSON.stringify(publishItemService.getPersistedSnapshot()));
|
|
4326
|
+
await saveAppState$1(`snapshot__publishItemService`, JSON.stringify(publishItemService.getPersistedSnapshot()));
|
|
4291
4327
|
return true;
|
|
4292
4328
|
};
|
|
4293
4329
|
_savePublishService().then((success) => {
|
|
@@ -4307,7 +4343,7 @@ const globalMachine = setup({
|
|
|
4307
4343
|
input: {},
|
|
4308
4344
|
},
|
|
4309
4345
|
actors: {
|
|
4310
|
-
initialize: initialize$
|
|
4346
|
+
initialize: initialize$3,
|
|
4311
4347
|
addModelsToDb,
|
|
4312
4348
|
getSchemaForModel,
|
|
4313
4349
|
savePublishService,
|
|
@@ -4878,7 +4914,7 @@ const itemMachineSingle = setup({
|
|
|
4878
4914
|
},
|
|
4879
4915
|
actors: {
|
|
4880
4916
|
waitForDb: waitForDb$1,
|
|
4881
|
-
initialize: initialize$
|
|
4917
|
+
initialize: initialize$4,
|
|
4882
4918
|
hydrateExistingItem,
|
|
4883
4919
|
hydrateNewItem,
|
|
4884
4920
|
fetchDataFromEas,
|
|
@@ -5108,7 +5144,7 @@ const getSeedData = async ({ seedLocalId, seedUid }) => {
|
|
|
5108
5144
|
return rows[0];
|
|
5109
5145
|
};
|
|
5110
5146
|
|
|
5111
|
-
const logger$
|
|
5147
|
+
const logger$b = debug('app:db:read:getItemData');
|
|
5112
5148
|
const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
5113
5149
|
if (!seedLocalId && !seedUid) {
|
|
5114
5150
|
throw new Error('[db/queries] [getItem] no seedLocalId or seedUid');
|
|
@@ -5116,7 +5152,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
5116
5152
|
if (seedUid && !seedLocalId) {
|
|
5117
5153
|
const seedData = await getSeedData({ seedUid });
|
|
5118
5154
|
if (!seedData) {
|
|
5119
|
-
logger$
|
|
5155
|
+
logger$b('[db/queries] [getItem] no seedData seedUid', seedUid);
|
|
5120
5156
|
return;
|
|
5121
5157
|
}
|
|
5122
5158
|
seedLocalId = seedData.localId;
|
|
@@ -5151,7 +5187,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
5151
5187
|
.orderBy(sql.raw('COALESCE(attestation_created_at, created_at) DESC'))
|
|
5152
5188
|
.groupBy(seeds.localId);
|
|
5153
5189
|
if (!itemDataRows || itemDataRows.length === 0) {
|
|
5154
|
-
logger$
|
|
5190
|
+
logger$b('[db/queries] [getItemDataFromDb] no itemDataRows');
|
|
5155
5191
|
return;
|
|
5156
5192
|
}
|
|
5157
5193
|
let itemData = itemDataRows[0];
|
|
@@ -5286,7 +5322,7 @@ const waitForDb = fromCallback(({ sendBack }) => {
|
|
|
5286
5322
|
});
|
|
5287
5323
|
});
|
|
5288
5324
|
|
|
5289
|
-
const initialize = fromCallback(({ sendBack, input: { context } }) => {
|
|
5325
|
+
const initialize$1 = fromCallback(({ sendBack, input: { context } }) => {
|
|
5290
5326
|
const { isRelation, propertyName, storageTransactionId } = context;
|
|
5291
5327
|
let { schemaUid } = context;
|
|
5292
5328
|
if (!schemaUid) {
|
|
@@ -5380,7 +5416,7 @@ const getRelationValueData = async (propertyValue) => {
|
|
|
5380
5416
|
return rows[0];
|
|
5381
5417
|
};
|
|
5382
5418
|
|
|
5383
|
-
const logger$
|
|
5419
|
+
const logger$a = debug('app:property:actors:resolveRelatedValue');
|
|
5384
5420
|
const storageTransactionIdToContentUrl = new Map();
|
|
5385
5421
|
const refResolvedValueToContentUrl = new Map();
|
|
5386
5422
|
const seedUidToContentUrl = new Map();
|
|
@@ -5395,7 +5431,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5395
5431
|
parsedValue = JSON.parse(propertyValue);
|
|
5396
5432
|
}
|
|
5397
5433
|
catch (error) {
|
|
5398
|
-
logger$
|
|
5434
|
+
logger$a(`${propertyName} value is not a JSON string.`);
|
|
5399
5435
|
}
|
|
5400
5436
|
if (!parsedValue && seedUidToContentUrl.has(propertyValue)) {
|
|
5401
5437
|
const contentUrl = seedUidToContentUrl.get(propertyValue);
|
|
@@ -5411,11 +5447,11 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5411
5447
|
}
|
|
5412
5448
|
if (Array.isArray(propertyValue)) {
|
|
5413
5449
|
// TODO: Handle array of seedUids
|
|
5414
|
-
logger$
|
|
5450
|
+
logger$a(`${propertyName} value is an array of seedUids`);
|
|
5415
5451
|
return;
|
|
5416
5452
|
}
|
|
5417
5453
|
if (Array.isArray(parsedValue)) {
|
|
5418
|
-
logger$
|
|
5454
|
+
logger$a(`${propertyName} value is a stringified array of seedUids`);
|
|
5419
5455
|
return;
|
|
5420
5456
|
}
|
|
5421
5457
|
const storageTransactionId = await getStorageTransactionIdForSeedUid(propertyValue);
|
|
@@ -5855,7 +5891,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5855
5891
|
if (propertyRecordSchema &&
|
|
5856
5892
|
propertyRecordSchema.storageType &&
|
|
5857
5893
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
5858
|
-
const { Item } = await import('./index-
|
|
5894
|
+
const { Item } = await import('./index-d8Qsot6w.js');
|
|
5859
5895
|
const item = await Item.find({
|
|
5860
5896
|
seedLocalId,
|
|
5861
5897
|
modelName,
|
|
@@ -5900,10 +5936,10 @@ const getVersionData = async ({ localId, seedLocalId, uid, }) => {
|
|
|
5900
5936
|
return queryRows[0];
|
|
5901
5937
|
};
|
|
5902
5938
|
|
|
5903
|
-
const logger$
|
|
5939
|
+
const logger$9 = debug('app:write:updateItemPropertyValue');
|
|
5904
5940
|
const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUid, seedLocalId, modelName, refSeedType, refResolvedValue, refResolvedDisplayValue, versionLocalId, versionUid, schemaUid, localStorageDir, }) => {
|
|
5905
5941
|
if (!localId && !seedLocalId) {
|
|
5906
|
-
logger$
|
|
5942
|
+
logger$9(`[db/write] [updateItemPropertyValue] no propertyLocalId or seedLocalId for property: ${propertyName}`);
|
|
5907
5943
|
return;
|
|
5908
5944
|
}
|
|
5909
5945
|
let safeNewValue = newValue;
|
|
@@ -5941,7 +5977,7 @@ const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUi
|
|
|
5941
5977
|
modelType === modelName?.toLowerCase() &&
|
|
5942
5978
|
refSeedTypeFromDb === refSeedType &&
|
|
5943
5979
|
refResolvedValueFromDb === refResolvedValue) {
|
|
5944
|
-
logger$
|
|
5980
|
+
logger$9(`[db/write] [updateItemPropertyValue] value is the same as most recent record for property: ${propertyNameFromDb}`);
|
|
5945
5981
|
return;
|
|
5946
5982
|
}
|
|
5947
5983
|
// This means we already have a local-only record so we should just update that one
|
|
@@ -6272,7 +6308,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
6272
6308
|
});
|
|
6273
6309
|
if (fileData instanceof ArrayBuffer) {
|
|
6274
6310
|
try {
|
|
6275
|
-
await
|
|
6311
|
+
await BaseFileManager.saveFile(filePath, new Uint8Array(fileData));
|
|
6276
6312
|
}
|
|
6277
6313
|
catch (e) {
|
|
6278
6314
|
fs.writeFileSync(filePath, new Uint8Array(fileData));
|
|
@@ -6281,7 +6317,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
6281
6317
|
}
|
|
6282
6318
|
if (typeof fileData === 'string') {
|
|
6283
6319
|
try {
|
|
6284
|
-
await
|
|
6320
|
+
await BaseFileManager.saveFile(filePath, fileData);
|
|
6285
6321
|
}
|
|
6286
6322
|
catch (e) {
|
|
6287
6323
|
fs.writeFileSync(filePath, fileData);
|
|
@@ -6491,7 +6527,7 @@ const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) =
|
|
|
6491
6527
|
if (!propertyData && newValue) {
|
|
6492
6528
|
const filename = `${seedUid || seedLocalId}${propertyRecordSchema.filenameSuffix}`;
|
|
6493
6529
|
const writeToPath = `/files/${propertyRecordSchema.localStorageDir}/${filename}`;
|
|
6494
|
-
await
|
|
6530
|
+
await BaseFileManager.saveFile(writeToPath, newValue);
|
|
6495
6531
|
const propertyDataRows = await createMetadata({
|
|
6496
6532
|
propertyName,
|
|
6497
6533
|
propertyValue: filename,
|
|
@@ -6523,7 +6559,7 @@ const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) =
|
|
|
6523
6559
|
}
|
|
6524
6560
|
const filePath = `/files/${localStorageDir}/${fileName}`;
|
|
6525
6561
|
try {
|
|
6526
|
-
await
|
|
6562
|
+
await BaseFileManager.saveFile(filePath, newValue);
|
|
6527
6563
|
}
|
|
6528
6564
|
catch (error) {
|
|
6529
6565
|
fs.writeFileSync(filePath, newValue);
|
|
@@ -6559,7 +6595,7 @@ const propertyMachine = setup({
|
|
|
6559
6595
|
actors: {
|
|
6560
6596
|
waitForDb,
|
|
6561
6597
|
hydrateFromDb,
|
|
6562
|
-
initialize,
|
|
6598
|
+
initialize: initialize$1,
|
|
6563
6599
|
resolveRelatedValue,
|
|
6564
6600
|
resolveRemoteStorage,
|
|
6565
6601
|
analyzeInput,
|
|
@@ -6759,7 +6795,7 @@ const getPropertyData$1 = async ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
6759
6795
|
};
|
|
6760
6796
|
|
|
6761
6797
|
var _a$1;
|
|
6762
|
-
const logger$
|
|
6798
|
+
const logger$8 = debug('app:property:class');
|
|
6763
6799
|
class BaseItemProperty {
|
|
6764
6800
|
constructor(initialValues) {
|
|
6765
6801
|
this._isRelation = false;
|
|
@@ -6806,7 +6842,7 @@ class BaseItemProperty {
|
|
|
6806
6842
|
serviceInput.propertyValue = JSON.parse(propertyValue);
|
|
6807
6843
|
}
|
|
6808
6844
|
catch (e) {
|
|
6809
|
-
logger$
|
|
6845
|
+
logger$8('List property value is not JSON', e);
|
|
6810
6846
|
}
|
|
6811
6847
|
}
|
|
6812
6848
|
const propertyNameSingular = pluralize(propertyName, 1);
|
|
@@ -6853,7 +6889,7 @@ class BaseItemProperty {
|
|
|
6853
6889
|
}
|
|
6854
6890
|
}
|
|
6855
6891
|
catch (e) {
|
|
6856
|
-
logger$
|
|
6892
|
+
logger$8(`[ItemProperty] [${context.seedLocalId}] [${context.propertyName}] [storageType] error`, e);
|
|
6857
6893
|
renderValue = 'No file found';
|
|
6858
6894
|
}
|
|
6859
6895
|
}
|
|
@@ -7098,7 +7134,7 @@ const getSegmentedItemProperties = (item) => {
|
|
|
7098
7134
|
};
|
|
7099
7135
|
};
|
|
7100
7136
|
|
|
7101
|
-
const logger$
|
|
7137
|
+
const logger$7 = debug('app:item:getPublishUploads');
|
|
7102
7138
|
const prepareArweaveTransaction = async (data, contentHash) => {
|
|
7103
7139
|
const transactionData = {
|
|
7104
7140
|
data,
|
|
@@ -7106,8 +7142,8 @@ const prepareArweaveTransaction = async (data, contentHash) => {
|
|
|
7106
7142
|
};
|
|
7107
7143
|
const tx = await getArweave().createTransaction(transactionData);
|
|
7108
7144
|
if (contentHash) {
|
|
7109
|
-
logger$
|
|
7110
|
-
logger$
|
|
7145
|
+
logger$7('contentHash', contentHash);
|
|
7146
|
+
logger$7('adding content hash tag to tx.id:', tx.id);
|
|
7111
7147
|
tx.addTag('Content-SHA-256', contentHash);
|
|
7112
7148
|
}
|
|
7113
7149
|
return tx;
|
|
@@ -7805,7 +7841,7 @@ const initItem = async () => {
|
|
|
7805
7841
|
Item$2 = (await Promise.resolve().then(function () { return Item$1; })).Item;
|
|
7806
7842
|
}
|
|
7807
7843
|
if (!isBrowser()) {
|
|
7808
|
-
Item$2 = (await import('./Item-
|
|
7844
|
+
Item$2 = (await import('./Item-CqWdJsyg.js')).Item;
|
|
7809
7845
|
}
|
|
7810
7846
|
};
|
|
7811
7847
|
|
|
@@ -7815,17 +7851,17 @@ const initItemProperty = async () => {
|
|
|
7815
7851
|
ItemProperty$2 = (await Promise.resolve().then(function () { return ItemProperty$1; })).ItemProperty;
|
|
7816
7852
|
}
|
|
7817
7853
|
if (!isBrowser()) {
|
|
7818
|
-
ItemProperty$2 = (await import('./ItemProperty-
|
|
7854
|
+
ItemProperty$2 = (await import('./ItemProperty-BpBW3IWx.js')).ItemProperty;
|
|
7819
7855
|
}
|
|
7820
7856
|
};
|
|
7821
7857
|
|
|
7822
7858
|
let Db;
|
|
7823
7859
|
const initDb = async () => {
|
|
7824
7860
|
if (isBrowser()) {
|
|
7825
|
-
Db = (await import('./Db-
|
|
7861
|
+
Db = (await import('./Db-Dpsbk_T7.js')).Db;
|
|
7826
7862
|
}
|
|
7827
7863
|
if (!isBrowser()) {
|
|
7828
|
-
Db = (await import('./Db-
|
|
7864
|
+
Db = (await import('./Db-D-BsZYlN.js')).Db;
|
|
7829
7865
|
}
|
|
7830
7866
|
// TODO: Add config for React Native
|
|
7831
7867
|
};
|
|
@@ -7842,7 +7878,7 @@ var Item$1 = /*#__PURE__*/Object.freeze({
|
|
|
7842
7878
|
Item: Item
|
|
7843
7879
|
});
|
|
7844
7880
|
|
|
7845
|
-
const logger$
|
|
7881
|
+
const logger$6 = debug('app:react:services');
|
|
7846
7882
|
const finalStrings = ['idle', 'ready', 'done', 'success', 'initialized'];
|
|
7847
7883
|
const getServiceName = (service) => {
|
|
7848
7884
|
let name = 'actor';
|
|
@@ -7889,7 +7925,7 @@ const getServiceUniqueKey = (service) => {
|
|
|
7889
7925
|
snapshot = service.getSnapshot();
|
|
7890
7926
|
}
|
|
7891
7927
|
catch (error) {
|
|
7892
|
-
logger$
|
|
7928
|
+
logger$6('Error:', error);
|
|
7893
7929
|
return uniqueKey;
|
|
7894
7930
|
}
|
|
7895
7931
|
if (snapshot) {
|
|
@@ -8118,7 +8154,7 @@ const useGlobalServiceStatus = () => {
|
|
|
8118
8154
|
};
|
|
8119
8155
|
};
|
|
8120
8156
|
|
|
8121
|
-
const logger$
|
|
8157
|
+
const logger$5 = debug('app:react:item');
|
|
8122
8158
|
const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
8123
8159
|
// const [itemSubscription, setItemSubscription] = useState<
|
|
8124
8160
|
// Subscription | undefined
|
|
@@ -8195,7 +8231,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
8195
8231
|
seedUid,
|
|
8196
8232
|
});
|
|
8197
8233
|
if (!foundItem) {
|
|
8198
|
-
logger$
|
|
8234
|
+
logger$5('[useItem] [getItemFromDb] no item found', modelName, seedLocalId);
|
|
8199
8235
|
isReadingDb.current = false;
|
|
8200
8236
|
return;
|
|
8201
8237
|
}
|
|
@@ -8217,7 +8253,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
8217
8253
|
const subscription = item.subscribe(async (_) => {
|
|
8218
8254
|
const newItem = await Item.find({ modelName, seedLocalId, seedUid });
|
|
8219
8255
|
if (!newItem) {
|
|
8220
|
-
logger$
|
|
8256
|
+
logger$5('[useItem] [itemSubscription] no item found', modelName, seedLocalId);
|
|
8221
8257
|
return;
|
|
8222
8258
|
}
|
|
8223
8259
|
updateItem(newItem);
|
|
@@ -8376,7 +8412,7 @@ var ItemProperty$1 = /*#__PURE__*/Object.freeze({
|
|
|
8376
8412
|
ItemProperty: ItemProperty
|
|
8377
8413
|
});
|
|
8378
8414
|
|
|
8379
|
-
const logger$
|
|
8415
|
+
const logger$4 = debug('app:react:property');
|
|
8380
8416
|
const useItemProperty = (props = {
|
|
8381
8417
|
propertyName: '',
|
|
8382
8418
|
seedLocalId: '',
|
|
@@ -8407,7 +8443,7 @@ const useItemProperty = (props = {
|
|
|
8407
8443
|
seedUid,
|
|
8408
8444
|
});
|
|
8409
8445
|
if (!foundProperty) {
|
|
8410
|
-
logger$
|
|
8446
|
+
logger$4(`[useItemPropertyTest] [readFromDb] no property found for Item.${seedLocalId}.${propertyName}`);
|
|
8411
8447
|
isReadingDb.current = false;
|
|
8412
8448
|
return;
|
|
8413
8449
|
}
|
|
@@ -8579,10 +8615,37 @@ const withSeed = (config, webpack, isServer) => {
|
|
|
8579
8615
|
return config;
|
|
8580
8616
|
};
|
|
8581
8617
|
|
|
8582
|
-
const
|
|
8618
|
+
const initEasClient = async () => {
|
|
8619
|
+
if (isBrowser()) {
|
|
8620
|
+
(await import('./EasClient-jqkT2ZBt.js')).EasClient;
|
|
8621
|
+
}
|
|
8622
|
+
if (!isBrowser()) {
|
|
8623
|
+
(await import('./EasClient-D3wKgt0o.js')).EasClient;
|
|
8624
|
+
}
|
|
8625
|
+
};
|
|
8626
|
+
|
|
8627
|
+
const initFileManager = async () => {
|
|
8628
|
+
if (isBrowser()) {
|
|
8629
|
+
(await Promise.resolve().then(function () { return FileManager$1; })).FileManager;
|
|
8630
|
+
}
|
|
8631
|
+
if (!isBrowser()) {
|
|
8632
|
+
(await import('./FileManager-4mWYO3Mt.js')).FileManager;
|
|
8633
|
+
}
|
|
8634
|
+
};
|
|
8635
|
+
|
|
8636
|
+
const initQueryClient = async () => {
|
|
8637
|
+
if (isBrowser()) {
|
|
8638
|
+
(await import('./QueryClient-CBOP3OoU.js')).QueryClient;
|
|
8639
|
+
}
|
|
8640
|
+
if (!isBrowser()) {
|
|
8641
|
+
(await import('./QueryClient-bKb3SB0W.js')).QueryClient;
|
|
8642
|
+
}
|
|
8643
|
+
};
|
|
8644
|
+
|
|
8645
|
+
const logger$3 = debug('app:services:events');
|
|
8583
8646
|
const handleServiceSaveState = (event) => {
|
|
8584
8647
|
const { state, serviceId } = event;
|
|
8585
|
-
logger$
|
|
8648
|
+
logger$3(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
|
|
8586
8649
|
localStorage.setItem(`seed_sdk_service_${serviceId}`, JSON.stringify(state));
|
|
8587
8650
|
};
|
|
8588
8651
|
const setupServicesEventHandlers = () => {
|
|
@@ -8601,49 +8664,23 @@ const saveServiceHandler = async (event) => {
|
|
|
8601
8664
|
console.log(`[saveServiceHandler] service not found: ${nameOfService}`);
|
|
8602
8665
|
return;
|
|
8603
8666
|
}
|
|
8604
|
-
await saveAppState(`snapshot__${modelName}`, JSON.stringify(service.getPersistedSnapshot()));
|
|
8667
|
+
await saveAppState$1(`snapshot__${modelName}`, JSON.stringify(service.getPersistedSnapshot()));
|
|
8605
8668
|
};
|
|
8606
8669
|
|
|
8607
8670
|
const setupServiceHandlers = () => {
|
|
8608
8671
|
eventEmitter.addListener('service.save', saveServiceHandler);
|
|
8609
8672
|
};
|
|
8610
8673
|
|
|
8611
|
-
const
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
}
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
const initQueryClient = async () => {
|
|
8621
|
-
if (isBrowser()) {
|
|
8622
|
-
(await import('./QueryClient-C-hFMF2j.js')).QueryClient;
|
|
8623
|
-
}
|
|
8624
|
-
if (!isBrowser()) {
|
|
8625
|
-
(await import('./QueryClient-C02sPZ-K.js')).QueryClient;
|
|
8626
|
-
}
|
|
8627
|
-
};
|
|
8628
|
-
|
|
8629
|
-
const initFileManager = async () => {
|
|
8630
|
-
if (isBrowser()) {
|
|
8631
|
-
(await Promise.resolve().then(function () { return FileManager$1; })).FileManager;
|
|
8632
|
-
}
|
|
8633
|
-
if (!isBrowser()) {
|
|
8634
|
-
(await import('./FileManager-Dv2zn1RW.js')).FileManager;
|
|
8674
|
+
const logger$2 = debug('app:ClientManager:initialize');
|
|
8675
|
+
const initialize = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
8676
|
+
logger$2('initialize from ClientManager');
|
|
8677
|
+
const { isInitialized } = context;
|
|
8678
|
+
const { options, } = event;
|
|
8679
|
+
if (isInitialized) {
|
|
8680
|
+
sendBack({ type: 'initialized' });
|
|
8681
|
+
return;
|
|
8635
8682
|
}
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
const logger = debug('app:client');
|
|
8639
|
-
const client = {
|
|
8640
|
-
isInitialized: false,
|
|
8641
|
-
init: async (options) => {
|
|
8642
|
-
logger('init client');
|
|
8643
|
-
if (client.isInitialized) {
|
|
8644
|
-
return;
|
|
8645
|
-
}
|
|
8646
|
-
client.isInitialized = true;
|
|
8683
|
+
const _initialize = async () => {
|
|
8647
8684
|
const { config, addresses } = options;
|
|
8648
8685
|
await initItem();
|
|
8649
8686
|
await initItemProperty();
|
|
@@ -8677,34 +8714,148 @@ const client = {
|
|
|
8677
8714
|
arweaveDomain,
|
|
8678
8715
|
filesDir,
|
|
8679
8716
|
});
|
|
8680
|
-
const { models: internalModels } = await import('./seed.schema.config-
|
|
8717
|
+
const { models: internalModels } = await import('./seed.schema.config-CPRn6KVL.js');
|
|
8681
8718
|
for (const [key, value] of Object.entries(internalModels)) {
|
|
8682
8719
|
setModel(key, value);
|
|
8683
8720
|
}
|
|
8684
|
-
}
|
|
8685
|
-
|
|
8721
|
+
};
|
|
8722
|
+
_initialize().then(() => {
|
|
8723
|
+
sendBack({ type: 'initialized' });
|
|
8724
|
+
});
|
|
8725
|
+
});
|
|
8726
|
+
|
|
8727
|
+
debug('app:client:writeToDb');
|
|
8728
|
+
const saveAppState = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
8729
|
+
const { key, value } = event;
|
|
8730
|
+
const _saveAppState = async () => {
|
|
8686
8731
|
const { BaseDb } = await Promise.resolve().then(function () { return BaseDb$1; });
|
|
8687
8732
|
if (!BaseDb) {
|
|
8688
8733
|
throw new Error('BaseDb not found');
|
|
8689
8734
|
}
|
|
8690
|
-
if (!BaseDb.PlatformClass) {
|
|
8691
|
-
await initDb();
|
|
8692
|
-
}
|
|
8693
8735
|
const appDb = BaseDb.getAppDb();
|
|
8694
8736
|
if (!appDb) {
|
|
8695
8737
|
throw new Error('App DB not found');
|
|
8696
8738
|
}
|
|
8697
8739
|
appDb.insert(appState)
|
|
8698
8740
|
.values({
|
|
8699
|
-
key:
|
|
8700
|
-
value: JSON.stringify(
|
|
8741
|
+
key: key,
|
|
8742
|
+
value: JSON.stringify(value),
|
|
8701
8743
|
})
|
|
8702
8744
|
.onConflictDoUpdate({
|
|
8703
8745
|
target: appState.key,
|
|
8704
8746
|
set: {
|
|
8705
|
-
value: JSON.stringify(
|
|
8747
|
+
value: JSON.stringify(value),
|
|
8706
8748
|
},
|
|
8707
8749
|
});
|
|
8750
|
+
};
|
|
8751
|
+
_saveAppState().then(() => {
|
|
8752
|
+
sendBack({
|
|
8753
|
+
type: 'saveAppStateSuccess',
|
|
8754
|
+
});
|
|
8755
|
+
});
|
|
8756
|
+
});
|
|
8757
|
+
|
|
8758
|
+
const setAddresses = assign(({ event, spawn }) => {
|
|
8759
|
+
const { addresses } = event;
|
|
8760
|
+
spawn(saveAppState, {
|
|
8761
|
+
input: {
|
|
8762
|
+
key: 'addresses',
|
|
8763
|
+
value: addresses,
|
|
8764
|
+
},
|
|
8765
|
+
});
|
|
8766
|
+
return {
|
|
8767
|
+
addresses,
|
|
8768
|
+
};
|
|
8769
|
+
});
|
|
8770
|
+
|
|
8771
|
+
const clientManagerMachine = setup({
|
|
8772
|
+
types: {
|
|
8773
|
+
context: {},
|
|
8774
|
+
input: {},
|
|
8775
|
+
},
|
|
8776
|
+
actions: {
|
|
8777
|
+
setAddresses,
|
|
8778
|
+
},
|
|
8779
|
+
actors: {
|
|
8780
|
+
initialize,
|
|
8781
|
+
},
|
|
8782
|
+
}).createMachine({
|
|
8783
|
+
id: 'clientManager',
|
|
8784
|
+
initial: 'uninitialized',
|
|
8785
|
+
context: ({ input }) => input,
|
|
8786
|
+
states: {
|
|
8787
|
+
uninitialized: {
|
|
8788
|
+
on: {
|
|
8789
|
+
init: {
|
|
8790
|
+
target: 'initializing',
|
|
8791
|
+
},
|
|
8792
|
+
},
|
|
8793
|
+
},
|
|
8794
|
+
initializing: {
|
|
8795
|
+
on: {
|
|
8796
|
+
initialized: {
|
|
8797
|
+
target: 'idle',
|
|
8798
|
+
},
|
|
8799
|
+
},
|
|
8800
|
+
invoke: {
|
|
8801
|
+
src: 'initialize',
|
|
8802
|
+
input: ({ event, context }) => ({ event, context }),
|
|
8803
|
+
},
|
|
8804
|
+
},
|
|
8805
|
+
idle: {
|
|
8806
|
+
on: {
|
|
8807
|
+
setAddressesSuccess: {
|
|
8808
|
+
actions: assign({
|
|
8809
|
+
isSaving: false,
|
|
8810
|
+
}),
|
|
8811
|
+
},
|
|
8812
|
+
},
|
|
8813
|
+
setAddresses: {
|
|
8814
|
+
actions: ['setAddresses'],
|
|
8815
|
+
},
|
|
8816
|
+
},
|
|
8817
|
+
},
|
|
8818
|
+
});
|
|
8819
|
+
|
|
8820
|
+
const logger$1 = debug('app:client');
|
|
8821
|
+
const clientManager = createActor(clientManagerMachine, {
|
|
8822
|
+
input: {
|
|
8823
|
+
isInitialized: false,
|
|
8824
|
+
}
|
|
8825
|
+
});
|
|
8826
|
+
const subscription = clientManager.subscribe((snapshot) => {
|
|
8827
|
+
console.log('ClientManager snapshot:', snapshot);
|
|
8828
|
+
});
|
|
8829
|
+
clientManager.start();
|
|
8830
|
+
const ClientManager = {
|
|
8831
|
+
getService: () => clientManager,
|
|
8832
|
+
init: async (options) => {
|
|
8833
|
+
clientManager.send({ type: 'init', options, });
|
|
8834
|
+
await waitFor(clientManager, (snapshot) => snapshot.value === 'initialized');
|
|
8835
|
+
},
|
|
8836
|
+
setAddresses: async (addresses) => {
|
|
8837
|
+
logger$1('setAddresses', addresses);
|
|
8838
|
+
clientManager.send({ type: 'setAddresses', addresses });
|
|
8839
|
+
await waitFor(clientManager, (snapshot) => !snapshot.context.isSaving);
|
|
8840
|
+
logger$1('setAddresses success', addresses);
|
|
8841
|
+
},
|
|
8842
|
+
stop: () => clientManager.stop(),
|
|
8843
|
+
unload: () => {
|
|
8844
|
+
clientManager.stop();
|
|
8845
|
+
subscription.unsubscribe();
|
|
8846
|
+
},
|
|
8847
|
+
};
|
|
8848
|
+
|
|
8849
|
+
const logger = debug('app:client');
|
|
8850
|
+
const client = {
|
|
8851
|
+
isInitialized: false,
|
|
8852
|
+
init: async (options) => {
|
|
8853
|
+
logger('init client');
|
|
8854
|
+
await ClientManager.init(options);
|
|
8855
|
+
logger('client initialized');
|
|
8856
|
+
},
|
|
8857
|
+
setAddresses: async (addresses) => {
|
|
8858
|
+
ClientManager.setAddresses(addresses);
|
|
8708
8859
|
},
|
|
8709
8860
|
subscribe: (callback) => {
|
|
8710
8861
|
const subscription = globalService.subscribe(callback);
|
|
@@ -8749,4 +8900,4 @@ const client = {
|
|
|
8749
8900
|
enableMapSet();
|
|
8750
8901
|
|
|
8751
8902
|
export { BaseItem as B, Db as D, FileManager as F, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, BaseItemProperty as a, BaseDb as b, ImageSrc as c, Item$2 as d, ItemProperty$2 as e, useItem as f, useItemProperties as g, useCreateItem as h, useItemProperty as i, useDeleteItem as j, useGlobalServiceStatus as k, usePublishItem as l, usePersistedSnapshots as m, useServices as n, useService as o, getCorrectId as p, getGlobalService as q, eventEmitter as r, client as s, useItems as u, withSeed as w };
|
|
8752
|
-
//# sourceMappingURL=index-
|
|
8903
|
+
//# sourceMappingURL=index-BRxO1tLl.js.map
|