@seedprotocol/sdk 0.2.45 → 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/{Db-BlgPVb_Z.js → Db-5C5VqRWb.js} +5 -2
- package/dist/Db-5C5VqRWb.js.map +1 -0
- package/dist/{Db-gw_uZA_e.js → Db-Dv890NJZ.js} +4 -3
- package/dist/{Db-gw_uZA_e.js.map → Db-Dv890NJZ.js.map} +1 -1
- package/dist/{FileManager-BNqJl6Bz.js → FileManager-AhAsy_F_.js} +20 -7
- package/dist/{FileManager-BNqJl6Bz.js.map → FileManager-AhAsy_F_.js.map} +1 -1
- package/dist/{Item-BO38NUjz.js → Item-BmPvgaG4.js} +4 -3
- package/dist/{Item-BO38NUjz.js.map → Item-BmPvgaG4.js.map} +1 -1
- package/dist/{ItemProperty-8H7B05zy.js → ItemProperty-BW4k1h0o.js} +4 -3
- package/dist/{ItemProperty-8H7B05zy.js.map → ItemProperty-BW4k1h0o.js.map} +1 -1
- package/dist/{index-CsbUKGXp.js → index-CGeSKilQ.js} +189 -144
- package/dist/index-CGeSKilQ.js.map +1 -0
- package/dist/{index-Km3L1_LR.js → index-CPxn1SR4.js} +4 -3
- package/dist/index-CPxn1SR4.js.map +1 -0
- package/dist/main.js +3 -2
- package/dist/main.js.map +1 -1
- package/dist/{seed.schema.config-Dn_1QbD7.js → seed.schema.config-BXWvwsZQ.js} +10 -9
- package/dist/seed.schema.config-BXWvwsZQ.js.map +1 -0
- 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 +1 -1
- package/dist/src/createMetadata.ts +11 -4
- package/dist/src/download.ts +1 -1
- 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 -1
- package/dist/src/gql.ts +9 -4
- package/dist/src/graphql.ts +12 -4
- package/dist/src/helpers.ts +14 -3
- package/dist/src/hydrateFromDb.ts +1 -1
- package/dist/src/metadataLatest.ts +34 -0
- package/dist/src/migrate.ts +1 -1
- 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 +1 -1
- package/dist/src/waitForDb.ts +12 -9
- 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/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/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/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/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/global/globalMachine.d.ts +90 -90
- package/dist/types/src/services/internal/helpers.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/Db-BlgPVb_Z.js.map +0 -1
- package/dist/index-CsbUKGXp.js.map +0 -1
- package/dist/index-Km3L1_LR.js.map +0 -1
- package/dist/seed.schema.config-Dn_1QbD7.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
|
@@ -3,20 +3,21 @@ import 'reflect-metadata';
|
|
|
3
3
|
import { Type } from '@sinclair/typebox';
|
|
4
4
|
import { fromCallback, setup, assign, waitFor, createActor, raise } from 'xstate';
|
|
5
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');
|
|
@@ -1518,6 +1522,7 @@ const validate = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1518
1522
|
});
|
|
1519
1523
|
});
|
|
1520
1524
|
|
|
1525
|
+
const logger$k = debug('app:helpers:files');
|
|
1521
1526
|
/**
|
|
1522
1527
|
* Waits for a file to exist at the specified path.
|
|
1523
1528
|
* @param {string} filePath - The path of the file to check.
|
|
@@ -1525,10 +1530,16 @@ const validate = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1525
1530
|
* @param {number} timeout - The timeout in milliseconds to wait for the file to exist (default: 10s).
|
|
1526
1531
|
* @returns {Promise<boolean>} - Resolves to true if the file exists within the timeout period, otherwise false.
|
|
1527
1532
|
*/
|
|
1528
|
-
const waitForFile = (filePath, interval =
|
|
1533
|
+
const waitForFile = (filePath, interval = 1000, timeout = 60000) => {
|
|
1529
1534
|
return new Promise((resolve, reject) => {
|
|
1530
1535
|
const startTime = Date.now();
|
|
1531
|
-
|
|
1536
|
+
let isBusy = false;
|
|
1537
|
+
const _interval = setInterval(async () => {
|
|
1538
|
+
logger$k('waitForFile', filePath);
|
|
1539
|
+
if (isBusy) {
|
|
1540
|
+
return;
|
|
1541
|
+
}
|
|
1542
|
+
isBusy = true;
|
|
1532
1543
|
if (fs.existsSync(filePath) && fsNode.existsSync(filePath)) {
|
|
1533
1544
|
clearInterval(_interval);
|
|
1534
1545
|
resolve(true);
|
|
@@ -1537,6 +1548,7 @@ const waitForFile = (filePath, interval = 500, timeout = 10000) => {
|
|
|
1537
1548
|
clearInterval(_interval);
|
|
1538
1549
|
reject(new Error('Timeout exceeded while waiting for file'));
|
|
1539
1550
|
}
|
|
1551
|
+
isBusy = false;
|
|
1540
1552
|
}, interval);
|
|
1541
1553
|
// retry(
|
|
1542
1554
|
// {
|
|
@@ -1562,16 +1574,16 @@ const waitForFile = (filePath, interval = 500, timeout = 10000) => {
|
|
|
1562
1574
|
});
|
|
1563
1575
|
};
|
|
1564
1576
|
|
|
1565
|
-
const logger$
|
|
1577
|
+
const logger$j = debug('app:services:db:actors:migrate');
|
|
1566
1578
|
const migrate = fromCallback(({ sendBack, input: { context } }) => {
|
|
1567
1579
|
const { pathToDbDir, dbId, dbName } = context;
|
|
1568
|
-
logger$
|
|
1580
|
+
logger$j('[db/actors] migrate context', context);
|
|
1569
1581
|
let journalExists = false;
|
|
1570
1582
|
const _checkForFiles = async () => {
|
|
1571
1583
|
const journalPath = `/${pathToDbDir}/meta/_journal.json`;
|
|
1572
|
-
journalExists = await fs
|
|
1584
|
+
journalExists = await fs.promises.exists(journalPath);
|
|
1573
1585
|
if (!journalExists) {
|
|
1574
|
-
await waitForFile(journalPath);
|
|
1586
|
+
await waitForFile(journalPath, 500, 60000);
|
|
1575
1587
|
}
|
|
1576
1588
|
};
|
|
1577
1589
|
const _migrate = async () => {
|
|
@@ -1595,7 +1607,7 @@ const waitForFiles$1 = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1595
1607
|
const _waitForFiles = async () => {
|
|
1596
1608
|
return new Promise((resolve) => {
|
|
1597
1609
|
const interval = setInterval(async () => {
|
|
1598
|
-
const journalExists = await fs
|
|
1610
|
+
const journalExists = await fs.promises.exists(`${pathToDbDir}/meta/_journal.json`);
|
|
1599
1611
|
if (journalExists) {
|
|
1600
1612
|
clearInterval(interval);
|
|
1601
1613
|
resolve();
|
|
@@ -1609,7 +1621,7 @@ const waitForFiles$1 = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1609
1621
|
});
|
|
1610
1622
|
});
|
|
1611
1623
|
|
|
1612
|
-
const logger$
|
|
1624
|
+
const logger$i = debug('app:services:db:machine');
|
|
1613
1625
|
const { CHECKING_STATUS, VALIDATING, WAITING_FOR_FILES, CONNECTING_TO_DB, MIGRATING, } = DbState;
|
|
1614
1626
|
const dbMachine = setup({
|
|
1615
1627
|
types: {
|
|
@@ -1631,7 +1643,7 @@ const dbMachine = setup({
|
|
|
1631
1643
|
[DB_WAITING_FOR_FILES_RECEIVED]: {
|
|
1632
1644
|
actions: assign({
|
|
1633
1645
|
hasFiles: ({ event }) => {
|
|
1634
|
-
logger$
|
|
1646
|
+
logger$i('[db/machine] DB_WAITING_FOR_FILES_RECEIVED event:', event);
|
|
1635
1647
|
return true;
|
|
1636
1648
|
},
|
|
1637
1649
|
}),
|
|
@@ -1640,8 +1652,8 @@ const dbMachine = setup({
|
|
|
1640
1652
|
target: `.${CHECKING_STATUS}`,
|
|
1641
1653
|
actions: assign({
|
|
1642
1654
|
hasFiles: ({ context, event }) => {
|
|
1643
|
-
logger$
|
|
1644
|
-
logger$
|
|
1655
|
+
logger$i('[db/machine] updateHasFiles event:', event);
|
|
1656
|
+
logger$i('[db/machine] updateHasFiles context:', context);
|
|
1645
1657
|
return event.hasFiles;
|
|
1646
1658
|
},
|
|
1647
1659
|
}),
|
|
@@ -1808,7 +1820,7 @@ const prepareDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1808
1820
|
});
|
|
1809
1821
|
});
|
|
1810
1822
|
|
|
1811
|
-
const logger$
|
|
1823
|
+
const logger$h = debug('app:services:internal:helpers');
|
|
1812
1824
|
/**
|
|
1813
1825
|
* Recursively create directories if they don't exist.
|
|
1814
1826
|
* @param {string} dirPath - The directory path to create.
|
|
@@ -1819,11 +1831,22 @@ const createDirectories = async (dirPath) => {
|
|
|
1819
1831
|
return;
|
|
1820
1832
|
}
|
|
1821
1833
|
const parentDir = path.dirname(dirPath);
|
|
1822
|
-
|
|
1834
|
+
let parentDirExists = await fs.promises.exists(parentDir);
|
|
1823
1835
|
if (!parentDirExists) {
|
|
1824
1836
|
await createDirectories(parentDir);
|
|
1825
1837
|
}
|
|
1826
|
-
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
|
+
}
|
|
1827
1850
|
};
|
|
1828
1851
|
let busy = false;
|
|
1829
1852
|
const downloadFile = async (url, localFilePath) => {
|
|
@@ -1869,15 +1892,15 @@ const downloadFile = async (url, localFilePath) => {
|
|
|
1869
1892
|
}
|
|
1870
1893
|
try {
|
|
1871
1894
|
await fs.promises.writeFile(localFilePath, fileData);
|
|
1872
|
-
logger$
|
|
1895
|
+
logger$h(`[downloadFile] Wrote file async to ${localFilePath}`);
|
|
1873
1896
|
}
|
|
1874
1897
|
catch (error) {
|
|
1875
1898
|
fs.writeFileSync(localFilePath, fileData);
|
|
1876
|
-
logger$
|
|
1899
|
+
logger$h(`[downloadFile] Wrote file sync to ${localFilePath}`);
|
|
1877
1900
|
}
|
|
1878
1901
|
}
|
|
1879
1902
|
catch (error) {
|
|
1880
|
-
logger$
|
|
1903
|
+
logger$h(`[Error] Failed to download file from ${url}:`, error);
|
|
1881
1904
|
}
|
|
1882
1905
|
busy = false;
|
|
1883
1906
|
};
|
|
@@ -1917,7 +1940,7 @@ const syncDbFiles = async ({ filePaths, files }) => {
|
|
|
1917
1940
|
fileList = fileList.filter((file) => !filesToExclude.includes(file));
|
|
1918
1941
|
await fetchFilesRecursively(files, BROWSER_FS_TOP_DIR, fileList);
|
|
1919
1942
|
await confirmFilesExist(fileList);
|
|
1920
|
-
logger$
|
|
1943
|
+
logger$h('[syncDbFiles] Files synced!');
|
|
1921
1944
|
};
|
|
1922
1945
|
|
|
1923
1946
|
const GET_FILES_METADATA = graphql(/* GraphQL */ `
|
|
@@ -2072,7 +2095,7 @@ const setArweaveDomain = (newDomain) => {
|
|
|
2072
2095
|
domain = newDomain;
|
|
2073
2096
|
};
|
|
2074
2097
|
|
|
2075
|
-
const logger$
|
|
2098
|
+
const logger$g = debug('app:files:download');
|
|
2076
2099
|
const downloadAllFilesRequestHandler = async ({ endpoints, eventId, }) => {
|
|
2077
2100
|
await syncDbFiles(endpoints);
|
|
2078
2101
|
eventEmitter.emit('fs.downloadAll.success', { eventId });
|
|
@@ -2164,7 +2187,7 @@ const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
2164
2187
|
try {
|
|
2165
2188
|
const res = await fetch(`https://${ARWEAVE_HOST}/tx/${transactionId}/status`);
|
|
2166
2189
|
if (res.status !== 200) {
|
|
2167
|
-
logger$
|
|
2190
|
+
logger$g(`[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`);
|
|
2168
2191
|
excludedTransactions.add(transactionId);
|
|
2169
2192
|
await saveAppState('excludedTransactions', JSON.stringify(Array.from(excludedTransactions)));
|
|
2170
2193
|
continue;
|
|
@@ -2193,7 +2216,7 @@ const downloadAllFilesBinaryRequestHandler = async () => {
|
|
|
2193
2216
|
transactionIdsToDownload.push(transactionId);
|
|
2194
2217
|
}
|
|
2195
2218
|
catch (error) {
|
|
2196
|
-
logger$
|
|
2219
|
+
logger$g(error);
|
|
2197
2220
|
}
|
|
2198
2221
|
}
|
|
2199
2222
|
console.log('[download] Calling downloadAllFiles with transactionIdsToDownload', transactionIdsToDownload);
|
|
@@ -2244,14 +2267,14 @@ const isFsInitialized = () => {
|
|
|
2244
2267
|
return isInitialized;
|
|
2245
2268
|
};
|
|
2246
2269
|
|
|
2247
|
-
const logger$
|
|
2270
|
+
const logger$f = debug('app:internal:actors:configureFs');
|
|
2248
2271
|
const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
2249
2272
|
const { endpoints, appDbService, filesDir, } = context;
|
|
2250
|
-
logger$
|
|
2273
|
+
logger$f('[internal/actors] [configureFs] Configuring FS');
|
|
2251
2274
|
const _configureFs = async () => {
|
|
2252
|
-
logger$
|
|
2253
|
-
logger$
|
|
2254
|
-
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());
|
|
2255
2278
|
await waitForEvent({
|
|
2256
2279
|
req: {
|
|
2257
2280
|
eventLabel: 'fs.downloadAll.request',
|
|
@@ -2268,7 +2291,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2268
2291
|
}
|
|
2269
2292
|
if (journalExists) {
|
|
2270
2293
|
appDbService.send({ type: DB_WAITING_FOR_FILES_RECEIVED });
|
|
2271
|
-
logger$
|
|
2294
|
+
logger$f('[internal/actors] [configureFs] fs configured!');
|
|
2272
2295
|
return true;
|
|
2273
2296
|
}
|
|
2274
2297
|
sendBack({ type: 'shouldWaitForFiles' });
|
|
@@ -2301,7 +2324,7 @@ const configureFs = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2301
2324
|
return () => { };
|
|
2302
2325
|
});
|
|
2303
2326
|
|
|
2304
|
-
const logger$
|
|
2327
|
+
const logger$e = debug('app:services:internal:actors:saveConfig');
|
|
2305
2328
|
const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
2306
2329
|
if (typeof window === 'undefined') {
|
|
2307
2330
|
console.error('seedInitBrowser called from non-browser context');
|
|
@@ -2362,20 +2385,20 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2362
2385
|
value: arweaveDomain || 'arweave.net',
|
|
2363
2386
|
},
|
|
2364
2387
|
});
|
|
2365
|
-
logger$
|
|
2388
|
+
logger$e('[sdk] [internal/actors] Should be done saving');
|
|
2366
2389
|
}
|
|
2367
2390
|
catch (error) {
|
|
2368
2391
|
console.error('Error saving config:', error);
|
|
2369
2392
|
}
|
|
2370
2393
|
};
|
|
2371
2394
|
_saveConfig().then(() => {
|
|
2372
|
-
logger$
|
|
2395
|
+
logger$e('[sdk] [internal/actors] Successfully saved config');
|
|
2373
2396
|
return sendBack({ type: INTERNAL_SAVING_CONFIG_SUCCESS });
|
|
2374
2397
|
});
|
|
2375
2398
|
return () => { };
|
|
2376
2399
|
});
|
|
2377
2400
|
|
|
2378
|
-
const logger$
|
|
2401
|
+
const logger$d = debug('app:services:internal:actors:loadAppDb');
|
|
2379
2402
|
const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
2380
2403
|
const { appDbService } = context;
|
|
2381
2404
|
let subscription;
|
|
@@ -2396,7 +2419,7 @@ const loadAppDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2396
2419
|
};
|
|
2397
2420
|
_loadAppDb().then(() => {
|
|
2398
2421
|
sendBack({ type: INTERNAL_LOADING_APP_DB_SUCCESS });
|
|
2399
|
-
logger$
|
|
2422
|
+
logger$d('[sdk] [internal/actors] Successfully loaded app DB');
|
|
2400
2423
|
});
|
|
2401
2424
|
return () => {
|
|
2402
2425
|
if (subscription) {
|
|
@@ -2412,7 +2435,7 @@ const waitForFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2412
2435
|
const _waitForFiles = async () => {
|
|
2413
2436
|
return new Promise((resolve) => {
|
|
2414
2437
|
const interval = setInterval(async () => {
|
|
2415
|
-
const journalExists = await fs
|
|
2438
|
+
const journalExists = await fs.promises.exists(`${filesDir}/db/meta/_journal.json`);
|
|
2416
2439
|
if (journalExists) {
|
|
2417
2440
|
clearInterval(interval);
|
|
2418
2441
|
resolve();
|
|
@@ -2426,7 +2449,7 @@ const waitForFiles = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2426
2449
|
});
|
|
2427
2450
|
});
|
|
2428
2451
|
|
|
2429
|
-
const logger$
|
|
2452
|
+
const logger$c = debug('app:services:internal:machine');
|
|
2430
2453
|
createBrowserInspector({
|
|
2431
2454
|
autoStart: false,
|
|
2432
2455
|
});
|
|
@@ -2546,7 +2569,7 @@ const internalMachine = setup({
|
|
|
2546
2569
|
[INTERNAL_LOADING_APP_DB_SUCCESS]: {
|
|
2547
2570
|
target: SAVING_CONFIG,
|
|
2548
2571
|
actions: () => {
|
|
2549
|
-
logger$
|
|
2572
|
+
logger$c('[sdk] [internal/index] App DB loaded!');
|
|
2550
2573
|
},
|
|
2551
2574
|
},
|
|
2552
2575
|
},
|
|
@@ -2572,7 +2595,7 @@ const internalMachine = setup({
|
|
|
2572
2595
|
},
|
|
2573
2596
|
ready: {
|
|
2574
2597
|
entry: () => {
|
|
2575
|
-
logger$
|
|
2598
|
+
logger$c('[sdk] [internal/index] Ready!');
|
|
2576
2599
|
},
|
|
2577
2600
|
meta: {
|
|
2578
2601
|
displayText: "Crossing the t's ...",
|
|
@@ -2587,7 +2610,7 @@ const internalMachine = setup({
|
|
|
2587
2610
|
},
|
|
2588
2611
|
},
|
|
2589
2612
|
entry: () => {
|
|
2590
|
-
logger$
|
|
2613
|
+
logger$c('[sdk] [internal/index] Error!');
|
|
2591
2614
|
},
|
|
2592
2615
|
meta: {
|
|
2593
2616
|
displayText: 'Whoops! Something went wrong.',
|
|
@@ -2764,7 +2787,7 @@ const fetchDbData = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2764
2787
|
return () => { };
|
|
2765
2788
|
});
|
|
2766
2789
|
|
|
2767
|
-
const logger$
|
|
2790
|
+
const logger$b = debug('app:allItemsActors:fetchSeeds');
|
|
2768
2791
|
const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
|
|
2769
2792
|
const { queryVariables, modelName } = context;
|
|
2770
2793
|
if (!queryVariables) {
|
|
@@ -2776,7 +2799,7 @@ const fetchSeeds = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2776
2799
|
const queryClient = BaseQueryClient.getQueryClient();
|
|
2777
2800
|
const easClient = BaseEasClient.getEasClient();
|
|
2778
2801
|
const cachedResults = queryClient.getQueryData(queryKey);
|
|
2779
|
-
logger$
|
|
2802
|
+
logger$b(`[allItemsActors] [fetchSeeds] cachedResults ${Date.now()}`, cachedResults);
|
|
2780
2803
|
const results = await queryClient.fetchQuery({
|
|
2781
2804
|
queryKey,
|
|
2782
2805
|
queryFn: async () => easClient.request(GET_SEEDS, queryVariables),
|
|
@@ -3225,13 +3248,13 @@ const preparePublishRequestData = fromCallback(({ sendBack, input: { context } }
|
|
|
3225
3248
|
});
|
|
3226
3249
|
});
|
|
3227
3250
|
|
|
3228
|
-
const logger$
|
|
3251
|
+
const logger$a = debug('app:services:publish:actors:upload');
|
|
3229
3252
|
const upload = fromCallback(({ sendBack, input: { context } }) => {
|
|
3230
3253
|
const { localId } = context;
|
|
3231
3254
|
const _upload = async () => {
|
|
3232
3255
|
const item = await BaseItem.find({ seedLocalId: localId });
|
|
3233
3256
|
if (!item) {
|
|
3234
|
-
logger$
|
|
3257
|
+
logger$a('no item with localId', localId);
|
|
3235
3258
|
return false;
|
|
3236
3259
|
}
|
|
3237
3260
|
const editedProperties = await item.getEditedProperties();
|
|
@@ -4068,6 +4091,30 @@ const itemMachineSingle = setup({
|
|
|
4068
4091
|
},
|
|
4069
4092
|
});
|
|
4070
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
|
+
|
|
4071
4118
|
const getItemProperties = async ({ seedLocalId, seedUid, edited, }) => {
|
|
4072
4119
|
const appDb = BaseDb.getAppDb();
|
|
4073
4120
|
const whereClauses = [isNotNull(metadata.propertyName)];
|
|
@@ -4077,15 +4124,7 @@ const getItemProperties = async ({ seedLocalId, seedUid, edited, }) => {
|
|
|
4077
4124
|
if (seedLocalId) {
|
|
4078
4125
|
whereClauses.push(eq(seeds.localId, seedLocalId));
|
|
4079
4126
|
}
|
|
4080
|
-
// const uidWhereClause: SQL = seedUid
|
|
4081
|
-
// ? eq(seeds.uid, seedUid)
|
|
4082
|
-
// : isNull(seeds.uid)
|
|
4083
|
-
// const localWhereClause: SQL = seedLocalId
|
|
4084
|
-
// ? eq(seeds.localId, seedLocalId)
|
|
4085
|
-
// : isNull(seeds.localId)
|
|
4086
|
-
// whereClauses.push(or(localWhereClause, uidWhereClause) as SQL)
|
|
4087
4127
|
whereClauses.push(isNotNull(metadata.propertyName));
|
|
4088
|
-
// whereClauses.push(isNotNull(metadata.easDataType))
|
|
4089
4128
|
if (typeof edited !== 'undefined') {
|
|
4090
4129
|
if (edited) {
|
|
4091
4130
|
whereClauses.push(isNull(metadata.uid));
|
|
@@ -4094,16 +4133,13 @@ const getItemProperties = async ({ seedLocalId, seedUid, edited, }) => {
|
|
|
4094
4133
|
whereClauses.push(isNotNull(metadata.uid));
|
|
4095
4134
|
}
|
|
4096
4135
|
}
|
|
4097
|
-
const metadataColumns = getTableColumns(metadata)
|
|
4136
|
+
// const metadataColumns = getTableColumns(metadata)
|
|
4137
|
+
const metadataLatest = getMetadataLatest({ seedLocalId, seedUid });
|
|
4098
4138
|
const propertiesData = await appDb
|
|
4099
|
-
.
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
.
|
|
4103
|
-
.leftJoin(metadata, eq(metadata.seedLocalId, seeds.localId))
|
|
4104
|
-
.leftJoin(versions, eq(versions.localId, seeds.localId))
|
|
4105
|
-
.where(and(...whereClauses))
|
|
4106
|
-
.groupBy(metadata.propertyName);
|
|
4139
|
+
.with(metadataLatest)
|
|
4140
|
+
.select()
|
|
4141
|
+
.from(metadataLatest)
|
|
4142
|
+
.where(eq(metadataLatest.rowNum, 1));
|
|
4107
4143
|
return propertiesData.map(data => ({
|
|
4108
4144
|
...data,
|
|
4109
4145
|
localId: data.localId || '',
|
|
@@ -4149,7 +4185,7 @@ const getSeedData = async ({ seedLocalId, seedUid }) => {
|
|
|
4149
4185
|
return rows[0];
|
|
4150
4186
|
};
|
|
4151
4187
|
|
|
4152
|
-
const logger$
|
|
4188
|
+
const logger$9 = debug('app:db:read:getItemData');
|
|
4153
4189
|
const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
4154
4190
|
if (!seedLocalId && !seedUid) {
|
|
4155
4191
|
throw new Error('[db/queries] [getItem] no seedLocalId or seedUid');
|
|
@@ -4157,7 +4193,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
4157
4193
|
if (seedUid && !seedLocalId) {
|
|
4158
4194
|
const seedData = await getSeedData({ seedUid });
|
|
4159
4195
|
if (!seedData) {
|
|
4160
|
-
logger$
|
|
4196
|
+
logger$9('[db/queries] [getItem] no seedData seedUid', seedUid);
|
|
4161
4197
|
return;
|
|
4162
4198
|
}
|
|
4163
4199
|
seedLocalId = seedData.localId;
|
|
@@ -4192,7 +4228,7 @@ const getItemData = async ({ modelName, seedLocalId, seedUid, }) => {
|
|
|
4192
4228
|
.orderBy(sql.raw('COALESCE(attestation_created_at, created_at) DESC'))
|
|
4193
4229
|
.groupBy(seeds.localId);
|
|
4194
4230
|
if (!itemDataRows || itemDataRows.length === 0) {
|
|
4195
|
-
logger$
|
|
4231
|
+
logger$9('[db/queries] [getItemDataFromDb] no itemDataRows');
|
|
4196
4232
|
return;
|
|
4197
4233
|
}
|
|
4198
4234
|
let itemData = itemDataRows[0];
|
|
@@ -4311,6 +4347,7 @@ const resolveRemoteStorage = fromCallback(({ sendBack, input: { context } }) =>
|
|
|
4311
4347
|
});
|
|
4312
4348
|
});
|
|
4313
4349
|
|
|
4350
|
+
debug('app:ItemProperty:service:actors:waitForDb');
|
|
4314
4351
|
const waitForDb = fromCallback(({ sendBack }) => {
|
|
4315
4352
|
const _waitForDb = new Promise((resolve) => {
|
|
4316
4353
|
const interval = setInterval(() => {
|
|
@@ -4420,7 +4457,7 @@ const getRelationValueData = async (propertyValue) => {
|
|
|
4420
4457
|
return rows[0];
|
|
4421
4458
|
};
|
|
4422
4459
|
|
|
4423
|
-
const logger$
|
|
4460
|
+
const logger$8 = debug('app:property:actors:resolveRelatedValue');
|
|
4424
4461
|
const storageTransactionIdToContentUrl = new Map();
|
|
4425
4462
|
const refResolvedValueToContentUrl = new Map();
|
|
4426
4463
|
const seedUidToContentUrl = new Map();
|
|
@@ -4435,7 +4472,7 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4435
4472
|
parsedValue = JSON.parse(propertyValue);
|
|
4436
4473
|
}
|
|
4437
4474
|
catch (error) {
|
|
4438
|
-
logger$
|
|
4475
|
+
logger$8(`${propertyName} value is not a JSON string.`);
|
|
4439
4476
|
}
|
|
4440
4477
|
if (!parsedValue && seedUidToContentUrl.has(propertyValue)) {
|
|
4441
4478
|
const contentUrl = seedUidToContentUrl.get(propertyValue);
|
|
@@ -4451,11 +4488,11 @@ const resolveRelatedValue = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4451
4488
|
}
|
|
4452
4489
|
if (Array.isArray(propertyValue)) {
|
|
4453
4490
|
// TODO: Handle array of seedUids
|
|
4454
|
-
logger$
|
|
4491
|
+
logger$8(`${propertyName} value is an array of seedUids`);
|
|
4455
4492
|
return;
|
|
4456
4493
|
}
|
|
4457
4494
|
if (Array.isArray(parsedValue)) {
|
|
4458
|
-
logger$
|
|
4495
|
+
logger$8(`${propertyName} value is a stringified array of seedUids`);
|
|
4459
4496
|
return;
|
|
4460
4497
|
}
|
|
4461
4498
|
const storageTransactionId = await getStorageTransactionIdForSeedUid(propertyValue);
|
|
@@ -4895,7 +4932,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
4895
4932
|
if (propertyRecordSchema &&
|
|
4896
4933
|
propertyRecordSchema.storageType &&
|
|
4897
4934
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
4898
|
-
const { Item } = await import('./index-
|
|
4935
|
+
const { Item } = await import('./index-CPxn1SR4.js');
|
|
4899
4936
|
const item = await Item.find({
|
|
4900
4937
|
seedLocalId,
|
|
4901
4938
|
modelName,
|
|
@@ -4940,16 +4977,10 @@ const getVersionData = async ({ localId, seedLocalId, uid, }) => {
|
|
|
4940
4977
|
return queryRows[0];
|
|
4941
4978
|
};
|
|
4942
4979
|
|
|
4943
|
-
const logger$
|
|
4944
|
-
const sendItemUpdateEvent = ({ modelName, seedLocalId, seedUid }) => {
|
|
4945
|
-
if (!modelName || (!seedLocalId && !seedUid)) {
|
|
4946
|
-
return;
|
|
4947
|
-
}
|
|
4948
|
-
eventEmitter.emit(`item.${modelName}.${seedUid || seedLocalId}.update`);
|
|
4949
|
-
};
|
|
4980
|
+
const logger$7 = debug('app:write:updateItemPropertyValue');
|
|
4950
4981
|
const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUid, seedLocalId, modelName, refSeedType, refResolvedValue, refResolvedDisplayValue, versionLocalId, versionUid, schemaUid, localStorageDir, }) => {
|
|
4951
4982
|
if (!localId && !seedLocalId) {
|
|
4952
|
-
logger$
|
|
4983
|
+
logger$7(`[db/write] [updateItemPropertyValue] no propertyLocalId or seedLocalId for property: ${propertyName}`);
|
|
4953
4984
|
return;
|
|
4954
4985
|
}
|
|
4955
4986
|
let safeNewValue = newValue;
|
|
@@ -4987,7 +5018,7 @@ const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUi
|
|
|
4987
5018
|
modelType === modelName?.toLowerCase() &&
|
|
4988
5019
|
refSeedTypeFromDb === refSeedType &&
|
|
4989
5020
|
refResolvedValueFromDb === refResolvedValue) {
|
|
4990
|
-
logger$
|
|
5021
|
+
logger$7(`[db/write] [updateItemPropertyValue] value is the same as most recent record for property: ${propertyNameFromDb}`);
|
|
4991
5022
|
return;
|
|
4992
5023
|
}
|
|
4993
5024
|
// This means we already have a local-only record so we should just update that one
|
|
@@ -5000,7 +5031,6 @@ const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUi
|
|
|
5000
5031
|
updated_at = ${Date.now()}
|
|
5001
5032
|
WHERE local_id = '${localId}';`;
|
|
5002
5033
|
await appDb.run(sql.raw(updatePropertyStatement));
|
|
5003
|
-
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
5004
5034
|
return;
|
|
5005
5035
|
}
|
|
5006
5036
|
const seedDataFromDb = await getSeedData({ seedLocalId });
|
|
@@ -5038,7 +5068,6 @@ const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUi
|
|
|
5038
5068
|
${localStorageDir ? `'${localStorageDir}'` : 'NULL'},
|
|
5039
5069
|
${Date.now()});`;
|
|
5040
5070
|
await appDb.run(sql.raw(newPropertyStatement));
|
|
5041
|
-
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
5042
5071
|
return {
|
|
5043
5072
|
localId: newLocalId,
|
|
5044
5073
|
schemaUid,
|
|
@@ -5087,7 +5116,6 @@ const updateItemPropertyValue = async ({ localId, propertyName, newValue, seedUi
|
|
|
5087
5116
|
${localStorageDir ? `'${localStorageDir}'` : 'NULL'},
|
|
5088
5117
|
${Date.now()});`;
|
|
5089
5118
|
await appDb.run(sql.raw(newPropertyStatement));
|
|
5090
|
-
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
5091
5119
|
return {
|
|
5092
5120
|
localId: newLocalId,
|
|
5093
5121
|
schemaUid,
|
|
@@ -5204,17 +5232,20 @@ const createMetadata = async (metadataValues, propertyRecordSchema) => {
|
|
|
5204
5232
|
const queryClient = BaseQueryClient.getQueryClient();
|
|
5205
5233
|
const easClient = BaseEasClient.getEasClient();
|
|
5206
5234
|
const easDataType = INTERNAL_DATA_TYPES[propertyRecordSchema.dataType].eas;
|
|
5235
|
+
const propertyNameSnakeCase = toSnakeCase$1(metadataValues.propertyName);
|
|
5207
5236
|
const queryResult = await queryClient.fetchQuery({
|
|
5208
5237
|
queryKey: [`getSchemaByName${metadataValues.propertyName}`],
|
|
5209
5238
|
queryFn: async () => easClient.request(GET_SCHEMA_BY_NAME, {
|
|
5210
5239
|
where: {
|
|
5211
5240
|
schema: {
|
|
5212
|
-
equals: `${easDataType} ${
|
|
5241
|
+
equals: `${easDataType} ${propertyNameSnakeCase}`,
|
|
5213
5242
|
},
|
|
5214
5243
|
},
|
|
5215
5244
|
}),
|
|
5216
5245
|
});
|
|
5217
|
-
|
|
5246
|
+
if (queryResult && queryResult.schemas.length > 0) {
|
|
5247
|
+
metadataValues.schemaUid = queryResult.schemas[0].id;
|
|
5248
|
+
}
|
|
5218
5249
|
}
|
|
5219
5250
|
return appDb
|
|
5220
5251
|
.insert(metadata)
|
|
@@ -5384,7 +5415,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
|
|
|
5384
5415
|
refSeedType: 'image',
|
|
5385
5416
|
refSchemaUid: imageSchemaUid,
|
|
5386
5417
|
renderValue: refResolvedDisplayValue,
|
|
5387
|
-
refResolvedDisplayValue
|
|
5418
|
+
refResolvedDisplayValue,
|
|
5388
5419
|
refResolvedValue: fileName,
|
|
5389
5420
|
localStorageDir: '/images',
|
|
5390
5421
|
easDataType: 'bytes32',
|
|
@@ -5799,7 +5830,7 @@ const getPropertyData$1 = async ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
5799
5830
|
};
|
|
5800
5831
|
|
|
5801
5832
|
var _a$1;
|
|
5802
|
-
const logger$
|
|
5833
|
+
const logger$6 = debug('app:property:class');
|
|
5803
5834
|
class BaseItemProperty {
|
|
5804
5835
|
constructor(initialValues) {
|
|
5805
5836
|
this._isRelation = false;
|
|
@@ -5846,7 +5877,7 @@ class BaseItemProperty {
|
|
|
5846
5877
|
serviceInput.propertyValue = JSON.parse(propertyValue);
|
|
5847
5878
|
}
|
|
5848
5879
|
catch (e) {
|
|
5849
|
-
logger$
|
|
5880
|
+
logger$6('List property value is not JSON', e);
|
|
5850
5881
|
}
|
|
5851
5882
|
}
|
|
5852
5883
|
const propertyNameSingular = pluralize(propertyName, 1);
|
|
@@ -5884,16 +5915,16 @@ class BaseItemProperty {
|
|
|
5884
5915
|
context.localStorageDir) {
|
|
5885
5916
|
const filePath = `/files/${context.localStorageDir}/${context.refResolvedValue}`;
|
|
5886
5917
|
try {
|
|
5887
|
-
const exists = await fs
|
|
5918
|
+
const exists = await fs.promises.exists(filePath);
|
|
5888
5919
|
if (exists) {
|
|
5889
|
-
renderValue = await fs
|
|
5920
|
+
renderValue = await fs.promises.readFile(filePath, 'utf-8');
|
|
5890
5921
|
}
|
|
5891
5922
|
if (!exists) {
|
|
5892
5923
|
renderValue = 'No file found';
|
|
5893
5924
|
}
|
|
5894
5925
|
}
|
|
5895
5926
|
catch (e) {
|
|
5896
|
-
logger$
|
|
5927
|
+
logger$6(`[ItemProperty] [${context.seedLocalId}] [${context.propertyName}] [storageType] error`, e);
|
|
5897
5928
|
renderValue = 'No file found';
|
|
5898
5929
|
}
|
|
5899
5930
|
}
|
|
@@ -5916,12 +5947,13 @@ class BaseItemProperty {
|
|
|
5916
5947
|
return;
|
|
5917
5948
|
}
|
|
5918
5949
|
this._subject.next(renderValue);
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
}
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
}
|
|
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
|
+
// }
|
|
5925
5957
|
});
|
|
5926
5958
|
this._service.start();
|
|
5927
5959
|
}
|
|
@@ -6137,7 +6169,7 @@ const getSegmentedItemProperties = (item) => {
|
|
|
6137
6169
|
};
|
|
6138
6170
|
};
|
|
6139
6171
|
|
|
6140
|
-
const logger$
|
|
6172
|
+
const logger$5 = debug('app:item:getPublishUploads');
|
|
6141
6173
|
const prepareArweaveTransaction = async (data, contentHash) => {
|
|
6142
6174
|
const transactionData = {
|
|
6143
6175
|
data,
|
|
@@ -6145,8 +6177,8 @@ const prepareArweaveTransaction = async (data, contentHash) => {
|
|
|
6145
6177
|
};
|
|
6146
6178
|
const tx = await getArweave().createTransaction(transactionData);
|
|
6147
6179
|
if (contentHash) {
|
|
6148
|
-
logger$
|
|
6149
|
-
logger$
|
|
6180
|
+
logger$5('contentHash', contentHash);
|
|
6181
|
+
logger$5('adding content hash tag to tx.id:', tx.id);
|
|
6150
6182
|
tx.addTag('Content-SHA-256', contentHash);
|
|
6151
6183
|
}
|
|
6152
6184
|
return tx;
|
|
@@ -6342,7 +6374,7 @@ const processBasicProperties = async (itemBasicProperties, itemPublishData) => {
|
|
|
6342
6374
|
}
|
|
6343
6375
|
return itemPublishData;
|
|
6344
6376
|
};
|
|
6345
|
-
const processRelationProperty = async (relationProperty, multiPublishPayload, uploadedTransactions) => {
|
|
6377
|
+
const processRelationProperty = async (relationProperty, multiPublishPayload, uploadedTransactions, originalSeedLocalId) => {
|
|
6346
6378
|
const value = relationProperty.getService().getSnapshot()
|
|
6347
6379
|
.context.propertyValue;
|
|
6348
6380
|
if (!value || relationProperty.uid) {
|
|
@@ -6368,7 +6400,7 @@ const processRelationProperty = async (relationProperty, multiPublishPayload, up
|
|
|
6368
6400
|
listOfAttestations: [],
|
|
6369
6401
|
propertiesToUpdate: [
|
|
6370
6402
|
{
|
|
6371
|
-
publishLocalId:
|
|
6403
|
+
publishLocalId: originalSeedLocalId,
|
|
6372
6404
|
propertySchemaUid: relationProperty.schemaUid,
|
|
6373
6405
|
},
|
|
6374
6406
|
],
|
|
@@ -6388,7 +6420,7 @@ const processRelationProperty = async (relationProperty, multiPublishPayload, up
|
|
|
6388
6420
|
multiPublishPayload.push(publishPayload);
|
|
6389
6421
|
return multiPublishPayload;
|
|
6390
6422
|
};
|
|
6391
|
-
const processListProperty = async (listProperty, multiPublishPayload) => {
|
|
6423
|
+
const processListProperty = async (listProperty, multiPublishPayload, originalSeedLocalId) => {
|
|
6392
6424
|
let value = listProperty.getService().getSnapshot().context.propertyValue;
|
|
6393
6425
|
if (!value || listProperty.uid) {
|
|
6394
6426
|
return multiPublishPayload;
|
|
@@ -6431,7 +6463,7 @@ const processListProperty = async (listProperty, multiPublishPayload) => {
|
|
|
6431
6463
|
listOfAttestations: [],
|
|
6432
6464
|
propertiesToUpdate: [
|
|
6433
6465
|
{
|
|
6434
|
-
publishLocalId:
|
|
6466
|
+
publishLocalId: originalSeedLocalId,
|
|
6435
6467
|
propertySchemaUid: listProperty.schemaUid,
|
|
6436
6468
|
},
|
|
6437
6469
|
],
|
|
@@ -6469,14 +6501,15 @@ const getPublishPayload = async (item, uploadedTransactions) => {
|
|
|
6469
6501
|
}
|
|
6470
6502
|
}
|
|
6471
6503
|
for (const relationProperty of itemRelationProperties) {
|
|
6472
|
-
multiPublishPayload = await processRelationProperty(relationProperty, multiPublishPayload, uploadedTransactions);
|
|
6504
|
+
multiPublishPayload = await processRelationProperty(relationProperty, multiPublishPayload, uploadedTransactions, item.seedLocalId);
|
|
6473
6505
|
itemBasicProperties.push(relationProperty);
|
|
6474
6506
|
}
|
|
6475
|
-
itemPublishData = await processBasicProperties(itemBasicProperties, itemPublishData);
|
|
6476
|
-
multiPublishPayload.push(itemPublishData);
|
|
6477
6507
|
for (const listProperty of itemListProperties) {
|
|
6478
|
-
multiPublishPayload = await processListProperty(listProperty, multiPublishPayload);
|
|
6508
|
+
multiPublishPayload = await processListProperty(listProperty, multiPublishPayload, item.seedLocalId);
|
|
6509
|
+
itemBasicProperties.push(listProperty);
|
|
6479
6510
|
}
|
|
6511
|
+
itemPublishData = await processBasicProperties(itemBasicProperties, itemPublishData);
|
|
6512
|
+
multiPublishPayload.push(itemPublishData);
|
|
6480
6513
|
return multiPublishPayload;
|
|
6481
6514
|
};
|
|
6482
6515
|
|
|
@@ -6591,7 +6624,7 @@ class BaseItem {
|
|
|
6591
6624
|
propertiesObj[transformedKey] = propertyInstance;
|
|
6592
6625
|
}
|
|
6593
6626
|
this._propertiesSubject.next(propertiesObj);
|
|
6594
|
-
eventEmitter.emit(`item.${modelName}.${seedUid || seedLocalId}.update`)
|
|
6627
|
+
// eventEmitter.emit(`item.${modelName}.${seedUid || seedLocalId}.update`)
|
|
6595
6628
|
});
|
|
6596
6629
|
this._service.start();
|
|
6597
6630
|
const definedKeys = ['ModelClass'];
|
|
@@ -6832,7 +6865,7 @@ const initItem = async () => {
|
|
|
6832
6865
|
Item$2 = (await Promise.resolve().then(function () { return Item$1; })).Item;
|
|
6833
6866
|
}
|
|
6834
6867
|
if (!isBrowser()) {
|
|
6835
|
-
Item$2 = (await import('./Item-
|
|
6868
|
+
Item$2 = (await import('./Item-BmPvgaG4.js')).Item;
|
|
6836
6869
|
}
|
|
6837
6870
|
};
|
|
6838
6871
|
|
|
@@ -6842,17 +6875,17 @@ const initItemProperty = async () => {
|
|
|
6842
6875
|
ItemProperty$2 = (await Promise.resolve().then(function () { return ItemProperty$1; })).ItemProperty;
|
|
6843
6876
|
}
|
|
6844
6877
|
if (!isBrowser()) {
|
|
6845
|
-
ItemProperty$2 = (await import('./ItemProperty-
|
|
6878
|
+
ItemProperty$2 = (await import('./ItemProperty-BW4k1h0o.js')).ItemProperty;
|
|
6846
6879
|
}
|
|
6847
6880
|
};
|
|
6848
6881
|
|
|
6849
6882
|
let Db;
|
|
6850
6883
|
const initDb = async () => {
|
|
6851
6884
|
if (isBrowser()) {
|
|
6852
|
-
Db = (await import('./Db-
|
|
6885
|
+
Db = (await import('./Db-5C5VqRWb.js')).Db;
|
|
6853
6886
|
}
|
|
6854
6887
|
if (!isBrowser()) {
|
|
6855
|
-
Db = (await import('./Db-
|
|
6888
|
+
Db = (await import('./Db-Dv890NJZ.js')).Db;
|
|
6856
6889
|
}
|
|
6857
6890
|
// TODO: Add config for React Native
|
|
6858
6891
|
};
|
|
@@ -6869,7 +6902,7 @@ var Item$1 = /*#__PURE__*/Object.freeze({
|
|
|
6869
6902
|
Item: Item
|
|
6870
6903
|
});
|
|
6871
6904
|
|
|
6872
|
-
const logger$
|
|
6905
|
+
const logger$4 = debug('app:react:services');
|
|
6873
6906
|
const finalStrings = ['idle', 'ready', 'done', 'success', 'initialized'];
|
|
6874
6907
|
const getServiceName = (service) => {
|
|
6875
6908
|
let name = 'actor';
|
|
@@ -6916,7 +6949,7 @@ const getServiceUniqueKey = (service) => {
|
|
|
6916
6949
|
snapshot = service.getSnapshot();
|
|
6917
6950
|
}
|
|
6918
6951
|
catch (error) {
|
|
6919
|
-
logger$
|
|
6952
|
+
logger$4('Error:', error);
|
|
6920
6953
|
return uniqueKey;
|
|
6921
6954
|
}
|
|
6922
6955
|
if (snapshot) {
|
|
@@ -7145,7 +7178,7 @@ const useGlobalServiceStatus = () => {
|
|
|
7145
7178
|
};
|
|
7146
7179
|
};
|
|
7147
7180
|
|
|
7148
|
-
const logger$
|
|
7181
|
+
const logger$3 = debug('app:react:item');
|
|
7149
7182
|
const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
7150
7183
|
// const [itemSubscription, setItemSubscription] = useState<
|
|
7151
7184
|
// Subscription | undefined
|
|
@@ -7222,7 +7255,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
7222
7255
|
seedUid,
|
|
7223
7256
|
});
|
|
7224
7257
|
if (!foundItem) {
|
|
7225
|
-
logger$
|
|
7258
|
+
logger$3('[useItem] [getItemFromDb] no item found', modelName, seedLocalId);
|
|
7226
7259
|
isReadingDb.current = false;
|
|
7227
7260
|
return;
|
|
7228
7261
|
}
|
|
@@ -7244,7 +7277,7 @@ const useItem = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
7244
7277
|
const subscription = item.subscribe(async (_) => {
|
|
7245
7278
|
const newItem = await Item.find({ modelName, seedLocalId, seedUid });
|
|
7246
7279
|
if (!newItem) {
|
|
7247
|
-
logger$
|
|
7280
|
+
logger$3('[useItem] [itemSubscription] no item found', modelName, seedLocalId);
|
|
7248
7281
|
return;
|
|
7249
7282
|
}
|
|
7250
7283
|
updateItem(newItem);
|
|
@@ -7402,8 +7435,13 @@ var ItemProperty$1 = /*#__PURE__*/Object.freeze({
|
|
|
7402
7435
|
ItemProperty: ItemProperty
|
|
7403
7436
|
});
|
|
7404
7437
|
|
|
7405
|
-
const logger$
|
|
7406
|
-
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;
|
|
7407
7445
|
const [property, setProperty] = useState();
|
|
7408
7446
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
7409
7447
|
const { internalStatus } = useGlobalServiceStatus();
|
|
@@ -7428,7 +7466,7 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
7428
7466
|
seedUid,
|
|
7429
7467
|
});
|
|
7430
7468
|
if (!foundProperty) {
|
|
7431
|
-
logger$
|
|
7469
|
+
logger$2(`[useItemPropertyTest] [readFromDb] no property found for Item.${seedLocalId}.${propertyName}`);
|
|
7432
7470
|
isReadingDb.current = false;
|
|
7433
7471
|
return;
|
|
7434
7472
|
}
|
|
@@ -7438,11 +7476,11 @@ const useItemProperty = ({ propertyName, seedLocalId, seedUid, }) => {
|
|
|
7438
7476
|
setProperty(foundProperty);
|
|
7439
7477
|
setIsInitialized(true);
|
|
7440
7478
|
isReadingDb.current = false;
|
|
7441
|
-
}, [internalStatus]);
|
|
7479
|
+
}, [internalStatus, props]);
|
|
7442
7480
|
const listenerRef = useRef(readFromDb);
|
|
7443
7481
|
useEffect(() => {
|
|
7444
7482
|
listenerRef.current = readFromDb;
|
|
7445
|
-
}, [readFromDb]);
|
|
7483
|
+
}, [readFromDb, props]);
|
|
7446
7484
|
useEffect(() => {
|
|
7447
7485
|
if (internalStatus === 'ready') {
|
|
7448
7486
|
readFromDb();
|
|
@@ -7600,10 +7638,10 @@ const withSeed = (config, webpack, isServer) => {
|
|
|
7600
7638
|
return config;
|
|
7601
7639
|
};
|
|
7602
7640
|
|
|
7603
|
-
const logger = debug('app:services:events');
|
|
7641
|
+
const logger$1 = debug('app:services:events');
|
|
7604
7642
|
const handleServiceSaveState = (event) => {
|
|
7605
7643
|
const { state, serviceId } = event;
|
|
7606
|
-
logger(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
|
|
7644
|
+
logger$1(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
|
|
7607
7645
|
localStorage.setItem(`seed_sdk_service_${serviceId}`, JSON.stringify(state));
|
|
7608
7646
|
};
|
|
7609
7647
|
const setupServicesEventHandlers = () => {
|
|
@@ -7649,15 +7687,22 @@ const initQueryClient = async () => {
|
|
|
7649
7687
|
|
|
7650
7688
|
const initFileManager = async () => {
|
|
7651
7689
|
if (isBrowser()) {
|
|
7652
|
-
(await import('./FileManager-
|
|
7690
|
+
(await import('./FileManager-AhAsy_F_.js')).FileManager;
|
|
7653
7691
|
}
|
|
7654
7692
|
if (!isBrowser()) {
|
|
7655
7693
|
(await import('./FileManager-COOp89Mj.js')).FileManager;
|
|
7656
7694
|
}
|
|
7657
7695
|
};
|
|
7658
7696
|
|
|
7697
|
+
const logger = debug('app:client');
|
|
7659
7698
|
const client = {
|
|
7699
|
+
isInitialized: false,
|
|
7660
7700
|
init: async (options) => {
|
|
7701
|
+
logger('init client');
|
|
7702
|
+
if (client.isInitialized) {
|
|
7703
|
+
return;
|
|
7704
|
+
}
|
|
7705
|
+
client.isInitialized = true;
|
|
7661
7706
|
const { config, addresses } = options;
|
|
7662
7707
|
await initItem();
|
|
7663
7708
|
await initItemProperty();
|
|
@@ -7691,7 +7736,7 @@ const client = {
|
|
|
7691
7736
|
arweaveDomain,
|
|
7692
7737
|
filesDir,
|
|
7693
7738
|
});
|
|
7694
|
-
const { models: internalModels } = await import('./seed.schema.config-
|
|
7739
|
+
const { models: internalModels } = await import('./seed.schema.config-BXWvwsZQ.js');
|
|
7695
7740
|
for (const [key, value] of Object.entries(internalModels)) {
|
|
7696
7741
|
setModel(key, value);
|
|
7697
7742
|
}
|
|
@@ -7739,4 +7784,4 @@ const client = {
|
|
|
7739
7784
|
enableMapSet();
|
|
7740
7785
|
|
|
7741
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 };
|
|
7742
|
-
//# sourceMappingURL=index-
|
|
7787
|
+
//# sourceMappingURL=index-CGeSKilQ.js.map
|