@nocobase/plugin-user-data-sync 1.4.0-alpha

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.
Files changed (47) hide show
  1. package/LICENSE.txt +159 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/Options.d.ts +12 -0
  6. package/dist/client/UserDataSyncSource.d.ts +10 -0
  7. package/dist/client/index.d.ts +21 -0
  8. package/dist/client/index.js +10 -0
  9. package/dist/client/locale/index.d.ts +10 -0
  10. package/dist/client/schemas/user-data-sync-sources.d.ts +155 -0
  11. package/dist/client/sourceType.d.ts +24 -0
  12. package/dist/externalVersion.js +24 -0
  13. package/dist/index.d.ts +10 -0
  14. package/dist/index.js +60 -0
  15. package/dist/locale/en-US.json +21 -0
  16. package/dist/locale/zh-CN.json +24 -0
  17. package/dist/server/actions/user-data.d.ts +16 -0
  18. package/dist/server/actions/user-data.js +64 -0
  19. package/dist/server/collections/user-data-sync-records-resources.d.ts +10 -0
  20. package/dist/server/collections/user-data-sync-records-resources.js +54 -0
  21. package/dist/server/collections/user-data-sync-records.d.ts +10 -0
  22. package/dist/server/collections/user-data-sync-records.js +85 -0
  23. package/dist/server/collections/user-data-sync-sources.d.ts +10 -0
  24. package/dist/server/collections/user-data-sync-sources.js +109 -0
  25. package/dist/server/collections/user-data-sync-tasks.d.ts +10 -0
  26. package/dist/server/collections/user-data-sync-tasks.js +131 -0
  27. package/dist/server/error.d.ts +21 -0
  28. package/dist/server/error.js +58 -0
  29. package/dist/server/index.d.ts +12 -0
  30. package/dist/server/index.js +56 -0
  31. package/dist/server/models/sync-source.d.ts +15 -0
  32. package/dist/server/models/sync-source.js +38 -0
  33. package/dist/server/plugin.d.ts +27 -0
  34. package/dist/server/plugin.js +100 -0
  35. package/dist/server/sync-source-manager.d.ts +28 -0
  36. package/dist/server/sync-source-manager.js +71 -0
  37. package/dist/server/sync-source.d.ts +42 -0
  38. package/dist/server/sync-source.js +107 -0
  39. package/dist/server/user-data-resource-manager.d.ts +108 -0
  40. package/dist/server/user-data-resource-manager.js +214 -0
  41. package/dist/server/user-data-sync-service.d.ts +23 -0
  42. package/dist/server/user-data-sync-service.js +130 -0
  43. package/dist/swagger/index.d.ts +116 -0
  44. package/dist/swagger/index.js +138 -0
  45. package/package.json +18 -0
  46. package/server.d.ts +2 -0
  47. package/server.js +1 -0
