@whyour/qinglong 2.17.12-rc.2 → 2.18.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 (252) hide show
  1. package/README-en.md +1 -1
  2. package/README.md +2 -2
  3. package/docker/docker-compose.yml +3 -8
  4. package/package.json +45 -41
  5. package/sample/config.sample.sh +21 -2
  6. package/sample/notify.js +114 -15
  7. package/sample/notify.py +99 -45
  8. package/shell/api.sh +26 -0
  9. package/shell/preload/sitecustomize.js +7 -1
  10. package/shell/preload/sitecustomize.py +9 -1
  11. package/shell/share.sh +3 -7
  12. package/shell/start.sh +6 -1
  13. package/shell/task.sh +1 -1
  14. package/shell/update.sh +2 -6
  15. package/static/build/api/config.js +2 -1
  16. package/static/build/api/script.js +4 -3
  17. package/static/build/api/system.js +16 -1
  18. package/static/build/api/user.js +1 -1
  19. package/static/build/config/util.js +13 -3
  20. package/static/build/data/notify.js +16 -1
  21. package/static/build/data/system.js +1 -0
  22. package/static/build/loaders/express.js +11 -14
  23. package/static/build/loaders/initData.js +41 -5
  24. package/static/build/loaders/initFile.js +74 -76
  25. package/static/build/loaders/sock.js +4 -5
  26. package/static/build/loaders/update.js +2 -2
  27. package/static/build/schedule/index.js +0 -1
  28. package/static/build/services/cron.js +2 -1
  29. package/static/build/services/dependence.js +16 -7
  30. package/static/build/services/env.js +4 -27
  31. package/static/build/services/notify.js +50 -4
  32. package/static/build/services/open.js +16 -14
  33. package/static/build/services/schedule.js +1 -1
  34. package/static/build/services/sshKey.js +5 -6
  35. package/static/build/services/system.js +17 -5
  36. package/static/build/services/user.js +116 -161
  37. package/static/build/shared/store.js +32 -0
  38. package/static/build/shared/utils.js +27 -0
  39. package/static/build/token.js +2 -6
  40. package/static/dist/{827.efeeec44.async.js → 105.85a5c47a.async.js} +1 -1
  41. package/static/dist/{4588.46a3a31e.async.js → 1083.f86ce804.async.js} +1 -1
  42. package/static/dist/1149.33cb7e7a.async.js +1 -0
  43. package/static/dist/119.89e2d610.async.js +1 -0
  44. package/static/dist/{9631.042017c3.async.js → 1352.ab6da08e.async.js} +1 -1
  45. package/static/dist/1690.f0290540.async.js +1 -0
  46. package/static/dist/1742.6cbe5aca.async.js +1 -0
  47. package/static/dist/1765.d8e002d7.async.js +1 -0
  48. package/static/dist/1885.e0d00d2d.async.js +1 -0
  49. package/static/dist/2081.d0d781b1.async.js +1 -0
  50. package/static/dist/2096.383c1047.async.js +1 -0
  51. package/static/dist/2237.4d3def87.async.js +1 -0
  52. package/static/dist/2325.dfa32834.async.js +1 -0
  53. package/static/dist/2338.d678967d.async.js +1 -0
  54. package/static/dist/255.12f03ab2.async.js +1 -0
  55. package/static/dist/2625.675b6a18.chunk.css +1 -0
  56. package/static/dist/2634.a765cd37.async.js +1 -0
  57. package/static/dist/{8605.f56664b9.async.js → 2742.4852aac8.async.js} +1 -1
  58. package/static/dist/2821.be3dc88e.async.js +1 -0
  59. package/static/dist/2890.9e373f5b.async.js +1 -0
  60. package/static/dist/{4658.8a9e2830.async.js → 3034.6413c38e.async.js} +1 -1
  61. package/static/dist/3382.a584a111.async.js +1 -0
  62. package/static/dist/{2755.f6377d52.async.js → 3383.041eee73.async.js} +1 -1
  63. package/static/dist/3390.fb4b6851.async.js +1 -0
  64. package/static/dist/3481.333c2962.async.js +1 -0
  65. package/static/dist/3600.7637c822.async.js +1 -0
  66. package/static/dist/4046.7fbcfa02.async.js +1 -0
  67. package/static/dist/4642.9e24d86c.async.js +1 -0
  68. package/static/dist/4799.d5ca9f30.async.js +1 -0
  69. package/static/dist/4865.98e5a005.async.js +1 -0
  70. package/static/dist/4902.54ecbdb5.async.js +1 -0
  71. package/static/dist/5171.7fc6d0a2.async.js +1 -0
  72. package/static/dist/5312.5545b3ed.async.js +1 -0
  73. package/static/dist/5481.624d0e07.async.js +1 -0
  74. package/static/dist/5520.ff2cfd6b.async.js +1 -0
  75. package/static/dist/{8167.8f9d5e88.async.js → 5653.4fce7ce8.async.js} +1 -1
  76. package/static/dist/5970.10ac4f16.async.js +1 -0
  77. package/static/dist/6013.2d7bb12a.async.js +1 -0
  78. package/static/dist/6016.9c379049.async.js +1 -0
  79. package/static/dist/6035.5889ddc7.async.js +1 -0
  80. package/static/dist/6159.55cb068a.async.js +1 -0
  81. package/static/dist/{5394.de174420.async.js → 6247.b550d996.async.js} +1 -1
  82. package/static/dist/6341.673fb65c.async.js +1 -0
  83. package/static/dist/6439.7ef6c5e3.async.js +1 -0
  84. package/static/dist/{6141.db67ebff.async.js → 6541.a6d499de.async.js} +1 -1
  85. package/static/dist/6646.5fc37228.async.js +1 -0
  86. package/static/dist/6707.801b886b.async.js +1 -0
  87. package/static/dist/6872.42f939f1.async.js +1 -0
  88. package/static/dist/691.187a388c.async.js +1 -0
  89. package/static/dist/{1667.94045304.async.js → 7025.f4080d63.async.js} +1 -1
  90. package/static/dist/7285.d561cf26.async.js +1 -0
  91. package/static/dist/7355.5e5e573b.async.js +1 -0
  92. package/static/dist/7384.065ccae2.async.js +1 -0
  93. package/static/dist/739.6be5552a.async.js +1 -0
  94. package/static/dist/7528.d8b76d8a.async.js +1 -0
  95. package/static/dist/7802.6b73f16a.async.js +1 -0
  96. package/static/dist/{9120.ef78d517.async.js → 8060.8b699029.async.js} +1 -1
  97. package/static/dist/{8078.4add9375.async.js → 8078.8586c875.async.js} +1 -1
  98. package/static/dist/8142.e3e82eda.async.js +1 -0
  99. package/static/dist/852.15be2189.async.js +1 -0
  100. package/static/dist/8528.3dffc548.async.js +1 -0
  101. package/static/dist/872.10bd0974.async.js +1 -0
  102. package/static/dist/872.3fffed15.chunk.css +1 -0
  103. package/static/dist/8982.d2dba153.async.js +1 -0
  104. package/static/dist/9065.df8d5dcc.async.js +1 -0
  105. package/static/dist/9066.605168f8.async.js +1 -0
  106. package/static/dist/955.3c9481f7.async.js +1 -0
  107. package/static/dist/9730.30083c91.async.js +1 -0
  108. package/static/dist/9761.627ca3b5.async.js +1 -0
  109. package/static/dist/index.html +8 -7
  110. package/static/dist/layouts__index.1fce90e0.chunk.css +1 -0
  111. package/static/dist/layouts__index.c164d41f.async.js +1 -0
  112. package/static/dist/preload_helper.55b35ae0.js +1 -0
  113. package/static/dist/src__pages__404.6871535b.async.js +1 -0
  114. package/static/dist/src__pages__config__index.39b5f99f.async.js +1 -0
  115. package/static/dist/src__pages__crontab__detail.6f7c3205.async.js +1 -0
  116. package/static/dist/src__pages__crontab__index.55a8714d.async.js +1 -0
  117. package/static/dist/src__pages__crontab__logModal.c88ea3b7.async.js +1 -0
  118. package/static/dist/src__pages__crontab__modal.328fee41.async.js +1 -0
  119. package/static/dist/{src__pages__crontab__type.a798cac7.async.js → src__pages__crontab__type.5895ed02.async.js} +1 -1
  120. package/static/dist/src__pages__crontab__viewCreateModal.ffcf7a24.async.js +1 -0
  121. package/static/dist/src__pages__crontab__viewManageModal.c71ebc5a.async.js +1 -0
  122. package/static/dist/src__pages__dependence__index.edec638b.async.js +1 -0
  123. package/static/dist/src__pages__dependence__logModal.f123e2ac.async.js +1 -0
  124. package/static/dist/src__pages__dependence__modal.9fd1176b.async.js +1 -0
  125. package/static/dist/{src__pages__dependence__type.860703e8.async.js → src__pages__dependence__type.bdac3725.async.js} +1 -1
  126. package/static/dist/src__pages__diff__index.8ba53a1e.async.js +1 -0
  127. package/static/dist/src__pages__env__editNameModal.c35e96f9.async.js +1 -0
  128. package/static/dist/src__pages__env__index.c799138c.async.js +1 -0
  129. package/static/dist/src__pages__env__modal.3b0ca9a6.async.js +1 -0
  130. package/static/dist/src__pages__error__index.0221fcd9.async.js +1 -0
  131. package/static/dist/src__pages__initialization__index.346725d1.async.js +1 -0
  132. package/static/dist/src__pages__log__index.2fd615f2.async.js +1 -0
  133. package/static/dist/src__pages__login__index.1dd6e684.async.js +1 -0
  134. package/static/dist/src__pages__script__editModal.28caeb56.async.js +1 -0
  135. package/static/dist/src__pages__script__editNameModal.1155d34c.async.js +1 -0
  136. package/static/dist/src__pages__script__index.6a212c2d.async.js +1 -0
  137. package/static/dist/src__pages__script__renameModal.dabfccfd.async.js +1 -0
  138. package/static/dist/src__pages__script__saveModal.04d43882.async.js +1 -0
  139. package/static/dist/src__pages__script__setting.9d5ad53c.async.js +1 -0
  140. package/static/dist/src__pages__setting__about.3a1a6f3b.async.js +1 -0
  141. package/static/dist/src__pages__setting__appModal.7b3bff1e.async.js +1 -0
  142. package/static/dist/src__pages__setting__checkUpdate.0dfdaf7c.async.js +1 -0
  143. package/static/dist/src__pages__setting__dependence.a9b7ed43.async.js +1 -0
  144. package/static/dist/src__pages__setting__index.ffa1cdd6.async.js +1 -0
  145. package/static/dist/src__pages__setting__loginLog.fc87584a.async.js +1 -0
  146. package/static/dist/src__pages__setting__notification.97b1d997.async.js +1 -0
  147. package/static/dist/src__pages__setting__other.34ccb2e8.async.js +1 -0
  148. package/static/dist/src__pages__setting__progress.75143dca.async.js +1 -0
  149. package/static/dist/src__pages__setting__security.c777fb87.async.js +1 -0
  150. package/static/dist/src__pages__setting__systemLog.63e9c69d.async.js +1 -0
  151. package/static/dist/src__pages__subscription__index.69a6de02.async.js +1 -0
  152. package/static/dist/src__pages__subscription__logModal.b3c7c02c.async.js +1 -0
  153. package/static/dist/src__pages__subscription__modal.aefaf070.async.js +1 -0
  154. package/static/dist/umi.a4d14b92.css +1 -0
  155. package/static/dist/umi.fb3ed7a0.js +1 -0
  156. package/version.yaml +7 -10
  157. package/static/dist/1186.39086229.async.js +0 -1
  158. package/static/dist/1431.36b64dc5.async.js +0 -1
  159. package/static/dist/1467.6163d4ee.async.js +0 -1
  160. package/static/dist/2099.a46e32fc.async.js +0 -1
  161. package/static/dist/2182.59dcf306.chunk.css +0 -1
  162. package/static/dist/2260.6c4d0bd0.async.js +0 -1
  163. package/static/dist/2393.3d8adf53.async.js +0 -1
  164. package/static/dist/2618.7a71aedf.async.js +0 -1
  165. package/static/dist/2715.292538bc.async.js +0 -1
  166. package/static/dist/2796.9a52d80e.async.js +0 -1
  167. package/static/dist/2899.03668225.async.js +0 -1
  168. package/static/dist/29.32a92099.async.js +0 -1
  169. package/static/dist/3435.2670d41f.async.js +0 -1
  170. package/static/dist/3435.d2d0a2c7.chunk.css +0 -1
  171. package/static/dist/3669.d39d1a9d.async.js +0 -1
  172. package/static/dist/380.33bc8989.async.js +0 -1
  173. package/static/dist/3800.f0507af4.async.js +0 -1
  174. package/static/dist/4039.badd6267.async.js +0 -1
  175. package/static/dist/4124.980265f2.async.js +0 -1
  176. package/static/dist/4163.17026fe1.async.js +0 -1
  177. package/static/dist/419.908ca086.async.js +0 -1
  178. package/static/dist/4424.a840b858.async.js +0 -1
  179. package/static/dist/4645.d909733e.async.js +0 -1
  180. package/static/dist/4674.1b3db685.async.js +0 -1
  181. package/static/dist/4925.9b770864.async.js +0 -1
  182. package/static/dist/5310.4cd7a0c1.async.js +0 -1
  183. package/static/dist/5484.68655765.async.js +0 -1
  184. package/static/dist/573.21675f9c.async.js +0 -1
  185. package/static/dist/5830.9be47cbb.async.js +0 -1
  186. package/static/dist/6035.48d17c03.async.js +0 -1
  187. package/static/dist/6064.a5141a7d.async.js +0 -1
  188. package/static/dist/641.f0614d96.async.js +0 -1
  189. package/static/dist/6712.05e15d48.async.js +0 -1
  190. package/static/dist/6805.ae3d4019.async.js +0 -1
  191. package/static/dist/694.0baa21db.async.js +0 -1
  192. package/static/dist/6986.6a4ae181.async.js +0 -1
  193. package/static/dist/7346.7096e3b3.async.js +0 -1
  194. package/static/dist/7362.e740709d.async.js +0 -1
  195. package/static/dist/7393.ea2d5ba3.async.js +0 -1
  196. package/static/dist/745.3be9ce9f.async.js +0 -1
  197. package/static/dist/7742.51617038.async.js +0 -1
  198. package/static/dist/7787.b041d555.async.js +0 -1
  199. package/static/dist/7987.5bace809.async.js +0 -1
  200. package/static/dist/8298.978b54ae.async.js +0 -1
  201. package/static/dist/833.87a694db.async.js +0 -1
  202. package/static/dist/8430.0291dda0.async.js +0 -1
  203. package/static/dist/8432.d8d0ade6.async.js +0 -1
  204. package/static/dist/858.1a385b25.async.js +0 -1
  205. package/static/dist/8934.55adca8f.async.js +0 -1
  206. package/static/dist/9065.a1341834.async.js +0 -1
  207. package/static/dist/9504.22415050.async.js +0 -1
  208. package/static/dist/9673.ac17e45d.async.js +0 -1
  209. package/static/dist/9847.d72d4b37.async.js +0 -1
  210. package/static/dist/layouts__index.2f94d49c.async.js +0 -1
  211. package/static/dist/layouts__index.35164d74.chunk.css +0 -1
  212. package/static/dist/src__pages__404.e1ca45fd.async.js +0 -1
  213. package/static/dist/src__pages__config__index.c778a0e0.async.js +0 -1
  214. package/static/dist/src__pages__crontab__detail.34c9ca68.async.js +0 -1
  215. package/static/dist/src__pages__crontab__index.f196124c.async.js +0 -1
  216. package/static/dist/src__pages__crontab__logModal.91357c7c.async.js +0 -1
  217. package/static/dist/src__pages__crontab__modal.6fa9520e.async.js +0 -1
  218. package/static/dist/src__pages__crontab__viewCreateModal.1fe0e251.async.js +0 -1
  219. package/static/dist/src__pages__crontab__viewManageModal.c6dcfcf8.async.js +0 -1
  220. package/static/dist/src__pages__dependence__index.aca3926b.async.js +0 -1
  221. package/static/dist/src__pages__dependence__logModal.07786c7c.async.js +0 -1
  222. package/static/dist/src__pages__dependence__modal.e67d0ff6.async.js +0 -1
  223. package/static/dist/src__pages__diff__index.82b124a8.async.js +0 -1
  224. package/static/dist/src__pages__env__editNameModal.38d65f05.async.js +0 -1
  225. package/static/dist/src__pages__env__index.f545d035.async.js +0 -1
  226. package/static/dist/src__pages__env__modal.6fad122b.async.js +0 -1
  227. package/static/dist/src__pages__error__index.c5c8ed46.async.js +0 -1
  228. package/static/dist/src__pages__initialization__index.a26591c2.async.js +0 -1
  229. package/static/dist/src__pages__log__index.bc06b12f.async.js +0 -1
  230. package/static/dist/src__pages__login__index.e4257741.async.js +0 -1
  231. package/static/dist/src__pages__script__editModal.be12c9e5.async.js +0 -1
  232. package/static/dist/src__pages__script__editNameModal.e7f7fea1.async.js +0 -1
  233. package/static/dist/src__pages__script__index.4fdb14ad.async.js +0 -1
  234. package/static/dist/src__pages__script__renameModal.436dedbf.async.js +0 -1
  235. package/static/dist/src__pages__script__saveModal.f65940c2.async.js +0 -1
  236. package/static/dist/src__pages__script__setting.b4891488.async.js +0 -1
  237. package/static/dist/src__pages__setting__about.d7cea886.async.js +0 -1
  238. package/static/dist/src__pages__setting__appModal.48994718.async.js +0 -1
  239. package/static/dist/src__pages__setting__checkUpdate.0dd2f8d5.async.js +0 -1
  240. package/static/dist/src__pages__setting__dependence.b6d378b3.async.js +0 -1
  241. package/static/dist/src__pages__setting__index.45c54c51.async.js +0 -1
  242. package/static/dist/src__pages__setting__loginLog.4ba597ea.async.js +0 -1
  243. package/static/dist/src__pages__setting__notification.7df85f89.async.js +0 -1
  244. package/static/dist/src__pages__setting__other.2c4534ef.async.js +0 -1
  245. package/static/dist/src__pages__setting__progress.57907231.async.js +0 -1
  246. package/static/dist/src__pages__setting__security.e26348a7.async.js +0 -1
  247. package/static/dist/src__pages__setting__systemLog.a77a9995.async.js +0 -1
  248. package/static/dist/src__pages__subscription__index.0f0a7c0a.async.js +0 -1
  249. package/static/dist/src__pages__subscription__logModal.8d68bb96.async.js +0 -1
  250. package/static/dist/src__pages__subscription__modal.26538bfd.async.js +0 -1
  251. package/static/dist/umi.8a0eaca6.css +0 -1
  252. package/static/dist/umi.ae45a508.js +0 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NtfyNotification = exports.LarkNotification = exports.WebhookNotification = exports.ChronocatNotification = exports.PushMeNotification = exports.EmailNotification = exports.WePlusBotNotification = exports.PushPlusNotification = exports.IGotNotification = exports.AibotkNotification = exports.WeWorkAppNotification = exports.WeWorkBotNotification = exports.DingtalkBotNotification = exports.TelegramBotNotification = exports.BarkNotification = exports.ChatNotification = exports.PushDeerNotification = exports.ServerChanNotification = exports.GoCqHttpBotNotification = exports.GotifyNotification = exports.NotificationMode = void 0;
