Skip to content

Commit

Permalink
Fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanoverna committed Oct 26, 2023
1 parent 5a6f58c commit dc5f169
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 10 deletions.
192 changes: 192 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@
"@apidevtools/json-schema-ref-parser": "^9.0.9",
"@types/jest": "^29.5.6",
"@types/rimraf": "^3.0.2",
"@whatwg-node/fetch": "^0.9.14",
"cross-fetch": "^3.1.5",
"esbuild": "^0.14.34",
"handlebars": "^4.7.7",
"husky": "^8.0.2",
"hyperschema-to-ts": "^0.0.11",
"jest": "^29.7.0",
"lerna": "^4.0.0",
"lint-staged": "^13.1.0",
"rimraf": "^3.0.2",
"rome": "^11.0.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.7.0",
"typescript": "^4.6.3",
"rome": "^11.0.0",
"husky": "^8.0.2",
"lint-staged": "^13.1.0",
"cross-fetch": "^3.1.5"
"typescript": "^4.6.3"
},
"homepage": "https://github.com/datocms/js-rest-api-clients",
"repository": {
Expand Down
7 changes: 7 additions & 0 deletions packages/cma-client-node/__tests__/helpers/generateClients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {
ClientConfigOptions as CmaClientConfigOptions,
} from '../../src';

import { fetch as ponyfillFetch } from '@whatwg-node/fetch';

const fetchFn = typeof fetch === 'undefined' ? ponyfillFetch : fetch;

export async function generateNewDashboardClient(
config?: Partial<DashboardClientConfigOptions>,
) {
Expand All @@ -18,6 +22,7 @@ export async function generateNewDashboardClient(
const client = buildDashboardClient({
apiToken: null,
baseUrl: process.env.ACCOUNT_API_BASE_URL,
fetchFn,
});

const account = await client.account.create({
Expand All @@ -31,6 +36,7 @@ export async function generateNewDashboardClient(
...config,
apiToken: account.id,
baseUrl: process.env.ACCOUNT_API_BASE_URL,
fetchFn,
});
}

Expand All @@ -46,5 +52,6 @@ export async function generateNewCmaClient(
return buildCmaClient({
...config,
apiToken: site.readwrite_token!,
fetchFn,
});
}
5 changes: 4 additions & 1 deletion packages/cma-client-node/src/buildClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { ClientConfigOptions } from '@datocms/cma-client';
import { Client } from './Client';
import { fetch as ponyfillFetch } from '@whatwg-node/fetch';

const fetchFn = typeof fetch === 'undefined' ? ponyfillFetch : fetch;

export function buildClient(config: ClientConfigOptions) {
return new Client(config);
return new Client({ ...config, fetchFn });
}
7 changes: 7 additions & 0 deletions packages/cma-client/__tests__/helpers/generateClients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {
ClientConfigOptions as CmaClientConfigOptions,
} from '../../src';

import { fetch as ponyfillFetch } from '@whatwg-node/fetch';

const fetchFn = typeof fetch === 'undefined' ? ponyfillFetch : fetch;

export async function generateNewDashboardClient(
config?: Partial<DashboardClientConfigOptions>,
) {
Expand All @@ -18,6 +22,7 @@ export async function generateNewDashboardClient(
const client = buildDashboardClient({
apiToken: null,
baseUrl: process.env.ACCOUNT_API_BASE_URL,
fetchFn,
});

const account = await client.account.create({
Expand All @@ -31,6 +36,7 @@ export async function generateNewDashboardClient(
...config,
apiToken: account.id,
baseUrl: process.env.ACCOUNT_API_BASE_URL,
fetchFn,
});
}

Expand All @@ -46,5 +52,6 @@ export async function generateNewCmaClient(
return buildCmaClient({
...config,
apiToken: site.readwrite_token!,
fetchFn,
});
}
2 changes: 1 addition & 1 deletion packages/cma-client/src/generated/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class Client {
...this.config,
...options,
logFn: this.config.logFn || console.log,
userAgent: '@datocms/cma-client',
userAgent: '@datocms/cma-client v3.0.0',
baseUrl: this.baseUrl,
preCallStack: new Error().stack,
extraHeaders: {
Expand Down
Loading

0 comments on commit dc5f169

Please sign in to comment.