-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(feat): introduce api diffing api for changelogs (#743)
- Loading branch information
Showing
75 changed files
with
662 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
imports: | ||
commons: commons.yml | ||
|
||
types: | ||
APIDiff: | ||
properties: | ||
endpointDiffs: list<EndpointDiff> | ||
|
||
EndpointDiff: | ||
properties: | ||
id: commons.EndpointIdentifier | ||
pathParameterDiff: PathParameterDiff | ||
queryParameterDiff: QueryParameterDiff | ||
requestBodyDiff: RequestBodyDiff | ||
responseBodyDiff: ResponseBodyDiff | ||
|
||
PathParameterDiff: | ||
properties: | ||
added: list<PathParameter> | ||
removed: list<PathParameter> | ||
|
||
PathParameter: | ||
properties: | ||
wireKey: string | ||
|
||
QueryParameterDiff: | ||
properties: | ||
added: list<QueryParameter> | ||
removed: list<QueryParameter> | ||
|
||
QueryParameter: | ||
properties: | ||
wireKey: string | ||
|
||
RequestBodyDiff: | ||
properties: | ||
added: list<RequestBodyParameter> | ||
removed: list<RequestBodyParameter> | ||
|
||
RequestBodyParameter: | ||
properties: | ||
wireKey: string | ||
|
||
ResponseBodyDiff: | ||
properties: | ||
added: list<ResponseBodyParameter> | ||
removed: list<ResponseBodyParameter> | ||
|
||
ResponseBodyParameter: | ||
properties: | ||
wireKey: string | ||
|
||
service: | ||
base-path: /registry | ||
auth: true | ||
endpoints: | ||
diff: | ||
method: GET | ||
path: /diff | ||
request: | ||
name: APIDiffRequest | ||
query-parameters: | ||
previousApiDefinitionId: | ||
type: commons.ApiDefinitionId | ||
docs: The id of the previous version of the api definition | ||
currentApiDefinitionId: | ||
type: commons.ApiDefinitionId | ||
docs: The id of the current version of the api definition | ||
response: | ||
type: APIDiff | ||
docs: The diff between the previous and current api definitions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
packages/fdr-sdk/src/client/generated/api/resources/diff/client/Client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* This file was auto-generated by Fern from our API Definition. | ||
*/ | ||
|
||
import * as environments from "../../../../environments"; | ||
import * as core from "../../../../core"; | ||
import * as FernRegistry from "../../.."; | ||
import urlJoin from "url-join"; | ||
|
||
export declare namespace Diff { | ||
interface Options { | ||
environment?: core.Supplier<environments.FernRegistryEnvironment | string>; | ||
token?: core.Supplier<core.BearerToken | undefined>; | ||
} | ||
|
||
interface RequestOptions { | ||
timeoutInSeconds?: number; | ||
maxRetries?: number; | ||
} | ||
} | ||
|
||
export class Diff { | ||
constructor(protected readonly _options: Diff.Options = {}) {} | ||
|
||
public async diff( | ||
request: FernRegistry.ApiDiffRequest, | ||
requestOptions?: Diff.RequestOptions | ||
): Promise<core.APIResponse<FernRegistry.ApiDiff, FernRegistry.diff.diff.Error>> { | ||
const { previousApiDefinitionId, currentApiDefinitionId } = request; | ||
const _queryParams: Record<string, string | string[] | object | object[]> = {}; | ||
_queryParams["previousApiDefinitionId"] = previousApiDefinitionId; | ||
_queryParams["currentApiDefinitionId"] = currentApiDefinitionId; | ||
const _response = await core.fetcher({ | ||
url: urlJoin( | ||
(await core.Supplier.get(this._options.environment)) ?? environments.FernRegistryEnvironment.Dev, | ||
"/registry/diff" | ||
), | ||
method: "GET", | ||
headers: { | ||
Authorization: await this._getAuthorizationHeader(), | ||
"X-Fern-Language": "JavaScript", | ||
"X-Fern-Runtime": core.RUNTIME.type, | ||
"X-Fern-Runtime-Version": core.RUNTIME.version, | ||
}, | ||
contentType: "application/json", | ||
queryParameters: _queryParams, | ||
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : undefined, | ||
maxRetries: requestOptions?.maxRetries, | ||
}); | ||
if (_response.ok) { | ||
return { | ||
ok: true, | ||
body: _response.body as FernRegistry.ApiDiff, | ||
}; | ||
} | ||
|
||
return { | ||
ok: false, | ||
error: FernRegistry.diff.diff.Error._unknown(_response.error), | ||
}; | ||
} | ||
|
||
protected async _getAuthorizationHeader() { | ||
const bearer = await core.Supplier.get(this._options.token); | ||
if (bearer != null) { | ||
return `Bearer ${bearer}`; | ||
} | ||
|
||
return undefined; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
packages/fdr-sdk/src/client/generated/api/resources/diff/client/diff.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* This file was auto-generated by Fern from our API Definition. | ||
*/ | ||
|
||
import * as FernRegistry from "../../.."; | ||
import * as core from "../../../../core"; | ||
|
||
export type Error = FernRegistry.diff.diff.Error._Unknown; | ||
|
||
export declare namespace Error { | ||
interface _Unknown { | ||
error: void; | ||
content: core.Fetcher.Error; | ||
} | ||
|
||
interface _Visitor<_Result> { | ||
_other: (value: core.Fetcher.Error) => _Result; | ||
} | ||
} | ||
|
||
export const Error = { | ||
_unknown: (fetcherError: core.Fetcher.Error): FernRegistry.diff.diff.Error._Unknown => { | ||
return { | ||
error: undefined, | ||
content: fetcherError, | ||
}; | ||
}, | ||
|
||
_visit: <_Result>( | ||
value: FernRegistry.diff.diff.Error, | ||
visitor: FernRegistry.diff.diff.Error._Visitor<_Result> | ||
): _Result => { | ||
switch (value.error) { | ||
default: | ||
return visitor._other(value as any); | ||
} | ||
}, | ||
} as const; |
2 changes: 2 additions & 0 deletions
2
packages/fdr-sdk/src/client/generated/api/resources/diff/client/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./requests"; | ||
export * as diff from "./diff"; |
16 changes: 16 additions & 0 deletions
16
packages/fdr-sdk/src/client/generated/api/resources/diff/client/requests/ApiDiffRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* This file was auto-generated by Fern from our API Definition. | ||
*/ | ||
|
||
import * as FernRegistry from "../../../.."; | ||
|
||
export interface ApiDiffRequest { | ||
/** | ||
* The id of the previous version of the api definition | ||
*/ | ||
previousApiDefinitionId: FernRegistry.ApiDefinitionId; | ||
/** | ||
* The id of the current version of the api definition | ||
*/ | ||
currentApiDefinitionId: FernRegistry.ApiDefinitionId; | ||
} |
1 change: 1 addition & 0 deletions
1
packages/fdr-sdk/src/client/generated/api/resources/diff/client/requests/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { ApiDiffRequest } from "./ApiDiffRequest"; |
2 changes: 2 additions & 0 deletions
2
packages/fdr-sdk/src/client/generated/api/resources/diff/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./types"; | ||
export * from "./client"; |
9 changes: 9 additions & 0 deletions
9
packages/fdr-sdk/src/client/generated/api/resources/diff/types/ApiDiff.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* This file was auto-generated by Fern from our API Definition. | ||
*/ | ||
|
||
import * as FernRegistry from "../../.."; | ||
|
||
export interface ApiDiff { | ||
endpointDiffs: FernRegistry.EndpointDiff[]; | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/fdr-sdk/src/client/generated/api/resources/diff/types/EndpointDiff.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* This file was auto-generated by Fern from our API Definition. | ||
*/ | ||
|
||
import * as FernRegistry from "../../.."; | ||
|
||
export interface EndpointDiff { | ||
id: FernRegistry.EndpointIdentifier; | ||
pathParameterDiff: FernRegistry.PathParameterDiff; | ||
queryParameterDiff: FernRegistry.QueryParameterDiff; | ||
requestBodyDiff: FernRegistry.RequestBodyDiff; | ||
responseBodyDiff: FernRegistry.ResponseBodyDiff; | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/fdr-sdk/src/client/generated/api/resources/diff/types/PathParameter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* This file was auto-generated by Fern from our API Definition. | ||
*/ | ||
|
||
export interface PathParameter { | ||
wireKey: string; | ||
} |
Oops, something went wrong.