@omnifyjp/omnify 5.8.22 → 5.8.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.
@@ -314,9 +314,74 @@
314
314
  "items": { "$ref": "#/definitions/CodegenLaravel" }
315
315
  }
316
316
  ]
317
+ },
318
+ "go": {
319
+ "description": "Go codegen configuration: plain structs + migrations, with optional uptrace/bun tag emission. Issue omnify-jp/omnify-go#65 + #103.",
320
+ "oneOf": [
321
+ { "$ref": "#/definitions/CodegenGo" },
322
+ {
323
+ "type": "array",
324
+ "items": { "$ref": "#/definitions/CodegenGo" }
325
+ }
326
+ ]
317
327
  }
318
328
  }
319
329
  },
330
+ "CodegenGo": {
331
+ "type": "object",
332
+ "properties": {
333
+ "name": { "type": "string", "description": "Target identifier (used by --target CLI flag)." },
334
+ "enable": { "type": "boolean", "description": "Enable this Go target. Default false." },
335
+ "rootPath": { "type": "string", "description": "Root path for generated Go files (e.g. './backend')." },
336
+ "database": {
337
+ "type": "string",
338
+ "enum": ["sqlite", "mysql", "mariadb", "postgres"],
339
+ "description": "SQL dialect used by the migrations generator. Default 'sqlite'."
340
+ },
341
+ "modulePath": {
342
+ "type": "string",
343
+ "description": "Go module path (e.g. 'github.com/org/app'). When empty, omnify reads go.mod under rootPath."
344
+ },
345
+ "domain": { "$ref": "#/definitions/CodegenGoPath" },
346
+ "enums": { "$ref": "#/definitions/CodegenGoPath" },
347
+ "migrations": { "$ref": "#/definitions/CodegenGoPath" },
348
+ "sqlc": { "$ref": "#/definitions/CodegenGoPath" },
349
+ "schemas": {
350
+ "type": "object",
351
+ "properties": {
352
+ "include": { "type": "array", "items": { "type": "string" } },
353
+ "exclude": { "type": "array", "items": { "type": "string" } }
354
+ }
355
+ },
356
+ "bun": {
357
+ "type": "object",
358
+ "description": "Bun ORM (uptrace/bun) tag emission. When enable=true, generated structs gain bun:\"...\" tags + an embedded bun.BaseModel.",
359
+ "properties": {
360
+ "enable": { "type": "boolean", "description": "Turn Bun tag emission on. Default false." },
361
+ "alias": { "type": "string", "description": "Table alias on bun.BaseModel. Empty → derive from schema name. '-' suppresses alias." },
362
+ "baseModelImport": { "type": "string", "description": "Import path for bun.BaseModel. Default 'github.com/uptrace/bun'." },
363
+ "softDeleteTag": { "type": "string", "description": "bun tag fragment used on soft-delete columns. Default ',soft_delete,nullzero'." }
364
+ }
365
+ },
366
+ "migrationStyle": {
367
+ "type": "string",
368
+ "enum": ["inline", "numbered_files"],
369
+ "description": "How migrations are emitted. 'inline' → generated/<pkg>/migrations.go with Migrations []string slice. 'numbered_files' → migrations/NNNN_*.up.sql + .down.sql (golang-migrate compatible). Default depends on database."
370
+ },
371
+ "jsonTags": { "type": "boolean", "description": "Emit json:\"...\" struct tags. Default true." },
372
+ "omitemptyForNullable": { "type": "boolean", "description": "Append ,omitempty to json tags for nullable / pointer fields. Default true." },
373
+ "emitTranslations": { "type": "boolean", "description": "Auto-generate <entity>_translations sidecar tables + Go structs (Bun has-many relation when bun.enable=true) for properties marked translatable: true. Default true when any translatable field is present." }
374
+ },
375
+ "additionalProperties": false
376
+ },
377
+ "CodegenGoPath": {
378
+ "type": "object",
379
+ "properties": {
380
+ "outputPath": { "type": "string" },
381
+ "packageName": { "type": "string" }
382
+ },
383
+ "additionalProperties": false
384
+ },
320
385
  "CodegenTypeScript": {
321
386
  "type": "object",
322
387
  "properties": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/omnify",
3
- "version": "5.8.22",
3
+ "version": "5.8.24",
4
4
  "description": "Schema-driven code generation for Laravel, TypeScript, and SQL",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,10 +36,10 @@
36
36
  "zod": "^3.24.0"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@omnifyjp/omnify-darwin-arm64": "5.8.22",
40
- "@omnifyjp/omnify-darwin-x64": "5.8.22",
41
- "@omnifyjp/omnify-linux-x64": "5.8.22",
42
- "@omnifyjp/omnify-linux-arm64": "5.8.22",
43
- "@omnifyjp/omnify-win32-x64": "5.8.22"
39
+ "@omnifyjp/omnify-darwin-arm64": "5.8.24",
40
+ "@omnifyjp/omnify-darwin-x64": "5.8.24",
41
+ "@omnifyjp/omnify-linux-x64": "5.8.24",
42
+ "@omnifyjp/omnify-linux-arm64": "5.8.24",
43
+ "@omnifyjp/omnify-win32-x64": "5.8.24"
44
44
  }
