@seedprotocol/sdk 0.1.118 → 0.1.120

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.
@@ -1,6 +1,5 @@
1
- export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-BPIesZ_6.js';
1
+ export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-lYH32Ucm.js';
2
2
  import 'tslib';
3
- import 'path';
4
3
  import 'reflect-metadata';
5
4
  import '@sinclair/typebox';
6
5
  import 'xstate';
@@ -16,6 +15,7 @@ import '@tanstack/react-query';
16
15
  import 'graphql-request';
17
16
  import '@tanstack/query-sync-storage-persister';
18
17
  import '@tanstack/react-query-persist-client';
18
+ import 'path';
19
19
  import 'use-immer';
20
20
  import '@xstate/react';
21
21
  import 'eventemitter3';
@@ -27,10 +27,11 @@ import 'rxjs';
27
27
  import 'drizzle-orm/sqlite-proxy';
28
28
  import 'drizzle-orm/sqlite-proxy/migrator';
29
29
  import 'drizzle-orm/migrator';
30
- import '@zenfs/dom';
31
30
  import 'node:fs';
31
+ import 'async-es/retry';
32
+ import '@zenfs/dom';
32
33
  import 'arweave';
33
34
  import './constants-B6s6tGup.js';
34
35
  import '@ethereum-attestation-service/eas-sdk';
35
36
  import 'thirdweb';
36
- //# sourceMappingURL=index-B_TEG7RD.js.map
37
+ //# sourceMappingURL=index-CXivX9-v.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-CXivX9-v.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,4 @@
1
1
  import { __awaiter, __rest } from 'tslib';
2
- import path, { basename } from 'path';
3
2
  import 'reflect-metadata';
4
3
  import { Type } from '@sinclair/typebox';
5
4
  import { fromCallback, createActor, waitFor, setup, assign, raise } from 'xstate';
@@ -15,6 +14,7 @@ import { QueryClient } from '@tanstack/react-query';
15
14
  import { GraphQLClient } from 'graphql-request';
16
15
  import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister';
17
16
  import { persistQueryClient } from '@tanstack/react-query-persist-client';
17
+ import path, { basename } from 'path';
18
18
  import { useImmer } from 'use-immer';
19
19
  import { useSelector } from '@xstate/react';
20
20
  import EventEmitter from 'eventemitter3';
@@ -26,8 +26,9 @@ import { BehaviorSubject } from 'rxjs';
26
26
  import { drizzle } from 'drizzle-orm/sqlite-proxy';
27
27
  import { migrate as migrate$1 } from 'drizzle-orm/sqlite-proxy/migrator';
28
28
  import { readMigrationFiles } from 'drizzle-orm/migrator';
29
- import { WebAccess } from '@zenfs/dom';
30
29
  import * as fsNode from 'node:fs';
30
+ import retry from 'async-es/retry';
31
+ import { WebAccess } from '@zenfs/dom';
31
32
  import Arweave from 'arweave';
32
33
  import { i as internalPropertyNames, I as INTERNAL_DATA_TYPES, V as VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA, d as defaultAttestationData } from './constants-B6s6tGup.js';
33
34
  import { ZERO_BYTES32, SchemaEncoder } from '@ethereum-attestation-service/eas-sdk';
