@orthacms/content-server 0.4.2 → 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/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -1
- package/dist/lib/content.module.d.ts.map +1 -1
- package/dist/lib/content.module.js +31 -1
- package/dist/lib/copilot/entry-proposal.applier.d.ts.map +1 -1
- package/dist/lib/copilot/entry-proposal.applier.js +5 -4
- package/dist/lib/docs/describe-content-api.d.ts +7 -0
- package/dist/lib/docs/describe-content-api.d.ts.map +1 -1
- package/dist/lib/docs/describe-content-api.js +177 -53
- package/dist/lib/docs/describe-views-api.d.ts +19 -0
- package/dist/lib/docs/describe-views-api.d.ts.map +1 -0
- package/dist/lib/docs/describe-views-api.js +76 -0
- package/dist/lib/docs/field-schema.d.ts.map +1 -1
- package/dist/lib/docs/field-schema.js +36 -2
- package/dist/lib/docs/openapi-writer.d.ts +49 -0
- package/dist/lib/docs/openapi-writer.d.ts.map +1 -0
- package/dist/lib/docs/openapi-writer.js +76 -0
- package/dist/lib/docs/public-api-schemas.d.ts +45 -0
- package/dist/lib/docs/public-api-schemas.d.ts.map +1 -0
- package/dist/lib/docs/public-api-schemas.js +377 -0
- package/dist/lib/docs/views-schemas.d.ts +22 -0
- package/dist/lib/docs/views-schemas.d.ts.map +1 -0
- package/dist/lib/docs/views-schemas.js +156 -0
- package/dist/lib/entries/application/use-cases/bulk-publish-entries.use-case.d.ts +8 -2
- package/dist/lib/entries/application/use-cases/bulk-publish-entries.use-case.d.ts.map +1 -1
- package/dist/lib/entries/application/use-cases/bulk-publish-entries.use-case.js +19 -4
- package/dist/lib/entries/application/use-cases/bulk-unpublish-entries.use-case.d.ts +2 -2
- package/dist/lib/entries/application/use-cases/bulk-unpublish-entries.use-case.d.ts.map +1 -1
- package/dist/lib/entries/application/use-cases/bulk-unpublish-entries.use-case.js +14 -4
- package/dist/lib/entries/application/use-cases/publish-entry.use-case.d.ts +6 -8
- package/dist/lib/entries/application/use-cases/publish-entry.use-case.d.ts.map +1 -1
- package/dist/lib/entries/application/use-cases/publish-entry.use-case.js +10 -4
- package/dist/lib/entries/application/use-cases/unpublish-entry.use-case.d.ts +2 -5
- package/dist/lib/entries/application/use-cases/unpublish-entry.use-case.d.ts.map +1 -1
- package/dist/lib/entries/application/use-cases/unpublish-entry.use-case.js +6 -1
- package/dist/lib/entries/domain/entry.d.ts +8 -1
- package/dist/lib/entries/domain/entry.d.ts.map +1 -1
- package/dist/lib/entries/domain/entry.js +12 -12
- package/dist/lib/entries/domain/events/entry-events.d.ts +47 -5
- package/dist/lib/entries/domain/events/entry-events.d.ts.map +1 -1
- package/dist/lib/entries/domain/events/entry-events.js +26 -10
- package/dist/lib/entries/entries.constants.d.ts +10 -2
- package/dist/lib/entries/entries.constants.d.ts.map +1 -1
- package/dist/lib/entries/entries.constants.js +11 -2
- package/dist/lib/entries/http/controllers/bulk-entries.controller.d.ts +2 -2
- package/dist/lib/entries/http/controllers/bulk-entries.controller.d.ts.map +1 -1
- package/dist/lib/entries/http/controllers/bulk-entries.controller.js +8 -6
- package/dist/lib/entries/http/controllers/create-entry.controller.d.ts.map +1 -1
- package/dist/lib/entries/http/controllers/create-entry.controller.js +1 -1
- package/dist/lib/entries/http/controllers/update-entry.controller.d.ts.map +1 -1
- package/dist/lib/entries/http/controllers/update-entry.controller.js +1 -1
- package/dist/lib/entries/http/dto/extension-bag.validator.d.ts +14 -0
- package/dist/lib/entries/http/dto/extension-bag.validator.d.ts.map +1 -0
- package/dist/lib/entries/http/dto/extension-bag.validator.js +42 -0
- package/dist/lib/entries/http/dto/save-entry.dto.d.ts +16 -0
- package/dist/lib/entries/http/dto/save-entry.dto.d.ts.map +1 -1
- package/dist/lib/entries/http/dto/save-entry.dto.js +30 -0
- package/dist/lib/entries/infrastructure/persistence/entry-writer.service.d.ts +50 -8
- package/dist/lib/entries/infrastructure/persistence/entry-writer.service.d.ts.map +1 -1
- package/dist/lib/entries/infrastructure/persistence/entry-writer.service.js +183 -32
- package/dist/lib/entries/infrastructure/persistence/relation-link.service.d.ts +38 -5
- package/dist/lib/entries/infrastructure/persistence/relation-link.service.d.ts.map +1 -1
- package/dist/lib/entries/infrastructure/persistence/relation-link.service.js +38 -6
- package/dist/lib/entries/infrastructure/queries/entries.service.d.ts +3 -1
- package/dist/lib/entries/infrastructure/queries/entries.service.d.ts.map +1 -1
- package/dist/lib/entries/infrastructure/queries/entries.service.js +17 -5
- package/dist/lib/entries/infrastructure/queries/entry-match.query.d.ts +82 -0
- package/dist/lib/entries/infrastructure/queries/entry-match.query.d.ts.map +1 -0
- package/dist/lib/entries/infrastructure/queries/entry-match.query.js +152 -0
- package/dist/lib/extension/entry-filter-provider.d.ts +79 -0
- package/dist/lib/extension/entry-filter-provider.d.ts.map +1 -0
- package/dist/lib/extension/entry-filter-provider.js +149 -0
- package/dist/lib/extension/entry-write-extension.d.ts +185 -0
- package/dist/lib/extension/entry-write-extension.d.ts.map +1 -0
- package/dist/lib/extension/entry-write-extension.js +182 -0
- package/dist/lib/extension/read-scope.d.ts +107 -0
- package/dist/lib/extension/read-scope.d.ts.map +1 -0
- package/dist/lib/extension/read-scope.js +131 -0
- package/dist/lib/insights/docs/describe-content-insights-api.d.ts +23 -0
- package/dist/lib/insights/docs/describe-content-insights-api.d.ts.map +1 -0
- package/dist/lib/insights/docs/describe-content-insights-api.js +329 -0
- package/dist/lib/mcp/content-tools.provider.d.ts.map +1 -1
- package/dist/lib/mcp/content-tools.provider.js +10 -9
- package/dist/lib/public-api/http/controllers/public-entry-writes.controller.d.ts +14 -13
- package/dist/lib/public-api/http/controllers/public-entry-writes.controller.d.ts.map +1 -1
- package/dist/lib/public-api/http/controllers/public-entry-writes.controller.js +62 -46
- package/dist/lib/public-api/http/guards/api-token-workspace.guard.d.ts.map +1 -1
- package/dist/lib/public-api/http/guards/api-token-workspace.guard.js +8 -0
- package/dist/lib/public-api/infrastructure/public-entries.query.d.ts +14 -1
- package/dist/lib/public-api/infrastructure/public-entries.query.d.ts.map +1 -1
- package/dist/lib/public-api/infrastructure/public-entries.query.js +20 -3
- package/dist/lib/public-api/infrastructure/public-entry-writes.service.d.ts +10 -9
- package/dist/lib/public-api/infrastructure/public-entry-writes.service.d.ts.map +1 -1
- package/dist/lib/public-api/infrastructure/public-entry-writes.service.js +23 -24
- package/dist/lib/public-api/infrastructure/public-expansion.query.d.ts +16 -4
- package/dist/lib/public-api/infrastructure/public-expansion.query.d.ts.map +1 -1
- package/dist/lib/public-api/infrastructure/public-expansion.query.js +29 -9
- package/dist/lib/public-api/infrastructure/token-actor.d.ts +37 -0
- package/dist/lib/public-api/infrastructure/token-actor.d.ts.map +1 -0
- package/dist/lib/public-api/infrastructure/token-actor.js +58 -0
- package/dist/lib/revisions/application/use-cases/restore-revision.use-case.d.ts.map +1 -1
- package/dist/lib/revisions/application/use-cases/restore-revision.use-case.js +23 -1
- package/dist/lib/revisions/infrastructure/persistence/revision-snapshot.d.ts +7 -1
- package/dist/lib/revisions/infrastructure/persistence/revision-snapshot.d.ts.map +1 -1
- package/dist/lib/revisions/infrastructure/persistence/revision-snapshot.js +9 -2
- package/dist/lib/revisions/infrastructure/purge/revisions-workspace.purger.d.ts +28 -0
- package/dist/lib/revisions/infrastructure/purge/revisions-workspace.purger.d.ts.map +1 -0
- package/dist/lib/revisions/infrastructure/purge/revisions-workspace.purger.js +52 -0
- package/dist/lib/revisions/types/revision-view.d.ts +11 -0
- package/dist/lib/revisions/types/revision-view.d.ts.map +1 -1
- package/dist/lib/utils/content-plugin.d.ts.map +1 -1
- package/dist/lib/utils/content-plugin.js +10 -1
- package/dist/lib/utils/content-views-plugin.d.ts +28 -0
- package/dist/lib/utils/content-views-plugin.d.ts.map +1 -0
- package/dist/lib/utils/content-views-plugin.js +37 -0
- package/dist/lib/views/application/queries/saved-views.query.d.ts +16 -0
- package/dist/lib/views/application/queries/saved-views.query.d.ts.map +1 -0
- package/dist/lib/views/application/queries/saved-views.query.js +46 -0
- package/dist/lib/views/application/saved-view-access.service.d.ts +30 -0
- package/dist/lib/views/application/saved-view-access.service.d.ts.map +1 -0
- package/dist/lib/views/application/saved-view-access.service.js +55 -0
- package/dist/lib/views/application/use-cases/create-saved-view.use-case.d.ts +30 -0
- package/dist/lib/views/application/use-cases/create-saved-view.use-case.d.ts.map +1 -0
- package/dist/lib/views/application/use-cases/create-saved-view.use-case.js +81 -0
- package/dist/lib/views/application/use-cases/delete-saved-view.use-case.d.ts +18 -0
- package/dist/lib/views/application/use-cases/delete-saved-view.use-case.d.ts.map +1 -0
- package/dist/lib/views/application/use-cases/delete-saved-view.use-case.js +56 -0
- package/dist/lib/views/application/use-cases/set-default-view.use-case.d.ts +23 -0
- package/dist/lib/views/application/use-cases/set-default-view.use-case.d.ts.map +1 -0
- package/dist/lib/views/application/use-cases/set-default-view.use-case.js +51 -0
- package/dist/lib/views/application/use-cases/update-saved-view.use-case.d.ts +24 -0
- package/dist/lib/views/application/use-cases/update-saved-view.use-case.d.ts.map +1 -0
- package/dist/lib/views/application/use-cases/update-saved-view.use-case.js +90 -0
- package/dist/lib/views/application/view-scope.service.d.ts +25 -0
- package/dist/lib/views/application/view-scope.service.d.ts.map +1 -0
- package/dist/lib/views/application/view-scope.service.js +45 -0
- package/dist/lib/views/content-views.module.d.ts +22 -0
- package/dist/lib/views/content-views.module.d.ts.map +1 -0
- package/dist/lib/views/content-views.module.js +63 -0
- package/dist/lib/views/domain/errors/index.d.ts +6 -0
- package/dist/lib/views/domain/errors/index.d.ts.map +1 -0
- package/dist/lib/views/domain/errors/index.js +12 -0
- package/dist/lib/views/domain/errors/saved-view-forbidden.error.d.ts +10 -0
- package/dist/lib/views/domain/errors/saved-view-forbidden.error.d.ts.map +1 -0
- package/dist/lib/views/domain/errors/saved-view-forbidden.error.js +16 -0
- package/dist/lib/views/domain/errors/saved-view-limit-error.d.ts +9 -0
- package/dist/lib/views/domain/errors/saved-view-limit-error.d.ts.map +1 -0
- package/dist/lib/views/domain/errors/saved-view-limit-error.js +16 -0
- package/dist/lib/views/domain/errors/saved-view-name-taken.error.d.ts +5 -0
- package/dist/lib/views/domain/errors/saved-view-name-taken.error.d.ts.map +1 -0
- package/dist/lib/views/domain/errors/saved-view-name-taken.error.js +11 -0
- package/dist/lib/views/domain/errors/saved-view-not-found.error.d.ts +9 -0
- package/dist/lib/views/domain/errors/saved-view-not-found.error.d.ts.map +1 -0
- package/dist/lib/views/domain/errors/saved-view-not-found.error.js +15 -0
- package/dist/lib/views/domain/events/saved-view-events.d.ts +28 -0
- package/dist/lib/views/domain/events/saved-view-events.d.ts.map +1 -0
- package/dist/lib/views/domain/events/saved-view-events.js +38 -0
- package/dist/lib/views/domain/saved-view.d.ts +66 -0
- package/dist/lib/views/domain/saved-view.d.ts.map +1 -0
- package/dist/lib/views/domain/saved-view.js +18 -0
- package/dist/lib/views/domain/saved-view.repository.d.ts +77 -0
- package/dist/lib/views/domain/saved-view.repository.d.ts.map +1 -0
- package/dist/lib/views/domain/saved-view.repository.js +5 -0
- package/dist/lib/views/http/controllers/saved-views.controller.d.ts +45 -0
- package/dist/lib/views/http/controllers/saved-views.controller.d.ts.map +1 -0
- package/dist/lib/views/http/controllers/saved-views.controller.js +216 -0
- package/dist/lib/views/http/controllers/to-http-error.d.ts +10 -0
- package/dist/lib/views/http/controllers/to-http-error.d.ts.map +1 -0
- package/dist/lib/views/http/controllers/to-http-error.js +26 -0
- package/dist/lib/views/http/dto/save-view.dto.d.ts +54 -0
- package/dist/lib/views/http/dto/save-view.dto.d.ts.map +1 -0
- package/dist/lib/views/http/dto/save-view.dto.js +230 -0
- package/dist/lib/views/http/dto/view-payload.validator.d.ts +20 -0
- package/dist/lib/views/http/dto/view-payload.validator.d.ts.map +1 -0
- package/dist/lib/views/http/dto/view-payload.validator.js +52 -0
- package/dist/lib/views/infrastructure/persistence/drizzle-saved-view.repository.d.ts +26 -0
- package/dist/lib/views/infrastructure/persistence/drizzle-saved-view.repository.d.ts.map +1 -0
- package/dist/lib/views/infrastructure/persistence/drizzle-saved-view.repository.js +135 -0
- package/dist/lib/views/infrastructure/schema/external-refs.d.ts +68 -0
- package/dist/lib/views/infrastructure/schema/external-refs.d.ts.map +1 -0
- package/dist/lib/views/infrastructure/schema/external-refs.js +29 -0
- package/dist/lib/views/infrastructure/schema/index.d.ts +8 -0
- package/dist/lib/views/infrastructure/schema/index.d.ts.map +1 -0
- package/dist/lib/views/infrastructure/schema/index.js +13 -0
- package/dist/lib/views/infrastructure/schema/saved-views.d.ts +275 -0
- package/dist/lib/views/infrastructure/schema/saved-views.d.ts.map +1 -0
- package/dist/lib/views/infrastructure/schema/saved-views.js +87 -0
- package/dist/lib/views/views.constants.d.ts +26 -0
- package/dist/lib/views/views.constants.d.ts.map +1 -0
- package/dist/lib/views/views.constants.js +28 -0
- package/dist/lib/views/views.tokens.d.ts +17 -0
- package/dist/lib/views/views.tokens.d.ts.map +1 -0
- package/dist/lib/views/views.tokens.js +21 -0
- package/migrations/0000_saved_views.sql +29 -0
- package/migrations/meta/0000_snapshot.json +256 -0
- package/migrations/meta/_journal.json +13 -0
- package/package.json +13 -12
- package/dist/lib/entries/controllers/bulk-entries.controller.d.ts +0 -26
- package/dist/lib/entries/controllers/bulk-entries.controller.d.ts.map +0 -1
- package/dist/lib/entries/controllers/create-entry.controller.d.ts +0 -20
- package/dist/lib/entries/controllers/create-entry.controller.d.ts.map +0 -1
- package/dist/lib/entries/controllers/delete-entry.controller.d.ts +0 -24
- package/dist/lib/entries/controllers/delete-entry.controller.d.ts.map +0 -1
- package/dist/lib/entries/controllers/get-entry.controller.d.ts +0 -34
- package/dist/lib/entries/controllers/get-entry.controller.d.ts.map +0 -1
- package/dist/lib/entries/controllers/list-entries.controller.d.ts +0 -20
- package/dist/lib/entries/controllers/list-entries.controller.d.ts.map +0 -1
- package/dist/lib/entries/controllers/publish-entry.controller.d.ts +0 -19
- package/dist/lib/entries/controllers/publish-entry.controller.d.ts.map +0 -1
- package/dist/lib/entries/controllers/resolve-type.d.ts +0 -9
- package/dist/lib/entries/controllers/resolve-type.d.ts.map +0 -1
- package/dist/lib/entries/controllers/update-entry.controller.d.ts +0 -18
- package/dist/lib/entries/controllers/update-entry.controller.d.ts.map +0 -1
- package/dist/lib/entries/dto/bulk-ids.dto.d.ts +0 -11
- package/dist/lib/entries/dto/bulk-ids.dto.d.ts.map +0 -1
- package/dist/lib/entries/dto/list-entries-query.dto.d.ts +0 -46
- package/dist/lib/entries/dto/list-entries-query.dto.d.ts.map +0 -1
- package/dist/lib/entries/dto/relation-delta-map.validator.d.ts +0 -19
- package/dist/lib/entries/dto/relation-delta-map.validator.d.ts.map +0 -1
- package/dist/lib/entries/dto/save-entry.dto.d.ts +0 -46
- package/dist/lib/entries/dto/save-entry.dto.d.ts.map +0 -1
- package/dist/lib/entries/infrastructure/persistence/field-selection.d.ts +0 -24
- package/dist/lib/entries/infrastructure/persistence/field-selection.d.ts.map +0 -1
- package/dist/lib/entries/infrastructure/queries/entry-filter-schema.d.ts +0 -40
- package/dist/lib/entries/infrastructure/queries/entry-filter-schema.d.ts.map +0 -1
- package/dist/lib/entries/services/entries.service.d.ts +0 -59
- package/dist/lib/entries/services/entries.service.d.ts.map +0 -1
- package/dist/lib/entries/services/entry-counter.service.d.ts +0 -31
- package/dist/lib/entries/services/entry-counter.service.d.ts.map +0 -1
- package/dist/lib/entries/services/entry-filter-schema.d.ts +0 -32
- package/dist/lib/entries/services/entry-filter-schema.d.ts.map +0 -1
- package/dist/lib/entries/services/entry-row.d.ts +0 -56
- package/dist/lib/entries/services/entry-row.d.ts.map +0 -1
- package/dist/lib/entries/services/entry-writer.service.d.ts +0 -193
- package/dist/lib/entries/services/entry-writer.service.d.ts.map +0 -1
- package/dist/lib/entries/services/relation-link.service.d.ts +0 -115
- package/dist/lib/entries/services/relation-link.service.d.ts.map +0 -1
- package/dist/lib/extension/per-locale-relation.d.ts +0 -18
- package/dist/lib/extension/per-locale-relation.d.ts.map +0 -1
- package/dist/lib/public/controllers/get-public-entry.controller.d.ts +0 -26
- package/dist/lib/public/controllers/get-public-entry.controller.d.ts.map +0 -1
- package/dist/lib/public/controllers/list-public-entries.controller.d.ts +0 -24
- package/dist/lib/public/controllers/list-public-entries.controller.d.ts.map +0 -1
- package/dist/lib/public/controllers/public-schema.controller.d.ts +0 -18
- package/dist/lib/public/controllers/public-schema.controller.d.ts.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The saved-views plugin's pass over the host's OpenAPI document.
|
|
3
|
+
*
|
|
4
|
+
* A second `decorate` from the same package as {@link describeContentApi},
|
|
5
|
+
* because saved views ship as a second `ServerPlugin` entry
|
|
6
|
+
* (`ContentViewsPlugin`) and a plugin describes what it registers. Keeping them
|
|
7
|
+
* apart also keeps the route tables honest: nothing here can accidentally claim
|
|
8
|
+
* a `/content/...` path, and nothing there can claim a `/views` one.
|
|
9
|
+
*
|
|
10
|
+
* Pure: takes the document and the serialized types, mutates only `/views`.
|
|
11
|
+
*/
|
|
12
|
+
import type { OpenApiDocument } from '@orthacms/bootstrap-server';
|
|
13
|
+
import type { SerializedContentType } from '../registry/content-type-registry';
|
|
14
|
+
/**
|
|
15
|
+
* Adds the saved-view schemas to `document` and points the `/views` operations
|
|
16
|
+
* at them.
|
|
17
|
+
*/
|
|
18
|
+
export declare function describeViewsApi(document: OpenApiDocument, types: readonly SerializedContentType[]): void;
|
|
19
|
+
//# sourceMappingURL=describe-views-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-views-api.d.ts","sourceRoot":"","sources":["../../../src/lib/docs/describe-views-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAmC/E;;;GAGG;AACH,wBAAgB,gBAAgB,CAC5B,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,SAAS,qBAAqB,EAAE,GACxC,IAAI,CAqCN"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The saved-views plugin's pass over the host's OpenAPI document.
|
|
4
|
+
*
|
|
5
|
+
* A second `decorate` from the same package as {@link describeContentApi},
|
|
6
|
+
* because saved views ship as a second `ServerPlugin` entry
|
|
7
|
+
* (`ContentViewsPlugin`) and a plugin describes what it registers. Keeping them
|
|
8
|
+
* apart also keeps the route tables honest: nothing here can accidentally claim
|
|
9
|
+
* a `/content/...` path, and nothing there can claim a `/views` one.
|
|
10
|
+
*
|
|
11
|
+
* Pure: takes the document and the serialized types, mutates only `/views`.
|
|
12
|
+
*/
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.describeViewsApi = describeViewsApi;
|
|
15
|
+
const content_schemas_1 = require("./content-schemas");
|
|
16
|
+
const views_schemas_1 = require("./views-schemas");
|
|
17
|
+
const openapi_writer_1 = require("./openapi-writer");
|
|
18
|
+
/**
|
|
19
|
+
* Matches `<prefix>/views<rest>` — anchored at both ends.
|
|
20
|
+
*
|
|
21
|
+
* The tail is one of the three shapes the controller actually serves. The head
|
|
22
|
+
* is `^/<one segment>/`, so `/api/insights/views` — another plugin's route,
|
|
23
|
+
* ending in the same word — is not caught: a suffix match claimed it and gave
|
|
24
|
+
* it this plugin's schemas, which is the same failure that once published
|
|
25
|
+
* thirteen public content operations with the admin's shapes.
|
|
26
|
+
*
|
|
27
|
+
* It assumes the host's global prefix is a single segment, which the default
|
|
28
|
+
* (`api`) is. A longer one leaves these three operations with no response
|
|
29
|
+
* schema rather than the wrong one — the direction to fail in, and the same
|
|
30
|
+
* one an unmatched route already takes.
|
|
31
|
+
*/
|
|
32
|
+
const VIEWS_ROUTE_RE = /^\/[^/]+\/views((?:\/\{id\})?(?:\/default)?)$/;
|
|
33
|
+
/**
|
|
34
|
+
* What each `/views` operation answers, keyed by what follows `/views`.
|
|
35
|
+
*
|
|
36
|
+
* The three `204`s (`DELETE /views/{id}`, `PUT|DELETE /views/{id}/default`) are
|
|
37
|
+
* listed as `null` rather than omitted: they are described — they simply have
|
|
38
|
+
* no body, and saying so here is what keeps a later reader from "fixing" the
|
|
39
|
+
* gap by inventing one.
|
|
40
|
+
*/
|
|
41
|
+
const VIEW_ROUTES = {
|
|
42
|
+
'': { get: 'list', post: 'one' },
|
|
43
|
+
'/{id}': { patch: 'one', delete: null },
|
|
44
|
+
'/{id}/default': { put: null, delete: null }
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Adds the saved-view schemas to `document` and points the `/views` operations
|
|
48
|
+
* at them.
|
|
49
|
+
*/
|
|
50
|
+
function describeViewsApi(document, types) {
|
|
51
|
+
document.components ??= {};
|
|
52
|
+
document.components.schemas ??= {};
|
|
53
|
+
Object.assign(document.components.schemas, (0, views_schemas_1.buildViewsSchemas)(types));
|
|
54
|
+
for (const [route, item] of Object.entries(document.paths)) {
|
|
55
|
+
const match = VIEWS_ROUTE_RE.exec(route);
|
|
56
|
+
if (!match) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const byMethod = VIEW_ROUTES[match[1]];
|
|
60
|
+
if (!byMethod) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
for (const [method, operation] of Object.entries(item)) {
|
|
64
|
+
const kind = byMethod[method];
|
|
65
|
+
if (kind == null || !operation || typeof operation !== 'object') {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (kind === 'list') {
|
|
69
|
+
(0, openapi_writer_1.setSuccessResponse)(operation, { type: 'array', items: (0, content_schemas_1.ref)(views_schemas_1.SAVED_VIEW_SCHEMA) }, 'The caller’s own views for this scope at any visibility, plus every workspace-shared one, ordered for the switcher.');
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
(0, openapi_writer_1.setSuccessResponse)(operation, (0, content_schemas_1.ref)(views_schemas_1.SAVED_VIEW_SCHEMA), 'The saved view.');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-schema.d.ts","sourceRoot":"","sources":["../../../src/lib/docs/field-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAyJpD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAK5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"field-schema.d.ts","sourceRoot":"","sources":["../../../src/lib/docs/field-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAEzE,qEAAqE;AACrE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAyJpD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAK5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,aAAa,CAyDjE"}
|
|
@@ -206,9 +206,43 @@ function fieldSchema(field) {
|
|
|
206
206
|
? field.admin['label']
|
|
207
207
|
: undefined;
|
|
208
208
|
return {
|
|
209
|
-
...valueSchema(field),
|
|
210
|
-
nullable: true,
|
|
209
|
+
...nullable(valueSchema(field)),
|
|
211
210
|
...(label ? { title: label } : {}),
|
|
212
211
|
...(notes.length ? { description: notes.join(' ') } : {})
|
|
213
212
|
};
|
|
214
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Marks a value schema nullable — and does the two things `nullable: true`
|
|
216
|
+
* alone does **not** do.
|
|
217
|
+
*
|
|
218
|
+
* OpenAPI 3.0's `nullable` is a modifier on the schema's `type`, so it is inert
|
|
219
|
+
* wherever there is no single type to modify, and it does not widen an
|
|
220
|
+
* enumeration. Both cases occur here and both produced a document that rejected
|
|
221
|
+
* responses the API really returns:
|
|
222
|
+
*
|
|
223
|
+
* - a `select` read back as `{ type: 'string', enum: [...], nullable: true }`,
|
|
224
|
+
* which every validator refuses `null` against, because OAS 3.0 requires a
|
|
225
|
+
* nullable enum to list `null` among its values;
|
|
226
|
+
* - a `richtext` read back as a bare `oneOf` (document or legacy HTML string)
|
|
227
|
+
* with `nullable` attached to nothing at all.
|
|
228
|
+
*
|
|
229
|
+
* Measured against a live server: an `article` with an unset `layout` did not
|
|
230
|
+
* validate against its own `ArticleValues` schema until this existed.
|
|
231
|
+
*/
|
|
232
|
+
function nullable(schema) {
|
|
233
|
+
if (Array.isArray(schema['oneOf'])) {
|
|
234
|
+
return {
|
|
235
|
+
...schema,
|
|
236
|
+
oneOf: [...schema['oneOf'], { type: 'null' }],
|
|
237
|
+
nullable: true
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
if (Array.isArray(schema['enum'])) {
|
|
241
|
+
return {
|
|
242
|
+
...schema,
|
|
243
|
+
enum: [...schema['enum'], null],
|
|
244
|
+
nullable: true
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
return { ...schema, nullable: true };
|
|
248
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two writes every `decorate` pass in this package makes on the generated
|
|
3
|
+
* document, and the one rule they both follow: **never invent a status code.**
|
|
4
|
+
*
|
|
5
|
+
* The scanner has already emitted whichever 2xx key the handler actually
|
|
6
|
+
* answers with — 201 for a bare `@Post`, 200 elsewhere, and whatever a
|
|
7
|
+
* `@HttpCode` moved it to — so a schema is written *onto that key* rather than
|
|
8
|
+
* onto a guessed one. A document that describes a `200` for a route answering
|
|
9
|
+
* `201` is worse than a document that describes nothing, because a consumer
|
|
10
|
+
* cannot tell it is wrong without curling the API, which is the whole thing
|
|
11
|
+
* these passes exist to make unnecessary.
|
|
12
|
+
*/
|
|
13
|
+
import type { OpenApiSchema } from './field-schema';
|
|
14
|
+
/** An operation object, as far as these passes need to see one. */
|
|
15
|
+
export interface Operation {
|
|
16
|
+
parameters?: {
|
|
17
|
+
name: string;
|
|
18
|
+
in: string;
|
|
19
|
+
schema?: OpenApiSchema;
|
|
20
|
+
description?: string;
|
|
21
|
+
}[];
|
|
22
|
+
responses?: Record<string, {
|
|
23
|
+
description?: string;
|
|
24
|
+
content?: unknown;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Writes a success response's schema onto whichever 2xx key the scanner already
|
|
29
|
+
* emitted.
|
|
30
|
+
*
|
|
31
|
+
* `204` is left alone deliberately: a no-content response has no body, and
|
|
32
|
+
* attaching one would describe a payload the server never sends.
|
|
33
|
+
*/
|
|
34
|
+
export declare function setSuccessResponse(operation: Operation, schema: OpenApiSchema, description: string,
|
|
35
|
+
/**
|
|
36
|
+
* Media type. `application/json` for all but the two transfer downloads,
|
|
37
|
+
* which stream a file.
|
|
38
|
+
*/
|
|
39
|
+
mediaType?: string,
|
|
40
|
+
/** Response headers worth documenting, keyed by header name. */
|
|
41
|
+
headers?: Record<string, unknown>): void;
|
|
42
|
+
/**
|
|
43
|
+
* Writes a success response carrying several media types — one download route
|
|
44
|
+
* whose content type depends on what the caller asked for.
|
|
45
|
+
*/
|
|
46
|
+
export declare function setSuccessResponseVariants(operation: Operation, byMediaType: Record<string, OpenApiSchema>, description: string, headers?: Record<string, unknown>): void;
|
|
47
|
+
/** Adds a documented failure response, leaving any existing one alone. */
|
|
48
|
+
export declare function addErrorResponse(operation: Operation, code: string, description: string, schema?: OpenApiSchema): void;
|
|
49
|
+
//# sourceMappingURL=openapi-writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-writer.d.ts","sourceRoot":"","sources":["../../../src/lib/docs/openapi-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,mEAAmE;AACnE,MAAM,WAAW,SAAS;IACtB,UAAU,CAAC,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,CAAC,EAAE,aAAa,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;KACxB,EAAE,CAAC;IACJ,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAC3E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAC9B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,MAAM;AACnB;;;GAGG;AACH,SAAS,SAAqB;AAC9B,gEAAgE;AAChE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,IAAI,CAYN;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACtC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,IAAI,CAiBN;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAC5B,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,aAAa,GACvB,IAAI,CAUN"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The two writes every `decorate` pass in this package makes on the generated
|
|
4
|
+
* document, and the one rule they both follow: **never invent a status code.**
|
|
5
|
+
*
|
|
6
|
+
* The scanner has already emitted whichever 2xx key the handler actually
|
|
7
|
+
* answers with — 201 for a bare `@Post`, 200 elsewhere, and whatever a
|
|
8
|
+
* `@HttpCode` moved it to — so a schema is written *onto that key* rather than
|
|
9
|
+
* onto a guessed one. A document that describes a `200` for a route answering
|
|
10
|
+
* `201` is worse than a document that describes nothing, because a consumer
|
|
11
|
+
* cannot tell it is wrong without curling the API, which is the whole thing
|
|
12
|
+
* these passes exist to make unnecessary.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.setSuccessResponse = setSuccessResponse;
|
|
16
|
+
exports.setSuccessResponseVariants = setSuccessResponseVariants;
|
|
17
|
+
exports.addErrorResponse = addErrorResponse;
|
|
18
|
+
/**
|
|
19
|
+
* Writes a success response's schema onto whichever 2xx key the scanner already
|
|
20
|
+
* emitted.
|
|
21
|
+
*
|
|
22
|
+
* `204` is left alone deliberately: a no-content response has no body, and
|
|
23
|
+
* attaching one would describe a payload the server never sends.
|
|
24
|
+
*/
|
|
25
|
+
function setSuccessResponse(operation, schema, description,
|
|
26
|
+
/**
|
|
27
|
+
* Media type. `application/json` for all but the two transfer downloads,
|
|
28
|
+
* which stream a file.
|
|
29
|
+
*/
|
|
30
|
+
mediaType = 'application/json',
|
|
31
|
+
/** Response headers worth documenting, keyed by header name. */
|
|
32
|
+
headers) {
|
|
33
|
+
const responses = operation.responses ?? {};
|
|
34
|
+
const key = Object.keys(responses).find((code) => /^2\d\d$/.test(code));
|
|
35
|
+
if (!key || key === '204') {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
responses[key] = {
|
|
39
|
+
description,
|
|
40
|
+
...(headers ? { headers } : {}),
|
|
41
|
+
content: { [mediaType]: { schema } }
|
|
42
|
+
};
|
|
43
|
+
operation.responses = responses;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Writes a success response carrying several media types — one download route
|
|
47
|
+
* whose content type depends on what the caller asked for.
|
|
48
|
+
*/
|
|
49
|
+
function setSuccessResponseVariants(operation, byMediaType, description, headers) {
|
|
50
|
+
const responses = operation.responses ?? {};
|
|
51
|
+
const key = Object.keys(responses).find((code) => /^2\d\d$/.test(code));
|
|
52
|
+
if (!key || key === '204') {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
responses[key] = {
|
|
56
|
+
description,
|
|
57
|
+
...(headers ? { headers } : {}),
|
|
58
|
+
content: Object.fromEntries(Object.entries(byMediaType).map(([type, schema]) => [
|
|
59
|
+
type,
|
|
60
|
+
{ schema }
|
|
61
|
+
]))
|
|
62
|
+
};
|
|
63
|
+
operation.responses = responses;
|
|
64
|
+
}
|
|
65
|
+
/** Adds a documented failure response, leaving any existing one alone. */
|
|
66
|
+
function addErrorResponse(operation, code, description, schema) {
|
|
67
|
+
const responses = operation.responses ?? {};
|
|
68
|
+
if (responses[code]) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
responses[code] = {
|
|
72
|
+
description,
|
|
73
|
+
...(schema ? { content: { 'application/json': { schema } } } : {})
|
|
74
|
+
};
|
|
75
|
+
operation.responses = responses;
|
|
76
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OpenAPI schemas of the **public** content API (`/api/v1/...`), kept apart
|
|
3
|
+
* from the admin's for the same reason `types/public-entry.ts` is kept apart
|
|
4
|
+
* from `EntryRecord`: this is a published contract an external site builds
|
|
5
|
+
* against, and it must be free to stay still while the admin's shape moves.
|
|
6
|
+
*
|
|
7
|
+
* Splitting them is not tidiness. Until this module existed the document
|
|
8
|
+
* described `/api/v1/content/{typeName}/{id}` with the **admin** entry schema,
|
|
9
|
+
* because the route pattern in `describe-content-api.ts` matched both spellings
|
|
10
|
+
* — so a consumer reading the reference was told a relation preview carries
|
|
11
|
+
* `RelationRef`s (id + title) when the public API returns whole entries, and
|
|
12
|
+
* that a media read is `Record<string, MediaRef[]>` when it is
|
|
13
|
+
* `Record<string, { items, total }>`. A wrong schema is worse than an absent
|
|
14
|
+
* one: the absent one sends you to curl, the wrong one does not.
|
|
15
|
+
*/
|
|
16
|
+
import type { SerializedContentType } from '../registry/content-type-registry';
|
|
17
|
+
import { type OpenApiSchema } from './field-schema';
|
|
18
|
+
/** Schema names of one content type's public trio. */
|
|
19
|
+
export interface PublicTypeSchemaNames {
|
|
20
|
+
/** The `values` bag — the entry's own data, references omitted. */
|
|
21
|
+
values: string;
|
|
22
|
+
/** One entry as the public API serves it. */
|
|
23
|
+
entry: string;
|
|
24
|
+
/** One page of them. */
|
|
25
|
+
listPage: string;
|
|
26
|
+
}
|
|
27
|
+
/** The three schema names a content type contributes to the public document. */
|
|
28
|
+
export declare function publicSchemaNamesOf(type: SerializedContentType): PublicTypeSchemaNames;
|
|
29
|
+
/**
|
|
30
|
+
* The public per-type entry schemas as alternatives — the response shape
|
|
31
|
+
* depends on `typeName`, which OpenAPI cannot express as a dependency. One
|
|
32
|
+
* registered type needs no union; none at all leaves an open object, since
|
|
33
|
+
* every one of these routes 404s anyway.
|
|
34
|
+
*
|
|
35
|
+
* `anyOf` rather than `oneOf`, for the reason `unionOf` in
|
|
36
|
+
* `describe-content-api.ts` spells out: the alternatives overlap, and *exactly
|
|
37
|
+
* one* is a promise the API does not keep.
|
|
38
|
+
*/
|
|
39
|
+
export declare function publicUnionOf(names: string[]): OpenApiSchema;
|
|
40
|
+
/**
|
|
41
|
+
* Every schema the public API contributes: its fixed shapes plus, per
|
|
42
|
+
* registered content type, the `Values` / `Entry` / `ListPage` trio.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildPublicApiSchemas(types: readonly SerializedContentType[]): Record<string, OpenApiSchema>;
|
|
45
|
+
//# sourceMappingURL=public-api-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-api-schemas.d.ts","sourceRoot":"","sources":["../../../src/lib/docs/public-api-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG/E,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAMjE,sDAAsD;AACtD,MAAM,WAAW,qBAAqB;IAClC,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CAC/B,IAAI,EAAE,qBAAqB,GAC5B,qBAAqB,CAOvB;AA+JD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa,CAK5D;AAuMD;;;GAGG;AACH,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,SAAS,qBAAqB,EAAE,GACxC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAY/B"}
|