@datalayer/core 1.0.20 → 1.0.21

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 (96) hide show
  1. package/README.md +27 -0
  2. package/lib/api/DatalayerApi.d.ts +5 -1
  3. package/lib/api/DatalayerApi.js +55 -8
  4. package/lib/api/iam/oauth2.d.ts +3 -3
  5. package/lib/api/iam/oauth2.js +2 -2
  6. package/lib/api/iam/profile.d.ts +9 -1
  7. package/lib/api/iam/profile.js +15 -0
  8. package/lib/api/runtimes/checkpoints.js +1 -1
  9. package/lib/api/runtimes/snapshots.d.ts +7 -7
  10. package/lib/api/runtimes/snapshots.js +9 -9
  11. package/lib/client/auth/storage.js +103 -12
  12. package/lib/client/index.d.ts +7 -7
  13. package/lib/client/index.js +1 -1
  14. package/lib/client/mixins/RuntimesMixin.d.ts +6 -6
  15. package/lib/client/mixins/RuntimesMixin.js +5 -5
  16. package/lib/client/mixins/SpacerMixin.js +22 -1
  17. package/lib/collaboration/DatalayerCollaborationProvider.d.ts +4 -3
  18. package/lib/components/avatars/DLAvatar.d.ts +24 -0
  19. package/lib/components/avatars/DLAvatar.js +26 -0
  20. package/lib/components/avatars/UserProfileAvatar.js +4 -4
  21. package/lib/components/avatars/index.d.ts +1 -0
  22. package/lib/components/avatars/index.js +1 -0
  23. package/lib/components/checkout/StripeCheckout.d.ts +24 -3
  24. package/lib/components/checkout/StripeCheckout.js +1116 -55
  25. package/lib/components/display/DatalayerBox.js +6 -1
  26. package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +2 -2
  27. package/lib/components/snapshots/{RuntimeSnapshotMenu.d.ts → SandboxSnapshotMenu.d.ts} +4 -4
  28. package/lib/components/snapshots/{RuntimeSnapshotMenu.js → SandboxSnapshotMenu.js} +33 -33
  29. package/lib/components/snapshots/index.d.ts +1 -1
  30. package/lib/components/snapshots/index.js +1 -1
  31. package/lib/components/storage/ContentsBrowser.js +2 -2
  32. package/lib/components/tokens/SpaceVariantToken.d.ts +1 -1
  33. package/lib/components/tokens/SpaceVariantToken.js +7 -4
  34. package/lib/components/users/PeerIndicator.js +5 -4
  35. package/lib/hooks/useCache.d.ts +125 -18
  36. package/lib/hooks/useCache.js +893 -120
  37. package/lib/hooks/useDatalayer.js +31 -3
  38. package/lib/hooks/useIAM.js +1 -8
  39. package/lib/hooks/useProjects.d.ts +44 -0
  40. package/lib/hooks/useProjects.js +26 -2
  41. package/lib/index.d.ts +2 -2
  42. package/lib/index.js +1 -1
  43. package/lib/mocks/components/FlashMock.js +8 -2
  44. package/lib/models/{RuntimeSnapshot.d.ts → CodeSandboxSnapshot.d.ts} +5 -5
  45. package/lib/models/{RuntimeSnapshot.js → CodeSandboxSnapshot.js} +1 -1
  46. package/lib/models/{RuntimeSnapshotDTO.d.ts → CodeSandboxSnapshotDTO.d.ts} +30 -30
  47. package/lib/models/{RuntimeSnapshotDTO.js → CodeSandboxSnapshotDTO.js} +6 -6
  48. package/lib/models/Environment.d.ts +4 -0
  49. package/lib/models/IAM.d.ts +66 -0
  50. package/lib/models/Organization.d.ts +1 -0
  51. package/lib/models/Organization.js +1 -0
  52. package/lib/models/Page.d.ts +2 -2
  53. package/lib/models/Page.js +2 -2
  54. package/lib/models/Profile.d.ts +1 -1
  55. package/lib/models/RuntimeDTO.d.ts +2 -2
  56. package/lib/models/Space.d.ts +1 -0
  57. package/lib/models/Space.js +29 -5
  58. package/lib/models/SpaceDTO.d.ts +4 -0
  59. package/lib/models/SpaceDTO.js +5 -0
  60. package/lib/models/Usage.d.ts +15 -0
  61. package/lib/models/Usage.js +9 -0
  62. package/lib/models/User.d.ts +21 -0
  63. package/lib/models/User.js +6 -2
  64. package/lib/models/index.d.ts +2 -2
  65. package/lib/models/index.js +2 -2
  66. package/lib/otel/auth.js +0 -4
  67. package/lib/services/index.d.ts +1 -1
  68. package/lib/services/index.js +1 -1
  69. package/lib/state/substates/IAMState.js +0 -7
  70. package/lib/state/substates/RuntimesState.d.ts +9 -9
  71. package/lib/state/substates/RuntimesState.js +3 -3
  72. package/lib/stateful/runtimes/actions.d.ts +17 -17
  73. package/lib/stateful/runtimes/actions.js +35 -55
  74. package/lib/stateful/runtimes/apis.d.ts +3 -3
  75. package/lib/stateful/runtimes/snapshots.d.ts +2 -2
  76. package/lib/stateful/runtimes/snapshots.js +7 -7
  77. package/lib/utils/Format.d.ts +6 -0
  78. package/lib/utils/Format.js +17 -0
  79. package/lib/utils/Snapshot.d.ts +1 -1
  80. package/lib/utils/Snapshot.js +1 -1
  81. package/lib/views/datasources/DatasourceDetail.d.ts +7 -1
  82. package/lib/views/datasources/DatasourceDetail.js +61 -23
  83. package/lib/views/datasources/DatasourceNew.d.ts +8 -1
  84. package/lib/views/datasources/DatasourceNew.js +23 -10
  85. package/lib/views/datasources/Datasources.d.ts +5 -1
  86. package/lib/views/datasources/Datasources.js +38 -30
  87. package/lib/views/iam-tokens/IAMTokenNew.d.ts +3 -1
  88. package/lib/views/iam-tokens/IAMTokenNew.js +2 -2
  89. package/lib/views/iam-tokens/IAMTokens.d.ts +3 -1
  90. package/lib/views/iam-tokens/IAMTokens.js +2 -2
  91. package/lib/views/otel/OtelHeader.d.ts +5 -0
  92. package/lib/views/otel/OtelHeader.js +3 -3
  93. package/lib/views/profile/UserBadge.d.ts +7 -2
  94. package/lib/views/profile/UserBadge.js +11 -2
  95. package/lib/views/secrets/Secrets.js +21 -21
  96. package/package.json +8 -7
