@webda/core 2.0.0-beta.3 → 2.0.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 (276) hide show
  1. package/lib/application.d.ts +5 -5
  2. package/lib/application.js +71 -84
  3. package/lib/application.js.map +1 -1
  4. package/lib/application.spec.js +121 -140
  5. package/lib/application.spec.js.map +1 -1
  6. package/lib/core.d.ts +20 -24
  7. package/lib/core.js +222 -315
  8. package/lib/core.js.map +1 -1
  9. package/lib/core.spec.js +332 -406
  10. package/lib/core.spec.js.map +1 -1
  11. package/lib/index.d.ts +49 -48
  12. package/lib/index.js +53 -70
  13. package/lib/index.js.map +1 -1
  14. package/lib/models/aclmodel.d.ts +2 -2
  15. package/lib/models/aclmodel.js +63 -90
  16. package/lib/models/aclmodel.js.map +1 -1
  17. package/lib/models/aclmodel.spec.js +127 -152
  18. package/lib/models/aclmodel.spec.js.map +1 -1
  19. package/lib/models/coremodel.d.ts +7 -6
  20. package/lib/models/coremodel.js +65 -113
  21. package/lib/models/coremodel.js.map +1 -1
  22. package/lib/models/coremodel.spec.js +88 -107
  23. package/lib/models/coremodel.spec.js.map +1 -1
  24. package/lib/models/deployment.js +1 -2
  25. package/lib/models/ident.d.ts +3 -3
  26. package/lib/models/ident.js +4 -9
  27. package/lib/models/ident.js.map +1 -1
  28. package/lib/models/ident.spec.js +9 -11
  29. package/lib/models/ident.spec.js.map +1 -1
  30. package/lib/models/ownermodel.d.ts +2 -2
  31. package/lib/models/ownermodel.js +39 -62
  32. package/lib/models/ownermodel.js.map +1 -1
  33. package/lib/models/ownermodel.spec.js +126 -168
  34. package/lib/models/ownermodel.spec.js.map +1 -1
  35. package/lib/models/rolemodel.d.ts +1 -1
  36. package/lib/models/rolemodel.js +24 -40
  37. package/lib/models/rolemodel.js.map +1 -1
  38. package/lib/models/rolemodel.spec.js +44 -63
  39. package/lib/models/rolemodel.spec.js.map +1 -1
  40. package/lib/models/user.d.ts +3 -3
  41. package/lib/models/user.js +3 -8
  42. package/lib/models/user.js.map +1 -1
  43. package/lib/models/user.spec.js +14 -16
  44. package/lib/models/user.spec.js.map +1 -1
  45. package/lib/queues/filequeue.d.ts +2 -2
  46. package/lib/queues/filequeue.js +72 -93
  47. package/lib/queues/filequeue.js.map +1 -1
  48. package/lib/queues/filequeue.spec.js +53 -70
  49. package/lib/queues/filequeue.spec.js.map +1 -1
  50. package/lib/queues/memoryqueue.d.ts +2 -2
  51. package/lib/queues/memoryqueue.js +37 -61
  52. package/lib/queues/memoryqueue.js.map +1 -1
  53. package/lib/queues/memoryqueue.spec.js +142 -165
  54. package/lib/queues/memoryqueue.spec.js.map +1 -1
  55. package/lib/queues/pubsubservice.d.ts +2 -2
  56. package/lib/queues/pubsubservice.js +3 -7
  57. package/lib/queues/pubsubservice.js.map +1 -1
  58. package/lib/queues/queue.spec.d.ts +1 -1
  59. package/lib/queues/queue.spec.js +42 -56
  60. package/lib/queues/queue.spec.js.map +1 -1
  61. package/lib/queues/queueservice.d.ts +3 -3
  62. package/lib/queues/queueservice.js +51 -67
  63. package/lib/queues/queueservice.js.map +1 -1
  64. package/lib/router.d.ts +3 -3
  65. package/lib/router.js +46 -47
  66. package/lib/router.js.map +1 -1
  67. package/lib/router.spec.js +64 -61
  68. package/lib/router.spec.js.map +1 -1
  69. package/lib/services/asyncevents.d.ts +2 -2
  70. package/lib/services/asyncevents.js +44 -64
  71. package/lib/services/asyncevents.js.map +1 -1
  72. package/lib/services/asyncevents.spec.js +81 -98
  73. package/lib/services/asyncevents.spec.js.map +1 -1
  74. package/lib/services/authentication.d.ts +23 -13
  75. package/lib/services/authentication.js +537 -563
  76. package/lib/services/authentication.js.map +1 -1
  77. package/lib/services/authentication.spec.js +411 -447
  78. package/lib/services/authentication.spec.js.map +1 -1
  79. package/lib/services/binary.d.ts +7 -5
  80. package/lib/services/binary.js +211 -244
  81. package/lib/services/binary.js.map +1 -1
  82. package/lib/services/binary.spec.d.ts +3 -3
  83. package/lib/services/binary.spec.js +390 -443
  84. package/lib/services/binary.spec.js.map +1 -1
  85. package/lib/services/cloudbinary.d.ts +3 -3
  86. package/lib/services/cloudbinary.js +45 -70
  87. package/lib/services/cloudbinary.js.map +1 -1
  88. package/lib/services/cloudbinary.spec.d.ts +3 -3
  89. package/lib/services/cloudbinary.spec.js +133 -162
  90. package/lib/services/cloudbinary.spec.js.map +1 -1
  91. package/lib/services/configuration.d.ts +1 -1
  92. package/lib/services/configuration.js +78 -105
  93. package/lib/services/configuration.js.map +1 -1
  94. package/lib/services/configuration.spec.js +63 -83
  95. package/lib/services/configuration.spec.js.map +1 -1
  96. package/lib/services/cron.d.ts +3 -2
  97. package/lib/services/cron.js +9 -13
  98. package/lib/services/cron.js.map +1 -1
  99. package/lib/services/cron.spec.js +18 -21
  100. package/lib/services/cron.spec.js.map +1 -1
  101. package/lib/services/cryptoservice.d.ts +9 -4
  102. package/lib/services/cryptoservice.js +187 -221
  103. package/lib/services/cryptoservice.js.map +1 -1
  104. package/lib/services/cryptoservice.spec.js +88 -115
  105. package/lib/services/cryptoservice.spec.js.map +1 -1
  106. package/lib/services/debugmailer.d.ts +1 -1
  107. package/lib/services/debugmailer.js +13 -34
  108. package/lib/services/debugmailer.js.map +1 -1
  109. package/lib/services/debugmailer.spec.js +16 -29
  110. package/lib/services/debugmailer.spec.js.map +1 -1
  111. package/lib/services/echo.d.ts +2 -2
  112. package/lib/services/echo.js +15 -31
  113. package/lib/services/echo.js.map +1 -1
  114. package/lib/services/echo.spec.js +27 -40
  115. package/lib/services/echo.spec.js.map +1 -1
  116. package/lib/services/filebinary.d.ts +5 -5
  117. package/lib/services/filebinary.js +165 -210
  118. package/lib/services/filebinary.js.map +1 -1
  119. package/lib/services/filebinary.spec.d.ts +2 -1
  120. package/lib/services/filebinary.spec.js +106 -116
  121. package/lib/services/filebinary.spec.js.map +1 -1
  122. package/lib/services/fileconfiguration.d.ts +1 -1
  123. package/lib/services/fileconfiguration.js +25 -44
  124. package/lib/services/fileconfiguration.js.map +1 -1
  125. package/lib/services/fileconfiguration.spec.js +79 -109
  126. package/lib/services/fileconfiguration.spec.js.map +1 -1
  127. package/lib/services/invitationservice.d.ts +7 -7
  128. package/lib/services/invitationservice.js +274 -314
  129. package/lib/services/invitationservice.js.map +1 -1
  130. package/lib/services/invitationservice.spec.js +442 -448
  131. package/lib/services/invitationservice.spec.js.map +1 -1
  132. package/lib/services/kubernetesconfiguration.d.ts +1 -1
  133. package/lib/services/kubernetesconfiguration.js +41 -60
  134. package/lib/services/kubernetesconfiguration.js.map +1 -1
  135. package/lib/services/kubernetesconfiguration.spec.js +80 -98
  136. package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
  137. package/lib/services/mailer.d.ts +4 -4
  138. package/lib/services/mailer.js +62 -86
  139. package/lib/services/mailer.js.map +1 -1
  140. package/lib/services/mailer.spec.js +86 -127
  141. package/lib/services/mailer.spec.js.map +1 -1
  142. package/lib/services/notificationservice.d.ts +3 -3
  143. package/lib/services/notificationservice.js +21 -42
  144. package/lib/services/notificationservice.js.map +1 -1
  145. package/lib/services/notificationservice.spec.js +47 -73
  146. package/lib/services/notificationservice.spec.js.map +1 -1
  147. package/lib/services/oauth.d.ts +4 -4
  148. package/lib/services/oauth.js +68 -83
  149. package/lib/services/oauth.js.map +1 -1
  150. package/lib/services/oauth.spec.js +130 -156
  151. package/lib/services/oauth.spec.js.map +1 -1
  152. package/lib/services/proxy.d.ts +2 -6
  153. package/lib/services/proxy.js +45 -58
  154. package/lib/services/proxy.js.map +1 -1
  155. package/lib/services/proxy.spec.js +34 -53
  156. package/lib/services/proxy.spec.js.map +1 -1
  157. package/lib/services/resource.d.ts +2 -2
  158. package/lib/services/resource.js +12 -18
  159. package/lib/services/resource.js.map +1 -1
  160. package/lib/services/resource.spec.js +67 -99
  161. package/lib/services/resource.spec.js.map +1 -1
  162. package/lib/services/service.d.ts +26 -3
  163. package/lib/services/service.js +68 -40
  164. package/lib/services/service.js.map +1 -1
  165. package/lib/services/service.spec.js +62 -67
  166. package/lib/services/service.spec.js.map +1 -1
  167. package/lib/services/version.d.ts +1 -1
  168. package/lib/services/version.js +3 -8
  169. package/lib/services/version.js.map +1 -1
  170. package/lib/services/version.spec.js +11 -24
  171. package/lib/services/version.spec.js.map +1 -1
  172. package/lib/stores/aggregator.d.ts +2 -2
  173. package/lib/stores/aggregator.js +37 -58
  174. package/lib/stores/aggregator.js.map +1 -1
  175. package/lib/stores/file.d.ts +3 -3
  176. package/lib/stores/file.js +93 -131
  177. package/lib/stores/file.js.map +1 -1
  178. package/lib/stores/file.spec.d.ts +2 -2
  179. package/lib/stores/file.spec.js +261 -289
  180. package/lib/stores/file.spec.js.map +1 -1
  181. package/lib/stores/mapper.d.ts +3 -3
  182. package/lib/stores/mapper.js +110 -137
  183. package/lib/stores/mapper.js.map +1 -1
  184. package/lib/stores/mapper.spec.js +131 -150
  185. package/lib/stores/mapper.spec.js.map +1 -1
  186. package/lib/stores/memory.d.ts +3 -3
  187. package/lib/stores/memory.js +98 -144
  188. package/lib/stores/memory.js.map +1 -1
  189. package/lib/stores/memory.spec.d.ts +2 -2
  190. package/lib/stores/memory.spec.js +124 -145
  191. package/lib/stores/memory.spec.js.map +1 -1
  192. package/lib/stores/store.d.ts +17 -13
  193. package/lib/stores/store.js +819 -847
  194. package/lib/stores/store.js.map +1 -1
  195. package/lib/stores/store.spec.d.ts +5 -4
  196. package/lib/stores/store.spec.js +624 -669
  197. package/lib/stores/store.spec.js.map +1 -1
  198. package/lib/stores/webdaql/WebdaQLLexer.d.ts +4 -4
  199. package/lib/stores/webdaql/WebdaQLLexer.js +9 -13
  200. package/lib/stores/webdaql/WebdaQLLexer.js.map +1 -1
  201. package/lib/stores/webdaql/WebdaQLParserLexer.d.ts +4 -4
  202. package/lib/stores/webdaql/WebdaQLParserLexer.js +9 -13
  203. package/lib/stores/webdaql/WebdaQLParserLexer.js.map +1 -1
  204. package/lib/stores/webdaql/WebdaQLParserListener.d.ts +2 -2
  205. package/lib/stores/webdaql/WebdaQLParserListener.js +1 -2
  206. package/lib/stores/webdaql/WebdaQLParserListener.js.map +1 -1
  207. package/lib/stores/webdaql/WebdaQLParserParser.d.ts +10 -10
  208. package/lib/stores/webdaql/WebdaQLParserParser.js +62 -91
  209. package/lib/stores/webdaql/WebdaQLParserParser.js.map +1 -1
  210. package/lib/stores/webdaql/WebdaQLParserVisitor.d.ts +2 -2
  211. package/lib/stores/webdaql/WebdaQLParserVisitor.js +1 -2
  212. package/lib/stores/webdaql/WebdaQLParserVisitor.js.map +1 -1
  213. package/lib/stores/webdaql/query.d.ts +4 -5
  214. package/lib/stores/webdaql/query.js +16 -19
  215. package/lib/stores/webdaql/query.js.map +1 -1
  216. package/lib/stores/webdaql/query.spec.js +30 -32
  217. package/lib/stores/webdaql/query.spec.js.map +1 -1
  218. package/lib/test.d.ts +3 -3
  219. package/lib/test.js +73 -100
  220. package/lib/test.js.map +1 -1
  221. package/lib/unpackedapplication.d.ts +1 -1
  222. package/lib/unpackedapplication.js +25 -31
  223. package/lib/unpackedapplication.js.map +1 -1
  224. package/lib/utils/abstractdeployer.js +1 -5
  225. package/lib/utils/abstractdeployer.js.map +1 -1
  226. package/lib/utils/abstractdeployer.spec.js +6 -8
  227. package/lib/utils/abstractdeployer.spec.js.map +1 -1
  228. package/lib/utils/context.d.ts +7 -5
  229. package/lib/utils/context.js +95 -103
  230. package/lib/utils/context.js.map +1 -1
  231. package/lib/utils/context.spec.js +139 -163
  232. package/lib/utils/context.spec.js.map +1 -1
  233. package/lib/utils/cookie.d.ts +3 -3
  234. package/lib/utils/cookie.js +42 -61
  235. package/lib/utils/cookie.js.map +1 -1
  236. package/lib/utils/cookie.spec.js +42 -64
  237. package/lib/utils/cookie.spec.js.map +1 -1
  238. package/lib/utils/esm.d.ts +4 -0
  239. package/lib/utils/esm.js +10 -0
  240. package/lib/utils/esm.js.map +1 -0
  241. package/lib/utils/httpcontext.d.ts +3 -0
  242. package/lib/utils/httpcontext.js +48 -65
  243. package/lib/utils/httpcontext.js.map +1 -1
  244. package/lib/utils/httpcontext.spec.js +37 -56
  245. package/lib/utils/httpcontext.spec.js.map +1 -1
  246. package/lib/utils/logger.d.ts +2 -2
  247. package/lib/utils/logger.js +15 -28
  248. package/lib/utils/logger.js.map +1 -1
  249. package/lib/utils/logger.spec.js +9 -11
  250. package/lib/utils/logger.spec.js.map +1 -1
  251. package/lib/utils/serializers.js +17 -20
  252. package/lib/utils/serializers.js.map +1 -1
  253. package/lib/utils/serializers.spec.js +43 -44
  254. package/lib/utils/serializers.spec.js.map +1 -1
  255. package/lib/utils/session.d.ts +6 -6
  256. package/lib/utils/session.js +37 -59
  257. package/lib/utils/session.js.map +1 -1
  258. package/lib/utils/session.spec.js +38 -51
  259. package/lib/utils/session.spec.js.map +1 -1
  260. package/lib/utils/waiter.d.ts +1 -1
  261. package/lib/utils/waiter.js +32 -52
  262. package/lib/utils/waiter.js.map +1 -1
  263. package/lib/utils/waiter.spec.js +75 -92
  264. package/lib/utils/waiter.spec.js.map +1 -1
  265. package/package.json +17 -12
  266. package/test/config-invitation.json +1 -3
  267. package/test/config.json +1 -2
  268. package/test/config.old.json +1 -2
  269. package/test/moddas/annotatedservice.js +5 -5
  270. package/test/moddas/debugmailer.js +2 -3
  271. package/test/moddas/fakeservice.js +2 -3
  272. package/test/moddas/voidstore.js +6 -4
  273. package/test/models/ident.js +2 -6
  274. package/test/models/task.js +3 -7
  275. package/test/package.json +2 -1
  276. package/webda.module.json +956 -189
