@tachybase/plugin-audit-logs 1.3.18 → 1.3.20

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.
@@ -1 +1 @@
1
- (function(a,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("@ant-design/icons"),require("react-i18next"),require("@tachybase/schema"),require("@tachybase/utils/client"),require("react"),require("@tachybase/components")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","@ant-design/icons","react-i18next","@tachybase/schema","@tachybase/utils/client","react","@tachybase/components"],e):(a=typeof globalThis!="undefined"?globalThis:a||self,e(a["@tachybase/plugin-audit-logs"]={},a["@tachybase/client"],a.jsxRuntime,a["@ant-design/icons"],a["react-i18next"],a["@tachybase/schema"],a["@tachybase/utils"],a.react,a["@tachybase/components"]))})(this,function(a,e,i,d,S,p,v,b,y){"use strict";var ne=Object.defineProperty,ae=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var B=(a,e,i)=>e in a?ne(a,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[e]=i,m=(a,e)=>{for(var i in e||(e={}))N.call(e,i)&&B(a,i,e[i]);if(F)for(var i of F(e))j.call(e,i)&&B(a,i,e[i]);return a},x=(a,e)=>ae(a,le(e));var E=(a,e)=>{var i={};for(var d in a)N.call(a,d)&&e.indexOf(d)<0&&(i[d]=a[d]);if(a!=null&&F)for(var d of F(a))e.indexOf(d)<0&&j.call(a,d)&&(i[d]=a[d]);return i};var O=(a,e,i)=>new Promise((d,S)=>{var p=y=>{try{b(i.next(y))}catch(h){S(h)}},v=y=>{try{b(i.throw(y))}catch(h){S(h)}},b=y=>y.done?d(y.value):Promise.resolve(y.value).then(p,v);b((i=i.apply(a,e)).next())});const h="@tachybase/plugin-audit-logs";function C(){return S.useTranslation(h)}const t=o=>e.tval(o,{ns:h}),P=()=>{const{insert:o}=e.useSchemaInitializer(),{t:r}=C(),l=e.useSchemaInitializerItem(),n=e.createTableBlockSchema({collection:"auditLogs",rowKey:"id",tableActionInitializers:"auditLogsTable:configureActions",tableColumnInitializers:"auditLogsTable:configureColumns",tableActionColumnInitializers:"auditLogsTable:configureItemActions",tableBlockProvider:"AuditLogsBlockProvider",disableTemplate:!0});return i.jsx(e.SchemaInitializerItem,m({icon:i.jsx(d.TableOutlined,{}),onClick:()=>{o(n)},title:r("Audit Logs")},l))},q=()=>({name:"auditLogs",title:t("Audit logs"),fields:[{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:t("Created at"),"x-component":"DatePicker","x-component-props":{showTime:!0,ellipsis:!0},"x-read-pretty":!0}},{name:"type",type:"string",interface:"select",uiSchema:{type:"string",title:t("Action type"),"x-component":"Select","x-component-props":{ellipsis:!0},"x-read-pretty":!0,enum:[{label:t("Create record"),value:"create",color:"lime"},{label:t("Update record"),value:"update",color:"gold"},{label:t("Delete record"),value:"destroy",color:"magenta"}]}},{name:"recordId",type:"string",interface:"input",uiSchema:{title:t("Record ID"),type:"string","x-component":"Input","x-component-props":{ellipsis:!0}}},{collectionName:"auditLogs",name:"collection",type:"belongsTo",interface:"m2o",target:"collections",targetKey:"name",sourceKey:"id",foreignKey:"collectionName",uiSchema:{type:"object",title:t("Collection"),"x-component":"AssociationField","x-component-props":{fieldNames:{value:"name",label:"title"},ellipsis:!0},"x-read-pretty":!0}},{name:"collectionName",type:"string",interface:"string",uiSchema:{type:"string",title:t("Collection name"),"x-component":"Input"}},{name:"user",collectionName:"auditLogs",type:"belongsTo",interface:"createdBy",targetKey:"id",foreignKey:"createdById",target:"users",uiSchema:{type:"object",title:t("User"),"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"},ellipsis:!0},"x-read-pretty":!0}},{name:"changes",collectionName:"auditLogs",type:"hasMany",interface:"subTable",target:"auditChanges",foreignKey:"auditLogId",targetKey:"id",uiSchema:{type:"object",title:t("Details of changes")}},{type:"bigInt",name:"id",interface:"number",uiSchema:{type:"number",title:"ID","x-component":"InputNumber"}}]}),M=()=>({name:"auditChanges",title:t("Audit Changes"),fields:[{name:"field",type:"json",interface:"input",uiSchema:{title:t("Field"),"x-component":"AuditLogsField"}},{type:"json",name:"before",interface:"input",uiSchema:{title:t("Before change"),"x-component":"AuditLogsValue"}},{type:"json",name:"after",interface:"input",uiSchema:{title:t("After change"),"x-component":"AuditLogsValue"}}]}),K=()=>({name:"collections",title:t("Collections"),fields:[{name:"name",type:"string",interface:"input",uiSchema:{title:t("Collection name"),type:"string","x-component":"Input","x-component-props":{ellipsis:!0}}},{name:"title",type:"string",interface:"input",uiSchema:{title:t("Collection display name"),type:"string","x-component":"Input","x-component-props":{ellipsis:!0}}}]}),U=l=>{var n=l,{children:o}=n,r=E(n,["children"]);const s=M(),c=q(),u=K();return i.jsx(e.ExtendCollectionsProvider,{collections:[c,s,u],children:i.jsx(e.TableBlockProvider,x(m({name:"audit-logs"},r),{children:o}))})},R=p.observer(()=>{var l,n,s,c;const o=p.useField(),r=e.useCompile();return o.value?i.jsx(e.EllipsisWithTooltip,{ellipsis:!0,children:(n=(l=o.value)==null?void 0:l.uiSchema)!=null&&n.title?r((c=(s=o.value)==null?void 0:s.uiSchema)==null?void 0:c.title):o.value.name}):null},{displayName:"AuditLogsField"}),W=p.observer(()=>{var l,n;const o=p.useField(),r=e.useRecord();return(l=r.field)!=null&&l.uiSchema?i.jsx(e.FormProvider,{children:i.jsx(e.SchemaComponent,{schema:x(m({name:r.field.name},(n=r.field)==null?void 0:n.uiSchema),{default:o.value,"x-read-pretty":!0})})}):i.jsx(e.EllipsisWithTooltip,{ellipsis:!0,children:o.value?JSON.stringify(o.value):null})},{displayName:"AuditLogsValue"}),_=()=>{const o={type:"string","x-component":"AssociationField","x-decorator":"FormItem","x-collection-field":"auditLogs.changes","x-read-pretty":!0,"x-component-props":{multiple:!0,fieldNames:{value:"id",label:"id"},mode:"SubTable"},properties:{block:{type:"void","x-component":"AssociationField.SubTable",properties:{[v.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{field:{"x-collection-field":"auditChanges.field","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},[v.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{before:{"x-collection-field":"auditChanges.before","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},[v.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{after:{"x-collection-field":"auditChanges.after","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}}}}}},r={type:"void",title:t("View"),"x-action":"view","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:view","x-component":"Action","x-component-props":{openMode:e.OpenMode.DRAWER_MODE},properties:{drawer:{type:"void",title:t("View record"),"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},properties:{tab1:{type:"void",title:t("Details"),"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid",properties:{"7ypqrxaqysp":{type:"void","x-component":"Grid.Row",properties:{"1fc2l8dwe7m":{type:"void","x-component":"Grid.Col",properties:{"5ley6xifrsb":{type:"void","x-acl-action":"auditLogs:get","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"auditLogs",collection:"auditLogs",readPretty:!0,action:"get",params:{appends:["collection","user","changes"]},useParams:"{{ useParamsFromRecord }}",useSourceId:"{{ useSourceIdFromParentRecord }}"},"x-component":"CardItem",properties:{bv710pbf9w6:{type:"void","x-component":"FormV2","x-read-pretty":!0,"x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid",properties:{g4c24abnbd9:{type:"void","x-component":"Grid.Row",properties:{fkt9dj5lu1k:{type:"void","x-component":"Grid.Col",properties:{createdAt:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.createdAt","x-component-props":{},"x-read-pretty":!0}}}}},l267bkv423v:{type:"void","x-component":"Grid.Row",properties:{tehaepm5xqy:{type:"void","x-component":"Grid.Col",properties:{type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.type","x-component-props":{},"x-read-pretty":!0}}}}},zhmn2tkzdh2:{type:"void","x-component":"Grid.Row",properties:{yuwyej17i64:{type:"void","x-component":"Grid.Col",properties:{recordId:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.recordId","x-component-props":{}}}}}},"6q933ic06mj":{type:"void","x-component":"Grid.Row",properties:{nwtbkqd99zl2:{type:"void","x-component":"Grid.Col",properties:{"collection.title":{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.collection.title","x-component-props":{}}}},nwtbkqd99zl1:{type:"void","x-component":"Grid.Col",properties:{"collection.name":{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.collection.name","x-component-props":{}}}}}},xd4kzulndqk:{type:"void","x-component":"Grid.Row",properties:{k3sd72n83zd:{type:"void","x-component":"Grid.Col",properties:{user:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.user","x-component-props":{},"x-read-pretty":!0,properties:{viewer:{type:"void",title:t("View record"),"x-component":"RecordPicker.Viewer","x-component-props":{className:"tb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:t("Details"),"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}}}}}},"3lghgclbtcg":{type:"void","x-component":"Grid.Row",properties:{"8l1v1auwlx0":{type:"void","x-component":"Grid.Col",properties:{changes:o}}}}}}}}}}}}}}}}}}}}}}}};return i.jsx(e.ActionInitializer,{schema:r})},J=()=>{var f,V,G,D;const{name:o,title:r}=e.useCollection_deprecated(),l=p.useField(),n=p.useFieldSchema(),{form:s}=e.useFormBlockContext(),{service:c}=e.useTableBlockContext(),{t:u}=C(),{dn:T}=e.useDesignable();return i.jsxs(e.GeneralSchemaDesigner,{title:r||o,children:[i.jsx(e.SchemaSettingsDataScope,{collectionName:o,defaultFilter:((V=(f=n==null?void 0:n["x-decorator-props"])==null?void 0:f.params)==null?void 0:V.filter)||{},form:s,onSubmit:({filter:A})=>{var I;const g=l.decoratorProps.params||{};g.filter=A,l.decoratorProps.params=g,n["x-decorator-props"].params=g,c.run(x(m({},(I=c.params)==null?void 0:I[0]),{filter:A,page:1})),T.emit("patch",{schema:{"x-uid":n["x-uid"],"x-decorator-props":n["x-decorator-props"]}})}}),i.jsx(e.SchemaSettingsSelectItem,{title:u("Records per page"),value:((D=(G=l.decoratorProps)==null?void 0:G.params)==null?void 0:D.pageSize)||20,options:[{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100},{label:"200",value:200}],onChange:A=>{var I;const g=l.decoratorProps.params||{};g.pageSize=A,l.decoratorProps.params=g,n["x-decorator-props"].params=g,c.run(x(m({},(I=c.params)==null?void 0:I[0]),{pageSize:A,page:1})),T.emit("patch",{schema:{"x-uid":n["x-uid"],"x-decorator-props":n["x-decorator-props"]}})}}),i.jsx(e.SchemaSettingsDivider,{}),i.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})},$={name:"auditLogs",title:t("Audit logs"),fields:[{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:t("Created at"),"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{name:"type",type:"string",interface:"select",uiSchema:{type:"string",title:t("Action type"),"x-component":"Select","x-read-pretty":!0,enum:[{label:t("Create record"),value:"create",color:"lime"},{label:t("Update record"),value:"update",color:"gold"},{label:t("Delete record"),value:"destroy",color:"magenta"}]}}]},H=p.observer(()=>{var r,l;const o=p.useField();return i.jsx("div",{children:((r=o==null?void 0:o.value)==null?void 0:r.nickname)||((l=o.value)==null?void 0:l.id)})},{displayName:"Username"}),Q=p.observer(()=>{const o=p.useField(),{title:r,name:l}=o.value||{},n=e.useCompile();return i.jsx("div",{children:r?n(r):l})},{displayName:"Collection"}),X=p.observer(()=>{var l,n,s,c;const o=p.useField(),r=e.useCompile();return o.value?i.jsx("div",{children:(n=(l=o.value)==null?void 0:l.uiSchema)!=null&&n.title?r((c=(s=o.value)==null?void 0:s.uiSchema)==null?void 0:c.title):o.value.name}):null},{displayName:"Field"}),Y=p.observer(()=>{var l,n;const o=p.useField(),r=y.ArrayTable.useRecord();return(l=r.field)!=null&&l.uiSchema?i.jsx(e.FormProvider,{children:i.jsx(e.SchemaComponent,{schema:x(m({name:r.field.name},(n=r.field)==null?void 0:n.uiSchema),{default:o.value,"x-read-pretty":!0})})}):i.jsx("div",{children:o.value?JSON.stringify(o.value):null})},{displayName:"Value"}),L=b.createContext(null);L.displayName="IsAssociationBlock";const w=()=>{const o=b.useContext(L),r={};return o||(r.column31={type:"void","x-component":"TableV2.Column",title:t("Record ID"),properties:{recordId:{"x-component":"Input","x-read-pretty":!0}}}),i.jsx(e.SchemaComponent,{memoized:!0,components:{ArrayTable:y.ArrayTable,Username:H,Collection:Q,Field:X,Value:Y},schema:{type:"void",name:"lfm4trkw8j3","x-component":"div",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:t("Filter"),"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"}}},y84dlntcaup:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useProps:"{{ useTableBlockProps }}"},properties:x(m({actions:{type:"void",title:t("Actions"),"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-designer":"TableV2.ActionColumnDesigner","x-initializer":"table:configureItemActions",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{o80rypwmeeg:{type:"void",title:t("View"),"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:view","x-component":"Action.Link","x-component-props":{openMode:e.OpenMode.DRAWER_MODE},properties:{drawer:{type:"void",title:t("View record"),"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{grid:{type:"void","x-component":"Grid",properties:{tdlav8o9o17:{type:"void","x-component":"Grid.Row",properties:{"7bsnaf47i6g":{type:"void","x-component":"Grid.Col",properties:{"6s2qbihe3tu":{type:"void","x-acl-action":"auditLogs:get","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"auditLogs",collection:"auditLogs",readPretty:!0,action:"get",params:{appends:["collection","user","changes"]},useParams:"{{ useParamsFromRecord }}",useSourceId:"{{ useSourceIdFromParentRecord }}"},"x-component":"CardItem",properties:{mevpuonrda0:{type:"void","x-component":"FormV2","x-read-pretty":!0,"x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid",properties:{row1:{type:"void","x-component":"Grid.Row",properties:{col11:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",title:t("Collection display name"),"x-component":"Collection","x-decorator":"FormItem","x-read-pretty":!0}}}}},row2:{type:"void","x-component":"Grid.Row",properties:{col21:{type:"void","x-component":"Grid.Col",properties:{type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0}}}}},row3:{type:"void","x-component":"Grid.Row",properties:{col31:{type:"void","x-component":"Grid.Col",properties:{createdAt:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0}}}}},row4:{type:"void","x-component":"Grid.Row",properties:{col41:{type:"void","x-component":"Grid.Col",properties:{user:{type:"string",title:t("User"),"x-component":"Username","x-decorator":"FormItem","x-read-pretty":!0}}}}},row5:{type:"void","x-component":"Grid.Row",properties:{col51:{type:"void","x-component":"Grid.Col",properties:{changes:{type:"array",title:t("Field value changes"),"x-decorator":"FormItem","x-component":"ArrayTable","x-component-props":{pagination:{pageSize:10},scroll:{x:"100%"}},items:{type:"object",properties:{column3:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:200,title:t("Field")},properties:{field:{type:"string","x-component":"Field"}}},column4:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:200,title:t("Before change")},properties:{before:{type:"string","x-decorator":"FormItem","x-component":"Value"}}},column5:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:200,title:t("After change")},properties:{after:{type:"string","x-decorator":"FormItem","x-component":"Value"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}},column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{"x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{type:{"x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-component":"TableV2.Column",title:t("Collection display name"),properties:{collection:{"x-component":"Collection","x-read-pretty":!0}}}},r),{column4:{type:"void","x-component":"TableV2.Column",title:t("User"),properties:{user:{"x-component":"Username","x-read-pretty":!0}}}})}}}})};w.Decorator=p.observer(o=>{var c;const r=e.useCollection_deprecated(),l=e.useRecord();let n=(c=o==null?void 0:o.params)==null?void 0:c.filter;if(r.name){const u=l==null?void 0:l[r.filterTargetKey||"id"];n?n={$and:[n,{collectionName:r.name,recordId:`${u}`}]}:n={collectionName:r.name,recordId:`${u}`}}const s={collection:"auditLogs",resource:"auditLogs",action:"list",params:x(m({pageSize:20,appends:["collection","user"]},o.params),{filter:n,sort:"-createdAt"}),rowKey:"id",showIndex:!0,dragSort:!1};return i.jsx(L.Provider,{value:!!r.name,children:i.jsx(e.ExtendCollectionsProvider,{collections:[$],children:i.jsx(e.TableBlockProvider,x(m({},s),{children:o.children}))})})},{displayName:"AuditLogs.Decorator"}),w.Designer=J;const Z=()=>{const o={type:"void",title:t("Actions"),"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-designer":"TableV2.ActionColumnDesigner","x-initializer":"auditLogsTable:configureItemActions","x-action-column":"actions",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{}}}},r=e.useSchemaInitializerItem();return i.jsx(e.InitializerWithSwitch,x(m({},r),{schema:o,item:r,type:"x-action-column"}))},z=o=>i.jsx(e.SchemaComponentOptions,{components:{AuditLogs:w,AuditLogsBlockProvider:U,AuditLogsBlockInitializer:P,AuditLogsValue:W,AuditLogsField:R,AuditLogsViewActionInitializer:_,AuditLogsTableActionColumnInitializer:Z},children:o.children}),ee=new e.SchemaInitializer({name:"auditLogsTable:configureItemActions",insertPosition:"beforeEnd",Component:o=>i.jsx(d.MenuOutlined,x(m({},o),{style:{cursor:"pointer"}})),useInsert(){const o=p.useFieldSchema(),r=e.useAPIClient(),{refresh:l}=e.useDesignable(),{t:n}=C();return s=>{const c=o.reduceProperties((T,f)=>f["x-component"]==="Space"?f:T,null);if(!c)return;const u=e.createDesignable({t:n,api:r,refresh:l,current:c});u.loadAPIClientEvents(),u.insertBeforeEnd(s)}},items:[{name:"enableActions",type:"itemGroup",title:t("Enable actions"),children:[{name:"view",type:"item",title:t("View"),Component:"AuditLogsViewActionInitializer",schema:{"x-component":"Action.Link","x-action":"view","x-decorator":"ACLActionProvider"}}]},{name:"divider",type:"divider"},{name:"columnWidth",type:"item",title:t("Column width"),Component:e.Resizable}]}),oe=new e.SchemaInitializer({name:"auditLogsTable:configureActions",title:t("Configure actions"),icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:t("Enable actions"),name:"enableActions",children:[{name:"filter",title:t("Filter"),Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"refresh",title:t("Refresh"),Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]}]}),te=()=>{const o=e.useInheritsTableColumnInitializerFields(),{t:r}=C(),l=e.useCompile();if(!(o!=null&&o.length))return null;const n=[];return o.forEach(s=>{Object.values(s)[0].length&&n.push({type:"itemGroup",divider:!0,title:r("Parent collection fields")+"("+l(`${Object.keys(s)[0]}`)+")",children:Object.values(s)[0].filter(c=>{var u;return!((u=c==null?void 0:c.field)!=null&&u.isForeignKey)})})}),i.jsx(e.SchemaInitializerChildren,{children:n})},ie=()=>{const o=e.useAssociatedTableColumnInitializerFields(),{t:r}=C();if(!(o!=null&&o.length))return null;const l=[{type:"itemGroup",divider:!0,title:r("Display association fields"),children:o}];return i.jsx(e.SchemaInitializerChildren,{children:l})},re=new e.SchemaInitializer({name:"auditLogsTable:configureColumns",insertPosition:"beforeEnd",icon:"SettingOutlined",title:t("Configure columns"),wrap(o){return o["x-action-column"]?o:{type:"void","x-toolbar":"TableColumnSchemaToolbar","x-settings":"fieldSettings:TableColumn","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{[o.name]:m({},o)}}},items:[{name:"displayFields",type:"itemGroup",title:t("Display fields"),useChildren:e.useTableColumnInitializerFields},{name:"parentCollectionFields",Component:te},{name:"associationFields",Component:ie},{name:"actionColumn",title:t("Action column"),Component:"AuditLogsTableActionColumnInitializer"}]});class k extends e.Plugin{load(){return O(this,null,function*(){this.app.use(z),this.app.schemaInitializerManager.add(oe),this.app.schemaInitializerManager.add(ee),this.app.schemaInitializerManager.add(re);const r=this.app.schemaInitializerManager.get("page:addBlock"),l=this.app.schemaInitializerManager.get("popup:common:addBlock"),n={title:t("Audit logs"),Component:"AuditLogsBlockInitializer"};r.add("otherBlocks.auditLogs",n),l.add("otherBlocks.auditLogs",n)})}}a.AuditLogsBlockInitializer=P,a.AuditLogsPlugin=k,a.AuditLogsProvider=z,a.default=k,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(a,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("@ant-design/icons"),require("react-i18next"),require("@tachybase/schema"),require("@tachybase/utils/client"),require("react"),require("@tachybase/components")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","@ant-design/icons","react-i18next","@tachybase/schema","@tachybase/utils/client","react","@tachybase/components"],e):(a=typeof globalThis!="undefined"?globalThis:a||self,e(a["@tachybase/plugin-audit-logs"]={},a["@tachybase/client"],a.jsxRuntime,a["@ant-design/icons"],a["react-i18next"],a["@tachybase/schema"],a["@tachybase/utils"],a.react,a["@tachybase/components"]))})(this,function(a,e,i,d,S,p,v,b,y){"use strict";var ne=Object.defineProperty,ae=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var D=(a,e,i)=>e in a?ne(a,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[e]=i,m=(a,e)=>{for(var i in e||(e={}))N.call(e,i)&&D(a,i,e[i]);if(F)for(var i of F(e))j.call(e,i)&&D(a,i,e[i]);return a},x=(a,e)=>ae(a,le(e));var q=(a,e)=>{var i={};for(var d in a)N.call(a,d)&&e.indexOf(d)<0&&(i[d]=a[d]);if(a!=null&&F)for(var d of F(a))e.indexOf(d)<0&&j.call(a,d)&&(i[d]=a[d]);return i};var E=(a,e,i)=>new Promise((d,S)=>{var p=y=>{try{b(i.next(y))}catch(h){S(h)}},v=y=>{try{b(i.throw(y))}catch(h){S(h)}},b=y=>y.done?d(y.value):Promise.resolve(y.value).then(p,v);b((i=i.apply(a,e)).next())});const h="@tachybase/plugin-audit-logs";function C(){return S.useTranslation(h)}const t=o=>e.tval(o,{ns:h}),P=()=>{const{insert:o}=e.useSchemaInitializer(),{t:r}=C(),l=e.useSchemaInitializerItem(),n=e.createTableBlockSchema({collection:"auditLogs",rowKey:"id",tableActionInitializers:"auditLogsTable:configureActions",tableColumnInitializers:"auditLogsTable:configureColumns",tableActionColumnInitializers:"auditLogsTable:configureItemActions",tableBlockProvider:"AuditLogsBlockProvider",disableTemplate:!0});return i.jsx(e.SchemaInitializerItem,m({icon:i.jsx(d.TableOutlined,{}),onClick:()=>{o(n)},title:r("Audit Logs")},l))},O=()=>({name:"auditLogs",title:t("Audit logs"),fields:[{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:t("Created at"),"x-component":"DatePicker","x-component-props":{showTime:!0,ellipsis:!0},"x-read-pretty":!0}},{name:"type",type:"string",interface:"select",uiSchema:{type:"string",title:t("Action type"),"x-component":"Select","x-component-props":{ellipsis:!0},"x-read-pretty":!0,enum:[{label:t("Create record"),value:"create",color:"lime"},{label:t("Update record"),value:"update",color:"gold"},{label:t("Delete record"),value:"destroy",color:"magenta"}]}},{name:"recordId",type:"string",interface:"input",uiSchema:{title:t("Record ID"),type:"string","x-component":"Input","x-component-props":{ellipsis:!0}}},{collectionName:"auditLogs",name:"collection",type:"belongsTo",interface:"m2o",target:"collections",targetKey:"name",sourceKey:"id",foreignKey:"collectionName",uiSchema:{type:"object",title:t("Collection"),"x-component":"AssociationField","x-component-props":{fieldNames:{value:"name",label:"title"},ellipsis:!0},"x-read-pretty":!0}},{name:"collectionName",type:"string",interface:"string",uiSchema:{type:"string",title:t("Collection name"),"x-component":"Input"}},{name:"user",collectionName:"auditLogs",type:"belongsTo",interface:"createdBy",targetKey:"id",foreignKey:"createdById",target:"users",uiSchema:{type:"object",title:t("User"),"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"},ellipsis:!0},"x-read-pretty":!0}},{name:"changes",collectionName:"auditLogs",type:"hasMany",interface:"subTable",target:"auditChanges",foreignKey:"auditLogId",targetKey:"id",uiSchema:{type:"object",title:t("Details of changes")}},{type:"bigInt",name:"id",interface:"number",uiSchema:{type:"number",title:"ID","x-component":"InputNumber"}}]}),K=()=>({name:"auditChanges",title:t("Audit Changes"),fields:[{name:"field",type:"json",interface:"input",uiSchema:{title:t("Field"),"x-component":"AuditLogsField"}},{type:"json",name:"before",interface:"input",uiSchema:{title:t("Before change"),"x-component":"AuditLogsValue"}},{type:"json",name:"after",interface:"input",uiSchema:{title:t("After change"),"x-component":"AuditLogsValue"}}]}),M=()=>({name:"collections",title:t("Collections"),fields:[{name:"name",type:"string",interface:"input",uiSchema:{title:t("Collection name"),type:"string","x-component":"Input","x-component-props":{ellipsis:!0}}},{name:"title",type:"string",interface:"input",uiSchema:{title:t("Collection display name"),type:"string","x-component":"Input","x-component-props":{ellipsis:!0}}}]}),U=l=>{var n=l,{children:o}=n,r=q(n,["children"]);const s=K(),c=O(),u=M();return i.jsx(e.ExtendCollectionsProvider,{collections:[c,s,u],children:i.jsx(e.TableBlockProvider,x(m({name:"audit-logs"},r),{children:o}))})},W=p.observer(()=>{var l,n,s,c;const o=p.useField(),r=e.useCompile();return o.value?i.jsx(e.EllipsisWithTooltip,{ellipsis:!0,children:(n=(l=o.value)==null?void 0:l.uiSchema)!=null&&n.title?r((c=(s=o.value)==null?void 0:s.uiSchema)==null?void 0:c.title):o.value.name}):null},{displayName:"AuditLogsField"}),_=p.observer(()=>{var l,n;const o=p.useField(),r=e.useRecord();return(l=r.field)!=null&&l.uiSchema?i.jsx(e.FormProvider,{children:i.jsx(e.SchemaComponent,{schema:x(m({name:r.field.name},(n=r.field)==null?void 0:n.uiSchema),{default:o.value,"x-read-pretty":!0})})}):i.jsx(e.EllipsisWithTooltip,{ellipsis:!0,children:o.value?JSON.stringify(o.value):null})},{displayName:"AuditLogsValue"}),J=()=>{const o={type:"string","x-component":"AssociationField","x-decorator":"FormItem","x-collection-field":"auditLogs.changes","x-read-pretty":!0,"x-component-props":{multiple:!0,fieldNames:{value:"id",label:"id"},mode:"SubTable"},properties:{block:{type:"void","x-component":"AssociationField.SubTable",properties:{[v.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{field:{"x-collection-field":"auditChanges.field","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},[v.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{before:{"x-collection-field":"auditChanges.before","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},[v.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{after:{"x-collection-field":"auditChanges.after","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}}}}}},r={type:"void",title:t("View"),"x-action":"view","x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:view","x-component":"Action","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:t("View record"),"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},properties:{tab1:{type:"void",title:t("Details"),"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid",properties:{"7ypqrxaqysp":{type:"void","x-component":"Grid.Row",properties:{"1fc2l8dwe7m":{type:"void","x-component":"Grid.Col",properties:{"5ley6xifrsb":{type:"void","x-acl-action":"auditLogs:get","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"auditLogs",collection:"auditLogs",readPretty:!0,action:"get",params:{appends:["collection","user","changes"]},useParams:"{{ useParamsFromRecord }}",useSourceId:"{{ useSourceIdFromParentRecord }}"},"x-component":"CardItem",properties:{bv710pbf9w6:{type:"void","x-component":"FormV2","x-read-pretty":!0,"x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid",properties:{g4c24abnbd9:{type:"void","x-component":"Grid.Row",properties:{fkt9dj5lu1k:{type:"void","x-component":"Grid.Col",properties:{createdAt:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.createdAt","x-component-props":{},"x-read-pretty":!0}}}}},l267bkv423v:{type:"void","x-component":"Grid.Row",properties:{tehaepm5xqy:{type:"void","x-component":"Grid.Col",properties:{type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.type","x-component-props":{},"x-read-pretty":!0}}}}},zhmn2tkzdh2:{type:"void","x-component":"Grid.Row",properties:{yuwyej17i64:{type:"void","x-component":"Grid.Col",properties:{recordId:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.recordId","x-component-props":{}}}}}},"6q933ic06mj":{type:"void","x-component":"Grid.Row",properties:{nwtbkqd99zl2:{type:"void","x-component":"Grid.Col",properties:{"collection.title":{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.collection.title","x-component-props":{}}}},nwtbkqd99zl1:{type:"void","x-component":"Grid.Col",properties:{"collection.name":{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.collection.name","x-component-props":{}}}}}},xd4kzulndqk:{type:"void","x-component":"Grid.Row",properties:{k3sd72n83zd:{type:"void","x-component":"Grid.Col",properties:{user:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"auditLogs.user","x-component-props":{},"x-read-pretty":!0,properties:{viewer:{type:"void",title:t("View record"),"x-component":"RecordPicker.Viewer","x-component-props":{className:"tb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},"x-initializer":"popup:addTab",properties:{tab1:{type:"void",title:t("Details"),"x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:common:addBlock"}}}}}}}}}}}}},"3lghgclbtcg":{type:"void","x-component":"Grid.Row",properties:{"8l1v1auwlx0":{type:"void","x-component":"Grid.Col",properties:{changes:o}}}}}}}}}}}}}}}}}}}}}}}};return i.jsx(e.ActionInitializer,{schema:r})},R=()=>{var f,V,G,B;const{name:o,title:r}=e.useCollection_deprecated(),l=p.useField(),n=p.useFieldSchema(),{form:s}=e.useFormBlockContext(),{service:c}=e.useTableBlockContext(),{t:u}=C(),{dn:T}=e.useDesignable();return i.jsxs(e.GeneralSchemaDesigner,{title:r||o,children:[i.jsx(e.SchemaSettingsDataScope,{collectionName:o,defaultFilter:((V=(f=n==null?void 0:n["x-decorator-props"])==null?void 0:f.params)==null?void 0:V.filter)||{},form:s,onSubmit:({filter:A})=>{var I;const g=l.decoratorProps.params||{};g.filter=A,l.decoratorProps.params=g,n["x-decorator-props"].params=g,c.run(x(m({},(I=c.params)==null?void 0:I[0]),{filter:A,page:1})),T.emit("patch",{schema:{"x-uid":n["x-uid"],"x-decorator-props":n["x-decorator-props"]}})}}),i.jsx(e.SchemaSettingsSelectItem,{title:u("Records per page"),value:((B=(G=l.decoratorProps)==null?void 0:G.params)==null?void 0:B.pageSize)||20,options:[{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100},{label:"200",value:200}],onChange:A=>{var I;const g=l.decoratorProps.params||{};g.pageSize=A,l.decoratorProps.params=g,n["x-decorator-props"].params=g,c.run(x(m({},(I=c.params)==null?void 0:I[0]),{pageSize:A,page:1})),T.emit("patch",{schema:{"x-uid":n["x-uid"],"x-decorator-props":n["x-decorator-props"]}})}}),i.jsx(e.SchemaSettingsDivider,{}),i.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})},$={name:"auditLogs",title:t("Audit logs"),fields:[{name:"createdAt",type:"date",interface:"createdAt",uiSchema:{type:"datetime",title:t("Created at"),"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{name:"type",type:"string",interface:"select",uiSchema:{type:"string",title:t("Action type"),"x-component":"Select","x-read-pretty":!0,enum:[{label:t("Create record"),value:"create",color:"lime"},{label:t("Update record"),value:"update",color:"gold"},{label:t("Delete record"),value:"destroy",color:"magenta"}]}}]},H=p.observer(()=>{var r,l;const o=p.useField();return i.jsx("div",{children:((r=o==null?void 0:o.value)==null?void 0:r.nickname)||((l=o.value)==null?void 0:l.id)})},{displayName:"Username"}),Q=p.observer(()=>{const o=p.useField(),{title:r,name:l}=o.value||{},n=e.useCompile();return i.jsx("div",{children:r?n(r):l})},{displayName:"Collection"}),X=p.observer(()=>{var l,n,s,c;const o=p.useField(),r=e.useCompile();return o.value?i.jsx("div",{children:(n=(l=o.value)==null?void 0:l.uiSchema)!=null&&n.title?r((c=(s=o.value)==null?void 0:s.uiSchema)==null?void 0:c.title):o.value.name}):null},{displayName:"Field"}),Y=p.observer(()=>{var l,n;const o=p.useField(),r=y.ArrayTable.useRecord();return(l=r.field)!=null&&l.uiSchema?i.jsx(e.FormProvider,{children:i.jsx(e.SchemaComponent,{schema:x(m({name:r.field.name},(n=r.field)==null?void 0:n.uiSchema),{default:o.value,"x-read-pretty":!0})})}):i.jsx("div",{children:o.value?JSON.stringify(o.value):null})},{displayName:"Value"}),L=b.createContext(null);L.displayName="IsAssociationBlock";const w=()=>{const o=b.useContext(L),r={};return o||(r.column31={type:"void","x-component":"TableV2.Column",title:t("Record ID"),properties:{recordId:{"x-component":"Input","x-read-pretty":!0}}}),i.jsx(e.SchemaComponent,{memoized:!0,components:{ArrayTable:y.ArrayTable,Username:H,Collection:Q,Field:X,Value:Y},schema:{type:"void",name:"lfm4trkw8j3","x-component":"div",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:t("Filter"),"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined",useProps:"{{ useFilterActionProps }}"},"x-align":"left"}}},y84dlntcaup:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useProps:"{{ useTableBlockProps }}"},properties:x(m({actions:{type:"void",title:t("Actions"),"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-designer":"TableV2.ActionColumnDesigner","x-initializer":"table:configureItemActions",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{o80rypwmeeg:{type:"void",title:t("View"),"x-toolbar":"ActionSchemaToolbar","x-settings":"actionSettings:view","x-component":"Action.Link","x-component-props":{openMode:"drawer"},properties:{drawer:{type:"void",title:t("View record"),"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{grid:{type:"void","x-component":"Grid",properties:{tdlav8o9o17:{type:"void","x-component":"Grid.Row",properties:{"7bsnaf47i6g":{type:"void","x-component":"Grid.Col",properties:{"6s2qbihe3tu":{type:"void","x-acl-action":"auditLogs:get","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"auditLogs",collection:"auditLogs",readPretty:!0,action:"get",params:{appends:["collection","user","changes"]},useParams:"{{ useParamsFromRecord }}",useSourceId:"{{ useSourceIdFromParentRecord }}"},"x-component":"CardItem",properties:{mevpuonrda0:{type:"void","x-component":"FormV2","x-read-pretty":!0,"x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:{type:"void","x-component":"Grid",properties:{row1:{type:"void","x-component":"Grid.Row",properties:{col11:{type:"void","x-component":"Grid.Col",properties:{collection:{type:"string",title:t("Collection display name"),"x-component":"Collection","x-decorator":"FormItem","x-read-pretty":!0}}}}},row2:{type:"void","x-component":"Grid.Row",properties:{col21:{type:"void","x-component":"Grid.Col",properties:{type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0}}}}},row3:{type:"void","x-component":"Grid.Row",properties:{col31:{type:"void","x-component":"Grid.Col",properties:{createdAt:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0}}}}},row4:{type:"void","x-component":"Grid.Row",properties:{col41:{type:"void","x-component":"Grid.Col",properties:{user:{type:"string",title:t("User"),"x-component":"Username","x-decorator":"FormItem","x-read-pretty":!0}}}}},row5:{type:"void","x-component":"Grid.Row",properties:{col51:{type:"void","x-component":"Grid.Col",properties:{changes:{type:"array",title:t("Field value changes"),"x-decorator":"FormItem","x-component":"ArrayTable","x-component-props":{pagination:{pageSize:10},scroll:{x:"100%"}},items:{type:"object",properties:{column3:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:200,title:t("Field")},properties:{field:{type:"string","x-component":"Field"}}},column4:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:200,title:t("Before change")},properties:{before:{type:"string","x-decorator":"FormItem","x-component":"Value"}}},column5:{type:"void","x-component":"ArrayTable.Column","x-component-props":{width:200,title:t("After change")},properties:{after:{type:"string","x-decorator":"FormItem","x-component":"Value"}}}}}}}}}}}}}}}}}}}}}}}}}}}}}},column1:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{createdAt:{"x-component":"CollectionField","x-read-pretty":!0}}},column2:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{type:{"x-component":"CollectionField","x-read-pretty":!0}}},column3:{type:"void","x-component":"TableV2.Column",title:t("Collection display name"),properties:{collection:{"x-component":"Collection","x-read-pretty":!0}}}},r),{column4:{type:"void","x-component":"TableV2.Column",title:t("User"),properties:{user:{"x-component":"Username","x-read-pretty":!0}}}})}}}})};w.Decorator=p.observer(o=>{var c;const r=e.useCollection_deprecated(),l=e.useRecord();let n=(c=o==null?void 0:o.params)==null?void 0:c.filter;if(r.name){const u=l==null?void 0:l[r.filterTargetKey||"id"];n?n={$and:[n,{collectionName:r.name,recordId:`${u}`}]}:n={collectionName:r.name,recordId:`${u}`}}const s={collection:"auditLogs",resource:"auditLogs",action:"list",params:x(m({pageSize:20,appends:["collection","user"]},o.params),{filter:n,sort:"-createdAt"}),rowKey:"id",showIndex:!0,dragSort:!1};return i.jsx(L.Provider,{value:!!r.name,children:i.jsx(e.ExtendCollectionsProvider,{collections:[$],children:i.jsx(e.TableBlockProvider,x(m({},s),{children:o.children}))})})},{displayName:"AuditLogs.Decorator"}),w.Designer=R;const Z=()=>{const o={type:"void",title:t("Actions"),"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-designer":"TableV2.ActionColumnDesigner","x-initializer":"auditLogsTable:configureItemActions","x-action-column":"actions",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{}}}},r=e.useSchemaInitializerItem();return i.jsx(e.InitializerWithSwitch,x(m({},r),{schema:o,item:r,type:"x-action-column"}))},z=o=>i.jsx(e.SchemaComponentOptions,{components:{AuditLogs:w,AuditLogsBlockProvider:U,AuditLogsBlockInitializer:P,AuditLogsValue:_,AuditLogsField:W,AuditLogsViewActionInitializer:J,AuditLogsTableActionColumnInitializer:Z},children:o.children}),ee=new e.SchemaInitializer({name:"auditLogsTable:configureItemActions",insertPosition:"beforeEnd",Component:o=>i.jsx(d.MenuOutlined,x(m({},o),{style:{cursor:"pointer"}})),useInsert(){const o=p.useFieldSchema(),r=e.useAPIClient(),{refresh:l}=e.useDesignable(),{t:n}=C();return s=>{const c=o.reduceProperties((T,f)=>f["x-component"]==="Space"?f:T,null);if(!c)return;const u=e.createDesignable({t:n,api:r,refresh:l,current:c});u.loadAPIClientEvents(),u.insertBeforeEnd(s)}},items:[{name:"enableActions",type:"itemGroup",title:t("Enable actions"),children:[{name:"view",type:"item",title:t("View"),Component:"AuditLogsViewActionInitializer",schema:{"x-component":"Action.Link","x-action":"view","x-decorator":"ACLActionProvider"}}]},{name:"divider",type:"divider"},{name:"columnWidth",type:"item",title:t("Column width"),Component:e.Resizable}]}),oe=new e.SchemaInitializer({name:"auditLogsTable:configureActions",title:t("Configure actions"),icon:"SettingOutlined",style:{marginLeft:8},items:[{type:"itemGroup",title:t("Enable actions"),name:"enableActions",children:[{name:"filter",title:t("Filter"),Component:"FilterActionInitializer",schema:{"x-align":"left"}},{name:"refresh",title:t("Refresh"),Component:"RefreshActionInitializer",schema:{"x-align":"right"}}]}]}),te=()=>{const o=e.useInheritsTableColumnInitializerFields(),{t:r}=C(),l=e.useCompile();if(!(o!=null&&o.length))return null;const n=[];return o.forEach(s=>{Object.values(s)[0].length&&n.push({type:"itemGroup",divider:!0,title:r("Parent collection fields")+"("+l(`${Object.keys(s)[0]}`)+")",children:Object.values(s)[0].filter(c=>{var u;return!((u=c==null?void 0:c.field)!=null&&u.isForeignKey)})})}),i.jsx(e.SchemaInitializerChildren,{children:n})},ie=()=>{const o=e.useAssociatedTableColumnInitializerFields(),{t:r}=C();if(!(o!=null&&o.length))return null;const l=[{type:"itemGroup",divider:!0,title:r("Display association fields"),children:o}];return i.jsx(e.SchemaInitializerChildren,{children:l})},re=new e.SchemaInitializer({name:"auditLogsTable:configureColumns",insertPosition:"beforeEnd",icon:"SettingOutlined",title:t("Configure columns"),wrap(o){return o["x-action-column"]?o:{type:"void","x-toolbar":"TableColumnSchemaToolbar","x-settings":"fieldSettings:TableColumn","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{[o.name]:m({},o)}}},items:[{name:"displayFields",type:"itemGroup",title:t("Display fields"),useChildren:e.useTableColumnInitializerFields},{name:"parentCollectionFields",Component:te},{name:"associationFields",Component:ie},{name:"actionColumn",title:t("Action column"),Component:"AuditLogsTableActionColumnInitializer"}]});class k extends e.Plugin{load(){return E(this,null,function*(){this.app.use(z),this.app.schemaInitializerManager.add(oe),this.app.schemaInitializerManager.add(ee),this.app.schemaInitializerManager.add(re);const r=this.app.schemaInitializerManager.get("page:addBlock"),l=this.app.schemaInitializerManager.get("popup:common:addBlock"),n={title:t("Audit logs"),Component:"AuditLogsBlockInitializer"};r.add("otherBlocks.auditLogs",n),l.add("otherBlocks.auditLogs",n)})}}a.AuditLogsBlockInitializer=P,a.AuditLogsPlugin=k,a.AuditLogsProvider=z,a.default=k,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,4 +1,3 @@
1
- import { OpenMode } from '@tachybase/client';
2
1
  export declare const createSchema: () => {
3
2
  type: string;
4
3
  name: string;
@@ -188,7 +187,7 @@ export declare const createSchema: () => {
188
187
  'x-action': string;
189
188
  'x-component': string;
190
189
  'x-component-props': {
191
- openMode: OpenMode;
190
+ openMode: string;
192
191
  };
193
192
  properties: {
194
193
  drawer: {
@@ -1,11 +1,11 @@
1
1
  module.exports = {
2
2
  "react": "18.3.1",
3
- "@tachybase/client": "1.3.18",
4
- "@tachybase/schema": "1.3.18",
3
+ "@tachybase/client": "1.3.20",
4
+ "@tachybase/schema": "1.3.20",
5
5
  "@ant-design/icons": "5.3.7",
6
- "@tachybase/database": "1.3.18",
7
- "@tachybase/server": "1.3.18",
8
- "@tachybase/utils": "1.3.18",
9
- "@tachybase/components": "1.3.18",
6
+ "@tachybase/database": "1.3.20",
7
+ "@tachybase/server": "1.3.20",
8
+ "@tachybase/utils": "1.3.20",
9
+ "@tachybase/components": "1.3.20",
10
10
  "react-i18next": "15.2.0"
11
11
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/plugin-audit-logs",
3
3
  "displayName": "Audit logs",
4
- "version": "1.3.18",
4
+ "version": "1.3.20",
5
5
  "description": "Audit logs.",
6
6
  "keywords": [
7
7
  "System management"
@@ -13,15 +13,15 @@
13
13
  "antd": "5.22.5",
14
14
  "react": "^18.3.1",
15
15
  "react-i18next": "^15.2.0",
16
- "@tachybase/components": "1.3.18"
16
+ "@tachybase/components": "1.3.20"
17
17
  },
18
18
  "peerDependencies": {
19
- "@tachybase/client": "1.3.18",
20
- "@tachybase/database": "1.3.18",
21
- "@tachybase/schema": "1.3.18",
22
- "@tachybase/server": "1.3.18",
23
- "@tachybase/utils": "1.3.18",
24
- "@tachybase/test": "1.3.18"
19
+ "@tachybase/client": "1.3.20",
20
+ "@tachybase/database": "1.3.20",
21
+ "@tachybase/schema": "1.3.20",
22
+ "@tachybase/server": "1.3.20",
23
+ "@tachybase/test": "1.3.20",
24
+ "@tachybase/utils": "1.3.20"
25
25
  },
26
26
  "description.zh-CN": "审计日志。",
27
27
  "displayName.zh-CN": "审计日志",