45
45
  }
@@ -58,9 +58,14 @@ export function generatePolicies(reader, config) {
58
58
  // Per-schema generation
59
59
  // ============================================================================
60
60
  function generateForSchema(name, schema, reader, config) {
61
+ // Issue #101 v5.8.23: only emit the policy BASE. The user-editable
62
+ // stub was pure scaffolding (extends base, no body) for every
63
+ // schema — typically 80+ noise files in a project. When the dev
64
+ // wants to customize a permission check, they hand-create the
65
+ // wrapper at `userEditablePath`; Laravel's policy auto-discovery
66
+ // picks it up. Until then, the base alone is enough.
61
67
  return [
62
68
  generateBasePolicyClass(name, schema, reader, config),
63
- generateUserPolicyClass(name, schema, config),
64
69
  ];
65
70
  }
66
71
  function generateBasePolicyClass(name, schema, reader, config) {
@@ -33,11 +33,14 @@ export function generateRequests(reader, config) {
33
33
  return files;
34
34
  }
35
35
  function generateForSchema(name, schema, reader, config) {
36
+ // Issue #101 v5.8.23: only emit the request BASE classes. The
37
+ // user-editable stubs were pure scaffolding (extends base, no body)
38
+ // — typically 121 noise files in a project. Controllers + DI inject
39
+ // the BASE FQN directly. When custom validation IS needed, the dev
40
+ // creates the editable file by hand under `userEditablePath`.
36
41
  return [
37
42
  generateBaseRequest(name, schema, reader, config, 'Store'),
38
43
  generateBaseRequest(name, schema, reader, config, 'Update'),
39
- generateUserRequest(name, schema, config, 'Store'),
40
- generateUserRequest(name, schema, config, 'Update'),
41
44
  ];
42
45
  }
43
46
  function generateBaseRequest(name, schema, reader, config, action) {
@@ -3,5 +3,11 @@
3
3
  */
4
4
  import { SchemaReader } from './schema-reader.js';
5
5
  import type { GeneratedFile, PhpConfig } from './types.js';
6
- /** Generate Resource classes for all project-owned visible object schemas. */
6
+ /** Generate Resource classes for all project-owned visible object schemas.
7
+ *
8
+ * Issue #101 v5.8.23: only the base is emitted. Empty editable stubs
9
+ * (every project's 30+ thin `class XResource extends Base {}`) are
10
+ * pure scaffolding noise — devs hand-create wrappers only when custom
11
+ * serialization logic IS needed.
12
+ */
7
13
  export declare function generateResources(reader: SchemaReader, config: PhpConfig): GeneratedFile[];
@@ -4,14 +4,19 @@
4
4
  import { toPascalCase, toSnakeCase, toCamelCase } from './naming-helper.js';
5
5
  import { isHiddenByDefault, toResourceExpression } from './type-mapper.js';
6
6
  import { baseFile, userFile, resolveModularBasePath, resolveModularBaseNamespace, resolveBaseClass, resolveEditableClass, nestByGroup, nestEditableByGroup } from './types.js';
7
- /** Generate Resource classes for all project-owned visible object schemas. */
7
+ /** Generate Resource classes for all project-owned visible object schemas.
8
+ *
9
+ * Issue #101 v5.8.23: only the base is emitted. Empty editable stubs
10
+ * (every project's 30+ thin `class XResource extends Base {}`) are
11
+ * pure scaffolding noise — devs hand-create wrappers only when custom
12
+ * serialization logic IS needed.
13
+ */
8
14
  export function generateResources(reader, config) {
9
15
  const files = [];
10
16
  for (const [name, schema] of Object.entries(reader.getProjectVisibleObjectSchemas())) {
11
17
  if (schema.kind === 'extend')
12
18
  continue;
13
19
  files.push(generateBaseResource(name, schema, reader, config));
14
- files.push(generateUserResource(name, schema, config));
15
20
  }
16
21
  return files;
17
22
  }
package/types/config.d.ts CHANGED
@@ -134,10 +134,93 @@ export interface CodegenLaravelConfig {
134
134
  nestedset?: CodegenNestedSetConfig;
135
135
  }
136
136
 
137
+ /** Migration emission style for the Go target. Issue #103. */
138
+ export type GoMigrationStyle = "inline" | "numbered_files";
139
+
140
+ /** Go database / SQL dialect for the Go migrations generator. */
141
+ export type GoDatabase = "sqlite" | "mysql" | "mariadb" | "postgres";
142
+
143
+ /** Output path + package name for one Go codegen sub-target. */
144
+ export interface CodegenGoPathConfig {
145
+ outputPath?: string;
146
+ packageName?: string;
147
+ }
148
+
149
+ /** Schema include / exclude filter for a Go target. */
150
+ export interface CodegenGoSchemaFilter {
151
+ include?: string[];
152
+ exclude?: string[];
153
+ }
154
+
155
+ /**
156
+ * Bun ORM (uptrace/bun) tag emission. When `enable: true`, generated
157
+ * structs gain `bun:"..."` struct tags + an embedded `bun.BaseModel`.
158
+ * Issue #103.
159
+ */
160
+ export interface CodegenGoBunConfig {
161
+ /** Turn Bun tag emission on. Default false → plain structs (json + db tags). */
162
+ enable?: boolean;
163
+ /**
164
+ * Table alias on `bun.BaseModel`. Empty → omnify derives one from the
165
+ * schema name (e.g. ProjectDoc → "pd"). Set to "-" to suppress alias.
166
+ */
167
+ alias?: string;
168
+ /** Import path for `bun.BaseModel`. Defaults to "github.com/uptrace/bun". */
169
+ baseModelImport?: string;
170
+ /** Tag fragment used on soft-delete columns. Default ",soft_delete,nullzero". */
171
+ softDeleteTag?: string;
172
+ }
173
+
174
+ /** Go (uptrace/bun-friendly) codegen target. Issue omnify-jp/omnify-go#65 + #103. */
175
+ export interface CodegenGoTarget {
176
+ /** Target identifier for partial-regen flags. */
177
+ name?: string;
178
+ /** Enable this target. Defaults to false. */
179
+ enable?: boolean;
180
+ /** Root path for generated Go files (e.g. "./backend"). */
181
+ rootPath?: string;
182
+ /** SQL dialect for the migrations generator. Default "sqlite". */
183
+ database?: GoDatabase;
184
+ /** Go module path (e.g. "github.com/org/app"). Reads go.mod when empty. */
185
+ modulePath?: string;
186
+ /** Plain-struct output (`{Model}Base` + json/db tags). */
187
+ domain?: CodegenGoPathConfig;
188
+ /** Enums package output. */
189
+ enums?: CodegenGoPathConfig;
190
+ /** Migrations output (style depends on `migrationStyle` + `database`). */
191
+ migrations?: CodegenGoPathConfig;
192
+ /** sqlc query files output. */
193
+ sqlc?: CodegenGoPathConfig;
194
+ /** Schema include / exclude filter for this target. */
195
+ schemas?: CodegenGoSchemaFilter;
196
+ /** Bun ORM tag emission (default off; opt in via `bun.enable: true`). */
197
+ bun?: CodegenGoBunConfig;
198
+ /**
199
+ * Migration emission style.
200
+ * "inline" — generated/<pkg>/migrations.go with `Migrations []string` slice
201
+ * "numbered_files" — migrations/NNNN_*.up.sql + .down.sql (golang-migrate compatible)
202
+ * Defaults: sqlite → "numbered_files"; mysql/mariadb/postgres → "inline".
203
+ */
204
+ migrationStyle?: GoMigrationStyle;
205
+ /** Emit `json:"..."` struct tags. Default true. */
206
+ jsonTags?: boolean;
207
+ /** Append `,omitempty` to json tags for nullable / pointer fields. Default true. */
208
+ omitemptyForNullable?: boolean;
209
+ /**
210
+ * Auto-generate `<entity>_translations` sidecar tables + Go structs
211
+ * (Bun has-many relation when `bun.enable: true`) for properties
212
+ * marked `translatable: true`. Default true when any translatable
213
+ * field is present.
214
+ */
215
+ emitTranslations?: boolean;
216
+ }
217
+
137
218
  /** Code generation configuration (connection-independent). */
138
219
  export interface CodegenConfig {
139
220
  typescript?: CodegenTypeScriptConfig;
140
221
  laravel?: CodegenLaravelConfig;
222
+ /** Go target — plain structs + migrations + optional Bun tags. */
223
+ go?: CodegenGoTarget | CodegenGoTarget[];
141
224
  }
142
225
 
143
226
  /**