rxdb-server 15.39.0 → 16.0.0-beta.1

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.
@@ -16,7 +16,7 @@ var RxServer = exports.RxServer = /*#__PURE__*/function () {
16
16
  this.cors = cors;
17
17
  this.database = options.database;
18
18
  this.adapter = options.adapter;
19
- options.database.onDestroy.push(this.closeFn);
19
+ options.database.onClose.push(this.closeFn);
20
20
  }
21
21
  var _proto = RxServer.prototype;
22
22
  _proto.ensureNotStarted = function ensureNotStarted() {
@@ -43,7 +43,7 @@ var RxServer = exports.RxServer = /*#__PURE__*/function () {
43
43
  return this.listenPromise;
44
44
  };
45
45
  _proto.close = async function close() {
46
- this.database.onDestroy = this.database.onDestroy.filter(fn => fn !== this.closeFn);
46
+ this.database.onClose = this.database.onClose.filter(fn => fn !== this.closeFn);
47
47
  if (this.listenPromise) {
48
48
  await this.listenPromise;
49
49
  await this.options.adapter.close(this.serverApp);
@@ -1 +1 @@
1
- {"version":3,"file":"rx-server.js","names":["_endpointReplication","require","_endpointRest","RxServer","exports","options","authHandler","serverApp","cors","endpoints","closeFn","close","bind","database","adapter","onDestroy","push","_proto","prototype","ensureNotStarted","listenPromise","Error","addReplicationEndpoint","opts","endpoint","RxServerReplicationEndpoint","name","collection","queryModifier","_a","q","changeValidator","serverOnlyFields","addRestEndpoint","RxServerRestEndpoint","start","hostname","listen","port","filter","fn"],"sources":["../../../../src/plugins/server/rx-server.ts"],"sourcesContent":["import type {\n RxCollection,\n RxDatabase\n} from 'rxdb/plugins/core';\nimport { RxServerReplicationEndpoint } from './endpoint-replication.ts';\nimport type {\n RxServerAdapter,\n RxServerAuthHandler,\n RxServerChangeValidator,\n RxServerEndpoint,\n RxServerOptions,\n RxServerQueryModifier\n} from './types.ts';\nimport { RxServerRestEndpoint } from './endpoint-rest.ts';\n\nexport class RxServer<ServerAppType, AuthType> {\n public readonly endpoints: RxServerEndpoint<AuthType, any>[] = [];\n\n private closeFn = (() => this.close()).bind(this);\n public listenPromise?: Promise<void>;\n\n public readonly database: RxDatabase;\n public readonly adapter: RxServerAdapter<ServerAppType>;\n\n constructor(\n public readonly options: RxServerOptions<ServerAppType, AuthType>,\n public readonly authHandler: RxServerAuthHandler<AuthType>,\n public readonly serverApp: ServerAppType,\n public readonly cors: string = '*'\n ) {\n this.database = options.database;\n this.adapter = options.adapter;\n options.database.onDestroy.push(this.closeFn);\n }\n\n private ensureNotStarted() {\n if (this.listenPromise) {\n throw new Error('This operation cannot be run after the RxServer has been started already');\n }\n\n }\n\n public addReplicationEndpoint<RxDocType>(opts: {\n name: string,\n collection: RxCollection<RxDocType>,\n queryModifier?: RxServerQueryModifier<AuthType, RxDocType>,\n changeValidator?: RxServerChangeValidator<AuthType, RxDocType>,\n /**\n * Set a origin for allowed CORS requests.\n * Overwrites the cors option of the server.\n * [default='*']\n */\n cors?: '*' | string,\n serverOnlyFields?: string[]\n }) {\n this.ensureNotStarted();\n const endpoint = new RxServerReplicationEndpoint(\n this,\n opts.name,\n opts.collection,\n opts.queryModifier ? opts.queryModifier : (_a, q) => q,\n opts.changeValidator ? opts.changeValidator : () => true,\n opts.serverOnlyFields ? opts.serverOnlyFields : [],\n opts.cors\n );\n this.endpoints.push(endpoint);\n return endpoint;\n }\n\n public addRestEndpoint<RxDocType>(opts: {\n name: string,\n collection: RxCollection<RxDocType>,\n queryModifier?: RxServerQueryModifier<AuthType, RxDocType>,\n changeValidator?: RxServerChangeValidator<AuthType, RxDocType>,\n /**\n * Set a origin for allowed CORS requests.\n * Overwrites the cors option of the server.\n * [default='*']\n */\n cors?: '*' | string,\n serverOnlyFields?: string[]\n }) {\n this.ensureNotStarted();\n const endpoint = new RxServerRestEndpoint(\n this,\n opts.name,\n opts.collection,\n opts.queryModifier ? opts.queryModifier : (_a, q) => q,\n opts.changeValidator ? opts.changeValidator : () => true,\n opts.serverOnlyFields ? opts.serverOnlyFields : [],\n opts.cors\n );\n this.endpoints.push(endpoint);\n return endpoint;\n }\n\n async start() {\n this.ensureNotStarted();\n const hostname = this.options.hostname ? this.options.hostname : 'localhost';\n this.listenPromise = this.options.adapter.listen(this.serverApp, this.options.port, hostname);\n return this.listenPromise;\n }\n\n async close() {\n this.database.onDestroy = this.database.onDestroy.filter(fn => fn !== this.closeFn);\n if (this.listenPromise) {\n await this.listenPromise;\n await this.options.adapter.close(this.serverApp);\n }\n }\n}\n"],"mappings":";;;;;;AAIA,IAAAA,oBAAA,GAAAC,OAAA;AASA,IAAAC,aAAA,GAAAD,OAAA;AAA0D,IAE7CE,QAAQ,GAAAC,OAAA,CAAAD,QAAA;EASjB,SAAAA,SACoBE,OAAiD,EACjDC,WAA0C,EAC1CC,SAAwB,EACxBC,IAAY,GAAG,GAAG,EACpC;IAAA,KAbcC,SAAS,GAAsC,EAAE;IAAA,KAEzDC,OAAO,GAAG,CAAC,MAAM,IAAI,CAACC,KAAK,CAAC,CAAC,EAAEC,IAAI,CAAC,IAAI,CAAC;IAAA,KAO7BP,OAAiD,GAAjDA,OAAiD;IAAA,KACjDC,WAA0C,GAA1CA,WAA0C;IAAA,KAC1CC,SAAwB,GAAxBA,SAAwB;IAAA,KACxBC,IAAY,GAAZA,IAAY;IAE5B,IAAI,CAACK,QAAQ,GAAGR,OAAO,CAACQ,QAAQ;IAChC,IAAI,CAACC,OAAO,GAAGT,OAAO,CAACS,OAAO;IAC9BT,OAAO,CAACQ,QAAQ,CAACE,SAAS,CAACC,IAAI,CAAC,IAAI,CAACN,OAAO,CAAC;EACjD;EAAC,IAAAO,MAAA,GAAAd,QAAA,CAAAe,SAAA;EAAAD,MAAA,CAEOE,gBAAgB,GAAxB,SAAQA,gBAAgBA,CAAA,EAAG;IACvB,IAAI,IAAI,CAACC,aAAa,EAAE;MACpB,MAAM,IAAIC,KAAK,CAAC,0EAA0E,CAAC;IAC/F;EAEJ,CAAC;EAAAJ,MAAA,CAEMK,sBAAsB,GAA7B,SAAOA,sBAAsBA,CAAYC,IAYxC,EAAE;IACC,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/B,OAAO,CAAC+B,QAAQ,GAAG,WAAW;IAC5E,IAAI,CAAChB,aAAa,GAAG,IAAI,CAACf,OAAO,CAACS,OAAO,CAACuB,MAAM,CAAC,IAAI,CAAC9B,SAAS,EAAE,IAAI,CAACF,OAAO,CAACiC,IAAI,EAAEF,QAAQ,CAAC;IAC7F,OAAO,IAAI,CAAChB,aAAa;EAC7B,CAAC;EAAAH,MAAA,CAEKN,KAAK,GAAX,eAAMA,KAAKA,CAAA,EAAG;IACV,IAAI,CAACE,QAAQ,CAACE,SAAS,GAAG,IAAI,CAACF,QAAQ,CAACE,SAAS,CAACwB,MAAM,CAACC,EAAE,IAAIA,EAAE,KAAK,IAAI,CAAC9B,OAAO,CAAC;IACnF,IAAI,IAAI,CAACU,aAAa,EAAE;MACpB,MAAM,IAAI,CAACA,aAAa;MACxB,MAAM,IAAI,CAACf,OAAO,CAACS,OAAO,CAACH,KAAK,CAAC,IAAI,CAACJ,SAAS,CAAC;IACpD;EACJ,CAAC;EAAA,OAAAJ,QAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"rx-server.js","names":["_endpointReplication","require","_endpointRest","RxServer","exports","options","authHandler","serverApp","cors","endpoints","closeFn","close","bind","database","adapter","onClose","push","_proto","prototype","ensureNotStarted","listenPromise","Error","addReplicationEndpoint","opts","endpoint","RxServerReplicationEndpoint","name","collection","queryModifier","_a","q","changeValidator","serverOnlyFields","addRestEndpoint","RxServerRestEndpoint","start","hostname","listen","port","filter","fn"],"sources":["../../../../src/plugins/server/rx-server.ts"],"sourcesContent":["import type {\n RxCollection,\n RxDatabase\n} from 'rxdb/plugins/core';\nimport { RxServerReplicationEndpoint } from './endpoint-replication.ts';\nimport type {\n RxServerAdapter,\n RxServerAuthHandler,\n RxServerChangeValidator,\n RxServerEndpoint,\n RxServerOptions,\n RxServerQueryModifier\n} from './types.ts';\nimport { RxServerRestEndpoint } from './endpoint-rest.ts';\n\nexport class RxServer<ServerAppType, AuthType> {\n public readonly endpoints: RxServerEndpoint<AuthType, any>[] = [];\n\n private closeFn = (() => this.close()).bind(this);\n public listenPromise?: Promise<void>;\n\n public readonly database: RxDatabase;\n public readonly adapter: RxServerAdapter<ServerAppType>;\n\n constructor(\n public readonly options: RxServerOptions<ServerAppType, AuthType>,\n public readonly authHandler: RxServerAuthHandler<AuthType>,\n public readonly serverApp: ServerAppType,\n public readonly cors: string = '*'\n ) {\n this.database = options.database;\n this.adapter = options.adapter;\n options.database.onClose.push(this.closeFn);\n }\n\n private ensureNotStarted() {\n if (this.listenPromise) {\n throw new Error('This operation cannot be run after the RxServer has been started already');\n }\n\n }\n\n public addReplicationEndpoint<RxDocType>(opts: {\n name: string,\n collection: RxCollection<RxDocType>,\n queryModifier?: RxServerQueryModifier<AuthType, RxDocType>,\n changeValidator?: RxServerChangeValidator<AuthType, RxDocType>,\n /**\n * Set a origin for allowed CORS requests.\n * Overwrites the cors option of the server.\n * [default='*']\n */\n cors?: '*' | string,\n serverOnlyFields?: string[]\n }) {\n this.ensureNotStarted();\n const endpoint = new RxServerReplicationEndpoint(\n this,\n opts.name,\n opts.collection,\n opts.queryModifier ? opts.queryModifier : (_a, q) => q,\n opts.changeValidator ? opts.changeValidator : () => true,\n opts.serverOnlyFields ? opts.serverOnlyFields : [],\n opts.cors\n );\n this.endpoints.push(endpoint);\n return endpoint;\n }\n\n public addRestEndpoint<RxDocType>(opts: {\n name: string,\n collection: RxCollection<RxDocType>,\n queryModifier?: RxServerQueryModifier<AuthType, RxDocType>,\n changeValidator?: RxServerChangeValidator<AuthType, RxDocType>,\n /**\n * Set a origin for allowed CORS requests.\n * Overwrites the cors option of the server.\n * [default='*']\n */\n cors?: '*' | string,\n serverOnlyFields?: string[]\n }) {\n this.ensureNotStarted();\n const endpoint = new RxServerRestEndpoint(\n this,\n opts.name,\n opts.collection,\n opts.queryModifier ? opts.queryModifier : (_a, q) => q,\n opts.changeValidator ? opts.changeValidator : () => true,\n opts.serverOnlyFields ? opts.serverOnlyFields : [],\n opts.cors\n );\n this.endpoints.push(endpoint);\n return endpoint;\n }\n\n async start() {\n this.ensureNotStarted();\n const hostname = this.options.hostname ? this.options.hostname : 'localhost';\n this.listenPromise = this.options.adapter.listen(this.serverApp, this.options.port, hostname);\n return this.listenPromise;\n }\n\n async close() {\n this.database.onClose = this.database.onClose.filter(fn => fn !== this.closeFn);\n if (this.listenPromise) {\n await this.listenPromise;\n await this.options.adapter.close(this.serverApp);\n }\n }\n}\n"],"mappings":";;;;;;AAIA,IAAAA,oBAAA,GAAAC,OAAA;AASA,IAAAC,aAAA,GAAAD,OAAA;AAA0D,IAE7CE,QAAQ,GAAAC,OAAA,CAAAD,QAAA;EASjB,SAAAA,SACoBE,OAAiD,EACjDC,WAA0C,EAC1CC,SAAwB,EACxBC,IAAY,GAAG,GAAG,EACpC;IAAA,KAbcC,SAAS,GAAsC,EAAE;IAAA,KAEzDC,OAAO,GAAG,CAAC,MAAM,IAAI,CAACC,KAAK,CAAC,CAAC,EAAEC,IAAI,CAAC,IAAI,CAAC;IAAA,KAO7BP,OAAiD,GAAjDA,OAAiD;IAAA,KACjDC,WAA0C,GAA1CA,WAA0C;IAAA,KAC1CC,SAAwB,GAAxBA,SAAwB;IAAA,KACxBC,IAAY,GAAZA,IAAY;IAE5B,IAAI,CAACK,QAAQ,GAAGR,OAAO,CAACQ,QAAQ;IAChC,IAAI,CAACC,OAAO,GAAGT,OAAO,CAACS,OAAO;IAC9BT,OAAO,CAACQ,QAAQ,CAACE,OAAO,CAACC,IAAI,CAAC,IAAI,CAACN,OAAO,CAAC;EAC/C;EAAC,IAAAO,MAAA,GAAAd,QAAA,CAAAe,SAAA;EAAAD,MAAA,CAEOE,gBAAgB,GAAxB,SAAQA,gBAAgBA,CAAA,EAAG;IACvB,IAAI,IAAI,CAACC,aAAa,EAAE;MACpB,MAAM,IAAIC,KAAK,CAAC,0EAA0E,CAAC;IAC/F;EAEJ,CAAC;EAAAJ,MAAA,CAEMK,sBAAsB,GAA7B,SAAOA,sBAAsBA,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,QAAQ,GAAG,IAAI,CAAC/B,OAAO,CAAC+B,QAAQ,GAAG,WAAW;IAC5E,IAAI,CAAChB,aAAa,GAAG,IAAI,CAACf,OAAO,CAACS,OAAO,CAACuB,MAAM,CAAC,IAAI,CAAC9B,SAAS,EAAE,IAAI,CAACF,OAAO,CAACiC,IAAI,EAAEF,QAAQ,CAAC;IAC7F,OAAO,IAAI,CAAChB,aAAa;EAC7B,CAAC;EAAAH,MAAA,CAEKN,KAAK,GAAX,eAAMA,KAAKA,CAAA,EAAG;IACV,IAAI,CAACE,QAAQ,CAACE,OAAO,GAAG,IAAI,CAACF,QAAQ,CAACE,OAAO,CAACwB,MAAM,CAACC,EAAE,IAAIA,EAAE,KAAK,IAAI,CAAC9B,OAAO,CAAC;IAC/E,IAAI,IAAI,CAACU,aAAa,EAAE;MACpB,MAAM,IAAI,CAACA,aAAa;MACxB,MAAM,IAAI,CAACf,OAAO,CAACS,OAAO,CAACH,KAAK,CAAC,IAAI,CAACJ,SAAS,CAAC;IACpD;EACJ,CAAC;EAAA,OAAAJ,QAAA;AAAA","ignoreList":[]}
@@ -10,7 +10,7 @@ export var RxServer = /*#__PURE__*/function () {
10
10
  this.cors = cors;
11
11
  this.database = options.database;
12
12
  this.adapter = options.adapter;
13
- options.database.onDestroy.push(this.closeFn);
13
+ options.database.onClose.push(this.closeFn);
14
14
  }
15
15
  var _proto = RxServer.prototype;
16
16
  _proto.ensureNotStarted = function ensureNotStarted() {
@@ -37,7 +37,7 @@ export var RxServer = /*#__PURE__*/function () {
37
37
  return this.listenPromise;
38
38
  };
39
39
  _proto.close = async function close() {
40
- this.database.onDestroy = this.database.onDestroy.filter(fn => fn !== this.closeFn);
40
+ this.database.onClose = this.database.onClose.filter(fn => fn !== this.closeFn);
41
41
  if (this.listenPromise) {
42
42
  await this.listenPromise;
43
43
  await this.options.adapter.close(this.serverApp);
@@ -1 +1 @@
1
- {"version":3,"file":"rx-server.js","names":["RxServerReplicationEndpoint","RxServerRestEndpoint","RxServer","options","authHandler","serverApp","cors","endpoints","closeFn","close","bind","database","adapter","onDestroy","push","_proto","prototype","ensureNotStarted","listenPromise","Error","addReplicationEndpoint","opts","endpoint","name","collection","queryModifier","_a","q","changeValidator","serverOnlyFields","addRestEndpoint","start","hostname","listen","port","filter","fn"],"sources":["../../../../src/plugins/server/rx-server.ts"],"sourcesContent":["import type {\n RxCollection,\n RxDatabase\n} from 'rxdb/plugins/core';\nimport { RxServerReplicationEndpoint } from './endpoint-replication.ts';\nimport type {\n RxServerAdapter,\n RxServerAuthHandler,\n RxServerChangeValidator,\n RxServerEndpoint,\n RxServerOptions,\n RxServerQueryModifier\n} from './types.ts';\nimport { RxServerRestEndpoint } from './endpoint-rest.ts';\n\nexport class RxServer<ServerAppType, AuthType> {\n public readonly endpoints: RxServerEndpoint<AuthType, any>[] = [];\n\n private closeFn = (() => this.close()).bind(this);\n public listenPromise?: Promise<void>;\n\n public readonly database: RxDatabase;\n public readonly adapter: RxServerAdapter<ServerAppType>;\n\n constructor(\n public readonly options: RxServerOptions<ServerAppType, AuthType>,\n public readonly authHandler: RxServerAuthHandler<AuthType>,\n public readonly serverApp: ServerAppType,\n public readonly cors: string = '*'\n ) {\n this.database = options.database;\n this.adapter = options.adapter;\n options.database.onDestroy.push(this.closeFn);\n }\n\n private ensureNotStarted() {\n if (this.listenPromise) {\n throw new Error('This operation cannot be run after the RxServer has been started already');\n }\n\n }\n\n public addReplicationEndpoint<RxDocType>(opts: {\n name: string,\n collection: RxCollection<RxDocType>,\n queryModifier?: RxServerQueryModifier<AuthType, RxDocType>,\n changeValidator?: RxServerChangeValidator<AuthType, RxDocType>,\n /**\n * Set a origin for allowed CORS requests.\n * Overwrites the cors option of the server.\n * [default='*']\n */\n cors?: '*' | string,\n serverOnlyFields?: string[]\n }) {\n this.ensureNotStarted();\n const endpoint = new RxServerReplicationEndpoint(\n this,\n opts.name,\n opts.collection,\n opts.queryModifier ? opts.queryModifier : (_a, q) => q,\n opts.changeValidator ? opts.changeValidator : () => true,\n opts.serverOnlyFields ? opts.serverOnlyFields : [],\n opts.cors\n );\n this.endpoints.push(endpoint);\n return endpoint;\n }\n\n public addRestEndpoint<RxDocType>(opts: {\n name: string,\n collection: RxCollection<RxDocType>,\n queryModifier?: RxServerQueryModifier<AuthType, RxDocType>,\n changeValidator?: RxServerChangeValidator<AuthType, RxDocType>,\n /**\n * Set a origin for allowed CORS requests.\n * Overwrites the cors option of the server.\n * [default='*']\n */\n cors?: '*' | string,\n serverOnlyFields?: string[]\n }) {\n this.ensureNotStarted();\n const endpoint = new RxServerRestEndpoint(\n this,\n opts.name,\n opts.collection,\n opts.queryModifier ? opts.queryModifier : (_a, q) => q,\n opts.changeValidator ? opts.changeValidator : () => true,\n opts.serverOnlyFields ? opts.serverOnlyFields : [],\n opts.cors\n );\n this.endpoints.push(endpoint);\n return endpoint;\n }\n\n async start() {\n this.ensureNotStarted();\n const hostname = this.options.hostname ? this.options.hostname : 'localhost';\n this.listenPromise = this.options.adapter.listen(this.serverApp, this.options.port, hostname);\n return this.listenPromise;\n }\n\n async close() {\n this.database.onDestroy = this.database.onDestroy.filter(fn => fn !== this.closeFn);\n if (this.listenPromise) {\n await this.listenPromise;\n await this.options.adapter.close(this.serverApp);\n }\n }\n}\n"],"mappings":"AAIA,SAASA,2BAA2B,QAAQ,2BAA2B;AASvE,SAASC,oBAAoB,QAAQ,oBAAoB;AAEzD,WAAaC,QAAQ;EASjB,SAAAA,SACoBC,OAAiD,EACjDC,WAA0C,EAC1CC,SAAwB,EACxBC,IAAY,GAAG,GAAG,EACpC;IAAA,KAbcC,SAAS,GAAsC,EAAE;IAAA,KAEzDC,OAAO,GAAG,CAAC,MAAM,IAAI,CAACC,KAAK,CAAC,CAAC,EAAEC,IAAI,CAAC,IAAI,CAAC;IAAA,KAO7BP,OAAiD,GAAjDA,OAAiD;IAAA,KACjDC,WAA0C,GAA1CA,WAA0C;IAAA,KAC1CC,SAAwB,GAAxBA,SAAwB;IAAA,KACxBC,IAAY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,IAAI,CAACI,aAAa,GAAG,CAACC,EAAE,EAAEC,CAAC,KAAKA,CAAC,EACtDN,IAAI,CAACO,eAAe,GAAGP,IAAI,CAACO,eAAe,GAAG,MAAM,IAAI,EACxDP,IAAI,CAACQ,gBAAgB,GAAGR,IAAI,CAACQ,gBAAgB,GAAG,EAAE,EAClDR,IAAI,CAACf,IACT,CAAC;IACD,IAAI,CAACC,SAAS,CAACO,IAAI,CAACQ,QAAQ,CAAC;IAC7B,OAAOA,QAAQ;EACnB,CAAC;EAAAP,MAAA,CAEKgB,KAAK,GAAX,eAAMA,KAAKA,CAAA,EAAG;IACV,IAAI,CAACd,gBAAgB,CAAC,CAAC;IACvB,IAAMe,QAAQ,GAAG,IAAI,CAAC7B,OAAO,CAAC6B,QAAQ,GAAG,IAAI,CAAC7B,OAAO,CAAC6B,QAAQ,GAAG,WAAW;IAC5E,IAAI,CAACd,aAAa,GAAG,IAAI,CAACf,OAAO,CAACS,OAAO,CAACqB,MAAM,CAAC,IAAI,CAAC5B,SAAS,EAAE,IAAI,CAACF,OAAO,CAAC+B,IAAI,EAAEF,QAAQ,CAAC;IAC7F,OAAO,IAAI,CAACd,aAAa;EAC7B,CAAC;EAAAH,MAAA,CAEKN,KAAK,GAAX,eAAMA,KAAKA,CAAA,EAAG;IACV,IAAI,CAACE,QAAQ,CAACE,SAAS,GAAG,IAAI,CAACF,QAAQ,CAACE,SAAS,CAACsB,MAAM,CAACC,EAAE,IAAIA,EAAE,KAAK,IAAI,CAAC5B,OAAO,CAAC;IACnF,IAAI,IAAI,CAACU,aAAa,EAAE;MACpB,MAAM,IAAI,CAACA,aAAa;MACxB,MAAM,IAAI,CAACf,OAAO,CAACS,OAAO,CAACH,KAAK,CAAC,IAAI,CAACJ,SAAS,CAAC;IACpD;EACJ,CAAC;EAAA,OAAAH,QAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"rx-server.js","names":["RxServerReplicationEndpoint","RxServerRestEndpoint","RxServer","options","authHandler","serverApp","cors","endpoints","closeFn","close","bind","database","adapter","onClose","push","_proto","prototype","ensureNotStarted","listenPromise","Error","addReplicationEndpoint","opts","endpoint","name","collection","queryModifier","_a","q","changeValidator","serverOnlyFields","addRestEndpoint","start","hostname","listen","port","filter","fn"],"sources":["../../../../src/plugins/server/rx-server.ts"],"sourcesContent":["import type {\n RxCollection,\n RxDatabase\n} from 'rxdb/plugins/core';\nimport { RxServerReplicationEndpoint } from './endpoint-replication.ts';\nimport type {\n RxServerAdapter,\n RxServerAuthHandler,\n RxServerChangeValidator,\n RxServerEndpoint,\n RxServerOptions,\n RxServerQueryModifier\n} from './types.ts';\nimport { RxServerRestEndpoint } from './endpoint-rest.ts';\n\nexport class RxServer<ServerAppType, AuthType> {\n public readonly endpoints: RxServerEndpoint<AuthType, any>[] = [];\n\n private closeFn = (() => this.close()).bind(this);\n public listenPromise?: Promise<void>;\n\n public readonly database: RxDatabase;\n public readonly adapter: RxServerAdapter<ServerAppType>;\n\n constructor(\n public readonly options: RxServerOptions<ServerAppType, AuthType>,\n public readonly authHandler: RxServerAuthHandler<AuthType>,\n public readonly serverApp: ServerAppType,\n public readonly cors: string = '*'\n ) {\n this.database = options.database;\n this.adapter = options.adapter;\n options.database.onClose.push(this.closeFn);\n }\n\n private ensureNotStarted() {\n if (this.listenPromise) {\n throw new Error('This operation cannot be run after the RxServer has been started already');\n }\n\n }\n\n public addReplicationEndpoint<RxDocType>(opts: {\n name: string,\n collection: RxCollection<RxDocType>,\n queryModifier?: RxServerQueryModifier<AuthType, RxDocType>,\n changeValidator?: RxServerChangeValidator<AuthType, RxDocType>,\n /**\n * Set a origin for allowed CORS requests.\n * Overwrites the cors option of the server.\n * [default='*']\n */\n cors?: '*' | string,\n serverOnlyFields?: string[]\n }) {\n this.ensureNotStarted();\n const endpoint = new RxServerReplicationEndpoint(\n this,\n opts.name,\n opts.collection,\n opts.queryModifier ? opts.queryModifier : (_a, q) => q,\n opts.changeValidator ? opts.changeValidator : () => true,\n opts.serverOnlyFields ? opts.serverOnlyFields : [],\n opts.cors\n );\n this.endpoints.push(endpoint);\n return endpoint;\n }\n\n public addRestEndpoint<RxDocType>(opts: {\n name: string,\n collection: RxCollection<RxDocType>,\n queryModifier?: RxServerQueryModifier<AuthType, RxDocType>,\n changeValidator?: RxServerChangeValidator<AuthType, RxDocType>,\n /**\n * Set a origin for allowed CORS requests.\n * Overwrites the cors option of the server.\n * [default='*']\n */\n cors?: '*' | string,\n serverOnlyFields?: string[]\n }) {\n this.ensureNotStarted();\n const endpoint = new RxServerRestEndpoint(\n this,\n opts.name,\n opts.collection,\n opts.queryModifier ? opts.queryModifier : (_a, q) => q,\n opts.changeValidator ? opts.changeValidator : () => true,\n opts.serverOnlyFields ? opts.serverOnlyFields : [],\n opts.cors\n );\n this.endpoints.push(endpoint);\n return endpoint;\n }\n\n async start() {\n this.ensureNotStarted();\n const hostname = this.options.hostname ? this.options.hostname : 'localhost';\n this.listenPromise = this.options.adapter.listen(this.serverApp, this.options.port, hostname);\n return this.listenPromise;\n }\n\n async close() {\n this.database.onClose = this.database.onClose.filter(fn => fn !== this.closeFn);\n if (this.listenPromise) {\n await this.listenPromise;\n await this.options.adapter.close(this.serverApp);\n }\n }\n}\n"],"mappings":"AAIA,SAASA,2BAA2B,QAAQ,2BAA2B;AASvE,SAASC,oBAAoB,QAAQ,oBAAoB;AAEzD,WAAaC,QAAQ;EASjB,SAAAA,SACoBC,OAAiD,EACjDC,WAA0C,EAC1CC,SAAwB,EACxBC,IAAY,GAAG,GAAG,EACpC;IAAA,KAbcC,SAAS,GAAsC,EAAE;IAAA,KAEzDC,OAAO,GAAG,CAAC,MAAM,IAAI,CAACC,KAAK,CAAC,CAAC,EAAEC,IAAI,CAAC,IAAI,CAAC;IAAA,KAO7BP,OAAiD,GAAjDA,OAAiD;IAAA,KACjDC,WAA0C,GAA1CA,WAA0C;IAAA,KAC1CC,SAAwB,GAAxBA,SAAwB;IAAA,KACxBC,IAAY,GAAZA,IAAY;IAE5B,IAAI,C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  "description": "RxDB Server Plugin",
5
5
  "license": "SSPL",
6
6
  "author": "pubkey",
@@ -106,7 +106,7 @@
106
106
  "@babel/preset-typescript": "7.26.0",
107
107
  "@babel/types": "7.26.0",
108
108
  "@faker-js/faker": "9.2.0",
109
- "@types/mocha": "10.0.9",
109
+ "@types/mocha": "10.0.10",
110
110
  "@types/node": "22.9.1",
111
111
  "@types/sqlite3": "3.1.11",
112
112
  "@types/websql": "0.0.30",
@@ -131,12 +131,12 @@
131
131
  "minify-all-js": "0.1.9",
132
132
  "mocha": "10.8.2",
133
133
  "rimraf": "6.0.1",
134
- "rxdb": "15.39.0",
134
+ "rxdb": "16.0.0-beta.1",
135
135
  "rxjs": "7.8.1",
136
136
  "ts-loader": "9.5.1",
137
137
  "ts-mocha": "10.0.0",
138
138
  "ts-node": "10.9.2",
139
- "typescript": "5.6.3",
139
+ "typescript": "5.7.2",
140
140
  "webpack": "5.96.1",
141
141
  "webpack-bundle-analyzer": "4.10.2",
142
142
  "webpack-cli": "5.1.4",