@taprootio/integration-sdk 0.1.2 → 0.1.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 +1 -1
- package/index.d.ts +3 -3
- package/package.json +1 -1
- package/src/client.js +5 -4
- package/src/constants.js +1 -1
- package/src/openapi-contract.d.ts +1 -1
- package/src/openapi-contract.js +3 -0
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Taproot publishes accepted, immutable content; it does not call an integration d
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
npm install @taprootio/integration-sdk@0.1.
|
|
10
|
+
npm install @taprootio/integration-sdk@0.1.3
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
The public manifest schema is exported at `@taprootio/integration-sdk/schema`. The fixtures under `@taprootio/integration-sdk/fixtures/...` are contract examples, not a local fixture host or a production deployment recipe.
|
package/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { INTEGRATION_OPENAPI_OPERATIONS, INTEGRATION_OPENAPI_SCHEMAS, INTEGRATIO
|
|
|
6
6
|
type OperationRequest<Name extends keyof IntegrationOpenApiOperationMap> = IntegrationOpenApiOperationMap[Name]["request"];
|
|
7
7
|
type OperationResponse<Name extends keyof IntegrationOpenApiOperationMap> = IntegrationOpenApiOperationMap[Name]["response"];
|
|
8
8
|
|
|
9
|
-
export const INTEGRATION_SDK_VERSION: "0.1.
|
|
9
|
+
export const INTEGRATION_SDK_VERSION: "0.1.3";
|
|
10
10
|
export const WEBHOOK_VERSION: "1";
|
|
11
11
|
export const WEBHOOK_EVENT_TYPES: readonly WebhookEventType[];
|
|
12
12
|
export const INTEGRATION_CAPABILITIES: readonly IntegrationCapability[];
|
|
@@ -209,9 +209,9 @@ export class TaprootIntegrationClient {
|
|
|
209
209
|
deleteManagedPage(input: { installationId: string; syncId?: string; externalId: string; idempotencyKey: string }): Promise<IntegrationSyncResult>;
|
|
210
210
|
putDataDocument(input: { installationId: string; syncId?: string; key: string; json: string; idempotencyKey: string }): Promise<IntegrationSyncResult>;
|
|
211
211
|
deleteDataDocument(input: { installationId: string; syncId?: string; key: string; idempotencyKey: string }): Promise<IntegrationSyncResult>;
|
|
212
|
-
requestMediaUpload(input: { installationId: string; fileName: string; contentType: string; fileSize: number; contentHash: string; width: number; height: number }): Promise<RequestMediaUploadResponse>;
|
|
212
|
+
requestMediaUpload(input: { installationId: string; fileName: string; contentType: string; fileSize: number; contentHash: string; width: number; height: number; operationKey?: string }): Promise<RequestMediaUploadResponse>;
|
|
213
213
|
confirmMediaUpload(input: { installationId: string; uploadId: string }): Promise<OperationResponse<"confirmMediaUpload">>;
|
|
214
|
-
putMedia(input: { installationId: string; fileName: string; contentType: string; fileSize: number; contentHash: string; width: number; height: number; body: Uint8Array | ArrayBuffer | string }): Promise<TaprootImage>;
|
|
214
|
+
putMedia(input: { installationId: string; fileName: string; contentType: string; fileSize: number; contentHash: string; width: number; height: number; body: Uint8Array | ArrayBuffer | string; operationKey?: string }): Promise<TaprootImage>;
|
|
215
215
|
uploadPresigned(input: { url: string; requiredHeaders?: Record<string, string>; body: Uint8Array | ArrayBuffer | string }): Promise<void>;
|
|
216
216
|
listPlacements(input: { installationId: string }): Promise<{ placements: IntegrationPlacement[] }>;
|
|
217
217
|
putFragment(input: { installationId: string; placementId: string; configurationRevision: number; expectedFragmentRevision?: number; html: string; structuredData?: string[]; syncId?: string; idempotencyKey: string }): Promise<IntegrationPlacementFragmentResult>;
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -334,10 +334,11 @@ export class TaprootIntegrationClient {
|
|
|
334
334
|
body: withIdempotency({ installationId: id, syncId, key: nonEmptyString(key, "invalid_content_key") }, idempotencyKey), retry: true });
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
-
requestMediaUpload({ installationId, fileName, contentType, fileSize, contentHash, width, height }) {
|
|
337
|
+
requestMediaUpload({ installationId, fileName, contentType, fileSize, contentHash, width, height, operationKey = createIdempotencyKey() }) {
|
|
338
338
|
const id = nonEmptyString(installationId, "invalid_installation_id");
|
|
339
|
+
const key = nonEmptyString(operationKey, "invalid_operation_key");
|
|
339
340
|
return this.#request({ path: operationPath("requestMediaUpload", { installationId: id }), credential: "installation",
|
|
340
|
-
body: { installationId: id, fileName: nonEmptyString(fileName, "invalid_file_name"), contentType: nonEmptyString(contentType, "invalid_content_type"), fileSize, contentHash: nonEmptyString(contentHash, "invalid_content_hash"), width, height } });
|
|
341
|
+
body: { installationId: id, fileName: nonEmptyString(fileName, "invalid_file_name"), contentType: nonEmptyString(contentType, "invalid_content_type"), fileSize, contentHash: nonEmptyString(contentHash, "invalid_content_hash"), width, height, operationKey: key } });
|
|
341
342
|
}
|
|
342
343
|
|
|
343
344
|
confirmMediaUpload({ installationId, uploadId }) {
|
|
@@ -345,8 +346,8 @@ export class TaprootIntegrationClient {
|
|
|
345
346
|
return this.#request({ path: operationPath("confirmMediaUpload", { installationId: id }), credential: "installation", body: { installationId: id, uploadId: nonEmptyString(uploadId, "invalid_upload_id") } });
|
|
346
347
|
}
|
|
347
348
|
|
|
348
|
-
async putMedia({ installationId, fileName, contentType, fileSize, contentHash, width, height, body }) {
|
|
349
|
-
const requested = await this.requestMediaUpload({ installationId, fileName, contentType, fileSize, contentHash, width, height });
|
|
349
|
+
async putMedia({ installationId, fileName, contentType, fileSize, contentHash, width, height, body, operationKey = createIdempotencyKey() }) {
|
|
350
|
+
const requested = await this.requestMediaUpload({ installationId, fileName, contentType, fileSize, contentHash, width, height, operationKey });
|
|
350
351
|
if (requested.isDuplicate) return requested.image;
|
|
351
352
|
await this.uploadPresigned({ url: requested.presignedUrl, requiredHeaders: requested.requiredHeaders, body });
|
|
352
353
|
return (await this.confirmMediaUpload({ installationId, uploadId: requested.uploadId })).image;
|
package/src/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { INTEGRATION_WEBHOOK_EVENTS } from "./openapi-contract.js";
|
|
2
2
|
|
|
3
|
-
export const INTEGRATION_SDK_VERSION = "0.1.
|
|
3
|
+
export const INTEGRATION_SDK_VERSION = "0.1.3";
|
|
4
4
|
export const WEBHOOK_VERSION = "1";
|
|
5
5
|
export const WEBHOOK_EVENT_TYPES = Object.freeze(Object.keys(INTEGRATION_WEBHOOK_EVENTS));
|
|
6
6
|
export const INTEGRATION_CAPABILITIES = Object.freeze([
|
|
@@ -26,7 +26,7 @@ export type PutIntegrationDataDocumentRequest = { "installationId"?: string; "sy
|
|
|
26
26
|
export type PutIntegrationFragmentRequest = { "installationId"?: string; "placementId"?: string; "configurationRevision"?: number; "expectedFragmentRevision"?: number; "html"?: string; "structuredData"?: Array<string>; "syncId"?: string; "idempotencyKey"?: string; };
|
|
27
27
|
export type RequestIntegrationBundleUploadRequest = { "integrationId"?: string; "contentHash"?: string; "byteLength"?: number; "runtimeMajor"?: number; };
|
|
28
28
|
export type RequestIntegrationBundleUploadResponse = { "uploadId"?: string; "presignedUrl"?: string; "requiredHeaders"?: { [key: string]: string; }; "expiresAt"?: string; "existingBundle"?: IntegrationBundle; "isDuplicate"?: boolean; };
|
|
29
|
-
export type RequestIntegrationMediaUploadRequest = { "installationId"?: string; "fileName"?: string; "contentType"?: string; "fileSize"?: number; "contentHash"?: string; "width"?: number; "height"?: number; };
|
|
29
|
+
export type RequestIntegrationMediaUploadRequest = { "installationId"?: string; "fileName"?: string; "contentType"?: string; "fileSize"?: number; "contentHash"?: string; "width"?: number; "height"?: number; "operationKey"?: string; };
|
|
30
30
|
export type RequestIntegrationMediaUploadResponse = { "presignedUrl"?: string; "uploadId"?: string; "isDuplicate"?: boolean; "image"?: TaprootImage; "requiredHeaders"?: { [key: string]: string; }; };
|
|
31
31
|
export type TaprootImage = { "imageId"?: string; "url"?: string; "height"?: number; "width"?: number; "fileSize"?: number; "uploadedName"?: string; "imageType"?: ImageType; "responsiveUrls"?: Array<ImageUrl>; "thumbHash"?: string; "processingState"?: ImageProcessingState; "ownershipScope"?: ImageOwnershipScope; "siteId"?: string; };
|
|
32
32
|
export type UpsertIntegrationPageRequest = { "installationId"?: string; "syncId"?: string; "idempotencyKey"?: string; "page"?: IntegrationManagedPageContent; };
|
package/src/openapi-contract.js
CHANGED