@things-factory/shell 10.0.0-zeta.8 → 10.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/client/entries/public/home.js +1 -1
  2. package/client/themes/app-theme.css +8 -24
  3. package/client/themes/calendar-theme.css +0 -7
  4. package/client/themes/grist-theme.css +13 -37
  5. package/client/themes/layout-theme.css +3 -23
  6. package/client/themes/report-theme.css +0 -9
  7. package/client/themes/theme-base.css +30 -0
  8. package/client/themes/tooltip-theme.css +0 -4
  9. package/dist-server/bootstrap-hooks.d.ts +51 -0
  10. package/dist-server/bootstrap-hooks.js +39 -0
  11. package/dist-server/bootstrap-hooks.js.map +1 -0
  12. package/dist-server/index.d.ts +1 -0
  13. package/dist-server/index.js +1 -0
  14. package/dist-server/index.js.map +1 -1
  15. package/dist-server/initializers/database.js +4 -1
  16. package/dist-server/initializers/database.js.map +1 -1
  17. package/dist-server/migrations/1785369600000-IndexDomainOwner.d.ts +5 -0
  18. package/dist-server/migrations/1785369600000-IndexDomainOwner.js +49 -0
  19. package/dist-server/migrations/1785369600000-IndexDomainOwner.js.map +1 -0
  20. package/dist-server/server-dev.js +13 -10
  21. package/dist-server/server-dev.js.map +1 -1
  22. package/dist-server/server.js +12 -8
  23. package/dist-server/server.js.map +1 -1
  24. package/dist-server/service/domain/domain-mutation.js +3 -2
  25. package/dist-server/service/domain/domain-mutation.js.map +1 -1
  26. package/dist-server/service/domain/domain.js +12 -1
  27. package/dist-server/service/domain/domain.js.map +1 -1
  28. package/dist-server/service/env-var/env-var-mutation.js +6 -1
  29. package/dist-server/service/env-var/env-var-mutation.js.map +1 -1
  30. package/dist-server/tsconfig.tsbuildinfo +1 -1
  31. package/dist-server/typeorm/get-data-encryption-key.js +11 -1
  32. package/dist-server/typeorm/get-data-encryption-key.js.map +1 -1
  33. package/dist-server/utils/apply-domain-filter.d.ts +17 -0
  34. package/dist-server/utils/apply-domain-filter.js +30 -0
  35. package/dist-server/utils/apply-domain-filter.js.map +1 -0
  36. package/dist-server/utils/condition-builder.js +15 -7
  37. package/dist-server/utils/condition-builder.js.map +1 -1
  38. package/dist-server/utils/get-query-builder-from-list-params.d.ts +39 -9
  39. package/dist-server/utils/get-query-builder-from-list-params.js +83 -40
  40. package/dist-server/utils/get-query-builder-from-list-params.js.map +1 -1
  41. package/dist-server/utils/index.d.ts +1 -0
  42. package/dist-server/utils/index.js +1 -0
  43. package/dist-server/utils/index.js.map +1 -1
  44. package/dist-server/utils/list-params-converter.js +8 -6
  45. package/dist-server/utils/list-params-converter.js.map +1 -1
  46. package/dist-server/utils/list-query-builder.js +2 -14
  47. package/dist-server/utils/list-query-builder.js.map +1 -1
  48. package/jest.config.js +5 -0
  49. package/package.json +12 -12
  50. package/tests/domain-owner-index.test.ts +121 -0
  51. package/tests/env-var-tenant-isolation.test.ts +118 -0
  52. package/tests/get-query-builder-features.test.ts +229 -0
  53. package/tests/list-param-operators.test.ts +87 -0
  54. package/tests/manifest-contract.test.ts +38 -0
  55. package/client/store.ts +0 -15
@@ -31,6 +31,7 @@ const env_1 = require("@things-factory/env");
31
31
  const operato_license_checker_1 = require("@things-factory/operato-license-checker");
32
32
  const graphql_local_client_js_1 = require("./graphql-local-client.js");
33
33
  const database_js_1 = require("./initializers/database.js");
34
+ const bootstrap_hooks_js_1 = require("./bootstrap-hooks.js");
34
35
  const index_js_1 = require("./routers/index.js");
35
36
  const schema_js_1 = require("./schema.js");
36
37
  const domain_middleware_js_1 = require("./middlewares/domain-middleware.js");
@@ -86,7 +87,7 @@ const bootstrap = async () => {
86
87
  await next();
87
88
  });
88
89
  var subscriptionMiddleware = [];
89
- process.emit('bootstrap-module-subscription', app, subscriptionMiddleware);
90
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-subscription', app, subscriptionMiddleware);
90
91
  const builtSchema = await (0, schema_js_1.schema)();
91
92
  const httpServer = (0, http_1.createServer)(app.callback());
