@seedprotocol/sdk 0.1.69 → 0.1.71

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.
@@ -896,6 +896,15 @@ const getAddressesFromDb = () => __awaiter(void 0, void 0, void 0, function* ()
896
896
  return JSON.parse(addressArrayString);
897
897
  });
898
898
 
899
+ const updateMetadata = (metadataValues) => __awaiter(void 0, void 0, void 0, function* () {
900
+ const appDb = getAppDb();
901
+ const { localId } = metadataValues, rest = __rest(metadataValues, ["localId"]);
902
+ if (!localId) {
903
+ throw new Error('No localId provided to updateMetadata');
904
+ }
905
+ yield appDb.update(metadata).set(rest).where(eq(metadata.localId, localId));
906
+ });
907
+
899
908
  const logger$m = debug('app:property:actors:hydrateFromDb');
900
909
  const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
901
910
  const { seedUid, seedLocalId, propertyName: propertyNameRaw, propertyValue, propertyRecordSchema, itemModelName, } = context;
@@ -989,12 +998,22 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
989
998
  urlNeedsToBeRefreshed = true;
990
999
  }
991
1000
  if (urlNeedsToBeRefreshed) {
992
- const filePath = `/files/${localStorageDir}/${refResolvedValue}`;
1001
+ let dir = localStorageDir;
1002
+ if (!dir &&
1003
+ propertyRecordSchema &&
1004
+ propertyRecordSchema.refValueType === 'ImageSrc') {
1005
+ dir = 'images';
1006
+ }
1007
+ const filePath = `/files/${dir}/${refResolvedValue}`;
993
1008
  const fileExists = yield fs.promises.exists(filePath);
994
1009
  if (fileExists) {
995
1010
  const fileContents = yield fs.promises.readFile(filePath);
996
1011
  const fileHandler = new File([fileContents], refResolvedValue);
997
1012
  refResolvedDisplayValue = URL.createObjectURL(fileHandler);
1013
+ yield updateMetadata({
1014
+ localId,
1015
+ refResolvedDisplayValue,
1016
+ });
998
1017
  }
999
1018
  }
1000
1019
  }
@@ -1004,24 +1023,6 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
1004
1023
  typeof propertyValueFromDb === 'string') {
1005
1024
  propertyValueProcessed = propertyValueFromDb.split(',');
1006
1025
  }
1007
- if (seedLocalIdFromDb === 'sAFXuO7Uez') {
1008
- console.log(`[hydrateFromDb] sending updateContext with:`, {
1009
- type: 'updateContext',
1010
- localId,
1011
- uid,
1012
- propertyValue: propertyValueProcessed,
1013
- seedLocalId: seedLocalIdFromDb,
1014
- seedUid: seedUidFromDb,
1015
- versionLocalId: versionLocalIdFromDb,
1016
- versionUid: versionUidFromDb,
1017
- schemaUid: schemaUidFromDb,
1018
- refValueType,
1019
- localStorageDir,
1020
- resolvedValue: refResolvedValue,
1021
- resolvedDisplayValue: refResolvedDisplayValue,
1022
- renderValue: refResolvedDisplayValue,
1023
- });
1024
- }
1025
1026
  sendBack({
1026
1027
  type: 'updateContext',
1027
1028
  localId,
@@ -1041,7 +1042,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
1041
1042
  if (propertyRecordSchema &&
1042
1043
  propertyRecordSchema.storageType &&
1043
1044
  propertyRecordSchema.storageType === 'ItemStorage') {
1044
- const { Item } = yield import('./index-VSlWKRIZ.js');
1045
+ const { Item } = yield import('./index-DXh19Ejc.js');
1045
1046
  const item = yield Item.find({
1046
1047
  seedLocalId,
1047
1048
  modelName: itemModelName,
@@ -2546,7 +2547,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
2546
2547
  if (!models$1) {
2547
2548
  return;
2548
2549
  }
2549
- const { models: SeedModels } = yield import('./seed.schema.config-BEvGEHkp.js');
2550
+ const { models: SeedModels } = yield import('./seed.schema.config-Bp82HrfV.js');
2550
2551
  const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
2551
2552
  let hasModelsInDb = false;
2552
2553
  const schemaDefsByModelName = new Map();
@@ -6498,7 +6499,7 @@ const client = {
6498
6499
  console.error('fs listeners not ready during init');
6499
6500
  }
6500
6501
  globalService.send({ type: 'init', endpoints, models, addresses });
6501
- import('./seed.schema.config-BEvGEHkp.js').then(({ models }) => {
6502
+ import('./seed.schema.config-Bp82HrfV.js').then(({ models }) => {
6502
6503
  for (const [key, value] of Object.entries(models)) {
6503
6504
  setModel(key, value);
6504
6505
  }
@@ -7459,4 +7460,4 @@ if (isNode()) {
7459
7460
  }
7460
7461
 
7461
7462
  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_SEEDS as a, GET_SEED_IDS as b, GET_STORAGE_TRANSACTION_ID as c, GET_VERSIONS as d, GET_PROPERTIES as e, GET_ALL_PROPERTIES_FOR_ALL_VERSIONS as f, itemMachineAll as g, ImageSrc as h, itemMachineSingle as i, ItemProperty as j, useItem as k, useItemProperties as l, useCreateItem as m, useItemProperty as n, useDeleteItem as o, useGlobalServiceStatus as p, useServices as q, getGlobalService as r, client as s, getCorrectId as t, useItems as u, withSeed as w };
7462
- //# sourceMappingURL=index-YshZfGRu.js.map
7463
+ //# sourceMappingURL=index-Cv-NmpW4.js.map