target-supabase-sdk 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +184 -1
- package/dist/browser.d.ts +60 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +6 -0
- package/dist/browser.js.map +1 -0
- package/dist/chunks/create-logger-DyH3mZ8p.js +1028 -0
- package/dist/chunks/create-logger-DyH3mZ8p.js.map +1 -0
- package/dist/chunks/enable-log-persist-C_bSw6Kx.js +1362 -0
- package/dist/chunks/enable-log-persist-C_bSw6Kx.js.map +1 -0
- package/dist/chunks/word.interface-DLgRobKV.js +1973 -0
- package/dist/chunks/word.interface-DLgRobKV.js.map +1 -0
- package/dist/command/command.api.d.ts +1 -1
- package/dist/command/command.api.d.ts.map +1 -1
- package/dist/command/command.interface.d.ts +1 -1
- package/dist/command/command.interface.d.ts.map +1 -1
- package/dist/core.api.d.ts +10 -6
- package/dist/core.api.d.ts.map +1 -1
- package/dist/core.interface.d.ts +3 -2
- package/dist/core.interface.d.ts.map +1 -1
- package/dist/core.utils.d.ts +1 -1
- package/dist/core.utils.d.ts.map +1 -1
- package/dist/idea/idea.interface.d.ts +1 -1
- package/dist/idea/idea.interface.d.ts.map +1 -1
- package/dist/index.d.ts +2 -48
- package/dist/index.d.ts.map +1 -1
- package/dist/link/link.api.d.ts +1 -1
- package/dist/link/link.api.d.ts.map +1 -1
- package/dist/link/link.interface.d.ts +3 -3
- package/dist/link/link.interface.d.ts.map +1 -1
- package/dist/list/list.api.d.ts +3 -1
- package/dist/list/list.api.d.ts.map +1 -1
- package/dist/list/list.interface.d.ts +2 -2
- package/dist/list/list.interface.d.ts.map +1 -1
- package/dist/node/env/env-parsers.d.ts +19 -0
- package/dist/node/env/env-parsers.d.ts.map +1 -0
- package/dist/node/env/index.d.ts +11 -0
- package/dist/node/env/index.d.ts.map +1 -0
- package/dist/node/env/init-supabase-from-env.d.ts +17 -0
- package/dist/node/env/init-supabase-from-env.d.ts.map +1 -0
- package/dist/node/env/load-env.d.ts +20 -0
- package/dist/node/env/load-env.d.ts.map +1 -0
- package/dist/node/env/project-root.d.ts +11 -0
- package/dist/node/env/project-root.d.ts.map +1 -0
- package/dist/node/env/public-base-url.d.ts +10 -0
- package/dist/node/env/public-base-url.d.ts.map +1 -0
- package/dist/node/env/require-env.d.ts +3 -0
- package/dist/node/env/require-env.d.ts.map +1 -0
- package/dist/node/fs/json-state-store.d.ts +19 -0
- package/dist/node/fs/json-state-store.d.ts.map +1 -0
- package/dist/node/fs/read-source-file.d.ts +19 -0
- package/dist/node/fs/read-source-file.d.ts.map +1 -0
- package/dist/node/node-liveness.d.ts +30 -0
- package/dist/node/node-liveness.d.ts.map +1 -0
- package/dist/node/node-runtime.base.d.ts +60 -0
- package/dist/node/node-runtime.base.d.ts.map +1 -0
- package/dist/node/node.api.d.ts +4 -4
- package/dist/node/node.api.d.ts.map +1 -1
- package/dist/node/node.interface.d.ts +1 -6
- package/dist/node/node.interface.d.ts.map +1 -1
- package/dist/node/preload/run-service-preload.d.ts +14 -0
- package/dist/node/preload/run-service-preload.d.ts.map +1 -0
- package/dist/node/preload/service-preload.interface.d.ts +15 -0
- package/dist/node/preload/service-preload.interface.d.ts.map +1 -0
- package/dist/node/process/index.d.ts +5 -0
- package/dist/node/process/index.d.ts.map +1 -0
- package/dist/node/process/managed-child-processes.d.ts +37 -0
- package/dist/node/process/managed-child-processes.d.ts.map +1 -0
- package/dist/node/process/process-spawn.d.ts +27 -0
- package/dist/node/process/process-spawn.d.ts.map +1 -0
- package/dist/node/readiness/index.d.ts +9 -0
- package/dist/node/readiness/index.d.ts.map +1 -0
- package/dist/node/readiness/poll-until.d.ts +11 -0
- package/dist/node/readiness/poll-until.d.ts.map +1 -0
- package/dist/node/readiness/readiness-checks.d.ts +22 -0
- package/dist/node/readiness/readiness-checks.d.ts.map +1 -0
- package/dist/node/readiness/readiness.types.d.ts +12 -0
- package/dist/node/readiness/readiness.types.d.ts.map +1 -0
- package/dist/node/readiness/run-readiness-checks.d.ts +4 -0
- package/dist/node/readiness/run-readiness-checks.d.ts.map +1 -0
- package/dist/node/readiness/service-ready-gate.d.ts +26 -0
- package/dist/node/readiness/service-ready-gate.d.ts.map +1 -0
- package/dist/node.d.ts +36 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +2483 -0
- package/dist/node.js.map +1 -0
- package/dist/parcel/chunk-fetch-registry.d.ts +14 -0
- package/dist/parcel/chunk-fetch-registry.d.ts.map +1 -0
- package/dist/parcel/chunk-url.utils.d.ts +9 -0
- package/dist/parcel/chunk-url.utils.d.ts.map +1 -0
- package/dist/parcel/parcel-manager.d.ts +44 -20
- package/dist/parcel/parcel-manager.d.ts.map +1 -1
- package/dist/parcel/parcel.api.d.ts +306 -0
- package/dist/parcel/parcel.api.d.ts.map +1 -0
- package/dist/parcel/parcel.interface.d.ts +26 -5
- package/dist/parcel/parcel.interface.d.ts.map +1 -1
- package/dist/parcel/parcel.service.d.ts +38 -0
- package/dist/parcel/parcel.service.d.ts.map +1 -0
- package/dist/parcel/storage-provider-registry.d.ts +17 -0
- package/dist/parcel/storage-provider-registry.d.ts.map +1 -0
- package/dist/parcel/storage-provider.types.d.ts +31 -0
- package/dist/parcel/storage-provider.types.d.ts.map +1 -0
- package/dist/preload.d.ts +7 -0
- package/dist/preload.d.ts.map +1 -0
- package/dist/preload.js +47 -0
- package/dist/preload.js.map +1 -0
- package/dist/repo/repo-context.utils.d.ts.map +1 -1
- package/dist/repo/repo-manager.d.ts +14 -3
- package/dist/repo/repo-manager.d.ts.map +1 -1
- package/dist/repo/repo.api.d.ts +1 -1
- package/dist/repo/repo.api.d.ts.map +1 -1
- package/dist/repo/repo.interface.d.ts +1 -1
- package/dist/repo/repo.interface.d.ts.map +1 -1
- package/dist/repo/repo.script-loader.d.ts +5 -5
- package/dist/repo/repo.script-loader.d.ts.map +1 -1
- package/dist/service/base.interface.d.ts +54 -57
- package/dist/service/base.interface.d.ts.map +1 -1
- package/dist/service/index.d.ts +21 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/service.api.d.ts +503 -0
- package/dist/service/service.api.d.ts.map +1 -0
- package/dist/service/service.interface.d.ts +36 -9
- package/dist/service/service.interface.d.ts.map +1 -1
- package/dist/shared/http/fetch-retry.d.ts +21 -0
- package/dist/shared/http/fetch-retry.d.ts.map +1 -0
- package/dist/shared/log/create-logger.d.ts +27 -0
- package/dist/shared/log/create-logger.d.ts.map +1 -0
- package/dist/shared/log/enable-log-persist.d.ts +28 -0
- package/dist/shared/log/enable-log-persist.d.ts.map +1 -0
- package/dist/shared/log/index.d.ts +10 -0
- package/dist/shared/log/index.d.ts.map +1 -0
- package/dist/shared/log/log-manager.d.ts +37 -60
- package/dist/shared/log/log-manager.d.ts.map +1 -1
- package/dist/shared/log/log-persist-batch-id.d.ts +13 -0
- package/dist/shared/log/log-persist-batch-id.d.ts.map +1 -0
- package/dist/shared/log/log-persist-flush.d.ts +8 -0
- package/dist/shared/log/log-persist-flush.d.ts.map +1 -0
- package/dist/shared/log/log-persist-hook.d.ts +6 -0
- package/dist/shared/log/log-persist-hook.d.ts.map +1 -0
- package/dist/shared/log/log-persist-logger.d.ts +15 -0
- package/dist/shared/log/log-persist-logger.d.ts.map +1 -0
- package/dist/shared/log/log-persist-registry.d.ts +17 -0
- package/dist/shared/log/log-persist-registry.d.ts.map +1 -0
- package/dist/shared/log/log-persist.config.d.ts +10 -0
- package/dist/shared/log/log-persist.config.d.ts.map +1 -0
- package/dist/shared/log/log-persist.d.ts +55 -0
- package/dist/shared/log/log-persist.d.ts.map +1 -0
- package/dist/shared/log/log-persist.interface.d.ts +116 -0
- package/dist/shared/log/log-persist.interface.d.ts.map +1 -0
- package/dist/shared/log/log-scope.d.ts +56 -0
- package/dist/shared/log/log-scope.d.ts.map +1 -0
- package/dist/shared/utils/fetch-url.d.ts +3 -0
- package/dist/shared/utils/fetch-url.d.ts.map +1 -0
- package/dist/shared/utils/network-error.d.ts +14 -0
- package/dist/shared/utils/network-error.d.ts.map +1 -0
- package/dist/shared/utils/safe-file-name.d.ts +14 -0
- package/dist/shared/utils/safe-file-name.d.ts.map +1 -0
- package/dist/shared/utils/sha256.d.ts +3 -0
- package/dist/shared/utils/sha256.d.ts.map +1 -0
- package/dist/supabase.d.ts +7 -2
- package/dist/supabase.d.ts.map +1 -1
- package/dist/task/index.d.ts +16 -0
- package/dist/task/index.d.ts.map +1 -0
- package/dist/task/local-task-registry.d.ts +11 -1
- package/dist/task/local-task-registry.d.ts.map +1 -1
- package/dist/task/task-manager.d.ts +21 -11
- package/dist/task/task-manager.d.ts.map +1 -1
- package/dist/task/task-node.d.ts +19 -0
- package/dist/task/task-node.d.ts.map +1 -0
- package/dist/task/task-post-validated.api.d.ts +19 -0
- package/dist/task/task-post-validated.api.d.ts.map +1 -0
- package/dist/task/task-post.api.d.ts +54 -0
- package/dist/task/task-post.api.d.ts.map +1 -0
- package/dist/task/task-queue.d.ts +7 -0
- package/dist/task/task-queue.d.ts.map +1 -0
- package/dist/task/task-repo-context.d.ts +2 -0
- package/dist/task/task-repo-context.d.ts.map +1 -1
- package/dist/task/task-repo-validation.d.ts +46 -0
- package/dist/task/task-repo-validation.d.ts.map +1 -0
- package/dist/task/task.api.d.ts +5 -47
- package/dist/task/task.api.d.ts.map +1 -1
- package/dist/task/task.constant.d.ts +4 -0
- package/dist/task/task.constant.d.ts.map +1 -0
- package/dist/task/task.interface.d.ts +3 -1
- package/dist/task/task.interface.d.ts.map +1 -1
- package/dist/trigger/trigger-manager.d.ts +25 -0
- package/dist/trigger/trigger-manager.d.ts.map +1 -0
- package/dist/trigger/trigger-node.d.ts +23 -0
- package/dist/trigger/trigger-node.d.ts.map +1 -0
- package/dist/trigger/trigger.api.d.ts +140 -0
- package/dist/trigger/trigger.api.d.ts.map +1 -0
- package/dist/trigger/trigger.constant.d.ts +8 -0
- package/dist/trigger/trigger.constant.d.ts.map +1 -0
- package/dist/trigger/trigger.interface.d.ts +87 -0
- package/dist/trigger/trigger.interface.d.ts.map +1 -0
- package/dist/trigger/trigger.utils.d.ts +6 -0
- package/dist/trigger/trigger.utils.d.ts.map +1 -0
- package/dist/word/word.api.d.ts +1 -1
- package/dist/word/word.api.d.ts.map +1 -1
- package/dist/word/word.interface.d.ts +2 -2
- package/dist/word/word.interface.d.ts.map +1 -1
- package/package.json +91 -61
- package/src/browser.ts +165 -0
- package/src/command/command.api.ts +20 -18
- package/src/command/command.interface.ts +2 -3
- package/src/core.api.ts +466 -477
- package/src/core.interface.ts +63 -62
- package/src/core.utils.ts +64 -64
- package/src/idea/idea.interface.ts +3 -3
- package/src/index.ts +2 -79
- package/src/link/link.api.ts +28 -30
- package/src/link/link.interface.ts +4 -5
- package/src/list/list.api.ts +50 -29
- package/src/list/list.interface.ts +3 -4
- package/src/node/env/env-parsers.ts +77 -0
- package/src/node/env/index.ts +10 -0
- package/src/node/env/init-supabase-from-env.ts +38 -0
- package/src/node/env/load-env.ts +67 -0
- package/src/node/env/project-root.ts +34 -0
- package/src/node/env/public-base-url.ts +18 -0
- package/src/node/env/require-env.ts +15 -0
- package/src/node/fs/json-state-store.ts +97 -0
- package/src/node/fs/read-source-file.ts +75 -0
- package/src/node/node-liveness.ts +80 -0
- package/src/node/node-runtime.base.ts +481 -0
- package/src/node/node.api.ts +12 -11
- package/src/node/node.interface.ts +1 -8
- package/src/node/node.utils.ts +1 -1
- package/src/node/preload/run-service-preload.ts +48 -0
- package/src/node/preload/service-preload.interface.ts +14 -0
- package/src/node/process/index.ts +8 -0
- package/src/node/process/managed-child-processes.ts +121 -0
- package/src/node/process/process-spawn.ts +61 -0
- package/src/node/readiness/index.ts +20 -0
- package/src/node/readiness/poll-until.ts +27 -0
- package/src/node/readiness/readiness-checks.ts +79 -0
- package/src/node/readiness/readiness.types.ts +13 -0
- package/src/node/readiness/run-readiness-checks.ts +20 -0
- package/src/node/readiness/service-ready-gate.ts +65 -0
- package/src/node.ts +153 -0
- package/src/parcel/chunk-fetch-registry.ts +96 -0
- package/src/parcel/chunk-url.utils.ts +30 -0
- package/src/parcel/parcel-manager.ts +431 -173
- package/src/parcel/parcel.api.ts +103 -0
- package/src/parcel/parcel.interface.ts +44 -23
- package/src/parcel/parcel.service.ts +79 -0
- package/src/parcel/storage-provider-registry.ts +49 -0
- package/src/parcel/storage-provider.types.ts +45 -0
- package/src/preload.ts +7 -0
- package/src/repo/repo-context.utils.ts +3 -4
- package/src/repo/repo-manager.ts +54 -39
- package/src/repo/repo.api.ts +5 -5
- package/src/repo/repo.interface.ts +1 -2
- package/src/repo/repo.script-loader.ts +16 -20
- package/src/service/base.interface.ts +81 -90
- package/src/service/index.ts +173 -0
- package/src/service/service.api.ts +294 -0
- package/src/service/service.interface.ts +49 -17
- package/src/shared/http/fetch-retry.ts +145 -0
- package/src/shared/log/create-logger.ts +51 -0
- package/src/shared/log/enable-log-persist.ts +225 -0
- package/src/shared/log/index.ts +31 -0
- package/src/shared/log/log-manager.ts +112 -121
- package/src/shared/log/log-persist-batch-id.ts +43 -0
- package/src/shared/log/log-persist-flush.ts +128 -0
- package/src/shared/log/log-persist-hook.ts +13 -0
- package/src/shared/log/log-persist-logger.ts +33 -0
- package/src/shared/log/log-persist-registry.ts +109 -0
- package/src/shared/log/log-persist.config.ts +97 -0
- package/src/shared/log/log-persist.interface.ts +132 -0
- package/src/shared/log/log-persist.ts +704 -0
- package/src/shared/log/log-scope.ts +123 -0
- package/src/shared/utils/config-path.utils.ts +1 -1
- package/src/shared/utils/fetch-url.ts +13 -0
- package/src/shared/utils/network-error.ts +152 -0
- package/src/shared/utils/safe-file-name.ts +37 -0
- package/src/shared/utils/sha256.ts +15 -0
- package/src/supabase.ts +125 -119
- package/src/task/index.ts +45 -0
- package/src/task/local-task-registry.ts +115 -36
- package/src/task/task-manager.ts +101 -113
- package/src/task/task-node.ts +302 -0
- package/src/task/task-post-validated.api.ts +47 -0
- package/src/task/task-post.api.ts +99 -0
- package/src/task/task-queue.ts +18 -0
- package/src/task/task-repo-context.ts +4 -1
- package/src/task/task-repo-validation.ts +169 -0
- package/src/task/task.api.ts +68 -92
- package/src/task/task.constant.ts +4 -0
- package/src/task/task.interface.ts +6 -7
- package/src/trigger/trigger-manager.ts +287 -0
- package/src/trigger/trigger-node.ts +80 -0
- package/src/trigger/trigger.api.ts +166 -0
- package/src/trigger/trigger.constant.ts +10 -0
- package/src/trigger/trigger.interface.ts +100 -0
- package/src/trigger/trigger.utils.ts +56 -0
- package/src/word/word.api.ts +28 -30
- package/src/word/word.interface.ts +3 -4
- package/dist/auth/auth.api.d.ts +0 -28
- package/dist/auth/auth.api.d.ts.map +0 -1
- package/dist/auth/auth.api.js +0 -51
- package/dist/auth/auth.api.js.map +0 -1
- package/dist/command/command.api.js +0 -58
- package/dist/command/command.api.js.map +0 -1
- package/dist/command/command.interface.js +0 -9
- package/dist/command/command.interface.js.map +0 -1
- package/dist/core.api.js +0 -412
- package/dist/core.api.js.map +0 -1
- package/dist/core.interface.js +0 -46
- package/dist/core.interface.js.map +0 -1
- package/dist/core.utils.js +0 -81
- package/dist/core.utils.js.map +0 -1
- package/dist/feed/feed.interface.d.ts +0 -27
- package/dist/feed/feed.interface.d.ts.map +0 -1
- package/dist/feed/feed.interface.js +0 -17
- package/dist/feed/feed.interface.js.map +0 -1
- package/dist/file/file-manager.d.ts +0 -24
- package/dist/file/file-manager.d.ts.map +0 -1
- package/dist/file/file-manager.js +0 -109
- package/dist/file/file-manager.js.map +0 -1
- package/dist/file/file.api.d.ts +0 -15
- package/dist/file/file.api.d.ts.map +0 -1
- package/dist/file/file.api.js +0 -30
- package/dist/file/file.api.js.map +0 -1
- package/dist/file/file.interface.d.ts +0 -25
- package/dist/file/file.interface.d.ts.map +0 -1
- package/dist/file/file.interface.js +0 -9
- package/dist/file/file.interface.js.map +0 -1
- package/dist/file-list/file-list.api.d.ts +0 -15
- package/dist/file-list/file-list.api.d.ts.map +0 -1
- package/dist/file-list/file-list.api.js +0 -54
- package/dist/file-list/file-list.api.js.map +0 -1
- package/dist/file-list/file-list.interface.d.ts +0 -22
- package/dist/file-list/file-list.interface.d.ts.map +0 -1
- package/dist/file-list/file-list.interface.js +0 -5
- package/dist/file-list/file-list.interface.js.map +0 -1
- package/dist/idea/idea.interface.js +0 -15
- package/dist/idea/idea.interface.js.map +0 -1
- package/dist/index.js +0 -42
- package/dist/index.js.map +0 -1
- package/dist/link/link.api.js +0 -30
- package/dist/link/link.api.js.map +0 -1
- package/dist/link/link.interface.js +0 -7
- package/dist/link/link.interface.js.map +0 -1
- package/dist/list/list.api.js +0 -30
- package/dist/list/list.api.js.map +0 -1
- package/dist/list/list.interface.js +0 -6
- package/dist/list/list.interface.js.map +0 -1
- package/dist/node/node-manager.d.ts +0 -48
- package/dist/node/node-manager.d.ts.map +0 -1
- package/dist/node/node-manager.js +0 -619
- package/dist/node/node-manager.js.map +0 -1
- package/dist/node/node-task.preset.d.ts +0 -1
- package/dist/node/node-task.preset.d.ts.map +0 -1
- package/dist/node/node-task.preset.js +0 -14
- package/dist/node/node-task.preset.js.map +0 -1
- package/dist/node/node.api.js +0 -100
- package/dist/node/node.api.js.map +0 -1
- package/dist/node/node.interface.js +0 -19
- package/dist/node/node.interface.js.map +0 -1
- package/dist/node/node.utils.js +0 -36
- package/dist/node/node.utils.js.map +0 -1
- package/dist/parcel/parcel-manager.js +0 -156
- package/dist/parcel/parcel-manager.js.map +0 -1
- package/dist/parcel/parcel.interface.js +0 -11
- package/dist/parcel/parcel.interface.js.map +0 -1
- package/dist/question-list/question-list.api.d.ts +0 -13
- package/dist/question-list/question-list.api.d.ts.map +0 -1
- package/dist/question-list/question-list.api.js +0 -35
- package/dist/question-list/question-list.api.js.map +0 -1
- package/dist/question-list/question-list.interface.d.ts +0 -18
- package/dist/question-list/question-list.interface.d.ts.map +0 -1
- package/dist/question-list/question-list.interface.js +0 -5
- package/dist/question-list/question-list.interface.js.map +0 -1
- package/dist/repo/repo-context.utils.js +0 -81
- package/dist/repo/repo-context.utils.js.map +0 -1
- package/dist/repo/repo-manager.js +0 -156
- package/dist/repo/repo-manager.js.map +0 -1
- package/dist/repo/repo.api.js +0 -40
- package/dist/repo/repo.api.js.map +0 -1
- package/dist/repo/repo.interface.js +0 -8
- package/dist/repo/repo.interface.js.map +0 -1
- package/dist/repo/repo.script-loader.js +0 -108
- package/dist/repo/repo.script-loader.js.map +0 -1
- package/dist/review/review.api.d.ts +0 -14
- package/dist/review/review.api.d.ts.map +0 -1
- package/dist/review/review.api.js +0 -133
- package/dist/review/review.api.js.map +0 -1
- package/dist/review/review.interface.d.ts +0 -24
- package/dist/review/review.interface.d.ts.map +0 -1
- package/dist/review/review.interface.js +0 -10
- package/dist/review/review.interface.js.map +0 -1
- package/dist/review-v2/apis/post-review-setting.api.d.ts +0 -12
- package/dist/review-v2/apis/post-review-setting.api.d.ts.map +0 -1
- package/dist/review-v2/apis/post-review-setting.api.js +0 -27
- package/dist/review-v2/apis/post-review-setting.api.js.map +0 -1
- package/dist/review-v2/apis/post-review.api.d.ts +0 -13
- package/dist/review-v2/apis/post-review.api.d.ts.map +0 -1
- package/dist/review-v2/apis/post-review.api.js +0 -46
- package/dist/review-v2/apis/post-review.api.js.map +0 -1
- package/dist/review-v2/review-setting.interface.d.ts +0 -23
- package/dist/review-v2/review-setting.interface.d.ts.map +0 -1
- package/dist/review-v2/review-setting.interface.js +0 -5
- package/dist/review-v2/review-setting.interface.js.map +0 -1
- package/dist/review-v2/review.interface.d.ts +0 -20
- package/dist/review-v2/review.interface.d.ts.map +0 -1
- package/dist/review-v2/review.interface.js +0 -5
- package/dist/review-v2/review.interface.js.map +0 -1
- package/dist/service/api.interface.d.ts +0 -35
- package/dist/service/api.interface.d.ts.map +0 -1
- package/dist/service/api.interface.js +0 -12
- package/dist/service/api.interface.js.map +0 -1
- package/dist/service/base.interface.js +0 -7
- package/dist/service/base.interface.js.map +0 -1
- package/dist/service/service.interface.js +0 -11
- package/dist/service/service.interface.js.map +0 -1
- package/dist/shared/log/create-api-logger.d.ts +0 -17
- package/dist/shared/log/create-api-logger.d.ts.map +0 -1
- package/dist/shared/log/create-api-logger.js +0 -15
- package/dist/shared/log/create-api-logger.js.map +0 -1
- package/dist/shared/log/log-manager.js +0 -218
- package/dist/shared/log/log-manager.js.map +0 -1
- package/dist/shared/utils/config-path.utils.js +0 -85
- package/dist/shared/utils/config-path.utils.js.map +0 -1
- package/dist/shared/utils/error.utils.js +0 -15
- package/dist/shared/utils/error.utils.js.map +0 -1
- package/dist/shared/utils/id.utils.js +0 -5
- package/dist/shared/utils/id.utils.js.map +0 -1
- package/dist/supabase.js +0 -100
- package/dist/supabase.js.map +0 -1
- package/dist/task/local-task-registry.js +0 -153
- package/dist/task/local-task-registry.js.map +0 -1
- package/dist/task/task-manager.js +0 -217
- package/dist/task/task-manager.js.map +0 -1
- package/dist/task/task-repo-context.js +0 -12
- package/dist/task/task-repo-context.js.map +0 -1
- package/dist/task/task.api.js +0 -351
- package/dist/task/task.api.js.map +0 -1
- package/dist/task/task.interface.js +0 -36
- package/dist/task/task.interface.js.map +0 -1
- package/dist/task/task.utils.js +0 -2
- package/dist/task/task.utils.js.map +0 -1
- package/dist/word/word.api.js +0 -30
- package/dist/word/word.api.js.map +0 -1
- package/dist/word/word.interface.js +0 -6
- package/dist/word/word.interface.js.map +0 -1
- package/src/auth/auth.api.ts +0 -87
- package/src/feed/feed.interface.ts +0 -33
- package/src/file/file-manager.ts +0 -145
- package/src/file/file.api.ts +0 -43
- package/src/file/file.interface.ts +0 -30
- package/src/file-list/file-list.api.ts +0 -64
- package/src/file-list/file-list.interface.ts +0 -24
- package/src/node/node-manager.ts +0 -673
- package/src/node/node-task.preset.ts +0 -13
- package/src/question-list/question-list.api.ts +0 -42
- package/src/question-list/question-list.interface.ts +0 -21
- package/src/review/review.api.ts +0 -145
- package/src/review/review.interface.ts +0 -26
- package/src/review-v2/apis/post-review-setting.api.ts +0 -35
- package/src/review-v2/apis/post-review.api.ts +0 -59
- package/src/review-v2/review-setting.interface.ts +0 -26
- package/src/review-v2/review.interface.ts +0 -23
- package/src/service/api.interface.ts +0 -47
- package/src/shared/log/create-api-logger.ts +0 -25
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readdir } from "node:fs/promises";
|
|
1
|
+
import { readdir, stat } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
|
|
4
4
|
import { RepoManager } from "../repo/repo-manager";
|
|
@@ -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 {
|
|
@@ -23,6 +23,11 @@ export interface BootstrapLocalTasksOptions {
|
|
|
23
23
|
rootConfigPath?: string;
|
|
24
24
|
/** Base directory for resolving root config (default `process.cwd()`) */
|
|
25
25
|
cwd?: string;
|
|
26
|
+
/**
|
|
27
|
+
* When set with an unchanged config fingerprint, skip full scan if this key is already
|
|
28
|
+
* registered in {@link RepoManager}.
|
|
29
|
+
*/
|
|
30
|
+
forTaskTypeKey?: string;
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
const EMPTY_RESULT: BootstrapLocalTasksResult = {
|
|
@@ -32,6 +37,14 @@ const EMPTY_RESULT: BootstrapLocalTasksResult = {
|
|
|
32
37
|
errors: [],
|
|
33
38
|
};
|
|
34
39
|
|
|
40
|
+
type BootstrapCacheState = {
|
|
41
|
+
fingerprint: string | null;
|
|
42
|
+
lastResult: BootstrapLocalTasksResult | null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
let bootstrapCache: BootstrapCacheState = { fingerprint: null, lastResult: null };
|
|
46
|
+
let bootstrapInFlight: Promise<BootstrapLocalTasksResult> | null = null;
|
|
47
|
+
|
|
35
48
|
function parseRootConfig(raw: unknown, configPath: string): TaskRunnerRootConfig {
|
|
36
49
|
if (raw == null || typeof raw !== "object") {
|
|
37
50
|
throw new Error(`Root config must export an object: ${configPath}`);
|
|
@@ -64,7 +77,7 @@ function parseTaskPackageConfig(raw: unknown, configPath: string): TaskLocalPack
|
|
|
64
77
|
entry: entry.trim(),
|
|
65
78
|
exportName: typeof record.exportName === "string" ? record.exportName : undefined,
|
|
66
79
|
displayName: typeof record.displayName === "string" ? record.displayName : undefined,
|
|
67
|
-
enabled: record.enabled
|
|
80
|
+
enabled: record.enabled !== false,
|
|
68
81
|
};
|
|
69
82
|
}
|
|
70
83
|
|
|
@@ -78,39 +91,58 @@ function finalizeStatus(result: Omit<BootstrapLocalTasksResult, "status">): Boot
|
|
|
78
91
|
return "loaded";
|
|
79
92
|
}
|
|
80
93
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
94
|
+
async function computeConfigFingerprint(rootConfigPath: string, tasksRoot: string): Promise<string> {
|
|
95
|
+
const rootStat = await stat(rootConfigPath);
|
|
96
|
+
const tasksRootStat = await stat(tasksRoot);
|
|
97
|
+
const entries = await readdir(tasksRoot, { withFileTypes: true });
|
|
98
|
+
const configMtims: number[] = [];
|
|
99
|
+
|
|
100
|
+
for (const entry of entries) {
|
|
101
|
+
if (!entry.isDirectory()) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const configPath = join(tasksRoot, entry.name, TASK_LOCAL_PACKAGE_CONFIG_FILENAME);
|
|
105
|
+
if (await pathExists(configPath)) {
|
|
106
|
+
const configStat = await stat(configPath);
|
|
107
|
+
configMtims.push(configStat.mtimeMs);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
configMtims.sort((a, b) => a - b);
|
|
112
|
+
return `${rootConfigPath}:${rootStat.mtimeMs}:${tasksRoot}:${tasksRootStat.mtimeMs}:${configMtims.join(",")}`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function canUseCachedBootstrap(
|
|
116
|
+
fingerprint: string,
|
|
117
|
+
forTaskTypeKey: string | undefined,
|
|
118
|
+
): BootstrapLocalTasksResult | null {
|
|
119
|
+
if (bootstrapCache.fingerprint !== fingerprint || bootstrapCache.lastResult == null) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (forTaskTypeKey != null && forTaskTypeKey !== "") {
|
|
124
|
+
if (!RepoManager.hasLocalRepo(forTaskTypeKey)) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return { ...bootstrapCache.lastResult, cached: true };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function runBootstrapScan(options: BootstrapLocalTasksOptions): Promise<BootstrapLocalTasksResult> {
|
|
100
133
|
const cwd = options.cwd ?? process.cwd();
|
|
101
134
|
|
|
102
135
|
const rootConfigPath = await resolveFirstExistingPath(cwd, {
|
|
103
136
|
explicitPath: options.rootConfigPath,
|
|
104
|
-
candidatePaths: [
|
|
105
|
-
TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH,
|
|
106
|
-
TASK_RUNNER_ROOT_CONFIG_LEGACY_RELATIVE_PATH,
|
|
107
|
-
],
|
|
137
|
+
candidatePaths: [TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH, TASK_RUNNER_ROOT_CONFIG_LEGACY_RELATIVE_PATH],
|
|
108
138
|
});
|
|
109
139
|
if (rootConfigPath == null) {
|
|
110
|
-
|
|
140
|
+
const result: BootstrapLocalTasksResult = {
|
|
111
141
|
...EMPTY_RESULT,
|
|
112
142
|
message: `No root config (tried ${TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH}, ${TASK_RUNNER_ROOT_CONFIG_LEGACY_RELATIVE_PATH})`,
|
|
113
143
|
};
|
|
144
|
+
bootstrapCache = { fingerprint: null, lastResult: result };
|
|
145
|
+
return result;
|
|
114
146
|
}
|
|
115
147
|
|
|
116
148
|
const result: Omit<BootstrapLocalTasksResult, "status"> = {
|
|
@@ -125,11 +157,19 @@ export async function bootstrapLocalTasks(
|
|
|
125
157
|
|
|
126
158
|
const tasksRoot = resolvePathFromConfigFile(rootConfigPath, taskDir);
|
|
127
159
|
if (!(await pathExists(tasksRoot))) {
|
|
128
|
-
|
|
160
|
+
const failed: BootstrapLocalTasksResult = {
|
|
129
161
|
status: "failed",
|
|
130
162
|
message: `taskDir does not exist: ${tasksRoot}`,
|
|
131
163
|
...result,
|
|
132
164
|
};
|
|
165
|
+
bootstrapCache = { fingerprint: null, lastResult: failed };
|
|
166
|
+
return failed;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const fingerprint = await computeConfigFingerprint(rootConfigPath, tasksRoot);
|
|
170
|
+
const cached = canUseCachedBootstrap(fingerprint, options.forTaskTypeKey);
|
|
171
|
+
if (cached != null) {
|
|
172
|
+
return cached;
|
|
133
173
|
}
|
|
134
174
|
|
|
135
175
|
const entries = await readdir(tasksRoot, { withFileTypes: true });
|
|
@@ -171,23 +211,62 @@ export async function bootstrapLocalTasks(
|
|
|
171
211
|
}
|
|
172
212
|
|
|
173
213
|
const status = finalizeStatus(result);
|
|
174
|
-
|
|
214
|
+
const finalResult: BootstrapLocalTasksResult = {
|
|
175
215
|
status,
|
|
176
|
-
message:
|
|
177
|
-
status === "empty"
|
|
178
|
-
? `Root config loaded but no tasks registered under ${tasksRoot}`
|
|
179
|
-
: undefined,
|
|
216
|
+
message: status === "empty" ? `Root config loaded but no tasks registered under ${tasksRoot}` : undefined,
|
|
180
217
|
...result,
|
|
181
218
|
};
|
|
219
|
+
bootstrapCache = { fingerprint, lastResult: finalResult };
|
|
220
|
+
return finalResult;
|
|
182
221
|
} catch (error) {
|
|
183
|
-
|
|
222
|
+
const failed: BootstrapLocalTasksResult = {
|
|
184
223
|
status: "failed",
|
|
185
224
|
message: error instanceof Error ? error.message : String(error),
|
|
186
225
|
...result,
|
|
187
226
|
};
|
|
227
|
+
bootstrapCache = { fingerprint: null, lastResult: failed };
|
|
228
|
+
return failed;
|
|
188
229
|
}
|
|
189
230
|
}
|
|
190
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Discover local task packages from config files and register them with {@link RepoManager}.
|
|
234
|
+
*
|
|
235
|
+
* **Never throws** for missing root config — returns `{ status: "not_configured" }`.
|
|
236
|
+
*
|
|
237
|
+
* Re-scans are skipped when the config fingerprint is unchanged (root config + taskDir mtimes).
|
|
238
|
+
* Concurrent calls share a single in-flight scan (single-flight).
|
|
239
|
+
*
|
|
240
|
+
* Host app layout (recommended):
|
|
241
|
+
* ```
|
|
242
|
+
* ./config/task.config.js → { taskDir: "../tasks" }
|
|
243
|
+
* ./tasks/my-task/task.config.js
|
|
244
|
+
* ./tasks/my-task/index.mjs
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
247
|
+
* `taskDir` / `entry` paths are relative to **their config file's directory** (see config-file-relative-paths skill).
|
|
248
|
+
*
|
|
249
|
+
* Legacy fallback: `./task.config.js` at project root (`taskDir: "./tasks"`).
|
|
250
|
+
*/
|
|
251
|
+
export async function bootstrapLocalTasks(
|
|
252
|
+
options: BootstrapLocalTasksOptions = {},
|
|
253
|
+
): Promise<BootstrapLocalTasksResult> {
|
|
254
|
+
if (bootstrapInFlight != null) {
|
|
255
|
+
return bootstrapInFlight;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
bootstrapInFlight = runBootstrapScan(options).finally(() => {
|
|
259
|
+
bootstrapInFlight = null;
|
|
260
|
+
});
|
|
261
|
+
return bootstrapInFlight;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Clear fingerprint cache (tests / hot-reload tooling). */
|
|
265
|
+
export function clearBootstrapLocalTasksCache(): void {
|
|
266
|
+
bootstrapCache = { fingerprint: null, lastResult: null };
|
|
267
|
+
bootstrapInFlight = null;
|
|
268
|
+
}
|
|
269
|
+
|
|
191
270
|
export function getRegisteredLocalTaskTypeKeys(): string[] {
|
|
192
271
|
return RepoManager.getRegisteredLocalTaskTypeKeys();
|
|
193
272
|
}
|
package/src/task/task-manager.ts
CHANGED
|
@@ -1,60 +1,70 @@
|
|
|
1
|
-
import { RepoManager } from "../repo/repo-manager";
|
|
2
1
|
import { getScanRemoteRepoValues } from "../repo/repo.api";
|
|
3
2
|
import { TASK_REPO_USAGE } from "../repo/repo.interface";
|
|
4
|
-
import {
|
|
5
|
-
import { ResultCode, Task } from "./task.interface";
|
|
6
|
-
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";
|
|
7
6
|
|
|
8
7
|
export type {
|
|
8
|
+
BootstrapLocalTasksResult,
|
|
9
|
+
BootstrapLocalTasksStatus,
|
|
10
|
+
ExecutableTaskFn,
|
|
9
11
|
TaskFn,
|
|
12
|
+
TaskLocalPackageConfig,
|
|
10
13
|
TaskRepoContext,
|
|
11
|
-
TaskRunResult,
|
|
12
|
-
ExecutableTaskFn,
|
|
13
14
|
TaskRepoScriptDetails,
|
|
14
15
|
TaskRepoScriptRecord,
|
|
15
16
|
TaskRunnerRootConfig,
|
|
16
|
-
|
|
17
|
-
BootstrapLocalTasksResult,
|
|
18
|
-
BootstrapLocalTasksStatus,
|
|
17
|
+
TaskRunResult,
|
|
19
18
|
} from "./task-repo-context";
|
|
20
19
|
export {
|
|
20
|
+
TASK_LOCAL_PACKAGE_CONFIG_FILENAME,
|
|
21
21
|
TASK_REPO_SCRIPT_CATEGORY,
|
|
22
22
|
TASK_RUNNER_CONFIG_DIR,
|
|
23
23
|
TASK_RUNNER_ROOT_CONFIG_FILENAME,
|
|
24
|
-
TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH,
|
|
25
24
|
TASK_RUNNER_ROOT_CONFIG_LEGACY_RELATIVE_PATH,
|
|
26
|
-
|
|
25
|
+
TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH,
|
|
27
26
|
} from "./task-repo-context";
|
|
27
|
+
|
|
28
28
|
import {
|
|
29
|
+
type BootstrapLocalTasksOptions,
|
|
29
30
|
bootstrapLocalTasks,
|
|
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";
|
|
36
|
+
import { TaskRepoValidation, type TaskRepoValidationFailureReason } from "./task-repo-validation";
|
|
34
37
|
|
|
35
|
-
export type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
export type {
|
|
39
|
+
TaskRepoValidationFailureReason,
|
|
40
|
+
ValidateTaskRepoAndParamsInput,
|
|
41
|
+
ValidateTaskRepoAndParamsResult,
|
|
42
|
+
} from "./task-repo-validation";
|
|
43
|
+
export { TaskRepoValidation } from "./task-repo-validation";
|
|
40
44
|
|
|
41
45
|
export interface PrepareTaskResponse {
|
|
42
46
|
isSuccess: boolean;
|
|
43
47
|
taskFn: ExecutableTaskFn | null;
|
|
44
48
|
code?: ResultCode;
|
|
45
49
|
message?: string;
|
|
46
|
-
reason?:
|
|
50
|
+
reason?: TaskRepoValidationFailureReason;
|
|
47
51
|
/** Pipeline step for log aggregation */
|
|
48
52
|
step?: string;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
export interface PrepareTaskParams {
|
|
52
|
-
logger:
|
|
56
|
+
logger: LoggerWithScope;
|
|
53
57
|
task: Task;
|
|
58
|
+
/**
|
|
59
|
+
* When false, do not fetch Repo from Supabase during validation.
|
|
60
|
+
* Should match {@link RegisterTasksOptions.includeRemote} on the worker.
|
|
61
|
+
*/
|
|
62
|
+
includeRemote?: boolean;
|
|
63
|
+
bootstrapLocalOptions?: BootstrapLocalTasksOptions;
|
|
54
64
|
}
|
|
55
65
|
|
|
56
66
|
export interface RegisterTasksOptions {
|
|
57
|
-
logger:
|
|
67
|
+
logger: LoggerWithScope;
|
|
58
68
|
local?: BootstrapLocalTasksOptions;
|
|
59
69
|
/** When `true` (default), union local keys with remote `Repo.value` from Supabase. */
|
|
60
70
|
includeRemote?: boolean;
|
|
@@ -64,32 +74,33 @@ export interface RegisterTasksResult {
|
|
|
64
74
|
availableTaskList: string[];
|
|
65
75
|
local: BootstrapLocalTasksResult;
|
|
66
76
|
remote: { values: string[] };
|
|
77
|
+
includeRemote: boolean;
|
|
67
78
|
}
|
|
68
79
|
|
|
69
|
-
function logLocalBootstrap(logger:
|
|
80
|
+
function logLocalBootstrap(logger: LoggerWithScope, bootstrap: BootstrapLocalTasksResult): void {
|
|
70
81
|
switch (bootstrap.status) {
|
|
71
82
|
case "not_configured":
|
|
72
83
|
logger.info("未找到本地任務配置,跳過本地註冊", {
|
|
73
|
-
topic:
|
|
74
|
-
|
|
84
|
+
topic: LOG_TOPIC_TASK,
|
|
85
|
+
data: { message: bootstrap.message },
|
|
75
86
|
});
|
|
76
87
|
break;
|
|
77
88
|
case "failed":
|
|
78
89
|
logger.warn("本地任務註冊失敗", {
|
|
79
|
-
topic:
|
|
80
|
-
|
|
90
|
+
topic: LOG_TOPIC_TASK,
|
|
91
|
+
data: { message: bootstrap.message, errors: bootstrap.errors },
|
|
81
92
|
});
|
|
82
93
|
break;
|
|
83
94
|
case "empty":
|
|
84
95
|
logger.info("本地任務掃描完成,無已註冊任務", {
|
|
85
|
-
topic:
|
|
86
|
-
|
|
96
|
+
topic: LOG_TOPIC_TASK,
|
|
97
|
+
data: { message: bootstrap.message, skipped: bootstrap.skipped },
|
|
87
98
|
});
|
|
88
99
|
break;
|
|
89
100
|
case "loaded":
|
|
90
101
|
logger.info("本地任務註冊完成", {
|
|
91
|
-
topic:
|
|
92
|
-
|
|
102
|
+
topic: LOG_TOPIC_TASK,
|
|
103
|
+
data: {
|
|
93
104
|
registered: bootstrap.registered,
|
|
94
105
|
skipped: bootstrap.skipped,
|
|
95
106
|
errors: bootstrap.errors,
|
|
@@ -113,36 +124,36 @@ async function registerTasks({
|
|
|
113
124
|
local: localOptions,
|
|
114
125
|
includeRemote = true,
|
|
115
126
|
}: RegisterTasksOptions): Promise<RegisterTasksResult> {
|
|
116
|
-
logger.
|
|
127
|
+
logger.debug("開始註冊任務(本地 + 遠程)", { topic: LOG_TOPIC_TASK });
|
|
117
128
|
|
|
118
129
|
const local = await bootstrapLocalTasks(localOptions ?? {});
|
|
119
130
|
logLocalBootstrap(logger, local);
|
|
120
131
|
|
|
121
132
|
let remoteValues: string[] = [];
|
|
122
133
|
if (includeRemote) {
|
|
123
|
-
logger.
|
|
124
|
-
topic:
|
|
125
|
-
|
|
134
|
+
logger.debug("查詢遠程 Repo 列表", {
|
|
135
|
+
topic: LOG_TOPIC_TASK,
|
|
136
|
+
data: { usage: TASK_REPO_USAGE },
|
|
126
137
|
});
|
|
127
138
|
const { data, error: remoteError } = await getScanRemoteRepoValues({ usage: TASK_REPO_USAGE });
|
|
128
139
|
if (remoteError) {
|
|
129
140
|
throw new Error(remoteError.message);
|
|
130
141
|
}
|
|
131
142
|
remoteValues = data ?? [];
|
|
132
|
-
logger.
|
|
133
|
-
topic:
|
|
134
|
-
|
|
143
|
+
logger.debug("遠程 Repo 查詢完成", {
|
|
144
|
+
topic: LOG_TOPIC_TASK,
|
|
145
|
+
data: { count: remoteValues.length, values: remoteValues },
|
|
135
146
|
});
|
|
136
147
|
}
|
|
137
148
|
|
|
138
149
|
const availableTaskList = [...new Set([...local.registered, ...remoteValues])];
|
|
139
150
|
if (availableTaskList.length === 0) {
|
|
140
|
-
throw new Error("
|
|
151
|
+
throw new Error("任務註冊失敗:本地與遠程均無可用任務類型");
|
|
141
152
|
}
|
|
142
153
|
|
|
143
154
|
logger.success("任務註冊完成", {
|
|
144
|
-
topic:
|
|
145
|
-
|
|
155
|
+
topic: LOG_TOPIC_TASK,
|
|
156
|
+
data: {
|
|
146
157
|
availableTaskList,
|
|
147
158
|
localRegistered: local.registered,
|
|
148
159
|
remoteValues,
|
|
@@ -153,10 +164,11 @@ async function registerTasks({
|
|
|
153
164
|
availableTaskList,
|
|
154
165
|
local,
|
|
155
166
|
remote: { values: remoteValues },
|
|
167
|
+
includeRemote,
|
|
156
168
|
};
|
|
157
169
|
}
|
|
158
170
|
|
|
159
|
-
/** 将 taskFn 与 params 闭包绑定,供
|
|
171
|
+
/** 将 taskFn 与 params 闭包绑定,供 TaskNode 无参调用 `await taskFn()` */
|
|
160
172
|
function bindTaskFn(taskFn: TaskFn, taskParams: unknown): ExecutableTaskFn {
|
|
161
173
|
const run = async () => taskFn(taskParams);
|
|
162
174
|
return Object.assign(run, {
|
|
@@ -165,45 +177,32 @@ function bindTaskFn(taskFn: TaskFn, taskParams: unknown): ExecutableTaskFn {
|
|
|
165
177
|
});
|
|
166
178
|
}
|
|
167
179
|
|
|
168
|
-
/** 调用 Repo 模块导出的 taskParamsValidator;抛错视为校验失败 */
|
|
169
|
-
function validateTaskParams(
|
|
170
|
-
validator: TaskRepoContext["taskParamsValidator"],
|
|
171
|
-
taskParams: unknown,
|
|
172
|
-
logger: LoggerWithContext
|
|
173
|
-
): boolean {
|
|
174
|
-
try {
|
|
175
|
-
return validator(taskParams) === true;
|
|
176
|
-
} catch (error) {
|
|
177
|
-
logger.warn("taskParamsValidator 拋出異常", {
|
|
178
|
-
topic: "task",
|
|
179
|
-
context: { error: error instanceof Error ? error.message : error },
|
|
180
|
-
});
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
180
|
/**
|
|
186
181
|
* 將 Supabase 認領到的 Task 解析為可執行的 `ExecutableTaskFn`。
|
|
187
182
|
*
|
|
188
183
|
* 流程:
|
|
189
184
|
* 1. 從 task.details 取出 `params`;`task.value` 作為 taskTypeKey(同 {@link Repo.value})
|
|
190
|
-
* 2. {@link
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* 5. bindTaskFn,返回閉包後的無參執行函數
|
|
185
|
+
* 2. {@link TaskRepoValidation.validate} — 本地註冊優先;未命中時可選遠端(`includeRemote`)
|
|
186
|
+
* Worker 在 registry 未命中時會補掃本地(`local_bootstrap_on_miss`)
|
|
187
|
+
* 3. bindTaskFn,返回閉包後的無參執行函數
|
|
194
188
|
*
|
|
195
189
|
* 失敗時返回 `{ isSuccess: false, code, message, reason, step }`(不 throw)。
|
|
196
190
|
*/
|
|
197
|
-
const prepareTask = async ({
|
|
191
|
+
const prepareTask = async ({
|
|
192
|
+
logger,
|
|
193
|
+
task,
|
|
194
|
+
includeRemote = true,
|
|
195
|
+
bootstrapLocalOptions,
|
|
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:
|
|
206
|
-
|
|
204
|
+
topic: LOG_TOPIC_TASK,
|
|
205
|
+
data: {
|
|
207
206
|
taskId: task.id,
|
|
208
207
|
taskTypeKey: task.value,
|
|
209
208
|
reason: params.reason,
|
|
@@ -221,74 +220,62 @@ const prepareTask = async ({ logger, task }: PrepareTaskParams): Promise<Prepare
|
|
|
221
220
|
};
|
|
222
221
|
|
|
223
222
|
const { id: taskId, name: taskName, value: taskTypeKey, details } = task;
|
|
224
|
-
logger.
|
|
225
|
-
topic:
|
|
226
|
-
|
|
223
|
+
logger.debug(`開始準備任務 ${taskName}-${taskTypeKey}`, {
|
|
224
|
+
topic: LOG_TOPIC_TASK,
|
|
225
|
+
data: { taskId, taskName, taskTypeKey },
|
|
227
226
|
});
|
|
228
227
|
|
|
229
228
|
const { params: taskParams } = details;
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
229
|
+
|
|
230
|
+
if (!getRegisteredLocalTaskTypeKeys().includes(taskTypeKey)) {
|
|
231
|
+
const bootstrap = await bootstrapLocalTasks({
|
|
232
|
+
...bootstrapLocalOptions,
|
|
233
|
+
forTaskTypeKey: taskTypeKey,
|
|
234
|
+
});
|
|
235
|
+
logger.debug("本地 registry 未命中,補掃本地任務", {
|
|
236
|
+
topic: LOG_TOPIC_TASK,
|
|
237
|
+
data: {
|
|
238
|
+
taskId,
|
|
239
|
+
taskTypeKey,
|
|
240
|
+
step: "local_bootstrap_on_miss",
|
|
241
|
+
status: bootstrap.status,
|
|
242
|
+
registered: bootstrap.registered,
|
|
243
|
+
cached: bootstrap.cached ?? false,
|
|
244
|
+
message: bootstrap.message,
|
|
245
|
+
},
|
|
236
246
|
});
|
|
237
247
|
}
|
|
238
248
|
|
|
239
|
-
|
|
240
|
-
topic: "task",
|
|
241
|
-
context: { taskTypeKey, step: "repo_load" },
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
const { context: repoContext, error: repoError } = await RepoManager.getRepoContext<TaskRepoContext>({
|
|
249
|
+
const validation = await TaskRepoValidation.validate({
|
|
245
250
|
logger,
|
|
246
251
|
taskTypeKey,
|
|
252
|
+
params: taskParams,
|
|
253
|
+
includeRemote,
|
|
247
254
|
});
|
|
248
|
-
|
|
249
|
-
if (repoContext == null) {
|
|
255
|
+
if (!validation.isValid) {
|
|
250
256
|
return fail({
|
|
251
|
-
reason:
|
|
252
|
-
code:
|
|
253
|
-
message:
|
|
254
|
-
step:
|
|
257
|
+
reason: validation.reason,
|
|
258
|
+
code: validation.code,
|
|
259
|
+
message: validation.message,
|
|
260
|
+
step: validation.step,
|
|
255
261
|
});
|
|
256
262
|
}
|
|
257
263
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
264
|
+
const { repoContext } = validation;
|
|
265
|
+
|
|
266
|
+
logger.debug("Repo 上下文加載成功", {
|
|
267
|
+
topic: LOG_TOPIC_TASK,
|
|
268
|
+
data: {
|
|
261
269
|
taskTypeKey,
|
|
262
270
|
taskFnDisplayName: repoContext.taskFn.displayName,
|
|
263
271
|
step: "repo_load",
|
|
264
272
|
},
|
|
265
273
|
});
|
|
266
274
|
|
|
267
|
-
if (repoContext.taskFn.taskTypeKey !== taskTypeKey) {
|
|
268
|
-
return fail({
|
|
269
|
-
reason: "TASK_TYPE_KEY_MISMATCH",
|
|
270
|
-
code: ResultCode.REPO_NOT_VALID,
|
|
271
|
-
message: `taskFn.taskTypeKey (${repoContext.taskFn.taskTypeKey}) 與 task.value (${taskTypeKey}) 不一致`,
|
|
272
|
-
step: "task_type_key",
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
logger.debug("開始校驗任務參數", { topic: "task", context: { taskTypeKey, step: "params_validation" } });
|
|
277
|
-
if (!validateTaskParams(repoContext.taskParamsValidator, taskParams, logger)) {
|
|
278
|
-
return fail({
|
|
279
|
-
reason: "PARAMS_VALIDATION_FAILED",
|
|
280
|
-
code: ResultCode.PARAMS_NOT_VALID,
|
|
281
|
-
message: "任務參數校驗失敗",
|
|
282
|
-
step: "params_validation",
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
logger.debug("任務參數校驗通過", { topic: "task", context: { taskTypeKey, step: "params_validation" } });
|
|
287
|
-
|
|
288
275
|
const boundTaskFn = bindTaskFn(repoContext.taskFn, taskParams);
|
|
289
|
-
logger.
|
|
290
|
-
topic:
|
|
291
|
-
|
|
276
|
+
logger.debug("任務準備完成", {
|
|
277
|
+
topic: LOG_TOPIC_TASK,
|
|
278
|
+
data: {
|
|
292
279
|
taskId,
|
|
293
280
|
taskTypeKey,
|
|
294
281
|
displayName: boundTaskFn.displayName,
|
|
@@ -307,6 +294,7 @@ const TaskManager = {
|
|
|
307
294
|
prepareTask,
|
|
308
295
|
bootstrapLocalTasks,
|
|
309
296
|
getRegisteredLocalTaskTypeKeys,
|
|
297
|
+
clearBootstrapLocalTasksCache,
|
|
310
298
|
};
|
|
311
299
|
|
|
312
300
|
export { TaskManager };
|