@seedprotocol/sdk 0.2.47 → 0.2.49

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 (92) hide show
  1. package/dist/{ArweaveClient-CoFomTCN.js → ArweaveClient-Dcqcpsq4.js} +2 -2
  2. package/dist/{ArweaveClient-DQrXvrNN.js.map → ArweaveClient-Dcqcpsq4.js.map} +1 -1
  3. package/dist/{ArweaveClient-DQrXvrNN.js → ArweaveClient-Dh7LRIqD.js} +2 -2
  4. package/dist/{ArweaveClient-CoFomTCN.js.map → ArweaveClient-Dh7LRIqD.js.map} +1 -1
  5. package/dist/{Db-Dgbci7BP.js → Db-BjoRtCFg.js} +3 -4
  6. package/dist/{Db-Dgbci7BP.js.map → Db-BjoRtCFg.js.map} +1 -1
  7. package/dist/{Db-Dv7s24Zi.js → Db-CMRjCZoY.js} +7 -7
  8. package/dist/Db-CMRjCZoY.js.map +1 -0
  9. package/dist/{EasClient-CBu9ENAi.js → EasClient-A1xC7Gm-.js} +2 -2
  10. package/dist/{EasClient-sCbTHcO8.js.map → EasClient-A1xC7Gm-.js.map} +1 -1
  11. package/dist/{EasClient-sCbTHcO8.js → EasClient-m2mXad59.js} +2 -2
  12. package/dist/{EasClient-CBu9ENAi.js.map → EasClient-m2mXad59.js.map} +1 -1
  13. package/dist/{FileManager-COOp89Mj.js → FileManager-Dv2zn1RW.js} +12 -2
  14. package/dist/FileManager-Dv2zn1RW.js.map +1 -0
  15. package/dist/{Item-DOEEhWwi.js → Item-7vg6XRhw.js} +3 -4
  16. package/dist/{Item-DOEEhWwi.js.map → Item-7vg6XRhw.js.map} +1 -1
  17. package/dist/{ItemProperty-CABHeoKm.js → ItemProperty-Bcht9WTV.js} +3 -4
  18. package/dist/{ItemProperty-CABHeoKm.js.map → ItemProperty-Bcht9WTV.js.map} +1 -1
  19. package/dist/{QueryClient-BBaE-LKI.js → QueryClient-C-hFMF2j.js} +2 -2
  20. package/dist/{QueryClient-BBaE-LKI.js.map → QueryClient-C-hFMF2j.js.map} +1 -1
  21. package/dist/{QueryClient-C-ZzUnWq.js → QueryClient-C02sPZ-K.js} +2 -2
  22. package/dist/{QueryClient-C-ZzUnWq.js.map → QueryClient-C02sPZ-K.js.map} +1 -1
  23. package/dist/bin.js +21 -21
  24. package/dist/bin.js.map +1 -1
  25. package/dist/{constants-Dgv-tSO3.js → constants-C03RQQht.js} +12 -5
  26. package/dist/constants-C03RQQht.js.map +1 -0
  27. package/dist/{index-OxV3e-OY.js → index-D3Scq_ka.js} +1095 -137
  28. package/dist/index-D3Scq_ka.js.map +1 -0
  29. package/dist/{index-CAikKppg.js → index-Dp3GcggF.js} +3 -4
  30. package/dist/index-Dp3GcggF.js.map +1 -0
  31. package/dist/main.js +2 -3
  32. package/dist/main.js.map +1 -1
  33. package/dist/{seed.schema.config-Ba_E7t1M.js → seed.schema.config-CS6BvsTl.js} +3 -4
  34. package/dist/seed.schema.config-CS6BvsTl.js.map +1 -0
  35. package/dist/src/BaseFileManager.ts +14 -2
  36. package/dist/src/BaseItem.ts +15 -3
  37. package/dist/src/BaseItemProperty.ts +1 -1
  38. package/dist/src/FileManager.ts +14 -1
  39. package/dist/src/IItem.ts +4 -1
  40. package/dist/src/ImageResizer.ts +3 -6
  41. package/dist/src/actors.ts +1 -1
  42. package/dist/src/client.ts +25 -0
  43. package/dist/src/configureFs.ts +1 -1
  44. package/dist/src/createNewItem.ts +5 -1
  45. package/dist/src/download.ts +6 -16
  46. package/dist/src/drizzle.ts +1 -1
  47. package/dist/src/files.ts +1 -1
  48. package/dist/src/getPublishUploads.ts +1 -1
  49. package/dist/src/helpers.ts +201 -84
  50. package/dist/src/hydrateFromDb.ts +1 -1
  51. package/dist/src/migrate.ts +3 -3
  52. package/dist/src/resolveRelatedValue.ts +1 -1
  53. package/dist/src/resolveRemoteStorage.ts +1 -1
  54. package/dist/src/saveImageSrc.ts +1 -1
  55. package/dist/src/saveItemStorage.ts +1 -1
  56. package/dist/src/ts-to-proto.ts +1 -1
  57. package/dist/src/validate.ts +1 -1
  58. package/dist/src/waitForDb.ts +9 -10
  59. package/dist/src/waitForFiles.ts +1 -1
  60. package/dist/types/src/Item/BaseItem.d.ts +4 -1
  61. package/dist/types/src/Item/BaseItem.d.ts.map +1 -1
  62. package/dist/types/src/Item/service/actors/saveDataToDb.d.ts +3 -0
  63. package/dist/types/src/Item/service/actors/saveDataToDb.d.ts.map +1 -0
  64. package/dist/types/src/browser/db/Db.d.ts +2 -2
  65. package/dist/types/src/browser/db/Db.d.ts.map +1 -1
  66. package/dist/types/src/browser/helpers/FileManager.d.ts +10 -0
  67. package/dist/types/src/browser/helpers/FileManager.d.ts.map +1 -1
  68. package/dist/types/src/browser/helpers/index.d.ts +1 -2
  69. package/dist/types/src/browser/helpers/index.d.ts.map +1 -1
  70. package/dist/types/src/browser/react/item.d.ts.map +1 -1
  71. package/dist/types/src/browser/workers/ImageResizer.d.ts.map +1 -1
  72. package/dist/types/src/client.d.ts +1 -0
  73. package/dist/types/src/client.d.ts.map +1 -1
  74. package/dist/types/src/db/write/createNewItem.d.ts.map +1 -1
  75. package/dist/types/src/events/files/download.d.ts.map +1 -1
  76. package/dist/types/src/helpers/FileManager/BaseFileManager.d.ts +5 -2
  77. package/dist/types/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
  78. package/dist/types/src/interfaces/IItem.d.ts +3 -0
  79. package/dist/types/src/interfaces/IItem.d.ts.map +1 -1
  80. package/dist/types/src/node/helpers/FileManager.d.ts +2 -0
  81. package/dist/types/src/node/helpers/FileManager.d.ts.map +1 -1
  82. package/dist/types/src/services/internal/helpers.d.ts +0 -2
  83. package/dist/types/src/services/internal/helpers.d.ts.map +1 -1
  84. package/package.json +1 -1
  85. package/dist/Db-Dv7s24Zi.js.map +0 -1
  86. package/dist/FileManager-COOp89Mj.js.map +0 -1
  87. package/dist/FileManager-Np-xCJ1X.js +0 -794
  88. package/dist/FileManager-Np-xCJ1X.js.map +0 -1
  89. package/dist/constants-Dgv-tSO3.js.map +0 -1
  90. package/dist/index-CAikKppg.js.map +0 -1
  91. package/dist/index-OxV3e-OY.js.map +0 -1
  92. package/dist/seed.schema.config-Ba_E7t1M.js.map +0 -1
