@ram_28/kf-ai-sdk 2.0.9 → 2.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 (43) hide show
  1. package/dist/api.cjs +1 -1
  2. package/dist/api.mjs +1 -1
  3. package/dist/auth.cjs +1 -1
  4. package/dist/auth.mjs +1 -1
  5. package/dist/bdo.cjs +1 -1
  6. package/dist/bdo.mjs +1 -1
  7. package/dist/{constants-CYJih7y4.js → constants-ConHc1oS.js} +5 -3
  8. package/dist/constants-QX2RX-wu.cjs +1 -0
  9. package/dist/filter.cjs +1 -1
  10. package/dist/filter.mjs +1 -1
  11. package/dist/form.cjs +1 -1
  12. package/dist/form.mjs +1 -1
  13. package/dist/table.cjs +1 -1
  14. package/dist/table.mjs +1 -1
  15. package/dist/types/constants.d.ts +5 -3
  16. package/dist/types/constants.d.ts.map +1 -1
  17. package/dist/workflow/components/useActivityTable/index.d.ts +4 -0
  18. package/dist/workflow/components/useActivityTable/index.d.ts.map +1 -0
  19. package/dist/workflow/components/useActivityTable/types.d.ts +53 -0
  20. package/dist/workflow/components/useActivityTable/types.d.ts.map +1 -0
  21. package/dist/workflow/components/useActivityTable/useActivityTable.d.ts +4 -0
  22. package/dist/workflow/components/useActivityTable/useActivityTable.d.ts.map +1 -0
  23. package/dist/workflow/types.d.ts +2 -3
  24. package/dist/workflow/types.d.ts.map +1 -1
  25. package/dist/workflow.cjs +1 -1
  26. package/dist/workflow.d.ts +2 -0
  27. package/dist/workflow.d.ts.map +1 -1
  28. package/dist/workflow.mjs +274 -204
  29. package/dist/workflow.types.d.ts +1 -0
  30. package/dist/workflow.types.d.ts.map +1 -1
  31. package/docs/api.md +1 -1
  32. package/docs/useFilter.md +279 -6
  33. package/docs/workflow.md +155 -10
  34. package/package.json +1 -1
  35. package/sdk/components/hooks/useFilter/useFilter.llm.txt +73 -4
  36. package/sdk/types/constants.ts +5 -3
  37. package/sdk/workflow/components/useActivityTable/index.ts +8 -0
  38. package/sdk/workflow/components/useActivityTable/types.ts +67 -0
  39. package/sdk/workflow/components/useActivityTable/useActivityTable.ts +145 -0
  40. package/sdk/workflow/types.ts +2 -3
  41. package/sdk/workflow.ts +7 -0
  42. package/sdk/workflow.types.ts +7 -0
  43. package/dist/constants-D0J69if5.cjs +0 -1
