@antelopejs/interface-database-decorators 0.1.6 → 0.1.7
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 +0 -2
- package/dist/antelope.test.js +4 -3
- package/dist/antelope.test.js.map +1 -1
- package/dist/common.d.ts +2 -1
- package/dist/common.js +5 -1
- package/dist/common.js.map +1 -1
- package/dist/database.js +12 -8
- package/dist/database.js.map +1 -1
- package/dist/model.d.ts +2 -2
- package/dist/model.js +10 -10
- package/dist/model.js.map +1 -1
- package/dist/modifiers/autodate.js.map +1 -1
- package/dist/modifiers/common.js.map +1 -1
- package/dist/modifiers/encryption.js +1 -1
- package/dist/modifiers/encryption.js.map +1 -1
- package/dist/modifiers/hash.js +1 -1
- package/dist/modifiers/hash.js.map +1 -1
- package/dist/modifiers/localization.js.map +1 -1
- package/dist/relation.js.map +1 -1
- package/dist/schema.js.map +1 -1
- package/dist/table.d.ts +21 -5
- package/dist/table.js +8 -8
- package/dist/table.js.map +1 -1
- package/dist/tests/common.test.js +1 -1
- package/dist/tests/common.test.js.map +1 -1
- package/dist/tests/database.test.js +80 -2
- package/dist/tests/database.test.js.map +1 -1
- package/dist/tests/integration.test.js +4 -4
- package/dist/tests/integration.test.js.map +1 -1
- package/dist/tests/model.test.js +4 -4
- package/dist/tests/model.test.js.map +1 -1
- package/dist/tests/modifiers/autodate.test.js +3 -3
- package/dist/tests/modifiers/autodate.test.js.map +1 -1
- package/dist/tests/modifiers/common.test.js +2 -2
- package/dist/tests/modifiers/common.test.js.map +1 -1
- package/dist/tests/modifiers/encryption.test.js +2 -2
- package/dist/tests/modifiers/encryption.test.js.map +1 -1
- package/dist/tests/modifiers/hash.test.js +2 -2
- package/dist/tests/modifiers/hash.test.js.map +1 -1
- package/dist/tests/modifiers/localization.test.js +2 -2
- package/dist/tests/modifiers/localization.test.js.map +1 -1
- package/dist/tests/relation.test.js +2 -2
- package/dist/tests/relation.test.js.map +1 -1
- package/dist/tests/schema.test.js +2 -2
- package/dist/tests/schema.test.js.map +1 -1
- package/dist/tests/table.test.js +11 -11
- package/dist/tests/table.test.js.map +1 -1
- package/docs/2.table-definitions.md +68 -17
- package/docs/3.table-modifiers.md +77 -23
- package/docs/4.data-models.md +4 -4
- package/docs/5.parameter-decoration.md +14 -3
- package/package.json +66 -57
- package/skills/database-decorators-interface/SKILL.md +60 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.test.js","sourceRoot":"","sources":["../../src/tests/schema.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"schema.test.js","sourceRoot":"","sources":["../../src/tests/schema.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+BAA8B;AAC9B,2EAIyD;AACzD,6EAG0D;AAC1D,6EAG0D;AAE1D,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE,CAC3D,yCAAyC,EAAE,CAAC,CAAC;IAC/C,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE,CACrD,oCAAoC,EAAE,CAAC,CAAC;IAC1C,EAAE,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE,CAAC,4BAA4B,EAAE,CAAC,CAAC;IAC9E,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE,CACnD,kCAAkC,EAAE,CAAC,CAAC;IACxC,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE,CACpD,mCAAmC,EAAE,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,yCAAyC;IAEtD,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,aAAK;QAE3B,IAAI,CAAU;KACf,CAAA;IADC;QADC,IAAA,aAAK,EAAC,QAAQ,CAAC;;2CACF;IAFV,SAAS;QADd,IAAA,sBAAa,EAAC,YAAY,EAAE,aAAa,CAAC;OACrC,SAAS,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;IAG/B,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,aAAK;KAAG,CAAA;IAA5B,WAAW;QADhB,IAAA,sBAAa,EAAC,cAAc,EAAE,iBAAiB,CAAC;OAC3C,WAAW,CAAiB;IAElC,MAAM,MAAM,GAAG,IAAA,2BAAkB,EAAC,iBAAiB,CAAC,CAAC;IACrD,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACvC,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAClD,CAAC;AAED,KAAK,UAAU,mCAAmC;IAChD,MAAM,MAAM,GAAG,IAAA,2BAAkB,EAAC,oBAAoB,CAAC,CAAC;IACxD,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC"}
|
package/dist/tests/table.test.js
CHANGED
|
@@ -9,10 +9,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const common_1 = require("@antelopejs/interface-database-decorators/common");
|
|
13
|
-
const common_2 = require("@antelopejs/interface-database-decorators/modifiers/common");
|
|
14
|
-
const table_1 = require("@antelopejs/interface-database-decorators/table");
|
|
15
12
|
const chai_1 = require("chai");
|
|
13
|
+
const common_1 = require("@antelopejs/interface-database-decorators/modifiers/common");
|
|
14
|
+
const table_1 = require("@antelopejs/interface-database-decorators/table");
|
|
15
|
+
const common_2 = require("@antelopejs/interface-database-decorators/common");
|
|
16
16
|
const codec_helpers_1 = require("./codec_helpers");
|
|
17
17
|
describe("Table - decorators", () => {
|
|
18
18
|
it("creates table with default primary key", async () => CreateTableWithDefaultPrimaryKeyTest());
|
|
@@ -29,7 +29,7 @@ async function CreateTableWithDefaultPrimaryKeyTest() {
|
|
|
29
29
|
(0, table_1.Index)(),
|
|
30
30
|
__metadata("design:type", String)
|
|
31
31
|
], TestTable.prototype, "name", void 0);
|
|
32
|
-
const metadata = (0,
|
|
32
|
+
const metadata = (0, common_2.getMetadata)(TestTable, common_2.DatumStaticMetadata);
|
|
33
33
|
(0, chai_1.expect)(metadata.primary).to.equal("_id");
|
|
34
34
|
(0, chai_1.expect)(metadata.indexes.name).to.deep.equal(["name"]);
|
|
35
35
|
}
|
|
@@ -46,7 +46,7 @@ async function CreateTableWithMultipleIndexesTest() {
|
|
|
46
46
|
(0, table_1.Index)(),
|
|
47
47
|
__metadata("design:type", Number)
|
|
48
48
|
], TestTable.prototype, "age", void 0);
|
|
49
|
-
const metadata = (0,
|
|
49
|
+
const metadata = (0, common_2.getMetadata)(TestTable, common_2.DatumStaticMetadata);
|
|
50
50
|
(0, chai_1.expect)(metadata.primary).to.equal("_id");
|
|
51
51
|
(0, chai_1.expect)(metadata.indexes.email).to.deep.equal(["email"]);
|
|
52
52
|
(0, chai_1.expect)(metadata.indexes.age).to.deep.equal(["age"]);
|
|
@@ -69,7 +69,7 @@ async function CreateTableWithGroupedIndexesTest() {
|
|
|
69
69
|
(0, table_1.Index)({ group: "age_range" }),
|
|
70
70
|
__metadata("design:type", Number)
|
|
71
71
|
], TestTable.prototype, "age", void 0);
|
|
72
|
-
const metadata = (0,
|
|
72
|
+
const metadata = (0, common_2.getMetadata)(TestTable, common_2.DatumStaticMetadata);
|
|
73
73
|
(0, chai_1.expect)(metadata.primary).to.equal("_id");
|
|
74
74
|
(0, chai_1.expect)(metadata.indexes.user_search).to.deep.equal(["name", "email"]);
|
|
75
75
|
(0, chai_1.expect)(metadata.indexes.age_range).to.deep.equal(["age"]);
|
|
@@ -85,7 +85,7 @@ async function CreateTableWithFixtureDataTest() {
|
|
|
85
85
|
TestTable = __decorate([
|
|
86
86
|
(0, table_1.Fixture)(() => testData)
|
|
87
87
|
], TestTable);
|
|
88
|
-
const metadata = (0,
|
|
88
|
+
const metadata = (0, common_2.getMetadata)(TestTable, common_2.DatumStaticMetadata);
|
|
89
89
|
(0, chai_1.expect)(metadata.generator).to.be.a("function");
|
|
90
90
|
(0, chai_1.expect)(metadata.primary).to.equal("_id");
|
|
91
91
|
}
|
|
@@ -101,7 +101,7 @@ function StoresStringTokenFieldTest() {
|
|
|
101
101
|
(0, table_1.Field)("string"),
|
|
102
102
|
__metadata("design:type", String)
|
|
103
103
|
], _T.prototype, "name", void 0);
|
|
104
|
-
const metadata = (0,
|
|
104
|
+
const metadata = (0, common_2.getMetadata)(_T, common_2.DatumStaticMetadata);
|
|
105
105
|
(0, chai_1.expect)(metadata.fields.name).to.equal("string");
|
|
106
106
|
}
|
|
107
107
|
function StoresCodecFieldTest() {
|
|
@@ -111,7 +111,7 @@ function StoresCodecFieldTest() {
|
|
|
111
111
|
(0, table_1.Field)((0, codec_helpers_1.asFieldType)(codec_helpers_1.stringCodec)),
|
|
112
112
|
__metadata("design:type", String)
|
|
113
113
|
], _T.prototype, "name", void 0);
|
|
114
|
-
const metadata = (0,
|
|
114
|
+
const metadata = (0, common_2.getMetadata)(_T, common_2.DatumStaticMetadata);
|
|
115
115
|
(0, chai_1.expect)(metadata.fields.name).to.equal(codec_helpers_1.stringCodec);
|
|
116
116
|
}
|
|
117
117
|
function StacksWithIndexTest() {
|
|
@@ -122,7 +122,7 @@ function StacksWithIndexTest() {
|
|
|
122
122
|
(0, table_1.Field)("string"),
|
|
123
123
|
__metadata("design:type", String)
|
|
124
124
|
], _T.prototype, "email", void 0);
|
|
125
|
-
const metadata = (0,
|
|
125
|
+
const metadata = (0, common_2.getMetadata)(_T, common_2.DatumStaticMetadata);
|
|
126
126
|
(0, chai_1.expect)(metadata.fields.email).to.equal("string");
|
|
127
127
|
(0, chai_1.expect)(metadata.indexes.email).to.deep.equal(["email"]);
|
|
128
128
|
}
|
|
@@ -131,7 +131,7 @@ async function CombineTableWithMixinsTest() {
|
|
|
131
131
|
testMethodUnunvailable() {
|
|
132
132
|
return "This method should be undefined";
|
|
133
133
|
}
|
|
134
|
-
[
|
|
134
|
+
[common_1.MixinSymbol] = class {
|
|
135
135
|
testMethod() {
|
|
136
136
|
return "mixin method ok";
|
|
137
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.test.js","sourceRoot":"","sources":["../../src/tests/table.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"table.test.js","sourceRoot":"","sources":["../../src/tests/table.test.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+BAA8B;AAC9B,uFAAyF;AACzF,2EAKyD;AACzD,6EAG0D;AAE1D,mDAA2D;AAE3D,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE,CACtD,oCAAoC,EAAE,CAAC,CAAC;IAC1C,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE,CACnD,kCAAkC,EAAE,CAAC,CAAC;IACxC,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE,CAClD,iCAAiC,EAAE,CAAC,CAAC;IACvC,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE,CAC/C,8BAA8B,EAAE,CAAC,CAAC;IACpC,EAAE,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE,CAAC,0BAA0B,EAAE,CAAC,CAAC;AAC7E,CAAC,CAAC,CAAC;AAEH,KAAK,UAAU,oCAAoC;IACjD,MAAM,SAAU,SAAQ,aAAK;QAE3B,IAAI,CAAU;KACf;IADC;QADC,IAAA,aAAK,GAAE;;2CACM;IAGhB,MAAM,QAAQ,GAAG,IAAA,oBAAW,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AAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,KAAK,UAAU,0BAA0B;IACvC,MAAM,SAAS;QACb,sBAAsB;YACpB,OAAO,iCAAiC,CAAC;QAC3C,CAAC;QAED,CAAC,oBAAW,CAAC,GAAG;YACd,UAAU;gBACR,OAAO,iBAAiB,CAAC;YAC3B,CAAC;SACF,CAAC;KACH;IAED,MAAM,SAAU,SAAQ,aAAK,CAAC,IAAI,CAAC,SAAS,CAAC;QAC3C,IAAI,CAAU;KACf;IAED,MAAM,QAAQ,GAAG,IAAI,SAAS,EAAE,CAAC;IACjC,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAChD,IAAA,aAAM,EAAE,QAAgB,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACnE,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAC;IAChE,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAA,aAAM,EAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -23,7 +23,12 @@ class User extends Table {
|
|
|
23
23
|
The `Table.with()` static method incorporates modifier mixins into the table class, adding capabilities like encryption, hashing, or localization:
|
|
24
24
|
|
|
25
25
|
```typescript
|
|
26
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
Table,
|
|
28
|
+
Field,
|
|
29
|
+
EncryptionModifier,
|
|
30
|
+
Encrypted,
|
|
31
|
+
} from "@antelopejs/interface-database-decorators";
|
|
27
32
|
|
|
28
33
|
class SensitiveData extends Table.with(EncryptionModifier) {
|
|
29
34
|
@Field("string")
|
|
@@ -56,16 +61,38 @@ class User extends Table {
|
|
|
56
61
|
|
|
57
62
|
### Options
|
|
58
63
|
|
|
59
|
-
| Option
|
|
60
|
-
|
|
|
61
|
-
| `group`
|
|
64
|
+
| Option | Type | Description |
|
|
65
|
+
| --------------- | --------- | ------------------------------------------------------------------- |
|
|
66
|
+
| `group` | `string` | Assign the field to a named compound index group. |
|
|
67
|
+
| `crossInstance` | `boolean` | Also keep the index fast for queries that run across all instances. |
|
|
68
|
+
|
|
69
|
+
### Cross-Instance Indexes
|
|
70
|
+
|
|
71
|
+
Every index is scoped to the schema instance, so queries on a single instance always use it. Set `crossInstance: true` when the index is also queried across all instances (queries on the `CROSS_INSTANCE` instance), so the database driver maintains an additional index for those queries.
|
|
72
|
+
|
|
73
|
+
The option never changes query results. Without it, cross-instance queries that name the index still return the same rows but run slower, and the driver logs a warning once per index. Leave it unset for indexes that are only queried within one instance, since each extra index costs storage and write time.
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
class User extends Table {
|
|
77
|
+
@Index({ crossInstance: true })
|
|
78
|
+
@Field("string")
|
|
79
|
+
declare email: string;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
For a compound index, setting `crossInstance: true` on any field of the group applies it to the whole group.
|
|
62
84
|
|
|
63
85
|
### Compound Indexes
|
|
64
86
|
|
|
65
87
|
Assign multiple fields to the same index group to create a compound index:
|
|
66
88
|
|
|
67
89
|
```typescript
|
|
68
|
-
import {
|
|
90
|
+
import {
|
|
91
|
+
Table,
|
|
92
|
+
Field,
|
|
93
|
+
Index,
|
|
94
|
+
Relation,
|
|
95
|
+
} from "@antelopejs/interface-database-decorators";
|
|
69
96
|
|
|
70
97
|
class User extends Table {
|
|
71
98
|
@Field("string")
|
|
@@ -93,7 +120,12 @@ class UserActivity extends Table {
|
|
|
93
120
|
|
|
94
121
|
```typescript
|
|
95
122
|
import * as t from "io-ts";
|
|
96
|
-
import {
|
|
123
|
+
import {
|
|
124
|
+
Table,
|
|
125
|
+
Field,
|
|
126
|
+
Index,
|
|
127
|
+
RegisterTable,
|
|
128
|
+
} from "@antelopejs/interface-database-decorators";
|
|
97
129
|
|
|
98
130
|
@RegisterTable("orders", "shop")
|
|
99
131
|
class Order extends Table {
|
|
@@ -116,7 +148,12 @@ Properties without `@Field` are omitted from `fields`. `@Field` stacks freely wi
|
|
|
116
148
|
The `Relation` decorator declares a link from a field to another table. It is **declarative metadata only**: database implementations do not enforce it (no foreign key constraint, no referential validation). Introspection tooling consumes it to expose the links between tables — for example to render schema diagrams or navigate related records.
|
|
117
149
|
|
|
118
150
|
```typescript
|
|
119
|
-
import {
|
|
151
|
+
import {
|
|
152
|
+
Table,
|
|
153
|
+
Field,
|
|
154
|
+
Index,
|
|
155
|
+
Relation,
|
|
156
|
+
} from "@antelopejs/interface-database-decorators";
|
|
120
157
|
|
|
121
158
|
class Comment extends Table {
|
|
122
159
|
@Index()
|
|
@@ -132,11 +169,11 @@ class Comment extends Table {
|
|
|
132
169
|
|
|
133
170
|
### Options
|
|
134
171
|
|
|
135
|
-
| Option | Type
|
|
136
|
-
| --------- |
|
|
137
|
-
| `to` | `() => typeof Table` | Thunk returning the target table class (lazy to allow forward references).
|
|
138
|
-
| `toField` | `string`
|
|
139
|
-
| `many` | `boolean`
|
|
172
|
+
| Option | Type | Description |
|
|
173
|
+
| --------- | -------------------- | -------------------------------------------------------------------------------- |
|
|
174
|
+
| `to` | `() => typeof Table` | Thunk returning the target table class (lazy to allow forward references). |
|
|
175
|
+
| `toField` | `string` | Target field name. Defaults to the target table's primary key. |
|
|
176
|
+
| `many` | `boolean` | The decorated field holds multiple target keys (many targets per source record). |
|
|
140
177
|
|
|
141
178
|
`@Relation` stacks freely with `@Field` and `@Index`.
|
|
142
179
|
|
|
@@ -145,7 +182,12 @@ class Comment extends Table {
|
|
|
145
182
|
The `RegisterTable` class decorator associates a table class with a specific table name and schema. This registration is used by `RegisterSchema` to build the schema definition automatically.
|
|
146
183
|
|
|
147
184
|
```typescript
|
|
148
|
-
import {
|
|
185
|
+
import {
|
|
186
|
+
Table,
|
|
187
|
+
Field,
|
|
188
|
+
Index,
|
|
189
|
+
RegisterTable,
|
|
190
|
+
} from "@antelopejs/interface-database-decorators";
|
|
149
191
|
|
|
150
192
|
@RegisterTable("users", "myapp")
|
|
151
193
|
class User extends Table {
|
|
@@ -165,7 +207,11 @@ The first argument is the table name in the database, and the second is the sche
|
|
|
165
207
|
The `Fixture` decorator defines default data to insert when a table is first created. It receives a generator function that produces initial records.
|
|
166
208
|
|
|
167
209
|
```typescript
|
|
168
|
-
import {
|
|
210
|
+
import {
|
|
211
|
+
Table,
|
|
212
|
+
Field,
|
|
213
|
+
Fixture,
|
|
214
|
+
} from "@antelopejs/interface-database-decorators";
|
|
169
215
|
|
|
170
216
|
@Fixture(() => [
|
|
171
217
|
{ _id: "admin", name: "Administrator" },
|
|
@@ -205,7 +251,12 @@ class SystemConfig extends Table {
|
|
|
205
251
|
Tables support standard class inheritance. Define a base table with common fields and extend it for specific use cases:
|
|
206
252
|
|
|
207
253
|
```typescript
|
|
208
|
-
import {
|
|
254
|
+
import {
|
|
255
|
+
Table,
|
|
256
|
+
Field,
|
|
257
|
+
Index,
|
|
258
|
+
Relation,
|
|
259
|
+
} from "@antelopejs/interface-database-decorators";
|
|
209
260
|
|
|
210
261
|
class BaseEntity extends Table {
|
|
211
262
|
@Field("date")
|
|
@@ -253,8 +304,8 @@ await RegisterSchema("myapp");
|
|
|
253
304
|
|
|
254
305
|
### Parameters
|
|
255
306
|
|
|
256
|
-
| Parameter | Type | Description
|
|
257
|
-
| ---------- | -------- |
|
|
307
|
+
| Parameter | Type | Description |
|
|
308
|
+
| ---------- | -------- | ------------------------------------------------------------------ |
|
|
258
309
|
| `schemaId` | `string` | Schema id matching the `@RegisterTable(_, schemaId)` declarations. |
|
|
259
310
|
|
|
260
311
|
`RegisterSchema` returns `Promise<void>`.
|
|
@@ -9,7 +9,12 @@ Table modifiers transform field values as they are stored in and retrieved from
|
|
|
9
9
|
The `EncryptionModifier` encrypts field values before storing them and decrypts them on retrieval. Both operations happen transparently.
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
Table,
|
|
14
|
+
Field,
|
|
15
|
+
EncryptionModifier,
|
|
16
|
+
Encrypted,
|
|
17
|
+
} from "@antelopejs/interface-database-decorators";
|
|
13
18
|
|
|
14
19
|
class UserCredentials extends Table.with(EncryptionModifier) {
|
|
15
20
|
@Encrypted({
|
|
@@ -39,18 +44,23 @@ class UserCredentials extends Table.with(EncryptionModifier) {
|
|
|
39
44
|
|
|
40
45
|
#### Options
|
|
41
46
|
|
|
42
|
-
| Option | Type | Default
|
|
43
|
-
| ----------- | -------- |
|
|
44
|
-
| `secretKey` | `string` | (required)
|
|
45
|
-
| `algorithm` | `string` | `"aes-256-gcm"`
|
|
46
|
-
| `ivSize` | `number` | `16`
|
|
47
|
+
| Option | Type | Default | Description |
|
|
48
|
+
| ----------- | -------- | --------------- | ------------------------------------ |
|
|
49
|
+
| `secretKey` | `string` | (required) | The encryption key. |
|
|
50
|
+
| `algorithm` | `string` | `"aes-256-gcm"` | Encryption algorithm. |
|
|
51
|
+
| `ivSize` | `number` | `16` | Initialization vector size in bytes. |
|
|
47
52
|
|
|
48
53
|
### HashModifier
|
|
49
54
|
|
|
50
55
|
The `HashModifier` stores a one-way hash of field values. Unlike encryption, hashing is irreversible -- you cannot retrieve the original value. Use this for passwords and other sensitive data that only needs equality verification.
|
|
51
56
|
|
|
52
57
|
```typescript
|
|
53
|
-
import {
|
|
58
|
+
import {
|
|
59
|
+
Table,
|
|
60
|
+
Field,
|
|
61
|
+
HashModifier,
|
|
62
|
+
Hashed,
|
|
63
|
+
} from "@antelopejs/interface-database-decorators";
|
|
54
64
|
|
|
55
65
|
class User extends Table.with(HashModifier) {
|
|
56
66
|
@Field("string")
|
|
@@ -93,7 +103,12 @@ Returns `true` if `value`, when hashed, matches the stored hash for the given fi
|
|
|
93
103
|
The `LocalizationModifier` stores multiple language versions of a field value. Access a specific locale by calling `localize()` on the table instance.
|
|
94
104
|
|
|
95
105
|
```typescript
|
|
96
|
-
import {
|
|
106
|
+
import {
|
|
107
|
+
Table,
|
|
108
|
+
Field,
|
|
109
|
+
LocalizationModifier,
|
|
110
|
+
Localized,
|
|
111
|
+
} from "@antelopejs/interface-database-decorators";
|
|
97
112
|
|
|
98
113
|
class Product extends Table.with(LocalizationModifier) {
|
|
99
114
|
@Field("number")
|
|
@@ -150,8 +165,8 @@ product.localize("*").name = {
|
|
|
150
165
|
|
|
151
166
|
#### Options
|
|
152
167
|
|
|
153
|
-
| Option | Type | Description
|
|
154
|
-
| ---------------- | -------- |
|
|
168
|
+
| Option | Type | Description |
|
|
169
|
+
| ---------------- | -------- | ------------------------------------------------------- |
|
|
155
170
|
| `fallbackLocale` | `string` | Locale to use when the requested locale is unavailable. |
|
|
156
171
|
|
|
157
172
|
#### Mixin Method
|
|
@@ -169,7 +184,11 @@ Sets the active locale for accessing localized fields. If `fields` is provided,
|
|
|
169
184
|
The `AutoDateModifier` automatically populates timestamp fields during insert and update operations. Use the `CreationTime` and `UpdateTime` decorators to mark fields.
|
|
170
185
|
|
|
171
186
|
```typescript
|
|
172
|
-
import {
|
|
187
|
+
import {
|
|
188
|
+
Table,
|
|
189
|
+
CreationTime,
|
|
190
|
+
UpdateTime,
|
|
191
|
+
} from "@antelopejs/interface-database-decorators";
|
|
173
192
|
|
|
174
193
|
class Article extends Table {
|
|
175
194
|
declare title: string;
|
|
@@ -204,7 +223,11 @@ import {
|
|
|
204
223
|
Localized,
|
|
205
224
|
} from "@antelopejs/interface-database-decorators";
|
|
206
225
|
|
|
207
|
-
class UserProfile extends Table.with(
|
|
226
|
+
class UserProfile extends Table.with(
|
|
227
|
+
EncryptionModifier,
|
|
228
|
+
HashModifier,
|
|
229
|
+
LocalizationModifier,
|
|
230
|
+
) {
|
|
208
231
|
@Encrypted({ secretKey: process.env.SECRET_KEY || "default-key" })
|
|
209
232
|
@Field("any")
|
|
210
233
|
declare privateInfo: {
|
|
@@ -229,11 +252,20 @@ class UserProfile extends Table.with(EncryptionModifier, HashModifier, Localizat
|
|
|
229
252
|
A `OneWayModifier` transforms data in one direction (when writing to the database). Use it for irreversible transformations like hashing.
|
|
230
253
|
|
|
231
254
|
```typescript
|
|
232
|
-
import {
|
|
255
|
+
import {
|
|
256
|
+
OneWayModifier,
|
|
257
|
+
MixinSymbol,
|
|
258
|
+
attachModifier,
|
|
259
|
+
} from "@antelopejs/interface-database-decorators";
|
|
233
260
|
import { MakePropertyDecorator } from "@antelopejs/interface-core/decorators";
|
|
234
261
|
import { createHash } from "crypto";
|
|
235
262
|
|
|
236
|
-
class PrefixHashModifier extends OneWayModifier<
|
|
263
|
+
class PrefixHashModifier extends OneWayModifier<
|
|
264
|
+
string | undefined,
|
|
265
|
+
[],
|
|
266
|
+
{},
|
|
267
|
+
{ algorithm?: string }
|
|
268
|
+
> {
|
|
237
269
|
public readonly autolock = true;
|
|
238
270
|
|
|
239
271
|
public override lock(_locked: string | undefined, value: unknown) {
|
|
@@ -248,15 +280,20 @@ class PrefixHashModifier extends OneWayModifier<string | undefined, [], {}, { al
|
|
|
248
280
|
|
|
249
281
|
const PrefixHashed = MakePropertyDecorator(
|
|
250
282
|
(target, propertyKey, options?: { algorithm?: string }) => {
|
|
251
|
-
attachModifier(
|
|
283
|
+
attachModifier(
|
|
284
|
+
target.constructor,
|
|
285
|
+
PrefixHashModifier,
|
|
286
|
+
propertyKey,
|
|
287
|
+
options || {},
|
|
288
|
+
);
|
|
252
289
|
},
|
|
253
290
|
);
|
|
254
291
|
```
|
|
255
292
|
|
|
256
293
|
The generic parameters for `OneWayModifier<LockedType, Args, Meta, Options>` are:
|
|
257
294
|
|
|
258
|
-
| Parameter | Description
|
|
259
|
-
| ------------ |
|
|
295
|
+
| Parameter | Description |
|
|
296
|
+
| ------------ | ---------------------------------------------------- |
|
|
260
297
|
| `LockedType` | The type stored in the database after transformation |
|
|
261
298
|
| `Args` | Additional arguments for `lock` and `test` |
|
|
262
299
|
| `Meta` | Per-field metadata stored alongside the value |
|
|
@@ -267,10 +304,19 @@ The generic parameters for `OneWayModifier<LockedType, Args, Meta, Options>` are
|
|
|
267
304
|
A `TwoWayModifier` extends `OneWayModifier` with an `unlock` method for reversible transformations like encryption:
|
|
268
305
|
|
|
269
306
|
```typescript
|
|
270
|
-
import {
|
|
307
|
+
import {
|
|
308
|
+
TwoWayModifier,
|
|
309
|
+
MixinSymbol,
|
|
310
|
+
attachModifier,
|
|
311
|
+
} from "@antelopejs/interface-database-decorators";
|
|
271
312
|
import { MakePropertyDecorator } from "@antelopejs/interface-core/decorators";
|
|
272
313
|
|
|
273
|
-
class Base64Modifier extends TwoWayModifier<
|
|
314
|
+
class Base64Modifier extends TwoWayModifier<
|
|
315
|
+
string,
|
|
316
|
+
[],
|
|
317
|
+
{},
|
|
318
|
+
{ prefix?: string }
|
|
319
|
+
> {
|
|
274
320
|
public readonly autolock = true;
|
|
275
321
|
public readonly autounlock = true;
|
|
276
322
|
|
|
@@ -295,7 +341,12 @@ class Base64Modifier extends TwoWayModifier<string, [], {}, { prefix?: string }>
|
|
|
295
341
|
|
|
296
342
|
const Base64Encoded = MakePropertyDecorator(
|
|
297
343
|
(target, propertyKey, options?: { prefix?: string }) => {
|
|
298
|
-
attachModifier(
|
|
344
|
+
attachModifier(
|
|
345
|
+
target.constructor,
|
|
346
|
+
Base64Modifier,
|
|
347
|
+
propertyKey,
|
|
348
|
+
options || {},
|
|
349
|
+
);
|
|
299
350
|
},
|
|
300
351
|
);
|
|
301
352
|
```
|
|
@@ -317,8 +368,8 @@ class MyContainerModifier extends ContainerModifier<{}, { fallback?: string }> {
|
|
|
317
368
|
|
|
318
369
|
Modifiers can hook into the data lifecycle by implementing event handler methods. These methods are called during data conversion and database operations:
|
|
319
370
|
|
|
320
|
-
| Event | Triggered When
|
|
321
|
-
| --------------- |
|
|
371
|
+
| Event | Triggered When |
|
|
372
|
+
| --------------- | ------------------------------------------ |
|
|
322
373
|
| `fromPlainData` | After converting plain data to an instance |
|
|
323
374
|
| `toPlainData` | After converting an instance to plain data |
|
|
324
375
|
| `fromDatabase` | After reading from the database |
|
|
@@ -327,7 +378,10 @@ Modifiers can hook into the data lifecycle by implementing event handler methods
|
|
|
327
378
|
| `update` | Before updating an existing record |
|
|
328
379
|
|
|
329
380
|
```typescript
|
|
330
|
-
import {
|
|
381
|
+
import {
|
|
382
|
+
Modifier,
|
|
383
|
+
MixinSymbol,
|
|
384
|
+
} from "@antelopejs/interface-database-decorators";
|
|
331
385
|
|
|
332
386
|
class TimestampModifier extends Modifier {
|
|
333
387
|
public insert(instance: any, field: string) {
|
package/docs/4.data-models.md
CHANGED
|
@@ -15,10 +15,10 @@ const UserModel = BasicDataModel(User, "users");
|
|
|
15
15
|
|
|
16
16
|
### Parameters
|
|
17
17
|
|
|
18
|
-
| Parameter | Type
|
|
19
|
-
| ----------- |
|
|
20
|
-
| `dataType` | `Constructible<T
|
|
21
|
-
| `tableName` | `string`
|
|
18
|
+
| Parameter | Type | Description |
|
|
19
|
+
| ----------- | ------------------ | --------------------------------------------------------------------- |
|
|
20
|
+
| `dataType` | `Constructible<T>` | The Table class representing your table |
|
|
21
|
+
| `tableName` | `string` | The table name in the database (optional if `@RegisterTable` is used) |
|
|
22
22
|
|
|
23
23
|
When the table class has been decorated with `@RegisterTable`, the `tableName` parameter can be omitted.
|
|
24
24
|
|
|
@@ -17,7 +17,9 @@ import { UserModel } from "./user.model";
|
|
|
17
17
|
|
|
18
18
|
class UsersController extends Controller("/users") {
|
|
19
19
|
@Get()
|
|
20
|
-
async listUsers(
|
|
20
|
+
async listUsers(
|
|
21
|
+
@Model(UserModel, "main") userModel: InstanceType<typeof UserModel>,
|
|
22
|
+
) {
|
|
21
23
|
return await userModel.getAll();
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -36,7 +38,8 @@ class MultitenantController extends Controller("/tenants") {
|
|
|
36
38
|
@Get("/:tenantId/users")
|
|
37
39
|
async getTenantUsers(
|
|
38
40
|
@Parameter("tenantId") tenantId: string,
|
|
39
|
-
@Model(UserModel, (ctx) => `tenant-${ctx.params.tenantId}`)
|
|
41
|
+
@Model(UserModel, (ctx) => `tenant-${ctx.params.tenantId}`)
|
|
42
|
+
userModel: InstanceType<typeof UserModel>,
|
|
40
43
|
) {
|
|
41
44
|
return await userModel.getAll();
|
|
42
45
|
}
|
|
@@ -88,7 +91,15 @@ const model3 = GetModel(UserModel, "other");
|
|
|
88
91
|
Model decorators compose naturally with other API decorators for building complete CRUD controllers:
|
|
89
92
|
|
|
90
93
|
```typescript
|
|
91
|
-
import {
|
|
94
|
+
import {
|
|
95
|
+
Controller,
|
|
96
|
+
Get,
|
|
97
|
+
Post,
|
|
98
|
+
Put,
|
|
99
|
+
Delete,
|
|
100
|
+
RawBody,
|
|
101
|
+
Parameter,
|
|
102
|
+
} from "@antelopejs/interface-api";
|
|
92
103
|
import { Model } from "@antelopejs/interface-database-decorators";
|
|
93
104
|
import { UserModel } from "./user.model";
|
|
94
105
|
|