@seedprotocol/sdk 0.2.1 → 0.2.2
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-EuINlFXI.js +41 -0
- package/dist/Item-EuINlFXI.js.map +1 -0
- package/dist/ItemProperty-l0sNRNKZ.js +2 -0
- package/dist/ItemProperty-l0sNRNKZ.js.map +1 -0
- package/dist/bin.js +1 -2
- package/dist/bin.js.map +1 -1
- package/dist/{constants-B6s6tGup.js → constants-yM3e1D1k.js} +2 -3
- package/dist/constants-yM3e1D1k.js.map +1 -0
- package/dist/{index-B5qzD-bs.js → index-C9eVIXxd.js} +5 -6
- package/dist/index-C9eVIXxd.js.map +1 -0
- package/dist/{index-DaK2dz5P.js → index-DIlkGqpY.js} +221 -223
- package/dist/index-DIlkGqpY.js.map +1 -0
- package/dist/main.js +2 -3
- package/dist/main.js.map +1 -1
- package/dist/{seed.schema.config-DIMmvqJf.js → seed.schema.config-Du8pUTQu.js} +6 -7
- package/dist/seed.schema.config-Du8pUTQu.js.map +1 -0
- package/dist/src/BaseItemProperty.ts +1 -1
- package/dist/src/IItemProperty.ts +1 -1
- package/dist/src/ItemProperty.ts +0 -16
- 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/getPublishPayload.ts +1 -1
- package/dist/src/globalMachine.ts +1 -1
- package/dist/src/hydrateFromDb.ts +1 -1
- package/dist/src/index.ts +4 -21
- package/dist/src/initialize.ts +88 -238
- package/dist/src/itemMachineAll.ts +6 -7
- 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/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/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.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,9 +1,9 @@
|
|
|
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';
|
|
@@ -16,7 +16,7 @@ import { useState, useEffect, useRef, useCallback } from 'react';
|
|
|
16
16
|
import pluralize from 'pluralize';
|
|
17
17
|
import EventEmitter from 'eventemitter3';
|
|
18
18
|
import { throttle, camelCase, startCase, orderBy as orderBy$1 } from 'lodash-es';
|
|
19
|
-
import { I as INTERNAL_DATA_TYPES, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, d as defaultAttestationData, i as internalPropertyNames } from './constants-
|
|
19
|
+
import { I as INTERNAL_DATA_TYPES, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, d as defaultAttestationData, i as internalPropertyNames } from './constants-yM3e1D1k.js';
|
|
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';
|
|
@@ -29,81 +29,6 @@ import { useSelector } from '@xstate/react';
|
|
|
29
29
|
import { startCase as startCase$1, orderBy } from 'lodash';
|
|
30
30
|
import { ZERO_BYTES32, SchemaEncoder } from '@ethereum-attestation-service/eas-sdk';
|
|
31
31
|
|
|
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
32
|
const modelStore = new Map();
|
|
108
33
|
const getModels = () => {
|
|
109
34
|
return Object.fromEntries(modelStore);
|
|
@@ -1374,7 +1299,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1374
1299
|
if (propertyRecordSchema &&
|
|
1375
1300
|
propertyRecordSchema.storageType &&
|
|
1376
1301
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
1377
|
-
const { Item } = yield import('./index-
|
|
1302
|
+
const { Item } = yield import('./index-C9eVIXxd.js');
|
|
1378
1303
|
const item = yield Item.find({
|
|
1379
1304
|
seedLocalId,
|
|
1380
1305
|
modelName,
|
|
@@ -2271,6 +2196,15 @@ const syncDbWithEasHandler = throttle((_) => __awaiter(void 0, void 0, void 0, f
|
|
|
2271
2196
|
trailing: false,
|
|
2272
2197
|
});
|
|
2273
2198
|
|
|
2199
|
+
const isNode = () => {
|
|
2200
|
+
return (typeof process !== 'undefined' &&
|
|
2201
|
+
process.versions != null &&
|
|
2202
|
+
process.versions.node != null);
|
|
2203
|
+
};
|
|
2204
|
+
const isReactNative = () => {
|
|
2205
|
+
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
2206
|
+
};
|
|
2207
|
+
|
|
2274
2208
|
const logger$m = debug('app:services:global:actors:initialize');
|
|
2275
2209
|
const initialize$1 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
2276
2210
|
const { internalService, models, endpoints, arweaveDomain } = context;
|
|
@@ -2390,7 +2324,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
2390
2324
|
if (!models$1) {
|
|
2391
2325
|
return;
|
|
2392
2326
|
}
|
|
2393
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
2327
|
+
const { models: SeedModels } = yield import('./seed.schema.config-Du8pUTQu.js');
|
|
2394
2328
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
2395
2329
|
let hasModelsInDb = false;
|
|
2396
2330
|
const schemaDefsByModelName = new Map();
|
|
@@ -6052,10 +5986,10 @@ const getPublishPayload = (item, uploadedTransactions) => __awaiter(void 0, void
|
|
|
6052
5986
|
return multiPublishPayload;
|
|
6053
5987
|
});
|
|
6054
5988
|
|
|
6055
|
-
var _a$
|
|
5989
|
+
var _a$1;
|
|
6056
5990
|
class BaseItem {
|
|
6057
5991
|
constructor(initialValues) {
|
|
6058
|
-
this[_a$
|
|
5992
|
+
this[_a$1] = true;
|
|
6059
5993
|
this._propertiesSubject = new BehaviorSubject({});
|
|
6060
5994
|
this.subscribe = (callback) => {
|
|
6061
5995
|
return this._service.subscribe((snapshot) => {
|
|
@@ -6320,7 +6254,7 @@ class BaseItem {
|
|
|
6320
6254
|
this._service.stop();
|
|
6321
6255
|
}
|
|
6322
6256
|
}
|
|
6323
|
-
_a$
|
|
6257
|
+
_a$1 = immerable;
|
|
6324
6258
|
BaseItem.instanceCache = new Map();
|
|
6325
6259
|
|
|
6326
6260
|
class Item extends BaseItem {
|
|
@@ -6330,6 +6264,11 @@ class Item extends BaseItem {
|
|
|
6330
6264
|
}
|
|
6331
6265
|
BaseItem.setPlatformClass(Item);
|
|
6332
6266
|
|
|
6267
|
+
var Item$1 = /*#__PURE__*/Object.freeze({
|
|
6268
|
+
__proto__: null,
|
|
6269
|
+
Item: Item
|
|
6270
|
+
});
|
|
6271
|
+
|
|
6333
6272
|
const logger$5 = debug('app:react:services');
|
|
6334
6273
|
const finalStrings = ['idle', 'ready', 'done', 'success', 'initialized'];
|
|
6335
6274
|
const getServiceName = (service) => {
|
|
@@ -6820,110 +6759,6 @@ const useDeleteItem = () => {
|
|
|
6820
6759
|
};
|
|
6821
6760
|
};
|
|
6822
6761
|
|
|
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
6762
|
const getVersionData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ localId, seedLocalId, uid, }) {
|
|
6928
6763
|
const appDb = BaseDb.getAppDb();
|
|
6929
6764
|
const whereClauses = [];
|
|
@@ -6946,7 +6781,7 @@ const getVersionData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ loca
|
|
|
6946
6781
|
return queryRows[0];
|
|
6947
6782
|
});
|
|
6948
6783
|
|
|
6949
|
-
const logger$
|
|
6784
|
+
const logger$2 = debug('app:write:updateItemPropertyValue');
|
|
6950
6785
|
const sendItemUpdateEvent = ({ modelName, seedLocalId, seedUid }) => {
|
|
6951
6786
|
if (!modelName || (!seedLocalId && !seedUid)) {
|
|
6952
6787
|
return;
|
|
@@ -6955,7 +6790,7 @@ const sendItemUpdateEvent = ({ modelName, seedLocalId, seedUid }) => {
|
|
|
6955
6790
|
};
|
|
6956
6791
|
const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function* ({ localId, propertyName, newValue, seedUid, seedLocalId, modelName, refSeedType, refResolvedValue, refResolvedDisplayValue, versionLocalId, versionUid, schemaUid, localStorageDir, }) {
|
|
6957
6792
|
if (!localId && !seedLocalId) {
|
|
6958
|
-
logger$
|
|
6793
|
+
logger$2(`[db/write] [updateItemPropertyValue] no propertyLocalId or seedLocalId for property: ${propertyName}`);
|
|
6959
6794
|
return;
|
|
6960
6795
|
}
|
|
6961
6796
|
let safeNewValue = newValue;
|
|
@@ -6993,7 +6828,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
6993
6828
|
modelType === (modelName === null || modelName === void 0 ? void 0 : modelName.toLowerCase()) &&
|
|
6994
6829
|
refSeedTypeFromDb === refSeedType &&
|
|
6995
6830
|
refResolvedValueFromDb === refResolvedValue) {
|
|
6996
|
-
logger$
|
|
6831
|
+
logger$2(`[db/write] [updateItemPropertyValue] value is the same as most recent record for property: ${propertyNameFromDb}`);
|
|
6997
6832
|
return;
|
|
6998
6833
|
}
|
|
6999
6834
|
// This means we already have a local-only record so we should just update that one
|
|
@@ -7729,13 +7564,13 @@ const getPropertyData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ pro
|
|
|
7729
7564
|
return Object.assign(Object.assign({}, row), { modelName: startCase$1(row.modelType) });
|
|
7730
7565
|
});
|
|
7731
7566
|
|
|
7732
|
-
var _a
|
|
7733
|
-
const logger = debug('app:property:class');
|
|
7567
|
+
var _a;
|
|
7568
|
+
const logger$1 = debug('app:property:class');
|
|
7734
7569
|
class BaseItemProperty {
|
|
7735
7570
|
constructor(initialValues) {
|
|
7736
7571
|
this._isRelation = false;
|
|
7737
7572
|
this._isList = false;
|
|
7738
|
-
this[_a
|
|
7573
|
+
this[_a] = true;
|
|
7739
7574
|
const { modelName, propertyName, propertyValue, seedLocalId, seedUid, versionLocalId, versionUid, storageTransactionId, schemaUid } = initialValues;
|
|
7740
7575
|
if (!modelName) {
|
|
7741
7576
|
throw new Error('Model name is required');
|
|
@@ -7777,7 +7612,7 @@ class BaseItemProperty {
|
|
|
7777
7612
|
serviceInput.propertyValue = JSON.parse(propertyValue);
|
|
7778
7613
|
}
|
|
7779
7614
|
catch (e) {
|
|
7780
|
-
logger('List property value is not JSON', e);
|
|
7615
|
+
logger$1('List property value is not JSON', e);
|
|
7781
7616
|
}
|
|
7782
7617
|
}
|
|
7783
7618
|
const propertyNameSingular = pluralize(propertyName, 1);
|
|
@@ -7824,7 +7659,7 @@ class BaseItemProperty {
|
|
|
7824
7659
|
}
|
|
7825
7660
|
}
|
|
7826
7661
|
catch (e) {
|
|
7827
|
-
logger(`[ItemProperty] [${context.seedLocalId}] [${context.propertyName}] [storageType] error`, e);
|
|
7662
|
+
logger$1(`[ItemProperty] [${context.seedLocalId}] [${context.propertyName}] [storageType] error`, e);
|
|
7828
7663
|
renderValue = 'No file found';
|
|
7829
7664
|
}
|
|
7830
7665
|
}
|
|
@@ -8021,7 +7856,7 @@ class BaseItemProperty {
|
|
|
8021
7856
|
this._service.stop();
|
|
8022
7857
|
}
|
|
8023
7858
|
}
|
|
8024
|
-
_a
|
|
7859
|
+
_a = immerable;
|
|
8025
7860
|
BaseItemProperty.instanceCache = new Map();
|
|
8026
7861
|
|
|
8027
7862
|
class ItemProperty extends BaseItemProperty {
|
|
@@ -8031,6 +7866,11 @@ class ItemProperty extends BaseItemProperty {
|
|
|
8031
7866
|
}
|
|
8032
7867
|
BaseItemProperty.setPlatformClass(ItemProperty);
|
|
8033
7868
|
|
|
7869
|
+
var ItemProperty$1 = /*#__PURE__*/Object.freeze({
|
|
7870
|
+
__proto__: null,
|
|
7871
|
+
ItemProperty: ItemProperty
|
|
7872
|
+
});
|
|
7873
|
+
|
|
8034
7874
|
const TPropertyDataType = Type.Union([
|
|
8035
7875
|
Type.Literal('Text'),
|
|
8036
7876
|
Type.Literal('Number'),
|
|
@@ -8149,38 +7989,196 @@ const Model = (constructor) => {
|
|
|
8149
7989
|
return ModelClass;
|
|
8150
7990
|
};
|
|
8151
7991
|
|
|
8152
|
-
const
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
7992
|
+
const withSeed = (config, webpack, isServer) => {
|
|
7993
|
+
// If you need to include directories outside of the project root
|
|
7994
|
+
// config.module.rules.push({
|
|
7995
|
+
// test: /\.ts$/,
|
|
7996
|
+
// include: [path.resolve(process.cwd(), 'schema.ts')],
|
|
7997
|
+
// use: 'ts-loader',
|
|
7998
|
+
// })
|
|
7999
|
+
config.plugins.push(
|
|
8000
|
+
// new webpack.DefinePlugin({
|
|
8001
|
+
// __dirname: JSON.stringify(__dirname),
|
|
8002
|
+
// }),
|
|
8003
|
+
new webpack.NormalModuleReplacementPlugin(/node:/, (resource) => {
|
|
8004
|
+
resource.request = resource.request.replace(/^node:/, '');
|
|
8005
|
+
}));
|
|
8006
|
+
// config.externals.push({
|
|
8007
|
+
// 'fsevents': 'commonjs2 fsevents',
|
|
8008
|
+
// })
|
|
8009
|
+
// console.log('__dirname:', __dirname)
|
|
8010
|
+
// console.log('process.cwd():', process.cwd())
|
|
8011
|
+
// console.log('crypto-browserify exists:', fs.existsSync(path.resolve(process.cwd(), './node_modules/crypto-browserify')))
|
|
8012
|
+
// console.log('path-browserify exists:', fs.existsSync(path.resolve(process.cwd(), './node_modules/path-browserify')))
|
|
8013
|
+
if (!isServer) {
|
|
8014
|
+
config.resolve.alias['fs'] = '@zenfs/core';
|
|
8015
|
+
config.resolve.alias['node:fs'] = '@zenfs/core';
|
|
8016
|
+
config.resolve.alias['node:path'] = 'path-browserify';
|
|
8017
|
+
config.resolve.alias['path'] = 'path-browserify';
|
|
8018
|
+
// config.resolve.alias['fs'] = path.resolve(
|
|
8019
|
+
// process.cwd(),
|
|
8020
|
+
// './node_modules/@zenfs/core',
|
|
8021
|
+
// )
|
|
8022
|
+
// config.resolve.alias['node:fs'] = path.resolve(
|
|
8023
|
+
// process.cwd(),
|
|
8024
|
+
// './node_modules/@zenfs/core',
|
|
8025
|
+
// )
|
|
8026
|
+
// config.resolve.alias['@schema'] = path.resolve(process.cwd(), 'schema.ts')
|
|
8027
|
+
// // config.resolve.alias['crypto'] = path.resolve(process.cwd(), './node_modules/crypto-browserify')
|
|
8028
|
+
// // config.resolve.alias['node:crypto'] = path.resolve(process.cwd(), './node_modules/crypto-browserify')
|
|
8029
|
+
// config.resolve.alias['node:path'] = path.resolve(
|
|
8030
|
+
// process.cwd(),
|
|
8031
|
+
// './node_modules/path-browserify',
|
|
8032
|
+
// )
|
|
8033
|
+
// config.resolve.alias['path'] = path.resolve(
|
|
8034
|
+
// process.cwd(),
|
|
8035
|
+
// './node_modules/path-browserify',
|
|
8036
|
+
// )
|
|
8037
|
+
}
|
|
8038
|
+
if (isServer) {
|
|
8039
|
+
config.externals.push('@sqlite.org/sqlite-wasm');
|
|
8040
|
+
config.externals.push('nunjucks');
|
|
8041
|
+
config.externals.push('chokidar');
|
|
8042
|
+
config.externals.push('arweave');
|
|
8043
|
+
}
|
|
8044
|
+
// config.module.rules.push({
|
|
8045
|
+
// test: /seed\.config\.mjs$/,
|
|
8046
|
+
// use: [
|
|
8047
|
+
// {
|
|
8048
|
+
// loader: 'babel-loader',
|
|
8049
|
+
// options: {
|
|
8050
|
+
// plugins: ['@babel/plugin-syntax-dynamic-import'],
|
|
8051
|
+
// },
|
|
8052
|
+
// },
|
|
8053
|
+
// ],
|
|
8054
|
+
// })
|
|
8055
|
+
return config;
|
|
8056
|
+
};
|
|
8057
|
+
|
|
8058
|
+
const logger = debug('app:services:events');
|
|
8059
|
+
const handleServiceSaveState = (event) => {
|
|
8060
|
+
const { state, serviceId } = event;
|
|
8061
|
+
logger(`[browser] [service.saveState.request] serviceId: ${serviceId}`);
|
|
8062
|
+
localStorage.setItem(`seed_sdk_service_${serviceId}`, JSON.stringify(state));
|
|
8063
|
+
};
|
|
8064
|
+
const setupServicesEventHandlers = () => {
|
|
8065
|
+
eventEmitter.addListener('service.saveState.request', handleServiceSaveState);
|
|
8066
|
+
};
|
|
8067
|
+
|
|
8068
|
+
const saveServiceHandler = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8069
|
+
const globalService = getGlobalService();
|
|
8070
|
+
if (!globalService || !globalService.getSnapshot().context) {
|
|
8071
|
+
return;
|
|
8072
|
+
}
|
|
8073
|
+
const { modelName } = event;
|
|
8074
|
+
const nameOfService = `${modelName}Service`;
|
|
8075
|
+
const service = globalService.getSnapshot().context[nameOfService];
|
|
8076
|
+
if (!service) {
|
|
8077
|
+
console.log(`[saveServiceHandler] service not found: ${nameOfService}`);
|
|
8078
|
+
return;
|
|
8079
|
+
}
|
|
8080
|
+
yield saveAppState(`snapshot__${modelName}`, JSON.stringify(service.getPersistedSnapshot()));
|
|
8081
|
+
});
|
|
8082
|
+
|
|
8083
|
+
const setupServiceHandlers = () => {
|
|
8084
|
+
eventEmitter.addListener('service.save', saveServiceHandler);
|
|
8085
|
+
};
|
|
8086
|
+
|
|
8087
|
+
const initItem = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8088
|
+
if (typeof window !== 'undefined') {
|
|
8089
|
+
(yield Promise.resolve().then(function () { return Item$1; })).Item;
|
|
8164
8090
|
}
|
|
8165
8091
|
else {
|
|
8092
|
+
(yield import('./Item-EuINlFXI.js')).Item;
|
|
8093
|
+
}
|
|
8094
|
+
});
|
|
8095
|
+
|
|
8096
|
+
const initItemProperty = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8097
|
+
if (typeof window !== 'undefined') {
|
|
8098
|
+
(yield Promise.resolve().then(function () { return ItemProperty$1; })).ItemProperty;
|
|
8099
|
+
}
|
|
8100
|
+
else {
|
|
8101
|
+
(yield import('./ItemProperty-l0sNRNKZ.js')).ItemProperty;
|
|
8102
|
+
}
|
|
8103
|
+
});
|
|
8104
|
+
|
|
8105
|
+
const client = {
|
|
8106
|
+
init: (_a) => __awaiter(void 0, [_a], void 0, function* ({ config, addresses }) {
|
|
8107
|
+
yield initItem();
|
|
8108
|
+
yield initItemProperty();
|
|
8109
|
+
const { endpoints, models, arweaveDomain } = config;
|
|
8110
|
+
if (arweaveDomain) {
|
|
8111
|
+
setArweaveDomain(arweaveDomain);
|
|
8112
|
+
}
|
|
8113
|
+
for (const [key, value] of Object.entries(models)) {
|
|
8114
|
+
setModel(key, value);
|
|
8115
|
+
}
|
|
8116
|
+
setupFsListeners();
|
|
8117
|
+
setupAllItemsEventHandlers();
|
|
8118
|
+
setupServicesEventHandlers();
|
|
8119
|
+
setupServiceHandlers();
|
|
8120
|
+
if (areFsListenersReady()) {
|
|
8121
|
+
eventEmitter.emit('fs.init');
|
|
8122
|
+
}
|
|
8123
|
+
if (!areFsListenersReady()) {
|
|
8124
|
+
console.error('fs listeners not ready during init');
|
|
8125
|
+
}
|
|
8126
|
+
globalService.send({
|
|
8127
|
+
type: 'init',
|
|
8128
|
+
endpoints,
|
|
8129
|
+
models,
|
|
8130
|
+
addresses,
|
|
8131
|
+
arweaveDomain,
|
|
8132
|
+
});
|
|
8133
|
+
const { models: internalModels } = yield import('./seed.schema.config-Du8pUTQu.js');
|
|
8134
|
+
for (const [key, value] of Object.entries(internalModels)) {
|
|
8135
|
+
setModel(key, value);
|
|
8136
|
+
}
|
|
8137
|
+
}),
|
|
8138
|
+
subscribe: (callback) => {
|
|
8139
|
+
callback({
|
|
8140
|
+
type: '@xstate.snapshot',
|
|
8141
|
+
actorRef: globalService,
|
|
8142
|
+
snapshot: globalService.getSnapshot(),
|
|
8143
|
+
});
|
|
8144
|
+
eventEmitter.addListener('globalService', callback);
|
|
8166
8145
|
return {
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
Relation,
|
|
8171
|
-
Text,
|
|
8172
|
-
List,
|
|
8173
|
-
Json,
|
|
8146
|
+
unsubscribe: () => {
|
|
8147
|
+
eventEmitter.removeListener('globalService', callback);
|
|
8148
|
+
},
|
|
8174
8149
|
};
|
|
8175
|
-
}
|
|
8150
|
+
},
|
|
8151
|
+
on: (outerEvent, callback) => {
|
|
8152
|
+
eventEmitter.addListener(outerEvent, callback);
|
|
8153
|
+
return {
|
|
8154
|
+
unsubscribe: () => {
|
|
8155
|
+
eventEmitter.removeListener(outerEvent, callback);
|
|
8156
|
+
},
|
|
8157
|
+
};
|
|
8158
|
+
},
|
|
8159
|
+
getSeedClass: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8160
|
+
return new Promise((resolve) => {
|
|
8161
|
+
const subscription = globalService.subscribe((snapshot) => {
|
|
8162
|
+
if (snapshot.status === 'done') {
|
|
8163
|
+
resolve(snapshot.output);
|
|
8164
|
+
}
|
|
8165
|
+
});
|
|
8166
|
+
globalService.send({ type: 'getSeed' });
|
|
8167
|
+
subscription.unsubscribe();
|
|
8168
|
+
});
|
|
8169
|
+
}),
|
|
8170
|
+
getModel: (modelName) => {
|
|
8171
|
+
return getModel(modelName);
|
|
8172
|
+
},
|
|
8173
|
+
getModels: () => {
|
|
8174
|
+
return getModels();
|
|
8175
|
+
},
|
|
8176
|
+
getModelNames: () => {
|
|
8177
|
+
return getModelNames();
|
|
8178
|
+
},
|
|
8176
8179
|
};
|
|
8177
8180
|
|
|
8178
|
-
var _a;
|
|
8179
8181
|
enableMapSet();
|
|
8180
|
-
let withSeed;
|
|
8181
|
-
if (isNode()) {
|
|
8182
|
-
withSeed = (_a = initSeedSync()) === null || _a === void 0 ? void 0 : _a.withSeed;
|
|
8183
|
-
}
|
|
8184
8182
|
|
|
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-
|
|
8183
|
+
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, BaseArweaveClient as l, BaseEasClient as m, BaseFileManager as n, BaseQueryClient as o, eventEmitter as p, client as q, useItems as u, withSeed as w };
|
|
8184
|
+
//# sourceMappingURL=index-DIlkGqpY.js.map
|