@tinybirdco/sdk 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -4
- package/dist/api/local.d.ts +92 -0
- package/dist/api/local.d.ts.map +1 -0
- package/dist/api/local.js +176 -0
- package/dist/api/local.js.map +1 -0
- package/dist/api/local.test.d.ts +2 -0
- package/dist/api/local.test.d.ts.map +1 -0
- package/dist/api/local.test.js +182 -0
- package/dist/api/local.test.js.map +1 -0
- package/dist/cli/commands/build.d.ts +3 -0
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +97 -47
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/dev.d.ts +9 -2
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +56 -31
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/config.d.ts +14 -0
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +7 -0
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/config.test.js +29 -0
- package/dist/cli/config.test.js.map +1 -1
- package/dist/cli/index.js +39 -3
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/local.test.ts +250 -0
- package/src/api/local.ts +270 -0
- package/src/cli/commands/build.ts +120 -54
- package/src/cli/commands/dev.ts +76 -38
- package/src/cli/config.test.ts +47 -0
- package/src/cli/config.ts +20 -0
- package/src/cli/index.ts +39 -3
package/README.md
CHANGED
|
@@ -174,6 +174,7 @@ Build and push resources to Tinybird.
|
|
|
174
174
|
```bash
|
|
175
175
|
npx tinybird build
|
|
176
176
|
npx tinybird build --dry-run # Preview without pushing
|
|
177
|
+
npx tinybird build --local # Build to local Tinybird container
|
|
177
178
|
```
|
|
178
179
|
|
|
179
180
|
### `npx tinybird dev`
|
|
@@ -182,6 +183,7 @@ Watch for changes and sync with Tinybird automatically.
|
|
|
182
183
|
|
|
183
184
|
```bash
|
|
184
185
|
npx tinybird dev
|
|
186
|
+
npx tinybird dev --local # Sync with local Tinybird container
|
|
185
187
|
```
|
|
186
188
|
|
|
187
189
|
## Configuration
|
|
@@ -195,13 +197,45 @@ Create a `tinybird.json` in your project root:
|
|
|
195
197
|
"src/tinybird/pipes.ts"
|
|
196
198
|
],
|
|
197
199
|
"token": "${TINYBIRD_TOKEN}",
|
|
198
|
-
"baseUrl": "https://api.tinybird.co"
|
|
200
|
+
"baseUrl": "https://api.tinybird.co",
|
|
201
|
+
"devMode": "branch"
|
|
199
202
|
}
|
|
200
203
|
```
|
|
201
204
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
### Configuration Options
|
|
206
|
+
|
|
207
|
+
| Option | Type | Default | Description |
|
|
208
|
+
|--------|------|---------|-------------|
|
|
209
|
+
| `include` | `string[]` | *required* | Array of TypeScript files to scan for datasources and pipes |
|
|
210
|
+
| `token` | `string` | *required* | API token. Supports `${ENV_VAR}` interpolation for environment variables |
|
|
211
|
+
| `baseUrl` | `string` | `"https://api.tinybird.co"` | Tinybird API URL. Use `"https://api.us-east.tinybird.co"` for US region |
|
|
212
|
+
| `devMode` | `"branch"` \| `"local"` | `"branch"` | Development mode. `"branch"` uses Tinybird cloud with branches, `"local"` uses local Docker container |
|
|
213
|
+
|
|
214
|
+
### Local Development Mode
|
|
215
|
+
|
|
216
|
+
Use a local Tinybird container for development without affecting your cloud workspace:
|
|
217
|
+
|
|
218
|
+
1. Start the local container:
|
|
219
|
+
```bash
|
|
220
|
+
docker run -d -p 7181:7181 --name tinybird-local tinybirdco/tinybird-local:latest
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
2. Configure your project:
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"devMode": "local"
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Or use the CLI flag:
|
|
231
|
+
```bash
|
|
232
|
+
npx tinybird dev --local
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
In local mode:
|
|
236
|
+
- Tokens are automatically obtained from the local container
|
|
237
|
+
- A workspace is created per git branch
|
|
238
|
+
- No cloud authentication required
|
|
205
239
|
|
|
206
240
|
## Defining Resources
|
|
207
241
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Tinybird container API client
|
|
3
|
+
* For use with tinybird-local Docker image
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Tokens returned by the local /tokens endpoint
|
|
7
|
+
*/
|
|
8
|
+
export interface LocalTokens {
|
|
9
|
+
/** User token for user-level operations */
|
|
10
|
+
user_token: string;
|
|
11
|
+
/** Admin token for admin operations like listing workspaces */
|
|
12
|
+
admin_token: string;
|
|
13
|
+
/** Default workspace admin token */
|
|
14
|
+
workspace_admin_token: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Workspace info from local Tinybird
|
|
18
|
+
*/
|
|
19
|
+
export interface LocalWorkspace {
|
|
20
|
+
/** Workspace ID */
|
|
21
|
+
id: string;
|
|
22
|
+
/** Workspace name */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Workspace token */
|
|
25
|
+
token: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Error thrown when local container is not running
|
|
29
|
+
*/
|
|
30
|
+
export declare class LocalNotRunningError extends Error {
|
|
31
|
+
constructor();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Error thrown by local API operations
|
|
35
|
+
*/
|
|
36
|
+
export declare class LocalApiError extends Error {
|
|
37
|
+
readonly status?: number | undefined;
|
|
38
|
+
readonly body?: unknown | undefined;
|
|
39
|
+
constructor(message: string, status?: number | undefined, body?: unknown | undefined);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Check if local Tinybird container is running
|
|
43
|
+
*
|
|
44
|
+
* @returns true if container is running and healthy
|
|
45
|
+
*/
|
|
46
|
+
export declare function isLocalRunning(): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Get tokens from local Tinybird container
|
|
49
|
+
*
|
|
50
|
+
* @returns Local tokens
|
|
51
|
+
* @throws LocalNotRunningError if container is not running
|
|
52
|
+
*/
|
|
53
|
+
export declare function getLocalTokens(): Promise<LocalTokens>;
|
|
54
|
+
/**
|
|
55
|
+
* List workspaces in local Tinybird
|
|
56
|
+
*
|
|
57
|
+
* @param adminToken - Admin token from getLocalTokens()
|
|
58
|
+
* @returns List of workspaces with their info
|
|
59
|
+
*/
|
|
60
|
+
export declare function listLocalWorkspaces(adminToken: string): Promise<{
|
|
61
|
+
workspaces: LocalWorkspace[];
|
|
62
|
+
organizationId?: string;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Create a workspace in local Tinybird
|
|
66
|
+
*
|
|
67
|
+
* @param userToken - User token from getLocalTokens()
|
|
68
|
+
* @param workspaceName - Name for the new workspace
|
|
69
|
+
* @param organizationId - Organization ID to assign workspace to
|
|
70
|
+
* @returns Created workspace info
|
|
71
|
+
*/
|
|
72
|
+
export declare function createLocalWorkspace(userToken: string, workspaceName: string, organizationId?: string): Promise<LocalWorkspace>;
|
|
73
|
+
/**
|
|
74
|
+
* Get or create a workspace in local Tinybird
|
|
75
|
+
*
|
|
76
|
+
* @param tokens - Tokens from getLocalTokens()
|
|
77
|
+
* @param workspaceName - Name of the workspace to get or create
|
|
78
|
+
* @returns Workspace info and whether it was newly created
|
|
79
|
+
*/
|
|
80
|
+
export declare function getOrCreateLocalWorkspace(tokens: LocalTokens, workspaceName: string): Promise<{
|
|
81
|
+
workspace: LocalWorkspace;
|
|
82
|
+
wasCreated: boolean;
|
|
83
|
+
}>;
|
|
84
|
+
/**
|
|
85
|
+
* Get workspace name for local mode based on git branch or path
|
|
86
|
+
*
|
|
87
|
+
* @param tinybirdBranch - Sanitized git branch name (or null if not in git)
|
|
88
|
+
* @param cwd - Current working directory (used for hash if no branch)
|
|
89
|
+
* @returns Workspace name to use
|
|
90
|
+
*/
|
|
91
|
+
export declare function getLocalWorkspaceName(tinybirdBranch: string | null, cwd: string): string;
|
|
92
|
+
//# sourceMappingURL=local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../src/api/local.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,mBAAmB;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAcD;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;;CAQ9C;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;aAGpB,MAAM,CAAC,EAAE,MAAM;aACf,IAAI,CAAC,EAAE,OAAO;gBAF9B,OAAO,EAAE,MAAM,EACC,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,IAAI,CAAC,EAAE,OAAO,YAAA;CAKjC;AAED;;;;GAIG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAUvD;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CA+B3D;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC;IAAE,UAAU,EAAE,cAAc,EAAE,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA0BpE;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,cAAc,CAAC,CAkCzB;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,WAAW,EACnB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,SAAS,EAAE,cAAc,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CA4B7D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,MAAM,GAAG,IAAI,EAC7B,GAAG,EAAE,MAAM,GACV,MAAM,CAQR"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Tinybird container API client
|
|
3
|
+
* For use with tinybird-local Docker image
|
|
4
|
+
*/
|
|
5
|
+
import * as crypto from "crypto";
|
|
6
|
+
import { LOCAL_BASE_URL } from "../cli/config.js";
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when local container is not running
|
|
9
|
+
*/
|
|
10
|
+
export class LocalNotRunningError extends Error {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(`Tinybird local is not running. Start it with:\n` +
|
|
13
|
+
`docker run -d -p 7181:7181 --name tinybird-local tinybirdco/tinybird-local:latest`);
|
|
14
|
+
this.name = "LocalNotRunningError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Error thrown by local API operations
|
|
19
|
+
*/
|
|
20
|
+
export class LocalApiError extends Error {
|
|
21
|
+
status;
|
|
22
|
+
body;
|
|
23
|
+
constructor(message, status, body) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.status = status;
|
|
26
|
+
this.body = body;
|
|
27
|
+
this.name = "LocalApiError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if local Tinybird container is running
|
|
32
|
+
*
|
|
33
|
+
* @returns true if container is running and healthy
|
|
34
|
+
*/
|
|
35
|
+
export async function isLocalRunning() {
|
|
36
|
+
try {
|
|
37
|
+
const response = await fetch(`${LOCAL_BASE_URL}/tokens`, {
|
|
38
|
+
method: "GET",
|
|
39
|
+
signal: AbortSignal.timeout(5000),
|
|
40
|
+
});
|
|
41
|
+
return response.ok;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get tokens from local Tinybird container
|
|
49
|
+
*
|
|
50
|
+
* @returns Local tokens
|
|
51
|
+
* @throws LocalNotRunningError if container is not running
|
|
52
|
+
*/
|
|
53
|
+
export async function getLocalTokens() {
|
|
54
|
+
try {
|
|
55
|
+
const response = await fetch(`${LOCAL_BASE_URL}/tokens`, {
|
|
56
|
+
method: "GET",
|
|
57
|
+
signal: AbortSignal.timeout(5000),
|
|
58
|
+
});
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
throw new LocalApiError(`Failed to get local tokens: ${response.status} ${response.statusText}`, response.status);
|
|
61
|
+
}
|
|
62
|
+
const tokens = (await response.json());
|
|
63
|
+
// Validate response structure
|
|
64
|
+
if (!tokens.user_token || !tokens.admin_token || !tokens.workspace_admin_token) {
|
|
65
|
+
throw new LocalApiError("Invalid tokens response from local Tinybird - missing required fields");
|
|
66
|
+
}
|
|
67
|
+
return tokens;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (error instanceof LocalApiError) {
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
// Connection error - container not running
|
|
74
|
+
throw new LocalNotRunningError();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* List workspaces in local Tinybird
|
|
79
|
+
*
|
|
80
|
+
* @param adminToken - Admin token from getLocalTokens()
|
|
81
|
+
* @returns List of workspaces with their info
|
|
82
|
+
*/
|
|
83
|
+
export async function listLocalWorkspaces(adminToken) {
|
|
84
|
+
const url = `${LOCAL_BASE_URL}/v1/user/workspaces?with_organization=true&token=${adminToken}`;
|
|
85
|
+
const response = await fetch(url, {
|
|
86
|
+
method: "GET",
|
|
87
|
+
});
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
const body = await response.text();
|
|
90
|
+
throw new LocalApiError(`Failed to list local workspaces: ${response.status} ${response.statusText}`, response.status, body);
|
|
91
|
+
}
|
|
92
|
+
const data = (await response.json());
|
|
93
|
+
return {
|
|
94
|
+
workspaces: data.workspaces.map((ws) => ({
|
|
95
|
+
id: ws.id,
|
|
96
|
+
name: ws.name,
|
|
97
|
+
token: ws.token,
|
|
98
|
+
})),
|
|
99
|
+
organizationId: data.organization_id,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a workspace in local Tinybird
|
|
104
|
+
*
|
|
105
|
+
* @param userToken - User token from getLocalTokens()
|
|
106
|
+
* @param workspaceName - Name for the new workspace
|
|
107
|
+
* @param organizationId - Organization ID to assign workspace to
|
|
108
|
+
* @returns Created workspace info
|
|
109
|
+
*/
|
|
110
|
+
export async function createLocalWorkspace(userToken, workspaceName, organizationId) {
|
|
111
|
+
const url = `${LOCAL_BASE_URL}/v1/workspaces`;
|
|
112
|
+
const formData = new URLSearchParams();
|
|
113
|
+
formData.append("name", workspaceName);
|
|
114
|
+
if (organizationId) {
|
|
115
|
+
formData.append("assign_to_organization_id", organizationId);
|
|
116
|
+
}
|
|
117
|
+
const response = await fetch(url, {
|
|
118
|
+
method: "POST",
|
|
119
|
+
headers: {
|
|
120
|
+
Authorization: `Bearer ${userToken}`,
|
|
121
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
122
|
+
},
|
|
123
|
+
body: formData.toString(),
|
|
124
|
+
});
|
|
125
|
+
if (!response.ok) {
|
|
126
|
+
const responseBody = await response.text();
|
|
127
|
+
throw new LocalApiError(`Failed to create local workspace: ${response.status} ${response.statusText}`, response.status, responseBody);
|
|
128
|
+
}
|
|
129
|
+
const data = (await response.json());
|
|
130
|
+
return {
|
|
131
|
+
id: data.id,
|
|
132
|
+
name: data.name,
|
|
133
|
+
token: data.token,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get or create a workspace in local Tinybird
|
|
138
|
+
*
|
|
139
|
+
* @param tokens - Tokens from getLocalTokens()
|
|
140
|
+
* @param workspaceName - Name of the workspace to get or create
|
|
141
|
+
* @returns Workspace info and whether it was newly created
|
|
142
|
+
*/
|
|
143
|
+
export async function getOrCreateLocalWorkspace(tokens, workspaceName) {
|
|
144
|
+
// List existing workspaces
|
|
145
|
+
const { workspaces, organizationId } = await listLocalWorkspaces(tokens.admin_token);
|
|
146
|
+
// Check if workspace already exists
|
|
147
|
+
const existing = workspaces.find((ws) => ws.name === workspaceName);
|
|
148
|
+
if (existing) {
|
|
149
|
+
return { workspace: existing, wasCreated: false };
|
|
150
|
+
}
|
|
151
|
+
// Create new workspace
|
|
152
|
+
await createLocalWorkspace(tokens.user_token, workspaceName, organizationId);
|
|
153
|
+
// Fetch the workspace again to get the token (create response may not include it)
|
|
154
|
+
const { workspaces: updatedWorkspaces } = await listLocalWorkspaces(tokens.admin_token);
|
|
155
|
+
const newWorkspace = updatedWorkspaces.find((ws) => ws.name === workspaceName);
|
|
156
|
+
if (!newWorkspace) {
|
|
157
|
+
throw new LocalApiError(`Created workspace '${workspaceName}' but could not find it in workspace list`);
|
|
158
|
+
}
|
|
159
|
+
return { workspace: newWorkspace, wasCreated: true };
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get workspace name for local mode based on git branch or path
|
|
163
|
+
*
|
|
164
|
+
* @param tinybirdBranch - Sanitized git branch name (or null if not in git)
|
|
165
|
+
* @param cwd - Current working directory (used for hash if no branch)
|
|
166
|
+
* @returns Workspace name to use
|
|
167
|
+
*/
|
|
168
|
+
export function getLocalWorkspaceName(tinybirdBranch, cwd) {
|
|
169
|
+
if (tinybirdBranch) {
|
|
170
|
+
return tinybirdBranch;
|
|
171
|
+
}
|
|
172
|
+
// No branch detected - use hash of path like Python implementation
|
|
173
|
+
const hash = crypto.createHash("sha256").update(cwd).digest("hex");
|
|
174
|
+
return `Build_${hash.substring(0, 16)}`;
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/api/local.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAsClD;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C;QACE,KAAK,CACH,iDAAiD;YAC/C,mFAAmF,CACtF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAGpB;IACA;IAHlB,YACE,OAAe,EACC,MAAe,EACf,IAAc;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,WAAM,GAAN,MAAM,CAAS;QACf,SAAI,GAAJ,IAAI,CAAU;QAG9B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,cAAc,SAAS,EAAE;YACvD,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;SAClC,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,c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UAAU,qBAAqB,CACnC,cAA6B,EAC7B,GAAW;IAEX,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,mEAAmE;IACnE,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnE,OAAO,SAAS,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.test.d.ts","sourceRoot":"","sources":["../../src/api/local.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, afterEach, afterAll } from "vitest";
|
|
2
|
+
import { setupServer } from "msw/node";
|
|
3
|
+
import { http, HttpResponse } from "msw";
|
|
4
|
+
import { getLocalTokens, listLocalWorkspaces, createLocalWorkspace, getOrCreateLocalWorkspace, isLocalRunning, getLocalWorkspaceName, LocalNotRunningError, LocalApiError, } from "./local.js";
|
|
5
|
+
import { LOCAL_BASE_URL } from "../cli/config.js";
|
|
6
|
+
const server = setupServer();
|
|
7
|
+
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
|
8
|
+
afterEach(() => server.resetHandlers());
|
|
9
|
+
afterAll(() => server.close());
|
|
10
|
+
describe("Local API", () => {
|
|
11
|
+
describe("isLocalRunning", () => {
|
|
12
|
+
it("returns true when local container is running", async () => {
|
|
13
|
+
server.use(http.get(`${LOCAL_BASE_URL}/tokens`, () => {
|
|
14
|
+
return HttpResponse.json({
|
|
15
|
+
user_token: "user-token",
|
|
16
|
+
admin_token: "admin-token",
|
|
17
|
+
workspace_admin_token: "workspace-token",
|
|
18
|
+
});
|
|
19
|
+
}));
|
|
20
|
+
const result = await isLocalRunning();
|
|
21
|
+
expect(result).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
it("returns false when local container is not running", async () => {
|
|
24
|
+
server.use(http.get(`${LOCAL_BASE_URL}/tokens`, () => {
|
|
25
|
+
return HttpResponse.error();
|
|
26
|
+
}));
|
|
27
|
+
const result = await isLocalRunning();
|
|
28
|
+
expect(result).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe("getLocalTokens", () => {
|
|
32
|
+
it("returns tokens from local container", async () => {
|
|
33
|
+
server.use(http.get(`${LOCAL_BASE_URL}/tokens`, () => {
|
|
34
|
+
return HttpResponse.json({
|
|
35
|
+
user_token: "user-token-123",
|
|
36
|
+
admin_token: "admin-token-456",
|
|
37
|
+
workspace_admin_token: "workspace-token-789",
|
|
38
|
+
});
|
|
39
|
+
}));
|
|
40
|
+
const tokens = await getLocalTokens();
|
|
41
|
+
expect(tokens.user_token).toBe("user-token-123");
|
|
42
|
+
expect(tokens.admin_token).toBe("admin-token-456");
|
|
43
|
+
expect(tokens.workspace_admin_token).toBe("workspace-token-789");
|
|
44
|
+
});
|
|
45
|
+
it("throws LocalNotRunningError when container is not running", async () => {
|
|
46
|
+
server.use(http.get(`${LOCAL_BASE_URL}/tokens`, () => {
|
|
47
|
+
return HttpResponse.error();
|
|
48
|
+
}));
|
|
49
|
+
await expect(getLocalTokens()).rejects.toThrow(LocalNotRunningError);
|
|
50
|
+
});
|
|
51
|
+
it("throws LocalApiError when response is invalid", async () => {
|
|
52
|
+
server.use(http.get(`${LOCAL_BASE_URL}/tokens`, () => {
|
|
53
|
+
return HttpResponse.json({
|
|
54
|
+
// Missing required fields
|
|
55
|
+
user_token: "user-token",
|
|
56
|
+
});
|
|
57
|
+
}));
|
|
58
|
+
await expect(getLocalTokens()).rejects.toThrow(LocalApiError);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
describe("listLocalWorkspaces", () => {
|
|
62
|
+
it("returns list of workspaces", async () => {
|
|
63
|
+
server.use(http.get(`${LOCAL_BASE_URL}/v1/user/workspaces`, () => {
|
|
64
|
+
return HttpResponse.json({
|
|
65
|
+
organization_id: "org-123",
|
|
66
|
+
workspaces: [
|
|
67
|
+
{ id: "ws-1", name: "Workspace1", token: "token-1" },
|
|
68
|
+
{ id: "ws-2", name: "Workspace2", token: "token-2" },
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
}));
|
|
72
|
+
const result = await listLocalWorkspaces("admin-token");
|
|
73
|
+
expect(result.organizationId).toBe("org-123");
|
|
74
|
+
expect(result.workspaces).toHaveLength(2);
|
|
75
|
+
expect(result.workspaces[0]).toEqual({
|
|
76
|
+
id: "ws-1",
|
|
77
|
+
name: "Workspace1",
|
|
78
|
+
token: "token-1",
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
it("throws LocalApiError on failure", async () => {
|
|
82
|
+
server.use(http.get(`${LOCAL_BASE_URL}/v1/user/workspaces`, () => {
|
|
83
|
+
return new HttpResponse("Not found", { status: 404 });
|
|
84
|
+
}));
|
|
85
|
+
await expect(listLocalWorkspaces("admin-token")).rejects.toThrow(LocalApiError);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
describe("createLocalWorkspace", () => {
|
|
89
|
+
it("creates a new workspace", async () => {
|
|
90
|
+
server.use(http.post(`${LOCAL_BASE_URL}/v1/workspaces`, async ({ request }) => {
|
|
91
|
+
const formData = await request.text();
|
|
92
|
+
const params = new URLSearchParams(formData);
|
|
93
|
+
return HttpResponse.json({
|
|
94
|
+
id: "new-ws-id",
|
|
95
|
+
name: params.get("name"),
|
|
96
|
+
token: "new-ws-token",
|
|
97
|
+
});
|
|
98
|
+
}));
|
|
99
|
+
const result = await createLocalWorkspace("user-token", "TestWorkspace");
|
|
100
|
+
expect(result.id).toBe("new-ws-id");
|
|
101
|
+
expect(result.name).toBe("TestWorkspace");
|
|
102
|
+
expect(result.token).toBe("new-ws-token");
|
|
103
|
+
});
|
|
104
|
+
it("throws LocalApiError on failure", async () => {
|
|
105
|
+
server.use(http.post(`${LOCAL_BASE_URL}/v1/workspaces`, () => {
|
|
106
|
+
return new HttpResponse("Server error", { status: 500 });
|
|
107
|
+
}));
|
|
108
|
+
await expect(createLocalWorkspace("user-token", "TestWorkspace")).rejects.toThrow(LocalApiError);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
describe("getOrCreateLocalWorkspace", () => {
|
|
112
|
+
const tokens = {
|
|
113
|
+
user_token: "user-token",
|
|
114
|
+
admin_token: "admin-token",
|
|
115
|
+
workspace_admin_token: "default-token",
|
|
116
|
+
};
|
|
117
|
+
it("returns existing workspace if found", async () => {
|
|
118
|
+
server.use(http.get(`${LOCAL_BASE_URL}/v1/user/workspaces`, () => {
|
|
119
|
+
return HttpResponse.json({
|
|
120
|
+
organization_id: "org-123",
|
|
121
|
+
workspaces: [
|
|
122
|
+
{ id: "existing-ws", name: "MyWorkspace", token: "existing-token" },
|
|
123
|
+
],
|
|
124
|
+
});
|
|
125
|
+
}));
|
|
126
|
+
const result = await getOrCreateLocalWorkspace(tokens, "MyWorkspace");
|
|
127
|
+
expect(result.wasCreated).toBe(false);
|
|
128
|
+
expect(result.workspace.name).toBe("MyWorkspace");
|
|
129
|
+
expect(result.workspace.token).toBe("existing-token");
|
|
130
|
+
});
|
|
131
|
+
it("creates new workspace if not found", async () => {
|
|
132
|
+
let createCalled = false;
|
|
133
|
+
server.use(http.get(`${LOCAL_BASE_URL}/v1/user/workspaces`, () => {
|
|
134
|
+
// Return different response based on whether create was called
|
|
135
|
+
if (createCalled) {
|
|
136
|
+
return HttpResponse.json({
|
|
137
|
+
organization_id: "org-123",
|
|
138
|
+
workspaces: [
|
|
139
|
+
{ id: "new-ws", name: "NewWorkspace", token: "new-token" },
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return HttpResponse.json({
|
|
144
|
+
organization_id: "org-123",
|
|
145
|
+
workspaces: [], // Empty initially
|
|
146
|
+
});
|
|
147
|
+
}), http.post(`${LOCAL_BASE_URL}/v1/workspaces`, () => {
|
|
148
|
+
createCalled = true;
|
|
149
|
+
return HttpResponse.json({
|
|
150
|
+
id: "new-ws",
|
|
151
|
+
name: "NewWorkspace",
|
|
152
|
+
token: "new-token",
|
|
153
|
+
});
|
|
154
|
+
}));
|
|
155
|
+
const result = await getOrCreateLocalWorkspace(tokens, "NewWorkspace");
|
|
156
|
+
expect(result.wasCreated).toBe(true);
|
|
157
|
+
expect(result.workspace.name).toBe("NewWorkspace");
|
|
158
|
+
expect(result.workspace.token).toBe("new-token");
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
describe("getLocalWorkspaceName", () => {
|
|
162
|
+
it("uses branch name when available", () => {
|
|
163
|
+
const name = getLocalWorkspaceName("feature_branch", "/some/path");
|
|
164
|
+
expect(name).toBe("feature_branch");
|
|
165
|
+
});
|
|
166
|
+
it("uses hash-based name when no branch", () => {
|
|
167
|
+
const name = getLocalWorkspaceName(null, "/some/path");
|
|
168
|
+
expect(name).toMatch(/^Build_[a-f0-9]{16}$/);
|
|
169
|
+
});
|
|
170
|
+
it("generates consistent hash for same path", () => {
|
|
171
|
+
const name1 = getLocalWorkspaceName(null, "/same/path");
|
|
172
|
+
const name2 = getLocalWorkspaceName(null, "/same/path");
|
|
173
|
+
expect(name1).toBe(name2);
|
|
174
|
+
});
|
|
175
|
+
it("generates different hash for different paths", () => {
|
|
176
|
+
const name1 = getLocalWorkspaceName(null, "/path/one");
|
|
177
|
+
const name2 = getLocalWorkspaceName(null, "/path/two");
|
|
178
|
+
expect(name1).not.toBe(name2);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
//# sourceMappingURL=local.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.test.js","sourceRoot":"","sources":["../../src/api/local.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AA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AChC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Build command - generates and pushes resources to Tinybird
|
|
3
3
|
*/
|
|
4
|
+
import { type DevMode } from "../config.js";
|
|
4
5
|
import { type BuildFromIncludeResult } from "../../generator/index.js";
|
|
5
6
|
import { type BuildApiResult } from "../../api/build.js";
|
|
6
7
|
/**
|
|
@@ -15,6 +16,8 @@ export interface BuildCommandOptions {
|
|
|
15
16
|
tokenOverride?: string;
|
|
16
17
|
/** Use /v1/deploy instead of /v1/build (for main branch) */
|
|
17
18
|
useDeployEndpoint?: boolean;
|
|
19
|
+
/** Override the devMode from config */
|
|
20
|
+
devModeOverride?: DevMode;
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
20
23
|
* Build command result
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAmD,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAoB,KAAK,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAU1E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uCAAuC;IACvC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,wCAAwC;IACxC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAgM7F"}
|