@seedprotocol/sdk 0.2.50 → 0.2.51

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 (44) hide show
  1. package/dist/{ArweaveClient-Dcqcpsq4.js → ArweaveClient-D1TsTBoj.js} +2 -2
  2. package/dist/{ArweaveClient-Dh7LRIqD.js.map → ArweaveClient-D1TsTBoj.js.map} +1 -1
  3. package/dist/{ArweaveClient-Dh7LRIqD.js → ArweaveClient-DpdXUcVJ.js} +2 -2
  4. package/dist/{ArweaveClient-Dcqcpsq4.js.map → ArweaveClient-DpdXUcVJ.js.map} +1 -1
  5. package/dist/{Db-BwkMqaQe.js → Db-DMJ0v3gO.js} +3 -3
  6. package/dist/{Db-BwkMqaQe.js.map → Db-DMJ0v3gO.js.map} +1 -1
  7. package/dist/{Db-jJH2s0gO.js → Db-quJxmvHH.js} +3 -3
  8. package/dist/{Db-jJH2s0gO.js.map → Db-quJxmvHH.js.map} +1 -1
  9. package/dist/{EasClient-A1xC7Gm-.js → EasClient-ClZDuT3o.js} +2 -2
  10. package/dist/{EasClient-A1xC7Gm-.js.map → EasClient-ClZDuT3o.js.map} +1 -1
  11. package/dist/{EasClient-m2mXad59.js → EasClient-DfnGY_2X.js} +2 -2
  12. package/dist/{EasClient-m2mXad59.js.map → EasClient-DfnGY_2X.js.map} +1 -1
  13. package/dist/{FileManager-Dv2zn1RW.js → FileManager-texI7UwL.js} +2 -2
  14. package/dist/{FileManager-Dv2zn1RW.js.map → FileManager-texI7UwL.js.map} +1 -1
  15. package/dist/{Item-DI3FxVPV.js → Item-D4n439Ei.js} +3 -3
  16. package/dist/{Item-DI3FxVPV.js.map → Item-D4n439Ei.js.map} +1 -1
  17. package/dist/{ItemProperty-CxNUwVnR.js → ItemProperty-Be5ymRVT.js} +3 -3
  18. package/dist/{ItemProperty-CxNUwVnR.js.map → ItemProperty-Be5ymRVT.js.map} +1 -1
  19. package/dist/{QueryClient-C-hFMF2j.js → QueryClient-B1HkAaJo.js} +2 -2
  20. package/dist/{QueryClient-C-hFMF2j.js.map → QueryClient-B1HkAaJo.js.map} +1 -1
  21. package/dist/{QueryClient-C02sPZ-K.js → QueryClient-BPoc9eBn.js} +2 -2
  22. package/dist/{QueryClient-C02sPZ-K.js.map → QueryClient-BPoc9eBn.js.map} +1 -1
  23. package/dist/bin.js +5 -5
  24. package/dist/{constants-C03RQQht.js → constants-5PxfAeqj.js} +4 -1
  25. package/dist/constants-5PxfAeqj.js.map +1 -0
  26. package/dist/{index-Dv8GeuSw.js → index-BLla2o05.js} +3 -3
  27. package/dist/index-BLla2o05.js.map +1 -0
  28. package/dist/{index-CKrLHw3B.js → index-BeKRizLf.js} +59 -20
  29. package/dist/index-BeKRizLf.js.map +1 -0
  30. package/dist/main.js +2 -2
  31. package/dist/{seed.schema.config-1s-iWHq_.js → seed.schema.config-CMpV_hyS.js} +3 -3
  32. package/dist/{seed.schema.config-1s-iWHq_.js.map → seed.schema.config-CMpV_hyS.js.map} +1 -1
  33. package/dist/src/BaseFileManager.ts +4 -0
  34. package/dist/src/saveImageSrc.ts +2 -2
  35. package/dist/src/saveItemStorage.ts +3 -2
  36. package/dist/types/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
  37. package/dist/types/src/browser/helpers/FileManager.d.ts +1 -0
  38. package/dist/types/src/browser/helpers/FileManager.d.ts.map +1 -1
  39. package/dist/types/src/helpers/FileManager/BaseFileManager.d.ts +1 -0
  40. package/dist/types/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/dist/constants-C03RQQht.js.map +0 -1
  43. package/dist/index-CKrLHw3B.js.map +0 -1
  44. package/dist/index-Dv8GeuSw.js.map +0 -1
@@ -2,7 +2,7 @@ import { immerable, produce, enableMapSet } from 'immer';
2
2
  import 'reflect-metadata';
