@seedprotocol/sdk 0.1.111 → 0.1.113

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.
@@ -1980,7 +1980,7 @@ const syncDbWithEasHandler = throttle((_) => __awaiter(void 0, void 0, void 0, f
1980
1980
 
1981
1981
  const logger$n = debug('app:services:global:actors:initialize');
1982
1982
  const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
1983
- const { internalService, models, endpoints } = context;
1983
+ const { internalService, models, endpoints, arweaveDomain } = context;
1984
1984
  const { addresses } = event;
1985
1985
  let environment = 'browser';
1986
1986
  if (isNode()) {
@@ -2004,7 +2004,12 @@ const initialize$2 = fromCallback(({ sendBack, input: { event, context } }) => {
2004
2004
  resolve();
2005
2005
  }
2006
2006
  });
2007
- internalService.send({ type: 'init', endpoints, addresses });
2007
+ internalService.send({
2008
+ type: 'init',
2009
+ endpoints,
2010
+ addresses,
2011
+ arweaveDomain,
2012
+ });
2008
2013
  });
2009
2014
  });
2010
2015
  const _initAllItemsServices = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -2090,7 +2095,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
2090
2095
  if (!models$1) {
2091
2096
  return;
2092
2097
  }
2093
- const { models: SeedModels } = yield import('./seed.schema.config-DfASQOur.js');
2098
+ const { models: SeedModels } = yield import('./seed.schema.config-Baj_iYq7.js');
2094
2099
  const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
2095
2100
  let hasModelsInDb = false;
2096
2101
  const schemaDefsByModelName = new Map();
@@ -3027,6 +3032,7 @@ setup({
3027
3032
  },
3028
3033
  });
3029
3034
 
3035
+ let domain = 'arweave.net';
3030
3036
  const getArweave = () => {
3031
3037
  if (typeof window === 'undefined' ||
3032
3038
  !Arweave ||
@@ -3053,15 +3059,18 @@ const getArweave = () => {
3053
3059
  // },)
3054
3060
  if (Object.keys(Arweave).includes('default')) {
3055
3061
  return Arweave.default.init({
3056
- host: 'permagate.io',
3062
+ host: domain,
3057
3063
  protocol: 'https',
3058
3064
  });
3059
3065
  }
3060
3066
  return Arweave.init({
3061
- host: 'permagate.io',
3067
+ host: domain,
3062
3068
  protocol: 'https',
3063
3069
  });
3064
3070
  };
3071
+ const setArweaveDomain = (newDomain) => {
3072
+ domain = newDomain;
3073
+ };
3065
3074
 
3066
3075
  const getMetadata = (props) => __awaiter(void 0, void 0, void 0, function* () {
3067
3076
  const appDb = getAppDb();
@@ -3423,7 +3432,7 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
3423
3432
  error: 'Browser method called from non-browser context',
3424
3433
  });
3425
3434
  }
3426
- const { endpoints, addresses } = context;
3435
+ const { endpoints, addresses, arweaveDomain } = context;
3427
3436
  if (!endpoints) {
3428
3437
  throw new Error('saveConfig called with invalid endpoints');
3429
3438
  }
@@ -3465,6 +3474,19 @@ const saveConfig = fromCallback(({ sendBack, input: { context } }) => {
3465
3474
  },
3466
3475
  setWhere: sql `key = 'addresses'`,
3467
3476
  });
3477
+ yield appDb
3478
+ .insert(appState)
3479
+ .values({
3480
+ key: 'arweaveDomain',
3481
+ value: arweaveDomain || 'arweave.net',
3482
+ })
3483
+ .onConflictDoUpdate({
3484
+ target: appState.key,
3485
+ set: {
3486
+ value: arweaveDomain,
3487
+ },
3488
+ setWhere: sql `key = 'arweaveDomain'`,
3489
+ });
3468
3490
  logger$d('[sdk] [internal/actors] Should be done saving');
3469
3491
  }
3470
3492
  catch (error) {
@@ -5531,12 +5553,12 @@ const processUploadProperty = (uploadProperty, uploads, relatedItemProperty) =>
5531
5553
  const childUploads = [];
5532
5554
  for (const childProperty of uploadProperty.childProperties) {
5533
5555
  const filePath = childProperty.localStoragePath;
5534
- if (!filePath) {
5556
+ if (!filePath || filePath.endsWith('undefined')) {
5535
5557
  continue;
5536
5558
  }
5537
5559
  const exists = yield fs.promises.exists(filePath);
5538
5560
  if (!exists) {
5539
- throw new Error(`File doesn't exist at ${filePath}`);
5561
+ continue;
5540
5562
  }
5541
5563
  childUploads.push({
5542
5564
  propertyName: childProperty.propertyName,
@@ -5569,6 +5591,9 @@ const processUploadProperty = (uploadProperty, uploads, relatedItemProperty) =>
5569
5591
  if (!childUploads || childUploads.length === 0) {
5570
5592
  if (relatedItemProperty && relatedItemProperty.localStoragePath) {
5571
5593
  const filePath = relatedItemProperty.localStoragePath;
5594
+ if (!filePath || filePath.endsWith('undefined')) {
5595
+ return uploads;
5596
+ }
5572
5597
  const exists = yield fs.promises.exists(filePath);
5573
5598
  if (!exists) {
5574
5599
  return uploads;
@@ -6436,7 +6461,10 @@ const setupServiceHandlers = () => {
6436
6461
 
6437
6462
  const client = {
6438
6463
  init: ({ config, addresses }) => {
6439
- const { endpoints, models } = config;
6464
+ const { endpoints, models, arweaveDomain } = config;
6465
+ if (arweaveDomain) {
6466
+ setArweaveDomain(arweaveDomain);
6467
+ }
6440
6468
  for (const [key, value] of Object.entries(models)) {
6441
6469
  setModel(key, value);
6442
6470
  }
@@ -6450,8 +6478,14 @@ const client = {
6450
6478
  if (!areFsListenersReady()) {
6451
6479
  console.error('fs listeners not ready during init');
6452
6480
  }
6453
- globalService.send({ type: 'init', endpoints, models, addresses });
6454
- import('./seed.schema.config-DfASQOur.js').then(({ models }) => {
6481
+ globalService.send({
6482
+ type: 'init',
6483
+ endpoints,
6484
+ models,
6485
+ addresses,
6486
+ arweaveDomain,
6487
+ });
6488
+ import('./seed.schema.config-Baj_iYq7.js').then(({ models }) => {
6455
6489
  for (const [key, value] of Object.entries(models)) {
6456
6490
  setModel(key, value);
6457
6491
  }
@@ -7126,7 +7160,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
7126
7160
  if (propertyRecordSchema &&
7127
7161
  propertyRecordSchema.storageType &&
7128
7162
  propertyRecordSchema.storageType === 'ItemStorage') {
7129
- const { Item } = yield import('./index-BM9Ymz63.js');
7163
+ const { Item } = yield import('./index-yw-bik4t.js');
7130
7164
  const item = yield Item.find({
7131
7165
  seedLocalId,
7132
7166
  modelName,
@@ -8068,4 +8102,4 @@ if (isNode()) {
8068
8102
  }
8069
8103
 
8070
8104
  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 };
8071
- //# sourceMappingURL=index-CkDKrj91.js.map
8105
+ //# sourceMappingURL=index-Dj4L9w50.js.map