target-supabase-sdk 0.2.0 → 0.2.2
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 +130 -11
- 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-BH-tbKEj.js +1481 -0
- package/dist/chunks/enable-log-persist-BH-tbKEj.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 +18 -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 +84 -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 +252 -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
package/src/task/index.ts
CHANGED
|
@@ -3,46 +3,43 @@
|
|
|
3
3
|
* Internal modules (local-task-registry, task-repo-context, task.utils) stay private.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
TaskStatusAction,
|
|
12
|
-
} from "./task.interface";
|
|
13
|
-
export type { Task, TaskDetails, TaskFlow } from "./task.interface";
|
|
14
|
-
|
|
6
|
+
export type {
|
|
7
|
+
PatchChangeTaskStatusPayload,
|
|
8
|
+
PatchClaimTaskPayload,
|
|
9
|
+
PatchTaskProgressPayload,
|
|
10
|
+
} from "./task.api";
|
|
15
11
|
// task.api
|
|
16
12
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
patchChangeTaskStatus,
|
|
14
|
+
patchChangeTaskStatusSchema,
|
|
15
|
+
patchClaimTask,
|
|
16
|
+
patchClaimTaskSchema,
|
|
17
|
+
patchTaskProgress,
|
|
18
|
+
patchTaskProgressSchema,
|
|
23
19
|
} from "./task.api";
|
|
20
|
+
export type { Task, TaskDetails, TaskFlow } from "./task.interface";
|
|
21
|
+
// task.interface
|
|
22
|
+
export {
|
|
23
|
+
CategoryTask,
|
|
24
|
+
ResultCode,
|
|
25
|
+
TaskStatus,
|
|
26
|
+
TaskStatusAction,
|
|
27
|
+
} from "./task.interface";
|
|
24
28
|
export type {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export type { PostTaskPayload } from "./task-post.api";
|
|
31
|
-
|
|
29
|
+
PrepareTaskParams,
|
|
30
|
+
PrepareTaskResponse,
|
|
31
|
+
RegisterTasksOptions,
|
|
32
|
+
RegisterTasksResult,
|
|
33
|
+
} from "./task-manager";
|
|
32
34
|
// task-manager
|
|
33
35
|
export { TaskManager } from "./task-manager";
|
|
36
|
+
export type { PostTaskPayload } from "./task-post.api";
|
|
37
|
+
export { postTask, postTaskSchema } from "./task-post.api";
|
|
38
|
+
export { postTaskWithValidation } from "./task-post-validated.api";
|
|
34
39
|
export type {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
RegisterTasksResult,
|
|
40
|
-
} from "./task-manager";
|
|
41
|
-
|
|
40
|
+
TaskRepoValidationFailureReason,
|
|
41
|
+
ValidateTaskRepoAndParamsInput,
|
|
42
|
+
ValidateTaskRepoAndParamsResult,
|
|
43
|
+
} from "./task-repo-validation";
|
|
42
44
|
// task-repo-validation
|
|
43
45
|
export { TaskRepoValidation } from "./task-repo-validation";
|
|
44
|
-
export type {
|
|
45
|
-
TaskRepoValidationFailureReason,
|
|
46
|
-
ValidateTaskRepoAndParamsInput,
|
|
47
|
-
ValidateTaskRepoAndParamsResult,
|
|
48
|
-
} from "./task-repo-validation";
|
|
@@ -10,12 +10,12 @@ import {
|
|
|
10
10
|
resolvePathFromConfigFile,
|
|
11
11
|
} from "../shared/utils/config-path.utils";
|
|
12
12
|
import {
|
|
13
|
-
BootstrapLocalTasksResult,
|
|
13
|
+
type BootstrapLocalTasksResult,
|
|
14
14
|
TASK_LOCAL_PACKAGE_CONFIG_FILENAME,
|
|
15
15
|
TASK_RUNNER_ROOT_CONFIG_LEGACY_RELATIVE_PATH,
|
|
16
16
|
TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH,
|
|
17
|
-
TaskLocalPackageConfig,
|
|
18
|
-
TaskRunnerRootConfig,
|
|
17
|
+
type TaskLocalPackageConfig,
|
|
18
|
+
type TaskRunnerRootConfig,
|
|
19
19
|
} from "./task-repo-context";
|
|
20
20
|
|
|
21
21
|
export interface BootstrapLocalTasksOptions {
|
|
@@ -77,7 +77,7 @@ function parseTaskPackageConfig(raw: unknown, configPath: string): TaskLocalPack
|
|
|
77
77
|
entry: entry.trim(),
|
|
78
78
|
exportName: typeof record.exportName === "string" ? record.exportName : undefined,
|
|
79
79
|
displayName: typeof record.displayName === "string" ? record.displayName : undefined,
|
|
80
|
-
enabled: record.enabled
|
|
80
|
+
enabled: record.enabled !== false,
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -114,7 +114,7 @@ async function computeConfigFingerprint(rootConfigPath: string, tasksRoot: strin
|
|
|
114
114
|
|
|
115
115
|
function canUseCachedBootstrap(
|
|
116
116
|
fingerprint: string,
|
|
117
|
-
forTaskTypeKey: string | undefined
|
|
117
|
+
forTaskTypeKey: string | undefined,
|
|
118
118
|
): BootstrapLocalTasksResult | null {
|
|
119
119
|
if (bootstrapCache.fingerprint !== fingerprint || bootstrapCache.lastResult == null) {
|
|
120
120
|
return null;
|
|
@@ -129,17 +129,12 @@ function canUseCachedBootstrap(
|
|
|
129
129
|
return { ...bootstrapCache.lastResult, cached: true };
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
async function runBootstrapScan(
|
|
133
|
-
options: BootstrapLocalTasksOptions
|
|
134
|
-
): Promise<BootstrapLocalTasksResult> {
|
|
132
|
+
async function runBootstrapScan(options: BootstrapLocalTasksOptions): Promise<BootstrapLocalTasksResult> {
|
|
135
133
|
const cwd = options.cwd ?? process.cwd();
|
|
136
134
|
|
|
137
135
|
const rootConfigPath = await resolveFirstExistingPath(cwd, {
|
|
138
136
|
explicitPath: options.rootConfigPath,
|
|
139
|
-
candidatePaths: [
|
|
140
|
-
TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH,
|
|
141
|
-
TASK_RUNNER_ROOT_CONFIG_LEGACY_RELATIVE_PATH,
|
|
142
|
-
],
|
|
137
|
+
candidatePaths: [TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH, TASK_RUNNER_ROOT_CONFIG_LEGACY_RELATIVE_PATH],
|
|
143
138
|
});
|
|
144
139
|
if (rootConfigPath == null) {
|
|
145
140
|
const result: BootstrapLocalTasksResult = {
|
|
@@ -218,10 +213,7 @@ async function runBootstrapScan(
|
|
|
218
213
|
const status = finalizeStatus(result);
|
|
219
214
|
const finalResult: BootstrapLocalTasksResult = {
|
|
220
215
|
status,
|
|
221
|
-
message:
|
|
222
|
-
status === "empty"
|
|
223
|
-
? `Root config loaded but no tasks registered under ${tasksRoot}`
|
|
224
|
-
: undefined,
|
|
216
|
+
message: status === "empty" ? `Root config loaded but no tasks registered under ${tasksRoot}` : undefined,
|
|
225
217
|
...result,
|
|
226
218
|
};
|
|
227
219
|
bootstrapCache = { fingerprint, lastResult: finalResult };
|
|
@@ -257,7 +249,7 @@ async function runBootstrapScan(
|
|
|
257
249
|
* Legacy fallback: `./task.config.js` at project root (`taskDir: "./tasks"`).
|
|
258
250
|
*/
|
|
259
251
|
export async function bootstrapLocalTasks(
|
|
260
|
-
options: BootstrapLocalTasksOptions = {}
|
|
252
|
+
options: BootstrapLocalTasksOptions = {},
|
|
261
253
|
): Promise<BootstrapLocalTasksResult> {
|
|
262
254
|
if (bootstrapInFlight != null) {
|
|
263
255
|
return bootstrapInFlight;
|
package/src/task/task-manager.ts
CHANGED
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
import { getScanRemoteRepoValues } from "../repo/repo.api";
|
|
2
2
|
import { TASK_REPO_USAGE } from "../repo/repo.interface";
|
|
3
|
-
import { LoggerWithScope } from "../shared/log";
|
|
4
|
-
import { ResultCode, Task } from "./task.interface";
|
|
5
|
-
import {
|
|
3
|
+
import type { LoggerWithScope } from "../shared/log";
|
|
4
|
+
import type { ResultCode, Task } from "./task.interface";
|
|
5
|
+
import type { ExecutableTaskFn, TaskFn } from "./task-repo-context";
|
|
6
6
|
|
|
7
7
|
export type {
|
|
8
|
+
BootstrapLocalTasksResult,
|
|
9
|
+
BootstrapLocalTasksStatus,
|
|
10
|
+
ExecutableTaskFn,
|
|
8
11
|
TaskFn,
|
|
12
|
+
TaskLocalPackageConfig,
|
|
9
13
|
TaskRepoContext,
|
|
10
|
-
TaskRunResult,
|
|
11
|
-
ExecutableTaskFn,
|
|
12
14
|
TaskRepoScriptDetails,
|
|
13
15
|
TaskRepoScriptRecord,
|
|
14
16
|
TaskRunnerRootConfig,
|
|
15
|
-
|
|
16
|
-
BootstrapLocalTasksResult,
|
|
17
|
-
BootstrapLocalTasksStatus,
|
|
17
|
+
TaskRunResult,
|
|
18
18
|
} from "./task-repo-context";
|
|
19
19
|
export {
|
|
20
|
+
TASK_LOCAL_PACKAGE_CONFIG_FILENAME,
|
|
20
21
|
TASK_REPO_SCRIPT_CATEGORY,
|
|
21
22
|
TASK_RUNNER_CONFIG_DIR,
|
|
22
23
|
TASK_RUNNER_ROOT_CONFIG_FILENAME,
|
|
23
|
-
TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH,
|
|
24
24
|
TASK_RUNNER_ROOT_CONFIG_LEGACY_RELATIVE_PATH,
|
|
25
|
-
|
|
25
|
+
TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH,
|
|
26
26
|
} from "./task-repo-context";
|
|
27
|
+
|
|
27
28
|
import {
|
|
29
|
+
type BootstrapLocalTasksOptions,
|
|
28
30
|
bootstrapLocalTasks,
|
|
29
|
-
BootstrapLocalTasksOptions,
|
|
30
31
|
clearBootstrapLocalTasksCache,
|
|
31
32
|
getRegisteredLocalTaskTypeKeys,
|
|
32
33
|
} from "./local-task-registry";
|
|
34
|
+
import { LOG_TOPIC_TASK } from "./task.constant";
|
|
33
35
|
import type { BootstrapLocalTasksResult } from "./task-repo-context";
|
|
34
36
|
import { TaskRepoValidation, type TaskRepoValidationFailureReason } from "./task-repo-validation";
|
|
35
37
|
|
|
36
|
-
/** @deprecated use {@link TaskRepoValidationFailureReason} */
|
|
37
|
-
export type PrepareTaskFailureReason = TaskRepoValidationFailureReason;
|
|
38
|
-
|
|
39
38
|
export type {
|
|
40
39
|
TaskRepoValidationFailureReason,
|
|
41
40
|
ValidateTaskRepoAndParamsInput,
|
|
@@ -48,7 +47,7 @@ export interface PrepareTaskResponse {
|
|
|
48
47
|
taskFn: ExecutableTaskFn | null;
|
|
49
48
|
code?: ResultCode;
|
|
50
49
|
message?: string;
|
|
51
|
-
reason?:
|
|
50
|
+
reason?: TaskRepoValidationFailureReason;
|
|
52
51
|
/** Pipeline step for log aggregation */
|
|
53
52
|
step?: string;
|
|
54
53
|
}
|
|
@@ -82,25 +81,25 @@ function logLocalBootstrap(logger: LoggerWithScope, bootstrap: BootstrapLocalTas
|
|
|
82
81
|
switch (bootstrap.status) {
|
|
83
82
|
case "not_configured":
|
|
84
83
|
logger.info("未找到本地任務配置,跳過本地註冊", {
|
|
85
|
-
topic:
|
|
84
|
+
topic: LOG_TOPIC_TASK,
|
|
86
85
|
data: { message: bootstrap.message },
|
|
87
86
|
});
|
|
88
87
|
break;
|
|
89
88
|
case "failed":
|
|
90
89
|
logger.warn("本地任務註冊失敗", {
|
|
91
|
-
topic:
|
|
90
|
+
topic: LOG_TOPIC_TASK,
|
|
92
91
|
data: { message: bootstrap.message, errors: bootstrap.errors },
|
|
93
92
|
});
|
|
94
93
|
break;
|
|
95
94
|
case "empty":
|
|
96
95
|
logger.info("本地任務掃描完成,無已註冊任務", {
|
|
97
|
-
topic:
|
|
96
|
+
topic: LOG_TOPIC_TASK,
|
|
98
97
|
data: { message: bootstrap.message, skipped: bootstrap.skipped },
|
|
99
98
|
});
|
|
100
99
|
break;
|
|
101
100
|
case "loaded":
|
|
102
101
|
logger.info("本地任務註冊完成", {
|
|
103
|
-
topic:
|
|
102
|
+
topic: LOG_TOPIC_TASK,
|
|
104
103
|
data: {
|
|
105
104
|
registered: bootstrap.registered,
|
|
106
105
|
skipped: bootstrap.skipped,
|
|
@@ -125,15 +124,15 @@ async function registerTasks({
|
|
|
125
124
|
local: localOptions,
|
|
126
125
|
includeRemote = true,
|
|
127
126
|
}: RegisterTasksOptions): Promise<RegisterTasksResult> {
|
|
128
|
-
logger.
|
|
127
|
+
logger.debug("開始註冊任務(本地 + 遠程)", { topic: LOG_TOPIC_TASK });
|
|
129
128
|
|
|
130
129
|
const local = await bootstrapLocalTasks(localOptions ?? {});
|
|
131
130
|
logLocalBootstrap(logger, local);
|
|
132
131
|
|
|
133
132
|
let remoteValues: string[] = [];
|
|
134
133
|
if (includeRemote) {
|
|
135
|
-
logger.
|
|
136
|
-
topic:
|
|
134
|
+
logger.debug("查詢遠程 Repo 列表", {
|
|
135
|
+
topic: LOG_TOPIC_TASK,
|
|
137
136
|
data: { usage: TASK_REPO_USAGE },
|
|
138
137
|
});
|
|
139
138
|
const { data, error: remoteError } = await getScanRemoteRepoValues({ usage: TASK_REPO_USAGE });
|
|
@@ -141,19 +140,19 @@ async function registerTasks({
|
|
|
141
140
|
throw new Error(remoteError.message);
|
|
142
141
|
}
|
|
143
142
|
remoteValues = data ?? [];
|
|
144
|
-
logger.
|
|
145
|
-
topic:
|
|
143
|
+
logger.debug("遠程 Repo 查詢完成", {
|
|
144
|
+
topic: LOG_TOPIC_TASK,
|
|
146
145
|
data: { count: remoteValues.length, values: remoteValues },
|
|
147
146
|
});
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
const availableTaskList = [...new Set([...local.registered, ...remoteValues])];
|
|
151
150
|
if (availableTaskList.length === 0) {
|
|
152
|
-
throw new Error("
|
|
151
|
+
throw new Error("任務註冊失敗:本地與遠程均無可用任務類型");
|
|
153
152
|
}
|
|
154
153
|
|
|
155
154
|
logger.success("任務註冊完成", {
|
|
156
|
-
topic:
|
|
155
|
+
topic: LOG_TOPIC_TASK,
|
|
157
156
|
data: {
|
|
158
157
|
availableTaskList,
|
|
159
158
|
localRegistered: local.registered,
|
|
@@ -196,13 +195,13 @@ const prepareTask = async ({
|
|
|
196
195
|
bootstrapLocalOptions,
|
|
197
196
|
}: PrepareTaskParams): Promise<PrepareTaskResponse> => {
|
|
198
197
|
const fail = (params: {
|
|
199
|
-
reason:
|
|
198
|
+
reason: TaskRepoValidationFailureReason;
|
|
200
199
|
code: ResultCode;
|
|
201
200
|
message: string;
|
|
202
201
|
step: string;
|
|
203
202
|
}): PrepareTaskResponse => {
|
|
204
203
|
logger.warn(params.message, {
|
|
205
|
-
topic:
|
|
204
|
+
topic: LOG_TOPIC_TASK,
|
|
206
205
|
data: {
|
|
207
206
|
taskId: task.id,
|
|
208
207
|
taskTypeKey: task.value,
|
|
@@ -221,8 +220,8 @@ const prepareTask = async ({
|
|
|
221
220
|
};
|
|
222
221
|
|
|
223
222
|
const { id: taskId, name: taskName, value: taskTypeKey, details } = task;
|
|
224
|
-
logger.
|
|
225
|
-
topic:
|
|
223
|
+
logger.debug(`開始準備任務 ${taskName}-${taskTypeKey}`, {
|
|
224
|
+
topic: LOG_TOPIC_TASK,
|
|
226
225
|
data: { taskId, taskName, taskTypeKey },
|
|
227
226
|
});
|
|
228
227
|
|
|
@@ -234,7 +233,7 @@ const prepareTask = async ({
|
|
|
234
233
|
forTaskTypeKey: taskTypeKey,
|
|
235
234
|
});
|
|
236
235
|
logger.debug("本地 registry 未命中,補掃本地任務", {
|
|
237
|
-
topic:
|
|
236
|
+
topic: LOG_TOPIC_TASK,
|
|
238
237
|
data: {
|
|
239
238
|
taskId,
|
|
240
239
|
taskTypeKey,
|
|
@@ -264,8 +263,8 @@ const prepareTask = async ({
|
|
|
264
263
|
|
|
265
264
|
const { repoContext } = validation;
|
|
266
265
|
|
|
267
|
-
logger.
|
|
268
|
-
topic:
|
|
266
|
+
logger.debug("Repo 上下文加載成功", {
|
|
267
|
+
topic: LOG_TOPIC_TASK,
|
|
269
268
|
data: {
|
|
270
269
|
taskTypeKey,
|
|
271
270
|
taskFnDisplayName: repoContext.taskFn.displayName,
|
|
@@ -274,8 +273,8 @@ const prepareTask = async ({
|
|
|
274
273
|
});
|
|
275
274
|
|
|
276
275
|
const boundTaskFn = bindTaskFn(repoContext.taskFn, taskParams);
|
|
277
|
-
logger.
|
|
278
|
-
topic:
|
|
276
|
+
logger.debug("任務準備完成", {
|
|
277
|
+
topic: LOG_TOPIC_TASK,
|
|
279
278
|
data: {
|
|
280
279
|
taskId,
|
|
281
280
|
taskTypeKey,
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type LoggerWithScope,
|
|
5
|
-
} from "../shared/log";
|
|
6
|
-
import { scopeForNodeLoop } from "./node-log-scope";
|
|
1
|
+
import { isOptimisticLockResponse } from "../core.api";
|
|
2
|
+
import { BaseNodeRuntime, LOG_TOPIC_NODE, type NodeLoopContext } from "../node/node-runtime.base";
|
|
3
|
+
import { createLogger, createScope, type LoggerWithScope, withModule } from "../shared/log";
|
|
7
4
|
import { getErrorMessage, toError } from "../shared/utils/error.utils";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { TaskStatusAction } from "
|
|
11
|
-
import {
|
|
12
|
-
import { BaseNodeRuntime } from "./node-runtime.base";
|
|
5
|
+
import { patchChangeTaskStatus, patchClaimTask } from "./task.api";
|
|
6
|
+
import { CRITICAL_UNKNOWN_TASK_TRACE_ID, LOG_TOPIC_TASK } from "./task.constant";
|
|
7
|
+
import { TaskStatusAction } from "./task.interface";
|
|
8
|
+
import { TaskManager, type TaskRunResult } from "./task-manager";
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
11
|
* Task worker node: commands → heartbeat → claim & execute tasks.
|
|
@@ -28,39 +24,39 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
protected async onBeforeRegisterNode(logger: LoggerWithScope): Promise<void> {
|
|
31
|
-
logger.info("開始註冊任務", { topic: "node" });
|
|
32
27
|
const { availableTaskList, includeRemote } = await TaskManager.registerTasks({ logger });
|
|
33
28
|
this._availableTaskList = availableTaskList;
|
|
34
29
|
this._includeRemote = includeRemote;
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
protected async runLoopSteps(ctx: NodeLoopContext, heartbeatOk: boolean): Promise<void> {
|
|
38
|
-
const loopScope = scopeForNodeLoop({
|
|
39
|
-
module: `${this.runtimeModule}-loop-iteration`,
|
|
40
|
-
traceId: ctx.loopTraceId,
|
|
41
|
-
nodeId: ctx.nodeId,
|
|
42
|
-
});
|
|
43
33
|
if (!heartbeatOk) {
|
|
44
|
-
const
|
|
45
|
-
|
|
34
|
+
const logger = createLogger({
|
|
35
|
+
scope: createScope({
|
|
36
|
+
module: `${this.runtimeModule}-runLoopSteps`,
|
|
37
|
+
traceId: ctx.loopTraceId,
|
|
38
|
+
labels: { nodeId: ctx.nodeId },
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
logger.warn("心跳失敗,本輪跳過任務認領", { topic: LOG_TOPIC_NODE });
|
|
46
42
|
return;
|
|
47
43
|
}
|
|
48
44
|
await this.runAsWorker(ctx);
|
|
49
45
|
}
|
|
50
46
|
|
|
51
|
-
async runAsWorker(ctx: NodeLoopContext) {
|
|
47
|
+
private async runAsWorker(ctx: NodeLoopContext): Promise<void> {
|
|
52
48
|
const { loopTraceId, nodeId } = ctx;
|
|
53
|
-
const loopScope =
|
|
54
|
-
const
|
|
49
|
+
const loopScope = createScope({ module: "runAsWorker", traceId: loopTraceId, labels: { nodeId } });
|
|
50
|
+
const logger = createLogger({ scope: loopScope });
|
|
55
51
|
|
|
56
52
|
const availableTaskList = this.availableTaskList;
|
|
57
53
|
if (availableTaskList.length === 0) {
|
|
58
|
-
logger.warn("未配置可認領任務類型,跳過本輪", { topic:
|
|
54
|
+
logger.warn("未配置可認領任務類型,跳過本輪", { topic: LOG_TOPIC_TASK });
|
|
59
55
|
return;
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
logger.
|
|
63
|
-
topic:
|
|
58
|
+
logger.debug("向 Supabase 認領任務", {
|
|
59
|
+
topic: LOG_TOPIC_TASK,
|
|
64
60
|
data: { availableTaskList },
|
|
65
61
|
});
|
|
66
62
|
const { data: task, error: claimError } = await patchClaimTask({
|
|
@@ -69,25 +65,41 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
69
65
|
traceId: loopTraceId,
|
|
70
66
|
});
|
|
71
67
|
if (claimError) {
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
if (isOptimisticLockResponse(claimError)) {
|
|
69
|
+
logger.debug("認領競爭失敗,本輪無可認領任務", {
|
|
70
|
+
topic: LOG_TOPIC_TASK,
|
|
71
|
+
data: { availableTaskList },
|
|
72
|
+
});
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
logger.error("認領任務失敗", {
|
|
76
|
+
topic: LOG_TOPIC_TASK,
|
|
74
77
|
data: {
|
|
75
78
|
availableTaskList,
|
|
76
79
|
error: claimError.message,
|
|
80
|
+
code: claimError.code,
|
|
77
81
|
},
|
|
78
82
|
});
|
|
79
83
|
return;
|
|
80
84
|
}
|
|
81
85
|
if (task == null) {
|
|
82
|
-
logger.
|
|
83
|
-
topic:
|
|
86
|
+
logger.debug("本輪無匹配的 TODO 任務", {
|
|
87
|
+
topic: LOG_TOPIC_TASK,
|
|
84
88
|
data: { availableTaskList },
|
|
85
89
|
});
|
|
86
90
|
return;
|
|
87
91
|
}
|
|
88
92
|
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
const taskTraceId = task.details.traceId ?? CRITICAL_UNKNOWN_TASK_TRACE_ID;
|
|
94
|
+
const taskScope = createScope({
|
|
95
|
+
module: "runAsWorker",
|
|
96
|
+
traceId: loopTraceId,
|
|
97
|
+
labels: { nodeId },
|
|
98
|
+
traceParentId: taskTraceId,
|
|
99
|
+
});
|
|
100
|
+
const taskLogger = createLogger({ scope: taskScope });
|
|
101
|
+
taskLogger.success("認領任務成功,準備執行", {
|
|
102
|
+
topic: LOG_TOPIC_TASK,
|
|
91
103
|
data: {
|
|
92
104
|
taskId: task.id,
|
|
93
105
|
taskName: task.name,
|
|
@@ -96,14 +108,7 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
96
108
|
},
|
|
97
109
|
});
|
|
98
110
|
|
|
99
|
-
const
|
|
100
|
-
const taskScope = scopeForNodeLoop({
|
|
101
|
-
module: "prepareTask",
|
|
102
|
-
traceId: taskTraceId,
|
|
103
|
-
nodeId,
|
|
104
|
-
traceParentId: loopTraceId,
|
|
105
|
-
});
|
|
106
|
-
const { logger: prepareLogger } = logManager.withScope(taskScope);
|
|
111
|
+
const prepareLogger = createLogger({ scope: withModule(taskScope, "prepareTask") });
|
|
107
112
|
const prepareResult = await TaskManager.prepareTask({
|
|
108
113
|
logger: prepareLogger,
|
|
109
114
|
task,
|
|
@@ -112,7 +117,7 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
112
117
|
const { isSuccess: isPrepareSuccess, taskFn, code, message, reason, step } = prepareResult;
|
|
113
118
|
if (!isPrepareSuccess || taskFn == null) {
|
|
114
119
|
prepareLogger.critical("任務準備失敗,無法繼續執行,中止任務並 RESET 為 OPEN", {
|
|
115
|
-
topic:
|
|
120
|
+
topic: LOG_TOPIC_TASK,
|
|
116
121
|
data: {
|
|
117
122
|
taskId: task.id,
|
|
118
123
|
taskTypeKey: task.value,
|
|
@@ -130,15 +135,25 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
130
135
|
});
|
|
131
136
|
return;
|
|
132
137
|
}
|
|
138
|
+
logger.success("任務準備完成", {
|
|
139
|
+
topic: LOG_TOPIC_TASK,
|
|
140
|
+
data: {
|
|
141
|
+
taskId: task.id,
|
|
142
|
+
taskName: task.name,
|
|
143
|
+
taskTypeKey: task.value,
|
|
144
|
+
displayName: taskFn.displayName,
|
|
145
|
+
},
|
|
146
|
+
});
|
|
133
147
|
|
|
134
|
-
const
|
|
148
|
+
const executeLogger = createLogger({ scope: withModule(taskScope, "executeTask") });
|
|
135
149
|
const onExecuteAbort = async (error?: Error) => {
|
|
136
|
-
|
|
137
|
-
topic:
|
|
150
|
+
executeLogger.critical("任務執行遇到未知錯誤,中止任務並 RESET 為 OPEN", {
|
|
151
|
+
topic: LOG_TOPIC_TASK,
|
|
138
152
|
data: {
|
|
139
153
|
taskId: task.id,
|
|
140
|
-
taskName: task.name,
|
|
141
154
|
taskTypeKey: task.value,
|
|
155
|
+
taskName: task.name,
|
|
156
|
+
displayName: taskFn.displayName,
|
|
142
157
|
error: getErrorMessage(error),
|
|
143
158
|
},
|
|
144
159
|
});
|
|
@@ -151,7 +166,7 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
151
166
|
};
|
|
152
167
|
|
|
153
168
|
executeLogger.info("開始執行業務邏輯", {
|
|
154
|
-
topic:
|
|
169
|
+
topic: LOG_TOPIC_TASK,
|
|
155
170
|
data: { taskId: task.id, displayName: taskFn.displayName },
|
|
156
171
|
});
|
|
157
172
|
const startTime = Date.now();
|
|
@@ -167,10 +182,6 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
167
182
|
return;
|
|
168
183
|
}
|
|
169
184
|
|
|
170
|
-
executeLogger.info("任務執行完成", {
|
|
171
|
-
topic: "task",
|
|
172
|
-
data: { taskId: task.id, displayName: taskFn.displayName },
|
|
173
|
-
});
|
|
174
185
|
const { isSuccess: isTaskSuccess, cost, extra } = result ?? { isSuccess: false, cost: 0, extra: null };
|
|
175
186
|
if (isTaskSuccess) {
|
|
176
187
|
await this.finalizeTaskRun("success", {
|
|
@@ -194,9 +205,15 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
194
205
|
});
|
|
195
206
|
}
|
|
196
207
|
const duration = Date.now() - startTime;
|
|
197
|
-
executeLogger.info("
|
|
198
|
-
topic:
|
|
199
|
-
data: {
|
|
208
|
+
executeLogger.info("業務邏輯執行結束", {
|
|
209
|
+
topic: LOG_TOPIC_TASK,
|
|
210
|
+
data: {
|
|
211
|
+
taskId: task.id,
|
|
212
|
+
taskName: task.name,
|
|
213
|
+
taskTypeKey: task.value,
|
|
214
|
+
displayName: taskFn.displayName,
|
|
215
|
+
durationMs: duration,
|
|
216
|
+
},
|
|
200
217
|
});
|
|
201
218
|
}
|
|
202
219
|
|
|
@@ -220,10 +237,10 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
220
237
|
});
|
|
221
238
|
|
|
222
239
|
if (error) {
|
|
223
|
-
logger.error(error.message, { topic:
|
|
240
|
+
logger.error(error.message, { topic: LOG_TOPIC_TASK, data: logData });
|
|
224
241
|
return false;
|
|
225
242
|
}
|
|
226
|
-
logger.info("任務已中止並 RESET 為 OPEN", { topic:
|
|
243
|
+
logger.info("任務已中止並 RESET 為 OPEN", { topic: LOG_TOPIC_TASK, data: logData });
|
|
227
244
|
return true;
|
|
228
245
|
}
|
|
229
246
|
|
|
@@ -235,9 +252,9 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
235
252
|
taskTypeKey: string;
|
|
236
253
|
nodeId: string;
|
|
237
254
|
cost: TaskRunResult["cost"];
|
|
238
|
-
extra: TaskRunResult["
|
|
255
|
+
extra: TaskRunResult["extra"];
|
|
239
256
|
traceId: string;
|
|
240
|
-
}
|
|
257
|
+
},
|
|
241
258
|
): Promise<void> {
|
|
242
259
|
const { logger, taskId, nodeId, taskTypeKey, cost, extra, traceId } = params;
|
|
243
260
|
const outcomePrefix = outcome === "success" ? "任務成功" : "任務失敗";
|
|
@@ -252,31 +269,32 @@ class TaskNode extends BaseNodeRuntime {
|
|
|
252
269
|
const { error: changeTaskStatusError } =
|
|
253
270
|
outcome === "success"
|
|
254
271
|
? await patchChangeTaskStatus({
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
272
|
+
id: taskId,
|
|
273
|
+
action: TaskStatusAction.FINISH,
|
|
274
|
+
nodeId,
|
|
275
|
+
cost,
|
|
276
|
+
extra: extraValue,
|
|
277
|
+
traceId,
|
|
278
|
+
})
|
|
262
279
|
: await patchChangeTaskStatus({
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
280
|
+
id: taskId,
|
|
281
|
+
action: TaskStatusAction.RESET,
|
|
282
|
+
nodeId,
|
|
283
|
+
extra: extraValue,
|
|
284
|
+
traceId,
|
|
285
|
+
});
|
|
269
286
|
|
|
270
287
|
if (changeTaskStatusError) {
|
|
271
288
|
const upperMessage = `${outcomePrefix}但是更新 TaskStatus 失敗,產生孤兒 Task,請儘快排查問題`;
|
|
272
|
-
logger.critical(upperMessage, { topic:
|
|
289
|
+
logger.critical(upperMessage, { topic: LOG_TOPIC_TASK, data: logData });
|
|
290
|
+
// TODO: 需要處理孤兒 Task
|
|
273
291
|
throw new Error(upperMessage);
|
|
274
292
|
}
|
|
275
|
-
logger.info("更新 TaskStatus 成功", { topic:
|
|
293
|
+
logger.info("更新 TaskStatus 成功", { topic: LOG_TOPIC_TASK, data: logData });
|
|
276
294
|
if (outcome === "success") {
|
|
277
|
-
logger.success("任務執行結束,業務邏輯成功", { topic:
|
|
295
|
+
logger.success("任務執行結束,業務邏輯成功", { topic: LOG_TOPIC_TASK, data: logData });
|
|
278
296
|
} else {
|
|
279
|
-
logger.warn("任務執行結束,業務邏輯失敗", { topic:
|
|
297
|
+
logger.warn("任務執行結束,業務邏輯失敗", { topic: LOG_TOPIC_TASK, data: logData });
|
|
280
298
|
}
|
|
281
299
|
}
|
|
282
300
|
}
|