rxdb-server 17.1.0 → 17.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +4 -0
  3. package/dist/cjs/plugins/adapter-express/index.js +10 -1
  4. package/dist/cjs/plugins/adapter-express/index.js.map +1 -1
  5. package/dist/cjs/plugins/client-rest/index.js +12 -7
  6. package/dist/cjs/plugins/client-rest/index.js.map +1 -1
  7. package/dist/cjs/plugins/replication-server/index.js +1 -1
  8. package/dist/cjs/plugins/replication-server/index.js.map +1 -1
  9. package/dist/cjs/plugins/server/endpoint-replication.js +9 -2
  10. package/dist/cjs/plugins/server/endpoint-replication.js.map +1 -1
  11. package/dist/cjs/plugins/server/endpoint-rest.js +58 -9
  12. package/dist/cjs/plugins/server/endpoint-rest.js.map +1 -1
  13. package/dist/cjs/plugins/server/helper.js +44 -7
  14. package/dist/cjs/plugins/server/helper.js.map +1 -1
  15. package/dist/cjs/plugins/server/index.js +12 -0
  16. package/dist/cjs/plugins/server/index.js.map +1 -1
  17. package/dist/cjs/plugins/server/performance-test.js +276 -0
  18. package/dist/cjs/plugins/server/performance-test.js.map +1 -0
  19. package/dist/esm/plugins/adapter-express/index.js +10 -1
  20. package/dist/esm/plugins/adapter-express/index.js.map +1 -1
  21. package/dist/esm/plugins/client-rest/index.js +12 -7
  22. package/dist/esm/plugins/client-rest/index.js.map +1 -1
  23. package/dist/esm/plugins/replication-server/index.js +1 -1
  24. package/dist/esm/plugins/replication-server/index.js.map +1 -1
  25. package/dist/esm/plugins/server/endpoint-replication.js +10 -3
  26. package/dist/esm/plugins/server/endpoint-replication.js.map +1 -1
  27. package/dist/esm/plugins/server/endpoint-rest.js +59 -10
  28. package/dist/esm/plugins/server/endpoint-rest.js.map +1 -1
  29. package/dist/esm/plugins/server/helper.js +43 -7
  30. package/dist/esm/plugins/server/helper.js.map +1 -1
  31. package/dist/esm/plugins/server/index.js +1 -0
  32. package/dist/esm/plugins/server/index.js.map +1 -1
  33. package/dist/esm/plugins/server/performance-test.js +271 -0
  34. package/dist/esm/plugins/server/performance-test.js.map +1 -0
  35. package/dist/types/plugins/server/helper.d.ts +11 -1
  36. package/dist/types/plugins/server/index.d.ts +1 -0
  37. package/dist/types/plugins/server/performance-test.d.ts +43 -0
  38. package/orga/changelog/README.md +18 -0
  39. package/orga/changelog/fix-cors-wildcard-with-credentials.md +1 -0
  40. package/orga/changelog/fix-false-conflicts-missing-server-only-field.md +1 -0
  41. package/orga/changelog/fix-replication-pull-url-encode-checkpoint.md +1 -0
  42. package/orga/changelog/fix-replication-push-new-doc-server-only-fields-strip.md +1 -0
  43. package/orga/changelog/fix-replication-push-new-doc-server-only-fields.md +1 -0
  44. package/orga/changelog/fix-replication-push-server-only-fields-insert.md +1 -0
  45. package/orga/changelog/fix-rest-client-missing-await.md +1 -0
  46. package/orga/changelog/fix-rest-client-observe-query-url-encode-base64.md +1 -0
  47. package/orga/changelog/fix-rest-delete-server-only-fields-validator.md +1 -0
  48. package/orga/changelog/fix-rest-query-observe-regex-rejection.md +1 -0
  49. package/orga/changelog/fix-rest-set-change-validator-new-doc.md +1 -0
  50. package/orga/changelog/fix-rest-set-document-ownership-check.md +1 -0
  51. package/orga/changelog/fix-rest-set-server-only-fields-insert.md +1 -0
  52. package/orga/changelog/fix-rest-set-server-only-fields-overwrite.md +1 -0
  53. package/package.json +7 -40
