@eduardbar/drift 1.2.0 → 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/.github/workflows/publish-vscode.yml +3 -3
- package/.github/workflows/publish.yml +3 -3
- package/.github/workflows/review-pr.yml +98 -6
- package/AGENTS.md +6 -0
- package/README.md +160 -10
- package/ROADMAP.md +6 -5
- package/dist/analyzer.d.ts +2 -2
- package/dist/analyzer.js +420 -159
- package/dist/benchmark.d.ts +2 -0
- package/dist/benchmark.js +185 -0
- package/dist/cli.js +453 -62
- package/dist/diff.js +74 -10
- package/dist/git.js +12 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -1
- package/dist/plugins.d.ts +2 -1
- package/dist/plugins.js +177 -28
- package/dist/printer.js +4 -0
- package/dist/review.js +2 -2
- package/dist/rules/comments.js +2 -2
- package/dist/rules/complexity.js +2 -7
- package/dist/rules/nesting.js +3 -13
- package/dist/rules/phase0-basic.js +10 -10
- package/dist/rules/shared.d.ts +2 -0
- package/dist/rules/shared.js +27 -3
- package/dist/saas.d.ts +143 -7
- package/dist/saas.js +478 -37
- package/dist/trust-kpi.d.ts +9 -0
- package/dist/trust-kpi.js +445 -0
- package/dist/trust.d.ts +65 -0
- package/dist/trust.js +571 -0
- package/dist/types.d.ts +154 -0
- package/docs/PRD.md +187 -109
- package/docs/plugin-contract.md +61 -0
- package/docs/trust-core-release-checklist.md +55 -0
- package/package.json +5 -3
- package/src/analyzer.ts +484 -155
- package/src/benchmark.ts +244 -0
- package/src/cli.ts +562 -79
- package/src/diff.ts +75 -10
- package/src/git.ts +16 -0
- package/src/index.ts +48 -0
- package/src/plugins.ts +354 -26
- package/src/printer.ts +4 -0
- package/src/review.ts +2 -2
- package/src/rules/comments.ts +2 -2
- package/src/rules/complexity.ts +2 -7
- package/src/rules/nesting.ts +3 -13
- package/src/rules/phase0-basic.ts +11 -12
- package/src/rules/shared.ts +31 -3
- package/src/saas.ts +641 -43
- package/src/trust-kpi.ts +518 -0
- package/src/trust.ts +774 -0
- package/src/types.ts +171 -0
- package/tests/diff.test.ts +124 -0
- package/tests/new-features.test.ts +71 -0
- package/tests/plugins.test.ts +219 -0
- package/tests/rules.test.ts +23 -1
- package/tests/saas-foundation.test.ts +358 -1
- package/tests/trust-kpi.test.ts +120 -0
- package/tests/trust.test.ts +584 -0
package/dist/saas.d.ts
CHANGED
|
@@ -4,14 +4,26 @@ export interface SaasPolicy {
|
|
|
4
4
|
maxRunsPerWorkspacePerMonth: number;
|
|
5
5
|
maxReposPerWorkspace: number;
|
|
6
6
|
retentionDays: number;
|
|
7
|
+
strictActorEnforcement: boolean;
|
|
8
|
+
maxWorkspacesPerOrganizationByPlan: Record<SaasPlan, number>;
|
|
7
9
|
}
|
|
10
|
+
export type SaasRole = 'owner' | 'member' | 'viewer';
|
|
11
|
+
export type SaasPlan = 'free' | 'sponsor' | 'team' | 'business';
|
|
8
12
|
export interface SaasUser {
|
|
9
13
|
id: string;
|
|
10
14
|
createdAt: string;
|
|
11
15
|
lastSeenAt: string;
|
|
12
16
|
}
|
|
17
|
+
export interface SaasOrganization {
|
|
18
|
+
id: string;
|
|
19
|
+
plan: SaasPlan;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
lastSeenAt: string;
|
|
22
|
+
workspaceIds: string[];
|
|
23
|
+
}
|
|
13
24
|
export interface SaasWorkspace {
|
|
14
25
|
id: string;
|
|
26
|
+
organizationId: string;
|
|
15
27
|
createdAt: string;
|
|
16
28
|
lastSeenAt: string;
|
|
17
29
|
userIds: string[];
|
|
@@ -19,17 +31,39 @@ export interface SaasWorkspace {
|
|
|
19
31
|
}
|
|
20
32
|
export interface SaasRepo {
|
|
21
33
|
id: string;
|
|
34
|
+
organizationId: string;
|
|
22
35
|
workspaceId: string;
|
|
23
36
|
name: string;
|
|
24
37
|
createdAt: string;
|
|
25
38
|
lastSeenAt: string;
|
|
26
39
|
}
|
|
40
|
+
export interface SaasMembership {
|
|
41
|
+
id: string;
|
|
42
|
+
organizationId: string;
|
|
43
|
+
workspaceId: string;
|
|
44
|
+
userId: string;
|
|
45
|
+
role: SaasRole;
|
|
46
|
+
createdAt: string;
|
|
47
|
+
lastSeenAt: string;
|
|
48
|
+
}
|
|
49
|
+
export interface SaasPlanChange {
|
|
50
|
+
id: string;
|
|
51
|
+
organizationId: string;
|
|
52
|
+
fromPlan: SaasPlan;
|
|
53
|
+
toPlan: SaasPlan;
|
|
54
|
+
changedAt: string;
|
|
55
|
+
changedByUserId: string;
|
|
56
|
+
reason?: string;
|
|
57
|
+
}
|
|
27
58
|
export interface SaasSnapshot {
|
|
28
59
|
id: string;
|
|
29
60
|
createdAt: string;
|
|
30
61
|
scannedAt: string;
|
|
62
|
+
organizationId: string;
|
|
31
63
|
workspaceId: string;
|
|
32
64
|
userId: string;
|
|
65
|
+
role: SaasRole;
|
|
66
|
+
plan: SaasPlan;
|
|
33
67
|
repoId: string;
|
|
34
68
|
repoName: string;
|
|
35
69
|
targetPath: string;
|
|
@@ -46,9 +80,60 @@ export interface SaasStore {
|
|
|
46
80
|
version: number;
|
|
47
81
|
policy: SaasPolicy;
|
|
48
82
|
users: Record<string, SaasUser>;
|
|
83
|
+
organizations: Record<string, SaasOrganization>;
|
|
49
84
|
workspaces: Record<string, SaasWorkspace>;
|
|
85
|
+
memberships: Record<string, SaasMembership>;
|
|
50
86
|
repos: Record<string, SaasRepo>;
|
|
51
87
|
snapshots: SaasSnapshot[];
|
|
88
|
+
planChanges: SaasPlanChange[];
|
|
89
|
+
}
|
|
90
|
+
export type SaasOperation = 'snapshot:write' | 'snapshot:read' | 'summary:read' | 'billing:write' | 'billing:read';
|
|
91
|
+
export interface SaasPermissionContext {
|
|
92
|
+
operation: SaasOperation;
|
|
93
|
+
organizationId: string;
|
|
94
|
+
workspaceId?: string;
|
|
95
|
+
actorUserId?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface SaasPermissionResult {
|
|
98
|
+
actorRole?: SaasRole;
|
|
99
|
+
requiredRole: SaasRole;
|
|
100
|
+
}
|
|
101
|
+
export interface SaasEffectiveLimits {
|
|
102
|
+
plan: SaasPlan;
|
|
103
|
+
maxWorkspaces: number;
|
|
104
|
+
maxReposPerWorkspace: number;
|
|
105
|
+
maxRunsPerWorkspacePerMonth: number;
|
|
106
|
+
retentionDays: number;
|
|
107
|
+
}
|
|
108
|
+
export interface SaasOrganizationUsageSnapshot {
|
|
109
|
+
organizationId: string;
|
|
110
|
+
plan: SaasPlan;
|
|
111
|
+
capturedAt: string;
|
|
112
|
+
workspaceCount: number;
|
|
113
|
+
repoCount: number;
|
|
114
|
+
runCount: number;
|
|
115
|
+
runCountThisMonth: number;
|
|
116
|
+
}
|
|
117
|
+
export interface ChangeOrganizationPlanOptions {
|
|
118
|
+
organizationId: string;
|
|
119
|
+
actorUserId: string;
|
|
120
|
+
newPlan: SaasPlan;
|
|
121
|
+
reason?: string;
|
|
122
|
+
storeFile?: string;
|
|
123
|
+
policy?: SaasPolicyOverrides;
|
|
124
|
+
}
|
|
125
|
+
export interface SaasUsageQueryOptions {
|
|
126
|
+
organizationId: string;
|
|
127
|
+
month?: string;
|
|
128
|
+
storeFile?: string;
|
|
129
|
+
policy?: SaasPolicyOverrides;
|
|
130
|
+
actorUserId?: string;
|
|
131
|
+
}
|
|
132
|
+
export interface SaasPlanChangeQueryOptions {
|
|
133
|
+
organizationId: string;
|
|
134
|
+
storeFile?: string;
|
|
135
|
+
policy?: SaasPolicyOverrides;
|
|
136
|
+
actorUserId?: string;
|
|
52
137
|
}
|
|
53
138
|
export interface SaasSummary {
|
|
54
139
|
policy: SaasPolicy;
|
|
@@ -61,23 +146,74 @@ export interface SaasSummary {
|
|
|
61
146
|
thresholdReached: boolean;
|
|
62
147
|
freeUsersRemaining: number;
|
|
63
148
|
}
|
|
149
|
+
export interface SaasPolicyOverrides {
|
|
150
|
+
freeUserThreshold?: number;
|
|
151
|
+
maxRunsPerWorkspacePerMonth?: number;
|
|
152
|
+
maxReposPerWorkspace?: number;
|
|
153
|
+
retentionDays?: number;
|
|
154
|
+
strictActorEnforcement?: boolean;
|
|
155
|
+
maxWorkspacesPerOrganizationByPlan?: Partial<Record<SaasPlan, number>>;
|
|
156
|
+
}
|
|
157
|
+
export interface SaasQueryOptions {
|
|
158
|
+
storeFile?: string;
|
|
159
|
+
policy?: SaasPolicyOverrides;
|
|
160
|
+
organizationId?: string;
|
|
161
|
+
workspaceId?: string;
|
|
162
|
+
actorUserId?: string;
|
|
163
|
+
}
|
|
64
164
|
export interface IngestOptions {
|
|
165
|
+
organizationId?: string;
|
|
65
166
|
workspaceId: string;
|
|
66
167
|
userId: string;
|
|
168
|
+
role?: SaasRole;
|
|
169
|
+
plan?: SaasPlan;
|
|
67
170
|
repoName?: string;
|
|
171
|
+
actorUserId?: string;
|
|
68
172
|
storeFile?: string;
|
|
69
|
-
policy?:
|
|
173
|
+
policy?: SaasPolicyOverrides;
|
|
174
|
+
}
|
|
175
|
+
export declare class SaasPermissionError extends Error {
|
|
176
|
+
readonly code = "SAAS_PERMISSION_DENIED";
|
|
177
|
+
readonly operation: SaasOperation;
|
|
178
|
+
readonly organizationId: string;
|
|
179
|
+
readonly workspaceId?: string;
|
|
180
|
+
readonly actorUserId?: string;
|
|
181
|
+
readonly requiredRole: SaasRole;
|
|
182
|
+
readonly actorRole?: SaasRole;
|
|
183
|
+
constructor(context: SaasPermissionContext, requiredRole: SaasRole, actorRole?: SaasRole);
|
|
184
|
+
}
|
|
185
|
+
export declare class SaasActorRequiredError extends Error {
|
|
186
|
+
readonly code = "SAAS_ACTOR_REQUIRED";
|
|
187
|
+
readonly operation: SaasOperation;
|
|
188
|
+
readonly organizationId: string;
|
|
189
|
+
readonly workspaceId?: string;
|
|
190
|
+
constructor(context: SaasPermissionContext);
|
|
70
191
|
}
|
|
71
192
|
export declare const DEFAULT_SAAS_POLICY: SaasPolicy;
|
|
72
|
-
export declare function resolveSaasPolicy(policy?:
|
|
193
|
+
export declare function resolveSaasPolicy(policy?: SaasPolicyOverrides | DriftConfig['saas']): SaasPolicy;
|
|
73
194
|
export declare function defaultSaasStorePath(root?: string): string;
|
|
74
|
-
export declare function
|
|
75
|
-
export declare function
|
|
195
|
+
export declare function getRequiredRoleForOperation(operation: SaasOperation): SaasRole;
|
|
196
|
+
export declare function assertSaasPermission(context: SaasPermissionContext & {
|
|
76
197
|
storeFile?: string;
|
|
77
|
-
policy?:
|
|
78
|
-
}):
|
|
198
|
+
policy?: SaasPolicyOverrides;
|
|
199
|
+
}): SaasPermissionResult;
|
|
200
|
+
export declare function getSaasEffectiveLimits(input: {
|
|
201
|
+
plan: SaasPlan;
|
|
202
|
+
policy?: SaasPolicyOverrides;
|
|
203
|
+
}): SaasEffectiveLimits;
|
|
204
|
+
export declare function getOrganizationEffectiveLimits(options: {
|
|
205
|
+
organizationId: string;
|
|
206
|
+
storeFile?: string;
|
|
207
|
+
policy?: SaasPolicyOverrides;
|
|
208
|
+
}): SaasEffectiveLimits;
|
|
209
|
+
export declare function changeOrganizationPlan(options: ChangeOrganizationPlanOptions): SaasPlanChange;
|
|
210
|
+
export declare function listOrganizationPlanChanges(options: SaasPlanChangeQueryOptions): SaasPlanChange[];
|
|
211
|
+
export declare function getOrganizationUsageSnapshot(options: SaasUsageQueryOptions): SaasOrganizationUsageSnapshot;
|
|
212
|
+
export declare function ingestSnapshotFromReport(report: DriftReport, options: IngestOptions): SaasSnapshot;
|
|
213
|
+
export declare function listSaasSnapshots(options?: SaasQueryOptions): SaasSnapshot[];
|
|
214
|
+
export declare function getSaasSummary(options?: SaasQueryOptions): SaasSummary;
|
|
79
215
|
export declare function generateSaasDashboardHtml(options?: {
|
|
80
216
|
storeFile?: string;
|
|
81
|
-
policy?:
|
|
217
|
+
policy?: SaasPolicyOverrides;
|
|
82
218
|
}): string;
|
|
83
219
|
//# sourceMappingURL=saas.d.ts.map
|