3
+ exports.WxPusherBotNotification = exports.NtfyNotification = exports.LarkNotification = exports.WebhookNotification = exports.ChronocatNotification = exports.PushMeNotification = exports.EmailNotification = exports.WePlusBotNotification = exports.PushPlusNotification = exports.IGotNotification = exports.AibotkNotification = exports.WeWorkAppNotification = exports.WeWorkBotNotification = exports.DingtalkBotNotification = exports.TelegramBotNotification = exports.BarkNotification = exports.ChatNotification = exports.PushDeerNotification = exports.ServerChanNotification = exports.GoCqHttpBotNotification = exports.GotifyNotification = exports.NotificationMode = void 0;
4
4
  var NotificationMode;
5
5
  (function (NotificationMode) {
6
6
  NotificationMode["gotify"] = "gotify";
@@ -23,6 +23,7 @@ var NotificationMode;
23
23
  NotificationMode["webhook"] = "webhook";
24
24
  NotificationMode["chronocat"] = "Chronocat";
25
25
  NotificationMode["ntfy"] = "ntfy";
26
+ NotificationMode["wxPusherBot"] = "wxPusherBot";
26
27
  })(NotificationMode || (exports.NotificationMode = NotificationMode = {}));
27
28
  class NotificationBaseInfo {
28
29
  }
