sasat 0.16.2 → 0.16.3

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.
@@ -34,7 +34,7 @@ export class GeneratedRepositoryGenerator {
34
34
  node.entityName.fieldTypeRef(Directory.paths.generatedDataSource.db),
35
35
  ])).addImport(['BaseDBDataSource'], Directory.basePath(Directory.paths.generatedDataSource.db, 'baseDBDataSource')))
36
36
  .addProperty(...this.properties(node))
37
- .addMethod(this.getDefaultValueMethod(node), ...this.findMethods(node)));
37
+ .addMethod(this.getDefaultValueMethod(node), ...this.findMethods(node))).disableEsLint();
38
38
  }
39
39
  sqlValueToTsExpression(value) {
40
40
  if (typeof value === 'string') {
@@ -5,7 +5,7 @@ export class EntityGenerator {
5
5
  this.node = node;
6
6
  }
7
7
  generate() {
8
- return new TsFile(this.entity(), this.creatable(), this.identifiable());
8
+ return new TsFile(this.entity(), this.creatable(), this.identifiable()).disableEsLint();
9
9
  }
10
10
  entity() {
11
11
  return tsg
@@ -7,7 +7,7 @@ export class FieldGenerator {
7
7
  .entities()
8
8
  .map(it => tsg
9
9
  .typeAlias(`${it.entityName}Fields`, tsg.intersectionType(tsg.typeRef('Fields').importFrom('sasat'), this.typeLiteral(it)))
10
- .export()));
10
+ .export())).disableEsLint();
11
11
  }
