@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.
Files changed (97) hide show
  1. package/dist/{Db-CQyWrG2a.js → Db-B1gJQbux.js} +3 -3
  2. package/dist/Db-B1gJQbux.js.map +1 -0
  3. package/dist/{Db-Cv4GVzh1.js → Db-CSgUyick.js} +33 -11
  4. package/dist/Db-CSgUyick.js.map +1 -0
  5. package/dist/{Item-UegZbC_j.js → Item-B_ZA4PWq.js} +2 -2
  6. package/dist/{Item-UegZbC_j.js.map → Item-B_ZA4PWq.js.map} +1 -1
  7. package/dist/ItemProperty-CQrtYQT7.js +39 -0
  8. package/dist/ItemProperty-CQrtYQT7.js.map +1 -0
  9. package/dist/{index-DQrMMoLY.js → index-8LV9Tqv2.js} +2 -2
  10. package/dist/index-8LV9Tqv2.js.map +1 -0
  11. package/dist/{index-DNw_v54Y.js → index-Xi0K-lIT.js} +155 -128
  12. package/dist/index-Xi0K-lIT.js.map +1 -0
  13. package/dist/main.js +1 -1
  14. package/dist/node/db/node.app.db.config.ts +1 -0
  15. package/dist/{seed.schema.config-SuJxms_6.js → seed.schema.config-uN0rq0mU.js} +2 -2
  16. package/dist/{seed.schema.config-SuJxms_6.js.map → seed.schema.config-uN0rq0mU.js.map} +1 -1
  17. package/dist/src/BaseDb.ts +2 -2
  18. package/dist/src/BaseItem.ts +3 -5
  19. package/dist/src/Db.ts +37 -3
  20. package/dist/src/IItem.ts +0 -1
  21. package/dist/src/IItemProperty.ts +0 -1
  22. package/dist/src/ItemProperty.ts +9 -0
  23. package/dist/src/client.ts +4 -2
  24. package/dist/src/environment.ts +20 -0
  25. package/dist/src/fetchDbData.ts +1 -1
  26. package/dist/src/fetchSeeds.ts +1 -1
  27. package/dist/src/fetchVersions.ts +1 -1
  28. package/dist/src/globalMachine.ts +6 -2
  29. package/dist/src/initialize.ts +75 -78
  30. package/dist/src/internalMachine.ts +2 -0
  31. package/dist/src/machines.ts +2 -0
  32. package/dist/src/node.app.db.config.ts +1 -0
  33. package/dist/src/prepareDb.ts +12 -6
  34. package/dist/src/processItems.ts +1 -1
  35. package/dist/src/sqlWasmClient.ts +4 -4
  36. package/dist/src/updateItemPropertyValue.ts +5 -6
  37. package/dist/src/validateInput.ts +22 -8
  38. package/dist/types/src/Item/BaseItem.d.ts +1 -10
  39. package/dist/types/src/Item/BaseItem.d.ts.map +1 -1
  40. package/dist/types/src/Item/index.d.ts +2 -2
  41. package/dist/types/src/Item/index.d.ts.map +1 -1
  42. package/dist/types/src/Item/service/actors/initialize.d.ts +1 -1
  43. package/dist/types/src/Item/service/actors/initialize.d.ts.map +1 -1
  44. package/dist/types/src/ItemProperty/index.d.ts +2 -2
  45. package/dist/types/src/ItemProperty/index.d.ts.map +1 -1
  46. package/dist/types/src/browser/db/Db.d.ts +1 -1
  47. package/dist/types/src/browser/db/Db.d.ts.map +1 -1
  48. package/dist/types/src/browser/db/sqlWasmClient.d.ts.map +1 -1
  49. package/dist/types/src/client.d.ts +1 -1
  50. package/dist/types/src/client.d.ts.map +1 -1
  51. package/dist/types/src/db/Db/BaseDb.d.ts +1 -1
  52. package/dist/types/src/db/Db/BaseDb.d.ts.map +1 -1
  53. package/dist/types/src/db/Db/index.d.ts.map +1 -1
  54. package/dist/types/src/db/write/updateItemPropertyValue.d.ts.map +1 -1
  55. package/dist/types/src/helpers/ArweaveClient/index.d.ts.map +1 -1
  56. package/dist/types/src/helpers/EasClient/index.d.ts.map +1 -1
  57. package/dist/types/src/helpers/FileManager/index.d.ts.map +1 -1
  58. package/dist/types/src/helpers/QueryClient/index.d.ts.map +1 -1
  59. package/dist/types/src/helpers/environment.d.ts +2 -0
  60. package/dist/types/src/helpers/environment.d.ts.map +1 -1
  61. package/dist/types/src/interfaces/IItem.d.ts +1 -2
  62. package/dist/types/src/interfaces/IItem.d.ts.map +1 -1
  63. package/dist/types/src/interfaces/IItemProperty.d.ts +0 -2
  64. package/dist/types/src/interfaces/IItemProperty.d.ts.map +1 -1
  65. package/dist/types/src/node/ItemProperty/ItemProperty.d.ts +6 -0
  66. package/dist/types/src/node/ItemProperty/ItemProperty.d.ts.map +1 -1
  67. package/dist/types/src/node/db/Db.d.ts +1 -1
  68. package/dist/types/src/node/db/Db.d.ts.map +1 -1
  69. package/dist/types/src/node/db/node.app.db.config.d.ts.map +1 -1
  70. package/dist/types/src/services/allItems/actors/fetchDbData.d.ts +1 -1
  71. package/dist/types/src/services/allItems/actors/fetchDbData.d.ts.map +1 -1
  72. package/dist/types/src/services/allItems/actors/fetchSeeds.d.ts +1 -1
  73. package/dist/types/src/services/allItems/actors/fetchSeeds.d.ts.map +1 -1
  74. package/dist/types/src/services/allItems/actors/fetchVersions.d.ts +1 -1
  75. package/dist/types/src/services/allItems/actors/fetchVersions.d.ts.map +1 -1
  76. package/dist/types/src/services/allItems/actors/processItems.d.ts +1 -1
  77. package/dist/types/src/services/allItems/actors/processItems.d.ts.map +1 -1
  78. package/dist/types/src/services/allItems/itemMachineAll.d.ts +9 -9
  79. package/dist/types/src/services/global/actors/initialize.d.ts.map +1 -1
  80. package/dist/types/src/services/global/globalMachine.d.ts.map +1 -1
  81. package/dist/types/src/services/internal/actors/prepareDb.d.ts +3 -1
  82. package/dist/types/src/services/internal/actors/prepareDb.d.ts.map +1 -1
  83. package/dist/types/src/services/internal/actors/validateInput.d.ts +3 -1
  84. package/dist/types/src/services/internal/actors/validateInput.d.ts.map +1 -1
  85. package/dist/types/src/services/internal/internalMachine.d.ts +56 -1
  86. package/dist/types/src/services/internal/internalMachine.d.ts.map +1 -1
  87. package/dist/types/src/types/index.d.ts +1 -0
  88. package/dist/types/src/types/index.d.ts.map +1 -1
  89. package/dist/types/src/types/machines.d.ts +2 -0
  90. package/dist/types/src/types/machines.d.ts.map +1 -1
  91. package/package.json +1 -1
  92. package/dist/Db-CQyWrG2a.js.map +0 -1
  93. package/dist/Db-Cv4GVzh1.js.map +0 -1
  94. package/dist/ItemProperty-l0sNRNKZ.js +0 -2
  95. package/dist/ItemProperty-l0sNRNKZ.js.map +0 -1
  96. package/dist/index-DNw_v54Y.js.map +0 -1
  97. 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 (typeof window !== 'undefined') {
133
+ if (isBrowser()) {
112
134
  Item$2 = (yield Promise.resolve().then(function () { return Item$1; })).Item;
113
135
  }
114
- else {
115
- Item$2 = (yield import('./Item-UegZbC_j.js')).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 (typeof window !== 'undefined') {
183
+ if (isBrowser()) {
162
184
  ItemProperty$2 = (yield Promise.resolve().then(function () { return ItemProperty$1; })).ItemProperty;
163
185
  }
164
- else {
165
- ItemProperty$2 = (yield import('./ItemProperty-l0sNRNKZ.js')).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 (typeof window !== 'undefined') {
172
- Db = (yield import('./Db-CQyWrG2a.js')).Db;
193
+ if (isBrowser()) {
194
+ Db = (yield import('./Db-B1gJQbux.js')).Db;
173
195
  }
174
- else {
175
- Db = (yield import('./Db-Cv4GVzh1.js')).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$1 = (_a) => __awaiter(void 0, void 0, void 0, function* () {
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
- const { addresses } = event;
1576
- let environment = 'browser';
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 (isReactNative()) {
1581
- environment = 'react-native';
1591
+ if (!models) {
1592
+ throw new Error('models is required');
1582
1593
  }
1594
+ let environment = getEnvironment();
1583
1595
  let internalSubscription;
1584
- if (environment === 'browser' && models) {
1585
- const _initFileSystem = () => __awaiter(void 0, void 0, void 0, function* () {
1586
- return;
1587
- // return new Promise((resolve) => {
1588
- // })
1589
- });
1590
- const _initInternal = () => __awaiter(void 0, void 0, void 0, function* () {
1591
- return new Promise((resolve) => {
1592
- internalSubscription = internalService.subscribe((snapshot) => {
1593
- logger$o('[sdk] [internal] snapshot', snapshot);
1594
- if (snapshot.value === 'ready') {
1595
- resolve();
1596
- }
1597
- });
1598
- internalService.send({
1599
- type: 'init',
1600
- endpoints,
1601
- addresses,
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
- const _initAllItemsServices = () => __awaiter(void 0, void 0, void 0, function* () {
1607
- const appDb = BaseDb.getAppDb();
1608
- const rows = yield appDb
1609
- .select()
1610
- .from(appState)
1611
- .where(like(appState.key, 'snapshot__%'));
1612
- const payloadObj = {
1613
- create: {},
1614
- restore: {},
1615
- };
1616
- const modelNamesRestored = [];
1617
- if (rows && rows.length > 0) {
1618
- for (const row of rows) {
1619
- const modelName = row.key.replace('snapshot__', '');
1620
- payloadObj.restore[modelName] = JSON.parse(row.value);
1621
- modelNamesRestored.push(modelName);
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
- for (const [modelName, ModelClass] of Object.entries(models)) {
1625
- if (!modelNamesRestored.includes(modelName)) {
1626
- payloadObj.create[modelName] = ModelClass;
1627
- }
1634
+ }
1635
+ for (const [modelName, ModelClass] of Object.entries(models)) {
1636
+ if (!modelNamesRestored.includes(modelName)) {
1637
+ payloadObj.create[modelName] = ModelClass;
1628
1638
  }
1629
- sendBack(Object.assign({ type: GLOBAL_INITIALIZING_CREATE_ALL_ITEMS_SERVICES }, payloadObj));
1630
- });
1631
- const _initEas = () => __awaiter(void 0, void 0, void 0, function* () {
1632
- yield fetchSchemaUids();
1633
- });
1634
- _initFileSystem().then(() => {
1635
- logger$o('[global/actors] File system initialized');
1636
- });
1637
- _initInternal()
1638
- .then(() => {
1639
- return _initAllItemsServices();
1640
- })
1641
- .then(() => {
1642
- return _initEas();
1643
- })
1644
- .then(() => {
1645
- logger$o('[global/actors] Internal initialized');
1646
- sendBack({ type: GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY });
1647
- internalSubscription === null || internalSubscription === void 0 ? void 0 : internalSubscription.unsubscribe();
1648
- });
1649
- // _initEas().then(() => {
1650
- // logger('EAS initialized')
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-SuJxms_6.js');
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: { event } }) => {
2303
- const { endpoints, addresses } = event;
2304
- if (typeof window === 'undefined') {
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
- if (typeof window === 'undefined') {
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
- internalService: ({ spawn, context }) => {
4067
+ filesDir: ({ event }) => event.filesDir,
4068
+ internalService: ({ spawn, event }) => {
4047
4069
  return spawn(internalMachine, {
4048
4070
  systemId: MachineIds.INTERNAL,
4049
4071
  input: {
4050
- endpoints: context.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-DQrMMoLY.js');
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 runQueryForStatement(updatePropertyStatement);
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 runQueryForStatement(newPropertyStatement);
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 runQueryForStatement(newPropertyStatement);
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$1(Object.assign({ modelName }, itemData));
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 (typeof window !== 'undefined') {
8089
+ if (isBrowser()) {
8065
8090
  (yield import('./EasClient-Bbxr5rcF.js')).EasClient;
8066
8091
  }
8067
- else {
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 (typeof window !== 'undefined') {
8098
+ if (isBrowser()) {
8074
8099
  (yield import('./QueryClient-Dk66c5aw.js')).QueryClient;
8075
8100
  }
8076
- else {
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 (typeof window !== 'undefined') {
8107
+ if (isBrowser()) {
8083
8108
  (yield import('./FileManager-BGej9rn4.js')).FileManager;
8084
8109
  }
8085
- else {
8110
+ if (!isBrowser()) {
8086
8111
  (yield import('./FileManager-CYXquukS.js')).FileManager;
8087
8112
  }
8088
8113
  });
8089
8114
 
8090
8115
  const client = {
8091
- init: (_a) => __awaiter(void 0, [_a], void 0, function* ({ config, addresses }) {
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-SuJxms_6.js');
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, BaseDb as a, getSqliteWasmClient as b, ImageSrc as c, Item$2 as d, ItemProperty$2 as e, useItem as f, getAppDb as g, useItemProperties as h, isAppDbReady as i, useCreateItem as j, useItemProperty as k, useDeleteItem as l, useGlobalServiceStatus as m, usePublishItem as n, usePersistedSnapshots as o, useServices as p, useService as q, getCorrectId as r, getGlobalService as s, eventEmitter as t, useItems as u, client as v, withSeed as w };
8170
- //# sourceMappingURL=index-DNw_v54Y.js.map
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