@object-ui/console 3.1.2 → 3.1.3
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/dist/assets/{AdvancedChartImpl-D711bBuO.js → AdvancedChartImpl-BvIFxlPf.js} +2 -2
- package/dist/assets/{AppManagementPage-CaWUYaXX.js → AppManagementPage-6bzxYNlP.js} +1 -1
- package/dist/assets/{AuditLogPage-CB1qkThp.js → AuditLogPage-qCzdxaNq.js} +1 -1
- package/dist/assets/{AuthPageLayout-9l5xWV_-.js → AuthPageLayout-DkrxSZOE.js} +1 -1
- package/dist/assets/{ChartImpl-B9B4Fnbe.js → ChartImpl-DYQ9eXJz.js} +1 -1
- package/dist/assets/CreateAppPage-DNKskVHK.js +1 -0
- package/dist/assets/{DashboardDesignPage-DGz-5xrK.js → DashboardDesignPage-T9tEAHAx.js} +1 -1
- package/dist/assets/{DashboardView-v834XbaQ.js → DashboardView-jCJCERzJ.js} +1 -1
- package/dist/assets/{EditAppPage-DocDqKMS.js → EditAppPage-UGT9V29B.js} +1 -1
- package/dist/assets/{ForgotPasswordPage-8ypvh4-X.js → ForgotPasswordPage-Ca0lLZwY.js} +1 -1
- package/dist/assets/{KanbanEnhanced-Cw4oddBv.js → KanbanEnhanced-CyIdmKhW.js} +1 -1
- package/dist/assets/{KanbanImpl-D6ggfmB0.js → KanbanImpl-PGPpv-gu.js} +1 -1
- package/dist/assets/{LoginPage-XakThPoT.js → LoginPage-BR2RpoGG.js} +1 -1
- package/dist/assets/{MarkdownImpl-C0wRapHT.js → MarkdownImpl-eDhoPCJp.js} +1 -1
- package/dist/assets/{OrgManagementPage-Df5167oO.js → OrgManagementPage-DjT2mZ2x.js} +1 -1
- package/dist/assets/{PageDesignPage-BzM4EsXt.js → PageDesignPage-DTEQcEuR.js} +1 -1
- package/dist/assets/{PageView-CpIQvLmr.js → PageView-CFJhE0CN.js} +2 -2
- package/dist/assets/{PermissionManagementPage-CZH3URJU.js → PermissionManagementPage-C_FPnvGW.js} +1 -1
- package/dist/assets/{ProfilePage-BvIbbebc.js → ProfilePage-CQkgvEEi.js} +1 -1
- package/dist/assets/RecordDetailView-ClpxNRz2.js +1 -0
- package/dist/assets/{RegisterPage-CIeFN9rY.js → RegisterPage-6IYU4bdp.js} +1 -1
- package/dist/assets/{ReportView-DYhXezmy.js → ReportView-DecAJ58u.js} +1 -1
- package/dist/assets/{RoleManagementPage-D0X7HlqJ.js → RoleManagementPage-v0ia3MGn.js} +1 -1
- package/dist/assets/{SearchResultsPage-CoMB32KW.js → SearchResultsPage-CaSb54ho.js} +1 -1
- package/dist/assets/{SystemHubPage-Cvl3VKcV.js → SystemHubPage-PNaxZEht.js} +1 -1
- package/dist/assets/{UserManagementPage-5k8BQxT1.js → UserManagementPage-KAZy5fgy.js} +1 -1
- package/dist/assets/data-adapter-DCM4pdG4.js +1 -0
- package/dist/assets/{framework-52FGgFF6.js → framework-jBjO8CT3.js} +2 -2
- package/dist/assets/{index-D5i0wk-G.js → index-BwkHrw9s.js} +1 -1
- package/dist/assets/index-DXak0mZe.css +1 -0
- package/dist/assets/{index-fjkakZm9.js → index-tta28Q_N.js} +3 -3
- package/dist/assets/infrastructure-CWeiQ12V.js +1 -0
- package/dist/assets/{maplibre-gl-DVmJFhI2.js → maplibre-gl-CENyyZ0G.js} +1 -1
- package/dist/assets/plugins-core-BV7ym-7D.js +8 -0
- package/dist/assets/plugins-views-gxDbTdkX.js +62 -0
- package/dist/assets/{ui-components-CxztIKgM.css → ui-components-BCiSmwiC.css} +1 -1
- package/dist/assets/ui-components-BRpbeVr1.js +36 -0
- package/dist/assets/ui-layout-VeUu0ZVf.js +1 -0
- package/dist/assets/vendor-charts-DthMRf4E.js +60 -0
- package/dist/assets/{vendor-dndkit-CX1oDZqy.js → vendor-dndkit-_-PfuStg.js} +1 -1
- package/dist/assets/vendor-i18n-B3GHNV0X.js +9 -0
- package/dist/assets/{vendor-icons-ndICq8DC.js → vendor-icons-CnLeuN7Z.js} +3419 -3414
- package/dist/assets/vendor-objectstack-BkRCrdfn.js +34 -0
- package/dist/assets/vendor-radix-BPVlBHPl.js +56 -0
- package/dist/assets/{vendor-react-9M-xu2bR.js → vendor-react-Dvo_9NuO.js} +6 -6
- package/dist/assets/{vendor-ui-utils-3tkeUVaX.js → vendor-ui-utils-CU11aiRA.js} +1 -1
- package/dist/assets/vendor-zod-CZmssJWz.js +39 -0
- package/dist/index.html +23 -23
- package/package.json +40 -40
- package/dist/assets/CreateAppPage-DLRU3TEg.js +0 -1
- package/dist/assets/RecordDetailView-BNnPf0DG.js +0 -1
- package/dist/assets/data-adapter-Bif-TtZA.js +0 -1
- package/dist/assets/index-h9Jznm67.css +0 -1
- package/dist/assets/infrastructure-Dn7jNPwf.js +0 -1
- package/dist/assets/plugins-core-CP8uPw4p.js +0 -8
- package/dist/assets/plugins-views-DZCu8Ex3.js +0 -62
- package/dist/assets/ui-components-BE4yvyhE.js +0 -36
- package/dist/assets/ui-layout-CYnH69Z2.js +0 -1
- package/dist/assets/vendor-charts-BLNOCZWl.js +0 -65
- package/dist/assets/vendor-i18n-E3-WitRV.js +0 -9
- package/dist/assets/vendor-objectstack-CatrkstC.js +0 -34
- package/dist/assets/vendor-radix-C6qchjxv.js +0 -56
- package/dist/assets/vendor-zod-C5j6C2CQ.js +0 -39
package/dist/index.html
CHANGED
|
@@ -19,30 +19,30 @@
|
|
|
19
19
|
<script>
|
|
20
20
|
window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
|
|
21
21
|
</script>
|
|
22
|
-
<script type="module" crossorigin src="/console/assets/index-
|
|
23
|
-
<link rel="modulepreload" crossorigin href="/console/assets/vendor-react-
|
|
24
|
-
<link rel="modulepreload" crossorigin href="/console/assets/vendor-zod-
|
|
25
|
-
<link rel="modulepreload" crossorigin href="/console/assets/vendor-objectstack-
|
|
26
|
-
<link rel="modulepreload" crossorigin href="/console/assets/framework-
|
|
27
|
-
<link rel="modulepreload" crossorigin href="/console/assets/vendor-ui-utils-
|
|
28
|
-
<link rel="modulepreload" crossorigin href="/console/assets/vendor-icons-
|
|
29
|
-
<link rel="modulepreload" crossorigin href="/console/assets/vendor-i18n-
|
|
30
|
-
<link rel="modulepreload" crossorigin href="/console/assets/vendor-radix-
|
|
31
|
-
<link rel="modulepreload" crossorigin href="/console/assets/vendor-charts-
|
|
32
|
-
<link rel="modulepreload" crossorigin href="/console/assets/infrastructure-
|
|
33
|
-
<link rel="modulepreload" crossorigin href="/console/assets/ui-components-
|
|
34
|
-
<link rel="modulepreload" crossorigin href="/console/assets/vendor-dndkit-
|
|
35
|
-
<link rel="modulepreload" crossorigin href="/console/assets/plugins-views-
|
|
36
|
-
<link rel="modulepreload" crossorigin href="/console/assets/plugins-core-
|
|
37
|
-
<link rel="modulepreload" crossorigin href="/console/assets/data-adapter-
|
|
38
|
-
<link rel="modulepreload" crossorigin href="/console/assets/ui-layout-
|
|
39
|
-
<link rel="stylesheet" crossorigin href="/console/assets/ui-components-
|
|
22
|
+
<script type="module" crossorigin src="/console/assets/index-tta28Q_N.js"></script>
|
|
23
|
+
<link rel="modulepreload" crossorigin href="/console/assets/vendor-react-Dvo_9NuO.js">
|
|
24
|
+
<link rel="modulepreload" crossorigin href="/console/assets/vendor-zod-CZmssJWz.js">
|
|
25
|
+
<link rel="modulepreload" crossorigin href="/console/assets/vendor-objectstack-BkRCrdfn.js">
|
|
26
|
+
<link rel="modulepreload" crossorigin href="/console/assets/framework-jBjO8CT3.js">
|
|
27
|
+
<link rel="modulepreload" crossorigin href="/console/assets/vendor-ui-utils-CU11aiRA.js">
|
|
28
|
+
<link rel="modulepreload" crossorigin href="/console/assets/vendor-icons-CnLeuN7Z.js">
|
|
29
|
+
<link rel="modulepreload" crossorigin href="/console/assets/vendor-i18n-B3GHNV0X.js">
|
|
30
|
+
<link rel="modulepreload" crossorigin href="/console/assets/vendor-radix-BPVlBHPl.js">
|
|
31
|
+
<link rel="modulepreload" crossorigin href="/console/assets/vendor-charts-DthMRf4E.js">
|
|
32
|
+
<link rel="modulepreload" crossorigin href="/console/assets/infrastructure-CWeiQ12V.js">
|
|
33
|
+
<link rel="modulepreload" crossorigin href="/console/assets/ui-components-BRpbeVr1.js">
|
|
34
|
+
<link rel="modulepreload" crossorigin href="/console/assets/vendor-dndkit-_-PfuStg.js">
|
|
35
|
+
<link rel="modulepreload" crossorigin href="/console/assets/plugins-views-gxDbTdkX.js">
|
|
36
|
+
<link rel="modulepreload" crossorigin href="/console/assets/plugins-core-BV7ym-7D.js">
|
|
37
|
+
<link rel="modulepreload" crossorigin href="/console/assets/data-adapter-DCM4pdG4.js">
|
|
38
|
+
<link rel="modulepreload" crossorigin href="/console/assets/ui-layout-VeUu0ZVf.js">
|
|
39
|
+
<link rel="stylesheet" crossorigin href="/console/assets/ui-components-BCiSmwiC.css">
|
|
40
40
|
<link rel="stylesheet" crossorigin href="/console/assets/plugins-views-P3eB-els.css">
|
|
41
|
-
<link rel="stylesheet" crossorigin href="/console/assets/index-
|
|
42
|
-
<link rel="modulepreload" href="/console/assets/vendor-react-
|
|
43
|
-
<link rel="modulepreload" href="/console/assets/framework-
|
|
44
|
-
<link rel="modulepreload" href="/console/assets/ui-components-
|
|
45
|
-
<link rel="modulepreload" href="/console/assets/vendor-radix-
|
|
41
|
+
<link rel="stylesheet" crossorigin href="/console/assets/index-DXak0mZe.css">
|
|
42
|
+
<link rel="modulepreload" href="/console/assets/vendor-react-Dvo_9NuO.js" />
|
|
43
|
+
<link rel="modulepreload" href="/console/assets/framework-jBjO8CT3.js" />
|
|
44
|
+
<link rel="modulepreload" href="/console/assets/ui-components-BRpbeVr1.js" />
|
|
45
|
+
<link rel="modulepreload" href="/console/assets/vendor-radix-BPVlBHPl.js" />
|
|
46
46
|
</head>
|
|
47
47
|
<body>
|
|
48
48
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/console",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "ObjectStack Console - The standard runtime UI for ObjectStack applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./plugin.js",
|
|
@@ -22,27 +22,27 @@
|
|
|
22
22
|
"@dnd-kit/core": "^6.3.1",
|
|
23
23
|
"@dnd-kit/sortable": "^10.0.0",
|
|
24
24
|
"@dnd-kit/utilities": "^3.2.2",
|
|
25
|
-
"@objectstack/cli": "^3.2.
|
|
26
|
-
"@objectstack/client": "^3.2.
|
|
27
|
-
"@objectstack/driver-memory": "^3.2.
|
|
28
|
-
"@objectstack/objectql": "^3.2.
|
|
29
|
-
"@objectstack/plugin-msw": "^3.2.
|
|
30
|
-
"@objectstack/runtime": "^3.2.
|
|
31
|
-
"@objectstack/spec": "^3.2.
|
|
25
|
+
"@objectstack/cli": "^3.2.6",
|
|
26
|
+
"@objectstack/client": "^3.2.6",
|
|
27
|
+
"@objectstack/driver-memory": "^3.2.6",
|
|
28
|
+
"@objectstack/objectql": "^3.2.6",
|
|
29
|
+
"@objectstack/plugin-msw": "^3.2.6",
|
|
30
|
+
"@objectstack/runtime": "^3.2.6",
|
|
31
|
+
"@objectstack/spec": "^3.2.6",
|
|
32
32
|
"@tailwindcss/postcss": "^4.2.1",
|
|
33
33
|
"@testing-library/jest-dom": "^6.9.1",
|
|
34
34
|
"@testing-library/react": "^16.3.2",
|
|
35
35
|
"@testing-library/user-event": "^14.6.1",
|
|
36
|
-
"@types/node": "^25.
|
|
36
|
+
"@types/node": "^25.4.0",
|
|
37
37
|
"@types/react": "19.2.14",
|
|
38
38
|
"@types/react-dom": "19.2.3",
|
|
39
39
|
"@vitejs/plugin-react": "^5.1.4",
|
|
40
40
|
"@vitest/ui": "^4.0.18",
|
|
41
41
|
"autoprefixer": "^10.4.27",
|
|
42
|
-
"happy-dom": "^20.
|
|
43
|
-
"lucide-react": "^0.
|
|
42
|
+
"happy-dom": "^20.8.3",
|
|
43
|
+
"lucide-react": "^0.577.0",
|
|
44
44
|
"msw": "^2.12.10",
|
|
45
|
-
"postcss": "^8.5.
|
|
45
|
+
"postcss": "^8.5.8",
|
|
46
46
|
"react": "19.2.4",
|
|
47
47
|
"react-dom": "19.2.4",
|
|
48
48
|
"react-router-dom": "^7.13.1",
|
|
@@ -51,36 +51,36 @@
|
|
|
51
51
|
"typescript": "^5.9.3",
|
|
52
52
|
"vite": "^6.4.1",
|
|
53
53
|
"vitest": "^4.0.18",
|
|
54
|
-
"@object-ui/
|
|
55
|
-
"@object-ui/
|
|
56
|
-
"@object-ui/components": "3.1.
|
|
57
|
-
"@object-ui/core": "3.1.
|
|
58
|
-
"@object-ui/data-objectstack": "3.1.
|
|
54
|
+
"@object-ui/auth": "3.1.3",
|
|
55
|
+
"@object-ui/collaboration": "3.1.3",
|
|
56
|
+
"@object-ui/components": "3.1.3",
|
|
57
|
+
"@object-ui/core": "3.1.3",
|
|
58
|
+
"@object-ui/data-objectstack": "3.1.3",
|
|
59
|
+
"@object-ui/example-crm": "3.1.0",
|
|
59
60
|
"@object-ui/example-kitchen-sink": "3.1.0",
|
|
60
61
|
"@object-ui/example-todo": "3.1.0",
|
|
61
|
-
"@object-ui/
|
|
62
|
-
"@object-ui/
|
|
63
|
-
"@object-ui/
|
|
64
|
-
"@object-ui/mobile": "3.1.
|
|
65
|
-
"@object-ui/
|
|
66
|
-
"@object-ui/
|
|
67
|
-
"@object-ui/plugin-
|
|
68
|
-
"@object-ui/plugin-
|
|
69
|
-
"@object-ui/plugin-
|
|
70
|
-
"@object-ui/plugin-
|
|
71
|
-
"@object-ui/plugin-
|
|
72
|
-
"@object-ui/plugin-
|
|
73
|
-
"@object-ui/plugin-
|
|
74
|
-
"@object-ui/plugin-
|
|
75
|
-
"@object-ui/plugin-
|
|
76
|
-
"@object-ui/plugin-
|
|
77
|
-
"@object-ui/plugin-
|
|
78
|
-
"@object-ui/plugin-
|
|
79
|
-
"@object-ui/plugin-
|
|
80
|
-
"@object-ui/plugin-
|
|
81
|
-
"@object-ui/
|
|
82
|
-
"@object-ui/
|
|
83
|
-
"@object-ui/types": "3.1.2"
|
|
62
|
+
"@object-ui/fields": "3.1.3",
|
|
63
|
+
"@object-ui/i18n": "3.1.3",
|
|
64
|
+
"@object-ui/layout": "3.1.3",
|
|
65
|
+
"@object-ui/mobile": "3.1.3",
|
|
66
|
+
"@object-ui/permissions": "3.1.3",
|
|
67
|
+
"@object-ui/plugin-calendar": "3.1.3",
|
|
68
|
+
"@object-ui/plugin-charts": "3.1.3",
|
|
69
|
+
"@object-ui/plugin-dashboard": "3.1.3",
|
|
70
|
+
"@object-ui/plugin-designer": "3.1.3",
|
|
71
|
+
"@object-ui/plugin-detail": "3.1.3",
|
|
72
|
+
"@object-ui/plugin-form": "3.1.3",
|
|
73
|
+
"@object-ui/plugin-gantt": "3.1.3",
|
|
74
|
+
"@object-ui/plugin-grid": "3.1.3",
|
|
75
|
+
"@object-ui/plugin-kanban": "3.1.3",
|
|
76
|
+
"@object-ui/plugin-list": "3.1.3",
|
|
77
|
+
"@object-ui/plugin-map": "3.1.3",
|
|
78
|
+
"@object-ui/plugin-markdown": "3.1.3",
|
|
79
|
+
"@object-ui/plugin-report": "3.1.3",
|
|
80
|
+
"@object-ui/plugin-timeline": "3.1.3",
|
|
81
|
+
"@object-ui/plugin-view": "3.1.3",
|
|
82
|
+
"@object-ui/react": "3.1.3",
|
|
83
|
+
"@object-ui/types": "3.1.3"
|
|
84
84
|
},
|
|
85
85
|
"msw": {
|
|
86
86
|
"workerDirectory": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as C,i as v,r as e,j as n}from"./vendor-react-9M-xu2bR.js";import{AppCreationWizard as x}from"./index-D5i0wk-G.js";import{z as S}from"./framework-52FGgFF6.js";import"./vendor-objectstack-CatrkstC.js";import{b,a as y}from"./index-fjkakZm9.js";import{b as s}from"./vendor-ui-utils-3tkeUVaX.js";import"./vendor-icons-ndICq8DC.js";import"./infrastructure-Dn7jNPwf.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-zod-C5j6C2CQ.js";import"./ui-components-BE4yvyhE.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-charts-BLNOCZWl.js";import"./plugins-core-CP8uPw4p.js";import"./vendor-dndkit-CX1oDZqy.js";import"./plugins-views-DZCu8Ex3.js";import"./data-adapter-Bif-TtZA.js";import"./ui-layout-CYnH69Z2.js";const i="objectui-app-wizard-draft";function K(){const t=C(),{appName:r}=v(),{objects:l,refresh:p}=b(),c=y(),f=(l||[]).map(a=>({name:a.name,label:a.label||a.name,icon:a.icon,selected:!1})),u=e.useCallback(()=>{try{const a=localStorage.getItem(i);if(a)return JSON.parse(a)}catch{}},[]),d=e.useCallback(async a=>{try{const o=S(a),m=c?.getClient();m&&await m.meta.saveItem("app",a.name,o),localStorage.removeItem(i),s.success(`Application "${a.title}" created successfully`),await p?.(),t(`/apps/${a.name}`)}catch(o){s.error(o?.message||"Failed to create application")}},[t,p,c]),g=e.useCallback(()=>{t(r?`/apps/${r}`:"/")},[t,r]),h=e.useCallback(a=>{try{localStorage.setItem(i,JSON.stringify(a)),s.info("Draft saved")}catch{}},[]);return n.jsx("div",{className:"mx-auto max-w-4xl py-8 px-4","data-testid":"create-app-page",children:n.jsx(x,{availableObjects:f,initialDraft:u(),onComplete:d,onCancel:g,onSaveDraft:h})})}export{K as CreateAppPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,r as c,i as ne,h as ae}from"./vendor-react-9M-xu2bR.js";import{D as re,R as le}from"./plugins-views-DZCu8Ex3.js";import{p as x,be as ie,bf as oe,bg as ce,bh as de,bi as me,bj as ue,bk as fe,bl as he,D as pe,O as xe,l as ge,n as je,o as be,aa as ye,a0 as ve,a1 as we,a2 as Ne,a3 as Ae,a4 as Ce,bm as De,ab as P,U as _e,B as U,b7 as ke,b8 as Ie,b9 as Re}from"./ui-components-BE4yvyhE.js";import{A as $e}from"./framework-52FGgFF6.js";import"./vendor-objectstack-CatrkstC.js";import{c as Te,u as Ee}from"./infrastructure-Dn7jNPwf.js";import{b as H}from"./vendor-ui-utils-3tkeUVaX.js";import{u as Ve,P as Fe,M as Pe}from"./index-fjkakZm9.js";import{aQ as Ue,b4 as He}from"./vendor-icons-ndICq8DC.js";import"./vendor-charts-BLNOCZWl.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-zod-C5j6C2CQ.js";import"./plugins-core-CP8uPw4p.js";import"./vendor-dndkit-CX1oDZqy.js";import"./data-adapter-Bif-TtZA.js";import"./ui-layout-CYnH69Z2.js";function Oe({fields:r=8,columns:h=2}){return e.jsxs("div",{className:"w-full space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{className:"h-8 w-8 rounded"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{className:"h-6 w-48"}),e.jsx(x,{className:"h-4 w-32"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-9 w-20"}),e.jsx(x,{className:"h-9 w-20"})]})]}),e.jsx(x,{className:"h-5 w-24"}),e.jsx("div",{className:`grid grid-cols-1 ${h===2?"md:grid-cols-2":""} gap-4`,children:Array.from({length:r}).map((p,i)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{className:"h-4 w-24"}),e.jsx(x,{className:"h-9 w-full"})]},`field-${i}`))}),e.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[e.jsx(x,{className:"h-5 w-32"}),e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((p,i)=>e.jsxs("div",{className:"flex items-center gap-3 py-2",children:[e.jsx(x,{className:"h-8 w-8 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(x,{className:"h-4 w-40"}),e.jsx(x,{className:"h-3 w-24"})]})]},`related-${i}`))})]})]})}function Se({state:r,onOpenChange:h}){const p=()=>{r.resolve?.(!0),h(!1)},i=()=>{r.resolve?.(!1),h(!1)};return e.jsx(ie,{open:r.open,onOpenChange:g=>{g||i()},children:e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsx(de,{children:r.options?.title||"Confirm Action"}),e.jsx(me,{children:r.message})]}),e.jsxs(ue,{children:[e.jsx(fe,{onClick:i,children:r.options?.cancelText||"Cancel"}),e.jsx(he,{onClick:p,children:r.options?.confirmText||"Continue"})]})]})})}function Le({state:r,onOpenChange:h}){const[p,i]=c.useState({}),[g,N]=c.useState({});c.useEffect(()=>{if(r.open){const n={};for(const o of r.params)o.defaultValue!==void 0&&(n[o.name]=o.defaultValue);i(n),N({})}},[r.open,r.params]);const v=n=>n==null?!0:typeof n=="string"?n.trim()==="":Array.isArray(n)?n.length===0:!1,A=()=>{const n={};for(const o of r.params)o.required&&v(p[o.name])&&(n[o.name]=!0);if(Object.keys(n).length>0){N(n);return}r.resolve?.(p),h(!1)},C=()=>{r.resolve?.(null),h(!1)},w=(n,o)=>{i(b=>({...b,[n]:o})),N(b=>({...b,[n]:!1}))};return e.jsx(pe,{open:r.open,onOpenChange:n=>{n||C()},children:e.jsxs(xe,{children:[e.jsxs(ge,{children:[e.jsx(je,{children:"Action Parameters"}),e.jsx(be,{children:"Please provide the required information to continue."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:r.params.map(n=>e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(ye,{htmlFor:n.name,children:[n.label,n.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),n.type==="select"&&n.options?e.jsxs(ve,{value:p[n.name]??"",onValueChange:o=>w(n.name,o),children:[e.jsx(we,{id:n.name,className:g[n.name]?"border-destructive":"",children:e.jsx(Ne,{placeholder:n.placeholder||`Select ${n.label}`})}),e.jsx(Ae,{children:n.options.map(o=>e.jsx(Ce,{value:o.value,children:o.label},o.value))})]}):n.type==="textarea"?e.jsx(De,{id:n.name,value:p[n.name]??"",onChange:o=>w(n.name,o.target.value),placeholder:n.placeholder,className:g[n.name]?"border-destructive":""}):n.type==="number"?e.jsx(P,{id:n.name,type:"number",value:p[n.name]??"",onChange:o=>w(n.name,o.target.value===""?void 0:o.target.valueAsNumber),placeholder:n.placeholder,className:g[n.name]?"border-destructive":""}):e.jsx(P,{id:n.name,type:["email","url","date","datetime-local","time","password"].includes(n.type)?n.type:"text",value:p[n.name]??"",onChange:o=>w(n.name,o.target.value),placeholder:n.placeholder,className:g[n.name]?"border-destructive":""}),g[n.name]&&e.jsxs("p",{className:"text-xs text-destructive",children:[n.label," is required"]}),n.helpText&&e.jsx("p",{className:"text-xs text-muted-foreground",children:n.helpText})]},n.name))}),e.jsxs(_e,{children:[e.jsx(U,{variant:"outline",onClick:C,children:"Cancel"}),e.jsx(U,{onClick:A,children:"Confirm"})]})]})})}const qe={id:"current-user",name:"Demo User"},Me=["status","stage","priority","category","type","owner","amount"];function ot({dataSource:r,objects:h,onEdit:p}){const{objectName:i,recordId:g}=ne(),{showDebug:N}=Ve(),{user:v}=Te(),A=ae(),{t:C}=Ee(),[w,n]=c.useState(!0),[o,b]=c.useState([]),[I,O]=c.useState([]),[S,L]=c.useState(0),[q,M]=c.useState({}),m=h.find(s=>s.name===i),u=g,[B,R]=c.useState({open:!1,message:""}),[G,$]=c.useState({open:!1,params:[]}),K=c.useCallback((s,t)=>new Promise(a=>{R({open:!0,message:s,options:t,resolve:a})}),[]),z=c.useCallback(s=>new Promise(t=>{$({open:!0,params:s,resolve:t})}),[]),Q=c.useCallback((s,t)=>{t?.type==="error"?H.error(s):H.success(s)},[]),J=c.useCallback((s,t)=>{t?.external||t?.newTab?window.open(s,"_blank","noopener,noreferrer"):A(s)},[A]),W=c.useCallback(async s=>{try{const t=s.target||s.name,a=s.params||{};switch(t){case"opportunity_change_stage":await r.update(i,u,{stage:a.new_stage});break;case"opportunity_mark_won":await r.update(i,u,{stage:"closed_won"});break;case"opportunity_mark_lost":await r.update(i,u,{stage:"closed_lost",loss_reason:a.loss_reason});break;default:Object.keys(a).length>0&&await r.update(i,u,a);break}const l=s.refreshAfter===!0;return l&&L(d=>d+1),{success:!0,reload:l}}catch(t){return{success:!1,error:t.message}}},[r,i,u]),D=c.useMemo(()=>{if(!m||!h)return[];const s=[];for(const t of h)if(t.name!==m.name)for(const[a,l]of Object.entries(t.fields||{}))l&&(l.type==="lookup"||l.type==="master_detail")&&(l.reference_to||l.reference)===m.name&&s.push({childObject:t.name,childLabel:t.label||t.name,referenceField:a});return s},[m,h]);c.useEffect(()=>{if(!r||!u||D.length===0)return;let s=!1;return Promise.all(D.map(({childObject:t,referenceField:a})=>r.find(t,{$filter:{[a]:u}}).then(l=>{const d=Array.isArray(l)?l:l?.data||[];return{childObject:t,items:d}}).catch(l=>(console.warn(`[RecordDetailView] Failed to fetch related ${t}:`,l),{childObject:t,items:[]})))).then(t=>{if(s)return;const a={};for(const{childObject:l,items:d}of t)a[l]=d;M(a)}),()=>{s=!0}},[r,u,D]);const f=v?{id:v.id,name:v.name,avatar:v.image}:qe;c.useEffect(()=>{if(!r||!i||!u)return;const s=`${i}:${u}`;r.find("sys_presence",{$filter:`recordId eq '${u}'`}).then(t=>{t.data?.length&&O(t.data)}).catch(()=>{}),r.find("sys_comment",{$filter:`threadId eq '${s}'`,$orderby:"createdAt asc"}).then(t=>{t.data?.length&&b(t.data.map(a=>({id:a.id,type:"comment",actor:a.author?.name??"Unknown",actorAvatarUrl:a.author?.avatar,body:a.content,createdAt:a.createdAt,updatedAt:a.updatedAt,parentId:a.parentId,reactions:a.reactions?Object.entries(a.reactions).map(([l,d])=>({emoji:l,count:d.length,reacted:d.includes(f.id)})):void 0})))}).catch(()=>{})},[r,i,u,f]);const X=c.useCallback(async s=>{const t={id:crypto.randomUUID(),type:"comment",actor:f.name,actorAvatarUrl:"avatar"in f?f.avatar:void 0,body:s,createdAt:new Date().toISOString()};if(b(a=>[...a,t]),r){const a=`${i}:${u}`;r.create("sys_comment",{id:t.id,threadId:a,author:f,content:s,mentions:[],createdAt:t.createdAt}).catch(()=>{})}},[f,r,i,u]),Y=c.useCallback(async(s,t)=>{const a={id:crypto.randomUUID(),type:"comment",actor:f.name,actorAvatarUrl:"avatar"in f?f.avatar:void 0,body:t,createdAt:new Date().toISOString(),parentId:s};if(b(l=>[...l,a].map(j=>j.id===s?{...j,replyCount:(j.replyCount??0)+1}:j)),r){const l=`${i}:${u}`;r.create("sys_comment",{id:a.id,threadId:l,author:f,content:t,mentions:[],createdAt:a.createdAt,parentId:s}).catch(()=>{})}},[f,r,i,u]),Z=c.useCallback((s,t)=>{b(a=>a.map(l=>{if(l.id!==s)return l;const d=[...l.reactions??[]],j=d.findIndex(y=>y.emoji===t);if(j>=0){const y=d[j];y.reacted?y.count<=1?d.splice(j,1):d[j]={...y,count:y.count-1,reacted:!1}:d[j]={...y,count:y.count+1,reacted:!0}}else d.push({emoji:t,count:1,reacted:!0});const se={...l,reactions:d};return r&&r.update("sys_comment",String(s),{$toggleReaction:{emoji:t,userId:f.id}}).catch(()=>{}),se}))},[f.id,r]);if(c.useEffect(()=>{n(!0),queueMicrotask(()=>n(!1))},[i,g]),w)return e.jsx(Oe,{});if(!m)return e.jsx("div",{className:"flex h-full items-center justify-center p-4",children:e.jsxs(ke,{children:[e.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:e.jsx(Ue,{className:"h-6 w-6 text-muted-foreground"})}),e.jsx(Ie,{children:"Object Not Found"}),e.jsxs(Re,{children:['Object "',i,'" definition missing. Check your configuration or navigate back to select a valid object.']})]})});const ee=m.primaryField||Object.keys(m.fields||{}).find(s=>s==="name"||s==="title"),_=m.views?.form?.sections,te=_&&_.length>0?_.map(s=>({title:s.title,collapsible:s.collapsible,defaultCollapsed:s.defaultCollapsed,fields:(s.fields||[]).map(t=>{const a=typeof t=="string"?t:t.name,l=m.fields[a];if(!l)return console.warn(`[RecordDetailView] Field "${a}" not found in ${m.name} definition`),{name:a,label:a};const d=l.reference_to||l.reference;return{name:a,label:l.label||a,type:l.type||"text",...l.options&&{options:l.options},...d&&{reference_to:d},...l.reference_field&&{reference_field:l.reference_field},...l.currency&&{currency:l.currency}}})})):[{title:C("detail.details",{defaultValue:"Details"}),fields:Object.keys(m.fields||{}).map(s=>{const t=m.fields[s],a=t.reference_to||t.reference;return{name:s,label:t.label||s,type:t.type||"text",...t.options&&{options:t.options},...a&&{reference_to:a},...t.reference_field&&{reference_field:t.reference_field},...t.currency&&{currency:t.currency}}})}],T=(()=>{const s=new Set;return(m.actions||[]).filter(t=>t.locations?.includes("record_header")?t.name?s.has(t.name)?!1:(s.add(t.name),!0):!0:!1)})(),E=m.views?.detail?.highlightFields??Object.entries(m.fields||{}).filter(([s])=>Me.includes(s)).map(([s,t])=>({name:s,label:t.label||s,...t.type&&{type:t.type}})),k=m.views?.detail?.sectionGroups??m.views?.form?.sectionGroups,V=D.map(({childObject:s,childLabel:t})=>({title:t,type:"table",api:s,data:q[s]||[]})),F={type:"detail-view",objectName:m.name,resourceId:u,showBack:!0,onBack:"history",showEdit:!0,title:m.label,primaryField:ee,sections:te,autoTabs:!0,autoDiscoverRelated:!0,...V.length>0&&{related:V},...E.length>0&&{highlightFields:E},...k&&k.length>0&&{sectionGroups:k},...T.length>0&&{actions:[{type:"action:bar",location:"record_header",actions:T}]}};return e.jsxs("div",{className:"h-full bg-background overflow-hidden flex flex-col relative",children:[e.jsx("div",{className:"absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2",children:I.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5",title:"Users viewing this record",children:[e.jsx(He,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Fe,{users:I,size:"sm",maxVisible:4,showStatus:!0})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-row",children:[e.jsxs("div",{className:"flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48",children:[e.jsx($e,{context:{record:{},objectName:i,user:f},onConfirm:K,onToast:Q,onNavigate:J,onParamCollection:z,handlers:{api:W},children:e.jsx(re,{schema:F,dataSource:r,onEdit:()=>{p({_id:u,id:u})}},S)}),e.jsx("div",{className:"mt-6 border-t pt-6",children:e.jsx(le,{config:{position:"bottom",collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:o,onAddComment:X,onAddReply:Y,onToggleReaction:Z})})]}),e.jsx(Pe,{open:N,sections:[{title:"View Schema",data:F}]})]}),e.jsx(Se,{state:B,onOpenChange:s=>{s||R(t=>({...t,open:!1}))}}),e.jsx(Le,{state:G,onOpenChange:s=>{s||$(t=>({...t,open:!1}))}})]})}export{ot as RecordDetailView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{O as S}from"./vendor-objectstack-CatrkstC.js";import{j as A}from"./framework-52FGgFF6.js";class O{cache;maxSize;ttl;stats;constructor(t={}){this.cache=new Map,this.maxSize=t.maxSize||100,this.ttl=t.ttl||300*1e3,this.stats={hits:0,misses:0,evictions:0}}async get(t,e){const s=Date.now(),n=this.cache.get(t);if(n){if(s-n.timestamp<this.ttl)return n.accessCount++,n.lastAccessed=s,this.stats.hits++,this.cache.delete(t),this.cache.set(t,n),n.data;this.cache.delete(t)}this.stats.misses++;const r=await e();return this.set(t,r),r}set(t,e){const s=Date.now();this.cache.size>=this.maxSize&&!this.cache.has(t)&&this.evictLRU(),this.cache.set(t,{data:e,timestamp:s,accessCount:1,lastAccessed:s})}evictLRU(){const t=this.cache.keys().next().value;t!==void 0&&(this.cache.delete(t),this.stats.evictions++)}invalidate(t){t?this.cache.delete(t):this.cache.clear()}clear(){this.cache.clear(),this.stats={hits:0,misses:0,evictions:0}}getStats(){const t=this.stats.hits+this.stats.misses,e=t>0?this.stats.hits/t:0;return{size:this.cache.size,maxSize:this.maxSize,hits:this.stats.hits,misses:this.stats.misses,evictions:this.stats.evictions,hitRate:e}}getCachedSync(t){const e=this.cache.get(t);if(e){if(this.ttl>0&&Date.now()-e.timestamp>this.ttl){this.cache.delete(t);return}return this.cache.delete(t),this.cache.set(t,e),this.stats.hits++,e.data}}has(t){const e=this.cache.get(t);return e?Date.now()-e.timestamp>=this.ttl?(this.cache.delete(t),!1):!0:!1}}class g extends Error{constructor(t,e,s,n){super(t),this.code=e,this.statusCode=s,this.details=n,this.name="ObjectStackError",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,details:this.details,stack:this.stack}}}class $ extends g{constructor(t,e){super(`Metadata not found for object: ${t}`,"METADATA_NOT_FOUND",404,{objectName:t,...e}),this.name="MetadataNotFoundError"}}class w extends g{constructor(t,e,s,n,r){super(`Bulk ${t} operation failed: ${e} succeeded, ${s} failed`,"BULK_OPERATION_ERROR",500,{operation:t,successCount:e,failureCount:s,errors:n,...r}),this.successCount=e,this.failureCount=s,this.errors=n,this.name="BulkOperationError"}getSummary(){const t=this.successCount+this.failureCount,e=t>0?this.failureCount/t:0;return{operation:this.details?.operation,total:t,successful:this.successCount,failed:this.failureCount,failureRate:e,errors:this.errors}}}class y extends g{constructor(t,e,s,n){super(`Connection error: ${t}`,"CONNECTION_ERROR",n||503,{url:e,...s}),this.url=e,this.name="ConnectionError"}}class p extends g{constructor(t="Authentication failed",e,s){super(t,"AUTHENTICATION_ERROR",s||401,e),this.name="AuthenticationError"}}class b extends g{constructor(t,e,s,n){super(t,"VALIDATION_ERROR",400,{field:e,validationErrors:s,...n}),this.field=e,this.validationErrors=s,this.name="ValidationError"}getValidationErrors(){return this.validationErrors||[]}}function C(u,t){const e=u?.status||u?.statusCode||500,s=u?.message||u?.statusText||"Unknown error",n={context:t,response:{status:e,data:u?.data,headers:u?.headers}};switch(e){case 401:return new p(s,n,401);case 403:return new p(s,n,403);case 404:if(t?.includes("metadata")||t?.includes("schema")||t?.includes("getObjectSchema")){const r=R(t);return new $(r,n)}return new g(s,"NOT_FOUND",404,n);case 400:return new b(s,void 0,u?.data?.errors,n);case 503:return new y(s,u?.config?.url,n,503);case 504:return new y(s,u?.config?.url,n,504);default:return new g(s,"UNKNOWN_ERROR",e,n)}}function R(u){if(!u)return"unknown";const t=u.match(/\(([^)]+)\)/);return t?t[1]:"unknown"}class k{client;connected=!1;metadataCache;connectionState="disconnected";connectionStateListeners=[];batchProgressListeners=[];autoReconnect;maxReconnectAttempts;reconnectDelay;reconnectAttempts=0;baseUrl;token;fetchImpl;constructor(t){this.client=new S(t),this.metadataCache=new O(t.cache),this.autoReconnect=t.autoReconnect??!0,this.maxReconnectAttempts=t.maxReconnectAttempts??3,this.reconnectDelay=t.reconnectDelay??1e3,this.baseUrl=t.baseUrl,this.token=t.token,this.fetchImpl=t.fetch||globalThis.fetch.bind(globalThis)}async connect(){if(!this.connected){this.setConnectionState("connecting");try{await this.client.connect(),this.connected=!0,this.reconnectAttempts=0,this.setConnectionState("connected")}catch(t){const e=t instanceof Error?t.message:"Failed to connect to ObjectStack server",s=new y(e,void 0,{originalError:t});if(this.setConnectionState("error",s),this.autoReconnect&&this.reconnectAttempts<this.maxReconnectAttempts)await this.attemptReconnect();else throw s}}}async attemptReconnect(){this.reconnectAttempts++,this.setConnectionState("reconnecting");const t=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);await new Promise(e=>setTimeout(e,t)),this.connected=!1,await this.connect()}getConnectionState(){return this.connectionState}isConnected(){return this.connected&&this.connectionState==="connected"}onConnectionStateChange(t){return this.connectionStateListeners.push(t),()=>{const e=this.connectionStateListeners.indexOf(t);e>-1&&this.connectionStateListeners.splice(e,1)}}onBatchProgress(t){return this.batchProgressListeners.push(t),()=>{const e=this.batchProgressListeners.indexOf(t);e>-1&&this.batchProgressListeners.splice(e,1)}}setConnectionState(t,e){this.connectionState=t;const s={state:t,timestamp:Date.now(),error:e};this.connectionStateListeners.forEach(n=>{try{n(s)}catch(r){console.error("Error in connection state listener:",r)}})}emitBatchProgress(t){this.batchProgressListeners.forEach(e=>{try{e(t)}catch(s){console.error("Error in batch progress listener:",s)}})}async find(t,e){if(await this.connect(),e?.$expand&&e.$expand.length>0){const r=await this.rawFindWithPopulate(t,e);return this.normalizeQueryResult(r,e)}const s=this.convertQueryParams(e),n=await this.client.data.find(t,s);return this.normalizeQueryResult(n,e)}async findOne(t,e,s){if(await this.connect(),s?.$expand&&s.$expand.length>0)try{const n={...s,$filter:{_id:String(e)},$top:1},r=await this.rawFindWithPopulate(t,n);if(Array.isArray(r))return r[0]||null;const a=r;return(a.records||a.value||[])[0]||null}catch(n){if(n?.status===404)return null}try{return(await this.client.data.get(t,String(e))).record}catch(n){if(n?.status===404)return null;throw n}}async create(t,e){return await this.connect(),(await this.client.data.create(t,e)).record}async update(t,e,s){return await this.connect(),(await this.client.data.update(t,String(e),s)).record}async delete(t,e){return await this.connect(),(await this.client.data.delete(t,String(e))).deleted}async bulk(t,e,s){if(await this.connect(),!s||s.length===0)return[];const n=s.length;let r=0,a=0;const c=()=>{this.emitBatchProgress({operation:e,total:n,completed:r,failed:a,percentage:n>0?(r+a)/n*100:0})};try{switch(e){case"create":{c();const i=await this.client.data.createMany(t,s);return r=i.length,a=n-r,c(),i}case"delete":{const i=s.map(h=>h.id).filter(Boolean);if(i.length===0){const h=s.map((o,l)=>({index:l,error:`Missing ID for item at index ${l}`}));throw a=s.length,c(),new w("delete",0,s.length,h)}return c(),await this.client.data.deleteMany(t,i),r=i.length,a=n-r,c(),[]}case"update":{if(typeof this.client.data.updateMany=="function")try{c();const o=this.client.data.updateMany,l=await o(t,s);return r=l.length,a=n-r,c(),l}catch{}const i=[],h=[];for(let o=0;o<s.length;o++){const l=s[o],f=l.id;if(!f){h.push({index:o,error:"Missing ID"}),a++,c();continue}try{const d=await this.client.data.update(t,String(f),l);i.push(d.record),r++,c()}catch(d){const m=d instanceof Error?d.message:String(d);h.push({index:o,error:m}),a++,c()}}if(h.length>0)throw new w("update",i.length,h.length,h,{resource:t,totalRecords:s.length});return i}default:throw new g(`Unsupported bulk operation: ${e}`,"UNSUPPORTED_OPERATION",400)}}catch(i){if(c(),i instanceof w||i instanceof g)throw i;const h=i instanceof Error?i.message:String(i),o=s.map((l,f)=>({index:f,error:h}));throw new w(e,0,s.length,o,{resource:t,originalError:i})}}normalizeQueryResult(t,e){if(Array.isArray(t))return{data:t,total:t.length,page:1,pageSize:t.length,hasMore:!1};const s=t,n=s.records||s.value||[],r=s.total??s.count??n.length;return{data:n,total:r,page:e?.$skip&&e.$top?Math.floor(e.$skip/e.$top)+1:1,pageSize:e?.$top,hasMore:e?.$top?n.length===e.$top:!1}}async rawFindWithPopulate(t,e){const s=new URLSearchParams;if(e.$expand&&e.$expand.length>0&&s.set("populate",e.$expand.join(",")),e.$top!==void 0&&s.set("top",String(e.$top)),e.$skip!==void 0&&s.set("skip",String(e.$skip)),e.$select&&e.$select.length>0&&s.set("select",e.$select.join(",")),e.$orderby)if(Array.isArray(e.$orderby)){const f=e.$orderby.map(d=>{if(typeof d=="string")return d;const m=d.field;return(d.order||"asc")==="desc"?`-${m}`:m}).join(",");s.set("sort",f)}else{const f=Object.entries(e.$orderby).map(([d,m])=>m==="desc"?`-${d}`:d).join(",");s.set("sort",f)}e.$filter&&s.set("filter",JSON.stringify(e.$filter));const n=this.baseUrl.replace(/\/$/,""),r=s.toString(),c=/\/api\/v\d+$/i.test(n)?"/data":"/api/v1/data",i=`${n}${c}/${t}${r?`?${r}`:""}`,h={"Content-Type":"application/json"};this.token&&(h.Authorization=`Bearer ${this.token}`);const o=await this.fetchImpl(i,{method:"GET",headers:h});if(!o.ok){const f=await o.json().catch(()=>({message:o.statusText})),d=new Error(f?.error?.message||f?.message||o.statusText);throw d.status=o.status,d}const l=await o.json();return l&&typeof l.success=="boolean"&&"data"in l?l.data:l}convertQueryParams(t){if(!t)return{};const e={};if(t.$select&&(e.select=t.$select),t.$filter&&(Array.isArray(t.$filter)?e.filters=t.$filter:e.filters=A(t.$filter)),t.$orderby)if(Array.isArray(t.$orderby))e.sort=t.$orderby.map(s=>{if(typeof s=="string")return s;const n=s.field;return(s.order||"asc")==="desc"?`-${n}`:n});else{const s=Object.entries(t.$orderby).map(([n,r])=>r==="desc"?`-${n}`:n);e.sort=s}return t.$skip!==void 0&&(e.skip=t.$skip),t.$top!==void 0&&(e.top=t.$top),e}async getObjectSchema(t){await this.connect();try{return await this.metadataCache.get(t,async()=>{const s=await this.client.meta.getItem("object",t);return s&&s.item?s.item:s})}catch(e){const s=e;throw s?.status===404||s?.statusCode===404?new $(t,{originalError:e}):e instanceof g?e:C(s,`getObjectSchema(${t})`)}}getClient(){return this.client}async getDiscovery(){try{return await this.connect(),this.client.discoveryInfo||null}catch{return null}}async getView(t,e){await this.connect();try{const s=`view:${t}:${e}`;return await this.metadataCache.get(s,async()=>{const n=await this.client.meta.getItem(t,`views/${e}`);return n&&n.item?n.item:n??null})}catch{return null}}async getApp(t){await this.connect();try{const e=`app:${t}`;return await this.metadataCache.get(e,async()=>{const s=await this.client.meta.getItem("apps",t);return s&&s.item?s.item:s??null})}catch{return null}}async getPage(t){await this.connect();try{const e=`page:${t}`;return await this.metadataCache.get(e,async()=>{const s=await this.client.meta.getItem("pages",t);return s&&s.item?s.item:s??null})}catch{return null}}async aggregate(t,e){await this.connect();try{const s={object:t,measures:[{field:e.field,function:e.function}],dimensions:[e.groupBy]};e.filter&&(s.filters=e.filter);const n=await this.client.analytics.query(s);return Array.isArray(n)?n:n?.data&&Array.isArray(n.data)?n.data:n?.results&&Array.isArray(n.results)?n.results:[]}catch{const n=(await this.find(t)).data||[];return n.length===0?[]:this.aggregateClientSide(n,e)}}aggregateClientSide(t,e){const{field:s,function:n,groupBy:r}=e,a={};for(const c of t){const i=String(c[r]??"Unknown");a[i]||(a[i]=[]),a[i].push(c)}return Object.entries(a).map(([c,i])=>{const h=i.map(l=>Number(l[s])||0);let o;switch(n){case"count":o=i.length;break;case"avg":o=h.length>0?h.reduce((l,f)=>l+f,0)/h.length:0;break;case"min":o=h.length>0?Math.min(...h):0;break;case"max":o=h.length>0?Math.max(...h):0;break;case"sum":default:o=h.reduce((l,f)=>l+f,0);break}return{[r]:c,[s]:o}})}async getItems(t,e){return await this.connect(),await Promise.all(e.map(async n=>{const r=`${t}:${n}`;return this.metadataCache.get(r,async()=>{const a=await this.client.meta.getItem(t,n);return a&&a.item?a.item:a})}))}getCached(t){return this.metadataCache.getCachedSync(t)}getCacheStats(){return this.metadataCache.getStats()}invalidateCache(t){this.metadataCache.invalidate(t)}clearCache(){this.metadataCache.clear()}async uploadFile(t,e,s){await this.connect();const n=new FormData;n.append("file",e),s?.recordId&&n.append("recordId",s.recordId),s?.fieldName&&n.append("fieldName",s.fieldName),s?.metadata&&n.append("metadata",JSON.stringify(s.metadata));const r=`${this.baseUrl}/api/data/${encodeURIComponent(t)}/upload`,a=await fetch(r,{method:"POST",body:n,headers:{...this.getAuthHeaders()}});if(!a.ok){const c=await a.json().catch(()=>({message:a.statusText}));throw new g(c.message||`Upload failed with status ${a.status}`,"UPLOAD_ERROR",a.status)}return a.json()}async uploadFiles(t,e,s){await this.connect();const n=new FormData;e.forEach((c,i)=>{n.append("files",c,c.name||`file-${i}`)}),s?.recordId&&n.append("recordId",s.recordId),s?.fieldName&&n.append("fieldName",s.fieldName),s?.metadata&&n.append("metadata",JSON.stringify(s.metadata));const r=`${this.baseUrl}/api/data/${encodeURIComponent(t)}/upload`,a=await fetch(r,{method:"POST",body:n,headers:{...this.getAuthHeaders()}});if(!a.ok){const c=await a.json().catch(()=>({message:a.statusText}));throw new g(c.message||`Upload failed with status ${a.status}`,"UPLOAD_ERROR",a.status)}return a.json()}getAuthHeaders(){const t={};return this.token&&(t.Authorization=`Bearer ${this.token}`),t}}export{k as O};
|