package/LICENSE.txt ADDED
@@ -0,0 +1,159 @@
1
+ Updated Date: October 15, 2024
2
+
3
+ NocoBase License Agreement
4
+
5
+ NOCOBASE PTE. LTD.,a Singaporean Exempt Private Company Limited by Shares with its principal place of business located at #03-01 ROBINSON 112 ("The Company") https://www.nocobase.com/ issues this License Agreement ("Agreement") to you. You, as an individual or a company ("the User"), will be deemed to voluntarily accept all terms of this Agreement by using NocoBase (including but not limited to obtaining NocoBase source code or installation package in any form, installing and using NocoBase, purchasing NocoBase commercial license and services, purchasing NocoBase commercial plugins). If the User does not agree to any term of this Agreement, or cannot accurately understand our interpretation of the relevant terms, please stop using it immediately.
6
+
7
+ This Agreement applies to any use, quotation, contract, invoice, and all software delivered by the Company. The User and the Company or NocoBase's agents can no longer sign a separate license agreement for the sale and delivery of the software.
8
+
9
+ The Company reserves the right to formulate and modify this Agreement from time to time as needed. If there are changes, the Company will announce them in the form of website announcements, without further individual notification. The changed Agreement will automatically take effect once it is announced, becoming part of this Agreement.
10
+
11
+ ==============
12
+ 1. Definitions
13
+ ==============
14
+
15
+ 1.1 "Software" refers to the NocoBase kernel and plugins placed in the same code repository as the kernel, including their source code, installation packages, images, and all their modifications, updates, and upgrades.
16
+
17
+ 1.2 "Community Edition" refers to the free version of the Software provided to the User through public channels.
18
+
19
+ 1.3 "Commercial Edition" refers to the paid version of the Software purchased by the User from the Company or its agents, downloaded through exclusive channels, and includes additional benefits. It consists of three versions: Standard Edition, Professional Edition, and Enterprise Edition.
20
+
21
+ 1.4 "Marketplace" refers to the marketplace provided by the Company for selling Software plugins and solutions.
22
+
23
+ 1.5 "Commercial Plugin" refers to the paid plugins sold in the Marketplace.
24
+
25
+ 1.6 "Upper Layer Application" refers to a specific business use case application serving internal or external customers of the User, developed based on Software and Commercial Plugins, such as ERP/CRM.
26
+
27
+ 1.7 "Customer" refers to the clients who purchase the User's Upper Layer Application.
28
+
29
+ 1.8 "Third-Party Open Source Software" refers to open source software provided with Software and Commercial Plugins. They are licensed through various published open source software licenses or copyright notices accompanying such software.
30
+
31
+ ===================================
32
+ 2. Intellectual Property Protection
33
+ ===================================
34
+
35
+ Except for Third-Party Open Source Software, the Company owns all copyrights, trademark rights, patent rights, trade secrets, and other intellectual property rights of the Software, and has registered and protected them in relevant countries and regions according to the "Paris Convention" or "TRIPS Agreement", ensuring that the intellectual property rights of the Software and Commercial Plugins are internationally recognized and protected.
36
+
37
+ =============
38
+ 3. Disclaimer
39
+ =============
40
+
41
+ 3.1 The User shall not use the Software and Commercial Plugins to engage in activities that violate local laws and regulations, religious beliefs. All legal responsibilities and legal consequences arising from the use of Software and Commercial Plugins shall be borne by the User.
42
+
43
+ 3.2 The Company shall not be liable for any direct, indirect, special, incidental, or consequential damages (including but not limited to loss of profits, business interruption, data loss, or business information disclosure) caused by the User's use of the Software and Commercial Plugins, even if it has been previously informed of the possibility of such damages.
44
+
45
+ ===============
46
+ 4. License Type
47
+ ===============
48
+
49
+ 4.1 The Software uses a dual license type of AGPL-3.0 Open Source License https://www.gnu.org/licenses/agpl-3..en.htm and Commercial License.
50
+
51
+ 4.2 The Community Edition uses the AGPL-3.0 Open Source License https://www.gnu.org/licenses/agpl-3.0.en.html.
52
+
53
+ 4.3 The Commercial Edition (including Standard, Professional, and Enterprise Editions) uses the Commercial License.
54
+
55
+ 4.4 Commercial Plugins use the Commercial Plugin License.
56
+
57
+ ================================================
58
+ 5. Rights and Obligations of Open Source License
59
+ ================================================
60
+
61
+ 5.1 The Software can be used for commercial purposes.
62
+
63
+ 5.2 The User can sell plugins developed for the Software in the Marketplace.
64
+
65
+ 5.3 Outside the Marketplace, changes and plugins to the Software developed by the User or third parties, and third-party applications developed based on the Software must all be open-sourced under the AGPL-3.0 license.
66
+
67
+ 5.4 It is not allowed to remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface, except for the main LOGO in the upper left corner of the page.
68
+
69
+ 5.5 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
70
+
71
+ 5.6 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.
72
+
73
+ 5.7 Comply with all requirements of the AGPL-3.0 agreement.
74
+
75
+ ===============================
76
+ 6. Rights of Commercial License
77
+ ===============================
78
+
79
+ 6.1 Obtain a permanent commercial license of the Software.
80
+
81
+ 6.2 Get 12 months of upgrade and exclusive technical support.
82
+
83
+ 6.3 The licensed Software can be used for commercial purposes with no restrictions on the number of applications and users.
84
+
85
+ 6.4 Changes and plugins to the Software, and applications integrated with the Software do not need to be open sourced.
86
+
87
+ 6.5 Can remove or change the brand, name, link, version number, license, and other information about NocoBase on the Software interface.
88
+
89
+ 6.6 Can sell plugins developed for Software in the Marketplace.
90
+
91
+ 6.7 The User with a Professional or Enterprise Edition License can sell Upper Layer Application to their clients.
92
+
93
+ 6.8 Not restricted by the AGPL-3.0 agreement.
94
+
95
+ 6.9 If there are other agreements in the contract for the above rights, the contract agreement shall prevail.
96
+
97
+ ====================================
98
+ 7. Obligations of Commercial License
99
+ ====================================
100
+
101
+ 7.1 It is not allowed to remove or change all intellectual property statements about NocoBase in the code.
102
+
103
+ 7.2 It is not allowed to sell, transfer, lease, share, or distribute the Commercial License.
104
+
105
+ 7.3 It is not allowed to sell, transfer, lease, share, or distribute any form of no-code, zero-code, low-code platform, or developer tools developed based on Software.
106
+
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
+
109
+ 7.5 It is not allowed for the User with a Standard Edition license to sell Upper Layer Application to clients without a Commercial license.
110
+
111
+ 7.6 It is not allowed to publicly sell plugins developed for Software outside of the Marketplace.
112
+
113
+ 7.7 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.
114
+
115
+ 7.8 If there are other agreements in the contract for the above obligations, the contract agreement shall prevail.
116
+
117
+ ======================================
118
+ 8. Rights of Commercial Plugin License
119
+ ======================================
120
+
121
+ 8.1 Obtain a permanent Commercial Plugin License for the Commercial Plugin.
122
+
123
+ 8.2 Receive 12 months of upgrades and exclusive technical support.
124
+
125
+ 8.3 Can be used for commercial purposes without restrictions on the number of applications or users.
126
+
127
+ 8.4 The User with a Professional or Enterprise Edition License can use the Commercial Plugin in Upper Layer Applications sold to their customers.
128
+
129
+ 8.5 Not restricted by the AGPL-3.0 agreement.
130
+
131
+ 8.6 If there are other agreements in the contract regarding the above rights, the contract agreement shall prevail.
132
+
133
+ ===========================================
134
+ 9. Obligations of Commercial Plugin License
135
+ ===========================================
136
+
137
+ 9.1 It is not allowed to remove or change any intellectual property statements about NocoBase and the plugin authors in the code.
138
+
139
+ 9.2 It is not allowed to sell, transfer, lease, share, or gift the Commercial Plugin.
140
+
141
+ 9.3 It is not allowed to use reverse engineering, decompilation, or other methods to attempt to discover the source code of Commercial Plugins without obtaining a source code license.
142
+
143
+ 9.4 It is not allowed to disclose the source code of Commercial Plugins to any third party.
144
+
145
+ 9.5 If there is any 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.
146
+
147
+ 9.6 If there are other agreements in the contract regarding the above obligations, the contract agreement shall prevail.
148
+
149
+ =============================================================
150
+ 10. Legal Jurisdiction, Interpretation, and Dispute Resolution
151
+ =============================================================
152
+
153
+ 10.1 Except for Mainland China, the interpretation, application, and all matters related to this agreement are subject to the jurisdiction of Singapore law.
154
+
155
+ 10.2 Any dispute related to this Agreement should first be resolved through friendly negotiation. If the negotiation fails to resolve the dispute, the dispute should be submitted to the International Chamber of Commerce (ICC) for arbitration. The arbitration venue should be Singapore, conducted in English.
156
+
157
+ 10.3 All terms and conditions of this Agreement shall be deemed enforceable to the maximum extent permitted by applicable law. If any term of this Agreement is deemed invalid by any applicable law, the invalidity of that term does not affect the validity of any other term of this Agreement, and it should be deemed that the invalid term has been modified as much as possible to make it valid and enforceable, or if the term cannot be modified, it should be deemed to have been deleted from this Agreement.
158
+
159
+ 10.4 The arbitration award is final, binding on both parties, and can be enforced in any court with jurisdiction.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @nocobase/plugin-user-data-sync
package/client.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './dist/client';
2
+ export { default } from './dist/client';
package/client.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client/index.js');
@@ -0,0 +1,12 @@
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
+ import React from 'react';
10
+ export declare const useValuesFromOptions: (options: any) => import("@nocobase/client").UseRequestResult<unknown>;
11
+ export declare const useAdminSettingsForm: (sourceType: string) => any;
12
+ export declare const Options: React.MemoExoticComponent<import("@formily/react").ReactFC<unknown>>;
@@ -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
+ import React from 'react';
10
+ export declare const UserDataSyncSource: React.FC;
@@ -0,0 +1,21 @@
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
+ import { Plugin } from '@nocobase/client';
10
+ import { ComponentType } from 'react';
11
+ export type SourceOptions = {
12
+ components: Partial<{
13
+ AdminSettingsForm: ComponentType;
14
+ }>;
15
+ };
16
+ export declare class PluginUserDataSyncClient extends Plugin {
17
+ sourceTypes: any;
18
+ registerType(sourceType: string, options: SourceOptions): void;
19
+ load(): Promise<void>;
20
+ }
21
+ export default PluginUserDataSyncClient;
@@ -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
+ (function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("@nocobase/utils/client"),require("react-i18next"),require("react/jsx-runtime"),require("antd"),require("react"),require("@ant-design/icons"),require("@formily/react"),require("@formily/core")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","@nocobase/utils/client","react-i18next","react/jsx-runtime","antd","react","@ant-design/icons","@formily/react","@formily/core"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-user-data-sync"]={},o["@nocobase/client"],o["@nocobase/utils"],o["react-i18next"],o.jsxRuntime,o.antd,o.react,o["@ant-design/icons"],o["@formily/react"],o["@formily/core"]))})(this,function(o,e,c,T,r,m,p,b,l,f){"use strict";var X=Object.defineProperty,Z=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var ee=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var k=(o,e,c)=>e in o?X(o,e,{enumerable:!0,configurable:!0,writable:!0,value:c}):o[e]=c,C=(o,e)=>{for(var c in e||(e={}))ee.call(e,c)&&k(o,c,e[c]);if(I)for(var c of I(e))te.call(e,c)&&k(o,c,e[c]);return o},P=(o,e)=>Z(o,$(e));var B=(o,e,c)=>(k(o,typeof e!="symbol"?e+"":e,c),c);var S=(o,e,c)=>new Promise((T,r)=>{var m=l=>{try{b(c.next(l))}catch(f){r(f)}},p=l=>{try{b(c.throw(l))}catch(f){r(f)}},b=l=>l.done?T(l.value):Promise.resolve(l.value).then(m,p);b((c=c.apply(o,e)).next())});const y="user-data-sync";function x(){return T.useTranslation([y,"client"],{nsMode:"fallback"})}const D={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"}}]},w={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}}]},q={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"}}}}}}}}}},V={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:w.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" }}'}}}}}}}}}}}}},N={type:"void",name:"userDataSyncSources","x-component":"CardItem","x-decorator":"TableBlockProvider","x-decorator-props":{collection:D.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"}}}}}}}}},g=p.createContext({type:""});g.displayName="SourceTypeContext";const v=p.createContext({types:[]});v.displayName="SourceTypesContext";const E=()=>{const{types:t}=p.useContext(v);return t},M=t=>{const n=e.useCollectionRecordData(),s=e.useRequest(()=>Promise.resolve({data:C({},n.options)}),P(C({},t),{manual:!0})),{run:i}=s,a=e.useActionContext();return p.useEffect(()=>{a.visible&&i()},[a.visible,i]),s},K=t=>{var i;const s=e.usePlugin(h).sourceTypes.get(t);return(i=s==null?void 0:s.components)==null?void 0:i.AdminSettingsForm},j=l.observer(()=>{const t=l.useForm(),n=e.useCollectionRecordData(),s=K(t.values.sourceType||n.sourceType);return s?r.jsx(s,{}):null},{displayName:"Options"}),O=()=>{const t=e.useCollectionRecordData();return{form:p.useMemo(()=>f.createForm({values:t}),[])}},_=()=>{const{setVisible:t}=e.useActionContext(),n=l.useForm(),s=e.useDataBlockResource(),{runAsync:i}=e.useDataBlockRequest(),a=e.useCollection();return{type:"primary",onClick(){return S(this,null,function*(){yield n.submit();const u=n.values;u[a.filterTargetKey]?yield s.update({values:u,filterByTk:u[a.filterTargetKey]}):yield s.create({values:u}),yield i(),t(!1)})}}};function z(){const t=e.useCollectionRecordData(),n=e.useDataBlockResource(),s=e.useCollection(),{runAsync:i}=e.useDataBlockRequest(),{t:a}=x();return{confirm:{title:a("Delete",{ns:y}),content:a("Are you sure you want to delete it?",{ns:y})},onClick(){return S(this,null,function*(){yield n.destroy({filterByTk:t[s.filterTargetKey]}),yield i()})}}}function L(){const{message:t}=m.App.useApp(),n=e.useCollectionRecordData(),s=e.useAPIClient(),{runAsync:i}=e.useDataBlockRequest(),{t:a}=x();return{onClick(){return S(this,null,function*(){yield s.resource("userData").pull({name:n.name}),yield i(),t.success(a("The synchronization has started. You can click on 'Tasks' to view the synchronization status.",{ns:y}))})}}}const U=()=>{const{type:t}=p.useContext(g);return{form:p.useMemo(()=>f.createForm({initialValues:{sourceType:t}}),[])}},R=()=>{const t=e.useCollectionRecordData(),n=e.useCollection();return{params:{pageSize:20,filter:{sourceId:t[n.filterTargetKey]},sort:["-sort"]}}};function G(){m.App.useApp();const t=e.useCollectionRecordData(),n=e.useCollection(),s=e.useAPIClient(),{runAsync:i}=e.useDataBlockRequest();return x(),{onClick(){return S(this,null,function*(){yield s.resource("userData").retry({id:t[n.filterTargetKey],sourceId:t.sourceId}),yield i()})}}}const Y=()=>{const{t}=x(),n=e.useAPIClient(),[s,i]=p.useState(!1),[a,A]=p.useState(""),u=E(),d=u.map(F=>P(C({},F),{onClick:()=>{i(!0),A(F.value)}})),W=[{key:"__empty__",label:r.jsx(m.Empty,{image:m.Empty.PRESENTED_IMAGE_SIMPLE,description:r.jsxs(r.Fragment,{children:[t("No user data source plugin installed",{ns:y}),r.jsx("br",{})," ",r.jsx("a",{target:"_blank",href:n.auth.locale==="zh-CN"?"https://docs-cn.nocobase.com/handbook/user-data-sync":"https://docs.nocobase.com/handbook/user-data-sync",rel:"noreferrer",children:t("View documentation",{ns:y})})]})}),onClick:()=>{}}];return r.jsx(e.ActionContextProvider,{value:{visible:s,setVisible:i},children:r.jsxs(g.Provider,{value:{type:a},children:[r.jsx(m.Dropdown,{menu:{items:d&&d.length>0?d:W},children:r.jsxs(m.Button,{icon:r.jsx(b.PlusOutlined,{}),type:"primary",children:[t("Add new")," ",r.jsx(b.DownOutlined,{})]})}),r.jsx(e.SchemaComponent,{scope:{types:u,setType:A,useCustomFormProps:U},schema:q})]})})},H=()=>{const{t}=x(),n=e.useCollectionRecordData();return r.jsx(e.ReadPretty.Input,{value:t(n.message),ellipsis:!0})},J=()=>{const{t}=x(),[n,s]=p.useState(!1);return r.jsxs(e.ActionContextProvider,{value:{visible:n,setVisible:s},children:[r.jsx(m.Button,{type:"link",onClick:()=>{s(!0)},children:t("Tasks")}),r.jsx(e.ExtendCollectionsProvider,{collections:[w],children:r.jsx(e.SchemaComponent,{scope:{useRetryActionProps:G,useTasksTableBlockProps:R,t},components:{Message:H},schema:V})})]})},Q=()=>{const{t}=x(),[n,s]=p.useState([]),i=e.useAPIClient();return e.useRequest(()=>i.resource("userData").listSyncTypes().then(a=>{var u;return(((u=a==null?void 0:a.data)==null?void 0:u.data)||[]).map(d=>({key:d.name,label:l.Schema.compile(d.title||d.name,{t}),value:d.name}))}),{onSuccess:a=>{s(a)}}),r.jsx(v.Provider,{value:{types:n},children:r.jsx(e.ExtendCollectionsProvider,{collections:[D],children:r.jsx(e.SchemaComponent,{schema:N,components:{AddNew:Y,Options:j,Tasks:J},scope:{types:n,t,useEditFormProps:O,useSubmitActionProps:_,useDeleteActionProps:z,useSyncActionProps:L,useValuesFromOptions:M}})})})};class h extends e.Plugin{constructor(){super(...arguments);B(this,"sourceTypes",new c.Registry)}registerType(s,i){this.sourceTypes.register(s,i)}load(){return S(this,null,function*(){this.app.pluginSettingsManager.add("users-permissions.sync",{title:c.tval("Synchronize",{ns:y}),icon:"SyncOutlined",Component:Q,sort:99,aclSnippet:"pm.user-data-sync"})})}}o.PluginUserDataSyncClient=h,o.default=h,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -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
+ export declare const NAMESPACE = "user-data-sync";
10
+ export declare function useUserDataSyncSourceTranslation(): import("react-i18next").UseTranslationResponse<("user-data-sync" | "client")[], undefined>;
@@ -0,0 +1,155 @@
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
+ import { ISchema } from '@nocobase/client';
10
+ export declare const sourceCollection: {
11
+ name: string;
12
+ sortable: boolean;
13
+ filterTargetKey: string;
14
+ fields: ({
15
+ name: string;
16
+ type: string;
17
+ interface: string;
18
+ uiSchema?: undefined;
19
+ allowNull?: undefined;
20
+ } | {
21
+ interface: string;
22
+ type: string;
23
+ name: string;
24
+ uiSchema: {
25
+ type: string;
26
+ title: string;
27
+ 'x-component': string;
28
+ required: boolean;
29
+ dataSource?: undefined;
30
+ };
31
+ allowNull?: undefined;
32
+ } | {
33
+ interface: string;
34
+ type: string;
35
+ name: string;
36
+ allowNull: boolean;
37
+ uiSchema: {
38
+ type: string;
39
+ title: string;
40
+ 'x-component': string;
41
+ required: boolean;
42
+ dataSource: string;
43
+ };
44
+ } | {
45
+ type: string;
46
+ name: string;
47
+ uiSchema: {
48
+ type: string;
49
+ title: string;
50
+ 'x-component': string;
51
+ required?: undefined;
52
+ dataSource?: undefined;
53
+ };
54
+ interface?: undefined;
55
+ allowNull?: undefined;
56
+ })[];
57
+ };
58
+ export declare const taskCollection: {
59
+ name: string;
60
+ filterTargetKey: string;
61
+ fields: ({
62
+ name: string;
63
+ type: string;
64
+ interface: string;
65
+ allowNull?: undefined;
66
+ uiSchema?: undefined;
67
+ target?: undefined;
68
+ targetKey?: undefined;
69
+ foreignKey?: undefined;
70
+ } | {
71
+ name: string;
72
+ interface: string;
73
+ type: string;
74
+ allowNull: boolean;
75
+ uiSchema: {
76
+ type: string;
77
+ title: string;
78
+ 'x-component': string;
79
+ required: boolean;
80
+ 'x-component-props'?: undefined;
81
+ 'x-read-pretty'?: undefined;
82
+ enum?: undefined;
83
+ };
84
+ target?: undefined;
85
+ targetKey?: undefined;
86
+ foreignKey?: undefined;
87
+ } | {
88
+ name: string;
89
+ interface: string;
90
+ type: string;
91
+ target: string;
92
+ targetKey: string;
93
+ foreignKey: string;
94
+ allowNull: boolean;
95
+ uiSchema: {
96
+ type: string;
97
+ title: string;
98
+ 'x-component': string;
99
+ 'x-component-props': {
100
+ fieldNames: {
101
+ value: string;
102
+ label: string;
103
+ };
104
+ precision?: undefined;
105
+ };
106
+ required: boolean;
107
+ 'x-read-pretty': boolean;
108
+ enum?: undefined;
109
+ };
110
+ } | {
111
+ name: string;
112
+ interface: string;
113
+ type: string;
114
+ allowNull: boolean;
115
+ uiSchema: {
116
+ type: string;
117
+ title: string;
118
+ 'x-component': string;
119
+ required: boolean;
120
+ enum: {
121
+ label: string;
122
+ value: string;
123
+ color: string;
124
+ }[];
125
+ 'x-component-props'?: undefined;
126
+ 'x-read-pretty'?: undefined;
127
+ };
128
+ target?: undefined;
129
+ targetKey?: undefined;
130
+ foreignKey?: undefined;
131
+ } | {
132
+ name: string;
133
+ interface: string;
134
+ type: string;
135
+ allowNull: boolean;
136
+ uiSchema: {
137
+ type: string;
138
+ title: string;
139
+ 'x-component': string;
140
+ 'x-component-props': {
141
+ precision: number;
142
+ fieldNames?: undefined;
143
+ };
144
+ required: boolean;
145
+ 'x-read-pretty'?: undefined;
146
+ enum?: undefined;
147
+ };
148
+ target?: undefined;
149
+ targetKey?: undefined;
150
+ foreignKey?: undefined;
151
+ })[];
152
+ };
153
+ export declare const createFormSchema: ISchema;
154
+ export declare const tasksTableBlockSchema: ISchema;
155
+ export declare const userDataSyncSourcesSchema: ISchema;
@@ -0,0 +1,24 @@
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
+ /// <reference types="react" />
10
+ export declare const SourceTypeContext: import("react").Context<{
11
+ type: string;
12
+ }>;
13
+ export declare const SourceTypesContext: import("react").Context<{
14
+ types: {
15
+ key: string;
16
+ label: string;
17
+ value: string;
18
+ }[];
19
+ }>;
20
+ export declare const useSourceTypes: () => {
21
+ key: string;
22
+ label: string;
23
+ value: string;
24
+ }[];
@@ -0,0 +1,24 @@
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
+ module.exports = {
11
+ "react": "18.2.0",
12
+ "@formily/react": "2.3.0",
13
+ "@nocobase/client": "1.4.0-alpha",
14
+ "antd": "5.12.8",
15
+ "@ant-design/icons": "5.2.6",
16
+ "@formily/core": "2.3.0",
17
+ "@nocobase/utils": "1.4.0-alpha",
18
+ "@nocobase/server": "1.4.0-alpha",
19
+ "@nocobase/logger": "1.4.0-alpha",
20
+ "@nocobase/actions": "1.4.0-alpha",
21
+ "dayjs": "1.11.10",
22
+ "@nocobase/database": "1.4.0-alpha",
23
+ "react-i18next": "11.18.6"
24
+ };
@@ -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
+ export * from './server';
10
+ export { default, UserDataResource, FormatUser, SyncAccept, OriginRecord, ExternalAPIError, ErrorCodes, } from './server';
package/dist/index.js ADDED
@@ -0,0 +1,60 @@
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
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var src_exports = {};
39
+ __export(src_exports, {
40
+ ErrorCodes: () => import_server.ErrorCodes,
41
+ ExternalAPIError: () => import_server.ExternalAPIError,
42
+ FormatUser: () => import_server.FormatUser,
43
+ OriginRecord: () => import_server.OriginRecord,
44
+ SyncAccept: () => import_server.SyncAccept,
45
+ UserDataResource: () => import_server.UserDataResource,
46
+ default: () => import_server.default
47
+ });
48
+ module.exports = __toCommonJS(src_exports);
49
+ __reExport(src_exports, require("./server"), module.exports);
50
+ var import_server = __toESM(require("./server"));
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ ErrorCodes,
54
+ ExternalAPIError,
55
+ FormatUser,
56
+ OriginRecord,
57
+ SyncAccept,
58
+ UserDataResource,
59
+ ...require("./server")
60
+ });
@@ -0,0 +1,21 @@
1
+ {
2
+ "Synchronize": "Synchronize",
3
+ "Source name": "Source name",
4
+ "Source display name": "Source display name",
5
+ "Type": "Type",
6
+ "Sync": "Sync",
7
+ "Tasks": "Tasks",
8
+ "Batch": "Batch",
9
+ "Status": "Status",
10
+ "Message": "Message",
11
+ "Init": "Init",
12
+ "Processing": "Processing",
13
+ "Success": "Success",
14
+ "Failed": "Failed",
15
+ "Authenticator": "Authenticator",
16
+ "Retry": "Retry",
17
+ "No user data source plugin installed": "No user data source plugin installed",
18
+ "View documentation": "View documentation",
19
+ "The synchronization has started. You can click on 'Tasks' to view the synchronization status.": "The synchronization has started. You can click on 'Tasks' to view the synchronization status.",
20
+ "The sync source API call failed. Please check the logs to troubleshoot the issue.": "The sync source API call failed. Please check the logs to troubleshoot the issue."
21
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "Synchronize": "同步",
3
+ "Source name": "数据源名称",
4
+ "Source display name": "数据源展示名称",
5
+ "Type": "类型",
6
+ "Sync": "同步",
7
+ "Tasks": "任务",
8
+ "Batch": "批次",
9
+ "Status": "状态",
10
+ "Message": "信息",
11
+ "Init": "初始化",
12
+ "Processing": "进行中",
13
+ "Success": "成功",
14
+ "Failed": "失败",
15
+ "Authenticator": "用户认证",
16
+ "dingtalk": "钉钉",
17
+ "wecom": "企业微信",
18
+ "default": "默认",
19
+ "Retry": "重试",
20
+ "No user data source plugin installed": "未安装同步数据源",
21
+ "View documentation": "查看文档",
22
+ "The synchronization has started. You can click on 'Tasks' to view the synchronization status.": "已开始同步,可点击「任务」查看同步任务状态",
23
+ "The sync source API call failed. Please check the logs to troubleshoot the issue.": "同步源 API 调用失败,请查看日志排查问题。"
24
+ }
@@ -0,0 +1,16 @@
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
+ import { Context, Next } from '@nocobase/actions';
10
+ declare const _default: {
11
+ listSyncTypes: (ctx: Context, next: Next) => Promise<void>;
12
+ pull: (ctx: Context, next: Next) => Promise<void>;
13
+ push: (ctx: Context, next: Next) => Promise<void>;
14
+ retry: (ctx: Context, next: Next) => Promise<void>;
15
+ };
16
+ export default _default;