ddd-ts-kit 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -9
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +2 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/configuration/config-inspection.d.ts +4 -0
- package/dist/check/configuration/config-inspection.d.ts.map +1 -1
- package/dist/check/configuration/config-inspection.js +10 -1
- package/dist/check/configuration/config-inspection.js.map +1 -1
- package/dist/check/explain/persistence-docs.d.ts +3 -0
- package/dist/check/explain/persistence-docs.d.ts.map +1 -0
- package/dist/check/explain/persistence-docs.js +14 -0
- package/dist/check/explain/persistence-docs.js.map +1 -0
- package/dist/check/explain/rule-docs.d.ts.map +1 -1
- package/dist/check/explain/rule-docs.js +2 -0
- package/dist/check/explain/rule-docs.js.map +1 -1
- package/dist/check/fixtures/fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/fixtures.js +2 -0
- package/dist/check/fixtures/fixtures.js.map +1 -1
- package/dist/check/fixtures/persistence-fixtures.d.ts +3 -0
- package/dist/check/fixtures/persistence-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/persistence-fixtures.js +72 -0
- package/dist/check/fixtures/persistence-fixtures.js.map +1 -0
- package/dist/check/migrations/drizzle-history-findings.d.ts +9 -0
- package/dist/check/migrations/drizzle-history-findings.d.ts.map +1 -0
- package/dist/check/migrations/drizzle-history-findings.js +70 -0
- package/dist/check/migrations/drizzle-history-findings.js.map +1 -0
- package/dist/check/migrations/drizzle-migrations.d.ts +23 -0
- package/dist/check/migrations/drizzle-migrations.d.ts.map +1 -0
- package/dist/check/migrations/drizzle-migrations.js +2 -0
- package/dist/check/migrations/drizzle-migrations.js.map +1 -0
- package/dist/check/migrations/drizzle-out-folder.d.ts +3 -0
- package/dist/check/migrations/drizzle-out-folder.d.ts.map +1 -0
- package/dist/check/migrations/drizzle-out-folder.js +18 -0
- package/dist/check/migrations/drizzle-out-folder.js.map +1 -0
- package/dist/check/migrations/migration-folder.d.ts +13 -0
- package/dist/check/migrations/migration-folder.d.ts.map +1 -0
- package/dist/check/migrations/migration-folder.js +2 -0
- package/dist/check/migrations/migration-folder.js.map +1 -0
- package/dist/check/migrations/migration-name-findings.d.ts +9 -0
- package/dist/check/migrations/migration-name-findings.d.ts.map +1 -0
- package/dist/check/migrations/migration-name-findings.js +32 -0
- package/dist/check/migrations/migration-name-findings.js.map +1 -0
- package/dist/check/migrations/read-drizzle-migrations.d.ts +4 -0
- package/dist/check/migrations/read-drizzle-migrations.d.ts.map +1 -0
- package/dist/check/migrations/read-drizzle-migrations.js +67 -0
- package/dist/check/migrations/read-drizzle-migrations.js.map +1 -0
- package/dist/check/migrations/read-migration-folder.d.ts +5 -0
- package/dist/check/migrations/read-migration-folder.d.ts.map +1 -0
- package/dist/check/migrations/read-migration-folder.js +38 -0
- package/dist/check/migrations/read-migration-folder.js.map +1 -0
- package/dist/check/rules/config-valid.d.ts.map +1 -1
- package/dist/check/rules/config-valid.js +3 -1
- package/dist/check/rules/config-valid.js.map +1 -1
- package/dist/check/rules/persistence-migration-history.d.ts +3 -0
- package/dist/check/rules/persistence-migration-history.d.ts.map +1 -0
- package/dist/check/rules/persistence-migration-history.js +24 -0
- package/dist/check/rules/persistence-migration-history.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +10 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commit/is-derived.d.ts.map +1 -1
- package/dist/commit/is-derived.js +5 -7
- package/dist/commit/is-derived.js.map +1 -1
- package/dist/config/ci-extra-problems.d.ts +4 -0
- package/dist/config/ci-extra-problems.d.ts.map +1 -0
- package/dist/config/ci-extra-problems.js +27 -0
- package/dist/config/ci-extra-problems.js.map +1 -0
- package/dist/config/ci-extras.d.ts +13 -0
- package/dist/config/ci-extras.d.ts.map +1 -0
- package/dist/config/ci-extras.js +13 -0
- package/dist/config/ci-extras.js.map +1 -0
- package/dist/config/config.d.ts +23 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/index.d.ts +4 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/open-api-problems.d.ts +4 -0
- package/dist/config/open-api-problems.d.ts.map +1 -0
- package/dist/config/open-api-problems.js +87 -0
- package/dist/config/open-api-problems.js.map +1 -0
- package/dist/config/openapi-formats.d.ts +3 -0
- package/dist/config/openapi-formats.d.ts.map +1 -0
- package/dist/config/openapi-formats.js +3 -0
- package/dist/config/openapi-formats.js.map +1 -0
- package/dist/config/parse-ci.d.ts +4 -0
- package/dist/config/parse-ci.d.ts.map +1 -0
- package/dist/config/parse-ci.js +7 -0
- package/dist/config/parse-ci.js.map +1 -0
- package/dist/config/parse-config.d.ts.map +1 -1
- package/dist/config/parse-config.js +4 -0
- package/dist/config/parse-config.js.map +1 -1
- package/dist/config/parse-open-api.d.ts +4 -0
- package/dist/config/parse-open-api.d.ts.map +1 -0
- package/dist/config/parse-open-api.js +20 -0
- package/dist/config/parse-open-api.js.map +1 -0
- package/dist/config/restack-config-text.d.ts +1 -1
- package/dist/config/restack-config-text.d.ts.map +1 -1
- package/dist/config/restack-config-text.js +9 -2
- package/dist/config/restack-config-text.js.map +1 -1
- package/dist/config/serialize-config.js +8 -0
- package/dist/config/serialize-config.js.map +1 -1
- package/dist/contracts/contract-format.d.ts +3 -0
- package/dist/contracts/contract-format.d.ts.map +1 -0
- package/dist/contracts/contract-format.js +11 -0
- package/dist/contracts/contract-format.js.map +1 -0
- package/dist/contracts/stringify-contract.d.ts +3 -0
- package/dist/contracts/stringify-contract.d.ts.map +1 -0
- package/dist/contracts/stringify-contract.js +6 -0
- package/dist/contracts/stringify-contract.js.map +1 -0
- package/dist/contracts.d.ts +9 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +9 -0
- package/dist/contracts.js.map +1 -0
- package/dist/describe/describe-context.d.ts.map +1 -1
- package/dist/describe/describe-context.js +14 -3
- package/dist/describe/describe-context.js.map +1 -1
- package/dist/docs/open-api-documents-file.d.ts +4 -0
- package/dist/docs/open-api-documents-file.d.ts.map +1 -0
- package/dist/docs/open-api-documents-file.js +5 -0
- package/dist/docs/open-api-documents-file.js.map +1 -0
- package/dist/docs/render-open-api-documents.d.ts +13 -0
- package/dist/docs/render-open-api-documents.d.ts.map +1 -0
- package/dist/docs/render-open-api-documents.js +42 -0
- package/dist/docs/render-open-api-documents.js.map +1 -0
- package/dist/docs/write-docs.d.ts.map +1 -1
- package/dist/docs/write-docs.js +2 -0
- package/dist/docs/write-docs.js.map +1 -1
- package/dist/docs/write-open-api-documents.d.ts +9 -0
- package/dist/docs/write-open-api-documents.d.ts.map +1 -0
- package/dist/docs/write-open-api-documents.js +33 -0
- package/dist/docs/write-open-api-documents.js.map +1 -0
- package/dist/help/commands-guide-region.d.ts +3 -0
- package/dist/help/commands-guide-region.d.ts.map +1 -0
- package/dist/help/commands-guide-region.js +12 -0
- package/dist/help/commands-guide-region.js.map +1 -0
- package/dist/help/notes.d.ts +3 -0
- package/dist/help/notes.d.ts.map +1 -0
- package/dist/help/notes.js +24 -0
- package/dist/help/notes.js.map +1 -0
- package/dist/help/reference-text.d.ts +3 -0
- package/dist/help/reference-text.d.ts.map +1 -0
- package/dist/help/reference-text.js +14 -0
- package/dist/help/reference-text.js.map +1 -0
- package/dist/help/usage.d.ts +3 -0
- package/dist/help/usage.d.ts.map +1 -0
- package/dist/help/usage.js +37 -0
- package/dist/help/usage.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/init/files/persistence-files.js +1 -1
- package/dist/init/files/persistence-files.js.map +1 -1
- package/dist/init/files/pipeline-files.d.ts.map +1 -1
- package/dist/init/files/pipeline-files.js +4 -2
- package/dist/init/files/pipeline-files.js.map +1 -1
- package/dist/init/manifest/database-scripts.d.ts.map +1 -1
- package/dist/init/manifest/database-scripts.js +5 -4
- package/dist/init/manifest/database-scripts.js.map +1 -1
- package/dist/init/manifest/versions.js +25 -25
- package/dist/init/manifest/versions.js.map +1 -1
- package/dist/init/run-init.d.ts.map +1 -1
- package/dist/init/run-init.js +3 -0
- package/dist/init/run-init.js.map +1 -1
- package/dist/init/stack/resolve-ci-extras.d.ts +8 -0
- package/dist/init/stack/resolve-ci-extras.d.ts.map +1 -0
- package/dist/init/stack/resolve-ci-extras.js +31 -0
- package/dist/init/stack/resolve-ci-extras.js.map +1 -0
- package/dist/init/stack/resolve-stack.d.ts.map +1 -1
- package/dist/init/stack/resolve-stack.js +3 -1
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/stack/stack-options.d.ts +2 -0
- package/dist/init/stack/stack-options.d.ts.map +1 -1
- package/dist/init/template-vars.d.ts.map +1 -1
- package/dist/init/template-vars.js +14 -0
- package/dist/init/template-vars.js.map +1 -1
- package/dist/init/write-agent-settings.js +2 -2
- package/dist/init/write-agent-settings.js.map +1 -1
- package/dist/init/write-contracts.d.ts.map +1 -1
- package/dist/init/write-contracts.js +7 -3
- package/dist/init/write-contracts.js.map +1 -1
- package/dist/progress/format-progress.d.ts.map +1 -1
- package/dist/progress/format-progress.js +3 -1
- package/dist/progress/format-progress.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +2 -63
- package/dist/run.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/yaml/to-yaml.d.ts +8 -0
- package/dist/yaml/to-yaml.d.ts.map +1 -0
- package/dist/yaml/to-yaml.js +132 -0
- package/dist/yaml/to-yaml.js.map +1 -0
- package/package.json +2 -2
- package/templates/docs/integration-readme.md.tpl +2 -2
- package/templates/init/CLAUDE.md.tpl +2 -1
- package/templates/init/README.md.tpl +37 -11
- package/templates/init/platform/database/data-source.typeorm.ts.tpl +1 -1
- package/templates/init/platform/database/drizzle.config.ts.tpl +2 -0
- package/templates/init/platform/database/knexfile.js.tpl +9 -3
- package/templates/init/platform/database/schema.drizzle.ts.tpl +1 -1
- package/templates/init/platform/database/schema.knex.ts.tpl +2 -2
- package/templates/init/platform/http/with-documentation.ts.tpl +13 -9
- package/templates/init/rules/presentation.md.tpl +1 -1
- package/templates/init/scripts/events.ts.tpl +16 -5
- package/templates/init/scripts/openapi.ts.tpl +49 -20
- package/templates/pipeline/github/branch-protection.md +8 -7
- package/templates/pipeline/github/dependabot.yml +5 -0
- package/templates/pipeline/github/workflows/{ci.yml → ci.yml.tpl} +3 -0
- package/templates/pipeline/gitlab/gitlab-ci.yml.tpl +11 -0
- package/templates/pipeline/gitlab/merge-request-settings.md +7 -6
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/pipeline/renovate.json +5 -0
- package/templates/repository/drizzle/table.tpl +2 -2
- package/templates/repository/prisma/model.tpl +1 -1
- package/templates/repository/typeorm/table.tpl +1 -1
|
@@ -10,7 +10,7 @@ export const processedEvents = processedEventsTable('messaging');
|
|
|
10
10
|
/** The schema of the audit trail. */
|
|
11
11
|
export const AUDIT_SCHEMA = 'audit';
|
|
12
12
|
|
|
13
|
-
// TODO(platform): drizzle-kit writes no trigger. After `npm run db:generate
|
|
13
|
+
// TODO(platform): drizzle-kit writes no trigger. After the first `npm run db:generate <name>`, add a custom migration (`npm run db:generate -- audit-guard --custom`) holding the statements `npm run db:audit-guard` prints: they make the entries refuse UPDATE, DELETE and TRUNCATE.
|
|
14
14
|
export const auditEntries = auditEntriesTable(AUDIT_SCHEMA);
|
|
15
15
|
export const auditChains = auditChainsTable(AUDIT_SCHEMA);
|
|
16
16
|
{{/if}}
|
|
@@ -13,9 +13,9 @@ export const AUDIT_SCHEMA = 'audit';
|
|
|
13
13
|
{{/if}}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* Every table of the application. The first migration (migrations/
|
|
16
|
+
* Every table of the application. The first migration (migrations/00000000000000_initial.js) and the
|
|
17
17
|
* in-process database of the tests both call it; once a database is shared, a change of an
|
|
18
|
-
* existing table goes into a migration of its own (`npm run db:generate <
|
|
18
|
+
* existing table goes into a migration of its own (`npm run db:generate <what-it-does>`).
|
|
19
19
|
*/
|
|
20
20
|
export const createTables = async (knex: Knex): Promise<void> => {
|
|
21
21
|
await createOutboxTables(knex, { schema: MESSAGING });
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import type { Route } from '@ddd-ts-kit/http';
|
|
2
|
-
import {
|
|
3
|
-
import { generateOpenApi } from '@ddd-ts-kit/http/openapi';
|
|
2
|
+
import { openApiDocumentsRoutes } from '@ddd-ts-kit/http/docs';
|
|
3
|
+
import { generateOpenApi, routesByDocument } from '@ddd-ts-kit/http/openapi';
|
|
4
4
|
import { securitySchemes } from '{{alias.platform}}/auth/security-schemes{{alias.ext}}';
|
|
5
5
|
import type { AppConfig } from '{{alias.platform}}/config/app-config{{alias.ext}}';
|
|
6
|
+
import { OPENAPI_DOCUMENTS } from '{{alias.platform}}/http/openapi-documents{{alias.ext}}';
|
|
6
7
|
|
|
7
|
-
/** Adds the contract and its interactive page next to the routes, unless documentation is switched off (API_DOCS, off in production by default). */
|
|
8
|
+
/** Adds the contract and its interactive page next to the routes, one per document of a split contract, unless documentation is switched off (API_DOCS, off in production by default). */
|
|
8
9
|
export function withDocumentation(routes: readonly Route[], config: AppConfig): readonly Route[] {
|
|
9
10
|
if (!config.docsEnabled) {
|
|
10
11
|
return routes;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const documents = routesByDocument(routes, OPENAPI_DOCUMENTS).map(({ name, title, routes: selected }) => ({
|
|
15
|
+
name,
|
|
16
|
+
document: generateOpenApi({
|
|
17
|
+
info: { title: title ?? config.serviceName, version: config.serviceVersion },
|
|
18
|
+
routes: selected,
|
|
19
|
+
securitySchemes,
|
|
20
|
+
}),
|
|
21
|
+
}));
|
|
18
22
|
|
|
19
|
-
return [...routes, ...
|
|
23
|
+
return [...routes, ...openApiDocumentsRoutes(documents, { ui: '{{docs.ui}}', title: config.serviceName })];
|
|
20
24
|
}
|
|
@@ -28,5 +28,5 @@ paths:
|
|
|
28
28
|
- Request and response types are presentation types, one class or schema per file next to the controller (`*.body.ts`, `*.params.ts`, `*.answer.ts`...; `*.dto.ts` for function routes and under `shared/`): never an aggregate, never a row.
|
|
29
29
|
- Never put the message of an unexpected failure in a response or a log.
|
|
30
30
|
- Files: the canonical tree of `presentation/http/` (`naming/suffix`, `tree/closed`): a folder per controller, `*.routes.ts` for the groups, `guards/`, `shared/`; function routes stay flat (`*.route.ts`, `*.dto.ts`).
|
|
31
|
-
- After a change, `npm run docs:generate` regenerates `openapi/openapi.json
|
|
31
|
+
- After a change, `npm run docs:generate` regenerates the contract, `openapi/openapi.yaml` (one file per document when `openapi.documents` of `ddd-ts-kit.config.json` splits it; JSON under `openapi.format: json`), committed with the route; CI fails on a difference. Never edit it by hand.
|
|
32
32
|
- Contract with `/ddd-ts-kit:document`. Create with `npx ddd-ts-kit generate route <context> <UseCase> --method <M> --path <p> [--group <Name>] [--mapper] [--serializer] --json`, then `generate e2e <context> <UseCase>`; `generate route-group` and `generate guard` write a group and a guard.
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { createEventRegistry, generateEventCatalog, type AnyIntegrationEventDefinition } from '@ddd-ts-kit/events';
|
|
4
|
-
import { generateAsyncApi
|
|
4
|
+
import { generateAsyncApi } from '@ddd-ts-kit/events/asyncapi';
|
|
5
|
+
import { contractFormat, stringifyContract } from 'ddd-ts-kit/dist/contracts.js';
|
|
5
6
|
|
|
6
|
-
// Generates docs/integration/asyncapi.json
|
|
7
|
-
//
|
|
8
|
-
// differs. Both files are build
|
|
7
|
+
// Generates docs/integration/asyncapi.yaml (asyncapi.json under "openapi.format": "json" in
|
|
8
|
+
// ddd-ts-kit.config.json) and docs/integration/event-catalog.md from the declarations of every
|
|
9
|
+
// published language; with --check, fails when a committed file differs. Both files are build
|
|
10
|
+
// products: never edit them by hand.
|
|
9
11
|
const contextsDirectory = '{{config.contextsDir}}';
|
|
10
12
|
const target = path.resolve('docs/integration');
|
|
13
|
+
const format = contractFormat();
|
|
14
|
+
const other = format === 'yaml' ? 'asyncapi.json' : 'asyncapi.yaml';
|
|
11
15
|
|
|
12
16
|
const registry = createEventRegistry(await declaredEvents());
|
|
13
17
|
|
|
14
18
|
const generated: Readonly<Record<string, string>> = {
|
|
15
|
-
|
|
19
|
+
[`asyncapi.${format}`]: stringifyContract(
|
|
16
20
|
generateAsyncApi({
|
|
17
21
|
info: {
|
|
18
22
|
title: manifestField('name', '{{project.name}}'),
|
|
@@ -20,6 +24,7 @@ const generated: Readonly<Record<string, string>> = {
|
|
|
20
24
|
},
|
|
21
25
|
registry,
|
|
22
26
|
}),
|
|
27
|
+
format,
|
|
23
28
|
),
|
|
24
29
|
'event-catalog.md': generateEventCatalog(registry, { consumers: consumersByEventType() }),
|
|
25
30
|
};
|
|
@@ -28,6 +33,7 @@ if (process.argv.includes('--check')) {
|
|
|
28
33
|
reportStale();
|
|
29
34
|
} else {
|
|
30
35
|
fs.mkdirSync(target, { recursive: true });
|
|
36
|
+
fs.rmSync(path.join(target, other), { force: true });
|
|
31
37
|
|
|
32
38
|
for (const [file, content] of Object.entries(generated)) {
|
|
33
39
|
fs.writeFileSync(path.join(target, file), content);
|
|
@@ -43,6 +49,11 @@ function reportStale(): void {
|
|
|
43
49
|
process.exitCode = 1;
|
|
44
50
|
}
|
|
45
51
|
}
|
|
52
|
+
|
|
53
|
+
if (fs.existsSync(path.join(target, other))) {
|
|
54
|
+
console.error('docs/integration/' + other + ' is in the other format: run the script `docs:generate`.');
|
|
55
|
+
process.exitCode = 1;
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
|
|
48
59
|
/** Every declaration exported by a published language. Read from the compiled modules next to this script, so that a new context needs no registration: a path completed at run time cannot be an import alias, which the build rewrites. */
|
|
@@ -1,47 +1,76 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { generateOpenApi, routesByDocument } from '@ddd-ts-kit/http/openapi';
|
|
4
|
+
import { contractFormat, stringifyContract } from 'ddd-ts-kit/dist/contracts.js';
|
|
4
5
|
import { offlineAuthenticator } from '{{alias.platform}}/auth/offline-authenticator{{alias.ext}}';
|
|
5
6
|
import { securitySchemes } from '{{alias.platform}}/auth/security-schemes{{alias.ext}}';
|
|
6
7
|
import { composeApplication } from '{{alias.platform}}/compose-application{{alias.ext}}';
|
|
7
8
|
import { inertPersistence } from '{{alias.platform}}/database/inert-persistence{{alias.ext}}';
|
|
8
9
|
import { inProcessEvents } from '{{alias.platform}}/events/in-process-events{{alias.ext}}';
|
|
10
|
+
import { OPENAPI_DOCUMENTS } from '{{alias.platform}}/http/openapi-documents{{alias.ext}}';
|
|
9
11
|
|
|
10
|
-
// Generates
|
|
11
|
-
//
|
|
12
|
-
|
|
12
|
+
// Generates the contract from the route definitions: openapi/openapi.yaml, or one file per
|
|
13
|
+
// document of "openapi.documents" in ddd-ts-kit.config.json, in the format of "openapi.format";
|
|
14
|
+
// with --check, fails when a committed file differs. Build products: never edit them by hand.
|
|
15
|
+
const directory = path.resolve('openapi');
|
|
16
|
+
const format = contractFormat();
|
|
13
17
|
|
|
14
18
|
const application = composeApplication(inertPersistence(), {
|
|
15
19
|
events: inProcessEvents(),
|
|
16
20
|
authenticator: offlineAuthenticator,
|
|
17
21
|
});
|
|
18
22
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const generated = new Map(
|
|
24
|
+
routesByDocument(application.routes, OPENAPI_DOCUMENTS).map(({ name, title, routes }) => [
|
|
25
|
+
`${name}.${format}`,
|
|
26
|
+
stringifyContract(
|
|
27
|
+
generateOpenApi({
|
|
28
|
+
info: { title: title ?? manifestField('name', '{{project.name}}'), version: manifestField('version', '0.0.0') },
|
|
29
|
+
routes,
|
|
30
|
+
securitySchemes,
|
|
31
|
+
errorMapper: application.boundary.errorMapper,
|
|
32
|
+
}),
|
|
33
|
+
format,
|
|
34
|
+
),
|
|
35
|
+
]),
|
|
36
|
+
);
|
|
28
37
|
|
|
29
38
|
if (process.argv.includes('--check')) {
|
|
30
39
|
reportDrift();
|
|
31
40
|
} else {
|
|
32
|
-
fs.mkdirSync(
|
|
33
|
-
|
|
41
|
+
fs.mkdirSync(directory, { recursive: true });
|
|
42
|
+
|
|
43
|
+
for (const file of staleFiles()) {
|
|
44
|
+
fs.rmSync(path.join(directory, file));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
for (const [file, content] of generated) {
|
|
48
|
+
fs.writeFileSync(path.join(directory, file), content);
|
|
49
|
+
}
|
|
34
50
|
}
|
|
35
51
|
|
|
36
52
|
function reportDrift(): void {
|
|
37
|
-
const
|
|
53
|
+
for (const [file, content] of generated) {
|
|
54
|
+
const target = path.join(directory, file);
|
|
55
|
+
const committed = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : '';
|
|
38
56
|
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
if (committed.replaceAll('\r\n', '\n') !== content) {
|
|
58
|
+
console.error(`openapi/${file} is out of date: run the script \`docs:generate\` and commit it.`);
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
}
|
|
41
61
|
}
|
|
42
62
|
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
for (const file of staleFiles()) {
|
|
64
|
+
console.error(`openapi/${file} is no document of the contract any more: run the script \`docs:generate\`.`);
|
|
65
|
+
process.exitCode = 1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The contracts left by another format or by a document that is gone. */
|
|
70
|
+
function staleFiles(): string[] {
|
|
71
|
+
const present = fs.existsSync(directory) ? fs.readdirSync(directory) : [];
|
|
72
|
+
|
|
73
|
+
return present.filter((file) => /\.(?:json|yaml)$/.test(file) && !generated.has(file));
|
|
45
74
|
}
|
|
46
75
|
|
|
47
76
|
function manifestField(name: string, fallback: string): string {
|
|
@@ -10,7 +10,7 @@ of `CI` on `main` (GitHub only offers a check as "required" once it has reported
|
|
|
10
10
|
|---|---|---|
|
|
11
11
|
| `gate` | `ci.yml` | Needs every other job of the workflow; a failed, cancelled or skipped job fails it. One required check, so adding a job never needs a settings change. |
|
|
12
12
|
| `Conventional title` | `pr-title.yml` | The squash commit takes the pull request title. |
|
|
13
|
-
| `Analyze` | `codeql.yml` |
|
|
13
|
+
| `Analyze` | `codeql.yml` | Only with `init --ci-extras codeql`: require it when code scanning is enabled on the repository. |
|
|
14
14
|
|
|
15
15
|
## Protect `main`
|
|
16
16
|
|
|
@@ -66,12 +66,13 @@ Expected: `{"checks":["gate","Conventional title"],"strict":true,"admins":true}`
|
|
|
66
66
|
|
|
67
67
|
## Notes
|
|
68
68
|
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
- Not installed by default, because they need a paid plan on a private repository:
|
|
70
|
+
dependency review (`--ci-extras dependency-review`: free on public repositories, GitHub Code
|
|
71
|
+
Security or GitHub Advanced Security on private ones) and CodeQL (`--ci-extras codeql`: free on
|
|
72
|
+
public repositories, GitHub Code Security on private ones). `npm run ci:audit` and gitleaks
|
|
73
|
+
hold dependencies and secrets on every plan.
|
|
73
74
|
- Secret scanning in `ci.yml` runs the gitleaks container, which needs no licence. The
|
|
74
|
-
`gitleaks/gitleaks-action` wrapper is not used
|
|
75
|
-
|
|
75
|
+
`gitleaks/gitleaks-action` wrapper is not used: it asks organization accounts for a licence
|
|
76
|
+
key (free, by its README) and is no longer MIT.
|
|
76
77
|
- Dependabot (`dependabot.yml`) is GitHub only. `renovate.json` works on both platforms; keep one
|
|
77
78
|
of the two, not both.
|
|
@@ -24,6 +24,11 @@ updates:
|
|
|
24
24
|
- '@ddd-ts-kit/eslint-plugin'
|
|
25
25
|
- 'knip'
|
|
26
26
|
- 'dependency-cruiser'
|
|
27
|
+
# pglite-socket pins the exact pglite it was built for: the two move together.
|
|
28
|
+
pglite:
|
|
29
|
+
patterns:
|
|
30
|
+
- '@electric-sql/pglite'
|
|
31
|
+
- '@electric-sql/pglite-*'
|
|
27
32
|
test:
|
|
28
33
|
patterns:
|
|
29
34
|
- 'vitest'
|
|
@@ -173,11 +173,14 @@ jobs:
|
|
|
173
173
|
- uses: ./.github/actions/setup
|
|
174
174
|
- name: Production dependencies audit
|
|
175
175
|
run: npm run ci:audit
|
|
176
|
+
{{#if extras.dependencyReview}}
|
|
177
|
+
# Opt-in (--ci-extras dependency-review): free on a public repository, GitHub Code Security on a private one.
|
|
176
178
|
- name: Dependency review
|
|
177
179
|
if: ${{ github.event_name == 'pull_request' && !cancelled() }}
|
|
178
180
|
uses: actions/dependency-review-action@v5.0.0
|
|
179
181
|
with:
|
|
180
182
|
fail-on-severity: high
|
|
183
|
+
{{/if}}
|
|
181
184
|
- name: Secrets
|
|
182
185
|
if: ${{ !cancelled() }}
|
|
183
186
|
run: docker run --rm --volume "$GITHUB_WORKSPACE:/repo" ghcr.io/gitleaks/gitleaks:v8.30.1 git /repo --redact --no-banner
|
|
@@ -7,13 +7,22 @@ workflow:
|
|
|
7
7
|
# A pipeline schedule (Build > Pipeline schedules, every night on the default branch) runs everything.
|
|
8
8
|
- if: $CI_PIPELINE_SOURCE == "schedule"
|
|
9
9
|
|
|
10
|
+
{{#if extras.gitlabSecurity}}
|
|
11
|
+
# Opt-in (--ci-extras): these run on every tier, but their findings reach a merge request on Ultimate only.
|
|
10
12
|
include:
|
|
13
|
+
{{#if extras.gitlabSast}}
|
|
11
14
|
- template: Jobs/SAST.gitlab-ci.yml
|
|
15
|
+
{{/if}}
|
|
16
|
+
{{#if extras.gitlabSecretDetection}}
|
|
12
17
|
- template: Jobs/Secret-Detection.gitlab-ci.yml
|
|
18
|
+
{{/if}}
|
|
19
|
+
{{#if extras.gitlabDependencyScanning}}
|
|
13
20
|
- template: Jobs/Dependency-Scanning.v2.gitlab-ci.yml
|
|
14
21
|
rules:
|
|
15
22
|
- if: $GITLAB_FEATURES =~ /\bdependency_scanning\b/
|
|
23
|
+
{{/if}}
|
|
16
24
|
|
|
25
|
+
{{/if}}
|
|
17
26
|
stages:
|
|
18
27
|
- install
|
|
19
28
|
- test
|
|
@@ -21,7 +30,9 @@ stages:
|
|
|
21
30
|
- gate
|
|
22
31
|
|
|
23
32
|
variables:
|
|
33
|
+
{{#if extras.gitlabSecurity}}
|
|
24
34
|
AST_ENABLE_MR_PIPELINES: 'true'
|
|
35
|
+
{{/if}}
|
|
25
36
|
NODE_IMAGE: node:24-bookworm-slim
|
|
26
37
|
# Behind the dependency proxy of a group, a registry that rate-limits is never asked twice:
|
|
27
38
|
# POSTGRES_IMAGE: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/postgres:18
|
|
@@ -76,14 +76,15 @@ glab api "projects/:id/protected_branches/main" | jq '{name, allow_force_push, p
|
|
|
76
76
|
|
|
77
77
|
| Piece | Free | Premium | Ultimate |
|
|
78
78
|
|---|---|---|---|
|
|
79
|
-
| SAST template (`Jobs/SAST.gitlab-ci.yml`, Semgrep rules for JavaScript and TypeScript) | job runs, report downloadable as an artifact | same | findings in the merge request, vulnerability management, Advanced SAST |
|
|
80
|
-
| Secret Detection template (`Jobs/Secret-Detection.gitlab-ci.yml`) | job runs, report downloadable as an artifact | same | findings in the merge request and the security dashboard |
|
|
81
|
-
| Dependency Scanning template (`Jobs/Dependency-Scanning.v2.gitlab-ci.yml`) | not available: the `include` is skipped | not available | available |
|
|
79
|
+
| SAST template (`Jobs/SAST.gitlab-ci.yml`, Semgrep rules for JavaScript and TypeScript), `--ci-extras gitlab-sast` | job runs, report downloadable as an artifact | same | findings in the merge request, vulnerability management, Advanced SAST |
|
|
80
|
+
| Secret Detection template (`Jobs/Secret-Detection.gitlab-ci.yml`), `--ci-extras gitlab-secret-detection` | job runs, report downloadable as an artifact | same | findings in the merge request and the security dashboard |
|
|
81
|
+
| Dependency Scanning template (`Jobs/Dependency-Scanning.v2.gitlab-ci.yml`), `--ci-extras gitlab-dependency-scanning` | not available: the `include` is skipped | not available | available |
|
|
82
82
|
| Code Quality report (ESLint and architecture) | merge request widget | plus the pipeline report tab | plus inline in the changes view |
|
|
83
83
|
| JUnit report, coverage percentage, Cobertura coverage in the diff | available | available | available |
|
|
84
84
|
| Push rules | no | yes | yes |
|
|
85
85
|
| Required approvals | no | yes | yes |
|
|
86
86
|
|
|
87
|
-
The
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
The three templates are not in `.gitlab-ci.yml` unless `init --ci-extras` names them: on Free
|
|
88
|
+
and Premium their findings reach no merge request, and their jobs are `allow_failure: true` by
|
|
89
|
+
design of GitLab, so they never block a merge. What blocks, on every tier, is the `audit` job
|
|
90
|
+
(`npm audit`, production dependencies, high and above) and the `secrets` job (gitleaks).
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@biomejs/biome": "2.5.15",
|
|
24
24
|
"@commitlint/cli": "^21.2.3",
|
|
25
25
|
"@commitlint/config-conventional": "^21.2.3",
|
|
26
|
-
"@ddd-ts-kit/eslint-plugin": "^0.
|
|
26
|
+
"@ddd-ts-kit/eslint-plugin": "^0.5.0",
|
|
27
27
|
"@eslint/js": "^10.0.1",
|
|
28
28
|
"@typescript/native": "npm:typescript@~7.0.2",
|
|
29
29
|
"@vitest/coverage-v8": "5.0.3",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"matchManagers": ["github-actions", "gitlabci", "gitlabci-include"],
|
|
37
37
|
"semanticCommitType": "ci"
|
|
38
38
|
},
|
|
39
|
+
{
|
|
40
|
+
"description": "pglite-socket pins the exact pglite it was built for: the two move together.",
|
|
41
|
+
"groupName": "pglite",
|
|
42
|
+
"matchPackageNames": ["@electric-sql/pglite", "@electric-sql/pglite-*"]
|
|
43
|
+
},
|
|
39
44
|
{
|
|
40
45
|
"groupName": "tests",
|
|
41
46
|
"matchPackageNames": ["vitest", "@vitest/**", "@faker-js/faker"]
|
|
@@ -13,7 +13,7 @@ export const {{aggregate.tableCamel}} = {{context.camel}}Schema.table(
|
|
|
13
13
|
{
|
|
14
14
|
id: text('id').primaryKey(),
|
|
15
15
|
registeredAt: timestamp('registered_at', { withTimezone: true, mode: 'date' }).notNull(),
|
|
16
|
-
// TODO(domain): add one column per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:generate
|
|
16
|
+
// TODO(domain): add one column per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:generate <what-it-does>`.
|
|
17
17
|
version: integer('version').notNull(),
|
|
18
18
|
...tenantColumn(),
|
|
19
19
|
...auditColumns(),
|
|
@@ -25,7 +25,7 @@ export const {{aggregate.tableCamel}} = {{context.camel}}Schema.table(
|
|
|
25
25
|
export const {{aggregate.tableCamel}} = {{context.camel}}Schema.table('{{aggregate.table}}', {
|
|
26
26
|
id: text('id').primaryKey(),
|
|
27
27
|
registeredAt: timestamp('registered_at', { withTimezone: true, mode: 'date' }).notNull(),
|
|
28
|
-
// TODO(domain): add one column per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:generate
|
|
28
|
+
// TODO(domain): add one column per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:generate <what-it-does>`.
|
|
29
29
|
version: integer('version').notNull(),
|
|
30
30
|
...auditColumns(),
|
|
31
31
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
model {{context.pascal}}{{aggregate.pascal}} {
|
|
3
3
|
id String @id
|
|
4
4
|
registeredAt DateTime @map("registered_at") @db.Timestamptz(3)
|
|
5
|
-
// TODO(domain): add one field per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:client` and `npm run db:generate
|
|
5
|
+
// TODO(domain): add one field per field of {{aggregate.pascal}}State, with the type and the constraints the storage must enforce; then run `npm run db:client` and `npm run db:generate <what-it-does>`.
|
|
6
6
|
version Int
|
|
7
7
|
createdAt DateTime @map("created_at") @db.Timestamptz(3)
|
|
8
8
|
createdBy String @map("created_by")
|
|
@@ -8,7 +8,7 @@ export const {{aggregate.tableCamel}} = new EntitySchema<{{aggregate.pascal}}Row
|
|
|
8
8
|
columns: {
|
|
9
9
|
id: { type: 'text', primary: true },
|
|
10
10
|
registeredAt: { name: 'registered_at', type: 'timestamptz' },
|
|
11
|
-
// TODO(domain): add one column per field of {{aggregate.pascal}}State (and to {{aggregate.pascal}}Columns of {{aggregate.kebab}}-row.schema.ts), with the type and the constraints the storage must enforce; then run `npm run db:generate
|
|
11
|
+
// TODO(domain): add one column per field of {{aggregate.pascal}}State (and to {{aggregate.pascal}}Columns of {{aggregate.kebab}}-row.schema.ts), with the type and the constraints the storage must enforce; then run `npm run build && npm run db:generate migrations/<what-it-does>`.
|
|
12
12
|
version: { type: 'int' },
|
|
13
13
|
...auditColumns(),
|
|
14
14
|
},
|