@nocobase/plugin-user-data-sync 1.6.0-alpha.3 → 1.6.0-alpha.31
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/LICENSE.txt +11 -9
- package/dist/client/4dfc6081fd6cc6eb.js +10 -0
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +7 -7
- package/dist/locale/it-IT.json +21 -0
- package/dist/server/actions/user-data.js +9 -0
- package/dist/server/collections/user-data-sync-records-resources.js +1 -0
- package/dist/server/collections/user-data-sync-records.js +1 -0
- package/dist/server/collections/user-data-sync-sources.js +1 -0
- package/dist/server/collections/user-data-sync-tasks.js +1 -0
- package/dist/server/plugin.js +1 -1
- package/dist/server/user-data-resource-manager.js +0 -5
- package/package.json +2 -2
- package/dist/client/f880f29ea08046b3.js +0 -10
package/LICENSE.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Updated Date:
|
|
1
|
+
Updated Date: February 20, 2025
|
|
2
2
|
|
|
3
3
|
NocoBase License Agreement
|
|
4
4
|
|
|
@@ -78,7 +78,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
78
78
|
|
|
79
79
|
6.1 Obtain a permanent commercial license of the Software.
|
|
80
80
|
|
|
81
|
-
6.2 Get
|
|
81
|
+
6.2 Get software upgrades and exclusive technical support during the upgrade validity period.
|
|
82
82
|
|
|
83
83
|
6.3 The licensed Software can be used for commercial purposes with no restrictions on the number of applications and users.
|
|
84
84
|
|
|
@@ -88,7 +88,7 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
88
88
|
|
|
89
89
|
6.6 Can sell plugins developed for Software in the Marketplace.
|
|
90
90
|
|
|
91
|
-
6.7 The User with
|
|
91
|
+
6.7 The User with an Enterprise Edition License can sell Upper Layer Application to their clients.
|
|
92
92
|
|
|
93
93
|
6.8 Not restricted by the AGPL-3.0 agreement.
|
|
94
94
|
|
|
@@ -106,13 +106,15 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
106
106
|
|
|
107
107
|
7.4 It is not allowed to provide any form of no-code, zero-code, low-code platform SaaS products to the public using the original or modified Software.
|
|
108
108
|
|
|
109
|
-
7.5 It is not allowed for the User
|
|
109
|
+
7.5 It is not allowed for the User withot an Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license.
|
|
110
110
|
|
|
111
|
-
7.6 It is not allowed to
|
|
111
|
+
7.6 It is not allowed for the User with an Enterprise Edition license to sell Upper Layer Application to clients without a Commercial license with access to further development and configuration.
|
|
112
112
|
|
|
113
|
-
7.7
|
|
113
|
+
7.7 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
|
|
114
114
|
|
|
115
|
-
7.8 If there
|
|
115
|
+
7.8 If there is a violation of the above obligations or the terms of this Agreement, the rights owned by the User will be immediately terminated, the paid fees will not be refunded, and the Company reserves the right to pursue the User's legal responsibility.
|
|
116
|
+
|
|
117
|
+
7.9 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
|
|
116
118
|
|
|
117
119
|
======================================
|
|
118
120
|
8. Rights of Commercial Plugin License
|
|
@@ -120,11 +122,11 @@ Except for Third-Party Open Source Software, the Company owns all copyrights, tr
|
|
|
120
122
|
|
|
121
123
|
8.1 Obtain a permanent Commercial Plugin License for the Commercial Plugin.
|
|
122
124
|
|
|
123
|
-
8.2
|
|
125
|
+
8.2 Get plugins upgrades and exclusive technical support during the upgrade validity period.
|
|
124
126
|
|
|
125
127
|
8.3 Can be used for commercial purposes without restrictions on the number of applications or users.
|
|
126
128
|
|
|
127
|
-
8.4 The User with
|
|
129
|
+
8.4 The User with an Enterprise Edition License can use the Commercial Plugin in Upper Layer Applications sold to their customers.
|
|
128
130
|
|
|
129
131
|
8.5 Not restricted by the AGPL-3.0 agreement.
|
|
130
132
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_user_data_sync=self.webpackChunk_nocobase_plugin_user_data_sync||[]).push([["157"],{700:function(e,t,o){o.r(t),o.d(t,{UserDataSyncSource:function(){return N}});var n=o("482"),r=o("563"),c=o("505"),i=o("772"),a=o("721"),s=o("156"),l=o.n(s),u=o("60");function p(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){var n,r,c;n=e,r=t,c=o[t],r in n?Object.defineProperty(n,r,{value:c,enumerable:!0,configurable:!0,writable:!0}):n[r]=c})}return e}var m=function(e){var t,o,n=(0,i.useCollectionRecordData)();var r=(0,i.useRequest)(function(){return Promise.resolve({data:p({},n.options)})},(t=p({},e),o=(o={manual:!0},o),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o.push.apply(o,n)}return o})(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}),t)),c=r.run,a=(0,i.useActionContext)();return(0,s.useEffect)(function(){a.visible&&c()},[a.visible,c]),r},y=function(e){var t,o=(0,i.usePlugin)(u.default).sourceTypes.get(e);return null==o?void 0:null===(t=o.components)||void 0===t?void 0:t.AdminSettingsForm},d=(0,c.observer)(function(){var e=(0,c.useForm)(),t=(0,i.useCollectionRecordData)(),o=y(e.values.sourceType||t.sourceType);return o?l().createElement(o,null):null},{displayName:"Options"}),f=o("573"),b={name:"userDataSyncSources",sortable:!0,filterTargetKey:"id",fields:[{name:"id",type:"string",interface:"id"},{interface:"input",type:"string",name:"name",uiSchema:{type:"string",title:'{{t("Source name")}}',"x-component":"Input",required:!0}},{interface:"input",type:"string",name:"sourceType",allowNull:!1,uiSchema:{type:"string",title:'{{t("Type")}}',"x-component":"Select",required:!0,dataSource:"{{ types }}"}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},v={name:"userDataSyncTasks",filterTargetKey:"id",fields:[{name:"id",type:"bigInt",interface:"id"},{name:"batch",interface:"input",type:"string",allowNull:!1,uiSchema:{type:"string",title:'{{t("Batch")}}',"x-component":"Input",required:!0}},{name:"source",interface:"input",type:"belongsTo",target:"userDataSyncSources",targetKey:"id",foreignKey:"sourceId",allowNull:!1,uiSchema:{type:"object",title:'{{t("Source")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}},required:!0,"x-read-pretty":!0}},{name:"status",interface:"input",type:"string",allowNull:!1,uiSchema:{type:"string",title:'{{t("Status")}}',"x-component":"Select",required:!0,enum:[{label:'{{t("Init")}}',value:"init",color:"default"},{label:'{{t("Processing")}}',value:"processing",color:"processing"},{label:'{{t("Success")}}',value:"success",color:"success"},{label:'{{t("Failed")}}',value:"failed",color:"error"}]}},{name:"message",interface:"input",type:"string",allowNull:!0,uiSchema:{type:"string",title:'{{t("Message")}}',"x-component":"Input",required:!1}},{name:"cost",interface:"input",type:"integer",allowNull:!0,uiSchema:{type:"integer",title:'{{t("Cost")}}',"x-component":"InputNumber","x-component-props":{precision:0},required:!1}}]},x={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer",title:'{{t("Add new")}}',properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCustomFormProps",properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},sourceType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useSubmitActionProps","x-component-props":{type:"primary"}}}}}}}}}},g={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer",title:'{{ t("Tasks") }}',properties:{table:{type:"void","x-decorator":"TableBlockProvider","x-use-decorator-props":"useTasksTableBlockProps","x-decorator-props":{collection:v.name,dragSort:!1,action:"list",showIndex:!0},properties:{table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{batch:{type:"void",title:'{{ t("Batch") }}',"x-component":"TableV2.Column",properties:{batch:{type:"string","x-component":"CollectionField","x-pattern":"readPretty"}}},status:{type:"void",title:'{{ t("Status") }}',"x-component":"TableV2.Column",properties:{status:{type:"string","x-component":"CollectionField","x-pattern":"readPretty"}}},message:{type:"void",title:'{{ t("Message") }}',"x-component":"TableV2.Column",properties:{message:{type:"string","x-component":"Message"}}},actions:{type:"void",title:'{{t("Actions")}}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{sync:{type:"void","x-component":"Retry"}}}}}}}}}}}}},h={type:"void",name:"userDataSyncSources","x-component":"CardItem","x-decorator":"TableBlockProvider","x-decorator-props":{collection:b.name,dragSort:!1,action:"list",params:{pageSize:10},showIndex:!0},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{name:{type:"void",title:'{{t("Source name")}}',"x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-pattern":"readPretty"}}},sourceType:{type:"void",title:'{{t("Type")}}',"x-component":"TableV2.Column",properties:{sourceType:{type:"string","x-component":"Select","x-pattern":"readPretty",enum:"{{ types }}"}}},enabled:{type:"void",title:'{{t("Enabled")}}',"x-component":"TableV2.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-pattern":"readPretty"}}},actions:{type:"void",title:'{{t("Actions")}}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{sync:{type:"void",title:'{{ t("Sync") }}',"x-component":"Action.Link","x-use-component-props":"useSyncActionProps"},tasks:{type:"void",title:'{{ t("Tasks") }}',"x-component":"Tasks","x-component-props":{type:"primary"}},edit:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary",openMode:"drawer"},properties:{drawer:{type:"void","x-component":"Action.Drawer",title:'{{t("Configure")}}',properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormProps",properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},sourceType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useSubmitActionProps","x-component-props":{type:"primary"}}}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-use-component-props":"useDeleteActionProps"}}}}}}}}},S=(0,s.createContext)({type:""});S.displayName="SourceTypeContext";var C=(0,s.createContext)({types:[]});C.displayName="SourceTypesContext";function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=Array(t);o<t;o++)n[o]=e[o];return n}function w(e,t,o,n,r,c,i){try{var a=e[c](i),s=a.value}catch(e){o(e);return}a.done?t(s):Promise.resolve(s).then(n,r)}function A(e){return function(){var t=this,o=arguments;return new Promise(function(n,r){var c=e.apply(t,o);function i(e){w(c,n,r,i,a,"next",e)}function a(e){w(c,n,r,i,a,"throw",e)}i(void 0)})}}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var o,n,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var c=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(o=r.next()).done)&&(c.push(o.value),!t||c.length!==t);i=!0);}catch(e){a=!0,n=e}finally{try{!i&&null!=r.return&&r.return()}finally{if(a)throw n}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return P(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);if("Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o)return Array.from(o);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return P(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t){var o,n,r,c,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return c={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function a(c){return function(a){return function(c){if(o)throw TypeError("Generator is already executing.");for(;i;)try{if(o=1,n&&(r=2&c[0]?n.return:c[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,c[1])).done)return r;switch(n=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){i=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){i.label=c[1];break}if(6===c[0]&&i.label<r[1]){i.label=r[1],r=c;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(c);break}r[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{o=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}var O=function(){var e=(0,i.useCollectionRecordData)();return{form:(0,s.useMemo)(function(){return(0,r.createForm)({values:e})},[])}},D=function(){var e=(0,i.useActionContext)().setVisible,t=(0,c.useForm)(),o=(0,i.useDataBlockResource)(),n=(0,i.useDataBlockRequestGetter)().getDataBlockRequest,r=(0,i.useCollection)();return{type:"primary",onClick:function(){return A(function(){var c,i;return T(this,function(a){switch(a.label){case 0:return[4,t.submit()];case 1:if(a.sent(),!(i=t.values)[r.filterTargetKey])return[3,3];return[4,o.update({values:i,filterByTk:i[r.filterTargetKey]})];case 2:return a.sent(),[3,5];case 3:return[4,o.create({values:i})];case 4:a.sent(),a.label=5;case 5:return[4,null===(c=n())||void 0===c?void 0:c.runAsync()];case 6:return a.sent(),e(!1),[2]}})})()}}};function E(){var e=(0,i.useCollectionRecordData)(),t=(0,i.useDataBlockResource)(),o=(0,i.useCollection)(),n=(0,i.useDataBlockRequestGetter)().getDataBlockRequest,r=(0,f.S)().t;return{confirm:{title:r("Delete",{ns:f.A}),content:r("Are you sure you want to delete it?",{ns:f.A})},onClick:function(){return A(function(){var r;return T(this,function(c){switch(c.label){case 0:return[4,t.destroy({filterByTk:e[o.filterTargetKey]})];case 1:return c.sent(),[4,null===(r=n())||void 0===r?void 0:r.runAsync()];case 2:return c.sent(),[2]}})})()}}}function j(){var e=a.App.useApp().message,t=(0,i.useCollectionRecordData)(),o=(0,i.useAPIClient)(),n=(0,i.useDataBlockRequestGetter)().getDataBlockRequest,r=(0,f.S)().t;return{hidden:!(null==t?void 0:t.enabled),onClick:function(){return A(function(){var c;return T(this,function(i){switch(i.label){case 0:return[4,o.resource("userData").pull({name:t.name})];case 1:return i.sent(),[4,null===(c=n())||void 0===c?void 0:c.runAsync()];case 2:return i.sent(),e.success(r("The synchronization has started. You can click on 'Tasks' to view the synchronization status.",{ns:f.A})),[2]}})})()}}}var F=function(){var e=(0,s.useContext)(S).type;return{form:(0,s.useMemo)(function(){return(0,r.createForm)({initialValues:{sourceType:e}})},[])}},I=function(){return{params:{pageSize:20,filter:{sourceId:(0,i.useCollectionRecordData)()[(0,i.useCollection)().filterTargetKey]},sort:["-sort"]}}};function R(){var e=(0,i.useCollectionRecordData)(),t=(0,i.useCollection)(),o=(0,i.useAPIClient)(),n=(0,i.useDataBlockRequestGetter)().getDataBlockRequest;return{onClick:function(){return A(function(){var r;return T(this,function(c){switch(c.label){case 0:return[4,o.resource("userData").retry({id:e[t.filterTargetKey],sourceId:e.sourceId})];case 1:return c.sent(),[4,null===(r=n())||void 0===r?void 0:r.runAsync()];case 2:return c.sent(),[2]}})})()}}}var B=function(){var e=(0,f.S)().t,t=(0,i.useAPIClient)(),o=k((0,s.useState)(!1),2),r=o[0],c=o[1],u=k((0,s.useState)(""),2),p=u[0],m=u[1],y=(0,s.useContext)(C).types,d=y.map(function(e){var t,o;return t=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){var n,r,c;n=e,r=t,c=o[t],r in n?Object.defineProperty(n,r,{value:c,enumerable:!0,configurable:!0,writable:!0}):n[r]=c})}return e}({},e),o=(o={onClick:function(){c(!0),m(e.value)}},o),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o.push.apply(o,n)}return o})(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}),t}),b=[{key:"__empty__",label:l().createElement(a.Empty,{image:a.Empty.PRESENTED_IMAGE_SIMPLE,description:l().createElement(l().Fragment,null,e("No user data source plugin installed",{ns:f.A}),l().createElement("br",null)," ",l().createElement("a",{target:"_blank",href:"zh-CN"===t.auth.locale?"https://docs-cn.nocobase.com/handbook/user-data-sync":"https://docs.nocobase.com/handbook/user-data-sync",rel:"noreferrer"},e("View documentation",{ns:f.A})))}),onClick:function(){}}];return l().createElement(i.ActionContextProvider,{value:{visible:r,setVisible:c}},l().createElement(S.Provider,{value:{type:p}},l().createElement(a.Dropdown,{menu:{items:d&&d.length>0?d:b}},l().createElement(a.Button,{icon:l().createElement(n.PlusOutlined,null),type:"primary"},e("Add new")," ",l().createElement(n.DownOutlined,null))),l().createElement(i.SchemaComponent,{scope:{types:y,setType:m,useCustomFormProps:F},schema:x})))},V=function(){var e=(0,f.S)().t,t=(0,i.useCollectionRecordData)();return l().createElement(i.ReadPretty.Input,{value:e(t.message),ellipsis:!0})},q=function(){var e=(0,i.useCollectionRecordData)(),t=(0,f.S)().t,o=k((0,s.useState)(!1),2),n=o[0],r=o[1];return e.enabled?l().createElement(i.ActionContextProvider,{value:{visible:n,setVisible:r}},l().createElement(a.Button,{type:"link",onClick:function(){r(!0)}},t("Tasks")),l().createElement(i.ExtendCollectionsProvider,{collections:[v]},l().createElement(i.SchemaComponent,{scope:{useRetryActionProps:R,useTasksTableBlockProps:I,t:t},components:{Message:V},schema:g}))):null},_=function(){var e=(0,f.S)().t;return"failed"!==(0,i.useCollectionRecordData)().status?null:l().createElement(i.SchemaComponent,{scope:{t:e},schema:{type:"void",properties:{retry:{title:'{{ t("Retry") }}',"x-component":"Action.Link","x-use-component-props":"useRetryActionProps"}}}})},N=function(){var e=(0,f.S)().t,t=k((0,s.useState)([]),2),o=t[0],n=t[1],r=(0,i.useAPIClient)();return(0,i.useRequest)(function(){return r.resource("userData").listSyncTypes().then(function(t){var o;return((null==t?void 0:null===(o=t.data)||void 0===o?void 0:o.data)||[]).map(function(t){return{key:t.name,label:c.Schema.compile(t.title||t.name,{t:e}),value:t.name}})})},{onSuccess:function(e){n(e)}}),l().createElement(C.Provider,{value:{types:o}},l().createElement(i.ExtendCollectionsProvider,{collections:[b]},l().createElement(i.SchemaComponent,{schema:h,components:{AddNew:B,Options:d,Tasks:q,Retry:_},scope:{types:o,t:e,useEditFormProps:O,useSubmitActionProps:D,useDeleteActionProps:E,useSyncActionProps:j,useValuesFromOptions:m}})))}}}]);
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@nocobase/utils/client"),require("@
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react-i18next"),require("@nocobase/utils/client"),require("@nocobase/client"),require("@formily/core"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("react")):"function"==typeof define&&define.amd?define("@nocobase/plugin-user-data-sync",["react-i18next","@nocobase/utils/client","@nocobase/client","@formily/core","antd","@ant-design/icons","@formily/react","react"],t):"object"==typeof exports?exports["@nocobase/plugin-user-data-sync"]=t(require("react-i18next"),require("@nocobase/utils/client"),require("@nocobase/client"),require("@formily/core"),require("antd"),require("@ant-design/icons"),require("@formily/react"),require("react")):e["@nocobase/plugin-user-data-sync"]=t(e["react-i18next"],e["@nocobase/utils/client"],e["@nocobase/client"],e["@formily/core"],e.antd,e["@ant-design/icons"],e["@formily/react"],e.react)}(self,function(e,t,n,r,o,i,u,c){return function(){var a,s,l,f,p,d,y={60:function(e,t,n){"use strict";n.r(t),n.d(t,{PluginUserDataSyncClient:function(){return b}});var r=n(772),o=n(584),i=n(573),u=n(581);function c(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function a(e,t,n){return(a=d()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&f(o,n.prototype),o}).apply(null,arguments)}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){var n;if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return a(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,e)})(e)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}var y=(0,r.lazy)(function(){return u("imported_-1c4lqme_component",n.e("157").then(n.bind(n,700)))},"UserDataSyncSource").UserDataSyncSource,b=function(e){var t,n,r;function u(){var e,t,n,r,i,c,a;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,u),t=this,n=u,r=arguments,n=l(n),i=e=function(e,t){return t&&("object"===function(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}(t)||"function"==typeof t)?t:function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(t,d()?Reflect.construct(n,r||[],l(t).constructor):n.apply(t,r)),c="sourceTypes",a=new o.Registry,c in i?Object.defineProperty(i,c,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[c]=a,e}return!function(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)}(u,e),t=u,n=[{key:"registerType",value:function(e,t){this.sourceTypes.register(e,t)}},{key:"load",value:function(){var e,t=this;return(e=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,function(e){return t.app.pluginSettingsManager.add("users-permissions.sync",{title:(0,o.tval)("Synchronize",{ns:i.A}),icon:"SyncOutlined",Component:y,sort:99,aclSnippet:"pm.user-data-sync"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){c(i,r,o,u,a,"next",e)}function a(e){c(i,r,o,u,a,"throw",e)}u(void 0)})})()}}],s(t.prototype,n),u}(p(r.Plugin));t.default=b},573:function(e,t,n){"use strict";n.d(t,{A:function(){return o},S:function(){return i}});var r=n(238),o="user-data-sync";function i(){return(0,r.useTranslation)([o,"client"],{nsMode:"fallback"})}},581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=i},563:function(e){"use strict";e.exports=r},505:function(e){"use strict";e.exports=u},772:function(e){"use strict";e.exports=n},584:function(e){"use strict";e.exports=t},721:function(e){"use strict";e.exports=o},156:function(e){"use strict";e.exports=c},238:function(t){"use strict";t.exports=e}},b={};function h(e){var t=b[e];if(void 0!==t)return t.exports;var n=b[e]={exports:{}};return y[e](n,n.exports,h),n.exports}return h.m=y,h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.f={},h.e=function(e){return Promise.all(Object.keys(h.f).reduce(function(t,n){return h.f[n](e,t),t},[]))},h.u=function(e){return"4dfc6081fd6cc6eb.js"},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a={},s="@nocobase/plugin-user-data-sync:",h.l=function(e,t,n,r){if(a[e]){a[e].push(t);return}if(void 0!==n){for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var l=u[c];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")==s+n){o=l;break}}}!o&&(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,h.nc&&o.setAttribute("nonce",h.nc),o.setAttribute("data-webpack",s+n),o.src=e),a[e]=[t];var f=function(t,n){o.onerror=o.onload=null,clearTimeout(p);var r=a[e];if(delete a[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(f.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=f.bind(null,o.onerror),o.onload=f.bind(null,o.onload),i&&document.head.appendChild(o)},h.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},h.p=(!(l=window.__nocobase_public_path__||"/").endsWith("/")&&(l+="/"),l+"static/plugins/@nocobase/plugin-user-data-sync/dist/client/"),f={909:0},h.f.j=function(e,t){var n=h.o(f,e)?f[e]:void 0;if(0!==n){if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=f[e]=[t,r]});t.push(n[2]=r);var o=h.p+h.u(e),i=Error();h.l(o,function(t){if(h.o(f,e)&&(0!==(n=f[e])&&(f[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}}},p=function(e,t){var n=t[0],r=t[1],o=t[2],i,u,c=0;if(n.some(function(e){return 0!==f[e]})){for(i in r)h.o(r,i)&&(h.m[i]=r[i]);o&&o(h)}for(e&&e(t);c<n.length;c++)u=n[c],h.o(f,u)&&f[u]&&f[u][0](),f[u]=0},(d=self.webpackChunk_nocobase_plugin_user_data_sync=self.webpackChunk_nocobase_plugin_user_data_sync||[]).forEach(p.bind(null,0)),d.push=p.bind(null,d.push.bind(d)),h("60")}()});
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"@formily/react": "2.3.0",
|
|
13
|
-
"@nocobase/client": "1.6.0-alpha.
|
|
14
|
-
"@ant-design/icons": "5.
|
|
13
|
+
"@nocobase/client": "1.6.0-alpha.31",
|
|
14
|
+
"@ant-design/icons": "5.6.1",
|
|
15
15
|
"@formily/core": "2.3.0",
|
|
16
16
|
"antd": "5.12.8",
|
|
17
|
-
"@nocobase/utils": "1.6.0-alpha.
|
|
18
|
-
"@nocobase/server": "1.6.0-alpha.
|
|
19
|
-
"@nocobase/logger": "1.6.0-alpha.
|
|
20
|
-
"@nocobase/actions": "1.6.0-alpha.
|
|
17
|
+
"@nocobase/utils": "1.6.0-alpha.31",
|
|
18
|
+
"@nocobase/server": "1.6.0-alpha.31",
|
|
19
|
+
"@nocobase/logger": "1.6.0-alpha.31",
|
|
20
|
+
"@nocobase/actions": "1.6.0-alpha.31",
|
|
21
21
|
"dayjs": "1.11.10",
|
|
22
|
-
"@nocobase/database": "1.6.0-alpha.
|
|
22
|
+
"@nocobase/database": "1.6.0-alpha.31",
|
|
23
23
|
"react-i18next": "11.18.6"
|
|
24
24
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Synchronize": "Sincronizza",
|
|
3
|
+
"Source name": "Nome origine",
|
|
4
|
+
"Source display name": "Nome visualizzato origine",
|
|
5
|
+
"Type": "Tipo",
|
|
6
|
+
"Sync": "Sincronizza",
|
|
7
|
+
"Tasks": "Attività",
|
|
8
|
+
"Batch": "Batch",
|
|
9
|
+
"Status": "Stato",
|
|
10
|
+
"Message": "Messaggio",
|
|
11
|
+
"Init": "Inizializzazione",
|
|
12
|
+
"Processing": "Elaborazione",
|
|
13
|
+
"Success": "Successo",
|
|
14
|
+
"Failed": "Fallito",
|
|
15
|
+
"Authenticator": "Autenticatore",
|
|
16
|
+
"Retry": "Riprova",
|
|
17
|
+
"No user data source plugin installed": "Nessun plugin origine dati utente installato",
|
|
18
|
+
"View documentation": "Visualizza documentazione",
|
|
19
|
+
"The synchronization has started. You can click on 'Tasks' to view the synchronization status.": "La sincronizzazione è iniziata. Puoi cliccare su 'Attività' per visualizzare lo stato della sincronizzazione.",
|
|
20
|
+
"The sync source API call failed. Please check the logs to troubleshoot the issue.": "La chiamata API di sincronizzazione all' origine è fallita. Controlla i registri per risolvere il problema."
|
|
21
|
+
}
|
|
@@ -46,6 +46,15 @@ var user_data_default = {
|
|
|
46
46
|
const data = ctx.action.params.values || {};
|
|
47
47
|
const plugin = ctx.app.pm.get(import_plugin.PluginUserDataSyncServer);
|
|
48
48
|
try {
|
|
49
|
+
let supported = false;
|
|
50
|
+
for (const resource of plugin.resourceManager.resources.nodes) {
|
|
51
|
+
if (resource.accepts.includes(data.dataType)) {
|
|
52
|
+
supported = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!supported) {
|
|
56
|
+
throw new Error(`dataType ${data.dataType} is not supported`);
|
|
57
|
+
}
|
|
49
58
|
const result = await plugin.syncService.push(data);
|
|
50
59
|
ctx.body = { code: 0, message: "success", result };
|
|
51
60
|
} catch (error) {
|
|
@@ -32,6 +32,7 @@ module.exports = __toCommonJS(user_data_sync_records_resources_exports);
|
|
|
32
32
|
var import_database = require("@nocobase/database");
|
|
33
33
|
var user_data_sync_records_resources_default = (0, import_database.defineCollection)({
|
|
34
34
|
name: "userDataSyncRecordsResources",
|
|
35
|
+
migrationRules: ["schema-only", "overwrite"],
|
|
35
36
|
fields: [
|
|
36
37
|
{
|
|
37
38
|
name: "recordId",
|
package/dist/server/plugin.js
CHANGED
|
@@ -81,7 +81,7 @@ class PluginUserDataSyncServer extends import_server.Plugin {
|
|
|
81
81
|
});
|
|
82
82
|
this.app.acl.registerSnippet({
|
|
83
83
|
name: `pm.${this.name}`,
|
|
84
|
-
actions: ["userData:*", "userDataSyncSources:*"]
|
|
84
|
+
actions: ["userData:*", "userDataSyncSources:*", "userDataSyncTasks:*"]
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
async install() {
|
|
@@ -129,14 +129,12 @@ class UserDataResourceManager {
|
|
|
129
129
|
await this.saveOriginRecords(data);
|
|
130
130
|
const { dataType, sourceName, records, matchKey } = data;
|
|
131
131
|
const sourceUks = records.map((record) => record.uid);
|
|
132
|
-
let processed = false;
|
|
133
132
|
const syncResults = [];
|
|
134
133
|
for (const resource of this.resources.nodes) {
|
|
135
134
|
if (!resource.accepts.includes(dataType)) {
|
|
136
135
|
continue;
|
|
137
136
|
}
|
|
138
137
|
const associateResource = resource.name;
|
|
139
|
-
processed = true;
|
|
140
138
|
const originRecords = await this.findOriginRecords({ sourceName, sourceUks, dataType });
|
|
141
139
|
if (!(originRecords && originRecords.length)) {
|
|
142
140
|
continue;
|
|
@@ -201,9 +199,6 @@ class UserDataResourceManager {
|
|
|
201
199
|
}
|
|
202
200
|
});
|
|
203
201
|
}
|
|
204
|
-
if (!processed) {
|
|
205
|
-
throw new Error(`dataType "${dataType}" is not support`);
|
|
206
|
-
}
|
|
207
202
|
return syncResults;
|
|
208
203
|
}
|
|
209
204
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "用户数据同步",
|
|
5
5
|
"description": "Reigster and manage extensible user data synchronization sources, with HTTP API provided by default. Support for synchronizing data to resources such as users and departments.",
|
|
6
6
|
"description.zh-CN": "注册和管理可扩展的用户数据同步来源,默认提供 HTTP API。支持向用户和部门等资源同步数据。",
|
|
7
|
-
"version": "1.6.0-alpha.
|
|
7
|
+
"version": "1.6.0-alpha.31",
|
|
8
8
|
"main": "dist/server/index.js",
|
|
9
9
|
"peerDependencies": {
|
|
10
10
|
"@nocobase/client": "1.x",
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
"keywords": [
|
|
15
15
|
"Users & permissions"
|
|
16
16
|
],
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "2f118f0a0691dd51c437f208b1166258a615b6a8"
|
|
18
18
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_user_data_sync=self.webpackChunk_nocobase_plugin_user_data_sync||[]).push([["157"],{700:function(e,t,o){o.r(t),o.d(t,{UserDataSyncSource:function(){return _}});var n=o("482"),r=o("563"),i=o("505"),c=o("772"),a=o("721"),s=o("156"),l=o.n(s),p=o("60");function u(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){var n,r,i;n=e,r=t,i=o[t],r in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i})}return e}var m=function(e){var t,o,n=(0,c.useCollectionRecordData)();var r=(0,c.useRequest)(function(){return Promise.resolve({data:u({},n.options)})},(t=u({},e),o=(o={manual:!0},o),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o.push.apply(o,n)}return o})(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}),t)),i=r.run,a=(0,c.useActionContext)();return(0,s.useEffect)(function(){a.visible&&i()},[a.visible,i]),r},y=function(e){var t,o=(0,c.usePlugin)(p.default).sourceTypes.get(e);return null==o?void 0:null===(t=o.components)||void 0===t?void 0:t.AdminSettingsForm},d=(0,i.observer)(function(){var e=(0,i.useForm)(),t=(0,c.useCollectionRecordData)(),o=y(e.values.sourceType||t.sourceType);return o?l().createElement(o,null):null},{displayName:"Options"}),f=o("573"),b={name:"userDataSyncSources",sortable:!0,filterTargetKey:"id",fields:[{name:"id",type:"string",interface:"id"},{interface:"input",type:"string",name:"name",uiSchema:{type:"string",title:'{{t("Source name")}}',"x-component":"Input",required:!0}},{interface:"input",type:"string",name:"sourceType",allowNull:!1,uiSchema:{type:"string",title:'{{t("Type")}}',"x-component":"Select",required:!0,dataSource:"{{ types }}"}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},v={name:"userDataSyncTasks",filterTargetKey:"id",fields:[{name:"id",type:"bigInt",interface:"id"},{name:"batch",interface:"input",type:"string",allowNull:!1,uiSchema:{type:"string",title:'{{t("Batch")}}',"x-component":"Input",required:!0}},{name:"source",interface:"input",type:"belongsTo",target:"userDataSyncSources",targetKey:"id",foreignKey:"sourceId",allowNull:!1,uiSchema:{type:"object",title:'{{t("Source")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}},required:!0,"x-read-pretty":!0}},{name:"status",interface:"input",type:"string",allowNull:!1,uiSchema:{type:"string",title:'{{t("Status")}}',"x-component":"Select",required:!0,enum:[{label:'{{t("Init")}}',value:"init",color:"default"},{label:'{{t("Processing")}}',value:"processing",color:"processing"},{label:'{{t("Success")}}',value:"success",color:"success"},{label:'{{t("Failed")}}',value:"failed",color:"error"}]}},{name:"message",interface:"input",type:"string",allowNull:!0,uiSchema:{type:"string",title:'{{t("Message")}}',"x-component":"Input",required:!1}},{name:"cost",interface:"input",type:"integer",allowNull:!0,uiSchema:{type:"integer",title:'{{t("Cost")}}',"x-component":"InputNumber","x-component-props":{precision:0},required:!1}}]},x={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer",title:'{{t("Add new")}}',properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCustomFormProps",properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},sourceType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useSubmitActionProps","x-component-props":{type:"primary"}}}}}}}}}},g={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer",title:'{{ t("Tasks") }}',properties:{table:{type:"void","x-decorator":"TableBlockProvider","x-use-decorator-props":"useTasksTableBlockProps","x-decorator-props":{collection:v.name,dragSort:!1,action:"list",showIndex:!0},properties:{table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{batch:{type:"void",title:'{{ t("Batch") }}',"x-component":"TableV2.Column",properties:{batch:{type:"string","x-component":"CollectionField","x-pattern":"readPretty"}}},status:{type:"void",title:'{{ t("Status") }}',"x-component":"TableV2.Column",properties:{status:{type:"string","x-component":"CollectionField","x-pattern":"readPretty"}}},message:{type:"void",title:'{{ t("Message") }}',"x-component":"TableV2.Column",properties:{message:{type:"string","x-component":"Message"}}},actions:{type:"void",title:'{{t("Actions")}}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{sync:{type:"void",title:'{{ t("Retry") }}',"x-component":"Action.Link","x-use-component-props":"useRetryActionProps","x-display":'{{ $record.status === "failed" ? "visible" : "hidden" }}'}}}}}}}}}}}}},h={type:"void",name:"userDataSyncSources","x-component":"CardItem","x-decorator":"TableBlockProvider","x-decorator-props":{collection:b.name,dragSort:!1,action:"list",params:{pageSize:10},showIndex:!0},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{name:{type:"void",title:'{{t("Source name")}}',"x-component":"TableV2.Column",properties:{name:{type:"string","x-component":"CollectionField","x-pattern":"readPretty"}}},sourceType:{type:"void",title:'{{t("Type")}}',"x-component":"TableV2.Column",properties:{sourceType:{type:"string","x-component":"Select","x-pattern":"readPretty",enum:"{{ types }}"}}},enabled:{type:"void",title:'{{t("Enabled")}}',"x-component":"TableV2.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-pattern":"readPretty"}}},actions:{type:"void",title:'{{t("Actions")}}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{sync:{type:"void",title:'{{ t("Sync") }}',"x-component":"Action.Link","x-use-component-props":"useSyncActionProps","x-display":'{{ $record.enabled ? "visible" : "hidden" }}'},tasks:{type:"void",title:'{{ t("Tasks") }}',"x-component":"Tasks","x-component-props":{type:"primary"},"x-display":'{{ $record.enabled ? "visible" : "hidden" }}'},edit:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary",openMode:"drawer"},properties:{drawer:{type:"void","x-component":"Action.Drawer",title:'{{t("Configure")}}',properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormProps",properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},sourceType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useSubmitActionProps","x-component-props":{type:"primary"}}}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-use-component-props":"useDeleteActionProps"}}}}}}}}},S=(0,s.createContext)({type:""});S.displayName="SourceTypeContext";var C=(0,s.createContext)({types:[]});C.displayName="SourceTypesContext";function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=Array(t);o<t;o++)n[o]=e[o];return n}function w(e,t,o,n,r,i,c){try{var a=e[i](c),s=a.value}catch(e){o(e);return}a.done?t(s):Promise.resolve(s).then(n,r)}function A(e){return function(){var t=this,o=arguments;return new Promise(function(n,r){var i=e.apply(t,o);function c(e){w(i,n,r,c,a,"next",e)}function a(e){w(i,n,r,c,a,"throw",e)}c(void 0)})}}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var o,n,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i=[],c=!0,a=!1;try{for(r=r.call(e);!(c=(o=r.next()).done)&&(i.push(o.value),!t||i.length!==t);c=!0);}catch(e){a=!0,n=e}finally{try{!c&&null!=r.return&&r.return()}finally{if(a)throw n}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return P(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);if("Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o)return Array.from(o);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return P(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e,t){var o,n,r,i,c={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw TypeError("Generator is already executing.");for(;c;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,n=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(r=(r=c.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){c.label=i[1];break}if(6===i[0]&&c.label<r[1]){c.label=r[1],r=i;break}if(r&&c.label<r[2]){c.label=r[2],c.ops.push(i);break}r[2]&&c.ops.pop(),c.trys.pop();continue}i=t.call(e,c)}catch(e){i=[6,e],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var O=function(){var e=(0,c.useCollectionRecordData)();return{form:(0,s.useMemo)(function(){return(0,r.createForm)({values:e})},[])}},D=function(){var e=(0,c.useActionContext)().setVisible,t=(0,i.useForm)(),o=(0,c.useDataBlockResource)(),n=(0,c.useDataBlockRequestGetter)().getDataBlockRequest,r=(0,c.useCollection)();return{type:"primary",onClick:function(){return A(function(){var i,c;return T(this,function(a){switch(a.label){case 0:return[4,t.submit()];case 1:if(a.sent(),!(c=t.values)[r.filterTargetKey])return[3,3];return[4,o.update({values:c,filterByTk:c[r.filterTargetKey]})];case 2:return a.sent(),[3,5];case 3:return[4,o.create({values:c})];case 4:a.sent(),a.label=5;case 5:return[4,null===(i=n())||void 0===i?void 0:i.runAsync()];case 6:return a.sent(),e(!1),[2]}})})()}}};function E(){var e=(0,c.useCollectionRecordData)(),t=(0,c.useDataBlockResource)(),o=(0,c.useCollection)(),n=(0,c.useDataBlockRequestGetter)().getDataBlockRequest,r=(0,f.S)().t;return{confirm:{title:r("Delete",{ns:f.A}),content:r("Are you sure you want to delete it?",{ns:f.A})},onClick:function(){return A(function(){var r;return T(this,function(i){switch(i.label){case 0:return[4,t.destroy({filterByTk:e[o.filterTargetKey]})];case 1:return i.sent(),[4,null===(r=n())||void 0===r?void 0:r.runAsync()];case 2:return i.sent(),[2]}})})()}}}function j(){var e=a.App.useApp().message,t=(0,c.useCollectionRecordData)(),o=(0,c.useAPIClient)(),n=(0,c.useDataBlockRequestGetter)().getDataBlockRequest,r=(0,f.S)().t;return{onClick:function(){return A(function(){var i;return T(this,function(c){switch(c.label){case 0:return[4,o.resource("userData").pull({name:t.name})];case 1:return c.sent(),[4,null===(i=n())||void 0===i?void 0:i.runAsync()];case 2:return c.sent(),e.success(r("The synchronization has started. You can click on 'Tasks' to view the synchronization status.",{ns:f.A})),[2]}})})()}}}var F=function(){var e=(0,s.useContext)(S).type;return{form:(0,s.useMemo)(function(){return(0,r.createForm)({initialValues:{sourceType:e}})},[])}},I=function(){return{params:{pageSize:20,filter:{sourceId:(0,c.useCollectionRecordData)()[(0,c.useCollection)().filterTargetKey]},sort:["-sort"]}}};function B(){var e=(0,c.useCollectionRecordData)(),t=(0,c.useCollection)(),o=(0,c.useAPIClient)(),n=(0,c.useDataBlockRequestGetter)().getDataBlockRequest;return{onClick:function(){return A(function(){var r;return T(this,function(i){switch(i.label){case 0:return[4,o.resource("userData").retry({id:e[t.filterTargetKey],sourceId:e.sourceId})];case 1:return i.sent(),[4,null===(r=n())||void 0===r?void 0:r.runAsync()];case 2:return i.sent(),[2]}})})()}}}var R=function(){var e=(0,f.S)().t,t=(0,c.useAPIClient)(),o=k((0,s.useState)(!1),2),r=o[0],i=o[1],p=k((0,s.useState)(""),2),u=p[0],m=p[1],y=(0,s.useContext)(C).types,d=y.map(function(e){var t,o;return t=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},n=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),n.forEach(function(t){var n,r,i;n=e,r=t,i=o[t],r in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i})}return e}({},e),o=(o={onClick:function(){i(!0),m(e.value)}},o),Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):(function(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o.push.apply(o,n)}return o})(Object(o)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}),t}),b=[{key:"__empty__",label:l().createElement(a.Empty,{image:a.Empty.PRESENTED_IMAGE_SIMPLE,description:l().createElement(l().Fragment,null,e("No user data source plugin installed",{ns:f.A}),l().createElement("br",null)," ",l().createElement("a",{target:"_blank",href:"zh-CN"===t.auth.locale?"https://docs-cn.nocobase.com/handbook/user-data-sync":"https://docs.nocobase.com/handbook/user-data-sync",rel:"noreferrer"},e("View documentation",{ns:f.A})))}),onClick:function(){}}];return l().createElement(c.ActionContextProvider,{value:{visible:r,setVisible:i}},l().createElement(S.Provider,{value:{type:u}},l().createElement(a.Dropdown,{menu:{items:d&&d.length>0?d:b}},l().createElement(a.Button,{icon:l().createElement(n.PlusOutlined,null),type:"primary"},e("Add new")," ",l().createElement(n.DownOutlined,null))),l().createElement(c.SchemaComponent,{scope:{types:y,setType:m,useCustomFormProps:F},schema:x})))},V=function(){var e=(0,f.S)().t,t=(0,c.useCollectionRecordData)();return l().createElement(c.ReadPretty.Input,{value:e(t.message),ellipsis:!0})},q=function(){var e=(0,f.S)().t,t=k((0,s.useState)(!1),2),o=t[0],n=t[1];return l().createElement(c.ActionContextProvider,{value:{visible:o,setVisible:n}},l().createElement(a.Button,{type:"link",onClick:function(){n(!0)}},e("Tasks")),l().createElement(c.ExtendCollectionsProvider,{collections:[v]},l().createElement(c.SchemaComponent,{scope:{useRetryActionProps:B,useTasksTableBlockProps:I,t:e},components:{Message:V},schema:g})))},_=function(){var e=(0,f.S)().t,t=k((0,s.useState)([]),2),o=t[0],n=t[1],r=(0,c.useAPIClient)();return(0,c.useRequest)(function(){return r.resource("userData").listSyncTypes().then(function(t){var o;return((null==t?void 0:null===(o=t.data)||void 0===o?void 0:o.data)||[]).map(function(t){return{key:t.name,label:i.Schema.compile(t.title||t.name,{t:e}),value:t.name}})})},{onSuccess:function(e){n(e)}}),l().createElement(C.Provider,{value:{types:o}},l().createElement(c.ExtendCollectionsProvider,{collections:[b]},l().createElement(c.SchemaComponent,{schema:h,components:{AddNew:R,Options:d,Tasks:q},scope:{types:o,t:e,useEditFormProps:O,useSubmitActionProps:D,useDeleteActionProps:E,useSyncActionProps:j,useValuesFromOptions:m}})))}}}]);
|