sasat 0.13.6 → 0.14.1

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 (390) hide show
  1. package/lib/cli/cli.d.ts +2 -2
  2. package/lib/cli/cli.js +30 -21
  3. package/lib/cli/commands/createMigration.d.ts +2 -2
  4. package/lib/cli/commands/createMigration.js +36 -38
  5. package/lib/cli/commands/dumpDb.d.ts +1 -0
  6. package/lib/cli/commands/dumpDb.js +42 -0
  7. package/lib/cli/commands/generate.d.ts +1 -1
  8. package/lib/cli/commands/generate.js +19 -21
  9. package/lib/cli/commands/init.d.ts +1 -1
  10. package/lib/cli/commands/init.js +12 -14
  11. package/lib/cli/commands/migrate.d.ts +3 -3
  12. package/lib/cli/commands/migrate.js +29 -31
  13. package/lib/cli/console.d.ts +5 -5
  14. package/lib/cli/console.js +12 -14
  15. package/lib/config/config.d.ts +33 -33
  16. package/lib/config/config.js +33 -35
  17. package/lib/config/loader.d.ts +8 -8
  18. package/lib/config/loader.js +41 -41
  19. package/lib/constants/directory.d.ts +20 -0
  20. package/lib/constants/directory.js +34 -0
  21. package/lib/constants/interfaceConstants.d.ts +6 -0
  22. package/lib/constants/interfaceConstants.js +6 -0
  23. package/lib/db/{dbClient.d.ts → connectors/dbClient.d.ts} +31 -28
  24. package/lib/db/connectors/dbClient.js +26 -0
  25. package/lib/db/{mariadb → connectors/mariadb}/client.d.ts +8 -8
  26. package/lib/db/connectors/mariadb/client.js +24 -0
  27. package/lib/db/{mariadb → connectors/mariadb}/transaction.d.ts +9 -9
  28. package/lib/db/{mariadb → connectors/mariadb}/transaction.js +20 -23
  29. package/lib/db/connectors/mockClient.d.ts +13 -0
  30. package/lib/db/connectors/mockClient.js +26 -0
  31. package/lib/db/{mysql → connectors/mysql}/client.d.ts +8 -8
  32. package/lib/db/connectors/mysql/client.js +27 -0
  33. package/lib/db/{mysql → connectors/mysql}/transaction.d.ts +9 -9
  34. package/lib/db/connectors/mysql/transaction.js +22 -0
  35. package/lib/db/formatQuery.d.ts +1 -1
  36. package/lib/db/formatQuery.js +14 -16
  37. package/lib/db/getDbClient.d.ts +2 -2
  38. package/lib/db/getDbClient.js +8 -9
  39. package/lib/db/sql/columnToSql.d.ts +2 -0
  40. package/lib/{sql → db/sql}/columnToSql.js +27 -29
  41. package/lib/db/sql/condition.d.ts +22 -0
  42. package/lib/db/sql/condition.js +50 -0
  43. package/lib/db/sql/createTable/createTableParser.d.ts +17 -0
  44. package/lib/db/sql/createTable/createTableParser.js +241 -0
  45. package/lib/db/sql/createTable/createTableSerializer.d.ts +2 -0
  46. package/lib/db/sql/createTable/createTableSerializer.js +135 -0
  47. package/lib/db/sql/createTable/lexer/columnLexer.d.ts +2 -0
  48. package/lib/db/sql/createTable/lexer/columnLexer.js +20 -0
  49. package/lib/db/sql/createTable/lexer/createSimpleLexer.d.ts +3 -0
  50. package/lib/db/sql/createTable/lexer/createSimpleLexer.js +8 -0
  51. package/lib/db/sql/createTable/lexer/createTableLexer.d.ts +2 -0
  52. package/lib/db/sql/createTable/lexer/createTableLexer.js +22 -0
  53. package/lib/db/sql/createTable/lexer/lexer.d.ts +30 -0
  54. package/lib/db/sql/createTable/lexer/lexer.js +126 -0
  55. package/lib/db/sql/createTable/lexer/lexer2.d.ts +22 -0
  56. package/lib/db/sql/createTable/lexer/lexer2.js +110 -0
  57. package/lib/db/sql/createTable/lexer/rules.d.ts +21 -0
  58. package/lib/db/sql/createTable/lexer/rules.js +92 -0
  59. package/lib/db/sql/expression/comparison.d.ts +19 -0
  60. package/lib/db/sql/expression/comparison.js +36 -0
  61. package/lib/db/sql/expression/compositeCondition.d.ts +9 -0
  62. package/lib/db/sql/expression/compositeCondition.js +16 -0
  63. package/lib/db/sql/expression/conditionExpression.d.ts +5 -0
  64. package/lib/db/sql/expression/conditionExpression.js +10 -0
  65. package/lib/db/sql/sqlCreater.d.ts +8 -0
  66. package/lib/db/sql/sqlCreater.js +12 -0
  67. package/lib/error.d.ts +3 -3
  68. package/lib/error.js +7 -10
  69. package/lib/generator/controller.d.ts +20 -21
  70. package/lib/generator/controller.js +68 -64
  71. package/lib/generator/generator.d.ts +21 -21
  72. package/lib/generator/generator.js +1 -2
  73. package/lib/generator/gql/columnToGqlType.d.ts +3 -3
  74. package/lib/generator/gql/columnToGqlType.js +27 -29
  75. package/lib/generator/gql/types.d.ts +7 -7
  76. package/lib/generator/gql/types.js +8 -10
  77. package/lib/generator/ts/code/abstruct/exportableDeclaration.d.ts +6 -0
  78. package/lib/generator/ts/code/abstruct/exportableDeclaration.js +14 -0
  79. package/lib/generator/ts/code/abstruct/statement.d.ts +4 -0
  80. package/lib/generator/ts/code/abstruct/statement.js +7 -0
  81. package/lib/generator/ts/code/abstruct/tsCode.d.ts +9 -0
  82. package/lib/generator/ts/code/abstruct/tsCode.js +22 -0
  83. package/lib/generator/ts/code/accessors.d.ts +5 -0
  84. package/lib/generator/ts/code/accessors.js +6 -0
  85. package/lib/generator/ts/code/factory.d.ts +68 -0
  86. package/lib/generator/ts/code/factory.js +80 -0
  87. package/lib/generator/ts/code/importDeclaration.d.ts +6 -0
  88. package/lib/generator/ts/code/importDeclaration.js +9 -0
  89. package/lib/generator/ts/code/node/ExpressionStatement.d.ts +7 -0
  90. package/lib/generator/ts/code/node/ExpressionStatement.js +11 -0
  91. package/lib/generator/ts/code/node/block.d.ts +6 -0
  92. package/lib/generator/ts/code/node/block.js +11 -0
  93. package/lib/generator/ts/code/node/class.d.ts +20 -0
  94. package/lib/generator/ts/code/node/class.js +42 -0
  95. package/lib/generator/ts/code/node/enumDeclaration.d.ts +10 -0
  96. package/lib/generator/ts/code/node/enumDeclaration.js +17 -0
  97. package/lib/generator/ts/code/node/enumMember.d.ts +8 -0
  98. package/lib/generator/ts/code/node/enumMember.js +16 -0
  99. package/lib/generator/ts/code/node/expressions.d.ts +103 -0
  100. package/lib/generator/ts/code/node/expressions.js +188 -0
  101. package/lib/generator/ts/code/node/extendsClause.d.ts +7 -0
  102. package/lib/generator/ts/code/node/extendsClause.js +11 -0
  103. package/lib/generator/ts/code/node/ifStatement.d.ts +8 -0
  104. package/lib/generator/ts/code/node/ifStatement.js +12 -0
  105. package/lib/generator/ts/code/node/implementsClause.d.ts +7 -0
  106. package/lib/generator/ts/code/node/implementsClause.js +11 -0
  107. package/lib/generator/ts/code/node/interface.d.ts +11 -0
  108. package/lib/generator/ts/code/node/interface.js +21 -0
  109. package/lib/generator/ts/code/node/methodDeclaration.d.ts +16 -0
  110. package/lib/generator/ts/code/node/methodDeclaration.js +30 -0
  111. package/lib/generator/ts/code/node/modifier/methodModifiers.d.ts +7 -0
  112. package/lib/generator/ts/code/node/modifier/methodModifiers.js +15 -0
  113. package/lib/generator/ts/code/node/modifier/modifiers.d.ts +17 -0
  114. package/lib/generator/ts/code/node/modifier/modifiers.js +47 -0
  115. package/lib/generator/ts/code/node/modifier/propertyModifiers.d.ts +10 -0
  116. package/lib/generator/ts/code/node/modifier/propertyModifiers.js +21 -0
  117. package/lib/generator/ts/code/node/parameter.d.ts +9 -0
  118. package/lib/generator/ts/code/node/parameter.js +17 -0
  119. package/lib/generator/ts/code/node/propertyAssignment.d.ts +8 -0
  120. package/lib/generator/ts/code/node/propertyAssignment.js +14 -0
  121. package/lib/generator/ts/code/node/propertyDeclaration.d.ts +15 -0
  122. package/lib/generator/ts/code/node/propertyDeclaration.js +32 -0
  123. package/lib/generator/ts/code/node/propertySignature.d.ts +11 -0
  124. package/lib/generator/ts/code/node/propertySignature.js +18 -0
  125. package/lib/generator/ts/code/node/rawCodeStatement.d.ts +6 -0
  126. package/lib/generator/ts/code/node/rawCodeStatement.js +10 -0
  127. package/lib/generator/ts/code/node/returnStatement.d.ts +7 -0
  128. package/lib/generator/ts/code/node/returnStatement.js +11 -0
  129. package/lib/generator/ts/code/node/spreadAssignment.d.ts +7 -0
  130. package/lib/generator/ts/code/node/spreadAssignment.js +11 -0
  131. package/lib/generator/ts/code/node/type/arrayType.d.ts +7 -0
  132. package/lib/generator/ts/code/node/type/arrayType.js +13 -0
  133. package/lib/generator/ts/code/node/type/intersectionType.d.ts +8 -0
  134. package/lib/generator/ts/code/node/type/intersectionType.js +11 -0
  135. package/lib/generator/ts/code/node/type/type.d.ts +10 -0
  136. package/lib/generator/ts/code/node/type/type.js +3 -0
  137. package/lib/generator/ts/code/node/type/typeAliasDeclaration.d.ts +8 -0
  138. package/lib/generator/ts/code/node/type/typeAliasDeclaration.js +14 -0
  139. package/lib/generator/ts/code/node/type/typeKeyword.d.ts +15 -0
  140. package/lib/generator/ts/code/node/type/typeKeyword.js +15 -0
  141. package/lib/generator/ts/code/node/type/typeLiteral.d.ts +9 -0
  142. package/lib/generator/ts/code/node/type/typeLiteral.js +16 -0
  143. package/lib/generator/ts/code/node/type/typeReference.d.ts +12 -0
  144. package/lib/generator/ts/code/node/type/typeReference.js +25 -0
  145. package/lib/generator/ts/code/node/type/unionType.d.ts +7 -0
  146. package/lib/generator/ts/code/node/type/unionType.js +13 -0
  147. package/lib/generator/ts/code/node/variableDeclaration.d.ts +13 -0
  148. package/lib/generator/ts/code/node/variableDeclaration.js +16 -0
  149. package/lib/generator/ts/code/tsUtil.d.ts +4 -0
  150. package/lib/generator/ts/code/tsUtil.js +4 -0
  151. package/lib/generator/ts/db/generatedRepositoryGenerator.d.ts +11 -0
  152. package/lib/generator/ts/db/generatedRepositoryGenerator.js +110 -0
  153. package/lib/generator/ts/db/repositoryGenerator.d.ts +5 -0
  154. package/lib/generator/ts/db/repositoryGenerator.js +13 -0
  155. package/lib/generator/ts/entityGenerator.d.ts +10 -0
  156. package/lib/generator/ts/entityGenerator.js +27 -0
  157. package/lib/generator/ts/fieldGenerator.d.ts +6 -0
  158. package/lib/generator/ts/fieldGenerator.js +25 -0
  159. package/lib/generator/ts/file.d.ts +10 -0
  160. package/lib/generator/ts/file.js +31 -0
  161. package/lib/generator/ts/generator.d.ts +18 -22
  162. package/lib/generator/ts/generator.js +53 -86
  163. package/lib/generator/ts/gql/contextGenerator.d.ts +5 -0
  164. package/lib/generator/ts/gql/contextGenerator.js +10 -0
  165. package/lib/generator/ts/gql/mutationGenerator.d.ts +15 -0
  166. package/lib/generator/ts/gql/mutationGenerator.js +87 -0
  167. package/lib/generator/ts/gql/queryGenerator.d.ts +6 -0
  168. package/lib/generator/ts/gql/queryGenerator.js +38 -0
  169. package/lib/generator/ts/gql/resolverGenerator.d.ts +8 -0
  170. package/lib/generator/ts/gql/resolverGenerator.js +45 -0
  171. package/lib/generator/ts/gql/subscriptionGenerator.d.ts +9 -0
  172. package/lib/generator/ts/gql/subscriptionGenerator.js +58 -0
  173. package/lib/generator/ts/gql/typeDefGenerator.d.ts +9 -0
  174. package/lib/generator/ts/gql/typeDefGenerator.js +42 -0
  175. package/lib/generator/ts/relationMapGenerator.d.ts +9 -0
  176. package/lib/generator/ts/relationMapGenerator.js +56 -0
  177. package/lib/generator/ts/staticFiles.d.ts +2 -0
  178. package/lib/generator/ts/staticFiles.js +52 -0
  179. package/lib/generator/ts/{code/value.d.ts → tsValueString.d.ts} +1 -1
  180. package/lib/generator/ts/{code/value.js → tsValueString.js} +27 -29
  181. package/lib/index.d.ts +17 -8
  182. package/lib/index.js +8 -14
  183. package/lib/migration/column/columnTypes.d.ts +27 -26
  184. package/lib/migration/column/columnTypes.js +44 -46
  185. package/lib/migration/controller.d.ts +12 -12
  186. package/lib/migration/controller.js +72 -68
  187. package/lib/migration/{column → creators}/columnBuilder.d.ts +91 -88
  188. package/lib/migration/{column → creators}/columnBuilder.js +179 -181
  189. package/lib/migration/{column → creators}/columnCreator.d.ts +24 -24
  190. package/lib/migration/creators/columnCreator.js +28 -0
  191. package/lib/migration/{tableCreator.d.ts → creators/tableCreator.d.ts} +33 -33
  192. package/lib/migration/{tableCreator.js → creators/tableCreator.js} +53 -63
  193. package/lib/{entity → migration/data}/foreignKey.d.ts +9 -14
  194. package/lib/migration/data/foreignKey.js +1 -0
  195. package/lib/migration/{gqlOption.d.ts → data/gqlOption.d.ts} +21 -20
  196. package/lib/migration/{gqlOption.js → data/gqlOption.js} +28 -31
  197. package/lib/{entity → migration/data}/index.d.ts +15 -13
  198. package/lib/{entity → migration/data}/index.js +22 -19
  199. package/lib/migration/data/relation.d.ts +1 -0
  200. package/lib/migration/data/relation.js +1 -0
  201. package/lib/migration/dataStore.d.ts +12 -0
  202. package/lib/migration/dataStore.js +17 -0
  203. package/lib/migration/{migration.d.ts → front/migration.d.ts} +9 -9
  204. package/lib/migration/front/migration.js +1 -0
  205. package/lib/migration/{storeMigrator.d.ts → front/storeMigrator.d.ts} +23 -22
  206. package/lib/migration/front/storeMigrator.js +53 -0
  207. package/lib/migration/front/tableMigrator.d.ts +39 -0
  208. package/lib/migration/front/tableMigrator.js +84 -0
  209. package/lib/migration/functions/assembleColumn.d.ts +4 -0
  210. package/lib/migration/functions/assembleColumn.js +7 -0
  211. package/lib/migration/migrationReader.d.ts +7 -6
  212. package/lib/migration/migrationReader.js +54 -40
  213. package/lib/migration/migrationTargetResolver.d.ts +9 -9
  214. package/lib/migration/migrationTargetResolver.js +34 -37
  215. package/lib/migration/serializable/column.d.ts +41 -0
  216. package/lib/migration/serializable/column.js +59 -0
  217. package/lib/migration/serializable/serializable.d.ts +3 -0
  218. package/lib/migration/serializable/serializable.js +1 -0
  219. package/lib/migration/serializable/table.d.ts +48 -0
  220. package/lib/migration/serializable/table.js +161 -0
  221. package/lib/migration/serialized/serializedColumn.d.ts +38 -0
  222. package/lib/migration/serialized/serializedColumn.js +10 -0
  223. package/lib/migration/serialized/serializedStore.d.ts +14 -0
  224. package/lib/migration/serialized/serializedStore.js +1 -0
  225. package/lib/parser/node/entityName.d.ts +22 -0
  226. package/lib/parser/node/entityName.js +59 -0
  227. package/lib/parser/node/entityNode.d.ts +23 -0
  228. package/lib/parser/node/entityNode.js +43 -0
  229. package/lib/parser/node/fieldNode.d.ts +25 -0
  230. package/lib/parser/node/fieldNode.js +43 -0
  231. package/lib/parser/node/findMethod.d.ts +10 -0
  232. package/lib/parser/node/findMethod.js +12 -0
  233. package/lib/parser/node/gql/contextNode.d.ts +6 -0
  234. package/lib/parser/node/gql/contextNode.js +6 -0
  235. package/lib/parser/node/gql/contextParamNode.d.ts +5 -0
  236. package/lib/parser/node/gql/contextParamNode.js +6 -0
  237. package/lib/parser/node/gql/mutationNode.d.ts +43 -0
  238. package/lib/parser/node/gql/mutationNode.js +68 -0
  239. package/lib/parser/node/gql/queryNode.d.ts +10 -0
  240. package/lib/parser/node/gql/queryNode.js +12 -0
  241. package/lib/parser/node/gql/subscriptionFilterNode.d.ts +6 -0
  242. package/lib/parser/node/gql/subscriptionFilterNode.js +6 -0
  243. package/lib/parser/node/gql/typeDefNode.d.ts +9 -0
  244. package/lib/parser/node/gql/typeDefNode.js +21 -0
  245. package/lib/parser/node/parameterNode.d.ts +8 -0
  246. package/lib/parser/node/parameterNode.js +12 -0
  247. package/lib/parser/node/relationNode.d.ts +20 -0
  248. package/lib/parser/node/relationNode.js +31 -0
  249. package/lib/parser/node/repositoryNode.d.ts +21 -0
  250. package/lib/parser/node/repositoryNode.js +55 -0
  251. package/lib/parser/node/rootNode.d.ts +20 -0
  252. package/lib/parser/node/rootNode.js +28 -0
  253. package/lib/parser/node/typeNode.d.ts +12 -0
  254. package/lib/parser/node/typeNode.js +28 -0
  255. package/lib/parser/nodeFactory/contextNodeFactory.d.ts +5 -0
  256. package/lib/parser/nodeFactory/contextNodeFactory.js +12 -0
  257. package/lib/parser/nodeFactory/mutationNodeFactory.d.ts +7 -0
  258. package/lib/parser/nodeFactory/mutationNodeFactory.js +33 -0
  259. package/lib/parser/nodeFactory/queryNodeFactory.d.ts +7 -0
  260. package/lib/parser/nodeFactory/queryNodeFactory.js +17 -0
  261. package/lib/parser/parser.d.ts +5 -0
  262. package/lib/parser/parser.js +10 -0
  263. package/lib/{createTypeDef.d.ts → runtime/createTypeDef.d.ts} +1 -1
  264. package/lib/{createTypeDef.js → runtime/createTypeDef.js} +4 -6
  265. package/lib/runtime/dsl/factory.d.ts +30 -0
  266. package/lib/runtime/dsl/factory.js +108 -0
  267. package/lib/runtime/dsl/mutation/mutation.d.ts +24 -0
  268. package/lib/runtime/dsl/mutation/mutation.js +20 -0
  269. package/lib/runtime/dsl/query/createQueryResolveInfo.d.ts +26 -0
  270. package/lib/runtime/dsl/query/createQueryResolveInfo.js +25 -0
  271. package/lib/runtime/dsl/query/fieldToQuery.d.ts +4 -0
  272. package/lib/runtime/dsl/query/fieldToQuery.js +22 -0
  273. package/lib/runtime/dsl/query/query.d.ts +106 -0
  274. package/lib/runtime/dsl/query/query.js +16 -0
  275. package/lib/runtime/dsl/query/sql/hydrate.d.ts +13 -0
  276. package/lib/runtime/dsl/query/sql/hydrate.js +81 -0
  277. package/lib/runtime/dsl/query/sql/nodeToSql.d.ts +22 -0
  278. package/lib/runtime/dsl/query/sql/nodeToSql.js +63 -0
  279. package/lib/runtime/dsl/query/sql/queryToSql.d.ts +2 -0
  280. package/lib/runtime/dsl/query/sql/queryToSql.js +13 -0
  281. package/lib/runtime/dsl/replaceAliases.d.ts +4 -0
  282. package/lib/runtime/dsl/replaceAliases.js +66 -0
  283. package/lib/runtime/field.d.ts +5 -0
  284. package/lib/runtime/field.js +1 -0
  285. package/lib/runtime/gqlResolveInfoToField.d.ts +3 -0
  286. package/lib/runtime/gqlResolveInfoToField.js +25 -0
  287. package/lib/runtime/sasatRepository.d.ts +31 -0
  288. package/lib/runtime/sasatRepository.js +75 -0
  289. package/lib/runtime/sql/sqlString.d.ts +5 -0
  290. package/lib/runtime/sql/sqlString.js +6 -0
  291. package/lib/util/arrayUtil.d.ts +3 -3
  292. package/lib/util/arrayUtil.js +11 -13
  293. package/lib/util/assignDeep.d.ts +5 -5
  294. package/lib/util/assignDeep.js +21 -23
  295. package/lib/util/dateUtil.d.ts +1 -1
  296. package/lib/util/dateUtil.js +20 -22
  297. package/lib/util/fsUtil.d.ts +7 -4
  298. package/lib/util/fsUtil.js +37 -19
  299. package/lib/util/stringUtil.d.ts +4 -3
  300. package/lib/util/stringUtil.js +12 -8
  301. package/lib/util/type.d.ts +3 -3
  302. package/lib/util/type.js +1 -2
  303. package/package.json +37 -29
  304. package/lib/compiler/compiler.d.ts +0 -12
  305. package/lib/compiler/compiler.js +0 -100
  306. package/lib/compiler/gqlCompiler.d.ts +0 -13
  307. package/lib/compiler/gqlCompiler.js +0 -181
  308. package/lib/db/dbClient.js +0 -24
  309. package/lib/db/mariadb/client.js +0 -26
  310. package/lib/db/mysql/client.js +0 -27
  311. package/lib/db/mysql/transaction.js +0 -24
  312. package/lib/entity/assembleColumn.d.ts +0 -5
  313. package/lib/entity/assembleColumn.js +0 -10
  314. package/lib/entity/column.d.ts +0 -33
  315. package/lib/entity/column.js +0 -45
  316. package/lib/entity/dataStore.d.ts +0 -12
  317. package/lib/entity/dataStore.js +0 -17
  318. package/lib/entity/foreignKey.js +0 -9
  319. package/lib/entity/referenceColumn.d.ts +0 -33
  320. package/lib/entity/referenceColumn.js +0 -56
  321. package/lib/entity/relation.d.ts +0 -5
  322. package/lib/entity/relation.js +0 -8
  323. package/lib/entity/serializedStore.d.ts +0 -16
  324. package/lib/entity/serializedStore.js +0 -2
  325. package/lib/entity/table.d.ts +0 -40
  326. package/lib/entity/table.js +0 -112
  327. package/lib/generator/gql/typeDef.d.ts +0 -8
  328. package/lib/generator/gql/typeDef.js +0 -13
  329. package/lib/generator/ts/code/array.d.ts +0 -1
  330. package/lib/generator/ts/code/array.js +0 -4
  331. package/lib/generator/ts/code/arrowFunction.d.ts +0 -4
  332. package/lib/generator/ts/code/arrowFunction.js +0 -4
  333. package/lib/generator/ts/code/nestedObject.d.ts +0 -7
  334. package/lib/generator/ts/code/nestedObject.js +0 -30
  335. package/lib/generator/ts/code/object.d.ts +0 -6
  336. package/lib/generator/ts/code/object.js +0 -20
  337. package/lib/generator/ts/file/entity.d.ts +0 -2
  338. package/lib/generator/ts/file/entity.js +0 -24
  339. package/lib/generator/ts/file/generatedRepository.d.ts +0 -13
  340. package/lib/generator/ts/file/generatedRepository.js +0 -126
  341. package/lib/generator/ts/file/repository.d.ts +0 -2
  342. package/lib/generator/ts/file/repository.js +0 -7
  343. package/lib/generator/ts/gql/context.d.ts +0 -5
  344. package/lib/generator/ts/gql/context.js +0 -17
  345. package/lib/generator/ts/gql/mutation.d.ts +0 -13
  346. package/lib/generator/ts/gql/mutation.js +0 -88
  347. package/lib/generator/ts/gql/query.d.ts +0 -2
  348. package/lib/generator/ts/gql/query.js +0 -25
  349. package/lib/generator/ts/gql/resolver.d.ts +0 -7
  350. package/lib/generator/ts/gql/resolver.js +0 -31
  351. package/lib/generator/ts/gql/subscription.d.ts +0 -5
  352. package/lib/generator/ts/gql/subscription.js +0 -49
  353. package/lib/generator/ts/gql/typeDef.d.ts +0 -2
  354. package/lib/generator/ts/gql/typeDef.js +0 -50
  355. package/lib/generator/ts/tsClassGenerator.d.ts +0 -45
  356. package/lib/generator/ts/tsClassGenerator.js +0 -59
  357. package/lib/generator/ts/tsFileGenerator.d.ts +0 -12
  358. package/lib/generator/ts/tsFileGenerator.js +0 -27
  359. package/lib/ir/entity.d.ts +0 -14
  360. package/lib/ir/entity.js +0 -2
  361. package/lib/ir/gql/context.d.ts +0 -5
  362. package/lib/ir/gql/context.js +0 -2
  363. package/lib/ir/gql/index.d.ts +0 -12
  364. package/lib/ir/gql/index.js +0 -2
  365. package/lib/ir/gql/mutation.d.ts +0 -29
  366. package/lib/ir/gql/mutation.js +0 -2
  367. package/lib/ir/gql/query.d.ts +0 -15
  368. package/lib/ir/gql/query.js +0 -8
  369. package/lib/ir/gql/resolver.d.ts +0 -8
  370. package/lib/ir/gql/resolver.js +0 -2
  371. package/lib/ir/gql/types.d.ts +0 -12
  372. package/lib/ir/gql/types.js +0 -2
  373. package/lib/ir/ir.d.ts +0 -6
  374. package/lib/ir/ir.js +0 -2
  375. package/lib/ir/repository.d.ts +0 -34
  376. package/lib/ir/repository.js +0 -2
  377. package/lib/migration/column/columnCreator.js +0 -31
  378. package/lib/migration/column/columnData.d.ts +0 -68
  379. package/lib/migration/column/columnData.js +0 -2
  380. package/lib/migration/migration.js +0 -2
  381. package/lib/migration/storeMigrator.js +0 -48
  382. package/lib/migration/tableMigrator.d.ts +0 -30
  383. package/lib/migration/tableMigrator.js +0 -52
  384. package/lib/sasatRepository.d.ts +0 -30
  385. package/lib/sasatRepository.js +0 -63
  386. package/lib/sql/columnToSql.d.ts +0 -2
  387. package/lib/sql/condition.d.ts +0 -32
  388. package/lib/sql/condition.js +0 -49
  389. package/lib/sql/sqlCreater.d.ts +0 -10
  390. package/lib/sql/sqlCreater.js +0 -19
