target-supabase-sdk 0.2.0 → 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 +127 -10
- package/dist/browser.d.ts +44 -36
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +6 -45
- package/dist/browser.js.map +1 -1
- 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/link/link.api.d.ts +1 -1
- package/dist/link/link.api.d.ts.map +1 -1
- package/dist/link/link.interface.d.ts +2 -2
- 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 +21 -3
- package/dist/node/node-runtime.base.d.ts.map +1 -1
- package/dist/node/node.api.d.ts +1 -1
- 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 +26 -12
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +2482 -18
- package/dist/node.js.map +1 -1
- 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 +1 -1
- 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 +3 -3
- 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 +6 -6
- package/dist/shared/log/index.d.ts.map +1 -1
- package/dist/shared/log/log-manager.d.ts +25 -27
- 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 +25 -18
- package/dist/shared/log/log-scope.d.ts.map +1 -1
- 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 +8 -7
- package/dist/task/index.d.ts.map +1 -1
- package/dist/task/local-task-registry.d.ts +1 -1
- package/dist/task/local-task-registry.d.ts.map +1 -1
- package/dist/task/task-manager.d.ts +7 -9
- package/dist/task/task-manager.d.ts.map +1 -1
- package/dist/{node → task}/task-node.d.ts +2 -3
- 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 +10 -5
- package/dist/task/task-post.api.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/task/task-repo-validation.d.ts +2 -2
- package/dist/task/task-repo-validation.d.ts.map +1 -1
- package/dist/task/task.api.d.ts +13 -13
- 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 +1 -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 +4 -4
- package/dist/trigger/trigger.api.d.ts.map +1 -1
- 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 +46 -2
- package/dist/trigger/trigger.interface.d.ts.map +1 -1
- 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 +89 -74
- package/src/browser.ts +144 -79
- package/src/command/command.api.ts +19 -17
- 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/link/link.api.ts +28 -30
- package/src/link/link.interface.ts +3 -4
- 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 +135 -104
- package/src/node/node.api.ts +11 -10
- 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 +138 -47
- 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 +7 -20
- package/src/repo/repo.api.ts +5 -5
- package/src/repo/repo.interface.ts +1 -2
- package/src/repo/repo.script-loader.ts +4 -8
- 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 +19 -11
- package/src/shared/log/log-manager.ts +65 -69
- 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 +46 -46
- 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 +31 -34
- package/src/task/local-task-registry.ts +9 -17
- package/src/task/task-manager.ts +34 -35
- package/src/{node → task}/task-node.ts +91 -73
- package/src/task/task-post-validated.api.ts +47 -0
- package/src/task/task-post.api.ts +81 -98
- package/src/task/task-queue.ts +18 -0
- package/src/task/task-repo-context.ts +2 -1
- package/src/task/task-repo-validation.ts +6 -8
- package/src/task/task.api.ts +61 -25
- package/src/task/task.constant.ts +4 -0
- package/src/task/task.interface.ts +4 -7
- package/src/trigger/trigger-manager.ts +287 -0
- package/src/trigger/trigger-node.ts +80 -0
- package/src/trigger/trigger.api.ts +11 -11
- package/src/trigger/trigger.constant.ts +10 -0
- package/src/trigger/trigger.interface.ts +52 -2
- package/src/trigger/trigger.utils.ts +1 -1
- 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 -3
- 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-log-scope.d.ts +0 -11
- package/dist/node/node-log-scope.d.ts.map +0 -1
- package/dist/node/node-log-scope.js +0 -7
- package/dist/node/node-log-scope.js.map +0 -1
- package/dist/node/node-runtime.base.js +0 -397
- package/dist/node/node-runtime.base.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/node/task-node.d.ts.map +0 -1
- package/dist/node/task-node.js +0 -245
- package/dist/node/task-node.js.map +0 -1
- package/dist/node/trigger-node.d.ts +0 -18
- package/dist/node/trigger-node.d.ts.map +0 -1
- package/dist/node/trigger-node.js +0 -150
- package/dist/node/trigger-node.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 -166
- 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 -21
- package/dist/shared/log/create-api-logger.d.ts.map +0 -1
- package/dist/shared/log/create-api-logger.js +0 -19
- package/dist/shared/log/create-api-logger.js.map +0 -1
- package/dist/shared/log/index.js +0 -10
- package/dist/shared/log/index.js.map +0 -1
- package/dist/shared/log/log-manager.js +0 -237
- package/dist/shared/log/log-manager.js.map +0 -1
- package/dist/shared/log/log-scope.js +0 -70
- package/dist/shared/log/log-scope.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/index.js +0 -14
- package/dist/task/index.js.map +0 -1
- package/dist/task/local-task-registry.js +0 -214
- package/dist/task/local-task-registry.js.map +0 -1
- package/dist/task/task-manager.js +0 -196
- package/dist/task/task-manager.js.map +0 -1
- package/dist/task/task-post.api.js +0 -91
- package/dist/task/task-post.api.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-repo-validation.js +0 -96
- package/dist/task/task-repo-validation.js.map +0 -1
- package/dist/task/task.api.js +0 -303
- 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/trigger/trigger.api.js +0 -125
- package/dist/trigger/trigger.api.js.map +0 -1
- package/dist/trigger/trigger.interface.js +0 -11
- package/dist/trigger/trigger.interface.js.map +0 -1
- package/dist/trigger/trigger.utils.js +0 -39
- package/dist/trigger/trigger.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-log-scope.ts +0 -15
- package/src/node/node-task.preset.ts +0 -13
- package/src/node/trigger-node.ts +0 -180
- 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 -36
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type LoggerWithScope, type LogLevel, logManager } from "./log-manager";
|
|
2
|
+
import { createScope, type LogScope, type LogScopePatch } from "./log-scope";
|
|
3
|
+
|
|
4
|
+
type CreateLoggerLevelOption = {
|
|
5
|
+
/** Overrides global minimum level for this logger only. */
|
|
6
|
+
minLevel?: LogLevel;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** Build scope from fields, then bind a logger. */
|
|
10
|
+
export type CreateLoggerFromModuleInput = {
|
|
11
|
+
module: string;
|
|
12
|
+
traceId?: string;
|
|
13
|
+
traceParentId?: string | null;
|
|
14
|
+
labels?: Record<string, string>;
|
|
15
|
+
} & CreateLoggerLevelOption;
|
|
16
|
+
|
|
17
|
+
/** Bind a logger to an existing {@link LogScope}. */
|
|
18
|
+
export type CreateLoggerFromScopeInput = {
|
|
19
|
+
scope: LogScope;
|
|
20
|
+
} & CreateLoggerLevelOption;
|
|
21
|
+
|
|
22
|
+
export type CreateLoggerInput = CreateLoggerFromModuleInput | CreateLoggerFromScopeInput;
|
|
23
|
+
|
|
24
|
+
function isScopeInput(input: CreateLoggerInput): input is CreateLoggerFromScopeInput {
|
|
25
|
+
return "scope" in input;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns a scoped logger — one entry for all call sites.
|
|
30
|
+
*
|
|
31
|
+
* - `{ module, traceId?, labels?, … }` — creates a scope (API handlers, one-shot calls)
|
|
32
|
+
* - `{ scope, minLevel? }` — binds an existing scope (`createScope`, `patchScope`, …)
|
|
33
|
+
*/
|
|
34
|
+
export function createLogger(input: CreateLoggerInput): LoggerWithScope {
|
|
35
|
+
const { minLevel } = input;
|
|
36
|
+
const scopeOptions = minLevel != null ? { minLevel } : undefined;
|
|
37
|
+
|
|
38
|
+
if (isScopeInput(input)) {
|
|
39
|
+
return logManager.withScope(input.scope, scopeOptions).logger;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const scope = createScope({
|
|
43
|
+
module: input.module,
|
|
44
|
+
traceId: input.traceId?.trim() || logManager.generateTraceId(),
|
|
45
|
+
traceParentId: input.traceParentId,
|
|
46
|
+
labels: input.labels,
|
|
47
|
+
});
|
|
48
|
+
return logManager.withScope(scope, scopeOptions).logger;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type { LogScopePatch };
|
|
@@ -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
|
+
}
|
package/src/shared/log/index.ts
CHANGED
|
@@ -2,22 +2,30 @@
|
|
|
2
2
|
* Log domain public API — curated re-exports only.
|
|
3
3
|
*/
|
|
4
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";
|
|
5
13
|
// log-manager
|
|
6
|
-
export {
|
|
7
|
-
export type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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";
|
|
13
23
|
// log-scope
|
|
14
24
|
export {
|
|
15
|
-
|
|
16
|
-
createChildScope,
|
|
17
|
-
createRootScope,
|
|
25
|
+
createScope,
|
|
18
26
|
formatScopeLabels,
|
|
19
27
|
normalizeScope,
|
|
28
|
+
patchScope,
|
|
20
29
|
resolveLogData,
|
|
21
30
|
withModule,
|
|
22
31
|
} from "./log-scope";
|
|
23
|
-
export type { LogScope, LogScopeInput, LogScopePatch, CreateRootScopeInput, CreateChildScopeInput } from "./log-scope";
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { isDevEnvironment } from "../../core.utils";
|
|
2
2
|
import { generateUniqueId } from "../utils/id.utils";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
formatScopeLabels,
|
|
6
|
-
resolveLogData,
|
|
7
|
-
type LogScope,
|
|
8
|
-
type LogScopePatch,
|
|
9
|
-
} from "./log-scope";
|
|
3
|
+
import { offerToLogPersist } from "./log-persist-hook";
|
|
4
|
+
import { formatScopeLabels, type LoggerResetScopePatch, type LogScope, patchScope, resolveLogData } from "./log-scope";
|
|
10
5
|
|
|
11
6
|
/**
|
|
12
7
|
* Log severity and semantics (low → high). `minLevel` filters by {@link LOG_LEVEL_RANK}.
|
|
@@ -42,14 +37,14 @@ interface LogEntry extends LogScope {
|
|
|
42
37
|
timestamp: number;
|
|
43
38
|
level: LogLevel;
|
|
44
39
|
message: string;
|
|
45
|
-
topic: string
|
|
40
|
+
topic: string;
|
|
46
41
|
extra?: string;
|
|
47
42
|
/** Per-line structured business payload. */
|
|
48
43
|
data?: unknown;
|
|
49
44
|
}
|
|
50
45
|
|
|
51
46
|
type LogRestParams = {
|
|
52
|
-
topic
|
|
47
|
+
topic: string;
|
|
53
48
|
extra?: LogEntry["extra"];
|
|
54
49
|
data?: unknown;
|
|
55
50
|
};
|
|
@@ -58,43 +53,43 @@ type LogParams = { message: LogEntry["message"] } & LogRestParams;
|
|
|
58
53
|
|
|
59
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
60
|
}
|
|
66
61
|
|
|
67
62
|
interface LogOptions {
|
|
68
|
-
defaultTopic: LogEntry["topic"];
|
|
69
63
|
formatTimestamp: boolean;
|
|
70
64
|
formatEmoji: boolean;
|
|
71
65
|
formatPrefix: string;
|
|
72
|
-
maxHistoryLength: number;
|
|
73
66
|
/** Logs below this level are skipped. Defaults to DEBUG in dev, INFO in production. */
|
|
74
67
|
minLevel?: LogLevel;
|
|
75
68
|
onLog?: (entry: LogEntry) => void;
|
|
76
69
|
}
|
|
77
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
|
+
|
|
78
77
|
const DEFAULT_OPTIONS: LogOptions = {
|
|
79
|
-
defaultTopic: null,
|
|
80
78
|
formatTimestamp: true,
|
|
81
79
|
formatEmoji: true,
|
|
82
80
|
formatPrefix: "",
|
|
83
|
-
maxHistoryLength: 4096,
|
|
84
81
|
minLevel: isDevEnvironment() ? LogLevel.DEBUG : LogLevel.INFO,
|
|
85
82
|
};
|
|
86
83
|
|
|
87
84
|
interface LoggerWithScope {
|
|
88
|
-
debug: (message: LogParams["message"], restParams
|
|
89
|
-
info: (message: LogParams["message"], restParams
|
|
90
|
-
success: (message: LogParams["message"], restParams
|
|
91
|
-
warn: (message: LogParams["message"], restParams
|
|
92
|
-
error: (message: LogParams["message"], restParams
|
|
93
|
-
critical: (message: LogParams["message"], restParams
|
|
94
|
-
/** Merge
|
|
95
|
-
resetScope: (
|
|
96
|
-
/** @deprecated use {@link LoggerWithScope.resetScope} */
|
|
97
|
-
resetContext: (fields: LogScopePatch) => void;
|
|
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;
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
function mergeLogOptions(options?: Partial<LogOptions>): LogOptions {
|
|
@@ -134,7 +129,6 @@ function validateLogScope(logScope: LogScope): void {
|
|
|
134
129
|
class LogManager {
|
|
135
130
|
private static instance: LogManager;
|
|
136
131
|
private options: LogOptions;
|
|
137
|
-
private history: LogEntry[] = [];
|
|
138
132
|
private readonly levelEmojis = {
|
|
139
133
|
[LogLevel.DEBUG]: "🔍",
|
|
140
134
|
[LogLevel.INFO]: "ℹ️",
|
|
@@ -152,7 +146,9 @@ class LogManager {
|
|
|
152
146
|
if (!LogManager.instance) {
|
|
153
147
|
LogManager.instance = new LogManager(options);
|
|
154
148
|
} else if (options != null && Object.keys(options).length > 0) {
|
|
155
|
-
console.warn(
|
|
149
|
+
console.warn(
|
|
150
|
+
"[LogManager] getInstance(options) ignored — singleton already created. Use setOptions() instead.",
|
|
151
|
+
);
|
|
156
152
|
}
|
|
157
153
|
return LogManager.instance;
|
|
158
154
|
}
|
|
@@ -161,20 +157,13 @@ class LogManager {
|
|
|
161
157
|
this.options = mergeLogOptions({ ...this.options, ...options });
|
|
162
158
|
}
|
|
163
159
|
|
|
164
|
-
public getHistory(): LogEntry[] {
|
|
165
|
-
return [...this.history];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
public clearHistory(): void {
|
|
169
|
-
this.history = [];
|
|
170
|
-
}
|
|
171
|
-
|
|
172
160
|
private getMinLevel(): LogLevel {
|
|
173
161
|
return this.options.minLevel ?? DEFAULT_OPTIONS.minLevel ?? LogLevel.INFO;
|
|
174
162
|
}
|
|
175
163
|
|
|
176
|
-
private shouldLog(level: LogLevel): boolean {
|
|
177
|
-
|
|
164
|
+
private shouldLog(level: LogLevel, scopeMinLevel?: LogLevel): boolean {
|
|
165
|
+
const minLevel = scopeMinLevel ?? this.getMinLevel();
|
|
166
|
+
return LOG_LEVEL_RANK[level] >= LOG_LEVEL_RANK[minLevel];
|
|
178
167
|
}
|
|
179
168
|
|
|
180
169
|
private createLogEntry(payload: LogEntryPayload): LogEntry {
|
|
@@ -183,7 +172,7 @@ class LogManager {
|
|
|
183
172
|
timestamp: Date.now(),
|
|
184
173
|
level,
|
|
185
174
|
message,
|
|
186
|
-
topic
|
|
175
|
+
topic,
|
|
187
176
|
module,
|
|
188
177
|
traceId,
|
|
189
178
|
traceParentId,
|
|
@@ -210,15 +199,14 @@ class LogManager {
|
|
|
210
199
|
|
|
211
200
|
parts.push(this.formatLevelTag(entry));
|
|
212
201
|
parts.push(
|
|
213
|
-
`traceId=${entry.traceId} parent=${entry.traceParentId ?? "null"} labels=${formatScopeLabels(entry.labels)} module=${entry.module} topic=${entry.topic
|
|
202
|
+
`traceId=${entry.traceId} parent=${entry.traceParentId ?? "null"} labels=${formatScopeLabels(entry.labels)} module=${entry.module} topic=${entry.topic}`,
|
|
214
203
|
);
|
|
215
204
|
|
|
216
205
|
if (this.options.formatPrefix) {
|
|
217
206
|
parts.push(`prefix=${this.options.formatPrefix}`);
|
|
218
207
|
}
|
|
219
208
|
|
|
220
|
-
const message =
|
|
221
|
-
entry.level === LogLevel.CRITICAL ? `>>> ${entry.message} <<<` : entry.message;
|
|
209
|
+
const message = entry.level === LogLevel.CRITICAL ? `>>> ${entry.message} <<<` : entry.message;
|
|
222
210
|
parts.push(`| ${message}`);
|
|
223
211
|
|
|
224
212
|
if (entry.extra) {
|
|
@@ -247,14 +235,23 @@ class LogManager {
|
|
|
247
235
|
}
|
|
248
236
|
}
|
|
249
237
|
|
|
250
|
-
private log(
|
|
251
|
-
|
|
238
|
+
private log(
|
|
239
|
+
level: LogLevel,
|
|
240
|
+
message: LogParams["message"],
|
|
241
|
+
logScope: LogScope,
|
|
242
|
+
restParams: LogRestParams,
|
|
243
|
+
scopeMinLevel?: LogLevel,
|
|
244
|
+
) {
|
|
245
|
+
if (!this.shouldLog(level, scopeMinLevel)) {
|
|
252
246
|
return;
|
|
253
247
|
}
|
|
254
248
|
|
|
255
249
|
validateLogScope(logScope);
|
|
250
|
+
if (!restParams.topic?.trim()) {
|
|
251
|
+
throw new Error("[LogManager] topic is required on every log call");
|
|
252
|
+
}
|
|
256
253
|
|
|
257
|
-
const { topic, extra } = restParams
|
|
254
|
+
const { topic, extra } = restParams;
|
|
258
255
|
const data = resolveLogData(restParams);
|
|
259
256
|
const entry = this.createLogEntry({
|
|
260
257
|
level,
|
|
@@ -265,71 +262,70 @@ class LogManager {
|
|
|
265
262
|
...logScope,
|
|
266
263
|
});
|
|
267
264
|
|
|
268
|
-
this.history.push(entry);
|
|
269
|
-
if (this.history.length > this.options.maxHistoryLength) {
|
|
270
|
-
this.history.shift();
|
|
271
|
-
}
|
|
272
|
-
|
|
273
265
|
const formatted = this.formatLog(entry);
|
|
274
266
|
this.emitLog(entry, formatted);
|
|
275
267
|
this.options.onLog?.(entry);
|
|
268
|
+
offerToLogPersist(entry);
|
|
276
269
|
}
|
|
277
270
|
|
|
278
271
|
public generateTraceId(): string {
|
|
279
272
|
return generateUniqueId();
|
|
280
273
|
}
|
|
281
274
|
|
|
282
|
-
public debug(message: LogParams["message"], logScope: LogScope, restParams
|
|
275
|
+
public debug(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
283
276
|
this.log(LogLevel.DEBUG, message, logScope, restParams);
|
|
284
277
|
}
|
|
285
278
|
|
|
286
|
-
public info(message: LogParams["message"], logScope: LogScope, restParams
|
|
279
|
+
public info(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
287
280
|
this.log(LogLevel.INFO, message, logScope, restParams);
|
|
288
281
|
}
|
|
289
282
|
|
|
290
|
-
public success(message: LogParams["message"], logScope: LogScope, restParams
|
|
283
|
+
public success(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
291
284
|
this.log(LogLevel.SUCCESS, message, logScope, restParams);
|
|
292
285
|
}
|
|
293
286
|
|
|
294
|
-
public warn(message: LogParams["message"], logScope: LogScope, restParams
|
|
287
|
+
public warn(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
295
288
|
this.log(LogLevel.WARN, message, logScope, restParams);
|
|
296
289
|
}
|
|
297
290
|
|
|
298
|
-
public error(message: LogParams["message"], logScope: LogScope, restParams
|
|
291
|
+
public error(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
299
292
|
this.log(LogLevel.ERROR, message, logScope, restParams);
|
|
300
293
|
}
|
|
301
294
|
|
|
302
|
-
public critical(message: LogParams["message"], logScope: LogScope, restParams
|
|
295
|
+
public critical(message: LogParams["message"], logScope: LogScope, restParams: LogRestParams) {
|
|
303
296
|
this.log(LogLevel.CRITICAL, message, logScope, restParams);
|
|
304
297
|
}
|
|
305
298
|
|
|
306
|
-
public withScope(scope: LogScope): { logger: LoggerWithScope; scope: LogScope } {
|
|
299
|
+
public withScope(scope: LogScope, options?: WithScopeOptions): { logger: LoggerWithScope; scope: LogScope } {
|
|
307
300
|
const boundScope: LogScope = { ...scope, labels: scope.labels ? { ...scope.labels } : undefined };
|
|
301
|
+
const scopeMinLevel = options?.minLevel;
|
|
308
302
|
|
|
309
303
|
const logger: LoggerWithScope = {
|
|
310
|
-
debug: (message, restParams) => this.
|
|
311
|
-
info: (message, restParams) => this.
|
|
312
|
-
success: (message, restParams) =>
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
318
|
boundScope.module = next.module;
|
|
319
319
|
boundScope.traceId = next.traceId;
|
|
320
320
|
boundScope.traceParentId = next.traceParentId;
|
|
321
321
|
boundScope.labels = next.labels;
|
|
322
322
|
},
|
|
323
|
-
resetContext: (fields) => {
|
|
324
|
-
logger.resetScope(fields);
|
|
325
|
-
},
|
|
326
323
|
};
|
|
327
324
|
|
|
328
325
|
return { logger, scope: boundScope };
|
|
329
326
|
}
|
|
330
|
-
|
|
331
327
|
}
|
|
332
328
|
|
|
333
329
|
export const logManager = LogManager.getInstance();
|
|
334
|
-
export {
|
|
335
|
-
export
|
|
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
|
+
}
|