@things-factory/shell 4.0.0-alpha.9 → 4.0.0-beta.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.
- package/bin/things-factory-dev +5 -11
- package/client/elements/oops-progress.js +15 -7
- package/client/graphql-client.js +14 -15
- package/client/index.js +2 -2
- package/client/{notification-store.js → indexdb.js} +49 -40
- package/client/serviceworker/sw-src.js +1 -1
- package/client/themes/oops-theme.css +9 -9
- package/config/config.development.js +12 -1
- package/dist-server/graphql-local-client.js +1 -1
- package/dist-server/graphql-local-client.js.map +1 -1
- package/dist-server/initializers/database.js +1 -1
- package/dist-server/initializers/database.js.map +1 -1
- package/dist-server/initializers/naming-strategy.js +1 -1
- package/dist-server/initializers/naming-strategy.js.map +1 -1
- package/dist-server/middlewares/domain-middleware.js +1 -1
- package/dist-server/middlewares/domain-middleware.js.map +1 -1
- package/dist-server/middlewares/index.js +1 -1
- package/dist-server/middlewares/index.js.map +1 -1
- package/dist-server/migrations/1000000000000-SeedDomain.js +2 -2
- package/dist-server/migrations/1000000000000-SeedDomain.js.map +1 -1
- package/dist-server/pubsub-log-transport.js +1 -1
- package/dist-server/pubsub-log-transport.js.map +1 -1
- package/dist-server/pubsub.js +15 -13
- package/dist-server/pubsub.js.map +1 -1
- package/dist-server/schema.js +10 -10
- package/dist-server/schema.js.map +1 -1
- package/dist-server/server-dev.js +71 -52
- package/dist-server/server-dev.js.map +1 -1
- package/dist-server/server.js +62 -47
- package/dist-server/server.js.map +1 -1
- package/dist-server/service/common-types/list-param.js +15 -15
- package/dist-server/service/common-types/list-param.js.map +1 -1
- package/dist-server/service/common-types/log.js +5 -5
- package/dist-server/service/common-types/log.js.map +1 -1
- package/dist-server/service/common-types/object-ref.js +4 -4
- package/dist-server/service/common-types/object-ref.js.map +1 -1
- package/dist-server/service/directive-transaction/transaction.js +4 -4
- package/dist-server/service/directive-transaction/transaction.js.map +1 -1
- package/dist-server/service/domain/domain-resolver.js +43 -43
- package/dist-server/service/domain/domain-resolver.js.map +1 -1
- package/dist-server/service/domain/domain-types.js +17 -17
- package/dist-server/service/domain/domain-types.js.map +1 -1
- package/dist-server/service/domain/domain.js +31 -31
- package/dist-server/service/domain/domain.js.map +1 -1
- package/dist-server/service/index.js +7 -6
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/subscription-data/data-resolver.js +5 -5
- package/dist-server/service/subscription-data/data-resolver.js.map +1 -1
- package/dist-server/service/subscription-data/data-types.js +4 -4
- package/dist-server/service/subscription-data/data-types.js.map +1 -1
- package/dist-server/utils/condition-builder.js +23 -25
- package/dist-server/utils/condition-builder.js.map +1 -1
- package/dist-server/utils/get-domain.js +3 -3
- package/dist-server/utils/get-domain.js.map +1 -1
- package/dist-server/utils/list-params-converter.js +21 -21
- package/dist-server/utils/list-params-converter.js.map +1 -1
- package/dist-server/utils/list-query-builder.js +2 -2
- package/dist-server/utils/list-query-builder.js.map +1 -1
- package/helps/about/components.md +3 -0
- package/helps/about/{common → framework}/redirection.md +0 -0
- package/helps/about/framework/typegraphql.md +74 -0
- package/helps/about/framework.md +10 -0
- package/helps/about/modules.md +3 -1
- package/helps/about/things-factory.en.md +3 -0
- package/helps/about/things-factory.ko.md +4 -0
- package/helps/components/oops-progress.md +73 -0
- package/package.json +25 -29
- package/server/pubsub.ts +16 -15
- package/server/schema.ts +5 -5
- package/server/server-dev.ts +55 -36
- package/server/server.ts +47 -31
- package/server/service/domain/domain-resolver.ts +8 -6
- package/server/service/index.ts +12 -5
- package/server/utils/condition-builder.ts +23 -25
- package/server/utils/list-query-builder.ts +1 -1
@@ -5,27 +5,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
process.env.NODE_ENV = 'development';
|
7
7
|
process.setMaxListeners(0);
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const koa_bodyparser_1 = __importDefault(require("koa-bodyparser"));
|
13
|
-
const koa2_connect_history_api_fallback_1 = require("koa2-connect-history-api-fallback");
|
14
|
-
const koa_webpack_1 = __importDefault(require("koa-webpack"));
|
8
|
+
const subscriptions_transport_ws_1 = require("subscriptions-transport-ws");
|
9
|
+
const env_1 = require("@things-factory/env");
|
10
|
+
const routers_1 = require("./routers");
|
11
|
+
const graphql_1 = require("graphql");
|
15
12
|
const apollo_server_koa_1 = require("apollo-server-koa");
|
16
|
-
const
|
13
|
+
const apollo_server_core_1 = require("apollo-server-core");
|
14
|
+
const graphql_local_client_1 = require("./graphql-local-client");
|
15
|
+
const koa_1 = __importDefault(require("koa"));
|
17
16
|
const co_1 = __importDefault(require("co"));
|
18
17
|
const koa_compose_1 = __importDefault(require("koa-compose"));
|
19
|
-
const
|
18
|
+
const cors_1 = __importDefault(require("@koa/cors"));
|
19
|
+
const http_1 = require("http");
|
20
20
|
const database_1 = require("./initializers/database");
|
21
|
-
const
|
22
|
-
const
|
21
|
+
const graphql_upload_1 = require("graphql-upload");
|
22
|
+
const koa2_connect_history_api_fallback_1 = require("koa2-connect-history-api-fallback");
|
23
|
+
const koa_ip_1 = __importDefault(require("koa-ip"));
|
24
|
+
const koa_bodyparser_1 = __importDefault(require("koa-bodyparser"));
|
25
|
+
const koa_static_1 = __importDefault(require("koa-static"));
|
26
|
+
const koa_webpack_1 = __importDefault(require("koa-webpack"));
|
23
27
|
const schema_1 = require("./schema");
|
24
28
|
const debug = require('debug')('things-factory:shell:server-dev');
|
25
29
|
const args = require('args');
|
26
30
|
args.option('port', 'The port on which the app will be running', env_1.config.get('port', 3000));
|
27
31
|
args.option('inspect', `The address on which the inspection will be running. Used in development mode only.
|
28
|
-
This option is just to
|
32
|
+
This option is just to prevent termination for reasons of not recognizing the 'inspect' option.`, env_1.config.get('inspect', ':9229'));
|
29
33
|
const flags = args.parse(process.argv);
|
30
34
|
const path = require('path');
|
31
35
|
const webpack = require('webpack');
|
@@ -39,9 +43,9 @@ const bodyParserOption = {
|
|
39
43
|
};
|
40
44
|
/* bootstrap */
|
41
45
|
const bootstrap = async () => {
|
42
|
-
await database_1.databaseInitializer();
|
46
|
+
await (0, database_1.databaseInitializer)();
|
43
47
|
const app = new koa_1.default();
|
44
|
-
app.use(cors_1.default({
|
48
|
+
app.use((0, cors_1.default)({
|
45
49
|
origin: function (ctx) {
|
46
50
|
return ctx.request.headers.origin || '*';
|
47
51
|
},
|
@@ -54,7 +58,7 @@ const bootstrap = async () => {
|
|
54
58
|
const whitelist = env_1.config.get('whitelist');
|
55
59
|
const blacklist = env_1.config.get('blacklist');
|
56
60
|
if (whitelist || blacklist) {
|
57
|
-
app.use(koa_ip_1.default({
|
61
|
+
app.use((0, koa_ip_1.default)({
|
58
62
|
whitelist,
|
59
63
|
blacklist,
|
60
64
|
handler: async (ctx, next) => {
|
@@ -64,28 +68,33 @@ const bootstrap = async () => {
|
|
64
68
|
}
|
65
69
|
var subscriptionMiddleware = [];
|
66
70
|
process.emit('bootstrap-module-subscription', app, subscriptionMiddleware);
|
67
|
-
const builtSchema = await schema_1.schema();
|
71
|
+
const builtSchema = await (0, schema_1.schema)();
|
72
|
+
const httpServer = (0, http_1.createServer)(app.callback());
|
73
|
+
const subscriptionServer = subscriptions_transport_ws_1.SubscriptionServer.create({
|
74
|
+
schema: builtSchema,
|
75
|
+
// These are imported from `graphql`.
|
76
|
+
execute: graphql_1.execute,
|
77
|
+
subscribe: graphql_1.subscribe,
|
78
|
+
async onConnect(connectionParams, webSocket, context) {
|
79
|
+
var { request } = context;
|
80
|
+
var url = new URL((connectionParams['headers'] || connectionParams).referer);
|
81
|
+
var accessToken = url.searchParams.get('access_token');
|
82
|
+
connectionParams['headers']['authorization'] = accessToken;
|
83
|
+
request.headers = Object.assign(Object.assign({}, request.headers), (connectionParams['headers'] || connectionParams));
|
84
|
+
var koacontext = await app.createContext(request, {});
|
85
|
+
koacontext['state'] = {};
|
86
|
+
/* in case connect error(like a authentication error) just throw exception */
|
87
|
+
var middlewares = [...subscriptionMiddleware];
|
88
|
+
const fn = co_1.default.wrap((0, koa_compose_1.default)(middlewares));
|
89
|
+
await fn(koacontext);
|
90
|
+
return koacontext;
|
91
|
+
}
|
92
|
+
}, {
|
93
|
+
server: httpServer,
|
94
|
+
path: '/subscriptions'
|
95
|
+
});
|
68
96
|
const server = new apollo_server_koa_1.ApolloServer({
|
69
97
|
schema: builtSchema,
|
70
|
-
uploads: false,
|
71
|
-
subscriptions: {
|
72
|
-
path: '/subscriptions',
|
73
|
-
onConnect: async (connectionParams, webSocket, context) => {
|
74
|
-
/* To maintain the same method as the http(s) request */
|
75
|
-
var { request } = context;
|
76
|
-
var url = new URL((connectionParams['headers'] || connectionParams).referer);
|
77
|
-
var accessToken = url.searchParams.get('access_token');
|
78
|
-
connectionParams['headers']['authorization'] = accessToken;
|
79
|
-
request.headers = Object.assign(Object.assign({}, request.headers), (connectionParams['headers'] || connectionParams));
|
80
|
-
var koacontext = await app.createContext(request, {});
|
81
|
-
koacontext['state'] = {};
|
82
|
-
/* in case connect error(like a authentication error) just throw exception */
|
83
|
-
var middlewares = [...subscriptionMiddleware];
|
84
|
-
const fn = co_1.default.wrap(koa_compose_1.default(middlewares));
|
85
|
-
await fn(koacontext);
|
86
|
-
return koacontext;
|
87
|
-
}
|
88
|
-
},
|
89
98
|
formatError: error => {
|
90
99
|
env_1.logger.error(error);
|
91
100
|
return error;
|
@@ -94,11 +103,6 @@ const bootstrap = async () => {
|
|
94
103
|
// logger.info('response %s', JSON.stringify(response, null, 2))
|
95
104
|
return response;
|
96
105
|
},
|
97
|
-
playground: {
|
98
|
-
settings: {
|
99
|
-
'request.credentials': 'include'
|
100
|
-
}
|
101
|
-
},
|
102
106
|
context: async ({ connection, ctx }) => {
|
103
107
|
if (connection) {
|
104
108
|
return connection.context;
|
@@ -106,14 +110,31 @@ const bootstrap = async () => {
|
|
106
110
|
else {
|
107
111
|
return ctx;
|
108
112
|
}
|
109
|
-
}
|
113
|
+
},
|
114
|
+
plugins: [
|
115
|
+
(0, apollo_server_core_1.ApolloServerPluginLandingPageGraphQLPlayground)({
|
116
|
+
settings: {
|
117
|
+
'request.credentials': 'same-origin'
|
118
|
+
}
|
119
|
+
}),
|
120
|
+
{
|
121
|
+
async serverWillStart() {
|
122
|
+
return {
|
123
|
+
async drainServer() {
|
124
|
+
subscriptionServer.close();
|
125
|
+
}
|
126
|
+
};
|
127
|
+
}
|
128
|
+
}
|
129
|
+
]
|
110
130
|
});
|
131
|
+
server.start();
|
111
132
|
graphql_local_client_1.GraphqlLocalClient.init(builtSchema, app);
|
112
133
|
env_1.orderedModuleNames.forEach(name => {
|
113
|
-
const { initMiddlewares } = env_1.loader(name);
|
134
|
+
const { initMiddlewares } = (0, env_1.loader)(name);
|
114
135
|
initMiddlewares && initMiddlewares(app);
|
115
136
|
});
|
116
|
-
const render = require('
|
137
|
+
const render = require('@things-factory/ejs-remote');
|
117
138
|
render(app, {
|
118
139
|
root: '/views',
|
119
140
|
host: `http://127.0.0.1:${PORT}`,
|
@@ -122,7 +143,7 @@ const bootstrap = async () => {
|
|
122
143
|
cache: false,
|
123
144
|
debug: false
|
124
145
|
});
|
125
|
-
const middleware = await koa_webpack_1.default({
|
146
|
+
const middleware = await (0, koa_webpack_1.default)({
|
126
147
|
compiler,
|
127
148
|
hotClient: {},
|
128
149
|
devMiddleware: {
|
@@ -134,8 +155,8 @@ const bootstrap = async () => {
|
|
134
155
|
compiler.plugin('done', stats => {
|
135
156
|
process.emit('client-rebuilt', app, compiler.outputFileSystem);
|
136
157
|
});
|
137
|
-
app.use(koa_bodyparser_1.default(bodyParserOption));
|
138
|
-
app.use(graphql_upload_1.graphqlUploadKoa({ maxFileSize: 10000000, maxFiles: 10 }));
|
158
|
+
app.use((0, koa_bodyparser_1.default)(bodyParserOption));
|
159
|
+
app.use((0, graphql_upload_1.graphqlUploadKoa)({ maxFileSize: 10000000, maxFiles: 10 }));
|
139
160
|
app.use(server.getMiddleware({
|
140
161
|
path: '/graphql'
|
141
162
|
}));
|
@@ -154,18 +175,16 @@ const bootstrap = async () => {
|
|
154
175
|
.use(routers_1.domainPrivateRouter.routes())
|
155
176
|
.use(routers_1.domainPrivateRouter.allowedMethods());
|
156
177
|
/* should be history-fallback => webpack-middleware => koaStatic */
|
157
|
-
app.use(koa2_connect_history_api_fallback_1.historyApiFallback({ whiteList: [] }));
|
178
|
+
app.use((0, koa2_connect_history_api_fallback_1.historyApiFallback)({ whiteList: [] }));
|
158
179
|
app.use(middleware);
|
159
|
-
app.use(koa_static_1.default(compiler.outputPath, {
|
180
|
+
app.use((0, koa_static_1.default)(compiler.outputPath, {
|
160
181
|
index: false
|
161
182
|
}));
|
162
|
-
|
163
|
-
const httpServer = app.listen({ port: PORT }, () => {
|
183
|
+
httpServer.listen({ port: PORT }, () => {
|
164
184
|
env_1.logger.info(`🚀 Server ready at http://0.0.0.0:${PORT}${server.graphqlPath}`);
|
165
|
-
env_1.logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}${
|
185
|
+
env_1.logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}${'/subscriptions'}`);
|
166
186
|
process.emit('bootstrap-module-start', { app, config: env_1.config, builtSchema, httpServer });
|
167
187
|
});
|
168
|
-
server.installSubscriptionHandlers(httpServer);
|
169
188
|
};
|
170
189
|
bootstrap();
|
171
190
|
//# sourceMappingURL=server-dev.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"server-dev.js","sourceRoot":"","sources":["../server/server-dev.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAA;AACpC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;AAE1B,
|
1
|
+
{"version":3,"file":"server-dev.js","sourceRoot":"","sources":["../server/server-dev.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAA;AACpC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;AAE1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E,GAAG,CAAC,GAAG,CAAC,IAAA,sDAAkB,EAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IAE9C,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAEnB,GAAG,CAAC,GAAG,CACL,IAAA,oBAAS,EAAC,QAAQ,CAAC,UAAU,EAAE;QAC7B,KAAK,EAAE,KAAK;KACb,CAAC,CACH,CAAA;IAED,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE;QACrC,YAAM,CAAC,IAAI,CAAC,qCAAqC,IAAI,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;QAC7E,YAAM,CAAC,IAAI,CAAC,0CAA0C,IAAI,GAAG,gBAAgB,EAAE,CAAC,CAAA;QAEhF,OAAO,CAAC,IAAI,CAAC,wBAA+B,EAAE,EAAE,GAAG,EAAE,MAAM,EAAN,YAAM,EAAE,WAAW,EAAE,UAAU,EAAS,CAAC,CAAA;IAChG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,SAAS,EAAE,CAAA"}
|
package/dist-server/server.js
CHANGED
@@ -5,20 +5,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
process.env.NODE_ENV = 'production';
|
7
7
|
process.setMaxListeners(0);
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const koa_bodyparser_1 = __importDefault(require("koa-bodyparser"));
|
13
|
-
const koa2_connect_history_api_fallback_1 = require("koa2-connect-history-api-fallback");
|
8
|
+
const subscriptions_transport_ws_1 = require("subscriptions-transport-ws");
|
9
|
+
const env_1 = require("@things-factory/env");
|
10
|
+
const routers_1 = require("./routers");
|
11
|
+
const graphql_1 = require("graphql");
|
14
12
|
const apollo_server_koa_1 = require("apollo-server-koa");
|
15
|
-
const
|
13
|
+
const graphql_local_client_1 = require("./graphql-local-client");
|
14
|
+
const koa_1 = __importDefault(require("koa"));
|
16
15
|
const co_1 = __importDefault(require("co"));
|
17
16
|
const koa_compose_1 = __importDefault(require("koa-compose"));
|
18
|
-
const
|
17
|
+
const cors_1 = __importDefault(require("@koa/cors"));
|
18
|
+
const http_1 = require("http");
|
19
19
|
const database_1 = require("./initializers/database");
|
20
|
-
const
|
21
|
-
const
|
20
|
+
const graphql_upload_1 = require("graphql-upload");
|
21
|
+
const koa2_connect_history_api_fallback_1 = require("koa2-connect-history-api-fallback");
|
22
|
+
const koa_ip_1 = __importDefault(require("koa-ip"));
|
23
|
+
const koa_bodyparser_1 = __importDefault(require("koa-bodyparser"));
|
24
|
+
const koa_static_1 = __importDefault(require("koa-static"));
|
22
25
|
const schema_1 = require("./schema");
|
23
26
|
const args = require('args');
|
24
27
|
args.option('port', 'The port on which the app will be running', env_1.config.get('port', 3000));
|
@@ -32,9 +35,9 @@ const bodyParserOption = {
|
|
32
35
|
};
|
33
36
|
/* bootstrap */
|
34
37
|
const bootstrap = async () => {
|
35
|
-
await database_1.databaseInitializer();
|
38
|
+
await (0, database_1.databaseInitializer)();
|
36
39
|
const app = new koa_1.default();
|
37
|
-
app.use(cors_1.default({
|
40
|
+
app.use((0, cors_1.default)({
|
38
41
|
origin: function (ctx) {
|
39
42
|
return ctx.request.headers.origin || '*';
|
40
43
|
},
|
@@ -47,7 +50,7 @@ const bootstrap = async () => {
|
|
47
50
|
const whitelist = env_1.config.get('whitelist');
|
48
51
|
const blacklist = env_1.config.get('blacklist');
|
49
52
|
if (whitelist || blacklist) {
|
50
|
-
app.use(koa_ip_1.default({
|
53
|
+
app.use((0, koa_ip_1.default)({
|
51
54
|
whitelist,
|
52
55
|
blacklist,
|
53
56
|
handler: async (ctx, next) => {
|
@@ -57,27 +60,33 @@ const bootstrap = async () => {
|
|
57
60
|
}
|
58
61
|
var subscriptionMiddleware = [];
|
59
62
|
process.emit('bootstrap-module-subscription', app, subscriptionMiddleware);
|
60
|
-
const builtSchema = await schema_1.schema();
|
63
|
+
const builtSchema = await (0, schema_1.schema)();
|
64
|
+
const httpServer = (0, http_1.createServer)(app.callback());
|
65
|
+
const subscriptionServer = subscriptions_transport_ws_1.SubscriptionServer.create({
|
66
|
+
schema: builtSchema,
|
67
|
+
// These are imported from `graphql`.
|
68
|
+
execute: graphql_1.execute,
|
69
|
+
subscribe: graphql_1.subscribe,
|
70
|
+
async onConnect(connectionParams, webSocket, context) {
|
71
|
+
var { request } = context;
|
72
|
+
var url = new URL((connectionParams['headers'] || connectionParams).referer);
|
73
|
+
var accessToken = url.searchParams.get('access_token');
|
74
|
+
connectionParams['headers']['authorization'] = accessToken;
|
75
|
+
request.headers = Object.assign(Object.assign({}, request.headers), (connectionParams['headers'] || connectionParams));
|
76
|
+
/* in case connect error(like a authentication error) just throw exception */
|
77
|
+
var koacontext = await app.createContext(request, {});
|
78
|
+
koacontext['state'] = {};
|
79
|
+
var middlewares = [...subscriptionMiddleware];
|
80
|
+
const fn = co_1.default.wrap((0, koa_compose_1.default)(middlewares));
|
81
|
+
await fn(koacontext);
|
82
|
+
return koacontext;
|
83
|
+
}
|
84
|
+
}, {
|
85
|
+
server: httpServer,
|
86
|
+
path: '/subscriptions'
|
87
|
+
});
|
61
88
|
const server = new apollo_server_koa_1.ApolloServer({
|
62
89
|
schema: builtSchema,
|
63
|
-
uploads: false,
|
64
|
-
subscriptions: {
|
65
|
-
path: '/subscriptions',
|
66
|
-
onConnect: async (connectionParams, webSocket, context) => {
|
67
|
-
var { request } = context;
|
68
|
-
var url = new URL((connectionParams['headers'] || connectionParams).referer);
|
69
|
-
var accessToken = url.searchParams.get('access_token');
|
70
|
-
connectionParams['headers']['authorization'] = accessToken;
|
71
|
-
request.headers = Object.assign(Object.assign({}, request.headers), (connectionParams['headers'] || connectionParams));
|
72
|
-
/* in case connect error(like a authentication error) just throw exception */
|
73
|
-
var koacontext = await app.createContext(request, {});
|
74
|
-
koacontext['state'] = {};
|
75
|
-
var middlewares = [...subscriptionMiddleware];
|
76
|
-
const fn = co_1.default.wrap(koa_compose_1.default(middlewares));
|
77
|
-
await fn(koacontext);
|
78
|
-
return koacontext;
|
79
|
-
}
|
80
|
-
},
|
81
90
|
formatError: error => {
|
82
91
|
env_1.logger.error(error);
|
83
92
|
return error;
|
@@ -87,11 +96,6 @@ const bootstrap = async () => {
|
|
87
96
|
return response;
|
88
97
|
},
|
89
98
|
introspection: true,
|
90
|
-
playground: {
|
91
|
-
settings: {
|
92
|
-
'request.credentials': 'include'
|
93
|
-
}
|
94
|
-
},
|
95
99
|
context: async ({ connection, ctx }) => {
|
96
100
|
if (connection) {
|
97
101
|
return connection.context;
|
@@ -99,14 +103,26 @@ const bootstrap = async () => {
|
|
99
103
|
else {
|
100
104
|
return ctx;
|
101
105
|
}
|
102
|
-
}
|
106
|
+
},
|
107
|
+
plugins: [
|
108
|
+
{
|
109
|
+
async serverWillStart() {
|
110
|
+
return {
|
111
|
+
async drainServer() {
|
112
|
+
subscriptionServer.close();
|
113
|
+
}
|
114
|
+
};
|
115
|
+
}
|
116
|
+
}
|
117
|
+
]
|
103
118
|
});
|
119
|
+
await server.start();
|
104
120
|
graphql_local_client_1.GraphqlLocalClient.init(builtSchema, app);
|
105
121
|
env_1.orderedModuleNames.forEach(name => {
|
106
|
-
const { initMiddlewares } = env_1.loader(name);
|
122
|
+
const { initMiddlewares } = (0, env_1.loader)(name);
|
107
123
|
initMiddlewares && initMiddlewares(app);
|
108
124
|
});
|
109
|
-
const render = require('
|
125
|
+
const render = require('@things-factory/ejs-remote');
|
110
126
|
render(app, {
|
111
127
|
root: '/views',
|
112
128
|
host: `http://127.0.0.1:${PORT}`,
|
@@ -115,8 +131,8 @@ const bootstrap = async () => {
|
|
115
131
|
cache: true,
|
116
132
|
debug: false
|
117
133
|
});
|
118
|
-
app.use(koa_bodyparser_1.default(bodyParserOption));
|
119
|
-
app.use(graphql_upload_1.graphqlUploadKoa({ maxFileSize: 10000000, maxFiles: 10 }));
|
134
|
+
app.use((0, koa_bodyparser_1.default)(bodyParserOption));
|
135
|
+
app.use((0, graphql_upload_1.graphqlUploadKoa)({ maxFileSize: 10000000, maxFiles: 10 }));
|
120
136
|
app.use(server.getMiddleware({
|
121
137
|
path: '/graphql'
|
122
138
|
}));
|
@@ -135,16 +151,15 @@ const bootstrap = async () => {
|
|
135
151
|
.use(routers_1.domainPrivateRouter.routes())
|
136
152
|
.use(routers_1.domainPrivateRouter.allowedMethods());
|
137
153
|
/* should be history-fallback => koaStatic */
|
138
|
-
app.use(koa2_connect_history_api_fallback_1.historyApiFallback({ whiteList: [] }));
|
139
|
-
app.use(koa_static_1.default(path.join(process.cwd(), 'dist-client'), {
|
154
|
+
app.use((0, koa2_connect_history_api_fallback_1.historyApiFallback)({ whiteList: [] }));
|
155
|
+
app.use((0, koa_static_1.default)(path.join(process.cwd(), 'dist-client'), {
|
140
156
|
index: 'index.html'
|
141
157
|
}));
|
142
|
-
|
158
|
+
httpServer.listen({ port: PORT }, () => {
|
143
159
|
env_1.logger.info(`🚀 Server ready at http://0.0.0.0:${PORT}${server.graphqlPath}`);
|
144
|
-
env_1.logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}${
|
160
|
+
env_1.logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}${'/subscriptions'}`);
|
145
161
|
process.emit('bootstrap-module-start', { app, config: env_1.config, builtSchema, httpServer });
|
146
162
|
});
|
147
|
-
server.installSubscriptionHandlers(httpServer);
|
148
163
|
};
|
149
164
|
bootstrap();
|
150
165
|
//# sourceMappingURL=server.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../server/server.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAA;AACnC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;AAE1B,
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../server/server.ts"],"names":[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any");
|
|
15
15
|
let Sorting = class Sorting {
|
16
16
|
};
|
17
17
|
__decorate([
|
18
|
-
type_graphql_1.Field({ description: 'Field name to sort by' }),
|
18
|
+
(0, type_graphql_1.Field)({ description: 'Field name to sort by' }),
|
19
19
|
__metadata("design:type", String)
|
20
20
|
], Sorting.prototype, "name", void 0);
|
21
21
|
__decorate([
|
22
|
-
type_graphql_1.Field({ nullable: true, description: 'Set to true if descending sort. Default is "false"' }),
|
22
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Set to true if descending sort. Default is "false"' }),
|
23
23
|
__metadata("design:type", Boolean)
|
24
24
|
], Sorting.prototype, "desc", void 0);
|
25
25
|
Sorting = __decorate([
|
26
|
-
type_graphql_1.InputType()
|
26
|
+
(0, type_graphql_1.InputType)()
|
27
27
|
], Sorting);
|
28
28
|
exports.Sorting = Sorting;
|
29
29
|
let Pagination = class Pagination {
|
30
30
|
};
|
31
31
|
__decorate([
|
32
|
-
type_graphql_1.Field(type => type_graphql_1.Int, { nullable: true }),
|
32
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
|
33
33
|
__metadata("design:type", Number)
|
34
34
|
], Pagination.prototype, "page", void 0);
|
35
35
|
__decorate([
|
36
|
-
type_graphql_1.Field(type => type_graphql_1.Int, { nullable: true }),
|
36
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
|
37
37
|
__metadata("design:type", Number)
|
38
38
|
], Pagination.prototype, "limit", void 0);
|
39
39
|
Pagination = __decorate([
|
40
|
-
type_graphql_1.InputType()
|
40
|
+
(0, type_graphql_1.InputType)()
|
41
41
|
], Pagination);
|
42
42
|
exports.Pagination = Pagination;
|
43
43
|
let Filter = class Filter {
|
44
44
|
};
|
45
45
|
__decorate([
|
46
|
-
type_graphql_1.Field(),
|
46
|
+
(0, type_graphql_1.Field)(),
|
47
47
|
__metadata("design:type", String)
|
48
48
|
], Filter.prototype, "name", void 0);
|
49
49
|
__decorate([
|
50
|
-
type_graphql_1.Field(),
|
50
|
+
(0, type_graphql_1.Field)(),
|
51
51
|
__metadata("design:type", String)
|
52
52
|
], Filter.prototype, "operator", void 0);
|
53
53
|
__decorate([
|
54
|
-
type_graphql_1.Field(type => scalar_any_1.ScalarAny),
|
54
|
+
(0, type_graphql_1.Field)(type => scalar_any_1.ScalarAny),
|
55
55
|
__metadata("design:type", Object)
|
56
56
|
], Filter.prototype, "value", void 0);
|
57
57
|
__decorate([
|
58
|
-
type_graphql_1.Field({ nullable: true }),
|
58
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
59
59
|
__metadata("design:type", Boolean)
|
60
60
|
], Filter.prototype, "relation", void 0);
|
61
61
|
Filter = __decorate([
|
62
|
-
type_graphql_1.InputType()
|
62
|
+
(0, type_graphql_1.InputType)()
|
63
63
|
], Filter);
|
64
64
|
exports.Filter = Filter;
|
65
65
|
let ListParam = class ListParam {
|
66
66
|
};
|
67
67
|
__decorate([
|
68
|
-
type_graphql_1.Field(type => [Filter], { nullable: true }),
|
68
|
+
(0, type_graphql_1.Field)(type => [Filter], { nullable: true }),
|
69
69
|
__metadata("design:type", Array)
|
70
70
|
], ListParam.prototype, "filters", void 0);
|
71
71
|
__decorate([
|
72
|
-
type_graphql_1.Field(type => Pagination, { nullable: true }),
|
72
|
+
(0, type_graphql_1.Field)(type => Pagination, { nullable: true }),
|
73
73
|
__metadata("design:type", Pagination)
|
74
74
|
], ListParam.prototype, "pagination", void 0);
|
75
75
|
__decorate([
|
76
|
-
type_graphql_1.Field(type => [Sorting], { nullable: true }),
|
76
|
+
(0, type_graphql_1.Field)(type => [Sorting], { nullable: true }),
|
77
77
|
__metadata("design:type", Array)
|
78
78
|
], ListParam.prototype, "sortings", void 0);
|
79
79
|
ListParam = __decorate([
|
80
|
-
type_graphql_1.ArgsType()
|
80
|
+
(0, type_graphql_1.ArgsType)()
|
81
81
|
], ListParam);
|
82
82
|
exports.ListParam = ListParam;
|
83
83
|
//# sourceMappingURL=list-param.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"list-param.js","sourceRoot":"","sources":["../../../server/service/common-types/list-param.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA8D;AAC9D,6CAAwC;AAGxC,IAAa,OAAO,GAApB,MAAa,OAAO;CAMnB,CAAA;AAJC;IADC,oBAAK,
|
1
|
+
{"version":3,"file":"list-param.js","sourceRoot":"","sources":["../../../server/service/common-types/list-param.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA8D;AAC9D,6CAAwC;AAGxC,IAAa,OAAO,GAApB,MAAa,OAAO;CAMnB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;;qCACpC;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oDAAoD,EAAE,CAAC;;qCAC/E;AALH,OAAO;IADnB,IAAA,wBAAS,GAAE;GACC,OAAO,CAMnB;AANY,0BAAO;AASpB,IAAa,UAAU,GAAvB,MAAa,UAAU;CAMtB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCAC1B;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACzB;AALH,UAAU;IADtB,IAAA,wBAAS,GAAE;GACC,UAAU,CAMtB;AANY,gCAAU;AASvB,IAAa,MAAM,GAAnB,MAAa,MAAM;CAYlB,CAAA;AAVC;IADC,IAAA,oBAAK,GAAE;;oCACI;AAGZ;IADC,IAAA,oBAAK,GAAE;;wCACQ;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,sBAAS,CAAC;;qCACf;AAGV;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCACR;AAXP,MAAM;IADlB,IAAA,wBAAS,GAAE;GACC,MAAM,CAYlB;AAZY,wBAAM;AAenB,IAAa,SAAS,GAAtB,MAAa,SAAS;CASrB,CAAA;AAPC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CAC1B;AAGlB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACjC,UAAU;6CAAA;AAGvB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACzB;AART,SAAS;IADrB,IAAA,uBAAQ,GAAE;GACE,SAAS,CASrB;AATY,8BAAS"}
|
@@ -15,23 +15,23 @@ const scalar_object_1 = require("./scalar-object");
|
|
15
15
|
let Log = class Log {
|
16
16
|
};
|
17
17
|
__decorate([
|
18
|
-
type_graphql_1.Field(() => scalar_object_1.ScalarObject, { description: 'the source of the log' }),
|
18
|
+
(0, type_graphql_1.Field)(() => scalar_object_1.ScalarObject, { description: 'the source of the log' }),
|
19
19
|
__metadata("design:type", Object)
|
20
20
|
], Log.prototype, "source", void 0);
|
21
21
|
__decorate([
|
22
|
-
type_graphql_1.Field({ description: 'log level (error, warning, info, ..)' }),
|
22
|
+
(0, type_graphql_1.Field)({ description: 'log level (error, warning, info, ..)' }),
|
23
23
|
__metadata("design:type", String)
|
24
24
|
], Log.prototype, "level", void 0);
|
25
25
|
__decorate([
|
26
|
-
type_graphql_1.Field({ description: 'log body message' }),
|
26
|
+
(0, type_graphql_1.Field)({ description: 'log body message' }),
|
27
27
|
__metadata("design:type", String)
|
28
28
|
], Log.prototype, "message", void 0);
|
29
29
|
__decorate([
|
30
|
-
type_graphql_1.Field({ description: 'timestamp the log occurred' }),
|
30
|
+
(0, type_graphql_1.Field)({ description: 'timestamp the log occurred' }),
|
31
31
|
__metadata("design:type", String)
|
32
32
|
], Log.prototype, "timestamp", void 0);
|
33
33
|
Log = __decorate([
|
34
|
-
type_graphql_1.ObjectType()
|
34
|
+
(0, type_graphql_1.ObjectType)()
|
35
35
|
], Log);
|
36
36
|
exports.Log = Log;
|
37
37
|
//# sourceMappingURL=log.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../server/service/common-types/log.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAgD;AAChD,mDAA8C;AAG9C,IAAa,GAAG,GAAhB,MAAa,GAAG;CAYf,CAAA;AAVC;IADC,oBAAK,
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../server/service/common-types/log.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAgD;AAChD,mDAA8C;AAG9C,IAAa,GAAG,GAAhB,MAAa,GAAG;CAYf,CAAA;AAVC;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,4BAAY,EAAE,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;;mCACtD;AAGd;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;;kCAClD;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;;oCAC5B;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;;sCACpC;AAXN,GAAG;IADf,IAAA,yBAAU,GAAE;GACA,GAAG,CAYf;AAZY,kBAAG"}
|
@@ -14,19 +14,19 @@ const type_graphql_1 = require("type-graphql");
|
|
14
14
|
let ObjectRef = class ObjectRef {
|
15
15
|
};
|
16
16
|
__decorate([
|
17
|
-
type_graphql_1.Field(() => type_graphql_1.ID, { description: 'Field id' }),
|
17
|
+
(0, type_graphql_1.Field)(() => type_graphql_1.ID, { description: 'Field id' }),
|
18
18
|
__metadata("design:type", String)
|
19
19
|
], ObjectRef.prototype, "id", void 0);
|
20
20
|
__decorate([
|
21
|
-
type_graphql_1.Field({ nullable: true, description: 'Field name' }),
|
21
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Field name' }),
|
22
22
|
__metadata("design:type", String)
|
23
23
|
], ObjectRef.prototype, "name", void 0);
|
24
24
|
__decorate([
|
25
|
-
type_graphql_1.Field({ nullable: true, description: 'Field description' }),
|
25
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Field description' }),
|
26
26
|
__metadata("design:type", String)
|
27
27
|
], ObjectRef.prototype, "description", void 0);
|
28
28
|
ObjectRef = __decorate([
|
29
|
-
type_graphql_1.InputType()
|
29
|
+
(0, type_graphql_1.InputType)()
|
30
30
|
], ObjectRef);
|
31
31
|
exports.ObjectRef = ObjectRef;
|
32
32
|
//# sourceMappingURL=object-ref.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"object-ref.js","sourceRoot":"","sources":["../../../server/service/common-types/object-ref.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAmD;AAGnD,IAAa,SAAS,GAAtB,MAAa,SAAS;CASrB,CAAA;AAPC;IADC,oBAAK,
|
1
|
+
{"version":3,"file":"object-ref.js","sourceRoot":"","sources":["../../../server/service/common-types/object-ref.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAmD;AAGnD,IAAa,SAAS,GAAtB,MAAa,SAAS;CASrB,CAAA;AAPC;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;;qCACnC;AAGV;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;uCACxC;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;;8CACxC;AART,SAAS;IADrB,IAAA,wBAAS,GAAE;GACC,SAAS,CASrB;AATY,8BAAS"}
|
@@ -7,18 +7,18 @@ const typeorm_1 = require("typeorm");
|
|
7
7
|
const utils_1 = require("@graphql-tools/utils");
|
8
8
|
const debug = require('debug')('things-factory:shell:directive-transaction');
|
9
9
|
const DIRECTIVE = 'transaction';
|
10
|
-
exports.transactionDirectiveTypeDefs = graphql_tag_1.gql `
|
10
|
+
exports.transactionDirectiveTypeDefs = (0, graphql_tag_1.gql) `
|
11
11
|
directive @${DIRECTIVE} on FIELD_DEFINITION
|
12
12
|
`;
|
13
|
-
const transactionDirectiveResolver = (schema) => utils_1.mapSchema(schema, {
|
13
|
+
const transactionDirectiveResolver = (schema) => (0, utils_1.mapSchema)(schema, {
|
14
14
|
[utils_1.MapperKind.OBJECT_FIELD]: (fieldConfig, fieldName) => {
|
15
15
|
var _a;
|
16
|
-
const transactionDirective = (_a = utils_1.getDirective(schema, fieldConfig, DIRECTIVE)) === null || _a === void 0 ? void 0 : _a[0];
|
16
|
+
const transactionDirective = (_a = (0, utils_1.getDirective)(schema, fieldConfig, DIRECTIVE)) === null || _a === void 0 ? void 0 : _a[0];
|
17
17
|
if (transactionDirective) {
|
18
18
|
const { resolve = graphql_1.defaultFieldResolver } = fieldConfig;
|
19
19
|
fieldConfig.resolve = async function (source, args, context, info) {
|
20
20
|
debug('@transaction-begin : ', fieldName);
|
21
|
-
return await typeorm_1.getConnection().transaction(async (tx) => {
|
21
|
+
return await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
22
22
|
/* local-graphql-client로부터 invoke인 경우에는 context.req, context.res 가 없으므로, 빈 오브젝트로 대체해준다. */
|
23
23
|
let wrap = context.app.createContext(context.req || {}, context.res || {});
|
24
24
|
wrap.state = Object.assign(Object.assign({}, context.state), { tx });
|