Skip to content

Commit e55bc43

Browse files
committed
chore(partners): harmonize data-script env vars to TWENTY_API_*
The data scripts (seed, import-from-tft, migrate-partner-scope, purge-soft-deleted, configure-partner-rls) read TWENTY_PARTNERS_API_URL/KEY, while the SDK's CoreApiClient, the vitest setup, and .env.example all use TWENTY_API_URL/KEY. CoreApiClient hardcodes the TWENTY_API_* names, so that's the only achievable single convention — align the scripts to it. Removes the two-name split: the scripts now run against .env.local (and env-toolkit bundles) with no manual env mapping. Note: .env.prod must rename its TWENTY_PARTNERS_API_URL/KEY keys to TWENTY_API_URL/KEY for the :prod script variants to keep working (.env.prod is gitignored/local).
1 parent 1fde014 commit e55bc43

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

packages/twenty-apps/internal/twenty-partners/src/scripts/configure-partner-rls.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ type PredicateResult = {
216216
};
217217

218218
async function main() {
219-
const baseUrl = requireEnv('TWENTY_PARTNERS_API_URL').replace(/\/$/, '');
220-
const apiKey = requireEnv('TWENTY_PARTNERS_API_KEY');
219+
const baseUrl = requireEnv('TWENTY_API_URL').replace(/\/$/, '');
220+
const apiKey = requireEnv('TWENTY_API_KEY');
221221
const metadataUrl = `${baseUrl}/metadata`;
222222

223223
console.log(`[rls:configure] target: ${metadataUrl}`);

packages/twenty-apps/internal/twenty-partners/src/scripts/import-from-tft.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// queries for them. The local (target) workspace is written via CoreApiClient,
88
// exactly like seed.ts. Two separate credential sets, no collision:
99
// TFT -> TFT_API_URL / TFT_API_KEY (raw fetch)
10-
// local-> TWENTY_PARTNERS_API_URL / TWENTY_PARTNERS_API_KEY (CoreApiClient)
10+
// local-> TWENTY_API_URL / TWENTY_API_KEY (CoreApiClient)
1111
//
1212
// The local server rate-limits API calls (~100 / 60s), so existence checks are
1313
// batched into one `in` query per object (like seed.ts) and writes are paced.
@@ -18,7 +18,7 @@
1818
// Set IMPORT_APPLY=1 to actually write to the local workspace.
1919
//
2020
// TFT_API_URL=https://twentyfortwenty.twenty.com TFT_API_KEY=<tft key> \
21-
// TWENTY_PARTNERS_API_URL=http://localhost:2020 TWENTY_PARTNERS_API_KEY=<local key> \
21+
// TWENTY_API_URL=http://localhost:2020 TWENTY_API_KEY=<local key> \
2222
// [IMPORT_APPLY=1] \
2323
// tsx src/scripts/import-from-tft.ts
2424

@@ -135,8 +135,8 @@ const distinct = <TRow>(rows: TRow[], pick: (row: TRow) => unknown): string[] =>
135135
async function main() {
136136
console.log(`[import] mode: ${APPLY ? 'APPLY (writing to local)' : 'DRY-RUN (no writes)'}`);
137137
const local = new CoreApiClient({
138-
url: `${requireEnv('TWENTY_PARTNERS_API_URL').replace(/\/$/, '')}/graphql`,
139-
headers: { Authorization: `Bearer ${requireEnv('TWENTY_PARTNERS_API_KEY')}` },
138+
url: `${requireEnv('TWENTY_API_URL').replace(/\/$/, '')}/graphql`,
139+
headers: { Authorization: `Bearer ${requireEnv('TWENTY_API_KEY')}` },
140140
});
141141

142142
// Pace writes to stay under the local server's ~100 req/60s limit.

packages/twenty-apps/internal/twenty-partners/src/scripts/migrate-partner-scope.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ const requireEnv = (name: string): string => {
2222

2323
async function main() {
2424
const apply = process.env.MIGRATE_APPLY === '1';
25-
const url = `${requireEnv('TWENTY_PARTNERS_API_URL').replace(/\/$/, '')}/graphql`;
25+
const url = `${requireEnv('TWENTY_API_URL').replace(/\/$/, '')}/graphql`;
2626
const client = new CoreApiClient({
2727
url,
28-
headers: { Authorization: `Bearer ${requireEnv('TWENTY_PARTNERS_API_KEY')}` },
28+
headers: { Authorization: `Bearer ${requireEnv('TWENTY_API_KEY')}` },
2929
});
3030
console.log(`[migrate-scope] target: ${url}${apply ? 'APPLY' : 'dry-run'}`);
3131

packages/twenty-apps/internal/twenty-partners/src/scripts/purge-soft-deleted.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ const gql = async (url: string, key: string, query: string): Promise<any> => {
3838
};
3939

4040
async function main() {
41-
const url = requireEnv('TWENTY_PARTNERS_API_URL');
42-
const key = requireEnv('TWENTY_PARTNERS_API_KEY');
41+
const url = requireEnv('TWENTY_API_URL');
42+
const key = requireEnv('TWENTY_API_KEY');
4343
console.log(`[purge] target: ${url} — destroying soft-deleted rows only`);
4444

4545
for (const obj of OBJECTS) {

packages/twenty-apps/internal/twenty-partners/src/scripts/seed.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66
// Run from this app directory, against a running Twenty server with the app
77
// installed (deploy first; do NOT run `yarn test` after — its teardown wipes the app).
8-
// Credentials from shell env or a gitignored .env.local (TWENTY_PARTNERS_API_URL/KEY).
8+
// Credentials from shell env or a gitignored .env.local (TWENTY_API_URL/KEY).
99
//
1010
// yarn twenty dev --once
1111
// tsx src/scripts/seed.ts
@@ -114,8 +114,8 @@ const nodes = (r: any, key: string): any[] => (r?.[key]?.edges ?? []).map((e: an
114114

115115
async function main() {
116116
const client = new CoreApiClient({
117-
url: `${requireEnv('TWENTY_PARTNERS_API_URL').replace(/\/$/, '')}/graphql`,
118-
headers: { Authorization: `Bearer ${requireEnv('TWENTY_PARTNERS_API_KEY')}` },
117+
url: `${requireEnv('TWENTY_API_URL').replace(/\/$/, '')}/graphql`,
118+
headers: { Authorization: `Bearer ${requireEnv('TWENTY_API_KEY')}` },
119119
});
120120

121121
// -- Partners (upsert by slug) --

0 commit comments

Comments
 (0)