@uecsio/pages-api 1.2.1 → 1.3.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.
package/README.md CHANGED
@@ -86,7 +86,83 @@ The package automatically provides a REST API with the following endpoints:
86
86
  - `PUT /pages/:id` - Update a page
87
87
  - `DELETE /pages/:id` - Delete a page
88
88
 
89
- ### 4. Customize the Page Entity
89
+ ### 4. Database Migrations
90
+
91
+ The package includes database migrations that are automatically discovered by the consuming application. The migrations will be executed externally via your TypeORM settings.
92
+
93
+ #### Automatic Discovery (Recommended)
94
+
95
+ The consuming application automatically discovers all `@uecsio` packages and their migrations:
96
+
97
+ ```typescript
98
+ // No manual configuration needed - migrations are auto-discovered!
99
+ @Module({
100
+ imports: [
101
+ TypeOrmModule.forRoot({
102
+ type: 'postgres',
103
+ host: 'localhost',
104
+ port: 5432,
105
+ username: 'postgres',
106
+ password: 'password',
107
+ database: 'your_database',
108
+ // Migrations and entities are automatically discovered from @uecsio packages
109
+ synchronize: false, // Always false for production
110
+ }),
111
+ PagesModule,
112
+ ],
113
+ })
114
+ export class AppModule {}
115
+ ```
116
+
117
+ #### Manual Integration (Alternative)
118
+
119
+ If you prefer manual control, you can still integrate manually:
120
+
121
+ ```typescript
122
+ import { PagesMigrationConfig } from '@uecsio/pages-api';
123
+
124
+ @Module({
125
+ imports: [
126
+ TypeOrmModule.forRoot({
127
+ type: 'postgres',
128
+ host: 'localhost',
129
+ port: 5432,
130
+ username: 'postgres',
131
+ password: 'password',
132
+ database: 'your_database',
133
+ entities: [...PagesMigrationConfig.entities],
134
+ migrations: [...PagesMigrationConfig.migrations],
135
+ migrationsTableName: 'migrations', // Standard migration table
136
+ synchronize: false, // Always false for production
137
+ }),
138
+ PagesModule,
139
+ ],
140
+ })
141
+ export class AppModule {}
142
+ ```
143
+
144
+ **Note:** This module uses the standard `migrations` table name, so it will work seamlessly with other modules that also use the same migration table.
145
+
146
+ #### Available migrations
147
+
148
+ The package provides the following migration:
149
+ - `CreatePagesTable1700000000000` - Creates the pages table with all required columns and indexes
150
+
151
+ #### Migration execution
152
+
153
+ Migrations will be executed automatically by TypeORM when you run:
154
+ ```bash
155
+ # Generate new migrations
156
+ npm run typeorm migration:generate
157
+
158
+ # Run pending migrations
159
+ npm run typeorm migration:run
160
+
161
+ # Revert last migration
162
+ npm run typeorm migration:revert
163
+ ```
164
+
165
+ ### 5. Customize the Page Entity
90
166
 
91
167
  You can extend the Page entity for your specific needs:
92
168
 
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './controllers/pages.controller';
4
4
  export * from './dto/create-page.dto';
5
5
  export * from './dto/update-page.dto';
6
6
  export * from './entities/page.entity';
7
+ export * from './migrations/migration.config';
7
8
  export { Page } from './entities/page.entity';
8
9
  export { CreatePageDto } from './dto/create-page.dto';
9
10
  export { UpdatePageDto } from './dto/update-page.dto';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AAGvC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,+BAA+B,CAAC;AAG9C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ __exportStar(require("./controllers/pages.controller"), exports);
21
21
  __exportStar(require("./dto/create-page.dto"), exports);
22
22
  __exportStar(require("./dto/update-page.dto"), exports);
23
23
  __exportStar(require("./entities/page.entity"), exports);
24
+ __exportStar(require("./migrations/migration.config"), exports);
24
25
  var page_entity_1 = require("./entities/page.entity");
25
26
  Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return page_entity_1.Page; } });
