remult 0.21.0 → 0.21.1-exp.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 (326) hide show
  1. package/SseSubscriptionServer.d.ts +25 -25
  2. package/SseSubscriptionServer.js +145 -145
  3. package/ably.d.ts +13 -13
  4. package/ably.js +59 -59
  5. package/assign.d.ts +1 -1
  6. package/assign.js +9 -9
  7. package/classType.d.ts +3 -3
  8. package/classType.js +2 -2
  9. package/esm/SseSubscriptionServer.d.ts +25 -25
  10. package/esm/SseSubscriptionServer.js +107 -104
  11. package/esm/ably.d.ts +13 -13
  12. package/esm/ably.js +30 -28
  13. package/esm/assign.d.ts +1 -1
  14. package/esm/assign.js +5 -5
  15. package/esm/classType.d.ts +3 -3
  16. package/esm/classType.js +1 -1
  17. package/esm/graphql.d.ts +14 -14
  18. package/esm/graphql.js +660 -662
  19. package/esm/index.d.ts +27 -27
  20. package/esm/index.js +25 -25
  21. package/esm/inputTypes.d.ts +9 -9
  22. package/esm/inputTypes.js +9 -9
  23. package/esm/live-query/data-provider-live-query-storage.d.ts +22 -22
  24. package/esm/live-query/data-provider-live-query-storage.js +86 -89
  25. package/esm/myLog.d.ts +1 -1
  26. package/esm/myLog.js +5 -5
  27. package/esm/postgres/index.d.ts +2 -2
  28. package/esm/postgres/index.js +2 -2
  29. package/esm/postgres/postgres-data-provider.d.ts +36 -36
  30. package/esm/postgres/postgres-data-provider.js +118 -114
  31. package/esm/postgres/schema-builder.d.ts +16 -16
  32. package/esm/postgres/schema-builder.js +149 -148
  33. package/esm/remult-express.d.ts +9 -9
  34. package/esm/remult-express.js +26 -25
  35. package/esm/remult-fastify.d.ts +6 -6
  36. package/esm/remult-fastify.js +66 -66
  37. package/esm/remult-fresh.d.ts +17 -17
  38. package/esm/remult-fresh.js +29 -29
  39. package/esm/remult-knex/index.d.ts +29 -29
  40. package/esm/remult-knex/index.js +440 -434
  41. package/esm/remult-mongo.d.ts +24 -24
  42. package/esm/remult-mongo.js +254 -247
  43. package/esm/remult-next.d.ts +25 -25
  44. package/esm/remult-next.js +108 -108
  45. package/esm/remult-sveltekit.d.ts +4 -4
  46. package/esm/remult-sveltekit.js +70 -71
  47. package/esm/server/JsonEntityFileStorage.d.ts +10 -10
  48. package/esm/server/JsonEntityFileStorage.js +25 -24
  49. package/esm/server/core.d.ts +4 -4
  50. package/esm/server/core.js +4 -4
  51. package/esm/server/expressBridge.d.ts +135 -135
  52. package/esm/server/expressBridge.js +997 -981
  53. package/esm/server/index.d.ts +6 -6
  54. package/esm/server/index.js +9 -9
  55. package/esm/server/initAsyncHooks.d.ts +1 -1
  56. package/esm/server/initAsyncHooks.js +9 -9
  57. package/esm/server/initDataProvider.d.ts +2 -2
  58. package/esm/server/initDataProvider.js +14 -14
  59. package/esm/src/__EntityValueProvider.d.ts +11 -11
  60. package/esm/src/__EntityValueProvider.js +1 -1
  61. package/esm/src/__RowsOfDataForTesting.d.ts +3 -3
  62. package/esm/src/__RowsOfDataForTesting.js +1 -1
  63. package/esm/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +6 -6
  64. package/esm/src/backend-tests/backend-database-test-setup.backend-spec.js +147 -147
  65. package/esm/src/buildRestDataProvider.d.ts +31 -31
  66. package/esm/src/buildRestDataProvider.js +113 -112
  67. package/esm/src/column-interfaces.d.ts +154 -154
  68. package/esm/src/column-interfaces.js +7 -7
  69. package/esm/src/column.d.ts +54 -54
  70. package/esm/src/column.js +164 -145
  71. package/esm/src/context.d.ts +117 -117
  72. package/esm/src/context.js +245 -241
  73. package/esm/src/data-api.d.ts +39 -39
  74. package/esm/src/data-api.js +279 -277
  75. package/esm/src/data-interfaces.d.ts +41 -41
  76. package/esm/src/data-interfaces.js +12 -12
  77. package/esm/src/data-providers/array-entity-data-provider.d.ts +22 -22
  78. package/esm/src/data-providers/array-entity-data-provider.js +252 -249
  79. package/esm/src/data-providers/in-memory-database.d.ts +9 -9
  80. package/esm/src/data-providers/in-memory-database.js +14 -16
  81. package/esm/src/data-providers/json-data-provider.d.ts +12 -12
  82. package/esm/src/data-providers/json-data-provider.js +55 -52
  83. package/esm/src/data-providers/rest-data-provider.d.ts +39 -39
  84. package/esm/src/data-providers/rest-data-provider.js +256 -251
  85. package/esm/src/data-providers/sql-database.d.ts +32 -32
  86. package/esm/src/data-providers/sql-database.js +384 -377
  87. package/esm/src/data-providers/web-sql-data-provider.d.ts +21 -21
  88. package/esm/src/data-providers/web-sql-data-provider.js +143 -135
  89. package/esm/src/entity.d.ts +91 -91
  90. package/esm/src/entity.js +1 -1
  91. package/esm/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -50
  92. package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +150 -147
  93. package/esm/src/filter/filter-consumer-bridge-to-url-builder.d.ts +1 -1
  94. package/esm/src/filter/filter-consumer-bridge-to-url-builder.js +1 -1
  95. package/esm/src/filter/filter-interfaces.d.ts +85 -85
  96. package/esm/src/filter/filter-interfaces.js +477 -472
  97. package/esm/src/live-query/LiveQueryClient.d.ts +1 -1
  98. package/esm/src/live-query/LiveQueryClient.js +188 -184
  99. package/esm/src/live-query/SseSubscriptionClient.d.ts +5 -5
  100. package/esm/src/live-query/SseSubscriptionClient.js +86 -86
  101. package/esm/src/live-query/SubscriptionChannel.d.ts +41 -41
  102. package/esm/src/live-query/SubscriptionChannel.js +123 -118
  103. package/esm/src/live-query/SubscriptionServer.d.ts +38 -38
  104. package/esm/src/live-query/SubscriptionServer.js +111 -108
  105. package/esm/src/remult-proxy.d.ts +2 -2
  106. package/esm/src/remult-proxy.js +112 -113
  107. package/esm/src/remult3/DecoratorReplacer.d.ts +10 -10
  108. package/esm/src/remult3/DecoratorReplacer.js +20 -20
  109. package/esm/src/remult3/RepositoryImplementation.d.ts +349 -353
  110. package/esm/src/remult3/RepositoryImplementation.js +2078 -2008
  111. package/esm/src/remult3/index.d.ts +2 -2
  112. package/esm/src/remult3/index.js +2 -2
  113. package/esm/src/remult3/remult3.d.ts +392 -392
  114. package/esm/src/remult3/remult3.js +2 -2
  115. package/esm/src/server-action.d.ts +81 -81
  116. package/esm/src/server-action.js +394 -371
  117. package/esm/src/shared-tests/db-tests-setup.d.ts +32 -32
  118. package/esm/src/shared-tests/db-tests-setup.js +78 -78
  119. package/esm/src/shared-tests/db-tests.db-tests.d.ts +25 -25
  120. package/esm/src/shared-tests/db-tests.db-tests.js +886 -906
  121. package/esm/src/shared-tests/deleteAll.d.ts +2 -2
  122. package/esm/src/shared-tests/deleteAll.js +4 -4
  123. package/esm/src/shared-tests/entityWithValidations.d.ts +14 -14
  124. package/esm/src/shared-tests/entityWithValidations.js +56 -53
  125. package/esm/src/shared-tests/index.d.ts +4 -4
  126. package/esm/src/shared-tests/index.js +4 -4
  127. package/esm/src/shared-tests/test-custom-id-column.spec.d.ts +1 -1
  128. package/esm/src/shared-tests/test-custom-id-column.spec.js +67 -63
  129. package/esm/src/shared-tests/test-special-value.spec.d.ts +10 -10
  130. package/esm/src/shared-tests/test-special-value.spec.js +86 -88
  131. package/esm/src/shared-tests/test-update-with-null.spec.d.ts +1 -1
  132. package/esm/src/shared-tests/test-update-with-null.spec.js +43 -45
  133. package/esm/src/sort.d.ts +16 -16
  134. package/esm/src/sort.js +103 -102
  135. package/esm/src/sql-command.d.ts +19 -19
  136. package/esm/src/sql-command.js +1 -1
  137. package/esm/src/tests/Done.d.ts +5 -5
  138. package/esm/src/tests/Done.js +9 -11
  139. package/esm/src/tests/TestDataApiResponse.d.ts +10 -10
  140. package/esm/src/tests/TestDataApiResponse.js +22 -22
  141. package/esm/src/tests/c.d.ts +8 -8
  142. package/esm/src/tests/c.js +24 -22
  143. package/esm/src/tests/createData.d.ts +7 -7
  144. package/esm/src/tests/createData.js +22 -22
  145. package/esm/src/tests/d.d.ts +6 -6
  146. package/esm/src/tests/d.js +20 -19
  147. package/esm/src/tests/dWithPrefilter.d.ts +7 -7
  148. package/esm/src/tests/dWithPrefilter.js +34 -32
  149. package/esm/src/tests/entityForCustomFilter.d.ts +16 -16
  150. package/esm/src/tests/entityForCustomFilter.js +43 -43
  151. package/esm/src/tests/entityWithValidationsOnColumn.d.ts +5 -5
  152. package/esm/src/tests/entityWithValidationsOnColumn.js +22 -21
  153. package/esm/src/tests/frontend-database-tests-setup.spec.d.ts +4 -4
  154. package/esm/src/tests/frontend-database-tests-setup.spec.js +37 -37
  155. package/esm/src/tests/h.d.ts +6 -6
  156. package/esm/src/tests/h.js +37 -35
  157. package/esm/src/tests/remult-3-entities.d.ts +23 -23
  158. package/esm/src/tests/remult-3-entities.js +77 -72
  159. package/esm/src/tests/tasks.d.ts +6 -6
  160. package/esm/src/tests/tasks.js +22 -24
  161. package/esm/src/tests/testHelper.spec.d.ts +36 -36
  162. package/esm/src/tests/testHelper.spec.js +226 -225
  163. package/esm/src/tests/testModel/models.d.ts +16 -16
  164. package/esm/src/tests/testModel/models.js +35 -31
  165. package/esm/src/validators.d.ts +14 -14
  166. package/esm/src/validators.js +33 -33
  167. package/esm/src/valueConverters.d.ts +13 -13
  168. package/esm/src/valueConverters.js +197 -197
  169. package/esm/urlBuilder.d.ts +6 -6
  170. package/esm/urlBuilder.js +20 -19
  171. package/graphql.d.ts +14 -14
  172. package/graphql.js +837 -839
  173. package/index.d.ts +27 -27
  174. package/index.js +67 -67
  175. package/inputTypes.d.ts +9 -9
  176. package/inputTypes.js +15 -16
  177. package/live-query/data-provider-live-query-storage.d.ts +22 -22
  178. package/live-query/data-provider-live-query-storage.js +259 -259
  179. package/myLog.d.ts +1 -1
  180. package/myLog.js +20 -20
  181. package/package.json +1 -1
  182. package/postgres/index.d.ts +2 -2
  183. package/postgres/index.js +5 -5
  184. package/postgres/postgres-data-provider.d.ts +36 -36
  185. package/postgres/postgres-data-provider.js +184 -184
  186. package/postgres/schema-builder.d.ts +16 -16
  187. package/postgres/schema-builder.js +320 -321
  188. package/projects/core/package.json +153 -0
  189. package/remult-express.d.ts +9 -9
  190. package/remult-express.js +34 -33
  191. package/remult-fastify.d.ts +6 -6
  192. package/remult-fastify.js +81 -79
  193. package/remult-fresh.d.ts +17 -17
  194. package/remult-fresh.js +44 -44
  195. package/remult-knex/index.d.ts +29 -29
  196. package/remult-knex/index.js +891 -892
  197. package/remult-mongo.d.ts +24 -24
  198. package/remult-mongo.js +498 -498
  199. package/remult-next.d.ts +25 -25
  200. package/remult-next.js +167 -167
  201. package/remult-sveltekit.d.ts +4 -4
  202. package/remult-sveltekit.js +111 -111
  203. package/server/JsonEntityFileStorage.d.ts +10 -10
  204. package/server/JsonEntityFileStorage.js +35 -35
  205. package/server/core.d.ts +4 -4
  206. package/server/core.js +12 -12
  207. package/server/expressBridge.d.ts +135 -135
  208. package/server/expressBridge.js +1397 -1400
  209. package/server/index.d.ts +6 -6
  210. package/server/index.js +21 -21
  211. package/server/initAsyncHooks.d.ts +1 -1
  212. package/server/initAsyncHooks.js +13 -13
  213. package/server/initDataProvider.d.ts +2 -2
  214. package/server/initDataProvider.js +26 -26
  215. package/src/__EntityValueProvider.d.ts +11 -11
  216. package/src/__EntityValueProvider.js +2 -2
  217. package/src/__RowsOfDataForTesting.d.ts +3 -3
  218. package/src/__RowsOfDataForTesting.js +2 -2
  219. package/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +6 -6
  220. package/src/backend-tests/backend-database-test-setup.backend-spec.js +311 -306
  221. package/src/buildRestDataProvider.d.ts +31 -31
  222. package/src/buildRestDataProvider.js +169 -166
  223. package/src/column-interfaces.d.ts +154 -154
  224. package/src/column-interfaces.js +11 -11
  225. package/src/column.d.ts +54 -54
  226. package/src/column.js +187 -187
  227. package/src/context.d.ts +117 -117
  228. package/src/context.js +406 -408
  229. package/src/data-api.d.ts +39 -39
  230. package/src/data-api.js +525 -526
  231. package/src/data-interfaces.d.ts +41 -41
  232. package/src/data-interfaces.js +16 -16
  233. package/src/data-providers/array-entity-data-provider.d.ts +22 -22
  234. package/src/data-providers/array-entity-data-provider.js +364 -364
  235. package/src/data-providers/in-memory-database.d.ts +9 -9
  236. package/src/data-providers/in-memory-database.js +31 -31
  237. package/src/data-providers/json-data-provider.d.ts +12 -12
  238. package/src/data-providers/json-data-provider.js +88 -88
  239. package/src/data-providers/rest-data-provider.d.ts +39 -39
  240. package/src/data-providers/rest-data-provider.js +373 -373
  241. package/src/data-providers/sql-database.d.ts +32 -32
  242. package/src/data-providers/sql-database.js +635 -636
  243. package/src/data-providers/web-sql-data-provider.d.ts +21 -21
  244. package/src/data-providers/web-sql-data-provider.js +227 -227
  245. package/src/entity.d.ts +91 -91
  246. package/src/entity.js +2 -2
  247. package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -50
  248. package/src/filter/filter-consumer-bridge-to-sql-request.js +290 -290
  249. package/src/filter/filter-consumer-bridge-to-url-builder.d.ts +1 -1
  250. package/src/filter/filter-consumer-bridge-to-url-builder.js +2 -2
  251. package/src/filter/filter-interfaces.d.ts +85 -85
  252. package/src/filter/filter-interfaces.js +638 -635
  253. package/src/live-query/LiveQueryClient.d.ts +1 -1
  254. package/src/live-query/LiveQueryClient.js +283 -283
  255. package/src/live-query/SseSubscriptionClient.d.ts +5 -5
  256. package/src/live-query/SseSubscriptionClient.js +150 -150
  257. package/src/live-query/SubscriptionChannel.d.ts +41 -41
  258. package/src/live-query/SubscriptionChannel.js +180 -180
  259. package/src/live-query/SubscriptionServer.d.ts +38 -38
  260. package/src/live-query/SubscriptionServer.js +258 -258
  261. package/src/remult-proxy.d.ts +2 -2
  262. package/src/remult-proxy.js +251 -251
  263. package/src/remult3/DecoratorReplacer.d.ts +10 -10
  264. package/src/remult3/DecoratorReplacer.js +24 -24
  265. package/src/remult3/RepositoryImplementation.d.ts +349 -353
  266. package/src/remult3/RepositoryImplementation.js +3346 -3332
  267. package/src/remult3/index.d.ts +2 -2
  268. package/src/remult3/index.js +5 -5
  269. package/src/remult3/remult3.d.ts +392 -392
  270. package/src/remult3/remult3.js +3 -3
  271. package/src/server-action.d.ts +81 -81
  272. package/src/server-action.js +624 -612
  273. package/src/shared-tests/db-tests-setup.d.ts +32 -32
  274. package/src/shared-tests/db-tests-setup.js +183 -183
  275. package/src/shared-tests/db-tests.db-tests.d.ts +25 -25
  276. package/src/shared-tests/db-tests.db-tests.js +2018 -2017
  277. package/src/shared-tests/deleteAll.d.ts +2 -2
  278. package/src/shared-tests/deleteAll.js +21 -21
  279. package/src/shared-tests/entityWithValidations.d.ts +14 -14
  280. package/src/shared-tests/entityWithValidations.js +79 -80
  281. package/src/shared-tests/index.d.ts +4 -4
  282. package/src/shared-tests/index.js +6 -6
  283. package/src/shared-tests/test-custom-id-column.spec.d.ts +1 -1
  284. package/src/shared-tests/test-custom-id-column.spec.js +111 -111
  285. package/src/shared-tests/test-special-value.spec.d.ts +10 -10
  286. package/src/shared-tests/test-special-value.spec.js +127 -128
  287. package/src/shared-tests/test-update-with-null.spec.d.ts +1 -1
  288. package/src/shared-tests/test-update-with-null.spec.js +87 -87
  289. package/src/sort.d.ts +16 -16
  290. package/src/sort.js +159 -159
  291. package/src/sql-command.d.ts +19 -19
  292. package/src/sql-command.js +2 -2
  293. package/src/tests/Done.d.ts +5 -5
  294. package/src/tests/Done.js +17 -17
  295. package/src/tests/TestDataApiResponse.d.ts +10 -10
  296. package/src/tests/TestDataApiResponse.js +29 -29
  297. package/src/tests/c.d.ts +8 -8
  298. package/src/tests/c.js +27 -28
  299. package/src/tests/createData.d.ts +7 -7
  300. package/src/tests/createData.js +50 -50
  301. package/src/tests/d.d.ts +6 -6
  302. package/src/tests/d.js +26 -27
  303. package/src/tests/dWithPrefilter.d.ts +7 -7
  304. package/src/tests/dWithPrefilter.js +44 -45
  305. package/src/tests/entityForCustomFilter.d.ts +16 -16
  306. package/src/tests/entityForCustomFilter.js +65 -67
  307. package/src/tests/entityWithValidationsOnColumn.d.ts +5 -5
  308. package/src/tests/entityWithValidationsOnColumn.js +28 -29
  309. package/src/tests/frontend-database-tests-setup.spec.d.ts +4 -4
  310. package/src/tests/frontend-database-tests-setup.spec.js +100 -100
  311. package/src/tests/h.d.ts +6 -6
  312. package/src/tests/h.js +43 -44
  313. package/src/tests/remult-3-entities.d.ts +23 -23
  314. package/src/tests/remult-3-entities.js +79 -81
  315. package/src/tests/tasks.d.ts +6 -6
  316. package/src/tests/tasks.js +29 -30
  317. package/src/tests/testHelper.spec.d.ts +36 -36
  318. package/src/tests/testHelper.spec.js +384 -384
  319. package/src/tests/testModel/models.d.ts +16 -16
  320. package/src/tests/testModel/models.js +37 -39
  321. package/src/validators.d.ts +14 -14
  322. package/src/validators.js +61 -60
  323. package/src/valueConverters.d.ts +13 -13
  324. package/src/valueConverters.js +195 -196
  325. package/urlBuilder.d.ts +6 -6
  326. package/urlBuilder.js +25 -25