@@ -1,29 +1,17 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
4
  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;
6
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
6
  };
8
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
- return new (P || (P = Promise))(function (resolve, reject) {
11
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
- step((generator = generator.apply(thisArg, _arguments || [])).next());
15
- });
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.FakeCloudBinaryTest = exports.CloudBinaryTest = void 0;
19
- const mocha_1 = require("@testdeck/mocha");
20
- const assert = require("assert");
21
- const sinon = require("sinon");
22
- const coremodel_1 = require("../models/coremodel");
23
- const test_1 = require("../test");
24
- const binary_spec_1 = require("./binary.spec");
25
- const cloudbinary_1 = require("./cloudbinary");
26
- class CloudBinaryFakeService extends cloudbinary_1.CloudBinary {
7
+ import { suite, test } from "@testdeck/mocha";
8
+ import * as assert from "assert";
9
+ import * as sinon from "sinon";
10
+ import { CoreModel } from "../models/coremodel.js";
11
+ import { WebdaTest } from "../test.js";
12
+ import { BinaryTest } from "./binary.spec.js";
13
+ import { CloudBinary, CloudBinaryParameters } from "./cloudbinary.js";
14
+ class CloudBinaryFakeService extends CloudBinary {
27
15
  store(object, property, file, metadata) {
28
16
  throw new Error("Method not implemented.");
29
17
  }
@@ -33,180 +21,163 @@ class CloudBinaryFakeService extends cloudbinary_1.CloudBinary {
33
21
  /**
34
22
  * Clean usage for a hash
35
23
  */
36
- _cleanUsage(hash, uuid) {
37
- return __awaiter(this, void 0, void 0, function* () { });
38
- }
39
- _get() {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- return undefined;
42
- });
24
+ async _cleanUsage(hash, uuid) { }
25
+ async _get() {
26
+ return undefined;
43
27
  }
44
28
  /**
45
29
  * Retrieve one signed URL to download the file in parameter
46
30
  * @param {GetSignedUrlParams} params
47
31
  * @returns {string} URL in order to download the file
48
32
  */
49
- getSignedUrlFromMap(map, expires) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- return `${map.hash}:${expires}`;
52
- });
33
+ async getSignedUrlFromMap(map, expires) {
34
+ return `${map.hash}:${expires}`;
53
35
  }
