@seedprotocol/sdk 0.3.14 → 0.3.16

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 (192) hide show
  1. package/dist/addModel.js +93 -0
  2. package/dist/addModel.js.map +1 -0
  3. package/dist/bin.js +8 -5
  4. package/dist/bin.js.map +1 -1
  5. package/dist/main.js +1 -0
  6. package/dist/main.js.map +1 -1
  7. package/dist/protos/seed.proto +97 -0
  8. package/dist/rpcServer.js +358 -0
  9. package/dist/rpcServer.js.map +1 -0
  10. package/dist/scripts/addModel.d.ts +3 -0
  11. package/dist/scripts/addModel.d.ts.map +1 -0
  12. package/dist/scripts/bin.d.ts.map +1 -1
  13. package/dist/scripts/rpcServer.cursor.d.ts +2 -0
  14. package/dist/scripts/rpcServer.cursor.d.ts.map +1 -0
  15. package/dist/scripts/rpcServer.d.ts +3 -0
  16. package/dist/scripts/rpcServer.d.ts.map +1 -0
  17. package/dist/scripts/vite.config.d.ts +3 -0
  18. package/dist/scripts/vite.config.d.ts.map +1 -0
  19. package/dist/seedSchema/AppStateSchema.ts +2 -2
  20. package/dist/seedSchema/ConfigSchema.ts +18 -14
  21. package/dist/seedSchema/MetadataSchema.ts +2 -1
  22. package/dist/seedSchema/ModelSchema.ts +3 -3
  23. package/dist/seedSchema/SeedSchema.ts +2 -1
  24. package/dist/seedSchema/VersionSchema.ts +2 -1
  25. package/dist/seedSchema/index.ts +1 -0
  26. package/dist/src/Item/BaseItem.d.ts +1 -1
  27. package/dist/src/Item/BaseItem.d.ts.map +1 -1
  28. package/dist/src/Item/BaseItem.js.map +1 -1
  29. package/dist/src/ItemProperty/BaseItemProperty.d.ts +55 -192
  30. package/dist/src/ItemProperty/BaseItemProperty.d.ts.map +1 -1
  31. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts +2 -1
  32. package/dist/src/ItemProperty/service/actors/hydrateFromDb.d.ts.map +1 -1
  33. package/dist/src/ItemProperty/service/actors/hydrateFromDb.js +2 -1
  34. package/dist/src/ItemProperty/service/actors/hydrateFromDb.js.map +1 -1
  35. package/dist/src/ItemProperty/service/actors/initialize.d.ts +2 -1
  36. package/dist/src/ItemProperty/service/actors/initialize.d.ts.map +1 -1
  37. package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts +2 -1
  38. package/dist/src/ItemProperty/service/actors/resolveRelatedValue.d.ts.map +1 -1
  39. package/dist/src/ItemProperty/service/actors/resolveRemoteStorage.d.ts +2 -1
  40. package/dist/src/ItemProperty/service/actors/resolveRemoteStorage.d.ts.map +1 -1
  41. package/dist/src/ItemProperty/service/actors/resolveRemoteStorage.js +1 -1
  42. package/dist/src/ItemProperty/service/actors/resolveRemoteStorage.js.map +1 -1
  43. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts +2 -2
  44. package/dist/src/ItemProperty/service/actors/saveValueToDb/analyzeInput.d.ts.map +1 -1
  45. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts +2 -2
  46. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveImage.d.ts.map +1 -1
  47. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts +2 -2
  48. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.d.ts.map +1 -1
  49. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.js +1 -0
  50. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveItemStorage.js.map +1 -1
  51. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts +2 -2
  52. package/dist/src/ItemProperty/service/actors/saveValueToDb/saveRelation.d.ts.map +1 -1
  53. package/dist/src/ItemProperty/service/actors/waitForDb.d.ts +2 -2
  54. package/dist/src/ItemProperty/service/actors/waitForDb.d.ts.map +1 -1
  55. package/dist/src/ItemProperty/service/propertyMachine.d.ts +60 -195
  56. package/dist/src/ItemProperty/service/propertyMachine.d.ts.map +1 -1
  57. package/dist/src/browser/helpers/FileManager.d.ts +1 -0
  58. package/dist/src/browser/helpers/FileManager.d.ts.map +1 -1
  59. package/dist/src/browser/helpers/FileManager.js +3 -0
  60. package/dist/src/browser/helpers/FileManager.js.map +1 -1
  61. package/dist/src/browser/react/services.js +1 -0
  62. package/dist/src/browser/react/services.js.map +1 -1
  63. package/dist/src/client/ClientManager.js +1 -0
  64. package/dist/src/client/ClientManager.js.map +1 -1
  65. package/dist/src/client/actors/initialize.d.ts.map +1 -1
  66. package/dist/src/client/actors/initialize.js +28 -14
  67. package/dist/src/client/actors/initialize.js.map +1 -1
  68. package/dist/src/client/actors/saveAppState.js +1 -0
  69. package/dist/src/client/actors/saveAppState.js.map +1 -1
  70. package/dist/src/client/index.d.ts +1 -1
  71. package/dist/src/client/index.d.ts.map +1 -1
  72. package/dist/src/db/Db/BaseDb.d.ts +1 -0
  73. package/dist/src/db/Db/BaseDb.d.ts.map +1 -1
  74. package/dist/src/db/Db/BaseDb.js +3 -0
  75. package/dist/src/db/Db/BaseDb.js.map +1 -1
  76. package/dist/src/db/read/getExistingItem.js +1 -0
  77. package/dist/src/db/read/getExistingItem.js.map +1 -1
  78. package/dist/src/db/read/getItemData.js +1 -0
  79. package/dist/src/db/read/getItemData.js.map +1 -1
  80. package/dist/src/db/read/getItemProperties.js +1 -0
  81. package/dist/src/db/read/getItemProperties.js.map +1 -1
  82. package/dist/src/db/read/getItemProperty.js +1 -0
  83. package/dist/src/db/read/getItemProperty.js.map +1 -1
  84. package/dist/src/db/read/getItems.js +1 -0
  85. package/dist/src/db/read/getItems.js.map +1 -1
  86. package/dist/src/db/read/getMetadata.js +1 -0
  87. package/dist/src/db/read/getMetadata.js.map +1 -1
  88. package/dist/src/db/read/getModelSchemas.js +1 -0
  89. package/dist/src/db/read/getModelSchemas.js.map +1 -1
  90. package/dist/src/db/read/getModels.js +1 -0
  91. package/dist/src/db/read/getModels.js.map +1 -1
  92. package/dist/src/db/read/getPropertyData.js +1 -0
  93. package/dist/src/db/read/getPropertyData.js.map +1 -1
  94. package/dist/src/db/read/getRelationValueData.js +1 -0
  95. package/dist/src/db/read/getRelationValueData.js.map +1 -1
  96. package/dist/src/db/read/getSeedData.js +1 -0
  97. package/dist/src/db/read/getSeedData.js.map +1 -1
  98. package/dist/src/db/read/getStorageTransactionIdForSeedUid.js +1 -0
  99. package/dist/src/db/read/getStorageTransactionIdForSeedUid.js.map +1 -1
  100. package/dist/src/db/read/getVersionData.js +1 -0
  101. package/dist/src/db/read/getVersionData.js.map +1 -1
  102. package/dist/src/db/read/subqueries/metadataLatest.js +1 -0
  103. package/dist/src/db/read/subqueries/metadataLatest.js.map +1 -1
  104. package/dist/src/db/read/subqueries/versionData.js +1 -0
  105. package/dist/src/db/read/subqueries/versionData.js.map +1 -1
  106. package/dist/src/db/write/createMetadata.js +1 -0
  107. package/dist/src/db/write/createMetadata.js.map +1 -1
  108. package/dist/src/db/write/createSeed.js +1 -0
  109. package/dist/src/db/write/createSeed.js.map +1 -1
  110. package/dist/src/db/write/createSeeds.js +1 -0
  111. package/dist/src/db/write/createSeeds.js.map +1 -1
  112. package/dist/src/db/write/createVersion.js +1 -0
  113. package/dist/src/db/write/createVersion.js.map +1 -1
  114. package/dist/src/db/write/deleteItem.js +1 -0
  115. package/dist/src/db/write/deleteItem.js.map +1 -1
  116. package/dist/src/db/write/saveAppState.js +1 -0
  117. package/dist/src/db/write/saveAppState.js.map +1 -1
  118. package/dist/src/db/write/saveMetadata.js +1 -0
  119. package/dist/src/db/write/saveMetadata.js.map +1 -1
  120. package/dist/src/db/write/updateItemPropertyValue.js +1 -0
  121. package/dist/src/db/write/updateItemPropertyValue.js.map +1 -1
  122. package/dist/src/db/write/updateMetadata.js +1 -0
  123. package/dist/src/db/write/updateMetadata.js.map +1 -1
  124. package/dist/src/events/files/download.js +1 -0
  125. package/dist/src/events/files/download.js.map +1 -1
  126. package/dist/src/events/item/syncDbWithEas.js +1 -0
  127. package/dist/src/events/item/syncDbWithEas.js.map +1 -1
  128. package/dist/src/helpers/FileManager/BaseFileManager.d.ts +2 -1
  129. package/dist/src/helpers/FileManager/BaseFileManager.d.ts.map +1 -1
  130. package/dist/src/helpers/FileManager/BaseFileManager.js +3 -0
  131. package/dist/src/helpers/FileManager/BaseFileManager.js.map +1 -1
  132. package/dist/src/helpers/db.js +1 -0
  133. package/dist/src/helpers/db.js.map +1 -1
  134. package/dist/src/helpers/environment.js +6 -1
  135. package/dist/src/helpers/environment.js.map +1 -1
  136. package/dist/src/helpers/index.d.ts.map +1 -1
  137. package/dist/src/helpers/index.js.map +1 -1
  138. package/dist/src/interfaces/IItem.d.ts +1 -1
  139. package/dist/src/interfaces/IItem.d.ts.map +1 -1
  140. package/dist/src/node/Item/Item.js +11 -0
  141. package/dist/src/node/Item/Item.js.map +1 -0
  142. package/dist/src/node/ItemProperty/ItemProperty.js +10 -0
  143. package/dist/src/node/ItemProperty/ItemProperty.js.map +1 -0
  144. package/dist/src/node/codegen/drizzle.js +36 -2
  145. package/dist/src/node/codegen/drizzle.js.map +1 -1
  146. package/dist/src/node/db/Db.d.ts.map +1 -1
  147. package/dist/src/node/db/Db.js +64 -0
  148. package/dist/src/node/db/Db.js.map +1 -0
  149. package/dist/src/node/helpers/FileManager.d.ts +1 -0
  150. package/dist/src/node/helpers/FileManager.d.ts.map +1 -1
  151. package/dist/src/node/helpers/FileManager.js +53 -0
  152. package/dist/src/node/helpers/FileManager.js.map +1 -0
  153. package/dist/src/seedSchema/AppStateSchema.d.ts +2 -1
  154. package/dist/src/seedSchema/AppStateSchema.d.ts.map +1 -1
  155. package/dist/src/seedSchema/AppStateSchema.js.map +1 -1
  156. package/dist/src/seedSchema/ConfigSchema.d.ts +2 -0
  157. package/dist/src/seedSchema/ConfigSchema.d.ts.map +1 -1
  158. package/dist/src/seedSchema/ConfigSchema.js +5 -8
  159. package/dist/src/seedSchema/ConfigSchema.js.map +1 -1
  160. package/dist/src/seedSchema/MetadataSchema.d.ts +2 -1
  161. package/dist/src/seedSchema/MetadataSchema.d.ts.map +1 -1
  162. package/dist/src/seedSchema/MetadataSchema.js.map +1 -1
  163. package/dist/src/seedSchema/ModelSchema.d.ts +3 -2
  164. package/dist/src/seedSchema/ModelSchema.d.ts.map +1 -1
  165. package/dist/src/seedSchema/ModelSchema.js.map +1 -1
  166. package/dist/src/seedSchema/SeedSchema.d.ts +2 -1
  167. package/dist/src/seedSchema/SeedSchema.d.ts.map +1 -1
  168. package/dist/src/seedSchema/SeedSchema.js.map +1 -1
  169. package/dist/src/seedSchema/VersionSchema.d.ts +2 -1
  170. package/dist/src/seedSchema/VersionSchema.d.ts.map +1 -1
  171. package/dist/src/seedSchema/VersionSchema.js.map +1 -1
  172. package/dist/src/seedSchema/index.d.ts +1 -0
  173. package/dist/src/seedSchema/index.d.ts.map +1 -1
  174. package/dist/src/services/allItems/actors/fetchRelatedItems.js +1 -0
  175. package/dist/src/services/allItems/actors/fetchRelatedItems.js.map +1 -1
  176. package/dist/src/services/allItems/actors/initialize.js +1 -0
  177. package/dist/src/services/allItems/actors/initialize.js.map +1 -1
  178. package/dist/src/services/global/actors/addModelsToDb.js +1 -0
  179. package/dist/src/services/global/actors/addModelsToDb.js.map +1 -1
  180. package/dist/src/services/global/actors/initialize.js +1 -0
  181. package/dist/src/services/global/actors/initialize.js.map +1 -1
  182. package/dist/src/services/internal/actors/saveConfig.d.ts.map +1 -1
  183. package/dist/src/services/internal/actors/saveConfig.js +16 -29
  184. package/dist/src/services/internal/actors/saveConfig.js.map +1 -1
  185. package/dist/src/services/internal/helpers.d.ts.map +1 -1
  186. package/dist/src/services/internal/helpers.js +2 -2
  187. package/dist/src/services/internal/helpers.js.map +1 -1
  188. package/dist/src/services/publish/actors/preparePublishRequestData.js +1 -0
  189. package/dist/src/services/publish/actors/preparePublishRequestData.js.map +1 -1
  190. package/dist/src/types/item.d.ts +9 -8
  191. package/dist/src/types/item.d.ts.map +1 -1
  192. package/package.json +8 -2