3
3
  import { Type } from '@sinclair/typebox';
4
4
  import { fromCallback, setup, assign, waitFor, createActor, raise } from 'xstate';
5
- import { b as BaseQueryClient, a as BaseEasClient, G as GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY, f as GLOBAL_INITIALIZING_SEND_CONFIG, g as GLOBAL_INITIALIZING_CREATE_ALL_ITEMS_SERVICES, h as GLOBAL_ADDING_MODELS_TO_DB_SUCCESS, D as DB_CHECK_STATUS_UPDATE_PATHS, i as DB_CHECK_STATUS_EXISTS, d as BROWSER_FS_TOP_DIR, j as DB_CREATING_SUCCESS, k as DB_VALIDATING_SUCCESS, l as DB_VALIDATING_WAIT, c as BaseFileManager, m as DB_MIGRATING_SUCCESS, n as DB_WAITING_FOR_FILES_RECEIVED, M as MachineIds, o as DB_MIGRATING_WAIT, p as DbState, I as INTERNAL_VALIDATING_INPUT_SUCCESS, q as ARWEAVE_HOST, B as BaseArweaveClient, r as INTERNAL_CONFIGURING_FS_SUCCESS, s as INTERNAL_SAVING_CONFIG_SUCCESS, t as INTERNAL_LOADING_APP_DB_SUCCESS, u as DB_ON_SNAPSHOT, v as DB_NAME_APP, w as InternalState, P as PublishMachineStates, x as GlobalState, y as INTERNAL_DATA_TYPES, z as ImageSize, C as internalPropertyNames, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, F as defaultAttestationData } from './constants-C03RQQht.js';
5
+ import { b as BaseQueryClient, a as BaseEasClient, G as GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY, f as GLOBAL_INITIALIZING_SEND_CONFIG, g as GLOBAL_INITIALIZING_CREATE_ALL_ITEMS_SERVICES, h as GLOBAL_ADDING_MODELS_TO_DB_SUCCESS, D as DB_CHECK_STATUS_UPDATE_PATHS, i as DB_CHECK_STATUS_EXISTS, d as BROWSER_FS_TOP_DIR, j as DB_CREATING_SUCCESS, k as DB_VALIDATING_SUCCESS, l as DB_VALIDATING_WAIT, c as BaseFileManager, m as DB_MIGRATING_SUCCESS, n as DB_WAITING_FOR_FILES_RECEIVED, M as MachineIds, o as DB_MIGRATING_WAIT, p as DbState, I as INTERNAL_VALIDATING_INPUT_SUCCESS, q as ARWEAVE_HOST, B as BaseArweaveClient, r as INTERNAL_CONFIGURING_FS_SUCCESS, s as INTERNAL_SAVING_CONFIG_SUCCESS, t as INTERNAL_LOADING_APP_DB_SUCCESS, u as DB_ON_SNAPSHOT, v as DB_NAME_APP, w as InternalState, P as PublishMachineStates, x as GlobalState, y as INTERNAL_DATA_TYPES, z as ImageSize, C as internalPropertyNames, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, F as defaultAttestationData } from './constants-5PxfAeqj.js';
6
6
  import debug from 'debug';
7
7
  import pluralize from 'pluralize';
8
8
  import { sqliteTable, text, int, unique } from 'drizzle-orm/sqlite-core';
@@ -1349,7 +1349,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
1349
1349
  if (!models$1) {
1350
1350
  return;
1351
1351
  }
1352
- const { models: SeedModels } = await import('./seed.schema.config-1s-iWHq_.js');
1352
+ const { models: SeedModels } = await import('./seed.schema.config-CMpV_hyS.js');
1353
1353
  const allModels = {
1354
1354
  ...SeedModels,
1355
1355
  ...models$1,
@@ -2429,6 +2429,45 @@ class FileManager extends BaseFileManager {
2429
2429
  // )
2430
2430
  });
2431
2431
  }
