@nocobase/plugin-snapshot-field 1.2.13-alpha → 1.3.0-alpha.20240710084543

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 (33) hide show
  1. package/package.json +2 -2
  2. package/dist/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializers.d.ts +0 -15
  3. package/dist/client/SnapshotBlock/SnapshotBlockInitializers/SnapshotBlockInitializersDetailItem.d.ts +0 -67
  4. package/dist/client/SnapshotBlock/SnapshotBlockProvider.d.ts +0 -10
  5. package/dist/client/SnapshotFieldProvider.d.ts +0 -10
  6. package/dist/client/SnapshotHistoryCollectionProvider.d.ts +0 -12
  7. package/dist/client/SnapshotRecordPicker.d.ts +0 -10
  8. package/dist/client/components/SnapshotOwnerCollectionFieldsSelect.d.ts +0 -21
  9. package/dist/client/index.d.ts +0 -13
  10. package/dist/client/index.js +0 -10
  11. package/dist/client/interface.d.ts +0 -103
  12. package/dist/client/locale/index.d.ts +0 -11
  13. package/dist/externalVersion.js +0 -22
  14. package/dist/index.d.ts +0 -10
  15. package/dist/index.js +0 -48
  16. package/dist/locale/en-US.json +0 -11
  17. package/dist/locale/es-ES.json +0 -11
  18. package/dist/locale/fr-FR.json +0 -11
  19. package/dist/locale/ko_KR.json +0 -14
  20. package/dist/locale/pt-BR.json +0 -11
  21. package/dist/locale/zh-CN.json +0 -13
  22. package/dist/server/collections/collectionsHistory.d.ts +0 -10
  23. package/dist/server/collections/collectionsHistory.js +0 -86
  24. package/dist/server/collections/fieldsHistory.d.ts +0 -10
  25. package/dist/server/collections/fieldsHistory.js +0 -104
  26. package/dist/server/fields/snapshot-field.d.ts +0 -21
  27. package/dist/server/fields/snapshot-field.js +0 -79
  28. package/dist/server/index.d.ts +0 -9
  29. package/dist/server/index.js +0 -42
  30. package/dist/server/plugin.d.ts +0 -21
  31. package/dist/server/plugin.js +0 -137
  32. package/dist/swagger/index.d.ts +0 -16
  33. package/dist/swagger/index.js +0 -38
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "数据表字段:关系快照",
5
5
  "description": "When adding a new record, create a snapshot for its relational record and save in the new record. The snapshot will not be updated when the relational record is updated.",
6
6
  "description.zh-CN": "在添加数据时,为它的关系数据创建快照,并保存在当前的数据中。关系数据更新时,快照不会更新。",
7
- "version": "1.2.13-alpha",
7
+ "version": "1.3.0-alpha.20240710084543",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/field-snapshot",
@@ -26,7 +26,7 @@
26
26
  "@nocobase/test": "1.x",
27
27
  "@nocobase/utils": "1.x"
28
28
  },
29
- "gitHead": "b6a1c2ee330b47c2581ea2ce15ee46210e6220f2",
29
+ "gitHead": "07a8b596fc64a9779a194cb9b0dc2ca7570ed9d4",
30
30
  "keywords": [
31
31
  "Collection fields"
32
32
  ]
