fiberx-backend-toolkit 0.0.60 → 0.0.61

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.
@@ -48,9 +48,9 @@ export default ${schema_name};
48
48
  };
49
49
  exports.SEQUELIZE_SCHEMA_CODE_TEMPLATE = SEQUELIZE_SCHEMA_CODE_TEMPLATE;
50
50
  const SEQUELIZE_CREATE_NEW_SCHEMA_MIGRATION_FILE_CODE_TEMPLATE = (schema_table_name, schema_model_name, schema_file_name) => `
51
- import { QueryInterface, DataTypes, Sequelize } from "sequelize";
52
- import { LoggerUtil } from "fiberx-backend-toolkit/dist/utils";
53
- import { SchemaDefinitionInterface } from "fiberx-backend-toolkit/dist/types/schema_type";
51
+ import { QueryInterface, Sequelize } from "sequelize";
52
+ import { LoggerUtil } from "fiberx-backend-toolkit/dist/utils/main";
53
+ import { SchemaDefinitionInterface } from "fiberx-backend-toolkit";
54
54
  import ${schema_model_name}Schema from "@/database/schemas/${schema_file_name.replace(".ts", "")}";
55
55
 
56
56
  class Create${schema_model_name}TableMigration {
@@ -63,16 +63,16 @@ class Create${schema_model_name}TableMigration {
63
63
  // Migration UP
64
64
  public async up(
65
65
  queryInterface: QueryInterface,
66
- Sequelize: typeof import("sequelize")
66
+ Sequelize: Sequelize
67
67
  ) {
68
68
  try {
69
- const { table_name, columns = {}, indexes = [] } = this.schema;
69
+ const { table_name, model_name, columns = {}, indexes = [] } = this.schema;
70
70
 
71
71
  await queryInterface.createTable(table_name, columns);
72
72
 
73
73
  for (const index_field_obj of indexes) {
74
74
 
75
- const { fields, name, index_options } = index_field_obj;
75
+ const { fields, name, ...index_options } = index_field_obj;
76
76
  const index_name = \`idx_\${table_name}_\${fields.join("_")}\`
77
77
 
78
78
  await queryInterface.addIndex(
@@ -82,7 +82,7 @@ class Create${schema_model_name}TableMigration {
82
82
  );
83
83
  }
84
84
 
85
- this.logger.success(\`✅ Table "\${table_name}" for schema "\${model_name}Schema" created with "\${this.index_attributes.length}" indexed Fields.\`);
85
+ this.logger.success(\`✅ Table "\${table_name}" for schema "\${model_name}Schema" created with "\${indexes.length}" indexed Fields.\`);
86
86
  }
87
87
  catch (error: any) {
88
88
  this.logger.error(\`🚫 Migration failed: "\${error.message}"\`, { error });
@@ -93,7 +93,7 @@ class Create${schema_model_name}TableMigration {
93
93
  // Migration DOWN
94
94
  public async down(
95
95
  queryInterface: QueryInterface,
96
- Sequelize: typeof import("sequelize")
96
+ Sequelize: Sequelize
97
97
  ) {
98
98
  try {
99
99
  const { table_name, database_name, model_name } = this.schema;
@@ -110,9 +110,9 @@ export default Create${schema_model_name}TableMigration;
110
110
  `;
111
111
  exports.SEQUELIZE_CREATE_NEW_SCHEMA_MIGRATION_FILE_CODE_TEMPLATE = SEQUELIZE_CREATE_NEW_SCHEMA_MIGRATION_FILE_CODE_TEMPLATE;
112
112
  const SEQUELIZE_UPDATE_EXISTING_SCHEMA_MIGRATION_FILE_CODE_TEMPLATE = (schema_table_name, schema_model_name, diff, schema_file_name) => `
113
- import { QueryInterface, DataTypes, Sequelize } from "sequelize";
114
- import { LoggerUtil } from "fiberx-backend-toolkit/dist/utils";
115
- import { SchemaDefinitionInterface } from "fiberx-backend-toolkit/dist/types/schema_type";
113
+ import { QueryInterface, Sequelize } from "sequelize";
114
+ import { LoggerUtil } from "fiberx-backend-toolkit/dist/utils/main";
115
+ import { SchemaDefinitionInterface } from "fiberx-backend-toolkit";
116
116
  import ${schema_model_name}Schema from "@/database/schemas/${schema_file_name.replace(".ts", "")}";
117
117
 
118
118
  class Update${schema_model_name}TableMigration {
@@ -124,7 +124,7 @@ class Update${schema_model_name}TableMigration {
124
124
 
125
125
  public async up(
126
126
  queryInterface: QueryInterface,
127
- Sequelize: typeof import("sequelize")
127
+ Sequelize: Sequelize
128
128
  ) {
129
129
  try {
130
130
  const { table_name, model_name, columns = {}, indexes = [] } = this.schema;
@@ -206,7 +206,7 @@ class Update${schema_model_name}TableMigration {
206
206
 
207
207
  public async down(
208
208
  queryInterface: QueryInterface,
209
- Sequelize: typeof import("sequelize")
209
+ Sequelize: Sequelize
210
210
  ) {
211
211
  try {
212
212
  const { table_name, model_name, columns = {} } = this.schema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fiberx-backend-toolkit",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "description": "A TypeScript backend toolkit providing shared domain logic, infrastructure helpers, and utilities for FiberX server-side applications and services.",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",