@seedprotocol/sdk 0.1.79 → 0.1.81

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.
@@ -1013,7 +1013,15 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
1013
1013
  }
1014
1014
  }
1015
1015
  const filePath = `/files/${dir}/${refResolvedValue}`;
1016
- const fileExists = yield fs.promises.exists(filePath);
1016
+ const files = yield fs.promises.readdir(filePath);
1017
+ const matchingFiles = files.filter((file) => {
1018
+ return path.basename(file).includes(refResolvedValue);
1019
+ });
1020
+ let fileExists = false;
1021
+ if (matchingFiles && matchingFiles.length > 0) {
1022
+ fileExists = true;
1023
+ }
1024
+ // const fileExists = await fs.promises.exists(filePath)
1017
1025
  if (fileExists) {
1018
1026
  const fileContents = yield fs.promises.readFile(filePath);
1019
1027
  const fileHandler = new File([fileContents], refResolvedValue);
@@ -1050,7 +1058,7 @@ const hydrateFromDb = fromCallback(({ sendBack, input: { context } }) => {
1050
1058
  if (propertyRecordSchema &&
1051
1059
  propertyRecordSchema.storageType &&
1052
1060
  propertyRecordSchema.storageType === 'ItemStorage') {
1053
- const { Item } = yield import('./index-DmrlOoY_.js');
1061
+ const { Item } = yield import('./index-DANJVD5r.js');
1054
1062
  const item = yield Item.find({
1055
1063
  seedLocalId,
1056
1064
  modelName: itemModelName,
@@ -2612,7 +2620,7 @@ const addModelsToDb = fromCallback(({ sendBack, input: { context } }) => {
2612
2620
  if (!models$1) {
2613
2621
  return;
2614
2622
  }
2615
- const { models: SeedModels } = yield import('./seed.schema.config-CD9Ee46X.js');
2623
+ const { models: SeedModels } = yield import('./seed.schema.config-C7EjL9AF.js');
2616
2624
  const allModels = Object.assign(Object.assign({}, SeedModels), models$1);
2617
2625
  let hasModelsInDb = false;
2618
2626
  const schemaDefsByModelName = new Map();
@@ -3805,41 +3813,48 @@ const downloadAllFilesBinaryRequestHandler = () => __awaiter(void 0, void 0, voi
3805
3813
  continue;
3806
3814
  }
3807
3815
  const mimeType = getMimeType(dataString);
3808
- let fileName = transactionId;
3809
- if (contentType === 'base64') {
3810
- if (mimeType) {
3811
- fileName += `.${mimeType}`;
3816
+ let fileExtension = mimeType;
3817
+ if (fileExtension && (fileExtension === null || fileExtension === void 0 ? void 0 : fileExtension.startsWith('image'))) {
3818
+ fileExtension = fileExtension.replace('image/', '');
3819
+ let fileName = transactionId;
3820
+ if (contentType === 'base64') {
3821
+ if (fileExtension) {
3822
+ fileName += `.${fileExtension}`;
3823
+ }
3824
+ // Remove the Base64 header if it exists (e.g., "data:image/png;base64,")
3825
+ const base64Data = dataString.split(',').pop() || '';
3826
+ // Decode the Base64 string to binary
3827
+ const binaryString = atob(base64Data);
3828
+ const length = binaryString.length;
3829
+ const binaryData = new Uint8Array(length);
3830
+ for (let i = 0; i < length; i++) {
3831
+ binaryData[i] = binaryString.charCodeAt(i);
3832
+ }
3833
+ yield fs.promises.writeFile(`/files/images/${fileName}`, binaryData, {
3834
+ encoding: 'binary',
3835
+ });
3836
+ // if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
3837
+ // await fs.promises.writeFile(
3838
+ // `/files/images/${fileName}`,
3839
+ // dataUint8Array,
3840
+ // )
3841
+ // }
3812
3842
  }
3813
- // Remove the Base64 header if it exists (e.g., "data:image/png;base64,")
3814
- const base64Data = dataString.split(',').pop() || '';
3815
- // Decode the Base64 string to binary
3816
- const binaryString = atob(base64Data);
3817
- const length = binaryString.length;
3818
- const binaryData = new Uint8Array(length);
3819
- for (let i = 0; i < length; i++) {
3820
- binaryData[i] = binaryString.charCodeAt(i);
3843
+ if (contentType === 'html') {
3844
+ fileName += '.html';
3845
+ yield fs.promises.writeFile(`/files/html/${fileName}`, dataString);
3846
+ }
3847
+ if (contentType === 'json') {
3848
+ fileName += '.json';
3849
+ yield fs.promises.writeFile(`/files/json/${fileName}`, dataString);
3821
3850
  }
3822
- yield fs.promises.writeFile(`/files/images/${fileName}`, binaryData, {
3823
- encoding: 'binary',
3824
- });
3825
- // if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
3826
- // await fs.promises.writeFile(
3827
- // `/files/images/${fileName}`,
3828
- // dataUint8Array,
3829
- // )
3830
- // }
3831
- }
3832
- if (contentType === 'html') {
3833
- fileName += '.html';
3834
- yield fs.promises.writeFile(`/files/html/${fileName}`, dataString);
3835
3851
  }
3836
- if (contentType === 'json') {
3837
- fileName += '.json';
3838
- yield fs.promises.writeFile(`/files/json/${fileName}`, dataString);
3852
+ try { }
3853
+ catch (error) {
3854
+ logger$c(error);
3839
3855
  }
3840
3856
  }
3841
- catch (error) {
3842
- logger$c(error);
3857
+ finally {
3843
3858
  }
3844
3859
  }
3845
3860
  });
@@ -6612,7 +6627,7 @@ const client = {
6612
6627
  console.error('fs listeners not ready during init');
6613
6628
  }
6614
6629
  globalService.send({ type: 'init', endpoints, models, addresses });
6615
- import('./seed.schema.config-CD9Ee46X.js').then(({ models }) => {
6630
+ import('./seed.schema.config-C7EjL9AF.js').then(({ models }) => {
6616
6631
  for (const [key, value] of Object.entries(models)) {
6617
6632
  setModel(key, value);
6618
6633
  }
@@ -7566,4 +7581,4 @@ if (isNode()) {
7566
7581
  }
7567
7582
 
7568
7583
  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 };
7569
- //# sourceMappingURL=index-_JWt4nA-.js.map
7584
+ //# sourceMappingURL=index-C6xQQWVh.js.map