@tachybase/module-ui-schema 0.23.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +6 -0
- package/LICENSE +201 -0
- package/README.md +9 -0
- package/README.zh-CN.md +9 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js +1 -0
- package/dist/externalVersion.js +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +30 -0
- package/dist/server/actions/ui-schema-action.d.ts +17 -0
- package/dist/server/actions/ui-schema-action.js +133 -0
- package/dist/server/collections/uiSchemaServerHooks.d.ts +3 -0
- package/dist/server/collections/uiSchemaServerHooks.js +49 -0
- package/dist/server/collections/uiSchemaTemplates.d.ts +2 -0
- package/dist/server/collections/uiSchemaTemplates.js +66 -0
- package/dist/server/collections/uiSchemaTreePath.d.ts +3 -0
- package/dist/server/collections/uiSchemaTreePath.js +64 -0
- package/dist/server/collections/uiSchemas.d.ts +3 -0
- package/dist/server/collections/uiSchemas.js +53 -0
- package/dist/server/dao/ui_schema_dao.d.ts +4 -0
- package/dist/server/dao/ui_schema_dao.js +31 -0
- package/dist/server/dao/ui_schema_node_dao.d.ts +22 -0
- package/dist/server/dao/ui_schema_node_dao.js +32 -0
- package/dist/server/helper.d.ts +0 -0
- package/dist/server/helper.js +0 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +32 -0
- package/dist/server/migrations/20230330214649-filter-form-block.d.ts +5 -0
- package/dist/server/migrations/20230330214649-filter-form-block.js +48 -0
- package/dist/server/migrations/20230509221649-association-select.d.ts +5 -0
- package/dist/server/migrations/20230509221649-association-select.js +61 -0
- package/dist/server/migrations/20230509235247-record-picker.d.ts +8 -0
- package/dist/server/migrations/20230509235247-record-picker.js +111 -0
- package/dist/server/migrations/20230522231231-association-field.d.ts +5 -0
- package/dist/server/migrations/20230522231231-association-field.js +64 -0
- package/dist/server/migrations/20231015125000-support-filter-blocks-in-select-record-drawer.d.ts +5 -0
- package/dist/server/migrations/20231015125000-support-filter-blocks-in-select-record-drawer.js +45 -0
- package/dist/server/migrations/2024082000001-update-uiSchemas_customDesigner.d.ts +6 -0
- package/dist/server/migrations/2024082000001-update-uiSchemas_customDesigner.js +37 -0
- package/dist/server/migrations/20241120132559-modify-schema.d.ts +6 -0
- package/dist/server/migrations/20241120132559-modify-schema.js +119 -0
- package/dist/server/model.d.ts +6 -0
- package/dist/server/model.js +33 -0
- package/dist/server/repository.d.ts +85 -0
- package/dist/server/repository.js +969 -0
- package/dist/server/server-hooks/hooks/bind-menu-to-role.d.ts +5 -0
- package/dist/server/server-hooks/hooks/bind-menu-to-role.js +40 -0
- package/dist/server/server-hooks/hooks/factory.d.ts +6 -0
- package/dist/server/server-hooks/hooks/factory.js +33 -0
- package/dist/server/server-hooks/hooks/index.d.ts +6 -0
- package/dist/server/server-hooks/hooks/index.js +36 -0
- package/dist/server/server-hooks/hooks/remove-parents-if-no-children.d.ts +6 -0
- package/dist/server/server-hooks/hooks/remove-parents-if-no-children.js +35 -0
- package/dist/server/server-hooks/hooks/remove-schema.d.ts +6 -0
- package/dist/server/server-hooks/hooks/remove-schema.js +42 -0
- package/dist/server/server-hooks/index.d.ts +25 -0
- package/dist/server/server-hooks/index.js +165 -0
- package/dist/server/server-hooks/model.d.ts +3 -0
- package/dist/server/server-hooks/model.js +29 -0
- package/dist/server/server.d.ts +8 -0
- package/dist/server/server.js +136 -0
- package/dist/swagger/index.d.ts +326 -0
- package/dist/swagger/index.js +354 -0
- package/package.json +32 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,119 @@
|
|
|
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 modify_schema_exports = {};
|
|
19
|
+
__export(modify_schema_exports, {
|
|
20
|
+
default: () => modify_schema_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(modify_schema_exports);
|
|
23
|
+
var import_server = require("@tachybase/server");
|
|
24
|
+
var import_sequelize = require("sequelize");
|
|
25
|
+
const initializerRule = {
|
|
26
|
+
BlockInitializers: "page:addBlock",
|
|
27
|
+
MBlockInitializers: "mobilePage:addBlock",
|
|
28
|
+
CreateFormBlockInitializers: "popup:addNew:addBlock",
|
|
29
|
+
CusomeizeCreateFormBlockInitializers: "popup:addRecord:addBlock",
|
|
30
|
+
RecordBlockInitializers: "popup:common:addBlock",
|
|
31
|
+
BulkEditBlockInitializers: "popup:bulkEdit:addBlock",
|
|
32
|
+
TableColumnInitializers: "table:configureColumns",
|
|
33
|
+
TableActionColumnInitializers: "table:configureItemActions",
|
|
34
|
+
TableActionInitializers: "table:configureActions",
|
|
35
|
+
SubTableActionInitializers: "subTable:configureActions",
|
|
36
|
+
FormItemInitializers: "form:configureFields",
|
|
37
|
+
CreateFormActionInitializers: "createForm:configureActions",
|
|
38
|
+
UpdateFormActionInitializers: "editForm:configureActions",
|
|
39
|
+
ReadPrettyFormItemInitializers: "details:configureFields",
|
|
40
|
+
DetailsActionInitializers: "detailsWithPaging:configureActions",
|
|
41
|
+
ReadPrettyFormActionInitializers: "details:configureActions",
|
|
42
|
+
KanbanCardInitializers: "kanban:configureItemFields",
|
|
43
|
+
KanbanActionInitializers: "kanban:configureActions",
|
|
44
|
+
GridCardActionInitializers: "gridCard:configureActions",
|
|
45
|
+
GridCardItemActionInitializers: "gridCard:configureItemActions",
|
|
46
|
+
ListActionInitializers: "list:configureActions",
|
|
47
|
+
ListItemActionInitializers: "list:configureItemActions",
|
|
48
|
+
CalendarActionInitializers: "calendar:configureActions",
|
|
49
|
+
GanttActionInitializers: "gantt:configureActions",
|
|
50
|
+
MapActionInitializers: "map:configureActions",
|
|
51
|
+
TableSelectorInitializers: "popup:tableSelector:addBlock",
|
|
52
|
+
ChartInitializers: "charts:addBlock",
|
|
53
|
+
ChartFilterItemInitializers: "chartFilterForm:configureFields",
|
|
54
|
+
ChartFilterActionInitializers: "chartFilterForm:configureActions",
|
|
55
|
+
AssociationFilterInitializers: "filterCollapse:configureFields",
|
|
56
|
+
FilterFormItemInitializers: "filterForm:configureFields",
|
|
57
|
+
FilterFormActionInitializers: "filterForm:configureActions",
|
|
58
|
+
CustomFormItemInitializers: "assignFieldValuesForm:configureFields",
|
|
59
|
+
BulkEditFormItemInitializers: "bulkEditForm:configureFields",
|
|
60
|
+
BulkEditFormActionInitializers: "bulkEditForm:configureActions",
|
|
61
|
+
AuditLogsTableColumnInitializers: "auditLogsTable:configureColumns",
|
|
62
|
+
AuditLogsTableActionColumnInitializers: "auditLogsTable:configureItemActions",
|
|
63
|
+
AuditLogsTableActionInitializers: "auditLogsTable:configureActions",
|
|
64
|
+
SnapshotBlockInitializers: "popup:snapshot:addBlock",
|
|
65
|
+
AddBlockButton: "workflowManual:popup:configureUserInterface:addBlock",
|
|
66
|
+
AddCustomFormField: "workflowManual:customForm:configureFields",
|
|
67
|
+
AddActionButton: "workflowManual:form:configureActions"
|
|
68
|
+
};
|
|
69
|
+
const settingsRule = {
|
|
70
|
+
GanttBlockSettings: "blockSettings:gantt",
|
|
71
|
+
"ActionSettings:customize:bulkEdit": "actionSettings:bulkEdit"
|
|
72
|
+
};
|
|
73
|
+
class modify_schema_default extends import_server.Migration {
|
|
74
|
+
on = "afterLoad";
|
|
75
|
+
// 'beforeLoad' or 'afterLoad'
|
|
76
|
+
appVersion = "<0.22.40";
|
|
77
|
+
async up() {
|
|
78
|
+
const sequelize = this.app.db.sequelize;
|
|
79
|
+
const result = await sequelize.query(`
|
|
80
|
+
SELECT "x-uid", "schema" FROM public."uiSchemas"
|
|
81
|
+
`);
|
|
82
|
+
const uiSchemas = result[0];
|
|
83
|
+
let count = 0;
|
|
84
|
+
for (const uiSchema of uiSchemas) {
|
|
85
|
+
const schema = uiSchema.schema;
|
|
86
|
+
if (!schema) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
let changed = false;
|
|
90
|
+
if (schema["x-initializer"] && initializerRule[schema["x-initializer"]]) {
|
|
91
|
+
schema["x-initializer"] = initializerRule[schema["x-initializer"]];
|
|
92
|
+
changed = true;
|
|
93
|
+
}
|
|
94
|
+
if (schema["x-settings"] && settingsRule[schema["x-settings"]]) {
|
|
95
|
+
schema["x-settings"] = settingsRule[schema["x-settings"]];
|
|
96
|
+
changed = true;
|
|
97
|
+
}
|
|
98
|
+
if (!changed) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const result2 = await sequelize.query(
|
|
102
|
+
`
|
|
103
|
+
UPDATE public."uiSchemas"
|
|
104
|
+
SET schema = :schema::jsonb
|
|
105
|
+
WHERE "x-uid" = :id
|
|
106
|
+
`,
|
|
107
|
+
{
|
|
108
|
+
type: import_sequelize.QueryTypes.UPDATE,
|
|
109
|
+
replacements: {
|
|
110
|
+
schema: JSON.stringify(schema),
|
|
111
|
+
id: uiSchema["x-uid"]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
count += result2[1];
|
|
116
|
+
}
|
|
117
|
+
console.log(`[uiSchemas]\u5171\u66F4\u65B0\u6570\u636E\uFF1A${count}\u6761`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 model_exports = {};
|
|
19
|
+
__export(model_exports, {
|
|
20
|
+
UiSchemaModel: () => UiSchemaModel
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(model_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
class UiSchemaModel extends import_database.MagicAttributeModel {
|
|
25
|
+
getServerHooksByType(type) {
|
|
26
|
+
const hooks = this.get("x-server-hooks") || [];
|
|
27
|
+
return hooks.filter((hook) => hook.type === type);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
UiSchemaModel
|
|
33
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Cache } from '@tachybase/cache';
|
|
2
|
+
import { Repository, Transaction, Transactionable } from '@tachybase/database';
|
|
3
|
+
import { ChildOptions, SchemaNode } from './dao/ui_schema_node_dao';
|
|
4
|
+
export interface GetJsonSchemaOptions {
|
|
5
|
+
includeAsyncNode?: boolean;
|
|
6
|
+
readFromCache?: boolean;
|
|
7
|
+
transaction?: Transaction;
|
|
8
|
+
}
|
|
9
|
+
export interface GetPropertiesOptions {
|
|
10
|
+
readFromCache?: boolean;
|
|
11
|
+
transaction?: Transaction;
|
|
12
|
+
}
|
|
13
|
+
type BreakRemoveOnType = {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
export interface removeParentOptions extends Transactionable {
|
|
17
|
+
removeParentsIfNoChildren?: boolean;
|
|
18
|
+
breakRemoveOn?: BreakRemoveOnType;
|
|
19
|
+
}
|
|
20
|
+
interface InsertAdjacentOptions extends removeParentOptions {
|
|
21
|
+
wrap?: any;
|
|
22
|
+
}
|
|
23
|
+
export declare class UiSchemaRepository extends Repository {
|
|
24
|
+
cache: Cache;
|
|
25
|
+
get uiSchemasTableName(): any;
|
|
26
|
+
get uiSchemaTreePathTableName(): any;
|
|
27
|
+
static schemaToSingleNodes(schema: any, carry?: SchemaNode[], childOptions?: ChildOptions): SchemaNode[];
|
|
28
|
+
setCache(cache: Cache): void;
|
|
29
|
+
/**
|
|
30
|
+
* clear cache with xUid which in uiSchemaTreePath's Path
|
|
31
|
+
* @param {string} xUid
|
|
32
|
+
* @param {Transaction} transaction
|
|
33
|
+
* @returns {Promise<void>}
|
|
34
|
+
*/
|
|
35
|
+
clearXUidPathCache(xUid: string, transaction: Transaction): Promise<void>;
|
|
36
|
+
tableNameAdapter(tableName: any): any;
|
|
37
|
+
sqlAdapter(sql: string): any;
|
|
38
|
+
getProperties(uid: string, options?: GetPropertiesOptions): Promise<any>;
|
|
39
|
+
getJsonSchema(uid: string, options?: GetJsonSchemaOptions): Promise<any>;
|
|
40
|
+
nodesToSchema(nodes: any, rootUid: any): any;
|
|
41
|
+
clearAncestor(uid: string, options?: Transactionable): Promise<void>;
|
|
42
|
+
patch(newSchema: any, options?: any): Promise<void>;
|
|
43
|
+
batchPatch(schemas: any[], options?: any): Promise<void>;
|
|
44
|
+
removeEmptyParents(options: Transactionable & {
|
|
45
|
+
uid: string;
|
|
46
|
+
breakRemoveOn?: BreakRemoveOnType;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
recursivelyRemoveIfNoChildren(options: Transactionable & {
|
|
49
|
+
uid: string;
|
|
50
|
+
breakRemoveOn?: BreakRemoveOnType;
|
|
51
|
+
}): Promise<void>;
|
|
52
|
+
remove(uid: string, options?: Transactionable & removeParentOptions): Promise<void>;
|
|
53
|
+
insertAdjacent(position: 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd', target: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
54
|
+
duplicate(uid: string, options?: Transactionable): Promise<any>;
|
|
55
|
+
insert(schema: any, options?: Transactionable): Promise<any>;
|
|
56
|
+
insertNewSchema(schema: any, options?: Transactionable & {
|
|
57
|
+
returnNode?: boolean;
|
|
58
|
+
}): Promise<any>;
|
|
59
|
+
insertSingleNode(schema: SchemaNode, options: Transactionable & removeParentOptions): Promise<any>;
|
|
60
|
+
protected updateNode(uid: string, schema: any, transaction?: Transaction): Promise<void>;
|
|
61
|
+
protected childrenCount(uid: any, transaction: any): Promise<number>;
|
|
62
|
+
protected isLeafNode(uid: any, transaction: any): Promise<boolean>;
|
|
63
|
+
protected findParentUid(uid: any, transaction?: any): Promise<string>;
|
|
64
|
+
protected findNodeSchemaWithParent(uid: any, transaction: any): Promise<{
|
|
65
|
+
parentUid: string;
|
|
66
|
+
schema: any;
|
|
67
|
+
}>;
|
|
68
|
+
protected isSingleChild(uid: any, transaction: any): Promise<any>;
|
|
69
|
+
protected insertBeside(targetUid: string, schema: any, side: 'before' | 'after', options?: InsertAdjacentOptions): Promise<any>;
|
|
70
|
+
protected insertInner(targetUid: string, schema: any, position: 'first' | 'last', options?: InsertAdjacentOptions): Promise<any>;
|
|
71
|
+
protected insertAfterBegin(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
72
|
+
protected insertBeforeEnd(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
73
|
+
protected insertBeforeBegin(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
74
|
+
protected insertAfterEnd(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
75
|
+
protected insertNodes(nodes: SchemaNode[], options?: Transactionable): Promise<any[]>;
|
|
76
|
+
private doGetProperties;
|
|
77
|
+
private doGetJsonSchema;
|
|
78
|
+
private ignoreSchemaProperties;
|
|
79
|
+
private breakOnMatched;
|
|
80
|
+
private schemaExists;
|
|
81
|
+
private regenerateUid;
|
|
82
|
+
private insertSchemaRecord;
|
|
83
|
+
private prepareSingleNodeForInsert;
|
|
84
|
+
}
|
|
85
|
+
export default UiSchemaRepository;
|