@things-factory/shell 8.0.37 → 9.0.0-9.0.0-beta.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/_index.html +0 -1
  2. package/bin/things-factory-migration +6 -3
  3. package/client/themes/calendar-theme.css +3 -1
  4. package/client/themes/index.css +2 -1
  5. package/dist-server/index.d.ts +12 -12
  6. package/dist-server/index.js +12 -12
  7. package/dist-server/index.js.map +1 -1
  8. package/dist-server/initializers/database.js +4 -10
  9. package/dist-server/initializers/database.js.map +1 -1
  10. package/dist-server/initializers/ormconfig.d.ts +2 -0
  11. package/dist-server/initializers/ormconfig.js +30 -0
  12. package/dist-server/initializers/ormconfig.js.map +1 -0
  13. package/dist-server/middlewares/domain-middleware.js +2 -2
  14. package/dist-server/middlewares/domain-middleware.js.map +1 -1
  15. package/dist-server/middlewares/index.d.ts +1 -1
  16. package/dist-server/middlewares/index.js +3 -3
  17. package/dist-server/middlewares/index.js.map +1 -1
  18. package/dist-server/migrations/1000000000000-SeedDomain.js +4 -4
  19. package/dist-server/migrations/1000000000000-SeedDomain.js.map +1 -1
  20. package/dist-server/migrations/index.js.map +1 -1
  21. package/dist-server/process-cleaner.d.ts +1 -0
  22. package/dist-server/process-cleaner.js +92 -0
  23. package/dist-server/process-cleaner.js.map +1 -0
  24. package/dist-server/routers/domain-router.js +3 -3
  25. package/dist-server/routers/domain-router.js.map +1 -1
  26. package/dist-server/routers/global-router.js +6 -6
  27. package/dist-server/routers/global-router.js.map +1 -1
  28. package/dist-server/routers/index.d.ts +3 -3
  29. package/dist-server/routers/index.js +3 -3
  30. package/dist-server/routers/index.js.map +1 -1
  31. package/dist-server/schema.js +5 -4
  32. package/dist-server/schema.js.map +1 -1
  33. package/dist-server/server-dev.js +37 -39
  34. package/dist-server/server-dev.js.map +1 -1
  35. package/dist-server/server.js +34 -36
  36. package/dist-server/server.js.map +1 -1
  37. package/dist-server/service/attribute-set/attribute-set-item-type.js +3 -3
  38. package/dist-server/service/attribute-set/attribute-set-item-type.js.map +1 -1
  39. package/dist-server/service/attribute-set/attribute-set-mutation.d.ts +2 -2
  40. package/dist-server/service/attribute-set/attribute-set-mutation.js +16 -16
  41. package/dist-server/service/attribute-set/attribute-set-mutation.js.map +1 -1
  42. package/dist-server/service/attribute-set/attribute-set-query.d.ts +3 -3
  43. package/dist-server/service/attribute-set/attribute-set-query.js +15 -15
  44. package/dist-server/service/attribute-set/attribute-set-query.js.map +1 -1
  45. package/dist-server/service/attribute-set/attribute-set-type.d.ts +2 -2
  46. package/dist-server/service/attribute-set/attribute-set-type.js +5 -5
  47. package/dist-server/service/attribute-set/attribute-set-type.js.map +1 -1
  48. package/dist-server/service/attribute-set/attribute-set.d.ts +1 -1
  49. package/dist-server/service/attribute-set/attribute-set.js +2 -2
  50. package/dist-server/service/attribute-set/attribute-set.js.map +1 -1
  51. package/dist-server/service/attribute-set/index.d.ts +3 -3
  52. package/dist-server/service/attribute-set/index.js +5 -5
  53. package/dist-server/service/attribute-set/index.js.map +1 -1
  54. package/dist-server/service/common-types/index.d.ts +6 -6
  55. package/dist-server/service/common-types/index.js +6 -6
  56. package/dist-server/service/common-types/index.js.map +1 -1
  57. package/dist-server/service/common-types/list-param.js +2 -2
  58. package/dist-server/service/common-types/list-param.js.map +1 -1
  59. package/dist-server/service/common-types/log.js +2 -2
  60. package/dist-server/service/common-types/log.js.map +1 -1
  61. package/dist-server/service/common-types/scalar-object.d.ts +2 -1
  62. package/dist-server/service/common-types/scalar-object.js +2 -2
  63. package/dist-server/service/common-types/scalar-object.js.map +1 -1
  64. package/dist-server/service/directive-transaction/index.d.ts +1 -1
  65. package/dist-server/service/directive-transaction/index.js +1 -1
  66. package/dist-server/service/directive-transaction/index.js.map +1 -1
  67. package/dist-server/service/directive-transaction/transaction.js +2 -2
  68. package/dist-server/service/directive-transaction/transaction.js.map +1 -1
  69. package/dist-server/service/domain/domain-mutation.d.ts +2 -2
  70. package/dist-server/service/domain/domain-mutation.js +21 -21
  71. package/dist-server/service/domain/domain-mutation.js.map +1 -1
  72. package/dist-server/service/domain/domain-query.js +6 -6
  73. package/dist-server/service/domain/domain-query.js.map +1 -1
  74. package/dist-server/service/domain/domain-types.d.ts +2 -2
  75. package/dist-server/service/domain/domain-types.js +6 -6
  76. package/dist-server/service/domain/domain-types.js.map +1 -1
  77. package/dist-server/service/domain/index.d.ts +3 -3
  78. package/dist-server/service/domain/index.js +5 -5
  79. package/dist-server/service/domain/index.js.map +1 -1
  80. package/dist-server/service/index.d.ts +7 -7
  81. package/dist-server/service/index.js +16 -16
  82. package/dist-server/service/index.js.map +1 -1
  83. package/dist-server/service/subscription-data/data-resolver.d.ts +1 -1
  84. package/dist-server/service/subscription-data/data-resolver.js +4 -4
  85. package/dist-server/service/subscription-data/data-resolver.js.map +1 -1
  86. package/dist-server/service/subscription-data/data-types.d.ts +1 -1
  87. package/dist-server/service/subscription-data/data-types.js +5 -5
  88. package/dist-server/service/subscription-data/data-types.js.map +1 -1
  89. package/dist-server/service/subscription-data/index.d.ts +1 -1
  90. package/dist-server/service/subscription-data/index.js +2 -2
  91. package/dist-server/service/subscription-data/index.js.map +1 -1
  92. package/dist-server/tsconfig.tsbuildinfo +1 -1
  93. package/dist-server/typeorm/encrypt-transform.js +3 -3
  94. package/dist-server/typeorm/encrypt-transform.js.map +1 -1
  95. package/dist-server/utils/get-times-for-period.d.ts +24 -4
  96. package/dist-server/utils/get-times-for-period.js +42 -5
  97. package/dist-server/utils/get-times-for-period.js.map +1 -1
  98. package/dist-server/utils/index.d.ts +8 -8
  99. package/dist-server/utils/index.js +8 -8
  100. package/dist-server/utils/index.js.map +1 -1
  101. package/dist-server/utils/list-param-adjuster.d.ts +1 -1
  102. package/dist-server/utils/list-param-adjuster.js.map +1 -1
  103. package/dist-server/utils/list-params-converter.d.ts +2 -2
  104. package/dist-server/utils/list-params-converter.js +2 -2
  105. package/dist-server/utils/list-params-converter.js.map +1 -1
  106. package/dist-server/utils/list-query-builder.d.ts +1 -1
  107. package/dist-server/utils/list-query-builder.js +7 -7
  108. package/dist-server/utils/list-query-builder.js.map +1 -1
  109. package/dist-server/utils/publish-progress.js +2 -2
  110. package/dist-server/utils/publish-progress.js.map +1 -1
  111. package/package.json +14 -19
  112. package/translations/en.json +2 -0
  113. package/translations/ja.json +2 -0
  114. package/translations/ko.json +3 -1
  115. package/translations/ms.json +2 -0
  116. package/translations/zh.json +2 -0
  117. package/views/public/home.html +0 -1
  118. package/client/hot-client/hot.js +0 -140
  119. package/client/hot-client/index.js +0 -103
  120. package/client/hot-client/log.js +0 -44
  121. package/client/hot-client/socket.js +0 -63
  122. package/client/scene/scene-components.js +0 -3
  123. package/client/scene/scene-player.js +0 -103
  124. package/client/scene/scene-viewer.js +0 -106
  125. package/client/scene/things-scene-components.import +0 -1
  126. package/ormconfig.js +0 -31
  127. package/server/graphql-local-client.ts +0 -59
  128. package/server/index.ts +0 -13
  129. package/server/initializers/database.ts +0 -96
  130. package/server/initializers/naming-strategy.ts +0 -14
  131. package/server/middlewares/domain-middleware.ts +0 -60
  132. package/server/middlewares/index.ts +0 -43
  133. package/server/migrations/1000000000000-SeedDomain.ts +0 -37
  134. package/server/migrations/index.ts +0 -9
  135. package/server/pubsub-log-transport.ts +0 -59
  136. package/server/pubsub.ts +0 -84
  137. package/server/routers/domain-router.ts +0 -13
  138. package/server/routers/global-router.ts +0 -76
  139. package/server/routers/graphql-router.ts +0 -3
  140. package/server/routers/index.ts +0 -3
  141. package/server/schema.ts +0 -163
  142. package/server/server-dev.ts +0 -305
  143. package/server/server.ts +0 -296
  144. package/server/service/attribute-set/attribute-set-item-type.ts +0 -65
  145. package/server/service/attribute-set/attribute-set-mutation.ts +0 -125
  146. package/server/service/attribute-set/attribute-set-query.ts +0 -36
  147. package/server/service/attribute-set/attribute-set-type.ts +0 -46
  148. package/server/service/attribute-set/attribute-set.ts +0 -35
  149. package/server/service/attribute-set/index.ts +0 -6
  150. package/server/service/common-types/index.ts +0 -6
  151. package/server/service/common-types/list-param.ts +0 -61
  152. package/server/service/common-types/log.ts +0 -17
  153. package/server/service/common-types/object-ref.ts +0 -13
  154. package/server/service/common-types/scalar-any.ts +0 -44
  155. package/server/service/common-types/scalar-date.ts +0 -22
  156. package/server/service/common-types/scalar-object.ts +0 -15
  157. package/server/service/directive-transaction/index.ts +0 -1
  158. package/server/service/directive-transaction/transaction.ts +0 -40
  159. package/server/service/domain/domain-mutation.ts +0 -120
  160. package/server/service/domain/domain-query.ts +0 -55
  161. package/server/service/domain/domain-types.ts +0 -69
  162. package/server/service/domain/domain.ts +0 -112
  163. package/server/service/domain/index.ts +0 -6
  164. package/server/service/index.ts +0 -32
  165. package/server/service/subscription-data/data-resolver.ts +0 -37
  166. package/server/service/subscription-data/data-types.ts +0 -16
  167. package/server/service/subscription-data/index.ts +0 -4
  168. package/server/typeorm/encrypt-transform.ts +0 -70
  169. package/server/typeorm/get-data-encryption-key.ts +0 -13
  170. package/server/typeorm/json5-transform.ts +0 -26
  171. package/server/typeorm/round-transform.ts +0 -20
  172. package/server/utils/condition-builder.ts +0 -145
  173. package/server/utils/get-domain.ts +0 -228
  174. package/server/utils/get-query-builder-from-list-params.ts +0 -469
  175. package/server/utils/get-times-for-period.ts +0 -60
  176. package/server/utils/index.ts +0 -8
  177. package/server/utils/list-param-adjuster.ts +0 -21
  178. package/server/utils/list-params-converter.ts +0 -200
  179. package/server/utils/list-query-builder.ts +0 -120
  180. package/server/utils/publish-progress.ts +0 -23
