@bagelink/workspace 1.7.33 → 1.7.37

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 CHANGED
@@ -79,7 +79,66 @@ export default defineWorkspace(configs)
79
79
 
80
80
  ## Usage
81
81
 
82
- ### 1. Configure Vite (`vite.config.ts`)
82
+ ### 1. Add Type Definitions
83
+
84
+ Add to your project's `env.d.ts`:
85
+
86
+ ```typescript
87
+ /// <reference types="@bagelink/workspace/env" />
88
+ ```
89
+
90
+ This provides TypeScript types for injected environment variables.
91
+
92
+ ### 2. Configure Vite (`vite.config.ts`)
93
+
94
+ **Recommended: Use the Vite plugin (keeps your config clean and standard)**
95
+
96
+ ```typescript
97
+ import { defineConfig } from 'vite'
98
+ import vue from '@vitejs/plugin-vue'
99
+ import { bagelink } from '@bagelink/workspace/vite'
100
+ import workspace from './bgl.config'
101
+
102
+ export default defineConfig({
103
+ plugins: [
104
+ vue(),
105
+ bagelink({ workspace }),
106
+ ],
107
+ })
108
+ ```
109
+
110
+ The plugin automatically:
111
+ - Configures proxy based on `bgl.config.ts`
112
+ - Sets up `@` alias pointing to `./src`
113
+ - Sets up `@shared` alias (in monorepos)
114
+ - Keeps your vite.config.ts clean and extensible
115
+
116
+ **Advanced: Custom options**
117
+
118
+ ```typescript
119
+ import { defineConfig } from 'vite'
120
+ import vue from '@vitejs/plugin-vue'
121
+ import { bagelink } from '@bagelink/workspace/vite'
122
+ import { fileURLToPath } from 'node:url'
123
+ import workspace from './bgl.config'
124
+
125
+ export default defineConfig({
126
+ plugins: [
127
+ vue(),
128
+ bagelink({
129
+ workspace,
130
+ config: {
131
+ sharedPath: '../packages/shared',
132
+ additionalAliases: {
133
+ '@utils': fileURLToPath(new URL('./src/utils', import.meta.url))
134
+ }
135
+ }
136
+ }),
137
+ ],
138
+ })
139
+ ```
140
+
141
+ **Legacy: Manual proxy setup**
83
142
 
84
143
  ```typescript
85
144
  import { defineConfig } from 'vite'
@@ -98,7 +157,47 @@ export default defineConfig(({ mode }) => {
98
157
  })
99
158
  ```
100
159
 
101
- ### 2. Add scripts to `package.json`
160
+ ### 3. Use Configuration in Your App
161
+
162
+ **Access config at runtime with `useWorkspace()`:**
163
+
164
+ ```typescript
165
+ import { useWorkspace } from '@bagelink/workspace'
166
+
167
+ // In your app setup
168
+ const { proxy, host, mode } = useWorkspace()
169
+ const auth = initAuth({ baseURL: proxy })
170
+
171
+ // Or get full API URL
172
+ import { getApiUrl } from '@bagelink/workspace'
173
+ const apiUrl = getApiUrl() // 'https://project.bagel.to/api'
174
+ ```
175
+
176
+ **Vue component example:**
177
+
178
+ ```vue
179
+ <script setup lang="ts">
180
+ import { useWorkspace } from '@bagelink/workspace'
181
+ import { initAuth } from '@bagelink/auth'
182
+
183
+ const { proxy, host, mode } = useWorkspace()
184
+ const auth = initAuth({ baseURL: proxy })
185
+
186
+ console.log('API Host:', host)
187
+ console.log('Environment:', mode)
188
+ </script>
189
+ ```
190
+
191
+ **Access raw environment variables:**
192
+
193
+ ```typescript
194
+ // These are injected at build time by the bagelink plugin
195
+ const proxy = import.meta.env.VITE_BGL_PROXY // '/api'
196
+ const host = import.meta.env.VITE_BGL_HOST // 'https://project.bagel.to'
197
+ const openapi = import.meta.env.VITE_BGL_OPENAPI_URL // optional
198
+ ```
199
+
200
+ ### 4. Add scripts to `package.json`
102
201
 
103
202
  ```json
104
203
  {
@@ -110,7 +209,7 @@ export default defineConfig(({ mode }) => {
110
209
  }
111
210
  ```
