@atlashub/smartstack-mcp 1.9.0 → 1.13.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/dist/index.js +240 -140
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/migrations/seed-permissions.cs.hbs +0 -108
package/package.json
CHANGED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
using Microsoft.EntityFrameworkCore.Migrations;
|
|
2
|
-
|
|
3
|
-
namespace SmartStack.Infrastructure.Data.Migrations.Core;
|
|
4
|
-
|
|
5
|
-
/// <summary>
|
|
6
|
-
/// Seed permissions generated from NavRoute controllers
|
|
7
|
-
/// Generated on {{timestamp}}
|
|
8
|
-
///
|
|
9
|
-
/// This migration seeds permissions following the SmartStack RBAC convention:
|
|
10
|
-
/// Permission Code: {navRoute}.{action}
|
|
11
|
-
///
|
|
12
|
-
/// Standard actions: read, create, update, delete
|
|
13
|
-
/// </summary>
|
|
14
|
-
public partial class {{migrationName}} : Migration
|
|
15
|
-
{
|
|
16
|
-
protected override void Up(MigrationBuilder migrationBuilder)
|
|
17
|
-
{
|
|
18
|
-
// ============================================================================
|
|
19
|
-
// PERMISSIONS SEED
|
|
20
|
-
// ============================================================================
|
|
21
|
-
// Convention: {context}.{application}.{module}.{action}
|
|
22
|
-
// Example: platform.administration.users.read
|
|
23
|
-
//
|
|
24
|
-
// These permissions are automatically generated from NavRoute attributes
|
|
25
|
-
// and should match the [Authorize(Policy="...")] attributes in controllers.
|
|
26
|
-
// ============================================================================
|
|
27
|
-
|
|
28
|
-
{{#each permissions}}
|
|
29
|
-
// {{category}} > {{name}} (Scope: {{scope}})
|
|
30
|
-
migrationBuilder.Sql(@"
|
|
31
|
-
IF NOT EXISTS (SELECT 1 FROM core.auth_Permissions WHERE Code = '{{code}}')
|
|
32
|
-
BEGIN
|
|
33
|
-
INSERT INTO core.auth_Permissions (
|
|
34
|
-
Id,
|
|
35
|
-
Code,
|
|
36
|
-
Scope,
|
|
37
|
-
Name,
|
|
38
|
-
Description,
|
|
39
|
-
IsDeleted,
|
|
40
|
-
CreatedAt,
|
|
41
|
-
UpdatedAt
|
|
42
|
-
)
|
|
43
|
-
VALUES (
|
|
44
|
-
NEWID(),
|
|
45
|
-
'{{code}}',
|
|
46
|
-
'{{scope}}',
|
|
47
|
-
'{{name}}',
|
|
48
|
-
'{{description}}',
|
|
49
|
-
0,
|
|
50
|
-
GETUTCDATE(),
|
|
51
|
-
GETUTCDATE()
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
PRINT 'Permission created: {{code}} (Scope: {{scope}})';
|
|
55
|
-
END
|
|
56
|
-
ELSE
|
|
57
|
-
BEGIN
|
|
58
|
-
-- Update existing permission (in case name/description/scope changed)
|
|
59
|
-
UPDATE core.auth_Permissions
|
|
60
|
-
SET
|
|
61
|
-
Name = '{{name}}',
|
|
62
|
-
Description = '{{description}}',
|
|
63
|
-
Scope = '{{scope}}',
|
|
64
|
-
UpdatedAt = GETUTCDATE()
|
|
65
|
-
WHERE Code = '{{code}}' AND IsDeleted = 0;
|
|
66
|
-
|
|
67
|
-
PRINT 'Permission updated: {{code}}';
|
|
68
|
-
END
|
|
69
|
-
");
|
|
70
|
-
|
|
71
|
-
{{/each}}
|
|
72
|
-
|
|
73
|
-
// ============================================================================
|
|
74
|
-
// SUMMARY
|
|
75
|
-
// ============================================================================
|
|
76
|
-
migrationBuilder.Sql(@"
|
|
77
|
-
PRINT '========================================';
|
|
78
|
-
PRINT 'Permissions Seed Complete';
|
|
79
|
-
PRINT 'Total permissions: {{permissions.length}}';
|
|
80
|
-
PRINT '========================================';
|
|
81
|
-
");
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
protected override void Down(MigrationBuilder migrationBuilder)
|
|
85
|
-
{
|
|
86
|
-
// ============================================================================
|
|
87
|
-
// ROLLBACK - Remove seeded permissions
|
|
88
|
-
// ============================================================================
|
|
89
|
-
// WARNING: This will remove permissions from the database.
|
|
90
|
-
// If any roles are using these permissions, they will be orphaned.
|
|
91
|
-
// Consider soft-delete (IsDeleted = 1) instead of hard delete.
|
|
92
|
-
// ============================================================================
|
|
93
|
-
|
|
94
|
-
{{#each permissions}}
|
|
95
|
-
// Remove: {{code}}
|
|
96
|
-
migrationBuilder.Sql(@"
|
|
97
|
-
UPDATE core.auth_Permissions
|
|
98
|
-
SET IsDeleted = 1, UpdatedAt = GETUTCDATE()
|
|
99
|
-
WHERE Code = '{{code}}';
|
|
100
|
-
");
|
|
101
|
-
|
|
102
|
-
{{/each}}
|
|
103
|
-
|
|
104
|
-
migrationBuilder.Sql(@"
|
|
105
|
-
PRINT 'Permissions rollback complete';
|
|
106
|
-
");
|
|
107
|
-
}
|
|
108
|
-
}
|