@lilaquadrat/studio 2.2.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 (238) hide show
  1. package/lib/helpers.d.ts +3 -0
  2. package/lib/helpers.js +11 -0
  3. package/lib/helpers.js.map +1 -0
  4. package/lib/interfaces.d.ts +33 -0
  5. package/lib/interfaces.js +13 -0
  6. package/lib/interfaces.js.map +1 -0
  7. package/lib/main.d.ts +15 -0
  8. package/lib/main.js +56 -0
  9. package/lib/main.js.map +1 -0
  10. package/lib/models.d.ts +13 -0
  11. package/lib/models.js +31 -0
  12. package/lib/models.js.map +1 -0
  13. package/lib/services.d.ts +9 -0
  14. package/lib/services.js +23 -0
  15. package/lib/services.js.map +1 -0
  16. package/lib/src/AzureBlobStorage.share.d.ts +17 -0
  17. package/lib/src/AzureBlobStorage.share.js +157 -0
  18. package/lib/src/AzureBlobStorage.share.js.map +1 -0
  19. package/lib/src/AzureFileStorage.share.d.ts +16 -0
  20. package/lib/src/AzureFileStorage.share.js +131 -0
  21. package/lib/src/AzureFileStorage.share.js.map +1 -0
  22. package/lib/src/Filesystem.share.d.ts +16 -0
  23. package/lib/src/Filesystem.share.js +87 -0
  24. package/lib/src/Filesystem.share.js.map +1 -0
  25. package/lib/src/Immutable.class.d.ts +45 -0
  26. package/lib/src/Immutable.class.js +164 -0
  27. package/lib/src/Immutable.class.js.map +1 -0
  28. package/lib/src/Mock.share.d.ts +15 -0
  29. package/lib/src/Mock.share.js +36 -0
  30. package/lib/src/Mock.share.js.map +1 -0
  31. package/lib/src/ShareClientFactory.class.d.ts +14 -0
  32. package/lib/src/ShareClientFactory.class.js +37 -0
  33. package/lib/src/ShareClientFactory.class.js.map +1 -0
  34. package/lib/src/aggegations/childData.aggregation.d.ts +194 -0
  35. package/lib/src/aggegations/childData.aggregation.js +102 -0
  36. package/lib/src/aggegations/childData.aggregation.js.map +1 -0
  37. package/lib/src/aggegations/partial.aggregation.d.ts +88 -0
  38. package/lib/src/aggegations/partial.aggregation.js +68 -0
  39. package/lib/src/aggegations/partial.aggregation.js.map +1 -0
  40. package/lib/src/aggegations/publishData.aggregation.d.ts +89 -0
  41. package/lib/src/aggegations/publishData.aggregation.js +79 -0
  42. package/lib/src/aggegations/publishData.aggregation.js.map +1 -0
  43. package/lib/src/aggegations/resultData.aggregation.d.ts +151 -0
  44. package/lib/src/aggegations/resultData.aggregation.js +124 -0
  45. package/lib/src/aggegations/resultData.aggregation.js.map +1 -0
  46. package/lib/src/classes/ControllerBase.class.d.ts +108 -0
  47. package/lib/src/classes/ControllerBase.class.js +280 -0
  48. package/lib/src/classes/ControllerBase.class.js.map +1 -0
  49. package/lib/src/classes/errors/History.error.d.ts +5 -0
  50. package/lib/src/classes/errors/History.error.js +11 -0
  51. package/lib/src/classes/errors/History.error.js.map +1 -0
  52. package/lib/src/classes/errors/Immutable.error.d.ts +5 -0
  53. package/lib/src/classes/errors/Immutable.error.js +11 -0
  54. package/lib/src/classes/errors/Immutable.error.js.map +1 -0
  55. package/lib/src/classes/models.class.d.ts +14 -0
  56. package/lib/src/classes/models.class.js +44 -0
  57. package/lib/src/classes/models.class.js.map +1 -0
  58. package/lib/src/classes/modelv2.class.d.ts +62 -0
  59. package/lib/src/classes/modelv2.class.js +136 -0
  60. package/lib/src/classes/modelv2.class.js.map +1 -0
  61. package/lib/src/classes/mongo.class.d.ts +22 -0
  62. package/lib/src/classes/mongo.class.js +80 -0
  63. package/lib/src/classes/mongo.class.js.map +1 -0
  64. package/lib/src/conf.class.d.ts +36 -0
  65. package/lib/src/conf.class.js +122 -0
  66. package/lib/src/conf.class.js.map +1 -0
  67. package/lib/src/docker-compose.class.d.ts +14 -0
  68. package/lib/src/docker-compose.class.js +87 -0
  69. package/lib/src/docker-compose.class.js.map +1 -0
  70. package/lib/src/domain.class.d.ts +25 -0
  71. package/lib/src/domain.class.js +98 -0
  72. package/lib/src/domain.class.js.map +1 -0
  73. package/lib/src/filterMergeModules.d.ts +3 -0
  74. package/lib/src/filterMergeModules.js +30 -0
  75. package/lib/src/filterMergeModules.js.map +1 -0
  76. package/lib/src/frontend/main.d.ts +2 -0
  77. package/lib/src/frontend/main.js +9 -0
  78. package/lib/src/frontend/main.js.map +1 -0
  79. package/lib/src/functions/respondCode.d.ts +3 -0
  80. package/lib/src/functions/respondCode.js +5 -0
  81. package/lib/src/functions/respondCode.js.map +1 -0
  82. package/lib/src/helpers/cleanObject.d.ts +5 -0
  83. package/lib/src/helpers/cleanObject.js +9 -0
  84. package/lib/src/helpers/cleanObject.js.map +1 -0
  85. package/lib/src/helpers/companyRights.d.ts +2 -0
  86. package/lib/src/helpers/companyRights.js +20 -0
  87. package/lib/src/helpers/companyRights.js.map +1 -0
  88. package/lib/src/helpers/hardCopy.d.ts +2 -0
  89. package/lib/src/helpers/hardCopy.js +5 -0
  90. package/lib/src/helpers/hardCopy.js.map +1 -0
  91. package/lib/src/helpers/helpers.export.d.ts +0 -0
  92. package/lib/src/helpers/helpers.export.js +1 -0
  93. package/lib/src/helpers/helpers.export.js.map +1 -0
  94. package/lib/src/interfaces/Action.interface.d.ts +1 -0
  95. package/lib/src/interfaces/Action.interface.js +3 -0
  96. package/lib/src/interfaces/Action.interface.js.map +1 -0
  97. package/lib/src/interfaces/AppPermissions.d.ts +7 -0
  98. package/lib/src/interfaces/AppPermissions.js +3 -0
  99. package/lib/src/interfaces/AppPermissions.js.map +1 -0
  100. package/lib/src/interfaces/BasicData.interface.d.ts +16 -0
  101. package/lib/src/interfaces/BasicData.interface.js +3 -0
  102. package/lib/src/interfaces/BasicData.interface.js.map +1 -0
  103. package/lib/src/interfaces/CallResponse.interface.d.ts +5 -0
  104. package/lib/src/interfaces/CallResponse.interface.js +3 -0
  105. package/lib/src/interfaces/CallResponse.interface.js.map +1 -0
  106. package/lib/src/interfaces/Contract.interface.d.ts +7 -0
  107. package/lib/src/interfaces/Contract.interface.js +3 -0
  108. package/lib/src/interfaces/Contract.interface.js.map +1 -0
  109. package/lib/src/interfaces/CreateResult.interface.d.ts +5 -0
  110. package/lib/src/interfaces/CreateResult.interface.js +3 -0
  111. package/lib/src/interfaces/CreateResult.interface.js.map +1 -0
  112. package/lib/src/interfaces/DataObject.interface.d.ts +11 -0
  113. package/lib/src/interfaces/DataObject.interface.js +3 -0
  114. package/lib/src/interfaces/DataObject.interface.js.map +1 -0
  115. package/lib/src/interfaces/DatabaseQuery.interface.d.ts +3 -0
  116. package/lib/src/interfaces/DatabaseQuery.interface.js +3 -0
  117. package/lib/src/interfaces/DatabaseQuery.interface.js.map +1 -0
  118. package/lib/src/interfaces/DatabaseQueryOptions.interface.d.ts +31 -0
  119. package/lib/src/interfaces/DatabaseQueryOptions.interface.js +3 -0
  120. package/lib/src/interfaces/DatabaseQueryOptions.interface.js.map +1 -0
  121. package/lib/src/interfaces/DatabaseQuerySites.interface.d.ts +11 -0
  122. package/lib/src/interfaces/DatabaseQuerySites.interface.js +3 -0
  123. package/lib/src/interfaces/DatabaseQuerySites.interface.js.map +1 -0
  124. package/lib/src/interfaces/DomainConf.interface.d.ts +10 -0
  125. package/lib/src/interfaces/DomainConf.interface.js +3 -0
  126. package/lib/src/interfaces/DomainConf.interface.js.map +1 -0
  127. package/lib/src/interfaces/EditorLegacy.interface.d.ts +5 -0
  128. package/lib/src/interfaces/EditorLegacy.interface.js +3 -0
  129. package/lib/src/interfaces/EditorLegacy.interface.js.map +1 -0
  130. package/lib/src/interfaces/HistoryReason.interface copy.d.ts +1 -0
  131. package/lib/src/interfaces/HistoryReason.interface copy.js +3 -0
  132. package/lib/src/interfaces/HistoryReason.interface copy.js.map +1 -0
  133. package/lib/src/interfaces/HistoryReason.interface.d.ts +1 -0
  134. package/lib/src/interfaces/HistoryReason.interface.js +3 -0
  135. package/lib/src/interfaces/HistoryReason.interface.js.map +1 -0
  136. package/lib/src/interfaces/HttpStatusCode.enum.d.ts +319 -0
  137. package/lib/src/interfaces/HttpStatusCode.enum.js +324 -0
  138. package/lib/src/interfaces/HttpStatusCode.enum.js.map +1 -0
  139. package/lib/src/interfaces/ListOfModels.interface.d.ts +5 -0
  140. package/lib/src/interfaces/ListOfModels.interface.js +3 -0
  141. package/lib/src/interfaces/ListOfModels.interface.js.map +1 -0
  142. package/lib/src/interfaces/Modelv2.interface.d.ts +3 -0
  143. package/lib/src/interfaces/Modelv2.interface.js +3 -0
  144. package/lib/src/interfaces/Modelv2.interface.js.map +1 -0
  145. package/lib/src/interfaces/ModuleGeneric.interface.d.ts +10 -0
  146. package/lib/src/interfaces/ModuleGeneric.interface.js +3 -0
  147. package/lib/src/interfaces/ModuleGeneric.interface.js.map +1 -0
  148. package/lib/src/interfaces/Partner.interface.d.ts +14 -0
  149. package/lib/src/interfaces/Partner.interface.js +3 -0
  150. package/lib/src/interfaces/Partner.interface.js.map +1 -0
  151. package/lib/src/interfaces/PublishResult.interface.d.ts +9 -0
  152. package/lib/src/interfaces/PublishResult.interface.js +3 -0
  153. package/lib/src/interfaces/PublishResult.interface.js.map +1 -0
  154. package/lib/src/interfaces/PublishResultStatistics.interface.d.ts +6 -0
  155. package/lib/src/interfaces/PublishResultStatistics.interface.js +3 -0
  156. package/lib/src/interfaces/PublishResultStatistics.interface.js.map +1 -0
  157. package/lib/src/interfaces/Scope.interface.d.ts +7 -0
  158. package/lib/src/interfaces/Scope.interface.js +3 -0
  159. package/lib/src/interfaces/Scope.interface.js.map +1 -0
  160. package/lib/src/interfaces/ShareClient.interface.d.ts +30 -0
  161. package/lib/src/interfaces/ShareClient.interface.js +3 -0
  162. package/lib/src/interfaces/ShareClient.interface.js.map +1 -0
  163. package/lib/src/interfaces/ShareClientOptions.interface.d.ts +5 -0
  164. package/lib/src/interfaces/ShareClientOptions.interface.js +3 -0
  165. package/lib/src/interfaces/ShareClientOptions.interface.js.map +1 -0
  166. package/lib/src/logger.d.ts +2 -0
  167. package/lib/src/logger.js +46 -0
  168. package/lib/src/logger.js.map +1 -0
  169. package/lib/src/models/certificate.model.d.ts +18 -0
  170. package/lib/src/models/certificate.model.js +42 -0
  171. package/lib/src/models/certificate.model.js.map +1 -0
  172. package/lib/src/models/company.model.d.ts +22 -0
  173. package/lib/src/models/company.model.js +63 -0
  174. package/lib/src/models/company.model.js.map +1 -0
  175. package/lib/src/models/editor.model.d.ts +27 -0
  176. package/lib/src/models/editor.model.js +122 -0
  177. package/lib/src/models/editor.model.js.map +1 -0
  178. package/lib/src/models/editorBase.model.d.ts +11 -0
  179. package/lib/src/models/editorBase.model.js +42 -0
  180. package/lib/src/models/editorBase.model.js.map +1 -0
  181. package/lib/src/models/history.model.d.ts +19 -0
  182. package/lib/src/models/history.model.js +46 -0
  183. package/lib/src/models/history.model.js.map +1 -0
  184. package/lib/src/models/id.model.d.ts +11 -0
  185. package/lib/src/models/id.model.js +21 -0
  186. package/lib/src/models/id.model.js.map +1 -0
  187. package/lib/src/models/me.model.d.ts +12 -0
  188. package/lib/src/models/me.model.js +35 -0
  189. package/lib/src/models/me.model.js.map +1 -0
  190. package/lib/src/models/media.model.d.ts +49 -0
  191. package/lib/src/models/media.model.js +123 -0
  192. package/lib/src/models/media.model.js.map +1 -0
  193. package/lib/src/models/permissions.model.d.ts +15 -0
  194. package/lib/src/models/permissions.model.js +163 -0
  195. package/lib/src/models/permissions.model.js.map +1 -0
  196. package/lib/src/models/project.model.d.ts +12 -0
  197. package/lib/src/models/project.model.js +46 -0
  198. package/lib/src/models/project.model.js.map +1 -0
  199. package/lib/src/models/publish.model.d.ts +23 -0
  200. package/lib/src/models/publish.model.js +180 -0
  201. package/lib/src/models/publish.model.js.map +1 -0
  202. package/lib/src/models/secrets.model.d.ts +14 -0
  203. package/lib/src/models/secrets.model.js +42 -0
  204. package/lib/src/models/secrets.model.js.map +1 -0
  205. package/lib/src/models/settings.model.d.ts +8 -0
  206. package/lib/src/models/settings.model.js +31 -0
  207. package/lib/src/models/settings.model.js.map +1 -0
  208. package/lib/src/nginx.class.d.ts +11 -0
  209. package/lib/src/nginx.class.js +49 -0
  210. package/lib/src/nginx.class.js.map +1 -0
  211. package/lib/src/services/editor.service.d.ts +23 -0
  212. package/lib/src/services/editor.service.js +175 -0
  213. package/lib/src/services/editor.service.js.map +1 -0
  214. package/lib/src/services/editorBase.service.d.ts +29 -0
  215. package/lib/src/services/editorBase.service.js +96 -0
  216. package/lib/src/services/editorBase.service.js.map +1 -0
  217. package/lib/src/services/handleFile.service.d.ts +10 -0
  218. package/lib/src/services/handleFile.service.js +48 -0
  219. package/lib/src/services/handleFile.service.js.map +1 -0
  220. package/lib/src/services/history.service.d.ts +26 -0
  221. package/lib/src/services/history.service.js +237 -0
  222. package/lib/src/services/history.service.js.map +1 -0
  223. package/lib/src/services/id.service.d.ts +6 -0
  224. package/lib/src/services/id.service.js +20 -0
  225. package/lib/src/services/id.service.js.map +1 -0
  226. package/lib/src/services/publish.service.d.ts +30 -0
  227. package/lib/src/services/publish.service.js +201 -0
  228. package/lib/src/services/publish.service.js.map +1 -0
  229. package/lib/src/services/secret.service.d.ts +24 -0
  230. package/lib/src/services/secret.service.js +50 -0
  231. package/lib/src/services/secret.service.js.map +1 -0
  232. package/lib/src/services/universal.service.d.ts +23 -0
  233. package/lib/src/services/universal.service.js +129 -0
  234. package/lib/src/services/universal.service.js.map +1 -0
  235. package/lib/src/ssl-challenge.class.d.ts +33 -0
  236. package/lib/src/ssl-challenge.class.js +63 -0
  237. package/lib/src/ssl-challenge.class.js.map +1 -0
  238. package/package.json +60 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const Immutable_class_1 = __importDefault(require("../Immutable.class"));
