image2ppt 0.5.3 → 0.7.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.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,wCAAwC;AACxC,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,UAAU,CAAU;IACpB,IAAI,CAAU;IACvB;;;;;;OAMG;IACH,aAAa,GAAU,EAAE,CAAC;IAE1B,YAAY,OAAe,EAAE,OAAkB,EAAE;QAC/C,KAAK,CAAC,OAAO,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACpE,2EAA2E;QAC3E,8BAA8B;QAC9B,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,UAAU,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC;IAC3D,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IACpD,IAAa,WAAW;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,eAAgB,SAAQ,kBAAkB;IACrD;;;;;OAKG;IACH,YAAY,OAAe,EAAE,OAAkB,EAAE;QAC/C,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;CACF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AAK,GAAG,EAAE,CAAC;QACvB,GAAG,GAAG,IAAI,gBAAgB,CAAC,OAAO,EAAE;YAClC,UAAU,EAAE,GAAG;YACf,IAAI,EAAE,IAAI,IAAI,cAAc;YAC5B,UAAU;SACX,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,IAAI,KAAK,6BAA6B,EAAE,CAAC;QAClD,GAAG,GAAG,IAAI,6BAA6B,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;IACrF,CAAC;SAAM,CAAC;QACN,8EAA8E;QAC9E,iFAAiF;QACjF,gFAAgF;QAChF,mEAAmE;QACnE,MAAM,GAAG,GACP,CAAC,IAAI,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;YAC7B,eAAe,CAAC,UAAU,CAAC;YAC3B,CAAC,UAAU,IAAI,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;QACrD,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;IAClB,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/index.d.ts CHANGED
@@ -15,10 +15,12 @@
15
15
  */
16
16
  export { DEFAULT_BASE_URL, Image2PPTClient } from "./client.js";
17
17
  export { VERSION } from "./version.js";
18
- export { APIConnectionError, APITimeoutError, AuthenticationError, Image2PPTError, Image2PPTTimeoutError, InsufficientCreditsError, InvalidAspectRatioError, InvalidFileError, JobAlreadyFinishedError, JobCancelledError, JobFailedError, JobNotFoundError, MalformedResponseError, MalformedUploadError, NoFilesError, NotReadyError, OutputExpiredError, PageRateExceededError, RateLimitedError, ServerError, TooManySlidesError, UploadAbortedError, } from "./errors.js";
18
+ export { APIConnectionError, APITimeoutError, AuthenticationError, IdempotencyKeyInProgressError, IdempotencyKeyMismatchError, Image2PPTError, Image2PPTTimeoutError, InsufficientCreditsError, InvalidAspectRatioError, InvalidCallbackUrlError, InvalidFileError, InvalidIdempotencyKeyError, InvalidNameError, InvalidPagesError, InvalidParameterError, InvalidUrlError, JobAlreadyFinishedError, JobCancelledError, JobFailedError, JobNotFoundError, MalformedResponseError, MalformedUploadError, NoFilesError, NotReadyError, OutputExpiredError, PageRateExceededError, PagesOutOfRangeError, RateLimitedError, ServerError, TooManySlidesError, UploadAbortedError, UrlFetchFailedError, WebhookVerificationError, } from "./errors.js";
19
19
  export type { ErrorInit } from "./errors.js";
20
- export { BATCH_TARGET_BYTES, MAX_FILE_BYTES, MAX_PAGES_PER_JOB, MAX_UPLOAD_BYTES, checkFileSize, checkSubmission, planBatches, } from "./limits.js";
20
+ export { BATCH_TARGET_BYTES, MAX_FILE_BYTES, MAX_PAGES_PER_JOB, MAX_UPLOAD_BYTES, checkFileSize, checkPageSelection, checkSubmission, planBatches, } from "./limits.js";
21
21
  export type { UploadItem } from "./limits.js";
22
- export { Job, PageError, PageResult } from "./types.js";
23
- export type { Account, AspectRatio, CancellationResult, ClientOptions, ConvertOptions, JobError, JobStatus, Locale, PageStatus, SubmitOptions, WaitOptions, } from "./types.js";
22
+ export { CallbackStatus, Job, JobList, PageError, PageResult } from "./types.js";
23
+ export { WebhookEvent, verifyWebhook } from "./webhook.js";
24
+ export type { VerifyWebhookOptions, WebhookHeaders } from "./webhook.js";
25
+ export type { Account, AspectRatio, CancellationResult, ClientOptions, ConvertAllOptions, ConvertOptions, JobError, ListJobsOptions, JobStatus, Locale, PageProgress, PageStatus, SubmitAllOptions, SubmitOptions, WaitOptions, } from "./types.js";
24
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EACV,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,QAAQ,EACR,SAAS,EACT,MAAM,EACN,UAAU,EACV,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,6BAA6B,EAC7B,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACzE,YAAY,EACV,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,eAAe,EACf,SAAS,EACT,MAAM,EACN,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -15,7 +15,8 @@
15
15
  */
