@seedprotocol/sdk 0.2.13 → 0.2.15

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 (173) hide show
  1. package/dist/Db-BZnRMEOf.js +82 -0
  2. package/dist/Db-BZnRMEOf.js.map +1 -0
  3. package/dist/{Db-DuTuGf68.js → Db-Dq4z7IcQ.js} +11 -10
  4. package/dist/{Db-DuTuGf68.js.map → Db-Dq4z7IcQ.js.map} +1 -1
  5. package/dist/{EasClient-DdahV-My.js → EasClient-BGQRv2-M.js} +2 -2
  6. package/dist/{EasClient-virlpmud.js.map → EasClient-BGQRv2-M.js.map} +1 -1
  7. package/dist/{EasClient-virlpmud.js → EasClient-Bbxr5rcF.js} +2 -2
  8. package/dist/{EasClient-DdahV-My.js.map → EasClient-Bbxr5rcF.js.map} +1 -1
  9. package/dist/{FileManager-hdyZkwYe.js → FileManager-BGej9rn4.js} +2 -2
  10. package/dist/{FileManager-hdyZkwYe.js.map → FileManager-BGej9rn4.js.map} +1 -1
  11. package/dist/{FileManager-5GT-dMg0.js → FileManager-CYXquukS.js} +2 -2
  12. package/dist/{FileManager-5GT-dMg0.js.map → FileManager-CYXquukS.js.map} +1 -1
  13. package/dist/{Item-CLlF0KW4.js → Item-BWNyN_kg.js} +11 -10
  14. package/dist/Item-BWNyN_kg.js.map +1 -0
  15. package/dist/{QueryClient-DI1wuuAt.js → QueryClient-CY_4gVB3.js} +2 -2
  16. package/dist/{QueryClient-DI1wuuAt.js.map → QueryClient-CY_4gVB3.js.map} +1 -1
  17. package/dist/{QueryClient-J0ohccHX.js → QueryClient-Dk66c5aw.js} +2 -2
  18. package/dist/{QueryClient-J0ohccHX.js.map → QueryClient-Dk66c5aw.js.map} +1 -1
  19. package/dist/bin.js +6 -6
  20. package/dist/bin.js.map +1 -1
  21. package/dist/{constants-C0HNnrob.js → constants-CuI_qYXt.js} +2 -2
  22. package/dist/constants-CuI_qYXt.js.map +1 -0
  23. package/dist/{index-DI6gojqO.js → index-Ce_InXlh.js} +11 -10
  24. package/dist/index-Ce_InXlh.js.map +1 -0
  25. package/dist/{index-B8uGwSbV.js → index-u7VSYW4L.js} +3866 -3967
  26. package/dist/index-u7VSYW4L.js.map +1 -0
  27. package/dist/main.js +9 -8
  28. package/dist/main.js.map +1 -1
  29. package/dist/{seed.schema.config-jYCP0EPe.js → seed.schema.config-gamPau9w.js} +12 -11
  30. package/dist/seed.schema.config-gamPau9w.js.map +1 -0
  31. package/dist/shared/configs/seed.schema.config.ts +1 -1
  32. package/dist/src/{ArweaveClientNode.ts → ArweaveClient.ts} +4 -4
  33. package/dist/src/BaseDb.ts +1 -1
  34. package/dist/src/BaseItemProperty.ts +6 -6
  35. package/dist/src/Db.ts +20 -0
  36. package/dist/src/IItem.ts +5 -3
  37. package/dist/src/IItemProperty.ts +4 -2
  38. package/dist/src/Item.ts +2 -2
  39. package/dist/src/SeedProtocolSdk.d.ts +7 -7
  40. package/dist/src/actors.ts +292 -7
  41. package/dist/src/addModelsToDb.ts +1 -1
  42. package/dist/src/client.ts +1 -1
  43. package/dist/src/download.ts +2 -2
  44. package/dist/src/index.ts +4 -21
  45. package/dist/src/initialize.ts +1 -1
  46. package/dist/src/machines.ts +0 -2
  47. package/dist/src/model.ts +13 -13
  48. package/dist/src/queries.ts +6 -27
  49. package/dist/src/seed.schema.config.ts +1 -1
  50. package/dist/src/seed.ts +4 -31
  51. package/dist/types/scripts/bin.d.ts +1 -1
  52. package/dist/types/scripts/bin.d.ts.map +1 -1
  53. package/dist/types/src/Item/BaseItem.d.ts +10 -1
  54. package/dist/types/src/Item/BaseItem.d.ts.map +1 -1
  55. package/dist/types/src/ItemProperty/BaseItemProperty.d.ts +3 -3
  56. package/dist/types/src/ItemProperty/BaseItemProperty.d.ts.map +1 -1
  57. package/dist/types/src/ItemProperty/service/propertyMachine.d.ts +1 -1
  58. package/dist/types/src/browser/ItemProperty/index.d.ts +0 -136
  59. package/dist/types/src/browser/ItemProperty/index.d.ts.map +1 -1
  60. package/dist/types/src/browser/helpers/ArweaveClient.d.ts +7 -0
  61. package/dist/types/src/browser/helpers/ArweaveClient.d.ts.map +1 -0
  62. package/dist/types/src/browser/index.d.ts +0 -2
  63. package/dist/types/src/browser/index.d.ts.map +1 -1
  64. package/dist/types/src/db/Db/BaseDb.d.ts +1 -1
  65. package/dist/types/src/db/Db/BaseDb.d.ts.map +1 -1
  66. package/dist/types/src/db/configs/browser.app.db.config.d.ts.map +1 -0
  67. package/dist/types/src/db/configs/seed.schema.config.d.ts.map +1 -0
  68. package/dist/types/src/helpers/ArweaveClient/BaseArweaveClient.d.ts.map +1 -0
  69. package/dist/types/src/helpers/ArweaveClient/index.d.ts +8 -0
  70. package/dist/types/src/helpers/ArweaveClient/index.d.ts.map +1 -0
  71. package/dist/types/src/helpers/environment.d.ts.map +1 -0
  72. package/dist/types/src/helpers/getSegmentedItemProperties.d.ts +3 -3
  73. package/dist/types/src/helpers/index.d.ts +1 -1
  74. package/dist/types/src/helpers/index.d.ts.map +1 -1
  75. package/dist/types/src/index.d.ts +6 -3
  76. package/dist/types/src/index.d.ts.map +1 -1
  77. package/dist/types/src/interfaces/IItem.d.ts +4 -3
  78. package/dist/types/src/interfaces/IItem.d.ts.map +1 -1
  79. package/dist/types/src/interfaces/IItemProperty.d.ts +3 -1
  80. package/dist/types/src/interfaces/IItemProperty.d.ts.map +1 -1
  81. package/dist/types/src/node/Item/Item.d.ts +2 -2
  82. package/dist/types/src/node/Item/Item.d.ts.map +1 -1
  83. package/dist/types/src/node/db/Db.d.ts +10 -0
  84. package/dist/types/src/node/db/Db.d.ts.map +1 -1
  85. package/dist/types/src/node/db/index.d.ts +2 -2
  86. package/dist/types/src/node/db/index.d.ts.map +1 -1
  87. package/dist/types/src/node/helpers/ArweaveClient.d.ts +7 -0
  88. package/dist/types/src/node/helpers/ArweaveClient.d.ts.map +1 -0
  89. package/dist/types/src/schema/file/download/actors.d.ts.map +1 -0
  90. package/dist/types/src/schema/file/download/index.d.ts.map +1 -0
  91. package/dist/types/src/schema/file/fetchAll/actors.d.ts.map +1 -0
  92. package/dist/types/src/schema/file/fetchAll/index.d.ts.map +1 -0
  93. package/dist/types/src/schema/file/queries.d.ts +9 -0
  94. package/dist/types/src/schema/file/queries.d.ts.map +1 -0
  95. package/dist/types/src/schema/image/queries.d.ts +7 -0
  96. package/dist/types/src/schema/image/queries.d.ts.map +1 -0
  97. package/dist/types/src/schema/index.d.ts +4 -0
  98. package/dist/types/src/schema/index.d.ts.map +1 -0
  99. package/dist/types/src/{browser/schema → schema}/model/index.d.ts +2 -2
  100. package/dist/types/src/schema/model/index.d.ts.map +1 -0
  101. package/dist/types/src/schema/property/index.d.ts +137 -0
  102. package/dist/types/src/schema/property/index.d.ts.map +1 -0
  103. package/dist/types/src/services/global/globalMachine.d.ts +94 -94
  104. package/dist/types/src/services/publish/publishMachine.d.ts +19 -19
  105. package/dist/types/src/types/machines.d.ts +0 -2
  106. package/dist/types/src/types/machines.d.ts.map +1 -1
  107. package/dist/types/src/types/model.d.ts +1 -1
  108. package/dist/types/src/types/model.d.ts.map +1 -1
  109. package/dist/types/src/types/property.d.ts +1 -1
  110. package/dist/types/src/types/property.d.ts.map +1 -1
  111. package/package.json +11 -4
  112. package/dist/Db-DOaWOiNg.js +0 -39
  113. package/dist/Db-DOaWOiNg.js.map +0 -1
  114. package/dist/Item-CLlF0KW4.js.map +0 -1
  115. package/dist/constants-C0HNnrob.js.map +0 -1
  116. package/dist/index-B8uGwSbV.js.map +0 -1
  117. package/dist/index-DI6gojqO.js.map +0 -1
  118. package/dist/seed.schema.config-jYCP0EPe.js.map +0 -1
  119. package/dist/shared/configs/browser.seed.db.config.ts +0 -33
  120. package/dist/src/ArweaveClientWeb.ts +0 -13
  121. package/dist/src/arweave.ts +0 -50
  122. package/dist/src/browser.seed.db.config.ts +0 -33
  123. package/dist/src/fsProxy.ts +0 -36
  124. package/dist/src/machine.ts +0 -55
  125. package/dist/types/src/browser/helpers/ArweaveClientWeb.d.ts +0 -7
  126. package/dist/types/src/browser/helpers/ArweaveClientWeb.d.ts.map +0 -1
  127. package/dist/types/src/browser/helpers/arweave.d.ts +0 -4
  128. package/dist/types/src/browser/helpers/arweave.d.ts.map +0 -1
  129. package/dist/types/src/browser/schema/file/download/actors.d.ts.map +0 -1
  130. package/dist/types/src/browser/schema/file/download/index.d.ts.map +0 -1
  131. package/dist/types/src/browser/schema/file/fetchAll/actors.d.ts.map +0 -1
  132. package/dist/types/src/browser/schema/file/fetchAll/index.d.ts.map +0 -1
  133. package/dist/types/src/browser/schema/file/index.d.ts +0 -17
  134. package/dist/types/src/browser/schema/file/index.d.ts.map +0 -1
  135. package/dist/types/src/browser/schema/file/machine.d.ts +0 -51
  136. package/dist/types/src/browser/schema/file/machine.d.ts.map +0 -1
  137. package/dist/types/src/browser/schema/file/queries.d.ts +0 -9
  138. package/dist/types/src/browser/schema/file/queries.d.ts.map +0 -1
  139. package/dist/types/src/browser/schema/file/upload/actors.d.ts +0 -3
  140. package/dist/types/src/browser/schema/file/upload/actors.d.ts.map +0 -1
  141. package/dist/types/src/browser/schema/file/upload/index.d.ts +0 -2
  142. package/dist/types/src/browser/schema/file/upload/index.d.ts.map +0 -1
  143. package/dist/types/src/browser/schema/image/index.d.ts +0 -9
  144. package/dist/types/src/browser/schema/image/index.d.ts.map +0 -1
  145. package/dist/types/src/browser/schema/image/queries.d.ts +0 -7
  146. package/dist/types/src/browser/schema/image/queries.d.ts.map +0 -1
  147. package/dist/types/src/browser/schema/index.d.ts +0 -6
  148. package/dist/types/src/browser/schema/index.d.ts.map +0 -1
  149. package/dist/types/src/browser/schema/model/actors.d.ts +0 -1
  150. package/dist/types/src/browser/schema/model/actors.d.ts.map +0 -1
  151. package/dist/types/src/browser/schema/model/index.d.ts.map +0 -1
  152. package/dist/types/src/helpers/BaseArweaveClient.d.ts.map +0 -1
  153. package/dist/types/src/node/helpers/ArweaveClientNode.d.ts +0 -7
  154. package/dist/types/src/node/helpers/ArweaveClientNode.d.ts.map +0 -1
  155. package/dist/types/src/shared/configs/browser.app.db.config.d.ts.map +0 -1
  156. package/dist/types/src/shared/configs/browser.seed.db.config.d.ts +0 -3
  157. package/dist/types/src/shared/configs/browser.seed.db.config.d.ts.map +0 -1
  158. package/dist/types/src/shared/configs/seed.schema.config.d.ts.map +0 -1
  159. package/dist/types/src/shared/environment.d.ts.map +0 -1
  160. package/dist/types/src/shared/fsProxy.d.ts +0 -5
  161. package/dist/types/src/shared/fsProxy.d.ts.map +0 -1
  162. package/dist/types/src/shared/index.d.ts +0 -3
  163. package/dist/types/src/shared/index.d.ts.map +0 -1
  164. package/dist/types/src/shared/seed.d.ts +0 -16
  165. package/dist/types/src/shared/seed.d.ts.map +0 -1
  166. /package/dist/types/src/{shared → db}/configs/browser.app.db.config.d.ts +0 -0
  167. /package/dist/types/src/{shared → db}/configs/seed.schema.config.d.ts +0 -0
  168. /package/dist/types/src/helpers/{BaseArweaveClient.d.ts → ArweaveClient/BaseArweaveClient.d.ts} +0 -0
  169. /package/dist/types/src/{shared → helpers}/environment.d.ts +0 -0
  170. /package/dist/types/src/{browser/schema → schema}/file/download/actors.d.ts +0 -0
  171. /package/dist/types/src/{browser/schema → schema}/file/download/index.d.ts +0 -0
  172. /package/dist/types/src/{browser/schema → schema}/file/fetchAll/actors.d.ts +0 -0
  173. /package/dist/types/src/{browser/schema → schema}/file/fetchAll/index.d.ts +0 -0
