@nuasite/cms-sidecar 0.43.0-beta.1
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/cli.js +25032 -0
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/cli.d.ts.map +1 -0
- package/dist/types/cli.js +77 -0
- package/dist/types/concurrency.d.ts +26 -0
- package/dist/types/concurrency.d.ts.map +1 -0
- package/dist/types/concurrency.js +47 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/media-from-env.d.ts +32 -0
- package/dist/types/media-from-env.d.ts.map +1 -0
- package/dist/types/media-from-env.js +57 -0
- package/dist/types/server.d.ts +22 -0
- package/dist/types/server.d.ts.map +1 -0
- package/dist/types/server.js +598 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dist/types/types.d.ts +99 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +10 -0
- package/package.json +57 -0
- package/src/cli.ts +105 -0
- package/src/concurrency.ts +51 -0
- package/src/index.ts +24 -0
- package/src/media-from-env.ts +96 -0
- package/src/server.ts +650 -0
- package/src/tsconfig.json +10 -0
- package/src/types.ts +141 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { CollectionDefinition, CollectionEntryInfo } from '@nuasite/cms-types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wire-level types specific to the `/cms/v1` HTTP contract. The structural model
|
|
5
|
+
* (collections, entries, mutations, pages, redirects, media) is reused 1:1 from
|
|
6
|
+
* `@nuasite/cms-types`; this module only adds the HTTP envelope (errors, the
|
|
7
|
+
* conflict response, the project model and the request body shapes).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Error model
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
/** Stable error codes exposed by the sidecar, each mapped to an HTTP status. */
|
|
15
|
+
export type ErrorCode =
|
|
16
|
+
| 'not_found'
|
|
17
|
+
| 'conflict'
|
|
18
|
+
| 'validation'
|
|
19
|
+
| 'parse_error'
|
|
20
|
+
| 'io_error'
|
|
21
|
+
| 'unsupported'
|
|
22
|
+
| 'unauthorized'
|
|
23
|
+
|
|
24
|
+
/** JSON body returned for every non-2xx response that is not a conflict. */
|
|
25
|
+
export interface ApiError {
|
|
26
|
+
error: string
|
|
27
|
+
code: ErrorCode
|
|
28
|
+
sourcePath?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** HTTP status for each error code. */
|
|
32
|
+
export const STATUS_BY_CODE: Record<ErrorCode, number> = {
|
|
33
|
+
not_found: 404,
|
|
34
|
+
conflict: 409,
|
|
35
|
+
validation: 400,
|
|
36
|
+
parse_error: 400,
|
|
37
|
+
io_error: 500,
|
|
38
|
+
unsupported: 501,
|
|
39
|
+
unauthorized: 401,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returned with `409` when a `PATCH`'s `baseHash` no longer matches the file on
|
|
44
|
+
* disk (an agent or a human wrote in between). Carries the current server
|
|
45
|
+
* version so the client can offer "use server" vs "use ours".
|
|
46
|
+
*/
|
|
47
|
+
export interface ConflictResponse {
|
|
48
|
+
code: 'conflict'
|
|
49
|
+
serverHash: string
|
|
50
|
+
serverFrontmatter: Record<string, unknown>
|
|
51
|
+
serverBody?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ============================================================================
|
|
55
|
+
// Request bodies / queries
|
|
56
|
+
// ============================================================================
|
|
57
|
+
|
|
58
|
+
export interface UpdateEntryBody {
|
|
59
|
+
/** Frontmatter keys to merge (not replace) into the entry. */
|
|
60
|
+
frontmatter?: Record<string, unknown>
|
|
61
|
+
body?: string
|
|
62
|
+
/** Hash of the entry source the client edited; `409` on drift. */
|
|
63
|
+
baseHash?: string
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface CreateEntryBody {
|
|
67
|
+
slug: string
|
|
68
|
+
frontmatter: Record<string, unknown>
|
|
69
|
+
body?: string
|
|
70
|
+
/** File extension override for data collections (e.g. 'json', 'yaml'). */
|
|
71
|
+
fileExtension?: string
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface RenameEntryBody {
|
|
75
|
+
to: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface AddArrayItemBody {
|
|
79
|
+
field: string
|
|
80
|
+
value: unknown
|
|
81
|
+
index?: number
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface RemoveArrayItemBody {
|
|
85
|
+
field: string
|
|
86
|
+
index: number
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface CreateFolderBody {
|
|
90
|
+
folder: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Parsed `GET …/entries` query. */
|
|
94
|
+
export interface EntriesQuery {
|
|
95
|
+
/** "slug,title" | "*" ; absent = light header (slug/title/draft/pathname/sourcePath), never the body. */
|
|
96
|
+
fields?: string
|
|
97
|
+
draft: 'true' | 'false' | 'all'
|
|
98
|
+
limit?: number
|
|
99
|
+
cursor?: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// Project model
|
|
104
|
+
// ============================================================================
|
|
105
|
+
|
|
106
|
+
export interface Capabilities {
|
|
107
|
+
coreVersion: string
|
|
108
|
+
features: string[]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A static page route discovered under `src/pages`.
|
|
113
|
+
*
|
|
114
|
+
* cms-core exposes no page-listing capability (only create/duplicate/delete +
|
|
115
|
+
* layouts), and the rich `PageEntry` with an SEO `title` lives in the render
|
|
116
|
+
* manifest, which is render-time and intentionally out of the headless scope.
|
|
117
|
+
* The sidecar therefore derives the list from the `CmsFileSystem` port: a pure
|
|
118
|
+
* `src/pages` walk yielding `pathname` only. `title` is omitted (it would need
|
|
119
|
+
* the manifest). Mirrors the shape of `@nuasite/cms`'s `PageEntry`.
|
|
120
|
+
*/
|
|
121
|
+
export interface PageEntry {
|
|
122
|
+
/** Page URL pathname (e.g. '/', '/about'). */
|
|
123
|
+
pathname: string
|
|
124
|
+
/** Page title — only populated by the render manifest (out of headless scope). */
|
|
125
|
+
title?: string
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface ProjectModel {
|
|
129
|
+
/** Collection definitions with their `entries[]` info (no full bodies). */
|
|
130
|
+
collections: CollectionDefinition[]
|
|
131
|
+
/** Static page routes discovered under `src/pages` (pathname-only). */
|
|
132
|
+
pages: PageEntry[]
|
|
133
|
+
capabilities: Capabilities
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Sparse list response: the projected entries plus an opaque continuation cursor. */
|
|
137
|
+
export interface EntriesListResult {
|
|
138
|
+
entries: CollectionEntryInfo[]
|
|
139
|
+
cursor?: string
|
|
140
|
+
hasMore: boolean
|
|
141
|
+
}
|