suppa-mcp-2 1.1.4 → 1.2.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.
@@ -0,0 +1,289 @@
1
+ # Entity declaration — verbatim rules
2
+
3
+ Transcribed from docs.modern-expo.com/backend/application-developing/migrations.html (captured 2026-08-03). If an option is not in these tables, it does not exist — stop and ask.
4
+
5
+ ## A Minimal Entity
6
+
7
+ ```ts
8
+ import { Column, Entity, FieldTypeEnum, SystemBaseEntity } from '@suppa/sdk';
9
+
10
+ @Entity({
11
+ name: 'Workflows',
12
+ title: { en: 'Workflows', uk: 'Робочі процеси' },
13
+ importKeyFields: ['name'],
14
+ representativeFieldName: 'name',
15
+ })
16
+ export class Workflows extends SystemBaseEntity {
17
+ @Column({ name: 'name', type: FieldTypeEnum.Text, nullable: false })
18
+ name: string;
19
+
20
+ @Column({ name: 'description', type: FieldTypeEnum.Text })
21
+ description: string;
22
+
23
+ @Column({
24
+ name: 'private',
25
+ type: FieldTypeEnum.Boolean,
26
+ default: 'false',
27
+ })
28
+ private: boolean;
29
+
30
+ @Column({ name: 'externalId', type: FieldTypeEnum.UUID })
31
+ externalId: string;
32
+ }
33
+ ```
34
+
35
+ ## SystemBaseEntity
36
+
37
+ Every entity must extend SystemBaseEntity. It contributes the standard columns, so you never declare them yourself:
38
+
39
+ | Field | Type | Description |
40
+ |---|---|---|
41
+ | id | serial | Auto-increment primary key |
42
+ | createdAt | timestamp | Creation timestamp |
43
+ | updatedAt | timestamp | Last update timestamp |
44
+ | deletedAt | timestamp | Soft-delete timestamp |
45
+ | createdBy | ManyToOne(Users) | Who created the record |
46
+ | removedBy | ManyToOne(Users) | Who soft-deleted it |
47
+
48
+ ## @Entity() Options
49
+
50
+ | Option | Type | Description |
51
+ |---|---|---|
52
+ | name | string | Entity and table name. Defaults to the class name. |
53
+ | title | Record<string, string> | Localized display name. |
54
+ | comment | string | Description shown in metadata. |
55
+ | representativeFieldName | string | Field used to display a record. Defaults to id. |
56
+ | importKeyFields | string[] | Business key used by seeds, import and relation references. |
57
+ | key | string | Stable identifier that survives renaming the entity. |
58
+ | icon | Record<string, any> | Icon configuration. |
59
+ | type | string | Entity type. |
60
+ | options | Record<string, any> | Platform features to enable or disable for the entity (see below). |
61
+
62
+ options toggles the built-in per-entity features. Disable what the entity does not need — each enabled feature adds side tables and processing:
63
+
64
+ ```ts
65
+ @Entity({
66
+ name: 'Workflows',
67
+ importKeyFields: ['name'],
68
+ options: {
69
+ comments: false,
70
+ favorites: false,
71
+ approvals: false,
72
+ timeTracking: false,
73
+ browsingHistory: false,
74
+ trackChangeHistory: false,
75
+ globalSearch: false,
76
+ notificationMutes: false,
77
+ reminders: false,
78
+ },
79
+ })
80
+ export class Workflows extends SystemBaseEntity {}
81
+ ```
82
+
83
+ ## @Column()
84
+
85
+ ```ts
86
+ import { Column, FieldTypeEnum } from '@suppa/sdk';
87
+
88
+ @Column({
89
+ name: 'title',
90
+ type: FieldTypeEnum.Text,
91
+ nullable: false,
92
+ length: 255,
93
+ })
94
+ title: string;
95
+
96
+ @Column({
97
+ name: 'estimatedDuration',
98
+ type: FieldTypeEnum.Numeric,
99
+ decimalPlaces: 2,
100
+ })
101
+ estimatedDuration: number;
102
+
103
+ @Column({ name: 'isActive', type: FieldTypeEnum.Boolean, default: 'false' })
104
+ isActive: boolean;
105
+
106
+ @Column({ name: 'deadline', type: FieldTypeEnum.Timestamp })
107
+ deadline: string;
108
+ ```
109
+
110
+ | Option | Type | Description |
111
+ |---|---|---|
112
+ | type | FieldTypeEnum | Column type. Take the value from FieldTypeEnum (see below). |
113
+ | name | string | Column name. Defaults to the property name. |
114
+ | nullable | boolean | Allow NULL. |
115
+ | primary | boolean | Mark as primary key. |
116
+ | unique | boolean | Unique constraint. |
117
+ | default | string | Default value as a SQL expression string. |
118
+ | length | number | Maximum length. |
119
+ | title | Record<string, string> | Localized field name. |
120
+ | comment | string | Description. |
121
+ | key | string | Stable identifier that survives renaming. |
122
+ | minLength | number | Validation: minimum length. |
123
+ | minValue | number | Validation: minimum value. |
124
+ | maxValue | number | Validation: maximum value. |
125
+ | decimalPlaces | number | Decimal precision. |
126
+ | isOnlyPositive | boolean | Positive numbers only. |
127
+ | mask | string | Input mask. |
128
+
129
+ > **WARNING**
130
+ > `default` is a string containing a SQL expression, not a JavaScript value. Write `default: 'false'`, not `default: false`, and `default: "'draft'"` for a string literal.
131
+
132
+ ## FieldTypeEnum — Column Types
133
+
134
+ Column types come from the FieldTypeEnum enum exported by @suppa/sdk:
135
+
136
+ ```ts
137
+ import { FieldTypeEnum } from '@suppa/sdk';
138
+ ```
139
+
140
+ `type` is declared as string, so a raw literal such as `type: 'text'` still compiles — but a misspelled one (`'txet'`) compiles too and only fails when the migration runs. Referencing the enum turns that into an editor error, and gives you the full list of valid types on autocomplete.
141
+
142
+ | Member | Value | Use for |
143
+ |---|---|---|
144
+ | Text | text | Strings of any length. Add length to cap it. |
145
+ | Numeric | numeric | Decimal numbers. Pair with decimalPlaces. |
146
+ | Integer | integer | Whole numbers. |
147
+ | Serial | serial | Auto-increment integer. Already provided by SystemBaseEntity.id. |
148
+ | Boolean | boolean | true / false. |
149
+ | Timestamp | timestamp | Dates and date-times. |
150
+ | JSON | json | Arbitrary structured payloads. |
151
+ | UUID | uuid | External identifiers. |
152
+ | MultiLang | multi-language | Per-language string values stored on the record. |
153
+ | Bytea | bytea | Raw binary. Prefer @File for attachments. |
154
+ | TsVector | tsvector | Full-text search vectors. |
155
+ | MultiType | multi-type | Composite field built from sub-fields. |
156
+ | Icon | icon | Icon reference. |
157
+
158
+ > **TIP**
159
+ > FieldTypeEnum covers scalar columns only. Relations, enums and files are declared with their own decorators — @ManyToOne, @ManyToMany, @OneToMany, @Enum, @MultiEnum, @File, @MultiFile — and never with @Column({ type: ... }). The SDK also exports RelationTypeEnum with those relation kinds, but you do not pass it manually; each decorator sets it for you.
160
+
161
+ ## Relations
162
+
163
+ Relation decorators take a thunk returning the target class — `() => Workflows` — which keeps circular imports working:
164
+
165
+ ```ts
166
+ import {
167
+ Entity,
168
+ ManyToOne,
169
+ ManyToMany,
170
+ OneToMany,
171
+ SystemBaseEntity,
172
+ IconsEntity,
173
+ } from '@suppa/sdk';
174
+ import { Workflows } from './workflows.entity';
175
+
176
+ @Entity({ name: 'StageWorkflows', importKeyFields: ['name'] })
177
+ export class StageWorkflows extends SystemBaseEntity {
178
+ @ManyToOne(() => Workflows, { nullable: false })
179
+ workflow: Workflows;
180
+
181
+ @ManyToOne(() => IconsEntity)
182
+ icon: any;
183
+ }
184
+ ```
185
+
186
+ | Decorator | Signature | Use |
187
+ |---|---|---|
188
+ | @ManyToOne | (target, options?) or (target, inverse, options?) | Foreign key on this entity. |
189
+ | @ManyToMany | (target, options?) or (target, inverse, options?) | Pivot table between both entities. |
190
+ | @ManyToManyBackRef | (target, inverse, options?) | Reverse side of a ManyToMany. |
191
+ | @OneToMany | (target, inverse, options?) | Reverse side of a ManyToOne. |
192
+
193
+ `inverse` is a property selector on the target entity, for example `(task) => task.project`.
194
+
195
+ Platform entities are importable from the SDK when you need to point at them — for example `IconsEntity`.
196
+
197
+ ## Enums
198
+
199
+ @Enum and @MultiEnum accept a TypeScript enum with string values. Give the enum a global name (first argument) so it can be referenced from seeds and shared across entities:
200
+
201
+ ```ts
202
+ export enum StageStatusEnum {
203
+ Active = 'active',
204
+ InProgress = 'inprogress',
205
+ Deferred = 'deferred',
206
+ Completed = 'completed',
207
+ Canceled = 'cancelled',
208
+ }
209
+
210
+ export const StageStatus = {
211
+ [StageStatusEnum.Active]: { title: { en: 'Active', uk: 'Активний' } },
212
+ [StageStatusEnum.InProgress]: {
213
+ title: { en: 'In Progress', uk: 'В процесі' },
214
+ },
215
+ [StageStatusEnum.Deferred]: { title: { en: 'Deferred', uk: 'Відкладений' } },
216
+ [StageStatusEnum.Completed]: {
217
+ title: { en: 'Completed', uk: 'Виконаний' },
218
+ },
219
+ [StageStatusEnum.Canceled]: { title: { en: 'Canceled', uk: 'Скасований' } },
220
+ };
221
+
222
+ @Enum('StageWorkflows.status', StageStatusEnum, StageStatus, {
223
+ nullable: false,
224
+ })
225
+ status: StageStatusEnum;
226
+ ```
227
+
228
+ The second map is optional and adds a localized title, icon and order per value.
229
+
230
+ Use @MultiEnum with the same signatures for multi-select.
231
+
232
+ ## Files
233
+
234
+ ```ts
235
+ @File({ title: { en: 'Cover', uk: 'Обкладинка' } })
236
+ cover: any;
237
+
238
+ @MultiFile({ title: { en: 'Attachments', uk: 'Вкладення' } })
239
+ attachments: any[];
240
+ ```
241
+
242
+ ## Indexes and Checks
243
+
244
+ @Index() and @Check() are class decorators:
245
+
246
+ ```ts
247
+ @Entity({ name: 'Tasks', importKeyFields: ['externalId'] })
248
+ @Index('idx_tasks_project', ['project'])
249
+ @Index('idx_tasks_alive', ['deadline'], { where: '"deletedAt" IS NULL' })
250
+ @Check(
251
+ 'chk_tasks_positive_duration',
252
+ ['estimatedDuration'],
253
+ '"estimatedDuration" > 0',
254
+ )
255
+ export class Tasks extends SystemBaseEntity {}
256
+ ```
257
+
258
+ | @Index() option | Type | Description |
259
+ |---|---|---|
260
+ | unique | boolean | Unique index. |
261
+ | method | string | Index method, e.g. btree, gin. |
262
+ | where | string | Partial index predicate. |
263
+ | expression | string | Expression index. |
264
+ | comment | string | Description. |
265
+
266
+ ## importKeyFields — the Business Key
267
+
268
+ importKeyFields names the fields that identify a record independently of its numeric id. It is the backbone of seeds, export/import and cross-schema references, because id values differ between tenants.
269
+
270
+ ```ts
271
+ @Entity({ name: 'Workflows', importKeyFields: ['name'] })
272
+ ```
273
+
274
+ Pick fields that are stable and unique in practice. Without importKeyFields, seeds have nothing to match on and cannot stay idempotent.
275
+
276
+ > **TIP**
277
+ > Use the key option on @Entity() and @Column() when you expect to rename things later. The key is the stable identity used to recognize an existing entity or field, so a rename becomes a rename instead of a drop-and-create.
278
+
279
+ ## About title
280
+
281
+ title is not stored as a column. During migration the platform creates a Localizations record holding the per-language strings and links the entity or field metadata to it. You write the object inline and the platform handles the rest:
282
+
283
+ ```ts
284
+ @Column({
285
+ type: FieldTypeEnum.Text,
286
+ title: { en: 'Email', uk: 'Електронна пошта' },
287
+ })
288
+ email: string;
289
+ ```
@@ -0,0 +1,174 @@
1
+ # Registration — verbatim rules
2
+
3
+ Transcribed from docs.modern-expo.com/backend/application-developing/migrations.html (captured 2026-08-03). If an option is not in these tables, it does not exist — stop and ask.
4
+
5
+ ## EntityModule.forFeature
6
+
7
+ Everything goes through EntityModule from @suppa/sdk. Import it with forFeature() in the module that owns the entities — usually AppModule.
8
+
9
+ ```ts
10
+ import { Module } from '@nestjs/common';
11
+ import { EntityModule } from '@suppa/sdk';
12
+ import { Workflows, StageWorkflows } from '../common/database/entities';
13
+ import { workflowsSeed, stageWorkflowsSeed } from '../common/database/seeds';
14
+
15
+ @Module({
16
+ imports: [
17
+ EntityModule.forFeature([Workflows, StageWorkflows], {
18
+ seeds: [workflowsSeed, stageWorkflowsSeed],
19
+ }),
20
+ ],
21
+ })
22
+ export class AppModule {}
23
+ ```
24
+
25
+ EntityModule.forFeature() is what makes the platform aware of your entities and seeds. An entity class that is never passed to forFeature() is invisible — no table is created for it.
26
+
27
+ ## Call Shapes
28
+
29
+ There are two supported shapes:
30
+
31
+ ```ts
32
+ // 1. Explicit classes, with optional options
33
+ EntityModule.forFeature([Workflows, StageWorkflows], {
34
+ seeds: [workflowsSeed],
35
+ });
36
+
37
+ // 2. Options only — entities and seeds are autoloaded from paths
38
+ EntityModule.forFeature({
39
+ entitiesPath: 'dist/common/database/entities',
40
+ seedsPath: 'dist/common/database/seeds',
41
+ });
42
+ ```
43
+
44
+ ### Options
45
+
46
+ | Option | Type | Description |
47
+ |---|---|---|
48
+ | seeds | EntitySeedDefinition[] | Seeds created with createSeed(). |
49
+ | entitiesPath | string \| string[] | Directory or file to autoload entity classes from. |
50
+ | seedsPath | string \| string[] | Directory or file to autoload seeds from. |
51
+
52
+ Resolution order:
53
+
54
+ 1. If the entities array is passed and not empty, it is used and entitiesPath is ignored.
55
+ 2. Otherwise entities are loaded from entitiesPath.
56
+ 3. If seeds is passed and not empty, it is used and seedsPath is ignored.
57
+ 4. Otherwise seeds are loaded from seedsPath.
58
+
59
+ ## Recommended Project Structure
60
+
61
+ Keep entities and seeds side by side, separate from business logic:
62
+
63
+ ```txt
64
+ src/
65
+ index.ts
66
+ app/
67
+ app.module.ts
68
+ common/
69
+ database/
70
+ index.ts
71
+ entities/
72
+ index.ts
73
+ workflows.entity.ts
74
+ stage-workflows.entity.ts
75
+ seeds/
76
+ index.ts
77
+ workflows.seed.ts
78
+ stage-workflows.seed.ts
79
+ ```
80
+
81
+ ## Full Registration Example
82
+
83
+ ```ts
84
+ import { Module } from '@nestjs/common';
85
+ import { EntityModule } from '@suppa/sdk';
86
+ import {
87
+ StageWorkflows,
88
+ Tasks,
89
+ Workflows,
90
+ } from '../common/database/entities';
91
+ import {
92
+ stageWorkflowsSeed,
93
+ workflowsSeed,
94
+ } from '../common/database/seeds';
95
+
96
+ @Module({
97
+ imports: [
98
+ EntityModule.forFeature([Workflows, StageWorkflows, Tasks], {
99
+ seeds: [workflowsSeed, stageWorkflowsSeed],
100
+ }),
101
+ ],
102
+ })
103
+ export class AppModule {}
104
+ ```
105
+
106
+ Two rules to remember:
107
+
108
+ - Every entity class must appear in the entities array.
109
+ - Every seed must appear in the seeds array, ordered so that dependencies come first.
110
+
111
+ ## How Migrations Are Applied
112
+
113
+ You never run a migration command. The platform applies your schema as part of the application lifecycle:
114
+
115
+ 1. The runner starts your application — on creation of the Applications record, on reload, or when a tenant is provisioned.
116
+ 2. The SDK reads the decorator metadata of everything registered in EntityModule.forFeature() and generates two migration files: one for entity metadata, one for seeds.
117
+ 3. The files are applied to the tenant's schema: tables, columns, relations, enums, indexes and checks are created or updated, then seeds are inserted or updated.
118
+ 4. The result is recorded. If nothing in your entities or seeds changed since the last start, the step is skipped.
119
+
120
+ Two details worth knowing:
121
+
122
+ Entities and seeds behave differently on conflict. Entity metadata is overridden so the schema always converges to your class definitions. Seed rows are only inserted when missing, so data edited by users in the workspace is not overwritten on the next start.
123
+
124
+ It runs per tenant. Each tenant schema is migrated separately, and a newly provisioned tenant gets your entities and seeds when the application first boots for it.
125
+
126
+ ## The Development Loop
127
+
128
+ ```txt
129
+ edit entity / seed → push → reload the application → verify
130
+ ```
131
+
132
+ Reload with the application record id:
133
+
134
+ ```http
135
+ POST /core/applications/:appId/reload
136
+ ```
137
+
138
+ appId is the id of the record in the Applications table. The runner rebuilds the app from that record and restarts the running instance.
139
+
140
+ See Run application for the full application lifecycle.
141
+
142
+ > **TIP**
143
+ > For a faster loop, suppa-dev start --watch runs your application locally through a tunnel so hooks and controllers reload on save.
144
+
145
+ ## Common Mistakes
146
+
147
+ | Symptom | Cause |
148
+ |---|---|
149
+ | No table is created for an entity | The class was not passed to EntityModule.forFeature(). |
150
+ | Autoloading finds nothing | entitiesPath / seedsPath points at src/ instead of compiled dist/. |
151
+ | Duplicate seed rows after a restart | Record is missing one or more importKeyFields, so nothing matched. |
152
+ | Seed relation is empty or fails to resolve | Relation referenced by numeric id, or the target seed runs later. |
153
+ | Back reference can't insert | A reverse @OneToMany field is present in a seed record, possibly as []. |
154
+ | A renamed entity or field appears as a new one | No key option was set, so the rename was not recognized as a rename. |
155
+ | default value is rejected | A JavaScript value was passed instead of a SQL expression string. |
156
+
157
+ ## Requirements
158
+
159
+ Use the latest version of @suppa/sdk:
160
+
161
+ ```bash
162
+ pnpm add @suppa/sdk@latest
163
+ ```
164
+
165
+ Entities rely on decorator metadata, so the application tsconfig.json must enable both decorator flags:
166
+
167
+ ```json
168
+ {
169
+ "compilerOptions": {
170
+ "experimentalDecorators": true,
171
+ "emitDecoratorMetadata": true
172
+ }
173
+ }
174
+ ```
@@ -0,0 +1,134 @@
1
+ # Seed declaration — verbatim rules
2
+
3
+ Transcribed from docs.modern-expo.com/backend/application-developing/migrations.html (captured 2026-08-03). If an option is not in these tables, it does not exist — stop and ask.
4
+
5
+ ## createSeed
6
+
7
+ A seed is created with createSeed(entityName, data, options?) and exported from a *.seed.ts file.
8
+
9
+ ```ts
10
+ import { createSeed } from '@suppa/sdk';
11
+ import { EntityNamesEnum } from '../../modules';
12
+
13
+ export const workflowsSeed = createSeed(EntityNamesEnum.Workflows, [
14
+ {
15
+ name: 'Default',
16
+ description: 'Default set of statuses',
17
+ private: false,
18
+ externalId: null,
19
+ },
20
+ ]);
21
+ ```
22
+
23
+ The first argument is the entity name as a string — the same value as `name` in `@Entity()`. Keeping those names in a local enum (`EntityNamesEnum`) avoids typos across seeds.
24
+
25
+ ## Idempotency
26
+
27
+ Seeds run on every application start, for every tenant. They must therefore be idempotent: a seed either inserts a record or updates the existing one, but never duplicates it.
28
+
29
+ Matching is done on the target entity's importKeyFields. So:
30
+
31
+ - Always provide all importKeyFields in every record.
32
+ - If the natural key does not fit your data, override identity per record with `$key`.
33
+
34
+ ```ts
35
+ export const localizationsSeed = createSeed('Localizations', [
36
+ {
37
+ $key: { key: 'task-manager.greeting' },
38
+ key: 'task-manager.greeting',
39
+ en: 'Hello',
40
+ uk: 'Привіт',
41
+ },
42
+ ]);
43
+ ```
44
+
45
+ ## Referencing Relations
46
+
47
+ Reference a related record through the target's importKeyFields, as an object — never by numeric id:
48
+
49
+ ```ts
50
+ import { createSeed } from '@suppa/sdk';
51
+ import { StageStatusEnum } from '../entities';
52
+ import { EntityNamesEnum } from '../../modules';
53
+
54
+ export const stageWorkflowsSeed = createSeed(EntityNamesEnum.StageWorkflows, [
55
+ {
56
+ name: 'To Do',
57
+ color: '#3069FE',
58
+ order: 1000,
59
+ default: true,
60
+ status: {
61
+ name: 'StageWorkflows.status',
62
+ value: StageStatusEnum.Active,
63
+ },
64
+ workflow: { name: 'Default' },
65
+ },
66
+ {
67
+ name: 'In Progress',
68
+ color: '#47D1E2',
69
+ order: 2000,
70
+ status: {
71
+ name: 'StageWorkflows.status',
72
+ value: StageStatusEnum.InProgress,
73
+ },
74
+ workflow: { name: 'Default' },
75
+ },
76
+ {
77
+ name: 'Done',
78
+ color: '#75D900',
79
+ order: 5000,
80
+ status: {
81
+ name: 'StageWorkflows.status',
82
+ value: StageStatusEnum.Completed,
83
+ },
84
+ workflow: { name: 'Default' },
85
+ },
86
+ ]);
87
+ ```
88
+
89
+ Two reference shapes appear here:
90
+
91
+ | Field type | Reference shape |
92
+ |---|---|
93
+ | @ManyToOne | { <importKeyField>: value } — e.g. { name: 'Default' } |
94
+ | @Enum | { name: '<global enum name>', value: '<enum value>' } |
95
+ | @ManyToMany | An array of reference objects. |
96
+
97
+ Because `workflow: { name: 'Default' }` resolves by name, the seed works in every tenant regardless of what id the Default workflow received there.
98
+
99
+ > **WARNING**
100
+ > Seed order matters for relations. Register a seed after the seed that creates the records it points at — workflowsSeed before stageWorkflowsSeed.
101
+
102
+ ## What Not to Put in a Seed
103
+
104
+ | Never include | Why |
105
+ |---|---|
106
+ | id, createdAt, updatedAt, deletedAt, createdBy, removedBy | System columns. They differ per tenant and corrupt matching. |
107
+ | $readAccess, $updateAccess, $instanceAccess | Access metadata, not data. |
108
+ | Reverse @OneToMany fields — even as [] | Back references cannot be inserted; the import throws. |
109
+ | Numeric relation ids | They do not match across tenants. Use import-key references. |
110
+
111
+ > **TIP**
112
+ > When you build a seed from an exported record, strip those keys before committing. Seed a child entity with its own seed instead of nesting it in the parent.
113
+
114
+ ## Keeping Seed Files Thin
115
+
116
+ When a record carries a large payload, move the data to a static file and import it:
117
+
118
+ `src/common/database/static/currencies.ts`
119
+
120
+ ```ts
121
+ export const CURRENCIES = [
122
+ { code: 'USD', symbol: '$' },
123
+ { code: 'EUR', symbol: '€' },
124
+ ];
125
+ ```
126
+
127
+ `src/common/database/seeds/currencies.seed.ts`
128
+
129
+ ```ts
130
+ import { createSeed } from '@suppa/sdk';
131
+ import { CURRENCIES } from '../static/currencies';
132
+
133
+ export const currenciesSeed = createSeed('Currencies', CURRENCIES);
134
+ ```
@@ -0,0 +1,78 @@
1
+ # Suppa 1.0 → v2 code mapping
2
+
3
+ The API migration path and this code path share one authority: `classifyV1Field()` in suppa-mcp-2. Read the v1 schema with `suppa_read_v1_entities` → `suppa_read_v1_entity_props` (+ `suppa_read_v1_enum` for enum fields); normalize names with the same rules as `suppa_migrate_entities_from_v1` (entities → PascalCase, fields → camelCase, semantic dictionary, Cyrillic transliteration). Then map each classified field to a decorator with the table below. Never invent a mapping not listed here.
4
+
5
+ ## Builder-type → decorator table
6
+
7
+ | `classifyV1Field` v2Type | Decorator to emit |
8
+ |---|---|
9
+ | `text` | `@Column({ type: FieldTypeEnum.Text })` |
10
+ | `numeric` | `@Column({ type: FieldTypeEnum.Numeric })` |
11
+ | `integer` | `@Column({ type: FieldTypeEnum.Integer })` |
12
+ | `boolean` | `@Column({ type: FieldTypeEnum.Boolean })` |
13
+ | `timestamp` | `@Column({ type: FieldTypeEnum.Timestamp })` |
14
+ | `json` | `@Column({ type: FieldTypeEnum.JSON })` |
15
+ | `uuid` | `@Column({ type: FieldTypeEnum.UUID })` |
16
+ | `multi-language` | `@Column({ type: FieldTypeEnum.MultiLang })` |
17
+ | `icon` | `@Column({ type: FieldTypeEnum.Icon })` — scalar by default; use `@ManyToOne(() => IconsEntity)` only when v1 reports a relation |
18
+ | `enum` | `@Enum('<Entity>.<field>', <Field>Enum, <Field>Titles, { … })` + a TypeScript string enum built from `suppa_read_v1_enum` values + a seed is NOT needed (enum values live in the decorator maps) |
19
+ | `multi-enum` | `@MultiEnum(…)` — same signature as `@Enum` |
20
+ | `file` | `@File({ title: … })` |
21
+ | `multi-file` | `@MultiFile({ title: … })` |
22
+ | `many-to-one` | `@ManyToOne(() => <TargetClass>)` |
23
+ | `many-to-many` | `@ManyToMany(() => <TargetClass>)` |
24
+ | `one-to-many` | `@OneToMany(() => <TargetClass>, <inverse>)` — **inverse is a blocking question** (v1 props don't name it) |
25
+ | `many-to-many-backref` | `@ManyToManyBackRef(() => <TargetClass>, <inverse>)` — **inverse is a blocking question** |
26
+ | `serial` | never emitted — `SystemBaseEntity.id` already provides it |
27
+ | kind = `skip` | emit `// SKIPPED: <field> — <note from classifyV1Field>` inside the class body — never silently drop a field |
28
+
29
+ ### Never drop a field silently
30
+
31
+ If `classifyV1Field` returns `kind = 'skip'` — a system/structural field, an unsupported relation sub_type, or an unrecognized v1 type — the field must still appear in the generated class as a `// SKIPPED: <field> — <reason>` comment, using the classifier's own note as `<reason>`. Omitting it is not an option: the generated code must account for every v1 field, migrated or not.
32
+
33
+ ## Documented open edges
34
+
35
+ - `v2SubType: 'date'` (date-only v1 fields): `@Column()` has no documented `subType` option — emit `FieldTypeEnum.Timestamp` plus `// TODO: date-only in v1 — @Column has no documented date subtype; confirm rendering`.
36
+ - Icon duality: default scalar `FieldTypeEnum.Icon`; relation form only if v1 reports `type: relation` targeting icons.
37
+ - Lossy mappings carry the classifier's note as a trailing comment, e.g. `// v1 html_text → text (2.0 has no rich-text type)`.
38
+
39
+ ## Worked example
40
+
41
+ v1 entity `zakazy` (fields: `nazva` — string/string, `status` — custom_enum/one-to-many, `klient` — relation/one-to-many).
42
+
43
+ Name normalization (per `nameMap.ts`'s `SEMANTIC_DICT`): `zakazy` → `Orders` (entity), `nazva` → `Name` → field `name`, `klient` → `Customer` → field `customer`, targeting entity class `Customers` (the v1 `klient` relation points at the customers entity, whose own v1 name normalizes to `Customers`).
44
+
45
+ Classification (per `classifyV1Field`): `nazva` (`string`/`string`) → scalar `text`. `status` (`custom_enum`/`one-to-many`) → `kind: enum`, `v2Type: 'enum'`, not multiple (sub_type is `one-to-many`, not `many-to-many`). `klient` (`relation`/`one-to-many`) → `kind: relation`, `v2Type: 'many-to-one'`, not multiple.
46
+
47
+ ```ts
48
+ import { Column, Entity, Enum, FieldTypeEnum, ManyToOne, SystemBaseEntity } from '@suppa/sdk';
49
+ import { Customers } from './customers.entity';
50
+
51
+ export enum StatusEnum {
52
+ New = 'new',
53
+ Completed = 'completed',
54
+ }
55
+
56
+ export const StatusTitles = {
57
+ // Illustrative only — read the real value set with `suppa_read_v1_enum`.
58
+ [StatusEnum.New]: { title: { en: 'New' } },
59
+ [StatusEnum.Completed]: { title: { en: 'Completed' } },
60
+ };
61
+
62
+ @Entity({
63
+ name: 'Orders',
64
+ title: { en: 'zakazy' }, // carries the original v1 entity name through
65
+ // BLOCKING QUESTION: v1 does not report a business key for this entity —
66
+ // confirm the correct importKeyFields with the user before migrating.
67
+ })
68
+ export class Orders extends SystemBaseEntity {
69
+ @Column({ name: 'name', type: FieldTypeEnum.Text })
70
+ name: string;
71
+
72
+ @Enum('Orders.status', StatusEnum, StatusTitles)
73
+ status: StatusEnum;
74
+
75
+ @ManyToOne(() => Customers)
76
+ customer: Customers;
77
+ }
78
+ ```