@datalayer/core 1.0.2 → 1.0.11

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 (145) hide show
  1. package/README.md +1 -1
  2. package/lib/api/constants.d.ts +6 -0
  3. package/lib/api/constants.js +6 -0
  4. package/lib/api/index.d.ts +1 -0
  5. package/lib/api/index.js +1 -0
  6. package/lib/api/otel/index.d.ts +12 -0
  7. package/lib/api/otel/index.js +16 -0
  8. package/lib/api/otel/logs.d.ts +19 -0
  9. package/lib/api/otel/logs.js +43 -0
  10. package/lib/api/otel/metrics.d.ts +31 -0
  11. package/lib/api/otel/metrics.js +65 -0
  12. package/lib/api/otel/query.d.ts +16 -0
  13. package/lib/api/otel/query.js +37 -0
  14. package/lib/api/otel/services.d.ts +39 -0
  15. package/lib/api/otel/services.js +81 -0
  16. package/lib/api/otel/traces.d.ts +24 -0
  17. package/lib/api/otel/traces.js +53 -0
  18. package/lib/api/otel/types.d.ts +112 -0
  19. package/lib/api/otel/types.js +5 -0
  20. package/lib/api/runtimes/checkpoints.d.ts +122 -0
  21. package/lib/api/runtimes/checkpoints.js +118 -0
  22. package/lib/api/runtimes/index.d.ts +1 -0
  23. package/lib/api/runtimes/index.js +1 -0
  24. package/lib/api/runtimes/runtimes.d.ts +84 -0
  25. package/lib/api/runtimes/runtimes.js +50 -0
  26. package/lib/components/auth/Login.js +1 -1
  27. package/lib/components/display/BusyDots.d.ts +9 -0
  28. package/lib/components/display/BusyDots.js +31 -0
  29. package/lib/components/display/LiveRelativeTime.d.ts +10 -0
  30. package/lib/components/display/LiveRelativeTime.js +21 -0
  31. package/lib/components/display/index.d.ts +2 -0
  32. package/lib/components/display/index.js +2 -0
  33. package/lib/components/flashes/FlashSurveys.js +1 -1
  34. package/lib/components/index.d.ts +1 -0
  35. package/lib/components/index.js +1 -0
  36. package/lib/components/navbar/SubdomainNavBar.js +1 -1
  37. package/lib/components/progress/ConsumptionBar.js +6 -7
  38. package/lib/components/progress/CreditsIndicator.js +2 -2
  39. package/lib/components/progress/consumption.d.ts +12 -0
  40. package/lib/components/progress/consumption.js +31 -0
  41. package/lib/components/progress/index.d.ts +1 -0
  42. package/lib/components/progress/index.js +1 -0
  43. package/lib/components/sparklines/Sparklines.d.ts +16 -0
  44. package/lib/components/sparklines/Sparklines.js +65 -0
  45. package/lib/components/sparklines/SparklinesLine.d.ts +8 -0
  46. package/lib/components/sparklines/SparklinesLine.js +37 -0
  47. package/lib/components/sparklines/dataProcessing.d.ts +25 -0
  48. package/lib/components/sparklines/dataProcessing.js +35 -0
  49. package/lib/components/sparklines/index.d.ts +4 -0
  50. package/lib/components/sparklines/index.js +7 -0
  51. package/lib/components/sparklines/types.d.ts +36 -0
  52. package/lib/components/sparklines/types.js +5 -0
  53. package/lib/components/storage/ContentsBrowser.js +17 -1
  54. package/lib/components/subnav/SubNav.js +1 -1
  55. package/lib/config/Configuration.d.ts +4 -0
  56. package/lib/hooks/useCache.d.ts +6 -63
  57. package/lib/hooks/useCache.js +35 -205
  58. package/lib/hooks/useProjects.d.ts +1 -1
  59. package/lib/index.d.ts +2 -0
  60. package/lib/index.js +4 -0
  61. package/lib/models/ItemDTO.js +1 -1
  62. package/lib/models/RolesPlatform.js +2 -2
  63. package/lib/models/User.d.ts +2 -0
  64. package/lib/models/User.js +4 -1
  65. package/lib/otel/client/OtelClient.d.ts +93 -0
  66. package/lib/otel/client/OtelClient.js +232 -0
  67. package/lib/otel/client/index.d.ts +2 -0
  68. package/lib/otel/client/index.js +5 -0
  69. package/lib/otel/hooks/index.d.ts +186 -0
  70. package/lib/otel/hooks/index.js +532 -0
  71. package/lib/otel/index.d.ts +34 -0
  72. package/lib/otel/index.js +23 -0
  73. package/lib/otel/types.d.ts +190 -0
  74. package/lib/otel/types.js +5 -0
  75. package/lib/otel/utils.d.ts +33 -0
  76. package/lib/otel/utils.js +181 -0
  77. package/lib/otel/views/OtelLive.d.ts +12 -0
  78. package/lib/otel/views/OtelLive.js +372 -0
  79. package/lib/otel/views/OtelLogsList.d.ts +11 -0
  80. package/lib/otel/views/OtelLogsList.js +137 -0
  81. package/lib/otel/views/OtelMetricsChart.d.ts +22 -0
  82. package/lib/otel/views/OtelMetricsChart.js +300 -0
  83. package/lib/otel/views/OtelMetricsList.d.ts +15 -0
  84. package/lib/otel/views/OtelMetricsList.js +213 -0
  85. package/lib/otel/views/OtelSearchBar.d.ts +11 -0
  86. package/lib/otel/views/OtelSearchBar.js +22 -0
  87. package/lib/otel/views/OtelSpanDetail.d.ts +11 -0
  88. package/lib/otel/views/OtelSpanDetail.js +172 -0
  89. package/lib/otel/views/OtelSpanTree.d.ts +11 -0
  90. package/lib/otel/views/OtelSpanTree.js +176 -0
  91. package/lib/otel/views/OtelSqlView.d.ts +16 -0
  92. package/lib/otel/views/OtelSqlView.js +239 -0
  93. package/lib/otel/views/OtelSystemView.d.ts +15 -0
  94. package/lib/otel/views/OtelSystemView.js +75 -0
  95. package/lib/otel/views/OtelTimeline.d.ts +11 -0
  96. package/lib/otel/views/OtelTimeline.js +101 -0
  97. package/lib/otel/views/OtelTimelineRangeSlider.d.ts +16 -0
  98. package/lib/otel/views/OtelTimelineRangeSlider.js +338 -0
  99. package/lib/otel/views/OtelTracesList.d.ts +13 -0
  100. package/lib/otel/views/OtelTracesList.js +199 -0
  101. package/lib/otel/views/index.d.ts +20 -0
  102. package/lib/otel/views/index.js +21 -0
  103. package/lib/state/storage/IAMStorage.d.ts +2 -1
  104. package/lib/state/substates/CoreState.js +7 -6
  105. package/lib/utils/Date.d.ts +6 -0
  106. package/lib/utils/Date.js +37 -0
  107. package/lib/utils/Jwt.d.ts +42 -0
  108. package/lib/utils/Jwt.js +44 -0
  109. package/lib/utils/index.d.ts +1 -0
  110. package/lib/utils/index.js +1 -0
  111. package/lib/views/iam/SignInSimple.d.ts +43 -0
  112. package/lib/views/iam/SignInSimple.js +113 -0
  113. package/lib/views/iam/index.d.ts +2 -0
  114. package/lib/views/iam/index.js +5 -0
  115. package/lib/views/iam-tokens/IAMTokenEdit.d.ts +5 -1
  116. package/lib/views/iam-tokens/IAMTokenEdit.js +54 -5
  117. package/lib/views/iam-tokens/IAMTokenNew.js +2 -2
  118. package/lib/views/iam-tokens/IAMTokens.d.ts +4 -2
  119. package/lib/views/iam-tokens/IAMTokens.js +68 -36
  120. package/lib/views/iam-tokens/Tokens.js +63 -31
  121. package/lib/views/index.d.ts +3 -1
  122. package/lib/views/index.js +3 -1
  123. package/lib/views/otel/DashboardView.d.ts +16 -0
  124. package/lib/views/otel/DashboardView.js +4 -0
  125. package/lib/views/otel/LogsView.d.ts +12 -0
  126. package/lib/views/otel/LogsView.js +4 -0
  127. package/lib/views/otel/MetricsView.d.ts +12 -0
  128. package/lib/views/otel/MetricsView.js +4 -0
  129. package/lib/views/otel/OtelHeader.d.ts +33 -0
  130. package/lib/views/otel/OtelHeader.js +105 -0
  131. package/lib/views/otel/SqlView.d.ts +9 -0
  132. package/lib/views/otel/SqlView.js +4 -0
  133. package/lib/views/otel/SystemView.d.ts +9 -0
  134. package/lib/views/otel/SystemView.js +4 -0
  135. package/lib/views/otel/TracesView.d.ts +12 -0
  136. package/lib/views/otel/TracesView.js +4 -0
  137. package/lib/views/otel/index.d.ts +16 -0
  138. package/lib/views/otel/index.js +12 -0
  139. package/lib/views/otel/simpleAuthStore.d.ts +21 -0
  140. package/lib/views/otel/simpleAuthStore.js +22 -0
  141. package/lib/views/profile/UserBadge.d.ts +20 -0
  142. package/lib/views/profile/UserBadge.js +101 -0
  143. package/lib/views/profile/index.d.ts +2 -0
  144. package/lib/views/profile/index.js +5 -0
  145. package/package.json +3 -4
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from '@primer/react';
3
+ import { OtelSqlView } from '../../otel';
4
+ export const SqlView = ({ baseUrl = '', token }) => (_jsx(Box, { sx: { display: 'flex', flex: 1, minHeight: 0, overflow: 'hidden' }, children: _jsx(OtelSqlView, { baseUrl: baseUrl, token: token }) }));
@@ -0,0 +1,9 @@
1
+ /**
2
+ * SystemView – OTEL system/infrastructure view.
3
+ */
4
+ import React from 'react';
5
+ export interface SystemViewProps {
6
+ baseUrl?: string;
7
+ token?: string;
8
+ }
9
+ export declare const SystemView: React.FC<SystemViewProps>;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from '@primer/react';
3
+ import { OtelSystemView } from '../../otel';
4
+ export const SystemView = ({ baseUrl = '', token, }) => (_jsx(Box, { sx: { display: 'flex', flex: 1, minHeight: 0, overflow: 'hidden' }, children: _jsx(OtelSystemView, { baseUrl: baseUrl, token: token }) }));
@@ -0,0 +1,12 @@
1
+ /**
2
+ * TracesView – Standalone traces-only view.
3
+ * Renders OtelLive defaulting to the traces signal.
4
+ */
5
+ import React from 'react';
6
+ export interface TracesViewProps {
7
+ baseUrl?: string;
8
+ token?: string;
9
+ autoRefreshMs?: number;
10
+ limit?: number;
11
+ }
12
+ export declare const TracesView: React.FC<TracesViewProps>;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box } from '@primer/react';
3
+ import { OtelLive } from '../../otel';
4
+ export const TracesView = ({ baseUrl = '', token, autoRefreshMs = 5000, limit = 200, }) => (_jsx(Box, { sx: { display: 'flex', flex: 1, minHeight: 0, overflow: 'hidden' }, children: _jsx(OtelLive, { baseUrl: baseUrl, token: token, autoRefreshMs: autoRefreshMs, defaultSignal: "traces", limit: limit }) }));
@@ -0,0 +1,16 @@
1
+ export { DashboardView } from './DashboardView';
2
+ export type { DashboardViewProps } from './DashboardView';
3
+ export { TracesView } from './TracesView';
4
+ export type { TracesViewProps } from './TracesView';
5
+ export { LogsView } from './LogsView';
6
+ export type { LogsViewProps } from './LogsView';
7
+ export { MetricsView } from './MetricsView';
8
+ export type { MetricsViewProps } from './MetricsView';
9
+ export { SqlView } from './SqlView';
10
+ export type { SqlViewProps } from './SqlView';
11
+ export { SystemView } from './SystemView';
12
+ export type { SystemViewProps } from './SystemView';
13
+ export { OtelHeader } from './OtelHeader';
14
+ export type { OtelHeaderProps } from './OtelHeader';
15
+ export { useSimpleAuthStore } from './simpleAuthStore';
16
+ export type { SimpleAuthState } from './simpleAuthStore';
@@ -0,0 +1,12 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ export { DashboardView } from './DashboardView';
6
+ export { TracesView } from './TracesView';
7
+ export { LogsView } from './LogsView';
8
+ export { MetricsView } from './MetricsView';
9
+ export { SqlView } from './SqlView';
10
+ export { SystemView } from './SystemView';
11
+ export { OtelHeader } from './OtelHeader';
12
+ export { useSimpleAuthStore } from './simpleAuthStore';
@@ -0,0 +1,21 @@
1
+ export interface SimpleAuthState {
2
+ /** JWT bearer token (from IAM login). */
3
+ token: string | null;
4
+ /** Authenticated user's handle. */
5
+ handle: string | null;
6
+ /** Set credentials after successful login. */
7
+ setAuth: (token: string, handle: string) => void;
8
+ /** Clear credentials (logout). */
9
+ clearAuth: () => void;
10
+ }
11
+ export declare const useSimpleAuthStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<SimpleAuthState>, "persist"> & {
12
+ persist: {
13
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<SimpleAuthState, SimpleAuthState>>) => void;
14
+ clearStorage: () => void;
15
+ rehydrate: () => Promise<void> | void;
16
+ hasHydrated: () => boolean;
17
+ onHydrate: (fn: (state: SimpleAuthState) => void) => () => void;
18
+ onFinishHydration: (fn: (state: SimpleAuthState) => void) => () => void;
19
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<SimpleAuthState, SimpleAuthState>>;
20
+ };
21
+ }>;
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * Minimal token-based authentication store.
7
+ *
8
+ * Persists a JWT bearer token and a user handle to localStorage so the
9
+ * session survives page refreshes. Intended for demo / example apps that
10
+ * need a lightweight auth layer without a full IAM integration.
11
+ *
12
+ * Import via the `@datalayer/core/views/otel` subpath:
13
+ * import { useSimpleAuthStore } from '@datalayer/core/views/otel';
14
+ */
15
+ import { create } from 'zustand';
16
+ import { persist } from 'zustand/middleware';
17
+ export const useSimpleAuthStore = create()(persist((set) => ({
18
+ token: null,
19
+ handle: null,
20
+ setAuth: (token, handle) => set({ token, handle }),
21
+ clearAuth: () => set({ token: null, handle: null }),
22
+ }), { name: 'datalayer-simple-auth' }));
@@ -0,0 +1,20 @@
1
+ /**
2
+ * UserBadge – Shows the authenticated user's display name.
3
+ *
4
+ * On hover, reveals a JWT details popover with email, handle, UID,
5
+ * issued/expiry timestamps, roles, and the raw decoded claims.
6
+ *
7
+ * The trigger text and the popover share a single container so the
8
+ * popover stays open while the mouse travels from the label into it.
9
+ *
10
+ * @module views/profile
11
+ */
12
+ import React from 'react';
13
+ export interface UserBadgeProps {
14
+ /** Raw JWT bearer token. */
15
+ token: string;
16
+ /** Display variant for the claims overlay. */
17
+ variant?: 'full' | 'small';
18
+ }
19
+ export declare const UserBadge: React.FC<UserBadgeProps>;
20
+ export default UserBadge;
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } 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
+ * UserBadge – Shows the authenticated user's display name.
8
+ *
9
+ * On hover, reveals a JWT details popover with email, handle, UID,
10
+ * issued/expiry timestamps, roles, and the raw decoded claims.
11
+ *
12
+ * The trigger text and the popover share a single container so the
13
+ * popover stays open while the mouse travels from the label into it.
14
+ *
15
+ * @module views/profile
16
+ */
17
+ import { useState, useRef, useCallback } from 'react';
18
+ import { Box, Text } from '@primer/react';
19
+ import { parseJwtPayload, getDatalayerJwtUser, getDatalayerDisplayName, } from '../../utils/Jwt';
20
+ // ── Component ─────────────────────────────────────────────────────
21
+ export const UserBadge = ({ token, variant = 'full', }) => {
22
+ const [open, setOpen] = useState(false);
23
+ const closeTimer = useRef(null);
24
+ const handleEnter = useCallback(() => {
25
+ if (closeTimer.current)
26
+ clearTimeout(closeTimer.current);
27
+ setOpen(true);
28
+ }, []);
29
+ const handleLeave = useCallback(() => {
30
+ // Small delay so the mouse can travel from the label into the popover
31
+ // without it closing.
32
+ closeTimer.current = setTimeout(() => setOpen(false), 120);
33
+ }, []);
34
+ const user = getDatalayerJwtUser(token);
35
+ const displayName = getDatalayerDisplayName(user, user?.handle ?? '');
36
+ const claims = parseJwtPayload(token);
37
+ return (_jsxs(Box, { sx: { position: 'relative' }, onMouseEnter: handleEnter, onMouseLeave: handleLeave, children: [_jsx(Text, { sx: {
38
+ fontSize: 1,
39
+ color: 'fg.muted',
40
+ cursor: 'default',
41
+ borderBottom: '1px dashed',
42
+ borderColor: 'border.muted',
43
+ pb: '1px',
44
+ userSelect: 'none',
45
+ }, children: displayName }), open && claims && (_jsxs(Box, { sx: {
46
+ position: 'absolute',
47
+ top: 'calc(100% + 4px)',
48
+ right: 0,
49
+ zIndex: 100,
50
+ width: '400px',
51
+ bg: 'canvas.overlay',
52
+ border: '1px solid',
53
+ borderColor: 'border.default',
54
+ borderRadius: 2,
55
+ boxShadow: 'shadow.large',
56
+ overflow: 'hidden',
57
+ }, children: [_jsx(Box, { sx: {
58
+ px: 3,
59
+ py: 2,
60
+ bg: 'canvas.subtle',
61
+ borderBottom: '1px solid',
62
+ borderColor: 'border.default',
63
+ }, children: _jsx(Text, { sx: { fontWeight: 'bold', fontSize: 1 }, children: "JWT Claims" }) }), claims.user && (_jsx(Box, { sx: {
64
+ px: 3,
65
+ py: 2,
66
+ borderBottom: '1px solid',
67
+ borderColor: 'border.muted',
68
+ }, children: _jsxs(Box, { sx: {
69
+ display: 'grid',
70
+ gridTemplateColumns: '90px 1fr',
71
+ gap: 1,
72
+ fontSize: 0,
73
+ }, children: [claims.user.email && (_jsxs(_Fragment, { children: [_jsx(Text, { sx: { color: 'fg.muted' }, children: "Email" }), _jsx(Text, { sx: { fontFamily: 'mono' }, children: claims.user.email })] })), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Handle" }), _jsx(Text, { sx: { fontFamily: 'mono' }, children: claims.user.handle }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "UID" }), _jsx(Text, { sx: { fontFamily: 'mono', wordBreak: 'break-all' }, children: claims.user.uid }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Issued" }), _jsx(Text, { sx: { fontFamily: 'mono' }, children: new Date(claims.iat * 1000).toISOString() }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Expires" }), _jsx(Text, { sx: { fontFamily: 'mono' }, children: new Date(claims.exp * 1000).toISOString() })] }) })), (claims.user?.roles ?? claims.roles ?? []).length > 0 && (_jsxs(Box, { sx: {
74
+ px: 3,
75
+ py: 2,
76
+ borderBottom: '1px solid',
77
+ borderColor: 'border.muted',
78
+ }, children: [_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', display: 'block', mb: 1 }, children: "Roles" }), _jsx(Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: 1 }, children: (claims.user?.roles ?? claims.roles ?? []).map(r => (_jsx(Box, { sx: {
79
+ fontSize: 0,
80
+ fontFamily: 'mono',
81
+ px: 1,
82
+ py: '1px',
83
+ bg: 'accent.subtle',
84
+ color: 'accent.fg',
85
+ borderRadius: 1,
86
+ border: '1px solid',
87
+ borderColor: 'accent.muted',
88
+ }, children: r }, r))) })] })), variant === 'full' && (_jsx(Box, { as: "pre", sx: {
89
+ m: 0,
90
+ px: 3,
91
+ py: 2,
92
+ fontFamily: 'mono',
93
+ fontSize: 0,
94
+ color: 'fg.default',
95
+ bg: 'canvas.inset',
96
+ overflow: 'auto',
97
+ maxHeight: '220px',
98
+ whiteSpace: 'pre',
99
+ }, children: JSON.stringify(claims, null, 2) }))] }))] }));
100
+ };
101
+ export default UserBadge;
@@ -0,0 +1,2 @@
1
+ export { UserBadge } from './UserBadge';
2
+ export type { UserBadgeProps } from './UserBadge';
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ export { UserBadge } from './UserBadge';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/core",
3
- "version": "1.0.2",
3
+ "version": "1.0.11",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",
@@ -54,7 +54,7 @@
54
54
  "build": "npm run clean && gulp resources-to-lib && tsc -b && vite build",
