@micacms/runtime 0.4.1 → 0.5.0-rc.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/README.md +2 -2
- package/dist/app.d.ts +8 -37
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +7 -42
- package/dist/app.js.map +1 -1
- package/dist/config.d.ts +12 -82
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -82
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +37 -66
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +24 -75
- package/dist/context.js.map +1 -1
- package/dist/http.d.ts +8 -16
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +6 -13
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +13 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -14
- package/dist/index.js.map +1 -1
- package/dist/routes/admin-content.d.ts +4 -17
- package/dist/routes/admin-content.d.ts.map +1 -1
- package/dist/routes/admin-content.js +11 -51
- package/dist/routes/admin-content.js.map +1 -1
- package/dist/routes/admin-media.d.ts +3 -14
- package/dist/routes/admin-media.d.ts.map +1 -1
- package/dist/routes/admin-media.js +7 -29
- package/dist/routes/admin-media.js.map +1 -1
- package/dist/routes/admin-staging.d.ts +4 -9
- package/dist/routes/admin-staging.d.ts.map +1 -1
- package/dist/routes/admin-staging.js +31 -18
- package/dist/routes/admin-staging.js.map +1 -1
- package/dist/routes/admin-system.d.ts +2 -8
- package/dist/routes/admin-system.d.ts.map +1 -1
- package/dist/routes/admin-system.js +9 -44
- package/dist/routes/admin-system.js.map +1 -1
- package/dist/routes/health.d.ts +3 -10
- package/dist/routes/health.d.ts.map +1 -1
- package/dist/routes/health.js +9 -26
- package/dist/routes/health.js.map +1 -1
- package/dist/schema.d.ts +10 -38
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +14 -65
- package/dist/schema.js.map +1 -1
- package/dist/server.d.ts +2 -10
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -9
- package/dist/server.js.map +1 -1
- package/dist/services/changes.d.ts +150 -0
- package/dist/services/changes.d.ts.map +1 -0
- package/dist/services/changes.js +339 -0
- package/dist/services/changes.js.map +1 -0
- package/dist/services/content-store.d.ts +61 -0
- package/dist/services/content-store.d.ts.map +1 -0
- package/dist/services/content-store.js +330 -0
- package/dist/services/content-store.js.map +1 -0
- package/dist/services/media.d.ts +9 -29
- package/dist/services/media.d.ts.map +1 -1
- package/dist/services/media.js +17 -57
- package/dist/services/media.js.map +1 -1
- package/dist/services/staging.d.ts +35 -167
- package/dist/services/staging.d.ts.map +1 -1
- package/dist/services/staging.js +195 -458
- package/dist/services/staging.js.map +1 -1
- package/dist/workspace/developer.d.ts +14 -0
- package/dist/workspace/developer.d.ts.map +1 -0
- package/dist/workspace/developer.js +31 -0
- package/dist/workspace/developer.js.map +1 -0
- package/dist/workspace/files.d.ts +70 -0
- package/dist/workspace/files.d.ts.map +1 -0
- package/dist/workspace/files.js +176 -0
- package/dist/workspace/files.js.map +1 -0
- package/dist/workspace/git.d.ts +45 -0
- package/dist/workspace/git.d.ts.map +1 -0
- package/dist/workspace/git.js +68 -0
- package/dist/workspace/git.js.map +1 -0
- package/dist/workspace/locks.d.ts +33 -0
- package/dist/workspace/locks.d.ts.map +1 -0
- package/dist/workspace/locks.js +76 -0
- package/dist/workspace/locks.js.map +1 -0
- package/dist/workspace/policy.d.ts +92 -0
- package/dist/workspace/policy.d.ts.map +1 -0
- package/dist/workspace/policy.js +7 -0
- package/dist/workspace/policy.js.map +1 -0
- package/dist/workspace/tree.d.ts +73 -0
- package/dist/workspace/tree.d.ts.map +1 -0
- package/dist/workspace/tree.js +229 -0
- package/dist/workspace/tree.js.map +1 -0
- package/package.json +2 -3
- package/dist/db/driver.d.ts +0 -35
- package/dist/db/driver.d.ts.map +0 -1
- package/dist/db/driver.js +0 -95
- package/dist/db/driver.js.map +0 -1
- package/dist/lib/git.d.ts +0 -29
- package/dist/lib/git.d.ts.map +0 -1
- package/dist/lib/git.js +0 -62
- package/dist/lib/git.js.map +0 -1
- package/dist/services/staging-local.d.ts +0 -58
- package/dist/services/staging-local.d.ts.map +0 -1
- package/dist/services/staging-local.js +0 -391
- package/dist/services/staging-local.js.map +0 -1
|
@@ -1,174 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - draft store (this file): the repository is remote and writing through
|
|
12
|
-
* its API would already be a commit, so saves accumulate in SQLite and
|
|
13
|
-
* Publish turns the whole set into one provider-side commit.
|
|
14
|
-
*
|
|
15
|
-
* The editor sees one API either way. What differs is only what Saved means —
|
|
16
|
-
* and the two must stay visibly different words in the UI, because in neither
|
|
17
|
-
* mode does Saved imply that a change is in Git.
|
|
2
|
+
* The staging service on a Git working tree. Autosave has already written the
|
|
3
|
+
* files; Publish commits the reviewed paths.
|
|
4
|
+
*
|
|
5
|
+
* - Every Git operation is limited to an explicit path set, so other work in
|
|
6
|
+
* the same checkout is never swept in.
|
|
7
|
+
* - Only the reviewed files are published, as the editor saw them. Drafts of
|
|
8
|
+
* other entries stay drafts.
|
|
9
|
+
* - When the push fails, the commit stays as `committed-pending-push`; a
|
|
10
|
+
* retry pushes and never commits again.
|
|
18
11
|
*/
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
renamedFrom?: string;
|
|
29
|
-
} | {
|
|
30
|
-
kind: "singleton";
|
|
31
|
-
name: string;
|
|
32
|
-
label: string;
|
|
33
|
-
} | {
|
|
34
|
-
kind: "order";
|
|
35
|
-
collection: string;
|
|
36
|
-
label: string;
|
|
37
|
-
} | {
|
|
38
|
-
kind: "media";
|
|
39
|
-
label: string;
|
|
40
|
-
} | {
|
|
41
|
-
kind: "other";
|
|
42
|
-
label: string;
|
|
43
|
-
};
|
|
44
|
-
export interface AnnotatedChange extends ContentChange {
|
|
45
|
-
owner: ChangeOwner;
|
|
46
|
-
}
|
|
47
|
-
/** One thing that would make the staged result unpublishable. */
|
|
48
|
-
export interface StagingProblem {
|
|
49
|
-
/** The file the problem is about, relative to the content root. */
|
|
50
|
-
path: string;
|
|
51
|
-
label: string;
|
|
52
|
-
issues: FieldIssue[];
|
|
53
|
-
}
|
|
54
|
-
export interface StagingValidation {
|
|
55
|
-
ok: boolean;
|
|
56
|
-
problems: StagingProblem[];
|
|
57
|
-
}
|
|
58
|
-
export interface StagingStatus {
|
|
59
|
-
/** How this deployment stages. The UI words differ with it. */
|
|
60
|
-
workspace: "working-tree" | "draft-store";
|
|
61
|
-
publish: {
|
|
62
|
-
enabled: boolean;
|
|
63
|
-
reason?: string;
|
|
64
|
-
};
|
|
12
|
+
import { type Site } from "@micacms/core";
|
|
13
|
+
import type { Logger } from "../lib/logger.js";
|
|
14
|
+
import type { ContentFiles } from "../workspace/files.js";
|
|
15
|
+
import { type WorkspaceLocks } from "../workspace/locks.js";
|
|
16
|
+
import type { OwnerPolicy } from "../workspace/policy.js";
|
|
17
|
+
import { type GitTree } from "../workspace/tree.js";
|
|
18
|
+
import { type ContentStagingService } from "./changes.js";
|
|
19
|
+
export interface WorkingTreeStagingDeps {
|
|
20
|
+
model: Site;
|
|
65
21
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
22
|
+
* The working tree's files without the lock wrapper: this service holds the
|
|
23
|
+
* locks around whole operations.
|
|
68
24
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
branch: string | null;
|
|
72
|
-
/** Commits created and not yet pushed. Working tree only. */
|
|
73
|
-
ahead: number | null;
|
|
74
|
-
changes: AnnotatedChange[];
|
|
75
|
-
validation: StagingValidation;
|
|
76
|
-
/** When the pending set last moved. Null when nothing is pending. */
|
|
77
|
-
updatedAt: string | null;
|
|
78
|
-
}
|
|
79
|
-
export interface PublishInput {
|
|
80
|
-
/** Subject line of the commit. Written by the editor, for `git log`. */
|
|
81
|
-
message: string;
|
|
82
|
-
/** The base the editor reviewed. A repository that moved past it refuses. */
|
|
83
|
-
expectedBase: string | null;
|
|
84
|
-
author?: Author;
|
|
85
|
-
}
|
|
86
|
-
export interface ContentStagingService {
|
|
87
|
-
status(): Promise<StagingStatus>;
|
|
88
|
-
publish(input: PublishInput): Promise<PublishResult>;
|
|
89
|
-
discard(paths: string[]): Promise<{
|
|
90
|
-
discarded: string[];
|
|
91
|
-
}>;
|
|
92
|
-
/** Retries the push after `committed-pending-push`. Working tree only. */
|
|
93
|
-
push(): Promise<PublishResult>;
|
|
94
|
-
/** The document a pending change touches, before and after that change. */
|
|
95
|
-
compare(target: CompareTarget): Promise<Comparison>;
|
|
96
|
-
}
|
|
97
|
-
/** One thing an editor recognises on the Publish page, named for comparison. */
|
|
98
|
-
export type CompareTarget =
|
|
99
|
-
/** `from` names the published slug of a renamed entry. */
|
|
100
|
-
{
|
|
101
|
-
kind: "entry";
|
|
102
|
-
collection: string;
|
|
103
|
-
slug: string;
|
|
104
|
-
from?: string;
|
|
105
|
-
} | {
|
|
106
|
-
kind: "singleton";
|
|
107
|
-
name: string;
|
|
108
|
-
} | {
|
|
109
|
-
kind: "order";
|
|
110
|
-
collection: string;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* A document on both sides of the pending change set.
|
|
114
|
-
*
|
|
115
|
-
* Raw field data, deliberately: the editor holds the model and can name,
|
|
116
|
-
* order and render every field, so the friendly comparison is its job. What
|
|
117
|
-
* only the server can do is read the same document from two places.
|
|
118
|
-
*/
|
|
119
|
-
export interface Comparison {
|
|
120
|
-
/** As the repository has it — null when the change creates the document. */
|
|
121
|
-
before: Record<string, unknown> | null;
|
|
122
|
-
/** As staged for publication — null when the change deletes it. */
|
|
123
|
-
after: Record<string, unknown> | null;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Reads one document from the repository (`published`) and from the pending
|
|
127
|
-
* workspace (`staged`) — the whole of a before/after comparison, shared by
|
|
128
|
-
* both staging implementations since a `ContentSource` is all it needs.
|
|
129
|
-
*
|
|
130
|
-
* An order target compares the collection's ordering rather than a document:
|
|
131
|
-
* each side becomes `{ order: [{ slug, title }] }`, in position order.
|
|
132
|
-
*/
|
|
133
|
-
export declare function compareSources(model: Site, published: ContentSource, staged: ContentSource, target: CompareTarget): Promise<Comparison>;
|
|
134
|
-
/**
|
|
135
|
-
* Annotates a change set with owners and validates the entries it touches.
|
|
136
|
-
*
|
|
137
|
-
* One pass on purpose: naming a change and validating it both need the same
|
|
138
|
-
* read of the same entries, and content trees are small enough to read the
|
|
139
|
-
* affected collections whole.
|
|
140
|
-
*
|
|
141
|
-
* Validation is scoped to *changed* documents. Content that was already in
|
|
142
|
-
* the repository is not this publication's problem — refusing
|
|
143
|
-
* to publish a fixed typo because somebody once hand-committed a broken entry
|
|
144
|
-
* elsewhere would make the editor hostage to history it cannot touch.
|
|
145
|
-
*/
|
|
146
|
-
export declare function analyseChanges(model: Site, source: ContentSource, changes: ContentChange[],
|
|
147
|
-
/** The repository's side. When given, renamed entries are detected. */
|
|
148
|
-
published?: ContentSource): Promise<{
|
|
149
|
-
changes: AnnotatedChange[];
|
|
150
|
-
validation: StagingValidation;
|
|
151
|
-
}>;
|
|
152
|
-
/**
|
|
153
|
-
* Which piece of content a file belongs to.
|
|
154
|
-
*
|
|
155
|
-
* The path layout is the model's own (`layout.ts`), so this is a reading of
|
|
156
|
-
* it, not a second convention: `collection/slug/…` or `collection/slug.json`,
|
|
157
|
-
* `singleton.json` or `singleton/…`, and the shared `media/` directory.
|
|
158
|
-
*/
|
|
159
|
-
export declare function classifyPath(model: Site, path: string): ChangeOwner;
|
|
160
|
-
export interface DraftStagingDeps {
|
|
161
|
-
model: Site;
|
|
162
|
-
drafts: DraftStore;
|
|
163
|
-
/** The real repository. The one thing here that writes to it. */
|
|
164
|
-
repository: RepositoryConnector;
|
|
165
|
-
/** The staged overlay the rest of the application reads through. */
|
|
166
|
-
overlay: RepositoryConnector;
|
|
167
|
-
/** Revision of `.mica/schema.json` when the model was loaded. */
|
|
25
|
+
files: ContentFiles;
|
|
26
|
+
contentRoot: string;
|
|
168
27
|
schemaRevision: string | null;
|
|
28
|
+
/** `MICA_LOCAL_PUBLISH`, for the default developer policy. */
|
|
29
|
+
publishEnabled: boolean;
|
|
30
|
+
logger: Logger;
|
|
31
|
+
/** Defaults to the developer. */
|
|
32
|
+
policy?: OwnerPolicy;
|
|
33
|
+
/** Shared with the services that write content. */
|
|
34
|
+
locks?: WorkspaceLocks;
|
|
35
|
+
/**
|
|
36
|
+
* Set by a managed clone, whose Git runs in an isolated environment. Without
|
|
37
|
+
* it, the developer's Git finds the tree.
|
|
38
|
+
*/
|
|
39
|
+
tree?: GitTree;
|
|
169
40
|
}
|
|
170
|
-
export declare function
|
|
171
|
-
export declare function describeProblems(problems: StagingProblem[]): string;
|
|
172
|
-
/** Field issues with the file path folded in, for the flat API envelope. */
|
|
173
|
-
export declare function flattenProblems(problems: StagingProblem[]): FieldIssue[];
|
|
41
|
+
export declare function createWorkingTreeStagingService(deps: WorkingTreeStagingDeps): ContentStagingService;
|
|
174
42
|
//# sourceMappingURL=staging.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staging.d.ts","sourceRoot":"","sources":["../../src/services/staging.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"staging.d.ts","sourceRoot":"","sources":["../../src/services/staging.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAmD,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAG3F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EASL,KAAK,OAAO,EAEb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAQL,KAAK,qBAAqB,EAK3B,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,IAAI,CAAC;IACZ;;;OAGG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,8DAA8D;IAC9D,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,mDAAmD;IACnD,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,sBAAsB,GAC3B,qBAAqB,CA8OvB"}
|