@contember/bindx-generator 0.1.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/README.md +258 -0
- package/dist/BindxGenerator.d.ts +41 -0
- package/dist/BindxGenerator.d.ts.map +1 -0
- package/dist/BindxGenerator.js +124 -0
- package/dist/BindxGenerator.js.map +1 -0
- package/dist/EntityTypeSchemaGenerator.d.ts +13 -0
- package/dist/EntityTypeSchemaGenerator.d.ts.map +1 -0
- package/dist/EntityTypeSchemaGenerator.js +64 -0
- package/dist/EntityTypeSchemaGenerator.js.map +1 -0
- package/dist/EnumTypeSchemaGenerator.d.ts +9 -0
- package/dist/EnumTypeSchemaGenerator.d.ts.map +1 -0
- package/dist/EnumTypeSchemaGenerator.js +19 -0
- package/dist/EnumTypeSchemaGenerator.js.map +1 -0
- package/dist/NameSchemaGenerator.d.ts +34 -0
- package/dist/NameSchemaGenerator.d.ts.map +1 -0
- package/dist/NameSchemaGenerator.js +39 -0
- package/dist/NameSchemaGenerator.js.map +1 -0
- package/dist/RoleNameSchemaGenerator.d.ts +24 -0
- package/dist/RoleNameSchemaGenerator.d.ts.map +1 -0
- package/dist/RoleNameSchemaGenerator.js +194 -0
- package/dist/RoleNameSchemaGenerator.js.map +1 -0
- package/dist/RoleSchemaGenerator.d.ts +41 -0
- package/dist/RoleSchemaGenerator.d.ts.map +1 -0
- package/dist/RoleSchemaGenerator.js +169 -0
- package/dist/RoleSchemaGenerator.js.map +1 -0
- package/dist/generate.d.ts +12 -0
- package/dist/generate.d.ts.map +1 -0
- package/dist/generate.js +45 -0
- package/dist/generate.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +17 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +51 -0
- package/dist/utils.js.map +1 -0
- package/package.json +31 -0
- package/src/BindxGenerator.ts +154 -0
- package/src/EntityTypeSchemaGenerator.ts +77 -0
- package/src/EnumTypeSchemaGenerator.ts +24 -0
- package/src/NameSchemaGenerator.ts +66 -0
- package/src/RoleSchemaGenerator.ts +219 -0
- package/src/generate.ts +55 -0
- package/src/index.ts +19 -0
- package/src/utils.ts +54 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role-aware name schema generator for bindx
|
|
3
|
+
* Generates runtime schema names filtered by ACL permissions per role
|
|
4
|
+
*/
|
|
5
|
+
import { Model } from '@contember/schema';
|
|
6
|
+
import { acceptEveryFieldVisitor } from '@contember/schema-utils';
|
|
7
|
+
import { capitalizeFirstLetter } from './utils';
|
|
8
|
+
/**
|
|
9
|
+
* Checks if a role has read permission for an entity
|
|
10
|
+
*/
|
|
11
|
+
function hasEntityReadPermission(entityPermissions) {
|
|
12
|
+
if (!entityPermissions)
|
|
13
|
+
return false;
|
|
14
|
+
const readOps = entityPermissions.operations?.read;
|
|
15
|
+
return readOps !== undefined && Object.keys(readOps).length > 0;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a role has read permission for a specific field
|
|
19
|
+
*/
|
|
20
|
+
function hasFieldReadPermission(entityPermissions, fieldName, allowPredicateAccess) {
|
|
21
|
+
if (!entityPermissions)
|
|
22
|
+
return false;
|
|
23
|
+
const readOps = entityPermissions.operations?.read;
|
|
24
|
+
if (!readOps)
|
|
25
|
+
return false;
|
|
26
|
+
const fieldPermission = readOps[fieldName];
|
|
27
|
+
if (fieldPermission === undefined)
|
|
28
|
+
return false;
|
|
29
|
+
if (fieldPermission === false)
|
|
30
|
+
return false;
|
|
31
|
+
if (fieldPermission === true)
|
|
32
|
+
return true;
|
|
33
|
+
return allowPredicateAccess;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get merged permissions for a role, including inherited roles
|
|
37
|
+
*/
|
|
38
|
+
function getMergedPermissions(acl, roleName, visited = new Set()) {
|
|
39
|
+
if (visited.has(roleName)) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
visited.add(roleName);
|
|
43
|
+
const role = acl.roles[roleName];
|
|
44
|
+
if (!role)
|
|
45
|
+
return {};
|
|
46
|
+
const merged = {};
|
|
47
|
+
if (role.inherits) {
|
|
48
|
+
for (const inheritedRole of role.inherits) {
|
|
49
|
+
const inheritedPermissions = getMergedPermissions(acl, inheritedRole, visited);
|
|
50
|
+
for (const [entityName, entityPerms] of Object.entries(inheritedPermissions)) {
|
|
51
|
+
if (!merged[entityName]) {
|
|
52
|
+
merged[entityName] = { predicates: {}, operations: {} };
|
|
53
|
+
}
|
|
54
|
+
const existingOps = merged[entityName].operations;
|
|
55
|
+
const inheritedOps = entityPerms.operations;
|
|
56
|
+
merged[entityName] = {
|
|
57
|
+
...merged[entityName],
|
|
58
|
+
operations: {
|
|
59
|
+
...existingOps,
|
|
60
|
+
read: { ...existingOps?.read, ...inheritedOps?.read },
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const [entityName, entityPerms] of Object.entries(role.entities)) {
|
|
67
|
+
if (!merged[entityName]) {
|
|
68
|
+
merged[entityName] = entityPerms;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const existingOps = merged[entityName].operations;
|
|
72
|
+
const roleOps = entityPerms.operations;
|
|
73
|
+
merged[entityName] = {
|
|
74
|
+
...merged[entityName],
|
|
75
|
+
...entityPerms,
|
|
76
|
+
operations: {
|
|
77
|
+
...existingOps,
|
|
78
|
+
...roleOps,
|
|
79
|
+
read: { ...existingOps?.read, ...roleOps?.read },
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return merged;
|
|
85
|
+
}
|
|
86
|
+
export class RoleNameSchemaGenerator {
|
|
87
|
+
options;
|
|
88
|
+
constructor(options = {}) {
|
|
89
|
+
this.options = {
|
|
90
|
+
flattenInheritance: options.flattenInheritance ?? true,
|
|
91
|
+
allowPredicateAccess: options.allowPredicateAccess ?? true,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
generate(model, acl) {
|
|
95
|
+
const result = {};
|
|
96
|
+
for (const roleName of Object.keys(acl.roles)) {
|
|
97
|
+
result[roleName] = this.generateForRole(model, acl, roleName);
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
generateForRole(model, acl, roleName) {
|
|
102
|
+
const permissions = this.options.flattenInheritance
|
|
103
|
+
? getMergedPermissions(acl, roleName)
|
|
104
|
+
: acl.roles[roleName]?.entities ?? {};
|
|
105
|
+
const entities = {};
|
|
106
|
+
for (const entity of Object.values(model.entities)) {
|
|
107
|
+
const entityPerms = permissions[entity.name];
|
|
108
|
+
if (!hasEntityReadPermission(entityPerms)) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const fields = {};
|
|
112
|
+
const scalars = [];
|
|
113
|
+
acceptEveryFieldVisitor(model, entity, {
|
|
114
|
+
visitHasOne: ctx => {
|
|
115
|
+
if (!hasFieldReadPermission(entityPerms, ctx.relation.name, this.options.allowPredicateAccess)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const targetEntityPerms = permissions[ctx.targetEntity.name];
|
|
119
|
+
if (!hasEntityReadPermission(targetEntityPerms)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
fields[ctx.relation.name] = {
|
|
123
|
+
type: 'one',
|
|
124
|
+
entity: ctx.targetEntity.name,
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
visitHasMany: ctx => {
|
|
128
|
+
if (!hasFieldReadPermission(entityPerms, ctx.relation.name, this.options.allowPredicateAccess)) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const targetEntityPerms = permissions[ctx.targetEntity.name];
|
|
132
|
+
if (!hasEntityReadPermission(targetEntityPerms)) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
fields[ctx.relation.name] = {
|
|
136
|
+
type: 'many',
|
|
137
|
+
entity: ctx.targetEntity.name,
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
visitColumn: ctx => {
|
|
141
|
+
if (!hasFieldReadPermission(entityPerms, ctx.column.name, this.options.allowPredicateAccess)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
scalars.push(ctx.column.name);
|
|
145
|
+
fields[ctx.column.name] = {
|
|
146
|
+
type: 'column',
|
|
147
|
+
};
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
entities[entity.name] = { name: entity.name, fields, scalars };
|
|
151
|
+
}
|
|
152
|
+
// Filter enums to only include those used by accessible entities
|
|
153
|
+
const usedEnums = new Set();
|
|
154
|
+
for (const entity of Object.values(model.entities)) {
|
|
155
|
+
const entityPerms = permissions[entity.name];
|
|
156
|
+
if (!hasEntityReadPermission(entityPerms))
|
|
157
|
+
continue;
|
|
158
|
+
acceptEveryFieldVisitor(model, entity, {
|
|
159
|
+
visitColumn: ctx => {
|
|
160
|
+
if (ctx.column.type === Model.ColumnType.Enum) {
|
|
161
|
+
if (hasFieldReadPermission(entityPerms, ctx.column.name, this.options.allowPredicateAccess)) {
|
|
162
|
+
usedEnums.add(ctx.column.columnType);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
visitHasOne: () => { },
|
|
167
|
+
visitHasMany: () => { },
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const enums = Object.fromEntries(Object.entries(model.enums).filter(([name]) => usedEnums.has(name)));
|
|
171
|
+
return { entities, enums };
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Generate TypeScript code that exports the role schema names
|
|
175
|
+
*/
|
|
176
|
+
generateCode(model, acl) {
|
|
177
|
+
const schemaNames = this.generate(model, acl);
|
|
178
|
+
let code = `import type { BindxSchemaNames } from './types'\n\n`;
|
|
179
|
+
// Export individual role schemas
|
|
180
|
+
for (const roleName of Object.keys(acl.roles)) {
|
|
181
|
+
const roleTypeName = capitalizeFirstLetter(roleName);
|
|
182
|
+
code += `export const ${roleTypeName}SchemaNames: BindxSchemaNames = ${JSON.stringify(schemaNames[roleName], null, '\t')}\n\n`;
|
|
183
|
+
}
|
|
184
|
+
// Export combined role schemas object
|
|
185
|
+
code += `export const RoleSchemaNames = {\n`;
|
|
186
|
+
for (const roleName of Object.keys(acl.roles)) {
|
|
187
|
+
const roleTypeName = capitalizeFirstLetter(roleName);
|
|
188
|
+
code += `\t${roleName}: ${roleTypeName}SchemaNames,\n`;
|
|
189
|
+
}
|
|
190
|
+
code += `} as const\n`;
|
|
191
|
+
return code;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=RoleNameSchemaGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoleNameSchemaGenerator.js","sourceRoot":"","sources":["../src/RoleNameSchemaGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAO,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAM/C;;GAEG;AACH,SAAS,uBAAuB,CAC/B,iBAAoD;IAEpD,IAAI,CAAC,iBAAiB;QAAE,OAAO,KAAK,CAAA;IACpC,MAAM,OAAO,GAAG,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAA;IAClD,OAAO,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;AAChE,CAAC;AAED;;GAEG;AACH,SAAS,sBAAsB,CAC9B,iBAAoD,EACpD,SAAiB,EACjB,oBAA6B;IAE7B,IAAI,CAAC,iBAAiB;QAAE,OAAO,KAAK,CAAA;IACpC,MAAM,OAAO,GAAG,iBAAiB,CAAC,U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QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAE7C,IAAI,IAAI,GAAG,qDAAqD,CAAA;QAEhE,iCAAiC;QACjC,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,MAAM,YAAY,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;YACpD,IAAI,IAAI,gBAAgB,YAAY,mCAAmC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAA;QAC/H,CAAC;QAED,sCAAsC;QACtC,IAAI,IAAI,oCAAoC,CAAA;QAC5C,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,MAAM,YAAY,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;YACpD,IAAI,IAAI,KAAK,QAAQ,KAAK,YAAY,gBAAgB,CAAA;QACvD,CAAC;QACD,IAAI,IAAI,cAAc,CAAA;QAEtB,OAAO,IAAI,CAAA;IACZ,CAAC;CACD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role-aware schema generator for bindx.
|
|
3
|
+
*
|
|
4
|
+
* Generates per-role entity interfaces filtered by Contember ACL read permissions.
|
|
5
|
+
* For each role, only fields with read access (true or predicate) are included.
|
|
6
|
+
*/
|
|
7
|
+
import { Model, Acl } from '@contember/schema';
|
|
8
|
+
export interface RoleSchemaGeneratorOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Whether to treat predicate-based permissions as allowed.
|
|
11
|
+
* When true, any non-false permission allows access.
|
|
12
|
+
* When false, only explicit `true` permissions are allowed.
|
|
13
|
+
* Default: true
|
|
14
|
+
*/
|
|
15
|
+
allowPredicateAccess?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare class RoleSchemaGenerator {
|
|
18
|
+
private readonly allowPredicateAccess;
|
|
19
|
+
constructor(options?: RoleSchemaGeneratorOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Generates per-role entity types + role map types.
|
|
22
|
+
* Returns code to be appended to entities.ts.
|
|
23
|
+
*/
|
|
24
|
+
generateRoleEntities(model: Model.Schema, acl: Acl.Schema): string;
|
|
25
|
+
/**
|
|
26
|
+
* Generates schema.ts content using roleEntityDef.
|
|
27
|
+
*/
|
|
28
|
+
generateSchemaFile(model: Model.Schema, acl: Acl.Schema): string;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves role permissions, flattening inheritance.
|
|
31
|
+
* Returns a map: role → (entity → Set<fieldName>)
|
|
32
|
+
*/
|
|
33
|
+
private resolveRoles;
|
|
34
|
+
/**
|
|
35
|
+
* Generates per-role entity interfaces for a single role.
|
|
36
|
+
*/
|
|
37
|
+
private generateRoleEntityTypes;
|
|
38
|
+
private generateRoleEntityType;
|
|
39
|
+
private roleEntityName;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=RoleSchemaGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoleSchemaGenerator.d.ts","sourceRoot":"","sources":["../src/RoleSchemaGenerator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAI9C,MAAM,WAAW,0BAA0B;IAC1C;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAOD,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;gBAElC,OAAO,GAAE,0BAA+B;IAIpD;;;OAGG;IACH,oBAAoB,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM;IA8BlE;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM;IAqChE;;;OAGG;IACH,OAAO,CAAC,YAAY;IA+CpB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAiB/B,OAAO,CAAC,sBAAsB;IAqC9B,OAAO,CAAC,cAAc;CAGtB"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role-aware schema generator for bindx.
|
|
3
|
+
*
|
|
4
|
+
* Generates per-role entity interfaces filtered by Contember ACL read permissions.
|
|
5
|
+
* For each role, only fields with read access (true or predicate) are included.
|
|
6
|
+
*/
|
|
7
|
+
import { acceptEveryFieldVisitor } from '@contember/schema-utils';
|
|
8
|
+
import { columnToTsType } from './utils';
|
|
9
|
+
export class RoleSchemaGenerator {
|
|
10
|
+
allowPredicateAccess;
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.allowPredicateAccess = options.allowPredicateAccess ?? true;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generates per-role entity types + role map types.
|
|
16
|
+
* Returns code to be appended to entities.ts.
|
|
17
|
+
*/
|
|
18
|
+
generateRoleEntities(model, acl) {
|
|
19
|
+
const roles = this.resolveRoles(acl);
|
|
20
|
+
const roleNames = Object.keys(roles);
|
|
21
|
+
let code = '';
|
|
22
|
+
// Generate per-role entity interfaces
|
|
23
|
+
for (const roleName of roleNames) {
|
|
24
|
+
const roleAccess = roles[roleName];
|
|
25
|
+
code += this.generateRoleEntityTypes(model, roleName, roleAccess);
|
|
26
|
+
}
|
|
27
|
+
// Generate RoleSchemas type map per entity
|
|
28
|
+
for (const entity of Object.values(model.entities)) {
|
|
29
|
+
const roleEntries = roleNames
|
|
30
|
+
.filter(role => roles[role].has(entity.name))
|
|
31
|
+
.map(role => `\treadonly ${role}: ${this.roleEntityName(role, entity.name)}`)
|
|
32
|
+
.join('\n');
|
|
33
|
+
if (roleEntries) {
|
|
34
|
+
code += `export interface ${entity.name}$Roles {\n${roleEntries}\n}\n\n`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Export available roles type
|
|
38
|
+
code += `export type AvailableRoles = ${roleNames.map(r => `'${r}'`).join(' | ')}\n`;
|
|
39
|
+
return code;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Generates schema.ts content using roleEntityDef.
|
|
43
|
+
*/
|
|
44
|
+
generateSchemaFile(model, acl) {
|
|
45
|
+
const roles = this.resolveRoles(acl);
|
|
46
|
+
const roleNames = Object.keys(roles);
|
|
47
|
+
const entityNames = Object.values(model.entities).map(e => e.name).sort();
|
|
48
|
+
// Build imports for role entity types
|
|
49
|
+
const roleTypeImports = [];
|
|
50
|
+
for (const name of entityNames) {
|
|
51
|
+
const hasRoles = roleNames.some(role => roles[role].has(name));
|
|
52
|
+
if (hasRoles) {
|
|
53
|
+
roleTypeImports.push(`${name}$Roles`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const entries = entityNames.map(name => {
|
|
57
|
+
const hasRoles = roleNames.some(role => roles[role].has(name));
|
|
58
|
+
if (hasRoles) {
|
|
59
|
+
return `\t${name}: roleEntityDef<${name}$Roles>('${name}', schemaDef),`;
|
|
60
|
+
}
|
|
61
|
+
return `\t${name}: entityDef<${name}>('${name}', schemaDef),`;
|
|
62
|
+
}).join('\n');
|
|
63
|
+
const allImports = [...entityNames, ...roleTypeImports];
|
|
64
|
+
return `import { entityDef, roleEntityDef } from '@contember/bindx'
|
|
65
|
+
import { schemaNamesToDef } from '@contember/bindx-react'
|
|
66
|
+
import type { ${allImports.join(', ')} } from './entities'
|
|
67
|
+
import { schemaNames } from './names'
|
|
68
|
+
|
|
69
|
+
const schemaDef = schemaNamesToDef(schemaNames)
|
|
70
|
+
|
|
71
|
+
export const schema = {
|
|
72
|
+
${entries}
|
|
73
|
+
} as const
|
|
74
|
+
`;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolves role permissions, flattening inheritance.
|
|
78
|
+
* Returns a map: role → (entity → Set<fieldName>)
|
|
79
|
+
*/
|
|
80
|
+
resolveRoles(acl) {
|
|
81
|
+
const result = {};
|
|
82
|
+
for (const [roleName, rolePerms] of Object.entries(acl.roles)) {
|
|
83
|
+
// Skip implicit roles
|
|
84
|
+
if (rolePerms.implicit)
|
|
85
|
+
continue;
|
|
86
|
+
const entityFieldMap = new Map();
|
|
87
|
+
// Collect inherited fields first
|
|
88
|
+
if (rolePerms.inherits) {
|
|
89
|
+
for (const parentRole of rolePerms.inherits) {
|
|
90
|
+
const parentFields = result[parentRole];
|
|
91
|
+
if (parentFields) {
|
|
92
|
+
for (const [entityName, fields] of parentFields) {
|
|
93
|
+
const existing = entityFieldMap.get(entityName) ?? new Set();
|
|
94
|
+
for (const field of fields) {
|
|
95
|
+
existing.add(field);
|
|
96
|
+
}
|
|
97
|
+
entityFieldMap.set(entityName, existing);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Add own permissions
|
|
103
|
+
for (const [entityName, entityPerms] of Object.entries(rolePerms.entities)) {
|
|
104
|
+
const readPerms = entityPerms.operations.read;
|
|
105
|
+
if (!readPerms)
|
|
106
|
+
continue;
|
|
107
|
+
const fields = entityFieldMap.get(entityName) ?? new Set();
|
|
108
|
+
for (const [fieldName, perm] of Object.entries(readPerms)) {
|
|
109
|
+
if (perm === true || (this.allowPredicateAccess && perm !== false)) {
|
|
110
|
+
fields.add(fieldName);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (fields.size > 0) {
|
|
114
|
+
entityFieldMap.set(entityName, fields);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
result[roleName] = entityFieldMap;
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Generates per-role entity interfaces for a single role.
|
|
123
|
+
*/
|
|
124
|
+
generateRoleEntityTypes(model, roleName, roleAccess) {
|
|
125
|
+
let code = '';
|
|
126
|
+
for (const entity of Object.values(model.entities)) {
|
|
127
|
+
const accessibleFields = roleAccess.get(entity.name);
|
|
128
|
+
if (!accessibleFields || accessibleFields.size === 0)
|
|
129
|
+
continue;
|
|
130
|
+
code += this.generateRoleEntityType(model, entity, roleName, accessibleFields, roleAccess);
|
|
131
|
+
}
|
|
132
|
+
return code;
|
|
133
|
+
}
|
|
134
|
+
generateRoleEntityType(model, entity, roleName, accessibleFields, roleAccess) {
|
|
135
|
+
const typeName = this.roleEntityName(roleName, entity.name);
|
|
136
|
+
let code = `export interface ${typeName} {\n`;
|
|
137
|
+
acceptEveryFieldVisitor(model, entity, {
|
|
138
|
+
visitColumn: ctx => {
|
|
139
|
+
if (!accessibleFields.has(ctx.column.name))
|
|
140
|
+
return;
|
|
141
|
+
code += `\t${ctx.column.name}: ${columnToTsType(ctx.column)}${ctx.column.nullable ? ' | null' : ''}\n`;
|
|
142
|
+
},
|
|
143
|
+
visitHasOne: ctx => {
|
|
144
|
+
if (!accessibleFields.has(ctx.relation.name))
|
|
145
|
+
return;
|
|
146
|
+
const targetFields = roleAccess.get(ctx.targetEntity.name);
|
|
147
|
+
const targetType = targetFields && targetFields.size > 0
|
|
148
|
+
? this.roleEntityName(roleName, ctx.targetEntity.name)
|
|
149
|
+
: ctx.targetEntity.name;
|
|
150
|
+
code += `\t${ctx.relation.name}: ${targetType}\n`;
|
|
151
|
+
},
|
|
152
|
+
visitHasMany: ctx => {
|
|
153
|
+
if (!accessibleFields.has(ctx.relation.name))
|
|
154
|
+
return;
|
|
155
|
+
const targetFields = roleAccess.get(ctx.targetEntity.name);
|
|
156
|
+
const targetType = targetFields && targetFields.size > 0
|
|
157
|
+
? this.roleEntityName(roleName, ctx.targetEntity.name)
|
|
158
|
+
: ctx.targetEntity.name;
|
|
159
|
+
code += `\t${ctx.relation.name}: ${targetType}[]\n`;
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
code += '}\n\n';
|
|
163
|
+
return code;
|
|
164
|
+
}
|
|
165
|
+
roleEntityName(roleName, entityName) {
|
|
166
|
+
return `${entityName}$${roleName}`;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=RoleSchemaGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoleSchemaGenerator.js","sourceRoot":"","sources":["../src/RoleSchemaGenerator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAA;AAiBzD,MAAM,OAAO,mBAAmB;IACd,oBAAoB,CAAS;IAE9C,YAAY,UAAsC,EAAE;QACnD,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,IAAI,IAAI,CAAA;IACjE,CAAC;IAED;;;OAGG;IACH,oBAAoB,CAAC,KAAmB,EAAE,GAAe;QACxD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;QACpC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAEpC,IAAI,IAAI,GAAG,EAAE,CAAA;QAEb,sCAAsC;QACtC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YAClC,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAE,CAAA;YACnC,IAAI,IAAI,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;QAClE,CAAC;QAED,2CAA2C;QAC3C,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;YACpD,MAAM,WAAW,GAAG,SAAS;iBAC3B,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;iBAC7C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AY,CAAC,IAAI,GAAG,CAAC;oBACvD,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;oBACtD,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAA;gBACxB,IAAI,IAAI,KAAK,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,IAAI,CAAA;YAClD,CAAC;YACD,YAAY,EAAE,GAAG,CAAC,EAAE;gBACnB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAAE,OAAM;gBACpD,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;gBAC1D,MAAM,UAAU,GAAG,YAAY,IAAI,YAAY,CAAC,IAAI,GAAG,CAAC;oBACvD,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;oBACtD,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAA;gBACxB,IAAI,IAAI,KAAK,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,MAAM,CAAA;YACpD,CAAC;SACD,CAAC,CAAA;QAEF,IAAI,IAAI,OAAO,CAAA;QACf,OAAO,IAAI,CAAA;IACZ,CAAC;IAEO,cAAc,CAAC,QAAgB,EAAE,UAAkB;QAC1D,OAAO,GAAG,UAAU,IAAI,QAAQ,EAAE,CAAA;IACnC,CAAC;CACD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Example script to generate bindx schema from Contember Model
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* bun run packages/bindx-generator/scripts/generate.ts ./path/to/model.ts ./path/to/output/dir
|
|
7
|
+
*
|
|
8
|
+
* This script demonstrates how to use the bindx generator to create
|
|
9
|
+
* TypeScript schema files from a Contember model.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG"}
|
package/dist/generate.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Example script to generate bindx schema from Contember Model
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* bun run packages/bindx-generator/scripts/generate.ts ./path/to/model.ts ./path/to/output/dir
|
|
7
|
+
*
|
|
8
|
+
* This script demonstrates how to use the bindx generator to create
|
|
9
|
+
* TypeScript schema files from a Contember model.
|
|
10
|
+
*/
|
|
11
|
+
import { generate } from './index';
|
|
12
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
13
|
+
import { join } from 'node:path';
|
|
14
|
+
async function main() {
|
|
15
|
+
console.log('Generating bindx schema...');
|
|
16
|
+
const schemaFile = process.argv[2];
|
|
17
|
+
const outputPath = process.argv[3];
|
|
18
|
+
if (!schemaFile || !outputPath) {
|
|
19
|
+
console.error('Usage: bun run generate.ts <schema-file> <output-dir>');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
const absoluteSchemaFile = join(process.cwd(), schemaFile);
|
|
23
|
+
const schema = (await import(absoluteSchemaFile)).default;
|
|
24
|
+
// Generate schema files
|
|
25
|
+
const files = generate(schema.model);
|
|
26
|
+
// Output directory
|
|
27
|
+
const outputDir = join(process.cwd(), outputPath);
|
|
28
|
+
// Create output directory
|
|
29
|
+
await mkdir(outputDir, { recursive: true });
|
|
30
|
+
// Write files
|
|
31
|
+
for (const [filename, content] of Object.entries(files)) {
|
|
32
|
+
const filePath = join(outputDir, filename);
|
|
33
|
+
await writeFile(filePath, String(content), 'utf-8');
|
|
34
|
+
console.log(`Generated: ${filePath}`);
|
|
35
|
+
}
|
|
36
|
+
console.log(`\nSchema generation complete!`);
|
|
37
|
+
console.log(`\nGenerated files in: ${outputDir}`);
|
|
38
|
+
console.log('\nTo use the generated schema:');
|
|
39
|
+
console.log(' import { useEntity, Entity } from "./generated"');
|
|
40
|
+
}
|
|
41
|
+
main().catch(error => {
|
|
42
|
+
console.error('Error generating schema:', error);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,KAAK,UAAU,IAAI;IAClB,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;IAEzC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAClC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAElC,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,KAAK,CAAC,uDAAuD,CAAC,CAAA;QACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC;IAED,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAA;IAC1D,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAA;IAEzD,wBAAwB;IACxB,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAEpC,mBAAmB;IACnB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAA;IAEjD,0BAA0B;IAC1B,MAAM,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAE3C,cAAc;IACd,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;QAC1C,MAAM,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAA;QACnD,OAAO,CAAC,GAAG,CAAC,cAAc,QAAQ,EAAE,CAAC,CAAA;IACtC,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;IAC5C,OAAO,CAAC,GAAG,CAAC,yBAAyB,SAAS,EAAE,CAAC,CAAA;IACjD,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;IAC7C,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAA;AACjE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACpB,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;IAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAChB,CAAC,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @contember/bindx-generator
|
|
3
|
+
*
|
|
4
|
+
* Schema generator for @contember/bindx.
|
|
5
|
+
* Generates TypeScript types and runtime schema definitions from
|
|
6
|
+
* Contember Model.Schema.
|
|
7
|
+
*/
|
|
8
|
+
export { BindxGenerator, generate } from './BindxGenerator';
|
|
9
|
+
export type { BindxGeneratorOptions, GeneratedFiles } from './BindxGenerator';
|
|
10
|
+
export { EntityTypeSchemaGenerator } from './EntityTypeSchemaGenerator';
|
|
11
|
+
export { EnumTypeSchemaGenerator } from './EnumTypeSchemaGenerator';
|
|
12
|
+
export { NameSchemaGenerator } from './NameSchemaGenerator';
|
|
13
|
+
export { RoleSchemaGenerator } from './RoleSchemaGenerator';
|
|
14
|
+
export type { RoleSchemaGeneratorOptions } from './RoleSchemaGenerator';
|
|
15
|
+
export type { BindxSchemaNames, BindxSchemaEntityNames } from './NameSchemaGenerator';
|
|
16
|
+
export { columnToTsType, getEnumTypeName, capitalizeFirstLetter } from './utils';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3D,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,YAAY,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AACvE,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAErF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @contember/bindx-generator
|
|
3
|
+
*
|
|
4
|
+
* Schema generator for @contember/bindx.
|
|
5
|
+
* Generates TypeScript types and runtime schema definitions from
|
|
6
|
+
* Contember Model.Schema.
|
|
7
|
+
*/
|
|
8
|
+
export { BindxGenerator, generate } from './BindxGenerator';
|
|
9
|
+
export { EntityTypeSchemaGenerator } from './EntityTypeSchemaGenerator';
|
|
10
|
+
export { EnumTypeSchemaGenerator } from './EnumTypeSchemaGenerator';
|
|
11
|
+
export { NameSchemaGenerator } from './NameSchemaGenerator';
|
|
12
|
+
export { RoleSchemaGenerator } from './RoleSchemaGenerator';
|
|
13
|
+
export { columnToTsType, getEnumTypeName, capitalizeFirstLetter } from './utils';
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAG3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAI3D,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for bindx schema generation
|
|
3
|
+
*/
|
|
4
|
+
import { Model } from '@contember/schema';
|
|
5
|
+
/**
|
|
6
|
+
* Convert Contember column type to TypeScript type string
|
|
7
|
+
*/
|
|
8
|
+
export declare const columnToTsType: (column: Model.AnyColumn) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Generate TypeScript enum type name from Contember enum name
|
|
11
|
+
*/
|
|
12
|
+
export declare const getEnumTypeName: (enumName: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Capitalize first letter of a string
|
|
15
|
+
*/
|
|
16
|
+
export declare const capitalizeFirstLetter: (value: string) => string;
|
|
17
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzC;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,KAAK,CAAC,SAAS,KAAG,MA8BxD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,KAAG,MAElD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO,MAAM,KAAG,MAErD,CAAA"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for bindx schema generation
|
|
3
|
+
*/
|
|
4
|
+
import { Model } from '@contember/schema';
|
|
5
|
+
/**
|
|
6
|
+
* Convert Contember column type to TypeScript type string
|
|
7
|
+
*/
|
|
8
|
+
export const columnToTsType = (column) => {
|
|
9
|
+
const baseType = (() => {
|
|
10
|
+
switch (column.type) {
|
|
11
|
+
case Model.ColumnType.Enum:
|
|
12
|
+
return getEnumTypeName(column.columnType);
|
|
13
|
+
case Model.ColumnType.String:
|
|
14
|
+
return 'string';
|
|
15
|
+
case Model.ColumnType.Int:
|
|
16
|
+
return 'number';
|
|
17
|
+
case Model.ColumnType.Double:
|
|
18
|
+
return 'number';
|
|
19
|
+
case Model.ColumnType.Bool:
|
|
20
|
+
return 'boolean';
|
|
21
|
+
case Model.ColumnType.DateTime:
|
|
22
|
+
return 'string';
|
|
23
|
+
case Model.ColumnType.Time:
|
|
24
|
+
return 'string';
|
|
25
|
+
case Model.ColumnType.Date:
|
|
26
|
+
return 'string';
|
|
27
|
+
case Model.ColumnType.Json:
|
|
28
|
+
return 'JSONValue';
|
|
29
|
+
case Model.ColumnType.Uuid:
|
|
30
|
+
return 'string';
|
|
31
|
+
default:
|
|
32
|
+
((_) => {
|
|
33
|
+
throw new Error(`Unknown column type ${_}`);
|
|
34
|
+
})(column.type);
|
|
35
|
+
}
|
|
36
|
+
})();
|
|
37
|
+
return column.list ? `readonly ${baseType}[]` : baseType;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Generate TypeScript enum type name from Contember enum name
|
|
41
|
+
*/
|
|
42
|
+
export const getEnumTypeName = (enumName) => {
|
|
43
|
+
return `${enumName}Enum`;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Capitalize first letter of a string
|
|
47
|
+
*/
|
|
48
|
+
export const capitalizeFirstLetter = (value) => {
|
|
49
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAuB,EAAU,EAAE;IACjE,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE;QACtB,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,KAAK,CAAC,UAAU,CAAC,IAAI;gBACzB,OAAO,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;YAC1C,KAAK,KAAK,CAAC,UAAU,CAAC,MAAM;gBAC3B,OAAO,QAAQ,CAAA;YAChB,KAAK,KAAK,CAAC,UAAU,CAAC,GAAG;gBACxB,OAAO,QAAQ,CAAA;YAChB,KAAK,KAAK,CAAC,UAAU,CAAC,MAAM;gBAC3B,OAAO,QAAQ,CAAA;YAChB,KAAK,KAAK,CAAC,UAAU,CAAC,IAAI;gBACzB,OAAO,SAAS,CAAA;YACjB,KAAK,KAAK,CAAC,UAAU,CAAC,QAAQ;gBAC7B,OAAO,QAAQ,CAAA;YAChB,KAAK,KAAK,CAAC,UAAU,CAAC,IAAI;gBACzB,OAAO,QAAQ,CAAA;YAChB,KAAK,KAAK,CAAC,UAAU,CAAC,IAAI;gBACzB,OAAO,QAAQ,CAAA;YAChB,KAAK,KAAK,CAAC,UAAU,CAAC,IAAI;gBACzB,OAAO,WAAW,CAAA;YACnB,KAAK,KAAK,CAAC,UAAU,CAAC,IAAI;gBACzB,OAAO,QAAQ,CAAA;YAChB;gBACC,CAAC,CAAC,CAAQ,EAAE,EAAE;oBACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAA;gBAC5C,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACjB,CAAC;IACF,CAAC,CAAC,EAAE,CAAA;IACJ,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,QAAQ,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAA;AACzD,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAU,EAAE;IAC3D,OAAO,GAAG,QAAQ,MAAM,CAAA;AACzB,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAU,EAAE;IAC9D,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACtD,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contember/bindx-generator",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Schema generator for @contember/bindx with role-based ACL support",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.ts"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc --build",
|
|
12
|
+
"typecheck": "tsc --build"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"src"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@contember/schema": "^2.1.0-alpha.30",
|
|
21
|
+
"@contember/schema-utils": "^2.1.0-alpha.30"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^25.0.3"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/contember/bindx.git",
|
|
29
|
+
"directory": "packages/bindx-generator"
|
|
30
|
+
}
|
|
31
|
+
}
|