@omnifyjp/omnify 3.13.1 → 3.14.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnifyjp/omnify",
3
- "version": "3.13.1",
3
+ "version": "3.14.1",
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": "3.13.1",
40
- "@omnifyjp/omnify-darwin-x64": "3.13.1",
41
- "@omnifyjp/omnify-linux-x64": "3.13.1",
42
- "@omnifyjp/omnify-linux-arm64": "3.13.1",
43
- "@omnifyjp/omnify-win32-x64": "3.13.1"
39
+ "@omnifyjp/omnify-darwin-arm64": "3.14.1",
40
+ "@omnifyjp/omnify-darwin-x64": "3.14.1",
41
+ "@omnifyjp/omnify-linux-x64": "3.14.1",
42
+ "@omnifyjp/omnify-linux-arm64": "3.14.1",
43
+ "@omnifyjp/omnify-win32-x64": "3.14.1"
44
44
  }
45
45
  }
@@ -17,6 +17,9 @@ import { generateEnums, generatePluginEnums, formatEnum, formatTypeAlias, extrac
17
17
  import { generateZodSchemas, generateDisplayNames, getExcludedFields, formatZodSchemasSection, formatZodModelFile, } from './zod-generator.js';
18
18
  import { generateI18nFileContent } from './i18n-generator.js';
19
19
  import { buildSchemaMetadata, formatMetadataConst, } from './metadata-generator.js';
20
+ import { generateTsServices } from './ts-service-generator.js';
21
+ import { generateTsQueryKeys } from './ts-query-keys-generator.js';
22
+ import { generateTsHooks } from './ts-hooks-generator.js';
20
23
  import { buildFormShape, formatPayloadBuilderSection, } from './payload-builder-generator.js';
21
24
  /** Auto-generated file header. */
22
25
  function generateBaseHeader() {
@@ -493,6 +496,11 @@ export function generateTypeScript(input) {
493
496
  files.push(generatePayloadHelpersFile(options));
494
497
  // I18n
495
498
  files.push(generateI18nFile(options));
499
+ // Frontend service layer: BaseService + QueryKeys + Hooks (issue #58)
500
+ // Only for schemas with options.api or options.service.
501
+ files.push(...generateTsServices(schemas, options));
502
+ files.push(...generateTsQueryKeys(schemas));
503
+ files.push(...generateTsHooks(schemas));
496
504
  // Index re-exports
497
505
  files.push(generateIndexFile(schemas, schemaEnums, pluginEnums, inlineTypeAliases, hasFiles));
498
506
  return files;
@@ -44,6 +44,8 @@ export interface MetadataField {
44
44
  label: Record<string, string>;
45
45
  /** Localized placeholder dictionary (locale → string). Optional. */
46
46
  placeholder?: Record<string, string>;
47
+ /** Localized description dictionary (locale → string). Optional. Issue #59. */
48
+ description?: Record<string, string>;
47
49
  }
48
50
  /** Aggregations exported alongside the per-field entries for ergonomics. */
49
51
  export interface MetadataAggregations {
@@ -191,6 +191,9 @@ export function buildSchemaMetadata(schema, allSchemas, options, displayNames) {
191
191
  const placeholder = displayNames.propertyPlaceholders[fieldKey];
192
192
  if (placeholder)
193
193
  meta.placeholder = placeholder;
194
+ const description = displayNames.propertyDescriptions[fieldKey];
195
+ if (description)
196
+ meta.description = description;
194
197
  if (fieldType === 'enum') {
195
198
  if (typeof prop.enum === 'string') {
196
199
  meta.enum = prop.enum;
@@ -314,6 +317,9 @@ export function formatMetadataConst(meta) {
314
317
  if (field.placeholder) {
315
318
  parts.push(` placeholder: ${jsLiteral(field.placeholder, 6)},\n`);
316
319
  }
320
+ if (field.description) {
321
+ parts.push(` description: ${jsLiteral(field.description, 6)},\n`);
322
+ }
317
323
  parts.push(` },\n`);
318
324
  }
319
325
  parts.push(` },\n\n`);
@@ -60,7 +60,6 @@ export function generatePhp(data, overrides) {
60
60
  if (reader.hasApiSchemas()) {
61
61
  files.push(...generateSchemaConfig(reader, config));
62
62
  files.push(...generateControllers(reader, config));
63
- files.push(...generateServices(reader, config));
64
63
  files.push(...generateRoutes(reader, config));
65
64
  // Issue #35: opt-in OpenAPI / Swagger annotation scaffold.
66
65
  // Controller-level method attributes are emitted inline by
@@ -68,6 +67,10 @@ export function generatePhp(data, overrides) {
68
67
  // we add the standalone Common / Info / Schemas files.
69
68
  files.push(...generateOpenApi(reader, config));
70
69
  }
70
+ // Service layer (schemas with options.api OR options.service). Issue #57.
71
+ if (reader.hasApiSchemas() || reader.hasServiceSchemas()) {
72
+ files.push(...generateServices(reader, config));
73
+ }
71
74
  // Issue #34: every `kind: enum` schema becomes a global PHP enum class.
72
75
  files.push(...generateEnums(reader, config));
73
76
  // Per-schema files
@@ -57,6 +57,17 @@ export declare class SchemaReader {
57
57
  getFileConfig(): import("../types.js").FileConfigExport | null;
58
58
  /** Get all schemas that have File-type properties. */
59
59
  getSchemasWithFileProperties(): Record<string, SchemaDefinition>;
60
+ /** Get global audit config from schemas.json. */
61
+ getAuditConfig(): {
62
+ model?: string;
63
+ createdBy?: boolean;
64
+ updatedBy?: boolean;
65
+ deletedBy?: boolean;
66
+ } | null;
67
+ /** Get schemas that have service options configured (options.service). */
68
+ getSchemasWithService(): Record<string, import('../types.js').SchemaDefinition>;
69
+ /** Check if any schema has service options. */
70
+ hasServiceSchemas(): boolean;
60
71
  /** Get translatable field names (snake_case) for a schema. */
61
72
  getTranslatableFields(schemaName: string): string[];
62
73
  }
@@ -201,6 +201,24 @@ export class SchemaReader {
201
201
  }
202
202
  return result;
203
203
  }
204
+ /** Get global audit config from schemas.json. */
205
+ getAuditConfig() {
206
+ return this.data.auditConfig ?? null;
207
+ }
208
+ /** Get schemas that have service options configured (options.service). */
209
+ getSchemasWithService() {
210
+ const result = {};
211
+ for (const [name, schema] of Object.entries(this.getProjectVisibleObjectSchemas())) {
212
+ if (schema.options?.service) {
213
+ result[name] = schema;
214
+ }
215
+ }
216
+ return result;
217
+ }
218
+ /** Check if any schema has service options. */
219
+ hasServiceSchemas() {
220
+ return Object.keys(this.getSchemasWithService()).length > 0;
221
+ }
204
222
  /** Get translatable field names (snake_case) for a schema. */
205
223
  getTranslatableFields(schemaName) {
206
224
  const schema = this.getSchema(schemaName);
@@ -1,7 +1,11 @@
1
1
  /**
2
- * Generates base + editable service classes for schemas with `options.api`.
2
+ * Generates base + editable service classes for schemas with `options.api`
3
+ * or `options.service`.
4
+ *
5
+ * Issue #57: Full BaseService codegen with translatable, softDelete, audit,
6
+ * DB::transaction, eagerLoad/eagerCount, lookupFields, defaultSort.
3
7
  */
4
8
  import { SchemaReader } from './schema-reader.js';
5
9
  import type { GeneratedFile, PhpConfig } from './types.js';
6
- /** Generate service classes for all schemas with api config. */
10
+ /** Generate service classes for all schemas with api or service config. */
7
11
  export declare function generateServices(reader: SchemaReader, config: PhpConfig): GeneratedFile[];