suppa-mcp-2 1.4.0 → 1.5.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.
@@ -107,11 +107,34 @@ function rawPath(pathOrUrl) {
107
107
  p = p.replace(/[\t\n\r]/g, "").replace(/^[\x00-\x20]+|[\x00-\x20]+$/g, "").replace(/\\/g, "/");
108
108
  const scheme = p.indexOf("://");
109
109
  if (scheme !== -1) {
110
- const slash = p.indexOf("/", scheme + 3);
110
+ // Skip the WHOLE run of slashes after the scheme, then the authority. The
111
+ // old code took the first '/' after '://', so `https:///host/core/data/X/delete`
112
+ // kept `host` as a path segment and the route no longer matched — while the
113
+ // URL parser consumed the run and made `host` the host. Eight inputs
114
+ // bypassed the block that way.
115
+ let i = scheme + 1;
116
+ while (i < p.length && p[i] === "/")
117
+ i += 1;
118
+ const slash = p.indexOf("/", i);
111
119
  p = slash === -1 ? "" : p.slice(slash);
112
120
  }
113
121
  return p.split("?")[0].split("#")[0];
114
122
  }
123
+ /**
124
+ * The path the request will actually carry, as computed by the SAME parser
125
+ * fetch uses. Hand-rolled normalisation has now been wrong six times — tabs,
126
+ * NULs, backslashes, dot segments, double-encoded dots, and slash runs — so the
127
+ * authoritative reading comes from the platform's URL parser, and the manual
128
+ * one below is kept only as a second opinion for inputs it refuses.
129
+ */
130
+ function parsedPath(pathOrUrl) {
131
+ try {
132
+ return new URL(String(pathOrUrl ?? ""), "https://blocked.invalid/").pathname;
133
+ }
134
+ catch {
135
+ return null;
136
+ }
137
+ }
115
138
  /** Collapse, trim and lowercase a resolved path into comparable route segments. */