26
27
  var create_page_dto_1 = require("./dto/create-page.dto");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,iDAA+B;AAC/B,2DAAyC;AACzC,iEAA+C;AAC/C,wDAAsC;AACtC,wDAAsC;AACtC,yDAAuC;AAGvC,sDAA8C;AAArC,mGAAA,IAAI,OAAA;AACb,yDAAsD;AAA7C,gHAAA,aAAa,OAAA;AACtB,yDAAsD;AAA7C,gHAAA,aAAa,OAAA;AACtB,0DAAwD;AAA/C,6GAAA,YAAY,OAAA;AACrB,mEAAiE;AAAxD,mHAAA,eAAe,OAAA;AACxB,+CAA6C;AAApC,2GAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,iDAA+B;AAC/B,2DAAyC;AACzC,iEAA+C;AAC/C,wDAAsC;AACtC,wDAAsC;AACtC,yDAAuC;AAGvC,gEAA8C;AAG9C,sDAA8C;AAArC,mGAAA,IAAI,OAAA;AACb,yDAAsD;AAA7C,gHAAA,aAAa,OAAA;AACtB,yDAAsD;AAA7C,gHAAA,aAAa,OAAA;AACtB,0DAAwD;AAA/C,6GAAA,YAAY,OAAA;AACrB,mEAAiE;AAAxD,mHAAA,eAAe,OAAA;AACxB,+CAA6C;AAApC,2GAAA,WAAW,OAAA"}
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class CreatePagesTable1700000000000 implements MigrationInterface {
3
+ up(queryRunner: QueryRunner): Promise<void>;
4
+ down(queryRunner: QueryRunner): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=1700000000000-CreatePagesTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1700000000000-CreatePagesTable.d.ts","sourceRoot":"","sources":["../../src/migrations/1700000000000-CreatePagesTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAqB,MAAM,SAAS,CAAC;AAE7E,qBAAa,6BAA8B,YAAW,kBAAkB;IACzD,EAAE,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAwG3C,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3D"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreatePagesTable1700000000000 = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ class CreatePagesTable1700000000000 {
6
+ async up(queryRunner) {
7
+ await queryRunner.createTable(new typeorm_1.Table({
8
+ name: 'pages',
9
+ columns: [
10
+ {
11
+ name: 'id',
12
+ type: 'int',
13
+ isPrimary: true,
14
+ isGenerated: true,
15
+ generationStrategy: 'increment',
16
+ },
17
+ {
18
+ name: 'title',
19
+ type: 'varchar',
20
+ length: '255',
21
+ isNullable: false,
22
+ },
23
+ {
24
+ name: 'url',
25
+ type: 'varchar',
26
+ length: '500',
27
+ isNullable: false,
28
+ },
29
+ {
30
+ name: 'content',
31
+ type: 'text',
32
+ isNullable: true,
33
+ },
34
+ {
35
+ name: 'meta_title',
36
+ type: 'varchar',
37
+ length: '255',
38
+ isNullable: true,
39
+ },
40
+ {
41
+ name: 'meta_keywords',
42
+ type: 'text',
43
+ isNullable: true,
44
+ },
45
+ {
46
+ name: 'meta_description',
47
+ type: 'text',
48
+ isNullable: true,
49
+ },
50
+ {
51
+ name: 'status',
52
+ type: 'int',
53
+ default: 1,
54
+ isNullable: false,
55
+ },
56
+ {
57
+ name: 'activate_from',
58
+ type: 'timestamp',
59
+ isNullable: true,
60
+ },
61
+ {
62
+ name: 'activate_to',
63
+ type: 'timestamp',
64
+ isNullable: true,
65
+ },
66
+ {
67
+ name: 'created_at',
68
+ type: 'timestamp',
69
+ default: 'CURRENT_TIMESTAMP',
70
+ isNullable: false,
71
+ },
72
+ {
73
+ name: 'updated_at',
74
+ type: 'timestamp',
75
+ default: 'CURRENT_TIMESTAMP',
76
+ onUpdate: 'CURRENT_TIMESTAMP',
77
+ isNullable: false,
78
+ },
79
+ ],
80
+ }), true);
81
+ await queryRunner.createIndex('pages', new typeorm_1.TableIndex({
82
+ name: 'IDX_PAGES_STATUS',
83
+ columnNames: ['status'],
84
+ }));
85
+ await queryRunner.createIndex('pages', new typeorm_1.TableIndex({
86
+ name: 'IDX_PAGES_ACTIVATE_FROM',
87
+ columnNames: ['activate_from'],
88
+ }));
89
+ await queryRunner.createIndex('pages', new typeorm_1.TableIndex({
90
+ name: 'IDX_PAGES_ACTIVATE_TO',
91
+ columnNames: ['activate_to'],
92
+ }));
93
+ }
94
+ async down(queryRunner) {
95
+ await queryRunner.dropTable('pages');
96
+ }
97
+ }
98
+ exports.CreatePagesTable1700000000000 = CreatePagesTable1700000000000;
99
+ //# sourceMappingURL=1700000000000-CreatePagesTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1700000000000-CreatePagesTable.js","sourceRoot":"","sources":["../../src/migrations/1700000000000-CreatePagesTable.ts"],"names":[],"mappings":";;;AAAA,qCAA6E;AAE7E,MAAa,6BAA6B;IACjC,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,WAAW,CAAC,WAAW,CAC3B,IAAI,eAAK,CAAC;YACR,IAAI,EAAE,OAAO;YACb,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,KAAK;oBACX,SAAS,EAAE,IAAI;oBACf,WAAW,EAAE,IAAI;oBACjB,kBAAkB,EAAE,WAAW;iBAChC;gBACD;oBACE,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,KAAK;oBACb,UAAU,EAAE,KAAK;iBAClB;gBACD;oBACE,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,KAAK;oBACb,UAAU,EAAE,KAAK;iBAClB;gBACD;oBACE,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,MAAM;oBACZ,UAAU,EAAE,IAAI;iBACjB;gBACD;oBACE,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,SAAS;oBACf,MAAM,EAAE,KAAK;oBACb,UAAU,EAAE,IAAI;iBACjB;gBACD;oBACE,IAAI,EAAE,eAAe;oBACrB,IAAI,EAAE,MAAM;oBACZ,UAAU,EAAE,IAAI;iBACjB;gBACD;oBACE,IAAI,EAAE,kBAAkB;oBACxB,IAAI,EAAE,MAAM;oBACZ,UAAU,EAAE,IAAI;iBACjB;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,KAAK;oBACX,OAAO,EAAE,CAAC;oBACV,UAAU,EAAE,KAAK;iBAClB;gBACD;oBACE,IAAI,EAAE,eAAe;oBACrB,IAAI,EAAE,WAAW;oBACjB,UAAU,EAAE,IAAI;iBACjB;gBACD;oBACE,IAAI,EAAE,aAAa;oBACnB,IAAI,EAAE,WAAW;oBACjB,UAAU,EAAE,IAAI;iBACjB;gBACD;oBACE,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,mBAAmB;oBAC5B,UAAU,EAAE,KAAK;iBAClB;gBACD;oBACE,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,mBAAmB;oBAC5B,QAAQ,EAAE,mBAAmB;oBAC7B,UAAU,EAAE,KAAK;iBAClB;aACF;SACF,CAAC,EACF,IAAI,CACL,CAAC;QAEF,MAAM,WAAW,CAAC,WAAW,CAC3B,OAAO,EACP,IAAI,oBAAU,CAAC;YACb,IAAI,EAAE,kBAAkB;YACxB,WAAW,EAAE,CAAC,QAAQ,CAAC;SACxB,CAAC,CACH,CAAC;QAEF,MAAM,WAAW,CAAC,WAAW,CAC3B,OAAO,EACP,IAAI,oBAAU,CAAC;YACb,IAAI,EAAE,yBAAyB;YAC/B,WAAW,EAAE,CAAC,eAAe,CAAC;SAC/B,CAAC,CACH,CAAC;QAEF,MAAM,WAAW,CAAC,WAAW,CAC3B,OAAO,EACP,IAAI,oBAAU,CAAC;YACb,IAAI,EAAE,uBAAuB;YAC7B,WAAW,EAAE,CAAC,aAAa,CAAC;SAC7B,CAAC,CACH,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,MAAM,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;CACF;AA5GD,sEA4GC"}
@@ -0,0 +1,10 @@
1
+ import { Page } from '../entities/page.entity';
2
+ import { CreatePagesTable1700000000000 } from './1700000000000-CreatePagesTable';
3
+ export declare const PagesMigrationConfig: {
4
+ entities: (typeof Page)[];
5
+ migrations: (typeof CreatePagesTable1700000000000)[];
6
+ migrationsTableName: string;
7
+ };
8
+ export { CreatePagesTable1700000000000 };
9
+ export { Page };
10
+ //# sourceMappingURL=migration.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.config.d.ts","sourceRoot":"","sources":["../../src/migrations/migration.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAMjF,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAC;AAKF,OAAO,EAAE,6BAA6B,EAAE,CAAC;AAKzC,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Page = exports.CreatePagesTable1700000000000 = exports.PagesMigrationConfig = void 0;
4
+ const page_entity_1 = require("../entities/page.entity");
5
+ Object.defineProperty(exports, "Page", { enumerable: true, get: function () { return page_entity_1.Page; } });
6
+ const _1700000000000_CreatePagesTable_1 = require("./1700000000000-CreatePagesTable");
7
+ Object.defineProperty(exports, "CreatePagesTable1700000000000", { enumerable: true, get: function () { return _1700000000000_CreatePagesTable_1.CreatePagesTable1700000000000; } });
8
+ exports.PagesMigrationConfig = {
9
+ entities: [page_entity_1.Page],
10
+ migrations: [_1700000000000_CreatePagesTable_1.CreatePagesTable1700000000000],
11
+ migrationsTableName: 'migrations',
12
+ };
13
+ //# sourceMappingURL=migration.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration.config.js","sourceRoot":"","sources":["../../src/migrations/migration.config.ts"],"names":[],"mappings":";;;AAAA,yDAA+C;AAqBtC,qFArBA,kBAAI,OAqBA;AApBb,sFAAiF;AAexE,8GAfA,+DAA6B,OAeA;AATzB,QAAA,oBAAoB,GAAG;IAClC,QAAQ,EAAE,CAAC,kBAAI,CAAC;IAChB,UAAU,EAAE,CAAC,+DAA6B,CAAC;IAC3C,mBAAmB,EAAE,YAAY;CAClC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uecsio/pages-api",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "A reusable NestJS API Pages module for content management",
5
5
  "keywords": [
6
6
  "nestjs",
@@ -29,26 +29,26 @@
29
29
  "clean": "rimraf dist"
30
30
  },