@@ -137,6 +138,11 @@ class PushPlusNotification extends NotificationBaseInfo {
137
138
  super(...arguments);
138
139
  this.pushPlusToken = '';
139
140
  this.pushPlusUser = '';
141
+ this.pushPlusTemplate = '';
142
+ this.pushplusChannel = '';
143
+ this.pushplusWebhook = '';
144
+ this.pushplusCallbackUrl = '';
145
+ this.pushplusTo = '';
140
146
  }
141
147
  }
142
148
  exports.PushPlusNotification = PushPlusNotification;
@@ -202,4 +208,13 @@ class NtfyNotification extends NotificationBaseInfo {
202
208
  }
203
209
  }
204
210
  exports.NtfyNotification = NtfyNotification;
211
+ class WxPusherBotNotification extends NotificationBaseInfo {
212
+ constructor() {
213
+ super(...arguments);
214
+ this.wxPusherBotAppToken = '';
215
+ this.wxPusherBotTopicIds = '';
216
+ this.wxPusherBotUids = '';
217
+ }
218
+ }
219
+ exports.WxPusherBotNotification = WxPusherBotNotification;
205
220
  //# sourceMappingURL=notify.js.map
@@ -24,6 +24,7 @@ var AuthDataType;
24
24
  AuthDataType["notification"] = "notification";
