@hocuspocus/extension-logger 1.0.0-alpha.60 → 1.0.0-alpha.61
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/dist/hocuspocus-logger.cjs +3 -2
- package/dist/hocuspocus-logger.cjs.map +1 -1
- package/dist/hocuspocus-logger.esm.js +3 -2
- package/dist/hocuspocus-logger.esm.js.map +1 -1
- package/dist/packages/extension-database/src/Database.d.ts +36 -0
- package/dist/packages/extension-database/src/index.d.ts +1 -0
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +26 -0
- package/dist/packages/extension-sqlite/src/index.d.ts +1 -0
- package/dist/packages/extension-webhook/src/index.d.ts +1 -1
- package/dist/packages/provider/src/HocuspocusCloudProvider.d.ts +10 -0
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +1 -1
- package/dist/packages/provider/src/index.d.ts +1 -0
- package/dist/{demos/backend/src/express.d.ts → playground/backend/src/default.d.ts} +0 -0
- package/dist/{demos/backend/src/koa.d.ts → playground/backend/src/express.d.ts} +0 -0
- package/dist/{demos/backend/src/load-document.d.ts → playground/backend/src/koa.d.ts} +0 -0
- package/dist/{demos/backend/src/minimal.d.ts → playground/backend/src/load-document.d.ts} +0 -0
- package/dist/{demos → playground}/backend/src/monitor.d.ts +0 -0
- package/dist/{demos → playground}/backend/src/redis.d.ts +0 -0
- package/dist/{demos → playground}/backend/src/slow.d.ts +0 -0
- package/dist/{demos → playground}/backend/src/webhook.d.ts +0 -0
- package/package.json +3 -3
- package/src/Logger.ts +4 -2
|
@@ -71,10 +71,11 @@ class Logger {
|
|
|
71
71
|
}
|
|
72
72
|
log(message) {
|
|
73
73
|
const date = (new Date()).toISOString();
|
|
74
|
-
|
|
74
|
+
let meta = `${date}`;
|
|
75
75
|
if (this.name) {
|
|
76
|
-
|
|
76
|
+
meta = `${this.name} ${meta}`;
|
|
77
77
|
}
|
|
78
|
+
message = `[${meta}] ${message}`;
|
|
78
79
|
this.configuration.log(message);
|
|
79
80
|
}
|
|
80
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-logger.cjs","sources":["../src/Logger.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onConfigurePayload,\n onConnectPayload,\n onLoadDocumentPayload,\n onDestroyPayload,\n onDisconnectPayload,\n onRequestPayload,\n onUpgradePayload,\n} from '@hocuspocus/server'\n\nexport interface LoggerConfiguration {\n /**\n * Prepend all logging message with a string.\n *\n * @deprecated\n */\n prefix: null | string,\n /**\n * Whether to log something for the `onLoadDocument` hook.\n */\n onLoadDocument: boolean,\n /**\n * Whether to log something for the `onChange` hook.\n */\n onChange: boolean,\n /**\n * Whether to log something for the `onConnect` hook.\n */\n onConnect: boolean,\n /**\n * Whether to log something for the `onDisconnect` hook.\n */\n onDisconnect: boolean,\n /**\n * Whether to log something for the `onUpgrade` hook.\n */\n onUpgrade: boolean,\n /**\n * Whether to log something for the `onRequest` hook.\n */\n onRequest: boolean,\n /**\n * Whether to log something for the `onDestroy` hook.\n */\n onDestroy: boolean,\n /**\n * Whether to log something for the `onConfigure` hook.\n */\n onConfigure: boolean,\n /**\n * A log function, if none is provided output will go to console\n */\n log: (...args: any[]) => void,\n}\n\nexport class Logger implements Extension {\n name: string | null = null\n\n configuration: LoggerConfiguration = {\n prefix: null,\n onLoadDocument: true,\n onChange: true,\n onConnect: true,\n onDisconnect: true,\n onUpgrade: true,\n onRequest: true,\n onDestroy: true,\n onConfigure: true,\n log: console.log, // eslint-disable-line\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<LoggerConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure(data: onConfigurePayload) {\n this.name = data.instance.configuration.name\n\n if (!this.configuration.onConfigure) {\n return\n }\n\n if (this.configuration.prefix) {\n console.warn('[hocuspocus warn] The Logger \\'prefix\\' is deprecated. Pass a \\'name\\' to the Hocuspocus configuration instead.')\n }\n }\n\n async onLoadDocument(data: onLoadDocumentPayload) {\n if (this.configuration.onLoadDocument) {\n this.log(`Loaded document \"${data.documentName}\".`)\n }\n }\n\n async onChange(data: onChangePayload) {\n if (this.configuration.onChange) {\n this.log(`Document \"${data.documentName}\" changed.`)\n }\n }\n\n async onConnect(data: onConnectPayload) {\n if (this.configuration.onConnect) {\n this.log(`New connection to \"${data.documentName}\".`)\n }\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n if (this.configuration.onDisconnect) {\n this.log(`Connection to \"${data.documentName}\" closed.`)\n }\n }\n\n async onUpgrade(data: onUpgradePayload) {\n if (this.configuration.onUpgrade) {\n this.log('Upgrading connection …')\n }\n }\n\n async onRequest(data: onRequestPayload) {\n if (this.configuration.onRequest) {\n this.log(`Incoming HTTP Request to ${data.request.url}`)\n }\n }\n\n async onDestroy(data: onDestroyPayload) {\n if (this.configuration.onDestroy) {\n this.log('Shut down.')\n }\n }\n\n private log(message: string) {\n const date = (new Date()).toISOString()\n
|
|
1
|
+
{"version":3,"file":"hocuspocus-logger.cjs","sources":["../src/Logger.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onConfigurePayload,\n onConnectPayload,\n onLoadDocumentPayload,\n onDestroyPayload,\n onDisconnectPayload,\n onRequestPayload,\n onUpgradePayload,\n} from '@hocuspocus/server'\n\nexport interface LoggerConfiguration {\n /**\n * Prepend all logging message with a string.\n *\n * @deprecated\n */\n prefix: null | string,\n /**\n * Whether to log something for the `onLoadDocument` hook.\n */\n onLoadDocument: boolean,\n /**\n * Whether to log something for the `onChange` hook.\n */\n onChange: boolean,\n /**\n * Whether to log something for the `onConnect` hook.\n */\n onConnect: boolean,\n /**\n * Whether to log something for the `onDisconnect` hook.\n */\n onDisconnect: boolean,\n /**\n * Whether to log something for the `onUpgrade` hook.\n */\n onUpgrade: boolean,\n /**\n * Whether to log something for the `onRequest` hook.\n */\n onRequest: boolean,\n /**\n * Whether to log something for the `onDestroy` hook.\n */\n onDestroy: boolean,\n /**\n * Whether to log something for the `onConfigure` hook.\n */\n onConfigure: boolean,\n /**\n * A log function, if none is provided output will go to console\n */\n log: (...args: any[]) => void,\n}\n\nexport class Logger implements Extension {\n name: string | null = null\n\n configuration: LoggerConfiguration = {\n prefix: null,\n onLoadDocument: true,\n onChange: true,\n onConnect: true,\n onDisconnect: true,\n onUpgrade: true,\n onRequest: true,\n onDestroy: true,\n onConfigure: true,\n log: console.log, // eslint-disable-line\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<LoggerConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure(data: onConfigurePayload) {\n this.name = data.instance.configuration.name\n\n if (!this.configuration.onConfigure) {\n return\n }\n\n if (this.configuration.prefix) {\n console.warn('[hocuspocus warn] The Logger \\'prefix\\' is deprecated. Pass a \\'name\\' to the Hocuspocus configuration instead.')\n }\n }\n\n async onLoadDocument(data: onLoadDocumentPayload) {\n if (this.configuration.onLoadDocument) {\n this.log(`Loaded document \"${data.documentName}\".`)\n }\n }\n\n async onChange(data: onChangePayload) {\n if (this.configuration.onChange) {\n this.log(`Document \"${data.documentName}\" changed.`)\n }\n }\n\n async onConnect(data: onConnectPayload) {\n if (this.configuration.onConnect) {\n this.log(`New connection to \"${data.documentName}\".`)\n }\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n if (this.configuration.onDisconnect) {\n this.log(`Connection to \"${data.documentName}\" closed.`)\n }\n }\n\n async onUpgrade(data: onUpgradePayload) {\n if (this.configuration.onUpgrade) {\n this.log('Upgrading connection …')\n }\n }\n\n async onRequest(data: onRequestPayload) {\n if (this.configuration.onRequest) {\n this.log(`Incoming HTTP Request to ${data.request.url}`)\n }\n }\n\n async onDestroy(data: onDestroyPayload) {\n if (this.configuration.onDestroy) {\n this.log('Shut down.')\n }\n }\n\n private log(message: string) {\n const date = (new Date()).toISOString()\n let meta = `${date}`\n\n if (this.name) {\n meta = `${this.name} ${meta}`\n }\n\n message = `[${meta}] ${message}`\n\n this.configuration.log(message)\n }\n\n}\n"],"names":[],"mappings":";;;;MAyDa,MAAM;;;;IAmBjB,YAAY,aAA4C;QAlBxD,SAAI,GAAkB,IAAI,CAAA;QAE1B,kBAAa,GAAwB;YACnC,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,IAAI;YACpB,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,YAAY,EAAE,IAAI;YAClB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,IAAI;YACjB,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAA;QAMC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;IAED,MAAM,WAAW,CAAC,IAAwB;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAA;QAE5C,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;YACnC,OAAM;SACP;QAED,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,iHAAiH,CAAC,CAAA;SAChI;KACF;IAED,MAAM,cAAc,CAAC,IAA2B;QAC9C,IAAI,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE;YACrC,IAAI,CAAC,GAAG,CAAC,oBAAoB,IAAI,CAAC,YAAY,IAAI,CAAC,CAAA;SACpD;KACF;IAED,MAAM,QAAQ,CAAC,IAAqB;QAClC,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;YAC/B,IAAI,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,YAAY,YAAY,CAAC,CAAA;SACrD;KACF;IAED,MAAM,SAAS,CAAC,IAAsB;QACpC,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;YAChC,IAAI,CAAC,GAAG,CAAC,sBAAsB,IAAI,CAAC,YAAY,IAAI,CAAC,CAAA;SACtD;KACF;IAED,MAAM,YAAY,CAAC,IAAyB;QAC1C,IAAI,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE;YACnC,IAAI,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,YAAY,WAAW,CAAC,CAAA;SACzD;KACF;IAED,MAAM,SAAS,CAAC,IAAsB;QACpC,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;YAChC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;SACnC;KACF;IAED,MAAM,SAAS,CAAC,IAAsB;QACpC,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;YAChC,IAAI,CAAC,GAAG,CAAC,4BAA4B,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;SACzD;KACF;IAED,MAAM,SAAS,CAAC,IAAsB;QACpC,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;YAChC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;SACvB;KACF;IAEO,GAAG,CAAC,OAAe;QACzB,MAAM,IAAI,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,WAAW,EAAE,CAAA;QACvC,IAAI,IAAI,GAAG,GAAG,IAAI,EAAE,CAAA;QAEpB,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAA;SAC9B;QAED,OAAO,GAAG,IAAI,IAAI,KAAK,OAAO,EAAE,CAAA;QAEhC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;KAChC;;;;;"}
|
|
@@ -67,10 +67,11 @@ class Logger {
|
|
|
67
67
|
}
|
|
68
68
|
log(message) {
|
|
69
69
|
const date = (new Date()).toISOString();
|
|
70
|
-
|
|
70
|
+
let meta = `${date}`;
|
|
71
71
|
if (this.name) {
|
|
72
|
-
|
|
72
|
+
meta = `${this.name} ${meta}`;
|
|
73
73
|
}
|
|
74
|
+
message = `[${meta}] ${message}`;
|
|
74
75
|
this.configuration.log(message);
|
|
75
76
|
}
|
|
76
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-logger.esm.js","sources":["../src/Logger.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onConfigurePayload,\n onConnectPayload,\n onLoadDocumentPayload,\n onDestroyPayload,\n onDisconnectPayload,\n onRequestPayload,\n onUpgradePayload,\n} from '@hocuspocus/server'\n\nexport interface LoggerConfiguration {\n /**\n * Prepend all logging message with a string.\n *\n * @deprecated\n */\n prefix: null | string,\n /**\n * Whether to log something for the `onLoadDocument` hook.\n */\n onLoadDocument: boolean,\n /**\n * Whether to log something for the `onChange` hook.\n */\n onChange: boolean,\n /**\n * Whether to log something for the `onConnect` hook.\n */\n onConnect: boolean,\n /**\n * Whether to log something for the `onDisconnect` hook.\n */\n onDisconnect: boolean,\n /**\n * Whether to log something for the `onUpgrade` hook.\n */\n onUpgrade: boolean,\n /**\n * Whether to log something for the `onRequest` hook.\n */\n onRequest: boolean,\n /**\n * Whether to log something for the `onDestroy` hook.\n */\n onDestroy: boolean,\n /**\n * Whether to log something for the `onConfigure` hook.\n */\n onConfigure: boolean,\n /**\n * A log function, if none is provided output will go to console\n */\n log: (...args: any[]) => void,\n}\n\nexport class Logger implements Extension {\n name: string | null = null\n\n configuration: LoggerConfiguration = {\n prefix: null,\n onLoadDocument: true,\n onChange: true,\n onConnect: true,\n onDisconnect: true,\n onUpgrade: true,\n onRequest: true,\n onDestroy: true,\n onConfigure: true,\n log: console.log, // eslint-disable-line\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<LoggerConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure(data: onConfigurePayload) {\n this.name = data.instance.configuration.name\n\n if (!this.configuration.onConfigure) {\n return\n }\n\n if (this.configuration.prefix) {\n console.warn('[hocuspocus warn] The Logger \\'prefix\\' is deprecated. Pass a \\'name\\' to the Hocuspocus configuration instead.')\n }\n }\n\n async onLoadDocument(data: onLoadDocumentPayload) {\n if (this.configuration.onLoadDocument) {\n this.log(`Loaded document \"${data.documentName}\".`)\n }\n }\n\n async onChange(data: onChangePayload) {\n if (this.configuration.onChange) {\n this.log(`Document \"${data.documentName}\" changed.`)\n }\n }\n\n async onConnect(data: onConnectPayload) {\n if (this.configuration.onConnect) {\n this.log(`New connection to \"${data.documentName}\".`)\n }\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n if (this.configuration.onDisconnect) {\n this.log(`Connection to \"${data.documentName}\" closed.`)\n }\n }\n\n async onUpgrade(data: onUpgradePayload) {\n if (this.configuration.onUpgrade) {\n this.log('Upgrading connection …')\n }\n }\n\n async onRequest(data: onRequestPayload) {\n if (this.configuration.onRequest) {\n this.log(`Incoming HTTP Request to ${data.request.url}`)\n }\n }\n\n async onDestroy(data: onDestroyPayload) {\n if (this.configuration.onDestroy) {\n this.log('Shut down.')\n }\n }\n\n private log(message: string) {\n const date = (new Date()).toISOString()\n
|
|
1
|
+
{"version":3,"file":"hocuspocus-logger.esm.js","sources":["../src/Logger.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onConfigurePayload,\n onConnectPayload,\n onLoadDocumentPayload,\n onDestroyPayload,\n onDisconnectPayload,\n onRequestPayload,\n onUpgradePayload,\n} from '@hocuspocus/server'\n\nexport interface LoggerConfiguration {\n /**\n * Prepend all logging message with a string.\n *\n * @deprecated\n */\n prefix: null | string,\n /**\n * Whether to log something for the `onLoadDocument` hook.\n */\n onLoadDocument: boolean,\n /**\n * Whether to log something for the `onChange` hook.\n */\n onChange: boolean,\n /**\n * Whether to log something for the `onConnect` hook.\n */\n onConnect: boolean,\n /**\n * Whether to log something for the `onDisconnect` hook.\n */\n onDisconnect: boolean,\n /**\n * Whether to log something for the `onUpgrade` hook.\n */\n onUpgrade: boolean,\n /**\n * Whether to log something for the `onRequest` hook.\n */\n onRequest: boolean,\n /**\n * Whether to log something for the `onDestroy` hook.\n */\n onDestroy: boolean,\n /**\n * Whether to log something for the `onConfigure` hook.\n */\n onConfigure: boolean,\n /**\n * A log function, if none is provided output will go to console\n */\n log: (...args: any[]) => void,\n}\n\nexport class Logger implements Extension {\n name: string | null = null\n\n configuration: LoggerConfiguration = {\n prefix: null,\n onLoadDocument: true,\n onChange: true,\n onConnect: true,\n onDisconnect: true,\n onUpgrade: true,\n onRequest: true,\n onDestroy: true,\n onConfigure: true,\n log: console.log, // eslint-disable-line\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<LoggerConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure(data: onConfigurePayload) {\n this.name = data.instance.configuration.name\n\n if (!this.configuration.onConfigure) {\n return\n }\n\n if (this.configuration.prefix) {\n console.warn('[hocuspocus warn] The Logger \\'prefix\\' is deprecated. Pass a \\'name\\' to the Hocuspocus configuration instead.')\n }\n }\n\n async onLoadDocument(data: onLoadDocumentPayload) {\n if (this.configuration.onLoadDocument) {\n this.log(`Loaded document \"${data.documentName}\".`)\n }\n }\n\n async onChange(data: onChangePayload) {\n if (this.configuration.onChange) {\n this.log(`Document \"${data.documentName}\" changed.`)\n }\n }\n\n async onConnect(data: onConnectPayload) {\n if (this.configuration.onConnect) {\n this.log(`New connection to \"${data.documentName}\".`)\n }\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n if (this.configuration.onDisconnect) {\n this.log(`Connection to \"${data.documentName}\" closed.`)\n }\n }\n\n async onUpgrade(data: onUpgradePayload) {\n if (this.configuration.onUpgrade) {\n this.log('Upgrading connection …')\n }\n }\n\n async onRequest(data: onRequestPayload) {\n if (this.configuration.onRequest) {\n this.log(`Incoming HTTP Request to ${data.request.url}`)\n }\n }\n\n async onDestroy(data: onDestroyPayload) {\n if (this.configuration.onDestroy) {\n this.log('Shut down.')\n }\n }\n\n private log(message: string) {\n const date = (new Date()).toISOString()\n let meta = `${date}`\n\n if (this.name) {\n meta = `${this.name} ${meta}`\n }\n\n message = `[${meta}] ${message}`\n\n this.configuration.log(message)\n }\n\n}\n"],"names":[],"mappings":"MAyDa,MAAM;;;;IAmBjB,YAAY,aAA4C;QAlBxD,SAAI,GAAkB,IAAI,CAAA;QAE1B,kBAAa,GAAwB;YACnC,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,IAAI;YACpB,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,IAAI;YACf,YAAY,EAAE,IAAI;YAClB,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI;YACf,WAAW,EAAE,IAAI;YACjB,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAA;QAMC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;IAED,MAAM,WAAW,CAAC,IAAwB;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAA;QAE5C,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;YACnC,OAAM;SACP;QAED,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAC7B,OAAO,CAAC,IAAI,CAAC,iHAAiH,CAAC,CAAA;SAChI;KACF;IAED,MAAM,cAAc,CAAC,IAA2B;QAC9C,IAAI,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE;YACrC,IAAI,CAAC,GAAG,CAAC,oBAAoB,IAAI,CAAC,YAAY,IAAI,CAAC,CAAA;SACpD;KACF;IAED,MAAM,QAAQ,CAAC,IAAqB;QAClC,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;YAC/B,IAAI,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,YAAY,YAAY,CAAC,CAAA;SACrD;KACF;IAED,MAAM,SAAS,CAAC,IAAsB;QACpC,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;YAChC,IAAI,CAAC,GAAG,CAAC,sBAAsB,IAAI,CAAC,YAAY,IAAI,CAAC,CAAA;SACtD;KACF;IAED,MAAM,YAAY,CAAC,IAAyB;QAC1C,IAAI,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE;YACnC,IAAI,CAAC,GAAG,CAAC,kBAAkB,IAAI,CAAC,YAAY,WAAW,CAAC,CAAA;SACzD;KACF;IAED,MAAM,SAAS,CAAC,IAAsB;QACpC,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;YAChC,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;SACnC;KACF;IAED,MAAM,SAAS,CAAC,IAAsB;QACpC,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;YAChC,IAAI,CAAC,GAAG,CAAC,4BAA4B,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;SACzD;KACF;IAED,MAAM,SAAS,CAAC,IAAsB;QACpC,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;YAChC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;SACvB;KACF;IAEO,GAAG,CAAC,OAAe;QACzB,MAAM,IAAI,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,WAAW,EAAE,CAAA;QACvC,IAAI,IAAI,GAAG,GAAG,IAAI,EAAE,CAAA;QAEpB,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE,CAAA;SAC9B;QAED,OAAO,GAAG,IAAI,IAAI,KAAK,OAAO,EAAE,CAAA;QAEhC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;KAChC;;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Extension, onChangePayload, onLoadDocumentPayload } from '@hocuspocus/server';
|
|
3
|
+
export interface DatabaseConfiguration {
|
|
4
|
+
/**
|
|
5
|
+
* Pass a Promise to retrieve updates from your database. The Promise should resolve to
|
|
6
|
+
* an array of items with Y.js-compatible binary data.
|
|
7
|
+
*/
|
|
8
|
+
fetchUpdates: ({ documentName }: {
|
|
9
|
+
documentName: string;
|
|
10
|
+
}) => Promise<Uint8Array[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Pass a function to store updates in your database.
|
|
13
|
+
*/
|
|
14
|
+
storeUpdate: ({ update, documentName }: {
|
|
15
|
+
update: Buffer;
|
|
16
|
+
documentName: string;
|
|
17
|
+
}) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare class Database implements Extension {
|
|
20
|
+
/**
|
|
21
|
+
* Default configuration
|
|
22
|
+
*/
|
|
23
|
+
configuration: DatabaseConfiguration;
|
|
24
|
+
/**
|
|
25
|
+
* Constructor
|
|
26
|
+
*/
|
|
27
|
+
constructor(configuration: Partial<DatabaseConfiguration>);
|
|
28
|
+
/**
|
|
29
|
+
* Get stored data from the database.
|
|
30
|
+
*/
|
|
31
|
+
onLoadDocument({ document, documentName }: onLoadDocumentPayload): Promise<any>;
|
|
32
|
+
/**
|
|
33
|
+
* Store new updates in the database.
|
|
34
|
+
*/
|
|
35
|
+
onChange({ document, documentName }: onChangePayload): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Database';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database';
|
|
2
|
+
import sqlite3 from 'sqlite3';
|
|
3
|
+
export interface SQLiteConfiguration extends DatabaseConfiguration {
|
|
4
|
+
/**
|
|
5
|
+
* Valid values are filenames, ":memory:" for an anonymous in-memory database and an empty
|
|
6
|
+
* string for an anonymous disk-based database. Anonymous databases are not persisted and
|
|
7
|
+
* when closing the database handle, their contents are lost.
|
|
8
|
+
*
|
|
9
|
+
* https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback
|
|
10
|
+
*/
|
|
11
|
+
database: string;
|
|
12
|
+
/**
|
|
13
|
+
* The database schema to create.
|
|
14
|
+
*/
|
|
15
|
+
schema: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class SQLite extends Database {
|
|
18
|
+
db?: sqlite3.Database;
|
|
19
|
+
configuration: SQLiteConfiguration;
|
|
20
|
+
/**
|
|
21
|
+
* Constructor
|
|
22
|
+
*/
|
|
23
|
+
constructor(configuration?: Partial<SQLiteConfiguration>);
|
|
24
|
+
onListen(): Promise<void>;
|
|
25
|
+
onConfigure(): Promise<void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SQLite';
|
|
@@ -42,7 +42,7 @@ export declare class Webhook implements Extension {
|
|
|
42
42
|
/**
|
|
43
43
|
* Send a request to the given url containing the given data
|
|
44
44
|
*/
|
|
45
|
-
sendRequest(event: Events, payload: any): Promise<AxiosResponse<
|
|
45
|
+
sendRequest(event: Events, payload: any): Promise<AxiosResponse<any, any>>;
|
|
46
46
|
/**
|
|
47
47
|
* onChange hook
|
|
48
48
|
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HocuspocusProvider, HocuspocusProviderOptions } from './HocuspocusProvider';
|
|
2
|
+
export interface HocuspocusCloudProviderOptions extends HocuspocusProviderOptions {
|
|
3
|
+
/**
|
|
4
|
+
* A Hocuspocus Cloud key, get one here: https://hocuspocus.cloud/
|
|
5
|
+
*/
|
|
6
|
+
key: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class HocuspocusCloudProvider extends HocuspocusProvider {
|
|
9
|
+
constructor(options: HocuspocusCloudProviderOptions);
|
|
10
|
+
}
|
|
@@ -130,7 +130,7 @@ export declare class HocuspocusProvider extends EventEmitter {
|
|
|
130
130
|
get awareness(): Awareness;
|
|
131
131
|
checkConnection(): void;
|
|
132
132
|
forceSync(): void;
|
|
133
|
-
|
|
133
|
+
registerEventListeners(): void;
|
|
134
134
|
documentUpdateHandler(update: Uint8Array, origin: any): void;
|
|
135
135
|
awarenessUpdateHandler({ added, updated, removed }: any, origin: any): void;
|
|
136
136
|
permissionDeniedHandler(reason: string): void;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-logger",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.61",
|
|
4
4
|
"description": "hocuspocus logging extension",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@hocuspocus/server": "^1.0.0-alpha.
|
|
31
|
+
"@hocuspocus/server": "^1.0.0-alpha.87"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "8ffe8d8f4d10ba33f4f203806bd1d4415bef5dc3"
|
|
34
34
|
}
|
package/src/Logger.ts
CHANGED
|
@@ -137,12 +137,14 @@ export class Logger implements Extension {
|
|
|
137
137
|
|
|
138
138
|
private log(message: string) {
|
|
139
139
|
const date = (new Date()).toISOString()
|
|
140
|
-
|
|
140
|
+
let meta = `${date}`
|
|
141
141
|
|
|
142
142
|
if (this.name) {
|
|
143
|
-
|
|
143
|
+
meta = `${this.name} ${meta}`
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
message = `[${meta}] ${message}`
|
|
147
|
+
|
|
146
148
|
this.configuration.log(message)
|
|
147
149
|
}
|
|
148
150
|
|