31
31
  "peerDependencies": {
32
- "@nestjs/common": "^10.0.0",
33
- "@nestjs/core": "^10.0.0",
34
- "@nestjs/typeorm": "^10.0.0",
32
+ "@nestjs/common": "^11.0.0",
33
+ "@nestjs/core": "^11.0.0",
34
+ "@nestjs/typeorm": "^11.0.0",
35
35
  "typeorm": "^0.3.0",
36
36
  "class-validator": "^0.14.0",
37
37
  "class-transformer": "^0.5.1",
38
38
  "@nestjs-library/crud": "^0.13.1"
39
39
  },
40
40
  "devDependencies": {
41
- "@nestjs/common": "^10.0.0",
42
- "@nestjs/core": "^10.0.0",
43
- "@nestjs/testing": "^10.0.0",
44
- "@nestjs/typeorm": "^10.0.0",
45
- "@types/jest": "^29.0.0",
46
- "@types/node": "^20.0.0",
47
- "jest": "^29.0.0",
48
- "ts-jest": "^29.0.0",
49
- "typescript": "^5.0.0",
50
- "typeorm": "^0.3.0",
51
- "class-validator": "^0.14.0",
41
+ "@nestjs/common": "^11.0.0",
42
+ "@nestjs/core": "^11.0.0",
43
+ "@nestjs/testing": "^11.0.0",
44
+ "@nestjs/typeorm": "^11.0.0",
45
+ "@types/jest": "^30.0.0",
46
+ "@types/node": "^22.0.0",
47
+ "jest": "^30.0.0",
48
+ "ts-jest": "^29.2.5",
49
+ "typescript": "^5.7.3",
50
+ "typeorm": "^0.3.26",
51
+ "class-validator": "^0.14.2",
52
52
  "class-transformer": "^0.5.1",
53
53
  "@nestjs-library/crud": "^0.13.1",
54
54
  "rimraf": "^5.0.0"