@taprootio/site-authoring 0.16.0 → 0.19.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 +67 -13
- package/package.json +1 -1
- package/src/api.js +129 -11
- package/src/cli.js +41 -1
- package/src/constants.js +16 -0
- package/src/field-schema.json +5 -0
- package/src/field-validation.js +5 -1
- package/src/forms-api.js +8 -1
- package/src/forms-contract.js +29 -6
- package/src/forms-workspace.js +23 -14
- package/src/reference-help.js +10 -4
- package/src/transport.js +73 -12
- package/src/typed-page-reference.js +3 -1
- package/src/verbs/deploy.js +24 -4
- package/src/verbs/forms-pull.js +1 -3
- package/src/verbs/forms-push.js +54 -36
- package/src/verbs/index.js +9 -1
- package/src/verbs/media-upload.js +0 -1
- package/src/verbs/places.js +72 -2
- package/src/verbs/status.js +1 -4
package/src/verbs/places.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
clearPlaceCategory,
|
|
5
|
+
isGooglePlaceId,
|
|
6
|
+
listPlaceCategories,
|
|
7
|
+
searchPlaces,
|
|
8
|
+
selectPlace,
|
|
9
|
+
setPlaceCategory,
|
|
10
|
+
withRefusalGuidance,
|
|
11
|
+
} from "../api.js";
|
|
12
|
+
import {
|
|
13
|
+
VERB_PLACES_CATEGORY_CLEAR,
|
|
14
|
+
VERB_PLACES_CATEGORY_LIST,
|
|
15
|
+
VERB_PLACES_CATEGORY_SET,
|
|
16
|
+
VERB_PLACES_SEARCH,
|
|
17
|
+
VERB_PLACES_SELECT,
|
|
18
|
+
} from "../constants.js";
|
|
5
19
|
import { SiteAuthoringError } from "../errors.js";
|
|
6
20
|
import { openSession, successResult } from "../session.js";
|
|
7
21
|
|
|
@@ -18,6 +32,9 @@ import { openSession, successResult } from "../session.js";
|
|
|
18
32
|
*/
|
|
19
33
|
|
|
20
34
|
const MAXIMUM_QUERY_LENGTH = 200;
|
|
35
|
+
const MAXIMUM_CATEGORY_LENGTH = 100;
|
|
36
|
+
// Any UUID version: the server mints place ids from a sequential-style generator.
|
|
37
|
+
const PLACE_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
|
|
21
38
|
const SESSION_TOKEN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u;
|
|
22
39
|
|
|
23
40
|
export async function placesSearch(invocation) {
|
|
@@ -59,3 +76,56 @@ export async function placesSelect(invocation) {
|
|
|
59
76
|
onProgress(`Selected ${place.name}: use placeId ${place.placeId} in the page's front matter.`);
|
|
60
77
|
return successResult(VERB_PLACES_SELECT, siteId, { place });
|
|
61
78
|
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* `places category set|clear|list` — this site's own category for a place
|
|
82
|
+
* (TR01203).
|
|
83
|
+
*
|
|
84
|
+
* A place's category is shared by every site, and Google's types do not always
|
|
85
|
+
* give the one an owner wants. The override is the site's alone: its place
|
|
86
|
+
* reviews and `/places/<category>` pages use it from the next deployment, and
|
|
87
|
+
* the platform-wide place is never changed. The server owns the closed list, so
|
|
88
|
+
* the CLI sends the name as given and lets the server check it.
|
|
89
|
+
*/
|
|
90
|
+
export async function placesCategorySet(invocation) {
|
|
91
|
+
const [placeId, category, ...extra] = Array.isArray(invocation.placeCategory) ? invocation.placeCategory : [];
|
|
92
|
+
if (!PLACE_ID.test(placeId ?? "") || extra.length > 0 || typeof category !== "string"
|
|
93
|
+
|| category.trim() === "" || category.length > MAXIMUM_CATEGORY_LENGTH) {
|
|
94
|
+
throw new SiteAuthoringError(
|
|
95
|
+
"places.category_invalid",
|
|
96
|
+
"places category set takes the placeId, then one category from 'places category list'.",
|
|
97
|
+
{ field: "category", exitCode: 2 },
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
const session = await openSession(invocation);
|
|
101
|
+
const { client, siteId, onProgress } = session;
|
|
102
|
+
const state = await withRefusalGuidance(onProgress, "place category", async () =>
|
|
103
|
+
await setPlaceCategory(client, siteId, { placeId, category: category.trim() }));
|
|
104
|
+
onProgress(`This site now files ${placeId} under ${state.category}; deploy for pages to use it.`);
|
|
105
|
+
return successResult(VERB_PLACES_CATEGORY_SET, siteId, { placeCategory: state });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export async function placesCategoryClear(invocation) {
|
|
109
|
+
const [placeId, ...extra] = Array.isArray(invocation.placeId) ? invocation.placeId : [];
|
|
110
|
+
if (!PLACE_ID.test(placeId ?? "") || extra.length > 0) {
|
|
111
|
+
throw new SiteAuthoringError(
|
|
112
|
+
"places.category_invalid",
|
|
113
|
+
"places category clear takes the placeId of the place whose category this site set.",
|
|
114
|
+
{ field: "placeId", exitCode: 2 },
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
const session = await openSession(invocation);
|
|
118
|
+
const { client, siteId, onProgress } = session;
|
|
119
|
+
const state = await withRefusalGuidance(onProgress, "place category", async () =>
|
|
120
|
+
await clearPlaceCategory(client, siteId, { placeId }));
|
|
121
|
+
onProgress(`This site files ${placeId} under ${state.category} again; deploy for pages to use it.`);
|
|
122
|
+
return successResult(VERB_PLACES_CATEGORY_CLEAR, siteId, { placeCategory: state });
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function placesCategoryList(invocation) {
|
|
126
|
+
const session = await openSession(invocation);
|
|
127
|
+
const { client, siteId, onProgress } = session;
|
|
128
|
+
const categories = await withRefusalGuidance(onProgress, "place categories", async () =>
|
|
129
|
+
await listPlaceCategories(client));
|
|
130
|
+
return successResult(VERB_PLACES_CATEGORY_LIST, siteId, { categories });
|
|
131
|
+
}
|
package/src/verbs/status.js
CHANGED
|
@@ -132,10 +132,7 @@ export async function status(invocation) {
|
|
|
132
132
|
const selection = presentationOnly
|
|
133
133
|
? { ...reviewed, stagedPageIds: [], includeNavigation: false }
|
|
134
134
|
: reviewed;
|
|
135
|
-
const readiness = await getPublishingReadiness(client, siteId,
|
|
136
|
-
...selection,
|
|
137
|
-
stagedPageIds: selection.stagedPageIds.length > 100 ? undefined : selection.stagedPageIds,
|
|
138
|
-
});
|
|
135
|
+
const readiness = await getPublishingReadiness(client, siteId, selection);
|
|
139
136
|
onProgress("Reading the deployment log.");
|
|
140
137
|
const {
|
|
141
138
|
deployments,
|