package/dist/api.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./client-BnVxSHAm.cjs"),u=require("./metadata-BfJtHz84.cjs"),o=require("./constants-D0J69if5.cjs"),p={DATE:"%Y-%m-%d",TIME:"%H:%M:%S",DATE_TIME:"%Y-%m-%d %H:%M:%S"};function D(t){const[e,a,r]=t.$__d__.split("-").map(Number);return new Date(e,a-1,r)}function g(t){return new Date(t.$__dt__*1e3)}function l(t){const e=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${a}-${r}`}function S(t){const e=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),c=String(t.getSeconds()).padStart(2,"0");return`${e}-${a}-${r} ${s}:${i}:${c}`}function y(t){const[e,a,r]=t.split("-").map(Number);return new Date(e,a-1,r)}function f(t){const[e,a]=t.split(" "),[r,s,i]=e.split("-").map(Number),[c,d,m]=a.split(":").map(Number);return new Date(r,s-1,i,c,d,m)}exports.api=n.api;exports.getApiBaseUrl=n.getApiBaseUrl;exports.getDefaultHeaders=n.getDefaultHeaders;exports.setApiBaseUrl=n.setApiBaseUrl;exports.setDefaultHeaders=n.setDefaultHeaders;exports.getBdoSchema=u.getBdoSchema;exports.listMetadata=u.listMetadata;exports.DateEncodingKey=o.DateEncodingKey;exports.DeleteStatus=o.DeleteStatus;exports.HttpMethod=o.HttpMethod;exports.MetricType=o.MetricType;exports.QueryType=o.QueryType;exports.DatetimeFormat=p;exports.decodeDate=D;exports.decodeDateTime=g;exports.formatDate=l;exports.formatDateTime=S;exports.parseDate=y;exports.parseDateTime=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./client-BnVxSHAm.cjs"),u=require("./metadata-BfJtHz84.cjs"),o=require("./constants-QX2RX-wu.cjs"),p={DATE:"%Y-%m-%d",TIME:"%H:%M:%S",DATE_TIME:"%Y-%m-%d %H:%M:%S"};function D(t){const[e,a,r]=t.$__d__.split("-").map(Number);return new Date(e,a-1,r)}function g(t){return new Date(t.$__dt__*1e3)}function l(t){const e=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${a}-${r}`}function S(t){const e=t.getFullYear(),a=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),c=String(t.getSeconds()).padStart(2,"0");return`${e}-${a}-${r} ${s}:${i}:${c}`}function y(t){const[e,a,r]=t.split("-").map(Number);return new Date(e,a-1,r)}function f(t){const[e,a]=t.split(" "),[r,s,i]=e.split("-").map(Number),[c,d,m]=a.split(":").map(Number);return new Date(r,s-1,i,c,d,m)}exports.api=n.api;exports.getApiBaseUrl=n.getApiBaseUrl;exports.getDefaultHeaders=n.getDefaultHeaders;exports.setApiBaseUrl=n.setApiBaseUrl;exports.setDefaultHeaders=n.setDefaultHeaders;exports.getBdoSchema=u.getBdoSchema;exports.listMetadata=u.listMetadata;exports.DateEncodingKey=o.DateEncodingKey;exports.DeleteStatus=o.DeleteStatus;exports.HttpMethod=o.HttpMethod;exports.MetricType=o.MetricType;exports.QueryType=o.QueryType;exports.DatetimeFormat=p;exports.decodeDate=D;exports.decodeDateTime=g;exports.formatDate=l;exports.formatDateTime=S;exports.parseDate=y;exports.parseDateTime=f;
package/dist/api.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as f, c as h, g as M, s as $, b as T } from "./client-CMERmrC-.js";
2
2
  import { g as H, l as b } from "./metadata-CwAo6a8e.js";
3
- import { a as w, b as x, H as A, M as N, Q as Y } from "./constants-CYJih7y4.js";
3
+ import { a as w, b as x, H as A, M as N, Q as Y } from "./constants-ConHc1oS.js";
4
4
  const m = {
5
5
  /** Date format: "YYYY-MM-DD" */
6
6
  DATE: "%Y-%m-%d",
package/dist/auth.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var J=Object.defineProperty;var X=(e,t,n)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var M=(e,t,n)=>X(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),r=require("react"),N=require("@tanstack/react-query"),L=require("./client-BnVxSHAm.cjs"),W=require("./constants-D0J69if5.cjs"),H={sessionEndpoint:"/api/id",providers:{google:{loginPath:"/api/auth/google/login",logoutPath:"/api/auth/logout"}},defaultProvider:"google",autoRedirect:!1,sessionCheckInterval:0,retry:{count:3,delay:1e3},staleTime:5*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!0};let h={...H};function Y(e){h={...h,...e,providers:{...h.providers,...e.providers},retry:{...h.retry,...e.retry}}}function Z(e,t){h.providers[e]=t}function b(){return{...h}}function k(){return h.baseUrl||L.getApiBaseUrl()||(typeof window<"u"?window.location.origin:"")}function G(e){return h.providers[e]}function D(){h={...H}}class E extends Error{constructor(n,o){super(n);M(this,"statusCode");this.name="AuthenticationError",this.statusCode=o}}async function ee(){const e=b(),t=k(),n=L.getDefaultHeaders(),o=await fetch(`${t}${e.sessionEndpoint}`,{method:"GET",headers:n,credentials:"include"});if(!o.ok)throw o.status===401||o.status===403?new E("Not authenticated",o.status):new E(`Session check failed: ${o.statusText}`,o.status);return await o.json()}function _(e,t){return new Promise(()=>{const n=b(),o=k();if(!o)throw new Error('Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.');const u=e||n.defaultProvider,c=G(u);if(!c){const A=Object.keys(n.providers||{}).join(", ")||"none";throw new Error(`Auth provider "${u}" is not configured. Available providers: ${A}`)}if(!c.loginPath)throw new Error(`Login path not configured for provider "${u}". Configure it with: configureAuth({ providers: { ${u}: { loginPath: '/api/auth/...' } } })`);let f;try{f=new URL(`${o}${c.loginPath}`)}catch{throw new Error(`Failed to construct login URL. Base URL: "${o}", Login path: "${c.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`)}(t!=null&&t.callbackUrl||n.callbackUrl)&&f.searchParams.set("callbackUrl",(t==null?void 0:t.callbackUrl)||n.callbackUrl||window.location.href),t!=null&&t.params&&Object.entries(t.params).forEach(([A,v])=>{f.searchParams.set(A,v)}),window.open(f.toString(),"_blank")})}async function te(e){const t=b(),n=k(),o=L.getDefaultHeaders(),u=G(t.defaultProvider),c=u==null?void 0:u.logoutPath;if(c&&(e==null?void 0:e.callLogoutEndpoint)!==!1)try{await fetch(`${n}${c}`,{method:"POST",headers:o,credentials:"include"})}catch(f){console.warn("Logout endpoint call failed:",f)}e!=null&&e.redirectUrl?window.location.href=e.redirectUrl:t.loginRedirectUrl&&(window.location.href=t.loginRedirectUrl)}const V=r.createContext(null),K=["auth","session"];function re({children:e,config:t,onAuthChange:n,onError:o,loadingComponent:u,unauthenticatedComponent:c,skipInitialCheck:f=!1}){const A=r.useRef(!1);t&&!A.current&&(Y(t),A.current=!0);const v=N.useQueryClient(),l=b(),{data:a,isLoading:g,error:U,refetch:R,isFetching:P}=N.useQuery({queryKey:K,queryFn:ee,enabled:!f,retry:(s,w)=>w instanceof E&&(w.statusCode===401||w.statusCode===403)?!1:s<l.retry.count,retryDelay:l.retry.delay,staleTime:l.staleTime,gcTime:l.staleTime*2,refetchOnWindowFocus:l.refetchOnWindowFocus??!0,refetchOnReconnect:l.refetchOnReconnect??!0,refetchInterval:l.sessionCheckInterval||!1}),[x,S]=r.useState(null),d=r.useMemo(()=>g||P?"loading":Object.keys((a==null?void 0:a.userDetails)||{}).length>0?"authenticated":"unauthenticated",[g,P,a]),i=(a==null?void 0:a.userDetails)||null,$=(a==null?void 0:a.staticBaseUrl)||null,O=(a==null?void 0:a.buildId)||null,j=d==="authenticated",C=r.useRef(n);C.current=n;const m=r.useRef(o);m.current=o,r.useEffect(()=>{var s;g||(s=C.current)==null||s.call(C,d,i)},[d,i,g]),r.useEffect(()=>{var s;U&&(S(U),(s=m.current)==null||s.call(m,U))},[U]),r.useEffect(()=>{d==="unauthenticated"&&l.autoRedirect&&!g&&_()},[d,g,l.autoRedirect]);const p=r.useCallback((s,w)=>{_(s,w)},[]),q=r.useCallback(async s=>{v.removeQueries({queryKey:K}),await te(s)},[v]),B=r.useCallback(async()=>{if(P)return a||null;try{return(await R()).data||null}catch(s){return S(s),null}},[R,P,a]),I=r.useCallback(s=>(i==null?void 0:i.Role)===s,[i]),T=r.useCallback(s=>s.includes((i==null?void 0:i.Role)||""),[i]),F=r.useCallback(()=>{S(null)},[]),Q=r.useCallback(()=>{R()},[R]),z=r.useMemo(()=>({user:i,staticBaseUrl:$,buildId:O,status:d,isAuthenticated:j,isLoading:g,login:p,logout:q,refreshSession:B,hasRole:I,hasAnyRole:T,error:x,clearError:F,_forceCheck:Q}),[i,$,O,d,j,g,p,q,B,I,T,x,F,Q]);return d==="loading"&&u?y.jsx(y.Fragment,{children:u}):d==="unauthenticated"&&!l.autoRedirect&&c?y.jsx(y.Fragment,{children:c}):y.jsx(V.Provider,{value:z,children:e})}function ne(){const e=r.useContext(V);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function oe(){const e=ne();return r.useMemo(()=>({user:e.user,staticBaseUrl:e.staticBaseUrl,buildId:e.buildId,status:e.status,isAuthenticated:e.isAuthenticated,isLoading:e.isLoading,login:e.login,logout:e.logout,refreshSession:e.refreshSession,hasRole:e.hasRole,hasAnyRole:e.hasAnyRole,error:e.error,clearError:e.clearError}),[e.user,e.staticBaseUrl,e.buildId,e.status,e.isAuthenticated,e.isLoading,e.login,e.logout,e.refreshSession,e.hasRole,e.hasAnyRole,e.error,e.clearError])}exports.AuthProviderName=W.AuthProviderName;exports.AuthStatus=W.AuthStatus;exports.AuthProvider=re;exports.AuthenticationError=E;exports.configureAuth=Y;exports.getAuthBaseUrl=k;exports.getAuthConfig=b;exports.resetAuthConfig=D;exports.setAuthProvider=Z;exports.useAuth=oe;
1
+ "use strict";var J=Object.defineProperty;var X=(e,t,n)=>t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var M=(e,t,n)=>X(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react/jsx-runtime"),r=require("react"),N=require("@tanstack/react-query"),L=require("./client-BnVxSHAm.cjs"),W=require("./constants-QX2RX-wu.cjs"),H={sessionEndpoint:"/api/id",providers:{google:{loginPath:"/api/auth/google/login",logoutPath:"/api/auth/logout"}},defaultProvider:"google",autoRedirect:!1,sessionCheckInterval:0,retry:{count:3,delay:1e3},staleTime:5*60*1e3,refetchOnWindowFocus:!1,refetchOnReconnect:!0};let h={...H};function Y(e){h={...h,...e,providers:{...h.providers,...e.providers},retry:{...h.retry,...e.retry}}}function Z(e,t){h.providers[e]=t}function b(){return{...h}}function k(){return h.baseUrl||L.getApiBaseUrl()||(typeof window<"u"?window.location.origin:"")}function G(e){return h.providers[e]}function D(){h={...H}}class E extends Error{constructor(n,o){super(n);M(this,"statusCode");this.name="AuthenticationError",this.statusCode=o}}async function ee(){const e=b(),t=k(),n=L.getDefaultHeaders(),o=await fetch(`${t}${e.sessionEndpoint}`,{method:"GET",headers:n,credentials:"include"});if(!o.ok)throw o.status===401||o.status===403?new E("Not authenticated",o.status):new E(`Session check failed: ${o.statusText}`,o.status);return await o.json()}function _(e,t){return new Promise(()=>{const n=b(),o=k();if(!o)throw new Error('Auth base URL is not configured. Call setApiBaseUrl("https://...") or configureAuth({ baseUrl: "https://..." }) first.');const u=e||n.defaultProvider,c=G(u);if(!c){const A=Object.keys(n.providers||{}).join(", ")||"none";throw new Error(`Auth provider "${u}" is not configured. Available providers: ${A}`)}if(!c.loginPath)throw new Error(`Login path not configured for provider "${u}". Configure it with: configureAuth({ providers: { ${u}: { loginPath: '/api/auth/...' } } })`);let f;try{f=new URL(`${o}${c.loginPath}`)}catch{throw new Error(`Failed to construct login URL. Base URL: "${o}", Login path: "${c.loginPath}". Ensure baseUrl is a valid URL (e.g., "https://example.com").`)}(t!=null&&t.callbackUrl||n.callbackUrl)&&f.searchParams.set("callbackUrl",(t==null?void 0:t.callbackUrl)||n.callbackUrl||window.location.href),t!=null&&t.params&&Object.entries(t.params).forEach(([A,v])=>{f.searchParams.set(A,v)}),window.open(f.toString(),"_blank")})}async function te(e){const t=b(),n=k(),o=L.getDefaultHeaders(),u=G(t.defaultProvider),c=u==null?void 0:u.logoutPath;if(c&&(e==null?void 0:e.callLogoutEndpoint)!==!1)try{await fetch(`${n}${c}`,{method:"POST",headers:o,credentials:"include"})}catch(f){console.warn("Logout endpoint call failed:",f)}e!=null&&e.redirectUrl?window.location.href=e.redirectUrl:t.loginRedirectUrl&&(window.location.href=t.loginRedirectUrl)}const V=r.createContext(null),K=["auth","session"];function re({children:e,config:t,onAuthChange:n,onError:o,loadingComponent:u,unauthenticatedComponent:c,skipInitialCheck:f=!1}){const A=r.useRef(!1);t&&!A.current&&(Y(t),A.current=!0);const v=N.useQueryClient(),l=b(),{data:a,isLoading:g,error:U,refetch:R,isFetching:P}=N.useQuery({queryKey:K,queryFn:ee,enabled:!f,retry:(s,w)=>w instanceof E&&(w.statusCode===401||w.statusCode===403)?!1:s<l.retry.count,retryDelay:l.retry.delay,staleTime:l.staleTime,gcTime:l.staleTime*2,refetchOnWindowFocus:l.refetchOnWindowFocus??!0,refetchOnReconnect:l.refetchOnReconnect??!0,refetchInterval:l.sessionCheckInterval||!1}),[x,S]=r.useState(null),d=r.useMemo(()=>g||P?"loading":Object.keys((a==null?void 0:a.userDetails)||{}).length>0?"authenticated":"unauthenticated",[g,P,a]),i=(a==null?void 0:a.userDetails)||null,$=(a==null?void 0:a.staticBaseUrl)||null,O=(a==null?void 0:a.buildId)||null,j=d==="authenticated",C=r.useRef(n);C.current=n;const m=r.useRef(o);m.current=o,r.useEffect(()=>{var s;g||(s=C.current)==null||s.call(C,d,i)},[d,i,g]),r.useEffect(()=>{var s;U&&(S(U),(s=m.current)==null||s.call(m,U))},[U]),r.useEffect(()=>{d==="unauthenticated"&&l.autoRedirect&&!g&&_()},[d,g,l.autoRedirect]);const p=r.useCallback((s,w)=>{_(s,w)},[]),q=r.useCallback(async s=>{v.removeQueries({queryKey:K}),await te(s)},[v]),B=r.useCallback(async()=>{if(P)return a||null;try{return(await R()).data||null}catch(s){return S(s),null}},[R,P,a]),I=r.useCallback(s=>(i==null?void 0:i.Role)===s,[i]),T=r.useCallback(s=>s.includes((i==null?void 0:i.Role)||""),[i]),F=r.useCallback(()=>{S(null)},[]),Q=r.useCallback(()=>{R()},[R]),z=r.useMemo(()=>({user:i,staticBaseUrl:$,buildId:O,status:d,isAuthenticated:j,isLoading:g,login:p,logout:q,refreshSession:B,hasRole:I,hasAnyRole:T,error:x,clearError:F,_forceCheck:Q}),[i,$,O,d,j,g,p,q,B,I,T,x,F,Q]);return d==="loading"&&u?y.jsx(y.Fragment,{children:u}):d==="unauthenticated"&&!l.autoRedirect&&c?y.jsx(y.Fragment,{children:c}):y.jsx(V.Provider,{value:z,children:e})}function ne(){const e=r.useContext(V);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function oe(){const e=ne();return r.useMemo(()=>({user:e.user,staticBaseUrl:e.staticBaseUrl,buildId:e.buildId,status:e.status,isAuthenticated:e.isAuthenticated,isLoading:e.isLoading,login:e.login,logout:e.logout,refreshSession:e.refreshSession,hasRole:e.hasRole,hasAnyRole:e.hasAnyRole,error:e.error,clearError:e.clearError}),[e.user,e.staticBaseUrl,e.buildId,e.status,e.isAuthenticated,e.isLoading,e.login,e.logout,e.refreshSession,e.hasRole,e.hasAnyRole,e.error,e.clearError])}exports.AuthProviderName=W.AuthProviderName;exports.AuthStatus=W.AuthStatus;exports.AuthProvider=re;exports.AuthenticationError=E;exports.configureAuth=Y;exports.getAuthBaseUrl=k;exports.getAuthConfig=b;exports.resetAuthConfig=D;exports.setAuthProvider=Z;exports.useAuth=oe;
package/dist/auth.mjs CHANGED
@@ -5,7 +5,7 @@ import { jsx as C, Fragment as W } from "react/jsx-runtime";
5
5
  import { useRef as p, useState as D, useMemo as k, useEffect as L, useCallback as g, createContext as ee, useContext as te } from "react";
6
6
  import { useQueryClient as re, useQuery as ne } from "@tanstack/react-query";
7
7
  import { c as oe, g as H } from "./client-CMERmrC-.js";
8
- import { c as me, A as be } from "./constants-CYJih7y4.js";
8
+ import { c as me, A as be } from "./constants-ConHc1oS.js";
9
9
  const M = {
10
10
  sessionEndpoint: "/api/id",
11
11
  providers: {
package/dist/bdo.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var U=Object.defineProperty;var B=(r,e,t)=>e in r?U(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>B(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./client-BnVxSHAm.cjs"),m=require("./BaseField-Drp0-OxL.cjs"),C=require("./constants-D0J69if5.cjs"),D=new Set(["jpg","jpeg","png","gif","webp","bmp","tiff","tif","heic","heif"]),M=new Set(["jpg","jpeg","png","gif","webp","bmp","tiff","tif","heic","heif","mp4","mov","avi","webm","mkv","m4v","wmv","flv","pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","zip"]);function x(r){if(!r.includes("."))return"";const e=r.split(".");return(e[e.length-1]??"").toLowerCase()}function S(r,e){const t=x(r),s=e==="Image"?D:M;if(!t||!s.has(t)){const a=[...s].sort().join(", ");throw new Error(`File "${r}" has unsupported extension "${t||"(none)"}". Supported for ${e} fields: ${a}`)}}class w{constructor(e,t){c(this,"_data");c(this,"_bdo");c(this,"_accessorCache",new Map);return this._bdo=e,this._data={...t},new Proxy(this,{get(s,a,i){return a==="validate"||a==="toJSON"||a==="_bdo"||a==="_data"||a==="_accessorCache"||a==="_getAccessor"||a==="_requireInstanceId"||typeof a=="symbol"?Reflect.get(s,a,i):a==="_id"?s._data._id:s._getAccessor(a)},set(s,a,i){return a==="_bdo"||a==="_data"||a==="_accessorCache"||a==="validate"||a==="toJSON"?!1:typeof a=="symbol"?Reflect.set(s,a,i):(s._data[a]=i,!0)},has(s,a){return a==="validate"||a==="toJSON"?!0:a in s._data||a in s._bdo.getFields()},ownKeys(s){return[...Object.keys(s._bdo.getFields()),"validate","toJSON"]},getOwnPropertyDescriptor(s,a){if(a==="validate"||a==="toJSON")return{configurable:!0,enumerable:!1,value:s[a]};const i=s._bdo.getFields();if(a in i||a in s._data)return{configurable:!0,enumerable:!0,get:()=>s._getAccessor(a)}}})}_requireInstanceId(){const e=this._data._id;if(!e)throw new Error("Cannot perform attachment operation: item has no _id. Save the item first.");return e}_getAccessor(e){if(this._accessorCache.has(e))return this._accessorCache.get(e);const s=this._bdo.getFields()[e],a=(s==null?void 0:s.meta)??{_id:e,Name:e,Type:"String"},i=(s==null?void 0:s.readOnly)??!1,u=()=>{if(s){const f=s.validate(this._data[e]);if(!f.valid)return f}return this._bdo.hasMetadata()?this._bdo.validateFieldExpression(e,this._data[e],this.toJSON()):{valid:!0,errors:[]}},h=f=>{const g=this._data[e];return g??f};let p;if(i?p={label:(s==null?void 0:s.label)??e,required:(s==null?void 0:s.required)??!1,readOnly:!0,defaultValue:s==null?void 0:s.defaultValue,meta:a,get:()=>this._data[e],getOrDefault:h,validate:u}:p={label:(s==null?void 0:s.label)??e,required:(s==null?void 0:s.required)??!1,readOnly:!1,defaultValue:s==null?void 0:s.defaultValue,meta:a,get:()=>this._data[e],getOrDefault:h,set:f=>{this._data[e]=f},validate:u},a.Type==="Image"||a.Type==="File"){const f=this._bdo.getBoId(),g=p;a.Type==="Image"?(g.getDownloadUrl=async o=>{const d=this._requireInstanceId(),_=this._data[e];if(!(_!=null&&_._id))throw new Error(`${e} has no image to download`);return n.api(f).getDownloadUrl(d,e,_._id,o)},i||(g.upload=async o=>{S(o.name,"Image");const d=this._requireInstanceId(),_={FileName:o.name,Size:o.size,FileExtension:x(o.name)},[l]=await n.api(f).getUploadUrl(d,e,[_]);await fetch(l.UploadUrl.URL,{method:"PUT",headers:{"Content-Type":l.ContentType},body:o});const v={_id:l._id,_name:l._name,FileName:l.FileName,FileExtension:l.FileExtension,Size:l.Size,ContentType:l.ContentType};return this._data[e]=v,v},g.deleteAttachment=async()=>{const o=this._requireInstanceId(),d=this._data[e];if(!(d!=null&&d._id))throw new Error(`${e} has no image to delete`);await n.api(f).deleteAttachment(o,e,d._id),this._data[e]=null})):(g.getDownloadUrl=async(o,d)=>{const _=this._requireInstanceId();return n.api(f).getDownloadUrl(_,e,o,d)},g.getDownloadUrls=async o=>{const d=this._requireInstanceId();return n.api(f).getDownloadUrls(d,e,o)},i||(g.upload=async o=>{for(const N of o)S(N.name,"File");const d=this._requireInstanceId(),_=o.map(N=>({FileName:N.name,Size:N.size,FileExtension:x(N.name)})),l=await n.api(f).getUploadUrl(d,e,_),v=await Promise.all(o.map(async(N,y)=>(await fetch(l[y].UploadUrl.URL,{method:"PUT",headers:{"Content-Type":l[y].ContentType},body:N}),{_id:l[y]._id,_name:l[y]._name,FileName:l[y].FileName,FileExtension:l[y].FileExtension,Size:l[y].Size,ContentType:l[y].ContentType}))),A=this._data[e]??[];return this._data[e]=[...A,...v],v},g.deleteAttachment=async o=>{const d=this._requireInstanceId();await n.api(f).deleteAttachment(d,e,o);const _=this._data[e]??[];this._data[e]=_.filter(l=>l._id!==o)}))}return this._accessorCache.set(e,p),p}validate(){const e=this._bdo.getFields(),t=[],s=this.toJSON();for(const[a,i]of Object.entries(e)){if(i.readOnly)continue;const u=this._data[a],h=i.validate(u);if(!h.valid){t.push(...h.errors);continue}if(this._bdo.hasMetadata()){const p=this._bdo.validateFieldExpression(a,u,s);p.valid||t.push(...p.errors)}}return{valid:t.length===0,errors:t}}toJSON(){return{...this._data}}}class F extends m.BaseField{constructor(e){super(e)}get length(){var e;return(e=this._meta.Constraint)==null?void 0:e.Length}validate(e){return e!=null&&typeof e!="string"?{valid:!1,errors:[`${this.label} must be a string`]}:{valid:!0,errors:[]}}}class E extends m.BaseField{constructor(e){super(e)}get precision(){var e;return((e=this._meta.Constraint)==null?void 0:e.Precision)??"Second"}validate(e){if(e==null||e==="")return{valid:!0,errors:[]};if(typeof e!="string")return{valid:!1,errors:[`${this.label} must be a valid date string`]};const t=new Date(e);return isNaN(t.getTime())?{valid:!1,errors:[`${this.label} is not a valid date`]}:{valid:!0,errors:[]}}}class T extends m.BaseField{constructor(e){super(e)}get businessEntity(){var e;return(e=this._meta.View)==null?void 0:e.BusinessEntity}validate(e){if(e==null)return{valid:!0,errors:[]};if(typeof e!="object")return{valid:!1,errors:[`${this.label} must be a valid user object`]};const t=e;return!("_id"in t)||typeof t._id!="string"?{valid:!1,errors:[`${this.label} must have a valid _id`]}:{valid:!0,errors:[]}}}const R={CONCAT:(...r)=>r.map(e=>String(e??"")).join(""),UPPER:r=>String(r??"").toUpperCase(),LOWER:r=>String(r??"").toLowerCase(),TRIM:r=>String(r??"").trim(),LENGTH:r=>String(r??"").length,SUBSTRING:(r,e,t)=>String(r??"").substring(e,t!==void 0?e+t:void 0),REPLACE:(r,e,t)=>String(r??"").replace(e,t),SUM:(...r)=>r.reduce((e,t)=>e+(Number(t)||0),0),AVG:(...r)=>{const e=r.filter(t=>t!=null&&!isNaN(Number(t)));return e.length===0?0:e.reduce((t,s)=>t+Number(s),0)/e.length},MIN:(...r)=>{const e=r.filter(t=>t!=null&&!isNaN(Number(t))).map(t=>Number(t));return e.length===0?0:Math.min(...e)},MAX:(...r)=>{const e=r.filter(t=>t!=null&&!isNaN(Number(t))).map(t=>Number(t));return e.length===0?0:Math.max(...e)},ABS:r=>Math.abs(Number(r)||0),ROUND:r=>Math.round(Number(r)||0),FLOOR:r=>Math.floor(Number(r)||0),CEIL:r=>Math.ceil(Number(r)||0),YEAR:r=>{const e=new Date(r);return isNaN(e.getTime())?0:e.getFullYear()},MONTH:r=>{const e=new Date(r);return isNaN(e.getTime())?0:e.getMonth()+1},DAY:r=>{const e=new Date(r);return isNaN(e.getTime())?0:e.getDate()},DATE_DIFF:(r,e)=>{const t=new Date(r),s=new Date(e);if(isNaN(t.getTime())||isNaN(s.getTime()))return 0;const a=Math.abs(t.getTime()-s.getTime());return Math.ceil(a/(1e3*60*60*24))},ADD_DAYS:(r,e)=>{const t=new Date(r);return isNaN(t.getTime())?new Date(NaN):(t.setDate(t.getDate()+e),t)},ADD_MONTHS:(r,e)=>{const t=new Date(r);return isNaN(t.getTime())?new Date(NaN):(t.setMonth(t.getMonth()+e),t)},IF:(r,e,t)=>r?e:t,UUID:()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})};function I(){const r=new Date;return{NOW:r,TODAY:new Date(r.getFullYear(),r.getMonth(),r.getDate()),CURRENT_USER:{Id:"",Email:"",FirstName:"",LastName:""}}}function b(r,e){var t;switch(r.Type){case"Literal":return r.Value;case"Identifier":return e.formValues[r.Name];case"SystemIdentifier":return $(r,e);case"BinaryExpression":return j(r,e);case"LogicalExpression":return V(r,e);case"CallExpression":return P(r,e);case"MemberExpression":return q(r,e);case"AssignmentExpression":return((t=r.Arguments)==null?void 0:t.length)===1?b(r.Arguments[0],e):void 0;default:throw new Error(`Unsupported expression type: ${r.Type}`)}}function $(r,e){const t=r.Name,s=e.systemValues[t];return r.Property?s&&typeof s=="object"?s[r.Property.Name]:void 0:s}function j(r,e){if(!r.Arguments||r.Arguments.length<2)throw new Error("BinaryExpression requires 2 arguments");const[t,s]=r.Arguments,a=b(t,e),i=b(s,e);switch(r.Operator){case"==":return a==i;case"!=":return a!=i;case"<":return Number(a)<Number(i);case"<=":return Number(a)<=Number(i);case">":return Number(a)>Number(i);case">=":return Number(a)>=Number(i);case"+":return Number(a)+Number(i);case"-":return Number(a)-Number(i);case"*":return Number(a)*Number(i);case"/":return Number(i)!==0?Number(a)/Number(i):0;case"%":return Number(a)%Number(i);default:throw new Error(`Unsupported binary operator: ${r.Operator}`)}}function V(r,e){if(!r.Arguments||r.Arguments.length===0)throw new Error("LogicalExpression requires at least 1 argument");const t=r.Arguments;switch(r.Operator){case"AND":return t.every(s=>!!b(s,e));case"OR":return t.some(s=>!!b(s,e));case"!":return!b(t[0],e);default:throw new Error(`Unsupported logical operator: ${r.Operator}`)}}function P(r,e){if(!r.Callee)throw new Error("CallExpression requires a Callee");const t=R[r.Callee];if(!t)throw new Error(`Unknown function: ${r.Callee}`);const s=(r.Arguments??[]).map(a=>b(a,e));return t(...s)}function q(r,e){var a,i;if(!((a=r.Arguments)!=null&&a.length))return;const t=b(r.Arguments[0],e),s=(i=r.Arguments[0].Property)==null?void 0:i.Name;return s&&t&&typeof t=="object"?t[s]:t}class L{constructor(){c(this,"fieldRules",new Map);c(this,"metadata",null)}loadMetadata(e){var t,s;this.metadata=e,this.fieldRules.clear();for(const[a,i]of Object.entries(e.Fields)){const u=[];if(i.Validation&&Array.isArray(i.Validation)){for(const h of i.Validation)if(typeof h=="object"&&h.ExpressionTree)u.push(h);else if(typeof h=="string"){const p=(s=(t=e.Rules)==null?void 0:t.Validation)==null?void 0:s[h];p&&u.push(p)}}u.length>0&&this.fieldRules.set(a,u)}}hasMetadata(){return this.metadata!==null}getFieldRules(e){return this.fieldRules.get(e)??[]}validateField(e,t,s){const a=this.fieldRules.get(e);if(!a||a.length===0)return{valid:!0,errors:[]};const i={formValues:{...s,[e]:t},systemValues:I()};for(const u of a)try{if(!b(u.ExpressionTree,i))return{valid:!1,errors:[u.Message||`Validation failed: ${u.Name||u.Id}`]}}catch(h){console.warn(`Expression evaluation failed for rule ${u.Id}:`,h)}return{valid:!0,errors:[]}}validateAll(e){const t=[];for(const s of this.fieldRules.keys()){const a=this.validateField(s,e[s],e);a.valid||t.push(...a.errors)}return{valid:t.length===0,errors:t}}}class Y{constructor(){c(this,"_id",new F({_id:"_id",Name:"ID",Type:"String",ReadOnly:!0}));c(this,"_created_at",new E({_id:"_created_at",Name:"Created At",Type:"DateTime",ReadOnly:!0}));c(this,"_modified_at",new E({_id:"_modified_at",Name:"Modified At",Type:"DateTime",ReadOnly:!0}));c(this,"_created_by",new T({_id:"_created_by",Name:"Created By",Type:"User",ReadOnly:!0}));c(this,"_modified_by",new T({_id:"_modified_by",Name:"Modified By",Type:"User",ReadOnly:!0}));c(this,"_version",new F({_id:"_version",Name:"Version",Type:"String",ReadOnly:!0}));c(this,"_m_version",new F({_id:"_m_version",Name:"Metadata Version",Type:"String",ReadOnly:!0}));c(this,"_fieldsBound",!1);c(this,"_fieldsCache",null);c(this,"_expressionEngine",new L)}getBoId(){return this.meta._id}getFields(){if(this._fieldsCache)return this._fieldsCache;const e={};for(const t of Object.keys(this)){const s=this[t];s instanceof m.BaseField&&(e[t]=s)}if(!this._fieldsBound){for(const t of Object.values(e))t._parentBoId=this.meta._id;this._fieldsBound=!0}return this._fieldsCache=e,e}loadMetadata(e){this._expressionEngine.loadMetadata(e)}hasMetadata(){return this._expressionEngine.hasMetadata()}validateFieldExpression(e,t,s){return this._expressionEngine.hasMetadata()?this._expressionEngine.validateField(e,t,s):{valid:!0,errors:[]}}async get(e){const t=await n.api(this.meta._id).get(e);return new w(this,t)}async list(e){return(await n.api(this.meta._id).list(e)).Data.map(s=>new w(this,s))}async count(e){return(await n.api(this.meta._id).count(e)).Count}async create(e){const t=await n.api(this.meta._id).create(e);return new w(this,{...e,_id:t._id})}async update(e,t){return n.api(this.meta._id).update(e,t)}async delete(e){return n.api(this.meta._id).delete(e)}async draft(e){return n.api(this.meta._id).draft(e)}async draftInteraction(e){return n.api(this.meta._id).draftInteraction(e)}createItem(e){return new w(this,e??{})}async draftUpdate(e,t){return n.api(this.meta._id).draftUpdate(e,t)}async draftPatch(e,t){return n.api(this.meta._id).draftPatch(e,t)}async metric(e){return n.api(this.meta._id).metric(e)}async pivot(e){return n.api(this.meta._id).pivot(e)}async getUploadUrl(e,t,s){return n.api(this.meta._id).getUploadUrl(e,t,s)}async getDownloadUrl(e,t,s,a){return n.api(this.meta._id).getDownloadUrl(e,t,s,a)}async getDownloadUrls(e,t,s){return n.api(this.meta._id).getDownloadUrls(e,t,s)}async deleteAttachment(e,t,s){return n.api(this.meta._id).deleteAttachment(e,t,s)}}class z extends m.BaseField{constructor(e){super(e)}get integerPart(){var e;return((e=this._meta.Constraint)==null?void 0:e.IntegerPart)??9}get fractionPart(){var e;return(e=this._meta.Constraint)==null?void 0:e.FractionPart}validate(e){return e!=null&&(typeof e!="number"||isNaN(e))?{valid:!1,errors:[`${this.label} must be a valid number`]}:{valid:!0,errors:[]}}}class J extends m.BaseField{constructor(e){super(e)}validate(e){return e!=null&&typeof e!="boolean"?{valid:!1,errors:[`${this.label} must be a boolean`]}:{valid:!0,errors:[]}}}class k extends m.BaseField{constructor(e){super(e)}validate(e){if(e==null||e==="")return{valid:!0,errors:[]};if(typeof e!="string")return{valid:!1,errors:[`${this.label} must be a valid date string`]};if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return{valid:!1,errors:[`${this.label} must be in YYYY-MM-DD format`]};const t=new Date(e+"T00:00:00");return isNaN(t.getTime())?{valid:!1,errors:[`${this.label} is not a valid date`]}:{valid:!0,errors:[]}}}class G extends m.BaseField{constructor(e){super(e)}get options(){var t;return(((t=this._meta.Constraint)==null?void 0:t.Enum)??[]).map(s=>({value:s,label:s}))}validate(e){if(e==null||e==="")return{valid:!0,errors:[]};if(this.options.length===0)return{valid:!0,errors:[]};const t=this.options.map(s=>s.value);return t.includes(e)?{valid:!0,errors:[]}:{valid:!1,errors:[`${this.label} must be one of: ${t.join(", ")}`]}}async fetchOptions(e){if(!this._parentBoId)throw new Error(`Field ${this.id} not bound to a BDO. Cannot fetch options.`);return(await n.api(this._parentBoId).fetchField(e??"new",this.id)).map(s=>({value:s.Value,label:s.Label}))}}class H extends m.BaseField{constructor(e){super(e)}get referenceBdo(){var e,t;return((t=(e=this._meta.View)==null?void 0:e.DataObject)==null?void 0:t.Id)??""}get referenceFields(){var e;return((e=this._meta.View)==null?void 0:e.Fields)??["_id"]}get searchFields(){var e;return((e=this._meta.View)==null?void 0:e.Search)??[]}validate(e){if(e==null)return{valid:!0,errors:[]};if(typeof e!="object")return{valid:!1,errors:[`${this.label} must be a valid reference object`]};const t=e;return!("_id"in t)||typeof t._id!="string"?{valid:!1,errors:[`${this.label} must have a valid _id`]}:{valid:!0,errors:[]}}async fetchOptions(e){if(!this._parentBoId)throw new Error(`Field ${this.id} not bound to a BDO. Cannot fetch options.`);return n.api(this._parentBoId).fetchField(e??"new",this.id)}}class X extends m.BaseField{constructor(e){super(e)}get elementType(){return this._meta.Property}validate(e){return e!=null&&!Array.isArray(e)?{valid:!1,errors:[`${this.label} must be an array`]}:{valid:!0,errors:[]}}}class K extends m.BaseField{constructor(e){super(e)}get properties(){return this._meta.Property}validate(e){return e==null?{valid:!0,errors:[]}:typeof e!="object"||Array.isArray(e)?{valid:!1,errors:[`${this.label} must be a valid object`]}:{valid:!0,errors:[]}}}class O extends m.BaseField{constructor(e){super(e)}get format(){var e;return((e=this._meta.Constraint)==null?void 0:e.Format)??"Plain"}validate(e){return e!=null&&typeof e!="string"?{valid:!1,errors:[`${this.label} must be a string`]}:{valid:!0,errors:[]}}}class W extends m.BaseField{constructor(e){super(e)}validate(e){if(e==null)return{valid:!0,errors:[]};if(!Array.isArray(e))return{valid:!1,errors:[`${this.label} must be an array of file objects`]};for(const t of e)if(!t||typeof t!="object"||!t._id)return{valid:!1,errors:[`Each file in ${this.label} must have an _id`]};return{valid:!0,errors:[]}}}class Q extends m.BaseField{constructor(e){super(e)}validate(e){return e==null?{valid:!0,errors:[]}:typeof e!="object"||Array.isArray(e)?{valid:!1,errors:[`${this.label} must be a valid image object`]}:!e._id||!e.FileName?{valid:!1,errors:[`${this.label} must have _id and FileName`]}:{valid:!0,errors:[]}}}exports.BaseField=m.BaseField;exports.SystemField=C.SystemField;exports.ArrayField=X;exports.BaseBdo=Y;exports.BooleanField=J;exports.DateField=k;exports.DateTimeField=E;exports.FileField=W;exports.ImageField=Q;exports.NumberField=z;exports.ObjectField=K;exports.ReferenceField=H;exports.SelectField=G;exports.StringField=F;exports.TextAreaField=O;exports.TextField=O;exports.UserField=T;
1
+ "use strict";var U=Object.defineProperty;var B=(r,e,t)=>e in r?U(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>B(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./client-BnVxSHAm.cjs"),m=require("./BaseField-Drp0-OxL.cjs"),C=require("./constants-QX2RX-wu.cjs"),D=new Set(["jpg","jpeg","png","gif","webp","bmp","tiff","tif","heic","heif"]),M=new Set(["jpg","jpeg","png","gif","webp","bmp","tiff","tif","heic","heif","mp4","mov","avi","webm","mkv","m4v","wmv","flv","pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","zip"]);function x(r){if(!r.includes("."))return"";const e=r.split(".");return(e[e.length-1]??"").toLowerCase()}function S(r,e){const t=x(r),s=e==="Image"?D:M;if(!t||!s.has(t)){const a=[...s].sort().join(", ");throw new Error(`File "${r}" has unsupported extension "${t||"(none)"}". Supported for ${e} fields: ${a}`)}}class w{constructor(e,t){c(this,"_data");c(this,"_bdo");c(this,"_accessorCache",new Map);return this._bdo=e,this._data={...t},new Proxy(this,{get(s,a,i){return a==="validate"||a==="toJSON"||a==="_bdo"||a==="_data"||a==="_accessorCache"||a==="_getAccessor"||a==="_requireInstanceId"||typeof a=="symbol"?Reflect.get(s,a,i):a==="_id"?s._data._id:s._getAccessor(a)},set(s,a,i){return a==="_bdo"||a==="_data"||a==="_accessorCache"||a==="validate"||a==="toJSON"?!1:typeof a=="symbol"?Reflect.set(s,a,i):(s._data[a]=i,!0)},has(s,a){return a==="validate"||a==="toJSON"?!0:a in s._data||a in s._bdo.getFields()},ownKeys(s){return[...Object.keys(s._bdo.getFields()),"validate","toJSON"]},getOwnPropertyDescriptor(s,a){if(a==="validate"||a==="toJSON")return{configurable:!0,enumerable:!1,value:s[a]};const i=s._bdo.getFields();if(a in i||a in s._data)return{configurable:!0,enumerable:!0,get:()=>s._getAccessor(a)}}})}_requireInstanceId(){const e=this._data._id;if(!e)throw new Error("Cannot perform attachment operation: item has no _id. Save the item first.");return e}_getAccessor(e){if(this._accessorCache.has(e))return this._accessorCache.get(e);const s=this._bdo.getFields()[e],a=(s==null?void 0:s.meta)??{_id:e,Name:e,Type:"String"},i=(s==null?void 0:s.readOnly)??!1,u=()=>{if(s){const f=s.validate(this._data[e]);if(!f.valid)return f}return this._bdo.hasMetadata()?this._bdo.validateFieldExpression(e,this._data[e],this.toJSON()):{valid:!0,errors:[]}},h=f=>{const g=this._data[e];return g??f};let p;if(i?p={label:(s==null?void 0:s.label)??e,required:(s==null?void 0:s.required)??!1,readOnly:!0,defaultValue:s==null?void 0:s.defaultValue,meta:a,get:()=>this._data[e],getOrDefault:h,validate:u}:p={label:(s==null?void 0:s.label)??e,required:(s==null?void 0:s.required)??!1,readOnly:!1,defaultValue:s==null?void 0:s.defaultValue,meta:a,get:()=>this._data[e],getOrDefault:h,set:f=>{this._data[e]=f},validate:u},a.Type==="Image"||a.Type==="File"){const f=this._bdo.getBoId(),g=p;a.Type==="Image"?(g.getDownloadUrl=async o=>{const d=this._requireInstanceId(),_=this._data[e];if(!(_!=null&&_._id))throw new Error(`${e} has no image to download`);return n.api(f).getDownloadUrl(d,e,_._id,o)},i||(g.upload=async o=>{S(o.name,"Image");const d=this._requireInstanceId(),_={FileName:o.name,Size:o.size,FileExtension:x(o.name)},[l]=await n.api(f).getUploadUrl(d,e,[_]);await fetch(l.UploadUrl.URL,{method:"PUT",headers:{"Content-Type":l.ContentType},body:o});const v={_id:l._id,_name:l._name,FileName:l.FileName,FileExtension:l.FileExtension,Size:l.Size,ContentType:l.ContentType};return this._data[e]=v,v},g.deleteAttachment=async()=>{const o=this._requireInstanceId(),d=this._data[e];if(!(d!=null&&d._id))throw new Error(`${e} has no image to delete`);await n.api(f).deleteAttachment(o,e,d._id),this._data[e]=null})):(g.getDownloadUrl=async(o,d)=>{const _=this._requireInstanceId();return n.api(f).getDownloadUrl(_,e,o,d)},g.getDownloadUrls=async o=>{const d=this._requireInstanceId();return n.api(f).getDownloadUrls(d,e,o)},i||(g.upload=async o=>{for(const N of o)S(N.name,"File");const d=this._requireInstanceId(),_=o.map(N=>({FileName:N.name,Size:N.size,FileExtension:x(N.name)})),l=await n.api(f).getUploadUrl(d,e,_),v=await Promise.all(o.map(async(N,y)=>(await fetch(l[y].UploadUrl.URL,{method:"PUT",headers:{"Content-Type":l[y].ContentType},body:N}),{_id:l[y]._id,_name:l[y]._name,FileName:l[y].FileName,FileExtension:l[y].FileExtension,Size:l[y].Size,ContentType:l[y].ContentType}))),A=this._data[e]??[];return this._data[e]=[...A,...v],v},g.deleteAttachment=async o=>{const d=this._requireInstanceId();await n.api(f).deleteAttachment(d,e,o);const _=this._data[e]??[];this._data[e]=_.filter(l=>l._id!==o)}))}return this._accessorCache.set(e,p),p}validate(){const e=this._bdo.getFields(),t=[],s=this.toJSON();for(const[a,i]of Object.entries(e)){if(i.readOnly)continue;const u=this._data[a],h=i.validate(u);if(!h.valid){t.push(...h.errors);continue}if(this._bdo.hasMetadata()){const p=this._bdo.validateFieldExpression(a,u,s);p.valid||t.push(...p.errors)}}return{valid:t.length===0,errors:t}}toJSON(){return{...this._data}}}class F extends m.BaseField{constructor(e){super(e)}get length(){var e;return(e=this._meta.Constraint)==null?void 0:e.Length}validate(e){return e!=null&&typeof e!="string"?{valid:!1,errors:[`${this.label} must be a string`]}:{valid:!0,errors:[]}}}class E extends m.BaseField{constructor(e){super(e)}get precision(){var e;return((e=this._meta.Constraint)==null?void 0:e.Precision)??"Second"}validate(e){if(e==null||e==="")return{valid:!0,errors:[]};if(typeof e!="string")return{valid:!1,errors:[`${this.label} must be a valid date string`]};const t=new Date(e);return isNaN(t.getTime())?{valid:!1,errors:[`${this.label} is not a valid date`]}:{valid:!0,errors:[]}}}class T extends m.BaseField{constructor(e){super(e)}get businessEntity(){var e;return(e=this._meta.View)==null?void 0:e.BusinessEntity}validate(e){if(e==null)return{valid:!0,errors:[]};if(typeof e!="object")return{valid:!1,errors:[`${this.label} must be a valid user object`]};const t=e;return!("_id"in t)||typeof t._id!="string"?{valid:!1,errors:[`${this.label} must have a valid _id`]}:{valid:!0,errors:[]}}}const R={CONCAT:(...r)=>r.map(e=>String(e??"")).join(""),UPPER:r=>String(r??"").toUpperCase(),LOWER:r=>String(r??"").toLowerCase(),TRIM:r=>String(r??"").trim(),LENGTH:r=>String(r??"").length,SUBSTRING:(r,e,t)=>String(r??"").substring(e,t!==void 0?e+t:void 0),REPLACE:(r,e,t)=>String(r??"").replace(e,t),SUM:(...r)=>r.reduce((e,t)=>e+(Number(t)||0),0),AVG:(...r)=>{const e=r.filter(t=>t!=null&&!isNaN(Number(t)));return e.length===0?0:e.reduce((t,s)=>t+Number(s),0)/e.length},MIN:(...r)=>{const e=r.filter(t=>t!=null&&!isNaN(Number(t))).map(t=>Number(t));return e.length===0?0:Math.min(...e)},MAX:(...r)=>{const e=r.filter(t=>t!=null&&!isNaN(Number(t))).map(t=>Number(t));return e.length===0?0:Math.max(...e)},ABS:r=>Math.abs(Number(r)||0),ROUND:r=>Math.round(Number(r)||0),FLOOR:r=>Math.floor(Number(r)||0),CEIL:r=>Math.ceil(Number(r)||0),YEAR:r=>{const e=new Date(r);return isNaN(e.getTime())?0:e.getFullYear()},MONTH:r=>{const e=new Date(r);return isNaN(e.getTime())?0:e.getMonth()+1},DAY:r=>{const e=new Date(r);return isNaN(e.getTime())?0:e.getDate()},DATE_DIFF:(r,e)=>{const t=new Date(r),s=new Date(e);if(isNaN(t.getTime())||isNaN(s.getTime()))return 0;const a=Math.abs(t.getTime()-s.getTime());return Math.ceil(a/(1e3*60*60*24))},ADD_DAYS:(r,e)=>{const t=new Date(r);return isNaN(t.getTime())?new Date(NaN):(t.setDate(t.getDate()+e),t)},ADD_MONTHS:(r,e)=>{const t=new Date(r);return isNaN(t.getTime())?new Date(NaN):(t.setMonth(t.getMonth()+e),t)},IF:(r,e,t)=>r?e:t,UUID:()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})};function I(){const r=new Date;return{NOW:r,TODAY:new Date(r.getFullYear(),r.getMonth(),r.getDate()),CURRENT_USER:{Id:"",Email:"",FirstName:"",LastName:""}}}function b(r,e){var t;switch(r.Type){case"Literal":return r.Value;case"Identifier":return e.formValues[r.Name];case"SystemIdentifier":return $(r,e);case"BinaryExpression":return j(r,e);case"LogicalExpression":return V(r,e);case"CallExpression":return P(r,e);case"MemberExpression":return q(r,e);case"AssignmentExpression":return((t=r.Arguments)==null?void 0:t.length)===1?b(r.Arguments[0],e):void 0;default:throw new Error(`Unsupported expression type: ${r.Type}`)}}function $(r,e){const t=r.Name,s=e.systemValues[t];return r.Property?s&&typeof s=="object"?s[r.Property.Name]:void 0:s}function j(r,e){if(!r.Arguments||r.Arguments.length<2)throw new Error("BinaryExpression requires 2 arguments");const[t,s]=r.Arguments,a=b(t,e),i=b(s,e);switch(r.Operator){case"==":return a==i;case"!=":return a!=i;case"<":return Number(a)<Number(i);case"<=":return Number(a)<=Number(i);case">":return Number(a)>Number(i);case">=":return Number(a)>=Number(i);case"+":return Number(a)+Number(i);case"-":return Number(a)-Number(i);case"*":return Number(a)*Number(i);case"/":return Number(i)!==0?Number(a)/Number(i):0;case"%":return Number(a)%Number(i);default:throw new Error(`Unsupported binary operator: ${r.Operator}`)}}function V(r,e){if(!r.Arguments||r.Arguments.length===0)throw new Error("LogicalExpression requires at least 1 argument");const t=r.Arguments;switch(r.Operator){case"AND":return t.every(s=>!!b(s,e));case"OR":return t.some(s=>!!b(s,e));case"!":return!b(t[0],e);default:throw new Error(`Unsupported logical operator: ${r.Operator}`)}}function P(r,e){if(!r.Callee)throw new Error("CallExpression requires a Callee");const t=R[r.Callee];if(!t)throw new Error(`Unknown function: ${r.Callee}`);const s=(r.Arguments??[]).map(a=>b(a,e));return t(...s)}function q(r,e){var a,i;if(!((a=r.Arguments)!=null&&a.length))return;const t=b(r.Arguments[0],e),s=(i=r.Arguments[0].Property)==null?void 0:i.Name;return s&&t&&typeof t=="object"?t[s]:t}class L{constructor(){c(this,"fieldRules",new Map);c(this,"metadata",null)}loadMetadata(e){var t,s;this.metadata=e,this.fieldRules.clear();for(const[a,i]of Object.entries(e.Fields)){const u=[];if(i.Validation&&Array.isArray(i.Validation)){for(const h of i.Validation)if(typeof h=="object"&&h.ExpressionTree)u.push(h);else if(typeof h=="string"){const p=(s=(t=e.Rules)==null?void 0:t.Validation)==null?void 0:s[h];p&&u.push(p)}}u.length>0&&this.fieldRules.set(a,u)}}hasMetadata(){return this.metadata!==null}getFieldRules(e){return this.fieldRules.get(e)??[]}validateField(e,t,s){const a=this.fieldRules.get(e);if(!a||a.length===0)return{valid:!0,errors:[]};const i={formValues:{...s,[e]:t},systemValues:I()};for(const u of a)try{if(!b(u.ExpressionTree,i))return{valid:!1,errors:[u.Message||`Validation failed: ${u.Name||u.Id}`]}}catch(h){console.warn(`Expression evaluation failed for rule ${u.Id}:`,h)}return{valid:!0,errors:[]}}validateAll(e){const t=[];for(const s of this.fieldRules.keys()){const a=this.validateField(s,e[s],e);a.valid||t.push(...a.errors)}return{valid:t.length===0,errors:t}}}class Y{constructor(){c(this,"_id",new F({_id:"_id",Name:"ID",Type:"String",ReadOnly:!0}));c(this,"_created_at",new E({_id:"_created_at",Name:"Created At",Type:"DateTime",ReadOnly:!0}));c(this,"_modified_at",new E({_id:"_modified_at",Name:"Modified At",Type:"DateTime",ReadOnly:!0}));c(this,"_created_by",new T({_id:"_created_by",Name:"Created By",Type:"User",ReadOnly:!0}));c(this,"_modified_by",new T({_id:"_modified_by",Name:"Modified By",Type:"User",ReadOnly:!0}));c(this,"_version",new F({_id:"_version",Name:"Version",Type:"String",ReadOnly:!0}));c(this,"_m_version",new F({_id:"_m_version",Name:"Metadata Version",Type:"String",ReadOnly:!0}));c(this,"_fieldsBound",!1);c(this,"_fieldsCache",null);c(this,"_expressionEngine",new L)}getBoId(){return this.meta._id}getFields(){if(this._fieldsCache)return this._fieldsCache;const e={};for(const t of Object.keys(this)){const s=this[t];s instanceof m.BaseField&&(e[t]=s)}if(!this._fieldsBound){for(const t of Object.values(e))t._parentBoId=this.meta._id;this._fieldsBound=!0}return this._fieldsCache=e,e}loadMetadata(e){this._expressionEngine.loadMetadata(e)}hasMetadata(){return this._expressionEngine.hasMetadata()}validateFieldExpression(e,t,s){return this._expressionEngine.hasMetadata()?this._expressionEngine.validateField(e,t,s):{valid:!0,errors:[]}}async get(e){const t=await n.api(this.meta._id).get(e);return new w(this,t)}async list(e){return(await n.api(this.meta._id).list(e)).Data.map(s=>new w(this,s))}async count(e){return(await n.api(this.meta._id).count(e)).Count}async create(e){const t=await n.api(this.meta._id).create(e);return new w(this,{...e,_id:t._id})}async update(e,t){return n.api(this.meta._id).update(e,t)}async delete(e){return n.api(this.meta._id).delete(e)}async draft(e){return n.api(this.meta._id).draft(e)}async draftInteraction(e){return n.api(this.meta._id).draftInteraction(e)}createItem(e){return new w(this,e??{})}async draftUpdate(e,t){return n.api(this.meta._id).draftUpdate(e,t)}async draftPatch(e,t){return n.api(this.meta._id).draftPatch(e,t)}async metric(e){return n.api(this.meta._id).metric(e)}async pivot(e){return n.api(this.meta._id).pivot(e)}async getUploadUrl(e,t,s){return n.api(this.meta._id).getUploadUrl(e,t,s)}async getDownloadUrl(e,t,s,a){return n.api(this.meta._id).getDownloadUrl(e,t,s,a)}async getDownloadUrls(e,t,s){return n.api(this.meta._id).getDownloadUrls(e,t,s)}async deleteAttachment(e,t,s){return n.api(this.meta._id).deleteAttachment(e,t,s)}}class z extends m.BaseField{constructor(e){super(e)}get integerPart(){var e;return((e=this._meta.Constraint)==null?void 0:e.IntegerPart)??9}get fractionPart(){var e;return(e=this._meta.Constraint)==null?void 0:e.FractionPart}validate(e){return e!=null&&(typeof e!="number"||isNaN(e))?{valid:!1,errors:[`${this.label} must be a valid number`]}:{valid:!0,errors:[]}}}class J extends m.BaseField{constructor(e){super(e)}validate(e){return e!=null&&typeof e!="boolean"?{valid:!1,errors:[`${this.label} must be a boolean`]}:{valid:!0,errors:[]}}}class k extends m.BaseField{constructor(e){super(e)}validate(e){if(e==null||e==="")return{valid:!0,errors:[]};if(typeof e!="string")return{valid:!1,errors:[`${this.label} must be a valid date string`]};if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return{valid:!1,errors:[`${this.label} must be in YYYY-MM-DD format`]};const t=new Date(e+"T00:00:00");return isNaN(t.getTime())?{valid:!1,errors:[`${this.label} is not a valid date`]}:{valid:!0,errors:[]}}}class G extends m.BaseField{constructor(e){super(e)}get options(){var t;return(((t=this._meta.Constraint)==null?void 0:t.Enum)??[]).map(s=>({value:s,label:s}))}validate(e){if(e==null||e==="")return{valid:!0,errors:[]};if(this.options.length===0)return{valid:!0,errors:[]};const t=this.options.map(s=>s.value);return t.includes(e)?{valid:!0,errors:[]}:{valid:!1,errors:[`${this.label} must be one of: ${t.join(", ")}`]}}async fetchOptions(e){if(!this._parentBoId)throw new Error(`Field ${this.id} not bound to a BDO. Cannot fetch options.`);return(await n.api(this._parentBoId).fetchField(e??"new",this.id)).map(s=>({value:s.Value,label:s.Label}))}}class H extends m.BaseField{constructor(e){super(e)}get referenceBdo(){var e,t;return((t=(e=this._meta.View)==null?void 0:e.DataObject)==null?void 0:t.Id)??""}get referenceFields(){var e;return((e=this._meta.View)==null?void 0:e.Fields)??["_id"]}get searchFields(){var e;return((e=this._meta.View)==null?void 0:e.Search)??[]}validate(e){if(e==null)return{valid:!0,errors:[]};if(typeof e!="object")return{valid:!1,errors:[`${this.label} must be a valid reference object`]};const t=e;return!("_id"in t)||typeof t._id!="string"?{valid:!1,errors:[`${this.label} must have a valid _id`]}:{valid:!0,errors:[]}}async fetchOptions(e){if(!this._parentBoId)throw new Error(`Field ${this.id} not bound to a BDO. Cannot fetch options.`);return n.api(this._parentBoId).fetchField(e??"new",this.id)}}class X extends m.BaseField{constructor(e){super(e)}get elementType(){return this._meta.Property}validate(e){return e!=null&&!Array.isArray(e)?{valid:!1,errors:[`${this.label} must be an array`]}:{valid:!0,errors:[]}}}class K extends m.BaseField{constructor(e){super(e)}get properties(){return this._meta.Property}validate(e){return e==null?{valid:!0,errors:[]}:typeof e!="object"||Array.isArray(e)?{valid:!1,errors:[`${this.label} must be a valid object`]}:{valid:!0,errors:[]}}}class O extends m.BaseField{constructor(e){super(e)}get format(){var e;return((e=this._meta.Constraint)==null?void 0:e.Format)??"Plain"}validate(e){return e!=null&&typeof e!="string"?{valid:!1,errors:[`${this.label} must be a string`]}:{valid:!0,errors:[]}}}class W extends m.BaseField{constructor(e){super(e)}validate(e){if(e==null)return{valid:!0,errors:[]};if(!Array.isArray(e))return{valid:!1,errors:[`${this.label} must be an array of file objects`]};for(const t of e)if(!t||typeof t!="object"||!t._id)return{valid:!1,errors:[`Each file in ${this.label} must have an _id`]};return{valid:!0,errors:[]}}}class Q extends m.BaseField{constructor(e){super(e)}validate(e){return e==null?{valid:!0,errors:[]}:typeof e!="object"||Array.isArray(e)?{valid:!1,errors:[`${this.label} must be a valid image object`]}:!e._id||!e.FileName?{valid:!1,errors:[`${this.label} must have _id and FileName`]}:{valid:!0,errors:[]}}}exports.BaseField=m.BaseField;exports.SystemField=C.SystemField;exports.ArrayField=X;exports.BaseBdo=Y;exports.BooleanField=J;exports.DateField=k;exports.DateTimeField=E;exports.FileField=W;exports.ImageField=Q;exports.NumberField=z;exports.ObjectField=K;exports.ReferenceField=H;exports.SelectField=G;exports.StringField=F;exports.TextAreaField=O;exports.TextField=O;exports.UserField=T;
package/dist/bdo.mjs CHANGED
@@ -3,7 +3,7 @@ var U = (r, e, t) => e in r ? S(r, e, { enumerable: !0, configurable: !0, writab
3
3
  var c = (r, e, t) => U(r, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { a as i } from "./client-CMERmrC-.js";
5
5
  import { B as f } from "./BaseField-B6da88U7.js";
6
- import { d as se } from "./constants-CYJih7y4.js";
6
+ import { d as se } from "./constants-ConHc1oS.js";
7
7
  const C = /* @__PURE__ */ new Set([
8
8
  "jpg",
9
9
  "jpeg",
@@ -30,7 +30,9 @@ const t = {
30
30
  /** Minimum string length */
31
31
  MinLength: "MinLength",
32
32
  /** Maximum string length */
33
- MaxLength: "MaxLength"
33
+ MaxLength: "MaxLength",
34
+ /** Exact length (array) */
35
+ Length: "Length"
34
36
  }, n = {
35
37
  /** All conditions must match */
36
38
  And: "And",
@@ -41,8 +43,8 @@ const t = {
41
43
  }, e = {
42
44
  /** Literal constant value */
43
45
  Constant: "Constant",
44
- /** Reference another field */
45
- BOField: "BOField",
46
+ /** Reference another BDO field */
47
+ BDOField: "BDOField",
46
48
  /** Reference app variable */
47
49
  AppVariable: "AppVariable"
48
50
  }, o = {
@@ -0,0 +1 @@
1
+ "use strict";const t={EQ:"EQ",NE:"NE",GT:"GT",GTE:"GTE",LT:"LT",LTE:"LTE",Between:"Between",NotBetween:"NotBetween",IN:"IN",NIN:"NIN",Empty:"Empty",NotEmpty:"NotEmpty",Contains:"Contains",NotContains:"NotContains",MinLength:"MinLength",MaxLength:"MaxLength",Length:"Length"},e={And:"And",Or:"Or",Not:"Not"},n={Constant:"Constant",BDOField:"BDOField",AppVariable:"AppVariable"},o={ASC:"ASC",DESC:"DESC"},i={Sum:"Sum",Avg:"Avg",Count:"Count",Max:"Max",Min:"Min",DistinctCount:"DistinctCount",BlankCount:"BlankCount",NotBlankCount:"NotBlankCount",Concat:"Concat",DistinctConcat:"DistinctConcat"},a={List:"List",Metric:"Metric",Pivot:"Pivot"},c={Create:"create",Update:"update"},r={Interactive:"interactive",NonInteractive:"non-interactive"},s={OnBlur:"onBlur",OnChange:"onChange",OnSubmit:"onSubmit",OnTouched:"onTouched",All:"all"},d={Loading:"loading",Authenticated:"authenticated",Unauthenticated:"unauthenticated"},u={Google:"google",Microsoft:"microsoft",GitHub:"github",Custom:"custom"},C={Id:"_id",CreatedAt:"_created_at",ModifiedAt:"_modified_at",CreatedBy:"_created_by",ModifiedBy:"_modified_by",Version:"_version",MergeVersion:"_m_version"},E={GET:"GET",POST:"POST",PATCH:"PATCH",DELETE:"DELETE"},p={SEARCH_DEBOUNCE_MS:300,PAGE_SIZE:10,PAGE:1,SEARCH_MAX_LENGTH:255},T={Date:"$__d__",DateTime:"$__dt__"},l={Success:"success"};exports.AuthProviderName=u;exports.AuthStatus=d;exports.ConditionOperator=t;exports.DateEncodingKey=T;exports.Defaults=p;exports.DeleteStatus=l;exports.FormOperation=c;exports.GroupOperator=e;exports.HttpMethod=E;exports.InteractionMode=r;exports.MetricType=i;exports.QueryType=a;exports.RHSType=n;exports.SortDirection=o;exports.SystemField=C;exports.ValidationMode=s;
package/dist/filter.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./useFilter-Bg0jvIL6.cjs"),e=require("./constants-D0J69if5.cjs");exports.isCondition=o.isCondition;exports.isConditionGroup=o.isConditionGroup;exports.useFilter=o.useFilter;exports.ConditionOperator=e.ConditionOperator;exports.FilterValueSource=e.RHSType;exports.GroupOperator=e.GroupOperator;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./useFilter-Bg0jvIL6.cjs"),e=require("./constants-QX2RX-wu.cjs");exports.isCondition=o.isCondition;exports.isConditionGroup=o.isConditionGroup;exports.useFilter=o.useFilter;exports.ConditionOperator=e.ConditionOperator;exports.FilterValueSource=e.RHSType;exports.GroupOperator=e.GroupOperator;
package/dist/filter.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i, a, u as e } from "./useFilter-DPNLKY3H.js";
2
- import { C as t, R as n, G as p } from "./constants-CYJih7y4.js";
2
+ import { C as t, R as n, G as p } from "./constants-ConHc1oS.js";
3
3
  export {
4
4
  t as ConditionOperator,
5
5
  n as FilterValueSource,
package/dist/form.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./constants-D0J69if5.cjs"),M=require("react"),j=require("./index.esm-DuwT11sx.cjs"),w=require("@tanstack/react-query"),B=require("./metadata-BfJtHz84.cjs");function P(s,e){const r=[];if(s.required&&(e==null||e===""||Array.isArray(e)&&e.length===0))return r.push(`${s.label} is required`),{valid:!1,errors:r};if(e==null||e==="")return{valid:!0,errors:[]};if("length"in s&&typeof s.length=="number"&&typeof e=="string"&&e.length>s.length&&r.push(`${s.label} must be at most ${s.length} characters`),"integerPart"in s&&typeof e=="number"){const o=Math.floor(Math.abs(e)),c=s.integerPart??9;o.toString().length>c&&r.push(`${s.label} integer part must be at most ${c} digits`);const t=s.fractionPart;t!==void 0&&(e.toString().split(".")[1]??"").length>t&&r.push(`${s.label} can have at most ${t} decimal places`)}return r.length>0?{valid:!1,errors:r}:{valid:!0,errors:[]}}function C(s,e){return async(r,o,c)=>{var v;const t={},a=s.getFields(),m=(c==null?void 0:c.names)??Object.keys(a);for(const n of m){if(n==="_id"||(v=a[n])!=null&&v.readOnly)continue;const f=a[n];if(!f)continue;const d=r[n],u=f.validate(d);if(!u.valid&&u.errors.length>0){t[n]={type:"validate",message:u.errors[0]||`${n} is invalid`};continue}if((e==null?void 0:e.enableConstraintValidation)!==!1){const l=P(f,d);if(!l.valid&&l.errors.length>0){t[n]={type:"constraint",message:l.errors[0]};continue}}if(s.hasMetadata()){const l=s.validateFieldExpression(n,d,r);!l.valid&&l.errors.length>0&&(t[n]={type:"validate",message:l.errors[0]})}}return Object.keys(t).length===0?{values:r,errors:{}}:{values:{},errors:t}}}function J(s,e){const r=s.getFields(),o=new Map;return new Proxy({},{get(c,t){if(typeof t=="symbol")return;if(t==="_id")return e.getValues("_id");if(t==="toJSON")return()=>e.getValues();if(t==="validate")return()=>e.trigger();if(o.has(t))return o.get(t);const a=r[t],m=(a==null?void 0:a.meta)??{_id:t,Name:t,Type:"String"},v=(a==null?void 0:a.readOnly)??!1,n=()=>{if(!a)return{valid:!0,errors:[]};const u=e.getValues(t),l=a.validate(u);if(!l.valid)return l;const R=P(a,u);if(!R.valid)return R;if(s.hasMetadata()){const g=s.validateFieldExpression(t,u,e.getValues());if(!g.valid)return g}return{valid:!0,errors:[]}},f=u=>{const l=e.getValues(t);return l??u};if(!v){const u={label:(a==null?void 0:a.label)??t,required:(a==null?void 0:a.required)??!1,readOnly:!1,defaultValue:a==null?void 0:a.defaultValue,meta:m,get:()=>e.getValues(t),getOrDefault:f,set:l=>{e.setValue(t,l,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!1})},validate:n};return o.set(t,u),u}const d={label:(a==null?void 0:a.label)??t,required:(a==null?void 0:a.required)??!1,readOnly:!0,defaultValue:a==null?void 0:a.defaultValue,meta:m,get:()=>e.getValues(t),getOrDefault:f,validate:n};return o.set(t,d),d},has(c,t){return typeof t=="symbol"?!1:t==="_id"||t==="toJSON"||t==="validate"?!0:t in r},ownKeys(c){return[...Object.keys(r),"_id","toJSON","validate"]},getOwnPropertyDescriptor(c,t){if(typeof t!="symbol")return{configurable:!0,enumerable:t!=="toJSON"&&t!=="validate"}}})}function F(s){const{bdo:e,recordId:r,operation:o,defaultValues:c,mode:t="onBlur",enableDraft:a=!1,enableConstraintValidation:m,enableExpressionValidation:v}=s,n=o??(r?"update":"create"),f=M.useMemo(()=>C(e,{enableConstraintValidation:m}),[e,m]),{data:d,isLoading:u,isFetching:l,error:R}=w.useQuery({queryKey:["form-record",e.meta._id,r],queryFn:async()=>(await e.get(r)).toJSON(),enabled:n==="update"&&!!r,staleTime:0}),{data:g}=w.useQuery({queryKey:["form-schema",e.meta._id],queryFn:()=>B.getBdoSchema(e.meta._id),staleTime:30*60*1e3,gcTime:60*60*1e3,enabled:v!==!1});M.useEffect(()=>{g!=null&&g.BDOBlob&&e.loadMetadata(g.BDOBlob)},[g,e]);const i=j.useForm({mode:t,resolver:f,defaultValues:c,values:n==="update"&&d?d:void 0}),$=M.useMemo(()=>J(e,i),[e,i]),h=e.getFields(),k=M.useCallback((S,y)=>{var b;const V=i.register(S,y);return(b=h[S])!=null&&b.readOnly?{...V,disabled:!0}:V},[i,h]),N=M.useCallback((S,y)=>i.handleSubmit(async(V,b)=>{try{const O={};if(n==="create")for(const[q,_]of Object.entries(V))h[q]&&!h[q].readOnly&&(O[q]=_);else{const q=i.formState.dirtyFields;for(const[_,T]of Object.entries(V))h[_]&&!h[_].readOnly&&q[_]&&(O[_]=T)}let x;n==="create"?x=await e.create(O):x=await e.update(r,O),S==null||S(x,b)}catch(O){y==null||y(O,b)}},(V,b)=>{y==null||y(V,b)}),[i,e,n,r,h]);return{item:$,bdo:e,operation:n,recordId:r,register:k,handleSubmit:N,watch:i.watch,setValue:i.setValue,getValues:i.getValues,reset:i.reset,trigger:i.trigger,control:i.control,formState:i.formState,errors:i.formState.errors,isDirty:i.formState.isDirty,isValid:i.formState.isValid,isSubmitting:i.formState.isSubmitting,isSubmitSuccessful:i.formState.isSubmitSuccessful,dirtyFields:i.formState.dirtyFields,isLoading:u,isFetching:l,loadError:R}}exports.FormOperation=D.FormOperation;exports.InteractionMode=D.InteractionMode;exports.ValidationMode=D.ValidationMode;exports.useForm=F;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./constants-QX2RX-wu.cjs"),M=require("react"),j=require("./index.esm-DuwT11sx.cjs"),w=require("@tanstack/react-query"),B=require("./metadata-BfJtHz84.cjs");function P(s,e){const r=[];if(s.required&&(e==null||e===""||Array.isArray(e)&&e.length===0))return r.push(`${s.label} is required`),{valid:!1,errors:r};if(e==null||e==="")return{valid:!0,errors:[]};if("length"in s&&typeof s.length=="number"&&typeof e=="string"&&e.length>s.length&&r.push(`${s.label} must be at most ${s.length} characters`),"integerPart"in s&&typeof e=="number"){const o=Math.floor(Math.abs(e)),c=s.integerPart??9;o.toString().length>c&&r.push(`${s.label} integer part must be at most ${c} digits`);const t=s.fractionPart;t!==void 0&&(e.toString().split(".")[1]??"").length>t&&r.push(`${s.label} can have at most ${t} decimal places`)}return r.length>0?{valid:!1,errors:r}:{valid:!0,errors:[]}}function C(s,e){return async(r,o,c)=>{var v;const t={},a=s.getFields(),m=(c==null?void 0:c.names)??Object.keys(a);for(const n of m){if(n==="_id"||(v=a[n])!=null&&v.readOnly)continue;const f=a[n];if(!f)continue;const d=r[n],u=f.validate(d);if(!u.valid&&u.errors.length>0){t[n]={type:"validate",message:u.errors[0]||`${n} is invalid`};continue}if((e==null?void 0:e.enableConstraintValidation)!==!1){const l=P(f,d);if(!l.valid&&l.errors.length>0){t[n]={type:"constraint",message:l.errors[0]};continue}}if(s.hasMetadata()){const l=s.validateFieldExpression(n,d,r);!l.valid&&l.errors.length>0&&(t[n]={type:"validate",message:l.errors[0]})}}return Object.keys(t).length===0?{values:r,errors:{}}:{values:{},errors:t}}}function J(s,e){const r=s.getFields(),o=new Map;return new Proxy({},{get(c,t){if(typeof t=="symbol")return;if(t==="_id")return e.getValues("_id");if(t==="toJSON")return()=>e.getValues();if(t==="validate")return()=>e.trigger();if(o.has(t))return o.get(t);const a=r[t],m=(a==null?void 0:a.meta)??{_id:t,Name:t,Type:"String"},v=(a==null?void 0:a.readOnly)??!1,n=()=>{if(!a)return{valid:!0,errors:[]};const u=e.getValues(t),l=a.validate(u);if(!l.valid)return l;const R=P(a,u);if(!R.valid)return R;if(s.hasMetadata()){const g=s.validateFieldExpression(t,u,e.getValues());if(!g.valid)return g}return{valid:!0,errors:[]}},f=u=>{const l=e.getValues(t);return l??u};if(!v){const u={label:(a==null?void 0:a.label)??t,required:(a==null?void 0:a.required)??!1,readOnly:!1,defaultValue:a==null?void 0:a.defaultValue,meta:m,get:()=>e.getValues(t),getOrDefault:f,set:l=>{e.setValue(t,l,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!1})},validate:n};return o.set(t,u),u}const d={label:(a==null?void 0:a.label)??t,required:(a==null?void 0:a.required)??!1,readOnly:!0,defaultValue:a==null?void 0:a.defaultValue,meta:m,get:()=>e.getValues(t),getOrDefault:f,validate:n};return o.set(t,d),d},has(c,t){return typeof t=="symbol"?!1:t==="_id"||t==="toJSON"||t==="validate"?!0:t in r},ownKeys(c){return[...Object.keys(r),"_id","toJSON","validate"]},getOwnPropertyDescriptor(c,t){if(typeof t!="symbol")return{configurable:!0,enumerable:t!=="toJSON"&&t!=="validate"}}})}function F(s){const{bdo:e,recordId:r,operation:o,defaultValues:c,mode:t="onBlur",enableDraft:a=!1,enableConstraintValidation:m,enableExpressionValidation:v}=s,n=o??(r?"update":"create"),f=M.useMemo(()=>C(e,{enableConstraintValidation:m}),[e,m]),{data:d,isLoading:u,isFetching:l,error:R}=w.useQuery({queryKey:["form-record",e.meta._id,r],queryFn:async()=>(await e.get(r)).toJSON(),enabled:n==="update"&&!!r,staleTime:0}),{data:g}=w.useQuery({queryKey:["form-schema",e.meta._id],queryFn:()=>B.getBdoSchema(e.meta._id),staleTime:30*60*1e3,gcTime:60*60*1e3,enabled:v!==!1});M.useEffect(()=>{g!=null&&g.BDOBlob&&e.loadMetadata(g.BDOBlob)},[g,e]);const i=j.useForm({mode:t,resolver:f,defaultValues:c,values:n==="update"&&d?d:void 0}),$=M.useMemo(()=>J(e,i),[e,i]),h=e.getFields(),k=M.useCallback((S,y)=>{var b;const V=i.register(S,y);return(b=h[S])!=null&&b.readOnly?{...V,disabled:!0}:V},[i,h]),N=M.useCallback((S,y)=>i.handleSubmit(async(V,b)=>{try{const O={};if(n==="create")for(const[q,_]of Object.entries(V))h[q]&&!h[q].readOnly&&(O[q]=_);else{const q=i.formState.dirtyFields;for(const[_,T]of Object.entries(V))h[_]&&!h[_].readOnly&&q[_]&&(O[_]=T)}let x;n==="create"?x=await e.create(O):x=await e.update(r,O),S==null||S(x,b)}catch(O){y==null||y(O,b)}},(V,b)=>{y==null||y(V,b)}),[i,e,n,r,h]);return{item:$,bdo:e,operation:n,recordId:r,register:k,handleSubmit:N,watch:i.watch,setValue:i.setValue,getValues:i.getValues,reset:i.reset,trigger:i.trigger,control:i.control,formState:i.formState,errors:i.formState.errors,isDirty:i.formState.isDirty,isValid:i.formState.isValid,isSubmitting:i.formState.isSubmitting,isSubmitSuccessful:i.formState.isSubmitSuccessful,dirtyFields:i.formState.dirtyFields,isLoading:u,isFetching:l,loadError:R}}exports.FormOperation=D.FormOperation;exports.InteractionMode=D.InteractionMode;exports.ValidationMode=D.ValidationMode;exports.useForm=F;
package/dist/form.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { F as H, I as U, V as W } from "./constants-CYJih7y4.js";
1
+ import { F as H, I as U, V as W } from "./constants-ConHc1oS.js";
2
2
  import { useMemo as q, useEffect as T, useCallback as M } from "react";
3
3
  import { u as j } from "./index.esm-Cj63v5ny.js";
4
4
  import { useQuery as w } from "@tanstack/react-query";
package/dist/table.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),L=require("@tanstack/react-query"),G=require("./client-BnVxSHAm.cjs"),C=require("./error-handling-CAoD0Kwb.cjs"),oe=require("./useFilter-Bg0jvIL6.cjs"),l=require("./constants-D0J69if5.cjs");function ne(o){var A,D,R,z,M,P,Q,w;const[a,h]=r.useState({query:"",debouncedQuery:"",field:null}),c=r.useRef(null),j=300,I=()=>{var t,n;const e=(t=o.initialState)==null?void 0:t.sort;if(e&&e.length>0){const H=e[0],x=Object.keys(H)[0],T=(n=H[x])==null?void 0:n.toUpperCase();return{field:x,direction:T==="ASC"||T==="DESC"?T:"ASC"}}return{field:null,direction:null}},[s,b]=r.useState(I),[i,u]=r.useState({pageNo:((D=(A=o.initialState)==null?void 0:A.pagination)==null?void 0:D.pageNo)||1,pageSize:((z=(R=o.initialState)==null?void 0:R.pagination)==null?void 0:z.pageSize)||10}),d=oe.useFilter({conditions:(P=(M=o.initialState)==null?void 0:M.filter)==null?void 0:P.conditions,operator:((w=(Q=o.initialState)==null?void 0:Q.filter)==null?void 0:w.operator)||"And"});r.useEffect(()=>{u(e=>({...e,pageNo:1}))},[d.payload]);const g=r.useMemo(()=>{const e={};let t=d.payload;if(a.debouncedQuery&&a.field){const n={LHSField:a.field,Operator:"Contains",RHSValue:a.debouncedQuery,RHSType:"Constant"};t?t.Operator==="And"?t={...t,Condition:[...t.Condition||[],n]}:t={Operator:"And",Condition:[t,n]}:t={Operator:"And",Condition:[n]}}return t&&(e.Filter=t),e},[a.debouncedQuery,a.field,d.payload]),E=r.useMemo(()=>{const e={...g};return s.field&&s.direction&&(e.Sort=[{[String(s.field)]:s.direction}]),e.Page=i.pageNo,e.PageSize=i.pageSize,e},[g,s,i]),{data:f,isLoading:K,isFetching:U,error:q,refetch:O}=L.useQuery({queryKey:["table",o.source,E],queryFn:async()=>{try{const e=await G.api(o.source).list(E);return o.onSuccess&&o.onSuccess(e.Data),e}catch(e){throw o.onError&&o.onError(C.toError(e)),e}},staleTime:0,gcTime:30*1e3}),{data:S,isLoading:_,isFetching:B,error:F,refetch:k}=L.useQuery({queryKey:["table-count",o.source,g],queryFn:async()=>{try{return await G.api(o.source).count(g)}catch(e){throw o.onError&&o.onError(C.toError(e)),e}},staleTime:0,gcTime:30*1e3}),V=r.useMemo(()=>(f==null?void 0:f.Data)||[],[f]),p=r.useMemo(()=>(S==null?void 0:S.Count)||0,[S]),y=r.useMemo(()=>Math.ceil(p/i.pageSize),[p,i.pageSize]),J=r.useCallback(e=>{b(t=>{if(t.field===e){if(t.direction==="ASC")return{field:e,direction:"DESC"};if(t.direction==="DESC")return{field:null,direction:null}}return{field:e,direction:"ASC"}})},[]),W=r.useCallback(()=>{b({field:null,direction:null})},[]),X=r.useCallback((e,t)=>{b({field:e,direction:t})},[]),Y=r.useCallback((e,t)=>{if(t.length>255){console.warn("Search query exceeds maximum length of 255 characters");return}h(n=>({...n,query:t,field:e})),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{h(n=>({...n,debouncedQuery:t})),u(n=>({...n,pageNo:1}))},j)},[]),Z=r.useCallback(()=>{c.current&&clearTimeout(c.current),h({query:"",debouncedQuery:"",field:null}),u(e=>({...e,pageNo:1}))},[]);r.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const m=i.pageNo<y,N=i.pageNo>1,$=r.useCallback(()=>{m&&u(e=>({...e,pageNo:e.pageNo+1}))},[m]),v=r.useCallback(()=>{N&&u(e=>({...e,pageNo:e.pageNo-1}))},[N]),ee=r.useCallback(e=>{const t=Math.max(1,Math.min(e,y));u(n=>({...n,pageNo:t}))},[y]),te=r.useCallback(e=>{u(t=>({...t,pageSize:e,pageNo:1}))},[]),re=r.useCallback(async()=>{const[e]=await Promise.all([O(),k()]);return e.data||{Data:[]}},[O,k]);return{rows:V,totalItems:p,isLoading:K||_,isFetching:U||B,error:q?C.toError(q):F?C.toError(F):null,search:{query:a.query,field:a.field,set:Y,clear:Z},sort:{field:s.field,direction:s.direction,toggle:J,clear:W,set:X},filter:d,pagination:{pageNo:i.pageNo,pageSize:i.pageSize,totalPages:y,totalItems:p,canGoNext:m,canGoPrevious:N,goToNext:$,goToPrevious:v,goToPage:ee,setPageSize:te},refetch:re}}exports.ConditionOperator=l.ConditionOperator;exports.GroupOperator=l.GroupOperator;exports.RHSType=l.RHSType;exports.SortDirection=l.SortDirection;exports.TableDefaults=l.Defaults;exports.useTable=ne;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),L=require("@tanstack/react-query"),G=require("./client-BnVxSHAm.cjs"),C=require("./error-handling-CAoD0Kwb.cjs"),oe=require("./useFilter-Bg0jvIL6.cjs"),l=require("./constants-QX2RX-wu.cjs");function ne(o){var A,D,R,z,M,P,Q,w;const[a,h]=r.useState({query:"",debouncedQuery:"",field:null}),c=r.useRef(null),j=300,I=()=>{var t,n;const e=(t=o.initialState)==null?void 0:t.sort;if(e&&e.length>0){const H=e[0],x=Object.keys(H)[0],T=(n=H[x])==null?void 0:n.toUpperCase();return{field:x,direction:T==="ASC"||T==="DESC"?T:"ASC"}}return{field:null,direction:null}},[s,b]=r.useState(I),[i,u]=r.useState({pageNo:((D=(A=o.initialState)==null?void 0:A.pagination)==null?void 0:D.pageNo)||1,pageSize:((z=(R=o.initialState)==null?void 0:R.pagination)==null?void 0:z.pageSize)||10}),d=oe.useFilter({conditions:(P=(M=o.initialState)==null?void 0:M.filter)==null?void 0:P.conditions,operator:((w=(Q=o.initialState)==null?void 0:Q.filter)==null?void 0:w.operator)||"And"});r.useEffect(()=>{u(e=>({...e,pageNo:1}))},[d.payload]);const g=r.useMemo(()=>{const e={};let t=d.payload;if(a.debouncedQuery&&a.field){const n={LHSField:a.field,Operator:"Contains",RHSValue:a.debouncedQuery,RHSType:"Constant"};t?t.Operator==="And"?t={...t,Condition:[...t.Condition||[],n]}:t={Operator:"And",Condition:[t,n]}:t={Operator:"And",Condition:[n]}}return t&&(e.Filter=t),e},[a.debouncedQuery,a.field,d.payload]),E=r.useMemo(()=>{const e={...g};return s.field&&s.direction&&(e.Sort=[{[String(s.field)]:s.direction}]),e.Page=i.pageNo,e.PageSize=i.pageSize,e},[g,s,i]),{data:f,isLoading:K,isFetching:U,error:q,refetch:O}=L.useQuery({queryKey:["table",o.source,E],queryFn:async()=>{try{const e=await G.api(o.source).list(E);return o.onSuccess&&o.onSuccess(e.Data),e}catch(e){throw o.onError&&o.onError(C.toError(e)),e}},staleTime:0,gcTime:30*1e3}),{data:S,isLoading:_,isFetching:B,error:F,refetch:k}=L.useQuery({queryKey:["table-count",o.source,g],queryFn:async()=>{try{return await G.api(o.source).count(g)}catch(e){throw o.onError&&o.onError(C.toError(e)),e}},staleTime:0,gcTime:30*1e3}),V=r.useMemo(()=>(f==null?void 0:f.Data)||[],[f]),p=r.useMemo(()=>(S==null?void 0:S.Count)||0,[S]),y=r.useMemo(()=>Math.ceil(p/i.pageSize),[p,i.pageSize]),J=r.useCallback(e=>{b(t=>{if(t.field===e){if(t.direction==="ASC")return{field:e,direction:"DESC"};if(t.direction==="DESC")return{field:null,direction:null}}return{field:e,direction:"ASC"}})},[]),W=r.useCallback(()=>{b({field:null,direction:null})},[]),X=r.useCallback((e,t)=>{b({field:e,direction:t})},[]),Y=r.useCallback((e,t)=>{if(t.length>255){console.warn("Search query exceeds maximum length of 255 characters");return}h(n=>({...n,query:t,field:e})),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{h(n=>({...n,debouncedQuery:t})),u(n=>({...n,pageNo:1}))},j)},[]),Z=r.useCallback(()=>{c.current&&clearTimeout(c.current),h({query:"",debouncedQuery:"",field:null}),u(e=>({...e,pageNo:1}))},[]);r.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const m=i.pageNo<y,N=i.pageNo>1,$=r.useCallback(()=>{m&&u(e=>({...e,pageNo:e.pageNo+1}))},[m]),v=r.useCallback(()=>{N&&u(e=>({...e,pageNo:e.pageNo-1}))},[N]),ee=r.useCallback(e=>{const t=Math.max(1,Math.min(e,y));u(n=>({...n,pageNo:t}))},[y]),te=r.useCallback(e=>{u(t=>({...t,pageSize:e,pageNo:1}))},[]),re=r.useCallback(async()=>{const[e]=await Promise.all([O(),k()]);return e.data||{Data:[]}},[O,k]);return{rows:V,totalItems:p,isLoading:K||_,isFetching:U||B,error:q?C.toError(q):F?C.toError(F):null,search:{query:a.query,field:a.field,set:Y,clear:Z},sort:{field:s.field,direction:s.direction,toggle:J,clear:W,set:X},filter:d,pagination:{pageNo:i.pageNo,pageSize:i.pageSize,totalPages:y,totalItems:p,canGoNext:m,canGoPrevious:N,goToNext:$,goToPrevious:v,goToPage:ee,setPageSize:te},refetch:re}}exports.ConditionOperator=l.ConditionOperator;exports.GroupOperator=l.GroupOperator;exports.RHSType=l.RHSType;exports.SortDirection=l.SortDirection;exports.TableDefaults=l.Defaults;exports.useTable=ne;
package/dist/table.mjs CHANGED
@@ -3,7 +3,7 @@ import { useQuery as I } from "@tanstack/react-query";
3
3
  import { a as K } from "./client-CMERmrC-.js";
4
4
  import { t as h } from "./error-handling-CrhTtD88.js";
5
5
  import { u as ae } from "./useFilter-DPNLKY3H.js";
6
- import { C as ye, G as he, R as me, S as Ce, D as Ne } from "./constants-CYJih7y4.js";
6
+ import { C as ye, G as he, R as me, S as Ce, D as Ne } from "./constants-ConHc1oS.js";
7
7
  function fe(r) {
8
8
  var R, P, q, w, Q, x, H, L;
9
9
  const [a, m] = E({
@@ -47,6 +47,8 @@ export declare const ConditionOperator: {
47
47
  readonly MinLength: "MinLength";
48
48
  /** Maximum string length */
49
49
  readonly MaxLength: "MaxLength";
50
+ /** Exact length (array) */
51
+ readonly Length: "Length";
50
52
  };
51
53
  /**
52
54
  * Group/Logical operators for combining conditions
@@ -79,13 +81,13 @@ export declare const GroupOperator: {
79
81
  * { RHSType: RHSType.Constant, RHSValue: 100 }
80
82
  *
81
83
  * // Compare against another field
82
- * { RHSType: RHSType.BOField, RHSValue: "otherField" }
84
+ * { RHSType: RHSType.BDOField, RHSValue: "otherField" }
83
85
  */
84
86
  export declare const RHSType: {
85
87
  /** Literal constant value */
86
88
  readonly Constant: "Constant";
87
- /** Reference another field */
88
- readonly BOField: "BOField";
89
+ /** Reference another BDO field */
90
+ readonly BDOField: "BDOField";
89
91
  /** Reference app variable */
90
92
  readonly AppVariable: "AppVariable";
91
93
  };
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../sdk/types/constants.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB;IAC5B,YAAY;;IAEZ,gBAAgB;;IAEhB,mBAAmB;;IAEn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,qBAAqB;;CAEb,CAAC;AAMX;;;;;;;GAOG;AACH,eAAO,MAAM,QAAQ;IACnB,gDAAgD;;IAEhD,6BAA6B;;IAE7B,sCAAsC;;IAEtC,kCAAkC;;CAE1B,CAAC;AAMX;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe;IAC1B,yDAAyD;;IAEzD,gEAAgE;;CAExD,CAAC;AAMX;;GAEG;AACH,eAAO,MAAM,YAAY;IACvB,0BAA0B;;CAElB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { useActivityTable } from './useActivityTable';
2
+ export { ActivityTableStatus } from './types';
3
+ export type { UseActivityTableOptionsType, UseActivityTableReturnType, ActivityTableStatusType, ActivityRowType, } from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../sdk/workflow/components/useActivityTable/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC9C,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,GAChB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { Activity } from '../../Activity';
2
+ import type { ActivityInstanceFieldsType } from '../../types';
3
+ import type { ExtractActivityEntity } from '../useActivityForm/types';
4
+ import type { ListResponseType } from '../../../types/common';
5
+ /**
6
+ * Activity table status — determines which API to call
7
+ */
8
+ export declare const ActivityTableStatus: {
9
+ readonly InProgress: "inprogress";
10
+ readonly Completed: "completed";
11
+ };
12
+ export type ActivityTableStatusType = (typeof ActivityTableStatus)[keyof typeof ActivityTableStatus];
13
+ /**
14
+ * Row type for activity table data.
15
+ * Combines activity instance system fields with entity-specific fields.
16
+ *
17
+ * For a ManagerApprovalActivity with { ManagerApproved, ManagerReason }:
18
+ * ActivityRowType resolves to:
19
+ * {
20
+ * // System fields (ActivityInstanceFieldsType)
21
+ * _id: string;
22
+ * Status: "InProgress" | "Completed";
23
+ * AssignedTo: UserRefType;
24
+ * CompletedAt: string;
25
+ * // Entity fields
26
+ * ManagerApproved: boolean;
27
+ * ManagerReason: string;
28
+ * }
29
+ */
30
+ export type ActivityRowType<A extends Activity<any, any, any>> = ActivityInstanceFieldsType & ExtractActivityEntity<A>;
31
+ export interface UseActivityTableOptionsType<A extends Activity<any, any, any>> {
32
+ /** Which activity instances to fetch */
33
+ status: ActivityTableStatusType;
34
+ /** Error callback */
35
+ onError?: (error: Error) => void;
36
+ /** Success callback with row data */
37
+ onSuccess?: (data: ActivityRowType<A>[]) => void;
38
+ }
39
+ export interface UseActivityTableReturnType<A extends Activity<any, any, any>> {
40
+ /** Activity instance records (system fields + entity fields) */
41
+ rows: ActivityRowType<A>[];
42
+ /** Total count from metrics endpoint */
43
+ totalItems: number;
44
+ /** Initial load in progress */
45
+ isLoading: boolean;
46
+ /** Any fetch in progress (including refetch) */
47
+ isFetching: boolean;
48
+ /** Fetch error */
49
+ error: Error | null;
50
+ /** Refetch both list and metrics */
51
+ refetch: () => Promise<ListResponseType<ActivityRowType<A>>>;
52
+ }
53
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../sdk/workflow/components/useActivityTable/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAEjE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAC3D,0BAA0B,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC;AAExD,MAAM,WAAW,2BAA2B,CAC1C,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAEjC,wCAAwC;IACxC,MAAM,EAAE,uBAAuB,CAAC;IAChC,qBAAqB;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,qCAAqC;IACrC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,0BAA0B,CACzC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;IAEjC,gEAAgE;IAChE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,gDAAgD;IAChD,UAAU,EAAE,OAAO,CAAC;IACpB,kBAAkB;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,oCAAoC;IACpC,OAAO,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9D"}
@@ -0,0 +1,4 @@
1
+ import type { Activity } from '../../Activity';
2
+ import { type UseActivityTableOptionsType, type UseActivityTableReturnType } from './types';
3
+ export declare function useActivityTable<A extends Activity<any, any, any>>(activity: A, options: UseActivityTableOptionsType<A>): UseActivityTableReturnType<A>;
4
+ //# sourceMappingURL=useActivityTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useActivityTable.d.ts","sourceRoot":"","sources":["../../../../sdk/workflow/components/useActivityTable/useActivityTable.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAEhC,MAAM,SAAS,CAAC;AAMjB,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAChE,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACtC,0BAA0B,CAAC,CAAC,CAAC,CAoH/B"}
@@ -1,6 +1,5 @@
1
1
  import type { ListResponseType, MetricResponseType, DraftResponseType, CreateUpdateResponseType } from "../types/common";
2
- import type { StringFieldType, SelectFieldType, DateTimeFieldType, ReferenceFieldType } from "../types/base-fields";
3
- import type { UserRefType } from "../types/base-fields";
2
+ import type { StringFieldType, SelectFieldType, DateTimeFieldType, UserFieldType } from "../types/base-fields";
4
3
  /**
5
4
  * Response from Workflow.start()
6
5
  */
@@ -37,7 +36,7 @@ export interface ActivityProgressType {
37
36
  export type ActivityInstanceFieldsType = {
38
37
  _id: StringFieldType;
39
38
  Status: SelectFieldType<"InProgress" | "Completed">;
40
- AssignedTo: ReferenceFieldType<UserRefType>;
39
+ AssignedTo: UserFieldType;
41
40
  CompletedAt: DateTimeFieldType;
42
41
  };
43
42
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../sdk/workflow/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAA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AE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE7E,2DAA2D;IAC3D,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAElF,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAEhE,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;CAC/D"}
package/dist/workflow.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var J=Object.defineProperty;var R=(o,t,e)=>t in o?J(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var O=(o,t,e)=>R(o,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./client-BnVxSHAm.cjs"),U=require("./BaseField-Drp0-OxL.cjs"),f=require("react"),L=require("./index.esm-DuwT11sx.cjs"),B=require("./error-handling-CAoD0Kwb.cjs");class C{constructor(t){O(this,"bp_id");this.bp_id=t}async start(){const t=await fetch(`${l.getApiBaseUrl()}/api/app/process/${this.bp_id}/start`,{method:"POST",headers:l.getDefaultHeaders()});if(!t.ok)throw new Error(`Failed to start process: ${t.statusText}`);return(await t.json()).Data}async progress(t){const e=await fetch(`${l.getApiBaseUrl()}/api/app/process/${this.bp_id}/${t}/progress`,{method:"GET",headers:l.getDefaultHeaders()});if(!e.ok)throw new Error(`Failed to get process progress: ${e.statusText}`);return(await e.json()).Data}activity(t){const e=`/api/app/process/${this.bp_id}/${t}`;return{async inProgressList(){const r=await fetch(`${l.getApiBaseUrl()}${e}/inprogress/list`,{method:"GET",headers:l.getDefaultHeaders()});if(!r.ok)throw new Error(`Failed to list in-progress activities: ${r.statusText}`);return r.json()},async completedList(){const r=await fetch(`${l.getApiBaseUrl()}${e}/completed/list`,{method:"GET",headers:l.getDefaultHeaders()});if(!r.ok)throw new Error(`Failed to list completed activities: ${r.statusText}`);return r.json()},async inProgressMetric(){const r=await fetch(`${l.getApiBaseUrl()}${e}/inprogress/metric`,{method:"GET",headers:l.getDefaultHeaders()});if(!r.ok)throw new Error(`Failed to get in-progress activity metrics: ${r.statusText}`);return r.json()},async completedMetric(){const r=await fetch(`${l.getApiBaseUrl()}${e}/completed/metric`,{method:"GET",headers:l.getDefaultHeaders()});if(!r.ok)throw new Error(`Failed to get completed activity metrics: ${r.statusText}`);return r.json()},async read(r){const s=await fetch(`${l.getApiBaseUrl()}${e}/${r}/read`,{method:"GET",headers:l.getDefaultHeaders()});if(!s.ok)throw new Error(`Failed to read activity: ${s.statusText}`);return(await s.json()).Data},async update(r,s){const a=await fetch(`${l.getApiBaseUrl()}${e}/${r}/update`,{method:"POST",headers:l.getDefaultHeaders(),body:JSON.stringify(s)});if(!a.ok)throw new Error(`Failed to update activity: ${a.statusText}`);return a.json()},async draftStart(r,s){const a=await fetch(`${l.getApiBaseUrl()}${e}/${r}/draft`,{method:"PATCH",headers:l.getDefaultHeaders(),body:JSON.stringify(s)});if(!a.ok)throw new Error(`Failed to start draft: ${a.statusText}`);return a.json()},async draftEnd(r,s){const a=await fetch(`${l.getApiBaseUrl()}${e}/${r}/draft`,{method:"POST",headers:l.getDefaultHeaders(),body:JSON.stringify(s)});if(!a.ok)throw new Error(`Failed to end draft: ${a.statusText}`);return a.json()},async complete(r){const s=await fetch(`${l.getApiBaseUrl()}${e}/${r}/done`,{method:"POST",headers:l.getDefaultHeaders()});if(!s.ok)throw new Error(`Failed to complete activity: ${s.statusText}`);return s.json()},async progress(r){const s=await fetch(`${l.getApiBaseUrl()}${e}/${r}/progress`,{method:"GET",headers:l.getDefaultHeaders()});if(!s.ok)throw new Error(`Failed to get activity progress: ${s.statusText}`);return s.json()}}}}class P{constructor(t,e,r,s){O(this,"_id");O(this,"_data");O(this,"_ops");O(this,"_fields");O(this,"_accessorCache",new Map);this._ops=t,this._id=e,this._data={...r},this._fields=s}toJSON(){return{...this._data}}validate(){const t=[];for(const[e,r]of Object.entries(this._fields)){const s=this._data[e],a=r.validate(s);a.valid||t.push(...a.errors)}return{valid:t.length===0,errors:t}}async update(t){return this._ops.update(this._id,t)}async save(t){return this._ops.draftEnd(this._id,t)}async complete(){return this._ops.complete(this._id)}async progress(){return this._ops.progress(this._id)}_getAccessor(t){if(this._accessorCache.has(t))return this._accessorCache.get(t);const e=this._fields[t],r=(e==null?void 0:e.meta)??{_id:t,Name:t,Type:"String"},s=(e==null?void 0:e.readOnly)??!1,a=()=>e?e.validate(this._data[t]):{valid:!0,errors:[]};let i;return s?i={label:(e==null?void 0:e.label)??t,required:(e==null?void 0:e.required)??!1,readOnly:!0,defaultValue:e==null?void 0:e.defaultValue,meta:r,get:()=>this._data[t],validate:a}:i={label:(e==null?void 0:e.label)??t,required:(e==null?void 0:e.required)??!1,readOnly:!1,defaultValue:e==null?void 0:e.defaultValue,meta:r,get:()=>this._data[t],set:g=>{this._data[t]=g},validate:a},this._accessorCache.set(t,i),i}}function G(o,t,e,r){const s=new P(o,t,e,r);return new Proxy(s,{get(a,i,g){return i==="validate"||i==="toJSON"||i==="update"||i==="save"||i==="complete"||i==="progress"||i==="_ops"||i==="_data"||i==="_fields"||i==="_accessorCache"||i==="_getAccessor"||typeof i=="symbol"?Reflect.get(a,i,g):i==="_id"?a._id:a._getAccessor(i)},has(a,i){return typeof i=="symbol"?!1:i==="validate"||i==="toJSON"||i==="update"||i==="save"||i==="complete"||i==="progress"||i==="_id"?!0:i in a._fields},ownKeys(a){return[...Object.keys(a._fields),"_id","validate","toJSON","update","save","complete","progress"]},getOwnPropertyDescriptor(a,i){if(typeof i!="symbol")return{configurable:!0,enumerable:i!=="validate"&&i!=="toJSON"&&i!=="update"&&i!=="save"&&i!=="complete"&&i!=="progress"}}})}class K{constructor(){O(this,"_fieldsCache",null)}_ops(){return new C(this.meta.businessProcessId).activity(this.meta.activityId)}_discoverFields(){if(this._fieldsCache)return this._fieldsCache;const t={};for(const e of Object.keys(this)){const r=this[e];r instanceof U.BaseField&&(t[e]=r)}return this._fieldsCache=t,t}async getInProgressList(){return this._ops().inProgressList()}async getCompletedList(){return this._ops().completedList()}async inProgressMetrics(){return this._ops().inProgressMetric()}async completedMetrics(){return this._ops().completedMetric()}async getInstance(t){const e=this._ops(),r=await e.read(t),s=this._discoverFields();return G(e,t,r,s)}_getFields(){return this._discoverFields()}_getOps(){return this._ops()}}function W(o){return async(t,e,r)=>{const s={},a=o._getFields(),i=(r==null?void 0:r.names)??Object.keys(a);for(const g of i){const w=a[g];if(!w||w.readOnly)continue;const S=t[g],$=w.validate(S);!$.valid&&$.errors.length>0&&(s[g]={type:"validate",message:$.errors[0]||`${g} is invalid`})}return Object.keys(s).length===0?{values:t,errors:{}}:{values:{},errors:s}}}function z(o,t){const e=o._getFields();return new Proxy({},{get(r,s){if(typeof s=="symbol")return;if(s==="toJSON")return()=>t.getValues();if(s==="validate")return()=>t.trigger();const a=e[s],i=(a==null?void 0:a.meta)??{_id:s,Name:s,Type:"String"},g=(a==null?void 0:a.readOnly)??!1,w=()=>a?a.validate(t.getValues(s)):{valid:!0,errors:[]};return g?{label:(a==null?void 0:a.label)??s,required:(a==null?void 0:a.required)??!1,readOnly:!0,defaultValue:a==null?void 0:a.defaultValue,meta:i,get:()=>t.getValues(s),getOrDefault:$=>t.getValues(s)??$,validate:w}:{label:(a==null?void 0:a.label)??s,required:(a==null?void 0:a.required)??!1,readOnly:!1,defaultValue:a==null?void 0:a.defaultValue,meta:i,get:()=>t.getValues(s),getOrDefault:b=>t.getValues(s)??b,set:b=>{t.setValue(s,b,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!1})},validate:w}},has(r,s){return typeof s=="symbol"?!1:s==="toJSON"||s==="validate"?!0:s in e},ownKeys(r){return[...Object.keys(e),"toJSON","validate"]},getOwnPropertyDescriptor(r,s){if(typeof s!="symbol")return{configurable:!0,enumerable:s!=="toJSON"&&s!=="validate"}}})}function Q(o,t){const{activity_instance_id:e,defaultValues:r={},mode:s="onBlur",enabled:a=!0}=t,[i,g]=f.useState(!1),[w,S]=f.useState(null),[$,b]=f.useState(!1),V=f.useRef(!1),j=f.useRef(null),T=f.useMemo(()=>o._getFields(),[o]),p=f.useMemo(()=>Object.keys(T).filter(d=>T[d].readOnly),[T]),x=f.useMemo(()=>W(o),[o]),n=L.useForm({mode:s,defaultValues:r,resolver:x}),E=f.useMemo(()=>z(o,n),[o,n]),v=f.useMemo(()=>o._getOps(),[o]);f.useEffect(()=>{if(!a)return;let d=!0;return(async()=>{g(!0),S(null);try{const u=await v.read(e);if(!d)return;u&&typeof u=="object"&&n.reset({...r,...u})}catch(u){if(!d)return;console.error("Failed to read activity data:",u),S(B.toError(u))}finally{d&&g(!1)}})(),()=>{d=!1}},[a,v,e]);const k=f.useCallback(async d=>{p.length!==0&&(V.current||(j.current&&clearTimeout(j.current),j.current=setTimeout(async()=>{if(!V.current){V.current=!0;try{const c=n.getValues(),u={},h=new Set(p);Object.keys(c).forEach(m=>{h.has(m)||(u[m]=c[m])});const y=await v.draftStart(e,u);y&&typeof y=="object"&&Object.entries(y).forEach(([m,_])=>{h.has(m)&&n.getValues(m)!==_&&n.setValue(m,_,{shouldDirty:!1,shouldValidate:!1})})}catch(c){console.warn("Draft computation failed:",c)}finally{V.current=!1}}},300)))},[v,p,n]),N=f.useCallback((d,c)=>{const u=T[d],h=u?u.readOnly:!1,y=c==null?void 0:c.onBlur,m=async D=>{y&&await y(D);let A=!0;s==="onBlur"||s==="onTouched"||s==="all"?A=await n.trigger(d):A=!n.getFieldState(d,n.formState).error,A&&await k(d)},_=n.register(d,{...c,onBlur:m,...h?{disabled:!0}:{}});return h?{..._,disabled:!0}:_},[n,T,k,s]),H=f.useCallback((d,c)=>n.handleSubmit(async(u,h)=>{b(!0);try{const y={},m=new Set(p);Object.keys(u).forEach(_=>{!m.has(_)&&u[_]!==void 0&&(y[_]=u[_])}),await v.update(e,y),await v.draftEnd(e,y),await(d==null?void 0:d(u,h))}catch(y){c==null||c(B.toError(y),h)}finally{b(!1)}},(u,h)=>{c==null||c(u,h)}),[n,v,p]),M=f.useCallback((d,c)=>n.handleSubmit(async(u,h)=>{b(!0);try{await v.complete(e),await(d==null?void 0:d(u,h))}catch(y){c==null||c(B.toError(y),h)}finally{b(!1)}},(u,h)=>{c==null||c(u,h)}),[n,v]),q=f.useCallback(()=>{n.clearErrors()},[n]),F=!!w;return{item:E,activity:o,register:N,handleSubmit:H,handleComplete:M,watch:n.watch,setValue:n.setValue,getValues:n.getValues,reset:n.reset,trigger:n.trigger,control:n.control,errors:n.formState.errors,isValid:n.formState.isValid,isDirty:n.formState.isDirty,isSubmitting:n.formState.isSubmitting||$,isSubmitSuccessful:n.formState.isSubmitSuccessful,isLoading:i,loadError:w,hasError:F,clearErrors:q}}exports.Activity=K;exports.ActivityInstance=P;exports.Workflow=C;exports.useActivityForm=Q;
1
+ "use strict";var J=Object.defineProperty;var U=(o,t,e)=>t in o?J(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var p=(o,t,e)=>U(o,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./client-BnVxSHAm.cjs"),G=require("./BaseField-Drp0-OxL.cjs"),h=require("react"),I=require("./index.esm-DuwT11sx.cjs"),j=require("./error-handling-CAoD0Kwb.cjs"),M=require("@tanstack/react-query");class q{constructor(t){p(this,"bp_id");this.bp_id=t}async start(){const t=await fetch(`${l.getApiBaseUrl()}/api/app/process/${this.bp_id}/start`,{method:"POST",headers:l.getDefaultHeaders()});if(!t.ok)throw new Error(`Failed to start process: ${t.statusText}`);return(await t.json()).Data}async progress(t){const e=await fetch(`${l.getApiBaseUrl()}/api/app/process/${this.bp_id}/${t}/progress`,{method:"GET",headers:l.getDefaultHeaders()});if(!e.ok)throw new Error(`Failed to get process progress: ${e.statusText}`);return(await e.json()).Data}activity(t){const e=`/api/app/process/${this.bp_id}/${t}`;return{async inProgressList(){const a=await fetch(`${l.getApiBaseUrl()}${e}/inprogress/list`,{method:"GET",headers:l.getDefaultHeaders()});if(!a.ok)throw new Error(`Failed to list in-progress activities: ${a.statusText}`);return a.json()},async completedList(){const a=await fetch(`${l.getApiBaseUrl()}${e}/completed/list`,{method:"GET",headers:l.getDefaultHeaders()});if(!a.ok)throw new Error(`Failed to list completed activities: ${a.statusText}`);return a.json()},async inProgressMetric(){const a=await fetch(`${l.getApiBaseUrl()}${e}/inprogress/metric`,{method:"GET",headers:l.getDefaultHeaders()});if(!a.ok)throw new Error(`Failed to get in-progress activity metrics: ${a.statusText}`);return a.json()},async completedMetric(){const a=await fetch(`${l.getApiBaseUrl()}${e}/completed/metric`,{method:"GET",headers:l.getDefaultHeaders()});if(!a.ok)throw new Error(`Failed to get completed activity metrics: ${a.statusText}`);return a.json()},async read(a){const s=await fetch(`${l.getApiBaseUrl()}${e}/${a}/read`,{method:"GET",headers:l.getDefaultHeaders()});if(!s.ok)throw new Error(`Failed to read activity: ${s.statusText}`);return(await s.json()).Data},async update(a,s){const r=await fetch(`${l.getApiBaseUrl()}${e}/${a}/update`,{method:"POST",headers:l.getDefaultHeaders(),body:JSON.stringify(s)});if(!r.ok)throw new Error(`Failed to update activity: ${r.statusText}`);return r.json()},async draftStart(a,s){const r=await fetch(`${l.getApiBaseUrl()}${e}/${a}/draft`,{method:"PATCH",headers:l.getDefaultHeaders(),body:JSON.stringify(s)});if(!r.ok)throw new Error(`Failed to start draft: ${r.statusText}`);return r.json()},async draftEnd(a,s){const r=await fetch(`${l.getApiBaseUrl()}${e}/${a}/draft`,{method:"POST",headers:l.getDefaultHeaders(),body:JSON.stringify(s)});if(!r.ok)throw new Error(`Failed to end draft: ${r.statusText}`);return r.json()},async complete(a){const s=await fetch(`${l.getApiBaseUrl()}${e}/${a}/done`,{method:"POST",headers:l.getDefaultHeaders()});if(!s.ok)throw new Error(`Failed to complete activity: ${s.statusText}`);return s.json()},async progress(a){const s=await fetch(`${l.getApiBaseUrl()}${e}/${a}/progress`,{method:"GET",headers:l.getDefaultHeaders()});if(!s.ok)throw new Error(`Failed to get activity progress: ${s.statusText}`);return s.json()}}}}class F{constructor(t,e,a,s){p(this,"_id");p(this,"_data");p(this,"_ops");p(this,"_fields");p(this,"_accessorCache",new Map);this._ops=t,this._id=e,this._data={...a},this._fields=s}toJSON(){return{...this._data}}validate(){const t=[];for(const[e,a]of Object.entries(this._fields)){const s=this._data[e],r=a.validate(s);r.valid||t.push(...r.errors)}return{valid:t.length===0,errors:t}}async update(t){return this._ops.update(this._id,t)}async save(t){return this._ops.draftEnd(this._id,t)}async complete(){return this._ops.complete(this._id)}async progress(){return this._ops.progress(this._id)}_getAccessor(t){if(this._accessorCache.has(t))return this._accessorCache.get(t);const e=this._fields[t],a=(e==null?void 0:e.meta)??{_id:t,Name:t,Type:"String"},s=(e==null?void 0:e.readOnly)??!1,r=()=>e?e.validate(this._data[t]):{valid:!0,errors:[]};let i;return s?i={label:(e==null?void 0:e.label)??t,required:(e==null?void 0:e.required)??!1,readOnly:!0,defaultValue:e==null?void 0:e.defaultValue,meta:a,get:()=>this._data[t],validate:r}:i={label:(e==null?void 0:e.label)??t,required:(e==null?void 0:e.required)??!1,readOnly:!1,defaultValue:e==null?void 0:e.defaultValue,meta:a,get:()=>this._data[t],set:f=>{this._data[t]=f},validate:r},this._accessorCache.set(t,i),i}}function K(o,t,e,a){const s=new F(o,t,e,a);return new Proxy(s,{get(r,i,f){return i==="validate"||i==="toJSON"||i==="update"||i==="save"||i==="complete"||i==="progress"||i==="_ops"||i==="_data"||i==="_fields"||i==="_accessorCache"||i==="_getAccessor"||typeof i=="symbol"?Reflect.get(r,i,f):i==="_id"?r._id:r._getAccessor(i)},has(r,i){return typeof i=="symbol"?!1:i==="validate"||i==="toJSON"||i==="update"||i==="save"||i==="complete"||i==="progress"||i==="_id"?!0:i in r._fields},ownKeys(r){return[...Object.keys(r._fields),"_id","validate","toJSON","update","save","complete","progress"]},getOwnPropertyDescriptor(r,i){if(typeof i!="symbol")return{configurable:!0,enumerable:i!=="validate"&&i!=="toJSON"&&i!=="update"&&i!=="save"&&i!=="complete"&&i!=="progress"}}})}class Q{constructor(){p(this,"_fieldsCache",null)}_ops(){return new q(this.meta.businessProcessId).activity(this.meta.activityId)}_discoverFields(){if(this._fieldsCache)return this._fieldsCache;const t={};for(const e of Object.keys(this)){const a=this[e];a instanceof G.BaseField&&(t[e]=a)}return this._fieldsCache=t,t}async getInProgressList(){return this._ops().inProgressList()}async getCompletedList(){return this._ops().completedList()}async inProgressMetrics(){return this._ops().inProgressMetric()}async completedMetrics(){return this._ops().completedMetric()}async getInstance(t){const e=this._ops(),a=await e.read(t),s=this._discoverFields();return K(e,t,a,s)}_getFields(){return this._discoverFields()}_getOps(){return this._ops()}}function W(o){return async(t,e,a)=>{const s={},r=o._getFields(),i=(a==null?void 0:a.names)??Object.keys(r);for(const f of i){const _=r[f];if(!_||_.readOnly)continue;const V=t[f],w=_.validate(V);!w.valid&&w.errors.length>0&&(s[f]={type:"validate",message:w.errors[0]||`${f} is invalid`})}return Object.keys(s).length===0?{values:t,errors:{}}:{values:{},errors:s}}}function z(o,t){const e=o._getFields();return new Proxy({},{get(a,s){if(typeof s=="symbol")return;if(s==="toJSON")return()=>t.getValues();if(s==="validate")return()=>t.trigger();const r=e[s],i=(r==null?void 0:r.meta)??{_id:s,Name:s,Type:"String"},f=(r==null?void 0:r.readOnly)??!1,_=()=>r?r.validate(t.getValues(s)):{valid:!0,errors:[]};return f?{label:(r==null?void 0:r.label)??s,required:(r==null?void 0:r.required)??!1,readOnly:!0,defaultValue:r==null?void 0:r.defaultValue,meta:i,get:()=>t.getValues(s),getOrDefault:w=>t.getValues(s)??w,validate:_}:{label:(r==null?void 0:r.label)??s,required:(r==null?void 0:r.required)??!1,readOnly:!1,defaultValue:r==null?void 0:r.defaultValue,meta:i,get:()=>t.getValues(s),getOrDefault:v=>t.getValues(s)??v,set:v=>{t.setValue(s,v,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!1})},validate:_}},has(a,s){return typeof s=="symbol"?!1:s==="toJSON"||s==="validate"?!0:s in e},ownKeys(a){return[...Object.keys(e),"toJSON","validate"]},getOwnPropertyDescriptor(a,s){if(typeof s!="symbol")return{configurable:!0,enumerable:s!=="toJSON"&&s!=="validate"}}})}function X(o,t){const{activity_instance_id:e,defaultValues:a={},mode:s="onBlur",enabled:r=!0}=t,[i,f]=h.useState(!1),[_,V]=h.useState(null),[w,v]=h.useState(!1),O=h.useRef(!1),P=h.useRef(null),A=h.useMemo(()=>o._getFields(),[o]),T=h.useMemo(()=>Object.keys(A).filter(d=>A[d].readOnly),[A]),D=h.useMemo(()=>W(o),[o]),n=I.useForm({mode:s,defaultValues:a,resolver:D}),E=h.useMemo(()=>z(o,n),[o,n]),b=h.useMemo(()=>o._getOps(),[o]);h.useEffect(()=>{if(!r)return;let d=!0;return(async()=>{f(!0),V(null);try{const u=await b.read(e);if(!d)return;u&&typeof u=="object"&&n.reset({...a,...u})}catch(u){if(!d)return;console.error("Failed to read activity data:",u),V(j.toError(u))}finally{d&&f(!1)}})(),()=>{d=!1}},[r,b,e]);const g=h.useCallback(async d=>{T.length!==0&&(O.current||(P.current&&clearTimeout(P.current),P.current=setTimeout(async()=>{if(!O.current){O.current=!0;try{const c=n.getValues(),u={},y=new Set(T);Object.keys(c).forEach($=>{y.has($)||(u[$]=c[$])});const m=await b.draftStart(e,u);m&&typeof m=="object"&&Object.entries(m).forEach(([$,S])=>{y.has($)&&n.getValues($)!==S&&n.setValue($,S,{shouldDirty:!1,shouldValidate:!1})})}catch(c){console.warn("Draft computation failed:",c)}finally{O.current=!1}}},300)))},[b,T,n]),x=h.useCallback((d,c)=>{const u=A[d],y=u?u.readOnly:!1,m=c==null?void 0:c.onBlur,$=async C=>{m&&await m(C);let k=!0;s==="onBlur"||s==="onTouched"||s==="all"?k=await n.trigger(d):k=!n.getFieldState(d,n.formState).error,k&&await g(d)},S=n.register(d,{...c,onBlur:$,...y?{disabled:!0}:{}});return y?{...S,disabled:!0}:S},[n,A,g,s]),N=h.useCallback((d,c)=>n.handleSubmit(async(u,y)=>{v(!0);try{const m={},$=new Set(T);Object.keys(u).forEach(S=>{!$.has(S)&&u[S]!==void 0&&(m[S]=u[S])}),await b.update(e,m),await b.draftEnd(e,m),await(d==null?void 0:d(u,y))}catch(m){c==null||c(j.toError(m),y)}finally{v(!1)}},(u,y)=>{c==null||c(u,y)}),[n,b,T]),L=h.useCallback((d,c)=>n.handleSubmit(async(u,y)=>{v(!0);try{await b.complete(e),await(d==null?void 0:d(u,y))}catch(m){c==null||c(j.toError(m),y)}finally{v(!1)}},(u,y)=>{c==null||c(u,y)}),[n,b]),R=h.useCallback(()=>{n.clearErrors()},[n]),H=!!_;return{item:E,activity:o,register:x,handleSubmit:N,handleComplete:L,watch:n.watch,setValue:n.setValue,getValues:n.getValues,reset:n.reset,trigger:n.trigger,control:n.control,errors:n.formState.errors,isValid:n.formState.isValid,isDirty:n.formState.isDirty,isSubmitting:n.formState.isSubmitting||w,isSubmitSuccessful:n.formState.isSubmitSuccessful,isLoading:i,loadError:_,hasError:H,clearErrors:R}}const B={InProgress:"inprogress",Completed:"completed"};function Y(o,t){const{status:e,onError:a,onSuccess:s}=t,{businessProcessId:r,activityId:i}=o.meta,{data:f,isLoading:_,isFetching:V,error:w,refetch:v}=M.useQuery({queryKey:["activity-table",r,i,e],queryFn:async()=>{try{const g=e===B.InProgress?await o.getInProgressList():await o.getCompletedList();return s&&s(g.Data),g}catch(g){throw a&&a(j.toError(g)),g}},staleTime:0,gcTime:30*1e3}),{data:O,isLoading:P,isFetching:A,error:T,refetch:D}=M.useQuery({queryKey:["activity-table-count",r,i,e],queryFn:async()=>{try{return e===B.InProgress?await o.inProgressMetrics():await o.completedMetrics()}catch(g){throw a&&a(j.toError(g)),g}},staleTime:0,gcTime:30*1e3}),n=h.useMemo(()=>(f==null?void 0:f.Data)||[],[f]),E=h.useMemo(()=>{var g;return((g=O==null?void 0:O.Data[0])==null?void 0:g.count__id)??0},[O]),b=h.useCallback(async()=>{const[g]=await Promise.all([v(),D()]);return g.data||{Data:[]}},[v,D]);return{rows:n,totalItems:E,isLoading:_||P,isFetching:V||A,error:w?j.toError(w):T?j.toError(T):null,refetch:b}}exports.Activity=Q;exports.ActivityInstance=F;exports.ActivityTableStatus=B;exports.Workflow=q;exports.useActivityForm=X;exports.useActivityTable=Y;
@@ -5,4 +5,6 @@ export type { ActivityInstanceType, EditableFieldAccessor, ReadonlyFieldAccessor
5
5
  export type { ActivityInstanceFieldsType, ActivityOperations, ActivityProgressType, WorkflowStartResponseType, } from './workflow/types';
6
6
  export { useActivityForm } from './workflow/components/useActivityForm';
7
7
  export type { UseActivityFormOptions, UseActivityFormReturn, } from './workflow/components/useActivityForm';
8
+ export { useActivityTable, ActivityTableStatus } from './workflow/components/useActivityTable';
9
+ export type { UseActivityTableOptionsType, UseActivityTableReturnType, ActivityRowType, } from './workflow/components/useActivityTable';
8
10
  //# sourceMappingURL=workflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../sdk/workflow.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../sdk/workflow.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,0BAA0B,EAC1B,kBAAkB,EAClB,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC/F,YAAY,EACV,2BAA2B,EAC3B,0BAA0B,EAC1B,eAAe,GAChB,MAAM,wCAAwC,CAAC"}