54
36
  }
55
- class CloudBinaryTest extends binary_spec_1.BinaryTest {
56
- redirectUrl() {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- let { user1, ctx } = yield this.setupDefault();
59
- // Making sure we are redirected on GET
60
- let executor = this.getExecutor(ctx, "test.webda.io", "GET", `/binary/users/${user1.getUuid()}/images/0`, {});
61
- yield executor.execute(ctx);
62
- assert.ok(ctx.getResponseHeaders().Location !== undefined);
63
- });
37
+ export class CloudBinaryTest extends BinaryTest {
38
+ async redirectUrl() {
39
+ let { user1, ctx } = await this.setupDefault();
40
+ // Making sure we are redirected on GET
41
+ let executor = this.getExecutor(ctx, "test.webda.io", "GET", `/binary/users/${user1.getUuid()}/images/0`, {});
42
+ await executor.execute(ctx);
43
+ assert.ok(ctx.getResponseHeaders().Location !== undefined);
64
44
  }
65
- redirectUrlInfo() {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- let { user1, ctx } = yield this.setupDefault();
68
- // Making sure we are redirected on GET
69
- let executor = this.getExecutor(ctx, "test.webda.io", "GET", `/binary/users/${user1.getUuid()}/images/0/url`, {});
70
- yield executor.execute(ctx);
71
- assert.ok(ctx.getResponseHeaders().Location === undefined);
72
- assert.notStrictEqual(JSON.parse(ctx.getResponseBody()).Location, undefined);
73
- });
45
+ async redirectUrlInfo() {
46
+ let { user1, ctx } = await this.setupDefault();
47
+ // Making sure we are redirected on GET
48
+ let executor = this.getExecutor(ctx, "test.webda.io", "GET", `/binary/users/${user1.getUuid()}/images/0/url`, {});
49
+ await executor.execute(ctx);
50
+ assert.ok(ctx.getResponseHeaders().Location === undefined);
51
+ assert.notStrictEqual(JSON.parse(ctx.getResponseBody()).Location, undefined);
74
52
  }