@@ -7,8 +7,7 @@ const graphql_scalars_1 = require("graphql-scalars");
7
7
  const schema_1 = require("@graphql-tools/schema");
8
8
  const env_1 = require("@things-factory/env");
9
9
  const utils_1 = require("@things-factory/utils");
10
- const pubsub_1 = require("./pubsub");
11
- const path = require('path');
10
+ const pubsub_js_1 = require("./pubsub.js");
12
11
  /**
13
12
  * Generates and returns a GraphQL schema by merging schemas and resolvers from various modules.
14
13
  * @returns {GraphQLSchema} The merged GraphQL schema.
@@ -51,7 +50,9 @@ async function schema() {
51
50
  const defs = {
52
51
  query: queries.length > 0 ? ['type Query {', ...queries, '}'].join('\n') : 'type Query { _ : Boolean }',
53
52
  mutation: mutations.length > 0 ? ['type Mutation {', ...mutations, '}'].join('\n') : 'type Mutation { _ : Boolean }',
54
- subscription: subscriptions.length > 0 ? ['type Subscription {', ...subscriptions, '}'].join('\n') : 'type Subscription { _ : Boolean }'
53
+ subscription: subscriptions.length > 0
54
+ ? ['type Subscription {', ...subscriptions, '}'].join('\n')
55
+ : 'type Subscription { _ : Boolean }'
55
56
  };
56
57
  typeDefs = [
57
58
  ...graphql_scalars_1.typeDefs,
@@ -99,7 +100,7 @@ async function schema() {
99
100
  var merged = (0, schema_1.mergeSchemas)({
100
101
  schemas: [
101
102
  await (0, type_graphql_1.buildSchema)({
102
- pubSub: pubsub_1.pubsub,
103
+ pubSub: pubsub_js_1.pubsub,
103
104
  resolvers: schemas.resolverClasses,
104
105
  // automatically create `schema.gql` file with schema definition
105
106
  // in project's working directory
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../server/schema.ts"],"names":[],"mappings":";;AAgBA,wBAkJC;AAjKD,sEAA+D;AAC/D,+CAA0C;AAC1C,qDAA0F;AAE1F,kDAAoD;AACpD,6CAAgE;AAChE,iDAAiD;AACjD,qCAAiC;AAEjC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAE5B;;;GAGG;AACI,KAAK,UAAU,MAAM;IAC1B,MAAM,OAAO,GAAG,wBAAkB;SAC/B,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAA,YAAM,EAAC,GAAG,CAAC,CAAC,MAAM,CAAC;SAC9B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC;SACxB,MAAM,CACL,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACd,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,GAAG,CAA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AAI,SAAS,GAAG,SAAS,CAAC,SAAS,IAAI,EAAE,CAAA;IAEzC,OAAO,SAAS,CAAC,KAAK,CAAA;IACtB,OAAO,SAAS,CAAC,QAAQ,CAAA;IACzB,OAAO,SAAS,CAAC,YAAY,CAAA;IAC7B,OAAO,SAAS,CAAC,SAAS,CAAA;IAE1B,SAAS,iCACP,MAAM,EAAE,gCAAoB,EAC5B,KAAK,EAAE,IAAA,iBAAS,EAAC,KAAK,EAAE,cAAc,CAAC,EACvC,QAAQ,EAAE,IAAA,iBAAS,EAAC,QAAQ,EAAE,iBAAiB,CAAC,EAChD,YAAY,EAAE,IAAA,iBAAS,EAAC,YAAY,EAAE,qBAAqB,CAAC,IACzD,2BAAe,GACf,SAAS,CACb,CAAA;IAED,IAAI,MAAM,GAAG,IAAA,qBAAY,EAAC;QACxB,OAAO,EAAE;YACP,MAAM,IAAA,0BAAW,EAAC;gBAChB,MAAM,EAAE,eAAM;gBACd,SAAS,EAAE,OAAO,CAAC,eAAe;gBAClC,gEAAgE;gBAChE,iCAAiC;gBACjC,kDAAkD;gBAClD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa;gBACrD,4EAA4E;aAC7E,CAAC;SACH;QACD,QAAQ;QACR,SAAS;KACV,CAAC,CAAA;IAEF,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,SAAwC,EAAE,EAAE;QACjF,MAAM,GAAG,SAAS,CAAC,MAAM,CAAQ,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { GraphQLSchema } from 'graphql'\nimport { GraphQLUpload } from 'graphql-upload/GraphQLUpload.js'\nimport { buildSchema } from 'type-graphql'\nimport { typeDefs as scalarTypeDefs, resolvers as scalarResolvers } from 'graphql-scalars'\n\nimport { mergeSchemas } from '@graphql-tools/schema'\nimport { loader, orderedModuleNames } from '@things-factory/env'\nimport { deepMerge } from '@things-factory/utils'\nimport { pubsub } from './pubsub'\n\nconst path = require('path')\n\n/**\n * Generates and returns a GraphQL schema by merging schemas and resolvers from various modules.\n * @returns {GraphQLSchema} The merged GraphQL schema.\n */\nexport async function schema() {\n const schemas = orderedModuleNames\n .map(dep => loader(dep).schema)\n .filter(schema => schema)\n .reduce(\n (sum, schema) => {\n const { typeDefs, resolvers, resolverClasses, directives } = sum\n let { typeDefs: sTypeDefs = {}, resolvers: sResolvers = {}, resolverClasses: sResolverClasses = [], directives: sDirectives = {} } = schema\n\n return {\n typeDefs: deepMerge(typeDefs, sTypeDefs),\n resolvers: deepMerge(resolvers, sResolvers),\n resolverClasses: [...resolverClasses, ...(sResolverClasses || [])],\n directives: deepMerge(directives, sDirectives)\n }\n },\n {\n typeDefs: {},\n resolvers: {},\n resolverClasses: [],\n directives: {}\n }\n )\n\n /* for typeDefs */\n var typeDefs = schemas.typeDefs\n var { queries = [], mutations = [], subscriptions = [], directives = [], types = [] } = typeDefs\n\n queries = [...queries, ...(typeDefs.Query || [])]\n mutations = [...mutations, ...(typeDefs.Mutation || [])]\n subscriptions = [...subscriptions, ...(typeDefs.Subscription || [])]\n directives = [...directives, ...(typeDefs.Directive || [])]\n\n delete typeDefs.Query\n delete typeDefs.Mutation\n delete typeDefs.Subscription\n delete typeDefs.Directive\n\n delete typeDefs.queries\n delete typeDefs.mutations\n delete typeDefs.subscriptions\n delete typeDefs.directives\n delete typeDefs.types\n\n const defs = {\n query: queries.length > 0 ? ['type Query {', ...queries, '}'].join('\\n') : 'type Query { _ : Boolean }',\n mutation: mutations.length > 0 ? ['type Mutation {', ...mutations, '}'].join('\\n') : 'type Mutation { _ : Boolean }',\n subscription: subscriptions.length > 0 ? ['type Subscription {', ...subscriptions, '}'].join('\\n') : 'type Subscription { _ : Boolean }'\n }\n\n typeDefs = [\n ...scalarTypeDefs,\n `\n scalar Upload\n `,\n defs.query,\n defs.mutation,\n defs.subscription,\n ...directives,\n ...types,\n ...Object.values(typeDefs)\n ].filter(type => !!type)\n\n /* for resolvers */\n var { resolvers } = schemas\n var { queries = [], mutations = [], subscriptions = [], directives = [] } = resolvers\n\n var queryResolvers =\n queries.length > 0 &&\n queries.reduce((sum, query) => {\n return {\n ...sum,\n ...query\n }\n }, {})\n\n var mutationResolvers =\n mutations.length > 0 &&\n mutations.reduce((sum, mutation) => {\n return {\n ...sum,\n ...mutation\n }\n }, {})\n\n var subscriptionResolvers =\n subscriptions.length > 0 &&\n subscriptions.reduce((sum, subscription) => {\n return {\n ...sum,\n ...subscription\n }\n }, {})\n\n var directiveResolvers = directives.reduce((sum, directive) => {\n return {\n ...sum,\n ...directive\n }\n }, {})\n\n delete resolvers.queries\n delete resolvers.mutations\n delete resolvers.subscriptions\n delete resolvers.directives\n\n var Query = resolvers.Query || {}\n var Mutation = resolvers.Mutation || {}\n var Subscription = resolvers.Subscription || {}\n var Directive = resolvers.Directive || {}\n\n delete resolvers.Query\n delete resolvers.Mutation\n delete resolvers.Subscription\n delete resolvers.Directive\n\n resolvers = {\n Upload: GraphQLUpload as any,\n Query: deepMerge(Query, queryResolvers),\n Mutation: deepMerge(Mutation, mutationResolvers),\n Subscription: deepMerge(Subscription, subscriptionResolvers),\n ...scalarResolvers,\n ...resolvers\n }\n\n var merged = mergeSchemas({\n schemas: [\n await buildSchema({\n pubSub: pubsub,\n resolvers: schemas.resolverClasses,\n // automatically create `schema.gql` file with schema definition\n // in project's working directory\n // or create the file with schema in selected path\n emitSchemaFile: process.env.NODE_ENV == 'development'\n // emitSchemaFile: path.resolve(__dirname, 'snapshots/schema', 'schema.gql')\n })\n ],\n typeDefs,\n resolvers\n })\n\n Object.values(schemas.directives).map((directive: (schema: GraphQLSchema) => {}) => {\n merged = directive(merged) as any\n })\n\n return merged\n}\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../server/schema.ts"],"names":[],"mappings":";;AAcA,wBA2JC;AAxKD,sEAA+D;AAC/D,+CAA0C;AAC1C,qDAA0F;A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,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,SAAwC,EAAE,EAAE;QACjF,MAAM,GAAG,SAAS,CAAC,MAAM,CAAQ,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { GraphQLSchema } from 'graphql'\nimport { GraphQLUpload } from 'graphql-upload/GraphQLUpload.js'\nimport { buildSchema } from 'type-graphql'\nimport { typeDefs as scalarTypeDefs, resolvers as scalarResolvers } from 'graphql-scalars'\n\nimport { mergeSchemas } from '@graphql-tools/schema'\nimport { loader, orderedModuleNames } from '@things-factory/env'\nimport { deepMerge } from '@things-factory/utils'\nimport { pubsub } from './pubsub.js'\n\n/**\n * Generates and returns a GraphQL schema by merging schemas and resolvers from various modules.\n * @returns {GraphQLSchema} The merged GraphQL schema.\n */\nexport async function schema() {\n const schemas = orderedModuleNames\n .map(dep => loader(dep).schema)\n .filter(schema => schema)\n .reduce(\n (sum, schema) => {\n const { typeDefs, resolvers, resolverClasses, directives } = sum\n let {\n typeDefs: sTypeDefs = {},\n resolvers: sResolvers = {},\n resolverClasses: sResolverClasses = [],\n directives: sDirectives = {}\n } = schema\n\n return {\n typeDefs: deepMerge(typeDefs, sTypeDefs),\n resolvers: deepMerge(resolvers, sResolvers),\n resolverClasses: [...resolverClasses, ...(sResolverClasses || [])],\n directives: deepMerge(directives, sDirectives)\n }\n },\n {\n typeDefs: {},\n resolvers: {},\n resolverClasses: [],\n directives: {}\n }\n )\n\n /* for typeDefs */\n var typeDefs = schemas.typeDefs\n var { queries = [], mutations = [], subscriptions = [], directives = [], types = [] } = typeDefs\n\n queries = [...queries, ...(typeDefs.Query || [])]\n mutations = [...mutations, ...(typeDefs.Mutation || [])]\n subscriptions = [...subscriptions, ...(typeDefs.Subscription || [])]\n directives = [...directives, ...(typeDefs.Directive || [])]\n\n delete typeDefs.Query\n delete typeDefs.Mutation\n delete typeDefs.Subscription\n delete typeDefs.Directive\n\n delete typeDefs.queries\n delete typeDefs.mutations\n delete typeDefs.subscriptions\n delete typeDefs.directives\n delete typeDefs.types\n\n const defs = {\n query: queries.length > 0 ? ['type Query {', ...queries, '}'].join('\\n') : 'type Query { _ : Boolean }',\n mutation:\n mutations.length > 0 ? ['type Mutation {', ...mutations, '}'].join('\\n') : 'type Mutation { _ : Boolean }',\n subscription:\n subscriptions.length > 0\n ? ['type Subscription {', ...subscriptions, '}'].join('\\n')\n : 'type Subscription { _ : Boolean }'\n }\n\n typeDefs = [\n ...scalarTypeDefs,\n `\n scalar Upload\n `,\n defs.query,\n defs.mutation,\n defs.subscription,\n ...directives,\n ...types,\n ...Object.values(typeDefs)\n ].filter(type => !!type)\n\n /* for resolvers */\n var { resolvers } = schemas\n var { queries = [], mutations = [], subscriptions = [], directives = [] } = resolvers\n\n var queryResolvers =\n queries.length > 0 &&\n queries.reduce((sum, query) => {\n return {\n ...sum,\n ...query\n }\n }, {})\n\n var mutationResolvers =\n mutations.length > 0 &&\n mutations.reduce((sum, mutation) => {\n return {\n ...sum,\n ...mutation\n }\n }, {})\n\n var subscriptionResolvers =\n subscriptions.length > 0 &&\n subscriptions.reduce((sum, subscription) => {\n return {\n ...sum,\n ...subscription\n }\n }, {})\n\n var directiveResolvers = directives.reduce((sum, directive) => {\n return {\n ...sum,\n ...directive\n }\n }, {})\n\n delete resolvers.queries\n delete resolvers.mutations\n delete resolvers.subscriptions\n delete resolvers.directives\n\n var Query = resolvers.Query || {}\n var Mutation = resolvers.Mutation || {}\n var Subscription = resolvers.Subscription || {}\n var Directive = resolvers.Directive || {}\n\n delete resolvers.Query\n delete resolvers.Mutation\n delete resolvers.Subscription\n delete resolvers.Directive\n\n resolvers = {\n Upload: GraphQLUpload as any,\n Query: deepMerge(Query, queryResolvers),\n Mutation: deepMerge(Mutation, mutationResolvers),\n Subscription: deepMerge(Subscription, subscriptionResolvers),\n ...scalarResolvers,\n ...resolvers\n }\n\n var merged = mergeSchemas({\n schemas: [\n await buildSchema({\n pubSub: pubsub,\n resolvers: schemas.resolverClasses,\n // automatically create `schema.gql` file with schema definition\n // in project's working directory\n // or create the file with schema in selected path\n emitSchemaFile: process.env.NODE_ENV == 'development'\n // emitSchemaFile: path.resolve(__dirname, 'snapshots/schema', 'schema.gql')\n })\n ],\n typeDefs,\n resolvers\n })\n\n Object.values(schemas.directives).map((directive: (schema: GraphQLSchema) => {}) => {\n merged = directive(merged) as any\n })\n\n return merged\n}\n"]}
@@ -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,25 +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 wdm = require('webpack-dev-middleware');
36
- process.on('uncaughtException', error => {
37
- env_1.logger.error('uncaughtException: ', error);
38
- //process.exit(1)
39
- });
40
- const args = require('args');
41
- args.option('port', 'The port on which the app will be running', env_1.config.get('port', 3000));
42
- 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.
43
41
  This option is just to prevent termination for reasons of not recognizing the 'inspect' option.`, env_1.config.get('inspect', ':9229'));
44
- args.option('webpack', 'webpack configuration file', env_1.config.get('webpack'));
45
- const flags = args.parse(process.argv);
46
- 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"));
47
45
  const webpackConfig = require(flags.webpack || '@things-factory/builder/webpack.config.dev.js');
48
- const compiler = webpack(webpackConfig);
46
+ const compiler = (0, webpack_1.default)(webpackConfig);
49
47
  const PORT = (process.env.PORT = flags.port);
50
48
  const requestBody = env_1.config.get('requestBody') || {};
51
49
  const bodyParserOption = {
@@ -61,7 +59,7 @@ const fileUploadOption = {
61
59
  (0, operato_license_checker_1.initLicense)(env_1.config.get('licenseKey'));
62
60
  /* bootstrap */
63
61
  const bootstrap = async () => {
64
- await (0, database_1.databaseInitializer)();
62
+ await (0, database_js_1.databaseInitializer)();
65
63
  const app = new koa_2.default();
66
64
  app.proxy = true;
67
65
  app.use((0, cors_1.default)({
@@ -87,7 +85,7 @@ const bootstrap = async () => {
87
85
  });
88
86
  var subscriptionMiddleware = [];
89
87
  process.emit('bootstrap-module-subscription', app, subscriptionMiddleware);
90
- const builtSchema = await (0, schema_1.schema)();
88
+ const builtSchema = await (0, schema_js_1.schema)();
91
89
  const httpServer = (0, http_1.createServer)(app.callback());
92
90
  const websocketServer = new ws_2.WebSocketServer({
93
91
  server: httpServer,
@@ -114,7 +112,7 @@ const bootstrap = async () => {
114
112
  var koacontext = await app.createContext(request, new http_2.default.ServerResponse(request));
115
113
  koacontext['state'] = {};
116
114
  /* in case connect error(like a authentication error) just throw exception */
117
- var middlewares = [middlewares_1.domainMiddleware, ...subscriptionMiddleware];
115
+ var middlewares = [domain_middleware_js_1.domainMiddleware, ...subscriptionMiddleware];
118
116
  const fn = co_1.default.wrap((0, koa_compose_1.default)(middlewares));
119
117
  await fn(koacontext);
120
118
  return (ctx['context'] = koacontext);
@@ -157,7 +155,7 @@ const bootstrap = async () => {
157
155
  cache: 'bounded'
158
156
  });
159
157
  await server.start();
160
- graphql_local_client_1.GraphqlLocalClient.init(builtSchema, app);
158
+ graphql_local_client_js_1.GraphqlLocalClient.init(builtSchema, app);
161
159
  env_1.orderedModuleNames.forEach(name => {
162
160
  const { initMiddlewares } = (0, env_1.loader)(name);
163
161
  initMiddlewares && initMiddlewares(app);
@@ -180,30 +178,30 @@ const bootstrap = async () => {
180
178
  const ssoMiddlewares = [];
181
179
  process.emit('bootstrap-collect-sso-middleware', null, ssoMiddlewares);
182
180
  app.ssoMiddlewares = ssoMiddlewares;
183
- process.emit('bootstrap-module-global-public-route', app, routers_1.globalPublicRouter);
184
- process.emit('bootstrap-module-global-private-route', app, routers_1.globalPrivateRouter);
185
- process.emit('bootstrap-module-domain-public-route', app, routers_1.domainPublicRouter);
186
- 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);
187
185
  app.use(operato_license_checker_1.checkValidity); /* Check the license after most of the context has been built */
188
186
  app
189
- .use(routers_1.globalPublicRouter.routes())
190
- .use(routers_1.globalPublicRouter.allowedMethods())
191
- .use(routers_1.globalPrivateRouter.routes())
192
- .use(routers_1.globalPrivateRouter.allowedMethods())
193
- .use(routers_1.domainPublicRouter.routes())
194
- .use(routers_1.domainPublicRouter.allowedMethods())
195
- .use(routers_1.domainPrivateRouter.routes())
196
- .use(routers_1.domainPrivateRouter.allowedMethods());
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());
197
195
  /* Graphql Upload's multipart/form-data handling affects the restful file upload feature, so it should be placed after the routers configuration. */
198
196
  app.use((0, graphqlUploadKoa_js_1.default)(fileUploadOption));
199
- routers_1.graphqlRouter.post('/graphql', (0, koa_1.koaMiddleware)(server, {
197
+ index_js_1.graphqlRouter.post('/graphql', (0, koa_1.koaMiddleware)(server, {
200
198
  context: async ({ ctx }) => ctx
201
199
  }));
202
- app.use(routers_1.graphqlRouter.routes());
203
- app.use(routers_1.graphqlRouter.allowedMethods());
200
+ app.use(index_js_1.graphqlRouter.routes());
201
+ app.use(index_js_1.graphqlRouter.allowedMethods());
204
202
  /* should follow this order : history-fallback => webpack-middleware */
205
203
  app.use((0, koa2_connect_history_api_fallback_1.historyApiFallback)({ whiteList: [] }));
206
- app.use(wdm.koaWrapper(compiler, {
204
+ app.use(webpack_dev_middleware_1.default.koaWrapper(compiler, {
207
205
  publicPath: webpackConfig.output.publicPath
208
206
  }));
209
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,MAAM,GAAG,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAA;AAE7C,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,KAAK,CAAC,EAAE;IACtC,YAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAA;IAE1C,iBAAiB;AACnB,CAAC,CAAC,CAAA;AAEF,MAAM,IAAI,GAAG,OAAO,CAAC,M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GAAG,CAAC,GAAG,CAAC,uBAAa,CAAC,MAAM,EAAE,CAAC,CAAA;IAC/B,GAAG,CAAC,GAAG,CAAC,uBAAa,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,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'\nconst wdm = require('webpack-dev-middleware')\n\nprocess.on('uncaughtException', error => {\n logger.error('uncaughtException: ', error)\n\n //process.exit(1)\n})\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;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J;IACpJ,GAAG,CAAC,GAAG,CAAC,IAAA,6BAAgB,EAAC,gBAAgB,CAAC,CAAC,CAAA;IAE3C,wBAAa,CAAC,IAAI,CAChB,UAAU,EACV,IAAA,mBAAa,EAAC,MAAM,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,23 +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
- process.on('uncaughtException', error => {
37
- env_1.logger.error('uncaughtException: ', error);
38
- //process.exit(1)
39
- });
40
- const args = require('args');
41
- args.option('port', 'The port on which the app will be running', env_1.config.get('port', 3000));
42
- const flags = args.parse(process.argv);
43
- 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);
44
42
  const PORT = (process.env.PORT = flags.port);
45
43
  const requestBody = env_1.config.get('requestBody') || {};
46
44
  const bodyParserOption = {
@@ -56,7 +54,7 @@ const fileUploadOption = {
56
54
  (0, operato_license_checker_1.initLicense)(env_1.config.get('licenseKey'));
57
55
  /* bootstrap */
58
56
  const bootstrap = async () => {
59
- await (0, database_1.databaseInitializer)();
57
+ await (0, database_js_1.databaseInitializer)();
60
58
  const app = new koa_2.default();
61
59
  app.proxy = true;
62
60
  app.use((0, cors_1.default)({
@@ -82,7 +80,7 @@ const bootstrap = async () => {
82
80
  });
83
81
  var subscriptionMiddleware = [];
84
82
  process.emit('bootstrap-module-subscription', app, subscriptionMiddleware);
85
- const builtSchema = await (0, schema_1.schema)();
83
+ const builtSchema = await (0, schema_js_1.schema)();
86
84
  const httpServer = (0, http_1.createServer)(app.callback());
87
85
  const websocketServer = new ws_2.WebSocketServer({
88
86
  server: httpServer,
@@ -109,7 +107,7 @@ const bootstrap = async () => {
109
107
  var koacontext = await app.createContext(request, new http_2.default.ServerResponse(request));
110
108
  koacontext['state'] = {};
111
109
  /* in case connect error(like a authentication error) just throw exception */
112
- var middlewares = [middlewares_1.domainMiddleware, ...subscriptionMiddleware];
110
+ var middlewares = [domain_middleware_js_1.domainMiddleware, ...subscriptionMiddleware];
113
111
  const fn = co_1.default.wrap((0, koa_compose_1.default)(middlewares));
114
112
  await fn(koacontext);
115
113
  return (ctx['context'] = koacontext);
@@ -127,7 +125,7 @@ const bootstrap = async () => {
127
125
  env_1.logger.error(error);
128
126
  return error;
129
127
  },
130
- introspection: true,
128
+ introspection: false,
131
129
  csrfPrevention: true,
132
130
  plugins: [
133
131
  // Proper shutdown for the HTTP server.
@@ -151,7 +149,7 @@ const bootstrap = async () => {
151
149
  cache: 'bounded'
152
150
  });
153
151
  await server.start();
154
- graphql_local_client_1.GraphqlLocalClient.init(builtSchema, app);
152
+ graphql_local_client_js_1.GraphqlLocalClient.init(builtSchema, app);
155
153
  env_1.orderedModuleNames.forEach(name => {
156
154
  const { initMiddlewares } = (0, env_1.loader)(name);
157
155
  initMiddlewares && initMiddlewares(app);
@@ -170,30 +168,30 @@ const bootstrap = async () => {
170
168
  const ssoMiddlewares = [];
171
169
  process.emit('bootstrap-collect-sso-middleware', null, ssoMiddlewares);
172
170
  app.ssoMiddlewares = ssoMiddlewares;
173
- process.emit('bootstrap-module-global-public-route', app, routers_1.globalPublicRouter);
174
- process.emit('bootstrap-module-global-private-route', app, routers_1.globalPrivateRouter);
175
- process.emit('bootstrap-module-domain-public-route', app, routers_1.domainPublicRouter);
176
- 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);
177
175
  app.use(operato_license_checker_1.checkValidity); /* Check the license after most of the context has been built */
178
176
  app
179
- .use(routers_1.globalPublicRouter.routes())
180
- .use(routers_1.globalPublicRouter.allowedMethods())
181
- .use(routers_1.globalPrivateRouter.routes())
182
- .use(routers_1.globalPrivateRouter.allowedMethods())
183
- .use(routers_1.domainPublicRouter.routes())
184
- .use(routers_1.domainPublicRouter.allowedMethods())
185
- .use(routers_1.domainPrivateRouter.routes())
186
- .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());
187
185
  /* Graphql Upload's multipart/form-data handling affects the restful file upload feature, so it should be placed after the routers configuration. */
188
186
  app.use((0, graphqlUploadKoa_js_1.default)(fileUploadOption));
189
- routers_1.graphqlRouter.post('/graphql', (0, koa_1.koaMiddleware)(server, {
187
+ index_js_1.graphqlRouter.post('/graphql', (0, koa_1.koaMiddleware)(server, {
190
188
  context: async ({ ctx }) => ctx
191
189
  }));
192
- app.use(routers_1.graphqlRouter.routes());
193
- app.use(routers_1.graphqlRouter.allowedMethods());
190
+ app.use(index_js_1.graphqlRouter.routes());
191
+ app.use(index_js_1.graphqlRouter.allowedMethods());
194
192
  /* should follow this order : history-fallback => koaStatic */
195
193
  app.use((0, koa2_connect_history_api_fallback_1.historyApiFallback)({ whiteList: [] }));
196
- 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'), {
197
195
  index: 'index.html'
198
196
  }));
199
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,+CA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CAAA;IAED,8EAA8E;IAC9E,mFAAmF;IACnF,2BAA2B;IAC3B,MAAM,gBAAgB,GAAG,YAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAA;IAE9D,gFAAgF;IAChF,0FAA0F;IAC1F,mFAAmF;IACnF,kFAAkF;IAClF,gFAAgF;IAChF,gCAAgC;IAChC,UAAU,CAAC,gBAAgB,GAAG,gBAAgB,IAAI,KAAK,CAAA;IAEvD,2EAA2E;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 */\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'\n\nprocess.on('uncaughtException', error => {\n logger.error('uncaughtException: ', error)\n\n //process.exit(1)\n})\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,2EAAy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GAAG,CACL,IAAA,oBAAS,EAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,EAAE;QAC9C,KAAK,EAAE,YAAY;KACpB,CAAC,CACH,CAAA;IAED,8EAA8E;IAC9E,mFAAmF;IACnF,2BAA2B;IAC3B,MAAM,gBAAgB,GAAG,YAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAA;IAE9D,gFAAgF;IAChF,0FAA0F;IAC1F,mFAAmF;IACnF,kFAAkF;IAClF,gFAAgF;IAChF,gCAAgC;IAChC,UAAU,CAAC,gBAAgB,GAAG,gBAAgB,IAAI,KAAK,CAAA;IAEvD,2EAA2E;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: false,\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,IAA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ADC,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,oB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AE,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>;