16
16
  export { DEFAULT_BASE_URL, Image2PPTClient } from "./client.js";
17
17
  export { VERSION } from "./version.js";
18
- export { APIConnectionError, APITimeoutError, AuthenticationError, Image2PPTError, Image2PPTTimeoutError, InsufficientCreditsError, InvalidAspectRatioError, InvalidFileError, JobAlreadyFinishedError, JobCancelledError, JobFailedError, JobNotFoundError, MalformedResponseError, MalformedUploadError, NoFilesError, NotReadyError, OutputExpiredError, PageRateExceededError, RateLimitedError, ServerError, TooManySlidesError, UploadAbortedError, } from "./errors.js";
19
- export { BATCH_TARGET_BYTES, MAX_FILE_BYTES, MAX_PAGES_PER_JOB, MAX_UPLOAD_BYTES, checkFileSize, checkSubmission, planBatches, } from "./limits.js";
20
- export { Job, PageError, PageResult } from "./types.js";
18
+ export { APIConnectionError, APITimeoutError, AuthenticationError, IdempotencyKeyInProgressError, IdempotencyKeyMismatchError, Image2PPTError, Image2PPTTimeoutError, InsufficientCreditsError, InvalidAspectRatioError, InvalidCallbackUrlError, InvalidFileError, InvalidIdempotencyKeyError, InvalidNameError, InvalidPagesError, InvalidParameterError, InvalidUrlError, JobAlreadyFinishedError, JobCancelledError, JobFailedError, JobNotFoundError, MalformedResponseError, MalformedUploadError, NoFilesError, NotReadyError, OutputExpiredError, PageRateExceededError, PagesOutOfRangeError, RateLimitedError, ServerError, TooManySlidesError, UploadAbortedError, UrlFetchFailedError, WebhookVerificationError, } from "./errors.js";
19
+ export { BATCH_TARGET_BYTES, MAX_FILE_BYTES, MAX_PAGES_PER_JOB, MAX_UPLOAD_BYTES, checkFileSize, checkPageSelection, checkSubmission, planBatches, } from "./limits.js";
20
+ export { CallbackStatus, Job, JobList, PageError, PageResult } from "./types.js";
21
+ export { WebhookEvent, verifyWebhook } from "./webhook.js";
21
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,6BAA6B,EAC7B,2BAA2B,EAC3B,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EAChB,0BAA0B,EAC1B,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
package/dist/limits.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Upload size limits and batch planning.
3
3
  *
4
- * The API caps the **file content of a single request** at 45MB. Going over that
4
+ * The API caps the **file content of a single request** at 90MB. Going over that
5
5
  * is not a friendly failure: the check can only run after the whole body has been
6
6
  * received, and the network layer in front of the API gives up on an oversized
7
7
  * request before it ever gets there — so a client that sends too much sees the
@@ -68,7 +68,7 @@ export declare function formatBytes(size: number): string;
68
68
  * Throw if one file is over the per-file cap, whatever else it travels with.
69
69
  *
70
70
  * Separate from `checkSubmission` because it is a property of the file, not of
71
- * the request: a 40MB PDF fits under the 45MB request cap and would sail through
71
+ * the request: a 40MB PDF fits under the 90MB request cap and would sail through
72
72
  * batch planning, then be rejected by the server every single time. Fail on it
73
73
  * locally instead of building a batch that can never succeed.
74
74
  *
@@ -94,12 +94,30 @@ export declare function checkFileSize(path: string, size: number): void;
94
94
  * @param imagePages Number of image files. Each is exactly 1 page.
95
95
  * @param pdfFiles Number of PDFs (or other files whose page count is unknown to
96
96
  * the client). Each counts as at least 1 page.
97
- * @throws TooManySlidesError The minimum page count already exceeds what one job
98
- * can hold.
97
+ * @param pages The `pages` selection, if any. **With a selection, the page limit
98
+ * applies to the pages selected, not to the files** — 60 images with
99
+ * `pages: "1-10"` is a 10-page job, and a PDF may itself run past 50 pages. See
100
+ * `checkPageSelection`.
101
+ * @throws TooManySlidesError The page count already exceeds what one job can hold.
102
+ * @throws InvalidPagesError / PagesOutOfRangeError See `checkPageSelection`.
99
103
  * @throws InvalidFileError File content over the per-request cap
100
104
  * (`code = "PAYLOAD_TOO_LARGE"`).
101
105
  */