7
+ const models_1 = require("../../models");
8
+ const main_1 = require("../../main");
9
+ const services_1 = require("../../services");
10
+ class EditorBaseService extends Immutable_class_1.default {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.model = models_1.EditorBaseModel;
14
+ }
15
+ get shareClient() {
16
+ const shareClient = (0, main_1.ShareClientFactory)(process.env.STORAGE_TYPE, {
17
+ connectionString: process.env.STORAGE_HOSTED,
18
+ });
19
+ return shareClient;
20
+ }
21
+ /**
22
+ * creates basic CDN folders for this project
23
+ *
24
+ * @param {string} project
25
+ * @param {string} customer
26
+ * @returns
27
+ * @memberof ProjectClass
28
+ */
29
+ createBase(company, project) {
30
+ const { shareClient } = this;
31
+ /**
32
+ * create the project folder for the customer
33
+ */
34
+ return shareClient
35
+ .createFolder(company, project)
36
+ .then(() => shareClient.createFolder(`${company}/${project}`, 'editor'))
37
+ .then(() => shareClient.createFolder(`${company}/${project}`, 'upload'));
38
+ }
39
+ /** copy basic editor setup into the project */
40
+ copyBase(company, project, type, user, app) {
41
+ let files;
42
+ const filter = type === 'app' ? /(.(js|css|woff)|index\.html)$/i : /.(json|server\.html)$/i;
43
+ return this.shareClient
44
+ .list('lilaquadrat/base/editorBase/', filter)
45
+ .then((foundFiles) => {
46
+ files = foundFiles;
47
+ main_1.logger.info(`projects.create.${company}.${project}.files.copy`);
48
+ return this.shareClient.copy(files, 'lilaquadrat/base/editorBase', `${company}/${project}/editor`);
49
+ })
50
+ .then(() => this.upsertType(company, project, type, false, user, app));
51
+ }
52
+ single(company, project, type) {
53
+ return this.model.db.findOne({ company, project, type });
54
+ }
55
+ /**
56
+ * updates/adds new entry at editorBase to make update process possible
57
+ */
58
+ upsertType(company, project, type, custom, user, app) {
59
+ return this.immutableUpsert({ company, project, type }, {
60
+ company, project, type, date: new Date(), custom,
61
+ }, user, 'change', app);
62
+ }
63
+ async updateFiles(company, project, file, type, user, app, isBase = false) {
64
+ const folder = isBase ? 'editorBase' : 'editor';
65
+ if (type === 'app')
66
+ await services_1.HandleFileService.clean(company, project, folder);
67
+ return services_1.HandleFileService.add(company, project, file, folder)
68
+ .then(() => this.upsertType(company, project, type, !isBase, user, app));
69
+ }
70
+ syncFiles(company, project, user, app, isBase = false) {
71
+ return this.syncFilesType(company, project, 'app', user, app, isBase)
72
+ .then(() => this.syncFilesType(company, project, 'server', user, app, isBase));
73
+ }
74
+ async syncFilesType(company, project, type, user, app, isBase = false) {
75
+ if (type === 'app')
76
+ await services_1.HandleFileService.clean(company, project, isBase ? 'editorBase' : 'editor');
77
+ return this.copyBase(company, project, type, user, app)
78
+ .then(() => this.upsertType(company, project, type, false, user, app));
79
+ }
80
+ async updateAvailable(company, project, type) {
81
+ const companyBase = await this.model.db.findOne({ company, project, type });
82
+ const systemBase = await this.model.db.findOne({ company: 'lilaquadrat', project: 'base', type });
83
+ if (!systemBase)
84
+ return false;
85
+ if (!companyBase)
86
+ return true;
87
+ // if the used base is a customized, dont show an available update
88
+ if (companyBase.custom)
89
+ return false;
90
+ if (companyBase.date < systemBase.date)
91
+ return true;
92
+ return false;
93
+ }
94
+ }
95
+ exports.default = new EditorBaseService();
96
+ //# sourceMappingURL=editorBase.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorBase.service.js","sourceRoot":"","sources":["../../../src/services/editorBase.service.ts"],"names":[],"mappings":";;;;;AACA,yEAA2C;AAC3C,yCAA+C;AAC/C,qCAAwD;AACxD,6CAAmD;AAEnD,MAAM,iBAAkB,SAAQ,yBAAqB;IAArD;;QAEE,UAAK,GAAG,wBAAe,CAAC;IA8H1B,CAAC;IA5HC,IAAI,WAAW;QAEb,MAAM,WAAW,GAAG,IAAA,yBAAkB,EAAC,OAAO,CAAC,GAAG,CAAC,YAAsB,EAAE;YACzE,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,cAAwB;SACvD,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC;IAErB,CAAC;IAED;;;;;;;OAOG;IACH,UAAU,CAAC,OAAe,EAAE,OAAe;QAEzC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;QAE7B;;aAEK;QACL,OAAO,WAAW;aACf,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC;aAC9B,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC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AK;QAErH,IAAI,IAAI,KAAK,KAAK;YAAE,MAAM,4BAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAEtG,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC;aACpD,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAE3E,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,OAAe,EAAE,IAAsB;QAE5E,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QAElG,IAAI,CAAC,UAAU;YAAE,OAAO,KAAK,CAAC;QAC9B,IAAI,CAAC,WAAW;YAAE,OAAO,IAAI,CAAC;QAE9B,kEAAkE;QAClE,IAAI,WAAW,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAErC,IAAI,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAEpD,OAAO,KAAK,CAAC;IAEf,CAAC;CAEF;AACD,kBAAe,IAAI,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ import { ShareClientInterface } from '../../interfaces';
3
+ export declare class HandleFileService {
4
+ client: ShareClientInterface;
5
+ constructor();
6
+ clean(company: string, project: string, folder?: string): Promise<boolean[]>;
7
+ add(company: string, project: string, data: Buffer, folder?: string): Promise<unknown>;
8
+ }
9
+ declare const _default: HandleFileService;
10
+ export default _default;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HandleFileService = void 0;
7
+ const unzipper_1 = __importDefault(require("unzipper"));
8
+ const stream_1 = require("stream");
9
+ const mime_types_1 = __importDefault(require("mime-types"));
10
+ const main_1 = require("../../main");
11
+ class HandleFileService {
12
+ constructor() {
13
+ const connectionString = `https://${process.env.STORAGE_BLOB_NAME}.blob.core.windows.net?${process.env.STORAGE_BLOB_SAS}`;
14
+ this.client = (0, main_1.ShareClientFactory)('azureBlob', { connectionString, shareName: 'main' });
15
+ }
16
+ clean(company, project, folder = 'editor') {
17
+ return this.client.list(`${company}/${project}/${folder}`, /.(js|css|woff)$/i)
18
+ .then((files) => {
19
+ const cleanArray = [];
20
+ files.forEach((file) => {
21
+ cleanArray.push(this.client.remove(`${company}/${project}/${folder}`, file));
22
+ });
23
+ return Promise.all(cleanArray);
24
+ });
25
+ }
26
+ add(company, project, data, folder = 'editor') {
27
+ return new Promise((resolve, reject) => {
28
+ const readable = new stream_1.Readable();
29
+ readable.push(data);
30
+ readable.push(null);
31
+ readable
32
+ .pipe(unzipper_1.default.Parse())
33
+ .on('entry', async (entry) => {
34
+ if (entry.type === 'Directory')
35
+ return entry.autodrain();
36
+ return this.client.create(`${company}/${project}/${folder}`, entry.path, await entry.buffer(), mime_types_1.default.lookup(entry.path))
37
+ .then(() => entry.autodrain())
38
+ .catch(() => entry.autodrain());
39
+ })
40
+ .on('close', () => {
41
+ resolve(true);
42
+ });
43
+ });
44
+ }
45
+ }
46
+ exports.HandleFileService = HandleFileService;
47
+ exports.default = new HandleFileService();
48
+ //# sourceMappingURL=handleFile.service.js.map
@@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AAC,CAAC;YACpB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEpB,QAAQ;iBACL,IAAI,CAAC,kBAAQ,CAAC,KAAK,EAAE,CAAC;iBACtB,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,KAAY,EAAE,EAAE;gBAElC,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;oBAAE,OAAO,KAAK,CAAC,SAAS,EAAE,CAAC;gBAEzD,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,IAAI,OAAO,IAAI,MAAM,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,EAAE,oBAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAW,CAAC;qBAC9H,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;qBAC7B,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;YAEpC,CAAC,CAAC;iBACD,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBAEhB,OAAO,CAAC,IAAI,CAAC,CAAC;YAEhB,CAAC,CAAC,CAAC;QAEP,CAAC,CAAC,CAAC;IAEL,CAAC;CAEF;AA5DD,8CA4DC;AACD,kBAAe,IAAI,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { Filter, ObjectId, OrderedBulkOperation, UnorderedBulkOperation } from 'mongodb';
2
+ import { BasicDataInterface, HistoryReason, History } from '../../interfaces';
3
+ declare class HistoryService {
4
+ model: import("../classes/modelv2.class").default<History>;
5
+ create<T extends BasicDataInterface>(data: T, user: string, reason: HistoryReason, app: string, modelName: string): Promise<any>;
6
+ create<T extends BasicDataInterface>(data: T, user: string, reason: HistoryReason, app: string, modelName: string, additionalHistoryData?: Record<string, string | number>): Promise<any>;
7
+ create<T extends BasicDataInterface>(data: T, user: string, reason: HistoryReason, app: string, modelName: string, additionalHistoryData?: Record<string, string | number> | undefined, bulk?: UnorderedBulkOperation | OrderedBulkOperation): UnorderedBulkOperation | OrderedBulkOperation;
8
+ list(company: string, project: string | undefined, id?: string | ObjectId, reason?: HistoryReason, model?: string, app?: string, sort?: number, limit?: number, skip?: number): Promise<{
9
+ all: number;
10
+ data: import("bson").Document[];
11
+ count: number;
12
+ }>;
13
+ singleList(company: string, project: string | undefined, internalId: ObjectId, reason?: HistoryReason, model?: string, app?: string, sort?: number, limit?: number, skip?: number): Promise<{
14
+ all: number;
15
+ data: import("bson").Document[];
16
+ count: number;
17
+ }>;
18
+ single(company: string, project: string | undefined, id: string, version: number): Promise<import("bson").Document>;
19
+ internal(company: string, project: string | undefined, id: ObjectId): Promise<import("bson").Document>;
20
+ createQuery(company: string, project: string | undefined, idorInernalId: string | ObjectId | undefined, reason?: HistoryReason, model?: string, app?: string, projection?: boolean, sort?: number, limit?: number, skip?: number): {
21
+ countQuery: Filter<History>;
22
+ aggregation: any[];
23
+ };
24
+ }
25
+ declare const _default: HistoryService;
26
+ export default _default;
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /* eslint-disable promise/no-callback-in-promise */
7
+ const mongodb_1 = require("mongodb");
8
+ const models_1 = require("../../models");
9
+ const History_error_1 = __importDefault(require("../classes/errors/History.error"));
10
+ class HistoryService {
11
+ constructor() {
12
+ this.model = models_1.HistoryModel;
13
+ }
14
+ create(data, user, reason, app, modelName, additionalHistoryData, bulk) {
15
+ var _a, _b, _c;
16
+ const immutable = Object.assign(Object.assign({}, data), { _id: new mongodb_1.ObjectId(), history: {
17
+ version: (_a = data.history) === null || _a === void 0 ? void 0 : _a.version,
18
+ source: (_b = data.history) === null || _b === void 0 ? void 0 : _b.source,
19
+ parent: data._id,
20
+ date: new Date(),
21
+ user,
22
+ reason,
23
+ app,
24
+ model: modelName,
25
+ } });
26
+ if (additionalHistoryData) {
27
+ immutable.history.additional = (_c = data.history) === null || _c === void 0 ? void 0 : _c.additional;
28
+ }
29
+ if (!this.model.validate(immutable)) {
30
+ throw new History_error_1.default('VALIDATION_FAILED', this.model.errors);
31
+ }
32
+ return bulk
33
+ ? bulk.insert(immutable)
34
+ : this.model.db.insertOne(immutable);
35
+ }
36
+ async list(company, project, id, reason, model, app, sort, limit, skip) {
37
+ const queries = this.createQuery(company, project, id, reason, model, app, true, sort, limit, skip);
38
+ const all = await this.model.db.countDocuments(queries.countQuery);
39
+ const data = await this.model.db.aggregate(queries.aggregation)
40
+ .toArray();
41
+ return { all, data, count: data.length };
42
+ }
43
+ async singleList(company, project, internalId, reason, model, app, sort, limit, skip) {
44
+ const queries = this.createQuery(company, project, internalId, reason, model, app, true, sort, limit, skip);
45
+ const all = await this.model.db.countDocuments(queries.countQuery);
46
+ const data = await this.model.db.aggregate(queries.aggregation)
47
+ .toArray();
48
+ return { all, data, count: data.length };
49
+ }
50
+ async single(company, project, id, version) {
51
+ const aggregation = [{
52
+ $match: {
53
+ $and: [
54
+ { $expr: { $eq: ['$company', company] } },
55
+ { $expr: { $eq: ['$project', project] } },
56
+ { $expr: { $eq: ['$id', id] } },
57
+ { $expr: { $eq: ['$history.version', version] } },
58
+ ],
59
+ },
60
+ }];
61
+ const lookup = [
62
+ {
63
+ $lookup: {
64
+ from: 'me',
65
+ as: 'userData',
66
+ let: { userid: '$history.user' },
67
+ pipeline: [
68
+ {
69
+ $match: {
70
+ $and: [
71
+ { $expr: { $eq: ['$id', '$$userid'] } },
72
+ ],
73
+ },
74
+ },
75
+ ],
76
+ },
77
+ },
78
+ {
79
+ $unwind: {
80
+ path: '$userData',
81
+ preserveNullAndEmptyArrays: true,
82
+ },
83
+ },
84
+ {
85
+ $addFields: {
86
+ 'history.user': {
87
+ $concat: ['$userData.lastname', ', ', '$userData.prename'],
88
+ },
89
+ },
90
+ },
91
+ ];
92
+ aggregation.push(...lookup);
93
+ return this.model.db.aggregate(aggregation).toArray()
94
+ .then((single) => single[0]);
95
+ }
96
+ async internal(company, project, id) {
97
+ const aggregation = [{
98
+ $match: {
99
+ $and: [
100
+ { $expr: { $eq: ['$company', company] } },
101
+ { $expr: { $eq: ['$project', project] } },
102
+ { $expr: { $eq: ['$_id', id] } },
103
+ ],
104
+ },
105
+ }];
106
+ const lookup = [
107
+ {
108
+ $lookup: {
109
+ from: 'me',
110
+ as: 'userData',
111
+ let: { userid: '$history.user' },
112
+ pipeline: [
113
+ {
114
+ $match: {
115
+ $and: [
116
+ { $expr: { $eq: ['$id', '$$userid'] } },
117
+ ],
118
+ },
119
+ },
120
+ ],
121
+ },
122
+ },
123
+ {
124
+ $unwind: {
125
+ path: '$userData',
126
+ preserveNullAndEmptyArrays: true,
127
+ },
128
+ },
129
+ {
130
+ $addFields: {
131
+ 'history.user': {
132
+ $concat: ['$userData.lastname', ', ', '$userData.prename'],
133
+ },
134
+ },
135
+ },
136
+ ];
137
+ aggregation.push(...lookup);
138
+ return this.model.db.aggregate(aggregation).toArray()
139
+ .then((single) => single[0]);
140
+ }
141
+ createQuery(company, project, idorInernalId, reason, model, app, projection, sort, limit, skip) {
142
+ let aggregation = [
143
+ {
144
+ $match: {
145
+ $and: [
146
+ { $expr: { $eq: ['$company', company] } },
147
+ ],
148
+ },
149
+ },
150
+ ];
151
+ aggregation.push({
152
+ $sort: { _id: sort || -1 },
153
+ });
154
+ const countQuery = {
155
+ company,
156
+ };
157
+ if (project) {
158
+ countQuery.project = project;
159
+ aggregation[0].$match.$and.push({ $expr: { $eq: ['$project', project] } });
160
+ }
161
+ if (reason) {
162
+ countQuery['history.reason'] = reason;
163
+ aggregation[0].$match.$and.push({ $expr: { $eq: ['$history.reason', reason] } });
164
+ }
165
+ if (app) {
166
+ countQuery['history.app'] = app;
167
+ aggregation[0].$match.$and.push({ $expr: { $eq: ['$history.app', app] } });
168
+ }
169
+ if (model) {
170
+ countQuery['history.model'] = model;
171
+ aggregation[0].$match.$and.push({ $expr: { $eq: ['$history.model', model] } });
172
+ }
173
+ if (idorInernalId) {
174
+ if (typeof idorInernalId === 'object') {
175
+ countQuery['history.parent'] = idorInernalId;
176
+ aggregation[0].$match.$and.push({ $expr: { $eq: ['$history.parent', idorInernalId] } });
177
+ }
178
+ else {
179
+ countQuery.id = idorInernalId;
180
+ aggregation[0].$match.$and.push({ $expr: { $eq: ['$id', idorInernalId] } });
181
+ }
182
+ }
183
+ aggregation.push({
184
+ $skip: skip,
185
+ }, {
186
+ $limit: limit,
187
+ });
188
+ const lookup = [
189
+ {
190
+ $lookup: {
191
+ from: 'me',
192
+ as: 'userData',
193
+ let: { userid: '$history.user' },
194
+ pipeline: [
195
+ {
196
+ $match: {
197
+ $and: [
198
+ { $expr: { $eq: ['$id', '$$userid'] } },
199
+ ],
200
+ },
201
+ },
202
+ ],
203
+ },
204
+ },
205
+ {
206
+ $unwind: {
207
+ path: '$userData',
208
+ preserveNullAndEmptyArrays: true,
209
+ },
210
+ },
211
+ {
212
+ $addFields: {
213
+ 'history.user': {
214
+ $concat: ['$userData.lastname', ', ', '$userData.prename'],
215
+ },
216
+ },
217
+ },
218
+ ];
219
+ if (projection) {
220
+ lookup.push({
221
+ $project: {
222
+ project: 1,
223
+ id: 1,
224
+ company: 1,
225
+ history: 1,
226
+ },
227
+ });
228
+ }
229
+ aggregation = [...aggregation, ...lookup];
230
+ return {
231
+ countQuery,
232
+ aggregation,
233
+ };
234
+ }
235
+ }
236
+ exports.default = new HistoryService();
237
+ //# sourceMappingURL=history.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.service.js","sourceRoot":"","sources":["../../../src/services/history.service.ts"],"names":[],"mappings":";;;;;AAAA,mDAAmD;AACnD,qCAGiB;AAEjB,yCAA4C;AAC5C,oFAA2D;AAE3D,MAAM,cAAc;IAApB;QAEE,UAAK,GAAG,qBAAY,CAAC;IA8WvB,CAAC;IApVC,MAAM,CACJ,IAAO,EAC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AAC;oBACV,EAAE,EAAE,CAAC;oBACL,OAAO,EAAE,CAAC;oBACV,OAAO,EAAE,CAAC;iBACX;aACF,CAAC,CAAC;SAEJ;QAED,WAAW,GAAG,CAAC,GAAG,WAAW,EAAE,GAAG,MAAM,CAAC,CAAC;QAE1C,OAAO;YACL,UAAU;YACV,WAAW;SACZ,CAAC;IAEJ,CAAC;CAEF;AACD,kBAAe,IAAI,cAAc,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare class IdService {
2
+ static getCurrent(company: string, project: string, app: string, model: string): Promise<import("mongodb").WithId<import("../models/id.model").Id> | null>;
3
+ static getUnique(company: string, project?: string, app?: string, model?: string): Promise<number | undefined>;
4
+ }
5
+ declare const _default: IdService;
6
+ export default _default;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdService = void 0;
4
+ const models_1 = require("../../models");
5
+ class IdService {
6
+ static getCurrent(company, project, app, model) {
7
+ return models_1.IdModel.db.findOne({
8
+ company, project, app, model,
9
+ });
10
+ }
11
+ static getUnique(company, project, app, model) {
12
+ return models_1.IdModel.db.findOneAndUpdate({
13
+ company, project, app, model,
14
+ }, { $inc: { count: 1 } }, { upsert: true, returnDocument: 'after' })
15
+ .then((response) => { var _a; return (_a = response.value) === null || _a === void 0 ? void 0 : _a.count; });
16
+ }
17
+ }
18
+ exports.IdService = IdService;
19
+ exports.default = new IdService();
20
+ //# sourceMappingURL=id.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id.service.js","sourceRoot":"","sources":["../../../src/services/id.service.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AAEvC,MAAa,SAAS;IAEpB,MAAM,CAAC,UAAU,CAAC,OAAe,EAAE,OAAe,EAAE,GAAW,EAAE,KAAa;QAE5E,OAAO,gBAAO,CAAC,EAAE,CAAC,OAAO,CAAC;YACxB,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK;SAC7B,CAAC,CAAC;IAEL,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,OAAe,EAAE,OAAgB,EAAE,GAAY,EAAE,KAAc;QAE9E,OAAO,gBAAO,CAAC,EAAE,CAAC,gBAAgB,CAAC;YACjC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK;SAC7B,EACD,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;aAC/D,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,WAAC,OAAA,MAAA,QAAQ,CAAC,KAAK,0CAAE,KAAK,CAAA,EAAA,CAAC,CAAC;IAE/C,CAAC;CAEF;AApBD,8BAoBC;AACD,kBAAe,IAAI,SAAS,EAAE,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { ObjectId, SortDirection, WithId } from 'mongodb';
2
+ import { QueueServiceClient, QueueClient } from '@azure/storage-queue';
3
+ import { Publish, PublishResult } from '../../interfaces';
4
+ import { Immutable } from '../../main';
5
+ export declare class PublishService extends Immutable<Publish> {
6
+ model: import("../classes/modelv2.class").default<Publish>;
7
+ service: QueueServiceClient;
8
+ queue: string;
9
+ client: QueueClient;
10
+ constructor(connectionString: string, queue: string);
11
+ publish(company: string, project: string, referenceId: ObjectId, method: Publish['method'], pre: Publish['pre'] | undefined, planned: Date | undefined, app: string | undefined, model: string | undefined, type: Publish['type'], user: string, source: string): Promise<void>;
12
+ publishPlanned(planned: Publish, user: string, app: string): Promise<void>;
13
+ setState(_id: ObjectId, state: Publish['state'], user: string, app: string): Promise<import("mongodb").UpdateResult>;
14
+ setResult(_id: ObjectId, result: PublishResult[] | undefined, state: Publish['state'], user: string, app: string): Promise<import("mongodb").UpdateResult>;
15
+ cancel(_id: ObjectId, company: string, project: string, user: string, app: string): Promise<import("mongodb").UpdateResult>;
16
+ getActiveExists(company: string, project: string, referenceId?: ObjectId, method?: Publish['method'], pre?: Publish['pre'] | undefined, planned?: Date, appPublish?: string, modelPublish?: string, type?: Publish['type']): Promise<boolean>;
17
+ getLast(company: string, project: string, appPublish: string, modelPublish: string): Promise<WithId<Publish> | null>;
18
+ getPlanned(company?: string, project?: string, appPublish?: string, modelPublish?: string): Promise<WithId<Publish>[]>;
19
+ handlePlanned(user: string, app: string): Promise<Promise<void>[]>;
20
+ single(_id: ObjectId, company: string, project: string): Promise<Publish | null>;
21
+ list(company: string, project: string, appPublish: string | undefined, modelPublish: string | undefined, state: Publish['state'] | undefined, method: Publish['method'] | undefined, type: Publish['type'] | undefined, pre: Publish['pre'] | undefined, limit: number, skip: number, sort: {
22
+ [key: string]: SortDirection;
23
+ }): Promise<{
24
+ data: Publish[];
25
+ all: number;
26
+ count: number;
27
+ }>;
28
+ }
29
+ declare const _default: PublishService;
30
+ export default _default;