@starci/hfs 4.0.8 → 4.0.10
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/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +81 -39
- package/emit/contracts.mjs +56 -9
- package/emit/db-types.mjs +169 -0
- package/emit/events.mjs +41 -0
- package/emit/operations-worker.mjs +1 -1
- package/emit/operations.mjs +2 -2
- package/emit/schema-worker.mjs +1 -1
- package/lint/bound-sys.cjs +50 -0
- package/lint/run.mjs +131 -24
- package/package.json +16 -10
- package/report/sonar.mjs +8 -8
- package/runtime/engine/admission.mjs +308 -0
- package/runtime/engine/canonical-json.mjs +10 -0
- package/runtime/engine/config.mjs +486 -0
- package/runtime/engine/db/blob.mjs +315 -0
- package/runtime/engine/db/ledger-paths.mjs +83 -0
- package/runtime/engine/db/ledger.mjs +1118 -0
- package/runtime/engine/db/machine-connection.mjs +135 -0
- package/runtime/engine/db/machine-schema.mjs +84 -0
- package/runtime/engine/db/machine.mjs +1367 -0
- package/runtime/engine/db/migrations/machine/0001-init.sql +924 -0
- package/runtime/engine/db/migrations/runtime/0001-init.sql +1108 -0
- package/runtime/engine/db/provider-reservations.mjs +101 -0
- package/runtime/engine/digest.mjs +16 -0
- package/runtime/engine/invalid-config.mjs +15 -0
- package/runtime/engine/orca-config.mjs +27 -0
- package/runtime/engine/refuse.mjs +11 -0
- package/runtime/engine/secrets.mjs +130 -0
- package/runtime/knowledge/hfs/canon-pins.yaml +162 -31
- package/runtime/knowledge/hfs/peer-integrations.yaml +2 -2
- package/runtime/knowledge/hfs/rules.yaml +2059 -0
- package/runtime/knowledge/hfs/slots.yaml +912 -120
- package/runtime/knowledge/patterns/be/api.yaml +369 -0
- package/runtime/knowledge/patterns/be/cli.yaml +297 -0
- package/runtime/knowledge/patterns/be/domain.yaml +113 -0
- package/runtime/knowledge/patterns/be/event-bus.yaml +285 -0
- package/runtime/knowledge/patterns/be/jobs.yaml +261 -0
- package/runtime/knowledge/patterns/be/projections.yaml +178 -0
- package/runtime/knowledge/patterns/be/queues.yaml +236 -0
- package/runtime/knowledge/patterns/be/reactors.yaml +140 -0
- package/runtime/knowledge/patterns/be/realtime.yaml +222 -0
- package/runtime/knowledge/patterns/be/saga.yaml +248 -0
- package/runtime/knowledge/patterns/be/webhooks.yaml +221 -0
- package/runtime/knowledge/patterns/fe/folder.yaml +131 -25
- package/runtime/knowledge/sonar-gate.yaml +52 -18
- package/runtime/modules/kernel/failure-codes.yaml +611 -51
- package/runtime/modules/models/registry.yaml +553 -0
- package/runtime/modules/models/runtimes.yaml +695 -0
- package/runtime/modules/ops/_labels.yaml +53 -0
- package/runtime/scripts/api/fs/forbidden-root.mjs +51 -0
- package/runtime/scripts/api/fs/is-link-like.mjs +25 -0
- package/runtime/scripts/api/fs/lib.mjs +16 -2
- package/runtime/scripts/api/fs/safe-remove.mjs +12 -132
- package/runtime/scripts/api/git/config-get.mjs +10 -0
- package/runtime/scripts/api/git/diff.mjs +5 -0
- package/runtime/scripts/api/git/lib.mjs +18 -26
- package/runtime/scripts/api/git/log.mjs +5 -0
- package/runtime/scripts/api/git/ls-files.mjs +6 -0
- package/runtime/scripts/api/git/ls-tree.mjs +5 -0
- package/runtime/scripts/api/git/merge-base.mjs +9 -0
- package/runtime/scripts/api/git/remote.mjs +5 -0
- package/runtime/scripts/api/git/rev-parse-query.mjs +5 -0
- package/runtime/scripts/api/git/show.mjs +6 -0
- package/runtime/scripts/api/node/lib.mjs +14 -0
- package/runtime/scripts/api/node/spawn-node.mjs +6 -0
- package/runtime/scripts/api/process/lib.mjs +111 -0
- package/runtime/scripts/api/process/owned-process.mjs +78 -0
- package/runtime/scripts/api/process/resolve-real-tool.mjs +46 -0
- package/runtime/scripts/api/process/run-program.mjs +7 -0
- package/runtime/scripts/api/process/stop-owned-process.mjs +9 -0
- package/runtime/scripts/api/sops/decrypt.mjs +9 -12
- package/runtime/scripts/api/sops/lib.mjs +255 -0
- package/runtime/scripts/api/sops/seal.mjs +22 -0
- package/runtime/scripts/connectors/lib.mjs +488 -0
- package/runtime/scripts/hfs/architecture/ast-walks.mjs +220 -0
- package/runtime/scripts/hfs/architecture/backend.mjs +16 -23
- package/runtime/scripts/hfs/architecture/background-unowned.mjs +16 -34
- package/runtime/scripts/hfs/architecture/client-reaches-server.mjs +3 -1
- package/runtime/scripts/hfs/architecture/clones.mjs +4 -4
- package/runtime/scripts/hfs/architecture/config.mjs +9 -6
- package/runtime/scripts/hfs/architecture/connection-map.mjs +20 -8
- package/runtime/scripts/hfs/architecture/context-coupling.mjs +88 -0
- package/runtime/scripts/hfs/architecture/context-map.mjs +237 -0
- package/runtime/scripts/hfs/architecture/context-owner.mjs +82 -0
- package/runtime/scripts/hfs/architecture/context-platform-tables.mjs +47 -0
- package/runtime/scripts/hfs/architecture/context-transaction.mjs +60 -0
- package/runtime/scripts/hfs/architecture/contract-fixture-guard.mjs +4 -10
- package/runtime/scripts/hfs/architecture/contracts.mjs +33 -162
- package/runtime/scripts/hfs/architecture/dead-exports.mjs +58 -29
- package/runtime/scripts/hfs/architecture/doc-language.mjs +1 -1
- package/runtime/scripts/hfs/architecture/entrypoint.mjs +2 -1
- package/runtime/scripts/hfs/architecture/fe-slot-allows.mjs +2 -2
- package/runtime/scripts/hfs/architecture/feature-shape.mjs +5 -2
- package/runtime/scripts/hfs/architecture/framework-pinned.mjs +1 -1
- package/runtime/scripts/hfs/architecture/frontend.mjs +17 -43
- package/runtime/scripts/hfs/architecture/hfs.mjs +24 -39
- package/runtime/scripts/hfs/architecture/i18n-keys.mjs +1 -1
- package/runtime/scripts/hfs/architecture/index.mjs +17 -4
- package/runtime/scripts/hfs/architecture/machine-ast.mjs +44 -11
- package/runtime/scripts/hfs/architecture/managed-scripts.mjs +27 -0
- package/runtime/scripts/hfs/architecture/module-per-transport.mjs +30 -6
- package/runtime/scripts/hfs/architecture/next-data.mjs +22 -63
- package/runtime/scripts/hfs/architecture/owners.mjs +35 -15
- package/runtime/scripts/hfs/architecture/register-once.mjs +2 -1
- package/runtime/scripts/hfs/architecture/registration.mjs +23 -81
- package/runtime/scripts/hfs/architecture/required-files.mjs +20 -12
- package/runtime/scripts/hfs/architecture/schema-owner.mjs +17 -114
- package/runtime/scripts/hfs/architecture/server-action.mjs +24 -0
- package/runtime/scripts/hfs/architecture/side-boundary.mjs +16 -0
- package/runtime/scripts/hfs/architecture/source-names.mjs +27 -147
- package/runtime/scripts/hfs/architecture/sql-owner.mjs +59 -18
- package/runtime/scripts/hfs/architecture/sql-returning.mjs +64 -0
- package/runtime/scripts/hfs/architecture/supabase-ast.mjs +111 -0
- package/runtime/scripts/hfs/architecture/supabase-be.mjs +131 -0
- package/runtime/scripts/hfs/architecture/supabase-tables.mjs +42 -0
- package/runtime/scripts/hfs/architecture/supabase.mjs +434 -0
- package/runtime/scripts/hfs/architecture/surface.mjs +9 -3
- package/runtime/scripts/hfs/architecture/test-world-files.mjs +9 -19
- package/runtime/scripts/hfs/architecture/tiers.mjs +47 -5
- package/runtime/scripts/hfs/architecture/transport-owner.mjs +3 -3
- package/runtime/scripts/hfs/architecture/typescript.mjs +12 -26
- package/runtime/scripts/hfs/architecture.mjs +4 -4
- package/runtime/scripts/hfs/check.mjs +75 -72
- package/runtime/scripts/hfs/coverage-scope.mjs +162 -0
- package/runtime/scripts/hfs/declaration-shape.mjs +62 -0
- package/runtime/scripts/hfs/declaration-slots.mjs +75 -0
- package/runtime/scripts/hfs/edition-slots.mjs +66 -0
- package/runtime/scripts/hfs/manifest-shape.mjs +109 -32
- package/runtime/scripts/hfs/param-names.mjs +18 -0
- package/runtime/scripts/hfs/path-findings.mjs +1 -1
- package/runtime/scripts/hfs/repo-identity.mjs +9 -6
- package/runtime/scripts/hfs/rule-params-shape.mjs +50 -0
- package/runtime/scripts/hfs/rules/app-root.mjs +51 -0
- package/runtime/scripts/hfs/rules/cli.mjs +37 -0
- package/runtime/scripts/hfs/rules/contract-compat.mjs +71 -0
- package/runtime/scripts/hfs/rules/contract.mjs +10 -9
- package/runtime/scripts/hfs/rules/database-config.mjs +102 -0
- package/runtime/scripts/hfs/rules/database-constants.mjs +13 -0
- package/runtime/scripts/hfs/rules/database-migrations.mjs +111 -0
- package/runtime/scripts/hfs/rules/database-plpgsql.mjs +233 -0
- package/runtime/scripts/hfs/rules/database-sql.mjs +336 -0
- package/runtime/scripts/hfs/rules/database.mjs +68 -0
- package/runtime/scripts/hfs/rules/deps.mjs +1 -1
- package/runtime/scripts/hfs/rules/docker.mjs +259 -0
- package/runtime/scripts/hfs/rules/edition.mjs +111 -0
- package/runtime/scripts/hfs/rules/event-bus.mjs +153 -0
- package/runtime/scripts/hfs/rules/fe-contract-documents.mjs +1 -1
- package/runtime/scripts/hfs/rules/fe-no-tests.mjs +6 -5
- package/runtime/scripts/hfs/rules/frontend-tree.mjs +9 -9
- package/runtime/scripts/hfs/rules/integration-specs.mjs +3 -6
- package/runtime/scripts/hfs/rules/kinds.mjs +84 -0
- package/runtime/scripts/hfs/rules/lint-suppression.mjs +1 -1
- package/runtime/scripts/hfs/rules/monorepo.mjs +179 -0
- package/runtime/scripts/hfs/rules/peer-integrations.mjs +3 -3
- package/runtime/scripts/hfs/rules/pipeline.mjs +11 -21
- package/runtime/scripts/hfs/rules/proof-commands.mjs +2 -2
- package/runtime/scripts/hfs/rules/read.mjs +1 -1
- package/runtime/scripts/hfs/rules/repo-local-checks.mjs +2 -2
- package/runtime/scripts/hfs/rules/saga.mjs +170 -0
- package/runtime/scripts/hfs/rules/secrets.mjs +3 -3
- package/runtime/scripts/hfs/rules/services.mjs +220 -0
- package/runtime/scripts/hfs/rules/spec-placement.mjs +1 -1
- package/runtime/scripts/hfs/rules/stacks.mjs +3 -3
- package/runtime/scripts/hfs/rules/supabase-secrets.mjs +89 -0
- package/runtime/scripts/hfs/rules/test-topology.mjs +2 -2
- package/runtime/scripts/hfs/secret.mjs +209 -0
- package/runtime/scripts/hfs/slots.mjs +78 -108
- package/runtime/scripts/hfs/sql/pg-parse.mjs +46 -0
- package/runtime/scripts/hfs/test-world-slot.mjs +6 -0
- package/runtime/scripts/hfs/tree.mjs +5 -4
- package/runtime/scripts/hfs/typescript-programs.mjs +0 -5
- package/runtime/scripts/hfs/view.mjs +3 -2
- package/runtime/scripts/lib/clip.mjs +19 -0
- package/runtime/scripts/lib/display-names.mjs +259 -0
- package/runtime/scripts/lib/dockerfile.mjs +124 -0
- package/runtime/scripts/lib/env.mjs +10 -0
- package/runtime/scripts/lib/event-contract.mjs +103 -0
- package/runtime/scripts/lib/example-refs.mjs +158 -0
- package/runtime/scripts/lib/fs-kind.mjs +14 -4
- package/runtime/scripts/lib/git.mjs +36 -0
- package/runtime/scripts/lib/graphql-contract.mjs +1 -1
- package/runtime/scripts/lib/i18n.mjs +86 -0
- package/runtime/scripts/lib/json-schema.mjs +52 -0
- package/runtime/scripts/lib/json.mjs +13 -3
- package/runtime/scripts/lib/language.mjs +24 -5
- package/runtime/scripts/lib/list.mjs +20 -0
- package/runtime/scripts/lib/mutation-fence.mjs +15 -0
- package/runtime/scripts/lib/package-at.mjs +37 -0
- package/runtime/scripts/lib/path-key.mjs +57 -2
- package/runtime/scripts/lib/process-identity.mjs +6 -0
- package/runtime/scripts/lib/read-text.mjs +34 -0
- package/runtime/scripts/lib/read-yaml.mjs +18 -0
- package/runtime/scripts/lib/redact.mjs +161 -0
- package/runtime/scripts/lib/regex.mjs +4 -0
- package/runtime/scripts/lib/same-text.mjs +5 -0
- package/runtime/scripts/lib/secret-patterns.mjs +4 -3
- package/runtime/scripts/lib/sleep-sync.mjs +2 -1
- package/runtime/scripts/lib/sleep.mjs +7 -0
- package/runtime/scripts/lib/sops-envelope.mjs +112 -0
- package/runtime/scripts/lib/source-phrases.mjs +34 -0
- package/runtime/scripts/lib/sqlite.mjs +21 -0
- package/runtime/scripts/lib/stack-services.mjs +7 -31
- package/runtime/scripts/lib/ts-ast.mjs +35 -0
- package/runtime/scripts/lib/walk.mjs +4 -3
- package/scaffold/add-app.mjs +174 -0
- package/scaffold/add-cli-lite.mjs +257 -0
- package/scaffold/add-inbox-lite.mjs +314 -0
- package/scaffold/add-table.mjs +344 -0
- package/scaffold/add.mjs +299 -0
- package/scaffold/app.mjs +358 -69
- package/scaffold/edition-gate.mjs +25 -0
- package/scaffold/image.mjs +19 -0
- package/scaffold/lite-exports.mjs +186 -0
- package/scaffold/service.mjs +32 -26
- package/scaffold/supabase-ports.mjs +26 -0
- package/src/main.mjs +327 -0
- package/sync/cli.mjs +6 -9
- package/sync/format.mjs +1 -1
- package/sync/hygiene.mjs +10 -10
- package/sync/index.mjs +167 -104
- package/sync/managed.mjs +19 -11
- package/sync/sonar-key.mjs +5 -0
- package/templates/app/ci-workflows/github/workflows/ci.yml +14 -14
- package/templates/app/ci-workflows/github/workflows/images.yml +37 -0
- package/templates/app/ci-workflows/sonar-steps.yml +9 -0
- package/templates/app/ci-workflows-lite/github/workflows/ci.yml +66 -0
- package/templates/app/ci-workflows-lite/github/workflows/db-deploy.yml +31 -0
- package/templates/app/ci-workflows-lite/github/workflows/images.yml +37 -0
- package/templates/app/codegen-lite/scripts/codegen.mjs +32 -0
- package/templates/app/docker-ignore/dockerignore +50 -0
- package/templates/app/gitignore-lite +35 -0
- package/templates/app/hooks/husky/pre-commit +3 -8
- package/templates/app/hooks/husky/pre-push +45 -6
- package/templates/app/package-scripts/core.json +8 -0
- package/templates/app/package-scripts/package.json +3 -10
- package/templates/app/package-scripts-lite/package.json +15 -0
- package/templates/app/quality-config/codecov.yml +15 -3
- package/templates/app/quality-config/sonar-base.properties +4 -0
- package/templates/app/quality-config/sonar-project.properties +1 -4
- package/templates/app/quality-config-lite/sonar-project.properties +5 -0
- package/templates/app/skeleton/.starcistacks/dev/seeds/primary-notes.sql +5 -0
- package/templates/app/skeleton/.starciwork/features/system-health/index.yaml +4 -0
- package/templates/app/skeleton/.starciwork/{features/index.yaml → index.yaml} +2 -2
- package/templates/app/skeleton/README.md +7 -5
- package/templates/app/skeleton-lite/.sops.yaml +3 -0
- package/templates/app/skeleton-lite/.starcistacks/dev/environment.json +5 -0
- package/templates/app/skeleton-lite/.starcistacks/dev/secrets/.gitkeep +1 -0
- package/templates/app/skeleton-lite/.starciwork/shell/index.yaml +55 -0
- package/templates/app/skeleton-lite/README.md +40 -0
- package/templates/app/skeleton-lite/supabase/config.toml +41 -0
- package/templates/app/skeleton-lite/supabase/migrations/__timestamp___baseline.sql +56 -0
- package/templates/app/skeleton-lite/supabase/seed.sql +0 -0
- package/templates/app/task-graph/turbo.json +23 -0
- package/templates/app/tool-config-lite/prettierignore +2 -0
- package/templates/app/tool-config-lite/prettierrc +1 -0
- package/templates/app/upgrade-full/.starcistacks/application-stacks.yaml +38 -0
- package/templates/app/upgrade-full/.starcistacks/dev/README.md +10 -0
- package/templates/app/upgrade-full/.starcistacks/dev/infra/compose/api.yaml +13 -0
- package/templates/app/upgrade-full/.starcistacks/dev/infra/compose/compose.yaml +3 -0
- package/templates/app/upgrade-full/.starcistacks/dev/infra/compose/postgres.yaml +12 -0
- package/templates/app/upgrade-full/.starcistacks/dev/infra/metadata.json +7 -0
- package/templates/be/common/main-listen.ts.partial +14 -0
- package/templates/be/common/sql-ident.ts.partial +7 -0
- package/templates/be/common/sql-tag.ts.partial +5 -0
- package/templates/be/image/api/Dockerfile +38 -0
- package/templates/be/image/cli/Dockerfile +38 -0
- package/templates/be/image/worker/Dockerfile +36 -0
- package/templates/be/inbox/database-client.ts.tpl +50 -0
- package/templates/be/inbox/index.ts.tpl +2 -0
- package/templates/be/inbox/migration.sql.tpl +29 -0
- package/templates/be/inbox/module-definition.ts.tpl +6 -0
- package/templates/be/inbox/module.ts.tpl +14 -0
- package/templates/be/inbox/options.ts.tpl +2 -0
- package/templates/be/inbox/service.ts.tpl +33 -0
- package/templates/be/inbox/sql.ts.tpl +16 -0
- package/templates/be/inbox/webhook-door.ts.tpl +36 -0
- package/templates/be/patterns/api/application.command.http.ts.tpl +10 -0
- package/templates/be/patterns/api/application.command.ts.tpl +10 -0
- package/templates/be/patterns/api/application.contracts.ts.tpl +11 -0
- package/templates/be/patterns/api/application.handler.http.ts.tpl +22 -0
- package/templates/be/patterns/api/application.handler.ts.tpl +22 -0
- package/templates/be/patterns/api/feature.index.http.ts.tpl +1 -0
- package/templates/be/patterns/api/feature.index.ts.tpl +1 -0
- package/templates/be/patterns/api/feature.module.ts.tpl +6 -0
- package/templates/be/patterns/api/graphql.input.ts.tpl +13 -0
- package/templates/be/patterns/api/graphql.mapper.ts.tpl +9 -0
- package/templates/be/patterns/api/graphql.module.ts.tpl +7 -0
- package/templates/be/patterns/api/graphql.resolver.ts.tpl +27 -0
- package/templates/be/patterns/api/graphql.type.ts.tpl +9 -0
- package/templates/be/patterns/api/http.controller.ts.tpl +27 -0
- package/templates/be/patterns/api/http.mapper.ts.tpl +9 -0
- package/templates/be/patterns/api/http.module.ts.tpl +7 -0
- package/templates/be/patterns/api/http.request.ts.tpl +10 -0
- package/templates/be/patterns/api/http.response.ts.tpl +5 -0
- package/templates/be/patterns/cli/group.cli.spec.ts.tpl +15 -0
- package/templates/be/patterns/cli/group.cli.ts.tpl +11 -0
- package/templates/be/patterns/cli/group.module.ts.tpl +7 -0
- package/templates/be/patterns/cli/sub.run.cli.spec.ts.tpl +17 -0
- package/templates/be/patterns/cli/sub.run.cli.ts.tpl +15 -0
- package/templates/be/patterns/event-bus/platform/errors/event-bus.error.ts.tpl +22 -0
- package/templates/be/patterns/event-bus/platform/event-bus.config.ts.tpl +19 -0
- package/templates/be/patterns/event-bus/platform/event-bus.contracts.ts.tpl +58 -0
- package/templates/be/patterns/event-bus/platform/event-bus.decorators.ts.tpl +46 -0
- package/templates/be/patterns/event-bus/platform/event-bus.log-events.ts.tpl +12 -0
- package/templates/be/patterns/event-bus/platform/event-bus.module-definition.ts.tpl +10 -0
- package/templates/be/patterns/event-bus/platform/event-bus.module.ts.tpl +52 -0
- package/templates/be/patterns/event-bus/platform/event-bus.options.ts.tpl +19 -0
- package/templates/be/patterns/event-bus/platform/event-bus.port.ts.tpl +28 -0
- package/templates/be/patterns/event-bus/platform/event-bus.service.spec.ts.tpl +165 -0
- package/templates/be/patterns/event-bus/platform/event-bus.service.ts.tpl +93 -0
- package/templates/be/patterns/event-bus/platform/event-envelope.policy.spec.ts.tpl +90 -0
- package/templates/be/patterns/event-bus/platform/event-envelope.policy.ts.tpl +58 -0
- package/templates/be/patterns/event-bus/platform/event-relay.service.spec.ts.tpl +136 -0
- package/templates/be/patterns/event-bus/platform/event-relay.service.ts.tpl +56 -0
- package/templates/be/patterns/event-bus/platform/event-runner.service.spec.ts.tpl +272 -0
- package/templates/be/patterns/event-bus/platform/event-runner.service.ts.tpl +128 -0
- package/templates/be/patterns/event-bus/platform/event-transport.port.ts.tpl +180 -0
- package/templates/be/patterns/event-bus/platform/event.policy.spec.ts.tpl +67 -0
- package/templates/be/patterns/event-bus/platform/event.policy.ts.tpl +38 -0
- package/templates/be/patterns/event-bus/platform/index.ts.tpl +11 -0
- package/templates/be/patterns/event-bus/platform/kafka-event-transport.client.spec.ts.tpl +348 -0
- package/templates/be/patterns/event-bus/platform/kafka-event-transport.client.ts.tpl +241 -0
- package/templates/be/patterns/event-bus/platform/messages/event-bus.messages.ts.tpl +15 -0
- package/templates/be/patterns/event-bus/platform/persistence/connection.ts.tpl +8 -0
- package/templates/be/patterns/event-bus/platform/persistence/entities/event-outbox.entity.ts.tpl +37 -0
- package/templates/be/patterns/event-bus/platform/persistence/event-bus.rows.ts.tpl +11 -0
- package/templates/be/patterns/event-bus/platform/persistence/event-bus.sql.ts.tpl +12 -0
- package/templates/be/patterns/event-bus/platform/persistence/migrations/1789800009000-create-event-outbox.ts.tpl +26 -0
- package/templates/be/patterns/jobs/job.index.ts.tpl +1 -0
- package/templates/be/patterns/jobs/job.module.ts.tpl +6 -0
- package/templates/be/patterns/jobs/job.processor.ts.tpl +20 -0
- package/templates/be/patterns/jobs/job.queue.module.ts.tpl +20 -0
- package/templates/be/patterns/jobs/job.step.ts.tpl +19 -0
- package/templates/be/patterns/jobs/platform/fenced.processor.spec.ts.tpl +31 -0
- package/templates/be/patterns/jobs/platform/fenced.processor.ts.tpl +13 -0
- package/templates/be/patterns/jobs/platform/job-claim.service.spec.ts.tpl +150 -0
- package/templates/be/patterns/jobs/platform/job-claim.service.ts.tpl +100 -0
- package/templates/be/patterns/jobs/platform/job-runner.service.spec.ts.tpl +138 -0
- package/templates/be/patterns/jobs/platform/job-runner.service.ts.tpl +69 -0
- package/templates/be/patterns/jobs/platform/jobs.config.ts.tpl +11 -0
- package/templates/be/patterns/jobs/platform/jobs.contracts.ts.tpl +62 -0
- package/templates/be/patterns/jobs/platform/jobs.decorators.ts.tpl +31 -0
- package/templates/be/patterns/jobs/platform/jobs.error.ts.tpl +22 -0
- package/templates/be/patterns/jobs/platform/jobs.index.ts.tpl +11 -0
- package/templates/be/patterns/jobs/platform/jobs.log-events.ts.tpl +9 -0
- package/templates/be/patterns/jobs/platform/jobs.messages.ts.tpl +15 -0
- package/templates/be/patterns/jobs/platform/jobs.module-definition.ts.tpl +10 -0
- package/templates/be/patterns/jobs/platform/jobs.module.ts.tpl +32 -0
- package/templates/be/patterns/jobs/platform/jobs.options.ts.tpl +11 -0
- package/templates/be/patterns/jobs/platform/jobs.port.ts.tpl +36 -0
- package/templates/be/patterns/jobs/platform/persistence.connection.ts.tpl +8 -0
- package/templates/be/patterns/jobs/platform/persistence.job.entity.ts.tpl +53 -0
- package/templates/be/patterns/jobs/platform/persistence.jobs.rows.ts.tpl +13 -0
- package/templates/be/patterns/jobs/platform/persistence.jobs.sql.ts.tpl +33 -0
- package/templates/be/patterns/jobs/platform/persistence.migration.ts.tpl +29 -0
- package/templates/be/patterns/outbox/platform/index.ts.tpl +2 -0
- package/templates/be/patterns/outbox/platform/outbox-relay.policy.spec.ts.tpl +96 -0
- package/templates/be/patterns/outbox/platform/outbox-relay.policy.ts.tpl +78 -0
- package/templates/be/patterns/outbox/platform/outbox.log-events.ts.tpl +5 -0
- package/templates/be/patterns/projections/migration.ts.tpl +18 -0
- package/templates/be/patterns/projections/persistence.connection.ts.tpl +8 -0
- package/templates/be/patterns/projections/projection.entity.ts.tpl +9 -0
- package/templates/be/patterns/projections/projection.index.ts.tpl +3 -0
- package/templates/be/patterns/projections/projection.module-definition.ts.tpl +7 -0
- package/templates/be/patterns/projections/projection.module.ts.tpl +18 -0
- package/templates/be/patterns/projections/projection.options.ts.tpl +2 -0
- package/templates/be/patterns/projections/projection.projection.spec.ts.tpl +55 -0
- package/templates/be/patterns/projections/projection.projection.ts.tpl +21 -0
- package/templates/be/patterns/queues/platform/bullmq-queue-transport.client.spec.ts.tpl +142 -0
- package/templates/be/patterns/queues/platform/bullmq-queue-transport.client.ts.tpl +81 -0
- package/templates/be/patterns/queues/platform/persistence.connection.ts.tpl +8 -0
- package/templates/be/patterns/queues/platform/persistence.migration.ts.tpl +25 -0
- package/templates/be/patterns/queues/platform/persistence.queue-outbox.entity.ts.tpl +25 -0
- package/templates/be/patterns/queues/platform/persistence.queue.rows.ts.tpl +9 -0
- package/templates/be/patterns/queues/platform/persistence.queue.sql.ts.tpl +12 -0
- package/templates/be/patterns/queues/platform/queue-outbox.service.spec.ts.tpl +48 -0
- package/templates/be/patterns/queues/platform/queue-outbox.service.ts.tpl +17 -0
- package/templates/be/patterns/queues/platform/queue-relay.service.spec.ts.tpl +128 -0
- package/templates/be/patterns/queues/platform/queue-relay.service.ts.tpl +48 -0
- package/templates/be/patterns/queues/platform/queue-transport.port.ts.tpl +115 -0
- package/templates/be/patterns/queues/platform/queue-worker.service.spec.ts.tpl +91 -0
- package/templates/be/patterns/queues/platform/queue-worker.service.ts.tpl +45 -0
- package/templates/be/patterns/queues/platform/queue.config.ts.tpl +15 -0
- package/templates/be/patterns/queues/platform/queue.contracts.ts.tpl +31 -0
- package/templates/be/patterns/queues/platform/queue.decorators.ts.tpl +45 -0
- package/templates/be/patterns/queues/platform/queue.index.ts.tpl +7 -0
- package/templates/be/patterns/queues/platform/queue.log-events.ts.tpl +5 -0
- package/templates/be/patterns/queues/platform/queue.module-definition.ts.tpl +10 -0
- package/templates/be/patterns/queues/platform/queue.module.ts.tpl +62 -0
- package/templates/be/patterns/queues/platform/queue.options.ts.tpl +22 -0
- package/templates/be/patterns/queues/platform/queue.policy.spec.ts.tpl +19 -0
- package/templates/be/patterns/queues/platform/queue.policy.ts.tpl +11 -0
- package/templates/be/patterns/queues/platform/queue.port.ts.tpl +14 -0
- package/templates/be/patterns/queues/queue.index.ts.tpl +3 -0
- package/templates/be/patterns/queues/queue.module.ts.tpl +6 -0
- package/templates/be/patterns/queues/queue.queue.ts.tpl +23 -0
- package/templates/be/patterns/reactors/application.command.ts.tpl +10 -0
- package/templates/be/patterns/reactors/application.contracts.ts.tpl +12 -0
- package/templates/be/patterns/reactors/application.handler.ts.tpl +22 -0
- package/templates/be/patterns/reactors/consumer.ts.tpl +19 -0
- package/templates/be/patterns/reactors/message.module.ts.tpl +20 -0
- package/templates/be/patterns/reactors/reactor.index.ts.tpl +1 -0
- package/templates/be/patterns/reactors/reactor.module.ts.tpl +6 -0
- package/templates/be/patterns/realtime/channel.graphql.module.ts.tpl +6 -0
- package/templates/be/patterns/realtime/channel.index.ts.tpl +1 -0
- package/templates/be/patterns/realtime/channel.input.ts.tpl +12 -0
- package/templates/be/patterns/realtime/channel.subscription.spec.ts.tpl +51 -0
- package/templates/be/patterns/realtime/channel.subscription.ts.tpl +32 -0
- package/templates/be/patterns/realtime/channel.type.ts.tpl +9 -0
- package/templates/be/patterns/saga/saga.compensate.command.ts.tpl +11 -0
- package/templates/be/patterns/saga/saga.compensate.contracts.ts.tpl +7 -0
- package/templates/be/patterns/saga/saga.compensate.handler.ts.tpl +22 -0
- package/templates/be/patterns/saga/saga.compensation.ts.tpl +21 -0
- package/templates/be/patterns/saga/saga.complete.command.ts.tpl +11 -0
- package/templates/be/patterns/saga/saga.complete.contracts.ts.tpl +7 -0
- package/templates/be/patterns/saga/saga.complete.handler.ts.tpl +22 -0
- package/templates/be/patterns/saga/saga.done.consumer.ts.tpl +21 -0
- package/templates/be/patterns/saga/saga.failed.consumer.ts.tpl +21 -0
- package/templates/be/patterns/saga/saga.index.ts.tpl +1 -0
- package/templates/be/patterns/saga/saga.message.module.ts.tpl +23 -0
- package/templates/be/patterns/saga/saga.module.ts.tpl +20 -0
- package/templates/be/patterns/saga/saga.service.spec.ts.tpl +70 -0
- package/templates/be/patterns/saga/saga.service.ts.tpl +44 -0
- package/templates/be/patterns/saga/saga.state.ts.tpl +14 -0
- package/templates/be/patterns/saga/saga.step.ts.tpl +11 -0
- package/templates/be/patterns/saga/saga.undo.command.ts.tpl +10 -0
- package/templates/be/patterns/saga/saga.undo.contracts.ts.tpl +5 -0
- package/templates/be/patterns/saga/saga.undo.handler.ts.tpl +21 -0
- package/templates/be/patterns/webhooks/webhook.door.spec.ts.tpl +72 -0
- package/templates/be/patterns/webhooks/webhook.door.ts.tpl +36 -0
- package/templates/be/patterns/webhooks/webhook.http.module.ts.tpl +6 -0
- package/templates/be/patterns/webhooks/webhook.index.ts.tpl +1 -0
- package/templates/be/patterns/webhooks/webhook.request.ts.tpl +9 -0
- package/templates/be/skeleton/apps/__app__/src/__app__.options.ts +3 -0
- package/templates/be/skeleton/apps/__app__/src/app.module.ts +15 -2
- package/templates/be/skeleton/apps/__app__/src/main.ts +7 -15
- package/templates/be/skeleton/apps/cli/src/app.module.ts +30 -0
- package/templates/be/skeleton/apps/cli/src/cli.options.ts +22 -0
- package/templates/be/skeleton/apps/cli/src/main.ts +24 -0
- package/templates/be/skeleton/src/features/cli/cli.module.ts +7 -0
- package/templates/be/skeleton/src/features/cli/index.ts +1 -0
- package/templates/be/skeleton/src/features/cli/migrate/migrate.cli.spec.ts +17 -0
- package/templates/be/skeleton/src/features/cli/migrate/migrate.cli.ts +15 -0
- package/templates/be/skeleton/src/features/cli/migrate/migrate.module.ts +7 -0
- package/templates/be/skeleton/src/features/cli/migrate/subs/run.cli.spec.ts +17 -0
- package/templates/be/skeleton/src/features/cli/migrate/subs/run.cli.ts +18 -0
- package/templates/be/skeleton/src/features/cli/seed/seed.cli.spec.ts +17 -0
- package/templates/be/skeleton/src/features/cli/seed/seed.cli.ts +15 -0
- package/templates/be/skeleton/src/features/cli/seed/seed.module.ts +7 -0
- package/templates/be/skeleton/src/features/cli/seed/subs/run.cli.spec.ts +33 -0
- package/templates/be/skeleton/src/features/cli/seed/subs/run.cli.ts +34 -0
- package/templates/be/skeleton/src/modules/domain/identity/admission.policy.spec.ts +13 -0
- package/templates/be/skeleton/src/modules/domain/identity/auth.guard.spec.ts +40 -0
- package/templates/be/skeleton/src/modules/domain/identity/messages/identity.messages.ts +1 -1
- package/templates/be/skeleton/src/modules/domain/note/errors/note.error.ts +16 -0
- package/templates/be/skeleton/src/modules/domain/note/index.ts +3 -0
- package/templates/be/skeleton/src/modules/domain/note/note.contracts.ts +19 -0
- package/templates/be/skeleton/src/modules/domain/note/note.decorators.ts +9 -0
- package/templates/be/skeleton/src/modules/domain/note/note.module-definition.ts +7 -0
- package/templates/be/skeleton/src/modules/domain/note/note.module.ts +19 -0
- package/templates/be/skeleton/src/modules/domain/note/note.options.ts +2 -0
- package/templates/be/skeleton/src/modules/domain/note/note.service.spec.ts +76 -0
- package/templates/be/skeleton/src/modules/domain/note/note.service.ts +37 -0
- package/templates/be/skeleton/src/modules/domain/note/persistence/connection.ts +8 -0
- package/templates/be/skeleton/src/modules/domain/note/persistence/entities/note.entity.ts +17 -0
- package/templates/be/skeleton/src/modules/domain/note/persistence/migrations/1790000000000-init-note.ts +22 -0
- package/templates/be/skeleton/src/modules/domain/note/persistence/note.rows.ts +17 -0
- package/templates/be/skeleton/src/modules/domain/note/persistence/note.sql.ts +4 -0
- package/templates/be/skeleton/src/modules/platform/config/env-source.config.ts +20 -0
- package/templates/be/skeleton/src/modules/platform/config/index.ts +1 -1
- package/templates/be/skeleton/src/modules/platform/cqrs/cqrs.contracts.ts +18 -0
- package/templates/be/skeleton/src/modules/platform/database/connection-source.client.spec.ts +41 -0
- package/templates/be/skeleton/src/modules/platform/database/connection-source.client.ts +17 -0
- package/templates/be/skeleton/src/modules/platform/database/database.module-definition.ts +13 -0
- package/templates/be/skeleton/src/modules/platform/database/database.module.ts +77 -0
- package/templates/be/skeleton/src/modules/platform/database/database.options.ts +30 -0
- package/templates/be/skeleton/src/modules/platform/database/database.port.ts +65 -0
- package/templates/be/skeleton/src/modules/platform/database/database.sql.ts +47 -0
- package/templates/be/skeleton/src/modules/platform/database/errors/database.error.ts +16 -0
- package/templates/be/skeleton/src/modules/platform/database/index.ts +9 -0
- package/templates/be/skeleton/src/modules/platform/database/migrate-connections.client.ts +30 -0
- package/templates/be/skeleton/src/modules/platform/database/migration-runner.service.spec.ts +84 -0
- package/templates/be/skeleton/src/modules/platform/database/migration-runner.service.ts +23 -0
- package/templates/be/skeleton/src/modules/platform/database/primary.config.ts +9 -0
- package/templates/be/skeleton/src/modules/platform/database/primary.connection.ts +2 -0
- package/templates/be/skeleton/src/modules/platform/database/primary.decorators.ts +10 -0
- package/templates/be/skeleton/src/modules/platform/database/seed-connections.client.spec.ts +108 -0
- package/templates/be/skeleton/src/modules/platform/database/seed-connections.client.ts +75 -0
- package/templates/be/skeleton/src/modules/platform/database/seed-runner.service.spec.ts +88 -0
- package/templates/be/skeleton/src/modules/platform/database/seed-runner.service.ts +29 -0
- package/templates/be/skeleton/src/modules/platform/errors/errors.filter.spec.ts +48 -0
- package/templates/be/skeleton/src/modules/platform/errors/messages/errors.messages.ts +1 -1
- package/templates/be/skeleton/src/modules/platform/http-security/errors/http-security.error.ts +12 -0
- package/templates/be/skeleton/src/modules/platform/http-security/execution-request.mapper.spec.ts +16 -0
- package/templates/be/skeleton/src/modules/platform/http-security/http-security.config.ts +8 -1
- package/templates/be/skeleton/src/modules/platform/http-security/http-security.decorators.ts +8 -0
- package/templates/be/skeleton/src/modules/platform/http-security/http-security.module.ts +14 -1
- package/templates/be/skeleton/src/modules/platform/http-security/http-security.options.ts +12 -0
- package/templates/be/skeleton/src/modules/platform/http-security/messages/http-security.messages.ts +10 -2
- package/templates/be/skeleton/src/modules/platform/http-security/origin.guard.spec.ts +63 -0
- package/templates/be/skeleton/src/modules/platform/http-security/rate-limit.guard.spec.ts +108 -0
- package/templates/be/skeleton/src/modules/platform/http-security/request-validation.service.spec.ts +39 -0
- package/templates/be/skeleton/src/modules/platform/http-security/request-validation.service.ts +25 -0
- package/templates/be/skeleton/src/modules/platform/http-security/webhook-signature.service.spec.ts +172 -0
- package/templates/be/skeleton/src/modules/platform/http-security/webhook-signature.service.ts +66 -0
- package/templates/be/skeleton/src/modules/platform/logging/logging.log-events.ts +3 -1
- package/templates/be/skeleton/src/modules/platform/primitives/outcome.mapper.spec.ts +52 -0
- package/templates/be/skeleton-lite/apps/api/Dockerfile +37 -0
- package/templates/be/skeleton-lite/apps/api/src/api.options.ts +16 -0
- package/templates/be/skeleton-lite/apps/api/src/app.module.ts +81 -0
- package/templates/be/skeleton-lite/apps/api/src/main.ts +34 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/admission.policy.ts +14 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/auth.guard.ts +50 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/identity.contracts.ts +26 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/identity.decorators.ts +19 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/identity.module.ts +26 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/identity.options.ts +7 -0
- package/templates/be/skeleton-lite/src/modules/domain/identity/index.ts +6 -0
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/errors/supabase.error.ts +19 -0
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/index.ts +10 -0
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.client.ts +24 -0
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.config.ts +8 -0
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.decorators.ts +17 -0
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.jwks.ts +32 -0
- package/templates/be/skeleton-lite/src/modules/integrations/supabase/supabase.options.ts +24 -0
- package/templates/be/skeleton-lite/src/modules/platform/cqrs/index.ts +4 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/database.module.ts +54 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/database.options.ts +23 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/database.port.ts +10 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/database.sql.ts +49 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/index.ts +4 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/migration-runner.service.ts +21 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/primary.config.ts +11 -0
- package/templates/be/skeleton-lite/src/modules/platform/database/seed-runner.service.ts +28 -0
- package/templates/be/skeleton-lite/src/modules/platform/http-security/http-security.module.ts +25 -0
- package/templates/be/skeleton-lite/src/modules/platform/http-security/index.ts +9 -0
- package/templates/be/skeleton-lite/src/modules/platform/i18n/index.ts +4 -0
- package/templates/be/skeleton-lite/src/modules/platform/logging/index.ts +5 -0
- package/templates/be/table/error.ts.tpl +16 -0
- package/templates/be/table/index.ts.tpl +2 -0
- package/templates/be/table/migration.sql.tpl +51 -0
- package/templates/be/table/module-definition.ts.tpl +7 -0
- package/templates/be/table/module.ts.tpl +14 -0
- package/templates/be/table/options.ts.tpl +2 -0
- package/templates/be/table/rows.ts.tpl +4 -0
- package/templates/be/table/service.ts.tpl +23 -0
- package/templates/be/table/sql.ts.tpl +4 -0
- package/templates/be/tool-config/jest.config.js +3 -1
- package/templates/be/upgrade-full/apps/cli/src/app.module.ts +14 -0
- package/templates/be/upgrade-full/apps/cli/src/main.ts +26 -0
- package/templates/be/upgrade-full/src/features/cli/cli.module.ts +6 -0
- package/templates/be/upgrade-full/src/features/cli/migrate/subs/run.cli.ts +23 -0
- package/templates/common/gitignore.base +1 -2
- package/templates/fe/app/package.json.tpl +1 -0
- package/templates/fe/app/tsconfig.json +12 -0
- package/templates/fe/common/app-layout.tsx.partial +8 -0
- package/templates/fe/common/site-shell.tsx.partial +9 -0
- package/templates/fe/image/next/Dockerfile +42 -0
- package/templates/fe/skeleton/apps/app/next.config.ts +23 -0
- package/templates/fe/skeleton/apps/app/postcss.config.mjs +7 -0
- package/templates/fe/skeleton/apps/{__app__ → app}/src/app/[locale]/error.tsx +2 -2
- package/templates/fe/skeleton/apps/app/src/app/[locale]/layout.tsx +22 -0
- package/templates/fe/skeleton/apps/{__app__ → app}/src/app/[locale]/loading.tsx +2 -2
- package/templates/fe/skeleton/apps/{__app__ → app}/src/app/[locale]/not-found.tsx +2 -2
- package/templates/fe/skeleton/apps/app/src/app/[locale]/page.tsx +9 -0
- package/templates/fe/skeleton/apps/{__app__ → app}/src/app/global-error.tsx +2 -2
- package/templates/fe/skeleton/apps/app/src/app/globals.css +10 -0
- package/templates/fe/skeleton/apps/app/src/features/layouts/AppLayout/index.tsx +18 -0
- package/templates/fe/skeleton/apps/app/src/features/pages/AppErrorPage/component.tsx +19 -0
- package/templates/fe/skeleton/apps/app/src/features/pages/AppErrorPage/index.tsx +11 -0
- package/templates/fe/skeleton/apps/app/src/features/pages/AppGlobalErrorPage/index.tsx +16 -0
- package/templates/fe/skeleton/apps/app/src/features/pages/AppHomePage/component.tsx +10 -0
- package/templates/fe/skeleton/apps/app/src/features/pages/AppHomePage/index.tsx +15 -0
- package/templates/fe/skeleton/apps/app/src/features/pages/AppLoadingPage/index.tsx +8 -0
- package/templates/fe/skeleton/apps/app/src/features/pages/AppNotFoundPage/index.tsx +9 -0
- package/templates/fe/skeleton/apps/app/src/modules/i18n/index.ts +4 -0
- package/templates/fe/skeleton/apps/app/src/modules/i18n/messages/vi.json +28 -0
- package/templates/fe/skeleton/apps/app/src/modules/i18n/request.ts +4 -0
- package/templates/fe/skeleton/apps/app/src/modules/routes/index.ts +4 -0
- package/templates/fe/skeleton/apps/app/src/proxy.ts +1 -0
- package/templates/fe/skeleton/apps/{__app__ → landing}/next.config.ts +4 -2
- package/templates/fe/skeleton/apps/landing/postcss.config.mjs +7 -0
- package/templates/fe/skeleton/apps/landing/src/app/[locale]/error.tsx +10 -0
- package/templates/fe/skeleton/apps/landing/src/app/[locale]/layout.tsx +22 -0
- package/templates/fe/skeleton/apps/landing/src/app/[locale]/loading.tsx +6 -0
- package/templates/fe/skeleton/apps/landing/src/app/[locale]/not-found.tsx +6 -0
- package/templates/fe/skeleton/apps/landing/src/app/[locale]/page.tsx +9 -0
- package/templates/fe/skeleton/apps/landing/src/app/global-error.tsx +10 -0
- package/templates/fe/skeleton/apps/landing/src/app/globals.css +10 -0
- package/templates/fe/skeleton/apps/landing/src/features/layouts/LandingLayout/index.tsx +24 -0
- package/templates/fe/skeleton/apps/landing/src/features/pages/LandingErrorPage/component.tsx +18 -0
- package/templates/fe/skeleton/apps/landing/src/features/pages/LandingErrorPage/index.tsx +11 -0
- package/templates/fe/skeleton/apps/landing/src/features/pages/LandingGlobalErrorPage/index.tsx +16 -0
- package/templates/fe/skeleton/apps/landing/src/features/pages/LandingLoadingPage/index.tsx +8 -0
- package/templates/fe/skeleton/apps/landing/src/features/pages/LandingNotFoundPage/index.tsx +9 -0
- package/templates/fe/skeleton/apps/landing/src/features/pages/LandingPage/component.tsx +24 -0
- package/templates/fe/skeleton/apps/landing/src/features/pages/LandingPage/index.tsx +16 -0
- package/templates/fe/skeleton/apps/landing/src/modules/config/index.ts +12 -0
- package/templates/fe/skeleton/apps/landing/src/modules/i18n/index.ts +7 -0
- package/templates/fe/skeleton/apps/landing/src/modules/i18n/messages/vi.json +31 -0
- package/templates/fe/skeleton/apps/landing/src/modules/i18n/request.ts +4 -0
- package/templates/fe/skeleton/apps/landing/src/modules/routes/index.ts +4 -0
- package/templates/fe/skeleton/apps/landing/src/proxy.ts +1 -0
- package/templates/fe/skeleton/packages/__project__-i18n/src/index.ts +49 -0
- package/templates/fe/skeleton/packages/__project__-i18n/src/proxy.ts +24 -0
- package/templates/fe/skeleton/packages/__project__-i18n/src/routing.ts +20 -0
- package/templates/fe/skeleton/packages/__project__-ui/src/branches/Providers/index.tsx +23 -0
- package/templates/fe/skeleton/packages/__project__-ui/src/composites/ErrorNotice/index.tsx +14 -0
- package/templates/fe/skeleton/packages/__project__-ui/src/composites/GlobalErrorNotice/index.tsx +25 -0
- package/templates/fe/skeleton/packages/__project__-ui/src/composites/LoadingNotice/index.tsx +9 -0
- package/templates/fe/skeleton/packages/__project__-ui/src/composites/LocaleShell/index.tsx +21 -0
- package/templates/fe/skeleton/packages/__project__-ui/src/composites/NotFoundNotice/index.tsx +19 -0
- package/templates/fe/skeleton/packages/__project__-ui/src/composites/SiteShell/classNames.ts +4 -0
- package/templates/fe/skeleton/packages/__project__-ui/src/composites/SiteShell/index.tsx +19 -0
- package/templates/fe/skeleton/packages/__project__-ui/src/index.ts +6 -0
- package/templates/fe/skeleton-lite/apps/web/next.config.ts +22 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/error.tsx +10 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/layout.tsx +37 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/loading.tsx +6 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/not-found.tsx +6 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/page.tsx +9 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/[locale]/providers.tsx +26 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/auth/callback/route.ts +24 -0
- package/templates/fe/skeleton-lite/apps/web/src/app/global-error.tsx +10 -0
- package/templates/fe/{skeleton/apps/__app__ → skeleton-lite/apps/web}/src/app/globals.css +1 -1
- package/templates/fe/skeleton-lite/apps/web/src/app/health/live/route.ts +5 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/blocks/SignInForm/component.tsx +29 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/blocks/SignInForm/index.tsx +41 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/blocks/SignOutButton/component.tsx +17 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/blocks/SignOutButton/index.tsx +38 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/composites/ErrorNotice/index.tsx +13 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/composites/GlobalErrorNotice/index.tsx +24 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/composites/LoadingNotice/index.tsx +7 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/composites/NotFoundNotice/index.tsx +18 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/composites/SiteShell/classNames.ts +4 -0
- package/templates/fe/skeleton-lite/apps/web/src/components/composites/SiteShell/index.tsx +13 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/layouts/AppLayout/index.tsx +31 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppErrorPage/component.tsx +12 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppErrorPage/index.tsx +10 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppGlobalErrorPage/index.tsx +15 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppHomePage/component.tsx +14 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppHomePage/index.tsx +30 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppLoadingPage/index.tsx +8 -0
- package/templates/fe/skeleton-lite/apps/web/src/features/pages/AppNotFoundPage/index.tsx +9 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/brand/brand.css +20 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/brand/index.ts +2 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/config/index.ts +20 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/auth/read-session.ts +25 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/auth/write-sign-in.ts +25 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/auth/write-sign-out.ts +17 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/browser.ts +14 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/index.ts +3 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/outcome.ts +59 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/principal.ts +29 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/server.ts +70 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/db/validation/validation.mapper.ts +50 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/i18n/index.ts +8 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/i18n/messages/vi.json +48 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/i18n/request.ts +16 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/i18n/routing.ts +14 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/routes/index.ts +7 -0
- package/templates/fe/skeleton-lite/apps/web/src/modules/routes/safe-next-path.ts +26 -0
- package/templates/fe/skeleton-lite/apps/web/src/proxy.ts +43 -0
- package/templates/fe/table/read.ts.tpl +16 -0
- package/templates/fe/table/write.ts.tpl +16 -0
- package/upgrade/check.mjs +137 -0
- package/upgrade/index.mjs +524 -0
- package/bin/hfs.mjs +0 -233
- package/runtime/scripts/api/fs/rmdir-link.mjs +0 -12
- package/runtime/scripts/lib/test-secrets.mjs +0 -116
- package/templates/fe/skeleton/apps/__app__/src/app/[locale]/layout.tsx +0 -20
- package/templates/fe/skeleton/apps/__app__/src/app/[locale]/page.tsx +0 -9
- package/templates/fe/skeleton/apps/__app__/src/components/composites/FailureScreen/index.tsx +0 -28
- package/templates/fe/skeleton/apps/__app__/src/features/layouts/LocaleShell/index.tsx +0 -35
- package/templates/fe/skeleton/apps/__app__/src/features/pages/ErrorPage/component.tsx +0 -19
- package/templates/fe/skeleton/apps/__app__/src/features/pages/ErrorPage/index.tsx +0 -11
- package/templates/fe/skeleton/apps/__app__/src/features/pages/GlobalErrorPage/component.tsx +0 -24
- package/templates/fe/skeleton/apps/__app__/src/features/pages/GlobalErrorPage/index.tsx +0 -14
- package/templates/fe/skeleton/apps/__app__/src/features/pages/HomePage/component.tsx +0 -21
- package/templates/fe/skeleton/apps/__app__/src/features/pages/HomePage/index.tsx +0 -15
- package/templates/fe/skeleton/apps/__app__/src/features/pages/LoadingPage/component.tsx +0 -23
- package/templates/fe/skeleton/apps/__app__/src/features/pages/LoadingPage/index.tsx +0 -8
- package/templates/fe/skeleton/apps/__app__/src/features/pages/NotFoundPage/component.tsx +0 -28
- package/templates/fe/skeleton/apps/__app__/src/features/pages/NotFoundPage/index.tsx +0 -8
- package/templates/fe/skeleton/apps/__app__/src/modules/i18n/config.ts +0 -8
- package/templates/fe/skeleton/apps/__app__/src/modules/i18n/index.ts +0 -2
- package/templates/fe/skeleton/apps/__app__/src/modules/i18n/messages/vi.json +0 -25
- package/templates/fe/skeleton/apps/__app__/src/modules/i18n/request.ts +0 -19
- package/templates/fe/skeleton/apps/__app__/src/modules/i18n/routing.ts +0 -9
- package/templates/fe/skeleton/apps/__app__/src/modules/routes/index.ts +0 -4
- package/templates/fe/skeleton/apps/__app__/src/proxy.ts +0 -10
- /package/templates/be/skeleton/src/features/{system-health → api/system-health}/application/check-liveness.contracts.ts +0 -0
- /package/templates/be/skeleton/src/features/{system-health → api/system-health}/application/check-liveness.handler.ts +0 -0
- /package/templates/be/skeleton/src/features/{system-health → api/system-health}/application/check-liveness.query.ts +0 -0
- /package/templates/be/skeleton/src/features/{system-health → api/system-health}/index.ts +0 -0
- /package/templates/be/skeleton/src/features/{system-health → api/system-health}/system-health.module.ts +0 -0
- /package/templates/be/skeleton/src/features/{system-health → api/system-health}/transport/http/live.controller.ts +0 -0
- /package/templates/be/skeleton/src/features/{system-health → api/system-health}/transport/http/system-health-http.module.ts +0 -0
- /package/templates/fe/skeleton/apps/{__app__ → app}/src/app/health/live/route.ts +0 -0
- /package/templates/fe/skeleton/apps/{__app__ → app}/src/modules/config/index.ts +0 -0
- /package/templates/fe/{skeleton/apps/__app__ → skeleton-lite/apps/web}/postcss.config.mjs +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
project_id = "{{project}}"
|
|
2
|
+
|
|
3
|
+
[api]
|
|
4
|
+
enabled = true
|
|
5
|
+
port = {{supabasePortApi}}
|
|
6
|
+
schemas = ["public", "graphql_public"]
|
|
7
|
+
extra_search_path = ["public", "extensions"]
|
|
8
|
+
max_rows = 1000
|
|
9
|
+
|
|
10
|
+
[db]
|
|
11
|
+
port = {{supabasePortDb}}
|
|
12
|
+
shadow_port = {{supabasePortShadow}}
|
|
13
|
+
major_version = 17
|
|
14
|
+
|
|
15
|
+
[db.pooler]
|
|
16
|
+
enabled = false
|
|
17
|
+
port = {{supabasePortPooler}}
|
|
18
|
+
|
|
19
|
+
[studio]
|
|
20
|
+
port = {{supabasePortStudio}}
|
|
21
|
+
|
|
22
|
+
[inbucket]
|
|
23
|
+
port = {{supabasePortInbucket}}
|
|
24
|
+
|
|
25
|
+
[analytics]
|
|
26
|
+
port = {{supabasePortAnalytics}}
|
|
27
|
+
|
|
28
|
+
[auth]
|
|
29
|
+
enabled = true
|
|
30
|
+
site_url = "http://127.0.0.1:3000"
|
|
31
|
+
additional_redirect_urls = ["http://127.0.0.1:3000/auth/callback"]
|
|
32
|
+
enable_signup = false
|
|
33
|
+
jwt_expiry = 3600
|
|
34
|
+
|
|
35
|
+
[auth.email]
|
|
36
|
+
enable_signup = false
|
|
37
|
+
|
|
38
|
+
[auth.external.google]
|
|
39
|
+
enabled = false
|
|
40
|
+
client_id = "env(SUPABASE_AUTH_GOOGLE_CLIENT_ID)"
|
|
41
|
+
secret = "env(SUPABASE_AUTH_GOOGLE_SECRET)"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
drop role if exists app_be;
|
|
2
|
+
create role app_be login noinherit;
|
|
3
|
+
|
|
4
|
+
create schema if not exists private;
|
|
5
|
+
|
|
6
|
+
revoke all on schema private from public, anon, authenticated;
|
|
7
|
+
|
|
8
|
+
create function private.set_updated_at()
|
|
9
|
+
returns trigger
|
|
10
|
+
language plpgsql
|
|
11
|
+
set search_path = ''
|
|
12
|
+
as $$
|
|
13
|
+
begin
|
|
14
|
+
new.updated_at = now();
|
|
15
|
+
return new;
|
|
16
|
+
end;
|
|
17
|
+
$$;
|
|
18
|
+
|
|
19
|
+
create table public.profiles (
|
|
20
|
+
id uuid primary key references auth.users (id) on delete cascade,
|
|
21
|
+
display_name text not null check (char_length(display_name) between 1 and 120),
|
|
22
|
+
created_at timestamptz not null default now(),
|
|
23
|
+
updated_at timestamptz not null default now()
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
alter table public.profiles enable row level security;
|
|
27
|
+
|
|
28
|
+
create trigger profiles_set_updated_at
|
|
29
|
+
before update on public.profiles
|
|
30
|
+
for each row
|
|
31
|
+
execute function private.set_updated_at();
|
|
32
|
+
|
|
33
|
+
create policy profiles_authenticated_select
|
|
34
|
+
on public.profiles
|
|
35
|
+
for select
|
|
36
|
+
to authenticated
|
|
37
|
+
using ((select auth.uid()) = id);
|
|
38
|
+
|
|
39
|
+
create policy profiles_authenticated_insert
|
|
40
|
+
on public.profiles
|
|
41
|
+
for insert
|
|
42
|
+
to authenticated
|
|
43
|
+
with check ((select auth.uid()) = id);
|
|
44
|
+
|
|
45
|
+
create policy profiles_authenticated_update
|
|
46
|
+
on public.profiles
|
|
47
|
+
for update
|
|
48
|
+
to authenticated
|
|
49
|
+
using ((select auth.uid()) = id)
|
|
50
|
+
with check ((select auth.uid()) = id);
|
|
51
|
+
|
|
52
|
+
grant usage on schema public to authenticated;
|
|
53
|
+
grant usage on schema public to app_be;
|
|
54
|
+
revoke all on table public.profiles from public, anon;
|
|
55
|
+
grant select, insert on table public.profiles to authenticated;
|
|
56
|
+
grant update (display_name) on table public.profiles to authenticated;
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://turbo.build/schema.json",
|
|
3
|
+
"ui": "stream",
|
|
4
|
+
"agentGuidance": false,
|
|
5
|
+
// Turbo strips undeclared env from task processes: the SWC cache variable must pass so next finds its native-binding cache when the default cache root has a host ACL @swc/core refuses (a Windows AppContainer grant).
|
|
6
|
+
"globalPassThroughEnv": ["SWC_NATIVE_BINDING_CACHE", "NEXT_TELEMETRY_DISABLED"],
|
|
7
|
+
"tasks": {
|
|
8
|
+
"build": {
|
|
9
|
+
"dependsOn": ["^build"],
|
|
10
|
+
"outputs": [".next/**", "!.next/cache/**", "dist/**"]
|
|
11
|
+
},
|
|
12
|
+
"dev": {
|
|
13
|
+
"cache": false,
|
|
14
|
+
"persistent": true
|
|
15
|
+
},
|
|
16
|
+
"lint": {
|
|
17
|
+
"dependsOn": ["^build"]
|
|
18
|
+
},
|
|
19
|
+
"typecheck": {
|
|
20
|
+
"dependsOn": ["^build"]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{> app/tool-config/prettierrc}}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
schema: starci/application-stacks@1
|
|
2
|
+
sources:
|
|
3
|
+
- repository: "{{project}}"
|
|
4
|
+
components:
|
|
5
|
+
supabase-postgres:
|
|
6
|
+
image: postgres:16@sha256:1a6ab3f5345eb6dbe04a1349529caabdb0ab09293a09590fad07b2246bfa4b54
|
|
7
|
+
role: stateful
|
|
8
|
+
compose: infra/compose/postgres.yaml
|
|
9
|
+
purpose: The pinned PostgreSQL-compatible database behind the Supabase project.
|
|
10
|
+
required: true
|
|
11
|
+
api:
|
|
12
|
+
image: "{{project}}/api:0.0.0"
|
|
13
|
+
role: service
|
|
14
|
+
compose: infra/compose/api.yaml
|
|
15
|
+
purpose: The Nest API that owns privileged and cross-tenant operations.
|
|
16
|
+
required: true
|
|
17
|
+
environments:
|
|
18
|
+
dev:
|
|
19
|
+
status: supported
|
|
20
|
+
runtime: docker-compose
|
|
21
|
+
composeFiles:
|
|
22
|
+
- infra/compose/compose.yaml
|
|
23
|
+
components:
|
|
24
|
+
supabase-postgres: { port: 5432 }
|
|
25
|
+
api: { port: 3001 }
|
|
26
|
+
runbook: README.md
|
|
27
|
+
secrets: []
|
|
28
|
+
k8s:
|
|
29
|
+
status: deferred
|
|
30
|
+
reason: The upgrade establishes the full local stack first; deployment topology is selected separately.
|
|
31
|
+
services:
|
|
32
|
+
sonar:
|
|
33
|
+
provider: sonarqube
|
|
34
|
+
mode: disabled
|
|
35
|
+
reason: Enable the repository's Sonar service when a host and project token are provisioned.
|
|
36
|
+
qualityGate: starci-quality
|
|
37
|
+
ci: { wiring: not-used }
|
|
38
|
+
ownerAction: none
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Development stack
|
|
2
|
+
|
|
3
|
+
The full-edition development stack keeps PostgreSQL and the API in one declared Docker Compose project.
|
|
4
|
+
|
|
5
|
+
- Prepare: provide `PRIMARY_DB_URL` to the API through the normal secret custody flow.
|
|
6
|
+
- Up: `docker compose -f infra/compose/compose.yaml up -d`.
|
|
7
|
+
- Status: `docker compose -f infra/compose/compose.yaml ps`.
|
|
8
|
+
- Logs: `docker compose -f infra/compose/compose.yaml logs`.
|
|
9
|
+
- Down: `docker compose -f infra/compose/compose.yaml down`.
|
|
10
|
+
- Verify: call the API health endpoint and run `npm run lint`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
services:
|
|
2
|
+
api:
|
|
3
|
+
image: "{{project}}/api:0.0.0"
|
|
4
|
+
build:
|
|
5
|
+
context: ../../../..
|
|
6
|
+
dockerfile: be/apps/api/Dockerfile
|
|
7
|
+
environment:
|
|
8
|
+
PRIMARY_DB_URL: postgres://postgres@supabase-postgres:5432/postgres
|
|
9
|
+
ports:
|
|
10
|
+
- "3001:3000"
|
|
11
|
+
depends_on:
|
|
12
|
+
supabase-postgres:
|
|
13
|
+
condition: service_healthy
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
services:
|
|
2
|
+
supabase-postgres:
|
|
3
|
+
image: postgres:16@sha256:1a6ab3f5345eb6dbe04a1349529caabdb0ab09293a09590fad07b2246bfa4b54
|
|
4
|
+
environment:
|
|
5
|
+
POSTGRES_HOST_AUTH_METHOD: trust
|
|
6
|
+
ports:
|
|
7
|
+
- "5432:5432"
|
|
8
|
+
healthcheck:
|
|
9
|
+
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
10
|
+
interval: 5s
|
|
11
|
+
timeout: 5s
|
|
12
|
+
retries: 12
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const app = await NestFactory.create(AppModule.register(options), { rawBody: true })
|
|
2
|
+
app.enableCors({ origin: [...options.httpSecurity.allowedOrigins] })
|
|
3
|
+
app.enableShutdownHooks()
|
|
4
|
+
await app.listen(options.server.port)
|
|
5
|
+
createJsonLogger(new SystemClockService()).info(LoggingLogEvent.ServerStarted, {
|
|
6
|
+
service: "{{app}}",
|
|
7
|
+
port: options.server.port,
|
|
8
|
+
})
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
bootstrap().catch((error: unknown) => {
|
|
12
|
+
createJsonLogger(new SystemClockService()).error(LoggingLogEvent.StartupFailed, error, { service: "{{app}}" })
|
|
13
|
+
process.exitCode = 1
|
|
14
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# {{project}}/{{app}} - the {{app}} api app. The build context is the APP ROOT (the folder holding the one package.json and
|
|
2
|
+
# package-lock.json), not this folder:
|
|
3
|
+
#
|
|
4
|
+
# docker build -f be/apps/{{app}}/Dockerfile -t {{project}}/{{app}}:<tag> .
|
|
5
|
+
#
|
|
6
|
+
# It follows the image canon (knowledge/hfs/docker.md) and diverges from it nowhere. No secret is built in: credentials are
|
|
7
|
+
# mounted at run time and .dockerignore keeps them out of the build context.
|
|
8
|
+
|
|
9
|
+
FROM {{nodeImage}} AS manifests
|
|
10
|
+
WORKDIR /app
|
|
11
|
+
COPY package.json package-lock.json ./
|
|
12
|
+
COPY fe fe
|
|
13
|
+
RUN find fe -type f ! -name package.json -delete
|
|
14
|
+
|
|
15
|
+
FROM {{nodeImage}} AS build
|
|
16
|
+
WORKDIR /app
|
|
17
|
+
COPY --from=manifests /app ./
|
|
18
|
+
RUN npm ci --ignore-scripts
|
|
19
|
+
|
|
20
|
+
COPY be/tsconfig.json be/tsconfig.build.json be/
|
|
21
|
+
COPY be/src be/src
|
|
22
|
+
COPY be/apps/{{app}} be/apps/{{app}}
|
|
23
|
+
RUN npm run build:be
|
|
24
|
+
|
|
25
|
+
FROM {{nodeImage}} AS runtime
|
|
26
|
+
WORKDIR /app
|
|
27
|
+
ENV NODE_ENV=production
|
|
28
|
+
ENV PORT={{port}}
|
|
29
|
+
|
|
30
|
+
COPY --from=manifests /app ./
|
|
31
|
+
RUN npm ci --omit=dev --ignore-scripts && npm cache clean --force
|
|
32
|
+
|
|
33
|
+
COPY --from=build /app/be/dist be/dist
|
|
34
|
+
|
|
35
|
+
USER node
|
|
36
|
+
EXPOSE {{port}}
|
|
37
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 CMD node -e "fetch('http://127.0.0.1:'+process.env.PORT+'/health/live').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
|
|
38
|
+
CMD ["node", "be/dist/apps/{{app}}/src/main.js"]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# {{project}}/{{app}} - the {{app}} command app: every one-off action (migrate, seed, sync, backup) is one command of this
|
|
2
|
+
# image, run with the command as its arguments, e.g. `docker run --rm {{project}}/{{app}}:<tag> migrate run`. The build context is
|
|
3
|
+
# the APP ROOT (the folder holding the one package.json and package-lock.json), not this folder:
|
|
4
|
+
#
|
|
5
|
+
# docker build -f be/apps/{{app}}/Dockerfile -t {{project}}/{{app}}:<tag> .
|
|
6
|
+
#
|
|
7
|
+
# It follows the image canon (knowledge/hfs/docker.md) and diverges from it nowhere. No secret is built in: credentials are
|
|
8
|
+
# mounted at run time and .dockerignore keeps them out of the build context.
|
|
9
|
+
|
|
10
|
+
FROM {{nodeImage}} AS manifests
|
|
11
|
+
WORKDIR /app
|
|
12
|
+
COPY package.json package-lock.json ./
|
|
13
|
+
COPY fe fe
|
|
14
|
+
RUN find fe -type f ! -name package.json -delete
|
|
15
|
+
|
|
16
|
+
FROM {{nodeImage}} AS build
|
|
17
|
+
WORKDIR /app
|
|
18
|
+
COPY --from=manifests /app ./
|
|
19
|
+
RUN npm ci --ignore-scripts
|
|
20
|
+
|
|
21
|
+
COPY be/tsconfig.json be/tsconfig.build.json be/
|
|
22
|
+
COPY be/src be/src
|
|
23
|
+
COPY be/apps/{{app}} be/apps/{{app}}
|
|
24
|
+
RUN npm run build:be
|
|
25
|
+
|
|
26
|
+
FROM {{nodeImage}} AS runtime
|
|
27
|
+
WORKDIR /app
|
|
28
|
+
ENV NODE_ENV=production
|
|
29
|
+
|
|
30
|
+
COPY --from=manifests /app ./
|
|
31
|
+
RUN npm ci --omit=dev --ignore-scripts && npm cache clean --force
|
|
32
|
+
|
|
33
|
+
COPY --from=build /app/be/dist be/dist
|
|
34
|
+
|
|
35
|
+
USER node
|
|
36
|
+
HEALTHCHECK NONE
|
|
37
|
+
ENTRYPOINT ["node", "be/dist/apps/{{app}}/src/main.js"]
|
|
38
|
+
CMD ["--help"]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# {{project}}/{{app}} - the {{app}} worker app (no listener). The build context is the APP ROOT (the folder holding the one
|
|
2
|
+
# package.json and package-lock.json), not this folder:
|
|
3
|
+
#
|
|
4
|
+
# docker build -f be/apps/{{app}}/Dockerfile -t {{project}}/{{app}}:<tag> .
|
|
5
|
+
#
|
|
6
|
+
# It follows the image canon (knowledge/hfs/docker.md) and diverges from it nowhere. No secret is built in: credentials are
|
|
7
|
+
# mounted at run time and .dockerignore keeps them out of the build context.
|
|
8
|
+
|
|
9
|
+
FROM {{nodeImage}} AS manifests
|
|
10
|
+
WORKDIR /app
|
|
11
|
+
COPY package.json package-lock.json ./
|
|
12
|
+
COPY fe fe
|
|
13
|
+
RUN find fe -type f ! -name package.json -delete
|
|
14
|
+
|
|
15
|
+
FROM {{nodeImage}} AS build
|
|
16
|
+
WORKDIR /app
|
|
17
|
+
COPY --from=manifests /app ./
|
|
18
|
+
RUN npm ci --ignore-scripts
|
|
19
|
+
|
|
20
|
+
COPY be/tsconfig.json be/tsconfig.build.json be/
|
|
21
|
+
COPY be/src be/src
|
|
22
|
+
COPY be/apps/{{app}} be/apps/{{app}}
|
|
23
|
+
RUN npm run build:be
|
|
24
|
+
|
|
25
|
+
FROM {{nodeImage}} AS runtime
|
|
26
|
+
WORKDIR /app
|
|
27
|
+
ENV NODE_ENV=production
|
|
28
|
+
|
|
29
|
+
COPY --from=manifests /app ./
|
|
30
|
+
RUN npm ci --omit=dev --ignore-scripts && npm cache clean --force
|
|
31
|
+
|
|
32
|
+
COPY --from=build /app/be/dist be/dist
|
|
33
|
+
|
|
34
|
+
USER node
|
|
35
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 CMD pgrep -f "apps/{{app}}/src/main.js" > /dev/null || exit 1
|
|
36
|
+
CMD ["node", "be/dist/apps/{{app}}/src/main.js"]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { EntityManager } from "typeorm"
|
|
2
|
+
import { DatabaseError, DatabaseErrorCode } from "./errors/database.error"
|
|
3
|
+
import type { SqlText } from "./database.sql"
|
|
4
|
+
|
|
5
|
+
interface WebhookInboxStatements {
|
|
6
|
+
readonly insert: SqlText
|
|
7
|
+
readonly complete: SqlText
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface AcceptWebhookDelivery extends WebhookInboxStatements {
|
|
11
|
+
readonly entityManager: EntityManager
|
|
12
|
+
readonly provider: string
|
|
13
|
+
readonly deliveryId: string | undefined
|
|
14
|
+
readonly payload: object
|
|
15
|
+
readonly process: (manager: EntityManager) => Promise<void>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface InboxIdentity {
|
|
19
|
+
readonly id: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Claims and processes one delivery in one EntityManager transaction. A conflict returns without calling `process`, so
|
|
24
|
+
* a redelivery receives the original empty acknowledgement and cannot repeat the domain mutation.
|
|
25
|
+
*/
|
|
26
|
+
export const acceptWebhookDelivery = async ({
|
|
27
|
+
entityManager,
|
|
28
|
+
insert,
|
|
29
|
+
complete,
|
|
30
|
+
provider,
|
|
31
|
+
deliveryId,
|
|
32
|
+
payload,
|
|
33
|
+
process,
|
|
34
|
+
}: AcceptWebhookDelivery): Promise<void> => {
|
|
35
|
+
const normalizedDeliveryId = deliveryId?.trim()
|
|
36
|
+
if (!normalizedDeliveryId) {
|
|
37
|
+
throw new DatabaseError({ code: DatabaseErrorCode.WebhookDeliveryIdRequired })
|
|
38
|
+
}
|
|
39
|
+
await entityManager.transaction(async (manager) => {
|
|
40
|
+
const claimed = await manager.query<Array<InboxIdentity>>(insert, [
|
|
41
|
+
provider,
|
|
42
|
+
normalizedDeliveryId,
|
|
43
|
+
JSON.stringify(payload),
|
|
44
|
+
])
|
|
45
|
+
const identity = claimed[0]
|
|
46
|
+
if (identity === undefined) return
|
|
47
|
+
await process(manager)
|
|
48
|
+
await manager.query(complete, [identity.id])
|
|
49
|
+
})
|
|
50
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
create table public.@@table@@ (
|
|
2
|
+
id uuid primary key default gen_random_uuid(),
|
|
3
|
+
provider text not null check (provider = '@@provider@@'),
|
|
4
|
+
delivery_id text not null,
|
|
5
|
+
received_at timestamptz not null default now(),
|
|
6
|
+
payload jsonb not null,
|
|
7
|
+
processed_at timestamptz,
|
|
8
|
+
constraint @@table@@_provider_delivery_id_key unique (provider, delivery_id)
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
alter table public.@@table@@ enable row level security;
|
|
12
|
+
|
|
13
|
+
-- The dedicated app_be PostgreSQL role is the only application path. With no anon or authenticated policy,
|
|
14
|
+
-- RLS denies those PostgREST roles by default; the service-role JWT is deliberately not granted here.
|
|
15
|
+
create policy "@@table@@_app_be_select"
|
|
16
|
+
on public.@@table@@ for select to app_be
|
|
17
|
+
using (provider = '@@provider@@');
|
|
18
|
+
|
|
19
|
+
create policy "@@table@@_app_be_insert"
|
|
20
|
+
on public.@@table@@ for insert to app_be
|
|
21
|
+
with check (provider = '@@provider@@');
|
|
22
|
+
|
|
23
|
+
create policy "@@table@@_app_be_update"
|
|
24
|
+
on public.@@table@@ for update to app_be
|
|
25
|
+
using (provider = '@@provider@@')
|
|
26
|
+
with check (provider = '@@provider@@');
|
|
27
|
+
|
|
28
|
+
revoke all on table public.@@table@@ from public, anon, authenticated;
|
|
29
|
+
grant select, insert, update on table public.@@table@@ to app_be;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConfigurableModuleBuilder } from "@nestjs/common"
|
|
2
|
+
import type { @@Provider@@InboxOptions } from "./@@provider@@-inbox.options"
|
|
3
|
+
|
|
4
|
+
export const { ConfigurableModuleClass, OPTIONS_TYPE } = new ConfigurableModuleBuilder<@@Provider@@InboxOptions>()
|
|
5
|
+
.setExtras({ isGlobal: false }, (definition, extras) => ({ ...definition, global: extras.isGlobal }))
|
|
6
|
+
.build()
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Module } from "@nestjs/common"
|
|
2
|
+
import type { DynamicModule } from "@nestjs/common"
|
|
3
|
+
import { ConfigurableModuleClass, OPTIONS_TYPE } from "./@@provider@@-inbox.module-definition"
|
|
4
|
+
import { @@Provider@@InboxService } from "./@@provider@@-inbox.service"
|
|
5
|
+
|
|
6
|
+
@Module({})
|
|
7
|
+
/** The durable, provider-specific inbox composed once by the API app. */
|
|
8
|
+
export class @@Provider@@InboxModule extends ConfigurableModuleClass {
|
|
9
|
+
/** Registers the @@provider@@ inbox and exposes its intake to the webhook door. */
|
|
10
|
+
static register(options: typeof OPTIONS_TYPE): DynamicModule {
|
|
11
|
+
const base = super.register(options)
|
|
12
|
+
return { ...base, providers: [...(base.providers ?? []), @@Provider@@InboxService], exports: [@@Provider@@InboxService] }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Injectable } from "@nestjs/common"
|
|
2
|
+
import type { EntityManager } from "typeorm"
|
|
3
|
+
import { @@service@@ } from "@@serviceModule@@"
|
|
4
|
+
import { acceptWebhookDelivery, InjectPrimaryEntityManager } from "@modules/platform/database"
|
|
5
|
+
import { COMPLETE_@@providerUpper@@_INBOX, INSERT_@@providerUpper@@_INBOX } from "./persistence/@@provider@@-inbox.sql"
|
|
6
|
+
|
|
7
|
+
interface @@Provider@@Delivery {
|
|
8
|
+
readonly id: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type @@Provider@@DeliveryId = string | undefined
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
/** Claims each @@provider@@ delivery once, then runs the domain intake and completion marker in the same transaction. */
|
|
15
|
+
export class @@Provider@@InboxService {
|
|
16
|
+
constructor(
|
|
17
|
+
@InjectPrimaryEntityManager() private readonly entityManager: EntityManager,
|
|
18
|
+
private readonly deliveries: @@service@@,
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
/** A duplicate is acknowledged without invoking the domain intake a second time. */
|
|
22
|
+
accept@@Provider@@Delivery(deliveryId: @@Provider@@DeliveryId, delivery: @@Provider@@Delivery): Promise<void> {
|
|
23
|
+
return acceptWebhookDelivery({
|
|
24
|
+
entityManager: this.entityManager,
|
|
25
|
+
insert: INSERT_@@providerUpper@@_INBOX,
|
|
26
|
+
complete: COMPLETE_@@providerUpper@@_INBOX,
|
|
27
|
+
provider: "@@provider@@",
|
|
28
|
+
deliveryId,
|
|
29
|
+
payload: delivery,
|
|
30
|
+
process: (manager) => this.deliveries.accept@@Provider@@Delivery(delivery, manager),
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { sql } from "@modules/platform/database"
|
|
2
|
+
|
|
3
|
+
/** Claims one @@provider@@ delivery and returns its durable inbox identity only to the winning transaction. */
|
|
4
|
+
export const INSERT_@@providerUpper@@_INBOX = sql`INSERT INTO public.@@table@@ (provider, delivery_id, payload)
|
|
5
|
+
VALUES ($1, $2, $3::jsonb)
|
|
6
|
+
ON CONFLICT (provider, delivery_id) DO NOTHING
|
|
7
|
+
RETURNING id`
|
|
8
|
+
|
|
9
|
+
/** Marks the claimed delivery complete before the same transaction commits. */
|
|
10
|
+
export const COMPLETE_@@providerUpper@@_INBOX = sql`WITH completed AS (
|
|
11
|
+
UPDATE public.@@table@@
|
|
12
|
+
SET processed_at = now()
|
|
13
|
+
WHERE id = $1
|
|
14
|
+
RETURNING id
|
|
15
|
+
)
|
|
16
|
+
SELECT id FROM completed`
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Body, Controller, Headers, HttpCode, HttpStatus, Post, Req } from "@nestjs/common"
|
|
2
|
+
import type { RawBodyRequest } from "@nestjs/common"
|
|
3
|
+
import type { Request } from "express"
|
|
4
|
+
import { Public, PublicReason } from "@modules/domain/identity"
|
|
5
|
+
import { @@Provider@@InboxService } from "@modules/domain/@@provider@@-inbox"
|
|
6
|
+
import { InjectWebhookSignature, RateLimit, RateTier } from "@modules/platform/http-security"
|
|
7
|
+
import type { WebhookSignatureService } from "@modules/platform/http-security"
|
|
8
|
+
import { @@Event@@Request } from "./dto/@@event@@.request"
|
|
9
|
+
|
|
10
|
+
@Controller("webhooks/@@provider@@")
|
|
11
|
+
/**
|
|
12
|
+
* POST /webhooks/@@provider@@, the signed intake door of the @@provider@@ notifier. The signature and replay window are proven
|
|
13
|
+
* first; the verified delivery goes to one domain intake that claims its inbox row and processes it in one transaction.
|
|
14
|
+
*/
|
|
15
|
+
export class @@Provider@@Webhook {
|
|
16
|
+
constructor(
|
|
17
|
+
@InjectWebhookSignature() private readonly signature: WebhookSignatureService,
|
|
18
|
+
private readonly deliveries: @@Provider@@InboxService,
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
/** Acknowledges with 204 and no body: a duplicate receives the same acknowledgement without being processed again. */
|
|
22
|
+
@Post()
|
|
23
|
+
@HttpCode(HttpStatus.NO_CONTENT)
|
|
24
|
+
@Public({ reason: PublicReason.SignedWebhook })
|
|
25
|
+
@RateLimit(RateTier.Strict)
|
|
26
|
+
async receive(
|
|
27
|
+
@Req() request: RawBodyRequest<Request>,
|
|
28
|
+
@Headers("x-@@provider@@-signature") signature: string | undefined,
|
|
29
|
+
@Headers("x-@@provider@@-timestamp") timestamp: string | undefined,
|
|
30
|
+
@Headers("x-@@provider@@-delivery-id") deliveryId: string | undefined,
|
|
31
|
+
@Body() delivery: @@Event@@Request,
|
|
32
|
+
): Promise<void> {
|
|
33
|
+
this.signature.verify({ provider: "@@provider@@", rawBody: request.rawBody, signature, timestamp })
|
|
34
|
+
await this.deliveries.accept@@Provider@@Delivery(deliveryId, delivery)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "@nestjs/cqrs"
|
|
2
|
+
import type { ExecuteParams } from "@modules/platform/cqrs"
|
|
3
|
+
import type { @@Action@@Request, @@Action@@Result } from "./@@action@@.contracts"
|
|
4
|
+
|
|
5
|
+
/** Asks to run @@action@@ for the authenticated caller. */
|
|
6
|
+
export class @@Action@@Command extends Command<@@Action@@Result> {
|
|
7
|
+
constructor(readonly params: ExecuteParams<@@Action@@Request>) {
|
|
8
|
+
super()
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "@nestjs/cqrs"
|
|
2
|
+
import type { ExecuteParams } from "@modules/platform/cqrs"
|
|
3
|
+
import type { @@Action@@Request, @@Action@@Result } from "./@@action@@.contracts"
|
|
4
|
+
|
|
5
|
+
/** Asks to run @@action@@ for the caller. */
|
|
6
|
+
export class @@Action@@Command extends Command<@@Action@@Result> {
|
|
7
|
+
constructor(readonly params: ExecuteParams<@@Action@@Request>) {
|
|
8
|
+
super()
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** What @@action@@ takes. */
|
|
2
|
+
export interface @@Action@@Request {
|
|
3
|
+
/** The id of the subject. */
|
|
4
|
+
readonly id: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** What @@action@@ answers. */
|
|
8
|
+
export interface @@Action@@Result {
|
|
9
|
+
/** The id of the subject. */
|
|
10
|
+
readonly id: string
|
|
11
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CommandHandler } from "@nestjs/cqrs"
|
|
2
|
+
import { @@service@@ } from "@@serviceModule@@"
|
|
3
|
+
import { ICQRSHandler } from "@modules/platform/cqrs"
|
|
4
|
+
import { InjectLogger } from "@modules/platform/logging"
|
|
5
|
+
import type { Logger } from "@modules/platform/logging"
|
|
6
|
+
import type { @@Action@@Result } from "./@@action@@.contracts"
|
|
7
|
+
import { @@Action@@Command } from "./@@action@@.command"
|
|
8
|
+
|
|
9
|
+
@CommandHandler(@@Action@@Command)
|
|
10
|
+
/** Runs @@action@@ for the authenticated principal through one domain-service call. */
|
|
11
|
+
export class @@Action@@Handler extends ICQRSHandler<@@Action@@Command, @@Action@@Result> {
|
|
12
|
+
constructor(
|
|
13
|
+
@InjectLogger() logger: Logger,
|
|
14
|
+
private readonly @@serviceCamel@@: @@service@@,
|
|
15
|
+
) {
|
|
16
|
+
super(logger)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
protected override process(command: @@Action@@Command): Promise<@@Action@@Result> {
|
|
20
|
+
return this.@@serviceCamel@@.@@actionCamel@@(command.params.principal.id, command.params.request.id)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CommandHandler } from "@nestjs/cqrs"
|
|
2
|
+
import { @@service@@ } from "@@serviceModule@@"
|
|
3
|
+
import { ICQRSHandler } from "@modules/platform/cqrs"
|
|
4
|
+
import { InjectLogger } from "@modules/platform/logging"
|
|
5
|
+
import type { Logger } from "@modules/platform/logging"
|
|
6
|
+
import type { @@Action@@Result } from "./@@action@@.contracts"
|
|
7
|
+
import { @@Action@@Command } from "./@@action@@.command"
|
|
8
|
+
|
|
9
|
+
@CommandHandler(@@Action@@Command)
|
|
10
|
+
/** Runs @@action@@: the domain service decides and writes in one transaction. */
|
|
11
|
+
export class @@Action@@Handler extends ICQRSHandler<@@Action@@Command, @@Action@@Result> {
|
|
12
|
+
constructor(
|
|
13
|
+
@InjectLogger() logger: Logger,
|
|
14
|
+
private readonly @@serviceCamel@@: @@service@@,
|
|
15
|
+
) {
|
|
16
|
+
super(logger)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
protected override process(command: @@Action@@Command): Promise<@@Action@@Result> {
|
|
20
|
+
return this.@@serviceCamel@@.@@actionCamel@@(command.params.request)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { @@Feature@@HttpModule } from "./transport/http/@@feature@@-http.module"
|