openxiangda-contracts 2.34.0 → 2.43.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.
- package/dist/browser.d.ts +8 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +8 -0
- package/dist/browser.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/native-compiler/compiler.d.ts +1 -1
- package/dist/native-compiler/compiler.d.ts.map +1 -1
- package/dist/native-compiler/compiler.js +99 -5
- package/dist/native-compiler/compiler.js.map +1 -1
- package/dist/native-compiler/index.cjs +6 -5
- package/dist/native-compiler/index.d.ts +10 -0
- package/dist/native-compiler/index.d.ts.map +1 -1
- package/dist/native-compiler/index.js +6 -5
- package/dist/native-compiler/role-membership-batch.d.ts +73 -0
- package/dist/native-compiler/role-membership-batch.d.ts.map +1 -0
- package/dist/native-compiler/role-membership-batch.js +91 -0
- package/dist/native-compiler/role-membership-batch.js.map +1 -0
- package/dist/native-compiler/workflow-assignment-routing.d.ts +121 -0
- package/dist/native-compiler/workflow-assignment-routing.d.ts.map +1 -0
- package/dist/native-compiler/workflow-assignment-routing.js +113 -0
- package/dist/native-compiler/workflow-assignment-routing.js.map +1 -0
- package/dist/native-compiler/workflow-automatic-cc.d.ts +20 -0
- package/dist/native-compiler/workflow-automatic-cc.d.ts.map +1 -0
- package/dist/native-compiler/workflow-automatic-cc.js +36 -0
- package/dist/native-compiler/workflow-automatic-cc.js.map +1 -0
- package/dist/native-compiler/workflow-business-step-identity.d.ts +12 -0
- package/dist/native-compiler/workflow-business-step-identity.d.ts.map +1 -0
- package/dist/native-compiler/workflow-business-step-identity.js +11 -0
- package/dist/native-compiler/workflow-business-step-identity.js.map +1 -0
- package/dist/native-compiler/workflow-business-step.d.ts +119 -0
- package/dist/native-compiler/workflow-business-step.d.ts.map +1 -0
- package/dist/native-compiler/workflow-business-step.js +357 -0
- package/dist/native-compiler/workflow-business-step.js.map +1 -0
- package/dist/native-compiler/workflow-delegation-administration.d.ts +1084 -0
- package/dist/native-compiler/workflow-delegation-administration.d.ts.map +1 -0
- package/dist/native-compiler/workflow-delegation-administration.js +68 -0
- package/dist/native-compiler/workflow-delegation-administration.js.map +1 -0
- package/dist/native-compiler/workflow-graph.d.ts +182 -0
- package/dist/native-compiler/workflow-graph.d.ts.map +1 -0
- package/dist/native-compiler/workflow-graph.js +201 -0
- package/dist/native-compiler/workflow-graph.js.map +1 -0
- package/dist/native-compiler/workflow-node-administration.d.ts +46 -0
- package/dist/native-compiler/workflow-node-administration.d.ts.map +1 -0
- package/dist/native-compiler/workflow-node-administration.js +105 -0
- package/dist/native-compiler/workflow-node-administration.js.map +1 -0
- package/dist/native-compiler/workflow-task-page.d.ts +119 -0
- package/dist/native-compiler/workflow-task-page.d.ts.map +1 -0
- package/dist/native-compiler/workflow-task-page.js +225 -0
- package/dist/native-compiler/workflow-task-page.js.map +1 -0
- package/dist/native-version.d.ts +10 -0
- package/dist/native-version.d.ts.map +1 -1
- package/dist/native-version.js +10 -0
- package/dist/native-version.js.map +1 -1
- package/dist/native.d.ts +2 -0
- package/dist/native.d.ts.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/schemas.d.ts +4745 -1006
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +217 -0
- package/dist/schemas.js.map +1 -1
- package/dist/types.d.ts +218 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
"use strict";var Do=Object.create;var Ke=Object.defineProperty;var Vo=Object.getOwnPropertyDescriptor;var wo=Object.getOwnPropertyNames;var Fo=Object.getPrototypeOf,vo=Object.prototype.hasOwnProperty;var Po=(e,t)=>{for(var o in t)Ke(e,o,{get:t[o],enumerable:!0})},mn=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of wo(t))!vo.call(e,s)&&s!==o&&Ke(e,s,{get:()=>t[s],enumerable:!(n=Vo(t,s))||n.enumerable});return e};var Lo=(e,t,o)=>(o=e!=null?Do(Fo(e)):{},mn(t||!e||!e.__esModule?Ke(o,"default",{value:e,enumerable:!0}):o,e)),ko=e=>mn(Ke({},"__esModule",{value:!0}),e);var fr={};Po(fr,{DATA_AUDIT_METADATA_FIELDS:()=>Ft,DATA_EVENT_TYPES_V2:()=>At,DATA_SYSTEM_SORT_FIELD_CODES:()=>yn,ManagedConcurrencyContractError:()=>Fe,NATIVE_CONFIGURATION_VALIDATOR_DIGEST:()=>ur,NATIVE_CONTRACT_CAPACITY_V2:()=>Y,NATIVE_DATA_POLICY_EXPRESSION_MAX_CLAUSES:()=>Yr,NATIVE_DATA_POLICY_EXPRESSION_MAX_DEPTH:()=>zr,NATIVE_DATA_POLICY_EXPRESSION_MAX_GROUP_ITEMS:()=>Gr,NATIVE_DATA_POLICY_EXPRESSION_MAX_LEAVES:()=>qr,NATIVE_DATA_POLICY_EXPRESSION_MAX_OCCURRENCES:()=>Kr,NATIVE_DATA_QUERY_OPERATORS_V2:()=>Rn,NATIVE_UNIQUE_KEY_MAX_BYTES:()=>xr,NATIVE_UNIQUE_KEY_NORMALIZERS:()=>en,NativeConfigurationCompilerError:()=>It,NativeDataFieldContractV2Error:()=>de,NativeDataPolicyExpressionV2Error:()=>Le,NativeDecimalLifecycleContractError:()=>ye,NativeEventActionContractError:()=>Et,NativeScopeSourceFieldPathV2Error:()=>ut,NativeUniqueKeyContractError:()=>Pe,OPENXIANGDA_NATIVE_DATA_FIELD_TYPES_V2:()=>bn,OPENXIANGDA_NATIVE_DATA_SURFACE_KEYS_V2:()=>ge,OPENXIANGDA_NATIVE_DRAFT_STATE_KEYS_V2:()=>ot,OPENXIANGDA_NATIVE_SYSTEM_FIELDS_V2:()=>Qe,OPENXIANGDA_NATIVE_SYSTEM_FIELD_MAP_V2:()=>Dt,WORKFLOW_EVENT_TYPES_V2:()=>mt,compileNativeApplicationConfiguration:()=>gi,compileNativeEventAction:()=>nn,compileNativeEventCapturePlansV2:()=>mo,compileRequiredPlatformCapabilitiesV3:()=>Ao,hasDataAuditReadPolicy:()=>vt,isDataAuditMetadataField:()=>Se,isDataSystemSortField:()=>Pt,isNativeDataQueryOperatorV2:()=>Ho,isNativeMultiValueFieldV2:()=>Me,materializeNativeDataQueryPathTypesV2:()=>Js,nativeDataPolicyExpressionLeavesV2:()=>ze,nativeDataPolicyExpressionToCnfV2:()=>an,nativeDataQueryPathPlanV2:()=>Ws,nativeFieldAggregatePlanV2:()=>ss,nativeFieldColumnDefinitionV2:()=>gs,nativeFieldDefaultSqlV2:()=>Ns,nativeFieldHasDefaultV2:()=>Cs,nativeFieldIndexStatementsV2:()=>hs,nativeFieldRequiresCreateInputV2:()=>je,nativeFieldSequenceGrantStatementsV2:()=>ys,nativeFieldSequenceOwnershipStatementsV2:()=>Os,nativeFieldSequenceStatementsV2:()=>bs,nativeFieldSupportsFilterV2:()=>Mt,nativeFieldSupportsOperatorV2:()=>ts,nativeFieldSupportsSearchV2:()=>tt,nativeFieldSupportsSortV2:()=>Ve,nativeOperatorsForFieldV2:()=>Ut,nativePhysicalFieldV2:()=>xn,nativePhysicalFieldsV2:()=>Is,nativePhysicalObjectNameV2:()=>Te,nativeScopeSourceFieldValueV2:()=>Fs,nativeScopeSourceGrantPathSupportedV2:()=>Xt,nativeScopeSourceSubjectPathSupportedV2:()=>ft,nativeSubtableConstraintStatementsV2:()=>$s,nativeUniqueKeysJsonSchema:()=>Gs,parseDecimalReservationLifecycle:()=>ct,parseNativeDataFieldsV2:()=>Ze,parseNativeDataResourceInvariantsV2:()=>wt,parseNativeUniqueKeys:()=>tn,projectNativeDataResourceViewV2:()=>it,quoteNativeIdentifierV2:()=>ne,resolveNativeScopeSourceFieldPathV2:()=>ve,validateDecimalReservationLifecycles:()=>Kt,validateManagedConcurrency:()=>zt,validateNativeDataDraftStateV2:()=>Bt,validateNativeDataResourceReferencesV2:()=>Vt,validateNativeDataResourceSurfaceV2:()=>st,validateWorkflowInstanceCommandPolicies:()=>sn,workflowInstanceCommandDeadlineError:()=>Ys,workflowInstanceTerminateCapabilityAllowed:()=>qs,workflowPolicyTimestamp:()=>on});module.exports=ko(fr);var In=require("node:crypto");function xo(e){if(!e||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ht(e,t){if(e===null)return"null";if(typeof e=="string"||typeof e=="boolean")return JSON.stringify(e);if(typeof e=="number"){if(!Number.isFinite(e))throw new TypeError(`JSON number must be finite: ${t}`);return JSON.stringify(e)}if(Array.isArray(e))return`[${e.map((n,s)=>ht(n,`${t}[${s}]`)).join(",")}]`;if(xo(e))return`{${Object.keys(e).filter(s=>e[s]!==void 0).sort((s,i)=>s===i?0:s<i?-1:1).map(s=>`${JSON.stringify(s)}:${ht(e[s],`${t}.${s}`)}`).join(",")}}`;let o=e instanceof Date?"Date":e?.constructor?.name||typeof e;throw new TypeError(`Value is not JSON serializable: ${t} (${o})`)}function Q(e){return ht(e,"$")}function ee(e){return(0,In.createHash)("sha256").update(Q(e)).digest("hex")}var Cn=/^[A-Za-z][A-Za-z0-9_]{0,62}$/,St=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,bn=["text.short","text.long","text.rich","number.integer","number.decimal","boolean","date","time","datetime","date-range","datetime-range","option.single","option.multiple","cascade.single","cascade.multiple","user.single","user.multiple","department.single","department.multiple","resource-ref.single","resource-ref.multiple","image","signature","address","location","uuid","json","file","serial-number","subtable"],Uo=new Set(bn),On=new Set(["option.multiple","cascade.multiple","user.multiple","department.multiple","resource-ref.multiple","file","image","subtable"]),gn=new Set(["option.single","option.multiple","cascade.single","cascade.multiple"]),Nn=new Set(["resource-ref.single","resource-ref.multiple"]),Qe=[{code:"id",type:"uuid",nullable:!1},{code:"revision",type:"number.integer",nullable:!1},{code:"created_by",type:"text.short",nullable:!1},{code:"updated_by",type:"text.short",nullable:!1},{code:"created_at",type:"datetime",nullable:!1},{code:"updated_at",type:"datetime",nullable:!1}],Dt=new Map(Qe.map(e=>[e.code,e])),de=class extends Error{constructor(o,n){super(o);this.code=o;this.pointer=n;this.name="NativeDataFieldContractV2Error"}code;pointer};function Me(e){return On.has(e)}function je(e,t={}){return e.type!=="serial-number"&&t.system!==!0&&e.nullable===!1&&(!Me(e.type)||t.requiredHint===!0)}function Ze(e,t,o=500){Array.isArray(e)||D("NATIVE_ARRAY_REQUIRED",t),e.length===0&&D("NATIVE_DATA_FIELDS_REQUIRED",t),e.length>o&&D("NATIVE_ARRAY_LIMIT_EXCEEDED",t);let n=new Set;return e.map((s,i)=>{let c=`${t}/${i}`,r=re(s,c);ce(r,["code","type","nullable","indexed","options","source","maxLength","precision","scale","exactDecimal","min","max","rangeBoundary","timePrecision","file","serial","subtable"],c);let a=le(r.code,`${c}/code`,63);Cn.test(a)||D("NATIVE_FIELD_CODE_INVALID",`${c}/code`),n.has(a)&&D("NATIVE_DATA_FIELD_DUPLICATE",`${c}/code`),n.add(a);let f=le(r.type,`${c}/type`,32);Uo.has(f)||D("NATIVE_DATA_FIELD_TYPE_INVALID",`${c}/type`);let _=f,d=Rt(r.nullable,`${c}/nullable`),u=Rt(r.indexed,`${c}/indexed`);d===!0&&On.has(_)&&D("NATIVE_DATA_MULTI_FIELD_NULLABLE_INVALID",`${c}/nullable`);let I=Bo(r.options,_,c),l=Jo(r.source,_,c),E=zo(r,_,c),T=Rt(r.exactDecimal,`${c}/exactDecimal`);T!==void 0&&_!=="number.decimal"&&D("NATIVE_DATA_FIELD_EXACT_DECIMAL_TYPE_INVALID",`${c}/exactDecimal`);let g=Mo(r.rangeBoundary,_,c),A=Go(r.file,_,c),m=qo(r.serial,_,c),O=Yo(r.subtable,_,c);return{code:a,type:_,...d===void 0?{}:{nullable:d},...u===void 0?{}:{indexed:u},...I?{options:I}:{},...l?{source:l}:{},...E,...T===void 0?{}:{exactDecimal:T},...g?{rangeBoundary:g}:{},...A?{file:A}:{},...m?{serial:m}:{},...O?{subtable:O}:{}}})}function Mo(e,t,o){let n=`${o}/rangeBoundary`;if(!(t==="date-range"||t==="datetime-range")){e!==void 0&&D("NATIVE_DATA_FIELD_RANGE_BOUNDARY_TYPE_INVALID",n);return}return e!=="closed"&&e!=="half-open"&&D("NATIVE_DATA_FIELD_RANGE_BOUNDARY_REQUIRED",n),e}function Vt(e,t){Array.isArray(e)||D("NATIVE_ARRAY_REQUIRED",t);let o=new Map;e.forEach((n,s)=>{let i=`${t}/${s}`,c=re(n,i),r=le(c.code,`${i}/code`,64);(!St.test(r)||o.has(r))&&D("NATIVE_RESOURCE_CODE_INVALID",`${i}/code`);let a=re(c.schema,`${i}/schema`);o.set(r,{pointer:i,fields:Ze(a.fields,`${i}/schema/fields`)})});for(let[n,s]of o){let i=new Map(s.fields.map(r=>[r.code,r]));s.fields.filter(r=>r.type==="subtable").reduce((r,a)=>r+(a.subtable?.maxRows??20),0)>49&&D("NATIVE_DATA_FIELD_SUBTABLE_AGGREGATE_MAX_ROWS_EXCEEDED",`${s.pointer}/schema/fields`),s.fields.forEach((r,a)=>{let f=`${s.pointer}/schema/fields/${a}`;if(r.source&&jo(r.source,i,o,`${f}/source`),r.subtable){let _=o.get(r.subtable.resourceCode);(!_||r.subtable.resourceCode===n)&&D("NATIVE_DATA_FIELD_SUBTABLE_TARGET_MISSING",`${f}/subtable/resourceCode`);let d=_.fields.find(I=>I.code===r.subtable?.foreignKey);(!d||d.type!=="uuid"||d.nullable!==!1)&&D("NATIVE_DATA_FIELD_SUBTABLE_FOREIGN_KEY_INVALID",`${f}/subtable/foreignKey`);let u=_.fields.find(I=>I.code===r.subtable?.orderField);(!u||u.type!=="number.integer"||u.nullable!==!1)&&D("NATIVE_DATA_FIELD_SUBTABLE_ORDER_FIELD_INVALID",`${f}/subtable/orderField`)}})}}function wt(e,t,o){if(e===void 0)return[];(!Array.isArray(e)||e.length>20)&&D("NATIVE_DATA_RESOURCE_INVARIANTS_INVALID",o);let n=new Map(t.map(i=>[i.code,i])),s=new Set;return e.map((i,c)=>{let r=`${o}/${c}`,a=re(i,r);ce(a,["code","message","expression"],r);let f=le(a.code,`${r}/code`,128);(!/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(f)||s.has(f))&&D("NATIVE_DATA_RESOURCE_INVARIANT_CODE_INVALID",`${r}/code`),s.add(f);let _=Xe(a.message,`${r}/message`,500);_!==void 0&&_.length===0&&D("NATIVE_DATA_RESOURCE_INVARIANT_MESSAGE_INVALID",`${r}/message`);let d=re(a.expression,`${r}/expression`);if(d.kind==="nonBlankTextWhenOption"){ce(d,["kind","optionField","optionValue","textField"],`${r}/expression`);let A=_e(d.optionField,`${r}/expression/optionField`),m=_e(d.textField,`${r}/expression/textField`),O=le(d.optionValue,`${r}/expression/optionValue`,128),C=n.get(A),b=n.get(m);return(!C||!b)&&D("NATIVE_DATA_RESOURCE_INVARIANT_FIELD_UNKNOWN",`${r}/expression`),(C.type!=="option.single"||!["text.short","text.long"].includes(b.type)||!C.options?.some(y=>y.value===O))&&D("NATIVE_DATA_RESOURCE_INVARIANT_FIELD_TYPES_INVALID",`${r}/expression`),{code:f,..._===void 0?{}:{message:_},expression:{kind:"nonBlankTextWhenOption",optionField:A,optionValue:O,textField:m}}}ce(d,["leftField","operator","rightField"],`${r}/expression`);let u=_e(d.leftField,`${r}/expression/leftField`),I=_e(d.rightField,`${r}/expression/rightField`),l=n.get(u),E=n.get(I);(!l||!E)&&D("NATIVE_DATA_RESOURCE_INVARIANT_FIELD_UNKNOWN",`${r}/expression`),l.type===E.type||["number.integer","number.decimal"].includes(l.type)&&["number.integer","number.decimal"].includes(E.type)||D("NATIVE_DATA_RESOURCE_INVARIANT_FIELD_TYPES_INVALID",`${r}/expression`);let g=String(d.operator);return["eq","neq","gt","gte","lt","lte"].includes(g)||D("NATIVE_DATA_RESOURCE_INVARIANT_OPERATOR_INVALID",`${r}/expression/operator`),!["eq","neq"].includes(g)&&!["number.integer","number.decimal","date","time","datetime","text.short","text.long","text.rich","serial-number","uuid"].includes(l.type)&&D("NATIVE_DATA_RESOURCE_INVARIANT_FIELD_TYPES_INVALID",`${r}/expression`),{code:f,..._===void 0?{}:{message:_},expression:{leftField:u,operator:g,rightField:I}}})}function jo(e,t,o,n){let s=o.get(e.resourceCode);s||D("NATIVE_DATA_FIELD_SOURCE_TARGET_MISSING",`${n}/resourceCode`);let i=new Map(s.fields.map(r=>[r.code,r])),c=i.get(e.labelField);(!c||!["text.short","text.long"].includes(c.type))&&D("NATIVE_DATA_FIELD_SOURCE_LABEL_INVALID",`${n}/labelField`);for(let r of["searchFields","descriptionFields","snapshotFields"])for(let a of e[r]||[])i.has(a)||D("NATIVE_DATA_FIELD_SOURCE_FIELD_MISSING",`${n}/${r}`);for(let[r,a]of(e.filters||[]).entries())i.has(a.field)||D("NATIVE_DATA_FIELD_SOURCE_FILTER_FIELD_MISSING",`${n}/filters/${r}/field`),"binding"in a&&!t.has(a.binding.field)&&D("NATIVE_DATA_FIELD_SOURCE_BINDING_FIELD_MISSING",`${n}/filters/${r}/binding/field`)}function Bo(e,t,o){let n=`${o}/options`;if(e===void 0){gn.has(t)&&D("NATIVE_DATA_FIELD_OPTIONS_REQUIRED",n);return}(!gn.has(t)||!Array.isArray(e))&&D("NATIVE_DATA_FIELD_OPTIONS_TYPE_INVALID",n),(e.length<1||e.length>100)&&D("NATIVE_DATA_FIELD_OPTIONS_INVALID",n);let s=0,i=(c,r,a)=>{a>5&&D("NATIVE_DATA_FIELD_OPTIONS_DEPTH_EXCEEDED",r);let f=new Set;return c.map((_,d)=>{s+=1,s>1e3&&D("NATIVE_DATA_FIELD_OPTIONS_COUNT_EXCEEDED",n);let u=`${r}/${d}`,I=re(_,u);ce(I,["label","value","description","color","children"],u);let l=le(I.label,`${u}/label`,500),E=le(I.value,`${u}/value`,500);f.has(E)&&D("NATIVE_DATA_FIELD_OPTION_VALUE_DUPLICATE",`${u}/value`),f.add(E);let T=Xe(I.description,`${u}/description`,2e3),g=Xe(I.color,`${u}/color`,64),A;return I.children!==void 0&&((!t.startsWith("cascade.")||!Array.isArray(I.children))&&D("NATIVE_DATA_FIELD_OPTION_CHILDREN_INVALID",`${u}/children`),(I.children.length<1||I.children.length>100)&&D("NATIVE_DATA_FIELD_OPTION_CHILDREN_INVALID",`${u}/children`),A=i(I.children,`${u}/children`,a+1)),{label:l,value:E,...T===void 0?{}:{description:T},...g===void 0?{}:{color:g},...A?{children:A}:{}}})};return i(e,n,1)}function Jo(e,t,o){let n=`${o}/source`;if(e===void 0){Nn.has(t)&&D("NATIVE_DATA_FIELD_SOURCE_REQUIRED",n);return}Nn.has(t)||D("NATIVE_DATA_FIELD_SOURCE_TYPE_INVALID",n);let s=re(e,n);ce(s,["kind","resourceCode","labelField","searchFields","descriptionFields","snapshotFields","filters","pageSize","loadMode"],n),s.kind!=="resource"&&D("NATIVE_DATA_FIELD_SOURCE_KIND_INVALID",`${n}/kind`);let i=le(s.resourceCode,`${n}/resourceCode`,64);St.test(i)||D("NATIVE_RESOURCE_CODE_INVALID",`${n}/resourceCode`);let c=_e(s.labelField,`${n}/labelField`),r=$t(s.searchFields,`${n}/searchFields`,10),a=$t(s.descriptionFields,`${n}/descriptionFields`,10),f=$t(s.snapshotFields,`${n}/snapshotFields`,50),_=Re(s.pageSize,`${n}/pageSize`,1,100),d;s.loadMode!==void 0&&(["search","all"].includes(String(s.loadMode))||D("NATIVE_DATA_FIELD_SOURCE_LOAD_MODE_INVALID",`${n}/loadMode`),d=s.loadMode);let u=Wo(s.filters,`${n}/filters`);return{kind:"resource",resourceCode:i,labelField:c,...r?{searchFields:r}:{},...a?{descriptionFields:a}:{},...f?{snapshotFields:f}:{},...u?{filters:u}:{},..._===void 0?{}:{pageSize:_},...d?{loadMode:d}:{}}}function Wo(e,t){if(e!==void 0)return(!Array.isArray(e)||e.length>20)&&D("NATIVE_DATA_FIELD_SOURCE_FILTERS_INVALID",t),e.map((o,n)=>{let s=`${t}/${n}`,i=re(o,s),c=Object.prototype.hasOwnProperty.call(i,"value"),r=Object.prototype.hasOwnProperty.call(i,"binding");ce(i,c?["field","operator","value"]:["field","operator","binding"],s),c===r&&D("NATIVE_DATA_FIELD_SOURCE_FILTER_VALUE_INVALID",s);let a=_e(i.field,`${s}/field`);["eq","in"].includes(String(i.operator))||D("NATIVE_DATA_FIELD_SOURCE_FILTER_OPERATOR_INVALID",`${s}/operator`);let f=i.operator;if(c)return{field:a,operator:f,value:i.value};let _=re(i.binding,`${s}/binding`);return ce(_,["kind","field"],`${s}/binding`),_.kind!=="field"&&D("NATIVE_DATA_FIELD_SOURCE_BINDING_KIND_INVALID",`${s}/binding/kind`),{field:a,operator:f,binding:{kind:"field",field:_e(_.field,`${s}/binding/field`)}}})}function zo(e,t,o){let n={};if(e.maxLength!==void 0&&(["text.short","text.long","text.rich"].includes(t)||D("NATIVE_DATA_FIELD_MAX_LENGTH_TYPE_INVALID",`${o}/maxLength`),n.maxLength=He(e.maxLength,`${o}/maxLength`,1,1e6)),(e.precision!==void 0||e.scale!==void 0)&&((t!=="number.decimal"||e.precision===void 0)&&D("NATIVE_DATA_FIELD_DECIMAL_CONFIG_INVALID",o),n.precision=He(e.precision,`${o}/precision`,1,1e3),n.scale=e.scale===void 0?0:He(e.scale,`${o}/scale`,0,n.precision)),e.min!==void 0||e.max!==void 0){["number.integer","number.decimal"].includes(t)||D("NATIVE_DATA_FIELD_NUMERIC_BOUNDS_TYPE_INVALID",o);let s=Tn(e.min,`${o}/min`),i=Tn(e.max,`${o}/max`);t==="number.integer"&&[s,i].some(c=>c!==void 0&&!Number.isSafeInteger(c))&&D("NATIVE_DATA_FIELD_NUMERIC_BOUNDS_INVALID",o),s!==void 0&&i!==void 0&&s>i&&D("NATIVE_DATA_FIELD_NUMERIC_BOUNDS_INVALID",o),s!==void 0&&(n.min=s),i!==void 0&&(n.max=i)}return e.timePrecision!==void 0&&((t!=="time"||!["minute","second"].includes(e.timePrecision))&&D("NATIVE_DATA_FIELD_TIME_PRECISION_INVALID",`${o}/timePrecision`),n.timePrecision=e.timePrecision),n}function Go(e,t,o){if(e===void 0)return;let n=`${o}/file`;["file","image","signature"].includes(t)||D("NATIVE_DATA_FIELD_FILE_TYPE_INVALID",n);let s=re(e,n);ce(s,["maxCount","maxSizeMb","accept"],n);let i=Re(s.maxCount,`${n}/maxCount`,1,100);t==="signature"&&i!==void 0&&i!==1&&D("NATIVE_DATA_FIELD_SIGNATURE_COUNT_INVALID",`${n}/maxCount`);let c=Re(s.maxSizeMb,`${n}/maxSizeMb`,1,1024),r;return s.accept!==void 0&&((!Array.isArray(s.accept)||s.accept.length>50)&&D("NATIVE_DATA_FIELD_FILE_ACCEPT_INVALID",`${n}/accept`),r=s.accept.map((a,f)=>le(a,`${n}/accept/${f}`,255)),new Set(r).size!==r.length&&D("NATIVE_DATA_FIELD_FILE_ACCEPT_INVALID",`${n}/accept`)),{...i===void 0?{}:{maxCount:i},...c===void 0?{}:{maxSizeMb:c},...r===void 0?{}:{accept:r}}}function qo(e,t,o){let n=`${o}/serial`;if(e===void 0){t==="serial-number"&&D("NATIVE_DATA_FIELD_SERIAL_REQUIRED",n);return}t!=="serial-number"&&D("NATIVE_DATA_FIELD_SERIAL_TYPE_INVALID",n);let s=re(e,n);ce(s,["prefix","digits","start"],n);let i=Xe(s.prefix,`${n}/prefix`,64),c=Re(s.digits,`${n}/digits`,1,32),r=Re(s.start,`${n}/start`,0,Number.MAX_SAFE_INTEGER);return{...i===void 0?{}:{prefix:i},...c===void 0?{}:{digits:c},...r===void 0?{}:{start:r}}}function Yo(e,t,o){let n=`${o}/subtable`;if(e===void 0){t==="subtable"&&D("NATIVE_DATA_FIELD_SUBTABLE_REQUIRED",n);return}t!=="subtable"&&D("NATIVE_DATA_FIELD_SUBTABLE_TYPE_INVALID",n);let s=re(e,n);ce(s,["resourceCode","foreignKey","orderField","maxRows"],n);let i=le(s.resourceCode,`${n}/resourceCode`,64);St.test(i)||D("NATIVE_RESOURCE_CODE_INVALID",`${n}/resourceCode`);let c=_e(s.foreignKey,`${n}/foreignKey`),r=_e(s.orderField,`${n}/orderField`);r===c&&D("NATIVE_DATA_FIELD_SUBTABLE_ORDER_FIELD_INVALID",`${n}/orderField`);let a=Re(s.maxRows,`${n}/maxRows`,1,49);return{resourceCode:i,foreignKey:c,orderField:r,...a===void 0?{}:{maxRows:a}}}function $t(e,t,o){if(e===void 0)return;(!Array.isArray(e)||e.length>o)&&D("NATIVE_DATA_FIELD_SOURCE_FIELDS_INVALID",t);let n=e.map((s,i)=>_e(s,`${t}/${i}`));return new Set(n).size!==n.length&&D("NATIVE_DATA_FIELD_SOURCE_FIELDS_INVALID",t),n}function _e(e,t){let o=le(e,t,63);return Cn.test(o)||D("NATIVE_FIELD_CODE_INVALID",t),o}function re(e,t){return(!e||typeof e!="object"||Array.isArray(e))&&D("NATIVE_OBJECT_REQUIRED",t),e}function ce(e,t,o){let n=new Set(t);for(let s of Object.keys(e))n.has(s)||D("NATIVE_PROPERTY_UNKNOWN",`${o}/${s}`)}function le(e,t,o){return(typeof e!="string"||e.length===0||e.length>o)&&D("NATIVE_STRING_INVALID",t),e}function Xe(e,t,o){if(e!==void 0)return(typeof e!="string"||e.length>o)&&D("NATIVE_STRING_INVALID",t),e}function Rt(e,t){if(e!==void 0)return typeof e!="boolean"&&D("NATIVE_BOOLEAN_REQUIRED",t),e}function Re(e,t,o,n){if(e!==void 0)return He(e,t,o,n)}function Tn(e,t){if(e!==void 0)return(typeof e!="number"||!Number.isFinite(e))&&D("NATIVE_NUMBER_REQUIRED",t),e}function He(e,t,o,n){return(!Number.isSafeInteger(e)||Number(e)<o||Number(e)>n)&&D("NATIVE_INTEGER_OUT_OF_RANGE",t),Number(e)}function D(e,t){throw new de(e,t)}var Ft=["created_by","updated_by","created_at","updated_at"];function Se(e){return Ft.includes(e)}function vt(e){return Ft.some(t=>Object.prototype.hasOwnProperty.call(e.fieldPolicies||{},t))}var yn=Qe.map(e=>e.code);function Pt(e){return yn.includes(e)}var Rn=["eq","neq","gt","gte","lt","lte","contains","startsWith","endsWith","in","between","has","hasAny","hasAll","overlaps","containedBy","jsonContains","isEmpty","isNotEmpty"],Ko=new Set(Rn);function Ho(e){return Ko.has(String(e))}var Lt=["eq","neq","contains","startsWith","endsWith","in","isEmpty","isNotEmpty"],Be=["eq","neq","gt","gte","lt","lte","between","in","isEmpty"],Xo=["eq","neq","in","isEmpty"],et=["eq","neq","in","isEmpty","isNotEmpty"],De=["has","hasAny","hasAll","isEmpty","isNotEmpty"],hn=["overlaps","contains","containedBy","isEmpty"],kt=["jsonContains","isEmpty","isNotEmpty"],xt=["isEmpty","isNotEmpty"],Qo={"text.short":Lt,"text.long":Lt,"text.rich":Lt,"number.integer":Be,"number.decimal":Be,boolean:Xo,date:Be,time:Be,datetime:Be,"date-range":hn,"datetime-range":hn,"option.single":et,"option.multiple":De,"cascade.single":De,"cascade.multiple":De,"user.single":et,"user.multiple":De,"department.single":et,"department.multiple":De,"resource-ref.single":et,"resource-ref.multiple":De,file:xt,image:xt,signature:xt,address:kt,location:kt,uuid:["eq","neq","in","isEmpty"],json:kt,"serial-number":["eq","neq","in","contains","startsWith"],subtable:[]},Zo=new Set(["text.short","text.long","text.rich","option.single","user.single","department.single","resource-ref.single","serial-number"]),es=new Set(["option.multiple","cascade.single","cascade.multiple","user.multiple","department.multiple","resource-ref.multiple","file","image","signature","address","location","json","subtable"]);function Ut(e){return Qo[e]}function ts(e,t){return Ut(e).includes(t)}function tt(e){return Zo.has(e)}function Ve(e){return!es.has(e)}function Mt(e){return Ut(e).length>0}var $n=new Set(["number.integer","number.decimal"]),Sn=new Set(["text.short","text.long","number.integer","number.decimal","date","time","datetime","serial-number"]),ns=new Set([...Sn,"boolean","uuid"]),os=new Set(["option.single","user.single","department.single","resource-ref.single"]);function ss(e,t){return t==="sum"||t==="avg"?$n.has(e)?{valueExpression:"column",numericResult:!0}:null:t==="min"||t==="max"?Sn.has(e)?{valueExpression:"column",numericResult:$n.has(e)}:null:os.has(e)?{valueExpression:"snapshot-value",numericResult:!0}:ns.has(e)?{valueExpression:"column",numericResult:!0}:null}var ot=["version","maxBytes","fields"];function Bt(e,t){if(e===void 0)return;let o=jt(e,t);Dn(o,ot,t);let n=nt(o.version,`${t}/version`,1,1e6),s=nt(o.maxBytes,`${t}/maxBytes`,2,196608);(!n||!s)&&se("NATIVE_DATA_DRAFT_STATE_SCHEMA_INVALID",t);let i=jt(o.fields,`${t}/fields`),c=Object.entries(i);(!c.length||c.length>50)&&se("NATIVE_DATA_DRAFT_STATE_FIELDS_INVALID",`${t}/fields`);for(let[r,a]of c){let f=`${t}/fields/${r}`;/^[A-Za-z][A-Za-z0-9_]{0,62}$/.test(r)||se("NATIVE_DATA_DRAFT_STATE_FIELD_CODE_INVALID",f);let _=jt(a,f),d=Vn(_.type,`${f}/type`,32),u=d==="string"?["type","required","maxLength","enum"]:d==="json.object"?["type","required","maxBytes"]:["type","required"];if(["string","number","integer","boolean","json.object"].includes(d)||se("NATIVE_DATA_DRAFT_STATE_FIELD_TYPE_INVALID",`${f}/type`),Dn(_,u,f),rs(_.required,`${f}/required`),d==="string"){let I=nt(_.maxLength,`${f}/maxLength`,1,196608);I||se("NATIVE_DATA_DRAFT_STATE_FIELD_INVALID",f),_.enum!==void 0&&is(_.enum,`${f}/enum`,100,!1).some(E=>E.length>I)&&se("NATIVE_DATA_DRAFT_STATE_FIELD_INVALID",`${f}/enum`)}else if(d==="json.object"){let I=nt(_.maxBytes,`${f}/maxBytes`,2,65536);(!I||I>s)&&se("NATIVE_DATA_DRAFT_STATE_FIELD_INVALID",f)}}}function is(e,t,o,n){(!Array.isArray(e)||!n&&e.length===0||e.length>o)&&se("NATIVE_DATA_SURFACE_STRING_ARRAY_INVALID",t);let s=e.map((i,c)=>Vn(i,`${t}/${c}`,255));return new Set(s).size!==s.length&&se("NATIVE_DATA_SURFACE_STRING_ARRAY_INVALID",t),s}function jt(e,t){return(!e||typeof e!="object"||Array.isArray(e))&&se("NATIVE_OBJECT_REQUIRED",t),e}function Dn(e,t,o){let n=new Set(t);for(let s of Object.keys(e))n.has(s)||se("NATIVE_PROPERTY_UNKNOWN",`${o}/${s}`)}function Vn(e,t,o){return(typeof e!="string"||e.length===0||e.length>o)&&se("NATIVE_STRING_INVALID",t),e}function rs(e,t){e!==void 0&&typeof e!="boolean"&&se("NATIVE_BOOLEAN_REQUIRED",t)}function nt(e,t,o,n){return(!Number.isSafeInteger(e)||Number(e)<o||Number(e)>n)&&se("NATIVE_INTEGER_INVALID",t),Number(e)}function se(e,t){throw new de(e,t)}var as=500,ge={surface:["mutationOwner","generated","fields","list","form","detail","mobile","views"],generated:["list","detail","create","update","delete"],field:["label","type","widget","section","requiredHint","system","hidden","readCapabilities","createCapabilities","updateCapabilities","maxLength","precision","scale","exactDecimal","min","max","rangeBoundary","maxCount","maxSizeMb","accept","options","list","searchable","sortable","source","timePrecision","serial","subtable"],list:["actions","fieldOrder","defaultPageSize","searchableFields","filterFields","defaultSort"],defaultSort:["field","order"],form:["layout","fieldOrder","draftState"],detail:["layout","fieldOrder"],layout:["layout","fieldOrder","draftState"],draftState:ot,mobile:["enabled"]},cs={"text.short":["text","email","phone"],"text.long":["textarea"],"text.rich":["rich-text"],"number.integer":["number","rating"],"number.decimal":["number","money","percent"],boolean:["switch"],date:["date"],time:["time"],datetime:["datetime"],"date-range":["date-range"],"datetime-range":["datetime-range"],"option.single":["select","radio"],"option.multiple":["multi-select","checkbox"],"cascade.single":["cascade"],"cascade.multiple":["cascade"],"user.single":["directory-user"],"user.multiple":["directory-user"],"department.single":["directory-department","scope"],"department.multiple":["directory-department","scope"],"resource-ref.single":["select","radio","resource"],"resource-ref.multiple":["multi-select","checkbox","resource"],file:["attachment"],image:["image"],signature:["signature"],address:["address"],location:["location"],uuid:["readonly"],json:["json"],"serial-number":["readonly"],subtable:["subtable"]};function st(e,t,o){if(e===void 0)return;let n=te(e,o);Ee(n,ge.surface,o);let s=n.mutationOwner===void 0?"native":Ne(n.mutationOwner,`${o}/mutationOwner`,16);["native","action","readonly","workflow","queued-command"].includes(s)||k("NATIVE_DATA_SURFACE_MUTATION_OWNER_INVALID",`${o}/mutationOwner`);let i=n.generated===void 0?{}:te(n.generated,`${o}/generated`);Ee(i,ge.generated,`${o}/generated`);for(let a of ge.generated)Wt(i[a],`${o}/generated/${a}`);if(s!=="native")for(let a of["create","update","delete"])i[a]===!0&&k("NATIVE_DATA_SURFACE_MUTATION_OWNER_CONFLICT",`${o}/generated/${a}`);let c=new Map(t.map(a=>[a.code,a])),r=te(n.fields,`${o}/fields`);for(let a of Object.keys(r))c.has(a)||k("NATIVE_DATA_SURFACE_FIELD_MISSING",`${o}/fields/${a}`);for(let a of t)Object.prototype.hasOwnProperty.call(r,a.code)||k("NATIVE_DATA_SURFACE_FIELD_REQUIRED",`${o}/fields/${a.code}`),ls(r[a.code],a,`${o}/fields/${a.code}`);for(let a of["create","update"]){let f=i[a]??s==="native",_=t.some(d=>{let u=te(r[d.code],`${o}/fields/${d.code}`);return Fn(d,u,a)});f&&!_&&k("NATIVE_DATA_SURFACE_WRITABLE_FIELDS_REQUIRED",`${o}/generated/${a}`)}if(us(n.list,c,`${o}/list`),wn(n.form,c,`${o}/form`,"form"),wn(n.detail,c,`${o}/detail`,"detail"),n.mobile!==void 0){let a=te(n.mobile,`${o}/mobile`);Ee(a,ge.mobile,`${o}/mobile`),Wt(a.enabled,`${o}/mobile/enabled`)}ds(n,t,o)}function it(e,t){let o=e.views?.find(s=>s.code===t);o||k("NATIVE_DATA_VIEW_NOT_FOUND",`/surface/views/${t}`);let n=new Map((o.sections||[]).flatMap(s=>s.fields.map(i=>[i,s.title])));return{mutationOwner:e.mutationOwner||"native",generated:o.generated,list:o.list,form:o.form,detail:o.detail,mobile:o.mobile,fields:Object.fromEntries(Object.entries(e.fields).map(([s,i])=>{let c={...i};delete c.section;let r=n.get(s);return[s,{...c,...r?{section:r}:{},list:o.list.fieldOrder.includes(s)}]}))}}function ds(e,t,o){if(e.views===void 0)return;(!Array.isArray(e.views)||e.views.length>20)&&k("NATIVE_DATA_VIEWS_LIMIT_INVALID",`${o}/views`);let n=new Set;e.views.forEach((s,i)=>{let c=`${o}/views/${i}`,r=te(s,c);Ee(r,["code","name","generated","list","form","detail","mobile","sections"],c);let a=Ne(r.code,`${c}/code`,64);(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(a)||n.has(a))&&k("NATIVE_DATA_VIEW_CODE_INVALID",`${c}/code`),n.add(a),Ne(r.name,`${c}/name`,255),te(r.generated,`${c}/generated`),te(r.mobile,`${c}/mobile`);for(let _ of["list","detail","create","update","delete"])typeof r.generated[_]!="boolean"&&k("NATIVE_DATA_VIEW_OPERATION_INVALID",`${c}/generated/${_}`);typeof r.mobile.enabled!="boolean"&&k("NATIVE_DATA_VIEW_MOBILE_INVALID",`${c}/mobile/enabled`);for(let _ of["list","form","detail"]){let d=te(r[_],`${c}/${_}`),u=we(d.fieldOrder,`${c}/${_}/fieldOrder`,500,!0);for(let I of u){let l=e.fields[I];(!l||(l.hidden??l.system)===!0)&&k("NATIVE_DATA_VIEW_FIELD_INVALID",`${c}/${_}/fieldOrder`)}}if(r.sections!==void 0){(!Array.isArray(r.sections)||r.sections.length>100)&&k("NATIVE_DATA_VIEW_SECTIONS_INVALID",`${c}/sections`);let _=new Set;r.sections.forEach((d,u)=>{let I=`${c}/sections/${u}`,l=te(d,I);Ee(l,["title","fields"],I),Ne(l.title,`${I}/title`,255);for(let E of we(l.fields,`${I}/fields`,100,!0)){let T=e.fields[E];(!T||(T.hidden??T.system)===!0||_.has(E))&&k("NATIVE_DATA_VIEW_FIELD_INVALID",`${I}/fields`),_.add(E)}})}let f=it(e,a);if(st(f,t,c),r.generated.create!==!1&&(e.mutationOwner||"native")==="native")for(let _ of t)je(_,e.fields[_.code])&&Fn(_,e.fields[_.code],"create")&&!r.form.fieldOrder.includes(_.code)&&k("NATIVE_DATA_VIEW_CREATE_REQUIRED_FIELD_MISSING",`${c}/form/fieldOrder`)})}function Fn(e,t,o){if(e.type==="serial-number"||t.system===!0)return!1;let n=t[`${o}Capabilities`];return Array.isArray(n)&&n.length>0}function ls(e,t,o){let n=te(e,o);Ee(n,ge.field,o),Ne(n.label,`${o}/label`,500),n.type!==t.type&&k("NATIVE_DATA_SURFACE_FIELD_TYPE_MISMATCH",`${o}/type`);let s=Ne(n.widget,`${o}/widget`,64);cs[t.type].includes(s)||k("NATIVE_DATA_SURFACE_WIDGET_INCOMPATIBLE",`${o}/widget`),_s(n.section,`${o}/section`,255);for(let i of["requiredHint","system","hidden","list","searchable","sortable"])Wt(n[i],`${o}/${i}`);n.searchable===!0&&!tt(t.type)&&k("NATIVE_DATA_SURFACE_SEARCH_UNSUPPORTED",`${o}/searchable`),n.sortable===!0&&!Ve(t.type)&&k("NATIVE_DATA_SURFACE_SORT_UNSUPPORTED",`${o}/sortable`);for(let i of["readCapabilities","createCapabilities","updateCapabilities"])we(n[i],`${o}/${i}`,100,!0);if(n.maxCount!==void 0&&(!Number.isSafeInteger(n.maxCount)||Number(n.maxCount)<1||Number(n.maxCount)>100)&&k("NATIVE_DATA_SURFACE_MAX_COUNT_INVALID",`${o}/maxCount`),n.maxSizeMb!==void 0&&(!Number.isSafeInteger(n.maxSizeMb)||Number(n.maxSizeMb)<1||Number(n.maxSizeMb)>1024)&&k("NATIVE_DATA_SURFACE_MAX_SIZE_INVALID",`${o}/maxSizeMb`),n.accept!==void 0){let i=Array.isArray(n.accept)?n.accept:[n.accept];we(i,`${o}/accept`,50,!1)}for(let i of["maxLength","precision","scale","exactDecimal","min","max","rangeBoundary","options","source","timePrecision","serial","subtable"])fs(n,t,i,o);ps(n,t,o)}function us(e,t,o){if(e===void 0)return;let n=te(e,o);if(Ee(n,ge.list,o),n.actions!==void 0){let s=te(n.actions,`${o}/actions`);Ee(s,["import","export"],`${o}/actions`);for(let i of["import","export"])s[i]!==void 0&&typeof s[i]!="boolean"&&k("NATIVE_DATA_SURFACE_LIST_ACTION_INVALID",`${o}/actions/${i}`)}if(n.fieldOrder!==void 0)for(let s of we(n.fieldOrder,`${o}/fieldOrder`,500,!0))t.has(s)||k("NATIVE_DATA_SURFACE_LIST_FIELD_INVALID",`${o}/fieldOrder`);n.defaultPageSize!==void 0&&(!Number.isSafeInteger(n.defaultPageSize)||Number(n.defaultPageSize)<1||Number(n.defaultPageSize)>200)&&k("NATIVE_DATA_SURFACE_PAGE_SIZE_INVALID",`${o}/defaultPageSize`);for(let[s,i]of[["searchableFields",tt],["filterFields",Mt]]){if(n[s]===void 0)continue;let c=we(n[s],`${o}/${s}`,100,!0);for(let r of c){let a=t.get(r);(!a||!i(a.type))&&k("NATIVE_DATA_SURFACE_LIST_FIELD_INVALID",`${o}/${s}`)}}if(n.defaultSort!==void 0){let s=te(n.defaultSort,`${o}/defaultSort`);Ee(s,ge.defaultSort,`${o}/defaultSort`);let i=Ne(s.field,`${o}/defaultSort/field`,63),c=t.get(i);!Pt(i)&&(!c||!Ve(c.type))&&k("NATIVE_DATA_SURFACE_SORT_UNSUPPORTED",`${o}/defaultSort/field`),s.order!==void 0&&!["asc","desc"].includes(s.order)&&k("NATIVE_DATA_SURFACE_SORT_ORDER_INVALID",`${o}/defaultSort/order`)}}function wn(e,t,o,n){if(e===void 0)return;let s=te(e,o);if(Ee(s,ge[n],o),s.layout!==void 0&&!["flat","sections"].includes(s.layout)&&k("NATIVE_DATA_SURFACE_LAYOUT_INVALID",`${o}/layout`),s.fieldOrder!==void 0){let i=`${o}/fieldOrder`;(!Array.isArray(s.fieldOrder)||s.fieldOrder.length>t.size||s.fieldOrder.length>as)&&k("NATIVE_DATA_SURFACE_FIELD_ORDER_INVALID",i);let c=s.fieldOrder.map((r,a)=>Ne(r,`${i}/${a}`,63));new Set(c).size!==c.length&&k("NATIVE_DATA_SURFACE_FIELD_ORDER_INVALID",i),c.forEach((r,a)=>{t.has(r)||k("NATIVE_DATA_SURFACE_FIELD_ORDER_FIELD_MISSING",`${i}/${a}`)})}n==="form"&&Bt(s.draftState,`${o}/draftState`)}function fs(e,t,o,n){e[o]===void 0&&t[o]===void 0||((e[o]===void 0||t[o]===void 0)&&k("NATIVE_DATA_SURFACE_FIELD_PROJECTION_MISMATCH",`${n}/${o}`),Q(e[o])!==Q(t[o])&&k("NATIVE_DATA_SURFACE_FIELD_PROJECTION_MISMATCH",`${n}/${o}`))}function ps(e,t,o){let n=t.file||{},s={...e.maxCount===void 0?{}:{maxCount:e.maxCount},...e.maxSizeMb===void 0?{}:{maxSizeMb:e.maxSizeMb},...e.accept===void 0?{}:{accept:Jt(e.accept)}};for(let i of["maxCount","maxSizeMb","accept"]){if(s[i]===void 0&&n[i]===void 0)continue;(s[i]===void 0||n[i]===void 0)&&k("NATIVE_DATA_SURFACE_FIELD_PROJECTION_MISMATCH",`${o}/${i}`);let c=i==="accept"?Jt(s[i]):s[i],r=i==="accept"?Jt(n[i]):n[i];Q(c)!==Q(r)&&k("NATIVE_DATA_SURFACE_FIELD_PROJECTION_MISMATCH",`${o}/${i}`)}}function Jt(e){return(Array.isArray(e)?[...e]:[e]).sort((t,o)=>{let n=String(t),s=String(o);return n===s?0:n<s?-1:1})}function we(e,t,o,n){(!Array.isArray(e)||!n&&e.length===0||e.length>o)&&k("NATIVE_DATA_SURFACE_STRING_ARRAY_INVALID",t);let s=e.map((i,c)=>Ne(i,`${t}/${c}`,255));return new Set(s).size!==s.length&&k("NATIVE_DATA_SURFACE_STRING_ARRAY_INVALID",t),s}function te(e,t){return(!e||typeof e!="object"||Array.isArray(e))&&k("NATIVE_OBJECT_REQUIRED",t),e}function Ee(e,t,o){let n=new Set(t);for(let s of Object.keys(e))n.has(s)||k("NATIVE_PROPERTY_UNKNOWN",`${o}/${s}`)}function Ne(e,t,o){return(typeof e!="string"||e.length===0||e.length>o)&&k("NATIVE_STRING_INVALID",t),e}function _s(e,t,o){e!==void 0&&(typeof e!="string"||e.length>o)&&k("NATIVE_STRING_INVALID",t)}function Wt(e,t){e!==void 0&&typeof e!="boolean"&&k("NATIVE_BOOLEAN_REQUIRED",t)}function k(e,t){throw new de(e,t)}var Fe=class extends Error{constructor(o,n){super(`${o}: ${n}`);this.pointer=o;this.reason=n}pointer;reason;code="NATIVE_MANAGED_CONCURRENCY_INVALID"};function zt(e,t,o){if(e===void 0)return;let n=(A,m)=>{throw new Fe(A,m)},s=(A,m,O)=>((!A||typeof A!="object"||Array.isArray(A)||Object.keys(A).some(C=>!O.includes(C)))&&n(m,"object contains unsupported properties"),A),i=(A,m,O,C)=>{(!Number.isSafeInteger(A)||A<m||A>O)&&n(C,`expected integer ${m}..${O}`)},c=(A,m)=>{(typeof A!="string"||!/^[a-z][a-z0-9_-]{0,63}$/.test(A))&&n(m,"invalid code")},r=(A,m,O)=>((!Array.isArray(A)||A.length>m)&&n(O,"array exceeds bound"),A),a=(A,m)=>{let O=t.find(C=>C.code===A);return O||n(m,"unknown resource"),O},f=(A,m,O)=>{let C=A.schema.fields.find(b=>b.code===m);return!C&&m!=="id"&&n(O,"unknown field"),C},_=(A,m,O=!1)=>{s(A,m,Object.keys(A||{})),Object.keys(A).length>8&&n(m,"at most eight parameters");for(let[C,b]of Object.entries(A))if(c(C,m),s(b,m,["type","values","minimum","maximum","minLength","maxLength"]),b.type==="uuid")Object.keys(b).length!==1&&n(m,"uuid has no options");else if(O&&b.type==="boolean")s(b,m,["type"]);else if(O&&b.type==="string"&&b.values===void 0)s(b,m,["type","minLength","maxLength"]),i(b.maxLength,1,256,m),b.minLength!==void 0&&i(b.minLength,0,b.maxLength,m);else if(b.type==="string"){s(b,m,["type","values"]);let y=r(b.values,100,m);(!y.length||y.some(S=>typeof S!="string"||S.length>128)||new Set(y).size!==y.length)&&n(m,"finite string values required")}else b.type==="integer"?(s(b,m,["type","minimum","maximum"]),i(b.minimum,0,1e6,m),i(b.maximum,b.minimum,b.minimum+1e3,m)):n(m,"unsupported parameter type")},d=(A,m,O,C=!1)=>{s(A,O,["from","key","value"]),!(A.from==="input"&&Object.keys(A).length===2&&Object.hasOwn(m,A.key))&&((A.from==="actor"||C&&A.from==="allocation")&&Object.keys(A).length===1||A.from==="literal"&&Object.keys(A).length===2&&Object.hasOwn(A,"value")&&(A.value===null||["string","boolean"].includes(typeof A.value)||typeof A.value=="number"&&Number.isFinite(A.value))&&JSON.stringify(A.value).length<=512||n(O,"invalid binding"))},u=(A,m,O)=>{d(A,m,O),!(A.from==="input"&&m[A.key].type==="uuid")&&(A.from==="literal"&&typeof A.value=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(A.value)||n(O,"record and allocation identifiers require a UUID binding"))},I=(A,m,O)=>{d(A,m,O),!(A.from==="input"&&m[A.key].type==="integer"&&m[A.key].minimum>=1)&&(A.from==="literal"&&Number.isSafeInteger(A.value)&&A.value>=1||n(O,"expectedRevision requires a positive integer binding"))},l="/data/concurrency";JSON.stringify(e).length>131072&&n(l,"declaration exceeds 128 KiB");let E=s(e,l,["version","admission","reads","quotas","commands"]);E.version!==1&&n(l,"unsupported version"),s(E.admission,l,["perSecond","burst","maxInFlight"]),i(E.admission.perSecond,1,1e3,l),i(E.admission.burst,1,1e3,l),i(E.admission.maxInFlight,1,1e3,l);let T=(A,m)=>{let O=new Set;for(let C of A)c(C?.code,m),O.has(C.code)&&n(m,"duplicate code"),O.add(C.code)};T(r(E.reads,32,l),l),T(r(E.quotas,16,l),l),T(r(E.commands,32,l),l);for(let A of E.reads){let m=`${l}/reads/${A.code}`;s(A,m,["code","resourceCode","parameters","select","where","limit","scope","freshSeconds","staleSeconds","maxKeys","sourcePerSecond","dependencies"]);let O=a(A.resourceCode,m);_(A.parameters,m),["subject","application"].includes(A.scope)||n(m,"invalid cache scope"),A.scope==="application"&&O.dataPolicyCode&&n(m,"shared cache cannot bypass a row policy");let C=r(A.select,32,m);C.length||n(m,"select required"),C.forEach(y=>f(O,y,m));let b=r(A.dependencies,64,m);b.forEach(y=>f(O,y,m));for(let y of r(A.where||[],8,m))s(y,m,["field","value"]),f(O,y.field,m),d(y.value,A.parameters,m),A.scope==="application"&&y.value.from==="actor"&&n(m,"actor requires subject cache"),b.includes(y.field)||n(m,"filter dependency missing");C.some(y=>!b.includes(y))&&n(m,"selected field dependency missing"),i(A.limit,1,100,m),i(A.freshSeconds,1,300,m),i(A.staleSeconds,0,300,m),i(A.maxKeys,1,1e4,m),i(A.sourcePerSecond,1,20,m)}for(let A of E.quotas){let m=`${l}/quotas/${A.code}`;s(A,m,["code","sourceResource","capacityField","allocationResource","allocationField","reservationSeconds"]);let O=a(A.sourceResource,m),C=a(A.allocationResource,m);f(O,A.capacityField,m)?.type!=="number.integer"&&n(m,"capacity must be an integer"),(f(C,A.allocationField,m)?.type!=="uuid"||f(C,A.allocationField,m)?.nullable!==!1)&&n(m,"allocation reference must be a uuid"),C.surface?.mutationOwner!=="queued-command"&&n(m,"allocation model must be command owned"),A.reservationSeconds!==void 0&&i(A.reservationSeconds,10,86400,m)}new Set(E.quotas.map(A=>A.allocationResource)).size!==E.quotas.length&&n(l,"an allocation model has exactly one pool owner");for(let A of E.commands){let m=`${l}/commands/${A.code}`;s(A,m,["code","mode","intake","execution","capability","parameters","resourceKey","admission","deadlineSeconds","guards","operations","quota"]),A.mode!==void 0&&!["permit","durable"].includes(A.mode)&&n(m,"unsupported mode");let O=A.mode==="durable";if(_(A.parameters,m,O),d(A.resourceKey,A.parameters,m),o.some(C=>C.code===A.capability)||n(m,"command capability must be declared"),s(A.admission,m,["perSecond","burst","maxInFlight","maxQueue","maxWaitSeconds","permitSeconds"]),i(A.admission.perSecond,1,E.admission.perSecond,m),i(A.admission.burst,1,E.admission.burst,m),i(A.admission.maxInFlight,1,E.admission.maxInFlight,m),i(A.admission.maxQueue,1,1e4,m),i(A.admission.maxWaitSeconds,1,3600,m),(!O||A.admission.permitSeconds!==void 0)&&i(A.admission.permitSeconds,5,60,m),i(A.deadlineSeconds,10,3600,m),O){(A.operations!==void 0||A.guards!==void 0||A.quota!==void 0)&&n(m,"backend-plan does not accept static operations, guards or quota"),s(A.intake,m,["perSecond","burst","maxInFlight"]);for(let y of["perSecond","burst","maxInFlight"])i(A.intake[y],1,1e3,m);let C=s(A.execution,m,["kind","handlerCode","timeoutMs","resources","directory"]);C.kind!=="backend-plan"&&n(m,"durable requires backend-plan"),c(C.handlerCode,m),i(C.timeoutMs,100,3e4,m);let b=r(C.resources,32,m);b.length||n(m,"execution resources required"),new Set(b.map(y=>y.resourceCode)).size!==b.length&&n(m,"duplicate execution resource");for(let y of b){s(y,m,["resourceCode","readFields","writeOperations","writeFields"]);let S=a(y.resourceCode,m);for(let F of["readFields","writeFields"]){let J=r(y[F],64,m);new Set(J).size!==J.length&&n(m,"duplicate field"),J.forEach(M=>{F==="readFields"&&Dt.has(M)||f(S,M,m)})}let P=r(y.writeOperations,3,m);(new Set(P).size!==P.length||P.some(F=>!["create","update","increment"].includes(F)))&&n(m,"unsupported execution operation"),y.writeFields.some(F=>["id","revision","created_by","updated_by","created_at","updated_at"].includes(F))&&n(m,"record metadata is platform owned"),!P.length&&y.writeFields.length&&n(m,"write fields require an operation"),P.length&&!y.writeFields.length&&n(m,"write operations require fields"),E.quotas.some(F=>F.allocationResource===y.resourceCode)&&P.length&&n(m,"allocation references remain owned by their pool command")}if(C.directory!==void 0){s(C.directory,m,["mode","fields"]),C.directory.mode!=="current-initiator"&&n(m,"only current initiator allowed");let y=r(C.directory.fields,4,m);(!y.length||new Set(y).size!==y.length||y.some(S=>!["displayName","employeeNumber","primaryDepartment","departments"].includes(S)))&&n(m,"unsupported directory fields")}continue}(A.execution!==void 0||A.intake!==void 0)&&n(m,"execution and intake require durable mode");for(let C of r(A.guards||[],8,m)){s(C,m,["resourceCode","id","conditions"]);let b=a(C.resourceCode,m);u(C.id,A.parameters,m);for(let y of r(C.conditions,16,m)){s(y,m,["kind","field","operator","value"]);let S=f(b,y.field,m);["eq","neq","lt","lte","gt","gte"].includes(y.operator)||n(m,"unsupported guard"),y.kind==="database-now"?(S?.type!=="datetime"||!["lt","lte","gt","gte"].includes(y.operator)||y.value!==void 0)&&n(m,"database-now requires datetime and an ordering operator"):(y.kind!==void 0&&y.kind!=="value"&&n(m,"unsupported condition kind"),d(y.value,A.parameters,m))}}for(let C of r(A.operations,8,m)){s(C,m,["operation","resourceCode","id","expectedRevision","data"]);let b=a(C.resourceCode,m);b.surface?.mutationOwner!=="queued-command"&&n(m,"command mutations require command owned models");let y=E.quotas.find(S=>S.allocationResource===C.resourceCode);y&&(C.operation==="create"?A.quota?.action!=="allocate"||A.quota.pool!==y.code:Object.hasOwn(C.data||{},y.allocationField))&&n(m,"allocation references are owned by their pool command"),["create","update"].includes(C.operation)||n(m,"unsupported operation"),C.operation==="update"?(u(C.id,A.parameters,m),I(C.expectedRevision,A.parameters,m)):(C.id!==void 0||C.expectedRevision!==void 0)&&n(m,"create has no caller supplied id/revision"),s(C.data,m,Object.keys(C.data||{})),Object.keys(C.data).length>32&&n(m,"too many fields");for(let[S,P]of Object.entries(C.data))S==="id"&&n(m,"record identifiers are platform owned"),f(b,S,m),d(P,A.parameters,m,A.quota?.action==="allocate")}if(A.quota){let C=s(A.quota,m,["pool","action","units","mode","allocation"]),b=E.quotas.find(y=>y.code===C.pool);b||n(m,"unknown quota pool"),u(A.resourceKey,A.parameters,m),C.action==="allocate"?(s(C,m,["pool","action","units","mode"]),i(C.units,1,1e3,m),(!["committed","reserved"].includes(C.mode)||C.mode==="reserved"&&!b.reservationSeconds)&&n(m,"invalid allocation mode"),(A.operations.length!==1||A.operations[0].operation!=="create"||A.operations[0].resourceCode!==b.allocationResource||A.operations[0].data[b.allocationField]?.from!=="allocation")&&n(m,"allocation must atomically create its bound business record")):["confirm","release"].includes(C.action)?(s(C,m,["pool","action","allocation"]),u(C.allocation,A.parameters,m),A.operations.length&&n(m,"lifecycle owns allocation state; business reference remains immutable")):n(m,"invalid quota action")}else A.operations.length||n(m,"operations required")}let g=E.commands.filter(A=>A.mode==="durable").map(A=>A.execution.handlerCode);return new Set(g).size!==g.length&&n(l,"handler code must be unique"),JSON.parse(JSON.stringify(E))}var ye=class extends Error{constructor(o,n){super(`\u91D1\u989D\u751F\u547D\u5468\u671F\u58F0\u660E\u65E0\u6548\uFF1A${n}\uFF08${o}\uFF09`);this.pointer=o;this.reason=n}pointer;reason;code="NATIVE_DECIMAL_LIFECYCLE_INVALID"},Yt=["parentTransitions","childTransitions","fulfilledChildStatuses","lockedParentStatuses"],vn=["amountFieldCode","currencyFieldCode","relationFieldCode","parentFieldCode","rootFieldCode","statusFieldCode","parentRelationValue","childRelationValue"],at=e=>!!(e&&typeof e=="object"&&!Array.isArray(e)),rt=e=>Array.isArray(e)?e.filter(at):[],Ae=(e,t)=>{throw new ye(e,t)},Gt=e=>typeof e=="string"&&/^[A-Za-z0-9._:-]{1,128}$/.test(e),qt=(e,t)=>e<t?-1:e>t?1:0;function ct(e,t="/decimalReservationLifecycle"){if(e===void 0)return;if(!at(e)||Object.keys(e).some(s=>!Yt.includes(s))||Yt.some(s=>!Object.prototype.hasOwnProperty.call(e,s)))return Ae(t,"\u5FC5\u987B\u5B8C\u6574\u58F0\u660E\u56DB\u9879\u89C4\u5219\uFF0C\u4E0D\u80FD\u5305\u542B\u672A\u77E5\u5C5E\u6027");let o=s=>{let i=e[s];if(!Array.isArray(i)||i.length>64)return Ae(`${t}/${s}`,"\u72B6\u6001\u8FB9\u6700\u591A 64 \u6761");let c=new Set;return i.map((r,a)=>{let f=`${t}/${s}/${a}`;if(!at(r)||Object.keys(r).some(d=>d!=="from"&&d!=="to")||!Gt(r.from)||!Gt(r.to)||r.from===r.to)return Ae(f,"\u72B6\u6001\u8FB9\u5FC5\u987B\u5305\u542B\u4E0D\u540C\u7684\u6709\u6548 from/to");let _=JSON.stringify([r.from,r.to]);return c.has(_)?Ae(f,"\u72B6\u6001\u8FB9\u4E0D\u80FD\u91CD\u590D"):(c.add(_),{from:r.from,to:r.to})}).sort((r,a)=>qt(r.from,a.from)||qt(r.to,a.to))},n=s=>{let i=e[s];return!Array.isArray(i)||i.length<1||i.length>16||i.some(c=>!Gt(c))||new Set(i).size!==i.length?Ae(`${t}/${s}`,"\u72B6\u6001\u96C6\u5408\u5FC5\u987B\u5305\u542B 1 \u5230 16 \u4E2A\u4E0D\u91CD\u590D\u7684\u6709\u6548\u72B6\u6001"):[...i].sort(qt)};return{parentTransitions:o("parentTransitions"),childTransitions:o("childTransitions"),fulfilledChildStatuses:n("fulfilledChildStatuses"),lockedParentStatuses:n("lockedParentStatuses")}}function Kt(e,t,o="/config/data/resources"){rt(e).forEach((n,s)=>{let i=`${o}/${s}/decimalReservationLifecycle`,c=ct(n.decimalReservationLifecycle,i);if(!c)return;let r=rt(t).map(d=>d.platformAccess?.decimalReservation).filter(d=>at(d)&&d.resourceCode===n.code),a=r.find(d=>d.mode==="reserve");if(!a)return Ae(i,"\u9700\u8981\u540C\u8D44\u6E90\u5DF2\u58F0\u660E\u7684 reserve \u52A8\u4F5C\u6620\u5C04");if(vn.some(d=>typeof a[d]!="string")||r.some(d=>vn.some(u=>d[u]!==a[u])))return Ae(i,"\u540C\u8D44\u6E90\u989D\u5EA6\u52A8\u4F5C\u7684\u5B57\u6BB5\u6620\u5C04\u5FC5\u987B\u4E00\u81F4");let f=rt(n.schema?.fields).find(d=>d.code===a.statusFieldCode);if(f?.type!=="option.single")return Ae(i,"\u989D\u5EA6\u72B6\u6001\u5B57\u6BB5\u5FC5\u987B\u4E3A option.single");let _=new Set(rt(f.options).map(d=>d.value));for(let d of Yt)if((d==="parentTransitions"||d==="childTransitions"?c[d].flatMap(I=>[I.from,I.to]):c[d]).some(I=>!_.has(I)))return Ae(`${i}/${d}`,"\u72B6\u6001\u5FC5\u987B\u6765\u81EA\u989D\u5EA6\u72B6\u6001\u5B57\u6BB5\u7684\u9009\u9879");if(r.some(d=>d.mode==="reserve"&&Array.isArray(d.eligibleParentStatuses)&&d.eligibleParentStatuses.some(u=>c.lockedParentStatuses.includes(String(u)))))return Ae(`${i}/lockedParentStatuses`,"\u9501\u5B9A\u7236\u72B6\u6001\u4E0D\u80FD\u5141\u8BB8\u65B0\u9884\u7559")})}var Ln=require("crypto");var Ht=new Set(["option.single","user.single","department.single","resource-ref.single"]),Es=new Set(["option.multiple","cascade.single","cascade.multiple","user.multiple","department.multiple","resource-ref.multiple","address","location","json"]),kn=new Set(["option.multiple","cascade.single","cascade.multiple","user.multiple","department.multiple","resource-ref.multiple","file","image"]),As=new Set(["option.single","user.single","department.single","resource-ref.single","signature","address","location"]),ms=new Set([...Ht,...kn,"signature","address","location","json"]);function Is(e,t){let o=new Set([...Array.isArray(t?.list?.searchableFields)?t.list.searchableFields:[],...Object.entries(t?.fields||{}).filter(([,n])=>n?.searchable===!0).map(([n])=>n)]);return e.map(n=>xn(n,o.has(n.code))).sort((n,s)=>n.code.localeCompare(s.code))}function xn(e,t=!1){let o=e.type==="date-range"||e.type==="datetime-range";if(o&&e.rangeBoundary!=="closed"&&e.rangeBoundary!=="half-open")throw new Error("OPENXIANGDA_NATIVE_DATA_RANGE_BOUNDARY_INVALID");return{code:e.code,type:e.type,nullable:!0,indexed:e.indexed===!0,storage:Ss(e),index:Rs(e,t),...o?{rangeBoundary:e.rangeBoundary}:{},...e.type==="serial-number"?{serial:{prefix:e.serial?.prefix||"",digits:e.serial?.digits??6,start:e.serial?.start??1}}:{},...e.type==="subtable"&&e.subtable?{subtable:{resourceCode:e.subtable.resourceCode,foreignKey:e.subtable.foreignKey,orderField:e.subtable.orderField,maxRows:e.subtable.maxRows??20}}:{}}}function gs(e,t){if(t.type==="subtable")return null;let o=ne(t.code),n=Un(e,t),s=[n?` DEFAULT ${n}`:"",Ds(o,t),Ts(o,t)].join("");return`${o} ${t.storage}${s}`}function Ns(e,t){return Un(e,t)}function Ts(e,t){if(t.type!=="date-range"&&t.type!=="datetime-range")return"";if(t.rangeBoundary!=="closed"&&t.rangeBoundary!=="half-open")throw new Error("OPENXIANGDA_NATIVE_DATA_RANGE_BOUNDARY_INVALID");let o=t.type==="datetime-range"&&t.rangeBoundary==="closed";return` CHECK (${e} IS NULL OR (NOT isempty(${e}) AND lower(${e}) IS NOT NULL AND upper(${e}) IS NOT NULL AND lower_inc(${e}) AND ${o?"":"NOT "}upper_inc(${e})))`}function Cs(e){return e.type==="serial-number"||Me(e.type)&&e.type!=="subtable"}function bs(e,t){return t.filter(o=>o.type==="serial-number").map(o=>{let n=lt(e,o.code),s=o.serial?.start??1;return`CREATE SEQUENCE IF NOT EXISTS ${n} AS bigint MINVALUE ${s} START WITH ${s} CACHE 1`})}function Os(e,t){let o=dt(e);return t.filter(n=>n.type==="serial-number").map(n=>`ALTER SEQUENCE ${lt(e,n.code)} OWNED BY ${o}.${ne(n.code)}`)}function ys(e,t){return t.filter(o=>o.type==="serial-number").map(o=>`GRANT USAGE, SELECT ON SEQUENCE ${lt(e,o.code)} TO "openxiangda_data_api"`)}function hs(e,t){let o=dt(e),n=[];for(let s of t){if(s.type==="subtable")continue;let i=ne(s.code),c=ne(Te("idx",e,s.code,s.index));switch(s.index){case"btree":n.push(`CREATE INDEX IF NOT EXISTS ${c} ON ${o} (${i})`);break;case"btree-snapshot-expressions":{let r=ne(Te("idx",e,s.code,"snapshot-value")),a=ne(Te("idx",e,s.code,"snapshot-label"));n.push(`CREATE INDEX IF NOT EXISTS ${r} ON ${o} ((${i} ->> 'value'))`,`CREATE INDEX IF NOT EXISTS ${a} ON ${o} ((${i} ->> 'label'))`);break}case"gin-jsonb-path":n.push(`CREATE INDEX IF NOT EXISTS ${c} ON ${o} USING GIN (${i} jsonb_path_ops)`);break;case"gist-range":n.push(`CREATE INDEX IF NOT EXISTS ${c} ON ${o} USING GIST (${i})`);break;case"gin-trigram":{let r=Ht.has(s.type)?`((${i} ->> 'label')) gin_trgm_ops`:`${i} gin_trgm_ops`;n.push(`CREATE INDEX IF NOT EXISTS ${c} ON ${o} USING GIN (${r})`);break}case"none":break}if(s.type==="serial-number"){let r=ne(Te("uidx",e,s.code,"serial"));n.push(`CREATE UNIQUE INDEX IF NOT EXISTS ${r} ON ${o} (${i})`)}}return n}function $s(e,t,o,n){let s=dt(e),i=dt(t),c=ne(Te("uidx",e,"environment_id","subtable-parent")),r=ne(Te("idx",t,o,n,"subtable-child")),a=ne(Te("fk",t,o,e)),f=ne(o),_=ne(n);return[`CREATE UNIQUE INDEX IF NOT EXISTS ${c} ON ${s} ("tenant_id", "app_code", "environment_key", "id")`,`CREATE INDEX IF NOT EXISTS ${r} ON ${i} ("tenant_id", "app_code", "environment_key", ${f}, ${_}, "id")`,`DO $native_subtable$ BEGIN
|
|
2
|
-
ALTER TABLE ${
|
|
1
|
+
"use strict";var rs=Object.create;var Rt=Object.defineProperty;var as=Object.getOwnPropertyDescriptor;var cs=Object.getOwnPropertyNames;var ds=Object.getPrototypeOf,ls=Object.prototype.hasOwnProperty;var us=(e,t)=>{for(var o in t)Rt(e,o,{get:t[o],enumerable:!0})},To=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of cs(t))!ls.call(e,i)&&i!==o&&Rt(e,i,{get:()=>t[i],enumerable:!(n=as(t,i))||n.enumerable});return e};var fs=(e,t,o)=>(o=e!=null?rs(ds(e)):{},To(t||!e||!e.__esModule?Rt(o,"default",{value:e,enumerable:!0}):o,e)),ps=e=>To(Rt({},"__esModule",{value:!0}),e);var fc={};us(fc,{DATA_AUDIT_METADATA_FIELDS:()=>On,DATA_EVENT_TYPES_V2:()=>on,DATA_SYSTEM_SORT_FIELD_CODES:()=>$o,ManagedConcurrencyContractError:()=>Ye,NATIVE_CONFIGURATION_VALIDATOR_DIGEST:()=>uc,NATIVE_CONTRACT_CAPACITY_V2:()=>Y,NATIVE_DATA_POLICY_EXPRESSION_MAX_CLAUSES:()=>ad,NATIVE_DATA_POLICY_EXPRESSION_MAX_DEPTH:()=>id,NATIVE_DATA_POLICY_EXPRESSION_MAX_GROUP_ITEMS:()=>sd,NATIVE_DATA_POLICY_EXPRESSION_MAX_LEAVES:()=>rd,NATIVE_DATA_POLICY_EXPRESSION_MAX_OCCURRENCES:()=>cd,NATIVE_DATA_QUERY_OPERATORS_V2:()=>Fo,NATIVE_ROLE_MEMBERSHIP_BATCH_MAX_BYTES:()=>vd,NATIVE_ROLE_MEMBERSHIP_BATCH_MAX_ITEMS:()=>Fd,NATIVE_UNIQUE_KEY_MAX_BYTES:()=>xc,NATIVE_UNIQUE_KEY_NORMALIZERS:()=>Gn,NativeConfigurationCompilerError:()=>rn,NativeDataFieldContractV2Error:()=>me,NativeDataPolicyExpressionV2Error:()=>nt,NativeDecimalLifecycleContractError:()=>Fe,NativeEventActionContractError:()=>qt,NativeRoleMembershipBatchInputError:()=>mn,NativeScopeSourceFieldPathV2Error:()=>Ut,NativeUniqueKeyContractError:()=>Xe,OPENXIANGDA_NATIVE_DATA_FIELD_TYPES_V2:()=>wo,OPENXIANGDA_NATIVE_DATA_SURFACE_KEYS_V2:()=>Oe,OPENXIANGDA_NATIVE_DRAFT_STATE_KEYS_V2:()=>Ft,OPENXIANGDA_NATIVE_SYSTEM_FIELDS_V2:()=>wt,OPENXIANGDA_NATIVE_SYSTEM_FIELD_MAP_V2:()=>yn,WORKFLOW_AUTOMATIC_CC_MAX_RECIPIENTS:()=>zc,WORKFLOW_AUTOMATIC_CC_PROVIDERS:()=>ai,WORKFLOW_BUSINESS_STEP_EVENT:()=>Qe,WORKFLOW_BUSINESS_STEP_EVENTS:()=>Qn,WORKFLOW_BUSINESS_STEP_FACTS_KEY:()=>hr,WORKFLOW_BUSINESS_STEP_MAX_BYTES:()=>Jt,WORKFLOW_BUSINESS_STEP_MAX_RECEIPT_BYTES:()=>ei,WORKFLOW_CONFIGURABLE_OPERATIONS:()=>Xt,WORKFLOW_CONFIGURABLE_PROVIDERS:()=>Qt,WORKFLOW_EVENT_TYPES_V2:()=>sn,WORKFLOW_ROUTING_MAX_BYTES:()=>td,WORKFLOW_ROUTING_MAX_MATCHED_RULES:()=>ed,WORKFLOW_ROUTING_MAX_RULES:()=>Zc,WORKFLOW_TASK_PAGE_MAX_BYTES:()=>Xc,WORKFLOW_TASK_PAGE_MAX_FIELDS:()=>Hc,WorkflowTaskPageError:()=>Ve,applyWorkflowTaskPageValues:()=>Fr,assertNativeRoleMembershipBatchInput:()=>rc,compileNativeApplicationConfiguration:()=>ma,compileNativeEventAction:()=>Jn,compileNativeEventCapturePlansV2:()=>ji,compileRequiredPlatformCapabilitiesV3:()=>xi,compileWorkflowBusinessStepHandlers:()=>zt,evaluateWorkflowTaskPageExpression:()=>Ce,formatWorkflowExpression:()=>_t,hasDataAuditReadPolicy:()=>hn,isDataAuditMetadataField:()=>Ge,isDataSystemSortField:()=>Rn,isNativeDataQueryOperatorV2:()=>Rs,isNativeMultiValueFieldV2:()=>at,materializeNativeDataQueryPathTypesV2:()=>Ir,nativeDataPolicyExpressionLeavesV2:()=>yt,nativeDataPolicyExpressionToCnfV2:()=>uo,nativeDataQueryPathPlanV2:()=>Nr,nativeFieldAggregatePlanV2:()=>Fs,nativeFieldColumnDefinitionV2:()=>Ys,nativeFieldDefaultSqlV2:()=>Hs,nativeFieldHasDefaultV2:()=>Qs,nativeFieldIndexStatementsV2:()=>nr,nativeFieldRequiresCreateInputV2:()=>ct,nativeFieldSequenceGrantStatementsV2:()=>tr,nativeFieldSequenceOwnershipStatementsV2:()=>er,nativeFieldSequenceStatementsV2:()=>Zs,nativeFieldSupportsFilterV2:()=>$n,nativeFieldSupportsOperatorV2:()=>$s,nativeFieldSupportsSearchV2:()=>Vt,nativeFieldSupportsSortV2:()=>Je,nativeOperatorsForFieldV2:()=>Dn,nativePhysicalFieldV2:()=>Ko,nativePhysicalFieldsV2:()=>zs,nativePhysicalObjectNameV2:()=>Re,nativeScopeSourceFieldValueV2:()=>dr,nativeScopeSourceGrantPathSupportedV2:()=>Un,nativeScopeSourceSubjectPathSupportedV2:()=>Bt,nativeSubtableConstraintStatementsV2:()=>or,nativeUniqueKeysJsonSchema:()=>br,parseDecimalReservationLifecycle:()=>jt,parseNativeDataFieldsV2:()=>Dt,parseNativeDataResourceInvariantsV2:()=>Tn,parseNativeUniqueKeys:()=>qn,projectNativeDataResourceViewV2:()=>Pt,projectWorkflowGraph:()=>Dr,projectWorkflowNodePolicy:()=>kr,quoteNativeIdentifierV2:()=>oe,refreshWorkflowTaskPageFacts:()=>vr,resolveNativeScopeSourceFieldPathV2:()=>He,selectWorkflowAssignmentRoutingRules:()=>Br,validateDecimalReservationLifecycles:()=>Mn,validateManagedConcurrency:()=>Pn,validateNativeDataDraftStateV2:()=>kn,validateNativeDataResourceReferencesV2:()=>bn,validateNativeDataResourceSurfaceV2:()=>vt,validateWorkflowAdministration:()=>Zt,validateWorkflowAssignmentRoutingBindings:()=>co,validateWorkflowAssignmentRoutingPolicy:()=>It,validateWorkflowAssignmentRoutingRules:()=>Wr,validateWorkflowAutomaticCc:()=>en,validateWorkflowBusinessStepHandlerContract:()=>Cr,validateWorkflowBusinessStepRequest:()=>Rr,validateWorkflowBusinessStepResult:()=>oi,validateWorkflowBusinessStepSchema:()=>ft,validateWorkflowBusinessStepSubscriptions:()=>eo,validateWorkflowBusinessSteps:()=>mt,validateWorkflowInstanceCommandPolicies:()=>Yn,validateWorkflowNodeConfigurationPatch:()=>Vr,validateWorkflowReadability:()=>oo,validateWorkflowTaskPages:()=>nn,workflowAssignmentRoutingFacts:()=>Ur,workflowAssignmentRoutingPolicySchema:()=>Mr,workflowAssignmentRoutingSemantic:()=>mi,workflowBusinessStepFactSchema:()=>pt,workflowBusinessStepHandlerDigest:()=>lc,workflowBusinessStepInput:()=>Sr,workflowBusinessStepPath:()=>ii,workflowBusinessStepReceiptSignatureSuffix:()=>dc,workflowBusinessStepValueMatches:()=>ut,workflowDelegationMutationRequestSchema:()=>ss,workflowExpressionPaths:()=>no,workflowInstanceCommandDeadlineError:()=>Or,workflowInstanceTerminateCapabilityAllowed:()=>Tr,workflowNodeAllowedOperations:()=>tt,workflowPolicyTimestamp:()=>zn,workflowTaskPageFieldState:()=>li,workflowTaskPageReplayCoversInvalidation:()=>Pr});module.exports=ps(fc);var Oo=require("node:crypto");function ms(e){if(!e||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function An(e,t){if(e===null)return"null";if(typeof e=="string"||typeof e=="boolean")return JSON.stringify(e);if(typeof e=="number"){if(!Number.isFinite(e))throw new TypeError(`JSON number must be finite: ${t}`);return JSON.stringify(e)}if(Array.isArray(e))return`[${e.map((n,i)=>An(n,`${t}[${i}]`)).join(",")}]`;if(ms(e))return`{${Object.keys(e).filter(i=>e[i]!==void 0).sort((i,s)=>i===s?0:i<s?-1:1).map(i=>`${JSON.stringify(i)}:${An(e[i],`${t}.${i}`)}`).join(",")}}`;let o=e instanceof Date?"Date":e?.constructor?.name||typeof e;throw new TypeError(`Value is not JSON serializable: ${t} (${o})`)}function ee(e){return An(e,"$")}function X(e){return(0,Oo.createHash)("sha256").update(ee(e)).digest("hex")}var So=/^[A-Za-z][A-Za-z0-9_]{0,62}$/,Nn=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,wo=["text.short","text.long","text.rich","number.integer","number.decimal","boolean","date","time","datetime","date-range","datetime-range","option.single","option.multiple","cascade.single","cascade.multiple","user.single","user.multiple","department.single","department.multiple","resource-ref.single","resource-ref.multiple","image","signature","address","location","uuid","json","file","serial-number","subtable"],_s=new Set(wo),Do=new Set(["option.multiple","cascade.multiple","user.multiple","department.multiple","resource-ref.multiple","file","image","subtable"]),ho=new Set(["option.single","option.multiple","cascade.single","cascade.multiple"]),Ro=new Set(["resource-ref.single","resource-ref.multiple"]),wt=[{code:"id",type:"uuid",nullable:!1},{code:"revision",type:"number.integer",nullable:!1},{code:"created_by",type:"text.short",nullable:!1},{code:"updated_by",type:"text.short",nullable:!1},{code:"created_at",type:"datetime",nullable:!1},{code:"updated_at",type:"datetime",nullable:!1}],yn=new Map(wt.map(e=>[e.code,e])),me=class extends Error{constructor(o,n){super(o);this.code=o;this.pointer=n;this.name="NativeDataFieldContractV2Error"}code;pointer};function at(e){return Do.has(e)}function ct(e,t={}){return e.type!=="serial-number"&&t.system!==!0&&e.nullable===!1&&(!at(e.type)||t.requiredHint===!0)}function Dt(e,t,o=500){Array.isArray(e)||w("NATIVE_ARRAY_REQUIRED",t),e.length===0&&w("NATIVE_DATA_FIELDS_REQUIRED",t),e.length>o&&w("NATIVE_ARRAY_LIMIT_EXCEEDED",t);let n=new Set;return e.map((i,s)=>{let c=`${t}/${s}`,r=le(i,c);pe(r,["code","type","nullable","indexed","options","source","maxLength","precision","scale","exactDecimal","min","max","rangeBoundary","timePrecision","file","serial","subtable"],c);let a=_e(r.code,`${c}/code`,63);So.test(a)||w("NATIVE_FIELD_CODE_INVALID",`${c}/code`),n.has(a)&&w("NATIVE_DATA_FIELD_DUPLICATE",`${c}/code`),n.add(a);let d=_e(r.type,`${c}/type`,32);_s.has(d)||w("NATIVE_DATA_FIELD_TYPE_INVALID",`${c}/type`);let u=d,l=In(r.nullable,`${c}/nullable`),f=In(r.indexed,`${c}/indexed`);l===!0&&Do.has(u)&&w("NATIVE_DATA_MULTI_FIELD_NULLABLE_INVALID",`${c}/nullable`);let A=Es(r.options,u,c),N=Is(r.source,u,c),I=ys(r,u,c),m=In(r.exactDecimal,`${c}/exactDecimal`);m!==void 0&&u!=="number.decimal"&&w("NATIVE_DATA_FIELD_EXACT_DECIMAL_TYPE_INVALID",`${c}/exactDecimal`);let E=gs(r.rangeBoundary,u,c),p=bs(r.file,u,c),g=Ts(r.serial,u,c),O=Os(r.subtable,u,c);return{code:a,type:u,...l===void 0?{}:{nullable:l},...f===void 0?{}:{indexed:f},...A?{options:A}:{},...N?{source:N}:{},...I,...m===void 0?{}:{exactDecimal:m},...E?{rangeBoundary:E}:{},...p?{file:p}:{},...g?{serial:g}:{},...O?{subtable:O}:{}}})}function gs(e,t,o){let n=`${o}/rangeBoundary`;if(!(t==="date-range"||t==="datetime-range")){e!==void 0&&w("NATIVE_DATA_FIELD_RANGE_BOUNDARY_TYPE_INVALID",n);return}return e!=="closed"&&e!=="half-open"&&w("NATIVE_DATA_FIELD_RANGE_BOUNDARY_REQUIRED",n),e}function bn(e,t){Array.isArray(e)||w("NATIVE_ARRAY_REQUIRED",t);let o=new Map;e.forEach((n,i)=>{let s=`${t}/${i}`,c=le(n,s),r=_e(c.code,`${s}/code`,64);(!Nn.test(r)||o.has(r))&&w("NATIVE_RESOURCE_CODE_INVALID",`${s}/code`);let a=le(c.schema,`${s}/schema`);o.set(r,{pointer:s,fields:Dt(a.fields,`${s}/schema/fields`)})});for(let[n,i]of o){let s=new Map(i.fields.map(r=>[r.code,r]));i.fields.filter(r=>r.type==="subtable").reduce((r,a)=>r+(a.subtable?.maxRows??20),0)>49&&w("NATIVE_DATA_FIELD_SUBTABLE_AGGREGATE_MAX_ROWS_EXCEEDED",`${i.pointer}/schema/fields`),i.fields.forEach((r,a)=>{let d=`${i.pointer}/schema/fields/${a}`;if(r.source&&As(r.source,s,o,`${d}/source`),r.subtable){let u=o.get(r.subtable.resourceCode);(!u||r.subtable.resourceCode===n)&&w("NATIVE_DATA_FIELD_SUBTABLE_TARGET_MISSING",`${d}/subtable/resourceCode`);let l=u.fields.find(A=>A.code===r.subtable?.foreignKey);(!l||l.type!=="uuid"||l.nullable!==!1)&&w("NATIVE_DATA_FIELD_SUBTABLE_FOREIGN_KEY_INVALID",`${d}/subtable/foreignKey`);let f=u.fields.find(A=>A.code===r.subtable?.orderField);(!f||f.type!=="number.integer"||f.nullable!==!1)&&w("NATIVE_DATA_FIELD_SUBTABLE_ORDER_FIELD_INVALID",`${d}/subtable/orderField`)}})}}function Tn(e,t,o){if(e===void 0)return[];(!Array.isArray(e)||e.length>20)&&w("NATIVE_DATA_RESOURCE_INVARIANTS_INVALID",o);let n=new Map(t.map(s=>[s.code,s])),i=new Set;return e.map((s,c)=>{let r=`${o}/${c}`,a=le(s,r);pe(a,["code","message","expression"],r);let d=_e(a.code,`${r}/code`,128);(!/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(d)||i.has(d))&&w("NATIVE_DATA_RESOURCE_INVARIANT_CODE_INVALID",`${r}/code`),i.add(d);let u=St(a.message,`${r}/message`,500);u!==void 0&&u.length===0&&w("NATIVE_DATA_RESOURCE_INVARIANT_MESSAGE_INVALID",`${r}/message`);let l=le(a.expression,`${r}/expression`);if(l.kind==="nonBlankTextWhenOption"){pe(l,["kind","optionField","optionValue","textField"],`${r}/expression`);let p=Ee(l.optionField,`${r}/expression/optionField`),g=Ee(l.textField,`${r}/expression/textField`),O=_e(l.optionValue,`${r}/expression/optionValue`,128),y=n.get(p),T=n.get(g);return(!y||!T)&&w("NATIVE_DATA_RESOURCE_INVARIANT_FIELD_UNKNOWN",`${r}/expression`),(y.type!=="option.single"||!["text.short","text.long"].includes(T.type)||!y.options?.some(h=>h.value===O))&&w("NATIVE_DATA_RESOURCE_INVARIANT_FIELD_TYPES_INVALID",`${r}/expression`),{code:d,...u===void 0?{}:{message:u},expression:{kind:"nonBlankTextWhenOption",optionField:p,optionValue:O,textField:g}}}pe(l,["leftField","operator","rightField"],`${r}/expression`);let f=Ee(l.leftField,`${r}/expression/leftField`),A=Ee(l.rightField,`${r}/expression/rightField`),N=n.get(f),I=n.get(A);(!N||!I)&&w("NATIVE_DATA_RESOURCE_INVARIANT_FIELD_UNKNOWN",`${r}/expression`),N.type===I.type||["number.integer","number.decimal"].includes(N.type)&&["number.integer","number.decimal"].includes(I.type)||w("NATIVE_DATA_RESOURCE_INVARIANT_FIELD_TYPES_INVALID",`${r}/expression`);let E=String(l.operator);return["eq","neq","gt","gte","lt","lte"].includes(E)||w("NATIVE_DATA_RESOURCE_INVARIANT_OPERATOR_INVALID",`${r}/expression/operator`),!["eq","neq"].includes(E)&&!["number.integer","number.decimal","date","time","datetime","text.short","text.long","text.rich","serial-number","uuid"].includes(N.type)&&w("NATIVE_DATA_RESOURCE_INVARIANT_FIELD_TYPES_INVALID",`${r}/expression`),{code:d,...u===void 0?{}:{message:u},expression:{leftField:f,operator:E,rightField:A}}})}function As(e,t,o,n){let i=o.get(e.resourceCode);i||w("NATIVE_DATA_FIELD_SOURCE_TARGET_MISSING",`${n}/resourceCode`);let s=new Map(i.fields.map(r=>[r.code,r])),c=s.get(e.labelField);(!c||!["text.short","text.long"].includes(c.type))&&w("NATIVE_DATA_FIELD_SOURCE_LABEL_INVALID",`${n}/labelField`);for(let r of["searchFields","descriptionFields","snapshotFields"])for(let a of e[r]||[])s.has(a)||w("NATIVE_DATA_FIELD_SOURCE_FIELD_MISSING",`${n}/${r}`);for(let[r,a]of(e.filters||[]).entries())s.has(a.field)||w("NATIVE_DATA_FIELD_SOURCE_FILTER_FIELD_MISSING",`${n}/filters/${r}/field`),"binding"in a&&!t.has(a.binding.field)&&w("NATIVE_DATA_FIELD_SOURCE_BINDING_FIELD_MISSING",`${n}/filters/${r}/binding/field`)}function Es(e,t,o){let n=`${o}/options`;if(e===void 0){ho.has(t)&&w("NATIVE_DATA_FIELD_OPTIONS_REQUIRED",n);return}(!ho.has(t)||!Array.isArray(e))&&w("NATIVE_DATA_FIELD_OPTIONS_TYPE_INVALID",n),(e.length<1||e.length>100)&&w("NATIVE_DATA_FIELD_OPTIONS_INVALID",n);let i=0,s=(c,r,a)=>{a>5&&w("NATIVE_DATA_FIELD_OPTIONS_DEPTH_EXCEEDED",r);let d=new Set;return c.map((u,l)=>{i+=1,i>1e3&&w("NATIVE_DATA_FIELD_OPTIONS_COUNT_EXCEEDED",n);let f=`${r}/${l}`,A=le(u,f);pe(A,["label","value","description","color","children"],f);let N=_e(A.label,`${f}/label`,500),I=_e(A.value,`${f}/value`,500);d.has(I)&&w("NATIVE_DATA_FIELD_OPTION_VALUE_DUPLICATE",`${f}/value`),d.add(I);let m=St(A.description,`${f}/description`,2e3),E=St(A.color,`${f}/color`,64),p;return A.children!==void 0&&((!t.startsWith("cascade.")||!Array.isArray(A.children))&&w("NATIVE_DATA_FIELD_OPTION_CHILDREN_INVALID",`${f}/children`),(A.children.length<1||A.children.length>100)&&w("NATIVE_DATA_FIELD_OPTION_CHILDREN_INVALID",`${f}/children`),p=s(A.children,`${f}/children`,a+1)),{label:N,value:I,...m===void 0?{}:{description:m},...E===void 0?{}:{color:E},...p?{children:p}:{}}})};return s(e,n,1)}function Is(e,t,o){let n=`${o}/source`;if(e===void 0){Ro.has(t)&&w("NATIVE_DATA_FIELD_SOURCE_REQUIRED",n);return}Ro.has(t)||w("NATIVE_DATA_FIELD_SOURCE_TYPE_INVALID",n);let i=le(e,n);pe(i,["kind","resourceCode","labelField","searchFields","descriptionFields","snapshotFields","filters","pageSize","loadMode"],n),i.kind!=="resource"&&w("NATIVE_DATA_FIELD_SOURCE_KIND_INVALID",`${n}/kind`);let s=_e(i.resourceCode,`${n}/resourceCode`,64);Nn.test(s)||w("NATIVE_RESOURCE_CODE_INVALID",`${n}/resourceCode`);let c=Ee(i.labelField,`${n}/labelField`),r=En(i.searchFields,`${n}/searchFields`,10),a=En(i.descriptionFields,`${n}/descriptionFields`,10),d=En(i.snapshotFields,`${n}/snapshotFields`,50),u=Ke(i.pageSize,`${n}/pageSize`,1,100),l;i.loadMode!==void 0&&(["search","all"].includes(String(i.loadMode))||w("NATIVE_DATA_FIELD_SOURCE_LOAD_MODE_INVALID",`${n}/loadMode`),l=i.loadMode);let f=Ns(i.filters,`${n}/filters`);return{kind:"resource",resourceCode:s,labelField:c,...r?{searchFields:r}:{},...a?{descriptionFields:a}:{},...d?{snapshotFields:d}:{},...f?{filters:f}:{},...u===void 0?{}:{pageSize:u},...l?{loadMode:l}:{}}}function Ns(e,t){if(e!==void 0)return(!Array.isArray(e)||e.length>20)&&w("NATIVE_DATA_FIELD_SOURCE_FILTERS_INVALID",t),e.map((o,n)=>{let i=`${t}/${n}`,s=le(o,i),c=Object.prototype.hasOwnProperty.call(s,"value"),r=Object.prototype.hasOwnProperty.call(s,"binding");pe(s,c?["field","operator","value"]:["field","operator","binding"],i),c===r&&w("NATIVE_DATA_FIELD_SOURCE_FILTER_VALUE_INVALID",i);let a=Ee(s.field,`${i}/field`);["eq","in"].includes(String(s.operator))||w("NATIVE_DATA_FIELD_SOURCE_FILTER_OPERATOR_INVALID",`${i}/operator`);let d=s.operator;if(c)return{field:a,operator:d,value:s.value};let u=le(s.binding,`${i}/binding`);return pe(u,["kind","field"],`${i}/binding`),u.kind!=="field"&&w("NATIVE_DATA_FIELD_SOURCE_BINDING_KIND_INVALID",`${i}/binding/kind`),{field:a,operator:d,binding:{kind:"field",field:Ee(u.field,`${i}/binding/field`)}}})}function ys(e,t,o){let n={};if(e.maxLength!==void 0&&(["text.short","text.long","text.rich"].includes(t)||w("NATIVE_DATA_FIELD_MAX_LENGTH_TYPE_INVALID",`${o}/maxLength`),n.maxLength=Ct(e.maxLength,`${o}/maxLength`,1,1e6)),(e.precision!==void 0||e.scale!==void 0)&&((t!=="number.decimal"||e.precision===void 0)&&w("NATIVE_DATA_FIELD_DECIMAL_CONFIG_INVALID",o),n.precision=Ct(e.precision,`${o}/precision`,1,1e3),n.scale=e.scale===void 0?0:Ct(e.scale,`${o}/scale`,0,n.precision)),e.min!==void 0||e.max!==void 0){["number.integer","number.decimal"].includes(t)||w("NATIVE_DATA_FIELD_NUMERIC_BOUNDS_TYPE_INVALID",o);let i=Co(e.min,`${o}/min`),s=Co(e.max,`${o}/max`);t==="number.integer"&&[i,s].some(c=>c!==void 0&&!Number.isSafeInteger(c))&&w("NATIVE_DATA_FIELD_NUMERIC_BOUNDS_INVALID",o),i!==void 0&&s!==void 0&&i>s&&w("NATIVE_DATA_FIELD_NUMERIC_BOUNDS_INVALID",o),i!==void 0&&(n.min=i),s!==void 0&&(n.max=s)}return e.timePrecision!==void 0&&((t!=="time"||!["minute","second"].includes(e.timePrecision))&&w("NATIVE_DATA_FIELD_TIME_PRECISION_INVALID",`${o}/timePrecision`),n.timePrecision=e.timePrecision),n}function bs(e,t,o){if(e===void 0)return;let n=`${o}/file`;["file","image","signature"].includes(t)||w("NATIVE_DATA_FIELD_FILE_TYPE_INVALID",n);let i=le(e,n);pe(i,["maxCount","maxSizeMb","accept"],n);let s=Ke(i.maxCount,`${n}/maxCount`,1,100);t==="signature"&&s!==void 0&&s!==1&&w("NATIVE_DATA_FIELD_SIGNATURE_COUNT_INVALID",`${n}/maxCount`);let c=Ke(i.maxSizeMb,`${n}/maxSizeMb`,1,1024),r;return i.accept!==void 0&&((!Array.isArray(i.accept)||i.accept.length>50)&&w("NATIVE_DATA_FIELD_FILE_ACCEPT_INVALID",`${n}/accept`),r=i.accept.map((a,d)=>_e(a,`${n}/accept/${d}`,255)),new Set(r).size!==r.length&&w("NATIVE_DATA_FIELD_FILE_ACCEPT_INVALID",`${n}/accept`)),{...s===void 0?{}:{maxCount:s},...c===void 0?{}:{maxSizeMb:c},...r===void 0?{}:{accept:r}}}function Ts(e,t,o){let n=`${o}/serial`;if(e===void 0){t==="serial-number"&&w("NATIVE_DATA_FIELD_SERIAL_REQUIRED",n);return}t!=="serial-number"&&w("NATIVE_DATA_FIELD_SERIAL_TYPE_INVALID",n);let i=le(e,n);pe(i,["prefix","digits","start"],n);let s=St(i.prefix,`${n}/prefix`,64),c=Ke(i.digits,`${n}/digits`,1,32),r=Ke(i.start,`${n}/start`,0,Number.MAX_SAFE_INTEGER);return{...s===void 0?{}:{prefix:s},...c===void 0?{}:{digits:c},...r===void 0?{}:{start:r}}}function Os(e,t,o){let n=`${o}/subtable`;if(e===void 0){t==="subtable"&&w("NATIVE_DATA_FIELD_SUBTABLE_REQUIRED",n);return}t!=="subtable"&&w("NATIVE_DATA_FIELD_SUBTABLE_TYPE_INVALID",n);let i=le(e,n);pe(i,["resourceCode","foreignKey","orderField","maxRows"],n);let s=_e(i.resourceCode,`${n}/resourceCode`,64);Nn.test(s)||w("NATIVE_RESOURCE_CODE_INVALID",`${n}/resourceCode`);let c=Ee(i.foreignKey,`${n}/foreignKey`),r=Ee(i.orderField,`${n}/orderField`);r===c&&w("NATIVE_DATA_FIELD_SUBTABLE_ORDER_FIELD_INVALID",`${n}/orderField`);let a=Ke(i.maxRows,`${n}/maxRows`,1,49);return{resourceCode:s,foreignKey:c,orderField:r,...a===void 0?{}:{maxRows:a}}}function En(e,t,o){if(e===void 0)return;(!Array.isArray(e)||e.length>o)&&w("NATIVE_DATA_FIELD_SOURCE_FIELDS_INVALID",t);let n=e.map((i,s)=>Ee(i,`${t}/${s}`));return new Set(n).size!==n.length&&w("NATIVE_DATA_FIELD_SOURCE_FIELDS_INVALID",t),n}function Ee(e,t){let o=_e(e,t,63);return So.test(o)||w("NATIVE_FIELD_CODE_INVALID",t),o}function le(e,t){return(!e||typeof e!="object"||Array.isArray(e))&&w("NATIVE_OBJECT_REQUIRED",t),e}function pe(e,t,o){let n=new Set(t);for(let i of Object.keys(e))n.has(i)||w("NATIVE_PROPERTY_UNKNOWN",`${o}/${i}`)}function _e(e,t,o){return(typeof e!="string"||e.length===0||e.length>o)&&w("NATIVE_STRING_INVALID",t),e}function St(e,t,o){if(e!==void 0)return(typeof e!="string"||e.length>o)&&w("NATIVE_STRING_INVALID",t),e}function In(e,t){if(e!==void 0)return typeof e!="boolean"&&w("NATIVE_BOOLEAN_REQUIRED",t),e}function Ke(e,t,o,n){if(e!==void 0)return Ct(e,t,o,n)}function Co(e,t){if(e!==void 0)return(typeof e!="number"||!Number.isFinite(e))&&w("NATIVE_NUMBER_REQUIRED",t),e}function Ct(e,t,o,n){return(!Number.isSafeInteger(e)||Number(e)<o||Number(e)>n)&&w("NATIVE_INTEGER_OUT_OF_RANGE",t),Number(e)}function w(e,t){throw new me(e,t)}var On=["created_by","updated_by","created_at","updated_at"];function Ge(e){return On.includes(e)}function hn(e){return On.some(t=>Object.prototype.hasOwnProperty.call(e.fieldPolicies||{},t))}var $o=wt.map(e=>e.code);function Rn(e){return $o.includes(e)}var Fo=["eq","neq","gt","gte","lt","lte","contains","startsWith","endsWith","in","between","has","hasAny","hasAll","overlaps","containedBy","jsonContains","isEmpty","isNotEmpty"],hs=new Set(Fo);function Rs(e){return hs.has(String(e))}var Cn=["eq","neq","contains","startsWith","endsWith","in","isEmpty","isNotEmpty"],dt=["eq","neq","gt","gte","lt","lte","between","in","isEmpty"],Cs=["eq","neq","in","isEmpty"],$t=["eq","neq","in","isEmpty","isNotEmpty"],qe=["has","hasAny","hasAll","isEmpty","isNotEmpty"],Vo=["overlaps","contains","containedBy","isEmpty"],Sn=["jsonContains","isEmpty","isNotEmpty"],wn=["isEmpty","isNotEmpty"],Ss={"text.short":Cn,"text.long":Cn,"text.rich":Cn,"number.integer":dt,"number.decimal":dt,boolean:Cs,date:dt,time:dt,datetime:dt,"date-range":Vo,"datetime-range":Vo,"option.single":$t,"option.multiple":qe,"cascade.single":qe,"cascade.multiple":qe,"user.single":$t,"user.multiple":qe,"department.single":$t,"department.multiple":qe,"resource-ref.single":$t,"resource-ref.multiple":qe,file:wn,image:wn,signature:wn,address:Sn,location:Sn,uuid:["eq","neq","in","isEmpty"],json:Sn,"serial-number":["eq","neq","in","contains","startsWith"],subtable:[]},ws=new Set(["text.short","text.long","text.rich","option.single","user.single","department.single","resource-ref.single","serial-number"]),Ds=new Set(["option.multiple","cascade.single","cascade.multiple","user.multiple","department.multiple","resource-ref.multiple","file","image","signature","address","location","json","subtable"]);function Dn(e){return Ss[e]}function $s(e,t){return Dn(e).includes(t)}function Vt(e){return ws.has(e)}function Je(e){return!Ds.has(e)}function $n(e){return Dn(e).length>0}var ko=new Set(["number.integer","number.decimal"]),vo=new Set(["text.short","text.long","number.integer","number.decimal","date","time","datetime","serial-number"]),Vs=new Set([...vo,"boolean","uuid"]),ks=new Set(["option.single","user.single","department.single","resource-ref.single"]);function Fs(e,t){return t==="sum"||t==="avg"?ko.has(e)?{valueExpression:"column",numericResult:!0}:null:t==="min"||t==="max"?vo.has(e)?{valueExpression:"column",numericResult:ko.has(e)}:null:ks.has(e)?{valueExpression:"snapshot-value",numericResult:!0}:Vs.has(e)?{valueExpression:"column",numericResult:!0}:null}var Ft=["version","maxBytes","fields"];function kn(e,t){if(e===void 0)return;let o=Vn(e,t);Po(o,Ft,t);let n=kt(o.version,`${t}/version`,1,1e6),i=kt(o.maxBytes,`${t}/maxBytes`,2,196608);(!n||!i)&&re("NATIVE_DATA_DRAFT_STATE_SCHEMA_INVALID",t);let s=Vn(o.fields,`${t}/fields`),c=Object.entries(s);(!c.length||c.length>50)&&re("NATIVE_DATA_DRAFT_STATE_FIELDS_INVALID",`${t}/fields`);for(let[r,a]of c){let d=`${t}/fields/${r}`;/^[A-Za-z][A-Za-z0-9_]{0,62}$/.test(r)||re("NATIVE_DATA_DRAFT_STATE_FIELD_CODE_INVALID",d);let u=Vn(a,d),l=Lo(u.type,`${d}/type`,32),f=l==="string"?["type","required","maxLength","enum"]:l==="json.object"?["type","required","maxBytes"]:["type","required"];if(["string","number","integer","boolean","json.object"].includes(l)||re("NATIVE_DATA_DRAFT_STATE_FIELD_TYPE_INVALID",`${d}/type`),Po(u,f,d),Ps(u.required,`${d}/required`),l==="string"){let A=kt(u.maxLength,`${d}/maxLength`,1,196608);A||re("NATIVE_DATA_DRAFT_STATE_FIELD_INVALID",d),u.enum!==void 0&&vs(u.enum,`${d}/enum`,100,!1).some(I=>I.length>A)&&re("NATIVE_DATA_DRAFT_STATE_FIELD_INVALID",`${d}/enum`)}else if(l==="json.object"){let A=kt(u.maxBytes,`${d}/maxBytes`,2,65536);(!A||A>i)&&re("NATIVE_DATA_DRAFT_STATE_FIELD_INVALID",d)}}}function vs(e,t,o,n){(!Array.isArray(e)||!n&&e.length===0||e.length>o)&&re("NATIVE_DATA_SURFACE_STRING_ARRAY_INVALID",t);let i=e.map((s,c)=>Lo(s,`${t}/${c}`,255));return new Set(i).size!==i.length&&re("NATIVE_DATA_SURFACE_STRING_ARRAY_INVALID",t),i}function Vn(e,t){return(!e||typeof e!="object"||Array.isArray(e))&&re("NATIVE_OBJECT_REQUIRED",t),e}function Po(e,t,o){let n=new Set(t);for(let i of Object.keys(e))n.has(i)||re("NATIVE_PROPERTY_UNKNOWN",`${o}/${i}`)}function Lo(e,t,o){return(typeof e!="string"||e.length===0||e.length>o)&&re("NATIVE_STRING_INVALID",t),e}function Ps(e,t){e!==void 0&&typeof e!="boolean"&&re("NATIVE_BOOLEAN_REQUIRED",t)}function kt(e,t,o,n){return(!Number.isSafeInteger(e)||Number(e)<o||Number(e)>n)&&re("NATIVE_INTEGER_INVALID",t),Number(e)}function re(e,t){throw new me(e,t)}var Ls=500,Oe={surface:["mutationOwner","generated","fields","list","form","detail","mobile","views"],generated:["list","detail","create","update","delete"],field:["label","type","widget","section","requiredHint","system","hidden","readCapabilities","createCapabilities","updateCapabilities","maxLength","precision","scale","exactDecimal","min","max","rangeBoundary","maxCount","maxSizeMb","accept","options","list","searchable","sortable","source","timePrecision","serial","subtable"],list:["actions","fieldOrder","defaultPageSize","searchableFields","filterFields","defaultSort"],defaultSort:["field","order"],form:["layout","fieldOrder","draftState"],detail:["layout","fieldOrder"],layout:["layout","fieldOrder","draftState"],draftState:Ft,mobile:["enabled"]},xs={"text.short":["text","email","phone"],"text.long":["textarea"],"text.rich":["rich-text"],"number.integer":["number","rating"],"number.decimal":["number","money","percent"],boolean:["switch"],date:["date"],time:["time"],datetime:["datetime"],"date-range":["date-range"],"datetime-range":["datetime-range"],"option.single":["select","radio"],"option.multiple":["multi-select","checkbox"],"cascade.single":["cascade"],"cascade.multiple":["cascade"],"user.single":["directory-user"],"user.multiple":["directory-user"],"department.single":["directory-department","scope"],"department.multiple":["directory-department","scope"],"resource-ref.single":["select","radio","resource"],"resource-ref.multiple":["multi-select","checkbox","resource"],file:["attachment"],image:["image"],signature:["signature"],address:["address"],location:["location"],uuid:["readonly"],json:["json"],"serial-number":["readonly"],subtable:["subtable"]};function vt(e,t,o){if(e===void 0)return;let n=ne(e,o);Ie(n,Oe.surface,o);let i=n.mutationOwner===void 0?"native":he(n.mutationOwner,`${o}/mutationOwner`,16);["native","action","readonly","workflow","queued-command"].includes(i)||L("NATIVE_DATA_SURFACE_MUTATION_OWNER_INVALID",`${o}/mutationOwner`);let s=n.generated===void 0?{}:ne(n.generated,`${o}/generated`);Ie(s,Oe.generated,`${o}/generated`);for(let a of Oe.generated)vn(s[a],`${o}/generated/${a}`);if(i!=="native")for(let a of["create","update","delete"])s[a]===!0&&L("NATIVE_DATA_SURFACE_MUTATION_OWNER_CONFLICT",`${o}/generated/${a}`);let c=new Map(t.map(a=>[a.code,a])),r=ne(n.fields,`${o}/fields`);for(let a of Object.keys(r))c.has(a)||L("NATIVE_DATA_SURFACE_FIELD_MISSING",`${o}/fields/${a}`);for(let a of t)Object.prototype.hasOwnProperty.call(r,a.code)||L("NATIVE_DATA_SURFACE_FIELD_REQUIRED",`${o}/fields/${a.code}`),Ms(r[a.code],a,`${o}/fields/${a.code}`);for(let a of["create","update"]){let d=s[a]??i==="native",u=t.some(l=>{let f=ne(r[l.code],`${o}/fields/${l.code}`);return jo(l,f,a)});d&&!u&&L("NATIVE_DATA_SURFACE_WRITABLE_FIELDS_REQUIRED",`${o}/generated/${a}`)}if(Ws(n.list,c,`${o}/list`),xo(n.form,c,`${o}/form`,"form"),xo(n.detail,c,`${o}/detail`,"detail"),n.mobile!==void 0){let a=ne(n.mobile,`${o}/mobile`);Ie(a,Oe.mobile,`${o}/mobile`),vn(a.enabled,`${o}/mobile/enabled`)}js(n,t,o)}function Pt(e,t){let o=e.views?.find(i=>i.code===t);o||L("NATIVE_DATA_VIEW_NOT_FOUND",`/surface/views/${t}`);let n=new Map((o.sections||[]).flatMap(i=>i.fields.map(s=>[s,i.title])));return{mutationOwner:e.mutationOwner||"native",generated:o.generated,list:o.list,form:o.form,detail:o.detail,mobile:o.mobile,fields:Object.fromEntries(Object.entries(e.fields).map(([i,s])=>{let c={...s};delete c.section;let r=n.get(i);return[i,{...c,...r?{section:r}:{},list:o.list.fieldOrder.includes(i)}]}))}}function js(e,t,o){if(e.views===void 0)return;(!Array.isArray(e.views)||e.views.length>20)&&L("NATIVE_DATA_VIEWS_LIMIT_INVALID",`${o}/views`);let n=new Set;e.views.forEach((i,s)=>{let c=`${o}/views/${s}`,r=ne(i,c);Ie(r,["code","name","generated","list","form","detail","mobile","sections"],c);let a=he(r.code,`${c}/code`,64);(!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(a)||n.has(a))&&L("NATIVE_DATA_VIEW_CODE_INVALID",`${c}/code`),n.add(a),he(r.name,`${c}/name`,255),ne(r.generated,`${c}/generated`),ne(r.mobile,`${c}/mobile`);for(let u of["list","detail","create","update","delete"])typeof r.generated[u]!="boolean"&&L("NATIVE_DATA_VIEW_OPERATION_INVALID",`${c}/generated/${u}`);typeof r.mobile.enabled!="boolean"&&L("NATIVE_DATA_VIEW_MOBILE_INVALID",`${c}/mobile/enabled`);for(let u of["list","form","detail"]){let l=ne(r[u],`${c}/${u}`),f=ze(l.fieldOrder,`${c}/${u}/fieldOrder`,500,!0);for(let A of f){let N=e.fields[A];(!N||(N.hidden??N.system)===!0)&&L("NATIVE_DATA_VIEW_FIELD_INVALID",`${c}/${u}/fieldOrder`)}}if(r.sections!==void 0){(!Array.isArray(r.sections)||r.sections.length>100)&&L("NATIVE_DATA_VIEW_SECTIONS_INVALID",`${c}/sections`);let u=new Set;r.sections.forEach((l,f)=>{let A=`${c}/sections/${f}`,N=ne(l,A);Ie(N,["title","fields"],A),he(N.title,`${A}/title`,255);for(let I of ze(N.fields,`${A}/fields`,100,!0)){let m=e.fields[I];(!m||(m.hidden??m.system)===!0||u.has(I))&&L("NATIVE_DATA_VIEW_FIELD_INVALID",`${A}/fields`),u.add(I)}})}let d=Pt(e,a);if(vt(d,t,c),r.generated.create!==!1&&(e.mutationOwner||"native")==="native")for(let u of t)ct(u,e.fields[u.code])&&jo(u,e.fields[u.code],"create")&&!r.form.fieldOrder.includes(u.code)&&L("NATIVE_DATA_VIEW_CREATE_REQUIRED_FIELD_MISSING",`${c}/form/fieldOrder`)})}function jo(e,t,o){if(e.type==="serial-number"||t.system===!0)return!1;let n=t[`${o}Capabilities`];return Array.isArray(n)&&n.length>0}function Ms(e,t,o){let n=ne(e,o);Ie(n,Oe.field,o),he(n.label,`${o}/label`,500),n.type!==t.type&&L("NATIVE_DATA_SURFACE_FIELD_TYPE_MISMATCH",`${o}/type`);let i=he(n.widget,`${o}/widget`,64);xs[t.type].includes(i)||L("NATIVE_DATA_SURFACE_WIDGET_INCOMPATIBLE",`${o}/widget`),Ks(n.section,`${o}/section`,255);for(let s of["requiredHint","system","hidden","list","searchable","sortable"])vn(n[s],`${o}/${s}`);n.searchable===!0&&!Vt(t.type)&&L("NATIVE_DATA_SURFACE_SEARCH_UNSUPPORTED",`${o}/searchable`),n.sortable===!0&&!Je(t.type)&&L("NATIVE_DATA_SURFACE_SORT_UNSUPPORTED",`${o}/sortable`);for(let s of["readCapabilities","createCapabilities","updateCapabilities"])ze(n[s],`${o}/${s}`,100,!0);if(n.maxCount!==void 0&&(!Number.isSafeInteger(n.maxCount)||Number(n.maxCount)<1||Number(n.maxCount)>100)&&L("NATIVE_DATA_SURFACE_MAX_COUNT_INVALID",`${o}/maxCount`),n.maxSizeMb!==void 0&&(!Number.isSafeInteger(n.maxSizeMb)||Number(n.maxSizeMb)<1||Number(n.maxSizeMb)>1024)&&L("NATIVE_DATA_SURFACE_MAX_SIZE_INVALID",`${o}/maxSizeMb`),n.accept!==void 0){let s=Array.isArray(n.accept)?n.accept:[n.accept];ze(s,`${o}/accept`,50,!1)}for(let s of["maxLength","precision","scale","exactDecimal","min","max","rangeBoundary","options","source","timePrecision","serial","subtable"])Us(n,t,s,o);Bs(n,t,o)}function Ws(e,t,o){if(e===void 0)return;let n=ne(e,o);if(Ie(n,Oe.list,o),n.actions!==void 0){let i=ne(n.actions,`${o}/actions`);Ie(i,["import","export"],`${o}/actions`);for(let s of["import","export"])i[s]!==void 0&&typeof i[s]!="boolean"&&L("NATIVE_DATA_SURFACE_LIST_ACTION_INVALID",`${o}/actions/${s}`)}if(n.fieldOrder!==void 0)for(let i of ze(n.fieldOrder,`${o}/fieldOrder`,500,!0))t.has(i)||L("NATIVE_DATA_SURFACE_LIST_FIELD_INVALID",`${o}/fieldOrder`);n.defaultPageSize!==void 0&&(!Number.isSafeInteger(n.defaultPageSize)||Number(n.defaultPageSize)<1||Number(n.defaultPageSize)>200)&&L("NATIVE_DATA_SURFACE_PAGE_SIZE_INVALID",`${o}/defaultPageSize`);for(let[i,s]of[["searchableFields",Vt],["filterFields",$n]]){if(n[i]===void 0)continue;let c=ze(n[i],`${o}/${i}`,100,!0);for(let r of c){let a=t.get(r);(!a||!s(a.type))&&L("NATIVE_DATA_SURFACE_LIST_FIELD_INVALID",`${o}/${i}`)}}if(n.defaultSort!==void 0){let i=ne(n.defaultSort,`${o}/defaultSort`);Ie(i,Oe.defaultSort,`${o}/defaultSort`);let s=he(i.field,`${o}/defaultSort/field`,63),c=t.get(s);!Rn(s)&&(!c||!Je(c.type))&&L("NATIVE_DATA_SURFACE_SORT_UNSUPPORTED",`${o}/defaultSort/field`),i.order!==void 0&&!["asc","desc"].includes(i.order)&&L("NATIVE_DATA_SURFACE_SORT_ORDER_INVALID",`${o}/defaultSort/order`)}}function xo(e,t,o,n){if(e===void 0)return;let i=ne(e,o);if(Ie(i,Oe[n],o),i.layout!==void 0&&!["flat","sections"].includes(i.layout)&&L("NATIVE_DATA_SURFACE_LAYOUT_INVALID",`${o}/layout`),i.fieldOrder!==void 0){let s=`${o}/fieldOrder`;(!Array.isArray(i.fieldOrder)||i.fieldOrder.length>t.size||i.fieldOrder.length>Ls)&&L("NATIVE_DATA_SURFACE_FIELD_ORDER_INVALID",s);let c=i.fieldOrder.map((r,a)=>he(r,`${s}/${a}`,63));new Set(c).size!==c.length&&L("NATIVE_DATA_SURFACE_FIELD_ORDER_INVALID",s),c.forEach((r,a)=>{t.has(r)||L("NATIVE_DATA_SURFACE_FIELD_ORDER_FIELD_MISSING",`${s}/${a}`)})}n==="form"&&kn(i.draftState,`${o}/draftState`)}function Us(e,t,o,n){e[o]===void 0&&t[o]===void 0||((e[o]===void 0||t[o]===void 0)&&L("NATIVE_DATA_SURFACE_FIELD_PROJECTION_MISMATCH",`${n}/${o}`),ee(e[o])!==ee(t[o])&&L("NATIVE_DATA_SURFACE_FIELD_PROJECTION_MISMATCH",`${n}/${o}`))}function Bs(e,t,o){let n=t.file||{},i={...e.maxCount===void 0?{}:{maxCount:e.maxCount},...e.maxSizeMb===void 0?{}:{maxSizeMb:e.maxSizeMb},...e.accept===void 0?{}:{accept:Fn(e.accept)}};for(let s of["maxCount","maxSizeMb","accept"]){if(i[s]===void 0&&n[s]===void 0)continue;(i[s]===void 0||n[s]===void 0)&&L("NATIVE_DATA_SURFACE_FIELD_PROJECTION_MISMATCH",`${o}/${s}`);let c=s==="accept"?Fn(i[s]):i[s],r=s==="accept"?Fn(n[s]):n[s];ee(c)!==ee(r)&&L("NATIVE_DATA_SURFACE_FIELD_PROJECTION_MISMATCH",`${o}/${s}`)}}function Fn(e){return(Array.isArray(e)?[...e]:[e]).sort((t,o)=>{let n=String(t),i=String(o);return n===i?0:n<i?-1:1})}function ze(e,t,o,n){(!Array.isArray(e)||!n&&e.length===0||e.length>o)&&L("NATIVE_DATA_SURFACE_STRING_ARRAY_INVALID",t);let i=e.map((s,c)=>he(s,`${t}/${c}`,255));return new Set(i).size!==i.length&&L("NATIVE_DATA_SURFACE_STRING_ARRAY_INVALID",t),i}function ne(e,t){return(!e||typeof e!="object"||Array.isArray(e))&&L("NATIVE_OBJECT_REQUIRED",t),e}function Ie(e,t,o){let n=new Set(t);for(let i of Object.keys(e))n.has(i)||L("NATIVE_PROPERTY_UNKNOWN",`${o}/${i}`)}function he(e,t,o){return(typeof e!="string"||e.length===0||e.length>o)&&L("NATIVE_STRING_INVALID",t),e}function Ks(e,t,o){e!==void 0&&(typeof e!="string"||e.length>o)&&L("NATIVE_STRING_INVALID",t)}function vn(e,t){e!==void 0&&typeof e!="boolean"&&L("NATIVE_BOOLEAN_REQUIRED",t)}function L(e,t){throw new me(e,t)}var Ye=class extends Error{constructor(o,n){super(`${o}: ${n}`);this.pointer=o;this.reason=n}pointer;reason;code="NATIVE_MANAGED_CONCURRENCY_INVALID"};function Pn(e,t,o){if(e===void 0)return;let n=(p,g)=>{throw new Ye(p,g)},i=(p,g,O)=>((!p||typeof p!="object"||Array.isArray(p)||Object.keys(p).some(y=>!O.includes(y)))&&n(g,"object contains unsupported properties"),p),s=(p,g,O,y)=>{(!Number.isSafeInteger(p)||p<g||p>O)&&n(y,`expected integer ${g}..${O}`)},c=(p,g)=>{(typeof p!="string"||!/^[a-z][a-z0-9_-]{0,63}$/.test(p))&&n(g,"invalid code")},r=(p,g,O)=>((!Array.isArray(p)||p.length>g)&&n(O,"array exceeds bound"),p),a=(p,g)=>{let O=t.find(y=>y.code===p);return O||n(g,"unknown resource"),O},d=(p,g,O)=>{let y=p.schema.fields.find(T=>T.code===g);return!y&&g!=="id"&&n(O,"unknown field"),y},u=(p,g,O=!1)=>{i(p,g,Object.keys(p||{})),Object.keys(p).length>8&&n(g,"at most eight parameters");for(let[y,T]of Object.entries(p))if(c(y,g),i(T,g,["type","values","minimum","maximum","minLength","maxLength"]),T.type==="uuid")Object.keys(T).length!==1&&n(g,"uuid has no options");else if(O&&T.type==="boolean")i(T,g,["type"]);else if(O&&T.type==="string"&&T.values===void 0)i(T,g,["type","minLength","maxLength"]),s(T.maxLength,1,256,g),T.minLength!==void 0&&s(T.minLength,0,T.maxLength,g);else if(T.type==="string"){i(T,g,["type","values"]);let h=r(T.values,100,g);(!h.length||h.some(D=>typeof D!="string"||D.length>128)||new Set(h).size!==h.length)&&n(g,"finite string values required")}else T.type==="integer"?(i(T,g,["type","minimum","maximum"]),s(T.minimum,0,1e6,g),s(T.maximum,T.minimum,T.minimum+1e3,g)):n(g,"unsupported parameter type")},l=(p,g,O,y=!1)=>{i(p,O,["from","key","value"]),!(p.from==="input"&&Object.keys(p).length===2&&Object.hasOwn(g,p.key))&&((p.from==="actor"||y&&p.from==="allocation")&&Object.keys(p).length===1||p.from==="literal"&&Object.keys(p).length===2&&Object.hasOwn(p,"value")&&(p.value===null||["string","boolean"].includes(typeof p.value)||typeof p.value=="number"&&Number.isFinite(p.value))&&JSON.stringify(p.value).length<=512||n(O,"invalid binding"))},f=(p,g,O)=>{l(p,g,O),!(p.from==="input"&&g[p.key].type==="uuid")&&(p.from==="literal"&&typeof p.value=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(p.value)||n(O,"record and allocation identifiers require a UUID binding"))},A=(p,g,O)=>{l(p,g,O),!(p.from==="input"&&g[p.key].type==="integer"&&g[p.key].minimum>=1)&&(p.from==="literal"&&Number.isSafeInteger(p.value)&&p.value>=1||n(O,"expectedRevision requires a positive integer binding"))},N="/data/concurrency";JSON.stringify(e).length>131072&&n(N,"declaration exceeds 128 KiB");let I=i(e,N,["version","admission","reads","quotas","commands"]);I.version!==1&&n(N,"unsupported version"),i(I.admission,N,["perSecond","burst","maxInFlight"]),s(I.admission.perSecond,1,1e3,N),s(I.admission.burst,1,1e3,N),s(I.admission.maxInFlight,1,1e3,N);let m=(p,g)=>{let O=new Set;for(let y of p)c(y?.code,g),O.has(y.code)&&n(g,"duplicate code"),O.add(y.code)};m(r(I.reads,32,N),N),m(r(I.quotas,16,N),N),m(r(I.commands,32,N),N);for(let p of I.reads){let g=`${N}/reads/${p.code}`;i(p,g,["code","resourceCode","parameters","select","where","limit","scope","freshSeconds","staleSeconds","maxKeys","sourcePerSecond","dependencies"]);let O=a(p.resourceCode,g);u(p.parameters,g),["subject","application"].includes(p.scope)||n(g,"invalid cache scope"),p.scope==="application"&&O.dataPolicyCode&&n(g,"shared cache cannot bypass a row policy");let y=r(p.select,32,g);y.length||n(g,"select required"),y.forEach(h=>d(O,h,g));let T=r(p.dependencies,64,g);T.forEach(h=>d(O,h,g));for(let h of r(p.where||[],8,g))i(h,g,["field","value"]),d(O,h.field,g),l(h.value,p.parameters,g),p.scope==="application"&&h.value.from==="actor"&&n(g,"actor requires subject cache"),T.includes(h.field)||n(g,"filter dependency missing");y.some(h=>!T.includes(h))&&n(g,"selected field dependency missing"),s(p.limit,1,100,g),s(p.freshSeconds,1,300,g),s(p.staleSeconds,0,300,g),s(p.maxKeys,1,1e4,g),s(p.sourcePerSecond,1,20,g)}for(let p of I.quotas){let g=`${N}/quotas/${p.code}`;i(p,g,["code","sourceResource","capacityField","allocationResource","allocationField","reservationSeconds"]);let O=a(p.sourceResource,g),y=a(p.allocationResource,g);d(O,p.capacityField,g)?.type!=="number.integer"&&n(g,"capacity must be an integer"),(d(y,p.allocationField,g)?.type!=="uuid"||d(y,p.allocationField,g)?.nullable!==!1)&&n(g,"allocation reference must be a uuid"),y.surface?.mutationOwner!=="queued-command"&&n(g,"allocation model must be command owned"),p.reservationSeconds!==void 0&&s(p.reservationSeconds,10,86400,g)}new Set(I.quotas.map(p=>p.allocationResource)).size!==I.quotas.length&&n(N,"an allocation model has exactly one pool owner");for(let p of I.commands){let g=`${N}/commands/${p.code}`;i(p,g,["code","mode","intake","execution","capability","parameters","resourceKey","admission","deadlineSeconds","guards","operations","quota"]),p.mode!==void 0&&!["permit","durable"].includes(p.mode)&&n(g,"unsupported mode");let O=p.mode==="durable";if(u(p.parameters,g,O),l(p.resourceKey,p.parameters,g),o.some(y=>y.code===p.capability)||n(g,"command capability must be declared"),i(p.admission,g,["perSecond","burst","maxInFlight","maxQueue","maxWaitSeconds","permitSeconds"]),s(p.admission.perSecond,1,I.admission.perSecond,g),s(p.admission.burst,1,I.admission.burst,g),s(p.admission.maxInFlight,1,I.admission.maxInFlight,g),s(p.admission.maxQueue,1,1e4,g),s(p.admission.maxWaitSeconds,1,3600,g),(!O||p.admission.permitSeconds!==void 0)&&s(p.admission.permitSeconds,5,60,g),s(p.deadlineSeconds,10,3600,g),O){(p.operations!==void 0||p.guards!==void 0||p.quota!==void 0)&&n(g,"backend-plan does not accept static operations, guards or quota"),i(p.intake,g,["perSecond","burst","maxInFlight"]);for(let h of["perSecond","burst","maxInFlight"])s(p.intake[h],1,1e3,g);let y=i(p.execution,g,["kind","handlerCode","timeoutMs","resources","directory"]);y.kind!=="backend-plan"&&n(g,"durable requires backend-plan"),c(y.handlerCode,g),s(y.timeoutMs,100,3e4,g);let T=r(y.resources,32,g);T.length||n(g,"execution resources required"),new Set(T.map(h=>h.resourceCode)).size!==T.length&&n(g,"duplicate execution resource");for(let h of T){i(h,g,["resourceCode","readFields","writeOperations","writeFields"]);let D=a(h.resourceCode,g);for(let k of["readFields","writeFields"]){let U=r(h[k],64,g);new Set(U).size!==U.length&&n(g,"duplicate field"),U.forEach(j=>{k==="readFields"&&yn.has(j)||d(D,j,g)})}let F=r(h.writeOperations,3,g);(new Set(F).size!==F.length||F.some(k=>!["create","update","increment"].includes(k)))&&n(g,"unsupported execution operation"),h.writeFields.some(k=>["id","revision","created_by","updated_by","created_at","updated_at"].includes(k))&&n(g,"record metadata is platform owned"),!F.length&&h.writeFields.length&&n(g,"write fields require an operation"),F.length&&!h.writeFields.length&&n(g,"write operations require fields"),I.quotas.some(k=>k.allocationResource===h.resourceCode)&&F.length&&n(g,"allocation references remain owned by their pool command")}if(y.directory!==void 0){i(y.directory,g,["mode","fields"]),y.directory.mode!=="current-initiator"&&n(g,"only current initiator allowed");let h=r(y.directory.fields,4,g);(!h.length||new Set(h).size!==h.length||h.some(D=>!["displayName","employeeNumber","primaryDepartment","departments"].includes(D)))&&n(g,"unsupported directory fields")}continue}(p.execution!==void 0||p.intake!==void 0)&&n(g,"execution and intake require durable mode");for(let y of r(p.guards||[],8,g)){i(y,g,["resourceCode","id","conditions"]);let T=a(y.resourceCode,g);f(y.id,p.parameters,g);for(let h of r(y.conditions,16,g)){i(h,g,["kind","field","operator","value"]);let D=d(T,h.field,g);["eq","neq","lt","lte","gt","gte"].includes(h.operator)||n(g,"unsupported guard"),h.kind==="database-now"?(D?.type!=="datetime"||!["lt","lte","gt","gte"].includes(h.operator)||h.value!==void 0)&&n(g,"database-now requires datetime and an ordering operator"):(h.kind!==void 0&&h.kind!=="value"&&n(g,"unsupported condition kind"),l(h.value,p.parameters,g))}}for(let y of r(p.operations,8,g)){i(y,g,["operation","resourceCode","id","expectedRevision","data"]);let T=a(y.resourceCode,g);T.surface?.mutationOwner!=="queued-command"&&n(g,"command mutations require command owned models");let h=I.quotas.find(D=>D.allocationResource===y.resourceCode);h&&(y.operation==="create"?p.quota?.action!=="allocate"||p.quota.pool!==h.code:Object.hasOwn(y.data||{},h.allocationField))&&n(g,"allocation references are owned by their pool command"),["create","update"].includes(y.operation)||n(g,"unsupported operation"),y.operation==="update"?(f(y.id,p.parameters,g),A(y.expectedRevision,p.parameters,g)):(y.id!==void 0||y.expectedRevision!==void 0)&&n(g,"create has no caller supplied id/revision"),i(y.data,g,Object.keys(y.data||{})),Object.keys(y.data).length>32&&n(g,"too many fields");for(let[D,F]of Object.entries(y.data))D==="id"&&n(g,"record identifiers are platform owned"),d(T,D,g),l(F,p.parameters,g,p.quota?.action==="allocate")}if(p.quota){let y=i(p.quota,g,["pool","action","units","mode","allocation"]),T=I.quotas.find(h=>h.code===y.pool);T||n(g,"unknown quota pool"),f(p.resourceKey,p.parameters,g),y.action==="allocate"?(i(y,g,["pool","action","units","mode"]),s(y.units,1,1e3,g),(!["committed","reserved"].includes(y.mode)||y.mode==="reserved"&&!T.reservationSeconds)&&n(g,"invalid allocation mode"),(p.operations.length!==1||p.operations[0].operation!=="create"||p.operations[0].resourceCode!==T.allocationResource||p.operations[0].data[T.allocationField]?.from!=="allocation")&&n(g,"allocation must atomically create its bound business record")):["confirm","release"].includes(y.action)?(i(y,g,["pool","action","allocation"]),f(y.allocation,p.parameters,g),p.operations.length&&n(g,"lifecycle owns allocation state; business reference remains immutable")):n(g,"invalid quota action")}else p.operations.length||n(g,"operations required")}let E=I.commands.filter(p=>p.mode==="durable").map(p=>p.execution.handlerCode);return new Set(E).size!==E.length&&n(N,"handler code must be unique"),JSON.parse(JSON.stringify(I))}var Fe=class extends Error{constructor(o,n){super(`\u91D1\u989D\u751F\u547D\u5468\u671F\u58F0\u660E\u65E0\u6548\uFF1A${n}\uFF08${o}\uFF09`);this.pointer=o;this.reason=n}pointer;reason;code="NATIVE_DECIMAL_LIFECYCLE_INVALID"},jn=["parentTransitions","childTransitions","fulfilledChildStatuses","lockedParentStatuses"],Mo=["amountFieldCode","currencyFieldCode","relationFieldCode","parentFieldCode","rootFieldCode","statusFieldCode","parentRelationValue","childRelationValue"],xt=e=>!!(e&&typeof e=="object"&&!Array.isArray(e)),Lt=e=>Array.isArray(e)?e.filter(xt):[],Ne=(e,t)=>{throw new Fe(e,t)},Ln=e=>typeof e=="string"&&/^[A-Za-z0-9._:-]{1,128}$/.test(e),xn=(e,t)=>e<t?-1:e>t?1:0;function jt(e,t="/decimalReservationLifecycle"){if(e===void 0)return;if(!xt(e)||Object.keys(e).some(i=>!jn.includes(i))||jn.some(i=>!Object.prototype.hasOwnProperty.call(e,i)))return Ne(t,"\u5FC5\u987B\u5B8C\u6574\u58F0\u660E\u56DB\u9879\u89C4\u5219\uFF0C\u4E0D\u80FD\u5305\u542B\u672A\u77E5\u5C5E\u6027");let o=i=>{let s=e[i];if(!Array.isArray(s)||s.length>64)return Ne(`${t}/${i}`,"\u72B6\u6001\u8FB9\u6700\u591A 64 \u6761");let c=new Set;return s.map((r,a)=>{let d=`${t}/${i}/${a}`;if(!xt(r)||Object.keys(r).some(l=>l!=="from"&&l!=="to")||!Ln(r.from)||!Ln(r.to)||r.from===r.to)return Ne(d,"\u72B6\u6001\u8FB9\u5FC5\u987B\u5305\u542B\u4E0D\u540C\u7684\u6709\u6548 from/to");let u=JSON.stringify([r.from,r.to]);return c.has(u)?Ne(d,"\u72B6\u6001\u8FB9\u4E0D\u80FD\u91CD\u590D"):(c.add(u),{from:r.from,to:r.to})}).sort((r,a)=>xn(r.from,a.from)||xn(r.to,a.to))},n=i=>{let s=e[i];return!Array.isArray(s)||s.length<1||s.length>16||s.some(c=>!Ln(c))||new Set(s).size!==s.length?Ne(`${t}/${i}`,"\u72B6\u6001\u96C6\u5408\u5FC5\u987B\u5305\u542B 1 \u5230 16 \u4E2A\u4E0D\u91CD\u590D\u7684\u6709\u6548\u72B6\u6001"):[...s].sort(xn)};return{parentTransitions:o("parentTransitions"),childTransitions:o("childTransitions"),fulfilledChildStatuses:n("fulfilledChildStatuses"),lockedParentStatuses:n("lockedParentStatuses")}}function Mn(e,t,o="/config/data/resources"){Lt(e).forEach((n,i)=>{let s=`${o}/${i}/decimalReservationLifecycle`,c=jt(n.decimalReservationLifecycle,s);if(!c)return;let r=Lt(t).map(l=>l.platformAccess?.decimalReservation).filter(l=>xt(l)&&l.resourceCode===n.code),a=r.find(l=>l.mode==="reserve");if(!a)return Ne(s,"\u9700\u8981\u540C\u8D44\u6E90\u5DF2\u58F0\u660E\u7684 reserve \u52A8\u4F5C\u6620\u5C04");if(Mo.some(l=>typeof a[l]!="string")||r.some(l=>Mo.some(f=>l[f]!==a[f])))return Ne(s,"\u540C\u8D44\u6E90\u989D\u5EA6\u52A8\u4F5C\u7684\u5B57\u6BB5\u6620\u5C04\u5FC5\u987B\u4E00\u81F4");let d=Lt(n.schema?.fields).find(l=>l.code===a.statusFieldCode);if(d?.type!=="option.single")return Ne(s,"\u989D\u5EA6\u72B6\u6001\u5B57\u6BB5\u5FC5\u987B\u4E3A option.single");let u=new Set(Lt(d.options).map(l=>l.value));for(let l of jn)if((l==="parentTransitions"||l==="childTransitions"?c[l].flatMap(A=>[A.from,A.to]):c[l]).some(A=>!u.has(A)))return Ne(`${s}/${l}`,"\u72B6\u6001\u5FC5\u987B\u6765\u81EA\u989D\u5EA6\u72B6\u6001\u5B57\u6BB5\u7684\u9009\u9879");if(r.some(l=>l.mode==="reserve"&&Array.isArray(l.eligibleParentStatuses)&&l.eligibleParentStatuses.some(f=>c.lockedParentStatuses.includes(String(f)))))return Ne(`${s}/lockedParentStatuses`,"\u9501\u5B9A\u7236\u72B6\u6001\u4E0D\u80FD\u5141\u8BB8\u65B0\u9884\u7559")})}var Uo=require("crypto");var Wn=new Set(["option.single","user.single","department.single","resource-ref.single"]),Gs=new Set(["option.multiple","cascade.single","cascade.multiple","user.multiple","department.multiple","resource-ref.multiple","address","location","json"]),Bo=new Set(["option.multiple","cascade.single","cascade.multiple","user.multiple","department.multiple","resource-ref.multiple","file","image"]),qs=new Set(["option.single","user.single","department.single","resource-ref.single","signature","address","location"]),Js=new Set([...Wn,...Bo,"signature","address","location","json"]);function zs(e,t){let o=new Set([...Array.isArray(t?.list?.searchableFields)?t.list.searchableFields:[],...Object.entries(t?.fields||{}).filter(([,n])=>n?.searchable===!0).map(([n])=>n)]);return e.map(n=>Ko(n,o.has(n.code))).sort((n,i)=>n.code.localeCompare(i.code))}function Ko(e,t=!1){let o=e.type==="date-range"||e.type==="datetime-range";if(o&&e.rangeBoundary!=="closed"&&e.rangeBoundary!=="half-open")throw new Error("OPENXIANGDA_NATIVE_DATA_RANGE_BOUNDARY_INVALID");return{code:e.code,type:e.type,nullable:!0,indexed:e.indexed===!0,storage:sr(e),index:ir(e,t),...o?{rangeBoundary:e.rangeBoundary}:{},...e.type==="serial-number"?{serial:{prefix:e.serial?.prefix||"",digits:e.serial?.digits??6,start:e.serial?.start??1}}:{},...e.type==="subtable"&&e.subtable?{subtable:{resourceCode:e.subtable.resourceCode,foreignKey:e.subtable.foreignKey,orderField:e.subtable.orderField,maxRows:e.subtable.maxRows??20}}:{}}}function Ys(e,t){if(t.type==="subtable")return null;let o=oe(t.code),n=Go(e,t),i=[n?` DEFAULT ${n}`:"",rr(o,t),Xs(o,t)].join("");return`${o} ${t.storage}${i}`}function Hs(e,t){return Go(e,t)}function Xs(e,t){if(t.type!=="date-range"&&t.type!=="datetime-range")return"";if(t.rangeBoundary!=="closed"&&t.rangeBoundary!=="half-open")throw new Error("OPENXIANGDA_NATIVE_DATA_RANGE_BOUNDARY_INVALID");let o=t.type==="datetime-range"&&t.rangeBoundary==="closed";return` CHECK (${e} IS NULL OR (NOT isempty(${e}) AND lower(${e}) IS NOT NULL AND upper(${e}) IS NOT NULL AND lower_inc(${e}) AND ${o?"":"NOT "}upper_inc(${e})))`}function Qs(e){return e.type==="serial-number"||at(e.type)&&e.type!=="subtable"}function Zs(e,t){return t.filter(o=>o.type==="serial-number").map(o=>{let n=Wt(e,o.code),i=o.serial?.start??1;return`CREATE SEQUENCE IF NOT EXISTS ${n} AS bigint MINVALUE ${i} START WITH ${i} CACHE 1`})}function er(e,t){let o=Mt(e);return t.filter(n=>n.type==="serial-number").map(n=>`ALTER SEQUENCE ${Wt(e,n.code)} OWNED BY ${o}.${oe(n.code)}`)}function tr(e,t){return t.filter(o=>o.type==="serial-number").map(o=>`GRANT USAGE, SELECT ON SEQUENCE ${Wt(e,o.code)} TO "openxiangda_data_api"`)}function nr(e,t){let o=Mt(e),n=[];for(let i of t){if(i.type==="subtable")continue;let s=oe(i.code),c=oe(Re("idx",e,i.code,i.index));switch(i.index){case"btree":n.push(`CREATE INDEX IF NOT EXISTS ${c} ON ${o} (${s})`);break;case"btree-snapshot-expressions":{let r=oe(Re("idx",e,i.code,"snapshot-value")),a=oe(Re("idx",e,i.code,"snapshot-label"));n.push(`CREATE INDEX IF NOT EXISTS ${r} ON ${o} ((${s} ->> 'value'))`,`CREATE INDEX IF NOT EXISTS ${a} ON ${o} ((${s} ->> 'label'))`);break}case"gin-jsonb-path":n.push(`CREATE INDEX IF NOT EXISTS ${c} ON ${o} USING GIN (${s} jsonb_path_ops)`);break;case"gist-range":n.push(`CREATE INDEX IF NOT EXISTS ${c} ON ${o} USING GIST (${s})`);break;case"gin-trigram":{let r=Wn.has(i.type)?`((${s} ->> 'label')) gin_trgm_ops`:`${s} gin_trgm_ops`;n.push(`CREATE INDEX IF NOT EXISTS ${c} ON ${o} USING GIN (${r})`);break}case"none":break}if(i.type==="serial-number"){let r=oe(Re("uidx",e,i.code,"serial"));n.push(`CREATE UNIQUE INDEX IF NOT EXISTS ${r} ON ${o} (${s})`)}}return n}function or(e,t,o,n){let i=Mt(e),s=Mt(t),c=oe(Re("uidx",e,"environment_id","subtable-parent")),r=oe(Re("idx",t,o,n,"subtable-child")),a=oe(Re("fk",t,o,e)),d=oe(o),u=oe(n);return[`CREATE UNIQUE INDEX IF NOT EXISTS ${c} ON ${i} ("tenant_id", "app_code", "environment_key", "id")`,`CREATE INDEX IF NOT EXISTS ${r} ON ${s} ("tenant_id", "app_code", "environment_key", ${d}, ${u}, "id")`,`DO $native_subtable$ BEGIN
|
|
2
|
+
ALTER TABLE ${s}
|
|
3
3
|
ADD CONSTRAINT ${a}
|
|
4
|
-
FOREIGN KEY ("tenant_id", "app_code", "environment_key", ${
|
|
5
|
-
REFERENCES ${
|
|
4
|
+
FOREIGN KEY ("tenant_id", "app_code", "environment_key", ${d})
|
|
5
|
+
REFERENCES ${i} ("tenant_id", "app_code", "environment_key", "id")
|
|
6
6
|
ON DELETE CASCADE;
|
|
7
7
|
EXCEPTION WHEN duplicate_object THEN NULL;
|
|
8
|
-
END $native_subtable$`]}function Te(e,...t){return`${e}_${(0,Ln.createHash)("sha256").update(t.join(":")).digest("hex").slice(0,32)}`}function ne(e){if(!/^[A-Za-z_][A-Za-z0-9_]{0,62}$/.test(e))throw new Error("OPENXIANGDA_NATIVE_IDENTIFIER_INVALID");return`"${e}"`}function Rs(e,t){return e.type==="subtable"?"none":t?"gin-trigram":e.indexed?["date-range","datetime-range"].includes(e.type)?"gist-range":Ht.has(e.type)?"btree-snapshot-expressions":Es.has(e.type)?"gin-jsonb-path":"btree":"none"}function Ss(e){switch(e.type){case"text.short":return`varchar(${e.maxLength??255})`;case"text.long":case"text.rich":return"text";case"number.integer":return"bigint";case"number.decimal":return`numeric(${e.precision??38},${e.scale??10})`;case"boolean":return"boolean";case"date":return"date";case"time":return"time(0)";case"datetime":return"timestamptz";case"date-range":return"daterange";case"datetime-range":return"tstzrange";case"uuid":return"uuid";case"serial-number":return"varchar(255)";case"subtable":return"child-resource";default:return ms.has(e.type),"jsonb"}}function Un(e,t){if(Me(t.type)&&t.type!=="subtable")return"'[]'::jsonb";if(t.type!=="serial-number")return"";let o=Pn(t.serial?.prefix||""),n=t.serial?.digits??6;return`(${o} || lpad(nextval(${Pn(lt(e,t.code))})::text, ${n}, '0'))`}function Ds(e,t){return kn.has(t.type)?` CHECK (${e} IS NULL OR jsonb_typeof(${e}) = 'array')`:As.has(t.type)?` CHECK (${e} IS NULL OR jsonb_typeof(${e}) = 'object')`:""}function dt(e){return`"app_data".${ne(e)}`}function lt(e,t){let o=Te("seq",e,t);return`"app_data".${ne(o)}`}function Pn(e){return`'${e.replace(/'/g,"''")}'`}var Mn=new Set(["option.single","option.multiple","user.single","user.multiple","department.single","department.multiple","resource-ref.single","resource-ref.multiple"]),Vs=new Set([...Mn,"cascade.single","cascade.multiple","file","image","signature","address","location","json"]),jn=/^[A-Za-z][A-Za-z0-9_]{0,62}$/,ws=new Set(["__proto__","prototype","constructor"]),ut=class extends Error{constructor(o){super("OPENXIANGDA_SCOPE_PROJECTION_FIELD_PATH_INVALID");this.path=o;this.name="NativeScopeSourceFieldPathV2Error"}path;code="OPENXIANGDA_SCOPE_PROJECTION_FIELD_PATH_INVALID"};function ve(e,t){let o=Bn(e);if(!o)return null;let n=t.get(o[0]);if(!n)return null;let s=o.slice(1).join(".")||void 0;return{field:n,...s?{valuePath:s}:{}}}function ft(e){return!!(e&&e.field.type==="user.single"&&e.valuePath==="value")}function Xt(e,t,o){if(!e||!t||!vs(e))return!1;let{field:n,valuePath:s}=e;if(!s)return t.valueType==="uuid"?n.type==="uuid":["text.short","text.long","serial-number"].includes(n.type);if(s==="value")return!(t.valueSourceResourceCode&&n.type.startsWith("resource-ref.")&&n.source?.resourceCode!==t.valueSourceResourceCode);let i=s.slice(9),r=o.get(n.source?.resourceCode||"")?.get(i)?.type;return t.valueType==="uuid"?r==="uuid":["text.short","text.long","serial-number"].includes(r||"")}function Fs(e,t){let o=Bn(t);if(!o)throw new ut(String(t||""));let n=e;for(let s of o){if(!n||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,s))return;n=n[s]}return n}function vs(e){let{field:t,valuePath:o}=e;if(!o)return!Vs.has(t.type);if(o==="value")return Mn.has(t.type);if(!o.startsWith("snapshot."))return!1;let n=o.slice(9);return jn.test(n)&&t.type.startsWith("resource-ref.")&&!!t.source?.snapshotFields?.includes(n)}function Bn(e){if(typeof e!="string"||e.length===0||e.length>192)return null;let t=e.split(".");return![1,2,3].includes(t.length)||t.some(o=>!jn.test(o)||ws.has(o))||t.length===2&&t[1]!=="value"||t.length===3&&t[1]!=="snapshot"?null:t}var Ps=new Set(["option.single","user.single","department.single","resource-ref.single"]),Ls=new Set(["text.short","text.long","text.rich","number.integer","number.decimal","boolean","date","time","datetime","uuid","serial-number"]),ks=new Set(["value","label","description","color"]),xs=new Set(["avatarUrl","employeeNo","title","mobile","email"]),Us=new Set(["fullPath","parent.value","parent.label"]),Ms=new Set(["country.value","country.label","province.value","province.label","city.value","city.label","district.value","district.label","street.value","street.label","detail","fullAddress"]),js=new Set(["longitude","latitude","accuracy"]),Bs=new Set(["address","name","province","city","district","source"]);function Js(e){let t=new Map(e.map(o=>[o.code,new Map(o.schema.fields.map(n=>[n.code,n]))]));return e.map(o=>({...o,schema:{...o.schema,fields:o.schema.fields.map(n=>{let s=zs(n,t);if(!Object.keys(s).length)return n;let i={...n};return Object.defineProperty(i,"queryPathTypes",{configurable:!1,enumerable:!1,writable:!1,value:Object.freeze(s)}),i})}}))}function Ws(e,t){if(Ps.has(e.type)&&ks.has(t)||e.type==="user.single"&&xs.has(t)||e.type==="department.single"&&Us.has(t))return Je(t);if(e.type==="resource-ref.single"){let o=e.queryPathTypes?.[t];return o?{parts:t.split("."),type:o}:null}if(e.type==="address"&&Ms.has(t))return Je(t);if(e.type==="location"){if(js.has(t))return{parts:[t],type:"number.decimal"};if(Bs.has(t))return Je(t);if(t==="capturedAt")return{parts:[t],type:"datetime"}}return null}function zs(e,t){if(e.type!=="resource-ref.single"||!e.source)return{};let o=t.get(e.source.resourceCode);return o?Object.fromEntries((e.source.snapshotFields||[]).flatMap(n=>{let s=o.get(n);return s?[[`snapshot.${n}`,Ls.has(s.type)?s.type:"json"]]:[]})):{}}function Je(e){return{parts:e.split("."),type:"text.short"}}var en=["exact-v1","nfkc-space-v1","nfkc-upper-ascii-v1"],xr=256,Pe=class extends Error{constructor(o,n){super(`\u6761\u4EF6\u552F\u4E00\u952E\u58F0\u660E\u65E0\u6548\uFF1A${n}\uFF08${o}\uFF09`);this.pointer=o;this.reason=n}pointer;reason;code="NATIVE_UNIQUE_KEY_INVALID"},Qt=e=>!!(e&&typeof e=="object"&&!Array.isArray(e)),oe=(e,t)=>{throw new Pe(e,t)},pt=(e,t)=>e<t?-1:e>t?1:0,_t=(e,t,o)=>{Object.keys(e).some(n=>!t.includes(n))&&oe(o,"\u4E0D\u652F\u6301\u672A\u77E5\u5C5E\u6027")};function tn(e,t,o="/uniqueKeys"){if(e===void 0)return;if(!Array.isArray(e)||e.length>8)return oe(o,"\u6BCF\u8D44\u6E90\u6700\u591A 8 \u6761\u89C4\u5219");let n=new Map(t.map(i=>[i.code,i])),s=new Set;return e.map((i,c)=>{let r=`${o}/${c}`;if(!Qt(i))return oe(r,"\u89C4\u5219\u5FC5\u987B\u662F\u5BF9\u8C61");if(_t(i,["code","fields","when"],r),typeof i.code!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(i.code)||i.code.length>20||s.has(i.code))return oe(`${r}/code`,"\u9700\u8981\u4E0D\u91CD\u590D\u4E14\u4E0D\u8D85\u8FC7 20 \u5B57\u7B26\u7684 lower-kebab-case \u6807\u8BC6");if(s.add(i.code),!Array.isArray(i.fields)||i.fields.length<1||i.fields.length>4)return oe(`${r}/fields`,"\u5FC5\u987B\u9009\u62E9 1 \u5230 4 \u4E2A\u5B57\u6BB5");let a=new Set,f=i.fields.map((I,l)=>{let E=`${r}/fields/${l}`;if(!Qt(I))return oe(E,"\u5B57\u6BB5\u5FC5\u987B\u662F\u5BF9\u8C61");_t(I,["fieldCode","normalizer"],E);let T=n.get(I.fieldCode);if(!T||!["text.short","uuid","option.single","resource-ref.single"].includes(T.type)||a.has(I.fieldCode))return oe(`${E}/fieldCode`,"\u9700\u8981\u4E0D\u91CD\u590D\u7684\u77ED\u6587\u672C\u3001UUID\u3001\u5355\u9009\u6216\u5355\u8BB0\u5F55\u5F15\u7528\u5B57\u6BB5");a.add(I.fieldCode);let g=I.normalizer===void 0?"exact-v1":I.normalizer;return!en.includes(g)||T.type!=="text.short"&&g!=="exact-v1"?oe(`${E}/normalizer`,"\u5F52\u4E00\u5316\u65B9\u5F0F\u4E0D\u652F\u6301\u6216\u4E0E\u5B57\u6BB5\u7C7B\u578B\u4E0D\u7B26"):{fieldCode:T.code,normalizer:g}}).sort((I,l)=>pt(I.fieldCode,l.fieldCode)),_=i.when===void 0?[]:i.when;if(!Array.isArray(_)||_.length>4)return oe(`${r}/when`,"\u6700\u591A 4 \u4E2A\u5408\u53D6\u6761\u4EF6");let d=new Set,u=_.map((I,l)=>{let E=`${r}/when/${l}`;if(!Qt(I))return oe(E,"\u6761\u4EF6\u5FC5\u987B\u662F\u5BF9\u8C61");let T=n.get(I.fieldCode);if(!T)return oe(`${E}/fieldCode`,"\u5B57\u6BB5\u4E0D\u5B58\u5728");let g;if(I.operator==="empty"||I.operator==="nonempty"){if(_t(I,["fieldCode","operator"],E),T.type!=="text.short")return oe(E,"\u7A7A\u503C\u6761\u4EF6\u4EC5\u652F\u6301\u77ED\u6587\u672C");g={fieldCode:T.code,operator:I.operator}}else if(I.operator==="in"||I.operator==="notIn"){_t(I,["fieldCode","operator","values"],E);let m=new Set((T.options??[]).map(O=>O.value));if(T.type!=="option.single"||!Array.isArray(I.values)||I.values.length<1||I.values.length>16||I.values.some(O=>typeof O!="string"||O.length<1||O.length>128||!m.has(O))||new Set(I.values).size!==I.values.length)return oe(E,"\u96C6\u5408\u6761\u4EF6\u9700\u8981 1 \u5230 16 \u4E2A\u4E0D\u91CD\u590D\u7684\u5DF2\u58F0\u660E\u5355\u9009\u503C");g={fieldCode:T.code,operator:I.operator,values:[...I.values].sort(pt)}}else return oe(`${E}/operator`,"\u53EA\u652F\u6301 empty\u3001nonempty\u3001in \u548C notIn");let A=JSON.stringify(g);return d.has(A)?oe(E,"\u6761\u4EF6\u4E0D\u80FD\u91CD\u590D"):(d.add(A),g)}).sort((I,l)=>pt(JSON.stringify(I),JSON.stringify(l)));return{code:i.code,fields:f,when:u}}).sort((i,c)=>pt(i.code,c.code))}var Zt={type:"string",pattern:"^[A-Za-z_][A-Za-z0-9_]{0,62}$"},Gs={type:"array",maxItems:8,items:{type:"object",additionalProperties:!1,required:["code","fields"],properties:{code:{type:"string",maxLength:20,pattern:"^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$"},fields:{type:"array",minItems:1,maxItems:4,uniqueItems:!0,items:{type:"object",additionalProperties:!1,required:["fieldCode"],properties:{fieldCode:Zt,normalizer:{enum:[...en]}}}},when:{type:"array",maxItems:4,uniqueItems:!0,items:{oneOf:[{type:"object",additionalProperties:!1,required:["fieldCode","operator"],properties:{fieldCode:Zt,operator:{enum:["empty","nonempty"]}}},{type:"object",additionalProperties:!1,required:["fieldCode","operator","values"],properties:{fieldCode:Zt,operator:{enum:["in","notIn"]},values:{type:"array",minItems:1,maxItems:16,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:128}}}}]}}}}};var Jn={"openxiangda.workflow.instance.completed.v2":"commit","openxiangda.workflow.instance.rejected.v2":"release","openxiangda.workflow.instance.withdrawn.v2":"release"};function Wn(e,t){let o=()=>{throw new Error("NATIVE_EVENT_DECIMAL_RESERVATION_INVALID")},n=u=>!u||typeof u!="object"||Array.isArray(u)?o():u,s=n(e);if(Object.keys(s).some(u=>!["resourceCode","workflowCode","outcomes"].includes(u))||typeof s.resourceCode!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(s.resourceCode)||typeof s.workflowCode!="string"||!/^[A-Za-z0-9._:-]{1,128}$/.test(s.workflowCode)||t.execution!==void 0||!Array.isArray(s.outcomes)||!s.outcomes.length||s.outcomes.length>3)return o();let i=t.resources.find(u=>u.code===s.resourceCode),c=t.reservations.find(u=>u.mode==="reserve"&&u.resourceCode===s.resourceCode),r=t.workflows.find(u=>u.code===s.workflowCode);if(!i||!c||!r||r.resourceCode!==i.code)return o();let a=i.fields.find(u=>u.code===c.statusFieldCode);if(a?.type!=="option.single")return o();let f=new Set(a.options?.map(u=>u.value)),_=new Set,d=s.outcomes.map(u=>{let I=n(u),l=I.eventType;return Object.keys(I).some(E=>!["eventType","mode","eligibleChildStatuses"].includes(E))||typeof l!="string"||!Object.prototype.hasOwnProperty.call(Jn,l)||!t.eventTypes.includes(l)||_.has(l)||I.mode!==Jn[l]||!Array.isArray(I.eligibleChildStatuses)||!I.eligibleChildStatuses.length||I.eligibleChildStatuses.length>16||new Set(I.eligibleChildStatuses).size!==I.eligibleChildStatuses.length||I.eligibleChildStatuses.some(E=>typeof E!="string"||!/^[A-Za-z0-9._:-]{1,128}$/.test(E)||!f.has(E))?o():(_.add(l),{eventType:l,mode:I.mode,eligibleChildStatuses:[...I.eligibleChildStatuses].sort()})}).sort((u,I)=>u.eventType.localeCompare(I.eventType));return{resourceCode:s.resourceCode,workflowCode:s.workflowCode,outcomes:d}}function zn(e,t){let o=n=>Array.isArray(n)?n.filter(s=>s&&typeof s=="object"&&!Array.isArray(s)):[];return{eventTypes:Array.isArray(t.eventTypes)?t.eventTypes:[],execution:t.execution,resources:o(e.data?.resources).map(n=>({code:n.code,fields:o(n.schema?.fields).map(s=>({code:s.code,type:s.type,options:o(s.options).map(i=>({value:i.value}))}))})),reservations:o(e.backend?.operations).flatMap(n=>n.platformAccess?.decimalReservation?[n.platformAccess.decimalReservation]:[]),workflows:o(e.workflows?.definitions).map(n=>({code:n.definition?.code,resourceCode:n.definition?.subject?.resourceCode}))}}var Et=class extends Error{constructor(o,n){super(n);this.pointer=o}pointer;code="NATIVE_EVENT_ACTION_INVALID"};function nn(e,t,o="/events/subscriptions"){if(e.execution===void 0)return;let n=(E,T)=>{throw new Et(`${o}${E}`,T)},s=(E,T,g)=>((!E||typeof E!="object"||Array.isArray(E)||Object.keys(E).some(A=>!g.includes(A)))&&n(T,"Invalid action object or unsupported property"),E),i=s(e.execution,"/execution",["kind","version","operations"]);(i.kind!=="native-data"||i.version!==1)&&n("/execution","Expected native-data version 1"),e.platformAccess&&n("/platformAccess","Native actions do not use application runtime capabilities"),(!Array.isArray(e.eventTypes)||!e.eventTypes.length||e.eventTypes.some(E=>!/^openxiangda\.data\.record\.(created|updated|deleted)\.v2$/.test(E)))&&n("/eventTypes","Native data actions require declared data events");let c=e.filter?.resourceCodes;(!Array.isArray(c)||!c.length||c.length>20)&&n("/filter/resourceCodes","Native actions require explicit source resources");let r=new Map(t.map(E=>[E.code,E])),a=c.map(E=>{let T=r.get(E);return T||n("/filter/resourceCodes","Unknown source resource"),new Set((T.schema?.fields||[]).map(g=>g.code))}),f=new Set(e.payload?.fields||[]),_=e.payload?.includeChanges===!0,d=(E,T)=>{let g=s(E,T,["source","path","value"]);if(g.source==="literal"){(!Object.hasOwn(g,"value")||Object.hasOwn(g,"path"))&&n(T,"Literal binding requires only value");let C;try{C=JSON.stringify(g.value)}catch{n(T,"Literal must be JSON")}return(C===void 0||Buffer.byteLength(C)>65536)&&n(T,"Literal is too large or not JSON"),{source:"literal",value:JSON.parse(C)}}(g.source!=="event"||typeof g.path!="string"||Object.hasOwn(g,"value"))&&n(T,"Expected a literal or event binding");let A=g.path.split(".");(A.length>8||A.some(C=>!/^[A-Za-z0-9_-]+$/.test(C)||["__proto__","prototype","constructor"].includes(C)))&&n(T,"Invalid event path");let m=/^data\.projection\.([A-Za-z][A-Za-z0-9_]{0,62})$/.exec(g.path),O=/^data\.changes\.([A-Za-z][A-Za-z0-9_]{0,62})\.(before|after)$/.exec(g.path);if(m||O){let C=(m||O)[1];a.some(b=>!b.has(C))&&n(T,"Source field must exist on every filtered resource"),f.add(C),O&&(_=!0)}else["id","time","type","subject","data.recordId","data.revision","data.operation","data.resourceCode"].includes(g.path)||n(T,"Event path is not part of the data event contract");return{source:"event",path:g.path}};(!Array.isArray(i.operations)||i.operations.length<1||i.operations.length>16)&&n("/execution/operations","Expected 1 to 16 operations");let u={},I=i.operations.map((E,T)=>{let g=`/execution/operations/${T}`,A=s(E,g,["operation","resourceCode","data","id","expectedRevision"]);["create","update","delete"].includes(A.operation)||n(g,"Unsupported Native operation");let m=r.get(A.resourceCode);m||n(g,"Unknown action target resource");let O=new Map((m.schema?.fields||[]).map(b=>[b.code,b])),C=A.data===void 0?{}:s(A.data,`${g}/data`,[...O.keys()]);return Object.keys(C).length>32&&n(g,"Maximum 32 mapped fields per operation"),A.operation==="create"&&(A.id!==void 0||A.expectedRevision!==void 0)&&n(g,"Create does not accept id or expectedRevision"),A.operation==="delete"&&A.data!==void 0&&n(g,"Delete does not accept data"),Object.keys(C).some(b=>O.get(b)?.type==="serial-number")&&n(g,"Generated fields cannot be assigned"),u[A.resourceCode]=ee(m),{operation:A.operation,resourceCode:A.resourceCode,...A.operation==="create"?{}:{id:d(A.id,`${g}/id`),expectedRevision:d(A.expectedRevision,`${g}/expectedRevision`)},...A.operation==="delete"?{}:{data:Object.fromEntries(Object.entries(C).map(([b,y])=>[b,d(y,`${g}/data/${b}`)]))}}});(f.size>32||[...f].some(E=>a.some(T=>!T.has(E))))&&n("/payload/fields","Payload must contain at most 32 declared source fields");let l={kind:"native-data",version:1,operations:I,resourceDigests:u};return Buffer.byteLength(JSON.stringify(l))>65536&&n("/execution","Action plan exceeds 64 KiB"),{execution:{...l,digest:ee(l)},payload:{includeChanges:_,fields:[...f].sort()}}}function be(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function sn(e,t){if(e?.instanceCommands===void 0)return[];let o=be(e.instanceCommands);if(!o||!Object.keys(o).length||Object.keys(o).some(s=>!["withdraw","terminate"].includes(s)))return["WORKFLOW_INSTANCE_COMMAND_POLICIES_INVALID"];let n=[];for(let[s,i]of Object.entries(o)){let c=be(i),r=s==="withdraw"?["beforeFact"]:["beforeFact","capability"];if(!c||Object.keys(c).some(a=>!r.includes(a))){n.push(`WORKFLOW_INSTANCE_COMMAND_POLICY_INVALID:${s}`);continue}if(s==="terminate"){let a=c.capability;(typeof a!="string"||a.length>255||!/^app:[a-z][a-z0-9]*(?:-[a-z0-9]+)*:[A-Za-z0-9:._-]+$/.test(a)||t&&(!a.startsWith(`app:${t.appCode}:`)||!t.capabilities.includes(a)))&&n.push("WORKFLOW_INSTANCE_TERMINATE_CAPABILITY_INVALID")}if(s==="withdraw"||c.beforeFact!==void 0){let a=c.beforeFact,f=be(e.inputSchema),_=be(be(f?.properties)?.[a]),d=be(be(e.subject)?.factProjection)?.[a],u=t?.fields.get(d);(typeof a!="string"||!/^[A-Za-z][A-Za-z0-9_]{0,62}$/.test(a)||!Array.isArray(f?.required)||!f.required.includes(a)||_?.type!=="string"||_?.format!=="date-time"||typeof d!="string"||t&&(u?.type!=="datetime"||u.nullable===!0))&&n.push(`WORKFLOW_INSTANCE_COMMAND_DEADLINE_FACT_INVALID:${s}`)}}return n}function qs(e,t){let o=e?.terminate?.capability;return typeof o=="string"&&/^app:[a-z][a-z0-9]*(?:-[a-z0-9]+)*:[A-Za-z0-9:._-]+$/.test(o)&&t.includes(o)}function on(e){if(typeof e!="string")return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?(Z|[+-]\d{2}:\d{2})$/.exec(e);if(!t)return null;let[,o,n,s,i,c,r]=t,a=t[8],f=new Date(Date.UTC(Number(o),Number(n),0)).getUTCDate();if(Number(n)<1||Number(n)>12||Number(s)<1||Number(s)>f||Number(i)>23||Number(c)>59||Number(r)>59||a!=="Z"&&(Number(a.slice(1,3))>23||Number(a.slice(4))>59))return null;let _=Date.parse(e);return Number.isFinite(_)?_:null}function Ys(e,t,o,n){let s=e?.[t];if(!s||t==="terminate"&&s.beforeFact===void 0)return null;let i=s.beforeFact,c=be(o),r=i&&c&&Object.hasOwn(c,i)?on(c[i]):null,a=n instanceof Date?n.getTime():on(n);return r===null||a===null||!Number.isFinite(a)?"WORKFLOW_V2_CANCELLATION_DEADLINE_INVALID":a<r?null:"WORKFLOW_V2_CANCELLATION_DEADLINE_PASSED"}var Tt=Lo(require("crypto"),1);var Gn="native-4",qn={"application-native-2":"1.0.0","authz.native-batch-explain":"1.0.0","authz.native-management":"1.0.0","deployment.durable-runs":"1.0.0","deployment.platform-executor":"1.0.0","environment.on-demand-production":"1.0.0","environment.runtime-lifecycle":"1.0.0","data-api-v2":"1.1.0","data.native-golden-crud":"1.0.0","data.audit-read-access":"1.0.0","data.managed-files":"1.1.0","data.decimal-reservations":"1.1.0","data.decimal-reservation-lifecycle":"1.0.0","data.unique-keys":"1.0.0","data.managed-concurrency":"1.0.0","data.managed-concurrency.durable":"1.0.0","workflow.named-input-sources":"1.0.0","directory-v2":"1.0.0","directory.selected-user":"1.0.0","events-v2":"1.0.0","events.durable-receipts":"1.0.0","events.capture-policy":"1.0.0","events.native-data-actions":"1.0.0","workflow-kernel-v2":"1.0.0","workflow.instance-cancellation-policy":"1.0.0","business-process.durable-command":"1.1.0","workflow.fresh-command-token":"1.0.0","notification-hub-v2":"1.0.0","authentication.application-login-surface":"1.0.0","public-access.anonymous-owner-records":"1.0.0"};var zr=5,Gr=20,qr=50,Yr=50,Kr=100,Le=class extends Error{constructor(o,n){super(o);this.code=o;this.pointer=n;this.name="NativeDataPolicyExpressionV2Error"}code;pointer};function ze(e,t){let o=[],n=(s,i,c)=>{c>5&&We("NATIVE_DATA_POLICY_EXPRESSION_DEPTH_EXCEEDED",i);let r=Yn(s,i),a=["allOf","anyOf"].filter(d=>d in r);if(a.length===0){o.push({rule:r,pointer:i}),o.length>50&&We("NATIVE_DATA_POLICY_EXPRESSION_LEAVES_EXCEEDED",i);return}let f=a[0],_=r[f];(a.length!==1||Object.keys(r).length!==1||!Array.isArray(_)||_.length<1||_.length>20)&&We("NATIVE_DATA_POLICY_EXPRESSION_GROUP_INVALID",i),_.forEach((d,u)=>n(d,`${i}/${f}/${u}`,c+1))};return n(e,t,1),o}function an(e,t){ze(e,t);let o=(n,s)=>{let i=Yn(n,s);if(Array.isArray(i.allOf))return rn(i.allOf.flatMap((c,r)=>o(c,`${s}/allOf/${r}`)),s);if(Array.isArray(i.anyOf)){let c=[[]];return i.anyOf.forEach((r,a)=>{let f=o(r,`${s}/anyOf/${a}`);c=rn(c.flatMap(_=>f.map(d=>[..._,...d])),s)}),c}return[[i]]};return rn(o(e,t),t)}function rn(e,t){let o=e.reduce((n,s)=>n+s.length,0);return(e.length>50||o>100)&&We("NATIVE_DATA_POLICY_EXPRESSION_EXPANSION_EXCEEDED",t),e}function Yn(e,t){return(!e||typeof e!="object"||Array.isArray(e))&&We("NATIVE_DATA_POLICY_EXPRESSION_NODE_INVALID",t),e}function We(e,t){throw new Le(e,t)}var Ks="openxiangda.config-bundle/v3",po="openxiangda.contract-bundle/v3",Kn="openxiangda.native-configuration-projection/v1",qe=Gn,Hs=/^[a-f0-9]{64}$/,Xs=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Qs=/^app:[a-z][a-z0-9]*(?:-[a-z0-9]+)*:[A-Za-z0-9:._*-]+$/,Zs=/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/,ei=/^[a-z][a-z0-9]*(?:[-.][a-z0-9]+)*$/,ti=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ni=/^[A-Za-z][A-Za-z0-9_]{0,62}$/,Hn=/^[A-Za-z][A-Za-z0-9_]{0,127}$/,oi=/^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$/,si=/^[A-Z][A-Z0-9_]*$/,ii=/^[a-z][a-z0-9-]{2,63}$/,ri=/^[A-Za-z][A-Za-z0-9_-]{0,127}$/,ai=/^[A-Za-z][A-Za-z0-9_.]{0,127}$/,ci=16,di=2*1024,li=new Set(["text.short","text.long","number.integer","number.decimal","boolean","date","time","datetime","option.single","option.multiple","cascade.single","cascade.multiple","user.single","user.multiple","department.single","department.multiple","resource-ref.single","resource-ref.multiple","uuid","serial-number"]),ui=new Set(["overview","database","operations","workflow","members","calendar","document","folder","settings"]),fi=new Set(["approve","reject","return","transfer","delegate","add_assignee","resubmit","withdraw","terminate","admin_reassign","admin_override","retry_resolution"]),pi=4*1024*1024,_i=8*1024*1024,Ei=40,Ai=1e5,dn=1024*1024,mi="openxiangda.event-handler-manifest/v2",_o="openxiangda.application-route-manifest/v3",Xn=64,Eo=new Set(["id","revision","created_by","updated_by","created_at","updated_at"]),Y=Object.freeze({perspectives:100,resources:100,subjectReadSurfaces:50,capabilities:2e3,operations:500,eventConsumers:100,eventProducers:1e3,eventSchemas:100,eventTypes:500,workflows:100,routes:500,adminPages:500,adminNavigationGroups:100,adminNavigationItems:500}),At=["openxiangda.data.record.created.v2","openxiangda.data.record.updated.v2","openxiangda.data.record.deleted.v2"],mt=["openxiangda.workflow.instance.started.v2","openxiangda.workflow.instance.cc_added.v2","openxiangda.workflow.instance.completed.v2","openxiangda.workflow.instance.rejected.v2","openxiangda.workflow.instance.returned.v2","openxiangda.workflow.instance.resumed.v2","openxiangda.workflow.instance.withdrawn.v2","openxiangda.workflow.instance.terminated.v2","openxiangda.workflow.task.created.v2","openxiangda.workflow.task.assigned.v2","openxiangda.workflow.task.assignment_pending.v2","openxiangda.workflow.task.assignment_resolution_failed.v2","openxiangda.workflow.task.approved.v2","openxiangda.workflow.task.completed.v2","openxiangda.workflow.task.rejected.v2","openxiangda.workflow.task.returned.v2","openxiangda.workflow.task.resubmitted.v2","openxiangda.workflow.task.transferred.v2","openxiangda.workflow.task.reassigned.v2","openxiangda.workflow.task.delegated.v2","openxiangda.workflow.task.assignee_added.v2","openxiangda.workflow.task.cancelled.v2","openxiangda.workflow.participant.activated.v2","openxiangda.workflow.participant.completed.v2","openxiangda.workflow.participant.rejected.v2","openxiangda.workflow.participant.returned.v2","openxiangda.workflow.participant.transferred.v2","openxiangda.workflow.participant.reassigned.v2","openxiangda.workflow.participant.delegated.v2","openxiangda.workflow.participant.added.v2","openxiangda.workflow.participant.suspended.v2","openxiangda.workflow.participant.resumed.v2","openxiangda.workflow.participant.cancelled.v2"],Ii=new Set(mt),It=class extends Error{code;pointer;identifiers;constructor(t,o,n={}){super(t),this.name="NativeConfigurationCompilerError",this.code=t,this.pointer=o,this.identifiers=Object.fromEntries(Object.entries(n).slice(0,8).map(([s,i])=>[s,String(i).slice(0,128)]))}};function gi(e){let t=R(e.appCode,"/appCode",128);Xs.test(t)||p("NATIVE_CONFIG_APP_CODE_INVALID","/appCode");let o=un(e.expectedConfigDigest,"/expectedConfigDigest"),n=un(e.expectedContractDigest,"/expectedContractDigest"),s=lo(e.configBytes,pi,"/configBytes","NATIVE_CONFIG_ARTIFACT_TOO_LARGE"),i=lo(e.contractBytes,_i,"/contractBytes","NATIVE_CONTRACT_ARTIFACT_TOO_LARGE");uo(s,o,"/configBytes","NATIVE_CONFIG_DIGEST_MISMATCH"),uo(i,n,"/contractBytes","NATIVE_CONTRACT_DIGEST_MISMATCH");let c=ao(s,"/configBytes","NATIVE_CONFIG_JSON_INVALID","NATIVE_CONFIG_NOT_CANONICAL"),r=ao(i,"/contractBytes","NATIVE_CONTRACT_JSON_INVALID","NATIVE_CONTRACT_NOT_CANONICAL");co(c,"/config"),co(r,"/contracts");let a=c,f=r;Ti(a,t),Ci(f,t,o);let _=bi(a,o,f.generatorVersion);dr(_,f,a),Q(_)!==Q(f)&&p("NATIVE_CONTRACT_CLOSURE_MISMATCH",fn(_,f,"/contracts"));let d={authz:{appCode:t,...a.authz,perspectives:a.perspectives,capabilityCatalog:_.capabilities},data:{appCode:t,resources:a.data.resources,resourceContracts:_.resources,..._.concurrency?{concurrency:_.concurrency}:{},..._.subjectReadSurfaces?{subjectReadSurfaces:_.subjectReadSurfaces}:{}},events:{appCode:t,...a.events,consumers:_.eventConsumers,producers:_.eventProducers,handlerManifest:_.eventHandlerManifest,eventTypes:_.eventTypes,capturePlans:mo({resources:a.data.resources,dataPolicies:a.authz.dataPolicies,subscriptions:_.eventConsumers,capturePolicies:a.events.capturePolicies})},workflows:{appCode:t,...a.workflows,contracts:_.workflows},runtime:{appCode:t,requirements:a.runtime,backend:a.backend,frontend:a.frontend},contracts:_},u={authz:ke(d.authz),data:ke(d.data),events:ke(d.events),workflows:ke(d.workflows),runtime:ke(d.runtime),contracts:ke(d.contracts)},I={configDigest:o,contractDigest:n,generatorVersion:f.generatorVersion},l=Ao(a),E={schemaVersion:Kn,compilerContractVersion:qe,appCode:t,source:I,projections:u,requiredPlatformCapabilities:l,aggregateDigest:ee({schemaVersion:Kn,compilerContractVersion:qe,appCode:t,source:I,requiredPlatformCapabilities:l,projectionDigests:Object.fromEntries(Object.entries(u).map(([T,g])=>[T,g.digest]))})};return So(E)}function Ao(e){let t=e.authz.roles,o=e.data.resources,n=e.backend.operations,s=t.some(l=>l.capabilities.some(E=>E.endsWith(":directory:read")))||o.some(l=>l.schema.fields.some(E=>["user.single","user.multiple","department.single","department.multiple"].includes(E.type)))||n.some(l=>l.platformAccess?.directory),i=!!(e.events.subscriptions.length||e.events.timers.length||e.events.dateTriggers.length||e.events.schemas.length),c=n.some(l=>l.platformAccess?.managedFiles||l.platformAccess?.managedFileCopies)||e.events.subscriptions.some(l=>l.platformAccess?.managedFileCopies),r=n.some(l=>l.platformAccess?.notification)||e.events.subscriptions.some(l=>l.platformAccess?.notification),a=e.workflows.definitions.filter(l=>l.launch.mode==="standalone"||l.launch.mode==="hidden-handoff"),f=n.some(l=>l.platformAccess?.workflow)||a.length>0,_={resources:o},d={perspectives:e.perspectives,authz:e.authz},u={schemaVersion:e.schemaVersion,appCode:e.appCode,frontend:{routes:e.frontend.routes,user:e.frontend.user,admin:e.frontend.admin,devicePolicy:e.frontend.devicePolicy},backend:{operations:n.map(l=>({code:l.code,method:l.method,path:l.path,capability:l.capability,platformAccess:l.platformAccess||null,...l.browser?{browser:l.browser}:{},ai:l.ai||null}))}};return[...o.some(l=>l.uniqueKeys?.length)?[{code:"data.unique-keys",declaration:o.filter(l=>l.uniqueKeys?.length).map(l=>({code:l.code,uniqueKeys:l.uniqueKeys}))}]:[],...e.data.concurrency?[{code:"data.managed-concurrency",declaration:e.data.concurrency}]:[],...e.data.concurrency?.commands.some(l=>l.mode==="durable")?[{code:"data.managed-concurrency.durable",declaration:e.data.concurrency}]:[],...o.some(l=>l.decimalReservationLifecycle)?[{code:"data.decimal-reservation-lifecycle",declaration:o.filter(l=>l.decimalReservationLifecycle).map(l=>({code:l.code,decimalReservationLifecycle:l.decimalReservationLifecycle}))}]:[],...n.some(l=>l.platformAccess?.decimalReservation)||e.events.subscriptions.some(l=>l.platformAccess?.decimalReservation)?[{code:"data.decimal-reservations",declaration:[...n.filter(l=>l.platformAccess?.decimalReservation).map(l=>({code:l.code,decimalReservation:l.platformAccess.decimalReservation})),...e.events.subscriptions.filter(l=>l.platformAccess?.decimalReservation).map(l=>({subscriptionCode:l.code,decimalReservation:l.platformAccess.decimalReservation}))]}]:[],{code:"application-native-2",declaration:u},{code:"authz.native-batch-explain",declaration:d},{code:"authz.native-management",declaration:d},{code:"deployment.durable-runs",declaration:u.backend},{code:"deployment.platform-executor",declaration:u.backend},{code:"environment.on-demand-production",declaration:{environments:["preproduction","production"]}},{code:"environment.runtime-lifecycle",declaration:{environments:["preproduction","production"]}},...o.length?[{code:"data-api-v2",declaration:_},{code:"data.native-golden-crud",declaration:_}]:[],...o.some(vt)?[{code:"data.audit-read-access",declaration:_}]:[],...s?[{code:"directory-v2",declaration:{roles:t.map(l=>({code:l.code,capabilities:l.capabilities.filter(E=>E.endsWith(":directory:read"))})),resources:o.map(l=>({code:l.code,fields:l.schema.fields.filter(E=>["user.single","user.multiple","department.single","department.multiple"].includes(E.type))})),operations:n.filter(l=>l.platformAccess?.directory).map(l=>({code:l.code,directory:l.platformAccess.directory}))}}]:[],...n.some(l=>l.platformAccess?.directory?.mode==="selected-user")?[{code:"directory.selected-user",declaration:n.filter(l=>l.platformAccess?.directory?.mode==="selected-user").map(l=>({code:l.code,directory:l.platformAccess.directory}))}]:[],...c?[{code:"data.managed-files",declaration:{operations:n.filter(l=>l.platformAccess?.managedFiles||l.platformAccess?.managedFileCopies).map(l=>({code:l.code,...l.platformAccess?.managedFiles?{managedFiles:l.platformAccess.managedFiles}:{},...l.platformAccess?.managedFileCopies?{managedFileCopies:l.platformAccess.managedFileCopies}:{}})),subscriptions:e.events.subscriptions.filter(l=>l.platformAccess?.managedFileCopies).map(l=>({code:l.code,managedFileCopies:l.platformAccess.managedFileCopies}))}}]:[],...e.events.subscriptions.some(l=>l.execution)?[{code:"events.native-data-actions",declaration:e.events.subscriptions.filter(l=>l.execution)}]:[],...e.events.capturePolicies?.length?[{code:"events.capture-policy",declaration:e.events.capturePolicies}]:[],...i?[{code:"events-v2",declaration:e.events},{code:"events.durable-receipts",declaration:e.events}]:[],...e.workflows.activations.length?[{code:"workflow-kernel-v2",declaration:e.workflows},{code:"workflow.fresh-command-token",declaration:e.workflows}]:[],...e.workflows.definitions.some(l=>l.definition.instanceCommands!==void 0)?[{code:"workflow.instance-cancellation-policy",declaration:e.workflows.definitions.filter(l=>l.definition.instanceCommands!==void 0)}]:[],...f?[{code:"business-process.durable-command",declaration:{operations:n.filter(l=>l.platformAccess?.workflow).map(l=>({code:l.code,workflow:l.platformAccess.workflow})),definitions:a,activations:e.workflows.activations.filter(l=>a.some(E=>E.definition.code===l.workflowCode))}}]:[],...r?[{code:"notification-hub-v2",declaration:{operations:n.filter(l=>l.platformAccess?.notification).map(l=>({code:l.code,notification:l.platformAccess.notification})),subscriptions:e.events.subscriptions.filter(l=>l.platformAccess?.notification).map(l=>({code:l.code,notification:l.platformAccess.notification}))}}]:[],...e.frontend.authentication?[{code:"authentication.application-login-surface",declaration:e.frontend.authentication}]:[],...e.frontend.publicAccess?[{code:"public-access.anonymous-owner-records",declaration:e.frontend.publicAccess}]:[]].map(({code:l,declaration:E})=>({code:l,contractVersion:qn[l],usageDigest:`sha256:${ee(E)}`})).sort((l,E)=>l.code===E.code?0:l.code<E.code?-1:1)}function mo(e){let t=new Map,o=new Set(e.resources.map(i=>String(i.code)));for(let[i,c]of $(e.capturePolicies===void 0?[]:e.capturePolicies,"/capturePlan/capturePolicies",100).entries()){let r=`/capturePlan/capturePolicies/${i}`,a=N(c,r);h(a,["resourceCode","mode"],r);let f=G(a.resourceCode,`${r}/resourceCode`);o.has(f)||p("NATIVE_EVENT_CAPTURE_RESOURCE_NOT_FOUND",r,{resourceCode:f}),t.has(f)&&p("NATIVE_EVENT_CAPTURE_POLICY_DUPLICATE",r,{resourceCode:f}),a.mode!=="all"&&a.mode!=="subscribed"&&p("NATIVE_EVENT_CAPTURE_MODE_INVALID",`${r}/mode`),t.set(f,a.mode)}let n=new Map(e.dataPolicies.map((i,c)=>{let r=N(i,`/capturePlan/dataPolicies/${c}`);return[String(r.code),r]})),s=e.subscriptions.map((i,c)=>N(i,`/capturePlan/subscriptions/${c}`));return e.resources.map((i,c)=>{let r=`/capturePlan/resources/${c}`,a=N(i,r),f=G(a.code,`${r}/code`),_=a.schema?N(a.schema,`${r}/schema`):a,d=new Set($(_.fields||[],`${r}/schema/fields`,500).map((b,y)=>B(N(b,`${r}/schema/fields/${y}`).code,`${r}/schema/fields/${y}/code`))),u=a.dataPolicyCode?w(a.dataPolicyCode,`${r}/dataPolicyCode`):null,I=u?n.get(u):void 0;u&&!I&&p("NATIVE_EVENT_CAPTURE_AUTHZ_POLICY_NOT_FOUND",r,{resourceCode:f,dataPolicyCode:u});let l=new Set;for(let b of I?.rules||[])l.add(String(b.field));if(I?.readExpression)for(let b of ze(I.readExpression,`${r}/readExpression`))l.add(String(b.rule.field));let E=new Set,T=new Set,g=new Set;for(let[b,y]of s.entries()){let S=$(y.eventTypes,`/capturePlan/subscriptions/${b}/eventTypes`,20).map(String);if(!S.some(M=>M.startsWith("openxiangda.data.")))continue;let P=N(y.filter||{},`/capturePlan/subscriptions/${b}/filter`),F=Array.isArray(P.resourceCodes)?P.resourceCodes.map(String):[];if(F.length&&!F.includes(f))continue;for(let M of S)At.includes(M)&&g.add(M);for(let M of Ni(P,`/capturePlan/subscriptions/${b}/filter`))E.add(M);let J=N(y.payload||{},`/capturePlan/subscriptions/${b}/payload`);for(let M of $(J.fields||[],`/capturePlan/subscriptions/${b}/payload/fields`,32))T.add(B(M,`/capturePlan/subscriptions/${b}/payload/fields`))}let A=new Set([...E,...T]),m=new Set([...A,...l]);m.size>Xn&&p("NATIVE_EVENT_CAPTURE_FIELDS_LIMIT",r,{resourceCode:f,maximum:Xn});for(let b of m)!d.has(b)&&!(l.has(b)&&Eo.has(b))&&p("NATIVE_EVENT_CAPTURE_FIELD_NOT_FOUND",r,{resourceCode:f,field:b});let O=N(a.fieldPolicies||{},`${r}/fieldPolicies`);for(let b of A)O[b]?.mask==="omit"&&p("NATIVE_EVENT_CAPTURE_FIELD_SENSITIVE",r,{resourceCode:f,field:b});let C={resourceCode:f,...t.get(f)==="subscribed"?{capturedEventTypes:[...g].sort()}:{},filterFields:[...E].sort(),projectionFields:[...T].sort(),authorizationFields:[...l].sort(),captureFields:[...m].sort()};return{...C,digest:ee(C)}}).sort((i,c)=>i.resourceCode.localeCompare(c.resourceCode))}function Ni(e,t){let o=new Set;for(let[c,r]of $(e.changes||[],`${t}/changes`,16).entries()){let a=N(r,`${t}/changes/${c}`);o.add(B(a.field,`${t}/changes/${c}/field`))}let n=N(e.changedFields||{},`${t}/changedFields`);for(let c of["anyOf","allOf","noneOf"])for(let[r,a]of $(n[c]||[],`${t}/changedFields/${c}`,32).entries())o.add(B(a,`${t}/changedFields/${c}/${r}`));let s=0,i=(c,r,a)=>{a>3&&p("NATIVE_EVENT_FILTER_DEPTH_LIMIT",r);let f=N(c,r);if(f.change){let d=N(f.change,`${r}/change`);o.add(B(d.field,`${r}/change/field`)),s+=1;return}if(f.not){i(f.not,`${r}/not`,a+1);return}let _=f.all?"all":f.any?"any":null;_||p("NATIVE_EVENT_FILTER_CONDITION_INVALID",r);for(let[d,u]of $(f[_],`${r}/${_}`,16).entries())i(u,`${r}/${_}/${d}`,a+1)};return e.where&&i(e.where,`${t}/where`,1),s+=Array.isArray(e.changes)?e.changes.length:0,s>16&&p("NATIVE_EVENT_FILTER_ATOM_LIMIT",t),[...o].sort()}function Ti(e,t){h(e,["schemaVersion","compilerContractVersion","appCode","perspectives","authz","backend","data","events","workflows","frontend","runtime"],"/config"),x(e.schemaVersion,Ks,"/config/schemaVersion"),x(e.compilerContractVersion,qe,"/config/compilerContractVersion"),x(e.appCode,t,"/config/appCode"),$(e.perspectives,"/config/perspectives",100);let o=N(e.authz,"/config/authz");h(o,["capabilities","roles","scopeDimensions","scopeSources","roleMembershipSources","relationshipGrantSources","dataPolicies","authorizationTransitions"],"/config/authz",["authenticatedUserRoleCode"]),$(o.capabilities,"/config/authz/capabilities",2e3),$(o.roles,"/config/authz/roles",100),$(o.scopeDimensions,"/config/authz/scopeDimensions",100),$(o.scopeSources,"/config/authz/scopeSources",100),$(o.roleMembershipSources,"/config/authz/roleMembershipSources",100),$(o.relationshipGrantSources,"/config/authz/relationshipGrantSources",100),$(o.dataPolicies,"/config/authz/dataPolicies",100),$(o.authorizationTransitions,"/config/authz/authorizationTransitions",100);let n=N(e.backend,"/config/backend");h(n,["secrets","operations"],"/config/backend"),$(n.secrets,"/config/backend/secrets",100),$(n.operations,"/config/backend/operations",500),or(n.secrets);let s=N(e.data,"/config/data");h(s,["resources"],"/config/data",["resourceDetailRoutes","subjectReadSurfaces","concurrency"]),$(s.resources,"/config/data/resources",100),s.subjectReadSurfaces!==void 0&&$(s.subjectReadSurfaces,"/config/data/subjectReadSurfaces",Y.subjectReadSurfaces),s.resourceDetailRoutes!==void 0&&$(s.resourceDetailRoutes,"/config/data/resourceDetailRoutes",100);let i=N(e.events,"/config/events");h(i,["schemas","subscriptions","timers","dateTriggers"],"/config/events",["capturePolicies"]),$(i.schemas,"/config/events/schemas",100),$(i.subscriptions,"/config/events/subscriptions",100),$(i.timers,"/config/events/timers",100),$(i.dateTriggers,"/config/events/dateTriggers",100);let c=N(e.workflows,"/config/workflows");h(c,["definitions","bindings","activations","providers","editableParameters"],"/config/workflows"),$(c.definitions,"/config/workflows/definitions",100),$(c.bindings,"/config/workflows/bindings",100),$(c.activations,"/config/workflows/activations",100),$(c.providers,"/config/workflows/providers",100),$(c.editableParameters,"/config/workflows/editableParameters",100);let r=N(e.frontend,"/config/frontend");h(r,["routes","user","admin","devicePolicy"],"/config/frontend",["authentication","publicAccess"]),$(r.routes,"/config/frontend/routes",500);let a=N(r.user,"/config/frontend/user");h(a,["applicationTodoCenter"],"/config/frontend/user"),Ue(a.applicationTodoCenter,"/config/frontend/user/applicationTodoCenter"),pn(r.devicePolicy,"/config/frontend/devicePolicy"),Object.prototype.hasOwnProperty.call(r,"authentication")&&go(r.authentication,r.routes,e,"/config/frontend/authentication"),Object.prototype.hasOwnProperty.call(r,"publicAccess")&&xi(r.publicAccess,e,"/config/frontend/publicAccess");let f=N(r.admin,"/config/frontend/admin");h(f,["navigation"],"/config/frontend/admin",["access"]),f.access!==void 0&&bt(f.access,"/config/frontend/admin/access",e.appCode),Bi(f.navigation,"/config/frontend/admin/navigation");let _=N(e.runtime,"/config/runtime");h(_,["protocolCapabilities","health"],"/config/runtime"),v(_.protocolCapabilities,"/config/runtime/protocolCapabilities",100),h(N(_.health,"/config/runtime/health"),["livePath","readyPath","versionPath"],"/config/runtime/health"),x(_.health.livePath,"/__platform/health","/config/runtime/health/livePath"),x(_.health.readyPath,"/__platform/ready","/config/runtime/health/readyPath"),x(_.health.versionPath,"/__platform/version","/config/runtime/health/versionPath")}function Ci(e,t,o){h(e,["schemaVersion","compilerContractVersion","generatorVersion","appCode","configDigest","perspectives","resources","capabilities","operations","eventConsumers","eventProducers","eventSchemas","eventHandlerManifest","eventTypes","workflows","routes","routeManifest","adminPages","adminNavigation"],"/contracts",["authentication","publicAccess","adminAccess","subjectReadSurfaces","concurrency"]),x(e.schemaVersion,po,"/contracts/schemaVersion"),x(e.compilerContractVersion,qe,"/contracts/compilerContractVersion"),R(e.generatorVersion,"/contracts/generatorVersion",128),x(e.appCode,t,"/contracts/appCode"),x(e.configDigest,o,"/contracts/configDigest"),$(e.perspectives,"/contracts/perspectives",Y.perspectives),$(e.resources,"/contracts/resources",Y.resources),e.subjectReadSurfaces!==void 0&&$(e.subjectReadSurfaces,"/contracts/subjectReadSurfaces",Y.subjectReadSurfaces),$(e.capabilities,"/contracts/capabilities",Y.capabilities),$(e.operations,"/contracts/operations",Y.operations),$(e.eventConsumers,"/contracts/eventConsumers",Y.eventConsumers),$(e.eventProducers,"/contracts/eventProducers",Y.eventProducers),$(e.eventSchemas,"/contracts/eventSchemas",Y.eventSchemas),N(e.eventHandlerManifest,"/contracts/eventHandlerManifest"),v(e.eventTypes,"/contracts/eventTypes",Y.eventTypes),$(e.workflows,"/contracts/workflows",Y.workflows),$(e.routes,"/contracts/routes",Y.routes),Object.prototype.hasOwnProperty.call(e,"authentication")&&Pi(e.authentication,"/contracts/authentication"),Object.prototype.hasOwnProperty.call(e,"publicAccess")&&Ui(e.publicAccess,"/contracts/publicAccess"),Object.prototype.hasOwnProperty.call(e,"adminAccess")&&bt(e.adminAccess,"/contracts/adminAccess",t),Yi(e.routeManifest,"/contracts/routeManifest",t),zi(e.adminPages,"/contracts/adminPages"),Gi(e.adminNavigation,"/contracts/adminNavigation")}function bi(e,t,o){let n=hi(e);Zi(e,n),tr(e),er(e),sr(e);let s=e.events.schemas.map((E,T)=>{let g=`/config/events/schemas/${T}`,A=N(E,g),m=R(A.eventType,`${g}/eventType`,255);return m.startsWith("openxiangda.")&&p("NATIVE_EVENT_SCHEMA_RESERVED",`${g}/eventType`,{eventType:m}),x(A.schemaDigest,ee(N(A.jsonSchema,`${g}/jsonSchema`)),`${g}/schemaDigest`),A}),i=new Set([...At,...mt,...s.map(E=>String(E.eventType))]),c=new Map(e.data.resources.map(E=>[String(E.code),new Map(E.schema.fields.map(T=>[String(T.code),String(T.type)]))])),r=X(e.events.subscriptions.map((E,T)=>{let g=`/config/events/subscriptions/${T}`,A=N(E,g),m=v(A.eventTypes,`${g}/eventTypes`,20);m.forEach((y,S)=>{i.has(y)||p("NATIVE_EVENT_TYPE_NOT_REGISTERED",`${g}/eventTypes/${S}`,{eventType:y})});let O=nn(A,e.data.resources,g),C=yi(A.delivery,m,`${g}/delivery`),b=Oi(A.platformAccess,`${g}/platformAccess`,c,e,A);return{code:w(A.code,`${g}/code`),endpointPath:ue(A.endpointPath,`${g}/endpointPath`),eventTypes:m,filter:N(A.filter,`${g}/filter`),payload:O?.payload||N(A.payload,`${g}/payload`),...O?{execution:O.execution}:{},...b?{platformAccess:b}:{},delivery:C}}),E=>E.code),a=new Map(s.map(E=>[String(E.eventType),String(E.dataSchemaVersion)])),f=X([...e.data.resources.flatMap(E=>At.map(T=>({code:`data:${E.code}:${T}`,source:"data",eventType:T,dataSchemaVersion:"2.0.0",resourceCode:E.code}))),...s.map(E=>({code:`app:${E.eventType}`,source:"app",eventType:E.eventType,dataSchemaVersion:E.dataSchemaVersion})),...e.events.timers.map(E=>({code:E.code,source:"timer",eventType:E.eventType,dataSchemaVersion:a.get(String(E.eventType))||"2.0.0"})),...e.events.dateTriggers.map(E=>({code:E.code,source:"date",eventType:E.eventType,dataSchemaVersion:a.get(String(E.eventType))||"2.0.0",resourceCode:E.resourceCode,field:E.field})),...e.workflows.activations.length?mt.map(E=>({code:`workflow:${E}`,source:"workflow",eventType:E,dataSchemaVersion:"2.0.0"})):[]],E=>`${E.source}:${E.code}:${E.eventType}`),_=j([...r.flatMap(E=>E.eventTypes),...f.map(E=>String(E.eventType))]);Wi(e);let d=Co(e),u;try{u=zt(e.data.concurrency,e.data.resources,n)}catch(E){throw E instanceof Fe&&p(E.code,E.pointer,{reason:E.reason}),E}u?.commands.some(E=>E.mode==="durable")&&e.backend?.enabled===!1&&p("NATIVE_MANAGED_CONCURRENCY_INVALID","/data/concurrency",{reason:"durable commands require backend runtime"});let I=Ri(e,n),l=Io(e);try{Kt(e.data.resources,l)}catch(E){throw E instanceof ye&&p(E.code,E.pointer,{reason:E.reason}),E}return{schemaVersion:po,compilerContractVersion:qe,generatorVersion:o,appCode:e.appCode,configDigest:t,perspectives:e.perspectives,resources:$i(e),...I.length?{subjectReadSurfaces:I}:{},...u?{concurrency:u}:{},capabilities:X(n,E=>E.code),operations:l,eventConsumers:r,eventProducers:f,eventSchemas:s,eventHandlerManifest:{schemaVersion:mi,appCode:e.appCode,handlers:r.filter(E=>!E.execution).map(E=>({code:E.code,endpointPath:E.endpointPath,eventTypes:E.eventTypes,dataSchemaVersions:j(E.eventTypes.map(T=>T.startsWith("openxiangda.")?"2.0.0":a.get(T)||"2.0.0")),maxBodyBytes:65536,receiptProtocolVersion:2}))},eventTypes:_,workflows:yo(e),routes:Ct(e),...Object.prototype.hasOwnProperty.call(e.frontend,"authentication")?{authentication:Li(e)}:{},...Object.prototype.hasOwnProperty.call(e.frontend,"publicAccess")?{publicAccess:Mi(e)}:{},...e.frontend.admin.access?{adminAccess:e.frontend.admin.access}:{},routeManifest:Xi(e),adminPages:d,adminNavigation:ji(e)}}function Oi(e,t,o,n,s){if(e===void 0)return;let i=N(e,t);h(i,["notification","managedFileCopies","decimalReservation"],t,!0);let c={};if(i.decimalReservation!==void 0)try{c.decimalReservation=Wn(i.decimalReservation,zn(n,s))}catch{p("NATIVE_EVENT_DECIMAL_RESERVATION_INVALID",`${t}/decimalReservation`)}if(i.notification!==void 0){let r=N(i.notification,`${t}/notification`);h(r,["mode"],`${t}/notification`),x(r.mode,"business-standard",`${t}/notification/mode`),c.notification={mode:"business-standard"}}if(i.managedFileCopies!==void 0){let r=$(i.managedFileCopies,`${t}/managedFileCopies`,16);r.length||p("NATIVE_EVENT_MANAGED_FILE_COPIES_REQUIRED",`${t}/managedFileCopies`);let a=new Set;c.managedFileCopies=X(r.map((f,_)=>{let d=`${t}/managedFileCopies/${_}`,u=N(f,d);h(u,["mode","sourceResourceCode","sourceFieldCodes","targetResourceCode","targetFieldCodes"],d),x(u.mode,"copy",`${d}/mode`);let I=G(u.sourceResourceCode,`${d}/sourceResourceCode`),l=G(u.targetResourceCode,`${d}/targetResourceCode`),E=o.get(I),T=o.get(l);(!E||!T)&&p("NATIVE_EVENT_MANAGED_FILE_COPY_RESOURCE_INVALID",d);let g=v(u.sourceFieldCodes,`${d}/sourceFieldCodes`,16),A=v(u.targetFieldCodes,`${d}/targetFieldCodes`,16);(!g.length||g.length!==A.length)&&p("NATIVE_EVENT_MANAGED_FILE_COPY_FIELDS_INVALID",d),g.forEach((O,C)=>{let b=E.get(O),y=T.get(A[C]);(!["file","image"].includes(String(b))||b!==y)&&p("NATIVE_EVENT_MANAGED_FILE_COPY_FIELD_INVALID",`${d}/sourceFieldCodes/${C}`)});let m=`${I}:${g.join(",")}=>${l}:${A.join(",")}`;return a.has(m)&&p("NATIVE_EVENT_MANAGED_FILE_COPY_DUPLICATE",d),a.add(m),{mode:"copy",sourceResourceCode:I,sourceFieldCodes:j(g),targetResourceCode:l,targetFieldCodes:j(A)}}),f=>`${f.sourceResourceCode}:${f.sourceFieldCodes.join(",")}=>${f.targetResourceCode}:${f.targetFieldCodes.join(",")}`)}return Object.keys(c).length||p("NATIVE_EVENT_PLATFORM_ACCESS_EMPTY",t),c}function yi(e,t,o){let n=N(e,o);h(n,["timeoutMs","maxAttempts","initialBackoffMs","maxBackoffMs","ordering","concurrency"],o),Z(n.timeoutMs,`${o}/timeoutMs`,1e3,3e4),Z(n.maxAttempts,`${o}/maxAttempts`,1,12);let s=Z(n.initialBackoffMs,`${o}/initialBackoffMs`,1e3,3e5);Z(n.maxBackoffMs,`${o}/maxBackoffMs`,s,18e5),Z(n.concurrency,`${o}/concurrency`,1,50);let i=R(n.ordering,`${o}/ordering`,32);return["none","record","workflow-instance"].includes(i)||p("NATIVE_EVENT_DELIVERY_ORDERING_INVALID",`${o}/ordering`),i==="workflow-instance"&&t.some(c=>!Ii.has(c))&&p("NATIVE_EVENT_WORKFLOW_ORDERING_REQUIRES_WORKFLOW_FACTS",`${o}/ordering`),n}function hi(e){let t=new Map;for(let o of Ro(e.appCode))t.set(o.code,o);for(let[o,n]of e.authz.capabilities.entries()){let s=`/config/authz/capabilities/${o}`,i=N(n,s);h(i,["code","kind","name","description"],s,!0);let c=Ce(i.code,`${s}/code`,e.appCode);t.has(c)&&p("NATIVE_CAPABILITY_DUPLICATE",`${s}/code`),["backend","ui"].includes(i.kind)||p("NATIVE_CAPABILITY_KIND_INVALID",`${s}/kind`);let r={code:c,kind:i.kind,name:R(i.name,`${s}/name`,255),source:"explicit",...i.description===void 0?{}:{description:En(i.description,`${s}/description`,2e3)}};t.set(c,r)}for(let[o,n]of e.data.resources.entries()){let s=`/config/data/resources/${o}`,i=he(n,s,e.appCode),c={read:`\u8BFB\u53D6${i.name}`,create:`\u65B0\u5EFA${i.name}`,update:`\u66F4\u65B0${i.name}`,delete:`\u5220\u9664${i.name}`};for(let r of["read","create","update","delete"]){let a=Ce(i.capabilities[r],`${s}/capabilities/${r}`,e.appCode);t.has(a)&&p("NATIVE_CAPABILITY_DUPLICATE",`${s}/capabilities/${r}`),t.set(a,{code:a,kind:"data",name:c[r],source:"data"})}for(let[r,a]of Object.entries(i.fieldPolicies)){if(Se(r))continue;let f=N(a,`${s}/fieldPolicies/${r}`);for(let _ of["read","create","update"])if(Array.isArray(f[_]))for(let d of v(f[_],`${s}/fieldPolicies/${r}/${_}`,2e3))Ce(d,`${s}/fieldPolicies/${r}/${_}`,e.appCode),!t.has(d)&&t.set(d,{code:d,kind:"data",name:`${i.name}.${r}.${_}`,source:"data"})}}return[...t.values()]}function $i(e){let t=Si(e);return X(e.data.resources.map((o,n)=>{let s=he(o,`/config/data/resources/${n}`,e.appCode),i=t.get(s.code);return{code:s.code,schemaDigest:ee(s.schema),fields:X(s.schema.fields.map(c=>({code:c.code,type:c.type})),c=>c.code),...i?{detailRouteCode:i}:{}}}),o=>o.code)}function Ri(e,t){if(e.data.subjectReadSurfaces===void 0)return[];let o=$(e.data.subjectReadSurfaces,"/config/data/subjectReadSurfaces",Y.subjectReadSurfaces),n=new Set(t.map(c=>String(c.code))),s=new Map(e.data.resources.map((c,r)=>{let a=`/config/data/resources/${r}`,f=he(c,a,e.appCode);return[String(f.code),{resource:f,fields:new Map($(N(f.schema,`${a}/schema`).fields,`${a}/schema/fields`,500).map(_=>{let d=N(_,`${a}/schema/fields`);return[String(d.code),d]}))}]})),i=new Set;return X(o.map((c,r)=>{let a=`/config/data/subjectReadSurfaces/${r}`,f=N(c,a);h(f,["code","name","capability","subject","relations"],a);let _=w(f.code,`${a}/code`);i.has(_)&&p("NATIVE_SUBJECT_READ_SURFACE_CODE_DUPLICATE",`${a}/code`),i.add(_);let d=Ce(f.capability,`${a}/capability`,e.appCode);n.has(d)||p("NATIVE_SUBJECT_READ_SURFACE_CAPABILITY_NOT_DECLARED",`${a}/capability`);let u=N(f.subject,`${a}/subject`);h(u,["resourceCode","fields"],`${a}/subject`);let I=G(u.resourceCode,`${a}/subject/resourceCode`),l=s.get(I);l||p("NATIVE_SUBJECT_READ_SURFACE_RESOURCE_NOT_DECLARED",`${a}/subject/resourceCode`);let E=v(u.fields,`${a}/subject/fields`,100).map((O,C)=>B(O,`${a}/subject/fields/${C}`));E.length||p("NATIVE_SUBJECT_READ_SURFACE_FIELDS_REQUIRED",`${a}/subject/fields`);for(let[O,C]of E.entries()){let b=l.fields.get(C);(!b||b.type==="subtable")&&p("NATIVE_SUBJECT_READ_SURFACE_FIELD_INVALID",`${a}/subject/fields/${O}`)}let T=$(f.relations,`${a}/relations`,8);T.length||p("NATIVE_SUBJECT_READ_SURFACE_RELATIONS_REQUIRED",`${a}/relations`);let g=new Set,A=0,m=X(T.map((O,C)=>{let b=`${a}/relations/${C}`,y=N(O,b);h(y,["code","resourceCode","foreignKeyField","fields","limit"],b,["order"]);let S=w(y.code,`${b}/code`);g.has(S)&&p("NATIVE_SUBJECT_READ_SURFACE_RELATION_CODE_DUPLICATE",`${b}/code`),g.add(S);let P=G(y.resourceCode,`${b}/resourceCode`),F=s.get(P);F||p("NATIVE_SUBJECT_READ_SURFACE_RESOURCE_NOT_DECLARED",`${b}/resourceCode`);let J=B(y.foreignKeyField,`${b}/foreignKeyField`),M=F.fields.get(J),fe=N(M?.source||{},`${b}/foreignKeyField/source`);(!M||!["uuid","resource-ref.single"].includes(String(M.type))||M.type==="resource-ref.single"&&(fe.kind!=="resource"||fe.resourceCode!==I))&&p("NATIVE_SUBJECT_READ_SURFACE_RELATION_INVALID",`${b}/foreignKeyField`);let pe=v(y.fields,`${b}/fields`,100).map((ie,V)=>B(ie,`${b}/fields/${V}`));pe.length||p("NATIVE_SUBJECT_READ_SURFACE_FIELDS_REQUIRED",`${b}/fields`);for(let[ie,V]of pe.entries()){let U=F.fields.get(V);(!U||U.type==="subtable")&&p("NATIVE_SUBJECT_READ_SURFACE_FIELD_INVALID",`${b}/fields/${ie}`)}let K=$(y.order||[],`${b}/order`,10).map((ie,V)=>{let U=`${b}/order/${V}`,L=N(ie,U);h(L,["field","direction"],U);let W=B(L.field,`${U}/field`),z=F.fields.get(W);return(!Eo.has(W)&&!z||z?.type==="subtable"||z&&!Ve(z.type))&&p("NATIVE_SUBJECT_READ_SURFACE_ORDER_FIELD_INVALID",`${U}/field`),["asc","desc"].includes(String(L.direction))||p("NATIVE_SUBJECT_READ_SURFACE_ORDER_DIRECTION_INVALID",`${U}/direction`),{field:W,direction:L.direction}}),me=Z(y.limit,`${b}/limit`,1,100);return A+=me,{code:S,resourceCode:P,foreignKeyField:J,fields:j(pe),...K.length?{order:K}:{},limit:me}}),O=>O.code);return A>400&&p("NATIVE_SUBJECT_READ_SURFACE_ROW_LIMIT_EXCEEDED",`${a}/relations`),{code:_,name:R(f.name,`${a}/name`,255),capability:d,subject:{resourceCode:I,fields:j(E)},relations:m}}),c=>c.code)}function Si(e){let t=e.data.resourceDetailRoutes===void 0?[]:$(e.data.resourceDetailRoutes,"/config/data/resourceDetailRoutes",100),o=new Map(e.data.resources.map((i,c)=>{let r=`/config/data/resources/${c}`,a=he(i,r,e.appCode);return[a.code,a]})),n=new Map(Ct(e).map(i=>[String(i.code),i])),s=new Map;for(let[i,c]of t.entries()){let r=`/config/data/resourceDetailRoutes/${i}`,a=N(c,r);h(a,["resourceCode","desktop","mobile"],r);let f=G(a.resourceCode,`${r}/resourceCode`);s.has(f)&&p("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_DUPLICATE",`${r}/resourceCode`);let _=o.get(f);_||p("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_RESOURCE_MISSING",`${r}/resourceCode`);let d=w(a.desktop,`${r}/desktop`),u=w(a.mobile,`${r}/mobile`);d===u&&p("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_INVALID",r);let I=String(_.capabilities.read);for(let[l,E]of[["desktop",d],["mobile",u]]){let T=`${r}/${l}`,g=n.get(E);g||p("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_REFERENCE_MISSING",T),g.surface!=="user"&&p("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_SURFACE_INVALID",T);let A=ue(g.path,`${T}/path`),m=[...A.matchAll(/:([A-Za-z][A-Za-z0-9_]*)/g)],O=l==="mobile"?!A.startsWith("/m/"):A==="/m"||A.startsWith("/m/");(A.includes("*")||A.includes("?")||A.includes("#")||A.split("/").includes("..")||m.length!==1||O)&&p("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_PATH_INVALID",T);let C=Array.isArray(g.access?.allOf)?g.access.allOf:[];g.capability!==I&&!C.includes(I)&&p("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_CAPABILITY_INVALID",T)}s.set(f,{desktop:d,mobile:u})}return s}function Io(e){let t=new Map(e.data.resources.map((c,r)=>{let a=`/config/data/resources/${r}`,f=he(c,a,e.appCode);return[f.code,new Map(f.schema.fields.map(_=>[String(_.code),_]))]})),o=new Map(e.data.resources.map((c,r)=>{let a=`/config/data/resources/${r}`,f=he(c,a,e.appCode);return[f.code,new Map(f.schema.fields.map(_=>[String(_.code),String(_.type)]))]})),n=new Set(o.keys()),s=new Set(e.workflows.activations.map((c,r)=>Ot(N(c,`/config/workflows/activations/${r}`).workflowCode,`/config/workflows/activations/${r}/workflowCode`))),i=new Map;return X(e.backend.operations.map((c,r)=>{let a=`/config/backend/operations/${r}`,f=N(c,a);h(f,["code","method","path","capability","requestSchema","responseSchema","description","platformAccess","browser","ai"],a,!0);let _=R(f.method,`${a}/method`,16);["GET","POST","PUT","PATCH","DELETE"].includes(_)||p("NATIVE_OPERATION_METHOD_INVALID",`${a}/method`);let d=w(f.code,`${a}/code`);Fi(f.ai,a,d,_,n);let u=wi(f.platformAccess,`${a}/platformAccess`,o,t,s,new Set(e.authz.roles.map(l=>String(l.code))));if(u?.decimalReservation){let l=u.decimalReservation,E=String(l.resourceCode),T=JSON.stringify([l.amountFieldCode,l.currencyFieldCode,l.relationFieldCode,l.parentFieldCode,l.rootFieldCode,l.statusFieldCode,l.parentRelationValue,l.childRelationValue]),g=i.get(E);g&&g!==T&&p("NATIVE_DECIMAL_RESERVATION_MAPPING_CONFLICT",`${a}/platformAccess/decimalReservation`),i.set(E,T)}let I=Di(f.browser,`${a}/browser`,_,f.requestSchema,f.responseSchema,o,t,e.data.subjectReadSurfaces||[]);return{code:d,method:_,path:ue(f.path,`${a}/path`),requiredCapability:Ce(f.capability,`${a}/capability`,e.appCode),requestSchemaDigest:ee(N(f.requestSchema,`${a}/requestSchema`)),responseSchemaDigest:ee(N(f.responseSchema,`${a}/responseSchema`)),...f.description===void 0?{}:{description:En(f.description,`${a}/description`,2e3)},...u?{platformAccess:u}:{},...I?{browser:I}:{}}}),c=>c.code)}function Di(e,t,o,n,s,i,c,r){if(e===void 0)return null;let a=N(e,t);h(a,["exposure","behavior","idempotency","subject"],t,["refreshTargets","fileIntent"]),x(a.exposure,"authenticated",`${t}/exposure`);let f=R(a.behavior,`${t}/behavior`,32);["read","controlled"].includes(f)||p("NATIVE_OPERATION_BROWSER_BEHAVIOR_INVALID",`${t}/behavior`);let _=R(a.idempotency,`${t}/idempotency`,32);(!["none","required"].includes(_)||f==="controlled"&&_!=="required"||f==="read"&&_!=="none")&&p("NATIVE_OPERATION_BROWSER_IDEMPOTENCY_INVALID",`${t}/idempotency`);let d=N(a.subject,`${t}/subject`);h(d,["resourceCode","inputField"],`${t}/subject`);let u=G(d.resourceCode,`${t}/subject/resourceCode`);i.has(u)||p("NATIVE_OPERATION_BROWSER_SUBJECT_RESOURCE_NOT_DECLARED",`${t}/subject/resourceCode`);let I=B(d.inputField,`${t}/subject/inputField`),l=N(n,`${t}/requestSchema`),E=N(s,`${t}/responseSchema`);(l.type!=="object"||l.additionalProperties!==!1||E.type!=="object"||E.additionalProperties!==!1)&&p("NATIVE_OPERATION_BROWSER_SCHEMA_ROOT_INVALID",`${t}/requestSchema`);let T=N(l.properties,`${t}/requestSchema/properties`),g=new Set(l.required===void 0?[]:v(l.required,`${t}/requestSchema/required`,200));(!(I in T)||!g.has(I))&&p("NATIVE_OPERATION_BROWSER_SUBJECT_INPUT_INVALID",`${t}/subject/inputField`);let A=N(T[I],`${t}/requestSchema/properties/${I}`);(A.type!=="string"||A.format!=="uuid")&&p("NATIVE_OPERATION_BROWSER_SUBJECT_INPUT_INVALID",`${t}/subject/inputField`);let m=new Map((Array.isArray(r)?r:[]).map((S,P)=>{let F=N(S,`/config/data/subjectReadSurfaces/${P}`);return[String(F.code),String(N(F.subject,`/config/data/subjectReadSurfaces/${P}/subject`).resourceCode)]})),O=a.refreshTargets===void 0?[]:$(a.refreshTargets,`${t}/refreshTargets`,16),C=new Set,b=X(O.map((S,P)=>{let F=`${t}/refreshTargets/${P}`,J=N(S,F);h(J,["kind","code"],F),x(J.kind,"subject-surface",`${F}/kind`);let M=w(J.code,`${F}/code`);return(C.has(M)||!m.has(M)||m.get(M)!==u)&&p("NATIVE_OPERATION_BROWSER_REFRESH_TARGET_INVALID",`${F}/code`),C.add(M),{kind:"subject-surface",code:M}}),S=>`${S.kind}:${S.code}`),y=Vi(a.fileIntent,`${t}/fileIntent`,o,f,_,u,T,g,c);return{exposure:"authenticated",behavior:f,idempotency:_,subject:{resourceCode:u,inputField:I},...b.length?{refreshTargets:b}:{},...y?{fileIntent:y}:{}}}function Vi(e,t,o,n,s,i,c,r,a){if(e===void 0)return null;let f=N(e,t);h(f,["recordResourceCode","recordIdInputField","relationField","fileNameField","contentTypeField","sizeField","purposes","maxTtlSeconds","maxBytes"],t),(o!=="GET"||n!=="read"||s!=="none")&&p("NATIVE_OPERATION_FILE_INTENT_BEHAVIOR_INVALID",t);let _=G(f.recordResourceCode,`${t}/recordResourceCode`),d=a.get(_);d||p("NATIVE_OPERATION_FILE_INTENT_RESOURCE_NOT_DECLARED",`${t}/recordResourceCode`);let u=B(f.recordIdInputField,`${t}/recordIdInputField`),I=N(c[u],`${t}/recordIdInputField`);(!r.has(u)||I.type!=="string"||I.format!=="uuid")&&p("NATIVE_OPERATION_FILE_INTENT_RECORD_INPUT_INVALID",`${t}/recordIdInputField`);let l=B(f.relationField,`${t}/relationField`),E=d.get(l);(!E||!["uuid","resource-ref.single"].includes(String(E.type))||String(E.type)==="resource-ref.single"&&(String(N(E.source,`${t}/relationField`).kind||"")!=="resource"||String(N(E.source,`${t}/relationField`).resourceCode||"")!==i))&&p("NATIVE_OPERATION_FILE_INTENT_RELATION_INVALID",`${t}/relationField`);let T=[["fileNameField",["text.short","text.long"]],["contentTypeField",["text.short","text.long"]],["sizeField",["number.integer"]]],g={};for(let[C,b]of T){let y=B(f[C],`${t}/${C}`);b.includes(String(d.get(y)?.type))||p("NATIVE_OPERATION_FILE_INTENT_METADATA_INVALID",`${t}/${C}`),g[C]=y}let A=X(v(f.purposes,`${t}/purposes`,2),C=>C);(!A.length||A.some(C=>!["preview","download"].includes(C)))&&p("NATIVE_OPERATION_FILE_INTENT_PURPOSE_INVALID",`${t}/purposes`);let m=Number(f.maxTtlSeconds);(!Number.isSafeInteger(m)||m<1||m>300)&&p("NATIVE_OPERATION_FILE_INTENT_TTL_INVALID",`${t}/maxTtlSeconds`);let O=Number(f.maxBytes);return(!Number.isSafeInteger(O)||O<1||O>104857600)&&p("NATIVE_OPERATION_FILE_INTENT_SIZE_INVALID",`${t}/maxBytes`),{recordResourceCode:_,recordIdInputField:u,relationField:l,fileNameField:g.fileNameField,contentTypeField:g.contentTypeField,sizeField:g.sizeField,purposes:A,maxTtlSeconds:m,maxBytes:O}}function wi(e,t,o,n,s,i){if(e===void 0)return null;let c=N(e,t);h(c,["directory","managedFiles","managedFileCopies","notification","workflow","roleAssertions","decimalReservation"],t,!0),Object.keys(c).length===0&&p("NATIVE_OPERATION_PLATFORM_ACCESS_EMPTY",t);let r={};if(c.roleAssertions!==void 0){let a=N(c.roleAssertions,`${t}/roleAssertions`);h(a,["roleCodes"],`${t}/roleAssertions`);let f=v(a.roleCodes,`${t}/roleAssertions/roleCodes`,20);f.length||p("NATIVE_OPERATION_ROLE_ASSERTIONS_REQUIRED",`${t}/roleAssertions/roleCodes`),f.forEach((_,d)=>{i.has(_)||p("NATIVE_ROLE_REFERENCE_MISSING",`${t}/roleAssertions/roleCodes/${d}`)}),r.roleAssertions={roleCodes:j(f)}}if(c.directory!==void 0){let a=N(c.directory,`${t}/directory`);h(a,["mode","fields"],`${t}/directory`),["current-initiator","selected-user"].includes(String(a.mode))||p("NATIVE_OPERATION_DIRECTORY_MODE_INVALID",`${t}/directory/mode`);let f=new Set(["displayName","employeeNumber","primaryDepartment","departments"]),_=v(a.fields,`${t}/directory/fields`,4);(!_.length||_.some(d=>!f.has(d)))&&p("NATIVE_OPERATION_DIRECTORY_FIELDS_INVALID",`${t}/directory/fields`),r.directory={mode:String(a.mode),fields:j(_)}}if(c.managedFiles!==void 0){let a=$(c.managedFiles,`${t}/managedFiles`,16);a.length||p("NATIVE_OPERATION_MANAGED_FILES_REQUIRED",`${t}/managedFiles`);let f=new Set;r.managedFiles=X(a.map((_,d)=>{let u=`${t}/managedFiles/${d}`,I=N(_,u);h(I,["resourceCode","fieldCodes","intents"],u);let l=G(I.resourceCode,`${u}/resourceCode`);(f.has(l)||!o.has(l))&&p("NATIVE_OPERATION_MANAGED_FILE_RESOURCE_INVALID",`${u}/resourceCode`),f.add(l);let E=v(I.fieldCodes,`${u}/fieldCodes`,16);(!E.length||E.some(g=>!["file","image","signature","text.rich"].includes(String(o.get(l)?.get(g)||""))))&&p("NATIVE_OPERATION_MANAGED_FILE_FIELD_INVALID",`${u}/fieldCodes`);let T=v(I.intents,`${u}/intents`,2);return(!T.length||T.some(g=>!["create","update"].includes(g)))&&p("NATIVE_OPERATION_MANAGED_FILE_INTENT_INVALID",`${u}/intents`),{resourceCode:l,fieldCodes:j(E),intents:j(T)}}),_=>_.resourceCode)}if(c.managedFileCopies!==void 0){let a=$(c.managedFileCopies,`${t}/managedFileCopies`,16);a.length||p("NATIVE_OPERATION_MANAGED_FILE_COPIES_REQUIRED",`${t}/managedFileCopies`);let f=new Set;r.managedFileCopies=X(a.map((_,d)=>{let u=`${t}/managedFileCopies/${d}`,I=N(_,u);h(I,["mode","sourceResourceCode","sourceFieldCodes","targetResourceCode","targetFieldCodes"],u),x(I.mode,"copy",`${u}/mode`);let l=G(I.sourceResourceCode,`${u}/sourceResourceCode`),E=G(I.targetResourceCode,`${u}/targetResourceCode`),T=o.get(l),g=o.get(E);(!T||!g)&&p("NATIVE_OPERATION_MANAGED_FILE_COPY_RESOURCE_INVALID",u);let A=v(I.sourceFieldCodes,`${u}/sourceFieldCodes`,16),m=v(I.targetFieldCodes,`${u}/targetFieldCodes`,16);(!A.length||A.length!==m.length)&&p("NATIVE_OPERATION_MANAGED_FILE_COPY_FIELDS_INVALID",u),A.forEach((C,b)=>{let y=T.get(C),S=g.get(m[b]);(!["file","image"].includes(String(y))||y!==S)&&p("NATIVE_OPERATION_MANAGED_FILE_COPY_FIELD_INVALID",`${u}/sourceFieldCodes/${b}`)});let O=`${l}:${A.join(",")}=>${E}:${m.join(",")}`;return f.has(O)&&p("NATIVE_OPERATION_MANAGED_FILE_COPY_DUPLICATE",u),f.add(O),{mode:"copy",sourceResourceCode:l,sourceFieldCodes:j(A),targetResourceCode:E,targetFieldCodes:j(m)}}),_=>`${_.sourceResourceCode}:${_.sourceFieldCodes.join(",")}=>${_.targetResourceCode}:${_.targetFieldCodes.join(",")}`)}if(c.notification!==void 0){let a=N(c.notification,`${t}/notification`);h(a,["mode"],`${t}/notification`),a.mode!=="business-standard"&&p("NATIVE_OPERATION_NOTIFICATION_MODE_INVALID",`${t}/notification/mode`),r.notification={mode:"business-standard"}}if(c.workflow!==void 0){let a=N(c.workflow,`${t}/workflow`);h(a,["codes"],`${t}/workflow`);let f=v(a.codes,`${t}/workflow/codes`,16);(!f.length||f.some(_=>!s.has(_)))&&p("NATIVE_OPERATION_WORKFLOW_CODE_INVALID",`${t}/workflow/codes`),r.workflow={codes:j(f)}}if(c.decimalReservation!==void 0){let a=`${t}/decimalReservation`,f=N(c.decimalReservation,a);h(f,["mode","resourceCode","amountFieldCode","currencyFieldCode","relationFieldCode","parentFieldCode","rootFieldCode","statusFieldCode","parentRelationValue","childRelationValue","eligibleParentStatuses","eligibleChildStatuses"],a);let _=R(f.mode,`${a}/mode`,16);["reserve","commit","release"].includes(_)||p("NATIVE_DECIMAL_RESERVATION_MODE_INVALID",`${a}/mode`);let d=G(f.resourceCode,`${a}/resourceCode`),u=n.get(d);u||p("NATIVE_DECIMAL_RESERVATION_RESOURCE_MISSING",`${a}/resourceCode`);let l=Object.fromEntries(["amountFieldCode","currencyFieldCode","relationFieldCode","parentFieldCode","rootFieldCode","statusFieldCode"].map(C=>[C,B(f[C],`${a}/${C}`)])),E=C=>u.get(l[C]),T=C=>new Set((E(C)?.options||[]).map(b=>String(b.value))),g=w(f.parentRelationValue,`${a}/parentRelationValue`),A=w(f.childRelationValue,`${a}/childRelationValue`),m=v(f.eligibleParentStatuses,`${a}/eligibleParentStatuses`,16),O=v(f.eligibleChildStatuses,`${a}/eligibleChildStatuses`,16);(E("amountFieldCode")?.type!=="number.decimal"||E("amountFieldCode")?.exactDecimal!==!0||E("amountFieldCode")?.precision!==18||E("amountFieldCode")?.scale!==2||E("currencyFieldCode")?.type!=="option.single"||E("relationFieldCode")?.type!=="option.single"||E("parentFieldCode")?.type!=="resource-ref.single"||E("parentFieldCode")?.source?.resourceCode!==d||E("rootFieldCode")?.type!=="uuid"||E("statusFieldCode")?.type!=="option.single"||g===A||!T("relationFieldCode").has(g)||!T("relationFieldCode").has(A)||!m.length||!O.length||m.some(C=>!T("statusFieldCode").has(C))||O.some(C=>!T("statusFieldCode").has(C)))&&p("NATIVE_DECIMAL_RESERVATION_FIELD_INVALID",a),r.decimalReservation={mode:_,resourceCode:d,...l,parentRelationValue:g,childRelationValue:A,eligibleParentStatuses:j(m),eligibleChildStatuses:j(O)}}return r}function Fi(e,t,o,n,s){if(e===void 0)return;let i=`${t}/ai`,c=N(e,i);ei.test(o)||p("NATIVE_OPERATION_AI_CODE_INVALID",`${t}/code`),h(c,["name","description","risk","resources","sideEffects","concurrency","timeoutMs"],i,!0),R(c.name,`${i}/name`,dn),R(c.description,`${i}/description`,dn);let r=R(c.risk,`${i}/risk`,16);["read","write","destructive","external"].includes(r)||p("NATIVE_OPERATION_AI_RISK_INVALID",`${i}/risk`),r==="read"!=(n==="GET")&&p("NATIVE_OPERATION_AI_METHOD_RISK_MISMATCH",`${i}/risk`),n==="DELETE"&&!["destructive","external"].includes(r)&&p("NATIVE_OPERATION_AI_METHOD_RISK_MISMATCH",`${i}/risk`);let a=v(c.resources,`${i}/resources`,16);a.length===0&&p("NATIVE_OPERATION_AI_RESOURCE_REQUIRED",`${i}/resources`),a.forEach((_,d)=>{let u=G(_,`${i}/resources/${d}`);s.has(u)||p("NATIVE_OPERATION_AI_RESOURCE_MISSING",`${i}/resources/${d}`)});let f=v(c.sideEffects,`${i}/sideEffects`,20);(r==="read"&&f.length!==0||r!=="read"&&f.length===0)&&p("NATIVE_OPERATION_AI_SIDE_EFFECT_INVALID",`${i}/sideEffects`),c.concurrency!==void 0&&!["none","revision"].includes(R(c.concurrency,`${i}/concurrency`,16))&&p("NATIVE_OPERATION_AI_CONCURRENCY_INVALID",`${i}/concurrency`),c.timeoutMs!==void 0&&Z(c.timeoutMs,`${i}/timeoutMs`,100,3e4)}function gt(e){return(e.replace(/\/{2,}/g,"/").replace(/\/$/,"")||"/").split("/").map(o=>o.startsWith(":")?":":o.includes("*")?"*":o).join("/")}function vi(e,t){let o=N(e,t),n=R(o.type,`${t}/type`,32),s=["code","type","label","presentation","required"],i=n==="sso"?[...s,"provider"]:n==="dingtalk"?[...s,"flow"]:s;h(o,i,t);let c=w(o.code,`${t}/code`),r=R(o.label,`${t}/label`,255),a=R(o.presentation,`${t}/presentation`,16);["primary","secondary"].includes(a)||p("NATIVE_APPLICATION_AUTH_METHOD_PRESENTATION_INVALID",`${t}/presentation`);let f=Ue(o.required,`${t}/required`);return["sso","password","dingtalk"].includes(n)||p("NATIVE_APPLICATION_AUTH_METHOD_TYPE_INVALID",`${t}/type`),n==="sso"&&o.provider!=="tenant-default"&&p("NATIVE_APPLICATION_AUTH_SSO_PROVIDER_INVALID",`${t}/provider`),n==="dingtalk"&&!["auto","jsapi","oauth"].includes(R(o.flow,`${t}/flow`,16))&&p("NATIVE_APPLICATION_AUTH_DINGTALK_FLOW_INVALID",`${t}/flow`),{code:c,type:n,label:r,presentation:a,required:f,...n==="sso"?{provider:"tenant-default"}:{},...n==="dingtalk"?{flow:o.flow}:{}}}function Qn(e,t,o){let n=N(e,o);h(n,["routeCode","path","defaultRouteCode"],o);let s=w(n.routeCode,`${o}/routeCode`),i=ue(n.path,`${o}/path`),c=t==="desktop"?"/login":"/m/login";return(i!==c||/[:*?#\\]/.test(i))&&p("NATIVE_APPLICATION_AUTH_SURFACE_PATH_INVALID",`${o}/path`,{device:t,expectedPath:c}),{routeCode:s,path:i,defaultRouteCode:w(n.defaultRouteCode,`${o}/defaultRouteCode`)}}function go(e,t,o,n){if(e===null)return;let s=N(e,n);h(s,["accountMode","registration","methods","surfaces"],n),x(s.accountMode,"existing-platform-users-only",`${n}/accountMode`);let i=N(s.registration,`${n}/registration`);h(i,["mode"],`${n}/registration`),x(i.mode,"reject",`${n}/registration/mode`);let c=$(s.methods,`${n}/methods`,8);c.length===0&&p("NATIVE_APPLICATION_AUTH_METHOD_REQUIRED",`${n}/methods`);let r=c.map((g,A)=>vi(g,`${n}/methods/${A}`)),a=new Set,f=new Set;for(let[g,A]of r.entries())a.has(A.code)&&p("NATIVE_APPLICATION_AUTH_METHOD_CODE_DUPLICATE",`${n}/methods/${g}/code`),f.has(A.type)&&p("NATIVE_APPLICATION_AUTH_METHOD_TYPE_DUPLICATE",`${n}/methods/${g}/type`),a.add(A.code),f.add(A.type);r.filter(g=>g.presentation==="primary").length!==1&&p("NATIVE_APPLICATION_AUTH_PRIMARY_METHOD_INVALID",`${n}/methods`);let _=N(s.surfaces,`${n}/surfaces`);h(_,["desktop","mobile"],`${n}/surfaces`);let d=Qn(_.desktop,"desktop",`${n}/surfaces/desktop`),u=Qn(_.mobile,"mobile",`${n}/surfaces/mobile`);d.routeCode===u.routeCode&&p("NATIVE_APPLICATION_AUTH_SURFACE_CODE_DUPLICATE",`${n}/surfaces/mobile/routeCode`);let I=$(t,"/config/frontend/routes",500),l=new Map;for(let[g,A]of I.entries()){let m=N(A,`/config/frontend/routes/${g}`);l.set(String(m.code||""),m)}let E=new Set((Array.isArray(o.data?.resources)?o.data.resources:[]).map(g=>String(g.code||"")).filter(g=>/^[a-z][a-z0-9-]{0,62}$/.test(g)));for(let[g,A]of[["desktop",d],["mobile",u]]){l.has(A.routeCode)&&p("NATIVE_APPLICATION_AUTH_SURFACE_CODE_CONFLICT",`${n}/surfaces/${g}/routeCode`);let m=/^user\.([a-z][a-z0-9-]{0,62})\.(records|submit)$/.exec(String(A.defaultRouteCode||"")),O=l.get(A.defaultRouteCode),C=String(O?.path||"");if(m&&E.has(m[1])){let y=m[2]==="records"?`/my/${m[1]}`:`/my/${m[1]}/submit`;O={surface:"user",path:g==="mobile"?`/m${y}`:y},C=String(O.path)}let b=g==="desktop"?C==="/m"||C.startsWith("/m/"):!(C==="/m"||C.startsWith("/m/"));(!O||O.surface!=="user"||/[:*]/.test(C)||b)&&p("NATIVE_APPLICATION_AUTH_DEFAULT_ROUTE_INVALID",`${n}/surfaces/${g}/defaultRouteCode`)}let T=No(o).filter(g=>!g.owner.startsWith("authentication:"));for(let[g,A]of[["desktop",d],["mobile",u]]){let m=T.find(O=>gt(O.path)===gt(A.path));m&&p("NATIVE_APPLICATION_AUTH_SURFACE_PATH_CONFLICT",`${n}/surfaces/${g}/path`,{owner:m.owner})}}function Pi(e,t){if(e===null)return;let o={data:{resources:[]},workflows:{definitions:[]},frontend:{routes:[{code:"auth-desktop-default",path:"/auth-desktop-default",surface:"user"},{code:"auth-mobile-default",path:"/m/auth-mobile-default",surface:"user"}],user:{applicationTodoCenter:!1},admin:{navigation:[]},authentication:e}},n=N(e,t),s=N(n.surfaces,`${t}/surfaces`),i={...n,surfaces:{...s,desktop:{...N(s.desktop,`${t}/surfaces/desktop`),defaultRouteCode:"auth-desktop-default"},mobile:{...N(s.mobile,`${t}/surfaces/mobile`),defaultRouteCode:"auth-mobile-default"}}};go(i,o.frontend.routes,{...o,frontend:{...o.frontend,authentication:i}},t)}function Li(e){let t=e.frontend.authentication;return t===null?null:{accountMode:t.accountMode,registration:{mode:t.registration.mode},methods:t.methods.map(o=>({...o})),surfaces:{desktop:{...t.surfaces.desktop},mobile:{...t.surfaces.mobile}}}}var ki=new Set(["draft.read","draft.update","validate","create","own.list","own.read","public.list","public.read"]);function xi(e,t,o){let n=N(e,o);h(n,["policies"],o);let s=$(n.policies,`${o}/policies`,16);s.length<1&&p("NATIVE_PUBLIC_POLICY_REQUIRED",o);let i=new Map(t.frontend.routes.map(f=>[f.code,f])),c=new Map(t.data.resources.map(f=>[f.code,f])),r=new Set,a=new Set(s.map(f=>String(f?.code||"")));s.forEach((f,_)=>{let d=`${o}/policies/${_}`,u=N(f,d);h(u,["code","routeCode","mode","resourceCode","operations","fields"],d,["requiredFields","ownRecordFields","publicRecordFields","publicFilters","serverGeneratedFields","schedule","publicSubtableFields","draft","validations"]);let I=w(u.code,`${d}/code`);r.has(I)&&p("NATIVE_PUBLIC_POLICY_DUPLICATE",`${d}/code`);let l=w(u.routeCode,`${d}/routeCode`),E=i.get(l);(!E||E.surface!=="user"||E.capability!==void 0||E.access!==void 0||/[:*]/.test(String(E.path)))&&p("NATIVE_PUBLIC_ROUTE_INVALID",`${d}/routeCode`),x(u.mode,"anonymous",`${d}/mode`);let T=G(u.resourceCode,`${d}/resourceCode`),g=c.get(T);g||p("NATIVE_PUBLIC_RESOURCE_MISSING",`${d}/resourceCode`);let A=new Map(g.schema.fields.map(V=>[String(V.code),String(V.type)])),m=v(u.operations,`${d}/operations`,8);(m.length<1||m.some(V=>!ki.has(V)))&&p("NATIVE_PUBLIC_OPERATION_INVALID",`${d}/operations`),m.includes("draft.read")!==m.includes("draft.update")&&p("NATIVE_PUBLIC_DRAFT_OPERATION_INCOMPLETE",`${d}/operations`);let O=v(u.fields,`${d}/fields`,64);(O.length<1||O.some(V=>!A.has(V)))&&p("NATIVE_PUBLIC_FIELD_INVALID",`${d}/fields`);for(let V of["requiredFields","ownRecordFields","publicRecordFields"]){if(!Object.prototype.hasOwnProperty.call(u,V))continue;v(u[V],`${d}/${V}`,64).some(L=>!O.includes(L))&&p("NATIVE_PUBLIC_FIELD_SCOPE_INVALID",`${d}/${V}`)}let C=Object.prototype.hasOwnProperty.call(u,"serverGeneratedFields")?$(u.serverGeneratedFields,`${d}/serverGeneratedFields`,16):[],b=new Set;C.forEach((V,U)=>{let L=`${d}/serverGeneratedFields/${U}`,W=N(V,L);h(W,["field","kind"],L);let z=B(W.field,`${L}/field`);(b.has(z)||!A.has(z)||O.includes(z)||A.get(z)!=="text.short"&&A.get(z)!=="text.long")&&p("NATIVE_PUBLIC_SERVER_GENERATED_FIELD_INVALID",`${L}/field`),x(W.kind,"random-token",`${L}/kind`),b.add(z)});let y=Object.prototype.hasOwnProperty.call(u,"schedule")?N(u.schedule,`${d}/schedule`):null;if(y){let V=["campusPolicyCode","rulePolicyCode","campusField","ruleCampusField","ruleWeekdaysField","ruleOpenAtField","ruleCloseAtField","ruleSlotMinutesField","ruleAdvanceHoursField","ruleAdvanceDaysField","campusEnabledField","ruleEnabledField","dateField","timeField"];h(y,V,`${d}/schedule`);for(let U of["campusPolicyCode","rulePolicyCode"])w(y[U],`${d}/schedule/${U}`);for(let U of V.filter(L=>!["campusPolicyCode","rulePolicyCode"].includes(L)))B(y[U],`${d}/schedule/${U}`);for(let U of[y.campusField,y.dateField,y.timeField])O.includes(String(U))||p("NATIVE_PUBLIC_SCHEDULE_FIELD_INVALID",`${d}/schedule`);(!a.has(String(y.campusPolicyCode))||!a.has(String(y.rulePolicyCode)))&&p("NATIVE_PUBLIC_SCHEDULE_POLICY_INVALID",`${d}/schedule`)}let S=Object.prototype.hasOwnProperty.call(u,"publicFilters")?$(u.publicFilters,`${d}/publicFilters`,16):[],P=new Set;S.forEach((V,U)=>{let L=`${d}/publicFilters/${U}`,W=N(V,L);h(W,["field","operator","value"],L);let z=B(W.field,`${L}/field`);P.has(z)&&p("NATIVE_PUBLIC_FILTER_DUPLICATE",`${L}/field`),O.includes(z)||p("NATIVE_PUBLIC_FILTER_FIELD_INVALID",`${L}/field`),x(W.operator,"eq",`${L}/operator`),["boolean","text.short","text.long","number.integer","number.decimal","date","time"].includes(A.get(z)||"")||p("NATIVE_PUBLIC_FILTER_FIELD_INVALID",`${L}/field`),W.value!==null&&typeof W.value!="string"&&typeof W.value!="number"&&typeof W.value!="boolean"&&p("NATIVE_PUBLIC_FILTER_VALUE_INVALID",`${L}/value`),P.add(z)});let F=Object.prototype.hasOwnProperty.call(u,"publicSubtableFields")?N(u.publicSubtableFields,`${d}/publicSubtableFields`):null;if(F){Object.keys(F).length>64&&p("NATIVE_PUBLIC_SUBTABLE_FIELDS_INVALID",`${d}/publicSubtableFields`);for(let[V,U]of Object.entries(F)){let L=g.schema.fields.find(H=>String(H.code)===V),W=String(L?.subtable?.resourceCode||""),z=c.get(W),Ie=new Map((z?.schema?.fields||[]).map(H=>[String(H.code),String(H.type)])),q=v(U,`${d}/publicSubtableFields/${V}`,64);(!O.includes(V)||A.get(V)!=="subtable"||!z||q.length<1||q.some(H=>!Ie.has(H))||q.some(H=>Ie.get(H)==="subtable")||q.some(H=>Ie.get(H)==="signature"))&&p("NATIVE_PUBLIC_SUBTABLE_FIELDS_INVALID",`${d}/publicSubtableFields/${V}`)}}if(m.some(V=>V.startsWith("public."))){Object.prototype.hasOwnProperty.call(u,"publicRecordFields")||p("NATIVE_PUBLIC_RECORD_FIELDS_REQUIRED",`${d}/publicRecordFields`);let V=v(u.publicRecordFields,`${d}/publicRecordFields`,64);(V.length<1||V.some(U=>!O.includes(U))||V.some(U=>A.get(U)==="signature"||A.get(U)==="subtable"&&!F?.[U]))&&p("NATIVE_PUBLIC_RECORD_FIELDS_INVALID",`${d}/publicRecordFields`)}let J=Object.prototype.hasOwnProperty.call(u,"requiredFields")?v(u.requiredFields,`${d}/requiredFields`,64):[],M=g.surface||{},fe=M.fields||{},pe=String(M.mutationOwner||"native")==="native"&&M.generated?.create!==!1,K=g.schema.fields.filter(V=>je(V,fe[V.code])).map(V=>String(V.code));if(m.includes("create")&&!pe&&p("NATIVE_PUBLIC_CREATE_FIELDS_INCOMPLETE",`${d}/fields`),m.includes("create")&&!Object.prototype.hasOwnProperty.call(u,"draft")&&p("NATIVE_PUBLIC_DRAFT_REQUIRED",`${d}/draft`),m.includes("create"))for(let V of K){let U=O.includes(V)?J.includes(V)?null:"requiredFields":"fields";U&&p("NATIVE_PUBLIC_CREATE_FIELDS_INCOMPLETE",`${d}/${U}`,{resourceCode:G,fieldCode:V})}if(Object.prototype.hasOwnProperty.call(u,"draft")){let V=N(u.draft,`${d}/draft`);h(V,["enabled","inactivityTtlSeconds","maxBytes"],`${d}/draft`),x(V.enabled,!0,`${d}/draft/enabled`),Z(V.inactivityTtlSeconds,`${d}/draft/inactivityTtlSeconds`,3600,7776e3),Z(V.maxBytes,`${d}/draft/maxBytes`,4096,262144)}else m.includes("draft.read")&&p("NATIVE_PUBLIC_DRAFT_REQUIRED",`${d}/draft`);let me=Object.prototype.hasOwnProperty.call(u,"validations")?$(u.validations,`${d}/validations`,16):[],ie=new Set;me.forEach((V,U)=>{let L=`${d}/validations/${U}`,W=N(V,L);h(W,["code","kind","fields","result"],L);let z=w(W.code,`${L}/code`);ie.has(z)&&p("NATIVE_PUBLIC_VALIDATION_DUPLICATE",`${L}/code`),x(W.kind,"duplicate",`${L}/kind`),x(W.result,"availability",`${L}/result`);let Ie=v(W.fields,`${L}/fields`,8);(Ie.length<1||Ie.some(q=>!O.includes(q))||Ie.some(q=>["file","subtable"].includes(A.get(q)||"")))&&p("NATIVE_PUBLIC_VALIDATION_FIELD_INVALID",`${L}/fields`),ie.add(z)}),r.add(I)})}function Ui(e,t){let o=N(e,t);h(o,["policies"],t),$(o.policies,`${t}/policies`,16).length<1&&p("NATIVE_PUBLIC_POLICY_REQUIRED",t)}function Mi(e){return{policies:X(e.frontend.publicAccess.policies.map(t=>({code:t.code,routeCode:t.routeCode,mode:t.mode,resourceCode:t.resourceCode,operations:j(t.operations),fields:j(t.fields),...t.requiredFields?{requiredFields:j(t.requiredFields)}:{},...t.ownRecordFields?{ownRecordFields:j(t.ownRecordFields)}:{},...t.publicRecordFields?{publicRecordFields:j(t.publicRecordFields)}:{},...t.publicFilters?{publicFilters:t.publicFilters.map(o=>({field:o.field,operator:o.operator,value:o.value})).sort((o,n)=>ae(o.field,n.field))}:{},...t.publicSubtableFields?{publicSubtableFields:Object.fromEntries(Object.entries(t.publicSubtableFields).sort(([o],[n])=>o.localeCompare(n)).map(([o,n])=>[o,j(Array.isArray(n)?n.map(String):[])]))}:{},...t.serverGeneratedFields?{serverGeneratedFields:t.serverGeneratedFields.map(o=>({field:o.field,kind:o.kind})).sort((o,n)=>ae(o.field,n.field))}:{},...t.schedule?{schedule:{campusPolicyCode:t.schedule.campusPolicyCode,rulePolicyCode:t.schedule.rulePolicyCode,campusField:t.schedule.campusField,ruleCampusField:t.schedule.ruleCampusField,ruleWeekdaysField:t.schedule.ruleWeekdaysField,ruleOpenAtField:t.schedule.ruleOpenAtField,ruleCloseAtField:t.schedule.ruleCloseAtField,ruleSlotMinutesField:t.schedule.ruleSlotMinutesField,ruleAdvanceHoursField:t.schedule.ruleAdvanceHoursField,ruleAdvanceDaysField:t.schedule.ruleAdvanceDaysField,campusEnabledField:t.schedule.campusEnabledField,ruleEnabledField:t.schedule.ruleEnabledField,dateField:t.schedule.dateField,timeField:t.schedule.timeField}}:{},...t.draft?{draft:{...t.draft}}:{},...t.validations?{validations:X(t.validations.map(o=>({code:o.code,kind:o.kind,fields:j(o.fields),result:o.result})),o=>o.code)}:{}})),t=>t.code)}}function No(e){let t=[{owner:"platform:admin-entry",path:"/"},{owner:"platform:admin-entry",path:"/admin"},{owner:"platform:file-preview",path:"/files/:resourceCode/:fileId/preview"}];e.frontend.authentication&&t.push({owner:"authentication:desktop",path:e.frontend.authentication.surfaces.desktop.path},{owner:"authentication:mobile",path:e.frontend.authentication.surfaces.mobile.path});for(let o of e.data.resources){let n=To(o),s=`/admin/resources/${o.code}`,i=[["list",s],["detail",`${s}/:id`],["create",`${s}/new`],["update",`${s}/:id/edit`]];for(let[c,r]of i)n[c]&&t.push({owner:`resource:${o.code}:${c}`,path:r},{owner:`resource:${o.code}:${c}:mobile`,path:`/m${r}`})}if(e.frontend.user.applicationTodoCenter===!0&&t.push({owner:"application:todo-center",path:"/todos"},{owner:"application:todo-center:mobile",path:"/m/todos"}),e.workflows.definitions.length>0){t.push({owner:"workflow:work-center",path:"/work-center"},{owner:"workflow:work-center:mobile",path:"/m/work-center"},{owner:"workflow:task",path:"/tasks/:taskId"},{owner:"workflow:task:mobile",path:"/m/tasks/:taskId"},{owner:"workflow:instance",path:"/workflows/:instanceId"},{owner:"workflow:instance:mobile",path:"/m/workflows/:instanceId"});let o=!1;for(let n of e.workflows.definitions)["standalone","hidden-handoff"].includes(n.launch.mode)&&(o=!0);o&&t.push({owner:"workflow:launch",path:"/workflows/:workflowCode/start"},{owner:"workflow:launch:mobile",path:"/m/workflows/:workflowCode/start"})}return t}function Ct(e){let t=new Map(No(e).map(o=>[gt(o.path),o]));return X(e.frontend.routes.map((o,n)=>{let s=`/config/frontend/routes/${n}`,i=N(o,s);h(i,["code","path","label","surface","parentCode","capability","access","pinned","tabPersistence","keepAlive"],s,!0),["admin","user"].includes(i.surface)||p("NATIVE_ROUTE_SURFACE_INVALID",`${s}/surface`);let c=ue(i.path,`${s}/path`);i.surface==="admin"&&c!=="/admin"&&!c.startsWith("/admin/")&&p("NATIVE_ADMIN_ROUTE_PATH_INVALID",`${s}/path`),i.surface==="user"&&(c==="/admin"||c.startsWith("/admin/"))&&p("NATIVE_USER_ROUTE_PATH_RESERVED",`${s}/path`);let r=gt(c),a=t.get(r);a&&p("NATIVE_ROUTE_PATH_CONFLICT",`${s}/path`,{path:c,owner:a.owner}),t.set(r,{owner:`frontend:${String(i.code||n)}`,path:c});let f=/[:*]/.test(c),_=_n(i,s,e.appCode),d=i.pinned===void 0?void 0:Ue(i.pinned,`${s}/pinned`),u=i.tabPersistence===void 0?f?"none":"session":R(i.tabPersistence,`${s}/tabPersistence`,16),I=i.keepAlive===void 0?"none":R(i.keepAlive,`${s}/keepAlive`,16);return["session","none"].includes(u)||p("NATIVE_ROUTE_TAB_PERSISTENCE_INVALID",`${s}/tabPersistence`),["none","memory"].includes(I)||p("NATIVE_ROUTE_KEEP_ALIVE_INVALID",`${s}/keepAlive`),f&&d===!0&&p("NATIVE_DYNAMIC_ROUTE_PINNED_FORBIDDEN",`${s}/pinned`),f&&u==="session"&&p("NATIVE_DYNAMIC_ROUTE_TAB_PERSISTENCE_FORBIDDEN",`${s}/tabPersistence`),f&&I==="memory"&&p("NATIVE_DYNAMIC_ROUTE_KEEP_ALIVE_FORBIDDEN",`${s}/keepAlive`),{code:w(i.code,`${s}/code`),path:c,label:R(i.label,`${s}/label`,255),surface:i.surface,...i.parentCode===void 0?{}:{parentCode:w(i.parentCode,`${s}/parentCode`)},..._,...d===void 0?{}:{pinned:d},tabPersistence:u,keepAlive:I}}),o=>o.code)}function To(e){let t=e.surface===void 0?{}:N(e.surface,"/surface"),o=t.mutationOwner||"native",n=t.generated===void 0?{}:N(t.generated,"/surface/generated"),s=o==="native";return{list:n.list??!0,detail:n.detail??!0,create:n.create??s,update:n.update??s,delete:n.delete??s}}function Co(e){let t=[];for(let o of X(e.data.resources,n=>n.code).flatMap(n=>[{resource:n,viewCode:void 0},...(n.surface?.views||[]).map(s=>({viewCode:s.code,resource:{...n,name:s.name,surface:it(n.surface,s.code)}}))])){let{resource:n,viewCode:s}=o,i=`/admin/resources/${n.code}${s?`/views/${s}`:""}`,c=To(n),r=[{operation:"list",kind:"resource-list",path:`${i}`,label:n.name,capability:n.capabilities.read,navigationEligible:!0},{operation:"detail",kind:"resource-detail",path:`${i}/:id`,label:`${n.name}\u8BE6\u60C5`,capability:n.capabilities.read,navigationEligible:!1},{operation:"create",kind:"resource-create",path:`${i}/new`,label:`\u65B0\u589E${n.name}`,capability:n.capabilities.create,navigationEligible:!1},{operation:"update",kind:"resource-update",path:`${i}/:id/edit`,label:`\u7F16\u8F91${n.name}`,capability:n.capabilities.update,navigationEligible:!1}];for(let a of r)c[a.operation]&&t.push({code:`resource:${n.code}${s?`:view:${s}`:""}:${a.operation}`,kind:a.kind,path:a.path,label:a.label,navigationEligible:a.navigationEligible,capability:a.capability,resourceCode:n.code,...s?{viewCode:s}:{}})}for(let o of Ct(e))o.surface==="admin"&&t.push({code:`operation:${o.code}`,kind:"operation",path:o.path,label:o.label,navigationEligible:!/[:*]/.test(o.path),routeCode:o.code});return t.sort((o,n)=>ae(o.code,n.code))}function bo(e){return e.kind==="resource"?`resource:${e.resourceCode}${e.viewCode?`:view:${e.viewCode}`:""}:list`:`operation:${e.routeCode}`}function ji(e){return e.frontend.admin.navigation.map((t,o)=>({code:t.code,label:t.label,...t.icon===void 0?{}:{icon:t.icon},order:t.order??o,items:t.items.map((n,s)=>({pageCode:bo(n.page),...n.label===void 0?{}:{label:n.label},...n.icon===void 0?{}:{icon:n.icon},order:n.order??s})).sort((n,s)=>n.order-s.order||ae(n.pageCode,s.pageCode))})).sort((t,o)=>t.order-o.order||ae(t.code,o.code))}function Bi(e,t){let o=$(e,t,Y.adminNavigationGroups),n=0;o.forEach((s,i)=>{let c=`${t}/${i}`,r=N(s,c);h(r,["code","label","icon","order","items"],c,!0),w(r.code,`${c}/code`),R(r.label,`${c}/label`,255),Nt(r.icon,`${c}/icon`),oo(r.order,`${c}/order`);let a=$(r.items,`${c}/items`,500);a.length===0&&p("NATIVE_ADMIN_GROUP_ORPHANED",`${c}/items`),n+=a.length,n>Y.adminNavigationItems&&p("NATIVE_ARRAY_LIMIT_EXCEEDED",t),a.forEach((f,_)=>{let d=`${c}/items/${_}`,u=N(f,d);h(u,["page","label","icon","order"],d,!0),Ji(u.page,`${d}/page`),u.label!==void 0&&R(u.label,`${d}/label`,255),Nt(u.icon,`${d}/icon`),oo(u.order,`${d}/order`)})})}function Ji(e,t){let o=N(e,t),n=R(o.kind,`${t}/kind`,64);if(n==="resource"){h(o,["kind","resourceCode"],t,["viewCode"]),o.viewCode!==void 0&&w(o.viewCode,`${t}/viewCode`),G(o.resourceCode,`${t}/resourceCode`);return}if(n==="operation"){h(o,["kind","routeCode"],t),w(o.routeCode,`${t}/routeCode`);return}p("NATIVE_ADMIN_PAGE_REFERENCE_KIND_INVALID",`${t}/kind`)}function Wi(e){let t=new Map(Co(e).map(s=>[String(s.code),s])),o=new Set,n=new Set;e.frontend.admin.navigation.forEach((s,i)=>{let c=`/config/frontend/admin/navigation/${i}`;o.has(s.code)&&p("NATIVE_ADMIN_GROUP_DUPLICATE",`${c}/code`),o.add(s.code),s.label===s.code&&p("NATIVE_ADMIN_USER_LABEL_REQUIRED",`${c}/label`),s.items.forEach((r,a)=>{let f=`${c}/items/${a}`,_=bo(r.page),d=t.get(_);(!d||d.navigationEligible!==!0)&&p("NATIVE_ADMIN_PAGE_NOT_FOUND",`${f}/page`),n.has(_)&&p("NATIVE_ADMIN_PAGE_DUPLICATE",`${f}/page`),n.add(_);let u=r.page.resourceCode||r.page.routeCode||r.page.workflowCode||_,I=r.label||d.label;(!I||I===u||I===_)&&p("NATIVE_ADMIN_USER_LABEL_REQUIRED",`${f}/label`)})})}function zi(e,t){let o=$(e,t,Y.adminPages),n=new Set;o.forEach((s,i)=>{let c=`${t}/${i}`,r=N(s,c);h(r,["code","kind","path","label","navigationEligible","capability","access","resourceCode","viewCode","routeCode"],c,!0);let a=R(r.code,`${c}/code`,255);n.has(a)&&p("NATIVE_ADMIN_PAGE_DUPLICATE",`${c}/code`),n.add(a);let f=R(r.kind,`${c}/kind`,64);if(["resource-list","resource-detail","resource-create","resource-update","operation"].includes(f)||p("NATIVE_ADMIN_PAGE_KIND_INVALID",`${c}/kind`),ue(r.path,`${c}/path`),R(r.label,`${c}/label`,255),Ue(r.navigationEligible,`${c}/navigationEligible`),r.capability!==void 0&&r.access!==void 0&&p("NATIVE_ROUTE_ACCESS_CONFLICT",`${c}/access`),r.capability!==void 0&&R(r.capability,`${c}/capability`,255),r.access!==void 0){let _=N(r.access,`${c}/access`);h(_,["allOf","anyOf"],`${c}/access`,!0);for(let d of["allOf","anyOf"])_[d]!==void 0&&v(_[d],`${c}/access/${d}`,50)}for(let _ of["resourceCode","viewCode","routeCode"])r[_]!==void 0&&w(r[_],`${c}/${_}`)})}function Gi(e,t){let o=$(e,t,Y.adminNavigationGroups),n=0;o.forEach((s,i)=>{let c=`${t}/${i}`,r=N(s,c);h(r,["code","label","icon","order","items"],c,!0),w(r.code,`${c}/code`),R(r.label,`${c}/label`,255),Nt(r.icon,`${c}/icon`),Z(r.order,`${c}/order`,-1e4,1e4);let a=$(r.items,`${c}/items`,500);a.length===0&&p("NATIVE_ADMIN_GROUP_ORPHANED",`${c}/items`),n+=a.length,n>Y.adminNavigationItems&&p("NATIVE_ARRAY_LIMIT_EXCEEDED",t),a.forEach((f,_)=>{let d=`${c}/items/${_}`,u=N(f,d);h(u,["pageCode","label","icon","order"],d,!0),R(u.pageCode,`${d}/pageCode`,255),u.label!==void 0&&R(u.label,`${d}/label`,255),Nt(u.icon,`${d}/icon`),Z(u.order,`${d}/order`,-1e4,1e4)})})}var qi=new Set(["application-todo-center","workflow-work-center","workflow-launch","workflow-task","workflow-instance","resource-records","resource-submit"]);function Yi(e,t,o){let n=N(e,t);h(n,["schemaVersion","appCode","devicePolicy","rootEntry","authentication","routes","digest"],t),x(n.schemaVersion,_o,`${t}/schemaVersion`),x(n.appCode,o,`${t}/appCode`),pn(n.devicePolicy,`${t}/devicePolicy`),Ki(n.rootEntry,`${t}/rootEntry`),Hi(n.authentication,`${t}/authentication`),un(n.digest,`${t}/digest`);let s=$(n.routes,`${t}/routes`,Y.routes),i=new Set;s.forEach((c,r)=>{let a=`${t}/routes/${r}`,f=N(c,a),_=f.kind==="resource-records"||f.kind==="resource-submit";h(f,["code","kind","desktop","mobile"],a,["workflowCode",..._?["resourceCode"]:[]]);let d=R(f.code,`${a}/code`,255);i.has(d)&&p("NATIVE_ROUTE_MANIFEST_DUPLICATE",`${a}/code`),i.add(d);let u=R(f.kind,`${a}/kind`,64);if(qi.has(u)||p("NATIVE_ROUTE_MANIFEST_KIND_INVALID",`${a}/kind`),f.workflowCode!==void 0&&w(f.workflowCode,`${a}/workflowCode`),_){let E=G(f.resourceCode,`${a}/resourceCode`);x(d,`user.${E}.${f.kind==="resource-records"?"records":"submit"}`,`${a}/code`)}else f.resourceCode!==void 0&&p("NATIVE_PROPERTY_UNKNOWN",`${a}/resourceCode`);let I=eo(f.desktop,`${a}/desktop`,o),l=eo(f.mobile,`${a}/mobile`,o);I.surface!=="user"&&p("NATIVE_ROUTE_MANIFEST_DESKTOP_SURFACE_INVALID",`${a}/desktop/surface`),l.surface!=="user"&&p("NATIVE_ROUTE_MANIFEST_MOBILE_SURFACE_INVALID",`${a}/mobile/surface`),I.routeCode===l.routeCode&&p("NATIVE_ROUTE_MANIFEST_PAIR_DUPLICATE",a)}),x(n.digest,ee({schemaVersion:n.schemaVersion,appCode:n.appCode,devicePolicy:n.devicePolicy,rootEntry:n.rootEntry,authentication:n.authentication,routes:n.routes}),`${t}/digest`)}function pn(e,t){let o=N(e,t);h(o,["kind","mobileMaxWidthPx","desktopMinWidthPx"],t),x(o.kind,"viewport-family",`${t}/kind`);let n=Z(o.mobileMaxWidthPx,`${t}/mobileMaxWidthPx`,320,1600),s=Z(o.desktopMinWidthPx,`${t}/desktopMinWidthPx`,320,1600);return s!==n+1&&p("NATIVE_FRONTEND_DEVICE_POLICY_INVALID",t),{kind:"viewport-family",mobileMaxWidthPx:n,desktopMinWidthPx:s}}function Ki(e,t){let o=N(e,t);h(o,["code","desktop","mobile"],t);let n=w(o.code,`${t}/code`),s=ln(o.desktop,`${t}/desktop`),i=ln(o.mobile,`${t}/mobile`);return(s===i||i==="/"||!i.startsWith("/m/"))&&p("NATIVE_ROUTE_MANIFEST_ROOT_ENTRY_INVALID",t),s.startsWith("/m/")&&p("NATIVE_ROUTE_MANIFEST_ROOT_ENTRY_INVALID",`${t}/desktop`),{code:n,desktop:s,mobile:i}}function Hi(e,t){let o=N(e,t);h(o,["desktop","mobile"],t);let n=Zn(o.desktop,`${t}/desktop`,!1),s=Zn(o.mobile,`${t}/mobile`,!0);return(n.routeCode===s.routeCode||n.path===s.path)&&p("NATIVE_ROUTE_MANIFEST_AUTHENTICATION_DUPLICATE",t),{desktop:n,mobile:s}}function Zn(e,t,o){let n=N(e,t);h(n,["routeCode","path"],t);let s=w(n.routeCode,`${t}/routeCode`),i=ln(n.path,`${t}/path`);return(o?!i.startsWith("/m/"):i.startsWith("/m/"))&&p("NATIVE_ROUTE_MANIFEST_AUTHENTICATION_PATH_INVALID",`${t}/path`),{routeCode:s,path:i}}function ln(e,t){let o=ue(e,t);return/[:*?#\\\\]/.test(o)&&p("NATIVE_ROUTE_MANIFEST_STATIC_PATH_INVALID",t),o}function eo(e,t,o){let n=N(e,t);h(n,["routeCode","path","surface","pathParams","requiresAuthentication"],t,["capability","access"]),w(n.routeCode,`${t}/routeCode`);let s=ue(n.path,`${t}/path`),i=R(n.surface,`${t}/surface`,16);["admin","user"].includes(i)||p("NATIVE_ROUTE_SURFACE_INVALID",`${t}/surface`);let c=v(n.pathParams,`${t}/pathParams`,8);return c.forEach((r,a)=>{(!/^[A-Za-z][A-Za-z0-9_]*$/.test(r)||r.length>64)&&p("NATIVE_ROUTE_PATH_PARAM_INVALID",`${t}/pathParams/${a}`)}),Q(c)!==Q(Oo(s))&&p("NATIVE_ROUTE_PATH_PARAMS_MISMATCH",`${t}/pathParams`),_n(n,t,o),n.requiresAuthentication!==!0&&p("NATIVE_ROUTE_AUTHENTICATION_REQUIRED",`${t}/requiresAuthentication`),n}function Oo(e){return j([...e.matchAll(/:([A-Za-z][A-Za-z0-9_]*)/g)].map(t=>t[1]))}function to(e,t,o,n){return{routeCode:e,path:t,surface:o,pathParams:Oo(t),...n?.capability?{capability:n.capability}:{},...n?.access?{access:n.access}:{},requiresAuthentication:!0}}function no(e,t,o,n){return e==="workflow-launch"?`workflow.${o}.launch.${t}`:e==="application-todo-center"?`application.todo-center.${t}`:e==="resource-records"?`user.${n}.records.${t}`:e==="resource-submit"?`user.${n}.submit.${t}`:`${e.replace(/-/g,".")}.${t}`}function Xi(e){let t=e.appCode,o=[],n=(I,l,E,T,g,A,m)=>{o.push({code:I,kind:l,...g?{workflowCode:g}:{},...m?{resourceCode:m}:{},desktop:to(no(l,"desktop",g,m),E,"user",A),mobile:to(no(l,"mobile",g,m),T,"user",A)})};e.frontend.user.applicationTodoCenter===!0&&n("application:todo-center","application-todo-center","/todos","/m/todos");let s=yo(e);s.length>0&&(n("workflow:work-center","workflow-work-center","/work-center","/m/work-center"),n("workflow:task","workflow-task","/tasks/:taskId","/m/tasks/:taskId"),n("workflow:instance","workflow-instance","/workflows/:instanceId","/m/workflows/:instanceId"));for(let I of s){if(!["standalone","hidden-handoff"].includes(I.launch.mode))continue;let l=j([I.launch.submission?.create?.requiredCapability,I.launch.submission?.existing?.requiredCapability].filter(E=>!!E));n(`workflow:${I.code}:launch`,"workflow-launch","/workflows/:workflowCode/start","/m/workflows/:workflowCode/start",I.code,l.length===1?{capability:l[0]}:l.length>1?{access:{anyOf:l}}:void 0)}let i=o.sort((I,l)=>ae(String(I.code),String(l.code))),c=Ct(e),r=I=>{let l=I==="mobile"?"/m/":"/",E=c.filter(g=>g.surface==="user"&&!/[:*?#\\\\]/.test(g.path)&&g.path===l).sort((g,A)=>ae(g.code,A.code))[0];if(E)return{code:E.code,path:E.path};let T=c.filter(g=>g.surface==="user"&&!/[:*?#\\\\]/.test(g.path)&&(I==="mobile"?g.path.startsWith("/m/"):!g.path.startsWith("/m/"))).sort((g,A)=>ae(g.code,A.code))[0];return T?{code:T.code,path:T.path}:{code:I==="mobile"?"application-root-mobile":"application-root",path:l}},a=e.frontend.authentication?{desktop:{routeCode:e.frontend.authentication.surfaces.desktop.routeCode,path:e.frontend.authentication.surfaces.desktop.path},mobile:{routeCode:e.frontend.authentication.surfaces.mobile.routeCode,path:e.frontend.authentication.surfaces.mobile.path}}:{desktop:{routeCode:"application-login",path:"/login"},mobile:{routeCode:"application-login-mobile",path:"/m/login"}},f=pn(e.frontend.devicePolicy,"/config/frontend/devicePolicy"),_=r("desktop"),d=r("mobile"),u={schemaVersion:_o,appCode:t,devicePolicy:f,rootEntry:{code:_.code,desktop:_.path,mobile:d.path},authentication:a,routes:i};return{...u,digest:ee(u)}}function Nt(e,t){if(e===void 0)return;let o=R(e,t,32);ui.has(o)||p("NATIVE_ADMIN_ICON_INVALID",t)}function oo(e,t){e!==void 0&&Z(e,t,-1e4,1e4)}function _n(e,t,o){return e.capability!==void 0&&e.access!==void 0&&p("NATIVE_ROUTE_ACCESS_CONFLICT",`${t}/access`),e.capability!==void 0?{capability:Ce(e.capability,`${t}/capability`,o)}:e.access===void 0?{}:{access:bt(e.access,`${t}/access`,o)}}function bt(e,t,o){let n=N(e,t);h(n,["allOf","anyOf"],t,!0);let s=n.allOf===void 0?void 0:j(v(n.allOf,`${t}/allOf`,50).map((c,r)=>Ce(c,`${t}/allOf/${r}`,o))),i=n.anyOf===void 0?void 0:j(v(n.anyOf,`${t}/anyOf`,50).map((c,r)=>Ce(c,`${t}/anyOf/${r}`,o)));return(s?.length||0)+(i?.length||0)===0&&p("NATIVE_ROUTE_ACCESS_EMPTY",t),{...s===void 0?{}:{allOf:s},...i===void 0?{}:{anyOf:i}}}function yo(e){let t=new Map(Io(e).map(s=>[String(s.code),s])),o=e.workflows.definitions.map((s,i)=>{let c=`/config/workflows/definitions/${i}`,r=N(s,c);h(r,["version","definition","launch"],c,["detailRouteCode"]);let a=N(r.definition,`${c}/definition`),f=r.detailRouteCode===void 0?void 0:$o(r.detailRouteCode,`${c}/detailRouteCode`);return{code:w(a.code,`${c}/definition/code`),title:R(a.title,`${c}/definition/title`,255),version:xe(r.version,`${c}/version`),launch:Qi(e,a,r.launch,`${c}/launch`,t),...f?{detailRouteCode:f}:{},definition:a}});return j(o.map(s=>s.code)).map(s=>{let i=o.filter(f=>f.code===s),c=e.workflows.activations.find(f=>f.workflowCode===s)?.definitionVersion,r=i.find(f=>f.version===c)||[...i].sort((f,_)=>_.version-f.version)[0],a=new Set;for(let f of i){let _=N(f.definition.nodes,"/config/workflows/definitions/nodes");for(let d of Object.values(_)){let u=N(d,"/config/workflows/definitions/nodes/*");if(u.kind==="approval")for(let I of v(u.allowedOperations||[],"/config/workflows/definitions/nodes/*/allowedOperations",20))a.add(I)}}return{code:s,title:r.title,acceptedCommandDeactivationPolicy:r.definition.acceptedCommandDeactivationPolicy,subject:r.definition.subject,launch:r.launch,...["standalone","hidden-handoff"].includes(r.launch.mode)&&!r.launch.submission?{processOperationCode:`openxiangda.workflow.${s}.submit`}:{},...r.detailRouteCode?{detailRouteCode:r.detailRouteCode}:{},definitionVersions:fo(i.map(f=>f.version)),bindingVersions:fo(e.workflows.bindings.map((f,_)=>{let d=`/config/workflows/bindings/${_}`,u=N(f,d),I=N(u.binding,`${d}/binding`);return{code:w(I.workflowCode,`${d}/binding/workflowCode`),version:xe(u.version,`${d}/version`)}}).filter(f=>f.code===s).map(f=>f.version)),providerCodes:j(e.workflows.providers.map((f,_)=>w(N(f,`/config/workflows/providers/${_}`).code,`/config/workflows/providers/${_}/code`))),allowedOperations:[...a].sort(ae),editableParameterCodes:j(e.workflows.editableParameters.map((f,_)=>{let d=`/config/workflows/editableParameters/${_}`,u=N(f,d);return{code:w(u.code,`${d}/code`),workflowCode:w(u.workflowCode,`${d}/workflowCode`)}}).filter(f=>f.workflowCode===s).map(f=>f.code))}})}function ho(e,t){let o=N(e,t);h(o,["mode"],t,["submission"]);let n=R(o.mode,`${t}/mode`,32);return["standalone","custom-page","hidden-handoff","work-center-only"].includes(n)||p("NATIVE_WORKFLOW_LAUNCH_MODE_INVALID",`${t}/mode`),{mode:n,...o.submission===void 0?{}:{submission:N(o.submission,`${t}/submission`)}}}function Qi(e,t,o,n,s){let i=ho(o,n);if(!i.submission)return{mode:i.mode};["standalone","hidden-handoff"].includes(i.mode)||p("NATIVE_WORKFLOW_NAMED_OPERATION_SUBMISSION_INVALID",`${n}/submission`);let c=N(i.submission,`${n}/submission`);h(c,["kind"],`${n}/submission`,["create","existing","context"]),x(c.kind,"named-operation",`${n}/submission/kind`);let r=n.endsWith("/launch")?n.slice(0,-7):n,a=N(t.subject,`${r}/definition/subject`),f=G(a.resourceCode,`${r}/definition/subject/resourceCode`),_=e.data.resources.findIndex(b=>b.code===f),d=e.data.resources[_];(_<0||!d)&&p("NATIVE_WORKFLOW_SUBJECT_RESOURCE_MISSING",`${r}/definition/subject/resourceCode`);let u=new Set(N(d.schema,`/config/data/resources/${_}/schema`).fields.map(b=>String(b.code))),I=new Map(e.backend.operations.map(b=>[String(b.code),b])),l=(b,y)=>{let S=`${n}/submission/${y}`,P=N(b,S);h(P,["operationCode","inputs","output"],S);let F=w(P.operationCode,`${S}/operationCode`),J=I.get(F),M=s.get(F),fe=M?.platformAccess?.workflow?.codes;(!J||!M||M.method!=="POST"||!Array.isArray(fe)||!fe.includes(t.code))&&p("NATIVE_WORKFLOW_NAMED_OPERATION_INVALID",S);let pe=N(J.requestSchema,`${S}/operation/requestSchema`),K=N(pe.properties,`${S}/operation/requestSchema/properties`),me=new Set(pe.required===void 0?[]:v(pe.required,`${S}/operation/requestSchema/required`,64)),ie=N(P.inputs,`${S}/inputs`),V=Object.entries(ie);(!V.length||V.length>64)&&p("NATIVE_WORKFLOW_NAMED_OPERATION_INPUT_INVALID",`${S}/inputs`);let U=new Set,L=new Map,W={};for(let[q,H]of V){(!Hn.test(q)||!Object.prototype.hasOwnProperty.call(K,q))&&p("NATIVE_WORKFLOW_NAMED_OPERATION_INPUT_INVALID",`${S}/inputs/${q}`);let $e=`${S}/inputs/${q}`,yt=N(H,$e),Oe=R(yt.source,`${$e}/source`,32);if(["field","idempotency-key","current-user-reference","subject-id","subject-revision","requested-at"].includes(Oe)||p("NATIVE_WORKFLOW_NAMED_OPERATION_INPUT_INVALID",$e),h(yt,["source"],$e,Oe==="field"?["fieldCode"]:!1),L.set(Oe,(L.get(Oe)||0)+1),Oe==="field"){let Ye=B(yt.fieldCode,`${$e}/fieldCode`);(U.has(Ye)||!u.has(Ye))&&p("NATIVE_WORKFLOW_NAMED_OPERATION_INPUT_INVALID",`${$e}/fieldCode`),U.add(Ye),W[q]={source:Oe,fieldCode:Ye}}else W[q]={source:Oe}}([...me].some(q=>!(q in ie))||(L.get("idempotency-key")||0)!==1||!V.some(([q,H])=>N(H,`${S}/inputs/${q}`).source==="idempotency-key"&&me.has(q))||y==="create"&&((L.get("subject-id")||0)>0||(L.get("subject-revision")||0)>0)||y==="existing"&&((L.get("subject-id")||0)!==1||(L.get("subject-revision")||0)!==1))&&p("NATIVE_WORKFLOW_NAMED_OPERATION_INPUT_INVALID",`${S}/inputs`);let z=N(P.output,`${S}/output`);h(z,["subjectId"],`${S}/output`,["subjectRevision","processCommand"]);let Ie=N(N(J.responseSchema,`${S}/operation/responseSchema`).properties,`${S}/operation/responseSchema/properties`);for(let q of["subjectId","subjectRevision","processCommand"]){if(z[q]===void 0)continue;let H=R(z[q],`${S}/output/${q}`,128);(!Hn.test(H)||!Object.prototype.hasOwnProperty.call(Ie,H))&&p("NATIVE_WORKFLOW_NAMED_OPERATION_OUTPUT_INVALID",`${S}/output/${q}`)}return{operationCode:F,method:"POST",path:M.path,requiredCapability:M.requiredCapability,requestSchemaDigest:M.requestSchemaDigest,responseSchemaDigest:M.responseSchemaDigest,inputs:W,output:{...z},fieldCodes:U}},E=c.create===void 0?void 0:l(c.create,"create"),T=c.existing===void 0?void 0:l(c.existing,"existing");!E&&!T&&p("NATIVE_WORKFLOW_NAMED_OPERATION_SUBMISSION_INVALID",`${n}/submission`);let g=new Set([...E?.fieldCodes||[],...T?.fieldCodes||[]]),A=c.context===void 0?[]:$(c.context,`${n}/submission/context`,16),m=new Set,O=A.map((b,y)=>{let S=`${n}/submission/context/${y}`,P=N(b,S);h(P,["queryParameter","fieldCode"],S);let F=R(P.queryParameter,`${S}/queryParameter`,64),J=B(P.fieldCode,`${S}/fieldCode`);return(!/^[A-Za-z][A-Za-z0-9]{0,63}$/.test(F)||m.has(F)||!g.has(J))&&p("NATIVE_WORKFLOW_LAUNCH_CONTEXT_INVALID",S),m.add(F),{queryParameter:F,fieldCode:J}}),C=b=>{let{fieldCodes:y,...S}=b;return S};return{mode:i.mode,submission:{kind:"named-operation",...E?{create:C(E)}:{},...T?{existing:C(T)}:{},context:O}}}function $o(e,t){let o=N(e,t);h(o,["desktop","mobile"],t);let n=w(o.desktop,`${t}/desktop`),s=w(o.mobile,`${t}/mobile`);return n===s&&p("NATIVE_WORKFLOW_DETAIL_ROUTE_DUPLICATE",t),{desktop:n,mobile:s}}function Zi(e,t){let o=new Set(t.map(_=>_.code)),n=new Map;e.data.resources.forEach((_,d)=>{let u=`/config/data/resources/${d}`,I=N(_,u);for(let[T,g]of Object.entries(I.fieldPolicies||{})){if(!Se(T))continue;let A=`${u}/fieldPolicies/${T}/read`,m=N(g,`${u}/fieldPolicies/${T}`);for(let O of v(m.read||[],A,2e3))o.has(O)||p("NATIVE_CAPABILITY_REFERENCE_MISSING",A)}let l=I.surface===void 0?{}:N(I.surface,`${u}/surface`);if(["native","queued-command"].includes(l.mutationOwner||"native"))return;let E=N(I.capabilities,`${u}/capabilities`);for(let T of["create","update","delete"])n.set(String(E[T]),T)});let s=new Set;for(let[_,d]of e.authz.roles.entries()){let u=`/config/authz/roles/${_}`,I=N(d,u);h(I,["code","name","description","capabilities"],u,!0);let l=w(I.code,`${u}/code`);s.has(l)&&p("NATIVE_ROLE_DUPLICATE",`${u}/code`),s.add(l),R(I.name,`${u}/name`,255);let E=v(I.capabilities,`${u}/capabilities`,2e3);for(let[T,g]of E.entries())n.has(g)&&p("NATIVE_DATA_SURFACE_MUTATION_GRANT_FORBIDDEN",`${u}/capabilities/${T}`,{operation:n.get(g)}),o.has(g)||p("NATIVE_CAPABILITY_REFERENCE_MISSING",`${u}/capabilities`)}let i=e.authz.authenticatedUserRoleCode===void 0?"":w(e.authz.authenticatedUserRoleCode,"/config/authz/authenticatedUserRoleCode");i&&!s.has(i)&&p("NATIVE_AUTHENTICATED_USER_ROLE_REFERENCE_MISSING","/config/authz/authenticatedUserRoleCode");let c=new Set,r=0;for(let[_,d]of e.perspectives.entries()){let u=`/config/perspectives/${_}`,I=N(d,u);h(I,["code","name","description","roleCodes","capabilityCodes","default"],u,!0);let l=w(I.code,`${u}/code`);c.has(l)&&p("NATIVE_PERSPECTIVE_DUPLICATE",`${u}/code`),c.add(l),R(I.name,`${u}/name`,255);let E=v(I.roleCodes,`${u}/roleCodes`,20);E.length<1&&p("NATIVE_PERSPECTIVE_ROLE_REQUIRED",`${u}/roleCodes`),E.forEach((A,m)=>{s.has(A)||p("NATIVE_PERSPECTIVE_ROLE_MISSING",`${u}/roleCodes/${m}`)});let T=j(e.authz.roles.filter(A=>E.includes(A.code)).flatMap(A=>A.capabilities)),g=v(I.capabilityCodes,`${u}/capabilityCodes`,2e3);Q(T)!==Q(g)&&p("NATIVE_PERSPECTIVE_CAPABILITY_PROJECTION_MISMATCH",`${u}/capabilityCodes`),I.default===!0?r+=1:I.default!==void 0&&p("NATIVE_PERSPECTIVE_DEFAULT_INVALID",`${u}/default`)}r>1&&p("NATIVE_PERSPECTIVE_DEFAULT_DUPLICATE","/config/perspectives");for(let[_,d]of e.backend.operations.entries()){let u=N(d,`/config/backend/operations/${_}`);o.has(u.capability)||p("NATIVE_CAPABILITY_REFERENCE_MISSING",`/config/backend/operations/${_}/capability`)}let a=new Set,f=new Set;for(let[_,d]of e.frontend.routes.entries()){let u=`/config/frontend/routes/${_}`,I=N(d,u),l=w(I.code,`${u}/code`);a.has(l)&&p("NATIVE_ROUTE_DUPLICATE",`${u}/code`),a.add(l);let E=ue(I.path,`${u}/path`);f.has(E)&&p("NATIVE_ROUTE_PATH_DUPLICATE",`${u}/path`),f.add(E);let T=_n(I,u,e.appCode);T.capability&&!o.has(T.capability)&&p("NATIVE_CAPABILITY_REFERENCE_MISSING",`${u}/capability`);let g=I.access===void 0?void 0:N(I.access,`${u}/access`);for(let A of["allOf","anyOf"]){let m=g?.[A]===void 0?[]:$(g[A],`${u}/access/${A}`,50);for(let[O,C]of m.entries()){let b=Ce(C,`${u}/access/${A}/${O}`,e.appCode);o.has(b)||p("NATIVE_CAPABILITY_REFERENCE_MISSING",`${u}/access/${A}/${O}`)}}}if(e.frontend.admin.access!==void 0){let _=bt(e.frontend.admin.access,"/config/frontend/admin/access",e.appCode);for(let d of["allOf","anyOf"])for(let[u,I]of(_[d]||[]).entries())o.has(I)||p("NATIVE_CAPABILITY_REFERENCE_MISSING",`/config/frontend/admin/access/${d}/${u}`)}for(let[_,d]of e.frontend.routes.entries()){let u=N(d,`/config/frontend/routes/${_}`);u.parentCode&&!a.has(u.parentCode)&&p("NATIVE_ROUTE_PARENT_MISSING",`/config/frontend/routes/${_}/parentCode`)}}function er(e){let t=new Set(e.authz.roles.map(f=>String(f.code))),o=e.authz.authenticatedUserRoleCode===void 0?"":w(e.authz.authenticatedUserRoleCode,"/config/authz/authenticatedUserRoleCode"),n=new Map(e.authz.scopeDimensions.map(f=>[String(f.code),{valueType:f.valueType==="uuid"?"uuid":"string",...f.valueSource?.resourceCode?{valueSourceResourceCode:String(f.valueSource.resourceCode)}:{}}])),s=new Set(n.keys()),i=new Map(e.data.resources.map((f,_)=>{let d=he(f,`/config/data/resources/${_}`,e.appCode);return[d.code,new Map(d.schema.fields.map(u=>[String(u.code),u]))]}));for(let[f,_]of e.authz.scopeDimensions.entries()){let d=`/config/authz/scopeDimensions/${f}`,u=N(_,d);if(h(u,["code","name","resourceCode","valueType","hierarchyMode","valueSource"],d,!0),u.valueSource===void 0)continue;let I=N(u.valueSource,`${d}/valueSource`);h(I,["kind","resourceCode","labelField","enabledField"],`${d}/valueSource`,!0),I.kind!=="native_resource"&&p("NATIVE_SCOPE_VALUE_SOURCE_KIND_INVALID",`${d}/valueSource/kind`),u.valueType!=="uuid"&&p("NATIVE_SCOPE_VALUE_SOURCE_TYPE_INVALID",`${d}/valueType`);let l=G(I.resourceCode,`${d}/valueSource/resourceCode`),E=i.get(l);E||p("NATIVE_SCOPE_VALUE_SOURCE_RESOURCE_MISSING",`${d}/valueSource/resourceCode`);let T=B(I.labelField,`${d}/valueSource/labelField`);if(["text.short","text.long"].includes(String(E.get(T)?.type||""))||p("NATIVE_SCOPE_VALUE_SOURCE_LABEL_FIELD_INVALID",`${d}/valueSource/labelField`),I.enabledField!==void 0){let g=B(I.enabledField,`${d}/valueSource/enabledField`);E.get(g)?.type!=="boolean"&&p("NATIVE_SCOPE_VALUE_SOURCE_ENABLED_FIELD_INVALID",`${d}/valueSource/enabledField`)}}let c=new Set,r=new Set;for(let[f,_]of e.authz.scopeSources.entries()){let d=`/config/authz/scopeSources/${f}`,u=N(_,d);h(u,["code","name","resourceCode","subject","grants","operationField","enabledField","effectiveFromField","effectiveToField","failureMode"],d,!0);let I=w(u.code,`${d}/code`);c.has(I)&&p("NATIVE_SCOPE_SOURCE_DUPLICATE",`${d}/code`),c.add(I),R(u.name,`${d}/name`,255);let l=G(u.resourceCode,`${d}/resourceCode`),E=i.get(l);E||p("NATIVE_SCOPE_SOURCE_RESOURCE_MISSING",`${d}/resourceCode`);let T=N(u.subject,`${d}/subject`),g=R(T.type,`${d}/subject/type`,32);h(T,g==="role_membership"?["type","userIdField","roleCode"]:["type","userIdField"],`${d}/subject`),["user","role_membership"].includes(g)||p("NATIVE_SCOPE_SOURCE_SUBJECT_INVALID",`${d}/subject/type`);let A=ve(T.userIdField,E);ft(A)||p("NATIVE_SCOPE_SOURCE_SUBJECT_PATH_INVALID",`${d}/subject/userIdField`),g==="role_membership"&&!t.has(String(T.roleCode))&&p("NATIVE_ROLE_REFERENCE_MISSING",`${d}/subject/roleCode`);let m=new Set;for(let[O,C]of $(u.grants,`${d}/grants`,100).entries()){let b=`${d}/grants/${O}`,y=N(C,b);h(y,["dimensionCode","valueField","parentValueField"],b,!0);let S=w(y.dimensionCode,`${b}/dimensionCode`);(!s.has(S)||m.has(S))&&p("NATIVE_SCOPE_SOURCE_DIMENSION_INVALID",`${b}/dimensionCode`),m.add(S),u.failureMode==="last_known_good"&&r.add(S);for(let P of["valueField","parentValueField"]){if(y[P]===void 0)continue;let F=ve(y[P],E);Xt(F,n.get(S),i)||p("NATIVE_SCOPE_SOURCE_GRANT_PATH_INVALID",`${b}/${P}`)}}m.size===0&&p("NATIVE_SCOPE_SOURCE_GRANT_REQUIRED",`${d}/grants`),["strict","last_known_good"].includes(u.failureMode)||p("NATIVE_SCOPE_SOURCE_FAILURE_MODE_INVALID",`${d}/failureMode`);for(let O of["operationField","enabledField","effectiveFromField","effectiveToField"]){if(u[O]===void 0)continue;let C=B(u[O],`${d}/${O}`);E.has(C)||p("NATIVE_SCOPE_SOURCE_FIELD_MISSING",`${d}/${O}`)}}nr(e,t,i,o);let a=new Set;for(let[f,_]of e.authz.dataPolicies.entries()){let d=`/config/authz/dataPolicies/${f}`,u=N(_,d);h(u,["code","name","resourceCode","unrestrictedRoleCodes","operations","matchMode","rules","readExpression","writeBoundary"],d,!0);let I=w(u.code,`${d}/code`);a.has(I)&&p("NATIVE_DATA_POLICY_DUPLICATE",`${d}/code`),a.add(I);let l=u.readExpression!==void 0,E=v(u.operations||[],`${d}/operations`,4);u.operations!==void 0&&(E.length===0||E.some(C=>!["read","create","update","delete"].includes(C)))&&p("NATIVE_DATA_POLICY_OPERATIONS_INVALID",`${d}/operations`),["AND","OR"].includes(u.matchMode)||p("NATIVE_DATA_POLICY_MATCH_MODE_INVALID",`${d}/matchMode`),l&&u.operations!==void 0&&p("NATIVE_DATA_POLICY_READ_EXPRESSION_OPERATIONS_FORBIDDEN",`${d}/operations`);let T=e.data.resources.find(C=>C.dataPolicyCode===I),g=u.resourceCode||T?.code,A=g?i.get(G(g,`${d}/resourceCode`)):void 0;l&&!A&&p("NATIVE_DATA_POLICY_RESOURCE_MISSING",`${d}/resourceCode`);let m=v(u.unrestrictedRoleCodes||[],`${d}/unrestrictedRoleCodes`,100);u.unrestrictedRoleCodes!==void 0&&m.length===0&&p("NATIVE_DATA_POLICY_UNRESTRICTED_ROLES_INVALID",`${d}/unrestrictedRoleCodes`);for(let C of m)t.has(C)||p("NATIVE_ROLE_REFERENCE_MISSING",`${d}/unrestrictedRoleCodes`);let O;try{let C=$(u.rules,`${d}/rules`,100).map((b,y)=>({rule:N(b,`${d}/rules/${y}`),pointer:`${d}/rules/${y}`}));C.length===0?(!l||u.matchMode!=="AND"||u.writeBoundary!=="capability_only")&&p("NATIVE_DATA_POLICY_WRITE_BOUNDARY_REQUIRED",d):u.writeBoundary!==void 0&&p("NATIVE_DATA_POLICY_WRITE_BOUNDARY_INVALID",`${d}/writeBoundary`),O=[...C],l&&(O.push(...ze(u.readExpression,`${d}/readExpression`)),an(u.readExpression,`${d}/readExpression`))}catch(C){throw C instanceof Le&&p(C.code,C.pointer),C}for(let{rule:C,pointer:b}of O){h(C,["subject","dimensionCode","relationCode","resourceCode","field","roleCodes","operation","valuePath","emptyMatchesAll","operator","value","operand"],b,!0);let y=B(C.field,`${b}/field`),S=A?.get(y);l&&!S&&p("NATIVE_DATA_POLICY_FIELD_MISSING",`${b}/field`);for(let K of v(C.roleCodes||[],`${b}/roleCodes`,100))t.has(K)||p("NATIVE_ROLE_REFERENCE_MISSING",`${b}/roleCodes`);let P=String(C.operator||""),F=C.operand==="db_now",J=["is_null","is_not_null"].includes(P),M=["eq","not_eq","in","not_in"].includes(P),fe=!F&&(C.operator!==void 0||C.value!==void 0);if([C.subject==="current_user"?"current_user":"",typeof C.dimensionCode=="string"?"dimension":"",typeof C.relationCode=="string"?"relationship":"",fe?"constant":"",F?"db_now":""].filter(Boolean).length!==1&&p("NATIVE_DATA_POLICY_RULE_SOURCE_INVALID",b),C.subject!==void 0&&C.subject!=="current_user"&&p("NATIVE_DATA_POLICY_SUBJECT_INVALID",`${b}/subject`),fe){if(!M&&!J&&p("NATIVE_DATA_POLICY_OPERATOR_INVALID",`${b}/operator`),["in","not_in"].includes(P)){let K=$(C.value,`${b}/value`,100).map((me,ie)=>R(me,`${b}/value/${ie}`,2048));(K.length===0||new Set(K).size!==K.length)&&p("NATIVE_DATA_POLICY_VALUE_INVALID",`${b}/value`)}else["eq","not_eq"].includes(P)?R(C.value,`${b}/value`,2048):(C.value!==void 0||C.operand!==void 0)&&p("NATIVE_DATA_POLICY_VALUE_INVALID",`${b}/value`);for(let K of["operation","valuePath","emptyMatchesAll","resourceCode","operand"])C[K]!==void 0&&p("NATIVE_DATA_POLICY_CONSTANT_RULE_INVALID",`${b}/${K}`)}if(F){(!["lt","lte","gt","gte"].includes(P)||C.value!==void 0||S?.type!=="datetime")&&p("NATIVE_DATA_POLICY_DB_NOW_INVALID",b);for(let K of["operation","valuePath","emptyMatchesAll","resourceCode","value"])C[K]!==void 0&&p("NATIVE_DATA_POLICY_DB_NOW_INVALID",`${b}/${K}`)}C.dimensionCode&&!s.has(C.dimensionCode)&&p("NATIVE_SCOPE_DIMENSION_MISSING",`${b}/dimensionCode`),r.has(String(C.dimensionCode||""))&&C.operation!=="read"&&p("NATIVE_SCOPE_SOURCE_LAST_KNOWN_GOOD_UNSAFE",`${b}/operation`)}}for(let[f,_]of e.data.resources.entries()){let d=N(_,`/config/data/resources/${f}`);d.dataPolicyCode&&!a.has(d.dataPolicyCode)&&p("NATIVE_DATA_POLICY_REFERENCE_MISSING",`/config/data/resources/${f}/dataPolicyCode`)}}function tr(e){try{Vt(e.data.resources,"/config/data/resources")}catch(t){throw t instanceof de&&p(t.code,t.pointer),t}}function nr(e,t,o,n){let s=new Set;for(let[i,c]of e.authz.roleMembershipSources.entries()){let r=`/config/authz/roleMembershipSources/${i}`,a=N(c,r);h(a,["code","name","resourceCode","userIdField","roleCode","enabledField","effectiveFromField","effectiveToField","failureMode"],r,!0);let f=w(a.code,`${r}/code`);f.length>100&&p("NATIVE_AUTHORIZATION_PROJECTION_SOURCE_CODE_INVALID",`${r}/code`),s.has(f)&&p("NATIVE_AUTHORIZATION_PROJECTION_SOURCE_DUPLICATE",`${r}/code`),s.add(f),R(a.name,`${r}/name`,255);let _=so(a.resourceCode,`${r}/resourceCode`,o);io(a.userIdField,`${r}/userIdField`,_),t.has(String(a.roleCode||""))||p("NATIVE_ROLE_REFERENCE_MISSING",`${r}/roleCode`),n&&a.roleCode===n&&p("NATIVE_AUTHENTICATED_USER_ROLE_SOURCE_CONFLICT",`${r}/roleCode`),ro(a,r,_)}for(let[i,c]of e.authz.relationshipGrantSources.entries()){let r=`/config/authz/relationshipGrantSources/${i}`,a=N(c,r);h(a,["code","name","resourceCode","subject","relationCode","targetResourceCode","resourceIdField","operations","enabledField","effectiveFromField","effectiveToField","failureMode"],r,!0);let f=w(a.code,`${r}/code`);f.length>100&&p("NATIVE_AUTHORIZATION_PROJECTION_SOURCE_CODE_INVALID",`${r}/code`),s.has(f)&&p("NATIVE_AUTHORIZATION_PROJECTION_SOURCE_DUPLICATE",`${r}/code`),s.add(f),R(a.name,`${r}/name`,255);let _=so(a.resourceCode,`${r}/resourceCode`,o),d=N(a.subject,`${r}/subject`),u=R(d.type,`${r}/subject/type`,32);h(d,u==="role_membership"?["type","userIdField","roleCode"]:["type","userIdField"],`${r}/subject`),["user","role_membership"].includes(u)||p("NATIVE_AUTHORIZATION_PROJECTION_SUBJECT_INVALID",`${r}/subject/type`),io(d.userIdField,`${r}/subject/userIdField`,_),u==="role_membership"&&!t.has(String(d.roleCode||""))&&p("NATIVE_ROLE_REFERENCE_MISSING",`${r}/subject/roleCode`),w(a.relationCode,`${r}/relationCode`);let I=G(a.targetResourceCode,`${r}/targetResourceCode`);o.has(I)||p("NATIVE_AUTHORIZATION_PROJECTION_TARGET_RESOURCE_MISSING",`${r}/targetResourceCode`);let l=ve(a.resourceIdField,_),E=l?.field.type==="resource-ref.single"&&l.valuePath==="value"&&l.field.source?.resourceCode===I;(a.resourceIdField==="id"?I!==String(a.resourceCode):!E)&&p("NATIVE_AUTHORIZATION_PROJECTION_RESOURCE_ID_FIELD_INVALID",`${r}/resourceIdField`);let T=v(a.operations,`${r}/operations`,20);(T.length===0||T.some(g=>g.length>64||!/^[A-Za-z0-9][A-Za-z0-9:._*-]{0,63}$/.test(g)))&&p("NATIVE_AUTHORIZATION_PROJECTION_OPERATIONS_INVALID",`${r}/operations`),ro(a,r,_)}}function so(e,t,o){let n=G(e,t),s=o.get(n);return s||p("NATIVE_AUTHORIZATION_PROJECTION_RESOURCE_MISSING",t),s}function io(e,t,o){let n=ve(e,o);ft(n)||p("NATIVE_AUTHORIZATION_PROJECTION_USER_FIELD_INVALID",t)}function ro(e,t,o){if(e.failureMode!=="strict"&&p("NATIVE_AUTHORIZATION_PROJECTION_FAILURE_MODE_INVALID",`${t}/failureMode`),e.enabledField!==void 0){let n=B(e.enabledField,`${t}/enabledField`);o.get(n)?.type!=="boolean"&&p("NATIVE_AUTHORIZATION_PROJECTION_ENABLED_FIELD_INVALID",`${t}/enabledField`)}for(let n of["effectiveFromField","effectiveToField"]){if(e[n]===void 0)continue;let s=B(e[n],`${t}/${n}`);["date","datetime"].includes(String(o.get(s)?.type))||p("NATIVE_AUTHORIZATION_PROJECTION_EFFECTIVE_FIELD_INVALID",`${t}/${n}`)}}function or(e){let t=new Set,o=new Set;e.forEach((n,s)=>{let i=`/config/backend/secrets/${s}`,c=N(n,i);h(c,["name","env","description","required","exposure"],i,!0);let r=R(c.name,`${i}/name`,128),a=R(c.env,`${i}/env`,128);oi.test(r)||p("NATIVE_SECRET_NAME_INVALID",`${i}/name`),(!si.test(a)||a.startsWith("OPENXIANGDA_")||["NODE_ENV","PORT"].includes(a))&&p("NATIVE_SECRET_ENV_INVALID",`${i}/env`),t.has(r)&&p("NATIVE_SECRET_NAME_DUPLICATE",`${i}/name`),o.has(a)&&p("NATIVE_SECRET_ENV_DUPLICATE",`${i}/env`),t.add(r),o.add(a),x(c.exposure,"active_only",`${i}/exposure`),c.required!==void 0&&Ue(c.required,`${i}/required`),c.description!==void 0&&En(c.description,`${i}/description`,2e3)})}function sr(e){let t=new Set,o=new Map,n=new Map(e.data.resources.map(u=>[String(u.code),u])),s=new Map(e.frontend.routes.map((u,I)=>{let l=N(u,`/config/frontend/routes/${I}`);return[w(l.code,`/config/frontend/routes/${I}/code`),l]}));for(let[u,I]of e.workflows.definitions.entries()){let l=`/config/workflows/definitions/${u}`,E=N(I,l);if(h(E,["version","definition","launch"],l,["detailRouteCode"]),ho(E.launch,`${l}/launch`),E.detailRouteCode!==void 0){let m=$o(E.detailRouteCode,`${l}/detailRouteCode`);for(let[O,C,b]of[["desktop",m.desktop,["admin","user"]],["mobile",m.mobile,["user"]]]){let y=`${l}/detailRouteCode/${O}`,S=s.get(C);S||p("NATIVE_WORKFLOW_DETAIL_ROUTE_MISSING",y),b.some(J=>J===S.surface)||p("NATIVE_WORKFLOW_DETAIL_ROUTE_SURFACE_INVALID",y);let P=ue(S.path,y),F=[...P.matchAll(/:([A-Za-z][A-Za-z0-9_]*)/g)].map(J=>J[1]);(P.includes("*")||F.length!==1||F[0]!=="instanceId")&&p("NATIVE_WORKFLOW_DETAIL_ROUTE_PATH_INVALID",y)}}let T=N(E.definition,`${l}/definition`),g=`${T.code}:${xe(E.version,`${l}/version`)}`;t.has(g)&&p("NATIVE_WORKFLOW_DEFINITION_DUPLICATE",l),t.add(g),rr(T,`${l}/definition`),ir(T.subject,n,`${l}/definition/subject`);let A=sn(T,{appCode:e.appCode,capabilities:e.authz.capabilities.map(m=>m.code),fields:new Map((n.get(T.subject.resourceCode)?.schema.fields||[]).map(m=>[m.code,m]))});A.length&&p("NATIVE_WORKFLOW_INSTANCE_COMMAND_POLICY_INVALID",`${l}/definition/instanceCommands`,{errors:A}),T.title===T.code&&p("NATIVE_WORKFLOW_USER_TITLE_REQUIRED",`${l}/definition/title`),o.set(g,T)}let i=new Set,c=new Map;for(let[u,I]of e.workflows.bindings.entries()){let l=N(I,`/config/workflows/bindings/${u}`),E=N(l.binding,`/config/workflows/bindings/${u}/binding`),T=`${E.workflowCode}:${xe(l.version,`/config/workflows/bindings/${u}/version`)}`;i.has(T)&&p("NATIVE_WORKFLOW_BINDING_DUPLICATE",`/config/workflows/bindings/${u}`),i.add(T),ar(E,`/config/workflows/bindings/${u}/binding`),c.set(T,E)}let r=new Set,a=new Map;for(let[u,I]of e.workflows.activations.entries()){let l=`/config/workflows/activations/${u}`,E=N(I,l);h(E,["workflowCode","definitionVersion","bindingVersion","acceptedCommandDeactivationPolicy"],l,["environmentKey"]);let T=w(E.workflowCode,`${l}/workflowCode`);r.has(T)&&p("NATIVE_WORKFLOW_ACTIVATION_DUPLICATE",l),r.add(T);let g=`${T}:${xe(E.definitionVersion,`${l}/definitionVersion`)}`,A=`${T}:${xe(E.bindingVersion,`${l}/bindingVersion`)}`;t.has(g)||p("NATIVE_WORKFLOW_DEFINITION_REFERENCE_MISSING",`${l}/definitionVersion`),i.has(A)||p("NATIVE_WORKFLOW_BINDING_REFERENCE_MISSING",`${l}/bindingVersion`);let m=o.get(g),O=c.get(A);(!["finish-pinned","cancel-on-deactivate"].includes(E.acceptedCommandDeactivationPolicy)||E.acceptedCommandDeactivationPolicy!==m.acceptedCommandDeactivationPolicy)&&p("NATIVE_WORKFLOW_COMMAND_DEACTIVATION_POLICY_MISMATCH",`${l}/acceptedCommandDeactivationPolicy`),cr(m,O,`/config/workflows/activations/${u}`),a.set(T,O)}let f=new Set;e.workflows.providers.forEach((u,I)=>{let l=`/config/workflows/providers/${I}`,E=N(u,l);h(E,["code","endpointPath","timeoutMs"],l,!0);let T=w(E.code,`${l}/code`);f.has(T)&&p("NATIVE_WORKFLOW_PROVIDER_DUPLICATE",`${l}/code`),f.add(T),ue(E.endpointPath,`${l}/endpointPath`),E.timeoutMs!==void 0&&Z(E.timeoutMs,`${l}/timeoutMs`,100,1e4)});for(let[u,I]of a.entries())for(let[l,E]of Object.entries(N(I.bindings,"/config/workflows/bindings/*/binding/bindings"))){let T=N(E,`/config/workflows/${u}/bindings/${l}`);T.provider==="application_provider"&&!f.has(T.providerCode)&&p("NATIVE_WORKFLOW_PROVIDER_REFERENCE_MISSING",`/config/workflows/${u}/bindings/${l}/providerCode`)}let _=new Set(e.authz.roles.map(u=>u.code)),d=new Set;e.workflows.editableParameters.forEach((u,I)=>{let l=`/config/workflows/editableParameters/${I}`,E=N(u,l);h(E,["code","workflowCode","bindingKey","label","valueType","required","allowedRoleCodes","allowedProviderCodes","maxItems"],l,!0);let T=w(E.code,`${l}/code`);d.has(T)&&p("NATIVE_WORKFLOW_EDITABLE_PARAMETER_DUPLICATE",`${l}/code`),d.add(T);let g=Ot(E.workflowCode,`${l}/workflowCode`),A=An(E.bindingKey,`${l}/bindingKey`),m=a.get(g);(!m||!N(m.bindings,`${l}/bindingKey`)[A])&&p("NATIVE_WORKFLOW_EDITABLE_BINDING_MISSING",`${l}/bindingKey`),R(E.label,`${l}/label`,255),["role_code","user_ids","provider_code"].includes(E.valueType)||p("NATIVE_WORKFLOW_EDITABLE_VALUE_TYPE_INVALID",`${l}/valueType`);for(let O of v(E.allowedRoleCodes||[],`${l}/allowedRoleCodes`,100))_.has(O)||p("NATIVE_ROLE_REFERENCE_MISSING",`${l}/allowedRoleCodes`);for(let O of v(E.allowedProviderCodes||[],`${l}/allowedProviderCodes`,100))f.has(O)||p("NATIVE_WORKFLOW_PROVIDER_REFERENCE_MISSING",`${l}/allowedProviderCodes`);E.required!==void 0&&Ue(E.required,`${l}/required`),E.maxItems!==void 0&&Z(E.maxItems,`${l}/maxItems`,1,200)})}function ir(e,t,o){let n=N(e,o);h(n,["resourceCode","factProjection"],o,["summaryFields"]);let s=G(n.resourceCode,`${o}/resourceCode`),i=t.get(s);i||p("NATIVE_WORKFLOW_SUBJECT_RESOURCE_MISSING",`${o}/resourceCode`);let c=new Set($(N(i.schema,`${o}/resourceCode`).fields,`${o}/resourceCode`,500).map((f,_)=>B(N(f,`${o}/resourceCode/${_}`).code,`${o}/resourceCode/${_}`))),r=N(n.factProjection,`${o}/factProjection`),a=Object.entries(r);(a.length<1||a.length>64)&&p("NATIVE_WORKFLOW_SUBJECT_FACT_PROJECTION_INVALID",`${o}/factProjection`);for(let[f,_]of a){ai.test(f)||p("NATIVE_WORKFLOW_SUBJECT_FACT_KEY_INVALID",`${o}/factProjection/${f}`);let d=B(_,`${o}/factProjection/${f}`);c.has(d)||p("NATIVE_WORKFLOW_SUBJECT_FIELD_MISSING",`${o}/factProjection/${f}`)}if(n.summaryFields!==void 0){let f=v(n.summaryFields,`${o}/summaryFields`,ci).map((l,E)=>B(l,`${o}/summaryFields/${E}`)),_=t.get(s),d=_.surface&&typeof _.surface=="object"&&!Array.isArray(_.surface)?_.surface:{},u=d.fields&&typeof d.fields=="object"&&!Array.isArray(d.fields)?d.fields:{},I=new Map($(N(_.schema,`${o}/resourceCode`).fields,`${o}/resourceCode`,500).map((l,E)=>{let T=N(l,`${o}/resourceCode/${E}`);return[String(T.code),T]}));for(let[l,E]of f.entries()){let T=I.get(E),g=u[E],A=String(T?.type||""),m=T?.maxLength;(!T||T.system===!0||g&&typeof g=="object"&&!Array.isArray(g)&&g.system===!0||["id","revision","created_by","updated_by","created_at","updated_at"].includes(E)||!li.has(A)||A==="text.long"&&typeof m=="number"&&Number.isFinite(m)&&m>di)&&p("NATIVE_WORKFLOW_SUBJECT_SUMMARY_FIELDS_INVALID",`${o}/summaryFields/${l}`)}}}function rr(e,t){h(e,["schemaVersion","code","title","subject","acceptedCommandDeactivationPolicy","startAt","inputSchema","nodes"],t,["organizationContext","instanceCommands"]),x(e.schemaVersion,"openxiangda.workflow-definition/v2",`${t}/schemaVersion`),Ot(e.code,`${t}/code`),R(e.title,`${t}/title`,255),["finish-pinned","cancel-on-deactivate"].includes(e.acceptedCommandDeactivationPolicy)||p("NATIVE_WORKFLOW_COMMAND_DEACTIVATION_POLICY_REQUIRED",`${t}/acceptedCommandDeactivationPolicy`);let o=N(e.nodes,`${t}/nodes`),n=Object.keys(o);(n.length===0||n.length>200)&&p("NATIVE_WORKFLOW_NODE_COUNT_INVALID",`${t}/nodes`);let s=R(e.startAt,`${t}/startAt`,128);o[s]||p("NATIVE_WORKFLOW_START_NODE_MISSING",`${t}/startAt`);let i=new Map;for(let[f,_]of Object.entries(o)){let d=`${t}/nodes/${f}`,u=N(_,d);x(u.id,f,`${d}/id`),["approval","condition","end"].includes(u.kind)||p("NATIVE_WORKFLOW_NODE_KIND_INVALID",`${d}/kind`);let I=[];if(u.kind==="approval"){R(u.title,`${d}/title`,255),An(u.binding,`${d}/binding`),["single","any","all","sequence"].includes(u.mode)||p("NATIVE_WORKFLOW_APPROVAL_MODE_INVALID",`${d}/mode`),I.push(R(u.onApprove,`${d}/onApprove`,128),R(u.onReject,`${d}/onReject`,128));for(let l of v(u.returnTargets||[],`${d}/returnTargets`,200))o[l]||p("NATIVE_WORKFLOW_TARGET_MISSING",`${d}/returnTargets`);for(let l of v(u.allowedOperations||[],`${d}/allowedOperations`,20))fi.has(l)||p("NATIVE_WORKFLOW_OPERATION_INVALID",`${d}/allowedOperations`)}else if(u.kind==="condition"){let l=$(u.branches,`${d}/branches`,100);l.length===0&&p("NATIVE_WORKFLOW_BRANCH_REQUIRED",`${d}/branches`),l.forEach((E,T)=>{let g=N(E,`${d}/branches/${T}`);Ge(g.when,`${d}/branches/${T}/when`,0),I.push(R(g.target,`${d}/branches/${T}/target`,128))}),I.push(R(u.otherwise,`${d}/otherwise`,128))}else R(u.title,`${d}/title`,255),R(u.outcome,`${d}/outcome`,128);for(let l of I)o[l]||p("NATIVE_WORKFLOW_TARGET_MISSING",d);i.set(f,I)}let c=new Set,r=new Set,a=f=>{if(r.has(f)&&p("NATIVE_WORKFLOW_CYCLE_FORBIDDEN",`${t}/nodes/${f}`),!c.has(f)){c.add(f),r.add(f);for(let _ of i.get(f)||[])a(_);r.delete(f)}};a(s),c.size!==n.length&&p("NATIVE_WORKFLOW_NODE_UNREACHABLE",`${t}/nodes`)}function Ge(e,t,o){o>20&&p("NATIVE_WORKFLOW_EXPRESSION_DEPTH_EXCEEDED",t);let n=N(e,t),s=R(n.op,`${t}/op`,16);if(s!=="literal"){if(s==="path"){let i=R(n.path,`${t}/path`,255);/^[A-Za-z][A-Za-z0-9_.]{0,254}$/.test(i)||p("NATIVE_WORKFLOW_EXPRESSION_PATH_INVALID",`${t}/path`);return}if(["eq","neq","gt","gte","lt","lte","in","contains"].includes(s)){Ge(n.left,`${t}/left`,o+1),Ge(n.right,`${t}/right`,o+1);return}if(["and","or"].includes(s)){let i=$(n.values,`${t}/values`,100);i.length===0&&p("NATIVE_WORKFLOW_EXPRESSION_EMPTY",`${t}/values`),i.forEach((c,r)=>Ge(c,`${t}/values/${r}`,o+1));return}if(["not","exists"].includes(s)){Ge(n.value,`${t}/value`,o+1);return}p("NATIVE_WORKFLOW_EXPRESSION_OPERATOR_INVALID",`${t}/op`)}}function ar(e,t){x(e.schemaVersion,"openxiangda.workflow-binding/v2",`${t}/schemaVersion`),Ot(e.workflowCode,`${t}/workflowCode`);let o=N(e.bindings,`${t}/bindings`);Object.keys(o).length>200&&p("NATIVE_WORKFLOW_BINDING_LIMIT_EXCEEDED",`${t}/bindings`);for(let[n,s]of Object.entries(o)){An(n,`${t}/bindings/${n}`);let i=N(s,`${t}/bindings/${n}`),c=R(i.provider,`${t}/bindings/${n}/provider`,64);["fixed_users","initiator","input_users","form_field_users","department_supervisor","app_role","app_role_in_scope","business_relation","previous_node_actor","initiator_select","application_provider"].includes(c)||p("NATIVE_WORKFLOW_BINDING_PROVIDER_INVALID",`${t}/bindings/${n}/provider`),c==="fixed_users"&&$(i.users,`${t}/bindings/${n}/users`,200).length===0&&p("NATIVE_WORKFLOW_BINDING_USERS_REQUIRED",`${t}/bindings/${n}/users`),["input_users","form_field_users"].includes(c)&&R(i.inputPath,`${t}/bindings/${n}/inputPath`,255),["app_role","app_role_in_scope","initiator_select"].includes(c)&&w(i.roleCode,`${t}/bindings/${n}/roleCode`),c==="department_supervisor"&&R(i.departmentIdFrom,`${t}/bindings/${n}/departmentIdFrom`,255),c==="application_provider"&&w(i.providerCode,`${t}/bindings/${n}/providerCode`)}}function cr(e,t,o){x(t.workflowCode,e.code,`${o}/workflowCode`);let n=N(t.bindings,`${o}/bindings`);for(let[s,i]of Object.entries(N(e.nodes,`${o}/nodes`))){let c=N(i,`${o}/nodes/${s}`);c.kind==="approval"&&!n[c.binding]&&p("NATIVE_WORKFLOW_BINDING_REFERENCE_MISSING",`${o}/nodes/${s}/binding`)}}function dr(e,t,o){let n=N(t.routeManifest,"/contracts/routeManifest"),s=N(e.routeManifest,"/contracts/routeManifest"),i=new Map;for(let _ of $(o.data?.resources,"/config/data/resources",100)){let d=N(_,"/config/data/resources");i.set(String(d.code||""),d)}let c=new Set($(s.routes,"/contracts/routeManifest/routes",1e3).map(_=>String(N(_,"/contracts/routeManifest/routes").code||""))),r=[];for(let _ of $(n.routes,"/contracts/routeManifest/routes",1e3)){let d=N(_,"/contracts/routeManifest/routes"),u=String(d.kind||"");if(u!=="resource-records"&&u!=="resource-submit")continue;let I=String(d.resourceCode||""),l=i.get(I);l||p("NATIVE_ROUTE_MANIFEST_RESOURCE_UNKNOWN","/contracts/routeManifest/routes");let T=`user.${I}.${u==="resource-records"?"records":"submit"}`;x(String(d.code||""),T,"/contracts/routeManifest/routes/code");let g=u==="resource-records"?"read":"create",A=String(N(l.capabilities,"/config/data/resources/capabilities")[g]||"");for(let m of["desktop","mobile"]){let O=N(d[m],`/contracts/routeManifest/routes/${m}`),C=m==="mobile"?"/m/my/":"/my/",b=u==="resource-records"?`${C}${I}`:`${C}${I}/submit`;x(String(O.path||""),b,`/contracts/routeManifest/routes/${m}/path`),x(String(O.capability||""),A,`/contracts/routeManifest/routes/${m}/capability`),x(String(O.routeCode||""),`${T}.${m}`,`/contracts/routeManifest/routes/${m}/routeCode`)}(c.has(T)||r.some(m=>String(m.code)===T))&&p("NATIVE_ROUTE_MANIFEST_DUPLICATE","/contracts/routeManifest/routes/code"),r.push(d)}if(!r.length)return;s.routes=$([...s.routes,...r],"/contracts/routeManifest/routes",1e3).sort((_,d)=>ae(String(N(_,"x").code||""),String(N(d,"x").code||"")));let a=String(N(n.rootEntry,"x").code||"");if(r.find(_=>String(_.code)===a&&_.kind==="resource-records")){let _=N(n.rootEntry,"x");s.rootEntry={code:a,desktop:String(_.desktop||""),mobile:String(_.mobile||"")}}s.digest=ee({schemaVersion:s.schemaVersion,appCode:s.appCode,devicePolicy:s.devicePolicy,rootEntry:s.rootEntry,authentication:s.authentication,routes:s.routes})}function he(e,t,o){let n=N(e,t);h(n,["schemaVersion","appCode","code","name","schema","surface","invariants","decimalReservationLifecycle","uniqueKeys","capabilities","dataPolicyCode","fieldPolicies"],t,!0),x(n.schemaVersion,"openxiangda.data-resource/v2",`${t}/schemaVersion`),x(n.appCode,o,`${t}/appCode`);let s=G(n.code,`${t}/code`),i=R(n.name,`${t}/name`,255),c=N(n.schema,`${t}/schema`);h(c,["fields"],`${t}/schema`);let r,a,f,_;try{f=ct(n.decimalReservationLifecycle,`${t}/decimalReservationLifecycle`),r=Ze(c.fields,`${t}/schema/fields`),_=tn(n.uniqueKeys,r,`${t}/uniqueKeys`),a=wt(n.invariants,r,`${t}/invariants`),st(n.surface,r,`${t}/surface`)}catch(l){throw(l instanceof de||l instanceof ye||l instanceof Pe)&&p(l.code,l.pointer),l}let d=new Set(r.map(l=>l.code)),u=N(n.capabilities,`${t}/capabilities`);h(u,["read","create","update","delete"],`${t}/capabilities`);let I=N(n.fieldPolicies,`${t}/fieldPolicies`);for(let[l,E]of Object.entries(I)){!d.has(l)&&!Se(l)&&p("NATIVE_DATA_FIELD_POLICY_FIELD_MISSING",`${t}/fieldPolicies/${l}`);let T=`${t}/fieldPolicies/${l}`,g=N(E,T);Se(l)&&(h(g,["read"],T,!0),(!Array.isArray(g.read)||g.read.length>20||g.read.some(A=>typeof A!="string"||!A.trim())||new Set(g.read).size!==g.read.length)&&p("NATIVE_DATA_AUDIT_READ_POLICY_INVALID",`${T}/read`)),h(g,["read","create","update","mask"],T,!0),g.mask!==void 0&&!["omit","null"].includes(g.mask)&&p("NATIVE_DATA_FIELD_POLICY_MASK_INVALID",`${T}/mask`)}return{...n,code:s,name:i,schema:{fields:r},...n.invariants===void 0?{}:{invariants:a},...f?{decimalReservationLifecycle:f}:{},..._!==void 0?{uniqueKeys:_}:{},capabilities:u,fieldPolicies:I}}function Ro(e){return[{code:`app:${e}:directory:read`,kind:"platform",name:"\u8BFB\u53D6\u53D7\u9650\u7EC4\u7EC7\u76EE\u5F55",source:"platform"},...[["app:role:read","\u67E5\u770B\u89D2\u8272\u4E0E\u6388\u6743"],["app:role:define","\u5B9A\u4E49\u624B\u5DE5\u89D2\u8272"],["app:role:assign","\u5206\u914D\u89D2\u8272\u6210\u5458"],["app:role:grant-capability","\u6388\u4E88\u89D2\u8272\u80FD\u529B"],["app:scope-grant:manage","\u7BA1\u7406\u6570\u636E\u8303\u56F4"],["app:super-admin:manage","\u7BA1\u7406\u5E94\u7528\u6700\u9AD8\u7BA1\u7406\u5458"]].map(([t,o])=>({code:t,kind:"platform",name:o,source:"platform"}))]}function ao(e,t,o,n){let s=e.toString("utf8"),i;try{i=JSON.parse(s)}catch{p(o,t)}let c=N(i,t);return Q(c)!==s&&p(n,t),c}function co(e,t){let o=0,n=(s,i,c)=>{if(o+=1,o>Ai&&p("NATIVE_ARTIFACT_NODE_LIMIT_EXCEEDED",i),c>Ei&&p("NATIVE_ARTIFACT_DEPTH_LIMIT_EXCEEDED",i),typeof s=="string"){Buffer.byteLength(s)>dn&&p("NATIVE_ARTIFACT_STRING_LIMIT_EXCEEDED",i);return}if(Array.isArray(s)){s.forEach((r,a)=>n(r,`${i}/${a}`,c+1));return}if(!(!s||typeof s!="object"))for(let[r,a]of Object.entries(s))["__proto__","prototype","constructor"].includes(r)&&p("NATIVE_ARTIFACT_DANGEROUS_KEY",`${i}/${r}`),lr(r)&&p("NATIVE_ARTIFACT_RUNTIME_FIELD_FORBIDDEN",`${i}/${r}`),n(a,`${i}/${r}`,c+1)};n(e,t,0)}function lr(e){return["environmentKey","environmentId","secretValue","ciphertext","oauthClient","oauthClientId","oauthClientSecret","signingSecret","kubernetesNamespace","nodePort","productionUrl"].includes(e)}function ke(e){return{value:e,digest:ee(e)}}function lo(e,t,o,n){typeof e!="string"&&!Buffer.isBuffer(e)&&!(e instanceof Uint8Array)&&p("NATIVE_ARTIFACT_BYTES_REQUIRED",o);let s=Buffer.isBuffer(e)?e:Buffer.from(e);return s.byteLength===0&&p("NATIVE_ARTIFACT_EMPTY",o),s.byteLength>t&&p(n,o),s}function uo(e,t,o,n){let s=Tt.createHash("sha256").update(e).digest("hex");Tt.timingSafeEqual(Buffer.from(s),Buffer.from(t))||p(n,o)}function N(e,t){return(!e||typeof e!="object"||Array.isArray(e))&&p("NATIVE_OBJECT_REQUIRED",t),e}function $(e,t,o){return Array.isArray(e)||p("NATIVE_ARRAY_REQUIRED",t),e.length>o&&p("NATIVE_ARRAY_LIMIT_EXCEEDED",t),e}function v(e,t,o){let n=$(e,t,o).map((s,i)=>R(s,`${t}/${i}`,255));return new Set(n).size!==n.length&&p("NATIVE_ARRAY_DUPLICATE",t),n}function R(e,t,o){return(typeof e!="string"||e.length===0||e.length>o)&&p("NATIVE_STRING_INVALID",t),e}function En(e,t,o){return(typeof e!="string"||e.length>o)&&p("NATIVE_STRING_INVALID",t),e}function w(e,t){let o=R(e,t,128);return Zs.test(o)||p("NATIVE_CODE_INVALID",t),o}function G(e,t){let o=R(e,t,64);return ti.test(o)||p("NATIVE_RESOURCE_CODE_INVALID",t),o}function B(e,t){let o=R(e,t,63);return ni.test(o)||p("NATIVE_FIELD_CODE_INVALID",t),o}function Ot(e,t){let o=R(e,t,128);return ii.test(o)||p("NATIVE_WORKFLOW_CODE_INVALID",t),o}function An(e,t){let o=R(e,t,128);return ri.test(o)||p("NATIVE_WORKFLOW_BINDING_CODE_INVALID",t),o}function Ce(e,t,o){let n=R(e,t,255);return Qs.test(n)||p("NATIVE_CAPABILITY_CODE_INVALID",t),!n.startsWith(`app:${o}:`)&&!Ro(o).some(s=>s.code===n)&&p("NATIVE_CAPABILITY_APP_MISMATCH",t),n}function ue(e,t){let o=R(e,t,2048);return(!o.startsWith("/")||o.startsWith("//")||o.includes("..")||o.includes("?")||o.includes("#"))&&p("NATIVE_ABSOLUTE_PATH_INVALID",t),o}function xe(e,t){return(!Number.isInteger(e)||Number(e)<1)&&p("NATIVE_POSITIVE_INTEGER_REQUIRED",t),Number(e)}function Z(e,t,o,n){return(!Number.isInteger(e)||Number(e)<o||Number(e)>n)&&p("NATIVE_INTEGER_OUT_OF_RANGE",t),Number(e)}function Ue(e,t){return typeof e!="boolean"&&p("NATIVE_BOOLEAN_REQUIRED",t),e}function un(e,t){let o=R(e,t,64).toLowerCase();return Hs.test(o)||p("NATIVE_DIGEST_INVALID",t),o}function x(e,t,o){e!==t&&p("NATIVE_VALUE_MISMATCH",o)}function h(e,t,o,n=!1){let s=new Set([...t,...Array.isArray(n)?n:[]]);for(let i of Object.keys(e))s.has(i)||p("NATIVE_PROPERTY_UNKNOWN",`${o}/${i}`);if(n!==!0)for(let i of t)Object.prototype.hasOwnProperty.call(e,i)||p("NATIVE_PROPERTY_REQUIRED",`${o}/${i}`)}function X(e,t){return[...e].sort((o,n)=>ae(t(o),t(n)))}function j(e){return[...new Set(e)].sort(ae)}function fo(e){return[...new Set(e)].sort((t,o)=>t-o)}function ae(e,t){return e===t?0:e<t?-1:1}function So(e){return!e||typeof e!="object"||Object.isFrozen(e)||(Object.freeze(e),Object.values(e).forEach(t=>So(t))),e}function fn(e,t,o){if(cn(e,t))return o;if(Array.isArray(e)&&Array.isArray(t)){let n=Math.max(e.length,t.length);for(let s=0;s<n;s+=1)if(!cn(e[s],t[s]))return fn(e[s],t[s],`${o}/${s}`)}if(e&&t&&typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)){let n=j([...Object.keys(e),...Object.keys(t)]);for(let s of n){let i=e[s],c=t[s];if(!cn(i,c))return fn(i,c,`${o}/${s}`)}}return o}function cn(e,t){return e===void 0||t===void 0?e===t:Q(e)===Q(t)}function p(e,t,o={}){throw new It(e,t,o)}var ur="b7ac11f81972d310db01573232792d62a070632d07ae8d0fef19c4e100488f8b";0&&(module.exports={DATA_AUDIT_METADATA_FIELDS,DATA_EVENT_TYPES_V2,DATA_SYSTEM_SORT_FIELD_CODES,ManagedConcurrencyContractError,NATIVE_CONFIGURATION_VALIDATOR_DIGEST,NATIVE_CONTRACT_CAPACITY_V2,NATIVE_DATA_POLICY_EXPRESSION_MAX_CLAUSES,NATIVE_DATA_POLICY_EXPRESSION_MAX_DEPTH,NATIVE_DATA_POLICY_EXPRESSION_MAX_GROUP_ITEMS,NATIVE_DATA_POLICY_EXPRESSION_MAX_LEAVES,NATIVE_DATA_POLICY_EXPRESSION_MAX_OCCURRENCES,NATIVE_DATA_QUERY_OPERATORS_V2,NATIVE_UNIQUE_KEY_MAX_BYTES,NATIVE_UNIQUE_KEY_NORMALIZERS,NativeConfigurationCompilerError,NativeDataFieldContractV2Error,NativeDataPolicyExpressionV2Error,NativeDecimalLifecycleContractError,NativeEventActionContractError,NativeScopeSourceFieldPathV2Error,NativeUniqueKeyContractError,OPENXIANGDA_NATIVE_DATA_FIELD_TYPES_V2,OPENXIANGDA_NATIVE_DATA_SURFACE_KEYS_V2,OPENXIANGDA_NATIVE_DRAFT_STATE_KEYS_V2,OPENXIANGDA_NATIVE_SYSTEM_FIELDS_V2,OPENXIANGDA_NATIVE_SYSTEM_FIELD_MAP_V2,WORKFLOW_EVENT_TYPES_V2,compileNativeApplicationConfiguration,compileNativeEventAction,compileNativeEventCapturePlansV2,compileRequiredPlatformCapabilitiesV3,hasDataAuditReadPolicy,isDataAuditMetadataField,isDataSystemSortField,isNativeDataQueryOperatorV2,isNativeMultiValueFieldV2,materializeNativeDataQueryPathTypesV2,nativeDataPolicyExpressionLeavesV2,nativeDataPolicyExpressionToCnfV2,nativeDataQueryPathPlanV2,nativeFieldAggregatePlanV2,nativeFieldColumnDefinitionV2,nativeFieldDefaultSqlV2,nativeFieldHasDefaultV2,nativeFieldIndexStatementsV2,nativeFieldRequiresCreateInputV2,nativeFieldSequenceGrantStatementsV2,nativeFieldSequenceOwnershipStatementsV2,nativeFieldSequenceStatementsV2,nativeFieldSupportsFilterV2,nativeFieldSupportsOperatorV2,nativeFieldSupportsSearchV2,nativeFieldSupportsSortV2,nativeOperatorsForFieldV2,nativePhysicalFieldV2,nativePhysicalFieldsV2,nativePhysicalObjectNameV2,nativeScopeSourceFieldValueV2,nativeScopeSourceGrantPathSupportedV2,nativeScopeSourceSubjectPathSupportedV2,nativeSubtableConstraintStatementsV2,nativeUniqueKeysJsonSchema,parseDecimalReservationLifecycle,parseNativeDataFieldsV2,parseNativeDataResourceInvariantsV2,parseNativeUniqueKeys,projectNativeDataResourceViewV2,quoteNativeIdentifierV2,resolveNativeScopeSourceFieldPathV2,validateDecimalReservationLifecycles,validateManagedConcurrency,validateNativeDataDraftStateV2,validateNativeDataResourceReferencesV2,validateNativeDataResourceSurfaceV2,validateWorkflowInstanceCommandPolicies,workflowInstanceCommandDeadlineError,workflowInstanceTerminateCapabilityAllowed,workflowPolicyTimestamp});
|
|
8
|
+
END $native_subtable$`]}function Re(e,...t){return`${e}_${(0,Uo.createHash)("sha256").update(t.join(":")).digest("hex").slice(0,32)}`}function oe(e){if(!/^[A-Za-z_][A-Za-z0-9_]{0,62}$/.test(e))throw new Error("OPENXIANGDA_NATIVE_IDENTIFIER_INVALID");return`"${e}"`}function ir(e,t){return e.type==="subtable"?"none":t?"gin-trigram":e.indexed?["date-range","datetime-range"].includes(e.type)?"gist-range":Wn.has(e.type)?"btree-snapshot-expressions":Gs.has(e.type)?"gin-jsonb-path":"btree":"none"}function sr(e){switch(e.type){case"text.short":return`varchar(${e.maxLength??255})`;case"text.long":case"text.rich":return"text";case"number.integer":return"bigint";case"number.decimal":return`numeric(${e.precision??38},${e.scale??10})`;case"boolean":return"boolean";case"date":return"date";case"time":return"time(0)";case"datetime":return"timestamptz";case"date-range":return"daterange";case"datetime-range":return"tstzrange";case"uuid":return"uuid";case"serial-number":return"varchar(255)";case"subtable":return"child-resource";default:return Js.has(e.type),"jsonb"}}function Go(e,t){if(at(t.type)&&t.type!=="subtable")return"'[]'::jsonb";if(t.type!=="serial-number")return"";let o=Wo(t.serial?.prefix||""),n=t.serial?.digits??6;return`(${o} || lpad(nextval(${Wo(Wt(e,t.code))})::text, ${n}, '0'))`}function rr(e,t){return Bo.has(t.type)?` CHECK (${e} IS NULL OR jsonb_typeof(${e}) = 'array')`:qs.has(t.type)?` CHECK (${e} IS NULL OR jsonb_typeof(${e}) = 'object')`:""}function Mt(e){return`"app_data".${oe(e)}`}function Wt(e,t){let o=Re("seq",e,t);return`"app_data".${oe(o)}`}function Wo(e){return`'${e.replace(/'/g,"''")}'`}var qo=new Set(["option.single","option.multiple","user.single","user.multiple","department.single","department.multiple","resource-ref.single","resource-ref.multiple"]),ar=new Set([...qo,"cascade.single","cascade.multiple","file","image","signature","address","location","json"]),Jo=/^[A-Za-z][A-Za-z0-9_]{0,62}$/,cr=new Set(["__proto__","prototype","constructor"]),Ut=class extends Error{constructor(o){super("OPENXIANGDA_SCOPE_PROJECTION_FIELD_PATH_INVALID");this.path=o;this.name="NativeScopeSourceFieldPathV2Error"}path;code="OPENXIANGDA_SCOPE_PROJECTION_FIELD_PATH_INVALID"};function He(e,t){let o=zo(e);if(!o)return null;let n=t.get(o[0]);if(!n)return null;let i=o.slice(1).join(".")||void 0;return{field:n,...i?{valuePath:i}:{}}}function Bt(e){return!!(e&&e.field.type==="user.single"&&e.valuePath==="value")}function Un(e,t,o){if(!e||!t||!lr(e))return!1;let{field:n,valuePath:i}=e;if(!i)return t.valueType==="uuid"?n.type==="uuid":["text.short","text.long","serial-number"].includes(n.type);if(i==="value")return!(t.valueSourceResourceCode&&n.type.startsWith("resource-ref.")&&n.source?.resourceCode!==t.valueSourceResourceCode);let s=i.slice(9),r=o.get(n.source?.resourceCode||"")?.get(s)?.type;return t.valueType==="uuid"?r==="uuid":["text.short","text.long","serial-number"].includes(r||"")}function dr(e,t){let o=zo(t);if(!o)throw new Ut(String(t||""));let n=e;for(let i of o){if(!n||typeof n!="object"||!Object.prototype.hasOwnProperty.call(n,i))return;n=n[i]}return n}function lr(e){let{field:t,valuePath:o}=e;if(!o)return!ar.has(t.type);if(o==="value")return qo.has(t.type);if(!o.startsWith("snapshot."))return!1;let n=o.slice(9);return Jo.test(n)&&t.type.startsWith("resource-ref.")&&!!t.source?.snapshotFields?.includes(n)}function zo(e){if(typeof e!="string"||e.length===0||e.length>192)return null;let t=e.split(".");return![1,2,3].includes(t.length)||t.some(o=>!Jo.test(o)||cr.has(o))||t.length===2&&t[1]!=="value"||t.length===3&&t[1]!=="snapshot"?null:t}var ur=new Set(["option.single","user.single","department.single","resource-ref.single"]),fr=new Set(["text.short","text.long","text.rich","number.integer","number.decimal","boolean","date","time","datetime","uuid","serial-number"]),pr=new Set(["value","label","description","color"]),mr=new Set(["avatarUrl","employeeNo","title","mobile","email"]),_r=new Set(["fullPath","parent.value","parent.label"]),gr=new Set(["country.value","country.label","province.value","province.label","city.value","city.label","district.value","district.label","street.value","street.label","detail","fullAddress"]),Ar=new Set(["longitude","latitude","accuracy"]),Er=new Set(["address","name","province","city","district","source"]);function Ir(e){let t=new Map(e.map(o=>[o.code,new Map(o.schema.fields.map(n=>[n.code,n]))]));return e.map(o=>({...o,schema:{...o.schema,fields:o.schema.fields.map(n=>{let i=yr(n,t);if(!Object.keys(i).length)return n;let s={...n};return Object.defineProperty(s,"queryPathTypes",{configurable:!1,enumerable:!1,writable:!1,value:Object.freeze(i)}),s})}}))}function Nr(e,t){if(ur.has(e.type)&&pr.has(t)||e.type==="user.single"&&mr.has(t)||e.type==="department.single"&&_r.has(t))return lt(t);if(e.type==="resource-ref.single"){let o=e.queryPathTypes?.[t];return o?{parts:t.split("."),type:o}:null}if(e.type==="address"&&gr.has(t))return lt(t);if(e.type==="location"){if(Ar.has(t))return{parts:[t],type:"number.decimal"};if(Er.has(t))return lt(t);if(t==="capturedAt")return{parts:[t],type:"datetime"}}return null}function yr(e,t){if(e.type!=="resource-ref.single"||!e.source)return{};let o=t.get(e.source.resourceCode);return o?Object.fromEntries((e.source.snapshotFields||[]).flatMap(n=>{let i=o.get(n);return i?[[`snapshot.${n}`,fr.has(i.type)?i.type:"json"]]:[]})):{}}function lt(e){return{parts:e.split("."),type:"text.short"}}var Gn=["exact-v1","nfkc-space-v1","nfkc-upper-ascii-v1"],xc=256,Xe=class extends Error{constructor(o,n){super(`\u6761\u4EF6\u552F\u4E00\u952E\u58F0\u660E\u65E0\u6548\uFF1A${n}\uFF08${o}\uFF09`);this.pointer=o;this.reason=n}pointer;reason;code="NATIVE_UNIQUE_KEY_INVALID"},Bn=e=>!!(e&&typeof e=="object"&&!Array.isArray(e)),ie=(e,t)=>{throw new Xe(e,t)},Kt=(e,t)=>e<t?-1:e>t?1:0,Gt=(e,t,o)=>{Object.keys(e).some(n=>!t.includes(n))&&ie(o,"\u4E0D\u652F\u6301\u672A\u77E5\u5C5E\u6027")};function qn(e,t,o="/uniqueKeys"){if(e===void 0)return;if(!Array.isArray(e)||e.length>8)return ie(o,"\u6BCF\u8D44\u6E90\u6700\u591A 8 \u6761\u89C4\u5219");let n=new Map(t.map(s=>[s.code,s])),i=new Set;return e.map((s,c)=>{let r=`${o}/${c}`;if(!Bn(s))return ie(r,"\u89C4\u5219\u5FC5\u987B\u662F\u5BF9\u8C61");if(Gt(s,["code","fields","when"],r),typeof s.code!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(s.code)||s.code.length>20||i.has(s.code))return ie(`${r}/code`,"\u9700\u8981\u4E0D\u91CD\u590D\u4E14\u4E0D\u8D85\u8FC7 20 \u5B57\u7B26\u7684 lower-kebab-case \u6807\u8BC6");if(i.add(s.code),!Array.isArray(s.fields)||s.fields.length<1||s.fields.length>4)return ie(`${r}/fields`,"\u5FC5\u987B\u9009\u62E9 1 \u5230 4 \u4E2A\u5B57\u6BB5");let a=new Set,d=s.fields.map((A,N)=>{let I=`${r}/fields/${N}`;if(!Bn(A))return ie(I,"\u5B57\u6BB5\u5FC5\u987B\u662F\u5BF9\u8C61");Gt(A,["fieldCode","normalizer"],I);let m=n.get(A.fieldCode);if(!m||!["text.short","uuid","option.single","resource-ref.single"].includes(m.type)||a.has(A.fieldCode))return ie(`${I}/fieldCode`,"\u9700\u8981\u4E0D\u91CD\u590D\u7684\u77ED\u6587\u672C\u3001UUID\u3001\u5355\u9009\u6216\u5355\u8BB0\u5F55\u5F15\u7528\u5B57\u6BB5");a.add(A.fieldCode);let E=A.normalizer===void 0?"exact-v1":A.normalizer;return!Gn.includes(E)||m.type!=="text.short"&&E!=="exact-v1"?ie(`${I}/normalizer`,"\u5F52\u4E00\u5316\u65B9\u5F0F\u4E0D\u652F\u6301\u6216\u4E0E\u5B57\u6BB5\u7C7B\u578B\u4E0D\u7B26"):{fieldCode:m.code,normalizer:E}}).sort((A,N)=>Kt(A.fieldCode,N.fieldCode)),u=s.when===void 0?[]:s.when;if(!Array.isArray(u)||u.length>4)return ie(`${r}/when`,"\u6700\u591A 4 \u4E2A\u5408\u53D6\u6761\u4EF6");let l=new Set,f=u.map((A,N)=>{let I=`${r}/when/${N}`;if(!Bn(A))return ie(I,"\u6761\u4EF6\u5FC5\u987B\u662F\u5BF9\u8C61");let m=n.get(A.fieldCode);if(!m)return ie(`${I}/fieldCode`,"\u5B57\u6BB5\u4E0D\u5B58\u5728");let E;if(A.operator==="empty"||A.operator==="nonempty"){if(Gt(A,["fieldCode","operator"],I),m.type!=="text.short")return ie(I,"\u7A7A\u503C\u6761\u4EF6\u4EC5\u652F\u6301\u77ED\u6587\u672C");E={fieldCode:m.code,operator:A.operator}}else if(A.operator==="in"||A.operator==="notIn"){Gt(A,["fieldCode","operator","values"],I);let g=new Set((m.options??[]).map(O=>O.value));if(m.type!=="option.single"||!Array.isArray(A.values)||A.values.length<1||A.values.length>16||A.values.some(O=>typeof O!="string"||O.length<1||O.length>128||!g.has(O))||new Set(A.values).size!==A.values.length)return ie(I,"\u96C6\u5408\u6761\u4EF6\u9700\u8981 1 \u5230 16 \u4E2A\u4E0D\u91CD\u590D\u7684\u5DF2\u58F0\u660E\u5355\u9009\u503C");E={fieldCode:m.code,operator:A.operator,values:[...A.values].sort(Kt)}}else return ie(`${I}/operator`,"\u53EA\u652F\u6301 empty\u3001nonempty\u3001in \u548C notIn");let p=JSON.stringify(E);return l.has(p)?ie(I,"\u6761\u4EF6\u4E0D\u80FD\u91CD\u590D"):(l.add(p),E)}).sort((A,N)=>Kt(JSON.stringify(A),JSON.stringify(N)));return{code:s.code,fields:d,when:f}}).sort((s,c)=>Kt(s.code,c.code))}var Kn={type:"string",pattern:"^[A-Za-z_][A-Za-z0-9_]{0,62}$"},br={type:"array",maxItems:8,items:{type:"object",additionalProperties:!1,required:["code","fields"],properties:{code:{type:"string",maxLength:20,pattern:"^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$"},fields:{type:"array",minItems:1,maxItems:4,uniqueItems:!0,items:{type:"object",additionalProperties:!1,required:["fieldCode"],properties:{fieldCode:Kn,normalizer:{enum:[...Gn]}}}},when:{type:"array",maxItems:4,uniqueItems:!0,items:{oneOf:[{type:"object",additionalProperties:!1,required:["fieldCode","operator"],properties:{fieldCode:Kn,operator:{enum:["empty","nonempty"]}}},{type:"object",additionalProperties:!1,required:["fieldCode","operator","values"],properties:{fieldCode:Kn,operator:{enum:["in","notIn"]},values:{type:"array",minItems:1,maxItems:16,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:128}}}}]}}}}};var Yo={"openxiangda.workflow.instance.completed.v2":"commit","openxiangda.workflow.instance.rejected.v2":"release","openxiangda.workflow.instance.withdrawn.v2":"release"};function Ho(e,t){let o=()=>{throw new Error("NATIVE_EVENT_DECIMAL_RESERVATION_INVALID")},n=f=>!f||typeof f!="object"||Array.isArray(f)?o():f,i=n(e);if(Object.keys(i).some(f=>!["resourceCode","workflowCode","outcomes"].includes(f))||typeof i.resourceCode!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(i.resourceCode)||typeof i.workflowCode!="string"||!/^[A-Za-z0-9._:-]{1,128}$/.test(i.workflowCode)||t.execution!==void 0||!Array.isArray(i.outcomes)||!i.outcomes.length||i.outcomes.length>3)return o();let s=t.resources.find(f=>f.code===i.resourceCode),c=t.reservations.find(f=>f.mode==="reserve"&&f.resourceCode===i.resourceCode),r=t.workflows.find(f=>f.code===i.workflowCode);if(!s||!c||!r||r.resourceCode!==s.code)return o();let a=s.fields.find(f=>f.code===c.statusFieldCode);if(a?.type!=="option.single")return o();let d=new Set(a.options?.map(f=>f.value)),u=new Set,l=i.outcomes.map(f=>{let A=n(f),N=A.eventType;return Object.keys(A).some(I=>!["eventType","mode","eligibleChildStatuses"].includes(I))||typeof N!="string"||!Object.prototype.hasOwnProperty.call(Yo,N)||!t.eventTypes.includes(N)||u.has(N)||A.mode!==Yo[N]||!Array.isArray(A.eligibleChildStatuses)||!A.eligibleChildStatuses.length||A.eligibleChildStatuses.length>16||new Set(A.eligibleChildStatuses).size!==A.eligibleChildStatuses.length||A.eligibleChildStatuses.some(I=>typeof I!="string"||!/^[A-Za-z0-9._:-]{1,128}$/.test(I)||!d.has(I))?o():(u.add(N),{eventType:N,mode:A.mode,eligibleChildStatuses:[...A.eligibleChildStatuses].sort()})}).sort((f,A)=>f.eventType.localeCompare(A.eventType));return{resourceCode:i.resourceCode,workflowCode:i.workflowCode,outcomes:l}}function Xo(e,t){let o=n=>Array.isArray(n)?n.filter(i=>i&&typeof i=="object"&&!Array.isArray(i)):[];return{eventTypes:Array.isArray(t.eventTypes)?t.eventTypes:[],execution:t.execution,resources:o(e.data?.resources).map(n=>({code:n.code,fields:o(n.schema?.fields).map(i=>({code:i.code,type:i.type,options:o(i.options).map(s=>({value:s.value}))}))})),reservations:o(e.backend?.operations).flatMap(n=>n.platformAccess?.decimalReservation?[n.platformAccess.decimalReservation]:[]),workflows:o(e.workflows?.definitions).map(n=>({code:n.definition?.code,resourceCode:n.definition?.subject?.resourceCode}))}}var qt=class extends Error{constructor(o,n){super(n);this.pointer=o}pointer;code="NATIVE_EVENT_ACTION_INVALID"};function Jn(e,t,o="/events/subscriptions"){if(e.execution===void 0)return;let n=(I,m)=>{throw new qt(`${o}${I}`,m)},i=(I,m,E)=>((!I||typeof I!="object"||Array.isArray(I)||Object.keys(I).some(p=>!E.includes(p)))&&n(m,"Invalid action object or unsupported property"),I),s=i(e.execution,"/execution",["kind","version","operations"]);(s.kind!=="native-data"||s.version!==1)&&n("/execution","Expected native-data version 1"),e.platformAccess&&n("/platformAccess","Native actions do not use application runtime capabilities"),(!Array.isArray(e.eventTypes)||!e.eventTypes.length||e.eventTypes.some(I=>!/^openxiangda\.data\.record\.(created|updated|deleted)\.v2$/.test(I)))&&n("/eventTypes","Native data actions require declared data events");let c=e.filter?.resourceCodes;(!Array.isArray(c)||!c.length||c.length>20)&&n("/filter/resourceCodes","Native actions require explicit source resources");let r=new Map(t.map(I=>[I.code,I])),a=c.map(I=>{let m=r.get(I);return m||n("/filter/resourceCodes","Unknown source resource"),new Set((m.schema?.fields||[]).map(E=>E.code))}),d=new Set(e.payload?.fields||[]),u=e.payload?.includeChanges===!0,l=(I,m)=>{let E=i(I,m,["source","path","value"]);if(E.source==="literal"){(!Object.hasOwn(E,"value")||Object.hasOwn(E,"path"))&&n(m,"Literal binding requires only value");let y;try{y=JSON.stringify(E.value)}catch{n(m,"Literal must be JSON")}return(y===void 0||Buffer.byteLength(y)>65536)&&n(m,"Literal is too large or not JSON"),{source:"literal",value:JSON.parse(y)}}(E.source!=="event"||typeof E.path!="string"||Object.hasOwn(E,"value"))&&n(m,"Expected a literal or event binding");let p=E.path.split(".");(p.length>8||p.some(y=>!/^[A-Za-z0-9_-]+$/.test(y)||["__proto__","prototype","constructor"].includes(y)))&&n(m,"Invalid event path");let g=/^data\.projection\.([A-Za-z][A-Za-z0-9_]{0,62})$/.exec(E.path),O=/^data\.changes\.([A-Za-z][A-Za-z0-9_]{0,62})\.(before|after)$/.exec(E.path);if(g||O){let y=(g||O)[1];a.some(T=>!T.has(y))&&n(m,"Source field must exist on every filtered resource"),d.add(y),O&&(u=!0)}else["id","time","type","subject","data.recordId","data.revision","data.operation","data.resourceCode"].includes(E.path)||n(m,"Event path is not part of the data event contract");return{source:"event",path:E.path}};(!Array.isArray(s.operations)||s.operations.length<1||s.operations.length>16)&&n("/execution/operations","Expected 1 to 16 operations");let f={},A=s.operations.map((I,m)=>{let E=`/execution/operations/${m}`,p=i(I,E,["operation","resourceCode","data","id","expectedRevision"]);["create","update","delete"].includes(p.operation)||n(E,"Unsupported Native operation");let g=r.get(p.resourceCode);g||n(E,"Unknown action target resource");let O=new Map((g.schema?.fields||[]).map(T=>[T.code,T])),y=p.data===void 0?{}:i(p.data,`${E}/data`,[...O.keys()]);return Object.keys(y).length>32&&n(E,"Maximum 32 mapped fields per operation"),p.operation==="create"&&(p.id!==void 0||p.expectedRevision!==void 0)&&n(E,"Create does not accept id or expectedRevision"),p.operation==="delete"&&p.data!==void 0&&n(E,"Delete does not accept data"),Object.keys(y).some(T=>O.get(T)?.type==="serial-number")&&n(E,"Generated fields cannot be assigned"),f[p.resourceCode]=X(g),{operation:p.operation,resourceCode:p.resourceCode,...p.operation==="create"?{}:{id:l(p.id,`${E}/id`),expectedRevision:l(p.expectedRevision,`${E}/expectedRevision`)},...p.operation==="delete"?{}:{data:Object.fromEntries(Object.entries(y).map(([T,h])=>[T,l(h,`${E}/data/${T}`)]))}}});(d.size>32||[...d].some(I=>a.some(m=>!m.has(I))))&&n("/payload/fields","Payload must contain at most 32 declared source fields");let N={kind:"native-data",version:1,operations:A,resourceDigests:f};return Buffer.byteLength(JSON.stringify(N))>65536&&n("/execution","Action plan exceeds 64 KiB"),{execution:{...N,digest:X(N)},payload:{includeChanges:u,fields:[...d].sort()}}}function De(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Yn(e,t){if(e?.instanceCommands===void 0)return[];let o=De(e.instanceCommands);if(!o||!Object.keys(o).length||Object.keys(o).some(i=>!["withdraw","terminate"].includes(i)))return["WORKFLOW_INSTANCE_COMMAND_POLICIES_INVALID"];let n=[];for(let[i,s]of Object.entries(o)){let c=De(s),r=i==="withdraw"?["beforeFact"]:["beforeFact","capability"];if(!c||Object.keys(c).some(a=>!r.includes(a))){n.push(`WORKFLOW_INSTANCE_COMMAND_POLICY_INVALID:${i}`);continue}if(i==="terminate"){let a=c.capability;(typeof a!="string"||a.length>255||!/^app:[a-z][a-z0-9]*(?:-[a-z0-9]+)*:[A-Za-z0-9:._-]+$/.test(a)||t&&(!a.startsWith(`app:${t.appCode}:`)||!t.capabilities.includes(a)))&&n.push("WORKFLOW_INSTANCE_TERMINATE_CAPABILITY_INVALID")}if(i==="withdraw"||c.beforeFact!==void 0){let a=c.beforeFact,d=De(e.inputSchema),u=De(De(d?.properties)?.[a]),l=De(De(e.subject)?.factProjection)?.[a],f=t?.fields.get(l);(typeof a!="string"||!/^[A-Za-z][A-Za-z0-9_]{0,62}$/.test(a)||!Array.isArray(d?.required)||!d.required.includes(a)||u?.type!=="string"||u?.format!=="date-time"||typeof l!="string"||t&&(f?.type!=="datetime"||f.nullable===!0))&&n.push(`WORKFLOW_INSTANCE_COMMAND_DEADLINE_FACT_INVALID:${i}`)}}return n}function Tr(e,t){let o=e?.terminate?.capability;return typeof o=="string"&&/^app:[a-z][a-z0-9]*(?:-[a-z0-9]+)*:[A-Za-z0-9:._-]+$/.test(o)&&t.includes(o)}function zn(e){if(typeof e!="string")return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?(Z|[+-]\d{2}:\d{2})$/.exec(e);if(!t)return null;let[,o,n,i,s,c,r]=t,a=t[8],d=new Date(Date.UTC(Number(o),Number(n),0)).getUTCDate();if(Number(n)<1||Number(n)>12||Number(i)<1||Number(i)>d||Number(s)>23||Number(c)>59||Number(r)>59||a!=="Z"&&(Number(a.slice(1,3))>23||Number(a.slice(4))>59))return null;let u=Date.parse(e);return Number.isFinite(u)?u:null}function Or(e,t,o,n){let i=e?.[t];if(!i||t==="terminate"&&i.beforeFact===void 0)return null;let s=i.beforeFact,c=De(o),r=s&&c&&Object.hasOwn(c,s)?zn(c[s]):null,a=n instanceof Date?n.getTime():zn(n);return r===null||a===null||!Number.isFinite(a)?"WORKFLOW_V2_CANCELLATION_DEADLINE_INVALID":a<r?null:"WORKFLOW_V2_CANCELLATION_DEADLINE_PASSED"}var Qe="openxiangda.workflow.step.requested.v2",Qn=[Qe,"openxiangda.workflow.step.result_received.v2","openxiangda.workflow.step.completed.v2","openxiangda.workflow.step.continuation_failed.v2"],Jt=16384,ei=2048,hr="steps",Zn=/^[A-Za-z][A-Za-z0-9_-]{0,127}$/,ti=/^[A-Za-z][A-Za-z0-9_]{0,62}$/,ve=new Set(["__proto__","prototype","constructor"]),B=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),ni=e=>{try{let t=JSON.stringify(e);return t===void 0?1/0:new TextEncoder().encode(t).length}catch{return 1/0}},Ze=(e,t,o=0)=>{if(o>32)return!1;if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((s,c)=>Ze(s,t[c],o+1));if(!B(e)||!B(t))return!1;let n=Object.keys(e).filter(s=>e[s]!==void 0),i=Object.keys(t).filter(s=>t[s]!==void 0);return n.length===i.length&&n.every(s=>Object.hasOwn(t,s)&&Ze(e[s],t[s],o+1))};function Hn(e,t){let o=0,n=(i,s)=>++o>1e4||s>8?!1:i===null||typeof i=="boolean"||typeof i=="string"?!0:typeof i=="number"?Number.isFinite(i):Array.isArray(i)?i.length<=200&&i.every(c=>n(c,s+1)):B(i)&&Object.keys(i).length<=32&&Object.keys(i).every(c=>!ve.has(c))&&Object.values(i).every(c=>n(c,s+1));return ni(e)<=t&&n(e,0)}function oi(e){return!B(e)||Object.keys(e).some(t=>!["executionId","handlerVersion","inputDigest","expectedFactRevision","output","receipt"].includes(t))?!1:/^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i.test(e.executionId||"")&&Number.isSafeInteger(e.handlerVersion)&&e.handlerVersion>=1&&e.handlerVersion<=1e6&&/^[a-f0-9]{64}$/.test(e.inputDigest||"")&&Number.isSafeInteger(e.expectedFactRevision)&&e.expectedFactRevision>=0&&B(e.output)&&Hn(e.output,Jt)&&(e.receipt===void 0||B(e.receipt)&&Hn(e.receipt,ei))}function Rr(e){return B(e)&&Object.keys(e).every(t=>["executionId","nodeId","handlerCode","handlerVersion","mode","input","inputDigest","expectedFactRevision"].includes(t))&&typeof e.nodeId=="string"&&Zn.test(e.nodeId)&&!ve.has(e.nodeId)&&typeof e.handlerCode=="string"&&/^[a-z][a-z0-9-]{0,100}$/.test(e.handlerCode)&&e.handlerCode.endsWith(`-v${e.handlerVersion}`)&&["pure","reconciled-effect"].includes(e.mode)&&oi({executionId:e.executionId,handlerVersion:e.handlerVersion,inputDigest:e.inputDigest,expectedFactRevision:e.expectedFactRevision,output:e.input})}function ut(e,t,o=Jt){if(!Hn(t,o))return!1;let n=1e4,i=(s,c,r)=>{if(--n<0||r>8||!B(s))return!1;let a=c===null?"null":Array.isArray(c)?"array":typeof c=="number"&&Number.isSafeInteger(c)?"integer":typeof c,d=Array.isArray(s.type)?s.type:[s.type];if(!d.includes(a)&&!(a==="integer"&&d.includes("number"))||s.enum!==void 0&&(!Array.isArray(s.enum)||!s.enum.some(u=>Ze(u,c)))||Object.hasOwn(s,"const")&&!Ze(s.const,c))return!1;if(typeof c=="number")return Number.isFinite(c)&&(s.minimum===void 0||c>=s.minimum)&&(s.maximum===void 0||c<=s.maximum);if(typeof c=="string"){let u=Array.from(c).length;return(s.minLength===void 0||u>=s.minLength)&&(s.maxLength===void 0||u<=s.maxLength)}return Array.isArray(c)?c.length<=s.maxItems&&(s.minItems===void 0||c.length>=s.minItems)&&c.every(u=>i(s.items,u,r+1)):B(c)?!B(s.properties)||Object.keys(c).some(u=>ve.has(u)||!Object.hasOwn(s.properties,u))||(Array.isArray(s.required)?s.required:[]).some(u=>!Object.hasOwn(c,u))||s.minProperties!==void 0&&Object.keys(c).length<s.minProperties||s.maxProperties!==void 0&&Object.keys(c).length>s.maxProperties?!1:Object.entries(c).every(([u,l])=>i(s.properties[u],l,r+1)):c===null||typeof c=="boolean"};return i(e,t,0)}function ii(e){return typeof e=="string"&&e.length<=256&&e.split(".").length<=8&&e.split(".").every(t=>Zn.test(t)&&!ve.has(t))}function ft(e){let t=0,o=(n,i)=>{if(!B(n)||i>6||++t>256||Object.keys(n).some(r=>!["type","title","description","properties","required","additionalProperties","items","maxItems","minItems","maxLength","minLength","minimum","maximum","enum","const","maxProperties","minProperties"].includes(r)))return!1;let s=Array.isArray(n.type)?n.type:[n.type];if(!s.length||s.length>2||s.some(r=>!["object","array","string","integer","number","boolean","null"].includes(r))||s.length>1&&(!s.includes("null")||new Set(s).size!==s.length))return!1;for(let r of["title","description"])if(n[r]!==void 0&&(typeof n[r]!="string"||n[r].length>2e3))return!1;for(let r of["minimum","maximum"])if(n[r]!==void 0&&(typeof n[r]!="number"||!Number.isFinite(n[r])))return!1;for(let[r,a]of[["maxItems",200],["minItems",200],["maxLength",16384],["minLength",16384],["maxProperties",32],["minProperties",32]])if(n[r]!==void 0&&(!Number.isSafeInteger(n[r])||n[r]<0||n[r]>a))return!1;for(let[r,a]of[["minimum","maximum"],["minItems","maxItems"],["minLength","maxLength"],["minProperties","maxProperties"]])if(n[r]!==void 0&&n[a]!==void 0&&n[r]>n[a])return!1;if(["properties","required","additionalProperties","maxProperties","minProperties"].some(r=>n[r]!==void 0)&&!s.includes("object")||["items","maxItems","minItems"].some(r=>n[r]!==void 0)&&!s.includes("array")||["maxLength","minLength"].some(r=>n[r]!==void 0)&&!s.includes("string")||["minimum","maximum"].some(r=>n[r]!==void 0)&&!s.some(r=>r==="integer"||r==="number")||n.enum!==void 0&&(!Array.isArray(n.enum)||!n.enum.length||n.enum.length>100)||s.includes("object")&&(!B(n.properties)||n.additionalProperties!==!1||Object.keys(n.properties).length>32||Object.keys(n.properties).some(r=>!ti.test(r)||ve.has(r))||n.required!==void 0&&(!Array.isArray(n.required)||new Set(n.required).size!==n.required.length||n.required.some(r=>typeof r!="string"||!Object.hasOwn(n.properties,r)))||n.minProperties!==void 0&&n.minProperties>Object.keys(n.properties).length||n.maxProperties!==void 0&&n.maxProperties<(n.required?.length||0)||!Object.values(n.properties).every(r=>o(r,i+1)))||s.includes("array")&&(!Number.isSafeInteger(n.maxItems)||!o(n.items,i+1)))return!1;let c={...n};return delete c.enum,delete c.const,!(n.enum!==void 0&&(!n.enum.every(r=>ut(c,r))||n.enum.some((r,a)=>n.enum.slice(0,a).some(d=>Ze(r,d))))||Object.hasOwn(n,"const")&&!ut(c,n.const))};return B(e)&&e.type==="object"&&ni(e)<=Jt&&o(e,0)}function pt(e){let t=Object.fromEntries(Object.values(e.nodes||{}).filter(o=>o?.kind==="action").map(o=>[o.id,o.outputSchema]));return Object.keys(t).length?{...e.inputSchema,properties:{...e.inputSchema?.properties,steps:{type:"object",additionalProperties:!1,properties:t}}}:e.inputSchema||{}}function si(e,t){let o=e;for(let n of t.split(".")){if(!B(o?.properties)||!Object.hasOwn(o.properties,n))return;o=o.properties[n]}return B(o)?o:void 0}var Qo=(e,t)=>!!si(e,t);function Cr(e){return B(e)&&Object.keys(e).every(t=>["version","mode","inputSchema","outputSchema"].includes(t))&&Number.isSafeInteger(e.version)&&e.version>=1&&e.version<=1e6&&["pure","reconciled-effect"].includes(e.mode)&&ft(e.inputSchema)&&ft(e.outputSchema)}function Zo(e){return e.kind==="approval"?[e.onApprove,e.onReject]:e.kind==="condition"?[...Array.isArray(e.branches)?e.branches.map(t=>t.target):[],e.otherwise]:e.kind==="cc"||e.kind==="action"?[e.next]:[]}function Xn(e,t=0){return!B(e)||t>16?[]:e.op==="path"?typeof e.path=="string"?[e.path]:[]:["left","right","value"].flatMap(o=>Xn(e[o],t+1)).concat(Array.isArray(e.values)?e.values.flatMap(o=>Xn(o,t+1)):[])}function mt(e,t){if(!B(e)||!B(e.nodes))return["WORKFLOW_STEP_DEFINITION_INVALID"];let o=e.nodes,n=Object.entries(o).filter(([,r])=>r?.kind==="action");if(!n.length)return[];let i=[];Object.hasOwn(e.inputSchema?.properties||{},"steps")&&i.push("WORKFLOW_STEP_FACT_NAMESPACE_RESERVED");let s=pt(e);for(let[r,a]of n){(Object.keys(a).some(l=>!["id","kind","title","next","handler","inputSchema","outputSchema","inputs"].includes(l))||a.id!==r||!Zn.test(r)||ve.has(r)||typeof a.title!="string"||!a.title.trim()||a.title.length>255||typeof a.next!="string"||!Object.hasOwn(o,a.next))&&i.push(`WORKFLOW_STEP_NODE_INVALID:${r}`);let d=a.handler;(!B(d)||Object.keys(d).some(l=>!["code","version","mode"].includes(l))||!Number.isSafeInteger(d.version)||d.version<1||d.version>1e6||!/^[a-z][a-z0-9-]{0,100}$/.test(d.code||"")||!String(d.code).endsWith(`-v${d.version}`)||!["pure","reconciled-effect"].includes(d.mode))&&i.push(`WORKFLOW_STEP_HANDLER_INVALID:${r}`);let u=ft(a.inputSchema);if((!u||!ft(a.outputSchema))&&i.push(`WORKFLOW_STEP_SCHEMA_INVALID:${r}`),!B(a.inputs)||Object.keys(a.inputs).length>32){i.push(`WORKFLOW_STEP_INPUTS_INVALID:${r}`);continue}for(let l of Array.isArray(a.inputSchema?.required)?a.inputSchema.required:[])Object.hasOwn(a.inputs,l)||i.push(`WORKFLOW_STEP_INPUT_REQUIRED:${r}:${l}`);for(let[l,f]of Object.entries(a.inputs)){if(!ti.test(l)||ve.has(l)||!Object.hasOwn(a.inputSchema?.properties||{},l)||!B(f)){i.push(`WORKFLOW_STEP_INPUT_INVALID:${r}:${l}`);continue}if(f.source==="literal")(!u||Object.keys(f).some(A=>!["source","value"].includes(A))||!Object.hasOwn(f,"value")||!ut(a.inputSchema.properties[l],f.value))&&i.push(`WORKFLOW_STEP_LITERAL_INVALID:${r}:${l}`);else if(f.source!=="fact"||Object.keys(f).some(A=>!["source","path"].includes(A))||!ii(f.path)||!Qo(s,f.path))i.push(`WORKFLOW_STEP_FACT_PATH_INVALID:${r}:${l}`);else if(u){let A=si(s,f.path),N=a.inputSchema.properties[l],I=Array.isArray(A.type)?A.type:[A.type],m=Array.isArray(N.type)?N.type:[N.type];I.some(E=>!m.includes(E)&&!(E==="integer"&&m.includes("number")))&&i.push(`WORKFLOW_STEP_FACT_TYPE_MISMATCH:${r}:${l}`)}}}let c=(r,a)=>{let d=new Set,u=[e.startAt||""];for(;u.length&&d.size<=200;){let l=u.shift();if(!(l===a||d.has(l)||!o[l])){if(l===r)return!0;d.add(l),u.push(...Zo(o[l]))}}return!1};for(let[r,a]of Object.entries(o)){if(!B(a))continue;let d=a.kind==="action"?Object.values(a.inputs||{}).flatMap(l=>l?.source==="fact"?[l.path]:[]):(Array.isArray(a.branches)?a.branches:[]).flatMap(l=>Xn(l?.when)),u=t?.bindings?.[a.binding];u&&d.push(...[u.inputPath,u.departmentIdFrom,u.resourceIdFrom,u.scope?.valueFrom].filter(l=>typeof l=="string"));for(let l of d.filter(f=>typeof f=="string"&&f.startsWith("steps."))){let f=l.split(".")[1];(o[f]?.kind!=="action"||f===r||!Qo(s,l)||c(r,f))&&i.push(`WORKFLOW_STEP_OUTPUT_NOT_AVAILABLE:${r}:${l}`)}}if(t)for(let[,r]of n){let a=new Set,d=[r.next];for(;d.length&&a.size<=200;){let u=d.shift();if(a.has(u)||!B(o[u]))continue;a.add(u);let l=o[u];if(!(l.kind==="action"||l.kind==="end")){if(l.kind==="approval"){let f=t.bindings?.[l.binding];f&&["application_provider","initiator_select"].includes(f.provider)&&i.push(`WORKFLOW_STEP_NEXT_PROVIDER_REQUIRES_PREPARED_RESULT:${u}`);continue}d.push(...Zo(l))}}}return[...new Set(i)]}function Sr(e,t){let o={};for(let[n,i]of Object.entries(e.inputs)){let s=i.source==="literal"?i.value:i.path.split(".").reduce((c,r)=>B(c)&&Object.hasOwn(c,r)?c[r]:void 0,t);s!==void 0&&(o[n]=s)}if(!ut(e.inputSchema,o))throw new Error("WORKFLOW_STEP_INPUT_SCHEMA_INVALID");return o}function eo(e,t,o){let n=zt(e),i=[];Object.keys(n).length&&!o&&i.push("WORKFLOW_STEP_BACKEND_REQUIRED");for(let s of Object.keys(n)){let c=t.find(r=>r.code===s);(!c||c.execution||c.action||!Array.isArray(c.eventTypes)||c.eventTypes.length!==1||c.eventTypes[0]!==Qe||!B(c.filter)||Object.keys(c.filter).length!==1||!B(c.filter.workflowStep)||Object.keys(c.filter.workflowStep).length!==1||c.filter.workflowStep.handlerCode!==s||!B(c.payload)||c.payload.includeChanges!==!1||!Array.isArray(c.payload.fields)||c.payload.fields.length)&&i.push(`WORKFLOW_STEP_SUBSCRIPTION_INVALID:${s}`)}for(let s of t)(s.eventTypes?.includes(Qe)&&!n[s.code]||s.filter?.workflowStep&&!n[s.code])&&i.push(`WORKFLOW_STEP_HANDLER_NOT_DECLARED:${s.code}`);return i}function zt(e){let t={};for(let o of e){let n=mt(o);if(n.length)throw new Error(n.join("; "));for(let i of Object.values(o.nodes||{})){if(i.kind!=="action")continue;let s={version:i.handler.version,mode:i.handler.mode,inputSchema:i.inputSchema,outputSchema:i.outputSchema},c=t[i.handler.code];if(c&&!Ze(c,s))throw new Error(`WORKFLOW_STEP_HANDLER_CONTRACT_CONFLICT:${i.handler.code}`);t[i.handler.code]=s}}return t}var ce=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},Pe=(e,t)=>typeof e=="string"&&!!e.trim()&&e.length<=t,wr=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z][A-Za-z0-9_-]*){0,15}$/,to=e=>typeof e=="string"&&e.length<=256&&wr.test(e)&&!e.split(".").some(t=>["__proto__","prototype","constructor"].includes(t));function Yt(e,t){let o=ce(e),n=!0;for(let i of t.split(".")){n&&=Array.isArray(o.required)&&o.required.includes(i);let s=ce(o.properties)[i];if(!s||typeof s!="object")return null;o=ce(s)}return{schema:o,required:n}}function no(e){let t=new Set,o=[],n=2048,i=(s,c)=>{if(--n<0||c>20){o.push("WORKFLOW_EXPRESSION_BUDGET_EXCEEDED");return}let r=ce(s);if(r.op==="path")to(r.path)?t.add(r.path):o.push("WORKFLOW_EXPRESSION_PATH_INVALID");else{if(r.op==="literal")return;if(r.op==="and"||r.op==="or")if(!Array.isArray(r.values)||!r.values.length||r.values.length>128)o.push("WORKFLOW_EXPRESSION_GROUP_INVALID");else for(let a of r.values){if(n<0)break;i(a,c+1)}else r.op==="not"||r.op==="exists"?i(r.value,c+1):["eq","neq","gt","gte","lt","lte","in","contains"].includes(String(r.op))?(i(r.left,c+1),i(r.right,c+1)):o.push("WORKFLOW_EXPRESSION_OPERATOR_INVALID")}};return i(e,0),{paths:[...t],errors:[...new Set(o)]}}function oo(e){if(e?.readability===void 0)return[];let t=[],o=pt(e),n=ce(e.readability);(Object.keys(n).some(r=>!["variables","logic"].includes(r))||!Object.keys(n).length)&&t.push("WORKFLOW_READABILITY_INVALID");let i=ce(n.variables);n.variables!==void 0&&(typeof n.variables!="object"||Array.isArray(n.variables)||n.variables===null)&&t.push("WORKFLOW_VARIABLES_INVALID"),Object.keys(i).length>128&&t.push("WORKFLOW_VARIABLE_LIMIT_EXCEEDED");for(let[r,a]of Object.entries(i)){let d=ce(a);(!to(r)||!Yt(o,r))&&t.push(`WORKFLOW_VARIABLE_SOURCE_UNKNOWN:${r}`),(!Pe(d.label,160)||Object.keys(d).some(u=>!["label","unit","description"].includes(u))||d.unit!==void 0&&!Pe(d.unit,32)||d.description!==void 0&&!Pe(d.description,2e3))&&t.push(`WORKFLOW_VARIABLE_METADATA_INVALID:${r}`)}let s=n.logic===void 0?[]:n.logic;(!Array.isArray(s)||s.length>32)&&t.push("WORKFLOW_LOGIC_LIMIT_INVALID");let c=new Set;for(let r of Array.isArray(s)?s.slice(0,32):[]){let a=ce(r),d=String(a.code||"");(!/^[a-z][a-z0-9-]{2,63}$/.test(d)||c.has(d)||!Pe(a.title,160)||!Pe(a.description,4e3)||Object.keys(a).some(u=>!["code","title","description","phase","nodeId","inputPaths","outputPaths","source"].includes(u)))&&t.push(`WORKFLOW_LOGIC_METADATA_INVALID:${d}`),c.add(d),(!["submission","node_input","completion"].includes(String(a.phase))||a.phase==="node_input"&&!ce(e.nodes)[String(a.nodeId)]||a.phase!=="node_input"&&a.nodeId!==void 0)&&t.push(`WORKFLOW_LOGIC_ANCHOR_INVALID:${d}`);for(let u of["inputPaths","outputPaths"]){let l=a[u];if(!(u==="outputPaths"&&l===void 0))if(!Array.isArray(l)||l.length>32||new Set(l).size!==l.length)t.push(`WORKFLOW_LOGIC_PATHS_INVALID:${d}:${u}`);else for(let f of l)(!to(f)||!Yt(o,f))&&t.push(`WORKFLOW_LOGIC_SOURCE_UNKNOWN:${d}:${String(f)}`)}if(a.source!==void 0){let u=ce(a.source);(!Pe(u.path,256)||String(u.path).startsWith("/")||String(u.path).includes("..")||String(u.path).includes("://")||!/^sha256:[a-f0-9]{64}$/.test(String(u.digest))||u.symbol!==void 0&&!Pe(u.symbol,160)||Object.keys(u).some(l=>!["path","symbol","digest"].includes(l)))&&t.push(`WORKFLOW_LOGIC_SOURCE_REFERENCE_INVALID:${d}`)}}for(let r of Object.values(ce(e.nodes))){let a=ce(r),d=Array.isArray(a.branches)?a.branches:[];for(let u of d){let l=no(u.when);t.push(...l.errors.map(f=>`${f}:${a.id}`));for(let f of l.paths)Yt(o,f)||t.push(`WORKFLOW_VARIABLE_SOURCE_UNKNOWN:${a.id}:${f}`)}}return[...new Set(t)]}function Dr(e,t){let o=pt(e),n=[],i=new Map,s=[];for(let a of Object.values(e.nodes)){if(a.kind==="approval")for(let[d,u,l]of[["approve",a.onApprove,"\u540C\u610F"],["reject",a.onReject,"\u62D2\u7EDD"]])u&&n.push({id:`${a.id}:${d}`,from:a.id,to:u,kind:d,label:l,variablePaths:[]});if(a.kind==="cc"&&a.next&&n.push({id:`${a.id}:next`,from:a.id,to:a.next,kind:"next",label:"\u6284\u9001\u540E\u7EE7\u7EED",variablePaths:[]}),a.kind==="action"&&a.next){let d=Object.values(a.inputs||{}).flatMap(u=>u.source==="fact"?[u.path]:[]);for(let u of d)i.has(u)||i.set(u,new Set),i.get(u).add(a.id);n.push({id:`${a.id}:next`,from:a.id,to:a.next,kind:"next",label:"\u6210\u529F\u56DE\u6267\u540E\u7EE7\u7EED",variablePaths:d})}if(a.kind==="condition"){for(let[d,u]of(a.branches||[]).entries()){let l=no(u.when);for(let f of l.paths)i.has(f)||i.set(f,new Set),i.get(f).add(a.id);n.push({id:`${a.id}:branch:${d}`,from:a.id,to:u.target,kind:"branch",label:u.label||`\u6761\u4EF6 ${d+1}`,priority:d+1,expression:u.when,variablePaths:l.paths}),s.push(...l.errors.map(f=>({code:f,path:a.id})))}a.otherwise&&n.push({id:`${a.id}:default`,from:a.id,to:a.otherwise,kind:"default",label:"\u5747\u4E0D\u6EE1\u8DB3\u65F6",variablePaths:[]})}}let r=[...new Set([...i.keys(),...Object.keys(e.readability?.variables||{}),...(e.readability?.logic||[]).flatMap(a=>[...a.inputPaths,...a.outputPaths||[]])])].slice(0,128).map(a=>{let d=Yt(o,a),u=e.readability?.variables?.[a],l=a.split("."),f=e.subject?.factProjection[l[0]],A=l[0]==="steps"?e.nodes[l[1]]:void 0;return d||s.push({code:"WORKFLOW_VARIABLE_SOURCE_UNKNOWN",path:a}),{path:a,label:u?.label||String(d?.schema.title||a),type:String(d?.schema.type||"unknown"),...u,required:d?.required||!1,usedBy:[...i.get(a)||[]],source:d&&A?.handler?{kind:"step_output",nodeId:A.id,handlerCode:A.handler.code,handlerVersion:A.handler.version}:d&&f&&e.subject?{kind:"subject_field",resourceCode:e.subject.resourceCode,fieldPath:[f,...l.slice(1)].join(".")}:{kind:d?"input":"unknown"}}});return{schemaVersion:"openxiangda.workflow-graph/v2",workflowCode:e.code,definitionDigest:t,startAt:e.startAt,fixedTopology:!0,branchStrategy:"first_match",nodes:Object.values(e.nodes).map(a=>({id:a.id,kind:a.kind,title:a.title||a.id,...a.binding?{binding:a.binding}:{},...a.mode?{mode:a.mode}:{},...a.outcome?{outcome:a.outcome}:{},...a.kind==="cc"?{emptyPolicy:a.emptyPolicy,notify:a.notify!==!1}:{},...a.kind==="action"&&a.handler?{businessStep:{handler:a.handler,inputs:a.inputs||{},outputPaths:Object.keys(ce(a.outputSchema).properties||{}).map(d=>`steps.${a.id}.${d}`)}}:{}})),edges:n,variables:r,logic:e.readability?.logic||[],diagnostics:s}}function _t(e,t=[],o=0){if(!e||o>20)return"\u65E0\u6CD5\u8BC6\u522B\u7684\u6761\u4EF6";if(e.op==="path")return t.find(c=>c.path===e.path)?.label||e.path;if(e.op==="literal")return JSON.stringify(e.value)??"\u7F3A\u503C";if(e.op==="and"||e.op==="or")return e.values.slice(0,128).map(c=>`\uFF08${_t(c,t,o+1)}\uFF09`).join(e.op==="and"?" \u4E14 ":" \u6216 ");if(e.op==="not"||e.op==="exists")return`${e.op==="not"?"\u4E0D\u6EE1\u8DB3":"\u5B58\u5728"}\uFF08${_t(e.value,t,o+1)}\uFF09`;if(!("left"in e))return"\u65E0\u6CD5\u8BC6\u522B\u7684\u6761\u4EF6";let n={eq:"=",neq:"\u2260",gt:">",gte:"\u2265",lt:"<",lte:"\u2264",in:"\u5C5E\u4E8E",contains:"\u5305\u542B"},i=e.left.op==="path"?e.left.path:void 0,s=i&&e.right.op==="literal"&&typeof e.right.value=="number"?t.find(c=>c.path===i)?.unit:void 0;return`${_t(e.left,t,o+1)} ${n[e.op]} ${_t(e.right,t,o+1)}${s?` ${s}`:""}`}var Xt=["approve","reject","return","transfer","delegate","add_assignee"],Qt=["fixed_users","app_role","app_role_in_scope"],$r=["single","any","all","sequence"],$e=e=>!!e&&typeof e=="object"&&!Array.isArray(e),et=(e,t)=>Object.keys(e).every(o=>t.includes(o)),Ht=(e,t,o)=>Array.isArray(e)&&e.length>0&&e.length<=o&&new Set(e).size===e.length&&e.every(n=>typeof n=="string"&&t.includes(n));function tt(e){return e.allowedOperations||[...Xt]}function ri(e,t,o={},n=!1){return!(!$e(e)||!Object.keys(e).length||!et(e,n?["enabled","label","commentRequired"]:["label","commentRequired"])||e.label!==void 0&&(typeof e.label!="string"||!e.label.trim()||e.label.length>40||/[\u0000-\u001f\u007f]/.test(e.label))||e.enabled!==void 0&&(typeof e.enabled!="boolean"||["approve","reject"].includes(t)&&!e.enabled)||e.commentRequired!==void 0&&(typeof e.commentRequired!="boolean"||!["approve","reject"].includes(t)||(t==="reject"||o.commentRequired)&&!e.commentRequired))}function Zt(e,t){let o=[];for(let[n,i]of Object.entries(e?.nodes||{})){if(!$e(i))continue;let s=i.administration,c=i.operationPolicy;if(i.kind==="cc"){(c!==void 0||s!==void 0&&(!$e(s)||!et(s,["assigneeProviders"])))&&o.push(`WORKFLOW_NODE_ADMINISTRATION_INVALID:${n}`),s?.assigneeProviders!==void 0&&!Ht(s.assigneeProviders,Qt,3)&&o.push(`WORKFLOW_NODE_ADMINISTRATION_PROVIDERS_INVALID:${n}`),s?.assigneeProviders?.includes("app_role_in_scope")&&t&&!t.bindings[i.binding||""]?.scope&&o.push(`WORKFLOW_NODE_ADMINISTRATION_SCOPE_REQUIRED:${n}`);continue}if(i.kind!=="approval"){(s!==void 0||c!==void 0)&&o.push(`WORKFLOW_NODE_ADMINISTRATION_APPROVAL_REQUIRED:${n}`);continue}if(c!==void 0&&(!$e(c)||Object.keys(c).length>8||Object.entries(c).some(([a,d])=>!Xt.includes(a)||!tt(i).includes(a)||!ri(d,a)))&&o.push(`WORKFLOW_NODE_OPERATION_POLICY_INVALID:${n}`),s===void 0)continue;if(!$e(s)||!et(s,["modes","assigneeProviders","operations"])){o.push(`WORKFLOW_NODE_ADMINISTRATION_INVALID:${n}`);continue}s.modes!==void 0&&(!Ht(s.modes,$r,4)||!s.modes.includes(i.mode))&&o.push(`WORKFLOW_NODE_ADMINISTRATION_MODES_INVALID:${n}`),s.assigneeProviders!==void 0&&!Ht(s.assigneeProviders,Qt,3)&&o.push(`WORKFLOW_NODE_ADMINISTRATION_PROVIDERS_INVALID:${n}`);let r=t?.bindings[i.binding||""];r&&Array.isArray(s.assigneeProviders)&&s.assigneeProviders.includes("app_role_in_scope")&&!r.scope&&o.push(`WORKFLOW_NODE_ADMINISTRATION_SCOPE_REQUIRED:${n}`),s.operations!==void 0&&(!Ht(s.operations,Xt,8)||s.operations.some(a=>!tt(i).includes(a)))&&o.push(`WORKFLOW_NODE_ADMINISTRATION_OPERATIONS_INVALID:${n}`)}return o}function Vr(e,t,o){let n=[];if(!e||!$e(o)||!Object.keys(o).length||!et(o,["title","description","assignee","mode","operations"]))return["WORKFLOW_V2_NODE_CONFIGURATION_PATCH_INVALID"];let i=o;for(let c of["title","description"])i[c]!==void 0&&(typeof i[c]!="string"||i[c].length>(c==="title"?255:1e3)||c==="title"&&!i[c].trim())&&n.push("WORKFLOW_V2_NODE_CONFIGURATION_PATCH_INVALID");let s=e.administration;if(i.mode!==void 0&&(e.kind!=="approval"||!s?.modes?.includes(i.mode))&&n.push("WORKFLOW_V2_NODE_CONFIGURATION_MODE_READONLY"),i.operations!==void 0&&(e.kind!=="approval"||!$e(i.operations)||!Object.keys(i.operations).length||Object.keys(i.operations).length>8||Object.entries(i.operations).some(([c,r])=>!s?.operations?.includes(c)||!tt(e).includes(c)||!ri(r,c,e.operationPolicy?.[c],!0)))&&n.push("WORKFLOW_V2_NODE_CONFIGURATION_OPERATION_INVALID"),i.assignee!==void 0){let c=i.assignee,r=s?.assigneeProviders||(e.kind==="approval"&&t&&Qt.includes(t.provider)?[t.provider]:[]);!$e(c)||!["approval","cc"].includes(e.kind)||!r.includes(c.provider)||c.provider==="app_role_in_scope"&&!t?.scope?n.push("WORKFLOW_V2_NODE_CONFIGURATION_PROVIDER_READONLY"):c.provider==="fixed_users"?(!et(c,["provider","users"])||!Array.isArray(c.users)||c.users.length<1||c.users.length>(e.kind==="cc"?20:200)||new Set(c.users).size!==c.users.length||c.users.some(a=>typeof a!="string"||!a.trim()||a.length>255))&&n.push("WORKFLOW_V2_NODE_CONFIGURATION_USERS_INVALID"):(!et(c,["provider","roleCode"])||typeof c.roleCode!="string"||!/^[a-z][a-z0-9_-]{0,127}$/.test(c.roleCode))&&n.push("WORKFLOW_V2_NODE_CONFIGURATION_ROLE_INVALID")}return n}function kr(e,t){let o=Object.fromEntries(tt(e).flatMap(n=>{let i=n,s=t?.operations?.[i],c={...e.operationPolicy?.[i],...s?.label!==void 0?{label:s.label}:{},...s?.commentRequired!==void 0?{commentRequired:s.commentRequired}:{}};return Object.keys(c).length?[[i,c]]:[]}));return{mode:t?.mode||e.mode,allowedOperations:tt(e).filter(n=>t?.operations?.[n]?.enabled!==!1),operationPolicy:o,fieldPolicy:{default:e.fieldPolicy?.default||"readonly",fields:{...e.fieldPolicy?.fields}}}}var zc=20,ai=["fixed_users","initiator","input_users","form_field_users","app_role","app_role_in_scope","previous_node_actor"];function en(e,t){let o=[];for(let[n,i]of Object.entries(e?.nodes||{})){if(i?.kind!=="cc"||((Object.keys(i).some(a=>!["id","kind","title","binding","next","emptyPolicy","notify","administration"].includes(a))||typeof i.title!="string"||!i.title.trim()||i.title.length>255||typeof i.binding!="string"||!i.binding.trim()||i.binding.length>255||typeof i.next!="string"||!i.next.trim()||!e.nodes?.[i.next]||!["block","skip"].includes(i.emptyPolicy)||i.notify!==void 0&&typeof i.notify!="boolean")&&o.push(`WORKFLOW_CC_NODE_INVALID:${n}`),!t))continue;let s=t.bindings?.[i.binding];if(!s){o.push(`WORKFLOW_CC_BINDING_NOT_FOUND:${n}`);continue}ai.includes(s.provider)||o.push(`WORKFLOW_CC_PROVIDER_INVALID:${n}`);let c=s.min??1,r=s.max??20;(!Number.isSafeInteger(c)||!Number.isSafeInteger(r)||c<1||r<c||r>20||s.provider==="fixed_users"&&(!Array.isArray(s.users)||!s.users.length||s.users.length>r))&&o.push(`WORKFLOW_CC_RECIPIENT_LIMIT_INVALID:${n}`)}return[...new Set(o)]}var Hc=64,Xc=65536,je=new Set(["__proto__","prototype","constructor"]),ci=/^[A-Za-z][A-Za-z0-9_-]{0,63}$/,so=/^[A-Za-z][A-Za-z0-9_]{0,62}$/,de=e=>!!e&&typeof e=="object"&&!Array.isArray(e)&&[null,Object.prototype].includes(Object.getPrototypeOf(e)),Le=(e,t)=>de(e)&&Object.keys(e).every(o=>t.includes(o)&&!je.has(o)),ro=e=>{try{return new TextEncoder().encode(JSON.stringify(e)).length}catch{return 1/0}},di=e=>e==null||typeof e=="string"&&!e.trim()||Array.isArray(e)&&e.length===0;function xe(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,i)=>xe(n,t[i]));if(!de(e)||!de(t))return!1;let o=Object.keys(e);return o.length===Object.keys(t).length&&o.every(n=>Object.hasOwn(t,n)&&xe(e[n],t[n]))}function io(e,t){let o=t.split(".");if(!(o.some(n=>!ci.test(n)||je.has(n))||o.length>12))return o.reduce((n,i)=>de(n)&&Object.hasOwn(n,i)?n[i]:void 0,e)}function Ce(e,t){switch(e.op){case"literal":return e.value;case"path":return io({values:t},e.path);case"and":return e.values.every(o=>!!Ce(o,t));case"or":return e.values.some(o=>!!Ce(o,t));case"not":return!Ce(e.value,t);case"exists":return!di(Ce(e.value,t));default:{let o=Ce(e.left,t),n=Ce(e.right,t);return e.op==="eq"?xe(o,n):e.op==="neq"?!xe(o,n):e.op==="in"?Array.isArray(n)&&n.some(i=>xe(i,o)):e.op==="contains"?Array.isArray(o)?o.some(i=>xe(i,n)):typeof o=="string"&&typeof n=="string"&&o.includes(n):typeof o!="number"||typeof n!="number"||!Number.isFinite(o)||!Number.isFinite(n)?!1:e.op==="gt"?o>n:e.op==="gte"?o>=n:e.op==="lt"?o<n:o<=n}}}function gt(e,t,o=0,n={nodes:0}){if(o>8||++n.nodes>64||!de(e))return!1;if(e.op==="literal")return Le(e,["op","value"])&&Object.hasOwn(e,"value")&&ro(e.value)<=4096&&tn(e.value);if(e.op==="path"){if(!Le(e,["op","path"])||typeof e.path!="string")return!1;let i=e.path.split(".");return i[0]==="values"&&i.length>=2&&i.length<=8&&t.has(i[1])&&i.every(s=>so.test(s)&&!je.has(s))}return["not","exists"].includes(e.op)?Le(e,["op","value"])&>(e.value,t,o+1,n):["and","or"].includes(e.op)?Le(e,["op","values"])&&Array.isArray(e.values)&&e.values.length>0&&e.values.length<=16&&e.values.every(i=>gt(i,t,o+1,n)):["eq","neq","gt","gte","lt","lte","in","contains"].includes(e.op)&&Le(e,["op","left","right"])&>(e.left,t,o+1,n)&>(e.right,t,o+1,n)}function nn(e,t){let o=[],n=e.taskPages;if(n!==void 0&&(!de(n)||Object.keys(n).length===0||Object.keys(n).length>16||ro(n)>65536))return["WORKFLOW_TASK_PAGES_INVALID"];for(let[i,s]of Object.entries(n||{})){let c=`taskPages.${i}`;if(!ci.test(i)||je.has(i)||!Le(s,["title","fields"])||typeof s.title!="string"||!s.title.trim()||s.title.length>160||!Array.isArray(s.fields)||!s.fields.length||s.fields.length>64){o.push(`WORKFLOW_TASK_PAGE_INVALID:${c}`);continue}let r=new Set(s.fields.map(a=>a?.code));r.size!==s.fields.length&&o.push(`WORKFLOW_TASK_PAGE_DUPLICATE_FIELD:${c}`);for(let a of s.fields){if(!Le(a,["code","readonly","required","visibleWhen","requiredWhen"])||!so.test(a.code)||je.has(a.code)||["readonly","required"].some(d=>a[d]!==void 0&&typeof a[d]!="boolean")||a.readonly&&(a.required||a.requiredWhen)){o.push(`WORKFLOW_TASK_PAGE_FIELD_INVALID:${c}`);continue}for(let d of["visibleWhen","requiredWhen"])a[d]!==void 0&&!gt(a[d],r)&&o.push(`WORKFLOW_TASK_PAGE_EXPRESSION_INVALID:${c}.${a.code}.${d}`);if(t){let d=t.get(a.code);(!d||d.system||d.hidden||d.type==="serial-number"||!a.readonly&&(d.widget==="readonly"||["subtable","signature","text.rich"].includes(d.type)))&&o.push(`WORKFLOW_TASK_PAGE_RESOURCE_FIELD_INVALID:${c}.${a.code}`)}}}for(let[i,s]of Object.entries(e.nodes||{}))de(s)&&s.taskPageCode!==void 0&&(s.kind!=="approval"||typeof s.taskPageCode!="string"||!de(n)||!Object.hasOwn(n,s.taskPageCode)?o.push(`WORKFLOW_TASK_PAGE_NOT_FOUND:${i}`):Array.isArray(n[s.taskPageCode]?.fields)&&n[s.taskPageCode].fields.some(c=>c&&(s.fieldPolicy?.fields?.[c.code]||s.fieldPolicy?.default)==="hidden")&&o.push(`WORKFLOW_TASK_PAGE_FIELD_HIDDEN:${i}`));return o}function li(e,t){return e.fields.map(o=>({code:o.code,visible:o.visibleWhen===void 0||!!Ce(o.visibleWhen,t),readonly:o.readonly===!0,required:o.required===!0||o.requiredWhen!==void 0&&!!Ce(o.requiredWhen,t)}))}var Ve=class extends Error{constructor(o,n){super(o);this.code=o;this.field=n}code;field};function tn(e,t={members:0},o=0){return++t.members>5e3||o>12?!1:e===null||typeof e=="boolean"?!0:typeof e=="string"?e.length<=65536:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.length<=1e3&&e.every(n=>tn(n,t,o+1)):de(e)&&Object.entries(e).every(([n,i])=>!je.has(n)&&tn(i,t,o+1))}function Fr(e,t,o,n){if(!de(o)||ro(o)>65536||!tn(o))throw new Ve("WORKFLOW_TASK_FORM_VALUES_INVALID");let i={...t,...o},s=new Map(li(e,i).map(c=>[c.code,c]));for(let c of Object.keys(o)){let r=s.get(c);if(!r||r.readonly||!r.visible)throw new Ve("WORKFLOW_TASK_FORM_FIELD_NOT_EDITABLE",c)}if(n){for(let c of s.values())if(c.visible&&!c.readonly&&c.required&&di(i[c.code]))throw new Ve("WORKFLOW_TASK_FORM_REQUIRED",c.code)}return i}function vr(e,t,o){let n=JSON.parse(JSON.stringify(t));for(let[c,r]of Object.entries(e.subject?.factProjection||{})){let a=c.split(".");if(!a.length||a.length>12||c.length>128||a[0]==="steps"||a.some(u=>!so.test(u)||je.has(u)))throw new Ve("WORKFLOW_TASK_FORM_FACT_PROJECTION_INVALID");if(!Object.hasOwn(o,r))throw new Ve("WORKFLOW_TASK_FORM_FACT_FIELD_MISSING",r);let d=n;for(let u of a.slice(0,-1))d=d[u]=de(d[u])?d[u]:{};d[a.at(-1)]=o[r]===void 0?void 0:JSON.parse(JSON.stringify(o[r]))}let i=new Set,s=Object.values(e.nodes||{}).filter(c=>c.kind==="action");for(let c=0;c<=s.length;c++){let r=!1;for(let a of s)de(n.steps)&&Object.hasOwn(n.steps,a.id)&&Object.values(a.inputs||{}).some(d=>d.source==="fact"&&!xe(io(t,d.path),io(n,d.path)))&&(delete n.steps[a.id],i.add(a.id),r=!0);if(!r)break}return{facts:n,invalidatedNodeIds:[...i].sort()}}function Pr(e,t,o){let n=e.nodes||{};for(let i of o){let s=new Set,c=new Map,r=a=>{if(a===i)return!0;if(c.has(a))return c.get(a);if(s.has(a)||s.size>200)return!1;let d=n[a];if(!de(d)||d.kind==="end")return!1;s.add(a);let u=d.kind==="approval"?[d.onApprove]:d.kind==="condition"?[...(d.branches||[]).map(f=>f.target),d.otherwise]:[d.next],l=u.length>0&&u.every(f=>typeof f=="string"&&r(f));return s.delete(a),c.set(a,l),l};if(!r(t))return!1}return!0}var Zc=256,ed=64,td=262144,Lr=/^[a-z][a-z0-9_-]{0,127}$/,xr=/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/,fi=new Set(["__proto__","prototype","constructor"]),ye=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Et=(e,t)=>Object.keys(e).every(o=>t.includes(o)),Me=(e,t)=>typeof e=="string"&&e.trim().length>0&&e.length<=t&&!/[\u0000-\u001f\u007f]/.test(e),Se=e=>typeof e=="string"&&Lr.test(e)&&!fi.has(e),pi=e=>typeof e=="string"&&e.length<=255&&xr.test(e)&&!e.split(".").some(t=>fi.has(t)),jr=e=>ye(e)&&Et(e,["dimension","valueFrom","value"])&&Se(e.dimension)&&(Me(e.value,255)&&e.valueFrom===void 0||pi(e.valueFrom)&&e.value===void 0),ui=e=>typeof e=="string"&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})$/.test(e)&&Number.isFinite(Date.parse(e)),At={type:"string",pattern:"^[a-z][a-z0-9_-]{0,127}$"},ao={type:"string",minLength:1,maxLength:128},Mr={type:"object",additionalProperties:!1,required:["policyCode","title","strategy","dimensions","sources"],properties:{policyCode:At,title:ao,strategy:{enum:["replace_then_append","replace_only"]},dimensions:{type:"object",maxProperties:8,propertyNames:At,additionalProperties:{type:"object",additionalProperties:!1,required:["title","valueFrom"],properties:{title:ao,valueFrom:{type:"string",minLength:1,maxLength:255}}}},sources:{type:"object",minProperties:1,maxProperties:16,propertyNames:At,additionalProperties:{type:"object",additionalProperties:!1,required:["title","provider","roleCode"],properties:{title:ao,provider:{enum:["app_role","app_role_in_scope"]},roleCode:At,scope:{type:"object",additionalProperties:!1,required:["dimension"],properties:{dimension:At,value:{type:"string",minLength:1,maxLength:255},valueFrom:{type:"string",minLength:1,maxLength:255}}}}}}}};function It(e){if(!ye(e)||!Et(e,["policyCode","title","strategy","dimensions","sources"])||!Se(e.policyCode)||!Me(e.title,128)||!["replace_then_append","replace_only"].includes(e.strategy))return["WORKFLOW_V2_ROUTING_POLICY_INVALID"];let t=[];return(!ye(e.dimensions)||Object.keys(e.dimensions).length>8||Object.entries(e.dimensions).some(([o,n])=>!Se(o)||!ye(n)||!Et(n,["title","valueFrom"])||!Me(n.title,128)||!pi(n.valueFrom)))&&t.push("WORKFLOW_V2_ROUTING_DIMENSIONS_INVALID"),(!ye(e.sources)||Object.keys(e.sources).length<1||Object.keys(e.sources).length>16||Object.entries(e.sources).some(([o,n])=>!Se(o)||!ye(n)||!Et(n,["title","provider","roleCode","scope"])||!Me(n.title,128)||!Se(n.roleCode)||!["app_role","app_role_in_scope"].includes(n.provider)||(n.provider==="app_role_in_scope"?!jr(n.scope):n.scope!==void 0)))&&t.push("WORKFLOW_V2_ROUTING_SOURCES_INVALID"),t}function Wr(e,t){if(It(e).length)return["WORKFLOW_V2_ROUTING_POLICY_INVALID"];if(!Array.isArray(t)||t.length>256||new TextEncoder().encode(JSON.stringify(t)).length>262144)return["WORKFLOW_V2_ROUTING_RULE_LIMIT_EXCEEDED"];let o=[],n=new Set;for(let i of t){if(!ye(i)||!Et(i,["ruleCode","title","enabled","workflowCode","nodeId","matches","sourceCode","effect","priority","validFrom","validTo"])||!Se(i.ruleCode)||!Me(i.title,128)||typeof i.enabled!="boolean"||!Se(i.sourceCode)||!Object.hasOwn(e.sources,i.sourceCode)||!["append","replace"].includes(i.effect)||!Number.isSafeInteger(i.priority)||i.priority<-1e3||i.priority>1e3||i.workflowCode!==void 0&&!Se(i.workflowCode)||i.nodeId!==void 0&&(!Se(i.nodeId)||i.workflowCode===void 0)||i.validFrom!==void 0&&!ui(i.validFrom)||i.validTo!==void 0&&!ui(i.validTo)||i.validFrom&&i.validTo&&Date.parse(i.validFrom)>=Date.parse(i.validTo)){o.push("WORKFLOW_V2_ROUTING_RULE_INVALID");continue}n.has(i.ruleCode)&&o.push(`WORKFLOW_V2_ROUTING_RULE_DUPLICATE:${i.ruleCode}`),n.add(i.ruleCode),(!ye(i.matches)||Object.entries(i.matches).some(([s,c])=>!Object.hasOwn(e.dimensions,s)||!Array.isArray(c)||c.length<1||c.length>64||new Set(c).size!==c.length||c.some(r=>!Me(r,255))))&&o.push(`WORKFLOW_V2_ROUTING_MATCH_INVALID:${i.ruleCode}`)}return[...new Set(o)]}function mi(e){return JSON.stringify({policyCode:e.policyCode,strategy:e.strategy,dimensions:Object.entries(e.dimensions).sort(([t],[o])=>t<o?-1:t>o?1:0).map(([t,o])=>[t,o.valueFrom]),sources:Object.entries(e.sources).sort(([t],[o])=>t<o?-1:t>o?1:0).map(([t,o])=>[t,o.provider,o.roleCode,o.scope?.dimension??null,o.scope?.valueFrom??null,o.scope?.value??null])})}function co(e){let t=[],o=new Map;for(let n of e)for(let[i,s]of Object.entries(n.bindings||{})){if(!ye(s)||s.routing===void 0)continue;let c=It(s.routing);if(c.length){t.push(...c.map(d=>`${d}:${i}`));continue}let r=mi(s.routing),a=o.get(s.routing.policyCode);a&&a!==r&&t.push(`WORKFLOW_V2_ROUTING_POLICY_CONFLICT:${s.routing.policyCode}`),o.set(s.routing.policyCode,r)}return[...new Set(t)]}function Ur(e,t){let o={};for(let[n,i]of Object.entries(e.dimensions)){let s=t;for(let c of i.valueFrom.split("."))s=ye(s)&&Object.hasOwn(s,c)?s[c]:void 0;if(!(typeof s=="string"&&Me(s,255)||typeof s=="number"&&Number.isFinite(s)||typeof s=="boolean"))throw new Error(`WORKFLOW_V2_ROUTING_FACT_REQUIRED:${n}`);o[n]=String(s)}return o}function Br(e,t,o){let n=t.filter(d=>d.enabled&&(!d.validFrom||Date.parse(d.validFrom)<=o.at)&&(!d.validTo||Date.parse(d.validTo)>o.at)&&(!d.workflowCode||d.workflowCode===o.workflowCode)&&(!d.nodeId||d.nodeId===o.nodeId)&&Object.entries(d.matches).every(([u,l])=>l.includes(o.facts[u])));if(n.length>64)throw new Error("WORKFLOW_V2_ROUTING_MATCH_LIMIT_EXCEEDED");let i=(d,u)=>u.priority-d.priority||+!!d.workflowCode-+!!u.workflowCode||+!!d.nodeId-+!!u.nodeId||(d.ruleCode<u.ruleCode?-1:d.ruleCode>u.ruleCode?1:0),s=n.filter(d=>d.effect==="replace").sort(i);if(s.length>1&&s[0].priority===s[1].priority)throw new Error("WORKFLOW_V2_ROUTING_REPLACE_CONFLICT");let c=s[0],r=c&&e.strategy==="replace_only"?[]:n.filter(d=>d.effect==="append").sort(i),a=[...c?[c]:[],...r];return{matched:n.sort(i),replacement:c,applied:a,ignored:n.filter(d=>!a.includes(d))}}var ln=fs(require("crypto"),1);var _i="native-4",gi={"application-native-2":"1.0.0","authz.native-batch-explain":"1.0.0","authz.native-management":"1.0.0","authz.native-membership-batch":"1.0.0","deployment.durable-runs":"1.0.0","deployment.platform-executor":"1.0.0","environment.on-demand-production":"1.0.0","environment.runtime-lifecycle":"1.0.0","data-api-v2":"1.1.0","data.native-golden-crud":"1.0.0","data.audit-read-access":"1.0.0","data.managed-files":"1.1.0","data.decimal-reservations":"1.1.0","data.decimal-reservation-lifecycle":"1.0.0","data.unique-keys":"1.0.0","data.managed-concurrency":"1.0.0","data.managed-concurrency.durable":"1.0.0","workflow.named-input-sources":"1.0.0","directory-v2":"1.0.0","directory.selected-user":"1.0.0","events-v2":"1.0.0","events.durable-receipts":"1.0.0","events.capture-policy":"1.0.0","events.native-data-actions":"1.0.0","workflow-kernel-v2":"1.0.0","workflow.instance-cancellation-policy":"1.0.0","workflow.node-administration":"1.0.0","workflow.assignment-routing":"1.0.0","workflow.role-references":"1.0.0","workflow.delegation-management":"1.0.0","workflow.automatic-cc":"1.0.0","workflow.task-page-submit":"1.0.0","workflow.task-private-drafts":"1.0.0","workflow.task-managed-files":"1.0.0","workflow.durable-business-step":"1.0.0","business-process.durable-command":"1.1.0","workflow.fresh-command-token":"1.0.0","notification-hub-v2":"1.0.0","authentication.application-login-surface":"1.0.0","public-access.anonymous-owner-records":"1.0.0"};var id=5,sd=20,rd=50,ad=50,cd=100,nt=class extends Error{constructor(o,n){super(o);this.code=o;this.pointer=n;this.name="NativeDataPolicyExpressionV2Error"}code;pointer};function yt(e,t){let o=[],n=(i,s,c)=>{c>5&&Nt("NATIVE_DATA_POLICY_EXPRESSION_DEPTH_EXCEEDED",s);let r=Ai(i,s),a=["allOf","anyOf"].filter(l=>l in r);if(a.length===0){o.push({rule:r,pointer:s}),o.length>50&&Nt("NATIVE_DATA_POLICY_EXPRESSION_LEAVES_EXCEEDED",s);return}let d=a[0],u=r[d];(a.length!==1||Object.keys(r).length!==1||!Array.isArray(u)||u.length<1||u.length>20)&&Nt("NATIVE_DATA_POLICY_EXPRESSION_GROUP_INVALID",s),u.forEach((l,f)=>n(l,`${s}/${d}/${f}`,c+1))};return n(e,t,1),o}function uo(e,t){yt(e,t);let o=(n,i)=>{let s=Ai(n,i);if(Array.isArray(s.allOf))return lo(s.allOf.flatMap((c,r)=>o(c,`${i}/allOf/${r}`)),i);if(Array.isArray(s.anyOf)){let c=[[]];return s.anyOf.forEach((r,a)=>{let d=o(r,`${i}/anyOf/${a}`);c=lo(c.flatMap(u=>d.map(l=>[...u,...l])),i)}),c}return[[s]]};return lo(o(e,t),t)}function lo(e,t){let o=e.reduce((n,i)=>n+i.length,0);return(e.length>50||o>100)&&Nt("NATIVE_DATA_POLICY_EXPRESSION_EXPANSION_EXCEEDED",t),e}function Ai(e,t){return(!e||typeof e!="object"||Array.isArray(e))&&Nt("NATIVE_DATA_POLICY_EXPRESSION_NODE_INVALID",t),e}function Nt(e,t){throw new nt(e,t)}var Kr="openxiangda.config-bundle/v3",vi="openxiangda.contract-bundle/v3",Ei="openxiangda.native-configuration-projection/v1",Tt=_i,Gr=/^[a-f0-9]{64}$/,qr=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Jr=/^app:[a-z][a-z0-9]*(?:-[a-z0-9]+)*:[A-Za-z0-9:._*-]+$/,zr=/^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/,Yr=/^[a-z][a-z0-9]*(?:[-.][a-z0-9]+)*$/,Hr=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Xr=/^[A-Za-z][A-Za-z0-9_]{0,62}$/,Ii=/^[A-Za-z][A-Za-z0-9_]{0,127}$/,Qr=/^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$/,Zr=/^[A-Z][A-Z0-9_]*$/,ea=/^[a-z][a-z0-9-]{2,63}$/,ta=/^[A-Za-z][A-Za-z0-9_-]{0,127}$/,na=/^[A-Za-z][A-Za-z0-9_.]{0,127}$/,oa=16,ia=2*1024,sa=new Set(["text.short","text.long","number.integer","number.decimal","boolean","date","time","datetime","option.single","option.multiple","cascade.single","cascade.multiple","user.single","user.multiple","department.single","department.multiple","resource-ref.single","resource-ref.multiple","uuid","serial-number"]),ra=new Set(["overview","database","operations","workflow","members","calendar","document","folder","settings"]),aa=new Set(["approve","reject","return","transfer","delegate","add_assignee","resubmit","withdraw","terminate","admin_reassign","admin_override","retry_resolution"]),ca=4*1024*1024,da=8*1024*1024,la=40,ua=1e5,po=1024*1024,fa="openxiangda.event-handler-manifest/v2",Pi="openxiangda.application-route-manifest/v3",Ni=64,Li=new Set(["id","revision","created_by","updated_by","created_at","updated_at"]),Y=Object.freeze({perspectives:100,resources:100,subjectReadSurfaces:50,capabilities:2e3,operations:500,eventConsumers:100,eventProducers:1e3,eventSchemas:100,eventTypes:500,workflows:100,routes:500,adminPages:500,adminNavigationGroups:100,adminNavigationItems:500}),on=["openxiangda.data.record.created.v2","openxiangda.data.record.updated.v2","openxiangda.data.record.deleted.v2"],sn=[Qe,"openxiangda.workflow.step.result_received.v2","openxiangda.workflow.step.completed.v2","openxiangda.workflow.step.continuation_failed.v2","openxiangda.workflow.instance.started.v2","openxiangda.workflow.instance.cc_added.v2","openxiangda.workflow.instance.completed.v2","openxiangda.workflow.instance.rejected.v2","openxiangda.workflow.instance.returned.v2","openxiangda.workflow.instance.resumed.v2","openxiangda.workflow.instance.withdrawn.v2","openxiangda.workflow.instance.terminated.v2","openxiangda.workflow.task.created.v2","openxiangda.workflow.task.assigned.v2","openxiangda.workflow.task.assignment_pending.v2","openxiangda.workflow.task.assignment_resolution_failed.v2","openxiangda.workflow.task.approved.v2","openxiangda.workflow.task.completed.v2","openxiangda.workflow.task.rejected.v2","openxiangda.workflow.task.returned.v2","openxiangda.workflow.task.resubmitted.v2","openxiangda.workflow.task.transferred.v2","openxiangda.workflow.task.reassigned.v2","openxiangda.workflow.task.delegated.v2","openxiangda.workflow.task.assignee_added.v2","openxiangda.workflow.task.cancelled.v2","openxiangda.workflow.participant.activated.v2","openxiangda.workflow.participant.completed.v2","openxiangda.workflow.participant.rejected.v2","openxiangda.workflow.participant.returned.v2","openxiangda.workflow.participant.transferred.v2","openxiangda.workflow.participant.reassigned.v2","openxiangda.workflow.participant.delegated.v2","openxiangda.workflow.participant.added.v2","openxiangda.workflow.participant.suspended.v2","openxiangda.workflow.participant.resumed.v2","openxiangda.workflow.participant.cancelled.v2"],pa=new Set(sn),rn=class extends Error{code;pointer;identifiers;constructor(t,o,n={}){super(t),this.name="NativeConfigurationCompilerError",this.code=t,this.pointer=o,this.identifiers=Object.fromEntries(Object.entries(n).slice(0,8).map(([i,s])=>[i,String(s).slice(0,128)]))}};function ma(e){let t=C(e.appCode,"/appCode",128);qr.test(t)||_("NATIVE_CONFIG_APP_CODE_INVALID","/appCode");let o=_o(e.expectedConfigDigest,"/expectedConfigDigest"),n=_o(e.expectedContractDigest,"/expectedContractDigest"),i=Vi(e.configBytes,ca,"/configBytes","NATIVE_CONFIG_ARTIFACT_TOO_LARGE"),s=Vi(e.contractBytes,da,"/contractBytes","NATIVE_CONTRACT_ARTIFACT_TOO_LARGE");ki(i,o,"/configBytes","NATIVE_CONFIG_DIGEST_MISMATCH"),ki(s,n,"/contractBytes","NATIVE_CONTRACT_DIGEST_MISMATCH");let c=Di(i,"/configBytes","NATIVE_CONFIG_JSON_INVALID","NATIVE_CONFIG_NOT_CANONICAL"),r=Di(s,"/contractBytes","NATIVE_CONTRACT_JSON_INVALID","NATIVE_CONTRACT_NOT_CANONICAL");$i(c,"/config"),$i(r,"/contracts");let a=c,d=r;ga(a,t),Aa(d,t,o);let u=Ea(a,o,d.generatorVersion);ic(u,d,a),ee(u)!==ee(d)&&_("NATIVE_CONTRACT_CLOSURE_MISMATCH",go(u,d,"/contracts"));let l={authz:{appCode:t,...a.authz,perspectives:a.perspectives,capabilityCatalog:u.capabilities},data:{appCode:t,resources:a.data.resources,resourceContracts:u.resources,...u.concurrency?{concurrency:u.concurrency}:{},...u.subjectReadSurfaces?{subjectReadSurfaces:u.subjectReadSurfaces}:{}},events:{appCode:t,...a.events,consumers:u.eventConsumers,producers:u.eventProducers,handlerManifest:u.eventHandlerManifest,eventTypes:u.eventTypes,capturePlans:ji({resources:a.data.resources,dataPolicies:a.authz.dataPolicies,subscriptions:u.eventConsumers,capturePolicies:a.events.capturePolicies})},workflows:{appCode:t,...a.workflows,contracts:u.workflows},runtime:{appCode:t,requirements:a.runtime,backend:a.backend,frontend:a.frontend},contracts:u},f={authz:ot(l.authz),data:ot(l.data),events:ot(l.events),workflows:ot(l.workflows),runtime:ot(l.runtime),contracts:ot(l.contracts)},A={configDigest:o,contractDigest:n,generatorVersion:d.generatorVersion},N=xi(a),I={schemaVersion:Ei,compilerContractVersion:Tt,appCode:t,source:A,projections:f,requiredPlatformCapabilities:N,aggregateDigest:X({schemaVersion:Ei,compilerContractVersion:Tt,appCode:t,source:A,requiredPlatformCapabilities:N,projectionDigests:Object.fromEntries(Object.entries(f).map(([m,E])=>[m,E.digest]))})};return Xi(I)}function xi(e){let t=e.authz.roles,o=e.data.resources,n=e.backend.operations,i=t.some(m=>m.capabilities.some(E=>E.endsWith(":directory:read")))||o.some(m=>m.schema.fields.some(E=>["user.single","user.multiple","department.single","department.multiple"].includes(E.type)))||n.some(m=>m.platformAccess?.directory),s=!!(e.events.subscriptions.length||e.events.timers.length||e.events.dateTriggers.length||e.events.schemas.length),c=n.some(m=>m.platformAccess?.managedFiles||m.platformAccess?.managedFileCopies)||e.events.subscriptions.some(m=>m.platformAccess?.managedFileCopies),r=n.some(m=>m.platformAccess?.notification)||e.events.subscriptions.some(m=>m.platformAccess?.notification),a=e.workflows.definitions.filter(m=>{let E=o.find(p=>p.code===m.definition.subject?.resourceCode)?.schema.fields||[];return Object.values(m.definition.taskPages||{}).some(p=>p.fields.some(g=>!g.readonly&&E.some(O=>O.code===g.code&&["file","image"].includes(O.type))))}),d=e.workflows.definitions.filter(m=>m.launch.mode==="standalone"||m.launch.mode==="hidden-handoff"),u=n.some(m=>m.platformAccess?.workflow)||d.length>0,l=d.filter(m=>{let E=m.launch.submission;if(!E)return!1;let p=o.find(g=>g.code===m.definition.subject.resourceCode);return[E.create,E.existing].some(g=>g&&Object.values(g.inputs).some(O=>O.source==="field"&&p?.schema.fields.some(y=>y.code===O.fieldCode&&y.type.startsWith("resource-ref.")&&y.source)))}),f={resources:o},A={perspectives:e.perspectives,authz:e.authz},N={schemaVersion:e.schemaVersion,appCode:e.appCode,frontend:{routes:e.frontend.routes,user:e.frontend.user,admin:e.frontend.admin,devicePolicy:e.frontend.devicePolicy},backend:{operations:n.map(m=>({code:m.code,method:m.method,path:m.path,capability:m.capability,platformAccess:m.platformAccess||null,...m.browser?{browser:m.browser}:{},ai:m.ai||null}))}};return[...o.some(m=>m.uniqueKeys?.length)?[{code:"data.unique-keys",declaration:o.filter(m=>m.uniqueKeys?.length).map(m=>({code:m.code,uniqueKeys:m.uniqueKeys}))}]:[],...e.data.concurrency?[{code:"data.managed-concurrency",declaration:e.data.concurrency}]:[],...e.data.concurrency?.commands.some(m=>m.mode==="durable")?[{code:"data.managed-concurrency.durable",declaration:e.data.concurrency}]:[],...o.some(m=>m.decimalReservationLifecycle)?[{code:"data.decimal-reservation-lifecycle",declaration:o.filter(m=>m.decimalReservationLifecycle).map(m=>({code:m.code,decimalReservationLifecycle:m.decimalReservationLifecycle}))}]:[],...n.some(m=>m.platformAccess?.decimalReservation)||e.events.subscriptions.some(m=>m.platformAccess?.decimalReservation)?[{code:"data.decimal-reservations",declaration:[...n.filter(m=>m.platformAccess?.decimalReservation).map(m=>({code:m.code,decimalReservation:m.platformAccess.decimalReservation})),...e.events.subscriptions.filter(m=>m.platformAccess?.decimalReservation).map(m=>({subscriptionCode:m.code,decimalReservation:m.platformAccess.decimalReservation}))]}]:[],{code:"application-native-2",declaration:N},{code:"authz.native-batch-explain",declaration:A},{code:"authz.native-management",declaration:A},{code:"deployment.durable-runs",declaration:N.backend},{code:"deployment.platform-executor",declaration:N.backend},{code:"environment.on-demand-production",declaration:{environments:["preproduction","production"]}},{code:"environment.runtime-lifecycle",declaration:{environments:["preproduction","production"]}},...o.length?[{code:"data-api-v2",declaration:f},{code:"data.native-golden-crud",declaration:f}]:[],...o.some(hn)?[{code:"data.audit-read-access",declaration:f}]:[],...i?[{code:"directory-v2",declaration:{roles:t.map(m=>({code:m.code,capabilities:m.capabilities.filter(E=>E.endsWith(":directory:read"))})),resources:o.map(m=>({code:m.code,fields:m.schema.fields.filter(E=>["user.single","user.multiple","department.single","department.multiple"].includes(E.type))})),operations:n.filter(m=>m.platformAccess?.directory).map(m=>({code:m.code,directory:m.platformAccess.directory}))}}]:[],...n.some(m=>m.platformAccess?.directory?.mode==="selected-user")?[{code:"directory.selected-user",declaration:n.filter(m=>m.platformAccess?.directory?.mode==="selected-user").map(m=>({code:m.code,directory:m.platformAccess.directory}))}]:[],...c?[{code:"data.managed-files",declaration:{operations:n.filter(m=>m.platformAccess?.managedFiles||m.platformAccess?.managedFileCopies).map(m=>({code:m.code,...m.platformAccess?.managedFiles?{managedFiles:m.platformAccess.managedFiles}:{},...m.platformAccess?.managedFileCopies?{managedFileCopies:m.platformAccess.managedFileCopies}:{}})),subscriptions:e.events.subscriptions.filter(m=>m.platformAccess?.managedFileCopies).map(m=>({code:m.code,managedFileCopies:m.platformAccess.managedFileCopies}))}}]:[],...e.events.subscriptions.some(m=>m.execution)?[{code:"events.native-data-actions",declaration:e.events.subscriptions.filter(m=>m.execution)}]:[],...e.events.capturePolicies?.length?[{code:"events.capture-policy",declaration:e.events.capturePolicies}]:[],...s?[{code:"events-v2",declaration:e.events},{code:"events.durable-receipts",declaration:e.events}]:[],...e.workflows.activations.length?[{code:"workflow-kernel-v2",declaration:e.workflows},{code:"workflow.fresh-command-token",declaration:e.workflows}]:[],...e.workflows.definitions.some(m=>m.definition.instanceCommands!==void 0)?[{code:"workflow.instance-cancellation-policy",declaration:e.workflows.definitions.filter(m=>m.definition.instanceCommands!==void 0)}]:[],...l.length?[{code:"workflow.named-input-sources",declaration:l}]:[],...e.workflows.definitions.some(m=>Object.values(m.definition.nodes).some(E=>E.administration!==void 0||E.operationPolicy!==void 0))?[{code:"workflow.node-administration",declaration:e.workflows.definitions.filter(m=>Object.values(m.definition.nodes).some(E=>E.administration!==void 0||E.operationPolicy!==void 0))}]:[],...e.workflows.definitions.some(m=>Object.values(m.definition.nodes).some(E=>E.kind==="cc"))?[{code:"workflow.automatic-cc",declaration:e.workflows.definitions.filter(m=>Object.values(m.definition.nodes).some(E=>E.kind==="cc"))}]:[],...e.workflows.definitions.some(m=>m.definition.taskPages!==void 0)?["workflow.task-page-submit","workflow.task-private-drafts"].map(m=>({code:m,declaration:e.workflows.definitions.filter(E=>E.definition.taskPages!==void 0)})):[],...a.length?[{code:"workflow.task-managed-files",declaration:a}]:[],...e.workflows.definitions.some(m=>Object.values(m.definition.nodes).some(E=>E.kind==="action"))?[{code:"workflow.durable-business-step",declaration:e.workflows.definitions.filter(m=>Object.values(m.definition.nodes).some(E=>E.kind==="action"))}]:[],...e.workflows.bindings.some(m=>Object.values(m.binding.bindings).some(E=>E.routing!==void 0))?[{code:"workflow.assignment-routing",declaration:e.workflows.bindings.filter(m=>Object.values(m.binding.bindings).some(E=>E.routing!==void 0))}]:[],...u?[{code:"business-process.durable-command",declaration:{operations:n.filter(m=>m.platformAccess?.workflow).map(m=>({code:m.code,workflow:m.platformAccess.workflow})),definitions:d,activations:e.workflows.activations.filter(m=>d.some(E=>E.definition.code===m.workflowCode))}}]:[],...r?[{code:"notification-hub-v2",declaration:{operations:n.filter(m=>m.platformAccess?.notification).map(m=>({code:m.code,notification:m.platformAccess.notification})),subscriptions:e.events.subscriptions.filter(m=>m.platformAccess?.notification).map(m=>({code:m.code,notification:m.platformAccess.notification}))}}]:[],...e.frontend.authentication?[{code:"authentication.application-login-surface",declaration:e.frontend.authentication}]:[],...e.frontend.publicAccess?[{code:"public-access.anonymous-owner-records",declaration:e.frontend.publicAccess}]:[]].map(({code:m,declaration:E})=>({code:m,contractVersion:gi[m],usageDigest:`sha256:${X(E)}`})).sort((m,E)=>m.code===E.code?0:m.code<E.code?-1:1)}function ji(e){let t=new Map,o=new Set(e.resources.map(s=>String(s.code)));for(let[s,c]of S(e.capturePolicies===void 0?[]:e.capturePolicies,"/capturePlan/capturePolicies",100).entries()){let r=`/capturePlan/capturePolicies/${s}`,a=b(c,r);R(a,["resourceCode","mode"],r);let d=J(a.resourceCode,`${r}/resourceCode`);o.has(d)||_("NATIVE_EVENT_CAPTURE_RESOURCE_NOT_FOUND",r,{resourceCode:d}),t.has(d)&&_("NATIVE_EVENT_CAPTURE_POLICY_DUPLICATE",r,{resourceCode:d}),a.mode!=="all"&&a.mode!=="subscribed"&&_("NATIVE_EVENT_CAPTURE_MODE_INVALID",`${r}/mode`),t.set(d,a.mode)}let n=new Map(e.dataPolicies.map((s,c)=>{let r=b(s,`/capturePlan/dataPolicies/${c}`);return[String(r.code),r]})),i=e.subscriptions.map((s,c)=>b(s,`/capturePlan/subscriptions/${c}`));return e.resources.map((s,c)=>{let r=`/capturePlan/resources/${c}`,a=b(s,r),d=J(a.code,`${r}/code`),u=a.schema?b(a.schema,`${r}/schema`):a,l=new Set(S(u.fields||[],`${r}/schema/fields`,500).map((T,h)=>K(b(T,`${r}/schema/fields/${h}`).code,`${r}/schema/fields/${h}/code`))),f=a.dataPolicyCode?V(a.dataPolicyCode,`${r}/dataPolicyCode`):null,A=f?n.get(f):void 0;f&&!A&&_("NATIVE_EVENT_CAPTURE_AUTHZ_POLICY_NOT_FOUND",r,{resourceCode:d,dataPolicyCode:f});let N=new Set;for(let T of A?.rules||[])N.add(String(T.field));if(A?.readExpression)for(let T of yt(A.readExpression,`${r}/readExpression`))N.add(String(T.rule.field));let I=new Set,m=new Set,E=new Set;for(let[T,h]of i.entries()){let D=S(h.eventTypes,`/capturePlan/subscriptions/${T}/eventTypes`,20).map(String);if(!D.some(j=>j.startsWith("openxiangda.data.")))continue;let F=b(h.filter||{},`/capturePlan/subscriptions/${T}/filter`),k=Array.isArray(F.resourceCodes)?F.resourceCodes.map(String):[];if(k.length&&!k.includes(d))continue;for(let j of D)on.includes(j)&&E.add(j);for(let j of _a(F,`/capturePlan/subscriptions/${T}/filter`))I.add(j);let U=b(h.payload||{},`/capturePlan/subscriptions/${T}/payload`);for(let j of S(U.fields||[],`/capturePlan/subscriptions/${T}/payload/fields`,32))m.add(K(j,`/capturePlan/subscriptions/${T}/payload/fields`))}let p=new Set([...I,...m]),g=new Set([...p,...N]);g.size>Ni&&_("NATIVE_EVENT_CAPTURE_FIELDS_LIMIT",r,{resourceCode:d,maximum:Ni});for(let T of g)!l.has(T)&&!(N.has(T)&&Li.has(T))&&_("NATIVE_EVENT_CAPTURE_FIELD_NOT_FOUND",r,{resourceCode:d,field:T});let O=b(a.fieldPolicies||{},`${r}/fieldPolicies`);for(let T of p)O[T]?.mask==="omit"&&_("NATIVE_EVENT_CAPTURE_FIELD_SENSITIVE",r,{resourceCode:d,field:T});let y={resourceCode:d,...t.get(d)==="subscribed"?{capturedEventTypes:[...E].sort()}:{},filterFields:[...I].sort(),projectionFields:[...m].sort(),authorizationFields:[...N].sort(),captureFields:[...g].sort()};return{...y,digest:X(y)}}).sort((s,c)=>s.resourceCode.localeCompare(c.resourceCode))}function _a(e,t){let o=new Set;for(let[c,r]of S(e.changes||[],`${t}/changes`,16).entries()){let a=b(r,`${t}/changes/${c}`);o.add(K(a.field,`${t}/changes/${c}/field`))}let n=b(e.changedFields||{},`${t}/changedFields`);for(let c of["anyOf","allOf","noneOf"])for(let[r,a]of S(n[c]||[],`${t}/changedFields/${c}`,32).entries())o.add(K(a,`${t}/changedFields/${c}/${r}`));let i=0,s=(c,r,a)=>{a>3&&_("NATIVE_EVENT_FILTER_DEPTH_LIMIT",r);let d=b(c,r);if(d.change){let l=b(d.change,`${r}/change`);o.add(K(l.field,`${r}/change/field`)),i+=1;return}if(d.not){s(d.not,`${r}/not`,a+1);return}let u=d.all?"all":d.any?"any":null;u||_("NATIVE_EVENT_FILTER_CONDITION_INVALID",r);for(let[l,f]of S(d[u],`${r}/${u}`,16).entries())s(f,`${r}/${u}/${l}`,a+1)};return e.where&&s(e.where,`${t}/where`,1),i+=Array.isArray(e.changes)?e.changes.length:0,i>16&&_("NATIVE_EVENT_FILTER_ATOM_LIMIT",t),[...o].sort()}function ga(e,t){R(e,["schemaVersion","compilerContractVersion","appCode","perspectives","authz","backend","data","events","workflows","frontend","runtime"],"/config"),x(e.schemaVersion,Kr,"/config/schemaVersion"),x(e.compilerContractVersion,Tt,"/config/compilerContractVersion"),x(e.appCode,t,"/config/appCode"),S(e.perspectives,"/config/perspectives",100);let o=b(e.authz,"/config/authz");R(o,["capabilities","roles","scopeDimensions","scopeSources","roleMembershipSources","relationshipGrantSources","dataPolicies","authorizationTransitions"],"/config/authz",["authenticatedUserRoleCode"]),S(o.capabilities,"/config/authz/capabilities",2e3),S(o.roles,"/config/authz/roles",100),S(o.scopeDimensions,"/config/authz/scopeDimensions",100),S(o.scopeSources,"/config/authz/scopeSources",100),S(o.roleMembershipSources,"/config/authz/roleMembershipSources",100),S(o.relationshipGrantSources,"/config/authz/relationshipGrantSources",100),S(o.dataPolicies,"/config/authz/dataPolicies",100),S(o.authorizationTransitions,"/config/authz/authorizationTransitions",100);let n=b(e.backend,"/config/backend");R(n,["secrets","operations"],"/config/backend"),S(n.secrets,"/config/backend/secrets",100),S(n.operations,"/config/backend/operations",500),Qa(n.secrets);let i=b(e.data,"/config/data");R(i,["resources"],"/config/data",["resourceDetailRoutes","subjectReadSurfaces","concurrency"]),S(i.resources,"/config/data/resources",100),i.subjectReadSurfaces!==void 0&&S(i.subjectReadSurfaces,"/config/data/subjectReadSurfaces",Y.subjectReadSurfaces),i.resourceDetailRoutes!==void 0&&S(i.resourceDetailRoutes,"/config/data/resourceDetailRoutes",100);let s=b(e.events,"/config/events");R(s,["schemas","subscriptions","timers","dateTriggers"],"/config/events",["capturePolicies"]),S(s.schemas,"/config/events/schemas",100),S(s.subscriptions,"/config/events/subscriptions",100),S(s.timers,"/config/events/timers",100),S(s.dateTriggers,"/config/events/dateTriggers",100);let c=b(e.workflows,"/config/workflows");R(c,["definitions","bindings","activations","providers","editableParameters"],"/config/workflows"),S(c.definitions,"/config/workflows/definitions",100),S(c.bindings,"/config/workflows/bindings",100),S(c.activations,"/config/workflows/activations",100),S(c.providers,"/config/workflows/providers",100),S(c.editableParameters,"/config/workflows/editableParameters",100);let r=b(e.frontend,"/config/frontend");R(r,["routes","user","admin","devicePolicy"],"/config/frontend",["authentication","publicAccess"]),S(r.routes,"/config/frontend/routes",500);let a=b(r.user,"/config/frontend/user");R(a,["applicationTodoCenter"],"/config/frontend/user"),st(a.applicationTodoCenter,"/config/frontend/user/applicationTodoCenter"),Ao(r.devicePolicy,"/config/frontend/devicePolicy"),Object.prototype.hasOwnProperty.call(r,"authentication")&&Wi(r.authentication,r.routes,e,"/config/frontend/authentication"),Object.prototype.hasOwnProperty.call(r,"publicAccess")&&ka(r.publicAccess,e,"/config/frontend/publicAccess");let d=b(r.admin,"/config/frontend/admin");R(d,["navigation"],"/config/frontend/admin",["access"]),d.access!==void 0&&fn(d.access,"/config/frontend/admin/access",e.appCode),La(d.navigation,"/config/frontend/admin/navigation");let u=b(e.runtime,"/config/runtime");R(u,["protocolCapabilities","health"],"/config/runtime"),v(u.protocolCapabilities,"/config/runtime/protocolCapabilities",100),R(b(u.health,"/config/runtime/health"),["livePath","readyPath","versionPath"],"/config/runtime/health"),x(u.health.livePath,"/__platform/health","/config/runtime/health/livePath"),x(u.health.readyPath,"/__platform/ready","/config/runtime/health/readyPath"),x(u.health.versionPath,"/__platform/version","/config/runtime/health/versionPath")}function Aa(e,t,o){R(e,["schemaVersion","compilerContractVersion","generatorVersion","appCode","configDigest","perspectives","resources","capabilities","operations","eventConsumers","eventProducers","eventSchemas","eventHandlerManifest","eventTypes","workflows","routes","routeManifest","adminPages","adminNavigation"],"/contracts",["authentication","publicAccess","adminAccess","subjectReadSurfaces","concurrency"]),x(e.schemaVersion,vi,"/contracts/schemaVersion"),x(e.compilerContractVersion,Tt,"/contracts/compilerContractVersion"),C(e.generatorVersion,"/contracts/generatorVersion",128),x(e.appCode,t,"/contracts/appCode"),x(e.configDigest,o,"/contracts/configDigest"),S(e.perspectives,"/contracts/perspectives",Y.perspectives),S(e.resources,"/contracts/resources",Y.resources),e.subjectReadSurfaces!==void 0&&S(e.subjectReadSurfaces,"/contracts/subjectReadSurfaces",Y.subjectReadSurfaces),S(e.capabilities,"/contracts/capabilities",Y.capabilities),S(e.operations,"/contracts/operations",Y.operations),S(e.eventConsumers,"/contracts/eventConsumers",Y.eventConsumers),S(e.eventProducers,"/contracts/eventProducers",Y.eventProducers),S(e.eventSchemas,"/contracts/eventSchemas",Y.eventSchemas),b(e.eventHandlerManifest,"/contracts/eventHandlerManifest"),v(e.eventTypes,"/contracts/eventTypes",Y.eventTypes),S(e.workflows,"/contracts/workflows",Y.workflows),S(e.routes,"/contracts/routes",Y.routes),Object.prototype.hasOwnProperty.call(e,"authentication")&&Da(e.authentication,"/contracts/authentication"),Object.prototype.hasOwnProperty.call(e,"publicAccess")&&Fa(e.publicAccess,"/contracts/publicAccess"),Object.prototype.hasOwnProperty.call(e,"adminAccess")&&fn(e.adminAccess,"/contracts/adminAccess",t),Ba(e.routeManifest,"/contracts/routeManifest",t),Ma(e.adminPages,"/contracts/adminPages"),Wa(e.adminNavigation,"/contracts/adminNavigation")}function Ea(e,t,o){let n=ya(e);za(e,n),Ha(e),Ya(e),Za(e);let i=e.events.schemas.map((p,g)=>{let O=`/config/events/schemas/${g}`,y=b(p,O),T=C(y.eventType,`${O}/eventType`,255);return T.startsWith("openxiangda.")&&_("NATIVE_EVENT_SCHEMA_RESERVED",`${O}/eventType`,{eventType:T}),x(y.schemaDigest,X(b(y.jsonSchema,`${O}/jsonSchema`)),`${O}/schemaDigest`),y}),s=new Set([...on,...sn,...i.map(p=>String(p.eventType))]),c=new Map(e.data.resources.map(p=>[String(p.code),new Map(p.schema.fields.map(g=>[String(g.code),String(g.type)]))])),r=Z(e.events.subscriptions.map((p,g)=>{let O=`/config/events/subscriptions/${g}`,y=b(p,O),T=v(y.eventTypes,`${O}/eventTypes`,20);T.forEach((k,U)=>{s.has(k)||_("NATIVE_EVENT_TYPE_NOT_REGISTERED",`${O}/eventTypes/${U}`,{eventType:k})});let h=Jn(y,e.data.resources,O),D=Na(y.delivery,T,`${O}/delivery`),F=Ia(y.platformAccess,`${O}/platformAccess`,c,e,y);return{code:V(y.code,`${O}/code`),endpointPath:ge(y.endpointPath,`${O}/endpointPath`),eventTypes:T,filter:b(y.filter,`${O}/filter`),payload:h?.payload||b(y.payload,`${O}/payload`),...h?{execution:h.execution}:{},...F?{platformAccess:F}:{},delivery:D}}),p=>p.code),a=new Map(i.map(p=>[String(p.eventType),String(p.dataSchemaVersion)])),d=Z([...e.data.resources.flatMap(p=>on.map(g=>({code:`data:${p.code}:${g}`,source:"data",eventType:g,dataSchemaVersion:"2.0.0",resourceCode:p.code}))),...i.map(p=>({code:`app:${p.eventType}`,source:"app",eventType:p.eventType,dataSchemaVersion:p.dataSchemaVersion})),...e.events.timers.map(p=>({code:p.code,source:"timer",eventType:p.eventType,dataSchemaVersion:a.get(String(p.eventType))||"2.0.0"})),...e.events.dateTriggers.map(p=>({code:p.code,source:"date",eventType:p.eventType,dataSchemaVersion:a.get(String(p.eventType))||"2.0.0",resourceCode:p.resourceCode,field:p.field})),...e.workflows.activations.length?sn.filter(p=>!Qn.includes(p)||e.workflows.definitions.some(g=>Object.values(g.definition.nodes).some(O=>O.kind==="action"))).map(p=>({code:`workflow:${p}`,source:"workflow",eventType:p,dataSchemaVersion:"2.0.0"})):[]],p=>`${p.source}:${p.code}:${p.eventType}`),u=W([...r.flatMap(p=>p.eventTypes),...d.map(p=>String(p.eventType))]);ja(e);let l=Ki(e),f;try{f=Pn(e.data.concurrency,e.data.resources,n)}catch(p){throw p instanceof Ye&&_(p.code,p.pointer,{reason:p.reason}),p}f?.commands.some(p=>p.mode==="durable")&&e.backend?.enabled===!1&&_("NATIVE_MANAGED_CONCURRENCY_INVALID","/data/concurrency",{reason:"durable commands require backend runtime"});let A=Ta(e,n),N=Mi(e),I=e.workflows.definitions.map(p=>p.definition),m=zt(I),E=eo(I,r,!0);E.length&&_(E[0],"/config/events/subscriptions");try{Mn(e.data.resources,N)}catch(p){throw p instanceof Fe&&_(p.code,p.pointer,{reason:p.reason}),p}return{schemaVersion:vi,compilerContractVersion:Tt,generatorVersion:o,appCode:e.appCode,configDigest:t,perspectives:e.perspectives,resources:ba(e),...A.length?{subjectReadSurfaces:A}:{},...f?{concurrency:f}:{},capabilities:Z(n,p=>p.code),operations:N,eventConsumers:r,eventProducers:d,eventSchemas:i,eventHandlerManifest:{schemaVersion:fa,appCode:e.appCode,handlers:r.filter(p=>!p.execution).map(p=>({code:p.code,endpointPath:p.endpointPath,eventTypes:p.eventTypes,dataSchemaVersions:W(p.eventTypes.map(g=>g.startsWith("openxiangda.")?"2.0.0":a.get(g)||"2.0.0")),maxBodyBytes:65536,receiptProtocolVersion:2,...m[p.code]?{workflowStep:m[p.code]}:{}}))},eventTypes:u,workflows:Ji(e),routes:un(e),...Object.prototype.hasOwnProperty.call(e.frontend,"authentication")?{authentication:$a(e)}:{},...Object.prototype.hasOwnProperty.call(e.frontend,"publicAccess")?{publicAccess:va(e)}:{},...e.frontend.admin.access?{adminAccess:e.frontend.admin.access}:{},routeManifest:qa(e),adminPages:l,adminNavigation:Pa(e)}}function Ia(e,t,o,n,i){if(e===void 0)return;let s=b(e,t);R(s,["notification","managedFileCopies","decimalReservation"],t,!0);let c={};if(s.decimalReservation!==void 0)try{c.decimalReservation=Ho(s.decimalReservation,Xo(n,i))}catch{_("NATIVE_EVENT_DECIMAL_RESERVATION_INVALID",`${t}/decimalReservation`)}if(s.notification!==void 0){let r=b(s.notification,`${t}/notification`);R(r,["mode"],`${t}/notification`),x(r.mode,"business-standard",`${t}/notification/mode`),c.notification={mode:"business-standard"}}if(s.managedFileCopies!==void 0){let r=S(s.managedFileCopies,`${t}/managedFileCopies`,16);r.length||_("NATIVE_EVENT_MANAGED_FILE_COPIES_REQUIRED",`${t}/managedFileCopies`);let a=new Set;c.managedFileCopies=Z(r.map((d,u)=>{let l=`${t}/managedFileCopies/${u}`,f=b(d,l);R(f,["mode","sourceResourceCode","sourceFieldCodes","targetResourceCode","targetFieldCodes"],l),x(f.mode,"copy",`${l}/mode`);let A=J(f.sourceResourceCode,`${l}/sourceResourceCode`),N=J(f.targetResourceCode,`${l}/targetResourceCode`),I=o.get(A),m=o.get(N);(!I||!m)&&_("NATIVE_EVENT_MANAGED_FILE_COPY_RESOURCE_INVALID",l);let E=v(f.sourceFieldCodes,`${l}/sourceFieldCodes`,16),p=v(f.targetFieldCodes,`${l}/targetFieldCodes`,16);(!E.length||E.length!==p.length)&&_("NATIVE_EVENT_MANAGED_FILE_COPY_FIELDS_INVALID",l),E.forEach((O,y)=>{let T=I.get(O),h=m.get(p[y]);(!["file","image"].includes(String(T))||T!==h)&&_("NATIVE_EVENT_MANAGED_FILE_COPY_FIELD_INVALID",`${l}/sourceFieldCodes/${y}`)});let g=`${A}:${E.join(",")}=>${N}:${p.join(",")}`;return a.has(g)&&_("NATIVE_EVENT_MANAGED_FILE_COPY_DUPLICATE",l),a.add(g),{mode:"copy",sourceResourceCode:A,sourceFieldCodes:W(E),targetResourceCode:N,targetFieldCodes:W(p)}}),d=>`${d.sourceResourceCode}:${d.sourceFieldCodes.join(",")}=>${d.targetResourceCode}:${d.targetFieldCodes.join(",")}`)}return Object.keys(c).length||_("NATIVE_EVENT_PLATFORM_ACCESS_EMPTY",t),c}function Na(e,t,o){let n=b(e,o);R(n,["timeoutMs","maxAttempts","initialBackoffMs","maxBackoffMs","ordering","concurrency"],o),te(n.timeoutMs,`${o}/timeoutMs`,1e3,3e4),te(n.maxAttempts,`${o}/maxAttempts`,1,12);let i=te(n.initialBackoffMs,`${o}/initialBackoffMs`,1e3,3e5);te(n.maxBackoffMs,`${o}/maxBackoffMs`,i,18e5),te(n.concurrency,`${o}/concurrency`,1,50);let s=C(n.ordering,`${o}/ordering`,32);return["none","record","workflow-instance"].includes(s)||_("NATIVE_EVENT_DELIVERY_ORDERING_INVALID",`${o}/ordering`),s==="workflow-instance"&&t.some(c=>!pa.has(c))&&_("NATIVE_EVENT_WORKFLOW_ORDERING_REQUIRES_WORKFLOW_FACTS",`${o}/ordering`),n}function ya(e){let t=new Map;for(let o of Hi(e.appCode))t.set(o.code,o);for(let[o,n]of e.authz.capabilities.entries()){let i=`/config/authz/capabilities/${o}`,s=b(n,i);R(s,["code","kind","name","description"],i,!0);let c=we(s.code,`${i}/code`,e.appCode);t.has(c)&&_("NATIVE_CAPABILITY_DUPLICATE",`${i}/code`),["backend","ui"].includes(s.kind)||_("NATIVE_CAPABILITY_KIND_INVALID",`${i}/kind`);let r={code:c,kind:s.kind,name:C(s.name,`${i}/name`,255),source:"explicit",...s.description===void 0?{}:{description:Io(s.description,`${i}/description`,2e3)}};t.set(c,r)}for(let[o,n]of e.data.resources.entries()){let i=`/config/data/resources/${o}`,s=We(n,i,e.appCode),c={read:`\u8BFB\u53D6${s.name}`,create:`\u65B0\u5EFA${s.name}`,update:`\u66F4\u65B0${s.name}`,delete:`\u5220\u9664${s.name}`};for(let r of["read","create","update","delete"]){let a=we(s.capabilities[r],`${i}/capabilities/${r}`,e.appCode);t.has(a)&&_("NATIVE_CAPABILITY_DUPLICATE",`${i}/capabilities/${r}`),t.set(a,{code:a,kind:"data",name:c[r],source:"data"})}for(let[r,a]of Object.entries(s.fieldPolicies)){if(Ge(r))continue;let d=b(a,`${i}/fieldPolicies/${r}`);for(let u of["read","create","update"])if(Array.isArray(d[u]))for(let l of v(d[u],`${i}/fieldPolicies/${r}/${u}`,2e3))we(l,`${i}/fieldPolicies/${r}/${u}`,e.appCode),!t.has(l)&&t.set(l,{code:l,kind:"data",name:`${s.name}.${r}.${u}`,source:"data"})}}return[...t.values()]}function ba(e){let t=Oa(e);return Z(e.data.resources.map((o,n)=>{let i=We(o,`/config/data/resources/${n}`,e.appCode),s=t.get(i.code);return{code:i.code,schemaDigest:X(i.schema),fields:Z(i.schema.fields.map(c=>({code:c.code,type:c.type})),c=>c.code),...s?{detailRouteCode:s}:{}}}),o=>o.code)}function Ta(e,t){if(e.data.subjectReadSurfaces===void 0)return[];let o=S(e.data.subjectReadSurfaces,"/config/data/subjectReadSurfaces",Y.subjectReadSurfaces),n=new Set(t.map(c=>String(c.code))),i=new Map(e.data.resources.map((c,r)=>{let a=`/config/data/resources/${r}`,d=We(c,a,e.appCode);return[String(d.code),{resource:d,fields:new Map(S(b(d.schema,`${a}/schema`).fields,`${a}/schema/fields`,500).map(u=>{let l=b(u,`${a}/schema/fields`);return[String(l.code),l]}))}]})),s=new Set;return Z(o.map((c,r)=>{let a=`/config/data/subjectReadSurfaces/${r}`,d=b(c,a);R(d,["code","name","capability","subject","relations"],a);let u=V(d.code,`${a}/code`);s.has(u)&&_("NATIVE_SUBJECT_READ_SURFACE_CODE_DUPLICATE",`${a}/code`),s.add(u);let l=we(d.capability,`${a}/capability`,e.appCode);n.has(l)||_("NATIVE_SUBJECT_READ_SURFACE_CAPABILITY_NOT_DECLARED",`${a}/capability`);let f=b(d.subject,`${a}/subject`);R(f,["resourceCode","fields"],`${a}/subject`);let A=J(f.resourceCode,`${a}/subject/resourceCode`),N=i.get(A);N||_("NATIVE_SUBJECT_READ_SURFACE_RESOURCE_NOT_DECLARED",`${a}/subject/resourceCode`);let I=v(f.fields,`${a}/subject/fields`,100).map((O,y)=>K(O,`${a}/subject/fields/${y}`));I.length||_("NATIVE_SUBJECT_READ_SURFACE_FIELDS_REQUIRED",`${a}/subject/fields`);for(let[O,y]of I.entries()){let T=N.fields.get(y);(!T||T.type==="subtable")&&_("NATIVE_SUBJECT_READ_SURFACE_FIELD_INVALID",`${a}/subject/fields/${O}`)}let m=S(d.relations,`${a}/relations`,8);m.length||_("NATIVE_SUBJECT_READ_SURFACE_RELATIONS_REQUIRED",`${a}/relations`);let E=new Set,p=0,g=Z(m.map((O,y)=>{let T=`${a}/relations/${y}`,h=b(O,T);R(h,["code","resourceCode","foreignKeyField","fields","limit"],T,["order"]);let D=V(h.code,`${T}/code`);E.has(D)&&_("NATIVE_SUBJECT_READ_SURFACE_RELATION_CODE_DUPLICATE",`${T}/code`),E.add(D);let F=J(h.resourceCode,`${T}/resourceCode`),k=i.get(F);k||_("NATIVE_SUBJECT_READ_SURFACE_RESOURCE_NOT_DECLARED",`${T}/resourceCode`);let U=K(h.foreignKeyField,`${T}/foreignKeyField`),j=k.fields.get(U),se=b(j?.source||{},`${T}/foreignKeyField/source`);(!j||!["uuid","resource-ref.single"].includes(String(j.type))||j.type==="resource-ref.single"&&(se.kind!=="resource"||se.resourceCode!==A))&&_("NATIVE_SUBJECT_READ_SURFACE_RELATION_INVALID",`${T}/foreignKeyField`);let Ae=v(h.fields,`${T}/fields`,100).map((ae,$)=>K(ae,`${T}/fields/${$}`));Ae.length||_("NATIVE_SUBJECT_READ_SURFACE_FIELDS_REQUIRED",`${T}/fields`);for(let[ae,$]of Ae.entries()){let M=k.fields.get($);(!M||M.type==="subtable")&&_("NATIVE_SUBJECT_READ_SURFACE_FIELD_INVALID",`${T}/fields/${ae}`)}let H=S(h.order||[],`${T}/order`,10).map((ae,$)=>{let M=`${T}/order/${$}`,P=b(ae,M);R(P,["field","direction"],M);let G=K(P.field,`${M}/field`),q=k.fields.get(G);return(!Li.has(G)&&!q||q?.type==="subtable"||q&&!Je(q.type))&&_("NATIVE_SUBJECT_READ_SURFACE_ORDER_FIELD_INVALID",`${M}/field`),["asc","desc"].includes(String(P.direction))||_("NATIVE_SUBJECT_READ_SURFACE_ORDER_DIRECTION_INVALID",`${M}/direction`),{field:G,direction:P.direction}}),be=te(h.limit,`${T}/limit`,1,100);return p+=be,{code:D,resourceCode:F,foreignKeyField:U,fields:W(Ae),...H.length?{order:H}:{},limit:be}}),O=>O.code);return p>400&&_("NATIVE_SUBJECT_READ_SURFACE_ROW_LIMIT_EXCEEDED",`${a}/relations`),{code:u,name:C(d.name,`${a}/name`,255),capability:l,subject:{resourceCode:A,fields:W(I)},relations:g}}),c=>c.code)}function Oa(e){let t=e.data.resourceDetailRoutes===void 0?[]:S(e.data.resourceDetailRoutes,"/config/data/resourceDetailRoutes",100),o=new Map(e.data.resources.map((s,c)=>{let r=`/config/data/resources/${c}`,a=We(s,r,e.appCode);return[a.code,a]})),n=new Map(un(e).map(s=>[String(s.code),s])),i=new Map;for(let[s,c]of t.entries()){let r=`/config/data/resourceDetailRoutes/${s}`,a=b(c,r);R(a,["resourceCode","desktop","mobile"],r);let d=J(a.resourceCode,`${r}/resourceCode`);i.has(d)&&_("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_DUPLICATE",`${r}/resourceCode`);let u=o.get(d);u||_("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_RESOURCE_MISSING",`${r}/resourceCode`);let l=V(a.desktop,`${r}/desktop`),f=V(a.mobile,`${r}/mobile`);l===f&&_("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_INVALID",r);let A=String(u.capabilities.read);for(let[N,I]of[["desktop",l],["mobile",f]]){let m=`${r}/${N}`,E=n.get(I);E||_("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_REFERENCE_MISSING",m),E.surface!=="user"&&_("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_SURFACE_INVALID",m);let p=ge(E.path,`${m}/path`),g=[...p.matchAll(/:([A-Za-z][A-Za-z0-9_]*)/g)],O=N==="mobile"?!p.startsWith("/m/"):p==="/m"||p.startsWith("/m/");(p.includes("*")||p.includes("?")||p.includes("#")||p.split("/").includes("..")||g.length!==1||O)&&_("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_PATH_INVALID",m);let y=Array.isArray(E.access?.allOf)?E.access.allOf:[];E.capability!==A&&!y.includes(A)&&_("NATIVE_DATA_RESOURCE_DETAIL_ROUTE_CAPABILITY_INVALID",m)}i.set(d,{desktop:l,mobile:f})}return i}function Mi(e){let t=new Map(e.data.resources.map((c,r)=>{let a=`/config/data/resources/${r}`,d=We(c,a,e.appCode);return[d.code,new Map(d.schema.fields.map(u=>[String(u.code),u]))]})),o=new Map(e.data.resources.map((c,r)=>{let a=`/config/data/resources/${r}`,d=We(c,a,e.appCode);return[d.code,new Map(d.schema.fields.map(u=>[String(u.code),String(u.type)]))]})),n=new Set(o.keys()),i=new Set(e.workflows.activations.map((c,r)=>pn(b(c,`/config/workflows/activations/${r}`).workflowCode,`/config/workflows/activations/${r}/workflowCode`))),s=new Map;return Z(e.backend.operations.map((c,r)=>{let a=`/config/backend/operations/${r}`,d=b(c,a);R(d,["code","method","path","capability","requestSchema","responseSchema","description","platformAccess","browser","ai"],a,!0);let u=C(d.method,`${a}/method`,16);["GET","POST","PUT","PATCH","DELETE"].includes(u)||_("NATIVE_OPERATION_METHOD_INVALID",`${a}/method`);let l=V(d.code,`${a}/code`);Sa(d.ai,a,l,u,n);let f=Ca(d.platformAccess,`${a}/platformAccess`,o,t,i,new Set(e.authz.roles.map(N=>String(N.code))));if(f?.decimalReservation){let N=f.decimalReservation,I=String(N.resourceCode),m=JSON.stringify([N.amountFieldCode,N.currencyFieldCode,N.relationFieldCode,N.parentFieldCode,N.rootFieldCode,N.statusFieldCode,N.parentRelationValue,N.childRelationValue]),E=s.get(I);E&&E!==m&&_("NATIVE_DECIMAL_RESERVATION_MAPPING_CONFLICT",`${a}/platformAccess/decimalReservation`),s.set(I,m)}let A=ha(d.browser,`${a}/browser`,u,d.requestSchema,d.responseSchema,o,t,e.data.subjectReadSurfaces||[]);return{code:l,method:u,path:ge(d.path,`${a}/path`),requiredCapability:we(d.capability,`${a}/capability`,e.appCode),requestSchemaDigest:X(b(d.requestSchema,`${a}/requestSchema`)),responseSchemaDigest:X(b(d.responseSchema,`${a}/responseSchema`)),...d.description===void 0?{}:{description:Io(d.description,`${a}/description`,2e3)},...f?{platformAccess:f}:{},...A?{browser:A}:{}}}),c=>c.code)}function ha(e,t,o,n,i,s,c,r){if(e===void 0)return null;let a=b(e,t);R(a,["exposure","behavior","idempotency","subject"],t,["refreshTargets","fileIntent"]),x(a.exposure,"authenticated",`${t}/exposure`);let d=C(a.behavior,`${t}/behavior`,32);["read","controlled"].includes(d)||_("NATIVE_OPERATION_BROWSER_BEHAVIOR_INVALID",`${t}/behavior`);let u=C(a.idempotency,`${t}/idempotency`,32);(!["none","required"].includes(u)||d==="controlled"&&u!=="required"||d==="read"&&u!=="none")&&_("NATIVE_OPERATION_BROWSER_IDEMPOTENCY_INVALID",`${t}/idempotency`);let l=b(a.subject,`${t}/subject`);R(l,["resourceCode","inputField"],`${t}/subject`);let f=J(l.resourceCode,`${t}/subject/resourceCode`);s.has(f)||_("NATIVE_OPERATION_BROWSER_SUBJECT_RESOURCE_NOT_DECLARED",`${t}/subject/resourceCode`);let A=K(l.inputField,`${t}/subject/inputField`),N=b(n,`${t}/requestSchema`),I=b(i,`${t}/responseSchema`);(N.type!=="object"||N.additionalProperties!==!1||I.type!=="object"||I.additionalProperties!==!1)&&_("NATIVE_OPERATION_BROWSER_SCHEMA_ROOT_INVALID",`${t}/requestSchema`);let m=b(N.properties,`${t}/requestSchema/properties`),E=new Set(N.required===void 0?[]:v(N.required,`${t}/requestSchema/required`,200));(!(A in m)||!E.has(A))&&_("NATIVE_OPERATION_BROWSER_SUBJECT_INPUT_INVALID",`${t}/subject/inputField`);let p=b(m[A],`${t}/requestSchema/properties/${A}`);(p.type!=="string"||p.format!=="uuid")&&_("NATIVE_OPERATION_BROWSER_SUBJECT_INPUT_INVALID",`${t}/subject/inputField`);let g=new Map((Array.isArray(r)?r:[]).map((D,F)=>{let k=b(D,`/config/data/subjectReadSurfaces/${F}`);return[String(k.code),String(b(k.subject,`/config/data/subjectReadSurfaces/${F}/subject`).resourceCode)]})),O=a.refreshTargets===void 0?[]:S(a.refreshTargets,`${t}/refreshTargets`,16),y=new Set,T=Z(O.map((D,F)=>{let k=`${t}/refreshTargets/${F}`,U=b(D,k);R(U,["kind","code"],k),x(U.kind,"subject-surface",`${k}/kind`);let j=V(U.code,`${k}/code`);return(y.has(j)||!g.has(j)||g.get(j)!==f)&&_("NATIVE_OPERATION_BROWSER_REFRESH_TARGET_INVALID",`${k}/code`),y.add(j),{kind:"subject-surface",code:j}}),D=>`${D.kind}:${D.code}`),h=Ra(a.fileIntent,`${t}/fileIntent`,o,d,u,f,m,E,c);return{exposure:"authenticated",behavior:d,idempotency:u,subject:{resourceCode:f,inputField:A},...T.length?{refreshTargets:T}:{},...h?{fileIntent:h}:{}}}function Ra(e,t,o,n,i,s,c,r,a){if(e===void 0)return null;let d=b(e,t);R(d,["recordResourceCode","recordIdInputField","relationField","fileNameField","contentTypeField","sizeField","purposes","maxTtlSeconds","maxBytes"],t),(o!=="GET"||n!=="read"||i!=="none")&&_("NATIVE_OPERATION_FILE_INTENT_BEHAVIOR_INVALID",t);let u=J(d.recordResourceCode,`${t}/recordResourceCode`),l=a.get(u);l||_("NATIVE_OPERATION_FILE_INTENT_RESOURCE_NOT_DECLARED",`${t}/recordResourceCode`);let f=K(d.recordIdInputField,`${t}/recordIdInputField`),A=b(c[f],`${t}/recordIdInputField`);(!r.has(f)||A.type!=="string"||A.format!=="uuid")&&_("NATIVE_OPERATION_FILE_INTENT_RECORD_INPUT_INVALID",`${t}/recordIdInputField`);let N=K(d.relationField,`${t}/relationField`),I=l.get(N);(!I||!["uuid","resource-ref.single"].includes(String(I.type))||String(I.type)==="resource-ref.single"&&(String(b(I.source,`${t}/relationField`).kind||"")!=="resource"||String(b(I.source,`${t}/relationField`).resourceCode||"")!==s))&&_("NATIVE_OPERATION_FILE_INTENT_RELATION_INVALID",`${t}/relationField`);let m=[["fileNameField",["text.short","text.long"]],["contentTypeField",["text.short","text.long"]],["sizeField",["number.integer"]]],E={};for(let[y,T]of m){let h=K(d[y],`${t}/${y}`);T.includes(String(l.get(h)?.type))||_("NATIVE_OPERATION_FILE_INTENT_METADATA_INVALID",`${t}/${y}`),E[y]=h}let p=Z(v(d.purposes,`${t}/purposes`,2),y=>y);(!p.length||p.some(y=>!["preview","download"].includes(y)))&&_("NATIVE_OPERATION_FILE_INTENT_PURPOSE_INVALID",`${t}/purposes`);let g=Number(d.maxTtlSeconds);(!Number.isSafeInteger(g)||g<1||g>300)&&_("NATIVE_OPERATION_FILE_INTENT_TTL_INVALID",`${t}/maxTtlSeconds`);let O=Number(d.maxBytes);return(!Number.isSafeInteger(O)||O<1||O>104857600)&&_("NATIVE_OPERATION_FILE_INTENT_SIZE_INVALID",`${t}/maxBytes`),{recordResourceCode:u,recordIdInputField:f,relationField:N,fileNameField:E.fileNameField,contentTypeField:E.contentTypeField,sizeField:E.sizeField,purposes:p,maxTtlSeconds:g,maxBytes:O}}function Ca(e,t,o,n,i,s){if(e===void 0)return null;let c=b(e,t);R(c,["directory","managedFiles","managedFileCopies","notification","workflow","roleAssertions","decimalReservation"],t,!0),Object.keys(c).length===0&&_("NATIVE_OPERATION_PLATFORM_ACCESS_EMPTY",t);let r={};if(c.roleAssertions!==void 0){let a=b(c.roleAssertions,`${t}/roleAssertions`);R(a,["roleCodes"],`${t}/roleAssertions`);let d=v(a.roleCodes,`${t}/roleAssertions/roleCodes`,20);d.length||_("NATIVE_OPERATION_ROLE_ASSERTIONS_REQUIRED",`${t}/roleAssertions/roleCodes`),d.forEach((u,l)=>{s.has(u)||_("NATIVE_ROLE_REFERENCE_MISSING",`${t}/roleAssertions/roleCodes/${l}`)}),r.roleAssertions={roleCodes:W(d)}}if(c.directory!==void 0){let a=b(c.directory,`${t}/directory`);R(a,["mode","fields"],`${t}/directory`),["current-initiator","selected-user"].includes(String(a.mode))||_("NATIVE_OPERATION_DIRECTORY_MODE_INVALID",`${t}/directory/mode`);let d=new Set(["displayName","employeeNumber","primaryDepartment","departments"]),u=v(a.fields,`${t}/directory/fields`,4);(!u.length||u.some(l=>!d.has(l)))&&_("NATIVE_OPERATION_DIRECTORY_FIELDS_INVALID",`${t}/directory/fields`),r.directory={mode:String(a.mode),fields:W(u)}}if(c.managedFiles!==void 0){let a=S(c.managedFiles,`${t}/managedFiles`,16);a.length||_("NATIVE_OPERATION_MANAGED_FILES_REQUIRED",`${t}/managedFiles`);let d=new Set;r.managedFiles=Z(a.map((u,l)=>{let f=`${t}/managedFiles/${l}`,A=b(u,f);R(A,["resourceCode","fieldCodes","intents"],f);let N=J(A.resourceCode,`${f}/resourceCode`);(d.has(N)||!o.has(N))&&_("NATIVE_OPERATION_MANAGED_FILE_RESOURCE_INVALID",`${f}/resourceCode`),d.add(N);let I=v(A.fieldCodes,`${f}/fieldCodes`,16);(!I.length||I.some(E=>!["file","image","signature","text.rich"].includes(String(o.get(N)?.get(E)||""))))&&_("NATIVE_OPERATION_MANAGED_FILE_FIELD_INVALID",`${f}/fieldCodes`);let m=v(A.intents,`${f}/intents`,2);return(!m.length||m.some(E=>!["create","update"].includes(E)))&&_("NATIVE_OPERATION_MANAGED_FILE_INTENT_INVALID",`${f}/intents`),{resourceCode:N,fieldCodes:W(I),intents:W(m)}}),u=>u.resourceCode)}if(c.managedFileCopies!==void 0){let a=S(c.managedFileCopies,`${t}/managedFileCopies`,16);a.length||_("NATIVE_OPERATION_MANAGED_FILE_COPIES_REQUIRED",`${t}/managedFileCopies`);let d=new Set;r.managedFileCopies=Z(a.map((u,l)=>{let f=`${t}/managedFileCopies/${l}`,A=b(u,f);R(A,["mode","sourceResourceCode","sourceFieldCodes","targetResourceCode","targetFieldCodes"],f),x(A.mode,"copy",`${f}/mode`);let N=J(A.sourceResourceCode,`${f}/sourceResourceCode`),I=J(A.targetResourceCode,`${f}/targetResourceCode`),m=o.get(N),E=o.get(I);(!m||!E)&&_("NATIVE_OPERATION_MANAGED_FILE_COPY_RESOURCE_INVALID",f);let p=v(A.sourceFieldCodes,`${f}/sourceFieldCodes`,16),g=v(A.targetFieldCodes,`${f}/targetFieldCodes`,16);(!p.length||p.length!==g.length)&&_("NATIVE_OPERATION_MANAGED_FILE_COPY_FIELDS_INVALID",f),p.forEach((y,T)=>{let h=m.get(y),D=E.get(g[T]);(!["file","image"].includes(String(h))||h!==D)&&_("NATIVE_OPERATION_MANAGED_FILE_COPY_FIELD_INVALID",`${f}/sourceFieldCodes/${T}`)});let O=`${N}:${p.join(",")}=>${I}:${g.join(",")}`;return d.has(O)&&_("NATIVE_OPERATION_MANAGED_FILE_COPY_DUPLICATE",f),d.add(O),{mode:"copy",sourceResourceCode:N,sourceFieldCodes:W(p),targetResourceCode:I,targetFieldCodes:W(g)}}),u=>`${u.sourceResourceCode}:${u.sourceFieldCodes.join(",")}=>${u.targetResourceCode}:${u.targetFieldCodes.join(",")}`)}if(c.notification!==void 0){let a=b(c.notification,`${t}/notification`);R(a,["mode"],`${t}/notification`),a.mode!=="business-standard"&&_("NATIVE_OPERATION_NOTIFICATION_MODE_INVALID",`${t}/notification/mode`),r.notification={mode:"business-standard"}}if(c.workflow!==void 0){let a=b(c.workflow,`${t}/workflow`);R(a,["codes"],`${t}/workflow`);let d=v(a.codes,`${t}/workflow/codes`,16);(!d.length||d.some(u=>!i.has(u)))&&_("NATIVE_OPERATION_WORKFLOW_CODE_INVALID",`${t}/workflow/codes`),r.workflow={codes:W(d)}}if(c.decimalReservation!==void 0){let a=`${t}/decimalReservation`,d=b(c.decimalReservation,a);R(d,["mode","resourceCode","amountFieldCode","currencyFieldCode","relationFieldCode","parentFieldCode","rootFieldCode","statusFieldCode","parentRelationValue","childRelationValue","eligibleParentStatuses","eligibleChildStatuses"],a);let u=C(d.mode,`${a}/mode`,16);["reserve","commit","release"].includes(u)||_("NATIVE_DECIMAL_RESERVATION_MODE_INVALID",`${a}/mode`);let l=J(d.resourceCode,`${a}/resourceCode`),f=n.get(l);f||_("NATIVE_DECIMAL_RESERVATION_RESOURCE_MISSING",`${a}/resourceCode`);let N=Object.fromEntries(["amountFieldCode","currencyFieldCode","relationFieldCode","parentFieldCode","rootFieldCode","statusFieldCode"].map(y=>[y,K(d[y],`${a}/${y}`)])),I=y=>f.get(N[y]),m=y=>new Set((I(y)?.options||[]).map(T=>String(T.value))),E=V(d.parentRelationValue,`${a}/parentRelationValue`),p=V(d.childRelationValue,`${a}/childRelationValue`),g=v(d.eligibleParentStatuses,`${a}/eligibleParentStatuses`,16),O=v(d.eligibleChildStatuses,`${a}/eligibleChildStatuses`,16);(I("amountFieldCode")?.type!=="number.decimal"||I("amountFieldCode")?.exactDecimal!==!0||I("amountFieldCode")?.precision!==18||I("amountFieldCode")?.scale!==2||I("currencyFieldCode")?.type!=="option.single"||I("relationFieldCode")?.type!=="option.single"||I("parentFieldCode")?.type!=="resource-ref.single"||I("parentFieldCode")?.source?.resourceCode!==l||I("rootFieldCode")?.type!=="uuid"||I("statusFieldCode")?.type!=="option.single"||E===p||!m("relationFieldCode").has(E)||!m("relationFieldCode").has(p)||!g.length||!O.length||g.some(y=>!m("statusFieldCode").has(y))||O.some(y=>!m("statusFieldCode").has(y)))&&_("NATIVE_DECIMAL_RESERVATION_FIELD_INVALID",a),r.decimalReservation={mode:u,resourceCode:l,...N,parentRelationValue:E,childRelationValue:p,eligibleParentStatuses:W(g),eligibleChildStatuses:W(O)}}return r}function Sa(e,t,o,n,i){if(e===void 0)return;let s=`${t}/ai`,c=b(e,s);Yr.test(o)||_("NATIVE_OPERATION_AI_CODE_INVALID",`${t}/code`),R(c,["name","description","risk","resources","sideEffects","concurrency","timeoutMs"],s,!0),C(c.name,`${s}/name`,po),C(c.description,`${s}/description`,po);let r=C(c.risk,`${s}/risk`,16);["read","write","destructive","external"].includes(r)||_("NATIVE_OPERATION_AI_RISK_INVALID",`${s}/risk`),r==="read"!=(n==="GET")&&_("NATIVE_OPERATION_AI_METHOD_RISK_MISMATCH",`${s}/risk`),n==="DELETE"&&!["destructive","external"].includes(r)&&_("NATIVE_OPERATION_AI_METHOD_RISK_MISMATCH",`${s}/risk`);let a=v(c.resources,`${s}/resources`,16);a.length===0&&_("NATIVE_OPERATION_AI_RESOURCE_REQUIRED",`${s}/resources`),a.forEach((u,l)=>{let f=J(u,`${s}/resources/${l}`);i.has(f)||_("NATIVE_OPERATION_AI_RESOURCE_MISSING",`${s}/resources/${l}`)});let d=v(c.sideEffects,`${s}/sideEffects`,20);(r==="read"&&d.length!==0||r!=="read"&&d.length===0)&&_("NATIVE_OPERATION_AI_SIDE_EFFECT_INVALID",`${s}/sideEffects`),c.concurrency!==void 0&&!["none","revision"].includes(C(c.concurrency,`${s}/concurrency`,16))&&_("NATIVE_OPERATION_AI_CONCURRENCY_INVALID",`${s}/concurrency`),c.timeoutMs!==void 0&&te(c.timeoutMs,`${s}/timeoutMs`,100,3e4)}function an(e){return(e.replace(/\/{2,}/g,"/").replace(/\/$/,"")||"/").split("/").map(o=>o.startsWith(":")?":":o.includes("*")?"*":o).join("/")}function wa(e,t){let o=b(e,t),n=C(o.type,`${t}/type`,32),i=["code","type","label","presentation","required"],s=n==="sso"?[...i,"provider"]:n==="dingtalk"?[...i,"flow"]:i;R(o,s,t);let c=V(o.code,`${t}/code`),r=C(o.label,`${t}/label`,255),a=C(o.presentation,`${t}/presentation`,16);["primary","secondary"].includes(a)||_("NATIVE_APPLICATION_AUTH_METHOD_PRESENTATION_INVALID",`${t}/presentation`);let d=st(o.required,`${t}/required`);return["sso","password","dingtalk"].includes(n)||_("NATIVE_APPLICATION_AUTH_METHOD_TYPE_INVALID",`${t}/type`),n==="sso"&&o.provider!=="tenant-default"&&_("NATIVE_APPLICATION_AUTH_SSO_PROVIDER_INVALID",`${t}/provider`),n==="dingtalk"&&!["auto","jsapi","oauth"].includes(C(o.flow,`${t}/flow`,16))&&_("NATIVE_APPLICATION_AUTH_DINGTALK_FLOW_INVALID",`${t}/flow`),{code:c,type:n,label:r,presentation:a,required:d,...n==="sso"?{provider:"tenant-default"}:{},...n==="dingtalk"?{flow:o.flow}:{}}}function yi(e,t,o){let n=b(e,o);R(n,["routeCode","path","defaultRouteCode"],o);let i=V(n.routeCode,`${o}/routeCode`),s=ge(n.path,`${o}/path`),c=t==="desktop"?"/login":"/m/login";return(s!==c||/[:*?#\\]/.test(s))&&_("NATIVE_APPLICATION_AUTH_SURFACE_PATH_INVALID",`${o}/path`,{device:t,expectedPath:c}),{routeCode:i,path:s,defaultRouteCode:V(n.defaultRouteCode,`${o}/defaultRouteCode`)}}function Wi(e,t,o,n){if(e===null)return;let i=b(e,n);R(i,["accountMode","registration","methods","surfaces"],n),x(i.accountMode,"existing-platform-users-only",`${n}/accountMode`);let s=b(i.registration,`${n}/registration`);R(s,["mode"],`${n}/registration`),x(s.mode,"reject",`${n}/registration/mode`);let c=S(i.methods,`${n}/methods`,8);c.length===0&&_("NATIVE_APPLICATION_AUTH_METHOD_REQUIRED",`${n}/methods`);let r=c.map((E,p)=>wa(E,`${n}/methods/${p}`)),a=new Set,d=new Set;for(let[E,p]of r.entries())a.has(p.code)&&_("NATIVE_APPLICATION_AUTH_METHOD_CODE_DUPLICATE",`${n}/methods/${E}/code`),d.has(p.type)&&_("NATIVE_APPLICATION_AUTH_METHOD_TYPE_DUPLICATE",`${n}/methods/${E}/type`),a.add(p.code),d.add(p.type);r.filter(E=>E.presentation==="primary").length!==1&&_("NATIVE_APPLICATION_AUTH_PRIMARY_METHOD_INVALID",`${n}/methods`);let u=b(i.surfaces,`${n}/surfaces`);R(u,["desktop","mobile"],`${n}/surfaces`);let l=yi(u.desktop,"desktop",`${n}/surfaces/desktop`),f=yi(u.mobile,"mobile",`${n}/surfaces/mobile`);l.routeCode===f.routeCode&&_("NATIVE_APPLICATION_AUTH_SURFACE_CODE_DUPLICATE",`${n}/surfaces/mobile/routeCode`);let A=S(t,"/config/frontend/routes",500),N=new Map;for(let[E,p]of A.entries()){let g=b(p,`/config/frontend/routes/${E}`);N.set(String(g.code||""),g)}let I=new Set((Array.isArray(o.data?.resources)?o.data.resources:[]).map(E=>String(E.code||"")).filter(E=>/^[a-z][a-z0-9-]{0,62}$/.test(E)));for(let[E,p]of[["desktop",l],["mobile",f]]){N.has(p.routeCode)&&_("NATIVE_APPLICATION_AUTH_SURFACE_CODE_CONFLICT",`${n}/surfaces/${E}/routeCode`);let g=/^user\.([a-z][a-z0-9-]{0,62})\.(records|submit)$/.exec(String(p.defaultRouteCode||"")),O=N.get(p.defaultRouteCode),y=String(O?.path||"");if(g&&I.has(g[1])){let h=g[2]==="records"?`/my/${g[1]}`:`/my/${g[1]}/submit`;O={surface:"user",path:E==="mobile"?`/m${h}`:h},y=String(O.path)}let T=E==="desktop"?y==="/m"||y.startsWith("/m/"):!(y==="/m"||y.startsWith("/m/"));(!O||O.surface!=="user"||/[:*]/.test(y)||T)&&_("NATIVE_APPLICATION_AUTH_DEFAULT_ROUTE_INVALID",`${n}/surfaces/${E}/defaultRouteCode`)}let m=Ui(o).filter(E=>!E.owner.startsWith("authentication:"));for(let[E,p]of[["desktop",l],["mobile",f]]){let g=m.find(O=>an(O.path)===an(p.path));g&&_("NATIVE_APPLICATION_AUTH_SURFACE_PATH_CONFLICT",`${n}/surfaces/${E}/path`,{owner:g.owner})}}function Da(e,t){if(e===null)return;let o={data:{resources:[]},workflows:{definitions:[]},frontend:{routes:[{code:"auth-desktop-default",path:"/auth-desktop-default",surface:"user"},{code:"auth-mobile-default",path:"/m/auth-mobile-default",surface:"user"}],user:{applicationTodoCenter:!1},admin:{navigation:[]},authentication:e}},n=b(e,t),i=b(n.surfaces,`${t}/surfaces`),s={...n,surfaces:{...i,desktop:{...b(i.desktop,`${t}/surfaces/desktop`),defaultRouteCode:"auth-desktop-default"},mobile:{...b(i.mobile,`${t}/surfaces/mobile`),defaultRouteCode:"auth-mobile-default"}}};Wi(s,o.frontend.routes,{...o,frontend:{...o.frontend,authentication:s}},t)}function $a(e){let t=e.frontend.authentication;return t===null?null:{accountMode:t.accountMode,registration:{mode:t.registration.mode},methods:t.methods.map(o=>({...o})),surfaces:{desktop:{...t.surfaces.desktop},mobile:{...t.surfaces.mobile}}}}var Va=new Set(["draft.read","draft.update","validate","create","own.list","own.read","public.list","public.read"]);function ka(e,t,o){let n=b(e,o);R(n,["policies"],o);let i=S(n.policies,`${o}/policies`,16);i.length<1&&_("NATIVE_PUBLIC_POLICY_REQUIRED",o);let s=new Map(t.frontend.routes.map(d=>[d.code,d])),c=new Map(t.data.resources.map(d=>[d.code,d])),r=new Set,a=new Set(i.map(d=>String(d?.code||"")));i.forEach((d,u)=>{let l=`${o}/policies/${u}`,f=b(d,l);R(f,["code","routeCode","mode","resourceCode","operations","fields"],l,["requiredFields","ownRecordFields","publicRecordFields","publicFilters","serverGeneratedFields","schedule","publicSubtableFields","draft","validations"]);let A=V(f.code,`${l}/code`);r.has(A)&&_("NATIVE_PUBLIC_POLICY_DUPLICATE",`${l}/code`);let N=V(f.routeCode,`${l}/routeCode`),I=s.get(N);(!I||I.surface!=="user"||I.capability!==void 0||I.access!==void 0||/[:*]/.test(String(I.path)))&&_("NATIVE_PUBLIC_ROUTE_INVALID",`${l}/routeCode`),x(f.mode,"anonymous",`${l}/mode`);let m=J(f.resourceCode,`${l}/resourceCode`),E=c.get(m);E||_("NATIVE_PUBLIC_RESOURCE_MISSING",`${l}/resourceCode`);let p=new Map(E.schema.fields.map($=>[String($.code),String($.type)])),g=v(f.operations,`${l}/operations`,8);(g.length<1||g.some($=>!Va.has($)))&&_("NATIVE_PUBLIC_OPERATION_INVALID",`${l}/operations`),g.includes("draft.read")!==g.includes("draft.update")&&_("NATIVE_PUBLIC_DRAFT_OPERATION_INCOMPLETE",`${l}/operations`);let O=v(f.fields,`${l}/fields`,64);(O.length<1||O.some($=>!p.has($)))&&_("NATIVE_PUBLIC_FIELD_INVALID",`${l}/fields`);for(let $ of["requiredFields","ownRecordFields","publicRecordFields"]){if(!Object.prototype.hasOwnProperty.call(f,$))continue;v(f[$],`${l}/${$}`,64).some(P=>!O.includes(P))&&_("NATIVE_PUBLIC_FIELD_SCOPE_INVALID",`${l}/${$}`)}let y=Object.prototype.hasOwnProperty.call(f,"serverGeneratedFields")?S(f.serverGeneratedFields,`${l}/serverGeneratedFields`,16):[],T=new Set;y.forEach(($,M)=>{let P=`${l}/serverGeneratedFields/${M}`,G=b($,P);R(G,["field","kind"],P);let q=K(G.field,`${P}/field`);(T.has(q)||!p.has(q)||O.includes(q)||p.get(q)!=="text.short"&&p.get(q)!=="text.long")&&_("NATIVE_PUBLIC_SERVER_GENERATED_FIELD_INVALID",`${P}/field`),x(G.kind,"random-token",`${P}/kind`),T.add(q)});let h=Object.prototype.hasOwnProperty.call(f,"schedule")?b(f.schedule,`${l}/schedule`):null;if(h){let $=["campusPolicyCode","rulePolicyCode","campusField","ruleCampusField","ruleWeekdaysField","ruleOpenAtField","ruleCloseAtField","ruleSlotMinutesField","ruleAdvanceHoursField","ruleAdvanceDaysField","campusEnabledField","ruleEnabledField","dateField","timeField"];R(h,$,`${l}/schedule`);for(let M of["campusPolicyCode","rulePolicyCode"])V(h[M],`${l}/schedule/${M}`);for(let M of $.filter(P=>!["campusPolicyCode","rulePolicyCode"].includes(P)))K(h[M],`${l}/schedule/${M}`);for(let M of[h.campusField,h.dateField,h.timeField])O.includes(String(M))||_("NATIVE_PUBLIC_SCHEDULE_FIELD_INVALID",`${l}/schedule`);(!a.has(String(h.campusPolicyCode))||!a.has(String(h.rulePolicyCode)))&&_("NATIVE_PUBLIC_SCHEDULE_POLICY_INVALID",`${l}/schedule`)}let D=Object.prototype.hasOwnProperty.call(f,"publicFilters")?S(f.publicFilters,`${l}/publicFilters`,16):[],F=new Set;D.forEach(($,M)=>{let P=`${l}/publicFilters/${M}`,G=b($,P);R(G,["field","operator","value"],P);let q=K(G.field,`${P}/field`);F.has(q)&&_("NATIVE_PUBLIC_FILTER_DUPLICATE",`${P}/field`),O.includes(q)||_("NATIVE_PUBLIC_FILTER_FIELD_INVALID",`${P}/field`),x(G.operator,"eq",`${P}/operator`),["boolean","text.short","text.long","number.integer","number.decimal","date","time"].includes(p.get(q)||"")||_("NATIVE_PUBLIC_FILTER_FIELD_INVALID",`${P}/field`),G.value!==null&&typeof G.value!="string"&&typeof G.value!="number"&&typeof G.value!="boolean"&&_("NATIVE_PUBLIC_FILTER_VALUE_INVALID",`${P}/value`),F.add(q)});let k=Object.prototype.hasOwnProperty.call(f,"publicSubtableFields")?b(f.publicSubtableFields,`${l}/publicSubtableFields`):null;if(k){Object.keys(k).length>64&&_("NATIVE_PUBLIC_SUBTABLE_FIELDS_INVALID",`${l}/publicSubtableFields`);for(let[$,M]of Object.entries(k)){let P=E.schema.fields.find(Q=>String(Q.code)===$),G=String(P?.subtable?.resourceCode||""),q=c.get(G),Te=new Map((q?.schema?.fields||[]).map(Q=>[String(Q.code),String(Q.type)])),z=v(M,`${l}/publicSubtableFields/${$}`,64);(!O.includes($)||p.get($)!=="subtable"||!q||z.length<1||z.some(Q=>!Te.has(Q))||z.some(Q=>Te.get(Q)==="subtable")||z.some(Q=>Te.get(Q)==="signature"))&&_("NATIVE_PUBLIC_SUBTABLE_FIELDS_INVALID",`${l}/publicSubtableFields/${$}`)}}if(g.some($=>$.startsWith("public."))){Object.prototype.hasOwnProperty.call(f,"publicRecordFields")||_("NATIVE_PUBLIC_RECORD_FIELDS_REQUIRED",`${l}/publicRecordFields`);let $=v(f.publicRecordFields,`${l}/publicRecordFields`,64);($.length<1||$.some(M=>!O.includes(M))||$.some(M=>p.get(M)==="signature"||p.get(M)==="subtable"&&!k?.[M]))&&_("NATIVE_PUBLIC_RECORD_FIELDS_INVALID",`${l}/publicRecordFields`)}let U=Object.prototype.hasOwnProperty.call(f,"requiredFields")?v(f.requiredFields,`${l}/requiredFields`,64):[],j=E.surface||{},se=j.fields||{},Ae=String(j.mutationOwner||"native")==="native"&&j.generated?.create!==!1,H=E.schema.fields.filter($=>ct($,se[$.code])).map($=>String($.code));if(g.includes("create")&&!Ae&&_("NATIVE_PUBLIC_CREATE_FIELDS_INCOMPLETE",`${l}/fields`),g.includes("create")&&!Object.prototype.hasOwnProperty.call(f,"draft")&&_("NATIVE_PUBLIC_DRAFT_REQUIRED",`${l}/draft`),g.includes("create"))for(let $ of H){let M=O.includes($)?U.includes($)?null:"requiredFields":"fields";M&&_("NATIVE_PUBLIC_CREATE_FIELDS_INCOMPLETE",`${l}/${M}`,{resourceCode:J,fieldCode:$})}if(Object.prototype.hasOwnProperty.call(f,"draft")){let $=b(f.draft,`${l}/draft`);R($,["enabled","inactivityTtlSeconds","maxBytes"],`${l}/draft`),x($.enabled,!0,`${l}/draft/enabled`),te($.inactivityTtlSeconds,`${l}/draft/inactivityTtlSeconds`,3600,7776e3),te($.maxBytes,`${l}/draft/maxBytes`,4096,262144)}else g.includes("draft.read")&&_("NATIVE_PUBLIC_DRAFT_REQUIRED",`${l}/draft`);let be=Object.prototype.hasOwnProperty.call(f,"validations")?S(f.validations,`${l}/validations`,16):[],ae=new Set;be.forEach(($,M)=>{let P=`${l}/validations/${M}`,G=b($,P);R(G,["code","kind","fields","result"],P);let q=V(G.code,`${P}/code`);ae.has(q)&&_("NATIVE_PUBLIC_VALIDATION_DUPLICATE",`${P}/code`),x(G.kind,"duplicate",`${P}/kind`),x(G.result,"availability",`${P}/result`);let Te=v(G.fields,`${P}/fields`,8);(Te.length<1||Te.some(z=>!O.includes(z))||Te.some(z=>["file","subtable"].includes(p.get(z)||"")))&&_("NATIVE_PUBLIC_VALIDATION_FIELD_INVALID",`${P}/fields`),ae.add(q)}),r.add(A)})}function Fa(e,t){let o=b(e,t);R(o,["policies"],t),S(o.policies,`${t}/policies`,16).length<1&&_("NATIVE_PUBLIC_POLICY_REQUIRED",t)}function va(e){return{policies:Z(e.frontend.publicAccess.policies.map(t=>({code:t.code,routeCode:t.routeCode,mode:t.mode,resourceCode:t.resourceCode,operations:W(t.operations),fields:W(t.fields),...t.requiredFields?{requiredFields:W(t.requiredFields)}:{},...t.ownRecordFields?{ownRecordFields:W(t.ownRecordFields)}:{},...t.publicRecordFields?{publicRecordFields:W(t.publicRecordFields)}:{},...t.publicFilters?{publicFilters:t.publicFilters.map(o=>({field:o.field,operator:o.operator,value:o.value})).sort((o,n)=>ue(o.field,n.field))}:{},...t.publicSubtableFields?{publicSubtableFields:Object.fromEntries(Object.entries(t.publicSubtableFields).sort(([o],[n])=>o.localeCompare(n)).map(([o,n])=>[o,W(Array.isArray(n)?n.map(String):[])]))}:{},...t.serverGeneratedFields?{serverGeneratedFields:t.serverGeneratedFields.map(o=>({field:o.field,kind:o.kind})).sort((o,n)=>ue(o.field,n.field))}:{},...t.schedule?{schedule:{campusPolicyCode:t.schedule.campusPolicyCode,rulePolicyCode:t.schedule.rulePolicyCode,campusField:t.schedule.campusField,ruleCampusField:t.schedule.ruleCampusField,ruleWeekdaysField:t.schedule.ruleWeekdaysField,ruleOpenAtField:t.schedule.ruleOpenAtField,ruleCloseAtField:t.schedule.ruleCloseAtField,ruleSlotMinutesField:t.schedule.ruleSlotMinutesField,ruleAdvanceHoursField:t.schedule.ruleAdvanceHoursField,ruleAdvanceDaysField:t.schedule.ruleAdvanceDaysField,campusEnabledField:t.schedule.campusEnabledField,ruleEnabledField:t.schedule.ruleEnabledField,dateField:t.schedule.dateField,timeField:t.schedule.timeField}}:{},...t.draft?{draft:{...t.draft}}:{},...t.validations?{validations:Z(t.validations.map(o=>({code:o.code,kind:o.kind,fields:W(o.fields),result:o.result})),o=>o.code)}:{}})),t=>t.code)}}function Ui(e){let t=[{owner:"platform:admin-entry",path:"/"},{owner:"platform:admin-entry",path:"/admin"},{owner:"platform:file-preview",path:"/files/:resourceCode/:fileId/preview"}];e.frontend.authentication&&t.push({owner:"authentication:desktop",path:e.frontend.authentication.surfaces.desktop.path},{owner:"authentication:mobile",path:e.frontend.authentication.surfaces.mobile.path});for(let o of e.data.resources){let n=Bi(o),i=`/admin/resources/${o.code}`,s=[["list",i],["detail",`${i}/:id`],["create",`${i}/new`],["update",`${i}/:id/edit`]];for(let[c,r]of s)n[c]&&t.push({owner:`resource:${o.code}:${c}`,path:r},{owner:`resource:${o.code}:${c}:mobile`,path:`/m${r}`})}if(e.frontend.user.applicationTodoCenter===!0&&t.push({owner:"application:todo-center",path:"/todos"},{owner:"application:todo-center:mobile",path:"/m/todos"}),e.workflows.definitions.length>0){t.push({owner:"workflow:work-center",path:"/work-center"},{owner:"workflow:work-center:mobile",path:"/m/work-center"},{owner:"workflow:task",path:"/tasks/:taskId"},{owner:"workflow:task:mobile",path:"/m/tasks/:taskId"},{owner:"workflow:instance",path:"/workflows/:instanceId"},{owner:"workflow:instance:mobile",path:"/m/workflows/:instanceId"});let o=!1;for(let n of e.workflows.definitions)["standalone","hidden-handoff"].includes(n.launch.mode)&&(o=!0);o&&t.push({owner:"workflow:launch",path:"/workflows/:workflowCode/start"},{owner:"workflow:launch:mobile",path:"/m/workflows/:workflowCode/start"})}return t}function un(e){let t=new Map(Ui(e).map(o=>[an(o.path),o]));return Z(e.frontend.routes.map((o,n)=>{let i=`/config/frontend/routes/${n}`,s=b(o,i);R(s,["code","path","label","surface","parentCode","capability","access","pinned","tabPersistence","keepAlive"],i,!0),["admin","user"].includes(s.surface)||_("NATIVE_ROUTE_SURFACE_INVALID",`${i}/surface`);let c=ge(s.path,`${i}/path`);s.surface==="admin"&&c!=="/admin"&&!c.startsWith("/admin/")&&_("NATIVE_ADMIN_ROUTE_PATH_INVALID",`${i}/path`),s.surface==="user"&&(c==="/admin"||c.startsWith("/admin/"))&&_("NATIVE_USER_ROUTE_PATH_RESERVED",`${i}/path`);let r=an(c),a=t.get(r);a&&_("NATIVE_ROUTE_PATH_CONFLICT",`${i}/path`,{path:c,owner:a.owner}),t.set(r,{owner:`frontend:${String(s.code||n)}`,path:c});let d=/[:*]/.test(c),u=Eo(s,i,e.appCode),l=s.pinned===void 0?void 0:st(s.pinned,`${i}/pinned`),f=s.tabPersistence===void 0?d?"none":"session":C(s.tabPersistence,`${i}/tabPersistence`,16),A=s.keepAlive===void 0?"none":C(s.keepAlive,`${i}/keepAlive`,16);return["session","none"].includes(f)||_("NATIVE_ROUTE_TAB_PERSISTENCE_INVALID",`${i}/tabPersistence`),["none","memory"].includes(A)||_("NATIVE_ROUTE_KEEP_ALIVE_INVALID",`${i}/keepAlive`),d&&l===!0&&_("NATIVE_DYNAMIC_ROUTE_PINNED_FORBIDDEN",`${i}/pinned`),d&&f==="session"&&_("NATIVE_DYNAMIC_ROUTE_TAB_PERSISTENCE_FORBIDDEN",`${i}/tabPersistence`),d&&A==="memory"&&_("NATIVE_DYNAMIC_ROUTE_KEEP_ALIVE_FORBIDDEN",`${i}/keepAlive`),{code:V(s.code,`${i}/code`),path:c,label:C(s.label,`${i}/label`,255),surface:s.surface,...s.parentCode===void 0?{}:{parentCode:V(s.parentCode,`${i}/parentCode`)},...u,...l===void 0?{}:{pinned:l},tabPersistence:f,keepAlive:A}}),o=>o.code)}function Bi(e){let t=e.surface===void 0?{}:b(e.surface,"/surface"),o=t.mutationOwner||"native",n=t.generated===void 0?{}:b(t.generated,"/surface/generated"),i=o==="native";return{list:n.list??!0,detail:n.detail??!0,create:n.create??i,update:n.update??i,delete:n.delete??i}}function Ki(e){let t=[];for(let o of Z(e.data.resources,n=>n.code).flatMap(n=>[{resource:n,viewCode:void 0},...(n.surface?.views||[]).map(i=>({viewCode:i.code,resource:{...n,name:i.name,surface:Pt(n.surface,i.code)}}))])){let{resource:n,viewCode:i}=o,s=`/admin/resources/${n.code}${i?`/views/${i}`:""}`,c=Bi(n),r=[{operation:"list",kind:"resource-list",path:`${s}`,label:n.name,capability:n.capabilities.read,navigationEligible:!0},{operation:"detail",kind:"resource-detail",path:`${s}/:id`,label:`${n.name}\u8BE6\u60C5`,capability:n.capabilities.read,navigationEligible:!1},{operation:"create",kind:"resource-create",path:`${s}/new`,label:`\u65B0\u589E${n.name}`,capability:n.capabilities.create,navigationEligible:!1},{operation:"update",kind:"resource-update",path:`${s}/:id/edit`,label:`\u7F16\u8F91${n.name}`,capability:n.capabilities.update,navigationEligible:!1}];for(let a of r)c[a.operation]&&t.push({code:`resource:${n.code}${i?`:view:${i}`:""}:${a.operation}`,kind:a.kind,path:a.path,label:a.label,navigationEligible:a.navigationEligible,capability:a.capability,resourceCode:n.code,...i?{viewCode:i}:{}})}for(let o of un(e))o.surface==="admin"&&t.push({code:`operation:${o.code}`,kind:"operation",path:o.path,label:o.label,navigationEligible:!/[:*]/.test(o.path),routeCode:o.code});return t.sort((o,n)=>ue(o.code,n.code))}function Gi(e){return e.kind==="resource"?`resource:${e.resourceCode}${e.viewCode?`:view:${e.viewCode}`:""}:list`:`operation:${e.routeCode}`}function Pa(e){return e.frontend.admin.navigation.map((t,o)=>({code:t.code,label:t.label,...t.icon===void 0?{}:{icon:t.icon},order:t.order??o,items:t.items.map((n,i)=>({pageCode:Gi(n.page),...n.label===void 0?{}:{label:n.label},...n.icon===void 0?{}:{icon:n.icon},order:n.order??i})).sort((n,i)=>n.order-i.order||ue(n.pageCode,i.pageCode))})).sort((t,o)=>t.order-o.order||ue(t.code,o.code))}function La(e,t){let o=S(e,t,Y.adminNavigationGroups),n=0;o.forEach((i,s)=>{let c=`${t}/${s}`,r=b(i,c);R(r,["code","label","icon","order","items"],c,!0),V(r.code,`${c}/code`),C(r.label,`${c}/label`,255),cn(r.icon,`${c}/icon`),Ri(r.order,`${c}/order`);let a=S(r.items,`${c}/items`,500);a.length===0&&_("NATIVE_ADMIN_GROUP_ORPHANED",`${c}/items`),n+=a.length,n>Y.adminNavigationItems&&_("NATIVE_ARRAY_LIMIT_EXCEEDED",t),a.forEach((d,u)=>{let l=`${c}/items/${u}`,f=b(d,l);R(f,["page","label","icon","order"],l,!0),xa(f.page,`${l}/page`),f.label!==void 0&&C(f.label,`${l}/label`,255),cn(f.icon,`${l}/icon`),Ri(f.order,`${l}/order`)})})}function xa(e,t){let o=b(e,t),n=C(o.kind,`${t}/kind`,64);if(n==="resource"){R(o,["kind","resourceCode"],t,["viewCode"]),o.viewCode!==void 0&&V(o.viewCode,`${t}/viewCode`),J(o.resourceCode,`${t}/resourceCode`);return}if(n==="operation"){R(o,["kind","routeCode"],t),V(o.routeCode,`${t}/routeCode`);return}_("NATIVE_ADMIN_PAGE_REFERENCE_KIND_INVALID",`${t}/kind`)}function ja(e){let t=new Map(Ki(e).map(i=>[String(i.code),i])),o=new Set,n=new Set;e.frontend.admin.navigation.forEach((i,s)=>{let c=`/config/frontend/admin/navigation/${s}`;o.has(i.code)&&_("NATIVE_ADMIN_GROUP_DUPLICATE",`${c}/code`),o.add(i.code),i.label===i.code&&_("NATIVE_ADMIN_USER_LABEL_REQUIRED",`${c}/label`),i.items.forEach((r,a)=>{let d=`${c}/items/${a}`,u=Gi(r.page),l=t.get(u);(!l||l.navigationEligible!==!0)&&_("NATIVE_ADMIN_PAGE_NOT_FOUND",`${d}/page`),n.has(u)&&_("NATIVE_ADMIN_PAGE_DUPLICATE",`${d}/page`),n.add(u);let f=r.page.resourceCode||r.page.routeCode||r.page.workflowCode||u,A=r.label||l.label;(!A||A===f||A===u)&&_("NATIVE_ADMIN_USER_LABEL_REQUIRED",`${d}/label`)})})}function Ma(e,t){let o=S(e,t,Y.adminPages),n=new Set;o.forEach((i,s)=>{let c=`${t}/${s}`,r=b(i,c);R(r,["code","kind","path","label","navigationEligible","capability","access","resourceCode","viewCode","routeCode"],c,!0);let a=C(r.code,`${c}/code`,255);n.has(a)&&_("NATIVE_ADMIN_PAGE_DUPLICATE",`${c}/code`),n.add(a);let d=C(r.kind,`${c}/kind`,64);if(["resource-list","resource-detail","resource-create","resource-update","operation"].includes(d)||_("NATIVE_ADMIN_PAGE_KIND_INVALID",`${c}/kind`),ge(r.path,`${c}/path`),C(r.label,`${c}/label`,255),st(r.navigationEligible,`${c}/navigationEligible`),r.capability!==void 0&&r.access!==void 0&&_("NATIVE_ROUTE_ACCESS_CONFLICT",`${c}/access`),r.capability!==void 0&&C(r.capability,`${c}/capability`,255),r.access!==void 0){let u=b(r.access,`${c}/access`);R(u,["allOf","anyOf"],`${c}/access`,!0);for(let l of["allOf","anyOf"])u[l]!==void 0&&v(u[l],`${c}/access/${l}`,50)}for(let u of["resourceCode","viewCode","routeCode"])r[u]!==void 0&&V(r[u],`${c}/${u}`)})}function Wa(e,t){let o=S(e,t,Y.adminNavigationGroups),n=0;o.forEach((i,s)=>{let c=`${t}/${s}`,r=b(i,c);R(r,["code","label","icon","order","items"],c,!0),V(r.code,`${c}/code`),C(r.label,`${c}/label`,255),cn(r.icon,`${c}/icon`),te(r.order,`${c}/order`,-1e4,1e4);let a=S(r.items,`${c}/items`,500);a.length===0&&_("NATIVE_ADMIN_GROUP_ORPHANED",`${c}/items`),n+=a.length,n>Y.adminNavigationItems&&_("NATIVE_ARRAY_LIMIT_EXCEEDED",t),a.forEach((d,u)=>{let l=`${c}/items/${u}`,f=b(d,l);R(f,["pageCode","label","icon","order"],l,!0),C(f.pageCode,`${l}/pageCode`,255),f.label!==void 0&&C(f.label,`${l}/label`,255),cn(f.icon,`${l}/icon`),te(f.order,`${l}/order`,-1e4,1e4)})})}var Ua=new Set(["application-todo-center","workflow-work-center","workflow-launch","workflow-task","workflow-instance","resource-records","resource-submit"]);function Ba(e,t,o){let n=b(e,t);R(n,["schemaVersion","appCode","devicePolicy","rootEntry","authentication","routes","digest"],t),x(n.schemaVersion,Pi,`${t}/schemaVersion`),x(n.appCode,o,`${t}/appCode`),Ao(n.devicePolicy,`${t}/devicePolicy`),Ka(n.rootEntry,`${t}/rootEntry`),Ga(n.authentication,`${t}/authentication`),_o(n.digest,`${t}/digest`);let i=S(n.routes,`${t}/routes`,Y.routes),s=new Set;i.forEach((c,r)=>{let a=`${t}/routes/${r}`,d=b(c,a),u=d.kind==="resource-records"||d.kind==="resource-submit";R(d,["code","kind","desktop","mobile"],a,["workflowCode",...u?["resourceCode"]:[]]);let l=C(d.code,`${a}/code`,255);s.has(l)&&_("NATIVE_ROUTE_MANIFEST_DUPLICATE",`${a}/code`),s.add(l);let f=C(d.kind,`${a}/kind`,64);if(Ua.has(f)||_("NATIVE_ROUTE_MANIFEST_KIND_INVALID",`${a}/kind`),d.workflowCode!==void 0&&V(d.workflowCode,`${a}/workflowCode`),u){let I=J(d.resourceCode,`${a}/resourceCode`);x(l,`user.${I}.${d.kind==="resource-records"?"records":"submit"}`,`${a}/code`)}else d.resourceCode!==void 0&&_("NATIVE_PROPERTY_UNKNOWN",`${a}/resourceCode`);let A=Ti(d.desktop,`${a}/desktop`,o),N=Ti(d.mobile,`${a}/mobile`,o);A.surface!=="user"&&_("NATIVE_ROUTE_MANIFEST_DESKTOP_SURFACE_INVALID",`${a}/desktop/surface`),N.surface!=="user"&&_("NATIVE_ROUTE_MANIFEST_MOBILE_SURFACE_INVALID",`${a}/mobile/surface`),A.routeCode===N.routeCode&&_("NATIVE_ROUTE_MANIFEST_PAIR_DUPLICATE",a)}),x(n.digest,X({schemaVersion:n.schemaVersion,appCode:n.appCode,devicePolicy:n.devicePolicy,rootEntry:n.rootEntry,authentication:n.authentication,routes:n.routes}),`${t}/digest`)}function Ao(e,t){let o=b(e,t);R(o,["kind","mobileMaxWidthPx","desktopMinWidthPx"],t),x(o.kind,"viewport-family",`${t}/kind`);let n=te(o.mobileMaxWidthPx,`${t}/mobileMaxWidthPx`,320,1600),i=te(o.desktopMinWidthPx,`${t}/desktopMinWidthPx`,320,1600);return i!==n+1&&_("NATIVE_FRONTEND_DEVICE_POLICY_INVALID",t),{kind:"viewport-family",mobileMaxWidthPx:n,desktopMinWidthPx:i}}function Ka(e,t){let o=b(e,t);R(o,["code","desktop","mobile"],t);let n=V(o.code,`${t}/code`),i=mo(o.desktop,`${t}/desktop`),s=mo(o.mobile,`${t}/mobile`);return(i===s||s==="/"||!s.startsWith("/m/"))&&_("NATIVE_ROUTE_MANIFEST_ROOT_ENTRY_INVALID",t),i.startsWith("/m/")&&_("NATIVE_ROUTE_MANIFEST_ROOT_ENTRY_INVALID",`${t}/desktop`),{code:n,desktop:i,mobile:s}}function Ga(e,t){let o=b(e,t);R(o,["desktop","mobile"],t);let n=bi(o.desktop,`${t}/desktop`,!1),i=bi(o.mobile,`${t}/mobile`,!0);return(n.routeCode===i.routeCode||n.path===i.path)&&_("NATIVE_ROUTE_MANIFEST_AUTHENTICATION_DUPLICATE",t),{desktop:n,mobile:i}}function bi(e,t,o){let n=b(e,t);R(n,["routeCode","path"],t);let i=V(n.routeCode,`${t}/routeCode`),s=mo(n.path,`${t}/path`);return(o?!s.startsWith("/m/"):s.startsWith("/m/"))&&_("NATIVE_ROUTE_MANIFEST_AUTHENTICATION_PATH_INVALID",`${t}/path`),{routeCode:i,path:s}}function mo(e,t){let o=ge(e,t);return/[:*?#\\\\]/.test(o)&&_("NATIVE_ROUTE_MANIFEST_STATIC_PATH_INVALID",t),o}function Ti(e,t,o){let n=b(e,t);R(n,["routeCode","path","surface","pathParams","requiresAuthentication"],t,["capability","access"]),V(n.routeCode,`${t}/routeCode`);let i=ge(n.path,`${t}/path`),s=C(n.surface,`${t}/surface`,16);["admin","user"].includes(s)||_("NATIVE_ROUTE_SURFACE_INVALID",`${t}/surface`);let c=v(n.pathParams,`${t}/pathParams`,8);return c.forEach((r,a)=>{(!/^[A-Za-z][A-Za-z0-9_]*$/.test(r)||r.length>64)&&_("NATIVE_ROUTE_PATH_PARAM_INVALID",`${t}/pathParams/${a}`)}),ee(c)!==ee(qi(i))&&_("NATIVE_ROUTE_PATH_PARAMS_MISMATCH",`${t}/pathParams`),Eo(n,t,o),n.requiresAuthentication!==!0&&_("NATIVE_ROUTE_AUTHENTICATION_REQUIRED",`${t}/requiresAuthentication`),n}function qi(e){return W([...e.matchAll(/:([A-Za-z][A-Za-z0-9_]*)/g)].map(t=>t[1]))}function Oi(e,t,o,n){return{routeCode:e,path:t,surface:o,pathParams:qi(t),...n?.capability?{capability:n.capability}:{},...n?.access?{access:n.access}:{},requiresAuthentication:!0}}function hi(e,t,o,n){return e==="workflow-launch"?`workflow.${o}.launch.${t}`:e==="application-todo-center"?`application.todo-center.${t}`:e==="resource-records"?`user.${n}.records.${t}`:e==="resource-submit"?`user.${n}.submit.${t}`:`${e.replace(/-/g,".")}.${t}`}function qa(e){let t=e.appCode,o=[],n=(A,N,I,m,E,p,g)=>{o.push({code:A,kind:N,...E?{workflowCode:E}:{},...g?{resourceCode:g}:{},desktop:Oi(hi(N,"desktop",E,g),I,"user",p),mobile:Oi(hi(N,"mobile",E,g),m,"user",p)})};e.frontend.user.applicationTodoCenter===!0&&n("application:todo-center","application-todo-center","/todos","/m/todos");let i=Ji(e);i.length>0&&(n("workflow:work-center","workflow-work-center","/work-center","/m/work-center"),n("workflow:task","workflow-task","/tasks/:taskId","/m/tasks/:taskId"),n("workflow:instance","workflow-instance","/workflows/:instanceId","/m/workflows/:instanceId"));for(let A of i){if(!["standalone","hidden-handoff"].includes(A.launch.mode))continue;let N=W([A.launch.submission?.create?.requiredCapability,A.launch.submission?.existing?.requiredCapability].filter(I=>!!I));n(`workflow:${A.code}:launch`,"workflow-launch","/workflows/:workflowCode/start","/m/workflows/:workflowCode/start",A.code,N.length===1?{capability:N[0]}:N.length>1?{access:{anyOf:N}}:void 0)}let s=o.sort((A,N)=>ue(String(A.code),String(N.code))),c=un(e),r=A=>{let N=A==="mobile"?"/m/":"/",I=c.filter(E=>E.surface==="user"&&!/[:*?#\\\\]/.test(E.path)&&E.path===N).sort((E,p)=>ue(E.code,p.code))[0];if(I)return{code:I.code,path:I.path};let m=c.filter(E=>E.surface==="user"&&!/[:*?#\\\\]/.test(E.path)&&(A==="mobile"?E.path.startsWith("/m/"):!E.path.startsWith("/m/"))).sort((E,p)=>ue(E.code,p.code))[0];return m?{code:m.code,path:m.path}:{code:A==="mobile"?"application-root-mobile":"application-root",path:N}},a=e.frontend.authentication?{desktop:{routeCode:e.frontend.authentication.surfaces.desktop.routeCode,path:e.frontend.authentication.surfaces.desktop.path},mobile:{routeCode:e.frontend.authentication.surfaces.mobile.routeCode,path:e.frontend.authentication.surfaces.mobile.path}}:{desktop:{routeCode:"application-login",path:"/login"},mobile:{routeCode:"application-login-mobile",path:"/m/login"}},d=Ao(e.frontend.devicePolicy,"/config/frontend/devicePolicy"),u=r("desktop"),l=r("mobile"),f={schemaVersion:Pi,appCode:t,devicePolicy:d,rootEntry:{code:u.code,desktop:u.path,mobile:l.path},authentication:a,routes:s};return{...f,digest:X(f)}}function cn(e,t){if(e===void 0)return;let o=C(e,t,32);ra.has(o)||_("NATIVE_ADMIN_ICON_INVALID",t)}function Ri(e,t){e!==void 0&&te(e,t,-1e4,1e4)}function Eo(e,t,o){return e.capability!==void 0&&e.access!==void 0&&_("NATIVE_ROUTE_ACCESS_CONFLICT",`${t}/access`),e.capability!==void 0?{capability:we(e.capability,`${t}/capability`,o)}:e.access===void 0?{}:{access:fn(e.access,`${t}/access`,o)}}function fn(e,t,o){let n=b(e,t);R(n,["allOf","anyOf"],t,!0);let i=n.allOf===void 0?void 0:W(v(n.allOf,`${t}/allOf`,50).map((c,r)=>we(c,`${t}/allOf/${r}`,o))),s=n.anyOf===void 0?void 0:W(v(n.anyOf,`${t}/anyOf`,50).map((c,r)=>we(c,`${t}/anyOf/${r}`,o)));return(i?.length||0)+(s?.length||0)===0&&_("NATIVE_ROUTE_ACCESS_EMPTY",t),{...i===void 0?{}:{allOf:i},...s===void 0?{}:{anyOf:s}}}function Ji(e){let t=new Map(Mi(e).map(i=>[String(i.code),i])),o=e.workflows.definitions.map((i,s)=>{let c=`/config/workflows/definitions/${s}`,r=b(i,c);R(r,["version","definition","launch"],c,["detailRouteCode"]);let a=b(r.definition,`${c}/definition`),d=r.detailRouteCode===void 0?void 0:Yi(r.detailRouteCode,`${c}/detailRouteCode`);return{code:V(a.code,`${c}/definition/code`),title:C(a.title,`${c}/definition/title`,255),version:it(r.version,`${c}/version`),launch:Ja(e,a,r.launch,`${c}/launch`,t),...d?{detailRouteCode:d}:{},definition:a}});return W(o.map(i=>i.code)).map(i=>{let s=o.filter(d=>d.code===i),c=e.workflows.activations.find(d=>d.workflowCode===i)?.definitionVersion,r=s.find(d=>d.version===c)||[...s].sort((d,u)=>u.version-d.version)[0],a=new Set;for(let d of s){let u=b(d.definition.nodes,"/config/workflows/definitions/nodes");for(let l of Object.values(u)){let f=b(l,"/config/workflows/definitions/nodes/*");if(f.kind==="approval")for(let A of v(f.allowedOperations||[],"/config/workflows/definitions/nodes/*/allowedOperations",20))a.add(A)}}return{code:i,title:r.title,acceptedCommandDeactivationPolicy:r.definition.acceptedCommandDeactivationPolicy,subject:r.definition.subject,launch:r.launch,...["standalone","hidden-handoff"].includes(r.launch.mode)&&!r.launch.submission?{processOperationCode:`openxiangda.workflow.${i}.submit`}:{},...r.detailRouteCode?{detailRouteCode:r.detailRouteCode}:{},definitionVersions:Fi(s.map(d=>d.version)),bindingVersions:Fi(e.workflows.bindings.map((d,u)=>{let l=`/config/workflows/bindings/${u}`,f=b(d,l),A=b(f.binding,`${l}/binding`);return{code:V(A.workflowCode,`${l}/binding/workflowCode`),version:it(f.version,`${l}/version`)}}).filter(d=>d.code===i).map(d=>d.version)),providerCodes:W(e.workflows.providers.map((d,u)=>V(b(d,`/config/workflows/providers/${u}`).code,`/config/workflows/providers/${u}/code`))),allowedOperations:[...a].sort(ue),editableParameterCodes:W(e.workflows.editableParameters.map((d,u)=>{let l=`/config/workflows/editableParameters/${u}`,f=b(d,l);return{code:V(f.code,`${l}/code`),workflowCode:V(f.workflowCode,`${l}/workflowCode`)}}).filter(d=>d.workflowCode===i).map(d=>d.code))}})}function zi(e,t){let o=b(e,t);R(o,["mode"],t,["submission"]);let n=C(o.mode,`${t}/mode`,32);return["standalone","custom-page","hidden-handoff","work-center-only"].includes(n)||_("NATIVE_WORKFLOW_LAUNCH_MODE_INVALID",`${t}/mode`),{mode:n,...o.submission===void 0?{}:{submission:b(o.submission,`${t}/submission`)}}}function Ja(e,t,o,n,i){let s=zi(o,n);if(!s.submission)return{mode:s.mode};["standalone","hidden-handoff"].includes(s.mode)||_("NATIVE_WORKFLOW_NAMED_OPERATION_SUBMISSION_INVALID",`${n}/submission`);let c=b(s.submission,`${n}/submission`);R(c,["kind"],`${n}/submission`,["create","existing","context"]),x(c.kind,"named-operation",`${n}/submission/kind`);let r=n.endsWith("/launch")?n.slice(0,-7):n,a=b(t.subject,`${r}/definition/subject`),d=J(a.resourceCode,`${r}/definition/subject/resourceCode`),u=e.data.resources.findIndex(T=>T.code===d),l=e.data.resources[u];(u<0||!l)&&_("NATIVE_WORKFLOW_SUBJECT_RESOURCE_MISSING",`${r}/definition/subject/resourceCode`);let f=new Set(b(l.schema,`/config/data/resources/${u}/schema`).fields.map(T=>String(T.code))),A=new Map(e.backend.operations.map(T=>[String(T.code),T])),N=(T,h)=>{let D=`${n}/submission/${h}`,F=b(T,D);R(F,["operationCode","inputs","output"],D);let k=V(F.operationCode,`${D}/operationCode`),U=A.get(k),j=i.get(k),se=j?.platformAccess?.workflow?.codes;(!U||!j||j.method!=="POST"||!Array.isArray(se)||!se.includes(t.code))&&_("NATIVE_WORKFLOW_NAMED_OPERATION_INVALID",D);let Ae=b(U.requestSchema,`${D}/operation/requestSchema`),H=b(Ae.properties,`${D}/operation/requestSchema/properties`),be=new Set(Ae.required===void 0?[]:v(Ae.required,`${D}/operation/requestSchema/required`,64)),ae=b(F.inputs,`${D}/inputs`),$=Object.entries(ae);(!$.length||$.length>64)&&_("NATIVE_WORKFLOW_NAMED_OPERATION_INPUT_INVALID",`${D}/inputs`);let M=new Set,P=new Map,G={};for(let[z,Q]of $){(!Ii.test(z)||!Object.prototype.hasOwnProperty.call(H,z))&&_("NATIVE_WORKFLOW_NAMED_OPERATION_INPUT_INVALID",`${D}/inputs/${z}`);let Be=`${D}/inputs/${z}`,gn=b(Q,Be),ke=C(gn.source,`${Be}/source`,32);if(["field","idempotency-key","current-user-reference","subject-id","subject-revision","requested-at"].includes(ke)||_("NATIVE_WORKFLOW_NAMED_OPERATION_INPUT_INVALID",Be),R(gn,["source"],Be,ke==="field"?["fieldCode"]:!1),P.set(ke,(P.get(ke)||0)+1),ke==="field"){let ht=K(gn.fieldCode,`${Be}/fieldCode`);(M.has(ht)||!f.has(ht))&&_("NATIVE_WORKFLOW_NAMED_OPERATION_INPUT_INVALID",`${Be}/fieldCode`),M.add(ht),G[z]={source:ke,fieldCode:ht}}else G[z]={source:ke}}([...be].some(z=>!(z in ae))||(P.get("idempotency-key")||0)!==1||!$.some(([z,Q])=>b(Q,`${D}/inputs/${z}`).source==="idempotency-key"&&be.has(z))||h==="create"&&((P.get("subject-id")||0)>0||(P.get("subject-revision")||0)>0)||h==="existing"&&((P.get("subject-id")||0)!==1||(P.get("subject-revision")||0)!==1))&&_("NATIVE_WORKFLOW_NAMED_OPERATION_INPUT_INVALID",`${D}/inputs`);let q=b(F.output,`${D}/output`);R(q,["subjectId"],`${D}/output`,["subjectRevision","processCommand"]);let Te=b(b(U.responseSchema,`${D}/operation/responseSchema`).properties,`${D}/operation/responseSchema/properties`);for(let z of["subjectId","subjectRevision","processCommand"]){if(q[z]===void 0)continue;let Q=C(q[z],`${D}/output/${z}`,128);(!Ii.test(Q)||!Object.prototype.hasOwnProperty.call(Te,Q))&&_("NATIVE_WORKFLOW_NAMED_OPERATION_OUTPUT_INVALID",`${D}/output/${z}`)}return{operationCode:k,method:"POST",path:j.path,requiredCapability:j.requiredCapability,requestSchemaDigest:j.requestSchemaDigest,responseSchemaDigest:j.responseSchemaDigest,inputs:G,output:{...q},fieldCodes:M}},I=c.create===void 0?void 0:N(c.create,"create"),m=c.existing===void 0?void 0:N(c.existing,"existing");!I&&!m&&_("NATIVE_WORKFLOW_NAMED_OPERATION_SUBMISSION_INVALID",`${n}/submission`);let E=new Set([...I?.fieldCodes||[],...m?.fieldCodes||[]]),p=c.context===void 0?[]:S(c.context,`${n}/submission/context`,16),g=new Set,O=p.map((T,h)=>{let D=`${n}/submission/context/${h}`,F=b(T,D);R(F,["queryParameter","fieldCode"],D);let k=C(F.queryParameter,`${D}/queryParameter`,64),U=K(F.fieldCode,`${D}/fieldCode`);return(!/^[A-Za-z][A-Za-z0-9]{0,63}$/.test(k)||g.has(k)||!E.has(U))&&_("NATIVE_WORKFLOW_LAUNCH_CONTEXT_INVALID",D),g.add(k),{queryParameter:k,fieldCode:U}}),y=T=>{let{fieldCodes:h,...D}=T;return D};return{mode:s.mode,submission:{kind:"named-operation",...I?{create:y(I)}:{},...m?{existing:y(m)}:{},context:O}}}function Yi(e,t){let o=b(e,t);R(o,["desktop","mobile"],t);let n=V(o.desktop,`${t}/desktop`),i=V(o.mobile,`${t}/mobile`);return n===i&&_("NATIVE_WORKFLOW_DETAIL_ROUTE_DUPLICATE",t),{desktop:n,mobile:i}}function za(e,t){let o=new Set(t.map(u=>u.code)),n=new Map;e.data.resources.forEach((u,l)=>{let f=`/config/data/resources/${l}`,A=b(u,f);for(let[m,E]of Object.entries(A.fieldPolicies||{})){if(!Ge(m))continue;let p=`${f}/fieldPolicies/${m}/read`,g=b(E,`${f}/fieldPolicies/${m}`);for(let O of v(g.read||[],p,2e3))o.has(O)||_("NATIVE_CAPABILITY_REFERENCE_MISSING",p)}let N=A.surface===void 0?{}:b(A.surface,`${f}/surface`);if(["native","queued-command"].includes(N.mutationOwner||"native"))return;let I=b(A.capabilities,`${f}/capabilities`);for(let m of["create","update","delete"])n.set(String(I[m]),m)});let i=new Set;for(let[u,l]of e.authz.roles.entries()){let f=`/config/authz/roles/${u}`,A=b(l,f);R(A,["code","name","description","capabilities"],f,!0);let N=V(A.code,`${f}/code`);i.has(N)&&_("NATIVE_ROLE_DUPLICATE",`${f}/code`),i.add(N),C(A.name,`${f}/name`,255);let I=v(A.capabilities,`${f}/capabilities`,2e3);for(let[m,E]of I.entries())n.has(E)&&_("NATIVE_DATA_SURFACE_MUTATION_GRANT_FORBIDDEN",`${f}/capabilities/${m}`,{operation:n.get(E)}),o.has(E)||_("NATIVE_CAPABILITY_REFERENCE_MISSING",`${f}/capabilities`)}let s=e.authz.authenticatedUserRoleCode===void 0?"":V(e.authz.authenticatedUserRoleCode,"/config/authz/authenticatedUserRoleCode");s&&!i.has(s)&&_("NATIVE_AUTHENTICATED_USER_ROLE_REFERENCE_MISSING","/config/authz/authenticatedUserRoleCode");let c=new Set,r=0;for(let[u,l]of e.perspectives.entries()){let f=`/config/perspectives/${u}`,A=b(l,f);R(A,["code","name","description","roleCodes","capabilityCodes","default"],f,!0);let N=V(A.code,`${f}/code`);c.has(N)&&_("NATIVE_PERSPECTIVE_DUPLICATE",`${f}/code`),c.add(N),C(A.name,`${f}/name`,255);let I=v(A.roleCodes,`${f}/roleCodes`,20);I.length<1&&_("NATIVE_PERSPECTIVE_ROLE_REQUIRED",`${f}/roleCodes`),I.forEach((p,g)=>{i.has(p)||_("NATIVE_PERSPECTIVE_ROLE_MISSING",`${f}/roleCodes/${g}`)});let m=W(e.authz.roles.filter(p=>I.includes(p.code)).flatMap(p=>p.capabilities)),E=v(A.capabilityCodes,`${f}/capabilityCodes`,2e3);ee(m)!==ee(E)&&_("NATIVE_PERSPECTIVE_CAPABILITY_PROJECTION_MISMATCH",`${f}/capabilityCodes`),A.default===!0?r+=1:A.default!==void 0&&_("NATIVE_PERSPECTIVE_DEFAULT_INVALID",`${f}/default`)}r>1&&_("NATIVE_PERSPECTIVE_DEFAULT_DUPLICATE","/config/perspectives");for(let[u,l]of e.backend.operations.entries()){let f=b(l,`/config/backend/operations/${u}`);o.has(f.capability)||_("NATIVE_CAPABILITY_REFERENCE_MISSING",`/config/backend/operations/${u}/capability`)}let a=new Set,d=new Set;for(let[u,l]of e.frontend.routes.entries()){let f=`/config/frontend/routes/${u}`,A=b(l,f),N=V(A.code,`${f}/code`);a.has(N)&&_("NATIVE_ROUTE_DUPLICATE",`${f}/code`),a.add(N);let I=ge(A.path,`${f}/path`);d.has(I)&&_("NATIVE_ROUTE_PATH_DUPLICATE",`${f}/path`),d.add(I);let m=Eo(A,f,e.appCode);m.capability&&!o.has(m.capability)&&_("NATIVE_CAPABILITY_REFERENCE_MISSING",`${f}/capability`);let E=A.access===void 0?void 0:b(A.access,`${f}/access`);for(let p of["allOf","anyOf"]){let g=E?.[p]===void 0?[]:S(E[p],`${f}/access/${p}`,50);for(let[O,y]of g.entries()){let T=we(y,`${f}/access/${p}/${O}`,e.appCode);o.has(T)||_("NATIVE_CAPABILITY_REFERENCE_MISSING",`${f}/access/${p}/${O}`)}}}if(e.frontend.admin.access!==void 0){let u=fn(e.frontend.admin.access,"/config/frontend/admin/access",e.appCode);for(let l of["allOf","anyOf"])for(let[f,A]of(u[l]||[]).entries())o.has(A)||_("NATIVE_CAPABILITY_REFERENCE_MISSING",`/config/frontend/admin/access/${l}/${f}`)}for(let[u,l]of e.frontend.routes.entries()){let f=b(l,`/config/frontend/routes/${u}`);f.parentCode&&!a.has(f.parentCode)&&_("NATIVE_ROUTE_PARENT_MISSING",`/config/frontend/routes/${u}/parentCode`)}}function Ya(e){let t=new Set(e.authz.roles.map(d=>String(d.code))),o=e.authz.authenticatedUserRoleCode===void 0?"":V(e.authz.authenticatedUserRoleCode,"/config/authz/authenticatedUserRoleCode"),n=new Map(e.authz.scopeDimensions.map(d=>[String(d.code),{valueType:d.valueType==="uuid"?"uuid":"string",...d.valueSource?.resourceCode?{valueSourceResourceCode:String(d.valueSource.resourceCode)}:{}}])),i=new Set(n.keys()),s=new Map(e.data.resources.map((d,u)=>{let l=We(d,`/config/data/resources/${u}`,e.appCode);return[l.code,new Map(l.schema.fields.map(f=>[String(f.code),f]))]}));for(let[d,u]of e.authz.scopeDimensions.entries()){let l=`/config/authz/scopeDimensions/${d}`,f=b(u,l);if(R(f,["code","name","resourceCode","valueType","hierarchyMode","valueSource"],l,!0),f.valueSource===void 0)continue;let A=b(f.valueSource,`${l}/valueSource`);R(A,["kind","resourceCode","labelField","enabledField"],`${l}/valueSource`,!0),A.kind!=="native_resource"&&_("NATIVE_SCOPE_VALUE_SOURCE_KIND_INVALID",`${l}/valueSource/kind`),f.valueType!=="uuid"&&_("NATIVE_SCOPE_VALUE_SOURCE_TYPE_INVALID",`${l}/valueType`);let N=J(A.resourceCode,`${l}/valueSource/resourceCode`),I=s.get(N);I||_("NATIVE_SCOPE_VALUE_SOURCE_RESOURCE_MISSING",`${l}/valueSource/resourceCode`);let m=K(A.labelField,`${l}/valueSource/labelField`);if(["text.short","text.long"].includes(String(I.get(m)?.type||""))||_("NATIVE_SCOPE_VALUE_SOURCE_LABEL_FIELD_INVALID",`${l}/valueSource/labelField`),A.enabledField!==void 0){let E=K(A.enabledField,`${l}/valueSource/enabledField`);I.get(E)?.type!=="boolean"&&_("NATIVE_SCOPE_VALUE_SOURCE_ENABLED_FIELD_INVALID",`${l}/valueSource/enabledField`)}}let c=new Set,r=new Set;for(let[d,u]of e.authz.scopeSources.entries()){let l=`/config/authz/scopeSources/${d}`,f=b(u,l);R(f,["code","name","resourceCode","subject","grants","operationField","enabledField","effectiveFromField","effectiveToField","failureMode"],l,!0);let A=V(f.code,`${l}/code`);c.has(A)&&_("NATIVE_SCOPE_SOURCE_DUPLICATE",`${l}/code`),c.add(A),C(f.name,`${l}/name`,255);let N=J(f.resourceCode,`${l}/resourceCode`),I=s.get(N);I||_("NATIVE_SCOPE_SOURCE_RESOURCE_MISSING",`${l}/resourceCode`);let m=b(f.subject,`${l}/subject`),E=C(m.type,`${l}/subject/type`,32);R(m,E==="role_membership"?["type","userIdField","roleCode"]:["type","userIdField"],`${l}/subject`),["user","role_membership"].includes(E)||_("NATIVE_SCOPE_SOURCE_SUBJECT_INVALID",`${l}/subject/type`);let p=He(m.userIdField,I);Bt(p)||_("NATIVE_SCOPE_SOURCE_SUBJECT_PATH_INVALID",`${l}/subject/userIdField`),E==="role_membership"&&!t.has(String(m.roleCode))&&_("NATIVE_ROLE_REFERENCE_MISSING",`${l}/subject/roleCode`);let g=new Set;for(let[O,y]of S(f.grants,`${l}/grants`,100).entries()){let T=`${l}/grants/${O}`,h=b(y,T);R(h,["dimensionCode","valueField","parentValueField"],T,!0);let D=V(h.dimensionCode,`${T}/dimensionCode`);(!i.has(D)||g.has(D))&&_("NATIVE_SCOPE_SOURCE_DIMENSION_INVALID",`${T}/dimensionCode`),g.add(D),f.failureMode==="last_known_good"&&r.add(D);for(let F of["valueField","parentValueField"]){if(h[F]===void 0)continue;let k=He(h[F],I);Un(k,n.get(D),s)||_("NATIVE_SCOPE_SOURCE_GRANT_PATH_INVALID",`${T}/${F}`)}}g.size===0&&_("NATIVE_SCOPE_SOURCE_GRANT_REQUIRED",`${l}/grants`),["strict","last_known_good"].includes(f.failureMode)||_("NATIVE_SCOPE_SOURCE_FAILURE_MODE_INVALID",`${l}/failureMode`);for(let O of["operationField","enabledField","effectiveFromField","effectiveToField"]){if(f[O]===void 0)continue;let y=K(f[O],`${l}/${O}`);I.has(y)||_("NATIVE_SCOPE_SOURCE_FIELD_MISSING",`${l}/${O}`)}}Xa(e,t,s,o);let a=new Set;for(let[d,u]of e.authz.dataPolicies.entries()){let l=`/config/authz/dataPolicies/${d}`,f=b(u,l);R(f,["code","name","resourceCode","unrestrictedRoleCodes","operations","matchMode","rules","readExpression","writeBoundary"],l,!0);let A=V(f.code,`${l}/code`);a.has(A)&&_("NATIVE_DATA_POLICY_DUPLICATE",`${l}/code`),a.add(A);let N=f.readExpression!==void 0,I=v(f.operations||[],`${l}/operations`,4);f.operations!==void 0&&(I.length===0||I.some(y=>!["read","create","update","delete"].includes(y)))&&_("NATIVE_DATA_POLICY_OPERATIONS_INVALID",`${l}/operations`),["AND","OR"].includes(f.matchMode)||_("NATIVE_DATA_POLICY_MATCH_MODE_INVALID",`${l}/matchMode`),N&&f.operations!==void 0&&_("NATIVE_DATA_POLICY_READ_EXPRESSION_OPERATIONS_FORBIDDEN",`${l}/operations`);let m=e.data.resources.find(y=>y.dataPolicyCode===A),E=f.resourceCode||m?.code,p=E?s.get(J(E,`${l}/resourceCode`)):void 0;N&&!p&&_("NATIVE_DATA_POLICY_RESOURCE_MISSING",`${l}/resourceCode`);let g=v(f.unrestrictedRoleCodes||[],`${l}/unrestrictedRoleCodes`,100);f.unrestrictedRoleCodes!==void 0&&g.length===0&&_("NATIVE_DATA_POLICY_UNRESTRICTED_ROLES_INVALID",`${l}/unrestrictedRoleCodes`);for(let y of g)t.has(y)||_("NATIVE_ROLE_REFERENCE_MISSING",`${l}/unrestrictedRoleCodes`);let O;try{let y=S(f.rules,`${l}/rules`,100).map((T,h)=>({rule:b(T,`${l}/rules/${h}`),pointer:`${l}/rules/${h}`}));y.length===0?(!N||f.matchMode!=="AND"||f.writeBoundary!=="capability_only")&&_("NATIVE_DATA_POLICY_WRITE_BOUNDARY_REQUIRED",l):f.writeBoundary!==void 0&&_("NATIVE_DATA_POLICY_WRITE_BOUNDARY_INVALID",`${l}/writeBoundary`),O=[...y],N&&(O.push(...yt(f.readExpression,`${l}/readExpression`)),uo(f.readExpression,`${l}/readExpression`))}catch(y){throw y instanceof nt&&_(y.code,y.pointer),y}for(let{rule:y,pointer:T}of O){R(y,["subject","dimensionCode","relationCode","resourceCode","field","roleCodes","operation","valuePath","emptyMatchesAll","operator","value","operand"],T,!0);let h=K(y.field,`${T}/field`),D=p?.get(h);N&&!D&&_("NATIVE_DATA_POLICY_FIELD_MISSING",`${T}/field`);for(let H of v(y.roleCodes||[],`${T}/roleCodes`,100))t.has(H)||_("NATIVE_ROLE_REFERENCE_MISSING",`${T}/roleCodes`);let F=String(y.operator||""),k=y.operand==="db_now",U=["is_null","is_not_null"].includes(F),j=["eq","not_eq","in","not_in"].includes(F),se=!k&&(y.operator!==void 0||y.value!==void 0);if([y.subject==="current_user"?"current_user":"",typeof y.dimensionCode=="string"?"dimension":"",typeof y.relationCode=="string"?"relationship":"",se?"constant":"",k?"db_now":""].filter(Boolean).length!==1&&_("NATIVE_DATA_POLICY_RULE_SOURCE_INVALID",T),y.subject!==void 0&&y.subject!=="current_user"&&_("NATIVE_DATA_POLICY_SUBJECT_INVALID",`${T}/subject`),se){if(!j&&!U&&_("NATIVE_DATA_POLICY_OPERATOR_INVALID",`${T}/operator`),["in","not_in"].includes(F)){let H=S(y.value,`${T}/value`,100).map((be,ae)=>C(be,`${T}/value/${ae}`,2048));(H.length===0||new Set(H).size!==H.length)&&_("NATIVE_DATA_POLICY_VALUE_INVALID",`${T}/value`)}else["eq","not_eq"].includes(F)?C(y.value,`${T}/value`,2048):(y.value!==void 0||y.operand!==void 0)&&_("NATIVE_DATA_POLICY_VALUE_INVALID",`${T}/value`);for(let H of["operation","valuePath","emptyMatchesAll","resourceCode","operand"])y[H]!==void 0&&_("NATIVE_DATA_POLICY_CONSTANT_RULE_INVALID",`${T}/${H}`)}if(k){(!["lt","lte","gt","gte"].includes(F)||y.value!==void 0||D?.type!=="datetime")&&_("NATIVE_DATA_POLICY_DB_NOW_INVALID",T);for(let H of["operation","valuePath","emptyMatchesAll","resourceCode","value"])y[H]!==void 0&&_("NATIVE_DATA_POLICY_DB_NOW_INVALID",`${T}/${H}`)}y.dimensionCode&&!i.has(y.dimensionCode)&&_("NATIVE_SCOPE_DIMENSION_MISSING",`${T}/dimensionCode`),r.has(String(y.dimensionCode||""))&&y.operation!=="read"&&_("NATIVE_SCOPE_SOURCE_LAST_KNOWN_GOOD_UNSAFE",`${T}/operation`)}}for(let[d,u]of e.data.resources.entries()){let l=b(u,`/config/data/resources/${d}`);l.dataPolicyCode&&!a.has(l.dataPolicyCode)&&_("NATIVE_DATA_POLICY_REFERENCE_MISSING",`/config/data/resources/${d}/dataPolicyCode`)}}function Ha(e){try{bn(e.data.resources,"/config/data/resources")}catch(t){throw t instanceof me&&_(t.code,t.pointer),t}}function Xa(e,t,o,n){let i=new Set;for(let[s,c]of e.authz.roleMembershipSources.entries()){let r=`/config/authz/roleMembershipSources/${s}`,a=b(c,r);R(a,["code","name","resourceCode","userIdField","roleCode","enabledField","effectiveFromField","effectiveToField","failureMode"],r,!0);let d=V(a.code,`${r}/code`);d.length>100&&_("NATIVE_AUTHORIZATION_PROJECTION_SOURCE_CODE_INVALID",`${r}/code`),i.has(d)&&_("NATIVE_AUTHORIZATION_PROJECTION_SOURCE_DUPLICATE",`${r}/code`),i.add(d),C(a.name,`${r}/name`,255);let u=Ci(a.resourceCode,`${r}/resourceCode`,o);Si(a.userIdField,`${r}/userIdField`,u),t.has(String(a.roleCode||""))||_("NATIVE_ROLE_REFERENCE_MISSING",`${r}/roleCode`),n&&a.roleCode===n&&_("NATIVE_AUTHENTICATED_USER_ROLE_SOURCE_CONFLICT",`${r}/roleCode`),wi(a,r,u)}for(let[s,c]of e.authz.relationshipGrantSources.entries()){let r=`/config/authz/relationshipGrantSources/${s}`,a=b(c,r);R(a,["code","name","resourceCode","subject","relationCode","targetResourceCode","resourceIdField","operations","enabledField","effectiveFromField","effectiveToField","failureMode"],r,!0);let d=V(a.code,`${r}/code`);d.length>100&&_("NATIVE_AUTHORIZATION_PROJECTION_SOURCE_CODE_INVALID",`${r}/code`),i.has(d)&&_("NATIVE_AUTHORIZATION_PROJECTION_SOURCE_DUPLICATE",`${r}/code`),i.add(d),C(a.name,`${r}/name`,255);let u=Ci(a.resourceCode,`${r}/resourceCode`,o),l=b(a.subject,`${r}/subject`),f=C(l.type,`${r}/subject/type`,32);R(l,f==="role_membership"?["type","userIdField","roleCode"]:["type","userIdField"],`${r}/subject`),["user","role_membership"].includes(f)||_("NATIVE_AUTHORIZATION_PROJECTION_SUBJECT_INVALID",`${r}/subject/type`),Si(l.userIdField,`${r}/subject/userIdField`,u),f==="role_membership"&&!t.has(String(l.roleCode||""))&&_("NATIVE_ROLE_REFERENCE_MISSING",`${r}/subject/roleCode`),V(a.relationCode,`${r}/relationCode`);let A=J(a.targetResourceCode,`${r}/targetResourceCode`);o.has(A)||_("NATIVE_AUTHORIZATION_PROJECTION_TARGET_RESOURCE_MISSING",`${r}/targetResourceCode`);let N=He(a.resourceIdField,u),I=N?.field.type==="resource-ref.single"&&N.valuePath==="value"&&N.field.source?.resourceCode===A;(a.resourceIdField==="id"?A!==String(a.resourceCode):!I)&&_("NATIVE_AUTHORIZATION_PROJECTION_RESOURCE_ID_FIELD_INVALID",`${r}/resourceIdField`);let m=v(a.operations,`${r}/operations`,20);(m.length===0||m.some(E=>E.length>64||!/^[A-Za-z0-9][A-Za-z0-9:._*-]{0,63}$/.test(E)))&&_("NATIVE_AUTHORIZATION_PROJECTION_OPERATIONS_INVALID",`${r}/operations`),wi(a,r,u)}}function Ci(e,t,o){let n=J(e,t),i=o.get(n);return i||_("NATIVE_AUTHORIZATION_PROJECTION_RESOURCE_MISSING",t),i}function Si(e,t,o){let n=He(e,o);Bt(n)||_("NATIVE_AUTHORIZATION_PROJECTION_USER_FIELD_INVALID",t)}function wi(e,t,o){if(e.failureMode!=="strict"&&_("NATIVE_AUTHORIZATION_PROJECTION_FAILURE_MODE_INVALID",`${t}/failureMode`),e.enabledField!==void 0){let n=K(e.enabledField,`${t}/enabledField`);o.get(n)?.type!=="boolean"&&_("NATIVE_AUTHORIZATION_PROJECTION_ENABLED_FIELD_INVALID",`${t}/enabledField`)}for(let n of["effectiveFromField","effectiveToField"]){if(e[n]===void 0)continue;let i=K(e[n],`${t}/${n}`);["date","datetime"].includes(String(o.get(i)?.type))||_("NATIVE_AUTHORIZATION_PROJECTION_EFFECTIVE_FIELD_INVALID",`${t}/${n}`)}}function Qa(e){let t=new Set,o=new Set;e.forEach((n,i)=>{let s=`/config/backend/secrets/${i}`,c=b(n,s);R(c,["name","env","description","required","exposure"],s,!0);let r=C(c.name,`${s}/name`,128),a=C(c.env,`${s}/env`,128);Qr.test(r)||_("NATIVE_SECRET_NAME_INVALID",`${s}/name`),(!Zr.test(a)||a.startsWith("OPENXIANGDA_")||["NODE_ENV","PORT"].includes(a))&&_("NATIVE_SECRET_ENV_INVALID",`${s}/env`),t.has(r)&&_("NATIVE_SECRET_NAME_DUPLICATE",`${s}/name`),o.has(a)&&_("NATIVE_SECRET_ENV_DUPLICATE",`${s}/env`),t.add(r),o.add(a),x(c.exposure,"active_only",`${s}/exposure`),c.required!==void 0&&st(c.required,`${s}/required`),c.description!==void 0&&Io(c.description,`${s}/description`,2e3)})}function Za(e){let t=new Set,o=new Map,n=new Map(e.data.resources.map(A=>[String(A.code),A])),i=new Map(e.frontend.routes.map((A,N)=>{let I=b(A,`/config/frontend/routes/${N}`);return[V(I.code,`/config/frontend/routes/${N}/code`),I]}));for(let[A,N]of e.workflows.definitions.entries()){let I=`/config/workflows/definitions/${A}`,m=b(N,I);if(R(m,["version","definition","launch"],I,["detailRouteCode"]),zi(m.launch,`${I}/launch`),m.detailRouteCode!==void 0){let y=Yi(m.detailRouteCode,`${I}/detailRouteCode`);for(let[T,h,D]of[["desktop",y.desktop,["admin","user"]],["mobile",y.mobile,["user"]]]){let F=`${I}/detailRouteCode/${T}`,k=i.get(h);k||_("NATIVE_WORKFLOW_DETAIL_ROUTE_MISSING",F),D.some(se=>se===k.surface)||_("NATIVE_WORKFLOW_DETAIL_ROUTE_SURFACE_INVALID",F);let U=ge(k.path,F),j=[...U.matchAll(/:([A-Za-z][A-Za-z0-9_]*)/g)].map(se=>se[1]);(U.includes("*")||j.length!==1||j[0]!=="instanceId")&&_("NATIVE_WORKFLOW_DETAIL_ROUTE_PATH_INVALID",F)}}let E=b(m.definition,`${I}/definition`),p=`${E.code}:${it(m.version,`${I}/version`)}`;t.has(p)&&_("NATIVE_WORKFLOW_DEFINITION_DUPLICATE",I),t.add(p),tc(E,`${I}/definition`),ec(E.subject,n,`${I}/definition/subject`);let g=nn(E,new Map((n.get(E.subject.resourceCode)?.schema.fields||[]).map(y=>[y.code,{...n.get(E.subject.resourceCode)?.surface?.fields?.[y.code],...y,system:["id","revision","createdAt","updatedAt","createdBy","updatedBy"].includes(y.code)}])));g.length&&_(g[0],`${I}/definition/taskPages`);let O=Yn(E,{appCode:e.appCode,capabilities:e.authz.capabilities.map(y=>y.code),fields:new Map((n.get(E.subject.resourceCode)?.schema.fields||[]).map(y=>[y.code,y]))});O.length&&_("NATIVE_WORKFLOW_INSTANCE_COMMAND_POLICY_INVALID",`${I}/definition/instanceCommands`,{errors:O}),E.title===E.code&&_("NATIVE_WORKFLOW_USER_TITLE_REQUIRED",`${I}/definition/title`),o.set(p,E)}let s=new Set,c=new Map;for(let[A,N]of e.workflows.bindings.entries()){let I=b(N,`/config/workflows/bindings/${A}`),m=b(I.binding,`/config/workflows/bindings/${A}/binding`),E=`${m.workflowCode}:${it(I.version,`/config/workflows/bindings/${A}/version`)}`;s.has(E)&&_("NATIVE_WORKFLOW_BINDING_DUPLICATE",`/config/workflows/bindings/${A}`),s.add(E),nc(m,`/config/workflows/bindings/${A}/binding`),c.set(E,m)}let r=new Set,a=new Map;for(let[A,N]of e.workflows.activations.entries()){let I=`/config/workflows/activations/${A}`,m=b(N,I);R(m,["workflowCode","definitionVersion","bindingVersion","acceptedCommandDeactivationPolicy"],I,["environmentKey"]);let E=V(m.workflowCode,`${I}/workflowCode`);r.has(E)&&_("NATIVE_WORKFLOW_ACTIVATION_DUPLICATE",I),r.add(E);let p=`${E}:${it(m.definitionVersion,`${I}/definitionVersion`)}`,g=`${E}:${it(m.bindingVersion,`${I}/bindingVersion`)}`;t.has(p)||_("NATIVE_WORKFLOW_DEFINITION_REFERENCE_MISSING",`${I}/definitionVersion`),s.has(g)||_("NATIVE_WORKFLOW_BINDING_REFERENCE_MISSING",`${I}/bindingVersion`);let O=o.get(p),y=c.get(g),T=Zt(O,y);T.length&&_(T[0],I),(!["finish-pinned","cancel-on-deactivate"].includes(m.acceptedCommandDeactivationPolicy)||m.acceptedCommandDeactivationPolicy!==O.acceptedCommandDeactivationPolicy)&&_("NATIVE_WORKFLOW_COMMAND_DEACTIVATION_POLICY_MISMATCH",`${I}/acceptedCommandDeactivationPolicy`),oc(O,y,`/config/workflows/activations/${A}`),a.set(E,y)}let d=co([...a.values()]);d.length&&_(d[0],"/config/workflows/activations");let u=new Set;e.workflows.providers.forEach((A,N)=>{let I=`/config/workflows/providers/${N}`,m=b(A,I);R(m,["code","endpointPath","timeoutMs"],I,!0);let E=V(m.code,`${I}/code`);u.has(E)&&_("NATIVE_WORKFLOW_PROVIDER_DUPLICATE",`${I}/code`),u.add(E),ge(m.endpointPath,`${I}/endpointPath`),m.timeoutMs!==void 0&&te(m.timeoutMs,`${I}/timeoutMs`,100,1e4)});for(let[A,N]of a.entries())for(let[I,m]of Object.entries(b(N.bindings,"/config/workflows/bindings/*/binding/bindings"))){let E=b(m,`/config/workflows/${A}/bindings/${I}`);E.provider==="application_provider"&&!u.has(E.providerCode)&&_("NATIVE_WORKFLOW_PROVIDER_REFERENCE_MISSING",`/config/workflows/${A}/bindings/${I}/providerCode`)}let l=new Set(e.authz.roles.map(A=>A.code)),f=new Set;e.workflows.editableParameters.forEach((A,N)=>{let I=`/config/workflows/editableParameters/${N}`,m=b(A,I);R(m,["code","workflowCode","bindingKey","label","valueType","required","allowedRoleCodes","allowedProviderCodes","maxItems"],I,!0);let E=V(m.code,`${I}/code`);f.has(E)&&_("NATIVE_WORKFLOW_EDITABLE_PARAMETER_DUPLICATE",`${I}/code`),f.add(E);let p=pn(m.workflowCode,`${I}/workflowCode`),g=dn(m.bindingKey,`${I}/bindingKey`),O=a.get(p);(!O||!b(O.bindings,`${I}/bindingKey`)[g])&&_("NATIVE_WORKFLOW_EDITABLE_BINDING_MISSING",`${I}/bindingKey`),C(m.label,`${I}/label`,255),["role_code","user_ids","provider_code"].includes(m.valueType)||_("NATIVE_WORKFLOW_EDITABLE_VALUE_TYPE_INVALID",`${I}/valueType`);for(let y of v(m.allowedRoleCodes||[],`${I}/allowedRoleCodes`,100))l.has(y)||_("NATIVE_ROLE_REFERENCE_MISSING",`${I}/allowedRoleCodes`);for(let y of v(m.allowedProviderCodes||[],`${I}/allowedProviderCodes`,100))u.has(y)||_("NATIVE_WORKFLOW_PROVIDER_REFERENCE_MISSING",`${I}/allowedProviderCodes`);m.required!==void 0&&st(m.required,`${I}/required`),m.maxItems!==void 0&&te(m.maxItems,`${I}/maxItems`,1,200)})}function ec(e,t,o){let n=b(e,o);R(n,["resourceCode","factProjection"],o,["summaryFields"]);let i=J(n.resourceCode,`${o}/resourceCode`),s=t.get(i);s||_("NATIVE_WORKFLOW_SUBJECT_RESOURCE_MISSING",`${o}/resourceCode`);let c=new Set(S(b(s.schema,`${o}/resourceCode`).fields,`${o}/resourceCode`,500).map((d,u)=>K(b(d,`${o}/resourceCode/${u}`).code,`${o}/resourceCode/${u}`))),r=b(n.factProjection,`${o}/factProjection`),a=Object.entries(r);(a.length<1||a.length>64)&&_("NATIVE_WORKFLOW_SUBJECT_FACT_PROJECTION_INVALID",`${o}/factProjection`);for(let[d,u]of a){na.test(d)||_("NATIVE_WORKFLOW_SUBJECT_FACT_KEY_INVALID",`${o}/factProjection/${d}`);let l=K(u,`${o}/factProjection/${d}`);c.has(l)||_("NATIVE_WORKFLOW_SUBJECT_FIELD_MISSING",`${o}/factProjection/${d}`)}if(n.summaryFields!==void 0){let d=v(n.summaryFields,`${o}/summaryFields`,oa).map((N,I)=>K(N,`${o}/summaryFields/${I}`)),u=t.get(i),l=u.surface&&typeof u.surface=="object"&&!Array.isArray(u.surface)?u.surface:{},f=l.fields&&typeof l.fields=="object"&&!Array.isArray(l.fields)?l.fields:{},A=new Map(S(b(u.schema,`${o}/resourceCode`).fields,`${o}/resourceCode`,500).map((N,I)=>{let m=b(N,`${o}/resourceCode/${I}`);return[String(m.code),m]}));for(let[N,I]of d.entries()){let m=A.get(I),E=f[I],p=String(m?.type||""),g=m?.maxLength;(!m||m.system===!0||E&&typeof E=="object"&&!Array.isArray(E)&&E.system===!0||["id","revision","created_by","updated_by","created_at","updated_at"].includes(I)||!sa.has(p)||p==="text.long"&&typeof g=="number"&&Number.isFinite(g)&&g>ia)&&_("NATIVE_WORKFLOW_SUBJECT_SUMMARY_FIELDS_INVALID",`${o}/summaryFields/${N}`)}}}function tc(e,t){R(e,["schemaVersion","code","title","subject","acceptedCommandDeactivationPolicy","startAt","inputSchema","nodes"],t,["organizationContext","instanceCommands","readability","taskPages"]),x(e.schemaVersion,"openxiangda.workflow-definition/v2",`${t}/schemaVersion`),pn(e.code,`${t}/code`),C(e.title,`${t}/title`,255),["finish-pinned","cancel-on-deactivate"].includes(e.acceptedCommandDeactivationPolicy)||_("NATIVE_WORKFLOW_COMMAND_DEACTIVATION_POLICY_REQUIRED",`${t}/acceptedCommandDeactivationPolicy`);let o=b(e.nodes,`${t}/nodes`),n=Object.keys(o);(n.length===0||n.length>200)&&_("NATIVE_WORKFLOW_NODE_COUNT_INVALID",`${t}/nodes`);let i=C(e.startAt,`${t}/startAt`,128),s=oo(e);s.length&&_(s[0],`${t}/readability`);let c=Zt(e);c.length&&_(c[0],`${t}/nodes`);let r=en(e);r.length&&_(r[0],`${t}/nodes`);let a=nn(e);a.length&&_(a[0],`${t}/taskPages`);let d=mt(e);d.length&&_(d[0],`${t}/nodes`),o[i]||_("NATIVE_WORKFLOW_START_NODE_MISSING",`${t}/startAt`);let u=new Map;for(let[N,I]of Object.entries(o)){let m=`${t}/nodes/${N}`,E=b(I,m);x(E.id,N,`${m}/id`),["approval","condition","end","cc","action"].includes(E.kind)||_("NATIVE_WORKFLOW_NODE_KIND_INVALID",`${m}/kind`);let p=[];if(E.kind==="approval"){C(E.title,`${m}/title`,255),dn(E.binding,`${m}/binding`),["single","any","all","sequence"].includes(E.mode)||_("NATIVE_WORKFLOW_APPROVAL_MODE_INVALID",`${m}/mode`),p.push(C(E.onApprove,`${m}/onApprove`,128),C(E.onReject,`${m}/onReject`,128));for(let g of v(E.returnTargets||[],`${m}/returnTargets`,200))o[g]||_("NATIVE_WORKFLOW_TARGET_MISSING",`${m}/returnTargets`);for(let g of v(E.allowedOperations||[],`${m}/allowedOperations`,20))aa.has(g)||_("NATIVE_WORKFLOW_OPERATION_INVALID",`${m}/allowedOperations`)}else if(E.kind==="action")p.push(C(E.next,`${m}/next`,128));else if(E.kind==="cc")C(E.title,`${m}/title`,255),dn(E.binding,`${m}/binding`),p.push(C(E.next,`${m}/next`,128));else if(E.kind==="condition"){let g=S(E.branches,`${m}/branches`,100);g.length===0&&_("NATIVE_WORKFLOW_BRANCH_REQUIRED",`${m}/branches`),g.forEach((O,y)=>{let T=b(O,`${m}/branches/${y}`);bt(T.when,`${m}/branches/${y}/when`,0),p.push(C(T.target,`${m}/branches/${y}/target`,128))}),p.push(C(E.otherwise,`${m}/otherwise`,128))}else C(E.title,`${m}/title`,255),C(E.outcome,`${m}/outcome`,128);for(let g of p)o[g]||_("NATIVE_WORKFLOW_TARGET_MISSING",m);u.set(N,p)}let l=new Set,f=new Set,A=N=>{if(f.has(N)&&_("NATIVE_WORKFLOW_CYCLE_FORBIDDEN",`${t}/nodes/${N}`),!l.has(N)){l.add(N),f.add(N);for(let I of u.get(N)||[])A(I);f.delete(N)}};A(i),l.size!==n.length&&_("NATIVE_WORKFLOW_NODE_UNREACHABLE",`${t}/nodes`)}function bt(e,t,o){o>20&&_("NATIVE_WORKFLOW_EXPRESSION_DEPTH_EXCEEDED",t);let n=b(e,t),i=C(n.op,`${t}/op`,16);if(i!=="literal"){if(i==="path"){let s=C(n.path,`${t}/path`,255);(!/^[A-Za-z][A-Za-z0-9_.-]{0,254}$/.test(s)||s.split(".").some(c=>["__proto__","constructor","prototype"].includes(c)))&&_("NATIVE_WORKFLOW_EXPRESSION_PATH_INVALID",`${t}/path`);return}if(["eq","neq","gt","gte","lt","lte","in","contains"].includes(i)){bt(n.left,`${t}/left`,o+1),bt(n.right,`${t}/right`,o+1);return}if(["and","or"].includes(i)){let s=S(n.values,`${t}/values`,100);s.length===0&&_("NATIVE_WORKFLOW_EXPRESSION_EMPTY",`${t}/values`),s.forEach((c,r)=>bt(c,`${t}/values/${r}`,o+1));return}if(["not","exists"].includes(i)){bt(n.value,`${t}/value`,o+1);return}_("NATIVE_WORKFLOW_EXPRESSION_OPERATOR_INVALID",`${t}/op`)}}function nc(e,t){x(e.schemaVersion,"openxiangda.workflow-binding/v2",`${t}/schemaVersion`),pn(e.workflowCode,`${t}/workflowCode`);let o=b(e.bindings,`${t}/bindings`);Object.keys(o).length>200&&_("NATIVE_WORKFLOW_BINDING_LIMIT_EXCEEDED",`${t}/bindings`);for(let[n,i]of Object.entries(o)){dn(n,`${t}/bindings/${n}`);let s=b(i,`${t}/bindings/${n}`),c=C(s.provider,`${t}/bindings/${n}/provider`,64);if(["fixed_users","initiator","input_users","form_field_users","department_supervisor","app_role","app_role_in_scope","business_relation","previous_node_actor","initiator_select","application_provider"].includes(c)||_("NATIVE_WORKFLOW_BINDING_PROVIDER_INVALID",`${t}/bindings/${n}/provider`),c==="fixed_users"&&S(s.users,`${t}/bindings/${n}/users`,200).length===0&&_("NATIVE_WORKFLOW_BINDING_USERS_REQUIRED",`${t}/bindings/${n}/users`),["input_users","form_field_users"].includes(c)&&C(s.inputPath,`${t}/bindings/${n}/inputPath`,255),["app_role","app_role_in_scope","initiator_select"].includes(c)&&V(s.roleCode,`${t}/bindings/${n}/roleCode`),c==="department_supervisor"&&C(s.departmentIdFrom,`${t}/bindings/${n}/departmentIdFrom`,255),c==="application_provider"&&V(s.providerCode,`${t}/bindings/${n}/providerCode`),s.routing!==void 0){let r=It(s.routing);r.length&&_(r[0],`${t}/bindings/${n}/routing`)}}}function oc(e,t,o){x(t.workflowCode,e.code,`${o}/workflowCode`);let n=b(t.bindings,`${o}/bindings`),i=en(e,t);i.length&&_(i[0],o);let s=mt(e,t);s.length&&_(s[0],o);for(let[c,r]of Object.entries(b(e.nodes,`${o}/nodes`))){let a=b(r,`${o}/nodes/${c}`);["approval","cc"].includes(a.kind)&&!n[a.binding]&&_("NATIVE_WORKFLOW_BINDING_REFERENCE_MISSING",`${o}/nodes/${c}/binding`)}}function ic(e,t,o){let n=b(t.routeManifest,"/contracts/routeManifest"),i=b(e.routeManifest,"/contracts/routeManifest"),s=new Map;for(let u of S(o.data?.resources,"/config/data/resources",100)){let l=b(u,"/config/data/resources");s.set(String(l.code||""),l)}let c=new Set(S(i.routes,"/contracts/routeManifest/routes",1e3).map(u=>String(b(u,"/contracts/routeManifest/routes").code||""))),r=[];for(let u of S(n.routes,"/contracts/routeManifest/routes",1e3)){let l=b(u,"/contracts/routeManifest/routes"),f=String(l.kind||"");if(f!=="resource-records"&&f!=="resource-submit")continue;let A=String(l.resourceCode||""),N=s.get(A);N||_("NATIVE_ROUTE_MANIFEST_RESOURCE_UNKNOWN","/contracts/routeManifest/routes");let m=`user.${A}.${f==="resource-records"?"records":"submit"}`;x(String(l.code||""),m,"/contracts/routeManifest/routes/code");let E=f==="resource-records"?"read":"create",p=String(b(N.capabilities,"/config/data/resources/capabilities")[E]||"");for(let g of["desktop","mobile"]){let O=b(l[g],`/contracts/routeManifest/routes/${g}`),y=g==="mobile"?"/m/my/":"/my/",T=f==="resource-records"?`${y}${A}`:`${y}${A}/submit`;x(String(O.path||""),T,`/contracts/routeManifest/routes/${g}/path`),x(String(O.capability||""),p,`/contracts/routeManifest/routes/${g}/capability`),x(String(O.routeCode||""),`${m}.${g}`,`/contracts/routeManifest/routes/${g}/routeCode`)}(c.has(m)||r.some(g=>String(g.code)===m))&&_("NATIVE_ROUTE_MANIFEST_DUPLICATE","/contracts/routeManifest/routes/code"),r.push(l)}if(!r.length)return;i.routes=S([...i.routes,...r],"/contracts/routeManifest/routes",1e3).sort((u,l)=>ue(String(b(u,"x").code||""),String(b(l,"x").code||"")));let a=String(b(n.rootEntry,"x").code||"");if(r.find(u=>String(u.code)===a&&u.kind==="resource-records")){let u=b(n.rootEntry,"x");i.rootEntry={code:a,desktop:String(u.desktop||""),mobile:String(u.mobile||"")}}i.digest=X({schemaVersion:i.schemaVersion,appCode:i.appCode,devicePolicy:i.devicePolicy,rootEntry:i.rootEntry,authentication:i.authentication,routes:i.routes})}function We(e,t,o){let n=b(e,t);R(n,["schemaVersion","appCode","code","name","schema","surface","invariants","decimalReservationLifecycle","uniqueKeys","capabilities","dataPolicyCode","fieldPolicies"],t,!0),x(n.schemaVersion,"openxiangda.data-resource/v2",`${t}/schemaVersion`),x(n.appCode,o,`${t}/appCode`);let i=J(n.code,`${t}/code`),s=C(n.name,`${t}/name`,255),c=b(n.schema,`${t}/schema`);R(c,["fields"],`${t}/schema`);let r,a,d,u;try{d=jt(n.decimalReservationLifecycle,`${t}/decimalReservationLifecycle`),r=Dt(c.fields,`${t}/schema/fields`),u=qn(n.uniqueKeys,r,`${t}/uniqueKeys`),a=Tn(n.invariants,r,`${t}/invariants`),vt(n.surface,r,`${t}/surface`)}catch(N){throw(N instanceof me||N instanceof Fe||N instanceof Xe)&&_(N.code,N.pointer),N}let l=new Set(r.map(N=>N.code)),f=b(n.capabilities,`${t}/capabilities`);R(f,["read","create","update","delete"],`${t}/capabilities`);let A=b(n.fieldPolicies,`${t}/fieldPolicies`);for(let[N,I]of Object.entries(A)){!l.has(N)&&!Ge(N)&&_("NATIVE_DATA_FIELD_POLICY_FIELD_MISSING",`${t}/fieldPolicies/${N}`);let m=`${t}/fieldPolicies/${N}`,E=b(I,m);Ge(N)&&(R(E,["read"],m,!0),(!Array.isArray(E.read)||E.read.length>20||E.read.some(p=>typeof p!="string"||!p.trim())||new Set(E.read).size!==E.read.length)&&_("NATIVE_DATA_AUDIT_READ_POLICY_INVALID",`${m}/read`)),R(E,["read","create","update","mask"],m,!0),E.mask!==void 0&&!["omit","null"].includes(E.mask)&&_("NATIVE_DATA_FIELD_POLICY_MASK_INVALID",`${m}/mask`)}return{...n,code:i,name:s,schema:{fields:r},...n.invariants===void 0?{}:{invariants:a},...d?{decimalReservationLifecycle:d}:{},...u!==void 0?{uniqueKeys:u}:{},capabilities:f,fieldPolicies:A}}function Hi(e){return[{code:`app:${e}:directory:read`,kind:"platform",name:"\u8BFB\u53D6\u53D7\u9650\u7EC4\u7EC7\u76EE\u5F55",source:"platform"},...[["app:role:read","\u67E5\u770B\u89D2\u8272\u4E0E\u6388\u6743"],["app:role:define","\u5B9A\u4E49\u624B\u5DE5\u89D2\u8272"],["app:role:assign","\u5206\u914D\u89D2\u8272\u6210\u5458"],["app:role:grant-capability","\u6388\u4E88\u89D2\u8272\u80FD\u529B"],["app:scope-grant:manage","\u7BA1\u7406\u6570\u636E\u8303\u56F4"],["app:super-admin:manage","\u7BA1\u7406\u5E94\u7528\u6700\u9AD8\u7BA1\u7406\u5458"]].map(([t,o])=>({code:t,kind:"platform",name:o,source:"platform"}))]}function Di(e,t,o,n){let i=e.toString("utf8"),s;try{s=JSON.parse(i)}catch{_(o,t)}let c=b(s,t);return ee(c)!==i&&_(n,t),c}function $i(e,t){let o=0,n=(i,s,c)=>{if(o+=1,o>ua&&_("NATIVE_ARTIFACT_NODE_LIMIT_EXCEEDED",s),c>la&&_("NATIVE_ARTIFACT_DEPTH_LIMIT_EXCEEDED",s),typeof i=="string"){Buffer.byteLength(i)>po&&_("NATIVE_ARTIFACT_STRING_LIMIT_EXCEEDED",s);return}if(Array.isArray(i)){i.forEach((r,a)=>n(r,`${s}/${a}`,c+1));return}if(!(!i||typeof i!="object"))for(let[r,a]of Object.entries(i))["__proto__","prototype","constructor"].includes(r)&&_("NATIVE_ARTIFACT_DANGEROUS_KEY",`${s}/${r}`),sc(r)&&_("NATIVE_ARTIFACT_RUNTIME_FIELD_FORBIDDEN",`${s}/${r}`),n(a,`${s}/${r}`,c+1)};n(e,t,0)}function sc(e){return["environmentKey","environmentId","secretValue","ciphertext","oauthClient","oauthClientId","oauthClientSecret","signingSecret","kubernetesNamespace","nodePort","productionUrl"].includes(e)}function ot(e){return{value:e,digest:X(e)}}function Vi(e,t,o,n){typeof e!="string"&&!Buffer.isBuffer(e)&&!(e instanceof Uint8Array)&&_("NATIVE_ARTIFACT_BYTES_REQUIRED",o);let i=Buffer.isBuffer(e)?e:Buffer.from(e);return i.byteLength===0&&_("NATIVE_ARTIFACT_EMPTY",o),i.byteLength>t&&_(n,o),i}function ki(e,t,o,n){let i=ln.createHash("sha256").update(e).digest("hex");ln.timingSafeEqual(Buffer.from(i),Buffer.from(t))||_(n,o)}function b(e,t){return(!e||typeof e!="object"||Array.isArray(e))&&_("NATIVE_OBJECT_REQUIRED",t),e}function S(e,t,o){return Array.isArray(e)||_("NATIVE_ARRAY_REQUIRED",t),e.length>o&&_("NATIVE_ARRAY_LIMIT_EXCEEDED",t),e}function v(e,t,o){let n=S(e,t,o).map((i,s)=>C(i,`${t}/${s}`,255));return new Set(n).size!==n.length&&_("NATIVE_ARRAY_DUPLICATE",t),n}function C(e,t,o){return(typeof e!="string"||e.length===0||e.length>o)&&_("NATIVE_STRING_INVALID",t),e}function Io(e,t,o){return(typeof e!="string"||e.length>o)&&_("NATIVE_STRING_INVALID",t),e}function V(e,t){let o=C(e,t,128);return zr.test(o)||_("NATIVE_CODE_INVALID",t),o}function J(e,t){let o=C(e,t,64);return Hr.test(o)||_("NATIVE_RESOURCE_CODE_INVALID",t),o}function K(e,t){let o=C(e,t,63);return Xr.test(o)||_("NATIVE_FIELD_CODE_INVALID",t),o}function pn(e,t){let o=C(e,t,128);return ea.test(o)||_("NATIVE_WORKFLOW_CODE_INVALID",t),o}function dn(e,t){let o=C(e,t,128);return ta.test(o)||_("NATIVE_WORKFLOW_BINDING_CODE_INVALID",t),o}function we(e,t,o){let n=C(e,t,255);return Jr.test(n)||_("NATIVE_CAPABILITY_CODE_INVALID",t),!n.startsWith(`app:${o}:`)&&!Hi(o).some(i=>i.code===n)&&_("NATIVE_CAPABILITY_APP_MISMATCH",t),n}function ge(e,t){let o=C(e,t,2048);return(!o.startsWith("/")||o.startsWith("//")||o.includes("..")||o.includes("?")||o.includes("#"))&&_("NATIVE_ABSOLUTE_PATH_INVALID",t),o}function it(e,t){return(!Number.isInteger(e)||Number(e)<1)&&_("NATIVE_POSITIVE_INTEGER_REQUIRED",t),Number(e)}function te(e,t,o,n){return(!Number.isInteger(e)||Number(e)<o||Number(e)>n)&&_("NATIVE_INTEGER_OUT_OF_RANGE",t),Number(e)}function st(e,t){return typeof e!="boolean"&&_("NATIVE_BOOLEAN_REQUIRED",t),e}function _o(e,t){let o=C(e,t,64).toLowerCase();return Gr.test(o)||_("NATIVE_DIGEST_INVALID",t),o}function x(e,t,o){e!==t&&_("NATIVE_VALUE_MISMATCH",o)}function R(e,t,o,n=!1){let i=new Set([...t,...Array.isArray(n)?n:[]]);for(let s of Object.keys(e))i.has(s)||_("NATIVE_PROPERTY_UNKNOWN",`${o}/${s}`);if(n!==!0)for(let s of t)Object.prototype.hasOwnProperty.call(e,s)||_("NATIVE_PROPERTY_REQUIRED",`${o}/${s}`)}function Z(e,t){return[...e].sort((o,n)=>ue(t(o),t(n)))}function W(e){return[...new Set(e)].sort(ue)}function Fi(e){return[...new Set(e)].sort((t,o)=>t-o)}function ue(e,t){return e===t?0:e<t?-1:1}function Xi(e){return!e||typeof e!="object"||Object.isFrozen(e)||(Object.freeze(e),Object.values(e).forEach(t=>Xi(t))),e}function go(e,t,o){if(fo(e,t))return o;if(Array.isArray(e)&&Array.isArray(t)){let n=Math.max(e.length,t.length);for(let i=0;i<n;i+=1)if(!fo(e[i],t[i]))return go(e[i],t[i],`${o}/${i}`)}if(e&&t&&typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)){let n=W([...Object.keys(e),...Object.keys(t)]);for(let i of n){let s=e[i],c=t[i];if(!fo(s,c))return go(s,c,`${o}/${i}`)}}return o}function fo(e,t){return e===void 0||t===void 0?e===t:ee(e)===ee(t)}function _(e,t,o={}){throw new rn(e,t,o)}var Fd=50,vd=131072,mn=class extends Error{constructor(o){super("OPENXIANGDA_NATIVE_AUTHZ_BATCH_INPUT_INVALID");this.pointer=o}pointer;code="OPENXIANGDA_NATIVE_AUTHZ_BATCH_INPUT_INVALID";status=400};function rc(e){let t=l=>{throw new mn(l)},o=(l,f)=>((!l||typeof l!="object"||Array.isArray(l))&&t(f),l),n=(l,f,A)=>{for(let N of Object.keys(l))f.includes(N)||t(`${A}/${N}`)},i=(l,f,A)=>((typeof l!="string"||!l.trim()||l.length>f)&&t(A),l),s=(l,f)=>{let A=i(l,36,f);return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(A)||t(f),A.toLowerCase()},c=o(e,""),r;try{r=new TextEncoder().encode(JSON.stringify(c)).byteLength}catch{t("")}r>131072&&t(""),n(c,["schemaVersion","environmentKey","items"],""),c.schemaVersion!=="openxiangda.native-role-membership-batch-request/v2"&&t("/schemaVersion"),c.environmentKey!==void 0&&!["preproduction","production"].includes(String(c.environmentKey))&&t("/environmentKey"),(!Array.isArray(c.items)||c.items.length<1||c.items.length>50)&&t("/items");let a=new Set,d=new Set,u;for(let[l,f]of c.items.entries()){let A=`/items/${l}`,N=o(f,A);["create","update","revoke"].includes(String(N.operation))||t(`${A}/operation`),u??=N.operation,u!==N.operation&&t(`${A}/operation`),n(N,["operation","operationId","reason",...u==="create"?["userId","roleCode"]:["membershipId","expectedRevision"],...u!=="revoke"?["scopeGrants","validFrom","validTo"]:[]],A);let I=s(N.operationId,`${A}/operationId`);a.has(I)&&t(`${A}/operationId`),a.add(I),i(N.reason,1e3,`${A}/reason`);let m;if(u==="create"){let E=i(N.userId,255,`${A}/userId`),p=i(N.roleCode,128,`${A}/roleCode`);/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(p)||t(`${A}/roleCode`),m=JSON.stringify([E,p])}else m=s(N.membershipId,`${A}/membershipId`),(!Number.isSafeInteger(N.expectedRevision)||Number(N.expectedRevision)<1)&&t(`${A}/expectedRevision`);d.has(m)&&t(A),d.add(m),N.scopeGrants!==void 0&&(!Array.isArray(N.scopeGrants)||N.scopeGrants.length>100)&&t(`${A}/scopeGrants`);for(let E of["validFrom","validTo"])N[E]!==void 0&&N[E]!==null&&i(N[E],64,`${A}/${E}`)}}var ts="openxiangda.workflow-delegation-administration/v2",ns="openxiangda.workflow-delegation-mutation/v2",Qi="openxiangda.workflow-delegation-preview/v2";var Ot={type:"string",format:"uuid",pattern:"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"},fe={type:"string",minLength:1,maxLength:255},Ue={type:"string",format:"date-time"},rt={type:"integer",minimum:1},ac={anyOf:[Ue,{type:"null"}]},No={anyOf:[fe,{type:"null"}]},_n={type:"string",pattern:"^membership:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},os={const:"future-assignments-only"},yo={schemaVersion:{const:ts},id:Ot,appCode:fe,environmentKey:fe,workflowCode:No,delegatorUserId:fe,delegateUserId:fe,delegatorRoleSubjectKey:_n,delegateRoleSubjectKey:_n,validFrom:Ue,validTo:Ue,status:{enum:["active","revoked","expired"]},reason:{type:"string",minLength:1,maxLength:4e3},createdBy:fe,createdAt:Ue,revokedAt:ac,revision:rt,roleCode:fe,roleName:fe,delegatorDisplayName:fe,delegateDisplayName:fe,delegatorRoleSubjectRevision:rt,delegateRoleSubjectRevision:rt,effectiveState:{enum:["active","scheduled","expired","revoked","ineligible"]},evaluatedAt:Ue,issues:{type:"array",maxItems:20,uniqueItems:!0,items:fe},canRevoke:{type:"boolean"},revokedBy:No,revokeReason:{type:["string","null"],maxLength:4e3},taskPolicy:os},bo={type:"object",additionalProperties:!1,required:Object.keys(yo),properties:yo},Ld={$id:ts,...bo},is={schemaVersion:{const:ns},operationId:Ot,environmentKey:{enum:["preproduction","production"]},reason:{type:"string",minLength:1,maxLength:2e3,pattern:"\\S"}},Zi={...is,operation:{const:"create"},workflowCode:No,delegatorRoleSubjectKey:_n,expectedDelegatorRevision:rt,delegateUserId:fe,delegateRoleSubjectKey:_n,expectedDelegateRevision:rt,validFrom:Ue,validTo:Ue},es={...is,operation:{const:"revoke"},delegationId:Ot,expectedRevision:rt},ss={$id:ns,type:"object",oneOf:[{type:"object",additionalProperties:!1,required:Object.keys(Zi),properties:Zi},{type:"object",additionalProperties:!1,required:Object.keys(es),properties:es}]},cc={type:"string",pattern:"^[0-9a-f]{64}$"},xd={$id:Qi,type:"object",additionalProperties:!1,required:["schemaVersion","operationId","operation","requestDigest","before","after","taskPolicy"],properties:{schemaVersion:{const:Qi},operationId:Ot,operation:{enum:["create","revoke"]},requestDigest:cc,before:{anyOf:[bo,{type:"null"}]},after:{...bo,properties:{...yo,id:{anyOf:[Ot,{type:"null"}]}}},taskPolicy:os}};function dc(e){return e===void 0?"":`
|
|
9
|
+
${X(e)}`}function lc(e,t){let o=e.handlers.find(n=>n.code===t);return X(o?.workflowStep?o:e)}var uc="c7768a3f65626330bcaf93664c3ab890eda13cbdd76ea4cfaf74b8ad2032ac99";0&&(module.exports={DATA_AUDIT_METADATA_FIELDS,DATA_EVENT_TYPES_V2,DATA_SYSTEM_SORT_FIELD_CODES,ManagedConcurrencyContractError,NATIVE_CONFIGURATION_VALIDATOR_DIGEST,NATIVE_CONTRACT_CAPACITY_V2,NATIVE_DATA_POLICY_EXPRESSION_MAX_CLAUSES,NATIVE_DATA_POLICY_EXPRESSION_MAX_DEPTH,NATIVE_DATA_POLICY_EXPRESSION_MAX_GROUP_ITEMS,NATIVE_DATA_POLICY_EXPRESSION_MAX_LEAVES,NATIVE_DATA_POLICY_EXPRESSION_MAX_OCCURRENCES,NATIVE_DATA_QUERY_OPERATORS_V2,NATIVE_ROLE_MEMBERSHIP_BATCH_MAX_BYTES,NATIVE_ROLE_MEMBERSHIP_BATCH_MAX_ITEMS,NATIVE_UNIQUE_KEY_MAX_BYTES,NATIVE_UNIQUE_KEY_NORMALIZERS,NativeConfigurationCompilerError,NativeDataFieldContractV2Error,NativeDataPolicyExpressionV2Error,NativeDecimalLifecycleContractError,NativeEventActionContractError,NativeRoleMembershipBatchInputError,NativeScopeSourceFieldPathV2Error,NativeUniqueKeyContractError,OPENXIANGDA_NATIVE_DATA_FIELD_TYPES_V2,OPENXIANGDA_NATIVE_DATA_SURFACE_KEYS_V2,OPENXIANGDA_NATIVE_DRAFT_STATE_KEYS_V2,OPENXIANGDA_NATIVE_SYSTEM_FIELDS_V2,OPENXIANGDA_NATIVE_SYSTEM_FIELD_MAP_V2,WORKFLOW_AUTOMATIC_CC_MAX_RECIPIENTS,WORKFLOW_AUTOMATIC_CC_PROVIDERS,WORKFLOW_BUSINESS_STEP_EVENT,WORKFLOW_BUSINESS_STEP_EVENTS,WORKFLOW_BUSINESS_STEP_FACTS_KEY,WORKFLOW_BUSINESS_STEP_MAX_BYTES,WORKFLOW_BUSINESS_STEP_MAX_RECEIPT_BYTES,WORKFLOW_CONFIGURABLE_OPERATIONS,WORKFLOW_CONFIGURABLE_PROVIDERS,WORKFLOW_EVENT_TYPES_V2,WORKFLOW_ROUTING_MAX_BYTES,WORKFLOW_ROUTING_MAX_MATCHED_RULES,WORKFLOW_ROUTING_MAX_RULES,WORKFLOW_TASK_PAGE_MAX_BYTES,WORKFLOW_TASK_PAGE_MAX_FIELDS,WorkflowTaskPageError,applyWorkflowTaskPageValues,assertNativeRoleMembershipBatchInput,compileNativeApplicationConfiguration,compileNativeEventAction,compileNativeEventCapturePlansV2,compileRequiredPlatformCapabilitiesV3,compileWorkflowBusinessStepHandlers,evaluateWorkflowTaskPageExpression,formatWorkflowExpression,hasDataAuditReadPolicy,isDataAuditMetadataField,isDataSystemSortField,isNativeDataQueryOperatorV2,isNativeMultiValueFieldV2,materializeNativeDataQueryPathTypesV2,nativeDataPolicyExpressionLeavesV2,nativeDataPolicyExpressionToCnfV2,nativeDataQueryPathPlanV2,nativeFieldAggregatePlanV2,nativeFieldColumnDefinitionV2,nativeFieldDefaultSqlV2,nativeFieldHasDefaultV2,nativeFieldIndexStatementsV2,nativeFieldRequiresCreateInputV2,nativeFieldSequenceGrantStatementsV2,nativeFieldSequenceOwnershipStatementsV2,nativeFieldSequenceStatementsV2,nativeFieldSupportsFilterV2,nativeFieldSupportsOperatorV2,nativeFieldSupportsSearchV2,nativeFieldSupportsSortV2,nativeOperatorsForFieldV2,nativePhysicalFieldV2,nativePhysicalFieldsV2,nativePhysicalObjectNameV2,nativeScopeSourceFieldValueV2,nativeScopeSourceGrantPathSupportedV2,nativeScopeSourceSubjectPathSupportedV2,nativeSubtableConstraintStatementsV2,nativeUniqueKeysJsonSchema,parseDecimalReservationLifecycle,parseNativeDataFieldsV2,parseNativeDataResourceInvariantsV2,parseNativeUniqueKeys,projectNativeDataResourceViewV2,projectWorkflowGraph,projectWorkflowNodePolicy,quoteNativeIdentifierV2,refreshWorkflowTaskPageFacts,resolveNativeScopeSourceFieldPathV2,selectWorkflowAssignmentRoutingRules,validateDecimalReservationLifecycles,validateManagedConcurrency,validateNativeDataDraftStateV2,validateNativeDataResourceReferencesV2,validateNativeDataResourceSurfaceV2,validateWorkflowAdministration,validateWorkflowAssignmentRoutingBindings,validateWorkflowAssignmentRoutingPolicy,validateWorkflowAssignmentRoutingRules,validateWorkflowAutomaticCc,validateWorkflowBusinessStepHandlerContract,validateWorkflowBusinessStepRequest,validateWorkflowBusinessStepResult,validateWorkflowBusinessStepSchema,validateWorkflowBusinessStepSubscriptions,validateWorkflowBusinessSteps,validateWorkflowInstanceCommandPolicies,validateWorkflowNodeConfigurationPatch,validateWorkflowReadability,validateWorkflowTaskPages,workflowAssignmentRoutingFacts,workflowAssignmentRoutingPolicySchema,workflowAssignmentRoutingSemantic,workflowBusinessStepFactSchema,workflowBusinessStepHandlerDigest,workflowBusinessStepInput,workflowBusinessStepPath,workflowBusinessStepReceiptSignatureSuffix,workflowBusinessStepValueMatches,workflowDelegationMutationRequestSchema,workflowExpressionPaths,workflowInstanceCommandDeadlineError,workflowInstanceTerminateCapabilityAllowed,workflowNodeAllowedOperations,workflowPolicyTimestamp,workflowTaskPageFieldState,workflowTaskPageReplayCoversInvalidation});
|