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,704 @@
|
|
|
1
|
+
import { type LogEntry, LogLevel } from "./log-manager";
|
|
2
|
+
import { DEFAULT_LOG_PERSIST_CONFIG, resolveLogPersistConfig } from "./log-persist.config";
|
|
3
|
+
import type {
|
|
4
|
+
EnableLogPersistOptions,
|
|
5
|
+
LogPersistConfig,
|
|
6
|
+
LogPersistLane,
|
|
7
|
+
LogPersistStats,
|
|
8
|
+
} from "./log-persist.interface";
|
|
9
|
+
import { computeLogBatchIdempotencyKey } from "./log-persist-batch-id";
|
|
10
|
+
import { buildLogListDraft, estimateEntriesBytes, postLogBatch, takeEntriesWithinBytes } from "./log-persist-flush";
|
|
11
|
+
import { registerLogPersistOffer } from "./log-persist-hook";
|
|
12
|
+
import { isLogPersistInternalTopic, patchPersistLoggerScope, persistLogger } from "./log-persist-logger";
|
|
13
|
+
import { heartbeatLogPersistProcess } from "./log-persist-registry";
|
|
14
|
+
|
|
15
|
+
const FAST_RETRY_INTERVAL_MS = 5_000;
|
|
16
|
+
const HEARTBEAT_INTERVAL_MS = 30_000;
|
|
17
|
+
|
|
18
|
+
function routeLane(level: LogLevel): LogPersistLane {
|
|
19
|
+
if (level === LogLevel.CRITICAL) {
|
|
20
|
+
return "fast";
|
|
21
|
+
}
|
|
22
|
+
if (level === LogLevel.ERROR || level === LogLevel.SUCCESS) {
|
|
23
|
+
return "medium";
|
|
24
|
+
}
|
|
25
|
+
return "slow";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class LogPersist {
|
|
29
|
+
private static instance: LogPersist | null = null;
|
|
30
|
+
|
|
31
|
+
private enabled = false;
|
|
32
|
+
private draining = false;
|
|
33
|
+
private service: string | null = null;
|
|
34
|
+
private processName: string | null = null;
|
|
35
|
+
private registryFilePath: string | null = null;
|
|
36
|
+
private config: LogPersistConfig = DEFAULT_LOG_PERSIST_CONFIG;
|
|
37
|
+
|
|
38
|
+
private fastQueue: LogEntry[] = [];
|
|
39
|
+
private fastRetryQueue: LogEntry[] = [];
|
|
40
|
+
private mediumQueue: LogEntry[] = [];
|
|
41
|
+
private slowQueue: LogEntry[] = [];
|
|
42
|
+
|
|
43
|
+
private mediumDebounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
44
|
+
private slowQueueStartedAt: number | null = null;
|
|
45
|
+
private fastRetryTimer: ReturnType<typeof setTimeout> | null = null;
|
|
46
|
+
private heartbeatTimer: ReturnType<typeof setInterval> | null = null;
|
|
47
|
+
private lastHeartbeatAt = 0;
|
|
48
|
+
|
|
49
|
+
private laneFlushing: Record<LogPersistLane, boolean> = {
|
|
50
|
+
fast: false,
|
|
51
|
+
medium: false,
|
|
52
|
+
slow: false,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
private consecutiveFailures: Record<LogPersistLane, number> = {
|
|
56
|
+
fast: 0,
|
|
57
|
+
medium: 0,
|
|
58
|
+
slow: 0,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
private lastFlushAt: Record<LogPersistLane, string | null> = {
|
|
62
|
+
fast: null,
|
|
63
|
+
medium: null,
|
|
64
|
+
slow: null,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
private lastError: string | null = null;
|
|
68
|
+
private lastErrorAt: string | null = null;
|
|
69
|
+
private shutdownHookInstalled = false;
|
|
70
|
+
private shutdownPromise: Promise<void> | null = null;
|
|
71
|
+
|
|
72
|
+
static getInstance(): LogPersist {
|
|
73
|
+
LogPersist.instance ??= new LogPersist();
|
|
74
|
+
return LogPersist.instance;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async enable(options: EnableLogPersistOptions): Promise<void> {
|
|
78
|
+
if (this.enabled) {
|
|
79
|
+
persistLogger.warn("log persist core enable skipped — already enabled", {
|
|
80
|
+
service: this.service,
|
|
81
|
+
process: this.processName,
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.service = options.service;
|
|
87
|
+
this.processName = options.process;
|
|
88
|
+
this.registryFilePath = options.registryFilePath ?? null;
|
|
89
|
+
this.config = resolveLogPersistConfig(options.config);
|
|
90
|
+
this.draining = false;
|
|
91
|
+
this.shutdownPromise = null;
|
|
92
|
+
this.consecutiveFailures = { fast: 0, medium: 0, slow: 0 };
|
|
93
|
+
this.lastError = null;
|
|
94
|
+
this.lastErrorAt = null;
|
|
95
|
+
this.enabled = true;
|
|
96
|
+
|
|
97
|
+
patchPersistLoggerScope({
|
|
98
|
+
service: options.service,
|
|
99
|
+
process: options.process,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
persistLogger.info("log persist core enabled", {
|
|
103
|
+
service: options.service,
|
|
104
|
+
process: options.process,
|
|
105
|
+
registryFilePath: this.registryFilePath,
|
|
106
|
+
config: this.config,
|
|
107
|
+
pid: process.pid,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
registerLogPersistOffer((entry) => {
|
|
111
|
+
this.offer(entry);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
if (this.registryFilePath != null) {
|
|
115
|
+
const { registerLogPersistProcess } = await import("./log-persist-registry");
|
|
116
|
+
await registerLogPersistProcess({
|
|
117
|
+
registryFilePath: this.registryFilePath,
|
|
118
|
+
service: options.service,
|
|
119
|
+
process: options.process,
|
|
120
|
+
});
|
|
121
|
+
this.startHeartbeat();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.installShutdownHook();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async disable(): Promise<void> {
|
|
128
|
+
if (!this.enabled && !this.draining) {
|
|
129
|
+
persistLogger.debug("disable skipped — not enabled");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
persistLogger.info("log persist core disabling", this.queueSnapshot());
|
|
134
|
+
this.cancelMediumDebounce();
|
|
135
|
+
this.stopHeartbeat();
|
|
136
|
+
await this.shutdown();
|
|
137
|
+
persistLogger.info("log persist core disabled");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
offer(entry: LogEntry): void {
|
|
141
|
+
if (isLogPersistInternalTopic(entry.topic)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!this.enabled || this.draining || this.service == null || this.processName == null) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
void this.touchRegistryHeartbeat();
|
|
150
|
+
|
|
151
|
+
const lane = routeLane(entry.level);
|
|
152
|
+
|
|
153
|
+
if (lane === "fast") {
|
|
154
|
+
this.fastQueue.push(entry);
|
|
155
|
+
this.evictFastOverflow();
|
|
156
|
+
void this.flushFast();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (lane === "medium") {
|
|
161
|
+
this.mediumQueue.push(entry);
|
|
162
|
+
this.evictMediumOverflow();
|
|
163
|
+
this.scheduleMediumFlush();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
this.slowQueue.push(entry);
|
|
168
|
+
if (this.slowQueueStartedAt == null) {
|
|
169
|
+
this.slowQueueStartedAt = Date.now();
|
|
170
|
+
}
|
|
171
|
+
this.evictSlowOverflow();
|
|
172
|
+
this.scheduleSlowFlush();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
getStats(): LogPersistStats {
|
|
176
|
+
return {
|
|
177
|
+
enabled: this.enabled,
|
|
178
|
+
draining: this.draining,
|
|
179
|
+
service: this.service,
|
|
180
|
+
process: this.processName,
|
|
181
|
+
queues: {
|
|
182
|
+
fast: this.fastQueue.length,
|
|
183
|
+
fastRetry: this.fastRetryQueue.length,
|
|
184
|
+
medium: this.mediumQueue.length,
|
|
185
|
+
slow: this.slowQueue.length,
|
|
186
|
+
},
|
|
187
|
+
queueBytes: {
|
|
188
|
+
fast: estimateEntriesBytes(this.fastQueue),
|
|
189
|
+
fastRetry: estimateEntriesBytes(this.fastRetryQueue),
|
|
190
|
+
medium: estimateEntriesBytes(this.mediumQueue),
|
|
191
|
+
slow: estimateEntriesBytes(this.slowQueue),
|
|
192
|
+
},
|
|
193
|
+
mediumDebouncePending: this.mediumDebounceTimer != null,
|
|
194
|
+
laneFlushing: { ...this.laneFlushing },
|
|
195
|
+
consecutiveFailures: { ...this.consecutiveFailures },
|
|
196
|
+
config: this.config,
|
|
197
|
+
lastFlushAt: { ...this.lastFlushAt },
|
|
198
|
+
lastError: this.lastError,
|
|
199
|
+
lastErrorAt: this.lastErrorAt,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async shutdown(): Promise<void> {
|
|
204
|
+
if (this.shutdownPromise != null) {
|
|
205
|
+
return this.shutdownPromise;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
this.shutdownPromise = this.shutdownInner();
|
|
209
|
+
return this.shutdownPromise;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
private async shutdownInner(): Promise<void> {
|
|
213
|
+
if (this.draining) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
this.draining = true;
|
|
218
|
+
this.enabled = false;
|
|
219
|
+
registerLogPersistOffer(null);
|
|
220
|
+
|
|
221
|
+
persistLogger.info("shutdown flush started", this.queueSnapshot());
|
|
222
|
+
|
|
223
|
+
this.cancelMediumDebounce();
|
|
224
|
+
await this.drainQueues(this.config.shutdownDrainTimeoutMs);
|
|
225
|
+
|
|
226
|
+
if (this.registryFilePath != null && this.processName != null) {
|
|
227
|
+
const { unregisterLogPersistProcess } = await import("./log-persist-registry");
|
|
228
|
+
await unregisterLogPersistProcess({
|
|
229
|
+
registryFilePath: this.registryFilePath,
|
|
230
|
+
process: this.processName,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (this.hasQueued()) {
|
|
235
|
+
persistLogger.warn("shutdown drain incomplete — queued logs dropped", {
|
|
236
|
+
...this.queueSnapshot(),
|
|
237
|
+
shutdownDrainTimeoutMs: this.config.shutdownDrainTimeoutMs,
|
|
238
|
+
});
|
|
239
|
+
this.fastQueue = [];
|
|
240
|
+
this.fastRetryQueue = [];
|
|
241
|
+
this.mediumQueue = [];
|
|
242
|
+
this.slowQueue = [];
|
|
243
|
+
this.slowQueueStartedAt = null;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
persistLogger.info("shutdown flush completed", this.queueSnapshot());
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
private hasQueued(): boolean {
|
|
250
|
+
return (
|
|
251
|
+
this.fastQueue.length > 0 ||
|
|
252
|
+
this.fastRetryQueue.length > 0 ||
|
|
253
|
+
this.mediumQueue.length > 0 ||
|
|
254
|
+
this.slowQueue.length > 0
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private async drainQueues(timeoutMs: number): Promise<void> {
|
|
259
|
+
const deadline = Date.now() + timeoutMs;
|
|
260
|
+
while (this.hasQueued() && Date.now() < deadline) {
|
|
261
|
+
await this.flushFast();
|
|
262
|
+
await this.flushMedium();
|
|
263
|
+
await this.flushSlow();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private recordLaneError(lane: LogPersistLane, error: unknown): void {
|
|
268
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
269
|
+
this.lastError = message;
|
|
270
|
+
this.lastErrorAt = new Date().toISOString();
|
|
271
|
+
this.consecutiveFailures[lane] += 1;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
private recordLaneSuccess(lane: LogPersistLane): void {
|
|
275
|
+
this.lastError = null;
|
|
276
|
+
this.consecutiveFailures[lane] = 0;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private queueSnapshot(): Record<string, unknown> {
|
|
280
|
+
return {
|
|
281
|
+
queues: {
|
|
282
|
+
fast: this.fastQueue.length,
|
|
283
|
+
fastRetry: this.fastRetryQueue.length,
|
|
284
|
+
medium: this.mediumQueue.length,
|
|
285
|
+
slow: this.slowQueue.length,
|
|
286
|
+
},
|
|
287
|
+
queueBytes: {
|
|
288
|
+
fast: estimateEntriesBytes(this.fastQueue),
|
|
289
|
+
fastRetry: estimateEntriesBytes(this.fastRetryQueue),
|
|
290
|
+
medium: estimateEntriesBytes(this.mediumQueue),
|
|
291
|
+
slow: estimateEntriesBytes(this.slowQueue),
|
|
292
|
+
},
|
|
293
|
+
laneFlushing: { ...this.laneFlushing },
|
|
294
|
+
consecutiveFailures: { ...this.consecutiveFailures },
|
|
295
|
+
lastError: this.lastError,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private installShutdownHook(): void {
|
|
300
|
+
if (this.shutdownHookInstalled) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
this.shutdownHookInstalled = true;
|
|
304
|
+
|
|
305
|
+
const handler = (signal: NodeJS.Signals) => {
|
|
306
|
+
persistLogger.info("shutdown signal received", { signal });
|
|
307
|
+
void this.shutdown();
|
|
308
|
+
};
|
|
309
|
+
process.once("SIGTERM", handler);
|
|
310
|
+
process.once("SIGINT", handler);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private startHeartbeat(): void {
|
|
314
|
+
this.stopHeartbeat();
|
|
315
|
+
this.heartbeatTimer = setInterval(() => {
|
|
316
|
+
void this.touchRegistryHeartbeat(true);
|
|
317
|
+
}, HEARTBEAT_INTERVAL_MS);
|
|
318
|
+
this.heartbeatTimer.unref?.();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private stopHeartbeat(): void {
|
|
322
|
+
if (this.heartbeatTimer != null) {
|
|
323
|
+
clearInterval(this.heartbeatTimer);
|
|
324
|
+
this.heartbeatTimer = null;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
private async touchRegistryHeartbeat(force = false): Promise<void> {
|
|
329
|
+
if (this.registryFilePath == null || this.processName == null) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const now = Date.now();
|
|
333
|
+
if (!force && now - this.lastHeartbeatAt < HEARTBEAT_INTERVAL_MS) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
this.lastHeartbeatAt = now;
|
|
337
|
+
await heartbeatLogPersistProcess({
|
|
338
|
+
registryFilePath: this.registryFilePath,
|
|
339
|
+
process: this.processName,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
private scheduleMediumFlush(): void {
|
|
344
|
+
const { debounceMs, maxEntries, maxBytes } = this.config.medium;
|
|
345
|
+
const queueBytes = estimateEntriesBytes(this.mediumQueue);
|
|
346
|
+
if (this.mediumQueue.length >= maxEntries || queueBytes >= maxBytes) {
|
|
347
|
+
persistLogger.warn("medium flush scheduled — threshold", {
|
|
348
|
+
reason: this.mediumQueue.length >= maxEntries ? "maxEntries" : "maxBytes",
|
|
349
|
+
queueLength: this.mediumQueue.length,
|
|
350
|
+
maxEntries,
|
|
351
|
+
queueBytes,
|
|
352
|
+
maxBytes,
|
|
353
|
+
});
|
|
354
|
+
this.cancelMediumDebounce();
|
|
355
|
+
void this.flushMedium();
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (this.mediumDebounceTimer == null && this.mediumQueue.length > 0) {
|
|
360
|
+
persistLogger.debug("medium flush debounce scheduled", {
|
|
361
|
+
debounceMs,
|
|
362
|
+
queueLength: this.mediumQueue.length,
|
|
363
|
+
queueBytes,
|
|
364
|
+
});
|
|
365
|
+
this.mediumDebounceTimer = setTimeout(() => {
|
|
366
|
+
this.mediumDebounceTimer = null;
|
|
367
|
+
persistLogger.debug("medium flush debounce fired");
|
|
368
|
+
void this.flushMedium();
|
|
369
|
+
}, debounceMs);
|
|
370
|
+
this.mediumDebounceTimer.unref?.();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
private cancelMediumDebounce(): void {
|
|
375
|
+
if (this.mediumDebounceTimer != null) {
|
|
376
|
+
clearTimeout(this.mediumDebounceTimer);
|
|
377
|
+
this.mediumDebounceTimer = null;
|
|
378
|
+
persistLogger.debug("medium flush debounce cancelled");
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
private scheduleSlowFlush(): void {
|
|
383
|
+
const { maxEntries, maxBytes, maxAgeMs } = this.config.slow;
|
|
384
|
+
const queueBytes = estimateEntriesBytes(this.slowQueue);
|
|
385
|
+
const ageMs = this.slowQueueStartedAt != null ? Date.now() - this.slowQueueStartedAt : 0;
|
|
386
|
+
if (this.slowQueue.length >= maxEntries || queueBytes >= maxBytes || ageMs >= maxAgeMs) {
|
|
387
|
+
persistLogger.debug("slow flush scheduled — threshold", {
|
|
388
|
+
reason:
|
|
389
|
+
this.slowQueue.length >= maxEntries
|
|
390
|
+
? "maxEntries"
|
|
391
|
+
: queueBytes >= maxBytes
|
|
392
|
+
? "maxBytes"
|
|
393
|
+
: "maxAgeMs",
|
|
394
|
+
queueLength: this.slowQueue.length,
|
|
395
|
+
maxEntries,
|
|
396
|
+
queueBytes,
|
|
397
|
+
maxBytes,
|
|
398
|
+
ageMs,
|
|
399
|
+
maxAgeMs,
|
|
400
|
+
});
|
|
401
|
+
void this.flushSlow();
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
private evictFastOverflow(): void {
|
|
406
|
+
const { maxBufferEntries } = this.config.fast;
|
|
407
|
+
let evicted = 0;
|
|
408
|
+
while (this.fastQueue.length + this.fastRetryQueue.length > maxBufferEntries) {
|
|
409
|
+
const removed = this.fastQueue.length > 0 ? this.fastQueue.shift() : this.fastRetryQueue.shift();
|
|
410
|
+
evicted += 1;
|
|
411
|
+
persistLogger.warn("fast queue overflow — evicted entry", {
|
|
412
|
+
evictedLevel: removed?.level,
|
|
413
|
+
evictedTopic: removed?.topic,
|
|
414
|
+
fromRetryQueue: this.fastQueue.length === 0,
|
|
415
|
+
maxBufferEntries,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
if (evicted > 0) {
|
|
419
|
+
persistLogger.warn("fast queue overflow summary", { evicted, maxBufferEntries });
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
private evictMediumOverflow(): void {
|
|
424
|
+
const { maxBufferEntries } = this.config.medium;
|
|
425
|
+
let evicted = 0;
|
|
426
|
+
while (this.mediumQueue.length > maxBufferEntries) {
|
|
427
|
+
const successIndex = this.mediumQueue.findIndex((entry) => entry.level === LogLevel.SUCCESS);
|
|
428
|
+
const removed = successIndex >= 0 ? this.mediumQueue.splice(successIndex, 1)[0] : this.mediumQueue.shift();
|
|
429
|
+
evicted += 1;
|
|
430
|
+
persistLogger.warn("medium queue overflow — evicted entry", {
|
|
431
|
+
evictedLevel: removed?.level,
|
|
432
|
+
evictedTopic: removed?.topic,
|
|
433
|
+
queueLength: this.mediumQueue.length,
|
|
434
|
+
maxBufferEntries,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
if (evicted > 0) {
|
|
438
|
+
persistLogger.warn("medium queue overflow summary", {
|
|
439
|
+
evicted,
|
|
440
|
+
queueLength: this.mediumQueue.length,
|
|
441
|
+
maxBufferEntries,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
private evictSlowOverflow(): void {
|
|
447
|
+
const { maxBufferEntries } = this.config.slow;
|
|
448
|
+
let evicted = 0;
|
|
449
|
+
while (this.slowQueue.length > maxBufferEntries) {
|
|
450
|
+
const debugIndex = this.slowQueue.findIndex((entry) => entry.level === LogLevel.DEBUG);
|
|
451
|
+
const removed = debugIndex >= 0 ? this.slowQueue.splice(debugIndex, 1)[0] : this.slowQueue.shift();
|
|
452
|
+
evicted += 1;
|
|
453
|
+
persistLogger.warn("slow queue overflow — evicted entry", {
|
|
454
|
+
evictedLevel: removed?.level,
|
|
455
|
+
evictedTopic: removed?.topic,
|
|
456
|
+
queueLength: this.slowQueue.length,
|
|
457
|
+
maxBufferEntries,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
if (evicted > 0) {
|
|
461
|
+
persistLogger.warn("slow queue overflow summary", {
|
|
462
|
+
evicted,
|
|
463
|
+
queueLength: this.slowQueue.length,
|
|
464
|
+
maxBufferEntries,
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
if (this.slowQueue.length === 0) {
|
|
468
|
+
this.slowQueueStartedAt = null;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
private async flushFast(): Promise<void> {
|
|
473
|
+
if (this.laneFlushing.fast) {
|
|
474
|
+
persistLogger.debug("fast flush skipped — already flushing");
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (this.service == null || this.processName == null) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
this.laneFlushing.fast = true;
|
|
482
|
+
try {
|
|
483
|
+
while (this.fastQueue.length > 0 || this.fastRetryQueue.length > 0) {
|
|
484
|
+
const fromRetry = this.fastQueue.length === 0;
|
|
485
|
+
const entry = this.fastQueue.shift() ?? this.fastRetryQueue.shift();
|
|
486
|
+
if (entry == null) {
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
const idempotencyKey = computeLogBatchIdempotencyKey({
|
|
491
|
+
service: this.service,
|
|
492
|
+
process: this.processName,
|
|
493
|
+
lane: "fast",
|
|
494
|
+
entries: [entry],
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
try {
|
|
498
|
+
const draft = buildLogListDraft({
|
|
499
|
+
service: this.service,
|
|
500
|
+
process: this.processName,
|
|
501
|
+
lane: "fast",
|
|
502
|
+
idempotencyKey,
|
|
503
|
+
entries: [entry],
|
|
504
|
+
});
|
|
505
|
+
persistLogger.debug("fast flush posting batch", {
|
|
506
|
+
idempotencyKey,
|
|
507
|
+
fromRetry,
|
|
508
|
+
level: entry.level,
|
|
509
|
+
topic: entry.topic,
|
|
510
|
+
});
|
|
511
|
+
await postLogBatch(draft, this.config.postTimeoutMs);
|
|
512
|
+
this.lastFlushAt.fast = new Date().toISOString();
|
|
513
|
+
this.recordLaneSuccess("fast");
|
|
514
|
+
persistLogger.info("fast lane flushed", {
|
|
515
|
+
idempotencyKey,
|
|
516
|
+
level: entry.level,
|
|
517
|
+
topic: entry.topic,
|
|
518
|
+
fastRetryRemaining: this.fastRetryQueue.length,
|
|
519
|
+
});
|
|
520
|
+
} catch (error) {
|
|
521
|
+
this.recordLaneError("fast", error);
|
|
522
|
+
this.fastRetryQueue.push(entry);
|
|
523
|
+
persistLogger.error("fast flush failed — queued for retry", {
|
|
524
|
+
idempotencyKey,
|
|
525
|
+
error: this.lastError,
|
|
526
|
+
retryInMs: FAST_RETRY_INTERVAL_MS,
|
|
527
|
+
fastRetryQueue: this.fastRetryQueue.length,
|
|
528
|
+
});
|
|
529
|
+
this.scheduleFastRetry();
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
} finally {
|
|
534
|
+
this.laneFlushing.fast = false;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
private scheduleFastRetry(): void {
|
|
539
|
+
if (this.fastRetryTimer != null) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
persistLogger.warn("fast flush retry scheduled", { retryInMs: FAST_RETRY_INTERVAL_MS });
|
|
543
|
+
this.fastRetryTimer = setTimeout(() => {
|
|
544
|
+
this.fastRetryTimer = null;
|
|
545
|
+
persistLogger.debug("fast flush retry timer fired");
|
|
546
|
+
void this.flushFast();
|
|
547
|
+
}, FAST_RETRY_INTERVAL_MS);
|
|
548
|
+
this.fastRetryTimer.unref?.();
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
private async flushMedium(): Promise<void> {
|
|
552
|
+
if (this.laneFlushing.medium) {
|
|
553
|
+
persistLogger.debug("medium flush skipped — already flushing");
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
if (this.mediumQueue.length === 0) {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (this.service == null || this.processName == null) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
this.laneFlushing.medium = true;
|
|
564
|
+
try {
|
|
565
|
+
while (this.mediumQueue.length > 0) {
|
|
566
|
+
const batch = takeEntriesWithinBytes(this.mediumQueue, this.config.medium.maxBytes);
|
|
567
|
+
if (batch.length === 0) {
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const idempotencyKey = computeLogBatchIdempotencyKey({
|
|
572
|
+
service: this.service,
|
|
573
|
+
process: this.processName,
|
|
574
|
+
lane: "medium",
|
|
575
|
+
entries: batch,
|
|
576
|
+
});
|
|
577
|
+
const batchBytes = estimateEntriesBytes(batch);
|
|
578
|
+
|
|
579
|
+
try {
|
|
580
|
+
persistLogger.debug("medium flush posting batch", {
|
|
581
|
+
idempotencyKey,
|
|
582
|
+
batchSize: batch.length,
|
|
583
|
+
batchBytes,
|
|
584
|
+
queueRemaining: this.mediumQueue.length,
|
|
585
|
+
});
|
|
586
|
+
const draft = buildLogListDraft({
|
|
587
|
+
service: this.service,
|
|
588
|
+
process: this.processName,
|
|
589
|
+
lane: "medium",
|
|
590
|
+
idempotencyKey,
|
|
591
|
+
entries: batch,
|
|
592
|
+
});
|
|
593
|
+
await postLogBatch(draft, this.config.postTimeoutMs);
|
|
594
|
+
this.mediumQueue.splice(0, batch.length);
|
|
595
|
+
this.lastFlushAt.medium = new Date().toISOString();
|
|
596
|
+
this.recordLaneSuccess("medium");
|
|
597
|
+
persistLogger.info("medium lane flushed", {
|
|
598
|
+
idempotencyKey,
|
|
599
|
+
batchSize: batch.length,
|
|
600
|
+
batchBytes,
|
|
601
|
+
queueRemaining: this.mediumQueue.length,
|
|
602
|
+
});
|
|
603
|
+
} catch (error) {
|
|
604
|
+
this.recordLaneError("medium", error);
|
|
605
|
+
persistLogger.error("medium flush failed — entries retained", {
|
|
606
|
+
idempotencyKey,
|
|
607
|
+
batchSize: batch.length,
|
|
608
|
+
batchBytes,
|
|
609
|
+
error: this.lastError,
|
|
610
|
+
queueRemaining: this.mediumQueue.length,
|
|
611
|
+
});
|
|
612
|
+
this.scheduleMediumFlush();
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
} finally {
|
|
617
|
+
this.laneFlushing.medium = false;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
if (this.mediumQueue.length > 0 && !this.laneFlushing.medium) {
|
|
621
|
+
this.scheduleMediumFlush();
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
private async flushSlow(): Promise<void> {
|
|
626
|
+
if (this.laneFlushing.slow) {
|
|
627
|
+
persistLogger.debug("slow flush skipped — already flushing");
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
if (this.slowQueue.length === 0) {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
if (this.service == null || this.processName == null) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
this.laneFlushing.slow = true;
|
|
638
|
+
try {
|
|
639
|
+
while (this.slowQueue.length > 0) {
|
|
640
|
+
const batch = takeEntriesWithinBytes(this.slowQueue, this.config.slow.maxBytes);
|
|
641
|
+
if (batch.length === 0) {
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
const idempotencyKey = computeLogBatchIdempotencyKey({
|
|
646
|
+
service: this.service,
|
|
647
|
+
process: this.processName,
|
|
648
|
+
lane: "slow",
|
|
649
|
+
entries: batch,
|
|
650
|
+
});
|
|
651
|
+
const batchBytes = estimateEntriesBytes(batch);
|
|
652
|
+
|
|
653
|
+
try {
|
|
654
|
+
persistLogger.debug("slow flush posting batch", {
|
|
655
|
+
idempotencyKey,
|
|
656
|
+
batchSize: batch.length,
|
|
657
|
+
batchBytes,
|
|
658
|
+
queueRemaining: this.slowQueue.length,
|
|
659
|
+
});
|
|
660
|
+
const draft = buildLogListDraft({
|
|
661
|
+
service: this.service,
|
|
662
|
+
process: this.processName,
|
|
663
|
+
lane: "slow",
|
|
664
|
+
idempotencyKey,
|
|
665
|
+
entries: batch,
|
|
666
|
+
});
|
|
667
|
+
await postLogBatch(draft, this.config.postTimeoutMs);
|
|
668
|
+
this.slowQueue.splice(0, batch.length);
|
|
669
|
+
this.lastFlushAt.slow = new Date().toISOString();
|
|
670
|
+
this.recordLaneSuccess("slow");
|
|
671
|
+
persistLogger.info("slow lane flushed", {
|
|
672
|
+
idempotencyKey,
|
|
673
|
+
batchSize: batch.length,
|
|
674
|
+
batchBytes,
|
|
675
|
+
queueRemaining: this.slowQueue.length,
|
|
676
|
+
});
|
|
677
|
+
} catch (error) {
|
|
678
|
+
this.recordLaneError("slow", error);
|
|
679
|
+
persistLogger.error("slow flush failed — entries retained", {
|
|
680
|
+
idempotencyKey,
|
|
681
|
+
batchSize: batch.length,
|
|
682
|
+
batchBytes,
|
|
683
|
+
error: this.lastError,
|
|
684
|
+
queueRemaining: this.slowQueue.length,
|
|
685
|
+
});
|
|
686
|
+
this.scheduleSlowFlush();
|
|
687
|
+
break;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
if (this.slowQueue.length === 0) {
|
|
692
|
+
this.slowQueueStartedAt = null;
|
|
693
|
+
}
|
|
694
|
+
} finally {
|
|
695
|
+
this.laneFlushing.slow = false;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (this.slowQueue.length > 0 && !this.laneFlushing.slow) {
|
|
699
|
+
this.scheduleSlowFlush();
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
export { LogPersist };
|