sofa-api 0.5.0 → 0.7.0

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 (55) hide show
  1. package/{dist/ast.d.ts → ast.d.ts} +7 -7
  2. package/{dist/common.d.ts → common.d.ts} +2 -1
  3. package/express.d.ts +5 -0
  4. package/index.cjs.js +1058 -0
  5. package/{dist/index.d.ts → index.d.ts} +6 -6
  6. package/index.esm.js +1050 -0
  7. package/{dist/logger.d.ts → logger.d.ts} +1 -1
  8. package/{dist/open-api → open-api}/index.d.ts +14 -12
  9. package/{dist/open-api → open-api}/interfaces.d.ts +325 -325
  10. package/{dist/open-api → open-api}/operations.d.ts +7 -7
  11. package/{dist/open-api → open-api}/types.d.ts +3 -3
  12. package/{dist/open-api → open-api}/utils.d.ts +2 -2
  13. package/{dist/operation.d.ts → operation.d.ts} +12 -12
  14. package/package.json +23 -71
  15. package/{dist/parse.d.ts → parse.d.ts} +6 -6
  16. package/{dist/sofa.d.ts → sofa.d.ts} +33 -33
  17. package/{dist/subscriptions.d.ts → subscriptions.d.ts} +38 -38
  18. package/{dist/types.d.ts → types.d.ts} +17 -17
  19. package/.DS_Store +0 -0
  20. package/.git/logs/refs/remotes/origin/changelog +0 -1
  21. package/.git/refs/remotes/origin/changelog +0 -1
  22. package/CHANGELOG.md +0 -30
  23. package/LICENSE +0 -21
  24. package/README.md +0 -276
  25. package/dist/ast.js +0 -16
  26. package/dist/ast.js.map +0 -1
  27. package/dist/common.js +0 -8
  28. package/dist/common.js.map +0 -1
  29. package/dist/express.d.ts +0 -5
  30. package/dist/express.js +0 -226
  31. package/dist/express.js.map +0 -1
  32. package/dist/index.js +0 -13
  33. package/dist/index.js.map +0 -1
  34. package/dist/logger.js +0 -8
  35. package/dist/logger.js.map +0 -1
  36. package/dist/open-api/index.js +0 -67
  37. package/dist/open-api/index.js.map +0 -1
  38. package/dist/open-api/interfaces.js +0 -3
  39. package/dist/open-api/interfaces.js.map +0 -1
  40. package/dist/open-api/operations.js +0 -112
  41. package/dist/open-api/operations.js.map +0 -1
  42. package/dist/open-api/types.js +0 -50
  43. package/dist/open-api/types.js.map +0 -1
  44. package/dist/open-api/utils.js +0 -29
  45. package/dist/open-api/utils.js.map +0 -1
  46. package/dist/operation.js +0 -258
  47. package/dist/operation.js.map +0 -1
  48. package/dist/parse.js +0 -46
  49. package/dist/parse.js.map +0 -1
  50. package/dist/sofa.js +0 -90
  51. package/dist/sofa.js.map +0 -1
  52. package/dist/subscriptions.js +0 -174
  53. package/dist/subscriptions.js.map +0 -1
  54. package/dist/types.js +0 -3
  55. package/dist/types.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { DocumentNode, GraphQLSchema } from 'graphql';
