@anthusai/papyrus 5.120.0 → 5.121.0-next.2
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/amplify/functions/content-actions/handler.py +19 -2
- package/amplify/functions/content-actions/requirements.txt +1 -1
- package/amplify/functions/content-actions/resource.js +1 -1
- package/amplify/functions/content-actions/resource.ts +1 -1
- package/amplify/functions/editorial-checks/requirements.txt +1 -1
- package/amplify/publication/redirect-and-index.js +7 -2
- package/package.json +1 -1
- package/routes.manifest.json +1 -1
|
@@ -814,7 +814,7 @@ def projection_status_action(arguments: dict) -> dict:
|
|
|
814
814
|
return {"ok": True, "itemId": arguments["id"], "lineageId": candidate.get("lineageId"), "projection": answer}
|
|
815
815
|
|
|
816
816
|
|
|
817
|
-
def start_projection_job(client, item_id: str, *, version: int | None, published_item_id: str | None, unpublished: bool = False) -> dict:
|
|
817
|
+
def start_projection_job(client, item_id: str, *, version: int | None, published_item_id: str | None, unpublished: bool = False, queue_only: bool = False) -> dict:
|
|
818
818
|
"""Start building a story's pages (or, for ``unpublished``, taking them down) in the background, or join the build already queued or running for it.
|
|
819
819
|
Returns what the caller is told. The build decides from the stored state whether the page stays or goes, so a queued unpublish is built by the same drain."""
|
|
820
820
|
context = projection_context(client)
|
|
@@ -833,9 +833,15 @@ def start_projection_job(client, item_id: str, *, version: int | None, published
|
|
|
833
833
|
task[PUBLISHED_TASK_KEY] = {"publishedItemId": published_item_id}
|
|
834
834
|
jobs = publish_jobs_from_environment()
|
|
835
835
|
if jobs is None:
|
|
836
|
+
if queue_only:
|
|
837
|
+
raise ValueError("A batch publish needs the site's publish job records, and this site keeps none; publish the Stories one at a time.")
|
|
836
838
|
answer["projection"] = {"state": "scheduled" if schedule_projection_task(task, "publish") else "not-scheduled"}
|
|
837
839
|
return answer
|
|
838
840
|
job, joined = jobs.request(item_id, version, announce={"publishedItemId": published_item_id} if published_item_id else None)
|
|
841
|
+
if queue_only:
|
|
842
|
+
# A batch (PPY: one projection per batch): the job is queued and no build is started for it. The batch's one drain builds every queued Story under one hold of the lease.
|
|
843
|
+
answer["projection"] = {**job_answer(job), "joined": joined, "queued": True}
|
|
844
|
+
return answer
|
|
839
845
|
if not joined:
|
|
840
846
|
if not schedule_projection_task({**task, "jobId": job["jobId"]}, "publish"):
|
|
841
847
|
jobs.finish(item_id, job["jobId"], ok=False, outcome={"error": "the build could not be started"})
|
|
@@ -844,9 +850,19 @@ def start_projection_job(client, item_id: str, *, version: int | None, published
|
|
|
844
850
|
return answer
|
|
845
851
|
|
|
846
852
|
|
|
853
|
+
def drain_publish_queue_action() -> dict:
|
|
854
|
+
"""``publishItem`` with ``{"drain": true}``: build every queued Story in one invocation under one hold of the lease (``run_queued_build`` drains the queue). A batch publish
|
|
855
|
+
queues each Story with ``queueOnly`` and asks for this once, so a backfill of N Stories takes the lease once, never N times against a deploy."""
|
|
856
|
+
if publish_jobs_from_environment() is None:
|
|
857
|
+
raise ValueError("A batch publish needs the site's publish job records, and this site keeps none; publish the Stories one at a time.")
|
|
858
|
+
return {"ok": True, "scheduled": bool(schedule_projection_task({"task": "drain"}, "batch publish"))}
|
|
859
|
+
|
|
860
|
+
|
|
847
861
|
def publish_item_action(arguments: dict, actor: str, approved_by: str | None = None) -> dict:
|
|
848
862
|
if arguments.get("jobStatus"):
|
|
849
863
|
return projection_status_action(arguments)
|
|
864
|
+
if arguments.get("drain") is True:
|
|
865
|
+
return drain_publish_queue_action()
|
|
850
866
|
client = authoring_client()
|
|
851
867
|
candidate = client.get_record("Item", arguments["id"]) or {}
|
|
852
868
|
live = client.get_record("PublishedItem", published_item_id_for(candidate.get("lineageId") or arguments["id"]))
|
|
@@ -867,7 +883,8 @@ def publish_item_action(arguments: dict, actor: str, approved_by: str | None = N
|
|
|
867
883
|
published_item_id = result.published_item_id if result.changed else None
|
|
868
884
|
if arguments.get("async") is True and projection_configured():
|
|
869
885
|
# The CLI asks for this (PPY-3acc8d): the data is saved now and the pages are built in the background; it asks for the job's status.
|
|
870
|
-
response.update(start_projection_job(client, arguments["id"], version=result.version_number, published_item_id=published_item_id
|
|
886
|
+
response.update(start_projection_job(client, arguments["id"], version=result.version_number, published_item_id=published_item_id,
|
|
887
|
+
queue_only=arguments.get("queueOnly") is True))
|
|
871
888
|
return response
|
|
872
889
|
response.update(project_item_action(client, arguments["id"], unpublished=False, published_item_id=published_item_id))
|
|
873
890
|
return response
|
|
@@ -7,7 +7,7 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
import { pythonLambdaCode } from "../shared/python-bundle.js";
|
|
8
8
|
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
9
|
const projectRoot = path.resolve(dirname, "../../..");
|
|
10
|
-
export const contentActionsRequirements = ["PyYAML>=6.0.2,<7", "citeproc-py>=0.8.2,<1", "anthus-markus==0.7.0", "latex2mathml>=3.78,<4", "Pillow>=11.3,<12", "awscrt>=0.23,<1", "humanus>=0.
|
|
10
|
+
export const contentActionsRequirements = ["PyYAML>=6.0.2,<7", "citeproc-py>=0.8.2,<1", "anthus-markus==0.7.0", "latex2mathml>=3.78,<4", "Pillow>=11.3,<12", "awscrt>=0.23,<1", "humanus>=0.39.0,<0.40", "pypdf>=6.12.1,<7"];
|
|
11
11
|
function installCheckoutRequirements(outputDir) {
|
|
12
12
|
const requirementsPath = path.join(projectRoot, "amplify/functions/content-actions/requirements.txt");
|
|
13
13
|
execSync(`python3 -m pip install -r "${requirementsPath}" -t "${outputDir}" --no-cache-dir --platform manylinux2014_aarch64 --implementation cp --python-version 3.12 --only-binary=:all: --ignore-requires-python`, { cwd: projectRoot, stdio: "inherit" });
|
|
@@ -10,7 +10,7 @@ import { pythonLambdaCode, type SiteBundleFile } from "../shared/python-bundle";
|
|
|
10
10
|
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
11
|
const projectRoot = path.resolve(dirname, "../../..");
|
|
12
12
|
|
|
13
|
-
export const contentActionsRequirements = ["PyYAML>=6.0.2,<7", "citeproc-py>=0.8.2,<1", "anthus-markus==0.7.0", "latex2mathml>=3.78,<4", "Pillow>=11.3,<12", "awscrt>=0.23,<1", "humanus>=0.
|
|
13
|
+
export const contentActionsRequirements = ["PyYAML>=6.0.2,<7", "citeproc-py>=0.8.2,<1", "anthus-markus==0.7.0", "latex2mathml>=3.78,<4", "Pillow>=11.3,<12", "awscrt>=0.23,<1", "humanus>=0.39.0,<0.40", "pypdf>=6.12.1,<7"];
|
|
14
14
|
|
|
15
15
|
function installCheckoutRequirements(outputDir: string): void {
|
|
16
16
|
const requirementsPath = path.join(projectRoot, "amplify/functions/content-actions/requirements.txt");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
humanus[jev]>=0.
|
|
1
|
+
humanus[jev]>=0.39.0,<0.40
|
|
@@ -124,6 +124,11 @@ function queryStringOf(request) {
|
|
|
124
124
|
return parts.length === 0 ? "" : "?" + parts.join("&");
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
// A redirect keeps the request's query string (a path on this site only: an absolute target is the rule's own address).
|
|
128
|
+
function withQuery(target, request) {
|
|
129
|
+
return target.charAt(0) === "/" && target.indexOf("?") === -1 ? target + queryStringOf(request) : target;
|
|
130
|
+
}
|
|
131
|
+
|
|
127
132
|
function wwwRedirectResponse(request) {
|
|
128
133
|
const header = request.headers && request.headers.host;
|
|
129
134
|
const host = header && header.value ? header.value.toLowerCase() : "";
|
|
@@ -150,7 +155,7 @@ async function handler(event) {
|
|
|
150
155
|
return {
|
|
151
156
|
statusCode: 301,
|
|
152
157
|
statusDescription: "Moved Permanently",
|
|
153
|
-
headers: { location: { value: redirectTarget } },
|
|
158
|
+
headers: { location: { value: withQuery(redirectTarget, request) } },
|
|
154
159
|
};
|
|
155
160
|
}
|
|
156
161
|
const patternRedirect = lookUpPatternRedirect(request.uri);
|
|
@@ -158,7 +163,7 @@ async function handler(event) {
|
|
|
158
163
|
return {
|
|
159
164
|
statusCode: patternRedirect.status,
|
|
160
165
|
statusDescription: "Moved",
|
|
161
|
-
headers: { location: { value: patternRedirect.target } },
|
|
166
|
+
headers: { location: { value: withQuery(patternRedirect.target, request) } },
|
|
162
167
|
};
|
|
163
168
|
}
|
|
164
169
|
request.uri = rewriteToIndexDocument(request.uri);
|
package/package.json
CHANGED
package/routes.manifest.json
CHANGED