@cloudpdf/sdk 3.0.0-next.1 → 3.0.0-next.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.
- package/README.md +23 -46
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.d.ts +3 -0
- package/dist/cjs/Client.js +9 -4
- package/dist/cjs/CloudPDFClient.d.ts +20 -0
- package/dist/cjs/CloudPDFClient.js +39 -0
- package/dist/cjs/api/errors/ConflictError.d.ts +7 -0
- package/dist/cjs/api/errors/ConflictError.js +54 -0
- package/dist/cjs/api/errors/GoneError.d.ts +7 -0
- package/dist/cjs/api/errors/GoneError.js +54 -0
- package/dist/cjs/api/errors/UnprocessableEntityError.d.ts +7 -0
- package/dist/cjs/api/errors/UnprocessableEntityError.js +54 -0
- package/dist/cjs/api/errors/index.d.ts +3 -0
- package/dist/cjs/api/errors/index.js +3 -0
- package/dist/cjs/api/resources/documents/client/Client.d.ts +14 -5
- package/dist/cjs/api/resources/documents/client/Client.js +26 -14
- package/dist/cjs/api/resources/documents/client/requests/DocumentsInitRequest.d.ts +7 -0
- package/dist/cjs/api/resources/documents/client/requests/DocumentsInitRequest.js +5 -0
- package/dist/cjs/api/resources/documents/client/requests/UploadProxyDocumentsRequest.d.ts +14 -0
- package/dist/cjs/api/resources/documents/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/index.d.ts +2 -0
- package/dist/cjs/api/resources/index.js +3 -1
- package/dist/cjs/api/resources/shares/client/Client.d.ts +119 -0
- package/dist/cjs/api/resources/shares/client/Client.js +422 -0
- package/dist/cjs/api/resources/shares/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/shares/client/index.js +17 -0
- package/dist/cjs/api/resources/shares/client/requests/DeleteSharesRequest.d.ts +11 -0
- package/dist/cjs/api/resources/shares/client/requests/GetSharesRequest.d.ts +11 -0
- package/dist/cjs/api/resources/shares/client/requests/GetSharesRequest.js +3 -0
- package/dist/cjs/api/resources/shares/client/requests/ListSharesRequest.d.ts +12 -0
- package/dist/cjs/api/resources/shares/client/requests/ListSharesRequest.js +3 -0
- package/dist/cjs/api/resources/shares/client/requests/SharesCreateRequest.d.ts +18 -0
- package/dist/cjs/api/resources/shares/client/requests/SharesCreateRequest.js +3 -0
- package/dist/cjs/api/resources/shares/client/requests/SharesExchangeRequest.d.ts +10 -0
- package/dist/cjs/api/resources/shares/client/requests/SharesExchangeRequest.js +3 -0
- package/dist/cjs/api/resources/shares/client/requests/SharesUpdateRequest.d.ts +17 -0
- package/dist/cjs/api/resources/shares/client/requests/SharesUpdateRequest.js +3 -0
- package/dist/cjs/api/resources/shares/client/requests/index.d.ts +6 -0
- package/dist/cjs/api/resources/shares/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/shares/exports.d.ts +2 -0
- package/dist/cjs/api/resources/shares/exports.js +21 -0
- package/dist/cjs/api/resources/shares/index.d.ts +1 -0
- package/dist/cjs/api/resources/shares/index.js +17 -0
- package/dist/cjs/api/resources/tenants/client/Client.d.ts +50 -0
- package/dist/cjs/api/resources/tenants/client/Client.js +181 -0
- package/dist/cjs/api/resources/tenants/client/requests/ResumeTenantsRequest.d.ts +9 -0
- package/dist/cjs/api/resources/tenants/client/requests/ResumeTenantsRequest.js +3 -0
- package/dist/cjs/api/resources/tenants/client/requests/TenantsSuspendRequest.d.ts +10 -0
- package/dist/cjs/api/resources/tenants/client/requests/TenantsSuspendRequest.js +3 -0
- package/dist/cjs/api/resources/tenants/client/requests/UsageTenantsRequest.d.ts +10 -0
- package/dist/cjs/api/resources/tenants/client/requests/UsageTenantsRequest.js +3 -0
- package/dist/cjs/api/resources/tenants/client/requests/index.d.ts +3 -0
- package/dist/cjs/api/types/DocumentsInit200ResponseCreatedUpload.d.ts +3 -3
- package/dist/cjs/api/types/DocumentsInit200ResponseResumedUpload.d.ts +3 -3
- package/dist/cjs/api/types/DocumentsUploadProxy200Response.d.ts +3 -0
- package/dist/cjs/api/types/DocumentsUploadProxy200Response.js +3 -0
- package/dist/cjs/api/types/DocumentsUploadProxy400Response.d.ts +9 -0
- package/dist/cjs/api/types/DocumentsUploadProxy400Response.js +3 -0
- package/dist/cjs/api/types/DocumentsUploadProxy409Response.d.ts +9 -0
- package/dist/cjs/api/types/DocumentsUploadProxy409Response.js +3 -0
- package/dist/cjs/api/types/SharesCreate200Response.d.ts +22 -0
- package/dist/cjs/api/types/SharesCreate200Response.js +3 -0
- package/dist/cjs/api/types/SharesCreate400Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesCreate400Response.js +3 -0
- package/dist/cjs/api/types/SharesCreate403Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesCreate403Response.js +3 -0
- package/dist/cjs/api/types/SharesCreate404Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesCreate404Response.js +3 -0
- package/dist/cjs/api/types/SharesDeleteResponse.d.ts +9 -0
- package/dist/cjs/api/types/SharesDeleteResponse.js +3 -0
- package/dist/cjs/api/types/SharesExchange200Response.d.ts +6 -0
- package/dist/cjs/api/types/SharesExchange200Response.js +3 -0
- package/dist/cjs/api/types/SharesExchange400Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesExchange400Response.js +3 -0
- package/dist/cjs/api/types/SharesExchange403Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesExchange403Response.js +3 -0
- package/dist/cjs/api/types/SharesExchange404Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesExchange404Response.js +3 -0
- package/dist/cjs/api/types/SharesExchange410Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesExchange410Response.js +3 -0
- package/dist/cjs/api/types/SharesExchange422Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesExchange422Response.js +3 -0
- package/dist/cjs/api/types/SharesGet200Response.d.ts +22 -0
- package/dist/cjs/api/types/SharesGet200Response.js +3 -0
- package/dist/cjs/api/types/SharesGet404Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesGet404Response.js +3 -0
- package/dist/cjs/api/types/SharesList200Response.d.ts +26 -0
- package/dist/cjs/api/types/SharesList200Response.js +3 -0
- package/dist/cjs/api/types/SharesList400Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesList400Response.js +3 -0
- package/dist/cjs/api/types/SharesUpdate200Response.d.ts +22 -0
- package/dist/cjs/api/types/SharesUpdate200Response.js +3 -0
- package/dist/cjs/api/types/SharesUpdate400Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesUpdate400Response.js +3 -0
- package/dist/cjs/api/types/SharesUpdate404Response.d.ts +9 -0
- package/dist/cjs/api/types/SharesUpdate404Response.js +3 -0
- package/dist/cjs/api/types/TenantsCreate200Response.d.ts +8 -0
- package/dist/cjs/api/types/TenantsCreate200Response.js +11 -0
- package/dist/cjs/api/types/TenantsGet200Response.d.ts +8 -0
- package/dist/cjs/api/types/TenantsGet200Response.js +11 -0
- package/dist/cjs/api/types/TenantsList200Response.d.ts +8 -0
- package/dist/cjs/api/types/TenantsList200Response.js +14 -0
- package/dist/cjs/api/types/TenantsResumeResponse.d.ts +9 -0
- package/dist/cjs/api/types/TenantsResumeResponse.js +3 -0
- package/dist/cjs/api/types/TenantsSuspendResponse.d.ts +9 -0
- package/dist/cjs/api/types/TenantsSuspendResponse.js +3 -0
- package/dist/cjs/api/types/TenantsUsage200Response.d.ts +13 -0
- package/dist/cjs/api/types/TenantsUsage200Response.js +3 -0
- package/dist/cjs/api/types/TenantsUsage400Response.d.ts +9 -0
- package/dist/cjs/api/types/TenantsUsage400Response.js +3 -0
- package/dist/cjs/api/types/TenantsUsage404Response.d.ts +9 -0
- package/dist/cjs/api/types/TenantsUsage404Response.js +3 -0
- package/dist/cjs/api/types/TokensIssueRequest.d.ts +2 -1
- package/dist/cjs/api/types/index.d.ts +26 -2
- package/dist/cjs/api/types/index.js +26 -2
- package/dist/cjs/auth/BearerAuthProvider.d.ts +1 -1
- package/dist/cjs/core/form-data-utils/FormDataWrapper.d.ts +15 -0
- package/dist/cjs/core/form-data-utils/FormDataWrapper.js +188 -0
- package/dist/cjs/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
- package/dist/cjs/core/form-data-utils/encodeAsFormParameter.js +12 -0
- package/dist/cjs/core/form-data-utils/index.d.ts +2 -0
- package/dist/cjs/core/form-data-utils/index.js +20 -0
- package/dist/cjs/core/index.d.ts +1 -0
- package/dist/cjs/core/index.js +1 -0
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.js +5 -2
- package/dist/cjs/uploads/Uploads.d.ts +7 -0
- package/dist/cjs/uploads/Uploads.js +78 -0
- package/dist/cjs/uploads/index.d.ts +2 -0
- package/dist/cjs/uploads/index.js +5 -0
- package/dist/cjs/uploads/source.d.ts +10 -0
- package/dist/cjs/uploads/source.js +155 -0
- package/dist/cjs/uploads/types.d.ts +46 -0
- package/dist/cjs/uploads/types.js +2 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.d.mts +3 -0
- package/dist/esm/Client.mjs +5 -0
- package/dist/esm/CloudPDFClient.d.mts +20 -0
- package/dist/esm/CloudPDFClient.mjs +35 -0
- package/dist/esm/api/errors/ConflictError.d.mts +7 -0
- package/dist/esm/api/errors/ConflictError.mjs +17 -0
- package/dist/esm/api/errors/GoneError.d.mts +7 -0
- package/dist/esm/api/errors/GoneError.mjs +17 -0
- package/dist/esm/api/errors/UnprocessableEntityError.d.mts +7 -0
- package/dist/esm/api/errors/UnprocessableEntityError.mjs +17 -0
- package/dist/esm/api/errors/index.d.mts +3 -0
- package/dist/esm/api/errors/index.mjs +3 -0
- package/dist/esm/api/resources/documents/client/Client.d.mts +14 -5
- package/dist/esm/api/resources/documents/client/Client.mjs +27 -15
- package/dist/esm/api/resources/documents/client/requests/DocumentsInitRequest.d.mts +7 -0
- package/dist/esm/api/resources/documents/client/requests/DocumentsInitRequest.mjs +5 -0
- package/dist/esm/api/resources/documents/client/requests/UploadProxyDocumentsRequest.d.mts +14 -0
- package/dist/esm/api/resources/documents/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/index.d.mts +2 -0
- package/dist/esm/api/resources/index.mjs +2 -0
- package/dist/esm/api/resources/shares/client/Client.d.mts +119 -0
- package/dist/esm/api/resources/shares/client/Client.mjs +385 -0
- package/dist/esm/api/resources/shares/client/index.d.mts +1 -0
- package/dist/esm/api/resources/shares/client/index.mjs +1 -0
- package/dist/esm/api/resources/shares/client/requests/DeleteSharesRequest.d.mts +11 -0
- package/dist/esm/api/resources/shares/client/requests/GetSharesRequest.d.mts +11 -0
- package/dist/esm/api/resources/shares/client/requests/GetSharesRequest.mjs +2 -0
- package/dist/esm/api/resources/shares/client/requests/ListSharesRequest.d.mts +12 -0
- package/dist/esm/api/resources/shares/client/requests/ListSharesRequest.mjs +2 -0
- package/dist/esm/api/resources/shares/client/requests/SharesCreateRequest.d.mts +18 -0
- package/dist/esm/api/resources/shares/client/requests/SharesCreateRequest.mjs +2 -0
- package/dist/esm/api/resources/shares/client/requests/SharesExchangeRequest.d.mts +10 -0
- package/dist/esm/api/resources/shares/client/requests/SharesExchangeRequest.mjs +2 -0
- package/dist/esm/api/resources/shares/client/requests/SharesUpdateRequest.d.mts +17 -0
- package/dist/esm/api/resources/shares/client/requests/SharesUpdateRequest.mjs +2 -0
- package/dist/esm/api/resources/shares/client/requests/index.d.mts +6 -0
- package/dist/esm/api/resources/shares/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/shares/exports.d.mts +2 -0
- package/dist/esm/api/resources/shares/exports.mjs +3 -0
- package/dist/esm/api/resources/shares/index.d.mts +1 -0
- package/dist/esm/api/resources/shares/index.mjs +1 -0
- package/dist/esm/api/resources/tenants/client/Client.d.mts +50 -0
- package/dist/esm/api/resources/tenants/client/Client.mjs +181 -0
- package/dist/esm/api/resources/tenants/client/requests/ResumeTenantsRequest.d.mts +9 -0
- package/dist/esm/api/resources/tenants/client/requests/ResumeTenantsRequest.mjs +2 -0
- package/dist/esm/api/resources/tenants/client/requests/TenantsSuspendRequest.d.mts +10 -0
- package/dist/esm/api/resources/tenants/client/requests/TenantsSuspendRequest.mjs +2 -0
- package/dist/esm/api/resources/tenants/client/requests/UsageTenantsRequest.d.mts +10 -0
- package/dist/esm/api/resources/tenants/client/requests/UsageTenantsRequest.mjs +2 -0
- package/dist/esm/api/resources/tenants/client/requests/index.d.mts +3 -0
- package/dist/esm/api/types/DocumentsInit200ResponseCreatedUpload.d.mts +3 -3
- package/dist/esm/api/types/DocumentsInit200ResponseResumedUpload.d.mts +3 -3
- package/dist/esm/api/types/DocumentsUploadProxy200Response.d.mts +3 -0
- package/dist/esm/api/types/DocumentsUploadProxy200Response.mjs +2 -0
- package/dist/esm/api/types/DocumentsUploadProxy400Response.d.mts +9 -0
- package/dist/esm/api/types/DocumentsUploadProxy400Response.mjs +2 -0
- package/dist/esm/api/types/DocumentsUploadProxy409Response.d.mts +9 -0
- package/dist/esm/api/types/DocumentsUploadProxy409Response.mjs +2 -0
- package/dist/esm/api/types/SharesCreate200Response.d.mts +22 -0
- package/dist/esm/api/types/SharesCreate200Response.mjs +2 -0
- package/dist/esm/api/types/SharesCreate400Response.d.mts +9 -0
- package/dist/esm/api/types/SharesCreate400Response.mjs +2 -0
- package/dist/esm/api/types/SharesCreate403Response.d.mts +9 -0
- package/dist/esm/api/types/SharesCreate403Response.mjs +2 -0
- package/dist/esm/api/types/SharesCreate404Response.d.mts +9 -0
- package/dist/esm/api/types/SharesCreate404Response.mjs +2 -0
- package/dist/esm/api/types/SharesDeleteResponse.d.mts +9 -0
- package/dist/esm/api/types/SharesDeleteResponse.mjs +2 -0
- package/dist/esm/api/types/SharesExchange200Response.d.mts +6 -0
- package/dist/esm/api/types/SharesExchange200Response.mjs +2 -0
- package/dist/esm/api/types/SharesExchange400Response.d.mts +9 -0
- package/dist/esm/api/types/SharesExchange400Response.mjs +2 -0
- package/dist/esm/api/types/SharesExchange403Response.d.mts +9 -0
- package/dist/esm/api/types/SharesExchange403Response.mjs +2 -0
- package/dist/esm/api/types/SharesExchange404Response.d.mts +9 -0
- package/dist/esm/api/types/SharesExchange404Response.mjs +2 -0
- package/dist/esm/api/types/SharesExchange410Response.d.mts +9 -0
- package/dist/esm/api/types/SharesExchange410Response.mjs +2 -0
- package/dist/esm/api/types/SharesExchange422Response.d.mts +9 -0
- package/dist/esm/api/types/SharesExchange422Response.mjs +2 -0
- package/dist/esm/api/types/SharesGet200Response.d.mts +22 -0
- package/dist/esm/api/types/SharesGet200Response.mjs +2 -0
- package/dist/esm/api/types/SharesGet404Response.d.mts +9 -0
- package/dist/esm/api/types/SharesGet404Response.mjs +2 -0
- package/dist/esm/api/types/SharesList200Response.d.mts +26 -0
- package/dist/esm/api/types/SharesList200Response.mjs +2 -0
- package/dist/esm/api/types/SharesList400Response.d.mts +9 -0
- package/dist/esm/api/types/SharesList400Response.mjs +2 -0
- package/dist/esm/api/types/SharesUpdate200Response.d.mts +22 -0
- package/dist/esm/api/types/SharesUpdate200Response.mjs +2 -0
- package/dist/esm/api/types/SharesUpdate400Response.d.mts +9 -0
- package/dist/esm/api/types/SharesUpdate400Response.mjs +2 -0
- package/dist/esm/api/types/SharesUpdate404Response.d.mts +9 -0
- package/dist/esm/api/types/SharesUpdate404Response.mjs +2 -0
- package/dist/esm/api/types/TenantsCreate200Response.d.mts +8 -0
- package/dist/esm/api/types/TenantsCreate200Response.mjs +10 -1
- package/dist/esm/api/types/TenantsGet200Response.d.mts +8 -0
- package/dist/esm/api/types/TenantsGet200Response.mjs +10 -1
- package/dist/esm/api/types/TenantsList200Response.d.mts +8 -0
- package/dist/esm/api/types/TenantsList200Response.mjs +13 -1
- package/dist/esm/api/types/TenantsResumeResponse.d.mts +9 -0
- package/dist/esm/api/types/TenantsResumeResponse.mjs +2 -0
- package/dist/esm/api/types/TenantsSuspendResponse.d.mts +9 -0
- package/dist/esm/api/types/TenantsSuspendResponse.mjs +2 -0
- package/dist/esm/api/types/TenantsUsage200Response.d.mts +13 -0
- package/dist/esm/api/types/TenantsUsage200Response.mjs +2 -0
- package/dist/esm/api/types/TenantsUsage400Response.d.mts +9 -0
- package/dist/esm/api/types/TenantsUsage400Response.mjs +2 -0
- package/dist/esm/api/types/TenantsUsage404Response.d.mts +9 -0
- package/dist/esm/api/types/TenantsUsage404Response.mjs +2 -0
- package/dist/esm/api/types/TokensIssueRequest.d.mts +2 -1
- package/dist/esm/api/types/index.d.mts +26 -2
- package/dist/esm/api/types/index.mjs +26 -2
- package/dist/esm/auth/BearerAuthProvider.d.mts +1 -1
- package/dist/esm/core/form-data-utils/FormDataWrapper.d.mts +15 -0
- package/dist/esm/core/form-data-utils/FormDataWrapper.mjs +150 -0
- package/dist/esm/core/form-data-utils/encodeAsFormParameter.d.mts +1 -0
- package/dist/esm/core/form-data-utils/encodeAsFormParameter.mjs +9 -0
- package/dist/esm/core/form-data-utils/index.d.mts +2 -0
- package/dist/esm/core/form-data-utils/index.mjs +2 -0
- package/dist/esm/core/index.d.mts +1 -0
- package/dist/esm/core/index.mjs +1 -0
- package/dist/esm/index.d.mts +3 -1
- package/dist/esm/index.mjs +3 -1
- package/dist/esm/uploads/Uploads.d.mts +7 -0
- package/dist/esm/uploads/Uploads.mjs +74 -0
- package/dist/esm/uploads/index.d.mts +2 -0
- package/dist/esm/uploads/index.mjs +1 -0
- package/dist/esm/uploads/source.d.mts +10 -0
- package/dist/esm/uploads/source.mjs +119 -0
- package/dist/esm/uploads/types.d.mts +46 -0
- package/dist/esm/uploads/types.mjs +1 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +188 -177
- package/reference.md +588 -0
- package/dist/cjs/api/types/DocumentsUploadDirect200Response.d.ts +0 -3
- package/dist/cjs/api/types/DocumentsUploadDirect400Response.d.ts +0 -9
- package/dist/esm/api/types/DocumentsUploadDirect200Response.d.mts +0 -3
- package/dist/esm/api/types/DocumentsUploadDirect400Response.d.mts +0 -9
- /package/dist/cjs/api/{types/DocumentsUploadDirect200Response.js → resources/documents/client/requests/UploadProxyDocumentsRequest.js} +0 -0
- /package/dist/cjs/api/{types/DocumentsUploadDirect400Response.js → resources/shares/client/requests/DeleteSharesRequest.js} +0 -0
- /package/dist/esm/api/{types/DocumentsUploadDirect200Response.mjs → resources/documents/client/requests/UploadProxyDocumentsRequest.mjs} +0 -0
- /package/dist/esm/api/{types/DocumentsUploadDirect400Response.mjs → resources/shares/client/requests/DeleteSharesRequest.mjs} +0 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
45
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
46
|
+
var m = o[Symbol.asyncIterator], i;
|
|
47
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
48
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
49
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.FormDataWrapper = void 0;
|
|
53
|
+
exports.newFormData = newFormData;
|
|
54
|
+
const index_js_1 = require("../../core/file/index.js");
|
|
55
|
+
const json_js_1 = require("../../core/json.js");
|
|
56
|
+
const index_js_2 = require("../runtime/index.js");
|
|
57
|
+
function newFormData() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
return new FormDataWrapper();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
class FormDataWrapper {
|
|
63
|
+
constructor() {
|
|
64
|
+
this.fd = new FormData();
|
|
65
|
+
}
|
|
66
|
+
setup() {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
// noop
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
append(key, value) {
|
|
72
|
+
this.fd.append(key, String(value));
|
|
73
|
+
}
|
|
74
|
+
appendFile(key, value) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
if (value == null) {
|
|
77
|
+
throw new Error(`File upload for "${key}" received ${value === null ? "null" : "undefined"}. The generated code should not call appendFile with null/undefined — check that optional file fields are guarded before this call.`);
|
|
78
|
+
}
|
|
79
|
+
const { data, filename, contentType } = yield (0, index_js_1.toMultipartDataPart)(value);
|
|
80
|
+
const blob = yield convertToBlob(data, contentType);
|
|
81
|
+
if (filename) {
|
|
82
|
+
this.fd.append(key, blob, filename);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.fd.append(key, blob);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
getRequest() {
|
|
90
|
+
return {
|
|
91
|
+
body: this.fd,
|
|
92
|
+
headers: {},
|
|
93
|
+
duplex: "half",
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.FormDataWrapper = FormDataWrapper;
|
|
98
|
+
function isStreamLike(value) {
|
|
99
|
+
return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
|
|
100
|
+
}
|
|
101
|
+
function isReadableStream(value) {
|
|
102
|
+
return typeof value === "object" && value != null && "getReader" in value;
|
|
103
|
+
}
|
|
104
|
+
function isBuffer(value) {
|
|
105
|
+
return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
|
|
106
|
+
}
|
|
107
|
+
function isArrayBufferView(value) {
|
|
108
|
+
return ArrayBuffer.isView(value);
|
|
109
|
+
}
|
|
110
|
+
function streamToBuffer(stream) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
var _a, stream_1, stream_1_1;
|
|
113
|
+
var _b, e_1, _c, _d;
|
|
114
|
+
if (index_js_2.RUNTIME.type === "node") {
|
|
115
|
+
const { Readable } = yield Promise.resolve().then(() => __importStar(require("stream")));
|
|
116
|
+
if (stream instanceof Readable) {
|
|
117
|
+
const chunks = [];
|
|
118
|
+
try {
|
|
119
|
+
for (_a = true, stream_1 = __asyncValues(stream); stream_1_1 = yield stream_1.next(), _b = stream_1_1.done, !_b; _a = true) {
|
|
120
|
+
_d = stream_1_1.value;
|
|
121
|
+
_a = false;
|
|
122
|
+
const chunk = _d;
|
|
123
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
127
|
+
finally {
|
|
128
|
+
try {
|
|
129
|
+
if (!_a && !_b && (_c = stream_1.return)) yield _c.call(stream_1);
|
|
130
|
+
}
|
|
131
|
+
finally { if (e_1) throw e_1.error; }
|
|
132
|
+
}
|
|
133
|
+
return Buffer.concat(chunks);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (isReadableStream(stream)) {
|
|
137
|
+
const reader = stream.getReader();
|
|
138
|
+
const chunks = [];
|
|
139
|
+
try {
|
|
140
|
+
while (true) {
|
|
141
|
+
const { done, value } = yield reader.read();
|
|
142
|
+
if (done)
|
|
143
|
+
break;
|
|
144
|
+
chunks.push(value);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
finally {
|
|
148
|
+
reader.releaseLock();
|
|
149
|
+
}
|
|
150
|
+
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
151
|
+
const result = new Uint8Array(totalLength);
|
|
152
|
+
let offset = 0;
|
|
153
|
+
for (const chunk of chunks) {
|
|
154
|
+
result.set(chunk, offset);
|
|
155
|
+
offset += chunk.length;
|
|
156
|
+
}
|
|
157
|
+
return Buffer.from(result);
|
|
158
|
+
}
|
|
159
|
+
throw new Error(`Unsupported stream type: ${typeof stream}. Expected Node.js Readable stream or Web ReadableStream.`);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function convertToBlob(value, contentType) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
if (isStreamLike(value) || isReadableStream(value)) {
|
|
165
|
+
const buffer = yield streamToBuffer(value);
|
|
166
|
+
return new Blob([buffer], { type: contentType });
|
|
167
|
+
}
|
|
168
|
+
if (value instanceof Blob) {
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
if (isBuffer(value)) {
|
|
172
|
+
return new Blob([value], { type: contentType });
|
|
173
|
+
}
|
|
174
|
+
if (value instanceof ArrayBuffer) {
|
|
175
|
+
return new Blob([value], { type: contentType });
|
|
176
|
+
}
|
|
177
|
+
if (isArrayBufferView(value)) {
|
|
178
|
+
return new Blob([value], { type: contentType });
|
|
179
|
+
}
|
|
180
|
+
if (typeof value === "string") {
|
|
181
|
+
return new Blob([value], { type: contentType });
|
|
182
|
+
}
|
|
183
|
+
if (typeof value === "object" && value !== null) {
|
|
184
|
+
return new Blob([(0, json_js_1.toJson)(value)], { type: contentType !== null && contentType !== void 0 ? contentType : "application/json" });
|
|
185
|
+
}
|
|
186
|
+
return new Blob([String(value)], { type: contentType });
|
|
187
|
+
});
|
|
188
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function encodeAsFormParameter(value: unknown): Record<string, string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeAsFormParameter = encodeAsFormParameter;
|
|
4
|
+
const qs_js_1 = require("../url/qs.js");
|
|
5
|
+
function encodeAsFormParameter(value) {
|
|
6
|
+
const stringified = (0, qs_js_1.toQueryString)(value, { encode: false });
|
|
7
|
+
const keyValuePairs = stringified.split("&").map((pair) => {
|
|
8
|
+
const [key, value] = pair.split("=");
|
|
9
|
+
return [key, value];
|
|
10
|
+
});
|
|
11
|
+
return Object.fromEntries(keyValuePairs);
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.encodeAsFormParameter = void 0;
|
|
18
|
+
var encodeAsFormParameter_js_1 = require("./encodeAsFormParameter.js");
|
|
19
|
+
Object.defineProperty(exports, "encodeAsFormParameter", { enumerable: true, get: function () { return encodeAsFormParameter_js_1.encodeAsFormParameter; } });
|
|
20
|
+
__exportStar(require("./FormDataWrapper.js"), exports);
|
package/dist/cjs/core/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./auth/index.js";
|
|
|
2
2
|
export * from "./base64.js";
|
|
3
3
|
export * from "./fetcher/index.js";
|
|
4
4
|
export * as file from "./file/index.js";
|
|
5
|
+
export * from "./form-data-utils/index.js";
|
|
5
6
|
export * as logging from "./logging/index.js";
|
|
6
7
|
export * from "./runtime/index.js";
|
|
7
8
|
export * as url from "./url/index.js";
|
package/dist/cjs/core/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __exportStar(require("./auth/index.js"), exports);
|
|
|
41
41
|
__exportStar(require("./base64.js"), exports);
|
|
42
42
|
__exportStar(require("./fetcher/index.js"), exports);
|
|
43
43
|
exports.file = __importStar(require("./file/index.js"));
|
|
44
|
+
__exportStar(require("./form-data-utils/index.js"), exports);
|
|
44
45
|
exports.logging = __importStar(require("./logging/index.js"));
|
|
45
46
|
__exportStar(require("./runtime/index.js"), exports);
|
|
46
47
|
exports.url = __importStar(require("./url/index.js"));
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * as CloudPDF from "./api/index.js";
|
|
2
2
|
export type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
|
|
3
|
-
export { CloudPDFClient } from "./
|
|
3
|
+
export { CloudPDFClient } from "./CloudPDFClient.js";
|
|
4
|
+
export { CloudPDFClient as GeneratedCloudPDFClient } from "./Client.js";
|
|
4
5
|
export { CloudPDFError, CloudPDFTimeoutError } from "./errors/index.js";
|
|
5
6
|
export * from "./exports.js";
|
|
7
|
+
export * from "./uploads/index.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -36,11 +36,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.CloudPDFTimeoutError = exports.CloudPDFError = exports.CloudPDFClient = exports.CloudPDF = void 0;
|
|
39
|
+
exports.CloudPDFTimeoutError = exports.CloudPDFError = exports.GeneratedCloudPDFClient = exports.CloudPDFClient = exports.CloudPDF = void 0;
|
|
40
40
|
exports.CloudPDF = __importStar(require("./api/index.js"));
|
|
41
|
+
var CloudPDFClient_js_1 = require("./CloudPDFClient.js");
|
|
42
|
+
Object.defineProperty(exports, "CloudPDFClient", { enumerable: true, get: function () { return CloudPDFClient_js_1.CloudPDFClient; } });
|
|
41
43
|
var Client_js_1 = require("./Client.js");
|
|
42
|
-
Object.defineProperty(exports, "
|
|
44
|
+
Object.defineProperty(exports, "GeneratedCloudPDFClient", { enumerable: true, get: function () { return Client_js_1.CloudPDFClient; } });
|
|
43
45
|
var index_js_1 = require("./errors/index.js");
|
|
44
46
|
Object.defineProperty(exports, "CloudPDFError", { enumerable: true, get: function () { return index_js_1.CloudPDFError; } });
|
|
45
47
|
Object.defineProperty(exports, "CloudPDFTimeoutError", { enumerable: true, get: function () { return index_js_1.CloudPDFTimeoutError; } });
|
|
46
48
|
__exportStar(require("./exports.js"), exports);
|
|
49
|
+
__exportStar(require("./uploads/index.js"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UploadCreateInput, UploadCreateResult, UploadProtocol } from "./types.js";
|
|
2
|
+
/** High-level, integrity-pinned `init -> transfer -> commit` workflow. */
|
|
3
|
+
export declare class Uploads<Document = unknown> {
|
|
4
|
+
private readonly protocol;
|
|
5
|
+
constructor(protocol: UploadProtocol);
|
|
6
|
+
create(input: UploadCreateInput): Promise<UploadCreateResult<Document>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Uploads = void 0;
|
|
13
|
+
const source_js_1 = require("./source.js");
|
|
14
|
+
/** High-level, integrity-pinned `init -> transfer -> commit` workflow. */
|
|
15
|
+
class Uploads {
|
|
16
|
+
constructor(protocol) {
|
|
17
|
+
this.protocol = protocol;
|
|
18
|
+
}
|
|
19
|
+
create(input) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
const source = yield (0, source_js_1.prepareUploadSource)(input.source);
|
|
23
|
+
const requestOptions = { abortSignal: input.signal };
|
|
24
|
+
const init = (yield this.protocol.init({
|
|
25
|
+
tenantId: input.tenantId,
|
|
26
|
+
contentLength: source.size,
|
|
27
|
+
contentSha256: source.sha256,
|
|
28
|
+
metadata: input.metadata,
|
|
29
|
+
idempotencyKey: input.idempotencyKey,
|
|
30
|
+
dedupMode: input.dedupMode,
|
|
31
|
+
docId: input.docId,
|
|
32
|
+
uploadTtlSec: input.uploadTtlSec,
|
|
33
|
+
uploadPreference: input.uploadPreference,
|
|
34
|
+
}, requestOptions));
|
|
35
|
+
if (init.tag === "deduped") {
|
|
36
|
+
(_a = input.onProgress) === null || _a === void 0 ? void 0 : _a.call(input, source.size, source.size);
|
|
37
|
+
return { tag: init.tag, document: init.document };
|
|
38
|
+
}
|
|
39
|
+
if (!init.upload)
|
|
40
|
+
throw new Error("CloudPDF init response omitted upload access");
|
|
41
|
+
(_b = input.onProgress) === null || _b === void 0 ? void 0 : _b.call(input, 0, source.size);
|
|
42
|
+
if (init.upload.kind === "presigned") {
|
|
43
|
+
const body = yield source.open();
|
|
44
|
+
const response = yield this.protocol.presigned(init.upload.presigned.url, Object.assign({ method: init.upload.presigned.method,
|
|
45
|
+
// These are the exact signed headers. In particular, no SDK
|
|
46
|
+
// Authorization header is added to an object-store request.
|
|
47
|
+
headers: init.upload.presigned.headers, body, signal: input.signal }, (isStreamBody(body) ? { duplex: "half" } : {})));
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
const detail = yield response.text().catch(() => "");
|
|
50
|
+
throw new Error(`presigned upload failed: ${response.status} ${response.statusText} ${detail}`.trim());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const form = new FormData();
|
|
55
|
+
form.append("file", yield source.openProxyBlob(), source.filename);
|
|
56
|
+
const response = yield this.protocol.proxy(init.upload.url, form, {
|
|
57
|
+
abortSignal: input.signal,
|
|
58
|
+
maxRetries: 0,
|
|
59
|
+
});
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
const detail = yield response.text().catch(() => "");
|
|
62
|
+
throw new Error(`proxy upload failed: ${response.status} ${response.statusText} ${detail}`.trim());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
(_c = input.onProgress) === null || _c === void 0 ? void 0 : _c.call(input, source.size, source.size);
|
|
66
|
+
const committed = (yield this.protocol.commit({
|
|
67
|
+
tenantId: input.tenantId,
|
|
68
|
+
id: init.document.id,
|
|
69
|
+
sha256: source.sha256,
|
|
70
|
+
}, requestOptions));
|
|
71
|
+
return { tag: init.tag, document: committed.document };
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.Uploads = Uploads;
|
|
76
|
+
function isStreamBody(body) {
|
|
77
|
+
return typeof body === "object" && body !== null && ("pipe" in body || "getReader" in body);
|
|
78
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { UploadSource } from "./types.js";
|
|
2
|
+
export interface PreparedUploadSource {
|
|
3
|
+
size: number;
|
|
4
|
+
sha256: string;
|
|
5
|
+
filename: string;
|
|
6
|
+
contentType: string;
|
|
7
|
+
open(): Promise<BodyInit>;
|
|
8
|
+
openProxyBlob(): Promise<Blob>;
|
|
9
|
+
}
|
|
10
|
+
export declare function prepareUploadSource(source: UploadSource): Promise<PreparedUploadSource>;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
45
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
46
|
+
var m = o[Symbol.asyncIterator], i;
|
|
47
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
48
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
49
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.prepareUploadSource = prepareUploadSource;
|
|
53
|
+
function prepareUploadSource(source) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
var _a, _b;
|
|
56
|
+
if (isReopenable(source)) {
|
|
57
|
+
return {
|
|
58
|
+
size: source.size,
|
|
59
|
+
sha256: normalizeSha(source.sha256),
|
|
60
|
+
filename: (_a = source.filename) !== null && _a !== void 0 ? _a : "document.pdf",
|
|
61
|
+
contentType: (_b = source.contentType) !== null && _b !== void 0 ? _b : "application/pdf",
|
|
62
|
+
open: () => __awaiter(this, void 0, void 0, function* () { return source.open(); }),
|
|
63
|
+
openProxyBlob: () => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
if (!source.openProxyBlob) {
|
|
65
|
+
throw new Error("the server selected proxy upload, but this reopenable source does not provide openProxyBlob()");
|
|
66
|
+
}
|
|
67
|
+
return source.openProxyBlob();
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (isPathSource(source))
|
|
72
|
+
return preparePath(source.path);
|
|
73
|
+
const blob = toBlob(source);
|
|
74
|
+
return {
|
|
75
|
+
size: blob.size,
|
|
76
|
+
sha256: yield sha256Bytes(new Uint8Array(yield blob.arrayBuffer())),
|
|
77
|
+
filename: "document.pdf",
|
|
78
|
+
contentType: blob.type || "application/pdf",
|
|
79
|
+
open: () => __awaiter(this, void 0, void 0, function* () { return blob; }),
|
|
80
|
+
openProxyBlob: () => __awaiter(this, void 0, void 0, function* () { return blob; }),
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function preparePath(path) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
var _a, e_1, _b, _c;
|
|
87
|
+
const [{ createReadStream }, { readFile, stat }, { createHash }] = yield Promise.all([
|
|
88
|
+
Promise.resolve().then(() => __importStar(require("node:fs"))),
|
|
89
|
+
Promise.resolve().then(() => __importStar(require("node:fs/promises"))),
|
|
90
|
+
Promise.resolve().then(() => __importStar(require("node:crypto"))),
|
|
91
|
+
]);
|
|
92
|
+
const info = yield stat(path);
|
|
93
|
+
if (!info.isFile())
|
|
94
|
+
throw new Error(`upload source is not a file: ${path}`);
|
|
95
|
+
const hash = createHash("sha256");
|
|
96
|
+
try {
|
|
97
|
+
for (var _d = true, _e = __asyncValues(createReadStream(path)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
98
|
+
_c = _f.value;
|
|
99
|
+
_d = false;
|
|
100
|
+
const chunk = _c;
|
|
101
|
+
hash.update(chunk);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
105
|
+
finally {
|
|
106
|
+
try {
|
|
107
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
108
|
+
}
|
|
109
|
+
finally { if (e_1) throw e_1.error; }
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
size: info.size,
|
|
113
|
+
sha256: hash.digest("hex"),
|
|
114
|
+
filename: path.split(/[\\/]/).pop() || "document.pdf",
|
|
115
|
+
contentType: "application/pdf",
|
|
116
|
+
open: () => __awaiter(this, void 0, void 0, function* () { return createReadStream(path); }),
|
|
117
|
+
// The proxy route is deliberately bounded. Presigned mode remains
|
|
118
|
+
// streaming; the uncommon filesystem fallback materializes one Blob.
|
|
119
|
+
openProxyBlob: () => __awaiter(this, void 0, void 0, function* () { return new Blob([new Uint8Array(yield readFile(path))], { type: "application/pdf" }); }),
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function sha256Bytes(bytes) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
var _a;
|
|
126
|
+
if ((_a = globalThis.crypto) === null || _a === void 0 ? void 0 : _a.subtle) {
|
|
127
|
+
const digest = yield globalThis.crypto.subtle.digest("SHA-256", new Uint8Array(bytes));
|
|
128
|
+
return hex(new Uint8Array(digest));
|
|
129
|
+
}
|
|
130
|
+
const { createHash } = yield Promise.resolve().then(() => __importStar(require("node:crypto")));
|
|
131
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function toBlob(source) {
|
|
135
|
+
if (source instanceof Blob)
|
|
136
|
+
return source;
|
|
137
|
+
const bytes = source instanceof Uint8Array ? new Uint8Array(source) : new Uint8Array(source.slice(0));
|
|
138
|
+
return new Blob([bytes], { type: "application/pdf" });
|
|
139
|
+
}
|
|
140
|
+
function isPathSource(source) {
|
|
141
|
+
return typeof source === "object" && source !== null && "path" in source;
|
|
142
|
+
}
|
|
143
|
+
function isReopenable(source) {
|
|
144
|
+
return typeof source === "object" && source !== null && "open" in source && "size" in source && "sha256" in source;
|
|
145
|
+
}
|
|
146
|
+
function normalizeSha(value) {
|
|
147
|
+
const normalized = value.toLowerCase();
|
|
148
|
+
if (!/^[a-f0-9]{64}$/.test(normalized)) {
|
|
149
|
+
throw new Error("reopenable upload source sha256 must be 64 lowercase or uppercase hex characters");
|
|
150
|
+
}
|
|
151
|
+
return normalized;
|
|
152
|
+
}
|
|
153
|
+
function hex(bytes) {
|
|
154
|
+
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
155
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type UploadPreference = "auto" | "presigned" | "proxy";
|
|
2
|
+
export type DedupMode = "always-create" | "reuse-existing";
|
|
3
|
+
/**
|
|
4
|
+
* A source that can be opened again after its hash is known. This is the
|
|
5
|
+
* escape hatch for streams: init needs the final SHA before transfer starts,
|
|
6
|
+
* so a one-shot unknown stream cannot implement the protocol safely.
|
|
7
|
+
*/
|
|
8
|
+
export interface ReopenableUploadSource {
|
|
9
|
+
size: number;
|
|
10
|
+
sha256: string;
|
|
11
|
+
filename?: string;
|
|
12
|
+
contentType?: string;
|
|
13
|
+
open(): BodyInit | Promise<BodyInit>;
|
|
14
|
+
/** Required only if the server selects the multipart proxy fallback. */
|
|
15
|
+
openProxyBlob?(): Blob | Promise<Blob>;
|
|
16
|
+
}
|
|
17
|
+
export type UploadSource = Uint8Array | ArrayBuffer | Blob | {
|
|
18
|
+
path: string;
|
|
19
|
+
} | ReopenableUploadSource;
|
|
20
|
+
export interface UploadCreateInput {
|
|
21
|
+
tenantId: string;
|
|
22
|
+
source: UploadSource;
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
idempotencyKey?: string;
|
|
25
|
+
dedupMode?: DedupMode;
|
|
26
|
+
docId?: string;
|
|
27
|
+
uploadTtlSec?: number;
|
|
28
|
+
/** `auto` prefers a presigned object-store PUT and is recommended. */
|
|
29
|
+
uploadPreference?: UploadPreference;
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
onProgress?: (loaded: number, total: number) => void;
|
|
32
|
+
}
|
|
33
|
+
export interface UploadCreateResult<Document = unknown> {
|
|
34
|
+
tag: "created" | "resumed" | "deduped";
|
|
35
|
+
document: Document;
|
|
36
|
+
}
|
|
37
|
+
export interface UploadRequestOptions {
|
|
38
|
+
abortSignal?: AbortSignal;
|
|
39
|
+
maxRetries?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface UploadProtocol {
|
|
42
|
+
init(request: Record<string, unknown>, options: UploadRequestOptions): Promise<unknown>;
|
|
43
|
+
commit(request: Record<string, unknown>, options: UploadRequestOptions): Promise<unknown>;
|
|
44
|
+
proxy(url: string, form: FormData, options: UploadRequestOptions): Promise<Response>;
|
|
45
|
+
presigned(url: string, init: RequestInit): Promise<Response>;
|
|
46
|
+
}
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "3.0.0-next.
|
|
1
|
+
export declare const SDK_VERSION = "3.0.0-next.3";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/BaseClient.mjs
CHANGED
|
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
|
|
|
6
6
|
const headers = mergeHeaders({
|
|
7
7
|
"X-Fern-Language": "JavaScript",
|
|
8
8
|
"X-Fern-SDK-Name": "@cloudpdf/sdk",
|
|
9
|
-
"X-Fern-SDK-Version": "3.0.0-next.
|
|
10
|
-
"User-Agent": "@cloudpdf/sdk/3.0.0-next.
|
|
9
|
+
"X-Fern-SDK-Version": "3.0.0-next.3",
|
|
10
|
+
"User-Agent": "@cloudpdf/sdk/3.0.0-next.3",
|
|
11
11
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
12
12
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
13
13
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
package/dist/esm/Client.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DeploymentClient } from "./api/resources/deployment/client/Client.mjs";
|
|
2
2
|
import { DocClient } from "./api/resources/doc/client/Client.mjs";
|
|
3
3
|
import { DocumentsClient } from "./api/resources/documents/client/Client.mjs";
|
|
4
|
+
import { SharesClient } from "./api/resources/shares/client/Client.mjs";
|
|
4
5
|
import { TenantsClient } from "./api/resources/tenants/client/Client.mjs";
|
|
5
6
|
import { TokensClient } from "./api/resources/tokens/client/Client.mjs";
|
|
6
7
|
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.mjs";
|
|
@@ -15,12 +16,14 @@ export declare class CloudPDFClient {
|
|
|
15
16
|
protected readonly _options: NormalizedClientOptionsWithAuth<CloudPDFClient.Options>;
|
|
16
17
|
protected _deployment: DeploymentClient | undefined;
|
|
17
18
|
protected _doc: DocClient | undefined;
|
|
19
|
+
protected _shares: SharesClient | undefined;
|
|
18
20
|
protected _tenants: TenantsClient | undefined;
|
|
19
21
|
protected _documents: DocumentsClient | undefined;
|
|
20
22
|
protected _tokens: TokensClient | undefined;
|
|
21
23
|
constructor(options: CloudPDFClient.Options);
|
|
22
24
|
get deployment(): DeploymentClient;
|
|
23
25
|
get doc(): DocClient;
|
|
26
|
+
get shares(): SharesClient;
|
|
24
27
|
get tenants(): TenantsClient;
|
|
25
28
|
get documents(): DocumentsClient;
|
|
26
29
|
get tokens(): TokensClient;
|