@@ -13,9 +13,10 @@ export declare abstract class BaseFileManager {
13
13
  static waitForFile(filePath: string): Promise<boolean>;
14
14
  static saveFile(filePath: string, content: string | Blob | ArrayBuffer): Promise<void>;
15
15
  static readFile(filePath: string): Promise<File>;
16
- static readFileAsBuffer(filePath: string): Promise<Buffer>;
16
+ static readFileAsBuffer(filePath: string): Promise<Buffer | Blob>;
17
17
  static readFileAsString(filePath: string): Promise<string>;
18
18
  static getFs(): Promise<any>;
19
+ static getPathModule(): any;
19
20
  static getParentDirPath(filePath: string): string;
20
21
  static getFilenameFromPath(filePath: string): string;
21
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BaseFileManager.d.ts","sourceRoot":"","sources":["../../../../src/helpers/FileManager/BaseFileManager.ts"],"names":[],"mappings":"AAAA,8BAAsB,eAAe;IACnC,OAAO,CAAC,MAAM,CAAC,qBAAqB,CAAQ;IAC5C,OAAO,CAAC,MAAM,CAAC,YAAY,CAAQ;IAEnC,MAAM,CAAC,aAAa,EAAE,OAAO,eAAe,CAAA;IAE5C,MAAM,CAAC,gBAAgB,CAAE,aAAa,EAAE,OAAO,eAAe;WAIjD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAUlD,MAAM,CAAC,qBAAqB,CAAE,IAAI,EAAE,MAAM,GAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIzE,MAAM,CAAC,gBAAgB,CAAE,EACE,cAAc,EACd,WAAW,EACX,oBAAoB,GACrB,EAAE,sBAAsB,GAAI,OAAO,CAAC,IAAI,CAAC;IAInE,MAAM,CAAC,WAAW,CAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,iBAAiB,GAAI,OAAO,CAAC,IAAI,CAAC;IAInF,MAAM,CAAC,eAAe,CAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,qBAAqB,GAAI,OAAO,CAAC,IAAI,CAAC;IAIjF,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrD,MAAM,CAAC,oBAAoB,CAAC,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E,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,iBAAiB,GAAI,OAAO,CAAC,IAAI,CAAC;IAInF,MAAM,CAAC,eAAe,CAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,qBAAqB,GAAI,OAAO,CAAC,IAAI,CAAC;IAIjF,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIrD,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAI/C,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAI/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;WAI/E,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAIzC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;WAI1D,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;WAInD,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC;IAIlC,MAAM,CAAC,aAAa,IAAI,GAAG;IAI3B,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIjD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAGrD"}
@@ -47,6 +47,9 @@ class BaseFileManager {
47
47
  static async getFs() {
48
48
  return this.PlatformClass.getFs();
49
49
  }
50
+ static getPathModule() {
51
+ return this.PlatformClass.getPathModule();
52
+ }
50
53
  static getParentDirPath(filePath) {
51
54
  return this.PlatformClass.getParentDirPath(filePath);
52
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BaseFileManager.js","sources":["../../../../../src/helpers/FileManager/BaseFileManager.ts"],"sourcesContent":["export abstract class BaseFileManager {\n private static fileSystemInitialized = false\n private static initializing = false\n\n static PlatformClass: typeof BaseFileManager\n\n static setPlatformClass( platformClass: typeof BaseFileManager ) {\n this.PlatformClass = platformClass\n }\n\n static async initializeFileSystem(): Promise<void> {\n if (this.initializing || this.fileSystemInitialized) {\n return Promise.resolve()\n }\n this.initializing = true\n await this.PlatformClass.initializeFileSystem()\n this.fileSystemInitialized = true\n this.initializing = false\n }\n\n static getContentUrlFromPath( path: string ): Promise<string | undefined> {\n return this.PlatformClass.getContentUrlFromPath(path)\n }\n\n static downloadAllFiles( {\n transactionIds,\n arweaveHost,\n excludedTransactions,\n }: DownloadAllFilesParams ): Promise<void> {\n return this.PlatformClass.downloadAllFiles({ transactionIds, arweaveHost, excludedTransactions })\n }\n\n static resizeImage( { filePath, width, height }: ResizeImageParams ): Promise<void> {\n return this.PlatformClass.resizeImage({ filePath, width, height })\n }\n\n static resizeAllImages( { width, height }: ResizeAllImagesParams ): Promise<void> {\n return this.PlatformClass.resizeAllImages({ width, height })\n }\n\n static pathExists(filePath: string): Promise<boolean> {\n return this.PlatformClass.pathExists(filePath)\n }\n\n static createDirIfNotExists(filePath: string): Promise<void> {\n return this.PlatformClass.createDirIfNotExists(filePath)\n }\n\n static async waitForFile(filePath: string): Promise<boolean> {\n return this.PlatformClass.waitForFile(filePath)\n }\n\n static async saveFile(filePath: string, content: string | Blob | ArrayBuffer): Promise<void> {\n return this.PlatformClass.saveFile(filePath, content)\n }\n\n static async readFile(filePath: string): Promise<File> {\n return this.PlatformClass.readFile(filePath)\n }\n\n static async readFileAsBuffer(filePath: string): Promise<Buffer> {\n return this.PlatformClass.readFileAsBuffer(filePath)\n }\n\n static async readFileAsString(filePath: string): Promise<string> {\n return this.PlatformClass.readFileAsString(filePath)\n }\n\n static async getFs(): Promise<any> {\n return this.PlatformClass.getFs()\n }\n\n static getParentDirPath(filePath: string): string {\n return this.PlatformClass.getParentDirPath(fil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,QAAQ,CAAC;;IAGhD,OAAO,oBAAoB,CAAC,QAAgB,EAAA;QAC1C,OAAO,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,QAAQ,CAAC;;AAG1D,IAAA,aAAa,WAAW,CAAC,QAAgB,EAAA;QACvC,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC;;AAGjD,IAAA,aAAa,QAAQ,CAAC,QAAgB,EAAE,OAAoC,EAAA;QAC1E,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;;AAGvD,IAAA,aAAa,QAAQ,CAAC,QAAgB,EAAA;QACpC,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;;AAG9C,IAAA,aAAa,gBAAgB,CAAC,QAAgB,EAAA;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC;;AAGtD,IAAA,aAAa,gBAAgB,CAAC,QAAgB,EAAA;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC;;IAGtD,aAAa,KAAK,GAAA;AAChB,QAAA,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;;IAGnC,OAAO,gBAAgB,CAAC,QAAgB,EAAA;QACtC,OAAO,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,QAAQ,CAAC;;IAGtD,OAAO,mBAAmB,CAAC,QAAgB,EAAA;QACzC,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,QAAQ,CAAC;;;AA5E1C,eAAqB,CAAA,qBAAA,GAAG,KAAK;AAC7B,eAAY,CAAA,YAAA,GAAG,KAAK;;;;"}
1
+ {"version":3,"file":"BaseFileManager.js","sources":["../../../../../src/helpers/FileManager/BaseFileManager.ts"],"sourcesContent":["export abstract class BaseFileManager {\n private static fileSystemInitialized = false\n private static initializing = false\n\n static PlatformClass: typeof BaseFileManager\n\n static setPlatformClass( platformClass: typeof BaseFileManager ) {\n this.PlatformClass = platformClass\n }\n\n static async initializeFileSystem(): Promise<void> {\n if (this.initializing || this.fileSystemInitialized) {\n return Promise.resolve()\n }\n this.initializing = true\n await this.PlatformClass.initializeFileSystem()\n this.fileSystemInitialized = true\n this.initializing = false\n }\n\n static getContentUrlFromPath( path: string ): Promise<string | undefined> {\n return this.PlatformClass.getContentUrlFromPath(path)\n }\n\n static downloadAllFiles( {\n transactionIds,\n arweaveHost,\n excludedTransactions,\n }: DownloadAllFilesParams ): Promise<void> {\n return this.PlatformClass.downloadAllFiles({ transactionIds, arweaveHost, excludedTransactions })\n }\n\n static resizeImage( { filePath, width, height }: ResizeImageParams ): Promise<void> {\n return this.PlatformClass.resizeImage({ filePath, width, height })\n }\n\n static resizeAllImages( { width, height }: ResizeAllImagesParams ): Promise<void> {\n return this.PlatformClass.resizeAllImages({ width, height })\n }\n\n static pathExists(filePath: string): Promise<boolean> {\n return this.PlatformClass.pathExists(filePath)\n }\n\n static createDirIfNotExists(filePath: string): Promise<void> {\n return this.PlatformClass.createDirIfNotExists(filePath)\n }\n\n static async waitForFile(filePath: string): Promise<boolean> {\n return this.PlatformClass.waitForFile(filePath)\n }\n\n static async saveFile(filePath: string, content: string | Blob | ArrayBuffer): Promise<void> {\n return this.PlatformClass.saveFile(filePath, content)\n }\n\n static async readFile(filePath: string): Promise<File> {\n return this.PlatformClass.readFile(filePath)\n }\n\n static async readFileAsBuffer(filePath: string): Promise<Buffer | Blob> {\n return this.PlatformClass.readFileAsBuffer(filePath)\n }\n\n static async readFileAsString(filePath: string): Promise<string> {\n return this.PlatformClass.readFileAsString(filePath)\n }\n\n static async getFs(): Promise<any> {\n return this.PlatformClass.getFs()\n }\n\n static getPathModule(): any {\n return this.PlatformClass.getPathModule()\n }\n\n static getParentDirPath(filePath: string): string {\n return this.PlatformClass.getParentDirPath(filePath)\n }\n\n static getFilenameFromPath(filePath: string): string {\n return this.PlatformClass.getFilenameFromPath(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ModelUidSchema.js';
7
+ import '../seedSchema/ConfigSchema.js';
7
8
  import { eq } from 'drizzle-orm';
8
9
  import { BaseDb } from '../db/Db/BaseDb.js';
9
10
 
@@ -1 +1 @@
1
- {"version":3,"file":"db.js","sources":["../../../../src/helpers/db.ts"],"sourcesContent":["import {\n appState,\n models as modelsTable,\n NewModelRecord,\n NewPropertyRecord,\n properties,\n} from '@/seedSchema'\nimport { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy'\nimport { DbQueryResult, ModelDefinitions, ResultObject } from '@/types'\nimport type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'\nimport { SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core'\nimport { and, eq, isNull, SQL } from 'drizzle-orm'\nimport { BaseDb } from '@/db/Db/BaseDb'\n\nexport const escapeSqliteString = (value: string): string => {\n if (typeof value !== 'string') {\n throw new Error(\n `Value must be a string, instead got: ${JSON.stringify(value)}`,\n )\n }\n return value.replace(/'/g, \"''\")\n}\nexport const getObjectForRow = (row: any): ResultObject => {\n const obj: ResultObject = {}\n\n row.columnNames.forEach((colName, index) => {\n const value = row.row[index]\n if (typeof value !== 'string') {\n obj[colName] = row.row[index]\n return\n }\n\n // Try to parse the value as JSON\n try {\n obj[colName] = JSON.parse(value)\n } catch (e) {\n // If it fails, just set the value as a string\n obj[colName] = value\n }\n })\n\n return obj\n}\nexport const getSqlResultObject = (\n queryResult: DbQueryResult,\n): ResultObject | ResultObject[] | undefined => {\n if (!queryResult || !queryResult.rows || queryResult.rows.length === 0) {\n return\n }\n\n let obj: ResultObject | ResultObject[] | undefined\n\n if (queryResult.rows.length === 1) {\n obj = getObjectForRow(queryResult.rows[0])\n }\n\n if (queryResult.rows.length > 1) {\n obj = queryResult.rows.reduce((acc, row) => {\n const rowObj = getObjectForRow(row)\n\n acc.push(rowObj)\n return acc\n }, [] as ResultObject[])\n }\n\n return obj\n}\nexport const createOrUpdate = async <T>(\n db: BetterSQLite3Database | SqliteRemoteDatabase,\n table: SQLiteTableWithColumns<any>,\n values: Partial<Record<keyof T, T[keyof T]>>,\n) => {\n const startTime = Date.now()\n\n const valueFilters: SQL[] = []\n\n const propertiesToExcludeFromDb = ['ref']\n\n const safeValues = Object.keys(values).reduce(\n (acc, key) => {\n if (!propertiesToExcludeFromDb.includes(key)) {\n acc[key] = values[key as string & keyof T]\n }\n return acc\n },\n {} as Record<string, unknown>,\n )\n\n for (const [key, value] of Object.entries(safeValues)) {\n let finalValue = value\n if (key === 'TObject') {\n continue\n }\n if (typeof value === 'object') {\n finalValue = JSON.stringify(value)\n }\n const column = table[key]\n if (!column) {\n throw new Error(`Column not found for ${key}`)\n }\n if (typeof finalValue === 'undefined') {\n finalValue = null\n }\n if (finalValue === null) {\n valueFilters.push(isNull(table[key]))\n continue\n }\n valueFilters.push(eq(table[key], finalValue))\n }\n\n const doneWithFilters = Date.now()\n\n // console.log('valueFilters:', valueFilters)\n\n // for ( const filter of valueFilters ) {\n // console.log('filter:', Object.keys(filter))\n // }\n\n // Build a query to find the record based on properties\n const existingRecords = await db\n .select()\n .from(table)\n .where(and(...valueFilters))\n\n const doneWithExistingRecords = Date.now()\n\n if (existingRecords.length > 1) {\n throw new Error('Multiple records found')\n }\n\n if (existingRecords.length > 0) {\n // If record exists, update it\n await db\n .update(table)\n .set(safeValues)\n .where(and(...valueFilters))\n\n const doneWithUpdate = Date.now()\n\n return existingRecords[0] as T\n } else {\n // If no record exists, create a new one\n const newRecord = await db.insert(table).values(safeValues).returning()\n return newRecord[0] as T\n }\n}\nexport const addModelsToInternalDb = async (\n db: BetterSQLite3Database<any> | SqliteRemoteDatabase<any>,\n models: ModelDefinitions,\n) => {\n for (const [modelName, modelClass] of Object.entries(models)) {\n const modelRecord = await createOrUpdate<NewModelRecord>(db, modelsTable, {\n name: modelName,\n })\n\n for (let [propertyName, propertyValues] of Object.entries(\n modelClass.schema,\n )) {\n if (!propertyValues) {\n throw new Error(`Property values not found for ${propertyName}`)\n }\n propertyValues.name = propertyName\n propertyValues.modelId = modelRecord.id!\n for (let [key, value] of Object.entries(propertyValues)) {\n if (key === 'ref') {\n const refModel = await createOrUpdate<NewModelRecord>(\n db,\n modelsTable,\n {\n name: value,\n },\n )\n // delete propertyValues.ref\n propertyValues.refModelId = refModel.id\n }\n }\n\n const propertyRecord = await createOrUpdate<NewPropertyRecord>(\n db,\n properties,\n propertyValues,\n )\n }\n }\n}\nexport const getAddressesFromDb = async (): Promise<string[]> => {\n const appDb = BaseDb.getAppDb()\n\n if (!appDb) {\n return new Promise((resolve) => {\n setTimeout(async () => {\n const addresses = await getAddressesFromDb()\n resolve(addresses)\n }, 500)\n })\n }\n\n const appStatesRecords = await appDb\n .select()\n .from(appState)\n .where(eq(appState.key, 'addresses'))\n .limit(1)\n\n if (!appStatesRecords || appStatesRecords.length === 0) {\n throw new Error('No appStatesRecords for addresses found')\n }\n\n const addressRecord = appStatesRecords[0]\n\n const addressArrayString = addressRecord.value\n\n if (!addressArrayString) {\n throw new Error('No addresses found')\n }\n\n return JSON.parse(addressArrayString)\n}\n"],"names":[],"mappings":";;;;;;;;;AAca,MAAA,kBAAkB,GAAG,CAAC,KAAa,KAAY;AAC1D,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,qCAAA,EAAwC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAE,CAAA,CAChE;;IAEH,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC;AAClC;AAoKa,MAAA,kBAAkB,GAAG,YAA8B;AAC9D,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE;IAE/B,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAI;YAC7B,UAAU,CAAC,YAAW;AACpB,gBAAA,MAAM,SAAS,GAAG,MAAM,kBAAkB,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC;aACnB,EAAE,GAAG,CAAC;AACT,SAAC,CAAC;;IAGJ,MAAM,gBAAgB,GAAG,MAAM;AAC5B,SAAA,MAAM;SACN,IAAI,CAAC,QAAQ;SACb,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;SACnC,KAAK,CAAC,CAAC,CAAC;IAEX,IAAI,CAAC,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE;AACtD,QAAA,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;;AAG5D,IAAA,MAAM,aAAa,GAAG,gBAAgB,CAAC,CAAC,CAAC;AAEzC,IAAA,MAAM,kBAAkB,GAAG,aAAa,CAAC,KAAK;IAE9C,IAAI,CAAC,kBAAkB,EAAE;AACvB,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC;;AAGvC,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC;AACvC;;;;"}
1
+ {"version":3,"file":"db.js","sources":["../../../../src/helpers/db.ts"],"sourcesContent":["import {\n appState,\n models as modelsTable,\n NewModelRecord,\n NewPropertyRecord,\n properties,\n} from '@/seedSchema'\nimport { SqliteRemoteDatabase } from 'drizzle-orm/sqlite-proxy'\nimport { DbQueryResult, ModelDefinitions, ResultObject } from '@/types'\nimport type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3'\nimport { SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core'\nimport { and, eq, isNull, SQL } from 'drizzle-orm'\nimport { BaseDb } from '@/db/Db/BaseDb'\n\nexport const escapeSqliteString = (value: string): string => {\n if (typeof value !== 'string') {\n throw new Error(\n `Value must be a string, instead got: ${JSON.stringify(value)}`,\n )\n }\n return value.replace(/'/g, \"''\")\n}\nexport const getObjectForRow = (row: any): ResultObject => {\n const obj: ResultObject = {}\n\n row.columnNames.forEach((colName, index) => {\n const value = row.row[index]\n if (typeof value !== 'string') {\n obj[colName] = row.row[index]\n return\n }\n\n // Try to parse the value as JSON\n try {\n obj[colName] = JSON.parse(value)\n } catch (e) {\n // If it fails, just set the value as a string\n obj[colName] = value\n }\n })\n\n return obj\n}\nexport const getSqlResultObject = (\n queryResult: DbQueryResult,\n): ResultObject | ResultObject[] | undefined => {\n if (!queryResult || !queryResult.rows || queryResult.rows.length === 0) {\n return\n }\n\n let obj: ResultObject | ResultObject[] | undefined\n\n if (queryResult.rows.length === 1) {\n obj = getObjectForRow(queryResult.rows[0])\n }\n\n if (queryResult.rows.length > 1) {\n obj = queryResult.rows.reduce((acc, row) => {\n const rowObj = getObjectForRow(row)\n\n acc.push(rowObj)\n return acc\n }, [] as ResultObject[])\n }\n\n return obj\n}\nexport const createOrUpdate = async <T>(\n db: BetterSQLite3Database | SqliteRemoteDatabase,\n table: SQLiteTableWithColumns<any>,\n values: Partial<Record<keyof T, T[keyof T]>>,\n) => {\n const startTime = Date.now()\n\n const valueFilters: SQL[] = []\n\n const propertiesToExcludeFromDb = ['ref']\n\n const safeValues = Object.keys(values).reduce(\n (acc, key) => {\n if (!propertiesToExcludeFromDb.includes(key)) {\n acc[key] = values[key as string & keyof T]\n }\n return acc\n },\n {} as Record<string, unknown>,\n )\n\n for (const [key, value] of Object.entries(safeValues)) {\n let finalValue = value\n if (key === 'TObject') {\n continue\n }\n if (typeof value === 'object') {\n finalValue = JSON.stringify(value)\n }\n const column = table[key]\n if (!column) {\n throw new Error(`Column not found for ${key}`)\n }\n if (typeof finalValue === 'undefined') {\n finalValue = null\n }\n if (finalValue === null) {\n valueFilters.push(isNull(table[key]))\n continue\n }\n valueFilters.push(eq(table[key], finalValue))\n }\n\n const doneWithFilters = Date.now()\n\n // console.log('valueFilters:', valueFilters)\n\n // for ( const filter of valueFilters ) {\n // console.log('filter:', Object.keys(filter))\n // }\n\n // Build a query to find the record based on properties\n const existingRecords = await db\n .select()\n .from(table)\n .where(and(...valueFilters))\n\n const doneWithExistingRecords = Date.now()\n\n if (existingRecords.length > 1) {\n throw new Error('Multiple records found')\n }\n\n if (existingRecords.length > 0) {\n // If record exists, update it\n await db\n .update(table)\n .set(safeValues)\n .where(and(...valueFilters))\n\n const doneWithUpdate = Date.now()\n\n return existingRecords[0] as T\n } else {\n // If no record exists, create a new one\n const newRecord = await db.insert(table).values(safeValues).returning()\n return newRecord[0] as T\n }\n}\nexport const addModelsToInternalDb = async (\n db: BetterSQLite3Database<any> | SqliteRemoteDatabase<any>,\n models: ModelDefinitions,\n) => {\n for (const [modelName, modelClass] of Object.entries(models)) {\n const modelRecord = await createOrUpdate<NewModelRecord>(db, modelsTable, {\n name: modelName,\n })\n\n for (let [propertyName, propertyValues] of Object.entries(\n modelClass.schema,\n )) {\n if (!propertyValues) {\n throw new Error(`Property values not found for ${propertyName}`)\n }\n propertyValues.name = propertyName\n propertyValues.modelId = modelRecord.id!\n for (let [key, value] of Object.entries(propertyValues)) {\n if (key === 'ref') {\n const refModel = await createOrUpdate<NewModelRecord>(\n db,\n modelsTable,\n {\n name: value,\n },\n )\n // delete propertyValues.ref\n propertyValues.refModelId = refModel.id\n }\n }\n\n const propertyRecord = await createOrUpdate<NewPropertyRecord>(\n db,\n properties,\n propertyValues,\n )\n }\n }\n}\nexport const getAddressesFromDb = async (): Promise<string[]> => {\n const appDb = BaseDb.getAppDb()\n\n if (!appDb) {\n return new Promise((resolve) => {\n setTimeout(async () => {\n const addresses = await getAddressesFromDb()\n resolve(addresses)\n }, 500)\n })\n }\n\n const appStatesRecords = await appDb\n .select()\n .from(appState)\n .where(eq(appState.key, 'addresses'))\n .limit(1)\n\n if (!appStatesRecords || appStatesRecords.length === 0) {\n throw new Error('No appStatesRecords for addresses found')\n }\n\n const addressRecord = appStatesRecords[0]\n\n const addressArrayString = addressRecord.value\n\n if (!addressArrayString) {\n throw new Error('No addresses found')\n }\n\n return JSON.parse(addressArrayString)\n}\n"],"names":[],"mappings":";;;;;;;;;;AAca,MAAA,kBAAkB,GAAG,CAAC,KAAa,KAAY;AAC1D,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AAC7B,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,qCAAA,EAAwC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAE,CAAA,CAChE;;IAEH,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC;AAClC;AAoKa,MAAA,kBAAkB,GAAG,YAA8B;AAC9D,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,EAAE;IAE/B,IAAI,CAAC,KAAK,EAAE;AACV,QAAA,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAI;YAC7B,UAAU,CAAC,YAAW;AACpB,gBAAA,MAAM,SAAS,GAAG,MAAM,kBAAkB,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC;aACnB,EAAE,GAAG,CAAC;AACT,SAAC,CAAC;;IAGJ,MAAM,gBAAgB,GAAG,MAAM;AAC5B,SAAA,MAAM;SACN,IAAI,CAAC,QAAQ;SACb,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;SACnC,KAAK,CAAC,CAAC,CAAC;IAEX,IAAI,CAAC,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE;AACtD,QAAA,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;;AAG5D,IAAA,MAAM,aAAa,GAAG,gBAAgB,CAAC,CAAC,CAAC;AAEzC,IAAA,MAAM,kBAAkB,GAAG,aAAa,CAAC,KAAK;IAE9C,IAAI,CAAC,kBAAkB,EAAE;AACvB,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC;;AAGvC,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC;AACvC;;;;"}
@@ -1,3 +1,8 @@
1
+ const isNode = () => {
2
+ return (typeof process !== 'undefined' &&
3
+ process.versions != null &&
4
+ process.versions.node != null);
5
+ };
1
6
  const isBrowser = () => {
2
7
  return !isElectron() && typeof document !== 'undefined' && typeof window !== 'undefined';
3
8
  };
@@ -20,5 +25,5 @@ const getEnvironment = () => {
20
25
  return 'node';
21
26
  };
22
27
 
23
- export { getEnvironment, isBrowser, isElectron, isReactNative };
28
+ export { getEnvironment, isBrowser, isElectron, isNode, isReactNative };
24
29
  //# sourceMappingURL=environment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","sources":["../../../../src/helpers/environment.ts"],"sourcesContent":["export const isNode = (): boolean => {\n return (\n typeof process !== 'undefined' &&\n process.versions != null &&\n process.versions.node != null\n )\n}\n\nexport const isBrowser = (): boolean => {\n return !isElectron() && typeof document !== 'undefined' && typeof window !== 'undefined'\n}\n\nexport const isReactNative = (): boolean => {\n return typeof navigator !== 'undefined' && navigator.product === 'ReactNative'\n}\n\nexport const isElectron = (): boolean => {\n return typeof process !== 'undefined' && process.versions != null && process.versions.electron != null;\n}\n\nexport const getEnvironment = (): string => {\n if (isBrowser()) {\n return 'browser'\n }\n\n if (isElectron()) {\n return 'electron'\n }\n\n if (isReactNative()) {\n return 'react-native'\n }\n\n return 'node'\n}\n"],"names":[],"mappings":"AAQO,MAAM,SAAS,GAAG,MAAc;AACrC,IAAA,OAAO,CAAC,UAAU,EAAE,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW;AAC1F;AAEO,MAAM,aAAa,GAAG,MAAc;IACzC,OAAO,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,OAAO,KAAK,aAAa;AAChF;AAEO,MAAM,UAAU,GAAG,MAAc;AACtC,IAAA,OAAO,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,IAAI,IAAI;AACxG;AAEO,MAAM,cAAc,GAAG,MAAa;IACzC,IAAI,SAAS,EAAE,EAAE;AACf,QAAA,OAAO,SAAS;;IAGlB,IAAI,UAAU,EAAE,EAAE;AAChB,QAAA,OAAO,UAAU;;IAGnB,IAAI,aAAa,EAAE,EAAE;AACnB,QAAA,OAAO,cAAc;;AAGvB,IAAA,OAAO,MAAM;AACf;;;;"}
1
+ {"version":3,"file":"environment.js","sources":["../../../../src/helpers/environment.ts"],"sourcesContent":["export const isNode = (): boolean => {\n return (\n typeof process !== 'undefined' &&\n process.versions != null &&\n process.versions.node != null\n )\n}\n\nexport const isBrowser = (): boolean => {\n return !isElectron() && typeof document !== 'undefined' && typeof window !== 'undefined'\n}\n\nexport const isReactNative = (): boolean => {\n return typeof navigator !== 'undefined' && navigator.product === 'ReactNative'\n}\n\nexport const isElectron = (): boolean => {\n return typeof process !== 'undefined' && process.versions != null && process.versions.electron != null;\n}\n\nexport const getEnvironment = (): string => {\n if (isBrowser()) {\n return 'browser'\n }\n\n if (isElectron()) {\n return 'electron'\n }\n\n if (isReactNative()) {\n return 'react-native'\n }\n\n return 'node'\n}\n"],"names":[],"mappings":"AAAO,MAAM,MAAM,GAAG,MAAc;AAClC,IAAA,QACE,OAAO,OAAO,KAAK,WAAW;QAC9B,OAAO,CAAC,QAAQ,IAAI,IAAI;AACxB,QAAA,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI;AAEjC;AAEO,MAAM,SAAS,GAAG,MAAc;AACrC,IAAA,OAAO,CAAC,UAAU,EAAE,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,MAAM,KAAK,WAAW;AAC1F;AAEO,MAAM,aAAa,GAAG,MAAc;IACzC,OAAO,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,OAAO,KAAK,aAAa;AAChF;AAEO,MAAM,UAAU,GAAG,MAAc;AACtC,IAAA,OAAO,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,QAAQ,IAAI,IAAI;AACxG;AAEO,MAAM,cAAc,GAAG,MAAa;IACzC,IAAI,SAAS,EAAE,EAAE;AACf,QAAA,OAAO,SAAS;;IAGlB,IAAI,UAAU,EAAE,EAAE;AAChB,QAAA,OAAO,UAAU;;IAGnB,IAAI,aAAa,EAAE,EAAE;AACnB,QAAA,OAAO,cAAc;;AAGvB,IAAA,OAAO,MAAM;AACf;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAG9C,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAM7C,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAA;AAED,eAAO,MAAM,WAAW,QAAS,MAAM,WAEtC,CAAA;AAED,eAAO,MAAM,cAAc,QAAS,MAAM,iEA2BzC,CAAA;AAED,eAAO,MAAM,WAAW,WAAY,MAAM,kBAWzC,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,YAe1B,CAAA;AAED,eAAO,MAAM,qBAAqB,SAC1B,MAAM,KACX,aAAa,GAAG,QAAQ,GAAG,KAAK,GAAG,IAwBrC,CAAA;AAED,eAAO,MAAM,kBAAkB,SACvB,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAc5B,CAAA;AAED,eAAO,MAAM,gBAAgB,2CAI5B,CAAA;AAED,eAAO,MAAM,qBAAqB,WAAY,MAAM,WACF,CAAA;AAElD,eAAO,MAAM,4BAA4B,oBAAqB,MAAM;;;;CAiBnE,CAAA;AAGD,eAAO,MAAM,QAAQ,gBAAiB,WAAW,KAAG,OAwBnD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAG9C,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,+BAA+B,CAAA;AAK7C,eAAO,MAAM,UAAU,QAAO,MAE7B,CAAA;AAED,eAAO,MAAM,WAAW,QAAS,MAAM,WAEtC,CAAA;AAED,eAAO,MAAM,cAAc,QAAS,MAAM,iEA2BzC,CAAA;AAED,eAAO,MAAM,WAAW,WAAY,MAAM,kBAWzC,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,YAe1B,CAAA;AAED,eAAO,MAAM,qBAAqB,SAC1B,MAAM,KACX,aAAa,GAAG,QAAQ,GAAG,KAAK,GAAG,IAwBrC,CAAA;AAED,eAAO,MAAM,kBAAkB,SACvB,MAAM,KACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAc5B,CAAA;AAED,eAAO,MAAM,gBAAgB,2CAI5B,CAAA;AAED,eAAO,MAAM,qBAAqB,WAAY,MAAM,WACF,CAAA;AAElD,eAAO,MAAM,4BAA4B,oBAAqB,MAAM;;;;CAiBnE,CAAA;AAGD,eAAO,MAAM,QAAQ,gBAAiB,WAAW,KAAG,OAwBnD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/helpers/index.ts"],"sourcesContent":["import { customAlphabet } from 'nanoid'\nimport * as nanoIdDictionary from 'nanoid-dictionary'\nimport debug from 'debug'\nimport { GetCorrectId } from '@/types/helpers'\nimport { GetCorrectIdReturn } from '@/types/helpers'\nimport { BaseFileManager } from './FileManager/BaseFileManager'\nexport * from './ArweaveClient/BaseArweaveClient'\nexport * from './EasClient/BaseEasClient'\nexport * from './QueryClient/BaseQueryClient'\nexport * from './FileManager/BaseFileManager'\nconst logger = debug('seedSdk:shared:helpers')\n\n\nconst { alphanumeric } = nanoIdDictionary\n\nexport const generateId = (): string => {\n return customAlphabet(alphanumeric, 10)()\n}\n\nexport const toSnakeCase = (str: string) => {\n return str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()\n}\n\nexport const identifyString = (str: string) => {\n try {\n JSON.parse(str)\n return 'json'\n } catch (e) {\n // Not JSON\n }\n\n if (!str) {\n return\n }\n\n if (str.trim().startsWith('<') && str.trim().endsWith('>')) {\n return 'html'\n }\n\n // Simple markdown checks (very naive)\n if (/^#{1,6}\\s|^-{3,}|\\*{3,}|^-{1,2}\\s|\\*\\s/.test(str)) {\n return 'markdown'\n }\n\n if (/^data:image\\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/.test(str)) {\n return 'base64'\n }\n\n // Default to plain text if unsure\n return 'text'\n}\n\nexport const getMimeType = (base64: string) => {\n if (!base64) {\n return null\n }\n const result = base64.match(/^data:([a-zA-Z0-9]+\\/[a-zA-Z0-9-.+]+).*,/)\n\n if (result && result.length > 1) {\n return result[1]\n } else {\n return null // MIME type could not be determined\n }\n}\n\nexport const getCorrectId: GetCorrectId = (localIdOrUid: string) => {\n const id: GetCorrectIdReturn = {\n localId: undefined,\n uid: undefined,\n }\n if (!localIdOrUid) {\n return id\n }\n if (localIdOrUid.length === 10) {\n id.localId = localIdOrUid\n }\n if (localIdOrUid.startsWith('0x') && localIdOrUid.length === 66) {\n id.uid = localIdOrUid\n }\n return id\n}\n\nexport const getDataTypeFromString = (\n data: string,\n): 'imageBase64' | 'base64' | 'url' | null => {\n const nonImageBase64Regex =\n /^(?!data:image\\/(?:jpeg|png|gif|bmp|webp);base64,)[A-Za-z0-9+/=]+$/\n\n if (nonImageBase64Regex.test(data)) {\n return 'base64'\n }\n\n // Regular expression for base64 (simple version, checking for base64 format)\n const imageBase64Regex = /^data:image\\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/\n\n if (imageBase64Regex.test(data)) {\n return 'imageBase64'\n }\n\n // Regular expression for URL (simple version, checking for common URL format)\n const urlRegex =\n /^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$/\n\n if (urlRegex.test(data)) {\n return 'url'\n }\n\n return null\n}\n\nexport const convertTxIdToImage = async (\n txId: string,\n): Promise<string | undefined> => {\n const imageFilePath = `/files/images/${txId}`\n const fileExists = await BaseFileManager.pathExists(imageFilePath)\n if (!fileExists) {\n logger(`[ItemView] [updateImage] ${imageFilePath} does not exist`)\n return\n }\n const buffer = await BaseFileManager.readFileAsBuffer(imageFilePath)\n\n const uint = new Uint8Array(buffer)\n\n const imageBlob = new Blob([uint])\n\n return URL.createObjectURL(imageBlob)\n}\n\nexport const getExecutionTime = async (task, args) => {\n const start = Date.now()\n await task(...args)\n return Date.now() - start\n}\n\nexport const capitalizeFirstLetter = (string: string) =>\n string.charAt(0).toUpperCase() + string.slice(1)\n\nexport const parseEasRelationPropertyName = (easPropertyName: string) => {\n // Split the input string on the first underscore\n const [singularProperty, modelName, idSegment] = easPropertyName.split('_')\n\n // If there are any other parts, assume it is a list (e.g., has 'ids' or other suffix)\n const isList = idSegment === 'ids'\n\n // Create the final property name by pluralizing the singular part\n const propertyName = singularProperty.endsWith('s')\n ? singularProperty\n : singularProperty + 's'\n\n return {\n propertyName, // Plural form of the property name\n modelName, // Model name extracted from the second part\n isList, // True if the property is a list (e.g., 'ids' is present)\n }\n}\n\n\nexport const isBinary = (arrayBuffer: ArrayBuffer): boolean => {\n const view = new Uint8Array(arrayBuffer);\n\n let nonTextCount = 0;\n const threshold = 0.2; // Adjust as needed (e.g., 20% non-text implies binary)\n\n for (let i = 0; i < view.length; i++) {\n const byte = view[i];\n\n // ASCII printable characters (32-126) and common whitespace (9, 10, 13)\n if (\n (byte >= 32 && byte <= 126) || // Printable ASCII\n byte === 9 || byte === 10 || byte === 13 // Tab, LF, CR\n ) {\n continue;\n }\n\n nonTextCount++;\n if (nonTextCount / view.length > threshold) {\n return true; // More than threshold are non-text bytes\n }\n }\n\n return false; // Fewer than threshold are non-text bytes\n}\n"],"names":[],"mappings":";;;;;;;AAUA,MAAM,MAAM,GAAG,KAAK,CAAC,wBAAwB,CAAC;AAG9C,MAAM,EAAE,YAAY,EAAE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from 'nanoid'\nimport * as nanoIdDictionary from 'nanoid-dictionary'\nimport debug from 'debug'\nimport { GetCorrectId } from '@/types/helpers'\nimport { GetCorrectIdReturn } from '@/types/helpers'\nimport { BaseFileManager } from './FileManager/BaseFileManager'\nexport * from './ArweaveClient/BaseArweaveClient'\nexport * from './EasClient/BaseEasClient'\nexport * from './QueryClient/BaseQueryClient'\nexport * from './FileManager/BaseFileManager'\nconst logger = debug('seedSdk:shared:helpers')\n\nconst { alphanumeric } = nanoIdDictionary\n\nexport const generateId = (): string => {\n return customAlphabet(alphanumeric, 10)()\n}\n\nexport const toSnakeCase = (str: string) => {\n return str.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()\n}\n\nexport const identifyString = (str: string) => {\n try {\n JSON.parse(str)\n return 'json'\n } catch (e) {\n // Not JSON\n }\n\n if (!str) {\n return\n }\n\n if (str.trim().startsWith('<') && str.trim().endsWith('>')) {\n return 'html'\n }\n\n // Simple markdown checks (very naive)\n if (/^#{1,6}\\s|^-{3,}|\\*{3,}|^-{1,2}\\s|\\*\\s/.test(str)) {\n return 'markdown'\n }\n\n if (/^data:image\\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/.test(str)) {\n return 'base64'\n }\n\n // Default to plain text if unsure\n return 'text'\n}\n\nexport const getMimeType = (base64: string) => {\n if (!base64) {\n return null\n }\n const result = base64.match(/^data:([a-zA-Z0-9]+\\/[a-zA-Z0-9-.+]+).*,/)\n\n if (result && result.length > 1) {\n return result[1]\n } else {\n return null // MIME type could not be determined\n }\n}\n\nexport const getCorrectId: GetCorrectId = (localIdOrUid: string) => {\n const id: GetCorrectIdReturn = {\n localId: undefined,\n uid: undefined,\n }\n if (!localIdOrUid) {\n return id\n }\n if (localIdOrUid.length === 10) {\n id.localId = localIdOrUid\n }\n if (localIdOrUid.startsWith('0x') && localIdOrUid.length === 66) {\n id.uid = localIdOrUid\n }\n return id\n}\n\nexport const getDataTypeFromString = (\n data: string,\n): 'imageBase64' | 'base64' | 'url' | null => {\n const nonImageBase64Regex =\n /^(?!data:image\\/(?:jpeg|png|gif|bmp|webp);base64,)[A-Za-z0-9+/=]+$/\n\n if (nonImageBase64Regex.test(data)) {\n return 'base64'\n }\n\n // Regular expression for base64 (simple version, checking for base64 format)\n const imageBase64Regex = /^data:image\\/[a-zA-Z]+;base64,[A-Za-z0-9+/]+={0,2}$/\n\n if (imageBase64Regex.test(data)) {\n return 'imageBase64'\n }\n\n // Regular expression for URL (simple version, checking for common URL format)\n const urlRegex =\n /^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$/\n\n if (urlRegex.test(data)) {\n return 'url'\n }\n\n return null\n}\n\nexport const convertTxIdToImage = async (\n txId: string,\n): Promise<string | undefined> => {\n const imageFilePath = `/files/images/${txId}`\n const fileExists = await BaseFileManager.pathExists(imageFilePath)\n if (!fileExists) {\n logger(`[ItemView] [updateImage] ${imageFilePath} does not exist`)\n return\n }\n const buffer = await BaseFileManager.readFileAsBuffer(imageFilePath)\n\n const uint = new Uint8Array(buffer)\n\n const imageBlob = new Blob([uint])\n\n return URL.createObjectURL(imageBlob)\n}\n\nexport const getExecutionTime = async (task, args) => {\n const start = Date.now()\n await task(...args)\n return Date.now() - start\n}\n\nexport const capitalizeFirstLetter = (string: string) =>\n string.charAt(0).toUpperCase() + string.slice(1)\n\nexport const parseEasRelationPropertyName = (easPropertyName: string) => {\n // Split the input string on the first underscore\n const [singularProperty, modelName, idSegment] = easPropertyName.split('_')\n\n // If there are any other parts, assume it is a list (e.g., has 'ids' or other suffix)\n const isList = idSegment === 'ids'\n\n // Create the final property name by pluralizing the singular part\n const propertyName = singularProperty.endsWith('s')\n ? singularProperty\n : singularProperty + 's'\n\n return {\n propertyName, // Plural form of the property name\n modelName, // Model name extracted from the second part\n isList, // True if the property is a list (e.g., 'ids' is present)\n }\n}\n\n\nexport const isBinary = (arrayBuffer: ArrayBuffer): boolean => {\n const view = new Uint8Array(arrayBuffer);\n\n let nonTextCount = 0;\n const threshold = 0.2; // Adjust as needed (e.g., 20% non-text implies binary)\n\n for (let i = 0; i < view.length; i++) {\n const byte = view[i];\n\n // ASCII printable characters (32-126) and common whitespace (9, 10, 13)\n if (\n (byte >= 32 && byte <= 126) || // Printable ASCII\n byte === 9 || byte === 10 || byte === 13 // Tab, LF, CR\n ) {\n continue;\n }\n\n nonTextCount++;\n if (nonTextCount / view.length > threshold) {\n return true; // More than threshold are non-text bytes\n }\n }\n\n return false; // Fewer than threshold are non-text bytes\n}\n"],"names":[],"mappings":";;;;;;;AAUA,MAAM,MAAM,GAAG,KAAK,CAAC,wBAAwB,CAAC;AAE9C,MAAM,EAAE,YAAY,EAAE,GAAG,gBAAgB;AAElC,MAAM,UAAU,GAAG,MAAa;AACrC,IAAA,OAAO,cAAc,CAAC,YAAY,EAAE,EAAE,CAAC,EAAE;AAC3C;AAEa,MAAA,WAAW,GAAG,CAAC,GAAW,KAAI;IACzC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE;AAC9D;AA+Ba,MAAA,WAAW,GAAG,CAAC,MAAc,KAAI;IAC5C,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,IAAI;;IAEb,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC;IAEvE,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;AAC/B,QAAA,OAAO,MAAM,CAAC,CAAC,CAAC;;SACX;QACL,OAAO,IAAI,CAAA;;AAEf;AAEa,MAAA,YAAY,GAAiB,CAAC,YAAoB,KAAI;AACjE,IAAA,MAAM,EAAE,GAAuB;AAC7B,QAAA,OAAO,EAAE,SAAS;AAClB,QAAA,GAAG,EAAE,SAAS;KACf;IACD,IAAI,CAAC,YAAY,EAAE;AACjB,QAA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,GAAG,CAAC,eAAe,CAAC,SAAS,CAAC;AACvC;AAWa,MAAA,4BAA4B,GAAG,CAAC,eAAuB,KAAI;;AAEtE,IAAA,MAAM,CAAC,gBAAgB,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC;;AAG3E,IAAA,MAAM,MAAM,GAAG,SAAS,KAAK,KAAK;;AAGlC,IAAA,MAAM,YAAY,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG;AAChD,UAAE;AACF,UAAE,gBAAgB,GAAG,GAAG;IAE1B,OAAO;AACL,QAAA,YAAY;AACZ,QAAA,SAAS;AACT,QAAA,MAAM;KACP;AACH;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { ActorRefFrom, Subscription } from 'xstate';
2
2
  import { ModelSchema, ModelValues, PropertyData } from '@/types';
3
- import { VersionsType } from '@/seedSchema/VersionSchema';
3
+ import { VersionsType } from '@/seedSchema';
4
4
  import { IItemProperty } from './IItemProperty';
5
5
  export interface IItem<T extends ModelValues<ModelSchema>> {
6
6
  subscribe(callback: (itemProps: any) => void): Subscription;
@@ -1 +1 @@
1
- {"version":3,"file":"IItem.d.ts","sourceRoot":"","sources":["../../../src/interfaces/IItem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C,MAAM,WAAW,KAAK,CAAC,CAAC,SAAS,WAAW,CAAC,WAAW,CAAC;IAEvD,SAAS,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,GAAG,KAAK,IAAI,GAAG,YAAY,CAAA;IAC3D,UAAU,IAAI,YAAY,CAAC,GAAG,CAAC,CAAA;IAC/B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AY,CAAA;IAC3D,UAAU,IAAI,YAAY,CAAC,GAAG,CAAC,CAAA;IAC/B,mBAAmB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;IAC9C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC,iBAAiB,CAAC,oBAAoB,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IAC5D,MAAM,IAAI,IAAI,CAAA;IAEd,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,YAAY,CAAA;IACvC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;IACvD,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAA;CACxC"}
@@ -0,0 +1,11 @@
1
+ import { BaseItem } from '../../Item/BaseItem.js';
2
+
3
+ class Item extends BaseItem {
4
+ constructor(initialValues) {
5
+ super(initialValues);
6
+ }
7
+ }
8
+ BaseItem.setPlatformClass(Item);
9
+
10
+ export { Item };
11
+ //# sourceMappingURL=Item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Item.js","sources":["../../../../../src/node/Item/Item.ts"],"sourcesContent":["import { IItem } from '@/interfaces';\nimport { BaseItem } from '@/Item/BaseItem';\nimport { ModelSchema, ModelValues, NewItemProps } from '@/types';\n\nexport class Item<T extends ModelValues<ModelSchema>> extends BaseItem<T> implements IItem<T> {\n constructor(initialValues: NewItemProps<T>) {\n super(initialValues);\n }\n\n}\n\nBaseItem.setPlatformClass(Item)"],"names":[],"mappings":";;AAIM,MAAO,IAAyC,SAAQ,QAAW,CAAA;AACvE,IAAA,WAAA,CAAY,aAA8B,EAAA;QACxC,KAAK,CAAC,aAAa,CAAC;;AAGvB;AAED,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC;;;;"}
@@ -0,0 +1,10 @@
1
+ import { BaseItemProperty } from '../../ItemProperty/BaseItemProperty.js';
2
+
3
+ class ItemProperty extends BaseItemProperty {
4
+ constructor(initialValues) {
5
+ super(initialValues);
6
+ }
7
+ }
8
+
9
+ export { ItemProperty };
10
+ //# sourceMappingURL=ItemProperty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ItemProperty.js","sources":["../../../../../src/node/ItemProperty/ItemProperty.ts"],"sourcesContent":["import { IItemProperty } from '@/interfaces'\nimport { BaseItemProperty } from '@/ItemProperty/BaseItemProperty'\nimport { CreatePropertyInstanceProps, ModelSchema, ModelValues, } from '@/types'\n\nexport class ItemProperty<PropertyType> extends BaseItemProperty<PropertyType> implements IItemProperty<PropertyType> {\n constructor(initialValues: Partial<CreatePropertyInstanceProps>) {\n super(initialValues)\n }\n}"],"names":[],"mappings":";;AAIM,MAAO,YAA2B,SAAQ,gBAA8B,CAAA;AAC5E,IAAA,WAAA,CAAY,aAAmD,EAAA;QAC7D,KAAK,CAAC,aAAa,CAAC;;AAEvB;;;;"}
@@ -8,7 +8,7 @@ import fs from 'fs';
8
8
  import { PathResolver } from '../PathResolver.js';
9
9
  import debug from 'debug';
10
10
 
11
- debug('seedSdk:codegen:drizzle');
11
+ const logger = debug('seedSdk:codegen:drizzle');
12
12
  const TemplateLoader = {
13
13
  getSource: (name) => {
14
14
  const pathResolver = PathResolver.getInstance();
@@ -68,6 +68,40 @@ const createDrizzleSchemaFilesFromConfig = async (configFilePath, outputDirPath)
68
68
  await fs.promises.writeFile(filePath, code).catch((e) => console.error(e));
69
69
  }
70
70
  };
71
+ // Helper to determine TypeScript type based on property type
72
+ const seedTypeToJsType = (propertyType) => {
73
+ switch (propertyType) {
74
+ case 'Text':
75
+ return 'string';
76
+ case 'Number':
77
+ return 'number';
78
+ case 'Boolean':
79
+ return 'boolean';
80
+ case 'Date':
81
+ return 'string';
82
+ case 'List':
83
+ return 'string[]';
84
+ case 'Relation':
85
+ return 'string';
86
+ case 'Image':
87
+ return 'string';
88
+ case 'File':
89
+ return 'string';
90
+ default:
91
+ return 'any';
92
+ }
93
+ };
94
+ const generateModelCode = (values) => {
95
+ const { modelName, properties } = values;
96
+ const pathResolver = PathResolver.getInstance();
97
+ const { templatePath } = pathResolver.getAppPaths();
98
+ if (modelName === 'Text' || modelName === 'TestModel') {
99
+ logger(`Model name is ${modelName}.`);
100
+ }
101
+ const njkEnv = new nunjucks.Environment(new nunjucks.FileSystemLoader(templatePath));
102
+ njkEnv.addFilter('seedTypeToJsType', seedTypeToJsType);
103
+ return njkEnv.render('model.njk', { modelName, properties });
104
+ };
71
105
 
72
- export { createDrizzleSchemaFilesFromConfig, generateDrizzleSchemaCode };
106
+ export { createDrizzleSchemaFilesFromConfig, generateDrizzleSchemaCode, generateModelCode };
73
107
  //# sourceMappingURL=drizzle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"drizzle.js","sources":["../../../../../src/node/codegen/drizzle.ts"],"sourcesContent":["import path from 'path'\nimport pluralize from 'pluralize'\nimport { camelCase, snakeCase } from 'lodash-es'\nimport * as nunjucks from 'nunjucks'\nimport { ILoader } from 'nunjucks'\nimport { ModelClassType } from '@/types'\nimport { SCHEMA_NJK } from '@/helpers/constants'\nimport { getTsImport } from '@/node/helpers'\nimport fs from 'fs'\nimport {PathResolver} from '@/node/PathResolver'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:codegen:drizzle')\n\n\nconst TemplateLoader: ILoader = {\n getSource: (name: string) => {\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n let templateFilePath = templatePath\n if (name.includes(templatePath)) {\n templateFilePath = name\n } else {\n templateFilePath = path.join(templatePath, path.basename(name))\n }\n const src = fs.readFileSync(templateFilePath, 'utf-8')\n\n return {\n path: name,\n src,\n noCache: false,\n }\n },\n}\n\n// Configure Nunjucks\nconst env = new nunjucks.Environment(TemplateLoader)\n\nenv.addFilter('camelCase', camelCase)\nenv.addFilter('snakeCase', snakeCase)\nenv.addFilter('pluralize', pluralize)\n\nconst refNamesToExcludeFromRelations = [\n 'Text',\n 'Number',\n 'Boolean',\n 'Date',\n]\n\nexport const generateDrizzleSchemaCode = (\n modelName: string,\n modelClass: ModelClassType,\n): string => {\n const listProperties = Object.entries(modelClass.schema).filter(\n ([key, propertyDef]) => propertyDef?.dataType === 'List' && !refNamesToExcludeFromRelations.includes(propertyDef?.ref!),\n )\n\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n const filePath = path.join(templatePath, SCHEMA_NJK)\n\n const schemaCode = env.render(filePath, {\n modelName,\n modelClass,\n listProperties,\n })\n\n return schemaCode\n}\n\nexport const createDrizzleSchemaFilesFromConfig = async (\n configFilePath: string | undefined,\n outputDirPath: string | undefined,\n) => {\n const pathResolver = PathResolver.getInstance()\n const { dotSeedDir, appSchemaDir } = pathResolver.getAppPaths()\n console.log('createDrizzleSchemaFilesFromConfig', configFilePath, outputDirPath)\n\n const schemaFilePath = configFilePath || path.join(dotSeedDir, 'schema.ts') // Developer created file with model definitions\n console.log('schemaFilePath', schemaFilePath)\n\n const { models, } = await getTsImport<{\n models: Record<string, ModelClassType>\n }>(schemaFilePath)\n\n const writeToDir = outputDirPath || appSchemaDir\n\n for (const [modelName, modelClass] of Object.entries(models)) {\n const code = generateDrizzleSchemaCode(modelName, modelClass)\n\n if (!fs.existsSync(writeToDir)) {\n fs.mkdirSync(writeToDir)\n }\n\n const filePath = path.join(writeToDir, `${modelName}Schema.ts`)\n\n await fs.promises.writeFile(filePath, code).catch((e) => console.error(e))\n }\n}\n\n // Helper to determine TypeScript type based on property type\n const seedTypeToJsType = (propertyType: string): string => {\n switch (propertyType) {\n case 'Text':\n return 'string';\n case 'Number':\n return 'number';\n case 'Boolean':\n return 'boolean';\n case 'Date':\n return 'string';\n case 'List':\n return 'string[]';\n case 'Relation':\n return 'string';\n case 'Image':\n return 'string';\n case 'File':\n return 'string';\n default:\n return 'any';\n }\n};\n\n\nexport const generateModelCode = (values: Record<string, any>): string => {\n const { modelName, properties } = values;\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n\n if (modelName === 'Text' || modelName === 'TestModel') {\n logger(`Model name is ${modelName}.`)\n }\n\n const njkEnv = new nunjucks.Environment(new nunjucks.FileSystemLoader(templatePath))\n njkEnv.addFilter('seedTypeToJsType', seedTypeToJsType)\n return njkEnv.render('model.njk', { modelName, properties })\n};\n"],"names":[],"mappings":";;;;;;;;;;AAYe,KAAK,CAAC,yBAAyB;AAG9C,MAAM,cAAc,GAAY;AAC9B,IAAA,SAAS,EAAE,CAAC,IAAY,KAAI;AAC1B,QAAA,MAAM,YAAY,GAAG,YAAY,CAAC,WAAW,EAAE;QAC/C,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC,WAAW,EAAE;QACnD,IAAI,gBAAgB,GAAG,YAAY;AACnC,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;YAC/B,gBAAgB,GAAG,IAAI;;aAClB;AACL,YAAA,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;;QAEjE,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC;QAEtD,OAAO;AACL,YAAA,IAAI,EAAE,IAAI;YACV,GAAG;AACH,YAAA,OAAO,EAAE,KAAK;SACf;KACF;CACF;AAED;AACA,MAAM,GAAG,GAAG,IAAI,Q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AU,EAAE,WAAW,CAAC,CAAA;AAC3E,IAAA,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,cAAc,CAAC;IAE7C,MAAM,EAAE,MAAM,GAAG,GAAG,MAAM,WAAW,CAElC,cAAc,CAAC;AAElB,IAAA,MAAM,UAAU,GAAoB,YAAY;AAEhD,IAAA,KAAK,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC5D,MAAM,IAAI,GAAG,yBAAyB,CAAC,SAAS,EAAE,UAAU,CAAC;QAE7D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;AAC9B,YAAA,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC;;AAG1B,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAG,EAAA,SAAS,CAAW,SAAA,CAAA,CAAC;QAE/D,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;;AAE9E;;;;"}
1
+ {"version":3,"file":"drizzle.js","sources":["../../../../../src/node/codegen/drizzle.ts"],"sourcesContent":["import path from 'path'\nimport pluralize from 'pluralize'\nimport { camelCase, snakeCase } from 'lodash-es'\nimport * as nunjucks from 'nunjucks'\nimport { ILoader } from 'nunjucks'\nimport { ModelClassType } from '@/types'\nimport { SCHEMA_NJK } from '@/helpers/constants'\nimport { getTsImport } from '@/node/helpers'\nimport fs from 'fs'\nimport {PathResolver} from '@/node/PathResolver'\nimport debug from 'debug'\n\nconst logger = debug('seedSdk:codegen:drizzle')\n\n\nconst TemplateLoader: ILoader = {\n getSource: (name: string) => {\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n let templateFilePath = templatePath\n if (name.includes(templatePath)) {\n templateFilePath = name\n } else {\n templateFilePath = path.join(templatePath, path.basename(name))\n }\n const src = fs.readFileSync(templateFilePath, 'utf-8')\n\n return {\n path: name,\n src,\n noCache: false,\n }\n },\n}\n\n// Configure Nunjucks\nconst env = new nunjucks.Environment(TemplateLoader)\n\nenv.addFilter('camelCase', camelCase)\nenv.addFilter('snakeCase', snakeCase)\nenv.addFilter('pluralize', pluralize)\n\nconst refNamesToExcludeFromRelations = [\n 'Text',\n 'Number',\n 'Boolean',\n 'Date',\n]\n\nexport const generateDrizzleSchemaCode = (\n modelName: string,\n modelClass: ModelClassType,\n): string => {\n const listProperties = Object.entries(modelClass.schema).filter(\n ([key, propertyDef]) => propertyDef?.dataType === 'List' && !refNamesToExcludeFromRelations.includes(propertyDef?.ref!),\n )\n\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n const filePath = path.join(templatePath, SCHEMA_NJK)\n\n const schemaCode = env.render(filePath, {\n modelName,\n modelClass,\n listProperties,\n })\n\n return schemaCode\n}\n\nexport const createDrizzleSchemaFilesFromConfig = async (\n configFilePath: string | undefined,\n outputDirPath: string | undefined,\n) => {\n const pathResolver = PathResolver.getInstance()\n const { dotSeedDir, appSchemaDir } = pathResolver.getAppPaths()\n console.log('createDrizzleSchemaFilesFromConfig', configFilePath, outputDirPath)\n\n const schemaFilePath = configFilePath || path.join(dotSeedDir, 'schema.ts') // Developer created file with model definitions\n console.log('schemaFilePath', schemaFilePath)\n\n const { models, } = await getTsImport<{\n models: Record<string, ModelClassType>\n }>(schemaFilePath)\n\n const writeToDir = outputDirPath || appSchemaDir\n\n for (const [modelName, modelClass] of Object.entries(models)) {\n const code = generateDrizzleSchemaCode(modelName, modelClass)\n\n if (!fs.existsSync(writeToDir)) {\n fs.mkdirSync(writeToDir)\n }\n\n const filePath = path.join(writeToDir, `${modelName}Schema.ts`)\n\n await fs.promises.writeFile(filePath, code).catch((e) => console.error(e))\n }\n}\n\n // Helper to determine TypeScript type based on property type\n const seedTypeToJsType = (propertyType: string): string => {\n switch (propertyType) {\n case 'Text':\n return 'string';\n case 'Number':\n return 'number';\n case 'Boolean':\n return 'boolean';\n case 'Date':\n return 'string';\n case 'List':\n return 'string[]';\n case 'Relation':\n return 'string';\n case 'Image':\n return 'string';\n case 'File':\n return 'string';\n default:\n return 'any';\n }\n};\n\n\nexport const generateModelCode = (values: Record<string, any>): string => {\n const { modelName, properties } = values;\n const pathResolver = PathResolver.getInstance()\n const { templatePath } = pathResolver.getAppPaths()\n\n if (modelName === 'Text' || modelName === 'TestModel') {\n logger(`Model name is ${modelName}.`)\n }\n\n const njkEnv = new nunjucks.Environment(new nunjucks.FileSystemLoader(templatePath))\n njkEnv.addFilter('seedTypeToJsType', seedTypeToJsType)\n return njkEnv.render('model.njk', { modelName, properties })\n};\n"],"names":[],"mappings":";;;;;;;;;;AAYA,MAAM,MAAM,GAAG,KAAK,CAAC,yBAAyB,CAAC;AAG/C,MAAM,cAAc,GAAY;AAC9B,IAAA,SAAS,EAAE,CAAC,IAAY,KAAI;AAC1B,QAAA,MAAM,YAAY,GAAG,YAAY,CAAC,WAAW,EAAE;QAC/C,MAAM,EAAE,YAAY,EAAE,GAAG,YAAY,CAAC,WAAW,EAAE;QACnD,IAAI,gBAAgB,GAAG,YAAY;AACnC,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE;YAC/B,gBAAgB,GAAG,IAAI;;aAClB;AACL,YAAA,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;;QAEjE,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC;QAEtD,OAAO;AACL,YAAA,IAAI,EAAE,IAAI;YACV,GAAG;AACH,YAAA,OAAO,EAAE,KAAK;SACf;KACF;CACF;AAED;AACA,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,cAAc,CAAC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src/node/db/Db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAc,gBAAgB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAiB,cAAc,CAAC;AA0B9C,cAAM,EAAG,SAAQ,MAAO,YAAW,GAAG;IACpC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAA;;IAMd,MAAM,CAAC,QAAQ;IAIf,MAAM,CAAC,YAAY;WAIN,SAAS,CAAC,QAAQ,EAAE,MAAM;WAiB1B,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;WAO7C,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAQvE;AAID,OAAO,EAAE,EAAE,EAAE,CAAA"}
@@ -0,0 +1,64 @@
1
+ import { BaseDb } from '../../db/Db/BaseDb.js';
2
+ import path from 'path';
3
+ import debug from 'debug';
4
+ import '../../seedSchema/SeedSchema.js';
5
+ import '../../seedSchema/VersionSchema.js';
6
+ import '../../seedSchema/MetadataSchema.js';
7
+ import { appState } from '../../seedSchema/AppStateSchema.js';
8
+ import '../../seedSchema/ModelSchema.js';
9
+ import '../../seedSchema/ModelUidSchema.js';
10
+ import '../../seedSchema/ConfigSchema.js';
11
+
12
+ const logger = debug('seedSdk:node:db:Db');
13
+ const getConfig = async (dotSeedDir) => {
14
+ const { defineConfig } = await import('drizzle-kit');
15
+ let schemaDir = path.join(process.cwd(), 'schema');
16
+ const nodeDbConfig = defineConfig({
17
+ schema: schemaDir,
18
+ dialect: 'sqlite',
19
+ out: `${dotSeedDir}/db`,
20
+ dbCredentials: {
21
+ url: `${dotSeedDir}/db/app_db.sqlite3`,
22
+ }
23
+ });
24
+ return nodeDbConfig;
25
+ };
26
+ class Db extends BaseDb {
27
+ constructor() {
28
+ super();
29
+ }
30
+ static getAppDb() {
31
+ return this.db;
32
+ }
33
+ static isAppDbReady() {
34
+ return true;
35
+ }
36
+ static async prepareDb(filesDir) {
37
+ const nodeDbConfig = await getConfig(filesDir);
38
+ const { drizzle } = await import('drizzle-orm/better-sqlite3');
39
+ this.db = drizzle({
40
+ ...nodeDbConfig,
41
+ logger: true,
42
+ });
43
+ if (!this.db) {
44
+ throw new Error('Db not found');
45
+ }
46
+ return this.db;
47
+ }
48
+ static async connectToDb(pathToDir, dbName) {
49
+ return {
50
+ id: this.db ? this.db.constructor.name : ''
51
+ };
52
+ }
53
+ static async migrate(pathToDbDir, dbName, dbId) {
54
+ const { migrate } = await import('drizzle-orm/better-sqlite3/migrator');
55
+ migrate(this.db, { migrationsFolder: pathToDbDir });
56
+ const queryResult = await this.db.select().from(appState);
57
+ logger('queryResult', queryResult);
58
+ return this.db;
59
+ }
60
+ }
61
+ BaseDb.setPlatformClass(Db);
62
+
63
+ export { Db };
64
+ //# sourceMappingURL=Db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Db.js","sources":["../../../../../src/node/db/Db.ts"],"sourcesContent":["import { BaseDb } from \"@/db/Db/BaseDb\";\nimport { IDb } from \"@/interfaces\";\nimport path from \"path\";\nimport { DrizzleConfig, } from \"drizzle-orm\";\nimport debug from 'debug'\nimport { appState } from '@/seedSchema'\n\nconst logger = debug('seedSdk:node:db:Db')\n\nconst getConfig = async (dotSeedDir: string) => {\n\n const { defineConfig } = await import('drizzle-kit')\n\n let schemaDir = path.join(process.cwd(), 'schema')\n\n const nodeDbConfig = defineConfig({\n schema: schemaDir,\n dialect: 'sqlite',\n out: `${dotSeedDir}/db`,\n dbCredentials: {\n url: `${dotSeedDir}/db/app_db.sqlite3`,\n }\n }) as DrizzleConfig & { dbCredentials: { url: string } }\n\n return nodeDbConfig\n}\n\nclass Db extends BaseDb implements IDb {\n static db: any\n\n constructor() {\n super()\n }\n\n static getAppDb() {\n return this.db\n }\n\n static isAppDbReady() {\n return true\n }\n\n static async prepareDb(filesDir: string) {\n const nodeDbConfig = await getConfig(filesDir)\n\n const {drizzle} = await import('drizzle-orm/better-sqlite3')\n\n this.db = drizzle({\n ...nodeDbConfig,\n logger: true,\n })\n\n if (!this.db) {\n throw new Error('Db not found')\n }\n\n return this.db\n }\n\n static async connectToDb(pathToDir: string, dbName: string) {\n\n return {\n id: this.db ? this.db.constructor.name : ''\n }\n }\n\n static async migrate(pathToDbDir: string, dbName: string, dbId: string) {\n const {migrate} = await import('drizzle-orm/better-sqlite3/migrator')\n migrate(this.db, { migrationsFolder: pathToDbDir })\n const queryResult = await this.db.select().from(appState)\n logger('queryResult', queryResult)\n\n return this.db\n }\n}\n\nBaseDb.setPlatformClass(Db)\n\nexport { Db }\n"],"names":[],"mappings":";;;;;;;;;;;AAOA,MAAM,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC;AAE1C,MAAM,SAAS,GAAG,OAAO,UAAkB,KAAI;IAE7C,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,OAAO,aAAa,CAAC;AAEpD,IAAA,IAAI,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC;IAElD,MAAM,YAAY,GAAG,YAAY,CAAC;AAChC,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,OAAO,EAAE,QAAQ;QACjB,GAAG,EAAE,CAAG,EAAA,UAAU,CAAK,GAAA,CAAA;AACvB,QAAA,aAAa,EAAE;YACb,GAAG,EAAE,CAAG,EAAA,UAAU,CAAoB,kBAAA,CAAA;AACvC;AACF,KAAA,CAAuD;AAExD,IAAA,OAAO,YAAY;AACrB,CAAC;AAED,MAAM,EAAG,SAAQ,MAAM,CAAA;AAGrB,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE;;AAGT,IAAA,OAAO,QAAQ,GAAA;QACb,OAAO,IAAI,CAAC,EAAE;;AAGhB,IAAA,OAAO,YAAY,GAAA;AACjB,QAAA,OAAO,IAAI;;AAGb,IAAA,aAAa,SAAS,CAAC,QAAgB,EAAA;AACrC,QAAA,MAAM,YAAY,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC;QAE9C,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM,OAAO,4BAA4B,CAAC;AAE5D,QAAA,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC;AAChB,YAAA,GAAG,YAAY;AACf,YAAA,MAAM,EAAE,IAAI;AACb,SAAA,CAAC;AAEF,QAAA,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE;AACZ,YAAA,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC;;QAGjC,OAAO,IAAI,CAAC,EAAE;;AAGhB,IAAA,aAAa,WAAW,CAAC,SAAiB,EAAE,MAAc,EAAA;QAExD,OAAO;AACL,YAAA,EAAE,EAAE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,GAAG;SAC1C;;IAGH,aAAa,OAAO,CAAC,WAAmB,EAAE,MAAc,EAAE,IAAY,EAAA;QACpE,MAAM,EAAC,OAAO,EAAC,GAAG,MAAM,OAAO,qCAAqC,CAAC;QACrE,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC;AACnD,QAAA,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;AACzD,QAAA,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC;QAElC,OAAO,IAAI,CAAC,EAAE;;AAEjB;AAED,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC;;;;"}
@@ -11,6 +11,7 @@ declare class FileManager extends BaseFileManager {
11
11
  static readFile(filePath: string): Promise<File>;
12
12
  static getParentDirPath(filePath: string): string;
13
13
  static getFilenameFromPath(filePath: string): string;
14
+ static getPathModule(): any;
14
15
  }
15
16
  export { FileManager };
16
17
  //# sourceMappingURL=FileManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileManager.d.ts","sourceRoot":"","sources":["../../../../src/node/hel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AC,IAAI,CAAC;WAMhC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAI9C,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAIrD,gBAAgB,CAAE,QAAQ,EAAE,MAAM,GAAI,OAAO,CAAC,MAAM,CAAC;WAIrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIjD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAIpD,MAAM,CAAC,aAAa,IAAI,GAAG;CAG5B;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -0,0 +1,53 @@
1
+ import * as fsAsync from 'fs/promises';
2
+ import { BaseFileManager } from '../../helpers/FileManager/BaseFileManager.js';
3
+ import path from 'path';
4
+
5
+ class FileManager extends BaseFileManager {
6
+ static async getContentUrlFromPath(path) {
7
+ return new Promise((resolve, reject) => {
8
+ reject(new Error('Not implemented'));
9
+ });
10
+ }
11
+ static async initializeFileSystem() {
12
+ return; // No need to initialize file system in node
13
+ }
14
+ static async downloadAllFiles() {
15
+ return new Promise((resolve, reject) => {
16
+ reject(new Error('Not implemented'));
17
+ });
18
+ }
19
+ static async resizeImage() {
20
+ return new Promise((resolve, reject) => {
21
+ reject(new Error('Not implemented'));
22
+ });
23
+ }
24
+ static async resizeAllImages() {
25
+ return new Promise((resolve, reject) => {
26
+ reject(new Error('Not implemented'));
27
+ });
28
+ }
29
+ static async pathExists(filePath) {
30
+ return await fsAsync.access(filePath).then(() => true).catch(() => false);
31
+ }
32
+ static async createDirIfNotExists(filePath) {
33
+ await fsAsync.mkdir(filePath, { recursive: true });
34
+ }
35
+ static async readFileAsBuffer(filePath) {
36
+ return await fsAsync.readFile(filePath);
37
+ }
38
+ static async readFile(filePath) {
39
+ return new File([await fsAsync.readFile(filePath)], filePath);
40
+ }
41
+ static getParentDirPath(filePath) {
42
+ return path.dirname(filePath);
43
+ }
44
+ static getFilenameFromPath(filePath) {
45
+ return path.basename(filePath);
46
+ }
47
+ static getPathModule() {
48
+ return path;
49
+ }
50
+ }
51
+
52
+ export { FileManager };
53
+ //# sourceMappingURL=FileManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileManager.js","sources":["../../../../../src/node/helpers/FileManager.ts"],"sourcesContent":["import * as fsAsync from 'fs/promises'\nimport { BaseFileManager } from '@/helpers/FileManager/BaseFileManager'\nimport path from 'path'\n\nclass FileManager extends BaseFileManager {\n\n static async getContentUrlFromPath( path: string ): Promise<string | undefined> {\n return new Promise(( resolve, reject ) => {\n reject(new Error('Not implemented'))\n })\n }\n\n static async initializeFileSystem(): Promise<void> {\n return // No need to initialize file system in node\n }\n\n static async downloadAllFiles(): Promise<void> {\n return new Promise(( resolve, reject ) => {\n reject(new Error('Not implemented'))\n })\n }\n\n static async resizeImage(): Promise<void> {\n return new Promise(( resolve, reject ) => {\n reject(new Error('Not implemented'))\n })\n }\n\n static async resizeAllImages(): Promise<void> {\n return new Promise(( resolve, reject ) => {\n reject(new Error('Not implemented'))\n })\n }\n\n static async pathExists(filePath: string): Promise<boolean> {\n return await fsAsync.access(filePath).then(() => true).catch(() => false)\n }\n\n static async createDirIfNotExists(filePath: string): Promise<void> {\n await fsAsync.mkdir(filePath, { recursive: true })\n }\n\n static async readFileAsBuffer( filePath: string ): Promise<Buffer> {\n return await fsAsync.readFile(filePath)\n }\n\n static async readFile(filePath: string): Promise<File> {\n return new File([await fsAsync.readFile(filePath)], filePath)\n }\n\n static getParentDirPath(filePath: string): string {\n return path.dirname(filePath)\n }\n\n static getFilenameFromPath(filePath: string): string {\n return path.basename(filePath)\n }\n\n static getPathModule(): any {\n return path\n }\n}\n\nexport { FileManager }\n\n"],"names":[],"mappings":";;;;AAIA,MAAM,WAAY,SAAQ,eAAe,CAAA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IAAI,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC;;IAG/D,OAAO,gBAAgB,CAAC,QAAgB,EAAA;AACtC,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;;IAG/B,OAAO,mBAAmB,CAAC,QAAgB,EAAA;AACzC,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;;AAGhC,IAAA,OAAO,aAAa,GAAA;AAClB,QAAA,OAAO,IAAI;;AAEd;;;;"}
@@ -1,3 +1,4 @@
1
+ import { InferSelectModel } from 'drizzle-orm';
1
2
  export declare const appState: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
2
3
  name: "appState";
3
4
  schema: undefined;
@@ -77,5 +78,5 @@ export declare const appState: import("drizzle-orm/sqlite-core").SQLiteTableWith
77
78
  };
78
79
  dialect: "sqlite";
79
80
  }>;
80
- export type appStateType = appState.$inferSelect;
81
+ export type appStateType = InferSelectModel<typeof appState>;
81
82
  //# sourceMappingURL=AppStateSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppStateSchema.d.ts","sourceRoot":"","sources":["../../../src/seedSchema/AppStateSchema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKnB,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAA"}
1
+ {"version":3,"file":"AppStateSchema.d.ts","sourceRoot":"","sources":["../../../src/seedSchema/AppStateSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKnB,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,QAAQ,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"AppStateSchema.js","sources":["../../../../src/seedSchema/AppStateSchema.ts"],"sourcesContent":["import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'\n\nexport const appState = sqliteTable('appState', {\n key: text('key').unique(),\n value: text('value'),\n createdAt: int('created_at'),\n updatedAt: int('updated_at'),\n})\n\nexport type appStateType = appState.$inferSelect\n"],"names":[],"mappings":";;AAEa,MAAA,QAAQ,GAAG,WAAW,CAAC,UAAU,EAAE;AAC9C,IAAA,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE;AACzB,IAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC;AACpB,IAAA,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC;AAC5B,IAAA,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC;AAC7B,CAAA;;;;"}
1
+ {"version":3,"file":"AppStateSchema.js","sources":["../../../../src/seedSchema/AppStateSchema.ts"],"sourcesContent":["import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'\nimport { InferSelectModel } from 'drizzle-orm'\nexport const appState = sqliteTable('appState', {\n key: text('key').unique(),\n value: text('value'),\n createdAt: int('created_at'),\n updatedAt: int('updated_at'),\n})\n\nexport type appStateType = InferSelectModel<typeof appState>\n"],"names":[],"mappings":";;AAEa,MAAA,QAAQ,GAAG,WAAW,CAAC,UAAU,EAAE;AAC9C,IAAA,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE;AACzB,IAAA,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC;AACpB,IAAA,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC;AAC5B,IAAA,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC;AAC7B,CAAA;;;;"}
@@ -1,3 +1,4 @@
1
+ import { InferSelectModel } from 'drizzle-orm';
1
2
  export declare const config: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
2
3
  name: "config";
3
4
  schema: undefined;
@@ -94,4 +95,5 @@ export declare const config: import("drizzle-orm/sqlite-core").SQLiteTableWithCo
94
95
  };
95
96
  dialect: "sqlite";
96
97
  }>;
98
+ export type configType = InferSelectModel<typeof config>;
97
99
  //# sourceMappingURL=ConfigSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigSchema.d.ts","sourceRoot":"","sources":["../../../src/seedSchema/ConfigSchema.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWjB,CAAA"}
1
+ {"version":3,"file":"ConfigSchema.d.ts","sourceRoot":"","sources":["../../../src/seedSchema/ConfigSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAO,MAAM,aAAa,CAAA;AAEnD,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAajB,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,MAAM,CAAC,CAAA"}
@@ -1,18 +1,15 @@
1
1
  import { sqliteTable, blob, text, int, check } from 'drizzle-orm/sqlite-core';
2
2
  import { sql } from 'drizzle-orm';
3
3
 
4
- const config = sqliteTable('config', {
4
+ sqliteTable('config', {
5
5
  id: int('id').primaryKey({ autoIncrement: true }),
6
6
  key: text('key').notNull(),
7
7
  text: text('text'),
8
8
  json: text('json', { mode: 'json' }),
9
9
  blob: blob('blob', { mode: 'buffer' }),
10
- }, () => {
11
- return {
12
- // Add a custom check constraint
13
- atLeastOneNotNull: check('hasValue', sql `key IS NOT NULL OR text IS NOT NULL OR json IS NOT NULL OR blob IS NOT NULL`),
14
- };
10
+ }, {
11
+ checks: [
12
+ check('hasValue', sql `key IS NOT NULL OR text IS NOT NULL OR json IS NOT NULL OR blob IS NOT NULL`),
13
+ ],
15
14
  });
16
-
17
- export { config };
18
15
  //# sourceMappingURL=ConfigSchema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigSchema.js","sources":["../../../../src/seedSchema/ConfigSchema.ts"],"sourcesContent":["import { blob, int, sqliteTable, text, check, } from 'drizzle-orm/sqlite-core'\nimport { sql } from 'drizzle-orm'\n\nexport const config = sqliteTable('config', {\n id: int('id').primaryKey({ autoIncrement: true }),\n key: text('key').notNull(),\n text: text('text'),\n json: text('json', {mode: 'json'}),\n blob: blob('blob', {mode: 'buffer'}),\n}, () => {\n return {\n // Add a custom check constraint\n atLeastOneNotNull: check('hasValue', sql`key IS NOT NULL OR text IS NOT NULL OR json IS NOT NULL OR blob IS NOT NULL`),\n }\n})"],"names":[],"mappings":";;;AAGa,MAAA,MAAM,GAAG,WAAW,CAAC,QAAQ,EAAE;AAC1C,IAAA,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AACjD,IAAA,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE;AAC1B,IAAA,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;AACrC,CAAA,EAAE,MAAK;IACN,OAAO;;QAEL,iBAAiB,EAAE,KAAK,CAAC,UAAU,EAAE,GAAG,CAAA,6EAA6E,CAAC;KACvH;AACH,CAAC;;;;"}
1
+ {"version":3,"file":"ConfigSchema.js","sources":["../../../../src/seedSchema/ConfigSchema.ts"],"sourcesContent":["import { int, sqliteTable, text, check, blob, } from 'drizzle-orm/sqlite-core'\nimport { InferSelectModel, sql } from 'drizzle-orm'\n\nexport const config = sqliteTable(\n 'config',\n {\n id: int('id').primaryKey({ autoIncrement: true }),\n key: text('key').notNull(),\n text: text('text'),\n json: text('json', {mode: 'json'}),\n blob: blob('blob', {mode: 'buffer'}),\n},\n{\n checks: [\n check('hasValue', sql`key IS NOT NULL OR text IS NOT NULL OR json IS NOT NULL OR blob IS NOT NULL`),\n ],\n})\n\nexport type configType = InferSelectModel<typeof config>"],"names":[],"mappings":";;;AAGsB,WAAW,CAC/B,QAAQ,EACR;AACE,IAAA,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AACjD,IAAA,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE;AAC1B,IAAA,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;IAClC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC;CACvC,EACD;AACE,IAAA,MAAM,EAAE;AACN,QAAA,KAAK,CAAC,UAAU,EAAE,GAAG,CAAA,6EAA6E,CAAC;AACpG,KAAA;AACF,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { InferSelectModel } from 'drizzle-orm';
1
2
  export declare const metadata: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
2
3
  name: "metadata";
3
4
  schema: undefined;
@@ -417,5 +418,5 @@ export declare const metadata: import("drizzle-orm/sqlite-core").SQLiteTableWith
417
418
  };
418
419
  dialect: "sqlite";
419
420
  }>;
420
- export type MetadataType = metadata.$inferSelect;
421
+ export type MetadataType = InferSelectModel<typeof metadata>;
421
422
  //# sourceMappingURL=MetadataSchema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetadataSchema.d.ts","sourceRoot":"","sources":["../../../src/seedSchema/MetadataSchema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBnB,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAA"}
1
+ {"version":3,"file":"MetadataSchema.d.ts","sourceRoot":"","sources":["../../../src/seedSchema/MetadataSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBnB,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,QAAQ,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"MetadataSchema.js","sources":["../../../../src/seedSchema/MetadataSchema.ts"],"sourcesContent":["import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'\n\nexport const metadata = sqliteTable('metadata', {\n localId: text('local_id').unique(),\n uid: text('uid'),\n propertyName: text('property_name'),\n propertyValue: text('property_value'),\n schemaUid: text('schema_uid'),\n modelType: text('model_type'),\n seedLocalId: text('seed_local_id'),\n seedUid: text('seed_uid'),\n versionLocalId: text('version_local_id'),\n versionUid: text('version_uid'),\n easDataType: text('eas_data_type'),\n refValueType: text('ref_value_type'),\n refModelUid: text('ref_schema_uid'),\n refSeedType: text('ref_seed_type'),\n refResolvedValue: text('ref_resolved_value'),\n refResolvedDisplayValue: text('ref_resolved_display_value'),\n localStorageDir: text('local_storage_dir'),\n attestationRaw: text('attestation_raw'),\n attestationCreatedAt: int('attestation_created_at'),\n contentHash: text('content_hash'),\n createdAt: int('created_at'),\n updatedAt: int('updated_at'),\n})\n\nexport type MetadataType = metadata.$inferSelect\n"],"names":[],"mappings":";;AAEa,MAAA,QAAQ,GAAG,WAAW,CAAC,UAAU,EAAE;AAC9C,IAAA,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;AAClC,IAAA,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC;AAChB,IAAA,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC;AACnC,IAAA,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC;AACrC,IAAA,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;AAC7B,IAAA,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;AAC7B,IAAA,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC;AAClC,IAAA,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;AACzB,IAAA,cAAc,EAAE,IAAI,CAAC,kBAAkB,CAAC;AACxC,IAAA,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC;AAC/B,IAAA,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC;AAClC,IAAA,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC;AACpC,IAAA,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC;AACnC,IAAA,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC;AAClC,IAAA,gBAAgB,EAAE,IAAI,CAAC,oBAAoB,CAAC;AAC5C,IAAA,uBAAuB,EAAE,IAAI,CAAC,4BAA4B,CAAC;AAC3D,IAAA,eAAe,EAAE,IAAI,CAAC,mBAAmB,CAAC;AAC1C,IAAA,cAAc,EAAE,IAAI,CAAC,iBAAiB,CAAC;AACvC,IAAA,oBAAoB,EAAE,GAAG,CAAC,wBAAwB,CAAC;AACnD,IAAA,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC;AACjC,IAAA,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC;AAC5B,IAAA,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC;AAC7B,CAAA;;;;"}
1
+ {"version":3,"file":"MetadataSchema.js","sources":["../../../../src/seedSchema/MetadataSchema.ts"],"sourcesContent":["import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core'\nimport { InferSelectModel } from 'drizzle-orm'\n\nexport const metadata = sqliteTable('metadata', {\n localId: text('local_id').unique(),\n uid: text('uid'),\n propertyName: text('property_name'),\n propertyValue: text('property_value'),\n schemaUid: text('schema_uid'),\n modelType: text('model_type'),\n seedLocalId: text('seed_local_id'),\n seedUid: text('seed_uid'),\n versionLocalId: text('version_local_id'),\n versionUid: text('version_uid'),\n easDataType: text('eas_data_type'),\n refValueType: text('ref_value_type'),\n refModelUid: text('ref_schema_uid'),\n refSeedType: text('ref_seed_type'),\n refResolvedValue: text('ref_resolved_value'),\n refResolvedDisplayValue: text('ref_resolved_display_value'),\n localStorageDir: text('local_storage_dir'),\n attestationRaw: text('attestation_raw'),\n attestationCreatedAt: int('attestation_created_at'),\n contentHash: text('content_hash'),\n createdAt: int('created_at'),\n updatedAt: int('updated_at'),\n})\n\nexport type MetadataType = InferSelectModel<typeof metadata>\n"],"names":[],"mappings":";;AAGa,MAAA,QAAQ,GAAG,WAAW,CAAC,UAAU,EAAE;AAC9C,IAAA,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;AAClC,IAAA,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC;AAChB,IAAA,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC;AACnC,IAAA,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC;AACrC,IAAA,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;AAC7B,IAAA,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC;AAC7B,IAAA,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC;AAClC,IAAA,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;AACzB,IAAA,cAAc,EAAE,IAAI,CAAC,kBAAkB,CAAC;AACxC,IAAA,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC;AAC/B,IAAA,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC;AAClC,IAAA,YAAY,EAAE,IAAI,CAAC,gBAAgB,CAAC;AACpC,IAAA,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC;AACnC,IAAA,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC;AAClC,IAAA,gBAAgB,EAAE,IAAI,CAAC,oBAAoB,CAAC;AAC5C,IAAA,uBAAuB,EAAE,IAAI,CAAC,4BAA4B,CAAC;AAC3D,IAAA,eAAe,EAAE,IAAI,CAAC,mBAAmB,CAAC;AAC1C,IAAA,cAAc,EAAE,IAAI,CAA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