@@ -1,25 +1,25 @@
1
- /// <reference types="node" />
2
- import { GenericResponse } from './server/index';
3
- import { Remult } from './src/context';
4
- import { SubscriptionServer } from './src/live-query/SubscriptionServer';
5
- export declare class SseSubscriptionServer implements SubscriptionServer {
6
- private canUserConnectToChannel?;
7
- constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
8
- publishMessage<T>(channel: string, message: any): Promise<void>;
9
- }
10
- export interface ResponseRequiredForSSE {
11
- write(data: string): void;
12
- writeHead(status: number, headers: any): void;
13
- flush?(): void;
14
- }
15
- export declare class clientConnection {
16
- response: GenericResponse & ResponseRequiredForSSE;
17
- channels: Record<string, boolean>;
18
- timeOutRef: NodeJS.Timeout;
19
- close(): void;
20
- closed: boolean;
21
- write(eventData: string, eventType?: string): void;
22
- connectionId: any;
23
- constructor(response: GenericResponse & ResponseRequiredForSSE);
24
- sendLiveMessage(): void;
25
- }
1
+ /// <reference types="node" />
2
+ import { GenericResponse } from './server/index';
3
+ import { Remult } from './src/context';
4
+ import { SubscriptionServer } from './src/live-query/SubscriptionServer';
5
+ export declare class SseSubscriptionServer implements SubscriptionServer {
6
+ private canUserConnectToChannel?;
7
+ constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
8
+ publishMessage<T>(channel: string, message: any): Promise<void>;
9
+ }
10
+ export interface ResponseRequiredForSSE {
11
+ write(data: string): void;
12
+ writeHead(status: number, headers: any): void;
13
+ flush?(): void;
14
+ }
15
+ export declare class clientConnection {
16
+ response: GenericResponse & ResponseRequiredForSSE;
17
+ channels: Record<string, boolean>;
18
+ timeOutRef: NodeJS.Timeout;
19
+ close(): void;
20
+ closed: boolean;
21
+ write(eventData: string, eventType?: string): void;
22
+ connectionId: any;
23
+ constructor(response: GenericResponse & ResponseRequiredForSSE);
24
+ sendLiveMessage(): void;
25
+ }
@@ -1,145 +1,145 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clientConnection = exports.SseSubscriptionServer = void 0;
4
- var tslib_1 = require("tslib");
5
- var uuid_1 = require("uuid");
6
- var SseSubscriptionClient_1 = require("./src/live-query/SseSubscriptionClient");
7
- var SseSubscriptionServer = /** @class */ (function () {
8
- function SseSubscriptionServer(canUserConnectToChannel) {
9
- this.canUserConnectToChannel = canUserConnectToChannel;
10
- //@internal
11
- this.connections = [];
12
- //@internal
13
- this.debugMessageFileSaver = function (id, channel, message) { };
14
- //@internal
15
- this.debugFileSaver = function () { };
16
- if (!this.canUserConnectToChannel) {
17
- this.canUserConnectToChannel = function () { return true; };
18
- }
19
- }
20
- //@internal
21
- SseSubscriptionServer.prototype.subscribeToChannel = function (_a, res, remult, remove) {
22
- var e_1, _b;
23
- var channel = _a.channel, clientId = _a.clientId;
24
- if (remove === void 0) { remove = false; }
25
- try {
26
- for (var _c = tslib_1.__values(this.connections), _d = _c.next(); !_d.done; _d = _c.next()) {
27
- var c = _d.value;
28
- if (c.connectionId === clientId) {
29
- if (this.canUserConnectToChannel(channel, remult)) {
30
- if (remove)
31
- delete c.channels[channel];
32
- else
33
- c.channels[channel] = true;
34
- res.success({ status: "ok" });
35
- this.debug();
36
- return;
37
- }
38
- else {
39
- res.forbidden();
40
- this.debug();
41
- return;
42
- }
43
- }
44
- }
45
- }
46
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
47
- finally {
48
- try {
49
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
50
- }
51
- finally { if (e_1) throw e_1.error; }
52
- }
53
- res.success(SseSubscriptionClient_1.ConnectionNotFoundError);
54
- };
55
- SseSubscriptionServer.prototype.publishMessage = function (channel, message) {
56
- return tslib_1.__awaiter(this, void 0, void 0, function () {
57
- var data, _a, _b, sc;
58
- var e_2, _c;
59
- return tslib_1.__generator(this, function (_d) {
60
- data = JSON.stringify({ channel: channel, data: message });
61
- try {
62
- for (_a = tslib_1.__values(this.connections), _b = _a.next(); !_b.done; _b = _a.next()) {
63
- sc = _b.value;
64
- if (sc.channels[channel]) {
65
- this.debugMessageFileSaver(sc.connectionId, channel, message);
66
- sc.write(data);
67
- }
68
- }
69
- }
70
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
71
- finally {
72
- try {
73
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
74
- }
75
- finally { if (e_2) throw e_2.error; }
76
- }
77
- return [2 /*return*/];
78
- });
79
- });
80
- };
81
- //@internal
82
- SseSubscriptionServer.prototype.openHttpServerStream = function (req, res) {
83
- var _this = this;
84
- res.writeHead(200, {
85
- 'Content-Type': 'text/event-stream',
86
- 'Cache-Control': 'no-cache',
87
- 'Connection': 'keep-alive'
88
- });
89
- var cc = new clientConnection(res);
90
- //const lastEventId = req.headers['last-event-id'];
91
- this.connections.push(cc);
92
- this.debug();
93
- //@ts-ignore
94
- req.on("close", function () {
95
- cc.close();
96
- _this.connections = _this.connections.filter(function (s) { return s !== cc; });
97
- _this.debug();
98
- });
99
- return cc;
100
- };
101
- //@internal
102
- SseSubscriptionServer.prototype.debug = function () {
103
- this.debugFileSaver(this.connections.map(function (x) { return ({
104
- id: x.connectionId,
105
- channels: x.channels
106
- }); }));
107
- };
108
- return SseSubscriptionServer;
109
- }());
110
- exports.SseSubscriptionServer = SseSubscriptionServer;
111
- var clientConnection = /** @class */ (function () {
112
- function clientConnection(response) {
113
- this.response = response;
114
- this.channels = {};
115
- this.closed = false;
116
- this.connectionId = uuid_1.v4();
117
- this.write(this.connectionId, "connectionId");
118
- this.sendLiveMessage();
119
- }
120
- clientConnection.prototype.close = function () {
121
- if (this.timeOutRef)
122
- clearTimeout(this.timeOutRef);
123
- this.closed = true;
124
- };
125
- clientConnection.prototype.write = function (eventData, eventType) {
126
- if (eventType === void 0) { eventType = "message"; }
127
- var event = "event:" + eventType;
128
- // if (id != undefined)
129
- // event += "\nid:" + id;
130
- this.response.write(event + "\ndata:" + eventData + "\n\n");
131
- if (this.response.flush)
132
- this.response.flush();
133
- };
134
- clientConnection.prototype.sendLiveMessage = function () {
135
- var _this = this;
136
- if (this.closed)
137
- return;
138
- this.write("", "keep-alive");
139
- this.timeOutRef = setTimeout(function () {
140
- _this.sendLiveMessage();
141
- }, 45000);
142
- };
143
- return clientConnection;
144
- }());
145
- exports.clientConnection = clientConnection;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clientConnection = exports.SseSubscriptionServer = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var uuid_1 = require("uuid");
6
+ var SseSubscriptionClient_1 = require("./src/live-query/SseSubscriptionClient");
7
+ var SseSubscriptionServer = /** @class */ (function () {
8
+ function SseSubscriptionServer(canUserConnectToChannel) {
9
+ this.canUserConnectToChannel = canUserConnectToChannel;
10
+ //@internal
11
+ this.connections = [];
12
+ //@internal
13
+ this.debugMessageFileSaver = function (id, channel, message) { };
14
+ //@internal
15
+ this.debugFileSaver = function () { };
16
+ if (!this.canUserConnectToChannel) {
17
+ this.canUserConnectToChannel = function () { return true; };
18
+ }
19
+ }
20
+ //@internal
21
+ SseSubscriptionServer.prototype.subscribeToChannel = function (_a, res, remult, remove) {
22
+ var e_1, _b;
23
+ var channel = _a.channel, clientId = _a.clientId;
24
+ if (remove === void 0) { remove = false; }
25
+ try {
26
+ for (var _c = tslib_1.__values(this.connections), _d = _c.next(); !_d.done; _d = _c.next()) {
27
+ var c = _d.value;
28
+ if (c.connectionId === clientId) {
29
+ if (this.canUserConnectToChannel(channel, remult)) {
30
+ if (remove)
31
+ delete c.channels[channel];
32
+ else
33
+ c.channels[channel] = true;
34
+ res.success({ status: "ok" });
35
+ this.debug();
36
+ return;
37
+ }
38
+ else {
39
+ res.forbidden();
40
+ this.debug();
41
+ return;
42
+ }
43
+ }
44
+ }
45
+ }
46
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
47
+ finally {
48
+ try {
49
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
50
+ }
51
+ finally { if (e_1) throw e_1.error; }
52
+ }
53
+ res.success(SseSubscriptionClient_1.ConnectionNotFoundError);
54
+ };
55
+ SseSubscriptionServer.prototype.publishMessage = function (channel, message) {
56
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
57
+ var data, _a, _b, sc;
58
+ var e_2, _c;
59
+ return tslib_1.__generator(this, function (_d) {
60
+ data = JSON.stringify({ channel: channel, data: message });
61
+ try {
62
+ for (_a = tslib_1.__values(this.connections), _b = _a.next(); !_b.done; _b = _a.next()) {
63
+ sc = _b.value;
64
+ if (sc.channels[channel]) {
65
+ this.debugMessageFileSaver(sc.connectionId, channel, message);
66
+ sc.write(data);
67
+ }
68
+ }
69
+ }
70
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
71
+ finally {
72
+ try {
73
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
74
+ }
75
+ finally { if (e_2) throw e_2.error; }
76
+ }
77
+ return [2 /*return*/];
78
+ });
79
+ });
80
+ };
81
+ //@internal
82
+ SseSubscriptionServer.prototype.openHttpServerStream = function (req, res) {
83
+ var _this = this;
84
+ res.writeHead(200, {
85
+ 'Content-Type': 'text/event-stream',
86
+ 'Cache-Control': 'no-cache',
87
+ 'Connection': 'keep-alive'
88
+ });
89
+ var cc = new clientConnection(res);
90
+ //const lastEventId = req.headers['last-event-id'];
91
+ this.connections.push(cc);
92
+ this.debug();
93
+ //@ts-ignore
94
+ req.on("close", function () {
95
+ cc.close();
96
+ _this.connections = _this.connections.filter(function (s) { return s !== cc; });
97
+ _this.debug();
98
+ });
99
+ return cc;
100
+ };
101
+ //@internal
102
+ SseSubscriptionServer.prototype.debug = function () {
103
+ this.debugFileSaver(this.connections.map(function (x) { return ({
104
+ id: x.connectionId,
105
+ channels: x.channels
106
+ }); }));
107
+ };
108
+ return SseSubscriptionServer;
109
+ }());
110
+ exports.SseSubscriptionServer = SseSubscriptionServer;
111
+ var clientConnection = /** @class */ (function () {
112
+ function clientConnection(response) {
113
+ this.response = response;
114
+ this.channels = {};
115
+ this.closed = false;
116
+ this.connectionId = (0, uuid_1.v4)();
117
+ this.write(this.connectionId, "connectionId");
118
+ this.sendLiveMessage();
119
+ }
120
+ clientConnection.prototype.close = function () {
121
+ if (this.timeOutRef)
122
+ clearTimeout(this.timeOutRef);
123
+ this.closed = true;
124
+ };
125
+ clientConnection.prototype.write = function (eventData, eventType) {
126
+ if (eventType === void 0) { eventType = "message"; }
127
+ var event = "event:" + eventType;
128
+ // if (id != undefined)
129
+ // event += "\nid:" + id;
130
+ this.response.write(event + "\ndata:" + eventData + "\n\n");
131
+ if (this.response.flush)
132
+ this.response.flush();
133
+ };
134
+ clientConnection.prototype.sendLiveMessage = function () {
135
+ var _this = this;
136
+ if (this.closed)
137
+ return;
138
+ this.write("", "keep-alive");
139
+ this.timeOutRef = setTimeout(function () {
140
+ _this.sendLiveMessage();
141
+ }, 45000);
142
+ };
143
+ return clientConnection;
144
+ }());
145
+ exports.clientConnection = clientConnection;
package/ably.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import type * as Ably from '../../node_modules/ably';
2
- import type { SubscriptionServer } from './src/live-query/SubscriptionServer';
3
- import type { SubscriptionClient, SubscriptionClientConnection } from './src/live-query/SubscriptionChannel';
4
- export declare class AblySubscriptionClient implements SubscriptionClient {
5
- private ably;
6
- constructor(ably: Ably.Types.RealtimePromise);
7
- openConnection(onReconnect: VoidFunction): Promise<SubscriptionClientConnection>;
8
- }
9
- export declare class AblySubscriptionServer implements SubscriptionServer {
10
- private ably;
11
- constructor(ably: Ably.Types.RestPromise);
12
- publishMessage<T>(channel: string, message: T): Promise<void>;
13
- }
1
+ import type * as Ably from '../../node_modules/ably';
2
+ import type { SubscriptionServer } from './src/live-query/SubscriptionServer';
3
+ import type { SubscriptionClient, SubscriptionClientConnection } from './src/live-query/SubscriptionChannel';
4
+ export declare class AblySubscriptionClient implements SubscriptionClient {
5
+ private ably;
6
+ constructor(ably: Ably.Types.RealtimePromise);
7
+ openConnection(onReconnect: VoidFunction): Promise<SubscriptionClientConnection>;
8
+ }
9
+ export declare class AblySubscriptionServer implements SubscriptionServer {
10
+ private ably;
11
+ constructor(ably: Ably.Types.RestPromise);
12
+ publishMessage<T>(channel: string, message: T): Promise<void>;
13
+ }
package/ably.js CHANGED
@@ -1,59 +1,59 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AblySubscriptionServer = exports.AblySubscriptionClient = void 0;
4
- var tslib_1 = require("tslib");
5
- var AblySubscriptionClient = /** @class */ (function () {
6
- function AblySubscriptionClient(ably) {
7
- this.ably = ably;
8
- }
9
- AblySubscriptionClient.prototype.openConnection = function (onReconnect) {
10
- return tslib_1.__awaiter(this, void 0, void 0, function () {
11
- var _this = this;
12
- return tslib_1.__generator(this, function (_a) {
13
- return [2 /*return*/, {
14
- close: function () {
15
- // Since we did not open the connection, we do not close it
16
- },
17
- subscribe: function (channel, handler) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
18
- var myHandler;
19
- var _this = this;
20
- return tslib_1.__generator(this, function (_a) {
21
- switch (_a.label) {
22
- case 0:
23
- myHandler = function (y) { return handler(y.data); };
24
- return [4 /*yield*/, this.ably.channels.get(channel).subscribe(function (y) { return myHandler(y); })];
25
- case 1:
26
- _a.sent();
27
- return [2 /*return*/, function () {
28
- myHandler = function () { };
29
- _this.ably.channels.get(channel).unsubscribe();
30
- }];
31
- }
32
- });
33
- }); }
34
- }];
35
- });
36
- });
37
- };
38
- return AblySubscriptionClient;
39
- }());
40
- exports.AblySubscriptionClient = AblySubscriptionClient;
41
- var AblySubscriptionServer = /** @class */ (function () {
42
- function AblySubscriptionServer(ably) {
43
- this.ably = ably;
44
- }
45
- AblySubscriptionServer.prototype.publishMessage = function (channel, message) {
46
- return tslib_1.__awaiter(this, void 0, void 0, function () {
47
- return tslib_1.__generator(this, function (_a) {
48
- switch (_a.label) {
49
- case 0: return [4 /*yield*/, this.ably.channels.get(channel).publish({ data: message })];
50
- case 1:
51
- _a.sent();
52
- return [2 /*return*/];
53
- }
54
- });
55
- });
56
- };
57
- return AblySubscriptionServer;
58
- }());
59
- exports.AblySubscriptionServer = AblySubscriptionServer;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AblySubscriptionServer = exports.AblySubscriptionClient = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var AblySubscriptionClient = /** @class */ (function () {
6
+ function AblySubscriptionClient(ably) {
7
+ this.ably = ably;
8
+ }
9
+ AblySubscriptionClient.prototype.openConnection = function (onReconnect) {
10
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
11
+ var _this = this;
12
+ return tslib_1.__generator(this, function (_a) {
13
+ return [2 /*return*/, {
14
+ close: function () {
15
+ // Since we did not open the connection, we do not close it
16
+ },
17
+ subscribe: function (channel, handler) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
18
+ var myHandler;
19
+ var _this = this;
20
+ return tslib_1.__generator(this, function (_a) {
21
+ switch (_a.label) {
22
+ case 0:
23
+ myHandler = function (y) { return handler(y.data); };
24
+ return [4 /*yield*/, this.ably.channels.get(channel).subscribe(function (y) { return myHandler(y); })];
25
+ case 1:
26
+ _a.sent();
27
+ return [2 /*return*/, function () {
28
+ myHandler = function () { };
29
+ _this.ably.channels.get(channel).unsubscribe();
30
+ }];
31
+ }
32
+ });
33
+ }); }
34
+ }];
35
+ });
36
+ });
37
+ };
38
+ return AblySubscriptionClient;
39
+ }());
40
+ exports.AblySubscriptionClient = AblySubscriptionClient;
41
+ var AblySubscriptionServer = /** @class */ (function () {
42
+ function AblySubscriptionServer(ably) {
43
+ this.ably = ably;
44
+ }
45
+ AblySubscriptionServer.prototype.publishMessage = function (channel, message) {
46
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
47
+ return tslib_1.__generator(this, function (_a) {
48
+ switch (_a.label) {
49
+ case 0: return [4 /*yield*/, this.ably.channels.get(channel).publish({ data: message })];
50
+ case 1:
51
+ _a.sent();
52
+ return [2 /*return*/];
53
+ }
54
+ });
55
+ });
56
+ };
57
+ return AblySubscriptionServer;
58
+ }());
59
+ exports.AblySubscriptionServer = AblySubscriptionServer;
package/assign.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function assign<T>(item: T, valuesToSet: Partial<T>): T;
1
+ export declare function assign<T>(item: T, valuesToSet: Partial<T>): T;
package/assign.js CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assign = void 0;
4
- function assign(item, valuesToSet) {
5
- if (valuesToSet)
6
- Object.assign(item, valuesToSet);
7
- return item;
8
- }
9
- exports.assign = assign;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assign = void 0;
4
+ function assign(item, valuesToSet) {
5
+ if (valuesToSet)
6
+ Object.assign(item, valuesToSet);
7
+ return item;
8
+ }
9
+ exports.assign = assign;
package/classType.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare type ClassType<T> = {
2
- new (...args: any[]): T;
3
- };
1
+ export type ClassType<T> = {
2
+ new (...args: any[]): T;
3
+ };
package/classType.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,25 +1,25 @@
1
- /// <reference types="node" />
2
- import { GenericResponse } from './server/index';
3
- import { Remult } from './src/context';
4
- import { SubscriptionServer } from './src/live-query/SubscriptionServer';
5
- export declare class SseSubscriptionServer implements SubscriptionServer {
6
- private canUserConnectToChannel?;
7
- constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
8
- publishMessage<T>(channel: string, message: any): Promise<void>;
9
- }
10
- export interface ResponseRequiredForSSE {
11
- write(data: string): void;
12
- writeHead(status: number, headers: any): void;
13
- flush?(): void;
14
- }
15
- export declare class clientConnection {
16
- response: GenericResponse & ResponseRequiredForSSE;
17
- channels: Record<string, boolean>;
18
- timeOutRef: NodeJS.Timeout;
19
- close(): void;
20
- closed: boolean;
21
- write(eventData: string, eventType?: string): void;
22
- connectionId: any;
23
- constructor(response: GenericResponse & ResponseRequiredForSSE);
24
- sendLiveMessage(): void;
25
- }
1
+ /// <reference types="node" />
2
+ import { GenericResponse } from './server/index';
3
+ import { Remult } from './src/context';
4
+ import { SubscriptionServer } from './src/live-query/SubscriptionServer';
5
+ export declare class SseSubscriptionServer implements SubscriptionServer {
6
+ private canUserConnectToChannel?;
7
+ constructor(canUserConnectToChannel?: (channel: string, remult: Remult) => boolean);
8
+ publishMessage<T>(channel: string, message: any): Promise<void>;
9
+ }
10
+ export interface ResponseRequiredForSSE {
11
+ write(data: string): void;
12
+ writeHead(status: number, headers: any): void;
13
+ flush?(): void;
14
+ }
15
+ export declare class clientConnection {
16
+ response: GenericResponse & ResponseRequiredForSSE;
17
+ channels: Record<string, boolean>;
18
+ timeOutRef: NodeJS.Timeout;
19
+ close(): void;
20
+ closed: boolean;
21
+ write(eventData: string, eventType?: string): void;
22
+ connectionId: any;
23
+ constructor(response: GenericResponse & ResponseRequiredForSSE);
24
+ sendLiveMessage(): void;
25
+ }