@@ -1,9 +1,9 @@
1
- export { I as Item } from './index-OxV3e-OY.js';
1
+ export { I as Item } from './index-D3Scq_ka.js';
2
2
  import 'immer';
3
3
  import 'reflect-metadata';
4
4
  import '@sinclair/typebox';
5
5
  import 'xstate';
6
- import './constants-Dgv-tSO3.js';
6
+ import './constants-C03RQQht.js';
7
7
  import '@ethereum-attestation-service/eas-sdk';
8
8
  import 'debug';
9
9
  import 'pluralize';
@@ -15,7 +15,6 @@ import 'nanoid-dictionary';
15
15
  import '@zenfs/core';
16
16
  import 'lodash-es';
17
17
  import '@statelyai/inspect';
18
- import 'node:fs';
19
18
  import 'path';
20
19
  import 'arweave';
21
20
  import 'rxjs';
@@ -23,4 +22,4 @@ import 'drizzle-orm/casing';
23
22
  import 'react';
24
23
  import 'use-immer';
25
24
  import '@xstate/react';
26
- //# sourceMappingURL=index-CAikKppg.js.map
25
+ //# sourceMappingURL=index-Dp3GcggF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Dp3GcggF.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/main.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'immer';
2
2
  import 'reflect-metadata';
3
- export { D as Db, c as ImageSrc, d as Item, e as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, v as client, r as eventEmitter, p as getCorrectId, q as getGlobalService, h as useCreateItem, j as useDeleteItem, k as useGlobalServiceStatus, f as useItem, g as useItemProperties, i as useItemProperty, u as useItems, m as usePersistedSnapshots, l as usePublishItem, o as useService, n as useServices, t as withSeed } from './index-OxV3e-OY.js';
4
- export { B as BaseArweaveClient, a as BaseEasClient, c as BaseFileManager, b as BaseQueryClient } from './constants-Dgv-tSO3.js';
3
+ export { D as Db, c as ImageSrc, d as Item, e as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, s as client, r as eventEmitter, p as getCorrectId, q as getGlobalService, h as useCreateItem, j as useDeleteItem, k as useGlobalServiceStatus, f as useItem, g as useItemProperties, i as useItemProperty, u as useItems, m as usePersistedSnapshots, l as usePublishItem, o as useService, n as useServices, w as withSeed } from './index-D3Scq_ka.js';
4
+ export { B as BaseArweaveClient, a as BaseEasClient, c as BaseFileManager, b as BaseQueryClient } from './constants-C03RQQht.js';
5
5
  import '@sinclair/typebox';