@@ -63,13 +64,29 @@ const withSeed$1 = (config, webpack, isServer) => {
63
64
  // console.log('crypto-browserify exists:', fs.existsSync(path.resolve(process.cwd(), './node_modules/crypto-browserify')))
64
65
  // console.log('path-browserify exists:', fs.existsSync(path.resolve(process.cwd(), './node_modules/path-browserify')))
65
66
  if (!isServer) {
66
- config.resolve.alias['fs'] = path.resolve(process.cwd(), './node_modules/@zenfs/core');
67
- config.resolve.alias['node:fs'] = path.resolve(process.cwd(), './node_modules/@zenfs/core');
68
- config.resolve.alias['@schema'] = path.resolve(process.cwd(), 'schema.ts');
69
- // config.resolve.alias['crypto'] = path.resolve(process.cwd(), './node_modules/crypto-browserify')
70
- // config.resolve.alias['node:crypto'] = path.resolve(process.cwd(), './node_modules/crypto-browserify')
71
- config.resolve.alias['node:path'] = path.resolve(process.cwd(), './node_modules/path-browserify');
72
- config.resolve.alias['path'] = path.resolve(process.cwd(), './node_modules/path-browserify');
67
+ config.resolve.alias['fs'] = '@zenfs/core';
68
+ config.resolve.alias['node:fs'] = '@zenfs/core';
69
+ config.resolve.alias['node:path'] = 'path-browserify';
70
+ config.resolve.alias['path'] = 'path-browserify';
71
+ // config.resolve.alias['fs'] = path.resolve(
72
+ // process.cwd(),
73
+ // './node_modules/@zenfs/core',
74
+ // )
75
+ // config.resolve.alias['node:fs'] = path.resolve(
76
+ // process.cwd(),
77
+ // './node_modules/@zenfs/core',
78
+ // )
79
+ // config.resolve.alias['@schema'] = path.resolve(process.cwd(), 'schema.ts')
80
+ // // config.resolve.alias['crypto'] = path.resolve(process.cwd(), './node_modules/crypto-browserify')
81
+ // // config.resolve.alias['node:crypto'] = path.resolve(process.cwd(), './node_modules/crypto-browserify')
82
+ // config.resolve.alias['node:path'] = path.resolve(
83
+ // process.cwd(),
84
+ // './node_modules/path-browserify',
85
+ // )
86
+ // config.resolve.alias['path'] = path.resolve(
87
+ // process.cwd(),
88
+ // './node_modules/path-browserify',
89
+ // )
73
90
  }
74
91
  if (isServer) {
75
92
  config.externals.push('@sqlite.org/sqlite-wasm');
@@ -2098,7 +2115,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
2098
2115
  if (!models$1) {
2099
2116
  return;
2100
2117
  }
2101
- const { models: SeedModels } = yield import('./seed.schema.config-BB6-tbUU.js');
2118
+ const { models: SeedModels } = yield import('./seed.schema.config-y0omDTDZ.js');
2102
2119
  const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
2103
2120
  let hasModelsInDb = false;
2104
2121
  const schemaDefsByModelName = new Map();
@@ -2298,6 +2315,36 @@ const validate = fromCallback(({ sendBack, input: { context } }) => {
2298
2315
  });
2299
2316
  });
2300
2317
 
2318
+ /**
2319
+ * Waits for a file to exist at the specified path.
2320
+ * @param {string} filePath - The path of the file to check.
2321
+ * @param {number} interval - The interval in milliseconds between checks (default: 500ms).
2322
+ * @param {number} timeout - The timeout in milliseconds to wait for the file to exist (default: 10s).
2323
+ * @returns {Promise<boolean>} - Resolves to true if the file exists within the timeout period, otherwise false.
2324
+ */
2325
+ const waitForFile = (filePath, interval = 500, timeout = 10000) => {
2326
+ return new Promise((resolve, reject) => {
2327
+ const startTime = Date.now();
2328
+ retry({
2329
+ times: Math.ceil(timeout / interval),
2330
+ interval: interval,
2331
+ }, (callback) => {
2332
+ if (fs.existsSync(filePath) && fsNode.existsSync(filePath)) {
2333
+ return callback(null, true); // File exists, finish with success
2334
+ }
2335
+ if (Date.now() - startTime >= timeout) {
2336
+ return callback(new Error('Timeout exceeded while waiting for file'));
2337
+ }
2338
+ callback(new Error('File does not exist yet')); // Retry with this error
2339
+ }, (err, result) => {
2340
+ if (err) {
2341
+ return resolve(false); // Resolve as false if timeout or error occurs
2342
+ }
2343
+ resolve(result); // Resolve as true if file exists
2344
+ });
2345
+ });
2346
+ };
2347
+
2301
2348
  const logger$i = debug('app:services:db:actors:migrate');
