@twin.org/entity 0.0.3-next.23 → 0.0.3-next.24
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/dist/es/decorators/entityDecorator.js +1 -0
- package/dist/es/decorators/entityDecorator.js.map +1 -1
- package/dist/es/decorators/propertyDecorator.js +1 -0
- package/dist/es/decorators/propertyDecorator.js.map +1 -1
- package/dist/es/utils/decoratorHelper.js +1 -0
- package/dist/es/utils/decoratorHelper.js.map +1 -1
- package/dist/types/decorators/entityDecorator.d.ts +1 -0
- package/dist/types/decorators/propertyDecorator.d.ts +1 -0
- package/dist/types/utils/decoratorHelper.d.ts +1 -0
- package/docs/changelog.md +19 -0
- package/docs/reference/interfaces/IComparatorGroup.md +1 -1
- package/docs/reference/interfaces/IEntitySchema.md +2 -2
- package/docs/reference/interfaces/IEntitySchemaOptions.md +1 -1
- package/docs/reference/interfaces/IEntitySchemaProperty.md +9 -9
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entityDecorator.js","sourceRoot":"","sources":["../../../src/decorators/entityDecorator.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,uDAAuD;AACvD,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"entityDecorator.js","sourceRoot":"","sources":["../../../src/decorators/entityDecorator.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,uDAAuD;AACvD,OAAO,kBAAkB,CAAC;AAC1B,OAAO,OAAO,CAAC;AAEf,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,OAA8B;IACpD,OAAO,CAAC,MAAW,EAAE,EAAE;QACtB,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACvD,YAAY,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QAChC,YAAY,CAAC,OAAO,GAAG,OAAO,CAAC;QAC/B,eAAe,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport \"reflect-metadata\";\nimport \"tslib\";\nimport type { IEntitySchemaOptions } from \"../models/IEntitySchemaOptions.js\";\nimport { DecoratorHelper } from \"../utils/decoratorHelper.js\";\n\n/**\n * Decorator to produce schema data for entity.\n * @param options The options for the entity.\n * @returns The class decorator.\n */\nexport function entity(options?: IEntitySchemaOptions): any {\n\treturn (target: any) => {\n\t\tconst entitySchema = DecoratorHelper.getSchema(target);\n\t\tentitySchema.type = target.name;\n\t\tentitySchema.options = options;\n\t\tDecoratorHelper.setSchema(target, entitySchema);\n\t};\n}\n"]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
4
|
import "reflect-metadata";
|
|
5
|
+
import "tslib";
|
|
5
6
|
import { DecoratorHelper } from "../utils/decoratorHelper.js";
|
|
6
7
|
/**
|
|
7
8
|
* Decorator to produce schema property data for entities.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propertyDecorator.js","sourceRoot":"","sources":["../../../src/decorators/propertyDecorator.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,uDAAuD;AACvD,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"propertyDecorator.js","sourceRoot":"","sources":["../../../src/decorators/propertyDecorator.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,uDAAuD;AACvD,OAAO,kBAAkB,CAAC;AAC1B,OAAO,OAAO,CAAC;AAEf,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAgD;IACxE,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QAC3C,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAM,MAAM,CAAC,CAAC;QAC5D,YAAY,CAAC,UAAU,KAAK,EAAE,CAAC;QAC/B,MAAM,GAAG,GAAG,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,WAAW,CAAC,CAAC;QAC/E,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;YAChB,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG;gBAC9B,GAAG,OAAO;gBACV,QAAQ,EAAE,WAAW;aACrB,CAAC;QACH,CAAC;aAAM,CAAC;YACP,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC;gBAC5B,GAAG,OAAO;gBACV,QAAQ,EAAE,WAAW;aACrB,CAAC,CAAC;QACJ,CAAC;QACD,eAAe,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACjD,CAAC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport \"reflect-metadata\";\nimport \"tslib\";\nimport type { IEntitySchemaProperty } from \"../models/IEntitySchemaProperty.js\";\nimport { DecoratorHelper } from \"../utils/decoratorHelper.js\";\n\n/**\n * Decorator to produce schema property data for entities.\n * @param options The options for the property.\n * @returns The property decorator.\n */\nexport function property(options: Omit<IEntitySchemaProperty, \"property\">): any {\n\treturn (target: any, propertyKey: string) => {\n\t\tconst entitySchema = DecoratorHelper.getSchema<any>(target);\n\t\tentitySchema.properties ??= [];\n\t\tconst idx = entitySchema.properties.findIndex(p => p.property === propertyKey);\n\t\tif (idx !== -1) {\n\t\t\tentitySchema.properties[idx] = {\n\t\t\t\t...options,\n\t\t\t\tproperty: propertyKey\n\t\t\t};\n\t\t} else {\n\t\t\tentitySchema.properties.push({\n\t\t\t\t...options,\n\t\t\t\tproperty: propertyKey\n\t\t\t});\n\t\t}\n\t\tDecoratorHelper.setSchema(target, entitySchema);\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decoratorHelper.js","sourceRoot":"","sources":["../../../src/utils/decoratorHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"decoratorHelper.js","sourceRoot":"","sources":["../../../src/utils/decoratorHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,kBAAkB,CAAC;AAC1B,OAAO,OAAO,CAAC;AAGf,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAE7C;;GAEG;AACH,MAAM,OAAO,eAAe;IAC3B;;;;OAIG;IACH,8DAA8D;IACvD,MAAM,CAAC,SAAS,CAAc,MAAW;QAC/C,OAAO,CACN,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;YAC1F,EAAE,CACF,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,8DAA8D;IACvD,MAAM,CAAC,SAAS,CAAc,MAAW,EAAE,YAA8B;QAC/E,OAAO,CAAC,cAAc,CACrB,aAAa,EACb,YAAY,EACZ,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CACtD,CAAC;IACH,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport \"reflect-metadata\";\nimport \"tslib\";\nimport type { IEntitySchema } from \"../models/IEntitySchema.js\";\n\nconst META_DATA_KEY = \"EntitySchemaMetadata\";\n\n/**\n * Class to help with decorators.\n */\nexport class DecoratorHelper {\n\t/**\n\t * Get the schema from the reflection metadata.\n\t * @param target The object to get the schema data from.\n\t * @returns The schema from the metadata if it can be found.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic static getSchema<T = unknown>(target: any): IEntitySchema<T> {\n\t\treturn (\n\t\t\tReflect.getMetadata(META_DATA_KEY, typeof target === \"object\" ? target : target.prototype) ??\n\t\t\t{}\n\t\t);\n\t}\n\n\t/**\n\t * Set the schema from the reflection metadata.\n\t * @param target The object to get the schema data from.\n\t * @param entitySchema The schema to set.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic static setSchema<T = unknown>(target: any, entitySchema: IEntitySchema<T>): void {\n\t\tReflect.defineMetadata(\n\t\t\tMETA_DATA_KEY,\n\t\t\tentitySchema,\n\t\t\ttypeof target === \"object\" ? target : target.prototype\n\t\t);\n\t}\n}\n"]}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.24](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.23...entity-v0.0.3-next.24) (2026-03-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* ensure __decorate is defined for decorators ([103a563](https://github.com/twinfoundation/framework/commit/103a563ce01ebdef6240d2e590e7b026e8692684))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/nameof bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
16
|
+
* @twin.org/core bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
17
|
+
* devDependencies
|
|
18
|
+
* @twin.org/nameof-transformer bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
19
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
20
|
+
* @twin.org/validate-locales bumped from 0.0.3-next.23 to 0.0.3-next.24
|
|
21
|
+
|
|
3
22
|
## [0.0.3-next.23](https://github.com/twinfoundation/framework/compare/entity-v0.0.3-next.22...entity-v0.0.3-next.23) (2026-03-17)
|
|
4
23
|
|
|
5
24
|
|
|
@@ -20,6 +20,6 @@ The conditions to join in a group.
|
|
|
20
20
|
|
|
21
21
|
### logicalOperator? {#logicaloperator}
|
|
22
22
|
|
|
23
|
-
> `optional` **logicalOperator
|
|
23
|
+
> `optional` **logicalOperator?**: [`LogicalOperator`](../type-aliases/LogicalOperator.md)
|
|
24
24
|
|
|
25
25
|
The logical operator to use.
|
|
@@ -20,7 +20,7 @@ The type of the entity.
|
|
|
20
20
|
|
|
21
21
|
### options? {#options}
|
|
22
22
|
|
|
23
|
-
> `optional` **options
|
|
23
|
+
> `optional` **options?**: [`IEntitySchemaOptions`](IEntitySchemaOptions.md)
|
|
24
24
|
|
|
25
25
|
The options for the entity.
|
|
26
26
|
|
|
@@ -28,6 +28,6 @@ The options for the entity.
|
|
|
28
28
|
|
|
29
29
|
### properties? {#properties}
|
|
30
30
|
|
|
31
|
-
> `optional` **properties
|
|
31
|
+
> `optional` **properties?**: [`IEntitySchemaProperty`](IEntitySchemaProperty.md)\<`T`\>[]
|
|
32
32
|
|
|
33
33
|
The properties of the entity.
|
|
@@ -28,7 +28,7 @@ The type of the property.
|
|
|
28
28
|
|
|
29
29
|
### format? {#format}
|
|
30
30
|
|
|
31
|
-
> `optional` **format
|
|
31
|
+
> `optional` **format?**: [`EntitySchemaPropertyFormat`](../type-aliases/EntitySchemaPropertyFormat.md)
|
|
32
32
|
|
|
33
33
|
The format of the property.
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ The format of the property.
|
|
|
36
36
|
|
|
37
37
|
### isPrimary? {#isprimary}
|
|
38
38
|
|
|
39
|
-
> `optional` **isPrimary
|
|
39
|
+
> `optional` **isPrimary?**: `boolean`
|
|
40
40
|
|
|
41
41
|
Is this the primary index property.
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ Is this the primary index property.
|
|
|
44
44
|
|
|
45
45
|
### isSecondary? {#issecondary}
|
|
46
46
|
|
|
47
|
-
> `optional` **isSecondary
|
|
47
|
+
> `optional` **isSecondary?**: `boolean`
|
|
48
48
|
|
|
49
49
|
Is this a secondary index property.
|
|
50
50
|
|
|
@@ -52,7 +52,7 @@ Is this a secondary index property.
|
|
|
52
52
|
|
|
53
53
|
### sortDirection? {#sortdirection}
|
|
54
54
|
|
|
55
|
-
> `optional` **sortDirection
|
|
55
|
+
> `optional` **sortDirection?**: [`SortDirection`](../type-aliases/SortDirection.md)
|
|
56
56
|
|
|
57
57
|
Default sort direction for this field, leave empty if not sortable.
|
|
58
58
|
|
|
@@ -60,7 +60,7 @@ Default sort direction for this field, leave empty if not sortable.
|
|
|
60
60
|
|
|
61
61
|
### optional? {#optional}
|
|
62
62
|
|
|
63
|
-
> `optional` **optional
|
|
63
|
+
> `optional` **optional?**: `boolean`
|
|
64
64
|
|
|
65
65
|
Is the property optional.
|
|
66
66
|
|
|
@@ -68,7 +68,7 @@ Is the property optional.
|
|
|
68
68
|
|
|
69
69
|
### itemType? {#itemtype}
|
|
70
70
|
|
|
71
|
-
> `optional` **itemType
|
|
71
|
+
> `optional` **itemType?**: [`EntitySchemaPropertyType`](../type-aliases/EntitySchemaPropertyType.md)
|
|
72
72
|
|
|
73
73
|
The type of the item (only applies when type is `array`).
|
|
74
74
|
|
|
@@ -76,7 +76,7 @@ The type of the item (only applies when type is `array`).
|
|
|
76
76
|
|
|
77
77
|
### itemTypeRef? {#itemtyperef}
|
|
78
78
|
|
|
79
|
-
> `optional` **itemTypeRef
|
|
79
|
+
> `optional` **itemTypeRef?**: `string`
|
|
80
80
|
|
|
81
81
|
The type ref of the item (only applies when type is either `array` or `object`).
|
|
82
82
|
|
|
@@ -84,7 +84,7 @@ The type ref of the item (only applies when type is either `array` or `object`).
|
|
|
84
84
|
|
|
85
85
|
### description? {#description}
|
|
86
86
|
|
|
87
|
-
> `optional` **description
|
|
87
|
+
> `optional` **description?**: `string`
|
|
88
88
|
|
|
89
89
|
Description of the object.
|
|
90
90
|
|
|
@@ -92,6 +92,6 @@ Description of the object.
|
|
|
92
92
|
|
|
93
93
|
### examples? {#examples}
|
|
94
94
|
|
|
95
|
-
> `optional` **examples
|
|
95
|
+
> `optional` **examples?**: `unknown`[]
|
|
96
96
|
|
|
97
97
|
Examples of the property values.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/entity",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.24",
|
|
4
4
|
"description": "Helpers for defining and working with entities",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/core": "0.0.3-next.
|
|
18
|
-
"@twin.org/nameof": "0.0.3-next.
|
|
19
|
-
"reflect-metadata": "0.2.2"
|
|
17
|
+
"@twin.org/core": "0.0.3-next.24",
|
|
18
|
+
"@twin.org/nameof": "0.0.3-next.24",
|
|
19
|
+
"reflect-metadata": "0.2.2",
|
|
20
|
+
"tslib": "2.8.1"
|
|
20
21
|
},
|
|
21
22
|
"main": "./dist/es/index.js",
|
|
22
23
|
"types": "./dist/types/index.d.ts",
|