92
93
  const websocketServer = new ws_2.WebSocketServer({
@@ -176,8 +177,7 @@ const bootstrap = async () => {
176
177
  });
177
178
  // only for development mode. triggered after webpack compilation is done.
178
179
  compiler.hooks.done.tap({ name: 'server-dev' }, stats => {
179
- ;
180
- process.emit('client-rebuilt', app, compiler.outputFileSystem);
180
+ (0, bootstrap_hooks_js_1.emitHook)('client-rebuilt', app, compiler.outputFileSystem);
181
181
  });
182
182
  // Skip body parser for proxy paths to allow raw body forwarding
183
183
  app.use(async (ctx, next) => {
@@ -189,12 +189,12 @@ const bootstrap = async () => {
189
189
  });
190
190
  /* routers */
191
191
  const ssoMiddlewares = [];
192
- process.emit('bootstrap-collect-sso-middleware', null, ssoMiddlewares);
192
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-collect-sso-middleware', null, ssoMiddlewares);
193
193
  app.ssoMiddlewares = ssoMiddlewares;
194
- process.emit('bootstrap-module-global-public-route', app, index_js_1.globalPublicRouter);
195
- process.emit('bootstrap-module-global-private-route', app, index_js_1.globalPrivateRouter);
196
- process.emit('bootstrap-module-domain-public-route', app, index_js_1.domainPublicRouter);
197
- process.emit('bootstrap-module-domain-private-route', app, index_js_1.domainPrivateRouter);
194
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-global-public-route', app, index_js_1.globalPublicRouter);
195
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-global-private-route', app, index_js_1.globalPrivateRouter);
196
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-domain-public-route', app, index_js_1.domainPublicRouter);
197
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-domain-private-route', app, index_js_1.domainPrivateRouter);
198
198
  app.use(operato_license_checker_1.checkValidity); /* Check the license after most of the context has been built */
199
199
  app
200
200
  .use(index_js_1.globalPublicRouter.routes())
@@ -220,8 +220,11 @@ const bootstrap = async () => {
220
220
  httpServer.listen({ port: PORT }, () => {
221
221
  env_1.logger.info(`🚀 Server ready at http://0.0.0.0:${PORT}/graphql`);
222
222
  env_1.logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}/graphql`);
223
- process.emit('bootstrap-module-start', { app, config: env_1.config, builtSchema, httpServer });
223
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-start', { app, config: env_1.config, builtSchema, httpServer });
224
224
  });
225
225
  };
226
- bootstrap();
226
+ bootstrap().catch(error => {
227
+ env_1.logger.error('Failed to bootstrap server', error);
228
+ process.exit(1);
229
+ });
227
230
  //# sourceMappingURL=server-dev.js.map
@@ -1 +1 @@
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;AAE3B,6CAAgF;AAChF,qFAAoF;AAEpF,uEAA8D;AAC9D,4DAAgE;AAChE,iDAM2B;AAC3B,2CAAoC;AAEpC,6EAAqE;AACrE,6DAA+D;AAE/D,IAAA,6CAAwB,GAAE,CAAA;AAE1B,cAAI,CAAC,MAAM,CAAC,MAAM,EAAE,2CAA2C,EAAE,YAAM,CAAC,GAAG,C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AAC,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 webpackConfigPath = flags.webpack || '@things-factory/builder/webpack.config.dev.js'\nconst webpackConfig = require(require.resolve(webpackConfigPath, { paths: [process.cwd()] }))\n\nconst compiler = webpack(webpackConfig)\n\nconst PORT = (process.env.PORT = flags.port)\n\nconst requestBody = config.get('requestBody') || {}\n\nprocess['PROXY_PASSTHROUGH_PATHS'] = []\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 as any).emit('bootstrap-module-subscription', 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 stopOnTerminationSignals: false, // ★ 자동 시그널 핸들러 비활성화\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 mod = loader(name) || {}\n mod.initMiddlewares && mod.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 as any).emit('client-rebuilt', app, compiler.outputFileSystem)\n })\n\n // Skip body parser for proxy paths to allow raw body forwarding\n app.use(async (ctx, next) => {\n const PROXY_PASSTHROUGH_PATHS = process['PROXY_PASSTHROUGH_PATHS'] || []\n if (PROXY_PASSTHROUGH_PATHS.some(path => ctx.path.startsWith(path))) {\n return next()\n }\n return koaBodyParser(bodyParserOption)(ctx, next)\n })\n\n /* routers */\n const ssoMiddlewares = []\n ;(process as any).emit('bootstrap-collect-sso-middleware', null, ssoMiddlewares)\n app.ssoMiddlewares = ssoMiddlewares\n\n ;(process as any).emit('bootstrap-module-global-public-route', app, globalPublicRouter)\n ;(process as any).emit('bootstrap-module-global-private-route', app, globalPrivateRouter)\n ;(process as any).emit('bootstrap-module-domain-public-route', app, domainPublicRouter)\n ;(process as any).emit('bootstrap-module-domain-private-route', 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 as any).emit('bootstrap-module-start', { app, config, builtSchema, httpServer })\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;AAE3B,6CAAgF;AAChF,qFAAoF;AAEpF,uEAA8D;AAC9D,4DAAgE;AAChE,6DAA+C;AAC/C,iDAM2B;AAC3B,2CAAoC;AAEpC,6EAAqE;AACrE,6DAA+D;AAE/D,IAAA,6CAAwB,GAAE,CAAA;AAE1B,cAAI,CAAC,MAAM,CAAC,MAAM,EAAE,2CAA2C,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A;AACJ,CAAC,CAAA;AAED,SAAS,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACxB,YAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAA;IACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,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 { emitHook } from './bootstrap-hooks.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 webpackConfigPath = flags.webpack || '@things-factory/builder/webpack.config.dev.js'\nconst webpackConfig = require(require.resolve(webpackConfigPath, { paths: [process.cwd()] }))\n\nconst compiler = webpack(webpackConfig)\n\nconst PORT = (process.env.PORT = flags.port)\n\nconst requestBody = config.get('requestBody') || {}\n\nprocess['PROXY_PASSTHROUGH_PATHS'] = []\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 emitHook('bootstrap-module-subscription', 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 stopOnTerminationSignals: false, // ★ 자동 시그널 핸들러 비활성화\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 mod = loader(name) || {}\n mod.initMiddlewares && mod.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 emitHook('client-rebuilt', app, compiler.outputFileSystem)\n })\n\n // Skip body parser for proxy paths to allow raw body forwarding\n app.use(async (ctx, next) => {\n const PROXY_PASSTHROUGH_PATHS = process['PROXY_PASSTHROUGH_PATHS'] || []\n if (PROXY_PASSTHROUGH_PATHS.some(path => ctx.path.startsWith(path))) {\n return next()\n }\n return koaBodyParser(bodyParserOption)(ctx, next)\n })\n\n /* routers */\n const ssoMiddlewares = []\n emitHook('bootstrap-collect-sso-middleware', null, ssoMiddlewares)\n app.ssoMiddlewares = ssoMiddlewares\n\n emitHook('bootstrap-module-global-public-route', app, globalPublicRouter)\n emitHook('bootstrap-module-global-private-route', app, globalPrivateRouter)\n emitHook('bootstrap-module-domain-public-route', app, domainPublicRouter)\n emitHook('bootstrap-module-domain-private-route', 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 emitHook('bootstrap-module-start', { app, config, builtSchema, httpServer })\n })\n}\n\nbootstrap().catch(error => {\n logger.error('Failed to bootstrap server', error)\n process.exit(1)\n})\n"]}
@@ -32,6 +32,7 @@ const env_1 = require("@things-factory/env");
32
32
  const operato_license_checker_1 = require("@things-factory/operato-license-checker");
33
33
  const graphql_local_client_js_1 = require("./graphql-local-client.js");
34
34
  const database_js_1 = require("./initializers/database.js");
35
+ const bootstrap_hooks_js_1 = require("./bootstrap-hooks.js");
35
36
  const index_js_1 = require("./routers/index.js");
36
37
  const schema_js_1 = require("./schema.js");
37
38
  const domain_middleware_js_1 = require("./middlewares/domain-middleware.js");
@@ -80,7 +81,7 @@ const bootstrap = async () => {
80
81
  await next();
81
82
  });
82
83
  var subscriptionMiddleware = [];
83
- process.emit('bootstrap-module-subscription', app, subscriptionMiddleware);
84
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-subscription', app, subscriptionMiddleware);
84
85
  const builtSchema = await (0, schema_js_1.schema)();
85
86
  const httpServer = (0, http_1.createServer)(app.callback());
86
87
  const websocketServer = new ws_2.WebSocketServer({
@@ -177,12 +178,12 @@ const bootstrap = async () => {
177
178
  });
178
179
  /* routers */
179
180
  const ssoMiddlewares = [];
180
- process.emit('bootstrap-collect-sso-middleware', null, ssoMiddlewares);
181
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-collect-sso-middleware', null, ssoMiddlewares);
181
182
  app.ssoMiddlewares = ssoMiddlewares;
182
- process.emit('bootstrap-module-global-public-route', app, index_js_1.globalPublicRouter);
183
- process.emit('bootstrap-module-global-private-route', app, index_js_1.globalPrivateRouter);
184
- process.emit('bootstrap-module-domain-public-route', app, index_js_1.domainPublicRouter);
185
- process.emit('bootstrap-module-domain-private-route', app, index_js_1.domainPrivateRouter);
183
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-global-public-route', app, index_js_1.globalPublicRouter);
184
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-global-private-route', app, index_js_1.globalPrivateRouter);
185
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-domain-public-route', app, index_js_1.domainPublicRouter);
186
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-domain-private-route', app, index_js_1.domainPrivateRouter);
186
187
  app.use(operato_license_checker_1.checkValidity); /* Check the license after most of the context has been built */
187
188
  app
188
189
  .use(index_js_1.globalPublicRouter.routes())
@@ -226,8 +227,11 @@ const bootstrap = async () => {
226
227
  httpServer.listen({ port: PORT }, () => {
227
228
  env_1.logger.info(`🚀 Server ready at http://0.0.0.0:${PORT}/graphql`);
228
229
  env_1.logger.info(`🚀 Subscriptions ready at ws://0.0.0.0:${PORT}/graphql`);
229
- process.emit('bootstrap-module-start', { app, config: env_1.config, builtSchema, httpServer });
230
+ (0, bootstrap_hooks_js_1.emitHook)('bootstrap-module-start', { app, config: env_1.config, builtSchema, httpServer });
230
231
  });
231
232
  };
232
- bootstrap();
233
+ bootstrap().catch(error => {
234
+ env_1.logger.error('Failed to bootstrap server', error);
235
+ process.exit(1);
236
+ });
233
237
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../server/server.ts"],"names":[],"mappings":";AAAA,4BAA4B;;;AAE5B,4DAA4D;AAC5D,oDAAmB;AACnB,OAAO,CAAC,GAAG,CAAC,kBAA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F,+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,CACpE;QAAC,OAAe,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,GAAG,EAAE,MAAM,EAAN,YAAM,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAA;IAC5F,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\nprocess['PROXY_PASSTHROUGH_PATHS'] = []\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 as any).emit('bootstrap-module-subscription', 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: false,\n csrfPrevention: true,\n stopOnTerminationSignals: false, // ★ 자동 시그널 핸들러 비활성화\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 // Skip body parser for proxy paths to allow raw body forwarding\n app.use(async (ctx, next) => {\n const PROXY_PASSTHROUGH_PATHS = process['PROXY_PASSTHROUGH_PATHS'] || []\n if (PROXY_PASSTHROUGH_PATHS.some(path => ctx.path.startsWith(path))) {\n return next()\n }\n return koaBodyParser(bodyParserOption)(ctx, next)\n })\n\n /* routers */\n const ssoMiddlewares = []\n ;(process as any).emit('bootstrap-collect-sso-middleware', null, ssoMiddlewares)\n app.ssoMiddlewares = ssoMiddlewares\n ;(process as any).emit('bootstrap-module-global-public-route', app, globalPublicRouter)\n ;(process as any).emit('bootstrap-module-global-private-route', app, globalPrivateRouter)\n ;(process as any).emit('bootstrap-module-domain-public-route', app, domainPublicRouter)\n ;(process as any).emit('bootstrap-module-domain-private-route', 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 ;(process as any).emit('bootstrap-module-start', { app, config, builtSchema, httpServer })\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;AAC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EAAN,YAAM,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,CAAA;IAC9E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,SAAS,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACxB,YAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAA;IACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,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 { emitHook } from './bootstrap-hooks.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\nprocess['PROXY_PASSTHROUGH_PATHS'] = []\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 emitHook('bootstrap-module-subscription', 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: false,\n csrfPrevention: true,\n stopOnTerminationSignals: false, // ★ 자동 시그널 핸들러 비활성화\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 // Skip body parser for proxy paths to allow raw body forwarding\n app.use(async (ctx, next) => {\n const PROXY_PASSTHROUGH_PATHS = process['PROXY_PASSTHROUGH_PATHS'] || []\n if (PROXY_PASSTHROUGH_PATHS.some(path => ctx.path.startsWith(path))) {\n return next()\n }\n return koaBodyParser(bodyParserOption)(ctx, next)\n })\n\n /* routers */\n const ssoMiddlewares = []\n emitHook('bootstrap-collect-sso-middleware', null, ssoMiddlewares)\n app.ssoMiddlewares = ssoMiddlewares\n emitHook('bootstrap-module-global-public-route', app, globalPublicRouter)\n emitHook('bootstrap-module-global-private-route', app, globalPrivateRouter)\n emitHook('bootstrap-module-domain-public-route', app, domainPublicRouter)\n emitHook('bootstrap-module-domain-private-route', 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 emitHook('bootstrap-module-start', { app, config, builtSchema, httpServer })\n })\n}\n\nbootstrap().catch(error => {\n logger.error('Failed to bootstrap server', error)\n process.exit(1)\n})\n"]}
@@ -43,7 +43,8 @@ let DomainMutation = class DomainMutation {
43
43
  const domainRepo = (0, database_js_1.getRepository)(domain_js_1.Domain);
44
44
  const patchIds = patches.filter((patch) => patch.id);
45
45
  if (patchIds.length > 0) {
46
- patchIds.forEach(async (updateRecord) => {
46
+ /* 모든 저장을 await 해야 @transaction 스코프 안에서 커밋되고 에러가 호출자에 전파된다. */
47
+ await Promise.all(patchIds.map(async (updateRecord) => {
47
48
  const domain = await domainRepo.findOne({ where: { id: updateRecord.id } });
48
49
  if (updateRecord.name) {
49
50
  updateRecord.subdomain = (0, utils_1.slugger)(updateRecord.name);
@@ -55,7 +56,7 @@ let DomainMutation = class DomainMutation {
55
56
  ...domain,
56
57
  ...updateRecord
57
58
  });
58
- });
59
+ }));
59
60
  }
60
61
  return true;
61
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"domain-mutation.js","sourceRoot":"","sources":["../../../server/service/domain/domain-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAyF;AACzF,qCAAwC;AAExC,iDAA+C;AAE/C,gEAA8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kBAAM,CAAC;GACJ,cAAc,CAsH1B","sourcesContent":["import { Arg, Args, Ctx, Directive, Mutation, Query, Resolver, Root } from 'type-graphql'\nimport { In, Repository } from 'typeorm'\n\nimport { slugger } from '@things-factory/utils'\n\nimport { getRepository } from '../../initializers/database.js'\n\nimport { Domain, IPList } from './domain.js'\nimport { DomainPatch } from './domain-types.js'\nimport { ScalarObject } from '../common-types/scalar-object.js'\n\n@Resolver(Domain)\nexport class DomainMutation {\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Domain, {\n description:\n 'Creates a new domain entity. Only superusers are granted this privilege. Use this mutation to register a new domain with a unique subdomain.'\n })\n async createDomain(\n @Arg('domainInput', { description: 'The input object containing the new domain details.' }) domainInput: DomainPatch\n ) {\n const { name, description } = domainInput\n const domainRepo: Repository<Domain> = getRepository(Domain)\n const subdomain: string = slugger(name)\n\n const domain: Domain = await domainRepo.findOneBy({ subdomain })\n if (domain) {\n throw new Error('domain is duplicated')\n }\n\n return await domainRepo.save({ name, description, subdomain })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Domain, {\n description:\n 'Deletes a domain entity by its name. Only superusers are granted this privilege. Use this mutation to permanently remove a domain.'\n })\n async deleteDomain(@Arg('name', { description: 'The name of the domain to delete.' }) name: string) {\n return await getRepository(Domain).delete({ name })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Boolean, {\n description:\n 'Deletes multiple domain entities by their names. Only superusers are granted this privilege. Use this mutation to remove several domains at once.'\n })\n async deleteDomains(\n @Arg('names', () => [String], { description: 'An array of domain names to delete.' }) names: string[]\n ) {\n const domains: Domain[] = await getRepository(Domain).find({ where: { name: In(names) } })\n const domainIds: string[] = domains.map(domain => domain.id)\n\n await getRepository(Domain).delete({ id: In(domainIds) })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Domain, {\n description: 'To update domain (Only superuser is granted this privilege.)'\n })\n async updateDomain(@Arg('name') name: string, @Arg('patch', () => DomainPatch) patch: DomainPatch) {\n const repository = getRepository(Domain)\n const domain: Domain = await repository.findOneBy({ name })\n\n if (patch.parent && patch.parent.id == domain.id) {\n delete patch.parent\n }\n\n return await repository.save({\n ...domain,\n ...patch\n } as any)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Boolean, {\n description: 'To update multiple domains (Only superuser is granted this privilege.)'\n })\n async updateDomains(@Arg('patches', () => [DomainPatch]) patches: DomainPatch[]): Promise<boolean> {\n const domainRepo: Repository<Domain> = getRepository(Domain)\n\n const patchIds = patches.filter((patch: any) => patch.id)\n\n if (patchIds.length > 0) {\n patchIds.forEach(async updateRecord => {\n const domain: Domain = await domainRepo.findOne({ where: { id: updateRecord.id } })\n\n if (updateRecord.name) {\n updateRecord.subdomain = slugger(updateRecord.name)\n }\n\n if (updateRecord.parent && updateRecord.parent.id == domain.id) {\n delete updateRecord.parent\n }\n\n await domainRepo.save({\n ...domain,\n ...updateRecord\n } as any)\n })\n }\n\n return true\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"security\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => ScalarObject, { nullable: true, description: 'To update secure IP list for domain' })\n async updateSecureIPList(\n @Arg('iplist', type => ScalarObject) iplist: IPList,\n @Ctx() context: any\n ): Promise<IPList | null> {\n const { domain } = context.state\n const repository = getRepository(Domain)\n // const domain: Domain = await repository.findOneBy({ id })\n\n const { iplist: result } = await repository.save({\n ...domain,\n iplist\n } as any)\n\n return result\n }\n}\n"]}
1
+ {"version":3,"file":"domain-mutation.js","sourceRoot":"","sources":["../../../server/service/domain/domain-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAyF;AACzF,qCAAwC;AAExC,iDAA+C;AAE/C,gEAA8D;AAE9D,2CAA4C;AAC5C,uDAA+C;AAC/C,uEAA+D;AAGxD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,CAAC;GACJ,cAAc,CAyH1B","sourcesContent":["import { Arg, Args, Ctx, Directive, Mutation, Query, Resolver, Root } from 'type-graphql'\nimport { In, Repository } from 'typeorm'\n\nimport { slugger } from '@things-factory/utils'\n\nimport { getRepository } from '../../initializers/database.js'\n\nimport { Domain, IPList } from './domain.js'\nimport { DomainPatch } from './domain-types.js'\nimport { ScalarObject } from '../common-types/scalar-object.js'\n\n@Resolver(Domain)\nexport class DomainMutation {\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Domain, {\n description:\n 'Creates a new domain entity. Only superusers are granted this privilege. Use this mutation to register a new domain with a unique subdomain.'\n })\n async createDomain(\n @Arg('domainInput', { description: 'The input object containing the new domain details.' }) domainInput: DomainPatch\n ) {\n const { name, description } = domainInput\n const domainRepo: Repository<Domain> = getRepository(Domain)\n const subdomain: string = slugger(name)\n\n const domain: Domain = await domainRepo.findOneBy({ subdomain })\n if (domain) {\n throw new Error('domain is duplicated')\n }\n\n return await domainRepo.save({ name, description, subdomain })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Domain, {\n description:\n 'Deletes a domain entity by its name. Only superusers are granted this privilege. Use this mutation to permanently remove a domain.'\n })\n async deleteDomain(@Arg('name', { description: 'The name of the domain to delete.' }) name: string) {\n return await getRepository(Domain).delete({ name })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Boolean, {\n description:\n 'Deletes multiple domain entities by their names. Only superusers are granted this privilege. Use this mutation to remove several domains at once.'\n })\n async deleteDomains(\n @Arg('names', () => [String], { description: 'An array of domain names to delete.' }) names: string[]\n ) {\n const domains: Domain[] = await getRepository(Domain).find({ where: { name: In(names) } })\n const domainIds: string[] = domains.map(domain => domain.id)\n\n await getRepository(Domain).delete({ id: In(domainIds) })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Domain, {\n description: 'To update domain (Only superuser is granted this privilege.)'\n })\n async updateDomain(@Arg('name') name: string, @Arg('patch', () => DomainPatch) patch: DomainPatch) {\n const repository = getRepository(Domain)\n const domain: Domain = await repository.findOneBy({ name })\n\n if (patch.parent && patch.parent.id == domain.id) {\n delete patch.parent\n }\n\n return await repository.save({\n ...domain,\n ...patch\n } as any)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(superUserGranted: true)')\n @Mutation(returns => Boolean, {\n description: 'To update multiple domains (Only superuser is granted this privilege.)'\n })\n async updateDomains(@Arg('patches', () => [DomainPatch]) patches: DomainPatch[]): Promise<boolean> {\n const domainRepo: Repository<Domain> = getRepository(Domain)\n\n const patchIds = patches.filter((patch: any) => patch.id)\n\n if (patchIds.length > 0) {\n /* 모든 저장을 await 해야 @transaction 스코프 안에서 커밋되고 에러가 호출자에 전파된다. */\n await Promise.all(\n patchIds.map(async updateRecord => {\n const domain: Domain = await domainRepo.findOne({ where: { id: updateRecord.id } })\n\n if (updateRecord.name) {\n updateRecord.subdomain = slugger(updateRecord.name)\n }\n\n if (updateRecord.parent && updateRecord.parent.id == domain.id) {\n delete updateRecord.parent\n }\n\n await domainRepo.save({\n ...domain,\n ...updateRecord\n } as any)\n })\n )\n }\n\n return true\n }\n\n @Directive('@transaction')\n @Directive(\n '@privilege(category: \"security\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)'\n )\n @Mutation(returns => ScalarObject, { nullable: true, description: 'To update secure IP list for domain' })\n async updateSecureIPList(\n @Arg('iplist', type => ScalarObject) iplist: IPList,\n @Ctx() context: any\n ): Promise<IPList | null> {\n const { domain } = context.state\n const repository = getRepository(Domain)\n // const domain: Domain = await repository.findOneBy({ id })\n\n const { iplist: result } = await repository.save({\n ...domain,\n iplist\n } as any)\n\n return result\n }\n}\n"]}
@@ -125,7 +125,18 @@ exports.Domain = Domain = tslib_1.__decorate([
125
125
  (0, typeorm_1.Index)('ix_domain_0', (domain) => [domain.subdomain, domain.deletedAt], {
126
126
  unique: true,
127
127
  where: '"deleted_at" IS NULL'
128
- }),
128
+ })
129
+ /*
130
+ * 소유권으로 도메인을 찾는 조회(`owner = :userId`)를 위한 인덱스.
131
+ * 체크인 가능 도메인 목록 계산이 이 조건을 쓰는데, 인덱스가 없으면 도메인 수에 비례해
132
+ * 테이블을 훑는다. 한 사용자가 여러 도메인을 소유할 수 있고 값이 비어 있을 수도 있으므로
133
+ * 반드시 non-unique 여야 한다.
134
+ *
135
+ * 기존 설치에는 `1785369600000-IndexDomainOwner` 마이그레이션이 같은 인덱스를 만든다
136
+ * (운영 설정은 `synchronize: false` 이므로 이 선언만으로는 반영되지 않는다).
137
+ */
138
+ ,
139
+ (0, typeorm_1.Index)('ix_domain_1', (domain) => [domain.owner]),
129
140
  (0, type_graphql_1.ObjectType)({
130
141
  description: 'Represents a domain entity, which is a logical grouping of users, roles, and resources within the system.'
131
142
  })
@@ -1 +1 @@
1
- {"version":3,"file":"domain.js","sourceRoot":"","sources":["../../../server/service/domain/domain.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAA+D;AAC/D,uEAA+D;AAC/D,sDAA8C;AA0BvC,IAAM,MAAM,GAAZ,MAAM,MAAM;CAuGlB,CAAA;AAvGY,wBAAM;AAGR;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;;kCACxD;AAInB;IAFC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACjD,IAAA,gBAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;oCACb;AAIZ;IAFC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IACtE,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACR;AAInB;IAFC,IAAA,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AAY,EAAE;QAC3B,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,kEAAkE;KAChF,CAAC;;sCACa;AAiBf;IAFC,IAAA,gBAAM,EAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,+BAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC;;0CAClG;AAIhB;IAFC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;IACxF,IAAA,0BAAgB,GAAE;sCACR,IAAI;yCAAA;AAIf;IAFC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC;IAC7F,IAAA,0BAAgB,GAAE;sCACR,IAAI;yCAAA;AAIf;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;sCAC5F,IAAI;yCAAA;iBAtGL,MAAM;IATlB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,aAAa,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE;QAC9E,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,yBAAU,EAAC;QACV,WAAW,EACT,2GAA2G;KAC9G,CAAC;GACW,MAAM,CAuGlB","sourcesContent":["import {\n Column,\n CreateDateColumn,\n ManyToOne,\n OneToMany,\n RelationId,\n Entity,\n Index,\n UpdateDateColumn,\n DeleteDateColumn,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Directive, Field, ID } from 'type-graphql'\nimport { ScalarObject } from '../common-types/scalar-object.js'\nimport { EnvVar } from '../env-var/env-var.js'\n// import { config } from '@things-factory/env'\n// import { encryptJsonTransformer } from '../../typeorm/encrypt-json-transform.js'\n\n// const ORMCONFIG = config.get('ormconfig', {})\n// const DATABASE_TYPE = ORMCONFIG.type\n\nexport type IPList = {\n whitelist?: string[]\n blacklist?: string[]\n protectedlist?: string[]\n privileges?: {\n category: string\n privilege: string\n }[]\n}\n\n@Entity()\n@Index('ix_domain_0', (domain: Domain) => [domain.subdomain, domain.deletedAt], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@ObjectType({\n description:\n 'Represents a domain entity, which is a logical grouping of users, roles, and resources within the system.'\n})\nexport class Domain {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'The unique identifier of the domain.' })\n readonly id: string\n\n @Field({ description: 'The name of the domain.' })\n @Column({ unique: true })\n name: string\n\n @Field({ nullable: true, description: 'A description of the domain.' })\n @Column({ nullable: true })\n description: string\n\n @Field({ nullable: true, description: 'The external type of the domain, if applicable.' })\n @Column({ nullable: true })\n extType: string\n\n @Field({ nullable: true, description: 'The timezone of the domain, if applicable.' })\n @Column({ nullable: true })\n timezone: string\n\n @Directive('@deprecated(reason: \"Use `parent`\")')\n @Field({\n nullable: true,\n description: 'A flag indicating if the domain is a system domain. Deprecated, use `parent` instead.'\n })\n @Column({ default: false })\n systemFlag: boolean\n\n @Field({ nullable: true, description: 'The subdomain of the domain, if applicable.' })\n @Column({ nullable: true })\n subdomain: string\n\n @Field({ nullable: true, description: 'The parent domain, if this domain is a subdomain.' })\n @ManyToOne(type => Domain, { nullable: true })\n parent: Domain\n\n @RelationId((domain: Domain) => domain.parent)\n parentId?: string\n\n @OneToMany(type => Domain, domain => domain.parent)\n @Field(type => Domain, { nullable: true, description: 'The child domains, if any, under this domain.' })\n children: Domain[]\n\n @OneToMany(type => EnvVar, envVar => envVar.domain)\n @Field(type => [EnvVar], { nullable: true, description: 'The environment variables associated with the domain.' })\n envVars: EnvVar[]\n\n @Field({ nullable: true, description: 'The brand name associated with the domain, if any.' })\n @Column({ nullable: true })\n brandName: string\n\n @Field({ nullable: true, description: 'The brand image URL associated with the domain, if any.' })\n @Column({ nullable: true })\n brandImage: string\n\n @Field({ nullable: true, description: 'The content image URL associated with the domain, if any.' })\n @Column({ nullable: true })\n contentImage: string\n\n @Field({ nullable: true, description: 'The owner of the domain, if applicable.' })\n @Column({ nullable: true })\n owner: string\n\n @Field({ nullable: true, description: 'The theme associated with the domain, if any.' })\n @Column({ nullable: true })\n theme: string\n\n @Column('simple-json', { nullable: true })\n @Field(type => ScalarObject, {\n nullable: true,\n description: 'A list of IPs and their associated access levels for the domain.'\n })\n iplist?: IPList\n\n // TODO: 암호화 처리가 필요하면, 이렇게 설정을 변경하라.\n // @Column({\n // type:\n // DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n // ? 'longtext'\n // : DATABASE_TYPE == 'oracle'\n // ? 'clob'\n // : DATABASE_TYPE == 'mssql'\n // ? 'nvarchar'\n // : 'text', // PostgreSQL, SQLite\n // length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined,\n // transformer: encryptJsonTransformer\n // })\n @Column('simple-json', { nullable: true })\n @Field(type => ScalarObject, { nullable: true, description: 'Additional attributes associated with the domain.' })\n attributes?: any\n\n @Field({ nullable: true, description: 'The date and time when the domain was created.' })\n @CreateDateColumn()\n createdAt: Date\n\n @Field({ nullable: true, description: 'The date and time when the domain was last updated.' })\n @UpdateDateColumn()\n updatedAt: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'The date and time when the domain was deleted, if applicable.' })\n deletedAt?: Date\n}\n"]}
1
+ {"version":3,"file":"domain.js","sourceRoot":"","sources":["../../../server/service/domain/domain.ts"],"names":[],"mappings":";;;;AAAA,qCAWgB;AAChB,+CAA+D;AAC/D,uEAA+D;AAC/D,sDAA8C;AAoCvC,IAAM,MAAM,GAAZ,MAAM,MAAM;CAuGlB,CAAA;AAvGY,wBAAM;AAGR;IAFR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E;IACR,IAAA,eAAK,EAAC,aAAa,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE;QAC9E,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACF;;;;;;;;OAQG;;IACF,IAAA,eAAK,EAAC,aAAa,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxD,IAAA,yBAAU,EAAC;QACV,WAAW,EACT,2GAA2G;KAC9G,CAAC;GACW,MAAM,CAuGlB","sourcesContent":["import {\n Column,\n CreateDateColumn,\n ManyToOne,\n OneToMany,\n RelationId,\n Entity,\n Index,\n UpdateDateColumn,\n DeleteDateColumn,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Directive, Field, ID } from 'type-graphql'\nimport { ScalarObject } from '../common-types/scalar-object.js'\nimport { EnvVar } from '../env-var/env-var.js'\n// import { config } from '@things-factory/env'\n// import { encryptJsonTransformer } from '../../typeorm/encrypt-json-transform.js'\n\n// const ORMCONFIG = config.get('ormconfig', {})\n// const DATABASE_TYPE = ORMCONFIG.type\n\nexport type IPList = {\n whitelist?: string[]\n blacklist?: string[]\n protectedlist?: string[]\n privileges?: {\n category: string\n privilege: string\n }[]\n}\n\n@Entity()\n@Index('ix_domain_0', (domain: Domain) => [domain.subdomain, domain.deletedAt], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n/*\n * 소유권으로 도메인을 찾는 조회(`owner = :userId`)를 위한 인덱스.\n * 체크인 가능 도메인 목록 계산이 이 조건을 쓰는데, 인덱스가 없으면 도메인 수에 비례해\n * 테이블을 훑는다. 한 사용자가 여러 도메인을 소유할 수 있고 값이 비어 있을 수도 있으므로\n * 반드시 non-unique 여야 한다.\n *\n * 기존 설치에는 `1785369600000-IndexDomainOwner` 마이그레이션이 같은 인덱스를 만든다\n * (운영 설정은 `synchronize: false` 이므로 이 선언만으로는 반영되지 않는다).\n */\n@Index('ix_domain_1', (domain: Domain) => [domain.owner])\n@ObjectType({\n description:\n 'Represents a domain entity, which is a logical grouping of users, roles, and resources within the system.'\n})\nexport class Domain {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'The unique identifier of the domain.' })\n readonly id: string\n\n @Field({ description: 'The name of the domain.' })\n @Column({ unique: true })\n name: string\n\n @Field({ nullable: true, description: 'A description of the domain.' })\n @Column({ nullable: true })\n description: string\n\n @Field({ nullable: true, description: 'The external type of the domain, if applicable.' })\n @Column({ nullable: true })\n extType: string\n\n @Field({ nullable: true, description: 'The timezone of the domain, if applicable.' })\n @Column({ nullable: true })\n timezone: string\n\n @Directive('@deprecated(reason: \"Use `parent`\")')\n @Field({\n nullable: true,\n description: 'A flag indicating if the domain is a system domain. Deprecated, use `parent` instead.'\n })\n @Column({ default: false })\n systemFlag: boolean\n\n @Field({ nullable: true, description: 'The subdomain of the domain, if applicable.' })\n @Column({ nullable: true })\n subdomain: string\n\n @Field({ nullable: true, description: 'The parent domain, if this domain is a subdomain.' })\n @ManyToOne(type => Domain, { nullable: true })\n parent: Domain\n\n @RelationId((domain: Domain) => domain.parent)\n parentId?: string\n\n @OneToMany(type => Domain, domain => domain.parent)\n @Field(type => Domain, { nullable: true, description: 'The child domains, if any, under this domain.' })\n children: Domain[]\n\n @OneToMany(type => EnvVar, envVar => envVar.domain)\n @Field(type => [EnvVar], { nullable: true, description: 'The environment variables associated with the domain.' })\n envVars: EnvVar[]\n\n @Field({ nullable: true, description: 'The brand name associated with the domain, if any.' })\n @Column({ nullable: true })\n brandName: string\n\n @Field({ nullable: true, description: 'The brand image URL associated with the domain, if any.' })\n @Column({ nullable: true })\n brandImage: string\n\n @Field({ nullable: true, description: 'The content image URL associated with the domain, if any.' })\n @Column({ nullable: true })\n contentImage: string\n\n @Field({ nullable: true, description: 'The owner of the domain, if applicable.' })\n @Column({ nullable: true })\n owner: string\n\n @Field({ nullable: true, description: 'The theme associated with the domain, if any.' })\n @Column({ nullable: true })\n theme: string\n\n @Column('simple-json', { nullable: true })\n @Field(type => ScalarObject, {\n nullable: true,\n description: 'A list of IPs and their associated access levels for the domain.'\n })\n iplist?: IPList\n\n // TODO: 암호화 처리가 필요하면, 이렇게 설정을 변경하라.\n // @Column({\n // type:\n // DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n // ? 'longtext'\n // : DATABASE_TYPE == 'oracle'\n // ? 'clob'\n // : DATABASE_TYPE == 'mssql'\n // ? 'nvarchar'\n // : 'text', // PostgreSQL, SQLite\n // length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined,\n // transformer: encryptJsonTransformer\n // })\n @Column('simple-json', { nullable: true })\n @Field(type => ScalarObject, { nullable: true, description: 'Additional attributes associated with the domain.' })\n attributes?: any\n\n @Field({ nullable: true, description: 'The date and time when the domain was created.' })\n @CreateDateColumn()\n createdAt: Date\n\n @Field({ nullable: true, description: 'The date and time when the domain was last updated.' })\n @UpdateDateColumn()\n updatedAt: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'The date and time when the domain was deleted, if applicable.' })\n deletedAt?: Date\n}\n"]}
@@ -46,7 +46,12 @@ let EnvVarMutation = class EnvVarMutation {
46
46
  if (_updateRecords.length > 0) {
47
47
  for (let i = 0; i < _updateRecords.length; i++) {
48
48
  const updateRecord = _updateRecords[i];
49
- const envVar = await envVarRepo.findOneBy({ id: updateRecord.id });
49
+ const envVar = await envVarRepo.findOne({
50
+ where: { domain: { id: domain.id }, id: updateRecord.id }
51
+ });
52
+ if (!envVar) {
53
+ throw new Error(`failed to find envVar to update: ${updateRecord.id}`);
54
+ }
50
55
  const result = await envVarRepo.save({
51
56
  ...envVar,
52
57
  ...updateRecord
@@ -1 +1 @@
1
- {"version":3,"file":"env-var-mutation.js","sourceRoot":"","sources":["../../../server/service/env-var/env-var-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,gEAA8D;AA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Ac;IAD1B,IAAA,uBAAQ,EAAC,gBAAM,CAAC;GACJ,cAAc,CAuG1B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { getRepository } from '../../initializers/database.js'\nimport { In } from 'typeorm'\n\nimport { EnvVar } from './env-var'\nimport { NewEnvVar, EnvVarPatch } from './env-var-type'\n\n@Resolver(EnvVar)\nexport class EnvVarMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"env-var\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => EnvVar, { description: 'To create new EnvVar' })\n async createEnvVar(@Arg('envVar') envVar: NewEnvVar, @Ctx() context: any): Promise<EnvVar> {\n const { domain, user, tx } = context.state\n const repository = getRepository<EnvVar>(EnvVar, tx)\n\n return await repository.save({\n ...envVar,\n domain\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"env-var\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => EnvVar, { description: 'To modify EnvVar information' })\n async updateEnvVar(@Arg('id') id: string, @Arg('envVar') envVar: EnvVarPatch, @Ctx() context: any): Promise<EnvVar> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(EnvVar, tx)\n\n const existingEnvVar = await repository.findOne({\n where: { id, domain: { id: domain.id } }\n })\n\n if (!existingEnvVar) {\n throw new Error('Environment variable not found')\n }\n\n return await repository.save(existingEnvVar)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"env-var\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [EnvVar], { description: \"To modify multiple EnvVars' information\" })\n async updateMultipleEnvVars(\n @Arg('patches', type => [EnvVarPatch]) patches: EnvVarPatch[],\n @Ctx() context: any\n ): Promise<EnvVar[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const envVarRepo = tx.getRepository(EnvVar)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await envVarRepo.save({\n ...newRecord,\n domain\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const envVar = await envVarRepo.findOneBy({ id: updateRecord.id })\n\n const result = await envVarRepo.save({\n ...envVar,\n ...updateRecord\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"env-var\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete EnvVar' })\n async deleteEnvVar(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n const repository = getRepository(EnvVar, tx)\n\n const envVar = await repository.delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"env-var\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple EnvVars' })\n async deleteEnvVars(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(EnvVar).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"env-var-mutation.js","sourceRoot":"","sources":["../../../server/service/env-var/env-var-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,gEAA8D;AAC9D,qCAA4B;AAE5B,uCAAkC;AAClC,iDAAuD;AAGhD,IAAM,cAAc,GAApB,MAAM,cAAc;IAInB,AAAN,KAAK,CAAC,YAAY,CAAgB,MAAiB,EAAS,OAAY;QACtE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,UAA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EAAC,gBAAM,CAAC;GACJ,cAAc,CA6G1B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { getRepository } from '../../initializers/database.js'\nimport { In } from 'typeorm'\n\nimport { EnvVar } from './env-var'\nimport { NewEnvVar, EnvVarPatch } from './env-var-type'\n\n@Resolver(EnvVar)\nexport class EnvVarMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"env-var\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => EnvVar, { description: 'To create new EnvVar' })\n async createEnvVar(@Arg('envVar') envVar: NewEnvVar, @Ctx() context: any): Promise<EnvVar> {\n const { domain, user, tx } = context.state\n const repository = getRepository<EnvVar>(EnvVar, tx)\n\n return await repository.save({\n ...envVar,\n domain\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"env-var\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => EnvVar, { description: 'To modify EnvVar information' })\n async updateEnvVar(@Arg('id') id: string, @Arg('envVar') envVar: EnvVarPatch, @Ctx() context: any): Promise<EnvVar> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(EnvVar, tx)\n\n const existingEnvVar = await repository.findOne({\n where: { id, domain: { id: domain.id } }\n })\n\n if (!existingEnvVar) {\n throw new Error('Environment variable not found')\n }\n\n return await repository.save(existingEnvVar)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"env-var\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => [EnvVar], { description: \"To modify multiple EnvVars' information\" })\n async updateMultipleEnvVars(\n @Arg('patches', type => [EnvVarPatch]) patches: EnvVarPatch[],\n @Ctx() context: any\n ): Promise<EnvVar[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const envVarRepo = tx.getRepository(EnvVar)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await envVarRepo.save({\n ...newRecord,\n domain\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const envVar = await envVarRepo.findOne({\n where: { domain: { id: domain.id }, id: updateRecord.id }\n })\n\n if (!envVar) {\n throw new Error(`failed to find envVar to update: ${updateRecord.id}`)\n }\n\n const result = await envVarRepo.save({\n ...envVar,\n ...updateRecord\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"env-var\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete EnvVar' })\n async deleteEnvVar(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n const repository = getRepository(EnvVar, tx)\n\n const envVar = await repository.delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"env-var\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete multiple EnvVars' })\n async deleteEnvVars(@Arg('ids', type => [String]) ids: string[], @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(EnvVar).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n}\n"]}