@things-factory/shell 9.0.0-beta.0 → 9.0.0-beta.5

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 (114) hide show
  1. package/bin/things-factory-migration +6 -3
  2. package/dist-server/index.d.ts +12 -12
  3. package/dist-server/index.js +12 -12
  4. package/dist-server/index.js.map +1 -1
  5. package/dist-server/initializers/database.js +4 -10
  6. package/dist-server/initializers/database.js.map +1 -1
  7. package/dist-server/initializers/ormconfig.d.ts +2 -0
  8. package/dist-server/initializers/ormconfig.js +30 -0
  9. package/dist-server/initializers/ormconfig.js.map +1 -0
  10. package/dist-server/middlewares/domain-middleware.js +2 -2
  11. package/dist-server/middlewares/domain-middleware.js.map +1 -1
  12. package/dist-server/middlewares/index.d.ts +1 -1
  13. package/dist-server/middlewares/index.js +3 -3
  14. package/dist-server/middlewares/index.js.map +1 -1
  15. package/dist-server/migrations/1000000000000-SeedDomain.js +4 -4
  16. package/dist-server/migrations/1000000000000-SeedDomain.js.map +1 -1
  17. package/dist-server/migrations/index.js +5 -4
  18. package/dist-server/migrations/index.js.map +1 -1
  19. package/dist-server/routers/domain-router.js +3 -3
  20. package/dist-server/routers/domain-router.js.map +1 -1
  21. package/dist-server/routers/global-router.js +6 -6
  22. package/dist-server/routers/global-router.js.map +1 -1
  23. package/dist-server/routers/index.d.ts +3 -3
  24. package/dist-server/routers/index.js +3 -3
  25. package/dist-server/routers/index.js.map +1 -1
  26. package/dist-server/schema.js +5 -4
  27. package/dist-server/schema.js.map +1 -1
  28. package/dist-server/server-dev.js +37 -37
  29. package/dist-server/server-dev.js.map +1 -1
  30. package/dist-server/server.js +33 -33
  31. package/dist-server/server.js.map +1 -1
  32. package/dist-server/service/attribute-set/attribute-set-item-type.js +3 -3
  33. package/dist-server/service/attribute-set/attribute-set-item-type.js.map +1 -1
  34. package/dist-server/service/attribute-set/attribute-set-mutation.d.ts +2 -2
  35. package/dist-server/service/attribute-set/attribute-set-mutation.js +16 -16
  36. package/dist-server/service/attribute-set/attribute-set-mutation.js.map +1 -1
  37. package/dist-server/service/attribute-set/attribute-set-query.d.ts +3 -3
  38. package/dist-server/service/attribute-set/attribute-set-query.js +15 -15
  39. package/dist-server/service/attribute-set/attribute-set-query.js.map +1 -1
  40. package/dist-server/service/attribute-set/attribute-set-type.d.ts +2 -2
  41. package/dist-server/service/attribute-set/attribute-set-type.js +5 -5
  42. package/dist-server/service/attribute-set/attribute-set-type.js.map +1 -1
  43. package/dist-server/service/attribute-set/attribute-set.d.ts +1 -1
  44. package/dist-server/service/attribute-set/attribute-set.js +2 -2
  45. package/dist-server/service/attribute-set/attribute-set.js.map +1 -1
  46. package/dist-server/service/attribute-set/index.d.ts +3 -3
  47. package/dist-server/service/attribute-set/index.js +5 -5
  48. package/dist-server/service/attribute-set/index.js.map +1 -1
  49. package/dist-server/service/common-types/index.d.ts +6 -6
  50. package/dist-server/service/common-types/index.js +6 -6
  51. package/dist-server/service/common-types/index.js.map +1 -1
  52. package/dist-server/service/common-types/list-param.js +2 -2
  53. package/dist-server/service/common-types/list-param.js.map +1 -1
  54. package/dist-server/service/common-types/log.js +2 -2
  55. package/dist-server/service/common-types/log.js.map +1 -1
  56. package/dist-server/service/common-types/scalar-object.d.ts +2 -1
  57. package/dist-server/service/common-types/scalar-object.js +2 -2
  58. package/dist-server/service/common-types/scalar-object.js.map +1 -1
  59. package/dist-server/service/directive-transaction/index.d.ts +1 -1
  60. package/dist-server/service/directive-transaction/index.js +1 -1
  61. package/dist-server/service/directive-transaction/index.js.map +1 -1
  62. package/dist-server/service/directive-transaction/transaction.js +2 -2
  63. package/dist-server/service/directive-transaction/transaction.js.map +1 -1
  64. package/dist-server/service/domain/domain-mutation.d.ts +2 -2
  65. package/dist-server/service/domain/domain-mutation.js +21 -21
  66. package/dist-server/service/domain/domain-mutation.js.map +1 -1
  67. package/dist-server/service/domain/domain-query.d.ts +3 -3
  68. package/dist-server/service/domain/domain-query.js +18 -18
  69. package/dist-server/service/domain/domain-query.js.map +1 -1
  70. package/dist-server/service/domain/domain-types.d.ts +2 -2
  71. package/dist-server/service/domain/domain-types.js +6 -6
  72. package/dist-server/service/domain/domain-types.js.map +1 -1
  73. package/dist-server/service/domain/domain.js +3 -3
  74. package/dist-server/service/domain/domain.js.map +1 -1
  75. package/dist-server/service/domain/index.d.ts +3 -3
  76. package/dist-server/service/domain/index.js +5 -5
  77. package/dist-server/service/domain/index.js.map +1 -1
  78. package/dist-server/service/index.d.ts +7 -7
  79. package/dist-server/service/index.js +16 -16
  80. package/dist-server/service/index.js.map +1 -1
  81. package/dist-server/service/subscription-data/data-resolver.d.ts +1 -1
  82. package/dist-server/service/subscription-data/data-resolver.js +4 -4
  83. package/dist-server/service/subscription-data/data-resolver.js.map +1 -1
  84. package/dist-server/service/subscription-data/data-types.d.ts +1 -1
  85. package/dist-server/service/subscription-data/data-types.js +5 -5
  86. package/dist-server/service/subscription-data/data-types.js.map +1 -1
  87. package/dist-server/service/subscription-data/index.d.ts +1 -1
  88. package/dist-server/service/subscription-data/index.js +2 -2
  89. package/dist-server/service/subscription-data/index.js.map +1 -1
  90. package/dist-server/tsconfig.tsbuildinfo +1 -1
  91. package/dist-server/typeorm/encrypt-transform.js +3 -3
  92. package/dist-server/typeorm/encrypt-transform.js.map +1 -1
  93. package/dist-server/utils/get-query-builder-from-list-params.d.ts +2 -2
  94. package/dist-server/utils/get-query-builder-from-list-params.js +5 -5
  95. package/dist-server/utils/get-query-builder-from-list-params.js.map +1 -1
  96. package/dist-server/utils/index.d.ts +8 -8
  97. package/dist-server/utils/index.js +8 -8
  98. package/dist-server/utils/index.js.map +1 -1
  99. package/dist-server/utils/list-param-adjuster.d.ts +1 -1
  100. package/dist-server/utils/list-param-adjuster.js.map +1 -1
  101. package/dist-server/utils/list-params-converter.d.ts +2 -2
  102. package/dist-server/utils/list-params-converter.js +2 -2
  103. package/dist-server/utils/list-params-converter.js.map +1 -1
  104. package/dist-server/utils/list-query-builder.d.ts +1 -1
  105. package/dist-server/utils/list-query-builder.js +7 -7
  106. package/dist-server/utils/list-query-builder.js.map +1 -1
  107. package/dist-server/utils/publish-progress.js +2 -2
  108. package/dist-server/utils/publish-progress.js.map +1 -1
  109. package/package.json +5 -7
  110. package/client/hot-client/hot.js +0 -140
  111. package/client/hot-client/index.js +0 -103
  112. package/client/hot-client/log.js +0 -44
  113. package/client/hot-client/socket.js +0 -63
  114. package/ormconfig.js +0 -31
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const tslib_1 = require("tslib");
5
5
  /* following 7 lines should be located in top of the file */
6
- const OS = require('os');
7
- process.env.UV_THREADPOOL_SIZE = OS.cpus().length;
6
+ const os_1 = tslib_1.__importDefault(require("os"));
7
+ process.env.UV_THREADPOOL_SIZE = String(os_1.default.availableParallelism());
8
8
  console.log('UV_THREADPOOL_SIZE', process.env.UV_THREADPOOL_SIZE);
9
9
  process.env.NODE_ENV = 'development';
10
10
  process.setMaxListeners(0);
@@ -12,6 +12,8 @@ const server_1 = require("@apollo/server");
12
12
  const drainHttpServer_1 = require("@apollo/server/plugin/drainHttpServer");
13
13
  const default_1 = require("@apollo/server/plugin/landingPage/default");
14
14
  const koa_1 = require("@as-integrations/koa");
15
+ const args_1 = tslib_1.__importDefault(require("args"));
16
+ const webpack_dev_middleware_1 = tslib_1.__importDefault(require("webpack-dev-middleware"));
15
17
  const bytes_1 = tslib_1.__importDefault(require("bytes"));
16
18
  const graphqlUploadKoa_js_1 = tslib_1.__importDefault(require("graphql-upload/graphqlUploadKoa.js"));
17
19
  const ws_1 = require("graphql-ws/lib/use/ws");
@@ -27,23 +29,21 @@ const cors_1 = tslib_1.__importDefault(require("@koa/cors"));
27
29
  const crypto_1 = tslib_1.__importDefault(require("crypto"));
28
30
  const env_1 = require("@things-factory/env");
29
31
  const operato_license_checker_1 = require("@things-factory/operato-license-checker");