2432
+ static async saveFile(filePath, content) {
2433
+ try {
2434
+ // Get a handle to the OPFS root directory
2435
+ const root = await navigator.storage.getDirectory();
2436
+ // Split the file path into directory and file name
2437
+ const pathParts = filePath.split('/');
2438
+ const fileName = pathParts.pop();
2439
+ if (!fileName)
2440
+ throw new Error('Invalid file path');
2441
+ // Traverse directories and create them if they don't exist
2442
+ let currentDir = root;
2443
+ for (const part of pathParts) {
2444
+ if (part !== '') {
2445
+ currentDir = await currentDir.getDirectoryHandle(part, { create: true });
2446
+ }
2447
+ }
2448
+ // Get the file handle and create the file if it doesn't exist
2449
+ const fileHandle = await currentDir.getFileHandle(fileName, { create: true });
2450
+ // Create a writable stream and write the content
2451
+ const writable = await fileHandle.createWritable();
2452
+ if (typeof content === 'string') {
2453
+ await writable.write(content);
2454
+ }
2455
+ else if (content instanceof Blob) {
2456
+ await writable.write(content);
2457
+ }
2458
+ else if (content instanceof ArrayBuffer) {
2459
+ await writable.write(new Blob([content]));
2460
+ }
2461
+ else {
2462
+ throw new Error('Unsupported content type');
2463
+ }
2464
+ await writable.close();
2465
+ console.log(`File written successfully: ${filePath}`);
2466
+ }
2467
+ catch (error) {
2468
+ console.error(`Error writing to OPFS: ${error.message}`);
2469
+ }
2470
+ }
2432
2471
  }
2433
2472
  BaseFileManager.setPlatformClass(FileManager);