102
- export declare function checkSubmission(totalBytes: number, imagePages: number, pdfFiles?: number): void;
106
+ export declare function checkSubmission(totalBytes: number, imagePages: number, pdfFiles?: number, pages?: string | null): void;
107
+ /**
108
+ * Throw if a `pages` selection is certain to be refused.
109
+ *
110
+ * Only what is certain: the spelling, page 0, a page past `totalPages` when the total
111
+ * is known (`undefined` when it is not — a PDF, or files behind `urls`), and more than
112
+ * `MAX_PAGES_PER_JOB` distinct pages selected. That last one fails whatever the files
113
+ * hold: either the pages exist and there are too many, or they do not. A blank or
114
+ * absent selection selects nothing and passes.
115
+ *
116
+ * @throws InvalidPagesError The spelling is wrong (`INVALID_PAGES`).
117
+ * @throws PagesOutOfRangeError Page 0, or past the known total (`PAGES_OUT_OF_RANGE`).
118
+ * @throws TooManySlidesError More than `MAX_PAGES_PER_JOB` pages selected.
119
+ */
120
+ export declare function checkPageSelection(pages: string | null | undefined, totalPages?: number): void;
103
121
  /**
104
122
  * Split files into batches that each fit in one submission.
105
123
  *
@@ -1 +1 @@
1
- {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAmB,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QAAmB,CAAC;AAEjD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,kBAAkB,QAAmB,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAS9D;AAED;;;;;;;;;;;;;;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mB9F;AAeD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,UAAU,EAAE,EAAE,CAsCvE"}
package/dist/limits.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Upload size limits and batch planning.
3
3
  *
4
- * The API caps the **file content of a single request** at 45MB. Going over that
4
+ * The API caps the **file content of a single request** at 90MB. Going over that
5
5
  * is not a friendly failure: the check can only run after the whole body has been
6
6
  * received, and the network layer in front of the API gives up on an oversized
7
7
  * request before it ever gets there — so a client that sends too much sees the
@@ -17,7 +17,8 @@
17
17
  * pages per job (`MAX_PAGES_PER_JOB`). `BATCH_TARGET_BYTES` is not a fourth cap — it
18
18
  * is how much `planBatches` puts in one batch, deliberately under the real one.
19
19
  */
20
- import { InvalidFileError, TooManySlidesError } from "./errors.js";
20
+ import { InvalidFileError, PagesOutOfRangeError, TooManySlidesError } from "./errors.js";
21
+ import { normalizePages, parsePages, selectedPageCount } from "./pages.js";
21
22
  /**
22
23
  * Server cap on **one** file. A file over this is rejected with `INVALID_FILE`
23
24
  * however it is submitted, so no amount of batching helps. Keep in sync with the
@@ -30,7 +31,7 @@ export const MAX_FILE_BYTES = 35 * 1024 * 1024;
30
31
  * (413 `PAYLOAD_TOO_LARGE`) — or, further up, cut off outright before the server can
31
32
  * answer at all. Keep in sync with the documented API contract.
32
33
  */
33
- export const MAX_UPLOAD_BYTES = 45 * 1024 * 1024;
34
+ export const MAX_UPLOAD_BYTES = 90 * 1024 * 1024;
34
35
  /**
35
36
  * Byte budget for one auto-planned batch. **A splitting budget, not a cap** — the cap
36
37
  * is `MAX_UPLOAD_BYTES`, and `checkSubmission` compares against that exactly.
@@ -43,7 +44,7 @@ export const MAX_UPLOAD_BYTES = 45 * 1024 * 1024;
43
44
  * count against the published limit, and a pre-flight that "leaves room" for framing
44
45
  * just makes the documented maximum unreachable.
45
46
  */
46
- export const BATCH_TARGET_BYTES = 40 * 1024 * 1024;
47
+ export const BATCH_TARGET_BYTES = 80 * 1024 * 1024;
47
48
  /**
48
49
  * Server cap on pages per job. An image is 1 page; a PDF counts as its own page
49
50
  * count. Keep in sync with the documented API contract.
@@ -52,7 +53,7 @@ export const MAX_PAGES_PER_JOB = 50;
52
53
  /** Format a byte count as MB, for human-readable error messages. */
