target-supabase-sdk 0.1.9 → 0.2.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.
- package/README.md +184 -1
- package/dist/browser.d.ts +60 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +6 -0
- package/dist/browser.js.map +1 -0
- package/dist/chunks/create-logger-DyH3mZ8p.js +1028 -0
- package/dist/chunks/create-logger-DyH3mZ8p.js.map +1 -0
- package/dist/chunks/enable-log-persist-C_bSw6Kx.js +1362 -0
- package/dist/chunks/enable-log-persist-C_bSw6Kx.js.map +1 -0
- package/dist/chunks/word.interface-DLgRobKV.js +1973 -0
- package/dist/chunks/word.interface-DLgRobKV.js.map +1 -0
- package/dist/command/command.api.d.ts +1 -1
- package/dist/command/command.api.d.ts.map +1 -1
- package/dist/command/command.interface.d.ts +1 -1
- package/dist/command/command.interface.d.ts.map +1 -1
- package/dist/core.api.d.ts +10 -6
- package/dist/core.api.d.ts.map +1 -1
- package/dist/core.interface.d.ts +3 -2
- package/dist/core.interface.d.ts.map +1 -1
- package/dist/core.utils.d.ts +1 -1
- package/dist/core.utils.d.ts.map +1 -1
- package/dist/idea/idea.interface.d.ts +1 -1
- package/dist/idea/idea.interface.d.ts.map +1 -1
- package/dist/index.d.ts +2 -48
- package/dist/index.d.ts.map +1 -1
- package/dist/link/link.api.d.ts +1 -1
- package/dist/link/link.api.d.ts.map +1 -1
- package/dist/link/link.interface.d.ts +3 -3
- package/dist/link/link.interface.d.ts.map +1 -1
- package/dist/list/list.api.d.ts +3 -1
- package/dist/list/list.api.d.ts.map +1 -1
- package/dist/list/list.interface.d.ts +2 -2
- package/dist/list/list.interface.d.ts.map +1 -1
- package/dist/node/env/env-parsers.d.ts +19 -0
- package/dist/node/env/env-parsers.d.ts.map +1 -0
- package/dist/node/env/index.d.ts +11 -0
- package/dist/node/env/index.d.ts.map +1 -0
- package/dist/node/env/init-supabase-from-env.d.ts +17 -0
- package/dist/node/env/init-supabase-from-env.d.ts.map +1 -0
- package/dist/node/env/load-env.d.ts +20 -0
- package/dist/node/env/load-env.d.ts.map +1 -0
- package/dist/node/env/project-root.d.ts +11 -0
- package/dist/node/env/project-root.d.ts.map +1 -0
- package/dist/node/env/public-base-url.d.ts +10 -0
- package/dist/node/env/public-base-url.d.ts.map +1 -0
- package/dist/node/env/require-env.d.ts +3 -0
- package/dist/node/env/require-env.d.ts.map +1 -0
- package/dist/node/fs/json-state-store.d.ts +19 -0
- package/dist/node/fs/json-state-store.d.ts.map +1 -0
- package/dist/node/fs/read-source-file.d.ts +19 -0
- package/dist/node/fs/read-source-file.d.ts.map +1 -0
- package/dist/node/node-liveness.d.ts +30 -0
- package/dist/node/node-liveness.d.ts.map +1 -0
- package/dist/node/node-runtime.base.d.ts +60 -0
- package/dist/node/node-runtime.base.d.ts.map +1 -0
- package/dist/node/node.api.d.ts +4 -4
- package/dist/node/node.api.d.ts.map +1 -1
- package/dist/node/node.interface.d.ts +1 -6
- package/dist/node/node.interface.d.ts.map +1 -1
- package/dist/node/preload/run-service-preload.d.ts +14 -0
- package/dist/node/preload/run-service-preload.d.ts.map +1 -0
- package/dist/node/preload/service-preload.interface.d.ts +15 -0
- package/dist/node/preload/service-preload.interface.d.ts.map +1 -0
- package/dist/node/process/index.d.ts +5 -0
- package/dist/node/process/index.d.ts.map +1 -0
- package/dist/node/process/managed-child-processes.d.ts +37 -0
- package/dist/node/process/managed-child-processes.d.ts.map +1 -0
- package/dist/node/process/process-spawn.d.ts +27 -0
- package/dist/node/process/process-spawn.d.ts.map +1 -0
- package/dist/node/readiness/index.d.ts +9 -0
- package/dist/node/readiness/index.d.ts.map +1 -0
- package/dist/node/readiness/poll-until.d.ts +11 -0
- package/dist/node/readiness/poll-until.d.ts.map +1 -0
- package/dist/node/readiness/readiness-checks.d.ts +22 -0
- package/dist/node/readiness/readiness-checks.d.ts.map +1 -0
- package/dist/node/readiness/readiness.types.d.ts +12 -0
- package/dist/node/readiness/readiness.types.d.ts.map +1 -0
- package/dist/node/readiness/run-readiness-checks.d.ts +4 -0
- package/dist/node/readiness/run-readiness-checks.d.ts.map +1 -0
- package/dist/node/readiness/service-ready-gate.d.ts +26 -0
- package/dist/node/readiness/service-ready-gate.d.ts.map +1 -0
- package/dist/node.d.ts +36 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +2483 -0
- package/dist/node.js.map +1 -0
- package/dist/parcel/chunk-fetch-registry.d.ts +14 -0
- package/dist/parcel/chunk-fetch-registry.d.ts.map +1 -0
- package/dist/parcel/chunk-url.utils.d.ts +9 -0
- package/dist/parcel/chunk-url.utils.d.ts.map +1 -0
- package/dist/parcel/parcel-manager.d.ts +44 -20
- package/dist/parcel/parcel-manager.d.ts.map +1 -1
- package/dist/parcel/parcel.api.d.ts +306 -0
- package/dist/parcel/parcel.api.d.ts.map +1 -0
- package/dist/parcel/parcel.interface.d.ts +26 -5
- package/dist/parcel/parcel.interface.d.ts.map +1 -1
- package/dist/parcel/parcel.service.d.ts +38 -0
- package/dist/parcel/parcel.service.d.ts.map +1 -0
- package/dist/parcel/storage-provider-registry.d.ts +17 -0
- package/dist/parcel/storage-provider-registry.d.ts.map +1 -0
- package/dist/parcel/storage-provider.types.d.ts +31 -0
- package/dist/parcel/storage-provider.types.d.ts.map +1 -0
- package/dist/preload.d.ts +7 -0
- package/dist/preload.d.ts.map +1 -0
- package/dist/preload.js +47 -0
- package/dist/preload.js.map +1 -0
- package/dist/repo/repo-context.utils.d.ts.map +1 -1
- package/dist/repo/repo-manager.d.ts +14 -3
- package/dist/repo/repo-manager.d.ts.map +1 -1
- package/dist/repo/repo.api.d.ts +1 -1
- package/dist/repo/repo.api.d.ts.map +1 -1
- package/dist/repo/repo.interface.d.ts +1 -1
- package/dist/repo/repo.interface.d.ts.map +1 -1
- package/dist/repo/repo.script-loader.d.ts +5 -5
- package/dist/repo/repo.script-loader.d.ts.map +1 -1
- package/dist/service/base.interface.d.ts +54 -57
- package/dist/service/base.interface.d.ts.map +1 -1
- package/dist/service/index.d.ts +21 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/service.api.d.ts +503 -0
- package/dist/service/service.api.d.ts.map +1 -0
- package/dist/service/service.interface.d.ts +36 -9
- package/dist/service/service.interface.d.ts.map +1 -1
- package/dist/shared/http/fetch-retry.d.ts +21 -0
- package/dist/shared/http/fetch-retry.d.ts.map +1 -0
- package/dist/shared/log/create-logger.d.ts +27 -0
- package/dist/shared/log/create-logger.d.ts.map +1 -0
- package/dist/shared/log/enable-log-persist.d.ts +28 -0
- package/dist/shared/log/enable-log-persist.d.ts.map +1 -0
- package/dist/shared/log/index.d.ts +10 -0
- package/dist/shared/log/index.d.ts.map +1 -0
- package/dist/shared/log/log-manager.d.ts +37 -60
- package/dist/shared/log/log-manager.d.ts.map +1 -1
- package/dist/shared/log/log-persist-batch-id.d.ts +13 -0
- package/dist/shared/log/log-persist-batch-id.d.ts.map +1 -0
- package/dist/shared/log/log-persist-flush.d.ts +8 -0
- package/dist/shared/log/log-persist-flush.d.ts.map +1 -0
- package/dist/shared/log/log-persist-hook.d.ts +6 -0
- package/dist/shared/log/log-persist-hook.d.ts.map +1 -0
- package/dist/shared/log/log-persist-logger.d.ts +15 -0
- package/dist/shared/log/log-persist-logger.d.ts.map +1 -0
- package/dist/shared/log/log-persist-registry.d.ts +17 -0
- package/dist/shared/log/log-persist-registry.d.ts.map +1 -0
- package/dist/shared/log/log-persist.config.d.ts +10 -0
- package/dist/shared/log/log-persist.config.d.ts.map +1 -0
- package/dist/shared/log/log-persist.d.ts +55 -0
- package/dist/shared/log/log-persist.d.ts.map +1 -0
- package/dist/shared/log/log-persist.interface.d.ts +116 -0
- package/dist/shared/log/log-persist.interface.d.ts.map +1 -0
- package/dist/shared/log/log-scope.d.ts +56 -0
- package/dist/shared/log/log-scope.d.ts.map +1 -0
- package/dist/shared/utils/fetch-url.d.ts +3 -0
- package/dist/shared/utils/fetch-url.d.ts.map +1 -0
- package/dist/shared/utils/network-error.d.ts +14 -0
- package/dist/shared/utils/network-error.d.ts.map +1 -0
- package/dist/shared/utils/safe-file-name.d.ts +14 -0
- package/dist/shared/utils/safe-file-name.d.ts.map +1 -0
- package/dist/shared/utils/sha256.d.ts +3 -0
- package/dist/shared/utils/sha256.d.ts.map +1 -0
- package/dist/supabase.d.ts +7 -2
- package/dist/supabase.d.ts.map +1 -1
- package/dist/task/index.d.ts +16 -0
- package/dist/task/index.d.ts.map +1 -0
- package/dist/task/local-task-registry.d.ts +11 -1
- package/dist/task/local-task-registry.d.ts.map +1 -1
- package/dist/task/task-manager.d.ts +21 -11
- package/dist/task/task-manager.d.ts.map +1 -1
- package/dist/task/task-node.d.ts +19 -0
- package/dist/task/task-node.d.ts.map +1 -0
- package/dist/task/task-post-validated.api.d.ts +19 -0
- package/dist/task/task-post-validated.api.d.ts.map +1 -0
- package/dist/task/task-post.api.d.ts +54 -0
- package/dist/task/task-post.api.d.ts.map +1 -0
- package/dist/task/task-queue.d.ts +7 -0
- package/dist/task/task-queue.d.ts.map +1 -0
- package/dist/task/task-repo-context.d.ts +2 -0
- package/dist/task/task-repo-context.d.ts.map +1 -1
- package/dist/task/task-repo-validation.d.ts +46 -0
- package/dist/task/task-repo-validation.d.ts.map +1 -0
- package/dist/task/task.api.d.ts +5 -47
- package/dist/task/task.api.d.ts.map +1 -1
- package/dist/task/task.constant.d.ts +4 -0
- package/dist/task/task.constant.d.ts.map +1 -0
- package/dist/task/task.interface.d.ts +3 -1
- package/dist/task/task.interface.d.ts.map +1 -1
- package/dist/trigger/trigger-manager.d.ts +25 -0
- package/dist/trigger/trigger-manager.d.ts.map +1 -0
- package/dist/trigger/trigger-node.d.ts +23 -0
- package/dist/trigger/trigger-node.d.ts.map +1 -0
- package/dist/trigger/trigger.api.d.ts +140 -0
- package/dist/trigger/trigger.api.d.ts.map +1 -0
- package/dist/trigger/trigger.constant.d.ts +8 -0
- package/dist/trigger/trigger.constant.d.ts.map +1 -0
- package/dist/trigger/trigger.interface.d.ts +87 -0
- package/dist/trigger/trigger.interface.d.ts.map +1 -0
- package/dist/trigger/trigger.utils.d.ts +6 -0
- package/dist/trigger/trigger.utils.d.ts.map +1 -0
- package/dist/word/word.api.d.ts +1 -1
- package/dist/word/word.api.d.ts.map +1 -1
- package/dist/word/word.interface.d.ts +2 -2
- package/dist/word/word.interface.d.ts.map +1 -1
- package/package.json +91 -61
- package/src/browser.ts +165 -0
- package/src/command/command.api.ts +20 -18
- package/src/command/command.interface.ts +2 -3
- package/src/core.api.ts +466 -477
- package/src/core.interface.ts +63 -62
- package/src/core.utils.ts +64 -64
- package/src/idea/idea.interface.ts +3 -3
- package/src/index.ts +2 -79
- package/src/link/link.api.ts +28 -30
- package/src/link/link.interface.ts +4 -5
- package/src/list/list.api.ts +50 -29
- package/src/list/list.interface.ts +3 -4
- package/src/node/env/env-parsers.ts +77 -0
- package/src/node/env/index.ts +10 -0
- package/src/node/env/init-supabase-from-env.ts +38 -0
- package/src/node/env/load-env.ts +67 -0
- package/src/node/env/project-root.ts +34 -0
- package/src/node/env/public-base-url.ts +18 -0
- package/src/node/env/require-env.ts +15 -0
- package/src/node/fs/json-state-store.ts +97 -0
- package/src/node/fs/read-source-file.ts +75 -0
- package/src/node/node-liveness.ts +80 -0
- package/src/node/node-runtime.base.ts +481 -0
- package/src/node/node.api.ts +12 -11
- package/src/node/node.interface.ts +1 -8
- package/src/node/node.utils.ts +1 -1
- package/src/node/preload/run-service-preload.ts +48 -0
- package/src/node/preload/service-preload.interface.ts +14 -0
- package/src/node/process/index.ts +8 -0
- package/src/node/process/managed-child-processes.ts +121 -0
- package/src/node/process/process-spawn.ts +61 -0
- package/src/node/readiness/index.ts +20 -0
- package/src/node/readiness/poll-until.ts +27 -0
- package/src/node/readiness/readiness-checks.ts +79 -0
- package/src/node/readiness/readiness.types.ts +13 -0
- package/src/node/readiness/run-readiness-checks.ts +20 -0
- package/src/node/readiness/service-ready-gate.ts +65 -0
- package/src/node.ts +153 -0
- package/src/parcel/chunk-fetch-registry.ts +96 -0
- package/src/parcel/chunk-url.utils.ts +30 -0
- package/src/parcel/parcel-manager.ts +431 -173
- package/src/parcel/parcel.api.ts +103 -0
- package/src/parcel/parcel.interface.ts +44 -23
- package/src/parcel/parcel.service.ts +79 -0
- package/src/parcel/storage-provider-registry.ts +49 -0
- package/src/parcel/storage-provider.types.ts +45 -0
- package/src/preload.ts +7 -0
- package/src/repo/repo-context.utils.ts +3 -4
- package/src/repo/repo-manager.ts +54 -39
- package/src/repo/repo.api.ts +5 -5
- package/src/repo/repo.interface.ts +1 -2
- package/src/repo/repo.script-loader.ts +16 -20
- package/src/service/base.interface.ts +81 -90
- package/src/service/index.ts +173 -0
- package/src/service/service.api.ts +294 -0
- package/src/service/service.interface.ts +49 -17
- package/src/shared/http/fetch-retry.ts +145 -0
- package/src/shared/log/create-logger.ts +51 -0
- package/src/shared/log/enable-log-persist.ts +225 -0
- package/src/shared/log/index.ts +31 -0
- package/src/shared/log/log-manager.ts +112 -121
- package/src/shared/log/log-persist-batch-id.ts +43 -0
- package/src/shared/log/log-persist-flush.ts +128 -0
- package/src/shared/log/log-persist-hook.ts +13 -0
- package/src/shared/log/log-persist-logger.ts +33 -0
- package/src/shared/log/log-persist-registry.ts +109 -0
- package/src/shared/log/log-persist.config.ts +97 -0
- package/src/shared/log/log-persist.interface.ts +132 -0
- package/src/shared/log/log-persist.ts +704 -0
- package/src/shared/log/log-scope.ts +123 -0
- package/src/shared/utils/config-path.utils.ts +1 -1
- package/src/shared/utils/fetch-url.ts +13 -0
- package/src/shared/utils/network-error.ts +152 -0
- package/src/shared/utils/safe-file-name.ts +37 -0
- package/src/shared/utils/sha256.ts +15 -0
- package/src/supabase.ts +125 -119
- package/src/task/index.ts +45 -0
- package/src/task/local-task-registry.ts +115 -36
- package/src/task/task-manager.ts +101 -113
- package/src/task/task-node.ts +302 -0
- package/src/task/task-post-validated.api.ts +47 -0
- package/src/task/task-post.api.ts +99 -0
- package/src/task/task-queue.ts +18 -0
- package/src/task/task-repo-context.ts +4 -1
- package/src/task/task-repo-validation.ts +169 -0
- package/src/task/task.api.ts +68 -92
- package/src/task/task.constant.ts +4 -0
- package/src/task/task.interface.ts +6 -7
- package/src/trigger/trigger-manager.ts +287 -0
- package/src/trigger/trigger-node.ts +80 -0
- package/src/trigger/trigger.api.ts +166 -0
- package/src/trigger/trigger.constant.ts +10 -0
- package/src/trigger/trigger.interface.ts +100 -0
- package/src/trigger/trigger.utils.ts +56 -0
- package/src/word/word.api.ts +28 -30
- package/src/word/word.interface.ts +3 -4
- package/dist/auth/auth.api.d.ts +0 -28
- package/dist/auth/auth.api.d.ts.map +0 -1
- package/dist/auth/auth.api.js +0 -51
- package/dist/auth/auth.api.js.map +0 -1
- package/dist/command/command.api.js +0 -58
- package/dist/command/command.api.js.map +0 -1
- package/dist/command/command.interface.js +0 -9
- package/dist/command/command.interface.js.map +0 -1
- package/dist/core.api.js +0 -412
- package/dist/core.api.js.map +0 -1
- package/dist/core.interface.js +0 -46
- package/dist/core.interface.js.map +0 -1
- package/dist/core.utils.js +0 -81
- package/dist/core.utils.js.map +0 -1
- package/dist/feed/feed.interface.d.ts +0 -27
- package/dist/feed/feed.interface.d.ts.map +0 -1
- package/dist/feed/feed.interface.js +0 -17
- package/dist/feed/feed.interface.js.map +0 -1
- package/dist/file/file-manager.d.ts +0 -24
- package/dist/file/file-manager.d.ts.map +0 -1
- package/dist/file/file-manager.js +0 -109
- package/dist/file/file-manager.js.map +0 -1
- package/dist/file/file.api.d.ts +0 -15
- package/dist/file/file.api.d.ts.map +0 -1
- package/dist/file/file.api.js +0 -30
- package/dist/file/file.api.js.map +0 -1
- package/dist/file/file.interface.d.ts +0 -25
- package/dist/file/file.interface.d.ts.map +0 -1
- package/dist/file/file.interface.js +0 -9
- package/dist/file/file.interface.js.map +0 -1
- package/dist/file-list/file-list.api.d.ts +0 -15
- package/dist/file-list/file-list.api.d.ts.map +0 -1
- package/dist/file-list/file-list.api.js +0 -54
- package/dist/file-list/file-list.api.js.map +0 -1
- package/dist/file-list/file-list.interface.d.ts +0 -22
- package/dist/file-list/file-list.interface.d.ts.map +0 -1
- package/dist/file-list/file-list.interface.js +0 -5
- package/dist/file-list/file-list.interface.js.map +0 -1
- package/dist/idea/idea.interface.js +0 -15
- package/dist/idea/idea.interface.js.map +0 -1
- package/dist/index.js +0 -42
- package/dist/index.js.map +0 -1
- package/dist/link/link.api.js +0 -30
- package/dist/link/link.api.js.map +0 -1
- package/dist/link/link.interface.js +0 -7
- package/dist/link/link.interface.js.map +0 -1
- package/dist/list/list.api.js +0 -30
- package/dist/list/list.api.js.map +0 -1
- package/dist/list/list.interface.js +0 -6
- package/dist/list/list.interface.js.map +0 -1
- package/dist/node/node-manager.d.ts +0 -48
- package/dist/node/node-manager.d.ts.map +0 -1
- package/dist/node/node-manager.js +0 -619
- package/dist/node/node-manager.js.map +0 -1
- package/dist/node/node-task.preset.d.ts +0 -1
- package/dist/node/node-task.preset.d.ts.map +0 -1
- package/dist/node/node-task.preset.js +0 -14
- package/dist/node/node-task.preset.js.map +0 -1
- package/dist/node/node.api.js +0 -100
- package/dist/node/node.api.js.map +0 -1
- package/dist/node/node.interface.js +0 -19
- package/dist/node/node.interface.js.map +0 -1
- package/dist/node/node.utils.js +0 -36
- package/dist/node/node.utils.js.map +0 -1
- package/dist/parcel/parcel-manager.js +0 -156
- package/dist/parcel/parcel-manager.js.map +0 -1
- package/dist/parcel/parcel.interface.js +0 -11
- package/dist/parcel/parcel.interface.js.map +0 -1
- package/dist/question-list/question-list.api.d.ts +0 -13
- package/dist/question-list/question-list.api.d.ts.map +0 -1
- package/dist/question-list/question-list.api.js +0 -35
- package/dist/question-list/question-list.api.js.map +0 -1
- package/dist/question-list/question-list.interface.d.ts +0 -18
- package/dist/question-list/question-list.interface.d.ts.map +0 -1
- package/dist/question-list/question-list.interface.js +0 -5
- package/dist/question-list/question-list.interface.js.map +0 -1
- package/dist/repo/repo-context.utils.js +0 -81
- package/dist/repo/repo-context.utils.js.map +0 -1
- package/dist/repo/repo-manager.js +0 -156
- package/dist/repo/repo-manager.js.map +0 -1
- package/dist/repo/repo.api.js +0 -40
- package/dist/repo/repo.api.js.map +0 -1
- package/dist/repo/repo.interface.js +0 -8
- package/dist/repo/repo.interface.js.map +0 -1
- package/dist/repo/repo.script-loader.js +0 -108
- package/dist/repo/repo.script-loader.js.map +0 -1
- package/dist/review/review.api.d.ts +0 -14
- package/dist/review/review.api.d.ts.map +0 -1
- package/dist/review/review.api.js +0 -133
- package/dist/review/review.api.js.map +0 -1
- package/dist/review/review.interface.d.ts +0 -24
- package/dist/review/review.interface.d.ts.map +0 -1
- package/dist/review/review.interface.js +0 -10
- package/dist/review/review.interface.js.map +0 -1
- package/dist/review-v2/apis/post-review-setting.api.d.ts +0 -12
- package/dist/review-v2/apis/post-review-setting.api.d.ts.map +0 -1
- package/dist/review-v2/apis/post-review-setting.api.js +0 -27
- package/dist/review-v2/apis/post-review-setting.api.js.map +0 -1
- package/dist/review-v2/apis/post-review.api.d.ts +0 -13
- package/dist/review-v2/apis/post-review.api.d.ts.map +0 -1
- package/dist/review-v2/apis/post-review.api.js +0 -46
- package/dist/review-v2/apis/post-review.api.js.map +0 -1
- package/dist/review-v2/review-setting.interface.d.ts +0 -23
- package/dist/review-v2/review-setting.interface.d.ts.map +0 -1
- package/dist/review-v2/review-setting.interface.js +0 -5
- package/dist/review-v2/review-setting.interface.js.map +0 -1
- package/dist/review-v2/review.interface.d.ts +0 -20
- package/dist/review-v2/review.interface.d.ts.map +0 -1
- package/dist/review-v2/review.interface.js +0 -5
- package/dist/review-v2/review.interface.js.map +0 -1
- package/dist/service/api.interface.d.ts +0 -35
- package/dist/service/api.interface.d.ts.map +0 -1
- package/dist/service/api.interface.js +0 -12
- package/dist/service/api.interface.js.map +0 -1
- package/dist/service/base.interface.js +0 -7
- package/dist/service/base.interface.js.map +0 -1
- package/dist/service/service.interface.js +0 -11
- package/dist/service/service.interface.js.map +0 -1
- package/dist/shared/log/create-api-logger.d.ts +0 -17
- package/dist/shared/log/create-api-logger.d.ts.map +0 -1
- package/dist/shared/log/create-api-logger.js +0 -15
- package/dist/shared/log/create-api-logger.js.map +0 -1
- package/dist/shared/log/log-manager.js +0 -218
- package/dist/shared/log/log-manager.js.map +0 -1
- package/dist/shared/utils/config-path.utils.js +0 -85
- package/dist/shared/utils/config-path.utils.js.map +0 -1
- package/dist/shared/utils/error.utils.js +0 -15
- package/dist/shared/utils/error.utils.js.map +0 -1
- package/dist/shared/utils/id.utils.js +0 -5
- package/dist/shared/utils/id.utils.js.map +0 -1
- package/dist/supabase.js +0 -100
- package/dist/supabase.js.map +0 -1
- package/dist/task/local-task-registry.js +0 -153
- package/dist/task/local-task-registry.js.map +0 -1
- package/dist/task/task-manager.js +0 -217
- package/dist/task/task-manager.js.map +0 -1
- package/dist/task/task-repo-context.js +0 -12
- package/dist/task/task-repo-context.js.map +0 -1
- package/dist/task/task.api.js +0 -351
- package/dist/task/task.api.js.map +0 -1
- package/dist/task/task.interface.js +0 -36
- package/dist/task/task.interface.js.map +0 -1
- package/dist/task/task.utils.js +0 -2
- package/dist/task/task.utils.js.map +0 -1
- package/dist/word/word.api.js +0 -30
- package/dist/word/word.api.js.map +0 -1
- package/dist/word/word.interface.js +0 -6
- package/dist/word/word.interface.js.map +0 -1
- package/src/auth/auth.api.ts +0 -87
- package/src/feed/feed.interface.ts +0 -33
- package/src/file/file-manager.ts +0 -145
- package/src/file/file.api.ts +0 -43
- package/src/file/file.interface.ts +0 -30
- package/src/file-list/file-list.api.ts +0 -64
- package/src/file-list/file-list.interface.ts +0 -24
- package/src/node/node-manager.ts +0 -673
- package/src/node/node-task.preset.ts +0 -13
- package/src/question-list/question-list.api.ts +0 -42
- package/src/question-list/question-list.interface.ts +0 -21
- package/src/review/review.api.ts +0 -145
- package/src/review/review.interface.ts +0 -26
- package/src/review-v2/apis/post-review-setting.api.ts +0 -35
- package/src/review-v2/apis/post-review.api.ts +0 -59
- package/src/review-v2/review-setting.interface.ts +0 -26
- package/src/review-v2/review.interface.ts +0 -23
- package/src/service/api.interface.ts +0 -47
- package/src/shared/log/create-api-logger.ts +0 -25
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { envBool } from "../../node/env/env-parsers";
|
|
3
|
+
import { readEnv, requireEnv } from "../../node/env/require-env";
|
|
4
|
+
import { pollUntil } from "../../node/readiness";
|
|
5
|
+
import { createLogger } from "./create-logger";
|
|
6
|
+
import { LogPersist } from "./log-persist";
|
|
7
|
+
import {
|
|
8
|
+
logPersistConfigFromEnv,
|
|
9
|
+
logPersistEnabledFromEnv,
|
|
10
|
+
logPersistProcessFromEnv,
|
|
11
|
+
logPersistRegistryDirFromEnv,
|
|
12
|
+
logPersistServiceFromEnv,
|
|
13
|
+
resolveLogPersistConfig,
|
|
14
|
+
} from "./log-persist.config";
|
|
15
|
+
import type {
|
|
16
|
+
EnableLogPersistOptions,
|
|
17
|
+
EnsureLogPersistFromEnvOptions,
|
|
18
|
+
LogPersistReadySnapshot,
|
|
19
|
+
LogPersistStats,
|
|
20
|
+
WaitForLogPersistReadyOptions,
|
|
21
|
+
} from "./log-persist.interface";
|
|
22
|
+
import { registerLogPersistOffer } from "./log-persist-hook";
|
|
23
|
+
import { LOG_PERSIST_TOPIC, persistLogger } from "./log-persist-logger";
|
|
24
|
+
import { defaultLogPersistRegistryPath, readLogPersistRegistry } from "./log-persist-registry";
|
|
25
|
+
|
|
26
|
+
export { logPersistEnabledFromEnv };
|
|
27
|
+
|
|
28
|
+
function resolveRegistryFilePath(explicit?: string): string {
|
|
29
|
+
if (explicit != null && explicit.trim() !== "") {
|
|
30
|
+
return resolve(explicit);
|
|
31
|
+
}
|
|
32
|
+
const dir = logPersistRegistryDirFromEnv();
|
|
33
|
+
if (dir == null) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
"[LogPersist] registry path required: set registryFilePath option or LOG_PERSIST_REGISTRY_DIR / RUNTIME_DATA_DIR",
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return defaultLogPersistRegistryPath(resolve(dir));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function enableLogPersist(options: EnableLogPersistOptions): Promise<void> {
|
|
42
|
+
const registryFilePath = options.registryFilePath != null ? resolve(options.registryFilePath) : undefined;
|
|
43
|
+
const resolvedRegistry = registryFilePath ?? resolveRegistryFilePath();
|
|
44
|
+
|
|
45
|
+
const envConfig = logPersistConfigFromEnv();
|
|
46
|
+
await LogPersist.getInstance().enable({
|
|
47
|
+
...options,
|
|
48
|
+
registryFilePath: resolvedRegistry,
|
|
49
|
+
config: resolveLogPersistConfig({
|
|
50
|
+
fast: { ...envConfig.fast, ...options.config?.fast },
|
|
51
|
+
medium: { ...envConfig.medium, ...options.config?.medium },
|
|
52
|
+
slow: { ...envConfig.slow, ...options.config?.slow },
|
|
53
|
+
postTimeoutMs: options.config?.postTimeoutMs ?? envConfig.postTimeoutMs,
|
|
54
|
+
shutdownDrainTimeoutMs: options.config?.shutdownDrainTimeoutMs ?? envConfig.shutdownDrainTimeoutMs,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function disableLogPersist(): Promise<void> {
|
|
60
|
+
await LogPersist.getInstance().disable();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getLogPersistStats(): LogPersistStats {
|
|
64
|
+
return LogPersist.getInstance().getStats();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Enable log persistence when LOG_PERSIST_ENABLED=true.
|
|
69
|
+
* `process` / `service` can be passed explicitly or via LOG_PERSIST_PROCESS / LOG_PERSIST_SERVICE.
|
|
70
|
+
*/
|
|
71
|
+
export async function ensureLogPersistFromEnv(options: EnsureLogPersistFromEnvOptions = {}): Promise<boolean> {
|
|
72
|
+
if (!logPersistEnabledFromEnv()) {
|
|
73
|
+
registerLogPersistOffer(null);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const service = options.service ?? logPersistServiceFromEnv();
|
|
78
|
+
const processName = options.process ?? logPersistProcessFromEnv();
|
|
79
|
+
if (service == null || service === "") {
|
|
80
|
+
throw new Error("[LogPersist] LOG_PERSIST_SERVICE is required when LOG_PERSIST_ENABLED=true");
|
|
81
|
+
}
|
|
82
|
+
if (processName == null || processName === "") {
|
|
83
|
+
throw new Error(
|
|
84
|
+
"[LogPersist] LOG_PERSIST_PROCESS is required when LOG_PERSIST_ENABLED=true (or pass process option)",
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const registryFilePath =
|
|
89
|
+
options.registryFilePath != null ? resolve(options.registryFilePath) : resolveRegistryFilePath();
|
|
90
|
+
|
|
91
|
+
await enableLogPersist({
|
|
92
|
+
service,
|
|
93
|
+
process: processName,
|
|
94
|
+
registryFilePath,
|
|
95
|
+
config: options.config,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const lifecycleLogger = createLogger({ module: "log-persist" });
|
|
99
|
+
lifecycleLogger.info("log persist enabled from env", {
|
|
100
|
+
topic: LOG_PERSIST_TOPIC,
|
|
101
|
+
data: { service, process: processName, registryFilePath },
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Preload guard: when persistence is enabled, required env must be present before app code runs.
|
|
109
|
+
*/
|
|
110
|
+
export function validateLogPersistPreloadEnv(env: NodeJS.ProcessEnv = process.env): void {
|
|
111
|
+
if (!envBool("LOG_PERSIST_ENABLED", false, env)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const missing: string[] = [];
|
|
116
|
+
if (readEnv("LOG_PERSIST_SERVICE", env) == null) {
|
|
117
|
+
missing.push("LOG_PERSIST_SERVICE");
|
|
118
|
+
}
|
|
119
|
+
const registryDir = logPersistRegistryDirFromEnv(env);
|
|
120
|
+
if (registryDir == null) {
|
|
121
|
+
missing.push("LOG_PERSIST_REGISTRY_DIR or RUNTIME_DATA_DIR");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (missing.length > 0) {
|
|
125
|
+
throw new Error(`[LogPersist] preload env incomplete: ${missing.join(", ")}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function evaluateLogPersistReady(
|
|
130
|
+
state: Awaited<ReturnType<typeof readLogPersistRegistry>>,
|
|
131
|
+
expectedProcesses: string[],
|
|
132
|
+
staleMs: number,
|
|
133
|
+
now: number,
|
|
134
|
+
): LogPersistReadySnapshot {
|
|
135
|
+
const missing: string[] = [];
|
|
136
|
+
const stale: string[] = [];
|
|
137
|
+
const registered: string[] = [];
|
|
138
|
+
|
|
139
|
+
for (const processName of expectedProcesses) {
|
|
140
|
+
const record = state.processes[processName];
|
|
141
|
+
if (record == null) {
|
|
142
|
+
missing.push(processName);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const heartbeatAt = Date.parse(record.lastHeartbeatAt);
|
|
147
|
+
if (!Number.isFinite(heartbeatAt) || now - heartbeatAt > staleMs) {
|
|
148
|
+
stale.push(processName);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
registered.push(processName);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
ok: missing.length === 0 && stale.length === 0,
|
|
157
|
+
missing,
|
|
158
|
+
stale,
|
|
159
|
+
registered,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Wait until every expected process has registered in the shared registry with a fresh heartbeat.
|
|
165
|
+
* Call from the service main process after spawning children.
|
|
166
|
+
*/
|
|
167
|
+
export async function waitForLogPersistReady(options: WaitForLogPersistReadyOptions): Promise<LogPersistReadySnapshot> {
|
|
168
|
+
const timeoutMs = options.timeoutMs ?? 60_000;
|
|
169
|
+
const pollIntervalMs = options.pollIntervalMs ?? 500;
|
|
170
|
+
const staleMs = options.staleMs ?? 90_000;
|
|
171
|
+
|
|
172
|
+
let last: LogPersistReadySnapshot = {
|
|
173
|
+
ok: false,
|
|
174
|
+
missing: [...options.expectedProcesses],
|
|
175
|
+
stale: [],
|
|
176
|
+
registered: [],
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
try {
|
|
180
|
+
await pollUntil({
|
|
181
|
+
intervalMs: pollIntervalMs,
|
|
182
|
+
timeoutMs,
|
|
183
|
+
until: async () => {
|
|
184
|
+
const state = await readLogPersistRegistry(options.registryFilePath);
|
|
185
|
+
if (state.service !== options.service) {
|
|
186
|
+
last = {
|
|
187
|
+
ok: false,
|
|
188
|
+
missing: options.expectedProcesses,
|
|
189
|
+
stale: [],
|
|
190
|
+
registered: [],
|
|
191
|
+
};
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
last = evaluateLogPersistReady(state, options.expectedProcesses, staleMs, Date.now());
|
|
195
|
+
return last.ok;
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
} catch {
|
|
199
|
+
persistLogger.warn("waitForLogPersistReady timed out", {
|
|
200
|
+
timeoutMs,
|
|
201
|
+
expectedProcesses: options.expectedProcesses,
|
|
202
|
+
...last,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return last;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export async function snapshotLogPersistReady(options: {
|
|
210
|
+
registryFilePath: string;
|
|
211
|
+
service: string;
|
|
212
|
+
expectedProcesses: string[];
|
|
213
|
+
staleMs?: number;
|
|
214
|
+
}): Promise<LogPersistReadySnapshot> {
|
|
215
|
+
const state = await readLogPersistRegistry(options.registryFilePath);
|
|
216
|
+
return evaluateLogPersistReady(state, options.expectedProcesses, options.staleMs ?? 90_000, Date.now());
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function resolveLogPersistRegistryPath(registryDir?: string): string {
|
|
220
|
+
const dir = registryDir ?? logPersistRegistryDirFromEnv();
|
|
221
|
+
if (dir == null) {
|
|
222
|
+
requireEnv("LOG_PERSIST_REGISTRY_DIR");
|
|
223
|
+
}
|
|
224
|
+
return defaultLogPersistRegistryPath(resolve(dir ?? ""));
|
|
225
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log domain public API — curated re-exports only.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export type {
|
|
6
|
+
CreateLoggerFromModuleInput,
|
|
7
|
+
CreateLoggerFromScopeInput,
|
|
8
|
+
CreateLoggerInput,
|
|
9
|
+
} from "./create-logger";
|
|
10
|
+
// create-logger
|
|
11
|
+
export { createLogger } from "./create-logger";
|
|
12
|
+
export type { LogEntry, LoggerWithScope, LogOptions, LogRestParams, WithScopeOptions } from "./log-manager";
|
|
13
|
+
// log-manager
|
|
14
|
+
export { LogLevel, LogManager, logManager } from "./log-manager";
|
|
15
|
+
export type {
|
|
16
|
+
CreateScopeInput,
|
|
17
|
+
LoggerResetScopePatch,
|
|
18
|
+
LogScope,
|
|
19
|
+
LogScopeInput,
|
|
20
|
+
LogScopePatch,
|
|
21
|
+
PatchScopeInput,
|
|
22
|
+
} from "./log-scope";
|
|
23
|
+
// log-scope
|
|
24
|
+
export {
|
|
25
|
+
createScope,
|
|
26
|
+
formatScopeLabels,
|
|
27
|
+
normalizeScope,
|
|
28
|
+
patchScope,
|
|
29
|
+
resolveLogData,
|
|
30
|
+
withModule,
|
|
31
|
+
} from "./log-scope";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { isDevEnvironment } from "../../core.utils";
|
|
2
2
|
import { generateUniqueId } from "../utils/id.utils";
|
|
3
|
+
import { offerToLogPersist } from "./log-persist-hook";
|
|
4
|
+
import { formatScopeLabels, type LoggerResetScopePatch, type LogScope, patchScope, resolveLogData } from "./log-scope";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Log severity and semantics (low → high). `minLevel` filters by {@link LOG_LEVEL_RANK}.
|
|
@@ -31,86 +33,70 @@ const LOG_LEVEL_RANK: Record<LogLevel, number> = {
|
|
|
31
33
|
[LogLevel.CRITICAL]: 5,
|
|
32
34
|
};
|
|
33
35
|
|
|
34
|
-
interface LogEntry {
|
|
36
|
+
interface LogEntry extends LogScope {
|
|
35
37
|
timestamp: number;
|
|
36
38
|
level: LogLevel;
|
|
37
|
-
/** Tell people what happened, but more structured */
|
|
38
39
|
message: string;
|
|
39
|
-
|
|
40
|
-
topic: string | null;
|
|
41
|
-
/** Where the log comes from */
|
|
42
|
-
module: string;
|
|
43
|
-
/** Specific process — correlates one logical chain (loop, request). */
|
|
44
|
-
traceId: string;
|
|
45
|
-
/** Worker node id when the log is node-scoped; omit for scheduler / admin / API-only paths. */
|
|
46
|
-
nodeId?: string;
|
|
40
|
+
topic: string;
|
|
47
41
|
extra?: string;
|
|
48
|
-
|
|
42
|
+
/** Per-line structured business payload. */
|
|
43
|
+
data?: unknown;
|
|
49
44
|
}
|
|
50
45
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
46
|
+
type LogRestParams = {
|
|
47
|
+
topic: string;
|
|
48
|
+
extra?: LogEntry["extra"];
|
|
49
|
+
data?: unknown;
|
|
50
|
+
};
|
|
56
51
|
|
|
57
|
-
type
|
|
52
|
+
type LogParams = { message: LogEntry["message"] } & LogRestParams;
|
|
58
53
|
|
|
59
|
-
interface LogEntryPayload {
|
|
54
|
+
interface LogEntryPayload extends LogScope {
|
|
60
55
|
message: LogEntry["message"];
|
|
61
|
-
topic
|
|
56
|
+
topic: LogEntry["topic"];
|
|
62
57
|
extra?: LogEntry["extra"];
|
|
63
|
-
|
|
58
|
+
data?: LogEntry["data"];
|
|
64
59
|
level: LogEntry["level"];
|
|
65
|
-
module: LogEntry["module"];
|
|
66
|
-
traceId: LogEntry["traceId"];
|
|
67
|
-
nodeId?: LogEntry["nodeId"];
|
|
68
60
|
}
|
|
69
61
|
|
|
70
|
-
type LogParams = Pick<LogEntryPayload, "message" | "topic" | "extra" | "context">;
|
|
71
|
-
|
|
72
62
|
interface LogOptions {
|
|
73
|
-
defaultTopic: LogEntry["topic"];
|
|
74
63
|
formatTimestamp: boolean;
|
|
75
64
|
formatEmoji: boolean;
|
|
76
65
|
formatPrefix: string;
|
|
77
|
-
maxHistoryLength: number;
|
|
78
66
|
/** Logs below this level are skipped. Defaults to DEBUG in dev, INFO in production. */
|
|
79
67
|
minLevel?: LogLevel;
|
|
80
68
|
onLog?: (entry: LogEntry) => void;
|
|
81
69
|
}
|
|
82
70
|
|
|
71
|
+
/** Per-scoped-logger options for {@link LogManager.withScope}. */
|
|
72
|
+
interface WithScopeOptions {
|
|
73
|
+
/** Overrides global {@link LogOptions.minLevel} for this logger instance. */
|
|
74
|
+
minLevel?: LogLevel;
|
|
75
|
+
}
|
|
76
|
+
|
|
83
77
|
const DEFAULT_OPTIONS: LogOptions = {
|
|
84
|
-
defaultTopic: null,
|
|
85
78
|
formatTimestamp: true,
|
|
86
79
|
formatEmoji: true,
|
|
87
80
|
formatPrefix: "",
|
|
88
|
-
maxHistoryLength: 4096,
|
|
89
81
|
minLevel: isDevEnvironment() ? LogLevel.DEBUG : LogLevel.INFO,
|
|
90
82
|
};
|
|
91
83
|
|
|
92
|
-
interface
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
|
|
101
|
-
/** Rank 4 — a concrete operation failed; needs investigation. */
|
|
102
|
-
error: (message: LogParams["message"], restParams?: LogRestParams) => void;
|
|
103
|
-
/** Rank 5 — invariant / design / integrity breach; escalate immediately. */
|
|
104
|
-
critical: (message: LogParams["message"], restParams?: LogRestParams) => void;
|
|
105
|
-
/** Merge partial fields into this logger's bound context (e.g. nodeId after register). */
|
|
106
|
-
resetContext: (fields: Partial<LogContext>) => void;
|
|
84
|
+
interface LoggerWithScope {
|
|
85
|
+
debug: (message: LogParams["message"], restParams: LogRestParams) => void;
|
|
86
|
+
info: (message: LogParams["message"], restParams: LogRestParams) => void;
|
|
87
|
+
success: (message: LogParams["message"], restParams: LogRestParams) => void;
|
|
88
|
+
warn: (message: LogParams["message"], restParams: LogRestParams) => void;
|
|
89
|
+
error: (message: LogParams["message"], restParams: LogRestParams) => void;
|
|
90
|
+
critical: (message: LogParams["message"], restParams: LogRestParams) => void;
|
|
91
|
+
/** Merge labels / module into this logger's bound scope (trace fields are not mutable). */
|
|
92
|
+
resetScope: (patch: LoggerResetScopePatch) => void;
|
|
107
93
|
}
|
|
108
94
|
|
|
109
95
|
function mergeLogOptions(options?: Partial<LogOptions>): LogOptions {
|
|
110
96
|
return { ...DEFAULT_OPTIONS, ...options };
|
|
111
97
|
}
|
|
112
98
|
|
|
113
|
-
function
|
|
99
|
+
function formatDataValue(value: unknown): string {
|
|
114
100
|
if (value === undefined) {
|
|
115
101
|
return "";
|
|
116
102
|
}
|
|
@@ -124,23 +110,25 @@ function formatContextValue(value: unknown): string {
|
|
|
124
110
|
}
|
|
125
111
|
}
|
|
126
112
|
|
|
127
|
-
function
|
|
113
|
+
function validateLogScope(logScope: LogScope): void {
|
|
128
114
|
const missing: string[] = [];
|
|
129
|
-
if (!
|
|
115
|
+
if (!logScope.module?.trim()) {
|
|
130
116
|
missing.push("module");
|
|
131
117
|
}
|
|
132
|
-
if (!
|
|
118
|
+
if (!logScope.traceId?.trim()) {
|
|
133
119
|
missing.push("traceId");
|
|
134
120
|
}
|
|
121
|
+
if (logScope.traceParentId !== null && typeof logScope.traceParentId !== "string") {
|
|
122
|
+
missing.push("traceParentId");
|
|
123
|
+
}
|
|
135
124
|
if (missing.length > 0) {
|
|
136
|
-
console.warn(`[LogManager]
|
|
125
|
+
console.warn(`[LogManager] LogScope missing or invalid: ${missing.join(", ")}`, logScope);
|
|
137
126
|
}
|
|
138
127
|
}
|
|
139
128
|
|
|
140
129
|
class LogManager {
|
|
141
130
|
private static instance: LogManager;
|
|
142
131
|
private options: LogOptions;
|
|
143
|
-
private history: LogEntry[] = [];
|
|
144
132
|
private readonly levelEmojis = {
|
|
145
133
|
[LogLevel.DEBUG]: "🔍",
|
|
146
134
|
[LogLevel.INFO]: "ℹ️",
|
|
@@ -158,7 +146,9 @@ class LogManager {
|
|
|
158
146
|
if (!LogManager.instance) {
|
|
159
147
|
LogManager.instance = new LogManager(options);
|
|
160
148
|
} else if (options != null && Object.keys(options).length > 0) {
|
|
161
|
-
console.warn(
|
|
149
|
+
console.warn(
|
|
150
|
+
"[LogManager] getInstance(options) ignored — singleton already created. Use setOptions() instead.",
|
|
151
|
+
);
|
|
162
152
|
}
|
|
163
153
|
return LogManager.instance;
|
|
164
154
|
}
|
|
@@ -167,42 +157,28 @@ class LogManager {
|
|
|
167
157
|
this.options = mergeLogOptions({ ...this.options, ...options });
|
|
168
158
|
}
|
|
169
159
|
|
|
170
|
-
public getHistory(): LogEntry[] {
|
|
171
|
-
return [...this.history];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
public clearHistory(): void {
|
|
175
|
-
this.history = [];
|
|
176
|
-
}
|
|
177
|
-
|
|
178
160
|
private getMinLevel(): LogLevel {
|
|
179
161
|
return this.options.minLevel ?? DEFAULT_OPTIONS.minLevel ?? LogLevel.INFO;
|
|
180
162
|
}
|
|
181
163
|
|
|
182
|
-
private shouldLog(level: LogLevel): boolean {
|
|
183
|
-
|
|
164
|
+
private shouldLog(level: LogLevel, scopeMinLevel?: LogLevel): boolean {
|
|
165
|
+
const minLevel = scopeMinLevel ?? this.getMinLevel();
|
|
166
|
+
return LOG_LEVEL_RANK[level] >= LOG_LEVEL_RANK[minLevel];
|
|
184
167
|
}
|
|
185
168
|
|
|
186
|
-
private createLogEntry({
|
|
187
|
-
level,
|
|
188
|
-
message,
|
|
189
|
-
topic,
|
|
190
|
-
module,
|
|
191
|
-
traceId,
|
|
192
|
-
nodeId,
|
|
193
|
-
extra,
|
|
194
|
-
context,
|
|
195
|
-
}: LogEntryPayload): LogEntry {
|
|
169
|
+
private createLogEntry(payload: LogEntryPayload): LogEntry {
|
|
170
|
+
const { level, message, topic, extra, data, module, traceId, traceParentId, labels } = payload;
|
|
196
171
|
return {
|
|
197
172
|
timestamp: Date.now(),
|
|
198
173
|
level,
|
|
199
174
|
message,
|
|
200
|
-
topic
|
|
175
|
+
topic,
|
|
201
176
|
module,
|
|
202
177
|
traceId,
|
|
203
|
-
|
|
178
|
+
traceParentId,
|
|
179
|
+
labels,
|
|
204
180
|
extra,
|
|
205
|
-
|
|
181
|
+
data,
|
|
206
182
|
};
|
|
207
183
|
}
|
|
208
184
|
|
|
@@ -223,24 +199,23 @@ class LogManager {
|
|
|
223
199
|
|
|
224
200
|
parts.push(this.formatLevelTag(entry));
|
|
225
201
|
parts.push(
|
|
226
|
-
`traceId=${entry.traceId}
|
|
202
|
+
`traceId=${entry.traceId} parent=${entry.traceParentId ?? "null"} labels=${formatScopeLabels(entry.labels)} module=${entry.module} topic=${entry.topic}`,
|
|
227
203
|
);
|
|
228
204
|
|
|
229
205
|
if (this.options.formatPrefix) {
|
|
230
206
|
parts.push(`prefix=${this.options.formatPrefix}`);
|
|
231
207
|
}
|
|
232
208
|
|
|
233
|
-
const message =
|
|
234
|
-
entry.level === LogLevel.CRITICAL ? `>>> ${entry.message} <<<` : entry.message;
|
|
209
|
+
const message = entry.level === LogLevel.CRITICAL ? `>>> ${entry.message} <<<` : entry.message;
|
|
235
210
|
parts.push(`| ${message}`);
|
|
236
211
|
|
|
237
212
|
if (entry.extra) {
|
|
238
213
|
parts.push(`| extra=${entry.extra}`);
|
|
239
214
|
}
|
|
240
215
|
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
243
|
-
parts.push(`|
|
|
216
|
+
const dataText = formatDataValue(entry.data);
|
|
217
|
+
if (dataText) {
|
|
218
|
+
parts.push(`| data=${dataText}`);
|
|
244
219
|
}
|
|
245
220
|
|
|
246
221
|
return parts.join(" ");
|
|
@@ -263,78 +238,94 @@ class LogManager {
|
|
|
263
238
|
private log(
|
|
264
239
|
level: LogLevel,
|
|
265
240
|
message: LogParams["message"],
|
|
266
|
-
|
|
267
|
-
restParams
|
|
241
|
+
logScope: LogScope,
|
|
242
|
+
restParams: LogRestParams,
|
|
243
|
+
scopeMinLevel?: LogLevel,
|
|
268
244
|
) {
|
|
269
|
-
if (!this.shouldLog(level)) {
|
|
245
|
+
if (!this.shouldLog(level, scopeMinLevel)) {
|
|
270
246
|
return;
|
|
271
247
|
}
|
|
272
248
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const { module, traceId, nodeId } = logContext;
|
|
277
|
-
const entry = this.createLogEntry({ level, message, topic, extra, context, module, traceId, nodeId });
|
|
278
|
-
|
|
279
|
-
this.history.push(entry);
|
|
280
|
-
if (this.history.length > this.options.maxHistoryLength) {
|
|
281
|
-
this.history.shift();
|
|
249
|
+
validateLogScope(logScope);
|
|
250
|
+
if (!restParams.topic?.trim()) {
|
|
251
|
+
throw new Error("[LogManager] topic is required on every log call");
|
|
282
252
|
}
|
|
283
253
|
|
|
254
|
+
const { topic, extra } = restParams;
|
|
255
|
+
const data = resolveLogData(restParams);
|
|
256
|
+
const entry = this.createLogEntry({
|
|
257
|
+
level,
|
|
258
|
+
message,
|
|
259
|
+
topic,
|
|
260
|
+
extra,
|
|
261
|
+
data,
|
|
262
|
+
...logScope,
|
|
263
|
+
});
|
|
264
|
+
|
|
284
265
|
const formatted = this.formatLog(entry);
|
|
285
266
|
this.emitLog(entry, formatted);
|
|
286
267
|
this.options.onLog?.(entry);
|
|
268
|
+
offerToLogPersist(entry);
|
|
287
269
|
}
|
|
288
270
|
|
|
289
271
|
public generateTraceId(): string {
|
|
290
272
|
return generateUniqueId();
|
|
291
273
|
}
|
|
292
274
|
|
|
293
|
-
public debug(message: LogParams["message"],
|
|
294
|
-
this.log(LogLevel.DEBUG, message,
|
|
275
|
+
public debug(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
276
|
+
this.log(LogLevel.DEBUG, message, logScope, restParams);
|
|
295
277
|
}
|
|
296
278
|
|
|
297
|
-
public info(message: LogParams["message"],
|
|
298
|
-
this.log(LogLevel.INFO, message,
|
|
279
|
+
public info(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
280
|
+
this.log(LogLevel.INFO, message, logScope, restParams);
|
|
299
281
|
}
|
|
300
282
|
|
|
301
|
-
public success(message: LogParams["message"],
|
|
302
|
-
this.log(LogLevel.SUCCESS, message,
|
|
283
|
+
public success(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
284
|
+
this.log(LogLevel.SUCCESS, message, logScope, restParams);
|
|
303
285
|
}
|
|
304
286
|
|
|
305
|
-
public warn(message: LogParams["message"],
|
|
306
|
-
this.log(LogLevel.WARN, message,
|
|
287
|
+
public warn(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
288
|
+
this.log(LogLevel.WARN, message, logScope, restParams);
|
|
307
289
|
}
|
|
308
290
|
|
|
309
|
-
public error(message: LogParams["message"],
|
|
310
|
-
this.log(LogLevel.ERROR, message,
|
|
291
|
+
public error(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
292
|
+
this.log(LogLevel.ERROR, message, logScope, restParams);
|
|
311
293
|
}
|
|
312
294
|
|
|
313
|
-
public critical(message: LogParams["message"],
|
|
314
|
-
this.log(LogLevel.CRITICAL, message,
|
|
295
|
+
public critical(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
296
|
+
this.log(LogLevel.CRITICAL, message, logScope, restParams);
|
|
315
297
|
}
|
|
316
298
|
|
|
317
|
-
public
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
299
|
+
public withScope(scope: LogScope, options?: WithScopeOptions): { logger: LoggerWithScope; scope: LogScope } {
|
|
300
|
+
const boundScope: LogScope = { ...scope, labels: scope.labels ? { ...scope.labels } : undefined };
|
|
301
|
+
const scopeMinLevel = options?.minLevel;
|
|
302
|
+
|
|
303
|
+
const logger: LoggerWithScope = {
|
|
304
|
+
debug: (message, restParams) => this.log(LogLevel.DEBUG, message, boundScope, restParams, scopeMinLevel),
|
|
305
|
+
info: (message, restParams) => this.log(LogLevel.INFO, message, boundScope, restParams, scopeMinLevel),
|
|
306
|
+
success: (message, restParams) =>
|
|
307
|
+
this.log(LogLevel.SUCCESS, message, boundScope, restParams, scopeMinLevel),
|
|
308
|
+
warn: (message, restParams) => this.log(LogLevel.WARN, message, boundScope, restParams, scopeMinLevel),
|
|
309
|
+
error: (message, restParams) => this.log(LogLevel.ERROR, message, boundScope, restParams, scopeMinLevel),
|
|
310
|
+
critical: (message, restParams) =>
|
|
311
|
+
this.log(LogLevel.CRITICAL, message, boundScope, restParams, scopeMinLevel),
|
|
312
|
+
resetScope: (patch) => {
|
|
313
|
+
const next = patchScope({
|
|
314
|
+
scope: boundScope,
|
|
315
|
+
patch,
|
|
316
|
+
allowTraceMutation: false,
|
|
317
|
+
});
|
|
318
|
+
boundScope.module = next.module;
|
|
319
|
+
boundScope.traceId = next.traceId;
|
|
320
|
+
boundScope.traceParentId = next.traceParentId;
|
|
321
|
+
boundScope.labels = next.labels;
|
|
329
322
|
},
|
|
330
323
|
};
|
|
331
324
|
|
|
332
|
-
return { logger,
|
|
325
|
+
return { logger, scope: boundScope };
|
|
333
326
|
}
|
|
334
327
|
}
|
|
335
328
|
|
|
336
329
|
export const logManager = LogManager.getInstance();
|
|
337
|
-
export {
|
|
338
|
-
export {
|
|
339
|
-
export type { CreateApiLoggerOptions } from "./create-api-logger";
|
|
340
|
-
export type { LogOptions, LogEntry, LogContext, LoggerWithContext, LogRestParams };
|
|
330
|
+
export type { LogEntry, LoggerWithScope, LogOptions, LogRestParams, WithScopeOptions };
|
|
331
|
+
export { LogLevel, LogManager };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import type { LogEntry } from "./log-manager";
|
|
3
|
+
import type { LogPersistLane } from "./log-persist.interface";
|
|
4
|
+
|
|
5
|
+
const BATCH_ID_VERSION = 1;
|
|
6
|
+
|
|
7
|
+
/** Stable subset of LogEntry for idempotency hashing (same batch → same key). */
|
|
8
|
+
function canonicalLogEntry(entry: LogEntry): Record<string, unknown> {
|
|
9
|
+
return {
|
|
10
|
+
timestamp: entry.timestamp,
|
|
11
|
+
level: entry.level,
|
|
12
|
+
message: entry.message,
|
|
13
|
+
topic: entry.topic,
|
|
14
|
+
module: entry.module,
|
|
15
|
+
traceId: entry.traceId,
|
|
16
|
+
traceParentId: entry.traceParentId ?? null,
|
|
17
|
+
extra: entry.extra ?? null,
|
|
18
|
+
data: entry.data ?? null,
|
|
19
|
+
labels: entry.labels ?? null,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Deterministic List.value for a log batch — retries after timeout map to the same row key.
|
|
25
|
+
* SHA-256 over canonical JSON (service + process + lane + entries in order).
|
|
26
|
+
*/
|
|
27
|
+
export function computeLogBatchIdempotencyKey(input: {
|
|
28
|
+
service: string;
|
|
29
|
+
process: string;
|
|
30
|
+
lane: LogPersistLane;
|
|
31
|
+
entries: LogEntry[];
|
|
32
|
+
}): string {
|
|
33
|
+
const payload = {
|
|
34
|
+
v: BATCH_ID_VERSION,
|
|
35
|
+
service: input.service,
|
|
36
|
+
process: input.process,
|
|
37
|
+
lane: input.lane,
|
|
38
|
+
entries: input.entries.map(canonicalLogEntry),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const hash = createHash("sha256").update(JSON.stringify(payload), "utf8").digest("hex");
|
|
42
|
+
return `${hash.slice(0, 32)}`;
|
|
43
|
+
}
|