manifest 4.16.3 → 4.18.0--beta.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 +1 -4
- package/dist/common/src/Helpers.js +3 -0
- package/dist/json-schema/src/index.js +4 -0
- package/dist/json-schema/src/schema/definitions/endpoint-schema.json +1 -1
- package/dist/json-schema/src/schema/definitions/entity-schema.json +4 -4
- package/dist/json-schema/src/schema/definitions/group-schema.json +26 -0
- package/dist/json-schema/src/schema/definitions/property-options/group-options-schema.json +19 -0
- package/dist/json-schema/src/schema/definitions/property-options/image-options-schema.json +1 -1
- package/dist/json-schema/src/schema/definitions/property-options/money-options-schema.json +1 -1
- package/dist/json-schema/src/schema/definitions/property-schema.json +15 -5
- package/dist/json-schema/src/schema/definitions/relationship-schema.json +1 -1
- package/dist/json-schema/src/schema/definitions/settings-schema.json +1 -1
- package/dist/json-schema/src/schema/schema.json +7 -0
- package/dist/manifest/src/crud/records/prop-type-valid-where-operators.js +2 -1
- package/dist/manifest/src/crud/services/crud.service.js +19 -9
- package/dist/manifest/src/entity/columns/mysql-prop-type-column-types.js +2 -1
- package/dist/manifest/src/entity/columns/postgres-prop-type-column-types copy.js +2 -1
- package/dist/manifest/src/entity/columns/sqlite-prop-type-column-types.js +2 -1
- package/dist/manifest/src/entity/services/entity-loader.service.d.ts +5 -5
- package/dist/manifest/src/entity/services/entity-loader.service.js +10 -8
- package/dist/manifest/src/entity/services/entity-type.service.js +33 -24
- package/dist/manifest/src/entity/services/entity.service.js +2 -1
- package/dist/manifest/src/entity/services/relationship.service.js +18 -4
- package/dist/manifest/src/entity/types/entity-ts-type-info.d.ts +1 -0
- package/dist/manifest/src/entity/types/prop-type-ts-type.js +2 -1
- package/dist/manifest/src/manifest/manifest.module.js +5 -1
- package/dist/manifest/src/manifest/services/entity-manifest.service.d.ts +13 -6
- package/dist/manifest/src/manifest/services/entity-manifest.service.js +45 -46
- package/dist/manifest/src/manifest/services/lock-file.service.d.ts +19 -0
- package/dist/manifest/src/manifest/services/lock-file.service.js +248 -0
- package/dist/manifest/src/manifest/services/manifest.service.d.ts +3 -1
- package/dist/manifest/src/manifest/services/manifest.service.js +13 -6
- package/dist/manifest/src/manifest/services/property-manifest.service.d.ts +4 -0
- package/dist/manifest/src/manifest/services/property-manifest.service.js +41 -0
- package/dist/manifest/src/manifest/services/relationship-manifest.service.d.ts +3 -1
- package/dist/manifest/src/manifest/services/relationship-manifest.service.js +56 -3
- package/dist/manifest/src/manifest/services/schema.service.d.ts +1 -0
- package/dist/manifest/src/manifest/services/schema.service.js +56 -1
- package/dist/manifest/src/open-api/schemas/prop-type-examples.js +2 -1
- package/dist/manifest/src/open-api/schemas/prop-type-formats.js +2 -1
- package/dist/manifest/src/open-api/services/open-api-crud.service.js +3 -5
- package/dist/manifest/src/open-api/services/open-api-schema.service.js +3 -0
- package/dist/manifest/src/seed/services/seeder.service.js +34 -4
- package/dist/manifest/src/validation/records/type-validators.js +2 -1
- package/dist/manifest/src/validation/services/validation.service.d.ts +5 -2
- package/dist/manifest/src/validation/services/validation.service.js +44 -1
- package/dist/manifest/src/validation/validation.module.js +2 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/src/common/AppEnvironment.d.ts +1 -0
- package/dist/types/src/common/AppEnvironment.js +2 -0
- package/dist/types/src/common/index.d.ts +1 -0
- package/dist/types/src/common/index.js +1 -0
- package/dist/types/src/crud/PropType.d.ts +2 -1
- package/dist/types/src/crud/PropType.js +1 -0
- package/dist/types/src/manifests/AppManifest.d.ts +3 -1
- package/dist/types/src/manifests/EntityManifest.d.ts +1 -0
- package/dist/types/src/manifests/EntityManifestCommonFields.d.ts +1 -1
- package/dist/types/src/manifests/ManifestSchema.d.ts +11 -1
- package/dist/types/src/manifests/RelationshipManifest.d.ts +2 -1
- package/package.json +2 -1
- package/dist/admin/256.cf479e10e4de8f41.js +0 -1
- package/dist/admin/45.f16207d428e7b8ce.js +0 -1
- package/dist/admin/69.3a06102c8e39ae88.js +0 -1
- package/dist/admin/693.78d2d5a546c5c39a.js +0 -1
- package/dist/admin/assets/fonts/mnfst-icon.svg +0 -41
- package/dist/admin/assets/fonts/mnfst-icon.ttf +0 -0
- package/dist/admin/assets/fonts/mnfst-icon.woff +0 -0
- package/dist/admin/assets/images/avatar-default.svg +0 -21
- package/dist/admin/assets/images/ext-link-01.svg +0 -68
- package/dist/admin/assets/images/ext-link-dc.svg +0 -11
- package/dist/admin/assets/images/ext-link-gh.svg +0 -11
- package/dist/admin/assets/images/favicon.png +0 -0
- package/dist/admin/assets/images/logo.svg +0 -97
- package/dist/admin/assets/images/open-api/favicon.ico +0 -0
- package/dist/admin/index.html +0 -13
- package/dist/admin/main.674db67fd5a7f27a.js +0 -50
- package/dist/admin/polyfills.2aefc0784c3d32a6.js +0 -7
- package/dist/admin/runtime.7c4d5bc807141c6a.js +0 -1
- package/dist/admin/styles.8ccfc17311992374.css +0 -7
package/README.md
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
<a href="https://manifest.build/#gh-light-mode-only">
|
|
3
3
|
<img alt="manifest" src="https://manifest.build/assets/images/logo-transparent.svg" height="55px" alt="Manifest logo" title="Manifest - The backend for AI code editors" />
|
|
4
4
|
</a>
|
|
5
|
-
<a href="https://manifest.build/#gh-dark-mode-only">
|
|
6
|
-
<img alt="manifest" src="https://manifest.build/assets/images/logo-light.svg" height="55px" alt="Manifest logo" title="Manifest - The backend for AI code editors" />
|
|
7
|
-
</a>
|
|
8
5
|
</p>
|
|
9
6
|
|
|
10
7
|
<p align='center'>
|
|
@@ -22,7 +19,7 @@
|
|
|
22
19
|
<br>
|
|
23
20
|
|
|
24
21
|
</p>
|
|
25
|
-
|
|
22
|
+
Manifest is a backend your AI can understand and your team can trust.
|
|
26
23
|
|
|
27
24
|
It allows you to create a backend with data, storage, logic and an admin panel. All is defined in **1 YAML file** that both humans and LLMs can understand and edit. ✨
|
|
28
25
|
|
|
@@ -45,6 +45,9 @@ function getRandomIntExcluding({ min, max, exclude }) {
|
|
|
45
45
|
: randomInt;
|
|
46
46
|
}
|
|
47
47
|
function getDtoPropertyNameFromRelationship(relationship) {
|
|
48
|
+
if (relationship.nested) {
|
|
49
|
+
return relationship.name;
|
|
50
|
+
}
|
|
48
51
|
if (relationship?.type === 'many-to-one') {
|
|
49
52
|
return relationship.name + 'Id';
|
|
50
53
|
}
|
|
@@ -20,6 +20,8 @@ const endpoint_schema_json_1 = __importDefault(require("./schema/definitions/end
|
|
|
20
20
|
const middleware_schema_json_1 = __importDefault(require("./schema/definitions/middlewares/middleware-schema.json"));
|
|
21
21
|
const middlewares_schema_json_1 = __importDefault(require("./schema/definitions/middlewares/middlewares-schema.json"));
|
|
22
22
|
const settings_schema_json_1 = __importDefault(require("./schema/definitions/settings-schema.json"));
|
|
23
|
+
const group_schema_json_1 = __importDefault(require("./schema/definitions/group-schema.json"));
|
|
24
|
+
const group_options_schema_json_1 = __importDefault(require("./schema/definitions/property-options/group-options-schema.json"));
|
|
23
25
|
exports.default = [
|
|
24
26
|
schema_json_1.default,
|
|
25
27
|
entity_schema_json_1.default,
|
|
@@ -30,6 +32,7 @@ exports.default = [
|
|
|
30
32
|
choice_options_schema_json_1.default,
|
|
31
33
|
money_options_schema_json_1.default,
|
|
32
34
|
image_options_schema_json_1.default,
|
|
35
|
+
group_options_schema_json_1.default,
|
|
33
36
|
policies_schema_json_1.default,
|
|
34
37
|
policy_schema_json_1.default,
|
|
35
38
|
hooks_schema_json_1.default,
|
|
@@ -37,5 +40,6 @@ exports.default = [
|
|
|
37
40
|
middlewares_schema_json_1.default,
|
|
38
41
|
middleware_schema_json_1.default,
|
|
39
42
|
endpoint_schema_json_1.default,
|
|
43
|
+
group_schema_json_1.default,
|
|
40
44
|
settings_schema_json_1.default
|
|
41
45
|
];
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"enum": ["GET", "POST", "PATCH", "PUT", "DELETE"]
|
|
17
17
|
},
|
|
18
18
|
"handler": {
|
|
19
|
-
"description": "The name of the handler function for this endpoint. Doc: https://manifest.build/docs/endpoints
|
|
19
|
+
"description": "The name of the handler function for this endpoint. Doc: https://manifest.build/docs/endpoints",
|
|
20
20
|
"type": "string"
|
|
21
21
|
},
|
|
22
22
|
"description": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"type": "integer"
|
|
31
31
|
},
|
|
32
32
|
"authenticable": {
|
|
33
|
-
"description": "Whether the entity is authenticable. Doc: https://manifest.build/docs/
|
|
33
|
+
"description": "Whether the entity is authenticable. Doc: https://manifest.build/docs/authentication#authenticable-entities",
|
|
34
34
|
"type": "boolean"
|
|
35
35
|
},
|
|
36
36
|
"single": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"default": false
|
|
40
40
|
},
|
|
41
41
|
"properties": {
|
|
42
|
-
"description": "The properties of the entity. Doc: https://manifest.build/docs/entities",
|
|
42
|
+
"description": "The properties of the entity. Doc: https://manifest.build/docs/entities#properties",
|
|
43
43
|
"type": "array",
|
|
44
44
|
"items": {
|
|
45
45
|
"$ref": "property-schema.json"
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"belongsToMany": {
|
|
56
|
-
"description": "The ManyToMany relationships of the entity. Doc: https://manifest.build/docs/relations",
|
|
56
|
+
"description": "The ManyToMany relationships of the entity. Doc: https://manifest.build/docs/entities#relations",
|
|
57
57
|
"type": "array",
|
|
58
58
|
"items": {
|
|
59
59
|
"$ref": "relationship-schema.json"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"policies": {
|
|
63
|
-
"description": "The policies of the entity. Doc: https://manifest.build/docs/
|
|
63
|
+
"description": "The policies of the entity. Doc: https://manifest.build/docs/access",
|
|
64
64
|
"type": "object",
|
|
65
65
|
"$ref": "./policies/policies-schema.json"
|
|
66
66
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://schema.manifest.build/definitions/group-schema.json",
|
|
4
|
+
"title": "Group Schema",
|
|
5
|
+
"description": "A group of reusable properties to be used in entities. Doc: https://manifest.build/docs/entities#groups",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"properties": {
|
|
9
|
+
"description": "The properties of the group. Doc: https://manifest.build/docs/entities#properties",
|
|
10
|
+
"type": "array",
|
|
11
|
+
"items": {
|
|
12
|
+
"$ref": "property-schema.json"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"validation": {
|
|
16
|
+
"description": "Validation object for the properties. Doc: https://manifest.build/docs/validation",
|
|
17
|
+
"type": "object",
|
|
18
|
+
"properties": {
|
|
19
|
+
"*": {
|
|
20
|
+
"$ref": "./validation-schema.json"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"additionalProperties": false
|
|
26
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://schema.manifest.build/definitions/property-options/group-options-schema.json",
|
|
4
|
+
"title": "Group Options Schema",
|
|
5
|
+
"description": "A group a reusable properties. Doc: https://manifest.build/docs/entities#groups",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"group": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The name of the group of properties."
|
|
11
|
+
},
|
|
12
|
+
"multiple": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"description": "Multiple groups allow to add several items (default: true)."
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"required": ["group"],
|
|
18
|
+
"additionalProperties": false
|
|
19
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"$id": "https://schema.manifest.build/definitions/property-options/image-options-schema.json",
|
|
4
4
|
"title": "Image Options Schema",
|
|
5
|
-
"description": "Specific options for the \"image\" property type.",
|
|
5
|
+
"description": "Specific options for the \"image\" property type. Doc: https://manifest.build/docs/entities#image",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"sizes": {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"$id": "https://schema.manifest.build/definitions/property-options/money-options-schema.json",
|
|
4
4
|
"title": "Money Options Schema",
|
|
5
|
-
"description": "Specific options for the \"Money\" property type. Doc: https://manifest.build/docs/
|
|
5
|
+
"description": "Specific options for the \"Money\" property type. Doc: https://manifest.build/docs/entities#money",
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"currency": {
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"type": "object",
|
|
9
9
|
"properties": {
|
|
10
10
|
"name": {
|
|
11
|
-
"description": "The name of the property. Doc: https://manifest.build/docs/properties",
|
|
11
|
+
"description": "The name of the property. Doc: https://manifest.build/docs/entities#properties",
|
|
12
12
|
"type": "string"
|
|
13
13
|
},
|
|
14
14
|
"type": {
|
|
15
|
-
"description": "The type of the property: text, number, link, currency... Default \"string\". Doc: https://manifest.build/docs/
|
|
15
|
+
"description": "The type of the property: text, number, link, currency... Default \"string\". Doc: https://manifest.build/docs/entities#property-types",
|
|
16
16
|
"type": "string",
|
|
17
17
|
"enum": [
|
|
18
18
|
"string",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"choice",
|
|
30
30
|
"location",
|
|
31
31
|
"file",
|
|
32
|
-
"image"
|
|
32
|
+
"image",
|
|
33
|
+
"group"
|
|
33
34
|
]
|
|
34
35
|
},
|
|
35
36
|
"helpText": {
|
|
@@ -41,11 +42,11 @@
|
|
|
41
42
|
"$ref": "./validation-schema.json"
|
|
42
43
|
},
|
|
43
44
|
"default": {
|
|
44
|
-
"description": "The default value of the property. Doc: https://manifest.build/docs/
|
|
45
|
+
"description": "The default value of the property. Doc: https://manifest.build/docs/entities#property-params",
|
|
45
46
|
"type": ["string", "number", "boolean", "object", "array"]
|
|
46
47
|
},
|
|
47
48
|
"hidden": {
|
|
48
|
-
"description": "If the property should be hidden in the API response. Default false. Doc: https://manifest.build/docs/
|
|
49
|
+
"description": "If the property should be hidden in the API response. Default false. Doc: https://manifest.build/docs/entities#property-params",
|
|
49
50
|
"type": "boolean"
|
|
50
51
|
},
|
|
51
52
|
"options": {
|
|
@@ -81,6 +82,15 @@
|
|
|
81
82
|
"then": {
|
|
82
83
|
"$ref": "./property-options/image-options-schema.json"
|
|
83
84
|
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"if": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"properties": { "type": { "const": "group" } }
|
|
90
|
+
},
|
|
91
|
+
"then": {
|
|
92
|
+
"$ref": "./property-options/group-options-schema.json"
|
|
93
|
+
}
|
|
84
94
|
}
|
|
85
95
|
]
|
|
86
96
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
3
|
"$id": "https://schema.manifest.build/definitions/relationship-schema.json",
|
|
4
4
|
"title": "Relationship Schema",
|
|
5
|
-
"description": "A relationship between two entities",
|
|
5
|
+
"description": "A relationship between two entities. Doc: https://manifest.build/docs/entities#relations",
|
|
6
6
|
"anyOf": [
|
|
7
7
|
{
|
|
8
8
|
"type": "object",
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"rateLimits": {
|
|
9
|
-
"description": "Rate limiting configuration for your app",
|
|
9
|
+
"description": "Rate limiting configuration for your app. Doc: https://manifest.build/docs/security#rate-limiting",
|
|
10
10
|
"type": "array",
|
|
11
11
|
"items": {
|
|
12
12
|
"type": "object",
|
|
@@ -20,6 +20,13 @@
|
|
|
20
20
|
"$ref": "./definitions/entity-schema.json"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
+
"groups": {
|
|
24
|
+
"description": "Groups of reusable properties to be used in entities. Doc: https://manifest.build/docs/entities#groups",
|
|
25
|
+
"type": "object",
|
|
26
|
+
"additionalProperties": {
|
|
27
|
+
"$ref": "./definitions/group-schema.json"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
23
30
|
"endpoints": {
|
|
24
31
|
"description": "The endpoints in your app. Create your own endpoints linking a path and an HTTP method to a handler function. Doc: https://manifest.build/docs/endpoints",
|
|
25
32
|
"type": "object",
|
|
@@ -85,7 +85,8 @@ exports.PROP_TYPE_VALID_WHERE_OPERATORS = {
|
|
|
85
85
|
src_1.WhereOperator.In
|
|
86
86
|
],
|
|
87
87
|
[src_1.PropType.Image]: [],
|
|
88
|
-
[src_1.PropType.Password]: []
|
|
88
|
+
[src_1.PropType.Password]: [],
|
|
89
|
+
[src_1.PropType.Nested]: []
|
|
89
90
|
};
|
|
90
91
|
function isValidWhereOperator(propType, operator) {
|
|
91
92
|
return exports.PROP_TYPE_VALID_WHERE_OPERATORS[propType].includes(operator);
|
|
@@ -36,6 +36,14 @@ let CrudService = class CrudService {
|
|
|
36
36
|
const entityMetadata = entityRepository.metadata;
|
|
37
37
|
const allColumns = entityMetadata.columns.map((col) => col.propertyName);
|
|
38
38
|
const validRelationships = entityMetadata.relations.map((rel) => rel.propertyName);
|
|
39
|
+
const validNestedRelationships = entityMetadata.relations
|
|
40
|
+
.filter((relation) => (relation.relationType === 'one-to-many' ||
|
|
41
|
+
relation.relationType === 'one-to-one') &&
|
|
42
|
+
this.entityManifestService.getEntityManifest({
|
|
43
|
+
className: relation.type,
|
|
44
|
+
includeNested: true
|
|
45
|
+
}).nested)
|
|
46
|
+
.map((r) => r.propertyName);
|
|
39
47
|
const validProperties = allColumns.filter((col) => !validRelationships.includes(col));
|
|
40
48
|
return Object.fromEntries(Object.entries(itemDto).filter(([key]) => {
|
|
41
49
|
if (validProperties.includes(key)) {
|
|
@@ -45,6 +53,9 @@ let CrudService = class CrudService {
|
|
|
45
53
|
validRelationships.includes(key.slice(0, -2))) {
|
|
46
54
|
return true;
|
|
47
55
|
}
|
|
56
|
+
if (validNestedRelationships.includes(key)) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
48
59
|
return false;
|
|
49
60
|
}));
|
|
50
61
|
}
|
|
@@ -148,9 +159,8 @@ let CrudService = class CrudService {
|
|
|
148
159
|
});
|
|
149
160
|
const relationItems = await this.relationshipService.fetchRelationItemsFromDto({
|
|
150
161
|
itemDto,
|
|
151
|
-
relationships: entityManifest.relationships
|
|
152
|
-
|
|
153
|
-
.filter((r) => r.type !== 'many-to-many' || r.owningSide)
|
|
162
|
+
relationships: entityManifest.relationships.filter((r) => r.type === 'many-to-one' ||
|
|
163
|
+
(r.type === 'many-to-many' && r.owningSide))
|
|
154
164
|
});
|
|
155
165
|
const newItem = this.createWithDefaults({
|
|
156
166
|
repository,
|
|
@@ -193,9 +203,8 @@ let CrudService = class CrudService {
|
|
|
193
203
|
}
|
|
194
204
|
const relationItems = await this.relationshipService.fetchRelationItemsFromDto({
|
|
195
205
|
itemDto,
|
|
196
|
-
relationships: entityManifest.relationships
|
|
197
|
-
|
|
198
|
-
.filter((r) => r.type !== 'many-to-many' || r.owningSide),
|
|
206
|
+
relationships: entityManifest.relationships.filter((r) => r.type === 'many-to-one' ||
|
|
207
|
+
(r.type === 'many-to-many' && r.owningSide)),
|
|
199
208
|
emptyMissing: !partialReplacement
|
|
200
209
|
});
|
|
201
210
|
let filteredItemDto = this.filterValidProperties(itemDto, entityRepository);
|
|
@@ -231,7 +240,7 @@ let CrudService = class CrudService {
|
|
|
231
240
|
.getEntityManifest({
|
|
232
241
|
slug: entitySlug
|
|
233
242
|
})
|
|
234
|
-
.relationships.filter((r) => r.type === 'one-to-many');
|
|
243
|
+
.relationships.filter((r) => r.type === 'one-to-many' && !r.nested);
|
|
235
244
|
const item = await entityRepository.findOne({
|
|
236
245
|
where: { id },
|
|
237
246
|
relations: oneToManyRelationships.map((r) => r.name)
|
|
@@ -247,7 +256,7 @@ let CrudService = class CrudService {
|
|
|
247
256
|
}
|
|
248
257
|
});
|
|
249
258
|
}
|
|
250
|
-
await entityRepository.
|
|
259
|
+
await entityRepository.remove(item);
|
|
251
260
|
return item;
|
|
252
261
|
}
|
|
253
262
|
createWithDefaults({ repository, entityManifest, itemDto }) {
|
|
@@ -277,7 +286,8 @@ let CrudService = class CrudService {
|
|
|
277
286
|
const aliasName = (0, common_2.camelize)([alias, relationMetadata.propertyName]);
|
|
278
287
|
query.leftJoin(`${alias}.${relationMetadata.propertyName}`, aliasName);
|
|
279
288
|
const relationEntityManifest = this.entityManifestService.getEntityManifest({
|
|
280
|
-
className: relationMetadata.inverseEntityMetadata.targetName
|
|
289
|
+
className: relationMetadata.inverseEntityMetadata.targetName,
|
|
290
|
+
includeNested: true
|
|
281
291
|
});
|
|
282
292
|
query.addSelect(this.getVisibleProps({
|
|
283
293
|
props: relationEntityManifest.properties,
|
|
@@ -17,5 +17,6 @@ exports.mysqlPropTypeColumnTypes = {
|
|
|
17
17
|
[types_1.PropType.Choice]: 'varchar',
|
|
18
18
|
[types_1.PropType.Location]: 'json',
|
|
19
19
|
[types_1.PropType.File]: 'varchar',
|
|
20
|
-
[types_1.PropType.Image]: 'json'
|
|
20
|
+
[types_1.PropType.Image]: 'json',
|
|
21
|
+
[types_1.PropType.Nested]: 'varchar'
|
|
21
22
|
};
|
|
@@ -17,5 +17,6 @@ exports.postgresPropTypeColumnTypes = {
|
|
|
17
17
|
[types_1.PropType.Choice]: 'text',
|
|
18
18
|
[types_1.PropType.Location]: 'jsonb',
|
|
19
19
|
[types_1.PropType.File]: 'varchar',
|
|
20
|
-
[types_1.PropType.Image]: 'jsonb'
|
|
20
|
+
[types_1.PropType.Image]: 'jsonb',
|
|
21
|
+
[types_1.PropType.Nested]: 'varchar'
|
|
21
22
|
};
|
|
@@ -17,5 +17,6 @@ exports.sqlitePropTypeColumnTypes = {
|
|
|
17
17
|
[types_1.PropType.Choice]: 'simple-enum',
|
|
18
18
|
[types_1.PropType.Location]: 'json',
|
|
19
19
|
[types_1.PropType.File]: 'varchar',
|
|
20
|
-
[types_1.PropType.Image]: 'json'
|
|
20
|
+
[types_1.PropType.Image]: 'json',
|
|
21
|
+
[types_1.PropType.Nested]: 'varchar'
|
|
21
22
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AuthenticableEntity, BaseEntity, DatabaseConnection } from '@repo/types';
|
|
2
|
-
import { EntitySchema, EntitySchemaColumnOptions } from 'typeorm';
|
|
2
|
+
import { EntitySchema as TypeORMEntitySchema, EntitySchemaColumnOptions } from 'typeorm';
|
|
3
3
|
import { RelationshipService } from './relationship.service';
|
|
4
|
-
import {
|
|
4
|
+
import { ManifestService } from '../../manifest/services/manifest.service';
|
|
5
5
|
export declare class EntityLoaderService {
|
|
6
|
-
private
|
|
6
|
+
private manifestService;
|
|
7
7
|
private relationshipService;
|
|
8
|
-
constructor(
|
|
9
|
-
loadEntities(dbConnection: DatabaseConnection):
|
|
8
|
+
constructor(manifestService: ManifestService, relationshipService: RelationshipService);
|
|
9
|
+
loadEntities(dbConnection: DatabaseConnection): TypeORMEntitySchema[];
|
|
10
10
|
getBaseEntityColumns(dbConnection: DatabaseConnection): {
|
|
11
11
|
[key in keyof BaseEntity]: EntitySchemaColumnOptions;
|
|
12
12
|
};
|
|
@@ -15,20 +15,22 @@ const common_1 = require("@nestjs/common");
|
|
|
15
15
|
const typeorm_1 = require("typeorm");
|
|
16
16
|
const sqlite_prop_type_column_types_1 = require("../columns/sqlite-prop-type-column-types");
|
|
17
17
|
const relationship_service_1 = require("./relationship.service");
|
|
18
|
-
const entity_manifest_service_1 = require("../../manifest/services/entity-manifest.service");
|
|
19
18
|
const mysql_prop_type_column_types_1 = require("../columns/mysql-prop-type-column-types");
|
|
20
19
|
const postgres_prop_type_column_types_copy_1 = require("../columns/postgres-prop-type-column-types copy");
|
|
21
20
|
const column_service_1 = require("./column.service");
|
|
22
21
|
const boolean_transformer_1 = require("../transformers/boolean-transformer");
|
|
23
22
|
const number_transformer_1 = require("../transformers/number-transformer");
|
|
24
23
|
const timestamp_transformer_1 = require("../transformers/timestamp-transformer");
|
|
24
|
+
const manifest_service_1 = require("../../manifest/services/manifest.service");
|
|
25
25
|
let EntityLoaderService = class EntityLoaderService {
|
|
26
|
-
constructor(
|
|
27
|
-
this.
|
|
26
|
+
constructor(manifestService, relationshipService) {
|
|
27
|
+
this.manifestService = manifestService;
|
|
28
28
|
this.relationshipService = relationshipService;
|
|
29
29
|
}
|
|
30
30
|
loadEntities(dbConnection) {
|
|
31
|
-
const
|
|
31
|
+
const appManifest = this.manifestService.getAppManifest({
|
|
32
|
+
fullVersion: true
|
|
33
|
+
});
|
|
32
34
|
let columns;
|
|
33
35
|
switch (dbConnection) {
|
|
34
36
|
case 'sqlite':
|
|
@@ -41,7 +43,7 @@ let EntityLoaderService = class EntityLoaderService {
|
|
|
41
43
|
columns = mysql_prop_type_column_types_1.mysqlPropTypeColumnTypes;
|
|
42
44
|
break;
|
|
43
45
|
}
|
|
44
|
-
const entitySchemas =
|
|
46
|
+
const entitySchemas = Object.values(appManifest.entities).map((entityManifest) => {
|
|
45
47
|
const entitySchema = new typeorm_1.EntitySchema({
|
|
46
48
|
name: entityManifest.className,
|
|
47
49
|
columns: entityManifest.properties.reduce((acc, propManifest) => {
|
|
@@ -63,11 +65,11 @@ let EntityLoaderService = class EntityLoaderService {
|
|
|
63
65
|
nullable: true
|
|
64
66
|
};
|
|
65
67
|
return acc;
|
|
66
|
-
}, entityManifest
|
|
68
|
+
}, entityManifest['authenticable']
|
|
67
69
|
? { ...this.getBaseAuthenticableEntityColumns(dbConnection) }
|
|
68
70
|
: { ...this.getBaseEntityColumns(dbConnection) }),
|
|
69
71
|
relations: this.relationshipService.getEntitySchemaRelationOptions(entityManifest),
|
|
70
|
-
uniques: entityManifest
|
|
72
|
+
uniques: entityManifest['authenticable'] ? [{ columns: ['email'] }] : []
|
|
71
73
|
});
|
|
72
74
|
return entitySchema;
|
|
73
75
|
});
|
|
@@ -124,6 +126,6 @@ let EntityLoaderService = class EntityLoaderService {
|
|
|
124
126
|
exports.EntityLoaderService = EntityLoaderService;
|
|
125
127
|
exports.EntityLoaderService = EntityLoaderService = __decorate([
|
|
126
128
|
(0, common_1.Injectable)(),
|
|
127
|
-
__metadata("design:paramtypes", [
|
|
129
|
+
__metadata("design:paramtypes", [manifest_service_1.ManifestService,
|
|
128
130
|
relationship_service_1.RelationshipService])
|
|
129
131
|
], EntityLoaderService);
|
|
@@ -24,7 +24,9 @@ let EntityTypeService = class EntityTypeService {
|
|
|
24
24
|
const appManifest = this.manifestService.getAppManifest();
|
|
25
25
|
const entityTsTypeInfos = [];
|
|
26
26
|
Object.values(appManifest.entities).map((entity) => entityTsTypeInfos.push(this.generateEntityTypeInfoFromManifest(entity)));
|
|
27
|
-
Object.values(appManifest.entities)
|
|
27
|
+
Object.values(appManifest.entities)
|
|
28
|
+
.filter((entity) => !entity.nested)
|
|
29
|
+
.map((entity) => {
|
|
28
30
|
entityTsTypeInfos.push(this.generateCreateDtoTypeInfoFromManifest(entity));
|
|
29
31
|
});
|
|
30
32
|
return entityTsTypeInfos;
|
|
@@ -63,28 +65,31 @@ let EntityTypeService = class EntityTypeService {
|
|
|
63
65
|
}
|
|
64
66
|
return propertyTsTypeInfo;
|
|
65
67
|
});
|
|
66
|
-
entityManifest.
|
|
67
|
-
|
|
68
|
-
relationship.type === '
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
68
|
+
if (!entityManifest.nested) {
|
|
69
|
+
entityManifest.relationships.forEach((relationship) => {
|
|
70
|
+
if (relationship.type === 'many-to-many' ||
|
|
71
|
+
relationship.type === 'one-to-many') {
|
|
72
|
+
propertyTypeInfos.push({
|
|
73
|
+
name: relationship.name,
|
|
74
|
+
type: `${relationship.entity}[]`,
|
|
75
|
+
isRelationship: true,
|
|
76
|
+
optional: true
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
propertyTypeInfos.push({
|
|
81
|
+
name: relationship.name,
|
|
82
|
+
type: relationship.entity,
|
|
83
|
+
isRelationship: true,
|
|
84
|
+
optional: true
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
85
89
|
return {
|
|
86
90
|
name: entityManifest.className,
|
|
87
|
-
properties: propertyTypeInfos
|
|
91
|
+
properties: propertyTypeInfos,
|
|
92
|
+
nested: entityManifest.nested
|
|
88
93
|
};
|
|
89
94
|
}
|
|
90
95
|
generateCreateDtoTypeInfoFromManifest(entityManifest) {
|
|
@@ -110,14 +115,18 @@ let EntityTypeService = class EntityTypeService {
|
|
|
110
115
|
return propertyTsTypeInfo;
|
|
111
116
|
});
|
|
112
117
|
entityManifest.relationships.forEach((relationship) => {
|
|
113
|
-
if (relationship.type === 'one-to-many') {
|
|
118
|
+
if (relationship.type === 'one-to-many' && !relationship.nested) {
|
|
114
119
|
return;
|
|
115
120
|
}
|
|
116
121
|
const dtoPropertyName = (0, src_2.getDtoPropertyNameFromRelationship)(relationship);
|
|
117
|
-
const isMultiple = relationship.type === 'many-to-many'
|
|
122
|
+
const isMultiple = relationship.type === 'many-to-many' ||
|
|
123
|
+
relationship.type === 'one-to-many';
|
|
124
|
+
const type = relationship.nested
|
|
125
|
+
? relationship.entity
|
|
126
|
+
: `string`;
|
|
118
127
|
propertyTypeInfos.push({
|
|
119
128
|
name: dtoPropertyName,
|
|
120
|
-
type: isMultiple ?
|
|
129
|
+
type: isMultiple ? `${type}[]` : type,
|
|
121
130
|
isRelationship: true,
|
|
122
131
|
optional: true
|
|
123
132
|
});
|
|
@@ -28,7 +28,8 @@ let EntityService = class EntityService {
|
|
|
28
28
|
if (slug) {
|
|
29
29
|
className = this.entityManifestService.getEntityManifest({
|
|
30
30
|
slug,
|
|
31
|
-
fullVersion: true
|
|
31
|
+
fullVersion: true,
|
|
32
|
+
includeNested: true
|
|
32
33
|
}).className;
|
|
33
34
|
}
|
|
34
35
|
const entityMetadata = this.dataSource.entityMetadatas.find((entity) => entity.targetName === className);
|
|
@@ -33,7 +33,8 @@ let RelationshipService = class RelationshipService {
|
|
|
33
33
|
relationOptions[belongsToRelationShip.name] = {
|
|
34
34
|
target: belongsToRelationShip.entity,
|
|
35
35
|
type: 'many-to-one',
|
|
36
|
-
eager: !!belongsToRelationShip.eager
|
|
36
|
+
eager: !!belongsToRelationShip.eager,
|
|
37
|
+
onDelete: entityManifest.nested ? 'CASCADE' : 'SET NULL'
|
|
37
38
|
};
|
|
38
39
|
});
|
|
39
40
|
entityManifest.relationships
|
|
@@ -54,12 +55,25 @@ let RelationshipService = class RelationshipService {
|
|
|
54
55
|
entityManifest.relationships
|
|
55
56
|
.filter((relationship) => relationship.type === 'one-to-many')
|
|
56
57
|
.forEach((oneToManyRelationship) => {
|
|
57
|
-
|
|
58
|
-
relationOptions[relationshipName] = {
|
|
58
|
+
relationOptions[oneToManyRelationship.name] = {
|
|
59
59
|
target: oneToManyRelationship.entity,
|
|
60
60
|
type: 'one-to-many',
|
|
61
61
|
eager: false,
|
|
62
|
-
inverseSide: oneToManyRelationship.inverseSide
|
|
62
|
+
inverseSide: oneToManyRelationship.inverseSide,
|
|
63
|
+
cascade: oneToManyRelationship.nested
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
entityManifest.relationships
|
|
67
|
+
.filter((relationship) => relationship.type === 'one-to-one')
|
|
68
|
+
.forEach((oneToOneRelationship) => {
|
|
69
|
+
relationOptions[oneToOneRelationship.name] = {
|
|
70
|
+
target: oneToOneRelationship.entity,
|
|
71
|
+
type: 'one-to-one',
|
|
72
|
+
eager: false,
|
|
73
|
+
inverseSide: oneToOneRelationship.inverseSide,
|
|
74
|
+
cascade: !!oneToOneRelationship.nested,
|
|
75
|
+
onDelete: entityManifest.nested ? 'CASCADE' : 'SET NULL',
|
|
76
|
+
joinColumn: !!entityManifest.nested
|
|
63
77
|
};
|
|
64
78
|
});
|
|
65
79
|
return relationOptions;
|
|
@@ -17,5 +17,6 @@ exports.propTypeTsType = {
|
|
|
17
17
|
[src_1.PropType.Choice]: 'string',
|
|
18
18
|
[src_1.PropType.Location]: '{ lat: number; lng: number }',
|
|
19
19
|
[src_1.PropType.File]: 'string',
|
|
20
|
-
[src_1.PropType.Image]: 'string'
|
|
20
|
+
[src_1.PropType.Image]: 'string',
|
|
21
|
+
[src_1.PropType.Nested]: 'string'
|
|
21
22
|
};
|
|
@@ -19,6 +19,8 @@ const manifest_service_1 = require("./services/manifest.service");
|
|
|
19
19
|
const hook_module_1 = require("../hook/hook.module");
|
|
20
20
|
const policy_module_1 = require("../policy/policy.module");
|
|
21
21
|
const endpoint_module_1 = require("../endpoint/endpoint.module");
|
|
22
|
+
const property_manifest_service_1 = require("./services/property-manifest.service");
|
|
23
|
+
const lock_file_service_1 = require("./services/lock-file.service");
|
|
22
24
|
let ManifestModule = class ManifestModule {
|
|
23
25
|
};
|
|
24
26
|
exports.ManifestModule = ManifestModule;
|
|
@@ -36,7 +38,9 @@ exports.ManifestModule = ManifestModule = __decorate([
|
|
|
36
38
|
yaml_service_1.YamlService,
|
|
37
39
|
schema_service_1.SchemaService,
|
|
38
40
|
entity_manifest_service_1.EntityManifestService,
|
|
39
|
-
|
|
41
|
+
property_manifest_service_1.PropertyManifestService,
|
|
42
|
+
relationship_manifest_service_1.RelationshipManifestService,
|
|
43
|
+
lock_file_service_1.LockFileService
|
|
40
44
|
],
|
|
41
45
|
controllers: [manifest_controller_1.ManifestController],
|
|
42
46
|
exports: [manifest_service_1.ManifestService, entity_manifest_service_1.EntityManifestService, relationship_manifest_service_1.RelationshipManifestService]
|