package/dist/main.js CHANGED
@@ -1,21 +1,18 @@
1
1
  import 'immer';
2
2
  import 'reflect-metadata';
3
- export { c as ImageSrc, I as Item, d as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, t as client, s as eventEmitter, r as getCorrectId, q as getGlobalService, h as useCreateItem, k as useDeleteItem, l as useGlobalServiceStatus, e as useItem, f as useItemProperties, j as useItemProperty, u as useItems, n as usePersistedSnapshots, m as usePublishItem, p as useService, o as useServices, w as withSeed } from './index-B8uGwSbV.js';
3
+ export { 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, t as eventEmitter, r as getCorrectId, s as getGlobalService, j as useCreateItem, l as useDeleteItem, m as useGlobalServiceStatus, f as useItem, h as useItemProperties, k as useItemProperty, u as useItems, o as usePersistedSnapshots, n as usePublishItem, q as useService, p as useServices, w as withSeed } from './index-u7VSYW4L.js';
4
4
  import 'tslib';
5
- import 'xstate';
6
- import 'arweave';
7
5
  import 'drizzle-orm';
8
- export { c as BaseArweaveClient, B as BaseEasClient, b as BaseFileManager, a as BaseQueryClient } from './constants-C0HNnrob.js';
6
+ export { c as BaseArweaveClient, B as BaseEasClient, b as BaseFileManager, a as BaseQueryClient } from './constants-CuI_qYXt.js';
9
7
  import '@sinclair/typebox';