2302
2349
  const dbExec = (dbId_1, params_1, sql_1, dbName_1, ...args_1) => __awaiter(void 0, [dbId_1, params_1, sql_1, dbName_1, ...args_1], void 0, function* (dbId, params, sql, dbName, retries = 2) {
2303
2350
  const rowsToReturnRaw = [];
@@ -2387,11 +2434,13 @@ const migrate = fromCallback(({ sendBack, input: { context } }) => {
2387
2434
  console.log('journalExistsSync', journalExistsSync);
2388
2435
  console.log('journalExistsSyncNode', journalExistsSyncNode);
2389
2436
  if (!journalExists) {
2390
- const handle = yield navigator.storage.getDirectory();
2391
- yield configureSingle({
2392
- backend: WebAccess,
2393
- handle,
2394
- });
2437
+ yield waitForFile(journalPath);
2438
+ // const handle = await navigator.storage.getDirectory()
2439
+ //
2440
+ // await configureSingle({
2441
+ // backend: WebAccess,
2442
+ // handle,
2443
+ // })
2395
2444
  // window.location.reload()
2396
2445
  // setTimeout(() => {
2397
2446
  // _checkForFiles().then(() => {
@@ -2467,11 +2516,13 @@ const migrate = fromCallback(({ sendBack, input: { context } }) => {
2467
2516
  catch (error) {
2468
2517
  // console.error('Error migrating database: ', error)
2469
2518
  // window.location.reload()
2470
- const handle = yield navigator.storage.getDirectory();
2471
- yield configureSingle({
2472
- backend: WebAccess,
2473
- handle,
2474
- });
2519
+ // const handle = await navigator.storage.getDirectory()
2520
+ //
2521
+ // await configureSingle({
2522
+ // backend: WebAccess,
2523
+ // handle,
2524
+ // })
2525
+ yield waitForFile(`${pathToDbDir}/meta/_journal.json`);
2475
2526
  return _migrate();
2476
2527
  }
2477
2528
  setAppDb(drizzleDb);
@@ -6500,7 +6551,7 @@ const client = {
6500
6551
  addresses,
6501
6552
  arweaveDomain,
6502
6553
  });
6503
- import('./seed.schema.config-BB6-tbUU.js').then(({ models }) => {
6554
+ import('./seed.schema.config-y0omDTDZ.js').then(({ models }) => {
6504
6555
  for (const [key, value] of Object.entries(models)) {
6505
6556
  setModel(key, value);
6506
6557
  }
@@ -7175,7 +7226,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
7175
7226
  if (propertyRecordSchema &&
7176
7227
  propertyRecordSchema.storageType &&
7177
7228
  propertyRecordSchema.storageType === 'ItemStorage') {
7178
- const { Item } = yield import('./index-B_TEG7RD.js');
7229
+ const { Item } = yield import('./index-CXivX9-v.js');
7179
7230
  const item = yield Item.find({
7180
7231
  seedLocalId,
7181
7232
  modelName,
@@ -8117,4 +8168,4 @@ if (isNode()) {
8117
8168
  }
8118
8169
 
8119
8170
  export { GET_SCHEMAS as G, Item as I, Json as J, List as L, Model as M, Property as P, Relation as R, Text as T, GET_SCHEMA_BY_NAME as a, GET_SEEDS as b, GET_SEED_IDS as c, GET_STORAGE_TRANSACTION_ID as d, GET_VERSIONS as e, GET_PROPERTIES as f, GET_ALL_PROPERTIES_FOR_ALL_VERSIONS as g, itemMachineAll as h, itemMachineSingle as i, ImageSrc as j, ItemProperty as k, useItem as l, useItemProperties as m, useCreateItem as n, useItemProperty as o, useDeleteItem as p, useGlobalServiceStatus as q, useServices as r, getGlobalService as s, client as t, useItems as u, getCorrectId as v, withSeed as w };
8120
- //# sourceMappingURL=index-BPIesZ_6.js.map
8171
+ //# sourceMappingURL=index-lYH32Ucm.js.map