image2ppt 0.5.3

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.
@@ -0,0 +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,CAAC,CAAC,CAAC,IAAI,CAAC;IAC/D,OAAO,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,IAAY;IACtD,IAAI,IAAI,GAAG,cAAc,EAAE,CAAC;QAC1B,MAAM,IAAI,gBAAgB,CACxB,IAAI,IAAI,QAAQ,WAAW,CAAC,IAAI,CAAC,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AG,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,229 @@
1
+ /** Shared types and the Job model. */
2
+ export type Locale = "zh-CN" | "en";
3
+ export type AspectRatio = "auto" | "16:9" | "4:3";
4
+ export type JobStatus = "pending" | "processing" | "completed" | "failed";
5
+ /**
6
+ * Outcome of a single page. `converted`: it became editable content.
7
+ * `failed`: it did not.
8
+ *
9
+ * A value this client does not recognise is passed through as it arrives rather
10
+ * than being folded into one of these — the service may add one, and losing it
11
+ * would be worse than seeing it.
12
+ */
13
+ export type PageStatus = "converted" | "failed";
14
+ export interface JobError {
15
+ /**
16
+ * Job-level failure reason: `JOB_CANCELLED` or `CONVERSION_FAILED`.
17
+ *
18
+ * These two are the whole set and are meant to stay that way — the finer
19
+ * reasons live per page, in `pageResults`. Treat a code you do not recognise
20
+ * as `CONVERSION_FAILED`.
21
+ */
22
+ code: string;
23
+ /**
24
+ * A sentence written for a person to read. Its language follows the client's
25
+ * `acceptLanguage` option. **Do not branch on it** — branch on `code`.
26
+ */
27
+ message: string;
28
+ }
29
+ /** Why one page did not convert. */
30
+ export declare class PageError {
31
+ /**
32
+ * Per-page failure reason. The contract's set is exactly `CONVERSION_FAILED`,
33
+ * `CONVERSION_TIMEOUT` and `PAGE_NOT_ATTEMPTED`; treat anything else as
34
+ * `CONVERSION_FAILED`.
35
+ *
36
+ * `PAGE_NOT_ATTEMPTED` is the one that changes what you do. That page never
37
+ * started and **is not in the delivered deck at all**. Every other failed page
38
+ * *is* in the deck — as the original image, not as editable content.
39
+ */
40
+ readonly code: string;
41
+ /**
42
+ * A sentence written for a person to read, in the language asked for by the
43
+ * client's `acceptLanguage`. **Do not branch on it** — branch on `code`.
44
+ */
45
+ readonly message: string;
46
+ /**
47
+ * Whether submitting the same image again could succeed. Every code the
48
+ * service returns today says true, but **branch on this field rather than
49
+ * hardcoding it**: a code added later may carry false.
50
+ */
51
+ readonly retryable: boolean;
52
+ /** Raw entry, for forward-compatible access to fields added later. */
53
+ readonly raw: Record<string, unknown>;
54
+ constructor(data: Record<string, unknown>);
55
+ }
56
+ /** What happened to one page of the deck. */
57
+ export declare class PageResult {
58
+ /** 1-based, in the order the pages were submitted (a PDF follows its own page order). */
59
+ readonly pageNumber: number;
60
+ /** `converted` or `failed`; an unrecognised value is passed through as-is. */
61
+ readonly status: PageStatus;
62
+ /** Present only when `status` is `failed`. */
63
+ readonly error?: PageError;
64
+ /** Raw entry, for forward-compatible access to fields added later. */
65
+ readonly raw: Record<string, unknown>;
66
+ constructor(data: Record<string, unknown>);
67
+ }
68
+ export interface ClientOptions {
69
+ /** Your API key (looks like `i2p_live_...`). */
70
+ apiKey: string;
71
+ /** Service base URL, defaults to `https://image2ppt.com`. */
72
+ baseUrl?: string;
73
+ /**
74
+ * How long one request may sit with **no data moving**, in ms (default 60000).
75
+ *
76
+ * An idle timeout, not a cap on how long a request may take: a 40MB upload or a
77
+ * large PPTX download that keeps making progress is never cut off, however long
78
+ * it runs in total. The clock only starts when nothing has been sent or received.
79
+ * Nothing at all for this long — including waiting for a response that never
80
+ * begins — throws `APITimeoutError`.
81
+ *
82
+ * This is one HTTP request, not the whole-job wait; that one is `WaitOptions`.
83
+ */
84
+ timeoutMs?: number;
85
+ /** Inject a custom fetch (for testing). Defaults to the global `fetch` (Node 18+). */
86
+ fetch?: typeof fetch;
87
+ /**
88
+ * Language for the **error messages** the service sends back, as an
89
+ * `Accept-Language` header value (e.g. `"zh-CN"`, `"fr, en;q=0.8"`). Sent
90
+ * verbatim on every request. Unset by default, and then no header is sent at
91
+ * all — which the service answers in English.
92
+ *
93
+ * **This is not `SubmitOptions.locale`, and the two are easy to confuse.**
94
+ * `locale` decides what language the generated PPTX is written in.
95
+ * `acceptLanguage` decides what language a failure is explained to *you* in.
96
+ * They are unrelated: you can ask for an English deck and Chinese errors. That
97
+ * is also why this is a free-form string rather than the `Locale` union — it is
98
+ * an HTTP header value, and the header's own syntax (several languages, quality
99
+ * weights) is what belongs in it.
100
+ *
101
+ * Either way, branch on `code`, never on `message`.
102
+ */
103
+ acceptLanguage?: string;
104
+ /**
105
+ * Total ms `submitAll` / `convertAll` may spend **waiting out rate limits** across
106
+ * the whole call (default 1_800_000 = 30 min). Only waiting counts against it — the
107
+ * time the uploads themselves take does not, so a slow link cannot quietly turn this
108
+ * into "do not wait at all". Submitting a large pile *will* hit the per-minute page
109
+ * quota, so waiting is the normal path, not an error.
110
+ */
111
+ rateLimitMaxWaitMs?: number;
112
+ /**
113
+ * When the service marks this SDK version deprecated, `console.warn` once.
114
+ * Default true. Set to false to silence it.
115
+ */
116
+ warnOnDeprecated?: boolean;
117
+ }
118
+ export interface SubmitOptions {
119
+ /**
120
+ * Language of the **generated deck**: `zh-CN` (default) or `en`.
121
+ *
122
+ * Not to be confused with the client-level `acceptLanguage`, which only sets
123
+ * what language error messages come back in.
124
+ */
125
+ locale?: Locale;
126
+ /** `auto` (default) / `16:9` / `4:3`. */
127
+ aspectRatio?: AspectRatio;
128
+ }
129
+ export interface WaitOptions {
130
+ /** Initial poll interval in ms (default 5000), backs off to 15000. */
131
+ pollIntervalMs?: number;
132
+ /** Overall wait cap in ms (default 1_800_000 = 30 min). */
133
+ timeoutMs?: number;
134
+ }
135
+ export type ConvertOptions = SubmitOptions & WaitOptions;
136
+ export interface Account {
137
+ email: string;
138
+ credits: number;
139
+ }
140
+ /**
141
+ * Result of requesting graceful cancellation for a conversion job.
142
+ *
143
+ * Cancellation is a graceful drain, not a hard stop: pages already running finish
144
+ * and are billed if they succeed, and **a page being dispatched at the very moment
145
+ * the request arrives may still run to completion and be billed** too. Pages that
146
+ * have not started are skipped and refunded. Repeating the call is safe.
147
+ */
148
+ export interface CancellationResult {
149
+ readonly jobId: string;
150
+ /** Whether the service accepted the cancellation request. */
151
+ readonly cancellationRequested: boolean;
152
+ /** True while the job is still winding down; keep polling `getJob` until terminal. */
153
+ readonly finalizing: boolean;
154
+ }
155
+ /**
156
+ * Read the three documented fields of a cancellation response.
157
+ *
158
+ * `CancellationResult` is an interface, so this is the shape check its two class
159
+ * siblings get in their constructors. Casting the body through instead would hand
160
+ * back `finalizing: undefined`, which reads as "settled" and stops a caller polling
161
+ * a job that is still draining.
162
+ *
163
+ * `false` is a real answer for both booleans and passes — see `requireFields`.
164
+ *
165
+ * Both are read by **identity, never truthiness** — the rule `PageError.retryable`
166
+ * already reads by. `[]` is truthy in JavaScript and falsy in Python, so a coerced
167
+ * field meant opposite things to the two clients for one API. Identity is the same
168
+ * test in both, and each field falls to the side that costs the caller nothing when
169
+ * the value cannot be read — which is why the two comparisons point opposite ways:
170
+ *
171
+ * - `cancellationRequested` needs a real `true`. Claiming a cancellation the service
172
+ * never accepted is the expensive mistake; repeating the call is safe.
173
+ * - `finalizing` needs a real `false` to mean settled — otherwise an unreadable
174
+ * value ends the wait exactly as the cast described above would. One more poll
175
+ * costs nothing, and `getJob` is the authority on when the job is really terminal.
176
+ */
177
+ export declare function parseCancellationResult(data: unknown): CancellationResult;
178
+ /** A snapshot of a conversion job's state. */
179
+ export declare class Job {
180
+ readonly jobId: string;
181
+ readonly status: JobStatus;
182
+ readonly slideCount: number | null;
183
+ readonly progress: number | null;
184
+ readonly creditsReserved: number | null;
185
+ readonly creditsUsed: number | null;
186
+ readonly creditsRefunded: number | null;
187
+ readonly createdAt: string | null;
188
+ readonly completedAt: string | null;
189
+ /** Optional in the public shape so pre-cancellation structural `Job` values still type-check. */
190
+ readonly cancellationRequested?: boolean;
191
+ readonly downloadUrl: string | null;
192
+ readonly error: JobError | null;
193
+ /**
194
+ * Per-page outcome, in page order, `slideCount` entries long — or `null`.
195
+ *
196
+ * That shape is what the API documents, and this client passes the ledger
197
+ * through as it arrived rather than cross-checking it against `slideCount`.
198
+ * Refusing a job over a ledger that did not add up would cost the caller a deck
199
+ * they can actually download, which is the worse trade. Check the length
200
+ * yourself if your own logic depends on it.
201
+ *
202
+ * `null` means the service did not send the field, which is a different fact
203
+ * from an empty array and must not be confused with one. It is absent while the
204
+ * job is still running (mid-run, "this page failed" and "this page has not had
205
+ * its turn" cannot be told apart), and absent for an early job that has no
206
+ * per-page record at all.
207
+ *
208
+ * `creditsRefunded` says how many pages did not convert; this says **which**,
209
+ * and whether each one still made it into the deck as its original image. See
210
+ * `PageError.code`.
211
+ *
212
+ * Declared required rather than optional (unlike `cancellationRequested`)
213
+ * precisely because absence is meaningful here: a third `undefined` state would
214
+ * make "the service didn't say" and "nobody filled this in" indistinguishable,
215
+ * which is the confusion `null` exists to prevent.
216
+ */
217
+ readonly pageResults: PageResult[] | null;
218
+ /** Raw response body, for forward-compatible access to new fields. */
219
+ readonly raw: Record<string, unknown>;
220
+ constructor(data: Record<string, unknown>);
221
+ /** Whether the job finished successfully (deliverable downloadable). */
222
+ get isCompleted(): boolean;
223
+ /** Whether the job failed. */
224
+ get isFailed(): boolean;
225
+ /** Whether the job reached a terminal state (completed or failed). */
226
+ get isTerminal(): boolean;
227
+ static fromJson(data: Record<string, unknown>): Job;
228
+ }
229
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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;AA0ChD,MAAM,WAAW,QAAQ;IACvB;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,oCAAoC;AACpC,qBAAa,SAAS;IACpB;;;;;;;;OAQG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAE1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAqB1C;AAED,6CAA6C;AAC7C,qBAAa,UAAU;IACrB,yFAAyF;IACzF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,8EAA8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E,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,GAAG;CAGpD"}
package/dist/types.js ADDED
@@ -0,0 +1,256 @@
1
+ /** Shared types and the Job model. */
2
+ import { MalformedResponseError } from "./errors.js";
3
+ /**
4
+ * A response envelope as an object, with every field the contract guarantees.
5
+ *
6
+ * One helper for all three envelopes — a job, a cancellation result, a page entry.
7
+ * The check used to be hand-written at each of them, and the copies drifted apart
8
+ * from each other and from the Python client's, which is exactly the kind of
9
+ * disagreement two clients for one API cannot afford.
10
+ *
11
+ * **A field counts as missing when the key is absent or its value is null.** The
12
+ * two mean the same thing to a caller: there is no value to act on.
13
+ *
14
+ * The test is `== null`, which catches null and undefined and nothing else. A
15
+ * falsiness test would look almost identical and be wrong: `cancellationRequested`
16
+ * and `finalizing` are booleans whose `false` is a real answer the service sends,
17
+ * and rejecting it would fail the response that says "no, the job is not still
18
+ * winding down".
19
+ *
20
+ * `what` names the envelope for the message ("job response").
21
+ */
22
+ function isJsonObject(value) {
23
+ return typeof value === "object" && value !== null && !Array.isArray(value);
24
+ }
25
+ function requireFields(data, keys, what) {
26
+ if (!isJsonObject(data)) {
27
+ throw new MalformedResponseError(`malformed ${what}, expected a JSON object`);
28
+ }
29
+ const d = data;
30
+ for (const key of keys) {
31
+ if (d[key] == null) {
32
+ throw new MalformedResponseError(`malformed ${what}, missing ${key}`);
33
+ }
34
+ }
35
+ return d;
36
+ }
37
+ /** Why one page did not convert. */
38
+ export class PageError {
39
+ /**
40
+ * Per-page failure reason. The contract's set is exactly `CONVERSION_FAILED`,
41
+ * `CONVERSION_TIMEOUT` and `PAGE_NOT_ATTEMPTED`; treat anything else as
42
+ * `CONVERSION_FAILED`.
43
+ *
44
+ * `PAGE_NOT_ATTEMPTED` is the one that changes what you do. That page never
45
+ * started and **is not in the delivered deck at all**. Every other failed page
46
+ * *is* in the deck — as the original image, not as editable content.
47
+ */
48
+ code;
49
+ /**
50
+ * A sentence written for a person to read, in the language asked for by the
51
+ * client's `acceptLanguage`. **Do not branch on it** — branch on `code`.
52
+ */
53
+ message;
54
+ /**
55
+ * Whether submitting the same image again could succeed. Every code the
56
+ * service returns today says true, but **branch on this field rather than
57
+ * hardcoding it**: a code added later may carry false.
58
+ */
59
+ retryable;
60
+ /** Raw entry, for forward-compatible access to fields added later. */
61
+ raw;
62
+ constructor(data) {
63
+ const d = data;
64
+ // Lenient on purpose: `pageResults` reports what went wrong, and a gap in the
65
+ // report is not itself worth turning into a thrown error the caller has to
66
+ // handle. Every rule below is pinned identically in the Python client — one
67
+ // body must not mean two different things depending on which SDK read it.
68
+ //
69
+ // A code has to be a non-empty string. An empty one names no failure, so it
70
+ // falls back the same way an unrecognised one does, which is the contract's
71
+ // own instruction to callers.
72
+ this.code = typeof d.code === "string" && d.code !== "" ? d.code : "CONVERSION_FAILED";
73
+ // A message has to be a string. A number is not turned into one: `42` is not a
74
+ // sentence anybody wants to show a person.
75
+ this.message = typeof d.message === "string" ? d.message : "";
76
+ // A real boolean, never truthiness. A flag we cannot read is not a licence to
77
+ // re-upload, so anything else — a missing field included — is false: telling a
78
+ // caller "try this page again" on a guess costs them credits, telling them
79
+ // "don't" costs them nothing they cannot recover by asking again themselves.
80
+ this.retryable = d.retryable === true;
81
+ this.raw = data;
82
+ }
83
+ }
84
+ /** What happened to one page of the deck. */
85
+ export class PageResult {
86
+ /** 1-based, in the order the pages were submitted (a PDF follows its own page order). */
87
+ pageNumber;
88
+ /** `converted` or `failed`; an unrecognised value is passed through as-is. */
89
+ status;
90
+ /** Present only when `status` is `failed`. */
91
+ error;
92
+ /** Raw entry, for forward-compatible access to fields added later. */
93
+ raw;
94
+ constructor(data) {
95
+ // `pageNumber` and `status` are guaranteed by the contract and are the two
96
+ // fields a caller has to have: without them an entry says nothing about which
97
+ // page it is or how that page ended. Their *types* are checked too rather than
98
+ // cast through — a page number of `"3"` would otherwise be quietly converted,
99
+ // covering up a wrong type instead of reporting it.
100
+ const d = requireFields(data, ["pageNumber", "status"], "pageResults entry");
101
+ // A whole number, not merely a finite one: pages are counted, and `1.5` names
102
+ // no page. `Number.isInteger` also rejects a numeric *string*, which is the
103
+ // half of this the Python client had to be brought into line with.
104
+ if (!Number.isInteger(d.pageNumber)) {
105
+ throw new MalformedResponseError(`malformed pageResults entry, pageNumber is not a number: ${JSON.stringify(d.pageNumber)}`);
106
+ }
107
+ if (typeof d.status !== "string") {
108
+ throw new MalformedResponseError(`malformed pageResults entry, status is not a string: ${JSON.stringify(d.status)}`);
109
+ }
110
+ this.pageNumber = d.pageNumber;
111
+ this.status = d.status;
112
+ // An `error` that is present but is not an object says nothing this model could
113
+ // report, so it reads as absent rather than throwing: the entry itself is what
114
+ // the contract guarantees, and a surprise *inside* `error` should not cost the
115
+ // caller the rest of the ledger. Building a fully-defaulted `PageError` from it
116
+ // instead would put a `CONVERSION_FAILED` on the page that nobody sent.
117
+ this.error = isJsonObject(d.error) ? new PageError(d.error) : undefined;
118
+ this.raw = data;
119
+ }
120
+ }
121
+ /**
122
+ * Read the three documented fields of a cancellation response.
123
+ *
124
+ * `CancellationResult` is an interface, so this is the shape check its two class
125
+ * siblings get in their constructors. Casting the body through instead would hand
126
+ * back `finalizing: undefined`, which reads as "settled" and stops a caller polling
127
+ * a job that is still draining.
128
+ *
129
+ * `false` is a real answer for both booleans and passes — see `requireFields`.
130
+ *
131
+ * Both are read by **identity, never truthiness** — the rule `PageError.retryable`
132
+ * already reads by. `[]` is truthy in JavaScript and falsy in Python, so a coerced
133
+ * field meant opposite things to the two clients for one API. Identity is the same
134
+ * test in both, and each field falls to the side that costs the caller nothing when
135
+ * the value cannot be read — which is why the two comparisons point opposite ways:
136
+ *
137
+ * - `cancellationRequested` needs a real `true`. Claiming a cancellation the service
138
+ * never accepted is the expensive mistake; repeating the call is safe.
139
+ * - `finalizing` needs a real `false` to mean settled — otherwise an unreadable
140
+ * value ends the wait exactly as the cast described above would. One more poll
141
+ * costs nothing, and `getJob` is the authority on when the job is really terminal.
142
+ */
143
+ export function parseCancellationResult(data) {
144
+ const d = requireFields(data, ["jobId", "cancellationRequested", "finalizing"], "cancellation response");
145
+ return {
146
+ jobId: d.jobId,
147
+ cancellationRequested: d.cancellationRequested === true,
148
+ finalizing: d.finalizing !== false,
149
+ };
150
+ }
151
+ /**
152
+ * `pageResults` as a list, or `null` when the response did not carry the field.
153
+ *
154
+ * The `?? null` the other optional Job fields use, except that a value which *is*
155
+ * there has to be the shape the contract promises — an array of entries — because
156
+ * unlike a missing credit count, a mangled ledger would be read as a real answer
157
+ * about which pages made it into the deck.
158
+ */
159
+ function parsePageResults(value) {
160
+ if (value == null)
161
+ return null;
162
+ if (!Array.isArray(value)) {
163
+ throw new MalformedResponseError("malformed job response, pageResults is not a list");
164
+ }
165
+ return value.map((entry) => new PageResult(entry));
166
+ }
167
+ /** A snapshot of a conversion job's state. */
168
+ export class Job {
169
+ jobId;
170
+ status;
171
+ slideCount;
172
+ progress;
173
+ creditsReserved;
174
+ creditsUsed;
175
+ creditsRefunded;
176
+ createdAt;
177
+ completedAt;
178
+ /** Optional in the public shape so pre-cancellation structural `Job` values still type-check. */
179
+ cancellationRequested;
180
+ downloadUrl;
181
+ error;
182
+ /**
183
+ * Per-page outcome, in page order, `slideCount` entries long — or `null`.
184
+ *
185
+ * That shape is what the API documents, and this client passes the ledger
186
+ * through as it arrived rather than cross-checking it against `slideCount`.
187
+ * Refusing a job over a ledger that did not add up would cost the caller a deck
188
+ * they can actually download, which is the worse trade. Check the length
189
+ * yourself if your own logic depends on it.
190
+ *
191
+ * `null` means the service did not send the field, which is a different fact
192
+ * from an empty array and must not be confused with one. It is absent while the
193
+ * job is still running (mid-run, "this page failed" and "this page has not had
194
+ * its turn" cannot be told apart), and absent for an early job that has no
195
+ * per-page record at all.
196
+ *
197
+ * `creditsRefunded` says how many pages did not convert; this says **which**,
198
+ * and whether each one still made it into the deck as its original image. See
199
+ * `PageError.code`.
200
+ *
201
+ * Declared required rather than optional (unlike `cancellationRequested`)
202
+ * precisely because absence is meaningful here: a third `undefined` state would
203
+ * make "the service didn't say" and "nobody filled this in" indistinguishable,
204
+ * which is the confusion `null` exists to prevent.
205
+ */
206
+ pageResults;
207
+ /** Raw response body, for forward-compatible access to new fields. */
208
+ raw;
209
+ constructor(data) {
210
+ // The contract guarantees `jobId` and `status`, and a job without them is not a
211
+ // job: a snapshot with either one undefined used to sail through here, and
212
+ // `wait()` would then poll that nonsense object until its half-hour deadline ran
213
+ // out. The same standard `cancel()` has always held its own response to — which
214
+ // is why all three envelopes now go through one check.
215
+ const d = requireFields(data, ["jobId", "status"], "job response");
216
+ this.jobId = d.jobId;
217
+ this.status = d.status;
218
+ this.slideCount = d.slideCount ?? null;
219
+ this.progress = d.progress ?? null;
220
+ this.creditsReserved = d.creditsReserved ?? null;
221
+ this.creditsUsed = d.creditsUsed ?? null;
222
+ this.creditsRefunded = d.creditsRefunded ?? null;
223
+ this.createdAt = d.createdAt ?? null;
224
+ this.completedAt = d.completedAt ?? null;
225
+ // Identity, not `?? false` and not `Boolean(...)`: the field is declared
226
+ // `boolean`, and coercing it left the two clients reading the same malformed
227
+ // body differently, because `[]` is truthy in JavaScript and falsy in Python.
228
+ // `true` is the only value that says the service accepted a cancellation. See
229
+ // `parseCancellationResult` for why the envelope's `finalizing` compares the
230
+ // other way round.
231
+ this.cancellationRequested = d.cancellationRequested === true;
232
+ this.downloadUrl = d.downloadUrl ?? null;
233
+ // Same rule as a page entry's `error` one level down: present but not an object
234
+ // says nothing this model could report, so it reads as absent. The original is
235
+ // still on `raw`.
236
+ this.error = isJsonObject(d.error) ? d.error : null;
237
+ this.pageResults = parsePageResults(d.pageResults);
238
+ this.raw = data;
239
+ }
240
+ /** Whether the job finished successfully (deliverable downloadable). */
241
+ get isCompleted() {
242
+ return this.status === "completed";
243
+ }
244
+ /** Whether the job failed. */
245
+ get isFailed() {
246
+ return this.status === "failed";
247
+ }
248
+ /** Whether the job reached a terminal state (completed or failed). */
249
+ get isTerminal() {
250
+ return this.isCompleted || this.isFailed;
251
+ }
252
+ static fromJson(data) {
253
+ return new Job(data);
254
+ }
255
+ }
256
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAgBrD;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,aAAa,CACpB,IAAa,EACb,IAAuB,EACvB,IAAY;IAEZ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,sBAAsB,CAAC,aAAa,IAAI,0BAA0B,CAAC,CAAC;IAChF,CAAC;IACD,MAAM,CAAC,GAAG,IAA2B,CAAC;IACtC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,sBAAsB,CAAC,aAAa,IAAI,aAAa,GAAG,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAkBD,oCAAoC;AACpC,MAAM,OAAO,SAAS;IACpB;;;;;;;;OAQG;IACM,IAAI,CAAS;IACtB;;;OAGG;IACM,OAAO,CAAS;IACzB;;;;OAIG;IACM,SAAS,CAAU;IAC5B,sEAAsE;IAC7D,GAAG,CAA0B;IAEtC,YAAY,IAA6B;QACvC,MAAM,CAAC,GAAG,IAA2B,CAAC;QACtC,8EAA8E;QAC9E,2EAA2E;QAC3E,4EAA4E;QAC5E,0EA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E;QAC7E,8EAA8E;QAC9E,8EAA8E;QAC9E,6EAA6E;QAC7E,mBAAmB;QACnB,IAAI,CAAC,qBAAqB,GAAG,CAAC,CAAC,qBAAqB,KAAK,IAAI,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC;QACzC,gFAAgF;QAChF,+EAA+E;QAC/E,kBAAkB;QAClB,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,KAAkB,CAAC,CAAC,CAAC,IAAI,CAAC;QAClE,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QACnD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;IAClB,CAAC;IAED,wEAAwE;IACxE,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,MAAM,KAAK,WAAW,CAAC;IACrC,CAAC;IAED,8BAA8B;IAC9B,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC;IAClC,CAAC;IAED,sEAAsE;IACtE,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,QAAQ,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAA6B;QAC3C,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Package version, in one place.
3
+ *
4
+ * `package.json` is the published number. This constant is what the User-Agent
5
+ * is built from, and `test/version.test.ts` keeps the two in step — they drifted
6
+ * apart once on the Python side, which made a bug report's version line useless.
7
+ *
8
+ * Do not read `package.json` at runtime: ESM + bundlers will not resolve it.
9
+ */
10
+ export declare const VERSION = "0.5.3";
11
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Package version, in one place.
3
+ *
4
+ * `package.json` is the published number. This constant is what the User-Agent
5
+ * is built from, and `test/version.test.ts` keeps the two in step — they drifted
6
+ * apart once on the Python side, which made a bug report's version line useless.
7
+ *
8
+ * Do not read `package.json` at runtime: ESM + bundlers will not resolve it.
9
+ */
10
+ export const VERSION = "0.5.3";
11
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "image2ppt",
3
+ "version": "0.5.3",
4
+ "description": "Official Node.js/TypeScript client for the image2ppt API — convert images and PDFs into editable PowerPoint (.pptx).",
5
+ "keywords": [
6
+ "image2ppt",
7
+ "pptx",
8
+ "powerpoint",
9
+ "presentation",
10
+ "slides",
11
+ "pdf",
12
+ "ocr",
13
+ "image-to-pptx",
14
+ "api",
15
+ "sdk"
16
+ ],
17
+ "homepage": "https://image2ppt.com",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/image2ppt/image2ppt-sdk.git",
21
+ "directory": "typescript"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/image2ppt/image2ppt-sdk/issues"
25
+ },
26
+ "license": "MIT",
27
+ "author": "image2ppt",
28
+ "type": "module",
29
+ "engines": {
30
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
31
+ },
32
+ "main": "./dist/index.js",
33
+ "types": "./dist/index.d.ts",
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js"
38
+ }
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "README.md",
43
+ "LICENSE"
44
+ ],
45
+ "scripts": {
46
+ "build": "tsc -p tsconfig.json",
47
+ "test": "vitest run",
48
+ "test:watch": "vitest",
49
+ "prepublishOnly": "npm run build"
50
+ },
51
+ "dependencies": {
52
+ "sharp": "^0.34.3"
53
+ },
54
+ "devDependencies": {
55
+ "@types/node": "^20.11.0",
56
+ "typescript": "^5.4.0",
57
+ "vitest": "^1.6.0"
58
+ }
59
+ }