30
- const graphql_local_client_1 = require("./graphql-local-client");
31
- const database_1 = require("./initializers/database");
32
- const routers_1 = require("./routers");
33
- const schema_1 = require("./schema");
34
- const middlewares_1 = require("./middlewares");
35
- const process_cleaner_1 = require("./process-cleaner");
36
- const wdm = require('webpack-dev-middleware');
37
- (0, process_cleaner_1.setupProcessExitHandlers)();
38
- const args = require('args');
39
- args.option('port', 'The port on which the app will be running', env_1.config.get('port', 3000));
40
- args.option('inspect', `The address on which the inspection will be running. Used in development mode only.
32
+ const graphql_local_client_js_1 = require("./graphql-local-client.js");
33
+ const database_js_1 = require("./initializers/database.js");
34
+ const index_js_1 = require("./routers/index.js");
35
+ const schema_js_1 = require("./schema.js");
36
+ const domain_middleware_js_1 = require("./middlewares/domain-middleware.js");
37
+ const process_cleaner_js_1 = require("./process-cleaner.js");
38
+ (0, process_cleaner_js_1.setupProcessExitHandlers)();
39
+ args_1.default.option('port', 'The port on which the app will be running', env_1.config.get('port', 3000));
40
+ args_1.default.option('inspect', `The address on which the inspection will be running. Used in development mode only.
41
41
  This option is just to prevent termination for reasons of not recognizing the 'inspect' option.`, env_1.config.get('inspect', ':9229'));
42
- args.option('webpack', 'webpack configuration file', env_1.config.get('webpack'));
43
- const flags = args.parse(process.argv);
44
- const webpack = require('webpack');
42
+ args_1.default.option('webpack', 'webpack configuration file', env_1.config.get('webpack'));
43
+ const flags = args_1.default.parse(process.argv);
44
+ const webpack_1 = tslib_1.__importDefault(require("webpack"));
45
45
  const webpackConfig = require(flags.webpack || '@things-factory/builder/webpack.config.dev.js');
46
- const compiler = webpack(webpackConfig);
46
+ const compiler = (0, webpack_1.default)(webpackConfig);
47
47
  const PORT = (process.env.PORT = flags.port);
48
48
  const requestBody = env_1.config.get('requestBody') || {};
49
49
  const bodyParserOption = {
@@ -59,7 +59,7 @@ const fileUploadOption = {
59
59
  (0, operato_license_checker_1.initLicense)(env_1.config.get('licenseKey'));
60
60
  /* bootstrap */
61
61
  const bootstrap = async () => {
62
- await (0, database_1.databaseInitializer)();
62
+ await (0, database_js_1.databaseInitializer)();
63
63
  const app = new koa_2.default();
64
64
  app.proxy = true;
65
65
  app.use((0, cors_1.default)({
@@ -85,7 +85,7 @@ const bootstrap = async () => {
85
85
  });
86
86
  var subscriptionMiddleware = [];
87
87
  process.emit('bootstrap-module-subscription', app, subscriptionMiddleware);
88
- const builtSchema = await (0, schema_1.schema)();
88
+ const builtSchema = await (0, schema_js_1.schema)();
89
89
  const httpServer = (0, http_1.createServer)(app.callback());
90
90
  const websocketServer = new ws_2.WebSocketServer({
91
91
  server: httpServer,
@@ -112,7 +112,7 @@ const bootstrap = async () => {
112
112
  var koacontext = await app.createContext(request, new http_2.default.ServerResponse(request));
113
113
  koacontext['state'] = {};
114
114
  /* in case connect error(like a authentication error) just throw exception */
115
- var middlewares = [middlewares_1.domainMiddleware, ...subscriptionMiddleware];
115
+ var middlewares = [domain_middleware_js_1.domainMiddleware, ...subscriptionMiddleware];
116
116
  const fn = co_1.default.wrap((0, koa_compose_1.default)(middlewares));
117
117
  await fn(koacontext);
118
118
  return (ctx['context'] = koacontext);
@@ -155,7 +155,7 @@ const bootstrap = async () => {
155
155
  cache: 'bounded'
156
156
  });
157
157
  await server.start();
158
- graphql_local_client_1.GraphqlLocalClient.init(builtSchema, app);
158
+ graphql_local_client_js_1.GraphqlLocalClient.init(builtSchema, app);
159
159
  env_1.orderedModuleNames.forEach(name => {
160
160
  const { initMiddlewares } = (0, env_1.loader)(name);
161
161
  initMiddlewares && initMiddlewares(app);
@@ -178,30 +178,30 @@ const bootstrap = async () => {
178
178
  const ssoMiddlewares = [];
179
179
  process.emit('bootstrap-collect-sso-middleware', null, ssoMiddlewares);
180
180
  app.ssoMiddlewares = ssoMiddlewares;
181
- process.emit('bootstrap-module-global-public-route', app, routers_1.globalPublicRouter);
182
- process.emit('bootstrap-module-global-private-route', app, routers_1.globalPrivateRouter);
183
- process.emit('bootstrap-module-domain-public-route', app, routers_1.domainPublicRouter);
184
- process.emit('bootstrap-module-domain-private-route', app, routers_1.domainPrivateRouter);
181
+ process.emit('bootstrap-module-global-public-route', app, index_js_1.globalPublicRouter);
182
+ process.emit('bootstrap-module-global-private-route', app, index_js_1.globalPrivateRouter);
183
+ process.emit('bootstrap-module-domain-public-route', app, index_js_1.domainPublicRouter);
184
+ process.emit('bootstrap-module-domain-private-route', app, index_js_1.domainPrivateRouter);
185
185
  app.use(operato_license_checker_1.checkValidity); /* Check the license after most of the context has been built */
186
186
  app
187
- .use(routers_1.globalPublicRouter.routes())
188
- .use(routers_1.globalPublicRouter.allowedMethods())
189
- .use(routers_1.globalPrivateRouter.routes())
190
- .use(routers_1.globalPrivateRouter.allowedMethods())
191
- .use(routers_1.domainPublicRouter.routes())
192
- .use(routers_1.domainPublicRouter.allowedMethods())
193
- .use(routers_1.domainPrivateRouter.routes())
194
- .use(routers_1.domainPrivateRouter.allowedMethods());
187
+ .use(index_js_1.globalPublicRouter.routes())
188
+ .use(index_js_1.globalPublicRouter.allowedMethods())
189
+ .use(index_js_1.globalPrivateRouter.routes())
190
+ .use(index_js_1.globalPrivateRouter.allowedMethods())
191
+ .use(index_js_1.domainPublicRouter.routes())
192
+ .use(index_js_1.domainPublicRouter.allowedMethods())
193
+ .use(index_js_1.domainPrivateRouter.routes())
194
+ .use(index_js_1.domainPrivateRouter.allowedMethods());
195
195
  /* Graphql Upload's multipart/form-data handling affects the restful file upload feature, so it should be placed after the routers configuration. */
196
196
  app.use((0, graphqlUploadKoa_js_1.default)(fileUploadOption));
197
- routers_1.graphqlRouter.post('/graphql', (0, koa_1.koaMiddleware)(server, {
197
+ index_js_1.graphqlRouter.post('/graphql', (0, koa_1.koaMiddleware)(server, {
198
198
  context: async ({ ctx }) => ctx
199
199
  }));
200
- app.use(routers_1.graphqlRouter.routes());
201
- app.use(routers_1.graphqlRouter.allowedMethods());
200
+ app.use(index_js_1.graphqlRouter.routes());
201
+ app.use(index_js_1.graphqlRouter.allowedMethods());
202
202
  /* should follow this order : history-fallback => webpack-middleware */
203
203
  app.use((0, koa2_connect_history_api_fallback_1.historyApiFallback)({ whiteList: [] }));
204
- app.use(wdm.koaWrapper(compiler, {
204
+ app.use(webpack_dev_middleware_1.default.koaWrapper(compiler, {
205
205
  publicPath: webpackConfig.output.publicPath
206
206
  }));
207
207
  httpServer.listen({ port: PORT }, () => {
@@ -1 +1 @@
1
- {"version":3,"file":"server-dev.js","sourceRoot":"","sources":["../server/server-dev.ts"],"names":[],"mappings":";AAAA,4BAA4B;;;AAE5B,4DAA4D;AAC5D,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AACxB,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,CAAA;AAEjD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;AAEjE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAA;AACpC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;AAE1B,2CAA6C;AAC7C,2EAAyF;AACzF,uEAAqG;AAErG,8CAAoD;AACpD,0DAA+B;AAC/B,qGAAiE;AACjE,8CAAiD;AACjD,+BAAmC;AACnC,sDAAqB;AACrB,4EAA0C;AAC1C,sEAAiC;AACjC,yFAAsE;AACtE,2BAAoC;AACpC,oDAAmB;AACnB,wDAAuB;AAEvB,6DAA4B;AAE5B,4DAA2B;AAE3B,6CAAgF;AAChF,qFAAoF;AAEpF,iEAA2D;AAC3D,sDAA6D;AAC7D,uCAMkB;AAClB,qCAAiC;AAGjC,+CAAgD;AAChD,uDAA4D;AAC5D,MAAM,GAAG,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAA;AAE7C,IAAA,0CAAwB,GAAE,CAAA;AAE1B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAE5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,2CAA2C,EAAE,YAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;A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,uEAAuE;IACvE,GAAG,CAAC,GAAG,CAAC,IAAA,sDAAkB,EAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IAE9C,GAAG,CAAC,GAAG,CACL,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE;QACvB,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,UAAU;KAC5C,CAAC,CACH,CAAA;IAED,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE;QACrC,YAAM,CAAC,IAAI,CAAC,qCAAqC,IAAI,UAAU,CAAC,CAAA;QAChE,YAAM,CAAC,IAAI,CAAC,0CAA0C,IAAI,UAAU,CAAC,CAAA;QAErE,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","sourcesContent":["// ts-import-sorter: disable\n\n/* following 7 lines should be located in top of the file */\nconst OS = require('os')\nprocess.env.UV_THREADPOOL_SIZE = OS.cpus().length\n\nconsole.log('UV_THREADPOOL_SIZE', process.env.UV_THREADPOOL_SIZE)\n\nprocess.env.NODE_ENV = 'development'\nprocess.setMaxListeners(0)\n\nimport { ApolloServer } from '@apollo/server'\nimport { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'\nimport { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default'\n\nimport { koaMiddleware } from '@as-integrations/koa'\nimport bytesFormat from 'bytes'\nimport graphqlUploadKoa from 'graphql-upload/graphqlUploadKoa.js'\nimport { useServer } from 'graphql-ws/lib/use/ws'\nimport { createServer } from 'http'\nimport Koa from 'koa'\nimport koaBodyParser from 'koa-bodyparser'\nimport compose from 'koa-compose'\nimport { historyApiFallback } from 'koa2-connect-history-api-fallback'\nimport { WebSocketServer } from 'ws'\nimport co from 'co'\nimport http from 'http'\n\nimport cors from '@koa/cors'\n\nimport crypto from 'crypto'\n\nimport { config, loader, logger, orderedModuleNames } from '@things-factory/env'\nimport { initLicense, checkValidity } from '@things-factory/operato-license-checker'\n\nimport { GraphqlLocalClient } from './graphql-local-client'\nimport { databaseInitializer } from './initializers/database'\nimport {\n domainPrivateRouter,\n domainPublicRouter,\n globalPrivateRouter,\n globalPublicRouter,\n graphqlRouter\n} from './routers'\nimport { schema } from './schema'\nimport { Domain } from './service'\nimport { EntityManager } from 'typeorm'\nimport { domainMiddleware } from './middlewares'\nimport { setupProcessExitHandlers } from './process-cleaner'\nconst wdm = require('webpack-dev-middleware')\n\nsetupProcessExitHandlers()\n\nconst args = require('args')\n\nargs.option('port', 'The port on which the app will be running', config.get('port', 3000))\nargs.option(\n 'inspect',\n `The address on which the inspection will be running. Used in development mode only.\n This option is just to prevent termination for reasons of not recognizing the 'inspect' option.`,\n config.get('inspect', ':9229')\n)\nargs.option('webpack', 'webpack configuration file', config.get('webpack'))\n\nconst flags = args.parse(process.argv)\n\nconst webpack = require('webpack')\nconst webpackConfig = require(flags.webpack || '@things-factory/builder/webpack.config.dev.js')\n\nconst compiler = webpack(webpackConfig)\n\nconst PORT = (process.env.PORT = flags.port)\n\nconst requestBody = config.get('requestBody') || {}\n\nconst bodyParserOption = {\n formLimit: requestBody.formLimit || '10mb',\n jsonLimit: requestBody.jsonLimit || '10mb',\n textLimit: requestBody.textLimit || '10mb'\n}\n\nconst fileUpload = config.get('fileUpload') || {}\nconst fileUploadOption = {\n maxFileSize: bytesFormat.parse(fileUpload.maxFileSize) || bytesFormat.parse('10mb'),\n maxFiles: fileUpload.maxFiles || 10\n}\n\ninterface ICustomAppState {\n domain: Domain\n user: any\n tx: EntityManager\n}\n\ninterface ICustomAppContext {\n t: any\n ssoMiddlewares: any[]\n}\n\ninitLicense(config.get('licenseKey'))\n\n/* bootstrap */\nconst bootstrap = async () => {\n await databaseInitializer()\n\n const app = new Koa<ICustomAppState, ICustomAppContext>() as any\n app.proxy = true\n\n app.use(\n cors({\n origin: function (ctx) {\n return ctx.request.headers.origin || '*'\n },\n exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],\n maxAge: 5,\n credentials: true,\n /* allowMethods: ['GET', 'POST', 'DELETE'], -- use default */\n allowHeaders: ['Content-Type', 'Authorization', 'Accept']\n })\n )\n\n app.use(async (ctx, next) => {\n ctx.set('X-Content-Type-Options', 'nosniff')\n\n const { directives = {} } = config.get('CSP') || {}\n\n const nonce = crypto.randomBytes(16).toString('base64')\n ctx.state.nonce = nonce\n\n const cspHeader = Object.entries(directives as { [key: string]: string[] })\n .map(([key, value]) => `${key} ${value.join(' ')}`)\n .join('; ')\n\n ctx.set('Content-Security-Policy', cspHeader)\n\n await next()\n })\n\n var subscriptionMiddleware = []\n process.emit('bootstrap-module-subscription' as any, app, subscriptionMiddleware)\n\n const builtSchema = await schema()\n\n const httpServer = createServer(app.callback())\n const websocketServer = new WebSocketServer({\n server: httpServer,\n path: '/graphql'\n })\n\n // Save the returned server's info so we can shut down this server later\n const serverCleanup = useServer(\n {\n schema: builtSchema,\n context: async (ctx, msg, args) => {\n return ctx['context']\n },\n onConnect: async ctx => {\n var { extra, connectionParams } = ctx\n var { request } = extra\n\n if (((connectionParams['headers'] as any) || connectionParams)?.referer) {\n var url = new URL(((connectionParams['headers'] as any) || connectionParams).referer)\n var accessToken = url.searchParams.get('access_token')\n if (accessToken) {\n connectionParams['headers']['authorization'] = accessToken\n }\n }\n\n request.headers = {\n ...request.headers,\n ...(connectionParams['headers'] || (connectionParams as any))\n }\n\n var koacontext = await app.createContext(request, new http.ServerResponse(request))\n koacontext['state'] = {}\n\n /* in case connect error(like a authentication error) just throw exception */\n var middlewares = [domainMiddleware, ...subscriptionMiddleware]\n const fn = co.wrap(compose(middlewares))\n\n await fn(koacontext)\n\n return (ctx['context'] = koacontext)\n },\n onDisconnect(ctx, code, reason) {\n console.log('Disconnected!')\n },\n onError(ctx, msg, errors) {\n console.error(msg, errors)\n }\n },\n websocketServer\n )\n\n const server = new ApolloServer({\n schema: builtSchema,\n formatError: error => {\n logger.error(error)\n return error\n },\n introspection: true,\n csrfPrevention: true,\n plugins: [\n // Proper shutdown for the HTTP server.\n ApolloServerPluginDrainHttpServer({ httpServer }),\n // Proper shutdown for the WebSocket server.\n {\n async serverWillStart() {\n return {\n async drainServer() {\n await serverCleanup.dispose()\n }\n }\n }\n },\n // TODO make this landing page work\n ApolloServerPluginLandingPageLocalDefault({\n footer: false,\n embed: true,\n includeCookies: true\n })\n ],\n cache: 'bounded'\n })\n\n await server.start()\n\n GraphqlLocalClient.init(builtSchema, app)\n\n orderedModuleNames.forEach(name => {\n const { initMiddlewares } = loader(name)\n initMiddlewares && initMiddlewares(app)\n })\n\n const render = require('@things-factory/ejs-remote')\n render(app, {\n root: '/views',\n host: `http://127.0.0.1:${PORT}`,\n layout: false,\n viewExt: 'html',\n cache: false,\n debug: false\n })\n\n // only for development mode. triggered after webpack compilation is done.\n compiler.hooks.done.tap({ name: 'server-dev' }, stats => {\n process.emit('client-rebuilt' as any, app, compiler.outputFileSystem)\n })\n\n app.use(koaBodyParser(bodyParserOption))\n\n /* routers */\n const ssoMiddlewares = []\n process.emit('bootstrap-collect-sso-middleware' as any, null, ssoMiddlewares)\n app.ssoMiddlewares = ssoMiddlewares\n\n process.emit('bootstrap-module-global-public-route' as any, app, globalPublicRouter)\n process.emit('bootstrap-module-global-private-route' as any, app, globalPrivateRouter)\n process.emit('bootstrap-module-domain-public-route' as any, app, domainPublicRouter)\n process.emit('bootstrap-module-domain-private-route' as any, app, domainPrivateRouter)\n\n app.use(checkValidity) /* Check the license after most of the context has been built */\n\n app\n .use(globalPublicRouter.routes())\n .use(globalPublicRouter.allowedMethods())\n .use(globalPrivateRouter.routes())\n .use(globalPrivateRouter.allowedMethods())\n .use(domainPublicRouter.routes())\n .use(domainPublicRouter.allowedMethods())\n .use(domainPrivateRouter.routes())\n .use(domainPrivateRouter.allowedMethods())\n\n /* Graphql Upload's multipart/form-data handling affects the restful file upload feature, so it should be placed after the routers configuration. */\n app.use(graphqlUploadKoa(fileUploadOption))\n\n graphqlRouter.post(\n '/graphql',\n koaMiddleware(server, {\n context: async ({ ctx }) => ctx\n })\n )\n app.use(graphqlRouter.routes())\n app.use(graphqlRouter.allowedMethods())\n\n /* should follow this order : history-fallback => webpack-middleware */\n app.use(historyApiFallback({ whiteList: [] }))\n\n app.use(\n wdm.koaWrapper(compiler, {\n publicPath: webpackConfig.output.publicPath\n })\n )\n\n httpServer.listen({ port: PORT }, () => {\n logger.info(`🚀 Server ready at http://0.0.0.0:${PORT}/graphql`)\n logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}/graphql`)\n\n process.emit('bootstrap-module-start' as any, { app, config, builtSchema, httpServer } as any)\n })\n}\n\nbootstrap()\n"]}
1
+ {"version":3,"file":"server-dev.js","sourceRoot":"","sources":["../server/server-dev.ts"],"names":[],"mappings":";AAAA,4BAA4B;;;AAE5B,4DAA4D;AAC5D,oDAAmB;AACnB,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,MAAM,CAAC,YAAE,CAAC,oBAAoB,EAAE,CAAC,CAAA;AAElE,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;AAEjE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAA;AACpC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;AAE1B,2CAA6C;AAC7C,2EAAyF;AACzF,uEAAqG;AAErG,8CAAoD;AAEpD,wDAAuB;AACvB,4FAAwC;AACxC,0DAA+B;AAC/B,qGAAiE;AACjE,8CAAiD;AACjD,+BAAmC;AACnC,sDAAqB;AACrB,4EAA0C;AAC1C,sEAAiC;AACjC,yFAAsE;AACtE,2BAAoC;AACpC,oDAAmB;AACnB,wDAAuB;AAEvB,6DAA4B;AAE5B,4DAA2B;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M,EAAE;QACpB,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG;KAChC,CAAC,CACH,CAAA;IACD,GAAG,CAAC,GAAG,CAAC,wBAAa,CAAC,MAAM,EAAE,CAAC,CAAA;IAC/B,GAAG,CAAC,GAAG,CAAC,wBAAa,CAAC,cAAc,EAAE,CAAC,CAAA;IAEvC,uEAAuE;IACvE,GAAG,CAAC,GAAG,CAAC,IAAA,sDAAkB,EAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IAE9C,GAAG,CAAC,GAAG,CACL,gCAAG,CAAC,UAAU,CAAC,QAAQ,EAAE;QACvB,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,UAAU;KAC5C,CAAC,CACH,CAAA;IAED,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE;QACrC,YAAM,CAAC,IAAI,CAAC,qCAAqC,IAAI,UAAU,CAAC,CAAA;QAChE,YAAM,CAAC,IAAI,CAAC,0CAA0C,IAAI,UAAU,CAAC,CAAA;QAErE,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","sourcesContent":["// ts-import-sorter: disable\n\n/* following 7 lines should be located in top of the file */\nimport OS from 'os'\nprocess.env.UV_THREADPOOL_SIZE = String(OS.availableParallelism())\n\nconsole.log('UV_THREADPOOL_SIZE', process.env.UV_THREADPOOL_SIZE)\n\nprocess.env.NODE_ENV = 'development'\nprocess.setMaxListeners(0)\n\nimport { ApolloServer } from '@apollo/server'\nimport { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'\nimport { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default'\n\nimport { koaMiddleware } from '@as-integrations/koa'\nimport { EntityManager } from 'typeorm'\nimport args from 'args'\nimport wdm from 'webpack-dev-middleware'\nimport bytesFormat from 'bytes'\nimport graphqlUploadKoa from 'graphql-upload/graphqlUploadKoa.js'\nimport { useServer } from 'graphql-ws/lib/use/ws'\nimport { createServer } from 'http'\nimport Koa from 'koa'\nimport koaBodyParser from 'koa-bodyparser'\nimport compose from 'koa-compose'\nimport { historyApiFallback } from 'koa2-connect-history-api-fallback'\nimport { WebSocketServer } from 'ws'\nimport co from 'co'\nimport http from 'http'\n\nimport cors from '@koa/cors'\n\nimport crypto from 'crypto'\n\nimport { config, loader, logger, orderedModuleNames } from '@things-factory/env'\nimport { initLicense, checkValidity } from '@things-factory/operato-license-checker'\n\nimport { GraphqlLocalClient } from './graphql-local-client.js'\nimport { databaseInitializer } from './initializers/database.js'\nimport {\n domainPrivateRouter,\n domainPublicRouter,\n globalPrivateRouter,\n globalPublicRouter,\n graphqlRouter\n} from './routers/index.js'\nimport { schema } from './schema.js'\nimport { Domain } from './service/index.js'\nimport { domainMiddleware } from './middlewares/domain-middleware.js'\nimport { setupProcessExitHandlers } from './process-cleaner.js'\n\nsetupProcessExitHandlers()\n\nargs.option('port', 'The port on which the app will be running', config.get('port', 3000))\nargs.option(\n 'inspect',\n `The address on which the inspection will be running. Used in development mode only.\n This option is just to prevent termination for reasons of not recognizing the 'inspect' option.`,\n config.get('inspect', ':9229')\n)\nargs.option('webpack', 'webpack configuration file', config.get('webpack'))\n\nconst flags = args.parse(process.argv)\n\nimport webpack from 'webpack'\nconst webpackConfig = require(flags.webpack || '@things-factory/builder/webpack.config.dev.js')\n\nconst compiler = webpack(webpackConfig)\n\nconst PORT = (process.env.PORT = flags.port)\n\nconst requestBody = config.get('requestBody') || {}\n\nconst bodyParserOption = {\n formLimit: requestBody.formLimit || '10mb',\n jsonLimit: requestBody.jsonLimit || '10mb',\n textLimit: requestBody.textLimit || '10mb'\n}\n\nconst fileUpload = config.get('fileUpload') || {}\nconst fileUploadOption = {\n maxFileSize: bytesFormat.parse(fileUpload.maxFileSize) || bytesFormat.parse('10mb'),\n maxFiles: fileUpload.maxFiles || 10\n}\n\ninterface ICustomAppState {\n domain: Domain\n user: any\n tx: EntityManager\n}\n\ninterface ICustomAppContext {\n t: any\n ssoMiddlewares: any[]\n}\n\ninitLicense(config.get('licenseKey'))\n\n/* bootstrap */\nconst bootstrap = async () => {\n await databaseInitializer()\n\n const app = new Koa<ICustomAppState, ICustomAppContext>() as any\n app.proxy = true\n\n app.use(\n cors({\n origin: function (ctx) {\n return ctx.request.headers.origin || '*'\n },\n exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],\n maxAge: 5,\n credentials: true,\n /* allowMethods: ['GET', 'POST', 'DELETE'], -- use default */\n allowHeaders: ['Content-Type', 'Authorization', 'Accept']\n })\n )\n\n app.use(async (ctx, next) => {\n ctx.set('X-Content-Type-Options', 'nosniff')\n\n const { directives = {} } = config.get('CSP') || {}\n\n const nonce = crypto.randomBytes(16).toString('base64')\n ctx.state.nonce = nonce\n\n const cspHeader = Object.entries(directives as { [key: string]: string[] })\n .map(([key, value]) => `${key} ${value.join(' ')}`)\n .join('; ')\n\n ctx.set('Content-Security-Policy', cspHeader)\n\n await next()\n })\n\n var subscriptionMiddleware = []\n process.emit('bootstrap-module-subscription' as any, app, subscriptionMiddleware)\n\n const builtSchema = await schema()\n\n const httpServer = createServer(app.callback())\n const websocketServer = new WebSocketServer({\n server: httpServer,\n path: '/graphql'\n })\n\n // Save the returned server's info so we can shut down this server later\n const serverCleanup = useServer(\n {\n schema: builtSchema,\n context: async (ctx, msg, args) => {\n return ctx['context']\n },\n onConnect: async ctx => {\n var { extra, connectionParams } = ctx\n var { request } = extra\n\n if (((connectionParams['headers'] as any) || connectionParams)?.referer) {\n var url = new URL(((connectionParams['headers'] as any) || connectionParams).referer)\n var accessToken = url.searchParams.get('access_token')\n if (accessToken) {\n connectionParams['headers']['authorization'] = accessToken\n }\n }\n\n request.headers = {\n ...request.headers,\n ...(connectionParams['headers'] || (connectionParams as any))\n }\n\n var koacontext = await app.createContext(request, new http.ServerResponse(request))\n koacontext['state'] = {}\n\n /* in case connect error(like a authentication error) just throw exception */\n var middlewares = [domainMiddleware, ...subscriptionMiddleware]\n const fn = co.wrap(compose(middlewares))\n\n await fn(koacontext)\n\n return (ctx['context'] = koacontext)\n },\n onDisconnect(ctx, code, reason) {\n console.log('Disconnected!')\n },\n onError(ctx, msg, errors) {\n console.error(msg, errors)\n }\n },\n websocketServer\n )\n\n const server = new ApolloServer({\n schema: builtSchema,\n formatError: error => {\n logger.error(error)\n return error\n },\n introspection: true,\n csrfPrevention: true,\n plugins: [\n // Proper shutdown for the HTTP server.\n ApolloServerPluginDrainHttpServer({ httpServer }),\n // Proper shutdown for the WebSocket server.\n {\n async serverWillStart() {\n return {\n async drainServer() {\n await serverCleanup.dispose()\n }\n }\n }\n },\n // TODO make this landing page work\n ApolloServerPluginLandingPageLocalDefault({\n footer: false,\n embed: true,\n includeCookies: true\n })\n ],\n cache: 'bounded'\n })\n\n await server.start()\n\n GraphqlLocalClient.init(builtSchema, app)\n\n orderedModuleNames.forEach(name => {\n const { initMiddlewares } = loader(name)\n initMiddlewares && initMiddlewares(app)\n })\n\n const render = require('@things-factory/ejs-remote')\n render(app, {\n root: '/views',\n host: `http://127.0.0.1:${PORT}`,\n layout: false,\n viewExt: 'html',\n cache: false,\n debug: false\n })\n\n // only for development mode. triggered after webpack compilation is done.\n compiler.hooks.done.tap({ name: 'server-dev' }, stats => {\n process.emit('client-rebuilt' as any, app, compiler.outputFileSystem)\n })\n\n app.use(koaBodyParser(bodyParserOption))\n\n /* routers */\n const ssoMiddlewares = []\n process.emit('bootstrap-collect-sso-middleware' as any, null, ssoMiddlewares)\n app.ssoMiddlewares = ssoMiddlewares\n\n process.emit('bootstrap-module-global-public-route' as any, app, globalPublicRouter)\n process.emit('bootstrap-module-global-private-route' as any, app, globalPrivateRouter)\n process.emit('bootstrap-module-domain-public-route' as any, app, domainPublicRouter)\n process.emit('bootstrap-module-domain-private-route' as any, app, domainPrivateRouter)\n\n app.use(checkValidity) /* Check the license after most of the context has been built */\n\n app\n .use(globalPublicRouter.routes())\n .use(globalPublicRouter.allowedMethods())\n .use(globalPrivateRouter.routes())\n .use(globalPrivateRouter.allowedMethods())\n .use(domainPublicRouter.routes())\n .use(domainPublicRouter.allowedMethods())\n .use(domainPrivateRouter.routes())\n .use(domainPrivateRouter.allowedMethods())\n\n /* Graphql Upload's multipart/form-data handling affects the restful file upload feature, so it should be placed after the routers configuration. */\n app.use(graphqlUploadKoa(fileUploadOption))\n\n graphqlRouter.post(\n '/graphql',\n koaMiddleware(server, {\n context: async ({ ctx }) => ctx\n })\n )\n app.use(graphqlRouter.routes())\n app.use(graphqlRouter.allowedMethods())\n\n /* should follow this order : history-fallback => webpack-middleware */\n app.use(historyApiFallback({ whiteList: [] }))\n\n app.use(\n wdm.koaWrapper(compiler, {\n publicPath: webpackConfig.output.publicPath\n })\n )\n\n httpServer.listen({ port: PORT }, () => {\n logger.info(`🚀 Server ready at http://0.0.0.0:${PORT}/graphql`)\n logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}/graphql`)\n\n process.emit('bootstrap-module-start' as any, { app, config, builtSchema, httpServer } as any)\n })\n}\n\nbootstrap()\n"]}
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const tslib_1 = require("tslib");
5
5
  /* following 5 lines should be located in top of the file */
6
- const OS = require('os');
7
- process.env.UV_THREADPOOL_SIZE = OS.cpus().length;
6
+ const os_1 = tslib_1.__importDefault(require("os"));
7
+ process.env.UV_THREADPOOL_SIZE = String(os_1.default.availableParallelism());
8
8
  console.log('UV_THREADPOOL_SIZE', process.env.UV_THREADPOOL_SIZE);
9
9
  process.env.NODE_ENV = 'production';
10
10
  process.setMaxListeners(0);
@@ -24,21 +24,21 @@ const koa2_connect_history_api_fallback_1 = require("koa2-connect-history-api-fa
24
24
  const ws_2 = require("ws");
25
25
  const co_1 = tslib_1.__importDefault(require("co"));
26
26
  const http_2 = tslib_1.__importDefault(require("http"));
27
+ const path_1 = tslib_1.__importDefault(require("path"));
28
+ const args_1 = tslib_1.__importDefault(require("args"));
27
29
  const cors_1 = tslib_1.__importDefault(require("@koa/cors"));
28
30
  const crypto_1 = tslib_1.__importDefault(require("crypto"));
29
31
  const env_1 = require("@things-factory/env");
30
32
  const operato_license_checker_1 = require("@things-factory/operato-license-checker");
31
- const graphql_local_client_1 = require("./graphql-local-client");
32
- const database_1 = require("./initializers/database");
33
- const routers_1 = require("./routers");
34
- const schema_1 = require("./schema");
35
- const middlewares_1 = require("./middlewares");
36
- const process_cleaner_1 = require("./process-cleaner");
37
- (0, process_cleaner_1.setupProcessExitHandlers)();
38
- const args = require('args');
39
- args.option('port', 'The port on which the app will be running', env_1.config.get('port', 3000));
40
- const flags = args.parse(process.argv);
41
- const path = require('path');
33
+ const graphql_local_client_js_1 = require("./graphql-local-client.js");
34
+ const database_js_1 = require("./initializers/database.js");
35
+ const index_js_1 = require("./routers/index.js");
36
+ const schema_js_1 = require("./schema.js");
37
+ const domain_middleware_js_1 = require("./middlewares/domain-middleware.js");
38
+ const process_cleaner_js_1 = require("./process-cleaner.js");
39
+ (0, process_cleaner_js_1.setupProcessExitHandlers)();
40
+ args_1.default.option('port', 'The port on which the app will be running', env_1.config.get('port', 3000));
41
+ const flags = args_1.default.parse(process.argv);
42
42
  const PORT = (process.env.PORT = flags.port);
43
43
  const requestBody = env_1.config.get('requestBody') || {};
44
44
  const bodyParserOption = {
@@ -54,7 +54,7 @@ const fileUploadOption = {
54
54
  (0, operato_license_checker_1.initLicense)(env_1.config.get('licenseKey'));
55
55
  /* bootstrap */
56
56
  const bootstrap = async () => {
57
- await (0, database_1.databaseInitializer)();
57
+ await (0, database_js_1.databaseInitializer)();
58
58
  const app = new koa_2.default();
59
59
  app.proxy = true;
60
60
  app.use((0, cors_1.default)({
@@ -80,7 +80,7 @@ const bootstrap = async () => {
80
80
  });
81
81
  var subscriptionMiddleware = [];
82
82
  process.emit('bootstrap-module-subscription', app, subscriptionMiddleware);
83
- const builtSchema = await (0, schema_1.schema)();
83
+ const builtSchema = await (0, schema_js_1.schema)();
84
84
  const httpServer = (0, http_1.createServer)(app.callback());
85
85
  const websocketServer = new ws_2.WebSocketServer({
86
86
  server: httpServer,
@@ -107,7 +107,7 @@ const bootstrap = async () => {
107
107
  var koacontext = await app.createContext(request, new http_2.default.ServerResponse(request));
108
108
  koacontext['state'] = {};
109
109
  /* in case connect error(like a authentication error) just throw exception */
110
- var middlewares = [middlewares_1.domainMiddleware, ...subscriptionMiddleware];
110
+ var middlewares = [domain_middleware_js_1.domainMiddleware, ...subscriptionMiddleware];
111
111
  const fn = co_1.default.wrap((0, koa_compose_1.default)(middlewares));
112
112
  await fn(koacontext);
113
113
  return (ctx['context'] = koacontext);
@@ -149,7 +149,7 @@ const bootstrap = async () => {
149
149
  cache: 'bounded'
150
150
  });
151
151
  await server.start();
152
- graphql_local_client_1.GraphqlLocalClient.init(builtSchema, app);
152
+ graphql_local_client_js_1.GraphqlLocalClient.init(builtSchema, app);
153
153
  env_1.orderedModuleNames.forEach(name => {
154
154
  const { initMiddlewares } = (0, env_1.loader)(name);
155
155
  initMiddlewares && initMiddlewares(app);
@@ -168,30 +168,30 @@ const bootstrap = async () => {
168
168
  const ssoMiddlewares = [];
169
169
  process.emit('bootstrap-collect-sso-middleware', null, ssoMiddlewares);
170
170
  app.ssoMiddlewares = ssoMiddlewares;
171
- process.emit('bootstrap-module-global-public-route', app, routers_1.globalPublicRouter);
172
- process.emit('bootstrap-module-global-private-route', app, routers_1.globalPrivateRouter);
173
- process.emit('bootstrap-module-domain-public-route', app, routers_1.domainPublicRouter);
174
- process.emit('bootstrap-module-domain-private-route', app, routers_1.domainPrivateRouter);
171
+ process.emit('bootstrap-module-global-public-route', app, index_js_1.globalPublicRouter);
172
+ process.emit('bootstrap-module-global-private-route', app, index_js_1.globalPrivateRouter);
173
+ process.emit('bootstrap-module-domain-public-route', app, index_js_1.domainPublicRouter);
174
+ process.emit('bootstrap-module-domain-private-route', app, index_js_1.domainPrivateRouter);
175
175
  app.use(operato_license_checker_1.checkValidity); /* Check the license after most of the context has been built */
176
176
  app
177
- .use(routers_1.globalPublicRouter.routes())
178
- .use(routers_1.globalPublicRouter.allowedMethods())
179
- .use(routers_1.globalPrivateRouter.routes())
180
- .use(routers_1.globalPrivateRouter.allowedMethods())
181
- .use(routers_1.domainPublicRouter.routes())
182
- .use(routers_1.domainPublicRouter.allowedMethods())
183
- .use(routers_1.domainPrivateRouter.routes())
184
- .use(routers_1.domainPrivateRouter.allowedMethods());
177
+ .use(index_js_1.globalPublicRouter.routes())
178
+ .use(index_js_1.globalPublicRouter.allowedMethods())
179
+ .use(index_js_1.globalPrivateRouter.routes())
180
+ .use(index_js_1.globalPrivateRouter.allowedMethods())
181
+ .use(index_js_1.domainPublicRouter.routes())
182
+ .use(index_js_1.domainPublicRouter.allowedMethods())
183
+ .use(index_js_1.domainPrivateRouter.routes())
184
+ .use(index_js_1.domainPrivateRouter.allowedMethods());
185
185
  /* Graphql Upload's multipart/form-data handling affects the restful file upload feature, so it should be placed after the routers configuration. */
186
186
  app.use((0, graphqlUploadKoa_js_1.default)(fileUploadOption));
187
- routers_1.graphqlRouter.post('/graphql', (0, koa_1.koaMiddleware)(server, {
187
+ index_js_1.graphqlRouter.post('/graphql', (0, koa_1.koaMiddleware)(server, {
188
188
  context: async ({ ctx }) => ctx
189
189
  }));
190
- app.use(routers_1.graphqlRouter.routes());
191
- app.use(routers_1.graphqlRouter.allowedMethods());
190
+ app.use(index_js_1.graphqlRouter.routes());
191
+ app.use(index_js_1.graphqlRouter.allowedMethods());
192
192
  /* should follow this order : history-fallback => koaStatic */
193
193
  app.use((0, koa2_connect_history_api_fallback_1.historyApiFallback)({ whiteList: [] }));
194
- app.use((0, koa_static_1.default)(path.join(process.cwd(), 'dist-app'), {
194
+ app.use((0, koa_static_1.default)(path_1.default.join(process.cwd(), 'dist-app'), {
195
195
  index: 'index.html'
196
196
  }));
197
197
  // Set keep-alive timeout from configuration or fallback to default (65000ms).
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../server/server.ts"],"names":[],"mappings":";AAAA,4BAA4B;;;AAE5B,4DAA4D;AAC5D,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AACxB,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,CAAA;AAEjD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;AAEjE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAA;AACnC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;AAE1B,2CAA6C;AAC7C,2EAAyF;AACzF,uEAA0G;AAC1G,8CAAoD;AAEpD,0DAA+B;AAC/B,qGAAiE;AACjE,8CAAiD;AACjD,+BAAmC;AACnC,sDAAqB;AACrB,4EAA0C;AAC1C,oEAAkC;AAClC,sEAAiC;AACjC,yFAAsE;AACtE,2BAAoC;AACpC,oDAAmB;AACnB,wDAAuB;AAEvB,6DAA4B;AAC5B,4DAA2B;AAE3B,6CAAgF;AAChF,qFAAoF;AAEpF,iEAA2D;AAC3D,sDAA6D;AAC7D,uCAMkB;AAClB,qCAAiC;AACjC,+CAAgD;AAChD,uDAA4D;AAE5D,IAAA,0CAAwB,GAAE,CAAA;AAE1B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAE5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,2CAA2C,EAAE,YAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;AAE1F,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAEtC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;IAEnD,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE;QACrC,YAAM,CAAC,IAAI,CAAC,qCAAqC,IAAI,UAAU,CAAC,CAAA;QAChE,YAAM,CAAC,IAAI,CAAC,0CAA0C,IAAI,UAAU,CAAC,CAAA;QAErE,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","sourcesContent":["// ts-import-sorter: disable\n\n/* following 5 lines should be located in top of the file */\nconst OS = require('os')\nprocess.env.UV_THREADPOOL_SIZE = OS.cpus().length\n\nconsole.log('UV_THREADPOOL_SIZE', process.env.UV_THREADPOOL_SIZE)\n\nprocess.env.NODE_ENV = 'production'\nprocess.setMaxListeners(0)\n\nimport { ApolloServer } from '@apollo/server'\nimport { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'\nimport { ApolloServerPluginLandingPageProductionDefault } from '@apollo/server/plugin/landingPage/default'\nimport { koaMiddleware } from '@as-integrations/koa'\n\nimport bytesFormat from 'bytes'\nimport graphqlUploadKoa from 'graphql-upload/graphqlUploadKoa.js'\nimport { useServer } from 'graphql-ws/lib/use/ws'\nimport { createServer } from 'http'\nimport Koa from 'koa'\nimport koaBodyParser from 'koa-bodyparser'\nimport koaStatic from 'koa-static'\nimport compose from 'koa-compose'\nimport { historyApiFallback } from 'koa2-connect-history-api-fallback'\nimport { WebSocketServer } from 'ws'\nimport co from 'co'\nimport http from 'http'\n\nimport cors from '@koa/cors'\nimport crypto from 'crypto'\n\nimport { config, loader, logger, orderedModuleNames } from '@things-factory/env'\nimport { initLicense, checkValidity } from '@things-factory/operato-license-checker'\n\nimport { GraphqlLocalClient } from './graphql-local-client'\nimport { databaseInitializer } from './initializers/database'\nimport {\n domainPrivateRouter,\n domainPublicRouter,\n globalPrivateRouter,\n globalPublicRouter,\n graphqlRouter\n} from './routers'\nimport { schema } from './schema'\nimport { domainMiddleware } from './middlewares'\nimport { setupProcessExitHandlers } from './process-cleaner'\n\nsetupProcessExitHandlers()\n\nconst args = require('args')\n\nargs.option('port', 'The port on which the app will be running', config.get('port', 3000))\n\nconst flags = args.parse(process.argv)\n\nconst path = require('path')\n\nconst PORT = (process.env.PORT = flags.port)\n\nconst requestBody = config.get('requestBody') || {}\n\nconst bodyParserOption = {\n formLimit: requestBody.formLimit || '10mb',\n jsonLimit: requestBody.jsonLimit || '10mb',\n textLimit: requestBody.textLimit || '10mb'\n}\n\nconst fileUpload = config.get('fileUpload') || {}\nconst fileUploadOption = {\n maxFileSize: bytesFormat.parse(fileUpload.maxFileSize) || bytesFormat.parse('10mb'),\n maxFiles: fileUpload.maxFiles || 10\n}\n\ninitLicense(config.get('licenseKey'))\n\n/* bootstrap */\nconst bootstrap = async () => {\n await databaseInitializer()\n\n const app = new Koa() as any\n app.proxy = true\n\n app.use(\n cors({\n origin: function (ctx) {\n return ctx.request.headers.origin || '*'\n },\n exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],\n maxAge: 5,\n credentials: true,\n /* allowMethods: ['GET', 'POST', 'DELETE'], -- use default */\n allowHeaders: ['Content-Type', 'Authorization', 'Accept']\n })\n )\n\n app.use(async (ctx, next) => {\n ctx.set('X-Content-Type-Options', 'nosniff')\n\n const { directives = {} } = config.get('CSP') || {}\n\n const nonce = crypto.randomBytes(16).toString('base64')\n ctx.state.nonce = nonce\n\n const cspHeader = Object.entries(directives as { [key: string]: string[] })\n .map(([key, value]) => `${key} ${value.join(' ')}`)\n .join('; ')\n\n ctx.set('Content-Security-Policy', cspHeader)\n\n await next()\n })\n\n var subscriptionMiddleware = []\n process.emit('bootstrap-module-subscription' as any, app, subscriptionMiddleware)\n\n const builtSchema = await schema()\n\n const httpServer = createServer(app.callback())\n const websocketServer = new WebSocketServer({\n server: httpServer,\n path: '/graphql'\n })\n\n // Save the returned server's info so we can shut down this server later\n const serverCleanup = useServer(\n {\n schema: builtSchema,\n context: async (ctx, msg, args) => {\n return ctx['context']\n },\n onConnect: async ctx => {\n var { extra, connectionParams } = ctx\n var { request } = extra\n\n if (((connectionParams['headers'] as any) || connectionParams)?.referer) {\n var url = new URL(((connectionParams['headers'] as any) || connectionParams).referer)\n var accessToken = url.searchParams.get('access_token')\n if (accessToken) {\n connectionParams['headers']['authorization'] = accessToken\n }\n }\n\n request.headers = {\n ...request.headers,\n ...(connectionParams['headers'] || (connectionParams as any))\n }\n\n var koacontext = await app.createContext(request, new http.ServerResponse(request))\n koacontext['state'] = {}\n\n /* in case connect error(like a authentication error) just throw exception */\n var middlewares = [domainMiddleware, ...subscriptionMiddleware]\n const fn = co.wrap(compose(middlewares))\n\n await fn(koacontext)\n\n return (ctx['context'] = koacontext)\n },\n onDisconnect(ctx, code, reason) {\n console.log('Disconnected!')\n },\n onError(ctx, msg, errors) {\n console.error(msg, errors)\n }\n },\n websocketServer\n )\n\n const server = new ApolloServer({\n schema: builtSchema,\n formatError: error => {\n logger.error(error)\n return error\n },\n introspection: true,\n csrfPrevention: true,\n plugins: [\n // Proper shutdown for the HTTP server.\n ApolloServerPluginDrainHttpServer({ httpServer }),\n // Proper shutdown for the WebSocket server.\n {\n async serverWillStart() {\n return {\n async drainServer() {\n await serverCleanup.dispose()\n }\n }\n }\n },\n // TODO make this landing page work\n ApolloServerPluginLandingPageProductionDefault({\n graphRef: 'my-graph-id@my-graph-variant',\n footer: false\n })\n ],\n cache: 'bounded'\n })\n\n await server.start()\n\n GraphqlLocalClient.init(builtSchema, app)\n\n orderedModuleNames.forEach(name => {\n const { initMiddlewares } = loader(name)\n initMiddlewares && initMiddlewares(app)\n })\n\n const render = require('@things-factory/ejs-remote')\n render(app, {\n root: '/views',\n host: `http://127.0.0.1:${PORT}`,\n layout: false,\n viewExt: 'html',\n cache: true,\n debug: false\n })\n\n app.use(koaBodyParser(bodyParserOption))\n\n /* routers */\n const ssoMiddlewares = []\n process.emit('bootstrap-collect-sso-middleware' as any, null, ssoMiddlewares)\n app.ssoMiddlewares = ssoMiddlewares\n\n process.emit('bootstrap-module-global-public-route' as any, app, globalPublicRouter)\n process.emit('bootstrap-module-global-private-route' as any, app, globalPrivateRouter)\n process.emit('bootstrap-module-domain-public-route' as any, app, domainPublicRouter)\n process.emit('bootstrap-module-domain-private-route' as any, app, domainPrivateRouter)\n\n app.use(checkValidity) /* Check the license after most of the context has been built */\n\n app\n .use(globalPublicRouter.routes())\n .use(globalPublicRouter.allowedMethods())\n .use(globalPrivateRouter.routes())\n .use(globalPrivateRouter.allowedMethods())\n .use(domainPublicRouter.routes())\n .use(domainPublicRouter.allowedMethods())\n .use(domainPrivateRouter.routes())\n .use(domainPrivateRouter.allowedMethods())\n\n /* Graphql Upload's multipart/form-data handling affects the restful file upload feature, so it should be placed after the routers configuration. */\n app.use(graphqlUploadKoa(fileUploadOption))\n\n graphqlRouter.post(\n '/graphql',\n koaMiddleware(server, {\n context: async ({ ctx }) => ctx\n })\n )\n app.use(graphqlRouter.routes())\n app.use(graphqlRouter.allowedMethods())\n\n /* should follow this order : history-fallback => koaStatic */\n app.use(historyApiFallback({ whiteList: [] }))\n\n app.use(\n koaStatic(path.join(process.cwd(), 'dist-app'), {\n index: 'index.html'\n })\n )\n\n // Set keep-alive timeout from configuration or fallback to default (65000ms).\n // The keepAliveTimeout determines how long the server will keep an idle connection\n // alive before closing it.\n const keepAliveTimeout = config.get('keepAliveTimeout', 65000)\n\n // Apply the configured keep-alive timeout to the server. If no configuration is\n // provided, default to 65000ms (65 seconds). In the context of an external load balancer,\n // this timeout is critical for maintaining persistent connections between the load\n // balancer and the server. Setting a sufficiently long keepAliveTimeout minimizes\n // the need to constantly re-establish TCP connections, improving efficiency and\n // reducing connection overhead.\n httpServer.keepAliveTimeout = keepAliveTimeout || 65000\n\n // Set headersTimeout to be 1000ms (1 second) longer than keepAliveTimeout.\n // This ensures the server has sufficient time to receive headers from the client\n // before closing the connection, preventing premature disconnections. In the context\n // of a load balancer, this ensures that if the load balancer is sending headers\n // slowly (due to network delays or other factors), the connection isn't closed\n // before the headers are fully transmitted.\n httpServer.headersTimeout = keepAliveTimeout + 1000\n\n httpServer.listen({ port: PORT }, () => {\n logger.info(`🚀 Server ready at http://0.0.0.0:${PORT}/graphql`)\n logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}/graphql`)\n\n process.emit('bootstrap-module-start' as any, { app, config, builtSchema, httpServer } as any)\n })\n}\n\nbootstrap()\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../server/server.ts"],"names":[],"mappings":";AAAA,4BAA4B;;;AAE5B,4DAA4D;AAC5D,oDAAmB;AACnB,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,MAAM,CAAC,YAAE,CAAC,oBAAoB,EAAE,CAAC,CAAA;AAElE,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;AAEjE,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAA;AACnC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;AAE1B,2CAA6C;AAC7C,2EAAyF;AACzF,uEAA0G;AAC1G,8CAAoD;AAEpD,0DAA+B;AAC/B,qGAAiE;AACjE,8CAAiD;AACjD,+BAAmC;AACnC,sDAAqB;AACrB,4EAA0C;AAC1C,oEAAkC;AAClC,sEAAiC;AACjC,yFAAsE;AACtE,2BAAoC;AACpC,oDAAmB;AACnB,wDAAuB;AACvB,wDAAuB;AACvB,wDAAuB;AAEvB,6DAA4B;AAC5B,4DAA2B;AAE3B,6CAAgF;AAChF,qFAAoF;AAEpF,uEAA8D;AAC9D,4DAAgE;AAChE,iDAM2B;AAC3B,2CAAoC;AACpC,6EAAqE;AACrE,6DAA+D;AAE/D,IAAA,6CAAwB,GAAE,CAAA;AAE1B,cAAI,CAA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;IAC3E,iFAAiF;IACjF,qFAAqF;IACrF,gFAAgF;IAChF,+EAA+E;IAC/E,4CAA4C;IAC5C,UAAU,CAAC,cAAc,GAAG,gBAAgB,GAAG,IAAI,CAAA;IAEnD,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE;QACrC,YAAM,CAAC,IAAI,CAAC,qCAAqC,IAAI,UAAU,CAAC,CAAA;QAChE,YAAM,CAAC,IAAI,CAAC,0CAA0C,IAAI,UAAU,CAAC,CAAA;QAErE,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","sourcesContent":["// ts-import-sorter: disable\n\n/* following 5 lines should be located in top of the file */\nimport OS from 'os'\nprocess.env.UV_THREADPOOL_SIZE = String(OS.availableParallelism())\n\nconsole.log('UV_THREADPOOL_SIZE', process.env.UV_THREADPOOL_SIZE)\n\nprocess.env.NODE_ENV = 'production'\nprocess.setMaxListeners(0)\n\nimport { ApolloServer } from '@apollo/server'\nimport { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'\nimport { ApolloServerPluginLandingPageProductionDefault } from '@apollo/server/plugin/landingPage/default'\nimport { koaMiddleware } from '@as-integrations/koa'\n\nimport bytesFormat from 'bytes'\nimport graphqlUploadKoa from 'graphql-upload/graphqlUploadKoa.js'\nimport { useServer } from 'graphql-ws/lib/use/ws'\nimport { createServer } from 'http'\nimport Koa from 'koa'\nimport koaBodyParser from 'koa-bodyparser'\nimport koaStatic from 'koa-static'\nimport compose from 'koa-compose'\nimport { historyApiFallback } from 'koa2-connect-history-api-fallback'\nimport { WebSocketServer } from 'ws'\nimport co from 'co'\nimport http from 'http'\nimport path from 'path'\nimport args from 'args'\n\nimport cors from '@koa/cors'\nimport crypto from 'crypto'\n\nimport { config, loader, logger, orderedModuleNames } from '@things-factory/env'\nimport { initLicense, checkValidity } from '@things-factory/operato-license-checker'\n\nimport { GraphqlLocalClient } from './graphql-local-client.js'\nimport { databaseInitializer } from './initializers/database.js'\nimport {\n domainPrivateRouter,\n domainPublicRouter,\n globalPrivateRouter,\n globalPublicRouter,\n graphqlRouter\n} from './routers/index.js'\nimport { schema } from './schema.js'\nimport { domainMiddleware } from './middlewares/domain-middleware.js'\nimport { setupProcessExitHandlers } from './process-cleaner.js'\n\nsetupProcessExitHandlers()\n\nargs.option('port', 'The port on which the app will be running', config.get('port', 3000))\n\nconst flags = args.parse(process.argv)\n\nconst PORT = (process.env.PORT = flags.port)\n\nconst requestBody = config.get('requestBody') || {}\n\nconst bodyParserOption = {\n formLimit: requestBody.formLimit || '10mb',\n jsonLimit: requestBody.jsonLimit || '10mb',\n textLimit: requestBody.textLimit || '10mb'\n}\n\nconst fileUpload = config.get('fileUpload') || {}\nconst fileUploadOption = {\n maxFileSize: bytesFormat.parse(fileUpload.maxFileSize) || bytesFormat.parse('10mb'),\n maxFiles: fileUpload.maxFiles || 10\n}\n\ninitLicense(config.get('licenseKey'))\n\n/* bootstrap */\nconst bootstrap = async () => {\n await databaseInitializer()\n\n const app = new Koa() as any\n app.proxy = true\n\n app.use(\n cors({\n origin: function (ctx) {\n return ctx.request.headers.origin || '*'\n },\n exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],\n maxAge: 5,\n credentials: true,\n /* allowMethods: ['GET', 'POST', 'DELETE'], -- use default */\n allowHeaders: ['Content-Type', 'Authorization', 'Accept']\n })\n )\n\n app.use(async (ctx, next) => {\n ctx.set('X-Content-Type-Options', 'nosniff')\n\n const { directives = {} } = config.get('CSP') || {}\n\n const nonce = crypto.randomBytes(16).toString('base64')\n ctx.state.nonce = nonce\n\n const cspHeader = Object.entries(directives as { [key: string]: string[] })\n .map(([key, value]) => `${key} ${value.join(' ')}`)\n .join('; ')\n\n ctx.set('Content-Security-Policy', cspHeader)\n\n await next()\n })\n\n var subscriptionMiddleware = []\n process.emit('bootstrap-module-subscription' as any, app, subscriptionMiddleware)\n\n const builtSchema = await schema()\n\n const httpServer = createServer(app.callback())\n const websocketServer = new WebSocketServer({\n server: httpServer,\n path: '/graphql'\n })\n\n // Save the returned server's info so we can shut down this server later\n const serverCleanup = useServer(\n {\n schema: builtSchema,\n context: async (ctx, msg, args) => {\n return ctx['context']\n },\n onConnect: async ctx => {\n var { extra, connectionParams } = ctx\n var { request } = extra\n\n if (((connectionParams['headers'] as any) || connectionParams)?.referer) {\n var url = new URL(((connectionParams['headers'] as any) || connectionParams).referer)\n var accessToken = url.searchParams.get('access_token')\n if (accessToken) {\n connectionParams['headers']['authorization'] = accessToken\n }\n }\n\n request.headers = {\n ...request.headers,\n ...(connectionParams['headers'] || (connectionParams as any))\n }\n\n var koacontext = await app.createContext(request, new http.ServerResponse(request))\n koacontext['state'] = {}\n\n /* in case connect error(like a authentication error) just throw exception */\n var middlewares = [domainMiddleware, ...subscriptionMiddleware]\n const fn = co.wrap(compose(middlewares))\n\n await fn(koacontext)\n\n return (ctx['context'] = koacontext)\n },\n onDisconnect(ctx, code, reason) {\n console.log('Disconnected!')\n },\n onError(ctx, msg, errors) {\n console.error(msg, errors)\n }\n },\n websocketServer\n )\n\n const server = new ApolloServer({\n schema: builtSchema,\n formatError: error => {\n logger.error(error)\n return error\n },\n introspection: true,\n csrfPrevention: true,\n plugins: [\n // Proper shutdown for the HTTP server.\n ApolloServerPluginDrainHttpServer({ httpServer }),\n // Proper shutdown for the WebSocket server.\n {\n async serverWillStart() {\n return {\n async drainServer() {\n await serverCleanup.dispose()\n }\n }\n }\n },\n // TODO make this landing page work\n ApolloServerPluginLandingPageProductionDefault({\n graphRef: 'my-graph-id@my-graph-variant',\n footer: false\n })\n ],\n cache: 'bounded'\n })\n\n await server.start()\n\n GraphqlLocalClient.init(builtSchema, app)\n\n orderedModuleNames.forEach(name => {\n const { initMiddlewares } = loader(name)\n initMiddlewares && initMiddlewares(app)\n })\n\n const render = require('@things-factory/ejs-remote')\n render(app, {\n root: '/views',\n host: `http://127.0.0.1:${PORT}`,\n layout: false,\n viewExt: 'html',\n cache: true,\n debug: false\n })\n\n app.use(koaBodyParser(bodyParserOption))\n\n /* routers */\n const ssoMiddlewares = []\n process.emit('bootstrap-collect-sso-middleware' as any, null, ssoMiddlewares)\n app.ssoMiddlewares = ssoMiddlewares\n\n process.emit('bootstrap-module-global-public-route' as any, app, globalPublicRouter)\n process.emit('bootstrap-module-global-private-route' as any, app, globalPrivateRouter)\n process.emit('bootstrap-module-domain-public-route' as any, app, domainPublicRouter)\n process.emit('bootstrap-module-domain-private-route' as any, app, domainPrivateRouter)\n\n app.use(checkValidity) /* Check the license after most of the context has been built */\n\n app\n .use(globalPublicRouter.routes())\n .use(globalPublicRouter.allowedMethods())\n .use(globalPrivateRouter.routes())\n .use(globalPrivateRouter.allowedMethods())\n .use(domainPublicRouter.routes())\n .use(domainPublicRouter.allowedMethods())\n .use(domainPrivateRouter.routes())\n .use(domainPrivateRouter.allowedMethods())\n\n /* Graphql Upload's multipart/form-data handling affects the restful file upload feature, so it should be placed after the routers configuration. */\n app.use(graphqlUploadKoa(fileUploadOption))\n\n graphqlRouter.post(\n '/graphql',\n koaMiddleware(server, {\n context: async ({ ctx }) => ctx\n })\n )\n app.use(graphqlRouter.routes())\n app.use(graphqlRouter.allowedMethods())\n\n /* should follow this order : history-fallback => koaStatic */\n app.use(historyApiFallback({ whiteList: [] }))\n\n app.use(\n koaStatic(path.join(process.cwd(), 'dist-app'), {\n index: 'index.html'\n })\n )\n\n // Set keep-alive timeout from configuration or fallback to default (65000ms).\n // The keepAliveTimeout determines how long the server will keep an idle connection\n // alive before closing it.\n const keepAliveTimeout = config.get('keepAliveTimeout', 65000)\n\n // Apply the configured keep-alive timeout to the server. If no configuration is\n // provided, default to 65000ms (65 seconds). In the context of an external load balancer,\n // this timeout is critical for maintaining persistent connections between the load\n // balancer and the server. Setting a sufficiently long keepAliveTimeout minimizes\n // the need to constantly re-establish TCP connections, improving efficiency and\n // reducing connection overhead.\n httpServer.keepAliveTimeout = keepAliveTimeout || 65000\n\n // Set headersTimeout to be 1000ms (1 second) longer than keepAliveTimeout.\n // This ensures the server has sufficient time to receive headers from the client\n // before closing the connection, preventing premature disconnections. In the context\n // of a load balancer, this ensures that if the load balancer is sending headers\n // slowly (due to network delays or other factors), the connection isn't closed\n // before the headers are fully transmitted.\n httpServer.headersTimeout = keepAliveTimeout + 1000\n\n httpServer.listen({ port: PORT }, () => {\n logger.info(`🚀 Server ready at http://0.0.0.0:${PORT}/graphql`)\n logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}/graphql`)\n\n process.emit('bootstrap-module-start' as any, { app, config, builtSchema, httpServer } as any)\n })\n}\n\nbootstrap()\n"]}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AttributeSetItemPatch = exports.AttributeSetItem = exports.AttributeSetItemType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
- const common_types_1 = require("../common-types");
6
+ const scalar_object_js_1 = require("../common-types/scalar-object.js");
7
7
  var AttributeSetItemType;
8
8
  (function (AttributeSetItemType) {
9
9
  AttributeSetItemType["number"] = "number";
@@ -46,7 +46,7 @@ tslib_1.__decorate([
46
46
  tslib_1.__metadata("design:type", String)
47
47
  ], AttributeSetItem.prototype, "type", void 0);
48
48
  tslib_1.__decorate([
49
- (0, type_graphql_1.Field)(type => common_types_1.ScalarObject, { nullable: true }),
49
+ (0, type_graphql_1.Field)(type => scalar_object_js_1.ScalarObject, { nullable: true }),
50
50
  tslib_1.__metadata("design:type", Object)
51
51
  ], AttributeSetItem.prototype, "options", void 0);
52
52
  exports.AttributeSetItem = AttributeSetItem = tslib_1.__decorate([
@@ -72,7 +72,7 @@ tslib_1.__decorate([
72
72
  tslib_1.__metadata("design:type", String)
73
73
  ], AttributeSetItemPatch.prototype, "type", void 0);
74
74
  tslib_1.__decorate([
75
- (0, type_graphql_1.Field)(type => common_types_1.ScalarObject, { nullable: true }),
75
+ (0, type_graphql_1.Field)(type => scalar_object_js_1.ScalarObject, { nullable: true }),
76
76
  tslib_1.__metadata("design:type", Object)
77
77
  ], AttributeSetItemPatch.prototype, "options", void 0);
78
78
  tslib_1.__decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"attribute-set-item-type.js","sourceRoot":"","sources":["../../../server/service/attribute-set/attribute-set-item-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAkF;AAClF,kDAA8C;AAE9C,IAAY,oBAQX;AARD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,2CAAmB,CAAA;IACnB,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,6CAAqB,CAAA;IACrB,qCAAa,CAAA;AACf,CAAC,EARW,oBAAoB,oCAApB,oBAAoB,QAQ/B;AAED,IAAA,+BAAgB,EAAC,oBAAoB,EAAE;IACrC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,0CAA0C;CACxD,CAAC,CAAA;AAGK,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAqB5B,CAAA;AArBY,4CAAgB;AAE3B;IADC,IAAA,oBAAK,GAAE;;8CACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACd;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACC;AAG3B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,2BAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACb;2BApBxB,gBAAgB;IAD5B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;GAC9C,gBAAgB,CAqB5B;AAGM,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;CAqBjC,CAAA;AArBY,sDAAqB;AAEhC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACb;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACd;AAGZ;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDAC7B;AAG3B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,2BAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACb;AAGnC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACV;gCApBL,qBAAqB;IADjC,IAAA,wBAAS,GAAE;GACC,qBAAqB,CAqBjC","sourcesContent":["import { Field, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'\nimport { ScalarObject } from '../common-types'\n\nexport enum AttributeSetItemType {\n number = 'number',\n text = 'text',\n boolean = 'boolean',\n select = 'select',\n date = 'date',\n datetime = 'datetime',\n file = 'file'\n}\n\nregisterEnumType(AttributeSetItemType, {\n name: 'AttributeSetItemType',\n description: 'type enumeration of a attribute-set-item'\n})\n\n@ObjectType({ description: 'Entity for AttributeSetItem' })\nexport class AttributeSetItem {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n tag?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n hidden?: boolean\n\n @Field({ nullable: true })\n type?: AttributeSetItemType\n\n @Field(type => ScalarObject, { nullable: true })\n options?: { [option: string]: any }\n}\n\n@InputType()\nexport class AttributeSetItemPatch {\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n tag?: string\n\n @Field(type => AttributeSetItemType, { nullable: true })\n type?: AttributeSetItemType\n\n @Field(type => ScalarObject, { nullable: true })\n options?: { [option: string]: any }\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n hidden?: boolean\n}\n"]}
1
+ {"version":3,"file":"attribute-set-item-type.js","sourceRoot":"","sources":["../../../server/service/attribute-set/attribute-set-item-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAkF;AAClF,uEAA+D;AAE/D,IAAY,oBAQX;AARD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,2CAAmB,CAAA;IACnB,yCAAiB,CAAA;IACjB,qCAAa,CAAA;IACb,6CAAqB,CAAA;IACrB,qCAAa,CAAA;AACf,CAAC,EARW,oBAAoB,oCAApB,oBAAoB,QAQ/B;AAED,IAAA,+BAAgB,EAAC,oBAAoB,EAAE;IACrC,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,0CAA0C;CACxD,CAAC,CAAA;AAGK,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAqB5B,CAAA;AArBY,4CAAgB;AAE3B;IADC,IAAA,oBAAK,GAAE;;8CACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACd;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACC;AAG3B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,+BAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACb;2BApBxB,gBAAgB;IAD5B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;GAC9C,gBAAgB,CAqB5B;AAGM,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;CAqBjC,CAAA;AArBY,sDAAqB;AAEhC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACb;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACd;AAGZ;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDAC7B;AAG3B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,+BAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sDACb;AAGnC;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACV;gCApBL,qBAAqB;IADjC,IAAA,wBAAS,GAAE;GACC,qBAAqB,CAqBjC","sourcesContent":["import { Field, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'\nimport { ScalarObject } from '../common-types/scalar-object.js'\n\nexport enum AttributeSetItemType {\n number = 'number',\n text = 'text',\n boolean = 'boolean',\n select = 'select',\n date = 'date',\n datetime = 'datetime',\n file = 'file'\n}\n\nregisterEnumType(AttributeSetItemType, {\n name: 'AttributeSetItemType',\n description: 'type enumeration of a attribute-set-item'\n})\n\n@ObjectType({ description: 'Entity for AttributeSetItem' })\nexport class AttributeSetItem {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n tag?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n hidden?: boolean\n\n @Field({ nullable: true })\n type?: AttributeSetItemType\n\n @Field(type => ScalarObject, { nullable: true })\n options?: { [option: string]: any }\n}\n\n@InputType()\nexport class AttributeSetItemPatch {\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n tag?: string\n\n @Field(type => AttributeSetItemType, { nullable: true })\n type?: AttributeSetItemType\n\n @Field(type => ScalarObject, { nullable: true })\n options?: { [option: string]: any }\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n hidden?: boolean\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { AttributeSet } from './attribute-set';
2
- import { NewAttributeSet, AttributeSetPatch } from './attribute-set-type';
1
+ import { AttributeSet } from './attribute-set.js';
2
+ import { NewAttributeSet, AttributeSetPatch } from './attribute-set-type.js';
3
3
  export declare class AttributeSetMutation {
4
4
  createAttributeSet(attribute: NewAttributeSet, context: any): Promise<AttributeSet>;
5
5
  updateAttributeSet(id: string, patch: AttributeSetPatch, context: any): Promise<AttributeSet>;
@@ -4,16 +4,16 @@ exports.AttributeSetMutation = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
6
  const typeorm_1 = require("typeorm");
7
- const attribute_set_1 = require("./attribute-set");
8
- const attribute_set_type_1 = require("./attribute-set-type");
7
+ const attribute_set_js_1 = require("./attribute-set.js");
8
+ const attribute_set_type_js_1 = require("./attribute-set-type.js");
9
9
  let AttributeSetMutation = class AttributeSetMutation {
10
10
  async createAttributeSet(attribute, context) {
11
11
  const { tx } = context.state;
12
- return await tx.getRepository(attribute_set_1.AttributeSet).save(Object.assign({}, attribute));
12
+ return await tx.getRepository(attribute_set_js_1.AttributeSet).save(Object.assign({}, attribute));
13
13
  }
14
14
  async updateAttributeSet(id, patch, context) {
15
15
  const { tx } = context.state;
16
- const repository = tx.getRepository(attribute_set_1.AttributeSet);
16
+ const repository = tx.getRepository(attribute_set_js_1.AttributeSet);
17
17
  const attribute = await repository.findOne({
18
18
  where: { id }
19
19
  });
@@ -24,7 +24,7 @@ let AttributeSetMutation = class AttributeSetMutation {
24
24
  let results = [];
25
25
  const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
26
26
  const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
27
- const attributeRepo = tx.getRepository(attribute_set_1.AttributeSet);
27
+ const attributeRepo = tx.getRepository(attribute_set_js_1.AttributeSet);
28
28
  if (_createRecords.length > 0) {
29
29
  for (let i = 0; i < _createRecords.length; i++) {
30
30
  const newRecord = _createRecords[i];
@@ -44,12 +44,12 @@ let AttributeSetMutation = class AttributeSetMutation {
44
44
  }
45
45
  async deleteAttributeSet(id, context) {
46
46
  const { tx } = context.state;
47
- await tx.getRepository(attribute_set_1.AttributeSet).delete({ id });
47
+ await tx.getRepository(attribute_set_js_1.AttributeSet).delete({ id });
48
48
  return true;
49
49
  }
50
50
  async deleteAttributeSets(ids, context) {
51
51
  const { tx } = context.state;
52
- await tx.getRepository(attribute_set_1.AttributeSet).delete({
52
+ await tx.getRepository(attribute_set_js_1.AttributeSet).delete({
53
53
  id: (0, typeorm_1.In)(ids)
54
54
  });
55
55
  return true;
@@ -57,7 +57,7 @@ let AttributeSetMutation = class AttributeSetMutation {
57
57
  async importAttributeSets(attributes, context) {
58
58
  const { tx } = context.state;
59
59
  await Promise.all(attributes.map(async (attribute) => {
60
- await tx.getRepository(attribute_set_1.AttributeSet).save(attribute);
60
+ await tx.getRepository(attribute_set_js_1.AttributeSet).save(attribute);
61
61
  }));
62
62
  return true;
63
63
  }
@@ -66,29 +66,29 @@ exports.AttributeSetMutation = AttributeSetMutation;
66
66
  tslib_1.__decorate([
67
67
  (0, type_graphql_1.Directive)('@transaction'),
68
68
  (0, type_graphql_1.Directive)('@privilege(superUserGranted: true)'),
69
- (0, type_graphql_1.Mutation)(returns => attribute_set_1.AttributeSet, { description: 'To create new AttributeSet' }),
69
+ (0, type_graphql_1.Mutation)(returns => attribute_set_js_1.AttributeSet, { description: 'To create new AttributeSet' }),
70
70
  tslib_1.__param(0, (0, type_graphql_1.Arg)('attribute')),
71
71
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
72
72
  tslib_1.__metadata("design:type", Function),
73
- tslib_1.__metadata("design:paramtypes", [attribute_set_type_1.NewAttributeSet, Object]),
73
+ tslib_1.__metadata("design:paramtypes", [attribute_set_type_js_1.NewAttributeSet, Object]),
74
74
  tslib_1.__metadata("design:returntype", Promise)
75
75
  ], AttributeSetMutation.prototype, "createAttributeSet", null);
76
76
  tslib_1.__decorate([
77
77
  (0, type_graphql_1.Directive)('@transaction'),
78
78
  (0, type_graphql_1.Directive)('@privilege(superUserGranted: true)'),
79
- (0, type_graphql_1.Mutation)(returns => attribute_set_1.AttributeSet, { description: 'To modify AttributeSet information' }),
79
+ (0, type_graphql_1.Mutation)(returns => attribute_set_js_1.AttributeSet, { description: 'To modify AttributeSet information' }),
80
80
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
81
81
  tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
82
82
  tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
83
83
  tslib_1.__metadata("design:type", Function),
84
- tslib_1.__metadata("design:paramtypes", [String, attribute_set_type_1.AttributeSetPatch, Object]),
84
+ tslib_1.__metadata("design:paramtypes", [String, attribute_set_type_js_1.AttributeSetPatch, Object]),
85
85
  tslib_1.__metadata("design:returntype", Promise)
86
86
  ], AttributeSetMutation.prototype, "updateAttributeSet", null);
87
87
  tslib_1.__decorate([
88
88
  (0, type_graphql_1.Directive)('@transaction'),
89
89
  (0, type_graphql_1.Directive)('@privilege(superUserGranted: true)'),
90
- (0, type_graphql_1.Mutation)(returns => [attribute_set_1.AttributeSet], { description: "To modify multiple AttributeSets' information" }),
91
- tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [attribute_set_type_1.AttributeSetPatch])),
90
+ (0, type_graphql_1.Mutation)(returns => [attribute_set_js_1.AttributeSet], { description: "To modify multiple AttributeSets' information" }),
91
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [attribute_set_type_js_1.AttributeSetPatch])),
92
92
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
93
93
  tslib_1.__metadata("design:type", Function),
94
94
  tslib_1.__metadata("design:paramtypes", [Array, Object]),
@@ -118,13 +118,13 @@ tslib_1.__decorate([
118
118
  (0, type_graphql_1.Directive)('@transaction'),
119
119
  (0, type_graphql_1.Directive)('@privilege(superUserGranted: true)'),
120
120
  (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple AttributeSets' }),
121
- tslib_1.__param(0, (0, type_graphql_1.Arg)('attributes', type => [attribute_set_type_1.AttributeSetPatch])),
121
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('attributes', type => [attribute_set_type_js_1.AttributeSetPatch])),
122
122
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
123
123
  tslib_1.__metadata("design:type", Function),
124
124
  tslib_1.__metadata("design:paramtypes", [Array, Object]),
125
125
  tslib_1.__metadata("design:returntype", Promise)
126
126
  ], AttributeSetMutation.prototype, "importAttributeSets", null);
127
127
  exports.AttributeSetMutation = AttributeSetMutation = tslib_1.__decorate([
128
- (0, type_graphql_1.Resolver)(attribute_set_1.AttributeSet)
128
+ (0, type_graphql_1.Resolver)(attribute_set_js_1.AttributeSet)
129
129
  ], AttributeSetMutation);
130
130
  //# sourceMappingURL=attribute-set-mutation.js.map