# Intoduction Closes https://github.com/twentyhq/core-team-issues/issues/2289 In this PR all the clients becomes available under `twenty-sdk/clients`, this is a breaking change but generated was too vague and thats still the now or never best timing to do so ## CoreClient The core client is now shipped with a default stub empty class for both the schema and the client Allowing its import, will still raises typescript errors when consumed as generated but not generated ## MetadataClient The metadata client is workspace agnostic, it's now generated and commited in the repo. added a ci that prevents any schema desync due to twenty-server additions Same behavior than for the twenty-front generated graphql schema
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { readFile } from 'node:fs/promises';
|
|
import path from 'path';
|
|
|
|
import { CLIENTS_GENERATED_DIR } from '@/cli/constants/clients-dir';
|
|
import { ClientService } from '@/cli/utilities/client/client-service';
|
|
|
|
const TEMPLATE_PATH = path.resolve(
|
|
__dirname,
|
|
'..',
|
|
'src',
|
|
'cli',
|
|
'utilities',
|
|
'client',
|
|
'twenty-client-template.ts',
|
|
);
|
|
|
|
const main = async () => {
|
|
const outputPath = path.resolve(
|
|
__dirname,
|
|
'..',
|
|
CLIENTS_GENERATED_DIR,
|
|
'metadata',
|
|
);
|
|
|
|
const serverUrl = process.env.TWENTY_API_URL ?? 'http://localhost:3000';
|
|
const token = process.env.TWENTY_API_KEY;
|
|
const clientWrapperTemplateSource = await readFile(TEMPLATE_PATH, 'utf-8');
|
|
|
|
const clientService = new ClientService({
|
|
clientWrapperTemplateSource,
|
|
serverUrl,
|
|
token,
|
|
});
|
|
|
|
await clientService.generateMetadataClient({ outputPath });
|
|
|
|
console.log(`Metadata client generated at ${outputPath}`);
|
|
};
|
|
|
|
main().catch((error) => {
|
|
console.error('Failed to generate metadata client:', error);
|
|
process.exit(1);
|
|
});
|