package/lib/cli/cli.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ #!/usr/bin/env node
2
+ export {};
package/lib/cli/cli.js CHANGED
@@ -1,21 +1,30 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const cac_1 = require("cac");
5
- const migrate_1 = require("./commands/migrate");
6
- const createMigration_1 = require("./commands/createMigration");
7
- const init_1 = require("./commands/init");
8
- const generate_1 = require("./commands/generate");
9
- const cli = cac_1.cac();
10
- cli
11
- .command('migrate', 'execute migration')
12
- .option('-g, --generateFiles', 'migrate with generate files')
13
- .action(async (options) => {
14
- await migrate_1.migrate(options);
15
- });
16
- cli.command('generate', 'generate files').action(generate_1.generate);
17
- cli.command('migration:create [name]', 'generate new migration file').action(createMigration_1.createMigration);
18
- cli.command('init').action(init_1.init);
19
- cli.parse();
20
- if (!cli.matchedCommand)
21
- cli.outputHelp();
1
+ #!/usr/bin/env node
2
+ import { cac } from 'cac';
3
+ import { createMigration } from './commands/createMigration.js';
4
+ import { migrate } from './commands/migrate.js';
5
+ import { init } from './commands/init.js';
6
+ import { generate } from './commands/generate.js';
7
+ import { dumpDB } from './commands/dumpDb.js';
8
+ const cli = cac();
9
+ try {
10
+ cli
11
+ .usage('yarn sasat <command> [options]\n')
12
+ .command('migrate', 'execute migration')
13
+ .option('-g, --generateFiles', 'migrate with generate files')
14
+ .action(async (options) => {
15
+ await migrate(options).catch(() => {
16
+ process.exit(1);
17
+ });
18
+ });
19
+ cli.command('generate', 'generate files').action(generate);
20
+ cli.command('migration:create [name]', 'generate new migration file').action(createMigration);
21
+ cli.command('dump-db', 'dump database schema').action(dumpDB);
22
+ cli.command('init').action(init);
23
+ cli.parse();
24
+ if (!cli.matchedCommand)
25
+ cli.outputHelp();
26
+ }
27
+ catch (e) {
28
+ console.error(e);
29
+ process.exit(1);
30
+ }
@@ -1,2 +1,2 @@
1
- export declare const createMigrationFile: (migrationName: string) => string;
2
- export declare const createMigration: (args: string) => void;
1
+ export declare const createMigrationFile: (migrationName: string) => string;
2
+ export declare const createMigration: (args: string) => void;
@@ -1,15 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const console_1 = require("../console");
4
- const fs = require("fs");
5
- const path_1 = require("path");
6
- const config_1 = require("../../config/config");
7
- const stringUtil_1 = require("../../util/stringUtil");
8
- const fsUtil_1 = require("../../util/fsUtil");
1
+ import * as fs from 'fs';
2
+ import { join } from 'path';
3
+ import { config } from '../../config/config.js';
4
+ import { capitalizeFirstLetter } from '../../util/stringUtil.js';
5
+ import { mkDirIfNotExist } from '../../util/fsUtil.js';
6
+ import { Console } from '../console.js';
9
7
  const getMigrationFile = (className) => `import { SasatMigration } from "sasat";
10
8
  import { MigrationStore } from "sasat";
11
9
 
12
- export class ${stringUtil_1.capitalizeFirstLetter(className)} implements SasatMigration {
10
+ export class ${capitalizeFirstLetter(className)} implements SasatMigration {
13
11
 
14
12
  up: (store: MigrationStore) => void = store => {
15
13
 
@@ -20,32 +18,32 @@ export class ${stringUtil_1.capitalizeFirstLetter(className)} implements SasatMi
20
18
  };
21
19
  }
22
20
 
23
- `;
24
- exports.createMigrationFile = (migrationName) => {
25
- const date = new Date();
26
- const pad = (val) => val.toString().padStart(2, '0');
27
- const now = date.getFullYear() +
28
- pad(date.getMonth() + 1) +
29
- pad(date.getDate()) +
30
- `_` +
31
- pad(date.getHours()) +
32
- pad(date.getMinutes()) +
33
- pad(date.getSeconds());
34
- const fileName = now + migrationName;
35
- const outDir = path_1.join(config_1.config().migration.dir);
36
- fsUtil_1.mkDirIfNotExist(outDir);
37
- fs.writeFileSync(path_1.join(outDir, fileName) + '.ts', getMigrationFile(migrationName));
38
- return fileName;
39
- };
40
- exports.createMigration = (args) => {
41
- if (!args) {
42
- console_1.Console.error('missing argument migration name');
43
- return;
44
- }
45
- if (!/^[$A-Za-z_][0-9A-Za-z_]+$/.test(args)) {
46
- console_1.Console.error('migration name should be match /^[$A-Za-z_][0-9A-Za-z_]+$/');
47
- return;
48
- }
49
- console_1.Console.success(exports.createMigrationFile(args) + ' Successfully created');
50
- return;
51
- };
21
+ `;
22
+ export const createMigrationFile = (migrationName) => {
23
+ const date = new Date();
24
+ const pad = (val) => val.toString().padStart(2, '0');
25
+ const now = date.getFullYear() +
26
+ pad(date.getMonth() + 1) +
27
+ pad(date.getDate()) +
28
+ `_` +
29
+ pad(date.getHours()) +
30
+ pad(date.getMinutes()) +
31
+ pad(date.getSeconds());
32
+ const fileName = now + migrationName;
33
+ const outDir = join(config().migration.dir);
34
+ mkDirIfNotExist(outDir);
35
+ fs.writeFileSync(join(outDir, fileName) + '.ts', getMigrationFile(migrationName));
36
+ return fileName;
37
+ };
38
+ export const createMigration = (args) => {
39
+ if (!args) {
40
+ Console.error('missing argument migration name');
41
+ return;
42
+ }
43
+ if (!/^[$A-Za-z_][0-9A-Za-z_]+$/.test(args)) {
44
+ Console.error('migration name should be match /^[$A-Za-z_][0-9A-Za-z_]+$/');
45
+ return;
46
+ }
47
+ Console.success(createMigrationFile(args) + ' Successfully created');
48
+ return;
49
+ };
@@ -0,0 +1 @@
1
+ export declare const dumpDB: () => Promise<void>;
@@ -0,0 +1,42 @@
1
+ import { Console } from '../console.js';
2
+ import { serializeCreateTable } from '../../db/sql/createTable/createTableSerializer.js';
3
+ import { SqlString } from '../../runtime/sql/sqlString.js';
4
+ import { writeYmlFile } from '../../util/fsUtil.js';
5
+ import { DBColumnTypes } from '../../migration/column/columnTypes.js';
6
+ import { config } from '../../config/config.js';
7
+ import { getDbClient } from "../../db/getDbClient.js";
8
+ export const dumpDB = async () => {
9
+ const con = getDbClient();
10
+ try {
11
+ const tables = await con.rawQuery('show tables').then(it => it.flatMap(it => Object.values(it)));
12
+ const serialized = await Promise.all(tables.map(table => {
13
+ return con
14
+ .rawQuery('show create table ' + SqlString.escapeId(table))
15
+ .then(it => it[0]['Create Table'])
16
+ .then(serializeCreateTable);
17
+ }));
18
+ const supportedTypes = Object.values(DBColumnTypes);
19
+ const store = {
20
+ tables: serialized.filter(it => {
21
+ if (it.primaryKey.length === 0) {
22
+ Console.error(`table ${it.tableName} skipped, reason: missing primary key`);
23
+ return false;
24
+ }
25
+ const notSupported = it.columns.find(it => !supportedTypes.includes(it.type));
26
+ if (notSupported) {
27
+ Console.error(`table ${it.tableName} skipped, reason: ${it.tableName}.${notSupported.columnName} column type "${notSupported.type}" is Not Supported`);
28
+ return false;
29
+ }
30
+ return true;
31
+ }),
32
+ };
33
+ writeYmlFile(config().migration.dir, 'initialSchema.yml', store);
34
+ }
35
+ catch (e) {
36
+ Console.error(e.message);
37
+ throw e;
38
+ }
39
+ finally {
40
+ await con.release();
41
+ }
42
+ };
@@ -1 +1 @@
1
- export declare const generate: () => Promise<void>;
1
+ export declare const generate: () => Promise<void>;
@@ -1,21 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const dataStore_1 = require("../../entity/dataStore");
4
- const compiler_1 = require("../../compiler/compiler");
5
- const gqlCompiler_1 = require("../../compiler/gqlCompiler");
6
- const controller_1 = require("../../generator/controller");
7
- const console_1 = require("../console");
8
- const migrationReader_1 = require("../../migration/migrationReader");
9
- exports.generate = async () => {
10
- try {
11
- const store = new migrationReader_1.MigrationReader().read();
12
- const storeHandler = new dataStore_1.DataStoreHandler(store.serialize());
13
- const ir = new compiler_1.Compiler(storeHandler).compile();
14
- const gql = new gqlCompiler_1.GqlCompiler(storeHandler).compile();
15
- await new controller_1.CodeGenerateController(ir, gql).generate();
16
- }
17
- catch (e) {
18
- console_1.Console.error(e.message);
19
- throw e;
20
- }
21
- };
1
+ import { Parser } from '../../parser/parser.js';
2
+ import { CodeGenerateController } from '../../generator/controller.js';
3
+ import { Console } from '../console.js';
4
+ import { MigrationReader } from '../../migration/migrationReader.js';
5
+ import { DataStoreHandler } from '../../migration/dataStore.js';
6
+ import { writeCurrentSchema } from '../../util/fsUtil.js';
7
+ export const generate = async () => {
8
+ try {
9
+ const store = new MigrationReader().read().serialize();
10
+ const storeHandler = new DataStoreHandler(store);
11
+ writeCurrentSchema(store);
12
+ const ir = new Parser().parse(storeHandler);
13
+ await new CodeGenerateController(ir).generate();
14
+ }
15
+ catch (e) {
16
+ Console.error(e.message);
17
+ throw e;
18
+ }
19
+ };
@@ -1 +1 @@
1
- export declare const init: () => void;
1
+ export declare const init: () => void;
@@ -1,14 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fsUtil_1 = require("../../util/fsUtil");
4
- const config_1 = require("../../config/config");
5
- const console_1 = require("../console");
6
- const fs = require("fs");
7
- exports.init = () => {
8
- if (fs.existsSync('./sasat.yml')) {
9
- console_1.Console.error('sasat.yml already exist');
10
- return;
11
- }
12
- fsUtil_1.writeYmlFile('./', 'sasat.yml', config_1.defaultConf);
13
- console_1.Console.success('sasat.yml created');
14
- };
1
+ import { writeYmlFile } from '../../util/fsUtil.js';
2
+ import { defaultConf } from '../../config/config.js';
3
+ import { Console } from '../console.js';
4
+ import * as fs from 'fs';
5
+ export const init = () => {
6
+ if (fs.existsSync('./sasat.yml')) {
7
+ Console.error('sasat.yml already exist');
8
+ return;
9
+ }
10
+ writeYmlFile('./', 'sasat.yml', defaultConf);
11
+ Console.success('sasat.yml created');
12
+ };
@@ -1,3 +1,3 @@
1
- export declare const migrate: (options: {
2
- [key: string]: boolean;
3
- }) => Promise<void>;
1
+ export declare const migrate: (options: {
2
+ [key: string]: boolean;
3
+ }) => Promise<void>;
@@ -1,31 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const controller_1 = require("../../migration/controller");
4
- const getDbClient_1 = require("../../db/getDbClient");
5
- const console_1 = require("../console");
6
- const dataStore_1 = require("../../entity/dataStore");
7
- const compiler_1 = require("../../compiler/compiler");
8
- const gqlCompiler_1 = require("../../compiler/gqlCompiler");
9
- const controller_2 = require("../../generator/controller");
10
- exports.migrate = async (options) => {
11
- let current;
12
- try {
13
- const migration = new controller_1.MigrationController();
14
- const result = await migration.migrate();
15
- current = result.currentMigration;
16
- if (options.generateFiles) {
17
- const storeHandler = new dataStore_1.DataStoreHandler(result.store);
18
- const ir = new compiler_1.Compiler(storeHandler).compile();
19
- const gql = new gqlCompiler_1.GqlCompiler(storeHandler).compile();
20
- await new controller_2.CodeGenerateController(ir, gql).generate();
21
- }
22
- }
23
- catch (e) {
24
- console_1.Console.error(e.message);
25
- throw e;
26
- }
27
- finally {
28
- await getDbClient_1.getDbClient().release();
29
- }
30
- console_1.Console.success(`current migration is ${current}`);
31
- };
1
+ import { MigrationController } from '../../migration/controller.js';
2
+ import { Console } from '../console.js';
3
+ import { Parser } from '../../parser/parser.js';
4
+ import { CodeGenerateController } from '../../generator/controller.js';
5
+ import { DataStoreHandler } from '../../migration/dataStore.js';
6
+ import { writeCurrentSchema } from '../../util/fsUtil.js';
7
+ import { getDbClient } from "../../db/getDbClient.js";
8
+ export const migrate = async (options) => {
9
+ let current;
10
+ try {
11
+ const migration = new MigrationController();
12
+ const result = await migration.migrate();
13
+ current = result.currentMigration;
14
+ if (options.generateFiles) {
15
+ const storeHandler = new DataStoreHandler(result.store);
16
+ writeCurrentSchema(result.store);
17
+ const ir = new Parser().parse(storeHandler);
18
+ await new CodeGenerateController(ir).generate();
19
+ }
20
+ }
21
+ catch (e) {
22
+ Console.error(e.message);
23
+ throw e;
24
+ }
25
+ finally {
26
+ await getDbClient().release();
27
+ }
28
+ Console.success(`current migration is ${current}`);
29
+ };
@@ -1,5 +1,5 @@
1
- export declare const Console: {
2
- success: (msg: string) => void;
3
- error: (msg: string) => void;
4
- log: (msg: any) => void;
5
- };
1
+ export declare const Console: {
2
+ success: (msg: string) => void;
3
+ error: (msg: string) => void;
4
+ log: (msg: any) => void;
5
+ };
@@ -1,14 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const chalk = require("chalk");
4
- exports.Console = {
5
- success: (msg) => {
6
- console.log(chalk.green(msg));
7
- },
8
- error: (msg) => {
9
- console.error(chalk.bold.red(msg));
10
- },
11
- log: (msg) => {
12
- console.log(msg);
13
- },
14
- };
1
+ import chalk from 'chalk';
2
+ export const Console = {
3
+ success: (msg) => {
4
+ console.log(chalk.green(msg));
5
+ },
6
+ error: (msg) => {
7
+ console.error(chalk.bold.red(msg));
8
+ },
9
+ log: (msg) => {
10
+ console.log(msg);
11
+ },
12
+ };
@@ -1,33 +1,33 @@
1
- import { NestedPartial } from '../util/type';
2
- export interface SasatConfigDb {
3
- host: string;
4
- port: number;
5
- user: string;
6
- password?: string;
7
- database: string;
8
- }
9
- export interface SasatConfigRedis {
10
- host: string;
11
- port: number;
12
- password?: string;
13
- }
14
- export interface SasatConfigMigration {
15
- table: string;
16
- dir: string;
17
- out: string;
18
- target?: string;
19
- }
20
- export interface SasatConfigGenerator {
21
- gql: {
22
- subscription: boolean;
23
- };
24
- }
25
- export interface SasatConfig {
26
- db: SasatConfigDb;
27
- migration: SasatConfigMigration;
28
- generator: SasatConfigGenerator;
29
- redis: SasatConfigRedis;
30
- }
31
- export declare type PartialSasatConfig = NestedPartial<SasatConfig>;
32
- export declare const defaultConf: SasatConfig;
33
- export declare const config: () => SasatConfig;
1
+ import { NestedPartial } from '../util/type.js';
2
+ export interface SasatConfigDb {
3
+ host: string;
4
+ port: number;
5
+ user: string;
6
+ password?: string;
7
+ database: string;
8
+ }
9
+ export interface SasatConfigRedis {
10
+ host: string;
11
+ port: number;
12
+ password?: string;
13
+ }
14
+ export interface SasatConfigMigration {
15
+ table: string;
16
+ dir: string;
17
+ out: string;
18
+ target?: string;
19
+ }
20
+ export interface SasatConfigGenerator {
21
+ gql: {
22
+ subscription: boolean;
23
+ };
24
+ }
25
+ export interface SasatConfig {
26
+ db: SasatConfigDb;
27
+ migration: SasatConfigMigration;
28
+ generator: SasatConfigGenerator;
29
+ redis: SasatConfigRedis;
30
+ }
31
+ export declare type PartialSasatConfig = NestedPartial<SasatConfig>;
32
+ export declare const defaultConf: SasatConfig;
33
+ export declare const config: () => SasatConfig;
@@ -1,35 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const loader_1 = require("./loader");
4
- const defaultConfDb = {
5
- host: '127.0.0.1',
6
- port: 3306,
7
- user: 'root',
8
- database: 'sasat',
9
- password: '',
10
- };
11
- const defaultCofRedis = {
12
- host: '127.0.0.1',
13
- port: 6379,
14
- };
15
- const defaultConfMigration = {
16
- table: '__migrate__',
17
- dir: 'migrations',
18
- out: 'sasat',
19
- };
20
- exports.defaultConf = {
21
- db: defaultConfDb,
22
- migration: defaultConfMigration,
23
- generator: {
24
- gql: {
25
- subscription: true,
26
- },
27
- },
28
- redis: defaultCofRedis,
29
- };
30
- let conf;
31
- exports.config = () => {
32
- if (conf === undefined)
33
- conf = new loader_1.SasatConfigLoader().getConfig();
34
- return conf;
35
- };
1
+ import { SasatConfigLoader } from './loader.js';
2
+ const defaultConfDb = {
3
+ host: '127.0.0.1',
4
+ port: 3306,
5
+ user: 'root',
6
+ database: 'sasat',
7
+ password: '',
8
+ };
9
+ const defaultCofRedis = {
10
+ host: '127.0.0.1',
11
+ port: 6379,
12
+ };
13
+ const defaultConfMigration = {
14
+ table: '__migrate__',
15
+ dir: 'migrations',
16
+ out: 'sasat',
17
+ };
18
+ export const defaultConf = {
19
+ db: defaultConfDb,
20
+ migration: defaultConfMigration,
21
+ generator: {
22
+ gql: {
23
+ subscription: true,
24
+ },
25
+ },
26
+ redis: defaultCofRedis,
27
+ };
28
+ let conf;
29
+ export const config = () => {
30
+ if (conf === undefined)
31
+ conf = new SasatConfigLoader().getConfig();
32
+ return conf;
33
+ };
@@ -1,8 +1,8 @@
1
- import { SasatConfig } from './config';
2
- export declare class SasatConfigLoader {
3
- private static loadFile;
4
- readonly conf: SasatConfig;
5
- constructor();
6
- getConfig(): SasatConfig;
7
- private readValue;
8
- }
1
+ import { SasatConfig } from './config.js';
2
+ export declare class SasatConfigLoader {
3
+ private static loadConfig;
4
+ readonly conf: SasatConfig;
5
+ constructor();
6
+ getConfig(): SasatConfig;
7
+ private readValue;
8
+ }
@@ -1,41 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const path = require("path");
4
- const fs = require("fs");
5
- const config_1 = require("./config");
6
- const fsUtil_1 = require("../util/fsUtil");
7
- class SasatConfigLoader {
8
- constructor() {
9
- const conf = this.readValue({ ...config_1.defaultConf, ...SasatConfigLoader.loadFile() });
10
- this.conf = {
11
- ...conf,
12
- };
13
- }
14
- static loadFile() {
15
- const fileName = 'sasat.yml';
16
- const filepath = path.join(process.cwd(), fileName);
17
- if (!fs.existsSync(filepath))
18
- throw new Error(`${fileName} not Found in Project root folder`);
19
- return fsUtil_1.readYmlFile(filepath);
20
- }
21
- getConfig() {
22
- return this.conf;
23
- }
24
- readValue(value) {
25
- if (!value)
26
- return value;
27
- if (Array.isArray(value))
28
- return value.map(it => this.readValue(it));
29
- if (typeof value === 'string' && value.startsWith('$'))
30
- return process.env[value.slice(1)];
31
- if (typeof value === 'object') {
32
- for (const key in value) {
33
- if (Object.prototype.hasOwnProperty.call(value, key))
34
- value[key] = this.readValue(value[key]);
35
- }
36
- return value;
37
- }
38
- return value;
39
- }
40
- }
41
- exports.SasatConfigLoader = SasatConfigLoader;
1
+ import * as path from 'path';
2
+ import * as fs from 'fs';
3
+ import { defaultConf } from './config.js';
4
+ import { readYmlFile } from '../util/fsUtil.js';
5
+ export class SasatConfigLoader {
6
+ constructor() {
7
+ const conf = this.readValue({
8
+ ...defaultConf,
9
+ ...SasatConfigLoader.loadConfig(),
10
+ });
11
+ this.conf = {
12
+ ...conf,
13
+ };
14
+ }
15
+ static loadConfig() {
16
+ const fileName = 'sasat.yml';
17
+ const filepath = path.join(process.cwd(), fileName);
18
+ if (!fs.existsSync(filepath))
19
+ return defaultConf;
20
+ return readYmlFile(filepath);
21
+ }
22
+ getConfig() {
23
+ return this.conf;
24
+ }
25
+ readValue(value) {
26
+ if (!value)
27
+ return value;
28
+ if (Array.isArray(value))
29
+ return value.map(it => this.readValue(it));
30
+ if (typeof value === 'string' && value.startsWith('$'))
31
+ return process.env[value.slice(1)];
32
+ if (typeof value === 'object') {
33
+ for (const key in value) {
34
+ if (Object.prototype.hasOwnProperty.call(value, key))
35
+ value[key] = this.readValue(value[key]);
36
+ }
37
+ return value;
38
+ }
39
+ return value;
40
+ }
41
+ }