25
25
  AuthDataType["removeLogFrequency"] = "removeLogFrequency";
26
26
  AuthDataType["systemConfig"] = "systemConfig";
27
+ AuthDataType["authConfig"] = "authConfig";
27
28
  })(AuthDataType || (exports.AuthDataType = AuthDataType = {}));
28
29
  exports.SystemModel = _1.sequelize.define('Auth', {
29
30
  ip: sequelize_1.DataTypes.STRING,
@@ -31,18 +31,15 @@ const body_parser_1 = __importDefault(require("body-parser"));
31
31
  const cors_1 = __importDefault(require("cors"));
32
32
  const api_1 = __importDefault(require("../api"));
33
33
  const config_1 = __importDefault(require("../config"));
34
- const express_jwt_1 = __importStar(require("express-jwt"));
35
- const promises_1 = __importDefault(require("fs/promises"));
34
+ const express_jwt_1 = require("express-jwt");
36
35
  const util_1 = require("../config/util");
37
- const typedi_1 = __importDefault(require("typedi"));
38
- const open_1 = __importDefault(require("../services/open"));
39
36
  const express_urlrewrite_1 = __importDefault(require("express-urlrewrite"));
40
- const user_1 = __importDefault(require("../services/user"));
41
37
  const Sentry = __importStar(require("@sentry/node"));
42
38
  const celebrate_1 = require("celebrate");
43
39
  const http_proxy_middleware_1 = require("http-proxy-middleware");
44
40
  const serverEnv_1 = require("../config/serverEnv");
45
41
  const logger_1 = __importDefault(require("./logger"));
42
+ const store_1 = require("../shared/store");
46
43
  exports.default = ({ app }) => {
47
44
  app.set('trust proxy', 'loopback');
48
45
  app.use((0, cors_1.default)());
@@ -52,11 +49,11 @@ exports.default = ({ app }) => {
52
49
  target: `http://0.0.0.0:${config_1.default.publicPort}/api`,
53
50
  changeOrigin: true,
54
51
  pathRewrite: { '/api/public': '' },
55
- logProvider: () => logger_1.default,
52
+ logger: logger_1.default,
56
53
  }));
57
54
  app.use(body_parser_1.default.json({ limit: '50mb' }));
58
55
  app.use(body_parser_1.default.urlencoded({ limit: '50mb', extended: true }));
59
- app.use((0, express_jwt_1.default)({
56
+ app.use((0, express_jwt_1.expressjwt)({
60
57
  secret: config_1.default.secret,
61
58
  algorithms: ['HS384'],
62
59
  }).unless({
@@ -73,10 +70,11 @@ exports.default = ({ app }) => {
73
70
  return next();
74
71
  });
75
72
  app.use(async (req, res, next) => {
73
+ var _a;
76
74
  const headerToken = (0, util_1.getToken)(req);
77
75
  if (req.path.startsWith('/open/')) {
78
- const openService = typedi_1.default.get(open_1.default);
79
- const doc = await openService.findTokenByValue(headerToken);
76
+ const apps = await store_1.shareStore.getApps();
77
+ const doc = (_a = apps === null || apps === void 0 ? void 0 : apps.filter((x) => { var _a; return (_a = x.tokens) === null || _a === void 0 ? void 0 : _a.find((y) => y.value === headerToken); })) === null || _a === void 0 ? void 0 : _a[0];
80
78
  if (doc && doc.tokens && doc.tokens.length > 0) {
81
79
  const currentToken = doc.tokens.find((x) => x.value === headerToken);
82
80
  const keyMatch = req.path.match(/\/open\/([a-z]+)\/*/);
@@ -94,9 +92,9 @@ exports.default = ({ app }) => {
94
92
  config_1.default.apiWhiteList.includes(originPath)) {
95
93
  return next();
96
94
  }
97
- const data = await promises_1.default.readFile(config_1.default.authConfigFile, 'utf8');
98
- if (data && headerToken) {
99
- const { token = '', tokens = {} } = (0, util_1.safeJSONParse)(data);
95
+ const authInfo = await store_1.shareStore.getAuthInfo();
96
+ if (authInfo && headerToken) {
97
+ const { token = '', tokens = {} } = authInfo;
100
98
  if (headerToken === token || tokens[req.platform] === headerToken) {
101
99
  return next();
102
100
  }
@@ -112,8 +110,7 @@ exports.default = ({ app }) => {
112
110
  if (!['/api/user/init', '/api/user/notification/init'].includes(req.path)) {
113
111
  return next();
114
112
  }
115
- const userService = typedi_1.default.get(user_1.default);
116
- const authInfo = await userService.getUserInfo();
113
+ const authInfo = (await store_1.shareStore.getAuthInfo()) || {};
117
114
  let isInitialized = true;
118
115
  if (Object.keys(authInfo).length === 2 &&
119
116
  authInfo.username === 'admin' &&
@@ -18,6 +18,10 @@ const system_1 = require("../data/system");
18
18
  const system_2 = __importDefault(require("../services/system"));
19
19
  const user_1 = __importDefault(require("../services/user"));
20
20
  const promises_1 = require("fs/promises");
21
+ const util_1 = require("../config/util");
22
+ const open_1 = __importDefault(require("../services/open"));
23
+ const store_1 = require("../shared/store");
24
+ const logger_1 = __importDefault(require("./logger"));
21
25
  exports.default = async () => {
22
26
  var _a, _b, _c, _d, _e, _f;
23
27
  const cronService = typedi_1.Container.get(cron_2.default);
@@ -25,12 +29,39 @@ exports.default = async () => {
25
29
  const dependenceService = typedi_1.Container.get(dependence_1.default);
26
30
  const systemService = typedi_1.Container.get(system_2.default);
27
31
  const userService = typedi_1.Container.get(user_1.default);
32
+ const openService = typedi_1.Container.get(open_1.default);
28
33
  // 初始化增加系统配置
29
- await system_1.SystemModel.upsert({ type: system_1.AuthDataType.systemConfig });
30
- await system_1.SystemModel.upsert({ type: system_1.AuthDataType.notification });
34
+ const [systemConfig] = await system_1.SystemModel.findOrCreate({
35
+ where: { type: system_1.AuthDataType.systemConfig },
36
+ });
37
+ const [notifyConfig] = await system_1.SystemModel.findOrCreate({
38
+ where: { type: system_1.AuthDataType.notification },
39
+ });
40
+ const [authConfig] = await system_1.SystemModel.findOrCreate({
41
+ where: { type: system_1.AuthDataType.authConfig },
42
+ });
43
+ if (!(authConfig === null || authConfig === void 0 ? void 0 : authConfig.info)) {
44
+ let authInfo = {
45
+ username: 'admin',
46
+ password: 'admin',
47
+ };
48
+ try {
49
+ const content = await (0, promises_1.readFile)(config_1.default.authConfigFile, 'utf8');
50
+ authInfo = (0, util_1.safeJSONParse)(content);
51
+ }
52
+ catch (error) {
53
+ logger_1.default.warn('Failed to read auth config file, using default credentials');
54
+ }
55
+ await system_1.SystemModel.upsert({
56
+ id: authConfig === null || authConfig === void 0 ? void 0 : authConfig.id,
57
+ info: authInfo,
58
+ type: system_1.AuthDataType.authConfig,
59
+ });
60
+ }
31
61
  // 初始化通知配置
32
- const notifyConfig = await userService.getNotificationMode();
33
- await (0, promises_1.writeFile)(config_1.default.systemNotifyFile, JSON.stringify(notifyConfig));
62
+ if (notifyConfig.info) {
63
+ await (0, promises_1.writeFile)(config_1.default.systemNotifyFile, JSON.stringify(notifyConfig.info));
64
+ }
34
65
  const installDependencies = () => {
35
66
  // 初始化时安装所有处于安装中,安装成功,安装失败的依赖
36
67
  dependence_2.DependenceModel.findAll({
@@ -48,7 +79,6 @@ exports.default = async () => {
48
79
  });
49
80
  };
50
81
  // 初始化更新 linux/python/nodejs 镜像源配置
51
- const systemConfig = await systemService.getSystemConfig();
52
82
  if ((_a = systemConfig.info) === null || _a === void 0 ? void 0 : _a.pythonMirror) {
53
83
  systemService.updatePythonMirror({
54
84
  pythonMirror: (_b = systemConfig.info) === null || _b === void 0 ? void 0 : _b.pythonMirror,
@@ -138,5 +168,11 @@ exports.default = async () => {
138
168
  // 初始化保存一次ck和定时任务数据
139
169
  await cronService.autosave_crontab();
140
170
  await envService.set_envs();
171
+ const authInfo = await userService.getAuthInfo();
172
+ const apps = await openService.findApps();
173
+ await store_1.shareStore.updateAuthInfo(authInfo);
174
+ if (apps === null || apps === void 0 ? void 0 : apps.length) {
175
+ await store_1.shareStore.updateApps(apps);
176
+ }
141
177
  };
142
178
  //# sourceMappingURL=initData.js.map
@@ -8,6 +8,7 @@ const path_1 = __importDefault(require("path"));
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const logger_1 = __importDefault(require("./logger"));
10
10
  const util_1 = require("../config/util");
11
+ const utils_1 = require("../shared/utils");
11
12
  const rootPath = process.env.QL_DIR;
12
13
  let dataPath = path_1.default.join(rootPath, 'data/');
13
14
  if (process.env.QL_DATA_DIR) {
@@ -22,9 +23,7 @@ const bakPath = path_1.default.join(dataPath, 'bak/');
22
23
  const samplePath = path_1.default.join(rootPath, 'sample/');
23
24
  const tmpPath = path_1.default.join(logPath, '.tmp/');
24
25
  const confFile = path_1.default.join(configPath, 'config.sh');
25
- const authConfigFile = path_1.default.join(configPath, 'auth.json');
26
26
  const sampleConfigFile = path_1.default.join(samplePath, 'config.sample.sh');
27
- const sampleAuthFile = path_1.default.join(samplePath, 'auth.sample.json');
28
27
  const sampleTaskShellFile = path_1.default.join(samplePath, 'task.sample.sh');
29
28
  const sampleNotifyJsFile = path_1.default.join(samplePath, 'notify.js');
30
29
  const sampleNotifyPyFile = path_1.default.join(samplePath, 'notify.py');
@@ -40,81 +39,80 @@ const homedir = os_1.default.homedir();
40
39
  const sshPath = path_1.default.resolve(homedir, '.ssh');
41
40
  const sshdPath = path_1.default.join(dataPath, 'ssh.d');
42
41
  const systemLogPath = path_1.default.join(dataPath, 'syslog');
42
+ const directories = [
43
+ configPath,
44
+ scriptPath,
45
+ preloadPath,
46
+ logPath,
47
+ tmpPath,
48
+ uploadPath,
49
+ sshPath,
50
+ bakPath,
51
+ sshdPath,
52
+ systemLogPath,
53
+ ];
54
+ const files = [
55
+ {
56
+ target: confFile,
57
+ source: sampleConfigFile,
58
+ checkExistence: true,
59
+ },
60
+ {
61
+ target: jsNotifyFile,
62
+ source: sampleNotifyJsFile,
63
+ checkExistence: false,
64
+ },
65
+ {
66
+ target: pyNotifyFile,
67
+ source: sampleNotifyPyFile,
68
+ checkExistence: false,
69
+ },
70
+ {
71
+ target: scriptNotifyJsFile,
72
+ source: sampleNotifyJsFile,
73
+ checkExistence: true,
74
+ },
75
+ {
76
+ target: scriptNotifyPyFile,
77
+ source: sampleNotifyPyFile,
78
+ checkExistence: true,
79
+ },
80
+ {
81
+ target: TaskBeforeFile,
82
+ source: sampleTaskShellFile,
83
+ checkExistence: true,
84
+ },
85
+ {
86
+ target: TaskBeforeJsFile,
87
+ content: '// The JavaScript code that executes before the JavaScript task execution will execute.',
88
+ checkExistence: true,
89
+ },
90
+ {
91
+ target: TaskBeforePyFile,
92
+ content: '# The Python code that executes before the Python task execution will execute.',
93
+ checkExistence: true,
94
+ },
95
+ {
96
+ target: TaskAfterFile,
97
+ source: sampleTaskShellFile,
98
+ checkExistence: true,
99
+ },
100
+ ];
43
101
  exports.default = async () => {
44
- const authFileExist = await (0, util_1.fileExist)(authConfigFile);
45
- const confFileExist = await (0, util_1.fileExist)(confFile);
46
- const scriptDirExist = await (0, util_1.fileExist)(scriptPath);
47
- const preloadDirExist = await (0, util_1.fileExist)(preloadPath);
48
- const logDirExist = await (0, util_1.fileExist)(logPath);
49
- const configDirExist = await (0, util_1.fileExist)(configPath);
50
- const uploadDirExist = await (0, util_1.fileExist)(uploadPath);
51
- const sshDirExist = await (0, util_1.fileExist)(sshPath);
52
- const bakDirExist = await (0, util_1.fileExist)(bakPath);
53
- const sshdDirExist = await (0, util_1.fileExist)(sshdPath);
54
- const systemLogDirExist = await (0, util_1.fileExist)(systemLogPath);
55
- const tmpDirExist = await (0, util_1.fileExist)(tmpPath);
56
- const scriptNotifyJsFileExist = await (0, util_1.fileExist)(scriptNotifyJsFile);
57
- const scriptNotifyPyFileExist = await (0, util_1.fileExist)(scriptNotifyPyFile);
58
- const TaskBeforeFileExist = await (0, util_1.fileExist)(TaskBeforeFile);
59
- const TaskBeforeJsFileExist = await (0, util_1.fileExist)(TaskBeforeJsFile);
60
- const TaskBeforePyFileExist = await (0, util_1.fileExist)(TaskBeforePyFile);
61
- const TaskAfterFileExist = await (0, util_1.fileExist)(TaskAfterFile);
62
- if (!configDirExist) {
63
- await promises_1.default.mkdir(configPath);
64
- }
65
- if (!scriptDirExist) {
66
- await promises_1.default.mkdir(scriptPath);
67
- }
68
- if (!preloadDirExist) {
69
- await promises_1.default.mkdir(preloadPath);
70
- }
71
- if (!logDirExist) {
72
- await promises_1.default.mkdir(logPath);
73
- }
74
- if (!tmpDirExist) {
75
- await promises_1.default.mkdir(tmpPath);
76
- }
77
- if (!uploadDirExist) {
78
- await promises_1.default.mkdir(uploadPath);
79
- }
80
- if (!sshDirExist) {
81
- await promises_1.default.mkdir(sshPath);
82
- }
83
- if (!bakDirExist) {
84
- await promises_1.default.mkdir(bakPath);
85
- }
86
- if (!sshdDirExist) {
87
- await promises_1.default.mkdir(sshdPath);
88
- }
89
- if (!systemLogDirExist) {
90
- await promises_1.default.mkdir(systemLogPath);
91
- }
92
- // 初始化文件
93
- if (!authFileExist) {
94
- await promises_1.default.writeFile(authConfigFile, await promises_1.default.readFile(sampleAuthFile));
95
- }
96
- if (!confFileExist) {
97
- await promises_1.default.writeFile(confFile, await promises_1.default.readFile(sampleConfigFile));
98
- }
99
- await promises_1.default.writeFile(jsNotifyFile, await promises_1.default.readFile(sampleNotifyJsFile));
100
- await promises_1.default.writeFile(pyNotifyFile, await promises_1.default.readFile(sampleNotifyPyFile));
101
- if (!scriptNotifyJsFileExist) {
102
- await promises_1.default.writeFile(scriptNotifyJsFile, await promises_1.default.readFile(sampleNotifyJsFile));
103
- }
104
- if (!scriptNotifyPyFileExist) {
105
- await promises_1.default.writeFile(scriptNotifyPyFile, await promises_1.default.readFile(sampleNotifyPyFile));
106
- }
107
- if (!TaskBeforeFileExist) {
108
- await promises_1.default.writeFile(TaskBeforeFile, await promises_1.default.readFile(sampleTaskShellFile));
109
- }
110
- if (!TaskBeforeJsFileExist) {
111
- await promises_1.default.writeFile(TaskBeforeJsFile, '// The JavaScript code that executes before the JavaScript task execution will execute.');
112
- }
113
- if (!TaskBeforePyFileExist) {
114
- await promises_1.default.writeFile(TaskBeforePyFile, '# The Python code that executes before the Python task execution will execute.');
115
- }
116
- if (!TaskAfterFileExist) {
117
- await promises_1.default.writeFile(TaskAfterFile, await promises_1.default.readFile(sampleTaskShellFile));
102
+ for (const dirPath of directories) {
103
+ if (!(await (0, util_1.fileExist)(dirPath))) {
104
+ await promises_1.default.mkdir(dirPath);
105
+ }
106
+ }
107
+ for (const item of files) {
108
+ const exists = await (0, util_1.fileExist)(item.target);
109
+ if (!item.checkExistence || !exists) {
110
+ if (!item.content && !item.source) {
111
+ throw new Error(`Neither content nor source specified for ${item.target}`);
112
+ }
113
+ const content = item.content || (await promises_1.default.readFile(item.source));
114
+ await (0, utils_1.writeFileWithLock)(item.target, content);
115
+ }
118
116
  }
119
117
  logger_1.default.info('✌️ Init file down');
120
118
  console.log('✌️ Init file down');
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const sockjs_1 = __importDefault(require("sockjs"));
7
7
  const typedi_1 = require("typedi");
8
8
  const sock_1 = __importDefault(require("../services/sock"));
9
- const index_1 = __importDefault(require("../config/index"));
10
- const promises_1 = __importDefault(require("fs/promises"));
11
9
  const util_1 = require("../config/util");
10
+ const store_1 = require("../shared/store");
12
11
  exports.default = async ({ server }) => {
13
12
  const echo = sockjs_1.default.createServer({ prefix: '/api/ws', log: () => { } });
14
13
  const sockService = typedi_1.Container.get(sock_1.default);
@@ -16,11 +15,11 @@ exports.default = async ({ server }) => {
16
15
  if (!conn.headers || !conn.url || !conn.pathname) {
17
16
  conn.close('404');
18
17
  }
19
- const data = await promises_1.default.readFile(index_1.default.authConfigFile, 'utf8');
18
+ const authInfo = await store_1.shareStore.getAuthInfo();
20
19
  const platform = (0, util_1.getPlatform)(conn.headers['user-agent'] || '') || 'desktop';
21
20
  const headerToken = conn.url.replace(`${conn.pathname}?token=`, '');
22
- if (data) {
23
- const { token = '', tokens = {} } = (0, util_1.safeJSONParse)(data);
21
+ if (authInfo) {
22
+ const { token = '', tokens = {} } = authInfo;
24
23
  if (headerToken === token || tokens[platform] === headerToken) {
25
24
  sockService.addClient(conn);
26
25
  conn.on('data', (message) => {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const body_parser_1 = __importDefault(require("body-parser"));
7
7
  const celebrate_1 = require("celebrate");
8
8
  const cors_1 = __importDefault(require("cors"));
9
- const express_jwt_1 = __importDefault(require("express-jwt"));
9
+ const express_jwt_1 = require("express-jwt");
10
10
  const typedi_1 = __importDefault(require("typedi"));
11
11
  const config_1 = __importDefault(require("../config"));
12
12
  const system_1 = __importDefault(require("../services/system"));
@@ -16,7 +16,7 @@ exports.default = ({ app }) => {
16
16
  app.use((0, cors_1.default)());
17
17
  app.use(body_parser_1.default.json({ limit: '50mb' }));
18
18
  app.use(body_parser_1.default.urlencoded({ limit: '50mb', extended: true }));
19
- app.use((0, express_jwt_1.default)({
19
+ app.use((0, express_jwt_1.expressjwt)({
20
20
  secret: config_1.default.secret,
21
21
  algorithms: ['HS384'],
22
22
  }));
@@ -19,7 +19,6 @@ server.bindAsync(`0.0.0.0:${config_1.default.cronPort}`, grpc_js_1.ServerCredent
19
19
  if (err) {
20
20
  throw err;
21
21
  }
22
- server.start();
23
22
  logger_1.default.debug(`✌️ 定时服务启动成功!`);
24
23
  console.debug(`✌️ 定时服务启动成功!`);
25
24
  (_a = process.send) === null || _a === void 0 ? void 0 : _a.call(process, 'ready');
@@ -32,6 +32,7 @@ const cross_spawn_1 = require("cross-spawn");
32
32
  const dayjs_1 = __importDefault(require("dayjs"));
33
33
  const pickBy_1 = __importDefault(require("lodash/pickBy"));
34
34
  const omit_1 = __importDefault(require("lodash/omit"));
35
+ const utils_1 = require("../shared/utils");
35
36
  let CronService = class CronService {
36
37
  constructor(logger) {
37
38
  this.logger = logger;
@@ -496,7 +497,7 @@ let CronService = class CronService {
496
497
  crontab_string += '\n';
497
498
  }
498
499
  });
499
- await promises_1.default.writeFile(config_1.default.crontabFile, crontab_string);
500
+ await (0, utils_1.writeFileWithLock)(config_1.default.crontabFile, crontab_string);
500
501
  await cron_1.CrontabModel.update({ saved: true }, { where: {} });
501
502
  }
502
503
  import_crontab() {
@@ -175,6 +175,12 @@ let DependenceService = class DependenceService {
175
175
  if (pLimit_1.default.firstDependencyId !== dependency.id) {
176
176
  return resolve(null);
177
177
  }
178
+ const depIds = [dependency.id];
179
+ let depName = dependency.name.trim();
180
+ const actionText = isInstall ? '安装' : '删除';
181
+ const socketMessageType = isInstall
182
+ ? 'installDependence'
183
+ : 'uninstallDependence';
178
184
  const isNodeDependence = dependency.type === dependence_1.DependenceTypes.nodejs;
179
185
  const isLinuxDependence = dependency.type === dependence_1.DependenceTypes.linux;
180
186
  const isPythonDependence = dependency.type === dependence_1.DependenceTypes.python3;
@@ -183,19 +189,23 @@ let DependenceService = class DependenceService {
183
189
  pLimit_1.default.removeQueuedDependency(dependency);
184
190
  if (isLinuxDependence) {
185
191
  if (!osType) {
192
+ await dependence_1.DependenceModel.update({ status: dependence_1.DependenceStatus.installFailed }, { where: { id: depIds } });
193
+ const startTime = (0, dayjs_1.default)();
194
+ const message = `开始${actionText}依赖 ${depName},开始时间 ${startTime.format('YYYY-MM-DD HH:mm:ss')}\n\n当前系统不支持\n\n依赖${actionText}失败,结束时间 ${startTime.format('YYYY-MM-DD HH:mm:ss')},耗时 ${startTime.diff(startTime, 'second')} 秒`;
195
+ this.sockService.sendMessage({
196
+ type: socketMessageType,
197
+ message,
198
+ references: depIds,
199
+ });
200
+ this.updateLog(depIds, message);
186
201
  return resolve(null);
187
202
  }
188
203
  linuxCommand = const_1.LINUX_DEPENDENCE_COMMAND[osType];
189
204
  }
190
- const depIds = [dependency.id];
191
205
  const status = isInstall
192
206
  ? dependence_1.DependenceStatus.installing
193
207
  : dependence_1.DependenceStatus.removing;
194
208
  await dependence_1.DependenceModel.update({ status }, { where: { id: depIds } });
195
- const socketMessageType = isInstall
196
- ? 'installDependence'
197
- : 'uninstallDependence';
198
- let depName = dependency.name.trim();
199
209
  let depRunCommand = (isInstall
200
210
  ? dependence_1.InstallDependenceCommandTypes
201
211
  : dependence_1.unInstallDependenceCommandTypes)[dependency.type];
@@ -204,7 +214,6 @@ let DependenceService = class DependenceService {
204
214
  ? linuxCommand.install
205
215
  : linuxCommand.uninstall;
206
216
  }
207
- const actionText = isInstall ? '安装' : '删除';
208
217
  const startTime = (0, dayjs_1.default)();
209
218
  const message = `开始${actionText}依赖 ${depName},开始时间 ${startTime.format('YYYY-MM-DD HH:mm:ss')}\n\n`;
210
219
  this.sockService.sendMessage({
@@ -294,7 +303,7 @@ let DependenceService = class DependenceService {
294
303
  references: depIds,
295
304
  });
296
305
  this.updateLog(depIds, message);
297
- let status = null;
306
+ let status;
298
307
  if (isSucceed) {
299
308
  status = isInstall
300
309
  ? dependence_1.DependenceStatus.installed
@@ -1,33 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
7
  };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
8
  var __metadata = (this && this.__metadata) || function (k, v) {
32
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
10
  };
@@ -41,10 +18,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
41
18
  const typedi_1 = require("typedi");
42
19
  const winston_1 = __importDefault(require("winston"));
43
20
  const config_1 = __importDefault(require("../config"));
44
- const fs = __importStar(require("fs/promises"));
45
21
  const env_1 = require("../data/env");
46
22
  const groupBy_1 = __importDefault(require("lodash/groupBy"));
47
23
  const sequelize_1 = require("sequelize");
24
+ const utils_1 = require("../shared/utils");
48
25
  let EnvService = class EnvService {
49
26
  constructor(logger) {
50
27
  this.logger = logger;
@@ -215,9 +192,9 @@ let EnvService = class EnvService {
215
192
  }
216
193
  }
217
194
  }
218
- await fs.writeFile(config_1.default.envFile, env_string);
219
- await fs.writeFile(config_1.default.jsEnvFile, js_env_string);
220
- await fs.writeFile(config_1.default.pyEnvFile, py_env_string);
195
+ await (0, utils_1.writeFileWithLock)(config_1.default.envFile, env_string);
196
+ await (0, utils_1.writeFileWithLock)(config_1.default.jsEnvFile, js_env_string);
197
+ await (0, utils_1.writeFileWithLock)(config_1.default.pyEnvFile, py_env_string);
221
198
  }
222
199
  };
223
200
  EnvService = __decorate([
@@ -55,6 +55,7 @@ let NotificationService = class NotificationService {
55
55
  ['lark', this.lark],
56
56
  ['chronocat', this.chronocat],
57
57
  ['ntfy', this.ntfy],
58
+ ['wxPusherBot', this.wxPusherBot],
58
59
  ]);
59
60
  this.title = '';
60
61
  this.content = '';
@@ -444,16 +445,22 @@ let NotificationService = class NotificationService {
444
445
  }
445
446
  }
446
447
  async pushPlus() {
447
- const { pushPlusToken, pushPlusUser } = this.params;
448
+ const { pushPlusToken, pushPlusUser, pushplusWebhook, pushPlusTemplate, pushplusChannel, pushplusCallbackUrl, pushplusTo } = this.params;
448
449
  const url = `https://www.pushplus.plus/send`;
449
450
  try {
450
- const res = await got_1.default
451
- .post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
451
+ let body = Object.assign(Object.assign({}, this.gotOption), { json: {
452
452
  token: `${pushPlusToken}`,
453
453
  title: `${this.title}`,
454
454
  content: `${this.content.replace(/[\n\r]/g, '<br>')}`,
455
455
  topic: `${pushPlusUser || ''}`,
456
- } }))
456
+ template: `${pushPlusTemplate || 'html'}`,
457
+ channel: `${pushplusChannel || 'wechat'}`,
458
+ webhook: `${pushplusWebhook || ''}`,
459
+ callbackUrl: `${pushplusCallbackUrl || ''}`,
460
+ to: `${pushplusTo || ''}`
461
+ } });
462
+ const res = await got_1.default
463
+ .post(url, body)
457
464
  .json();
458
465
  if (res.code === 200) {
459
466
  return true;
@@ -589,6 +596,45 @@ let NotificationService = class NotificationService {
589
596
  throw new Error(error.response ? error.response.body : error);
590
597
  }
591
598
  }
599
+ async wxPusherBot() {
600
+ const { wxPusherBotAppToken, wxPusherBotTopicIds, wxPusherBotUids } = this.params;
601
+ // 处理 topicIds,将分号分隔的字符串转为数组
602
+ const topicIds = wxPusherBotTopicIds ? wxPusherBotTopicIds.split(';')
603
+ .map(id => id.trim())
604
+ .filter(id => id)
605
+ .map(id => parseInt(id)) : [];
606
+ // 处理 uids,将分号分隔的字符串转为数组
607
+ const uids = wxPusherBotUids ? wxPusherBotUids.split(';')
608
+ .map(uid => uid.trim())
609
+ .filter(uid => uid) : [];
610
+ // topic_ids 和 uids 至少要有一个
611
+ if (!topicIds.length && !uids.length) {
612
+ throw new Error('wxPusher 服务的 TopicIds 和 Uids 至少配置一个才行');
613
+ }
614
+ const url = `https://wxpusher.zjiecode.com/api/send/message`;
615
+ try {
616
+ const res = await got_1.default
617
+ .post(url, Object.assign(Object.assign({}, this.gotOption), { json: {
618
+ appToken: wxPusherBotAppToken,
619
+ content: `<h1>${this.title}</h1><br/><div style='white-space: pre-wrap;'>${this.content}</div>`,
620
+ summary: this.title,
621
+ contentType: 2,
622
+ topicIds: topicIds,
623
+ uids: uids,
624
+ verifyPayType: 0
625
+ } }))
626
+ .json();
627
+ if (res.code === 1000) {
628
+ return true;
629
+ }
630
+ else {
631
+ throw new Error(JSON.stringify(res));
632
+ }
633
+ }
634
+ catch (error) {
635
+ throw new Error(error.response ? error.response.body : error);
636
+ }
637
+ }
592
638
  async chronocat() {
593
639
  var _a, _b;
594
640
  const { chronocatURL, chronocatQQ, chronocatToken } = this.params;