sasat 0.14.1 → 0.14.4

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.
@@ -4,10 +4,9 @@ import { config } from '../../config/config.js';
4
4
  import { capitalizeFirstLetter } from '../../util/stringUtil.js';
5
5
  import { mkDirIfNotExist } from '../../util/fsUtil.js';
6
6
  import { Console } from '../console.js';
7
- const getMigrationFile = (className) => `import { SasatMigration } from "sasat";
8
- import { MigrationStore } from "sasat";
7
+ const getMigrationFile = (className) => `import { SasatMigration, MigrationStore } from "sasat";
9
8
 
10
- export class ${capitalizeFirstLetter(className)} implements SasatMigration {
9
+ class ${capitalizeFirstLetter(className)} implements SasatMigration {
11
10
 
12
11
  up: (store: MigrationStore) => void = store => {
13
12
 
@@ -18,6 +17,10 @@ export class ${capitalizeFirstLetter(className)} implements SasatMigration {
18
17
  };
19
18
  }
20
19
 
20
+
21
+ // DO NOT EDIT (last line is used)
22
+ new ${capitalizeFirstLetter(className)}()
23
+
21
24
  `;
22
25
  export const createMigrationFile = (migrationName) => {
23
26
  const date = new Date();
@@ -1,5 +1,5 @@
1
- import * as path from 'path';
2
- import * as fs from 'fs';
1
+ import path from 'path';
2
+ import fs from 'fs-extra';
3
3
  import { defaultConf } from './config.js';
4
4
  import { readYmlFile } from '../util/fsUtil.js';
5
5
  export class SasatConfigLoader {
@@ -4,7 +4,7 @@ const EntityDirName = 'entities';
4
4
  const DataSourceDirName = 'dataSources';
5
5
  const GeneratedDataSourceDirName = 'dataSources';
6
6
  const relative = (from, to) => {
7
- const result = path.relative(from, to);
7
+ const result = path.posix.relative(from, to);
8
8
  if (result.startsWith('../'))
9
9
  return result;
10
10
  return './' + result;
@@ -4,6 +4,6 @@ export class ImportDeclaration {
4
4
  this.module = module;
5
5
  }
6
6
  toString() {
7
- return `import {${this.types.join(',')}} from "${this.module}";`;
7
+ return `import {${this.types.join(',')}} from "${this.module.startsWith('.') ? this.module + '.js' : this.module}";`;
8
8
  }
9
9
  }
@@ -4,8 +4,8 @@ import { tsg } from '../code/factory.js';
4
4
  export class QueryGenerator {
5
5
  generate(nodes) {
6
6
  return new TsFile(tsg
7
- .variable('const', tsg.identifier('query'), tsg.object(...nodes.flatMap(node => this.entity(node))), tsg.typeRef('IResolverObject').importFrom('graphql-tools'))
8
- .export());
7
+ .variable('const', tsg.identifier('query'), tsg.object(...nodes.flatMap(node => this.entity(node))), tsg.typeRef('IResolvers').importFrom('@graphql-tools/utils/Interfaces'))
8
+ .export()).addImport(['GraphQLResolveInfo'], 'graphql');
9
9
  }
10
10
  entity(node) {
11
11
  const createParams = (query) => {
@@ -14,14 +14,14 @@ export class QueryGenerator {
14
14
  tsg.parameter('_1', tsg.typeRef('unknown')),
15
15
  tsg.parameter('_2', tsg.typeRef('unknown')),
16
16
  tsg.parameter('_3', tsg.typeRef('unknown')),
17
- tsg.parameter('info'),
17
+ tsg.parameter('info', tsg.typeRef('GraphQLResolveInfo')),
18
18
  ];
19
19
  const paramNames = query.queryParams.map(it => it.name);
20
20
  return [
21
21
  tsg.parameter('_1', tsg.typeRef('unknown')),
22
22
  tsg.parameter(`{ ${paramNames.join(',')} }`, node.entityName.getTypeReference(Directory.paths.generated).pick(...paramNames)),
23
23
  tsg.parameter('_2', tsg.typeRef('unknown')),
24
- tsg.parameter('info'),
24
+ tsg.parameter('info', tsg.typeRef('GraphQLResolveInfo')),
25
25
  ];
26
26
  };
27
27
  return node.queries.map(it => tsg.propertyAssign(it.queryName, tsg.arrowFunc(createParams(it), undefined, tsg
@@ -1,17 +1,16 @@
1
1
  const contextFile = `\
2
- import { BaseGqlContext } from './__generated__/context';
2
+ import { BaseGqlContext } from './__generated__/context.js';
3
3
  export interface GqlContext extends BaseGqlContext {}
4
4
  `;
5
5
  const pubsubFile = `\
6
- import { PubSub } from "apollo-server";
7
- import { PubSubEngine } from "graphql-subscriptions";
6
+ import { PubSub, PubSubEngine } from "graphql-subscriptions";
8
7
 
9
8
  export const pubsub: PubSubEngine = new PubSub();
10
9
  `;
11
10
  const schemaFile = `\
12
11
  import { assignDeep, createTypeDef } from "sasat";
13
- import { typeDef } from "./__generated__/typeDefs";
14
- import { resolvers } from "./__generated__/resolver";
12
+ import { typeDef } from "./__generated__/typeDefs.js";
13
+ import { resolvers } from "./__generated__/resolver.js";
15
14
 
16
15
  export const schema = {
17
16
  typeDefs: createTypeDef(assignDeep(typeDef, {})),
@@ -19,8 +18,8 @@ export const schema = {
19
18
  };
20
19
  `;
21
20
  const baseDBDataSourceFile = `\
22
- import { Fields, SasatRepository } from '../../src';
23
- import { dataStoreInfo } from './__generated__/relationMap';
21
+ import { Fields, SasatRepository } from 'sasat';
22
+ import { dataStoreInfo } from './__generated__/relationMap.js';
24
23
 
25
24
 
26
25
  export abstract class BaseDBDataSource<Entity, Creatable, Identifiable, EntityFields extends Fields> extends SasatRepository<
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sasat",
3
- "version": "0.14.1",
3
+ "version": "0.14.4",
4
4
  "repository": "https://github.com/yanokunpei/sasat.git",
5
5
  "author": "yanokunpei <ninian138@gmail.com>",
6
6
  "license": "MIT",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "scripts": {
16
16
  "start": "env-cmd .env ts-node ./index.ts",
17
- "build": "rm -rf ./lib && yarn tsc",
17
+ "build": "yarn tsc",
18
18
  "lint": "eslint 'src/**/*.ts'",
19
19
  "fmt": "yarn lint --fix && yarn prettier",
20
20
  "prettier": "prettier --write './**/*.ts'",
@@ -29,13 +29,15 @@
29
29
  "cac": "6.7.12",
30
30
  "chalk": "5.0.1",
31
31
  "fs-extra": "^10.0.0",
32
+ "graphql-subscriptions": "^2.0.0",
32
33
  "js-yaml": "^4.0.0",
33
34
  "mariadb": "^2.1.5",
34
35
  "mysql": "^2.17.1",
35
36
  "pluralize": "^8.0.0",
36
37
  "prettier": "^2.0.0",
37
38
  "sqlstring": "^2.3.1",
38
- "typescript": "4.6.3"
39
+ "typescript": "4.6.3",
40
+ "graphql": "^16.3.0"
39
41
  },
40
42
  "devDependencies": {
41
43
  "@types/fs-extra": "9.0.13",
@@ -53,7 +55,6 @@
53
55
  "eslint": "8.13.0",
54
56
  "eslint-config-prettier": "8.5.0",
55
57
  "eslint-plugin-prettier": "4.0.0",
56
- "graphql": "16.3.0",
57
58
  "husky": "7.0.4",
58
59
  "jest": "27.5.1",
59
60
  "lint-staged": "12.3.7",