10
- import 'rxjs';
11
- import '@zenfs/core';
8
+ import 'react';
12
9
  import 'dayjs';
13
10
  import 'nanoid';
14
11
  import 'nanoid-dictionary';
12
+ import '@zenfs/core';
15
13
  import 'debug';
16
14
  import 'drizzle-orm/sqlite-core';
17
- import 'path';
18
- import 'react';
15
+ import 'xstate';
19
16
  import 'pluralize';
20
17
  import 'eventemitter3';
21
18
  import 'lodash-es';
@@ -25,7 +22,11 @@ import 'drizzle-orm/sqlite-proxy/migrator';
25
22
  import 'drizzle-orm/migrator';
26
23
  import 'node:fs';
27
24
  import '@zenfs/dom';
25
+ import 'path';
26
+ import 'arweave';
28
27
  import 'use-immer';
29
28
  import '@xstate/react';
29
+ import 'rxjs';
30
+ import '@/browser/helpers/arweave';
30
31
  import '@ethereum-attestation-service/eas-sdk';
31
32
  //# sourceMappingURL=main.js.map
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,22 +1,19 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
- import 'drizzle-orm';
3
- import { T as Text, M as Model } from './index-B8uGwSbV.js';
4
- import 'react';
5
2
  import 'reflect-metadata';
