@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.
Files changed (56) hide show
  1. package/README.md +10 -121
  2. package/lib/client/auth/AuthenticationManager.d.ts +3 -3
  3. package/lib/client/auth/AuthenticationManager.js +13 -13
  4. package/lib/client/auth/strategies.d.ts +2 -2
  5. package/lib/client/auth/strategies.js +6 -6
  6. package/lib/client/base.d.ts +9 -9
  7. package/lib/client/base.js +17 -17
  8. package/lib/client/mixins/IAMMixin.js +26 -26
  9. package/lib/components/auth/Login.js +2 -2
  10. package/lib/components/billing/BillingEntitySelect.d.ts +35 -0
  11. package/lib/components/billing/{BillableAccountSelect.js → BillingEntitySelect.js} +39 -41
  12. package/lib/components/billing/index.d.ts +1 -1
  13. package/lib/components/billing/index.js +1 -1
  14. package/lib/components/checkout/StripeCheckout.js +5 -5
  15. package/lib/components/display/VisuallyHidden.d.ts +1 -1
  16. package/lib/components/display/index.d.ts +0 -1
  17. package/lib/components/display/index.js +0 -1
  18. package/lib/components/principal/Principal.js +4 -2
  19. package/lib/components/principal/PrincipalBadge.js +21 -0
  20. package/lib/components/principal/PrincipalDetailsOverlay.js +72 -37
  21. package/lib/components/principal/PrincipalSwitcherMenu.d.ts +3 -3
  22. package/lib/components/principal/PrincipalSwitcherMenu.js +133 -114
  23. package/lib/components/sharing/ShareAccessComponent.js +14 -14
  24. package/lib/config/Configuration.d.ts +13 -13
  25. package/lib/config/Configuration.js +5 -5
  26. package/lib/hooks/index.d.ts +2 -2
  27. package/lib/hooks/index.js +2 -2
  28. package/lib/hooks/useBillingEntityStore.d.ts +31 -0
  29. package/lib/hooks/useBillingEntityStore.js +53 -0
  30. package/lib/hooks/useCache.d.ts +34 -33
  31. package/lib/hooks/useCache.js +298 -282
  32. package/lib/hooks/useIAM.js +1 -1
  33. package/lib/hooks/useSelectedBillingEntity.d.ts +14 -0
  34. package/lib/hooks/{useSelectedBillableAccount.js → useSelectedBillingEntity.js} +14 -14
  35. package/lib/hooks/useSelectedPrincipal.d.ts +1 -1
  36. package/lib/hooks/useSelectedPrincipal.js +1 -1
  37. package/lib/models/UserSettings.d.ts +1 -1
  38. package/lib/models/UserSettings.js +1 -1
  39. package/lib/otel/client/OtelClient.d.ts +2 -2
  40. package/lib/otel/client/OtelClient.js +2 -2
  41. package/lib/otel/hooks/index.js +5 -5
  42. package/lib/otel/types.d.ts +1 -1
  43. package/lib/otel/views/OtelLive.js +1 -1
  44. package/lib/state/substates/CoreState.js +13 -13
  45. package/lib/state/substates/IAMState.d.ts +1 -1
  46. package/lib/state/substates/IAMState.js +14 -14
  47. package/lib/state/substates/SurveysState.d.ts +1 -1
  48. package/lib/state/substates/SurveysState.js +10 -10
  49. package/lib/views/iam/SignInSimple.js +6 -6
  50. package/package.json +4 -4
  51. package/lib/components/billing/BillableAccountSelect.d.ts +0 -35
  52. package/lib/components/display/LiveRelativeTime.d.ts +0 -1
  53. package/lib/components/display/LiveRelativeTime.js +0 -10
  54. package/lib/hooks/useBillableAccountStore.d.ts +0 -31
  55. package/lib/hooks/useBillableAccountStore.js +0 -53
  56. package/lib/hooks/useSelectedBillableAccount.d.ts +0 -14