75
53
  }
76
54
  __decorate([
77
- mocha_1.test
55
+ test
78
56
  ], CloudBinaryTest.prototype, "redirectUrl", null);
79
57
  __decorate([
80
- mocha_1.test
58
+ test
81
59
  ], CloudBinaryTest.prototype, "redirectUrlInfo", null);
82
- exports.CloudBinaryTest = CloudBinaryTest;
83
- let FakeCloudBinaryTest = class FakeCloudBinaryTest extends test_1.WebdaTest {
84
- testDefaults() {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- let service = new CloudBinaryFakeService(this.webda, "fake", {});
87
- let binaryMap = { hash: "test", size: 10 };
88
- yield service.cascadeDelete(binaryMap, "plop");
89
- let stub = sinon.stub(service, "_cleanUsage").callsFake(() => {
90
- throw new Error();
91
- });
92
- // Should not fail even with exception
93
- yield service.cascadeDelete(binaryMap, "plop");
94
- stub.restore();
95
- assert.strictEqual(service._getKey("hash"), "hash/data");
96
- service.getParameters().prefix = "prefix";
97
- assert.strictEqual(service._getKey("hash", "plop"), "prefix/hash/plop");
98
- assert.strictEqual(new cloudbinary_1.CloudBinaryParameters({}, service).prefix, "");
99
- sinon.stub(service, "deleteSuccess").resolves();
100
- let model = new coremodel_1.CoreModel();
101
- model.load({ plop: [{}, { hash: "fake" }] }, true);
102
- yield service.delete(model, "plop", 1);
103
- // Check called with "fake", 1
60
+ let FakeCloudBinaryTest = class FakeCloudBinaryTest extends WebdaTest {
61
+ async testDefaults() {
62
+ let service = new CloudBinaryFakeService(this.webda, "fake", {});
63
+ let binaryMap = { hash: "test", size: 10 };
64
+ await service.cascadeDelete(binaryMap, "plop");
65
+ let stub = sinon.stub(service, "_cleanUsage").callsFake(() => {
66
+ throw new Error();
104
67
  });
68
+ // Should not fail even with exception
69
+ await service.cascadeDelete(binaryMap, "plop");
70
+ stub.restore();
71
+ assert.strictEqual(service._getKey("hash"), "hash/data");
72
+ service.getParameters().prefix = "prefix";
73
+ assert.strictEqual(service._getKey("hash", "plop"), "prefix/hash/plop");
74
+ assert.strictEqual(new CloudBinaryParameters({}, service).prefix, "");
75
+ sinon.stub(service, "deleteSuccess").resolves();
76
+ let model = new CoreModel();
77
+ model.load({ plop: [{}, { hash: "fake" }] }, true);
78
+ await service.delete(model, "plop", 1);
79
+ // Check called with "fake", 1
105
80
  }
106
- initRoutes() {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- let service = new CloudBinaryFakeService(this.webda, "fake", {});
109
- let counter = 0;
110
- // @ts-ignore addRoute is a protected method of service
111
- let stub = sinon.stub(service, "addRoute").callsFake(() => {
112
- counter++;
113
- });
114
- service.initRoutes();
115
- assert.strictEqual(counter, 0);
116
- service.getParameters().expose = {
117
- url: "plop",
118
- restrict: {}
119
- };
120
- service.initRoutes();
121
- assert.strictEqual(counter, 7);
122
- counter = 0;
123
- service.getParameters().expose = {
124
- url: "plop",
125
- restrict: {
126
- get: true
127
- }
128
- };
129
- service.initRoutes();
130
- assert.strictEqual(counter, 4);
81
+ async initRoutes() {
82
+ let service = new CloudBinaryFakeService(this.webda, "fake", {});
83
+ let counter = 0;
84
+ // @ts-ignore addRoute is a protected method of service
85
+ let stub = sinon.stub(service, "addRoute").callsFake(() => {
86
+ counter++;
131
87
  });
88
+ service.initRoutes();
89
+ assert.strictEqual(counter, 0);
90
+ service.getParameters().expose = {
91
+ url: "plop",
92
+ restrict: {}
93
+ };
94
+ service.initRoutes();
95
+ assert.strictEqual(counter, 7);
96
+ counter = 0;
97
+ service.getParameters().expose = {
98
+ url: "plop",
99
+ restrict: {
100
+ get: true
101
+ }
102
+ };
103
+ service.initRoutes();
104
+ assert.strictEqual(counter, 4);
132
105
  }
133
- routes() {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- let service = new CloudBinaryFakeService(this.webda, "fake", {});
136
- let wrote;
137
- let wroteHead;
138
- let context = {
139
- parameter: name => {
140
- return name === "index" ? 1 : name;
141
- },
142
- write: (...arg) => {
143
- wrote = arg;
144
- },
145
- writeHead: (...arg) => {
146
- wroteHead = arg;
106
+ async routes() {
107
+ let service = new CloudBinaryFakeService(this.webda, "fake", {});
108
+ let wrote;
109
+ let wroteHead;
110
+ let context = {
111
+ parameter: name => {
112
+ return name === "index" ? 1 : name;
113
+ },
114
+ write: (...arg) => {
115
+ wrote = arg;
116
+ },
117
+ writeHead: (...arg) => {
118
+ wroteHead = arg;
119
+ }
120
+ };
121
+ let storeGetResult;
122
+ // @ts-ignore
123
+ sinon.stub(service, "_verifyMapAndStore").callsFake(() => {
124
+ return {
125
+ get: async () => {
126
+ return storeGetResult;
147
127
  }
148
128
  };
149
- let storeGetResult;
150
- // @ts-ignore
151
- sinon.stub(service, "_verifyMapAndStore").callsFake(() => {
152
- return {
153
- get: () => __awaiter(this, void 0, void 0, function* () {
154
- return storeGetResult;
155
- })
156
- };
157
- });
158
- yield assert.rejects(() => service.getRedirectUrl(context), /404/);
159
- storeGetResult = {
160
- property: "plop"
161
- };
162
- yield assert.rejects(() => service.getRedirectUrl(context), /404/);
163
- storeGetResult = {
164
- property: [1]
165
- };
166
- yield assert.rejects(() => service.getRedirectUrl(context), /404/);
167
- let myEvt;
168
- storeGetResult = {
169
- property: [
170
- 1,
171
- {
172
- hash: "myhash"
173
- }
174
- ],
175
- canAct: (ctx, evt) => {
176
- myEvt = evt;
177
- }
178
- };
179
- let counter = 0;
180
- service.on("Binary.Get", () => {
181
- counter++;
182
- });
183
- yield service.getRedirectUrl(context);
184
- assert.deepStrictEqual(wroteHead, [302, { Location: "myhash:30" }]);
185
- yield service.getRedirectUrlInfo(context);
186
- assert.strictEqual(counter, 2);
187
- assert.deepStrictEqual(wrote, [
129
+ });
130
+ await assert.rejects(() => service.getRedirectUrl(context), /404/);
131
+ storeGetResult = {
132
+ property: "plop"
133
+ };
134
+ await assert.rejects(() => service.getRedirectUrl(context), /404/);
135
+ storeGetResult = {
136
+ property: [1]
137
+ };
138
+ await assert.rejects(() => service.getRedirectUrl(context), /404/);
139
+ let myEvt;
140
+ storeGetResult = {
141
+ property: [
142
+ 1,
188
143
  {
189
- Location: "myhash:30",
190
- Map: {
191
- hash: "myhash"
192
- }
144
+ hash: "myhash"
193
145
  }
194
- ]);
195
- assert.strictEqual(myEvt, "get_binary");
146
+ ],
147
+ canAct: (ctx, evt) => {
148
+ myEvt = evt;
149
+ }
150
+ };
151
+ let counter = 0;
152
+ service.on("Binary.Get", () => {
153
+ counter++;
196
154
  });
155
+ await service.getRedirectUrl(context);
156
+ assert.deepStrictEqual(wroteHead, [302, { Location: "myhash:30" }]);
157
+ await service.getRedirectUrlInfo(context);
158
+ assert.strictEqual(counter, 2);
159
+ assert.deepStrictEqual(wrote, [
160
+ {
161
+ Location: "myhash:30",
162
+ Map: {
163
+ hash: "myhash"
164
+ }
165
+ }
166
+ ]);
167
+ assert.strictEqual(myEvt, "get_binary");
197
168
  }
198
169
  };
199
170
  __decorate([
200
- mocha_1.test
171
+ test
201
172
  ], FakeCloudBinaryTest.prototype, "testDefaults", null);
202
173
  __decorate([
203
- mocha_1.test
174
+ test
204
175
  ], FakeCloudBinaryTest.prototype, "initRoutes", null);
205
176
  __decorate([
206
- mocha_1.test
177
+ test
207
178
  ], FakeCloudBinaryTest.prototype, "routes", null);
208
179
  FakeCloudBinaryTest = __decorate([
209
- mocha_1.suite
180
+ suite
210
181
  ], FakeCloudBinaryTest);
211
- exports.FakeCloudBinaryTest = FakeCloudBinaryTest;
182
+ export { FakeCloudBinaryTest };
212
183
  //# sourceMappingURL=cloudbinary.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloudbinary.spec.js","sourceRoot":"","sources":["../../src/services/cloudbinary.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAA8C;AAC9C,iCAAiC;AACjC,+BAA+B;AAC/B,mDAAgD;AAChD,kCAAoC;AAGpC,+CAA2C;AAC3C,+CAAmE;AAEnE,MAAM,sBAAuB,SAAQ,yBAAW;IAC9C,KAAK,CAAC,MAAiB,EAAE,QAAgB,EAAE,IAAgB,EAAE,QAAyB;QACpF,M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AAE,YAAY,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AApHC;IADC,IAAI;uDAwBJ;AAGD;IADC,IAAI;qDAyBJ;AAGD;IADC,IAAI;iDA+DJ;AAvHU,mBAAmB;IAD/B,KAAK;GACO,mBAAmB,CAwH/B;SAxHY,mBAAmB"}
@@ -1,4 +1,4 @@
1
- import { Service, ServiceParameters } from "./service";
1
+ import { Service, ServiceParameters } from "./service.js";
2
2
  /**
3
3
  * Service that can store configuration
4
4
  */
@@ -1,26 +1,12 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ConfigurationService = exports.ConfigurationServiceParameters = void 0;
13
- const jsonpath = require("jsonpath");
14
- const core_1 = require("../core");
15
- const service_1 = require("./service");
16
- class ConfigurationServiceParameters extends service_1.ServiceParameters {
1
+ import jsonpath from "jsonpath";
2
+ import { WebdaError } from "../core.js";
3
+ import { Service, ServiceParameters } from "./service.js";
4
+ export class ConfigurationServiceParameters extends ServiceParameters {
17
5
  constructor(params) {
18
- var _a;
19
6
  super(params);
20
- (_a = this.checkInterval) !== null && _a !== void 0 ? _a : (this.checkInterval = 3600);
7
+ this.checkInterval ?? (this.checkInterval = 3600);
21
8
  }
22
9
  }
23
- exports.ConfigurationServiceParameters = ConfigurationServiceParameters;
24
10
  /**
25
11
  * Handle sessionSecret ( rolling between two secrets ) expire every hour
26
12
  * Handle longTermSecret ( rolling between two longer secret ) expire every month
@@ -33,7 +19,7 @@ exports.ConfigurationServiceParameters = ConfigurationServiceParameters;
33
19
  * @category CoreServices
34
20
  * @WebdaModda
35
21
  */
36
- class ConfigurationService extends service_1.Service {
22
+ export default class ConfigurationService extends Service {
37
23
  constructor() {
38
24
  super(...arguments);
39
25
  /**
@@ -53,33 +39,31 @@ class ConfigurationService extends service_1.Service {
53
39
  /**
54
40
  * @inheritdoc
55
41
  */
56
- init() {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- // Check interval by default every hour
59
- if (!this.parameters.source) {
60
- throw new core_1.WebdaError("CONFIGURATION_SOURCE_MISSING", "Need a source for ConfigurationService");
61
- }
62
- let source = this.parameters.source.split(":");
63
- this.sourceService = this.getService(source[0]);
64
- if (!this.sourceService) {
65
- throw new core_1.WebdaError("CONFIGURATION_SOURCE_INVALID", 'Need a valid service for source ("sourceService:sourceId")');
66
- }
67
- this.sourceId = source[1];
68
- if (!this.sourceId) {
69
- throw new core_1.WebdaError("CONFIGURATION_SOURCE_INVALID", 'Need a valid source ("sourceService:sourceId")');
70
- }
71
- if (!this.sourceService.getConfiguration) {
72
- throw new core_1.WebdaError("CONFIGURATION_SOURCE_INVALID", `Service '${source[0]}' is not implementing ConfigurationProvider interface`);
73
- }
74
- this.serializedConfiguration = JSON.stringify(this.parameters.default);
75
- yield this.checkUpdate();
76
- if (!this.sourceService.canTriggerConfiguration(this.sourceId, this.checkUpdate.bind(this, true))) {
77
- this.interval = setInterval(this.checkUpdate.bind(this), 1000);
78
- }
79
- // Add webda info
80
- this.watch("$.webda.services", this._webda.reinit.bind(this._webda));
81
- return this;
82
- });
42
+ async init() {
43
+ // Check interval by default every hour
44
+ if (!this.parameters.source) {
45
+ throw new WebdaError("CONFIGURATION_SOURCE_MISSING", "Need a source for ConfigurationService");
46
+ }
47
+ let source = this.parameters.source.split(":");
48
+ this.sourceService = this.getService(source[0]);
49
+ if (!this.sourceService) {
50
+ throw new WebdaError("CONFIGURATION_SOURCE_INVALID", 'Need a valid service for source ("sourceService:sourceId")');
51
+ }
52
+ this.sourceId = source[1];
53
+ if (!this.sourceId) {
54
+ throw new WebdaError("CONFIGURATION_SOURCE_INVALID", 'Need a valid source ("sourceService:sourceId")');
55
+ }
56
+ if (!this.sourceService.getConfiguration) {
57
+ throw new WebdaError("CONFIGURATION_SOURCE_INVALID", `Service '${source[0]}' is not implementing ConfigurationProvider interface`);
58
+ }
59
+ this.serializedConfiguration = JSON.stringify(this.parameters.default);
60
+ await this.checkUpdate();
61
+ if (!this.sourceService.canTriggerConfiguration(this.sourceId, this.checkUpdate.bind(this, true))) {
62
+ this.interval = setInterval(this.checkUpdate.bind(this), 1000);
63
+ }
64
+ // Add webda info
65
+ this.watch("$.webda.services", this._webda.reinit.bind(this._webda));
66
+ return this;
83
67
  }
84
68
  /**
85
69
  * Watch a specific configuration modification
@@ -112,25 +96,19 @@ class ConfigurationService extends service_1.Service {
112
96
  *
113
97
  * @inheritdoc
114
98
  */
115
- reinit(_config) {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- // Need to prevent any reinit
118
- return this;
119
- });
99
+ async reinit(_config) {
100
+ // Need to prevent any reinit
101
+ return this;
120
102
  }
121
103
  /**
122
104
  * Load the configuration by calling the source service with the source id
123
105
  * @returns
124
106
  */
125
- loadConfiguration() {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- return this.sourceService.getConfiguration(this.sourceId);
128
- });
107
+ async loadConfiguration() {
108
+ return this.sourceService.getConfiguration(this.sourceId);
129
109
  }
130
- initConfiguration() {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- throw new Error("ConfigurationService with dependencies cannot be used");
133
- });
110
+ async initConfiguration() {
111
+ throw new Error("ConfigurationService with dependencies cannot be used");
134
112
  }
135
113
  /**
136
114
  * Checking for configuration updates
@@ -139,46 +117,44 @@ class ConfigurationService extends service_1.Service {
139
117
  *
140
118
  * @returns
141
119
  */
142
- checkUpdate(dynamic = false) {
143
- return __awaiter(this, void 0, void 0, function* () {
144
- // If the ConfigurationProvider cannot trigger we check at interval
145
- if (!dynamic && this.interval && this.nextCheck > Date.now()) {
146
- return;
147
- }
148
- this.log("DEBUG", "Refreshing configuration");
149
- const newConfig = (yield this.loadConfiguration()) || this.parameters.default;
150
- const serializedConfig = JSON.stringify(newConfig);
151
- if (serializedConfig !== this.serializedConfiguration) {
152
- this.emit("Configuration.Applying", undefined);
153
- this.log("DEBUG", "Apply new configuration");
154
- this.serializedConfiguration = serializedConfig;
155
- this.configuration = newConfig;
156
- // Add the webda parameters logical
157
- if (this.configuration.webda && this.configuration.webda.services) {
158
- // Merge parameters with each service
159
- for (let i in this.configuration.webda.services) {
160
- if (this.getWebda().getService(i)) {
161
- this.configuration.webda.services[i] = this.getWebda().getServiceParams(i, this.configuration.webda);
162
- }
120
+ async checkUpdate(dynamic = false) {
121
+ // If the ConfigurationProvider cannot trigger we check at interval
122
+ if (!dynamic && this.interval && this.nextCheck > Date.now()) {
123
+ return;
124
+ }
125
+ this.log("DEBUG", "Refreshing configuration");
126
+ const newConfig = (await this.loadConfiguration()) || this.parameters.default;
127
+ const serializedConfig = JSON.stringify(newConfig);
128
+ if (serializedConfig !== this.serializedConfiguration) {
129
+ this.emit("Configuration.Applying", undefined);
130
+ this.log("DEBUG", "Apply new configuration");
131
+ this.serializedConfiguration = serializedConfig;
132
+ this.configuration = newConfig;
133
+ // Add the webda parameters logical
134
+ if (this.configuration.webda && this.configuration.webda.services) {
135
+ // Merge parameters with each service
136
+ for (let i in this.configuration.webda.services) {
137
+ if (this.getWebda().getService(i)) {
138
+ this.configuration.webda.services[i] = this.getWebda().getServiceParams(i, this.configuration.webda);
163
139
  }
164
140
  }
165
- let promises = [];
166
- this.watchs.forEach(w => {
167
- this.log("TRACE", "Apply new configuration value", jsonpath.query(newConfig, w.path).pop() || w.defaultValue);
168
- let p = w.callback(jsonpath.query(newConfig, w.path).pop() || w.defaultValue);
169
- if (p) {
170
- promises.push(p);
171
- }
172
- });
173
- yield Promise.all(promises);
174
- this.emit("Configuration.Applied", undefined);
175
141
  }
176
- // If the ConfigurationProvider cannot trigger we check at interval
177
- if (this.interval) {
178
- this.updateNextCheck();
179
- this.log("DEBUG", "Next configuration refresh in", this.parameters.checkInterval, "s");
180
- }
181
- });
142
+ let promises = [];
143
+ this.watchs.forEach(w => {
144
+ this.log("TRACE", "Apply new configuration value", jsonpath.query(newConfig, w.path).pop() || w.defaultValue);
145
+ let p = w.callback(jsonpath.query(newConfig, w.path).pop() || w.defaultValue);
146
+ if (p) {
147
+ promises.push(p);
148
+ }
149
+ });
150
+ await Promise.all(promises);
151
+ this.emit("Configuration.Applied", undefined);
152
+ }
153
+ // If the ConfigurationProvider cannot trigger we check at interval
154
+ if (this.interval) {
155
+ this.updateNextCheck();
156
+ this.log("DEBUG", "Next configuration refresh in", this.parameters.checkInterval, "s");
157
+ }
182
158
  }
183
159
  /**
184
160
  * Update the next check time
@@ -189,14 +165,11 @@ class ConfigurationService extends service_1.Service {
189
165
  /**
190
166
  * Read the file and store it
191
167
  */
192
- loadAndStoreConfiguration() {
193
- return __awaiter(this, void 0, void 0, function* () {
194
- let res = yield this.loadConfiguration();
195
- this.serializedConfiguration = JSON.stringify(res);
196
- return res;
197
- });
168
+ async loadAndStoreConfiguration() {
169
+ let res = await this.loadConfiguration();
170
+ this.serializedConfiguration = JSON.stringify(res);
171
+ return res;
198
172
  }
199
173
  }
200
- exports.default = ConfigurationService;
201
- exports.ConfigurationService = ConfigurationService;
174
+ export { ConfigurationService };
202
175
  //# sourceMappingURL=configuration.js.map