@things-factory/shell 4.3.671 → 4.3.673

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 (89) hide show
  1. package/dist-server/graphql-local-client.js +36 -0
  2. package/dist-server/graphql-local-client.js.map +1 -0
  3. package/dist-server/index.js +25 -0
  4. package/dist-server/index.js.map +1 -0
  5. package/dist-server/initializers/database.js +30 -0
  6. package/dist-server/initializers/database.js.map +1 -0
  7. package/dist-server/initializers/naming-strategy.js +19 -0
  8. package/dist-server/initializers/naming-strategy.js.map +1 -0
  9. package/dist-server/middlewares/domain-middleware.js +23 -0
  10. package/dist-server/middlewares/domain-middleware.js.map +1 -0
  11. package/dist-server/middlewares/index.js +59 -0
  12. package/dist-server/middlewares/index.js.map +1 -0
  13. package/dist-server/migrations/1000000000000-SeedDomain.js +29 -0
  14. package/dist-server/migrations/1000000000000-SeedDomain.js.map +1 -0
  15. package/dist-server/migrations/index.js +12 -0
  16. package/dist-server/migrations/index.js.map +1 -0
  17. package/dist-server/pubsub-log-transport.js +27 -0
  18. package/dist-server/pubsub-log-transport.js.map +1 -0
  19. package/dist-server/pubsub.js +84 -0
  20. package/dist-server/pubsub.js.map +1 -0
  21. package/dist-server/routers/domain-router.js +20 -0
  22. package/dist-server/routers/domain-router.js.map +1 -0
  23. package/dist-server/routers/global-router.js +47 -0
  24. package/dist-server/routers/global-router.js.map +1 -0
  25. package/dist-server/routers/index.js +19 -0
  26. package/dist-server/routers/index.js.map +1 -0
  27. package/dist-server/schema.js +109 -0
  28. package/dist-server/schema.js.map +1 -0
  29. package/dist-server/server-dev.js +217 -0
  30. package/dist-server/server-dev.js.map +1 -0
  31. package/dist-server/server.js +177 -0
  32. package/dist-server/server.js.map +1 -0
  33. package/dist-server/service/common-types/index.js +23 -0
  34. package/dist-server/service/common-types/index.js.map +1 -0
  35. package/dist-server/service/common-types/list-param.js +83 -0
  36. package/dist-server/service/common-types/list-param.js.map +1 -0
  37. package/dist-server/service/common-types/log.js +37 -0
  38. package/dist-server/service/common-types/log.js.map +1 -0
  39. package/dist-server/service/common-types/object-ref.js +32 -0
  40. package/dist-server/service/common-types/object-ref.js.map +1 -0
  41. package/dist-server/service/common-types/scalar-any.js +45 -0
  42. package/dist-server/service/common-types/scalar-any.js.map +1 -0
  43. package/dist-server/service/common-types/scalar-date.js +25 -0
  44. package/dist-server/service/common-types/scalar-date.js.map +1 -0
  45. package/dist-server/service/common-types/scalar-object.js +18 -0
  46. package/dist-server/service/common-types/scalar-object.js.map +1 -0
  47. package/dist-server/service/directive-transaction/index.js +18 -0
  48. package/dist-server/service/directive-transaction/index.js.map +1 -0
  49. package/dist-server/service/directive-transaction/transaction.js +35 -0
  50. package/dist-server/service/directive-transaction/transaction.js.map +1 -0
  51. package/dist-server/service/domain/domain-resolver.js +150 -0
  52. package/dist-server/service/domain/domain-resolver.js.map +1 -0
  53. package/dist-server/service/domain/domain-types.js +89 -0
  54. package/dist-server/service/domain/domain-types.js.map +1 -0
  55. package/dist-server/service/domain/domain.js +113 -0
  56. package/dist-server/service/domain/domain.js.map +1 -0
  57. package/dist-server/service/domain/index.js +8 -0
  58. package/dist-server/service/domain/index.js.map +1 -0
  59. package/dist-server/service/index.js +45 -0
  60. package/dist-server/service/index.js.map +1 -0
  61. package/dist-server/service/subscription-data/data-resolver.js +62 -0
  62. package/dist-server/service/subscription-data/data-resolver.js.map +1 -0
  63. package/dist-server/service/subscription-data/data-types.js +35 -0
  64. package/dist-server/service/subscription-data/data-types.js.map +1 -0
  65. package/dist-server/service/subscription-data/index.js +7 -0
  66. package/dist-server/service/subscription-data/index.js.map +1 -0
  67. package/dist-server/utils/condition-builder.js +126 -0
  68. package/dist-server/utils/condition-builder.js.map +1 -0
  69. package/dist-server/utils/get-domain.js +128 -0
  70. package/dist-server/utils/get-domain.js.map +1 -0
  71. package/dist-server/utils/index.js +22 -0
  72. package/dist-server/utils/index.js.map +1 -0
  73. package/dist-server/utils/list-params-converter.js +102 -0
  74. package/dist-server/utils/list-params-converter.js.map +1 -0
  75. package/dist-server/utils/list-query-builder.js +51 -0
  76. package/dist-server/utils/list-query-builder.js.map +1 -0
  77. package/dist-server/utils/publish-progress.js +18 -0
  78. package/dist-server/utils/publish-progress.js.map +1 -0
  79. package/dist-server/webpack/koa-webpack/client.js +24 -0
  80. package/dist-server/webpack/koa-webpack/client.js.map +1 -0
  81. package/dist-server/webpack/koa-webpack/index.js +58 -0
  82. package/dist-server/webpack/koa-webpack/index.js.map +1 -0
  83. package/dist-server/webpack/koa-webpack/middleware.js +42 -0
  84. package/dist-server/webpack/koa-webpack/middleware.js.map +1 -0
  85. package/dist-server/webpack/koa-webpack/validate.js +26 -0
  86. package/dist-server/webpack/koa-webpack/validate.js.map +1 -0
  87. package/package.json +2 -2
  88. package/server/index.ts +0 -2
  89. package/server/pubsub.ts +1 -1
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ // @prettier-ignore
7
+ process.env.NODE_ENV = 'development';
8
+ process.setMaxListeners(0);
9
+ /** Never move following lines */
10
+ const subscriptions_transport_ws_1 = require("subscriptions-transport-ws");
11
+ const env_1 = require("@things-factory/env");
12
+ const routers_1 = require("./routers");
13
+ const graphql_1 = require("graphql");
14
+ const apollo_server_koa_1 = require("apollo-server-koa");
15
+ const apollo_server_core_1 = require("apollo-server-core");
16
+ const graphql_local_client_1 = require("./graphql-local-client");
17
+ const koa_1 = __importDefault(require("koa"));
18
+ const co_1 = __importDefault(require("co"));
19
+ const koa_compose_1 = __importDefault(require("koa-compose"));
20
+ const cors_1 = __importDefault(require("@koa/cors"));
21
+ const http_1 = require("http");
22
+ const database_1 = require("./initializers/database");
23
+ const graphql_upload_1 = require("graphql-upload");
24
+ const koa2_connect_history_api_fallback_1 = require("koa2-connect-history-api-fallback");
25
+ const koa_ip_1 = __importDefault(require("koa-ip"));
26
+ const koa_bodyparser_1 = __importDefault(require("koa-bodyparser"));
27
+ const koa_static_1 = __importDefault(require("koa-static"));
28
+ const koa_webpack_1 = __importDefault(require("@hatiolab/koa-webpack"));
29
+ const schema_1 = require("./schema");
30
+ const bytes_1 = __importDefault(require("bytes"));
31
+ const debug = require('debug')('things-factory:shell:server-dev');
32
+ const args = require('args');
33
+ args.option('port', 'The port on which the app will be running', env_1.config.get('port', 3000));
34
+ args.option('inspect', `The address on which the inspection will be running. Used in development mode only.
35
+ This option is just to prevent termination for reasons of not recognizing the 'inspect' option.`, env_1.config.get('inspect', ':9229'));
36
+ const flags = args.parse(process.argv);
37
+ const path = require('path');
38
+ const webpack = require('webpack');
39
+ const webpackConfig = require('@things-factory/builder/webpack.config.dev.js');
40
+ const compiler = webpack(webpackConfig);
41
+ const PORT = (process.env.PORT = flags.port);
42
+ const keepAliveTimeout = process.env.keepAliveTimeout || '61000';
43
+ const headersTimeout = process.env.headersTimeout || '30000';
44
+ const requestBody = env_1.config.get('requestBody') || {};
45
+ const bodyParserOption = {
46
+ formLimit: requestBody.formLimit || '10mb',
47
+ jsonLimit: requestBody.jsonLimit || '10mb',
48
+ textLimit: requestBody.textLimit || '10mb'
49
+ };
50
+ const fileUpload = env_1.config.get('fileUpload') || {};
51
+ const fileUploadOption = {
52
+ maxFileSize: bytes_1.default.parse(fileUpload.maxFileSize) || bytes_1.default.parse('10mb'),
53
+ maxFiles: fileUpload.maxFiles || 10
54
+ };
55
+ /* bootstrap */
56
+ const bootstrap = async () => {
57
+ try {
58
+ await (0, database_1.databaseInitializer)();
59
+ const app = new koa_1.default();
60
+ app.use((0, cors_1.default)({
61
+ origin: function (ctx) {
62
+ return ctx.request.headers.origin || '*';
63
+ },
64
+ exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],
65
+ maxAge: 5,
66
+ credentials: true,
67
+ /* allowMethods: ['GET', 'POST', 'DELETE'], -- use default */
68
+ allowHeaders: ['Content-Type', 'Authorization', 'Accept']
69
+ }));
70
+ const whitelist = env_1.config.get('whitelist');
71
+ const blacklist = env_1.config.get('blacklist');
72
+ if (whitelist || blacklist) {
73
+ app.use((0, koa_ip_1.default)({
74
+ whitelist,
75
+ blacklist,
76
+ handler: async (ctx, next) => {
77
+ ctx.status = 403;
78
+ }
79
+ }));
80
+ }
81
+ var subscriptionMiddleware = [];
82
+ process.emit('bootstrap-module-subscription', app, subscriptionMiddleware);
83
+ const builtSchema = await (0, schema_1.schema)();
84
+ const httpServer = (0, http_1.createServer)(app.callback());
85
+ const subscriptionServer = subscriptions_transport_ws_1.SubscriptionServer.create({
86
+ schema: builtSchema,
87
+ // These are imported from `graphql`.
88
+ execute: graphql_1.execute,
89
+ subscribe: graphql_1.subscribe,
90
+ async onConnect(connectionParams, webSocket, context) {
91
+ var { request } = context;
92
+ var url = new URL((connectionParams['headers'] || connectionParams).referer);
93
+ var accessToken = url.searchParams.get('access_token');
94
+ connectionParams['headers']['authorization'] = accessToken;
95
+ request.headers = Object.assign(Object.assign({}, request.headers), (connectionParams['headers'] || connectionParams));
96
+ var koacontext = await app.createContext(request, {});
97
+ koacontext['state'] = {};
98
+ /* in case connect error(like a authentication error) just throw exception */
99
+ var middlewares = [...subscriptionMiddleware];
100
+ const fn = co_1.default.wrap((0, koa_compose_1.default)(middlewares));
101
+ await fn(koacontext);
102
+ return koacontext;
103
+ }
104
+ }, {
105
+ server: httpServer,
106
+ path: '/subscriptions'
107
+ });
108
+ const server = new apollo_server_koa_1.ApolloServer({
109
+ schema: builtSchema,
110
+ formatError: error => {
111
+ env_1.logger.error(error);
112
+ return error;
113
+ },
114
+ formatResponse: response => {
115
+ // logger.info('response %s', JSON.stringify(response, null, 2))
116
+ return response;
117
+ },
118
+ context: async ({ connection, ctx }) => {
119
+ if (connection) {
120
+ return connection.context;
121
+ }
122
+ else {
123
+ return ctx;
124
+ }
125
+ },
126
+ plugins: [
127
+ (0, apollo_server_core_1.ApolloServerPluginLandingPageGraphQLPlayground)({
128
+ settings: {
129
+ 'request.credentials': 'same-origin'
130
+ }
131
+ }),
132
+ {
133
+ async serverWillStart() {
134
+ return {
135
+ async drainServer() {
136
+ subscriptionServer.close();
137
+ }
138
+ };
139
+ }
140
+ }
141
+ ],
142
+ cache: 'bounded'
143
+ });
144
+ server.start();
145
+ graphql_local_client_1.GraphqlLocalClient.init(builtSchema, app);
146
+ env_1.orderedModuleNames.forEach(name => {
147
+ const { initMiddlewares } = (0, env_1.loader)(name);
148
+ initMiddlewares && initMiddlewares(app);
149
+ });
150
+ const render = require('@things-factory/ejs-remote');
151
+ render(app, {
152
+ root: '/views',
153
+ host: `http://127.0.0.1:${PORT}`,
154
+ layout: false,
155
+ viewExt: 'html',
156
+ cache: false,
157
+ debug: false
158
+ });
159
+ const middleware = await (0, koa_webpack_1.default)({
160
+ compiler,
161
+ hotClient: {},
162
+ devMiddleware: {
163
+ publicPath: webpackConfig.output.publicPath,
164
+ stats: { colors: true }
165
+ }
166
+ });
167
+ // only for development mode. triggered after webpack compilation is done.
168
+ compiler.hooks.done.tap({ name: 'server-dev' }, stats => {
169
+ process.emit('client-rebuilt', app, compiler.outputFileSystem);
170
+ });
171
+ app.use((0, koa_bodyparser_1.default)(bodyParserOption));
172
+ app.use((ctx, next) => {
173
+ // Check if the request path is for the GraphQL endpoint.
174
+ if (ctx.path === '/graphql') {
175
+ return (0, graphql_upload_1.graphqlUploadKoa)(fileUploadOption)(ctx, next);
176
+ }
177
+ // If not, just continue to the next middleware.
178
+ return next();
179
+ });
180
+ app.use(server.getMiddleware({
181
+ path: '/graphql'
182
+ }));
183
+ /* routers */
184
+ process.emit('bootstrap-module-global-public-route', app, routers_1.globalPublicRouter);
185
+ process.emit('bootstrap-module-global-private-route', app, routers_1.globalPrivateRouter);
186
+ process.emit('bootstrap-module-domain-public-route', app, routers_1.domainPublicRouter);
187
+ process.emit('bootstrap-module-domain-private-route', app, routers_1.domainPrivateRouter);
188
+ app
189
+ .use(routers_1.globalPublicRouter.routes())
190
+ .use(routers_1.globalPublicRouter.allowedMethods())
191
+ .use(routers_1.globalPrivateRouter.routes())
192
+ .use(routers_1.globalPrivateRouter.allowedMethods())
193
+ .use(routers_1.domainPublicRouter.routes())
194
+ .use(routers_1.domainPublicRouter.allowedMethods())
195
+ .use(routers_1.domainPrivateRouter.routes())
196
+ .use(routers_1.domainPrivateRouter.allowedMethods());
197
+ /* should be history-fallback => webpack-middleware => koaStatic */
198
+ app.use((0, koa2_connect_history_api_fallback_1.historyApiFallback)({ whiteList: [] }));
199
+ app.use(middleware);
200
+ app.use((0, koa_static_1.default)(compiler.outputPath, {
201
+ index: false
202
+ }));
203
+ httpServer.keepAliveTimeout = parseInt(keepAliveTimeout);
204
+ httpServer.headersTimeout = parseInt(headersTimeout);
205
+ httpServer.listen({ port: PORT }, () => {
206
+ env_1.logger.info(`🚀 Server ready at http://0.0.0.0:${PORT}${server.graphqlPath}`);
207
+ env_1.logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}${'/subscriptions'}`);
208
+ process.emit('bootstrap-module-start', { app, config: env_1.config, builtSchema, httpServer });
209
+ });
210
+ }
211
+ catch (error) {
212
+ console.log(error);
213
+ throw error;
214
+ }
215
+ };
216
+ bootstrap();
217
+ //# sourceMappingURL=server-dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-dev.js","sourceRoot":"","sources":["../server/server-dev.ts"],"names":[],"mappings":";;;;;AAAA,mBAAmB;AACnB,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAA;AACpC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;AAC1B,iCAAiC;AAEjC,2EAAkF;AAClF,6CAAgF;AAChF,uCAA4G;AAC5G,qCAA4C;AAE5C,yDAAgD;AAChD,2DAAmF;AACnF,iEAA2D;AAC3D,8CAAqB;AACrB,4CAAmB;AACnB,8DAAiC;AACjC,qDAA4B;AAC5B,+BAAmC;AACnC,sDAA6D;AAC7D,mDAAiD;AACjD,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AM,CAAC,IAAI,CAAC,0CAA0C,IAAI,GAAG,gBAAgB,EAAE,CAAC,CAAA;YAEhF,OAAO,CAAC,IAAI,CAAC,wBAA+B,EAAE,EAAE,GAAG,EAAE,MAAM,EAAN,YAAM,EAAE,WAAW,EAAE,UAAU,EAAS,CAAC,CAAA;QAChG,CAAC,CAAC,CAAA;KACH;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAClB,MAAM,KAAK,CAAA;KACZ;AACH,CAAC,CAAA;AAED,SAAS,EAAE,CAAA"}
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ process.env.NODE_ENV = 'production';
7
+ process.setMaxListeners(0);
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");
12
+ const apollo_server_koa_1 = require("apollo-server-koa");
13
+ const graphql_local_client_1 = require("./graphql-local-client");
14
+ const koa_1 = __importDefault(require("koa"));
15
+ const co_1 = __importDefault(require("co"));
16
+ const koa_compose_1 = __importDefault(require("koa-compose"));
17
+ const cors_1 = __importDefault(require("@koa/cors"));
18
+ const http_1 = require("http");
19
+ const database_1 = require("./initializers/database");
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"));
25
+ const schema_1 = require("./schema");
26
+ const bytes_1 = __importDefault(require("bytes"));
27
+ const args = require('args');
28
+ args.option('port', 'The port on which the app will be running', env_1.config.get('port', 3000));
29
+ const flags = args.parse(process.argv);
30
+ const path = require('path');
31
+ const PORT = (process.env.PORT = flags.port);
32
+ const keepAliveTimeout = process.env.keepAliveTimeout || '61000';
33
+ const headersTimeout = process.env.headersTimeout || '30000';
34
+ const requestBody = env_1.config.get('requestBody') || {};
35
+ const bodyParserOption = {
36
+ formLimit: requestBody.formLimit || '10mb',
37
+ jsonLimit: requestBody.jsonLimit || '10mb',
38
+ textLimit: requestBody.textLimit || '10mb'
39
+ };
40
+ const fileUpload = env_1.config.get('fileUpload') || {};
41
+ const fileUploadOption = {
42
+ maxFileSize: bytes_1.default.parse(fileUpload.maxFileSize) || bytes_1.default.parse('10mb'),
43
+ maxFiles: fileUpload.maxFiles || 10
44
+ };
45
+ /* bootstrap */
46
+ const bootstrap = async () => {
47
+ await (0, database_1.databaseInitializer)();
48
+ const app = new koa_1.default();
49
+ app.use((0, cors_1.default)({
50
+ origin: function (ctx) {
51
+ return ctx.request.headers.origin || '*';
52
+ },
53
+ exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],
54
+ maxAge: 5,
55
+ credentials: true,
56
+ /* allowMethods: ['GET', 'POST', 'DELETE'], -- use default */
57
+ allowHeaders: ['Content-Type', 'Authorization', 'Accept']
58
+ }));
59
+ const whitelist = env_1.config.get('whitelist');
60
+ const blacklist = env_1.config.get('blacklist');
61
+ if (whitelist || blacklist) {
62
+ app.use((0, koa_ip_1.default)({
63
+ whitelist,
64
+ blacklist,
65
+ handler: async (ctx, next) => {
66
+ ctx.status = 403;
67
+ }
68
+ }));
69
+ }
70
+ var subscriptionMiddleware = [];
71
+ process.emit('bootstrap-module-subscription', app, subscriptionMiddleware);
72
+ const builtSchema = await (0, schema_1.schema)();
73
+ const httpServer = (0, http_1.createServer)(app.callback());
74
+ const subscriptionServer = subscriptions_transport_ws_1.SubscriptionServer.create({
75
+ schema: builtSchema,
76
+ // These are imported from `graphql`.
77
+ execute: graphql_1.execute,
78
+ subscribe: graphql_1.subscribe,
79
+ async onConnect(connectionParams, webSocket, context) {
80
+ var { request } = context;
81
+ var url = new URL((connectionParams['headers'] || connectionParams).referer);
82
+ var accessToken = url.searchParams.get('access_token');
83
+ connectionParams['headers']['authorization'] = accessToken;
84
+ request.headers = Object.assign(Object.assign({}, request.headers), (connectionParams['headers'] || connectionParams));
85
+ /* in case connect error(like a authentication error) just throw exception */
86
+ var koacontext = await app.createContext(request, {});
87
+ koacontext['state'] = {};
88
+ var middlewares = [...subscriptionMiddleware];
89
+ const fn = co_1.default.wrap((0, koa_compose_1.default)(middlewares));
90
+ await fn(koacontext);
91
+ return koacontext;
92
+ }
93
+ }, {
94
+ server: httpServer,
95
+ path: '/subscriptions'
96
+ });
97
+ const server = new apollo_server_koa_1.ApolloServer({
98
+ schema: builtSchema,
99
+ formatError: error => {
100
+ env_1.logger.error(error);
101
+ return error;
102
+ },
103
+ formatResponse: response => {
104
+ // logger.info('response %s', JSON.stringify(response, null, 2))
105
+ return response;
106
+ },
107
+ introspection: true,
108
+ context: async ({ connection, ctx }) => {
109
+ if (connection) {
110
+ return connection.context;
111
+ }
112
+ else {
113
+ return ctx;
114
+ }
115
+ },
116
+ plugins: [
117
+ {
118
+ async serverWillStart() {
119
+ return {
120
+ async drainServer() {
121
+ subscriptionServer.close();
122
+ }
123
+ };
124
+ }
125
+ }
126
+ ],
127
+ cache: 'bounded'
128
+ });
129
+ await server.start();
130
+ graphql_local_client_1.GraphqlLocalClient.init(builtSchema, app);
131
+ env_1.orderedModuleNames.forEach(name => {
132
+ const { initMiddlewares } = (0, env_1.loader)(name);
133
+ initMiddlewares && initMiddlewares(app);
134
+ });
135
+ const render = require('@things-factory/ejs-remote');
136
+ render(app, {
137
+ root: '/views',
138
+ host: `http://127.0.0.1:${PORT}`,
139
+ layout: false,
140
+ viewExt: 'html',
141
+ cache: true,
142
+ debug: false
143
+ });
144
+ app.use((0, koa_bodyparser_1.default)(bodyParserOption));
145
+ app.use((0, graphql_upload_1.graphqlUploadKoa)(fileUploadOption));
146
+ app.use(server.getMiddleware({
147
+ path: '/graphql'
148
+ }));
149
+ /* routers */
150
+ process.emit('bootstrap-module-global-public-route', app, routers_1.globalPublicRouter);
151
+ process.emit('bootstrap-module-global-private-route', app, routers_1.globalPrivateRouter);
152
+ process.emit('bootstrap-module-domain-public-route', app, routers_1.domainPublicRouter);
153
+ process.emit('bootstrap-module-domain-private-route', app, routers_1.domainPrivateRouter);
154
+ app
155
+ .use(routers_1.globalPublicRouter.routes())
156
+ .use(routers_1.globalPublicRouter.allowedMethods())
157
+ .use(routers_1.globalPrivateRouter.routes())
158
+ .use(routers_1.globalPrivateRouter.allowedMethods())
159
+ .use(routers_1.domainPublicRouter.routes())
160
+ .use(routers_1.domainPublicRouter.allowedMethods())
161
+ .use(routers_1.domainPrivateRouter.routes())
162
+ .use(routers_1.domainPrivateRouter.allowedMethods());
163
+ /* should be history-fallback => koaStatic */
164
+ app.use((0, koa2_connect_history_api_fallback_1.historyApiFallback)({ whiteList: [] }));
165
+ app.use((0, koa_static_1.default)(path.join(process.cwd(), 'dist-client'), {
166
+ index: 'index.html'
167
+ }));
168
+ httpServer.keepAliveTimeout = parseInt(keepAliveTimeout);
169
+ httpServer.headersTimeout = parseInt(headersTimeout);
170
+ httpServer.listen({ port: PORT }, () => {
171
+ env_1.logger.info(`🚀 Server ready at http://0.0.0.0:${PORT}${server.graphqlPath}`);
172
+ env_1.logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}${'/subscriptions'}`);
173
+ process.emit('bootstrap-module-start', { app, config: env_1.config, builtSchema, httpServer });
174
+ });
175
+ };
176
+ bootstrap();
177
+ //# sourceMappingURL=server.js.map
@@ -0,0 +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,2EAAkF;AAClF,6CAAgF;AAChF,uCAA4G;AAC5G,qCAA4C;AA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cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAA;IAEpD,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"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./list-param"), exports);
18
+ __exportStar(require("./scalar-any"), exports);
19
+ __exportStar(require("./scalar-date"), exports);
20
+ __exportStar(require("./scalar-object"), exports);
21
+ __exportStar(require("./object-ref"), exports);
22
+ __exportStar(require("./log"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/common-types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B;AAC5B,+CAA4B;AAC5B,gDAA6B;AAC7B,kDAA+B;AAC/B,+CAA4B;AAC5B,wCAAqB"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ListParam = exports.Filter = exports.Pagination = exports.Sorting = void 0;
13
+ const type_graphql_1 = require("type-graphql");
14
+ const scalar_any_1 = require("./scalar-any");
15
+ let Sorting = class Sorting {
16
+ };
17
+ __decorate([
18
+ (0, type_graphql_1.Field)({ description: 'Field name to sort by' }),
19
+ __metadata("design:type", String)
20
+ ], Sorting.prototype, "name", void 0);
21
+ __decorate([
22
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Set to true if descending sort. Default is "false"' }),
23
+ __metadata("design:type", Boolean)
24
+ ], Sorting.prototype, "desc", void 0);
25
+ Sorting = __decorate([
26
+ (0, type_graphql_1.InputType)()
27
+ ], Sorting);
28
+ exports.Sorting = Sorting;
29
+ let Pagination = class Pagination {
30
+ };
31
+ __decorate([
32
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
33
+ __metadata("design:type", Number)
34
+ ], Pagination.prototype, "page", void 0);
35
+ __decorate([
36
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
37
+ __metadata("design:type", Number)
38
+ ], Pagination.prototype, "limit", void 0);
39
+ Pagination = __decorate([
40
+ (0, type_graphql_1.InputType)()
41
+ ], Pagination);
42
+ exports.Pagination = Pagination;
43
+ let Filter = class Filter {
44
+ };
45
+ __decorate([
46
+ (0, type_graphql_1.Field)(),
47
+ __metadata("design:type", String)
48
+ ], Filter.prototype, "name", void 0);
49
+ __decorate([
50
+ (0, type_graphql_1.Field)(),
51
+ __metadata("design:type", String)
52
+ ], Filter.prototype, "operator", void 0);
53
+ __decorate([
54
+ (0, type_graphql_1.Field)(type => scalar_any_1.ScalarAny),
55
+ __metadata("design:type", Object)
56
+ ], Filter.prototype, "value", void 0);
57
+ __decorate([
58
+ (0, type_graphql_1.Field)({ nullable: true }),
59
+ __metadata("design:type", Boolean)
60
+ ], Filter.prototype, "relation", void 0);
61
+ Filter = __decorate([
62
+ (0, type_graphql_1.InputType)()
63
+ ], Filter);
64
+ exports.Filter = Filter;
65
+ let ListParam = class ListParam {
66
+ };
67
+ __decorate([
68
+ (0, type_graphql_1.Field)(type => [Filter], { nullable: true }),
69
+ __metadata("design:type", Array)
70
+ ], ListParam.prototype, "filters", void 0);
71
+ __decorate([
72
+ (0, type_graphql_1.Field)(type => Pagination, { nullable: true }),
73
+ __metadata("design:type", Pagination)
74
+ ], ListParam.prototype, "pagination", void 0);
75
+ __decorate([
76
+ (0, type_graphql_1.Field)(type => [Sorting], { nullable: true }),
77
+ __metadata("design:type", Array)
78
+ ], ListParam.prototype, "sortings", void 0);
79
+ ListParam = __decorate([
80
+ (0, type_graphql_1.ArgsType)()
81
+ ], ListParam);
82
+ exports.ListParam = ListParam;
83
+ //# sourceMappingURL=list-param.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-param.js","sourceRoot":"","sources":["../../../server/service/common-types/list-param.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA8D;AAC9D,6CAAwC;AAGjC,IAAM,OAAO,GA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E,IAAI,EAAE,CAAC;8BACjC,UAAU;6CAAA;AAEvB;IAAC,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"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Log = void 0;
13
+ const type_graphql_1 = require("type-graphql");
14
+ const scalar_object_1 = require("./scalar-object");
15
+ let Log = class Log {
16
+ };
17
+ __decorate([
18
+ (0, type_graphql_1.Field)(() => scalar_object_1.ScalarObject, { description: 'the source of the log' }),
19
+ __metadata("design:type", Object)
20
+ ], Log.prototype, "source", void 0);
21
+ __decorate([
22
+ (0, type_graphql_1.Field)({ description: 'log level (error, warning, info, ..)' }),
23
+ __metadata("design:type", String)
24
+ ], Log.prototype, "level", void 0);
25
+ __decorate([
26
+ (0, type_graphql_1.Field)({ description: 'log body message' }),
27
+ __metadata("design:type", String)
28
+ ], Log.prototype, "message", void 0);
29
+ __decorate([
30
+ (0, type_graphql_1.Field)({ description: 'timestamp the log occurred' }),
31
+ __metadata("design:type", String)
32
+ ], Log.prototype, "timestamp", void 0);
33
+ Log = __decorate([
34
+ (0, type_graphql_1.ObjectType)()
35
+ ], Log);
36
+ exports.Log = Log;
37
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../server/service/common-types/log.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAgD;AAChD,mDAA8C;AAGvC,IAAM,GAAG,GAAT,MAAM,GAAG;CAYf,CAAA;AAXC;IAAC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,4BAAY,EAAE,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;;mCACtD;AAEd;IAAC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;;kCAClD;AAEb;IAAC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;;oCAC5B;AAEf;IAAC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;;sCACpC;AAXN,GAAG;IADf,IAAA,yBAAU,GAAE;GACA,GAAG,CAYf;AAZY,kBAAG"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ObjectRef = void 0;
13
+ const type_graphql_1 = require("type-graphql");
14
+ let ObjectRef = class ObjectRef {
15
+ };
16
+ __decorate([
17
+ (0, type_graphql_1.Field)(() => type_graphql_1.ID, { description: 'Field id' }),
18
+ __metadata("design:type", String)
19
+ ], ObjectRef.prototype, "id", void 0);
20
+ __decorate([
21
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Field name' }),
22
+ __metadata("design:type", String)
23
+ ], ObjectRef.prototype, "name", void 0);
24
+ __decorate([
25
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Field description' }),
26
+ __metadata("design:type", String)
27
+ ], ObjectRef.prototype, "description", void 0);
28
+ ObjectRef = __decorate([
29
+ (0, type_graphql_1.InputType)()
30
+ ], ObjectRef);
31
+ exports.ObjectRef = ObjectRef;
32
+ //# sourceMappingURL=object-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-ref.js","sourceRoot":"","sources":["../../../server/service/common-types/object-ref.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAmD;AAG5C,IAAM,SAAS,GAAf,MAAM,SAAS;CASrB,CAAA;AARC;IAAC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;;qCACnC;AAEV;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;uCACxC;AAEb;IAAC,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"}