@ram_28/kf-ai-sdk 2.0.18 → 2.0.20-beta.0

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 (107) hide show
  1. package/README.md +8 -16
  2. package/dist/{FileField-CZjS2uLh.js → FileField-BWrSHNRq.js} +3 -3
  3. package/dist/{FileField-DU4UWo_t.cjs → FileField-eDeuzln8.cjs} +1 -1
  4. package/dist/api.cjs +1 -1
  5. package/dist/api.mjs +1 -1
  6. package/dist/auth/authClient.d.ts.map +1 -1
  7. package/dist/auth/authConfig.d.ts +1 -1
  8. package/dist/auth/types.d.ts +1 -1
  9. package/dist/auth/types.d.ts.map +1 -1
  10. package/dist/auth.cjs +1 -1
  11. package/dist/auth.mjs +102 -106
  12. package/dist/bdo/core/Item.d.ts +4 -0
  13. package/dist/bdo/core/Item.d.ts.map +1 -1
  14. package/dist/bdo/fields/ReferenceField.d.ts +1 -1
  15. package/dist/bdo/fields/ReferenceField.d.ts.map +1 -1
  16. package/dist/bdo/fields/SelectField.d.ts +1 -1
  17. package/dist/bdo/fields/SelectField.d.ts.map +1 -1
  18. package/dist/bdo/fields/UserField.d.ts +1 -1
  19. package/dist/bdo/fields/UserField.d.ts.map +1 -1
  20. package/dist/bdo.cjs +1 -1
  21. package/dist/bdo.mjs +62 -53
  22. package/dist/components/hooks/useActivityForm/types.d.ts +5 -4
  23. package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -1
  24. package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -1
  25. package/dist/components/hooks/useActivityTable/types.d.ts +4 -5
  26. package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -1
  27. package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -1
  28. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts +3 -2
  29. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -1
  30. package/dist/components/hooks/useBDOTable/types.d.ts +12 -20
  31. package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -1
  32. package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +2 -2
  33. package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -1
  34. package/dist/{constants-Cyi942Yr.js → constants-ConHc1oS.js} +5 -5
  35. package/dist/constants-QX2RX-wu.cjs +1 -0
  36. package/dist/filter.cjs +1 -1
  37. package/dist/filter.mjs +1 -1
  38. package/dist/form.cjs +1 -1
  39. package/dist/form.mjs +243 -226
  40. package/dist/table.cjs +1 -1
  41. package/dist/table.mjs +16 -15
  42. package/dist/table.types.d.ts +1 -1
  43. package/dist/table.types.d.ts.map +1 -1
  44. package/dist/types/constants.d.ts +1 -1
  45. package/dist/workflow/Activity.d.ts +5 -8
  46. package/dist/workflow/Activity.d.ts.map +1 -1
  47. package/dist/workflow.cjs +1 -1
  48. package/dist/workflow.mjs +476 -461
  49. package/docs/api.md +95 -0
  50. package/docs/bdo.md +224 -0
  51. package/docs/gaps.md +360 -0
  52. package/docs/useActivityForm.md +393 -0
  53. package/docs/useActivityTable.md +418 -0
  54. package/docs/useBDOForm.md +498 -0
  55. package/docs/useBDOTable.md +284 -0
  56. package/docs/useFilter.md +188 -0
  57. package/docs/workflow.md +560 -0
  58. package/package.json +14 -15
  59. package/sdk/auth/authClient.ts +15 -21
  60. package/sdk/auth/authConfig.ts +1 -1
  61. package/sdk/auth/types.ts +1 -1
  62. package/sdk/bdo/core/Item.ts +10 -1
  63. package/sdk/bdo/fields/ReferenceField.ts +1 -1
  64. package/sdk/bdo/fields/SelectField.ts +1 -1
  65. package/sdk/bdo/fields/UserField.ts +1 -1
  66. package/sdk/components/hooks/useActivityForm/types.ts +6 -4
  67. package/sdk/components/hooks/useActivityForm/useActivityForm.ts +73 -10
  68. package/sdk/components/hooks/useActivityTable/types.ts +5 -4
  69. package/sdk/components/hooks/useActivityTable/useActivityTable.ts +8 -10
  70. package/sdk/components/hooks/useBDOForm/createItemProxy.ts +58 -17
  71. package/sdk/components/hooks/useBDOTable/types.ts +10 -20
  72. package/sdk/components/hooks/useBDOTable/useBDOTable.ts +8 -12
  73. package/sdk/table.types.ts +0 -2
  74. package/sdk/types/constants.ts +1 -1
  75. package/sdk/workflow/Activity.ts +7 -39
  76. package/dist/constants-DEmYwKfC.cjs +0 -1
  77. package/docs/README.md +0 -57
  78. package/docs/bdo/README.md +0 -161
  79. package/docs/bdo/api_reference.md +0 -281
  80. package/docs/examples/bdo/create-product.md +0 -69
  81. package/docs/examples/bdo/edit-product-dialog.md +0 -95
  82. package/docs/examples/bdo/filtered-product-table.md +0 -100
  83. package/docs/examples/bdo/product-listing.md +0 -73
  84. package/docs/examples/bdo/supplier-dropdown.md +0 -60
  85. package/docs/examples/fields/complex-fields.md +0 -248
  86. package/docs/examples/fields/primitive-fields.md +0 -217
  87. package/docs/examples/workflow/approve-leave-request.md +0 -76
  88. package/docs/examples/workflow/filtered-activity-table.md +0 -101
  89. package/docs/examples/workflow/my-pending-requests.md +0 -90
  90. package/docs/examples/workflow/start-new-workflow.md +0 -47
  91. package/docs/examples/workflow/submit-leave-request.md +0 -72
  92. package/docs/examples/workflow/workflow-progress.md +0 -49
  93. package/docs/fields/README.md +0 -141
  94. package/docs/fields/api_reference.md +0 -134
  95. package/docs/useActivityForm/README.md +0 -244
  96. package/docs/useActivityForm/api_reference.md +0 -279
  97. package/docs/useActivityTable/README.md +0 -263
  98. package/docs/useActivityTable/api_reference.md +0 -294
  99. package/docs/useBDOForm/README.md +0 -175
  100. package/docs/useBDOForm/api_reference.md +0 -244
  101. package/docs/useBDOTable/README.md +0 -242
  102. package/docs/useBDOTable/api_reference.md +0 -253
  103. package/docs/useFilter/README.md +0 -323
  104. package/docs/useFilter/api_reference.md +0 -228
  105. package/docs/workflow/README.md +0 -158
  106. package/docs/workflow/api_reference.md +0 -161
  107. /package/docs/{useAuth/README.md → useAuth.md} +0 -0