@@ -473,8 +473,29 @@ export function SpacerMixin(Base) {
473
473
  // Use getMySpaces and filter by variant, because the
474
474
  // /spaces/types/project endpoint returns empty results.
475
475
  const allSpaces = await this.getMySpaces();
476
+ const isProjectSpace = (space) => {
477
+ const raw = space.rawData();
478
+ const variant = raw?.variant_s ?? space.variant;
479
+ if (variant !== 'project') {
480
+ return false;
481
+ }
482
+ const items = Array.isArray(raw?.items)
483
+ ? raw.items
484
+ : raw?.items && typeof raw.items === 'object'
485
+ ? [raw.items]
486
+ : [];
487
+ if (items.length === 0) {
488
+ return true;
489
+ }
490
+ const hasNotebook = items.some((item) => (item?.type_s ?? item?.type) === 'notebook');
491
+ const hasDocument = items.some((item) => {
492
+ const type = item?.type_s ?? item?.type;
493
+ return type === 'document' || type === 'lexical';
494
+ });
495
+ return hasNotebook && hasDocument;
496
+ };
476
497
  return allSpaces
477
- .filter(s => s.variant === 'project')
498
+ .filter(s => isProjectSpace(s))
478
499
  .map(s => new ProjectDTO(s.rawData()));
479
500
  }
