@cloudpdf/contract 3.0.0-next.5 → 3.0.0-next.7
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/dist/index.d.ts +2439 -1448
- package/dist/index.js +102 -3
- package/dist/index.js.map +1 -1
- package/dist/openapi.d.ts +5 -1
- package/dist/openapi.js +143 -5
- package/dist/openapi.js.map +1 -1
- package/openapi.json +421 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
2
|
import {
|
|
4
3
|
AnnotationListPageSnapshotSchema,
|
|
5
4
|
DocumentHeadSchema,
|
|
@@ -11,6 +10,7 @@ import {
|
|
|
11
10
|
PageTextSnapshotSchema,
|
|
12
11
|
wireTemplates
|
|
13
12
|
} from "@embedpdf/engine-core/wire";
|
|
13
|
+
import { z } from "zod";
|
|
14
14
|
var sha256Hex = /^[0-9a-f]{64}$/i;
|
|
15
15
|
var docIdPattern = /^[A-Za-z0-9_-]+$/;
|
|
16
16
|
var tenantIdPattern = /^[A-Za-z0-9_-]+$/;
|
|
@@ -27,6 +27,7 @@ var adminWirePaths = {
|
|
|
27
27
|
tenant: (tenantId) => `/v1/tenants/${encodeURIComponent(tenantId)}`,
|
|
28
28
|
documents: (tenantId) => `/v1/tenants/${encodeURIComponent(tenantId)}/documents`,
|
|
29
29
|
documentsInit: (tenantId) => `/v1/tenants/${encodeURIComponent(tenantId)}/documents/init`,
|
|
30
|
+
documentsImport: (tenantId) => `/v1/tenants/${encodeURIComponent(tenantId)}/documents/import`,
|
|
30
31
|
document: (tenantId, docId) => `/v1/tenants/${encodeURIComponent(tenantId)}/documents/${encodeURIComponent(docId)}`,
|
|
31
32
|
documentCommit: (tenantId, docId) => `/v1/tenants/${encodeURIComponent(tenantId)}/documents/${encodeURIComponent(docId)}/commit`,
|
|
32
33
|
documentUploadProxy: (tenantId, docId) => `/v1/tenants/${encodeURIComponent(tenantId)}/documents/${encodeURIComponent(docId)}/upload-proxy`,
|
|
@@ -49,7 +50,9 @@ var adminWirePaths = {
|
|
|
49
50
|
/** Deployment-global singletons: API-token only, no tenant context. */
|
|
50
51
|
deploymentLicenseStatus: "/v1/deployment/license/status"
|
|
51
52
|
};
|
|
52
|
-
var DedupModeSchema = z.enum(["always-create", "reuse-existing"])
|
|
53
|
+
var DedupModeSchema = z.enum(["always-create", "reuse-existing"]).describe(
|
|
54
|
+
"always-create (default) creates a new document every time. reuse-existing returns a document that already holds the same content instead of storing it twice."
|
|
55
|
+
);
|
|
53
56
|
var UploadPreferenceSchema = z.enum(["auto", "presigned", "proxy"]);
|
|
54
57
|
var DocumentStateSchema = z.enum(["pending", "ready", "failed", "deleting"]);
|
|
55
58
|
var AdminDocumentRecordSchema = z.object({
|
|
@@ -118,6 +121,79 @@ var AdminDocumentCommitRequestSchema = z.object({
|
|
|
118
121
|
var AdminDocumentCommitResponseSchema = z.object({
|
|
119
122
|
document: AdminDocumentRecordSchema
|
|
120
123
|
});
|
|
124
|
+
var utf8ByteLength = (s) => new TextEncoder().encode(s).length;
|
|
125
|
+
var AdminImportSourceSchema = z.discriminatedUnion("kind", [
|
|
126
|
+
z.object({
|
|
127
|
+
kind: z.literal("url"),
|
|
128
|
+
url: z.string().url().max(8192).describe(
|
|
129
|
+
"The URL to fetch. Must be allowed by the deployment import policy (scheme, network range, size) and must declare a length."
|
|
130
|
+
)
|
|
131
|
+
}).describe(
|
|
132
|
+
"The caller supplies the authority: a presigned S3/GCS/Azure/R2/MinIO GET, or any HTTPS endpoint the deployment import policy allows. The URL is a capability \u2014 treat it as a secret. CloudPDF never echoes its query string back in errors, logs, or stored failure reasons."
|
|
133
|
+
),
|
|
134
|
+
z.object({
|
|
135
|
+
kind: z.literal("connection"),
|
|
136
|
+
connectionId: z.string().min(1).max(128).describe("The operator-registered storage connection to read from."),
|
|
137
|
+
key: z.string().min(1).refine((k) => !k.includes("\0"), "key must not contain NUL").refine((k) => utf8ByteLength(k) <= 1024, "key must be at most 1024 UTF-8 bytes").describe(
|
|
138
|
+
"The object key to read, inside the connection's configured scope. At most 1024 UTF-8 bytes."
|
|
139
|
+
),
|
|
140
|
+
revision: z.string().min(1).max(1024).optional().describe(
|
|
141
|
+
"Pins a specific version of the object. Provider-interpreted (S3 VersionId, GCS generation, Azure version id); providers without versioning reject it."
|
|
142
|
+
)
|
|
143
|
+
}).describe(
|
|
144
|
+
"The operator pre-registered the authority: the request names a connection and a key inside it. Which provider backs the connection (S3, GCS, Azure Blob, filesystem, ...) is deployment configuration, never wire surface."
|
|
145
|
+
)
|
|
146
|
+
]).describe(
|
|
147
|
+
"Where CloudPDF pulls the bytes from. The two shapes differ in WHO supplies the authority to read, not in which storage vendor holds the file."
|
|
148
|
+
);
|
|
149
|
+
var AdminDocumentImportRequestSchema = z.object({
|
|
150
|
+
source: AdminImportSourceSchema,
|
|
151
|
+
/**
|
|
152
|
+
* Optional integrity pins, enforced when present: `sizeBytes`
|
|
153
|
+
* against the source's declared Content-Length before the transfer,
|
|
154
|
+
* `sha256` against the server-observed digest after it. When absent
|
|
155
|
+
* the server-observed values become authoritative.
|
|
156
|
+
* `dedupMode=reuse-existing` REQUIRES `sha256` — without a declared
|
|
157
|
+
* hash the server cannot know what content to reuse.
|
|
158
|
+
*/
|
|
159
|
+
expected: z.object({
|
|
160
|
+
sizeBytes: z.number().int().min(1).optional().describe("Checked against the source's declared Content-Length before the transfer."),
|
|
161
|
+
sha256: z.string().regex(sha256Hex).optional().describe(
|
|
162
|
+
"Checked against the server-observed digest after the transfer. Required when dedupMode is reuse-existing."
|
|
163
|
+
)
|
|
164
|
+
}).optional().describe(
|
|
165
|
+
"Integrity pins, enforced when present. When absent, the server-observed values become authoritative."
|
|
166
|
+
),
|
|
167
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
168
|
+
idempotencyKey: z.string().optional().describe(
|
|
169
|
+
"Retrying with the same key resumes the same document rather than importing a second copy \u2014 including after a 502."
|
|
170
|
+
),
|
|
171
|
+
dedupMode: DedupModeSchema.optional(),
|
|
172
|
+
docId: z.string().regex(docIdPattern).optional(),
|
|
173
|
+
/**
|
|
174
|
+
* `sync` (default) holds the response open for the whole transfer.
|
|
175
|
+
* `async` accepts the request (202, document `pending`), transfers
|
|
176
|
+
* in the background, and the caller polls the document. Async
|
|
177
|
+
* requires a `connection` source (URLs are secrets and expire, so
|
|
178
|
+
* they cannot sit in a durable job); filesystem connections
|
|
179
|
+
* additionally require `expected.sha256`, since they have no
|
|
180
|
+
* revisions to pin retries to.
|
|
181
|
+
*/
|
|
182
|
+
mode: z.enum(["sync", "async"]).optional().describe(
|
|
183
|
+
"sync (default) holds the response open for the whole transfer. async answers 202 with the document pending and transfers in the background; it requires a connection source, and filesystem connections additionally require expected.sha256."
|
|
184
|
+
)
|
|
185
|
+
});
|
|
186
|
+
var AdminDocumentImportResponseSchema = z.object({
|
|
187
|
+
/**
|
|
188
|
+
* `imported` — bytes were pulled, verified, and committed (sync).
|
|
189
|
+
* `deduped` — an existing document satisfied the request without a
|
|
190
|
+
* transfer (content dedup or idempotent replay).
|
|
191
|
+
* `accepted` — async: the job is queued (HTTP 202); poll the
|
|
192
|
+
* document until `ready` or `failed`.
|
|
193
|
+
*/
|
|
194
|
+
tag: z.enum(["imported", "deduped", "accepted"]),
|
|
195
|
+
document: AdminDocumentRecordSchema
|
|
196
|
+
});
|
|
121
197
|
var AdminDocumentResponseSchema = z.object({
|
|
122
198
|
document: AdminDocumentRecordSchema
|
|
123
199
|
});
|
|
@@ -476,6 +552,25 @@ var adminOperations = {
|
|
|
476
552
|
},
|
|
477
553
|
notes: "This bounded origin-mediated fallback must only be used after documents.init returns upload.kind=proxy. Auto mode prefers a presigned object-store PUT whenever available."
|
|
478
554
|
},
|
|
555
|
+
"documents.importFrom": {
|
|
556
|
+
operationId: "documents.importFrom",
|
|
557
|
+
title: "Import document",
|
|
558
|
+
summary: "Server-side pull: fetch a PDF from a caller-supplied URL (e.g. a presigned object-store GET) or an operator-registered storage connection into CloudPDF-owned storage, verify it, and commit it.",
|
|
559
|
+
method: "POST",
|
|
560
|
+
path: "/v1/tenants/:tenantId/documents/import",
|
|
561
|
+
credentials: ["api-token", "tenant-jwt"],
|
|
562
|
+
scope: ["docs.create"],
|
|
563
|
+
params: AdminTenantParamsSchema,
|
|
564
|
+
body: { contentType: "application/json", schema: AdminDocumentImportRequestSchema },
|
|
565
|
+
responses: {
|
|
566
|
+
200: { contentType: "application/json", schema: AdminDocumentImportResponseSchema },
|
|
567
|
+
202: { contentType: "application/json", schema: AdminDocumentImportResponseSchema },
|
|
568
|
+
400: { contentType: "application/json", schema: AdminErrorPayloadSchema },
|
|
569
|
+
403: { contentType: "application/json", schema: AdminErrorPayloadSchema },
|
|
570
|
+
502: { contentType: "application/json", schema: AdminErrorPayloadSchema }
|
|
571
|
+
},
|
|
572
|
+
notes: "Default mode is synchronous and bounded: the response returns only after the transfer verified and committed (or failed). mode=async (connection sources only) answers 202 immediately and an in-process worker performs the transfer with leased, fenced retries; poll the document until ready/failed. The deployment import policy gates scheme, network range, and size; sources must declare a length. CloudPDF copies and owns the bytes \u2014 the source is never referenced in place. A 502 marks a retryable upstream failure: retry with the same idempotencyKey to resume the same document. URL sources are capabilities and never echoed back. Connection sources name operator-registered storage (bucket/prefix scope, allowed credential classes, and tenant bindings are deployment configuration); `revision` is provider-interpreted (S3 VersionId, GCS generation, Azure version id)."
|
|
573
|
+
},
|
|
479
574
|
"documents.list": {
|
|
480
575
|
operationId: "documents.list",
|
|
481
576
|
title: "List documents",
|
|
@@ -1133,6 +1228,8 @@ export {
|
|
|
1133
1228
|
ADMIN_DOCUMENT_LIST_MAX_LIMIT,
|
|
1134
1229
|
AdminDocumentCommitRequestSchema,
|
|
1135
1230
|
AdminDocumentCommitResponseSchema,
|
|
1231
|
+
AdminDocumentImportRequestSchema,
|
|
1232
|
+
AdminDocumentImportResponseSchema,
|
|
1136
1233
|
AdminDocumentInitRequestSchema,
|
|
1137
1234
|
AdminDocumentInitResponseSchema,
|
|
1138
1235
|
AdminDocumentListQuerySchema,
|
|
@@ -1140,6 +1237,7 @@ export {
|
|
|
1140
1237
|
AdminDocumentRecordSchema,
|
|
1141
1238
|
AdminDocumentResponseSchema,
|
|
1142
1239
|
AdminErrorPayloadSchema,
|
|
1240
|
+
AdminImportSourceSchema,
|
|
1143
1241
|
AdminInitUploadSchema,
|
|
1144
1242
|
AdminLicenseStatusResponseSchema,
|
|
1145
1243
|
AdminPresignedUploadSchema,
|
|
@@ -1186,6 +1284,7 @@ export {
|
|
|
1186
1284
|
allOperations,
|
|
1187
1285
|
docOperations,
|
|
1188
1286
|
docsGroups,
|
|
1189
|
-
documentPasswordHeader
|
|
1287
|
+
documentPasswordHeader,
|
|
1288
|
+
tenantIdPattern
|
|
1190
1289
|
};
|
|
1191
1290
|
//# sourceMappingURL=index.js.map
|