@fluid-app/fluid-cli-portal 0.1.0

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.
Files changed (45) hide show
  1. package/dist/index.d.mts +680 -0
  2. package/dist/index.d.mts.map +1 -0
  3. package/dist/index.mjs +2230 -0
  4. package/dist/index.mjs.map +1 -0
  5. package/package.json +54 -0
  6. package/templates/base/index.html +14 -0
  7. package/templates/base/src/App.tsx +18 -0
  8. package/templates/base/src/index.css +80 -0
  9. package/templates/base/src/main.tsx +42 -0
  10. package/templates/base/src/navigation.config.ts +21 -0
  11. package/templates/base/src/portal.config.ts +32 -0
  12. package/templates/base/src/screens/Dashboard.tsx +133 -0
  13. package/templates/base/src/screens/ExampleForm.tsx +187 -0
  14. package/templates/base/src/vite-env.d.ts +1 -0
  15. package/templates/base/tsconfig.json +26 -0
  16. package/templates/fullstack/.dockerignore +9 -0
  17. package/templates/fullstack/.env.example +15 -0
  18. package/templates/fullstack/.github/workflows/ci.yml +47 -0
  19. package/templates/fullstack/.github/workflows/deploy.yml +54 -0
  20. package/templates/fullstack/Dockerfile +44 -0
  21. package/templates/fullstack/README.md.template +176 -0
  22. package/templates/fullstack/drizzle/0000_initial.sql +7 -0
  23. package/templates/fullstack/drizzle/meta/0000_snapshot.json +63 -0
  24. package/templates/fullstack/drizzle/meta/_journal.json +13 -0
  25. package/templates/fullstack/drizzle.config.ts +13 -0
  26. package/templates/fullstack/esbuild.config.js +14 -0
  27. package/templates/fullstack/eslint.config.js +13 -0
  28. package/templates/fullstack/package.json.template +63 -0
  29. package/templates/fullstack/src/fluid.config.ts.template +69 -0
  30. package/templates/fullstack/src/server/db/index.ts +10 -0
  31. package/templates/fullstack/src/server/db/migrate.ts +12 -0
  32. package/templates/fullstack/src/server/db/schema.ts +14 -0
  33. package/templates/fullstack/src/server/entry.ts +59 -0
  34. package/templates/fullstack/src/server/index.ts +33 -0
  35. package/templates/fullstack/src/server/routes/index.test.ts +123 -0
  36. package/templates/fullstack/src/server/routes/index.ts +109 -0
  37. package/templates/fullstack/src/server/routes/schemas.ts +7 -0
  38. package/templates/fullstack/src/test/setup.ts +9 -0
  39. package/templates/fullstack/vite.config.ts +39 -0
  40. package/templates/fullstack/vitest.config.ts +9 -0
  41. package/templates/starter/.env.example +1 -0
  42. package/templates/starter/README.md.template +218 -0
  43. package/templates/starter/package.json.template +40 -0
  44. package/templates/starter/src/fluid.config.ts.template +69 -0
  45. package/templates/starter/vite.config.ts +12 -0