2434
2473
  class CancelableInterval {
@@ -2980,10 +3019,10 @@ const GET_TRANSACTION_TAGS = graphql(/* GraphQL */ `
2980
3019
 
2981
3020
  const initArweaveClient = async () => {
2982
3021
  if (isBrowser()) {
2983
- (await import('./ArweaveClient-Dcqcpsq4.js')).ArweaveClient;
3022
+ (await import('./ArweaveClient-DpdXUcVJ.js')).ArweaveClient;
2984
3023
  }
2985
3024
  if (!isBrowser()) {
2986
- (await import('./ArweaveClient-Dh7LRIqD.js')).ArweaveClient;
3025
+ (await import('./ArweaveClient-D1TsTBoj.js')).ArweaveClient;
2987
3026
  }
2988
3027
  };
2989
3028
  let domain = 'arweave.net';
@@ -5855,7 +5894,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
5855
5894
  if (propertyRecordSchema &&
5856
5895
  propertyRecordSchema.storageType &&
5857
5896
  propertyRecordSchema.storageType === 'ItemStorage') {
5858
- const { Item } = await import('./index-Dv8GeuSw.js');
5897
+ const { Item } = await import('./index-BLla2o05.js');
5859
5898
  const item = await Item.find({
5860
5899
  seedLocalId,
5861
5900
  modelName,
@@ -6272,7 +6311,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
6272
6311
  });
6273
6312
  if (fileData instanceof ArrayBuffer) {
6274
6313
  try {
6275
- await fs.promises.writeFile(filePath, new Uint8Array(fileData));
6314
+ await BaseFileManager.saveFile(filePath, new Uint8Array(fileData));
6276
6315
  }
6277
6316
  catch (e) {
6278
6317
  fs.writeFileSync(filePath, new Uint8Array(fileData));
@@ -6281,7 +6320,7 @@ const saveImageSrc = fromCallback(({ sendBack, input: { context, event } }) => {
6281
6320
  }
6282
6321
  if (typeof fileData === 'string') {
6283
6322
  try {
6284
- await fs.promises.writeFile(filePath, fileData);
6323
+ await BaseFileManager.saveFile(filePath, fileData);
6285
6324
  }
6286
6325
  catch (e) {
6287
6326
  fs.writeFileSync(filePath, fileData);
@@ -6491,7 +6530,7 @@ const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) =
6491
6530
  if (!propertyData && newValue) {
6492
6531
  const filename = `${seedUid || seedLocalId}${propertyRecordSchema.filenameSuffix}`;
6493
6532
  const writeToPath = `/files/${propertyRecordSchema.localStorageDir}/${filename}`;
6494
- await fs.promises.writeFile(writeToPath, newValue);
6533
+ await BaseFileManager.saveFile(writeToPath, newValue);
6495
6534
  const propertyDataRows = await createMetadata({
6496
6535
  propertyName,
6497
6536
  propertyValue: filename,
@@ -6523,7 +6562,7 @@ const saveItemStorage = fromCallback(({ sendBack, input: { context, event } }) =
6523
6562
  }
6524
6563
  const filePath = `/files/${localStorageDir}/${fileName}`;
6525
6564
  try {
6526
- await fs.promises.writeFile(filePath, newValue);
6565
+ await BaseFileManager.saveFile(filePath, newValue);
6527
6566
  }
6528
6567
  catch (error) {
6529
6568
  fs.writeFileSync(filePath, newValue);
@@ -7805,7 +7844,7 @@ const initItem = async () => {
7805
7844
  Item$2 = (await Promise.resolve().then(function () { return Item$1; })).Item;
7806
7845
  }
7807
7846
  if (!isBrowser()) {
7808
- Item$2 = (await import('./Item-DI3FxVPV.js')).Item;
7847
+ Item$2 = (await import('./Item-D4n439Ei.js')).Item;
7809
7848
  }
7810
7849
  };
7811
7850
 
@@ -7815,17 +7854,17 @@ const initItemProperty = async () => {
7815
7854
  ItemProperty$2 = (await Promise.resolve().then(function () { return ItemProperty$1; })).ItemProperty;
7816
7855
  }
7817
7856
  if (!isBrowser()) {
7818
- ItemProperty$2 = (await import('./ItemProperty-CxNUwVnR.js')).ItemProperty;
7857
+ ItemProperty$2 = (await import('./ItemProperty-Be5ymRVT.js')).ItemProperty;
7819
7858
  }
7820
7859
  };
7821
7860
 
7822
7861
  let Db;
7823
7862
  const initDb = async () => {
7824
7863
  if (isBrowser()) {
7825
- Db = (await import('./Db-BwkMqaQe.js')).Db;
7864
+ Db = (await import('./Db-DMJ0v3gO.js')).Db;
7826
7865
  }
7827
7866
  if (!isBrowser()) {
7828
- Db = (await import('./Db-jJH2s0gO.js')).Db;
7867
+ Db = (await import('./Db-quJxmvHH.js')).Db;
7829
7868
  }
7830
7869
  // TODO: Add config for React Native
7831
7870
  };
@@ -8610,19 +8649,19 @@ const setupServiceHandlers = () => {
8610
8649
 
8611
8650
  const initEasClient = async () => {
8612
8651
  if (isBrowser()) {
8613
- (await import('./EasClient-A1xC7Gm-.js')).EasClient;
8652
+ (await import('./EasClient-ClZDuT3o.js')).EasClient;
8614
8653
  }
8615
8654
  if (!isBrowser()) {
8616
- (await import('./EasClient-m2mXad59.js')).EasClient;
8655
+ (await import('./EasClient-DfnGY_2X.js')).EasClient;
8617
8656
  }
8618
8657
  };
8619
8658
 
8620
8659
  const initQueryClient = async () => {
8621
8660
  if (isBrowser()) {
8622
- (await import('./QueryClient-C-hFMF2j.js')).QueryClient;
8661
+ (await import('./QueryClient-B1HkAaJo.js')).QueryClient;
8623
8662
  }
8624
8663
  if (!isBrowser()) {
8625
- (await import('./QueryClient-C02sPZ-K.js')).QueryClient;
8664
+ (await import('./QueryClient-BPoc9eBn.js')).QueryClient;
8626
8665
  }
8627
8666
  };
8628
8667
 
@@ -8631,7 +8670,7 @@ const initFileManager = async () => {
8631
8670
  (await Promise.resolve().then(function () { return FileManager$1; })).FileManager;
8632
8671
  }
8633
8672
  if (!isBrowser()) {
8634
- (await import('./FileManager-Dv2zn1RW.js')).FileManager;
8673
+ (await import('./FileManager-texI7UwL.js')).FileManager;
8635
8674
  }
8636
8675
  };
8637
8676
 
@@ -8677,7 +8716,7 @@ const client = {
8677
8716
  arweaveDomain,
8678
8717
  filesDir,
8679
8718
  });
8680
- const { models: internalModels } = await import('./seed.schema.config-1s-iWHq_.js');
8719
+ const { models: internalModels } = await import('./seed.schema.config-CMpV_hyS.js');
8681
8720
  for (const [key, value] of Object.entries(internalModels)) {
8682
8721
  setModel(key, value);
8683
8722
  }
@@ -8749,4 +8788,4 @@ const client = {
8749
8788
  enableMapSet();
8750
8789
 
8751
8790
  export { BaseItem as B, Db as D, FileManager as F, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, BaseItemProperty as a, BaseDb as b, ImageSrc as c, Item$2 as d, ItemProperty$2 as e, useItem as f, useItemProperties as g, useCreateItem as h, useItemProperty as i, useDeleteItem as j, useGlobalServiceStatus as k, usePublishItem as l, usePersistedSnapshots as m, useServices as n, useService as o, getCorrectId as p, getGlobalService as q, eventEmitter as r, client as s, useItems as u, withSeed as w };
8752
- //# sourceMappingURL=index-CKrLHw3B.js.map
8791
+ //# sourceMappingURL=index-BeKRizLf.js.map