@datalayer/core 1.1.41 → 1.1.45
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 +10 -121
- package/lib/client/auth/AuthenticationManager.d.ts +3 -3
- package/lib/client/auth/AuthenticationManager.js +13 -13
- package/lib/client/auth/strategies.d.ts +2 -2
- package/lib/client/auth/strategies.js +6 -6
- package/lib/client/base.d.ts +9 -9
- package/lib/client/base.js +17 -17
- package/lib/client/mixins/IAMMixin.js +26 -26
- package/lib/components/auth/Login.js +2 -2
- package/lib/components/billing/BillingEntitySelect.d.ts +35 -0
- package/lib/components/billing/{BillableAccountSelect.js → BillingEntitySelect.js} +39 -41
- package/lib/components/billing/index.d.ts +1 -1
- package/lib/components/billing/index.js +1 -1
- package/lib/components/checkout/StripeCheckout.js +5 -5
- package/lib/components/display/VisuallyHidden.d.ts +1 -1
- package/lib/components/display/index.d.ts +0 -1
- package/lib/components/display/index.js +0 -1
- package/lib/components/principal/Principal.js +4 -2
- package/lib/components/principal/PrincipalBadge.js +21 -0
- package/lib/components/principal/PrincipalDetailsOverlay.js +72 -37
- package/lib/components/principal/PrincipalSwitcherMenu.d.ts +3 -3
- package/lib/components/principal/PrincipalSwitcherMenu.js +133 -114
- package/lib/components/sharing/ShareAccessComponent.js +14 -14
- package/lib/config/Configuration.d.ts +13 -13
- package/lib/config/Configuration.js +5 -5
- package/lib/hooks/index.d.ts +2 -2
- package/lib/hooks/index.js +2 -2
- package/lib/hooks/useBillingEntityStore.d.ts +31 -0
- package/lib/hooks/useBillingEntityStore.js +53 -0
- package/lib/hooks/useCache.d.ts +34 -33
- package/lib/hooks/useCache.js +298 -282
- package/lib/hooks/useIAM.js +1 -1
- package/lib/hooks/useSelectedBillingEntity.d.ts +14 -0
- package/lib/hooks/{useSelectedBillableAccount.js → useSelectedBillingEntity.js} +14 -14
- package/lib/hooks/useSelectedPrincipal.d.ts +1 -1
- package/lib/hooks/useSelectedPrincipal.js +1 -1
- package/lib/models/UserSettings.d.ts +1 -1
- package/lib/models/UserSettings.js +1 -1
- package/lib/otel/client/OtelClient.d.ts +2 -2
- package/lib/otel/client/OtelClient.js +2 -2
- package/lib/otel/hooks/index.js +5 -5
- package/lib/otel/types.d.ts +1 -1
- package/lib/otel/views/OtelLive.js +1 -1
- package/lib/state/substates/CoreState.js +13 -13
- package/lib/state/substates/IAMState.d.ts +1 -1
- package/lib/state/substates/IAMState.js +14 -14
- package/lib/state/substates/SurveysState.d.ts +1 -1
- package/lib/state/substates/SurveysState.js +10 -10
- package/lib/views/iam/SignInSimple.js +6 -6
- package/package.json +4 -4
- package/lib/components/billing/BillableAccountSelect.d.ts +0 -35
- package/lib/components/display/LiveRelativeTime.d.ts +0 -1
- package/lib/components/display/LiveRelativeTime.js +0 -10
- package/lib/hooks/useBillableAccountStore.d.ts +0 -31
- package/lib/hooks/useBillableAccountStore.js +0 -53
- package/lib/hooks/useSelectedBillableAccount.d.ts +0 -14
package/README.md
CHANGED
|
@@ -25,12 +25,10 @@ This package serves as the base foundation used by many other Datalayer packages
|
|
|
25
25
|
## Key Features
|
|
26
26
|
|
|
27
27
|
- **🔐 Simple Authentication**: Easy token-based authentication with environment variable support
|
|
28
|
-
- **⚡ Runtime Management**: Create and manage scalable compute runtimes (CPU/GPU) for code execution
|
|
29
|
-
- **📸 Snapshot Management**: Create and manage compute snapshots of your runtimes for reproducible environments
|
|
30
28
|
- **🔒 Secrets Management**: Securely handle sensitive data and credentials in your workflows
|
|
31
29
|
- **🐍 Python Client**: Programmatic access to Datalayer platform with context managers and clean resource management
|
|
32
30
|
- **🌐 TypeScript/React Client**: React components and services for building Jupyter-based applications
|
|
33
|
-
- **💻 Command Line Interface**: CLI tools for
|
|
31
|
+
- **💻 Command Line Interface**: CLI tools for account and platform operations
|
|
34
32
|
- **🔧 Base Classes**: Core application classes and configuration inherited by other Datalayer projects
|
|
35
33
|
- **📓 Jupyter Integration**: ServiceManager and collaboration providers for notebook experiences
|
|
36
34
|
- **🧭 Universal Navigation**: Smart navigation hooks that auto-detect and work with React Router, Next.js, or native browser
|
|
@@ -85,136 +83,27 @@ from datalayer_core import DatalayerClient
|
|
|
85
83
|
client = DatalayerClient()
|
|
86
84
|
|
|
87
85
|
# Or pass token directly
|
|
88
|
-
client = DatalayerClient(
|
|
86
|
+
client = DatalayerClient(api_key="your-api-key-here")
|
|
89
87
|
|
|
90
88
|
if client.authenticate():
|
|
91
89
|
print("Successfully authenticated!")
|
|
92
90
|
```
|
|
93
91
|
|
|
94
|
-
### 2.
|
|
92
|
+
### 2. Runtime, Snapshots, and Evals
|
|
95
93
|
|
|
96
|
-
|
|
97
|
-
> [`agent-runtimes`](https://github.com/datalayer/agent-runtimes) package. Use its
|
|
98
|
-
> `RuntimeClient` (and the `@datalayer` decorator) for runtime workloads. The
|
|
99
|
-
> `datalayer-core` `DatalayerClient` now focuses on account/platform operations
|
|
100
|
-
> (authentication, secrets, API keys, usage, profile).
|
|
94
|
+
Runtime execution, snapshot workflows, and evals CLI are now documented and maintained in:
|
|
101
95
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
client = RuntimeClient()
|
|
106
|
-
|
|
107
|
-
# Execute code in a managed runtime
|
|
108
|
-
with client.create_runtime() as runtime:
|
|
109
|
-
response = runtime.execute("print('Hello from Datalayer!')")
|
|
110
|
-
print(response.stdout)
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### 3. Using the CLI
|
|
114
|
-
|
|
115
|
-
The CLI provides command-line access to Datalayer platform features:
|
|
96
|
+
- [agent-runtimes README](https://github.com/datalayer/agent-runtimes/blob/main/README.md)
|
|
97
|
+
- [agent-runtimes CLI docs](https://agent-runtimes.datalayer.tech/cli)
|
|
116
98
|
|
|
117
|
-
|
|
118
|
-
# List available runtimes
|
|
119
|
-
datalayer runtime list
|
|
120
|
-
|
|
121
|
-
# Create a new runtime
|
|
122
|
-
datalayer runtime create ai-env --given-name my-runtime-123
|
|
123
|
-
|
|
124
|
-
# Execute a script in a runtime
|
|
125
|
-
datalayer runtime exec my-script.py --agent <agent-id>
|
|
126
|
-
|
|
127
|
-
# Create a snapshot from a runtime but do not terminate the runtime
|
|
128
|
-
datalayer snapshots create <pod-name> my-snapshot 'AI work!' False
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### 4. Subscription and Credits CLI
|
|
132
|
-
|
|
133
|
-
Use these commands to inspect billing and manage credits distribution.
|
|
134
|
-
|
|
135
|
-
```bash
|
|
136
|
-
# End-user billing view
|
|
137
|
-
datalayer subscriptions show
|
|
138
|
-
datalayer subscriptions available
|
|
139
|
-
datalayer subscriptions move
|
|
140
|
-
datalayer subscriptions topups
|
|
141
|
-
datalayer subscriptions dry-run
|
|
142
|
-
|
|
143
|
-
# Organization and team credits visibility
|
|
144
|
-
datalayer usage org-overview --organization-uid <org_uid>
|
|
145
|
-
datalayer usage team-overview --team-uid <team_uid>
|
|
146
|
-
|
|
147
|
-
# Monitoring-driven credit management
|
|
148
|
-
datalayer usage org-monitor --organization-uid <org_uid> --window-hours 24
|
|
149
|
-
datalayer usage team-monitor --team-uid <team_uid> --window-hours 24
|
|
150
|
-
|
|
151
|
-
# Credits transfer operations (owners/admins)
|
|
152
|
-
datalayer usage org-allocate-team --organization-uid <org_uid> --team-uid <team_uid> --amount 50
|
|
153
|
-
datalayer usage org-revoke-team --organization-uid <org_uid> --team-uid <team_uid> --amount 20
|
|
154
|
-
datalayer usage team-allocate-member --team-uid <team_uid> --member-uid <member_uid> --amount 15
|
|
155
|
-
datalayer usage team-revoke-member --team-uid <team_uid> --member-uid <member_uid> --amount 5
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### 5. Evals CLI (Multi-Agentspec)
|
|
159
|
-
|
|
160
|
-
Use comma-separated agentspec ids to create one experiment per agentspec variant:
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
# Creates one experiment per agentspec in the list
|
|
164
|
-
agent-runtimes evals experiments create my-exp \
|
|
165
|
-
--evalset-id <evalset_id> \
|
|
166
|
-
--agent-spec-ids example-evals,example-evals-nocodemode,example-custom
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Generate a comparison report:
|
|
170
|
-
|
|
171
|
-
```bash
|
|
172
|
-
agent-runtimes evals report <evalset_id> --run-limit 50 --export
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
How to interpret grouped comparisons in the report:
|
|
176
|
-
|
|
177
|
-
- `Within-Agentspec Pairwise Latest-Pass Deltas`: compares experiments using the same agentspec id.
|
|
178
|
-
- `Cross-Agentspec Pairwise Latest-Pass Deltas`: compares experiments using different agentspec ids.
|
|
179
|
-
- Pairwise sections compute all combinations for the selected experiments, not just two agentspecs.
|
|
99
|
+
Use `agent-runtimes` for runtime workloads (`RuntimeClient`, `@datalayer`, snapshots, and evals), and use `datalayer-core` for account/platform operations (authentication, secrets, API keys, usage, profile).
|
|
180
100
|
|
|
181
101
|
## Examples
|
|
182
102
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
For comprehensive Python usage examples, see the [`examples/`](https://github.com/datalayer/core/tree/main/examples) directory which includes:
|
|
186
|
-
|
|
187
|
-
- **OpenTelemetry observability**: Traces and metrics instrumentation with a visualization UI
|
|
188
|
-
|
|
189
|
-
The framework and client examples (**FastAPI + scikit-learn**, **Streamlit + scikit-learn**, **PyTorch GPU workloads**, **`@datalayer` decorator patterns**, and **Next.js**) have moved to the [Agent Runtimes examples](https://github.com/datalayer/agent-runtimes/tree/main/examples).
|
|
190
|
-
|
|
191
|
-
### TypeScript/React Examples
|
|
192
|
-
|
|
193
|
-
Run the interactive examples locally:
|
|
194
|
-
|
|
195
|
-
```bash
|
|
196
|
-
# Install dependencies
|
|
197
|
-
npm install
|
|
198
|
-
|
|
199
|
-
# Set your Datalayer API token in .env
|
|
200
|
-
echo "VITE_DATALAYER_API_KEY=your-token-here" > .env
|
|
201
|
-
|
|
202
|
-
# Start the examples server
|
|
203
|
-
npm run examples
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
Available at http://localhost:3000/:
|
|
207
|
-
|
|
208
|
-
- **DatalayerNotebookExample**: Full integration with Datalayer services and collaboration
|
|
209
|
-
- **NotebookExample**: Basic Jupyter notebook in React
|
|
210
|
-
- **CellExample**: Individual code cell execution
|
|
211
|
-
- **ReactRouterAdvancedExample**: Comprehensive navigation demo with React Router integration
|
|
212
|
-
- **ReactRouterNavigationExample**: Basic navigation with route parameters
|
|
213
|
-
- **NativeNavigationExample**: Browser-native navigation fallback
|
|
214
|
-
|
|
215
|
-
### Next.js Application Example
|
|
103
|
+
Examples have moved to Agent Runtimes:
|
|
216
104
|
|
|
217
|
-
|
|
105
|
+
- [Agent Runtimes examples README](https://github.com/datalayer/agent-runtimes/blob/main/examples/README.md)
|
|
106
|
+
- [Agent Runtimes examples directory](https://github.com/datalayer/agent-runtimes/tree/main/examples)
|
|
218
107
|
|
|
219
108
|
## Platform Integration
|
|
220
109
|
|
|
@@ -10,15 +10,15 @@ import { UserDTO } from '../../models/UserDTO';
|
|
|
10
10
|
export declare class AuthenticationManager {
|
|
11
11
|
private strategies;
|
|
12
12
|
private storage;
|
|
13
|
-
private
|
|
13
|
+
private iamUrl;
|
|
14
14
|
private currentUser?;
|
|
15
15
|
private currentToken?;
|
|
16
16
|
/**
|
|
17
17
|
* Create an AuthenticationManager instance
|
|
18
|
-
* @param
|
|
18
|
+
* @param iamUrl - IAM service URL (e.g., "https://prod1.datalayer.run")
|
|
19
19
|
* @param storage - Token storage backend (optional, defaults to auto-detected)
|
|
20
20
|
*/
|
|
21
|
-
constructor(
|
|
21
|
+
constructor(iamUrl: string, storage?: TokenStorage);
|
|
22
22
|
/**
|
|
23
23
|
* Login using various authentication methods
|
|
24
24
|
* Automatically selects the appropriate strategy based on options
|
|
@@ -15,25 +15,25 @@ import { NodeStorage, BrowserStorage } from './storage.js';
|
|
|
15
15
|
export class AuthenticationManager {
|
|
16
16
|
strategies;
|
|
17
17
|
storage;
|
|
18
|
-
|
|
18
|
+
iamUrl;
|
|
19
19
|
currentUser;
|
|
20
20
|
currentToken;
|
|
21
21
|
/**
|
|
22
22
|
* Create an AuthenticationManager instance
|
|
23
|
-
* @param
|
|
23
|
+
* @param iamUrl - IAM service URL (e.g., "https://prod1.datalayer.run")
|
|
24
24
|
* @param storage - Token storage backend (optional, defaults to auto-detected)
|
|
25
25
|
*/
|
|
26
|
-
constructor(
|
|
27
|
-
this.
|
|
28
|
-
// Extract
|
|
29
|
-
const
|
|
30
|
-
// CRITICAL: Pass
|
|
26
|
+
constructor(iamUrl, storage) {
|
|
27
|
+
this.iamUrl = iamUrl;
|
|
28
|
+
// Extract datalayer_url (remove /api/iam/v1 if present)
|
|
29
|
+
const datalayerUrl = iamUrl.replace('/api/iam/v1', '');
|
|
30
|
+
// CRITICAL: Pass datalayerUrl to storage for keyring compatibility
|
|
31
31
|
if (!storage) {
|
|
32
32
|
if (typeof window !== 'undefined') {
|
|
33
33
|
this.storage = new BrowserStorage();
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
this.storage = new NodeStorage(
|
|
36
|
+
this.storage = new NodeStorage(datalayerUrl); // Pass datalayerUrl as serviceUrl
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
@@ -41,10 +41,10 @@ export class AuthenticationManager {
|
|
|
41
41
|
}
|
|
42
42
|
// Initialize strategies
|
|
43
43
|
this.strategies = [
|
|
44
|
-
new TokenAuthStrategy(this.
|
|
45
|
-
new CredentialsAuthStrategy(this.
|
|
46
|
-
new StorageAuthStrategy(this.
|
|
47
|
-
new BrowserOAuthStrategy(this.
|
|
44
|
+
new TokenAuthStrategy(this.iamUrl, this.storage),
|
|
45
|
+
new CredentialsAuthStrategy(this.iamUrl, this.storage),
|
|
46
|
+
new StorageAuthStrategy(this.iamUrl, this.storage),
|
|
47
|
+
new BrowserOAuthStrategy(this.iamUrl, this.storage),
|
|
48
48
|
];
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
@@ -98,7 +98,7 @@ export class AuthenticationManager {
|
|
|
98
98
|
async logout() {
|
|
99
99
|
if (this.currentToken) {
|
|
100
100
|
try {
|
|
101
|
-
await authentication.logout(this.currentToken, this.
|
|
101
|
+
await authentication.logout(this.currentToken, this.iamUrl);
|
|
102
102
|
}
|
|
103
103
|
catch (error) {
|
|
104
104
|
console.error('Error during logout API call:', error);
|
|
@@ -4,9 +4,9 @@ import { UserDTO } from '../../models/UserDTO';
|
|
|
4
4
|
* Base authentication strategy with common functionality
|
|
5
5
|
*/
|
|
6
6
|
declare abstract class BaseAuthStrategy implements AuthStrategy {
|
|
7
|
-
protected
|
|
7
|
+
protected iamUrl: string;
|
|
8
8
|
protected storage?: TokenStorage | undefined;
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(iamUrl: string, storage?: TokenStorage | undefined);
|
|
10
10
|
abstract authenticate(options: AuthOptions): Promise<AuthResult>;
|
|
11
11
|
abstract canHandle(options: AuthOptions): boolean;
|
|
12
12
|
/**
|
|
@@ -17,17 +17,17 @@ import { UserDTO } from '../../models/UserDTO.js';
|
|
|
17
17
|
* Base authentication strategy with common functionality
|
|
18
18
|
*/
|
|
19
19
|
class BaseAuthStrategy {
|
|
20
|
-
|
|
20
|
+
iamUrl;
|
|
21
21
|
storage;
|
|
22
|
-
constructor(
|
|
23
|
-
this.
|
|
22
|
+
constructor(iamUrl, storage) {
|
|
23
|
+
this.iamUrl = iamUrl;
|
|
24
24
|
this.storage = storage;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Validate a token by calling whoami
|
|
28
28
|
*/
|
|
29
29
|
async validateToken(token) {
|
|
30
|
-
const response = await profile.whoami(token, this.
|
|
30
|
+
const response = await profile.whoami(token, this.iamUrl);
|
|
31
31
|
if (!response || !response.profile) {
|
|
32
32
|
throw new Error('Invalid response from profile API');
|
|
33
33
|
}
|
|
@@ -82,7 +82,7 @@ export class CredentialsAuthStrategy extends BaseAuthStrategy {
|
|
|
82
82
|
throw new Error('Handle and password are required for credentials authentication');
|
|
83
83
|
}
|
|
84
84
|
// Call the login API
|
|
85
|
-
const response = await authentication.login({ handle: options.handle, password: options.password }, this.
|
|
85
|
+
const response = await authentication.login({ handle: options.handle, password: options.password }, this.iamUrl);
|
|
86
86
|
if (!response || !response.success || !response.token) {
|
|
87
87
|
throw new Error(response?.message || 'Login failed');
|
|
88
88
|
}
|
|
@@ -158,7 +158,7 @@ export class BrowserOAuthStrategy extends BaseAuthStrategy {
|
|
|
158
158
|
const callbackUri = options.callbackUri || `${window.location.origin}/auth/callback`;
|
|
159
159
|
try {
|
|
160
160
|
// Step 1: Get OAuth authorization URL
|
|
161
|
-
const authzResponse = await getOAuth2AuthzUrl(provider, callbackUri, this.
|
|
161
|
+
const authzResponse = await getOAuth2AuthzUrl(provider, callbackUri, this.iamUrl, options.nonce);
|
|
162
162
|
// Step 2: Open OAuth URL in popup or redirect
|
|
163
163
|
if (options.usePopup !== false) {
|
|
164
164
|
// Use popup window
|
package/lib/client/base.d.ts
CHANGED
|
@@ -14,11 +14,11 @@ export interface DatalayerClientConfig {
|
|
|
14
14
|
/** Authentication token for API requests */
|
|
15
15
|
token?: string;
|
|
16
16
|
/** URL for the IAM service */
|
|
17
|
-
|
|
17
|
+
iamUrl?: string;
|
|
18
18
|
/** URL for the Runtimes service */
|
|
19
|
-
|
|
19
|
+
runtimesUrl?: string;
|
|
20
20
|
/** URL for the Spacer service */
|
|
21
|
-
|
|
21
|
+
spacerUrl?: string;
|
|
22
22
|
/** Custom token storage backend (optional, defaults to auto-detected) */
|
|
23
23
|
storage?: TokenStorage;
|
|
24
24
|
/** Handlers for intercepting Client method calls */
|
|
@@ -27,11 +27,11 @@ export interface DatalayerClientConfig {
|
|
|
27
27
|
/** Base Client class providing core configuration and token management. */
|
|
28
28
|
export declare class DatalayerClientBase {
|
|
29
29
|
/** URL for IAM service */
|
|
30
|
-
readonly
|
|
30
|
+
readonly iamUrl: string;
|
|
31
31
|
/** URL for Runtimes service */
|
|
32
|
-
readonly
|
|
32
|
+
readonly runtimesUrl: string;
|
|
33
33
|
/** URL for Spacer service */
|
|
34
|
-
readonly
|
|
34
|
+
readonly spacerUrl: string;
|
|
35
35
|
/** Authentication token */
|
|
36
36
|
token?: string;
|
|
37
37
|
/** Method lifecycle handlers */
|
|
@@ -49,11 +49,11 @@ export declare class DatalayerClientBase {
|
|
|
49
49
|
*/
|
|
50
50
|
getConfig(): DatalayerClientConfig;
|
|
51
51
|
/** Get the IAM service URL. */
|
|
52
|
-
|
|
52
|
+
getIamUrl(): string;
|
|
53
53
|
/** Get the Runtimes service URL. */
|
|
54
|
-
|
|
54
|
+
getRuntimesUrl(): string;
|
|
55
55
|
/** Get the Spacer service URL. */
|
|
56
|
-
|
|
56
|
+
getSpacerUrl(): string;
|
|
57
57
|
/** Get the current authentication token. */
|
|
58
58
|
getToken(): string | undefined;
|
|
59
59
|
/**
|
package/lib/client/base.js
CHANGED
|
@@ -11,11 +11,11 @@ import { AuthenticationManager } from './auth/index.js';
|
|
|
11
11
|
/** Base Client class providing core configuration and token management. */
|
|
12
12
|
export class DatalayerClientBase {
|
|
13
13
|
/** URL for IAM service */
|
|
14
|
-
|
|
14
|
+
iamUrl;
|
|
15
15
|
/** URL for Runtimes service */
|
|
16
|
-
|
|
16
|
+
runtimesUrl;
|
|
17
17
|
/** URL for Spacer service */
|
|
18
|
-
|
|
18
|
+
spacerUrl;
|
|
19
19
|
/** Authentication token */
|
|
20
20
|
token;
|
|
21
21
|
/** Method lifecycle handlers */
|
|
@@ -27,14 +27,14 @@ export class DatalayerClientBase {
|
|
|
27
27
|
* @param config - Client configuration options
|
|
28
28
|
*/
|
|
29
29
|
constructor(config) {
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
config.
|
|
33
|
-
this.
|
|
30
|
+
this.iamUrl = config.iamUrl || DEFAULT_SERVICE_URLS.IAM;
|
|
31
|
+
this.runtimesUrl =
|
|
32
|
+
config.runtimesUrl || DEFAULT_SERVICE_URLS.RUNTIMES;
|
|
33
|
+
this.spacerUrl = config.spacerUrl || DEFAULT_SERVICE_URLS.SPACER;
|
|
34
34
|
this.token = config.token;
|
|
35
35
|
this.handlers = config.handlers;
|
|
36
36
|
// Initialize authentication manager with custom storage if provided
|
|
37
|
-
this.auth = new AuthenticationManager(this.
|
|
37
|
+
this.auth = new AuthenticationManager(this.iamUrl, config.storage);
|
|
38
38
|
// If a token was provided, store it in the auth manager
|
|
39
39
|
if (this.token) {
|
|
40
40
|
this.auth.storeToken(this.token);
|
|
@@ -46,23 +46,23 @@ export class DatalayerClientBase {
|
|
|
46
46
|
*/
|
|
47
47
|
getConfig() {
|
|
48
48
|
return {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
iamUrl: this.iamUrl,
|
|
50
|
+
runtimesUrl: this.runtimesUrl,
|
|
51
|
+
spacerUrl: this.spacerUrl,
|
|
52
52
|
token: this.token,
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
/** Get the IAM service URL. */
|
|
56
|
-
|
|
57
|
-
return this.
|
|
56
|
+
getIamUrl() {
|
|
57
|
+
return this.iamUrl;
|
|
58
58
|
}
|
|
59
59
|
/** Get the Runtimes service URL. */
|
|
60
|
-
|
|
61
|
-
return this.
|
|
60
|
+
getRuntimesUrl() {
|
|
61
|
+
return this.runtimesUrl;
|
|
62
62
|
}
|
|
63
63
|
/** Get the Spacer service URL. */
|
|
64
|
-
|
|
65
|
-
return this.
|
|
64
|
+
getSpacerUrl() {
|
|
65
|
+
return this.spacerUrl;
|
|
66
66
|
}
|
|
67
67
|
/** Get the current authentication token. */
|
|
68
68
|
getToken() {
|
|
@@ -29,8 +29,8 @@ export function IAMMixin(Base) {
|
|
|
29
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
30
|
const token = this.getToken();
|
|
31
31
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
const
|
|
33
|
-
const response = await profile.whoami(token,
|
|
32
|
+
const iamUrl = this.getIamUrl();
|
|
33
|
+
const response = await profile.whoami(token, iamUrl);
|
|
34
34
|
// Handle the whoami response format
|
|
35
35
|
let userData;
|
|
36
36
|
if (!response) {
|
|
@@ -83,8 +83,8 @@ export function IAMMixin(Base) {
|
|
|
83
83
|
/** Log out the current user. */
|
|
84
84
|
async logout() {
|
|
85
85
|
const token = this.getToken();
|
|
86
|
-
const
|
|
87
|
-
await authentication.logout(token,
|
|
86
|
+
const iamUrl = this.getIamUrl();
|
|
87
|
+
await authentication.logout(token, iamUrl);
|
|
88
88
|
// Clear the token from the Client and cached user
|
|
89
89
|
this.setToken('');
|
|
90
90
|
this.currentUserCache = undefined;
|
|
@@ -95,8 +95,8 @@ export function IAMMixin(Base) {
|
|
|
95
95
|
*/
|
|
96
96
|
async getCredits() {
|
|
97
97
|
const token = this.getToken();
|
|
98
|
-
const
|
|
99
|
-
const response = await usage.getCredits(token,
|
|
98
|
+
const iamUrl = this.getIamUrl();
|
|
99
|
+
const response = await usage.getCredits(token, iamUrl);
|
|
100
100
|
if (!response || !response.credits) {
|
|
101
101
|
throw new Error('Invalid response from credits API');
|
|
102
102
|
}
|
|
@@ -191,8 +191,8 @@ export function IAMMixin(Base) {
|
|
|
191
191
|
*/
|
|
192
192
|
async createSecret(data) {
|
|
193
193
|
const token = this.getToken();
|
|
194
|
-
const
|
|
195
|
-
const response = await secrets.createSecret(token, data,
|
|
194
|
+
const iamUrl = this.getIamUrl();
|
|
195
|
+
const response = await secrets.createSecret(token, data, iamUrl);
|
|
196
196
|
return new SecretDTO(response.secret, this);
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
@@ -201,8 +201,8 @@ export function IAMMixin(Base) {
|
|
|
201
201
|
*/
|
|
202
202
|
async listSecrets() {
|
|
203
203
|
const token = this.getToken();
|
|
204
|
-
const
|
|
205
|
-
const response = await secrets.listSecrets(token,
|
|
204
|
+
const iamUrl = this.getIamUrl();
|
|
205
|
+
const response = await secrets.listSecrets(token, iamUrl);
|
|
206
206
|
return response.secrets.map(s => new SecretDTO(s, this));
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
@@ -212,8 +212,8 @@ export function IAMMixin(Base) {
|
|
|
212
212
|
*/
|
|
213
213
|
async getSecret(secretId) {
|
|
214
214
|
const token = this.getToken();
|
|
215
|
-
const
|
|
216
|
-
const response = await secrets.getSecret(token, secretId,
|
|
215
|
+
const iamUrl = this.getIamUrl();
|
|
216
|
+
const response = await secrets.getSecret(token, secretId, iamUrl);
|
|
217
217
|
return new SecretDTO(response.secret, this);
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
@@ -224,8 +224,8 @@ export function IAMMixin(Base) {
|
|
|
224
224
|
*/
|
|
225
225
|
async updateSecret(secretId, updates) {
|
|
226
226
|
const token = this.getToken();
|
|
227
|
-
const
|
|
228
|
-
const response = await secrets.updateSecret(token, secretId, updates,
|
|
227
|
+
const iamUrl = this.getIamUrl();
|
|
228
|
+
const response = await secrets.updateSecret(token, secretId, updates, iamUrl);
|
|
229
229
|
return new SecretDTO(response.secret, this);
|
|
230
230
|
}
|
|
231
231
|
/**
|
|
@@ -234,8 +234,8 @@ export function IAMMixin(Base) {
|
|
|
234
234
|
*/
|
|
235
235
|
async deleteSecret(secretId) {
|
|
236
236
|
const token = this.getToken();
|
|
237
|
-
const
|
|
238
|
-
await secrets.deleteSecret(token, secretId,
|
|
237
|
+
const iamUrl = this.getIamUrl();
|
|
238
|
+
await secrets.deleteSecret(token, secretId, iamUrl);
|
|
239
239
|
}
|
|
240
240
|
// ========================================================================
|
|
241
241
|
// Datasources Management
|
|
@@ -247,8 +247,8 @@ export function IAMMixin(Base) {
|
|
|
247
247
|
*/
|
|
248
248
|
async createDatasource(data) {
|
|
249
249
|
const token = this.getToken();
|
|
250
|
-
const
|
|
251
|
-
const response = await datasources.createDatasource(token, data,
|
|
250
|
+
const iamUrl = this.getIamUrl();
|
|
251
|
+
const response = await datasources.createDatasource(token, data, iamUrl);
|
|
252
252
|
return new DatasourceDTO(response.datasource, this);
|
|
253
253
|
}
|
|
254
254
|
/**
|
|
@@ -257,8 +257,8 @@ export function IAMMixin(Base) {
|
|
|
257
257
|
*/
|
|
258
258
|
async listDatasources() {
|
|
259
259
|
const token = this.getToken();
|
|
260
|
-
const
|
|
261
|
-
const response = await datasources.listDatasources(token,
|
|
260
|
+
const iamUrl = this.getIamUrl();
|
|
261
|
+
const response = await datasources.listDatasources(token, iamUrl);
|
|
262
262
|
return response.datasources.map(d => new DatasourceDTO(d, this));
|
|
263
263
|
}
|
|
264
264
|
/**
|
|
@@ -268,8 +268,8 @@ export function IAMMixin(Base) {
|
|
|
268
268
|
*/
|
|
269
269
|
async getDatasource(datasourceId) {
|
|
270
270
|
const token = this.getToken();
|
|
271
|
-
const
|
|
272
|
-
const response = await datasources.getDatasource(token, datasourceId,
|
|
271
|
+
const iamUrl = this.getIamUrl();
|
|
272
|
+
const response = await datasources.getDatasource(token, datasourceId, iamUrl);
|
|
273
273
|
return new DatasourceDTO(response.datasource, this);
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
@@ -280,8 +280,8 @@ export function IAMMixin(Base) {
|
|
|
280
280
|
*/
|
|
281
281
|
async updateDatasource(datasourceId, updates) {
|
|
282
282
|
const token = this.getToken();
|
|
283
|
-
const
|
|
284
|
-
const response = await datasources.updateDatasource(token, datasourceId, updates,
|
|
283
|
+
const iamUrl = this.getIamUrl();
|
|
284
|
+
const response = await datasources.updateDatasource(token, datasourceId, updates, iamUrl);
|
|
285
285
|
return new DatasourceDTO(response.datasource, this);
|
|
286
286
|
}
|
|
287
287
|
/**
|
|
@@ -290,8 +290,8 @@ export function IAMMixin(Base) {
|
|
|
290
290
|
*/
|
|
291
291
|
async deleteDatasource(datasourceId) {
|
|
292
292
|
const token = this.getToken();
|
|
293
|
-
const
|
|
294
|
-
await datasources.deleteDatasource(token, datasourceId,
|
|
293
|
+
const iamUrl = this.getIamUrl();
|
|
294
|
+
await datasources.deleteDatasource(token, datasourceId, iamUrl);
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
297
|
}
|
|
@@ -22,7 +22,7 @@ export const Login = (props) => {
|
|
|
22
22
|
const loginMutation = useLogin();
|
|
23
23
|
const getOAuth2URLMutation = useOAuth2AuthorizationURL();
|
|
24
24
|
const { loginAndNavigate, setLogin } = useIAM();
|
|
25
|
-
const { externalToken, iamProvidersAuthorizationURL, addIAMProviderAuthorizationURL,
|
|
25
|
+
const { externalToken, iamProvidersAuthorizationURL, addIAMProviderAuthorizationURL, iamUrl, logout, checkIAMToken, } = useIAMStore();
|
|
26
26
|
const { enqueueToast } = useToast();
|
|
27
27
|
const navigate = useNavigate();
|
|
28
28
|
const [loading, setLoading] = useState(false);
|
|
@@ -76,7 +76,7 @@ export const Login = (props) => {
|
|
|
76
76
|
if (!iamProvidersAuthorizationURL[IAMProvidersSpecs.LinkedIn.name]) {
|
|
77
77
|
initIAMProvider(IAMProvidersSpecs.LinkedIn);
|
|
78
78
|
}
|
|
79
|
-
}, [
|
|
79
|
+
}, [iamUrl, iamProvidersAuthorizationURL, addIAMProviderAuthorizationURL]);
|
|
80
80
|
useEffect(() => {
|
|
81
81
|
if (externalToken) {
|
|
82
82
|
setLoadingWithToken(1);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type BillingEntityType = 'user' | 'organization' | 'team';
|
|
2
|
+
export type BillingEntity = {
|
|
3
|
+
accountUid: string;
|
|
4
|
+
accountType: BillingEntityType;
|
|
5
|
+
accountHandle: string;
|
|
6
|
+
accountName: string;
|
|
7
|
+
planName: string;
|
|
8
|
+
isEligible: boolean;
|
|
9
|
+
isPaidPlan: boolean;
|
|
10
|
+
sourceOrganizationUid?: string;
|
|
11
|
+
sourceOrganizationHandle?: string;
|
|
12
|
+
teamHandle?: string;
|
|
13
|
+
};
|
|
14
|
+
export type BillingEntitySelectProps = {
|
|
15
|
+
value: string;
|
|
16
|
+
onChange: (accountUid: string) => void;
|
|
17
|
+
onSelectedAccountChange?: (account: BillingEntity | undefined) => void;
|
|
18
|
+
onAccountsResolved?: (state: {
|
|
19
|
+
accounts: BillingEntity[];
|
|
20
|
+
eligibleAccounts: BillingEntity[];
|
|
21
|
+
isLoading: boolean;
|
|
22
|
+
hasEligibleAccount: boolean;
|
|
23
|
+
}) => void;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
label?: string;
|
|
26
|
+
caption?: string;
|
|
27
|
+
emptyMessage?: string;
|
|
28
|
+
flashMessage?: string;
|
|
29
|
+
width?: string | number;
|
|
30
|
+
preferOrganizationDefault?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export declare function resolveBillingPlanTier(value: unknown): 'free' | 'pro';
|
|
33
|
+
export declare function formatBillingEntityPlanLabel(planName: string): string;
|
|
34
|
+
export declare function BillingEntitySelect({ value, onChange, onSelectedAccountChange, onAccountsResolved, disabled, label, caption, emptyMessage, flashMessage, width, preferOrganizationDefault, }: BillingEntitySelectProps): JSX.Element;
|
|
35
|
+
export default BillingEntitySelect;
|