@@ -0,0 +1,43 @@
1
+ /**
2
+ * A reusable performance test suite for RxDB server adapters.
3
+ * This function can be exported and used by consumers who
4
+ * create custom adapters to verify their performance characteristics.
5
+ */
6
+ import type { RxDatabase } from 'rxdb/plugins/core';
7
+ import type { RxServerAdapter } from './types.ts';
8
+ export type PerformanceTestResult = {
9
+ /** Name of the test case */
10
+ name: string;
11
+ /** Total time in milliseconds */
12
+ timeMs: number;
13
+ /** Number of operations performed */
14
+ opsCount: number;
15
+ /** Calculated operations per second */
16
+ opsPerSecond: number;
17
+ };
18
+ export type PerformanceTestOptions<ServerAppType> = {
19
+ adapter: RxServerAdapter<ServerAppType, any, any>;
20
+ /**
21
+ * Function that creates a fresh RxDatabase instance.
22
+ * Must return a database that can be closed after each test.
23
+ */
24
+ createDatabase: () => Promise<RxDatabase>;
25
+ /**
26
+ * Function that resolves an available port for the server.
27
+ */
28
+ getPort: () => Promise<number>;
29
+ /**
30
+ * Number of documents to use for each test.
31
+ * [default=30]
32
+ */
33
+ batchSize?: number;
34
+ };
35
+ /**
36
+ * Runs a set of performance tests against the given adapter.
37
+ * Each test creates its own server and collection, measures
38
+ * the time for the operations, and tears down afterwards.
39
+ *
40
+ * Returns an array of results that callers can assert against
41
+ * or log for comparison purposes.
42
+ */
43
+ export declare function performanceTest<ServerAppType>(options: PerformanceTestOptions<ServerAppType>): Promise<PerformanceTestResult[]>;
@@ -0,0 +1,18 @@
1
+ ## Changelog Entries
2
+
3
+ Add one file per changelog entry to this folder. Each file should contain one or more changelog lines starting with `-`.
4
+
5
+ **File naming**: Use a descriptive filename ending in `.md`, for example:
6
+
7
+ - `fix-count-query-with-limit.md`
8
+ - `add-supabase-attachment-support.md`
9
+
10
+ **File content example**:
11
+
12
+ ```
13
+ - FIX some bug that caused incorrect results
14
+ ```
15
+
16
+ On rxdb release, all `.md` files in this folder (except this README) are read out from rxdb-server and merged into the changelog at rxdb core.
17
+
18
+ This approach prevents merge conflicts in `CHANGELOG.md` when multiple PRs are open at the same time.
@@ -0,0 +1 @@
1
+ - FIX invalid CORS response when the server is configured with the default `cors: '*'`. The express adapter always sends `Access-Control-Allow-Credentials: true`, but combining that with `Access-Control-Allow-Origin: *` is rejected by browsers per the CORS spec, so credentialed (cookie/auth-header) requests from any cross-origin client would fail. The adapter now reflects the request `Origin` back when `cors` is `'*'`, keeping the "allow from anywhere" semantics while staying compatible with credentials.
@@ -0,0 +1 @@
1
+ - FIX false conflicts during replication push when a `serverOnlyField` is absent from the stored server document (e.g. because the field is optional and was never set). `mergeServerDocumentFieldsMonad` previously wrote a `null` value for the missing field onto the merged `assumedMasterState`, so the extra key caused `masterWrite`'s `isEqual` check to report a conflict that did not actually exist, silently reverting the client's update. The helper now deletes the property in that case so the merged row matches the stored master state.
@@ -0,0 +1 @@
1
+ - FIX replication pull URL not URL-encoding the checkpoint `id`. When a document's primary key contained URL-reserved characters (for example `&`, `#`, `=`), the URL was parsed incorrectly on the server, causing the checkpoint to be truncated. With `batchSize: 1` this could make the pull loop never advance past such a document. The client now encodes the `id` with `encodeURIComponent`.
@@ -0,0 +1 @@
1
+ - FIX replication `/push` endpoint allowing clients to populate `serverOnlyFields` when inserting NEW documents. `mergeServerDocumentFieldsMonad` returned the client document unchanged when no server-side document existed yet, so a client-supplied value for a server-only field was passed through to `replicationHandler.masterWrite()` and persisted on the server. The merge now strips server-only fields from the client document when the server has no prior state for it, matching the documented contract that clients cannot do writes where one of the `serverOnlyFields` is set. The REST `/set` endpoint already stripped these fields explicitly, so it was unaffected.
@@ -0,0 +1 @@
1
+ - FIX conflict handling for new documents pushed via replication when `serverOnlyFields` are configured. `mergeServerDocumentFieldsMonad` incorrectly transformed a falsy `assumedMasterState` (used for new document inserts) into an object and set server-only fields to `null` on `newDocumentState`, causing schema validation failures and false conflicts.
@@ -0,0 +1 @@
1
+ - FIX replication `/push` endpoint allowing clients to populate `serverOnlyFields` when inserting NEW documents. Updates of existing documents already preserved the stored server value via `mergeServerDocumentFields`, but inserts (no `assumedMasterState` / no existing serverDoc) passed the client document straight into `masterWrite`, so any value the client sent for a server-only field was persisted. The handler now strips server-only fields from the new document state on insert, matching the behavior of the REST `/set` endpoint and the documented contract that clients cannot do writes where one of the `serverOnlyFields` is set.
@@ -0,0 +1 @@
1
+ - FIX missing `await` in `RxRestClient.get()`, `RxRestClient.set()`, and `RxRestClient.delete()` methods. The `postRequest()` call was not awaited before calling `handleError()`, which caused server errors (e.g. 403 Forbidden from `changeValidator`) to be silently swallowed instead of thrown to the caller.
@@ -0,0 +1 @@
1
+ - FIX REST client `observeQuery` not URL-encoding the base64 query string. Standard base64 contains `+` and `/`; in a URL query parameter `+` is decoded by the server as a space, so the server's `atob` rejected the corrupted string with `Invalid character` and the SSE handler crashed silently after the response headers were already sent. Any query whose base64 contained `+` or `/` (for example, queries that filtered by a unicode value such as `firstName: { $eq: 'ûÿþ' }`) would never deliver a document and the client just hung. The base64 is now passed through `encodeURIComponent` before being appended to the URL.
@@ -0,0 +1 @@
1
+ - FIX REST `/delete` endpoint returning 403 Forbidden when `serverOnlyFields` is configured. The delete handler passed full documents (including server-only fields) to the `changeValidator`, which always rejected them because the wrapper checks for the presence of server-only fields. Now the server-only fields are stripped before validation, consistent with the `/set` endpoint behavior.
@@ -0,0 +1 @@
1
+ - FIX REST `/query/observe` endpoint not rejecting `$regex` queries with a proper 400 response. The `queryModifier` wrapper throws on `$regex` selectors to prevent DOS attacks (matching the `/query` behavior), but the observe handler called the wrapped modifier AFTER `setSSEHeaders` had already committed a 200 OK SSE response, and without a `try/catch`. A client that sent a `$regex` query therefore observed a successful 200 status with an empty stream that the server then dropped, instead of the same 400 Bad Request that `/query` returns. The handler now runs the queryModifier (and the JSON/base64 query parsing) inside a `try/catch` BEFORE setting the SSE headers, so a bad request is answered with a proper 400 response.
@@ -0,0 +1 @@
1
+ - FIX REST `/set` endpoint not running the `changeValidator` for inserts of NEW documents. The handler only invoked the validator on the update path (when an existing document was found by primary key), so a `changeValidator` that returned `false` had no effect when the client sent a document whose primary key did not yet exist on the server. The handler now runs the validator for inserts as well, with `assumedMasterState` set to `undefined`, matching the behavior of the replication `/push` endpoint and the documented contract that the validator gates all writes.
@@ -0,0 +1 @@
1
+ - FIX REST `/set` endpoint allowing a client to overwrite documents they do not own. When a `queryModifier` was configured, the handler only validated that the client-provided (new) document state matched the modifier but never checked the existing server document. An authenticated user could therefore take over a foreign document by sending a write whose new state matched the modifier while targeting another user's primary key. The handler now also runs the query matcher against the existing server document and rejects the request with 403 Forbidden if it does not match, aligning the behavior with the replication `/push` endpoint.
@@ -0,0 +1 @@
1
+ - FIX REST endpoint `/set` allowing clients to populate `serverOnlyFields` when inserting NEW documents. Updates to existing documents already stripped client-supplied values for these fields, but the insert path passed the client document straight to `RxCollection.insert()`, so a client could persist arbitrary values into fields that are documented as server-only. The handler now strips server-only fields from the client document before inserting, matching the documented contract that clients cannot do writes where one of the `serverOnlyFields` is set.
@@ -0,0 +1 @@
1
+ - FIX REST endpoint `/set` not protecting `serverOnlyFields` from client overwrites. Clients could include server-only fields in write requests to `/set`, and those values would be stored directly instead of being ignored. The handler now uses `mergeServerDocumentFields` (consistent with the replication endpoint) to ensure server-only field values are always preserved from the server-side document, not taken from client input.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rxdb-server",
3
- "version": "17.1.0",
3
+ "version": "17.2.0",
4
4
  "description": "RxDB Server Plugin",
