The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
[App] Small fixes (#17254)
Marie1731c3427e55
diff --git a/packages/twenty-docs/developers/extend/capabilities/apps.mdx b/packages/twenty-docs/developers/extend/capabilities/apps.mdxindex cddfbcf2c27..a8179a08031 100644--- a/packages/twenty-docs/developers/extend/capabilities/apps.mdx+++ b/packages/twenty-docs/developers/extend/capabilities/apps.mdx@@ -34,32 +34,32 @@ npx create-twenty-app@latest my-twenty-appcd my-twenty-app# Authenticate using your API key (you'll be prompted)-yarn auth+yarn auth:login# Start dev mode: automatically syncs local changes to your workspace-yarn dev+yarn app:dev```From here you can:```bash filename="Terminal"# Add a new entity to your application (guided)-yarn create-entity+yarn app:create-entity# Generate a typed Twenty client and workspace entity types-yarn generate+yarn app:generate# Run a one‑time sync (instead of watch mode)-yarn sync+yarn app:sync# Watch your application's functions logs-yarn logs+yarn app:logs# Uninstall the application from the current workspace-yarn uninstall+yarn app:uninstall# Display commands' help-yarn help+yarn app:help```See also: the CLI reference pages for [create-twenty-app](https://www.npmjs.com/package/create-twenty-app) and [twenty-sdk CLI](https://www.npmjs.com/package/twenty-sdk).@@ -159,13 +159,13 @@ At a high level:Later commands will add more files and folders:-- `yarn generate` will create a `generated/` folder (typed Twenty client + workspace types).-- `yarn create-entity` will add entity definition files under `src/app/` for your custom objects, functions, or roles.-+- `yarn app:generate` will create a `generated/` folder (typed Twenty client + workspace types).+- `yarn app:create-entity` will add entity definition files under `src/app/` for your custom objects, functions, or roles.+l## Authentication-The first time you run `yarn auth`, you'll be prompted for:+The first time you run `yarn auth:login`, you'll be prompted for:- API URL (defaults to http://localhost:3000 or your current workspace profile)- API key@@ -176,10 +176,10 @@ Examples:```bash filename="Terminal"# Login interactively (recommended)-yarn auth+yarn auth:login# Use a specific workspace profile-yarn auth --workspace my-custom-workspace+yarn auth:login --workspace my-custom-workspace```## Use the SDK resources (types & config)@@ -278,7 +278,7 @@ Key points:- The `universalIdentifier` must be unique and stable across deployments.- Each field requires a `name`, `type`, `label`, and its own stable `universalIdentifier`.- The `fields` array is optional — you can define objects without custom fields.-- You can scaffold new objects using `yarn create-entity`, which guides you through naming, fields, and relationships.+- You can scaffold new objects using `yarn app:create-entity`, which guides you through naming, fields, and relationships.<Note>**Base fields are created automatically.** When you define a custom object, Twenty automatically adds standard fields such as `name`, `createdAt`, `updatedAt`, `createdBy`, `position`, and `deletedAt`. You don't need to define these in your `fields` array — only add your custom fields.@@ -601,12 +601,12 @@ const handler = async (event: RoutePayload) => {You can create new functions in two ways:-- **Scaffolded**: Run `yarn create-entity` and choose the option to add a new function. This generates a starter file with a handler and config.+- **Scaffolded**: Run `yarn app:create-entity` and choose the option to add a new function. This generates a starter file with a handler and config.- **Manual**: Create a new `*.function.ts` file and use `defineFunction()`, following the same pattern.### Generated typed client-Run yarn generate to create a local typed client in generated/ based on your workspace schema. Use it in your functions:+Run yarn app:generate to create a local typed client in generated/ based on your workspace schema. Use it in your functions:```typescriptimport Twenty from './generated';@@ -615,7 +615,7 @@ const client = new Twenty();const { me } = await client.query({ me: { id: true, displayName: true } });```-The client is re-generated by `yarn generate`. Re-run after changing your objects and `yarn sync` or when onboarding to a new workspace.+The client is re-generated by `yarn app:generate`. Re-run after changing your objects and `yarn app:sync` or when onboarding to a new workspace.#### Runtime credentials in serverless functions@@ -659,13 +659,13 @@ Then add scripts like these:}```-Now you can run the same commands via Yarn, e.g. `yarn dev`, `yarn sync`, etc.+Now you can run the same commands via Yarn, e.g. `yarn app:dev`, `yarn app:sync`, etc.## Troubleshooting-- Authentication errors: run `yarn auth` and ensure your API key has the required permissions.+- Authentication errors: run `yarn auth:login` and ensure your API key has the required permissions.- Cannot connect to server: verify the API URL and that the Twenty server is reachable.-- Types or client missing/outdated: run `yarn generate` and then `yarn dev`.-- Dev mode not syncing: ensure `yarn dev` is running and that changes are not ignored by your environment.+- Types or client missing/outdated: run `yarn app:generate` and then `yarn app:dev`.+- Dev mode not syncing: ensure `yarn app:dev` is running and that changes are not ignored by your environment.Discord Help Channel: https://discord.com/channels/1130383047699738754/1130386664812982322diff --git a/packages/twenty-sdk/src/cli/utilities/generate/services/generate.service.ts b/packages/twenty-sdk/src/cli/utilities/generate/services/generate.service.tsindex 1d15e2d2ed8..be46d7ba38a 100644--- a/packages/twenty-sdk/src/cli/utilities/generate/services/generate.service.ts+++ b/packages/twenty-sdk/src/cli/utilities/generate/services/generate.service.ts@@ -86,6 +86,8 @@ const defaultOptions: ClientOptions = {export default class Twenty {private client: Client;+ private apiUrl: string;+ private authorizationToken: string;constructor(options?: ClientOptions) {const merged: ClientOptions = {@@ -98,6 +100,8 @@ export default class Twenty {};this.client = createClient(merged);+ this.apiUrl = merged.url;+ this.authorizationToken = merged.headers.Authorization;}query<R extends QueryGenqlSelection>(request: R & { __name?: string }) {@@ -126,10 +130,10 @@ export default class Twenty {form.append('0', new Blob([fileBuffer], { type: contentType }), filename);- const response = await fetch(\`\${process.env.TWENTY_API_URL}/graphql\`, {+ const response = await fetch(\`\${this.apiUrl}/graphql\`, {method: 'POST',headers: {- Authorization: \`Bearer \${process.env.TWENTY_API_KEY}\`,+ Authorization: this.authorizationToken,},body: form,});