@@ -0,0 +1,680 @@
1
+ import { Command } from "commander";
2
+ import { FluidPlugin } from "@fluid-app/fluid-cli";
3
+
4
+ //#region src/types.d.ts
5
+ /**
6
+ * Available project templates
7
+ */
8
+ declare const TEMPLATES: {
9
+ readonly starter: "starter";
10
+ readonly fullstack: "fullstack";
11
+ };
12
+ /**
13
+ * Union type of valid template names
14
+ */
15
+ type TemplateName = (typeof TEMPLATES)[keyof typeof TEMPLATES];
16
+ /**
17
+ * Type guard to check if a string is a valid template name
18
+ */
19
+ declare function isTemplateName(value: string): value is TemplateName;
20
+ /**
21
+ * Selected page template info
22
+ */
23
+ interface SelectedPageTemplate {
24
+ readonly id: string;
25
+ readonly slug: string;
26
+ readonly name: string;
27
+ }
28
+ /**
29
+ * Configuration options collected during project scaffolding
30
+ */
31
+ interface ProjectConfig {
32
+ /** Project name (used for directory and package.json name) */
33
+ readonly name: string;
34
+ /** Template to scaffold from */
35
+ readonly template: TemplateName;
36
+ /** Whether to install dependencies after scaffolding */
37
+ readonly installDeps: boolean;
38
+ /** Selected optional page templates to include */
39
+ readonly selectedPages: readonly SelectedPageTemplate[];
40
+ }
41
+ /**
42
+ * Options for the create command (from CLI arguments)
43
+ * Uses string types since CLI input needs validation before narrowing
44
+ */
45
+ interface CreateOptions {
46
+ /** Template name (validated against TemplateName type at runtime) */
47
+ readonly template?: string;
48
+ /** Skip dependency installation */
49
+ readonly skipInstall?: boolean;
50
+ }
51
+ /**
52
+ * Options for the dev command
53
+ */
54
+ interface DevOptions {
55
+ readonly port?: number;
56
+ readonly host?: boolean;
57
+ }
58
+ /**
59
+ * Options for the build command
60
+ */
61
+ interface BuildOptions {
62
+ readonly outDir?: string;
63
+ }
64
+ /**
65
+ * Options for the deploy command
66
+ */
67
+ interface DeployOptions {
68
+ /** Cloud Run region (default: us-central1) */
69
+ readonly region?: string;
70
+ /** GCP project ID (default: from gcloud config) */
71
+ readonly gcpProject?: string;
72
+ /** Service name override (default: from package.json) */
73
+ readonly project?: string;
74
+ /** Turso database group location (default: aws-us-east-1) */
75
+ readonly dbRegion?: string;
76
+ /** Require IAM authentication for the Cloud Run service (default: public) */
77
+ readonly requireAuth?: boolean;
78
+ /** Run database migrations (db:push) after successful deploy */
79
+ readonly migrate?: boolean;
80
+ /** Skip the local Docker build check before deploying */
81
+ readonly skipLocalBuild?: boolean;
82
+ /** Turso organization slug (skips interactive org selection) */
83
+ readonly tursoOrg?: string;
84
+ /** Fluid company API key (skips env var lookup and interactive prompt) */
85
+ readonly fluidCompanyApiKey?: string;
86
+ /** Skip navigation sync from portal.config.ts */
87
+ readonly skipNavSync?: boolean;
88
+ }
89
+ /**
90
+ * Options for the destroy command
91
+ */
92
+ interface DestroyOptions {
93
+ /** Cloud Run region (default: us-central1) */
94
+ readonly region?: string;
95
+ /** GCP project ID (default: from gcloud config) */
96
+ readonly gcpProject?: string;
97
+ /** Service name override (default: from package.json) */
98
+ readonly project?: string;
99
+ /** Turso organization slug (skips interactive org selection) */
100
+ readonly tursoOrg?: string;
101
+ /** Fluid company API key (skips env var lookup and interactive prompt) */
102
+ readonly fluidCompanyApiKey?: string;
103
+ /** Skip confirmation prompt */
104
+ readonly yes?: boolean;
105
+ }
106
+ /**
107
+ * Template variables for Handlebars processing
108
+ */
109
+ interface TemplateVariables {
110
+ readonly projectName: string;
111
+ readonly sdkVersion: string;
112
+ /** Selected page templates for the project */
113
+ readonly selectedPages: readonly SelectedPageTemplate[];
114
+ /** Whether any optional pages were selected */
115
+ readonly hasSelectedPages: boolean;
116
+ }
117
+ //#endregion
118
+ //#region src/utils/package-manager.d.ts
119
+ /**
120
+ * Returns the install command for pnpm
121
+ */
122
+ declare function getInstallCommand(): string;
123
+ /**
124
+ * Returns the run command for pnpm
125
+ */
126
+ declare function getRunCommand(script: string): string;
127
+ /**
128
+ * Runs a pnpm command in the specified directory
129
+ */
130
+ declare function runPackageManager(args: string[], cwd: string): Promise<void>;
131
+ /**
132
+ * Installs dependencies using pnpm
133
+ */
134
+ declare function installDependencies(cwd: string): Promise<void>;
135
+ //#endregion
136
+ //#region src/utils/result.d.ts
137
+ /**
138
+ * Result type utilities for type-safe error handling
139
+ *
140
+ * The Result<T, E> pattern provides a discriminated union for fallible operations,
141
+ * enabling exhaustive handling without try/catch blocks.
142
+ */
143
+ /**
144
+ * Successful result containing a value of type T
145
+ */
146
+ interface Success<T> {
147
+ readonly success: true;
148
+ readonly value: T;
149
+ }
150
+ /**
151
+ * Failed result containing an error of type E
152
+ */
153
+ interface Failure<E> {
154
+ readonly success: false;
155
+ readonly error: E;
156
+ }
157
+ /**
158
+ * Result type - discriminated union of Success and Failure
159
+ * The `success` field serves as the discriminant for type narrowing
160
+ */
161
+ type Result<T, E = Error> = Success<T> | Failure<E>;
162
+ /**
163
+ * Create a successful result
164
+ */
165
+ declare function success<T>(value: T): Success<T>;
166
+ /**
167
+ * Create a failed result
168
+ */
169
+ declare function failure<E>(error: E): Failure<E>;
170
+ /**
171
+ * Type guard for successful results
172
+ */
173
+ declare function isSuccess<T, E>(result: Result<T, E>): result is Success<T>;
174
+ /**
175
+ * Type guard for failed results
176
+ */
177
+ declare function isFailure<T, E>(result: Result<T, E>): result is Failure<E>;
178
+ /**
179
+ * Wrap a function that may throw into a Result-returning function
180
+ */
181
+ declare function tryCatch<T>(fn: () => T): Result<T, Error>;
182
+ /**
183
+ * Wrap an async function that may throw into a Result-returning function
184
+ */
185
+ declare function tryCatchAsync<T>(fn: () => Promise<T>): Promise<Result<T, Error>>;
186
+ /**
187
+ * Extract value from Result or throw error
188
+ * Use sparingly - prefer pattern matching with isSuccess/isFailure
189
+ */
190
+ declare function unwrap<T, E>(result: Result<T, E>): T;
191
+ /**
192
+ * Extract value from Result or return a default value
193
+ */
194
+ declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
195
+ /**
196
+ * Map over a successful Result value
197
+ */
198
+ declare function mapResult<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
199
+ /**
200
+ * Map over a failed Result error
201
+ */
202
+ declare function mapError<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F>;
203
+ /**
204
+ * Type guard to check if a value is an Error instance
205
+ *
206
+ * @example
207
+ * ```ts
208
+ * catch (error) {
209
+ * if (isError(error)) {
210
+ * console.log(error.message); // TypeScript knows this is an Error
211
+ * }
212
+ * }
213
+ * ```
214
+ */
215
+ declare function isError(value: unknown): value is Error;
216
+ /**
217
+ * Type guard for Node.js system errors (with `code` property)
218
+ *
219
+ * @example
220
+ * ```ts
221
+ * catch (error) {
222
+ * if (isNodeError(error) && error.code === "ENOENT") {
223
+ * console.log("File not found");
224
+ * }
225
+ * }
226
+ * ```
227
+ */
228
+ declare function isNodeError(value: unknown): value is NodeJS.ErrnoException;
229
+ /**
230
+ * Extract error message safely from unknown catch parameter.
231
+ * Prefer type guards (isError, isNodeError) when you need the full error object.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * catch (error) {
236
+ * console.log("Error: " + getErrorMessage(error));
237
+ * }
238
+ * ```
239
+ */
240
+ declare function getErrorMessage(error: unknown): string;
241
+ //#endregion
242
+ //#region src/utils/file-system.d.ts
243
+ /**
244
+ * Error types for file system operations
245
+ */
246
+ declare const FILE_SYSTEM_ERRORS: {
247
+ readonly directoryNotFound: "DIRECTORY_NOT_FOUND";
248
+ readonly fileNotFound: "FILE_NOT_FOUND";
249
+ readonly readError: "READ_ERROR";
250
+ readonly writeError: "WRITE_ERROR";
251
+ readonly templateError: "TEMPLATE_ERROR";
252
+ };
253
+ /**
254
+ * Union type for file system error codes
255
+ */
256
+ type FileSystemErrorCode = (typeof FILE_SYSTEM_ERRORS)[keyof typeof FILE_SYSTEM_ERRORS];
257
+ /**
258
+ * Structured file system error with code for pattern matching
259
+ */
260
+ interface FileSystemError {
261
+ readonly code: FileSystemErrorCode;
262
+ readonly message: string;
263
+ readonly path?: string;
264
+ readonly cause?: Error;
265
+ }
266
+ /**
267
+ * Paths for the base + overlay template system
268
+ */
269
+ interface TemplatePaths {
270
+ /** Path to shared frontend files used by all templates */
271
+ readonly base: string;
272
+ /** Path to template-specific overlay files */
273
+ readonly overlay: string;
274
+ }
275
+ /**
276
+ * Gets paths for the base + overlay template system.
277
+ *
278
+ * The create command copies `base` first, then the `overlay` on top.
279
+ * Any overlay file with the same relative path overwrites the base version.
280
+ */
281
+ declare function getTemplatePaths(templateName: string): TemplatePaths;
282
+ /**
283
+ * Copies a template directory to the target directory
284
+ * Processes .template files with Handlebars
285
+ */
286
+ declare function copyTemplate(templatePath: string, targetPath: string, variables: TemplateVariables): Promise<void>;
287
+ /**
288
+ * Checks if a directory exists
289
+ */
290
+ declare function directoryExists(path: string): Promise<boolean>;
291
+ /**
292
+ * Checks if a file exists
293
+ */
294
+ declare function fileExists(path: string): Promise<boolean>;
295
+ /**
296
+ * Checks if a path exists (file or directory)
297
+ */
298
+ declare function pathExists(path: string): Promise<boolean>;
299
+ /**
300
+ * Creates a directory
301
+ */
302
+ declare function createDirectory(path: string): Promise<void>;
303
+ /**
304
+ * Reads the SDK version from the workspace package.json
305
+ * Falls back to ^0.1.0 if not found
306
+ */
307
+ declare function getSdkVersion(): Promise<string>;
308
+ /**
309
+ * Read a file's content with Result-based error handling
310
+ */
311
+ declare function readFileSafe(path: string): Promise<Result<string, FileSystemError>>;
312
+ /**
313
+ * Write content to a file with Result-based error handling
314
+ */
315
+ declare function writeFileSafe(path: string, content: string): Promise<Result<void, FileSystemError>>;
316
+ /**
317
+ * Create a directory with Result-based error handling
318
+ */
319
+ declare function createDirectorySafe(path: string): Promise<Result<void, FileSystemError>>;
320
+ /**
321
+ * Copy a template directory with Result-based error handling
322
+ */
323
+ declare function copyTemplateSafe(templatePath: string, targetPath: string, variables: Readonly<TemplateVariables>): Promise<Result<void, FileSystemError>>;
324
+ /**
325
+ * Get SDK version with Result-based error handling
326
+ * Unlike getSdkVersion, this returns an error instead of a fallback
327
+ */
328
+ declare function getSdkVersionSafe(): Promise<Result<string, FileSystemError>>;
329
+ //#endregion
330
+ //#region src/utils/prompts.d.ts
331
+ /**
332
+ * Prompts the user for project configuration
333
+ * Pre-fills values from CLI options when provided
334
+ */
335
+ declare function promptProjectConfig(projectName: string, options: CreateOptions): Promise<ProjectConfig | null>;
336
+ //#endregion
337
+ //#region src/commands/create.d.ts
338
+ declare const createCommand: Command;
339
+ //#endregion
340
+ //#region src/commands/destroy.d.ts
341
+ declare const destroyCommand: Command;
342
+ //#endregion
343
+ //#region src/utils/cloud-run.d.ts
344
+ /**
345
+ * Cloud Run error codes and default messages
346
+ */
347
+ declare const CLOUD_RUN_ERRORS: {
348
+ readonly GCLOUD_NOT_INSTALLED: {
349
+ readonly code: "GCLOUD_NOT_INSTALLED";
350
+ readonly message: "gcloud CLI is not installed. Install it from https://cloud.google.com/sdk/docs/install";
351
+ };
352
+ readonly GCLOUD_NOT_AUTHENTICATED: {
353
+ readonly code: "GCLOUD_NOT_AUTHENTICATED";
354
+ readonly message: "gcloud CLI is not authenticated. Run 'gcloud auth login' to authenticate";
355
+ };
356
+ readonly NO_GCP_PROJECT: {
357
+ readonly code: "NO_GCP_PROJECT";
358
+ readonly message: "No GCP project configured. Run 'gcloud config set project PROJECT_ID' or pass --gcp-project";
359
+ };
360
+ readonly DEPLOY_FAILED: {
361
+ readonly code: "DEPLOY_FAILED";
362
+ readonly message: "Cloud Run deployment failed";
363
+ };
364
+ readonly SERVICE_DELETION_FAILED: {
365
+ readonly code: "SERVICE_DELETION_FAILED";
366
+ readonly message: "Cloud Run service deletion failed";
367
+ };
368
+ };
369
+ /**
370
+ * Configuration for Cloud Run deployment
371
+ */
372
+ interface CloudRunConfig {
373
+ /** GCP project ID */
374
+ readonly gcpProject: string;
375
+ /** GCP region (e.g., "us-central1") */
376
+ readonly region: string;
377
+ /** Cloud Run service name */
378
+ readonly serviceName: string;
379
+ /** Environment variables to set on the service */
380
+ readonly envVars: Record<string, string>;
381
+ /** Path to the source directory to deploy */
382
+ readonly sourceDir: string;
383
+ /** Require IAM authentication (default: public / allow-unauthenticated) */
384
+ readonly requireAuth?: boolean;
385
+ }
386
+ /**
387
+ * Structured error for Cloud Run operations
388
+ */
389
+ interface CloudRunError {
390
+ readonly code: string;
391
+ readonly message: string;
392
+ readonly details?: string;
393
+ }
394
+ /**
395
+ * Result of a successful Cloud Run deployment
396
+ */
397
+ interface CloudRunResult {
398
+ /** Service URL (e.g., "https://my-service-abc123.a.run.app") */
399
+ readonly url: string;
400
+ /** Cloud Run service name */
401
+ readonly serviceName: string;
402
+ /** GCP region the service is deployed to */
403
+ readonly region: string;
404
+ /** GCP project ID */
405
+ readonly gcpProject: string;
406
+ }
407
+ /**
408
+ * Callbacks for Cloud Run deployment progress tracking
409
+ */
410
+ interface CloudRunDeployCallbacks {
411
+ readonly onValidating?: () => void;
412
+ readonly onDeploying?: () => void;
413
+ readonly onDeployComplete?: (url: string) => void;
414
+ }
415
+ /**
416
+ * Validate that the gcloud CLI is installed
417
+ */
418
+ declare function validateGcloudInstalled(): Promise<Result<void, CloudRunError>>;
419
+ /**
420
+ * Validate that the gcloud CLI has an active authenticated account
421
+ */
422
+ declare function validateGcloudAuth(): Promise<Result<void, CloudRunError>>;
423
+ /**
424
+ * Get the currently configured GCP project from gcloud config
425
+ */
426
+ declare function getGcpProject(): Promise<Result<string, CloudRunError>>;
427
+ /**
428
+ * Deploy to Cloud Run using `gcloud run deploy --source`
429
+ *
430
+ * This builds the container from source and deploys it in a single step.
431
+ * Progress is reported through optional callbacks.
432
+ */
433
+ declare function deployToCloudRun(config: Readonly<CloudRunConfig>, callbacks?: Readonly<CloudRunDeployCallbacks>): Promise<Result<CloudRunResult, CloudRunError>>;
434
+ /**
435
+ * Delete a Cloud Run service using `gcloud run services delete`.
436
+ */
437
+ declare function deleteCloudRunService(config: {
438
+ readonly serviceName: string;
439
+ readonly gcpProject: string;
440
+ readonly region: string;
441
+ }): Promise<Result<void, CloudRunError>>;
442
+ //#endregion
443
+ //#region src/utils/fluid-api.d.ts
444
+ declare const FLUID_API_ERROR: {
445
+ readonly MISSING_API_KEY: {
446
+ readonly code: "MISSING_API_KEY";
447
+ readonly message: "FLUID_COMPANY_API_KEY is not set";
448
+ };
449
+ readonly INVALID_API_KEY: {
450
+ readonly code: "INVALID_API_KEY";
451
+ readonly message: "FLUID_COMPANY_API_KEY is invalid or expired";
452
+ };
453
+ readonly API_UNREACHABLE: {
454
+ readonly code: "API_UNREACHABLE";
455
+ readonly message: "Could not reach the Fluid API";
456
+ };
457
+ };
458
+ /**
459
+ * Fluid API error codes derived from error constants
460
+ */
461
+ type FluidApiErrorCode = (typeof FLUID_API_ERROR)[keyof typeof FLUID_API_ERROR]["code"];
462
+ /**
463
+ * Structured Fluid API error with code for pattern matching
464
+ */
465
+ interface FluidApiError {
466
+ readonly code: string;
467
+ readonly message: string;
468
+ readonly details?: string;
469
+ }
470
+ /**
471
+ * Validated Fluid company info returned on successful API key check
472
+ */
473
+ interface FluidCompany {
474
+ readonly name: string;
475
+ readonly apiKey: string;
476
+ }
477
+ /**
478
+ * Resolve and validate the Fluid API key.
479
+ *
480
+ * Priority:
481
+ * 1. `apiKeyOverride` parameter (from --fluid-company-api-key flag)
482
+ * 2. FLUID_COMPANY_API_KEY environment variable
483
+ * 3. Interactive hidden-input prompt
484
+ * 4. Fail with instructions if all sources exhausted
485
+ *
486
+ * Once resolved, validates against the Fluid API (GET /api/company/v1/companies/me).
487
+ *
488
+ * @param apiKeyOverride - Optional API key from CLI flag (skips env + prompt)
489
+ */
490
+ declare function resolveFluidApiKey(apiKeyOverride?: string): Promise<Result<FluidCompany, FluidApiError>>;
491
+ /**
492
+ * Validate a Fluid API key by calling the companies/me endpoint.
493
+ *
494
+ * - 200 → extract company name, return success
495
+ * - 401/403 → invalid or expired key
496
+ * - Network error → API unreachable
497
+ */
498
+ declare function validateFluidApiKey(apiKey: string): Promise<Result<FluidCompany, FluidApiError>>;
499
+ //#endregion
500
+ //#region src/utils/turso.d.ts
501
+ declare const TURSO_ERROR: {
502
+ readonly MISSING_TOKEN: {
503
+ readonly code: "MISSING_TOKEN";
504
+ readonly message: "TURSO_API_TOKEN environment variable is not set";
505
+ };
506
+ readonly MISSING_ORG: {
507
+ readonly code: "MISSING_ORG";
508
+ readonly message: "TURSO_ORG environment variable is not set";
509
+ };
510
+ readonly GROUP_CREATION_FAILED: {
511
+ readonly code: "GROUP_CREATION_FAILED";
512
+ readonly message: "Failed to create database group";
513
+ };
514
+ readonly DATABASE_CREATION_FAILED: {
515
+ readonly code: "DATABASE_CREATION_FAILED";
516
+ readonly message: "Failed to create database";
517
+ };
518
+ readonly TOKEN_CREATION_FAILED: {
519
+ readonly code: "TOKEN_CREATION_FAILED";
520
+ readonly message: "Failed to create database auth token";
521
+ };
522
+ readonly DATABASE_DELETION_FAILED: {
523
+ readonly code: "DATABASE_DELETION_FAILED";
524
+ readonly message: "Failed to delete database";
525
+ };
526
+ readonly INVALID_LOCATION: {
527
+ readonly code: "INVALID_LOCATION";
528
+ readonly message: "Invalid database location";
529
+ };
530
+ readonly LOCATIONS_FETCH_FAILED: {
531
+ readonly code: "LOCATIONS_FETCH_FAILED";
532
+ readonly message: "Failed to fetch available Turso locations";
533
+ };
534
+ readonly TURSO_CLI_NOT_FOUND: {
535
+ readonly code: "TURSO_CLI_NOT_FOUND";
536
+ readonly message: "Turso CLI is not installed";
537
+ };
538
+ readonly TURSO_CLI_NOT_AUTHENTICATED: {
539
+ readonly code: "TURSO_CLI_NOT_AUTHENTICATED";
540
+ readonly message: "Turso CLI is not authenticated";
541
+ };
542
+ readonly TURSO_NO_ORGS: {
543
+ readonly code: "TURSO_NO_ORGS";
544
+ readonly message: "No organizations found in Turso CLI";
545
+ };
546
+ };
547
+ /**
548
+ * Structured Turso error with code for pattern matching
549
+ */
550
+ interface TursoError {
551
+ readonly code: string;
552
+ readonly message: string;
553
+ readonly details?: string;
554
+ }
555
+ /**
556
+ * Validated Turso configuration from environment variables
557
+ */
558
+ interface TursoConfig {
559
+ readonly apiToken: string;
560
+ readonly org: string;
561
+ }
562
+ /**
563
+ * Where the Turso credentials were resolved from
564
+ */
565
+ type TursoConfigSource = "env" | "cli";
566
+ /**
567
+ * Turso configuration with source tracking
568
+ */
569
+ interface ResolvedTursoConfig extends TursoConfig {
570
+ readonly source: TursoConfigSource;
571
+ }
572
+ /**
573
+ * Parsed Turso organization from CLI output
574
+ */
575
+ interface TursoOrg {
576
+ readonly name: string;
577
+ readonly slug: string;
578
+ readonly isCurrent: boolean;
579
+ }
580
+ /**
581
+ * Provisioned Turso database connection details
582
+ */
583
+ interface TursoDatabase {
584
+ readonly url: string;
585
+ readonly authToken: string;
586
+ readonly databaseName: string;
587
+ readonly hostname: string;
588
+ /** true when the database was freshly created (HTTP 200), false when it already existed (HTTP 409) */
589
+ readonly isNew: boolean;
590
+ }
591
+ /**
592
+ * Callbacks for database provisioning progress
593
+ */
594
+ interface TursoProvisionCallbacks {
595
+ readonly onGroupCreating?: () => void;
596
+ readonly onGroupReady?: () => void;
597
+ readonly onDatabaseCreating?: (name: string) => void;
598
+ readonly onDatabaseReady?: (name: string) => void;
599
+ readonly onTokenCreating?: () => void;
600
+ readonly onTokenReady?: () => void;
601
+ }
602
+ /**
603
+ * Validate that required Turso environment variables are present
604
+ */
605
+ declare function validateTursoConfig(): Result<TursoConfig, TursoError>;
606
+ /**
607
+ * Parse the tabular output of `turso org list`.
608
+ *
609
+ * Example input:
610
+ * Name Slug Type
611
+ * My Org my-org personal (current)
612
+ * Team Org team-org team
613
+ *
614
+ * Exported for unit testing.
615
+ */
616
+ declare function parseOrgList(stdout: string): TursoOrg[];
617
+ /**
618
+ * Resolve Turso credentials from the best available source.
619
+ *
620
+ * Priority:
621
+ * 1. Environment variables (TURSO_API_TOKEN + TURSO_ORG) — immediate, for CI/CD
622
+ * 2. Turso CLI (turso auth token + turso org list) — interactive, for local dev
623
+ * 3. Fail with instructions for both options
624
+ *
625
+ * @param tursoOrgOverride - Optional org slug from --turso-org flag (skips interactive selection)
626
+ */
627
+ declare function resolveTursoConfig(tursoOrgOverride?: string): Promise<Result<ResolvedTursoConfig, TursoError>>;
628
+ /**
629
+ * Fetch available Turso database locations.
630
+ * Returns a map of location ID → description (e.g., "aws-us-east-1" → "US East (N. Virginia)").
631
+ */
632
+ declare function fetchLocations(config: TursoConfig): Promise<Result<Record<string, string>, TursoError>>;
633
+ /**
634
+ * Validate that a location string is a known Turso location.
635
+ * On failure, returns an error listing all valid locations.
636
+ */
637
+ declare function validateLocation(config: TursoConfig, location: string): Promise<Result<void, TursoError>>;
638
+ /**
639
+ * Ensure a default database group exists in the Turso organization.
640
+ * Creates the group if it does not exist; treats 409 (conflict) as success
641
+ * since it means the group already exists.
642
+ */
643
+ declare function ensureGroup(config: TursoConfig, location?: string): Promise<Result<void, TursoError>>;
644
+ /**
645
+ * Create a new Turso database in the default group.
646
+ * If the database already exists (409), fetches its info via GET instead.
647
+ * Returns the database name and hostname.
648
+ */
649
+ declare function createDatabase(config: TursoConfig, name: string): Promise<Result<{
650
+ name: string;
651
+ hostname: string;
652
+ isNew: boolean;
653
+ }, TursoError>>;
654
+ /**
655
+ * Delete a Turso database by name.
656
+ * Returns void on success, or a TursoError on failure.
657
+ */
658
+ declare function deleteDatabase(config: TursoConfig, name: string): Promise<Result<void, TursoError>>;
659
+ /**
660
+ * Create an auth token for a Turso database.
661
+ * Returns the JWT token string used for database connections.
662
+ */
663
+ declare function createDatabaseToken(config: TursoConfig, dbName: string): Promise<Result<string, TursoError>>;
664
+ /**
665
+ * Provision a complete Turso database for a project.
666
+ *
667
+ * Orchestrates the full flow:
668
+ * 1. Ensure a default group exists
669
+ * 2. Create (or retrieve) the database
670
+ * 3. Generate an auth token
671
+ *
672
+ * Calls progress callbacks at each step so callers can display status.
673
+ */
674
+ declare function provisionDatabase(config: TursoConfig, projectName: string, location?: string, callbacks?: TursoProvisionCallbacks): Promise<Result<TursoDatabase, TursoError>>;
675
+ //#endregion
676
+ //#region src/index.d.ts
677
+ declare const plugin: FluidPlugin;
678
+ //#endregion
679
+ export { type BuildOptions, CLOUD_RUN_ERRORS, type CloudRunConfig, type CloudRunDeployCallbacks, type CloudRunError, type CloudRunResult, type CreateOptions, type DeployOptions, type DestroyOptions, type DevOptions, FILE_SYSTEM_ERRORS, FLUID_API_ERROR, type Failure, type FileSystemError, type FileSystemErrorCode, type FluidApiError, type FluidApiErrorCode, type FluidCompany, type ProjectConfig, type ResolvedTursoConfig, type Result, type SelectedPageTemplate, type Success, TEMPLATES, TURSO_ERROR, type TemplateName, type TemplatePaths, type TemplateVariables, type TursoConfig, type TursoConfigSource, type TursoDatabase, type TursoError, type TursoOrg, type TursoProvisionCallbacks, copyTemplate, copyTemplateSafe, createCommand, createDatabase, createDatabaseToken, createDirectory, createDirectorySafe, plugin as default, deleteCloudRunService, deleteDatabase, deployToCloudRun, destroyCommand, directoryExists, ensureGroup, failure, fetchLocations, fileExists, getErrorMessage, getGcpProject, getInstallCommand, getRunCommand, getSdkVersion, getSdkVersionSafe, getTemplatePaths, installDependencies, isError, isFailure, isNodeError, isSuccess, isTemplateName, mapError, mapResult, parseOrgList, pathExists, promptProjectConfig, provisionDatabase, readFileSafe, resolveFluidApiKey, resolveTursoConfig, runPackageManager, success, tryCatch, tryCatchAsync, unwrap, unwrapOr, validateFluidApiKey, validateGcloudAuth, validateGcloudInstalled, validateLocation, validateTursoConfig, writeFileSafe };
680
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/utils/package-manager.ts","../src/utils/result.ts","../src/utils/file-system.ts","../src/utils/prompts.ts","../src/commands/create.ts","../src/commands/destroy.ts","../src/utils/cloud-run.ts","../src/utils/fluid-api.ts","../src/utils/turso.ts","../src/index.ts"],"mappings":";;;;;;;cAOa,SAAA;EAAA,SACX,OAAA;EAAA,SACA,SAAA;AAAA;;;AAMF;KAAY,YAAA,WAAuB,SAAA,eAAwB,SAAA;;;;iBAK3C,cAAA,CAAe,KAAA,WAAgB,KAAA,IAAS,YAAA;;;;UAWvC,oBAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;EAAA,SACA,IAAA;AAAA;AAHX;;;AAAA,UASiB,aAAA;;WAEN,IAAA;;WAEA,QAAA,EAAU,YAAA;EAVV;EAAA,SAYA,WAAA;EANM;EAAA,SAQN,aAAA,WAAwB,oBAAA;AAAA;;;;;UAOlB,aAAA;;WAEN,QAAA;EATwB;EAAA,SAWxB,WAAA;AAAA;;;;UAUM,UAAA;EAAA,SACN,IAAA;EAAA,SACA,IAAA;AAAA;;AAMX;;UAAiB,YAAA;EAAA,SACN,MAAA;AAAA;AAMX;;;AAAA,UAAiB,aAAA;;WAEN,MAAA;;WAEA,UAAA;;WAEA,OAAA;;WAEA,QAAA;;WAEA,WAAA;;WAEA,OAAA;EAcX;EAAA,SAZW,cAAA;;WAEA,QAAA;;WAEA,kBAAA;;WAEA,WAAA;AAAA;;;;UAMM,cAAA;EAsBA;EAAA,SApBN,MAAA;EAwBwB;EAAA,SAtBxB,UAAA;;WAEA,OAAA;;WAEA,QAAA;;WAEA,kBAAA;;WAEA,GAAA;AAAA;ACrHX;;;AAAA,UD+HiB,iBAAA;EAAA,SACN,WAAA;EAAA,SACA,UAAA;EC1HK;EAAA,SD4HL,aAAA,WAAwB,oBAAA;EC5HnB;EAAA,SD8HL,gBAAA;AAAA;;;;;;iBCrIK,iBAAA,CAAA;ADEhB;;;AAAA,iBCKgB,aAAA,CAAc,MAAA;;ADG9B;;iBCIsB,iBAAA,CACpB,IAAA,YACA,GAAA,WACC,OA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