Skip to content

Commit b6af300

Browse files
authored
refactor(examples): replace ACCOUNT_IDS constant with inline placeholders (#198)
Remove the centralised constants.ts file containing hardcoded account IDs and replace with inline placeholder values in each example file. This change addresses feedback from PR #148 review by @glebedel: - Account IDs should not be stored in shared constants - Examples are clearer with inline values that users replace directly - Avoids exposing internal implementation details Changes: - Delete examples/constants.ts with hardcoded account IDs - Update all example files to use inline placeholder accountId variables - Each example now has a clear comment: "Replace with your actual account ID" - Update README.md to reflect new pattern and remove constants.ts references Closes #196
1 parent 29ba8db commit b6af300

File tree

8 files changed

+34
-68
lines changed

8 files changed

+34
-68
lines changed

examples/README.md

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,15 @@ OPENAI_API_KEY=your_api_key_here
3838

3939
### 3. Configure Account IDs
4040

41-
Update the account IDs in [`constants.ts`](./constants.ts) with your actual integration account IDs:
41+
Each example includes a placeholder account ID that you need to replace with your actual StackOne account ID:
4242

4343
```typescript
44-
export const ACCOUNT_IDS = {
45-
// Human Resources Information System
46-
HRIS: "your_hris_account_id",
47-
48-
// Applicant Tracking System
49-
ATS: "your_ats_account_id",
50-
51-
// Customer Relationship Management
52-
CRM: "your_crm_account_id",
53-
54-
// Document Management System
55-
DOCUMENTS: "your_documents_account_id",
56-
57-
// Test account IDs (used in examples that don't make real API calls)
58-
TEST: {
59-
VALID: "test_account_id",
60-
OVERRIDE: "test_account_id_override",
61-
DIRECT: "test_account_id_direct",
62-
INVALID: "invalid_test_account_id",
63-
},
64-
};
44+
// Replace with your actual account ID from StackOne dashboard
45+
const accountId = 'your-hris-account-id';
6546
```
6647

48+
You can find your account IDs in the [StackOne dashboard](https://app.stackone.com).
49+
6750
## Running Examples
6851

6952
### Run Individual Examples
@@ -287,7 +270,7 @@ cd examples && pnpm test examples.spec.ts
287270
### Common Issues
288271

289272
1. **Authentication Errors**: Ensure `STACKONE_API_KEY` is set correctly
290-
2. **Account ID Errors**: Update account IDs in `constants.ts` with your actual values
273+
2. **Account ID Errors**: Update account ID placeholders in the example files with your actual values
291274
3. **Network Errors**: Check if you're behind a proxy or firewall
292275
4. **TypeScript Errors**: Ensure you're using compatible Node.js and TypeScript versions
293276

@@ -306,7 +289,7 @@ When adding new examples:
306289
3. Include proper error handling
307290
4. Add TypeScript types
308291
5. Test with the examples test suite
309-
6. Update `constants.ts` if new account IDs are needed
292+
6. Use inline placeholder account IDs with clear comments (e.g., `const accountId = 'your-hris-account-id';`)
310293

311294
## License
312295

examples/ai-sdk-integration.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ import process from 'node:process';
77
import { openai } from '@ai-sdk/openai';
88
import { StackOneToolSet } from '@stackone/ai';
99
import { generateText, stepCountIs } from 'ai';
10-
import { ACCOUNT_IDS } from './constants';
1110

1211
const apiKey = process.env.STACKONE_API_KEY;
1312
if (!apiKey) {
1413
console.error('STACKONE_API_KEY environment variable is required');
1514
process.exit(1);
1615
}
1716

17+
// Replace with your actual account ID from StackOne dashboard
18+
const accountId = 'your-hris-account-id';
19+
1820
const aiSdkIntegration = async (): Promise<void> => {
1921
// Initialise StackOne
2022
const toolset = new StackOneToolSet({
21-
accountId: ACCOUNT_IDS.HRIS,
23+
accountId,
2224
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
2325
});
2426

examples/constants.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

examples/human-in-the-loop.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ import process from 'node:process';
1111
import { openai } from '@ai-sdk/openai';
1212
import { type JsonDict, StackOneToolSet } from '@stackone/ai';
1313
import { generateText, stepCountIs } from 'ai';
14-
import { ACCOUNT_IDS } from './constants';
1514

1615
const apiKey = process.env.STACKONE_API_KEY;
1716
if (!apiKey) {
1817
console.error('STACKONE_API_KEY environment variable is required');
1918
process.exit(1);
2019
}
2120

21+
// Replace with your actual account ID from StackOne dashboard
22+
const accountId = 'your-hris-account-id';
23+
2224
interface ToolCall {
2325
toolName: string;
2426
args: Record<string, unknown>;
@@ -27,7 +29,7 @@ interface ToolCall {
2729
const humanInTheLoopExample = async (): Promise<void> => {
2830
// Create a toolset
2931
const toolset = new StackOneToolSet({
30-
accountId: ACCOUNT_IDS.HRIS,
32+
accountId,
3133
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
3234
});
3335

examples/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@
2727
* # Account IDs
2828
*
2929
* StackOne uses account IDs to identify different integrations.
30-
* See the example in the README for more details.
31-
*
32-
* This example will use the centralised account ID:
30+
* Replace the placeholder below with your actual account ID from the StackOne dashboard.
3331
*/
3432

3533
import process from 'node:process';
36-
import { ACCOUNT_IDS } from './constants';
3734

38-
const accountId = ACCOUNT_IDS.HRIS;
35+
// Replace with your actual account ID from StackOne dashboard
36+
const accountId = 'your-hris-account-id';
3937

4038
/**
4139
* # Quickstart

examples/meta-tools.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ import process from 'node:process';
1010
import { openai } from '@ai-sdk/openai';
1111
import { StackOneToolSet, Tools } from '@stackone/ai';
1212
import { generateText, stepCountIs } from 'ai';
13-
import { ACCOUNT_IDS } from './constants';
1413

1514
const apiKey = process.env.STACKONE_API_KEY;
1615
if (!apiKey) {
1716
console.error('STACKONE_API_KEY environment variable is required');
1817
process.exit(1);
1918
}
2019

20+
// Replace with your actual account ID from StackOne dashboard
21+
const accountId = 'your-hris-account-id';
22+
2123
/**
2224
* Example 1: Using meta tools with AI SDK for dynamic tool discovery
2325
*/
@@ -26,7 +28,7 @@ const metaToolsWithAISDK = async (): Promise<void> => {
2628

2729
// Initialise StackOne toolset
2830
const toolset = new StackOneToolSet({
29-
accountId: ACCOUNT_IDS.HRIS,
31+
accountId,
3032
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
3133
});
3234

@@ -64,7 +66,7 @@ const metaToolsWithOpenAI = async (): Promise<void> => {
6466

6567
// Initialise StackOne toolset
6668
const toolset = new StackOneToolSet({
67-
accountId: ACCOUNT_IDS.HRIS,
69+
accountId,
6870
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
6971
});
7072

@@ -118,7 +120,7 @@ const directMetaToolUsage = async (): Promise<void> => {
118120

119121
// Initialise toolset
120122
const toolset = new StackOneToolSet({
121-
accountId: ACCOUNT_IDS.HRIS,
123+
accountId,
122124
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
123125
});
124126

@@ -188,7 +190,7 @@ const dynamicToolRouter = async (): Promise<void> => {
188190
console.log('\n🔄 Example 4: Dynamic tool router\n');
189191

190192
const toolset = new StackOneToolSet({
191-
accountId: ACCOUNT_IDS.HRIS,
193+
accountId,
192194
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
193195
});
194196

examples/openai-integration.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@ import assert from 'node:assert';
66
import process from 'node:process';
77
import { StackOneToolSet } from '@stackone/ai';
88
import OpenAI from 'openai';
9-
import { ACCOUNT_IDS } from './constants';
109

1110
const apiKey = process.env.STACKONE_API_KEY;
1211
if (!apiKey) {
1312
console.error('STACKONE_API_KEY environment variable is required');
1413
process.exit(1);
1514
}
1615

16+
// Replace with your actual account ID from StackOne dashboard
17+
const accountId = 'your-hris-account-id';
18+
1719
const openaiIntegration = async (): Promise<void> => {
1820
// Initialise StackOne
1921
const toolset = new StackOneToolSet({
20-
accountId: ACCOUNT_IDS.HRIS,
22+
accountId,
2123
baseUrl: process.env.STACKONE_BASE_URL ?? 'https://api.stackone.com',
2224
});
2325

examples/planning.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
import { openai } from '@ai-sdk/openai';
1010
import { StackOneToolSet } from '@stackone/ai';
1111
import { generateText, stepCountIs } from 'ai';
12-
import { ACCOUNT_IDS } from './constants';
12+
13+
// Replace with your actual account IDs from StackOne dashboard
14+
const atsAccountId = 'your-ats-account-id';
15+
const hrisAccountId = 'your-hris-account-id';
1316

1417
export const planningModule = async (): Promise<void> => {
1518
const toolset = new StackOneToolSet();
@@ -19,7 +22,7 @@ export const planningModule = async (): Promise<void> => {
1922
input: 'Onboard the last new hire from Teamtailor to Workday',
2023
model: 'stackone-planner-latest',
2124
tools: ['hris_*', 'ats_*'],
22-
accountIds: [ACCOUNT_IDS.ATS, ACCOUNT_IDS.HRIS],
25+
accountIds: [atsAccountId, hrisAccountId],
2326
cache: true, // saves the plan to $HOME/.stackone/plans
2427
});
2528

0 commit comments

Comments
 (0)