480
501
  /**
@@ -1,4 +1,3 @@
1
- import { YNotebook } from '@jupyter/ydoc';
2
1
  import { WebsocketProvider } from 'y-websocket';
3
2
  import type { ICollaborationProvider, ICollaborationProviderEvents } from '@datalayer/jupyter-react';
4
3
  export declare enum CollaborationStatus {
@@ -7,6 +6,8 @@ export declare enum CollaborationStatus {
7
6
  Connected = "connected",
8
7
  Error = "error"
9
8
  }
9
+ type SharedModel = Parameters<ICollaborationProvider['connect']>[0];
10
+ type ConnectOptions = Parameters<ICollaborationProvider['connect']>[2];
10
11
  /**
11
12
  * Configuration for Datalayer collaboration provider
12
13
  */
@@ -48,10 +49,10 @@ export declare class DatalayerCollaborationProvider implements ICollaborationPro
48
49
  get isDisposed(): boolean;
49
50
  get events(): ICollaborationProviderEvents;
50
51
  private setStatus;
51
- connect(sharedModel: YNotebook, documentId: string, options?: Record<string, any>): Promise<void>;
52
+ connect(sharedModel: SharedModel, documentId: string, options?: ConnectOptions): Promise<void>;
52
53
  disconnect(): void;
53
54
  getProvider(): WebsocketProvider | null;
54
- getSharedModel(): YNotebook | null;
55
+ getSharedModel(): SharedModel | null;
55
56
  handleConnectionClose(event: CloseEvent): void;
56
57
  handleSync(isSynced: boolean): void;
57
58
  dispose(): void;
@@ -0,0 +1,24 @@
1
+ import { type AvatarProps } from '@primer/react';
2
+ /**
3
+ * Props for {@link DLAvatar}.
4
+ *
5
+ * Same as Primer's `AvatarProps` but `src` accepts the raw avatar URL
6
+ * (e.g. `user.avatar_url_s`) and is run through {@link getAvatarURL}
7
+ * so Gravatar fallbacks and the default avatar are handled consistently.
8
+ */
9
+ export type DLAvatarProps = Omit<AvatarProps, 'src'> & {
10
+ src?: string;
11
+ };
12
+ /**
13
+ * Datalayer Avatar wrapper.
14
+ *
15
+ * Centralizes two concerns for every avatar rendered in our apps:
16
+ *
17
+ * - URL normalization via {@link getAvatarURL} (handles Gravatar query
18
+ * parameters and the default avatar fallback).
19
+ * - `referrerPolicy="no-referrer"` so that third-party CDNs such as
20
+ * `lh3.googleusercontent.com` (Google), LinkedIn media, etc. do not
21
+ * deny the request based on the `Referer` header.
22
+ */
23
+ export declare const DLAvatar: ({ src, ...rest }: DLAvatarProps) => import("react/jsx-runtime").JSX.Element;
24
+ export default DLAvatar;
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2023-2025 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ /*
7
+ * Copyright (c) 2023-2026 Datalayer, Inc.
8
+ * Distributed under the terms of the Modified BSD License.
9
+ */
10
+ import { Avatar } from '@primer/react';
11
+ import { getAvatarURL } from '../../utils/index.js';
12
+ /**
13
+ * Datalayer Avatar wrapper.
14
+ *
15
+ * Centralizes two concerns for every avatar rendered in our apps:
16
+ *
17
+ * - URL normalization via {@link getAvatarURL} (handles Gravatar query
18
+ * parameters and the default avatar fallback).
19
+ * - `referrerPolicy="no-referrer"` so that third-party CDNs such as
20
+ * `lh3.googleusercontent.com` (Google), LinkedIn media, etc. do not
21
+ * deny the request based on the `Referer` header.
22
+ */
23
+ export const DLAvatar = ({ src, ...rest }) => {
24
+ return (_jsx(Avatar, { src: getAvatarURL(src), referrerPolicy: "no-referrer", ...rest }));
25
+ };
26
+ export default DLAvatar;
@@ -3,16 +3,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  * Copyright (c) 2023-2025 Datalayer, Inc.
4
4
  * Distributed under the terms of the Modified BSD License.
