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.
- package/lib/cli/cli.d.ts +2 -2
- package/lib/cli/cli.js +30 -21
- package/lib/cli/commands/createMigration.d.ts +2 -2
- package/lib/cli/commands/createMigration.js +36 -38
- package/lib/cli/commands/dumpDb.d.ts +1 -0
- package/lib/cli/commands/dumpDb.js +42 -0
- package/lib/cli/commands/generate.d.ts +1 -1
- package/lib/cli/commands/generate.js +19 -21
- package/lib/cli/commands/init.d.ts +1 -1
- package/lib/cli/commands/init.js +12 -14
- package/lib/cli/commands/migrate.d.ts +3 -3
- package/lib/cli/commands/migrate.js +29 -31
- package/lib/cli/console.d.ts +5 -5
- package/lib/cli/console.js +12 -14
- package/lib/config/config.d.ts +33 -33
- package/lib/config/config.js +33 -35
- package/lib/config/loader.d.ts +8 -8
- package/lib/config/loader.js +41 -41
- package/lib/constants/directory.d.ts +20 -0
- package/lib/constants/directory.js +34 -0
- package/lib/constants/interfaceConstants.d.ts +6 -0
- package/lib/constants/interfaceConstants.js +6 -0
- package/lib/db/{dbClient.d.ts → connectors/dbClient.d.ts} +31 -28
- package/lib/db/connectors/dbClient.js +26 -0
- package/lib/db/{mariadb → connectors/mariadb}/client.d.ts +8 -8
- package/lib/db/connectors/mariadb/client.js +24 -0
- package/lib/db/{mariadb → connectors/mariadb}/transaction.d.ts +9 -9
- package/lib/db/{mariadb → connectors/mariadb}/transaction.js +20 -23
- package/lib/db/connectors/mockClient.d.ts +13 -0
- package/lib/db/connectors/mockClient.js +26 -0
- package/lib/db/{mysql → connectors/mysql}/client.d.ts +8 -8
- package/lib/db/connectors/mysql/client.js +27 -0
- package/lib/db/{mysql → connectors/mysql}/transaction.d.ts +9 -9
- package/lib/db/connectors/mysql/transaction.js +22 -0
- package/lib/db/formatQuery.d.ts +1 -1
- package/lib/db/formatQuery.js +14 -16
- package/lib/db/getDbClient.d.ts +2 -2
- package/lib/db/getDbClient.js +8 -9
- package/lib/db/sql/columnToSql.d.ts +2 -0
- package/lib/{sql → db/sql}/columnToSql.js +27 -29
- package/lib/db/sql/condition.d.ts +22 -0
- package/lib/db/sql/condition.js +50 -0
- package/lib/db/sql/createTable/createTableParser.d.ts +17 -0
- package/lib/db/sql/createTable/createTableParser.js +241 -0
- package/lib/db/sql/createTable/createTableSerializer.d.ts +2 -0
- package/lib/db/sql/createTable/createTableSerializer.js +135 -0
- package/lib/db/sql/createTable/lexer/columnLexer.d.ts +2 -0
- package/lib/db/sql/createTable/lexer/columnLexer.js +20 -0
- package/lib/db/sql/createTable/lexer/createSimpleLexer.d.ts +3 -0
- package/lib/db/sql/createTable/lexer/createSimpleLexer.js +8 -0
- package/lib/db/sql/createTable/lexer/createTableLexer.d.ts +2 -0
- package/lib/db/sql/createTable/lexer/createTableLexer.js +22 -0
- package/lib/db/sql/createTable/lexer/lexer.d.ts +30 -0
- package/lib/db/sql/createTable/lexer/lexer.js +126 -0
- package/lib/db/sql/createTable/lexer/lexer2.d.ts +22 -0
- package/lib/db/sql/createTable/lexer/lexer2.js +110 -0
- package/lib/db/sql/createTable/lexer/rules.d.ts +21 -0
- package/lib/db/sql/createTable/lexer/rules.js +92 -0
- package/lib/db/sql/expression/comparison.d.ts +19 -0
- package/lib/db/sql/expression/comparison.js +36 -0
- package/lib/db/sql/expression/compositeCondition.d.ts +9 -0
- package/lib/db/sql/expression/compositeCondition.js +16 -0
- package/lib/db/sql/expression/conditionExpression.d.ts +5 -0
- package/lib/db/sql/expression/conditionExpression.js +10 -0
- package/lib/db/sql/sqlCreater.d.ts +8 -0
- package/lib/db/sql/sqlCreater.js +12 -0
- package/lib/error.d.ts +3 -3
- package/lib/error.js +7 -10
- package/lib/generator/controller.d.ts +20 -21
- package/lib/generator/controller.js +68 -64
- package/lib/generator/generator.d.ts +21 -21
- package/lib/generator/generator.js +1 -2
- package/lib/generator/gql/columnToGqlType.d.ts +3 -3
- package/lib/generator/gql/columnToGqlType.js +27 -29
- package/lib/generator/gql/types.d.ts +7 -7
- package/lib/generator/gql/types.js +8 -10
- package/lib/generator/ts/code/abstruct/exportableDeclaration.d.ts +6 -0
- package/lib/generator/ts/code/abstruct/exportableDeclaration.js +14 -0
- package/lib/generator/ts/code/abstruct/statement.d.ts +4 -0
- package/lib/generator/ts/code/abstruct/statement.js +7 -0
- package/lib/generator/ts/code/abstruct/tsCode.d.ts +9 -0
- package/lib/generator/ts/code/abstruct/tsCode.js +22 -0
- package/lib/generator/ts/code/accessors.d.ts +5 -0
- package/lib/generator/ts/code/accessors.js +6 -0
- package/lib/generator/ts/code/factory.d.ts +68 -0
- package/lib/generator/ts/code/factory.js +80 -0
- package/lib/generator/ts/code/importDeclaration.d.ts +6 -0
- package/lib/generator/ts/code/importDeclaration.js +9 -0
- package/lib/generator/ts/code/node/ExpressionStatement.d.ts +7 -0
- package/lib/generator/ts/code/node/ExpressionStatement.js +11 -0
- package/lib/generator/ts/code/node/block.d.ts +6 -0
- package/lib/generator/ts/code/node/block.js +11 -0
- package/lib/generator/ts/code/node/class.d.ts +20 -0
- package/lib/generator/ts/code/node/class.js +42 -0
- package/lib/generator/ts/code/node/enumDeclaration.d.ts +10 -0
- package/lib/generator/ts/code/node/enumDeclaration.js +17 -0
- package/lib/generator/ts/code/node/enumMember.d.ts +8 -0
- package/lib/generator/ts/code/node/enumMember.js +16 -0
- package/lib/generator/ts/code/node/expressions.d.ts +103 -0
- package/lib/generator/ts/code/node/expressions.js +188 -0
- package/lib/generator/ts/code/node/extendsClause.d.ts +7 -0
- package/lib/generator/ts/code/node/extendsClause.js +11 -0
- package/lib/generator/ts/code/node/ifStatement.d.ts +8 -0
- package/lib/generator/ts/code/node/ifStatement.js +12 -0
- package/lib/generator/ts/code/node/implementsClause.d.ts +7 -0
- package/lib/generator/ts/code/node/implementsClause.js +11 -0
- package/lib/generator/ts/code/node/interface.d.ts +11 -0
- package/lib/generator/ts/code/node/interface.js +21 -0
- package/lib/generator/ts/code/node/methodDeclaration.d.ts +16 -0
- package/lib/generator/ts/code/node/methodDeclaration.js +30 -0
- package/lib/generator/ts/code/node/modifier/methodModifiers.d.ts +7 -0
- package/lib/generator/ts/code/node/modifier/methodModifiers.js +15 -0
- package/lib/generator/ts/code/node/modifier/modifiers.d.ts +17 -0
- package/lib/generator/ts/code/node/modifier/modifiers.js +47 -0
- package/lib/generator/ts/code/node/modifier/propertyModifiers.d.ts +10 -0
- package/lib/generator/ts/code/node/modifier/propertyModifiers.js +21 -0
- package/lib/generator/ts/code/node/parameter.d.ts +9 -0
- package/lib/generator/ts/code/node/parameter.js +17 -0
- package/lib/generator/ts/code/node/propertyAssignment.d.ts +8 -0
- package/lib/generator/ts/code/node/propertyAssignment.js +14 -0
- package/lib/generator/ts/code/node/propertyDeclaration.d.ts +15 -0
- package/lib/generator/ts/code/node/propertyDeclaration.js +32 -0
- package/lib/generator/ts/code/node/propertySignature.d.ts +11 -0
- package/lib/generator/ts/code/node/propertySignature.js +18 -0
- package/lib/generator/ts/code/node/rawCodeStatement.d.ts +6 -0
- package/lib/generator/ts/code/node/rawCodeStatement.js +10 -0
- package/lib/generator/ts/code/node/returnStatement.d.ts +7 -0
- package/lib/generator/ts/code/node/returnStatement.js +11 -0
- package/lib/generator/ts/code/node/spreadAssignment.d.ts +7 -0
- package/lib/generator/ts/code/node/spreadAssignment.js +11 -0
- package/lib/generator/ts/code/node/type/arrayType.d.ts +7 -0
- package/lib/generator/ts/code/node/type/arrayType.js +13 -0
- package/lib/generator/ts/code/node/type/intersectionType.d.ts +8 -0
- package/lib/generator/ts/code/node/type/intersectionType.js +11 -0
- package/lib/generator/ts/code/node/type/type.d.ts +10 -0
- package/lib/generator/ts/code/node/type/type.js +3 -0
- package/lib/generator/ts/code/node/type/typeAliasDeclaration.d.ts +8 -0
- package/lib/generator/ts/code/node/type/typeAliasDeclaration.js +14 -0
- package/lib/generator/ts/code/node/type/typeKeyword.d.ts +15 -0
- package/lib/generator/ts/code/node/type/typeKeyword.js +15 -0
- package/lib/generator/ts/code/node/type/typeLiteral.d.ts +9 -0
- package/lib/generator/ts/code/node/type/typeLiteral.js +16 -0
- package/lib/generator/ts/code/node/type/typeReference.d.ts +12 -0
- package/lib/generator/ts/code/node/type/typeReference.js +25 -0
- package/lib/generator/ts/code/node/type/unionType.d.ts +7 -0
- package/lib/generator/ts/code/node/type/unionType.js +13 -0
- package/lib/generator/ts/code/node/variableDeclaration.d.ts +13 -0
- package/lib/generator/ts/code/node/variableDeclaration.js +16 -0
- package/lib/generator/ts/code/tsUtil.d.ts +4 -0
- package/lib/generator/ts/code/tsUtil.js +4 -0
- package/lib/generator/ts/db/generatedRepositoryGenerator.d.ts +11 -0
- package/lib/generator/ts/db/generatedRepositoryGenerator.js +110 -0
- package/lib/generator/ts/db/repositoryGenerator.d.ts +5 -0
- package/lib/generator/ts/db/repositoryGenerator.js +13 -0
- package/lib/generator/ts/entityGenerator.d.ts +10 -0
- package/lib/generator/ts/entityGenerator.js +27 -0
- package/lib/generator/ts/fieldGenerator.d.ts +6 -0
- package/lib/generator/ts/fieldGenerator.js +25 -0
- package/lib/generator/ts/file.d.ts +10 -0
- package/lib/generator/ts/file.js +31 -0
- package/lib/generator/ts/generator.d.ts +18 -22
- package/lib/generator/ts/generator.js +53 -86
- package/lib/generator/ts/gql/contextGenerator.d.ts +5 -0
- package/lib/generator/ts/gql/contextGenerator.js +10 -0
- package/lib/generator/ts/gql/mutationGenerator.d.ts +15 -0
- package/lib/generator/ts/gql/mutationGenerator.js +87 -0
- package/lib/generator/ts/gql/queryGenerator.d.ts +6 -0
- package/lib/generator/ts/gql/queryGenerator.js +38 -0
- package/lib/generator/ts/gql/resolverGenerator.d.ts +8 -0
- package/lib/generator/ts/gql/resolverGenerator.js +45 -0
- package/lib/generator/ts/gql/subscriptionGenerator.d.ts +9 -0
- package/lib/generator/ts/gql/subscriptionGenerator.js +58 -0
- package/lib/generator/ts/gql/typeDefGenerator.d.ts +9 -0
- package/lib/generator/ts/gql/typeDefGenerator.js +42 -0
- package/lib/generator/ts/relationMapGenerator.d.ts +9 -0
- package/lib/generator/ts/relationMapGenerator.js +56 -0
- package/lib/generator/ts/staticFiles.d.ts +2 -0
- package/lib/generator/ts/staticFiles.js +52 -0
- package/lib/generator/ts/{code/value.d.ts → tsValueString.d.ts} +1 -1
- package/lib/generator/ts/{code/value.js → tsValueString.js} +27 -29
- package/lib/index.d.ts +17 -8
- package/lib/index.js +8 -14
- package/lib/migration/column/columnTypes.d.ts +27 -26
- package/lib/migration/column/columnTypes.js +44 -46
- package/lib/migration/controller.d.ts +12 -12
- package/lib/migration/controller.js +72 -68
- package/lib/migration/{column → creators}/columnBuilder.d.ts +91 -88
- package/lib/migration/{column → creators}/columnBuilder.js +179 -181
- package/lib/migration/{column → creators}/columnCreator.d.ts +24 -24
- package/lib/migration/creators/columnCreator.js +28 -0
- package/lib/migration/{tableCreator.d.ts → creators/tableCreator.d.ts} +33 -33
- package/lib/migration/{tableCreator.js → creators/tableCreator.js} +53 -63
- package/lib/{entity → migration/data}/foreignKey.d.ts +9 -14
- package/lib/migration/data/foreignKey.js +1 -0
- package/lib/migration/{gqlOption.d.ts → data/gqlOption.d.ts} +21 -20
- package/lib/migration/{gqlOption.js → data/gqlOption.js} +28 -31
- package/lib/{entity → migration/data}/index.d.ts +15 -13
- package/lib/{entity → migration/data}/index.js +22 -19
- package/lib/migration/data/relation.d.ts +1 -0
- package/lib/migration/data/relation.js +1 -0
- package/lib/migration/dataStore.d.ts +12 -0
- package/lib/migration/dataStore.js +17 -0
- package/lib/migration/{migration.d.ts → front/migration.d.ts} +9 -9
- package/lib/migration/front/migration.js +1 -0
- package/lib/migration/{storeMigrator.d.ts → front/storeMigrator.d.ts} +23 -22
- package/lib/migration/front/storeMigrator.js +53 -0
- package/lib/migration/front/tableMigrator.d.ts +39 -0
- package/lib/migration/front/tableMigrator.js +84 -0
- package/lib/migration/functions/assembleColumn.d.ts +4 -0
- package/lib/migration/functions/assembleColumn.js +7 -0
- package/lib/migration/migrationReader.d.ts +7 -6
- package/lib/migration/migrationReader.js +54 -40
- package/lib/migration/migrationTargetResolver.d.ts +9 -9
- package/lib/migration/migrationTargetResolver.js +34 -37
- package/lib/migration/serializable/column.d.ts +41 -0
- package/lib/migration/serializable/column.js +59 -0
- package/lib/migration/serializable/serializable.d.ts +3 -0
- package/lib/migration/serializable/serializable.js +1 -0
- package/lib/migration/serializable/table.d.ts +48 -0
- package/lib/migration/serializable/table.js +161 -0
- package/lib/migration/serialized/serializedColumn.d.ts +38 -0
- package/lib/migration/serialized/serializedColumn.js +10 -0
- package/lib/migration/serialized/serializedStore.d.ts +14 -0
- package/lib/migration/serialized/serializedStore.js +1 -0
- package/lib/parser/node/entityName.d.ts +22 -0
- package/lib/parser/node/entityName.js +59 -0
- package/lib/parser/node/entityNode.d.ts +23 -0
- package/lib/parser/node/entityNode.js +43 -0
- package/lib/parser/node/fieldNode.d.ts +25 -0
- package/lib/parser/node/fieldNode.js +43 -0
- package/lib/parser/node/findMethod.d.ts +10 -0
- package/lib/parser/node/findMethod.js +12 -0
- package/lib/parser/node/gql/contextNode.d.ts +6 -0
- package/lib/parser/node/gql/contextNode.js +6 -0
- package/lib/parser/node/gql/contextParamNode.d.ts +5 -0
- package/lib/parser/node/gql/contextParamNode.js +6 -0
- package/lib/parser/node/gql/mutationNode.d.ts +43 -0
- package/lib/parser/node/gql/mutationNode.js +68 -0
- package/lib/parser/node/gql/queryNode.d.ts +10 -0
- package/lib/parser/node/gql/queryNode.js +12 -0
- package/lib/parser/node/gql/subscriptionFilterNode.d.ts +6 -0
- package/lib/parser/node/gql/subscriptionFilterNode.js +6 -0
- package/lib/parser/node/gql/typeDefNode.d.ts +9 -0
- package/lib/parser/node/gql/typeDefNode.js +21 -0
- package/lib/parser/node/parameterNode.d.ts +8 -0
- package/lib/parser/node/parameterNode.js +12 -0
- package/lib/parser/node/relationNode.d.ts +20 -0
- package/lib/parser/node/relationNode.js +31 -0
- package/lib/parser/node/repositoryNode.d.ts +21 -0
- package/lib/parser/node/repositoryNode.js +55 -0
- package/lib/parser/node/rootNode.d.ts +20 -0
- package/lib/parser/node/rootNode.js +28 -0
- package/lib/parser/node/typeNode.d.ts +12 -0
- package/lib/parser/node/typeNode.js +28 -0
- package/lib/parser/nodeFactory/contextNodeFactory.d.ts +5 -0
- package/lib/parser/nodeFactory/contextNodeFactory.js +12 -0
- package/lib/parser/nodeFactory/mutationNodeFactory.d.ts +7 -0
- package/lib/parser/nodeFactory/mutationNodeFactory.js +33 -0
- package/lib/parser/nodeFactory/queryNodeFactory.d.ts +7 -0
- package/lib/parser/nodeFactory/queryNodeFactory.js +17 -0
- package/lib/parser/parser.d.ts +5 -0
- package/lib/parser/parser.js +10 -0
- package/lib/{createTypeDef.d.ts → runtime/createTypeDef.d.ts} +1 -1
- package/lib/{createTypeDef.js → runtime/createTypeDef.js} +4 -6
- package/lib/runtime/dsl/factory.d.ts +30 -0
- package/lib/runtime/dsl/factory.js +108 -0
- package/lib/runtime/dsl/mutation/mutation.d.ts +24 -0
- package/lib/runtime/dsl/mutation/mutation.js +20 -0
- package/lib/runtime/dsl/query/createQueryResolveInfo.d.ts +26 -0
- package/lib/runtime/dsl/query/createQueryResolveInfo.js +25 -0
- package/lib/runtime/dsl/query/fieldToQuery.d.ts +4 -0
- package/lib/runtime/dsl/query/fieldToQuery.js +22 -0
- package/lib/runtime/dsl/query/query.d.ts +106 -0
- package/lib/runtime/dsl/query/query.js +16 -0
- package/lib/runtime/dsl/query/sql/hydrate.d.ts +13 -0
- package/lib/runtime/dsl/query/sql/hydrate.js +81 -0
- package/lib/runtime/dsl/query/sql/nodeToSql.d.ts +22 -0
- package/lib/runtime/dsl/query/sql/nodeToSql.js +63 -0
- package/lib/runtime/dsl/query/sql/queryToSql.d.ts +2 -0
- package/lib/runtime/dsl/query/sql/queryToSql.js +13 -0
- package/lib/runtime/dsl/replaceAliases.d.ts +4 -0
- package/lib/runtime/dsl/replaceAliases.js +66 -0
- package/lib/runtime/field.d.ts +5 -0
- package/lib/runtime/field.js +1 -0
- package/lib/runtime/gqlResolveInfoToField.d.ts +3 -0
- package/lib/runtime/gqlResolveInfoToField.js +25 -0
- package/lib/runtime/sasatRepository.d.ts +31 -0
- package/lib/runtime/sasatRepository.js +75 -0
- package/lib/runtime/sql/sqlString.d.ts +5 -0
- package/lib/runtime/sql/sqlString.js +6 -0
- package/lib/util/arrayUtil.d.ts +3 -3
- package/lib/util/arrayUtil.js +11 -13
- package/lib/util/assignDeep.d.ts +5 -5
- package/lib/util/assignDeep.js +21 -23
- package/lib/util/dateUtil.d.ts +1 -1
- package/lib/util/dateUtil.js +20 -22
- package/lib/util/fsUtil.d.ts +7 -4
- package/lib/util/fsUtil.js +37 -19
- package/lib/util/stringUtil.d.ts +4 -3
- package/lib/util/stringUtil.js +12 -8
- package/lib/util/type.d.ts +3 -3
- package/lib/util/type.js +1 -2
- package/package.json +37 -29
- package/lib/compiler/compiler.d.ts +0 -12
- package/lib/compiler/compiler.js +0 -100
- package/lib/compiler/gqlCompiler.d.ts +0 -13
- package/lib/compiler/gqlCompiler.js +0 -181
- package/lib/db/dbClient.js +0 -24
- package/lib/db/mariadb/client.js +0 -26
- package/lib/db/mysql/client.js +0 -27
- package/lib/db/mysql/transaction.js +0 -24
- package/lib/entity/assembleColumn.d.ts +0 -5
- package/lib/entity/assembleColumn.js +0 -10
- package/lib/entity/column.d.ts +0 -33
- package/lib/entity/column.js +0 -45
- package/lib/entity/dataStore.d.ts +0 -12
- package/lib/entity/dataStore.js +0 -17
- package/lib/entity/foreignKey.js +0 -9
- package/lib/entity/referenceColumn.d.ts +0 -33
- package/lib/entity/referenceColumn.js +0 -56
- package/lib/entity/relation.d.ts +0 -5
- package/lib/entity/relation.js +0 -8
- package/lib/entity/serializedStore.d.ts +0 -16
- package/lib/entity/serializedStore.js +0 -2
- package/lib/entity/table.d.ts +0 -40
- package/lib/entity/table.js +0 -112
- package/lib/generator/gql/typeDef.d.ts +0 -8
- package/lib/generator/gql/typeDef.js +0 -13
- package/lib/generator/ts/code/array.d.ts +0 -1
- package/lib/generator/ts/code/array.js +0 -4
- package/lib/generator/ts/code/arrowFunction.d.ts +0 -4
- package/lib/generator/ts/code/arrowFunction.js +0 -4
- package/lib/generator/ts/code/nestedObject.d.ts +0 -7
- package/lib/generator/ts/code/nestedObject.js +0 -30
- package/lib/generator/ts/code/object.d.ts +0 -6
- package/lib/generator/ts/code/object.js +0 -20
- package/lib/generator/ts/file/entity.d.ts +0 -2
- package/lib/generator/ts/file/entity.js +0 -24
- package/lib/generator/ts/file/generatedRepository.d.ts +0 -13
- package/lib/generator/ts/file/generatedRepository.js +0 -126
- package/lib/generator/ts/file/repository.d.ts +0 -2
- package/lib/generator/ts/file/repository.js +0 -7
- package/lib/generator/ts/gql/context.d.ts +0 -5
- package/lib/generator/ts/gql/context.js +0 -17
- package/lib/generator/ts/gql/mutation.d.ts +0 -13
- package/lib/generator/ts/gql/mutation.js +0 -88
- package/lib/generator/ts/gql/query.d.ts +0 -2
- package/lib/generator/ts/gql/query.js +0 -25
- package/lib/generator/ts/gql/resolver.d.ts +0 -7
- package/lib/generator/ts/gql/resolver.js +0 -31
- package/lib/generator/ts/gql/subscription.d.ts +0 -5
- package/lib/generator/ts/gql/subscription.js +0 -49
- package/lib/generator/ts/gql/typeDef.d.ts +0 -2
- package/lib/generator/ts/gql/typeDef.js +0 -50
- package/lib/generator/ts/tsClassGenerator.d.ts +0 -45
- package/lib/generator/ts/tsClassGenerator.js +0 -59
- package/lib/generator/ts/tsFileGenerator.d.ts +0 -12
- package/lib/generator/ts/tsFileGenerator.js +0 -27
- package/lib/ir/entity.d.ts +0 -14
- package/lib/ir/entity.js +0 -2
- package/lib/ir/gql/context.d.ts +0 -5
- package/lib/ir/gql/context.js +0 -2
- package/lib/ir/gql/index.d.ts +0 -12
- package/lib/ir/gql/index.js +0 -2
- package/lib/ir/gql/mutation.d.ts +0 -29
- package/lib/ir/gql/mutation.js +0 -2
- package/lib/ir/gql/query.d.ts +0 -15
- package/lib/ir/gql/query.js +0 -8
- package/lib/ir/gql/resolver.d.ts +0 -8
- package/lib/ir/gql/resolver.js +0 -2
- package/lib/ir/gql/types.d.ts +0 -12
- package/lib/ir/gql/types.js +0 -2
- package/lib/ir/ir.d.ts +0 -6
- package/lib/ir/ir.js +0 -2
- package/lib/ir/repository.d.ts +0 -34
- package/lib/ir/repository.js +0 -2
- package/lib/migration/column/columnCreator.js +0 -31
- package/lib/migration/column/columnData.d.ts +0 -68
- package/lib/migration/column/columnData.js +0 -2
- package/lib/migration/migration.js +0 -2
- package/lib/migration/storeMigrator.js +0 -48
- package/lib/migration/tableMigrator.d.ts +0 -30
- package/lib/migration/tableMigrator.js +0 -52
- package/lib/sasatRepository.d.ts +0 -30
- package/lib/sasatRepository.js +0 -63
- package/lib/sql/columnToSql.d.ts +0 -2
- package/lib/sql/condition.d.ts +0 -32
- package/lib/sql/condition.js +0 -49
- package/lib/sql/sqlCreater.d.ts +0 -10
- 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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
cli
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
cli.
|
|
20
|
-
|
|
21
|
-
cli.
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 ${
|
|
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
|
-
|
|
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 =
|
|
36
|
-
|
|
37
|
-
fs.writeFileSync(
|
|
38
|
-
return fileName;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
if (!args) {
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (!/^[$A-Za-z_][0-9A-Za-z_]+$/.test(args)) {
|
|
46
|
-
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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;
|
package/lib/cli/commands/init.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
+
};
|
package/lib/cli/console.d.ts
CHANGED
|
@@ -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
|
+
};
|
package/lib/cli/console.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
};
|
package/lib/config/config.d.ts
CHANGED
|
@@ -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;
|
package/lib/config/config.js
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
};
|
package/lib/config/loader.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { SasatConfig } from './config';
|
|
2
|
-
export declare class SasatConfigLoader {
|
|
3
|
-
private static
|
|
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
|
+
}
|
package/lib/config/loader.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
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
|
+
}
|