6
6
  import 'xstate';
7
7
  import 'debug';
@@ -14,7 +14,6 @@ import 'nanoid-dictionary';
14
14
  import '@zenfs/core';
15
15
  import 'lodash-es';
16
16
  import '@statelyai/inspect';
17
- import 'node:fs';
18
17
  import 'path';
19
18
  import 'arweave';
20
19
  import 'rxjs';
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,10 +1,10 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
2
  import 'reflect-metadata';
3
- import { T as Text, M as Model } from './index-OxV3e-OY.js';
3
+ import { T as Text, M as Model } from './index-D3Scq_ka.js';
4
4
  import 'immer';
5
5
  import '@sinclair/typebox';
6
6
  import 'xstate';
7
- import './constants-Dgv-tSO3.js';
7
+ import './constants-C03RQQht.js';
8
8
  import '@ethereum-attestation-service/eas-sdk';
9
9
  import 'debug';
10
10
  import 'pluralize';
@@ -16,7 +16,6 @@ import 'nanoid-dictionary';
16
16
  import '@zenfs/core';
17
17
  import 'lodash-es';
18
18
  import '@statelyai/inspect';
19
- import 'node:fs';
20
19
  import 'path';
21
20
  import 'arweave';
22
21
  import 'rxjs';
@@ -71,4 +70,4 @@ const models = {
71
70
  };
72
71
 
73
72
  export { models };