5
5
  */
6
- import { Avatar, Link } from '@primer/react';
6
+ import { Link } from '@primer/react';
7
7
  import { Box } from '@datalayer/primer-addons';
8
8
  import { AvatarSkeleton } from '../../components/display/index.js';
9
- import { getAvatarURL } from '../../utils/index.js';
9
+ import { DLAvatar } from './DLAvatar.js';
10
10
  const Profile = ({ user, size = 100, onClick }) => {
11
- return (_jsx(Box, { style: { width: size }, children: _jsx(Avatar
11
+ return (_jsx(Box, { style: { width: size }, children: _jsx(DLAvatar
12
12
  // square
13
13
  , {
14
14
  // square
15
- src: getAvatarURL(user?.avatarUrl), size: size, onClick: onClick }) }));
15
+ src: user?.avatarUrl, size: size, onClick: onClick }) }));
16
16
  };
17
17
  export const UserProfileAvatar = ({ onClick, user, size = 100, }) => {
18
18
  return user ? (onClick ? (_jsx(Link, { href: "javascript: return false;", onClick: onClick, children: _jsx(Profile, { user: user, size: size, onClick: onClick }) })) : (_jsx(Profile, { user: user, size: size, onClick: onClick }))) : (_jsx(AvatarSkeleton, { size: size }));
@@ -1,2 +1,3 @@
1
1
  export * from './BoringAvatar';
2
+ export * from './DLAvatar';
2
3
  export * from './UserProfileAvatar';
@@ -3,4 +3,5 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
  export * from './BoringAvatar.js';
6
+ export * from './DLAvatar.js';
6
7
  export * from './UserProfileAvatar.js';
@@ -1,3 +1,4 @@
1
+ import type { StripeElementsOptions } from '@stripe/stripe-js';
1
2
  import type { ICheckoutPortal } from '../../models';
2
3
  /**
3
4
  * Price item interface
@@ -23,10 +24,30 @@ export interface IPrice {
23
24
  * Computational credits to receive
24
25
  */
25
26
  credits: number;
27
+ /**
28
+ * Whether this price is the server-selected default option
29
+ */
30
+ default?: boolean;
26
31
  }
32
+ export interface ISubscriptionPlan {
33
+ id: string;
34
+ name: string;
35
+ amount: number;
36
+ currency: string;
37
+ interval?: string;
38
+ included_runs?: number;
39
+ }
40
+ export type StripeCheckoutProps = {
41
+ checkoutPortal: ICheckoutPortal | null;
42
+ appearance?: StripeElementsOptions['appearance'];
43
+ accountUid?: string;
44
+ showStatusUsageSummary?: boolean;
45
+ onCheckoutSuccess?: (event: {
46
+ checkoutType: 'topup' | 'subscription' | 'resume';
47
+ purchasedCredits?: number;
48
+ }) => void;
49
+ };
27
50
  /**
28
51
  * Stripe checkout.
29
52
  */
30
- export declare function StripeCheckout({ checkoutPortal, }: {
31
- checkoutPortal: ICheckoutPortal | null;
32
- }): import("react/jsx-runtime").JSX.Element;
53
+ export declare function StripeCheckout({ checkoutPortal, appearance, accountUid, showStatusUsageSummary, onCheckoutSuccess, }: StripeCheckoutProps): import("react/jsx-runtime").JSX.Element;