116
139
  function comparable(path) {
117
140
  return path
@@ -143,18 +166,26 @@ function comparable(path) {
143
166
  * 3. the decoded path re-resolved, for one that normalizes after decoding.
144
167
  */
145
168
  function routeCandidates(pathOrUrl) {
146
- const onWire = resolveDotSegments(rawPath(pathOrUrl));
147
- const candidates = [comparable(onWire)];
148
- let decoded = null;
149
- try {
150
- decoded = decodeURIComponent(onWire);
151
- }
152
- catch {
153
- // Malformed escapes: the wire form above is the whole answer. A router
154
- // cannot decode this either, so there is no second reading to model.
155
- }
156
- if (decoded !== null && decoded !== onWire) {
157
- candidates.push(comparable(decoded), comparable(resolveDotSegments(decoded)));
169
+ const candidates = [];
170
+ // Two readings of the wire: the platform's own URL parser (authoritative) and
171
+ // the manual normalisation (for inputs it rejects). Both feed the same decode
172
+ // variants below, so a divergence between them can only ADD a blocked form.
173
+ const wireForms = [parsedPath(pathOrUrl), resolveDotSegments(rawPath(pathOrUrl))];
174
+ for (const onWire of wireForms) {
175
+ if (onWire === null)
176
+ continue;
177
+ candidates.push(comparable(onWire));
178
+ let decoded = null;
179
+ try {
180
+ decoded = decodeURIComponent(onWire);
181
+ }
182
+ catch {
183
+ // Malformed escapes: the wire form is the whole answer. A router cannot
184
+ // decode this either, so there is no second reading to model.
185
+ }
186
+ if (decoded !== null && decoded !== onWire) {
187
+ candidates.push(comparable(decoded), comparable(resolveDotSegments(decoded)));
188
+ }
158
189
  }
159
190
  return candidates;
160
191
  }
package/dist/server.js CHANGED
@@ -297,7 +297,7 @@ export function buildServer() {
297
297
  // Reset so repeated buildServer() calls (e.g. in tests) do not double-count.
298
298
  TOOL_NAMES.length = 0;
299
299
  PROMPT_NAMES.length = 0;
300
- const server = new McpServer({ name: "suppa-2.0", version: "1.4.0" }, { instructions: INSTRUCTIONS });
300
+ const server = new McpServer({ name: "suppa-2.0", version: "1.5.0" }, { instructions: INSTRUCTIONS });
301
301
  const reg = (name, cfg, handler) => {
302
302
  server.registerTool(name, {
303
303
  description: cfg.description,
@@ -1038,15 +1038,20 @@ export function buildServer() {
1038
1038
  " 'relation' is accepted as an alias for many-to-one. Provide relation_entity for\n" +
1039
1039
  " relations, enum_name for enums. Constraints: max_length/min_length (text),\n" +
1040
1040
  " decimal_places / min_value / max_value / only_positive (numeric).\n" +
1041
- " options_json decides whether the field is USABLE once created: showInTable,\n" +
1042
- " canFilter, canSort, canGroup, editFromTable, readOnly, searchable +\n" +
1043
- " searchPriority (1-4). A field created without them is absent from table views\n" +
1044
- " and cannot be found by free-text search. They can be changed later with\n" +
1045
- " suppa_update_field; the field's TYPE never can.\n" +
1046
- " required=true makes the column NOT NULL and REQUIRES default_value (a SQL\n" +
1047
- " expression or literal: '0', 'false', \"'draft'\", 'now()'); the call is refused\n" +
1048
- " before any request if it is missing — no default is ever invented for you.\n" +
1049
- " many-to-many / multi-enum take no default_value.\n" +
1041
+ " options_json tunes the field: showInTable, canFilter, canSort, canGroup,\n" +
1042
+ " editFromTable, readOnly, searchable + searchPriority (1-4). Omitted, the\n" +
1043
+ " platform fills its own defaults in — visible, sortable, groupable, filterable,\n" +
1044
+ " editable, not read-only, and NOT searchable. So searchable (+searchPriority) is\n" +
1045
+ " the one worth setting: without it the field cannot be found by free-text\n" +
1046
+ " search. All of them can be changed later with suppa_update_field; the field's\n" +
1047
+ " TYPE never can.\n" +
1048
+ " required=true makes the column NOT NULL. Where a defaultValue APPLIES it is\n" +
1049
+ " also required, and the call is refused before any request if missing — no\n" +
1050
+ " default is ever invented for you. defaultValue does NOT apply to relations,\n" +
1051
+ " enums, files or unique fields (builder.txt:43): there it is dropped, and the\n" +
1052
+ " result says so under not_applicable. notNull itself does not apply to\n" +
1053
+ " many-to-many / multi-enum, nor unique to relations and enums (builder.txt:41-42)\n" +
1054
+ " — those are withheld and reported the same way.\n" +
1050
1055
  " 'one-to-many' is REFUSED: an owned child collection is a TABULAR PART\n" +
1051
1056
  " (suppa_create_tabular_part, which auto-creates the child's 'owner' and the\n" +
1052
1057
  " parent link); never hand-build parent.one-to-many + child.owner. Use\n" +
@@ -1076,7 +1081,10 @@ export function buildServer() {
1076
1081
  .string()
1077
1082
  .nullable()
1078
1083
  .default(null)
1079
- .describe("Qualified enum key 'Entity.field' — REQUIRED for enum/multi-enum."),
1084
+ .describe("The enum's global name — REQUIRED for enum/multi-enum. Conventionally " +
1085
+ "'Entity.field' (e.g. 'Receipts.type'), but it need not match the field " +
1086
+ "name: one enum can back several fields. Create its values first with " +
1087
+ "suppa_add_enum_values under this same name."),
1080
1088
  sub_type: z
1081
1089
  .string()
1082
1090
  .nullable()
@@ -97,10 +97,19 @@ export function defaultValueApplies(fieldType, unique = false) {
97
97
  // ---------------------------------------------------------------------------
98
98
  //
99
99
  // builder.txt:60 — "options | object | false | Field options configuration."
100
- // Its keys are builder.txt:66-73. A field created without them is invisible in
101
- // table views and unsearchable until a human fixes it in the UI: the free-text
102
- // search of suppa_search_records only covers fields carrying `searchable`
103
- // (data.txt:218 — "Only fields with the searchable option participate.").
100
+ // Its keys are builder.txt:66-73.
101
+ //
102
+ // The platform FILLS THEM IN when the body omits them. Read back from a live
103
+ // 2.0 tenant (modern-expo.dev.suppa.me, 2026-08-05) on a field this server
104
+ // created with no options object at all:
105
+ // canGroup:true canSort:true showInTable:true editFromTable:true
106
+ // canFilter:true readOnly:false searchable:false
107
+ // So an omitted options object leaves a field visible, sortable, groupable and
108
+ // filterable — but NOT searchable: the free-text search of suppa_search_records
109
+ // only covers fields carrying `searchable` (data.txt:218 — "Only fields with
110
+ // the searchable option participate."). `searchable` (and searchPriority) are
111
+ // therefore the ones worth setting deliberately; the rest already hold the
112
+ // value most fields want.
104
113
  /** Boolean members of the Field Options object. */
105
114
  export const FIELD_OPTION_BOOLEAN_KEYS = [
106
115
  "searchable", // builder.txt:66 — "Available for search."
@@ -1369,10 +1378,17 @@ export async function addField(entityName, fieldName, fieldType, title, opts = {
1369
1378
  `(this field is '${resolvedType}'). The field was created WITHOUT the unique constraint.`);
1370
1379
  }
1371
1380
  // builder.txt:43 — "Not applicable to relations, enums, or unique fields":
1372
- // sending it there is at best ignored, so it is never emitted.
1381
+ // sending it there is at best ignored, so it is never emitted. A default the
1382
+ // caller ASKED for and did not get is reported, like the other two — dropping
1383
+ // it silently was the same defect notNull and unique already had fixed.
1373
1384
  if (defaultText.trim() !== "" && typeNeedsDefault) {
1374
1385
  fieldDef.defaultValue = defaultText;
1375
1386
  }
1387
+ else if (defaultText.trim() !== "") {
1388
+ notApplicable.push(`defaultValue was NOT set: builder.txt:43 — "Not applicable to relations, enums, or unique ` +
1389
+ `fields" (this field is '${resolvedType}'${unique ? " and unique" : ""}). The field was ` +
1390
+ "created WITHOUT a default.");
1391
+ }
1376
1392
  if (subType) {
1377
1393
  fieldDef.subType = subType;
1378
1394
  }
@@ -1626,6 +1642,40 @@ export async function updateField(entityName, fieldName, opts = {}) {
1626
1642
  });
1627
1643
  }
1628
1644
  }
1645
+ // Applicability is a property of the field TYPE, not of the endpoint
1646
+ // (builder.txt:41-43), so update-field has to withhold exactly what add-fields
1647
+ // withholds. It used to send all three unconditionally and report them as
1648
+ // applied — the 1.3.1 fix, never carried across to this path. The live type
1649
+ // read above is what makes the decision possible; without it nothing is
1650
+ // withheld, because guessing would be worse than sending.
1651
+ const notApplicable = [];
1652
+ const liveType = String(meta?.type ?? "");
1653
+ if (liveType) {
1654
+ if ("notNull" in body && body.notNull === true && !notNullApplies(liveType)) {
1655
+ delete body.notNull;
1656
+ notApplicable.push(`notNull was NOT sent: builder.txt:41 — "Not applicable to many-to-many / multi-enum" ` +
1657
+ `('${fieldName}' is '${liveType}'). The required constraint is unchanged.`);
1658
+ }
1659
+ if ("unique" in body &&
1660
+ body.unique === true &&
1661
+ RELATION_LIKE_FIELD_TYPES.includes(liveType)) {
1662
+ delete body.unique;
1663
+ notApplicable.push(`unique was NOT sent: builder.txt:42 — "Not applicable to relations and enums" ` +
1664
+ `('${fieldName}' is '${liveType}'). The unique constraint is unchanged.`);
1665
+ }
1666
+ if ("defaultValue" in body && !defaultValueApplies(liveType, body.unique === true)) {
1667
+ delete body.defaultValue;
1668
+ notApplicable.push(`defaultValue was NOT sent: builder.txt:43 — "Not applicable to relations, enums, or ` +
1669
+ `unique fields" ('${fieldName}' is '${liveType}'). The default is unchanged.`);
1670
+ }
1671
+ }
1672
+ if (Object.keys(body).length === 0) {
1673
+ return jsonResponse({
1674
+ error: `Refused: every change requested for '${entityName}.${fieldName}' is inapplicable to a ` +
1675
+ `'${liveType}' field, so nothing was sent.`,
1676
+ not_applicable: notApplicable,
1677
+ });
1678
+ }
1629
1679
  const result = await makeRequest("POST", `/api/core/builder/${entityName}/${fieldName}/update-field`, body);
1630
1680
  const out = {
1631
1681
  entity: entityName,
@@ -1633,6 +1683,9 @@ export async function updateField(entityName, fieldName, opts = {}) {
1633
1683
  sent: body,
1634
1684
  result,
1635
1685
  };
1686
+ if (notApplicable.length > 0) {
1687
+ out.not_applicable = notApplicable;
1688
+ }
1636
1689
  if (subTypeValue === "encrypted") {
1637
1690
  // migrations.txt:244-247 — what the platform does to the field and its rows.
1638
1691
  out.encryption_note =
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "MCP server for the Suppa platform (modern.suppa.me) — Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments, with multi-tenant Google auth. Node port of PyPI suppa-mcp.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -40,13 +40,13 @@ Confirm all 5 before writing anything:
40
40
  ## Hard rules
41
41
 
42
42
  1. Every entity extends `SystemBaseEntity`; never declare `id`, `createdAt`, `updatedAt`, `deletedAt`, `createdBy`, `removedBy` yourself — it already provides them.
43
- 2. An entity class that is not in `EntityModule.forFeature()` does not exist — the platform creates no table for it (doc: "An entity class that is never passed to forFeature() is invisible"). Write the entity and register it in the SAME step; never move on to the next entity, or report progress, with an unregistered class.
43
+ 2. An entity class that is not in `EntityModule.forFeature()` does not exist — the platform creates no table for it (doc: "An entity class that is never passed to forFeature() is invisible"). Write the entity and register it in the SAME step; never move on to the next entity, or report progress, with an unregistered class. Being *named* in a `forFeature()` is not enough: the call's result must be consumed by an `@Module`'s `imports` (rule 19), or nothing is registered at all.
44
44
  3. `default` is a SQL expression string — `'false'`, `"'draft'"` — never a JS value; a JS value is rejected at migration time.
45
45
  4. Scalars only via `@Column({ type: FieldTypeEnum.X })`; relations/enums/files are NEVER declared via `@Column` — use the `@ManyToOne`/`@ManyToMany`/`@OneToMany`/`@ManyToManyBackRef`/`@Enum`/`@MultiEnum`/`@File`/`@MultiFile` families.
46
46
  5. Relation targets are thunks — `() => Target`, never the class itself — or circular imports break.
47
47
  6. Do not pass the optional `inverse` selector to `@ManyToOne`/`@ManyToMany` — write `@ManyToOne(() => Target, { … })`. Add one only when the target class declares the paired back-reference and you are deliberately linking the two sides. An `inverse` must select a RELATION property on the target (`(task) => task.project`); `(e) => e.id` is always wrong — `id` is a system column, not a back-reference.
48
48
  7. If an option isn't in the reference tables (`references/entities.md`, `references/seeds.md`, `references/registration.md`), it doesn't exist — stop and ask, don't guess.
49
- 8. Every entity class must appear in some `forFeature()`'s `entities` array; every seed in its `seeds` array, dependencies first — `workflowsSeed` before `stageWorkflowsSeed`.
49
+ 8. Every entity class must appear in the class array passed as `forFeature()`'s FIRST argument (there is no `entities` option — rule 19); every seed in the options object's `seeds` array, dependencies first — `workflowsSeed` before `stageWorkflowsSeed`.
50
50
  9. Seeds: every record carries all `importKeyFields` (or `$key`); relations are referenced by the target's import-key object, never a numeric id; no system columns; no `$readAccess`/`$updateAccess`/`$instanceAccess`; no reverse `@OneToMany` field, even as `[]`.
51
51
  10. Autoload paths (`entitiesPath`/`seedsPath`) point at `dist/`, never `src/` — autoloading reads compiled output.
52
52
  11. Renames need `key` set on `@Entity()`/`@Column()` BEFORE the rename ships — otherwise it's a drop-and-create, not a rename.
@@ -57,6 +57,7 @@ Confirm all 5 before writing anything:
57
57
  16. **Never write an option that already holds its default value.** The platform applies `canGroup: true`, `canSort: true`, `showInTable: true`, `editFromTable: true`, `canFilter: true`, `readOnly: false`, `searchable: false` on its own. Declare one of these ONLY where the field departs from it; repeating defaults on every field buries the one option that actually differs. W612.
58
58
  17. **`@Enum`/`@MultiEnum` take the global name only when the enum is global.** Default is local: `@Enum(StageStatusEnum, StageStatus, { nullable: false })` — the decorator derives `<ClassName>.<propertyName>`. Pass the name as the FIRST argument only when the value set is shared across entities or referenced from a seed: `@Enum('StageWorkflows.status', StageStatusEnum, StageStatus, { … })`. W613.
59
59
  18. Repeating rows owned by one parent record are a **tabular part**, never a plain entity: `type: 'tabular-part'` + `relationEntityName` (the parent's `@Entity()` name) + a `@ManyToOne` field named exactly `owner` pointing at the parent class — all three required, the platform infers none of them. Put `owner` FIRST in `importKeyFields` — it scopes the business key to the parent, or rows collide across different parents.
60
+ 19. **`EntityModule.forFeature()` must be consumed by an `@Module`, and has exactly two shapes.** It RETURNS a module: put it in `@Module({ imports: [...] })` and export that class from `src/index.ts` as `AppModule` — a bare `EntityModule.forFeature(...);` statement discards the result and registers nothing (E307). The two shapes (`references/registration.md`) are `forFeature([A, B], { seeds: [...] })` — classes FIRST, options second — and `forFeature({ entitiesPath, seedsPath })` for autoloading. The options object accepts only `seeds`, `entitiesPath` and `seedsPath`. `forFeature({ entities: [...] })` looks reasonable and registers NOTHING: the classes are dropped with the unknown option and no table is created for any of them. E306.
60
61
 
61
62
  ## Decorator decision table
62
63
 
@@ -129,7 +130,7 @@ A `@ManyToOne` without `nullable: false` is written `owner?: ProductMatrixEntity
129
130
 
130
131
  1. Pre-flight (above) — confirm repo, SDK version, tsconfig, layout.
131
132
  2. Blocking questions (above) — get answers before writing any file.
132
- 3. Write the entity AND wire it in (one step, both files): write `*.entity.ts` from `templates/entity.template.ts` per `references/entities.md`, then immediately export it from the entities barrel and add it to `EntityModule.forFeature()`'s `entities` array — see "Wiring a new entity in" below. The class does not exist to the platform until this is done.
133
+ 3. Write the entity AND wire it in (one step, both files): write `*.entity.ts` from `templates/entity.template.ts` per `references/entities.md`, then immediately export it from the entities barrel and add it to the class array passed as `EntityModule.forFeature()`'s first argument — see "Wiring a new entity in" below. The class does not exist to the platform until this is done.
133
134
  4. Need default rows? Same deal for the seed: write it from `templates/seed.template.ts` per `references/seeds.md`, export it from the seeds barrel, and add it to the `seeds` array (dependencies first) in the same step. The seed is not done until it is in the `seeds` array.
134
135
  5. Run the close-out gate (below) — do not report "done" before all 4 steps pass.
135
136
 
@@ -156,22 +157,47 @@ Four edits, every time:
156
157
 
157
158
  1. Export the class from the entities barrel — `src/common/database/entities/index.ts`.
158
159
  2. Export the seed from the seeds barrel — `src/common/database/seeds/index.ts`.
159
- 3. Import the class in the module and add it to the `entities` array.
160
+ 3. Import the class in the module and add it to the class array — `forFeature()`'s FIRST argument.
160
161
  4. Add the seed to the `seeds` array, positioned AFTER the seeds of everything it references.
161
162
 
162
163
  ```ts
163
164
  // before
164
- EntityModule.forFeature([Workflows], { seeds: [workflowsSeed] });
165
+ import { Module } from '@nestjs/common';
166
+ import { EntityModule } from '@suppa/sdk';
167
+ import { Workflows } from '../common/database/entities';
168
+ import { workflowsSeed } from '../common/database/seeds';
169
+
170
+ @Module({
171
+ imports: [EntityModule.forFeature([Workflows], { seeds: [workflowsSeed] })],
172
+ })
173
+ export class AppModule {}
165
174
 
166
175
  // after — new import, new entity, new seed
167
176
  import { MyNewEntity } from '../common/database/entities';
168
177
  import { myNewEntitySeed } from '../common/database/seeds';
169
178
 
170
- EntityModule.forFeature([Workflows, MyNewEntity], {
171
- seeds: [workflowsSeed, myNewEntitySeed],
172
- });
179
+ @Module({
180
+ imports: [
181
+ EntityModule.forFeature([Workflows, MyNewEntity], {
182
+ seeds: [workflowsSeed, myNewEntitySeed],
183
+ }),
184
+ ],
185
+ })
186
+ export class AppModule {}
173
187
  ```
174
188
 
189
+ **forFeature() RETURNS a module — something must consume it.** It goes in the `imports` of an `@Module`. Called as a bare statement the returned module is thrown away and NOTHING is registered, while the call still looks exactly like working code (E307). And `src/index.ts` must export `AppModule`: the runner imports your package from there and expects to find it.
190
+
191
+ **The shape is not negotiable.** There are exactly two (`references/registration.md`): the classes as the FIRST argument with an options object second, or an options object alone that autoloads from `entitiesPath`/`seedsPath`. The options object accepts only `seeds`, `entitiesPath` and `seedsPath` — there is no `entities` option:
192
+
193
+ ```ts
194
+ EntityModule.forFeature([A, B], { seeds: [aSeed] }); // correct
195
+ EntityModule.forFeature({ entitiesPath: 'dist/…/entities' }); // correct
196
+ EntityModule.forFeature({ entities: [A, B], seeds: [aSeed] }); // WRONG — E306
197
+ ```
198
+
199
+ The third form looks reasonable and registers nothing: the classes are dropped with the unknown option, and no table is created for any of them.
200
+
175
201
  Self-check, no tooling required:
176
202
 
177
203
  ```
@@ -201,6 +227,9 @@ The validator parses with the TypeScript compiler API, read from the app repo yo
201
227
  | Symptom | Cause | Validator code |
202
228
  |---|---|---|
203
229
  | No table is created for an entity | The class was not passed to `EntityModule.forFeature()` | E301 |
230
+ | No table is created for ANY entity, and the registration looks right | `forFeature({ entities: [...] })` — an invented shape; the classes go in the FIRST argument and the options object has no `entities` key | E306 |
231
+ | Every entity is missing its table, and the registration reads correctly | `forFeature()` called as a bare statement — the module it returns is discarded | E307 — put it in `@Module({ imports: [...] })` and export `AppModule` from `src/index.ts` |
232
+ | E301 never fires even though an entity is clearly unregistered | A `forFeature()` names neither a class array nor `entitiesPath`, so membership is unknown and the check is skipped for the whole run | W614 |
204
233
  | Autoloading finds nothing | `entitiesPath` / `seedsPath` points at `src/` instead of compiled `dist/` | E303 |
205
234
  | Duplicate seed rows after a restart | Record is missing one or more `importKeyFields` | E205 |
206
235
  | Seed relation is empty or fails to resolve | Relation referenced by numeric id, or the target seed runs later | E203 + E304 |
@@ -10,7 +10,7 @@ The API migration path and this code path share one authority: `classifyV1Field(
10
10
  | `numeric` | `@Column({ type: FieldTypeEnum.Numeric })` |
11
11
  | `integer` | `@Column({ type: FieldTypeEnum.Integer })` |
12
12
  | `boolean` | `@Column({ type: FieldTypeEnum.Boolean })` |
13
- | `timestamp` | `@Column({ type: FieldTypeEnum.Timestamp })` — plus `subType: 'date'` when `classifyV1Field` returns `v2SubType: 'date'` (see below) |
13
+ | `timestamp` | `@Column({ type: FieldTypeEnum.Timestamp })` — plus `subType: 'date'` or `subType: 'time'` when `classifyV1Field` returns that `v2SubType` (see below) |
14
14
  | `json` | `@Column({ type: FieldTypeEnum.JSON })` |
15
15
  | `uuid` | `@Column({ type: FieldTypeEnum.UUID })` |
16
16
  | `multi-language` | `@Column({ type: FieldTypeEnum.MultiLang })` |
@@ -21,22 +21,34 @@ The API migration path and this code path share one authority: `classifyV1Field(
21
21
  | `multi-file` | `@MultiFile({ title: … })` |
22
22
  | `many-to-one` | `@ManyToOne(() => <TargetClass>)` |
23
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 |
24
+ | `one-to-many` | `@OneToMany(() => <TargetClass>, <inverse>)` — **inverse is a blocking question** (v1 props don't name it). NEVER produced by `classifyV1Field` — see the warning below |
25
+ | `many-to-many-backref` | `@ManyToManyBackRef(() => <TargetClass>, <inverse>)` — **inverse is a blocking question**. NEVER produced by `classifyV1Field` |
26
+ | `serial` | never emitted — `SystemBaseEntity.id` already provides it, and `classifyV1Field` never returns it |
27
27
  | kind = `skip` | emit `// SKIPPED: <field> — <note from classifyV1Field>` inside the class body — never silently drop a field |
28
28
 
29
+ > **This table is keyed on the CLASSIFIER'S OUTPUT (`v2Type`), never on a raw v1 `sub_type`.**
30
+ > The distinction matters most for one string: v1 reports `sub_type: 'one-to-many'` on an ordinary
31
+ > foreign-key column, and `classifyV1Field` maps that to **`many-to-one`** (`v1Fields.ts` —
32
+ > `"one-to-many": ["many-to-one", false]`). Matching the raw v1 string against the left column
33
+ > instead would emit `@OneToMany`, a back reference, where `@ManyToOne` is correct — the FK would
34
+ > never be created. The `one-to-many`, `many-to-many-backref` and `serial` rows exist only to say
35
+ > what to write IF that v2 type ever reaches you: the reverse-side decorators are authored,
36
+ > parent-side additions you add deliberately, never products of the migration.
37
+
29
38
  ### Never drop a field silently
30
39
 
31
40
  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
41
 
33
- ## `v2SubType` — date-only v1 fields
42
+ ## `v2SubType` — date-only and time-only v1 fields
34
43
 
35
- `classifyV1Field` returns `v2SubType: 'date'` for a v1 date-only field. That maps to a documented option: `FieldTypeEnum.Timestamp` + `subType: 'date'`, which the platform turns into a real Postgres `date` column.
44
+ `classifyV1Field` returns `v2SubType: 'date'` for a v1 date-only field and `v2SubType: 'time'` for a time-only one. Both map to a documented option: `FieldTypeEnum.Timestamp` plus that `subType`, which the platform turns into a real Postgres `date` / `time` column. There is no `FieldTypeEnum.Date` and no `FieldTypeEnum.Time`.
36
45
 
37
46
  ```ts
38
47
  @Column({ name: 'birthday', type: FieldTypeEnum.Timestamp, subType: 'date' })
39
48
  birthday: string;
49
+
50
+ @Column({ name: 'opensAt', type: FieldTypeEnum.Timestamp, subType: 'time' })
51
+ opensAt: string;
40
52
  ```
41
53
 
42
54
  Get it right the first time: `subType` is immutable after creation except for the `'encrypted'` toggle, so a field created as plain `timestamp` cannot later be converted to `date` — it has to be replaced by a new field. Never emit `subType` on an `@Enum`/`@MultiEnum` field; the decorator writes it.