@nocobase/plugin-snapshot-field 0.12.0-alpha.5 → 0.13.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,511 +1 @@
1
- (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@nocobase/client"), 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", "antd", "@formily/react", "lodash", "react-i18next", "@ant-design/icons", "@formily/shared", "@formily/core"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@nocobase/plugin-snapshot-field"] = {}, global["@nocobase/client"], global.react, global.antd, global["@formily/react"], global.lodash, global["react-i18next"], global["@ant-design/icons"], global["@formily/shared"], global["@formily/core"]));
3
- })(this, function(exports2, client, require$$0, antd, react, lodash, reactI18next, icons, shared, core) {
4
- "use strict";
5
- var jsxRuntime = { exports: {} };
6
- var reactJsxRuntime_production_min = {};
7
- /**
8
- * @license React
9
- * react-jsx-runtime.production.min.js
10
- *
11
- * Copyright (c) Facebook, Inc. and its affiliates.
12
- *
13
- * This source code is licensed under the MIT license found in the
14
- * LICENSE file in the root directory of this source tree.
15
- */
16
- var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
17
- function q(c, a, g) {
18
- var b, d = {}, e = null, h = null;
19
- void 0 !== g && (e = "" + g);
20
- void 0 !== a.key && (e = "" + a.key);
21
- void 0 !== a.ref && (h = a.ref);
22
- for (b in a)
23
- m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
24
- if (c && c.defaultProps)
25
- for (b in a = c.defaultProps, a)
26
- void 0 === d[b] && (d[b] = a[b]);
27
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
28
- }
29
- reactJsxRuntime_production_min.Fragment = l;
30
- reactJsxRuntime_production_min.jsx = q;
31
- reactJsxRuntime_production_min.jsxs = q;
32
- {
33
- jsxRuntime.exports = reactJsxRuntime_production_min;
34
- }
35
- var jsxRuntimeExports = jsxRuntime.exports;
36
- const NAMESPACE = "snapshot-field";
37
- function useSnapshotTranslation() {
38
- return reactI18next.useTranslation(NAMESPACE);
39
- }
40
- const { defaultProps } = client.interfacesProperties;
41
- const APPENDS = "appends";
42
- const TARGET_FIELD = "targetField";
43
- const useTopRecord = () => {
44
- let record = client.useRecord();
45
- while (record && Object.keys(record.__parent).length > 0) {
46
- record = record.__parent;
47
- }
48
- return record;
49
- };
50
- function useRecordCollection() {
51
- var _a;
52
- const { getCollectionField } = client.useCollectionManager();
53
- const record = useTopRecord();
54
- const formValues = react.useForm().values;
55
- return (_a = getCollectionField(`${record.name}.${formValues.targetField}`)) == null ? void 0 : _a.target;
56
- }
57
- function MakeFieldsPathOptions(fields, appends = []) {
58
- const { getCollection } = client.useCollectionManager();
59
- const options = [];
60
- fields.forEach((field) => {
61
- var _a, _b;
62
- if (["belongsTo", "hasOne", "hasMany", "belongsToMany"].includes(field.type)) {
63
- const currentAppends = appends.filter((key) => `${key}.`.startsWith(`${field.name}.`));
64
- if (currentAppends.length) {
65
- const nextCollection = getCollection(field.target);
66
- const nextAppends = currentAppends.filter((key) => key !== field.name).map((key) => key.replace(`${field.name}.`, "")).filter((key) => key);
67
- options.push({
68
- label: ((_a = field.uiSchema) == null ? void 0 : _a.title) ?? field.name,
69
- value: field.name,
70
- children: MakeFieldsPathOptions(nextCollection.fields, nextAppends)
71
- });
72
- }
73
- } else {
74
- options.push({
75
- label: ((_b = field.uiSchema) == null ? void 0 : _b.title) ?? field.name,
76
- value: field.name
77
- });
78
- }
79
- });
80
- return options;
81
- }
82
- const recordPickerViewer = {
83
- type: "void",
84
- title: `{{t('View record')}}`,
85
- "x-component": "RecordPicker.Viewer",
86
- "x-component-props": {
87
- className: "nb-action-popup"
88
- },
89
- properties: {
90
- tabs: {
91
- type: "void",
92
- "x-component": "Tabs",
93
- "x-component-props": {},
94
- // 'x-initializer': 'TabPaneInitializers',
95
- properties: {
96
- tab1: {
97
- type: "void",
98
- title: `{{t('Detail')}}`,
99
- "x-component": "Tabs.TabPane",
100
- "x-designer": "Tabs.Designer",
101
- "x-component-props": {},
102
- properties: {
103
- grid: {
104
- type: "void",
105
- "x-component": "Grid",
106
- "x-initializer": "SnapshotBlockInitializers",
107
- properties: {}
108
- }
109
- }
110
- }
111
- }
112
- }
113
- }
114
- };
115
- const snapshot = {
116
- name: "snapshot",
117
- type: "object",
118
- group: "advanced",
119
- title: `{{t('Snapshot', {ns: '${NAMESPACE}'})}}`,
120
- 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: '${NAMESPACE}'})}}`,
121
- default: {
122
- type: "snapshot",
123
- // name,
124
- uiSchema: {
125
- // title,
126
- "x-component": "SnapshotRecordPicker",
127
- "x-component-props": {
128
- multiple: true,
129
- fieldNames: {
130
- label: "id",
131
- value: "id"
132
- }
133
- }
134
- }
135
- },
136
- schemaInitialize(schema, { field, readPretty, action, block }) {
137
- schema["properties"] = {
138
- viewer: lodash.cloneDeep(recordPickerViewer)
139
- };
140
- },
141
- initialize: (values) => {
142
- },
143
- usePathOptions(field) {
144
- const { appends = [], targetCollection } = field;
145
- const { getCollection } = client.useCollectionManager();
146
- const { fields } = getCollection(targetCollection);
147
- const result = MakeFieldsPathOptions(fields, appends);
148
- return [
149
- {
150
- label: `{{t('Snapshot data', { ns: '${NAMESPACE}' })}}`,
151
- value: "data",
152
- children: result
153
- }
154
- ];
155
- },
156
- properties: {
157
- ...defaultProps,
158
- [TARGET_FIELD]: {
159
- type: "string",
160
- title: `{{t('The association field to snapshot', {ns: '${NAMESPACE}'})}}`,
161
- required: true,
162
- "x-decorator": "FormItem",
163
- "x-component": "SnapshotOwnerCollectionFieldsSelect",
164
- "x-disabled": "{{ !createOnly || isOverride }}",
165
- "x-reactions": [
166
- {
167
- target: APPENDS,
168
- when: "{{$self.value != undefined}}",
169
- fulfill: {
170
- state: {
171
- visible: true
172
- }
173
- },
174
- otherwise: {
175
- state: {
176
- visible: false
177
- }
178
- }
179
- }
180
- ]
181
- },
182
- [APPENDS]: {
183
- type: "string",
184
- title: `{{t("Snapshot the snapshot's association fields", {ns: "${NAMESPACE}"})}}`,
185
- "x-decorator": "FormItem",
186
- "x-component": "AppendsTreeSelect",
187
- "x-component-props": {
188
- multiple: true,
189
- useCollection: useRecordCollection
190
- },
191
- "x-reactions": [
192
- {
193
- dependencies: [TARGET_FIELD],
194
- when: "{{$deps[0]}}",
195
- fulfill: {
196
- run: "{{$self.setValue($self.value)}}"
197
- }
198
- }
199
- ]
200
- }
201
- }
202
- };
203
- const useSnapshotOwnerCollectionFields = () => {
204
- const record = useTopRecord();
205
- const { getCollection } = client.useCollectionManager();
206
- const collection = getCollection(record.name);
207
- const compile = client.useCompile();
208
- return collection.fields.filter((i) => !!i.target && !!i.interface).map((i) => {
209
- var _a;
210
- return { ...i, label: compile((_a = i.uiSchema) == null ? void 0 : _a.title), value: i.name };
211
- });
212
- };
213
- const SnapshotOwnerCollectionFieldsSelect = (props) => {
214
- const options = useSnapshotOwnerCollectionFields();
215
- return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Select, { popupMatchSelectWidth: false, options, ...props });
216
- };
217
- const SnapshotBlockInitializers = (props) => {
218
- const { t } = useSnapshotTranslation();
219
- const { insertPosition, component } = props;
220
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
221
- client.SchemaInitializer.Button,
222
- {
223
- wrap: client.gridRowColWrap,
224
- insertPosition,
225
- component,
226
- title: component ? null : t("Add block"),
227
- icon: "PlusOutlined",
228
- items: [
229
- {
230
- type: "itemGroup",
231
- title: '{{t("Current record blocks")}}',
232
- children: [
233
- {
234
- key: "details",
235
- type: "item",
236
- title: '{{t("Details")}}',
237
- component: "SnapshotBlockInitializersDetailItem",
238
- actionInitializers: "CalendarFormActionInitializers"
239
- }
240
- ]
241
- },
242
- {
243
- type: "itemGroup",
244
- title: '{{t("Other blocks")}}',
245
- children: [
246
- {
247
- key: "markdown",
248
- type: "item",
249
- title: '{{t("Markdown")}}',
250
- component: "MarkdownBlockInitializer"
251
- }
252
- ]
253
- }
254
- ]
255
- }
256
- );
257
- };
258
- const createSnapshotBlockSchema = (options) => {
259
- const {
260
- formItemInitializers = "ReadPrettyFormItemInitializers",
261
- actionInitializers = "ReadPrettyFormActionInitializers",
262
- collection,
263
- association,
264
- resource,
265
- template,
266
- ...others
267
- } = options;
268
- const resourceName = resource || association || collection;
269
- const schema = {
270
- type: "void",
271
- "x-acl-action": `${resourceName}:get`,
272
- "x-decorator": "SnapshotBlockProvider",
273
- "x-decorator-props": {
274
- resource: resourceName,
275
- collection,
276
- association,
277
- readPretty: true,
278
- action: "get",
279
- useParams: "{{ useParamsFromRecord }}",
280
- ...others
281
- },
282
- "x-designer": "FormV2.ReadPrettyDesigner",
283
- "x-component": "CardItem",
284
- properties: {
285
- [shared.uid()]: {
286
- type: "void",
287
- "x-component": "FormV2",
288
- "x-read-pretty": true,
289
- "x-component-props": {
290
- useProps: "{{ useFormBlockProps }}"
291
- },
292
- properties: {
293
- grid: template || {
294
- type: "void",
295
- "x-component": "Grid",
296
- "x-initializer": formItemInitializers,
297
- properties: {}
298
- }
299
- }
300
- }
301
- }
302
- };
303
- console.log(JSON.stringify(schema, null, 2));
304
- return schema;
305
- };
306
- const SnapshotBlockInitializersDetailItem = (props) => {
307
- const {
308
- onCreateBlockSchema,
309
- componentType,
310
- createBlockSchema,
311
- insert,
312
- icon = true,
313
- targetCollection,
314
- ...others
315
- } = props;
316
- const { getTemplateSchemaByMode } = client.useSchemaTemplateManager();
317
- const collection = targetCollection || client.useCollection();
318
- const association = client.useBlockAssociationContext();
319
- const { block } = client.useBlockRequestContext();
320
- const actionInitializers = block !== "TableField" ? props.actionInitializers || "ReadPrettyFormActionInitializers" : null;
321
- return /* @__PURE__ */ require$$0.createElement(
322
- client.SchemaInitializer.Item,
323
- {
324
- icon: icon && /* @__PURE__ */ jsxRuntimeExports.jsx(icons.FormOutlined, {}),
325
- ...others,
326
- key: "snapshotDetail",
327
- onClick: async ({ item }) => {
328
- if (item.template) {
329
- const s = await getTemplateSchemaByMode(item);
330
- if (item.template.componentName === "ReadPrettyFormItem") {
331
- const blockSchema = createSnapshotBlockSchema({
332
- actionInitializers,
333
- association,
334
- collection: collection.name,
335
- action: "get",
336
- useSourceId: "{{ useSourceIdFromParentRecord }}",
337
- useParams: "{{ useParamsFromRecord }}",
338
- template: s
339
- });
340
- if (item.mode === "reference") {
341
- blockSchema["x-template-key"] = item.template.key;
342
- }
343
- insert(blockSchema);
344
- } else {
345
- insert(s);
346
- }
347
- } else {
348
- insert(
349
- createSnapshotBlockSchema({
350
- actionInitializers,
351
- association,
352
- collection: collection.name,
353
- action: "get",
354
- useSourceId: "{{ useSourceIdFromParentRecord }}",
355
- useParams: "{{ useParamsFromRecord }}"
356
- })
357
- );
358
- }
359
- },
360
- items: client.useRecordCollectionDataSourceItems("ReadPrettyFormItem")
361
- }
362
- );
363
- };
364
- const InternalFormBlockProvider = (props) => {
365
- var _a;
366
- const { action, readPretty } = props;
367
- const field = react.useField();
368
- const form = require$$0.useMemo(
369
- () => core.createForm({
370
- readPretty
371
- }),
372
- []
373
- );
374
- const { resource, service } = client.useBlockRequestContext();
375
- const formBlockRef = require$$0.useRef();
376
- if (service.loading) {
377
- return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Spin, {});
378
- }
379
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
380
- client.FormBlockContext.Provider,
381
- {
382
- value: {
383
- action,
384
- form,
385
- field,
386
- service,
387
- resource,
388
- updateAssociationValues: [],
389
- formBlockRef
390
- },
391
- children: readPretty ? /* @__PURE__ */ jsxRuntimeExports.jsx(client.RecordProvider, { record: (_a = service == null ? void 0 : service.data) == null ? void 0 : _a.data, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: formBlockRef, children: props.children }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: formBlockRef, children: props.children })
392
- }
393
- );
394
- };
395
- const BlockRequestProvider = (props) => {
396
- const field = react.useField();
397
- const resource = client.useBlockResource();
398
- const service = {
399
- loading: false,
400
- data: {
401
- data: client.useRecord()
402
- }
403
- };
404
- const __parent = require$$0.useContext(client.BlockRequestContext);
405
- return /* @__PURE__ */ jsxRuntimeExports.jsx(client.BlockRequestContext.Provider, { value: { block: props.block, props, field, service, resource, __parent }, children: props.children });
406
- };
407
- const BlockProvider = (props) => {
408
- const { collection, association } = props;
409
- const resource = client.useResource(props);
410
- return /* @__PURE__ */ jsxRuntimeExports.jsx(client.MaybeCollectionProvider, { collection, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.BlockAssociationContext.Provider, { value: association, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.BlockResourceContext.Provider, { value: resource, children: /* @__PURE__ */ jsxRuntimeExports.jsx(BlockRequestProvider, { ...props, children: props.children }) }) }) });
411
- };
412
- const SnapshotBlockProvider = (props) => {
413
- const record = client.useRecord();
414
- const { __tableName } = record;
415
- const { getInheritCollections } = client.useCollectionManager();
416
- const inheritCollections = getInheritCollections(__tableName);
417
- const { designable } = client.useDesignable();
418
- const flag = !designable && __tableName && !inheritCollections.includes(props.collection) && __tableName !== props.collection;
419
- return !flag && /* @__PURE__ */ jsxRuntimeExports.jsx(BlockProvider, { ...props, children: /* @__PURE__ */ jsxRuntimeExports.jsx(InternalFormBlockProvider, { ...props }) });
420
- };
421
- const SnapshotHistoryCollectionProvider = (props) => {
422
- var _a;
423
- const { collectionName } = props;
424
- const { collections: allCollections, ...rest } = require$$0.useContext(client.CollectionManagerContext);
425
- const snapshotTargetCollection = (_a = client.useHistoryCollectionsByNames([collectionName])) == null ? void 0 : _a[0];
426
- const inheritCollections = client.useHistoryCollectionsByNames((snapshotTargetCollection == null ? void 0 : snapshotTargetCollection.inherits) ?? []);
427
- const associationFieldTargetCollections = client.useHistoryCollectionsByNames(
428
- (snapshotTargetCollection == null ? void 0 : snapshotTargetCollection.fields.filter((i) => i.interface !== "snapshot").map((i) => i.target)) ?? []
429
- );
430
- const finallyHistoryCollecionts = [
431
- snapshotTargetCollection,
432
- ...associationFieldTargetCollections,
433
- ...inheritCollections
434
- ].filter((i) => i);
435
- const filterdAllCollection = allCollections.filter(
436
- (c) => !finallyHistoryCollecionts.map((i) => i.name).includes(c.name)
437
- );
438
- const overridedCollections = [...filterdAllCollection, ...finallyHistoryCollecionts];
439
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
440
- client.CollectionManagerContext.Provider,
441
- {
442
- value: {
443
- ...rest,
444
- collections: overridedCollections
445
- },
446
- children: props.children
447
- }
448
- );
449
- };
450
- const ReadPrettyRecordPickerWrapper = (props) => {
451
- const fieldSchema = react.useFieldSchema();
452
- const { getField } = client.useCollection();
453
- const collectionField = getField(fieldSchema.name);
454
- return /* @__PURE__ */ jsxRuntimeExports.jsx(SnapshotHistoryCollectionProvider, { collectionName: collectionField == null ? void 0 : collectionField.targetCollection, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.ReadPrettyRecordPicker, { ...props }) });
455
- };
456
- const SnapshotRecordPickerInner = react.connect(
457
- ReadPrettyRecordPickerWrapper,
458
- react.mapReadPretty(ReadPrettyRecordPickerWrapper)
459
- );
460
- const SnapshotRecordPicker = (props) => {
461
- const { value, onChange, ...restProps } = props;
462
- const newProps = {
463
- ...restProps,
464
- value: value == null ? void 0 : value.data,
465
- onChange: (value2) => onChange({ data: value2 })
466
- };
467
- return /* @__PURE__ */ jsxRuntimeExports.jsx(SnapshotRecordPickerInner, { ...newProps });
468
- };
469
- const SnapshotFieldProvider = require$$0.memo((props) => {
470
- require$$0.useEffect(() => {
471
- client.registerField(snapshot.group, snapshot.name, snapshot);
472
- }, []);
473
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
474
- client.CollectionManagerProvider,
475
- {
476
- interfaces: {
477
- snapshot
478
- },
479
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.CollectionHistoryProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
480
- client.SchemaInitializerProvider,
481
- {
482
- initializers: {
483
- SnapshotBlockInitializers
484
- },
485
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
486
- client.SchemaComponentOptions,
487
- {
488
- components: {
489
- SnapshotRecordPicker,
490
- SnapshotBlockProvider,
491
- SnapshotBlockInitializersDetailItem,
492
- SnapshotOwnerCollectionFieldsSelect
493
- },
494
- children: props.children
495
- }
496
- )
497
- }
498
- ) })
499
- }
500
- );
501
- });
502
- SnapshotFieldProvider.displayName = "SnapshotFieldProvider";
503
- class SnapshotFieldPlugin extends client.Plugin {
504
- async load() {
505
- this.app.use(SnapshotFieldProvider);
506
- }
507
- }
508
- exports2.SnapshotFieldPlugin = SnapshotFieldPlugin;
509
- exports2.default = SnapshotFieldPlugin;
510
- Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
511
- });
1
+ (function(n,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):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@nocobase/plugin-snapshot-field"]={},n["@nocobase/client"],n.jsxRuntime,n.react,n.antd,n["@formily/react"],n.lodash,n["react-i18next"],n["@ant-design/icons"],n["@formily/shared"],n["@formily/core"]))})(this,function(n,e,r,l,v,g,w,F,C,I,W){"use strict";var ce=Object.defineProperty,le=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var V=(n,e,r)=>e in n?ce(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r,m=(n,e)=>{for(var r in e||(e={}))H.call(e,r)&&V(n,r,e[r]);if(M)for(var r of M(e))G.call(e,r)&&V(n,r,e[r]);return n},S=(n,e)=>le(n,de(e));var B=(n,e)=>{var r={};for(var l in n)H.call(n,l)&&e.indexOf(l)<0&&(r[l]=n[l]);if(n!=null&&M)for(var l of M(n))e.indexOf(l)<0&&G.call(n,l)&&(r[l]=n[l]);return r};var T=(n,e,r)=>new Promise((l,v)=>{var g=C=>{try{F(r.next(C))}catch(I){v(I)}},w=C=>{try{F(r.throw(C))}catch(I){v(I)}},F=C=>C.done?l(C.value):Promise.resolve(C.value).then(g,w);F((r=r.apply(n,e)).next())});const x="snapshot-field";function J(){return F.useTranslation(x)}const{defaultProps:L}=e.interfacesProperties,q="appends",A="targetField",O=()=>{let o=e.useRecord();for(;o&&Object.keys(o.__parent).length>0;)o=o.__parent;return o};function K(){var s;const{getCollectionField:o}=e.useCollectionManager(),i=O(),a=g.useForm().values;return(s=o(`${i.name}.${a.targetField}`))==null?void 0:s.target}function $(o,i=[]){const{getCollection:a}=e.useCollectionManager(),s=[];return o.forEach(t=>{var c,d,u,f;if(["belongsTo","hasOne","hasMany","belongsToMany"].includes(t.type)){const P=i.filter(h=>`${h}.`.startsWith(`${t.name}.`));if(P.length){const h=a(t.target),k=P.filter(y=>y!==t.name).map(y=>y.replace(`${t.name}.`,"")).filter(y=>y);s.push({label:(d=(c=t.uiSchema)==null?void 0:c.title)!=null?d:t.name,value:t.name,children:$(h.fields,k)})}}else s.push({label:(f=(u=t.uiSchema)==null?void 0:u.title)!=null?f:t.name,value:t.name})}),s}const Q={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":"SnapshotBlockInitializers",properties:{}}}}}}}},z={name:"snapshot",type:"object",group:"advanced",title:`{{t('Snapshot', {ns: '${x}'})}}`,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: '${x}'})}}`,default:{type:"snapshot",uiSchema:{"x-component":"SnapshotRecordPicker","x-component-props":{multiple:!0,fieldNames:{label:"id",value:"id"}}}},schemaInitialize(o,{field:i,readPretty:a,action:s,block:t}){o.properties={viewer:w.cloneDeep(Q)}},initialize:o=>{},usePathOptions(o){const{appends:i=[],targetCollection:a}=o,{getCollection:s}=e.useCollectionManager(),{fields:t}=s(a),c=$(t,i);return[{label:`{{t('Snapshot data', { ns: '${x}' })}}`,value:"data",children:c}]},properties:S(m({},L),{[A]:{type:"string",title:`{{t('The association field to snapshot', {ns: '${x}'})}}`,required:!0,"x-decorator":"FormItem","x-component":"SnapshotOwnerCollectionFieldsSelect","x-disabled":"{{ !createOnly || isOverride }}","x-reactions":[{target:q,when:"{{$self.value != undefined}}",fulfill:{state:{visible:!0}},otherwise:{state:{visible:!1}}}]},[q]:{type:"string",title:`{{t("Snapshot the snapshot's association fields", {ns: "${x}"})}}`,"x-decorator":"FormItem","x-component":"AppendsTreeSelect","x-component-props":{multiple:!0,useCollection:K},"x-reactions":[{dependencies:[A],when:"{{$deps[0]}}",fulfill:{run:"{{$self.setValue($self.value)}}"}}]}})},U=()=>{const o=O(),{getCollection:i}=e.useCollectionManager(),a=i(o.name),s=e.useCompile();return a.fields.filter(t=>!!t.target&&!!t.interface).map(t=>{var c;return S(m({},t),{label:s((c=t.uiSchema)==null?void 0:c.title),value:t.name})})},X=o=>{const i=U();return r.jsx(v.Select,m({popupMatchSelectWidth:!1,options:i},o))},Y=o=>{const{t:i}=J(),{insertPosition:a,component:s}=o;return r.jsx(e.SchemaInitializer.Button,{wrap:e.gridRowColWrap,insertPosition:a,component:s,title:s?null:i("Add block"),icon:"PlusOutlined",items:[{type:"itemGroup",title:'{{t("Current record blocks")}}',children:[{key:"details",type:"item",title:'{{t("Details")}}',component:"SnapshotBlockInitializersDetailItem",actionInitializers:"CalendarFormActionInitializers"}]},{type:"itemGroup",title:'{{t("Other blocks")}}',children:[{key:"markdown",type:"item",title:'{{t("Markdown")}}',component:"MarkdownBlockInitializer"}]}]})},N=o=>{const h=o,{formItemInitializers:i="ReadPrettyFormItemInitializers",actionInitializers:a="ReadPrettyFormActionInitializers",collection:s,association:t,resource:c,template:d}=h,u=B(h,["formItemInitializers","actionInitializers","collection","association","resource","template"]),f=c||t||s,P={type:"void","x-acl-action":`${f}:get`,"x-decorator":"SnapshotBlockProvider","x-decorator-props":m({resource:f,collection:s,association:t,readPretty:!0,action:"get",useParams:"{{ useParamsFromRecord }}"},u),"x-designer":"FormV2.ReadPrettyDesigner","x-component":"CardItem",properties:{[I.uid()]:{type:"void","x-component":"FormV2","x-read-pretty":!0,"x-component-props":{useProps:"{{ useFormBlockProps }}"},properties:{grid:d||{type:"void","x-component":"Grid","x-initializer":i,properties:{}}}}}};return console.log(JSON.stringify(P,null,2)),P},Z=o=>{const b=o,{onCreateBlockSchema:i,componentType:a,createBlockSchema:s,insert:t,icon:c=!0,targetCollection:d}=b,u=B(b,["onCreateBlockSchema","componentType","createBlockSchema","insert","icon","targetCollection"]),{getTemplateSchemaByMode:f}=e.useSchemaTemplateManager(),P=d||e.useCollection(),h=e.useBlockAssociationContext(),{block:k}=e.useBlockRequestContext(),y=k!=="TableField"?o.actionInitializers||"ReadPrettyFormActionInitializers":null;return l.createElement(e.SchemaInitializer.Item,S(m({icon:c&&r.jsx(C.FormOutlined,{})},u),{key:"snapshotDetail",onClick:ae=>T(this,[ae],function*({item:p}){if(p.template){const j=yield f(p);if(p.template.componentName==="ReadPrettyFormItem"){const E=N({actionInitializers:y,association:h,collection:P.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}",template:j});p.mode==="reference"&&(E["x-template-key"]=p.template.key),t(E)}else t(j)}else t(N({actionInitializers:y,association:h,collection:P.name,action:"get",useSourceId:"{{ useSourceIdFromParentRecord }}",useParams:"{{ useParamsFromRecord }}"}))}),items:e.useRecordCollectionDataSourceItems("ReadPrettyFormItem")}))},ee=o=>{var f;const{action:i,readPretty:a}=o,s=g.useField(),t=l.useMemo(()=>W.createForm({readPretty:a}),[]),{resource:c,service:d}=e.useBlockRequestContext(),u=l.useRef();return d.loading?r.jsx(v.Spin,{}):r.jsx(e.FormBlockContext.Provider,{value:{action:i,form:t,field:s,service:d,resource:c,updateAssociationValues:[],formBlockRef:u},children:a?r.jsx(e.RecordProvider,{record:(f=d==null?void 0:d.data)==null?void 0:f.data,children:r.jsx("div",{ref:u,children:o.children})}):r.jsx("div",{ref:u,children:o.children})})},oe=o=>{const i=g.useField(),a=e.useBlockResource(),s={loading:!1,data:{data:e.useRecord()}},t=l.useContext(e.BlockRequestContext);return r.jsx(e.BlockRequestContext.Provider,{value:{block:o.block,props:o,field:i,service:s,resource:a,__parent:t},children:o.children})},te=o=>{const{collection:i,association:a}=o,s=e.useResource(o);return r.jsx(e.MaybeCollectionProvider,{collection:i,children:r.jsx(e.BlockAssociationContext.Provider,{value:a,children:r.jsx(e.BlockResourceContext.Provider,{value:s,children:r.jsx(oe,S(m({},o),{children:o.children}))})})})},re=o=>{const i=e.useRecord(),{__tableName:a}=i,{getInheritCollections:s}=e.useCollectionManager(),t=s(a),{designable:c}=e.useDesignable();return!(!c&&a&&!t.includes(o.collection)&&a!==o.collection)&&r.jsx(te,S(m({},o),{children:r.jsx(ee,m({},o))}))},ne=o=>{var k,y,b;const{collectionName:i}=o,h=l.useContext(e.CollectionManagerContext),{collections:a}=h,s=B(h,["collections"]),t=(k=e.useHistoryCollectionsByNames([i]))==null?void 0:k[0],c=e.useHistoryCollectionsByNames((y=t==null?void 0:t.inherits)!=null?y:[]),d=e.useHistoryCollectionsByNames((b=t==null?void 0:t.fields.filter(p=>p.interface!=="snapshot").map(p=>p.target))!=null?b:[]),u=[t,...d,...c].filter(p=>p),P=[...a.filter(p=>!u.map(ae=>ae.name).includes(p.name)),...u];return r.jsx(e.CollectionManagerContext.Provider,{value:S(m({},s),{collections:P}),children:o.children})},D=o=>{const i=g.useFieldSchema(),{getField:a}=e.useCollection(),s=a(i.name);return r.jsx(ne,{collectionName:s==null?void 0:s.targetCollection,children:r.jsx(e.ReadPrettyRecordPicker,m({},o))})},se=g.connect(D,g.mapReadPretty(D)),ie=o=>{const c=o,{value:i,onChange:a}=c,s=B(c,["value","onChange"]),t=S(m({},s),{value:i==null?void 0:i.data,onChange:d=>a({data:d})});return r.jsx(se,m({},t))},R=l.memo(o=>(l.useEffect(()=>{e.registerField(z.group,z.name,z)},[]),r.jsx(e.CollectionManagerProvider,{interfaces:{snapshot:z},children:r.jsx(e.CollectionHistoryProvider,{children:r.jsx(e.SchemaInitializerProvider,{initializers:{SnapshotBlockInitializers:Y},children:r.jsx(e.SchemaComponentOptions,{components:{SnapshotRecordPicker:ie,SnapshotBlockProvider:re,SnapshotBlockInitializersDetailItem:Z,SnapshotOwnerCollectionFieldsSelect:X},children:o.children})})})})));R.displayName="SnapshotFieldProvider";class _ extends e.Plugin{load(){return T(this,null,function*(){this.app.use(R)})}}n.SnapshotFieldPlugin=_,n.default=_,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/index.js CHANGED
@@ -1,18 +1,39 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var server = require('./server');
6
-
7
-
8
-
9
- Object.defineProperty(exports, 'default', {
10
- enumerable: true,
11
- get: function () { return server__namespace.default; }
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ default: () => import_server.default
12
32
  });
13
- Object.keys(server).forEach(function (k) {
14
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
15
- enumerable: true,
16
- get: function () { return server[k]; }
17
- });
33
+ module.exports = __toCommonJS(src_exports);
34
+ __reExport(src_exports, require("./server"), module.exports);
35
+ var import_server = __toESM(require("./server"));
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ ...require("./server")
18
39
  });
@@ -1,5 +1,25 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var en_US_exports = {};
19
+ __export(en_US_exports, {
20
+ default: () => en_US_default
21
+ });
22
+ module.exports = __toCommonJS(en_US_exports);
3
23
  var en_US_default = {
4
24
  Detail: "Detail",
5
25
  Snapshot: "Snapshot",
@@ -11,5 +31,3 @@ var en_US_default = {
11
31
  "Snapshot the snapshot's association fields": "Snapshot the snapshot's association fields",
12
32
  "Please select": "Please select"
13
33
  };
14
-
15
- module.exports = en_US_default;
@@ -1,5 +1,25 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var es_ES_exports = {};
19
+ __export(es_ES_exports, {
20
+ default: () => es_ES_default
21
+ });
22
+ module.exports = __toCommonJS(es_ES_exports);
3
23
  var es_ES_default = {
4
24
  "Detail": "Detalle",
5
25
  "Snapshot": "Snapshot",
@@ -11,5 +31,3 @@ var es_ES_default = {
11
31
  "Snapshot the snapshot's association fields": "Snapshot los campos de asociaci\xF3n de la snapshot",
12
32
  "Please select": "Por favor, seleccione"
13
33
  };
14
-
15
- module.exports = es_ES_default;
@@ -1,5 +1,25 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var fr_FR_exports = {};
19
+ __export(fr_FR_exports, {
20
+ default: () => fr_FR_default
21
+ });
22
+ module.exports = __toCommonJS(fr_FR_exports);
3
23
  var fr_FR_default = {
4
24
  Detail: "D\xE9tail",
5
25
  Snapshot: "Snapshot",
@@ -11,5 +31,3 @@ var fr_FR_default = {
11
31
  "Snapshot the snapshot's association fields": "Snapshot des champs d'association du snapshot",
12
32
  "Please select": "Veuillez s\xE9lectionner"
13
33
  };
14
-
15
- module.exports = fr_FR_default;
@@ -1,5 +1,23 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var ja_JP_exports = {};
19
+ __export(ja_JP_exports, {
20
+ default: () => ja_JP_default
21
+ });
22
+ module.exports = __toCommonJS(ja_JP_exports);
3
23
  var ja_JP_default = {};
4
-
5
- module.exports = ja_JP_default;
@@ -1,5 +1,25 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var pt_BR_exports = {};
19
+ __export(pt_BR_exports, {
20
+ default: () => pt_BR_default
21
+ });
22
+ module.exports = __toCommonJS(pt_BR_exports);
3
23
  var pt_BR_default = {
4
24
  Detail: "Detalhes",
5
25
  Snapshot: "Fotografia",
@@ -11,5 +31,3 @@ var pt_BR_default = {
11
31
  "Snapshot the snapshot's association fields": "Criar imagem instant\xE2nea para os campos de associa\xE7\xE3o da imagem instant\xE2nea",
12
32
  "Please select": "Por favor, selecione"
13
33
  };
14
-
15
- module.exports = pt_BR_default;
@@ -1,5 +1,23 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var ru_RU_exports = {};
19
+ __export(ru_RU_exports, {
20
+ default: () => ru_RU_default
21
+ });
22
+ module.exports = __toCommonJS(ru_RU_exports);
3
23
  var ru_RU_default = {};
4
-
5
- module.exports = ru_RU_default;
@@ -1,5 +1,23 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var tr_TR_exports = {};
19
+ __export(tr_TR_exports, {
20
+ default: () => tr_TR_default
21
+ });
22
+ module.exports = __toCommonJS(tr_TR_exports);
3
23
  var tr_TR_default = {};
4
-
5
- module.exports = tr_TR_default;
@@ -1,5 +1,25 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var zh_CN_exports = {};
19
+ __export(zh_CN_exports, {
20
+ default: () => zh_CN_default
21
+ });
22
+ module.exports = __toCommonJS(zh_CN_exports);
3
23
  var zh_CN_default = {
4
24
  Detail: "\u8BE6\u60C5",
5
25
  Snapshot: "\u5FEB\u7167",
@@ -13,5 +33,3 @@ var zh_CN_default = {
13
33
  "When a record is created, association data is backed up in a snapshot": "\u521B\u5EFA\u8BB0\u5F55\u65F6\uFF0C\u5173\u7CFB\u6570\u636E\u4F1A\u5907\u4EFD\u5230\u5FEB\u7167\u91CC",
14
34
  "Snapshot data": "\u5FEB\u7167\u6570\u636E"
15
35
  };
16
-
17
- module.exports = zh_CN_default;
@@ -1,5 +1,25 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var collectionsHistory_exports = {};
19
+ __export(collectionsHistory_exports, {
20
+ default: () => collectionsHistory_default
21
+ });
22
+ module.exports = __toCommonJS(collectionsHistory_exports);
3
23
  var collectionsHistory_default = {
4
24
  namespace: "snapshot-field.snapshot-field",
5
25
  duplicator: "required",
@@ -55,5 +75,3 @@ var collectionsHistory_default = {
55
75
  }
56
76
  ]
57
77
  };
58
-
59
- module.exports = collectionsHistory_default;
@@ -1,5 +1,25 @@
1
- 'use strict';
2
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var fieldsHistory_exports = {};
19
+ __export(fieldsHistory_exports, {
20
+ default: () => fieldsHistory_default
21
+ });
22
+ module.exports = __toCommonJS(fieldsHistory_exports);
3
23
  var fieldsHistory_default = {
4
24
  namespace: "snapshot-field.snapshot-field",
5
25
  duplicator: "required",
@@ -73,5 +93,3 @@ var fieldsHistory_default = {
73
93
  }
74
94
  ]
75
95
  };
76
-
77
- module.exports = fieldsHistory_default;
@@ -1,10 +1,29 @@
1
- 'use strict';
2
-
3
- var database = require('@nocobase/database');
4
-
5
- class SnapshotField extends database.Field {
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var snapshot_field_exports = {};
19
+ __export(snapshot_field_exports, {
20
+ SnapshotField: () => SnapshotField
21
+ });
22
+ module.exports = __toCommonJS(snapshot_field_exports);
23
+ var import_database = require("@nocobase/database");
24
+ class SnapshotField extends import_database.Field {
6
25
  get dataType() {
7
- return database.DataTypes.JSON;
26
+ return import_database.DataTypes.JSON;
8
27
  }
9
28
  createSnapshot = async (model, { transaction, values }) => {
10
29
  const { name, targetField } = this.options;
@@ -45,5 +64,7 @@ class SnapshotField extends database.Field {
45
64
  this.off("afterCreateWithAssociations", this.createSnapshot);
46
65
  }
47
66
  }
48
-
49
- exports.SnapshotField = SnapshotField;
67
+ // Annotate the CommonJS export names for ESM import in node:
68
+ 0 && (module.exports = {
69
+ SnapshotField
70
+ });
@@ -1,11 +1,33 @@
1
- 'use strict';
2
-
3
- var plugin = require('./plugin');
4
-
5
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
-
7
- var plugin__default = /*#__PURE__*/_interopDefault(plugin);
8
-
9
-
10
-
11
- module.exports = plugin__default.default;
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var server_exports = {};
29
+ __export(server_exports, {
30
+ default: () => import_plugin.default
31
+ });
32
+ module.exports = __toCommonJS(server_exports);
33
+ var import_plugin = __toESM(require("./plugin"));
@@ -1,12 +1,30 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var server = require('@nocobase/server');
6
- var path = require('path');
7
- var snapshotField = require('./fields/snapshot-field');
8
-
9
- class SnapshotFieldPlugin extends server.Plugin {
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var plugin_exports = {};
19
+ __export(plugin_exports, {
20
+ SnapshotFieldPlugin: () => SnapshotFieldPlugin,
21
+ default: () => plugin_default
22
+ });
23
+ module.exports = __toCommonJS(plugin_exports);
24
+ var import_server = require("@nocobase/server");
25
+ var import_path = require("path");
26
+ var import_snapshot_field = require("./fields/snapshot-field");
27
+ class SnapshotFieldPlugin extends import_server.Plugin {
10
28
  afterAdd() {
11
29
  }
12
30
  async beforeLoad() {
@@ -69,10 +87,10 @@ class SnapshotFieldPlugin extends server.Plugin {
69
87
  };
70
88
  async load() {
71
89
  await this.db.import({
72
- directory: path.resolve(__dirname, "collections")
90
+ directory: (0, import_path.resolve)(__dirname, "collections")
73
91
  });
74
92
  this.app.db.registerFieldTypes({
75
- snapshot: snapshotField.SnapshotField
93
+ snapshot: import_snapshot_field.SnapshotField
76
94
  });
77
95
  this.app.acl.allow("collectionsHistory", "list", "loggedIn");
78
96
  }
@@ -107,6 +125,7 @@ class SnapshotFieldPlugin extends server.Plugin {
107
125
  }
108
126
  }
109
127
  var plugin_default = SnapshotFieldPlugin;
110
-
111
- exports.SnapshotFieldPlugin = SnapshotFieldPlugin;
112
- exports.default = plugin_default;
128
+ // Annotate the CommonJS export names for ESM import in node:
129
+ 0 && (module.exports = {
130
+ SnapshotFieldPlugin
131
+ });
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ info: {
3
+ title: string;
4
+ };
5
+ tags: any[];
6
+ paths: {};
7
+ };
8
+ export default _default;
@@ -0,0 +1,29 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var swagger_exports = {};
19
+ __export(swagger_exports, {
20
+ default: () => swagger_default
21
+ });
22
+ module.exports = __toCommonJS(swagger_exports);
23
+ var swagger_default = {
24
+ info: {
25
+ title: "NocoBase API - Snapshot field plugin"
26
+ },
27
+ tags: [],
28
+ paths: {}
29
+ };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "关系快照字段",
5
5
  "description": "",
6
6
  "description.zh-CN": "",
7
- "version": "0.12.0-alpha.5",
7
+ "version": "0.13.0-alpha.10",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "devDependencies": {
@@ -24,5 +24,5 @@
24
24
  "@nocobase/test": "0.x",
25
25
  "@nocobase/utils": "0.x"
26
26
  },
27
- "gitHead": "689cc16e83361c4d0b91907e0deac30bdb907692"
27
+ "gitHead": "5360ed81650f6895f3ed39aede2706467d55862c"
28
28
  }