2
- export declare function buildPathFromOperation({ url, schema, operation, useRequestBody, }: {
3
- url: string;
4
- schema: GraphQLSchema;
5
- operation: DocumentNode;
6
- useRequestBody: boolean;
7
- }): any;
1
+ import { DocumentNode, GraphQLSchema } from 'graphql';
2
+ export declare function buildPathFromOperation({ url, schema, operation, useRequestBody, }: {
3
+ url: string;
4
+ schema: GraphQLSchema;
5
+ operation: DocumentNode;
6
+ useRequestBody: boolean;
7
+ }): any;
@@ -1,3 +1,3 @@
1
- import { GraphQLObjectType, GraphQLInputObjectType, GraphQLOutputType, GraphQLNamedType } from 'graphql';
2
- export declare function buildSchemaObjectFromType(type: GraphQLObjectType | GraphQLInputObjectType): any;
3
- export declare function resolveFieldType(type: GraphQLOutputType | GraphQLNamedType): any;
1
+ import { GraphQLObjectType, GraphQLInputObjectType, GraphQLOutputType, GraphQLNamedType } from 'graphql';
2
+ export declare function buildSchemaObjectFromType(type: GraphQLObjectType | GraphQLInputObjectType): any;
3
+ export declare function resolveFieldType(type: GraphQLOutputType | GraphQLNamedType): any;
@@ -1,2 +1,2 @@
1
- export declare function mapToPrimitive(type: string): any;
2
- export declare function mapToRef(type: string): string;
1
+ export declare function mapToPrimitive(type: string): any;
2
+ export declare function mapToRef(type: string): string;
@@ -1,12 +1,12 @@
1
- import { GraphQLSchema, DocumentNode, OperationTypeNode } from 'graphql';
2
- import { Ignore } from './types';
3
- export declare type Skip = string[];
4
- export declare type Force = string[];
5
- export declare function buildOperation({ schema, kind, field, models, ignore, depthLimit, }: {
6
- schema: GraphQLSchema;
7
- kind: OperationTypeNode;
8
- field: string;
9
- models: string[];
10
- ignore: Ignore;
11
- depthLimit?: number;
12
- }): DocumentNode;
1
+ import { GraphQLSchema, DocumentNode, OperationTypeNode } from 'graphql';
2
+ import { Ignore } from './types';
3
+ export declare type Skip = string[];
4
+ export declare type Force = string[];
5
+ export declare function buildOperation({ schema, kind, field, models, ignore, depthLimit, }: {
6
+ schema: GraphQLSchema;
7
+ kind: OperationTypeNode;
8
+ field: string;
9
+ models: string[];
10
+ ignore: Ignore;
11
+ depthLimit?: number;
12
+ }): DocumentNode;
package/package.json CHANGED
@@ -1,91 +1,43 @@
1
1
  {
2
2
  "name": "sofa-api",
3
+ "version": "0.7.0",
3
4
  "description": "Create REST APIs with GraphQL",
4
- "version": "0.5.0",
5
- "main": "dist/index.js",
6
- "typings": "dist/index.d.ts",
7
- "sideEffects": false,
8
- "license": "MIT",
5
+ "peerDependencies": {
6
+ "express": "^4.0.0",
7
+ "graphql": "^0.13.2 || ^14.0.0"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "Urigo/sofa"
12
+ },
9
13
  "keywords": [
10
14
  "api",
11
15
  "rest",
12
16
  "graphql",
13
17
  "sofa"
14
18
  ],
15
- "repository": {
16
- "type": "git",
17
- "url": "Urigo/sofa"
18
- },
19
19
  "author": {
20
20
  "name": "Uri Goldshtein",
21
21
  "email": "uri.goldshtein@gmail.com",
22
22
  "url": "https://github.com/Urigo"
23
23
  },
24
- "peerDependencies": {
25
- "express": "^4.0.0",
26
- "graphql": "^0.13.2 || ^14.0.0"
24
+ "license": "MIT",
25
+ "main": "index.cjs.js",
26
+ "module": "index.esm.js",
27
+ "typings": "index.d.ts",
28
+ "typescript": {
29
+ "definition": "index.d.ts"
27
30
  },
28
31
  "dependencies": {
29
- "change-case": "3.1.0",
32
+ "axios": "0.19.2",
33
+ "change-case": "4.1.1",
30
34
  "graphql-subscriptions": "1.1.0",
31
- "iterall": "1.2.2",
32
- "request": "2.88.0",
33
- "request-promise-native": "1.0.7",
34
- "uuid": "3.3.3",
35
+ "iterall": "1.3.0",
36
+ "title-case": "3.0.2",
37
+ "tslib": "1.11.1",
38
+ "uuid": "3.4.0",
35
39
  "winston": "3.2.1",
36
40
  "yamljs": "0.3.0"
37
41
  },
38
- "scripts": {
39
- "start": "ts-node example/index.ts",
40
- "prod": "webpack && node dist/bundle.js",
41
- "build": "tsc -p tsconfig.build.json",
42
- "test": "jest --forceExit && yarn bundlesize",
43
- "format": "prettier --write **/*.{ts,js,md,json}",
44
- "prebuild": "rm -rf dist/",
45
- "prepublishOnly": "yarn build",
46
- "bundlesize": "yarn build && cd bundle-test/ && yarn && yarn test"
47
- },
48
- "devDependencies": {
49
- "@types/body-parser": "1.17.1",
50
- "@types/express": "4.17.1",
51
- "@types/express-graphql": "0.8.2",
52
- "@types/graphql": "14.2.3",
53
- "@types/jest": "24.0.18",
54
- "@types/request-promise-native": "1.0.16",
55
- "@types/supertest": "2.0.8",
56
- "@types/swagger-ui-express": "3.0.1",
57
- "@types/uuid": "3.4.5",
58
- "@types/webpack": "4.39.1",
59
- "@types/yamljs": "0.2.30",
60
- "body-parser": "1.19.0",
61
- "chalk": "2.4.2",
62
- "express": "4.17.1",
63
- "express-graphql": "0.9.0",
64
- "graphql": "14.5.4",
65
- "graphql-tag": "2.10.1",
66
- "graphql-tools": "4.0.5",
67
- "husky": "3.0.5",
68
- "jest": "24.9.0",
69
- "lint-staged": "9.2.5",
70
- "prettier": "1.18.2",
71
- "supertest": "4.0.2",
72
- "swagger-ui-express": "4.0.7",
73
- "ts-jest": "24.0.2",
74
- "ts-loader": "6.0.4",
75
- "ts-node": "8.3.0",
76
- "typescript": "3.6.2",
77
- "webpack": "4.39.3",
78
- "webpack-cli": "3.3.8"
79
- },
80
- "husky": {
81
- "hooks": {
82
- "pre-commit": "lint-staged"
83
- }
84
- },
85
- "lint-staged": {
86
- "*.{ts,js,md,json}": [
87
- "prettier --write",
88
- "git add"
89
- ]
90
- }
91
- }
42
+ "sideEffects": false
43
+ }
@@ -1,6 +1,6 @@
1
- import { VariableDefinitionNode, GraphQLSchema } from 'graphql';
2
- export declare function parseVariable({ value, variable, schema, }: {
3
- value: any;
4
- variable: VariableDefinitionNode;
5
- schema: GraphQLSchema;
6
- }): any;
1
+ import { VariableDefinitionNode, GraphQLSchema } from 'graphql';
2
+ export declare function parseVariable({ value, variable, schema, }: {
3
+ value: any;
4
+ variable: VariableDefinitionNode;
5
+ schema: GraphQLSchema;
6
+ }): any;
@@ -1,33 +1,33 @@
1
- import { GraphQLSchema } from 'graphql';
2
- import { Ignore, Context, ContextFn, ExecuteFn, OnRoute, MethodMap } from './types';
3
- import { ErrorHandler } from './express';
4
- export interface SofaConfig {
5
- schema: GraphQLSchema;
6
- context?: Context;
7
- execute?: ExecuteFn;
8
- /**
9
- * Treats an Object with an ID as not a model.
10
- * @example ["User", "Message.author"]
11
- */
12
- ignore?: Ignore;
13
- onRoute?: OnRoute;
14
- depthLimit?: number;
15
- errorHandler?: ErrorHandler;
16
- /**
17
- * Overwrites the default HTTP method.
18
- * @example {"Query.field": "GET", "Mutation.field": "POST"}
19
- */
20
- method?: MethodMap;
21
- }
22
- export interface Sofa {
23
- schema: GraphQLSchema;
24
- context: Context;
25
- models: string[];
26
- ignore: Ignore;
27
- method?: MethodMap;
28
- execute: ExecuteFn;
29
- onRoute?: OnRoute;
30
- errorHandler?: ErrorHandler;
31
- }
32
- export declare function createSofa(config: SofaConfig): Sofa;
33
- export declare function isContextFn(context: any): context is ContextFn;
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { Ignore, Context, ContextFn, ExecuteFn, OnRoute, MethodMap } from './types';
3
+ import { ErrorHandler } from './express';
4
+ export interface SofaConfig {
5
+ schema: GraphQLSchema;
6
+ context?: Context;
7
+ execute?: ExecuteFn;
8
+ /**
9
+ * Treats an Object with an ID as not a model.
10
+ * @example ["User", "Message.author"]
11
+ */
12
+ ignore?: Ignore;
13
+ onRoute?: OnRoute;
14
+ depthLimit?: number;
15
+ errorHandler?: ErrorHandler;
16
+ /**
17
+ * Overwrites the default HTTP method.
18
+ * @example {"Query.field": "GET", "Mutation.field": "POST"}
19
+ */
20
+ method?: MethodMap;
21
+ }
22
+ export interface Sofa {
23
+ schema: GraphQLSchema;
24
+ context: Context;
25
+ models: string[];
26
+ ignore: Ignore;
27
+ method?: MethodMap;
28
+ execute: ExecuteFn;
29
+ onRoute?: OnRoute;
30
+ errorHandler?: ErrorHandler;
31
+ }
32
+ export declare function createSofa(config: SofaConfig): Sofa;
33
+ export declare function isContextFn(context: any): context is ContextFn;
@@ -1,38 +1,38 @@
1
- import { ExecutionResult } from 'graphql';
2
- import { Sofa } from './sofa';
3
- export declare type ID = string;
4
- export declare type SubscriptionFieldName = string;
5
- export interface StartSubscriptionEvent {
6
- subscription: SubscriptionFieldName;
7
- variables: any;
8
- url: string;
9
- }
10
- export interface UpdateSubscriptionEvent {
11
- id: ID;
12
- variables: any;
13
- }
14
- export interface StopSubscriptionResponse {
15
- id: ID;
16
- }
17
- export declare class SubscriptionManager {
18
- private sofa;
19
- private operations;
20
- private clients;
21
- constructor(sofa: Sofa);
22
- start(event: StartSubscriptionEvent, { req, res, }: {
23
- req: any;
24
- res: any;
25
- }): Promise<ExecutionResult<any> | {
26
- id: string;
27
- }>;
28
- stop(id: ID): Promise<StopSubscriptionResponse>;
29
- update(event: UpdateSubscriptionEvent, { req, res, }: {
30
- req: any;
31
- res: any;
32
- }): Promise<ExecutionResult<any> | {
33
- id: string;
34
- }>;
35
- private execute;
36
- private sendData;
37
- private buildOperations;
38
- }
1
+ import { ExecutionResult } from 'graphql';
2
+ import { Sofa } from './sofa';
3
+ export declare type ID = string;
4
+ export declare type SubscriptionFieldName = string;
5
+ export interface StartSubscriptionEvent {
6
+ subscription: SubscriptionFieldName;
7
+ variables: any;
8
+ url: string;
9
+ }
10
+ export interface UpdateSubscriptionEvent {
11
+ id: ID;
12
+ variables: any;
13
+ }
14
+ export interface StopSubscriptionResponse {
15
+ id: ID;
16
+ }
17
+ export declare class SubscriptionManager {
18
+ private sofa;
19
+ private operations;
20
+ private clients;
21
+ constructor(sofa: Sofa);
22
+ start(event: StartSubscriptionEvent, { req, res, }: {
23
+ req: any;
24
+ res: any;
25
+ }): Promise<ExecutionResult<any> | {
26
+ id: string;
27
+ }>;
28
+ stop(id: ID): Promise<StopSubscriptionResponse>;
29
+ update(event: UpdateSubscriptionEvent, { req, res, }: {
30
+ req: any;
31
+ res: any;
32
+ }): Promise<ExecutionResult<any> | {
33
+ id: string;
34
+ }>;
35
+ private execute;
36
+ private sendData;
37
+ private buildOperations;
38
+ }
@@ -1,17 +1,17 @@
1
- import { GraphQLArgs, ExecutionResult, DocumentNode } from 'graphql';
2
- export declare type ContextValue = Record<string, any>;
3
- export declare type ContextFn = (init: {
4
- req: any;
5
- res: any;
6
- }) => ContextValue;
7
- export declare type Context = ContextValue | ContextFn;
8
- export declare type Ignore = string[];
9
- export declare type ExecuteFn = (args: GraphQLArgs) => Promise<ExecutionResult<any>>;
10
- export declare type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
11
- export interface RouteInfo {
12
- document: DocumentNode;
13
- path: string;
14
- method: Method;
15
- }
16
- export declare type OnRoute = (info: RouteInfo) => void;
17
- export declare type MethodMap = Record<string, Method>;
1
+ import { GraphQLArgs, ExecutionResult, DocumentNode } from 'graphql';
2
+ export declare type ContextValue = Record<string, any>;
3
+ export declare type ContextFn = (init: {
4
+ req: any;
5
+ res: any;
6
+ }) => ContextValue;
7
+ export declare type Context = ContextValue | ContextFn;
8
+ export declare type Ignore = string[];
9
+ export declare type ExecuteFn = (args: GraphQLArgs) => Promise<ExecutionResult<any>>;
10
+ export declare type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
11
+ export interface RouteInfo {
12
+ document: DocumentNode;
13
+ path: string;
14
+ method: Method;
15
+ }
16
+ export declare type OnRoute = (info: RouteInfo) => void;
17
+ export declare type MethodMap = Record<string, Method>;
package/.DS_Store DELETED
Binary file
@@ -1 +0,0 @@
1
- 0000000000000000000000000000000000000000 79d5acd0848b9f42e4718cde217aec0925011261 Kamil Kisiela <kamil.kisiela@gmail.com> 1551086355 +0100 update by push
@@ -1 +0,0 @@
1
- 79d5acd0848b9f42e4718cde217aec0925011261
package/CHANGELOG.md DELETED
@@ -1,30 +0,0 @@
1
- # Change log
2
-
3
- ### vNEXT
4
-
5
- ### v0.5.0
6
-
7
- - feat(swagger): add description [PR #107](https://github.com/Urigo/SOFA/pull/107)
8
- - feat(swagger): add `ID` scalar definition [PR #107](https://github.com/Urigo/SOFA/pull/107)
9
- - fix(swagger): use `requestBody` or `parameters` not both [PR #107](https://github.com/Urigo/SOFA/pull/107)
10
- - fix(swagger): generate valid YAML structure for nested objects [PR #107](https://github.com/Urigo/SOFA/pull/107)
11
- - fix(swagger): avoid empty `required` array [PR #107](https://github.com/Urigo/SOFA/pull/107)
12
-
13
- ### v0.4.0
14
-
15
- - feat: add error handler [PR #44](https://github.com/Urigo/SOFA/pull/44) [PR #45](https://github.com/Urigo/SOFA/pull/45)
16
- - feat: allow to customize endpoint's HTTP Method [PR #46](https://github.com/Urigo/SOFA/pull/46)
17
- - feat: add InputTypeObjects to OpenAPI generation [PR #34](https://github.com/Urigo/SOFA/pull/34) - [@hajnalben](https://github.com/hajnalben)
18
-
19
- ### v0.3.0
20
-
21
- - fix: parse InputTypeObject with JSON.parse [PR #30](https://github.com/Urigo/SOFA/pull/30)
22
- - feat: custom `depthLimit` (circular references) [PR #29](https://github.com/Urigo/SOFA/pull/29)
23
-
24
- ### v0.2.3
25
-
26
- - fix: prevent circular references [PR #23](https://github.com/Urigo/SOFA/pull/23)
27
-
28
- ### v0.2.2
29
-
30
- We didn't track changes before this version.
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Uri Goldshtein
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.