Skip to content

Commit

Permalink
bump to beta and cast
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi committed Oct 17, 2024
1 parent 5a28c60 commit f7563f3
Show file tree
Hide file tree
Showing 4 changed files with 269 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ jobs:
- name: Publish to npm
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --access public
npm publish --access public --tag beta
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fern-api/sdk",
"version": "0.13.0",
"version": "0.13.0-beta0",
"private": false,
"repository": "https://github.com/fern-api/typescript-sdk",
"license": "MIT",
Expand All @@ -19,7 +19,7 @@
"node-fetch": "2.7.0",
"qs": "6.11.2",
"js-base64": "3.7.2",
"@fern-api/template-resolver": "0.7.5"
"@fern-api/template-resolver": "0.8.1"
},
"devDependencies": {
"@types/url-join": "4.0.1",
Expand Down
29 changes: 25 additions & 4 deletions src/wrapper/Template.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Fern } from "../index";
import { SnippetTemplateResolver } from "@fern-api/template-resolver";
import { FdrClient, FdrAPI } from "@fern-api/fdr-sdk";

export class Template implements Fern.templates.EndpointSnippetTemplate {
private endpointSnippetTemplate: Fern.EndpointSnippetTemplate;
Expand All @@ -19,8 +20,16 @@ export class Template implements Fern.templates.EndpointSnippetTemplate {
*/
public resolve(payload: Fern.snippets.CustomSnippetPayload): Fern.snippets.Snippet {
const _innerResolver = new SnippetTemplateResolver({
payload,
endpointSnippetTemplate: this.endpointSnippetTemplate,
payload: {
...payload,
headers: payload.headers?.map((header): FdrAPI.ParameterPayload => { return { name: header.name, value: header.value ?? undefined } }),
pathParameters: payload.pathParameters?.map((header): FdrAPI.ParameterPayload => { return { name: header.name, value: header.value ?? undefined } }),
queryParameters: payload.queryParameters?.map((header): FdrAPI.ParameterPayload => { return { name: header.name, value: header.value ?? undefined } }),
requestBody: payload.requestBody ?? undefined,
auth: payload.auth ?? undefined,
},
endpointSnippetTemplate: this.endpointSnippetTemplate as FdrAPI.EndpointSnippetTemplate,
provideFdrClient: () => new FdrClient(),
});

return _innerResolver.resolve();
Expand All @@ -34,8 +43,16 @@ export class Template implements Fern.templates.EndpointSnippetTemplate {
*/
public async resolveFormatted(payload: Fern.snippets.CustomSnippetPayload): Promise<Fern.snippets.Snippet> {
const _innerResolver = new SnippetTemplateResolver({
payload,
endpointSnippetTemplate: this.endpointSnippetTemplate,
payload: {
...payload,
headers: payload.headers?.map((header): FdrAPI.ParameterPayload => { return { name: header.name, value: header.value ?? undefined } }),
pathParameters: payload.pathParameters?.map((header): FdrAPI.ParameterPayload => { return { name: header.name, value: header.value ?? undefined } }),
queryParameters: payload.queryParameters?.map((header): FdrAPI.ParameterPayload => { return { name: header.name, value: header.value ?? undefined } }),
requestBody: payload.requestBody ?? undefined,
auth: payload.auth ?? undefined,
},
endpointSnippetTemplate: this.endpointSnippetTemplate as FdrAPI.EndpointSnippetTemplate,
provideFdrClient: () => new FdrClient(),
});

return await _innerResolver.resolveWithFormatting();
Expand All @@ -48,4 +65,8 @@ export class Template implements Fern.templates.EndpointSnippetTemplate {
public static from(template: Fern.templates.EndpointSnippetTemplate): Template {
return new Template(template.sdk, template.endpointId, template.snippetTemplate);
}
}

export function isNonNullish<T>(x: T | null | undefined): x is T {
return x != null;
}
Loading

0 comments on commit f7563f3

Please sign in to comment.