@hocuspocus/extension-logger 3.4.6-rc.1 → 4.0.0-rc.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.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023, Tiptap GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1 +1 @@
1
- {"version":3,"file":"hocuspocus-logger.cjs","names":[],"sources":["../src/Logger.ts"],"sourcesContent":["import type {\n\tExtension,\n\tonChangePayload,\n\tonConfigurePayload,\n\tonConnectPayload,\n\tonLoadDocumentPayload,\n\tonDestroyPayload,\n\tonDisconnectPayload,\n\tonRequestPayload,\n\tonUpgradePayload,\n} from \"@hocuspocus/server\";\n\nexport interface LoggerConfiguration {\n\t/**\n\t * Prepend all logging message with a string.\n\t *\n\t * @deprecated\n\t */\n\tprefix: null | string;\n\t/**\n\t * Whether to log something for the `onLoadDocument` hook.\n\t */\n\tonLoadDocument: boolean;\n\t/**\n\t * Whether to log something for the `onChange` hook.\n\t */\n\tonChange: boolean;\n\t/**\n\t * Whether to log something for the `onStoreDocument` hook.\n\t */\n\tonStoreDocument: boolean;\n\t/**\n\t * Whether to log something for the `onConnect` hook.\n\t */\n\tonConnect: boolean;\n\t/**\n\t * Whether to log something for the `onDisconnect` hook.\n\t */\n\tonDisconnect: boolean;\n\t/**\n\t * Whether to log something for the `onUpgrade` hook.\n\t */\n\tonUpgrade: boolean;\n\t/**\n\t * Whether to log something for the `onRequest` hook.\n\t */\n\tonRequest: boolean;\n\t/**\n\t * Whether to log something for the `onDestroy` hook.\n\t */\n\tonDestroy: boolean;\n\t/**\n\t * Whether to log something for the `onConfigure` hook.\n\t */\n\tonConfigure: boolean;\n\t/**\n\t * A log function, if none is provided output will go to console\n\t */\n\tlog: (...args: any[]) => void;\n}\n\nexport class Logger implements Extension {\n\tname: string | null = null;\n\n\tconfiguration: LoggerConfiguration = {\n\t\tprefix: null,\n\t\tonLoadDocument: true,\n\t\tonChange: true,\n\t\tonStoreDocument: true,\n\t\tonConnect: true,\n\t\tonDisconnect: true,\n\t\tonUpgrade: true,\n\t\tonRequest: true,\n\t\tonDestroy: true,\n\t\tonConfigure: true,\n\t\tlog: console.log, // eslint-disable-line\n\t};\n\n\t/**\n\t * Constructor\n\t */\n\tconstructor(configuration?: Partial<LoggerConfiguration>) {\n\t\tthis.configuration = {\n\t\t\t...this.configuration,\n\t\t\t...configuration,\n\t\t};\n\t}\n\n\tasync onConfigure(data: onConfigurePayload) {\n\t\tthis.name = data.instance.configuration.name;\n\n\t\tif (!this.configuration.onConfigure) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.configuration.prefix) {\n\t\t\tconsole.warn(\n\t\t\t\t\"[hocuspocus warn] The Logger 'prefix' is deprecated. Pass a 'name' to the Hocuspocus configuration instead.\",\n\t\t\t);\n\t\t}\n\t}\n\n\tasync onLoadDocument(data: onLoadDocumentPayload) {\n\t\tif (this.configuration.onLoadDocument) {\n\t\t\tthis.log(`Loaded document \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onChange(data: onChangePayload) {\n\t\tif (this.configuration.onChange) {\n\t\t\tthis.log(`Document \"${data.documentName}\" changed.`);\n\t\t}\n\t}\n\n\tasync onStoreDocument(data: onDisconnectPayload) {\n\t\tif (this.configuration.onStoreDocument) {\n\t\t\tthis.log(`Store \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onConnect(data: onConnectPayload) {\n\t\tif (this.configuration.onConnect) {\n\t\t\tthis.log(`New connection to \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onDisconnect(data: onDisconnectPayload) {\n\t\tif (this.configuration.onDisconnect) {\n\t\t\tthis.log(`Connection to \"${data.documentName}\" closed.`);\n\t\t}\n\t}\n\n\tasync onUpgrade(data: onUpgradePayload) {\n\t\tif (this.configuration.onUpgrade) {\n\t\t\tthis.log(\"Upgrading connection …\");\n\t\t}\n\t}\n\n\tasync onRequest(data: onRequestPayload) {\n\t\tif (this.configuration.onRequest) {\n\t\t\tthis.log(`Incoming HTTP Request to ${data.request.url}`);\n\t\t}\n\t}\n\n\tasync onDestroy(data: onDestroyPayload) {\n\t\tif (this.configuration.onDestroy) {\n\t\t\tthis.log(\"Shut down.\");\n\t\t}\n\t}\n\n\tprivate log(message: string) {\n\t\tconst date = new Date().toISOString();\n\t\tlet meta = `${date}`;\n\n\t\tif (this.name) {\n\t\t\tmeta = `${this.name} ${meta}`;\n\t\t}\n\n\t\tmessage = `[${meta}] ${message}`;\n\n\t\tthis.configuration.log(message);\n\t}\n}\n"],"mappings":";;;AA6DA,IAAa,SAAb,MAAyC;;;;CAoBxC,YAAY,eAA8C;cAnBpC;uBAEe;GACpC,QAAQ;GACR,gBAAgB;GAChB,UAAU;GACV,iBAAiB;GACjB,WAAW;GACX,cAAc;GACd,WAAW;GACX,WAAW;GACX,WAAW;GACX,aAAa;GACb,KAAK,QAAQ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,\n\tonConfigurePayload,\n\tonConnectPayload,\n\tonDestroyPayload,\n\tonDisconnectPayload,\n\tonLoadDocumentPayload,\n\tonRequestPayload,\n\tonStoreDocumentPayload,\n\tonUpgradePayload,\n} from \"@hocuspocus/server\";\n\nexport interface LoggerConfiguration {\n\t/**\n\t * Prepend all logging message with a string.\n\t *\n\t * @deprecated\n\t */\n\tprefix: null | string;\n\t/**\n\t * Whether to log something for the `onLoadDocument` hook.\n\t */\n\tonLoadDocument: boolean;\n\t/**\n\t * Whether to log something for the `onChange` hook.\n\t */\n\tonChange: boolean;\n\t/**\n\t * Whether to log something for the `onStoreDocument` hook.\n\t */\n\tonStoreDocument: boolean;\n\t/**\n\t * Whether to log something for the `onConnect` hook.\n\t */\n\tonConnect: boolean;\n\t/**\n\t * Whether to log something for the `onDisconnect` hook.\n\t */\n\tonDisconnect: boolean;\n\t/**\n\t * Whether to log something for the `onUpgrade` hook.\n\t */\n\tonUpgrade: boolean;\n\t/**\n\t * Whether to log something for the `onRequest` hook.\n\t */\n\tonRequest: boolean;\n\t/**\n\t * Whether to log something for the `onDestroy` hook.\n\t */\n\tonDestroy: boolean;\n\t/**\n\t * Whether to log something for the `onConfigure` hook.\n\t */\n\tonConfigure: boolean;\n\t/**\n\t * A log function, if none is provided output will go to console\n\t */\n\tlog: (...args: any[]) => void;\n}\n\nexport class Logger implements Extension {\n\tname: string | null = null;\n\n\tconfiguration: LoggerConfiguration = {\n\t\tprefix: null,\n\t\tonLoadDocument: true,\n\t\tonChange: true,\n\t\tonStoreDocument: true,\n\t\tonConnect: true,\n\t\tonDisconnect: true,\n\t\tonUpgrade: true,\n\t\tonRequest: true,\n\t\tonDestroy: true,\n\t\tonConfigure: true,\n\t\tlog: console.log, // eslint-disable-line\n\t};\n\n\t/**\n\t * Constructor\n\t */\n\tconstructor(configuration?: Partial<LoggerConfiguration>) {\n\t\tthis.configuration = {\n\t\t\t...this.configuration,\n\t\t\t...configuration,\n\t\t};\n\t}\n\n\tasync onConfigure(data: onConfigurePayload) {\n\t\tthis.name = data.instance.configuration.name;\n\n\t\tif (!this.configuration.onConfigure) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.configuration.prefix) {\n\t\t\tconsole.warn(\n\t\t\t\t\"[hocuspocus warn] The Logger 'prefix' is deprecated. Pass a 'name' to the Hocuspocus configuration instead.\",\n\t\t\t);\n\t\t}\n\t}\n\n\tasync onLoadDocument(data: onLoadDocumentPayload) {\n\t\tif (this.configuration.onLoadDocument) {\n\t\t\tthis.log(`Loaded document \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onChange(data: onChangePayload) {\n\t\tif (this.configuration.onChange) {\n\t\t\tthis.log(`Document \"${data.documentName}\" changed.`);\n\t\t}\n\t}\n\n\tasync onStoreDocument(data: onStoreDocumentPayload) {\n\t\tif (this.configuration.onStoreDocument) {\n\t\t\tthis.log(`Store \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onConnect(data: onConnectPayload) {\n\t\tif (this.configuration.onConnect) {\n\t\t\tthis.log(`New connection to \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onDisconnect(data: onDisconnectPayload) {\n\t\tif (this.configuration.onDisconnect) {\n\t\t\tthis.log(`Connection to \"${data.documentName}\" closed.`);\n\t\t}\n\t}\n\n\tasync onUpgrade(data: onUpgradePayload) {\n\t\tif (this.configuration.onUpgrade) {\n\t\t\tthis.log(\"Upgrading connection …\");\n\t\t}\n\t}\n\n\tasync onRequest(data: onRequestPayload) {\n\t\tif (this.configuration.onRequest) {\n\t\t\tthis.log(`Incoming HTTP Request to ${data.request.url}`);\n\t\t}\n\t}\n\n\tasync onDestroy(data: onDestroyPayload) {\n\t\tif (this.configuration.onDestroy) {\n\t\t\tthis.log(\"Shut down.\");\n\t\t}\n\t}\n\n\tprivate log(message: string) {\n\t\tconst date = new Date().toISOString();\n\t\tlet meta = `${date}`;\n\n\t\tif (this.name) {\n\t\t\tmeta = `${this.name} ${meta}`;\n\t\t}\n\n\t\tm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iB;EAE5B,IAAI,OAAO,oBADE,IAAI,MAAM,EAAC,aAAa;AAGrC,MAAI,KAAK,KACR,QAAO,GAAG,KAAK,KAAK,GAAG;AAGxB,YAAU,IAAI,KAAK,IAAI;AAEvB,OAAK,cAAc,IAAI,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"hocuspocus-logger.esm.js","names":[],"sources":["../src/Logger.ts"],"sourcesContent":["import type {\n\tExtension,\n\tonChangePayload,\n\tonConfigurePayload,\n\tonConnectPayload,\n\tonLoadDocumentPayload,\n\tonDestroyPayload,\n\tonDisconnectPayload,\n\tonRequestPayload,\n\tonUpgradePayload,\n} from \"@hocuspocus/server\";\n\nexport interface LoggerConfiguration {\n\t/**\n\t * Prepend all logging message with a string.\n\t *\n\t * @deprecated\n\t */\n\tprefix: null | string;\n\t/**\n\t * Whether to log something for the `onLoadDocument` hook.\n\t */\n\tonLoadDocument: boolean;\n\t/**\n\t * Whether to log something for the `onChange` hook.\n\t */\n\tonChange: boolean;\n\t/**\n\t * Whether to log something for the `onStoreDocument` hook.\n\t */\n\tonStoreDocument: boolean;\n\t/**\n\t * Whether to log something for the `onConnect` hook.\n\t */\n\tonConnect: boolean;\n\t/**\n\t * Whether to log something for the `onDisconnect` hook.\n\t */\n\tonDisconnect: boolean;\n\t/**\n\t * Whether to log something for the `onUpgrade` hook.\n\t */\n\tonUpgrade: boolean;\n\t/**\n\t * Whether to log something for the `onRequest` hook.\n\t */\n\tonRequest: boolean;\n\t/**\n\t * Whether to log something for the `onDestroy` hook.\n\t */\n\tonDestroy: boolean;\n\t/**\n\t * Whether to log something for the `onConfigure` hook.\n\t */\n\tonConfigure: boolean;\n\t/**\n\t * A log function, if none is provided output will go to console\n\t */\n\tlog: (...args: any[]) => void;\n}\n\nexport class Logger implements Extension {\n\tname: string | null = null;\n\n\tconfiguration: LoggerConfiguration = {\n\t\tprefix: null,\n\t\tonLoadDocument: true,\n\t\tonChange: true,\n\t\tonStoreDocument: true,\n\t\tonConnect: true,\n\t\tonDisconnect: true,\n\t\tonUpgrade: true,\n\t\tonRequest: true,\n\t\tonDestroy: true,\n\t\tonConfigure: true,\n\t\tlog: console.log, // eslint-disable-line\n\t};\n\n\t/**\n\t * Constructor\n\t */\n\tconstructor(configuration?: Partial<LoggerConfiguration>) {\n\t\tthis.configuration = {\n\t\t\t...this.configuration,\n\t\t\t...configuration,\n\t\t};\n\t}\n\n\tasync onConfigure(data: onConfigurePayload) {\n\t\tthis.name = data.instance.configuration.name;\n\n\t\tif (!this.configuration.onConfigure) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.configuration.prefix) {\n\t\t\tconsole.warn(\n\t\t\t\t\"[hocuspocus warn] The Logger 'prefix' is deprecated. Pass a 'name' to the Hocuspocus configuration instead.\",\n\t\t\t);\n\t\t}\n\t}\n\n\tasync onLoadDocument(data: onLoadDocumentPayload) {\n\t\tif (this.configuration.onLoadDocument) {\n\t\t\tthis.log(`Loaded document \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onChange(data: onChangePayload) {\n\t\tif (this.configuration.onChange) {\n\t\t\tthis.log(`Document \"${data.documentName}\" changed.`);\n\t\t}\n\t}\n\n\tasync onStoreDocument(data: onDisconnectPayload) {\n\t\tif (this.configuration.onStoreDocument) {\n\t\t\tthis.log(`Store \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onConnect(data: onConnectPayload) {\n\t\tif (this.configuration.onConnect) {\n\t\t\tthis.log(`New connection to \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onDisconnect(data: onDisconnectPayload) {\n\t\tif (this.configuration.onDisconnect) {\n\t\t\tthis.log(`Connection to \"${data.documentName}\" closed.`);\n\t\t}\n\t}\n\n\tasync onUpgrade(data: onUpgradePayload) {\n\t\tif (this.configuration.onUpgrade) {\n\t\t\tthis.log(\"Upgrading connection …\");\n\t\t}\n\t}\n\n\tasync onRequest(data: onRequestPayload) {\n\t\tif (this.configuration.onRequest) {\n\t\t\tthis.log(`Incoming HTTP Request to ${data.request.url}`);\n\t\t}\n\t}\n\n\tasync onDestroy(data: onDestroyPayload) {\n\t\tif (this.configuration.onDestroy) {\n\t\t\tthis.log(\"Shut down.\");\n\t\t}\n\t}\n\n\tprivate log(message: string) {\n\t\tconst date = new Date().toISOString();\n\t\tlet meta = `${date}`;\n\n\t\tif (this.name) {\n\t\t\tmeta = `${this.name} ${meta}`;\n\t\t}\n\n\t\tmessage = `[${meta}] ${message}`;\n\n\t\tthis.configuration.log(message);\n\t}\n}\n"],"mappings":";AA6DA,IAAa,SAAb,MAAyC;;;;CAoBxC,YAAY,eAA8C;cAnBpC;uBAEe;GACpC,QAAQ;GACR,gBAAgB;GAChB,UAAU;GACV,iBAAiB;GACjB,WAAW;GACX,cAAc;GACd,WAAW;GACX,WAAW;GACX,WAAW;GACX,aAAa;GACb,KAAK,QAAQ;GACb;AAMA,OAAK,gBAAgB;GACpB,GAAG,KAAK;GACR,GAAG;GACH;;CAGF,MAAM,YAAY,MAA0B;AAC3C,OAAK,OAAO,KAAK,SAAS,cAAc;AAExC,MAAI,CAAC,KAAK,cAAc,YACvB;AAGD,MAAI,KAAK,cAAc,OACtB,SAAQ,KACP,8GACA;;CAIH,MAAM,eAAe,MAA6B;AACjD,MAAI,KAAK,cAAc,eACtB,MAAK,IAAI,oBAAoB,KAAK,aAAa,IAAI;;CAIrD,MAAM,SAAS,MAAuB;AACrC,MAAI,KAAK,cAAc,SACtB,MAAK,IAAI,aAAa,KAAK,aAAa,YAAY;;CAItD,MAAM,gBAAgB,MAA2B;AAChD,MAAI,KAAK,cAAc,gBACtB,MAAK,IAAI,UAAU,KAAK,aAAa,IAAI;;CAI3C,MAAM,UAAU,MAAwB;AACvC,MAAI,KAAK,cAAc,UACtB,MAAK,IAAI,sBAAsB,KAAK,aAAa,IAAI;;CAIvD,MAAM,aAAa,MAA2B;AAC7C,MAAI,KAAK,cAAc,aACtB,MAAK,IAAI,kBAAkB,KAAK,aAAa,WAAW;;CAI1D,MAAM,UAAU,MAAwB;AACvC,MAAI,KAAK,cAAc,UACtB,MAAK,IAAI,yBAAyB;;CAIpC,MAAM,UAAU,MAAwB;AACvC,MAAI,KAAK,cAAc,UACtB,MAAK,IAAI,4BAA4B,KAAK,QAAQ,MAAM;;CAI1D,MAAM,UAAU,MAAwB;AACvC,MAAI,KAAK,cAAc,UACtB,MAAK,IAAI,aAAa;;CAIxB,AAAQ,IAAI,SAAiB;EAE5B,IAAI,OAAO,oBADE,IAAI,MAAM,EAAC,aAAa;AAGrC,MAAI,KAAK,KACR,QAAO,GAAG,KAAK,KAAK,GAAG;AAGxB,YAAU,IAAI,KAAK,IAAI;AAEvB,OAAK,cAAc,IAAI,QAAQ"}
1
+ {"version":3,"file":"hocuspocus-logger.esm.js","names":[],"sources":["../src/Logger.ts"],"sourcesContent":["import type {\n\tExtension,\n\tonChangePayload,\n\tonConfigurePayload,\n\tonConnectPayload,\n\tonDestroyPayload,\n\tonDisconnectPayload,\n\tonLoadDocumentPayload,\n\tonRequestPayload,\n\tonStoreDocumentPayload,\n\tonUpgradePayload,\n} from \"@hocuspocus/server\";\n\nexport interface LoggerConfiguration {\n\t/**\n\t * Prepend all logging message with a string.\n\t *\n\t * @deprecated\n\t */\n\tprefix: null | string;\n\t/**\n\t * Whether to log something for the `onLoadDocument` hook.\n\t */\n\tonLoadDocument: boolean;\n\t/**\n\t * Whether to log something for the `onChange` hook.\n\t */\n\tonChange: boolean;\n\t/**\n\t * Whether to log something for the `onStoreDocument` hook.\n\t */\n\tonStoreDocument: boolean;\n\t/**\n\t * Whether to log something for the `onConnect` hook.\n\t */\n\tonConnect: boolean;\n\t/**\n\t * Whether to log something for the `onDisconnect` hook.\n\t */\n\tonDisconnect: boolean;\n\t/**\n\t * Whether to log something for the `onUpgrade` hook.\n\t */\n\tonUpgrade: boolean;\n\t/**\n\t * Whether to log something for the `onRequest` hook.\n\t */\n\tonRequest: boolean;\n\t/**\n\t * Whether to log something for the `onDestroy` hook.\n\t */\n\tonDestroy: boolean;\n\t/**\n\t * Whether to log something for the `onConfigure` hook.\n\t */\n\tonConfigure: boolean;\n\t/**\n\t * A log function, if none is provided output will go to console\n\t */\n\tlog: (...args: any[]) => void;\n}\n\nexport class Logger implements Extension {\n\tname: string | null = null;\n\n\tconfiguration: LoggerConfiguration = {\n\t\tprefix: null,\n\t\tonLoadDocument: true,\n\t\tonChange: true,\n\t\tonStoreDocument: true,\n\t\tonConnect: true,\n\t\tonDisconnect: true,\n\t\tonUpgrade: true,\n\t\tonRequest: true,\n\t\tonDestroy: true,\n\t\tonConfigure: true,\n\t\tlog: console.log, // eslint-disable-line\n\t};\n\n\t/**\n\t * Constructor\n\t */\n\tconstructor(configuration?: Partial<LoggerConfiguration>) {\n\t\tthis.configuration = {\n\t\t\t...this.configuration,\n\t\t\t...configuration,\n\t\t};\n\t}\n\n\tasync onConfigure(data: onConfigurePayload) {\n\t\tthis.name = data.instance.configuration.name;\n\n\t\tif (!this.configuration.onConfigure) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.configuration.prefix) {\n\t\t\tconsole.warn(\n\t\t\t\t\"[hocuspocus warn] The Logger 'prefix' is deprecated. Pass a 'name' to the Hocuspocus configuration instead.\",\n\t\t\t);\n\t\t}\n\t}\n\n\tasync onLoadDocument(data: onLoadDocumentPayload) {\n\t\tif (this.configuration.onLoadDocument) {\n\t\t\tthis.log(`Loaded document \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onChange(data: onChangePayload) {\n\t\tif (this.configuration.onChange) {\n\t\t\tthis.log(`Document \"${data.documentName}\" changed.`);\n\t\t}\n\t}\n\n\tasync onStoreDocument(data: onStoreDocumentPayload) {\n\t\tif (this.configuration.onStoreDocument) {\n\t\t\tthis.log(`Store \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onConnect(data: onConnectPayload) {\n\t\tif (this.configuration.onConnect) {\n\t\t\tthis.log(`New connection to \"${data.documentName}\".`);\n\t\t}\n\t}\n\n\tasync onDisconnect(data: onDisconnectPayload) {\n\t\tif (this.configuration.onDisconnect) {\n\t\t\tthis.log(`Connection to \"${data.documentName}\" closed.`);\n\t\t}\n\t}\n\n\tasync onUpgrade(data: onUpgradePayload) {\n\t\tif (this.configuration.onUpgrade) {\n\t\t\tthis.log(\"Upgrading connection …\");\n\t\t}\n\t}\n\n\tasync onRequest(data: onRequestPayload) {\n\t\tif (this.configuration.onRequest) {\n\t\t\tthis.log(`Incoming HTTP Request to ${data.request.url}`);\n\t\t}\n\t}\n\n\tasync onDestroy(data: onDestroyPayload) {\n\t\tif (this.configuration.onDestroy) {\n\t\t\tthis.log(\"Shut down.\");\n\t\t}\n\t}\n\n\tprivate log(message: string) {\n\t\tconst date = new Date().toISOString();\n\t\tlet meta = `${date}`;\n\n\t\tif (this.name) {\n\t\t\tmeta = `${this.name} ${meta}`;\n\t\t}\n\n\t\tmessage = `[${meta}] ${message}`;\n\n\t\tthis.configuration.log(message);\n\t}\n}\n"],"mappings":";AA8DA,IAAa,SAAb,MAAyC;;;;CAoBxC,YAAY,eAA8C;cAnBpC;uBAEe;GACpC,QAAQ;GACR,gBAAgB;GAChB,UAAU;GACV,iBAAiB;GACjB,WAAW;GACX,cAAc;GACd,WAAW;GACX,WAAW;GACX,WAAW;GACX,aAAa;GACb,KAAK,QAAQ;GACb;AAMA,OAAK,gBAAgB;GACpB,GAAG,KAAK;GACR,GAAG;GACH;;CAGF,MAAM,YAAY,MAA0B;AAC3C,OAAK,OAAO,KAAK,SAAS,cAAc;AAExC,MAAI,CAAC,KAAK,cAAc,YACvB;AAGD,MAAI,KAAK,cAAc,OACtB,SAAQ,KACP,8GACA;;CAIH,MAAM,eAAe,MAA6B;AACjD,MAAI,KAAK,cAAc,eACtB,MAAK,IAAI,oBAAoB,KAAK,aAAa,IAAI;;CAIrD,MAAM,SAAS,MAAuB;AACrC,MAAI,KAAK,cAAc,SACtB,MAAK,IAAI,aAAa,KAAK,aAAa,YAAY;;CAItD,MAAM,gBAAgB,MAA8B;AACnD,MAAI,KAAK,cAAc,gBACtB,MAAK,IAAI,UAAU,KAAK,aAAa,IAAI;;CAI3C,MAAM,UAAU,MAAwB;AACvC,MAAI,KAAK,cAAc,UACtB,MAAK,IAAI,sBAAsB,KAAK,aAAa,IAAI;;CAIvD,MAAM,aAAa,MAA2B;AAC7C,MAAI,KAAK,cAAc,aACtB,MAAK,IAAI,kBAAkB,KAAK,aAAa,WAAW;;CAI1D,MAAM,UAAU,MAAwB;AACvC,MAAI,KAAK,cAAc,UACtB,MAAK,IAAI,yBAAyB;;CAIpC,MAAM,UAAU,MAAwB;AACvC,MAAI,KAAK,cAAc,UACtB,MAAK,IAAI,4BAA4B,KAAK,QAAQ,MAAM;;CAI1D,MAAM,UAAU,MAAwB;AACvC,MAAI,KAAK,cAAc,UACtB,MAAK,IAAI,aAAa;;CAIxB,AAAQ,IAAI,SAAiB;EAE5B,IAAI,OAAO,oBADE,IAAI,MAAM,EAAC,aAAa;AAGrC,MAAI,KAAK,KACR,QAAO,GAAG,KAAK,KAAK,GAAG;AAGxB,YAAU,IAAI,KAAK,IAAI;AAEvB,OAAK,cAAc,IAAI,QAAQ"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onDestroyPayload, onDisconnectPayload, onLoadDocumentPayload, onRequestPayload, onUpgradePayload } from "@hocuspocus/server";
1
+ import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onDestroyPayload, onDisconnectPayload, onLoadDocumentPayload, onRequestPayload, onStoreDocumentPayload, onUpgradePayload } from "@hocuspocus/server";
2
2
 