@@ -1,15 +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
- import { CompatibleSchemaInitializer } from '@nocobase/client';
10
- /**
11
- * @deprecated
12
- * use `snapshotBlockInitializers` instead
13
- */
14
- export declare const snapshotBlockInitializers_deprecated: CompatibleSchemaInitializer;
15
- export declare const snapshotBlockInitializers: CompatibleSchemaInitializer;
@@ -1,67 +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
- import React from 'react';
10
- export declare const createSnapshotBlockSchema: (options: any) => import("@formily/react").Stringify<{
11
- [key: symbol]: any;
12
- [key: `x-${string}`]: any;
13
- [key: `x-${number}`]: any;
14
- version?: string;
15
- name?: import("@formily/react").SchemaKey;
16
- title?: any;
17
- description?: any;
18
- default?: any;
19
- readOnly?: boolean;
20
- writeOnly?: boolean;
21
- type?: import("@formily/react").SchemaTypes;
22
- enum?: import("@formily/react").SchemaEnum<any>;
23
- const?: any;
24
- multipleOf?: number;
25
- maximum?: number;
26
- exclusiveMaximum?: number;
27
- minimum?: number;
28
- exclusiveMinimum?: number;
29
- maxLength?: number;
30
- minLength?: number;
31
- pattern?: string | RegExp;
32
- maxItems?: number;
33
- minItems?: number;
34
- uniqueItems?: boolean;
35
- maxProperties?: number;
36
- minProperties?: number;
37
- required?: string | boolean | string[];
38
- format?: string;
39
- $ref?: string;
40
- $namespace?: string;
41
- definitions?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
42
- properties?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
43
- items?: import("@formily/react").SchemaItems<any, any, any, any, any, any, any, any>;
44
- additionalItems?: import("@formily/react").Stringify<any>;
45
- patternProperties?: import("@formily/react").SchemaProperties<any, any, any, any, any, any, any, any>;
46
- additionalProperties?: import("@formily/react").Stringify<any>;
47
- "x-value"?: any;
48
- "x-index"?: number;
49
- "x-pattern"?: any;
50
- "x-display"?: any;
51
- "x-validator"?: any;
52
- "x-decorator"?: any;
53
- "x-decorator-props"?: any;
54
- "x-component"?: any;
55
- "x-component-props"?: any;
56
- "x-reactions"?: import("@formily/react").SchemaReactions<any>;
57
- "x-content"?: any;
58
- "x-data"?: any;
59
- "x-visible"?: boolean;
60
- "x-hidden"?: boolean;
61
- "x-disabled"?: boolean;
62
- "x-editable"?: boolean;
63
- "x-read-only"?: boolean;
64
- "x-read-pretty"?: boolean;
65
- "x-compile-omitted"?: string[];
66
- }>;
67
- export declare const SnapshotBlockInitializersDetailItem: () => React.JSX.Element;
@@ -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
- import React from 'react';
10
- export declare const SnapshotBlockProvider: (props: any) => React.JSX.Element;
@@ -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
- import React from 'react';
10
- export declare const SnapshotFieldProvider: React.NamedExoticComponent<object>;
@@ -1,12 +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
- import React from 'react';
10
- export declare const SnapshotHistoryCollectionProvider: React.FC<{
11
- collectionName: string;
12
- }>;
@@ -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
- import React from 'react';
10
- export declare const SnapshotRecordPicker: (props: any) => React.JSX.Element;
@@ -1,21 +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
- import { SelectProps } from 'antd';
10
- import React from 'react';
11
- export type SnapshotOwnerCollectionFieldsSelectProps = Omit<SelectProps, 'options'>;
12
- export declare const useSnapshotOwnerCollectionFields: () => {
13
- label: any;
14
- value: any;
15
- name?: any;
16
- collectionName?: string;
17
- sourceKey?: string;
18
- uiSchema?: any;
19
- target?: string;
20
- }[];
21
- export declare const SnapshotOwnerCollectionFieldsSelect: React.FC<SnapshotOwnerCollectionFieldsSelectProps>;
@@ -1,13 +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
- import { Plugin } from '@nocobase/client';
10
- export declare class PluginSnapshotFieldClient extends Plugin {
11
- load(): Promise<void>;
12
- }
13
- export default PluginSnapshotFieldClient;
@@ -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
- (function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("react"),require("antd"),require("@formily/react"),require("lodash"),require("react-i18next"),require("@ant-design/icons"),require("@formily/shared"),require("@formily/core")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","react","antd","@formily/react","lodash","react-i18next","@ant-design/icons","@formily/shared","@formily/core"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r["@nocobase/plugin-snapshot-field"]={},r["@nocobase/client"],r.jsxRuntime,r.react,r.antd,r["@formily/react"],r.lodash,r["react-i18next"],r["@ant-design/icons"],r["@formily/shared"],r["@formily/core"]))})(this,function(r,e,t,d,v,g,w,b,C,I,J){"use strict";var le=Object.defineProperty,de=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var z=(r,e,t)=>e in r?le(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e)=>{for(var t in e||(e={}))W.call(e,t)&&z(r,t,e[t]);if(_)for(var t of _(e))L.call(e,t)&&z(r,t,e[t]);return r},S=(r,e)=>de(r,pe(e));var M=(r,e)=>{var t={};for(var d in r)W.call(r,d)&&e.indexOf(d)<0&&(t[d]=r[d]);if(r!=null&&_)for(var d of _(r))e.indexOf(d)<0&&L.call(r,d)&&(t[d]=r[d]);return t};var P=(r,e,t)=>(z(r,typeof e!="symbol"?e+"":e,t),t);var q=(r,e,t)=>new Promise((d,v)=>{var g=C=>{try{b(t.next(C))}catch(I){v(I)}},w=C=>{try{b(t.throw(C))}catch(I){v(I)}},b=C=>C.done?d(C.value):Promise.resolve(C.value).then(g,w);b((t=t.apply(r,e)).next())});const k="snapshot-field",{defaultProps:K}=e.interfacesProperties,T="appends",A="targetField",$=()=>{let o=e.useRecord();for(;o!=null&&o.__parent&&Object.keys(o.__parent).length>0;)o=o.__parent;return o};function Q(){var s;const{getCollectionField:o}=e.useCollectionManager_deprecated(),i=$(),a=g.useForm().values;return(s=o(`${i.name}.${a.targetField}`))==null?void 0:s.target}function O(o,i=[]){const{getCollection:a}=e.useCollectionManager_deprecated(),s=[];return o.forEach(n=>{var c,l,u,h;if(["belongsTo","hasOne","hasMany","belongsToMany"].includes(n.type)){const y=i.filter(f=>`${f}.`.startsWith(`${n.name}.`));if(y.length){const f=a(n.target),x=y.filter(p=>p!==n.name).map(p=>p.replace(`${n.name}.`,"")).filter(p=>p);s.push({label:(l=(c=n.uiSchema)==null?void 0:c.title)!=null?l:n.name,value:n.name,children:O(f.fields,x)})}}else s.push({label:(h=(u=n.uiSchema)==null?void 0:u.title)!=null?h:n.name,value:n.name})}),s}const U={type:"void",title:"{{t('View record')}}","x-component":"RecordPicker.Viewer","x-component-props":{className:"nb-action-popup"},properties:{tabs:{type:"void","x-component":"Tabs","x-component-props":{},properties:{tab1:{type:"void",title:"{{t('Detail')}}","x-component":"Tabs.TabPane","x-designer":"Tabs.Designer","x-component-props":{},properties:{grid:{type:"void","x-component":"Grid","x-initializer":"popup:snapshot:addBlock",properties:{}}}}}}}};class X extends e.CollectionFieldInterface{constructor(){super(...arguments);P(this,"name","snapshot");P(this,"type","object");P(this,"group","advanced");P(this,"title",`{{t('Snapshot', {ns: '${k}'})}}`);P(this,"description",`{{t('When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.', {ns: '${k}'})}}`);P(this,"default",{type:"snapshot",uiSchema:{"x-component":"SnapshotRecordPicker","x-component-props":{multiple:!0,fieldNames:{label:"id",value:"id"}}}});P(this,"properties",S(m({},K),{[A]:{type:"string",title:`{{t('The association field to snapshot', {ns: '${k}'})}}`,required:!0,"x-decorator":"FormItem","x-component":"SnapshotOwnerCollectionFieldsSelect","x-disabled":"{{ !createOnly || isOverride }}","x-reactions":[{target:T,when:"{{$self.value != undefined}}",fulfill:{state:{visible:!0}},otherwise:{state:{visible:!1}}}]},[T]:{type:"string",title:`{{t("Snapshot the snapshot's association fields", {ns: "${k}"})}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection:Q},"x-reactions":[{dependencies:[A],when:"{{$deps[0]}}",fulfill:{run:"{{$self.setValue($self.value)}}"}}]}}))}schemaInitialize(a,{field:s,readPretty:n,action:c,block:l}){a.properties={viewer:w.cloneDeep(U)}}initialize(a){}usePathOptions(a){const{appends:s=[],targetCollection:n}=a,{getCollection:c}=e.useCollectionManager_deprecated(),{fields:l}=c(n),u=O(l,s);return[{label:`{{t('Snapshot data', { ns: '${k}' })}}`,value:"data",children:u}]}}const Y=()=>{const o=$(),{getCollection:i}=e.useCollectionManager_deprecated(),a=i(o.name),s=e.useCompile();return a.fields.filter(n=>!!n.target&&!!n.interface).map(n=>{var c;return S(m({},n),{label:s((c=n.uiSchema)==null?void 0:c.title),value:n.name})})},Z=o=>{const i=Y();return t.jsx(v.Select,m({popupMatchSelectWidth:!1,options:i},o))},N=o=>{const f=o,{formItemInitializers:i="details:configureFields",actionInitializers:a="details:configureActions",collection:s,association:n,resource:c,template:l}=f,u=M(f,["formItemInitializers","actionInitializers","collection","association","resource","template"]),h=c||n||s;return{type:"void","x-acl-action":`${h}:get`,"x-decorator":"SnapshotBlockProvider","x-decorator-props":m({resource:h,collection:s,association:n,readPretty:!0,action:"get",useParams:"{{ useParamsFromRecord }}"},u),"x-designer":"FormV2.ReadPrettyDesigner","x-component":"CardItem",properties:{[I.uid()]:{type:"void","x-component":"FormV2","x-use-component-props":"useFormBlockProps","x-read-pretty":!0,properties:{grid:l||{type:"void","x-component":"Grid","x-initializer":i,properties:{}}}}}}},ee=()=>{const o=e.useSchemaInitializerItem(),B=o,{onCreateBlockSchema:i,componentType:a,createBlockSchema:s,icon:n=!0,targetCollection:c}=B,l=M(B,["onCreateBlockSchema","componentType","createBlockSchema","icon","targetCollection"]),{insert:u}=e.useSchemaInitializer(),{getTemplateSchemaByMode:h}=e.useSchemaTemplateManager(),y=c||e.useCollection_deprecated(),f=e.useAssociationName(),{block:x}=e.useBlockRequestContext(),p=x!=="TableField"?o.actionInitializers||"details:configureActions":null;return d.createElement(e.SchemaInitializerItem,S(m({icon:n&&t.jsx(C.FormOutlined,{})},l),{key:"snapshotDetail",onClick:he=>q(this,[he],function*({item:F}){if(F.template){const H=yield h(F);if(F.template.componentName==="ReadPrettyFormItem"){const G=N({actionInitializers:p,association:f,collection:y.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}",template:H});F.mode==="reference"&&(G["x-template-key"]=F.template.key),u(G)}else u(H)}else u(N({actionInitializers:p,association:f,collection:y.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}"}))}),items:e.useRecordCollectionDataSourceItems("ReadPrettyFormItem")}))},oe=o=>{var h;const{action:i,readPretty:a}=o,s=g.useField(),n=d.useMemo(()=>J.createForm({readPretty:a}),[]),{resource:c,service:l}=e.useBlockRequestContext(),u=d.useRef();return l.loading?t.jsx(v.Spin,{}):t.jsx(e.FormBlockContext.Provider,{value:{action:i,form:n,field:s,service:l,resource:c,updateAssociationValues:[],formBlockRef:u},children:a?t.jsx(e.RecordProvider,{record:(h=l==null?void 0:l.data)==null?void 0:h.data,children:t.jsx("div",{ref:u,children:o.children})}):t.jsx("div",{ref:u,children:o.children})})},te=o=>{const i=g.useField(),a=e.useBlockResource(),s={loading:!1,data:{data:e.useRecord()}},n=e.useBlockRequestContext();return t.jsx(e.BlockRequestContext_deprecated.Provider,{value:{block:o.block,props:o,field:i,service:s,resource:a,__parent:n},children:o.children})},re=o=>{const{collection:i,association:a,dataSource:s}=o,n=e.useResource(o);return t.jsx(e.CollectionManagerProvider,{dataSource:s,children:t.jsx(e.MaybeCollectionProvider,{collection:i,children:t.jsx(e.BlockAssociationContext.Provider,{value:a,children:t.jsx(e.BlockResourceContext.Provider,{value:n,children:t.jsx(te,S(m({},o),{children:o.children}))})})})})},ne=o=>{const i=e.useRecord(),{__tableName:a}=i,{getInheritCollections:s}=e.useCollectionManager_deprecated(o.dataSource),n=s(a),{designable:c}=e.useDesignable();return!(!c&&a&&!n.includes(o.collection)&&a!==o.collection)&&t.jsx(re,S(m({},o),{children:t.jsx(oe,m({},o))}))},se=o=>{var y,f,x;const{collectionName:i}=o,{collections:a}=e.useCollectionManager_deprecated(),s=(y=e.useHistoryCollectionsByNames([i]))==null?void 0:y[0],n=e.useHistoryCollectionsByNames((f=s==null?void 0:s.inherits)!=null?f:[]),c=e.useHistoryCollectionsByNames((x=s==null?void 0:s.fields.filter(p=>p.interface!=="snapshot").map(p=>p.target))!=null?x:[]),l=[s,...c,...n].filter(p=>p),h=[...a.filter(p=>!l.map(B=>B.name).includes(p.name)),...l];return t.jsx(e.ExtendCollectionsProvider,{collections:h,children:t.jsx(e.CollectionManagerProvider_deprecated,{children:o.children})})},R=o=>{const i=g.useFieldSchema(),{getField:a}=e.useCollection_deprecated(),s=a(i.name);return t.jsx(se,{collectionName:s==null?void 0:s.targetCollection,children:t.jsx(e.ReadPrettyRecordPicker,m({},o))})},ae=g.connect(R,g.mapReadPretty(R)),ie=o=>{const c=o,{value:i,onChange:a}=c,s=M(c,["value","onChange"]),n=S(m({},s),{value:i==null?void 0:i.data,onChange:l=>a({data:l})});return t.jsx(ae,m({},n))},D=d.memo(o=>t.jsx(e.CollectionHistoryProvider,{children:t.jsx(e.SchemaComponentOptions,{components:{SnapshotRecordPicker:ie,SnapshotBlockProvider:ne,SnapshotBlockInitializersDetailItem:ee,SnapshotOwnerCollectionFieldsSelect:Z},children:o.children})}));D.displayName="SnapshotFieldProvider";const j={wrap:e.gridRowColWrap,title:`{{t("Add block", { ns: "${k}" })}}`,icon:"PlusOutlined",items:[{type:"itemGroup",title:'{{t("Current record blocks")}}',name:"currentRecordBlocks",children:[{name:"details",title:'{{t("Details")}}',Component:"SnapshotBlockInitializersDetailItem",actionInitializers:"details:configureActions"}]},{type:"itemGroup",title:'{{t("Other blocks")}}',name:"otherBlocks",children:[{name:"markdown",title:'{{t("Markdown")}}',Component:"MarkdownBlockInitializer"}]}]},E=new e.CompatibleSchemaInitializer(m({name:"SnapshotBlockInitializers"},j)),ce=new e.CompatibleSchemaInitializer(m({name:"popup:snapshot:addBlock"},j),E);class V extends e.Plugin{load(){return q(this,null,function*(){this.app.use(D),this.app.schemaInitializerManager.add(E),this.app.schemaInitializerManager.add(ce),this.app.dataSourceManager.addFieldInterfaces([X])})}}r.PluginSnapshotFieldClient=V,r.default=V,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,103 +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
- import { ISchema } from '@formily/react';
10
- import { CollectionFieldInterface } from '@nocobase/client';
11
- export declare const useTopRecord: () => any;
12
- declare function useRecordCollection(): any;
13
- export declare class SnapshotFieldInterface extends CollectionFieldInterface {
14
- name: string;
15
- type: string;
16
- group: string;
17
- title: string;
18
- description: string;
19
- default: {
20
- type: string;
21
- uiSchema: {
22
- 'x-component': string;
23
- 'x-component-props': {
24
- multiple: boolean;
25
- fieldNames: {
26
- label: string;
27
- value: string;
28
- };
29
- };
30
- };
31
- };
32
- schemaInitialize(schema: ISchema, { field, readPretty, action, block }: {
33
- field: any;
34
- readPretty: any;
35
- action: any;
36
- block: any;
37
- }): void;
38
- initialize(values: any): void;
39
- usePathOptions(field: any): {
40
- label: string;
41
- value: string;
42
- children: any[];
43
- }[];
44
- properties: {
45
- targetField: {
46
- type: string;
47
- title: string;
48
- required: boolean;
49
- 'x-decorator': string;
50
- 'x-component': string;
51
- 'x-disabled': string;
52
- 'x-reactions': {
53
- target: string;
54
- when: string;
55
- fulfill: {
56
- state: {
57
- visible: boolean;
58
- };
59
- };
60
- otherwise: {
61
- state: {
62
- visible: boolean;
63
- };
64
- };
65
- }[];
66
- };
67
- appends: {
68
- type: string;
69
- title: string;
70
- 'x-decorator': string;
71
- 'x-component': string;
72
- 'x-component-props': {
73
- multiple: boolean;
74
- useCollection: typeof useRecordCollection;
75
- };
76
- 'x-reactions': {
77
- dependencies: string[];
78
- when: string;
79
- fulfill: {
80
- run: string;
81
- };
82
- }[];
83
- };
84
- 'uiSchema.title': {
85
- type: string;
86
- title: string;
87
- required: boolean;
88
- 'x-decorator': string;
89
- 'x-component': string;
90
- };
91
- name: {
92
- type: string;
93
- title: string;
94
- required: boolean;
95
- 'x-disabled': string;
96
- 'x-decorator': string;
97
- 'x-component': string;
98
- 'x-validator': string;
99
- description: string;
100
- };
101
- };
102
- }
103
- export {};
@@ -1,11 +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
- export declare const NAMESPACE = "snapshot-field";
10
- export declare function lang(key: string): string;
11
- export declare function useSnapshotTranslation(): import("react-i18next").UseTranslationResponse<"snapshot-field", undefined>;
@@ -1,22 +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
- module.exports = {
11
- "@nocobase/client": "1.2.13-alpha",
12
- "react": "18.2.0",
13
- "@formily/react": "2.3.0",
14
- "@formily/core": "2.3.0",
15
- "lodash": "4.17.21",
16
- "@nocobase/database": "1.2.13-alpha",
17
- "@nocobase/server": "1.2.13-alpha",
18
- "antd": "5.12.8",
19
- "react-i18next": "11.18.6",
20
- "@ant-design/icons": "5.2.6",
21
- "@formily/shared": "2.3.0"
22
- };
package/dist/index.d.ts DELETED
@@ -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
- export * from './server';
10
- export { default } from './server';
package/dist/index.js DELETED
@@ -1,48 +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
- 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
- default: () => import_server.default
41
- });
42
- module.exports = __toCommonJS(src_exports);
43
- __reExport(src_exports, require("./server"), module.exports);
44
- var import_server = __toESM(require("./server"));
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- ...require("./server")
48
- });
@@ -1,11 +0,0 @@
1
- {
2
- "Detail": "Detail",
3
- "Snapshot": "Snapshot",
4
- "View record": "View record",
5
- "Add block": "Add block",
6
- "Allow linking to multiple records": "Allow linking to multiple records",
7
- "When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.": "When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.",
8
- "The association field to snapshot": "The association field to snapshot",
9
- "Snapshot the snapshot's association fields": "Snapshot the snapshot's association fields",
10
- "Please select": "Please select"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "Detail": "Detalle",
3
- "Snapshot": "Snapshot",
4
- "View record": "Ver registro",
5
- "Add block": "Añadir bloque",
6
- "Allow linking to multiple records": "Permitir enlace a múltiples registros",
7
- "When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.": "Al añadir un nuevo registro, crear una snapshot para su registro relacional y guardar en el registro actual. La snapshot no se actualiza cuando el registro se actualiza posteriormente.",
8
- "The association field to snapshot": "El campo de asociación a la snapshot",
9
- "Snapshot the snapshot's association fields": "Snapshot los campos de asociación de la snapshot",
10
- "Please select": "Por favor, seleccione"
11
- }
@@ -1,11 +0,0 @@
1
- {
2
- "Detail": "Détail",
3
- "Snapshot": "Snapshot",
4
- "View record": "Voir l'enregistrement",
5
- "Add block": "Ajouter un bloc",
6
- "Allow linking to multiple records": "Autoriser la liaison à plusieurs enregistrements",
7
- "When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.": "Lors de l'ajout d'un nouvel enregistrement, créez un snapshot pour son enregistrement relationnel et enregistrez-le dans l'enregistrement actuel. Le snapshot n'est pas mis à jour lorsque l'enregistrement est ultérieurement modifié.",
8
- "The association field to snapshot": "Le champ d'association à un snapshot",
9
- "Snapshot the snapshot's association fields": "Snapshot des champs d'association du snapshot",
10
- "Please select": "Veuillez sélectionner"
11
- }
@@ -1,14 +0,0 @@
1
- {
2
- "Detail": "상세 정보",
3
- "Snapshot": "스냅샷",
4
- "Add block": "블록 추가",
5
- "When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.":
6
- "새로운 레코드를 추가할 때 해당 레코드의 관련 데이터에 대한 스냅샷을 생성하고 현재 레코드에 저장합니다. 레코드가 이후에 업데이트되어도 스냅샷은 업데이트되지 않습니다.",
7
- "View record": "레코드 보기",
8
- "Allow linking to multiple records": "다중 레코드에 연결 허용",
9
- "The association field to snapshot": "스냅샷을 찍을 관련 필드",
10
- "Snapshot the snapshot's association fields": "스냅샷의 관련 필드를 스냅샷으로 만듭니다.",
11
- "Please select": "선택하세요",
12
- "When a record is created, association data is backed up in a snapshot": "레코드가 생성되면 관련 데이터가 스냅샷에 백업됩니다.",
13
- "Snapshot data": "스냅샷 데이터"
14
- }
@@ -1,11 +0,0 @@
1
- {
2
- "Detail": "Detalhes",
3
- "Snapshot": "Fotografia",
4
- "View record": "Visualizar registro",
5
- "Add block": "Adicionar bloco",
6
- "Allow linking to multiple records": "Permitir vinculação a vários registros",
7
- "When adding a new record, create a snapshot for its relational record and save in the current record. The snapshot is not updated when the record is subsequently updated.": "Ao adicionar um novo registro, crie uma imagem instantânea para o registro relacionado e salve no registro atual. A imagem instantânea não é atualizada quando o registro é posteriormente atualizado.",
8
- "The association field to snapshot": "O campo de associação para criar imagem instantânea",
9
- "Snapshot the snapshot's association fields": "Criar imagem instantânea para os campos de associação da imagem instantânea",
10
- "Please select": "Por favor, selecione"
11
- }
@@ -1,13 +0,0 @@
1
- {
2
- "Detail": "详情",
3
- "Snapshot": "快照",
4
- "Add block": "创建区块",
5
- "When adding a new record, create a snapshot for its relational record and save in the new record. The snapshot will not be updated when the relational record is updated.": "在添加数据时,为它的关系数据创建快照,并保存在当前的数据中。关系数据更新时,快照不会更新。",
6
- "View record": "查看数据",
7
- "Allow linking to multiple records": "允许关联多条记录",
8
- "The association field to snapshot": "快照目标关系字段",
9
- "Snapshot the snapshot's association fields": "为快照的关系数据创建快照",
10
- "Please select": "请选择",
11
- "When a record is created, association data is backed up in a snapshot": "创建记录时,关系数据会备份到快照里",
12
- "Snapshot data": "快照数据"
13
- }
@@ -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
- declare const _default: import("@nocobase/database").CollectionOptions;
10
- export default _default;
@@ -1,86 +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
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var collectionsHistory_exports = {};
28
- __export(collectionsHistory_exports, {
29
- default: () => collectionsHistory_default
30
- });
31
- module.exports = __toCommonJS(collectionsHistory_exports);
32
- var import_database = require("@nocobase/database");
33
- var collectionsHistory_default = (0, import_database.defineCollection)({
34
- dumpRules: "required",
35
- name: "collectionsHistory",
36
- sortable: "sort",
37
- autoGenId: false,
38
- model: "CollectionModel",
39
- repository: "CollectionRepository",
40
- timestamps: false,
41
- filterTargetKey: "name",
42
- shared: true,
43
- fields: [
44
- {
45
- type: "uid",
46
- name: "key",
47
- primaryKey: true
48
- },
49
- {
50
- type: "uid",
51
- name: "name",
52
- unique: true,
53
- prefix: "t_"
54
- },
55
- {
56
- type: "string",
57
- name: "title",
58
- required: true
59
- },
60
- {
61
- type: "boolean",
62
- name: "inherit",
63
- defaultValue: false
64
- },
65
- {
66
- type: "boolean",
67
- name: "hidden",
68
- defaultValue: false
69
- },
70
- {
71
- type: "json",
72
- name: "options",
73
- defaultValue: {}
74
- },
75
- {
76
- type: "hasMany",
77
- name: "fields",
78
- target: "fieldsHistory",
79
- sourceKey: "name",
80
- targetKey: "name",
81
- foreignKey: "collectionName",
82
- onDelete: "CASCADE",
83
- sortBy: "sort"
84
- }
85
- ]
86
- });
@@ -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
- declare const _default: import("@nocobase/database").CollectionOptions;
10
- export default _default;
@@ -1,104 +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
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var fieldsHistory_exports = {};
28
- __export(fieldsHistory_exports, {
29
- default: () => fieldsHistory_default
30
- });
31
- module.exports = __toCommonJS(fieldsHistory_exports);
32
- var import_database = require("@nocobase/database");
33
- var fieldsHistory_default = (0, import_database.defineCollection)({
34
- dumpRules: "required",
35
- name: "fieldsHistory",
36
- autoGenId: false,
37
- model: "FieldModel",
38
- timestamps: false,
39
- shared: true,
40
- sortable: {
41
- name: "sort",
42
- scopeKey: "collectionName"
43
- },
44
- indexes: [
45
- {
46
- type: "UNIQUE",
47
- fields: ["collectionName", "name"]
48
- }
49
- ],
50
- fields: [
51
- {
52
- type: "uid",
53
- name: "key",
54
- primaryKey: true
55
- },
56
- {
57
- type: "uid",
58
- name: "name",
59
- prefix: "f_"
60
- },
61
- {
62
- type: "string",
63
- name: "type"
64
- },
65
- {
66
- type: "string",
67
- name: "interface",
68
- allowNull: true
69
- },
70
- {
71
- type: "belongsTo",
72
- name: "collection",
73
- target: "collectionsHistory",
74
- foreignKey: "collectionName",
75
- targetKey: "name",
76
- onDelete: "CASCADE"
77
- },
78
- {
79
- type: "hasMany",
80
- name: "children",
81
- target: "fieldsHistory",
82
- sourceKey: "key",
83
- foreignKey: "parentKey"
84
- },
85
- {
86
- type: "hasOne",
87
- name: "reverseField",
88
- target: "fieldsHistory",
89
- sourceKey: "key",
90
- foreignKey: "reverseKey"
91
- },
92
- // {
93
- // type: 'belongsTo',
94
- // name: 'uiSchema',
95
- // target: 'uiSchemas',
96
- // foreignKey: 'uiSchemaUid',
97
- // },
98
- {
99
- type: "json",
100
- name: "options",
101
- defaultValue: {}
102
- }
103
- ]
104
- });
@@ -1,21 +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
- import { BaseColumnFieldOptions, CreateOptions, DataTypes, Field, Model } from '@nocobase/database';
10
- export declare class SnapshotField extends Field {
11
- get dataType(): DataTypes.AbstractDataTypeConstructor;
12
- createSnapshot: (model: Model, { transaction, values }: CreateOptions) => Promise<void>;
13
- bind(): void;
14
- unbind(): void;
15
- }
16
- export interface SnapshotFieldOptions extends BaseColumnFieldOptions {
17
- type: 'snapshot';
18
- targetField: string;
19
- targetCollection?: string;
20
- appends?: string[];
21
- }
@@ -1,79 +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
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var snapshot_field_exports = {};
28
- __export(snapshot_field_exports, {
29
- SnapshotField: () => SnapshotField
30
- });
31
- module.exports = __toCommonJS(snapshot_field_exports);
32
- var import_database = require("@nocobase/database");
33
- class SnapshotField extends import_database.Field {
34
- get dataType() {
35
- return import_database.DataTypes.JSON;
36
- }
37
- createSnapshot = async (model, { transaction, values }) => {
38
- const { name, targetField } = this.options;
39
- const collectionName = this.collection.name;
40
- const primaryKey = this.collection.model.primaryKeyAttribute;
41
- if (!this.collection.hasField(targetField)) {
42
- return;
43
- }
44
- const repository = this.database.getRepository(`${collectionName}.${targetField}`, model.get(primaryKey));
45
- const appends = (this.options.appends || []).filter(
46
- (appendName) => this.database.getFieldByPath(`${repository.targetCollection.name}.${appendName}`)
47
- );
48
- let data = await repository.find({
49
- transaction,
50
- appends
51
- });
52
- if (Array.isArray(data)) {
53
- data = data.map((i) => i.toJSON());
54
- } else if (data == null ? void 0 : data.toJSON) {
55
- data = data.toJSON();
56
- }
57
- await model.update(
58
- {
59
- [name]: {
60
- collectionName,
61
- data
62
- }
63
- },
64
- { transaction }
65
- );
66
- };
67
- bind() {
68
- super.bind();
69
- this.on("afterCreateWithAssociations", this.createSnapshot);
70
- }
71
- unbind() {
72
- super.unbind();
73
- this.off("afterCreateWithAssociations", this.createSnapshot);
74
- }
75
- }
76
- // Annotate the CommonJS export names for ESM import in node:
77
- 0 && (module.exports = {
78
- SnapshotField
79
- });
@@ -1,9 +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
- export { default } from './plugin';
@@ -1,42 +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
- 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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var server_exports = {};
38
- __export(server_exports, {
39
- default: () => import_plugin.default
40
- });
41
- module.exports = __toCommonJS(server_exports);
42
- var import_plugin = __toESM(require("./plugin"));
@@ -1,21 +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
- import { Model } from '@nocobase/database';
10
- import { InstallOptions, Plugin } from '@nocobase/server';
11
- export declare class PluginSnapshotFieldServer extends Plugin {
12
- afterAdd(): void;
13
- beforeLoad(): Promise<void>;
14
- autoFillTargetCollection: (model: Model) => Promise<void>;
15
- load(): Promise<void>;
16
- install(options?: InstallOptions): Promise<void>;
17
- afterEnable(): Promise<void>;
18
- afterDisable(): Promise<void>;
19
- remove(): Promise<void>;
20
- }
21
- export default PluginSnapshotFieldServer;
@@ -1,137 +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
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var plugin_exports = {};
28
- __export(plugin_exports, {
29
- PluginSnapshotFieldServer: () => PluginSnapshotFieldServer,
30
- default: () => plugin_default
31
- });
32
- module.exports = __toCommonJS(plugin_exports);
33
- var import_server = require("@nocobase/server");
34
- var import_path = require("path");
35
- var import_snapshot_field = require("./fields/snapshot-field");
36
- class PluginSnapshotFieldServer extends import_server.Plugin {
37
- afterAdd() {
38
- }
39
- async beforeLoad() {
40
- const collectionHandler = async (model, { transaction }) => {
41
- const collectionDoc = model.toJSON();
42
- const collectionsHistoryRepository = this.app.db.getRepository("collectionsHistory");
43
- const fieldsHistoryRepository = this.app.db.getRepository("fieldsHistory");
44
- const existCollection = await collectionsHistoryRepository.findOne({
45
- filter: {
46
- name: collectionDoc.name
47
- },
48
- transaction
49
- });
50
- if (existCollection) {
51
- await existCollection.destroy({
52
- transaction
53
- });
54
- }
55
- await collectionsHistoryRepository.create({
56
- values: collectionDoc,
57
- transaction
58
- });
59
- };
60
- this.app.db.on("collections.afterCreateWithAssociations", collectionHandler);
61
- const deleteField = async (field, transaction) => {
62
- const fieldsHistoryRepository = this.app.db.getRepository("fieldsHistory");
63
- const { name, collectionName } = field;
64
- await fieldsHistoryRepository.destroy({
65
- filter: { name, collectionName },
66
- transaction
67
- });
68
- };
69
- const fieldHandler = async (model, { transaction }) => {
70
- const fieldsHistoryRepository = this.app.db.getRepository("fieldsHistory");
71
- const fieldDoc = model.get();
72
- await deleteField(fieldDoc, transaction);
73
- const reverseField = fieldDoc.reverseField;
74
- if (reverseField) {
75
- await deleteField(reverseField, transaction);
76
- }
77
- await fieldsHistoryRepository.create({
78
- values: JSON.parse(JSON.stringify(fieldDoc)),
79
- transaction
80
- });
81
- };
82
- this.app.db.on("fields.afterCreateWithAssociations", fieldHandler);
83
- this.app.db.on("fields.beforeCreate", this.autoFillTargetCollection);
84
- }
85
- autoFillTargetCollection = async (model) => {
86
- const { collectionName, targetField } = model.get();
87
- const collection = this.db.getCollection(collectionName);
88
- if (!collection) {
89
- return;
90
- }
91
- const field = collection.getField(targetField);
92
- if (field == null ? void 0 : field.target) {
93
- model.set("targetCollection", field.target);
94
- }
95
- };
96
- async load() {
97
- await this.importCollections((0, import_path.resolve)(__dirname, "collections"));
98
- this.app.db.registerFieldTypes({
99
- snapshot: import_snapshot_field.SnapshotField
100
- });
101
- this.app.acl.allow("collectionsHistory", "list", "loggedIn");
102
- }
103
- // 初始化安装的时候
104
- async install(options) {
105
- await this.app.db.sequelize.transaction(async (transaction) => {
106
- const collectionsRepository = this.app.db.getRepository("collections");
107
- const collectionsHistoryRepository = this.app.db.getRepository("collectionsHistory");
108
- if ((await collectionsHistoryRepository.find()).length === 0) {
109
- const collectionsModels = await collectionsRepository.find();
110
- await collectionsHistoryRepository.createMany({
111
- records: collectionsModels.map((m) => m.get()),
112
- transaction
113
- });
114
- }
115
- const fieldsRepository = this.app.db.getRepository("fields");
116
- const fieldsHistoryRepository = this.app.db.getRepository("fieldsHistory");
117
- if ((await fieldsHistoryRepository.find()).length === 0) {
118
- const fieldsModels = await fieldsRepository.find();
119
- await fieldsHistoryRepository.createMany({
120
- records: fieldsModels.map((m) => m.get()),
121
- transaction
122
- });
123
- }
124
- });
125
- }
126
- async afterEnable() {
127
- }
128
- async afterDisable() {
129
- }
130
- async remove() {
131
- }
132
- }
133
- var plugin_default = PluginSnapshotFieldServer;
134
- // Annotate the CommonJS export names for ESM import in node:
135
- 0 && (module.exports = {
136
- PluginSnapshotFieldServer
137
- });
@@ -1,16 +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
- declare const _default: {
10
- info: {
11
- title: string;
12
- };
13
- tags: any[];
14
- paths: {};
15
- };
16
- export default _default;
@@ -1,38 +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
- var __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var swagger_exports = {};
28
- __export(swagger_exports, {
29
- default: () => swagger_default
30
- });
31
- module.exports = __toCommonJS(swagger_exports);
32
- var swagger_default = {
33
- info: {
34
- title: "NocoBase API - Snapshot field plugin"
35
- },
36
- tags: [],
37
- paths: {}
38
- };