Skip to content

Commit 48c08a2

Browse files
committed
Add wrapper for Collection and Items Client to override fern change on wrapping certain requests with a body object
1 parent 34cd65a commit 48c08a2

File tree

9 files changed

+771
-4
lines changed

9 files changed

+771
-4
lines changed

src/wrapper/CollectionsClient.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @ts-nocheck
2+
3+
import { Collections } from "../api/resources/collections/client/Client";
4+
import { Client as Items } from "./ItemsClient";
5+
6+
declare module "../api/resources/collections/client/Client" {
7+
export namespace Collections {}
8+
}
9+
10+
// Client adapts the base client to permit extra properties in
11+
// the client.Collections.Items.createItem request.
12+
export class Client extends Collections {
13+
constructor(protected readonly _options: Collections.Options) {
14+
super(_options);
15+
}
16+
17+
protected _items: Items | undefined;
18+
19+
public get items(): Items {
20+
return (this._items ??= new Items(this._options));
21+
}
22+
}

src/wrapper/ItemsClient.ts

Lines changed: 713 additions & 0 deletions
Large diffs are not rendered by default.

src/wrapper/WebflowClient.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as errors from "../errors";
66
import { SDK_VERSION } from "../version";
77
import { Client as Webhooks } from "./WebhooksClient";
88
import { Client as Assets } from "./AssetsClient";
9+
import { Client as Collections } from "./CollectionsClient";
910

1011
export class WebflowClient extends FernClient {
1112
constructor(protected readonly _options: FernClient.Options) {
@@ -16,6 +17,8 @@ export class WebflowClient extends FernClient {
1617

1718
protected _assets: Assets | undefined;
1819

20+
protected _collections: Collections | undefined;
21+
1922
public get webhooks(): Webhooks {
2023
return (this._webhooks ??= new Webhooks(this._options));
2124
}
@@ -24,6 +27,9 @@ export class WebflowClient extends FernClient {
2427
return (this._assets ??= new Assets(this._options));
2528
}
2629

30+
public get collections(): Collections {
31+
return (this._collections ??= new Collections(this._options));
32+
}
2733

2834
/**
2935
* @param clientId The OAuth client ID
@@ -116,9 +122,7 @@ export class WebflowClient extends FernClient {
116122
body: response.error.rawBody,
117123
});
118124
case "timeout":
119-
throw new errors.WebflowTimeoutError(
120-
"Timeout exceeded when calling POST /oauth/token"
121-
);
125+
throw new errors.WebflowTimeoutError("Timeout exceeded when calling POST /oauth/token");
122126
case "unknown":
123127
throw new errors.WebflowError({
124128
message: response.error.errorMessage,

src/wrapper/WebhooksClient.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Webhooks } from "../api/resources/webhooks/client/Client";
2-
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../core/headers.js";
32
import crypto from "crypto";
43

54
// Extends the namespace declared in the Fern generated client
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// @ts-nocheck
2+
import { Webflow } from "../../index";
3+
4+
// Overriding this type to include skipInvalidFiles to prevent breaking change where Fern may wrap the existing request body in a `body` wrapper object
5+
export type ItemsCreateItemLiveRequest = Webflow.collections.ItemsCreateItemLiveRequestBody & {
6+
skipInvalidFiles?: boolean;
7+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Webflow } from "../../index";
2+
3+
// Overriding this type to include skipInvalidFiles to prevent breaking change where Fern may wrap the existing request body in a `body` wrapper object
4+
export type ItemsCreateItemRequest = (Webflow.CollectionItemPostSingle | Webflow.collections.MultipleItems) & {
5+
skipInvalidFiles?: boolean;
6+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Webflow } from "../../index";
2+
3+
// Overriding this type to include skipInvalidFiles to prevent breaking change where Fern may wrap the existing request body in a `body` wrapper object
4+
export type ItemsUpdateItemLiveRequest = Webflow.CollectionItemPatchSingle & {
5+
skipInvalidFiles?: boolean;
6+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Webflow } from "../../index";
2+
3+
// Overriding this type to include skipInvalidFiles to prevent breaking change where Fern may wrap the existing request body in a `body` wrapper object
4+
export type ItemsUpdateItemRequest = Webflow.CollectionItemPatchSingle & {
5+
skipInvalidFiles?: boolean;
6+
};

src/wrapper/schemas/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from "./ItemsCreateItemRequest";
2+
export * from "./ItemsUpdateItemRequest";
3+
export * from "./ItemsCreateItemLiveRequest";
4+
export * from "./ItemsUpdateItemLiveRequest";

0 commit comments

Comments
 (0)