@linyjs/plugin-docs 0.1.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/README.md +97 -0
- package/docs/api-reference/index.md +341 -0
- package/docs/best-practices/error-handling.md +462 -0
- package/docs/best-practices/naming-conventions.md +495 -0
- package/docs/best-practices/performance.md +532 -0
- package/docs/best-practices/security.md +620 -0
- package/docs/faq.md +323 -0
- package/docs/getting-started/first-plugin.md +358 -0
- package/docs/getting-started/installation.md +244 -0
- package/docs/getting-started/quick-start.md +174 -0
- package/docs/guides/client-module.md +598 -0
- package/docs/guides/data-persistence.md +536 -0
- package/docs/guides/permissions.md +440 -0
- package/docs/guides/server-module.md +371 -0
- package/docs/guides/ui-slots.md +475 -0
- package/docs/migration/v0-to-v1.md +354 -0
- package/examples/analytics-plugin/README.md +416 -0
- package/examples/analytics-plugin/dist/client/index.d.ts +36 -0
- package/examples/analytics-plugin/dist/client/index.js +173 -0
- package/examples/analytics-plugin/dist/index.d.ts +64 -0
- package/examples/analytics-plugin/dist/index.js +72 -0
- package/examples/analytics-plugin/dist/server/index.d.ts +119 -0
- package/examples/analytics-plugin/dist/server/index.js +313 -0
- package/examples/analytics-plugin/package.json +28 -0
- package/examples/analytics-plugin/src/client/index.tsx +410 -0
- package/examples/analytics-plugin/src/index.ts +71 -0
- package/examples/analytics-plugin/src/server/index.ts +348 -0
- package/examples/analytics-plugin/tsconfig.json +21 -0
- package/examples/blog-plugin/README.md +316 -0
- package/examples/blog-plugin/dist/client/index.d.ts +22 -0
- package/examples/blog-plugin/dist/client/index.js +197 -0
- package/examples/blog-plugin/dist/server/index.d.ts +5 -0
- package/examples/blog-plugin/dist/server/index.js +220 -0
- package/examples/blog-plugin/package.json +24 -0
- package/examples/blog-plugin/src/client/index.tsx +405 -0
- package/examples/blog-plugin/src/server/index.ts +240 -0
- package/examples/blog-plugin/tsconfig.json +16 -0
- package/examples/hello-world/README.md +101 -0
- package/examples/hello-world/dist/client/index.d.ts +5 -0
- package/examples/hello-world/dist/client/index.js +80 -0
- package/examples/hello-world/dist/server/index.d.ts +5 -0
- package/examples/hello-world/dist/server/index.js +38 -0
- package/examples/hello-world/node_modules/.package-lock.json +61 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/HOOKS_USAGE.md +281 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/IMPLEMENTATION_SUMMARY.md +166 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/QUICK_REFERENCE.md +130 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/README.md +214 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/package.json +26 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/application.ts +50 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/comparison-example.tsx +229 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/di.ts +127 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/domain.ts +52 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/hooks-example.tsx +275 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/hooks.ts +175 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/index.ts +87 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/interfaces.ts +117 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/src/router.ts +49 -0
- package/examples/hello-world/node_modules/@linyjs/client-module-interface/tsconfig.json +10 -0
- package/examples/hello-world/node_modules/@linyjs/server-module-interface/package.json +21 -0
- package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/application.ts +21 -0
- package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/di.ts +127 -0
- package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/domain.ts +75 -0
- package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/index.ts +55 -0
- package/examples/hello-world/node_modules/@linyjs/server-module-interface/src/interfaces.ts +58 -0
- package/examples/hello-world/node_modules/@linyjs/server-module-interface/tsconfig.json +8 -0
- package/examples/hello-world/node_modules/@types/react/LICENSE +21 -0
- package/examples/hello-world/node_modules/@types/react/README.md +15 -0
- package/examples/hello-world/node_modules/@types/react/canary.d.ts +129 -0
- package/examples/hello-world/node_modules/@types/react/compiler-runtime.d.ts +4 -0
- package/examples/hello-world/node_modules/@types/react/experimental.d.ts +184 -0
- package/examples/hello-world/node_modules/@types/react/global.d.ts +166 -0
- package/examples/hello-world/node_modules/@types/react/index.d.ts +4369 -0
- package/examples/hello-world/node_modules/@types/react/jsx-dev-runtime.d.ts +33 -0
- package/examples/hello-world/node_modules/@types/react/jsx-runtime.d.ts +24 -0
- package/examples/hello-world/node_modules/@types/react/package.json +210 -0
- package/examples/hello-world/node_modules/@types/react/ts5.0/canary.d.ts +129 -0
- package/examples/hello-world/node_modules/@types/react/ts5.0/experimental.d.ts +184 -0
- package/examples/hello-world/node_modules/@types/react/ts5.0/global.d.ts +166 -0
- package/examples/hello-world/node_modules/@types/react/ts5.0/index.d.ts +4356 -0
- package/examples/hello-world/node_modules/@types/react/ts5.0/jsx-dev-runtime.d.ts +33 -0
- package/examples/hello-world/node_modules/@types/react/ts5.0/jsx-runtime.d.ts +24 -0
- package/examples/hello-world/node_modules/csstype/LICENSE +19 -0
- package/examples/hello-world/node_modules/csstype/README.md +291 -0
- package/examples/hello-world/node_modules/csstype/index.d.ts +22569 -0
- package/examples/hello-world/node_modules/csstype/index.js.flow +6863 -0
- package/examples/hello-world/node_modules/csstype/package.json +70 -0
- package/examples/hello-world/node_modules/react/LICENSE +21 -0
- package/examples/hello-world/node_modules/react/README.md +37 -0
- package/examples/hello-world/node_modules/react/cjs/react-compiler-runtime.development.js +24 -0
- package/examples/hello-world/node_modules/react/cjs/react-compiler-runtime.production.js +16 -0
- package/examples/hello-world/node_modules/react/cjs/react-compiler-runtime.profiling.js +16 -0
- package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.development.js +338 -0
- package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.production.js +14 -0
- package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.profiling.js +14 -0
- package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.react-server.development.js +370 -0
- package/examples/hello-world/node_modules/react/cjs/react-jsx-dev-runtime.react-server.production.js +40 -0
- package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.development.js +352 -0
- package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.production.js +34 -0
- package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.profiling.js +34 -0
- package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.react-server.development.js +370 -0
- package/examples/hello-world/node_modules/react/cjs/react-jsx-runtime.react-server.production.js +40 -0
- package/examples/hello-world/node_modules/react/cjs/react.development.js +1284 -0
- package/examples/hello-world/node_modules/react/cjs/react.production.js +542 -0
- package/examples/hello-world/node_modules/react/cjs/react.react-server.development.js +848 -0
- package/examples/hello-world/node_modules/react/cjs/react.react-server.production.js +423 -0
- package/examples/hello-world/node_modules/react/compiler-runtime.js +14 -0
- package/examples/hello-world/node_modules/react/index.js +7 -0
- package/examples/hello-world/node_modules/react/jsx-dev-runtime.js +7 -0
- package/examples/hello-world/node_modules/react/jsx-dev-runtime.react-server.js +7 -0
- package/examples/hello-world/node_modules/react/jsx-runtime.js +7 -0
- package/examples/hello-world/node_modules/react/jsx-runtime.react-server.js +7 -0
- package/examples/hello-world/node_modules/react/package.json +51 -0
- package/examples/hello-world/node_modules/react/react.react-server.js +7 -0
- package/examples/hello-world/node_modules/typescript/LICENSE.txt +55 -0
- package/examples/hello-world/node_modules/typescript/README.md +50 -0
- package/examples/hello-world/node_modules/typescript/SECURITY.md +41 -0
- package/examples/hello-world/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
- package/examples/hello-world/node_modules/typescript/bin/tsc +2 -0
- package/examples/hello-world/node_modules/typescript/bin/tsserver +2 -0
- package/examples/hello-world/node_modules/typescript/lib/_tsc.js +133818 -0
- package/examples/hello-world/node_modules/typescript/lib/_tsserver.js +659 -0
- package/examples/hello-world/node_modules/typescript/lib/_typingsInstaller.js +222 -0
- package/examples/hello-world/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.d.ts +22 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.es6.d.ts +23 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
- package/examples/hello-world/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
- package/examples/hello-world/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/tsc.js +8 -0
- package/examples/hello-world/node_modules/typescript/lib/tsserver.js +8 -0
- package/examples/hello-world/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
- package/examples/hello-world/node_modules/typescript/lib/tsserverlibrary.js +21 -0
- package/examples/hello-world/node_modules/typescript/lib/typesMap.json +497 -0
- package/examples/hello-world/node_modules/typescript/lib/typescript.d.ts +11437 -0
- package/examples/hello-world/node_modules/typescript/lib/typescript.js +200276 -0
- package/examples/hello-world/node_modules/typescript/lib/typingsInstaller.js +8 -0
- package/examples/hello-world/node_modules/typescript/lib/watchGuard.js +53 -0
- package/examples/hello-world/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
- package/examples/hello-world/node_modules/typescript/package.json +120 -0
- package/examples/hello-world/package-lock.json +74 -0
- package/examples/hello-world/package.json +23 -0
- package/examples/hello-world/src/client/index.tsx +110 -0
- package/examples/hello-world/src/server/index.ts +42 -0
- package/examples/hello-world/tsconfig.json +16 -0
- package/package.json +42 -0
- package/src/cli.ts +321 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.analyticsClientModule = exports.analyticsServerModule = void 0;
|
|
4
|
+
const server_1 = require("./server");
|
|
5
|
+
const client_1 = require("./client");
|
|
6
|
+
var server_2 = require("./server");
|
|
7
|
+
Object.defineProperty(exports, "analyticsServerModule", { enumerable: true, get: function () { return server_2.analyticsServerModule; } });
|
|
8
|
+
var client_2 = require("./client");
|
|
9
|
+
Object.defineProperty(exports, "analyticsClientModule", { enumerable: true, get: function () { return client_2.analyticsClientModule; } });
|
|
10
|
+
// 默认导出两个模块(同时适用于服务端和客户端)
|
|
11
|
+
const analyticsPlugin = {
|
|
12
|
+
server: server_1.analyticsServerModule,
|
|
13
|
+
client: client_1.analyticsClientModule
|
|
14
|
+
};
|
|
15
|
+
exports.default = analyticsPlugin;
|
|
16
|
+
/**
|
|
17
|
+
* @module @linyjs/example-analytics-plugin
|
|
18
|
+
*
|
|
19
|
+
* Analytics Plugin Example
|
|
20
|
+
* ===============
|
|
21
|
+
*
|
|
22
|
+
* Features:
|
|
23
|
+
* - 📊 Real-time analytics dashboard
|
|
24
|
+
* - 📈 User behavior tracking
|
|
25
|
+
* - 🔄 Hourly data aggregation (cron job)
|
|
26
|
+
* - 📈 User retention analysis
|
|
27
|
+
* - 🌊 Live metrics monitoring
|
|
28
|
+
* - 📱 Responsive web interface
|
|
29
|
+
*
|
|
30
|
+
* Server-side:
|
|
31
|
+
* - AnalyticsService: Core analytics logic
|
|
32
|
+
* - AnalyticsController: REST API endpoints
|
|
33
|
+
* - AnalyticsCronService: Background aggregation task
|
|
34
|
+
*
|
|
35
|
+
* Client-side:
|
|
36
|
+
* - AnalyticsDashboard: Main dashboard UI
|
|
37
|
+
* - AnalyticsTracker: Event tracking utility
|
|
38
|
+
* - Visual charts and metrics display
|
|
39
|
+
*
|
|
40
|
+
* API Endpoints:
|
|
41
|
+
* - POST /api/analytics/track - Track events
|
|
42
|
+
* - GET /api/analytics/summary - Get analytics summary
|
|
43
|
+
* - GET /api/analytics/realtime - Get real-time stats
|
|
44
|
+
* - GET /api/analytics/retention - Get user retention
|
|
45
|
+
* - POST /api/analytics/aggregate - Manual aggregation
|
|
46
|
+
*
|
|
47
|
+
* Usage:
|
|
48
|
+
*
|
|
49
|
+
* 1. Include in your Linyjs app:
|
|
50
|
+
* ```typescript
|
|
51
|
+
* import { analyticsServerModule } from '@linyjs/example-analytics-plugin';
|
|
52
|
+
*
|
|
53
|
+
* // In server config
|
|
54
|
+
* plugins: [analyticsServerModule]
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* 2. Track events from client:
|
|
58
|
+
* ```javascript
|
|
59
|
+
* fetch('/api/analytics/track', {
|
|
60
|
+
* method: 'POST',
|
|
61
|
+
* headers: { 'Content-Type': 'application/json' },
|
|
62
|
+
* body: JSON.stringify({
|
|
63
|
+
* eventName: 'page_view',
|
|
64
|
+
* userId: 'user123',
|
|
65
|
+
* data: { page: '/home' }
|
|
66
|
+
* })
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* 3. View analytics dashboard:
|
|
71
|
+
* Access at `/analytics` route in your app
|
|
72
|
+
*/
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { IModule } from '@linyjs/server-module-interface';
|
|
2
|
+
/**
|
|
3
|
+
* 分析数据服务 - 收集和聚合应用使用数据
|
|
4
|
+
*/
|
|
5
|
+
declare class AnalyticsService {
|
|
6
|
+
private metrics;
|
|
7
|
+
private users;
|
|
8
|
+
/**
|
|
9
|
+
* 记录用户行为事件
|
|
10
|
+
*/
|
|
11
|
+
trackEvent(eventName: string, userId: string, data: any): Promise<{
|
|
12
|
+
success: boolean;
|
|
13
|
+
eventId: number;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* 获取指定时间范围内的统计汇总
|
|
17
|
+
*/
|
|
18
|
+
getAnalytics(startDate: string, endDate: string): Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* 获取实时在线用户数(模拟)
|
|
21
|
+
*/
|
|
22
|
+
getRealTimeStats(): Promise<{
|
|
23
|
+
onlineUsers: number;
|
|
24
|
+
currentEvents: number;
|
|
25
|
+
serverTime: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* 定时聚合任务 - 每小时运行一次
|
|
29
|
+
*/
|
|
30
|
+
runHourlyAggregation(): Promise<{
|
|
31
|
+
period: string;
|
|
32
|
+
summary: any;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* 用户留存率分析
|
|
36
|
+
*/
|
|
37
|
+
getUserRetention(days?: number): Promise<any>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 分析控制器 - 提供API接口
|
|
41
|
+
*/
|
|
42
|
+
declare class AnalyticsController {
|
|
43
|
+
private analyticsService;
|
|
44
|
+
constructor();
|
|
45
|
+
getRoutes(): ({
|
|
46
|
+
method: "POST";
|
|
47
|
+
path: string;
|
|
48
|
+
middlewares: never[];
|
|
49
|
+
responseType: "json";
|
|
50
|
+
handler: (params: any, ctx: any) => Promise<{
|
|
51
|
+
success: boolean;
|
|
52
|
+
data: {
|
|
53
|
+
success: boolean;
|
|
54
|
+
eventId: number;
|
|
55
|
+
};
|
|
56
|
+
status?: undefined;
|
|
57
|
+
} | {
|
|
58
|
+
status: number;
|
|
59
|
+
data: {
|
|
60
|
+
error: any;
|
|
61
|
+
};
|
|
62
|
+
success?: undefined;
|
|
63
|
+
}>;
|
|
64
|
+
} | {
|
|
65
|
+
method: "GET";
|
|
66
|
+
path: string;
|
|
67
|
+
middlewares: never[];
|
|
68
|
+
responseType: "json";
|
|
69
|
+
handler: (params: any, ctx: any) => Promise<any>;
|
|
70
|
+
} | {
|
|
71
|
+
method: "POST";
|
|
72
|
+
path: string;
|
|
73
|
+
middlewares: never[];
|
|
74
|
+
responseType: "json";
|
|
75
|
+
handler: (params: any, ctx: any) => Promise<{
|
|
76
|
+
success: boolean;
|
|
77
|
+
data: {
|
|
78
|
+
period: string;
|
|
79
|
+
summary: any;
|
|
80
|
+
};
|
|
81
|
+
status?: undefined;
|
|
82
|
+
} | {
|
|
83
|
+
status: number;
|
|
84
|
+
data: {
|
|
85
|
+
error: any;
|
|
86
|
+
};
|
|
87
|
+
success?: undefined;
|
|
88
|
+
}>;
|
|
89
|
+
})[];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 定时任务服务
|
|
93
|
+
*/
|
|
94
|
+
declare class AnalyticsCronService {
|
|
95
|
+
private analyticsService;
|
|
96
|
+
private intervalId;
|
|
97
|
+
constructor();
|
|
98
|
+
/**
|
|
99
|
+
* 启动定时聚合任务
|
|
100
|
+
*/
|
|
101
|
+
startHourlyAggregation(): void;
|
|
102
|
+
/**
|
|
103
|
+
* 停止定时聚合任务
|
|
104
|
+
*/
|
|
105
|
+
stopHourlyAggregation(): void;
|
|
106
|
+
/**
|
|
107
|
+
* 插件启动时调用
|
|
108
|
+
*/
|
|
109
|
+
onModuleInit(): void;
|
|
110
|
+
/**
|
|
111
|
+
* 插件销毁时调用
|
|
112
|
+
*/
|
|
113
|
+
onModuleDestroy(): void;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 服务端模块
|
|
117
|
+
*/
|
|
118
|
+
export declare const analyticsServerModule: IModule;
|
|
119
|
+
export { AnalyticsService, AnalyticsController, AnalyticsCronService };
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnalyticsCronService = exports.AnalyticsController = exports.AnalyticsService = exports.analyticsServerModule = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 分析数据服务 - 收集和聚合应用使用数据
|
|
6
|
+
*/
|
|
7
|
+
class AnalyticsService {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.metrics = new Map();
|
|
10
|
+
this.users = new Map();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 记录用户行为事件
|
|
14
|
+
*/
|
|
15
|
+
async trackEvent(eventName, userId, data) {
|
|
16
|
+
const event = {
|
|
17
|
+
id: Date.now(),
|
|
18
|
+
eventName,
|
|
19
|
+
userId,
|
|
20
|
+
timestamp: new Date().toISOString(),
|
|
21
|
+
data
|
|
22
|
+
};
|
|
23
|
+
if (!this.metrics.has(eventName)) {
|
|
24
|
+
this.metrics.set(eventName, []);
|
|
25
|
+
}
|
|
26
|
+
this.metrics.get(eventName).push(event);
|
|
27
|
+
return { success: true, eventId: event.id };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 获取指定时间范围内的统计汇总
|
|
31
|
+
*/
|
|
32
|
+
async getAnalytics(startDate, endDate) {
|
|
33
|
+
const start = new Date(startDate);
|
|
34
|
+
const end = new Date(endDate);
|
|
35
|
+
const result = {
|
|
36
|
+
totalEvents: 0,
|
|
37
|
+
eventsByDay: {},
|
|
38
|
+
eventTypes: {},
|
|
39
|
+
activeUsers: 0,
|
|
40
|
+
topEvents: []
|
|
41
|
+
};
|
|
42
|
+
// 统计各类事件
|
|
43
|
+
for (const [eventName, events] of this.metrics.entries()) {
|
|
44
|
+
const filtered = events.filter(event => {
|
|
45
|
+
const eventDate = new Date(event.timestamp);
|
|
46
|
+
return eventDate >= start && eventDate <= end;
|
|
47
|
+
});
|
|
48
|
+
if (filtered.length > 0) {
|
|
49
|
+
result.eventTypes[eventName] = filtered.length;
|
|
50
|
+
result.totalEvents += filtered.length;
|
|
51
|
+
// 统计每日事件
|
|
52
|
+
filtered.forEach(event => {
|
|
53
|
+
const day = event.timestamp.split('T')[0];
|
|
54
|
+
result.eventsByDay[day] = (result.eventsByDay[day] || 0) + 1;
|
|
55
|
+
});
|
|
56
|
+
// 记录活跃用户
|
|
57
|
+
const uniqueUsers = new Set(filtered.map(e => e.userId));
|
|
58
|
+
result.activeUsers = Math.max(result.activeUsers, uniqueUsers.size);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// 计算热门事件
|
|
62
|
+
result.topEvents = Object.entries(result.eventTypes)
|
|
63
|
+
.sort(([, a], [, b]) => b - a)
|
|
64
|
+
.slice(0, 10)
|
|
65
|
+
.map(([name, count]) => ({ name, count }));
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 获取实时在线用户数(模拟)
|
|
70
|
+
*/
|
|
71
|
+
async getRealTimeStats() {
|
|
72
|
+
// 模拟实时数据
|
|
73
|
+
const onlineUsers = Math.floor(Math.random() * 100) + 50;
|
|
74
|
+
const currentEvents = Math.floor(Math.random() * 20) + 5;
|
|
75
|
+
return {
|
|
76
|
+
onlineUsers,
|
|
77
|
+
currentEvents,
|
|
78
|
+
serverTime: new Date().toISOString()
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 定时聚合任务 - 每小时运行一次
|
|
83
|
+
*/
|
|
84
|
+
async runHourlyAggregation() {
|
|
85
|
+
const now = new Date();
|
|
86
|
+
const hourStart = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours());
|
|
87
|
+
const hourEnd = new Date(hourStart.getTime() + 60 * 60 * 1000);
|
|
88
|
+
const hourData = await this.getAnalytics(hourStart.toISOString(), hourEnd.toISOString());
|
|
89
|
+
// 这里可以将聚合数据保存到数据库,现在只返回
|
|
90
|
+
return {
|
|
91
|
+
period: `${hourStart.toISOString()} to ${hourEnd.toISOString()}`,
|
|
92
|
+
summary: hourData
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* 用户留存率分析
|
|
97
|
+
*/
|
|
98
|
+
async getUserRetention(days = 7) {
|
|
99
|
+
const now = new Date();
|
|
100
|
+
const retentionData = {
|
|
101
|
+
dayIntervals: [],
|
|
102
|
+
newUsers: [],
|
|
103
|
+
returningUsers: []
|
|
104
|
+
};
|
|
105
|
+
// 模拟留存率数据
|
|
106
|
+
for (let i = 0; i < days; i++) {
|
|
107
|
+
const date = new Date(now.getTime() - i * 24 * 60 * 60 * 1000);
|
|
108
|
+
const dayKey = date.toISOString().split('T')[0];
|
|
109
|
+
retentionData.dayIntervals.push(dayKey);
|
|
110
|
+
retentionData.newUsers.push(Math.floor(Math.random() * 50) + 10);
|
|
111
|
+
retentionData.returningUsers.push(Math.floor(Math.random() * 30) + 5);
|
|
112
|
+
}
|
|
113
|
+
// 计算留存率
|
|
114
|
+
retentionData.retentionRates = retentionData.returningUsers.map((returning, index) => {
|
|
115
|
+
const newUsers = retentionData.newUsers[index] || 1;
|
|
116
|
+
return ((returning / newUsers) * 100).toFixed(1);
|
|
117
|
+
});
|
|
118
|
+
return retentionData;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.AnalyticsService = AnalyticsService;
|
|
122
|
+
/**
|
|
123
|
+
* 分析控制器 - 提供API接口
|
|
124
|
+
*/
|
|
125
|
+
class AnalyticsController {
|
|
126
|
+
constructor() {
|
|
127
|
+
this.analyticsService = new AnalyticsService();
|
|
128
|
+
}
|
|
129
|
+
getRoutes() {
|
|
130
|
+
return [
|
|
131
|
+
// POST /api/analytics/track - 记录事件
|
|
132
|
+
{
|
|
133
|
+
method: 'POST',
|
|
134
|
+
path: '/api/analytics/track',
|
|
135
|
+
middlewares: [],
|
|
136
|
+
responseType: 'json',
|
|
137
|
+
handler: async (params, ctx) => {
|
|
138
|
+
try {
|
|
139
|
+
const { eventName, userId, data } = params.body;
|
|
140
|
+
if (!eventName || !userId) {
|
|
141
|
+
return {
|
|
142
|
+
status: 400,
|
|
143
|
+
data: { error: 'eventName and userId are required' }
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const result = await this.analyticsService.trackEvent(eventName, userId, data);
|
|
147
|
+
return { success: true, data: result };
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
return {
|
|
151
|
+
status: 500,
|
|
152
|
+
data: { error: error.message }
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
// GET /api/analytics/summary - 获取分析摘要
|
|
158
|
+
{
|
|
159
|
+
method: 'GET',
|
|
160
|
+
path: '/api/analytics/summary',
|
|
161
|
+
middlewares: [],
|
|
162
|
+
responseType: 'json',
|
|
163
|
+
handler: async (params, ctx) => {
|
|
164
|
+
var _a, _b;
|
|
165
|
+
try {
|
|
166
|
+
const startDate = ((_a = params.query) === null || _a === void 0 ? void 0 : _a.start) || new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
|
|
167
|
+
const endDate = ((_b = params.query) === null || _b === void 0 ? void 0 : _b.end) || new Date().toISOString();
|
|
168
|
+
const result = await this.analyticsService.getAnalytics(startDate, endDate);
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
return {
|
|
173
|
+
status: 500,
|
|
174
|
+
data: { error: error.message }
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
// GET /api/analytics/realtime - 获取实时统计
|
|
180
|
+
{
|
|
181
|
+
method: 'GET',
|
|
182
|
+
path: '/api/analytics/realtime',
|
|
183
|
+
middlewares: [],
|
|
184
|
+
responseType: 'json',
|
|
185
|
+
handler: async (params, ctx) => {
|
|
186
|
+
try {
|
|
187
|
+
const result = await this.analyticsService.getRealTimeStats();
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
return {
|
|
192
|
+
status: 500,
|
|
193
|
+
data: { error: error.message }
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
// GET /api/analytics/retention - 用户留存分析
|
|
199
|
+
{
|
|
200
|
+
method: 'GET',
|
|
201
|
+
path: '/api/analytics/retention',
|
|
202
|
+
middlewares: [],
|
|
203
|
+
responseType: 'json',
|
|
204
|
+
handler: async (params, ctx) => {
|
|
205
|
+
var _a;
|
|
206
|
+
try {
|
|
207
|
+
const days = parseInt(((_a = params.query) === null || _a === void 0 ? void 0 : _a.days) || '7');
|
|
208
|
+
const result = await this.analyticsService.getUserRetention(days);
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
return {
|
|
213
|
+
status: 500,
|
|
214
|
+
data: { error: error.message }
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
// POST /api/analytics/aggregate - 手动触发聚合 (管理员用)
|
|
220
|
+
{
|
|
221
|
+
method: 'POST',
|
|
222
|
+
path: '/api/analytics/aggregate',
|
|
223
|
+
middlewares: [],
|
|
224
|
+
responseType: 'json',
|
|
225
|
+
handler: async (params, ctx) => {
|
|
226
|
+
try {
|
|
227
|
+
const result = await this.analyticsService.runHourlyAggregation();
|
|
228
|
+
return { success: true, data: result };
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
return {
|
|
232
|
+
status: 500,
|
|
233
|
+
data: { error: error.message }
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.AnalyticsController = AnalyticsController;
|
|
242
|
+
/**
|
|
243
|
+
* 定时任务服务
|
|
244
|
+
*/
|
|
245
|
+
class AnalyticsCronService {
|
|
246
|
+
constructor() {
|
|
247
|
+
this.intervalId = null;
|
|
248
|
+
this.analyticsService = new AnalyticsService();
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* 启动定时聚合任务
|
|
252
|
+
*/
|
|
253
|
+
startHourlyAggregation() {
|
|
254
|
+
// 每小时执行一次聚合
|
|
255
|
+
this.intervalId = setInterval(async () => {
|
|
256
|
+
try {
|
|
257
|
+
const result = await this.analyticsService.runHourlyAggregation();
|
|
258
|
+
console.log('Analytics aggregation completed:', result.period);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
console.error('Analytics aggregation failed:', error);
|
|
262
|
+
}
|
|
263
|
+
}, 60 * 60 * 1000); // 1小时
|
|
264
|
+
console.log('Started analytics hourly aggregation');
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* 停止定时聚合任务
|
|
268
|
+
*/
|
|
269
|
+
stopHourlyAggregation() {
|
|
270
|
+
if (this.intervalId) {
|
|
271
|
+
clearInterval(this.intervalId);
|
|
272
|
+
this.intervalId = null;
|
|
273
|
+
console.log('Stopped analytics hourly aggregation');
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* 插件启动时调用
|
|
278
|
+
*/
|
|
279
|
+
onModuleInit() {
|
|
280
|
+
this.startHourlyAggregation();
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* 插件销毁时调用
|
|
284
|
+
*/
|
|
285
|
+
onModuleDestroy() {
|
|
286
|
+
this.stopHourlyAggregation();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
exports.AnalyticsCronService = AnalyticsCronService;
|
|
290
|
+
/**
|
|
291
|
+
* 服务端模块
|
|
292
|
+
*/
|
|
293
|
+
exports.analyticsServerModule = {
|
|
294
|
+
name: 'analyticsServer',
|
|
295
|
+
serviceDefs: [
|
|
296
|
+
{
|
|
297
|
+
serviceTag: 'analyticsController',
|
|
298
|
+
serviceImpl: AnalyticsController,
|
|
299
|
+
meta: { usageType: 'controller' }
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
serviceTag: 'analyticsCron',
|
|
303
|
+
serviceImpl: AnalyticsCronService,
|
|
304
|
+
meta: {
|
|
305
|
+
usageType: 'service',
|
|
306
|
+
lifecycle: {
|
|
307
|
+
init: 'onModuleInit',
|
|
308
|
+
destroy: 'onModuleDestroy'
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
]
|
|
313
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@linyjs/example-analytics-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Analytics plugin example - Dashboard and metrics collection for Linyjs apps",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "tsc --watch",
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"serve": "node dist/index.js",
|
|
10
|
+
"test": "echo \"No tests yet\""
|
|
11
|
+
},
|
|
12
|
+
"keywords": ["linyjs", "example", "plugin", "analytics", "dashboard"],
|
|
13
|
+
"author": "Linyjs Team",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@linyjs/server-module-interface": "0.0.3",
|
|
17
|
+
"@linyjs/client-module-interface": "0.0.3",
|
|
18
|
+
"@linyjs/ui-slots-interface": "0.0.3"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@linyjs/server-module-interface": "0.0.3",
|
|
22
|
+
"@linyjs/client-module-interface": "0.0.3"
|
|
23
|
+
},
|
|
24
|
+
"linyjs": {
|
|
25
|
+
"compatibleVersions": ["0.8.x"],
|
|
26
|
+
"type": "plugin"
|
|
27
|
+
}
|
|
28
|
+
}
|