5
5
  "license": "SSPL",
6
6
  "author": "pubkey",
@@ -73,72 +73,39 @@
73
73
  "test:integration:mongodb": "(cd test-integration && npm run transpile && npm run test:node:mongodb)"
74
74
  },
75
75
  "peerDependencies": {
76
- "rxdb": "*",
76
+ "rxdb": "17.2.0",
77
77
  "rxjs": "*"
78
78
  },
79
79
  "dependencies": {
80
+ "@types/cors": "2.8.19",
80
81
  "@types/express": "5.0.6",
81
- "array-push-at-sort-position": "5.0.0",
82
82
  "async-test-util": "2.5.0",
83
83
  "cors": "2.8.6",
84
- "eth-crypto": "4.0.0",
85
- "eventsource": "4.1.0",
86
- "percom": "1.1.3",
87
- "web-locks": "0.0.9",
88
- "web-worker": "1.5.0"
84
+ "eventsource": "4.1.0"
89
85
  },
90
86
  "devDependencies": {
91
87
  "@babel/cli": "7.28.6",
92
88
  "@babel/core": "7.29.0",
93
- "@babel/plugin-external-helpers": "7.27.1",
94
- "@babel/plugin-proposal-class-properties": "7.18.6",
95
- "@babel/plugin-proposal-object-rest-spread": "7.20.7",
96
89
  "@babel/plugin-transform-literals": "7.27.1",
97
- "@babel/plugin-transform-member-expression-literals": "7.27.1",
98
90
  "@babel/plugin-transform-modules-commonjs": "7.28.6",
99
91
  "@babel/plugin-transform-react-jsx": "7.28.6",
100
- "@babel/plugin-transform-property-literals": "7.27.1",
101
92
  "@babel/plugin-transform-runtime": "7.29.0",
102
- "@babel/plugin-transform-spread": "7.28.6",
103
93
  "@babel/plugin-transform-template-literals": "7.27.1",
104
94
  "@babel/plugin-transform-typescript": "7.28.6",
105
- "@babel/polyfill": "7.12.1",
106
95
  "@babel/preset-env": "7.29.2",
107
96
  "@babel/preset-typescript": "7.28.5",
108
- "@babel/types": "7.29.0",
109
- "@faker-js/faker": "10.4.0",
110
97
  "@types/mocha": "10.0.10",
111
- "@types/node": "24.12.0",
112
- "@types/websql": "0.0.30",
113
- "babel-loader": "10.1.1",
98
+ "@types/node": "24.12.2",
114
99
  "babel-plugin-transform-class-properties": "6.24.1",
115
100
  "concurrently": "9.2.1",
116
101
  "cross-env": "10.1.0",
117
- "detect-browser": "5.3.0",
118
102
  "express": "5.2.1",
119
103
  "get-port": "5.1.1",
120
- "http-server": "14.1.1",
121
- "karma": "6.4.4",
122
- "karma-chrome-launcher": "3.2.0",
123
- "karma-detect-browsers": "2.3.3",
124
- "karma-firefox-launcher": "2.1.3",
125
- "karma-mocha": "2.0.1",
126
- "karma-sourcemap-loader": "0.4.0",
127
- "karma-spec-reporter": "0.0.36",
128
- "karma-typescript": "5.5.4",
129
- "karma-webpack": "5.0.1",
130
- "mini-css-extract-plugin": "2.10.2",
131
- "minify-all-js": "0.1.9",
132
104
  "mocha": "11.7.5",
133
105
  "rimraf": "6.1.3",
134
- "rxdb": "17.1.0",
106
+ "rxdb": "https://github.com/pubkey/rxdb/archive/1ad97a93e4589aaf634e0d7c8ead0d75c4325017.tar.gz",
135
107
  "rxjs": "7.8.2",
136
- "ts-loader": "9.5.4",
137
108
  "ts-node": "10.9.2",
138
- "typescript": "5.9.3",
139
- "webpack": "5.105.4",
140
- "webpack-bundle-analyzer": "5.3.0",
141
- "webpack-cli": "7.0.2",
142
- "webpack-dev-server": "5.2.3"
109
+ "typescript": "5.9.3"
143
110
  }
144
111
  }