@seedprotocol/sdk 0.2.1 → 0.2.3
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/Item-D_fRE67b.js +40 -0
- package/dist/Item-D_fRE67b.js.map +1 -0
- package/dist/ItemProperty-l0sNRNKZ.js +2 -0
- package/dist/ItemProperty-l0sNRNKZ.js.map +1 -0
- package/dist/bin.js +35 -3
- package/dist/bin.js.map +1 -1
- package/dist/constants-CtWTDW5q.js +168 -0
- package/dist/constants-CtWTDW5q.js.map +1 -0
- package/dist/{index-DaK2dz5P.js → index-CaMCzFrd.js} +226 -332
- package/dist/index-CaMCzFrd.js.map +1 -0
- package/dist/{index-B5qzD-bs.js → index-DpAde4Hk.js} +6 -8
- package/dist/index-DpAde4Hk.js.map +1 -0
- package/dist/main.js +3 -5
- package/dist/main.js.map +1 -1
- package/dist/node/db/node.app.db.config.ts +2 -2
- package/dist/{seed.schema.config-DIMmvqJf.js → seed.schema.config-DrU0-rhL.js} +7 -9
- package/dist/seed.schema.config-DrU0-rhL.js.map +1 -0
- package/dist/seedSchema/AppStateSchema.ts +10 -0
- package/dist/seedSchema/ConfigSchema.ts +15 -0
- package/dist/seedSchema/MetadataSchema.ts +28 -0
- package/dist/seedSchema/ModelSchema.ts +46 -0
- package/dist/seedSchema/ModelUidSchema.ts +16 -0
- package/dist/seedSchema/PropertyUidSchema.ts +16 -0
- package/dist/seedSchema/SeedSchema.ts +29 -0
- package/dist/seedSchema/VersionSchema.ts +16 -0
- package/dist/seedSchema/index.ts +8 -0
- package/dist/src/ArweaveClientNode.ts +13 -0
- package/dist/src/BaseItem.ts +1 -1
- package/dist/src/BaseItemProperty.ts +1 -1
- package/dist/src/EasClientNode.ts +13 -0
- package/dist/src/FileManagerNode.ts +31 -0
- package/dist/src/IItemProperty.ts +1 -1
- package/dist/src/ItemProperty.ts +0 -16
- package/dist/src/QueryClientNode.ts +24 -0
- package/dist/src/SeedProtocolSdk.d.ts +1 -1
- package/dist/src/client.ts +12 -6
- package/dist/src/create.ts +1 -1
- package/dist/src/fetchDbData.ts +7 -4
- package/dist/src/fetchSeeds.ts +5 -2
- package/dist/src/fetchVersions.ts +5 -2
- package/dist/src/getItem.ts +1 -1
- package/dist/src/getPropertyData.ts +1 -1
- package/dist/src/getPublishPayload.ts +1 -1
- package/dist/src/globalMachine.ts +1 -1
- package/dist/src/hydrateFromDb.ts +1 -1
- package/dist/src/initialize.ts +88 -238
- package/dist/src/itemMachineAll.ts +6 -7
- package/dist/src/node.app.db.config.ts +2 -2
- package/dist/src/preparePublishRequestData.ts +1 -1
- package/dist/src/processItems.ts +5 -2
- package/dist/src/property.ts +2 -2
- package/dist/src/requestAll.ts +1 -1
- package/dist/src/trash.ts +1 -1
- package/dist/types/scripts/bin.d.ts +4 -0
- package/dist/types/scripts/bin.d.ts.map +1 -1
- package/dist/types/src/Item/index.d.ts +5 -0
- package/dist/types/src/Item/index.d.ts.map +1 -0
- 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/index.d.ts +5 -0
- package/dist/types/src/ItemProperty/index.d.ts.map +1 -0
- package/dist/types/src/browser/{item → Item}/Item.d.ts.map +1 -1
- package/dist/types/src/browser/Item/index.d.ts +2 -0
- package/dist/types/src/browser/Item/index.d.ts.map +1 -0
- package/dist/types/src/browser/{item → ItemProperty}/ItemProperty.d.ts +2 -1
- package/dist/types/src/browser/ItemProperty/ItemProperty.d.ts.map +1 -0
- package/dist/types/src/browser/{property → ItemProperty}/index.d.ts +1 -1
- package/dist/types/src/browser/ItemProperty/index.d.ts.map +1 -0
- package/dist/types/src/browser/index.d.ts +2 -3
- package/dist/types/src/browser/index.d.ts.map +1 -1
- package/dist/types/src/browser/react/item.d.ts +1 -1
- package/dist/types/src/browser/react/property.d.ts +1 -1
- package/dist/types/src/browser/react/trash.d.ts +1 -1
- package/dist/types/src/browser/schema/index.d.ts +2 -2
- package/dist/types/src/browser/schema/index.d.ts.map +1 -1
- package/dist/types/src/browser/schema/model/index.d.ts +1 -1
- package/dist/types/src/{browser/client.d.ts → client.d.ts} +1 -1
- package/dist/types/src/client.d.ts.map +1 -0
- package/dist/types/src/db/read/getPublishPayload.d.ts +1 -1
- package/dist/types/src/helpers/constants.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +4 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/interfaces/IItemProperty.d.ts +1 -1
- package/dist/types/src/interfaces/IItemProperty.d.ts.map +1 -1
- package/dist/types/src/node/{item → Item}/Item.d.ts.map +1 -1
- package/dist/types/src/node/ItemProperty/ItemProperty.d.ts +1 -0
- package/dist/types/src/node/ItemProperty/ItemProperty.d.ts.map +1 -0
- package/dist/types/src/node/helpers/ArweaveClientNode.d.ts +7 -0
- package/dist/types/src/node/helpers/ArweaveClientNode.d.ts.map +1 -0
- package/dist/types/src/node/helpers/EasClientNode.d.ts +7 -0
- package/dist/types/src/node/helpers/EasClientNode.d.ts.map +1 -0
- package/dist/types/src/node/helpers/FileManagerNode.d.ts +9 -0
- package/dist/types/src/node/helpers/FileManagerNode.d.ts.map +1 -0
- package/dist/types/src/node/helpers/QueryClientNode.d.ts +9 -0
- package/dist/types/src/node/helpers/QueryClientNode.d.ts.map +1 -0
- package/dist/types/src/services/allItems/actors/fetchDbData.d.ts +4 -0
- package/dist/types/src/services/allItems/actors/fetchDbData.d.ts.map +1 -0
- package/dist/types/src/services/allItems/actors/fetchRelatedItems.d.ts.map +1 -0
- package/dist/types/src/services/allItems/actors/fetchSeeds.d.ts +4 -0
- package/dist/types/src/services/allItems/actors/fetchSeeds.d.ts.map +1 -0
- package/dist/types/src/services/allItems/actors/fetchVersions.d.ts +4 -0
- package/dist/types/src/services/allItems/actors/fetchVersions.d.ts.map +1 -0
- package/dist/types/src/services/allItems/actors/initialize.d.ts.map +1 -0
- package/dist/types/src/services/allItems/actors/processItems.d.ts +4 -0
- package/dist/types/src/services/allItems/actors/processItems.d.ts.map +1 -0
- package/dist/types/src/services/allItems/itemMachineAll.d.ts +67 -0
- package/dist/types/src/services/allItems/itemMachineAll.d.ts.map +1 -0
- package/dist/types/src/types/item.d.ts +5 -5
- package/dist/types/src/types/item.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/constants-B6s6tGup.js +0 -65
- package/dist/constants-B6s6tGup.js.map +0 -1
- package/dist/index-B5qzD-bs.js.map +0 -1
- package/dist/index-DaK2dz5P.js.map +0 -1
- package/dist/seed.schema.config-DIMmvqJf.js.map +0 -1
- package/dist/src/init.ts +0 -61
- package/dist/types/src/browser/client.d.ts.map +0 -1
- package/dist/types/src/browser/item/ItemProperty.d.ts.map +0 -1
- package/dist/types/src/browser/item/all/actors/fetchDbData.d.ts +0 -2
- package/dist/types/src/browser/item/all/actors/fetchDbData.d.ts.map +0 -1
- package/dist/types/src/browser/item/all/actors/fetchRelatedItems.d.ts.map +0 -1
- package/dist/types/src/browser/item/all/actors/fetchSeeds.d.ts +0 -2
- package/dist/types/src/browser/item/all/actors/fetchSeeds.d.ts.map +0 -1
- package/dist/types/src/browser/item/all/actors/fetchVersions.d.ts +0 -2
- package/dist/types/src/browser/item/all/actors/fetchVersions.d.ts.map +0 -1
- package/dist/types/src/browser/item/all/actors/initialize.d.ts.map +0 -1
- package/dist/types/src/browser/item/all/actors/processItems.d.ts +0 -2
- package/dist/types/src/browser/item/all/actors/processItems.d.ts.map +0 -1
- package/dist/types/src/browser/item/all/itemMachineAll.d.ts +0 -2
- package/dist/types/src/browser/item/all/itemMachineAll.d.ts.map +0 -1
- package/dist/types/src/browser/item/index.d.ts +0 -3
- package/dist/types/src/browser/item/index.d.ts.map +0 -1
- package/dist/types/src/browser/property/index.d.ts.map +0 -1
- package/dist/types/src/init.d.ts +0 -6
- package/dist/types/src/init.d.ts.map +0 -1
- package/dist/types/src/seed.d.ts +0 -1
- package/dist/types/src/seed.d.ts.map +0 -1
- /package/dist/types/src/browser/{item → Item}/Item.d.ts +0 -0
- /package/dist/types/src/node/{item → Item}/Item.d.ts +0 -0
- /package/dist/types/src/{browser/item/all → services/allItems}/actors/fetchRelatedItems.d.ts +0 -0
- /package/dist/types/src/{browser/item/all → services/allItems}/actors/initialize.d.ts +0 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { immerable, produce, enableMapSet } from 'immer';
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
+
import { __awaiter, __rest } from 'tslib';
|
|
3
4
|
import { Type } from '@sinclair/typebox';
|
|
4
5
|
import { fromCallback, setup, assign, waitFor, createActor, raise } from 'xstate';
|
|
5
6
|
import { BehaviorSubject } from 'rxjs';
|
|
6
|
-
import { immerable, produce, enableMapSet } from 'immer';
|
|
7
7
|
import fs$1, { fs, configureSingle } from '@zenfs/core';
|
|
8
8
|
import 'dayjs';
|
|
9
9
|
import { customAlphabet } from 'nanoid';
|
|
10
10
|
import * as nanoIdDictionary from 'nanoid-dictionary';
|
|
11
11
|
import debug from 'debug';
|
|
12
|
+
import { B as BaseEasClient, a as BaseQueryClient, I as INTERNAL_DATA_TYPES, G as GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY, d as GLOBAL_INITIALIZING_SEND_CONFIG, e as GLOBAL_INITIALIZING_CREATE_ALL_ITEMS_SERVICES, f as GLOBAL_ADDING_MODELS_TO_DB_SUCCESS, D as DB_CHECK_STATUS_UPDATE_PATHS, g as DB_CHECK_STATUS_EXISTS, h as BROWSER_FS_TOP_DIR, i as DB_CREATING_SUCCESS, j as DB_VALIDATING_SUCCESS, k as DB_VALIDATING_WAIT, l as DB_MIGRATING_SUCCESS, M as MachineIds, m as DB_WAITING_FOR_FILES_RECEIVED, n as DB_MIGRATING_WAIT, o as DbState, p as INTERNAL_VALIDATING_INPUT_SUCCESS, b as BaseArweaveClient, q as ARWEAVE_HOST, 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, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, y as defaultAttestationData, z as internalPropertyNames } from './constants-CtWTDW5q.js';
|
|
12
13
|
import { sqliteTable, text, int, blob, check, unique } from 'drizzle-orm/sqlite-core';
|
|
13
14
|
import { sql, relations, and, eq, max, or, isNotNull, not, inArray, like, isNull, getTableColumns, count, gt } from 'drizzle-orm';
|
|
14
15
|
import path from 'path';
|
|
15
16
|
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
16
17
|
import pluralize from 'pluralize';
|
|
17
18
|
import EventEmitter from 'eventemitter3';
|
|
18
|
-
import { throttle, camelCase, startCase, orderBy
|
|
19
|
-
import { I as INTERNAL_DATA_TYPES, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, d as defaultAttestationData, i as internalPropertyNames } from './constants-B6s6tGup.js';
|
|
19
|
+
import { throttle, camelCase, startCase, orderBy } from 'lodash-es';
|
|
20
20
|
import { createBrowserInspector } from '@statelyai/inspect';
|
|
21
21
|
import { drizzle } from 'drizzle-orm/sqlite-proxy';
|
|
22
22
|
import { migrate as migrate$1 } from 'drizzle-orm/sqlite-proxy/migrator';
|
|
@@ -26,84 +26,8 @@ import { WebAccess } from '@zenfs/dom';
|
|
|
26
26
|
import Arweave from 'arweave';
|
|
27
27
|
import { useImmer } from 'use-immer';
|
|
28
28
|
import { useSelector } from '@xstate/react';
|
|
29
|
-
import { startCase as startCase$1, orderBy } from 'lodash';
|
|
30
29
|
import { ZERO_BYTES32, SchemaEncoder } from '@ethereum-attestation-service/eas-sdk';
|
|
31
30
|
|
|
32
|
-
const isNode = () => {
|
|
33
|
-
return (typeof process !== 'undefined' &&
|
|
34
|
-
process.versions != null &&
|
|
35
|
-
process.versions.node != null);
|
|
36
|
-
};
|
|
37
|
-
const isReactNative = () => {
|
|
38
|
-
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const withSeed$1 = (config, webpack, isServer) => {
|
|
42
|
-
// If you need to include directories outside of the project root
|
|
43
|
-
// config.module.rules.push({
|
|
44
|
-
// test: /\.ts$/,
|
|
45
|
-
// include: [path.resolve(process.cwd(), 'schema.ts')],
|
|
46
|
-
// use: 'ts-loader',
|
|
47
|
-
// })
|
|
48
|
-
config.plugins.push(
|
|
49
|
-
// new webpack.DefinePlugin({
|
|
50
|
-
// __dirname: JSON.stringify(__dirname),
|
|
51
|
-
// }),
|
|
52
|
-
new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
|
|
53
|
-
resource.request = resource.request.replace(/^node:/, '');
|
|
54
|
-
}));
|
|
55
|
-
// config.externals.push({
|
|
56
|
-
// 'fsevents': 'commonjs2 fsevents',
|
|
57
|
-
// })
|
|
58
|
-
// console.log('__dirname:', __dirname)
|
|
59
|
-
// console.log('process.cwd():', process.cwd())
|
|
60
|
-
// console.log('crypto-browserify exists:', fs.existsSync(path.resolve(process.cwd(), './node_modules/crypto-browserify')))
|
|
61
|
-
// console.log('path-browserify exists:', fs.existsSync(path.resolve(process.cwd(), './node_modules/path-browserify')))
|
|
62
|
-
if (!isServer) {
|
|
63
|
-
config.resolve.alias['fs'] = '@zenfs/core';
|
|
64
|
-
config.resolve.alias['node:fs'] = '@zenfs/core';
|
|
65
|
-
config.resolve.alias['node:path'] = 'path-browserify';
|
|
66
|
-
config.resolve.alias['path'] = 'path-browserify';
|
|
67
|
-
// config.resolve.alias['fs'] = path.resolve(
|
|
68
|
-
// process.cwd(),
|
|
69
|
-
// './node_modules/@zenfs/core',
|
|
70
|
-
// )
|
|
71
|
-
// config.resolve.alias['node:fs'] = path.resolve(
|
|
72
|
-
// process.cwd(),
|
|
73
|
-
// './node_modules/@zenfs/core',
|
|
74
|
-
// )
|
|
75
|
-
// config.resolve.alias['@schema'] = path.resolve(process.cwd(), 'schema.ts')
|
|
76
|
-
// // config.resolve.alias['crypto'] = path.resolve(process.cwd(), './node_modules/crypto-browserify')
|
|
77
|
-
// // config.resolve.alias['node:crypto'] = path.resolve(process.cwd(), './node_modules/crypto-browserify')
|
|
78
|
-
// config.resolve.alias['node:path'] = path.resolve(
|
|
79
|
-
// process.cwd(),
|
|
80
|
-
// './node_modules/path-browserify',
|
|
81
|
-
// )
|
|
82
|
-
// config.resolve.alias['path'] = path.resolve(
|
|
83
|
-
// process.cwd(),
|
|
84
|
-
// './node_modules/path-browserify',
|
|
85
|
-
// )
|
|
86
|
-
}
|
|
87
|
-
if (isServer) {
|
|
88
|
-
config.externals.push('@sqlite.org/sqlite-wasm');
|
|
89
|
-
config.externals.push('nunjucks');
|
|
90
|
-
config.externals.push('chokidar');
|
|
91
|
-
config.externals.push('arweave');
|
|
92
|
-
}
|
|
93
|
-
// config.module.rules.push({
|
|
94
|
-
// test: /seed\.config\.mjs$/,
|
|
95
|
-
// use: [
|
|
96
|
-
// {
|
|
97
|
-
// loader: 'babel-loader',
|
|
98
|
-
// options: {
|
|
99
|
-
// plugins: ['@babel/plugin-syntax-dynamic-import'],
|
|
100
|
-
// },
|
|
101
|
-
// },
|
|
102
|
-
// ],
|
|
103
|
-
// })
|
|
104
|
-
return config;
|
|
105
|
-
};
|
|
106
|
-
|
|
107
31
|
const modelStore = new Map();
|
|
108
32
|
const getModels = () => {
|
|
109
33
|
return Object.fromEntries(modelStore);
|
|
@@ -209,33 +133,6 @@ const waitForDb$1 = fromCallback(({ sendBack }) => {
|
|
|
209
133
|
});
|
|
210
134
|
});
|
|
211
135
|
|
|
212
|
-
class BaseArweaveClient {
|
|
213
|
-
static setPlatformClass(platformClass) {
|
|
214
|
-
this.PlatformClass = platformClass;
|
|
215
|
-
}
|
|
216
|
-
static getArweaveClient() {
|
|
217
|
-
return this.PlatformClass.getArweaveClient();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
class BaseEasClient {
|
|
222
|
-
static setPlatformClass(platformClass) {
|
|
223
|
-
this.PlatformClass = platformClass;
|
|
224
|
-
}
|
|
225
|
-
static getEasClient() {
|
|
226
|
-
return this.PlatformClass.getEasClient();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
class BaseQueryClient {
|
|
231
|
-
static setPlatformClass(platformClass) {
|
|
232
|
-
this.PlatformClass = platformClass;
|
|
233
|
-
}
|
|
234
|
-
static getQueryClient() {
|
|
235
|
-
return this.PlatformClass.getQueryClient();
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
136
|
class BaseFileManager {
|
|
240
137
|
static setPlatformClass(platformClass) {
|
|
241
138
|
this.PlatformClass = platformClass;
|
|
@@ -1374,7 +1271,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1374
1271
|
if (propertyRecordSchema &&
|
|
1375
1272
|
propertyRecordSchema.storageType &&
|
|
1376
1273
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
1377
|
-
const { Item } = yield import('./index-
|
|
1274
|
+
const { Item } = yield import('./index-DpAde4Hk.js');
|
|
1378
1275
|
const item = yield Item.find({
|
|
1379
1276
|
seedLocalId,
|
|
1380
1277
|
modelName,
|
|
@@ -1584,82 +1481,6 @@ const createNewItem$1 = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
1584
1481
|
};
|
|
1585
1482
|
});
|
|
1586
1483
|
|
|
1587
|
-
var MachineIds;
|
|
1588
|
-
(function (MachineIds) {
|
|
1589
|
-
MachineIds["GLOBAL"] = "@seedSdk/global";
|
|
1590
|
-
MachineIds["INTERNAL"] = "@seedSdk/internal";
|
|
1591
|
-
MachineIds["DB"] = "@seedSdk/db";
|
|
1592
|
-
MachineIds["EAS"] = "@seedSdk/eas";
|
|
1593
|
-
MachineIds["ITEM"] = "@seedSdk/item";
|
|
1594
|
-
MachineIds["ALL_ITEMS"] = "@seedSdk/allItems";
|
|
1595
|
-
MachineIds["MODEL"] = "@seedSdk/model";
|
|
1596
|
-
MachineIds["FILE_SYSTEM"] = "@seedSdk/fileSystem";
|
|
1597
|
-
})(MachineIds || (MachineIds = {}));
|
|
1598
|
-
const { INTERNAL, DB, GLOBAL, EAS, MODEL } = MachineIds;
|
|
1599
|
-
var GlobalState;
|
|
1600
|
-
(function (GlobalState) {
|
|
1601
|
-
GlobalState["UNINITIALIZED"] = "uninitialized";
|
|
1602
|
-
GlobalState["INITIALIZING"] = "initializing";
|
|
1603
|
-
GlobalState["INITIALIZED"] = "initialized";
|
|
1604
|
-
GlobalState["PUBLISHING_ITEM"] = "publishingItem";
|
|
1605
|
-
GlobalState["ADDING_MODELS_TO_DB"] = "addingModelsToDb";
|
|
1606
|
-
})(GlobalState || (GlobalState = {}));
|
|
1607
|
-
const { UNINITIALIZED: UNINITIALIZED$1, INITIALIZING: INITIALIZING$1, INITIALIZED: INITIALIZED$1, PUBLISHING_ITEM: PUBLISHING_ITEM$1, ADDING_MODELS_TO_DB: ADDING_MODELS_TO_DB$1, } = GlobalState;
|
|
1608
|
-
var InternalState;
|
|
1609
|
-
(function (InternalState) {
|
|
1610
|
-
InternalState["IDLE"] = "idle";
|
|
1611
|
-
InternalState["INITIALIZING"] = "initializing";
|
|
1612
|
-
InternalState["VALIDATING_INPUT"] = "validatingInput";
|
|
1613
|
-
InternalState["CONFIGURING_FS"] = "configuringFs";
|
|
1614
|
-
InternalState["LOADING_SEED_DB"] = "loadingSeedDb";
|
|
1615
|
-
InternalState["SAVING_CONFIG"] = "savingConfig";
|
|
1616
|
-
InternalState["LOADING_APP_DB"] = "loadingAppDb";
|
|
1617
|
-
InternalState["LOADING_SDK_DB"] = "loadingSdkDb";
|
|
1618
|
-
})(InternalState || (InternalState = {}));
|
|
1619
|
-
const { VALIDATING_INPUT: VALIDATING_INPUT$1, CONFIGURING_FS: CONFIGURING_FS$1, LOADING_SEED_DB, LOADING_APP_DB: LOADING_APP_DB$1 } = InternalState;
|
|
1620
|
-
var DbState;
|
|
1621
|
-
(function (DbState) {
|
|
1622
|
-
DbState["CHECKING_STATUS"] = "checkingStatus";
|
|
1623
|
-
DbState["WAITING_FOR_FILES"] = "waitingForFiles";
|
|
1624
|
-
DbState["VALIDATING"] = "validating";
|
|
1625
|
-
DbState["CONNECTING_TO_DB"] = "connectingToDb";
|
|
1626
|
-
// FETCHING_MIGRATIONS = 'fetchingMigrations',
|
|
1627
|
-
DbState["MIGRATING"] = "migrating";
|
|
1628
|
-
})(DbState || (DbState = {}));
|
|
1629
|
-
const { CHECKING_STATUS: CHECKING_STATUS$1, VALIDATING: VALIDATING$1, CONNECTING_TO_DB: CONNECTING_TO_DB$1, WAITING_FOR_FILES: WAITING_FOR_FILES$1, MIGRATING: MIGRATING$1, } = DbState;
|
|
1630
|
-
var PublishMachineStates;
|
|
1631
|
-
(function (PublishMachineStates) {
|
|
1632
|
-
PublishMachineStates["VALIDATING_ITEM_DATA"] = "validatingItemData";
|
|
1633
|
-
PublishMachineStates["CREATING_PUBLISH_ATTEMPT"] = "creatingPublishAttempt";
|
|
1634
|
-
PublishMachineStates["UPLOADING"] = "uploading";
|
|
1635
|
-
PublishMachineStates["PREPARING_PUBLISH_REQUEST_DATA"] = "preparingPublishRequestData";
|
|
1636
|
-
PublishMachineStates["PUBLISHING"] = "publishing";
|
|
1637
|
-
PublishMachineStates["IDLE"] = "idle";
|
|
1638
|
-
})(PublishMachineStates || (PublishMachineStates = {}));
|
|
1639
|
-
const INTERNAL_VALIDATING_INPUT_SUCCESS = `${INTERNAL}.${VALIDATING_INPUT$1}.success`;
|
|
1640
|
-
const INTERNAL_CONFIGURING_FS_SUCCESS = `${INTERNAL}.${CONFIGURING_FS$1}.success`;
|
|
1641
|
-
const INTERNAL_LOADING_APP_DB_SUCCESS = `${INTERNAL}.${LOADING_APP_DB$1}.success`;
|
|
1642
|
-
const INTERNAL_SAVING_CONFIG_SUCCESS = `${INTERNAL}.savingConfig.success`;
|
|
1643
|
-
const GLOBAL_INITIALIZING_SEND_CONFIG = `${GLOBAL}.${INITIALIZING$1}.sendConfig`;
|
|
1644
|
-
const GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY = `${GLOBAL}.${INITIALIZING$1}.internalServiceReady`;
|
|
1645
|
-
const GLOBAL_INITIALIZING_CREATE_ALL_ITEMS_SERVICES = `${GLOBAL}.${INITIALIZING$1}.createAllItemsServices`;
|
|
1646
|
-
const GLOBAL_ADDING_MODELS_TO_DB_SUCCESS = `${GLOBAL}.${ADDING_MODELS_TO_DB$1}.success`;
|
|
1647
|
-
const DB_CHECK_STATUS_UPDATE_PATHS = `${DB}.${CHECKING_STATUS$1}.updatePaths`;
|
|
1648
|
-
const DB_CHECK_STATUS_EXISTS = `${DB}.${CHECKING_STATUS$1}.exists`;
|
|
1649
|
-
const DB_VALIDATING_SUCCESS = `${DB}.${VALIDATING$1}.success`;
|
|
1650
|
-
const DB_VALIDATING_WAIT = `${DB}.${VALIDATING$1}.wait`;
|
|
1651
|
-
const DB_MIGRATING_WAIT = `${DB}.${MIGRATING$1}.wait`;
|
|
1652
|
-
const DB_MIGRATING_SUCCESS = `${DB}.${MIGRATING$1}.success`;
|
|
1653
|
-
const DB_CREATING_SUCCESS = `${DB}.${CONNECTING_TO_DB$1}.success`;
|
|
1654
|
-
const DB_WAITING_FOR_FILES_RECEIVED = `${DB}.${WAITING_FOR_FILES$1}.filesReceived`;
|
|
1655
|
-
const DB_ON_SNAPSHOT = `${DB}.onSnapshot`;
|
|
1656
|
-
const DB_NAME_APP = 'app_db';
|
|
1657
|
-
const BROWSER_FS_TOP_DIR = 'app-files';
|
|
1658
|
-
process.env.NEXT_PUBLIC_EAS_ENDPOINT ||
|
|
1659
|
-
process.env.EAS_ENDPOINT ||
|
|
1660
|
-
'https://optimism-sepolia.easscan.org/graphql';
|
|
1661
|
-
const ARWEAVE_HOST = process.env.NEXT_PUBLIC_ARWEAVE_HOST || 'arweave.net';
|
|
1662
|
-
|
|
1663
1484
|
const waitForDb = fromCallback(({ sendBack }) => {
|
|
1664
1485
|
const _waitForDb = new Promise((resolve) => {
|
|
1665
1486
|
const interval = setInterval(() => {
|
|
@@ -2271,6 +2092,15 @@ const syncDbWithEasHandler = throttle((_) => __awaiter(void 0, void 0, void 0, f
|
|
|
2271
2092
|
trailing: false,
|
|
2272
2093
|
});
|
|
2273
2094
|
|
|
2095
|
+
const isNode = () => {
|
|
2096
|
+
return (typeof process !== 'undefined' &&
|
|
2097
|
+
process.versions != null &&
|
|
2098
|
+
process.versions.node != null);
|
|
2099
|
+
};
|
|
2100
|
+
const isReactNative = () => {
|
|
2101
|
+
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
2102
|
+
};
|
|
2103
|
+
|
|
2274
2104
|
const logger$m = debug('app:services:global:actors:initialize');
|
|
2275
2105
|
const initialize$1 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
2276
2106
|
const { internalService, models, endpoints, arweaveDomain } = context;
|
|
@@ -2390,7 +2220,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2390
2220
|
if (!models$1) {
|
|
2391
2221
|
return;
|
|
2392
2222
|
}
|
|
2393
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2223
|
+
const { models: SeedModels } = yield import('./seed.schema.config-DrU0-rhL.js');
|
|
2394
2224
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2395
2225
|
let hasModelsInDb = false;
|
|
2396
2226
|
const schemaDefsByModelName = new Map();
|
|
@@ -6052,10 +5882,10 @@ const getPublishPayload = (item, uploadedTransactions) => __awaiter(void 0, void
|
|
|
6052
5882
|
return multiPublishPayload;
|
|
6053
5883
|
});
|
|
6054
5884
|
|
|
6055
|
-
var _a$
|
|
5885
|
+
var _a$1;
|
|
6056
5886
|
class BaseItem {
|
|
6057
5887
|
constructor(initialValues) {
|
|
6058
|
-
this[_a$
|
|
5888
|
+
this[_a$1] = true;
|
|
6059
5889
|
this._propertiesSubject = new BehaviorSubject({});
|
|
6060
5890
|
this.subscribe = (callback) => {
|
|
6061
5891
|
return this._service.subscribe((snapshot) => {
|
|
@@ -6180,7 +6010,7 @@ class BaseItem {
|
|
|
6180
6010
|
static create(props) {
|
|
6181
6011
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6182
6012
|
if (!props.modelName && props.type) {
|
|
6183
|
-
props.modelName = startCase
|
|
6013
|
+
props.modelName = startCase(props.type);
|
|
6184
6014
|
}
|
|
6185
6015
|
if (props.seedUid || props.seedLocalId) {
|
|
6186
6016
|
const seedId = (props.seedUid || props.seedLocalId);
|
|
@@ -6320,7 +6150,7 @@ class BaseItem {
|
|
|
6320
6150
|
this._service.stop();
|
|
6321
6151
|
}
|
|
6322
6152
|
}
|
|
6323
|
-
_a$
|
|
6153
|
+
_a$1 = immerable;
|
|
6324
6154
|
BaseItem.instanceCache = new Map();
|
|
6325
6155
|
|
|
6326
6156
|
class Item extends BaseItem {
|
|
@@ -6330,6 +6160,11 @@ class Item extends BaseItem {
|
|
|
6330
6160
|
}
|
|
6331
6161
|
BaseItem.setPlatformClass(Item);
|
|
6332
6162
|
|
|
6163
|
+
var Item$1 = /*#__PURE__*/Object.freeze({
|
|
6164
|
+
__proto__: null,
|
|
6165
|
+
Item: Item
|
|
6166
|
+
});
|
|
6167
|
+
|
|
6333
6168
|
const logger$5 = debug('app:react:services');
|
|
6334
6169
|
const finalStrings = ['idle', 'ready', 'done', 'success', 'initialized'];
|
|
6335
6170
|
const getServiceName = (service) => {
|
|
@@ -6427,7 +6262,7 @@ const useServices = () => {
|
|
|
6427
6262
|
actorsMap.set(uniqueKey, innerService);
|
|
6428
6263
|
});
|
|
6429
6264
|
let actorsArray = Array.from(actorsMap.values());
|
|
6430
|
-
actorsArray = orderBy
|
|
6265
|
+
actorsArray = orderBy(actorsArray, (a) => a.logic.config.id, ['asc']);
|
|
6431
6266
|
setActors(produce(actors, (draft) => {
|
|
6432
6267
|
return actorsArray;
|
|
6433
6268
|
}));
|
|
@@ -6645,7 +6480,7 @@ const useItems = ({ modelName, deleted }) => {
|
|
|
6645
6480
|
};
|
|
6646
6481
|
}, []);
|
|
6647
6482
|
return {
|
|
6648
|
-
items: orderBy
|
|
6483
|
+
items: orderBy(items, [
|
|
6649
6484
|
(item) => item.lastVersionPublishedAt ||
|
|
6650
6485
|
item.attestationCreatedAt ||
|
|
6651
6486
|
item.createdAt,
|
|
@@ -6820,110 +6655,6 @@ const useDeleteItem = () => {
|
|
|
6820
6655
|
};
|
|
6821
6656
|
};
|
|
6822
6657
|
|
|
6823
|
-
const logger$2 = debug('app:services:events');
|
|
6824
|
-
const handleServiceSaveState = (event) => {
|
|
6825
|
-
const { state, serviceId } = event;
|
|
6826
|
-
logger$2(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
|
|
6827
|
-
localStorage.setItem(`seed_sdk_service_${serviceId}`, JSON.stringify(state));
|
|
6828
|
-
};
|
|
6829
|
-
const setupServicesEventHandlers = () => {
|
|
6830
|
-
eventEmitter.addListener('service.saveState.request', handleServiceSaveState);
|
|
6831
|
-
};
|
|
6832
|
-
|
|
6833
|
-
const saveServiceHandler = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6834
|
-
const globalService = getGlobalService();
|
|
6835
|
-
if (!globalService || !globalService.getSnapshot().context) {
|
|
6836
|
-
return;
|
|
6837
|
-
}
|
|
6838
|
-
const { modelName } = event;
|
|
6839
|
-
const nameOfService = `${modelName}Service`;
|
|
6840
|
-
const service = globalService.getSnapshot().context[nameOfService];
|
|
6841
|
-
if (!service) {
|
|
6842
|
-
console.log(`[saveServiceHandler] service not found: ${nameOfService}`);
|
|
6843
|
-
return;
|
|
6844
|
-
}
|
|
6845
|
-
yield saveAppState(`snapshot__${modelName}`, JSON.stringify(service.getPersistedSnapshot()));
|
|
6846
|
-
});
|
|
6847
|
-
|
|
6848
|
-
const setupServiceHandlers = () => {
|
|
6849
|
-
eventEmitter.addListener('service.save', saveServiceHandler);
|
|
6850
|
-
};
|
|
6851
|
-
|
|
6852
|
-
const client = {
|
|
6853
|
-
init: ({ config, addresses }) => {
|
|
6854
|
-
const { endpoints, models, arweaveDomain } = config;
|
|
6855
|
-
if (arweaveDomain) {
|
|
6856
|
-
setArweaveDomain(arweaveDomain);
|
|
6857
|
-
}
|
|
6858
|
-
for (const [key, value] of Object.entries(models)) {
|
|
6859
|
-
setModel(key, value);
|
|
6860
|
-
}
|
|
6861
|
-
setupFsListeners();
|
|
6862
|
-
setupAllItemsEventHandlers();
|
|
6863
|
-
setupServicesEventHandlers();
|
|
6864
|
-
setupServiceHandlers();
|
|
6865
|
-
if (areFsListenersReady()) {
|
|
6866
|
-
eventEmitter.emit('fs.init');
|
|
6867
|
-
}
|
|
6868
|
-
if (!areFsListenersReady()) {
|
|
6869
|
-
console.error('fs listeners not ready during init');
|
|
6870
|
-
}
|
|
6871
|
-
globalService.send({
|
|
6872
|
-
type: 'init',
|
|
6873
|
-
endpoints,
|
|
6874
|
-
models,
|
|
6875
|
-
addresses,
|
|
6876
|
-
arweaveDomain,
|
|
6877
|
-
});
|
|
6878
|
-
import('./seed.schema.config-DIMmvqJf.js').then(({ models }) => {
|
|
6879
|
-
for (const [key, value] of Object.entries(models)) {
|
|
6880
|
-
setModel(key, value);
|
|
6881
|
-
}
|
|
6882
|
-
});
|
|
6883
|
-
},
|
|
6884
|
-
subscribe: (callback) => {
|
|
6885
|
-
callback({
|
|
6886
|
-
type: '@xstate.snapshot',
|
|
6887
|
-
actorRef: globalService,
|
|
6888
|
-
snapshot: globalService.getSnapshot(),
|
|
6889
|
-
});
|
|
6890
|
-
eventEmitter.addListener('globalService', callback);
|
|
6891
|
-
return {
|
|
6892
|
-
unsubscribe: () => {
|
|
6893
|
-
eventEmitter.removeListener('globalService', callback);
|
|
6894
|
-
},
|
|
6895
|
-
};
|
|
6896
|
-
},
|
|
6897
|
-
on: (outerEvent, callback) => {
|
|
6898
|
-
eventEmitter.addListener(outerEvent, callback);
|
|
6899
|
-
return {
|
|
6900
|
-
unsubscribe: () => {
|
|
6901
|
-
eventEmitter.removeListener(outerEvent, callback);
|
|
6902
|
-
},
|
|
6903
|
-
};
|
|
6904
|
-
},
|
|
6905
|
-
getSeedClass: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
6906
|
-
return new Promise((resolve) => {
|
|
6907
|
-
const subscription = globalService.subscribe((snapshot) => {
|
|
6908
|
-
if (snapshot.status === 'done') {
|
|
6909
|
-
resolve(snapshot.output);
|
|
6910
|
-
}
|
|
6911
|
-
});
|
|
6912
|
-
globalService.send({ type: 'getSeed' });
|
|
6913
|
-
subscription.unsubscribe();
|
|
6914
|
-
});
|
|
6915
|
-
}),
|
|
6916
|
-
getModel: (modelName) => {
|
|
6917
|
-
return getModel(modelName);
|
|
6918
|
-
},
|
|
6919
|
-
getModels: () => {
|
|
6920
|
-
return getModels();
|
|
6921
|
-
},
|
|
6922
|
-
getModelNames: () => {
|
|
6923
|
-
return getModelNames();
|
|
6924
|
-
},
|
|
6925
|
-
};
|
|
6926
|
-
|
|
6927
6658
|
const getVersionData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ localId, seedLocalId, uid, }) {
|
|
6928
6659
|
const appDb = BaseDb.getAppDb();
|
|
6929
6660
|
const whereClauses = [];
|
|
@@ -6946,7 +6677,7 @@ const getVersionData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ loca
|
|
|
6946
6677
|
return queryRows[0];
|
|
6947
6678
|
});
|
|
6948
6679
|
|
|
6949
|
-
const logger$
|
|
6680
|
+
const logger$2 = debug('app:write:updateItemPropertyValue');
|
|
6950
6681
|
const sendItemUpdateEvent = ({ modelName, seedLocalId, seedUid }) => {
|
|
6951
6682
|
if (!modelName || (!seedLocalId && !seedUid)) {
|
|
6952
6683
|
return;
|
|
@@ -6955,7 +6686,7 @@ const sendItemUpdateEvent = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
6955
6686
|
};
|
|
6956
6687
|
const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function* ({ localId, propertyName, newValue, seedUid, seedLocalId, modelName, refSeedType, refResolvedValue, refResolvedDisplayValue, versionLocalId, versionUid, schemaUid, localStorageDir, }) {
|
|
6957
6688
|
if (!localId && !seedLocalId) {
|
|
6958
|
-
logger$
|
|
6689
|
+
logger$2(`[db/write] [updateItemPropertyValue] no propertyLocalId or seedLocalId for property: ${propertyName}`);
|
|
6959
6690
|
return;
|
|
6960
6691
|
}
|
|
6961
6692
|
let safeNewValue = newValue;
|
|
@@ -6993,7 +6724,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
6993
6724
|
modelType === (modelName === null || modelName === void 0 ? void 0 : modelName.toLowerCase()) &&
|
|
6994
6725
|
refSeedTypeFromDb === refSeedType &&
|
|
6995
6726
|
refResolvedValueFromDb === refResolvedValue) {
|
|
6996
|
-
logger$
|
|
6727
|
+
logger$2(`[db/write] [updateItemPropertyValue] value is the same as most recent record for property: ${propertyNameFromDb}`);
|
|
6997
6728
|
return;
|
|
6998
6729
|
}
|
|
6999
6730
|
// This means we already have a local-only record so we should just update that one
|
|
@@ -7726,16 +7457,16 @@ const getPropertyData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pro
|
|
|
7726
7457
|
return;
|
|
7727
7458
|
}
|
|
7728
7459
|
const row = rows[0];
|
|
7729
|
-
return Object.assign(Object.assign({}, row), { modelName: startCase
|
|
7460
|
+
return Object.assign(Object.assign({}, row), { modelName: startCase(row.modelType) });
|
|
7730
7461
|
});
|
|
7731
7462
|
|
|
7732
|
-
var _a
|
|
7733
|
-
const logger = debug('app:property:class');
|
|
7463
|
+
var _a;
|
|
7464
|
+
const logger$1 = debug('app:property:class');
|
|
7734
7465
|
class BaseItemProperty {
|
|
7735
7466
|
constructor(initialValues) {
|
|
7736
7467
|
this._isRelation = false;
|
|
7737
7468
|
this._isList = false;
|
|
7738
|
-
this[_a
|
|
7469
|
+
this[_a] = true;
|
|
7739
7470
|
const { modelName, propertyName, propertyValue, seedLocalId, seedUid, versionLocalId, versionUid, storageTransactionId, schemaUid } = initialValues;
|
|
7740
7471
|
if (!modelName) {
|
|
7741
7472
|
throw new Error('Model name is required');
|
|
@@ -7777,7 +7508,7 @@ class BaseItemProperty {
|
|
|
7777
7508
|
serviceInput.propertyValue = JSON.parse(propertyValue);
|
|
7778
7509
|
}
|
|
7779
7510
|
catch (e) {
|
|
7780
|
-
logger('List property value is not JSON', e);
|
|
7511
|
+
logger$1('List property value is not JSON', e);
|
|
7781
7512
|
}
|
|
7782
7513
|
}
|
|
7783
7514
|
const propertyNameSingular = pluralize(propertyName, 1);
|
|
@@ -7824,7 +7555,7 @@ class BaseItemProperty {
|
|
|
7824
7555
|
}
|
|
7825
7556
|
}
|
|
7826
7557
|
catch (e) {
|
|
7827
|
-
logger(`[ItemProperty] [${context.seedLocalId}] [${context.propertyName}] [storageType] error`, e);
|
|
7558
|
+
logger$1(`[ItemProperty] [${context.seedLocalId}] [${context.propertyName}] [storageType] error`, e);
|
|
7828
7559
|
renderValue = 'No file found';
|
|
7829
7560
|
}
|
|
7830
7561
|
}
|
|
@@ -8021,7 +7752,7 @@ class BaseItemProperty {
|
|
|
8021
7752
|
this._service.stop();
|
|
8022
7753
|
}
|
|
8023
7754
|
}
|
|
8024
|
-
_a
|
|
7755
|
+
_a = immerable;
|
|
8025
7756
|
BaseItemProperty.instanceCache = new Map();
|
|
8026
7757
|
|
|
8027
7758
|
class ItemProperty extends BaseItemProperty {
|
|
@@ -8031,6 +7762,11 @@ class ItemProperty extends BaseItemProperty {
|
|
|
8031
7762
|
}
|
|
8032
7763
|
BaseItemProperty.setPlatformClass(ItemProperty);
|
|
8033
7764
|
|
|
7765
|
+
var ItemProperty$1 = /*#__PURE__*/Object.freeze({
|
|
7766
|
+
__proto__: null,
|
|
7767
|
+
ItemProperty: ItemProperty
|
|
7768
|
+
});
|
|
7769
|
+
|
|
8034
7770
|
const TPropertyDataType = Type.Union([
|
|
8035
7771
|
Type.Literal('Text'),
|
|
8036
7772
|
Type.Literal('Number'),
|
|
@@ -8149,38 +7885,196 @@ const Model = (constructor) => {
|
|
|
8149
7885
|
return ModelClass;
|
|
8150
7886
|
};
|
|
8151
7887
|
|
|
8152
|
-
const
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
7888
|
+
const withSeed = (config, webpack, isServer) => {
|
|
7889
|
+
// If you need to include directories outside of the project root
|
|
7890
|
+
// config.module.rules.push({
|
|
7891
|
+
// test: /\.ts$/,
|
|
7892
|
+
// include: [path.resolve(process.cwd(), 'schema.ts')],
|
|
7893
|
+
// use: 'ts-loader',
|
|
7894
|
+
// })
|
|
7895
|
+
config.plugins.push(
|
|
7896
|
+
// new webpack.DefinePlugin({
|
|
7897
|
+
// __dirname: JSON.stringify(__dirname),
|
|
7898
|
+
// }),
|
|
7899
|
+
new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
|
|
7900
|
+
resource.request = resource.request.replace(/^node:/, '');
|
|
7901
|
+
}));
|
|
7902
|
+
// config.externals.push({
|
|
7903
|
+
// 'fsevents': 'commonjs2 fsevents',
|
|
7904
|
+
// })
|
|
7905
|
+
// console.log('__dirname:', __dirname)
|
|
7906
|
+
// console.log('process.cwd():', process.cwd())
|
|
7907
|
+
// console.log('crypto-browserify exists:', fs.existsSync(path.resolve(process.cwd(), './node_modules/crypto-browserify')))
|
|
7908
|
+
// console.log('path-browserify exists:', fs.existsSync(path.resolve(process.cwd(), './node_modules/path-browserify')))
|
|
7909
|
+
if (!isServer) {
|
|
7910
|
+
config.resolve.alias['fs'] = '@zenfs/core';
|
|
7911
|
+
config.resolve.alias['node:fs'] = '@zenfs/core';
|
|
7912
|
+
config.resolve.alias['node:path'] = 'path-browserify';
|
|
7913
|
+
config.resolve.alias['path'] = 'path-browserify';
|
|
7914
|
+
// config.resolve.alias['fs'] = path.resolve(
|
|
7915
|
+
// process.cwd(),
|
|
7916
|
+
// './node_modules/@zenfs/core',
|
|
7917
|
+
// )
|
|
7918
|
+
// config.resolve.alias['node:fs'] = path.resolve(
|
|
7919
|
+
// process.cwd(),
|
|
7920
|
+
// './node_modules/@zenfs/core',
|
|
7921
|
+
// )
|
|
7922
|
+
// config.resolve.alias['@schema'] = path.resolve(process.cwd(), 'schema.ts')
|
|
7923
|
+
// // config.resolve.alias['crypto'] = path.resolve(process.cwd(), './node_modules/crypto-browserify')
|
|
7924
|
+
// // config.resolve.alias['node:crypto'] = path.resolve(process.cwd(), './node_modules/crypto-browserify')
|
|
7925
|
+
// config.resolve.alias['node:path'] = path.resolve(
|
|
7926
|
+
// process.cwd(),
|
|
7927
|
+
// './node_modules/path-browserify',
|
|
7928
|
+
// )
|
|
7929
|
+
// config.resolve.alias['path'] = path.resolve(
|
|
7930
|
+
// process.cwd(),
|
|
7931
|
+
// './node_modules/path-browserify',
|
|
7932
|
+
// )
|
|
7933
|
+
}
|
|
7934
|
+
if (isServer) {
|
|
7935
|
+
config.externals.push('@sqlite.org/sqlite-wasm');
|
|
7936
|
+
config.externals.push('nunjucks');
|
|
7937
|
+
config.externals.push('chokidar');
|
|
7938
|
+
config.externals.push('arweave');
|
|
7939
|
+
}
|
|
7940
|
+
// config.module.rules.push({
|
|
7941
|
+
// test: /seed\.config\.mjs$/,
|
|
7942
|
+
// use: [
|
|
7943
|
+
// {
|
|
7944
|
+
// loader: 'babel-loader',
|
|
7945
|
+
// options: {
|
|
7946
|
+
// plugins: ['@babel/plugin-syntax-dynamic-import'],
|
|
7947
|
+
// },
|
|
7948
|
+
// },
|
|
7949
|
+
// ],
|
|
7950
|
+
// })
|
|
7951
|
+
return config;
|
|
7952
|
+
};
|
|
7953
|
+
|
|
7954
|
+
const logger = debug('app:services:events');
|
|
7955
|
+
const handleServiceSaveState = (event) => {
|
|
7956
|
+
const { state, serviceId } = event;
|
|
7957
|
+
logger(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
|
|
7958
|
+
localStorage.setItem(`seed_sdk_service_${serviceId}`, JSON.stringify(state));
|
|
7959
|
+
};
|
|
7960
|
+
const setupServicesEventHandlers = () => {
|
|
7961
|
+
eventEmitter.addListener('service.saveState.request', handleServiceSaveState);
|
|
7962
|
+
};
|
|
7963
|
+
|
|
7964
|
+
const saveServiceHandler = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7965
|
+
const globalService = getGlobalService();
|
|
7966
|
+
if (!globalService || !globalService.getSnapshot().context) {
|
|
7967
|
+
return;
|
|
7968
|
+
}
|
|
7969
|
+
const { modelName } = event;
|
|
7970
|
+
const nameOfService = `${modelName}Service`;
|
|
7971
|
+
const service = globalService.getSnapshot().context[nameOfService];
|
|
7972
|
+
if (!service) {
|
|
7973
|
+
console.log(`[saveServiceHandler] service not found: ${nameOfService}`);
|
|
7974
|
+
return;
|
|
7975
|
+
}
|
|
7976
|
+
yield saveAppState(`snapshot__${modelName}`, JSON.stringify(service.getPersistedSnapshot()));
|
|
7977
|
+
});
|
|
7978
|
+
|
|
7979
|
+
const setupServiceHandlers = () => {
|
|
7980
|
+
eventEmitter.addListener('service.save', saveServiceHandler);
|
|
7981
|
+
};
|
|
7982
|
+
|
|
7983
|
+
const initItem = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
7984
|
+
if (typeof window !== 'undefined') {
|
|
7985
|
+
(yield Promise.resolve().then(function () { return Item$1; })).Item;
|
|
8164
7986
|
}
|
|
8165
7987
|
else {
|
|
7988
|
+
(yield import('./Item-D_fRE67b.js')).Item;
|
|
7989
|
+
}
|
|
7990
|
+
});
|
|
7991
|
+
|
|
7992
|
+
const initItemProperty = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
7993
|
+
if (typeof window !== 'undefined') {
|
|
7994
|
+
(yield Promise.resolve().then(function () { return ItemProperty$1; })).ItemProperty;
|
|
7995
|
+
}
|
|
7996
|
+
else {
|
|
7997
|
+
(yield import('./ItemProperty-l0sNRNKZ.js')).ItemProperty;
|
|
7998
|
+
}
|
|
7999
|
+
});
|
|
8000
|
+
|
|
8001
|
+
const client = {
|
|
8002
|
+
init: (_a) => __awaiter(void 0, [_a], void 0, function* ({ config, addresses }) {
|
|
8003
|
+
yield initItem();
|
|
8004
|
+
yield initItemProperty();
|
|
8005
|
+
const { endpoints, models, arweaveDomain } = config;
|
|
8006
|
+
if (arweaveDomain) {
|
|
8007
|
+
setArweaveDomain(arweaveDomain);
|
|
8008
|
+
}
|
|
8009
|
+
for (const [key, value] of Object.entries(models)) {
|
|
8010
|
+
setModel(key, value);
|
|
8011
|
+
}
|
|
8012
|
+
setupFsListeners();
|
|
8013
|
+
setupAllItemsEventHandlers();
|
|
8014
|
+
setupServicesEventHandlers();
|
|
8015
|
+
setupServiceHandlers();
|
|
8016
|
+
if (areFsListenersReady()) {
|
|
8017
|
+
eventEmitter.emit('fs.init');
|
|
8018
|
+
}
|
|
8019
|
+
if (!areFsListenersReady()) {
|
|
8020
|
+
console.error('fs listeners not ready during init');
|
|
8021
|
+
}
|
|
8022
|
+
globalService.send({
|
|
8023
|
+
type: 'init',
|
|
8024
|
+
endpoints,
|
|
8025
|
+
models,
|
|
8026
|
+
addresses,
|
|
8027
|
+
arweaveDomain,
|
|
8028
|
+
});
|
|
8029
|
+
const { models: internalModels } = yield import('./seed.schema.config-DrU0-rhL.js');
|
|
8030
|
+
for (const [key, value] of Object.entries(internalModels)) {
|
|
8031
|
+
setModel(key, value);
|
|
8032
|
+
}
|
|
8033
|
+
}),
|
|
8034
|
+
subscribe: (callback) => {
|
|
8035
|
+
callback({
|
|
8036
|
+
type: '@xstate.snapshot',
|
|
8037
|
+
actorRef: globalService,
|
|
8038
|
+
snapshot: globalService.getSnapshot(),
|
|
8039
|
+
});
|
|
8040
|
+
eventEmitter.addListener('globalService', callback);
|
|
8166
8041
|
return {
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
Relation,
|
|
8171
|
-
Text,
|
|
8172
|
-
List,
|
|
8173
|
-
Json,
|
|
8042
|
+
unsubscribe: () => {
|
|
8043
|
+
eventEmitter.removeListener('globalService', callback);
|
|
8044
|
+
},
|
|
8174
8045
|
};
|
|
8175
|
-
}
|
|
8046
|
+
},
|
|
8047
|
+
on: (outerEvent, callback) => {
|
|
8048
|
+
eventEmitter.addListener(outerEvent, callback);
|
|
8049
|
+
return {
|
|
8050
|
+
unsubscribe: () => {
|
|
8051
|
+
eventEmitter.removeListener(outerEvent, callback);
|
|
8052
|
+
},
|
|
8053
|
+
};
|
|
8054
|
+
},
|
|
8055
|
+
getSeedClass: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8056
|
+
return new Promise((resolve) => {
|
|
8057
|
+
const subscription = globalService.subscribe((snapshot) => {
|
|
8058
|
+
if (snapshot.status === 'done') {
|
|
8059
|
+
resolve(snapshot.output);
|
|
8060
|
+
}
|
|
8061
|
+
});
|
|
8062
|
+
globalService.send({ type: 'getSeed' });
|
|
8063
|
+
subscription.unsubscribe();
|
|
8064
|
+
});
|
|
8065
|
+
}),
|
|
8066
|
+
getModel: (modelName) => {
|
|
8067
|
+
return getModel(modelName);
|
|
8068
|
+
},
|
|
8069
|
+
getModels: () => {
|
|
8070
|
+
return getModels();
|
|
8071
|
+
},
|
|
8072
|
+
getModelNames: () => {
|
|
8073
|
+
return getModelNames();
|
|
8074
|
+
},
|
|
8176
8075
|
};
|
|
8177
8076
|
|
|
8178
|
-
var _a;
|
|
8179
8077
|
enableMapSet();
|
|
8180
|
-
let withSeed;
|
|
8181
|
-
if (isNode()) {
|
|
8182
|
-
withSeed = (_a = initSeedSync()) === null || _a === void 0 ? void 0 : _a.withSeed;
|
|
8183
|
-
}
|
|
8184
8078
|
|
|
8185
|
-
export { Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, ImageSrc as a, ItemProperty as b, useItem as c, useItemProperties as d, useCreateItem as e, useItemProperty as f, useDeleteItem as g, useGlobalServiceStatus as h,
|
|
8186
|
-
//# sourceMappingURL=index-
|
|
8079
|
+
export { BaseItem as B, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, ImageSrc as a, ItemProperty as b, useItem as c, useItemProperties as d, useCreateItem as e, useItemProperty as f, useDeleteItem as g, useGlobalServiceStatus as h, useServices as i, getGlobalService as j, getCorrectId as k, BaseFileManager as l, eventEmitter as m, client as n, useItems as u, withSeed as w };
|
|
8080
|
+
//# sourceMappingURL=index-CaMCzFrd.js.map
|