@datalayer/core 1.1.43 → 1.1.46
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/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 +130 -111
- package/lib/config/Configuration.d.ts +18 -0
- 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 +32 -16
- 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/otel/client/OtelClient.js +2 -3
- package/lib/otel/hooks/index.js +6 -6
- package/lib/otel/views/OtelLive.js +2 -2
- package/lib/state/substates/CoreState.d.ts +11 -0
- package/lib/state/substates/CoreState.js +18 -0
- 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
|
@@ -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;
|