@@ -19,7 +19,7 @@ export const useIAM = (props = { user: undefined, token: undefined }) => {
19
19
  const loginAndNavigate = async (token, logout, refresh, navigate, homeRoute) => {
20
20
  try {
21
21
  const resp = await requestDatalayerAPI({
22
- url: `${iamStore.iamRunUrl}/api/iam/v1/login`,
22
+ url: `${iamStore.iamUrl}/api/iam/v1/login`,
23
23
  method: 'POST',
24
24
  body: { token },
25
25
  });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Read-only selector for the currently scoped billing entity.
3
+ *
4
+ * Use this for billing, quotas, plans, credits, agents, and runtime capacity.
5
+ * For visibility/creation/sharing scope, use {@link useSelectedPrincipal}.
6
+ */
7
+ export declare function useSelectedBillingEntity(): {
8
+ billingEntityKind: string;
9
+ billingEntityUid: string | undefined;
10
+ billingEntityHandle: string | undefined;
11
+ isUserAccount: boolean;
12
+ isOrganizationAccount: boolean;
13
+ };
14
+ export default useSelectedBillingEntity;
@@ -2,35 +2,35 @@
2
2
  * Copyright (c) 2023-2025 Datalayer, Inc.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
- import { useBillableAccountStore } from './useBillableAccountStore.js';
5
+ import { useBillingEntityStore } from './useBillingEntityStore.js';
6
6
  import { useSelectedPrincipal } from './useSelectedPrincipal.js';
7
7
  /**
8
- * Read-only selector for the currently scoped billable account.
8
+ * Read-only selector for the currently scoped billing entity.
9
9
  *
10
10
  * Use this for billing, quotas, plans, credits, agents, and runtime capacity.
11
11
  * For visibility/creation/sharing scope, use {@link useSelectedPrincipal}.
12
12
  */
13
- export function useSelectedBillableAccount() {
14
- const persistedUid = useBillableAccountStore(state => state.billableAccountUid);
15
- const persistedHandle = useBillableAccountStore(state => state.billableAccountHandle);
13
+ export function useSelectedBillingEntity() {
14
+ const persistedUid = useBillingEntityStore(state => state.billingEntityUid);
15
+ const persistedHandle = useBillingEntityStore(state => state.billingEntityHandle);
16
16
  const { selectedPrincipalKind, selectedPrincipalUid, selectedPrincipalHandle, selectedTeamParentOrganizationUid, selectedTeamParentOrganizationHandle, } = useSelectedPrincipal();
17
- const billableAccountKind = selectedPrincipalKind === 'team'
17
+ const billingEntityKind = selectedPrincipalKind === 'team'
18
18
  ? 'organization'
19
19
  : selectedPrincipalKind === 'organization'
20
20
  ? 'organization'
21
21
  : 'user';
22
- const billableAccountUid = selectedPrincipalKind === 'team'
22
+ const billingEntityUid = selectedPrincipalKind === 'team'
23
23
  ? selectedTeamParentOrganizationUid || persistedUid
24
24
  : selectedPrincipalUid || persistedUid;
25
- const billableAccountHandle = selectedPrincipalKind === 'team'
25
+ const billingEntityHandle = selectedPrincipalKind === 'team'
26
26
  ? selectedTeamParentOrganizationHandle || persistedHandle
27
27
  : selectedPrincipalHandle || persistedHandle;
28
28
  return {
29
- billableAccountKind,
30
- billableAccountUid,
31
- billableAccountHandle,
32
- isUserAccount: billableAccountKind === 'user',
33
- isOrganizationAccount: billableAccountKind === 'organization',
29
+ billingEntityKind,
30
+ billingEntityUid,
31
+ billingEntityHandle,
32
+ isUserAccount: billingEntityKind === 'user',
33
+ isOrganizationAccount: billingEntityKind === 'organization',
34
34
  };
35
35
  }
36
- export default useSelectedBillableAccount;
36
+ export default useSelectedBillingEntity;
@@ -2,7 +2,7 @@
2
2
  * Read-only selector for the currently selected principal (UI scope).
3
3
  *
4
4
  * Use this for visibility, creation, and sharing of artifacts.
5
- * For billing, quotas, plans, and agents, use {@link useSelectedBillableAccount}.
5
+ * For billing, quotas, plans, and agents, use {@link useSelectedBillingEntity}.
6
6
  */
7
7
  export declare function useSelectedPrincipal(): {
8
8
  selectedPrincipalKind: import("./usePrincipalStore").PrincipalKind;
@@ -7,7 +7,7 @@ import { usePrincipalStore } from './usePrincipalStore.js';
7
7
  * Read-only selector for the currently selected principal (UI scope).
8
8
  *
9
9
  * Use this for visibility, creation, and sharing of artifacts.
10
- * For billing, quotas, plans, and agents, use {@link useSelectedBillableAccount}.
10
+ * For billing, quotas, plans, and agents, use {@link useSelectedBillingEntity}.
11
11
  */
12
12
  export function useSelectedPrincipal() {
13
13
  const selectedPrincipalKind = usePrincipalStore(state => state.selectedPrincipalKind);
@@ -1,4 +1,4 @@
1
- export declare const AI_AGENTS_URL_KEY = "aiagents_url_s";
1
+ export declare const AI_AGENTS_URL_KEY = "aiAgents_url_s";
2
2
  export declare const CAN_INVITE_URL_KEY = "can_invite_b";
3
3
  export type IUserSettings = {
4
4
  aiAgentsUrl?: string;
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2023-2025 Datalayer, Inc.
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
- export const AI_AGENTS_URL_KEY = 'aiagents_url_s';
5
+ export const AI_AGENTS_URL_KEY = 'aiAgents_url_s';
6
6
  export const CAN_INVITE_URL_KEY = 'can_invite_b';
7
7
  export class UserSettings {
8
8
  _aiAgentsUrl;
@@ -3,7 +3,7 @@ import type { OtelSystemData, OtelSystemProcess, OtelSystemDisk, OtelSystemTable
3
3
  export interface OtelClientOptions {
4
4
  /**
5
5
  * Base URL of the OTEL service.
6
- * Defaults to `configuration.otelRunUrl` from the Datalayer core config
6
+ * Defaults to `configuration.otelUrl` from the Datalayer core config
7
7
  * (i.e. `https://prod1.datalayer.run`).
8
8
  */
9
9
  baseUrl?: string;
@@ -83,7 +83,7 @@ export declare class OtelClient {
83
83
  /**
84
84
  * Create a new `OtelClient`.
85
85
  *
86
- * The `baseUrl` defaults to `configuration.otelRunUrl` from the Datalayer core
86
+ * The `baseUrl` defaults to `configuration.otelUrl` from the Datalayer core
87
87
  * configuration store, so only pass it when you want to override the default.
88
88
  *
89
89
  * @example
@@ -126,7 +126,7 @@ export class OtelClient {
126
126
  userUid;
127
127
  constructor(options) {
128
128
  this.baseUrl =
129
- options.baseUrl ?? coreStore.getState().configuration.otelRunUrl;
129
+ options.baseUrl ?? coreStore.getState().configuration.otelUrl;
130
130
  const auth = resolveOtelAuth(options.token, options.userUid);
131
131
  this.token = auth.token;
132
132
  this.userUid = auth.userUid;
@@ -235,7 +235,7 @@ export class OtelClient {
235
235
  /**
236
236
  * Create a new `OtelClient`.
237
237
  *
238
- * The `baseUrl` defaults to `configuration.otelRunUrl` from the Datalayer core
238
+ * The `baseUrl` defaults to `configuration.otelUrl` from the Datalayer core
239
239
  * configuration store, so only pass it when you want to override the default.
240
240
  *
241
241
  * @example
@@ -189,7 +189,7 @@ function normalizeMetric(raw) {
189
189
  // ── useOtelTraces ───────────────────────────────────────────────────
190
190
  /** Fetch a list of traces / spans from the OTEL service. */
191
191
  export function useOtelTraces(options) {
192
- const { token, baseUrl = coreStore.getState().configuration.otelRunUrl, serviceName, limit = 50, autoRefreshMs, } = options;
192
+ const { token, baseUrl = coreStore.getState().configuration.otelUrl, serviceName, limit = 50, autoRefreshMs, } = options;
193
193
  const [traces, setTraces] = useState([]);
194
194
  const [loading, setLoading] = useState(true);
195
195
  const [error, setError] = useState(null);
@@ -246,7 +246,7 @@ export function useOtelTrace(options) {
246
246
  // ── useOtelLogs ─────────────────────────────────────────────────────
247
247
  /** Fetch log records from the OTEL service. */
248
248
  export function useOtelLogs(options) {
249
- const { token, baseUrl = coreStore.getState().configuration.otelRunUrl, serviceName, severity, traceId, limit = 100, autoRefreshMs, } = options;
249
+ const { token, baseUrl = coreStore.getState().configuration.otelUrl, serviceName, severity, traceId, limit = 100, autoRefreshMs, } = options;
250
250
  const [logs, setLogs] = useState([]);
251
251
  const [loading, setLoading] = useState(true);
252
252
  const [error, setError] = useState(null);
@@ -283,7 +283,7 @@ export function useOtelLogs(options) {
283
283
  // ── useOtelMetrics ──────────────────────────────────────────────────
284
284
  /** Fetch metrics from the OTEL service. */
285
285
  export function useOtelMetrics(options) {
286
- const { token, baseUrl = coreStore.getState().configuration.otelRunUrl, serviceName, metricName, limit = 50, autoRefreshMs, } = options;
286
+ const { token, baseUrl = coreStore.getState().configuration.otelUrl, serviceName, metricName, limit = 50, autoRefreshMs, } = options;
287
287
  const [metrics, setMetrics] = useState([]);
288
288
  const [loading, setLoading] = useState(true);
289
289
  const [error, setError] = useState(null);
@@ -318,7 +318,7 @@ export function useOtelMetrics(options) {
318
318
  // ── useOtelServices ─────────────────────────────────────────────────
319
319
  /** Fetch list of observed service names. */
320
320
  export function useOtelServices(options) {
321
- const { token, baseUrl = coreStore.getState().configuration.otelRunUrl } = options;
321
+ const { token, baseUrl = coreStore.getState().configuration.otelUrl } = options;
322
322
  const [services, setServices] = useState([]);
323
323
  const [loading, setLoading] = useState(true);
324
324
  useEffect(() => {
@@ -437,7 +437,7 @@ export function useOtelQuery(options) {
437
437
  * @returns `{ connected, error, close }` – reactive connection state.
438
438
  */
439
439
  export function useOtelWebSocket(options) {
440
- const { baseUrl = coreStore.getState().configuration.otelRunUrl, token, userUid, autoReconnect = true, reconnectDelayMs = 3000, callbacks, } = options;
440
+ const { baseUrl = coreStore.getState().configuration.otelUrl, token, userUid, autoReconnect = true, reconnectDelayMs = 3000, callbacks, } = options;
441
441
  const [connected, setConnected] = useState(false);
442
442
  const [error, setError] = useState(null);
443
443
  const wsRef = useRef(null);
@@ -65,7 +65,7 @@ export type SignalType = 'traces' | 'logs' | 'metrics';
65
65
  /** Props for the main OtelLive orchestrator component. */
66
66
  export interface OtelLiveProps {
67
67
  /**
68
- * OTEL API base URL. When omitted, falls back to `otelRunUrl` from the
68
+ * OTEL API base URL. When omitted, falls back to `otelUrl` from the
69
69
  * Datalayer core configuration (defaults to "https://prod1.datalayer.run").
70
70
  */
71
71
  baseUrl?: string;
@@ -51,7 +51,7 @@ function buildHistogram(timestamps, start, end, buckets) {
51
51
  }));
52
52
  }
53
53
  // ── OtelLive ────────────────────────────────────────────────────────
54
- export const OtelLive = ({ baseUrl = coreStore.getState().configuration.otelRunUrl, wsBaseUrl, token, autoRefreshMs = 5000, defaultSignal = 'traces', limit = 200, onSignalRef, }) => {
54
+ export const OtelLive = ({ baseUrl = coreStore.getState().configuration.otelUrl, wsBaseUrl, token, autoRefreshMs = 5000, defaultSignal = 'traces', limit = 200, onSignalRef, }) => {
55
55
  // ── state ──
56
56
  const [signal, setSignalState] = useState(() => {
57
57
  try {
@@ -7,7 +7,7 @@ import { useStore } from 'zustand';
7
7
  import { configLogger } from '../../utils/Logger.js';
8
8
  let loadConfigurationFromServer = true;
9
9
  let initialConfiguration = {
10
- runUrl: 'https://prod1.datalayer.run',
10
+ datalayerUrl: 'https://prod1.datalayer.run',
11
11
  token: '',
12
12
  credits: 0,
13
13
  cpuEnvironment: 'ai-agents-env"',
@@ -16,18 +16,18 @@ let initialConfiguration = {
16
16
  whiteLabel: true,
17
17
  loadConfigurationFromServer: true,
18
18
  jupyterServerless: false,
19
- iamRunUrl: 'https://prod1.datalayer.run',
20
- runtimesRunUrl: 'https://r1.datalayer.run',
21
- libraryRunUrl: 'https://prod1.datalayer.run',
22
- spacerRunUrl: 'https://prod1.datalayer.run',
23
- aiagentsRunUrl: 'https://prod1.datalayer.run',
24
- aiinferenceRunUrl: 'https://prod1.datalayer.run',
25
- mcpserversRunUrl: 'https://prod1.datalayer.run',
26
- otelRunUrl: 'https://prod1.datalayer.run',
27
- growthRunUrl: 'https://prod1.datalayer.run',
28
- inboundsRunUrl: 'https://prod1.datalayer.run',
29
- successRunUrl: 'https://prod1.datalayer.run',
30
- supportRunUrl: 'https://prod1.datalayer.run',
19
+ iamUrl: 'https://prod1.datalayer.run',
20
+ runtimesUrl: 'https://r1.datalayer.run',
21
+ libraryUrl: 'https://prod1.datalayer.run',
22
+ spacerUrl: 'https://prod1.datalayer.run',
23
+ aiAgentsUrl: 'https://prod1.datalayer.run',
24
+ aiInferenceUrl: 'https://prod1.datalayer.run',
25
+ mcpServersUrl: 'https://prod1.datalayer.run',
26
+ otelUrl: 'https://prod1.datalayer.run',
27
+ growthUrl: 'https://prod1.datalayer.run',
28
+ inboundsUrl: 'https://prod1.datalayer.run',
29
+ successUrl: 'https://prod1.datalayer.run',
30
+ supportUrl: 'https://prod1.datalayer.run',
31
31
  launcher: {
32
32
  category: 'Datalayer',
33
33
  name: 'Datalayer Runtimes',
@@ -23,7 +23,7 @@ export type IIAMState = {
23
23
  /**
24
24
  * IAM server base URL.
25
25
  */
26
- iamRunUrl: string;
26
+ iamUrl: string;
27
27
  /**
28
28
  * Mapping of IAM providers and the corresponding Authorization URL.
29
29
  */
@@ -21,7 +21,7 @@ export const iamStore = createStore((set, get) => {
21
21
  externalToken: loadRefreshTokenFromCookie() ?? undefined,
22
22
  user: getStoredUser(),
23
23
  token: getStoredToken(),
24
- iamRunUrl: coreStore.getState().configuration?.iamRunUrl,
24
+ iamUrl: coreStore.getState().configuration?.iamUrl,
25
25
  iamProvidersAuthorizationURL: {},
26
26
  version: '',
27
27
  isLoginInProgress: false,
@@ -34,12 +34,12 @@ export const iamStore = createStore((set, get) => {
34
34
  }));
35
35
  },
36
36
  login: async (token) => {
37
- const { refreshUserByToken, iamRunUrl, logout } = get();
37
+ const { refreshUserByToken, iamUrl, logout } = get();
38
38
  // Set flag to prevent interference from automatic token refresh
39
39
  set({ isLoginInProgress: true });
40
40
  try {
41
41
  const resp = await requestDatalayerAPI({
42
- url: `${iamRunUrl}/api/iam/v1/login`,
42
+ url: `${iamUrl}/api/iam/v1/login`,
43
43
  method: 'POST',
44
44
  body: { token },
45
45
  });
@@ -114,11 +114,11 @@ export const iamStore = createStore((set, get) => {
114
114
  return updatedState;
115
115
  }),
116
116
  refreshCredits: async () => {
117
- const { externalToken, token, iamRunUrl, logout } = get();
117
+ const { externalToken, token, iamUrl, logout } = get();
118
118
  if (token) {
119
119
  try {
120
120
  const creditsRaw = await requestDatalayerAPI({
121
- url: `${iamRunUrl}/api/iam/v1/usage/credits`,
121
+ url: `${iamUrl}/api/iam/v1/usage/credits`,
122
122
  token,
123
123
  headers: externalToken
124
124
  ? {
@@ -169,10 +169,10 @@ export const iamStore = createStore((set, get) => {
169
169
  }
170
170
  },
171
171
  refreshUserByToken: async (token) => {
172
- const { iamRunUrl, logout, isLoginInProgress } = get();
172
+ const { iamUrl, logout, isLoginInProgress } = get();
173
173
  try {
174
174
  const data = await requestDatalayerAPI({
175
- url: `${iamRunUrl}/api/iam/v1/whoami`,
175
+ url: `${iamUrl}/api/iam/v1/whoami`,
176
176
  token,
177
177
  });
178
178
  const user = asUser(data.profile);
@@ -235,12 +235,12 @@ iamStore
235
235
  console.error('Failed to refresh to validate the stored token.', reason);
236
236
  })
237
237
  .finally(() => {
238
- const { externalToken, iamRunUrl, checkIAMToken, token } = iamStore.getState();
238
+ const { externalToken, iamUrl, checkIAMToken, token } = iamStore.getState();
239
239
  // If the stored token is invalid and an external token exists, try authenticating with it.
240
240
  if (!token && externalToken) {
241
241
  console.debug('Can not login with token - Trying with the external token.');
242
242
  requestDatalayerAPI({
243
- url: `${iamRunUrl}/api/iam/v1/login`,
243
+ url: `${iamUrl}/api/iam/v1/login`,
244
244
  method: 'POST',
245
245
  body: { token: externalToken },
246
246
  })
@@ -282,11 +282,11 @@ iamStore
282
282
  });
283
283
  // Connect the core store with the iam store.
284
284
  coreStore.subscribe((state, prevState) => {
285
- if (state.configuration?.iamRunUrl &&
286
- state.configuration.iamRunUrl !== prevState.configuration?.iamRunUrl) {
287
- const iamRunUrl = state.configuration.iamRunUrl;
288
- console.log('Updating iamRunUrl with new value', iamRunUrl);
289
- iamStore.setState({ iamRunUrl });
285
+ if (state.configuration?.iamUrl &&
286
+ state.configuration.iamUrl !== prevState.configuration?.iamUrl) {
287
+ const iamUrl = state.configuration.iamUrl;
288
+ console.log('Updating iamUrl with new value', iamUrl);
289
+ iamStore.setState({ iamUrl });
290
290
  // Check the token is valid with the new server.
291
291
  if (iamStore.getState().externalToken) {
292
292
  iamStore
@@ -1,6 +1,6 @@
1
1
  import { ISurvey } from '../../models';
2
2
  export type ISuccessState = {
3
- growthRunUrl: string;
3
+ growthUrl: string;
4
4
  surveys?: Map<string, ISurvey>;
5
5
  };
6
6
  export type SuccessState = ISuccessState & {
@@ -10,7 +10,7 @@ import { coreStore } from './CoreState.js';
10
10
  import { iamStore } from './IAMState.js';
11
11
  export const surveysStore = createStore((set, get) => ({
12
12
  surveys: undefined,
13
- growthRunUrl: coreStore.getState().configuration?.growthRunUrl,
13
+ growthUrl: coreStore.getState().configuration?.growthUrl,
14
14
  setSurveys: (s) => {
15
15
  const surveys = new Map();
16
16
  s.forEach(survey => surveys.set(survey.name, survey));
@@ -18,10 +18,10 @@ export const surveysStore = createStore((set, get) => ({
18
18
  },
19
19
  refreshSurveys: async () => {
20
20
  const { token } = iamStore.getState();
21
- const { growthRunUrl } = get();
21
+ const { growthUrl } = get();
22
22
  try {
23
23
  const resp = await requestDatalayerAPI({
24
- url: `${growthRunUrl}/api/growth/v1/surveys`,
24
+ url: `${growthUrl}/api/growth/v1/surveys`,
25
25
  method: 'GET',
26
26
  token,
27
27
  });
@@ -45,11 +45,11 @@ export const surveysStore = createStore((set, get) => ({
45
45
  }
46
46
  },
47
47
  createSurvey: async (name, form) => {
48
- const { growthRunUrl } = get();
48
+ const { growthUrl } = get();
49
49
  const { token } = iamStore.getState();
50
50
  try {
51
51
  const resp = await requestDatalayerAPI({
52
- url: `${growthRunUrl}/api/growth/v1/surveys`,
52
+ url: `${growthUrl}/api/growth/v1/surveys`,
53
53
  method: 'POST',
54
54
  body: {
55
55
  name,
@@ -85,11 +85,11 @@ export const surveysStore = createStore((set, get) => ({
85
85
  },
86
86
  }));
87
87
  coreStore.subscribe((state, prevState) => {
88
- if (state.configuration.successRunUrl &&
89
- state.configuration.successRunUrl !== prevState.configuration.successRunUrl) {
90
- const growthRunUrl = state.configuration.growthRunUrl;
91
- console.log(`Updating growthRunUrl with new value ${growthRunUrl}`);
92
- surveysStore.setState({ growthRunUrl });
88
+ if (state.configuration.successUrl &&
89
+ state.configuration.successUrl !== prevState.configuration.successUrl) {
90
+ const growthUrl = state.configuration.growthUrl;
91
+ console.log(`Updating growthUrl with new value ${growthUrl}`);
92
+ surveysStore.setState({ growthUrl });
93
93
  }
94
94
  });
95
95
  export function useSurveysStore(selector) {
@@ -36,7 +36,7 @@ const OAUTH2_PROVIDERS = {
36
36
  oauth2CallbackUIRoute: '/iam/oauth2/linkedin/callback',
37
37
  },
38
38
  };
39
- const getIAMRunUrlFromDocumentConfig = () => {
39
+ const getIAMUrlFromDocumentConfig = () => {
40
40
  if (typeof document === 'undefined') {
41
41
  return '';
42
42
  }
@@ -46,7 +46,7 @@ const getIAMRunUrlFromDocumentConfig = () => {
46
46
  }
47
47
  try {
48
48
  const config = JSON.parse(configScript.textContent);
49
- return String(config?.iamRunUrl || '').replace(/\/$/, '');
49
+ return String(config?.iamUrl || '').replace(/\/$/, '');
50
50
  }
51
51
  catch {
52
52
  return '';
@@ -59,8 +59,8 @@ export const SignInSimple = ({ onSignIn, onApiKeySignIn, loginUrl: loginUrlProp,
59
59
  const loginUrl = useMemo(() => {
60
60
  if (loginUrlProp)
61
61
  return loginUrlProp;
62
- const iamRunUrl = getIAMRunUrlFromDocumentConfig();
63
- return iamRunUrl ? `${iamRunUrl}/api/iam/v1/login` : '/api/iam/v1/login';
62
+ const iamUrl = getIAMUrlFromDocumentConfig();
63
+ return iamUrl ? `${iamUrl}/api/iam/v1/login` : '/api/iam/v1/login';
64
64
  }, [loginUrlProp]);
65
65
  const [handle, setHandle] = useState('');
66
66
  const [password, setPassword] = useState('');
@@ -89,7 +89,7 @@ export const SignInSimple = ({ onSignIn, onApiKeySignIn, loginUrl: loginUrlProp,
89
89
  setError(null);
90
90
  setSocialLoading(true);
91
91
  try {
92
- const iamRunUrl = getIAMRunUrlFromDocumentConfig();
92
+ const iamUrl = getIAMUrlFromDocumentConfig();
93
93
  const params = new URLSearchParams({
94
94
  provider: providerSpec.name,
95
95
  callback_uri: buildCallbackURI(providerSpec),
@@ -109,7 +109,7 @@ export const SignInSimple = ({ onSignIn, onApiKeySignIn, loginUrl: loginUrlProp,
109
109
  if (callbackNavigationTarget) {
110
110
  params.set('post_auth_redirect', callbackNavigationTarget);
111
111
  }
112
- const endpointBase = iamRunUrl || '';
112
+ const endpointBase = iamUrl || '';
113
113
  const endpoint = `${endpointBase}/api/iam/v1/oauth2/authz/url?${params.toString()}`;
114
114
  const response = await fetch(endpoint);
115
115
  const payload = await response.json();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/core",
3
- "version": "1.1.41",
3
+ "version": "1.1.45",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",
@@ -131,9 +131,9 @@
131
131
  "@primer/behaviors": "^1.8.4",
132
132
  "@primer/brand-primitives": "^0.51.0",
133
133
  "@primer/css": "^21.5.1",
134
- "@primer/octicons-react": "^19.15.1",
135
- "@primer/primitives": "^10.5.0",
136
- "@primer/react": "^37.19.0",
134
+ "@primer/octicons-react": "^19.29.1",
135
+ "@primer/primitives": "^10.7.0",
136
+ "@primer/react": "^37.31.0",
137
137
  "@primer/react-brand": "^0.58.0",
138
138
  "@stripe/react-stripe-js": "^6.3.0",
139
139
  "@stripe/stripe-js": "^9.4.0",
@@ -1,35 +0,0 @@
1
- export type BillableAccountType = 'user' | 'organization' | 'team';
2
- export type BillableAccount = {
3
- accountUid: string;
4
- accountType: BillableAccountType;
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 BillableAccountSelectProps = {
15
- value: string;
16
- onChange: (accountUid: string) => void;
17
- onSelectedAccountChange?: (account: BillableAccount | undefined) => void;
18
- onAccountsResolved?: (state: {
19
- accounts: BillableAccount[];
20
- eligibleAccounts: BillableAccount[];
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 resolveBillablePlanTier(value: unknown): 'free' | 'pro';
33
- export declare function formatBillableAccountPlanLabel(planName: string): string;
34
- export declare function BillableAccountSelect({ value, onChange, onSelectedAccountChange, onAccountsResolved, disabled, label, caption, emptyMessage, flashMessage, width, preferOrganizationDefault, }: BillableAccountSelectProps): JSX.Element;
35
- export default BillableAccountSelect;
@@ -1 +0,0 @@
1
- export { LiveRelativeTime } from '../time/LiveRelativeTime';
@@ -1,10 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- /*
6
- * Copyright (c) 2023-2026 Datalayer, Inc.
7
- * Distributed under the terms of the Modified BSD License.
8
- */
9
- // Backward compatibility export. Use ../../components/time/LiveRelativeTime.
10
- export { LiveRelativeTime } from '../time/LiveRelativeTime.js';
@@ -1,31 +0,0 @@
1
- /**
2
- * The kind of billable account currently in scope.
3
- *
4
- * An account is the *billable* principal — only users and organizations
5
- * are accounts. Teams are NOT accounts; when a team is the selected
6
- * principal, the billable account is the team's parent organization.
7
- */
8
- export type BillableAccountKind = 'user' | 'organization';
9
- export type BillableAccountState = {
10
- billableAccountKind: BillableAccountKind;
11
- billableAccountUid?: string;
12
- billableAccountHandle?: string;
13
- setBillableAccount: (args: {
14
- kind: BillableAccountKind;
15
- uid: string;
16
- handle: string;
17
- }) => void;
18
- resetBillableAccount: () => void;
19
- };
20
- export declare const useBillableAccountStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<BillableAccountState>, "persist"> & {
21
- persist: {
22
- setOptions: (options: Partial<import("zustand/middleware").PersistOptions<BillableAccountState, unknown>>) => void;
23
- clearStorage: () => void;
24
- rehydrate: () => Promise<void> | void;
25
- hasHydrated: () => boolean;
26
- onHydrate: (fn: (state: BillableAccountState) => void) => () => void;
27
- onFinishHydration: (fn: (state: BillableAccountState) => void) => () => void;
28
- getOptions: () => Partial<import("zustand/middleware").PersistOptions<BillableAccountState, unknown>>;
29
- };
30
- }>;
31
- export default useBillableAccountStore;
@@ -1,53 +0,0 @@
1
- /*
2
- * Copyright (c) 2023-2025 Datalayer, Inc.
3
- * Distributed under the terms of the Modified BSD License.
4
- */
5
- import { create } from 'zustand';
6
- import { createJSONStorage, persist } from 'zustand/middleware';
7
- import { useUsageRefreshStore } from './useUsageRefreshStore.js';
8
- export const useBillableAccountStore = create()(persist(set => ({
9
- billableAccountKind: 'user',
10
- billableAccountUid: undefined,
11
- billableAccountHandle: undefined,
12
- setBillableAccount: ({ kind, uid, handle }) => set(state => {
13
- const unchanged = state.billableAccountKind === kind &&
14
- state.billableAccountUid === uid &&
15
- state.billableAccountHandle === handle;
16
- if (unchanged) {
17
- return state;
18
- }
19
- useUsageRefreshStore
20
- .getState()
21
- .requestUsageRefresh('billable-account-changed');
22
- return {
23
- billableAccountKind: kind,
24
- billableAccountUid: uid,
25
- billableAccountHandle: handle,
26
- };
27
- }),
28
- resetBillableAccount: () => set(state => {
29
- const unchanged = state.billableAccountKind === 'user' &&
30
- state.billableAccountUid === undefined &&
31
- state.billableAccountHandle === undefined;
32
- if (unchanged) {
33
- return state;
34
- }
35
- useUsageRefreshStore
36
- .getState()
37
- .requestUsageRefresh('billable-account-reset');
38
- return {
39
- billableAccountKind: 'user',
40
- billableAccountUid: undefined,
41
- billableAccountHandle: undefined,
42
- };
43
- }),
44
- }), {
45
- name: 'datalayer-billable-account',
46
- storage: createJSONStorage(() => localStorage),
47
- partialize: state => ({
48
- billableAccountKind: state.billableAccountKind,
49
- billableAccountUid: state.billableAccountUid,
50
- billableAccountHandle: state.billableAccountHandle,
51
- }),
52
- }));
53
- export default useBillableAccountStore;
@@ -1,14 +0,0 @@
1
- /**
2
- * Read-only selector for the currently scoped billable account.
3
- *
4
- * Use this for billing, quotas, plans, credits, agents, and runtime capacity.
5
- * For visibility/creation/sharing scope, use {@link useSelectedPrincipal}.
6
- */
7
- export declare function useSelectedBillableAccount(): {
8
- billableAccountKind: string;
9
- billableAccountUid: string | undefined;
10
- billableAccountHandle: string | undefined;
11
- isUserAccount: boolean;
12
- isOrganizationAccount: boolean;
13
- };
14
- export default useSelectedBillableAccount;