112
211
 
113
- ### 3. Generate Netlify Config
212
+ ### 5. Generate Netlify Config
114
213
 
115
214
  ```typescript
116
215
  import { writeNetlifyConfig } from '@bagelink/workspace'
@@ -409,7 +508,41 @@ Show CLI help.
409
508
 
410
509
  ## API
411
510
 
412
- ### `defineWorkspace(configs)`
511
+ ### Runtime Functions
512
+
513
+ #### `useWorkspace()`
514
+
515
+ Get workspace configuration at runtime. Config is injected as environment variables during build.
516
+
517
+ ```typescript
518
+ import { useWorkspace } from '@bagelink/workspace'
519
+
520
+ const { proxy, host, openapiUrl, mode } = useWorkspace()
521
+ ```
522
+
523
+ **Returns:**
524
+ ```typescript
525
+ interface RuntimeWorkspaceConfig {
526
+ proxy: string // '/api'
527
+ host: string // 'https://project.bagel.to'
528
+ openapiUrl?: string // optional
529
+ mode: 'localhost' | 'development' | 'production'
530
+ }
531
+ ```
532
+
533
+ #### `getApiUrl()`
534
+
535
+ Get the full API URL by combining host and proxy.
536
+
537
+ ```typescript
538
+ import { getApiUrl } from '@bagelink/workspace'
539
+
540
+ const apiUrl = getApiUrl() // 'https://project.bagel.to/api'
541
+ ```
542
+
543
+ ### Configuration Functions
544
+
545
+ #### `defineWorkspace(configs)`
413
546
 
414
547
  Define workspace configuration for all environments.
415
548
 
package/bin/bgl.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { resolve } from 'node:path'
2
3
  import process from 'node:process'
3
4
  import { isWorkspace } from '../src/detect.js'
4
5
  import { runDev } from '../src/dev.js'
@@ -17,11 +18,19 @@ async function main() {
17
18
  || subcommand === '-w'
18
19
  || args.includes('--workspace')
19
20
  || args.includes('-w')
21
+
22
+ // Support 'bgl init .' or 'bgl init <path>'
23
+ let targetPath = process.cwd()
24
+ if (subcommand && !subcommand.startsWith('-')) {
25
+ // If subcommand is not a flag, treat it as a path
26
+ targetPath = subcommand === '.' ? process.cwd() : resolve(process.cwd(), subcommand)
27
+ }
28
+
20
29
  if (createWorkspace) {
21
30
  await initWorkspace()
22
31
  }
23
32
  else {
24
- await generateWorkspaceConfig()
33
+ await generateWorkspaceConfig(targetPath)
25
34
  }
26
35
  }
27
36
  else if (command === 'add') {
@@ -110,7 +119,8 @@ SDK Commands:
110
119
  Bagel Workspace CLI
111
120
 
112
121
  Usage:
113
- bgl init Generate bgl.config.ts for single project
122
+ bgl init [path] Generate bgl.config.ts for single project
123
+ Examples: bgl init, bgl init ., bgl init ./my-app
114
124
  bgl init --workspace Create a new workspace with multiple projects
115
125
  bgl add <name> Add a new project to workspace
116
126
  bgl list List all projects in workspace
package/dist/bin/bgl.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
+ const node_path = require('node:path');
4
5
  const process = require('node:process');
5
- const workspace = require('../shared/workspace.OuHxYc4s.cjs');
6
+ const workspace = require('../shared/workspace.CamNrnD_.cjs');
6
7
  require('node:fs');
7
- require('node:path');
8
8
  require('prompts');
9
9
  require('node:child_process');
10
10
 
@@ -16,10 +16,14 @@ const [, , command, subcommand, ...args] = process__default.argv;
16
16
  async function main() {
17
17
  if (command === "init") {
18
18
  const createWorkspace = subcommand === "--workspace" || subcommand === "-w" || args.includes("--workspace") || args.includes("-w");
19
+ let targetPath = process__default.cwd();
20
+ if (subcommand && !subcommand.startsWith("-")) {
21
+ targetPath = subcommand === "." ? process__default.cwd() : node_path.resolve(process__default.cwd(), subcommand);
22
+ }
19
23
  if (createWorkspace) {
20
24
  await workspace.initWorkspace();
21
25
  } else {
22
- await workspace.generateWorkspaceConfig();
26
+ await workspace.generateWorkspaceConfig(targetPath);
23
27
  }
24
28
  } else if (command === "add") {
25
29
  const projectName = subcommand;
@@ -92,7 +96,8 @@ SDK Commands:
92
96
  Bagel Workspace CLI
93
97
 
94
98
  Usage:
95
- bgl init Generate bgl.config.ts for single project
99
+ bgl init [path] Generate bgl.config.ts for single project
100
+ Examples: bgl init, bgl init ., bgl init ./my-app
96
101
  bgl init --workspace Create a new workspace with multiple projects
97
102
  bgl add <name> Add a new project to workspace
98
103
  bgl list List all projects in workspace
package/dist/bin/bgl.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
+ import { resolve } from 'node:path';
2
3
  import process from 'node:process';
3
- import { k as initWorkspace, g as generateWorkspaceConfig, j as addProject, l as listProjects, i as isWorkspace, e as setupLint, h as generateSDKForWorkspace, f as generateSDK, r as runDev } from '../shared/workspace.CcKgYZPx.mjs';
4
+ import { k as initWorkspace, g as generateWorkspaceConfig, j as addProject, l as listProjects, i as isWorkspace, e as setupLint, h as generateSDKForWorkspace, f as generateSDK, r as runDev } from '../shared/workspace.PLrsjsJ2.mjs';
4
5
  import 'node:fs';
5
- import 'node:path';
6
6
  import 'prompts';
7
7
  import 'node:child_process';
8
8
 
@@ -10,10 +10,14 @@ const [, , command, subcommand, ...args] = process.argv;
10
10
  async function main() {
11
11
  if (command === "init") {
12
12
  const createWorkspace = subcommand === "--workspace" || subcommand === "-w" || args.includes("--workspace") || args.includes("-w");
13
+ let targetPath = process.cwd();
14
+ if (subcommand && !subcommand.startsWith("-")) {
15
+ targetPath = subcommand === "." ? process.cwd() : resolve(process.cwd(), subcommand);
16
+ }
13
17
  if (createWorkspace) {
14
18
  await initWorkspace();
15
19
  } else {
16
- await generateWorkspaceConfig();
20
+ await generateWorkspaceConfig(targetPath);
17
21
  }
18
22
  } else if (command === "add") {
19
23
  const projectName = subcommand;
@@ -86,7 +90,8 @@ SDK Commands:
86
90
  Bagel Workspace CLI
87
91
 
88
92
  Usage:
89
- bgl init Generate bgl.config.ts for single project
93
+ bgl init [path] Generate bgl.config.ts for single project
94
+ Examples: bgl init, bgl init ., bgl init ./my-app
90
95
  bgl init --workspace Create a new workspace with multiple projects
91
96
  bgl add <name> Add a new project to workspace
92
97
  bgl list List all projects in workspace
package/dist/index.cjs CHANGED
@@ -3,9 +3,11 @@
3
3
  const node_fs = require('node:fs');
4
4
  const node_path = require('node:path');
5
5
  const process = require('node:process');
6
- const workspace = require('./shared/workspace.OuHxYc4s.cjs');
6
+ const workspace = require('./shared/workspace.CamNrnD_.cjs');
7
+ const vite = require('./shared/workspace.DfLGMczD.cjs');
7
8
  require('prompts');
8
9
  require('node:child_process');
10
+ require('node:url');
9
11
 
10
12
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
11
13
 
@@ -71,38 +73,21 @@ function mergeConfigs(base, override) {
71
73
  };
72
74
  }
73
75
 
74
- function createViteProxy(config) {
75
- const proxy = {};
76
- if (config.proxy && config.host) {
77
- proxy[config.proxy] = {
78
- target: config.host,
79
- changeOrigin: true,
80
- rewrite: (path) => path.replace(new RegExp(`^${config.proxy}`), ""),
81
- secure: true
82
- };
83
- }
84
- if (config.host) {
85
- proxy["/files"] = {
86
- target: config.host,
87
- changeOrigin: true,
88
- secure: true
89
- };
90
- }
91
- return proxy;
76
+ function useWorkspace() {
77
+ const proxy = undefined.VITE_BGL_PROXY || "/api";
78
+ const host = undefined.VITE_BGL_HOST || "";
79
+ const openapiUrl = undefined.VITE_BGL_OPENAPI_URL;
80
+ const mode = undefined.MODE || "development";
81
+ return {
82
+ proxy,
83
+ host,
84
+ openapiUrl,
85
+ mode
86
+ };
92
87
  }
93
- function createCustomProxy(paths, target, options = {}) {
94
- const proxy = {};
95
- for (const path of paths) {
96
- proxy[path] = {
97
- target,
98
- changeOrigin: options.changeOrigin ?? true,
99
- secure: options.secure ?? true,
100
- ...options.rewrite === true && {
101
- rewrite: (p) => p.replace(new RegExp(`^${path}`), "")
102
- }
103
- };
104
- }
105
- return proxy;
88
+ function getApiUrl() {
89
+ const { host, proxy } = useWorkspace();
90
+ return `${host}${proxy}`;
106
91
  }
107
92
 
108
93
  function defineWorkspace(configs) {
@@ -126,7 +111,7 @@ function createWorkspace(options = {}) {
126
111
  * Create Vite proxy configuration
127
112
  */
128
113
  createProxy(config) {
129
- return createViteProxy(config);
114
+ return vite.createViteProxy(config);
130
115
  },
131
116
  /**
132
117
  * Generate Netlify configuration file
@@ -164,9 +149,12 @@ exports.runDev = workspace.runDev;
164
149
  exports.setBuildEnvVars = workspace.setBuildEnvVars;
165
150
  exports.setupLint = workspace.setupLint;
166
151
  exports.writeNetlifyConfig = workspace.writeNetlifyConfig;
167
- exports.createCustomProxy = createCustomProxy;
168
- exports.createViteProxy = createViteProxy;
152
+ exports.bagelink = vite.bagelink;
153
+ exports.createCustomProxy = vite.createCustomProxy;
154
+ exports.createViteProxy = vite.createViteProxy;
169
155
  exports.createWorkspace = createWorkspace;
170
156
  exports.defineWorkspace = defineWorkspace;
157
+ exports.getApiUrl = getApiUrl;
171
158
  exports.mergeConfigs = mergeConfigs;
172
159
  exports.resolveConfig = resolveConfig;
160
+ exports.useWorkspace = useWorkspace;
package/dist/index.d.cts CHANGED
@@ -1,45 +1,6 @@
1
- type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
2
- interface WorkspaceConfig {
3
- /**
4
- * The host URL of the backend API server
5
- * @example 'http://localhost:8000' | 'https://project.bagel.to'
6
- */
7
- host: string;
8
- /**
9
- * The proxy path to use for API requests
10
- * @default '/api'
11
- */
12
- proxy: string;
13
- /**
14
- * Optional OpenAPI specification URL for SDK generation
15
- */
16
- openapi_url?: string;
17
- }
18
- interface WorkspaceOptions {
19
- /**
20
- * Root directory of the workspace
21
- * @default process.cwd()
22
- */
23
- root?: string;
24
- /**
25
- * Path to the config file relative to root
26
- * @default 'bgl.config.ts'
27
- */
28
- configFile?: string;
29
- /**
30
- * Enable interactive config generation if no config is found
31
- * @default true
32
- */
33
- interactive?: boolean;
34
- }
35
- interface ProxyConfig {
36
- [path: string]: {
37
- target: string;
38
- changeOrigin: boolean;
39
- rewrite?: (path: string) => string;
40
- secure: boolean;
41
- };
42
- }
1
+ import { W as WorkspaceConfig, a as WorkspaceEnvironment, b as WorkspaceOptions, P as ProxyConfig } from './shared/workspace.CSNgk3PR.cjs';
2
+ export { B as BagelinkPluginOptions, c as bagelink } from './shared/workspace.CSNgk3PR.cjs';
3
+ import 'vite';
43
4
 
44
5
  /**
45
6
  * Load and resolve bgl.config.ts with cascading support
@@ -63,16 +24,17 @@ declare function generateWorkspaceConfigSync(projectId: string, root?: string, c
63
24
 
64
25
  /**
65
26
  * Generate netlify.toml redirect configuration
27
+ * Uses environment variables for flexibility across environments
66
28
  */
67
29
  declare function generateNetlifyRedirect(config: WorkspaceConfig): string;
68
30
  /**
69
31
  * Generate complete netlify.toml file
70
32
  */
71
- declare function generateNetlifyConfig(config: WorkspaceConfig, additionalConfig?: string): string;
33
+ declare function generateNetlifyConfig(config: WorkspaceConfig, additionalConfig?: string, useTemplate?: boolean): string;
72
34
  /**
73
35
  * Write netlify.toml file to disk
74
36
  */
75
- declare function writeNetlifyConfig(config: WorkspaceConfig, outPath?: string, additionalConfig?: string): void;
37
+ declare function writeNetlifyConfig(config: WorkspaceConfig, outPath?: string, additionalConfig?: string, useTemplate?: boolean): void;
76
38
  /**
77
39
  * Set environment variables for build process
78
40
  */
@@ -91,6 +53,54 @@ declare function createCustomProxy(paths: string[], target: string, options?: {
91
53
  secure?: boolean;
92
54
  }): ProxyConfig;
93
55
 
56
+ /**
57
+ * Runtime workspace configuration
58
+ * Provides access to workspace config injected at build time
59
+ */
60
+ interface RuntimeWorkspaceConfig {
61
+ /** API proxy path (e.g., '/api') */
62
+ proxy: string;
63
+ /** API host URL (e.g., 'https://project.bagel.to') */
64
+ host: string;
65
+ /** OpenAPI specification URL (if configured) */
66
+ openapiUrl?: string;
67
+ /** Current environment mode */
68
+ mode: 'localhost' | 'development' | 'production';
69
+ }
70
+ /**
71
+ * Get workspace configuration at runtime
72
+ * Config is injected as environment variables during build
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * import { useWorkspace } from '@bagelink/workspace'
77
+ *
78
+ * const { proxy, host } = useWorkspace()
79
+ * const auth = initAuth({ baseURL: proxy })
80
+ * ```
81
+ *
82
+ * @example In Vue component
83
+ * ```vue
84
+ * <script setup>
85
+ * import { useWorkspace } from '@bagelink/workspace'
86
+ *
87
+ * const { proxy, host, mode } = useWorkspace()
88
+ * </script>
89
+ * ```
90
+ */
91
+ declare function useWorkspace(): RuntimeWorkspaceConfig;
92
+ /**
93
+ * Get the full API URL by combining host and proxy
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { getApiUrl } from '@bagelink/workspace'
98
+ *
99
+ * const apiUrl = getApiUrl() // 'https://project.bagel.to/api'
100
+ * ```
101
+ */
102
+ declare function getApiUrl(): string;
103
+
94
104
  /**
95
105
  * Detect if current directory is a workspace root
96
106
  */