package/dist/bdo.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var T=(r,e,t)=>e in r?E(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var m=(r,e,t)=>T(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./client-D5k4SYuw.cjs"),w=require("./attachment-constants-B5jlqoKI.cjs"),o=require("./FileField-DU4UWo_t.cjs"),U=require("./constants-DEmYwKfC.cjs");class x{constructor(e,t){m(this,"_data");m(this,"_bdo");m(this,"_accessorCache",new Map);return this._bdo=e,this._data={...t},new Proxy(this,{get(a,s,n){return s==="validate"||s==="toJSON"||s==="_bdo"||s==="_data"||s==="_accessorCache"||s==="_getAccessor"||s==="_requireInstanceId"||typeof s=="symbol"?Reflect.get(a,s,n):s==="_id"?a._data._id:a._getAccessor(s)},set(a,s,n){return s==="_bdo"||s==="_data"||s==="_accessorCache"||s==="validate"||s==="toJSON"?!1:typeof s=="symbol"?Reflect.set(a,s,n):(a._data[s]=n,!0)},has(a,s){return s==="validate"||s==="toJSON"?!0:s in a._data||s in a._bdo.getFields()},ownKeys(a){return[...Object.keys(a._bdo.getFields()),"validate","toJSON"]},getOwnPropertyDescriptor(a,s){if(s==="validate"||s==="toJSON")return{configurable:!0,enumerable:!1,value:a[s]};const n=a._bdo.getFields();if(s in n||s in a._data)return{configurable:!0,enumerable:!0,get:()=>a._getAccessor(s)}}})}_requireInstanceId(){return this._data._id||"draft"}_getAccessor(e){if(this._accessorCache.has(e))return this._accessorCache.get(e);const a=this._bdo.getFields()[e],s=(a==null?void 0:a.meta)??{_id:e,Name:e,Type:"String"},n=(a==null?void 0:a.readOnly)??!1,d=()=>{if(a){const _=a.validate(this._data[e]);if(!_.valid)return _}return this._bdo.hasMetadata()?this._bdo.validateFieldExpression(e,this._data[e],this.toJSON()):{valid:!0,errors:[]}},h=_=>{const f=this._data[e];return f??_};let y;if(n?y={label:(a==null?void 0:a.label)??e,required:(a==null?void 0:a.required)??!1,readOnly:!0,defaultValue:a==null?void 0:a.defaultValue,meta:s,get:()=>this._data[e],getOrDefault:h,validate:d}:y={label:(a==null?void 0:a.label)??e,required:(a==null?void 0:a.required)??!1,readOnly:!1,defaultValue:a==null?void 0:a.defaultValue,meta:s,get:()=>this._data[e],getOrDefault:h,set:_=>{this._data[e]=_},validate:d},s.Type==="Image"||s.Type==="File"){const _=this._bdo.getBoId(),f=y;s.Type==="Image"?(f.getDownloadUrl=async l=>{const c=this._requireInstanceId(),g=this._data[e];if(!(g!=null&&g._id))throw new Error(`${e} has no image to download`);return i.api(_).getDownloadUrl(c,e,g._id,l)},n||(f.upload=async l=>{w.validateFileExtension(l.name,"Image");const c=this._requireInstanceId(),g={FileName:l.name,Size:l.size,FileExtension:w.extractFileExtension(l.name)},[u]=await i.api(_).getUploadUrl(c,e,[g]);await fetch(u.UploadUrl.URL,{method:"PUT",headers:{"Content-Type":u.ContentType},body:l});const F={_id:u._id,_name:u._name,FileName:u.FileName,FileExtension:u.FileExtension,Size:u.Size,ContentType:u.ContentType};return this._data[e]=F,F},f.deleteAttachment=async()=>{const l=this._requireInstanceId(),c=this._data[e];if(!(c!=null&&c._id))throw new Error(`${e} has no image to delete`);await i.api(_).deleteAttachment(l,e,c._id),this._data[e]=null})):(f.getDownloadUrl=async(l,c)=>{const g=this._requireInstanceId();return i.api(_).getDownloadUrl(g,e,l,c)},f.getDownloadUrls=async l=>{const c=this._requireInstanceId();return i.api(_).getDownloadUrls(c,e,l)},n||(f.upload=async l=>{for(const b of l)w.validateFileExtension(b.name,"File");const c=this._requireInstanceId(),g=l.map(b=>({FileName:b.name,Size:b.size,FileExtension:w.extractFileExtension(b.name)})),u=await i.api(_).getUploadUrl(c,e,g),F=await Promise.all(l.map(async(b,p)=>(await fetch(u[p].UploadUrl.URL,{method:"PUT",headers:{"Content-Type":u[p].ContentType},body:b}),{_id:u[p]._id,_name:u[p]._name,FileName:u[p].FileName,FileExtension:u[p].FileExtension,Size:u[p].Size,ContentType:u[p].ContentType}))),v=this._data[e]??[];return this._data[e]=[...v,...F],F},f.deleteAttachment=async l=>{const c=this._requireInstanceId();await i.api(_).deleteAttachment(c,e,l);const g=this._data[e]??[];this._data[e]=g.filter(u=>u._id!==l)}))}return this._accessorCache.set(e,y),y}validate(){const e=this._bdo.getFields(),t=[],a=this.toJSON();for(const[s,n]of Object.entries(e)){if(n.readOnly)continue;const d=this._data[s],h=n.validate(d);if(!h.valid){t.push(...h.errors);continue}if(this._bdo.hasMetadata()){const y=this._bdo.validateFieldExpression(s,d,a);y.valid||t.push(...y.errors)}}return{valid:t.length===0,errors:t}}toJSON(){return{...this._data}}}const A={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,a)=>t+Number(a),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),a=new Date(e);if(isNaN(t.getTime())||isNaN(a.getTime()))return 0;const s=Math.abs(t.getTime()-a.getTime());return Math.ceil(s/(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 S(){const r=new Date;return{NOW:r,TODAY:new Date(r.getFullYear(),r.getMonth(),r.getDate()),CURRENT_USER:{Id:"",Email:"",FirstName:"",LastName:""}}}function N(r,e){var t;switch(r.Type){case"Literal":return r.Value;case"Identifier":return e.formValues[r.Name];case"SystemIdentifier":return O(r,e);case"BinaryExpression":return R(r,e);case"LogicalExpression":return D(r,e);case"CallExpression":return C(r,e);case"MemberExpression":return M(r,e);case"AssignmentExpression":return((t=r.Arguments)==null?void 0:t.length)===1?N(r.Arguments[0],e):void 0;default:throw new Error(`Unsupported expression type: ${r.Type}`)}}function O(r,e){const t=r.Name,a=e.systemValues[t];return r.Property?a&&typeof a=="object"?a[r.Property.Name]:void 0:a}function R(r,e){if(!r.Arguments||r.Arguments.length<2)throw new Error("BinaryExpression requires 2 arguments");const[t,a]=r.Arguments,s=N(t,e),n=N(a,e);switch(r.Operator){case"==":return s==n;case"!=":return s!=n;case"<":return Number(s)<Number(n);case"<=":return Number(s)<=Number(n);case">":return Number(s)>Number(n);case">=":return Number(s)>=Number(n);case"+":return Number(s)+Number(n);case"-":return Number(s)-Number(n);case"*":return Number(s)*Number(n);case"/":return Number(n)!==0?Number(s)/Number(n):0;case"%":return Number(s)%Number(n);default:throw new Error(`Unsupported binary operator: ${r.Operator}`)}}function D(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(a=>!!N(a,e));case"OR":return t.some(a=>!!N(a,e));case"!":return!N(t[0],e);default:throw new Error(`Unsupported logical operator: ${r.Operator}`)}}function C(r,e){if(!r.Callee)throw new Error("CallExpression requires a Callee");const t=A[r.Callee];if(!t)throw new Error(`Unknown function: ${r.Callee}`);const a=(r.Arguments??[]).map(s=>N(s,e));return t(...a)}function M(r,e){var s,n;if(!((s=r.Arguments)!=null&&s.length))return;const t=N(r.Arguments[0],e),a=(n=r.Arguments[0].Property)==null?void 0:n.Name;return a&&t&&typeof t=="object"?t[a]:t}class B{constructor(){m(this,"fieldRules",new Map);m(this,"metadata",null)}loadMetadata(e){var t,a;this.metadata=e,this.fieldRules.clear();for(const[s,n]of Object.entries(e.Fields)){const d=[];if(n.Validation&&Array.isArray(n.Validation)){for(const h of n.Validation)if(typeof h=="object"&&h.ExpressionTree)d.push(h);else if(typeof h=="string"){const y=(a=(t=e.Rules)==null?void 0:t.Validation)==null?void 0:a[h];y&&d.push(y)}}d.length>0&&this.fieldRules.set(s,d)}}hasMetadata(){return this.metadata!==null}getFieldRules(e){return this.fieldRules.get(e)??[]}validateField(e,t,a){const s=this.fieldRules.get(e);if(!s||s.length===0)return{valid:!0,errors:[]};const n={formValues:{...a,[e]:t},systemValues:S()};for(const d of s)try{if(!N(d.ExpressionTree,n))return{valid:!1,errors:[d.Message||`Validation failed: ${d.Name||d.Id}`]}}catch(h){console.warn(`Expression evaluation failed for rule ${d.Id}:`,h)}return{valid:!0,errors:[]}}validateAll(e){const t=[];for(const a of this.fieldRules.keys()){const s=this.validateField(a,e[a],e);s.valid||t.push(...s.errors)}return{valid:t.length===0,errors:t}}}class I{constructor(){m(this,"_id",new o.StringField({_id:"_id",Name:"ID",Type:"String",ReadOnly:!0}));m(this,"_created_at",new o.DateTimeField({_id:"_created_at",Name:"Created At",Type:"DateTime",ReadOnly:!0}));m(this,"_modified_at",new o.DateTimeField({_id:"_modified_at",Name:"Modified At",Type:"DateTime",ReadOnly:!0}));m(this,"_created_by",new o.UserField({_id:"_created_by",Name:"Created By",Type:"User",ReadOnly:!0}));m(this,"_modified_by",new o.UserField({_id:"_modified_by",Name:"Modified By",Type:"User",ReadOnly:!0}));m(this,"_version",new o.StringField({_id:"_version",Name:"Version",Type:"String",ReadOnly:!0}));m(this,"_m_version",new o.StringField({_id:"_m_version",Name:"Metadata Version",Type:"String",ReadOnly:!0}));m(this,"_fieldsBound",!1);m(this,"_fieldsCache",null);m(this,"_expressionEngine",new B)}getBoId(){return this.meta._id}getFields(){if(this._fieldsCache)return this._fieldsCache;const e={};for(const t of Object.keys(this)){const a=this[t];a instanceof o.BaseField&&(e[t]=a)}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,a){return this._expressionEngine.hasMetadata()?this._expressionEngine.validateField(e,t,a):{valid:!0,errors:[]}}async get(e){const t=await i.api(this.meta._id).get(e);return new x(this,t)}async list(e){return(await i.api(this.meta._id).list(e)).Data.map(a=>new x(this,a))}async count(e){return(await i.api(this.meta._id).count(e)).Count}async create(e){const t=await i.api(this.meta._id).create(e);return new x(this,{...e,_id:t._id})}async update(e,t){return i.api(this.meta._id).update(e,t)}async delete(e){return i.api(this.meta._id).delete(e)}async draft(e){return i.api(this.meta._id).draft(e)}async draftInteraction(e){return i.api(this.meta._id).draftInteraction(e)}createItem(e){return new x(this,e??{})}async draftUpdate(e,t){return i.api(this.meta._id).draftUpdate(e,t)}async draftPatch(e,t){return i.api(this.meta._id).draftPatch(e,t)}async metric(e){return i.api(this.meta._id).metric(e)}async pivot(e){return i.api(this.meta._id).pivot(e)}async getUploadUrl(e,t,a){return i.api(this.meta._id).getUploadUrl(e,t,a)}async getDownloadUrl(e,t,a,s){return i.api(this.meta._id).getDownloadUrl(e,t,a,s)}async getDownloadUrls(e,t,a){return i.api(this.meta._id).getDownloadUrls(e,t,a)}async deleteAttachment(e,t,a){return i.api(this.meta._id).deleteAttachment(e,t,a)}}class q extends o.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 V extends o.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 j extends o.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=o.BaseField;exports.BooleanField=o.BooleanField;exports.DateField=o.DateField;exports.DateTimeField=o.DateTimeField;exports.FileField=o.FileField;exports.NumberField=o.NumberField;exports.ReferenceField=o.ReferenceField;exports.SelectField=o.SelectField;exports.StringField=o.StringField;exports.TextAreaField=o.TextField;exports.TextField=o.TextField;exports.UserField=o.UserField;exports.SystemField=U.SystemField;exports.ArrayField=q;exports.BaseBdo=I;exports.ImageField=j;exports.ObjectField=V;
1
+ "use strict";var E=Object.defineProperty;var T=(r,e,t)=>e in r?E(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var m=(r,e,t)=>T(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./client-D5k4SYuw.cjs"),w=require("./attachment-constants-B5jlqoKI.cjs"),o=require("./FileField-eDeuzln8.cjs"),U=require("./constants-QX2RX-wu.cjs");class x{constructor(e,t){m(this,"_data");m(this,"_bdo");m(this,"_accessorCache",new Map);return this._bdo=e,this._data={...t},new Proxy(this,{get(a,s,n){return s==="validate"||s==="toJSON"||s==="_bdo"||s==="_data"||s==="_accessorCache"||s==="_getAccessor"||s==="_requireInstanceId"||typeof s=="symbol"?Reflect.get(a,s,n):s==="_id"?a._data._id:a._getAccessor(s)},set(a,s,n){return s==="_bdo"||s==="_data"||s==="_accessorCache"||s==="validate"||s==="toJSON"?!1:typeof s=="symbol"?Reflect.set(a,s,n):(a._data[s]=n,!0)},has(a,s){return s==="validate"||s==="toJSON"?!0:s in a._data||s in a._bdo.getFields()},ownKeys(a){return[...Object.keys(a._bdo.getFields()),"validate","toJSON"]},getOwnPropertyDescriptor(a,s){if(s==="validate"||s==="toJSON")return{configurable:!0,enumerable:!1,value:a[s]};const n=a._bdo.getFields();if(s in n||s in a._data)return{configurable:!0,enumerable:!0,get:()=>a._getAccessor(s)}}})}_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 a=this._bdo.getFields()[e],s=(a==null?void 0:a.meta)??{_id:e,Name:e,Type:"String"},n=(a==null?void 0:a.readOnly)??!1,d=()=>{if(a){const _=a.validate(this._data[e]);if(!_.valid)return _}return this._bdo.hasMetadata()?this._bdo.validateFieldExpression(e,this._data[e],this.toJSON()):{valid:!0,errors:[]}},h=_=>{const f=this._data[e];return f??_};let y;if(n?y={label:(a==null?void 0:a.label)??e,required:(a==null?void 0:a.required)??!1,readOnly:!0,defaultValue:a==null?void 0:a.defaultValue,meta:s,get:()=>this._data[e],getOrDefault:h,validate:d}:y={label:(a==null?void 0:a.label)??e,required:(a==null?void 0:a.required)??!1,readOnly:!1,defaultValue:a==null?void 0:a.defaultValue,meta:s,get:()=>this._data[e],getOrDefault:h,set:_=>{this._data[e]=_},validate:d},s.Type==="Image"||s.Type==="File"){const _=this._bdo.getBoId(),f=y;s.Type==="Image"?(f.getDownloadUrl=async l=>{const c=this._requireInstanceId(),g=this._data[e];if(!(g!=null&&g._id))throw new Error(`${e} has no image to download`);return i.api(_).getDownloadUrl(c,e,g._id,l)},n||(f.upload=async l=>{w.validateFileExtension(l.name,"Image");const c=this._requireInstanceId(),g={FileName:l.name,Size:l.size,FileExtension:w.extractFileExtension(l.name)},[u]=await i.api(_).getUploadUrl(c,e,[g]);await fetch(u.UploadUrl.URL,{method:"PUT",headers:{"Content-Type":u.ContentType},body:l});const F={_id:u._id,_name:u._name,FileName:u.FileName,FileExtension:u.FileExtension,Size:u.Size,ContentType:u.ContentType};return this._data[e]=F,F},f.deleteAttachment=async()=>{const l=this._requireInstanceId(),c=this._data[e];if(!(c!=null&&c._id))throw new Error(`${e} has no image to delete`);await i.api(_).deleteAttachment(l,e,c._id),this._data[e]=null})):(f.getDownloadUrl=async(l,c)=>{const g=this._requireInstanceId();return i.api(_).getDownloadUrl(g,e,l,c)},f.getDownloadUrls=async l=>{const c=this._requireInstanceId();return i.api(_).getDownloadUrls(c,e,l)},n||(f.upload=async l=>{for(const b of l)w.validateFileExtension(b.name,"File");const c=this._requireInstanceId(),g=l.map(b=>({FileName:b.name,Size:b.size,FileExtension:w.extractFileExtension(b.name)})),u=await i.api(_).getUploadUrl(c,e,g),F=await Promise.all(l.map(async(b,N)=>(await fetch(u[N].UploadUrl.URL,{method:"PUT",headers:{"Content-Type":u[N].ContentType},body:b}),{_id:u[N]._id,_name:u[N]._name,FileName:u[N].FileName,FileExtension:u[N].FileExtension,Size:u[N].Size,ContentType:u[N].ContentType}))),v=this._data[e]??[];return this._data[e]=[...v,...F],F},f.deleteAttachment=async l=>{const c=this._requireInstanceId();await i.api(_).deleteAttachment(c,e,l);const g=this._data[e]??[];this._data[e]=g.filter(u=>u._id!==l)}))}return this._accessorCache.set(e,y),y}validate(){const e=this._bdo.getFields(),t=[],a=this.toJSON();for(const[s,n]of Object.entries(e)){if(n.readOnly)continue;const d=this._data[s],h=n.validate(d);if(!h.valid){t.push(...h.errors);continue}if(this._bdo.hasMetadata()){const y=this._bdo.validateFieldExpression(s,d,a);y.valid||t.push(...y.errors)}}return{valid:t.length===0,errors:t}}toJSON(){return{...this._data}}}const A={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,a)=>t+Number(a),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),a=new Date(e);if(isNaN(t.getTime())||isNaN(a.getTime()))return 0;const s=Math.abs(t.getTime()-a.getTime());return Math.ceil(s/(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 S(){const r=new Date;return{NOW:r,TODAY:new Date(r.getFullYear(),r.getMonth(),r.getDate()),CURRENT_USER:{Id:"",Email:"",FirstName:"",LastName:""}}}function p(r,e){var t;switch(r.Type){case"Literal":return r.Value;case"Identifier":return e.formValues[r.Name];case"SystemIdentifier":return O(r,e);case"BinaryExpression":return R(r,e);case"LogicalExpression":return C(r,e);case"CallExpression":return D(r,e);case"MemberExpression":return M(r,e);case"AssignmentExpression":return((t=r.Arguments)==null?void 0:t.length)===1?p(r.Arguments[0],e):void 0;default:throw new Error(`Unsupported expression type: ${r.Type}`)}}function O(r,e){const t=r.Name,a=e.systemValues[t];return r.Property?a&&typeof a=="object"?a[r.Property.Name]:void 0:a}function R(r,e){if(!r.Arguments||r.Arguments.length<2)throw new Error("BinaryExpression requires 2 arguments");const[t,a]=r.Arguments,s=p(t,e),n=p(a,e);switch(r.Operator){case"==":return s==n;case"!=":return s!=n;case"<":return Number(s)<Number(n);case"<=":return Number(s)<=Number(n);case">":return Number(s)>Number(n);case">=":return Number(s)>=Number(n);case"+":return Number(s)+Number(n);case"-":return Number(s)-Number(n);case"*":return Number(s)*Number(n);case"/":return Number(n)!==0?Number(s)/Number(n):0;case"%":return Number(s)%Number(n);default:throw new Error(`Unsupported binary operator: ${r.Operator}`)}}function C(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(a=>!!p(a,e));case"OR":return t.some(a=>!!p(a,e));case"!":return!p(t[0],e);default:throw new Error(`Unsupported logical operator: ${r.Operator}`)}}function D(r,e){if(!r.Callee)throw new Error("CallExpression requires a Callee");const t=A[r.Callee];if(!t)throw new Error(`Unknown function: ${r.Callee}`);const a=(r.Arguments??[]).map(s=>p(s,e));return t(...a)}function M(r,e){var s,n;if(!((s=r.Arguments)!=null&&s.length))return;const t=p(r.Arguments[0],e),a=(n=r.Arguments[0].Property)==null?void 0:n.Name;return a&&t&&typeof t=="object"?t[a]:t}class B{constructor(){m(this,"fieldRules",new Map);m(this,"metadata",null)}loadMetadata(e){var t,a;this.metadata=e,this.fieldRules.clear();for(const[s,n]of Object.entries(e.Fields)){const d=[];if(n.Validation&&Array.isArray(n.Validation)){for(const h of n.Validation)if(typeof h=="object"&&h.ExpressionTree)d.push(h);else if(typeof h=="string"){const y=(a=(t=e.Rules)==null?void 0:t.Validation)==null?void 0:a[h];y&&d.push(y)}}d.length>0&&this.fieldRules.set(s,d)}}hasMetadata(){return this.metadata!==null}getFieldRules(e){return this.fieldRules.get(e)??[]}validateField(e,t,a){const s=this.fieldRules.get(e);if(!s||s.length===0)return{valid:!0,errors:[]};const n={formValues:{...a,[e]:t},systemValues:S()};for(const d of s)try{if(!p(d.ExpressionTree,n))return{valid:!1,errors:[d.Message||`Validation failed: ${d.Name||d.Id}`]}}catch(h){console.warn(`Expression evaluation failed for rule ${d.Id}:`,h)}return{valid:!0,errors:[]}}validateAll(e){const t=[];for(const a of this.fieldRules.keys()){const s=this.validateField(a,e[a],e);s.valid||t.push(...s.errors)}return{valid:t.length===0,errors:t}}}class I{constructor(){m(this,"_id",new o.StringField({_id:"_id",Name:"ID",Type:"String",ReadOnly:!0}));m(this,"_created_at",new o.DateTimeField({_id:"_created_at",Name:"Created At",Type:"DateTime",ReadOnly:!0}));m(this,"_modified_at",new o.DateTimeField({_id:"_modified_at",Name:"Modified At",Type:"DateTime",ReadOnly:!0}));m(this,"_created_by",new o.UserField({_id:"_created_by",Name:"Created By",Type:"User",ReadOnly:!0}));m(this,"_modified_by",new o.UserField({_id:"_modified_by",Name:"Modified By",Type:"User",ReadOnly:!0}));m(this,"_version",new o.StringField({_id:"_version",Name:"Version",Type:"String",ReadOnly:!0}));m(this,"_m_version",new o.StringField({_id:"_m_version",Name:"Metadata Version",Type:"String",ReadOnly:!0}));m(this,"_fieldsBound",!1);m(this,"_fieldsCache",null);m(this,"_expressionEngine",new B)}getBoId(){return this.meta._id}getFields(){if(this._fieldsCache)return this._fieldsCache;const e={};for(const t of Object.keys(this)){const a=this[t];a instanceof o.BaseField&&(e[t]=a)}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,a){return this._expressionEngine.hasMetadata()?this._expressionEngine.validateField(e,t,a):{valid:!0,errors:[]}}async get(e){const t=await i.api(this.meta._id).get(e);return new x(this,t)}async list(e){return(await i.api(this.meta._id).list(e)).Data.map(a=>new x(this,a))}async count(e){return(await i.api(this.meta._id).count(e)).Count}async create(e){const t=await i.api(this.meta._id).create(e);return new x(this,{...e,_id:t._id})}async update(e,t){return i.api(this.meta._id).update(e,t)}async delete(e){return i.api(this.meta._id).delete(e)}async draft(e){return i.api(this.meta._id).draft(e)}async draftInteraction(e){return i.api(this.meta._id).draftInteraction(e)}createItem(e){return new x(this,e??{})}async draftUpdate(e,t){return i.api(this.meta._id).draftUpdate(e,t)}async draftPatch(e,t){return i.api(this.meta._id).draftPatch(e,t)}async metric(e){return i.api(this.meta._id).metric(e)}async pivot(e){return i.api(this.meta._id).pivot(e)}async getUploadUrl(e,t,a){return i.api(this.meta._id).getUploadUrl(e,t,a)}async getDownloadUrl(e,t,a,s){return i.api(this.meta._id).getDownloadUrl(e,t,a,s)}async getDownloadUrls(e,t,a){return i.api(this.meta._id).getDownloadUrls(e,t,a)}async deleteAttachment(e,t,a){return i.api(this.meta._id).deleteAttachment(e,t,a)}}class q extends o.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 V extends o.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 j extends o.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=o.BaseField;exports.BooleanField=o.BooleanField;exports.DateField=o.DateField;exports.DateTimeField=o.DateTimeField;exports.FileField=o.FileField;exports.NumberField=o.NumberField;exports.ReferenceField=o.ReferenceField;exports.SelectField=o.SelectField;exports.StringField=o.StringField;exports.TextAreaField=o.TextField;exports.TextField=o.TextField;exports.UserField=o.UserField;exports.SystemField=U.SystemField;exports.ArrayField=q;exports.BaseBdo=I;exports.ImageField=j;exports.ObjectField=V;
package/dist/bdo.mjs CHANGED
@@ -1,16 +1,16 @@
1
1
  var O = Object.defineProperty;
2
2
  var S = (r, e, t) => e in r ? O(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var c = (r, e, t) => S(r, typeof e != "symbol" ? e + "" : e, t);
3
+ var d = (r, e, t) => S(r, typeof e != "symbol" ? e + "" : e, t);
4
4
  import { a as i } from "./client-_ayziI1d.js";
5
5
  import { v, e as E } from "./attachment-constants-C2UHWxmp.js";
6
- import { S as F, D as T, U, B as x } from "./FileField-CZjS2uLh.js";
7
- import { a as K, b as W, F as X, N as Q, R as Z, c as ee, T as te, T as re } from "./FileField-CZjS2uLh.js";
8
- import { d as se } from "./constants-Cyi942Yr.js";
6
+ import { S as F, D as T, U, B as x } from "./FileField-BWrSHNRq.js";
7
+ import { a as K, b as W, F as X, N as Q, R as Z, c as ee, T as te, T as re } from "./FileField-BWrSHNRq.js";
8
+ import { d as se } from "./constants-ConHc1oS.js";
9
9
  class w {
10
10
  constructor(e, t) {
11
- c(this, "_data");
12
- c(this, "_bdo");
13
- c(this, "_accessorCache", /* @__PURE__ */ new Map());
11
+ d(this, "_data");
12
+ d(this, "_bdo");
13
+ d(this, "_accessorCache", /* @__PURE__ */ new Map());
14
14
  return this._bdo = e, this._data = { ...t }, new Proxy(this, {
15
15
  get(a, s, n) {
16
16
  return s === "validate" || s === "toJSON" || s === "_bdo" || s === "_data" || s === "_accessorCache" || s === "_getAccessor" || s === "_requireInstanceId" || typeof s == "symbol" ? Reflect.get(a, s, n) : s === "_id" ? a._data._id : a._getAccessor(s);
@@ -41,8 +41,17 @@ class w {
41
41
  }
42
42
  });
43
43
  }
44
+ /**
45
+ * Require instanceId or throw.
46
+ * TODO: Support create flow via draftInteraction to get temp _id
47
+ */
44
48
  _requireInstanceId() {
45
- return this._data._id || "draft";
49
+ const e = this._data._id;
50
+ if (!e)
51
+ throw new Error(
52
+ "Cannot perform attachment operation: item has no _id. Save the item first."
53
+ );
54
+ return e;
46
55
  }
47
56
  /**
48
57
  * Get or create a field accessor for the given field.
@@ -67,8 +76,8 @@ class w {
67
76
  this.toJSON()
68
77
  ) : { valid: !0, errors: [] };
69
78
  }, m = (h) => {
70
- const g = this._data[e];
71
- return g ?? h;
79
+ const f = this._data[e];
80
+ return f ?? h;
72
81
  };
73
82
  let y;
74
83
  if (n ? y = {
@@ -93,25 +102,25 @@ class w {
93
102
  },
94
103
  validate: l
95
104
  }, s.Type === "Image" || s.Type === "File") {
96
- const h = this._bdo.getBoId(), g = y;
97
- s.Type === "Image" ? (g.getDownloadUrl = async (o) => {
98
- const d = this._requireInstanceId(), _ = this._data[e];
105
+ const h = this._bdo.getBoId(), f = y;
106
+ s.Type === "Image" ? (f.getDownloadUrl = async (o) => {
107
+ const c = this._requireInstanceId(), _ = this._data[e];
99
108
  if (!(_ != null && _._id))
100
109
  throw new Error(`${e} has no image to download`);
101
110
  return i(h).getDownloadUrl(
102
- d,
111
+ c,
103
112
  e,
104
113
  _._id,
105
114
  o
106
115
  );
107
- }, n || (g.upload = async (o) => {
116
+ }, n || (f.upload = async (o) => {
108
117
  v(o.name, "Image");
109
- const d = this._requireInstanceId(), _ = {
118
+ const c = this._requireInstanceId(), _ = {
110
119
  FileName: o.name,
111
120
  Size: o.size,
112
121
  FileExtension: E(o.name)
113
122
  }, [u] = await i(h).getUploadUrl(
114
- d,
123
+ c,
115
124
  e,
116
125
  [_]
117
126
  );
@@ -129,31 +138,31 @@ class w {
129
138
  ContentType: u.ContentType
130
139
  };
131
140
  return this._data[e] = p, p;
132
- }, g.deleteAttachment = async () => {
133
- const o = this._requireInstanceId(), d = this._data[e];
134
- if (!(d != null && d._id))
141
+ }, f.deleteAttachment = async () => {
142
+ const o = this._requireInstanceId(), c = this._data[e];
143
+ if (!(c != null && c._id))
135
144
  throw new Error(`${e} has no image to delete`);
136
- await i(h).deleteAttachment(o, e, d._id), this._data[e] = null;
137
- })) : (g.getDownloadUrl = async (o, d) => {
145
+ await i(h).deleteAttachment(o, e, c._id), this._data[e] = null;
146
+ })) : (f.getDownloadUrl = async (o, c) => {
138
147
  const _ = this._requireInstanceId();
139
148
  return i(h).getDownloadUrl(
140
149
  _,
141
150
  e,
142
151
  o,
143
- d
152
+ c
144
153
  );
145
- }, g.getDownloadUrls = async (o) => {
146
- const d = this._requireInstanceId();
147
- return i(h).getDownloadUrls(d, e, o);
148
- }, n || (g.upload = async (o) => {
154
+ }, f.getDownloadUrls = async (o) => {
155
+ const c = this._requireInstanceId();
156
+ return i(h).getDownloadUrls(c, e, o);
157
+ }, n || (f.upload = async (o) => {
149
158
  for (const b of o)
150
159
  v(b.name, "File");
151
- const d = this._requireInstanceId(), _ = o.map((b) => ({
160
+ const c = this._requireInstanceId(), _ = o.map((b) => ({
152
161
  FileName: b.name,
153
162
  Size: b.size,
154
163
  FileExtension: E(b.name)
155
164
  })), u = await i(h).getUploadUrl(
156
- d,
165
+ c,
157
166
  e,
158
167
  _
159
168
  ), p = await Promise.all(
@@ -174,10 +183,10 @@ class w {
174
183
  ...A,
175
184
  ...p
176
185
  ], p;
177
- }, g.deleteAttachment = async (o) => {
178
- const d = this._requireInstanceId();
186
+ }, f.deleteAttachment = async (o) => {
187
+ const c = this._requireInstanceId();
179
188
  await i(h).deleteAttachment(
180
- d,
189
+ c,
181
190
  e,
182
191
  o
183
192
  );
@@ -407,7 +416,7 @@ function C() {
407
416
  }
408
417
  };
409
418
  }
410
- function f(r, e) {
419
+ function g(r, e) {
411
420
  var t;
412
421
  switch (r.Type) {
413
422
  case "Literal":
@@ -425,7 +434,7 @@ function f(r, e) {
425
434
  case "MemberExpression":
426
435
  return V(r, e);
427
436
  case "AssignmentExpression":
428
- return ((t = r.Arguments) == null ? void 0 : t.length) === 1 ? f(r.Arguments[0], e) : void 0;
437
+ return ((t = r.Arguments) == null ? void 0 : t.length) === 1 ? g(r.Arguments[0], e) : void 0;
429
438
  default:
430
439
  throw new Error(`Unsupported expression type: ${r.Type}`);
431
440
  }
@@ -437,7 +446,7 @@ function M(r, e) {
437
446
  function D(r, e) {
438
447
  if (!r.Arguments || r.Arguments.length < 2)
439
448
  throw new Error("BinaryExpression requires 2 arguments");
440
- const [t, a] = r.Arguments, s = f(t, e), n = f(a, e);
449
+ const [t, a] = r.Arguments, s = g(t, e), n = g(a, e);
441
450
  switch (r.Operator) {
442
451
  case "==":
443
452
  return s == n;
@@ -471,11 +480,11 @@ function I(r, e) {
471
480
  const t = r.Arguments;
472
481
  switch (r.Operator) {
473
482
  case "AND":
474
- return t.every((a) => !!f(a, e));
483
+ return t.every((a) => !!g(a, e));
475
484
  case "OR":
476
- return t.some((a) => !!f(a, e));
485
+ return t.some((a) => !!g(a, e));
477
486
  case "!":
478
- return !f(t[0], e);
487
+ return !g(t[0], e);
479
488
  default:
480
489
  throw new Error(`Unsupported logical operator: ${r.Operator}`);
481
490
  }
@@ -486,14 +495,14 @@ function B(r, e) {
486
495
  const t = R[r.Callee];
487
496
  if (!t)
488
497
  throw new Error(`Unknown function: ${r.Callee}`);
489
- const a = (r.Arguments ?? []).map((s) => f(s, e));
498
+ const a = (r.Arguments ?? []).map((s) => g(s, e));
490
499
  return t(...a);
491
500
  }
492
501
  function V(r, e) {
493
502
  var s, n;
494
503
  if (!((s = r.Arguments) != null && s.length))
495
504
  return;
496
- const t = f(r.Arguments[0], e), a = (n = r.Arguments[0].Property) == null ? void 0 : n.Name;
505
+ const t = g(r.Arguments[0], e), a = (n = r.Arguments[0].Property) == null ? void 0 : n.Name;
497
506
  return a && t && typeof t == "object" ? t[a] : t;
498
507
  }
499
508
  class q {
@@ -501,11 +510,11 @@ class q {
501
510
  /**
502
511
  * Map of field ID to its validation rules
503
512
  */
504
- c(this, "fieldRules", /* @__PURE__ */ new Map());
513
+ d(this, "fieldRules", /* @__PURE__ */ new Map());
505
514
  /**
506
515
  * The loaded BDO metadata
507
516
  */
508
- c(this, "metadata", null);
517
+ d(this, "metadata", null);
509
518
  }
510
519
  /**
511
520
  * Load metadata and extract field validation rules
@@ -573,7 +582,7 @@ class q {
573
582
  };
574
583
  for (const l of s)
575
584
  try {
576
- if (!f(l.ExpressionTree, n))
585
+ if (!g(l.ExpressionTree, n))
577
586
  return {
578
587
  valid: !1,
579
588
  errors: [l.Message || `Validation failed: ${l.Name || l.Id}`]
@@ -612,28 +621,28 @@ class z {
612
621
  // ============================================================
613
622
  // SYSTEM FIELDS (inherited by all BDOs)
614
623
  // ============================================================
615
- c(this, "_id", new F({ _id: "_id", Name: "ID", Type: "String", ReadOnly: !0 }));
616
- c(this, "_created_at", new T({ _id: "_created_at", Name: "Created At", Type: "DateTime", ReadOnly: !0 }));
617
- c(this, "_modified_at", new T({ _id: "_modified_at", Name: "Modified At", Type: "DateTime", ReadOnly: !0 }));
618
- c(this, "_created_by", new U({ _id: "_created_by", Name: "Created By", Type: "User", ReadOnly: !0 }));
619
- c(this, "_modified_by", new U({ _id: "_modified_by", Name: "Modified By", Type: "User", ReadOnly: !0 }));
620
- c(this, "_version", new F({ _id: "_version", Name: "Version", Type: "String", ReadOnly: !0 }));
621
- c(this, "_m_version", new F({ _id: "_m_version", Name: "Metadata Version", Type: "String", ReadOnly: !0 }));
624
+ d(this, "_id", new F({ _id: "_id", Name: "ID", Type: "String", ReadOnly: !0 }));
625
+ d(this, "_created_at", new T({ _id: "_created_at", Name: "Created At", Type: "DateTime", ReadOnly: !0 }));
626
+ d(this, "_modified_at", new T({ _id: "_modified_at", Name: "Modified At", Type: "DateTime", ReadOnly: !0 }));
627
+ d(this, "_created_by", new U({ _id: "_created_by", Name: "Created By", Type: "User", ReadOnly: !0 }));
628
+ d(this, "_modified_by", new U({ _id: "_modified_by", Name: "Modified By", Type: "User", ReadOnly: !0 }));
629
+ d(this, "_version", new F({ _id: "_version", Name: "Version", Type: "String", ReadOnly: !0 }));
630
+ d(this, "_m_version", new F({ _id: "_m_version", Name: "Metadata Version", Type: "String", ReadOnly: !0 }));
622
631
  /**
623
632
  * Whether fields have been bound to this BDO
624
633
  */
625
- c(this, "_fieldsBound", !1);
634
+ d(this, "_fieldsBound", !1);
626
635
  /**
627
636
  * Cached field map
628
637
  */
629
- c(this, "_fieldsCache", null);
638
+ d(this, "_fieldsCache", null);
630
639
  // ============================================================
631
640
  // EXPRESSION ENGINE (for backend validation rules)
632
641
  // ============================================================
633
642
  /**
634
643
  * Expression engine instance for evaluating backend validation rules
635
644
  */
636
- c(this, "_expressionEngine", new q());
645
+ d(this, "_expressionEngine", new q());
637
646
  }
638
647
  // ============================================================
639
648
  // FIELD DEFINITIONS (auto-discovered)
@@ -1,6 +1,5 @@
1
1
  import type { UseFormWatch, UseFormSetValue, UseFormGetValues, UseFormReset, UseFormTrigger, Control, FieldErrors } from 'react-hook-form';
2
2
  import type { Activity } from '../../../workflow/Activity';
3
- import type { CreateUpdateResponseType } from '../../../types/common';
4
3
  import type { HandleSubmitType, FormItemType, FormRegisterType, EditableFormFieldAccessorType, ReadonlyFormFieldAccessorType } from '../useBDOForm/types';
5
4
  export type { HandleSubmitType, FormItemType, FormRegisterType, EditableFormFieldAccessorType, ReadonlyFormFieldAccessorType, };
6
5
  /** Extract TEntity from an Activity instance */
@@ -43,8 +42,10 @@ export interface UseActivityFormReturn<A extends Activity<any, any, any>> {
43
42
  activity: A;
44
43
  /** Smart register with auto-disable for readonly fields */
45
44
  register: FormRegisterType<ExtractActivityEditable<A>, ExtractActivityReadonly<A>>;
46
- /** Handle form submission — validates, updates dirty fields, then completes the activity */
47
- handleSubmit: HandleSubmitType<CreateUpdateResponseType>;
45
+ /** Handle form submission — calls activity.update() */
46
+ handleSubmit: HandleSubmitType<AllActivityFields<A>>;
47
+ /** Handle form completion — calls activity.update() + activity.complete() */
48
+ handleComplete: HandleSubmitType<AllActivityFields<A>>;
48
49
  /** Watch field values */
49
50
  watch: UseFormWatch<AllActivityFields<A>>;
50
51
  /** Set field value programmatically */
@@ -63,7 +64,7 @@ export interface UseActivityFormReturn<A extends Activity<any, any, any>> {
63
64
  isValid: boolean;
64
65
  /** Form has been modified */
65
66
  isDirty: boolean;
66
- /** Form is currently submitting */
67
+ /** Form is currently submitting (save or complete) */
67
68
  isSubmitting: boolean;
68
69
  /** Form submission was successful */
69
70
  isSubmitSuccessful: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useActivityForm/types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,OAAO,EACP,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAGtE,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,6BAA6B,EAC7B,6BAA6B,EAC9B,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,6BAA6B,EAC7B,6BAA6B,GAC9B,CAAC;AAMF,gDAAgD;AAChD,MAAM,MAAM,qBAAqB,CAAC,CAAC,IACjC,CAA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sX1B"}
1
+ {"version":3,"file":"useActivityForm.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useActivityForm/useActivityForm.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EACV,sBAAsB,EACtB,qBAAqB,EAEtB,MAAM,SAAS,CAAC;AAwBjB,wBAAgB,eAAe,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC/D,QAAQ,EAAE,CAAC,EACX,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,GACjC,qBAAqB,CAAC,CAAC,CAAC,CAkb1B"}
@@ -1,4 +1,5 @@
1
1
  import type { Activity } from '../../../workflow/Activity';
2
+ import type { ActivityInstanceFieldsType } from '../../../workflow/types';
2
3
  import type { UseTableReturnType, PaginationStateType } from '../useTable/types';
3
4
  import type { UseFilterOptionsType } from '../useFilter/types';
4
5
  import type { SortType } from '../../../types/common';
@@ -11,12 +12,10 @@ export declare const ActivityTableStatus: {
11
12
  };
12
13
  export type ActivityTableStatusType = (typeof ActivityTableStatus)[keyof typeof ActivityTableStatus];
13
14
  /**
14
- * Row type inferred from Activity's getInProgressList() return type.
15
- * Resolves to ActivityInstanceType (proxy with .get()/.set()).
15
+ * Row type for activity table data.
16
+ * System fields and entity fields are flat at the top level.
16
17
  */
17
- export type ActivityRowType<A extends Activity<any, any, any>> = A extends {
18
- getInProgressList(opts?: any): Promise<(infer R)[]>;
19
- } ? R : never;
18
+ export type ActivityRowType<A extends Activity<any, any, any>> = A extends Activity<infer E, any, any> ? ActivityInstanceFieldsType & E : never;
20
19
  export interface UseActivityTableOptionsType<A extends Activity<any, any, any>> {
21
20
  /** The activity instance to fetch data for */
22
21
  activity: A;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useActivityTable/types.ts"],"names":[],"mappings":"AAAA,OA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mB,CAAC;QACjC,MAAM,CAAC,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;KACnD,CAAC;IACF,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,MAAM,0BAA0B,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IACtE,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useActivityTable.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useActivityTable/useActivityTable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,SAAS,CAAC;AAEjB,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAChE,OAAO,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACtC,0BAA0B,CAAC,CAAC,CAAC,CA8B/B"}
1
+ {"version":3,"file":"useActivityTable.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useActivityTable/useActivityTable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EACV,2BAA2B,EAC3B,0BAA0B,EAE3B,MAAM,SAAS,CAAC;AAEjB,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAChE,OAAO,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACtC,0BAA0B,CAAC,CAAC,CAAC,CA4B/B"}
@@ -7,8 +7,9 @@ import type { FormItemType, ExtractEditableType, ExtractReadonlyType } from "./t
7
7
  * Key principle: Item has NO state. It's a view over RHF's state.
8
8
  * Editable fields get set(), readonly fields do not.
9
9
  *
10
- * In create mode (no _id), attachment and fetch operations use 'draft' as the
11
- * instanceId, which the backend accepts as a placeholder.
10
+ * Draft-based upload: In create mode (no _id), upload() automatically creates
11
+ * a draft record via draftInteraction() to get an _id, then uploads immediately.
12
+ * On form submit, if a draft _id exists, update() is used instead of create().
12
13
  *
13
14
  * @param bdo - The BDO instance for field metadata
14
15
  * @param form - The RHF useForm return object
@@ -1 +1 @@
1
- {"version":3,"file":"createItemProxy.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useBDOForm/createItemProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAQ,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQ5C,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EAGpB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC9D,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,GAC/B,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAyS9D"}
1
+ {"version":3,"file":"createItemProxy.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useBDOForm/createItemProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAQ,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQ5C,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EAGpB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC9D,GAAG,EAAE,CAAC,EACN,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,GAC/B,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAiV9D"}
@@ -1,32 +1,24 @@
1
- import type { ListOptionsType, SortType } from '../../../types/common';
2
1
  import type { UseTableReturnType, PaginationStateType } from '../useTable/types';
3
2
  import type { UseFilterOptionsType } from '../useFilter/types';
4
- /** Structural constraint any object with list() and count() */
5
- export interface BDOTableSourceType {
6
- meta: {
7
- readonly _id: string;
8
- readonly name: string;
3
+ import type { SortType } from '../../../types/common';
4
+ export interface UseBDOTableOptionsType<T> {
5
+ /** BDO instance — only meta._id is used (for API routing) */
6
+ bdo: {
7
+ meta: {
8
+ readonly _id: string;
9
+ readonly name: string;
10
+ };
9
11
  };
10
- list(options?: ListOptionsType): Promise<any[]>;
11
- count(options?: ListOptionsType): Promise<number>;
12
- }
13
- /** Infer row type from BDO's list() return type */
14
- export type BDORowType<B extends BDOTableSourceType> = B extends {
15
- list(opts?: any): Promise<(infer R)[]>;
16
- } ? R : never;
17
- export interface UseBDOTableOptionsType<B extends BDOTableSourceType> {
18
- /** BDO instance — list() and count() are called for data */
19
- bdo: B;
20
12
  /** Initial state */
21
13
  initialState?: {
22
14
  sort?: SortType;
23
15
  pagination?: PaginationStateType;
24
- filter?: UseFilterOptionsType<BDORowType<B>>;
16
+ filter?: UseFilterOptionsType<T>;
25
17
  };
26
18
  /** Error callback */
27
19
  onError?: (error: Error) => void;
28
- /** Success callback — receives Item rows from current page */
29
- onSuccess?: (data: BDORowType<B>[]) => void;
20
+ /** Success callback — receives rows from current page */
21
+ onSuccess?: (data: T[]) => void;
30
22
  }
31
- export type UseBDOTableReturnType<B extends BDOTableSourceType> = UseTableReturnType<BDORowType<B>>;
23
+ export type UseBDOTableReturnType<T> = UseTableReturnType<T>;
32
24
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useBDOTable/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,iEAAiE;AACjE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAChD,KAAK,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnD;AAED,mDAAmD;AACnD,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,kBAAkB,IACjD,CAAC,SAAS;IAAE,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAEnE,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,kBAAkB;IAClE,4DAA4D;IAC5D,GAAG,EAAE,CAAC,CAAC;IACP,oBAAoB;IACpB,YAAY,CAAC,EAAE;QACb,IAAI,CAAC,EAAE,QAAQ,CAAC;QAChB,UAAU,CAAC,EAAE,mBAAmB,CAAC;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M,MAAM,qBAAqB,CAAC,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
- import type { BDOTableSourceType, UseBDOTableOptionsType, UseBDOTableReturnType } from './types';
2
- export declare function useBDOTable<B extends BDOTableSourceType>(options: UseBDOTableOptionsType<B>): UseBDOTableReturnType<B>;
1
+ import type { UseBDOTableOptionsType, UseBDOTableReturnType } from './types';
2
+ export declare function useBDOTable<T = any>(options: UseBDOTableOptionsType<T>): UseBDOTableReturnType<T>;
3
3
  //# sourceMappingURL=useBDOTable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBDOTable.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useBDOTable/useBDOTable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAElB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAEjB,wBAAgB,WAAW,CAAC,CAAC,SAAS,kBAAkB,EACtD,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,GACjC,qBAAqB,CAAC,CAAC,CAAC,CAS1B"}
1
+ {"version":3,"file":"useBDOTable.d.ts","sourceRoot":"","sources":["../../../../sdk/components/hooks/useBDOTable/useBDOTable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE7E,wBAAgB,WAAW,CAAC,CAAC,GAAG,GAAG,EACjC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,GACjC,qBAAqB,CAAC,CAAC,CAAC,CAS1B"}
@@ -110,7 +110,7 @@ const t = {
110
110
  Unauthenticated: "unauthenticated"
111
111
  }, u = {
112
112
  Google: "google",
113
- Azure: "azure",
113
+ Microsoft: "microsoft",
114
114
  GitHub: "github",
115
115
  Custom: "custom"
116
116
  }, C = {
@@ -146,12 +146,12 @@ const t = {
146
146
  PAGE: 1,
147
147
  /** Maximum search query length */
148
148
  SEARCH_MAX_LENGTH: 255
149
- }, A = {
149
+ }, T = {
150
150
  /** Date encoded field key: { "$__d__": "YYYY-MM-DD" } */
151
151
  Date: "$__d__",
152
152
  /** DateTime encoded field key: { "$__dt__": unix_timestamp } */
153
153
  DateTime: "$__dt__"
154
- }, T = {
154
+ }, A = {
155
155
  /** Successful deletion */
156
156
  Success: "success"
157
157
  };
@@ -168,8 +168,8 @@ export {
168
168
  e as R,
169
169
  o as S,
170
170
  r as V,
171
- A as a,
172
- T as b,
171
+ T as a,
172
+ A as b,
173
173
  u as c,
174
174
  C as d
175
175
  };
@@ -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-DEmYwKfC.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-Cyi942Yr.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,