@tachybase/plugin-api-logs 1.3.17 → 1.3.18
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/client/index.js +1 -1
- package/dist/externalVersion.js +10 -10
- package/package.json +12 -12
package/dist/client/index.js
CHANGED
|
@@ -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"),require("antd")):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","antd"],e):(a=typeof globalThis!="undefined"?globalThis:a||self,e(a["@tachybase/plugin-api-logs"]={},a["@tachybase/client"],a.jsxRuntime,a["@ant-design/icons"],a["react-i18next"],a["@tachybase/schema"],a["@tachybase/utils"],a.react,a["@tachybase/components"],a.antd))})(this,function(a,e,r,m,S,l,h,f,y,v){"use strict";var xe=Object.defineProperty,ye=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var G=(a,e,r)=>e in a?xe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r,u=(a,e)=>{for(var r in e||(e={}))N.call(e,r)&&G(a,r,e[r]);if(w)for(var r of w(e))q.call(e,r)&&G(a,r,e[r]);return a},x=(a,e)=>ye(a,ge(e));var E=(a,e)=>{var r={};for(var m in a)N.call(a,m)&&e.indexOf(m)<0&&(r[m]=a[m]);if(a!=null&&w)for(var m of w(a))e.indexOf(m)<0&&q.call(a,m)&&(r[m]=a[m]);return r};var F=(a,e,r)=>new Promise((m,S)=>{var l=y=>{try{f(r.next(y))}catch(v){S(v)}},h=y=>{try{f(r.throw(y))}catch(v){S(v)}},f=y=>y.done?m(y.value):Promise.resolve(y.value).then(l,h);f((r=r.apply(a,e)).next())});const P="@tachybase/plugin-api-logs";function O(o){return e.i18n.t(o,{ns:P})}function A(){return S.useTranslation(P)}const t=o=>e.tval(o,{ns:P}),j=()=>{const{insert:o}=e.useSchemaInitializer(),{t:n}=A(),p=e.useSchemaInitializerItem(),i=e.createTableBlockSchema({collection:"apiLogs",rowKey:"id",tableActionInitializers:"apiLogsTable:configureActions",tableColumnInitializers:"apiLogsTable:configureColumns",tableActionColumnInitializers:"apiLogsTable:configureItemActions",tableBlockProvider:"ApiLogsBlockProvider",disableTemplate:!0});return r.jsx(e.SchemaInitializerItem,u({icon:r.jsx(m.TableOutlined,{}),onClick:()=>{o(i)},title:n("Api Logs")},p))},R=()=>({name:"apiLogs",title:t("Api 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:"action",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:"apiLogs",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:"apiLogs",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:"apiLogs",type:"hasMany",interface:"subTable",target:"apiChanges",foreignKey:"apiLogId",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:"apiChanges",title:t("Api Changes"),fields:[{name:"field",type:"json",interface:"input",uiSchema:{title:t("Field"),"x-component":"ApiLogsField"}},{type:"json",name:"before",interface:"input",uiSchema:{title:t("Before change"),"x-component":"ApiLogsValue"}},{type:"json",name:"after",interface:"input",uiSchema:{title:t("After change"),"x-component":"ApiLogsValue"}}]}),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=p=>{var i=p,{children:o}=i,n=E(i,["children"]);const s=K(),c=R(),d=M();return r.jsx(e.ExtendCollectionsProvider,{collections:[c,s,d],children:r.jsx(e.TableBlockProvider,x(u({name:"api-logs"},n),{children:o}))})},W=l.observer(()=>{var p,i,s,c;const o=l.useField(),n=e.useCompile();return o.value?r.jsx(e.EllipsisWithTooltip,{ellipsis:!0,children:(i=(p=o.value)==null?void 0:p.uiSchema)!=null&&i.title?n((c=(s=o.value)==null?void 0:s.uiSchema)==null?void 0:c.title):o.value.name}):null},{displayName:"ApiLogsField"}),_=l.observer(()=>{var p,i;const o=l.useField(),n=e.useCollectionRecordData();return(p=n.field)!=null&&p.uiSchema&&n.field.uiSchema["x-component"]!=="AssociationField"?r.jsx(e.FormProvider,{children:r.jsx(e.SchemaComponent,{schema:x(u({name:n.field.name},(i=n.field)==null?void 0:i.uiSchema),{default:o.value,"x-read-pretty":!0})})}):r.jsx(e.EllipsisWithTooltip,{ellipsis:!0,children:o.value?JSON.stringify(o.value):null})},{displayName:"ApiLogsValue"}),$=()=>{const o={type:"string","x-component":"AssociationField","x-decorator":"FormItem","x-collection-field":"apiLogs.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:{[h.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{field:{"x-collection-field":"apiChanges.field","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},[h.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{before:{"x-collection-field":"apiChanges.before","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},[h.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{after:{"x-collection-field":"apiChanges.after","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}}}}}},n={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":"apiLogs:get","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"apiLogs",collection:"apiLogs",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":"apiLogs.createdAt","x-component-props":{},"x-read-pretty":!0}}}}},l267bkv423v:{type:"void","x-component":"Grid.Row",properties:{tehaepm5xqy:{type:"void","x-component":"Grid.Col",properties:{action:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"apiLogs.action","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":"apiLogs.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":"apiLogs.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":"apiLogs.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":"apiLogs.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 r.jsx(e.ActionInitializer,{schema:n})},J=()=>{var C,D,V,z;const{name:o,title:n}=e.useCollection_deprecated(),p=l.useField(),i=l.useFieldSchema(),{form:s}=e.useFormBlockContext(),{service:c}=e.useTableBlockContext(),{t:d}=A(),{dn:g}=e.useDesignable();return r.jsxs(e.GeneralSchemaDesigner,{title:n||o,children:[r.jsx(e.SchemaSettingsDataScope,{collectionName:o,defaultFilter:((D=(C=i==null?void 0:i["x-decorator-props"])==null?void 0:C.params)==null?void 0:D.filter)||{},form:s,onSubmit:({filter:I})=>{var T;const b=p.decoratorProps.params||{};b.filter=I,p.decoratorProps.params=b,i["x-decorator-props"].params=b,c.run(x(u({},(T=c.params)==null?void 0:T[0]),{filter:I,page:1})),g.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}})}}),r.jsx(e.SchemaSettingsSelectItem,{title:d("Records per page"),value:((z=(V=p.decoratorProps)==null?void 0:V.params)==null?void 0:z.pageSize)||20,options:[{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100},{label:"200",value:200}],onChange:I=>{var T;const b=p.decoratorProps.params||{};b.pageSize=I,p.decoratorProps.params=b,i["x-decorator-props"].params=b,c.run(x(u({},(T=c.params)==null?void 0:T[0]),{pageSize:I,page:1})),g.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}})}}),r.jsx(e.SchemaSettingsDivider,{}),r.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})},H={name:"apiLogs",title:t("Api 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:"action",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"}]}}]},Q=l.observer(()=>{var n,p;const o=l.useField();return r.jsx("div",{children:((n=o==null?void 0:o.value)==null?void 0:n.nickname)||((p=o.value)==null?void 0:p.id)})},{displayName:"Username"}),X=l.observer(()=>{const o=l.useField(),{title:n,name:p}=o.value||{},i=e.useCompile();return r.jsx("div",{children:n?i(n):p})},{displayName:"Collection"}),Y=l.observer(()=>{var p,i,s,c;const o=l.useField(),n=e.useCompile();return o.value?r.jsx("div",{children:(i=(p=o.value)==null?void 0:p.uiSchema)!=null&&i.title?n((c=(s=o.value)==null?void 0:s.uiSchema)==null?void 0:c.title):o.value.name}):null},{displayName:"Field"}),Z=l.observer(()=>{var p,i;const o=l.useField(),n=y.ArrayTable.useRecord();return(p=n.field)!=null&&p.uiSchema?r.jsx(e.FormProvider,{children:r.jsx(e.SchemaComponent,{schema:x(u({name:n.field.name},(i=n.field)==null?void 0:i.uiSchema),{default:o.value,"x-read-pretty":!0})})}):r.jsx("div",{children:o.value?JSON.stringify(o.value):null})},{displayName:"Value"}),k=f.createContext(null);k.displayName="IsAssociationBlock";const B=()=>{const o=f.useContext(k),n={};return o||(n.column31={type:"void","x-component":"TableV2.Column",title:t("Record ID"),properties:{recordId:{"x-component":"Input","x-read-pretty":!0}}}),r.jsx(e.SchemaComponent,{memoized:!0,components:{ArrayTable:y.ArrayTable,Username:Q,Collection:X,Field:Y,Value:Z},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(u({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":"apiLogs:get","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"apiLogs",collection:"apiLogs",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:{action:{"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}}}},n),{column4:{type:"void","x-component":"TableV2.Column",title:t("User"),properties:{user:{"x-component":"Username","x-read-pretty":!0}}}})}}}})};B.Decorator=l.observer(o=>{var c;const n=e.useCollection_deprecated(),p=e.useRecord();let i=(c=o==null?void 0:o.params)==null?void 0:c.filter;if(n.name){const d=p==null?void 0:p[n.filterTargetKey||"id"];i?i={$and:[i,{collectionName:n.name,recordId:`${d}`}]}:i={collectionName:n.name,recordId:`${d}`}}const s={collection:"apiLogs",resource:"apiLogs",action:"list",params:x(u({pageSize:20,appends:["collection","user"]},o.params),{filter:i,sort:"-createdAt"}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(k.Provider,{value:!!n.name,children:r.jsx(e.ExtendCollectionsProvider,{collections:[H],children:r.jsx(e.TableBlockProvider,x(u({},s),{children:o.children}))})})},{displayName:"ApiLogs.Decorator"}),B.Designer=J;const ee=()=>{const o={type:"void",title:t("Actions"),"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-designer":"TableV2.ActionColumnDesigner","x-initializer":"apiLogsTable:configureItemActions","x-action-column":"actions",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{}}}},n=e.useSchemaInitializerItem();return r.jsx(e.InitializerWithSwitch,x(u({},n),{schema:o,item:n,type:"x-action-column"}))},oe=o=>r.jsx(e.SchemaComponentOptions,{components:{ApiLogs:B,ApiLogsBlockProvider:U,ApiLogsBlockInitializer:j,ApiLogsValue:_,ApiLogsField:W,ApiLogsViewActionInitializer:$,ApiLogsTableActionColumnInitializer:ee},children:o.children}),te=()=>{const{t:o}=e.useTranslation(),{field:n}=e.useBlockRequestContext(),p=e.useDataBlockResource(),{refresh:i}=e.useDataBlockRequest();return{onClick(){return F(this,null,function*(){var c,d,g;if(!((d=(c=n==null?void 0:n.data)==null?void 0:c.selectedRowKeys)!=null&&d.length))return v.message.error(o("Please select the records you want to enable"));try{yield p.update({filterByTk:(g=n.data)==null?void 0:g.selectedRowKeys,values:{apiConfig:!0}}),i==null||i()}catch(C){console.error("Error enabling API logs config:",C)}})}}},ne=()=>{const{t:o}=e.useTranslation(),{field:n}=e.useBlockRequestContext(),p=e.useDataBlockResource(),{refresh:i}=e.useDataBlockRequest();return{onClick(){return F(this,null,function*(){var c,d,g;if(!((d=(c=n==null?void 0:n.data)==null?void 0:c.selectedRowKeys)!=null&&d.length))return v.message.error(o("Please select the records you want to disable"));try{yield p.update({filterByTk:(g=n.data)==null?void 0:g.selectedRowKeys,values:{apiConfig:!1}}),i==null||i()}catch(C){console.error("Error disenabling API logs config:",C)}})}}},re=()=>{const{field:o}=e.useBlockRequestContext(),n=e.useDataBlockResource(),{refresh:p}=e.useDataBlockRequest();return{onClick(){return F(this,null,function*(){try{yield n.tablesync({name:"tablesync"}),p==null||p()}catch(s){console.error("Error sync API logs config:",s)}})}}},L={name:"apiLogsConfig",fields:[{interface:"input",type:"string",name:"resourceName",uiSchema:{type:"string",title:t("Resource name"),"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"input",type:"string",name:"action",uiSchema:{type:"string",title:`{{t("Action", { ns: "${P}" })}}`,"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"boolean",type:"boolean",name:"apiConfig",uiSchema:{type:"boolean",title:t("Api audit"),"x-component":"Checkbox"}}]},ie={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":`${L.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:L},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},title:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},resourceName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem",required:!0},action:{type:"string","x-component":"CollectionField","x-decorator":"FormItem",required:!0},apiConfig:{type:"boolean",default:!0,"x-component":"CollectionField","x-decorator":"FormItem"}}}}}}}}},pe={type:"void",properties:{apiLogsConfig:{type:"void","x-component":"CardItem","x-decorator":"TableBlockProvider","x-decorator-props":{collection:L,action:"list",params:{filter:{}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action","x-decorator":"ACLActionProvider","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},enable:{type:"void",title:'{{ t("Enable") }}',"x-action":"update","x-decorator":"ACLActionProvider","x-use-component-props":"useApiLogsConfigEnableProps","x-component":"Action","x-component-props":{icon:"EditOutlined"}},disenable:{type:"void",title:t("Disable"),"x-action":"update","x-decorator":"ACLActionProvider","x-use-component-props":"useApiLogsConfigDisenableProps","x-component":"Action","x-component-props":{icon:"EditOutlined"}},sync:{type:"void",title:t("Table sync"),"x-use-component-props":"useApiLogsConfigSyncProps","x-component":"Action","x-component-props":{icon:"VerticalAlignBottomOutlined"}},create:ie}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{align:"center"},properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},resourceName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{align:"center"},properties:{resourceName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},action:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{align:"center"},properties:{action:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},apiConfig:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{align:"center"},properties:{apiConfig:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}},ae=()=>r.jsx(e.ExtendCollectionsProvider,{collections:[L],children:r.jsx(e.SchemaComponent,{schema:pe,scope:{useApiLogsConfigEnableProps:te,useApiLogsConfigDisenableProps:ne,useApiLogsConfigSyncProps:re}})}),ce=new e.SchemaInitializer({name:"apiLogsTable:configureItemActions",insertPosition:"beforeEnd",Component:o=>r.jsx(m.MenuOutlined,x(u({},o),{style:{cursor:"pointer"}})),useInsert(){const o=l.useFieldSchema(),n=e.useAPIClient(),{refresh:p}=e.useDesignable(),{t:i}=A();return s=>{const c=o.reduceProperties((g,C)=>C["x-component"]==="Space"?C:g,null);if(!c)return;const d=e.createDesignable({t:i,api:n,refresh:p,current:c});d.loadAPIClientEvents(),d.insertBeforeEnd(s)}},items:[{name:"enableActions",type:"itemGroup",title:t("Enable actions"),children:[{name:"view",type:"item",title:t("View"),Component:"ApiLogsViewActionInitializer",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}]}),se=new e.SchemaInitializer({name:"apiLogsTable: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"}}]}]}),le=()=>{const o=e.useInheritsTableColumnInitializerFields(),{t:n}=A(),p=e.useCompile();if(!(o!=null&&o.length))return null;const i=[];return o.forEach(s=>{Object.values(s)[0].length&&i.push({type:"itemGroup",divider:!0,title:n("Parent collection fields")+"("+p(`${Object.keys(s)[0]}`)+")",children:Object.values(s)[0].filter(c=>{var d;return!((d=c==null?void 0:c.field)!=null&&d.isForeignKey)})})}),r.jsx(e.SchemaInitializerChildren,{children:i})},de=()=>{const o=e.useAssociatedTableColumnInitializerFields(),{t:n}=A();if(!(o!=null&&o.length))return null;const p=[{type:"itemGroup",divider:!0,title:n("Display association fields"),children:o}];return r.jsx(e.SchemaInitializerChildren,{children:p})},me=new e.SchemaInitializer({name:"apiLogsTable: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]:u({},o)}}},items:[{name:"displayFields",type:"itemGroup",title:t("Display fields"),useChildren:e.useTableColumnInitializerFields},{name:"parentCollectionFields",Component:le},{name:"associationFields",Component:de},{name:"actionColumn",title:t("Action column"),Component:"ApiLogsTableActionColumnInitializer"}]});class ue extends e.Plugin{load(){return F(this,null,function*(){this.app.use(oe),this.app.schemaInitializerManager.add(se),this.app.schemaInitializerManager.add(ce),this.app.schemaInitializerManager.add(me);const n=this.app.schemaInitializerManager.get("page:addBlock"),p=this.app.schemaInitializerManager.get("popup:common:addBlock"),i={title:t("Api logs"),Component:"ApiLogsBlockInitializer"};n.add("otherBlocks.apiLogs",i),p.add("otherBlocks.apiLogs",i),this.app.systemSettingsManager.add("system-services.apilogs-config",{icon:"SettingOutlined",title:O("Api logs configuration"),aclSnippet:"pm.system-services.apiLogsConfig",Component:ae})})}}a.default=ue,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"),require("antd")):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","antd"],e):(a=typeof globalThis!="undefined"?globalThis:a||self,e(a["@tachybase/plugin-api-logs"]={},a["@tachybase/client"],a.jsxRuntime,a["@ant-design/icons"],a["react-i18next"],a["@tachybase/schema"],a["@tachybase/utils"],a.react,a["@tachybase/components"],a.antd))})(this,function(a,e,r,m,S,l,h,f,y,v){"use strict";var xe=Object.defineProperty,ye=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var k=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var G=(a,e,r)=>e in a?xe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r,u=(a,e)=>{for(var r in e||(e={}))N.call(e,r)&&G(a,r,e[r]);if(k)for(var r of k(e))E.call(e,r)&&G(a,r,e[r]);return a},x=(a,e)=>ye(a,ge(e));var O=(a,e)=>{var r={};for(var m in a)N.call(a,m)&&e.indexOf(m)<0&&(r[m]=a[m]);if(a!=null&&k)for(var m of k(a))e.indexOf(m)<0&&E.call(a,m)&&(r[m]=a[m]);return r};var F=(a,e,r)=>new Promise((m,S)=>{var l=y=>{try{f(r.next(y))}catch(v){S(v)}},h=y=>{try{f(r.throw(y))}catch(v){S(v)}},f=y=>y.done?m(y.value):Promise.resolve(y.value).then(l,h);f((r=r.apply(a,e)).next())});const P="@tachybase/plugin-api-logs";function q(o){return e.i18n.t(o,{ns:P})}function A(){return S.useTranslation(P)}const t=o=>e.tval(o,{ns:P}),R=()=>{const{insert:o}=e.useSchemaInitializer(),{t:n}=A(),p=e.useSchemaInitializerItem(),i=e.createTableBlockSchema({collection:"apiLogs",rowKey:"id",tableActionInitializers:"apiLogsTable:configureActions",tableColumnInitializers:"apiLogsTable:configureColumns",tableActionColumnInitializers:"apiLogsTable:configureItemActions",tableBlockProvider:"ApiLogsBlockProvider",disableTemplate:!0});return r.jsx(e.SchemaInitializerItem,u({icon:r.jsx(m.TableOutlined,{}),onClick:()=>{o(i)},title:n("Api Logs")},p))},M=()=>({name:"apiLogs",title:t("Api 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:"action",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:"apiLogs",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:"apiLogs",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:"apiLogs",type:"hasMany",interface:"subTable",target:"apiChanges",foreignKey:"apiLogId",targetKey:"id",uiSchema:{type:"object",title:t("Details of changes")}},{type:"bigInt",name:"id",interface:"number",uiSchema:{type:"number",title:"ID","x-component":"InputNumber"}}]}),j=()=>({name:"apiChanges",title:t("Api Changes"),fields:[{name:"field",type:"json",interface:"input",uiSchema:{title:t("Field"),"x-component":"ApiLogsField"}},{type:"json",name:"before",interface:"input",uiSchema:{title:t("Before change"),"x-component":"ApiLogsValue"}},{type:"json",name:"after",interface:"input",uiSchema:{title:t("After change"),"x-component":"ApiLogsValue"}}]}),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=p=>{var i=p,{children:o}=i,n=O(i,["children"]);const s=j(),c=M(),d=K();return r.jsx(e.ExtendCollectionsProvider,{collections:[c,s,d],children:r.jsx(e.TableBlockProvider,x(u({name:"api-logs"},n),{children:o}))})},W=l.observer(()=>{var p,i,s,c;const o=l.useField(),n=e.useCompile();return o.value?r.jsx(e.EllipsisWithTooltip,{ellipsis:!0,children:(i=(p=o.value)==null?void 0:p.uiSchema)!=null&&i.title?n((c=(s=o.value)==null?void 0:s.uiSchema)==null?void 0:c.title):o.value.name}):null},{displayName:"ApiLogsField"}),_=l.observer(()=>{var p,i;const o=l.useField(),n=e.useCollectionRecordData();return(p=n.field)!=null&&p.uiSchema&&n.field.uiSchema["x-component"]!=="AssociationField"?r.jsx(e.FormProvider,{children:r.jsx(e.SchemaComponent,{schema:x(u({name:n.field.name},(i=n.field)==null?void 0:i.uiSchema),{default:o.value,"x-read-pretty":!0})})}):r.jsx(e.EllipsisWithTooltip,{ellipsis:!0,children:o.value?JSON.stringify(o.value):null})},{displayName:"ApiLogsValue"}),$=()=>{const o={type:"string","x-component":"AssociationField","x-decorator":"FormItem","x-collection-field":"apiLogs.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:{[h.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{field:{"x-collection-field":"apiChanges.field","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},[h.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{before:{"x-collection-field":"apiChanges.before","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},[h.uid()]:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{after:{"x-collection-field":"apiChanges.after","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}}}}}},n={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":"apiLogs:get","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"apiLogs",collection:"apiLogs",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":"apiLogs.createdAt","x-component-props":{},"x-read-pretty":!0}}}}},l267bkv423v:{type:"void","x-component":"Grid.Row",properties:{tehaepm5xqy:{type:"void","x-component":"Grid.Col",properties:{action:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"apiLogs.action","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":"apiLogs.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":"apiLogs.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":"apiLogs.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":"apiLogs.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 r.jsx(e.ActionInitializer,{schema:n})},J=()=>{var C,B,V,z;const{name:o,title:n}=e.useCollection_deprecated(),p=l.useField(),i=l.useFieldSchema(),{form:s}=e.useFormBlockContext(),{service:c}=e.useTableBlockContext(),{t:d}=A(),{dn:g}=e.useDesignable();return r.jsxs(e.GeneralSchemaDesigner,{title:n||o,children:[r.jsx(e.SchemaSettingsDataScope,{collectionName:o,defaultFilter:((B=(C=i==null?void 0:i["x-decorator-props"])==null?void 0:C.params)==null?void 0:B.filter)||{},form:s,onSubmit:({filter:I})=>{var T;const b=p.decoratorProps.params||{};b.filter=I,p.decoratorProps.params=b,i["x-decorator-props"].params=b,c.run(x(u({},(T=c.params)==null?void 0:T[0]),{filter:I,page:1})),g.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}})}}),r.jsx(e.SchemaSettingsSelectItem,{title:d("Records per page"),value:((z=(V=p.decoratorProps)==null?void 0:V.params)==null?void 0:z.pageSize)||20,options:[{label:"10",value:10},{label:"20",value:20},{label:"50",value:50},{label:"100",value:100},{label:"200",value:200}],onChange:I=>{var T;const b=p.decoratorProps.params||{};b.pageSize=I,p.decoratorProps.params=b,i["x-decorator-props"].params=b,c.run(x(u({},(T=c.params)==null?void 0:T[0]),{pageSize:I,page:1})),g.emit("patch",{schema:{"x-uid":i["x-uid"],"x-decorator-props":i["x-decorator-props"]}})}}),r.jsx(e.SchemaSettingsDivider,{}),r.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})},H={name:"apiLogs",title:t("Api 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:"action",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"}]}}]},Q=l.observer(()=>{var n,p;const o=l.useField();return r.jsx("div",{children:((n=o==null?void 0:o.value)==null?void 0:n.nickname)||((p=o.value)==null?void 0:p.id)})},{displayName:"Username"}),X=l.observer(()=>{const o=l.useField(),{title:n,name:p}=o.value||{},i=e.useCompile();return r.jsx("div",{children:n?i(n):p})},{displayName:"Collection"}),Y=l.observer(()=>{var p,i,s,c;const o=l.useField(),n=e.useCompile();return o.value?r.jsx("div",{children:(i=(p=o.value)==null?void 0:p.uiSchema)!=null&&i.title?n((c=(s=o.value)==null?void 0:s.uiSchema)==null?void 0:c.title):o.value.name}):null},{displayName:"Field"}),Z=l.observer(()=>{var p,i;const o=l.useField(),n=y.ArrayTable.useRecord();return(p=n.field)!=null&&p.uiSchema?r.jsx(e.FormProvider,{children:r.jsx(e.SchemaComponent,{schema:x(u({name:n.field.name},(i=n.field)==null?void 0:i.uiSchema),{default:o.value,"x-read-pretty":!0})})}):r.jsx("div",{children:o.value?JSON.stringify(o.value):null})},{displayName:"Value"}),w=f.createContext(null);w.displayName="IsAssociationBlock";const D=()=>{const o=f.useContext(w),n={};return o||(n.column31={type:"void","x-component":"TableV2.Column",title:t("Record ID"),properties:{recordId:{"x-component":"Input","x-read-pretty":!0}}}),r.jsx(e.SchemaComponent,{memoized:!0,components:{ArrayTable:y.ArrayTable,Username:Q,Collection:X,Field:Y,Value:Z},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(u({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":"apiLogs:get","x-decorator":"FormBlockProvider","x-decorator-props":{resource:"apiLogs",collection:"apiLogs",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:{action:{"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}}}},n),{column4:{type:"void","x-component":"TableV2.Column",title:t("User"),properties:{user:{"x-component":"Username","x-read-pretty":!0}}}})}}}})};D.Decorator=l.observer(o=>{var c;const n=e.useCollection_deprecated(),p=e.useRecord();let i=(c=o==null?void 0:o.params)==null?void 0:c.filter;if(n.name){const d=p==null?void 0:p[n.filterTargetKey||"id"];i?i={$and:[i,{collectionName:n.name,recordId:`${d}`}]}:i={collectionName:n.name,recordId:`${d}`}}const s={collection:"apiLogs",resource:"apiLogs",action:"list",params:x(u({pageSize:20,appends:["collection","user"]},o.params),{filter:i,sort:"-createdAt"}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(w.Provider,{value:!!n.name,children:r.jsx(e.ExtendCollectionsProvider,{collections:[H],children:r.jsx(e.TableBlockProvider,x(u({},s),{children:o.children}))})})},{displayName:"ApiLogs.Decorator"}),D.Designer=J;const ee=()=>{const o={type:"void",title:t("Actions"),"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-designer":"TableV2.ActionColumnDesigner","x-initializer":"apiLogsTable:configureItemActions","x-action-column":"actions",properties:{actions:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{}}}},n=e.useSchemaInitializerItem();return r.jsx(e.InitializerWithSwitch,x(u({},n),{schema:o,item:n,type:"x-action-column"}))},oe=o=>r.jsx(e.SchemaComponentOptions,{components:{ApiLogs:D,ApiLogsBlockProvider:U,ApiLogsBlockInitializer:R,ApiLogsValue:_,ApiLogsField:W,ApiLogsViewActionInitializer:$,ApiLogsTableActionColumnInitializer:ee},children:o.children}),te=()=>{const{t:o}=e.useTranslation(),{field:n}=e.useBlockRequestContext(),p=e.useDataBlockResource(),{refresh:i}=e.useDataBlockRequest();return{onClick(){return F(this,null,function*(){var c,d,g;if(!((d=(c=n==null?void 0:n.data)==null?void 0:c.selectedRowKeys)!=null&&d.length))return v.message.error(o("Please select the records you want to enable"));try{yield p.update({filterByTk:(g=n.data)==null?void 0:g.selectedRowKeys,values:{apiConfig:!0}}),i==null||i()}catch(C){console.error("Error enabling API logs config:",C)}})}}},ne=()=>{const{t:o}=e.useTranslation(),{field:n}=e.useBlockRequestContext(),p=e.useDataBlockResource(),{refresh:i}=e.useDataBlockRequest();return{onClick(){return F(this,null,function*(){var c,d,g;if(!((d=(c=n==null?void 0:n.data)==null?void 0:c.selectedRowKeys)!=null&&d.length))return v.message.error(o("Please select the records you want to disable"));try{yield p.update({filterByTk:(g=n.data)==null?void 0:g.selectedRowKeys,values:{apiConfig:!1}}),i==null||i()}catch(C){console.error("Error disenabling API logs config:",C)}})}}},re=()=>{const{field:o}=e.useBlockRequestContext(),n=e.useDataBlockResource(),{refresh:p}=e.useDataBlockRequest();return{onClick(){return F(this,null,function*(){try{yield n.tablesync({name:"tablesync"}),p==null||p()}catch(s){console.error("Error sync API logs config:",s)}})}}},L={name:"apiLogsConfig",fields:[{interface:"input",type:"string",name:"resourceName",uiSchema:{type:"string",title:t("Resource name"),"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"input",type:"string",name:"action",uiSchema:{type:"string",title:`{{t("Action", { ns: "${P}" })}}`,"x-component":"Input","x-component-props":{},"x-read-pretty":!0}},{interface:"boolean",type:"boolean",name:"apiConfig",uiSchema:{type:"boolean",title:t("Api audit"),"x-component":"Checkbox"}}]},ie={type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:e.OpenMode.DRAWER_MODE,type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{body:{type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":`${L.name}:create`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:L},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{assignedValues:{},triggerWorkflows:[],pageMode:!1}}}},title:{type:"string","x-component":"CollectionField","x-decorator":"FormItem"},resourceName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem",required:!0},action:{type:"string","x-component":"CollectionField","x-decorator":"FormItem",required:!0},apiConfig:{type:"boolean",default:!0,"x-component":"CollectionField","x-decorator":"FormItem"}}}}}}}}},pe={type:"void",properties:{apiLogsConfig:{type:"void","x-component":"CardItem","x-decorator":"TableBlockProvider","x-decorator-props":{collection:L,action:"list",params:{filter:{}}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action","x-decorator":"ACLActionProvider","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},enable:{type:"void",title:'{{ t("Enable") }}',"x-action":"update","x-decorator":"ACLActionProvider","x-use-component-props":"useApiLogsConfigEnableProps","x-component":"Action","x-component-props":{icon:"EditOutlined"}},disenable:{type:"void",title:t("Disable"),"x-action":"update","x-decorator":"ACLActionProvider","x-use-component-props":"useApiLogsConfigDisenableProps","x-component":"Action","x-component-props":{icon:"EditOutlined"}},sync:{type:"void",title:t("Table sync"),"x-use-component-props":"useApiLogsConfigSyncProps","x-component":"Action","x-component-props":{icon:"VerticalAlignBottomOutlined"}},create:ie}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{align:"center"},properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},resourceName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{align:"center"},properties:{resourceName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},action:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{align:"center"},properties:{action:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},apiConfig:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{align:"center"},properties:{apiConfig:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}}}}}}}},ae=()=>r.jsx(e.ExtendCollectionsProvider,{collections:[L],children:r.jsx(e.SchemaComponent,{schema:pe,scope:{useApiLogsConfigEnableProps:te,useApiLogsConfigDisenableProps:ne,useApiLogsConfigSyncProps:re}})}),ce=new e.SchemaInitializer({name:"apiLogsTable:configureItemActions",insertPosition:"beforeEnd",Component:o=>r.jsx(m.MenuOutlined,x(u({},o),{style:{cursor:"pointer"}})),useInsert(){const o=l.useFieldSchema(),n=e.useAPIClient(),{refresh:p}=e.useDesignable(),{t:i}=A();return s=>{const c=o.reduceProperties((g,C)=>C["x-component"]==="Space"?C:g,null);if(!c)return;const d=e.createDesignable({t:i,api:n,refresh:p,current:c});d.loadAPIClientEvents(),d.insertBeforeEnd(s)}},items:[{name:"enableActions",type:"itemGroup",title:t("Enable actions"),children:[{name:"view",type:"item",title:t("View"),Component:"ApiLogsViewActionInitializer",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}]}),se=new e.SchemaInitializer({name:"apiLogsTable: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"}}]}]}),le=()=>{const o=e.useInheritsTableColumnInitializerFields(),{t:n}=A(),p=e.useCompile();if(!(o!=null&&o.length))return null;const i=[];return o.forEach(s=>{Object.values(s)[0].length&&i.push({type:"itemGroup",divider:!0,title:n("Parent collection fields")+"("+p(`${Object.keys(s)[0]}`)+")",children:Object.values(s)[0].filter(c=>{var d;return!((d=c==null?void 0:c.field)!=null&&d.isForeignKey)})})}),r.jsx(e.SchemaInitializerChildren,{children:i})},de=()=>{const o=e.useAssociatedTableColumnInitializerFields(),{t:n}=A();if(!(o!=null&&o.length))return null;const p=[{type:"itemGroup",divider:!0,title:n("Display association fields"),children:o}];return r.jsx(e.SchemaInitializerChildren,{children:p})},me=new e.SchemaInitializer({name:"apiLogsTable: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]:u({},o)}}},items:[{name:"displayFields",type:"itemGroup",title:t("Display fields"),useChildren:e.useTableColumnInitializerFields},{name:"parentCollectionFields",Component:le},{name:"associationFields",Component:de},{name:"actionColumn",title:t("Action column"),Component:"ApiLogsTableActionColumnInitializer"}]});class ue extends e.Plugin{load(){return F(this,null,function*(){this.app.use(oe),this.app.schemaInitializerManager.add(se),this.app.schemaInitializerManager.add(ce),this.app.schemaInitializerManager.add(me);const n=this.app.schemaInitializerManager.get("page:addBlock"),p=this.app.schemaInitializerManager.get("popup:common:addBlock"),i={title:t("Api logs"),Component:"ApiLogsBlockInitializer"};n.add("otherBlocks.apiLogs",i),p.add("otherBlocks.apiLogs",i),this.app.systemSettingsManager.add("system-services.apilogs-config",{icon:"SettingOutlined",title:q("Api logs configuration"),aclSnippet:"pm.system-services.apiLogsConfig",Component:ae})})}}a.default=ue,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "1.3.
|
|
4
|
-
"@tachybase/schema": "1.3.
|
|
3
|
+
"@tachybase/client": "1.3.18",
|
|
4
|
+
"@tachybase/schema": "1.3.18",
|
|
5
5
|
"@ant-design/icons": "5.6.1",
|
|
6
|
-
"react-i18next": "15.
|
|
7
|
-
"@tachybase/database": "1.3.
|
|
8
|
-
"@tachybase/actions": "1.3.
|
|
9
|
-
"@tachybase/server": "1.3.
|
|
10
|
-
"@tachybase/utils": "1.3.
|
|
6
|
+
"react-i18next": "15.2.0",
|
|
7
|
+
"@tachybase/database": "1.3.18",
|
|
8
|
+
"@tachybase/actions": "1.3.18",
|
|
9
|
+
"@tachybase/server": "1.3.18",
|
|
10
|
+
"@tachybase/utils": "1.3.18",
|
|
11
11
|
"antd": "5.22.5",
|
|
12
|
-
"@tachybase/components": "1.3.
|
|
13
|
-
"@tachybase/data-source": "1.3.
|
|
14
|
-
"@tachybase/resourcer": "1.3.
|
|
12
|
+
"@tachybase/components": "1.3.18",
|
|
13
|
+
"@tachybase/data-source": "1.3.18",
|
|
14
|
+
"@tachybase/resourcer": "1.3.18"
|
|
15
15
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-api-logs",
|
|
3
3
|
"displayName": "Api Logs",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.18",
|
|
5
5
|
"description": "Provides seamless tracking of API actions through enhanced user interface components, configuration panels, and dashboards",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"Logging and monitoring"
|
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
"@ant-design/icons": "^5.6.1",
|
|
12
12
|
"antd": "5.22.5",
|
|
13
13
|
"lodash": "^4.17.21",
|
|
14
|
-
"react-i18next": "^15.
|
|
14
|
+
"react-i18next": "^15.2.0",
|
|
15
15
|
"react-router-dom": "6.28.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@tachybase/actions": "1.3.
|
|
19
|
-
"@tachybase/
|
|
20
|
-
"@tachybase/
|
|
21
|
-
"@tachybase/
|
|
22
|
-
"@tachybase/database": "1.3.
|
|
23
|
-
"@tachybase/
|
|
24
|
-
"@tachybase/
|
|
25
|
-
"@tachybase/
|
|
26
|
-
"@tachybase/
|
|
27
|
-
"@tachybase/
|
|
18
|
+
"@tachybase/actions": "1.3.18",
|
|
19
|
+
"@tachybase/client": "1.3.18",
|
|
20
|
+
"@tachybase/data-source": "1.3.18",
|
|
21
|
+
"@tachybase/components": "1.3.18",
|
|
22
|
+
"@tachybase/database": "1.3.18",
|
|
23
|
+
"@tachybase/schema": "1.3.18",
|
|
24
|
+
"@tachybase/server": "1.3.18",
|
|
25
|
+
"@tachybase/test": "1.3.18",
|
|
26
|
+
"@tachybase/utils": "1.3.18",
|
|
27
|
+
"@tachybase/resourcer": "1.3.18"
|
|
28
28
|
},
|
|
29
29
|
"description.zh-CN": "Api Logs通过增强的用户界面组件、配置面板和仪表板提供对 API 操作的无缝跟踪",
|
|
30
30
|
"displayName.zh-CN": "Api 日志"
|