@seedprotocol/sdk 0.2.19 → 0.2.21
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-CQyWrG2a.js → Db-B1gJQbux.js} +3 -3
- package/dist/Db-B1gJQbux.js.map +1 -0
- package/dist/{Db-Cv4GVzh1.js → Db-CSgUyick.js} +33 -11
- package/dist/Db-CSgUyick.js.map +1 -0
- package/dist/{Item-UegZbC_j.js → Item-B_ZA4PWq.js} +2 -2
- package/dist/{Item-UegZbC_j.js.map → Item-B_ZA4PWq.js.map} +1 -1
- package/dist/ItemProperty-CQrtYQT7.js +39 -0
- package/dist/ItemProperty-CQrtYQT7.js.map +1 -0
- package/dist/{index-DQrMMoLY.js → index-8LV9Tqv2.js} +2 -2
- package/dist/index-8LV9Tqv2.js.map +1 -0
- package/dist/{index-DNw_v54Y.js → index-Xi0K-lIT.js} +155 -128
- package/dist/index-Xi0K-lIT.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/node/db/node.app.db.config.ts +1 -0
- package/dist/{seed.schema.config-SuJxms_6.js → seed.schema.config-uN0rq0mU.js} +2 -2
- package/dist/{seed.schema.config-SuJxms_6.js.map → seed.schema.config-uN0rq0mU.js.map} +1 -1
- package/dist/src/BaseDb.ts +2 -2
- package/dist/src/BaseItem.ts +3 -5
- package/dist/src/Db.ts +37 -3
- package/dist/src/IItem.ts +0 -1
- package/dist/src/IItemProperty.ts +0 -1
- package/dist/src/ItemProperty.ts +9 -0
- package/dist/src/client.ts +4 -2
- package/dist/src/environment.ts +20 -0
- package/dist/src/fetchDbData.ts +1 -1
- package/dist/src/fetchSeeds.ts +1 -1
- package/dist/src/fetchVersions.ts +1 -1
- package/dist/src/globalMachine.ts +6 -2
- package/dist/src/initialize.ts +75 -78
- package/dist/src/internalMachine.ts +2 -0
- package/dist/src/machines.ts +2 -0
- package/dist/src/node.app.db.config.ts +1 -0
- package/dist/src/prepareDb.ts +12 -6
- package/dist/src/processItems.ts +1 -1
- package/dist/src/sqlWasmClient.ts +4 -4
- package/dist/src/updateItemPropertyValue.ts +5 -6
- package/dist/src/validateInput.ts +22 -8
- package/dist/types/src/Item/BaseItem.d.ts +1 -10
- package/dist/types/src/Item/BaseItem.d.ts.map +1 -1
- package/dist/types/src/Item/index.d.ts +2 -2
- package/dist/types/src/Item/index.d.ts.map +1 -1
- package/dist/types/src/Item/service/actors/initialize.d.ts +1 -1
- package/dist/types/src/Item/service/actors/initialize.d.ts.map +1 -1
- package/dist/types/src/ItemProperty/index.d.ts +2 -2
- package/dist/types/src/ItemProperty/index.d.ts.map +1 -1
- package/dist/types/src/browser/db/Db.d.ts +1 -1
- package/dist/types/src/browser/db/Db.d.ts.map +1 -1
- package/dist/types/src/browser/db/sqlWasmClient.d.ts.map +1 -1
- package/dist/types/src/client.d.ts +1 -1
- package/dist/types/src/client.d.ts.map +1 -1
- package/dist/types/src/db/Db/BaseDb.d.ts +1 -1
- package/dist/types/src/db/Db/BaseDb.d.ts.map +1 -1
- package/dist/types/src/db/Db/index.d.ts.map +1 -1
- package/dist/types/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
- package/dist/types/src/helpers/ArweaveClient/index.d.ts.map +1 -1
- package/dist/types/src/helpers/EasClient/index.d.ts.map +1 -1
- package/dist/types/src/helpers/FileManager/index.d.ts.map +1 -1
- package/dist/types/src/helpers/QueryClient/index.d.ts.map +1 -1
- package/dist/types/src/helpers/environment.d.ts +2 -0
- package/dist/types/src/helpers/environment.d.ts.map +1 -1
- package/dist/types/src/interfaces/IItem.d.ts +1 -2
- package/dist/types/src/interfaces/IItem.d.ts.map +1 -1
- package/dist/types/src/interfaces/IItemProperty.d.ts +0 -2
- package/dist/types/src/interfaces/IItemProperty.d.ts.map +1 -1
- package/dist/types/src/node/ItemProperty/ItemProperty.d.ts +6 -0
- package/dist/types/src/node/ItemProperty/ItemProperty.d.ts.map +1 -1
- package/dist/types/src/node/db/Db.d.ts +1 -1
- package/dist/types/src/node/db/Db.d.ts.map +1 -1
- package/dist/types/src/node/db/node.app.db.config.d.ts.map +1 -1
- package/dist/types/src/services/allItems/actors/fetchDbData.d.ts +1 -1
- package/dist/types/src/services/allItems/actors/fetchDbData.d.ts.map +1 -1
- package/dist/types/src/services/allItems/actors/fetchSeeds.d.ts +1 -1
- package/dist/types/src/services/allItems/actors/fetchSeeds.d.ts.map +1 -1
- package/dist/types/src/services/allItems/actors/fetchVersions.d.ts +1 -1
- package/dist/types/src/services/allItems/actors/fetchVersions.d.ts.map +1 -1
- package/dist/types/src/services/allItems/actors/processItems.d.ts +1 -1
- package/dist/types/src/services/allItems/actors/processItems.d.ts.map +1 -1
- package/dist/types/src/services/allItems/itemMachineAll.d.ts +9 -9
- package/dist/types/src/services/global/actors/initialize.d.ts.map +1 -1
- package/dist/types/src/services/global/globalMachine.d.ts.map +1 -1
- package/dist/types/src/services/internal/actors/prepareDb.d.ts +3 -1
- package/dist/types/src/services/internal/actors/prepareDb.d.ts.map +1 -1
- package/dist/types/src/services/internal/actors/validateInput.d.ts +3 -1
- package/dist/types/src/services/internal/actors/validateInput.d.ts.map +1 -1
- package/dist/types/src/services/internal/internalMachine.d.ts +56 -1
- package/dist/types/src/services/internal/internalMachine.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/machines.d.ts +2 -0
- package/dist/types/src/types/machines.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/Db-CQyWrG2a.js.map +0 -1
- package/dist/Db-Cv4GVzh1.js.map +0 -1
- package/dist/ItemProperty-l0sNRNKZ.js +0 -2
- package/dist/ItemProperty-l0sNRNKZ.js.map +0 -1
- package/dist/index-DNw_v54Y.js.map +0 -1
- package/dist/index-DQrMMoLY.js.map +0 -1
|
@@ -106,13 +106,35 @@ const ImageSrc = () => PropertyConstructor(Property.ImageSrc());
|
|
|
106
106
|
const Relation = (ref, refValueType) => PropertyConstructor(Property.Relation(ref, refValueType)); // Adjust for actual relation type
|
|
107
107
|
const List = (ref, reValueType) => PropertyConstructor(Property.List(ref, reValueType)); // Adjust for actual list type
|
|
108
108
|
|
|
109
|
+
const isBrowser = () => {
|
|
110
|
+
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
111
|
+
};
|
|
112
|
+
const isReactNative = () => {
|
|
113
|
+
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
114
|
+
};
|
|
115
|
+
const isElectron = () => {
|
|
116
|
+
return typeof process !== 'undefined' && process.versions != null && process.versions.electron != null;
|
|
117
|
+
};
|
|
118
|
+
const getEnvironment = () => {
|
|
119
|
+
if (isBrowser()) {
|
|
120
|
+
return 'browser';
|
|
121
|
+
}
|
|
122
|
+
if (isElectron()) {
|
|
123
|
+
return 'electron';
|
|
124
|
+
}
|
|
125
|
+
if (isReactNative()) {
|
|
126
|
+
return 'react-native';
|
|
127
|
+
}
|
|
128
|
+
return 'node';
|
|
129
|
+
};
|
|
130
|
+
|
|
109
131
|
let Item$2;
|
|
110
132
|
const initItem = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
|
-
if (
|
|
133
|
+
if (isBrowser()) {
|
|
112
134
|
Item$2 = (yield Promise.resolve().then(function () { return Item$1; })).Item;
|
|
113
135
|
}
|
|
114
|
-
|
|
115
|
-
Item$2 = (yield import('./Item-
|
|
136
|
+
if (!isBrowser()) {
|
|
137
|
+
Item$2 = (yield import('./Item-B_ZA4PWq.js')).Item;
|
|
116
138
|
}
|
|
117
139
|
});
|
|
118
140
|
|
|
@@ -158,22 +180,23 @@ const Model = (constructor) => {
|
|
|
158
180
|
|
|
159
181
|
let ItemProperty$2;
|
|
160
182
|
const initItemProperty = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
-
if (
|
|
183
|
+
if (isBrowser()) {
|
|
162
184
|
ItemProperty$2 = (yield Promise.resolve().then(function () { return ItemProperty$1; })).ItemProperty;
|
|
163
185
|
}
|
|
164
|
-
|
|
165
|
-
ItemProperty$2 = (yield import('./ItemProperty-
|
|
186
|
+
if (!isBrowser()) {
|
|
187
|
+
ItemProperty$2 = (yield import('./ItemProperty-CQrtYQT7.js')).ItemProperty;
|
|
166
188
|
}
|
|
167
189
|
});
|
|
168
190
|
|
|
169
191
|
let Db;
|
|
170
192
|
const initDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
-
if (
|
|
172
|
-
Db = (yield import('./Db-
|
|
193
|
+
if (isBrowser()) {
|
|
194
|
+
Db = (yield import('./Db-B1gJQbux.js')).Db;
|
|
173
195
|
}
|
|
174
|
-
|
|
175
|
-
Db = (yield import('./Db-
|
|
196
|
+
if (!isBrowser()) {
|
|
197
|
+
Db = (yield import('./Db-CSgUyick.js')).Db;
|
|
176
198
|
}
|
|
199
|
+
// TODO: Add config for React Native
|
|
177
200
|
});
|
|
178
201
|
|
|
179
202
|
let sqlite3InitModule;
|
|
@@ -226,10 +249,6 @@ const getAppDb = () => {
|
|
|
226
249
|
const isAppDbReady = () => {
|
|
227
250
|
return !!appDb;
|
|
228
251
|
};
|
|
229
|
-
const runQueryForStatement = (statement) => __awaiter(void 0, void 0, void 0, function* () {
|
|
230
|
-
const appDb = getAppDb();
|
|
231
|
-
return appDb.run(sql.raw(statement));
|
|
232
|
-
});
|
|
233
252
|
|
|
234
253
|
const modelStore = new Map();
|
|
235
254
|
const getModels = () => {
|
|
@@ -494,8 +513,8 @@ class BaseDb {
|
|
|
494
513
|
static isAppDbReady() {
|
|
495
514
|
return this.PlatformClass.isAppDbReady();
|
|
496
515
|
}
|
|
497
|
-
static prepareDb() {
|
|
498
|
-
return this.PlatformClass.prepareDb();
|
|
516
|
+
static prepareDb(filesDir) {
|
|
517
|
+
return this.PlatformClass.prepareDb(filesDir);
|
|
499
518
|
}
|
|
500
519
|
static connectToDb(pathToDir, dbName) {
|
|
501
520
|
return this.PlatformClass.connectToDb(pathToDir, dbName);
|
|
@@ -802,7 +821,7 @@ const createMetadata = (metadataValues, propertyRecordSchema) => __awaiter(void
|
|
|
802
821
|
.returning();
|
|
803
822
|
});
|
|
804
823
|
|
|
805
|
-
const createNewItem
|
|
824
|
+
const createNewItem = (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
806
825
|
var _b;
|
|
807
826
|
var { modelName } = _a, propertyData = __rest(_a, ["modelName"]);
|
|
808
827
|
if (!modelName) {
|
|
@@ -867,6 +886,9 @@ const getExistingItem = (_a) => __awaiter(void 0, [_a], void 0, function* ({ see
|
|
|
867
886
|
|
|
868
887
|
const initialize$3 = fromCallback(({ sendBack, input: { context } }) => {
|
|
869
888
|
const { seedLocalId, seedUid, ModelClass } = context;
|
|
889
|
+
if (!ModelClass) {
|
|
890
|
+
throw new Error('ModelClass is required');
|
|
891
|
+
}
|
|
870
892
|
const modelName = ModelClass.originalConstructor.name;
|
|
871
893
|
const modelNamePlural = pluralize(modelName);
|
|
872
894
|
const modelTableName = modelNamePlural.toLowerCase();
|
|
@@ -1560,96 +1582,84 @@ const syncDbWithEasHandler = throttle((_) => __awaiter(void 0, void 0, void 0, f
|
|
|
1560
1582
|
trailing: false,
|
|
1561
1583
|
});
|
|
1562
1584
|
|
|
1563
|
-
const isNode = () => {
|
|
1564
|
-
return (typeof process !== 'undefined' &&
|
|
1565
|
-
process.versions != null &&
|
|
1566
|
-
process.versions.node != null);
|
|
1567
|
-
};
|
|
1568
|
-
const isReactNative = () => {
|
|
1569
|
-
return typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
1570
|
-
};
|
|
1571
|
-
|
|
1572
1585
|
const logger$o = debug('app:services:global:actors:initialize');
|
|
1573
1586
|
const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
|
|
1574
|
-
const { internalService, models, endpoints, arweaveDomain } = context;
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
if (isNode()) {
|
|
1578
|
-
environment = 'node';
|
|
1587
|
+
const { internalService, models, endpoints, arweaveDomain, addresses, } = context;
|
|
1588
|
+
if (!internalService) {
|
|
1589
|
+
throw new Error('internalService is required');
|
|
1579
1590
|
}
|
|
1580
|
-
if (
|
|
1581
|
-
|
|
1591
|
+
if (!models) {
|
|
1592
|
+
throw new Error('models is required');
|
|
1582
1593
|
}
|
|
1594
|
+
let environment = getEnvironment();
|
|
1583
1595
|
let internalSubscription;
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
arweaveDomain,
|
|
1603
|
-
});
|
|
1596
|
+
const _initFileSystem = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1597
|
+
return;
|
|
1598
|
+
// return new Promise((resolve) => {
|
|
1599
|
+
// })
|
|
1600
|
+
});
|
|
1601
|
+
const _initInternal = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1602
|
+
return new Promise((resolve) => {
|
|
1603
|
+
internalSubscription = internalService.subscribe((snapshot) => {
|
|
1604
|
+
logger$o('[sdk] [internal] snapshot', snapshot);
|
|
1605
|
+
if (snapshot.value === 'ready') {
|
|
1606
|
+
resolve();
|
|
1607
|
+
}
|
|
1608
|
+
});
|
|
1609
|
+
internalService.send({
|
|
1610
|
+
type: 'init',
|
|
1611
|
+
endpoints,
|
|
1612
|
+
addresses,
|
|
1613
|
+
arweaveDomain,
|
|
1604
1614
|
});
|
|
1605
1615
|
});
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
}
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1616
|
+
});
|
|
1617
|
+
const _initAllItemsServices = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1618
|
+
const appDb = BaseDb.getAppDb();
|
|
1619
|
+
const rows = yield appDb
|
|
1620
|
+
.select()
|
|
1621
|
+
.from(appState)
|
|
1622
|
+
.where(like(appState.key, 'snapshot__%'));
|
|
1623
|
+
const payloadObj = {
|
|
1624
|
+
create: {},
|
|
1625
|
+
restore: {},
|
|
1626
|
+
};
|
|
1627
|
+
const modelNamesRestored = [];
|
|
1628
|
+
if (rows && rows.length > 0) {
|
|
1629
|
+
for (const row of rows) {
|
|
1630
|
+
const modelName = row.key.replace('snapshot__', '');
|
|
1631
|
+
payloadObj.restore[modelName] = JSON.parse(row.value);
|
|
1632
|
+
modelNamesRestored.push(modelName);
|
|
1623
1633
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1634
|
+
}
|
|
1635
|
+
for (const [modelName, ModelClass] of Object.entries(models)) {
|
|
1636
|
+
if (!modelNamesRestored.includes(modelName)) {
|
|
1637
|
+
payloadObj.create[modelName] = ModelClass;
|
|
1628
1638
|
}
|
|
1629
|
-
|
|
1630
|
-
});
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
}
|
|
1639
|
+
}
|
|
1640
|
+
sendBack(Object.assign({ type: GLOBAL_INITIALIZING_CREATE_ALL_ITEMS_SERVICES }, payloadObj));
|
|
1641
|
+
});
|
|
1642
|
+
const _initEas = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1643
|
+
yield fetchSchemaUids();
|
|
1644
|
+
});
|
|
1645
|
+
_initFileSystem().then(() => {
|
|
1646
|
+
logger$o('[global/actors] File system initialized');
|
|
1647
|
+
});
|
|
1648
|
+
_initInternal()
|
|
1649
|
+
.then(() => {
|
|
1650
|
+
return _initAllItemsServices();
|
|
1651
|
+
})
|
|
1652
|
+
.then(() => {
|
|
1653
|
+
return _initEas();
|
|
1654
|
+
})
|
|
1655
|
+
.then(() => {
|
|
1656
|
+
logger$o('[global/actors] Internal initialized');
|
|
1657
|
+
sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY });
|
|
1658
|
+
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
1659
|
+
});
|
|
1660
|
+
// _initEas().then(() => {
|
|
1661
|
+
// logger('EAS initialized')
|
|
1662
|
+
// })
|
|
1653
1663
|
sendBack({ type: GLOBAL_INITIALIZING_SEND_CONFIG, environment });
|
|
1654
1664
|
return () => {
|
|
1655
1665
|
internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
|
|
@@ -1686,7 +1696,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
1686
1696
|
if (!models$1) {
|
|
1687
1697
|
return;
|
|
1688
1698
|
}
|
|
1689
|
-
const { models: SeedModels } = yield import('./seed.schema.config-
|
|
1699
|
+
const { models: SeedModels } = yield import('./seed.schema.config-uN0rq0mU.js');
|
|
1690
1700
|
const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
|
|
1691
1701
|
let hasModelsInDb = false;
|
|
1692
1702
|
const schemaDefsByModelName = new Map();
|
|
@@ -2299,22 +2309,30 @@ const dbMachine = setup({
|
|
|
2299
2309
|
},
|
|
2300
2310
|
});
|
|
2301
2311
|
|
|
2302
|
-
const validateInput = fromCallback(({ sendBack, input: {
|
|
2303
|
-
const { endpoints, addresses } =
|
|
2304
|
-
|
|
2305
|
-
throw new Error('validateInput called from non-browser context');
|
|
2306
|
-
}
|
|
2312
|
+
const validateInput = fromCallback(({ sendBack, input: { context } }) => {
|
|
2313
|
+
const { endpoints, addresses, arweaveDomain } = context;
|
|
2314
|
+
let { filesDir } = context;
|
|
2307
2315
|
if (!endpoints || !endpoints.filePaths || !endpoints.files) {
|
|
2308
2316
|
throw new Error('validateInput called with invalid endpoints');
|
|
2309
2317
|
}
|
|
2310
2318
|
if (!addresses || !addresses.length) {
|
|
2311
2319
|
throw new Error('validateInput called with invalid addresses');
|
|
2312
2320
|
}
|
|
2321
|
+
if (!filesDir) {
|
|
2322
|
+
if (isBrowser()) {
|
|
2323
|
+
filesDir = '/';
|
|
2324
|
+
}
|
|
2325
|
+
if (!isBrowser()) {
|
|
2326
|
+
throw new Error('validateInput called with invalid filesDir');
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2313
2329
|
const _validateInput = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2314
2330
|
sendBack({
|
|
2315
2331
|
type: INTERNAL_VALIDATING_INPUT_SUCCESS,
|
|
2316
2332
|
endpoints,
|
|
2317
2333
|
addresses,
|
|
2334
|
+
filesDir,
|
|
2335
|
+
arweaveDomain: arweaveDomain || ARWEAVE_HOST,
|
|
2318
2336
|
});
|
|
2319
2337
|
});
|
|
2320
2338
|
_validateInput().then(() => {
|
|
@@ -2322,12 +2340,13 @@ const validateInput = fromCallback(({ sendBack, input: { event } }) => {
|
|
|
2322
2340
|
});
|
|
2323
2341
|
});
|
|
2324
2342
|
|
|
2325
|
-
const prepareDb = fromCallback(({ sendBack }) => {
|
|
2343
|
+
const prepareDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
2344
|
+
const { filesDir } = context;
|
|
2345
|
+
if (!filesDir) {
|
|
2346
|
+
throw new Error('filesDir is required');
|
|
2347
|
+
}
|
|
2326
2348
|
const _prepareDb = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2327
|
-
|
|
2328
|
-
return;
|
|
2329
|
-
}
|
|
2330
|
-
const manager = yield BaseDb.prepareDb();
|
|
2349
|
+
const manager = yield BaseDb.prepareDb(filesDir);
|
|
2331
2350
|
if (manager) {
|
|
2332
2351
|
sendBack({ type: 'prepareDbSuccess', manager });
|
|
2333
2352
|
}
|
|
@@ -3096,6 +3115,8 @@ const internalMachine = setup({
|
|
|
3096
3115
|
actions: assign({
|
|
3097
3116
|
endpoints: ({ event }) => event.endpoints,
|
|
3098
3117
|
addresses: ({ event }) => event.addresses,
|
|
3118
|
+
filesDir: ({ event }) => event.filesDir,
|
|
3119
|
+
arweaveDomain: ({ event }) => event.arweaveDomain,
|
|
3099
3120
|
}),
|
|
3100
3121
|
},
|
|
3101
3122
|
},
|
|
@@ -4043,11 +4064,15 @@ const globalMachine = setup({
|
|
|
4043
4064
|
addedModelRecordsToDb: false,
|
|
4044
4065
|
models: ({ event }) => event.models,
|
|
4045
4066
|
endpoints: ({ event }) => event.endpoints,
|
|
4046
|
-
|
|
4067
|
+
filesDir: ({ event }) => event.filesDir,
|
|
4068
|
+
internalService: ({ spawn, event }) => {
|
|
4047
4069
|
return spawn(internalMachine, {
|
|
4048
4070
|
systemId: MachineIds.INTERNAL,
|
|
4049
4071
|
input: {
|
|
4050
|
-
endpoints:
|
|
4072
|
+
endpoints: event.endpoints,
|
|
4073
|
+
filesDir: event.filesDir,
|
|
4074
|
+
addresses: event.addresses,
|
|
4075
|
+
arweaveDomain: event.arweaveDomain,
|
|
4051
4076
|
},
|
|
4052
4077
|
});
|
|
4053
4078
|
},
|
|
@@ -5492,7 +5517,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
|
|
|
5492
5517
|
if (propertyRecordSchema &&
|
|
5493
5518
|
propertyRecordSchema.storageType &&
|
|
5494
5519
|
propertyRecordSchema.storageType === 'ItemStorage') {
|
|
5495
|
-
const { Item } = yield import('./index-
|
|
5520
|
+
const { Item } = yield import('./index-8LV9Tqv2.js');
|
|
5496
5521
|
const item = yield Item.find({
|
|
5497
5522
|
seedLocalId,
|
|
5498
5523
|
modelName,
|
|
@@ -5555,7 +5580,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
5555
5580
|
!refResolvedValue) {
|
|
5556
5581
|
safeNewValue = escapeSqliteString(newValue);
|
|
5557
5582
|
}
|
|
5558
|
-
const appDb = getAppDb();
|
|
5583
|
+
const appDb = BaseDb.getAppDb();
|
|
5559
5584
|
const rows = yield appDb
|
|
5560
5585
|
.select()
|
|
5561
5586
|
.from(metadata)
|
|
@@ -5596,7 +5621,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
5596
5621
|
ref_resolved_display_value = ${refResolvedDisplayValue ? `'${refResolvedDisplayValue}'` : 'NULL'},
|
|
5597
5622
|
updated_at = ${Date.now()}
|
|
5598
5623
|
WHERE local_id = '${localId}';`;
|
|
5599
|
-
yield
|
|
5624
|
+
yield appDb.run(sql.raw(updatePropertyStatement));
|
|
5600
5625
|
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
5601
5626
|
return;
|
|
5602
5627
|
}
|
|
@@ -5634,7 +5659,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
5634
5659
|
${refResolvedDisplayValue ? `'${refResolvedDisplayValue}'` : 'NULL'},
|
|
5635
5660
|
${localStorageDir ? `'${localStorageDir}'` : 'NULL'},
|
|
5636
5661
|
${Date.now()});`;
|
|
5637
|
-
yield
|
|
5662
|
+
yield appDb.run(sql.raw(newPropertyStatement));
|
|
5638
5663
|
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
5639
5664
|
return;
|
|
5640
5665
|
}
|
|
@@ -5680,7 +5705,7 @@ const updateItemPropertyValue = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
5680
5705
|
${refResolvedDisplayValue ? `'${refResolvedDisplayValue}'` : 'NULL'},
|
|
5681
5706
|
${localStorageDir ? `'${localStorageDir}'` : 'NULL'},
|
|
5682
5707
|
${Date.now()});`;
|
|
5683
|
-
yield
|
|
5708
|
+
yield appDb.run(sql.raw(newPropertyStatement));
|
|
5684
5709
|
sendItemUpdateEvent({ modelName, seedLocalId, seedUid });
|
|
5685
5710
|
});
|
|
5686
5711
|
|
|
@@ -7790,7 +7815,7 @@ const useCreateItem = (modelName) => {
|
|
|
7790
7815
|
return;
|
|
7791
7816
|
}
|
|
7792
7817
|
setIsCreatingItem(true);
|
|
7793
|
-
const { seedLocalId } = yield createNewItem
|
|
7818
|
+
const { seedLocalId } = yield createNewItem(Object.assign({ modelName }, itemData));
|
|
7794
7819
|
yield Item.find({ modelName, seedLocalId });
|
|
7795
7820
|
eventEmitter.emit('item.requestAll', { modelName });
|
|
7796
7821
|
setIsCreatingItem(false);
|
|
@@ -8061,41 +8086,42 @@ const setupServiceHandlers = () => {
|
|
|
8061
8086
|
};
|
|
8062
8087
|
|
|
8063
8088
|
const initEasClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8064
|
-
if (
|
|
8089
|
+
if (isBrowser()) {
|
|
8065
8090
|
(yield import('./EasClient-Bbxr5rcF.js')).EasClient;
|
|
8066
8091
|
}
|
|
8067
|
-
|
|
8092
|
+
if (!isBrowser()) {
|
|
8068
8093
|
(yield import('./EasClient-BGQRv2-M.js')).EasClient;
|
|
8069
8094
|
}
|
|
8070
8095
|
});
|
|
8071
8096
|
|
|
8072
8097
|
const initQueryClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8073
|
-
if (
|
|
8098
|
+
if (isBrowser()) {
|
|
8074
8099
|
(yield import('./QueryClient-Dk66c5aw.js')).QueryClient;
|
|
8075
8100
|
}
|
|
8076
|
-
|
|
8101
|
+
if (!isBrowser()) {
|
|
8077
8102
|
(yield import('./QueryClient-CY_4gVB3.js')).QueryClient;
|
|
8078
8103
|
}
|
|
8079
8104
|
});
|
|
8080
8105
|
|
|
8081
8106
|
const initFileManager = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
8082
|
-
if (
|
|
8107
|
+
if (isBrowser()) {
|
|
8083
8108
|
(yield import('./FileManager-BGej9rn4.js')).FileManager;
|
|
8084
8109
|
}
|
|
8085
|
-
|
|
8110
|
+
if (!isBrowser()) {
|
|
8086
8111
|
(yield import('./FileManager-CYXquukS.js')).FileManager;
|
|
8087
8112
|
}
|
|
8088
8113
|
});
|
|
8089
8114
|
|
|
8090
8115
|
const client = {
|
|
8091
|
-
init: (
|
|
8116
|
+
init: (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8117
|
+
const { config, addresses } = options;
|
|
8092
8118
|
yield initItem();
|
|
8093
8119
|
yield initItemProperty();
|
|
8094
8120
|
yield initEasClient();
|
|
8095
8121
|
yield initQueryClient();
|
|
8096
8122
|
yield initFileManager();
|
|
8097
8123
|
yield initDb();
|
|
8098
|
-
const { endpoints, models, arweaveDomain } = config;
|
|
8124
|
+
const { endpoints, models, arweaveDomain, filesDir, } = config;
|
|
8099
8125
|
if (arweaveDomain) {
|
|
8100
8126
|
setArweaveDomain(arweaveDomain);
|
|
8101
8127
|
}
|
|
@@ -8118,8 +8144,9 @@ const client = {
|
|
|
8118
8144
|
models,
|
|
8119
8145
|
addresses,
|
|
8120
8146
|
arweaveDomain,
|
|
8147
|
+
filesDir,
|
|
8121
8148
|
});
|
|
8122
|
-
const { models: internalModels } = yield import('./seed.schema.config-
|
|
8149
|
+
const { models: internalModels } = yield import('./seed.schema.config-uN0rq0mU.js');
|
|
8123
8150
|
for (const [key, value] of Object.entries(internalModels)) {
|
|
8124
8151
|
setModel(key, value);
|
|
8125
8152
|
}
|
|
@@ -8166,5 +8193,5 @@ const client = {
|
|
|
8166
8193
|
|
|
8167
8194
|
enableMapSet();
|
|
8168
8195
|
|
|
8169
|
-
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,
|
|
8170
|
-
//# sourceMappingURL=index-
|
|
8196
|
+
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, getSqliteWasmClient as c, ImageSrc as d, Item$2 as e, ItemProperty$2 as f, getAppDb as g, useItem as h, isAppDbReady as i, useItemProperties as j, useCreateItem as k, useItemProperty as l, useDeleteItem as m, useGlobalServiceStatus as n, usePublishItem as o, usePersistedSnapshots as p, useServices as q, useService as r, getCorrectId as s, getGlobalService as t, useItems as u, eventEmitter as v, withSeed as w, client as x };
|
|
8197
|
+
//# sourceMappingURL=index-Xi0K-lIT.js.map
|