image2ppt 0.5.3 → 0.6.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 +175 -13
- package/dist/client.d.ts +80 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +424 -54
- package/dist/client.js.map +1 -1
- package/dist/compress.d.ts +3 -3
- package/dist/compress.d.ts.map +1 -1
- package/dist/compress.js +7 -5
- package/dist/compress.js.map +1 -1
- package/dist/errors.d.ts +118 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +150 -18
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +23 -5
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +51 -10
- package/dist/limits.js.map +1 -1
- package/dist/pages.d.ts +47 -0
- package/dist/pages.d.ts.map +1 -0
- package/dist/pages.js +90 -0
- package/dist/pages.js.map +1 -0
- package/dist/types.d.ts +122 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +87 -2
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/webhook.d.ts +75 -0
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +182 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +1 -1
package/dist/errors.js.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAM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AAE,gBAAgB;CACtB,CAAC;AAEF,wDAAwD;AACxD,MAAM,UAAU,YAAY,CAAC,IAM5B;IACC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAC9D,IAAI,GAAmB,CAAC;IACxB,IAAI,UAAU,KAAK,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, 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
|
|
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, PageStatus, SubmitAllOptions, SubmitOptions, WaitOptions, } from "./types.js";
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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,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,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, 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,
|
|
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,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
|
|
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
|
|
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
|
-
* @
|
|
98
|
-
*
|
|
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
|
*
|
package/dist/limits.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH;;;;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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,SAAI,EACZ,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACpB,IAAI,CAkBN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAmB9F;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
|
|
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 =
|
|
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 =
|
|
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 "
|
|
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
|
|
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
|
-
* @
|
|
100
|
-
*
|
|
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 (
|
|
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 ` +
|
package/dist/limits.js.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE3E;;;;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,IA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C,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"}
|
package/dist/pages.d.ts
ADDED
|
@@ -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,CA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,GAAG,CAAC,CAAC,CAAC;IAC5B,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,oBAAoB,CAC5B,SAAS,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,4CAA4C,EAC1E,EAAE,IAAI,EAAE,oBAAoB,EAAE,CAC/B,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,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
|
-
/**
|
|
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,8 @@ export interface ClientOptions {
|
|
|
115
140
|
*/
|
|
116
141
|
warnOnDeprecated?: boolean;
|
|
117
142
|
}
|
|
118
|
-
|
|
143
|
+
/** Options every kind of submission takes, including the batch calls. */
|
|
144
|
+
export interface SubmitAllOptions {
|
|
119
145
|
/**
|
|
120
146
|
* Language of the **generated deck**: `zh-CN` (default) or `en`.
|
|
121
147
|
*
|
|
@@ -125,6 +151,33 @@ export interface SubmitOptions {
|
|
|
125
151
|
locale?: Locale;
|
|
126
152
|
/** `auto` (default) / `16:9` / `4:3`. */
|
|
127
153
|
aspectRatio?: AspectRatio;
|
|
154
|
+
/**
|
|
155
|
+
* An `https` URL the service POSTs to when the job ends. Check each delivery with
|
|
156
|
+
* `verifyWebhook`. With `submitAll`, every batch's job calls it.
|
|
157
|
+
*/
|
|
158
|
+
callbackUrl?: string;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Options for one submission (`submit`, `submitUrls`, `convert`).
|
|
162
|
+
*
|
|
163
|
+
* `pages` and `idempotencyKey` exist only here, not on `SubmitAllOptions`: page
|
|
164
|
+
* numbers run across one submission and a key names one job, so neither can span
|
|
165
|
+
* the several batches `submitAll` makes.
|
|
166
|
+
*/
|
|
167
|
+
export interface SubmitOptions extends SubmitAllOptions {
|
|
168
|
+
/**
|
|
169
|
+
* Convert only these pages, e.g. `"1-3, 7"`. Page numbers run across the whole
|
|
170
|
+
* submission in order — an image is one page, a PDF its page count — so with a
|
|
171
|
+
* single PDF they are the PDF's own. Only the selected pages are charged and count
|
|
172
|
+
* towards the 50-page limit; the PDF itself may be longer.
|
|
173
|
+
*/
|
|
174
|
+
pages?: string;
|
|
175
|
+
/**
|
|
176
|
+
* 1–255 printable ASCII characters. Default: a random UUID per call. Pass your own
|
|
177
|
+
* to make resubmitting safe across calls or processes — e.g. an id from your own
|
|
178
|
+
* database.
|
|
179
|
+
*/
|
|
180
|
+
idempotencyKey?: string;
|
|
128
181
|
}
|
|
129
182
|
export interface WaitOptions {
|
|
130
183
|
/** Initial poll interval in ms (default 5000), backs off to 15000. */
|
|
@@ -133,6 +186,17 @@ export interface WaitOptions {
|
|
|
133
186
|
timeoutMs?: number;
|
|
134
187
|
}
|
|
135
188
|
export type ConvertOptions = SubmitOptions & WaitOptions;
|
|
189
|
+
export type ConvertAllOptions = SubmitAllOptions & WaitOptions;
|
|
190
|
+
export interface ListJobsOptions {
|
|
191
|
+
/** `YYYY-MM-DD` in UTC, inclusive. */
|
|
192
|
+
createdFrom?: string;
|
|
193
|
+
/** `YYYY-MM-DD` in UTC, inclusive. */
|
|
194
|
+
createdTo?: string;
|
|
195
|
+
/** Jobs per page, 1–100 (default 20). */
|
|
196
|
+
limit?: number;
|
|
197
|
+
/** `nextCursor` from the previous page, passed back unchanged. */
|
|
198
|
+
cursor?: string;
|
|
199
|
+
}
|
|
136
200
|
export interface Account {
|
|
137
201
|
email: string;
|
|
138
202
|
credits: number;
|
|
@@ -175,6 +239,34 @@ export interface CancellationResult {
|
|
|
175
239
|
* costs nothing, and `getJob` is the authority on when the job is really terminal.
|
|
176
240
|
*/
|
|
177
241
|
export declare function parseCancellationResult(data: unknown): CancellationResult;
|
|
242
|
+
/** A whole number: `3` and `3.0` count, `"3"`, `true` and `1.5` do not. */
|
|
243
|
+
export declare function wholeNumber(value: unknown): number | null;
|
|
244
|
+
/**
|
|
245
|
+
* How delivering the completion callback is going (only for jobs submitted with
|
|
246
|
+
* `callbackUrl`).
|
|
247
|
+
*
|
|
248
|
+
* `status` is `pending` (the job has not finished, or the next attempt is
|
|
249
|
+
* scheduled), `delivered`, or `failed` (all 6 attempts failed; no more retries).
|
|
250
|
+
* `lastResponseStatus` is `null` for a network error or timeout. Times are
|
|
251
|
+
* `YYYY-MM-DD HH:MM:SS` in UTC, or `null`.
|
|
252
|
+
*
|
|
253
|
+
* Read leniently, like `PageError`: this is a report on a side channel, and a
|
|
254
|
+
* surprise inside it should not cost you the job it is attached to. A field of the
|
|
255
|
+
* wrong type reads as `null`; the original is on `raw`.
|
|
256
|
+
*/
|
|
257
|
+
export declare class CallbackStatus {
|
|
258
|
+
readonly url: string | null;
|
|
259
|
+
/** `pending` | `delivered` | `failed`. */
|
|
260
|
+
readonly status: string | null;
|
|
261
|
+
readonly attempts: number | null;
|
|
262
|
+
readonly lastAttemptAt: string | null;
|
|
263
|
+
readonly lastResponseStatus: number | null;
|
|
264
|
+
readonly nextAttemptAt: string | null;
|
|
265
|
+
readonly raw: Record<string, unknown>;
|
|
266
|
+
constructor(data: Record<string, unknown>);
|
|
267
|
+
/** Build it from a `callback` value, or return null for anything but an object. */
|
|
268
|
+
static fromJson(value: unknown): CallbackStatus | null;
|
|
269
|
+
}
|
|
178
270
|
/** A snapshot of a conversion job's state. */
|
|
179
271
|
export declare class Job {
|
|
180
272
|
readonly jobId: string;
|
|
@@ -215,6 +307,15 @@ export declare class Job {
|
|
|
215
307
|
* which is the confusion `null` exists to prevent.
|
|
216
308
|
*/
|
|
217
309
|
readonly pageResults: PageResult[] | null;
|
|
310
|
+
/** Delivery of the completion callback; `null` unless submitted with `callbackUrl`. */
|
|
311
|
+
readonly callback: CallbackStatus | null;
|
|
312
|
+
/**
|
|
313
|
+
* True when `submit` got this job back from an earlier request with the same
|
|
314
|
+
* `Idempotency-Key` (response header `Idempotent-Replayed: true`) instead of
|
|
315
|
+
* creating it now. Nothing was charged for the replay. Set by the client after
|
|
316
|
+
* construction, since it comes from a header rather than the body.
|
|
317
|
+
*/
|
|
318
|
+
replayed: boolean;
|
|
218
319
|
/** Raw response body, for forward-compatible access to new fields. */
|
|
219
320
|
readonly raw: Record<string, unknown>;
|
|
220
321
|
constructor(data: Record<string, unknown>);
|
|
@@ -226,4 +327,23 @@ export declare class Job {
|
|
|
226
327
|
get isTerminal(): boolean;
|
|
227
328
|
static fromJson(data: Record<string, unknown>): Job;
|
|
228
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* One page of `listJobs`: API-submitted jobs, newest first.
|
|
332
|
+
*
|
|
333
|
+
* Each job in `data` has the same shape as `getJob` returns, minus `pageResults`.
|
|
334
|
+
* `nextCursor` is `null` on the last page; otherwise pass it back as `cursor`
|
|
335
|
+
* unchanged. For reconciliation, add up each job's `creditsUsed` (charged) and
|
|
336
|
+
* `creditsRefunded`.
|
|
337
|
+
*/
|
|
338
|
+
export declare class JobList {
|
|
339
|
+
readonly data: Job[];
|
|
340
|
+
readonly nextCursor: string | null;
|
|
341
|
+
readonly raw: Record<string, unknown>;
|
|
342
|
+
/**
|
|
343
|
+
* `nextCursor` that is missing or not a string reads as the last page: an
|
|
344
|
+
* unreadable cursor could not be passed back anyway, and stopping is the answer
|
|
345
|
+
* that cannot loop forever.
|
|
346
|
+
*/
|
|
347
|
+
constructor(data: unknown);
|
|
348
|
+
}
|
|
229
349
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAItC,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AACpC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAClD,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAItC,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AACpC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAClD,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,C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