@ram_28/kf-ai-sdk 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-types.d.ts +1 -1
- package/dist/base-types.d.ts.map +1 -1
- package/dist/bdo/core/types.d.ts +2 -2
- package/dist/bdo/core/types.d.ts.map +1 -1
- package/dist/bdo/fields/DateField.d.ts +19 -0
- package/dist/bdo/fields/DateField.d.ts.map +1 -0
- package/dist/bdo/fields/ObjectField.d.ts +19 -0
- package/dist/bdo/fields/ObjectField.d.ts.map +1 -0
- package/dist/bdo/fields/SelectField.d.ts +1 -1
- package/dist/bdo/fields/SelectField.d.ts.map +1 -1
- package/dist/bdo/fields/TextAreaField.d.ts +19 -0
- package/dist/bdo/fields/TextAreaField.d.ts.map +1 -0
- package/dist/bdo/fields/index.d.ts +3 -0
- package/dist/bdo/fields/index.d.ts.map +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.d.ts +2 -2
- package/dist/bdo.d.ts.map +1 -1
- package/dist/bdo.mjs +90 -41
- package/dist/types/base-fields.d.ts +1 -1
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/types/constants.d.ts +6 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/package.json +1 -1
- package/sdk/base-types.ts +4 -0
- package/sdk/bdo/core/types.ts +2 -2
- package/sdk/bdo/fields/DateField.ts +56 -0
- package/sdk/bdo/fields/ObjectField.ts +42 -0
- package/sdk/bdo/fields/SelectField.ts +2 -2
- package/sdk/bdo/fields/TextAreaField.ts +35 -0
- package/sdk/bdo/fields/index.ts +3 -0
- package/sdk/bdo.ts +6 -0
- package/sdk/types/base-fields.ts +1 -1
- package/sdk/types/constants.ts +6 -0
package/dist/base-types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { StringFieldType, TextAreaFieldType, NumberFieldType, LongFieldType, BooleanFieldType, DateFieldType, DateTimeFieldType, CurrencyFieldType, CurrencyValueType, JSONFieldType, ReferenceFieldType, ExtractReferenceType, ExtractFetchFieldType, JSONValueType, JSONObjectType, JSONArrayType, SelectFieldType, ArrayFieldType, ObjectFieldType, OptionalFieldType, ExtractFieldType, } from './types/base-fields';
|
|
1
|
+
export type { StringFieldType, TextAreaFieldType, NumberFieldType, LongFieldType, BooleanFieldType, DateFieldType, DateTimeFieldType, CurrencyFieldType, CurrencyValueType, JSONFieldType, ReferenceFieldType, ExtractReferenceType, ExtractFetchFieldType, JSONValueType, JSONObjectType, JSONArrayType, SelectFieldType, ArrayFieldType, ObjectFieldType, OptionalFieldType, ExtractFieldType, SystemFieldsType, UserRefType, } from './types/base-fields';
|
|
2
2
|
//# sourceMappingURL=base-types.d.ts.map
|
package/dist/base-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-types.d.ts","sourceRoot":"","sources":["../sdk/base-types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,eAAe,EACf,iBAAiB,EAGjB,eAAe,EACf,aAAa,EAGb,gBAAgB,EAGhB,aAAa,EACb,iBAAiB,EAGjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EAGrB,aAAa,EACb,cAAc,EACd,aAAa,EAGb,eAAe,EAGf,cAAc,EACd,eAAe,EACf,iBAAiB,EAGjB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"base-types.d.ts","sourceRoot":"","sources":["../sdk/base-types.ts"],"names":[],"mappings":"AAKA,YAAY,EAEV,eAAe,EACf,iBAAiB,EAGjB,eAAe,EACf,aAAa,EAGb,gBAAgB,EAGhB,aAAa,EACb,iBAAiB,EAGjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EAGrB,aAAa,EACb,cAAc,EACd,aAAa,EAGb,eAAe,EAGf,cAAc,EACd,eAAe,EACf,iBAAiB,EAGjB,gBAAgB,EAGhB,gBAAgB,EAChB,WAAW,GACZ,MAAM,qBAAqB,CAAC"}
|
package/dist/bdo/core/types.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface FieldMetaType {
|
|
|
24
24
|
/**
|
|
25
25
|
* SelectField meta — extends FieldMetaType with static options
|
|
26
26
|
*/
|
|
27
|
-
export interface SelectFieldMetaType<T = string> extends FieldMetaType {
|
|
27
|
+
export interface SelectFieldMetaType<T extends string | number = string> extends FieldMetaType {
|
|
28
28
|
readonly options: readonly SelectOptionType<T>[];
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -55,7 +55,7 @@ export interface FieldConfigType {
|
|
|
55
55
|
/**
|
|
56
56
|
* Configuration for select fields with predefined options
|
|
57
57
|
*/
|
|
58
|
-
export interface SelectFieldConfigType<T extends string> extends FieldConfigType {
|
|
58
|
+
export interface SelectFieldConfigType<T extends string | number = string> extends FieldConfigType {
|
|
59
59
|
options: readonly SelectOptionType<T>[];
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../sdk/bdo/core/types.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,MAAM,CAAE,SAAQ,aAAa;
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,MAAM,CAAE,SAAQ,eAAe;IAChG,OAAO,EAAE,SAAS,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB,CAEvC,KAAK,GAAG,OAAO,CACf,SAAQ,eAAe;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DateFieldType } from "../../types/base-fields";
|
|
2
|
+
import type { FieldConfigType, ValidationResultType } from "../core/types";
|
|
3
|
+
import { BaseField } from "./BaseField";
|
|
4
|
+
/**
|
|
5
|
+
* Field definition for date-only fields (YYYY-MM-DD)
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* readonly BirthDate = new DateField({
|
|
10
|
+
* id: "BirthDate",
|
|
11
|
+
* label: "Birth Date"
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class DateField extends BaseField<DateFieldType> {
|
|
16
|
+
constructor(config: FieldConfigType);
|
|
17
|
+
validate(value: DateFieldType | undefined): ValidationResultType;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=DateField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DateField.d.ts","sourceRoot":"","sources":["../../../sdk/bdo/fields/DateField.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;GAUG;AACH,qBAAa,SAAU,SAAQ,SAAS,CAAC,aAAa,CAAC;gBACzC,MAAM,EAAE,eAAe;IAInC,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,oBAAoB;CA8BjE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ObjectFieldType } from "../../types/base-fields";
|
|
2
|
+
import type { FieldConfigType, ValidationResultType } from "../core/types";
|
|
3
|
+
import { BaseField } from "./BaseField";
|
|
4
|
+
/**
|
|
5
|
+
* Field definition for nested object fields
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* readonly Config = new ObjectField({
|
|
10
|
+
* id: "Config",
|
|
11
|
+
* label: "Configuration"
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class ObjectField<T extends Record<string, unknown> = Record<string, unknown>> extends BaseField<ObjectFieldType<T>> {
|
|
16
|
+
constructor(config: FieldConfigType);
|
|
17
|
+
validate(value: ObjectFieldType<T> | undefined): ValidationResultType;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ObjectField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectField.d.ts","sourceRoot":"","sources":["../../../sdk/bdo/fields/ObjectField.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;GAUG;AACH,qBAAa,WAAW,CACtB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC3D,SAAQ,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;gBACzB,MAAM,EAAE,eAAe;IAInC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,oBAAoB;CActE"}
|
|
@@ -18,7 +18,7 @@ import { BaseField } from "./BaseField";
|
|
|
18
18
|
* });
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export declare class SelectField<T extends string = string> extends BaseField<T> {
|
|
21
|
+
export declare class SelectField<T extends string | number = string> extends BaseField<T> {
|
|
22
22
|
protected readonly options: readonly SelectOptionType<T>[];
|
|
23
23
|
constructor(config: SelectFieldConfigType<T>);
|
|
24
24
|
validate(value: T | undefined): ValidationResultType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectField.d.ts","sourceRoot":"","sources":["../../../sdk/bdo/fields/SelectField.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGxH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"SelectField.d.ts","sourceRoot":"","sources":["../../../sdk/bdo/fields/SelectField.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGxH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAC/E,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;gBAE/C,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAK5C,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,oBAAoB;IAqBpD;;OAEG;IACG,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;IAgBvE;;OAEG;IACH,IAAa,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAO1C;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TextAreaFieldType } from "../../types/base-fields";
|
|
2
|
+
import type { FieldConfigType, ValidationResultType } from "../core/types";
|
|
3
|
+
import { BaseField } from "./BaseField";
|
|
4
|
+
/**
|
|
5
|
+
* Field definition for multi-line text fields
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* readonly Description = new TextAreaField({
|
|
10
|
+
* id: "Description",
|
|
11
|
+
* label: "Description"
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class TextAreaField extends BaseField<TextAreaFieldType> {
|
|
16
|
+
constructor(config: FieldConfigType);
|
|
17
|
+
validate(value: TextAreaFieldType | undefined): ValidationResultType;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=TextAreaField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextAreaField.d.ts","sourceRoot":"","sources":["../../../sdk/bdo/fields/TextAreaField.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,SAAQ,SAAS,CAAC,iBAAiB,CAAC;gBACjD,MAAM,EAAE,eAAe;IAInC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,GAAG,oBAAoB;CASrE"}
|
|
@@ -6,4 +6,7 @@ export { DateTimeField } from "./DateTimeField";
|
|
|
6
6
|
export { SelectField } from "./SelectField";
|
|
7
7
|
export { ReferenceField } from "./ReferenceField";
|
|
8
8
|
export { ArrayField } from "./ArrayField";
|
|
9
|
+
export { DateField } from "./DateField";
|
|
10
|
+
export { TextAreaField } from "./TextAreaField";
|
|
11
|
+
export { ObjectField } from "./ObjectField";
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../sdk/bdo/fields/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../sdk/bdo/fields/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/bdo.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var N=Object.defineProperty;var p=(r,e,t)=>e in r?N(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e,t)=>p(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./client-DxjRcEtN.cjs"),y=require("./constants-C49b9Exc.cjs");class h{constructor(e,t){n(this,"_data");n(this,"_bdo");n(this,"_accessorCache",new Map);return this._bdo=e,this._data={...t},new Proxy(this,{get(i,s,a){return s==="validate"||s==="toJSON"||s==="_bdo"||s==="_data"||s==="_accessorCache"||s==="_getAccessor"||typeof s=="symbol"?Reflect.get(i,s,a):s==="_id"?i._data._id:i._getAccessor(s)},set(i,s,a){return s==="_bdo"||s==="_data"||s==="_accessorCache"||s==="validate"||s==="toJSON"?!1:typeof s=="symbol"?Reflect.set(i,s,a):(i._data[s]=a,!0)},has(i,s){return s==="validate"||s==="toJSON"?!0:s in i._data||s in i._bdo.getFields()},ownKeys(i){return[...Object.keys(i._bdo.getFields()),"validate","toJSON"]},getOwnPropertyDescriptor(i,s){if(s==="validate"||s==="toJSON")return{configurable:!0,enumerable:!1,value:i[s]};const a=i._bdo.getFields();if(s in a||s in i._data)return{configurable:!0,enumerable:!0,get:()=>i._getAccessor(s)}}})}_getAccessor(e){if(this._accessorCache.has(e))return this._accessorCache.get(e);const i=this._bdo.getFields()[e],s=(i==null?void 0:i.meta)??{id:e,label:e,isEditable:!0},a=s.isEditable,l=()=>{if(i){const d=i.validate(this._data[e]);if(!d.valid)return d}return this._bdo.hasMetadata()?this._bdo.validateFieldExpression(e,this._data[e],this.toJSON()):{valid:!0,errors:[]}};let o;return a?o={meta:s,get:()=>this._data[e],set:d=>{this._data[e]=d},validate:l}:o={meta:s,get:()=>this._data[e],validate:l},this._accessorCache.set(e,o),o}validate(){const e=this._bdo.getFields(),t=[],i=this.toJSON();for(const[s,a]of Object.entries(e)){const l=this._data[s],o=a.validate(l);if(!o.valid){t.push(...o.errors);continue}if(this._bdo.hasMetadata()){const d=this._bdo.validateFieldExpression(s,l,i);d.valid||t.push(...d.errors)}}return{valid:t.length===0,errors:t}}toJSON(){return{...this._data}}}class f{constructor(e){n(this,"id");n(this,"label");n(this,"editable");n(this,"_parentBoId");this.id=e.id,this.label=e.label,this.editable=e.editable??!0}get meta(){return{id:this.id,label:this.label,isEditable:this.editable}}}class m extends f{constructor(e){super(e)}validate(e){return e!=null&&typeof e!="string"?{valid:!1,errors:[`${this.label} must be a string`]}:{valid:!0,errors:[]}}}class b extends f{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`]};const t=new Date(e);return isNaN(t.getTime())?{valid:!1,errors:[`${this.label} is not a valid date`]}:{valid:!0,errors:[]}}}class _ extends f{constructor(t){super(t);n(this,"referenceBdo");n(this,"referenceFields");this.referenceBdo=t.referenceBdo,this.referenceFields=t.referenceFields??["_id"]}validate(t){if(t==null)return{valid:!0,errors:[]};if(typeof t!="object")return{valid:!1,errors:[`${this.label} must be a valid reference object`]};const i=t;return!("_id"in i)||typeof i._id!="string"?{valid:!1,errors:[`${this.label} must have a valid _id`]}:{valid:!0,errors:[]}}async fetchOptions(t){if(!this._parentBoId)throw new Error(`Field ${this.id} not bound to a BDO. Cannot fetch options.`);return u.api(this._parentBoId).fetchField(t??"new",this.id)}get meta(){return{id:this.id,label:this.label,isEditable:this.editable,reference:{bdo:this.referenceBdo,fields:[...this.referenceFields]}}}}const v={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,i)=>t+Number(i),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),i=new Date(e);if(isNaN(t.getTime())||isNaN(i.getTime()))return 0;const s=Math.abs(t.getTime()-i.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 w(){const r=new Date;return{NOW:r,TODAY:new Date(r.getFullYear(),r.getMonth(),r.getDate()),CURRENT_USER:{Id:"",Email:"",FirstName:"",LastName:""}}}function c(r,e){var t;switch(r.Type){case"Literal":return r.Value;case"Identifier":return e.formValues[r.Name];case"SystemIdentifier":return x(r,e);case"BinaryExpression":return E(r,e);case"LogicalExpression":return F(r,e);case"CallExpression":return A(r,e);case"MemberExpression":return D(r,e);case"AssignmentExpression":return((t=r.Arguments)==null?void 0:t.length)===1?c(r.Arguments[0],e):void 0;default:throw new Error(`Unsupported expression type: ${r.Type}`)}}function x(r,e){const t=r.Name,i=e.systemValues[t];return r.Property?i&&typeof i=="object"?i[r.Property.Name]:void 0:i}function E(r,e){if(!r.Arguments||r.Arguments.length<2)throw new Error("BinaryExpression requires 2 arguments");const[t,i]=r.Arguments,s=c(t,e),a=c(i,e);switch(r.Operator){case"==":return s==a;case"!=":return s!=a;case"<":return Number(s)<Number(a);case"<=":return Number(s)<=Number(a);case">":return Number(s)>Number(a);case">=":return Number(s)>=Number(a);case"+":return Number(s)+Number(a);case"-":return Number(s)-Number(a);case"*":return Number(s)*Number(a);case"/":return Number(a)!==0?Number(s)/Number(a):0;case"%":return Number(s)%Number(a);default:throw new Error(`Unsupported binary operator: ${r.Operator}`)}}function F(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(i=>!!c(i,e));case"OR":return t.some(i=>!!c(i,e));case"!":return!c(t[0],e);default:throw new Error(`Unsupported logical operator: ${r.Operator}`)}}function A(r,e){if(!r.Callee)throw new Error("CallExpression requires a Callee");const t=v[r.Callee];if(!t)throw new Error(`Unknown function: ${r.Callee}`);const i=(r.Arguments??[]).map(s=>c(s,e));return t(...i)}function D(r,e){var s,a;if(!((s=r.Arguments)!=null&&s.length))return;const t=c(r.Arguments[0],e),i=(a=r.Arguments[0].Property)==null?void 0:a.Name;return i&&t&&typeof t=="object"?t[i]:t}class S{constructor(){n(this,"fieldRules",new Map);n(this,"metadata",null)}loadMetadata(e){var t,i;this.metadata=e,this.fieldRules.clear();for(const[s,a]of Object.entries(e.Fields)){const l=[];if(a.Validation&&Array.isArray(a.Validation)){for(const o of a.Validation)if(typeof o=="object"&&o.ExpressionTree)l.push(o);else if(typeof o=="string"){const d=(i=(t=e.Rules)==null?void 0:t.Validation)==null?void 0:i[o];d&&l.push(d)}}l.length>0&&this.fieldRules.set(s,l)}}hasMetadata(){return this.metadata!==null}getFieldRules(e){return this.fieldRules.get(e)??[]}validateField(e,t,i){const s=this.fieldRules.get(e);if(!s||s.length===0)return{valid:!0,errors:[]};const a={formValues:{...i,[e]:t},systemValues:w()};for(const l of s)try{if(!c(l.ExpressionTree,a))return{valid:!1,errors:[l.Message||`Validation failed: ${l.Name||l.Id}`]}}catch(o){console.warn(`Expression evaluation failed for rule ${l.Id}:`,o)}return{valid:!0,errors:[]}}validateAll(e){const t=[];for(const i of this.fieldRules.keys()){const s=this.validateField(i,e[i],e);s.valid||t.push(...s.errors)}return{valid:t.length===0,errors:t}}}const g="SYS_User";class M{constructor(){n(this,"_id",new m({id:"_id",label:"ID"}));n(this,"_created_at",new b({id:"_created_at",label:"Created At"}));n(this,"_modified_at",new b({id:"_modified_at",label:"Modified At"}));n(this,"_created_by",new _({id:"_created_by",label:"Created By",referenceBdo:g,referenceFields:["_id","username"]}));n(this,"_modified_by",new _({id:"_modified_by",label:"Modified By",referenceBdo:g,referenceFields:["_id","username"]}));n(this,"_version",new m({id:"_version",label:"Version"}));n(this,"_m_version",new m({id:"_m_version",label:"Metadata Version"}));n(this,"_fieldsBound",!1);n(this,"_fieldsCache",null);n(this,"_expressionEngine",new S)}getFields(){if(this._fieldsCache)return this._fieldsCache;const e={};for(const t of Object.keys(this)){const i=this[t];i instanceof f&&(e[t]=i)}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,i){return this._expressionEngine.hasMetadata()?this._expressionEngine.validateField(e,t,i):{valid:!0,errors:[]}}async get(e){const t=await u.api(this.meta._id).get(e);return new h(this,t)}async list(e){return(await u.api(this.meta._id).list(e)).Data.map(i=>new h(this,i))}async count(e){return(await u.api(this.meta._id).count(e)).Count}async create(e){const t=await u.api(this.meta._id).create(e);return new h(this,{...e,_id:t._id})}async update(e,t){return u.api(this.meta._id).update(e,t)}async delete(e){return u.api(this.meta._id).delete(e)}async draft(e){return u.api(this.meta._id).draft(e)}async draftInteraction(e){return u.api(this.meta._id).draftInteraction(e)}createItem(e){return new h(this,e??{})}async draftPatch(e,t){return u.api(this.meta._id).draftPatch(e,t)}async metric(e){return u.api(this.meta._id).metric(e)}async pivot(e){return u.api(this.meta._id).pivot(e)}}class O extends f{constructor(e){super(e)}validate(e){return e!=null&&(typeof e!="number"||isNaN(e))?{valid:!1,errors:[`${this.label} must be a valid number`]}:{valid:!0,errors:[]}}}class B extends f{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 C extends f{constructor(t){super(t);n(this,"options");this.options=t.options}validate(t){if(t==null||t==="")return{valid:!0,errors:[]};if(this.options.length===0)return{valid:!0,errors:[]};const i=this.options.map(s=>s.value);return i.includes(t)?{valid:!0,errors:[]}:{valid:!1,errors:[`${this.label} must be one of: ${i.join(", ")}`]}}async fetchOptions(t){if(!this._parentBoId)throw new Error(`Field ${this.id} not bound to a BDO. Cannot fetch options.`);return(await u.api(this._parentBoId).fetchField(t??"new",this.id)).map(s=>({value:s.Value,label:s.Label}))}get meta(){return{id:this.id,label:this.label,isEditable:this.editable,options:this.options}}}class R extends f{constructor(e){super(e)}validate(e){return e!=null&&!Array.isArray(e)?{valid:!1,errors:[`${this.label} must be an array`]}:{valid:!0,errors:[]}}}exports.SystemField=y.SystemField;exports.ArrayField=R;exports.BaseBdo=M;exports.BooleanField=B;exports.DateTimeField=b;exports.NumberField=O;exports.ReferenceField=_;exports.SelectField=C;exports.StringField=m;
|
|
1
|
+
"use strict";var N=Object.defineProperty;var p=(r,e,t)=>e in r?N(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e,t)=>p(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./client-DxjRcEtN.cjs"),y=require("./constants-C49b9Exc.cjs");class h{constructor(e,t){n(this,"_data");n(this,"_bdo");n(this,"_accessorCache",new Map);return this._bdo=e,this._data={...t},new Proxy(this,{get(i,s,a){return s==="validate"||s==="toJSON"||s==="_bdo"||s==="_data"||s==="_accessorCache"||s==="_getAccessor"||typeof s=="symbol"?Reflect.get(i,s,a):s==="_id"?i._data._id:i._getAccessor(s)},set(i,s,a){return s==="_bdo"||s==="_data"||s==="_accessorCache"||s==="validate"||s==="toJSON"?!1:typeof s=="symbol"?Reflect.set(i,s,a):(i._data[s]=a,!0)},has(i,s){return s==="validate"||s==="toJSON"?!0:s in i._data||s in i._bdo.getFields()},ownKeys(i){return[...Object.keys(i._bdo.getFields()),"validate","toJSON"]},getOwnPropertyDescriptor(i,s){if(s==="validate"||s==="toJSON")return{configurable:!0,enumerable:!1,value:i[s]};const a=i._bdo.getFields();if(s in a||s in i._data)return{configurable:!0,enumerable:!0,get:()=>i._getAccessor(s)}}})}_getAccessor(e){if(this._accessorCache.has(e))return this._accessorCache.get(e);const i=this._bdo.getFields()[e],s=(i==null?void 0:i.meta)??{id:e,label:e,isEditable:!0},a=s.isEditable,l=()=>{if(i){const c=i.validate(this._data[e]);if(!c.valid)return c}return this._bdo.hasMetadata()?this._bdo.validateFieldExpression(e,this._data[e],this.toJSON()):{valid:!0,errors:[]}};let o;return a?o={meta:s,get:()=>this._data[e],set:c=>{this._data[e]=c},validate:l}:o={meta:s,get:()=>this._data[e],validate:l},this._accessorCache.set(e,o),o}validate(){const e=this._bdo.getFields(),t=[],i=this.toJSON();for(const[s,a]of Object.entries(e)){const l=this._data[s],o=a.validate(l);if(!o.valid){t.push(...o.errors);continue}if(this._bdo.hasMetadata()){const c=this._bdo.validateFieldExpression(s,l,i);c.valid||t.push(...c.errors)}}return{valid:t.length===0,errors:t}}toJSON(){return{...this._data}}}class u{constructor(e){n(this,"id");n(this,"label");n(this,"editable");n(this,"_parentBoId");this.id=e.id,this.label=e.label,this.editable=e.editable??!0}get meta(){return{id:this.id,label:this.label,isEditable:this.editable}}}class m extends u{constructor(e){super(e)}validate(e){return e!=null&&typeof e!="string"?{valid:!1,errors:[`${this.label} must be a string`]}:{valid:!0,errors:[]}}}class b extends u{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`]};const t=new Date(e);return isNaN(t.getTime())?{valid:!1,errors:[`${this.label} is not a valid date`]}:{valid:!0,errors:[]}}}class _ extends u{constructor(t){super(t);n(this,"referenceBdo");n(this,"referenceFields");this.referenceBdo=t.referenceBdo,this.referenceFields=t.referenceFields??["_id"]}validate(t){if(t==null)return{valid:!0,errors:[]};if(typeof t!="object")return{valid:!1,errors:[`${this.label} must be a valid reference object`]};const i=t;return!("_id"in i)||typeof i._id!="string"?{valid:!1,errors:[`${this.label} must have a valid _id`]}:{valid:!0,errors:[]}}async fetchOptions(t){if(!this._parentBoId)throw new Error(`Field ${this.id} not bound to a BDO. Cannot fetch options.`);return d.api(this._parentBoId).fetchField(t??"new",this.id)}get meta(){return{id:this.id,label:this.label,isEditable:this.editable,reference:{bdo:this.referenceBdo,fields:[...this.referenceFields]}}}}const v={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,i)=>t+Number(i),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),i=new Date(e);if(isNaN(t.getTime())||isNaN(i.getTime()))return 0;const s=Math.abs(t.getTime()-i.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 x(){const r=new Date;return{NOW:r,TODAY:new Date(r.getFullYear(),r.getMonth(),r.getDate()),CURRENT_USER:{Id:"",Email:"",FirstName:"",LastName:""}}}function f(r,e){var t;switch(r.Type){case"Literal":return r.Value;case"Identifier":return e.formValues[r.Name];case"SystemIdentifier":return w(r,e);case"BinaryExpression":return F(r,e);case"LogicalExpression":return E(r,e);case"CallExpression":return D(r,e);case"MemberExpression":return A(r,e);case"AssignmentExpression":return((t=r.Arguments)==null?void 0:t.length)===1?f(r.Arguments[0],e):void 0;default:throw new Error(`Unsupported expression type: ${r.Type}`)}}function w(r,e){const t=r.Name,i=e.systemValues[t];return r.Property?i&&typeof i=="object"?i[r.Property.Name]:void 0:i}function F(r,e){if(!r.Arguments||r.Arguments.length<2)throw new Error("BinaryExpression requires 2 arguments");const[t,i]=r.Arguments,s=f(t,e),a=f(i,e);switch(r.Operator){case"==":return s==a;case"!=":return s!=a;case"<":return Number(s)<Number(a);case"<=":return Number(s)<=Number(a);case">":return Number(s)>Number(a);case">=":return Number(s)>=Number(a);case"+":return Number(s)+Number(a);case"-":return Number(s)-Number(a);case"*":return Number(s)*Number(a);case"/":return Number(a)!==0?Number(s)/Number(a):0;case"%":return Number(s)%Number(a);default:throw new Error(`Unsupported binary operator: ${r.Operator}`)}}function E(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(i=>!!f(i,e));case"OR":return t.some(i=>!!f(i,e));case"!":return!f(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=v[r.Callee];if(!t)throw new Error(`Unknown function: ${r.Callee}`);const i=(r.Arguments??[]).map(s=>f(s,e));return t(...i)}function A(r,e){var s,a;if(!((s=r.Arguments)!=null&&s.length))return;const t=f(r.Arguments[0],e),i=(a=r.Arguments[0].Property)==null?void 0:a.Name;return i&&t&&typeof t=="object"?t[i]:t}class M{constructor(){n(this,"fieldRules",new Map);n(this,"metadata",null)}loadMetadata(e){var t,i;this.metadata=e,this.fieldRules.clear();for(const[s,a]of Object.entries(e.Fields)){const l=[];if(a.Validation&&Array.isArray(a.Validation)){for(const o of a.Validation)if(typeof o=="object"&&o.ExpressionTree)l.push(o);else if(typeof o=="string"){const c=(i=(t=e.Rules)==null?void 0:t.Validation)==null?void 0:i[o];c&&l.push(c)}}l.length>0&&this.fieldRules.set(s,l)}}hasMetadata(){return this.metadata!==null}getFieldRules(e){return this.fieldRules.get(e)??[]}validateField(e,t,i){const s=this.fieldRules.get(e);if(!s||s.length===0)return{valid:!0,errors:[]};const a={formValues:{...i,[e]:t},systemValues:x()};for(const l of s)try{if(!f(l.ExpressionTree,a))return{valid:!1,errors:[l.Message||`Validation failed: ${l.Name||l.Id}`]}}catch(o){console.warn(`Expression evaluation failed for rule ${l.Id}:`,o)}return{valid:!0,errors:[]}}validateAll(e){const t=[];for(const i of this.fieldRules.keys()){const s=this.validateField(i,e[i],e);s.valid||t.push(...s.errors)}return{valid:t.length===0,errors:t}}}const g="SYS_User";class O{constructor(){n(this,"_id",new m({id:"_id",label:"ID"}));n(this,"_created_at",new b({id:"_created_at",label:"Created At"}));n(this,"_modified_at",new b({id:"_modified_at",label:"Modified At"}));n(this,"_created_by",new _({id:"_created_by",label:"Created By",referenceBdo:g,referenceFields:["_id","username"]}));n(this,"_modified_by",new _({id:"_modified_by",label:"Modified By",referenceBdo:g,referenceFields:["_id","username"]}));n(this,"_version",new m({id:"_version",label:"Version"}));n(this,"_m_version",new m({id:"_m_version",label:"Metadata Version"}));n(this,"_fieldsBound",!1);n(this,"_fieldsCache",null);n(this,"_expressionEngine",new M)}getFields(){if(this._fieldsCache)return this._fieldsCache;const e={};for(const t of Object.keys(this)){const i=this[t];i instanceof u&&(e[t]=i)}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,i){return this._expressionEngine.hasMetadata()?this._expressionEngine.validateField(e,t,i):{valid:!0,errors:[]}}async get(e){const t=await d.api(this.meta._id).get(e);return new h(this,t)}async list(e){return(await d.api(this.meta._id).list(e)).Data.map(i=>new h(this,i))}async count(e){return(await d.api(this.meta._id).count(e)).Count}async create(e){const t=await d.api(this.meta._id).create(e);return new h(this,{...e,_id:t._id})}async update(e,t){return d.api(this.meta._id).update(e,t)}async delete(e){return d.api(this.meta._id).delete(e)}async draft(e){return d.api(this.meta._id).draft(e)}async draftInteraction(e){return d.api(this.meta._id).draftInteraction(e)}createItem(e){return new h(this,e??{})}async draftPatch(e,t){return d.api(this.meta._id).draftPatch(e,t)}async metric(e){return d.api(this.meta._id).metric(e)}async pivot(e){return d.api(this.meta._id).pivot(e)}}class S extends u{constructor(e){super(e)}validate(e){return e!=null&&(typeof e!="number"||isNaN(e))?{valid:!1,errors:[`${this.label} must be a valid number`]}:{valid:!0,errors:[]}}}class B extends u{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 T extends u{constructor(t){super(t);n(this,"options");this.options=t.options}validate(t){if(t==null||t==="")return{valid:!0,errors:[]};if(this.options.length===0)return{valid:!0,errors:[]};const i=this.options.map(s=>s.value);return i.includes(t)?{valid:!0,errors:[]}:{valid:!1,errors:[`${this.label} must be one of: ${i.join(", ")}`]}}async fetchOptions(t){if(!this._parentBoId)throw new Error(`Field ${this.id} not bound to a BDO. Cannot fetch options.`);return(await d.api(this._parentBoId).fetchField(t??"new",this.id)).map(s=>({value:s.Value,label:s.Label}))}get meta(){return{id:this.id,label:this.label,isEditable:this.editable,options:this.options}}}class C extends u{constructor(e){super(e)}validate(e){return e!=null&&!Array.isArray(e)?{valid:!1,errors:[`${this.label} must be an array`]}:{valid:!0,errors:[]}}}class R extends u{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 $ extends u{constructor(e){super(e)}validate(e){return e!=null&&typeof e!="string"?{valid:!1,errors:[`${this.label} must be a string`]}:{valid:!0,errors:[]}}}class j extends u{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 object`]}:{valid:!0,errors:[]}}}exports.SystemField=y.SystemField;exports.ArrayField=C;exports.BaseBdo=O;exports.BooleanField=B;exports.DateField=R;exports.DateTimeField=b;exports.NumberField=S;exports.ObjectField=j;exports.ReferenceField=_;exports.SelectField=T;exports.StringField=m;exports.TextAreaField=$;
|
package/dist/bdo.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BaseBdo } from "./bdo/core/BaseBdo";
|
|
2
2
|
export type { SystemFields } from "./bdo/core/BaseBdo";
|
|
3
|
-
export { StringField, NumberField, BooleanField, DateTimeField, SelectField, ReferenceField, ArrayField, } from "./bdo/fields";
|
|
4
|
-
export type { StringFieldType, NumberFieldType, BooleanFieldType, DateFieldType, DateTimeFieldType, ReferenceFieldType, ArrayFieldType, SystemFieldsType, UserRefType, } from "./types/base-fields";
|
|
3
|
+
export { StringField, NumberField, BooleanField, DateTimeField, DateField, TextAreaField, SelectField, ReferenceField, ArrayField, ObjectField, } from "./bdo/fields";
|
|
4
|
+
export type { StringFieldType, NumberFieldType, BooleanFieldType, DateFieldType, DateTimeFieldType, TextAreaFieldType, SelectFieldType, ReferenceFieldType, ArrayFieldType, ObjectFieldType, SystemFieldsType, UserRefType, } from "./types/base-fields";
|
|
5
5
|
export type { BdoMetaType, ValidationResultType, SelectOptionType, FieldConfigType, SelectFieldConfigType, ReferenceFieldConfigType, FieldMetaType, } from "./bdo/core/types";
|
|
6
6
|
export type { ItemType } from "./bdo/core/Item";
|
|
7
7
|
export { SystemField } from "./types/constants";
|
package/dist/bdo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bdo.d.ts","sourceRoot":"","sources":["../sdk/bdo.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,WAAW,EACX,cAAc,EACd,UAAU,
|
|
1
|
+
{"version":3,"file":"bdo.d.ts","sourceRoot":"","sources":["../sdk/bdo.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACd,UAAU,EACV,WAAW,GACZ,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EACV,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/bdo.mjs
CHANGED
|
@@ -2,7 +2,7 @@ var N = Object.defineProperty;
|
|
|
2
2
|
var y = (r, e, t) => e in r ? N(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var n = (r, e, t) => y(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { a as u } from "./client-BIkaIr2y.js";
|
|
5
|
-
import { d as
|
|
5
|
+
import { d as L } from "./constants-DaX7GLgl.js";
|
|
6
6
|
class h {
|
|
7
7
|
constructor(e, t) {
|
|
8
8
|
n(this, "_data");
|
|
@@ -51,9 +51,9 @@ class h {
|
|
|
51
51
|
isEditable: !0
|
|
52
52
|
}, a = s.isEditable, l = () => {
|
|
53
53
|
if (i) {
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
return
|
|
54
|
+
const c = i.validate(this._data[e]);
|
|
55
|
+
if (!c.valid)
|
|
56
|
+
return c;
|
|
57
57
|
}
|
|
58
58
|
return this._bdo.hasMetadata() ? this._bdo.validateFieldExpression(
|
|
59
59
|
e,
|
|
@@ -65,8 +65,8 @@ class h {
|
|
|
65
65
|
return a ? o = {
|
|
66
66
|
meta: s,
|
|
67
67
|
get: () => this._data[e],
|
|
68
|
-
set: (
|
|
69
|
-
this._data[e] =
|
|
68
|
+
set: (c) => {
|
|
69
|
+
this._data[e] = c;
|
|
70
70
|
},
|
|
71
71
|
validate: l
|
|
72
72
|
} : o = {
|
|
@@ -87,12 +87,12 @@ class h {
|
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
89
89
|
if (this._bdo.hasMetadata()) {
|
|
90
|
-
const
|
|
90
|
+
const c = this._bdo.validateFieldExpression(
|
|
91
91
|
s,
|
|
92
92
|
l,
|
|
93
93
|
i
|
|
94
94
|
);
|
|
95
|
-
|
|
95
|
+
c.valid || t.push(...c.errors);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
return {
|
|
@@ -107,7 +107,7 @@ class h {
|
|
|
107
107
|
return { ...this._data };
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
class
|
|
110
|
+
class d {
|
|
111
111
|
constructor(e) {
|
|
112
112
|
n(this, "id");
|
|
113
113
|
n(this, "label");
|
|
@@ -126,7 +126,7 @@ class f {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
class m extends
|
|
129
|
+
class m extends d {
|
|
130
130
|
constructor(e) {
|
|
131
131
|
super(e);
|
|
132
132
|
}
|
|
@@ -137,7 +137,7 @@ class m extends f {
|
|
|
137
137
|
} : { valid: !0, errors: [] };
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
class b extends
|
|
140
|
+
class b extends d {
|
|
141
141
|
constructor(e) {
|
|
142
142
|
super(e);
|
|
143
143
|
}
|
|
@@ -156,7 +156,7 @@ class b extends f {
|
|
|
156
156
|
} : { valid: !0, errors: [] };
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
class _ extends
|
|
159
|
+
class _ extends d {
|
|
160
160
|
constructor(t) {
|
|
161
161
|
super(t);
|
|
162
162
|
n(this, "referenceBdo");
|
|
@@ -202,7 +202,7 @@ class _ extends f {
|
|
|
202
202
|
};
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
const
|
|
205
|
+
const v = {
|
|
206
206
|
// ============================================================
|
|
207
207
|
// STRING FUNCTIONS (7)
|
|
208
208
|
// ============================================================
|
|
@@ -372,7 +372,7 @@ const p = {
|
|
|
372
372
|
return (r === "x" ? e : e & 3 | 8).toString(16);
|
|
373
373
|
})
|
|
374
374
|
};
|
|
375
|
-
function
|
|
375
|
+
function p() {
|
|
376
376
|
const r = /* @__PURE__ */ new Date();
|
|
377
377
|
return {
|
|
378
378
|
NOW: r,
|
|
@@ -387,7 +387,7 @@ function v() {
|
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function f(r, e) {
|
|
391
391
|
var t;
|
|
392
392
|
switch (r.Type) {
|
|
393
393
|
case "Literal":
|
|
@@ -395,29 +395,29 @@ function c(r, e) {
|
|
|
395
395
|
case "Identifier":
|
|
396
396
|
return e.formValues[r.Name];
|
|
397
397
|
case "SystemIdentifier":
|
|
398
|
-
return w(r, e);
|
|
399
|
-
case "BinaryExpression":
|
|
400
398
|
return x(r, e);
|
|
399
|
+
case "BinaryExpression":
|
|
400
|
+
return w(r, e);
|
|
401
401
|
case "LogicalExpression":
|
|
402
402
|
return E(r, e);
|
|
403
403
|
case "CallExpression":
|
|
404
404
|
return F(r, e);
|
|
405
405
|
case "MemberExpression":
|
|
406
|
-
return
|
|
406
|
+
return D(r, e);
|
|
407
407
|
case "AssignmentExpression":
|
|
408
|
-
return ((t = r.Arguments) == null ? void 0 : t.length) === 1 ?
|
|
408
|
+
return ((t = r.Arguments) == null ? void 0 : t.length) === 1 ? f(r.Arguments[0], e) : void 0;
|
|
409
409
|
default:
|
|
410
410
|
throw new Error(`Unsupported expression type: ${r.Type}`);
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
function
|
|
413
|
+
function x(r, e) {
|
|
414
414
|
const t = r.Name, i = e.systemValues[t];
|
|
415
415
|
return r.Property ? i && typeof i == "object" ? i[r.Property.Name] : void 0 : i;
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function w(r, e) {
|
|
418
418
|
if (!r.Arguments || r.Arguments.length < 2)
|
|
419
419
|
throw new Error("BinaryExpression requires 2 arguments");
|
|
420
|
-
const [t, i] = r.Arguments, s =
|
|
420
|
+
const [t, i] = r.Arguments, s = f(t, e), a = f(i, e);
|
|
421
421
|
switch (r.Operator) {
|
|
422
422
|
case "==":
|
|
423
423
|
return s == a;
|
|
@@ -451,11 +451,11 @@ function E(r, e) {
|
|
|
451
451
|
const t = r.Arguments;
|
|
452
452
|
switch (r.Operator) {
|
|
453
453
|
case "AND":
|
|
454
|
-
return t.every((i) => !!
|
|
454
|
+
return t.every((i) => !!f(i, e));
|
|
455
455
|
case "OR":
|
|
456
|
-
return t.some((i) => !!
|
|
456
|
+
return t.some((i) => !!f(i, e));
|
|
457
457
|
case "!":
|
|
458
|
-
return !
|
|
458
|
+
return !f(t[0], e);
|
|
459
459
|
default:
|
|
460
460
|
throw new Error(`Unsupported logical operator: ${r.Operator}`);
|
|
461
461
|
}
|
|
@@ -463,20 +463,20 @@ function E(r, e) {
|
|
|
463
463
|
function F(r, e) {
|
|
464
464
|
if (!r.Callee)
|
|
465
465
|
throw new Error("CallExpression requires a Callee");
|
|
466
|
-
const t =
|
|
466
|
+
const t = v[r.Callee];
|
|
467
467
|
if (!t)
|
|
468
468
|
throw new Error(`Unknown function: ${r.Callee}`);
|
|
469
|
-
const i = (r.Arguments ?? []).map((s) =>
|
|
469
|
+
const i = (r.Arguments ?? []).map((s) => f(s, e));
|
|
470
470
|
return t(...i);
|
|
471
471
|
}
|
|
472
|
-
function
|
|
472
|
+
function D(r, e) {
|
|
473
473
|
var s, a;
|
|
474
474
|
if (!((s = r.Arguments) != null && s.length))
|
|
475
475
|
return;
|
|
476
|
-
const t =
|
|
476
|
+
const t = f(r.Arguments[0], e), i = (a = r.Arguments[0].Property) == null ? void 0 : a.Name;
|
|
477
477
|
return i && t && typeof t == "object" ? t[i] : t;
|
|
478
478
|
}
|
|
479
|
-
class
|
|
479
|
+
class A {
|
|
480
480
|
constructor() {
|
|
481
481
|
/**
|
|
482
482
|
* Map of field ID to its validation rules
|
|
@@ -507,8 +507,8 @@ class D {
|
|
|
507
507
|
if (typeof o == "object" && o.ExpressionTree)
|
|
508
508
|
l.push(o);
|
|
509
509
|
else if (typeof o == "string") {
|
|
510
|
-
const
|
|
511
|
-
|
|
510
|
+
const c = (i = (t = e.Rules) == null ? void 0 : t.Validation) == null ? void 0 : i[o];
|
|
511
|
+
c && l.push(c);
|
|
512
512
|
}
|
|
513
513
|
}
|
|
514
514
|
l.length > 0 && this.fieldRules.set(s, l);
|
|
@@ -549,11 +549,11 @@ class D {
|
|
|
549
549
|
return { valid: !0, errors: [] };
|
|
550
550
|
const a = {
|
|
551
551
|
formValues: { ...i, [e]: t },
|
|
552
|
-
systemValues:
|
|
552
|
+
systemValues: p()
|
|
553
553
|
};
|
|
554
554
|
for (const l of s)
|
|
555
555
|
try {
|
|
556
|
-
if (!
|
|
556
|
+
if (!f(l.ExpressionTree, a))
|
|
557
557
|
return {
|
|
558
558
|
valid: !1,
|
|
559
559
|
errors: [l.Message || `Validation failed: ${l.Name || l.Id}`]
|
|
@@ -627,7 +627,7 @@ class S {
|
|
|
627
627
|
/**
|
|
628
628
|
* Expression engine instance for evaluating backend validation rules
|
|
629
629
|
*/
|
|
630
|
-
n(this, "_expressionEngine", new
|
|
630
|
+
n(this, "_expressionEngine", new A());
|
|
631
631
|
}
|
|
632
632
|
/**
|
|
633
633
|
* Get all field definitions (system + business) with automatic binding.
|
|
@@ -640,7 +640,7 @@ class S {
|
|
|
640
640
|
const e = {};
|
|
641
641
|
for (const t of Object.keys(this)) {
|
|
642
642
|
const i = this[t];
|
|
643
|
-
i instanceof
|
|
643
|
+
i instanceof d && (e[t] = i);
|
|
644
644
|
}
|
|
645
645
|
if (!this._fieldsBound) {
|
|
646
646
|
for (const t of Object.values(e))
|
|
@@ -785,7 +785,7 @@ class S {
|
|
|
785
785
|
return u(this.meta._id).pivot(e);
|
|
786
786
|
}
|
|
787
787
|
}
|
|
788
|
-
class B extends
|
|
788
|
+
class B extends d {
|
|
789
789
|
constructor(e) {
|
|
790
790
|
super(e);
|
|
791
791
|
}
|
|
@@ -796,7 +796,7 @@ class B extends f {
|
|
|
796
796
|
} : { valid: !0, errors: [] };
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
|
-
class C extends
|
|
799
|
+
class C extends d {
|
|
800
800
|
constructor(e) {
|
|
801
801
|
super(e);
|
|
802
802
|
}
|
|
@@ -807,7 +807,7 @@ class C extends f {
|
|
|
807
807
|
} : { valid: !0, errors: [] };
|
|
808
808
|
}
|
|
809
809
|
}
|
|
810
|
-
class R extends
|
|
810
|
+
class R extends d {
|
|
811
811
|
constructor(t) {
|
|
812
812
|
super(t);
|
|
813
813
|
n(this, "options");
|
|
@@ -852,7 +852,7 @@ class R extends f {
|
|
|
852
852
|
};
|
|
853
853
|
}
|
|
854
854
|
}
|
|
855
|
-
class T extends
|
|
855
|
+
class T extends d {
|
|
856
856
|
constructor(e) {
|
|
857
857
|
super(e);
|
|
858
858
|
}
|
|
@@ -863,14 +863,63 @@ class T extends f {
|
|
|
863
863
|
} : { valid: !0, errors: [] };
|
|
864
864
|
}
|
|
865
865
|
}
|
|
866
|
+
class $ extends d {
|
|
867
|
+
constructor(e) {
|
|
868
|
+
super(e);
|
|
869
|
+
}
|
|
870
|
+
validate(e) {
|
|
871
|
+
if (e == null || e === "")
|
|
872
|
+
return { valid: !0, errors: [] };
|
|
873
|
+
if (typeof e != "string")
|
|
874
|
+
return {
|
|
875
|
+
valid: !1,
|
|
876
|
+
errors: [`${this.label} must be a valid date string`]
|
|
877
|
+
};
|
|
878
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(e))
|
|
879
|
+
return {
|
|
880
|
+
valid: !1,
|
|
881
|
+
errors: [`${this.label} must be in YYYY-MM-DD format`]
|
|
882
|
+
};
|
|
883
|
+
const t = /* @__PURE__ */ new Date(e + "T00:00:00");
|
|
884
|
+
return isNaN(t.getTime()) ? {
|
|
885
|
+
valid: !1,
|
|
886
|
+
errors: [`${this.label} is not a valid date`]
|
|
887
|
+
} : { valid: !0, errors: [] };
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
class U extends d {
|
|
891
|
+
constructor(e) {
|
|
892
|
+
super(e);
|
|
893
|
+
}
|
|
894
|
+
validate(e) {
|
|
895
|
+
return e != null && typeof e != "string" ? {
|
|
896
|
+
valid: !1,
|
|
897
|
+
errors: [`${this.label} must be a string`]
|
|
898
|
+
} : { valid: !0, errors: [] };
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
class j extends d {
|
|
902
|
+
constructor(e) {
|
|
903
|
+
super(e);
|
|
904
|
+
}
|
|
905
|
+
validate(e) {
|
|
906
|
+
return e == null ? { valid: !0, errors: [] } : typeof e != "object" || Array.isArray(e) ? {
|
|
907
|
+
valid: !1,
|
|
908
|
+
errors: [`${this.label} must be a valid object`]
|
|
909
|
+
} : { valid: !0, errors: [] };
|
|
910
|
+
}
|
|
911
|
+
}
|
|
866
912
|
export {
|
|
867
913
|
T as ArrayField,
|
|
868
914
|
S as BaseBdo,
|
|
869
915
|
C as BooleanField,
|
|
916
|
+
$ as DateField,
|
|
870
917
|
b as DateTimeField,
|
|
871
918
|
B as NumberField,
|
|
919
|
+
j as ObjectField,
|
|
872
920
|
_ as ReferenceField,
|
|
873
921
|
R as SelectField,
|
|
874
922
|
m as StringField,
|
|
875
|
-
|
|
923
|
+
L as SystemField,
|
|
924
|
+
U as TextAreaField
|
|
876
925
|
};
|
|
@@ -182,7 +182,7 @@ export interface JSONArrayType extends Array<JSONValueType> {
|
|
|
182
182
|
* @example
|
|
183
183
|
* SelectFieldType<'active' | 'inactive' | 'pending'> // => 'active' | 'inactive' | 'pending'
|
|
184
184
|
*/
|
|
185
|
-
export type SelectFieldType<T extends string> = T;
|
|
185
|
+
export type SelectFieldType<T extends string | number = string> = T;
|
|
186
186
|
/**
|
|
187
187
|
* Array field with MultiValue support
|
|
188
188
|
* @template T - Type of array elements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-fields.d.ts","sourceRoot":"","sources":["../../sdk/types/base-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,eAAe,CACzB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,UAAU,SAAS,MAAM,GAAG,KAAK,EACjC,UAAU,SAAS,MAAM,GAAG,KAAK,IAC/B,CAAC,CAAC;AAEN;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEvC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,CAAC,UAAU,SAAS,MAAM,GAAG,KAAK,IAAI,MAAM,CAAC;AAExE;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,eAAe;I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MAAM,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;AAMjD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAC5B,CAAC,SAAS,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAM/C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,eAAe,CAAC;IACrB,QAAQ,EAAE,eAAe,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,eAAe,CAAC;IACrB,WAAW,EAAE,iBAAiB,CAAC;IAC/B,YAAY,EAAE,iBAAiB,CAAC;IAChC,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,WAAW,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,eAAe,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC"}
|
|
@@ -230,6 +230,12 @@ export declare const BdoFieldType: {
|
|
|
230
230
|
readonly Object: "Object";
|
|
231
231
|
/** Activity flow field */
|
|
232
232
|
readonly ActivityFlow: "ActivityFlow";
|
|
233
|
+
/** Multi-line text field */
|
|
234
|
+
readonly TextArea: "TextArea";
|
|
235
|
+
/** Secret/password field */
|
|
236
|
+
readonly Secret: "Secret";
|
|
237
|
+
/** User reference field */
|
|
238
|
+
readonly User: "User";
|
|
233
239
|
};
|
|
234
240
|
/**
|
|
235
241
|
* Form input types for rendering
|
|
@@ -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;;IAEnB,4BAA4B;;IAE5B,gBAAg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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"}
|
package/package.json
CHANGED
package/sdk/base-types.ts
CHANGED
package/sdk/bdo/core/types.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface FieldMetaType {
|
|
|
31
31
|
/**
|
|
32
32
|
* SelectField meta — extends FieldMetaType with static options
|
|
33
33
|
*/
|
|
34
|
-
export interface SelectFieldMetaType<T = string> extends FieldMetaType {
|
|
34
|
+
export interface SelectFieldMetaType<T extends string | number = string> extends FieldMetaType {
|
|
35
35
|
readonly options: readonly SelectOptionType<T>[];
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -64,7 +64,7 @@ export interface FieldConfigType {
|
|
|
64
64
|
/**
|
|
65
65
|
* Configuration for select fields with predefined options
|
|
66
66
|
*/
|
|
67
|
-
export interface SelectFieldConfigType<T extends string> extends FieldConfigType {
|
|
67
|
+
export interface SelectFieldConfigType<T extends string | number = string> extends FieldConfigType {
|
|
68
68
|
options: readonly SelectOptionType<T>[];
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// DATE FIELD
|
|
3
|
+
// Field for date-only values (no time component)
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
import type { DateFieldType } from "../../types/base-fields";
|
|
7
|
+
import type { FieldConfigType, ValidationResultType } from "../core/types";
|
|
8
|
+
import { BaseField } from "./BaseField";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Field definition for date-only fields (YYYY-MM-DD)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* readonly BirthDate = new DateField({
|
|
16
|
+
* id: "BirthDate",
|
|
17
|
+
* label: "Birth Date"
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class DateField extends BaseField<DateFieldType> {
|
|
22
|
+
constructor(config: FieldConfigType) {
|
|
23
|
+
super(config);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
validate(value: DateFieldType | undefined): ValidationResultType {
|
|
27
|
+
if (value === undefined || value === null || (value as string) === "") {
|
|
28
|
+
return { valid: true, errors: [] };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (typeof value !== "string") {
|
|
32
|
+
return {
|
|
33
|
+
valid: false,
|
|
34
|
+
errors: [`${this.label} must be a valid date string`],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Enforce date-only format: YYYY-MM-DD (reject time components)
|
|
39
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
40
|
+
return {
|
|
41
|
+
valid: false,
|
|
42
|
+
errors: [`${this.label} must be in YYYY-MM-DD format`],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const date = new Date(value + "T00:00:00");
|
|
47
|
+
if (isNaN(date.getTime())) {
|
|
48
|
+
return {
|
|
49
|
+
valid: false,
|
|
50
|
+
errors: [`${this.label} is not a valid date`],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { valid: true, errors: [] };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// OBJECT FIELD
|
|
3
|
+
// Field for nested object values
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
import type { ObjectFieldType } from "../../types/base-fields";
|
|
7
|
+
import type { FieldConfigType, ValidationResultType } from "../core/types";
|
|
8
|
+
import { BaseField } from "./BaseField";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Field definition for nested object fields
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* readonly Config = new ObjectField({
|
|
16
|
+
* id: "Config",
|
|
17
|
+
* label: "Configuration"
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class ObjectField<
|
|
22
|
+
T extends Record<string, unknown> = Record<string, unknown>,
|
|
23
|
+
> extends BaseField<ObjectFieldType<T>> {
|
|
24
|
+
constructor(config: FieldConfigType) {
|
|
25
|
+
super(config);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
validate(value: ObjectFieldType<T> | undefined): ValidationResultType {
|
|
29
|
+
if (value === undefined || value === null) {
|
|
30
|
+
return { valid: true, errors: [] };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
34
|
+
return {
|
|
35
|
+
valid: false,
|
|
36
|
+
errors: [`${this.label} must be a valid object`],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { valid: true, errors: [] };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -26,7 +26,7 @@ import { BaseField } from "./BaseField";
|
|
|
26
26
|
* });
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
export class SelectField<T extends string = string> extends BaseField<T> {
|
|
29
|
+
export class SelectField<T extends string | number = string> extends BaseField<T> {
|
|
30
30
|
protected readonly options: readonly SelectOptionType<T>[];
|
|
31
31
|
|
|
32
32
|
constructor(config: SelectFieldConfigType<T>) {
|
|
@@ -35,7 +35,7 @@ export class SelectField<T extends string = string> extends BaseField<T> {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
validate(value: T | undefined): ValidationResultType {
|
|
38
|
-
if (value === undefined || value === null || value === "") {
|
|
38
|
+
if (value === undefined || value === null || (value as string) === "") {
|
|
39
39
|
return { valid: true, errors: [] };
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// TEXTAREA FIELD
|
|
3
|
+
// Field for multi-line text values
|
|
4
|
+
// ============================================================
|
|
5
|
+
|
|
6
|
+
import type { TextAreaFieldType } from "../../types/base-fields";
|
|
7
|
+
import type { FieldConfigType, ValidationResultType } from "../core/types";
|
|
8
|
+
import { BaseField } from "./BaseField";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Field definition for multi-line text fields
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* readonly Description = new TextAreaField({
|
|
16
|
+
* id: "Description",
|
|
17
|
+
* label: "Description"
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class TextAreaField extends BaseField<TextAreaFieldType> {
|
|
22
|
+
constructor(config: FieldConfigType) {
|
|
23
|
+
super(config);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
validate(value: TextAreaFieldType | undefined): ValidationResultType {
|
|
27
|
+
if (value !== undefined && value !== null && typeof value !== "string") {
|
|
28
|
+
return {
|
|
29
|
+
valid: false,
|
|
30
|
+
errors: [`${this.label} must be a string`],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return { valid: true, errors: [] };
|
|
34
|
+
}
|
|
35
|
+
}
|
package/sdk/bdo/fields/index.ts
CHANGED
|
@@ -10,3 +10,6 @@ export { DateTimeField } from "./DateTimeField";
|
|
|
10
10
|
export { SelectField } from "./SelectField";
|
|
11
11
|
export { ReferenceField } from "./ReferenceField";
|
|
12
12
|
export { ArrayField } from "./ArrayField";
|
|
13
|
+
export { DateField } from "./DateField";
|
|
14
|
+
export { TextAreaField } from "./TextAreaField";
|
|
15
|
+
export { ObjectField } from "./ObjectField";
|
package/sdk/bdo.ts
CHANGED
|
@@ -13,9 +13,12 @@ export {
|
|
|
13
13
|
NumberField,
|
|
14
14
|
BooleanField,
|
|
15
15
|
DateTimeField,
|
|
16
|
+
DateField,
|
|
17
|
+
TextAreaField,
|
|
16
18
|
SelectField,
|
|
17
19
|
ReferenceField,
|
|
18
20
|
ArrayField,
|
|
21
|
+
ObjectField,
|
|
19
22
|
} from "./bdo/fields";
|
|
20
23
|
|
|
21
24
|
// Re-export types for consumer convenience
|
|
@@ -25,8 +28,11 @@ export type {
|
|
|
25
28
|
BooleanFieldType,
|
|
26
29
|
DateFieldType,
|
|
27
30
|
DateTimeFieldType,
|
|
31
|
+
TextAreaFieldType,
|
|
32
|
+
SelectFieldType,
|
|
28
33
|
ReferenceFieldType,
|
|
29
34
|
ArrayFieldType,
|
|
35
|
+
ObjectFieldType,
|
|
30
36
|
SystemFieldsType,
|
|
31
37
|
UserRefType,
|
|
32
38
|
} from "./types/base-fields";
|
package/sdk/types/base-fields.ts
CHANGED
|
@@ -217,7 +217,7 @@ export interface JSONArrayType extends Array<JSONValueType> {}
|
|
|
217
217
|
* @example
|
|
218
218
|
* SelectFieldType<'active' | 'inactive' | 'pending'> // => 'active' | 'inactive' | 'pending'
|
|
219
219
|
*/
|
|
220
|
-
export type SelectFieldType<T extends string> = T;
|
|
220
|
+
export type SelectFieldType<T extends string | number = string> = T;
|
|
221
221
|
|
|
222
222
|
// ============================================================
|
|
223
223
|
// CONTAINER AND UTILITY TYPES
|
package/sdk/types/constants.ts
CHANGED
|
@@ -268,6 +268,12 @@ export const BdoFieldType = {
|
|
|
268
268
|
Object: "Object",
|
|
269
269
|
/** Activity flow field */
|
|
270
270
|
ActivityFlow: "ActivityFlow",
|
|
271
|
+
/** Multi-line text field */
|
|
272
|
+
TextArea: "TextArea",
|
|
273
|
+
/** Secret/password field */
|
|
274
|
+
Secret: "Secret",
|
|
275
|
+
/** User reference field */
|
|
276
|
+
User: "User",
|
|
271
277
|
} as const;
|
|
272
278
|
|
|
273
279
|
/**
|