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
|
@@ -8,11 +8,17 @@ export interface LogScope {
|
|
|
8
8
|
labels?: Readonly<Record<string, string>>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
/** Partial update for {@link
|
|
11
|
+
/** Partial update for {@link patchScope}. */
|
|
12
12
|
export type LogScopePatch = Partial<Omit<LogScope, "labels">> & {
|
|
13
13
|
labels?: Record<string, string>;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
/** Fields allowed on {@link LoggerWithScope.resetScope} — no trace identity changes. */
|
|
17
|
+
export type LoggerResetScopePatch = {
|
|
18
|
+
module?: string;
|
|
19
|
+
labels?: Record<string, string>;
|
|
20
|
+
};
|
|
21
|
+
|
|
16
22
|
export type LogScopeInput = LogScopePatch & Pick<LogScope, "module">;
|
|
17
23
|
|
|
18
24
|
interface NormalizeScopeOptions {
|
|
@@ -20,9 +26,20 @@ interface NormalizeScopeOptions {
|
|
|
20
26
|
generateTraceId?: boolean;
|
|
21
27
|
}
|
|
22
28
|
|
|
29
|
+
/** Input for {@link patchScope}. */
|
|
30
|
+
export type PatchScopeInput = {
|
|
31
|
+
scope: LogScope;
|
|
32
|
+
patch: LogScopePatch;
|
|
33
|
+
/**
|
|
34
|
+
* When `false` (default), `patch.traceId` / `patch.traceParentId` are ignored.
|
|
35
|
+
* New spans: use {@link createScope}.
|
|
36
|
+
*/
|
|
37
|
+
allowTraceMutation?: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
23
40
|
function mergeLabels(
|
|
24
41
|
base?: Readonly<Record<string, string>>,
|
|
25
|
-
patch?: Record<string, string
|
|
42
|
+
patch?: Record<string, string>,
|
|
26
43
|
): Record<string, string> | undefined {
|
|
27
44
|
const merged: Record<string, string> = { ...base, ...patch };
|
|
28
45
|
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
@@ -44,64 +61,47 @@ export function normalizeScope(input: LogScopeInput, options?: NormalizeScopeOpt
|
|
|
44
61
|
};
|
|
45
62
|
}
|
|
46
63
|
|
|
47
|
-
/** Input for {@link
|
|
48
|
-
export type
|
|
64
|
+
/** Input for {@link createScope}. */
|
|
65
|
+
export type CreateScopeInput = {
|
|
49
66
|
module: string;
|
|
50
|
-
traceId
|
|
51
|
-
labels?: Record<string, string>;
|
|
52
|
-
traceParentId?: string | null;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/** Root scope: traceParentId defaults to null. */
|
|
56
|
-
export function createRootScope(input: CreateRootScopeInput): LogScope {
|
|
57
|
-
return normalizeScope(
|
|
58
|
-
{
|
|
59
|
-
module: input.module,
|
|
60
|
-
traceId: input.traceId,
|
|
61
|
-
traceParentId: input.traceParentId ?? null,
|
|
62
|
-
labels: input.labels,
|
|
63
|
-
},
|
|
64
|
-
{ generateTraceId: true }
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** Input for {@link createChildScope}. */
|
|
69
|
-
export type CreateChildScopeInput = {
|
|
70
|
-
module: string;
|
|
71
|
-
parent: LogScope;
|
|
72
|
-
traceId?: string;
|
|
67
|
+
traceId: string;
|
|
73
68
|
traceParentId?: string | null;
|
|
74
69
|
labels?: Record<string, string>;
|
|
70
|
+
/** When set, default traceParentId to parent.traceId and merge labels. */
|
|
71
|
+
parent?: LogScope;
|
|
75
72
|
};
|
|
76
73
|
|
|
77
|
-
/**
|
|
78
|
-
export function
|
|
74
|
+
/** Build a scope; optional parent links trace chain and merges labels. */
|
|
75
|
+
export function createScope(input: CreateScopeInput): LogScope {
|
|
79
76
|
const { module, parent, traceId, traceParentId, labels } = input;
|
|
80
|
-
return normalizeScope(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
{ generateTraceId: true }
|
|
88
|
-
);
|
|
77
|
+
return normalizeScope({
|
|
78
|
+
module,
|
|
79
|
+
traceId,
|
|
80
|
+
traceParentId: traceParentId ?? (parent != null ? parent.traceId : null),
|
|
81
|
+
labels: parent != null ? mergeLabels(parent.labels, labels) : mergeLabels(undefined, labels),
|
|
82
|
+
});
|
|
89
83
|
}
|
|
90
84
|
|
|
91
|
-
/**
|
|
92
|
-
export function
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
/** Merge patch into scope (labels deep-merge). Returns a new scope. */
|
|
86
|
+
export function patchScope(input: PatchScopeInput): LogScope {
|
|
87
|
+
const { scope, patch, allowTraceMutation = false } = input;
|
|
88
|
+
const traceId = allowTraceMutation && patch.traceId != null && patch.traceId !== "" ? patch.traceId : scope.traceId;
|
|
89
|
+
const traceParentId =
|
|
90
|
+
allowTraceMutation && patch.traceParentId !== undefined ? patch.traceParentId : scope.traceParentId;
|
|
95
91
|
|
|
96
|
-
/** Merge patch into scope (labels deep-merge). */
|
|
97
|
-
export function applyScopePatch(scope: LogScope, patch: LogScopePatch): LogScope {
|
|
98
92
|
return normalizeScope({
|
|
99
93
|
module: patch.module ?? scope.module,
|
|
100
|
-
traceId
|
|
101
|
-
traceParentId
|
|
94
|
+
traceId,
|
|
95
|
+
traceParentId,
|
|
102
96
|
labels: mergeLabels(scope.labels, patch.labels),
|
|
103
97
|
});
|
|
104
98
|
}
|
|
99
|
+
|
|
100
|
+
/** Same trace chain, different module (e.g. prepareTask vs executeTask). */
|
|
101
|
+
export function withModule(scope: LogScope, module: string): LogScope {
|
|
102
|
+
return patchScope({ scope, patch: { module } });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
105
|
export function formatScopeLabels(labels?: Readonly<Record<string, string>>): string {
|
|
106
106
|
if (labels == null || Object.keys(labels).length === 0) {
|
|
107
107
|
return "--";
|
|
@@ -69,7 +69,7 @@ export interface ResolveFirstExistingPathOptions {
|
|
|
69
69
|
*/
|
|
70
70
|
export async function resolveFirstExistingPath(
|
|
71
71
|
cwd: string,
|
|
72
|
-
options: ResolveFirstExistingPathOptions
|
|
72
|
+
options: ResolveFirstExistingPathOptions,
|
|
73
73
|
): Promise<string | null> {
|
|
74
74
|
const { explicitPath, candidatePaths } = options;
|
|
75
75
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function resolveFetchUrl(input: string | URL | Request): string {
|
|
2
|
+
if (typeof input === "string") {
|
|
3
|
+
return input;
|
|
4
|
+
}
|
|
5
|
+
if (input instanceof URL) {
|
|
6
|
+
return input.href;
|
|
7
|
+
}
|
|
8
|
+
return input.url;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isHttpUrl(url: string): boolean {
|
|
12
|
+
return url.startsWith("http://") || url.startsWith("https://");
|
|
13
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export type NetworkErrorKind =
|
|
2
|
+
| "connect_timeout"
|
|
3
|
+
| "tls_disconnect"
|
|
4
|
+
| "connection_refused"
|
|
5
|
+
| "dns_error"
|
|
6
|
+
| "socket_closed"
|
|
7
|
+
| "timeout"
|
|
8
|
+
| "proxy_error"
|
|
9
|
+
| "unknown";
|
|
10
|
+
|
|
11
|
+
export interface ClassifiedNetworkError {
|
|
12
|
+
kind: NetworkErrorKind;
|
|
13
|
+
retryable: boolean;
|
|
14
|
+
code: string;
|
|
15
|
+
detail: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const RETRYABLE_CAUSE_CODES = new Set([
|
|
19
|
+
"UND_ERR_CONNECT_TIMEOUT",
|
|
20
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
21
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
22
|
+
"UND_ERR_SOCKET",
|
|
23
|
+
"ECONNRESET",
|
|
24
|
+
"ECONNREFUSED",
|
|
25
|
+
"ENOTFOUND",
|
|
26
|
+
"ETIMEDOUT",
|
|
27
|
+
"EPIPE",
|
|
28
|
+
"EAI_AGAIN",
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
function errorCause(error: unknown): { code?: string; message?: string } | undefined {
|
|
32
|
+
if (error instanceof Error) {
|
|
33
|
+
return error.cause as { code?: string; message?: string } | undefined;
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function classifyNetworkError(error: unknown): ClassifiedNetworkError {
|
|
39
|
+
if (!(error instanceof Error)) {
|
|
40
|
+
return { kind: "unknown", retryable: false, code: "", detail: String(error) };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const cause = errorCause(error);
|
|
44
|
+
const code = cause?.code ?? "";
|
|
45
|
+
const causeMessage = cause?.message ?? "";
|
|
46
|
+
const message = error.message;
|
|
47
|
+
|
|
48
|
+
const tlsDisconnect =
|
|
49
|
+
/TLS connection was established/i.test(causeMessage) ||
|
|
50
|
+
/secure TLS connection/i.test(causeMessage) ||
|
|
51
|
+
/socket disconnected before secure TLS/i.test(message) ||
|
|
52
|
+
/socket disconnected before secure TLS/i.test(causeMessage);
|
|
53
|
+
|
|
54
|
+
if (tlsDisconnect) {
|
|
55
|
+
return {
|
|
56
|
+
kind: "tls_disconnect",
|
|
57
|
+
retryable: true,
|
|
58
|
+
code,
|
|
59
|
+
detail: causeMessage || message,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (code === "UND_ERR_CONNECT_TIMEOUT" || error.name === "TimeoutError" || error.name === "AbortError") {
|
|
64
|
+
return {
|
|
65
|
+
kind: error.name === "AbortError" ? "timeout" : "connect_timeout",
|
|
66
|
+
retryable: true,
|
|
67
|
+
code,
|
|
68
|
+
detail: causeMessage || message,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (code === "ECONNREFUSED") {
|
|
73
|
+
return {
|
|
74
|
+
kind: "connection_refused",
|
|
75
|
+
retryable: true,
|
|
76
|
+
code,
|
|
77
|
+
detail: causeMessage || message,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (code === "ENOTFOUND" || code === "EAI_AGAIN") {
|
|
82
|
+
return {
|
|
83
|
+
kind: "dns_error",
|
|
84
|
+
retryable: code === "EAI_AGAIN",
|
|
85
|
+
code,
|
|
86
|
+
detail: causeMessage || message,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (
|
|
91
|
+
code === "UND_ERR_SOCKET" ||
|
|
92
|
+
code === "ECONNRESET" ||
|
|
93
|
+
code === "EPIPE" ||
|
|
94
|
+
/socket disconnected/i.test(causeMessage) ||
|
|
95
|
+
/other side closed/i.test(causeMessage)
|
|
96
|
+
) {
|
|
97
|
+
return {
|
|
98
|
+
kind: "socket_closed",
|
|
99
|
+
retryable: true,
|
|
100
|
+
code,
|
|
101
|
+
detail: causeMessage || message,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (RETRYABLE_CAUSE_CODES.has(code)) {
|
|
106
|
+
return {
|
|
107
|
+
kind: "proxy_error",
|
|
108
|
+
retryable: true,
|
|
109
|
+
code,
|
|
110
|
+
detail: causeMessage || message,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
kind: "unknown",
|
|
116
|
+
retryable: false,
|
|
117
|
+
code,
|
|
118
|
+
detail: causeMessage ? `${message}: ${causeMessage}` : message,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface FormatNetworkErrorOptions {
|
|
123
|
+
/** Extra hint appended (proxy URL, env var name, etc.). */
|
|
124
|
+
hint?: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function formatNetworkError(error: unknown, label: string, options: FormatNetworkErrorOptions = {}): string {
|
|
128
|
+
const classified = classifyNetworkError(error);
|
|
129
|
+
const hint = options.hint ?? "";
|
|
130
|
+
|
|
131
|
+
switch (classified.kind) {
|
|
132
|
+
case "connect_timeout":
|
|
133
|
+
return `${label}: connect timeout${hint}`;
|
|
134
|
+
case "tls_disconnect":
|
|
135
|
+
return `${label}: TLS handshake dropped${hint}. Often transient through proxies — retries may succeed.`;
|
|
136
|
+
case "connection_refused":
|
|
137
|
+
return `${label}: connection refused — ${classified.detail}${hint}`;
|
|
138
|
+
case "dns_error":
|
|
139
|
+
return `${label}: DNS lookup failed (${classified.code}) — ${classified.detail}`;
|
|
140
|
+
case "socket_closed":
|
|
141
|
+
return (
|
|
142
|
+
`${label}: connection closed mid-request (${classified.code || "socket"}) — ` +
|
|
143
|
+
`${classified.detail}${hint}`
|
|
144
|
+
);
|
|
145
|
+
case "timeout":
|
|
146
|
+
return `${label}: request timeout — ${classified.detail}${hint}`;
|
|
147
|
+
case "proxy_error":
|
|
148
|
+
return `${label}: network/proxy error (${classified.code}) — ${classified.detail}${hint}`;
|
|
149
|
+
default:
|
|
150
|
+
return `${label}: ${classified.detail}${hint}`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface SanitizeFileNameOptions {
|
|
2
|
+
/** Max length after sanitization (default 200). */
|
|
3
|
+
maxLength?: number;
|
|
4
|
+
/** When set, used instead of throwing on invalid names. */
|
|
5
|
+
fallback?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function fileBaseName(raw: string): string {
|
|
9
|
+
const normalized = raw.replace(/\\/g, "/");
|
|
10
|
+
const parts = normalized.split("/");
|
|
11
|
+
return parts.at(-1) ?? normalized;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Safe display / storage file name from a browser or filesystem path string.
|
|
16
|
+
* Strips directory segments and forbidden characters.
|
|
17
|
+
*/
|
|
18
|
+
export function sanitizeFileName(raw: string, options: SanitizeFileNameOptions = {}): string {
|
|
19
|
+
const maxLength = options.maxLength ?? 200;
|
|
20
|
+
const base = fileBaseName(raw);
|
|
21
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: intentionally strip ASCII control chars (0x00–0x1f)
|
|
22
|
+
const cleaned = base.replace(/[\x00-\x1f<>:"/\\|?*]+/g, "_").trim();
|
|
23
|
+
|
|
24
|
+
if (cleaned === "" || cleaned === "." || cleaned === "..") {
|
|
25
|
+
if (options.fallback != null) {
|
|
26
|
+
return options.fallback.slice(0, maxLength);
|
|
27
|
+
}
|
|
28
|
+
throw new Error("Invalid file name");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return cleaned.slice(0, maxLength);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Parcel.name / value default — 200 char cap. */
|
|
35
|
+
export function sanitizeParcelFileName(raw: string): string {
|
|
36
|
+
return sanitizeFileName(raw, { maxLength: 200 });
|
|
37
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function getCrypto(): Crypto {
|
|
2
|
+
if (typeof globalThis !== "undefined" && globalThis.crypto) {
|
|
3
|
+
return globalThis.crypto;
|
|
4
|
+
}
|
|
5
|
+
throw new Error("sha256Hex: crypto.subtle not available");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** SHA-256 digest as lowercase hex (browser + Node Web Crypto). */
|
|
9
|
+
export async function sha256Hex(buffer: ArrayBuffer): Promise<string> {
|
|
10
|
+
const crypto = getCrypto();
|
|
11
|
+
const hash = await crypto.subtle.digest("SHA-256", buffer);
|
|
12
|
+
return Array.from(new Uint8Array(hash))
|
|
13
|
+
.map((byte) => byte.toString(16).padStart(2, "0"))
|
|
14
|
+
.join("");
|
|
15
|
+
}
|
package/src/supabase.ts
CHANGED
|
@@ -1,143 +1,149 @@
|
|
|
1
|
-
import { createClient, SupabaseClient } from "@supabase/supabase-js";
|
|
1
|
+
import { createClient, type SupabaseClient } from "@supabase/supabase-js";
|
|
2
2
|
import { logDev, logDevGroup } from "./core.utils";
|
|
3
3
|
|
|
4
4
|
interface SupabaseConfig {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
main: {
|
|
6
|
+
url: string;
|
|
7
|
+
anonKey: string;
|
|
8
|
+
};
|
|
9
|
+
auth: {
|
|
10
|
+
url: string;
|
|
11
|
+
anonKey: string;
|
|
12
|
+
} | null;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface SupabaseInitializerParams {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
supabaseUrl: string;
|
|
17
|
+
supabaseAnonKey: string;
|
|
18
|
+
supabaseNeedAuthUrl?: string;
|
|
19
|
+
supabaseNeedAuthAnonKey?: string;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
class SupabaseInitializer {
|
|
23
|
+
private static instance: SupabaseInitializer;
|
|
24
|
+
private isInitialized = false;
|
|
25
|
+
private _mainClient: SupabaseClient | null = null;
|
|
26
|
+
private _authClient: SupabaseClient | null = null;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
private constructor() {}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Initialize Supabase clients
|
|
39
|
-
*/
|
|
40
|
-
async initialize(
|
|
41
|
-
params: SupabaseInitializerParams
|
|
42
|
-
): Promise<{ supabase: SupabaseClient; supabaseAuth: SupabaseClient | null }> {
|
|
43
|
-
if (this.isInitialized) {
|
|
44
|
-
logDev("🚫 Supabase already initialized");
|
|
45
|
-
return { supabase: this._mainClient!, supabaseAuth: this._authClient };
|
|
30
|
+
static getInstance(): SupabaseInitializer {
|
|
31
|
+
if (!SupabaseInitializer.instance) {
|
|
32
|
+
SupabaseInitializer.instance = new SupabaseInitializer();
|
|
33
|
+
}
|
|
34
|
+
return SupabaseInitializer.instance;
|
|
46
35
|
}
|
|
47
36
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Initialize Supabase clients
|
|
39
|
+
*/
|
|
40
|
+
async initialize(
|
|
41
|
+
params: SupabaseInitializerParams,
|
|
42
|
+
): Promise<{ supabase: SupabaseClient; supabaseAuth: SupabaseClient | null }> {
|
|
43
|
+
if (this.isInitialized) {
|
|
44
|
+
logDev("🚫 Supabase already initialized");
|
|
45
|
+
return { supabase: this._mainClient!, supabaseAuth: this._authClient };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
logDev("🔧 Initializing Supabase...");
|
|
49
|
+
|
|
50
|
+
// Validate and get environment variables
|
|
51
|
+
const config = this.validateEnvironmentVariables(params);
|
|
52
|
+
|
|
53
|
+
// Create main client
|
|
54
|
+
this._mainClient = createClient(config.main.url, config.main.anonKey, {
|
|
55
|
+
// TODO
|
|
56
|
+
// auth: {
|
|
57
|
+
// persistSession: true,
|
|
58
|
+
// autoRefreshToken: true,
|
|
59
|
+
// },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Create auth client if configured
|
|
63
|
+
if (config.auth) {
|
|
64
|
+
this._authClient = createClient(config.auth.url, config.auth.anonKey, {
|
|
65
|
+
// TODO
|
|
66
|
+
// auth: {
|
|
67
|
+
// persistSession: true,
|
|
68
|
+
// autoRefreshToken: true,
|
|
69
|
+
// },
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Log configuration
|
|
74
|
+
this.logConfiguration(config);
|
|
75
|
+
|
|
76
|
+
this.isInitialized = true;
|
|
77
|
+
logDev("✅ Supabase initialization completed");
|
|
78
|
+
|
|
79
|
+
return { supabase: this._mainClient, supabaseAuth: this._authClient };
|
|
71
80
|
}
|
|
72
81
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
private validateEnvironmentVariables({
|
|
83
|
+
supabaseUrl,
|
|
84
|
+
supabaseAnonKey,
|
|
85
|
+
supabaseNeedAuthUrl,
|
|
86
|
+
supabaseNeedAuthAnonKey,
|
|
87
|
+
}: SupabaseInitializerParams): SupabaseConfig {
|
|
88
|
+
const mainUrl = supabaseUrl;
|
|
89
|
+
const mainAnonKey = supabaseAnonKey;
|
|
90
|
+
const authUrl = supabaseNeedAuthUrl;
|
|
91
|
+
const authAnonKey = supabaseNeedAuthAnonKey;
|
|
92
|
+
|
|
93
|
+
if (!mainUrl || !mainAnonKey) {
|
|
94
|
+
throw new Error("Missing required Supabase environment variables: SUPABASE_URL, SUPABASE_ANON_KEY");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
main: { url: mainUrl, anonKey: mainAnonKey },
|
|
99
|
+
auth: authUrl && authAnonKey ? { url: authUrl, anonKey: authAnonKey } : null,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
92
102
|
|
|
93
|
-
|
|
94
|
-
|
|
103
|
+
private logConfiguration(config: SupabaseConfig) {
|
|
104
|
+
logDevGroup("🔧 Supabase Configuration", () => {
|
|
105
|
+
console.log("Main URL:", config.main.url);
|
|
106
|
+
console.log("Auth URL:", config.auth?.url || "Not configured");
|
|
107
|
+
console.log("Clients:", {
|
|
108
|
+
main: !!this._mainClient,
|
|
109
|
+
auth: !!this._authClient,
|
|
110
|
+
});
|
|
111
|
+
});
|
|
95
112
|
}
|
|
96
113
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
private logConfiguration(config: SupabaseConfig) {
|
|
104
|
-
logDevGroup("🔧 Supabase Configuration", () => {
|
|
105
|
-
console.log("Main URL:", config.main.url);
|
|
106
|
-
console.log("Auth URL:", config.auth?.url || "Not configured");
|
|
107
|
-
console.log("Clients:", {
|
|
108
|
-
main: !!this._mainClient,
|
|
109
|
-
auth: !!this._authClient,
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
getClients() {
|
|
115
|
-
if (!this.isInitialized) {
|
|
116
|
-
throw new Error("Supabase not initialized. Call initialize() first.");
|
|
114
|
+
getClients() {
|
|
115
|
+
if (!this.isInitialized) {
|
|
116
|
+
throw new Error("Supabase not initialized. Call initialize() first.");
|
|
117
|
+
}
|
|
118
|
+
return { supabase: this._mainClient!, supabaseAuth: this._authClient };
|
|
117
119
|
}
|
|
118
|
-
return { supabase: this._mainClient!, supabaseAuth: this._authClient };
|
|
119
|
-
}
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
get client(): SupabaseClient {
|
|
122
|
+
if (!this.isInitialized) {
|
|
123
|
+
throw new Error("Supabase not initialized. Call initialize() first.");
|
|
124
|
+
}
|
|
125
|
+
if (!this._mainClient) {
|
|
126
|
+
throw new Error("Main Supabase client is null. Initialization may have failed.");
|
|
127
|
+
}
|
|
128
|
+
return this._mainClient;
|
|
124
129
|
}
|
|
125
|
-
|
|
126
|
-
|
|
130
|
+
|
|
131
|
+
get authClient(): SupabaseClient | null {
|
|
132
|
+
if (!this.isInitialized) {
|
|
133
|
+
throw new Error("Supabase not initialized. Call initialize() first.");
|
|
134
|
+
}
|
|
135
|
+
return this._authClient;
|
|
127
136
|
}
|
|
128
|
-
return this._mainClient;
|
|
129
|
-
}
|
|
130
137
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
reset() {
|
|
139
|
+
this.isInitialized = false;
|
|
140
|
+
this._mainClient = null;
|
|
141
|
+
this._authClient = null;
|
|
134
142
|
}
|
|
135
|
-
return this._authClient;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
reset() {
|
|
139
|
-
this.isInitialized = false;
|
|
140
|
-
this._mainClient = null;
|
|
141
|
-
this._authClient = null;
|
|
142
|
-
}
|
|
143
143
|
}
|
|
144
|
+
|
|
145
|
+
/** Process-wide holder — import this; class is module-private. */
|
|
146
|
+
export const supabase = SupabaseInitializer.getInstance();
|
|
147
|
+
|
|
148
|
+
/** Public type for the `supabase` holder instance. */
|
|
149
|
+
export type SupabaseHolder = typeof supabase;
|