3
3
  //#region packages/extension-logger/src/Logger.d.ts
4
4
  interface LoggerConfiguration {
@@ -59,7 +59,7 @@ declare class Logger implements Extension {
59
59
  onConfigure(data: onConfigurePayload): Promise<void>;
60
60
  onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
61
61
  onChange(data: onChangePayload): Promise<void>;
62
- onStoreDocument(data: onDisconnectPayload): Promise<void>;
62
+ onStoreDocument(data: onStoreDocumentPayload): Promise<void>;
63
63
  onConnect(data: onConnectPayload): Promise<void>;
64
64
  onDisconnect(data: onDisconnectPayload): Promise<void>;
65
65
  onUpgrade(data: onUpgradePayload): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/extension-logger",
3
- "version": "3.4.6-rc.1",
3
+ "version": "4.0.0-rc.0",
4
4
  "description": "hocuspocus logging extension",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -29,10 +29,13 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@hocuspocus/server": "^3.4.6-rc.1"
32
+ "@hocuspocus/server": "^4.0.0-rc.0"
33
33
  },
34
- "gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d",
34
+ "gitHead": "3fe6c023877badd74d3ea3e50019b73660e028a4",
35
35
  "repository": {
36
36
  "url": "https://github.com/ueberdosis/hocuspocus"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
37
40
  }
38
41
  }
package/src/Logger.ts CHANGED
@@ -3,10 +3,11 @@ import type {
3
3
  onChangePayload,
4
4
  onConfigurePayload,
5
5
  onConnectPayload,
6
- onLoadDocumentPayload,
7
6
  onDestroyPayload,
8
7
  onDisconnectPayload,
8
+ onLoadDocumentPayload,
9
9
  onRequestPayload,
10
+ onStoreDocumentPayload,
10
11
  onUpgradePayload,
11
12
  } from "@hocuspocus/server";
12
13
 
@@ -112,7 +113,7 @@ export class Logger implements Extension {
112
113
  }
113
114
  }
114
115
 
115
- async onStoreDocument(data: onDisconnectPayload) {
116
+ async onStoreDocument(data: onStoreDocumentPayload) {
116
117
  if (this.configuration.onStoreDocument) {
117
118
  this.log(`Store "${data.documentName}".`);
118
119
  }