12
12
  typeLiteral(entity) {
13
13
  return tsg.typeLiteral([
@@ -2,9 +2,12 @@ import { TsCode } from './code/abstruct/tsCode.js';
2
2
  import { TsStatement } from './code/abstruct/statement.js';
3
3
  import { ImportDeclaration } from './code/importDeclaration.js';
4
4
  export declare class TsFile extends TsCode {
5
+ private esLintDisabled;
5
6
  private readonly statements;
6
7
  constructor(...statements: TsStatement[]);
7
8
  protected toTsString(): string;
8
9
  protected resolveImport(imports: ImportDeclaration[]): ImportDeclaration[];
10
+ disableEsLint(): this;
11
+ enableEsLint(): this;
9
12
  private static prettier;
10
13
  }
@@ -4,6 +4,7 @@ import { ImportDeclaration } from './code/importDeclaration.js';
4
4
  export class TsFile extends TsCode {
5
5
  constructor(...statements) {
6
6
  super();
7
+ this.esLintDisabled = false;
7
8
  this.mergeImport(...statements);
8
9
  this.statements = statements;
9
10
  }
@@ -14,7 +15,7 @@ export class TsFile extends TsCode {
14
15
  ]
15
16
  .map(it => it.toString())
16
17
  .join('\n');
17
- return TsFile.prettier(string);
18
+ return (this.esLintDisabled ? "/* eslint-disable */\n" : '') + TsFile.prettier(string);
18
19
  }
19
20
  resolveImport(imports) {
20
21
  const map = {};
@@ -28,6 +29,14 @@ export class TsFile extends TsCode {
28
29
  });
29
30
  return Object.entries(map).map(([module, types]) => new ImportDeclaration([...new Set(types)], module));
30
31
  }
32
+ disableEsLint() {
33
+ this.esLintDisabled = true;
34
+ return this;
35
+ }
36
+ enableEsLint() {
37
+ this.esLintDisabled = false;
38
+ return this;
39
+ }
31
40
  static prettier(code) {
32
41
  return prettier.format(code, { parser: 'typescript' });
33
42
  }
@@ -5,6 +5,6 @@ export class ContextGenerator {
5
5
  generate(contexts) {
6
6
  return new TsFile(new TsInterface('BaseGqlContext')
7
7
  .addProperties(contexts.map(it => new PropertySignature(it.name, it.type.toTsType())))
8
- .export());
8
+ .export()).disableEsLint();
9
9
  }
10
10
  }
@@ -13,7 +13,7 @@ import { MutationNode, } from '../../../parser/node/gql/mutationNode.js';
13
13
  export class MutationGenerator {
14
14
  constructor() {
15
15
  this.generate = (mutations) => {
16
- return new TsFile(new VariableDeclaration('const', new Identifier('mutation'), new ObjectLiteral(...mutations.flatMap(this.mutationToProperty))).export());
16
+ return new TsFile(new VariableDeclaration('const', new Identifier('mutation'), new ObjectLiteral(...mutations.flatMap(this.mutationToProperty))).export()).disableEsLint();
17
17
  };
18
18
  this.mutationToProperty = (node) => {
19
19
  if (MutationNode.isCreateMutation(node))
@@ -5,7 +5,7 @@ export class QueryGenerator {
5
5
  generate(nodes) {
6
6
  return new TsFile(tsg
7
7
  .variable('const', tsg.identifier('query'), tsg.object(...nodes.flatMap(node => this.entity(node))))
8
- .export()).addImport(['GraphQLResolveInfo'], 'graphql');
8
+ .export()).addImport(['GraphQLResolveInfo'], 'graphql').disableEsLint();
9
9
  }
10
10
  static createParams(node, query) {
11
11
  if (query.queryParams.length === 0)
@@ -53,6 +53,6 @@ export class ResolverGenerator {
53
53
  ];
54
54
  if (hasSubscription)
55
55
  properties.push(new PropertyAssignment('Subscription', new Identifier('subscription').importFrom('./subscription')));
56
- return new TsFile(new VariableDeclaration('const', new Identifier('resolvers'), new ObjectLiteral(...properties, new SpreadAssignment(new ObjectLiteral(...root.entities().map(this.entityResolver))))).export());
56
+ return new TsFile(new VariableDeclaration('const', new Identifier('resolvers'), new ObjectLiteral(...properties, new SpreadAssignment(new ObjectLiteral(...root.entities().map(this.entityResolver))))).export()).disableEsLint();
57
57
  }
58
58
  }
@@ -14,7 +14,7 @@ import { Directory } from '../../../constants/directory.js';
14
14
  export class SubscriptionGenerator {
15
15
  generate(nodes) {
16
16
  const data = this.createData(nodes);
17
- return this.createFile(data);
17
+ return this.createFile(data).disableEsLint();
18
18
  }
19
19
  createAsyncIteratorCall(event) {
20
20
  return new ArrowFunction([], undefined, new PropertyAccessExpression(new Identifier('pubsub').importFrom('../pubsub'), 'asyncIterator').call(new ArrayLiteral([new Identifier(`SubscriptionName.${event}`)])));
@@ -15,7 +15,7 @@ export class TypeDefGenerator {
15
15
  .variable('const', tsg.identifier('typeDefs'), tsg.object(...types))
16
16
  .export(), tsg
17
17
  .variable('const', tsg.identifier('inputs'), tsg.object(...this.createInputs(root)))
18
- .export());
18
+ .export()).disableEsLint();
19
19
  }
20
20
  createTypes(types) {
21
21
  return types.map(type => tsg.propertyAssign(type.typeName, tsg.array(type.params.map(it => tsg.string(it.toGqlString())))));
@@ -6,7 +6,7 @@ export class RelationMapGenerator {
6
6
  generate(root) {
7
7
  return new TsFile(this.relationMap(root), this.tableInfo(root), tsg
8
8
  .variable('const', 'dataStoreInfo', tsg.object(tsg.propertyAssign('tableInfo'), tsg.propertyAssign('relationMap')), tsg.typeRef('DataStoreInfo').importFrom('sasat'))
9
- .export(), ...root.entities().flatMap(this.entityRelationType));
9
+ .export(), ...root.entities().flatMap(this.entityRelationType)).disableEsLint();
10
10
  }
11
11
  relationMap(root) {
12
12
  return tsg.variable('const', tsg.identifier('relationMap'), tsg.object(...root.entities().map(it => this.entityRelationMap(it))), tsg.typeRef('RelationMap').importFrom('sasat'));
@@ -54,7 +54,7 @@ export class TableHandler {
54
54
  uniqueKeys: this.uniqueKeys,
55
55
  indexes: this.indexes,
56
56
  tableName: this.tableName,
57
- gqlOption: this.gqlOption,
57
+ gqlOption: JSON.parse(JSON.stringify(this.gqlOption)),
58
58
  };
59
59
  }
60
60
  addReferences(ref, fieldName, notNull = true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sasat",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "repository": "https://github.com/yanokunpei/sasat.git",
5
5
  "author": "yanokunpei <ninian138@gmail.com>",
6
6
  "license": "MIT",