@nocobase/plugin-ui-schema-storage 0.7.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/esm/actions/ui-schema-action.d.ts +16 -0
- package/esm/actions/ui-schema-action.js +100 -0
- package/esm/actions/ui-schema-action.js.map +1 -0
- package/esm/collections/uiSchemaServerHooks.d.ts +3 -0
- package/esm/collections/uiSchemaServerHooks.js +27 -0
- package/esm/collections/uiSchemaServerHooks.js.map +1 -0
- package/esm/collections/uiSchemaTemplates.d.ts +2 -0
- package/esm/collections/uiSchemaTemplates.js +39 -0
- package/esm/collections/uiSchemaTemplates.js.map +1 -0
- package/esm/collections/uiSchemaTreePath.d.ts +3 -0
- package/esm/collections/uiSchemaTreePath.js +42 -0
- package/esm/collections/uiSchemaTreePath.js.map +1 -0
- package/esm/collections/uiSchemas.d.ts +3 -0
- package/esm/collections/uiSchemas.js +32 -0
- package/esm/collections/uiSchemas.js.map +1 -0
- package/esm/dao/ui_schema_dao.d.ts +4 -0
- package/esm/dao/ui_schema_dao.js +6 -0
- package/esm/dao/ui_schema_dao.js.map +1 -0
- package/esm/dao/ui_schema_node_dao.d.ts +22 -0
- package/esm/dao/ui_schema_node_dao.js +6 -0
- package/esm/dao/ui_schema_node_dao.js.map +1 -0
- package/esm/helper.d.ts +0 -0
- package/esm/helper.js +1 -0
- package/esm/helper.js.map +1 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.js +4 -0
- package/esm/index.js.map +1 -0
- package/esm/model.d.ts +6 -0
- package/esm/model.js +9 -0
- package/esm/model.js.map +1 -0
- package/esm/repository.d.ts +72 -0
- package/esm/repository.js +858 -0
- package/esm/repository.js.map +1 -0
- package/esm/server-hooks/hooks/bind-menu-to-role.d.ts +5 -0
- package/esm/server-hooks/hooks/bind-menu-to-role.js +26 -0
- package/esm/server-hooks/hooks/bind-menu-to-role.js.map +1 -0
- package/esm/server-hooks/hooks/factory.d.ts +6 -0
- package/esm/server-hooks/hooks/factory.js +8 -0
- package/esm/server-hooks/hooks/factory.js.map +1 -0
- package/esm/server-hooks/hooks/index.d.ts +6 -0
- package/esm/server-hooks/hooks/index.js +12 -0
- package/esm/server-hooks/hooks/index.js.map +1 -0
- package/esm/server-hooks/hooks/remove-parents-if-no-children.d.ts +6 -0
- package/esm/server-hooks/hooks/remove-parents-if-no-children.js +21 -0
- package/esm/server-hooks/hooks/remove-parents-if-no-children.js.map +1 -0
- package/esm/server-hooks/hooks/remove-schema.d.ts +6 -0
- package/esm/server-hooks/hooks/remove-schema.js +29 -0
- package/esm/server-hooks/hooks/remove-schema.js.map +1 -0
- package/esm/server-hooks/index.d.ts +23 -0
- package/esm/server-hooks/index.js +133 -0
- package/esm/server-hooks/index.js.map +1 -0
- package/esm/server-hooks/model.d.ts +3 -0
- package/esm/server-hooks/model.js +4 -0
- package/esm/server-hooks/model.js.map +1 -0
- package/esm/server.d.ts +10 -0
- package/esm/server.js +78 -0
- package/esm/server.js.map +1 -0
- package/lib/actions/ui-schema-action.d.ts +16 -0
- package/lib/actions/ui-schema-action.js +106 -0
- package/lib/actions/ui-schema-action.js.map +1 -0
- package/lib/collections/uiSchemaServerHooks.d.ts +3 -0
- package/lib/collections/uiSchemaServerHooks.js +29 -0
- package/lib/collections/uiSchemaServerHooks.js.map +1 -0
- package/lib/collections/uiSchemaTemplates.d.ts +2 -0
- package/lib/collections/uiSchemaTemplates.js +41 -0
- package/lib/collections/uiSchemaTemplates.js.map +1 -0
- package/lib/collections/uiSchemaTreePath.d.ts +3 -0
- package/lib/collections/uiSchemaTreePath.js +44 -0
- package/lib/collections/uiSchemaTreePath.js.map +1 -0
- package/lib/collections/uiSchemas.d.ts +3 -0
- package/lib/collections/uiSchemas.js +34 -0
- package/lib/collections/uiSchemas.js.map +1 -0
- package/lib/dao/ui_schema_dao.d.ts +4 -0
- package/lib/dao/ui_schema_dao.js +10 -0
- package/lib/dao/ui_schema_dao.js.map +1 -0
- package/lib/dao/ui_schema_node_dao.d.ts +22 -0
- package/lib/dao/ui_schema_node_dao.js +10 -0
- package/lib/dao/ui_schema_node_dao.js.map +1 -0
- package/lib/helper.d.ts +0 -0
- package/lib/helper.js +1 -0
- package/lib/helper.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/model.d.ts +6 -0
- package/lib/model.js +12 -0
- package/lib/model.js.map +1 -0
- package/lib/repository.d.ts +72 -0
- package/lib/repository.js +865 -0
- package/lib/repository.js.map +1 -0
- package/lib/server-hooks/hooks/bind-menu-to-role.d.ts +5 -0
- package/lib/server-hooks/hooks/bind-menu-to-role.js +30 -0
- package/lib/server-hooks/hooks/bind-menu-to-role.js.map +1 -0
- package/lib/server-hooks/hooks/factory.d.ts +6 -0
- package/lib/server-hooks/hooks/factory.js +12 -0
- package/lib/server-hooks/hooks/factory.js.map +1 -0
- package/lib/server-hooks/hooks/index.d.ts +6 -0
- package/lib/server-hooks/hooks/index.js +15 -0
- package/lib/server-hooks/hooks/index.js.map +1 -0
- package/lib/server-hooks/hooks/remove-parents-if-no-children.d.ts +6 -0
- package/lib/server-hooks/hooks/remove-parents-if-no-children.js +25 -0
- package/lib/server-hooks/hooks/remove-parents-if-no-children.js.map +1 -0
- package/lib/server-hooks/hooks/remove-schema.d.ts +6 -0
- package/lib/server-hooks/hooks/remove-schema.js +33 -0
- package/lib/server-hooks/hooks/remove-schema.js.map +1 -0
- package/lib/server-hooks/index.d.ts +23 -0
- package/lib/server-hooks/index.js +137 -0
- package/lib/server-hooks/index.js.map +1 -0
- package/lib/server-hooks/model.d.ts +3 -0
- package/lib/server-hooks/model.js +8 -0
- package/lib/server-hooks/model.js.map +1 -0
- package/lib/server.d.ts +10 -0
- package/lib/server.js +85 -0
- package/lib/server.js.map +1 -0
- package/package.json +22 -0
- package/tsconfig.build.json +9 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.uiSchemaActions = void 0;
|
|
16
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
17
|
+
const getRepositoryFromCtx = (ctx) => {
|
|
18
|
+
return ctx.db.getCollection('uiSchemas').repository;
|
|
19
|
+
};
|
|
20
|
+
const callRepositoryMethod = (method, paramsKey, optionsBuilder) => {
|
|
21
|
+
return (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const params = lodash_1.default.get(ctx.action.params, paramsKey);
|
|
23
|
+
const options = optionsBuilder ? optionsBuilder(ctx.action.params) : {};
|
|
24
|
+
const repository = getRepositoryFromCtx(ctx);
|
|
25
|
+
const returnValue = yield repository[method](params, options);
|
|
26
|
+
ctx.body = returnValue || {
|
|
27
|
+
result: 'ok',
|
|
28
|
+
};
|
|
29
|
+
yield next();
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
function parseInsertAdjacentValues(values) {
|
|
33
|
+
if (lodash_1.default.has(values, 'schema')) {
|
|
34
|
+
return values;
|
|
35
|
+
}
|
|
36
|
+
return { schema: values, wrap: null };
|
|
37
|
+
}
|
|
38
|
+
exports.uiSchemaActions = {
|
|
39
|
+
getJsonSchema: callRepositoryMethod('getJsonSchema', 'resourceIndex', (params) => {
|
|
40
|
+
return {
|
|
41
|
+
includeAsyncNode: params === null || params === void 0 ? void 0 : params.includeAsyncNode,
|
|
42
|
+
};
|
|
43
|
+
}),
|
|
44
|
+
getProperties: callRepositoryMethod('getProperties', 'resourceIndex'),
|
|
45
|
+
insert: callRepositoryMethod('insert', 'values'),
|
|
46
|
+
insertNewSchema: callRepositoryMethod('insertNewSchema', 'values'),
|
|
47
|
+
remove: callRepositoryMethod('remove', 'resourceIndex'),
|
|
48
|
+
patch: callRepositoryMethod('patch', 'values'),
|
|
49
|
+
clearAncestor: callRepositoryMethod('clearAncestor', 'resourceIndex'),
|
|
50
|
+
insertAdjacent(ctx, next) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const { resourceIndex, position, values, removeParentsIfNoChildren, breakRemoveOn } = ctx.action.params;
|
|
53
|
+
const repository = getRepositoryFromCtx(ctx);
|
|
54
|
+
const { schema, wrap } = parseInsertAdjacentValues(values);
|
|
55
|
+
ctx.body = yield repository.insertAdjacent(position, resourceIndex, schema, {
|
|
56
|
+
removeParentsIfNoChildren,
|
|
57
|
+
breakRemoveOn,
|
|
58
|
+
wrap,
|
|
59
|
+
});
|
|
60
|
+
yield next();
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
insertBeforeBegin: insertPositionActionBuilder('beforeBegin'),
|
|
64
|
+
insertAfterBegin: insertPositionActionBuilder('afterBegin'),
|
|
65
|
+
insertBeforeEnd: insertPositionActionBuilder('beforeEnd'),
|
|
66
|
+
insertAfterEnd: insertPositionActionBuilder('afterEnd'),
|
|
67
|
+
saveAsTemplate(ctx, next) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const { filterByTk, values } = ctx.action.params;
|
|
70
|
+
const db = ctx.db;
|
|
71
|
+
const transaction = yield db.sequelize.transaction();
|
|
72
|
+
try {
|
|
73
|
+
yield db.getRepository('uiSchemaTemplates').create({
|
|
74
|
+
values: Object.assign(Object.assign({}, values), { uid: filterByTk }),
|
|
75
|
+
transaction,
|
|
76
|
+
});
|
|
77
|
+
yield db.getRepository('uiSchemas').clearAncestor(filterByTk, { transaction });
|
|
78
|
+
ctx.body = {
|
|
79
|
+
result: 'ok',
|
|
80
|
+
};
|
|
81
|
+
yield transaction.commit();
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
yield transaction.rollback();
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
yield next();
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
function insertPositionActionBuilder(position) {
|
|
92
|
+
return function (ctx, next) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const { resourceIndex, values, removeParentsIfNoChildren, breakRemoveOn } = ctx.action.params;
|
|
95
|
+
const repository = getRepositoryFromCtx(ctx);
|
|
96
|
+
const { schema, wrap } = parseInsertAdjacentValues(values);
|
|
97
|
+
ctx.body = yield repository.insertAdjacent(position, resourceIndex, schema, {
|
|
98
|
+
removeParentsIfNoChildren,
|
|
99
|
+
breakRemoveOn,
|
|
100
|
+
wrap,
|
|
101
|
+
});
|
|
102
|
+
yield next();
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=ui-schema-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-schema-action.js","sourceRoot":"","sources":["../../src/actions/ui-schema-action.ts"],"names":[],"mappings":"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","sourcesContent":["import { Context } from '@nocobase/actions';\nimport { ActionParams } from '@nocobase/resourcer';\nimport lodash from 'lodash';\nimport UiSchemaRepository from '../repository';\n\nconst getRepositoryFromCtx = (ctx: Context) => {\n return ctx.db.getCollection('uiSchemas').repository as UiSchemaRepository;\n};\n\nconst callRepositoryMethod = (method, paramsKey: 'resourceIndex' | 'values', optionsBuilder?) => {\n return async (ctx, next) => {\n const params = lodash.get(ctx.action.params, paramsKey);\n const options = optionsBuilder ? optionsBuilder(ctx.action.params) : {};\n\n const repository = getRepositoryFromCtx(ctx);\n const returnValue = await repository[method](params, options);\n\n ctx.body = returnValue || {\n result: 'ok',\n };\n\n await next();\n };\n};\n\nfunction parseInsertAdjacentValues(values) {\n if (lodash.has(values, 'schema')) {\n return values;\n }\n\n return { schema: values, wrap: null };\n}\n\nexport const uiSchemaActions = {\n getJsonSchema: callRepositoryMethod('getJsonSchema', 'resourceIndex', (params: ActionParams) => {\n return {\n includeAsyncNode: params?.includeAsyncNode,\n };\n }),\n\n getProperties: callRepositoryMethod('getProperties', 'resourceIndex'),\n insert: callRepositoryMethod('insert', 'values'),\n insertNewSchema: callRepositoryMethod('insertNewSchema', 'values'),\n remove: callRepositoryMethod('remove', 'resourceIndex'),\n patch: callRepositoryMethod('patch', 'values'),\n clearAncestor: callRepositoryMethod('clearAncestor', 'resourceIndex'),\n\n async insertAdjacent(ctx: Context, next) {\n const { resourceIndex, position, values, removeParentsIfNoChildren, breakRemoveOn } = ctx.action.params;\n const repository = getRepositoryFromCtx(ctx);\n\n const { schema, wrap } = parseInsertAdjacentValues(values);\n\n ctx.body = await repository.insertAdjacent(position, resourceIndex, schema, {\n removeParentsIfNoChildren,\n breakRemoveOn,\n wrap,\n });\n\n await next();\n },\n\n insertBeforeBegin: insertPositionActionBuilder('beforeBegin'),\n insertAfterBegin: insertPositionActionBuilder('afterBegin'),\n insertBeforeEnd: insertPositionActionBuilder('beforeEnd'),\n insertAfterEnd: insertPositionActionBuilder('afterEnd'),\n\n async saveAsTemplate(ctx: Context, next) {\n const { filterByTk, values } = ctx.action.params;\n const db = ctx.db;\n const transaction = await db.sequelize.transaction();\n try {\n await db.getRepository('uiSchemaTemplates').create({\n values: {\n ...values,\n uid: filterByTk,\n },\n transaction,\n });\n await db.getRepository<UiSchemaRepository>('uiSchemas').clearAncestor(filterByTk, { transaction });\n ctx.body = {\n result: 'ok',\n };\n await transaction.commit();\n } catch (error) {\n await transaction.rollback();\n throw error;\n }\n await next();\n },\n};\n\nfunction insertPositionActionBuilder(position: 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd') {\n return async function (ctx: Context, next) {\n const { resourceIndex, values, removeParentsIfNoChildren, breakRemoveOn } = ctx.action.params;\n const repository = getRepositoryFromCtx(ctx);\n const { schema, wrap } = parseInsertAdjacentValues(values);\n\n ctx.body = await repository.insertAdjacent(position, resourceIndex, schema, {\n removeParentsIfNoChildren,\n breakRemoveOn,\n wrap,\n });\n await next();\n };\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
name: 'uiSchemaServerHooks',
|
|
5
|
+
model: 'ServerHookModel',
|
|
6
|
+
// autoGenId: false,
|
|
7
|
+
timestamps: false,
|
|
8
|
+
fields: [
|
|
9
|
+
{ type: 'belongsTo', name: 'uiSchema', target: 'uiSchemas', foreignKey: 'uid', onDelete: 'CASCADE' },
|
|
10
|
+
{ type: 'string', name: 'type' },
|
|
11
|
+
{
|
|
12
|
+
type: 'string',
|
|
13
|
+
name: 'collection',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: 'string',
|
|
17
|
+
name: 'field',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: 'string',
|
|
21
|
+
name: 'method',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'json',
|
|
25
|
+
name: 'params',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=uiSchemaServerHooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uiSchemaServerHooks.js","sourceRoot":"","sources":["../../src/collections/uiSchemaServerHooks.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,qBAAqB;IAC3B,KAAK,EAAE,iBAAiB;IACxB,oBAAoB;IACpB,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE;QACN,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE;QACpG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE;QAChC;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,YAAY;SACnB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;SACd;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;SACf;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;SACf;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'uiSchemaServerHooks',\n model: 'ServerHookModel',\n // autoGenId: false,\n timestamps: false,\n fields: [\n { type: 'belongsTo', name: 'uiSchema', target: 'uiSchemas', foreignKey: 'uid', onDelete: 'CASCADE' },\n { type: 'string', name: 'type' },\n {\n type: 'string',\n name: 'collection',\n },\n {\n type: 'string',\n name: 'field',\n },\n {\n type: 'string',\n name: 'method',\n },\n {\n type: 'json',\n name: 'params',\n },\n ],\n} as CollectionOptions;\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const database_1 = require("@nocobase/database");
|
|
4
|
+
exports.default = (0, database_1.defineCollection)({
|
|
5
|
+
name: 'uiSchemaTemplates',
|
|
6
|
+
autoGenId: false,
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
type: 'uid',
|
|
10
|
+
name: 'key',
|
|
11
|
+
primaryKey: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: 'string',
|
|
15
|
+
name: 'name',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: 'string',
|
|
19
|
+
name: 'componentName',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'string',
|
|
23
|
+
name: 'associationName',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'belongsTo',
|
|
27
|
+
name: 'uiSchema',
|
|
28
|
+
target: 'uiSchemas',
|
|
29
|
+
foreignKey: 'uid',
|
|
30
|
+
onDelete: 'CASCADE',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'belongsTo',
|
|
34
|
+
name: 'collection',
|
|
35
|
+
target: 'collections',
|
|
36
|
+
foreignKey: 'collectionName',
|
|
37
|
+
targetKey: 'name',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=uiSchemaTemplates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uiSchemaTemplates.js","sourceRoot":"","sources":["../../src/collections/uiSchemaTemplates.ts"],"names":[],"mappings":";;AAAA,iDAAsD;AAEtD,kBAAe,IAAA,2BAAgB,EAAC;IAC9B,IAAI,EAAE,mBAAmB;IACzB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE;QACN;YACE,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,KAAK;YACX,UAAU,EAAE,IAAI;SACjB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;SACb;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,eAAe;SACtB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,iBAAiB;SACxB;QACD;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,SAAS;SACpB;QACD;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,aAAa;YACrB,UAAU,EAAE,gBAAgB;YAC5B,SAAS,EAAE,MAAM;SAClB;KACF;CACF,CAAC,CAAC","sourcesContent":["import { defineCollection } from '@nocobase/database';\n\nexport default defineCollection({\n name: 'uiSchemaTemplates',\n autoGenId: false,\n fields: [\n {\n type: 'uid',\n name: 'key',\n primaryKey: true,\n },\n {\n type: 'string',\n name: 'name',\n },\n {\n type: 'string',\n name: 'componentName',\n },\n {\n type: 'string',\n name: 'associationName',\n },\n {\n type: 'belongsTo',\n name: 'uiSchema',\n target: 'uiSchemas',\n foreignKey: 'uid',\n onDelete: 'CASCADE',\n },\n {\n type: 'belongsTo',\n name: 'collection',\n target: 'collections',\n foreignKey: 'collectionName',\n targetKey: 'name',\n },\n ],\n});\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
name: 'uiSchemaTreePath',
|
|
5
|
+
autoGenId: false,
|
|
6
|
+
timestamps: false,
|
|
7
|
+
indexes: [
|
|
8
|
+
{
|
|
9
|
+
fields: ['descendant'],
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
fields: [
|
|
13
|
+
{
|
|
14
|
+
type: 'string',
|
|
15
|
+
name: 'ancestor',
|
|
16
|
+
primaryKey: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: 'string',
|
|
20
|
+
name: 'descendant',
|
|
21
|
+
primaryKey: true,
|
|
22
|
+
index: true,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: 'integer',
|
|
26
|
+
name: 'depth',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
name: 'async',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'string',
|
|
34
|
+
name: 'type',
|
|
35
|
+
comment: 'type of node',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'integer',
|
|
39
|
+
name: 'sort',
|
|
40
|
+
comment: 'sort of node in adjacency',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=uiSchemaTreePath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uiSchemaTreePath.js","sourceRoot":"","sources":["../../src/collections/uiSchemaTreePath.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,kBAAkB;IACxB,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,KAAK;IACjB,OAAO,EAAE;QACP;YACE,MAAM,EAAE,CAAC,YAAY,CAAC;SACvB;KACF;IACD,MAAM,EAAE;QACN;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,IAAI;SACjB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI;SACZ;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,OAAO;SACd;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,OAAO;SACd;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,cAAc;SACxB;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,2BAA2B;SACrC;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'uiSchemaTreePath',\n autoGenId: false,\n timestamps: false,\n indexes: [\n {\n fields: ['descendant'],\n },\n ],\n fields: [\n {\n type: 'string',\n name: 'ancestor',\n primaryKey: true,\n },\n {\n type: 'string',\n name: 'descendant',\n primaryKey: true,\n index: true,\n },\n {\n type: 'integer',\n name: 'depth',\n },\n {\n type: 'boolean',\n name: 'async',\n },\n {\n type: 'string',\n name: 'type',\n comment: 'type of node',\n },\n {\n type: 'integer',\n name: 'sort',\n comment: 'sort of node in adjacency',\n },\n ],\n} as CollectionOptions;\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
name: 'uiSchemas',
|
|
5
|
+
title: '字段配置',
|
|
6
|
+
autoGenId: false,
|
|
7
|
+
timestamps: false,
|
|
8
|
+
repository: 'UiSchemaRepository',
|
|
9
|
+
model: 'UiSchemaModel',
|
|
10
|
+
magicAttribute: 'schema',
|
|
11
|
+
fields: [
|
|
12
|
+
{
|
|
13
|
+
type: 'uid',
|
|
14
|
+
name: 'x-uid',
|
|
15
|
+
primaryKey: true,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: 'string',
|
|
19
|
+
name: 'name',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'hasMany',
|
|
23
|
+
name: 'serverHooks',
|
|
24
|
+
target: 'uiSchemaServerHooks',
|
|
25
|
+
foreignKey: 'uid',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'json',
|
|
29
|
+
name: 'schema',
|
|
30
|
+
defaultValue: {},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=uiSchemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uiSchemas.js","sourceRoot":"","sources":["../../src/collections/uiSchemas.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,MAAM;IACb,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,oBAAoB;IAChC,KAAK,EAAE,eAAe;IACtB,cAAc,EAAE,QAAQ;IACxB,MAAM,EAAE;QACN;YACE,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,OAAO;YACb,UAAU,EAAE,IAAI;SACjB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;SACb;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE,qBAAqB;YAC7B,UAAU,EAAE,KAAK;SAClB;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,EAAE;SACjB;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'uiSchemas',\n title: '字段配置',\n autoGenId: false,\n timestamps: false,\n repository: 'UiSchemaRepository',\n model: 'UiSchemaModel',\n magicAttribute: 'schema',\n fields: [\n {\n type: 'uid',\n name: 'x-uid',\n primaryKey: true,\n },\n {\n type: 'string',\n name: 'name',\n },\n {\n type: 'hasMany',\n name: 'serverHooks',\n target: 'uiSchemaServerHooks',\n foreignKey: 'uid',\n },\n {\n type: 'json',\n name: 'schema',\n defaultValue: {},\n },\n ],\n} as CollectionOptions;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UiSchemaDAO = void 0;
|
|
4
|
+
class UiSchemaDAO {
|
|
5
|
+
constructor(schema) {
|
|
6
|
+
this.nodeKeys = ['properties', 'patternProperties', 'additionalProperties'];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.UiSchemaDAO = UiSchemaDAO;
|
|
10
|
+
//# sourceMappingURL=ui_schema_dao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui_schema_dao.js","sourceRoot":"","sources":["../../src/dao/ui_schema_dao.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;IAGtB,YAAY,MAAW;QAFvB,aAAQ,GAAG,CAAC,YAAY,EAAE,mBAAmB,EAAE,sBAAsB,CAAC,CAAC;IAE7C,CAAC;CAC5B;AAJD,kCAIC","sourcesContent":["export class UiSchemaDAO {\n nodeKeys = ['properties', 'patternProperties', 'additionalProperties'];\n\n constructor(schema: any) {}\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface TargetPosition {
|
|
2
|
+
type: 'before' | 'after';
|
|
3
|
+
target: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ChildOptions {
|
|
6
|
+
parentUid: string;
|
|
7
|
+
parentPath?: string[];
|
|
8
|
+
type: string;
|
|
9
|
+
position?: 'first' | 'last' | TargetPosition;
|
|
10
|
+
sort?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SchemaNode {
|
|
13
|
+
name: string;
|
|
14
|
+
'x-uid': string;
|
|
15
|
+
schema: object;
|
|
16
|
+
'x-async'?: boolean;
|
|
17
|
+
childOptions?: ChildOptions;
|
|
18
|
+
}
|
|
19
|
+
export declare class UiSchemaNodeDAO {
|
|
20
|
+
schemaNode: SchemaNode;
|
|
21
|
+
constructor(schemaNode: SchemaNode);
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UiSchemaNodeDAO = void 0;
|
|
4
|
+
class UiSchemaNodeDAO {
|
|
5
|
+
constructor(schemaNode) {
|
|
6
|
+
this.schemaNode = schemaNode;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
exports.UiSchemaNodeDAO = UiSchemaNodeDAO;
|
|
10
|
+
//# sourceMappingURL=ui_schema_node_dao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui_schema_node_dao.js","sourceRoot":"","sources":["../../src/dao/ui_schema_node_dao.ts"],"names":[],"mappings":";;;AAoBA,MAAa,eAAe;IAE1B,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AALD,0CAKC","sourcesContent":["export interface TargetPosition {\n type: 'before' | 'after';\n target: string;\n}\nexport interface ChildOptions {\n parentUid: string;\n parentPath?: string[];\n type: string;\n position?: 'first' | 'last' | TargetPosition;\n sort?: number;\n}\n\nexport interface SchemaNode {\n name: string;\n 'x-uid': string;\n schema: object;\n 'x-async'?: boolean;\n childOptions?: ChildOptions;\n}\n\nexport class UiSchemaNodeDAO {\n schemaNode: SchemaNode;\n constructor(schemaNode: SchemaNode) {\n this.schemaNode = schemaNode;\n }\n}\n"]}
|
package/lib/helper.d.ts
ADDED
|
File without changes
|
package/lib/helper.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.default = void 0;
|
|
17
|
+
__exportStar(require("./repository"), exports);
|
|
18
|
+
__exportStar(require("./server"), exports);
|
|
19
|
+
var server_1 = require("./server");
|
|
20
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(server_1).default; } });
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,2CAAyB;AACzB,mCAAmC;AAA1B,kHAAA,OAAO,OAAA","sourcesContent":["export * from './repository';\nexport * from './server';\nexport { default } from './server';\n\n"]}
|
package/lib/model.d.ts
ADDED
package/lib/model.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UiSchemaModel = void 0;
|
|
4
|
+
const database_1 = require("@nocobase/database");
|
|
5
|
+
class UiSchemaModel extends database_1.MagicAttributeModel {
|
|
6
|
+
getServerHooksByType(type) {
|
|
7
|
+
const hooks = this.get('x-server-hooks') || [];
|
|
8
|
+
return hooks.filter((hook) => hook.type === type);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.UiSchemaModel = UiSchemaModel;
|
|
12
|
+
//# sourceMappingURL=model.js.map
|
package/lib/model.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";;;AAAA,iDAAyD;AAGzD,MAAM,aAAc,SAAQ,8BAAmB;IAC7C,oBAAoB,CAAC,IAAc;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACpD,CAAC;CACF;AAEQ,sCAAa","sourcesContent":["import { MagicAttributeModel } from '@nocobase/database';\nimport { HookType } from './server-hooks';\n\nclass UiSchemaModel extends MagicAttributeModel {\n getServerHooksByType(type: HookType) {\n const hooks = this.get('x-server-hooks') || [];\n return hooks.filter((hook) => hook.type === type);\n }\n}\n\nexport { UiSchemaModel };\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Repository, TransactionAble } from '@nocobase/database';
|
|
2
|
+
import { Transaction } from 'sequelize';
|
|
3
|
+
import { ChildOptions, SchemaNode } from './dao/ui_schema_node_dao';
|
|
4
|
+
interface GetJsonSchemaOptions {
|
|
5
|
+
includeAsyncNode?: boolean;
|
|
6
|
+
transaction?: Transaction;
|
|
7
|
+
}
|
|
8
|
+
declare type BreakRemoveOnType = {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
export interface removeParentOptions extends TransactionAble {
|
|
12
|
+
removeParentsIfNoChildren?: boolean;
|
|
13
|
+
breakRemoveOn?: BreakRemoveOnType;
|
|
14
|
+
}
|
|
15
|
+
interface InsertAdjacentOptions extends removeParentOptions {
|
|
16
|
+
wrap?: any;
|
|
17
|
+
}
|
|
18
|
+
export declare class UiSchemaRepository extends Repository {
|
|
19
|
+
tableNameAdapter(tableName: any): any;
|
|
20
|
+
get uiSchemasTableName(): any;
|
|
21
|
+
get uiSchemaTreePathTableName(): any;
|
|
22
|
+
sqlAdapter(sql: string): string;
|
|
23
|
+
static schemaToSingleNodes(schema: any, carry?: SchemaNode[], childOptions?: ChildOptions): SchemaNode[];
|
|
24
|
+
getProperties(uid: string, options?: TransactionAble): Promise<Partial<{
|
|
25
|
+
"x-uid": any;
|
|
26
|
+
"x-async": boolean;
|
|
27
|
+
}>>;
|
|
28
|
+
getJsonSchema(uid: string, options?: GetJsonSchemaOptions): Promise<any>;
|
|
29
|
+
private ignoreSchemaProperties;
|
|
30
|
+
nodesToSchema(nodes: any, rootUid: any): {
|
|
31
|
+
"x-uid": any;
|
|
32
|
+
"x-async": boolean;
|
|
33
|
+
};
|
|
34
|
+
clearAncestor(uid: string, options?: TransactionAble): Promise<void>;
|
|
35
|
+
patch(newSchema: any, options?: any): Promise<void>;
|
|
36
|
+
updateNode(uid: string, schema: any, transaction?: Transaction): Promise<void>;
|
|
37
|
+
protected childrenCount(uid: any, transaction: any): Promise<number>;
|
|
38
|
+
protected isLeafNode(uid: any, transaction: any): Promise<boolean>;
|
|
39
|
+
findParentUid(uid: any, transaction?: any): Promise<string>;
|
|
40
|
+
protected findNodeSchemaWithParent(uid: any, transaction: any): Promise<{
|
|
41
|
+
parentUid: string;
|
|
42
|
+
schema: import("@nocobase/database").Model<any, any>;
|
|
43
|
+
}>;
|
|
44
|
+
protected isSingleChild(uid: any, transaction: any): Promise<import("@nocobase/database").Model<any, any>>;
|
|
45
|
+
removeEmptyParents(options: TransactionAble & {
|
|
46
|
+
uid: string;
|
|
47
|
+
breakRemoveOn?: BreakRemoveOnType;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
private breakOnMatched;
|
|
50
|
+
recursivelyRemoveIfNoChildren(options: TransactionAble & {
|
|
51
|
+
uid: string;
|
|
52
|
+
breakRemoveOn?: BreakRemoveOnType;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
remove(uid: string, options?: TransactionAble & removeParentOptions): Promise<void>;
|
|
55
|
+
insertBeside(targetUid: string, schema: any, side: 'before' | 'after', options?: InsertAdjacentOptions): Promise<any>;
|
|
56
|
+
insertInner(targetUid: string, schema: any, position: 'first' | 'last', options?: InsertAdjacentOptions): Promise<any>;
|
|
57
|
+
private schemaExists;
|
|
58
|
+
insertAdjacent(position: 'beforeBegin' | 'afterBegin' | 'beforeEnd' | 'afterEnd', target: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
59
|
+
protected insertAfterBegin(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
60
|
+
protected insertBeforeEnd(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
61
|
+
protected insertBeforeBegin(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
62
|
+
protected insertAfterEnd(targetUid: string, schema: any, options?: InsertAdjacentOptions): Promise<any>;
|
|
63
|
+
insertNodes(nodes: SchemaNode[], options?: TransactionAble): Promise<any[]>;
|
|
64
|
+
insert(schema: any, options?: TransactionAble): Promise<any>;
|
|
65
|
+
insertNewSchema(schema: any, options?: TransactionAble & {
|
|
66
|
+
returnNode?: boolean;
|
|
67
|
+
}): Promise<any>;
|
|
68
|
+
private insertSchemaRecord;
|
|
69
|
+
private prepareSingleNodeForInsert;
|
|
70
|
+
insertSingleNode(schema: SchemaNode, options: TransactionAble & removeParentOptions): Promise<any>;
|
|
71
|
+
}
|
|
72
|
+
export default UiSchemaRepository;
|