routesync 1.0.3 → 1.0.4

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/dist/cli.js CHANGED
@@ -8459,7 +8459,10 @@ if ($extractModels) {
8459
8459
  $result['models'][] = [
8460
8460
  'name' => class_basename($class),
8461
8461
  'table' => $table,
8462
- 'columns' => $parsedColumns
8462
+ 'columns' => $parsedColumns,
8463
+ 'hidden' => $model->getHidden(),
8464
+ 'appends' => $model->getAppends(),
8465
+ 'casts' => $model->getCasts()
8463
8466
  ];
8464
8467
  } catch (\\Exception $e) {}
8465
8468
  }
@@ -8916,12 +8919,23 @@ var ModelGenerator = class {
8916
8919
  lines.push(``);
8917
8920
  for (const model of manifest.models) {
8918
8921
  lines.push(`export interface ${model.name} {`);
8922
+ const hidden = Array.isArray(model.hidden) ? model.hidden : [];
8923
+ const casts = model.casts || {};
8919
8924
  for (const col of model.columns) {
8920
- const tsType = this.mapSqlTypeToTs(col.type);
8925
+ const isHidden2 = hidden.includes(col.name);
8926
+ const isOptional = isHidden2 ? "?" : "";
8927
+ const castType = casts[col.name];
8928
+ let tsType = this.mapSqlTypeToTs(col.type);
8929
+ if (castType) {
8930
+ tsType = this.mapCastToTs(castType, tsType);
8931
+ }
8921
8932
  const nullable = col.nullable ? " | null" : "";
8922
- const isOptional = col.name === "password" || col.name === "remember_token" ? "?" : "";
8923
8933
  lines.push(` ${col.name}${isOptional}: ${tsType}${nullable}`);
8924
8934
  }
8935
+ const appends = Array.isArray(model.appends) ? model.appends : [];
8936
+ for (const append of appends) {
8937
+ lines.push(` ${append}: any // appended attribute`);
8938
+ }
8925
8939
  lines.push(`}`);
8926
8940
  lines.push(``);
8927
8941
  }
@@ -8940,6 +8954,22 @@ var ModelGenerator = class {
8940
8954
  }
8941
8955
  return "string";
8942
8956
  }
8957
+ static mapCastToTs(castType, defaultType) {
8958
+ const type = castType.toLowerCase();
8959
+ if (type.includes("int") || type.includes("float") || type.includes("decimal") || type.includes("double")) {
8960
+ return "number";
8961
+ }
8962
+ if (type.includes("bool")) {
8963
+ return "boolean";
8964
+ }
8965
+ if (type.includes("array") || type.includes("json") || type.includes("collection") || type.includes("object")) {
8966
+ return "any";
8967
+ }
8968
+ if (type.includes("date") || type.includes("datetime") || type.includes("string")) {
8969
+ return "string";
8970
+ }
8971
+ return defaultType;
8972
+ }
8943
8973
  };
8944
8974
 
8945
8975
  // packages/cli/src/commands/generate.ts
package/dist/core.d.mts CHANGED
@@ -223,6 +223,9 @@ interface ParsedModel {
223
223
  name: string;
224
224
  table: string;
225
225
  columns: ParsedColumn[];
226
+ hidden?: string[];
227
+ appends?: string[];
228
+ casts?: Record<string, string>;
226
229
  }
227
230
 
228
231
  export { type ApiDefinition, ApiError, type ApiResponse, type AuthConfig, AuthMiddleware, ErrorHandler, HttpClient, type HttpMethod, Interceptor, type PaginationMeta, type ParsedChannel, type ParsedColumn, type ParsedModel, type ParsedRoute, PathResolver, QueryBuilder, Request, type RequestOptions, Response, type RetryConfig, type RouteDefinition, type RouteManifest, type RouteMapper, type RouteParserSchema, type RouteSchema, type RouteSchemaMap, type RouteSchemaValue, type RouteTransform, type RouteTransformMap, type ServiceConfig, TokenManager };
package/dist/core.d.ts CHANGED
@@ -223,6 +223,9 @@ interface ParsedModel {
223
223
  name: string;
224
224
  table: string;
225
225
  columns: ParsedColumn[];
226
+ hidden?: string[];
227
+ appends?: string[];
228
+ casts?: Record<string, string>;
226
229
  }
227
230
 
228
231
  export { type ApiDefinition, ApiError, type ApiResponse, type AuthConfig, AuthMiddleware, ErrorHandler, HttpClient, type HttpMethod, Interceptor, type PaginationMeta, type ParsedChannel, type ParsedColumn, type ParsedModel, type ParsedRoute, PathResolver, QueryBuilder, Request, type RequestOptions, Response, type RetryConfig, type RouteDefinition, type RouteManifest, type RouteMapper, type RouteParserSchema, type RouteSchema, type RouteSchemaMap, type RouteSchemaValue, type RouteTransform, type RouteTransformMap, type ServiceConfig, TokenManager };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "routesync",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Laravel routes to typed frontend SDKs.",
5
5
  "main": "./dist/sdk.js",
6
6
  "module": "./dist/sdk.mjs",