@@ -165,5 +175,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
165
175
  clearCache(): void;
166
176
  };
167
177
 
168
- export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, runDev, setBuildEnvVars, setupLint, writeNetlifyConfig };
169
- export type { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
178
+ export { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions, addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getApiUrl, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, runDev, setBuildEnvVars, setupLint, useWorkspace, writeNetlifyConfig };
179
+ export type { RuntimeWorkspaceConfig };
package/dist/index.d.mts CHANGED
@@ -1,45 +1,6 @@
1
- type WorkspaceEnvironment = 'localhost' | 'development' | 'production';
2
- interface WorkspaceConfig {
3
- /**
4
- * The host URL of the backend API server
5
- * @example 'http://localhost:8000' | 'https://project.bagel.to'
6
- */
7
- host: string;
8
- /**
9
- * The proxy path to use for API requests
10
- * @default '/api'
11
- */
12
- proxy: string;
13
- /**
14
- * Optional OpenAPI specification URL for SDK generation
15
- */
16
- openapi_url?: string;
17
- }
18
- interface WorkspaceOptions {
19
- /**
20
- * Root directory of the workspace
21
- * @default process.cwd()
22
- */
23
- root?: string;
24
- /**
25
- * Path to the config file relative to root
26
- * @default 'bgl.config.ts'
27
- */
28
- configFile?: string;
29
- /**
30
- * Enable interactive config generation if no config is found
31
- * @default true
32
- */
33
- interactive?: boolean;
34
- }
35
- interface ProxyConfig {
36
- [path: string]: {
37
- target: string;
38
- changeOrigin: boolean;
39
- rewrite?: (path: string) => string;
40
- secure: boolean;
41
- };
42
- }
1
+ import { W as WorkspaceConfig, a as WorkspaceEnvironment, b as WorkspaceOptions, P as ProxyConfig } from './shared/workspace.CSNgk3PR.mjs';
2
+ export { B as BagelinkPluginOptions, c as bagelink } from './shared/workspace.CSNgk3PR.mjs';
3
+ import 'vite';
43
4
 
44
5
  /**
45
6
  * Load and resolve bgl.config.ts with cascading support
@@ -63,16 +24,17 @@ declare function generateWorkspaceConfigSync(projectId: string, root?: string, c
63
24
 
64
25
  /**
65
26
  * Generate netlify.toml redirect configuration
27
+ * Uses environment variables for flexibility across environments
66
28
  */
67
29
  declare function generateNetlifyRedirect(config: WorkspaceConfig): string;
68
30
  /**
69
31
  * Generate complete netlify.toml file
70
32
  */
71
- declare function generateNetlifyConfig(config: WorkspaceConfig, additionalConfig?: string): string;
33
+ declare function generateNetlifyConfig(config: WorkspaceConfig, additionalConfig?: string, useTemplate?: boolean): string;
72
34
  /**
73
35
  * Write netlify.toml file to disk
74
36
  */
75
- declare function writeNetlifyConfig(config: WorkspaceConfig, outPath?: string, additionalConfig?: string): void;
37
+ declare function writeNetlifyConfig(config: WorkspaceConfig, outPath?: string, additionalConfig?: string, useTemplate?: boolean): void;
76
38
  /**
77
39
  * Set environment variables for build process
78
40
  */
@@ -91,6 +53,54 @@ declare function createCustomProxy(paths: string[], target: string, options?: {
91
53
  secure?: boolean;
92
54
  }): ProxyConfig;
93
55
 
56
+ /**
57
+ * Runtime workspace configuration
58
+ * Provides access to workspace config injected at build time
59
+ */
60
+ interface RuntimeWorkspaceConfig {
61
+ /** API proxy path (e.g., '/api') */
62
+ proxy: string;
63
+ /** API host URL (e.g., 'https://project.bagel.to') */
64
+ host: string;
65
+ /** OpenAPI specification URL (if configured) */
66
+ openapiUrl?: string;
67
+ /** Current environment mode */
68
+ mode: 'localhost' | 'development' | 'production';
69
+ }
70
+ /**
71
+ * Get workspace configuration at runtime
72
+ * Config is injected as environment variables during build
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * import { useWorkspace } from '@bagelink/workspace'
77
+ *
78
+ * const { proxy, host } = useWorkspace()
79
+ * const auth = initAuth({ baseURL: proxy })
80
+ * ```
81
+ *
82
+ * @example In Vue component
83
+ * ```vue
84
+ * <script setup>
85
+ * import { useWorkspace } from '@bagelink/workspace'
86
+ *
87
+ * const { proxy, host, mode } = useWorkspace()
88
+ * </script>
89
+ * ```
90
+ */
91
+ declare function useWorkspace(): RuntimeWorkspaceConfig;
92
+ /**
93
+ * Get the full API URL by combining host and proxy
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { getApiUrl } from '@bagelink/workspace'
98
+ *
99
+ * const apiUrl = getApiUrl() // 'https://project.bagel.to/api'
100
+ * ```
101
+ */
102
+ declare function getApiUrl(): string;
103
+
94
104
  /**
95
105
  * Detect if current directory is a workspace root
96
106
  */
@@ -165,5 +175,5 @@ declare function createWorkspace(options?: WorkspaceOptions): {
165
175
  clearCache(): void;
166
176
  };
167
177
 
168
- export { addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, runDev, setBuildEnvVars, setupLint, writeNetlifyConfig };
169
- export type { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions };
178
+ export { ProxyConfig, WorkspaceConfig, WorkspaceEnvironment, WorkspaceOptions, addProject, createCustomProxy, createViteProxy, createWorkspace, defineWorkspace, generateNetlifyConfig, generateNetlifyRedirect, generateSDK, generateSDKForWorkspace, generateWorkspaceConfig, generateWorkspaceConfigSync, getApiUrl, getWorkspaceInfo, initWorkspace, isWorkspace, listProjects, mergeConfigs, resolveConfig, runDev, setBuildEnvVars, setupLint, useWorkspace, writeNetlifyConfig };
179
+ export type { RuntimeWorkspaceConfig };