@seedprotocol/sdk 0.2.44 → 0.2.46
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-CA1Vsnow.js → ArweaveClient-CoFomTCN.js} +2 -2
- package/dist/{ArweaveClient-MgJXScYG.js.map → ArweaveClient-CoFomTCN.js.map} +1 -1
- package/dist/{ArweaveClient-MgJXScYG.js → ArweaveClient-DQrXvrNN.js} +2 -2
- package/dist/{ArweaveClient-CA1Vsnow.js.map → ArweaveClient-DQrXvrNN.js.map} +1 -1
- package/dist/{Db-BEoczaGe.js → Db-5C5VqRWb.js} +16 -14
- package/dist/Db-5C5VqRWb.js.map +1 -0
- package/dist/{Db-Y1GWsyNL.js → Db-Dv890NJZ.js} +5 -4
- package/dist/{Db-Y1GWsyNL.js.map → Db-Dv890NJZ.js.map} +1 -1
- package/dist/{EasClient-BjlbuffX.js → EasClient-CBu9ENAi.js} +2 -2
- package/dist/{EasClient-Cg1q8lBu.js.map → EasClient-CBu9ENAi.js.map} +1 -1
- package/dist/{EasClient-Cg1q8lBu.js → EasClient-sCbTHcO8.js} +2 -2
- package/dist/{EasClient-BjlbuffX.js.map → EasClient-sCbTHcO8.js.map} +1 -1
- package/dist/{FileManager-D53H3aUS.js → FileManager-AhAsy_F_.js} +21 -8
- package/dist/{FileManager-D53H3aUS.js.map → FileManager-AhAsy_F_.js.map} +1 -1
- package/dist/{FileManager-t4zcT3NL.js → FileManager-COOp89Mj.js} +2 -2
- package/dist/{FileManager-t4zcT3NL.js.map → FileManager-COOp89Mj.js.map} +1 -1
- package/dist/{Item-BleJyiA2.js → Item-BmPvgaG4.js} +5 -4
- package/dist/{Item-BleJyiA2.js.map → Item-BmPvgaG4.js.map} +1 -1
- package/dist/{ItemProperty-CH7JmVg-.js → ItemProperty-BW4k1h0o.js} +5 -4
- package/dist/{ItemProperty-CH7JmVg-.js.map → ItemProperty-BW4k1h0o.js.map} +1 -1
- package/dist/{QueryClient-CDsEencG.js → QueryClient-BBaE-LKI.js} +2 -2
- package/dist/{QueryClient-CDsEencG.js.map → QueryClient-BBaE-LKI.js.map} +1 -1
- package/dist/{QueryClient-BKjgZnSt.js → QueryClient-C-ZzUnWq.js} +2 -2
- package/dist/{QueryClient-BKjgZnSt.js.map → QueryClient-C-ZzUnWq.js.map} +1 -1
- package/dist/bin.js +5 -5
- package/dist/{constants-BIdH8wc3.js → constants-Dgv-tSO3.js} +13 -3
- package/dist/constants-Dgv-tSO3.js.map +1 -0
- package/dist/{index-DanGFTTF.js → index-CGeSKilQ.js} +283 -206
- package/dist/index-CGeSKilQ.js.map +1 -0
- package/dist/{index-Dk6K4W4n.js → index-CPxn1SR4.js} +5 -4
- package/dist/index-CPxn1SR4.js.map +1 -0
- package/dist/main.js +4 -3
- package/dist/main.js.map +1 -1
- package/dist/{seed.schema.config-DdCq87m_.js → seed.schema.config-BXWvwsZQ.js} +11 -10
- package/dist/seed.schema.config-BXWvwsZQ.js.map +1 -0
- package/dist/src/BaseFileManager.ts +11 -2
- package/dist/src/BaseItem.ts +1 -1
- package/dist/src/BaseItemProperty.ts +7 -6
- package/dist/src/actors.ts +1 -1
- package/dist/src/client.ts +12 -0
- package/dist/src/configureFs.ts +19 -6
- package/dist/src/createMetadata.ts +11 -4
- package/dist/src/dbMachine.ts +6 -0
- package/dist/src/download.ts +4 -2
- package/dist/src/files.ts +15 -4
- package/dist/src/getItemProperties.ts +9 -19
- package/dist/src/getPublishPayload.ts +15 -8
- package/dist/src/getPublishUploads.ts +1 -28
- package/dist/src/gql.ts +9 -4
- package/dist/src/graphql.ts +12 -4
- package/dist/src/helpers.ts +21 -4
- package/dist/src/hydrateFromDb.ts +5 -2
- package/dist/src/internalMachine.ts +16 -0
- package/dist/src/metadataLatest.ts +34 -0
- package/dist/src/migrate.ts +1 -25
- package/dist/src/property.ts +10 -7
- package/dist/src/resolveRelatedValue.ts +1 -1
- package/dist/src/resolveRemoteStorage.ts +1 -1
- package/dist/src/saveImageSrc.ts +2 -2
- package/dist/src/saveItemStorage.ts +1 -1
- package/dist/src/updateItemPropertyValue.ts +1 -1
- package/dist/src/validate.ts +7 -4
- package/dist/src/waitForDb.ts +12 -9
- package/dist/src/waitForFiles.ts +9 -8
- package/dist/types/src/Item/queries.d.ts +2 -2
- package/dist/types/src/Item/queries.d.ts.map +1 -1
- package/dist/types/src/Item/service/actors/fetchDataFromEas.d.ts +1 -2
- package/dist/types/src/Item/service/actors/fetchDataFromEas.d.ts.map +1 -1
- package/dist/types/src/Item/service/actors/waitForDb.d.ts +3 -1
- package/dist/types/src/Item/service/actors/waitForDb.d.ts.map +1 -1
- package/dist/types/src/ItemProperty/BaseItemProperty.d.ts +1 -1
- package/dist/types/src/ItemProperty/BaseItemProperty.d.ts.map +1 -1
- package/dist/types/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
- package/dist/types/src/ItemProperty/service/actors/waitForDb.d.ts.map +1 -1
- package/dist/types/src/ItemProperty/service/propertyMachine.d.ts +6 -6
- package/dist/types/src/browser/db/Db.d.ts.map +1 -1
- package/dist/types/src/browser/helpers/FileManager.d.ts.map +1 -1
- package/dist/types/src/browser/react/property.d.ts +1 -1
- package/dist/types/src/browser/react/property.d.ts.map +1 -1
- package/dist/types/src/client.d.ts +1 -0
- package/dist/types/src/client.d.ts.map +1 -1
- package/dist/types/src/db/read/getItemProperties.d.ts.map +1 -1
- package/dist/types/src/db/read/getPublishPayload.d.ts.map +1 -1
- package/dist/types/src/db/read/getPublishUploads.d.ts.map +1 -1
- package/dist/types/src/db/read/subqueries/metadataLatest.d.ts +5 -0
- package/dist/types/src/db/read/subqueries/metadataLatest.d.ts.map +1 -0
- package/dist/types/src/db/write/createMetadata.d.ts.map +1 -1
- package/dist/types/src/events/files/download.d.ts.map +1 -1
- package/dist/types/src/graphql/gql/gql.d.ts +12 -5
- package/dist/types/src/graphql/gql/gql.d.ts.map +1 -1
- package/dist/types/src/graphql/gql/graphql.d.ts +31 -15
- package/dist/types/src/graphql/gql/graphql.d.ts.map +1 -1
- package/dist/types/src/helpers/FileManager/BaseFileManager.d.ts +2 -0
- package/dist/types/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
- package/dist/types/src/helpers/files.d.ts.map +1 -1
- package/dist/types/src/schema/file/queries.d.ts.map +1 -1
- package/dist/types/src/schema/model/index.d.ts.map +1 -1
- package/dist/types/src/services/db/actors/migrate.d.ts.map +1 -1
- package/dist/types/src/services/db/actors/validate.d.ts.map +1 -1
- package/dist/types/src/services/db/dbMachine.d.ts +10 -0
- package/dist/types/src/services/db/dbMachine.d.ts.map +1 -1
- package/dist/types/src/services/global/globalMachine.d.ts +90 -90
- package/dist/types/src/services/internal/actors/configureFs.d.ts.map +1 -1
- package/dist/types/src/services/internal/actors/waitForFiles.d.ts +4 -0
- package/dist/types/src/services/internal/actors/waitForFiles.d.ts.map +1 -0
- package/dist/types/src/services/internal/helpers.d.ts.map +1 -1
- package/dist/types/src/services/internal/internalMachine.d.ts +10 -0
- package/dist/types/src/services/internal/internalMachine.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/Db-BEoczaGe.js.map +0 -1
- package/dist/constants-BIdH8wc3.js.map +0 -1
- package/dist/index-DanGFTTF.js.map +0 -1
- package/dist/index-Dk6K4W4n.js.map +0 -1
- package/dist/seed.schema.config-DdCq87m_.js.map +0 -1
- package/dist/types/src/Item/service/actors/saveDataToDb.d.ts +0 -3
- package/dist/types/src/Item/service/actors/saveDataToDb.d.ts.map +0 -1
|
@@ -2,21 +2,22 @@ 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 { b 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, m as DB_MIGRATING_SUCCESS,
|
|
5
|
+
import { b 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, 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, c as BaseFileManager, 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-Dgv-tSO3.js';
|
|
6
|
+
import debug from 'debug';
|
|
6
7
|
import pluralize from 'pluralize';
|
|
7
8
|
import { sqliteTable, text, int, unique } from 'drizzle-orm/sqlite-core';
|
|
8
|
-
import { relations, or, and, isNotNull, not, eq, inArray, sql, like,
|
|
9
|
+
import { relations, or, and, isNotNull, not, eq, inArray, sql, like, getTableColumns, isNull, count, max, gt } from 'drizzle-orm';
|
|
9
10
|
import EventEmitter from 'eventemitter3';
|
|
10
11
|
import { customAlphabet } from 'nanoid';
|
|
11
12
|
import * as nanoIdDictionary from 'nanoid-dictionary';
|
|
12
|
-
import fs
|
|
13
|
-
import debug from 'debug';
|
|
13
|
+
import fs from '@zenfs/core';
|
|
14
14
|
import { throttle, camelCase, startCase, orderBy } from 'lodash-es';
|
|
15
15
|
import { createBrowserInspector } from '@statelyai/inspect';
|
|
16
16
|
import * as fsNode from 'node:fs';
|
|
17
17
|
import path from 'path';
|
|
18
18
|
import Arweave from 'arweave';
|
|
19
19
|
import { BehaviorSubject } from 'rxjs';
|
|
20
|
+
import { toSnakeCase as toSnakeCase$1 } from 'drizzle-orm/casing';
|
|
20
21
|
import { ZERO_BYTES32, SchemaEncoder } from '@ethereum-attestation-service/eas-sdk';
|
|
21
22
|
import { useState, useCallback, useEffect, useRef } from 'react';
|
|
22
23
|
import { useImmer } from 'use-immer';
|
|
@@ -123,6 +124,7 @@ class BaseDb {
|
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
|
|
127
|
+
debug('app:item:service:actors:waitForDb');
|
|
126
128
|
const waitForDb$1 = fromCallback(({ sendBack }) => {
|
|
127
129
|
const _waitForDb = new Promise((resolve) => {
|
|
128
130
|
const interval = setInterval(() => {
|
|
@@ -288,7 +290,7 @@ const initialize$3 = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
288
290
|
|
|
289
291
|
const eventEmitter = new EventEmitter();
|
|
290
292
|
|
|
291
|
-
const logger$
|
|
293
|
+
const logger$q = debug('app:shared:helpers');
|
|
292
294
|
const { alphanumeric } = nanoIdDictionary;
|
|
293
295
|
const generateId = () => {
|
|
294
296
|
return customAlphabet(alphanumeric, 10)();
|
|
@@ -345,7 +347,7 @@ const convertTxIdToImageSrc = async (txId) => {
|
|
|
345
347
|
const imageFilePath = `/files/images/${txId}`;
|
|
346
348
|
const fileExists = await fs.promises.exists(imageFilePath);
|
|
347
349
|
if (!fileExists) {
|
|
348
|
-
logger$
|
|
350
|
+
logger$q(`[ItemView] [updateImageSrc] ${imageFilePath} does not exist`);
|
|
349
351
|
return;
|
|
350
352
|
}
|
|
351
353
|
const uint = await fs.promises.readFile(imageFilePath);
|
|
@@ -470,6 +472,7 @@ const AttestationFieldsFragmentDoc = { "kind": "Document", "definitions": [{ "ki
|
|
|
470
472
|
const SchemaFieldsFragmentDoc = { "kind": "Document", "definitions": [{ "kind": "FragmentDefinition", "name": { "kind": "Name", "value": "schemaFields" }, "typeCondition": { "kind": "NamedType", "name": { "kind": "Name", "value": "Schema" } }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "resolver" } }, { "kind": "Field", "name": { "kind": "Name", "value": "revocable" } }, { "kind": "Field", "name": { "kind": "Name", "value": "schema" } }, { "kind": "Field", "name": { "kind": "Name", "value": "index" } }, { "kind": "Field", "name": { "kind": "Name", "value": "schemaNames" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "name" } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "time" } }, { "kind": "Field", "name": { "kind": "Name", "value": "txid" } }, { "kind": "Field", "name": { "kind": "Name", "value": "creator" } }] } }] };
|
|
471
473
|
const GetTransactionTagsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetTransactionTags" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "transactionId" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "ID" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "alias": { "kind": "Name", "value": "tags" }, "name": { "kind": "Name", "value": "transaction" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "id" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "transactionId" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "tags" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "name" } }, { "kind": "Field", "name": { "kind": "Name", "value": "value" } }] } }] } }] } }] };
|
|
472
474
|
const GetSchemasDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetSchemas" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "where" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "SchemaWhereInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "alias": { "kind": "Name", "value": "schemas" }, "name": { "kind": "Name", "value": "schemata" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "where" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "schema" } }, { "kind": "Field", "name": { "kind": "Name", "value": "schemaNames" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "name" } }] } }] } }] } }] };
|
|
475
|
+
const GetSchemaByNameDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetSchemaByName" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "where" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "SchemaWhereInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "alias": { "kind": "Name", "value": "schemas" }, "name": { "kind": "Name", "value": "schemata" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "where" } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "schema" } }, { "kind": "Field", "name": { "kind": "Name", "value": "schemaNames" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "name" } }] } }] } }] } }] };
|
|
473
476
|
const GetSeedsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetSeeds" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "where" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "AttestationWhereInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "alias": { "kind": "Name", "value": "itemSeeds" }, "name": { "kind": "Name", "value": "attestations" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "where" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "orderBy" }, "value": { "kind": "ListValue", "values": [{ "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "timeCreated" }, "value": { "kind": "EnumValue", "value": "desc" } }] }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "decodedDataJson" } }, { "kind": "Field", "name": { "kind": "Name", "value": "attester" } }, { "kind": "Field", "name": { "kind": "Name", "value": "schema" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "schemaNames" }, "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "name" } }] } }] } }, { "kind": "Field", "name": { "kind": "Name", "value": "refUID" } }, { "kind": "Field", "name": { "kind": "Name", "value": "revoked" } }, { "kind": "Field", "name": { "kind": "Name", "value": "schemaId" } }, { "kind": "Field", "name": { "kind": "Name", "value": "timeCreated" } }, { "kind": "Field", "name": { "kind": "Name", "value": "isOffchain" } }] } }] } }] };
|
|
474
477
|
const GetSeedIdsDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetSeedIds" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "where" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "AttestationWhereInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "alias": { "kind": "Name", "value": "itemSeedIds" }, "name": { "kind": "Name", "value": "attestations" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "where" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "orderBy" }, "value": { "kind": "ListValue", "values": [{ "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "timeCreated" }, "value": { "kind": "EnumValue", "value": "desc" } }] }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }] } }] } }] };
|
|
475
478
|
const GetStorageTransactionIdDocument = { "kind": "Document", "definitions": [{ "kind": "OperationDefinition", "operation": "query", "name": { "kind": "Name", "value": "GetStorageTransactionId" }, "variableDefinitions": [{ "kind": "VariableDefinition", "variable": { "kind": "Variable", "name": { "kind": "Name", "value": "where" } }, "type": { "kind": "NonNullType", "type": { "kind": "NamedType", "name": { "kind": "Name", "value": "AttestationWhereInput" } } } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "alias": { "kind": "Name", "value": "storageTransactionId" }, "name": { "kind": "Name", "value": "attestations" }, "arguments": [{ "kind": "Argument", "name": { "kind": "Name", "value": "where" }, "value": { "kind": "Variable", "name": { "kind": "Name", "value": "where" } } }, { "kind": "Argument", "name": { "kind": "Name", "value": "orderBy" }, "value": { "kind": "ListValue", "values": [{ "kind": "ObjectValue", "fields": [{ "kind": "ObjectField", "name": { "kind": "Name", "value": "timeCreated" }, "value": { "kind": "EnumValue", "value": "desc" } }] }] } }], "selectionSet": { "kind": "SelectionSet", "selections": [{ "kind": "Field", "name": { "kind": "Name", "value": "id" } }, { "kind": "Field", "name": { "kind": "Name", "value": "decodedDataJson" } }] } }] } }] };
|
|
@@ -495,10 +498,11 @@ const GetSchemaUidsDocument = { "kind": "Document", "definitions": [{ "kind": "O
|
|
|
495
498
|
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
|
|
496
499
|
*/
|
|
497
500
|
const documents = {
|
|
498
|
-
"\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n": GetTransactionTagsDocument,
|
|
499
501
|
"\n fragment attestationFields on Attestation {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n txid\n timeCreated\n time\n isOffchain\n }\n": AttestationFieldsFragmentDoc,
|
|
500
502
|
"\n fragment schemaFields on Schema {\n id\n resolver\n revocable\n schema\n index\n schemaNames {\n name\n }\n time\n txid\n creator\n }\n": SchemaFieldsFragmentDoc,
|
|
503
|
+
"\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n": GetTransactionTagsDocument,
|
|
501
504
|
"\n query GetSchemas($where: SchemaWhereInput!) {\n schemas: schemata(where: $where) {\n id\n schema\n schemaNames {\n name\n }\n }\n }\n": GetSchemasDocument,
|
|
505
|
+
"\n query GetSchemaByName($where: SchemaWhereInput!) {\n schemas: schemata(where: $where) {\n id\n schema\n schemaNames {\n name\n }\n }\n }\n": GetSchemaByNameDocument,
|
|
502
506
|
"\n query GetSeeds($where: AttestationWhereInput!) {\n itemSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n timeCreated\n isOffchain\n }\n }\n": GetSeedsDocument,
|
|
503
507
|
"\n query GetSeedIds($where: AttestationWhereInput!) {\n itemSeedIds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n }\n }\n": GetSeedIdsDocument,
|
|
504
508
|
"\n query GetStorageTransactionId($where: AttestationWhereInput!) {\n storageTransactionId: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n id\n decodedDataJson\n }\n }\n": GetStorageTransactionIdDocument,
|
|
@@ -528,7 +532,7 @@ const GET_SCHEMAS = graphql(/* GraphQL */ `
|
|
|
528
532
|
`);
|
|
529
533
|
const GET_SCHEMA_BY_NAME = graphql(/* GraphQL */ `
|
|
530
534
|
query GetSchemaByName($where: SchemaWhereInput!) {
|
|
531
|
-
|
|
535
|
+
schemas: schemata(where: $where) {
|
|
532
536
|
id
|
|
533
537
|
schema
|
|
534
538
|
schemaNames {
|
|
@@ -1225,7 +1229,7 @@ const getEnvironment = () => {
|
|
|
1225
1229
|
return 'node';
|
|
1226
1230
|
};
|
|
1227
1231
|
|
|
1228
|
-
const logger$
|
|
1232
|
+
const logger$p = debug('app:services:global:actors:initialize');
|
|
1229
1233
|
const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
1230
1234
|
const { internalService, models, endpoints, arweaveDomain, addresses, } = context;
|
|
1231
1235
|
if (!internalService) {
|
|
@@ -1244,7 +1248,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
1244
1248
|
const _initInternal = async () => {
|
|
1245
1249
|
return new Promise((resolve) => {
|
|
1246
1250
|
internalSubscription = internalService.subscribe((snapshot) => {
|
|
1247
|
-
logger$
|
|
1251
|
+
logger$p('[sdk] [internal] snapshot', snapshot);
|
|
1248
1252
|
if (snapshot.value === 'ready') {
|
|
1249
1253
|
resolve();
|
|
1250
1254
|
}
|
|
@@ -1289,7 +1293,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
1289
1293
|
await fetchSchemaUids();
|
|
1290
1294
|
};
|
|
1291
1295
|
_initFileSystem().then(() => {
|
|
1292
|
-
logger$
|
|
1296
|
+
logger$p('[global/actors] File system initialized');
|
|
1293
1297
|
});
|
|
1294
1298
|
_initInternal()
|
|
1295
1299
|
.then(() => {
|
|
@@ -1299,7 +1303,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
1299
1303
|
return _initEas();
|
|
1300
1304
|
})
|
|
1301
1305
|
.then(() => {
|
|
1302
|
-
logger$
|
|
1306
|
+
logger$p('[global/actors] Internal initialized');
|
|
1303
1307
|
sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY });
|
|
1304
1308
|
internalSubscription?.unsubscribe();
|
|
1305
1309
|
});
|
|
@@ -1312,7 +1316,7 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
|
1312
1316
|
};
|
|
1313
1317
|
});
|
|
1314
1318
|
|
|
1315
|
-
const logger$
|
|
1319
|
+
const logger$o = debug('app:services:global:actors:getSchemaForModel');
|
|
1316
1320
|
const getSchemaForModel = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
1317
1321
|
const { modelName } = event;
|
|
1318
1322
|
if (!modelName) {
|
|
@@ -1328,12 +1332,12 @@ const getSchemaForModel = fromCallback(({ sendBack, input: { context, event } })
|
|
|
1328
1332
|
if (!model) {
|
|
1329
1333
|
throw new Error(`Model ${modelName} not found`);
|
|
1330
1334
|
}
|
|
1331
|
-
logger$
|
|
1335
|
+
logger$o('[service/actor] [getSchemaForModel] model:', model);
|
|
1332
1336
|
sendBack({ type: 'schemaForModel', schema: model.schema });
|
|
1333
1337
|
return () => { };
|
|
1334
1338
|
});
|
|
1335
1339
|
|
|
1336
|
-
const logger$
|
|
1340
|
+
const logger$n = debug('app:services:global:actors:addModelsToDb');
|
|
1337
1341
|
const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
1338
1342
|
const { models: models$1 } = context;
|
|
1339
1343
|
const _addModelsToDb = async () => {
|
|
@@ -1341,7 +1345,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1341
1345
|
if (!models$1) {
|
|
1342
1346
|
return;
|
|
1343
1347
|
}
|
|
1344
|
-
const { models: SeedModels } = await import('./seed.schema.config-
|
|
1348
|
+
const { models: SeedModels } = await import('./seed.schema.config-BXWvwsZQ.js');
|
|
1345
1349
|
const allModels = {
|
|
1346
1350
|
...SeedModels,
|
|
1347
1351
|
...models$1,
|
|
@@ -1349,7 +1353,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1349
1353
|
let hasModelsInDb = false;
|
|
1350
1354
|
const schemaDefsByModelName = new Map();
|
|
1351
1355
|
for (const [modelName, _] of Object.entries(allModels)) {
|
|
1352
|
-
logger$
|
|
1356
|
+
logger$n('[helpers/db] [addModelsToInternalDb] starting modelName:', modelName);
|
|
1353
1357
|
let foundModel;
|
|
1354
1358
|
const foundModelsQuery = await appDb
|
|
1355
1359
|
.select()
|
|
@@ -1359,7 +1363,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1359
1363
|
await appDb.insert(models).values({
|
|
1360
1364
|
name: modelName,
|
|
1361
1365
|
});
|
|
1362
|
-
logger$
|
|
1366
|
+
logger$n('[global/actors] [addModelsToDb] inserted model:', modelName);
|
|
1363
1367
|
const foundModels = await appDb
|
|
1364
1368
|
.select({
|
|
1365
1369
|
id: models.id,
|
|
@@ -1429,10 +1433,10 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1429
1433
|
return () => { };
|
|
1430
1434
|
});
|
|
1431
1435
|
|
|
1432
|
-
const logger$
|
|
1436
|
+
const logger$m = debug('app:services:db:actors:checkStatus');
|
|
1433
1437
|
const checkStatus = fromCallback(({ sendBack, input: { context } }) => {
|
|
1434
1438
|
const { dbName } = context;
|
|
1435
|
-
logger$
|
|
1439
|
+
logger$m('[db/actors] checkStatus context', context);
|
|
1436
1440
|
const pathToDir = `${BROWSER_FS_TOP_DIR}`;
|
|
1437
1441
|
const pathToDbDir = `${pathToDir}/db`;
|
|
1438
1442
|
const pathToDb = `${pathToDbDir}/${dbName}.sqlite3`;
|
|
@@ -1463,9 +1467,9 @@ const checkStatus = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1463
1467
|
});
|
|
1464
1468
|
});
|
|
1465
1469
|
|
|
1466
|
-
const logger$
|
|
1470
|
+
const logger$l = debug('app:services:db:actors:connectToDb');
|
|
1467
1471
|
const connectToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
1468
|
-
logger$
|
|
1472
|
+
logger$l('[db/actors] connectToDb context', context);
|
|
1469
1473
|
const { dbName, pathToDir } = context;
|
|
1470
1474
|
if (!pathToDir || !dbName) {
|
|
1471
1475
|
throw new Error('pathToDir and dbName are required');
|
|
@@ -1509,12 +1513,16 @@ const validate = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1509
1513
|
}
|
|
1510
1514
|
return exists;
|
|
1511
1515
|
};
|
|
1512
|
-
_validate().then(() => {
|
|
1513
|
-
|
|
1514
|
-
|
|
1516
|
+
_validate().then((allFilesExist) => {
|
|
1517
|
+
if (allFilesExist) {
|
|
1518
|
+
sendBack({ type: DB_VALIDATING_SUCCESS, pathToDb, pathToDir });
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
sendBack({ type: DB_VALIDATING_WAIT });
|
|
1515
1522
|
});
|
|
1516
1523
|
});
|
|
1517
1524
|
|
|
1525
|
+
const logger$k = debug('app:helpers:files');
|
|
1518
1526
|
/**
|
|
1519
1527
|
* Waits for a file to exist at the specified path.
|
|
1520
1528
|
* @param {string} filePath - The path of the file to check.
|
|
@@ -1522,10 +1530,16 @@ const validate = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1522
1530
|
* @param {number} timeout - The timeout in milliseconds to wait for the file to exist (default: 10s).
|
|
1523
1531
|
* @returns {Promise<boolean>} - Resolves to true if the file exists within the timeout period, otherwise false.
|
|
1524
1532
|
*/
|
|
1525
|
-
const waitForFile = (filePath, interval =
|
|
1533
|
+
const waitForFile = (filePath, interval = 1000, timeout = 60000) => {
|
|
1526
1534
|
return new Promise((resolve, reject) => {
|
|
1527
1535
|
const startTime = Date.now();
|
|
1528
|
-
|
|
1536
|
+
let isBusy = false;
|
|
1537
|
+
const _interval = setInterval(async () => {
|
|
1538
|
+
logger$k('waitForFile', filePath);
|
|
1539
|
+
if (isBusy) {
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1542
|
+
isBusy = true;
|
|
1529
1543
|
if (fs.existsSync(filePath) && fsNode.existsSync(filePath)) {
|
|
1530
1544
|
clearInterval(_interval);
|
|
1531
1545
|
resolve(true);
|
|
@@ -1534,6 +1548,7 @@ const waitForFile = (filePath, interval = 500, timeout = 10000) => {
|
|
|
1534
1548
|
clearInterval(_interval);
|
|
1535
1549
|
reject(new Error('Timeout exceeded while waiting for file'));
|
|
1536
1550
|
}
|
|
1551
|
+
isBusy = false;
|
|
1537
1552
|
}, interval);
|
|
1538
1553
|
// retry(
|
|
1539
1554
|
// {
|
|
@@ -1559,38 +1574,16 @@ const waitForFile = (filePath, interval = 500, timeout = 10000) => {
|
|
|
1559
1574
|
});
|
|
1560
1575
|
};
|
|
1561
1576
|
|
|
1562
|
-
const logger$
|
|
1577
|
+
const logger$j = debug('app:services:db:actors:migrate');
|
|
1563
1578
|
const migrate = fromCallback(({ sendBack, input: { context } }) => {
|
|
1564
1579
|
const { pathToDbDir, dbId, dbName } = context;
|
|
1565
|
-
logger$
|
|
1580
|
+
logger$j('[db/actors] migrate context', context);
|
|
1566
1581
|
let journalExists = false;
|
|
1567
|
-
// const _initFs = async (): Promise<void> => {
|
|
1568
|
-
// const handle = await navigator.storage.getDirectory()
|
|
1569
|
-
// // await configure({ backend: WebAccess, handle })
|
|
1570
|
-
// await configureSingle({
|
|
1571
|
-
// backend: WebAccess,
|
|
1572
|
-
// handle,
|
|
1573
|
-
// })
|
|
1574
|
-
// }
|
|
1575
|
-
//
|
|
1576
|
-
// _initFs()
|
|
1577
1582
|
const _checkForFiles = async () => {
|
|
1578
1583
|
const journalPath = `/${pathToDbDir}/meta/_journal.json`;
|
|
1579
|
-
journalExists = await fs
|
|
1584
|
+
journalExists = await fs.promises.exists(journalPath);
|
|
1580
1585
|
if (!journalExists) {
|
|
1581
|
-
await waitForFile(journalPath);
|
|
1582
|
-
// const handle = await navigator.storage.getDirectory()
|
|
1583
|
-
//
|
|
1584
|
-
// await configureSingle({
|
|
1585
|
-
// backend: WebAccess,
|
|
1586
|
-
// handle,
|
|
1587
|
-
// })
|
|
1588
|
-
// window.location.reload()
|
|
1589
|
-
// setTimeout(() => {
|
|
1590
|
-
// _checkForFiles().then(() => {
|
|
1591
|
-
// return
|
|
1592
|
-
// })
|
|
1593
|
-
// }, 500)
|
|
1586
|
+
await waitForFile(journalPath, 500, 60000);
|
|
1594
1587
|
}
|
|
1595
1588
|
};
|
|
1596
1589
|
const _migrate = async () => {
|
|
@@ -1608,7 +1601,27 @@ const migrate = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1608
1601
|
return () => { };
|
|
1609
1602
|
});
|
|
1610
1603
|
|
|
1611
|
-
|
|
1604
|
+
debug('app:services:db:actors:waitForFiles');
|
|
1605
|
+
const waitForFiles$1 = fromCallback(({ sendBack, input: { context } }) => {
|
|
1606
|
+
const { pathToDbDir } = context;
|
|
1607
|
+
const _waitForFiles = async () => {
|
|
1608
|
+
return new Promise((resolve) => {
|
|
1609
|
+
const interval = setInterval(async () => {
|
|
1610
|
+
const journalExists = await fs.promises.exists(`${pathToDbDir}/meta/_journal.json`);
|
|
1611
|
+
if (journalExists) {
|
|
1612
|
+
clearInterval(interval);
|
|
1613
|
+
resolve();
|
|
1614
|
+
}
|
|
1615
|
+
}, 1000);
|
|
1616
|
+
});
|
|
1617
|
+
};
|
|
1618
|
+
_waitForFiles().then(() => {
|
|
1619
|
+
sendBack({ type: DB_WAITING_FOR_FILES_RECEIVED });
|
|
1620
|
+
return;
|
|
1621
|
+
});
|
|
1622
|
+
});
|
|
1623
|
+
|
|
1624
|
+
const logger$i = debug('app:services:db:machine');
|
|
1612
1625
|
const { CHECKING_STATUS, VALIDATING, WAITING_FOR_FILES, CONNECTING_TO_DB, MIGRATING, } = DbState;
|
|
1613
1626
|
const dbMachine = setup({
|
|
1614
1627
|
types: {
|
|
@@ -1620,6 +1633,7 @@ const dbMachine = setup({
|
|
|
1620
1633
|
validate,
|
|
1621
1634
|
connectToDb,
|
|
1622
1635
|
migrate,
|
|
1636
|
+
waitForFiles: waitForFiles$1,
|
|
1623
1637
|
},
|
|
1624
1638
|
}).createMachine({
|
|
1625
1639
|
id: MachineIds.DB,
|
|
@@ -1629,7 +1643,7 @@ const dbMachine = setup({
|
|
|
1629
1643
|
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
1630
1644
|
actions: assign({
|
|
1631
1645
|
hasFiles: ({ event }) => {
|
|
1632
|
-
logger$
|
|
1646
|
+
logger$i('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event);
|
|
1633
1647
|
return true;
|
|
1634
1648
|
},
|
|
1635
1649
|
}),
|
|
@@ -1638,8 +1652,8 @@ const dbMachine = setup({
|
|
|
1638
1652
|
target: `.${CHECKING_STATUS}`,
|
|
1639
1653
|
actions: assign({
|
|
1640
1654
|
hasFiles: ({ context, event }) => {
|
|
1641
|
-
logger$
|
|
1642
|
-
logger$
|
|
1655
|
+
logger$i('[db/machine] updateHasFiles event:', event);
|
|
1656
|
+
logger$i('[db/machine] updateHasFiles context:', context);
|
|
1643
1657
|
return event.hasFiles;
|
|
1644
1658
|
},
|
|
1645
1659
|
}),
|
|
@@ -1728,6 +1742,10 @@ const dbMachine = setup({
|
|
|
1728
1742
|
},
|
|
1729
1743
|
[DB_MIGRATING_SUCCESS]: 'ready',
|
|
1730
1744
|
},
|
|
1745
|
+
invoke: {
|
|
1746
|
+
src: 'waitForFiles',
|
|
1747
|
+
input: ({ context }) => ({ context }),
|
|
1748
|
+
},
|
|
1731
1749
|
},
|
|
1732
1750
|
[MIGRATING]: {
|
|
1733
1751
|
on: {
|
|
@@ -1802,7 +1820,7 @@ const prepareDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1802
1820
|
});
|
|
1803
1821
|
});
|
|
1804
1822
|
|
|
1805
|
-
const logger$
|
|
1823
|
+
const logger$h = debug('app:services:internal:helpers');
|
|
1806
1824
|
/**
|
|
1807
1825
|
* Recursively create directories if they don't exist.
|
|
1808
1826
|
* @param {string} dirPath - The directory path to create.
|
|
@@ -1813,11 +1831,22 @@ const createDirectories = async (dirPath) => {
|
|
|
1813
1831
|
return;
|
|
1814
1832
|
}
|
|
1815
1833
|
const parentDir = path.dirname(dirPath);
|
|
1816
|
-
|
|
1834
|
+
let parentDirExists = await fs.promises.exists(parentDir);
|
|
1817
1835
|
if (!parentDirExists) {
|
|
1818
1836
|
await createDirectories(parentDir);
|
|
1819
1837
|
}
|
|
1820
|
-
await fs.promises.
|
|
1838
|
+
parentDirExists = await fs.promises.exists(parentDir);
|
|
1839
|
+
if (parentDirExists) {
|
|
1840
|
+
try {
|
|
1841
|
+
await fs.promises.mkdir(dirPath);
|
|
1842
|
+
}
|
|
1843
|
+
catch (error) {
|
|
1844
|
+
logger$h(`[Error] Failed to create directories for ${dirPath}:`, error);
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
if (!parentDirExists) {
|
|
1848
|
+
console.log(fs);
|
|
1849
|
+
}
|
|
1821
1850
|
};
|
|
1822
1851
|
let busy = false;
|
|
1823
1852
|
const downloadFile = async (url, localFilePath) => {
|
|
@@ -1861,10 +1890,17 @@ const downloadFile = async (url, localFilePath) => {
|
|
|
1861
1890
|
}
|
|
1862
1891
|
}
|
|
1863
1892
|
}
|
|
1864
|
-
|
|
1893
|
+
try {
|
|
1894
|
+
await fs.promises.writeFile(localFilePath, fileData);
|
|
1895
|
+
logger$h(`[downloadFile] Wrote file async to ${localFilePath}`);
|
|
1896
|
+
}
|
|
1897
|
+
catch (error) {
|
|
1898
|
+
fs.writeFileSync(localFilePath, fileData);
|
|
1899
|
+
logger$h(`[downloadFile] Wrote file sync to ${localFilePath}`);
|
|
1900
|
+
}
|
|
1865
1901
|
}
|
|
1866
1902
|
catch (error) {
|
|
1867
|
-
logger$
|
|
1903
|
+
logger$h(`[Error] Failed to download file from ${url}:`, error);
|
|
1868
1904
|
}
|
|
1869
1905
|
busy = false;
|
|
1870
1906
|
};
|
|
@@ -1904,7 +1940,7 @@ const syncDbFiles = async ({ filePaths, files }) => {
|
|
|
1904
1940
|
fileList = fileList.filter((file) => !filesToExclude.includes(file));
|
|
1905
1941
|
await fetchFilesRecursively(files, BROWSER_FS_TOP_DIR, fileList);
|
|
1906
1942
|
await confirmFilesExist(fileList);
|
|
1907
|
-
logger$
|
|
1943
|
+
logger$h('[syncDbFiles] Files synced!');
|
|
1908
1944
|
};
|
|
1909
1945
|
|
|
1910
1946
|
const GET_FILES_METADATA = graphql(/* GraphQL */ `
|
|
@@ -2013,10 +2049,10 @@ const saveAppState = async (key, value) => {
|
|
|
2013
2049
|
|
|
2014
2050
|
const initArweaveClient = async () => {
|
|
2015
2051
|
if (isBrowser()) {
|
|
2016
|
-
(await import('./ArweaveClient-
|
|
2052
|
+
(await import('./ArweaveClient-DQrXvrNN.js')).ArweaveClient;
|
|
2017
2053
|
}
|
|
2018
2054
|
if (!isBrowser()) {
|
|
2019
|
-
(await import('./ArweaveClient-
|
|
2055
|
+
(await import('./ArweaveClient-CoFomTCN.js')).ArweaveClient;
|
|
2020
2056
|
}
|
|
2021
2057
|
};
|
|
2022
2058
|
let domain = 'arweave.net';
|
|
@@ -2059,7 +2095,7 @@ const setArweaveDomain = (newDomain) => {
|
|
|
2059
2095
|
domain = newDomain;
|
|
2060
2096
|
};
|
|
2061
2097
|
|
|
2062
|
-
const logger$
|
|
2098
|
+
const logger$g = debug('app:files:download');
|
|
2063
2099
|
const downloadAllFilesRequestHandler = async ({ endpoints, eventId, }) => {
|
|
2064
2100
|
await syncDbFiles(endpoints);
|
|
2065
2101
|
eventEmitter.emit('fs.downloadAll.success', { eventId });
|
|
@@ -2074,7 +2110,9 @@ const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
2074
2110
|
const globalService = getGlobalService();
|
|
2075
2111
|
const internalService = globalService.getSnapshot().context.internalService;
|
|
2076
2112
|
if (internalService) {
|
|
2077
|
-
await waitFor(internalService, (snapshot) =>
|
|
2113
|
+
await waitFor(internalService, (snapshot) => {
|
|
2114
|
+
return snapshot.value === 'ready';
|
|
2115
|
+
});
|
|
2078
2116
|
addresses = await getAddressesFromDb();
|
|
2079
2117
|
}
|
|
2080
2118
|
}
|
|
@@ -2149,7 +2187,7 @@ const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
2149
2187
|
try {
|
|
2150
2188
|
const res = await fetch(`https://${ARWEAVE_HOST}/tx/${transactionId}/status`);
|
|
2151
2189
|
if (res.status !== 200) {
|
|
2152
|
-
logger$
|
|
2190
|
+
logger$g(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`);
|
|
2153
2191
|
excludedTransactions.add(transactionId);
|
|
2154
2192
|
await saveAppState('excludedTransactions', JSON.stringify(Array.from(excludedTransactions)));
|
|
2155
2193
|
continue;
|
|
@@ -2178,7 +2216,7 @@ const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
2178
2216
|
transactionIdsToDownload.push(transactionId);
|
|
2179
2217
|
}
|
|
2180
2218
|
catch (error) {
|
|
2181
|
-
logger$
|
|
2219
|
+
logger$g(error);
|
|
2182
2220
|
}
|
|
2183
2221
|
}
|
|
2184
2222
|
console.log('[download] Calling downloadAllFiles with transactionIdsToDownload', transactionIdsToDownload);
|
|
@@ -2229,14 +2267,14 @@ const isFsInitialized = () => {
|
|
|
2229
2267
|
return isInitialized;
|
|
2230
2268
|
};
|
|
2231
2269
|
|
|
2232
|
-
const logger$
|
|
2270
|
+
const logger$f = debug('app:internal:actors:configureFs');
|
|
2233
2271
|
const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
2234
2272
|
const { endpoints, appDbService, filesDir, } = context;
|
|
2235
|
-
logger$
|
|
2273
|
+
logger$f('[internal/actors] [configureFs] Configuring FS');
|
|
2236
2274
|
const _configureFs = async () => {
|
|
2237
|
-
logger$
|
|
2238
|
-
logger$
|
|
2239
|
-
logger$
|
|
2275
|
+
logger$f('[internal/actors] [configureFs] calling _configureFs');
|
|
2276
|
+
logger$f('[internal/actors] [configureFs] areFsListenersReady:', areFsListenersReady());
|
|
2277
|
+
logger$f('[internal/actors] [configureFs] isFsInitialized:', isFsInitialized());
|
|
2240
2278
|
await waitForEvent({
|
|
2241
2279
|
req: {
|
|
2242
2280
|
eventLabel: 'fs.downloadAll.request',
|
|
@@ -2247,10 +2285,17 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2247
2285
|
},
|
|
2248
2286
|
});
|
|
2249
2287
|
const journalPath = `${filesDir || BROWSER_FS_TOP_DIR}/db/meta/_journal.json`;
|
|
2250
|
-
|
|
2288
|
+
let journalExists = await fs.promises.exists(journalPath);
|
|
2289
|
+
if (!journalExists) {
|
|
2290
|
+
journalExists = fs.existsSync(journalPath);
|
|
2291
|
+
}
|
|
2251
2292
|
if (journalExists) {
|
|
2252
2293
|
appDbService.send({ type: DB_WAITING_FOR_FILES_RECEIVED });
|
|
2294
|
+
logger$f('[internal/actors] [configureFs] fs configured!');
|
|
2295
|
+
return true;
|
|
2253
2296
|
}
|
|
2297
|
+
sendBack({ type: 'shouldWaitForFiles' });
|
|
2298
|
+
return false;
|
|
2254
2299
|
// return new Promise<void>((resolve) => {
|
|
2255
2300
|
// const interval = setInterval(() => {
|
|
2256
2301
|
// journalExistsSync = fs.existsSync(journalPath)
|
|
@@ -2265,20 +2310,21 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2265
2310
|
// }
|
|
2266
2311
|
// }, 200)
|
|
2267
2312
|
// })
|
|
2268
|
-
logger$e('[internal/actors] [configureFs] fs configured!');
|
|
2269
2313
|
};
|
|
2270
2314
|
// Some of our dependencies use fs sync functions, which don't work with
|
|
2271
2315
|
// OPFS. ZenFS creates an async cache of all files so that the sync functions
|
|
2272
2316
|
// work, but we have to wait for it to be built. Otherwise things like
|
|
2273
2317
|
// drizzleMigrate will fail since they can't see the migration files yet.
|
|
2274
|
-
_configureFs().then(() => {
|
|
2275
|
-
|
|
2318
|
+
_configureFs().then((fsConfigured) => {
|
|
2319
|
+
if (fsConfigured) {
|
|
2320
|
+
sendBack({ type: INTERNAL_CONFIGURING_FS_SUCCESS });
|
|
2321
|
+
}
|
|
2276
2322
|
return;
|
|
2277
2323
|
});
|
|
2278
2324
|
return () => { };
|
|
2279
2325
|
});
|
|
2280
2326
|
|
|
2281
|
-
const logger$
|
|
2327
|
+
const logger$e = debug('app:services:internal:actors:saveConfig');
|
|
2282
2328
|
const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
2283
2329
|
if (typeof window === 'undefined') {
|
|
2284
2330
|
console.error('seedInitBrowser called from non-browser context');
|
|
@@ -2339,20 +2385,20 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2339
2385
|
value: arweaveDomain || 'arweave.net',
|
|
2340
2386
|
},
|
|
2341
2387
|
});
|
|
2342
|
-
logger$
|
|
2388
|
+
logger$e('[sdk] [internal/actors] Should be done saving');
|
|
2343
2389
|
}
|
|
2344
2390
|
catch (error) {
|
|
2345
2391
|
console.error('Error saving config:', error);
|
|
2346
2392
|
}
|
|
2347
2393
|
};
|
|
2348
2394
|
_saveConfig().then(() => {
|
|
2349
|
-
logger$
|
|
2395
|
+
logger$e('[sdk] [internal/actors] Successfully saved config');
|
|
2350
2396
|
return sendBack({ type: INTERNAL_SAVING_CONFIG_SUCCESS });
|
|
2351
2397
|
});
|
|
2352
2398
|
return () => { };
|
|
2353
2399
|
});
|
|
2354
2400
|
|
|
2355
|
-
const logger$
|
|
2401
|
+
const logger$d = debug('app:services:internal:actors:loadAppDb');
|
|
2356
2402
|
const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
2357
2403
|
const { appDbService } = context;
|
|
2358
2404
|
let subscription;
|
|
@@ -2373,7 +2419,7 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2373
2419
|
};
|
|
2374
2420
|
_loadAppDb().then(() => {
|
|
2375
2421
|
sendBack({ type: INTERNAL_LOADING_APP_DB_SUCCESS });
|
|
2376
|
-
logger$
|
|
2422
|
+
logger$d('[sdk] [internal/actors] Successfully loaded app DB');
|
|
2377
2423
|
});
|
|
2378
2424
|
return () => {
|
|
2379
2425
|
if (subscription) {
|
|
@@ -2382,7 +2428,28 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2382
2428
|
};
|
|
2383
2429
|
});
|
|
2384
2430
|
|
|
2385
|
-
|
|
2431
|
+
debug('app:services:internal:actors:waitForFiles');
|
|
2432
|
+
const waitForFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
2433
|
+
const { endpoints } = context;
|
|
2434
|
+
const filesDir = endpoints.files;
|
|
2435
|
+
const _waitForFiles = async () => {
|
|
2436
|
+
return new Promise((resolve) => {
|
|
2437
|
+
const interval = setInterval(async () => {
|
|
2438
|
+
const journalExists = await fs.promises.exists(`${filesDir}/db/meta/_journal.json`);
|
|
2439
|
+
if (journalExists) {
|
|
2440
|
+
clearInterval(interval);
|
|
2441
|
+
resolve();
|
|
2442
|
+
}
|
|
2443
|
+
}, 1000);
|
|
2444
|
+
});
|
|
2445
|
+
};
|
|
2446
|
+
_waitForFiles().then(() => {
|
|
2447
|
+
sendBack({ type: 'filesReceived' });
|
|
2448
|
+
return;
|
|
2449
|
+
});
|
|
2450
|
+
});
|
|
2451
|
+
|
|
2452
|
+
const logger$c = debug('app:services:internal:machine');
|
|
2386
2453
|
createBrowserInspector({
|
|
2387
2454
|
autoStart: false,
|
|
2388
2455
|
});
|
|
@@ -2396,6 +2463,7 @@ const internalMachine = setup({
|
|
|
2396
2463
|
actors: {
|
|
2397
2464
|
prepareDb,
|
|
2398
2465
|
validateInput,
|
|
2466
|
+
waitForFiles,
|
|
2399
2467
|
configureFs,
|
|
2400
2468
|
loadAppDb,
|
|
2401
2469
|
saveConfig,
|
|
@@ -2465,12 +2533,26 @@ const internalMachine = setup({
|
|
|
2465
2533
|
input: ({ context, event }) => ({ context, event }),
|
|
2466
2534
|
},
|
|
2467
2535
|
},
|
|
2536
|
+
waitingForFiles: {
|
|
2537
|
+
on: {
|
|
2538
|
+
filesReceived: {
|
|
2539
|
+
target: LOADING_APP_DB,
|
|
2540
|
+
},
|
|
2541
|
+
},
|
|
2542
|
+
invoke: {
|
|
2543
|
+
src: 'waitForFiles',
|
|
2544
|
+
input: ({ context, event }) => ({ context, event }),
|
|
2545
|
+
},
|
|
2546
|
+
},
|
|
2468
2547
|
[CONFIGURING_FS]: {
|
|
2469
2548
|
on: {
|
|
2470
2549
|
[INTERNAL_CONFIGURING_FS_SUCCESS]: {
|
|
2471
2550
|
target: LOADING_APP_DB,
|
|
2472
2551
|
actions: assign({ hasFiles: true }),
|
|
2473
2552
|
},
|
|
2553
|
+
shouldWaitForFiles: {
|
|
2554
|
+
target: 'waitingForFiles',
|
|
2555
|
+
},
|
|
2474
2556
|
},
|
|
2475
2557
|
invoke: {
|
|
2476
2558
|
src: 'configureFs',
|
|
@@ -2487,7 +2569,7 @@ const internalMachine = setup({
|
|
|
2487
2569
|
[INTERNAL_LOADING_APP_DB_SUCCESS]: {
|
|
2488
2570
|
target: SAVING_CONFIG,
|
|
2489
2571
|
actions: () => {
|
|
2490
|
-
logger$
|
|
2572
|
+
logger$c('[sdk] [internal/index] App DB loaded!');
|
|
2491
2573
|
},
|
|
2492
2574
|
},
|
|
2493
2575
|
},
|
|
@@ -2513,7 +2595,7 @@ const internalMachine = setup({
|
|
|
2513
2595
|
},
|
|
2514
2596
|
ready: {
|
|
2515
2597
|
entry: () => {
|
|
2516
|
-
logger$
|
|
2598
|
+
logger$c('[sdk] [internal/index] Ready!');
|
|
2517
2599
|
},
|
|
2518
2600
|
meta: {
|
|
2519
2601
|
displayText: "Crossing the t's ...",
|
|
@@ -2528,7 +2610,7 @@ const internalMachine = setup({
|
|
|
2528
2610
|
},
|
|
2529
2611
|
},
|
|
2530
2612
|
entry: () => {
|
|
2531
|
-
logger$
|
|
2613
|
+
logger$c('[sdk] [internal/index] Error!');
|
|
2532
2614
|
},
|
|
2533
2615
|
meta: {
|
|
2534
2616
|
displayText: 'Whoops! Something went wrong.',
|
|
@@ -2705,7 +2787,7 @@ const fetchDbData = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2705
2787
|
return () => { };
|
|
2706
2788
|
});
|
|
2707
2789
|
|
|
2708
|
-
const logger$
|
|
2790
|
+
const logger$b = debug('app:allItemsActors:fetchSeeds');
|
|
2709
2791
|
const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
|
|
2710
2792
|
const { queryVariables, modelName } = context;
|
|
2711
2793
|
if (!queryVariables) {
|
|
@@ -2717,7 +2799,7 @@ const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2717
2799
|
const queryClient = BaseQueryClient.getQueryClient();
|
|
2718
2800
|
const easClient = BaseEasClient.getEasClient();
|
|
2719
2801
|
const cachedResults = queryClient.getQueryData(queryKey);
|
|
2720
|
-
logger$
|
|
2802
|
+
logger$b(`[allItemsActors] [fetchSeeds] cachedResults ${Date.now()}`, cachedResults);
|
|
2721
2803
|
const results = await queryClient.fetchQuery({
|
|
2722
2804
|
queryKey,
|
|
2723
2805
|
queryFn: async () => easClient.request(GET_SEEDS, queryVariables),
|
|
@@ -3166,13 +3248,13 @@ const preparePublishRequestData = fromCallback(({ sendBack, input: { context } }
|
|
|
3166
3248
|
});
|
|
3167
3249
|
});
|
|
3168
3250
|
|
|
3169
|
-
const logger$
|
|
3251
|
+
const logger$a = debug('app:services:publish:actors:upload');
|
|
3170
3252
|
const upload = fromCallback(({ sendBack, input: { context } }) => {
|
|
3171
3253
|
const { localId } = context;
|
|
3172
3254
|
const _upload = async () => {
|
|
3173
3255
|
const item = await BaseItem.find({ seedLocalId: localId });
|
|
3174
3256
|
if (!item) {
|
|
3175
|
-
logger$
|
|
3257
|
+
logger$a('no item with localId', localId);
|
|
3176
3258
|
return false;
|
|
3177
3259
|
}
|
|
3178
3260
|
const editedProperties = await item.getEditedProperties();
|
|
@@ -4009,6 +4091,30 @@ const itemMachineSingle = setup({
|
|
|
4009
4091
|
},
|
|
4010
4092
|
});
|
|
4011
4093
|
|
|
4094
|
+
const getMetadataLatest = ({ seedLocalId, seedUid }) => {
|
|
4095
|
+
const appDb = BaseDb.getAppDb();
|
|
4096
|
+
const whereClauses = [];
|
|
4097
|
+
if (seedLocalId) {
|
|
4098
|
+
whereClauses.push(eq(metadata.seedLocalId, seedLocalId));
|
|
4099
|
+
}
|
|
4100
|
+
if (seedUid) {
|
|
4101
|
+
whereClauses.push(eq(metadata.seedUid, seedUid));
|
|
4102
|
+
}
|
|
4103
|
+
const metadataColumns = getTableColumns(metadata);
|
|
4104
|
+
return appDb.$with('metadataLatest').as(appDb
|
|
4105
|
+
.select({
|
|
4106
|
+
...metadataColumns,
|
|
4107
|
+
rowNum: sql.raw(`
|
|
4108
|
+
ROW_NUMBER() OVER (
|
|
4109
|
+
PARTITION BY property_name
|
|
4110
|
+
ORDER BY COALESCE(created_at, attestation_created_at) DESC
|
|
4111
|
+
)
|
|
4112
|
+
`).as('rowNum')
|
|
4113
|
+
})
|
|
4114
|
+
.from(metadata)
|
|
4115
|
+
.where(and(...whereClauses)));
|
|
4116
|
+
};
|
|
4117
|
+
|
|
4012
4118
|
const getItemProperties = async ({ seedLocalId, seedUid, edited, }) => {
|
|
4013
4119
|
const appDb = BaseDb.getAppDb();
|
|
4014
4120
|
const whereClauses = [isNotNull(metadata.propertyName)];
|
|
@@ -4018,15 +4124,7 @@ const getItemProperties = async ({ seedLocalId, seedUid, edited, }) => {
|
|
|
4018
4124
|
if (seedLocalId) {
|
|
4019
4125
|
whereClauses.push(eq(seeds.localId, seedLocalId));
|
|
4020
4126
|
}
|
|
4021
|
-
// const uidWhereClause: SQL = seedUid
|
|
4022
|
-
// ? eq(seeds.uid, seedUid)
|
|
4023
|
-
// : isNull(seeds.uid)
|
|
4024
|
-
// const localWhereClause: SQL = seedLocalId
|
|
4025
|
-
// ? eq(seeds.localId, seedLocalId)
|
|
4026
|
-
// : isNull(seeds.localId)
|
|
4027
|
-
// whereClauses.push(or(localWhereClause, uidWhereClause) as SQL)
|
|
4028
4127
|
whereClauses.push(isNotNull(metadata.propertyName));
|
|
4029
|
-
// whereClauses.push(isNotNull(metadata.easDataType))
|
|
4030
4128
|
if (typeof edited !== 'undefined') {
|
|
4031
4129
|
if (edited) {
|
|
4032
4130
|
whereClauses.push(isNull(metadata.uid));
|
|
@@ -4035,16 +4133,13 @@ const getItemProperties = async ({ seedLocalId, seedUid, edited, }) => {
|
|
|
4035
4133
|
whereClauses.push(isNotNull(metadata.uid));
|
|
4036
4134
|
}
|
|
4037
4135
|
}
|
|
4038
|
-
const metadataColumns = getTableColumns(metadata)
|
|
4136
|
+
// const metadataColumns = getTableColumns(metadata)
|
|
4137
|
+
const metadataLatest = getMetadataLatest({ seedLocalId, seedUid });
|
|
4039
4138
|
const propertiesData = await appDb
|
|
4040
|
-
.
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
.
|
|
4044
|
-
.leftJoin(metadata, eq(metadata.seedLocalId, seeds.localId))
|
|
4045
|
-
.leftJoin(versions, eq(versions.localId, seeds.localId))
|
|
4046
|
-
.where(and(...whereClauses))
|
|
4047
|
-
.groupBy(metadata.propertyName);
|
|
4139
|
+
.with(metadataLatest)
|
|
4140
|
+
.select()
|
|
4141
|
+
.from(metadataLatest)
|
|
4142
|
+
.where(eq(metadataLatest.rowNum, 1));
|
|
4048
4143
|
return propertiesData.map(data => ({
|
|
4049
4144
|
...data,
|
|
4050
4145
|
localId: data.localId || '',
|
|
@@ -4090,7 +4185,7 @@ const getSeedData = async ({ seedLocalId, seedUid }) => {
|
|
|
4090
4185
|
return rows[0];
|
|
4091
4186
|
};
|
|
4092
4187
|
|
|
4093
|
-
const logger$
|
|
4188
|
+
const logger$9 = debug('app:db:read:getItemData');
|
|
4094
4189
|
const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
4095
4190
|
if (!seedLocalId && !seedUid) {
|
|
4096
4191
|
throw new Error('[db/queries] [getItem] no seedLocalId or seedUid');
|
|
@@ -4098,7 +4193,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
4098
4193
|
if (seedUid && !seedLocalId) {
|
|
4099
4194
|
const seedData = await getSeedData({ seedUid });
|
|
4100
4195
|
if (!seedData) {
|
|
4101
|
-
logger$
|
|
4196
|
+
logger$9('[db/queries] [getItem] no seedData seedUid', seedUid);
|
|
4102
4197
|
return;
|
|
4103
4198
|
}
|
|
4104
4199
|
seedLocalId = seedData.localId;
|
|
@@ -4133,7 +4228,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
4133
4228
|
.orderBy(sql.raw('COALESCE(attestation_created_at, created_at) DESC'))
|
|
4134
4229
|
.groupBy(seeds.localId);
|
|
4135
4230
|
if (!itemDataRows || itemDataRows.length === 0) {
|
|
4136
|
-
logger$
|
|
4231
|
+
logger$9('[db/queries] [getItemDataFromDb] no itemDataRows');
|
|
4137
4232
|
return;
|
|
4138
4233
|
}
|
|
4139
4234
|
let itemData = itemDataRows[0];
|
|
@@ -4252,6 +4347,7 @@ const resolveRemoteStorage = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
4252
4347
|
});
|
|
4253
4348
|
});
|
|
4254
4349
|
|
|
4350
|
+
debug('app:ItemProperty:service:actors:waitForDb');
|
|
4255
4351
|
const waitForDb = fromCallback(({ sendBack }) => {
|
|
4256
4352
|
const _waitForDb = new Promise((resolve) => {
|
|
4257
4353
|
const interval = setInterval(() => {
|
|
@@ -4361,7 +4457,7 @@ const getRelationValueData = async (propertyValue) => {
|
|
|
4361
4457
|
return rows[0];
|
|
4362
4458
|
};
|
|
4363
4459
|
|
|
4364
|
-
const logger$
|
|
4460
|
+
const logger$8 = debug('app:property:actors:resolveRelatedValue');
|
|
4365
4461
|
const storageTransactionIdToContentUrl = new Map();
|
|
4366
4462
|
const refResolvedValueToContentUrl = new Map();
|
|
4367
4463
|
const seedUidToContentUrl = new Map();
|
|
@@ -4376,7 +4472,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4376
4472
|
parsedValue = JSON.parse(propertyValue);
|
|
4377
4473
|
}
|
|
4378
4474
|
catch (error) {
|
|
4379
|
-
logger$
|
|
4475
|
+
logger$8(`${propertyName} value is not a JSON string.`);
|
|
4380
4476
|
}
|
|
4381
4477
|
if (!parsedValue && seedUidToContentUrl.has(propertyValue)) {
|
|
4382
4478
|
const contentUrl = seedUidToContentUrl.get(propertyValue);
|
|
@@ -4392,11 +4488,11 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4392
4488
|
}
|
|
4393
4489
|
if (Array.isArray(propertyValue)) {
|
|
4394
4490
|
// TODO: Handle array of seedUids
|
|
4395
|
-
logger$
|
|
4491
|
+
logger$8(`${propertyName} value is an array of seedUids`);
|
|
4396
4492
|
return;
|
|
4397
4493
|
}
|
|
4398
4494
|
if (Array.isArray(parsedValue)) {
|
|
4399
|
-
logger$
|
|
4495
|
+
logger$8(`${propertyName} value is a stringified array of seedUids`);
|
|
4400
4496
|
return;
|
|
4401
4497
|
}
|
|
4402
4498
|
const storageTransactionId = await getStorageTransactionIdForSeedUid(propertyValue);
|
|
@@ -4775,7 +4871,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4775
4871
|
propertyValue: metadata.propertyValue,
|
|
4776
4872
|
})
|
|
4777
4873
|
.from(metadata)
|
|
4778
|
-
.where(and(eq(metadata.seedUid, propertyValueFromDb), eq(metadata.propertyName, 'storageTransactionId')));
|
|
4874
|
+
.where(and(eq(metadata.seedUid, propertyValueFromDb), or(eq(metadata.propertyName, 'storageTransactionId'), eq(metadata.propertyName, 'transactionId'))));
|
|
4779
4875
|
if (storageTransactionQuery && storageTransactionQuery.length > 0) {
|
|
4780
4876
|
const row = storageTransactionQuery[0];
|
|
4781
4877
|
refResolvedValue = row.propertyValue;
|
|
@@ -4836,7 +4932,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4836
4932
|
if (propertyRecordSchema &&
|
|
4837
4933
|
propertyRecordSchema.storageType &&
|
|
4838
4934
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
4839
|
-
const { Item } = await import('./index-
|
|
4935
|
+
const { Item } = await import('./index-CPxn1SR4.js');
|
|
4840
4936
|
const item = await Item.find({
|
|
4841
4937
|
seedLocalId,
|
|
4842
4938
|
modelName,
|
|
@@ -4881,16 +4977,10 @@ const getVersionData = async ({ localId, seedLocalId, uid, }) => {
|
|
|
4881
4977
|
return queryRows[0];
|
|
4882
4978
|
};
|
|
4883
4979
|
|
|
4884
|
-
const logger$
|
|
4885
|
-
const sendItemUpdateEvent = ({ modelName, seedLocalId, seedUid }) => {
|
|
4886
|
-
if (!modelName || (!seedLocalId && !seedUid)) {
|
|
4887
|
-
return;
|
|
4888
|
-
}
|
|
4889
|
-
eventEmitter.emit(`item.${modelName}.${seedUid || seedLocalId}.update`);
|
|
4890
|
-
};
|
|
4980
|
+
const logger$7 = debug('app:write:updateItemPropertyValue');
|
|
4891
4981
|
const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUid, seedLocalId, modelName, refSeedType, refResolvedValue, refResolvedDisplayValue, versionLocalId, versionUid, schemaUid, localStorageDir, }) => {
|
|
4892
4982
|
if (!localId && !seedLocalId) {
|
|
4893
|
-
logger$
|
|
4983
|
+
logger$7(`[db/write] [updateItemPropertyValue] no propertyLocalId or seedLocalId for property: ${propertyName}`);
|
|
4894
4984
|
return;
|
|
4895
4985
|
}
|
|
4896
4986
|
let safeNewValue = newValue;
|
|
@@ -4928,7 +5018,7 @@ const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUi
|
|
|
4928
5018
|
modelType === modelName?.toLowerCase() &&
|
|
4929
5019
|
refSeedTypeFromDb === refSeedType &&
|
|
4930
5020
|
refResolvedValueFromDb === refResolvedValue) {
|
|
4931
|
-
logger$
|
|
5021
|
+
logger$7(`[db/write] [updateItemPropertyValue] value is the same as most recent record for property: ${propertyNameFromDb}`);
|
|
4932
5022
|
return;
|
|
4933
5023
|
}
|
|
4934
5024
|
// This means we already have a local-only record so we should just update that one
|
|
@@ -4941,7 +5031,6 @@ const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUi
|
|
|
4941
5031
|
updated_at = ${Date.now()}
|
|
4942
5032
|
WHERE local_id = '${localId}';`;
|
|
4943
5033
|
await appDb.run(sql.raw(updatePropertyStatement));
|
|
4944
|
-
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
4945
5034
|
return;
|
|
4946
5035
|
}
|
|
4947
5036
|
const seedDataFromDb = await getSeedData({ seedLocalId });
|
|
@@ -4979,7 +5068,6 @@ const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUi
|
|
|
4979
5068
|
${localStorageDir ? `'${localStorageDir}'` : 'NULL'},
|
|
4980
5069
|
${Date.now()});`;
|
|
4981
5070
|
await appDb.run(sql.raw(newPropertyStatement));
|
|
4982
|
-
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
4983
5071
|
return {
|
|
4984
5072
|
localId: newLocalId,
|
|
4985
5073
|
schemaUid,
|
|
@@ -5028,7 +5116,6 @@ const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUi
|
|
|
5028
5116
|
${localStorageDir ? `'${localStorageDir}'` : 'NULL'},
|
|
5029
5117
|
${Date.now()});`;
|
|
5030
5118
|
await appDb.run(sql.raw(newPropertyStatement));
|
|
5031
|
-
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
5032
5119
|
return {
|
|
5033
5120
|
localId: newLocalId,
|
|
5034
5121
|
schemaUid,
|
|
@@ -5145,17 +5232,20 @@ const createMetadata = async (metadataValues, propertyRecordSchema) => {
|
|
|
5145
5232
|
const queryClient = BaseQueryClient.getQueryClient();
|
|
5146
5233
|
const easClient = BaseEasClient.getEasClient();
|
|
5147
5234
|
const easDataType = INTERNAL_DATA_TYPES[propertyRecordSchema.dataType].eas;
|
|
5235
|
+
const propertyNameSnakeCase = toSnakeCase$1(metadataValues.propertyName);
|
|
5148
5236
|
const queryResult = await queryClient.fetchQuery({
|
|
5149
5237
|
queryKey: [`getSchemaByName${metadataValues.propertyName}`],
|
|
5150
5238
|
queryFn: async () => easClient.request(GET_SCHEMA_BY_NAME, {
|
|
5151
5239
|
where: {
|
|
5152
5240
|
schema: {
|
|
5153
|
-
equals: `${easDataType} ${
|
|
5241
|
+
equals: `${easDataType} ${propertyNameSnakeCase}`,
|
|
5154
5242
|
},
|
|
5155
5243
|
},
|
|
5156
5244
|
}),
|
|
5157
5245
|
});
|
|
5158
|
-
|
|
5246
|
+
if (queryResult && queryResult.schemas.length > 0) {
|
|
5247
|
+
metadataValues.schemaUid = queryResult.schemas[0].id;
|
|
5248
|
+
}
|
|
5159
5249
|
}
|
|
5160
5250
|
return appDb
|
|
5161
5251
|
.insert(metadata)
|
|
@@ -5325,7 +5415,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
5325
5415
|
refSeedType: 'image',
|
|
5326
5416
|
refSchemaUid: imageSchemaUid,
|
|
5327
5417
|
renderValue: refResolvedDisplayValue,
|
|
5328
|
-
refResolvedDisplayValue
|
|
5418
|
+
refResolvedDisplayValue,
|
|
5329
5419
|
refResolvedValue: fileName,
|
|
5330
5420
|
localStorageDir: '/images',
|
|
5331
5421
|
easDataType: 'bytes32',
|
|
@@ -5740,7 +5830,7 @@ const getPropertyData$1 = async ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
5740
5830
|
};
|
|
5741
5831
|
|
|
5742
5832
|
var _a$1;
|
|
5743
|
-
const logger$
|
|
5833
|
+
const logger$6 = debug('app:property:class');
|
|
5744
5834
|
class BaseItemProperty {
|
|
5745
5835
|
constructor(initialValues) {
|
|
5746
5836
|
this._isRelation = false;
|
|
@@ -5787,7 +5877,7 @@ class BaseItemProperty {
|
|
|
5787
5877
|
serviceInput.propertyValue = JSON.parse(propertyValue);
|
|
5788
5878
|
}
|
|
5789
5879
|
catch (e) {
|
|
5790
|
-
logger$
|
|
5880
|
+
logger$6('List property value is not JSON', e);
|
|
5791
5881
|
}
|
|
5792
5882
|
}
|
|
5793
5883
|
const propertyNameSingular = pluralize(propertyName, 1);
|
|
@@ -5825,16 +5915,16 @@ class BaseItemProperty {
|
|
|
5825
5915
|
context.localStorageDir) {
|
|
5826
5916
|
const filePath = `/files/${context.localStorageDir}/${context.refResolvedValue}`;
|
|
5827
5917
|
try {
|
|
5828
|
-
const exists = await fs
|
|
5918
|
+
const exists = await fs.promises.exists(filePath);
|
|
5829
5919
|
if (exists) {
|
|
5830
|
-
renderValue = await fs
|
|
5920
|
+
renderValue = await fs.promises.readFile(filePath, 'utf-8');
|
|
5831
5921
|
}
|
|
5832
5922
|
if (!exists) {
|
|
5833
5923
|
renderValue = 'No file found';
|
|
5834
5924
|
}
|
|
5835
5925
|
}
|
|
5836
5926
|
catch (e) {
|
|
5837
|
-
logger$
|
|
5927
|
+
logger$6(`[ItemProperty] [${context.seedLocalId}] [${context.propertyName}] [storageType] error`, e);
|
|
5838
5928
|
renderValue = 'No file found';
|
|
5839
5929
|
}
|
|
5840
5930
|
}
|
|
@@ -5857,12 +5947,13 @@ class BaseItemProperty {
|
|
|
5857
5947
|
return;
|
|
5858
5948
|
}
|
|
5859
5949
|
this._subject.next(renderValue);
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
}
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
}
|
|
5950
|
+
// TODO: Maybe have this only update the property?
|
|
5951
|
+
// if (context.seedLocalId) {
|
|
5952
|
+
// eventEmitter.emit(`item.${modelName}.${context.seedLocalId}.update`)
|
|
5953
|
+
// }
|
|
5954
|
+
// if (context.seedUid) {
|
|
5955
|
+
// eventEmitter.emit(`item.${modelName}.${context.seedUid}.update`)
|
|
5956
|
+
// }
|
|
5866
5957
|
});
|
|
5867
5958
|
this._service.start();
|
|
5868
5959
|
}
|
|
@@ -6078,7 +6169,7 @@ const getSegmentedItemProperties = (item) => {
|
|
|
6078
6169
|
};
|
|
6079
6170
|
};
|
|
6080
6171
|
|
|
6081
|
-
const logger$
|
|
6172
|
+
const logger$5 = debug('app:item:getPublishUploads');
|
|
6082
6173
|
const prepareArweaveTransaction = async (data, contentHash) => {
|
|
6083
6174
|
const transactionData = {
|
|
6084
6175
|
data,
|
|
@@ -6086,8 +6177,8 @@ const prepareArweaveTransaction = async (data, contentHash) => {
|
|
|
6086
6177
|
};
|
|
6087
6178
|
const tx = await getArweave().createTransaction(transactionData);
|
|
6088
6179
|
if (contentHash) {
|
|
6089
|
-
logger$
|
|
6090
|
-
logger$
|
|
6180
|
+
logger$5('contentHash', contentHash);
|
|
6181
|
+
logger$5('adding content hash tag to tx.id:', tx.id);
|
|
6091
6182
|
tx.addTag('Content-SHA-256', contentHash);
|
|
6092
6183
|
}
|
|
6093
6184
|
return tx;
|
|
@@ -6109,27 +6200,6 @@ const processUploadProperty = async (uploadProperty, uploads, relatedItemPropert
|
|
|
6109
6200
|
localStoragePath: filePath,
|
|
6110
6201
|
});
|
|
6111
6202
|
}
|
|
6112
|
-
// const filePath = itemProperty.localStoragePath
|
|
6113
|
-
//
|
|
6114
|
-
// if (!filePath) {
|
|
6115
|
-
// throw new Error(
|
|
6116
|
-
// `No localStoragePath found for ItemProperty ${itemProperty.propertyName}`,
|
|
6117
|
-
// )
|
|
6118
|
-
// }
|
|
6119
|
-
//
|
|
6120
|
-
// const exists = await fs.promises.exists(filePath)
|
|
6121
|
-
// if (!exists) {
|
|
6122
|
-
// throw new Error(`File doesn't exist at ${filePath}`)
|
|
6123
|
-
//
|
|
6124
|
-
// // const handle = await navigator.storage.getDirectory()
|
|
6125
|
-
// //
|
|
6126
|
-
// // await configureSingle({
|
|
6127
|
-
// // backend: WebAccess,
|
|
6128
|
-
// // handle,
|
|
6129
|
-
// // })
|
|
6130
|
-
// }
|
|
6131
|
-
//
|
|
6132
|
-
// const mainFileContents = await fs.promises.readFile(filePath)
|
|
6133
6203
|
let fileContents;
|
|
6134
6204
|
let transaction;
|
|
6135
6205
|
if (!childUploads || childUploads.length === 0) {
|
|
@@ -6141,12 +6211,6 @@ const processUploadProperty = async (uploadProperty, uploads, relatedItemPropert
|
|
|
6141
6211
|
const exists = await fs.promises.exists(filePath);
|
|
6142
6212
|
if (!exists) {
|
|
6143
6213
|
return uploads;
|
|
6144
|
-
// const handle = await navigator.storage.getDirectory()
|
|
6145
|
-
//
|
|
6146
|
-
// await configureSingle({
|
|
6147
|
-
// backend: WebAccess,
|
|
6148
|
-
// handle,
|
|
6149
|
-
// })
|
|
6150
6214
|
}
|
|
6151
6215
|
try {
|
|
6152
6216
|
fileContents = await fs.promises.readFile(filePath);
|
|
@@ -6310,7 +6374,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData) => {
|
|
|
6310
6374
|
}
|
|
6311
6375
|
return itemPublishData;
|
|
6312
6376
|
};
|
|
6313
|
-
const processRelationProperty = async (relationProperty, multiPublishPayload, uploadedTransactions) => {
|
|
6377
|
+
const processRelationProperty = async (relationProperty, multiPublishPayload, uploadedTransactions, originalSeedLocalId) => {
|
|
6314
6378
|
const value = relationProperty.getService().getSnapshot()
|
|
6315
6379
|
.context.propertyValue;
|
|
6316
6380
|
if (!value || relationProperty.uid) {
|
|
@@ -6336,7 +6400,7 @@ const processRelationProperty = async (relationProperty, multiPublishPayload, up
|
|
|
6336
6400
|
listOfAttestations: [],
|
|
6337
6401
|
propertiesToUpdate: [
|
|
6338
6402
|
{
|
|
6339
|
-
publishLocalId:
|
|
6403
|
+
publishLocalId: originalSeedLocalId,
|
|
6340
6404
|
propertySchemaUid: relationProperty.schemaUid,
|
|
6341
6405
|
},
|
|
6342
6406
|
],
|
|
@@ -6356,7 +6420,7 @@ const processRelationProperty = async (relationProperty, multiPublishPayload, up
|
|
|
6356
6420
|
multiPublishPayload.push(publishPayload);
|
|
6357
6421
|
return multiPublishPayload;
|
|
6358
6422
|
};
|
|
6359
|
-
const processListProperty = async (listProperty, multiPublishPayload) => {
|
|
6423
|
+
const processListProperty = async (listProperty, multiPublishPayload, originalSeedLocalId) => {
|
|
6360
6424
|
let value = listProperty.getService().getSnapshot().context.propertyValue;
|
|
6361
6425
|
if (!value || listProperty.uid) {
|
|
6362
6426
|
return multiPublishPayload;
|
|
@@ -6399,7 +6463,7 @@ const processListProperty = async (listProperty, multiPublishPayload) => {
|
|
|
6399
6463
|
listOfAttestations: [],
|
|
6400
6464
|
propertiesToUpdate: [
|
|
6401
6465
|
{
|
|
6402
|
-
publishLocalId:
|
|
6466
|
+
publishLocalId: originalSeedLocalId,
|
|
6403
6467
|
propertySchemaUid: listProperty.schemaUid,
|
|
6404
6468
|
},
|
|
6405
6469
|
],
|
|
@@ -6437,14 +6501,15 @@ const getPublishPayload = async (item, uploadedTransactions) => {
|
|
|
6437
6501
|
}
|
|
6438
6502
|
}
|
|
6439
6503
|
for (const relationProperty of itemRelationProperties) {
|
|
6440
|
-
multiPublishPayload = await processRelationProperty(relationProperty, multiPublishPayload, uploadedTransactions);
|
|
6504
|
+
multiPublishPayload = await processRelationProperty(relationProperty, multiPublishPayload, uploadedTransactions, item.seedLocalId);
|
|
6441
6505
|
itemBasicProperties.push(relationProperty);
|
|
6442
6506
|
}
|
|
6443
|
-
itemPublishData = await processBasicProperties(itemBasicProperties, itemPublishData);
|
|
6444
|
-
multiPublishPayload.push(itemPublishData);
|
|
6445
6507
|
for (const listProperty of itemListProperties) {
|
|
6446
|
-
multiPublishPayload = await processListProperty(listProperty, multiPublishPayload);
|
|
6508
|
+
multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, item.seedLocalId);
|
|
6509
|
+
itemBasicProperties.push(listProperty);
|
|
6447
6510
|
}
|
|
6511
|
+
itemPublishData = await processBasicProperties(itemBasicProperties, itemPublishData);
|
|
6512
|
+
multiPublishPayload.push(itemPublishData);
|
|
6448
6513
|
return multiPublishPayload;
|
|
6449
6514
|
};
|
|
6450
6515
|
|
|
@@ -6559,7 +6624,7 @@ class BaseItem {
|
|
|
6559
6624
|
propertiesObj[transformedKey] = propertyInstance;
|
|
6560
6625
|
}
|
|
6561
6626
|
this._propertiesSubject.next(propertiesObj);
|
|
6562
|
-
eventEmitter.emit(`item.${modelName}.${seedUid || seedLocalId}.update`)
|
|
6627
|
+
// eventEmitter.emit(`item.${modelName}.${seedUid || seedLocalId}.update`)
|
|
6563
6628
|
});
|
|
6564
6629
|
this._service.start();
|
|
6565
6630
|
const definedKeys = ['ModelClass'];
|
|
@@ -6800,7 +6865,7 @@ const initItem = async () => {
|
|
|
6800
6865
|
Item$2 = (await Promise.resolve().then(function () { return Item$1; })).Item;
|
|
6801
6866
|
}
|
|
6802
6867
|
if (!isBrowser()) {
|
|
6803
|
-
Item$2 = (await import('./Item-
|
|
6868
|
+
Item$2 = (await import('./Item-BmPvgaG4.js')).Item;
|
|
6804
6869
|
}
|
|
6805
6870
|
};
|
|
6806
6871
|
|
|
@@ -6810,17 +6875,17 @@ const initItemProperty = async () => {
|
|
|
6810
6875
|
ItemProperty$2 = (await Promise.resolve().then(function () { return ItemProperty$1; })).ItemProperty;
|
|
6811
6876
|
}
|
|
6812
6877
|
if (!isBrowser()) {
|
|
6813
|
-
ItemProperty$2 = (await import('./ItemProperty-
|
|
6878
|
+
ItemProperty$2 = (await import('./ItemProperty-BW4k1h0o.js')).ItemProperty;
|
|
6814
6879
|
}
|
|
6815
6880
|
};
|
|
6816
6881
|
|
|
6817
6882
|
let Db;
|
|
6818
6883
|
const initDb = async () => {
|
|
6819
6884
|
if (isBrowser()) {
|
|
6820
|
-
Db = (await import('./Db-
|
|
6885
|
+
Db = (await import('./Db-5C5VqRWb.js')).Db;
|
|
6821
6886
|
}
|
|
6822
6887
|
if (!isBrowser()) {
|
|
6823
|
-
Db = (await import('./Db-
|
|
6888
|
+
Db = (await import('./Db-Dv890NJZ.js')).Db;
|
|
6824
6889
|
}
|
|
6825
6890
|
// TODO: Add config for React Native
|
|
6826
6891
|
};
|
|
@@ -6837,7 +6902,7 @@ var Item$1 = /*#__PURE__*/Object.freeze({
|
|
|
6837
6902
|
Item: Item
|
|
6838
6903
|
});
|
|
6839
6904
|
|
|
6840
|
-
const logger$
|
|
6905
|
+
const logger$4 = debug('app:react:services');
|
|
6841
6906
|
const finalStrings = ['idle', 'ready', 'done', 'success', 'initialized'];
|
|
6842
6907
|
const getServiceName = (service) => {
|
|
6843
6908
|
let name = 'actor';
|
|
@@ -6884,7 +6949,7 @@ const getServiceUniqueKey = (service) => {
|
|
|
6884
6949
|
snapshot = service.getSnapshot();
|
|
6885
6950
|
}
|
|
6886
6951
|
catch (error) {
|
|
6887
|
-
logger$
|
|
6952
|
+
logger$4('Error:', error);
|
|
6888
6953
|
return uniqueKey;
|
|
6889
6954
|
}
|
|
6890
6955
|
if (snapshot) {
|
|
@@ -7113,7 +7178,7 @@ const useGlobalServiceStatus = () => {
|
|
|
7113
7178
|
};
|
|
7114
7179
|
};
|
|
7115
7180
|
|
|
7116
|
-
const logger$
|
|
7181
|
+
const logger$3 = debug('app:react:item');
|
|
7117
7182
|
const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
7118
7183
|
// const [itemSubscription, setItemSubscription] = useState<
|
|
7119
7184
|
// Subscription | undefined
|
|
@@ -7190,7 +7255,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
7190
7255
|
seedUid,
|
|
7191
7256
|
});
|
|
7192
7257
|
if (!foundItem) {
|
|
7193
|
-
logger$
|
|
7258
|
+
logger$3('[useItem] [getItemFromDb] no item found', modelName, seedLocalId);
|
|
7194
7259
|
isReadingDb.current = false;
|
|
7195
7260
|
return;
|
|
7196
7261
|
}
|
|
@@ -7212,7 +7277,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
7212
7277
|
const subscription = item.subscribe(async (_) => {
|
|
7213
7278
|
const newItem = await Item.find({ modelName, seedLocalId, seedUid });
|
|
7214
7279
|
if (!newItem) {
|
|
7215
|
-
logger$
|
|
7280
|
+
logger$3('[useItem] [itemSubscription] no item found', modelName, seedLocalId);
|
|
7216
7281
|
return;
|
|
7217
7282
|
}
|
|
7218
7283
|
updateItem(newItem);
|
|
@@ -7370,8 +7435,13 @@ var ItemProperty$1 = /*#__PURE__*/Object.freeze({
|
|
|
7370
7435
|
ItemProperty: ItemProperty
|
|
7371
7436
|
});
|
|
7372
7437
|
|
|
7373
|
-
const logger$
|
|
7374
|
-
const useItemProperty = (
|
|
7438
|
+
const logger$2 = debug('app:react:property');
|
|
7439
|
+
const useItemProperty = (props = {
|
|
7440
|
+
propertyName: '',
|
|
7441
|
+
seedLocalId: '',
|
|
7442
|
+
seedUid: '',
|
|
7443
|
+
}) => {
|
|
7444
|
+
const { propertyName, seedLocalId, seedUid } = props;
|
|
7375
7445
|
const [property, setProperty] = useState();
|
|
7376
7446
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
7377
7447
|
const { internalStatus } = useGlobalServiceStatus();
|
|
@@ -7396,7 +7466,7 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
7396
7466
|
seedUid,
|
|
7397
7467
|
});
|
|
7398
7468
|
if (!foundProperty) {
|
|
7399
|
-
logger$
|
|
7469
|
+
logger$2(`[useItemPropertyTest] [readFromDb] no property found for Item.${seedLocalId}.${propertyName}`);
|
|
7400
7470
|
isReadingDb.current = false;
|
|
7401
7471
|
return;
|
|
7402
7472
|
}
|
|
@@ -7406,11 +7476,11 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
7406
7476
|
setProperty(foundProperty);
|
|
7407
7477
|
setIsInitialized(true);
|
|
7408
7478
|
isReadingDb.current = false;
|
|
7409
|
-
}, [internalStatus]);
|
|
7479
|
+
}, [internalStatus, props]);
|
|
7410
7480
|
const listenerRef = useRef(readFromDb);
|
|
7411
7481
|
useEffect(() => {
|
|
7412
7482
|
listenerRef.current = readFromDb;
|
|
7413
|
-
}, [readFromDb]);
|
|
7483
|
+
}, [readFromDb, props]);
|
|
7414
7484
|
useEffect(() => {
|
|
7415
7485
|
if (internalStatus === 'ready') {
|
|
7416
7486
|
readFromDb();
|
|
@@ -7568,10 +7638,10 @@ const withSeed = (config, webpack, isServer) => {
|
|
|
7568
7638
|
return config;
|
|
7569
7639
|
};
|
|
7570
7640
|
|
|
7571
|
-
const logger = debug('app:services:events');
|
|
7641
|
+
const logger$1 = debug('app:services:events');
|
|
7572
7642
|
const handleServiceSaveState = (event) => {
|
|
7573
7643
|
const { state, serviceId } = event;
|
|
7574
|
-
logger(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
|
|
7644
|
+
logger$1(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
|
|
7575
7645
|
localStorage.setItem(`seed_sdk_service_${serviceId}`, JSON.stringify(state));
|
|
7576
7646
|
};
|
|
7577
7647
|
const setupServicesEventHandlers = () => {
|
|
@@ -7599,33 +7669,40 @@ const setupServiceHandlers = () => {
|
|
|
7599
7669
|
|
|
7600
7670
|
const initEasClient = async () => {
|
|
7601
7671
|
if (isBrowser()) {
|
|
7602
|
-
(await import('./EasClient-
|
|
7672
|
+
(await import('./EasClient-sCbTHcO8.js')).EasClient;
|
|
7603
7673
|
}
|
|
7604
7674
|
if (!isBrowser()) {
|
|
7605
|
-
(await import('./EasClient-
|
|
7675
|
+
(await import('./EasClient-CBu9ENAi.js')).EasClient;
|
|
7606
7676
|
}
|
|
7607
7677
|
};
|
|
7608
7678
|
|
|
7609
7679
|
const initQueryClient = async () => {
|
|
7610
7680
|
if (isBrowser()) {
|
|
7611
|
-
(await import('./QueryClient-
|
|
7681
|
+
(await import('./QueryClient-BBaE-LKI.js')).QueryClient;
|
|
7612
7682
|
}
|
|
7613
7683
|
if (!isBrowser()) {
|
|
7614
|
-
(await import('./QueryClient-
|
|
7684
|
+
(await import('./QueryClient-C-ZzUnWq.js')).QueryClient;
|
|
7615
7685
|
}
|
|
7616
7686
|
};
|
|
7617
7687
|
|
|
7618
7688
|
const initFileManager = async () => {
|
|
7619
7689
|
if (isBrowser()) {
|
|
7620
|
-
(await import('./FileManager-
|
|
7690
|
+
(await import('./FileManager-AhAsy_F_.js')).FileManager;
|
|
7621
7691
|
}
|
|
7622
7692
|
if (!isBrowser()) {
|
|
7623
|
-
(await import('./FileManager-
|
|
7693
|
+
(await import('./FileManager-COOp89Mj.js')).FileManager;
|
|
7624
7694
|
}
|
|
7625
7695
|
};
|
|
7626
7696
|
|
|
7697
|
+
const logger = debug('app:client');
|
|
7627
7698
|
const client = {
|
|
7699
|
+
isInitialized: false,
|
|
7628
7700
|
init: async (options) => {
|
|
7701
|
+
logger('init client');
|
|
7702
|
+
if (client.isInitialized) {
|
|
7703
|
+
return;
|
|
7704
|
+
}
|
|
7705
|
+
client.isInitialized = true;
|
|
7629
7706
|
const { config, addresses } = options;
|
|
7630
7707
|
await initItem();
|
|
7631
7708
|
await initItemProperty();
|
|
@@ -7659,7 +7736,7 @@ const client = {
|
|
|
7659
7736
|
arweaveDomain,
|
|
7660
7737
|
filesDir,
|
|
7661
7738
|
});
|
|
7662
|
-
const { models: internalModels } = await import('./seed.schema.config-
|
|
7739
|
+
const { models: internalModels } = await import('./seed.schema.config-BXWvwsZQ.js');
|
|
7663
7740
|
for (const [key, value] of Object.entries(internalModels)) {
|
|
7664
7741
|
setModel(key, value);
|
|
7665
7742
|
}
|
|
@@ -7707,4 +7784,4 @@ const client = {
|
|
|
7707
7784
|
enableMapSet();
|
|
7708
7785
|
|
|
7709
7786
|
export { BaseItem as B, Db as D, 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, saveAppState as s, withSeed as t, useItems as u, client as v, waitForFile as w };
|
|
7710
|
-
//# sourceMappingURL=index-
|
|
7787
|
+
//# sourceMappingURL=index-CGeSKilQ.js.map
|