6
- import 'xstate';
7
- import 'arweave';
3
+ import { T as Text, M as Model } from './index-u7VSYW4L.js';
8
4
  import 'immer';
9
5
  import '@sinclair/typebox';
10
- import 'rxjs';
11
- import '@zenfs/core';
6
+ import 'drizzle-orm';
7
+ import 'react';
12
8
  import 'dayjs';
13
9
  import 'nanoid';
14
10
  import 'nanoid-dictionary';
11
+ import '@zenfs/core';
15
12
  import 'debug';
16
- import './constants-C0HNnrob.js';
17
- import '@ethereum-attestation-service/eas-sdk';
18
13
  import 'drizzle-orm/sqlite-core';
19
- import 'path';
14
+ import './constants-CuI_qYXt.js';
15
+ import '@ethereum-attestation-service/eas-sdk';
16
+ import 'xstate';
20
17
  import 'pluralize';
21
18
  import 'eventemitter3';
22
19
  import 'lodash-es';
@@ -26,8 +23,12 @@ import 'drizzle-orm/sqlite-proxy/migrator';
26
23
  import 'drizzle-orm/migrator';
27
24
  import 'node:fs';
28
25
  import '@zenfs/dom';
26
+ import 'path';
27
+ import 'arweave';
29
28
  import 'use-immer';
30
29
  import '@xstate/react';
30
+ import 'rxjs';
31
+ import '@/browser/helpers/arweave';
31
32
 
32
33
  let Seed = class Seed {
33
34
  };
@@ -75,4 +76,4 @@ const models = {
75
76
  };
76
77
 
77
78
  export { models };
78
- //# sourceMappingURL=seed.schema.config-jYCP0EPe.js.map
79
+ //# sourceMappingURL=seed.schema.config-gamPau9w.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.schema.config-gamPau9w.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,KAAA,CAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,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,KAAA,CAAA,CAAA;AAChB,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,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,KAAA,CAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAe,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA;AAFlB,QAAQ,GAAA,UAAA,CAAA;IADb;AACK,CAAA,EAAA,QAAQ,CAGb;AAEY,MAAA,MAAM,GAAG;IACpB,IAAI;IACJ,OAAO;IACP,QAAQ;;;;;"}
@@ -1,4 +1,4 @@
1
- import { Model, Text } from '@/browser'
1
+ import { Model, Text } from '@/schema'
2
2
 
3
3
  @Model