74
- //# sourceMappingURL=seed.schema.config-Ba_E7t1M.js.map
73
+ //# sourceMappingURL=seed.schema.config-CS6BvsTl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.schema.config-CS6BvsTl.js","sources":["../../src/db/configs/seed.schema.config.ts"],"sourcesContent":["import { Model, Text } from '@/schema'\n\n@Model\nclass Seed {\n @Text() uid!: string\n @Text() type!: string\n}\n\n@Model\nclass Version {\n @Text() seedUid!: string\n @Text() note!: string\n}\n\n@Model\nclass Metadata {\n @Text() key!: string\n @Text() value!: string\n}\n\nexport const models = {\n Seed,\n Version,\n Metadata,\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,IAAI,GAAV,MAAM,IAAI,CAAA;CAGT;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAa,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,KAAA,EAAA,SAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,MAAA,EAAA,SAAA,CAAA;AAFjB,IAAI,GAAA,UAAA,CAAA;IADT;AACK,CAAA,EAAA,IAAI,CAGT;AAGD,IAAM,OAAO,GAAb,MAAM,OAAO,CAAA;CAGZ;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAiB,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,SAAA,EAAA,SAAA,CAAA;AAChB,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,MAAA,EAAA,SAAA,CAAA;AAFjB,OAAO,GAAA,UAAA,CAAA;IADZ;AACK,CAAA,EAAA,OAAO,CAGZ;AAGD,IAAM,QAAQ,GAAd,MAAM,QAAQ,CAAA;CAGb;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAa,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,KAAA,EAAA,SAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAe,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,OAAA,EAAA,SAAA,CAAA;AAFlB,QAAQ,GAAA,UAAA,CAAA;IADb;AACK,CAAA,EAAA,QAAQ,CAGb;AAEY,MAAA,MAAM,GAAG;IACpB,IAAI;IACJ,OAAO;IACP,QAAQ;;;;;"}
@@ -1,6 +1,6 @@
1
1
  export abstract class BaseFileManager {
2
- private fileSystemInitialized = false
3
- private initializing = false
2
+ private static fileSystemInitialized = false
3
+ private static initializing = false
4
4
 
5
5
  static PlatformClass: typeof BaseFileManager
6
6
 
@@ -37,4 +37,16 @@ export abstract class BaseFileManager {
37
37
  static resizeAllImages( { width, height }: ResizeAllImagesParams ): Promise<void> {
38
38
  return this.PlatformClass.resizeAllImages({ width, height })
39
39
  }
40
+
41
+ static pathExists(filePath: string): Promise<boolean> {
42
+ return this.PlatformClass.pathExists(filePath)
43
+ }
44
+
45
+ static createDirIfNotExists(filePath: string): Promise<void> {
46
+ return this.PlatformClass.createDirIfNotExists(filePath)
47
+ }
48
+
49
+ static async waitForFile(filePath: string): Promise<boolean> {
50
+ return this.PlatformClass.waitForFile(filePath)
51
+ }
40
52
  }
@@ -226,7 +226,7 @@ export abstract class BaseItem<T extends ModelValues<ModelSchema>> implements II
226
226
  if (!props.modelName) {
227
227
  throw new Error('Model name is required to create an item')
228
228
  }
229
- const { seedLocalId, versionLocalId, versionUid } = await createNewItem({
229
+ const { seedLocalId, versionLocalId, } = await createNewItem({
230
230
  modelName: props.modelName,
231
231
  })
232
232
  props.seedLocalId = seedLocalId
@@ -267,9 +267,9 @@ export abstract class BaseItem<T extends ModelValues<ModelSchema>> implements II
267
267
  static async all(
268
268
  modelName?: string,
269
269
  deleted?: boolean,
270
- ): Promise<IItem<any>[]> {
270
+ ): Promise<BaseItem<any>[]> {
271
271
  const itemsData = await getItemsData({ modelName, deleted })
272
- const itemInstances: IItem<any>[] = []
272
+ const itemInstances: BaseItem<any>[] = []
273
273
  for (const itemData of itemsData) {
274
274
  itemInstances.push(
275
275
  await BaseItem.create({
@@ -381,6 +381,10 @@ export abstract class BaseItem<T extends ModelValues<ModelSchema>> implements II
381
381
  return this.serviceContext.latestVersionUid as VersionsType
382
382
  }
383
383
 
384
+ get latestVersionLocalId(): string {
385
+ return this.serviceContext.latestVersionLocalId as string
386
+ }
387
+
384
388
  get modelName(): string {
385
389
  return this.serviceContext.modelName as string
386
390
  }
@@ -393,6 +397,14 @@ export abstract class BaseItem<T extends ModelValues<ModelSchema>> implements II
393
397
  return this.serviceContext.attestationCreatedAt as number
394
398
  }
395
399
 
400
+ get versionsCount(): number {
401
+ return this.serviceContext.versionsCount as number
402
+ }
403
+
404
+ get lastVersionPublishedAt(): number {
405
+ return this.serviceContext.lastVersionPublishedAt as number
406
+ }
407
+
396
408
  unload(): void {
397
409
  this._subscription?.unsubscribe()
398
410
  this._service.stop()
@@ -10,7 +10,7 @@ import { internalPropertyNames } from '@/helpers/constants'
10
10
  import debug from 'debug'
11
11
  import pluralize from 'pluralize'
12
12
  import { eventEmitter } from '@/eventBus'
13
- import { fs } from '@zenfs/core'
13
+ import fs from '@zenfs/core'
14
14
  import { getPropertyData } from '@/db/read/getPropertyData'
15
15
  import { getCorrectId } from '@/helpers'
16
16
  import { TProperty } from '@/schema'
@@ -37,8 +37,21 @@ class FileManager extends BaseFileManager {
37
37
  })
38
38
  }
39
39
 
40
+ static async pathExists(filePath: string): Promise<boolean> {
41
+ return new Promise(( resolve, reject ) => {
42
+ reject(new Error('Not implemented'))
43
+ })
44
+ }
45
+
46
+ static async createDirIfNotExists(filePath: string): Promise<void> {
47
+ return new Promise(( resolve, reject ) => {
48
+ reject(new Error('Not implemented'))
49
+ })
50
+ }
51
+
40
52
  }
41
53
 
42
54
  BaseFileManager.setPlatformClass(FileManager)
43
55
 
44
- export { FileManager }
56
+ export { FileManager }
57
+
package/dist/src/IItem.ts CHANGED
@@ -17,7 +17,10 @@ export interface IItem<T extends ModelValues<ModelSchema>> {
17
17
  readonly seedUid?: string
18
18
  readonly schemaUid: string
19
19
  readonly latestVersionUid: VersionsType
20
+ readonly latestVersionLocalId: string
20
21
  readonly modelName: string
21
22
  readonly properties: Record<string, IItemProperty<any>>
22
23
  readonly attestationCreatedAt: number
23
- }
24
+ readonly versionsCount: number
25
+ readonly lastVersionPublishedAt: number
26
+ }
@@ -1,5 +1,6 @@
1
- import { fs } from '@zenfs/core';
1
+ import fs from '@zenfs/core';
2
2
  import imageResize from './imageResize'
3
+ import { FileManager } from '@/browser/helpers/FileManager';
3
4
 
4
5
 
5
6
 
@@ -66,11 +67,7 @@ export class ImageResizer {
66
67
 
67
68
  const widthDir = `${imageDir}/${width}`
68
69
 
69
- const widthDirExists = await fs.promises.exists(widthDir)
70
-
71
- if (!widthDirExists) {
72
- await fs.promises.mkdir(widthDir)
73
- }
70
+ await FileManager.createDirIfNotExists(widthDir)
74
71
 
75
72
  for (const imageFile of imageFiles) {
76
73
  const resizedImageExists = await fs.promises.exists(`${widthDir}/${imageFile}`)
@@ -3,7 +3,7 @@ import { fetchAllFilesMachine } from '@/schema/file/fetchAll/index'
3
3
  import { ARWEAVE_HOST } from '@/services/internal/constants'
4
4
  import { GET_FILES_METADATA } from '@/schema/file/queries'
5
5
  import { getArweave } from '@/helpers/ArweaveClient'
6
- import { fs } from '@zenfs/core'
6
+ import fs from '@zenfs/core'
7
7
  import {
8
8
  getDataTypeFromString,
9
9
  getMimeType,
@@ -19,6 +19,7 @@ import { initQueryClient } from './helpers/QueryClient'
19
19
  import { initFileManager } from './helpers/FileManager'
20
20
  import { initDb } from './db/Db'
21
21
  import debug from 'debug'
22
+ import { appState } from './seedSchema'
22
23
 
23
24
  const logger = debug('app:client')
24
25
 
@@ -76,6 +77,30 @@ const client = {
76
77
  setModel(key, value)
77
78
  }
78
79
  },
80
+ setAddresses: async(addresses: string[]) => {
81
+ const {BaseDb} = await import('./db/Db/BaseDb')
82
+ if (!BaseDb) {
83
+ throw new Error('BaseDb not found')
84
+ }
85
+ if (!BaseDb.PlatformClass) {
86
+ await initDb()
87
+ }
88
+ const appDb = BaseDb.getAppDb()
89
+ if (!appDb) {
90
+ throw new Error('App DB not found')
91
+ }
92
+ appDb.insert(appState)
93
+ .values({
94
+ key: 'addresses',
95
+ value: JSON.stringify(addresses),
96
+ })
97
+ .onConflictDoUpdate({
98
+ target: appState.key,
99
+ set: {
100
+ value: JSON.stringify(addresses),
101
+ },
102
+ })
103
+ },
79
104
  subscribe: (callback: any) => {
80
105
  const subscription = globalService.subscribe(callback)
81
106
 
@@ -6,7 +6,7 @@ import {
6
6
  DB_WAITING_FOR_FILES_RECEIVED,
7
7
  INTERNAL_CONFIGURING_FS_SUCCESS,
8
8
  } from '@/services/internal/constants'
9
- import { fs } from '@zenfs/core'
9
+ import fs from '@zenfs/core'
10
10
  import debug from 'debug'
11
11
  import { FromCallbackInput, InternalMachineContext } from '@/types'
12
12
 
@@ -3,6 +3,8 @@ import { getModel } from '@/stores/modelClass'
3
3
  import { createSeed } from './createSeed'
4
4
  import { createVersion } from './createVersion'
5
5
  import { createMetadata } from './createMetadata'
6
+ import { toSnakeCase } from 'drizzle-orm/casing'
7
+ import { eventEmitter } from '@/eventBus'
6
8
 
7
9
  type CreateNewItemProps = Partial<ModelValues<any>> & {
8
10
  modelName: string
@@ -26,7 +28,7 @@ export const createNewItem = async ({
26
28
 
27
29
  const newSeedId = await createSeed({ type: seedType })
28
30
 
29
- const newVersionId = await createVersion({ seedLocalId: newSeedId })
31
+ const newVersionId = await createVersion({ seedLocalId: newSeedId, seedType: toSnakeCase(modelName) })
30
32
 
31
33
  const propertySchemas = getModel(modelName)?.schema
32
34
 
@@ -49,6 +51,8 @@ export const createNewItem = async ({
49
51
  )
50
52
  }
51
53
 
54
+ eventEmitter.emit('item.requestAll', { modelName })
55
+
52
56
  return {
53
57
  modelName,
54
58
  seedLocalId: newSeedId,
@@ -1,6 +1,6 @@
1
1
  import { syncDbFiles } from '@/services/internal/helpers'
2
2
  import { eventEmitter } from '@/eventBus'
3
- import { fs } from '@zenfs/core'
3
+ import fs from '@zenfs/core'
4
4
  import { ARWEAVE_HOST } from '@/services/internal/constants'
5
5
  import { appState } from '@/seedSchema'
6
6
  import { eq } from 'drizzle-orm'
@@ -23,6 +23,7 @@ import { getArweave } from '@/helpers/ArweaveClient'
23
23
 
24
24
  const logger = debug('app:files:download')
25
25
 
26
+
26
27
  export const downloadAllFilesRequestHandler = async ({
27
28
  endpoints,
28
29
  eventId,
@@ -78,21 +79,10 @@ export const downloadAllFilesBinaryRequestHandler = async () => {
78
79
  }),
79
80
  })
80
81
 
81
- if (!(await fs.promises.exists('/files'))) {
82
- await fs.promises.mkdir('/files', { recursive: true })
83
- }
84
-
85
- if (!(await fs.promises.exists('/files/html'))) {
86
- await fs.promises.mkdir('/files/html', { recursive: true })
87
- }
88
-
89
- if (!(await fs.promises.exists('/files/json'))) {
90
- await fs.promises.mkdir('/files/json', { recursive: true })
91
- }
92
-
93
- if (!(await fs.promises.exists('/files/images'))) {
94
- await fs.promises.mkdir('/files/images', { recursive: true })
95
- }
82
+ await BaseFileManager.createDirIfNotExists('/files')
83
+ await BaseFileManager.createDirIfNotExists('/files/html')
84
+ await BaseFileManager.createDirIfNotExists('/files/json')
85
+ await BaseFileManager.createDirIfNotExists('/files/images')
96
86
 
97
87
  const appDb = BaseDb.getAppDb()
98
88
 
@@ -1,5 +1,5 @@
1
1
  import path from 'path'
2
- import { fs } from 'fs'
2
+ import fs from 'fs'
3
3
  import pluralize from 'pluralize'
4
4
  import { camelCase, snakeCase } from 'lodash-es'
5
5
  import * as nunjucks from 'nunjucks'
package/dist/src/files.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { fs } from '@zenfs/core'
1
+ import fs from '@zenfs/core'
2
2
  import * as fsNode from 'node:fs'
3
3
  import debug from 'debug'
4
4
 
@@ -1,7 +1,7 @@
1
1
  import Transaction from 'arweave'
2
2
  import { CreateTransactionInterface } from 'arweave/web'
3
3
  import { getArweave } from '@/helpers/ArweaveClient'
4
- import { fs } from '@zenfs/core'
4
+ import fs from '@zenfs/core'
5
5
  import { getCorrectId } from '@/helpers'
6
6
  import { getSegmentedItemProperties } from '@/helpers/getSegmentedItemProperties'
7
7
  import debug from 'debug'