@anthusai/papyrus 5.120.0-next.1 → 5.121.0-next.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.
@@ -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
@@ -4,5 +4,5 @@ anthus-markus==0.7.0
4
4
  latex2mathml>=3.78,<4
5
5
  Pillow>=11.3,<12
6
6
  awscrt>=0.23,<1
7
- humanus>=0.38.3,<0.39
7
+ humanus>=0.39.0,<0.40
8
8
  pypdf>=6.12.1,<7
@@ -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.38.3,<0.39", "pypdf>=6.12.1,<7"];
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.38.3,<0.39", "pypdf>=6.12.1,<7"];
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.38.3,<0.39
1
+ humanus[jev]>=0.39.0,<0.40
package/package.json CHANGED
@@ -640,7 +640,7 @@
640
640
  "optional": true
641
641
  }
642
642
  },
643
- "version": "5.120.0-next.1",
643
+ "version": "5.121.0-next.1",
644
644
  "dependencies": {
645
645
  "@aws-amplify/adapter-nextjs": "^1.7.3",
646
646
  "@aws-crypto/sha256-js": "5.2.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.120.0-next.1",
2
+ "version": "5.121.0-next.1",
3
3
  "routes": [
4
4
  {
5
5
  "file": "app/%5F_preview/[[...path]]/route.ts",