53
54
  export function formatBytes(size) {
54
55
  // Stays honest below a megabyte. Rounding everything to MB makes a submission one
55
- // byte over the cap read as "45.0MB, over the 45.0MB limit (0.0MB too much)" — a
56
+ // byte over the cap read as "90.0MB, over the 90.0MB limit (0.0MB too much)" — a
56
57
  // message that contradicts itself and looks like the check is broken.
57
58
  if (size < 1024)
58
59
  return `${size}B`;
@@ -64,7 +65,7 @@ export function formatBytes(size) {
64
65
  * Throw if one file is over the per-file cap, whatever else it travels with.
65
66
  *
66
67
  * Separate from `checkSubmission` because it is a property of the file, not of
67
- * the request: a 40MB PDF fits under the 45MB request cap and would sail through
68
+ * the request: a 40MB PDF fits under the 90MB request cap and would sail through
68
69
  * batch planning, then be rejected by the server every single time. Fail on it
69
70
  * locally instead of building a batch that can never succeed.
70
71
  *
@@ -96,14 +97,23 @@ export function checkFileSize(path, size) {
96
97
  * @param imagePages Number of image files. Each is exactly 1 page.
97
98
  * @param pdfFiles Number of PDFs (or other files whose page count is unknown to
98
99
  * the client). Each counts as at least 1 page.
99
- * @throws TooManySlidesError The minimum page count already exceeds what one job
100
- * can hold.
100
+ * @param pages The `pages` selection, if any. **With a selection, the page limit
101
+ * applies to the pages selected, not to the files** — 60 images with
102
+ * `pages: "1-10"` is a 10-page job, and a PDF may itself run past 50 pages. See
103
+ * `checkPageSelection`.
104
+ * @throws TooManySlidesError The page count already exceeds what one job can hold.
105
+ * @throws InvalidPagesError / PagesOutOfRangeError See `checkPageSelection`.
101
106
  * @throws InvalidFileError File content over the per-request cap
102
107
  * (`code = "PAYLOAD_TOO_LARGE"`).
103
108
  */
104
- export function checkSubmission(totalBytes, imagePages, pdfFiles = 0) {
109
+ export function checkSubmission(totalBytes, imagePages, pdfFiles = 0, pages) {
105
110
  const minPages = imagePages + pdfFiles;
106
- if (minPages > MAX_PAGES_PER_JOB) {
111
+ if (normalizePages(pages) !== undefined) {
112
+ // Without PDFs every page is an image and the total is exact; with any, it is
113
+ // only known server-side.
114
+ checkPageSelection(pages, pdfFiles ? undefined : imagePages);
115
+ }
116
+ else if (minPages > MAX_PAGES_PER_JOB) {
107
117
  const counted = pdfFiles
108
118
  ? `${imagePages} images plus ${pdfFiles} ${pdfFiles === 1 ? "PDF" : "PDFs"} ` +
109
119
  `(at least 1 page each) is at least ${minPages} pages`
@@ -111,6 +121,37 @@ export function checkSubmission(totalBytes, imagePages, pdfFiles = 0) {
111
121
  throw new TooManySlidesError(`${counted} in one submission, over the ${MAX_PAGES_PER_JOB}-page-per-job ` +
112
122
  "limit; use submitAll() or convertAll() to split them into jobs automatically", { code: "TOO_MANY_SLIDES" });
113
123
  }
124
+ checkBytes(totalBytes);
125
+ }
126
+ /**
127
+ * Throw if a `pages` selection is certain to be refused.
128
+ *
129
+ * Only what is certain: the spelling, page 0, a page past `totalPages` when the total
130
+ * is known (`undefined` when it is not — a PDF, or files behind `urls`), and more than
131
+ * `MAX_PAGES_PER_JOB` distinct pages selected. That last one fails whatever the files
132
+ * hold: either the pages exist and there are too many, or they do not. A blank or
133
+ * absent selection selects nothing and passes.
134
+ *
135
+ * @throws InvalidPagesError The spelling is wrong (`INVALID_PAGES`).
136
+ * @throws PagesOutOfRangeError Page 0, or past the known total (`PAGES_OUT_OF_RANGE`).
137
+ * @throws TooManySlidesError More than `MAX_PAGES_PER_JOB` pages selected.
138
+ */
139
+ export function checkPageSelection(pages, totalPages) {
140
+ const selection = normalizePages(pages);
141
+ if (selection === undefined)
142
+ return;
143
+ const ranges = parsePages(selection);
144
+ if (totalPages !== undefined && Math.max(...ranges.map(([, end]) => end)) > totalPages) {
145
+ throw new PagesOutOfRangeError(`pages ${JSON.stringify(selection)} goes past the end of the submission, which has ` +
146
+ `${totalPages} ${totalPages === 1 ? "page" : "pages"}`, { code: "PAGES_OUT_OF_RANGE" });
147
+ }
148
+ const selected = selectedPageCount(ranges);
149
+ if (selected > MAX_PAGES_PER_JOB) {
150
+ throw new TooManySlidesError(`pages ${JSON.stringify(selection)} selects ${selected} pages, over the ` +
151
+ `${MAX_PAGES_PER_JOB}-page-per-job limit`, { code: "TOO_MANY_SLIDES" });
152
+ }
153
+ }
154
+ function checkBytes(totalBytes) {
114
155
  if (totalBytes > MAX_UPLOAD_BYTES) {
115
156
  throw new InvalidFileError(`these files add up to ${formatBytes(totalBytes)}, over the ` +
116
157
  `${formatBytes(MAX_UPLOAD_BYTES)} of file content one request may carry ` +
@@ -1 +1 @@
1
- {"version":3,"file":"limits.js","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAiBpC,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,kFAAkF;IAClF,iFAAiF;IACjF,sEAAsE;IACtE,IAAI,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,IAAI,GAAG,CAAC;IACnC,IAAI,IAAI,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,C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B,EAAE,CAAC;IAC/B,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,GAAG,EAAE,CAAC;YACb,YAAY,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,4EAA4E;QAC5E,kDAAkD;QAClD,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,KAAK,EAAE,CAAC;YACR,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YACrB,SAAS;QACX,CAAC;QACD,uEAAuE;QACvE,6EAA6E;QAC7E,2BAA2B;QAC3B,IACE,OAAO,CAAC,MAAM;YACd,CAAC,YAAY,GAAG,IAAI,CAAC,IAAI,GAAG,kBAAkB;gBAC5C,OAAO,CAAC,MAAM,GAAG,CAAC,GAAG,iBAAiB,CAAC,EACzC,CAAC;YACD,KAAK,EAAE,CAAC;QACV,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,KAAK,EAAE,CAAC;IACR,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Local reading of the `pages` selection, e.g. `"1-3, 7"`.
3
+ *
4
+ * The API picks pages out of the whole submission laid end to end (an image is one
5
+ * page, a PDF is its own page count). This module only answers what can be known
6
+ * without the files: whether the spelling is valid, and how many pages it selects.
7
+ *
8
+ * **It must never refuse a selection the API would accept.** Every rule here is the
9
+ * contract's, and every one is pinned identically in the Python client, so a
10
+ * selection means the same thing to both. Digits are ASCII only.
11
+ */
12
+ /**
13
+ * Longest `pages` value the API accepts. Measured in UTF-16 units here and in
14
+ * characters by the Python client; the two only differ for characters outside the
15
+ * Basic Multilingual Plane, and any such character is a spelling error on both sides
16
+ * anyway.
17
+ */
18
+ export declare const MAX_PAGES_LENGTH = 1000;
19
+ export type PageRanges = Array<[number, number]>;
20
+ /** Whether `text` is empty once surrounding whitespace is removed. */
21
+ export declare function isBlank(text: string): boolean;
22
+ /**
23
+ * Return `pages` if it selects anything, or undefined when it counts as not given.
24
+ *
25
+ * `undefined`, `null`, an empty string, and a string of nothing but whitespace all
26
+ * mean "no selection" to the service, so none of them is sent. Anything but a string
27
+ * is a caller mistake: sent as a form field it would silently become text, and in a
28
+ * JSON body it would be refused — the same call behaving two different ways.
29
+ */
30
+ export declare function normalizePages(pages: unknown): string | undefined;
31
+ /**
32
+ * Parse a non-empty selection into `[start, end]` ranges, as written.
33
+ *
34
+ * @throws InvalidPagesError The spelling is wrong (`INVALID_PAGES`). Every token is
35
+ * checked for spelling before any range is, so `"0,abc"` is a spelling error, as it
36
+ * is to the service.
37
+ * @throws PagesOutOfRangeError A page number is 0 (`PAGES_OUT_OF_RANGE`).
38
+ */
39
+ export declare function parsePages(pages: string): PageRanges;
40
+ /**
41
+ * How many distinct pages the ranges select, overlaps counted once.
42
+ *
43
+ * Counted by merging, never by expanding: `"1-1000000000000"` is a valid spelling,
44
+ * and listing it out would be a very long wait for the answer "too many".
45
+ */
46
+ export declare function selectedPageCount(ranges: PageRanges): number;
47
+ //# sourceMappingURL=pages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../src/pages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAIrC,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEjD,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMjE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAgCpD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAS5D"}
package/dist/pages.js ADDED
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Local reading of the `pages` selection, e.g. `"1-3, 7"`.
3
+ *
4
+ * The API picks pages out of the whole submission laid end to end (an image is one
5
+ * page, a PDF is its own page count). This module only answers what can be known
6
+ * without the files: whether the spelling is valid, and how many pages it selects.
7
+ *
8
+ * **It must never refuse a selection the API would accept.** Every rule here is the
9
+ * contract's, and every one is pinned identically in the Python client, so a
10
+ * selection means the same thing to both. Digits are ASCII only.
11
+ */
12
+ import { InvalidPagesError, PagesOutOfRangeError } from "./errors.js";
13
+ /**
14
+ * Longest `pages` value the API accepts. Measured in UTF-16 units here and in
15
+ * characters by the Python client; the two only differ for characters outside the
16
+ * Basic Multilingual Plane, and any such character is a spelling error on both sides
17
+ * anyway.
18
+ */
19
+ export const MAX_PAGES_LENGTH = 1000;
20
+ const TOKEN = /^(\d+)(?:\s*-\s*(\d+))?$/;
21
+ /** Whether `text` is empty once surrounding whitespace is removed. */
22
+ export function isBlank(text) {
23
+ return text.trim() === "";
24
+ }
25
+ /**
26
+ * Return `pages` if it selects anything, or undefined when it counts as not given.
27
+ *
28
+ * `undefined`, `null`, an empty string, and a string of nothing but whitespace all
29
+ * mean "no selection" to the service, so none of them is sent. Anything but a string
30
+ * is a caller mistake: sent as a form field it would silently become text, and in a
31
+ * JSON body it would be refused — the same call behaving two different ways.
32
+ */
33
+ export function normalizePages(pages) {
34
+ if (pages == null)
35
+ return undefined;
36
+ if (typeof pages !== "string") {
37
+ throw new TypeError(`pages must be a string like '1-3,7', not ${typeof pages}`);
38
+ }
39
+ return isBlank(pages) ? undefined : pages;
40
+ }
41
+ /**
42
+ * Parse a non-empty selection into `[start, end]` ranges, as written.
43
+ *
44
+ * @throws InvalidPagesError The spelling is wrong (`INVALID_PAGES`). Every token is
45
+ * checked for spelling before any range is, so `"0,abc"` is a spelling error, as it
46
+ * is to the service.
47
+ * @throws PagesOutOfRangeError A page number is 0 (`PAGES_OUT_OF_RANGE`).
48
+ */
49
+ export function parsePages(pages) {
50
+ // Measured after trimming: surrounding whitespace is not part of the value.
51
+ const length = pages.trim().length;
52
+ if (length > MAX_PAGES_LENGTH) {
53
+ throw new InvalidPagesError(`pages is ${length} characters long, over the ${MAX_PAGES_LENGTH} allowed`, { code: "INVALID_PAGES" });
54
+ }
55
+ const ranges = [];
56
+ for (const rawToken of pages.split(",")) {
57
+ const match = TOKEN.exec(rawToken.trim());
58
+ const start = match ? Number(match[1]) : 0;
59
+ const end = match && match[2] !== undefined ? Number(match[2]) : start;
60
+ // 2**53 - 1 is the largest page number the API accepts; past it the answer is
61
+ // INVALID_PAGES, not an out-of-range page — so it is here too.
62
+ if (!match || !Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start > end) {
63
+ throw new InvalidPagesError(`pages ${JSON.stringify(pages)} is not a valid selection: write single pages or ` +
64
+ "start-end ranges separated by commas, e.g. '1-3, 7'", { code: "INVALID_PAGES" });
65
+ }
66
+ ranges.push([start, end]);
67
+ }
68
+ if (ranges.some(([start]) => start < 1)) {
69
+ throw new PagesOutOfRangeError(`pages ${JSON.stringify(pages)} selects page 0; pages are numbered from 1`, { code: "PAGES_OUT_OF_RANGE" });
70
+ }
71
+ return ranges;
72
+ }
73
+ /**
74
+ * How many distinct pages the ranges select, overlaps counted once.
75
+ *
76
+ * Counted by merging, never by expanding: `"1-1000000000000"` is a valid spelling,
77
+ * and listing it out would be a very long wait for the answer "too many".
78
+ */
79
+ export function selectedPageCount(ranges) {
80
+ let count = 0;
81
+ let coveredTo = 0;
82
+ for (const [start, end] of [...ranges].sort((a, b) => a[0] - b[0] || a[1] - b[1])) {
83
+ if (end <= coveredTo)
84
+ continue;
85
+ count += end - Math.max(start, coveredTo + 1) + 1;
86
+ coveredTo = end;
87
+ }
88
+ return count;
89
+ }
90
+ //# sourceMappingURL=pages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pages.js","sourceRoot":"","sources":["../src/pages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,MAAM,KAAK,GAAG,0BAA0B,CAAC;AAIzC,sEAAsE;AACtE,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,SAAS,CAAC,4CAA4C,OAAO,KAAK,EAAE,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,4EAA4E;IAC5E,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC;IACnC,IAAI,MAAM,GAAG,gBAAgB,EAAE,CAAC;QAC9B,MAAM,IAAI,iBAAiB,CACzB,YAAY,MAAM,8BAA8B,gBAAgB,UAAU,EAC1E,EAAE,IAAI,EAAE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AAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAkB;IAClD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAClF,IAAI,GAAG,IAAI,SAAS;YAAE,SAAS;QAC/B,KAAK,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAClD,SAAS,GAAG,GAAG,CAAC;IAClB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/types.d.ts CHANGED
@@ -11,6 +11,26 @@ export type JobStatus = "pending" | "processing" | "completed" | "failed";
11
11
  * would be worse than seeing it.
12
12
  */
13
13
  export type PageStatus = "converted" | "failed";
14
+ /**
15
+ * A response envelope as an object, with every field the contract guarantees.
16
+ *
17
+ * One helper for all three envelopes — a job, a cancellation result, a page entry.
18
+ * The check used to be hand-written at each of them, and the copies drifted apart
19
+ * from each other and from the Python client's, which is exactly the kind of
20
+ * disagreement two clients for one API cannot afford.
21
+ *
22
+ * **A field counts as missing when the key is absent or its value is null.** The
23
+ * two mean the same thing to a caller: there is no value to act on.
24
+ *
25
+ * The test is `== null`, which catches null and undefined and nothing else. A
26
+ * falsiness test would look almost identical and be wrong: `cancellationRequested`
27
+ * and `finalizing` are booleans whose `false` is a real answer the service sends,
28
+ * and rejecting it would fail the response that says "no, the job is not still
29
+ * winding down".
30
+ *
31
+ * `what` names the envelope for the message ("job response").
32
+ */
33
+ export declare function isJsonObject(value: unknown): value is Record<string, any>;
14
34
  export interface JobError {
15
35
  /**
16
36
  * Job-level failure reason: `JOB_CANCELLED` or `CONVERSION_FAILED`.
@@ -55,7 +75,12 @@ export declare class PageError {
55
75
  }
56
76
  /** What happened to one page of the deck. */
57
77
  export declare class PageResult {
58
- /** 1-based, in the order the pages were submitted (a PDF follows its own page order). */
78
+ /**
79
+ * 1-based, and counts **pages of the delivered deck**. Without `pages` that is the
80
+ * order the files were submitted in (a PDF follows its own page order). With
81
+ * `pages` it is the k-th *selected* page, not the page number you selected:
82
+ * `pages: "3,7"` gives entries 1 and 2.
83
+ */
59
84
  readonly pageNumber: number;
60
85
  /** `converted` or `failed`; an unrecognised value is passed through as-is. */
61
86
  readonly status: PageStatus;
@@ -115,7 +140,10 @@ export interface ClientOptions {
115
140
  */
116
141
  warnOnDeprecated?: boolean;
117
142
  }
118
- export interface SubmitOptions {
143
+ /** Options every kind of submission takes, including the batch calls. */
144
+ export interface SubmitAllOptions {
145
+ /** Task and download filename without `.pptx`; the service resolves collisions. */
146
+ name?: string;
119
147
  /**
120
148
  * Language of the **generated deck**: `zh-CN` (default) or `en`.
121
149
  *
@@ -125,14 +153,63 @@ export interface SubmitOptions {
125
153
  locale?: Locale;
126
154
  /** `auto` (default) / `16:9` / `4:3`. */
127
155
  aspectRatio?: AspectRatio;
156
+ /**
157
+ * An `https` URL the service POSTs to when the job ends. Check each delivery with
158
+ * `verifyWebhook`. With `submitAll`, every batch's job calls it.
159
+ */
160
+ callbackUrl?: string;
161
+ }
162
+ /**
163
+ * Options for one submission (`submit`, `submitUrls`, `convert`).
164
+ *
165
+ * `pages` and `idempotencyKey` exist only here, not on `SubmitAllOptions`: page
166
+ * numbers run across one submission and a key names one job, so neither can span
167
+ * the several batches `submitAll` makes.
168
+ */
169
+ export interface SubmitOptions extends SubmitAllOptions {
170
+ /**
171
+ * Convert only these pages, e.g. `"1-3, 7"`. Page numbers run across the whole
172
+ * submission in order — an image is one page, a PDF its page count — so with a
173
+ * single PDF they are the PDF's own. Only the selected pages are charged and count
174
+ * towards the 50-page limit; the PDF itself may be longer.
175
+ */
176
+ pages?: string;
177
+ /**
178
+ * 1–255 printable ASCII characters. Default: a random UUID per call. Pass your own
179
+ * to make resubmitting safe across calls or processes — e.g. an id from your own
180
+ * database.
181
+ */
182
+ idempotencyKey?: string;
128
183
  }
129
184
  export interface WaitOptions {
130
185
  /** Initial poll interval in ms (default 5000), backs off to 15000. */
131
186
  pollIntervalMs?: number;
132
187
  /** Overall wait cap in ms (default 1_800_000 = 30 min). */
133
188
  timeoutMs?: number;
189
+ /**
190
+ * Called as `onProgress(job, elapsedMs)` after every successful poll, the final
191
+ * one included — so a completed job reports `progress === 100` before `wait`
192
+ * resolves. `job` is the fresh snapshot (`job.progress` is 0–100, or `null` if
193
+ * the service did not report it); `elapsedMs` is milliseconds since this `wait`
194
+ * call started. Polls that failed and are being retried do not call it. A
195
+ * returned promise is awaited before the next poll; anything it throws (or
196
+ * rejects with) ends the wait. In `convertAll` it is called for each job in turn
197
+ * — tell them apart by `job.jobId`; `elapsedMs` restarts at zero for each job.
198
+ */
199
+ onProgress?: (job: Job, elapsedMs: number) => void | Promise<void>;
134
200
  }
135
201
  export type ConvertOptions = SubmitOptions & WaitOptions;
202
+ export type ConvertAllOptions = SubmitAllOptions & WaitOptions;
203
+ export interface ListJobsOptions {
204
+ /** `YYYY-MM-DD` in UTC, inclusive. */
205
+ createdFrom?: string;
206
+ /** `YYYY-MM-DD` in UTC, inclusive. */
207
+ createdTo?: string;
208
+ /** Jobs per page, 1–100 (default 20). */
209
+ limit?: number;
210
+ /** `nextCursor` from the previous page, passed back unchanged. */
211
+ cursor?: string;
212
+ }
136
213
  export interface Account {
137
214
  email: string;
138
215
  credits: number;
@@ -175,9 +252,53 @@ export interface CancellationResult {
175
252
  * costs nothing, and `getJob` is the authority on when the job is really terminal.
176
253
  */
177
254
  export declare function parseCancellationResult(data: unknown): CancellationResult;
255
+ /** A whole number: `3` and `3.0` count, `"3"`, `true` and `1.5` do not. */
256
+ export declare function wholeNumber(value: unknown): number | null;
257
+ /** How far one page has got while the job is still running. */
258
+ export interface PageProgress {
259
+ /** 1-based, numbered like `PageResult.pageNumber`. */
260
+ readonly pageNumber: number;
261
+ /** 0–100. */
262
+ readonly progress: number;
263
+ /**
264
+ * A short human-readable line about what the page is doing right now, in the
265
+ * language of the client's `acceptLanguage` (English by default), or `null`.
266
+ * Show it as-is; its wording changes as the service changes, so never branch
267
+ * on it.
268
+ */
269
+ readonly stepLabel: string | null;
270
+ }
271
+ /**
272
+ * How delivering the completion callback is going (only for jobs submitted with
273
+ * `callbackUrl`).
274
+ *
275
+ * `status` is `pending` (the job has not finished, or the next attempt is
276
+ * scheduled), `delivered`, or `failed` (all 6 attempts failed; no more retries).
277
+ * `lastResponseStatus` is `null` for a network error or timeout. Times are
278
+ * `YYYY-MM-DD HH:MM:SS` in UTC, or `null`.
279
+ *
280
+ * Read leniently, like `PageError`: this is a report on a side channel, and a
281
+ * surprise inside it should not cost you the job it is attached to. A field of the
282
+ * wrong type reads as `null`; the original is on `raw`.
283
+ */
284
+ export declare class CallbackStatus {
285
+ readonly url: string | null;
286
+ /** `pending` | `delivered` | `failed`. */
287
+ readonly status: string | null;
288
+ readonly attempts: number | null;
289
+ readonly lastAttemptAt: string | null;
290
+ readonly lastResponseStatus: number | null;
291
+ readonly nextAttemptAt: string | null;
292
+ readonly raw: Record<string, unknown>;
293
+ constructor(data: Record<string, unknown>);
294
+ /** Build it from a `callback` value, or return null for anything but an object. */
295
+ static fromJson(value: unknown): CallbackStatus | null;
296
+ }
178
297
  /** A snapshot of a conversion job's state. */
179
298
  export declare class Job {
180
299
  readonly jobId: string;
300
+ /** Current resolved task name, or null when an older server does not send it. */
301
+ readonly name: string | null;
181
302
  readonly status: JobStatus;
182
303
  readonly slideCount: number | null;
183
304
  readonly progress: number | null;
@@ -215,6 +336,27 @@ export declare class Job {
215
336
  * which is the confusion `null` exists to prevent.
216
337
  */
217
338
  readonly pageResults: PageResult[] | null;
339
+ /** Delivery of the completion callback; `null` unless submitted with `callbackUrl`. */
340
+ readonly callback: CallbackStatus | null;
341
+ /**
342
+ * True when `submit` got this job back from an earlier request with the same
343
+ * `Idempotency-Key` (response header `Idempotent-Replayed: true`) instead of
344
+ * creating it now. Nothing was charged for the replay. Set by the client after
345
+ * construction, since it comes from a header rather than the body.
346
+ */
347
+ replayed: boolean;
348
+ /**
349
+ * While the job runs: seconds the service expects it still needs. `null` while
350
+ * no estimate is available yet, and once the job has ended.
351
+ */
352
+ readonly estimatedRemainingSeconds: number | null;
353
+ /** Jobs ahead of this one while it waits to start; `null` once it is running. */
354
+ readonly queueAhead: number | null;
355
+ /**
356
+ * Per-page progress while the job is `pending` / `processing`, one entry per
357
+ * page; `null` otherwise. `progress` is the whole job's figure.
358
+ */
359
+ readonly pageProgress: PageProgress[] | null;
218
360
  /** Raw response body, for forward-compatible access to new fields. */
219
361
  readonly raw: Record<string, unknown>;
220
362
  constructor(data: Record<string, unknown>);
@@ -226,4 +368,23 @@ export declare class Job {
226
368
  get isTerminal(): boolean;
227
369
  static fromJson(data: Record<string, unknown>): Job;
228
370
  }
371
+ /**
372
+ * One page of `listJobs`: API-submitted jobs, newest first.
373
+ *
374
+ * Each job in `data` has the same shape as `getJob` returns, minus `pageResults`.
375
+ * `nextCursor` is `null` on the last page; otherwise pass it back as `cursor`
376
+ * unchanged. For reconciliation, add up each job's `creditsUsed` (charged) and
377
+ * `creditsRefunded`.
378
+ */
379
+ export declare class JobList {
380
+ readonly data: Job[];
381
+ readonly nextCursor: string | null;
382
+ readonly raw: Record<string, unknown>;
383
+ /**
384
+ * `nextCursor` that is missing or not a string reads as the last page: an
385
+ * unreadable cursor could not be passed back anyway, and stopping is the answer
386
+ * that cannot loop forever.
387
+ */
388
+ constructor(data: unknown);
389
+ }
229
390
  //# sourceMappingURL=types.d.ts.map