4
4
  class Seed {
@@ -1,13 +1,13 @@
1
- import { BaseArweaveClient } from '@/helpers/BaseArweaveClient';
1
+ import { BaseArweaveClient } from '@/helpers/ArweaveClient/BaseArweaveClient';
2
2
  import { ARWEAVE_ENDPOINT } from '@/services/internal/constants';
3
3
  import { GraphQLClient } from 'graphql-request';
4
4
 
5
- class ArweaveClientNode extends BaseArweaveClient {
5
+ class ArweaveClient extends BaseArweaveClient {
6
6
  static getArweaveClient(): GraphQLClient {
7
7
  return new GraphQLClient(ARWEAVE_ENDPOINT);
8
8
  }
9
9
  }
10
10
 
11
- BaseArweaveClient.setPlatformClass(ArweaveClientNode);
11
+ BaseArweaveClient.setPlatformClass(ArweaveClient);
12
12
 
13
- export { ArweaveClientNode };
13
+ export { ArweaveClient };
@@ -20,7 +20,7 @@ export abstract class BaseDb implements IDb {
20
20
  return this.PlatformClass.isAppDbReady()
21
21
  }
22
22
 
23
- static prepareDb(): Promise<unknown> {
23
+ static prepareDb(): Promise<BaseSQLiteDatabase> {
24
24
  return this.PlatformClass.prepareDb()
25
25
  }
26
26
 
@@ -1,7 +1,6 @@
1
1
  import { ActorRefFrom, createActor, SnapshotFrom, Subscription, waitFor } from 'xstate'
2
2
  import { BehaviorSubject, Subscriber } from 'rxjs'
3
3
  import { Static } from '@sinclair/typebox'
4
- import { ItemProperty, TProperty } from '@/browser/ItemProperty'
5
4
  import { IItemProperty } from '@/interfaces/IItemProperty'
6
5
  import { immerable } from 'immer'
7
6
  import { CreatePropertyInstanceProps, PropertyMachineContext } from '@/types'
@@ -14,6 +13,7 @@ import { eventEmitter } from '@/eventBus'
14
13
  import fs from '@zenfs/core'
15
14
  import { getPropertyData } from '@/db/read/getPropertyData'
16
15
  import { getCorrectId } from '@/helpers'
16
+ import { TProperty } from '@/schema'
17
17
 
18
18
  const logger = debug('app:property:class')
19
19
 
@@ -133,7 +133,7 @@ export abstract class BaseItemProperty<PropertyType> implements IItemProperty<Pr
133
133
  const { propertyRecordSchema } = context
134
134
 
135
135
  if (context.seedLocalId) {
136
- const cacheKey = ItemProperty.cacheKey(
136
+ const cacheKey = BaseItemProperty.cacheKey(
137
137
  context.seedLocalId,
138
138
  context.propertyName,
139
139
  )
@@ -256,12 +256,12 @@ export abstract class BaseItemProperty<PropertyType> implements IItemProperty<Pr
256
256
  return instance
257
257
  }
258
258
  if (!this.instanceCache.has(cacheKey)) {
259
- const newInstance = new ItemProperty(props)
259
+ const newInstance = new this(props)
260
260
  this.instanceCache.set(cacheKey, { instance: newInstance, refCount: 1 })
261
261
  return newInstance
262
262
  }
263
263
  }
264
- return new ItemProperty(props)
264
+ return new this(props)
265
265
  }
266
266
 
267
267
  static async find({
@@ -273,7 +273,7 @@ export abstract class BaseItemProperty<PropertyType> implements IItemProperty<Pr
273
273
  return
274
274
  }
275
275
  const cacheKeyId = seedUid || seedLocalId
276
- const cacheKey = ItemProperty.cacheKey(cacheKeyId!, propertyName)
276
+ const cacheKey = BaseItemProperty.cacheKey(cacheKeyId!, propertyName)
277
277
  if (this.instanceCache.has(cacheKey)) {
278
278
  const { instance, refCount } = this.instanceCache.get(cacheKey)!
279
279
  this.instanceCache.set(cacheKey, {
@@ -290,7 +290,7 @@ export abstract class BaseItemProperty<PropertyType> implements IItemProperty<Pr
290
290
  if (!propertyData) {
291
291
  return
292
292
  }
293
- return ItemProperty.create(propertyData)
293
+ return BaseItemProperty.create(propertyData)
294
294
  }
295
295
 
296
296
  static cacheKey(seedLocalIdOrUid: string, propertyName: string): string {
package/dist/src/Db.ts CHANGED
@@ -1,8 +1,28 @@
1
1
  import { BaseDb } from "@/db/Db/BaseDb";
2
2
  import { IDb } from "@/interfaces";
3
+ import nodeAppDbConfig from "./node.app.db.config";
4
+ import { drizzle } from "drizzle-orm/better-sqlite3";
3
5
 
4
6
  export class Db extends BaseDb implements IDb {
5
7
  constructor() {
6
8
  super()
7
9
  }
10
+
11
+ static getAppDb() {
12
+ return drizzle(nodeAppDbConfig)
13
+ }
14
+
15
+ static isAppDbReady() {
16
+ return true
17
+ }
18
+
19
+ static async prepareDb() {
20
+ return drizzle(nodeAppDbConfig)
21
+ }
22
+
23
+ static connectToDb(pathToDir: string, dbName: string) {
24
+ return {
25
+ id: drizzle(nodeAppDbConfig).$client.name
26
+ }
27
+ }
8
28
  }
package/dist/src/IItem.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { ActorRefFrom, Subscription } from 'xstate'
2
- import { ItemProperty } from '@/browser/property/ItemProperty'
3
- import { CreatePropertyInstanceProps, ModelSchema, ModelValues, PropertyData } from '@/types'
2
+ import { ModelSchema, ModelValues, NewItemProps, PropertyData } from '@/types'
4
3
  import { VersionsType } from '@/seedSchema/VersionSchema'
4
+ import { IItemProperty } from './IItemProperty'
5
5
 
6
6
  export interface IItem<T extends ModelValues<ModelSchema>> {
7
+
8
+ constructor(initialValues: NewItemProps<T>): void
7
9
  subscribe(callback: (itemProps: any) => void): Subscription
8
10
  getService(): ActorRefFrom<any>
9
11
  getEditedProperties(): Promise<PropertyData[]>
@@ -17,5 +19,5 @@ export interface IItem<T extends ModelValues<ModelSchema>> {
17
19
  readonly schemaUid: string
18
20
  readonly latestVersionUid: VersionsType
19
21
  readonly modelName: string
20
- readonly properties: Record<string, ItemProperty<any>>
22
+ readonly properties: Record<string, IItemProperty<any>>
21
23
  }
@@ -1,10 +1,12 @@
1
1
  import { ActorRefFrom, Subscription } from 'xstate';
2
- import { PropertyMachineContext } from '@/types';
3
2
  import { BehaviorSubject } from 'rxjs';
4
3
  import { Static } from '@sinclair/typebox';
5
- import { TProperty } from '@/browser/ItemProperty';
4
+ import { TProperty } from '@/schema';
5
+ import { CreatePropertyInstanceProps } from '@/types';
6
6
 
7
7
  export interface IItemProperty<PropertyType> {
8
+
9
+ constructor(initialValues: Partial<CreatePropertyInstanceProps>): void
8
10
  readonly localId: string;
9
11
  readonly uid: string;
10
12
  readonly seedLocalId: string;
package/dist/src/Item.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { IItem } from '@/interfaces';
2
2
  import { BaseItem } from '@/Item/BaseItem';
3
- import { ModelSchema, ModelValues } from '@/types';
3
+ import { ModelSchema, ModelValues, NewItemProps } from '@/types';
4
4
 
5
5
  export class Item<T extends ModelValues<ModelSchema>> extends BaseItem<T> implements IItem<T> {
6
- constructor(initialValues: any) {
6
+ constructor(initialValues: NewItemProps<T>) {
7
7
  super(initialValues);
8
8
  }
9
9
 
@@ -21,13 +21,13 @@ export interface SeedProtocolSdk {
21
21
  eventEmitter: typeof import('@/eventBus').eventEmitter;
22
22
 
23
23
  // Exported types
24
- Model: typeof import('@/browser/schema').Model;
25
- Property: typeof import('@/browser/schema').Property;
26
- ImageSrc: typeof import('@/browser/schema').ImageSrc;
27
- List: typeof import('@/browser/schema').List;
28
- Text: typeof import('@/browser/schema').Text;
29
- Json: typeof import('@/browser/schema').Json;
30
- Relation: typeof import('@/browser/schema').Relation;
24
+ Model: typeof import('@/schema').Model;
25
+ Property: typeof import('@/schema').Property;
26
+ ImageSrc: typeof import('@/schema').ImageSrc;
27
+ List: typeof import('@/schema').List;
28
+ Text: typeof import('@/schema').Text;
29
+ Json: typeof import('@/schema').Json;
30
+ Relation: typeof import('@/schema').Relation;
31
31
 
32
32
  // Node-specific exports
33
33
  withSeed?: typeof import('@/node').withSeed;
@@ -1,10 +1,295 @@
1
1
  import { EventObject, fromCallback } from 'xstate'
2
- import { uploadMachine } from '@/browser/schema/file/upload/index'
2
+ import { fetchAllFilesMachine } from '@/schema/file/fetchAll/index'
3
+ import { ARWEAVE_HOST } from '@/services/internal/constants'
4
+ import { GET_FILES_METADATA } from '@/schema/file/queries'
5
+ import { getArweave } from '@/browser/helpers/arweave'
6
+ import { fs } from '@zenfs/core'
7
+ import {
8
+ getDataTypeFromString,
9
+ getMimeType,
10
+ identifyString,
11
+ } from '@/helpers'
12
+ import { appState } from '@/seedSchema'
13
+ import { eq } from 'drizzle-orm'
14
+ import { BaseEasClient } from '@/helpers/EasClient/BaseEasClient'
15
+ import { BaseQueryClient } from '@/helpers/QueryClient/BaseQueryClient'
16
+ import debug from 'debug'
17
+ import { BaseDb } from '@/db/Db/BaseDb'
18
+ import { saveAppState } from '@/db/write/saveAppState'
3
19
 
4
- export const uploadBinaryData = fromCallback<EventObject, typeof uploadMachine>(
5
- ({ sendBack, receive, input }) => {},
6
- )
20
+ const logger = debug('app:file:actors:fetchAll')
7
21
 
8
- export const uploadMetadata = fromCallback<EventObject, typeof uploadMachine>(
9
- ({ sendBack, receive, input }) => {},
10
- )
22
+ type FileType = {
23
+ mimeType: string
24
+ extension: string
25
+ }
26
+
27
+ // Map of common MIME types to file extensions
28
+ const fileTypeMap: Record<string, FileType> = {
29
+ 'image/jpeg': { mimeType: 'image/jpeg', extension: '.jpg' },
30
+ 'image/png': { mimeType: 'image/png', extension: '.png' },
31
+ 'application/json': { mimeType: 'application/json', extension: '.json' },
32
+ 'text/plain': { mimeType: 'text/plain', extension: '.txt' },
33
+ // Add more MIME types and file extensions as needed
34
+ }
35
+
36
+ export const fetchAllMetadataRecords = fromCallback<
37
+ EventObject,
38
+ typeof fetchAllFilesMachine
39
+ >(({ sendBack, receive, input: { context, event } }) => {
40
+ const { addresses } = context
41
+
42
+ const _fetchAllMetadataRecords = async () => {
43
+ const queryClient = BaseQueryClient.getQueryClient()
44
+ const easClient = BaseEasClient.getEasClient()
45
+
46
+ const { filesMetadata } = await queryClient.fetchQuery({
47
+ queryKey: ['getFilesMetadata', ...addresses],
48
+ queryFn: async () =>
49
+ easClient.request(GET_FILES_METADATA, {
50
+ where: {
51
+ attester: {
52
+ in: addresses,
53
+ },
54
+ schema: {
55
+ is: {
56
+ id: {
57
+ equals:
58
+ '0x55fdefb36fcbbaebeb7d6b41dc3a1a9666e4e42154267c889de064faa7ede517',
59
+ },
60
+ },
61
+ },
62
+ },
63
+ }),
64
+ })
65
+
66
+ return filesMetadata
67
+ }
68
+
69
+ _fetchAllMetadataRecords().then((filesMetadata) => {
70
+ sendBack({ type: 'fetchingAllMetadataRecordsSuccess', filesMetadata })
71
+ })
72
+
73
+ return () => { }
74
+ })
75
+
76
+ export const fetchAllBinaryData = fromCallback<
77
+ EventObject,
78
+ typeof fetchAllFilesMachine
79
+ >(({ sendBack, input: { context } }) => {
80
+ const { filesMetadata, addresses } = context
81
+
82
+ const _fetchAllBinaryData = async () => {
83
+ if (!(await fs.promises.exists('/files'))) {
84
+ await fs.promises.mkdir('/files', { recursive: true })
85
+ }
86
+
87
+ if (!(await fs.promises.exists('/files/html'))) {
88
+ await fs.promises.mkdir('/files/html', { recursive: true })
89
+ }
90
+
91
+ if (!(await fs.promises.exists('/files/json'))) {
92
+ await fs.promises.mkdir('/files/json', { recursive: true })
93
+ }
94
+
95
+ if (!(await fs.promises.exists('/files/images'))) {
96
+ await fs.promises.mkdir('/files/images', { recursive: true })
97
+ }
98
+
99
+ const appDb = BaseDb.getAppDb()
100
+
101
+ if (!appDb) {
102
+ logger('[fetchAll/actors] [fetchAllBinaryData] seedDb not available')
103
+ return []
104
+ }
105
+
106
+ for (const fileMetadata of filesMetadata) {
107
+ const json = JSON.parse(fileMetadata.decodedDataJson)
108
+ const transactionId = json[0].value.value
109
+
110
+ const excludedTransactionsQuery = await appDb
111
+ .select()
112
+ .from(appState)
113
+ .where(eq(appState.key, 'excludedTransactions'))
114
+
115
+ let excludedTransactions = new Set<string>()
116
+
117
+ if (excludedTransactionsQuery && excludedTransactionsQuery.length === 1) {
118
+ const valueString = excludedTransactionsQuery[0].value
119
+ if (valueString) {
120
+ const excludedTransactionsArray = JSON.parse(valueString)
121
+ excludedTransactions = new Set(excludedTransactionsArray)
122
+ }
123
+ }
124
+
125
+ if (excludedTransactions.has(transactionId)) {
126
+ continue
127
+ }
128
+
129
+ const arweave = getArweave()
130
+
131
+ if (!arweave) {
132
+ logger('[fetchAll/actors] [fetchAllBinaryData] arweave not available')
133
+ return []
134
+ }
135
+
136
+ try {
137
+ const res = await fetch(
138
+ `https://${ARWEAVE_HOST}/tx/${transactionId}/status`,
139
+ )
140
+
141
+ if (res.status !== 200) {
142
+ logger(
143
+ `[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`,
144
+ )
145
+
146
+ excludedTransactions.add(transactionId)
147
+
148
+ await saveAppState(
149
+ 'excludedTransactions',
150
+ JSON.stringify(Array.from(excludedTransactions)),
151
+ )
152
+
153
+ logger(
154
+ '[fetchAll/actors] [fetchAllBinaryData] updated excludedTransactions:',
155
+ excludedTransactions,
156
+ )
157
+
158
+ continue
159
+ }
160
+
161
+ const dataString = await arweave.transactions
162
+ .getData(transactionId, {
163
+ decode: true,
164
+ string: true,
165
+ })
166
+ .catch((error) => {
167
+ logger(
168
+ `[fetchAll/actors] [fetchAllBinaryData] error fetching transaction data for ${transactionId}`,
169
+ error,
170
+ )
171
+ })
172
+
173
+ const dataUint8Array = await arweave.transactions.getData(transactionId)
174
+ // let buffer
175
+ //
176
+ // if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
177
+ // }
178
+
179
+ let contentType = identifyString(dataString)
180
+ if (
181
+ contentType !== 'json' &&
182
+ contentType !== 'base64' &&
183
+ contentType !== 'html'
184
+ ) {
185
+ const possibleImageType = getDataTypeFromString(dataString)
186
+ if (!possibleImageType) {
187
+ logger(
188
+ `[fetchAll/actors] [fetchAllBinaryData] transaction ${transactionId} data not in expected format: ${possibleImageType}`,
189
+ )
190
+ continue
191
+ }
192
+
193
+ contentType = possibleImageType
194
+ }
195
+
196
+ if (contentType === 'url') {
197
+ const url = dataString as string
198
+ const response = await fetch(url)
199
+ if (!response.ok) {
200
+ throw new Error(`Failed to fetch image: ${response.statusText}`)
201
+ }
202
+
203
+ // Get the image as a Blob
204
+ const blob = await response.blob()
205
+ const buffer = await blob.arrayBuffer()
206
+ const bufferUint8Array = new Uint8Array(buffer)
207
+
208
+ // Extract the file extension from the URL
209
+ const extensionMatch = url.match(
210
+ /\.(jpg|jpeg|png|gif|bmp|webp|svg)$/i,
211
+ )
212
+ if (!extensionMatch) {
213
+ throw new Error(
214
+ 'Unable to determine the file extension from the URL.',
215
+ )
216
+ }
217
+ const fileExtension = extensionMatch[0] // e.g., ".jpg"
218
+
219
+ // Set the file name (you can customize this)
220
+ // const fileNameFromUrl = `${transactionId}${fileExtension}`
221
+
222
+ await fs.promises.writeFile(
223
+ `/files/images/${transactionId}`,
224
+ bufferUint8Array,
225
+ {
226
+ encoding: 'binary',
227
+ },
228
+ )
229
+
230
+ continue
231
+ }
232
+
233
+ let mimeType = getMimeType(dataString as string)
234
+ let fileExtension = mimeType
235
+
236
+ if (fileExtension && fileExtension?.startsWith('image')) {
237
+ fileExtension = fileExtension.replace('image/', '')
238
+ }
239
+
240
+ let fileName = transactionId
241
+
242
+ if (contentType === 'base64') {
243
+ if (mimeType) {
244
+ fileName += `.${fileExtension}`
245
+ }
246
+
247
+ // Remove the Base64 header if it exists (e.g., "data:image/png;base64,")
248
+ const base64Data = dataString.split(',').pop() || ''
249
+
250
+ // Decode the Base64 string to binary
251
+ const binaryString = atob(base64Data)
252
+ const length = binaryString.length
253
+ const binaryData = new Uint8Array(length)
254
+
255
+ for (let i = 0; i < length; i++) {
256
+ binaryData[i] = binaryString.charCodeAt(i)
257
+ }
258
+
259
+ console.log(`attempting to writeFile to /files/images/${fileName}`)
260
+
261
+ await fs.promises.writeFile(`/files/images/${fileName}`, binaryData, {
262
+ encoding: 'binary',
263
+ })
264
+
265
+ // if (dataUint8Array && dataUint8Array instanceof Uint8Array) {
266
+ // await fs.promises.writeFile(
267
+ // `/files/images/${fileName}`,
268
+ // dataUint8Array,
269
+ // )
270
+ // }
271
+ }
272
+
273
+ if (contentType === 'html') {
274
+ fileName += '.html'
275
+ await fs.promises.writeFile(`/files/html/${fileName}`, dataString)
276
+ }
277
+
278
+ if (contentType === 'json') {
279
+ fileName += '.json'
280
+ await fs.promises.writeFile(`/files/json/${fileName}`, dataString)
281
+ }
282
+ } catch (error) {
283
+ logger(error)
284
+ }
285
+ }
286
+
287
+ return []
288
+ }
289
+
290
+ _fetchAllBinaryData().then((binaryData) => {
291
+ sendBack({ type: 'fetchingAllBinaryDataSuccess', binaryData })
292
+ })
293
+
294
+ return () => { }
295
+ })
@@ -25,7 +25,7 @@ export const addModelsToDb = fromCallback<
25
25
  }
26
26
 
27
27
  const { models: SeedModels } = await import(
28
- '@/shared/configs/seed.schema.config'
28
+ '@/db/configs/seed.schema.config'
29
29
  )
30
30
 
31
31
  const allModels = {
@@ -56,7 +56,7 @@ const client = {
56
56
  arweaveDomain,
57
57
  })
58
58
 
59
- const { models: internalModels } = await import('@/shared/configs/seed.schema.config')
59
+ const { models: internalModels } = await import('@/db/configs/seed.schema.config')
60
60
  for (const [key, value] of Object.entries(internalModels)) {
61
61
  setModel(key, value)
62
62
  }
@@ -4,14 +4,13 @@ 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'
7
- import { getArweave } from '@/browser/schema/file'
8
7
  import { getAddressesFromDb } from '@/helpers/db'
9
8
  import {
10
9
  getDataTypeFromString,
11
10
  getMimeType,
12
11
  identifyString,
13
12
  } from '@/helpers'
14
- import { GET_FILES_METADATA } from '@/browser/schema/file/queries'
13
+ import { GET_FILES_METADATA } from '@/schema/file/queries'
15
14
  import debug from 'debug'
16
15
  import { getGlobalService } from '@/services'
17
16
  import { waitFor } from 'xstate'
@@ -21,6 +20,7 @@ import { GET_TRANSACTION_TAGS } from '@/browser/arweave/queries'
21
20
  import { saveAppState } from '@/db/write/saveAppState'
22
21
  import { BaseDb } from '@/db/Db/BaseDb'
23
22
  import { BaseEasClient, BaseQueryClient, BaseArweaveClient } from '@/helpers'
23
+ import { getArweave } from '@/helpers/ArweaveClient'
24
24
 
25
25
 
26
26
  const logger = debug('app:files:download')
package/dist/src/index.ts CHANGED
@@ -1,21 +1,4 @@
1
- import { setup } from 'xstate'
2
- import {
3
- uploadBinaryData,
4
- uploadMetadata,
5
- } from '@/browser/schema/file/upload/actors'
6
-
7
- export const uploadMachine = setup({
8
- actors: {
9
- uploadBinaryData,
10
- uploadMetadata,
11
- },
12
- }).createMachine({
13
- id: 'upload',
14
- initial: 'idle',
15
- context: {
16
- file: '',
17
- },
18
- states: {
19
- idle: {},
20
- },
21
- })
1
+ export * from './analyzeInput'
2
+ export * from './saveImageSrc'
3
+ export * from './saveRelation'
4
+ export * from './saveItemStorage'
@@ -1,5 +1,5 @@
1
1
  import { EventObject, fromCallback, Subscription } from 'xstate'
2
- import { isNode, isReactNative } from '@/shared'
2
+ import { isNode, isReactNative } from '@/helpers/environment'
3
3
  import {
4
4
  GLOBAL_INITIALIZING_CREATE_ALL_ITEMS_SERVICES,
5
5
  GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY,