@digimuza/saas-core 0.0.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/CLAUDE.md +1165 -0
- package/LICENSE +21 -0
- package/README.md +234 -0
- package/dist/api-keys/index.d.ts +9 -0
- package/dist/api-keys/index.d.ts.map +1 -0
- package/dist/api-keys/index.js +37 -0
- package/dist/api-keys/index.js.map +1 -0
- package/dist/api-keys/keys.d.ts +55 -0
- package/dist/api-keys/keys.d.ts.map +1 -0
- package/dist/api-keys/keys.js +92 -0
- package/dist/api-keys/keys.js.map +1 -0
- package/dist/api-keys/service.d.ts +111 -0
- package/dist/api-keys/service.d.ts.map +1 -0
- package/dist/api-keys/service.js +210 -0
- package/dist/api-keys/service.js.map +1 -0
- package/dist/audit/index.d.ts +5 -0
- package/dist/audit/index.d.ts.map +1 -0
- package/dist/audit/index.js +44 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/service.d.ts +88 -0
- package/dist/audit/service.d.ts.map +1 -0
- package/dist/audit/service.js +128 -0
- package/dist/audit/service.js.map +1 -0
- package/dist/auth/client.d.ts +5 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +26 -0
- package/dist/auth/client.js.map +1 -0
- package/dist/auth/cookies.d.ts +51 -0
- package/dist/auth/cookies.d.ts.map +1 -0
- package/dist/auth/cookies.js +58 -0
- package/dist/auth/cookies.js.map +1 -0
- package/dist/auth/index.d.ts +14 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +46 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/service.d.ts +67 -0
- package/dist/auth/service.d.ts.map +1 -0
- package/dist/auth/service.js +275 -0
- package/dist/auth/service.js.map +1 -0
- package/dist/auth/types.d.ts +56 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/authorization/index.d.ts +4 -0
- package/dist/authorization/index.d.ts.map +1 -0
- package/dist/authorization/index.js +24 -0
- package/dist/authorization/index.js.map +1 -0
- package/dist/authorization/service.d.ts +92 -0
- package/dist/authorization/service.d.ts.map +1 -0
- package/dist/authorization/service.js +254 -0
- package/dist/authorization/service.js.map +1 -0
- package/dist/billing/index.d.ts +16 -0
- package/dist/billing/index.d.ts.map +1 -0
- package/dist/billing/index.js +47 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing/provider.d.ts +114 -0
- package/dist/billing/provider.d.ts.map +1 -0
- package/dist/billing/provider.js +2 -0
- package/dist/billing/provider.js.map +1 -0
- package/dist/billing/revolut.d.ts +68 -0
- package/dist/billing/revolut.d.ts.map +1 -0
- package/dist/billing/revolut.js +181 -0
- package/dist/billing/revolut.js.map +1 -0
- package/dist/billing/service.d.ts +124 -0
- package/dist/billing/service.d.ts.map +1 -0
- package/dist/billing/service.js +470 -0
- package/dist/billing/service.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +43 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +212 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/project.d.ts +12 -0
- package/dist/cli/commands/project.d.ts.map +1 -0
- package/dist/cli/commands/project.js +49 -0
- package/dist/cli/commands/project.js.map +1 -0
- package/dist/cli/docker.d.ts +50 -0
- package/dist/cli/docker.d.ts.map +1 -0
- package/dist/cli/docker.js +84 -0
- package/dist/cli/docker.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +198 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/output.d.ts +30 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +66 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/templates.d.ts +52 -0
- package/dist/cli/templates.d.ts.map +1 -0
- package/dist/cli/templates.js +225 -0
- package/dist/cli/templates.js.map +1 -0
- package/dist/config/client.d.ts +60 -0
- package/dist/config/client.d.ts.map +1 -0
- package/dist/config/client.js +94 -0
- package/dist/config/client.js.map +1 -0
- package/dist/config/config-loader.d.ts +2 -0
- package/dist/config/config-loader.d.ts.map +1 -0
- package/dist/config/config-loader.js +2 -0
- package/dist/config/config-loader.js.map +1 -0
- package/dist/config/env.d.ts +24 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +40 -0
- package/dist/config/env.js.map +1 -0
- package/dist/config/errors.d.ts +17 -0
- package/dist/config/errors.d.ts.map +1 -0
- package/dist/config/errors.js +26 -0
- package/dist/config/errors.js.map +1 -0
- package/dist/config/index.d.ts +72 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +106 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/runtime.d.ts +15 -0
- package/dist/config/runtime.d.ts.map +1 -0
- package/dist/config/runtime.js +22 -0
- package/dist/config/runtime.js.map +1 -0
- package/dist/config/sections.d.ts +226 -0
- package/dist/config/sections.d.ts.map +1 -0
- package/dist/config/sections.js +141 -0
- package/dist/config/sections.js.map +1 -0
- package/dist/db/client.d.ts +43 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +77 -0
- package/dist/db/client.js.map +1 -0
- package/dist/db/errors.d.ts +39 -0
- package/dist/db/errors.d.ts.map +1 -0
- package/dist/db/errors.js +67 -0
- package/dist/db/errors.js.map +1 -0
- package/dist/db/index.d.ts +10 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +10 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrate.d.ts +21 -0
- package/dist/db/migrate.d.ts.map +1 -0
- package/dist/db/migrate.js +28 -0
- package/dist/db/migrate.js.map +1 -0
- package/dist/db/schema/_shared.d.ts +30 -0
- package/dist/db/schema/_shared.d.ts.map +1 -0
- package/dist/db/schema/_shared.js +36 -0
- package/dist/db/schema/_shared.js.map +1 -0
- package/dist/db/schema/apikeys.d.ts +263 -0
- package/dist/db/schema/apikeys.d.ts.map +1 -0
- package/dist/db/schema/apikeys.js +70 -0
- package/dist/db/schema/apikeys.js.map +1 -0
- package/dist/db/schema/authorization.d.ts +465 -0
- package/dist/db/schema/authorization.d.ts.map +1 -0
- package/dist/db/schema/authorization.js +134 -0
- package/dist/db/schema/authorization.js.map +1 -0
- package/dist/db/schema/billing.d.ts +1100 -0
- package/dist/db/schema/billing.d.ts.map +1 -0
- package/dist/db/schema/billing.js +223 -0
- package/dist/db/schema/billing.js.map +1 -0
- package/dist/db/schema/events.d.ts +161 -0
- package/dist/db/schema/events.d.ts.map +1 -0
- package/dist/db/schema/events.js +66 -0
- package/dist/db/schema/events.js.map +1 -0
- package/dist/db/schema/features.d.ts +243 -0
- package/dist/db/schema/features.d.ts.map +1 -0
- package/dist/db/schema/features.js +87 -0
- package/dist/db/schema/features.js.map +1 -0
- package/dist/db/schema/files.d.ts +253 -0
- package/dist/db/schema/files.d.ts.map +1 -0
- package/dist/db/schema/files.js +74 -0
- package/dist/db/schema/files.js.map +1 -0
- package/dist/db/schema/index.d.ts +38 -0
- package/dist/db/schema/index.d.ts.map +1 -0
- package/dist/db/schema/index.js +38 -0
- package/dist/db/schema/index.js.map +1 -0
- package/dist/db/schema/invitations.d.ts +214 -0
- package/dist/db/schema/invitations.d.ts.map +1 -0
- package/dist/db/schema/invitations.js +80 -0
- package/dist/db/schema/invitations.js.map +1 -0
- package/dist/db/schema/messaging.d.ts +442 -0
- package/dist/db/schema/messaging.d.ts.map +1 -0
- package/dist/db/schema/messaging.js +120 -0
- package/dist/db/schema/messaging.js.map +1 -0
- package/dist/db/schema/users.d.ts +246 -0
- package/dist/db/schema/users.d.ts.map +1 -0
- package/dist/db/schema/users.js +60 -0
- package/dist/db/schema/users.js.map +1 -0
- package/dist/db/schema/webhooks.d.ts +693 -0
- package/dist/db/schema/webhooks.d.ts.map +1 -0
- package/dist/db/schema/webhooks.js +147 -0
- package/dist/db/schema/webhooks.js.map +1 -0
- package/dist/db/schema/workspaces.d.ts +196 -0
- package/dist/db/schema/workspaces.d.ts.map +1 -0
- package/dist/db/schema/workspaces.js +57 -0
- package/dist/db/schema/workspaces.js.map +1 -0
- package/dist/db/types.d.ts +18 -0
- package/dist/db/types.d.ts.map +1 -0
- package/dist/db/types.js +2 -0
- package/dist/db/types.js.map +1 -0
- package/dist/email/adapters.d.ts +29 -0
- package/dist/email/adapters.d.ts.map +1 -0
- package/dist/email/adapters.js +60 -0
- package/dist/email/adapters.js.map +1 -0
- package/dist/email/index.d.ts +20 -0
- package/dist/email/index.d.ts.map +1 -0
- package/dist/email/index.js +79 -0
- package/dist/email/index.js.map +1 -0
- package/dist/email/provider.d.ts +47 -0
- package/dist/email/provider.d.ts.map +1 -0
- package/dist/email/provider.js +7 -0
- package/dist/email/provider.js.map +1 -0
- package/dist/email/resend.d.ts +22 -0
- package/dist/email/resend.d.ts.map +1 -0
- package/dist/email/resend.js +51 -0
- package/dist/email/resend.js.map +1 -0
- package/dist/email/service.d.ts +55 -0
- package/dist/email/service.d.ts.map +1 -0
- package/dist/email/service.js +87 -0
- package/dist/email/service.js.map +1 -0
- package/dist/email/templates.d.ts +81 -0
- package/dist/email/templates.d.ts.map +1 -0
- package/dist/email/templates.js +84 -0
- package/dist/email/templates.js.map +1 -0
- package/dist/entitlements/index.d.ts +10 -0
- package/dist/entitlements/index.d.ts.map +1 -0
- package/dist/entitlements/index.js +28 -0
- package/dist/entitlements/index.js.map +1 -0
- package/dist/entitlements/service.d.ts +83 -0
- package/dist/entitlements/service.d.ts.map +1 -0
- package/dist/entitlements/service.js +158 -0
- package/dist/entitlements/service.js.map +1 -0
- package/dist/errors.d.ts +85 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +95 -0
- package/dist/errors.js.map +1 -0
- package/dist/events/core-events.d.ts +120 -0
- package/dist/events/core-events.d.ts.map +1 -0
- package/dist/events/core-events.js +109 -0
- package/dist/events/core-events.js.map +1 -0
- package/dist/events/index.d.ts +15 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +58 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/publisher.d.ts +46 -0
- package/dist/events/publisher.d.ts.map +1 -0
- package/dist/events/publisher.js +54 -0
- package/dist/events/publisher.js.map +1 -0
- package/dist/events/registry.d.ts +87 -0
- package/dist/events/registry.d.ts.map +1 -0
- package/dist/events/registry.js +34 -0
- package/dist/events/registry.js.map +1 -0
- package/dist/events/service.d.ts +78 -0
- package/dist/events/service.d.ts.map +1 -0
- package/dist/events/service.js +182 -0
- package/dist/events/service.js.map +1 -0
- package/dist/features/bucket.d.ts +22 -0
- package/dist/features/bucket.d.ts.map +1 -0
- package/dist/features/bucket.js +42 -0
- package/dist/features/bucket.js.map +1 -0
- package/dist/features/index.d.ts +15 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +78 -0
- package/dist/features/index.js.map +1 -0
- package/dist/features/registry.d.ts +51 -0
- package/dist/features/registry.d.ts.map +1 -0
- package/dist/features/registry.js +52 -0
- package/dist/features/registry.js.map +1 -0
- package/dist/features/service.d.ts +78 -0
- package/dist/features/service.d.ts.map +1 -0
- package/dist/features/service.js +207 -0
- package/dist/features/service.js.map +1 -0
- package/dist/files/index.d.ts +6 -0
- package/dist/files/index.d.ts.map +1 -0
- package/dist/files/index.js +64 -0
- package/dist/files/index.js.map +1 -0
- package/dist/files/service.d.ts +92 -0
- package/dist/files/service.d.ts.map +1 -0
- package/dist/files/service.js +303 -0
- package/dist/files/service.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs/backend.d.ts +23 -0
- package/dist/jobs/backend.d.ts.map +1 -0
- package/dist/jobs/backend.js +23 -0
- package/dist/jobs/backend.js.map +1 -0
- package/dist/jobs/index.d.ts +29 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +114 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/service.d.ts +67 -0
- package/dist/jobs/service.d.ts.map +1 -0
- package/dist/jobs/service.js +139 -0
- package/dist/jobs/service.js.map +1 -0
- package/dist/jobs/types.d.ts +78 -0
- package/dist/jobs/types.d.ts.map +1 -0
- package/dist/jobs/types.js +4 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/logger/default.d.ts +7 -0
- package/dist/logger/default.d.ts.map +1 -0
- package/dist/logger/default.js +28 -0
- package/dist/logger/default.js.map +1 -0
- package/dist/logger/index.d.ts +24 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +90 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/redact.d.ts +40 -0
- package/dist/logger/redact.d.ts.map +1 -0
- package/dist/logger/redact.js +178 -0
- package/dist/logger/redact.js.map +1 -0
- package/dist/logger/service.d.ts +14 -0
- package/dist/logger/service.d.ts.map +1 -0
- package/dist/logger/service.js +56 -0
- package/dist/logger/service.js.map +1 -0
- package/dist/logger/sinks.d.ts +37 -0
- package/dist/logger/sinks.d.ts.map +1 -0
- package/dist/logger/sinks.js +135 -0
- package/dist/logger/sinks.js.map +1 -0
- package/dist/logger/types.d.ts +47 -0
- package/dist/logger/types.d.ts.map +1 -0
- package/dist/logger/types.js +8 -0
- package/dist/logger/types.js.map +1 -0
- package/dist/notifications/index.d.ts +8 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +72 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/service.d.ts +79 -0
- package/dist/notifications/service.d.ts.map +1 -0
- package/dist/notifications/service.js +164 -0
- package/dist/notifications/service.js.map +1 -0
- package/dist/realtime/channels.d.ts +37 -0
- package/dist/realtime/channels.d.ts.map +1 -0
- package/dist/realtime/channels.js +58 -0
- package/dist/realtime/channels.js.map +1 -0
- package/dist/realtime/index.d.ts +19 -0
- package/dist/realtime/index.d.ts.map +1 -0
- package/dist/realtime/index.js +118 -0
- package/dist/realtime/index.js.map +1 -0
- package/dist/realtime/postgres.d.ts +48 -0
- package/dist/realtime/postgres.d.ts.map +1 -0
- package/dist/realtime/postgres.js +151 -0
- package/dist/realtime/postgres.js.map +1 -0
- package/dist/realtime/service.d.ts +75 -0
- package/dist/realtime/service.d.ts.map +1 -0
- package/dist/realtime/service.js +103 -0
- package/dist/realtime/service.js.map +1 -0
- package/dist/realtime/sse.d.ts +55 -0
- package/dist/realtime/sse.d.ts.map +1 -0
- package/dist/realtime/sse.js +123 -0
- package/dist/realtime/sse.js.map +1 -0
- package/dist/realtime/transport.d.ts +52 -0
- package/dist/realtime/transport.d.ts.map +1 -0
- package/dist/realtime/transport.js +2 -0
- package/dist/realtime/transport.js.map +1 -0
- package/dist/storage/index.d.ts +18 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +89 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/keys.d.ts +50 -0
- package/dist/storage/keys.d.ts.map +1 -0
- package/dist/storage/keys.js +120 -0
- package/dist/storage/keys.js.map +1 -0
- package/dist/storage/memory.d.ts +32 -0
- package/dist/storage/memory.d.ts.map +1 -0
- package/dist/storage/memory.js +84 -0
- package/dist/storage/memory.js.map +1 -0
- package/dist/storage/provider.d.ts +93 -0
- package/dist/storage/provider.d.ts.map +1 -0
- package/dist/storage/provider.js +2 -0
- package/dist/storage/provider.js.map +1 -0
- package/dist/storage/s3.d.ts +34 -0
- package/dist/storage/s3.d.ts.map +1 -0
- package/dist/storage/s3.js +175 -0
- package/dist/storage/s3.js.map +1 -0
- package/dist/storage/service.d.ts +86 -0
- package/dist/storage/service.d.ts.map +1 -0
- package/dist/storage/service.js +107 -0
- package/dist/storage/service.js.map +1 -0
- package/dist/storage/sigv4.d.ts +58 -0
- package/dist/storage/sigv4.d.ts.map +1 -0
- package/dist/storage/sigv4.js +114 -0
- package/dist/storage/sigv4.js.map +1 -0
- package/dist/streams/client.d.ts +91 -0
- package/dist/streams/client.d.ts.map +1 -0
- package/dist/streams/client.js +128 -0
- package/dist/streams/client.js.map +1 -0
- package/dist/streams/events.d.ts +68 -0
- package/dist/streams/events.d.ts.map +1 -0
- package/dist/streams/events.js +81 -0
- package/dist/streams/events.js.map +1 -0
- package/dist/streams/index.d.ts +47 -0
- package/dist/streams/index.d.ts.map +1 -0
- package/dist/streams/index.js +47 -0
- package/dist/streams/index.js.map +1 -0
- package/dist/streams/realtime.d.ts +27 -0
- package/dist/streams/realtime.d.ts.map +1 -0
- package/dist/streams/realtime.js +50 -0
- package/dist/streams/realtime.js.map +1 -0
- package/dist/streams/state.d.ts +26 -0
- package/dist/streams/state.d.ts.map +1 -0
- package/dist/streams/state.js +34 -0
- package/dist/streams/state.js.map +1 -0
- package/dist/users/index.d.ts +9 -0
- package/dist/users/index.d.ts.map +1 -0
- package/dist/users/index.js +23 -0
- package/dist/users/index.js.map +1 -0
- package/dist/users/service.d.ts +43 -0
- package/dist/users/service.d.ts.map +1 -0
- package/dist/users/service.js +113 -0
- package/dist/users/service.js.map +1 -0
- package/dist/webhooks/inbound.d.ts +70 -0
- package/dist/webhooks/inbound.d.ts.map +1 -0
- package/dist/webhooks/inbound.js +146 -0
- package/dist/webhooks/inbound.js.map +1 -0
- package/dist/webhooks/index.d.ts +12 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +65 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/webhooks/outgoing.d.ts +89 -0
- package/dist/webhooks/outgoing.d.ts.map +1 -0
- package/dist/webhooks/outgoing.js +375 -0
- package/dist/webhooks/outgoing.js.map +1 -0
- package/dist/webhooks/signature.d.ts +40 -0
- package/dist/webhooks/signature.d.ts.map +1 -0
- package/dist/webhooks/signature.js +77 -0
- package/dist/webhooks/signature.js.map +1 -0
- package/dist/workspaces/context.d.ts +30 -0
- package/dist/workspaces/context.d.ts.map +1 -0
- package/dist/workspaces/context.js +12 -0
- package/dist/workspaces/context.js.map +1 -0
- package/dist/workspaces/index.d.ts +5 -0
- package/dist/workspaces/index.d.ts.map +1 -0
- package/dist/workspaces/index.js +21 -0
- package/dist/workspaces/index.js.map +1 -0
- package/dist/workspaces/service.d.ts +126 -0
- package/dist/workspaces/service.d.ts.map +1 -0
- package/dist/workspaces/service.js +495 -0
- package/dist/workspaces/service.js.map +1 -0
- package/docs/README.md +71 -0
- package/docs/api-keys.md +184 -0
- package/docs/audit.md +198 -0
- package/docs/auth.md +196 -0
- package/docs/authorization.md +225 -0
- package/docs/billing.md +293 -0
- package/docs/cli.md +238 -0
- package/docs/config.md +163 -0
- package/docs/db.md +219 -0
- package/docs/email.md +222 -0
- package/docs/entitlements.md +194 -0
- package/docs/errors.md +158 -0
- package/docs/events.md +279 -0
- package/docs/feature-flags.md +237 -0
- package/docs/files.md +229 -0
- package/docs/jobs.md +288 -0
- package/docs/logger.md +269 -0
- package/docs/notifications.md +179 -0
- package/docs/publishing.md +128 -0
- package/docs/realtime.md +360 -0
- package/docs/storage.md +279 -0
- package/docs/streams.md +296 -0
- package/docs/users.md +117 -0
- package/docs/webhooks.md +272 -0
- package/docs/workspaces.md +269 -0
- package/drizzle/0000_init_users.sql +21 -0
- package/drizzle/0001_workspaces_roles_permissions.sql +86 -0
- package/drizzle/0002_billing_entitlements.sql +97 -0
- package/drizzle/0003_events.sql +17 -0
- package/drizzle/0004_notifications_audit.sql +64 -0
- package/drizzle/0005_api_keys_webhooks.sql +77 -0
- package/drizzle/0006_feature_flags.sql +22 -0
- package/drizzle/0007_files.sql +23 -0
- package/drizzle/meta/0000_snapshot.json +160 -0
- package/drizzle/meta/0001_snapshot.json +837 -0
- package/drizzle/meta/0002_snapshot.json +1580 -0
- package/drizzle/meta/0003_snapshot.json +1751 -0
- package/drizzle/meta/0004_snapshot.json +2109 -0
- package/drizzle/meta/0005_snapshot.json +2719 -0
- package/drizzle/meta/0006_snapshot.json +2909 -0
- package/drizzle/meta/0007_snapshot.json +3113 -0
- package/drizzle/meta/_journal.json +62 -0
- package/package.json +180 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public jobs surface: `@digimuza/saas-core/jobs`. Server-only.
|
|
3
|
+
*
|
|
4
|
+
* Trigger.dev owns durable execution — retries, scheduling, cron, waits,
|
|
5
|
+
* concurrency, multi-step workflows and run observability. The core does not
|
|
6
|
+
* reimplement any of it and stores no run state: a `job_runs` table would be a
|
|
7
|
+
* second, always-slightly-wrong copy of what Trigger.dev already knows.
|
|
8
|
+
*
|
|
9
|
+
* What the core adds is exactly two things:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Tenant attribution.** A job outlives the request that queued it, so the
|
|
12
|
+
* workspace travels with it — in the payload envelope, in Trigger.dev tags,
|
|
13
|
+
* and in run metadata.
|
|
14
|
+
* 2. **Application events.** `job.started` / `.progress` / `.completed` /
|
|
15
|
+
* `.failed`, so the rest of the system (and eventually a browser) can react.
|
|
16
|
+
*
|
|
17
|
+
* Everything else is Trigger.dev's, and the SDK is re-exported below rather than
|
|
18
|
+
* wrapped, so advanced use is never blocked.
|
|
19
|
+
*
|
|
20
|
+
* ## Queueing work
|
|
21
|
+
*
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { jobs } from "@digimuza/saas-core/jobs";
|
|
24
|
+
*
|
|
25
|
+
* const handle = await jobs.trigger("resize-image", { assetId }, {
|
|
26
|
+
* workspaceId: context.workspaceId,
|
|
27
|
+
* actorId: user.id,
|
|
28
|
+
* idempotencyKey: requestId,
|
|
29
|
+
* concurrencyKey: context.workspaceId, // one tenant cannot starve another
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* ## Writing the task
|
|
34
|
+
*
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { task } from "@digimuza/saas-core/jobs";
|
|
37
|
+
* import type { JobPayload } from "@digimuza/saas-core/jobs";
|
|
38
|
+
* import { workspaces } from "@digimuza/saas-core/workspaces";
|
|
39
|
+
* import { jobs } from "@digimuza/saas-core/jobs";
|
|
40
|
+
*
|
|
41
|
+
* export const resizeImage = task({
|
|
42
|
+
* id: "resize-image",
|
|
43
|
+
* run: async (payload: JobPayload<{ assetId: string }>, { ctx }) => {
|
|
44
|
+
* const reporter = jobs.reporter({ runId: ctx.run.id, taskId: ctx.task.id }, payload.tenant);
|
|
45
|
+
* await reporter.started();
|
|
46
|
+
*
|
|
47
|
+
* // Re-verify: the workspace may have been deleted, or the actor removed,
|
|
48
|
+
* // between queueing and running. The payload is attribution, not authority.
|
|
49
|
+
* const context = await workspaces.requireContext({
|
|
50
|
+
* userId: payload.tenant.actorId!,
|
|
51
|
+
* workspaceId: payload.tenant.workspaceId,
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* try {
|
|
55
|
+
* await doWork(context, payload.data);
|
|
56
|
+
* await reporter.completed();
|
|
57
|
+
* } catch (error) {
|
|
58
|
+
* await reporter.failed({ error, attempt: ctx.attempt.number });
|
|
59
|
+
* throw error; // rethrow so Trigger.dev retries
|
|
60
|
+
* }
|
|
61
|
+
* },
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* ## Configuration
|
|
66
|
+
*
|
|
67
|
+
* Call {@link configureJobs} once at startup so the Infisical-injected `jobs`
|
|
68
|
+
* configuration reaches the SDK. Without it the SDK falls back to reading
|
|
69
|
+
* `TRIGGER_SECRET_KEY` from the environment itself, which works but bypasses the
|
|
70
|
+
* validation every other section gets.
|
|
71
|
+
*/
|
|
72
|
+
import { config } from "../config/index.js";
|
|
73
|
+
import { events as coreEventsService } from "../events/index.js";
|
|
74
|
+
import { createTriggerDevBackend } from "./backend.js";
|
|
75
|
+
import { createJobsService } from "./service.js";
|
|
76
|
+
export { createTriggerDevBackend } from "./backend.js";
|
|
77
|
+
export { createJobsService, describeJobError, } from "./service.js";
|
|
78
|
+
export { ACTOR_TAG_PREFIX, WORKSPACE_TAG_PREFIX, } from "./types.js";
|
|
79
|
+
/**
|
|
80
|
+
* The Trigger.dev SDK, re-exported unchanged.
|
|
81
|
+
*
|
|
82
|
+
* Deliberate: the spec is explicit that advanced applications must be able to
|
|
83
|
+
* reach Trigger.dev's own capabilities. Wrapping `task`, `schedules` or `wait`
|
|
84
|
+
* would mean re-documenting and re-typing a mature API for no gain, and would
|
|
85
|
+
* lag behind it.
|
|
86
|
+
*/
|
|
87
|
+
export { batch, configure as configureTriggerClient, idempotencyKeys, logger, metadata, queue, queues, retry, runs, schedules, schemaTask, tags, task, tasks, timeout, usage, wait, } from "@trigger.dev/sdk";
|
|
88
|
+
/**
|
|
89
|
+
* Point the Trigger.dev SDK at the configured credentials.
|
|
90
|
+
*
|
|
91
|
+
* Idempotent; call it from application startup and from the Trigger.dev config
|
|
92
|
+
* file. Reads the `jobs` configuration section, so it throws `ConfigError` if
|
|
93
|
+
* Trigger.dev is not configured.
|
|
94
|
+
*/
|
|
95
|
+
export async function configureJobs() {
|
|
96
|
+
const { configure } = await import("@trigger.dev/sdk");
|
|
97
|
+
const jobsConfig = config.jobs;
|
|
98
|
+
configure({
|
|
99
|
+
// `secretKey` is deprecated upstream in favour of `accessToken`.
|
|
100
|
+
accessToken: jobsConfig.secretKey,
|
|
101
|
+
baseURL: jobsConfig.apiUrl,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Default service, wired to Trigger.dev and the core event registry.
|
|
106
|
+
*
|
|
107
|
+
* The backend is built eagerly but imports the SDK lazily, so this module stays
|
|
108
|
+
* importable in a process that never queues anything.
|
|
109
|
+
*/
|
|
110
|
+
export const jobs = createJobsService({
|
|
111
|
+
backend: createTriggerDevBackend(),
|
|
112
|
+
events: coreEventsService,
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/jobs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,cAAc,CAAC;AAEnE,OAAO,EAAE,uBAAuB,EAAmB,MAAM,cAAc,CAAC;AACxE,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GAKjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,GAOrB,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,OAAO,EACL,KAAK,EACL,SAAS,IAAI,sBAAsB,EACnC,eAAe,EACf,MAAM,EACN,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,EACL,IAAI,EACJ,SAAS,EACT,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,OAAO,EACP,KAAK,EACL,IAAI,GACL,MAAM,kBAAkB,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC;IAE/B,SAAS,CAAC;QACR,iEAAiE;QACjE,WAAW,EAAE,UAAU,CAAC,SAAS;QACjC,OAAO,EAAE,UAAU,CAAC,MAAM;KAC3B,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAgB,iBAAiB,CAAC;IACjD,OAAO,EAAE,uBAAuB,EAAE;IAClC,MAAM,EAAE,iBAAiB;CAC1B,CAAC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { CoreEventPublisher } from "../events/publisher.ts";
|
|
2
|
+
import type { JobBackend } from "./backend.ts";
|
|
3
|
+
import { type JobHandle, type JobTenant, type JobTriggerOptions, type TriggerJobOptions } from "./types.ts";
|
|
4
|
+
export interface JobProgress {
|
|
5
|
+
readonly percent?: number;
|
|
6
|
+
readonly message?: string;
|
|
7
|
+
readonly step?: number;
|
|
8
|
+
readonly totalSteps?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Emits `job.*` application events from inside a running task.
|
|
12
|
+
*
|
|
13
|
+
* Trigger.dev already tracks run state; these events exist so the *application*
|
|
14
|
+
* can react and a browser can watch progress. They are not a second source of
|
|
15
|
+
* truth, and losing one does not lose the run.
|
|
16
|
+
*/
|
|
17
|
+
export interface JobReporter {
|
|
18
|
+
started(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Report progress. Throttle it — each call writes a row, and a tight loop
|
|
21
|
+
* would turn the events table into a firehose.
|
|
22
|
+
*/
|
|
23
|
+
progress(progress: JobProgress): Promise<void>;
|
|
24
|
+
completed(result?: {
|
|
25
|
+
durationMs?: number;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
failed(input: {
|
|
28
|
+
error: unknown;
|
|
29
|
+
attempt?: number;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export interface JobsService {
|
|
33
|
+
/**
|
|
34
|
+
* Queue a task for a workspace.
|
|
35
|
+
*
|
|
36
|
+
* The payload is wrapped in a {@link JobPayload} envelope and the run is tagged
|
|
37
|
+
* with the workspace and actor, so runs are filterable per tenant in the
|
|
38
|
+
* Trigger.dev dashboard.
|
|
39
|
+
*/
|
|
40
|
+
trigger<TData>(taskId: string, data: TData, options: TriggerJobOptions): Promise<JobHandle>;
|
|
41
|
+
/**
|
|
42
|
+
* Queue a task that belongs to no tenant — a nightly sweep, a catalogue sync.
|
|
43
|
+
*
|
|
44
|
+
* Separate from {@link trigger} rather than accepting a null workspace, so
|
|
45
|
+
* forgetting to attribute tenant work is a deliberate choice and not a typo.
|
|
46
|
+
*/
|
|
47
|
+
triggerSystem<TData>(taskId: string, data: TData, options?: JobTriggerOptions): Promise<JobHandle>;
|
|
48
|
+
/** Build a reporter for the run currently executing. */
|
|
49
|
+
reporter(run: {
|
|
50
|
+
runId: string;
|
|
51
|
+
taskId: string;
|
|
52
|
+
}, tenant: JobTenant | null): JobReporter;
|
|
53
|
+
}
|
|
54
|
+
export interface JobsServiceDeps {
|
|
55
|
+
readonly backend: JobBackend;
|
|
56
|
+
/**
|
|
57
|
+
* Optional event publisher. Without it, {@link JobsService.reporter} returns a
|
|
58
|
+
* reporter that does nothing — so a task can call it unconditionally.
|
|
59
|
+
*/
|
|
60
|
+
readonly events?: CoreEventPublisher;
|
|
61
|
+
readonly now?: () => Date;
|
|
62
|
+
}
|
|
63
|
+
/** Reduce an unknown throwable to a bounded string. */
|
|
64
|
+
declare function describeError(error: unknown): string;
|
|
65
|
+
export declare function createJobsService(deps: JobsServiceDeps): JobsService;
|
|
66
|
+
export { describeError as describeJobError };
|
|
67
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/jobs/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAGL,KAAK,SAAS,EAEd,KAAK,SAAS,EACd,KAAK,iBAAiB,EAEtB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAKpB,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,IAAI,OAAO,CAA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,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { InvalidInputError } from "../errors.js";
|
|
2
|
+
import { ACTOR_TAG_PREFIX, WORKSPACE_TAG_PREFIX, } from "./types.js";
|
|
3
|
+
/** Trigger.dev caps tag length; keep messages short so they are not rejected. */
|
|
4
|
+
const MAX_ERROR_LENGTH = 2000;
|
|
5
|
+
function mergeTags(tenant, tags) {
|
|
6
|
+
const own = tenant === null
|
|
7
|
+
? []
|
|
8
|
+
: [
|
|
9
|
+
`${WORKSPACE_TAG_PREFIX}${tenant.workspaceId}`,
|
|
10
|
+
...(tenant.actorId !== null ? [`${ACTOR_TAG_PREFIX}${tenant.actorId}`] : []),
|
|
11
|
+
];
|
|
12
|
+
// De-duplicated: Trigger.dev counts tags against a per-run limit.
|
|
13
|
+
return [...new Set([...own, ...(tags ?? [])])];
|
|
14
|
+
}
|
|
15
|
+
/** Reduce an unknown throwable to a bounded string. */
|
|
16
|
+
function describeError(error) {
|
|
17
|
+
const message = error instanceof Error
|
|
18
|
+
? error.message
|
|
19
|
+
: typeof error === "string"
|
|
20
|
+
? error
|
|
21
|
+
: "Unknown error";
|
|
22
|
+
return message.length > MAX_ERROR_LENGTH ? `${message.slice(0, MAX_ERROR_LENGTH - 1)}…` : message;
|
|
23
|
+
}
|
|
24
|
+
export function createJobsService(deps) {
|
|
25
|
+
const now = deps.now ?? (() => new Date());
|
|
26
|
+
async function send(taskId, payload, tenant, options) {
|
|
27
|
+
if (taskId.trim().length === 0) {
|
|
28
|
+
throw new InvalidInputError("A task id is required.");
|
|
29
|
+
}
|
|
30
|
+
const { tags, metadata, ...rest } = options;
|
|
31
|
+
const handle = await deps.backend.trigger(taskId, payload, {
|
|
32
|
+
...rest,
|
|
33
|
+
tags: mergeTags(tenant, tags),
|
|
34
|
+
metadata: {
|
|
35
|
+
...(metadata ?? {}),
|
|
36
|
+
/**
|
|
37
|
+
* Duplicated into metadata as well as the payload: metadata is visible in
|
|
38
|
+
* the Trigger.dev dashboard and searchable there, which is what makes a
|
|
39
|
+
* production incident traceable back to a tenant.
|
|
40
|
+
*/
|
|
41
|
+
...(tenant !== null
|
|
42
|
+
? { workspaceId: tenant.workspaceId, actorId: tenant.actorId }
|
|
43
|
+
: {}),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
return { runId: handle.id, taskId };
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
async trigger(taskId, data, options) {
|
|
50
|
+
const { workspaceId, actorId, ...triggerOptions } = options;
|
|
51
|
+
if (workspaceId.trim().length === 0) {
|
|
52
|
+
throw new InvalidInputError("A workspaceId is required to trigger a tenant job.");
|
|
53
|
+
}
|
|
54
|
+
const tenant = { workspaceId, actorId: actorId ?? null };
|
|
55
|
+
return send(taskId, { tenant, data }, tenant, triggerOptions);
|
|
56
|
+
},
|
|
57
|
+
async triggerSystem(taskId, data, options = {}) {
|
|
58
|
+
return send(taskId, { tenant: null, data }, null, options);
|
|
59
|
+
},
|
|
60
|
+
reporter(run, tenant) {
|
|
61
|
+
const publisher = deps.events;
|
|
62
|
+
// A no-op reporter, so a task never has to branch on whether events exist.
|
|
63
|
+
if (publisher === undefined) {
|
|
64
|
+
return {
|
|
65
|
+
started: async () => undefined,
|
|
66
|
+
progress: async () => undefined,
|
|
67
|
+
completed: async () => undefined,
|
|
68
|
+
failed: async () => undefined,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const workspaceId = tenant?.workspaceId ?? null;
|
|
72
|
+
const actorId = tenant?.actorId ?? null;
|
|
73
|
+
const startedAt = now();
|
|
74
|
+
async function emit(input) {
|
|
75
|
+
const { event, created } = await publisher.record(input);
|
|
76
|
+
if (created) {
|
|
77
|
+
await publisher.dispatch(event);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
async started() {
|
|
82
|
+
await emit({
|
|
83
|
+
type: "job.started",
|
|
84
|
+
workspaceId,
|
|
85
|
+
actorId,
|
|
86
|
+
/**
|
|
87
|
+
* Keyed on the run so a Trigger.dev retry re-executing the task body
|
|
88
|
+
* does not announce a second start for the same run.
|
|
89
|
+
*/
|
|
90
|
+
idempotencyKey: run.runId,
|
|
91
|
+
data: { runId: run.runId, taskId: run.taskId },
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
async progress(progress) {
|
|
95
|
+
await emit({
|
|
96
|
+
type: "job.progress",
|
|
97
|
+
workspaceId,
|
|
98
|
+
actorId,
|
|
99
|
+
// Progress is intentionally not deduplicated; each tick is news.
|
|
100
|
+
data: { runId: run.runId, taskId: run.taskId, ...progress },
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
async completed(result = {}) {
|
|
104
|
+
await emit({
|
|
105
|
+
type: "job.completed",
|
|
106
|
+
workspaceId,
|
|
107
|
+
actorId,
|
|
108
|
+
idempotencyKey: run.runId,
|
|
109
|
+
data: {
|
|
110
|
+
runId: run.runId,
|
|
111
|
+
taskId: run.taskId,
|
|
112
|
+
durationMs: result.durationMs ?? now().getTime() - startedAt.getTime(),
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
async failed(input) {
|
|
117
|
+
await emit({
|
|
118
|
+
type: "job.failed",
|
|
119
|
+
workspaceId,
|
|
120
|
+
actorId,
|
|
121
|
+
/**
|
|
122
|
+
* Keyed per attempt, not per run: each failed attempt is a distinct
|
|
123
|
+
* fact, and a run that fails twice should say so twice.
|
|
124
|
+
*/
|
|
125
|
+
idempotencyKey: input.attempt !== undefined ? `${run.runId}:${input.attempt}` : run.runId,
|
|
126
|
+
data: {
|
|
127
|
+
runId: run.runId,
|
|
128
|
+
taskId: run.taskId,
|
|
129
|
+
error: describeError(input.error),
|
|
130
|
+
...(input.attempt !== undefined ? { attempt: input.attempt } : {}),
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
export { describeError as describeJobError };
|
|
139
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/jobs/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD,OAAO,EACL,gBAAgB,EAChB,oBAAoB,GAOrB,MAAM,YAAY,CAAC;AAEpB,iFAAiF;AACjF,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAmE9B,SAAS,SAAS,CAAC,MAAwB,EAAE,IAA0B;IACrE,MAAM,GAAG,GAAG,MAAM,KAAK,IAAI;QACzB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;YACE,GAAG,oBAAoB,GAAG,MAAM,CAAC,WAAW,EAAE;YAC9C,GAAG,CAAC,MAAM,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SAC7E,CAAC;IAEN,kEAAkE;IAClE,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,uDAAuD;AACvD,SAAS,aAAa,CAAC,KAAc;IACnC,MAAM,OAAO,GACX,KAAK,YAAY,KAAK;QACpB,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ;YACzB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,eAAe,CAAC;IAExB,OAAO,OAAO,CAAC,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;AACpG,CAAC;AAED,MAAM,UAAU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AAG,CAAC,KAAK;4BAChB,MAAM,EAAE,GAAG,CAAC,MAAM;4BAClB,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC;4BACjC,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;yBACnE;qBACF,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant attribution carried by every job the core triggers.
|
|
3
|
+
*
|
|
4
|
+
* A job outlives the request that queued it, so the workspace it belongs to has
|
|
5
|
+
* to travel with it. This is *attribution*, not authorisation: by the time the
|
|
6
|
+
* task runs, the workspace may have been deleted or the actor removed from it, so
|
|
7
|
+
* a task must re-verify with `workspaces.requireContext()` before touching tenant
|
|
8
|
+
* data.
|
|
9
|
+
*/
|
|
10
|
+
export interface JobTenant {
|
|
11
|
+
readonly workspaceId: string;
|
|
12
|
+
/** The user who queued it. Null for scheduled or system-initiated work. */
|
|
13
|
+
readonly actorId: string | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The envelope a core-triggered task receives.
|
|
17
|
+
*
|
|
18
|
+
* The application's own payload sits under `data`, untouched, so the two never
|
|
19
|
+
* collide — a task payload with its own `tenant` field keeps working.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* export const resizeImage = task({
|
|
23
|
+
* id: "resize-image",
|
|
24
|
+
* run: async (payload: JobPayload<{ assetId: string }>) => {
|
|
25
|
+
* const context = await workspaces.requireContext({
|
|
26
|
+
* userId: payload.tenant.actorId!,
|
|
27
|
+
* workspaceId: payload.tenant.workspaceId,
|
|
28
|
+
* });
|
|
29
|
+
* // ...
|
|
30
|
+
* },
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export interface JobPayload<TData> {
|
|
35
|
+
readonly tenant: JobTenant;
|
|
36
|
+
readonly data: TData;
|
|
37
|
+
}
|
|
38
|
+
/** A payload for work that belongs to no single tenant. */
|
|
39
|
+
export interface SystemJobPayload<TData> {
|
|
40
|
+
readonly tenant: null;
|
|
41
|
+
readonly data: TData;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Trigger.dev options the core passes straight through.
|
|
45
|
+
*
|
|
46
|
+
* Deliberately mirrored rather than re-invented: the core adds tenant tagging
|
|
47
|
+
* and nothing else, so anything Trigger.dev supports stays reachable. Use the
|
|
48
|
+
* re-exported SDK directly for options not listed here.
|
|
49
|
+
*/
|
|
50
|
+
export interface JobTriggerOptions {
|
|
51
|
+
/** Ensures the task runs once per key, even across retried requests. */
|
|
52
|
+
readonly idempotencyKey?: string | string[];
|
|
53
|
+
readonly idempotencyKeyTTL?: string;
|
|
54
|
+
readonly maxAttempts?: number;
|
|
55
|
+
readonly queue?: string;
|
|
56
|
+
/** Limits concurrency within a key — pass a workspace id to fence tenants. */
|
|
57
|
+
readonly concurrencyKey?: string;
|
|
58
|
+
readonly delay?: string | Date;
|
|
59
|
+
readonly ttl?: string | number;
|
|
60
|
+
readonly priority?: number;
|
|
61
|
+
/** Merged with the tenant tags the core adds. */
|
|
62
|
+
readonly tags?: string[];
|
|
63
|
+
readonly metadata?: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
export interface TriggerJobOptions extends JobTriggerOptions {
|
|
66
|
+
readonly workspaceId: string;
|
|
67
|
+
readonly actorId?: string | null;
|
|
68
|
+
}
|
|
69
|
+
/** What a trigger returns: enough to correlate, not a run snapshot. */
|
|
70
|
+
export interface JobHandle {
|
|
71
|
+
/** Trigger.dev run id. Use it to subscribe, cancel, or look the run up. */
|
|
72
|
+
readonly runId: string;
|
|
73
|
+
readonly taskId: string;
|
|
74
|
+
}
|
|
75
|
+
/** Tag prefixes the core attaches, so runs are filterable per tenant. */
|
|
76
|
+
export declare const WORKSPACE_TAG_PREFIX = "workspace:";
|
|
77
|
+
export declare const ACTOR_TAG_PREFIX = "actor:";
|
|
78
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/jobs/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,UAAU,CAAC,KAAK;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;CACtB;AAED,2DAA2D;AAC3D,MAAM,WAAW,gBAAgB,CAAC,KAAK;IACrC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,8EAA8E;IAC9E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,uEAAuE;AACvE,MAAM,WAAW,SAAS;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,gBAAgB,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/jobs/types.ts"],"names":[],"mappings":"AAgFA,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Logger } from "./types.ts";
|
|
2
|
+
export declare function getDefaultLogger(): Logger;
|
|
3
|
+
/** Replace the core's logger. Call once, at startup. */
|
|
4
|
+
export declare function setDefaultLogger(logger: Logger): void;
|
|
5
|
+
/** Silence the core. For tests. */
|
|
6
|
+
export declare function silenceDefaultLogger(): void;
|
|
7
|
+
//# sourceMappingURL=default.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/logger/default.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAiBzC,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAErD;AAED,mCAAmC;AACnC,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createLogger } from "./service.js";
|
|
2
|
+
import { createNoopSink } from "./sinks.js";
|
|
3
|
+
/**
|
|
4
|
+
* The logger the core itself writes to.
|
|
5
|
+
*
|
|
6
|
+
* A mutable default rather than a configuration read, so that importing any core
|
|
7
|
+
* module never requires configuration — a migration script should not need
|
|
8
|
+
* `LOG_LEVEL` set to run. An application calls {@link setDefaultLogger} once at
|
|
9
|
+
* startup with something configured; until then the core logs at `info` to
|
|
10
|
+
* stdout as JSON.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately in its own module with no imports beyond the logger itself: if this
|
|
13
|
+
* pulled in `config`, every module that logs would transitively depend on
|
|
14
|
+
* configuration.
|
|
15
|
+
*/
|
|
16
|
+
let current = createLogger();
|
|
17
|
+
export function getDefaultLogger() {
|
|
18
|
+
return current;
|
|
19
|
+
}
|
|
20
|
+
/** Replace the core's logger. Call once, at startup. */
|
|
21
|
+
export function setDefaultLogger(logger) {
|
|
22
|
+
current = logger;
|
|
23
|
+
}
|
|
24
|
+
/** Silence the core. For tests. */
|
|
25
|
+
export function silenceDefaultLogger() {
|
|
26
|
+
current = createLogger({ sink: createNoopSink() });
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/logger/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5C;;;;;;;;;;;;GAYG;AACH,IAAI,OAAO,GAAW,YAAY,EAAE,CAAC;AAErC,MAAM,UAAU,gBAAgB;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAED,mCAAmC;AACnC,MAAM,UAAU,oBAAoB;IAClC,OAAO,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type CreateLoggerOptions } from "./service.ts";
|
|
2
|
+
import type { Logger } from "./types.ts";
|
|
3
|
+
export { createRedactor, DEFAULT_REDACT_KEYS, REDACTED, type RedactOptions, type Redactor, } from "./redact.ts";
|
|
4
|
+
export { createJsonSink, createMemorySink, createMultiSink, createNoopSink, createPrettySink, type MemorySink, type StreamSinkOptions, } from "./sinks.ts";
|
|
5
|
+
export { createLogger, type CreateLoggerOptions } from "./service.ts";
|
|
6
|
+
export { getDefaultLogger, setDefaultLogger, silenceDefaultLogger, } from "./default.ts";
|
|
7
|
+
export { LOG_LEVEL_RANK, type LogFields, type Logger, type LogLevel, type LogRecord, type LogSink, } from "./types.ts";
|
|
8
|
+
/**
|
|
9
|
+
* A logger built from the `app` configuration section.
|
|
10
|
+
*
|
|
11
|
+
* JSON in production, human-readable outside it. Reads `LOG_LEVEL`, so it throws
|
|
12
|
+
* `ConfigError` if `app` is not configured — which is why the core does not call
|
|
13
|
+
* this itself.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createConfiguredLogger(options?: Omit<CreateLoggerOptions, "level" | "sink">): Logger;
|
|
16
|
+
/**
|
|
17
|
+
* The core's logger, as a stable reference.
|
|
18
|
+
*
|
|
19
|
+
* Each method resolves the current default at call time, so
|
|
20
|
+
* {@link setDefaultLogger} takes effect for code that captured this earlier.
|
|
21
|
+
* Explicit delegation rather than a Proxy — there is no magic to reason about.
|
|
22
|
+
*/
|
|
23
|
+
export declare const logger: Logger;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AA0CA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGtE,OAAO,KAAK,EAAa,MAAM,EAAY,MAAM,YAAY,CAAC;AAE9D,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,cAAc,EACd,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,OAAO,GACb,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,IAAI,CAAC,mBAAmB,EAAE,OAAO,GAAG,MAAM,CAAM,GAAG,MAAM,CAcxG;AAED;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,EAAE,MAUpB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public logger surface: `@digimuza/saas-core/logger`. Server-only.
|
|
3
|
+
*
|
|
4
|
+
* Structured logging with bound context and redaction, over a one-method sink so
|
|
5
|
+
* any backend can be plugged in. No logging dependency: a level check, a merge and
|
|
6
|
+
* a JSON line do not justify one, and the sink seam means adding pino or a hosted
|
|
7
|
+
* collector later is an adapter rather than a migration.
|
|
8
|
+
*
|
|
9
|
+
* ## Setup
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { createConfiguredLogger, setDefaultLogger } from "@digimuza/saas-core/logger";
|
|
13
|
+
*
|
|
14
|
+
* // Once at startup. Reads LOG_LEVEL and APP_ENV.
|
|
15
|
+
* setDefaultLogger(createConfiguredLogger());
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Until then the core logs at `info` to stdout as JSON — so importing a core
|
|
19
|
+
* module never requires configuration.
|
|
20
|
+
*
|
|
21
|
+
* ## Bound context is the point
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* const log = logger.child({ requestId, workspaceId: context.workspaceId, userId: user.id });
|
|
25
|
+
*
|
|
26
|
+
* log.info("project created", { projectId });
|
|
27
|
+
* log.error("indexing failed", { projectId, error });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Bind at the edge and every line beneath is attributable, without threading
|
|
31
|
+
* identifiers through call signatures.
|
|
32
|
+
*
|
|
33
|
+
* ## Redaction is on by default
|
|
34
|
+
*
|
|
35
|
+
* The core handles API keys, session cookies, invitation tokens and webhook
|
|
36
|
+
* secrets. A logger that faithfully serialises whatever it is handed is the
|
|
37
|
+
* easiest way to move all of them into an aggregator a wider audience can read.
|
|
38
|
+
*
|
|
39
|
+
* Sensitive **keys** are replaced whatever the value; credential-shaped **values**
|
|
40
|
+
* are replaced whatever the key. Both, because either alone has a hole.
|
|
41
|
+
*/
|
|
42
|
+
import { config } from "../config/index.js";
|
|
43
|
+
import { createLogger } from "./service.js";
|
|
44
|
+
import { createJsonSink, createPrettySink } from "./sinks.js";
|
|
45
|
+
import { getDefaultLogger } from "./default.js";
|
|
46
|
+
export { createRedactor, DEFAULT_REDACT_KEYS, REDACTED, } from "./redact.js";
|
|
47
|
+
export { createJsonSink, createMemorySink, createMultiSink, createNoopSink, createPrettySink, } from "./sinks.js";
|
|
48
|
+
export { createLogger } from "./service.js";
|
|
49
|
+
export { getDefaultLogger, setDefaultLogger, silenceDefaultLogger, } from "./default.js";
|
|
50
|
+
export { LOG_LEVEL_RANK, } from "./types.js";
|
|
51
|
+
/**
|
|
52
|
+
* A logger built from the `app` configuration section.
|
|
53
|
+
*
|
|
54
|
+
* JSON in production, human-readable outside it. Reads `LOG_LEVEL`, so it throws
|
|
55
|
+
* `ConfigError` if `app` is not configured — which is why the core does not call
|
|
56
|
+
* this itself.
|
|
57
|
+
*/
|
|
58
|
+
export function createConfiguredLogger(options = {}) {
|
|
59
|
+
const app = config.app;
|
|
60
|
+
return createLogger({
|
|
61
|
+
...options,
|
|
62
|
+
level: app.logLevel,
|
|
63
|
+
sink: app.isProduction ? createJsonSink() : createPrettySink(),
|
|
64
|
+
base: {
|
|
65
|
+
// Identifies the source when several services ship to one aggregator.
|
|
66
|
+
app: app.name,
|
|
67
|
+
env: app.environment,
|
|
68
|
+
...options.base,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The core's logger, as a stable reference.
|
|
74
|
+
*
|
|
75
|
+
* Each method resolves the current default at call time, so
|
|
76
|
+
* {@link setDefaultLogger} takes effect for code that captured this earlier.
|
|
77
|
+
* Explicit delegation rather than a Proxy — there is no magic to reason about.
|
|
78
|
+
*/
|
|
79
|
+
export const logger = {
|
|
80
|
+
get level() {
|
|
81
|
+
return getDefaultLogger().level;
|
|
82
|
+
},
|
|
83
|
+
isEnabled: (level) => getDefaultLogger().isEnabled(level),
|
|
84
|
+
debug: (message, fields) => getDefaultLogger().debug(message, fields),
|
|
85
|
+
info: (message, fields) => getDefaultLogger().info(message, fields),
|
|
86
|
+
warn: (message, fields) => getDefaultLogger().warn(message, fields),
|
|
87
|
+
error: (message, fields) => getDefaultLogger().error(message, fields),
|
|
88
|
+
child: (fields) => getDefaultLogger().child(fields),
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@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KAAK;QACP,OAAO,gBAAgB,EAAE,CAAC,KAAK,CAAC;IAClC,CAAC;IACD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC;IACzD,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC;IACrE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;IACnE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;IACnE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC;IACrE,KAAK,EAAE,CAAC,MAAiB,EAAE,EAAE,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;CAC/D,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction.
|
|
3
|
+
*
|
|
4
|
+
* The core handles API keys, session cookies, invitation tokens and webhook
|
|
5
|
+
* signing secrets. A logger that faithfully serialises whatever it is handed is
|
|
6
|
+
* the easiest way to move all of them into a log aggregator that a wider audience
|
|
7
|
+
* can read — so redaction is on by default, and errs toward over-redacting.
|
|
8
|
+
*
|
|
9
|
+
* Two independent passes, because either alone has a hole:
|
|
10
|
+
*
|
|
11
|
+
* - **By key.** `{ apiKey: "..." }` is redacted whatever the value looks like.
|
|
12
|
+
* - **By value.** A credential under an innocent key — `{ input: "dgk_..." }` —
|
|
13
|
+
* is caught by its shape.
|
|
14
|
+
*/
|
|
15
|
+
export declare const REDACTED = "[redacted]";
|
|
16
|
+
/**
|
|
17
|
+
* Field names whose values are never logged.
|
|
18
|
+
*
|
|
19
|
+
* Matched as case-insensitive substrings of the key, so `workosCookiePassword`
|
|
20
|
+
* and `cookie_password` are both caught without enumerating spellings.
|
|
21
|
+
*/
|
|
22
|
+
export declare const DEFAULT_REDACT_KEYS: readonly string[];
|
|
23
|
+
export interface RedactOptions {
|
|
24
|
+
/** Replaces {@link DEFAULT_REDACT_KEYS} entirely. */
|
|
25
|
+
readonly keys?: readonly string[];
|
|
26
|
+
/** Added to the defaults. The usual way to extend. */
|
|
27
|
+
readonly additionalKeys?: readonly string[];
|
|
28
|
+
/**
|
|
29
|
+
* Turn off value scanning.
|
|
30
|
+
*
|
|
31
|
+
* Only sensible when you are certain no credential can reach a field, and you
|
|
32
|
+
* have measured the scan as a problem. Key redaction stays on.
|
|
33
|
+
*/
|
|
34
|
+
readonly disableValueScanning?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface Redactor {
|
|
37
|
+
(value: unknown): unknown;
|
|
38
|
+
}
|
|
39
|
+
export declare function createRedactor(options?: RedactOptions): Redactor;
|
|
40
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/logger/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,QAAQ,eAAe,CAAC;AAErC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAmBhD,CAAC;AAwBF,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,sDAAsD;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C;;;;;OAKG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACzC;AAOD,MAAM,WAAW,QAAQ;IACvB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;CAC3B;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,aAAkB,GAAG,QAAQ,CA6FpE"}
|