55
55
  "build:lib": "npm run clean:lib && gulp resources-to-lib && tsc -b && node scripts/fix-esm-imports.cjs",
56
56
  "build:types": "npm run clean:lib && tsc -b",
57
- "build:nextjs": "npm run build --workspace=nextjs-notebook-example",
57
+ "build:nextjs": "npm run build --workspace=nextjj-example",
58
58
  "build:examples": "npm run build:nextjs",
59
59
  "build:all": "npm run build && npm run build:examples",
60
60
  "lint": "eslint . --quiet",
@@ -90,7 +90,7 @@
90
90
  "type-check:watch": "tsc -b -w --noEmit",
91
91
  "examples": "run-p jupyter:start examples:vite",
92
92
  "examples:vite": "VITE_DATALAYER_RUN_URL=http://localhost:8888 vite --config vite.examples.config.ts",
93
- "examples:nextjs": "npm run dev --workspace=nextjs-notebook-example",
93
+ "examples:nextjs": "npm run dev --workspace=nextjj-example",
94
94
  "jupyter:start": "./dev/sh/start-jupyter-server.sh",
95
95
  "prepare": "husky || true",
96
96
  "kill": "./dev/sh/kill.sh || true",
@@ -196,7 +196,6 @@
196
196
  "@types/node": "^20.11.0",
197
197
  "@types/react": "18.3.20",
198
198
  "@types/react-dom": "18.3.6",
199
- "@types/react-syntax-highlighter": "^15.5.13",
200
199
  "@vitejs/plugin-react": "^4.5.2",
201
200
  "@vitest/browser": "^3.2.4",
202
201
  "@vitest/coverage-v8": "^3.2.4",